lemon-project-template-glpk

changeset 9:33de93886c88 subpack-glpk

Import GLPK 4.47
author Alpar Juttner <alpar@cs.elte.hu>
date Sun, 06 Nov 2011 20:59:10 +0100
parents dda9b6665fde
children 5545663ca997
files deps/glpk/AUTHORS deps/glpk/COPYING deps/glpk/ChangeLog deps/glpk/INSTALL deps/glpk/Makefile.am deps/glpk/Makefile.in deps/glpk/Makefile_MMIX deps/glpk/NEWS deps/glpk/README deps/glpk/THANKS deps/glpk/aclocal.m4 deps/glpk/config.guess deps/glpk/config.h.in deps/glpk/config.sub deps/glpk/configure deps/glpk/configure.ac deps/glpk/depcomp deps/glpk/doc/cnfsat.pdf deps/glpk/doc/cnfsat.tex deps/glpk/doc/glpk.pdf deps/glpk/doc/glpk.tex deps/glpk/doc/glpk01.tex deps/glpk/doc/glpk02.tex deps/glpk/doc/glpk03.tex deps/glpk/doc/glpk04.tex deps/glpk/doc/glpk05.tex deps/glpk/doc/glpk06.tex deps/glpk/doc/glpk07.tex deps/glpk/doc/glpk08.tex deps/glpk/doc/glpk09.tex deps/glpk/doc/glpk10.tex deps/glpk/doc/glpk11.tex deps/glpk/doc/glpk12.tex deps/glpk/doc/glpk_faq.txt deps/glpk/doc/gmpl.pdf deps/glpk/doc/gmpl.tex deps/glpk/doc/graphs.pdf deps/glpk/doc/graphs.tex deps/glpk/doc/miplib2.txt deps/glpk/doc/miplib3.txt deps/glpk/doc/netlib.txt deps/glpk/doc/notes/dfeas.pdf deps/glpk/doc/notes/gomory.pdf deps/glpk/doc/notes/keller.pdf deps/glpk/doc/notes/scaling.pdf deps/glpk/doc/notes/updating.pdf deps/glpk/examples/INDEX deps/glpk/examples/Makefile.am deps/glpk/examples/Makefile.in deps/glpk/examples/assign.mod deps/glpk/examples/bpp.mod deps/glpk/examples/cal.mod deps/glpk/examples/cf12a.mod deps/glpk/examples/cf12b.mod deps/glpk/examples/cflsq.mod deps/glpk/examples/color.mod deps/glpk/examples/cplex/README deps/glpk/examples/cplex/concorde.txt deps/glpk/examples/cplex/cplex.c deps/glpk/examples/cplex/cplex.h deps/glpk/examples/cpp.mod deps/glpk/examples/crypto.mod deps/glpk/examples/csv/distances.csv deps/glpk/examples/csv/markets.csv deps/glpk/examples/csv/parameters.csv deps/glpk/examples/csv/plants.csv deps/glpk/examples/csv/transp_csv.mod deps/glpk/examples/dbf/ForestMgt_Model_I_GIS_dbf.mod deps/glpk/examples/dbf/Forest_Cost.dbf deps/glpk/examples/dbf/NetRev_Table.dbf deps/glpk/examples/dbf/README deps/glpk/examples/dbf/TCost_Table.dbf deps/glpk/examples/dbf/Yield_Table_Vol.dbf deps/glpk/examples/dbf/cultural_pres.dbf deps/glpk/examples/dbf/mgt_year.dbf deps/glpk/examples/dbf/stands.dbf deps/glpk/examples/dbf/standtype.dbf deps/glpk/examples/dea.mod deps/glpk/examples/diet.mod deps/glpk/examples/dist.mod deps/glpk/examples/egypt.mod deps/glpk/examples/fctp.mod deps/glpk/examples/food.mod deps/glpk/examples/food2.mod deps/glpk/examples/gap.mod deps/glpk/examples/glpsol.c deps/glpk/examples/graph.mod deps/glpk/examples/hashi.mod deps/glpk/examples/huge.mod deps/glpk/examples/iptsamp.c deps/glpk/examples/jssp.mod deps/glpk/examples/magic.mod deps/glpk/examples/maxcut.mod deps/glpk/examples/maxflow.mod deps/glpk/examples/mfasp.mod deps/glpk/examples/mfvsp.mod deps/glpk/examples/min01ks.mod deps/glpk/examples/misp.mod deps/glpk/examples/money.mod deps/glpk/examples/mplsamp1.c deps/glpk/examples/mplsamp2.c deps/glpk/examples/murtagh.mps deps/glpk/examples/mvcp.mod deps/glpk/examples/netgen.c deps/glpk/examples/numbrix.mod deps/glpk/examples/pbn/9dom.dat deps/glpk/examples/pbn/README deps/glpk/examples/pbn/bucks.dat deps/glpk/examples/pbn/cat.dat deps/glpk/examples/pbn/dancer.dat deps/glpk/examples/pbn/dragon.dat deps/glpk/examples/pbn/edge.dat deps/glpk/examples/pbn/forever.dat deps/glpk/examples/pbn/knot.dat deps/glpk/examples/pbn/light.dat deps/glpk/examples/pbn/mum.dat deps/glpk/examples/pbn/pbn.mod deps/glpk/examples/pbn/pbn.pdf deps/glpk/examples/pbn/pbn.tex deps/glpk/examples/pbn/petro.dat deps/glpk/examples/pbn/skid.dat deps/glpk/examples/pbn/swing.dat deps/glpk/examples/plan.lp deps/glpk/examples/plan.mod deps/glpk/examples/plan.mps deps/glpk/examples/prod.mod deps/glpk/examples/qfit.mod deps/glpk/examples/queens.mod deps/glpk/examples/samp1.mps deps/glpk/examples/samp2.mps deps/glpk/examples/sample.asn deps/glpk/examples/sample.c deps/glpk/examples/sample.clq deps/glpk/examples/sample.cnf deps/glpk/examples/sample.col deps/glpk/examples/sample.max deps/glpk/examples/sample.min deps/glpk/examples/sat.mod deps/glpk/examples/shiftcover.mod deps/glpk/examples/shikaku.mod deps/glpk/examples/sorting.mod deps/glpk/examples/spp.mod deps/glpk/examples/spxsamp1.c deps/glpk/examples/spxsamp2.c deps/glpk/examples/sql/README deps/glpk/examples/sql/mysql_setup.sh deps/glpk/examples/sql/sudoku.sql deps/glpk/examples/sql/sudoku_mysql.mod deps/glpk/examples/sql/sudoku_odbc.mod deps/glpk/examples/sql/transp.sql deps/glpk/examples/sql/transp_mysql.mod deps/glpk/examples/sql/transp_odbc.mod deps/glpk/examples/stigler.mod deps/glpk/examples/sudoku.dat deps/glpk/examples/sudoku.mod deps/glpk/examples/t1.cs deps/glpk/examples/tas.mod deps/glpk/examples/todd.mod deps/glpk/examples/train.mod deps/glpk/examples/transp.mod deps/glpk/examples/trick.mod deps/glpk/examples/tsp.mod deps/glpk/examples/xyacfs.mod deps/glpk/examples/yacfs.mod deps/glpk/examples/zebra.mod deps/glpk/install-sh deps/glpk/ltmain.sh deps/glpk/m4/libtool.m4 deps/glpk/m4/ltoptions.m4 deps/glpk/m4/ltsugar.m4 deps/glpk/m4/ltversion.m4 deps/glpk/m4/lt~obsolete.m4 deps/glpk/missing deps/glpk/src/Makefile.am deps/glpk/src/Makefile.in deps/glpk/src/amd/COPYING deps/glpk/src/amd/README deps/glpk/src/amd/amd.h deps/glpk/src/amd/amd_1.c deps/glpk/src/amd/amd_2.c deps/glpk/src/amd/amd_aat.c deps/glpk/src/amd/amd_control.c deps/glpk/src/amd/amd_defaults.c deps/glpk/src/amd/amd_dump.c deps/glpk/src/amd/amd_info.c deps/glpk/src/amd/amd_internal.h deps/glpk/src/amd/amd_order.c deps/glpk/src/amd/amd_post_tree.c deps/glpk/src/amd/amd_postorder.c deps/glpk/src/amd/amd_preprocess.c deps/glpk/src/amd/amd_valid.c deps/glpk/src/colamd/COPYING deps/glpk/src/colamd/README deps/glpk/src/colamd/colamd.c deps/glpk/src/colamd/colamd.h deps/glpk/src/glpapi.h deps/glpk/src/glpapi01.c deps/glpk/src/glpapi02.c deps/glpk/src/glpapi03.c deps/glpk/src/glpapi04.c deps/glpk/src/glpapi05.c deps/glpk/src/glpapi06.c deps/glpk/src/glpapi07.c deps/glpk/src/glpapi08.c deps/glpk/src/glpapi09.c deps/glpk/src/glpapi10.c deps/glpk/src/glpapi11.c deps/glpk/src/glpapi12.c deps/glpk/src/glpapi13.c deps/glpk/src/glpapi14.c deps/glpk/src/glpapi15.c deps/glpk/src/glpapi16.c deps/glpk/src/glpapi17.c deps/glpk/src/glpapi18.c deps/glpk/src/glpapi19.c deps/glpk/src/glpapi20.c deps/glpk/src/glpapi21.c deps/glpk/src/glpavl.c deps/glpk/src/glpavl.h deps/glpk/src/glpbfd.c deps/glpk/src/glpbfd.h deps/glpk/src/glpbfx.c deps/glpk/src/glpbfx.h deps/glpk/src/glpcpx.c deps/glpk/src/glpdmp.c deps/glpk/src/glpdmp.h deps/glpk/src/glpdmx.c deps/glpk/src/glpenv.h deps/glpk/src/glpenv01.c deps/glpk/src/glpenv02.c deps/glpk/src/glpenv03.c deps/glpk/src/glpenv04.c deps/glpk/src/glpenv05.c deps/glpk/src/glpenv06.c deps/glpk/src/glpenv07.c deps/glpk/src/glpenv08.c deps/glpk/src/glpfhv.c deps/glpk/src/glpfhv.h deps/glpk/src/glpgmp.c deps/glpk/src/glpgmp.h deps/glpk/src/glphbm.c deps/glpk/src/glphbm.h deps/glpk/src/glpini01.c deps/glpk/src/glpini02.c deps/glpk/src/glpios.h deps/glpk/src/glpios01.c deps/glpk/src/glpios02.c deps/glpk/src/glpios03.c deps/glpk/src/glpios04.c deps/glpk/src/glpios05.c deps/glpk/src/glpios06.c deps/glpk/src/glpios07.c deps/glpk/src/glpios08.c deps/glpk/src/glpios09.c deps/glpk/src/glpios10.c deps/glpk/src/glpios11.c deps/glpk/src/glpios12.c deps/glpk/src/glpipm.c deps/glpk/src/glpipm.h deps/glpk/src/glpk.h deps/glpk/src/glplib.h deps/glpk/src/glplib01.c deps/glpk/src/glplib02.c deps/glpk/src/glplib03.c deps/glpk/src/glplpf.c deps/glpk/src/glplpf.h deps/glpk/src/glplpx01.c deps/glpk/src/glplpx02.c deps/glpk/src/glplpx03.c deps/glpk/src/glpluf.c deps/glpk/src/glpluf.h deps/glpk/src/glplux.c deps/glpk/src/glplux.h deps/glpk/src/glpmat.c deps/glpk/src/glpmat.h deps/glpk/src/glpmpl.h deps/glpk/src/glpmpl01.c deps/glpk/src/glpmpl02.c deps/glpk/src/glpmpl03.c deps/glpk/src/glpmpl04.c deps/glpk/src/glpmpl05.c deps/glpk/src/glpmpl06.c deps/glpk/src/glpmps.c deps/glpk/src/glpnet.h deps/glpk/src/glpnet01.c deps/glpk/src/glpnet02.c deps/glpk/src/glpnet03.c deps/glpk/src/glpnet04.c deps/glpk/src/glpnet05.c deps/glpk/src/glpnet06.c deps/glpk/src/glpnet07.c deps/glpk/src/glpnet08.c deps/glpk/src/glpnet09.c deps/glpk/src/glpnpp.h deps/glpk/src/glpnpp01.c deps/glpk/src/glpnpp02.c deps/glpk/src/glpnpp03.c deps/glpk/src/glpnpp04.c deps/glpk/src/glpnpp05.c deps/glpk/src/glpnpp06.c deps/glpk/src/glpqmd.c deps/glpk/src/glpqmd.h deps/glpk/src/glprgr.c deps/glpk/src/glprgr.h deps/glpk/src/glprng.h deps/glpk/src/glprng01.c deps/glpk/src/glprng02.c deps/glpk/src/glpscf.c deps/glpk/src/glpscf.h deps/glpk/src/glpscl.c deps/glpk/src/glpsdf.c deps/glpk/src/glpspm.c deps/glpk/src/glpspm.h deps/glpk/src/glpspx.h deps/glpk/src/glpspx01.c deps/glpk/src/glpspx02.c deps/glpk/src/glpsql.c deps/glpk/src/glpsql.h deps/glpk/src/glpssx.h deps/glpk/src/glpssx01.c deps/glpk/src/glpssx02.c deps/glpk/src/glpstd.h deps/glpk/src/glptsp.c deps/glpk/src/glptsp.h deps/glpk/src/minisat/LICENSE deps/glpk/src/minisat/README deps/glpk/src/minisat/minisat.c deps/glpk/src/minisat/minisat.h deps/glpk/src/zlib/README deps/glpk/src/zlib/adler32.c deps/glpk/src/zlib/compress.c deps/glpk/src/zlib/crc32.c deps/glpk/src/zlib/crc32.h deps/glpk/src/zlib/deflate.c deps/glpk/src/zlib/deflate.h deps/glpk/src/zlib/gzclose.c deps/glpk/src/zlib/gzguts.h deps/glpk/src/zlib/gzlib.c deps/glpk/src/zlib/gzread.c deps/glpk/src/zlib/gzwrite.c deps/glpk/src/zlib/infback.c deps/glpk/src/zlib/inffast.c deps/glpk/src/zlib/inffast.h deps/glpk/src/zlib/inffixed.h deps/glpk/src/zlib/inflate.c deps/glpk/src/zlib/inflate.h deps/glpk/src/zlib/inftrees.c deps/glpk/src/zlib/inftrees.h deps/glpk/src/zlib/trees.c deps/glpk/src/zlib/trees.h deps/glpk/src/zlib/uncompr.c deps/glpk/src/zlib/zconf.h deps/glpk/src/zlib/zio.c deps/glpk/src/zlib/zio.h deps/glpk/src/zlib/zlib.h deps/glpk/src/zlib/zutil.c deps/glpk/src/zlib/zutil.h deps/glpk/w32/Build_GLPK_with_VC10.bat deps/glpk/w32/Build_GLPK_with_VC10_DLL.bat deps/glpk/w32/Build_GLPK_with_VC9.bat deps/glpk/w32/Build_GLPK_with_VC9_DLL.bat deps/glpk/w32/Makefile_VC deps/glpk/w32/Makefile_VC_DLL deps/glpk/w32/config_VC deps/glpk/w32/glpk_4_47.def deps/glpk/w32/readme.txt deps/glpk/w64/Build_GLPK_with_VC10.bat deps/glpk/w64/Build_GLPK_with_VC10_DLL.bat deps/glpk/w64/Build_GLPK_with_VC9.bat deps/glpk/w64/Build_GLPK_with_VC9_DLL.bat deps/glpk/w64/config_VC deps/glpk/w64/glpk_4_47.def deps/glpk/w64/makefile_VC deps/glpk/w64/makefile_VC_DLL deps/glpk/w64/readme.txt
diffstat 375 files changed, 196430 insertions(+), 0 deletions(-) [+]
line diff
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/deps/glpk/AUTHORS	Sun Nov 06 20:59:10 2011 +0100
     1.3 @@ -0,0 +1,33 @@
     1.4 +The GLPK package was developed and programmed by Andrew Makhorin,
     1.5 +Department for Applied Informatics, Moscow Aviation Institute, Moscow,
     1.6 +Russia.
     1.7 +
     1.8 +E-mail:         <mao@gnu.org>
     1.9 +
    1.10 +Paper mail:     125871, Russia, Moscow, Volokolamskoye sh., 4,
    1.11 +                Moscow Aviation Institute, Andrew O. Makhorin
    1.12 +
    1.13 +-----BEGIN PGP PUBLIC KEY BLOCK-----
    1.14 +Version: GnuPG v1.2.2 (MingW32)
    1.15 +
    1.16 +mQGiBD8UdT8RBAC6yWYxoa1b7U973J0jBuQpgZnhXlGJJpMZgAW9efDBD17vhkJm
    1.17 +hPVOQBKRUeOOLcW3/a7NMoNLMdmF1Rgz1FPVy3RgBDsYj4Sp4RBCsX/o0xXh+jxe
    1.18 +gncr4bdN0Ruk03pezVtLi9oYygdxfI51SsjZ2vwYP6BhMwv+xrIgcnc4qwCgoCit
    1.19 +26mTd0FoGOmsQuipo6X5LaUD/1l7NqFIjiGdWthyG3TqsiK5Ew7xF3fLEABXKPjb
    1.20 +PMRTMucX8XXHmW8RUD1vP1uGDnEn6s+fjc3/RtaqKjqGMdLt4XgHQkImaVguNpSS
    1.21 +IxN3LaK600BgAbwSd1bomRqWNlczAM7469VvGG9ASpCBveUUrqwerHZcUbvngL62
    1.22 +pIcqA/41dO0xYrOTqMRhuguYMgHL2xbwB2Aj2TqRwBm697DIS25B9nE+8UsbjGRx
    1.23 +q3EmeuHeZ5kN5RbESXkGUB8whIcYxvH16HRNmM1ZjmFoBVL2Z6S2gpa2ZUqsq7BZ
    1.24 +s+hriElm3dfOQCt79/o852uKWu5bSjw2yiemVA2T8tG4OoN6DrQjQW5kcmV3IE1h
    1.25 +a2hvcmluIDxtYW9AbWFpMi5yY25ldC5ydT6IWwQTEQIAGwUCPxR1PwYLCQgHAwID
    1.26 +FQIDAxYCAQIeAQIXgAAKCRDRe/IwWYHoGKpHAJ44MmzWKr8OiTc0Bb6/RD56aekp
    1.27 +3wCdGznQMCfWFkehQPbeNaB5yFIs+8a5AQ0EPxR1UBAEAO3U3H5M0iYv06C4kKty
    1.28 +6ReWyYH4CzMAfp2lPVUKzRSjPtoAJ6SkrBSKMT+U+DahxZ4K4HbinvHq3uvlwWax
    1.29 +xw0wKxJl4oY6EGE1Jqn3B//Ak47RaNMnrs9V739WT1YNRpQvh4wOCeMekBzksf43
    1.30 +hm4dSV4PMQkLmrEeG2+BYaZnAAMFA/4tVHhjGRkxzcTcfHCB+Yo3PXeIQMuIs00c
    1.31 +VKCrNReLni/3BWZC0w9tFzZSdz+URXefPWDGuAC16vLCVOD06NcIQGutPe189dUn
    1.32 +Kf9Bl6qc9DyWsxSTdF/PbLqcLfEe9g7fHhIwdY+w/hSq2n3NEURMzHiMT1U3CvHd
    1.33 +As5IzV/yD4hGBBgRAgAGBQI/FHVQAAoJENF78jBZgegYRZEAmwReJkMSrbs0EQs2
    1.34 +wjyTCMd5KDh3AKCR2/RvVad9RT3ShYnUiPPYTL2/Nw==
    1.35 +=OfLQ
    1.36 +-----END PGP PUBLIC KEY BLOCK-----
     2.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     2.2 +++ b/deps/glpk/COPYING	Sun Nov 06 20:59:10 2011 +0100
     2.3 @@ -0,0 +1,676 @@
     2.4 +
     2.5 +                    GNU GENERAL PUBLIC LICENSE
     2.6 +                       Version 3, 29 June 2007
     2.7 +
     2.8 + Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
     2.9 + Everyone is permitted to copy and distribute verbatim copies
    2.10 + of this license document, but changing it is not allowed.
    2.11 +
    2.12 +                            Preamble
    2.13 +
    2.14 +  The GNU General Public License is a free, copyleft license for
    2.15 +software and other kinds of works.
    2.16 +
    2.17 +  The licenses for most software and other practical works are designed
    2.18 +to take away your freedom to share and change the works.  By contrast,
    2.19 +the GNU General Public License is intended to guarantee your freedom to
    2.20 +share and change all versions of a program--to make sure it remains free
    2.21 +software for all its users.  We, the Free Software Foundation, use the
    2.22 +GNU General Public License for most of our software; it applies also to
    2.23 +any other work released this way by its authors.  You can apply it to
    2.24 +your programs, too.
    2.25 +
    2.26 +  When we speak of free software, we are referring to freedom, not
    2.27 +price.  Our General Public Licenses are designed to make sure that you
    2.28 +have the freedom to distribute copies of free software (and charge for
    2.29 +them if you wish), that you receive source code or can get it if you
    2.30 +want it, that you can change the software or use pieces of it in new
    2.31 +free programs, and that you know you can do these things.
    2.32 +
    2.33 +  To protect your rights, we need to prevent others from denying you
    2.34 +these rights or asking you to surrender the rights.  Therefore, you have
    2.35 +certain responsibilities if you distribute copies of the software, or if
    2.36 +you modify it: responsibilities to respect the freedom of others.
    2.37 +
    2.38 +  For example, if you distribute copies of such a program, whether
    2.39 +gratis or for a fee, you must pass on to the recipients the same
    2.40 +freedoms that you received.  You must make sure that they, too, receive
    2.41 +or can get the source code.  And you must show them these terms so they
    2.42 +know their rights.
    2.43 +
    2.44 +  Developers that use the GNU GPL protect your rights with two steps:
    2.45 +(1) assert copyright on the software, and (2) offer you this License
    2.46 +giving you legal permission to copy, distribute and/or modify it.
    2.47 +
    2.48 +  For the developers' and authors' protection, the GPL clearly explains
    2.49 +that there is no warranty for this free software.  For both users' and
    2.50 +authors' sake, the GPL requires that modified versions be marked as
    2.51 +changed, so that their problems will not be attributed erroneously to
    2.52 +authors of previous versions.
    2.53 +
    2.54 +  Some devices are designed to deny users access to install or run
    2.55 +modified versions of the software inside them, although the manufacturer
    2.56 +can do so.  This is fundamentally incompatible with the aim of
    2.57 +protecting users' freedom to change the software.  The systematic
    2.58 +pattern of such abuse occurs in the area of products for individuals to
    2.59 +use, which is precisely where it is most unacceptable.  Therefore, we
    2.60 +have designed this version of the GPL to prohibit the practice for those
    2.61 +products.  If such problems arise substantially in other domains, we
    2.62 +stand ready to extend this provision to those domains in future versions
    2.63 +of the GPL, as needed to protect the freedom of users.
    2.64 +
    2.65 +  Finally, every program is threatened constantly by software patents.
    2.66 +States should not allow patents to restrict development and use of
    2.67 +software on general-purpose computers, but in those that do, we wish to
    2.68 +avoid the special danger that patents applied to a free program could
    2.69 +make it effectively proprietary.  To prevent this, the GPL assures that
    2.70 +patents cannot be used to render the program non-free.
    2.71 +
    2.72 +  The precise terms and conditions for copying, distribution and
    2.73 +modification follow.
    2.74 +
    2.75 +                       TERMS AND CONDITIONS
    2.76 +
    2.77 +  0. Definitions.
    2.78 +
    2.79 +  "This License" refers to version 3 of the GNU General Public License.
    2.80 +
    2.81 +  "Copyright" also means copyright-like laws that apply to other kinds of
    2.82 +works, such as semiconductor masks.
    2.83 +
    2.84 +  "The Program" refers to any copyrightable work licensed under this
    2.85 +License.  Each licensee is addressed as "you".  "Licensees" and
    2.86 +"recipients" may be individuals or organizations.
    2.87 +
    2.88 +  To "modify" a work means to copy from or adapt all or part of the work
    2.89 +in a fashion requiring copyright permission, other than the making of an
    2.90 +exact copy.  The resulting work is called a "modified version" of the
    2.91 +earlier work or a work "based on" the earlier work.
    2.92 +
    2.93 +  A "covered work" means either the unmodified Program or a work based
    2.94 +on the Program.
    2.95 +
    2.96 +  To "propagate" a work means to do anything with it that, without
    2.97 +permission, would make you directly or secondarily liable for
    2.98 +infringement under applicable copyright law, except executing it on a
    2.99 +computer or modifying a private copy.  Propagation includes copying,
   2.100 +distribution (with or without modification), making available to the
   2.101 +public, and in some countries other activities as well.
   2.102 +
   2.103 +  To "convey" a work means any kind of propagation that enables other
   2.104 +parties to make or receive copies.  Mere interaction with a user through
   2.105 +a computer network, with no transfer of a copy, is not conveying.
   2.106 +
   2.107 +  An interactive user interface displays "Appropriate Legal Notices"
   2.108 +to the extent that it includes a convenient and prominently visible
   2.109 +feature that (1) displays an appropriate copyright notice, and (2)
   2.110 +tells the user that there is no warranty for the work (except to the
   2.111 +extent that warranties are provided), that licensees may convey the
   2.112 +work under this License, and how to view a copy of this License.  If
   2.113 +the interface presents a list of user commands or options, such as a
   2.114 +menu, a prominent item in the list meets this criterion.
   2.115 +
   2.116 +  1. Source Code.
   2.117 +
   2.118 +  The "source code" for a work means the preferred form of the work
   2.119 +for making modifications to it.  "Object code" means any non-source
   2.120 +form of a work.
   2.121 +
   2.122 +  A "Standard Interface" means an interface that either is an official
   2.123 +standard defined by a recognized standards body, or, in the case of
   2.124 +interfaces specified for a particular programming language, one that
   2.125 +is widely used among developers working in that language.
   2.126 +
   2.127 +  The "System Libraries" of an executable work include anything, other
   2.128 +than the work as a whole, that (a) is included in the normal form of
   2.129 +packaging a Major Component, but which is not part of that Major
   2.130 +Component, and (b) serves only to enable use of the work with that
   2.131 +Major Component, or to implement a Standard Interface for which an
   2.132 +implementation is available to the public in source code form.  A
   2.133 +"Major Component", in this context, means a major essential component
   2.134 +(kernel, window system, and so on) of the specific operating system
   2.135 +(if any) on which the executable work runs, or a compiler used to
   2.136 +produce the work, or an object code interpreter used to run it.
   2.137 +
   2.138 +  The "Corresponding Source" for a work in object code form means all
   2.139 +the source code needed to generate, install, and (for an executable
   2.140 +work) run the object code and to modify the work, including scripts to
   2.141 +control those activities.  However, it does not include the work's
   2.142 +System Libraries, or general-purpose tools or generally available free
   2.143 +programs which are used unmodified in performing those activities but
   2.144 +which are not part of the work.  For example, Corresponding Source
   2.145 +includes interface definition files associated with source files for
   2.146 +the work, and the source code for shared libraries and dynamically
   2.147 +linked subprograms that the work is specifically designed to require,
   2.148 +such as by intimate data communication or control flow between those
   2.149 +subprograms and other parts of the work.
   2.150 +
   2.151 +  The Corresponding Source need not include anything that users
   2.152 +can regenerate automatically from other parts of the Corresponding
   2.153 +Source.
   2.154 +
   2.155 +  The Corresponding Source for a work in source code form is that
   2.156 +same work.
   2.157 +
   2.158 +  2. Basic Permissions.
   2.159 +
   2.160 +  All rights granted under this License are granted for the term of
   2.161 +copyright on the Program, and are irrevocable provided the stated
   2.162 +conditions are met.  This License explicitly affirms your unlimited
   2.163 +permission to run the unmodified Program.  The output from running a
   2.164 +covered work is covered by this License only if the output, given its
   2.165 +content, constitutes a covered work.  This License acknowledges your
   2.166 +rights of fair use or other equivalent, as provided by copyright law.
   2.167 +
   2.168 +  You may make, run and propagate covered works that you do not
   2.169 +convey, without conditions so long as your license otherwise remains
   2.170 +in force.  You may convey covered works to others for the sole purpose
   2.171 +of having them make modifications exclusively for you, or provide you
   2.172 +with facilities for running those works, provided that you comply with
   2.173 +the terms of this License in conveying all material for which you do
   2.174 +not control copyright.  Those thus making or running the covered works
   2.175 +for you must do so exclusively on your behalf, under your direction
   2.176 +and control, on terms that prohibit them from making any copies of
   2.177 +your copyrighted material outside their relationship with you.
   2.178 +
   2.179 +  Conveying under any other circumstances is permitted solely under
   2.180 +the conditions stated below.  Sublicensing is not allowed; section 10
   2.181 +makes it unnecessary.
   2.182 +
   2.183 +  3. Protecting Users' Legal Rights From Anti-Circumvention Law.
   2.184 +
   2.185 +  No covered work shall be deemed part of an effective technological
   2.186 +measure under any applicable law fulfilling obligations under article
   2.187 +11 of the WIPO copyright treaty adopted on 20 December 1996, or
   2.188 +similar laws prohibiting or restricting circumvention of such
   2.189 +measures.
   2.190 +
   2.191 +  When you convey a covered work, you waive any legal power to forbid
   2.192 +circumvention of technological measures to the extent such circumvention
   2.193 +is effected by exercising rights under this License with respect to
   2.194 +the covered work, and you disclaim any intention to limit operation or
   2.195 +modification of the work as a means of enforcing, against the work's
   2.196 +users, your or third parties' legal rights to forbid circumvention of
   2.197 +technological measures.
   2.198 +
   2.199 +  4. Conveying Verbatim Copies.
   2.200 +
   2.201 +  You may convey verbatim copies of the Program's source code as you
   2.202 +receive it, in any medium, provided that you conspicuously and
   2.203 +appropriately publish on each copy an appropriate copyright notice;
   2.204 +keep intact all notices stating that this License and any
   2.205 +non-permissive terms added in accord with section 7 apply to the code;
   2.206 +keep intact all notices of the absence of any warranty; and give all
   2.207 +recipients a copy of this License along with the Program.
   2.208 +
   2.209 +  You may charge any price or no price for each copy that you convey,
   2.210 +and you may offer support or warranty protection for a fee.
   2.211 +
   2.212 +  5. Conveying Modified Source Versions.
   2.213 +
   2.214 +  You may convey a work based on the Program, or the modifications to
   2.215 +produce it from the Program, in the form of source code under the
   2.216 +terms of section 4, provided that you also meet all of these conditions:
   2.217 +
   2.218 +    a) The work must carry prominent notices stating that you modified
   2.219 +    it, and giving a relevant date.
   2.220 +
   2.221 +    b) The work must carry prominent notices stating that it is
   2.222 +    released under this License and any conditions added under section
   2.223 +    7.  This requirement modifies the requirement in section 4 to
   2.224 +    "keep intact all notices".
   2.225 +
   2.226 +    c) You must license the entire work, as a whole, under this
   2.227 +    License to anyone who comes into possession of a copy.  This
   2.228 +    License will therefore apply, along with any applicable section 7
   2.229 +    additional terms, to the whole of the work, and all its parts,
   2.230 +    regardless of how they are packaged.  This License gives no
   2.231 +    permission to license the work in any other way, but it does not
   2.232 +    invalidate such permission if you have separately received it.
   2.233 +
   2.234 +    d) If the work has interactive user interfaces, each must display
   2.235 +    Appropriate Legal Notices; however, if the Program has interactive
   2.236 +    interfaces that do not display Appropriate Legal Notices, your
   2.237 +    work need not make them do so.
   2.238 +
   2.239 +  A compilation of a covered work with other separate and independent
   2.240 +works, which are not by their nature extensions of the covered work,
   2.241 +and which are not combined with it such as to form a larger program,
   2.242 +in or on a volume of a storage or distribution medium, is called an
   2.243 +"aggregate" if the compilation and its resulting copyright are not
   2.244 +used to limit the access or legal rights of the compilation's users
   2.245 +beyond what the individual works permit.  Inclusion of a covered work
   2.246 +in an aggregate does not cause this License to apply to the other
   2.247 +parts of the aggregate.
   2.248 +
   2.249 +  6. Conveying Non-Source Forms.
   2.250 +
   2.251 +  You may convey a covered work in object code form under the terms
   2.252 +of sections 4 and 5, provided that you also convey the
   2.253 +machine-readable Corresponding Source under the terms of this License,
   2.254 +in one of these ways:
   2.255 +
   2.256 +    a) Convey the object code in, or embodied in, a physical product
   2.257 +    (including a physical distribution medium), accompanied by the
   2.258 +    Corresponding Source fixed on a durable physical medium
   2.259 +    customarily used for software interchange.
   2.260 +
   2.261 +    b) Convey the object code in, or embodied in, a physical product
   2.262 +    (including a physical distribution medium), accompanied by a
   2.263 +    written offer, valid for at least three years and valid for as
   2.264 +    long as you offer spare parts or customer support for that product
   2.265 +    model, to give anyone who possesses the object code either (1) a
   2.266 +    copy of the Corresponding Source for all the software in the
   2.267 +    product that is covered by this License, on a durable physical
   2.268 +    medium customarily used for software interchange, for a price no
   2.269 +    more than your reasonable cost of physically performing this
   2.270 +    conveying of source, or (2) access to copy the
   2.271 +    Corresponding Source from a network server at no charge.
   2.272 +
   2.273 +    c) Convey individual copies of the object code with a copy of the
   2.274 +    written offer to provide the Corresponding Source.  This
   2.275 +    alternative is allowed only occasionally and noncommercially, and
   2.276 +    only if you received the object code with such an offer, in accord
   2.277 +    with subsection 6b.
   2.278 +
   2.279 +    d) Convey the object code by offering access from a designated
   2.280 +    place (gratis or for a charge), and offer equivalent access to the
   2.281 +    Corresponding Source in the same way through the same place at no
   2.282 +    further charge.  You need not require recipients to copy the
   2.283 +    Corresponding Source along with the object code.  If the place to
   2.284 +    copy the object code is a network server, the Corresponding Source
   2.285 +    may be on a different server (operated by you or a third party)
   2.286 +    that supports equivalent copying facilities, provided you maintain
   2.287 +    clear directions next to the object code saying where to find the
   2.288 +    Corresponding Source.  Regardless of what server hosts the
   2.289 +    Corresponding Source, you remain obligated to ensure that it is
   2.290 +    available for as long as needed to satisfy these requirements.
   2.291 +
   2.292 +    e) Convey the object code using peer-to-peer transmission, provided
   2.293 +    you inform other peers where the object code and Corresponding
   2.294 +    Source of the work are being offered to the general public at no
   2.295 +    charge under subsection 6d.
   2.296 +
   2.297 +  A separable portion of the object code, whose source code is excluded
   2.298 +from the Corresponding Source as a System Library, need not be
   2.299 +included in conveying the object code work.
   2.300 +
   2.301 +  A "User Product" is either (1) a "consumer product", which means any
   2.302 +tangible personal property which is normally used for personal, family,
   2.303 +or household purposes, or (2) anything designed or sold for incorporation
   2.304 +into a dwelling.  In determining whether a product is a consumer product,
   2.305 +doubtful cases shall be resolved in favor of coverage.  For a particular
   2.306 +product received by a particular user, "normally used" refers to a
   2.307 +typical or common use of that class of product, regardless of the status
   2.308 +of the particular user or of the way in which the particular user
   2.309 +actually uses, or expects or is expected to use, the product.  A product
   2.310 +is a consumer product regardless of whether the product has substantial
   2.311 +commercial, industrial or non-consumer uses, unless such uses represent
   2.312 +the only significant mode of use of the product.
   2.313 +
   2.314 +  "Installation Information" for a User Product means any methods,
   2.315 +procedures, authorization keys, or other information required to install
   2.316 +and execute modified versions of a covered work in that User Product from
   2.317 +a modified version of its Corresponding Source.  The information must
   2.318 +suffice to ensure that the continued functioning of the modified object
   2.319 +code is in no case prevented or interfered with solely because
   2.320 +modification has been made.
   2.321 +
   2.322 +  If you convey an object code work under this section in, or with, or
   2.323 +specifically for use in, a User Product, and the conveying occurs as
   2.324 +part of a transaction in which the right of possession and use of the
   2.325 +User Product is transferred to the recipient in perpetuity or for a
   2.326 +fixed term (regardless of how the transaction is characterized), the
   2.327 +Corresponding Source conveyed under this section must be accompanied
   2.328 +by the Installation Information.  But this requirement does not apply
   2.329 +if neither you nor any third party retains the ability to install
   2.330 +modified object code on the User Product (for example, the work has
   2.331 +been installed in ROM).
   2.332 +
   2.333 +  The requirement to provide Installation Information does not include a
   2.334 +requirement to continue to provide support service, warranty, or updates
   2.335 +for a work that has been modified or installed by the recipient, or for
   2.336 +the User Product in which it has been modified or installed.  Access to a
   2.337 +network may be denied when the modification itself materially and
   2.338 +adversely affects the operation of the network or violates the rules and
   2.339 +protocols for communication across the network.
   2.340 +
   2.341 +  Corresponding Source conveyed, and Installation Information provided,
   2.342 +in accord with this section must be in a format that is publicly
   2.343 +documented (and with an implementation available to the public in
   2.344 +source code form), and must require no special password or key for
   2.345 +unpacking, reading or copying.
   2.346 +
   2.347 +  7. Additional Terms.
   2.348 +
   2.349 +  "Additional permissions" are terms that supplement the terms of this
   2.350 +License by making exceptions from one or more of its conditions.
   2.351 +Additional permissions that are applicable to the entire Program shall
   2.352 +be treated as though they were included in this License, to the extent
   2.353 +that they are valid under applicable law.  If additional permissions
   2.354 +apply only to part of the Program, that part may be used separately
   2.355 +under those permissions, but the entire Program remains governed by
   2.356 +this License without regard to the additional permissions.
   2.357 +
   2.358 +  When you convey a copy of a covered work, you may at your option
   2.359 +remove any additional permissions from that copy, or from any part of
   2.360 +it.  (Additional permissions may be written to require their own
   2.361 +removal in certain cases when you modify the work.)  You may place
   2.362 +additional permissions on material, added by you to a covered work,
   2.363 +for which you have or can give appropriate copyright permission.
   2.364 +
   2.365 +  Notwithstanding any other provision of this License, for material you
   2.366 +add to a covered work, you may (if authorized by the copyright holders of
   2.367 +that material) supplement the terms of this License with terms:
   2.368 +
   2.369 +    a) Disclaiming warranty or limiting liability differently from the
   2.370 +    terms of sections 15 and 16 of this License; or
   2.371 +
   2.372 +    b) Requiring preservation of specified reasonable legal notices or
   2.373 +    author attributions in that material or in the Appropriate Legal
   2.374 +    Notices displayed by works containing it; or
   2.375 +
   2.376 +    c) Prohibiting misrepresentation of the origin of that material, or
   2.377 +    requiring that modified versions of such material be marked in
   2.378 +    reasonable ways as different from the original version; or
   2.379 +
   2.380 +    d) Limiting the use for publicity purposes of names of licensors or
   2.381 +    authors of the material; or
   2.382 +
   2.383 +    e) Declining to grant rights under trademark law for use of some
   2.384 +    trade names, trademarks, or service marks; or
   2.385 +
   2.386 +    f) Requiring indemnification of licensors and authors of that
   2.387 +    material by anyone who conveys the material (or modified versions of
   2.388 +    it) with contractual assumptions of liability to the recipient, for
   2.389 +    any liability that these contractual assumptions directly impose on
   2.390 +    those licensors and authors.
   2.391 +
   2.392 +  All other non-permissive additional terms are considered "further
   2.393 +restrictions" within the meaning of section 10.  If the Program as you
   2.394 +received it, or any part of it, contains a notice stating that it is
   2.395 +governed by this License along with a term that is a further
   2.396 +restriction, you may remove that term.  If a license document contains
   2.397 +a further restriction but permits relicensing or conveying under this
   2.398 +License, you may add to a covered work material governed by the terms
   2.399 +of that license document, provided that the further restriction does
   2.400 +not survive such relicensing or conveying.
   2.401 +
   2.402 +  If you add terms to a covered work in accord with this section, you
   2.403 +must place, in the relevant source files, a statement of the
   2.404 +additional terms that apply to those files, or a notice indicating
   2.405 +where to find the applicable terms.
   2.406 +
   2.407 +  Additional terms, permissive or non-permissive, may be stated in the
   2.408 +form of a separately written license, or stated as exceptions;
   2.409 +the above requirements apply either way.
   2.410 +
   2.411 +  8. Termination.
   2.412 +
   2.413 +  You may not propagate or modify a covered work except as expressly
   2.414 +provided under this License.  Any attempt otherwise to propagate or
   2.415 +modify it is void, and will automatically terminate your rights under
   2.416 +this License (including any patent licenses granted under the third
   2.417 +paragraph of section 11).
   2.418 +
   2.419 +  However, if you cease all violation of this License, then your
   2.420 +license from a particular copyright holder is reinstated (a)
   2.421 +provisionally, unless and until the copyright holder explicitly and
   2.422 +finally terminates your license, and (b) permanently, if the copyright
   2.423 +holder fails to notify you of the violation by some reasonable means
   2.424 +prior to 60 days after the cessation.
   2.425 +
   2.426 +  Moreover, your license from a particular copyright holder is
   2.427 +reinstated permanently if the copyright holder notifies you of the
   2.428 +violation by some reasonable means, this is the first time you have
   2.429 +received notice of violation of this License (for any work) from that
   2.430 +copyright holder, and you cure the violation prior to 30 days after
   2.431 +your receipt of the notice.
   2.432 +
   2.433 +  Termination of your rights under this section does not terminate the
   2.434 +licenses of parties who have received copies or rights from you under
   2.435 +this License.  If your rights have been terminated and not permanently
   2.436 +reinstated, you do not qualify to receive new licenses for the same
   2.437 +material under section 10.
   2.438 +
   2.439 +  9. Acceptance Not Required for Having Copies.
   2.440 +
   2.441 +  You are not required to accept this License in order to receive or
   2.442 +run a copy of the Program.  Ancillary propagation of a covered work
   2.443 +occurring solely as a consequence of using peer-to-peer transmission
   2.444 +to receive a copy likewise does not require acceptance.  However,
   2.445 +nothing other than this License grants you permission to propagate or
   2.446 +modify any covered work.  These actions infringe copyright if you do
   2.447 +not accept this License.  Therefore, by modifying or propagating a
   2.448 +covered work, you indicate your acceptance of this License to do so.
   2.449 +
   2.450 +  10. Automatic Licensing of Downstream Recipients.
   2.451 +
   2.452 +  Each time you convey a covered work, the recipient automatically
   2.453 +receives a license from the original licensors, to run, modify and
   2.454 +propagate that work, subject to this License.  You are not responsible
   2.455 +for enforcing compliance by third parties with this License.
   2.456 +
   2.457 +  An "entity transaction" is a transaction transferring control of an
   2.458 +organization, or substantially all assets of one, or subdividing an
   2.459 +organization, or merging organizations.  If propagation of a covered
   2.460 +work results from an entity transaction, each party to that
   2.461 +transaction who receives a copy of the work also receives whatever
   2.462 +licenses to the work the party's predecessor in interest had or could
   2.463 +give under the previous paragraph, plus a right to possession of the
   2.464 +Corresponding Source of the work from the predecessor in interest, if
   2.465 +the predecessor has it or can get it with reasonable efforts.
   2.466 +
   2.467 +  You may not impose any further restrictions on the exercise of the
   2.468 +rights granted or affirmed under this License.  For example, you may
   2.469 +not impose a license fee, royalty, or other charge for exercise of
   2.470 +rights granted under this License, and you may not initiate litigation
   2.471 +(including a cross-claim or counterclaim in a lawsuit) alleging that
   2.472 +any patent claim is infringed by making, using, selling, offering for
   2.473 +sale, or importing the Program or any portion of it.
   2.474 +
   2.475 +  11. Patents.
   2.476 +
   2.477 +  A "contributor" is a copyright holder who authorizes use under this
   2.478 +License of the Program or a work on which the Program is based.  The
   2.479 +work thus licensed is called the contributor's "contributor version".
   2.480 +
   2.481 +  A contributor's "essential patent claims" are all patent claims
   2.482 +owned or controlled by the contributor, whether already acquired or
   2.483 +hereafter acquired, that would be infringed by some manner, permitted
   2.484 +by this License, of making, using, or selling its contributor version,
   2.485 +but do not include claims that would be infringed only as a
   2.486 +consequence of further modification of the contributor version.  For
   2.487 +purposes of this definition, "control" includes the right to grant
   2.488 +patent sublicenses in a manner consistent with the requirements of
   2.489 +this License.
   2.490 +
   2.491 +  Each contributor grants you a non-exclusive, worldwide, royalty-free
   2.492 +patent license under the contributor's essential patent claims, to
   2.493 +make, use, sell, offer for sale, import and otherwise run, modify and
   2.494 +propagate the contents of its contributor version.
   2.495 +
   2.496 +  In the following three paragraphs, a "patent license" is any express
   2.497 +agreement or commitment, however denominated, not to enforce a patent
   2.498 +(such as an express permission to practice a patent or covenant not to
   2.499 +sue for patent infringement).  To "grant" such a patent license to a
   2.500 +party means to make such an agreement or commitment not to enforce a
   2.501 +patent against the party.
   2.502 +
   2.503 +  If you convey a covered work, knowingly relying on a patent license,
   2.504 +and the Corresponding Source of the work is not available for anyone
   2.505 +to copy, free of charge and under the terms of this License, through a
   2.506 +publicly available network server or other readily accessible means,
   2.507 +then you must either (1) cause the Corresponding Source to be so
   2.508 +available, or (2) arrange to deprive yourself of the benefit of the
   2.509 +patent license for this particular work, or (3) arrange, in a manner
   2.510 +consistent with the requirements of this License, to extend the patent
   2.511 +license to downstream recipients.  "Knowingly relying" means you have
   2.512 +actual knowledge that, but for the patent license, your conveying the
   2.513 +covered work in a country, or your recipient's use of the covered work
   2.514 +in a country, would infringe one or more identifiable patents in that
   2.515 +country that you have reason to believe are valid.
   2.516 +
   2.517 +  If, pursuant to or in connection with a single transaction or
   2.518 +arrangement, you convey, or propagate by procuring conveyance of, a
   2.519 +covered work, and grant a patent license to some of the parties
   2.520 +receiving the covered work authorizing them to use, propagate, modify
   2.521 +or convey a specific copy of the covered work, then the patent license
   2.522 +you grant is automatically extended to all recipients of the covered
   2.523 +work and works based on it.
   2.524 +
   2.525 +  A patent license is "discriminatory" if it does not include within
   2.526 +the scope of its coverage, prohibits the exercise of, or is
   2.527 +conditioned on the non-exercise of one or more of the rights that are
   2.528 +specifically granted under this License.  You may not convey a covered
   2.529 +work if you are a party to an arrangement with a third party that is
   2.530 +in the business of distributing software, under which you make payment
   2.531 +to the third party based on the extent of your activity of conveying
   2.532 +the work, and under which the third party grants, to any of the
   2.533 +parties who would receive the covered work from you, a discriminatory
   2.534 +patent license (a) in connection with copies of the covered work
   2.535 +conveyed by you (or copies made from those copies), or (b) primarily
   2.536 +for and in connection with specific products or compilations that
   2.537 +contain the covered work, unless you entered into that arrangement,
   2.538 +or that patent license was granted, prior to 28 March 2007.
   2.539 +
   2.540 +  Nothing in this License shall be construed as excluding or limiting
   2.541 +any implied license or other defenses to infringement that may
   2.542 +otherwise be available to you under applicable patent law.
   2.543 +
   2.544 +  12. No Surrender of Others' Freedom.
   2.545 +
   2.546 +  If conditions are imposed on you (whether by court order, agreement or
   2.547 +otherwise) that contradict the conditions of this License, they do not
   2.548 +excuse you from the conditions of this License.  If you cannot convey a
   2.549 +covered work so as to satisfy simultaneously your obligations under this
   2.550 +License and any other pertinent obligations, then as a consequence you may
   2.551 +not convey it at all.  For example, if you agree to terms that obligate you
   2.552 +to collect a royalty for further conveying from those to whom you convey
   2.553 +the Program, the only way you could satisfy both those terms and this
   2.554 +License would be to refrain entirely from conveying the Program.
   2.555 +
   2.556 +  13. Use with the GNU Affero General Public License.
   2.557 +
   2.558 +  Notwithstanding any other provision of this License, you have
   2.559 +permission to link or combine any covered work with a work licensed
   2.560 +under version 3 of the GNU Affero General Public License into a single
   2.561 +combined work, and to convey the resulting work.  The terms of this
   2.562 +License will continue to apply to the part which is the covered work,
   2.563 +but the special requirements of the GNU Affero General Public License,
   2.564 +section 13, concerning interaction through a network will apply to the
   2.565 +combination as such.
   2.566 +
   2.567 +  14. Revised Versions of this License.
   2.568 +
   2.569 +  The Free Software Foundation may publish revised and/or new versions of
   2.570 +the GNU General Public License from time to time.  Such new versions will
   2.571 +be similar in spirit to the present version, but may differ in detail to
   2.572 +address new problems or concerns.
   2.573 +
   2.574 +  Each version is given a distinguishing version number.  If the
   2.575 +Program specifies that a certain numbered version of the GNU General
   2.576 +Public License "or any later version" applies to it, you have the
   2.577 +option of following the terms and conditions either of that numbered
   2.578 +version or of any later version published by the Free Software
   2.579 +Foundation.  If the Program does not specify a version number of the
   2.580 +GNU General Public License, you may choose any version ever published
   2.581 +by the Free Software Foundation.
   2.582 +
   2.583 +  If the Program specifies that a proxy can decide which future
   2.584 +versions of the GNU General Public License can be used, that proxy's
   2.585 +public statement of acceptance of a version permanently authorizes you
   2.586 +to choose that version for the Program.
   2.587 +
   2.588 +  Later license versions may give you additional or different
   2.589 +permissions.  However, no additional obligations are imposed on any
   2.590 +author or copyright holder as a result of your choosing to follow a
   2.591 +later version.
   2.592 +
   2.593 +  15. Disclaimer of Warranty.
   2.594 +
   2.595 +  THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
   2.596 +APPLICABLE LAW.  EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
   2.597 +HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
   2.598 +OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
   2.599 +THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
   2.600 +PURPOSE.  THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
   2.601 +IS WITH YOU.  SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
   2.602 +ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
   2.603 +
   2.604 +  16. Limitation of Liability.
   2.605 +
   2.606 +  IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
   2.607 +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
   2.608 +THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
   2.609 +GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
   2.610 +USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
   2.611 +DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
   2.612 +PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
   2.613 +EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
   2.614 +SUCH DAMAGES.
   2.615 +
   2.616 +  17. Interpretation of Sections 15 and 16.
   2.617 +
   2.618 +  If the disclaimer of warranty and limitation of liability provided
   2.619 +above cannot be given local legal effect according to their terms,
   2.620 +reviewing courts shall apply local law that most closely approximates
   2.621 +an absolute waiver of all civil liability in connection with the
   2.622 +Program, unless a warranty or assumption of liability accompanies a
   2.623 +copy of the Program in return for a fee.
   2.624 +
   2.625 +                     END OF TERMS AND CONDITIONS
   2.626 +
   2.627 +            How to Apply These Terms to Your New Programs
   2.628 +
   2.629 +  If you develop a new program, and you want it to be of the greatest
   2.630 +possible use to the public, the best way to achieve this is to make it
   2.631 +free software which everyone can redistribute and change under these terms.
   2.632 +
   2.633 +  To do so, attach the following notices to the program.  It is safest
   2.634 +to attach them to the start of each source file to most effectively
   2.635 +state the exclusion of warranty; and each file should have at least
   2.636 +the "copyright" line and a pointer to where the full notice is found.
   2.637 +
   2.638 +    <one line to give the program's name and a brief idea of what it does.>
   2.639 +    Copyright (C) <year>  <name of author>
   2.640 +
   2.641 +    This program is free software: you can redistribute it and/or modify
   2.642 +    it under the terms of the GNU General Public License as published by
   2.643 +    the Free Software Foundation, either version 3 of the License, or
   2.644 +    (at your option) any later version.
   2.645 +
   2.646 +    This program is distributed in the hope that it will be useful,
   2.647 +    but WITHOUT ANY WARRANTY; without even the implied warranty of
   2.648 +    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   2.649 +    GNU General Public License for more details.
   2.650 +
   2.651 +    You should have received a copy of the GNU General Public License
   2.652 +    along with this program.  If not, see <http://www.gnu.org/licenses/>.
   2.653 +
   2.654 +Also add information on how to contact you by electronic and paper mail.
   2.655 +
   2.656 +  If the program does terminal interaction, make it output a short
   2.657 +notice like this when it starts in an interactive mode:
   2.658 +
   2.659 +    <program>  Copyright (C) <year>  <name of author>
   2.660 +    This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
   2.661 +    This is free software, and you are welcome to redistribute it
   2.662 +    under certain conditions; type `show c' for details.
   2.663 +
   2.664 +The hypothetical commands `show w' and `show c' should show the appropriate
   2.665 +parts of the General Public License.  Of course, your program's commands
   2.666 +might be different; for a GUI interface, you would use an "about box".
   2.667 +
   2.668 +  You should also get your employer (if you work as a programmer) or school,
   2.669 +if any, to sign a "copyright disclaimer" for the program, if necessary.
   2.670 +For more information on this, and how to apply and follow the GNU GPL, see
   2.671 +<http://www.gnu.org/licenses/>.
   2.672 +
   2.673 +  The GNU General Public License does not permit incorporating your program
   2.674 +into proprietary programs.  If your program is a subroutine library, you
   2.675 +may consider it more useful to permit linking proprietary applications with
   2.676 +the library.  If this is what you want to do, use the GNU Lesser General
   2.677 +Public License instead of this License.  But first, please read
   2.678 +<http://www.gnu.org/philosophy/why-not-lgpl.html>.
   2.679 +
     3.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     3.2 +++ b/deps/glpk/ChangeLog	Sun Nov 06 20:59:10 2011 +0100
     3.3 @@ -0,0 +1,2432 @@
     3.4 +Fri Sep 09 12:00:00 2011 Andrew Makhorin <mao@gnu.org>
     3.5 +
     3.6 +        * GLPK 4.47 (32:0:32) has been released
     3.7 +
     3.8 +        * src/glpapi20.c
     3.9 +        New API routine glp_infeas1 to solve 0-1 feasibility problem
    3.10 +        was added and documented (see doc/cnfsat.pdf).
    3.11 +
    3.12 +        * src/glpnpp06.c
    3.13 +        Some new preprocessor routines for SAT-CNF encoding, which are
    3.14 +        used by the routine glp_intfeas1, were added.
    3.15 +
    3.16 +        * src/glpnpp.h
    3.17 +        The header was modified due to additions.
    3.18 +
    3.19 +        * src/glpapi21.c
    3.20 +        The glpsol solver was modified to bypass model postprocessing
    3.21 +        if the solution reported is neither optimal nor feasible.
    3.22 +
    3.23 +        * src/glpapi21.c
    3.24 +        New glpsol options (--minisat and --objbnd) were added.
    3.25 +
    3.26 +        * examples/pbn/*.*
    3.27 +        The paint-by-numbers puzzle model (pbn.mod) was modified to
    3.28 +        print solution in PostScript format and to check for multiple
    3.29 +        solutions. Some benchmark examples from <webpbn.com> encoded
    3.30 +        in MathProg were included in the distribution. For more details
    3.31 +        see examples/pbn/README and examples/pbn/pbn.pdf.
    3.32 +
    3.33 +        * examples/Makefile.am
    3.34 +        A minor bug was fixed to correctly build glpk in a separate
    3.35 +        directory. Thanks to Marco Atzeri <marco.atzeri@gmail.com> for
    3.36 +        bug report.
    3.37 +
    3.38 +Tue Aug 09 12:00:00 2011 Andrew Makhorin <mao@gnu.org>
    3.39 +
    3.40 +        * GLPK 4.46 (31:0:31) has been released
    3.41 +
    3.42 +        * src/glpk.h, src/Makefile
    3.43 +        glpk.h was relocated from 'include' to 'src', and 'include'
    3.44 +        subdir was removed; src/Makefile.am was changed appropriately.
    3.45 +
    3.46 +        * src/zlib/*.*
    3.47 +        zlib general purpose compression library, version 1.2.5,
    3.48 +        was ANSIfied and modified according to GLPK requirements and
    3.49 +        included in the distribution as an external software module.
    3.50 +
    3.51 +        For details see src/zlib/README.
    3.52 +
    3.53 +        * src/glpdmx.c
    3.54 +        The following new API routines were added:
    3.55 +        glp_read_cnfsat  - read CNF-SAT problem data in DIMACS format
    3.56 +        glp_check_cnfsat - check for CNF-SAT problem instance
    3.57 +        glp_write_cnfsat - write CNF-SAT problem data in DIMACS format
    3.58 +
    3.59 +        * src/minisat/*.*
    3.60 +        MiniSat, a CNF-SAT solver, version 1.14.1, was ANSIfied and
    3.61 +        modified according to GLPK requirements and included in the
    3.62 +        distribution as an external software module.
    3.63 +
    3.64 +        For details see minisat/README and minisat/LICENSE.
    3.65 +
    3.66 +        * src/glpapi19.c
    3.67 +        The API routine glp_minisat1, which is a driver to the MiniSat
    3.68 +        solver, was included in the package.
    3.69 +
    3.70 +        * doc/satcnf.*
    3.71 +        The document "CNF Satisfiability Problem" was included in the
    3.72 +        package. It is a supplement to the GLPK Reference Manual.
    3.73 +
    3.74 +        * src/glpapi20.c
    3.75 +        New glpsol options (--cnf, --wcnf, and --minisat) was added.
    3.76 +
    3.77 +        * glpsql.c
    3.78 +        Some bugs were fixed. Thanks to Xypron <xypron.glpk@gmx.de>.
    3.79 +
    3.80 +Sun Dec 05 12:00:00 2010 Andrew Makhorin <mao@gnu.org>
    3.81 +
    3.82 +        * GLPK 4.45 (30:0:30) has been released
    3.83 +
    3.84 +        * glplpx01.c
    3.85 +        A bug (it_cnt) in routine reset_parms was fixed.
    3.86 +        Thanks to Ali Baharev <ali.baharev@gmail.com> for report.
    3.87 +
    3.88 +        * glpmpl03.c
    3.89 +        A bug (print "text\") was fixed.
    3.90 +        Thanks to Xypron <xypron.glpk@gmx.de> for report.
    3.91 +
    3.92 +        * glpsql.c
    3.93 +        A precision bug was fixed.
    3.94 +        Thanks to Xypron <xypron.glpk@gmx.de>.
    3.95 +
    3.96 +        * glpk.tex
    3.97 +        Some typos were corrected.
    3.98 +        Thanks to Robbie Morrison <robbie@actrix.co.nz>.
    3.99 +
   3.100 +Thu Jun 03 12:00:00 2010 Andrew Makhorin <mao@gnu.org>
   3.101 +
   3.102 +        * GLPK 4.44 (29:0:29) has been released
   3.103 +
   3.104 +        * glpapi14.c glpmpl.h glpmpl01.c glpmpl03.c glpmpl04.c
   3.105 +        Implemented suffixes for variables and constraints.
   3.106 +
   3.107 +        * glpmpl06.c
   3.108 +        Made changes to allow comment records in CSV files.
   3.109 +
   3.110 +        * glpapi17.c
   3.111 +        Added and documented new API routine glp_cpp to solve Critical
   3.112 +        Path Problem.
   3.113 +
   3.114 +Sat Feb 20 12:00:00 2010 Andrew Makhorin <mao@gnu.org>
   3.115 +
   3.116 +        * GLPK 4.43 (28:0:28) has been released
   3.117 +
   3.118 +        * glplib.h, glplib.c, glpenv.h, glpenv.c
   3.119 +        The module glpenv was split into two modules glpenv and glplib.
   3.120 +
   3.121 +        * glpenv01.c, glpenv03.c, glpenv04.c, glpenv06.c
   3.122 +        The following new API routines were added and documented:
   3.123 +        glp_init_env, glp_free_env, glp_open_tee, glp_close_tee,
   3.124 +        glp_error (macro), glp_difftime.
   3.125 +
   3.126 +        * glpapi16.c
   3.127 +        New API routine glp_top_sort (topological sorting of ayclic
   3.128 +        digraph) was added and documented.
   3.129 +
   3.130 +        * glpapi17.c
   3.131 +        A serious bug was fixed in the routine glp_asn_prob_hall.
   3.132 +
   3.133 +        * glpnpp05.c
   3.134 +        A bug was fixed in the LP/MIP preprocessor (hidden covering
   3.135 +        inequalities).
   3.136 +
   3.137 +        * glpsql.c
   3.138 +        Some improvements were made in the table driver (NULL data).
   3.139 +        Thanks to Xypron <xypron.glpk@gmx.de> for contribution.
   3.140 +
   3.141 +        * configure.ac
   3.142 +        Changes were made to use .dylib rather than .so under Mac OS.
   3.143 +        Thanks to Noli Sicad <nsicad@gmail.com> for testing
   3.144 +
   3.145 +Wed Jan 13 12:00:00 2010 Andrew Makhorin <mao@gnu.org>
   3.146 +
   3.147 +        * GLPK 4.42 (27:0:27) has been released
   3.148 +
   3.149 +        * glpapi01.c, glpapi11.c, glpapi12.c, glpdmx.c
   3.150 +        The following new API routines were added and documented:
   3.151 +        glp_check_dup (check for duplicate elements in sparse matrix);
   3.152 +        glp_sort_matrix (sort elements of the constraint matrix);
   3.153 +        glp_read_prob (read problem data in GLPK format);
   3.154 +        glp_write_prob (write problem data in GLPK format);
   3.155 +        glp_analyze_bound (analyze active bound of non-basic variable);
   3.156 +        glp_analyze_coef (analyze obj. coefficient at basic variable);
   3.157 +        glp_print_ranges (print sensitivity analysis report; replaces
   3.158 +        lpx_print_sens_bnds).
   3.159 +
   3.160 +        * glpapi20.c
   3.161 +        New command-line options were added to glpsol:
   3.162 +        --glp (read problem data in GLPK format);
   3.163 +        --wglp (write problem data in GLPK format);
   3.164 +        --lp (replaces --cpxlp);
   3.165 +        --wlp (replaces --wcpxlp);
   3.166 +        --ranges (print sensitivity analysis report).
   3.167 +
   3.168 +        * glpapi06.c
   3.169 +        In the routine glp_init_smcp default value of the parameter
   3.170 +        out_frq was changed to 500 (it was 200).
   3.171 +
   3.172 +        * glpipp.h, glpipp01.c, glpipp02.c
   3.173 +        The old MIP preprocessor module was removed.
   3.174 +
   3.175 +        * glpapi09.c
   3.176 +        Now the MIP solver uses the new MIP preprocessor (NPP).
   3.177 +
   3.178 +        * glplpx03.c
   3.179 +        lpx_write_opb was disabled due to replacing IPP with NPP.
   3.180 +
   3.181 +        * glpnet09.c
   3.182 +        Kellerman's heuristic to cover edges by cliques was added.
   3.183 +
   3.184 +        * glplib08.c
   3.185 +        Recognition of special filenames "/dev/stdin", "/dev/stdout",
   3.186 +        and "/dev/stderr" was added.
   3.187 +
   3.188 +        * glpk.tex
   3.189 +        Chapter "Graph and network routines" was carried out from the
   3.190 +        reference manual as a separate document.
   3.191 +
   3.192 +Mon Dec 21 12:00:00 2009 Andrew Makhorin <mao@gnu.org>
   3.193 +
   3.194 +        * GLPK 4.41 (26:0:26) has been released
   3.195 +
   3.196 +        * glpapi12.c
   3.197 +        The following new API routines were added:
   3.198 +        glp_transform_row (replaces lpx_transform_row);
   3.199 +        glp_transform_col (replaces lpx_transform_col);
   3.200 +        glp_prim_rtest (replaces lpx_prim_ratio_test);
   3.201 +        glp_dual_rtest (replaces lpx_dual_ratio_test).
   3.202 +        Note that values returned by glp_prim_rtest and glp_dual_rtest
   3.203 +        differ from the ones retutned by the deprecated routines.
   3.204 +
   3.205 +        * glpnpp*.*
   3.206 +        The LP/MIP preprocessor was essentially re-implemented.
   3.207 +
   3.208 +        * glpios03.c
   3.209 +        The feature to remove inactive cuts from the active subproblem
   3.210 +        was implemented.
   3.211 +
   3.212 +        * glpios11.c
   3.213 +        The feature processing cuts stored in the cut pool was improved
   3.214 +        (now it uses estimation of objective degradation).
   3.215 +
   3.216 +        * glpscg.*
   3.217 +        Obsolete implemetation of the conflict graph was removed.
   3.218 +
   3.219 +        * glpmpl.h, glpmpl03.c, glpmpl04.c
   3.220 +        FILE was replaced by XFILE to allow using GLPK I/O routines.
   3.221 +
   3.222 +        * glpsql.c, examples/sql, doc/tables.tex
   3.223 +        The SQL table driver was changed to allow multiple arguments
   3.224 +        separated by semicolon in SQL statements. Thanks to Xypron
   3.225 +        <xypron.glpk@gmx.de>.
   3.226 +
   3.227 +        * glpk.h, glpapi14.c
   3.228 +        New API routine glp_time was added (not documented yet).
   3.229 +
   3.230 +        * glpapi20.c
   3.231 +        Two new options were added to glpsol: --seed value (initialize
   3.232 +        pseudo-random number generator used in MathProg model with
   3.233 +        specified seed value), and --ini filename (use as initial basis
   3.234 +        previously saved with -w option).
   3.235 +
   3.236 +        * examples/xyacfs.mod
   3.237 +        Thanks to Nigel Galloway <nigel_galloway@operamail.com> for
   3.238 +        contribution.
   3.239 +
   3.240 +        * examples/dbf/*.*
   3.241 +        Thanks to Noli Sicad <nsicad@gmail.com> for contribution.
   3.242 +
   3.243 +        * w32/*.*, w64/*.*
   3.244 +        Scripts to build GLPK with Microsoft Visual Studio 2010 were
   3.245 +        added. Thanks to Xypron <xypron.glpk@gmx.de> for contribution
   3.246 +        and testing.
   3.247 +
   3.248 +Tue Nov 03 12:00:00 2009 Andrew Makhorin <mao@gnu.org>
   3.249 +
   3.250 +        * GLPK 4.40 (25:0:25) has been released
   3.251 +
   3.252 +        * glpdmx.c
   3.253 +        Two new API routines were added:
   3.254 +        glp_read_ccdata (read graph in DIMACS clique/coloring format);
   3.255 +        glp_write_ccdata (write graph in DIMACS clique/coloring format).
   3.256 +        Also an example file examples/sample.col was added.
   3.257 +
   3.258 +        * glpapi19.c, glpnet08.c
   3.259 +        New API routine glp_wclique_exact was added. It is intended to
   3.260 +        find a maximum weight clique with the exact algorithm developed
   3.261 +        by Prof. P. Ostergard.
   3.262 +
   3.263 +        * glpnpp02.c
   3.264 +        A bug was fixed in the LP preprocessor (routine npp_empty_col).
   3.265 +        Thanks to Stefan Vigerske <stefan@math.hu-berlin.de> for the
   3.266 +        bug report.
   3.267 +
   3.268 +        * glpios10.c
   3.269 +        A bug was fixed and some improvements were made in the FPUMP
   3.270 +        heuristic module. Thanks to Xypron <xypron.glpk@gmx.de>.
   3.271 +
   3.272 +        * glpapi12.c
   3.273 +        A bug was fixed in the API routine glp_warm_up (dual
   3.274 +        feasibility test was incorrect in maximization case). Thanks to
   3.275 +        Uday Venkatadri <Uday.Venkatadri@dal.ca> for the bug report.
   3.276 +
   3.277 +        * glpapi16.c
   3.278 +        Two new API routines were added:
   3.279 +        glp_del_vertices (remove vertices from graph);
   3.280 +        glp_del_arc (remove arc from graph).
   3.281 +
   3.282 +        * glpios09.c
   3.283 +        The hybrid pseudocost branching heuristic was included in the
   3.284 +        MIP solver. It is available on API level (iocp.br_tech should
   3.285 +        be set to GLP_BR_PCH) and in the stand-alone solver glpsol
   3.286 +        (via the command-line option --pcost). This heuristic may be
   3.287 +        useful on solving hard MIP instances.
   3.288 +
   3.289 +        * glpios03.c
   3.290 +        The branching heuristic by Driebeck and Tomlin (used in the
   3.291 +        MIP solver by default) was changed to switch to branching on
   3.292 +        most fractional variable if an lower bound of degradation of
   3.293 +        the objective is close to zero for all branching candidates.
   3.294 +
   3.295 +Sun Jul 26 12:00:00 2009 Andrew Makhorin <mao@mai2.rcnet.ru>
   3.296 +
   3.297 +        * GLPK 4.39 (24:0:24) has been released
   3.298 +
   3.299 +        * glpsdf.c
   3.300 +        New API routines to read plain data files were added.
   3.301 +
   3.302 +        * glpcpx.h, glpini.h, glpscl.h
   3.303 +        These headers were removed.
   3.304 +
   3.305 +        * glpcpx.c
   3.306 +        API routines glp_read_lp and glp_write_lp to read/write files
   3.307 +        in CPLEX LP format were re-implemented. Now glp_write_lp
   3.308 +        correctly writes double-bounded (ranged) rows by introducing
   3.309 +        slack variables rather than by duplicating the rows. The data
   3.310 +        structure glp_cpxcp and routine glp_init_cpxcp were added.
   3.311 +
   3.312 +        * amd/*
   3.313 +        The 'xfree(NULL)' bug was fixed in the AMD routines. Thanks to
   3.314 +        Niels Klitgord <niels@bu.edu> for the bug report.
   3.315 +
   3.316 +        * glpapi16.c
   3.317 +        New API routines glp_set_vertex_name, glp_create_v_index,
   3.318 +        glp_find_vertex, and glp_delete_v_index were added.
   3.319 +
   3.320 +        * glpdmx.c
   3.321 +        New API routines glp_read_asnprob, glp_write_asnprob,
   3.322 +        glp_read_ccformat, and glp_write_ccformat were added (the two
   3.323 +        latter routines are not documented yet).
   3.324 +
   3.325 +        * glpapi18.c
   3.326 +        New API routines glp_check_asnprob, glp_asnprob_lp,
   3.327 +        glp_asnprob_okalg, and glp_asnprob_hall were added.
   3.328 +
   3.329 +        * glpini01.c, glpini02.c
   3.330 +        The message "Crashing..." was changed to "Constructing initial
   3.331 +        basis..." due to suggestion by Thomas Kahle <tom111@gmx.de>.
   3.332 +
   3.333 +        * glpapi14.c
   3.334 +        New API routines glp_printf, glp_vprintf, glp_malloc,
   3.335 +        glp_calloc, glp_free, and glp_assert were added.
   3.336 +
   3.337 +        * glplpp.h, glplpp01.c, glplpp02.c
   3.338 +        Old LP presolver routines were removed. Now glp_simplex uses
   3.339 +        new preprocessing routines (see glpnpp).
   3.340 +
   3.341 +        * glpapi12.c
   3.342 +        New API routine glp_warm_up was added; it replaces the routine
   3.343 +        lpx_warm_up.
   3.344 +
   3.345 +Sat May 02 12:00:00 2009 Andrew Makhorin <mao@mai2.rcnet.ru>
   3.346 +
   3.347 +        * GLPK 4.38 (23:0:23) has been released
   3.348 +
   3.349 +        * glpmps.c
   3.350 +        API routines to read/write MPS files were re-implemented.
   3.351 +
   3.352 +        * glpspx02.c
   3.353 +        Some improvements were made in the dual simplex routine.
   3.354 +
   3.355 +        * glpk.h
   3.356 +        New structure glp_iptcp was added.
   3.357 +
   3.358 +        * glpnpp.h, glpnpp01.c, glpnpp02.c
   3.359 +        New LP/MIP preprocessor. Currently it includes only some basic
   3.360 +        routines and used only in the interior-point solver.
   3.361 +
   3.362 +        * glpapi08.c
   3.363 +        API routine glp_interior was replaced by an improved version
   3.364 +        (new LP/MIP preprocessor, new ordering algorithms).
   3.365 +
   3.366 +        New API routine glp_init_iptcp was added.
   3.367 +
   3.368 +        API routine glp_ipt_status may return two new statuses due to
   3.369 +        changes in glp_interior.
   3.370 +
   3.371 +        * glpsol.c
   3.372 +        New command-line options were added (ordering algorithm used in
   3.373 +        the interior-point solver).
   3.374 +
   3.375 +        * amd/*.*, colamd/*.*
   3.376 +        Two external software modules AMD and COLAMD/SYMAMD used in the
   3.377 +        interior-point solver were included in the distribution.
   3.378 +
   3.379 +        For details see amd/README and colamd/README.
   3.380 +
   3.381 +        * glpnet03.c, glpnet04.c, glpnet05.c
   3.382 +        A minor bug was fixed (_G => G_). Thanks to Nelson H. F. Beebe
   3.383 +        <beebe@math.utah.edu> for bug report.
   3.384 +
   3.385 +Sun Mar 29 12:00:00 2009 Andrew Makhorin <mao@mai2.rcnet.ru>
   3.386 +
   3.387 +        * GLPK 4.37 (22:0:22) has been released
   3.388 +
   3.389 +        * glpk.h
   3.390 +        iocp.fp_heur was added to enable/disable fpump heuristic.
   3.391 +
   3.392 +        * glpios10.c
   3.393 +        ios_feas_pump was added (feasibility pump heuristic).
   3.394 +
   3.395 +        * glpsol.c
   3.396 +        --fpump command-line option was added.
   3.397 +
   3.398 +        * glpsds.c
   3.399 +        Plain data set routines were added to facilitate reading plain
   3.400 +        data in application programs. Currently these routines are not
   3.401 +        in API, though declared in glpk.h.
   3.402 +
   3.403 +        * glpapi08.c
   3.404 +        A bug was fixed in the internal routine restore. (Due to this
   3.405 +        bug dual solution components were computed incorrectly if the
   3.406 +        problem was scaled.)
   3.407 +
   3.408 +        * glpapi10.c, glpapi11.c
   3.409 +        The following new API routines were added:
   3.410 +        glp_print_sol (replaces lpx_print_sol);
   3.411 +        glp_print_ipt (replaces lpx_print_ips);
   3.412 +        glp_print_mip (replaces lpx_print_mip);
   3.413 +        _glp_check_kkt (replaces lpx_check_kkt, lpx_check_int).
   3.414 +        Now the routine lpx_print_prob (deprecated) is equivalent to
   3.415 +        the routine glp_write_lp.
   3.416 +
   3.417 +        * glpapi18.c, glpapi19.c
   3.418 +        The following new API routines were added:
   3.419 +        glp_read_graph (read graph from plain text file);
   3.420 +        glp_write_graph (write graph to plain text file);
   3.421 +        glp_weak_comp (find all weakly connected components);
   3.422 +        glp_strong_comp (find all strongly connected components).
   3.423 +
   3.424 +        * configure.ac, Makefile.am
   3.425 +        Changes were made: (a) to allow using autoreconf/autoheader;
   3.426 +        (b) to allow building glpk in a directory other than its source
   3.427 +        directory. Thanks to Marco Atzeri <marco_atzeri@yahoo.it> for
   3.428 +        bug report.
   3.429 +
   3.430 +        * examples/shiftcover.mod
   3.431 +        An example model in MathProg was added.
   3.432 +        Thanks to Larry D'Agostino <Larry.D'Agostino@gmacrescap.com>
   3.433 +        for contribution.
   3.434 +
   3.435 +Fri Feb 06 12:00:00 2009 Andrew Makhorin <mao@mai2.rcnet.ru>
   3.436 +
   3.437 +        * GLPK 4.36 (21:0:21) has been released
   3.438 +
   3.439 +        * glpnet06.c, glpnet07.c, glpapi19.c
   3.440 +        The following new API routines were added:
   3.441 +        glp_mincost_okalg     find minimum-cost flow with out-of-kilter
   3.442 +                              algorithm
   3.443 +        glp_maxflow_ffalg     find maximal flow with Ford-Fulkerson
   3.444 +                              algorithm
   3.445 +
   3.446 +        * glpsol.c
   3.447 +        Two new command-line options were added:
   3.448 +        --mincost             read min-cost flow data in DIMACS format
   3.449 +        --maxflow             read maximum flow data in DIMACS format
   3.450 +
   3.451 +        * doc/glpk.*
   3.452 +        New edition of the reference manual was included.
   3.453 +
   3.454 +        * glpk.h
   3.455 +        Duplicate symbols were removed to allow using swig.
   3.456 +        Thanks to Kelly Westbrooks <kellywestbrooks@yahoo.com> and
   3.457 +        Nigel Galloway <nigel_galloway@operamail.com> for suggestion.
   3.458 +
   3.459 +        * glpcpx.c
   3.460 +        A minor defect was fixed in the routine glp_write_lp.
   3.461 +        Thanks to Sebastien Briais <sbriais@free.fr> for bug report.
   3.462 +
   3.463 +        * glpsql.c
   3.464 +        A minor bug was fixed. Thanks to Xypron <xypron.glpk@gmx.de>
   3.465 +        for patch.
   3.466 +
   3.467 +        * examples/hashi.mod, examples/shikaku.mod
   3.468 +        Two example models in MathProg were added. Thanks to Sebastian
   3.469 +        Nowozin <nowozin@gmail.com> for contribution.
   3.470 +
   3.471 +        * examples/qfit.mod, examples/yacfs.mod
   3.472 +        Two example models in MathProg were added. Thanks to Nigel
   3.473 +        Galloway <nigel_galloway@operamail.com> for contribution.
   3.474 +
   3.475 +Fri Jan 09 12:00:00 2009 Andrew Makhorin <mao@mai2.rcnet.ru>
   3.476 +
   3.477 +        * GLPK 4.35 (20:0:20) has been released
   3.478 +
   3.479 +        * glpk.h, glpapi.c, glpnet.c
   3.480 +        The following new API routines were added:
   3.481 +        glp_create_graph      create graph
   3.482 +        glp_set_graph_name    assign (change) graph name
   3.483 +        glp_add_vertices      add new vertices to graph
   3.484 +        glp_add_arc           add new arc to graph
   3.485 +        glp_erase_graph       erase graph content
   3.486 +        glp_delete_graph      delete graph
   3.487 +        glp_read_mincost      read minimum cost flow problem data in
   3.488 +                              DIMACS format
   3.489 +        glp_write_mincost     write minimum cost flow problem data in
   3.490 +                              DIMACS format
   3.491 +        glp_mincost_lp        convert minimum cost flow problem to LP
   3.492 +        glp_netgen            Klingman's network problem generator
   3.493 +        glp_gridgen           grid-like network problem generator
   3.494 +        glp_read_maxflow      read maximum flow problem data in DIMACS
   3.495 +                              format
   3.496 +        glp_write_maxflow     write maximum flow problem data in DIMACS
   3.497 +                              format
   3.498 +        glp_maxflow_lp        convert maximum flow problem to LP
   3.499 +        glp_rmfgen            Goldfarb's maximum flow problem generator
   3.500 +
   3.501 +        * doc/glpk.*
   3.502 +        New edition of the reference manual was included.
   3.503 +
   3.504 +        * examples/sample.min, examples/sample.max
   3.505 +        Two example data files in DIMACS format were added.
   3.506 +
   3.507 +        * glplib04.c
   3.508 +        The statement "if (c = '\n') fflush(stdout)" was added to the
   3.509 +        internal routine xputc to provide "real-time" terminal output.
   3.510 +        Thanks to Luiz Bettoni <bettoni@cpgei.ct.utfpr.edu.br> for
   3.511 +        suggestion.
   3.512 +
   3.513 +        * glpmpl05.c
   3.514 +        A minor bug was fixed in the internal routine mpl_fn_time2str.
   3.515 +        Thanks to Stefan Vigerske <stefan@vigerske.de> for bug report.
   3.516 +
   3.517 +        * w32/makefile, w64/makefile
   3.518 +        The flag -O2 (/O2) was added to some makefiles.
   3.519 +
   3.520 +Thu Dec 04 12:00:00 2008 Andrew Makhorin <mao@mai2.rcnet.ru>
   3.521 +
   3.522 +        * GLPK 4.34 (19:0:19) has been released
   3.523 +
   3.524 +        * src/glpios03.c
   3.525 +        A bug was fixed in the internal routine branch_on. Thanks to
   3.526 +        Nigel Galloway <nigel_galloway@operamail.com> for bug report.
   3.527 +
   3.528 +        * src/glpmpl05.c
   3.529 +        Three new MathProg functions were included:
   3.530 +        gmtime    obtaining current calendar time
   3.531 +        str2time  converting character string to calendar time
   3.532 +        time2str  converting calendar time to character string
   3.533 +        Thanks to Xypron <xypron.glpk@gmx.de>.
   3.534 +
   3.535 +        * doc/glpk.*, doc/gmpl.*
   3.536 +        A new edition of the GLPK reference manual and GNU MathProg
   3.537 +        language description were included.
   3.538 +
   3.539 +Thu Oct 30 12:00:00 2008 Andrew Makhorin <mao@mai2.rcnet.ru>
   3.540 +
   3.541 +        * GLPK 4.33 (18:0:18) has been released
   3.542 +
   3.543 +        * glpapi*.*
   3.544 +        The following new API routines were added:
   3.545 +        glp_copy_prob         copy problem object content
   3.546 +        glp_exact             solve LP in exact arithmetic
   3.547 +                              (makes lpx_exact deprecated)
   3.548 +        glp_get_unbnd_ray     determine variable causing unboundedness
   3.549 +                              (makes lpx_get_ray_info deprecated)
   3.550 +        glp_interior          solve LP with interior-point method
   3.551 +                              (makes lpx_interior deprecated)
   3.552 +
   3.553 +        * glpapi*.*
   3.554 +        The following new API routines for processing models written in
   3.555 +        the GNU Mathprog language were added to the package:
   3.556 +        glp_mpl_alloc_wksp    allocate the translator workspace
   3.557 +        glp_mpl_read_model    read and translate model section
   3.558 +        glp_mpl_read_data     read and translate data section
   3.559 +        glp_mpl_generate      generate the model
   3.560 +        glp_mpl_build_prob    build LP/MIP instance from the model
   3.561 +        glp_mpl_postsolve     postsolve the model
   3.562 +        glp_mpl_free_wksp     deallocate the translator workspace
   3.563 +        (These routines make lpx_read_model deprecated.)
   3.564 +
   3.565 +        * src/glpapi17.c, examples/glpsol.c
   3.566 +        The stand-alone solver glpsol was re-implemented with new API
   3.567 +        routines.
   3.568 +
   3.569 +        * src/glpsql.c
   3.570 +        Some bugs were fixed in the SQL table driver. Thanks to Xypron
   3.571 +        <xypron.glpk@gmx.de>.
   3.572 +
   3.573 +        * examples/cplex/*.*
   3.574 +        A crude implementation of CPLEX-like interface to GLPK API was
   3.575 +        added to the package. See examples/cplex/README.
   3.576 +
   3.577 +Fri Oct 03 12:00:00 2008 Andrew Makhorin <mao@mai2.rcnet.ru>
   3.578 +
   3.579 +        * GLPK 4.32 (17:0:17) has been released
   3.580 +
   3.581 +        * glpmpl01.c
   3.582 +        A bug was fixed. Due to this bug iterated expressions having
   3.583 +        an indexing expression whose dummy indices are bound to some
   3.584 +        values, i.e. like sum{(i+1,j,k-1) in E} x[i,j,k] are evaluated
   3.585 +        incorrectly. Namely, current value of such expressions is not
   3.586 +        invalidated when corresponding dummy indices (like i and k in
   3.587 +        the example above) are changed, that erroneously results in the
   3.588 +        same value evaluated for the first time.
   3.589 +
   3.590 +        * glpios03.c
   3.591 +        Euclidean reduction of the local objective bound was added in
   3.592 +        the routine glpios03.c.
   3.593 +
   3.594 +        * glpapi11.c
   3.595 +        The following new branch-and-cut API routines were added:
   3.596 +        glp_ios_row_attr      determine additional row attributes;
   3.597 +        glp_ios_pool_size     determine current size of the cut pool;
   3.598 +        glp_ios_add_row       add constraint to the cut pool;
   3.599 +        glp_ios_del_row       delete constraint from the cut pool;
   3.600 +        glp_ios_clear_pool    delete all constraints from the cut pool.
   3.601 +
   3.602 +        * glpapi08.c
   3.603 +        The following new features were included in the branch-and-cut
   3.604 +        solver (the API routine glp_intopt):
   3.605 +        MIP presolver;
   3.606 +        mixed cover cut generator;
   3.607 +        clique cut generator.
   3.608 +        Due to the MIP presolver glp_intopt may additionally return
   3.609 +        GLP_ENOPFS and GLP_ENODFS, if primal or dual infeasibility of
   3.610 +        LP relaxation is detected by the presolver. Also the return
   3.611 +        code GLP_EMIPGAP was introduced to correctly indicate that the
   3.612 +        mip gap tolerance is reached.
   3.613 +
   3.614 +        * glplpx01.c
   3.615 +        Now the obsolete API routines lpx_integer and lpx_intopt are
   3.616 +        completely superseded by the API routine glp_intopt that makes
   3.617 +        them deprecated.
   3.618 +
   3.619 +        * glpmpl05.c
   3.620 +        Now the table driver name "iODBC" can be specified as "ODBC".
   3.621 +
   3.622 +        * glpmpl03.c
   3.623 +        A bug fixed in the routine free_dca.
   3.624 +        Thanks to Xypron <xypron.glpk@gmx.de>.
   3.625 +
   3.626 +        * glpsql.c
   3.627 +        A bug was fixed in the SQL table driver.
   3.628 +        Thanks to Xypron <xypron.glpk@gmx.de>.
   3.629 +
   3.630 +        * examples/glpsol.c
   3.631 +        Changes were made to allow multiple MathProg data files.
   3.632 +
   3.633 +        * doc/glpk.*
   3.634 +        A new edition of the GLPK reference manual was included.
   3.635 +
   3.636 +        * doc/tables.*
   3.637 +        A new edition of the supplement "Using data tables in the GNU
   3.638 +        MathProg language" was included.
   3.639 +
   3.640 +Tue Sep 02 12:00:00 2008 Andrew Makhorin <mao@mai2.rcnet.ru>
   3.641 +
   3.642 +        * GLPK 4.31 (16:0:16) has been released
   3.643 +
   3.644 +        * glpspx.h, glpspx01.c, glpspx02.c, glpapi06.c
   3.645 +        The dual simplex solver (spx_dual_opt) was replaced by a new
   3.646 +        implementation of the two-phase dual simplex method (spx_dual).
   3.647 +        Old simplex method routines (spx_prim_opt, spx_prim_feas, and
   3.648 +        spx_dual_opt) were removed from the package.
   3.649 +
   3.650 +        * glpk.h, glpscl.h, glpscl.c, glpapi04.c
   3.651 +        New API routine glp_scale_prob was added. It replaces routine
   3.652 +        lpx_scale_prob which is deprecated.
   3.653 +
   3.654 +        * glpk.h, glpini.h, glpini01.c, glpini02.c, glpapi05.c
   3.655 +        New API routines glp_std_basis, glp_adv_basis, glp_cpx_basis
   3.656 +        were added. They replace routines lpx_std_basis, lpx_adv_basis,
   3.657 +        lpx_cpx_basis which are deprecated.
   3.658 +
   3.659 +        * glpdmp.c
   3.660 +        8-byte data alignment was added to the module (sufficient for
   3.661 +        both ILP32 and LP64 environments).
   3.662 +
   3.663 +        * glplib07.c
   3.664 +        16-byte data alignment was added to the module to provide
   3.665 +        compatibility with LP64 environment (8-byte is not sufficient
   3.666 +        due to jmp_buf; thanks to Xypron for investigation).
   3.667 +
   3.668 +        * glplpx16.c
   3.669 +        New version of the routine lpx_write_pb was added. Thanks to
   3.670 +        Oscar Gustafsson <oscarg@isy.liu.se> for the contribution.
   3.671 +
   3.672 +        * w32/VC9, w64/VC9
   3.673 +        Makefiles and batch files were added to build GLPK under 32-
   3.674 +        and 64-bit Windows with Microsoft Visual Studio Express 2008.
   3.675 +        Thanks to Heinrich Schuchardt <heinrich.schuchardt@gmx.de> for
   3.676 +        the contribution and testing.
   3.677 +
   3.678 +        * w32/DM, w32/OWC
   3.679 +        Makefiles and batch files were added to build GLPK with Digital
   3.680 +        Mars C/C++ 8.50 and Open Watcom C/C++ 1.6 (32-bit Windows).
   3.681 +
   3.682 +Wed Aug 13 12:00:00 2008 Andrew Makhorin <mao@mai2.rcnet.ru>
   3.683 +
   3.684 +        * GLPK 4.30 (15:0:15) has been released
   3.685 +
   3.686 +        * glpspx.h, glpspx03.c, glpapi06.c
   3.687 +        The primal simplex solver (spx_prim_opt, spx_prim_feas) was
   3.688 +        replaced by a new implementation (spx_primal), which currently
   3.689 +        provides the same features as the old version.
   3.690 +
   3.691 +        * glpmpl01.c, glpmpl03.c
   3.692 +        Some changes were made in the MathProg translator to allow <,
   3.693 +        <=, >=, and > on comparing symbolic values. Thanks to Heinrich
   3.694 +        Schuchardt <heinrich.schuchardt@gmx.de> for patches.
   3.695 +
   3.696 +        * glplpx10.c
   3.697 +        Internal routine set_d_eps in the exact LP solver was changed
   3.698 +        to prevent approximation errors in case of integral data.
   3.699 +        Thanks to Markus Pilz <pilz@cs.uni-bonn.de> for bug report.
   3.700 +
   3.701 +XXX XXX XX 12:00:00 2008 Andrew Makhorin <mao@mai2.rcnet.ru>
   3.702 +
   3.703 +        * GLPK 4.29 (14:0:14) has been released
   3.704 +
   3.705 +        * configure.ac
   3.706 +        The configure script was changed to disable optional features
   3.707 +        by default. For details see file INSTALL.
   3.708 +
   3.709 +        * glpipp02.c
   3.710 +        A bug was fixed in the internal routine reduce_bounds. Thanks
   3.711 +        to Anne-Laurence Putz <anne-laurence.putz@eurodecision.com> for
   3.712 +        the bug report.
   3.713 +
   3.714 +        * glpapi01.c
   3.715 +        New API routine glp_erase_prob was added.
   3.716 +
   3.717 +        * glpapi13.c
   3.718 +        New API routines glp_read_mps and glp_write_mps were added.
   3.719 +        They replace API routines lpx_read_mps, lpx_read_freemps,
   3.720 +        lpx_write_mps, and lpx_write_freemps, which are deprecated.
   3.721 +
   3.722 +        * glpapi14.c
   3.723 +        New API routines glp_read_lp and glp_write_lp were added. They
   3.724 +        replace API routines lpx_read_cpxlp and lpx_write_cpxlp, which
   3.725 +        are deprecated.
   3.726 +
   3.727 +        * glpsql.c
   3.728 +        Minor bug was fixed. Thanks to Xypron <xypron.glpk@gmx.de> for
   3.729 +        the bug report.
   3.730 +
   3.731 +Tue Mar 25 12:00:00 2008 Andrew Makhorin <mao@mai2.rcnet.ru>
   3.732 +
   3.733 +        * GLPK 4.28 (13:0:13) has been released
   3.734 +
   3.735 +        * glplib.h, glplib.c
   3.736 +        Three wrapper routines xdlopen, xdlsym, and xdlclose, which
   3.737 +        provide the shared library support, were added. A particular
   3.738 +        version of these routines depends on the option --enable-dl
   3.739 +        passed to the configure script (see file INSTALL for details).
   3.740 +        Thanks to Rafael Laboissiere <rafael@debian.org> for useful
   3.741 +        advices concerning the shared library support.
   3.742 +
   3.743 +        * glpsql.c
   3.744 +        A static linking to iODBC and MySQL libraries used in the
   3.745 +        MathProg table drivers was replaced by a dynamic linking to
   3.746 +        corresponding shared libraries.
   3.747 +        Many thanks to Heinrich Schuchardt <heinrich.schuchardt@gmx.de>
   3.748 +        for the contribution and to Vijay Patil <vijay.patil@gmail.com>
   3.749 +        for testing this feature under Windows XP.
   3.750 +
   3.751 +        * glpgmp.h, glpgmp.c
   3.752 +        A bug (which appeared only on 64-bit platforms) was fixed.
   3.753 +        Thanks to Axel Simon <Axel.Simon@ens.fr> for the bug report.
   3.754 +
   3.755 +        * glpapi.c
   3.756 +        A bug was fixed in the api routine glp_add_cols. (If the basis
   3.757 +        is valid, adding column keeps it valid, however, col->bind was
   3.758 +        set to -1 rather to 0.)
   3.759 +        Thanks to Cedric[FR] <fox2113@wanadoo.fr> for the bug report.
   3.760 +
   3.761 +        * glplib.c
   3.762 +        64-bit unsigned int type glp_ulong and corresponding routines
   3.763 +        were replaced by 64-bit signed int type xlong_t.
   3.764 +
   3.765 +        * glpk.h, glpapi.c
   3.766 +        The type glp_ulong was replaced by glp_long. This affects only
   3.767 +        the api routine glp_mem_usage.
   3.768 +
   3.769 +        * glplib.c
   3.770 +        Compressed data file support was added. This feature requires
   3.771 +        the zlib data compression libraries and allows compressing and
   3.772 +        decompressing .gz files "on the fly".
   3.773 +
   3.774 +        * glpcli.h, glpcli.c
   3.775 +        Command-line interface routines were added. (This feature is
   3.776 +        incomplete so far.)
   3.777 +
   3.778 +Sun Mar 02 12:00:00 2008 Andrew Makhorin <mao@mai2.rcnet.ru>
   3.779 +
   3.780 +        * GLPK 4.27 (12:0:12) has been released
   3.781 +
   3.782 +        * glpsql.h, glpsql.c
   3.783 +        Two MathProg table drivers for iODBC and MySQL contributed by
   3.784 +        Heinrich Schuchardt <heinrich.schuchardt@gmx.de> were added to
   3.785 +        the package.
   3.786 +
   3.787 +        * glpmpl05.c
   3.788 +        Mathprog table driver for xBASE was added to the package.
   3.789 +
   3.790 +        * glpmpl03.c
   3.791 +        A minor was fixed in the MathProg translator (if some field
   3.792 +        specified in the table statement is missing in corresponding
   3.793 +        input table, the bug causes abnormal termination). Thanks to
   3.794 +        Heinrich Schuchardt <heinrich.schuchardt@gmx.de> for the bug
   3.795 +        report.
   3.796 +
   3.797 +        * glpmpl.h, glpmpl.c
   3.798 +        STRING data type was replaced by plain character strings.
   3.799 +
   3.800 +Sun Feb 17 12:00:00 2008 Andrew Makhorin <mao@mai2.rcnet.ru>
   3.801 +
   3.802 +        * GLPK 4.26 (11:0:11) has been released
   3.803 +
   3.804 +        * glpmpl.h, glpmpl01.c, glpmpl03.c, glpmpl05.c
   3.805 +        The table statement was implemented. Description of this new
   3.806 +        feature is given in file doc/tables.txt.
   3.807 +
   3.808 +        * glpios03.c
   3.809 +        A bug causing zero divide error on computing euclidean norm of
   3.810 +        the cut coefficient vector was fixed.
   3.811 +
   3.812 +Wed Dec 19 12:00:00 2007 Andrew Makhorin <mao@mai2.rcnet.ru>
   3.813 +
   3.814 +        * GLPK 4.25 (10:0:10) has been released
   3.815 +
   3.816 +        * glpapi10.c
   3.817 +        Routines lpx_eval_tab_row and lpx_eval_tab_col were replaced by
   3.818 +        glp_eval_tab_row and glp_eval_tab_col.
   3.819 +
   3.820 +        * glpios03.c, glpios05.c
   3.821 +        Gomory's mixed integer cuts were implemented.
   3.822 +
   3.823 +        * glpscs.h, glpscs.c
   3.824 +        Segmented character string routines are no longer used and were
   3.825 +        removed from the package.
   3.826 +
   3.827 +Wed Nov 21 12:00:00 2007 Andrew Makhorin <mao@mai2.rcnet.ru>
   3.828 +
   3.829 +        * GLPK 4.24 (9:0:9) has been released
   3.830 +
   3.831 +        * src/glplpx16.c
   3.832 +        A bug was fixed in the routine lpx_write_cpxlp. If a variable
   3.833 +        x has upper bound and no lower bound, it should appear in the
   3.834 +        bounds section as "-inf <= x <= u", not as "x <= u". Thanks to
   3.835 +        Enric Rodriguez <erodri@lsi.upc.edu> for the bug report.
   3.836 +
   3.837 +        * src/glpios03.c, src/glpios04.c, src/glpios05.c
   3.838 +        MIR (mixed integer rounding) cuts were implemented.
   3.839 +
   3.840 +Sun Oct 28 12:00:00 2007 Andrew Makhorin <mao@mai2.rcnet.ru>
   3.841 +
   3.842 +        * GLPK 4.23 (8:0:8) has been released
   3.843 +
   3.844 +        * src/glplib05.c, configure.ac
   3.845 +        Check for vsnprintf was added.
   3.846 +
   3.847 +        * include/glppds.h, src/glppds.c
   3.848 +        A module to scan plain data was added.
   3.849 +
   3.850 +        * src/glpapi09.c
   3.851 +        The following new API routines were added:
   3.852 +        glp_read_sol    read basic solution from text file;
   3.853 +        glp_write_sol   write basic solution to text file;
   3.854 +        glp_read_ipt    read interior-point solution from text file;
   3.855 +        glp_write_ipt   write interior-point solution to text file;
   3.856 +        glp_read_mip    read MIP solution from text file;
   3.857 +        glp_write_mip   write MIP solution to text file.
   3.858 +
   3.859 +        * src/glpapi12.c
   3.860 +        Advanced API routine glp_free_env was added.
   3.861 +
   3.862 +        * examples/glpsol.c
   3.863 +        The following three command-line options were added:
   3.864 +        --mipgap tol    set relative MIP gap tolerance
   3.865 +        -r filename     read solution from filename
   3.866 +        -w filename     write solution to filename
   3.867 +
   3.868 +Wed Sep 19 12:00:00 2007 Andrew Makhorin <mao@mai2.rcnet.ru>
   3.869 +
   3.870 +        * GLPK 4.22 (7:0:7) has been released
   3.871 +
   3.872 +        * src/glpios02.c
   3.873 +        A bug was fixed in the MIP preprocessor (ios_preprocess_node).
   3.874 +        Thanks to Roberto Bagnara <bagnara@cs.unipr.it> (Department of
   3.875 +        Mathematics, University of Parma, Italy) for the bug report.
   3.876 +
   3.877 +        * src/glpios02.c
   3.878 +        A bug was fixed in the MIP preprocessor (col_implied_bounds),
   3.879 +        due to which constraint coefficients with small magnitude could
   3.880 +        lead to wrong implied bounds of structural variables.
   3.881 +
   3.882 +        * src/glpipp02.c
   3.883 +        A similar bug was fixed in the routine reduce_bounds.
   3.884 +
   3.885 +        * src/glpapi01.c
   3.886 +        A bug was fixed in the routines glp_set_mat_row and
   3.887 +        glp_set_mat_col. (The bug appeared due to incorrect removing
   3.888 +        zero elements from the row/column lists.)
   3.889 +
   3.890 +        * src/glplpx14.c
   3.891 +        A bug was fixed in the API routines lpx_read_mps and
   3.892 +        lpx_read_freemps, due to which bounds of type LI specified in
   3.893 +        BOUNDS section were incorrectly processed.
   3.894 +
   3.895 +        * src/glplib05.c
   3.896 +        A call to standard function vsprintf was replaced by a call to
   3.897 +        vsnprintf for security reasons. Many thanks to Peter T. Breuer
   3.898 +        <ptb@inv.it.uc3m.es> and Rafael Laboissiere <rafael@debian.org>.
   3.899 +
   3.900 +Tue Aug 28 12:00:00 2007 Andrew Makhorin <mao@mai2.rcnet.ru>
   3.901 +
   3.902 +        * GLPK 4.21 (6:0:6) has been released
   3.903 +
   3.904 +        * glpscg.h, glpscg.c
   3.905 +        Routines to maintain sparse cliqued graph were added.
   3.906 +
   3.907 +        * glpios02.c
   3.908 +        MIP preprocessing routines were added.
   3.909 +
   3.910 +        * glpk.h, glpios.h, glpios03.c
   3.911 +        New reasons for calling the callback routine were introduced
   3.912 +        in the MIP solver.
   3.913 +
   3.914 +        * glpapi08.c
   3.915 +        Default backtracking strategy was changed to best local bound.
   3.916 +
   3.917 +        * glpapi11.c
   3.918 +        New API routine glp_term_out to enable/disable terminal output
   3.919 +        was added.
   3.920 +
   3.921 +        * glprng.h, glprng02.c
   3.922 +        Two routines to generate uniformly distributed pseudo-random
   3.923 +        floating-point numbers were added.
   3.924 +
   3.925 +Thu Jul 26 12:00:00 2007 Andrew Makhorin <mao@mai2.rcnet.ru>
   3.926 +
   3.927 +        * GLPK 4.20 (5:0:5) has been released
   3.928 +
   3.929 +        * glpk.h, glpapi08.c
   3.930 +        The routine lpx_integer was replaced by an equivalent routine
   3.931 +        glp_intopt. Also new API routine glp_init_iocp was added.
   3.932 +
   3.933 +        * glpiet.h, glpiet.c
   3.934 +        Routines implementing the implicit enumeration tree are
   3.935 +        no longer used and therefore were removed from the package.
   3.936 +
   3.937 +        * glpios.h, glpios01.c, glpios02, glpios03
   3.938 +        Routines implementing the integer optimization suite being
   3.939 +        replaced by a new version were removed from the package.
   3.940 +
   3.941 +        * glpmip.h, glpmip01.c, glpmip02.c
   3.942 +
   3.943 +        Routines implementing the B&B method being replaced by a new
   3.944 +        version were removed from the package.
   3.945 +
   3.946 +        * glpios.h, glpios01.c, glpios02.c
   3.947 +
   3.948 +        Routines implementing a new version of the integer optimization
   3.949 +        suite (IOS) based on the B&B method were added to the package.
   3.950 +
   3.951 +        * glpk.h, glpapi10.c
   3.952 +        Branch-and-bound interface routines were added to the package.
   3.953 +
   3.954 +        * examples/tspsol.c
   3.955 +        The TSP solver based on old version of the integer optimization
   3.956 +        suite is no more supported and was removed from the package.
   3.957 +
   3.958 +        * glpipp02.c
   3.959 +        An error in the routine reduce_bounds was fixed; thanks to
   3.960 +        Graham Rockwell <bionomicron@gmail.com> for the bug report.
   3.961 +
   3.962 +        * glpk.latex
   3.963 +        A new edition of the reference manual was included.
   3.964 +
   3.965 +Thu Jul 05 12:00:00 2007 Andrew Makhorin <mao@mai2.rcnet.ru>
   3.966 +
   3.967 +        * GLPK 4.19 (4:0:4) has been released
   3.968 +
   3.969 +        The principal change is upgrading to GPLv3.
   3.970 +
   3.971 +        * glpapi01.c
   3.972 +        A serious bug in the routine glp_del_cols was fixed; thanks to
   3.973 +        Cedric[FR] <fox2113@wanadoo.fr> for the bug report. The bug
   3.974 +        appeared because on deleting non-basic columns the basis header
   3.975 +        remained valid, however, contained invalid (old) column ordinal
   3.976 +        numbers.
   3.977 +
   3.978 +        * glpapi10.c
   3.979 +        A new advanced API routine glp_mem_limit was added.
   3.980 +
   3.981 +        * glplpx01.c
   3.982 +        The case GLP_EBOUND was added to the routine lpx_simplex.
   3.983 +        Thanks to Cameron Kellough <Cameron.Kellough@sri.com> for the
   3.984 +        bug report.
   3.985 +
   3.986 +        * glplpx19.c
   3.987 +        An API routine lpx_write_pb to write the problem instance in
   3.988 +        OPB (pseudo boolean) format format was added. Thanks to Oscar
   3.989 +        Gustafsson <oscarg@isy.liu.se> for the contribution.
   3.990 +
   3.991 +        * glpsol.c
   3.992 +        Two new options --wpb and --wnpb were added to glpsol to write
   3.993 +        the problem instance in OPB format.
   3.994 +
   3.995 +Mon Jun 25 12:00:00 2007 Andrew Makhorin <mao@mai2.rcnet.ru>
   3.996 +
   3.997 +        * GLPK 4.18 (3:0:3) has been released
   3.998 +
   3.999 +        * glplib.h
  3.1000 +        Type names ulong_t and uldiv_t were changed to glp_ulong and
  3.1001 +        glp_uldiv to avoid conflicts with standard type names on some
  3.1002 +        platforms. Thanks to Boris Wirtz <Boris.Wirtz@uni-oldenburg.de>
  3.1003 +        for the bug report.
  3.1004 +
  3.1005 +        * glpbfd.*, glpfhv.*, glplpf.*
  3.1006 +        LP basis factorization routines were made tidy.
  3.1007 +
  3.1008 +        * glpk.h, glpapi04.c
  3.1009 +        The following API routines were added:
  3.1010 +        glp_set_rii, glp_set_sjj, glp_get_rii, glp_get_sjj.
  3.1011 +
  3.1012 +        * glpk.h, glpapi06.c
  3.1013 +        The routine lpx_simplex was replaced by an equivalent routine
  3.1014 +        glp_simplex. Also new API routine glp_init_smcp was added.
  3.1015 +
  3.1016 +        * glpk.h, glpapi09.c
  3.1017 +        The following advanced API routines were added:
  3.1018 +        glp_bf_exists, glp_factorize, glp_bf_updated, glp_get_bfcp,
  3.1019 +        glp_set_bfcp, glp_get_bhead, glp_get_row_bind, glp_get_col_bind,
  3.1020 +        glp_ftran, glp_btran.
  3.1021 +
  3.1022 +        * glpk.latex
  3.1023 +        A new edition of the reference manual was included.
  3.1024 +
  3.1025 +        * examples/dea.mod, examples/food.mod, examples/food2.mod
  3.1026 +        Three examples in the MathProg language were added.
  3.1027 +        Thanks to Sebastian Nowozin <nowozin@gmail.com>.
  3.1028 +
  3.1029 +Sat May 26 12:00:00 2007 Andrew Makhorin <mao@mai2.rcnet.ru>
  3.1030 +
  3.1031 +        * GLPK 4.17 (2:0:2) has been released
  3.1032 +
  3.1033 +        * glpdmp.h, glpdmp.c
  3.1034 +        Memory pool routines were replaced by a new version.
  3.1035 +
  3.1036 +        * glpscs.h, glpscs.c
  3.1037 +        Segmented string routines were replaced by a new version.
  3.1038 +
  3.1039 +        * glplpx08.c, glplpx09.c
  3.1040 +        Now the MIP problem may have no integer columns.
  3.1041 +
  3.1042 +        * glpapi01.c
  3.1043 +        The routines glp_set_mat_row, glp_set_mat_col, and glp_load_mat
  3.1044 +        were modified to allow zero elements (which are not stored in
  3.1045 +        the constraint matrix).
  3.1046 +
  3.1047 +        * glpscf.h, glpscf.c
  3.1048 +        Schur complement factorization routines were implemented.
  3.1049 +
  3.1050 +        * glplpf.h, glplpf.c
  3.1051 +        LP basis factorization routines based on LU-factorization and
  3.1052 +        Schur complement were implemented.
  3.1053 +
  3.1054 +        * glplpx02.c, glplpx03.c
  3.1055 +        New control parameter LPX_K_BFTYPE was introduced to choose the
  3.1056 +        basis factorization type used by the simplex method routines.
  3.1057 +
  3.1058 +        * glpsol.c
  3.1059 +        Three new command-line options were added to choose the basis
  3.1060 +        factorization type used by the simplex method routines: --luf,
  3.1061 +        --cbg, and --cgr.
  3.1062 +
  3.1063 +        * glpk.latex
  3.1064 +        A new edition of the reference manual was included.
  3.1065 +
  3.1066 +Sat May 05 12:00:00 2007 Andrew Makhorin <mao@mai2.rcnet.ru>
  3.1067 +
  3.1068 +        * GLPK 4.16 (1:0:1) has been released
  3.1069 +
  3.1070 +        * glpk.h, glpapi.c, glplpx01.c, glplpx02.c
  3.1071 +        Names of a number basic api routines were changed and now have
  3.1072 +        the prefix 'glp_'. To keep backward compatibility these routines
  3.1073 +        are also available via their old names prefixed with 'lpx_'.
  3.1074 +
  3.1075 +        * glplpx19.c
  3.1076 +        Three new api routines were added: glp_version, glp_term_hook,
  3.1077 +        and glp_mem_usage.
  3.1078 +
  3.1079 +        * glpk.latex, gmpl.texi
  3.1080 +        A new edition of the reference manuals was included.
  3.1081 +
  3.1082 +        * lpglpk40.c
  3.1083 +        This example program is no longer supported and therefore was
  3.1084 +        removed from the package.
  3.1085 +
  3.1086 +Sun Feb 18 12:00:00 2007 Andrew Makhorin <mao@mai2.rcnet.ru>
  3.1087 +
  3.1088 +        * GLPK 4.15 (0:0:0) has been released
  3.1089 +
  3.1090 +        * configure.ac, Makefile.am
  3.1091 +        Autotools specification files were changed to use GNU Libtool
  3.1092 +        that allows building the static as well as shared GLPK library.
  3.1093 +        Thanks to Rafael Laboissiere <rafael@debian.org>.
  3.1094 +
  3.1095 +Mon Feb 05 08:00:00 2007 Andrew Makhorin <mao@mai2.rcnet.ru>
  3.1096 +
  3.1097 +        * GLPK 4.14 has been released
  3.1098 +        Now GLPK conforms to ILP32, LLP64, and LP64 programming models
  3.1099 +        (the latter seems to be the ultimate choice regarding 64-bit
  3.1100 +        architectures). Note that GLPK itself is a 32-bit application,
  3.1101 +        and the conformity only means that the package works correctly
  3.1102 +        on all these arenae. Nevertheless, on 64-bit platforms it is
  3.1103 +        possible to use more than 4GB of memory, if necessary.
  3.1104 +
  3.1105 +        * Makefile
  3.1106 +        Starting from this release only the header glpk.h is needed to
  3.1107 +        be installed.
  3.1108 +
  3.1109 +        * glplib01.c
  3.1110 +        Two routines bigmul and bigdiv which performs multiplication
  3.1111 +        and division of unsigned integers of arbitrary precision were
  3.1112 +        added.
  3.1113 +
  3.1114 +        * glplib02.c
  3.1115 +        A set of 64-bit arithmetic routines were added.
  3.1116 +
  3.1117 +        * glplib04.c
  3.1118 +        Some low-level library routines were improved and renamed.
  3.1119 +
  3.1120 +        * glpcfg.h
  3.1121 +        The macro GLP_TM_SPEC were introduced to specify a version of
  3.1122 +        the time routine depending on the host environment.
  3.1123 +
  3.1124 +Mon Nov 13 12:00:00 2006 Andrew Makhorin <mao@mai2.rcnet.ru>
  3.1125 +
  3.1126 +        * GLPK 4.13 has been released
  3.1127 +
  3.1128 +        * configure.in
  3.1129 +        '-lm' bug was fixed.
  3.1130 +
  3.1131 +        * glpbfx.h, glpbfx.c
  3.1132 +        Basis factorization interface routines based on exact (bignum)
  3.1133 +        arithmetic were implemented.
  3.1134 +
  3.1135 +        * glpssx.h, glpssx1.c, glpssx2.c
  3.1136 +        Simplex method routines based on exact (bignum) arithmetic were
  3.1137 +        implemented.
  3.1138 +
  3.1139 +        * glplpx6e.c
  3.1140 +        The routine lpx_exact, which is an easy-to-use driver to the
  3.1141 +        exact simplex method, was added.
  3.1142 +
  3.1143 +        * glpsol.c
  3.1144 +        Two command-line options were added: '--exact' and '--xcheck'.
  3.1145 +
  3.1146 +Wed Nov 08 12:00:00 2006 Andrew Makhorin <mao@mai2.rcnet.ru>
  3.1147 +
  3.1148 +        * GLPK 4.12 has been released
  3.1149 +
  3.1150 +        * glpcfg.h
  3.1151 +        The package configuration file was added.
  3.1152 +
  3.1153 +        * glplib2.c
  3.1154 +        Alternative version of the routines umalloc, ucalloc, and ufree
  3.1155 +        was provided. It does not limit the amount of allocated memory
  3.1156 +        to INT_MAX bytes and therefore can be used on platforms where
  3.1157 +        sizeof(void *) > sizeof(int). To enable this version one should
  3.1158 +        define the preprocessor variable GLP_HUGE_MEM.
  3.1159 +
  3.1160 +        * glprng.c
  3.1161 +        The routine rng_create_rand was changed to initialize the
  3.1162 +        generator using seed = 1, not 0, to conform ISO C requirements.
  3.1163 +
  3.1164 +        * glpgmp.h, glpgmp.c
  3.1165 +        A set of bignum arithmetic routines implementing operations on
  3.1166 +        integers and rationals was added. These routines are compatible
  3.1167 +        with the GNU MP library.
  3.1168 +
  3.1169 +        NOTE: To attain a much better performance it is recommended to
  3.1170 +        use, if possible, the original GNU MP library rather than the
  3.1171 +        GLPK version, by defining the preprocessor variable GLP_USE_GMP.
  3.1172 +
  3.1173 +        * glplux.h, glplux.c
  3.1174 +        A tentative implementation of sparse LU-factorization based on
  3.1175 +        exact (bignum) arithmetic was added.
  3.1176 +
  3.1177 +        * glpssx.h, glpssx.c
  3.1178 +        A tentative implementation of some simplex method routines based
  3.1179 +        on exact (bignum) arithmetic was added.
  3.1180 +
  3.1181 +        * glplpx6f.c
  3.1182 +        A preliminary implementation of the routine lpx_exact_check was
  3.1183 +        added. This routine checks the current basis for primal and dual
  3.1184 +        feasibility using exact (bignum) arithmetic.
  3.1185 +
  3.1186 +        * examples/glpsol.c
  3.1187 +        The command-line option '--xcheck' was introduced to check the
  3.1188 +        current basis for feasibility using exact (bignum) arithmetic.
  3.1189 +
  3.1190 +Tue Jul 25 12:00:00 2006 Andrew Makhorin <mao@mai2.rcnet.ru>
  3.1191 +
  3.1192 +        * GLPK 4.11 has been released.
  3.1193 +
  3.1194 +        * include/glpbfi.h, src/glpbfi.c
  3.1195 +        Basis factorization interface routines were added.
  3.1196 +
  3.1197 +        * include/glpluf.h, src/glpluf1.c
  3.1198 +        Hypersparse solution routines were added.
  3.1199 +
  3.1200 +        * include/glpinv.h, src/glpinv1.c
  3.1201 +        Hypersparse solution routines (fake version) were added.
  3.1202 +
  3.1203 +        * include/glpmpl.h, src/glpmpl.c
  3.1204 +        Built-in functions card, length, and substr were implemented.
  3.1205 +        Output redirection in the printf statement was implemented.
  3.1206 +
  3.1207 +        * examples/graph.mod, examples/crypto.mod
  3.1208 +        Two example models illustrating new features of the modeling
  3.1209 +        language were included.
  3.1210 +
  3.1211 +Thu May 11 12:00:00 2006 Andrew Makhorin <mao@mai2.rcnet.ru>
  3.1212 +
  3.1213 +        * GLPK 4.10 has been released.
  3.1214 +
  3.1215 +        * src/glplpx8a.c
  3.1216 +        A fragment was added to the routines lpx_read_mps and
  3.1217 +        lpx_read_freemps to accept LI bound type (it is similar to LO,
  3.1218 +        however, additionally marks the column as integer).
  3.1219 +
  3.1220 +        * include/glpbfi.h, src/glpbfi.c
  3.1221 +        The module glpbfi which implements the basis factorization
  3.1222 +        interface (BFI) was added.
  3.1223 +
  3.1224 +        * src/glplpx7a.c
  3.1225 +        The routine lpx_cover_cut to generate mixed cover cuts was
  3.1226 +        added.
  3.1227 +
  3.1228 +        * src/glplpx7b.c
  3.1229 +        The routine lpx_clique_cut to generate clique cuts and related
  3.1230 +        routines to maintain the conflict graph were added.
  3.1231 +
  3.1232 +        * include/glplpx.h, src/glplpx5.c
  3.1233 +        The routine lpx_cpx_basis implementing Bixby's algorithm to
  3.1234 +        construct an initial LP basis was added.
  3.1235 +
  3.1236 +        * examples/glpsol.c
  3.1237 +        Command-line option '--bib' was added which allows building
  3.1238 +        an initial LP basis using Bixby's algorithm.
  3.1239 +        Default command-line option '--mps' was changed to '--freemps'.
  3.1240 +
  3.1241 +        * examples/cf12a.mod, examples/cf12b.mod
  3.1242 +        Two examples in MathProg (curve fitting problem) were added.
  3.1243 +        Thanks to Dr. Harley Mackenzie <hjm@hardsoftware.com>.
  3.1244 +
  3.1245 +Tue Jan 17 12:00:00 2006 Andrew Makhorin <mao@mai2.rcnet.ru>
  3.1246 +
  3.1247 +        * GLPK 4.9 has been released.
  3.1248 +
  3.1249 +        * glpipp.h, glpipp1.c, glpipp2.c
  3.1250 +        A MIP presolver were implemented (currently incomplete). It is
  3.1251 +        used internally in the routine lpx_intopt (see below).
  3.1252 +
  3.1253 +        * glplpx6d.c, glplpx7a.c
  3.1254 +        An advanced branch-and-bound solver (the routine lpx_intopt)
  3.1255 +        were implemented.
  3.1256 +
  3.1257 +        * glplpx6c.c
  3.1258 +        The routine lpx_check_int to check MIP feasibility conditions
  3.1259 +        was added.
  3.1260 +
  3.1261 +        * glplpx8a.c
  3.1262 +        The routine lpx_print_mip was changed to print MIP feasibility
  3.1263 +        conditions.
  3.1264 +
  3.1265 +        * glpmpl.h, glpmpl1.c, glpmpl3.c
  3.1266 +        The built-in functions sin, cos, atan, and atan2 were added to
  3.1267 +        the MathProg language.
  3.1268 +
  3.1269 +        * doc/lang.*
  3.1270 +        Some typos were fixed.
  3.1271 +        Thanks to Minh Ha Duong <haduong@centre-cired.fr> (CIRED, CNRS).
  3.1272 +
  3.1273 +Wed Jan 12 12:00:00 2005 Andrew Makhorin <mao@mai2.rcnet.ru>
  3.1274 +
  3.1275 +        * GLPK 4.8 has been released.
  3.1276 +
  3.1277 +        * glpspx.h, glpspx1.c, glpspx2.c, glplpx6a.c
  3.1278 +        Simplex method routines were changed due to a new format of the
  3.1279 +        constraint matrix.
  3.1280 +
  3.1281 +        * glpmat.h, glpmat.c
  3.1282 +        Sparse matrix routines were re-implemented using storage-by-rows
  3.1283 +        format.
  3.1284 +
  3.1285 +        * glpipm.h, glpipm.c, glplpx6b.c
  3.1286 +        Interior-point method routines were changed due to a new format
  3.1287 +        of sparse matrices.
  3.1288 +
  3.1289 +        * glpchol.h, glpchol.c
  3.1290 +        Old version of Cholesky factorization routines being replaced by
  3.1291 +        a new one (see glpmat.c) was removed from the package.
  3.1292 +
  3.1293 +        * glplpx8c.c
  3.1294 +        Minor bug was fixed in api routine lpx_read_cpxlp.
  3.1295 +
  3.1296 +Mon Aug 23 12:00:00 2004 Andrew Makhorin <mao@mai2.rcnet.ru>
  3.1297 +
  3.1298 +        * GLPK 4.7 has been released.
  3.1299 +
  3.1300 +        * glplpx.h, glplpx1.c
  3.1301 +        New core API routines were added (but not documented yet):
  3.1302 +        lpx_order_matrix, lpx_create_index, lpx_find_row, lpx_find_col,
  3.1303 +        lpx_delete_index.
  3.1304 +
  3.1305 +        * glplpx8a.c
  3.1306 +        API routine lpx_read_mps was re-implemented, and two new API
  3.1307 +        routines lpx_read_freemps and lpx_write_freemps were added to
  3.1308 +        support free MPS format.
  3.1309 +
  3.1310 +        * glplpx8c.c
  3.1311 +        Two API routines lpx_read_cpxlp and lpx_write_cpxlp (formerly
  3.1312 +        named lpx_read_lpt and lpx_write_lpt) were re-implemented.
  3.1313 +
  3.1314 +        * glpmps.h, glpmps.c
  3.1315 +        This module formerly used in lpx_read_mps was removed from the
  3.1316 +        package.
  3.1317 +
  3.1318 +        * glplpt.h, glplpt.c
  3.1319 +        This module formerly used in lpx_read_lpt was removed from the
  3.1320 +        package.
  3.1321 +
  3.1322 +        * glpmip.h, glpmip1.h, glpmip2.h
  3.1323 +        New MIP routines mip_best_node and mip_relative_gap were added
  3.1324 +        due to suggestion of Brady Hunsaker <hunsaker@engr.pitt.edu>.
  3.1325 +
  3.1326 +        * glpsol.c
  3.1327 +        The following new command-options were added:
  3.1328 +        --freemps  to read problem data in free MPS format
  3.1329 +        --wfreemps to write problem data in free MPS format
  3.1330 +        --cpxlp    to read problem data in CPLEX LP format
  3.1331 +        --wcpxlp   to write problem data in CPLEX LP format
  3.1332 +        --bas      to read LP basis from a text file in MPS format
  3.1333 +        --wbas     to write LP basis to a text file in MPS format
  3.1334 +        --mostf    to use "most fractional" branching heuristic
  3.1335 +        --bestb    to use "best bound" backtracking heuristic
  3.1336 +
  3.1337 +        * contrib/deli/*.*
  3.1338 +        GLPK Delphi interface module was temporarily removed from the
  3.1339 +        distribution due to licensing problems.
  3.1340 +
  3.1341 +        * contrib/glpkmex/*.*
  3.1342 +        GLPK Matlab interface module was temporarily removed from the
  3.1343 +        distribution due to licensing problems.
  3.1344 +
  3.1345 +        * contrib/jni/*.*
  3.1346 +        GLPK Java interface module was temporarily removed from the
  3.1347 +        distribution due to licensing problems.
  3.1348 +
  3.1349 +Wed Aug 04 12:00:00 2004 Andrew Makhorin <mao@mai2.rcnet.ru>
  3.1350 +
  3.1351 +        * GLPK 4.6 has been released.
  3.1352 +
  3.1353 +        * glpmpl.h, glpmpl1.c, glpmpl2.c, glpmpl3.c, glpmpl4.c
  3.1354 +        Three new statements were implemented in the GNU MathProg
  3.1355 +        language: solve, printf, and for. Also some bugs were fixed.
  3.1356 +
  3.1357 +        * glplpx.h, glplpx8e.c
  3.1358 +        Two API routines were added: lpx_read_prob and lpx_write_prob,
  3.1359 +        which allow reading and writing problem data in GNU LP format.
  3.1360 +
  3.1361 +        * glpsol.c
  3.1362 +        Three new command-line options were added: --glp (to read
  3.1363 +        problem data in GNU LP format), --wglp (to write problem data
  3.1364 +        in GNU LP format), and --name (to change problem name).
  3.1365 +
  3.1366 +        * glprng.h, glprng.c
  3.1367 +        A portable pseudo-random number generator was implemented as a
  3.1368 +        separate module.
  3.1369 +
  3.1370 +        * glplib4.c
  3.1371 +        The old implementation of a pseudo-random number generator was
  3.1372 +        removed from the package.
  3.1373 +
  3.1374 +        * doc/lang.*, doc/refman.*
  3.1375 +        New edition of the GLPK documentation was included.
  3.1376 +
  3.1377 +        * contrib/glpkmex/*.*
  3.1378 +        A new version of GLPKMEX was included in the distribution. For
  3.1379 +        more details see contrib/glpkmex/ChangeLog.
  3.1380 +
  3.1381 +Mon Jul 19 12:00:00 2004 Andrew Makhorin <mao@mai2.rcnet.ru>
  3.1382 +
  3.1383 +        * GLPK 4.5 has been released.
  3.1384 +
  3.1385 +        * glpmip.h, glpmip1.c, glpmip2.c, glplpx6c.c
  3.1386 +        New implementation of the branch-and-bound method was added.
  3.1387 +        It replaces the old implementation, which was removed from the
  3.1388 +        package.
  3.1389 +
  3.1390 +        * glpies.h, glpies1.c, glpies2.c, glpies3.c
  3.1391 +        Modules used in the old implementation of the branch-and-bound
  3.1392 +        method were removed from the package.
  3.1393 +
  3.1394 +        * glplib2.c
  3.1395 +        Now if the preprocessor variable GLPHUGEMEM is defined, other
  3.1396 +        version of the routines umalloc, ucalloc, and ufree is used on
  3.1397 +        compiling the package. This allows avoiding memory allocation
  3.1398 +        problems on platforms where sizeof(void *) > sizeof(int), for
  3.1399 +        example, where addresses are 64-bit while integers are 32-bit.
  3.1400 +        The modification was made due to a bug report provided by Karel
  3.1401 +        Zimmermann <kzimm@diamant.jouy.inra.fr> and Christophe Caron
  3.1402 +        <caron@diamant.jouy.inra.fr>.
  3.1403 +
  3.1404 +Sat Jan 17 12:00:00 2004 Andrew Makhorin <mao@mai2.rcnet.ru>
  3.1405 +
  3.1406 +        * GLPK 4.4 has been released.
  3.1407 +
  3.1408 +        * glplpx.h, glplpx*.c
  3.1409 +        All API routines were re-implemented using new data structures.
  3.1410 +        Some new API routines were added and some existing API routines
  3.1411 +        became obsolete as shown below:
  3.1412 +
  3.1413 +        Obsolete API routine   Equivalent new API routine
  3.1414 +        lpx_check_name         (no more supported)
  3.1415 +        lpx_set_obj_c0         lpx_set_obj_coef
  3.1416 +        lpx_set_row_coef       (no more supported)
  3.1417 +        lpx_set_col_coef       lpx_set_obj_coef
  3.1418 +        lpx_load_mat           (no more supported)
  3.1419 +        lpx_load_mat3          lpx_load_matrix
  3.1420 +        lpx_unmark_all         (no more supported)
  3.1421 +        lpx_mark_row           (no more supported)
  3.1422 +        lpx_mark_col           (no more supported)
  3.1423 +        lpx_clear_mat          (no more supported)
  3.1424 +        lpx_del_items          lpx_del_rows, lpx_del_cols
  3.1425 +        lpx_get_row_bnds       lpx_get_row_type, lpx_get_row_lb,
  3.1426 +                               lpx_get_row_ub
  3.1427 +        lpx_get_col_bnds       lpx_get_col_type, lpx_get_col_lb,
  3.1428 +                               lpx_get_col_ub
  3.1429 +        lpx_get_obj_c0         lpx_get_obj_coef
  3.1430 +        lpx_get_row_coef       (no more supported)
  3.1431 +        lpx_get_col_coef       lpx_get_obj_coef
  3.1432 +        lpx_get_row_mark       (no more supported)
  3.1433 +        lpx_get_col_mark       (no more supported)
  3.1434 +        lpx_get_row_info       lpx_get_row_stat, lpx_get_row_prim,
  3.1435 +                               lpx_get_row_dual
  3.1436 +        lpx_get_col_info       lpx_get_col_stat, lpx_get_col_prim,
  3.1437 +                               lpx_get_col_dual
  3.1438 +        lpx_get_ips_stat       lpx_ipt_status
  3.1439 +        lpx_get_ips_row        lpx_ipt_row_prim, lpx_ipt_row_dual
  3.1440 +        lpx_get_ips_col        lpx_ipt_col_prim, lpx_ipt_col_dual
  3.1441 +        lpx_get_ips_obj        lpx_ipt_obj_val
  3.1442 +        lpx_get_mip_stat       lpx_mip_status
  3.1443 +        lpx_get_mip_row        lpx_mip_row_val
  3.1444 +        lpx_get_mip_col        lpx_mip_col_val
  3.1445 +        lpx_get_mip_obj        lpx_mip_obj_val
  3.1446 +
  3.1447 +        Obsolete API routines were kept for backward compatibility,
  3.1448 +        however, they will be removed in the future.
  3.1449 +
  3.1450 +        * doc/refman.*
  3.1451 +        New edition of the GLPK reference manual containing description
  3.1452 +        of all new API routines was included.
  3.1453 +
  3.1454 +        * contrib/glpkmex/*.*
  3.1455 +        GLPKMEX, a Matlab MEX interface to GLPK package, contributed by
  3.1456 +        Nicolo Giorgetti <giorgetti@dii.unisi.it> was included.
  3.1457 +
  3.1458 +        * doc/GLPK_FAQ.txt
  3.1459 +        GLPK FAQ contributed by Harley Mackenzie <hjm@bigpond.com> was
  3.1460 +        included.
  3.1461 +
  3.1462 +Fri Dec 12 12:00:00 2003 Andrew Makhorin <mao@mai2.rcnet.ru>
  3.1463 +
  3.1464 +        * GLPK 4.3 has been released.
  3.1465 +
  3.1466 +        * configure.in
  3.1467 +        The bug, due to which the standard math library is not linked on
  3.1468 +        some platforms, was fixed.
  3.1469 +
  3.1470 +        * glpmpl3.c
  3.1471 +        The bug (0 ** y) was fixed in the routine fp_power.
  3.1472 +
  3.1473 +        * glpmpl.h, glpmpl1.c, glpmpl3.c
  3.1474 +        Some new built-in functions (round, trunc, Irand224, Uniform01,
  3.1475 +        Uniform, Normal01, Normal) were added to the MathProg language.
  3.1476 +
  3.1477 +        * glpmpl1.c
  3.1478 +        The MathProg syntax was changed to allow writing 'subj to'.
  3.1479 +
  3.1480 +        * glplpx.h, glplpx1.c, glplpx2.c
  3.1481 +        The new api routine lpx_get_ray_info was added.
  3.1482 +
  3.1483 +        * glplpx8a.c
  3.1484 +        The api routine lpx_print_sol was changed to print the number of
  3.1485 +        non-basic variable, which causes primal unboundness.
  3.1486 +
  3.1487 +        * glpmps.c
  3.1488 +        The code was changed to avoid errors on compiling the package on
  3.1489 +        Mac OS X. Thanks to Andre Girard <andre@inrs-emt.uquebec.ca> for
  3.1490 +        the bug report.
  3.1491 +
  3.1492 +        * doc/lang.*, doc/refman.*
  3.1493 +        Several typos were fixed and some new material was added in the
  3.1494 +        glpk documentation.
  3.1495 +
  3.1496 +Fri Nov 14 12:00:00 2003 Andrew Makhorin <mao@mai2.rcnet.ru>
  3.1497 +
  3.1498 +        * GLPK 4.2 has been released.
  3.1499 +
  3.1500 +        * glpiet.h, glpiet.c, glpios.h, glpios1.c, glpios2.c, glpios3.c
  3.1501 +        A preliminary implementation of the Integer Optimization Suite
  3.1502 +        (IOS) was included in the package. Eventually IOS will replace
  3.1503 +        the Implicit Enumeration Suite (IES).
  3.1504 +
  3.1505 +        * glplpx.h, glplpx6d.c
  3.1506 +        A dummy version of the integer optimization routine lpx_intopt
  3.1507 +        was included in the package. Later this routine will replace the
  3.1508 +        routine lpx_integer.
  3.1509 +
  3.1510 +        * examples/glpsol.c
  3.1511 +        A new command-line option --int-opt was added to the solver to
  3.1512 +        call lpx_intopt rather than lpx_integer.
  3.1513 +
  3.1514 +        * glpbcs.h, glpbcs1.c, glpbcs2.c
  3.1515 +        Being replaced by IOS routines (see above) the Branch-and-Cut
  3.1516 +        Framework (BCS) routines were removed from the package.
  3.1517 +
  3.1518 +        * examples/tspsol.c
  3.1519 +        Stand-alone Symmetric TSP solver was completely re-programmed
  3.1520 +        using IOS routines.
  3.1521 +
  3.1522 +        * glplib.h, glplib2.c, glplib4.c
  3.1523 +        The random-number generator was implemented. It is based on the
  3.1524 +        module GB_FLIB from the Stanford GraphBase originally developed
  3.1525 +        by Donald Knuth.
  3.1526 +
  3.1527 +        * glphbsm.c, glplpx8a.c, glpmps.c
  3.1528 +        All calls to fopen/fclose were replaced by corresponding calls
  3.1529 +        to ufopen/ufclose due to bug reports provided by Morten Welinder
  3.1530 +        <terra@gnu.org> and <jpark@sfwmd.gov>.
  3.1531 +
  3.1532 +        * glpmps.c
  3.1533 +        The code was made re-entrant.
  3.1534 +
  3.1535 +        * glplpx8b.c
  3.1536 +        API routine lpx_print_sens_bnds for bounds sensitivity analysis
  3.1537 +        contributed by Brady Hunsaker <hunsaker@engr.pitt.edu> was added
  3.1538 +        to the package. This feature is also available in glpsol via the
  3.1539 +        command-line option --bounds.
  3.1540 +
  3.1541 +        * contrib/jni/*.*
  3.1542 +        New version of GLPK JNI (Java Native Interface) contributed by
  3.1543 +        Chris Rosebrugh <cpr@pobox.com> was added to the package.
  3.1544 +
  3.1545 +        * contrib/deli/*.*
  3.1546 +        GLPK DELI (Delphi Interface) contributed by Ivo van Baren
  3.1547 +        <i.van.baren@freeler.nl> was added to the package.
  3.1548 +
  3.1549 +        * glplpx3.c
  3.1550 +        Default method to scale the problem was changed to equilibration
  3.1551 +        scaling (lp->scale = 1 in lpx_reset_parms).
  3.1552 +
  3.1553 +        * glplpx6a.c
  3.1554 +        Two minor (non-critical) typos were fixed due to report provided
  3.1555 +        by Andrew Hamilton-Wright <andrewhw@ieee.org>.
  3.1556 +
  3.1557 +        * glplpp2.c
  3.1558 +        An untested case (line 941) had been tested due to bug report
  3.1559 +        provided by Jiri Spitz <jiri.spitz@telecom.cz>.
  3.1560 +
  3.1561 +        * w32bc5.mak, w32vc6.mak, w32vc6d.mak, d32dmc.mak
  3.1562 +        Several makefiles were added to allow building GLPK library for
  3.1563 +        some non-GNU 32-bit platforms.
  3.1564 +
  3.1565 +Sat Aug 23 12:00:00 2003 Andrew Makhorin <mao@mai2.rcnet.ru>
  3.1566 +
  3.1567 +        * GLPK 4.1 has been released.
  3.1568 +
  3.1569 +        * glpmpl1.c, glpmpl3.c
  3.1570 +        Some bugs were fixed in the MathProg translator due to the bug
  3.1571 +        reports provided by Giles Thompson <gwpt1@cus.cam.ac.uk>:
  3.1572 +        conditional set expressions were incorrectly parsed;
  3.1573 +        dimen attribute was not set by default when a set was used
  3.1574 +        recursively in its own declaration;
  3.1575 +        logical expressions ... in if ... then ... else ... did not
  3.1576 +        work;
  3.1577 +        displaying set expressions did not free memory allocated for
  3.1578 +        temporary results.
  3.1579 +
  3.1580 +        * glpmpl3.c (reduce_terms)
  3.1581 +        Implementation of summation of linear forms over domain was
  3.1582 +        improved to reduce complexity of that operation from O(n*n) to
  3.1583 +        O(n*log n). The improvement was made due to a report provided
  3.1584 +        by Sebastien de Menten <sdementen@hotmail.com>.
  3.1585 +
  3.1586 +        * glplpx6a.c (line 1056), glpmip1.c (line 641)
  3.1587 +        Two minor bugs were fixed due to the bug report provided by
  3.1588 +        Kendall Demaree <kendal.demaree@verizon.net>.
  3.1589 +
  3.1590 +        * glplpx.h, glplpx6a.c
  3.1591 +        The method of one artificial variable implemented in the routine
  3.1592 +        lpx_prim_art and used on the phase I in the glpk simplex solver
  3.1593 +        has a serious defect: for some lp instances it erroneously
  3.1594 +        reports that the problem has no primal feasible solution. This
  3.1595 +        error appears when the column of the artificial variable, which
  3.1596 +        enters the basis to make it primal feasible, has large
  3.1597 +        constraint coefficients, that leads to small reduced costs of
  3.1598 +        non-basic variables and premature termination of the search,
  3.1599 +        i.e. to wrong conclusion that the problem has no primal feasible
  3.1600 +        solution. To avoid this defect the routine lpx_prim_feas was
  3.1601 +        included. It implements the method of implicit artifical
  3.1602 +        variables (based on minimization of the sum of infeasibilities),
  3.1603 +        which is a bit slower but much more robust. The routine
  3.1604 +        lpx_prim_feas having the same functionality now is used instead
  3.1605 +        the routine lpx_prim_art.
  3.1606 +
  3.1607 +        * glpinv.h, glpinv.c
  3.1608 +        The test used in the routine inv_update to detect low accuracy
  3.1609 +        after updating LU-factorization of the basis matrix was replaced
  3.1610 +        by a new, more robust test.
  3.1611 +
  3.1612 +        * glplpx6c.c
  3.1613 +        Selecting an active node to be solved next in the routine
  3.1614 +        btrack_bestp was changed. Now, if any integer feasible solution
  3.1615 +        has not been found yet, the routine chooses an active node which
  3.1616 +        has the minimal sum of integer infeasibilities.
  3.1617 +
  3.1618 +        * glpmip.h, glpmip1.c
  3.1619 +        The additional flag int_obj was included in the structure
  3.1620 +        MIPTREE used by the branch-and-bound. This flag is set in the
  3.1621 +        routine mip_create_tree and used in the routine is_better. It
  3.1622 +        means that the objective is integral, i.e. depends only on
  3.1623 +        integer variables with integer objective coefficients. The test
  3.1624 +        used in the routine check_integrality was also replaced by a
  3.1625 +        new, more reasonable one.
  3.1626 +
  3.1627 +        * glplpx1.c
  3.1628 +        A minor bug was fixed in the routine lpx_check_name.
  3.1629 +
  3.1630 +        * glpmpl.h, glpmpl4.c, glplpx8d.c
  3.1631 +        The flag skip_data was added to the parameter list of the
  3.1632 +        routine mpl_read_model. If this flag is set, the data section
  3.1633 +        in the model file is ignored. Corresponding change was made in
  3.1634 +        the routine lpx_read_model. Now, if both model and data files
  3.1635 +        are specified, the data section in the model file is ignored.
  3.1636 +
  3.1637 +        * glplpx8c.c
  3.1638 +        A minor bug (wrong format used for writing free columns) in the
  3.1639 +        routine lpx_write_lpt was fixed due to the bug report provided
  3.1640 +        by Bernhard Schmidt <schmidt@math.uni-augsburg.de>
  3.1641 +
  3.1642 +        * sample/glpsol.c
  3.1643 +        The command-line parameter --tmlim, which allows limiting the
  3.1644 +        solution time, was added.
  3.1645 +
  3.1646 +        * doc/lang.*, doc/refman.*
  3.1647 +        New edition of the GLPK documentation was included.
  3.1648 +
  3.1649 +        * java-binding/*.*
  3.1650 +        New version of the GLPK JNI (Java Native Interface) package was
  3.1651 +        included in the distribution.
  3.1652 +
  3.1653 +        * sample/lpglpk40.c
  3.1654 +        A non-trivial example was added. It allows using GLPK as a base
  3.1655 +        LP solver for Concorde, a program for solving Traveling Salesman
  3.1656 +        Problem (TSP). For details see comments in lpglpk40.c.
  3.1657 +
  3.1658 +        * sample/*.mod
  3.1659 +        Some examples of LP and MIP models written in GNU MathProg were
  3.1660 +        added.
  3.1661 +
  3.1662 +Tue May 06 12:00:00 2003 Andrew Makhorin <mao@mai2.rcnet.ru>
  3.1663 +
  3.1664 +        * GLPK 4.0 has been released.
  3.1665 +
  3.1666 +        * glpmpl.h, glpmpl1.c, glpmpl2.c, glpmpl3.c, glpmpl4.c
  3.1667 +        The model translator for the GNU MathProg modeling language was
  3.1668 +        implemented and included in the package.
  3.1669 +
  3.1670 +        * glplpx.h, glplpx8d.c
  3.1671 +        The api routine lpx_read_model, which is an interface to the
  3.1672 +        MathProg translator, was included in the package.
  3.1673 +
  3.1674 +        * glplpx.h, glplpx8a.c
  3.1675 +        The api routine lpx_print_prob for writing LP/MIP problem data
  3.1676 +        in plain text format was included in the package.
  3.1677 +
  3.1678 +        * sample/glpsol.c
  3.1679 +        New version of the GLPK stand-alone LP/MIP solver that supports
  3.1680 +        the GNU MathProg modeling language was implemented.
  3.1681 +
  3.1682 +        * doc/lang.latex, doc/lang.dvi, doc/lang.ps
  3.1683 +        The document "GLPK: Modeling Language GNU MathProg" was included
  3.1684 +        in the package.
  3.1685 +
  3.1686 +        * doc/refman.latex, doc/refman.dvi, doc/refman.ps
  3.1687 +        New edition of the GLPK Reference Manual was included in the
  3.1688 +        package.
  3.1689 +
  3.1690 +        * glplpx8c.c
  3.1691 +        A bug in the api routine lpx_write_lpt was fixed. Due to that
  3.1692 +        bug an addressing error occured in the routine if the objective
  3.1693 +        function has the non-zero constant term.
  3.1694 +
  3.1695 +        * glplan.h, glplan1.c, glplan2.c, glplan3.c, glplan4.c,
  3.1696 +        * glplan5.c, glplan6.c, glplan7.c, glplan8.c, glplpx8b.c
  3.1697 +        All modules of the translator for the GLPK/L modeling language
  3.1698 +        were removed from the package, because GLPK/L being completely
  3.1699 +        superseded by GNU MathProg is no more supported.
  3.1700 +
  3.1701 +Tue Mar 25 12:00:00 2003 Andrew Makhorin <mao@mai2.rcnet.ru>
  3.1702 +
  3.1703 +        * GLPK 3.3 has been released.
  3.1704 +
  3.1705 +        * glplpp.h, glplpp1.c, glplpp2.c
  3.1706 +        An implementation of the built-in LP presolver was added to the
  3.1707 +        package.
  3.1708 +
  3.1709 +        * glplpx.h
  3.1710 +        The flag presol was added to the structure LPX. This flag tells
  3.1711 +        the lpx_simplex whether the built-in LP presolver should be used
  3.1712 +        or not. By default this flag is off. Also three macros (namely
  3.1713 +        LPX_E_NOPFS, LPX_E_NODFS, and LPX_K_PRESOL) that concern using
  3.1714 +        the LP presolver were introduced.
  3.1715 +
  3.1716 +        * glplpx3.c, glplpx6a.c
  3.1717 +        These modules was changed to use the built-in LP presolver.
  3.1718 +
  3.1719 +        * sample/glpsol.c
  3.1720 +        Command line options --presol and --nopresol that concern using
  3.1721 +        the LP presolver were added to the stand-alone LP/MIP solver.
  3.1722 +
  3.1723 +        * glplan1.c
  3.1724 +        This module was changed to allow declaring sets like A[1:10] in
  3.1725 +        the models written in the GLPK/L modeling language.
  3.1726 +
  3.1727 +        * doc/refman.latex, doc/lang.latex
  3.1728 +        New editions of the documents "GLPK User's Guide" and "GLPK/L
  3.1729 +        Modeling Language" were included in the distribution.
  3.1730 +
  3.1731 +        * java-binding/*.*
  3.1732 +        The package GLPK JNI (Java Native Interface) implementing Java
  3.1733 +        binding for GLPK was included in the distribution. This package
  3.1734 +        was developed and programmed by Yuri Victorovich <yuri@gjt.org>.
  3.1735 +
  3.1736 +Tue Feb 18 12:00:00 2003 Andrew Makhorin <mao@mai2.rcnet.ru>
  3.1737 +
  3.1738 +        * GLPK 3.2.4 has been released.
  3.1739 +
  3.1740 +        * glplpx6b.c
  3.1741 +        The code was changed to allow auxiliary variables have non-zero
  3.1742 +        objective coefficients.
  3.1743 +
  3.1744 +        Also a minor bug was fixed (the constant term was not considered
  3.1745 +        on displaying the objective function value).
  3.1746 +
  3.1747 +        * sample/glpsol.c
  3.1748 +        The code was changed to fix a bug (the command-line option 'bfs'
  3.1749 +        was not recognized). The bug was fixed due to report provided by
  3.1750 +        Olivier <odwl@skynet.be>.
  3.1751 +
  3.1752 +        * glplpt.c
  3.1753 +        The code was changed to fix a bug (binary variables were treated
  3.1754 +        erroneously as integer ones).
  3.1755 +
  3.1756 +        * glplpx6b.c
  3.1757 +        The code was changed to fix a bug (variables that have no lower
  3.1758 +        bounds were incorrectly processed on converting to the standard
  3.1759 +        formulation). The bug was fixed due to report kindly provided by
  3.1760 +        Kjell Eikland <kjell.eikland@broadpark.no>.
  3.1761 +
  3.1762 +Mon Nov 11 12:00:00 2002 Andrew Makhorin <mao@mai2.rcnet.ru>
  3.1763 +
  3.1764 +        * GLPK 3.2.3 has been released.
  3.1765 +
  3.1766 +        * glpmip.h, glpmip1.c
  3.1767 +        A preliminary implementation of the branch-and-bound driver
  3.1768 +        based on the implicit enumeration suite (glpies) was added to
  3.1769 +        the package. This module is not documented yet.
  3.1770 +
  3.1771 +        * glplpx6c.c
  3.1772 +        A new implementation of the api routine lpx_integer which now
  3.1773 +        is based on the b&b driver (see glpmip above) was included in
  3.1774 +        the package. This new implementation has exactly the same
  3.1775 +        functionality as the old version and therefore all changes are
  3.1776 +        transparent to the api user.
  3.1777 +
  3.1778 +        * glpbbm.h, glpbbm.c
  3.1779 +        * glprsm.h, glprsm1.c, glprsm2.c
  3.1780 +        * glplp.h, glplp.c
  3.1781 +        These modules were removed from the package, because they were
  3.1782 +        used only in the old version of the routine lpx_integer, which
  3.1783 +        was replaced by the new version (see glplpx6c above).
  3.1784 +
  3.1785 +        * glplpx.h, glplpx6a.c
  3.1786 +        The api routine lpx_check_kkt was included in the package and
  3.1787 +        its description was added in the reference manual. This routine
  3.1788 +        allows checking Karush-Kuhn-Tucker optimality conditions for an
  3.1789 +        LP solution.
  3.1790 +
  3.1791 +        * glplpx.h, glplpx8a.c
  3.1792 +        Now the api routine lpx_print_sol also prints information about
  3.1793 +        "solution quality" obtained via the api routine lpx_check_kkt.
  3.1794 +
  3.1795 +        * glplpx.h, glplpx8a.c
  3.1796 +        New api routines lpx_read_bas and lpx_write_bas were included
  3.1797 +        in the package and documented. The routine lpx_write_bas allows
  3.1798 +        writing a current basis from an LP object to a text file in the
  3.1799 +        MPS format. The routine lpx_read_bas allows reading a basis
  3.1800 +        prepared in the MPS format from a text file into an LP object.
  3.1801 +
  3.1802 +        * glplpt.c
  3.1803 +        The parsing routine which reads LP problem data prepared in the
  3.1804 +        CPLEX LP format was modified to allow specifying lower bounds
  3.1805 +        of variables also in the form 'variable >= lower bound' (in the
  3.1806 +        bounds section). This modification was made due to a notice
  3.1807 +        provided by Ivan Luzzi <iluzzi@libero.it>.
  3.1808 +
  3.1809 +        * glplpx.h, glplpx8c.c
  3.1810 +        The api routine lpx_write_lpt which allows writing LP problem
  3.1811 +        data from an LP object to a text file using the CPLEX LP format
  3.1812 +        was included in the package and documented.
  3.1813 +
  3.1814 +        * glplpx.h, glplpx3.c
  3.1815 +        The control parameter LPX_K_LPTORIG that affects the behavior
  3.1816 +        of the api routine lpx_write_lpt was introduced.
  3.1817 +
  3.1818 +        * glplan6.c
  3.1819 +        The semantics of the language GLPK/L was changed to allow
  3.1820 +        selection in case when not all mute letters of a predicate (the
  3.1821 +        operand that follows the keyword 'where') are presented in a
  3.1822 +        parameter (the operand that precedes the keyword 'where'), i.e.
  3.1823 +        to allow writing something like this:
  3.1824 +            y[j] := sum(i, x[i] where p[i,j]);
  3.1825 +        The paragraph "Selection" in the langauge description (page 25)
  3.1826 +        was also correspondingly changed. This change of the language
  3.1827 +        semantics was undertaken due to a notice provided by Peter Lee
  3.1828 +        <plee@kinggee.com.au>.
  3.1829 +
  3.1830 +        * sample/hwd.lpm
  3.1831 +        A nice example of LP model written in GLPK/L and contributed by
  3.1832 +        Peter Lee <plee@kinggee.com.au> was included in the package.
  3.1833 +
  3.1834 +        * glplpx6b.c
  3.1835 +        The api routine lpx_interior was modified: a) to compute dual
  3.1836 +        values for all structural as well as auxiliary variables; b) to
  3.1837 +        allow specifying non-zero objective coefficients at auxiliary
  3.1838 +        variables.
  3.1839 +
  3.1840 +        * sample/glpsol.c
  3.1841 +        Three new command-line options were added to the solver, which
  3.1842 +        are: --plain, --orig, and --wrlpt.
  3.1843 +
  3.1844 +Mon Oct 14 12:00:00 2002 Andrew Makhorin <mao@mai2.rcnet.ru>
  3.1845 +
  3.1846 +        * GLPK 3.2.2 has been released.
  3.1847 +
  3.1848 +        * glplpt.h, glplpt.c
  3.1849 +        A module that reads LP/MIP problem data in CPLEX LP format was
  3.1850 +        implemented.
  3.1851 +
  3.1852 +        * glplpx8c.c
  3.1853 +        An api routine lpx_read_lpt that reads LP/MIP problem data in
  3.1854 +        CPLEX LP format was implemented.
  3.1855 +
  3.1856 +        * sample/glpsol.c, sample/plan.lpt
  3.1857 +        A new command-line option '--lpt' that allows reading LP/MIP
  3.1858 +        problem data in CPLEX LP format was added to the solver.
  3.1859 +
  3.1860 +        * doc/refman.latex, doc/refman.dvi, doc/refman.ps
  3.1861 +        A new edition of the Reference Manual was included.
  3.1862 +
  3.1863 +        * source/*.c
  3.1864 +        Casting to (unsigned char) was added in some calls to the
  3.1865 +        classification functions (isalpha, etc.). The bug was fixed due
  3.1866 +        to report provided by Morten Welinder <terra@diku.dk>.
  3.1867 +
  3.1868 +        * glplpx8a.c
  3.1869 +        The local routine mps_numb used in the routine lpx_write_mps
  3.1870 +        was modified to correctly format floating-point numbers that
  3.1871 +        have two digits in the decimal exponent. The bug was fixed due
  3.1872 +        to report provided by Vlahos Kiriakos <Kiriakos.Vlahos@gs.com>.
  3.1873 +
  3.1874 +        * glplan.h, glplan1.c, ..., glplan8.c
  3.1875 +        Several serious bugs were fixed in the language processor due
  3.1876 +        to reports provided by <NORBERT.PIOTROWSKI@LHSYSTEMS.COM>:
  3.1877 +        (a) a static search tree used to find sparse array elements was
  3.1878 +        sometimes overwritten that caused the message 'assertion failed'
  3.1879 +        to appear; the bug was fixed by creating separate search trees
  3.1880 +        in parsing routines; (b) a variable declared using the
  3.1881 +        predicate-controlled variable declaration statement had wrong
  3.1882 +        order of domain sets, because the variable array was built as
  3.1883 +        a copy of the predicate array; the bug was fixed by using the
  3.1884 +        internal routine transpose that coordinates mute letters (and
  3.1885 +        therefore domain sets) on copying sparse arrays; (c) sometimes
  3.1886 +        assignment statements like x[#a,#b,#c] := ... was incorrectly
  3.1887 +        processed; the bug was fixed by including an appropriate check
  3.1888 +        into the internal routine assign_stmt.
  3.1889 +
  3.1890 +        * glp_simplex.c
  3.1891 +        An additional check to see if all lower bounds are not greater
  3.1892 +        than corresponding upper bounds was included in the routine to
  3.1893 +        prevent wrong results to appear. Such incorrectness sometimes
  3.1894 +        was not detected, namely, when variables with such bounds were
  3.1895 +        non-basic and never entered the basis.
  3.1896 +
  3.1897 +        * glpspx1.c
  3.1898 +        Maximal number of simplex iterations before reinversion was
  3.1899 +        decreased from 100 to 50. This allowed to improve accuracy and,
  3.1900 +        that is more important, to reduce the solution time for many
  3.1901 +        serial lp problems approximately 1.5--2 times.
  3.1902 +
  3.1903 +        * glpspx2.c
  3.1904 +        A check to see if all elements in the column chosen to enter
  3.1905 +        the basis are close to zero in the routine spx_prim_chuzr was
  3.1906 +        temporarily removed because this check gave wrong conclusion in
  3.1907 +        case when the corresponding non-basic variable had zero column
  3.1908 +        in the constraint matrix. An analogous check to see if all
  3.1909 +        elements in the row chosen to leave the basis are close to zero
  3.1910 +        in the routine spx_dual_chuzc was also temporarily removed on
  3.1911 +        the same reason. The bug was fixed due to reports provided by
  3.1912 +        Flavio Keidi Miyazawa <fkm@ic.unicamp.br> and Vlahos Kiriakos
  3.1913 +        <Kiriakos.Vlahos@gs.com>.
  3.1914 +
  3.1915 +Mon Aug 12 12:00:00 2002 Andrew Makhorin <mao@mai2.rcnet.ru>
  3.1916 +
  3.1917 +        * GLPK 3.2.1 has been released.
  3.1918 +
  3.1919 +        * glpbcs.h, glpbcs1.c, glpbcs2.c
  3.1920 +        * glpies.h, glpies1.c, glpies2.c, glpies3.c
  3.1921 +        A preliminary implementation of the branch-and-cut framework
  3.1922 +        was included in the package.
  3.1923 +
  3.1924 +        * doc/brcut.txt
  3.1925 +        The document "GLPK: A Preliminary Implementation of the
  3.1926 +        Branch-And-Cut Framework" was included in the distribution.
  3.1927 +
  3.1928 +        * sample/tspsol.c
  3.1929 +        An illustrative program for solving symmetric TSP based on the
  3.1930 +        branch-and-cut method was included in the package.
  3.1931 +
  3.1932 +        * glpdmp.h, glpdmp.c
  3.1933 +        A new, re-enterable version of routines for managing dynamic
  3.1934 +        memory pools was included in the package.
  3.1935 +
  3.1936 +        * glpavl.h, glpavl.c
  3.1937 +        A new, re-enterable version of routines for managing AVL search
  3.1938 +        trees was included in the package.
  3.1939 +
  3.1940 +        * glplib.h, glplib2.c
  3.1941 +        Two new low-level routines ufopen and ufclose were included in
  3.1942 +        the package.
  3.1943 +
  3.1944 +        * glplpx.h, glplpx7.c
  3.1945 +        The following new api routines were added: lpx_eval_activity,
  3.1946 +        lpx_eval_red_cost, lpx_reduce_form, lpx_mixed_gomory.
  3.1947 +
  3.1948 +        * glptsp.h, glptsp.c
  3.1949 +        A module for reading TSP data using TSPLIB format was included
  3.1950 +        in the package.
  3.1951 +
  3.1952 +Mon Jul 15 12:00:00 2002 Andrew Makhorin <mao@mai2.rcnet.ru>
  3.1953 +
  3.1954 +        * GLPK 3.2 has been released.
  3.1955 +
  3.1956 +        * glplpx.h, glplpx1.c, glplpx2.c
  3.1957 +        The identifier 'class' (used as a member name in the structure
  3.1958 +        LPX and as an argument name in the routine lpx_set_class) was
  3.1959 +        changed to 'clss' in order to avoid conflicts with C++ reserved
  3.1960 +        words.
  3.1961 +
  3.1962 +        * glpk.h, glplpx.h, glplpx1.c, glplpx2.c, glplpx6a.c,
  3.1963 +        * glplpx6b.c, glplpx6c.c, glplpx7.c, glplpx8.c
  3.1964 +        The following new api routines were added: lpx_set_obj_name,
  3.1965 +        lpx_get_obj_name, lpx_get_row_mark, lpx_get_col_mark,
  3.1966 +        lpx_transform_row, lpx_transform_col, lpx_prim_ratio_test,
  3.1967 +        lpx_dual_ratio_test, lpx_interior, lpx_get_ips_stat,
  3.1968 +        lpx_get_ips_row, lpx_get_ips_col, lpx_get_ips_obj, lpx_read_lpm,
  3.1969 +        lpx_write_mps, lpx_print_ips.
  3.1970 +
  3.1971 +        * glpsol.c
  3.1972 +        The solver was completely re-programmed using new api routines.
  3.1973 +
  3.1974 +        * lang.latex, lang.dvi, lang.ps
  3.1975 +        New edition of the document "GLPK: Modeling Language GLPK/L"
  3.1976 +        was included in the distribution.
  3.1977 +
  3.1978 +        * refman.latex, refman.dvi, refman.ps
  3.1979 +        New edition of the document "GLPK: Reference Manual" (which
  3.1980 +        contains descriptions of all new api routines) was included in
  3.1981 +        the distribution.
  3.1982 +
  3.1983 +        * glpapi.h, glpapi1.c, glpapi2.c, glpapi3.c, glpapi4.c
  3.1984 +        These files (which contain old api routines) were removed from
  3.1985 +        the package.
  3.1986 +
  3.1987 +        * glpipm1.c, glpipm2.c
  3.1988 +        The file glpipm1.c was renamed to glpipm.c. The file glpipm2.c
  3.1989 +        was used only by old api routines and therefore was removed from
  3.1990 +        the package.
  3.1991 +
  3.1992 +        * language.texinfo
  3.1993 +        Old version of the document "GLPK: Modeling Language GLPK/L" was
  3.1994 +        removed from the distribution.
  3.1995 +
  3.1996 +Mon May 27 12:00:00 2002 Andrew Makhorin <mao@mai2.rcnet.ru>
  3.1997 +
  3.1998 +        * GLPK 3.1 has been released.
  3.1999 +
  3.2000 +        * glplpx.h, glplpx1.c, glplpx2.c, glplpx3.c, glplpx4.c,
  3.2001 +        * glplpx5.c, glplpx6.c, glplpx7.c, glplpx8.c
  3.2002 +        A preliminary implementation of new API routines was completed.
  3.2003 +
  3.2004 +        * refman.latex, refman.dvi, refman.ps
  3.2005 +        A draft edition of the document "GLPK Reference Manual", which
  3.2006 +        describes new API routines, was included.
  3.2007 +
  3.2008 +        * glplib3.c
  3.2009 +        A bug in measuring long time intervals was fixed up.
  3.2010 +
  3.2011 +        * glprsm3.c
  3.2012 +        This module contains some obsolete routines not longer used and
  3.2013 +        therefore it was removed from the package (into the subdirectory
  3.2014 +        'oldsrc').
  3.2015 +
  3.2016 +        * glprsm.h
  3.2017 +        Some declarations related to the module 'glprsm3.c' (see above)
  3.2018 +        were removed.
  3.2019 +
  3.2020 +        * guide.texinfo
  3.2021 +        The document "GLPK User's Guide" describing old API routines was
  3.2022 +        removed from the package (into the subdirectory 'oldsrc').
  3.2023 +
  3.2024 +        * newapi.txt
  3.2025 +        The document "New GLPK API Routines" was removed at all, because
  3.2026 +        it is superseded by the new reference manual (see above).
  3.2027 +
  3.2028 +Mon May 13 12:00:00 2002 Andrew Makhorin <mao@mai2.rcnet.ru>
  3.2029 +
  3.2030 +        * GLPK 3.0.8 has been released.
  3.2031 +
  3.2032 +        * glplpx.h, glplpx1.c, glplpx2.c, glplpx3.c, glplpx4.c,
  3.2033 +        * glplpx5.c, glplpx6.c, glplpx7.c
  3.2034 +        A preliminary (currently incomplete) implementation of new api
  3.2035 +        routines was included.
  3.2036 +
  3.2037 +        * sample/newsamp.c
  3.2038 +        A sample program for the new api routines was included.
  3.2039 +
  3.2040 +        * newapi.txt
  3.2041 +        A draft of the document "New GLPK API Routines" was included.
  3.2042 +
  3.2043 +        * glpapi2.c, glpapi5.c, glpapi6.c
  3.2044 +        These modules (which contain the api routines glp_call_rsm1,
  3.2045 +        glp_simplex1, glp_pivot_in, glp_pivot_out) were removed from the
  3.2046 +        package (to the subdirectory 'oldsrc') since these routines are
  3.2047 +        functionally superseded by the new api routines.
  3.2048 +
  3.2049 +        * glpk.h, glpapi2.c, glpapi3.c, glpapi4.c
  3.2050 +        The api routines glp_simplex2, glp_call_ipm1, glp_call_bbm1 were
  3.2051 +        renamed to glp_simplex, glp_interior, glp_integer, respectively.
  3.2052 +
  3.2053 +        * sample/glpsol.c
  3.2054 +        Some command-line options (which got obsolete due to the recent
  3.2055 +        changes in api) were excluded.
  3.2056 +
  3.2057 +        * doc/guide.texinfo
  3.2058 +        New edition of the document "GLPK User's Guide" was included in
  3.2059 +        the distribution to reflect the changes in some api routines.
  3.2060 +
  3.2061 +        * doc/libref.texinfo
  3.2062 +        This document was removed from the package (to the subdirectory
  3.2063 +        'oldsrc') since it describes the library routines, most of which
  3.2064 +        got obsolete and no longer used.
  3.2065 +
  3.2066 +        * Makefile.in
  3.2067 +        A minor bug was fixed up due to bug report from Hans Schwengeler
  3.2068 +        <Hans.Schwengeler@unibas.ch>.
  3.2069 +
  3.2070 +Mon Apr 22 12:00:00 2002 Andrew Makhorin <mao@mai2.rcnet.ru>
  3.2071 +
  3.2072 +        * GLPK 3.0.7 has been released.
  3.2073 +
  3.2074 +        * glpduff.h, glpduff.c, glpspx.h, glpspx1.c, glpspx2.c,
  3.2075 +        * glpapi7.c
  3.2076 +        These modules were replaced by a new implementation of the
  3.2077 +        simplex method and therefore they were removed from the package
  3.2078 +        (however they still can be found in the subdirectory 'oldsrc').
  3.2079 +
  3.2080 +        * glprsm1.c
  3.2081 +        The routine crash_aa was replaced by a new implementation and
  3.2082 +        therefore it was removed from the file 'glprsm1.c'.
  3.2083 +
  3.2084 +        * glplpx.h, glplpx.c, glpspx.h, glpspx1.c, glpspx2.c, glpspx3.c,
  3.2085 +        * glpspx4.c, glpapi7.c
  3.2086 +        New (currently incomplete) implementation of the simplex method
  3.2087 +        components was included in the package.
  3.2088 +
  3.2089 +Thu Mar 28 12:00:00 2002 Andrew Makhorin <mao@mai2.rcnet.ru>
  3.2090 +
  3.2091 +        * GLPK 3.0.6 has been released.
  3.2092 +
  3.2093 +        * glpluf.h, glpluf.c, glpinv.h, glpinv.c
  3.2094 +        New version of LU-factorization and basis maintenance routines
  3.2095 +        (based on Forrest-Tomlin updating technique) was implemented.
  3.2096 +
  3.2097 +        * glpeta.h, glpeta.c, glpfhv.h, glpfhv.c, glpgel.h, glpgel.c,
  3.2098 +        * glppfi.h, glppfi.c, glprfi.h, glprfi.c
  3.2099 +        These routines implement some other forms of the basis matrix.
  3.2100 +        Now they became obsolete being functionally superseded by the
  3.2101 +        new version of basis maintenance routines (see above) and were
  3.2102 +        removed from the package (however they still can be found in the
  3.2103 +        subdirectory 'oldsrc').
  3.2104 +
  3.2105 +        * glpbbm.c, glprsm.h, glprsm1.h, glprsm2.h, glpspx.h, glpspx2.c,
  3.2106 +        * glprsm2.c, glpsol.c
  3.2107 +        Necessary changes were made in order to use the new version of
  3.2108 +        basis maintenance routines.
  3.2109 +
  3.2110 +Tue Jan 29 12:00:00 2002 Andrew Makhorin <mao@mai2.rcnet.ru>
  3.2111 +
  3.2112 +        * GLPK 3.0.5 has been released.
  3.2113 +        Structure of the package was re-organized in order to simplify
  3.2114 +        its maintenance.
  3.2115 +
  3.2116 +        * doc/guide.texinfo
  3.2117 +        New edition of the document "GLPK User's Guide" was included in
  3.2118 +        the distribution. Now the document includes descriptions of some
  3.2119 +        additional API routines recently added to the package.
  3.2120 +
  3.2121 +        * doc/newapi.txt
  3.2122 +        The document "Additional GLPK API Routines" was removed from the
  3.2123 +        distribution, because the corresponding material was included in
  3.2124 +        the user's guide (see above).
  3.2125 +
  3.2126 +Mon Dec 10 12:00:00 2001 Andrew Makhorin <mao@mai2.rcnet.ru>
  3.2127 +
  3.2128 +        * GLPK 3.0.4 has been released.
  3.2129 +
  3.2130 +        * glpspx.h, glpspx1.c, glpspx2.c, glpapi/glp_simplex2.h
  3.2131 +        A new, more efficient version of the two-phase primal simplex
  3.2132 +        method was implemented (advanced initial basis, projected
  3.2133 +        steepest edge, recursive computations of solution components).
  3.2134 +
  3.2135 +        * glpapi/glp_call_bbm1.c
  3.2136 +        Now LP relaxation can be solved either using rsm1_driver(), or
  3.2137 +        using glp_simplex2(). The choice is controlled by the parameter
  3.2138 +        'meth' (a member of struct bbm1).
  3.2139 +
  3.2140 +        * sample/glpsol.c
  3.2141 +        The new implementation of the simplex method is now used by
  3.2142 +        default. The old version is available via --old-sim option.
  3.2143 +
  3.2144 +        * glpmat/gm_scaling.c
  3.2145 +        Now this routine displays only two lines: an initial "quality"
  3.2146 +        and a final "quality".
  3.2147 +
  3.2148 +        * glplp/prepro_lp.c
  3.2149 +        Identifiers 'fmin' and 'fmax' renamed to 'f_min' and 'f_max' in
  3.2150 +        order to avoid conflict with <math.h>. The bug was fixed due to
  3.2151 +        report provided by Sami Farin <sfarin@ratol.fi>.
  3.2152 +
  3.2153 +Wed Oct 03 12:00:00 2001 Andrew Makhorin <mao@mai2.rcnet.ru>
  3.2154 +
  3.2155 +        * GLPK 3.0.3 has been released.
  3.2156 +
  3.2157 +        * glprsm/harris_row.c, glprsm/harris_col.c
  3.2158 +        The relative tolerance used on the first pass of the two-pass
  3.2159 +        ratio test was replaced by the absolute tolerance.
  3.2160 +
  3.2161 +        * glprsm/rsm_primal.c, glprsm/rsm_feas.c, glprsm/rsm_dual.c
  3.2162 +        The absolute tolerance passed to the two-pass ratio test routine
  3.2163 +        was decaresed (for both primal and dual simplex).
  3.2164 +
  3.2165 +        These changes were made in order to improve numerical stability
  3.2166 +        of the simplex method.
  3.2167 +
  3.2168 +        * glprsm/glp_call_rsm1.c, glprsm/glp_call_bbm1.c,
  3.2169 +        * glprsm/glp_simplex1, glprsm/glp_pivoting.c
  3.2170 +        Default form of the inverse was changed from RFI to AFI.
  3.2171 +
  3.2172 +Mon Sep 24 12:00:00 2001 Andrew Makhorin <mao@mai2.rcnet.ru>
  3.2173 +
  3.2174 +        * GLPK 3.0.2 has been released.
  3.2175 +
  3.2176 +        * glpfhv.h, glpfhv.c
  3.2177 +        New version of the basis maintaining routines was implemented.
  3.2178 +        These routines, which are based on so called FHV-factorization
  3.2179 +        (a variety of LU-factorization) and Gustavson's data structures,
  3.2180 +        perform the main operations on the basis matrix faster at the
  3.2181 +        expense of some worsening numerical accuracy.
  3.2182 +
  3.2183 +        * glprsm.h, glprsm/afi.c
  3.2184 +        The routines, which implement AFI (Advanced Form of the
  3.2185 +        Inverse) based on FHV-factorization, were added to the package.
  3.2186 +        This new form is available via the parameter form = 3 (on API
  3.2187 +        level) or via the option --afi (in GLPSOL solver).
  3.2188 +
  3.2189 +        * EFI was renamed to PFI
  3.2190 +        In order to correct terminology the acronym EFI (Elimination
  3.2191 +        Form of the Inverse) was replaced by PFI (Product Form of the
  3.2192 +        Inverse) everywhere in the source code and the documentation.
  3.2193 +
  3.2194 +        * glpset/umalloc.c, glpset/ucalloc.c
  3.2195 +        * glpset/get_atom.c, glpset/get_atomv.c
  3.2196 +        These memory management routines were changed in order *not* to
  3.2197 +        clear allocated memory blocks by binary zeros.
  3.2198 +
  3.2199 +Wed Aug 01 12:00:00 2001 Andrew Makhorin <mao@mai2.rcnet.ru>
  3.2200 +
  3.2201 +        * GLPK 3.0.1 has been released.
  3.2202 +
  3.2203 +        * glpapi/old_api.c, glplp/extract_lp.c, store_lpsol.c
  3.2204 +        Old API routines were deleted from the package.
  3.2205 +
  3.2206 +        * include/glpk.h, include/glpapi.h, include/glplp.h
  3.2207 +        Specifications of old API routines and data structures were
  3.2208 +        removed from the headers.
  3.2209 +
  3.2210 +        * sample/glpsol.c
  3.2211 +        New version of the stand-alone solver GLPSOL that now uses new
  3.2212 +        API routines was implemented.
  3.2213 +
  3.2214 +        * glpapi/glp_set_row_fctr.c, glpapi/glp_set_col_fctr.c,
  3.2215 +        * glpapi/glp_get_row_fctr.c, glpapi/glp_get_col_fctr.c,
  3.2216 +        * glpapi/glp_scale_prob.c
  3.2217 +        Scaling routines were added.
  3.2218 +
  3.2219 +        * glpapi/glp_write_mps.c
  3.2220 +        The routine for writing problem data in MPS format was added.
  3.2221 +
  3.2222 +        * glpapi/glp_simplex1.c
  3.2223 +        Comprehensive driver to the simplex method was added.
  3.2224 +
  3.2225 +        * glpapi/glp_pivoting.c
  3.2226 +        The routines glp_pivot_in() and glp_pivot_out() intended for
  3.2227 +        basis maintaining were added.
  3.2228 +
  3.2229 +        * glprsm/create_rsm.c, glprsm/delete_rsm.c, glprsm/scale_rsm.c,
  3.2230 +        * glprsm/build_basis.c
  3.2231 +        Additional low level routines related to the simplex method
  3.2232 +        were added.
  3.2233 +
  3.2234 +        * glpk.h, glpapi.h, glprsm.h
  3.2235 +        Additional specifications for new routines and data structures
  3.2236 +        were added.
  3.2237 +
  3.2238 +        * sample/lpglpk30.c
  3.2239 +        A non-trivial example was added. It allows using GLPK as a base
  3.2240 +        LP solver for Concorde, a program for solving Traveling Salesman
  3.2241 +        Problem (TSP). For details see comments in 'lpglpk30.c'.
  3.2242 +
  3.2243 +        * doc/newapi.txt
  3.2244 +        The document "Additional GLPK API Routines" that describes some
  3.2245 +        new API routines was included.
  3.2246 +
  3.2247 +Thu Jul 19 12:00:00 2001 Andrew Makhorin <mao@mai2.rcnet.ru>
  3.2248 +
  3.2249 +        * GLPK 3.0 has been released.
  3.2250 +
  3.2251 +        Now GLPK is provided with new API, which is intended for using
  3.2252 +        the package in more complex algorithmic schemes.
  3.2253 +
  3.2254 +        * glpapi/old_api.c
  3.2255 +        All routines related to old API were gathered in one file named
  3.2256 +        'old_api.c'.
  3.2257 +
  3.2258 +        * glpapi/*.c
  3.2259 +        These routines that implement new API were added to the package.
  3.2260 +
  3.2261 +        * include/glpk.h, include/glpapi.h
  3.2262 +        Specifications of new API routines and data structures were
  3.2263 +        added to these headers. Specifications of old API routines and
  3.2264 +        data structures were locked by #ifdef GLP_OLD_API directive.
  3.2265 +
  3.2266 +        * doc/guide.texinfo
  3.2267 +        New edition of the document "GLPK User's Guide" that correspond
  3.2268 +        to new API was included.
  3.2269 +
  3.2270 +Thu Jun 14 12:00:00 2001 Andrew Makhorin <mao@mai2.rcnet.ru>
  3.2271 +
  3.2272 +        * GLPK 2.4.1 has been released.
  3.2273 +
  3.2274 +        * doc/glpk_ml.texinfo
  3.2275 +        The new document "Modeling Language GLPK/L" was included.
  3.2276 +
  3.2277 +        * doc/glpk_ug.texinfo
  3.2278 +        New edition of the document "GLPK User's Guide" was included.
  3.2279 +
  3.2280 +        * doc/language.txt
  3.2281 +        The preliminary document "GLPK/L Modeling Language: A Brief
  3.2282 +        description" was removed from the distribution, because it has
  3.2283 +        been replaced by the new document "Modeling Language GLPK/L".
  3.2284 +
  3.2285 +        * glplang/l_spar.c
  3.2286 +        The routine comparison() was re-programmed in order to
  3.2287 +        implement the relation operation as specified in the language
  3.2288 +        description.
  3.2289 +
  3.2290 +        * glpmip.h, glpmip/*.c
  3.2291 +        The partition 'glpmip' was renamed to 'glpbbm'.
  3.2292 +
  3.2293 +Thu May 10 12:00:00 2001 Andrew Makhorin <mao@mai2.rcnet.ru>
  3.2294 +
  3.2295 +        * GLPK 2.4 has been released.
  3.2296 +
  3.2297 +        Now GLPK includes an implementation of a preliminary version of
  3.2298 +        the GLPK/L modeling language.
  3.2299 +
  3.2300 +        * glplang.h, glplang/*.c
  3.2301 +        The header 'glplang.h' and a set of routines that implements
  3.2302 +        the GLPK/L language processor (the partition 'glplang') were
  3.2303 +        added to the package.
  3.2304 +
  3.2305 +        * doc/language.txt
  3.2306 +        The document "GLPK/L Modeling Language: A Brief Description
  3.2307 +        (Supplement to GLPK User's Guide)" in plain text format was
  3.2308 +        included in the package (see the file 'language.txt' in the
  3.2309 +        subdirectory 'doc' of the distribution).
  3.2310 +
  3.2311 +        * ex/model1.lpm, ex/model2.lpm
  3.2312 +        Two examples of model descriptions written in GLPK/L were added
  3.2313 +        to the package.
  3.2314 +
  3.2315 +        * sample/glpsol.c
  3.2316 +        This program was modified in order: a) to allow processing
  3.2317 +        model description written in GLPK/L; b) to allow solving pure
  3.2318 +        LP problem using the interior point method.
  3.2319 +
  3.2320 +        * sample/glpipm.c
  3.2321 +        This program was removed from the package, because its function
  3.2322 +        was passed to the GLPSOL solver.
  3.2323 +
  3.2324 +        * Makefile.in
  3.2325 +        This file was changed in order to install the GLPSOL solver
  3.2326 +        executable.
  3.2327 +
  3.2328 +Mon Apr 09 12:00:00 2001 Andrew Makhorin <mao@mai2.rcnet.ru>
  3.2329 +
  3.2330 +        * GLPK 2.3 has been released.
  3.2331 +
  3.2332 +        * glpmip.h, glpmip/*.c
  3.2333 +        These routines (that implement the branch-and-bound method) were
  3.2334 +        re-programmed in order to improve robustness of implementation.
  3.2335 +        In particular, heuristic routines were carried out from the main
  3.2336 +        driver routine.
  3.2337 +
  3.2338 +        Additional GLPK API routines were documented.
  3.2339 +
  3.2340 +        New edition of the document "GLPK User's Guide" was included in
  3.2341 +        the package.
  3.2342 +
  3.2343 +        The preliminary document "Mixed Integer Programming Using GLPK
  3.2344 +        Version 2.2 (Supplement to GLPK User's Guide)" was removed from
  3.2345 +        the package, because this material was included in GLPK User's
  3.2346 +        Guide.
  3.2347 +
  3.2348 +Thu Mar 15 12:00:00 2001 Andrew Makhorin <mao@mai2.rcnet.ru>
  3.2349 +
  3.2350 +        * GLPK 2.2 has been released.
  3.2351 +
  3.2352 +        Now GLPK includes a tentative implementation of the
  3.2353 +        branch-and-bound procedure based on the dual simplex method for
  3.2354 +        mixed integer linear programming (MIP).
  3.2355 +
  3.2356 +        The preliminary document "Mixed Integer Programming Using GLPK
  3.2357 +        Version 2.2 (Supplement to GLPK User's Guide)" was included into
  3.2358 +        the package in plain text format (see the file 'mip.txt' in the
  3.2359 +        subdirectory 'doc' of the distribution).
  3.2360 +
  3.2361 +        * glpmip.h, glpmip/*.c, glpapi/glp_integer.c
  3.2362 +        These routines (that implement the branch-and-bound method) were
  3.2363 +        added to the package.
  3.2364 +
  3.2365 +        * sample/glpsol.c
  3.2366 +        This program was modified in order to allow solving LP and MIP
  3.2367 +        problems.
  3.2368 +
  3.2369 +        * glprsm/rsm_primal.c, glprsm/rsm_dual.c, glprsm/rsm_feas.c,
  3.2370 +        * glprsm/rsm1_driver.c
  3.2371 +        These routines (which are drivers to basic components of the
  3.2372 +        revised simplex method) were added to the package.
  3.2373 +
  3.2374 +Mon Feb 19 12:00:00 2001 Andrew Makhorin <mao@mai2.rcnet.ru>
  3.2375 +
  3.2376 +        * GLPK 2.1 has been released.
  3.2377 +
  3.2378 +        * glprsm.h, glprsm/*.c
  3.2379 +        These routines (that implement components of the revised simplex
  3.2380 +        method) were re-programmed and documented.
  3.2381 +
  3.2382 +        The document "GLPK Implementation of the Revised Simplex Method"
  3.2383 +        was included into the package.
  3.2384 +
  3.2385 +Thu Jan 25 12:00:00 2001 Andrew Makhorin <mao@mai2.rcnet.ru>
  3.2386 +
  3.2387 +        * GLPK 2.0 has been released.
  3.2388 +
  3.2389 +        Now GLPK includes a tentative implementation of the primal-dual
  3.2390 +        interior point method for large-scale linear programming (for
  3.2391 +        more details see the file `NEWS' in the distribution). A number
  3.2392 +        of routines related to the interior point method were added to
  3.2393 +        the package.
  3.2394 +
  3.2395 +        * insist.c
  3.2396 +        The routine `insist' and the macro of the same name were
  3.2397 +        introduced into the package in order to replace the standard
  3.2398 +        macro `assert'. Some routines require the expression specified
  3.2399 +        in the `assert' macro to be evaluated, but compiling the package
  3.2400 +        with NDEBUG option prevents from that. This bug was fixed due to
  3.2401 +        bug report provided by Peter A. Huegler <phuegler@bsco.com>.
  3.2402 +
  3.2403 +        * Makefile.in
  3.2404 +        Minor bug was fixed due to a patch provided by Alexandre Oliva
  3.2405 +        <oliva@lsd.ic.unicamp.br>.
  3.2406 +
  3.2407 +Wed Jan 10 12:00:00 2001 Andrew Makhorin <mao@mai2.rcnet.ru>
  3.2408 +
  3.2409 +        * GLPK 1.1.2 has been released.
  3.2410 +
  3.2411 +        * umalloc.c, ufree.c, create_pool.c, get_atom.c, get_atomv.c
  3.2412 +        These routines were changed in order to fix a bug due to
  3.2413 +        report provided by Andrew Hood <ajhood@fl.net.au>. Because of
  3.2414 +        this bug data alignment error occured on the Sparc computer.
  3.2415 +
  3.2416 +Tue Dec 14 12:00:00 2000 Andrew Makhorin <mao@mai2.rcnet.ru>
  3.2417 +
  3.2418 +        * GLPK 1.1.1 has been released.
  3.2419 +
  3.2420 +        Minor bug was fixed in `Makefile.in'.
  3.2421 +
  3.2422 +        GLPK Library Reference was included.
  3.2423 +
  3.2424 +Mon Nov 27 12:00:00 2000 Andrew Makhorin <mao@mai2.rcnet.ru>
  3.2425 +
  3.2426 +        * GLPK 1.1 has been released.
  3.2427 +
  3.2428 +        Minor changes were made in order to co-ordinate GLPK routines
  3.2429 +        and their descriptions.
  3.2430 +
  3.2431 +        GLPK User's Guide was included.
  3.2432 +
  3.2433 +Fri Oct 20 12:00:00 2000 Andrew Makhorin <mao@mai2.rcnet.ru>
  3.2434 +
  3.2435 +        * GLPK 1.0 has been released.
     4.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     4.2 +++ b/deps/glpk/INSTALL	Sun Nov 06 20:59:10 2011 +0100
     4.3 @@ -0,0 +1,209 @@
     4.4 +INSTALLING GLPK ON YOUR COMPUTER
     4.5 +********************************
     4.6 +
     4.7 +Unpacking the distribution file
     4.8 +-------------------------------
     4.9 +The GLPK package (like all other GNU software) is distributed in the
    4.10 +form of a packed archive. It is one file named `glpk-X.Y.tar.gz', where
    4.11 +`X' is the major version number and `Y' is the minor version number;
    4.12 +for example, the archive name might be `glpk-4.15.tar.gz'.
    4.13 +
    4.14 +In order to prepare the distribution for installation you should:
    4.15 +
    4.16 +1. Copy the GLPK distribution file to a working directory.
    4.17 +
    4.18 +2. Unpack the distribution file with the following command:
    4.19 +
    4.20 +      gzip -d glpk-X.Y.tar.gz
    4.21 +
    4.22 +   After unpacking the distribution file is automatically renamed to
    4.23 +   `glpk-X.Y.tar'.
    4.24 +
    4.25 +3. Unarchive the distribution file with the following command:
    4.26 +
    4.27 +      tar -x < glpk-X.Y.tar
    4.28 +
    4.29 +   It automatically creates the subdirectory `glpk-X.Y' containing the
    4.30 +   GLPK distribution.
    4.31 +
    4.32 +Configuring the package
    4.33 +-----------------------
    4.34 +After unpacking and unarchiving the GLPK distribution you should
    4.35 +configure the package, i.e. automatically tune it for your platform.
    4.36 +
    4.37 +Normally, you should just `cd' to the directory `glpk-X.Y' and run the
    4.38 +`configure' script, e.g.
    4.39 +
    4.40 +      ./configure
    4.41 +
    4.42 +The `configure' shell script attempts to guess correct values for
    4.43 +various system-dependent variables used during compilation. It uses
    4.44 +those values to create a `Makefile' in each directory of the package.
    4.45 +It also creates file `config.h' containing platform-dependent
    4.46 +definitions. Finally, it creates a shell script `config.status' that
    4.47 +you can run in the future to recreate the current configuration, a file
    4.48 +`config.cache' that saves the results of its tests to speed up
    4.49 +reconfiguring, and a file `config.log' containing compiler output
    4.50 +(useful mainly for debugging `configure').
    4.51 +
    4.52 +Running `configure' takes about a few seconds. While it is running, it
    4.53 +displays some messages that tell you what it is doing. If you don't want
    4.54 +to see the messages, run `configure' with its standard output redirected
    4.55 +to `dev/null'; for example, `./configure > /dev/null'.
    4.56 +
    4.57 +By default both static and shared versions of the GLPK library will be
    4.58 +compiled. Compilation of the shared librariy can be turned off by
    4.59 +specifying the `--disable-shared' option to `configure', e.g.
    4.60 +
    4.61 +      ./configure --disable-shared
    4.62 +
    4.63 +If you encounter problems building the library try using the above
    4.64 +option, because some platforms do not support shared libraries.
    4.65 +
    4.66 +The GLPK package has some optional features listed below. By default
    4.67 +all these features are disabled. To enable a feature the corresponding
    4.68 +option should be passed to the configure script.
    4.69 +
    4.70 +--with-gmp           Enable using the GNU MP bignum library
    4.71 +
    4.72 +   This feature allows the exact simplex solver to use the GNU MP
    4.73 +   bignum library. If it is disabled, the exact simplex solver uses the
    4.74 +   GLPK bignum module, which provides the same functionality as GNU MP,
    4.75 +   however, it is much less efficient.
    4.76 +
    4.77 +   For details about the GNU MP bignum library see its web page at
    4.78 +   <http://gmplib.org/>.
    4.79 +
    4.80 +--with-zlib          Enable using the zlib data compression library
    4.81 +
    4.82 +   This feature allows GLPK API routines and the stand-alone solver to
    4.83 +   read and write compressed data files performing compression and
    4.84 +   decompression "on the fly" (compressed data files are recognized by
    4.85 +   suffix `.gz' in the file name). It may be useful in case of large
    4.86 +   MPS files to save the disk space.
    4.87 +
    4.88 +   For details about the zlib compression library see its web page at
    4.89 +   <http://www.zlib.net/>.
    4.90 +
    4.91 +--enable-dl          The same as --enable-dl=ltdl
    4.92 +--enable-dl=ltdl     Enable shared library support (GNU)
    4.93 +--enable-dl=dlfcn    Enable shared library support (POSIX)
    4.94 +
    4.95 +   Currently this feature is only needed to provide dynamic linking to
    4.96 +   ODBC and MySQL shared libraries (see below).
    4.97 +
    4.98 +   For details about the GNU shared library support see the manual at
    4.99 +   <http://www.gnu.org/software/libtool/manual/>.
   4.100 +
   4.101 +--enable-odbc        Enable using ODBC table driver (libiodbc)
   4.102 +--enable-odbc=unix   Enable using ODBC table driver (libodbc)
   4.103 +
   4.104 +   This feature allows transmitting data between MathProg model objects
   4.105 +   and relational databases accessed through ODBC.
   4.106 +
   4.107 +   For more details about this feature see the supplement "Using Data
   4.108 +   Tables in the GNU MathProg Modeling Language" (doc/tables.*).
   4.109 +
   4.110 +--enable-mysql       Enable using MySQL table driver (libmysql)
   4.111 +
   4.112 +   This feature allows transmitting data between MathProg model objects
   4.113 +   and MySQL relational databases.
   4.114 +
   4.115 +   For more details about this feature see the supplement "Using Data
   4.116 +   Tables in the GNU MathProg Modeling Language" (doc/tables.*).
   4.117 +
   4.118 +Compiling the package
   4.119 +---------------------
   4.120 +Normally, you can compile (build) the package by typing the command:
   4.121 +
   4.122 +      make
   4.123 +
   4.124 +It reads `Makefile' generated by `configure' and performs all necessary
   4.125 +jobs.
   4.126 +
   4.127 +If you want, you can override the `make' variables CFLAGS and LDFLAGS
   4.128 +like this:
   4.129 +
   4.130 +      make CFLAGS=-O2 LDFLAGS=-s
   4.131 +
   4.132 +To compile the package in a different directory from the one containing
   4.133 +the source code, you must use a version of `make' that supports `VPATH'
   4.134 +variable, such as GNU `make'. `cd' to the directory where you want the
   4.135 +object files and executables to go and run the `configure' script.
   4.136 +`configure' automatically checks for the source code in the directory
   4.137 +that `configure' is in and in `..'. If for some reason `configure' is
   4.138 +not in the source code directory that you are configuring, then it will
   4.139 +report that it can't find the source code. In that case, run `configure'
   4.140 +with the option `--srcdir=DIR', where DIR is the directory that contains
   4.141 +the source code.
   4.142 +
   4.143 +Some systems require unusual options for compilation or linking that
   4.144 +the `configure' script does not know about. You can give `configure'
   4.145 +initial values for variables by setting them in the environment. Using
   4.146 +a Bourne-compatible shell, you can do that on the command line like
   4.147 +this:
   4.148 +
   4.149 +      CC=c89 CFLAGS=-O2 LIBS=-lposix ./configure
   4.150 +
   4.151 +Or on systems that have the `env' program, you can do it like this:
   4.152 +
   4.153 +      env CPPFLAGS=-I/usr/local/include LDFLAGS=-s ./configure
   4.154 +
   4.155 +Here are the `make' variables that you might want to override with
   4.156 +environment variables when running `configure'.
   4.157 +
   4.158 +For these variables, any value given in the environment overrides the
   4.159 +value that `configure' would choose:
   4.160 +
   4.161 +CC:      C compiler program. The default is `cc'.
   4.162 +
   4.163 +INSTALL: Program used to install files. The default value is `install'
   4.164 +         if you have it, otherwise `cp'.
   4.165 +
   4.166 +For these variables, any value given in the environment is added to the
   4.167 +value that `configure' chooses:
   4.168 +
   4.169 +DEFS:    Configuration options, in the form `-Dfoo -Dbar ...'.
   4.170 +
   4.171 +LIBS:    Libraries to link with, in the form `-lfoo -lbar ...'.
   4.172 +
   4.173 +Checking the package
   4.174 +--------------------
   4.175 +To check the package, i.e. to run some tests included in the package,
   4.176 +you can use the following command:
   4.177 +
   4.178 +      make check
   4.179 +
   4.180 +Installing the package
   4.181 +----------------------
   4.182 +Normally, to install the GLPK package you should type the following
   4.183 +command:
   4.184 +
   4.185 +      make install
   4.186 +
   4.187 +By default, `make install' will install the package's files in
   4.188 +`usr/local/bin', `usr/local/lib', etc. You can specify an installation
   4.189 +prefix other than `/usr/local' by giving `configure' the option
   4.190 +`--prefix=PATH'. Alternately, you can do so by consistently giving a
   4.191 +value for the `prefix' variable when you run `make', e.g.
   4.192 +
   4.193 +      make prefix=/usr/gnu
   4.194 +      make prefix=/usr/gnu install
   4.195 +
   4.196 +After installing you can remove the program binaries and object files
   4.197 +from the source directory by typing `make clean'. To remove all files
   4.198 +that `configure' created (`Makefile', `config.status', etc.), just type
   4.199 +`make distclean'.
   4.200 +
   4.201 +The file `configure.ac' is used to create `configure' by a program
   4.202 +called `autoconf'. You only need it if you want to remake `configure'
   4.203 +using a newer version of `autoconf'.
   4.204 +
   4.205 +Uninstalling the package
   4.206 +------------------------
   4.207 +To uninstall the GLPK package, i.e. to remove all the package's files
   4.208 +from the system places, you can use the following command:
   4.209 +
   4.210 +      make uninstall
   4.211 +
   4.212 +========================================================================
     5.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     5.2 +++ b/deps/glpk/Makefile.am	Sun Nov 06 20:59:10 2011 +0100
     5.3 @@ -0,0 +1,7 @@
     5.4 +## Process this file with automake to produce Makefile.in ##
     5.5 +
     5.6 +ACLOCAL_AMFLAGS=-I m4
     5.7 +
     5.8 +SUBDIRS = src examples
     5.9 +
    5.10 +## eof ##
     6.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     6.2 +++ b/deps/glpk/Makefile.in	Sun Nov 06 20:59:10 2011 +0100
     6.3 @@ -0,0 +1,719 @@
     6.4 +# Makefile.in generated by automake 1.11.1 from Makefile.am.
     6.5 +# @configure_input@
     6.6 +
     6.7 +# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
     6.8 +# 2003, 2004, 2005, 2006, 2007, 2008, 2009  Free Software Foundation,
     6.9 +# Inc.
    6.10 +# This Makefile.in is free software; the Free Software Foundation
    6.11 +# gives unlimited permission to copy and/or distribute it,
    6.12 +# with or without modifications, as long as this notice is preserved.
    6.13 +
    6.14 +# This program is distributed in the hope that it will be useful,
    6.15 +# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
    6.16 +# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
    6.17 +# PARTICULAR PURPOSE.
    6.18 +
    6.19 +@SET_MAKE@
    6.20 +VPATH = @srcdir@
    6.21 +pkgdatadir = $(datadir)/@PACKAGE@
    6.22 +pkgincludedir = $(includedir)/@PACKAGE@
    6.23 +pkglibdir = $(libdir)/@PACKAGE@
    6.24 +pkglibexecdir = $(libexecdir)/@PACKAGE@
    6.25 +am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
    6.26 +install_sh_DATA = $(install_sh) -c -m 644
    6.27 +install_sh_PROGRAM = $(install_sh) -c
    6.28 +install_sh_SCRIPT = $(install_sh) -c
    6.29 +INSTALL_HEADER = $(INSTALL_DATA)
    6.30 +transform = $(program_transform_name)
    6.31 +NORMAL_INSTALL = :
    6.32 +PRE_INSTALL = :
    6.33 +POST_INSTALL = :
    6.34 +NORMAL_UNINSTALL = :
    6.35 +PRE_UNINSTALL = :
    6.36 +POST_UNINSTALL = :
    6.37 +build_triplet = @build@
    6.38 +host_triplet = @host@
    6.39 +subdir = .
    6.40 +DIST_COMMON = README $(am__configure_deps) $(srcdir)/Makefile.am \
    6.41 +	$(srcdir)/Makefile.in $(srcdir)/config.h.in \
    6.42 +	$(top_srcdir)/configure AUTHORS COPYING ChangeLog INSTALL NEWS \
    6.43 +	THANKS config.guess config.sub depcomp install-sh ltmain.sh \
    6.44 +	missing
    6.45 +ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
    6.46 +am__aclocal_m4_deps = $(top_srcdir)/m4/libtool.m4 \
    6.47 +	$(top_srcdir)/m4/ltoptions.m4 $(top_srcdir)/m4/ltsugar.m4 \
    6.48 +	$(top_srcdir)/m4/ltversion.m4 $(top_srcdir)/m4/lt~obsolete.m4 \
    6.49 +	$(top_srcdir)/configure.ac
    6.50 +am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
    6.51 +	$(ACLOCAL_M4)
    6.52 +am__CONFIG_DISTCLEAN_FILES = config.status config.cache config.log \
    6.53 + configure.lineno config.status.lineno
    6.54 +mkinstalldirs = $(install_sh) -d
    6.55 +CONFIG_HEADER = config.h
    6.56 +CONFIG_CLEAN_FILES =
    6.57 +CONFIG_CLEAN_VPATH_FILES =
    6.58 +SOURCES =
    6.59 +DIST_SOURCES =
    6.60 +RECURSIVE_TARGETS = all-recursive check-recursive dvi-recursive \
    6.61 +	html-recursive info-recursive install-data-recursive \
    6.62 +	install-dvi-recursive install-exec-recursive \
    6.63 +	install-html-recursive install-info-recursive \
    6.64 +	install-pdf-recursive install-ps-recursive install-recursive \
    6.65 +	installcheck-recursive installdirs-recursive pdf-recursive \
    6.66 +	ps-recursive uninstall-recursive
    6.67 +RECURSIVE_CLEAN_TARGETS = mostlyclean-recursive clean-recursive	\
    6.68 +  distclean-recursive maintainer-clean-recursive
    6.69 +AM_RECURSIVE_TARGETS = $(RECURSIVE_TARGETS:-recursive=) \
    6.70 +	$(RECURSIVE_CLEAN_TARGETS:-recursive=) tags TAGS ctags CTAGS \
    6.71 +	distdir dist dist-all distcheck
    6.72 +ETAGS = etags
    6.73 +CTAGS = ctags
    6.74 +DIST_SUBDIRS = $(SUBDIRS)
    6.75 +DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
    6.76 +distdir = $(PACKAGE)-$(VERSION)
    6.77 +top_distdir = $(distdir)
    6.78 +am__remove_distdir = \
    6.79 +  { test ! -d "$(distdir)" \
    6.80 +    || { find "$(distdir)" -type d ! -perm -200 -exec chmod u+w {} ';' \
    6.81 +         && rm -fr "$(distdir)"; }; }
    6.82 +am__relativize = \
    6.83 +  dir0=`pwd`; \
    6.84 +  sed_first='s,^\([^/]*\)/.*$$,\1,'; \
    6.85 +  sed_rest='s,^[^/]*/*,,'; \
    6.86 +  sed_last='s,^.*/\([^/]*\)$$,\1,'; \
    6.87 +  sed_butlast='s,/*[^/]*$$,,'; \
    6.88 +  while test -n "$$dir1"; do \
    6.89 +    first=`echo "$$dir1" | sed -e "$$sed_first"`; \
    6.90 +    if test "$$first" != "."; then \
    6.91 +      if test "$$first" = ".."; then \
    6.92 +        dir2=`echo "$$dir0" | sed -e "$$sed_last"`/"$$dir2"; \
    6.93 +        dir0=`echo "$$dir0" | sed -e "$$sed_butlast"`; \
    6.94 +      else \
    6.95 +        first2=`echo "$$dir2" | sed -e "$$sed_first"`; \
    6.96 +        if test "$$first2" = "$$first"; then \
    6.97 +          dir2=`echo "$$dir2" | sed -e "$$sed_rest"`; \
    6.98 +        else \
    6.99 +          dir2="../$$dir2"; \
   6.100 +        fi; \
   6.101 +        dir0="$$dir0"/"$$first"; \
   6.102 +      fi; \
   6.103 +    fi; \
   6.104 +    dir1=`echo "$$dir1" | sed -e "$$sed_rest"`; \
   6.105 +  done; \
   6.106 +  reldir="$$dir2"
   6.107 +DIST_ARCHIVES = $(distdir).tar.gz
   6.108 +GZIP_ENV = --best
   6.109 +distuninstallcheck_listfiles = find . -type f -print
   6.110 +distcleancheck_listfiles = find . -type f -print
   6.111 +ACLOCAL = @ACLOCAL@
   6.112 +AMTAR = @AMTAR@
   6.113 +AR = @AR@
   6.114 +AUTOCONF = @AUTOCONF@
   6.115 +AUTOHEADER = @AUTOHEADER@
   6.116 +AUTOMAKE = @AUTOMAKE@
   6.117 +AWK = @AWK@
   6.118 +CC = @CC@
   6.119 +CCDEPMODE = @CCDEPMODE@
   6.120 +CFLAGS = @CFLAGS@
   6.121 +CPP = @CPP@
   6.122 +CPPFLAGS = @CPPFLAGS@
   6.123 +CYGPATH_W = @CYGPATH_W@
   6.124 +DEFS = @DEFS@
   6.125 +DEPDIR = @DEPDIR@
   6.126 +DLLTOOL = @DLLTOOL@
   6.127 +DSYMUTIL = @DSYMUTIL@
   6.128 +DUMPBIN = @DUMPBIN@
   6.129 +ECHO_C = @ECHO_C@
   6.130 +ECHO_N = @ECHO_N@
   6.131 +ECHO_T = @ECHO_T@
   6.132 +EGREP = @EGREP@
   6.133 +EXEEXT = @EXEEXT@
   6.134 +FGREP = @FGREP@
   6.135 +GREP = @GREP@
   6.136 +INSTALL = @INSTALL@
   6.137 +INSTALL_DATA = @INSTALL_DATA@
   6.138 +INSTALL_PROGRAM = @INSTALL_PROGRAM@
   6.139 +INSTALL_SCRIPT = @INSTALL_SCRIPT@
   6.140 +INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
   6.141 +LD = @LD@
   6.142 +LDFLAGS = @LDFLAGS@
   6.143 +LIBOBJS = @LIBOBJS@
   6.144 +LIBS = @LIBS@
   6.145 +LIBTOOL = @LIBTOOL@
   6.146 +LIPO = @LIPO@
   6.147 +LN_S = @LN_S@
   6.148 +LTLIBOBJS = @LTLIBOBJS@
   6.149 +MAKEINFO = @MAKEINFO@
   6.150 +MKDIR_P = @MKDIR_P@
   6.151 +NM = @NM@
   6.152 +NMEDIT = @NMEDIT@
   6.153 +OBJDUMP = @OBJDUMP@
   6.154 +OBJEXT = @OBJEXT@
   6.155 +OTOOL = @OTOOL@
   6.156 +OTOOL64 = @OTOOL64@
   6.157 +PACKAGE = @PACKAGE@
   6.158 +PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
   6.159 +PACKAGE_NAME = @PACKAGE_NAME@
   6.160 +PACKAGE_STRING = @PACKAGE_STRING@
   6.161 +PACKAGE_TARNAME = @PACKAGE_TARNAME@
   6.162 +PACKAGE_URL = @PACKAGE_URL@
   6.163 +PACKAGE_VERSION = @PACKAGE_VERSION@
   6.164 +PATH_SEPARATOR = @PATH_SEPARATOR@
   6.165 +RANLIB = @RANLIB@
   6.166 +SED = @SED@
   6.167 +SET_MAKE = @SET_MAKE@
   6.168 +SHELL = @SHELL@
   6.169 +STRIP = @STRIP@
   6.170 +VERSION = @VERSION@
   6.171 +abs_builddir = @abs_builddir@
   6.172 +abs_srcdir = @abs_srcdir@
   6.173 +abs_top_builddir = @abs_top_builddir@
   6.174 +abs_top_srcdir = @abs_top_srcdir@
   6.175 +ac_ct_CC = @ac_ct_CC@
   6.176 +ac_ct_DUMPBIN = @ac_ct_DUMPBIN@
   6.177 +am__include = @am__include@
   6.178 +am__leading_dot = @am__leading_dot@
   6.179 +am__quote = @am__quote@
   6.180 +am__tar = @am__tar@
   6.181 +am__untar = @am__untar@
   6.182 +bindir = @bindir@
   6.183 +build = @build@
   6.184 +build_alias = @build_alias@
   6.185 +build_cpu = @build_cpu@
   6.186 +build_os = @build_os@
   6.187 +build_vendor = @build_vendor@
   6.188 +builddir = @builddir@
   6.189 +datadir = @datadir@
   6.190 +datarootdir = @datarootdir@
   6.191 +docdir = @docdir@
   6.192 +dvidir = @dvidir@
   6.193 +exec_prefix = @exec_prefix@
   6.194 +host = @host@
   6.195 +host_alias = @host_alias@
   6.196 +host_cpu = @host_cpu@
   6.197 +host_os = @host_os@
   6.198 +host_vendor = @host_vendor@
   6.199 +htmldir = @htmldir@
   6.200 +includedir = @includedir@
   6.201 +infodir = @infodir@
   6.202 +install_sh = @install_sh@
   6.203 +libdir = @libdir@
   6.204 +libexecdir = @libexecdir@
   6.205 +localedir = @localedir@
   6.206 +localstatedir = @localstatedir@
   6.207 +mandir = @mandir@
   6.208 +mkdir_p = @mkdir_p@
   6.209 +oldincludedir = @oldincludedir@
   6.210 +pdfdir = @pdfdir@
   6.211 +prefix = @prefix@
   6.212 +program_transform_name = @program_transform_name@
   6.213 +psdir = @psdir@
   6.214 +sbindir = @sbindir@
   6.215 +sharedstatedir = @sharedstatedir@
   6.216 +srcdir = @srcdir@
   6.217 +sysconfdir = @sysconfdir@
   6.218 +target_alias = @target_alias@
   6.219 +to_host_path_cmd = @to_host_path_cmd@
   6.220 +top_build_prefix = @top_build_prefix@
   6.221 +top_builddir = @top_builddir@
   6.222 +top_srcdir = @top_srcdir@
   6.223 +ACLOCAL_AMFLAGS = -I m4
   6.224 +SUBDIRS = src examples
   6.225 +all: config.h
   6.226 +	$(MAKE) $(AM_MAKEFLAGS) all-recursive
   6.227 +
   6.228 +.SUFFIXES:
   6.229 +am--refresh:
   6.230 +	@:
   6.231 +$(srcdir)/Makefile.in:  $(srcdir)/Makefile.am  $(am__configure_deps)
   6.232 +	@for dep in $?; do \
   6.233 +	  case '$(am__configure_deps)' in \
   6.234 +	    *$$dep*) \
   6.235 +	      echo ' cd $(srcdir) && $(AUTOMAKE) --gnu'; \
   6.236 +	      $(am__cd) $(srcdir) && $(AUTOMAKE) --gnu \
   6.237 +		&& exit 0; \
   6.238 +	      exit 1;; \
   6.239 +	  esac; \
   6.240 +	done; \
   6.241 +	echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu Makefile'; \
   6.242 +	$(am__cd) $(top_srcdir) && \
   6.243 +	  $(AUTOMAKE) --gnu Makefile
   6.244 +.PRECIOUS: Makefile
   6.245 +Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
   6.246 +	@case '$?' in \
   6.247 +	  *config.status*) \
   6.248 +	    echo ' $(SHELL) ./config.status'; \
   6.249 +	    $(SHELL) ./config.status;; \
   6.250 +	  *) \
   6.251 +	    echo ' cd $(top_builddir) && $(SHELL) ./config.status $@ $(am__depfiles_maybe)'; \
   6.252 +	    cd $(top_builddir) && $(SHELL) ./config.status $@ $(am__depfiles_maybe);; \
   6.253 +	esac;
   6.254 +
   6.255 +$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
   6.256 +	$(SHELL) ./config.status --recheck
   6.257 +
   6.258 +$(top_srcdir)/configure:  $(am__configure_deps)
   6.259 +	$(am__cd) $(srcdir) && $(AUTOCONF)
   6.260 +$(ACLOCAL_M4):  $(am__aclocal_m4_deps)
   6.261 +	$(am__cd) $(srcdir) && $(ACLOCAL) $(ACLOCAL_AMFLAGS)
   6.262 +$(am__aclocal_m4_deps):
   6.263 +
   6.264 +config.h: stamp-h1
   6.265 +	@if test ! -f $@; then \
   6.266 +	  rm -f stamp-h1; \
   6.267 +	  $(MAKE) $(AM_MAKEFLAGS) stamp-h1; \
   6.268 +	else :; fi
   6.269 +
   6.270 +stamp-h1: $(srcdir)/config.h.in $(top_builddir)/config.status
   6.271 +	@rm -f stamp-h1
   6.272 +	cd $(top_builddir) && $(SHELL) ./config.status config.h
   6.273 +$(srcdir)/config.h.in:  $(am__configure_deps) 
   6.274 +	($(am__cd) $(top_srcdir) && $(AUTOHEADER))
   6.275 +	rm -f stamp-h1
   6.276 +	touch $@
   6.277 +
   6.278 +distclean-hdr:
   6.279 +	-rm -f config.h stamp-h1
   6.280 +
   6.281 +mostlyclean-libtool:
   6.282 +	-rm -f *.lo
   6.283 +
   6.284 +clean-libtool:
   6.285 +	-rm -rf .libs _libs
   6.286 +
   6.287 +distclean-libtool:
   6.288 +	-rm -f libtool config.lt
   6.289 +
   6.290 +# This directory's subdirectories are mostly independent; you can cd
   6.291 +# into them and run `make' without going through this Makefile.
   6.292 +# To change the values of `make' variables: instead of editing Makefiles,
   6.293 +# (1) if the variable is set in `config.status', edit `config.status'
   6.294 +#     (which will cause the Makefiles to be regenerated when you run `make');
   6.295 +# (2) otherwise, pass the desired values on the `make' command line.
   6.296 +$(RECURSIVE_TARGETS):
   6.297 +	@fail= failcom='exit 1'; \
   6.298 +	for f in x $$MAKEFLAGS; do \
   6.299 +	  case $$f in \
   6.300 +	    *=* | --[!k]*);; \
   6.301 +	    *k*) failcom='fail=yes';; \
   6.302 +	  esac; \
   6.303 +	done; \
   6.304 +	dot_seen=no; \
   6.305 +	target=`echo $@ | sed s/-recursive//`; \
   6.306 +	list='$(SUBDIRS)'; for subdir in $$list; do \
   6.307 +	  echo "Making $$target in $$subdir"; \
   6.308 +	  if test "$$subdir" = "."; then \
   6.309 +	    dot_seen=yes; \
   6.310 +	    local_target="$$target-am"; \
   6.311 +	  else \
   6.312 +	    local_target="$$target"; \
   6.313 +	  fi; \
   6.314 +	  ($(am__cd) $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \
   6.315 +	  || eval $$failcom; \
   6.316 +	done; \
   6.317 +	if test "$$dot_seen" = "no"; then \
   6.318 +	  $(MAKE) $(AM_MAKEFLAGS) "$$target-am" || exit 1; \
   6.319 +	fi; test -z "$$fail"
   6.320 +
   6.321 +$(RECURSIVE_CLEAN_TARGETS):
   6.322 +	@fail= failcom='exit 1'; \
   6.323 +	for f in x $$MAKEFLAGS; do \
   6.324 +	  case $$f in \
   6.325 +	    *=* | --[!k]*);; \
   6.326 +	    *k*) failcom='fail=yes';; \
   6.327 +	  esac; \
   6.328 +	done; \
   6.329 +	dot_seen=no; \
   6.330 +	case "$@" in \
   6.331 +	  distclean-* | maintainer-clean-*) list='$(DIST_SUBDIRS)' ;; \
   6.332 +	  *) list='$(SUBDIRS)' ;; \
   6.333 +	esac; \
   6.334 +	rev=''; for subdir in $$list; do \
   6.335 +	  if test "$$subdir" = "."; then :; else \
   6.336 +	    rev="$$subdir $$rev"; \
   6.337 +	  fi; \
   6.338 +	done; \
   6.339 +	rev="$$rev ."; \
   6.340 +	target=`echo $@ | sed s/-recursive//`; \
   6.341 +	for subdir in $$rev; do \
   6.342 +	  echo "Making $$target in $$subdir"; \
   6.343 +	  if test "$$subdir" = "."; then \
   6.344 +	    local_target="$$target-am"; \
   6.345 +	  else \
   6.346 +	    local_target="$$target"; \
   6.347 +	  fi; \
   6.348 +	  ($(am__cd) $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \
   6.349 +	  || eval $$failcom; \
   6.350 +	done && test -z "$$fail"
   6.351 +tags-recursive:
   6.352 +	list='$(SUBDIRS)'; for subdir in $$list; do \
   6.353 +	  test "$$subdir" = . || ($(am__cd) $$subdir && $(MAKE) $(AM_MAKEFLAGS) tags); \
   6.354 +	done
   6.355 +ctags-recursive:
   6.356 +	list='$(SUBDIRS)'; for subdir in $$list; do \
   6.357 +	  test "$$subdir" = . || ($(am__cd) $$subdir && $(MAKE) $(AM_MAKEFLAGS) ctags); \
   6.358 +	done
   6.359 +
   6.360 +ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
   6.361 +	list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
   6.362 +	unique=`for i in $$list; do \
   6.363 +	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
   6.364 +	  done | \
   6.365 +	  $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
   6.366 +	      END { if (nonempty) { for (i in files) print i; }; }'`; \
   6.367 +	mkid -fID $$unique
   6.368 +tags: TAGS
   6.369 +
   6.370 +TAGS: tags-recursive $(HEADERS) $(SOURCES) config.h.in $(TAGS_DEPENDENCIES) \
   6.371 +		$(TAGS_FILES) $(LISP)
   6.372 +	set x; \
   6.373 +	here=`pwd`; \
   6.374 +	if ($(ETAGS) --etags-include --version) >/dev/null 2>&1; then \
   6.375 +	  include_option=--etags-include; \
   6.376 +	  empty_fix=.; \
   6.377 +	else \
   6.378 +	  include_option=--include; \
   6.379 +	  empty_fix=; \
   6.380 +	fi; \
   6.381 +	list='$(SUBDIRS)'; for subdir in $$list; do \
   6.382 +	  if test "$$subdir" = .; then :; else \
   6.383 +	    test ! -f $$subdir/TAGS || \
   6.384 +	      set "$$@" "$$include_option=$$here/$$subdir/TAGS"; \
   6.385 +	  fi; \
   6.386 +	done; \
   6.387 +	list='$(SOURCES) $(HEADERS) config.h.in $(LISP) $(TAGS_FILES)'; \
   6.388 +	unique=`for i in $$list; do \
   6.389 +	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
   6.390 +	  done | \
   6.391 +	  $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
   6.392 +	      END { if (nonempty) { for (i in files) print i; }; }'`; \
   6.393 +	shift; \
   6.394 +	if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \
   6.395 +	  test -n "$$unique" || unique=$$empty_fix; \
   6.396 +	  if test $$# -gt 0; then \
   6.397 +	    $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
   6.398 +	      "$$@" $$unique; \
   6.399 +	  else \
   6.400 +	    $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
   6.401 +	      $$unique; \
   6.402 +	  fi; \
   6.403 +	fi
   6.404 +ctags: CTAGS
   6.405 +CTAGS: ctags-recursive $(HEADERS) $(SOURCES) config.h.in $(TAGS_DEPENDENCIES) \
   6.406 +		$(TAGS_FILES) $(LISP)
   6.407 +	list='$(SOURCES) $(HEADERS) config.h.in $(LISP) $(TAGS_FILES)'; \
   6.408 +	unique=`for i in $$list; do \
   6.409 +	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
   6.410 +	  done | \
   6.411 +	  $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
   6.412 +	      END { if (nonempty) { for (i in files) print i; }; }'`; \
   6.413 +	test -z "$(CTAGS_ARGS)$$unique" \
   6.414 +	  || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
   6.415 +	     $$unique
   6.416 +
   6.417 +GTAGS:
   6.418 +	here=`$(am__cd) $(top_builddir) && pwd` \
   6.419 +	  && $(am__cd) $(top_srcdir) \
   6.420 +	  && gtags -i $(GTAGS_ARGS) "$$here"
   6.421 +
   6.422 +distclean-tags:
   6.423 +	-rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
   6.424 +
   6.425 +distdir: $(DISTFILES)
   6.426 +	$(am__remove_distdir)
   6.427 +	test -d "$(distdir)" || mkdir "$(distdir)"
   6.428 +	@srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
   6.429 +	topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
   6.430 +	list='$(DISTFILES)'; \
   6.431 +	  dist_files=`for file in $$list; do echo $$file; done | \
   6.432 +	  sed -e "s|^$$srcdirstrip/||;t" \
   6.433 +	      -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \
   6.434 +	case $$dist_files in \
   6.435 +	  */*) $(MKDIR_P) `echo "$$dist_files" | \
   6.436 +			   sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \
   6.437 +			   sort -u` ;; \
   6.438 +	esac; \
   6.439 +	for file in $$dist_files; do \
   6.440 +	  if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
   6.441 +	  if test -d $$d/$$file; then \
   6.442 +	    dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \
   6.443 +	    if test -d "$(distdir)/$$file"; then \
   6.444 +	      find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
   6.445 +	    fi; \
   6.446 +	    if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
   6.447 +	      cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \
   6.448 +	      find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
   6.449 +	    fi; \
   6.450 +	    cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \
   6.451 +	  else \
   6.452 +	    test -f "$(distdir)/$$file" \
   6.453 +	    || cp -p $$d/$$file "$(distdir)/$$file" \
   6.454 +	    || exit 1; \
   6.455 +	  fi; \
   6.456 +	done
   6.457 +	@list='$(DIST_SUBDIRS)'; for subdir in $$list; do \
   6.458 +	  if test "$$subdir" = .; then :; else \
   6.459 +	    test -d "$(distdir)/$$subdir" \
   6.460 +	    || $(MKDIR_P) "$(distdir)/$$subdir" \
   6.461 +	    || exit 1; \
   6.462 +	  fi; \
   6.463 +	done
   6.464 +	@list='$(DIST_SUBDIRS)'; for subdir in $$list; do \
   6.465 +	  if test "$$subdir" = .; then :; else \
   6.466 +	    dir1=$$subdir; dir2="$(distdir)/$$subdir"; \
   6.467 +	    $(am__relativize); \
   6.468 +	    new_distdir=$$reldir; \
   6.469 +	    dir1=$$subdir; dir2="$(top_distdir)"; \
   6.470 +	    $(am__relativize); \
   6.471 +	    new_top_distdir=$$reldir; \
   6.472 +	    echo " (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) top_distdir="$$new_top_distdir" distdir="$$new_distdir" \\"; \
   6.473 +	    echo "     am__remove_distdir=: am__skip_length_check=: am__skip_mode_fix=: distdir)"; \
   6.474 +	    ($(am__cd) $$subdir && \
   6.475 +	      $(MAKE) $(AM_MAKEFLAGS) \
   6.476 +	        top_distdir="$$new_top_distdir" \
   6.477 +	        distdir="$$new_distdir" \
   6.478 +		am__remove_distdir=: \
   6.479 +		am__skip_length_check=: \
   6.480 +		am__skip_mode_fix=: \
   6.481 +	        distdir) \
   6.482 +	      || exit 1; \
   6.483 +	  fi; \
   6.484 +	done
   6.485 +	-test -n "$(am__skip_mode_fix)" \
   6.486 +	|| find "$(distdir)" -type d ! -perm -755 \
   6.487 +		-exec chmod u+rwx,go+rx {} \; -o \
   6.488 +	  ! -type d ! -perm -444 -links 1 -exec chmod a+r {} \; -o \
   6.489 +	  ! -type d ! -perm -400 -exec chmod a+r {} \; -o \
   6.490 +	  ! -type d ! -perm -444 -exec $(install_sh) -c -m a+r {} {} \; \
   6.491 +	|| chmod -R a+r "$(distdir)"
   6.492 +dist-gzip: distdir
   6.493 +	tardir=$(distdir) && $(am__tar) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).tar.gz
   6.494 +	$(am__remove_distdir)
   6.495 +
   6.496 +dist-bzip2: distdir
   6.497 +	tardir=$(distdir) && $(am__tar) | bzip2 -9 -c >$(distdir).tar.bz2
   6.498 +	$(am__remove_distdir)
   6.499 +
   6.500 +dist-lzma: distdir
   6.501 +	tardir=$(distdir) && $(am__tar) | lzma -9 -c >$(distdir).tar.lzma
   6.502 +	$(am__remove_distdir)
   6.503 +
   6.504 +dist-xz: distdir
   6.505 +	tardir=$(distdir) && $(am__tar) | xz -c >$(distdir).tar.xz
   6.506 +	$(am__remove_distdir)
   6.507 +
   6.508 +dist-tarZ: distdir
   6.509 +	tardir=$(distdir) && $(am__tar) | compress -c >$(distdir).tar.Z
   6.510 +	$(am__remove_distdir)
   6.511 +
   6.512 +dist-shar: distdir
   6.513 +	shar $(distdir) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).shar.gz
   6.514 +	$(am__remove_distdir)
   6.515 +
   6.516 +dist-zip: distdir
   6.517 +	-rm -f $(distdir).zip
   6.518 +	zip -rq $(distdir).zip $(distdir)
   6.519 +	$(am__remove_distdir)
   6.520 +
   6.521 +dist dist-all: distdir
   6.522 +	tardir=$(distdir) && $(am__tar) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).tar.gz
   6.523 +	$(am__remove_distdir)
   6.524 +
   6.525 +# This target untars the dist file and tries a VPATH configuration.  Then
   6.526 +# it guarantees that the distribution is self-contained by making another
   6.527 +# tarfile.
   6.528 +distcheck: dist
   6.529 +	case '$(DIST_ARCHIVES)' in \
   6.530 +	*.tar.gz*) \
   6.531 +	  GZIP=$(GZIP_ENV) gzip -dc $(distdir).tar.gz | $(am__untar) ;;\
   6.532 +	*.tar.bz2*) \
   6.533 +	  bzip2 -dc $(distdir).tar.bz2 | $(am__untar) ;;\
   6.534 +	*.tar.lzma*) \
   6.535 +	  lzma -dc $(distdir).tar.lzma | $(am__untar) ;;\
   6.536 +	*.tar.xz*) \
   6.537 +	  xz -dc $(distdir).tar.xz | $(am__untar) ;;\
   6.538 +	*.tar.Z*) \
   6.539 +	  uncompress -c $(distdir).tar.Z | $(am__untar) ;;\
   6.540 +	*.shar.gz*) \
   6.541 +	  GZIP=$(GZIP_ENV) gzip -dc $(distdir).shar.gz | unshar ;;\
   6.542 +	*.zip*) \
   6.543 +	  unzip $(distdir).zip ;;\
   6.544 +	esac
   6.545 +	chmod -R a-w $(distdir); chmod a+w $(distdir)
   6.546 +	mkdir $(distdir)/_build
   6.547 +	mkdir $(distdir)/_inst
   6.548 +	chmod a-w $(distdir)
   6.549 +	test -d $(distdir)/_build || exit 0; \
   6.550 +	dc_install_base=`$(am__cd) $(distdir)/_inst && pwd | sed -e 's,^[^:\\/]:[\\/],/,'` \
   6.551 +	  && dc_destdir="$${TMPDIR-/tmp}/am-dc-$$$$/" \
   6.552 +	  && am__cwd=`pwd` \
   6.553 +	  && $(am__cd) $(distdir)/_build \
   6.554 +	  && ../configure --srcdir=.. --prefix="$$dc_install_base" \
   6.555 +	    $(DISTCHECK_CONFIGURE_FLAGS) \
   6.556 +	  && $(MAKE) $(AM_MAKEFLAGS) \
   6.557 +	  && $(MAKE) $(AM_MAKEFLAGS) dvi \
   6.558 +	  && $(MAKE) $(AM_MAKEFLAGS) check \
   6.559 +	  && $(MAKE) $(AM_MAKEFLAGS) install \
   6.560 +	  && $(MAKE) $(AM_MAKEFLAGS) installcheck \
   6.561 +	  && $(MAKE) $(AM_MAKEFLAGS) uninstall \
   6.562 +	  && $(MAKE) $(AM_MAKEFLAGS) distuninstallcheck_dir="$$dc_install_base" \
   6.563 +	        distuninstallcheck \
   6.564 +	  && chmod -R a-w "$$dc_install_base" \
   6.565 +	  && ({ \
   6.566 +	       (cd ../.. && umask 077 && mkdir "$$dc_destdir") \
   6.567 +	       && $(MAKE) $(AM_MAKEFLAGS) DESTDIR="$$dc_destdir" install \
   6.568 +	       && $(MAKE) $(AM_MAKEFLAGS) DESTDIR="$$dc_destdir" uninstall \
   6.569 +	       && $(MAKE) $(AM_MAKEFLAGS) DESTDIR="$$dc_destdir" \
   6.570 +	            distuninstallcheck_dir="$$dc_destdir" distuninstallcheck; \
   6.571 +	      } || { rm -rf "$$dc_destdir"; exit 1; }) \
   6.572 +	  && rm -rf "$$dc_destdir" \
   6.573 +	  && $(MAKE) $(AM_MAKEFLAGS) dist \
   6.574 +	  && rm -rf $(DIST_ARCHIVES) \
   6.575 +	  && $(MAKE) $(AM_MAKEFLAGS) distcleancheck \
   6.576 +	  && cd "$$am__cwd" \
   6.577 +	  || exit 1
   6.578 +	$(am__remove_distdir)
   6.579 +	@(echo "$(distdir) archives ready for distribution: "; \
   6.580 +	  list='$(DIST_ARCHIVES)'; for i in $$list; do echo $$i; done) | \
   6.581 +	  sed -e 1h -e 1s/./=/g -e 1p -e 1x -e '$$p' -e '$$x'
   6.582 +distuninstallcheck:
   6.583 +	@$(am__cd) '$(distuninstallcheck_dir)' \
   6.584 +	&& test `$(distuninstallcheck_listfiles) | wc -l` -le 1 \
   6.585 +	   || { echo "ERROR: files left after uninstall:" ; \
   6.586 +	        if test -n "$(DESTDIR)"; then \
   6.587 +	          echo "  (check DESTDIR support)"; \
   6.588 +	        fi ; \
   6.589 +	        $(distuninstallcheck_listfiles) ; \
   6.590 +	        exit 1; } >&2
   6.591 +distcleancheck: distclean
   6.592 +	@if test '$(srcdir)' = . ; then \
   6.593 +	  echo "ERROR: distcleancheck can only run from a VPATH build" ; \
   6.594 +	  exit 1 ; \
   6.595 +	fi
   6.596 +	@test `$(distcleancheck_listfiles) | wc -l` -eq 0 \
   6.597 +	  || { echo "ERROR: files left in build directory after distclean:" ; \
   6.598 +	       $(distcleancheck_listfiles) ; \
   6.599 +	       exit 1; } >&2
   6.600 +check-am: all-am
   6.601 +check: check-recursive
   6.602 +all-am: Makefile config.h
   6.603 +installdirs: installdirs-recursive
   6.604 +installdirs-am:
   6.605 +install: install-recursive
   6.606 +install-exec: install-exec-recursive
   6.607 +install-data: install-data-recursive
   6.608 +uninstall: uninstall-recursive
   6.609 +
   6.610 +install-am: all-am
   6.611 +	@$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
   6.612 +
   6.613 +installcheck: installcheck-recursive
   6.614 +install-strip:
   6.615 +	$(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
   6.616 +	  install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
   6.617 +	  `test -z '$(STRIP)' || \
   6.618 +	    echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install
   6.619 +mostlyclean-generic:
   6.620 +
   6.621 +clean-generic:
   6.622 +
   6.623 +distclean-generic:
   6.624 +	-test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
   6.625 +	-test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES)
   6.626 +
   6.627 +maintainer-clean-generic:
   6.628 +	@echo "This command is intended for maintainers to use"
   6.629 +	@echo "it deletes files that may require special tools to rebuild."
   6.630 +clean: clean-recursive
   6.631 +
   6.632 +clean-am: clean-generic clean-libtool mostlyclean-am
   6.633 +
   6.634 +distclean: distclean-recursive
   6.635 +	-rm -f $(am__CONFIG_DISTCLEAN_FILES)
   6.636 +	-rm -f Makefile
   6.637 +distclean-am: clean-am distclean-generic distclean-hdr \
   6.638 +	distclean-libtool distclean-tags
   6.639 +
   6.640 +dvi: dvi-recursive
   6.641 +
   6.642 +dvi-am:
   6.643 +
   6.644 +html: html-recursive
   6.645 +
   6.646 +html-am:
   6.647 +
   6.648 +info: info-recursive
   6.649 +
   6.650 +info-am:
   6.651 +
   6.652 +install-data-am:
   6.653 +
   6.654 +install-dvi: install-dvi-recursive
   6.655 +
   6.656 +install-dvi-am:
   6.657 +
   6.658 +install-exec-am:
   6.659 +
   6.660 +install-html: install-html-recursive
   6.661 +
   6.662 +install-html-am:
   6.663 +
   6.664 +install-info: install-info-recursive
   6.665 +
   6.666 +install-info-am:
   6.667 +
   6.668 +install-man:
   6.669 +
   6.670 +install-pdf: install-pdf-recursive
   6.671 +
   6.672 +install-pdf-am:
   6.673 +
   6.674 +install-ps: install-ps-recursive
   6.675 +
   6.676 +install-ps-am:
   6.677 +
   6.678 +installcheck-am:
   6.679 +
   6.680 +maintainer-clean: maintainer-clean-recursive
   6.681 +	-rm -f $(am__CONFIG_DISTCLEAN_FILES)
   6.682 +	-rm -rf $(top_srcdir)/autom4te.cache
   6.683 +	-rm -f Makefile
   6.684 +maintainer-clean-am: distclean-am maintainer-clean-generic
   6.685 +
   6.686 +mostlyclean: mostlyclean-recursive
   6.687 +
   6.688 +mostlyclean-am: mostlyclean-generic mostlyclean-libtool
   6.689 +
   6.690 +pdf: pdf-recursive
   6.691 +
   6.692 +pdf-am:
   6.693 +
   6.694 +ps: ps-recursive
   6.695 +
   6.696 +ps-am:
   6.697 +
   6.698 +uninstall-am:
   6.699 +
   6.700 +.MAKE: $(RECURSIVE_CLEAN_TARGETS) $(RECURSIVE_TARGETS) all \
   6.701 +	ctags-recursive install-am install-strip tags-recursive
   6.702 +
   6.703 +.PHONY: $(RECURSIVE_CLEAN_TARGETS) $(RECURSIVE_TARGETS) CTAGS GTAGS \
   6.704 +	all all-am am--refresh check check-am clean clean-generic \
   6.705 +	clean-libtool ctags ctags-recursive dist dist-all dist-bzip2 \
   6.706 +	dist-gzip dist-lzma dist-shar dist-tarZ dist-xz dist-zip \
   6.707 +	distcheck distclean distclean-generic distclean-hdr \
   6.708 +	distclean-libtool distclean-tags distcleancheck distdir \
   6.709 +	distuninstallcheck dvi dvi-am html html-am info info-am \
   6.710 +	install install-am install-data install-data-am install-dvi \
   6.711 +	install-dvi-am install-exec install-exec-am install-html \
   6.712 +	install-html-am install-info install-info-am install-man \
   6.713 +	install-pdf install-pdf-am install-ps install-ps-am \
   6.714 +	install-strip installcheck installcheck-am installdirs \
   6.715 +	installdirs-am maintainer-clean maintainer-clean-generic \
   6.716 +	mostlyclean mostlyclean-generic mostlyclean-libtool pdf pdf-am \
   6.717 +	ps ps-am tags tags-recursive uninstall uninstall-am
   6.718 +
   6.719 +
   6.720 +# Tell versions [3.59,3.63) of GNU make to not export all variables.
   6.721 +# Otherwise a system limit (for SysV at least) may be exceeded.
   6.722 +.NOEXPORT:
     7.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     7.2 +++ b/deps/glpk/Makefile_MMIX	Sun Nov 06 20:59:10 2011 +0100
     7.3 @@ -0,0 +1,169 @@
     7.4 +# Build GLPK for MMIX with GCC cross-compiler
     7.5 +
     7.6 +#**********************************************************************#
     7.7 +# You can use this Makefile to build GLPK with GCC cross-compiler for  #
     7.8 +# MMIX. No configuring is needed.                                      #
     7.9 +#                                                                      #
    7.10 +# MMIX is a 64-bit RISC computer for the third millennium designed by  #
    7.11 +# Prof. Donald Knuth. For details see:                                 #
    7.12 +#                                                                      #
    7.13 +# http://www-cs-faculty.stanford.edu/~knuth/mmix.html                  #
    7.14 +# http://en.wikipedia.org/wiki/MMIX                                    #
    7.15 +# http://www.malgil.com/mmix                                           #
    7.16 +#                                                                      #
    7.17 +# The GNU MMIX compiler tool-suite (GCC backend, binutils, and newlib) #
    7.18 +# was developed by Hans-Peter Nilsson. You may follow his instructions #
    7.19 +# to build and install the MMIX tools; see:                            #
    7.20 +#                                                                      #
    7.21 +# http://bitrange.com/mmix/install.html                                #
    7.22 +#**********************************************************************#
    7.23 +
    7.24 +GCC = mmix-gcc
    7.25 +AR = mmix-ar
    7.26 +MMIX = mmix
    7.27 +CFLAGS = -O2
    7.28 +
    7.29 +OBJSET = \
    7.30 +src/glpapi01.o \
    7.31 +src/glpapi02.o \
    7.32 +src/glpapi03.o \
    7.33 +src/glpapi04.o \
    7.34 +src/glpapi05.o \
    7.35 +src/glpapi06.o \
    7.36 +src/glpapi07.o \
    7.37 +src/glpapi08.o \
    7.38 +src/glpapi09.o \
    7.39 +src/glpapi10.o \
    7.40 +src/glpapi11.o \
    7.41 +src/glpapi12.o \
    7.42 +src/glpapi13.o \
    7.43 +src/glpapi14.o \
    7.44 +src/glpapi15.o \
    7.45 +src/glpapi16.o \
    7.46 +src/glpapi17.o \
    7.47 +src/glpapi18.o \
    7.48 +src/glpapi19.o \
    7.49 +src/glpapi20.o \
    7.50 +src/glpapi21.o \
    7.51 +src/glpavl.o \
    7.52 +src/glpbfd.o \
    7.53 +src/glpbfx.o \
    7.54 +src/glpcpx.o \
    7.55 +src/glpdmp.o \
    7.56 +src/glpdmx.o \
    7.57 +src/glpenv01.o \
    7.58 +src/glpenv02.o \
    7.59 +src/glpenv03.o \
    7.60 +src/glpenv04.o \
    7.61 +src/glpenv05.o \
    7.62 +src/glpenv06.o \
    7.63 +src/glpenv07.o \
    7.64 +src/glpenv08.o \
    7.65 +src/glpfhv.o \
    7.66 +src/glpgmp.o \
    7.67 +src/glphbm.o \
    7.68 +src/glpini01.o \
    7.69 +src/glpini02.o \
    7.70 +src/glpios01.o \
    7.71 +src/glpios02.o \
    7.72 +src/glpios03.o \
    7.73 +src/glpios04.o \
    7.74 +src/glpios05.o \
    7.75 +src/glpios06.o \
    7.76 +src/glpios07.o \
    7.77 +src/glpios08.o \
    7.78 +src/glpios09.o \
    7.79 +src/glpios10.o \
    7.80 +src/glpios11.o \
    7.81 +src/glpios12.o \
    7.82 +src/glpipm.o \
    7.83 +src/glplib01.o \
    7.84 +src/glplib02.o \
    7.85 +src/glplib03.o \
    7.86 +src/glplpf.o \
    7.87 +src/glplpx01.o \
    7.88 +src/glplpx02.o \
    7.89 +src/glplpx03.o \
    7.90 +src/glpluf.o \
    7.91 +src/glplux.o \
    7.92 +src/glpmat.o \
    7.93 +src/glpmpl01.o \
    7.94 +src/glpmpl02.o \
    7.95 +src/glpmpl03.o \
    7.96 +src/glpmpl04.o \
    7.97 +src/glpmpl05.o \
    7.98 +src/glpmpl06.o \
    7.99 +src/glpmps.o \
   7.100 +src/glpnet01.o \
   7.101 +src/glpnet02.o \
   7.102 +src/glpnet03.o \
   7.103 +src/glpnet04.o \
   7.104 +src/glpnet05.o \
   7.105 +src/glpnet06.o \
   7.106 +src/glpnet07.o \
   7.107 +src/glpnet08.o \
   7.108 +src/glpnet09.o \
   7.109 +src/glpnpp01.o \
   7.110 +src/glpnpp02.o \
   7.111 +src/glpnpp03.o \
   7.112 +src/glpnpp04.o \
   7.113 +src/glpnpp05.o \
   7.114 +src/glpnpp06.o \
   7.115 +src/glpqmd.o \
   7.116 +src/glprgr.o \
   7.117 +src/glprng01.o \
   7.118 +src/glprng02.o \
   7.119 +src/glpscf.o \
   7.120 +src/glpscl.o \
   7.121 +src/glpsdf.o \
   7.122 +src/glpspm.o \
   7.123 +src/glpspx01.o \
   7.124 +src/glpspx02.o \
   7.125 +src/glpsql.o \
   7.126 +src/glpssx01.o \
   7.127 +src/glpssx02.o \
   7.128 +src/glptsp.o \
   7.129 +src/amd/amd_1.o \
   7.130 +src/amd/amd_2.o \
   7.131 +src/amd/amd_aat.o \
   7.132 +src/amd/amd_control.o \
   7.133 +src/amd/amd_defaults.o \
   7.134 +src/amd/amd_dump.o \
   7.135 +src/amd/amd_info.o \
   7.136 +src/amd/amd_order.o \
   7.137 +src/amd/amd_post_tree.o \
   7.138 +src/amd/amd_postorder.o \
   7.139 +src/amd/amd_preprocess.o \
   7.140 +src/amd/amd_valid.o \
   7.141 +src/colamd/colamd.o \
   7.142 +src/minisat/minisat.o \
   7.143 +src/zlib/adler32.o \
   7.144 +src/zlib/compress.o \
   7.145 +src/zlib/crc32.o \
   7.146 +src/zlib/deflate.o \
   7.147 +src/zlib/gzclose.o \
   7.148 +src/zlib/gzlib.o \
   7.149 +src/zlib/gzread.o \
   7.150 +src/zlib/gzwrite.o \
   7.151 +src/zlib/infback.o \
   7.152 +src/zlib/inffast.o \
   7.153 +src/zlib/inflate.o \
   7.154 +src/zlib/inftrees.o \
   7.155 +src/zlib/trees.o \
   7.156 +src/zlib/uncompr.o \
   7.157 +src/zlib/zio.o \
   7.158 +src/zlib/zutil.o
   7.159 +
   7.160 +.c.o:
   7.161 +	$(GCC) $(CFLAGS) -Isrc -o $@ -c $<
   7.162 +
   7.163 +all: libglpk.a glpsol.mmo
   7.164 +
   7.165 +libglpk.a: $(OBJSET)
   7.166 +	$(AR) cru libglpk.a $(OBJSET)
   7.167 +
   7.168 +glpsol.mmo: examples/glpsol.o libglpk.a
   7.169 +	$(GCC) $(CFLAGS) -o glpsol.mmo examples/glpsol.o libglpk.a -lm
   7.170 +
   7.171 +check: glpsol.mmo
   7.172 +	$(MMIX) glpsol.mmo --mps examples/plan.mps
     8.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     8.2 +++ b/deps/glpk/NEWS	Sun Nov 06 20:59:10 2011 +0100
     8.3 @@ -0,0 +1,1607 @@
     8.4 +GLPK 4.47 (release date: Sep 09, 2011)
     8.5 +
     8.6 +        The new API routine glp_intfeas1 was added to the package.
     8.7 +        This routine is a tentative implementation of the integer (0-1)
     8.8 +        feasibility solver based on the CNF-SAT solver (which currently
     8.9 +        is MiniSat). It may be used in the same way as glp_intopt to
    8.10 +        find either any integer feasible solution or a solution, for
    8.11 +        which the objective function is not worse than the specified
    8.12 +        value. Detailed description of this routine can be found in the
    8.13 +        document "CNF Satisfiability Problem", which is included in the
    8.14 +        distribution (see doc/cnfsat.pdf).
    8.15 +
    8.16 +        The following two options were added to glpsol:
    8.17 +
    8.18 +        --minisat       translate 0-1 feasibility problem to CNF-SAT
    8.19 +                        problem and solve it with glp_intfeas1/MiniSat
    8.20 +                        (if the problem instance is already in CNF-SAT
    8.21 +                        format, no translation is performed)
    8.22 +
    8.23 +        --objbnd bound  add inequality obj <= bound (minimization) or
    8.24 +                        obj >= bound (maximization) to 0-1 feasibility
    8.25 +                        problem (this option assumes --minisat)
    8.26 +
    8.27 +        The paint-by-numbers puzzle model (pbn.mod) included in the
    8.28 +        distribution is a nice example of the 0-1 feasibility problem,
    8.29 +        which can be efficiently solved with glp_intfeas1/MiniSat. This
    8.30 +        model along with a brief instruction (pbn.pdf) and benchmark
    8.31 +        examples from <webpbn.com> encoded in GNU MathProg (*.dat) can
    8.32 +        be found in subdirectory examples/pbn/.
    8.33 +
    8.34 +        The glpsol lp/mip solver was modified to bypass postprocessing
    8.35 +        of MathProg models if the solution reported is neither optimal
    8.36 +        nor feasible.
    8.37 +
    8.38 +        A minor bug in examples/Makefile.am was fixed to correctly
    8.39 +        build glpk in a separate directory. Thanks to Marco Atzeri
    8.40 +        <marco.atzeri@gmail.com> for bug report and patch.
    8.41 +
    8.42 +GLPK 4.46 (release date: Aug 09, 2011)
    8.43 +
    8.44 +        The following new API routines were added:
    8.45 +
    8.46 +        glp_read_cnfsat    read CNF-SAT problem data in DIMACS format
    8.47 +        glp_check_cnfsat   check for CNF-SAT problem instance
    8.48 +        glp_write_cnfsat   write CNF-SAT problem data in DIMACS format
    8.49 +        glp_minisat1       solve CNF-SAT problem instance with MiniSat
    8.50 +
    8.51 +        The routine glp_minisat1 is a driver to MiniSat, a CNF-SAT
    8.52 +        solver developed by Niklas Een and Niklas Sorensson, Chalmers
    8.53 +        University of Technology, Sweden. This routine is similar to
    8.54 +        the routine glp_intopt, however, it is intended to solve a 0-1
    8.55 +        programming problem instance, which is the MIP translation of
    8.56 +        a CNF-SAT problem instance.
    8.57 +
    8.58 +        Detailed description of these new API routines can be found in
    8.59 +        the document "CNF Satisfiability Problem", which is included in
    8.60 +        the distribution (see files doc/cnfsat.tex and doc/cnfsat.pdf).
    8.61 +
    8.62 +        The following new glpsol command-line options were added:
    8.63 +
    8.64 +        --cnf filename     read CNF-SAT problem instance in DIMACS
    8.65 +                           format from filename and translate it to MIP
    8.66 +        --wcnf filename    write CNF-SAT problem instance in DIMACS
    8.67 +                           format to filename
    8.68 +        --minisat          solve CNF-SAT problem instance with MiniSat
    8.69 +                           solver
    8.70 +
    8.71 +        The zlib compression library (version 1.2.5) was ANSIfied,
    8.72 +        modified according to GLPK requirements and included in the
    8.73 +        distribution as an external software module. Thus, now this
    8.74 +        feature is platform independent.
    8.75 +
    8.76 +        Some bugs were fixed in the SQL table driver. Thanks to Xypron
    8.77 +        <xypron.glpk@gmx.de>.
    8.78 +
    8.79 +GLPK 4.45 (release date: Dec 05, 2010)
    8.80 +
    8.81 +        This is a bug-fix release.
    8.82 +
    8.83 +        Several bugs/typos were fixed. Thanks to
    8.84 +        Xypron <xypron.glpk@gmx.de>,
    8.85 +        Robbie Morrison <robbie@actrix.co.nz>, and
    8.86 +        Ali Baharev <ali.baharev@gmail.com> for reports.
    8.87 +
    8.88 +        Some glpk documents was re-formatted and merged into a single
    8.89 +        document. Now the glpk documentation consists of the following
    8.90 +        three main documents (all included in the distribution):
    8.91 +
    8.92 +        GLPK: Reference Manual
    8.93 +
    8.94 +        GLPK: Graph and Network Routines
    8.95 +
    8.96 +        Modeling Language GNU MathProg: Language Reference
    8.97 +
    8.98 +GLPK 4.44 (release date: Jun 03, 2010)
    8.99 +
   8.100 +        The following suffixes for variables and constraints were
   8.101 +        implemented in the MathProg language:
   8.102 +
   8.103 +        .lb     (lower bound),
   8.104 +        .ub     (upper bound),
   8.105 +        .status (status in the solution),
   8.106 +        .val    (primal value), and
   8.107 +        .dual   (dual value).
   8.108 +
   8.109 +        Thanks to Xypron <xypron.glpk@gmx.de> for draft implementation
   8.110 +        and testing.
   8.111 +
   8.112 +        Now the MathProg language allows comment records (marked by
   8.113 +        '#' in the very first position) in CSV data files read with the
   8.114 +        table statements. Note that the comment records may appear only
   8.115 +        in the beginning of a CSV data file.
   8.116 +
   8.117 +        The API routine glp_cpp to solve the Critical Path Problem was
   8.118 +        added and documented.
   8.119 +
   8.120 +GLPK 4.43 (release date: Feb 20, 2010)
   8.121 +
   8.122 +        This is a maintainer release.
   8.123 +
   8.124 +        `configure.ac' was changed to allow building the package under
   8.125 +        Mac OS and Darwin with ODBC support.
   8.126 +        Thanks to Xypron <xypron.glpk@gmx.de> for suggestions and Noli
   8.127 +        Sicad <nsicad@gmail.com> for testing.
   8.128 +
   8.129 +        The SQL table driver was improved to process NULL data. Thanks
   8.130 +        to Xypron <xypron.glpk@gmx.de>.
   8.131 +
   8.132 +        Some bugs were fixed in the LP/MIP preprocessor.
   8.133 +
   8.134 +GLPK 4.42 (release date: Jan 13, 2010)
   8.135 +
   8.136 +        The following new API routines were added:
   8.137 +
   8.138 +        glp_check_dup         check for duplicate elements in sparse
   8.139 +                              matrix
   8.140 +        glp_sort_matrix       sort elements of the constraint matrix
   8.141 +        glp_read_prob         read problem data in GLPK format
   8.142 +        glp_write_prob        write problem data in GLPK format
   8.143 +        glp_analyze_bound     analyze active bound of non-basic variable
   8.144 +        glp_analyze_coef      analyze objective coefficient at basic
   8.145 +                              variable
   8.146 +        glp_print_ranges      print sensitivity analysis report (this
   8.147 +                              routine replaces lpx_print_sens_bnds and
   8.148 +                              makes it deprecated)
   8.149 +
   8.150 +        For description of these new routines and the GLPK LP/MIP
   8.151 +        format see a new edition of the reference manual included in
   8.152 +        the distribution. (Chapter "Graph and network API routines" was
   8.153 +        carried out from the main reference manual and included in the
   8.154 +        distribution as a separate document.)
   8.155 +
   8.156 +        The following new command-line options were added to the stand-
   8.157 +        alone solver glpsol:
   8.158 +        --glp filename        read problem data in GLPK format
   8.159 +        --wglp filename       write problem data in GLPK format
   8.160 +        --ranges filename     print sensitivity analysis report (this
   8.161 +                              option replaces --bounds)
   8.162 +
   8.163 +        Now all GLPK routines performing file I/O support special
   8.164 +        filenames "/dev/stdin", "/dev/stdout", and "/dev/stderr", which
   8.165 +        can be specified in the same way as regular filenames. This
   8.166 +        feature is plaform-independent.
   8.167 +
   8.168 +GLPK 4.41 (release date: Dec 21, 2009)
   8.169 +
   8.170 +        The following new API routies were added:
   8.171 +
   8.172 +        glp_transform_row     transform explicitly specified row
   8.173 +        glp_transform_col     transform explicitly specified column
   8.174 +        glp_prim_rtest        perform primal ratio test
   8.175 +        glp_dual_rtest        perform dual ratio test
   8.176 +
   8.177 +        For description of these new routines see a new edition of the
   8.178 +        reference manual included in the distribution.
   8.179 +
   8.180 +        The following API routines are deprecated: lpx_transform_row,
   8.181 +        lpx_transform_col, lpx_prim_ratio_test, lpx_dual_ratio_test.
   8.182 +
   8.183 +        Some improvements were made in the MIP solver (glp_intopt).
   8.184 +
   8.185 +        The SQL table driver used to read/write data in MathProg models
   8.186 +        was changed to allow multiple arguments separated by semicolon
   8.187 +        in SQL statements. Thanks to Xypron <xypron.glpk@gmx.de>.
   8.188 +
   8.189 +        Two new options were added to the glpsol stand-alone solver:
   8.190 +        --seed value (to initialize the pseudo-random number generator
   8.191 +        used in MathProg models with specified value), and
   8.192 +        --ini filename (to use a basis previously saved with -w option
   8.193 +        as an initial basis on solving similar LP's).
   8.194 +
   8.195 +        Two new MathProg example models were included. Thanks to
   8.196 +        Nigel Galloway <nigel_galloway@operamail.com> and Noli Sicad
   8.197 +        <nsicad@gmail.com> for contribution.
   8.198 +
   8.199 +        Scripts to build GLPK with Microsoft Visual Studio 2010 for
   8.200 +        both 32-bit and 64-bit Windows were included. Thanks to Xypron
   8.201 +        <xypron.glpk@gmx.de> for contribution and testing.
   8.202 +
   8.203 +GLPK 4.40 (release date: Nov 03, 2009)
   8.204 +
   8.205 +        The following new API routines were added:
   8.206 +
   8.207 +        glp_del_vertices      remove vertices from graph
   8.208 +        glp_del_arc           remove arc from graph
   8.209 +        glp_wclique_exact     find maximum weight clique with the exact
   8.210 +                              algorithm developed by Prof. P. Ostergard
   8.211 +        glp_read_ccdata       read graph in DIMACS clique/coloring
   8.212 +                              format
   8.213 +        glp_write_ccdata      write graph in DIMACS clique/coloring
   8.214 +                              format
   8.215 +
   8.216 +        For description of these new routines see a new edition of the
   8.217 +        reference manual included in the distribution.
   8.218 +
   8.219 +        The hybrid pseudocost branching heuristic was included in the
   8.220 +        MIP solver. It is available on API level (iocp.br_tech should
   8.221 +        be set to GLP_BR_PCH) and in the stand-alone solver glpsol
   8.222 +        (via the command-line option --pcost). This heuristic may be
   8.223 +        useful on solving hard MIP instances.
   8.224 +
   8.225 +        The branching heuristic by Driebeck and Tomlin (used in the
   8.226 +        MIP solver by default) was changed to switch to branching on
   8.227 +        most fractional variable if an lower bound of degradation of
   8.228 +        the objective is close to zero for all branching candidates.
   8.229 +
   8.230 +        A bug was fixed in the LP preprocessor (routine npp_empty_col).
   8.231 +        Thanks to Stefan Vigerske <stefan@math.hu-berlin.de> for the
   8.232 +        bug report.
   8.233 +
   8.234 +        A bug was fixed and some improvements were made in the FPUMP
   8.235 +        heuristic module. Thanks to Xypron <xypron.glpk@gmx.de>.
   8.236 +
   8.237 +        A bug was fixed in the API routine glp_warm_up (dual
   8.238 +        feasibility test was incorrect in maximization case). Thanks to
   8.239 +        Uday Venkatadri <Uday.Venkatadri@dal.ca> for the bug report.
   8.240 +
   8.241 +GLPK 4.39 (release date: Jul 26, 2009)
   8.242 +
   8.243 +        The following new API routines were added:
   8.244 +
   8.245 +        glp_warm_up           "warm up" LP basis
   8.246 +        glp_set_vertex_name   assign (change) vertex name
   8.247 +        glp_create_v_index    create vertex name index
   8.248 +        glp_find_vertex       find vertex by its name
   8.249 +        glp_delete_v_index    delete vertex name index
   8.250 +        glp_read_asnprob      read assignment problem data in DIMACS
   8.251 +                              format
   8.252 +        glp_write_asnprob     write assignment problem data in DIMACS
   8.253 +                              format
   8.254 +        glp_check_asnprob     check correctness of assignment problem
   8.255 +                              data
   8.256 +        glp_asnprob_lp        convert assignment problem to LP
   8.257 +        glp_asnprob_okalg     solve assignment problem with the
   8.258 +                              out-of-kilter algorithm
   8.259 +        glp_asnprob_hall      find bipartite matching of maxumum
   8.260 +                              cardinality with Hall's algorithm
   8.261 +
   8.262 +        Also were added some API routines to read plain data files.
   8.263 +
   8.264 +        The API routines glp_read_lp and glp_write_lp to read/write
   8.265 +        files in CPLEX LP format were re-implemented. Now glp_write_lp
   8.266 +        correctly writes double-bounded (ranged) rows by introducing
   8.267 +        slack variables rather than by duplicating the rows.
   8.268 +
   8.269 +        For description of these new routines see a new edition of the
   8.270 +        reference manual included in the distribution.
   8.271 +
   8.272 +        The 'xfree(NULL)' bug was fixed in the AMD routines. Thanks to
   8.273 +        Niels Klitgord <niels@bu.edu> for bug report.
   8.274 +
   8.275 +        The message "Crashing..." was changed to "Constructing initial
   8.276 +        basis..." due to suggestion by Thomas Kahle <tom111@gmx.de>.
   8.277 +
   8.278 +        Some typos were corrected in glpsol output messages. Thanks to
   8.279 +        Xypron <xypron.glpk@gmx.de> for patch.
   8.280 +
   8.281 +GLPK 4.38 (release date: May 02, 2009)
   8.282 +
   8.283 +        API routines glp_read_mps and glp_write_mps were improved.
   8.284 +
   8.285 +        Some improvements were made in the dual simplex routines.
   8.286 +
   8.287 +        Two external software modules AMD and COLAMD were included in
   8.288 +        the distribution (for more details please see src/amd/README
   8.289 +        and src/colamd/README). Now they are used in the interior-point
   8.290 +        solver to reorder the matrix prior to Cholesky factorization.
   8.291 +
   8.292 +        API routine glp_ipt_status may return two new statuses due to
   8.293 +        changes in the routine glp_interior. For details please see the
   8.294 +        reference manual included in the distribution.
   8.295 +
   8.296 +        A minor bug was fixed in the graph/network routines. Thanks to
   8.297 +        Nelson H. F. Beebe <beebe@math.utah.edu> for bug report.
   8.298 +
   8.299 +GLPK 4.37 (release date: Mar 29, 2009)
   8.300 +
   8.301 +        The 0-1 Feasibility Pump heuristic was included in the GLPK
   8.302 +        integer optimizer glp_intopt. On API level the heuristic can be
   8.303 +        enabled by setting the parameter fp_heur in glp_iocp to GLP_ON.
   8.304 +        This feature is also available in the solver glpsol through
   8.305 +        command-line option '--fpump'. For more details please see the
   8.306 +        reference manual included in the distribution.
   8.307 +
   8.308 +        The following new API routines were added:
   8.309 +
   8.310 +        glp_print_sol         write basic solution in printable format
   8.311 +        glp_print_ipt         write interior-point solution in printable
   8.312 +                              format
   8.313 +        glp_print_mip         write MIP solution in printable format
   8.314 +        glp_read_graph        read (di)graph from plain text file
   8.315 +        glp_write_graph       write (di)graph to plain text file
   8.316 +        glp_weak_comp         find all weakly connected components
   8.317 +        glp_strong_comp       find all strongly connected components
   8.318 +
   8.319 +        The following API routines are deprecated: lpx_print_sol,
   8.320 +        lpx_print_ips, lpx_print_mip, lpx_print_prob (the latter is
   8.321 +        equivalent to glp_write_lp).
   8.322 +
   8.323 +        A bug was fixed in the interior-point solver (glp_interior) to
   8.324 +        correctly compute dual solution components when the problem is
   8.325 +        scaled.
   8.326 +
   8.327 +        The files configure.ac and Makefile.am were changed:
   8.328 +        (a) to allow using autoreconf/autoheader;
   8.329 +        (b) to allow building the package in a directory other than its
   8.330 +            source directory.
   8.331 +        Thanks to Marco Atzeri <marco_atzeri@yahoo.it> for bug report.
   8.332 +
   8.333 +        An example model in the GNU MathProg language was added.
   8.334 +        Thanks to Larry D'Agostino <Larry.D'Agostino@gmacrescap.com> for
   8.335 +        contribution.
   8.336 +
   8.337 +GLPK 4.36 (release date: Feb 06, 2009)
   8.338 +
   8.339 +        The following new API routines were added to the package:
   8.340 +
   8.341 +        glp_mincost_okalg     find minimum-cost flow with out-of-kilter
   8.342 +                              algorithm
   8.343 +        glp_maxflow_ffalg     find maximal flow with Ford-Fulkerson
   8.344 +                              algorithm
   8.345 +
   8.346 +        For detailed description of these new routines and related data
   8.347 +        structures see chapter "Graph and Network API Routines" in a new
   8.348 +        edition of the reference manual included in the distribution.
   8.349 +
   8.350 +        The following two new command-line options were added to the
   8.351 +        solver glpsol:
   8.352 +
   8.353 +        --mincost             read min-cost flow data in DIMACS format
   8.354 +        --maxflow             read maximum flow data in DIMACS format
   8.355 +
   8.356 +        Duplicate symbols in the header glpk.h were removed to allow
   8.357 +        using swig.
   8.358 +        Thanks to Kelly Westbrooks <kellywestbrooks@yahoo.com> and
   8.359 +        Nigel Galloway <nigel_galloway@operamail.com> for suggestion.
   8.360 +
   8.361 +        A minor defect was fixed in the routine glp_write_lp.
   8.362 +        Thanks to Sebastien Briais <sbriais@free.fr> for bug report.
   8.363 +
   8.364 +        A minor bug was fixed in the SQL module.
   8.365 +        Thanks to Xypron <xypron.glpk@gmx.de> for patch.
   8.366 +
   8.367 +        Some new example models in the GNU MathProg modeling language
   8.368 +        were added. Thanks to Sebastian Nowozin <nowozin@gmail.com> and
   8.369 +        Nigel Galloway <nigel_galloway@operamail.com> for contribution.
   8.370 +
   8.371 +GLPK 4.35 (release date: Jan 09, 2009)
   8.372 +
   8.373 +        The following new API routines were added to the package:
   8.374 +
   8.375 +        glp_create_graph      create graph
   8.376 +        glp_set_graph_name    assign (change) graph name
   8.377 +        glp_add_vertices      add new vertices to graph
   8.378 +        glp_add_arc           add new arc to graph
   8.379 +        glp_erase_graph       erase graph content
   8.380 +        glp_delete_graph      delete graph
   8.381 +        glp_read_mincost      read minimum cost flow problem data in
   8.382 +                              DIMACS format
   8.383 +        glp_write_mincost     write minimum cost flow problem data in
   8.384 +                              DIMACS format
   8.385 +        glp_mincost_lp        convert minimum cost flow problem to LP
   8.386 +        glp_netgen            Klingman's network problem generator
   8.387 +        glp_gridgen           grid-like network problem generator
   8.388 +        glp_read_maxflow      read maximum flow problem data in DIMACS
   8.389 +                              format
   8.390 +        glp_write_maxflow     write maximum flow problem data in DIMACS
   8.391 +                              format
   8.392 +        glp_maxflow_lp        convert maximum flow problem to LP
   8.393 +        glp_rmfgen            Goldfarb's maximum flow problem generator
   8.394 +
   8.395 +        For detailed description of these new routines and related data
   8.396 +        structures see chapter "Graph and Network API Routines" in a new
   8.397 +        edition of the reference manual included in the distribution.
   8.398 +
   8.399 +        A minor change were made in the internal routine xputc. Thanks
   8.400 +        to Luiz Bettoni <bettoni@cpgei.ct.utfpr.edu.br> for suggestion.
   8.401 +
   8.402 +        A minor bug was fixed in the internal routine mpl_fn_time2str.
   8.403 +        Thanks to Stefan Vigerske <stefan@vigerske.de> for bug report.
   8.404 +
   8.405 +GLPK 4.34 (release date: Dec 04, 2008)
   8.406 +
   8.407 +        The GNU MathProg modeling language was supplemented with three
   8.408 +        new built-in functions:
   8.409 +
   8.410 +        gmtime    obtaining current calendar time
   8.411 +        str2time  converting character string to calendar time
   8.412 +        time2str  converting calendar time to character string
   8.413 +
   8.414 +        (Thanks to Xypron <xypron.glpk@gmx.de>.)
   8.415 +
   8.416 +        For detailed description of these functions see Appendix A in
   8.417 +        the document "Modeling Language GNU MathProg", a new edition of
   8.418 +        which was included in the distribution.
   8.419 +
   8.420 +        A bug was fixed in the MIP solver. Thanks to Nigel Galloway
   8.421 +        <nigel_galloway@operamail.com> for bug report.
   8.422 +
   8.423 +        A new makefile was added to build the GLPK DLL with Microsoft
   8.424 +        Visual Studio Express 2008 for 64-bit Windows. Thanks to Xypron
   8.425 +        <xypron.glpk@gmx.de> for contribution and testing.
   8.426 +
   8.427 +GLPK 4.33 (release date: Oct 30, 2008)
   8.428 +
   8.429 +        The following new API routines were added to the package:
   8.430 +        glp_copy_prob         copy problem object content
   8.431 +        glp_exact             solve LP in exact arithmetic
   8.432 +                              (makes lpx_exact deprecated)
   8.433 +        glp_get_unbnd_ray     determine variable causing unboundedness
   8.434 +                              (makes lpx_get_ray_info deprecated)
   8.435 +        glp_interior          solve LP with interior-point method
   8.436 +                              (makes lpx_interior deprecated)
   8.437 +
   8.438 +        The following new API routines for processing models written in
   8.439 +        the GNU Mathprog language were added to the package:
   8.440 +        glp_mpl_alloc_wksp    allocate the translator workspace
   8.441 +        glp_mpl_read_model    read and translate model section
   8.442 +        glp_mpl_read_data     read and translate data section
   8.443 +        glp_mpl_generate      generate the model
   8.444 +        glp_mpl_build_prob    build LP/MIP instance from the model
   8.445 +        glp_mpl_postsolve     postsolve the model
   8.446 +        glp_mpl_free_wksp     deallocate the translator workspace
   8.447 +        (These routines make lpx_read_model deprecated.)
   8.448 +
   8.449 +        For description of all these new API routines see the reference
   8.450 +        manual included in the distribution.
   8.451 +
   8.452 +        A crude implementation of CPLEX-like interface to GLPK API was
   8.453 +        added to the package. Currently it allows using GLPK as a core
   8.454 +        LP solver for Concorde, a well known computer code for solving
   8.455 +        the symmetric TSP. For details see examples/cplex/README.
   8.456 +
   8.457 +        Some bugs were fixed in the SQL table driver. Thanks to Xypron
   8.458 +        <xypron.glpk@gmx.de>.
   8.459 +
   8.460 +GLPK 4.32 (release date: Oct 03, 2008)
   8.461 +
   8.462 +        The following new features were included in the MIP solver
   8.463 +        (the API routine glp_intopt):
   8.464 +
   8.465 +        *  MIP presolver
   8.466 +        *  mixed cover cut generator
   8.467 +        *  clique cut generator
   8.468 +        *  Euclidean reduction of the objective value
   8.469 +
   8.470 +        Due to changes the routine glp_intopt may additionally return
   8.471 +        GLP_ENOPFS, GLP_ENODFS, and GLP_EMIPGAP.
   8.472 +
   8.473 +        The API routines lpx_integer are lpx_intopt are deprecated,
   8.474 +        since they are completely superseded by glp_intopt.
   8.475 +
   8.476 +        The following new branch-and-cut API routines were added:
   8.477 +        glp_ios_row_attr      determine additional row attributes
   8.478 +        glp_ios_pool_size     determine current size of the cut pool
   8.479 +        glp_ios_add_row       add constraint to the cut pool
   8.480 +        glp_ios_del_row       delete constraint from the cut pool
   8.481 +        glp_ios_clear_pool    delete all constraints from the cut pool
   8.482 +
   8.483 +        For description of these new routines see the reference manual
   8.484 +        included in the distribution.
   8.485 +
   8.486 +        The stand-alone solver glpsol was changed to allow multiple
   8.487 +        data files.
   8.488 +
   8.489 +        A new edition of the supplement "Using Data Tables in the GNU
   8.490 +        MathProg Modeling Language" was included.
   8.491 +
   8.492 +        As usual, some bugs were fixed (in the MathProg translator).
   8.493 +        Thanks to Xypron <xypron.glpk@gmx.de>.
   8.494 +
   8.495 +GLPK 4.31 (release date: Sep 02, 2008)
   8.496 +
   8.497 +        The core LP solver based on the dual simplex method was
   8.498 +        re-implemented and now it provides both phases I and II.
   8.499 +
   8.500 +        The following new API routines were added:
   8.501 +        glp_scale_prob  automatic scaling of problem data
   8.502 +        glp_std_basis   construct standard initial LP basis
   8.503 +        glp_adv_basis   construct advanced initial LP basis
   8.504 +        glp_cpx_basis   construct Bixby's initial LP basis
   8.505 +
   8.506 +        For description of these new routines see the reference manual
   8.507 +        included in the distribution.
   8.508 +
   8.509 +        The following API routines are deprecated:
   8.510 +        lpx_scale_prob, lpx_std_basis, lpx_adv_basis, lpx_cpx_basis.
   8.511 +
   8.512 +        Necessary changes were made in memory allocation routines to
   8.513 +        resolve portability issues for 64-bit platforms.
   8.514 +
   8.515 +        New version of the routine lpx_write_pb to write problem data
   8.516 +        in OPB (pseudo boolean format) was added to the package. Thanks
   8.517 +        to Oscar Gustafsson <oscarg@isy.liu.se> for the contribution.
   8.518 +
   8.519 +        Two new makefiles were added to build the package for 32- and
   8.520 +        64-bit Windows with Microsoft Visual Studio Express 2008.
   8.521 +        Thanks to Heinrich Schuchardt <heinrich.schuchardt@gmx.de> (aka
   8.522 +        Xypron) for the contribution and testing.
   8.523 +
   8.524 +        Two new makefiles were added to build the package with Digital
   8.525 +        Mars C/C++ 8.50 and Open Watcom C/C++ 1.6 (for 32-bit Windows).
   8.526 +
   8.527 +GLPK 4.30 (release date: Aug 13, 2008)
   8.528 +
   8.529 +        The core LP solver based on the primal simplex method was
   8.530 +        re-implemented to allow its further improvements. Currently the
   8.531 +        new version provides the same features as the old one, however,
   8.532 +        it is a bit faster and more numerically stable.
   8.533 +
   8.534 +        Some changes were made in the MathProg translator to allow <,
   8.535 +        <=, >=, and > on comparing symbolic values. Thanks to Heinrich
   8.536 +        Schuchardt <heinrich.schuchardt@gmx.de> for patches.
   8.537 +
   8.538 +        Internal routine set_d_eps in the exact LP solver was changed
   8.539 +        to prevent approximation errors in case of integral data.
   8.540 +        Thanks to Markus Pilz <pilz@cs.uni-bonn.de> for bug report.
   8.541 +
   8.542 +GLPK 4.29 (release date: Jul 06, 2008)
   8.543 +
   8.544 +        The configure script was changed to disable all optional
   8.545 +        features by default. For details please see file INSTALL.
   8.546 +
   8.547 +        The following new API routines were added:
   8.548 +        glp_erase_prob  erase problem object content
   8.549 +        glp_read_mps    read problem data in MPS format
   8.550 +        glp_write_mps   write problem data in MPS format
   8.551 +        glp_read_lp     read problem data in CPLEX LP format
   8.552 +        glp_write_lp    write problem data in CPLEX LP format
   8.553 +
   8.554 +        For description of these new routines see the reference manual
   8.555 +        included in the distribution.
   8.556 +
   8.557 +        The following API routines are deprecated:
   8.558 +        lpx_read_mps, lpx_read_freemps, lpx_write_mps,
   8.559 +        lpx_write_freemps, lpx_read_cpxlp, and lpx_write_cpxlp.
   8.560 +
   8.561 +        Two bugs were fixed. Thanks to
   8.562 +        Anne-Laurence Putz <anne-laurence.putz@eurodecision.com> and
   8.563 +        Xypron <xypron.glpk@gmx.de> for bug report.
   8.564 +
   8.565 +GLPK 4.28 (release date: Mar 25, 2008)
   8.566 +
   8.567 +        The iODBC and MySQL table drivers, which allows transmitting
   8.568 +        data between MathProg model objects and relational databases,
   8.569 +        were re-implemented to replace a static linking by a dynamic
   8.570 +        linking to corresponding shared libraries.
   8.571 +        Many thanks to Heinrich Schuchardt <heinrich.schuchardt@gmx.de>
   8.572 +        for the contribution, Rafael Laboissiere <rafael@debian.org>
   8.573 +        for useful advices concerning the shared library support under
   8.574 +        GNU/Linux, and Vijay Patil <vijay.patil@gmail.com> for testing
   8.575 +        this feature under Windows XP.
   8.576 +
   8.577 +        A new optional feature was added to the package. This feature
   8.578 +        is based on the zlib data compression library and allows GLPK
   8.579 +        API routines and the stand-alone solver to read and write
   8.580 +        compressed data files performing compression/decompression "on
   8.581 +        the fly" (compressed data files are recognized by suffix `.gz'
   8.582 +        in the file name). It may be useful in case of large MPS files
   8.583 +        to save the disk space (up to ten times).
   8.584 +
   8.585 +        The `configure' script was re-implemented. Now it supports the
   8.586 +        following specific options:
   8.587 +
   8.588 +        --with-gmp           Enable using the GNU MP bignum library
   8.589 +        --without-gmp        Disable using the GNU MP bignum library
   8.590 +        --with-zlib          Enable using the zlib data compression
   8.591 +                             library
   8.592 +        --without-zlib       Disable using the zlib data compression
   8.593 +                             library
   8.594 +        --enable-dl          Enable shared library support (auto check)
   8.595 +        --enable-dl=ltdl     Enable shared library support (GNU)
   8.596 +        --enable-dl=dlfcn    Enable shared library support (POSIX)
   8.597 +        --disable-dl         Disable shared library support
   8.598 +        --enable-odbc        Enable using ODBC table driver
   8.599 +        --disable-odbc       Disable using ODBC table driver
   8.600 +        --enable-mysql       Enable using MySQL table driver
   8.601 +        --disable-mysql      Disable using MySQL table driver
   8.602 +
   8.603 +        For more details please see file INSTALL.
   8.604 +
   8.605 +GLPK 4.27 (release date: Mar 02, 2008)
   8.606 +
   8.607 +        Three new table drivers were added to the MathProg translator:
   8.608 +
   8.609 +        xBASE built-in table driver, which allows reading and writing
   8.610 +        data in .dbf format (only C and N fields are supported);
   8.611 +
   8.612 +        MySQL table driver, which provides connection to a MySQL
   8.613 +        database;
   8.614 +
   8.615 +        iODBC table driver, which provides connection to a database
   8.616 +        through ODBC.
   8.617 +
   8.618 +        The MySQL and iODBC table drivers were contributed to GLPK by
   8.619 +        Heinrich Schuchardt <heinrich.schuchardt@gmx.de>.
   8.620 +
   8.621 +        The table driver is a program module which allows transmitting
   8.622 +        data between MathProg model objects and external data tables.
   8.623 +
   8.624 +        For detailed description of the table statement and table
   8.625 +        drivers see the document "Using Data Tables in the GNU MathProg
   8.626 +        Modeling Language" (file doc/tables.txt) included in the
   8.627 +        distribution. Some examples which demonstrate using MySQL and
   8.628 +        iODBC table drivers can be found in subdirectory examples/sql.
   8.629 +
   8.630 +GLPK 4.26 (release date: Feb 17, 2008)
   8.631 +
   8.632 +        The table statement was implemented in the GNU MathProg
   8.633 +        modeling language. This new feature allows reading data from
   8.634 +        external tables into model objects such as sets and parameters
   8.635 +        as well as writing results of computations to external tables.
   8.636 +
   8.637 +        A table is a (unordered) set of records, where each record
   8.638 +        consists of the same number of fields, and each field is
   8.639 +        provided with a unique symbolic name called the field name.
   8.640 +
   8.641 +        Currently the GLPK package has the only built-in table driver,
   8.642 +        which supports tables in the CSV (comma-separated values) file
   8.643 +        format. This format is very simple and supported by almost all
   8.644 +        spreadsheets and database management systems.
   8.645 +
   8.646 +        Detailed description of the table statement and CSV format can
   8.647 +        be found in file doc/tables.txt, included in the distribution.
   8.648 +
   8.649 +GLPK 4.25 (release date: Dec 19, 2007)
   8.650 +
   8.651 +        A tentative implementation of Gomory's mixed integer cuts was
   8.652 +        included in the branch-and-cut solver. To enable generating
   8.653 +        Gomory's cuts the control parameter gmi_cuts passed to the
   8.654 +        routine glp_intopt should be set to GLP_ON. This feature is
   8.655 +        also available in the solver glpsol through command-line option
   8.656 +        '--gomory'. For more details please see the reference manual
   8.657 +        included in the distribution.
   8.658 +
   8.659 +GLPK 4.24 (release date: Nov 21, 2007)
   8.660 +
   8.661 +        A tentative implementation of MIR (mixed integer rounding) cuts
   8.662 +        was included in the MIP solver. To enable generating MIR cuts
   8.663 +        the control parameter mir_cuts passed to the routine glp_intopt
   8.664 +        should be set to GLP_ON. This feature is also available in the
   8.665 +        stand-alone solver glpsol via command-line option '--mir'. For
   8.666 +        more details please see the reference manual included in the
   8.667 +        distribution.
   8.668 +
   8.669 +        The implementation is mainly based on the following two papers:
   8.670 +
   8.671 +        1. H. Marchand and L. A. Wolsey. Aggregation and mixed integer
   8.672 +           rounding to solve MIPs. CORE discussion paper 9839, CORE,
   8.673 +           Universite catholique de Louvain, June 1998.
   8.674 +
   8.675 +        2. G. Andreello, A. Caprara, and M. Fischetti. Embedding cuts
   8.676 +           in a Branch&Cut framework. Preliminary draft, October 2003.
   8.677 +
   8.678 +        MIR cuts can be generated on any level of the search tree that
   8.679 +        makes the GLPK MIP solver to be a real branch-and-cut solver.
   8.680 +
   8.681 +        A bug was fixed in the routine lpx_write_cpxlp. If a variable
   8.682 +        x has upper bound and no lower bound, it should appear in the
   8.683 +        bounds section as "-inf <= x <= u", not as "x <= u". Thanks to
   8.684 +        Enric Rodriguez <erodri@lsi.upc.edu> for the bug report.
   8.685 +
   8.686 +GLPK 4.23 (release date: Oct 28, 2007)
   8.687 +
   8.688 +        The following new API routines were added:
   8.689 +
   8.690 +        glp_read_sol    read basic solution from text file
   8.691 +        glp_write_sol   write basic solution to text file
   8.692 +        glp_read_ipt    read interior-point solution from text file
   8.693 +        glp_write_ipt   write interior-point solution to text file
   8.694 +        glp_read_mip    read MIP solution from text file
   8.695 +        glp_write_mip   write MIP solution to text file
   8.696 +
   8.697 +        For description of these routines and corresponding file
   8.698 +        formats see Chapter "API Routines", Section "Utility routines"
   8.699 +        in the reference manual included in the distribution.
   8.700 +
   8.701 +        Advanced API routine glp_free_env was added. It may be used by
   8.702 +        the application program to free all resources allocated by GLPK
   8.703 +        routines.
   8.704 +
   8.705 +        The following three new command-line options were added to the
   8.706 +        solver glpsol:
   8.707 +
   8.708 +        --mipgap tol    set relative MIP gap tolerance
   8.709 +        -r filename     read solution from filename
   8.710 +        -w filename     write solution to filename
   8.711 +
   8.712 +GLPK 4.22 (release date: Sep 19, 2007)
   8.713 +
   8.714 +        This is a maintainer release.
   8.715 +
   8.716 +        A bug was fixed in the MIP preprocessor (ios_preprocess_node).
   8.717 +        Thanks to Roberto Bagnara <bagnara@cs.unipr.it> (Department of
   8.718 +        Mathematics, University of Parma, Italy) for the bug report.
   8.719 +
   8.720 +        A bug was fixed in the MIP preprocessor (col_implied_bounds),
   8.721 +        due to which constraint coefficients with small magnitude could
   8.722 +        lead to wrong implied bounds of structural variables.
   8.723 +
   8.724 +        A similar bug was fixed in the routine reduce_bounds.
   8.725 +
   8.726 +        A bug was fixed in the routines glp_set_mat_row and
   8.727 +        glp_set_mat_col. (The bug appeared due to incorrect removing
   8.728 +        zero elements from the row/column lists.)
   8.729 +
   8.730 +        A bug was fixed in the API routines lpx_read_mps and
   8.731 +        lpx_read_freemps, due to which bounds of type LI specified in
   8.732 +        BOUNDS section were incorrectly processed.
   8.733 +
   8.734 +        A call to standard function vsprintf was replaced by a call to
   8.735 +        vsnprintf for security reasons. Many thanks to Peter T. Breuer
   8.736 +        <ptb@inv.it.uc3m.es> and Rafael Laboissiere <rafael@debian.org>.
   8.737 +
   8.738 +GLPK 4.21 (release date: Aug 28, 2007)
   8.739 +
   8.740 +        Additional reasons for calling the callback routine used in the
   8.741 +        MIP solver (glp_intopt) were introduced. Currently the following
   8.742 +        reasons are supported:
   8.743 +
   8.744 +        * request for subproblem selection
   8.745 +        * request for preprocessing
   8.746 +        * request for row generation
   8.747 +        * request for heuristic solution
   8.748 +        * request for cut generation
   8.749 +        * request for branching
   8.750 +        * better integer solution found
   8.751 +
   8.752 +        A basic preprocessing component used to improve subproblem
   8.753 +        formulations by tightening bounds of variables was included in
   8.754 +        the MIP solver. Depending on the control parameter pp_tech
   8.755 +        passed to the routine glp_intopt the preprocessing can be
   8.756 +        performed either on the root level or on all levels (default)
   8.757 +        or can be disabled.
   8.758 +
   8.759 +        Backtracking heuristic used by default in the MIP solver was
   8.760 +        changed to the "best local bound".
   8.761 +
   8.762 +        For more details see Chapter "Advanced API routines", Section
   8.763 +        "Branch-and-bound interface routines" in a new edition of the
   8.764 +        reference manual included in the distribution.
   8.765 +
   8.766 +GLPK 4.20 (release date: Jul 26, 2007)
   8.767 +
   8.768 +        API routine lpx_integer was replaced by API routine glp_intopt,
   8.769 +        which provides equivalent functionality and additionally allows
   8.770 +        the application to control the solution process by means of the
   8.771 +        user-written callback routine, which is called by the solver at
   8.772 +        various points of the branch-and-bound algorithm. Besides, the
   8.773 +        new MIP solver allows generating "lazy" constraints and cutting
   8.774 +        planes on all levels of the branch-and-bound tree, not only on
   8.775 +        the root level. The routine lpx_integer is also still available
   8.776 +        for the backward compatibility.
   8.777 +
   8.778 +        The following new advanced API routines, which may be called
   8.779 +        from the B&B callback routine, were included in the package:
   8.780 +
   8.781 +        glp_ios_reason     determine reason for calling callback
   8.782 +                           routine
   8.783 +        glp_ios_get_prob   access the problem object
   8.784 +        glp_ios_tree_size  determine size of the branch-and-bound tree
   8.785 +        glp_ios_curr_node  determine current active subproblem
   8.786 +        glp_ios_next_node  determine next active subproblem
   8.787 +        glp_ios_prev_node  determine previous active subproblem
   8.788 +        glp_ios_up_node    determine parent subproblem
   8.789 +        glp_ios_node_level determine subproblem level
   8.790 +        glp_ios_node_bound determine subproblem local bound
   8.791 +        glp_ios_mip_gap    compute relative MIP gap
   8.792 +        glp_ios_heur_sol   provide solution found by heuristic
   8.793 +        glp_ios_terminate  terminate the solution process
   8.794 +
   8.795 +        For description of these routines see Chapter "Advanced API
   8.796 +        routines", Section "Branch-and-bound interface routines" in a
   8.797 +        new edition of the reference manual, which was included in the
   8.798 +        distribution.
   8.799 +
   8.800 +        Old version of the integer optimization suite (IOS) as well as
   8.801 +        TSP solver tspsol based on it are no longer supported and were
   8.802 +        removed from the package.
   8.803 +
   8.804 +        A minor error in the MIP presolver was fixed; thanks to Graham
   8.805 +        Rockwell <bionomicron@gmail.com> for the bug report.
   8.806 +
   8.807 +GLPK 4.19 (release date: Jul 05, 2007)
   8.808 +
   8.809 +        The principal change is upgrading to GPLv3.
   8.810 +
   8.811 +        A serious bug in the routine glp_del_cols was fixed; thanks to
   8.812 +        Cedric[FR] <fox2113@wanadoo.fr> for the bug report. The bug
   8.813 +        appeared because on deleting non-basic columns the basis header
   8.814 +        remained valid, however, contained invalid (old) column ordinal
   8.815 +        numbers.
   8.816 +
   8.817 +        A new advanced API routine glp_mem_limit was added.
   8.818 +
   8.819 +        The case GLP_EBOUND was added to the routine lpx_simplex.
   8.820 +        Thanks to Cameron Kellough <Cameron.Kellough@sri.com> for the
   8.821 +        bug report.
   8.822 +
   8.823 +        An API routine lpx_write_pb to write the problem instance in
   8.824 +        OPB (pseudo boolean) format format was added. Thanks to Oscar
   8.825 +        Gustafsson <oscarg@isy.liu.se> for the contribution.
   8.826 +
   8.827 +        Two new options --wpb and --wnpb were added to glpsol to write
   8.828 +        the problem instance in OPB format.
   8.829 +
   8.830 +GLPK 4.18 (release date: Jun 25, 2007)
   8.831 +
   8.832 +        The following new API routines were added:
   8.833 +
   8.834 +        glp_set_rii        set (change) row scale factor
   8.835 +        glp_set_sjj        set (change) column scale factor
   8.836 +        glp_get_rii        retrieve row scale factor
   8.837 +        glp_get_sjj        retrieve column scale factor
   8.838 +        glp_simplex        solve LP problem with the simplex method
   8.839 +                           (this routine replaces lpx_simplex, which is
   8.840 +                           also available for backward compatibility)
   8.841 +        glp_init_smcp      initialize simplex method control params
   8.842 +        glp_bf_exists      check if the basis factorization exists
   8.843 +        glp_factorize      compute the basis factorization
   8.844 +        glp_bf_updated     check if the basis factorization has been
   8.845 +                           updated
   8.846 +        glp_get_bfcp       retrieve basis factorization control params
   8.847 +        glp_set_bfcp       change basis factorization control params
   8.848 +        glp_get_bhead      retrieve the basis header information
   8.849 +        glp_get_row_bind   retrieve row index in the basis header
   8.850 +        glp_get_col_bind   retrieve column index in the basis header
   8.851 +        glp_ftran          perform forward transformation
   8.852 +        glp_btran          perform backward transformation
   8.853 +
   8.854 +        For description of all these routines see a new edition of the
   8.855 +        reference manual included in the distribution.
   8.856 +
   8.857 +        Type names ulong_t and uldiv_t were changed to glp_ulong and
   8.858 +        glp_uldiv to avoid conflicts with standard type names on some
   8.859 +        platforms. Thanks to Boris Wirtz <Boris.Wirtz@uni-oldenburg.de>
   8.860 +        for the bug report.
   8.861 +
   8.862 +        Some new examples in the MathProg language were added. Thanks
   8.863 +        to Sebastian Nowozin <nowozin@gmail.com>.
   8.864 +
   8.865 +GLPK 4.17 (release date: May 26, 2007)
   8.866 +
   8.867 +        API routines glp_set_mat_row, glp_set_mat_col, and glp_load_mat
   8.868 +        were modified to allow zero constraint coefficients (which are
   8.869 +        not stored in the constraint matrix). Note that constraint
   8.870 +        coefficients with duplicate row/column indices are not allowed.
   8.871 +
   8.872 +        Another form of LP basis factorization was implemented in the
   8.873 +        package. It is based on LU-factorization of an initial basis
   8.874 +        and Schur complement to reflect changes in the basis. Currently
   8.875 +        the implementation is incomplete and provides only updating the
   8.876 +        factorization on replacing a column of the basis matrix. On API
   8.877 +        level the user can set the control parameter LPX_K_BFTYPE to
   8.878 +        choose between the folloiwng forms of LP basis factorization to
   8.879 +        be used in the simplex method routines:
   8.880 +        1) LU + Forrest-Tomlin update;
   8.881 +        2) LU + Schur complement + Bartels-Golub update;
   8.882 +        3) LU + Schur complement + Givens rotation update.
   8.883 +        The GLPK implementation is similar to LUSOL/LUMOD developed by
   8.884 +        Michael A. Saunders.
   8.885 +
   8.886 +        The user can choose the form of LP basis factorzation used by
   8.887 +        the simplex method routines by specifying the folloiwng options
   8.888 +        of glpsol: --luf, --cbg, --cgr.
   8.889 +
   8.890 +GLPK 4.16 (release date: May 05, 2007)
   8.891 +
   8.892 +        A number of basic GLPK API routines, which now are in the
   8.893 +        stable stable, were renamed to be prefixed with 'glp_'. Note
   8.894 +        that all these routines are available via their old names
   8.895 +        prefixed with 'lpx_' that keeps the downward compatibility with
   8.896 +        older versions of the package.
   8.897 +
   8.898 +        Three new GLPK API routines were added to the package:
   8.899 +        glp_version, glp_term_hook, and glp_mem_usage; for more details
   8.900 +        see a new edition of the GLPK reference manual included in the
   8.901 +        distribution. The routine glp_version reports the actual version
   8.902 +        of the GLPK library and also can be used (along with the header
   8.903 +        glpk.h) in Autotools specification files to check if the GLPK
   8.904 +        library has been installed.
   8.905 +
   8.906 +        The header glpk.h was changed to conform to C++ environment.
   8.907 +
   8.908 +GLPK 4.15 (release date: Feb 18, 2007)
   8.909 +
   8.910 +        Autotools specification files (configure.ac, Makefile.am) were
   8.911 +        changed to use GNU Libtool. This allows building the static as
   8.912 +        well as shared GLPK library.
   8.913 +
   8.914 +GLPK 4.14 (release date: Feb 05, 2007)
   8.915 +
   8.916 +        Now GLPK conforms to ILP32, LLP64, and LP64 programming models
   8.917 +        (the latter seems to be the ultimate choice regarding 64-bit
   8.918 +        architectures). Note that GLPK itself is a 32-bit application,
   8.919 +        and the conformity only means that the package works correctly
   8.920 +        on all these arenae. Nevertheless, on 64-bit platforms it is
   8.921 +        possible to use more than 4GB of memory, if necessary.
   8.922 +
   8.923 +GLPK 4.13 (release date: Nov 13, 2006)
   8.924 +
   8.925 +        A tentative implementation of the "exact" simplex method based
   8.926 +        on bignum (rational) arithmetic was included in the package.
   8.927 +
   8.928 +        On API level this new feature is available through the routine
   8.929 +        lpx_exact, which is similar to the routine lpx_simplex.
   8.930 +
   8.931 +        In the solver glpsol this feature is available through two new
   8.932 +        command-line options: --exact and --xcheck. If the '--exact'
   8.933 +        option is specified, glpsol solves LP instance using the exact
   8.934 +        simplex method; in case of MIP it is used to obtain optimal
   8.935 +        solution of LP relaxation. If the --xcheck option is specified,
   8.936 +        LP instance (or LP relaxation) is solved using the standard
   8.937 +        (floating-point) simplex method, however, then glpsol calls the
   8.938 +        exact simplex routine to make sure that the final LP basis is
   8.939 +        exactly optimal, and if it is not, to perform some additional
   8.940 +        simplex iterations in exact arithmetic.
   8.941 +
   8.942 +GLPK 4.12 (release date: Nov 08, 2006)
   8.943 +
   8.944 +        A tentative implementation of some simplex method routines
   8.945 +        based on exact (bignum) arithmetic was included in the package.
   8.946 +        Currently these routines provide computing LU-factorization of
   8.947 +        the basis matrix and computing components of basic solution.
   8.948 +
   8.949 +        These routines were used to implement a routine, which checks
   8.950 +        primal and dual feasibility of basic solution exactly, i.e. in
   8.951 +        rational numbers, without round-off errors. In glpsol this
   8.952 +        feature is available through the command-line option --xcheck.
   8.953 +
   8.954 +        GLPK has its own low-level routines implementing operations on
   8.955 +        integer and rational numbers that makes it independent on other
   8.956 +        software packages. However, to attain a much better performance
   8.957 +        it is highly recommended to install (before configuring GLPK)
   8.958 +        the GNU Multiple Precision Arithmetic Library (GMP). Using GMP
   8.959 +        makes computations 100-200 times faster.
   8.960 +
   8.961 +GLPK 4.11 (release date: Jul 25, 2006)
   8.962 +
   8.963 +        Three new built-in functions in the modeling language were
   8.964 +        implemented: card (cardinality of set), length (length of
   8.965 +        character string), and substr (substring of character string).
   8.966 +        Another improvement concerns the printf statement which now
   8.967 +        allows redirecting its output to a specified file. These new
   8.968 +        features are illustrated in example models crypto.mod and
   8.969 +        graph.mod included in the distribution. For more details see
   8.970 +        the document "Modeling Language GNU MathProg".
   8.971 +
   8.972 +        Four batch files (along with corresponding makefiles) were
   8.973 +        included in the distribution to simplify building GLPK under
   8.974 +        MS Windows; see them in subdirectory 'w32'.
   8.975 +
   8.976 +GLPK 4.10 (release date: May 11, 2006)
   8.977 +
   8.978 +        Cutting planes of two new classes were implemented: mixed cover
   8.979 +        cuts and clique cuts. On API level this feature can be enabled
   8.980 +        by setting control parameter LPX_K_USECUTS passed to the routine
   8.981 +        lpx_intopt. In glpsol this feature is available through the
   8.982 +        command-line options --cover and --clique. For more details see
   8.983 +        the reference manual.
   8.984 +
   8.985 +        Now the routines lpx_read_mps and lpx_read_freemps support LI
   8.986 +        bound type. It is similar to LO, however, indicates the column
   8.987 +        as of integer kind.
   8.988 +
   8.989 +GLPK 4.9 (release date: Jan 17, 2006)
   8.990 +
   8.991 +        An advanced MIP solver was implemented. It includes:
   8.992 +
   8.993 +        - basic presolving technique (removing free, singleton and
   8.994 +          redundant rows, improving bounds of columns, removing fixed
   8.995 +          columns, reducing constraint coefficents);
   8.996 +
   8.997 +        - generating cutting planes to improve LP relaxation (currently
   8.998 +          only Gomory's mixed integer cuts are implemented);
   8.999 +
  8.1000 +        - using the branch-and-bound method to solve resultant MIP;
  8.1001 +
  8.1002 +        - recovering solution of the original MIP.
  8.1003 +
  8.1004 +        The solver is available on API level via the routine lpx_intopt
  8.1005 +        (see the reference manual). It is similar to the routine
  8.1006 +        lpx_integer, however, does not require initial solution of LP
  8.1007 +        relaxation.
  8.1008 +
  8.1009 +        The solver is also available in the command-line utility glpsol
  8.1010 +        via two options: --intopt (only presolving) and --cuts (assumes
  8.1011 +        --intopt plus generating cuts).
  8.1012 +
  8.1013 +        Note that efficiency of the MIP solver strongly depends on the
  8.1014 +        internal structure of the problem to be solved. For some hard
  8.1015 +        instances it is very efficient, but for other instances it may
  8.1016 +        be significantly worse than the standard branch-and-bound.
  8.1017 +
  8.1018 +        For some comparative benchmarks see doc/bench1.txt.
  8.1019 +
  8.1020 +        Well, what else...
  8.1021 +
  8.1022 +        Three built-in functions were added to MathProg: sin, cos, and
  8.1023 +        atan (the latter allows one or two arguments).
  8.1024 +
  8.1025 +        Some bugs were fixed.
  8.1026 +
  8.1027 +        Several new examples in MathProg were included: color.mod
  8.1028 +        (graph coloring problem), tsp.mod (traveling salesman problem),
  8.1029 +        and pbn.mod (paint-by-numbers puzzle).
  8.1030 +
  8.1031 +GLPK 4.8 (release date: Jan 12, 2005)
  8.1032 +
  8.1033 +        Core simplex method and interior-point method routines were
  8.1034 +        re-implemented and now they use a new, "storage-by-rows" sparse
  8.1035 +        matrix format (unlike previous versions where linked lists were
  8.1036 +        used to represent sparse matrices). For details see ChangeLog.
  8.1037 +
  8.1038 +        Also a minor bug was fixed in API routine lpx_read_cpxlp.
  8.1039 +
  8.1040 +GLPK 4.7 (release date: Aug 23, 2004)
  8.1041 +
  8.1042 +        Now GLPK supports free MPS format. Two new API routines
  8.1043 +        lpx_read_freemps (to read problem data in free MPS format) and
  8.1044 +        lpx_write_freemps (to write problem data in free MPS format)
  8.1045 +        were added. This feature is also available in the solver glpsol
  8.1046 +        via new command-line options --freemps and --wfreemps. For more
  8.1047 +        details see the GLPK reference manual.
  8.1048 +
  8.1049 +        API routines lpx_read_cpxlp and lpx_write_cpxlp for reading and
  8.1050 +        writing problem data in CPLEX LP format were re-implemented to
  8.1051 +        allow long symbolic names (up to 255 characters).
  8.1052 +
  8.1053 +        The following three modules were temporarily removed from the
  8.1054 +        GLPK distribution due to licensing problems: DELI (an interface
  8.1055 +        module to Delphi), GLPKMEX (an interface module to Matlab), and
  8.1056 +        JNI (an interface module to Java).
  8.1057 +
  8.1058 +GLPK 4.6 (release date: Aug 04, 2004)
  8.1059 +
  8.1060 +        Three new statements were implemented in the GNU MathProg
  8.1061 +        language: solve, printf, and for. Their detailed description can
  8.1062 +        be found in the GLPK documentation included in the distribution.
  8.1063 +        (See also a sample model, examples/queens.mod, which illustrates
  8.1064 +        using these new statements.)
  8.1065 +
  8.1066 +        Two new API routines were added to the package: lpx_read_prob
  8.1067 +        and lpx_write_prob. They allow reading/writing problem data in
  8.1068 +        GNU LP low-level text format.
  8.1069 +
  8.1070 +        Three new command-line options were implemented in the LP/MIP
  8.1071 +        solver glpsol: --glp (to read problem data in GNU LP format),
  8.1072 +        --wglp (to write problem data in GNU LP format), and --name (to
  8.1073 +        change problem name). Now glpsol also supports processing models
  8.1074 +        where the new statements (see above) are used.
  8.1075 +
  8.1076 +        A new version of GLPKMEX, a Matlab MEX interface to GLPK, was
  8.1077 +        included. For more details see contrib/glpkmex/ChangeLog.
  8.1078 +
  8.1079 +GLPK 4.5 (release date: Jul 19, 2004)
  8.1080 +
  8.1081 +        The branch-and-bound solver was completely re-implemented.
  8.1082 +
  8.1083 +        Some modifications were made in memory allocation routines that
  8.1084 +        allows using the package on 64-bit platforms.
  8.1085 +
  8.1086 +        For more details see ChangeLog.
  8.1087 +
  8.1088 +GLPK 4.4 (release date: Jan 17, 2004)
  8.1089 +
  8.1090 +        All API routines were re-implemented using new data structures.
  8.1091 +        The new implementation provides the same specifications and
  8.1092 +        functionality of API routines as the old one, however, it has
  8.1093 +        some important advantages, in particular:
  8.1094 +        * linked lists are used everywhere that allows creating and
  8.1095 +          modifying the problem object as efficiently as possible
  8.1096 +        * all data stored in the problem object are non-scaled (even if
  8.1097 +          the internal scaling is used) that prevents distortion of the
  8.1098 +          original problem data
  8.1099 +        * solution components obtained by the solver remain available
  8.1100 +          even if the problem object has been modified
  8.1101 +        * no solver-specific data are used in the new data structures
  8.1102 +          that allows attaching any external lp/mip solver using GLPK
  8.1103 +          API as an uniform interface
  8.1104 +        Note that some API routines became obsolete being replaced by
  8.1105 +        new, more convenient routines. These obsolete routines are kept
  8.1106 +        for backward compatibility, however, they will be removed in
  8.1107 +        the future. For more details please see ChangeLog and the GLPK
  8.1108 +        Reference Manual.
  8.1109 +
  8.1110 +        New edition of the GLPK Reference Manual was included in the
  8.1111 +        distribution.
  8.1112 +
  8.1113 +        GLPKMEX, a Matlab MEX interface to GLPK package, contributed by
  8.1114 +        Nicolo Giorgetti <giorgetti@dii.unisi.it> was included in the
  8.1115 +        distribution.
  8.1116 +
  8.1117 +        GLPK FAQ contributed by Harley Mackenzie <hjm@bigpond.com> was
  8.1118 +        included in the distribution.
  8.1119 +
  8.1120 +GLPK 4.3 (release date: Dec 12, 2003)
  8.1121 +
  8.1122 +        The bug, due to which the standard math library is not linked
  8.1123 +        on building the package on some platforms, was fixed.
  8.1124 +
  8.1125 +        The following new built-in functions were added to the MathProg
  8.1126 +        language: round, trunc, Irand224, Uniform01, Uniform, Normal01,
  8.1127 +        Normal. For details see the language description.
  8.1128 +
  8.1129 +        The MathProg syntax was changed to allow writing 'subj to' that
  8.1130 +        means 'subject to'.
  8.1131 +
  8.1132 +        The new api routine lpx_get_ray_info was added. It is intended
  8.1133 +        to determine which (non-basic) variable causes unboundness. For
  8.1134 +        details see the reference manual.
  8.1135 +
  8.1136 +        The module glpmps.c was changed to avoid compilation errors on
  8.1137 +        building the package on Mac OS X.
  8.1138 +
  8.1139 +        Several typos was fixed and some new material was added to the
  8.1140 +        GLPK documentation.
  8.1141 +
  8.1142 +GLPK 4.2 (release date: Nov 14, 2003)
  8.1143 +
  8.1144 +        A preliminary implementation of the Integer Optimization Suite
  8.1145 +        (IOS) was included in the package. The Branch-and-Cut Framework
  8.1146 +        being completely superseded by IOS was removed from the package.
  8.1147 +
  8.1148 +        New API routine lpx_print_sens_bnds intended for bounds
  8.1149 +        sensitivity analysis was contributed to GLPK by Brady Hunsaker
  8.1150 +        <hunsaker@engr.pitt.edu>. This function is also available in
  8.1151 +        the solver glpsol (via command-line option --bounds).
  8.1152 +
  8.1153 +        An improved version of GLPK JNI (Java Native Interface) was
  8.1154 +        contributed by Chris Rosebrugh <cpr@pobox.com>.
  8.1155 +
  8.1156 +        GLPK DELI (Delphi Interface) was contributed by Ivo van Baren
  8.1157 +        <i.van.baren@freeler.nl>.
  8.1158 +
  8.1159 +        Several makefiles were added to allow compiling GLPK on some
  8.1160 +        non-GNU 32-bit platforms:
  8.1161 +        * Windows single-threaded static library, Visual C++ 6.0
  8.1162 +        * Windows multi-threaded dynamic library, Visual C++ 6.0
  8.1163 +        * Windows single-threaded static library, Borland C++ 5.2
  8.1164 +        * DOS single-threaded static library, Digital Mars C++ 7.50
  8.1165 +
  8.1166 +        And, of course, some bugs were fixed.
  8.1167 +
  8.1168 +        For more details see ChangeLog.
  8.1169 +
  8.1170 +GLPK 4.1 (release date: Aug 23, 2003)
  8.1171 +
  8.1172 +        Some improvements were made in the lp/mip solver routines and
  8.1173 +        several bugs were fixed in the model translator.
  8.1174 +
  8.1175 +        For more details see ChangeLog.
  8.1176 +
  8.1177 +GLPK 4.0 (release date: May 06, 2003)
  8.1178 +
  8.1179 +        Now GLPK supports the GNU MathProg modeling language, which is
  8.1180 +        a subset of the AMPL modeling language.
  8.1181 +
  8.1182 +        The document "GLPK: Modeling Language GNU MathProg" included in
  8.1183 +        the distribution is a complete description of GNU MathProg. (See
  8.1184 +        the files lang.latex, lang.dvi, and lang.ps in the subdirectory
  8.1185 +        'doc'. See also some examples in the subdirectory 'sample'.)
  8.1186 +
  8.1187 +        New version of the solver glpsol, which supports models written
  8.1188 +        in GNU MathProg, was implemented. (Brief instructions how to use
  8.1189 +        glpsol can be found in the GNU MathProg documentation.)
  8.1190 +
  8.1191 +        The GLPK/L modeling language is no more supported. The reason is
  8.1192 +        that GNU MathProg being much more powerful completely supersedes
  8.1193 +        all features of GLPK/L.
  8.1194 +
  8.1195 +GLPK 3.3 (release date: Mar 25, 2003)
  8.1196 +
  8.1197 +        LP PRESOLVER
  8.1198 +        ------------
  8.1199 +
  8.1200 +        Now the routine lpx_simplex (which is a driver to the simplex
  8.1201 +        method for solving LP) is provided with the built-in LP
  8.1202 +        presolver, which is a program that transforms the original LP
  8.1203 +        problem to an equivalent LP problem, which may be easier for
  8.1204 +        solving with the simplex method than the original one. Once the
  8.1205 +        transformed LP has been solver, the presolver transforms its
  8.1206 +        basic solution back to a corresponding basic solution of the
  8.1207 +        original problem. For details about this feature please see the
  8.1208 +        GLPK reference manual.
  8.1209 +
  8.1210 +        Currently the LP presolver implements the following features:
  8.1211 +        * removing empty rows;
  8.1212 +        * removing empty columns;
  8.1213 +        * removing free rows;
  8.1214 +        * removing fixed columns;
  8.1215 +        * removing row singletons, which have the form of equations;
  8.1216 +        * removing row singletons, which have the form of inequalities;
  8.1217 +        * removing column singletons, which are implied slack variables;
  8.1218 +        * fixing and removing column singletons, which are implied free
  8.1219 +          variables;
  8.1220 +        * removing forcing rows that involves fixing and removing the
  8.1221 +          corresponding columns;
  8.1222 +        * checking for primal and dual infeasibilities.
  8.1223 +
  8.1224 +        The LP presolver is also used by default in the stand-alone
  8.1225 +        program glpsol. In order *not* to use it, the option --nopresol
  8.1226 +        should be specified in the command-line.
  8.1227 +
  8.1228 +        CHANGES IN GLPK/L
  8.1229 +        -----------------
  8.1230 +
  8.1231 +        The syntax and semantics of the GLPK/L modeling language was
  8.1232 +        changed to allow declaration of "interval" sets. This means that
  8.1233 +        now the user can declare a set, for example, as:
  8.1234 +
  8.1235 +           set task = [8:11];
  8.1236 +
  8.1237 +        that is exactly equivalent to the following declaration:
  8.1238 +
  8.1239 +           set task = (task_8, task_9, task_10, task_11);
  8.1240 +
  8.1241 +        For details see the language description.
  8.1242 +
  8.1243 +        JAVA INTERFACE
  8.1244 +        --------------
  8.1245 +
  8.1246 +        Now GLPK includes the package GLPK JNI (Java Native Interface)
  8.1247 +        that implements Java binding for GLPK. It allows Java programs
  8.1248 +        to utilize GLPK in solving LP and MIP problems. For details see
  8.1249 +        a brief user's guide in the subdirectory contrib/java-binding.
  8.1250 +        This package was developed and programmed by Yuri Victorovich
  8.1251 +        <yuri@gjt.org>, who contributed it to GLPK.
  8.1252 +
  8.1253 +GLPK 3.2.4 (release date: Feb 18, 2003)
  8.1254 +
  8.1255 +        This is a bug-fix release. For details see ChangeLog.
  8.1256 +
  8.1257 +GLPK 3.2.3 (release date: Nov 11, 2002)
  8.1258 +
  8.1259 +        A new implementation of the api routine lpx_integer which now
  8.1260 +        is based on the b&b driver (which is based on the implicit
  8.1261 +        enumeration suite) was included in the package. This new
  8.1262 +        implementation has exactly the same functionality as the old
  8.1263 +        version, so all changes are transparent to the api user.
  8.1264 +
  8.1265 +        Four new api routines were included in the package:
  8.1266 +        lpx_check_kkt checks Karush-Kuhn-Tucker optmality conditions;
  8.1267 +        lpx_read_bas reads predifined basis in MPS format;
  8.1268 +        lpx_write_bas writes current basis in MPS format;
  8.1269 +        lpx_write_lpt writes problem data in CPLEX LP format.
  8.1270 +
  8.1271 +        Also other minor improvements were made (for details see the
  8.1272 +        file 'ChangeLog').
  8.1273 +
  8.1274 +GLPK 3.2.2 (release date: Oct 14, 2002)
  8.1275 +
  8.1276 +        The api routine lpx_read_lpt was included in the package. It
  8.1277 +        is similar to the routine lpx_read_mps and intended to read
  8.1278 +        LP/MIP data prepared in CPLEX LP format. Description of this
  8.1279 +        format is given in the GLPK reference manual, a new edition of
  8.1280 +        which was also included in the distribution (see the files
  8.1281 +        'refman.latex', 'refman.dvi', 'refman.ps' in the subdirectory
  8.1282 +        'doc'). In order to use data files in CPLEX LP format with the
  8.1283 +        solver glpsol the option '--lpt' should be specified in the
  8.1284 +        command line.
  8.1285 +
  8.1286 +        Several bugs were fixed and some minor improvements were made
  8.1287 +        (for details see the file 'ChangeLog').
  8.1288 +
  8.1289 +GLPK 3.2.1 (release date: Aug 12, 2002)
  8.1290 +
  8.1291 +        Now GLPK includes a preliminary implementation of the
  8.1292 +        branch-and-cut framework, which is a set of data structures and
  8.1293 +        routines intended for developing branch-and-cut methods for
  8.1294 +        solving mixed-integer and combinatorial optimization problems.
  8.1295 +
  8.1296 +        Detailed decsription of the branch-and-cut framework is given in
  8.1297 +        the document "GLPK: A Preliminary Implementation of the
  8.1298 +        Branch-And-Cut Framework" included in the distribution (see the
  8.1299 +        file 'brcut.txt' in the subdirectory 'doc').
  8.1300 +
  8.1301 +        In order to illustrate how the GLPK branch-and-cut framework
  8.1302 +        can be used for solving a particular optimization problem there
  8.1303 +        is an example included in the package. This is a stand-alone
  8.1304 +        program, TSPSOL, which is intended for solving to optimality the
  8.1305 +        symmetric Traveling Salesman Problem (TSP), a classical problem
  8.1306 +        of the combinatorial optimization (see the file 'tspsol.c' in
  8.1307 +        the subdirectory 'sample').
  8.1308 +
  8.1309 +GLPK 3.2 (release date: Jul 15, 2002)
  8.1310 +
  8.1311 +        New edition of the document "GLPK: Reference Manual" was
  8.1312 +        included (see the files 'refman.latex', 'refman.dvi', and
  8.1313 +        'refman.ps' in the subdirectory 'doc').
  8.1314 +
  8.1315 +        New edition of the document "GLPK: Modeling Language GLPK/L" was
  8.1316 +        included (see the files 'lang.latex', 'lang.dvi', and 'lang.ps'
  8.1317 +        in the subdirectory 'doc').
  8.1318 +
  8.1319 +        The following new API routines were added to the package:
  8.1320 +
  8.1321 +        lpx_transform_row (transform explicitly specified row);
  8.1322 +        lpx_transform_col (transform explicitly specified column);
  8.1323 +        lpx_prim_ratio_test (perform primal ratio test);
  8.1324 +        lpx_dual_ratio_test (perform dual ratio test);
  8.1325 +        lpx_interior (solve LP problem using interior point method);
  8.1326 +        lpx_get_ips_stat (query status of interior point solution);
  8.1327 +        lpx_get_ips_row (obtain row interior point solution);
  8.1328 +        lpx_get_ips_col (obtain column interior point solution);
  8.1329 +        lpx_get_ips_obj (obtain interior point value of obj.func.);
  8.1330 +        lpx_read_lpm (read LP/MIP model written in GLPK/L);
  8.1331 +        lpx_write_mps (write problem data using MPS format);
  8.1332 +        lpx_print_ips (print interior point solution).
  8.1333 +
  8.1334 +        Detailed description of all these new API routines are given in
  8.1335 +        the new edition of the reference manual.
  8.1336 +
  8.1337 +        New version of the stand-alone solver glpsol (which is based on
  8.1338 +        the new API) was implemented.
  8.1339 +
  8.1340 +        So long as the new API (introduced in glpk 3.0) now provides
  8.1341 +        all the functions, which were provided by the old API, the old
  8.1342 +        API routines were removed from the package at all.
  8.1343 +
  8.1344 +GLPK 3.1 (release date: May 27, 2002)
  8.1345 +
  8.1346 +        A preliminary implementation of new API routines was completed
  8.1347 +        and included in the package.
  8.1348 +
  8.1349 +        These new API routines provide much more flexible interaction
  8.1350 +        between the application program, LP/MIP problem instances, and
  8.1351 +        solver routines. Based on completely changed data structures
  8.1352 +        they are, however, similar to the API routines and provide the
  8.1353 +        same functionality. Please note that three routines, namely,
  8.1354 +        solving LPs using interior point method, reading model written
  8.1355 +        in the GLPK/L modeling language, and writing problem data in
  8.1356 +        the MPS format, are not implemented in the new API, however,
  8.1357 +        these routines are planned to be implemented in the next version
  8.1358 +        of the package.
  8.1359 +
  8.1360 +        A description of the new API routines is given in the document
  8.1361 +        "GLPK Reference Manual", a draft edition of which is included
  8.1362 +        in the package (see the files 'refman.latex', 'refman.dvi', and
  8.1363 +        'refman.ps' in the subdirectory 'doc').
  8.1364 +
  8.1365 +        Although the old API routines are kept in the package, they are
  8.1366 +        no longer supported and will be removed in the future.
  8.1367 +
  8.1368 +GLPK 3.0.8 (release date: May 13, 2002)
  8.1369 +
  8.1370 +        A preliminary implementation of new API routines was included
  8.1371 +        in the package. These new API routines are intended to provide
  8.1372 +        much more flexible interaction between the application program,
  8.1373 +        LP/MIP problem and solver routines. See the document "New GLPK
  8.1374 +        API Routines" (the file 'newapi.txt' in the subdirectory 'doc')
  8.1375 +        also included in the package.
  8.1376 +
  8.1377 +        The api routines glp_simplex2, glp_call_ipm1, glp_call_bbm1 were
  8.1378 +        renamed, respectively, to glp_simplex, glp_interior, glp_integer
  8.1379 +        in order to reflect changes in implementation. The api routines
  8.1380 +        glp_call_rsm1, glp_simplex1, glp_pivot_in, glp_pivout_out were
  8.1381 +        removed from the package since they are completely supreseded by
  8.1382 +        the new API routines (however, these routines still can be found
  8.1383 +        in the subdirectory 'oldsrc'). Please consult a new edition of
  8.1384 +        the document "GLPK User's Guide" about all these changes in the
  8.1385 +        existing api routines.
  8.1386 +
  8.1387 +        The document "GLPK Library Reference" was removed from the
  8.1388 +        package (into the subdirectory 'oldsrc') since it describes the
  8.1389 +        obsolete library routines, most of which are no longer used.
  8.1390 +
  8.1391 +GLPK 3.0.7 (release date: Apr 22, 2002)
  8.1392 +
  8.1393 +        A new, more efficient implementation of the primal/dual simplex
  8.1394 +        method was included in the package. Due to some improvements the
  8.1395 +        simplex-based solver allows solving many LP problems faster and
  8.1396 +        provides more reliable results. Note that the new implementation
  8.1397 +        is currently incomplete and available only via the api routine
  8.1398 +        glp_simplex2.
  8.1399 +
  8.1400 +        All the changes are transparent on API level.
  8.1401 +
  8.1402 +GLPK 3.0.6 (release date: Mar 28, 2002)
  8.1403 +
  8.1404 +        New version of LU-factorization and basis maintenance routines
  8.1405 +        (based on Forrest-Tomlin updating technique) was implemented.
  8.1406 +        Since these new routines functionally supersede some routines
  8.1407 +        (which implement other forms of the basis matrix) and make them
  8.1408 +        obsolete, the latter were removed from the package (they still
  8.1409 +        can be found in the subdirectory 'oldsrc').
  8.1410 +
  8.1411 +        All the changes are transparent on API level.
  8.1412 +
  8.1413 +GLPK 3.0.5 (release date: Jan 29, 2002)
  8.1414 +
  8.1415 +        New edition of the document "GLPK User's Guide" was included in
  8.1416 +        the distribution. Now it describes all additional API routines,
  8.1417 +        which were recently added to the package.
  8.1418 +
  8.1419 +        Structure of the package was re-organized in order to make its
  8.1420 +        maintenance easier (all small files in the subdurectory 'source'
  8.1421 +        were merged in bigger units). These changes are transparent for
  8.1422 +        the user.
  8.1423 +
  8.1424 +GLPK 3.0.4 (release date: Dec 10, 2001)
  8.1425 +
  8.1426 +        A new, more efficient implementation of the two-phase primal
  8.1427 +        simplex method was included in the package. Due to some new
  8.1428 +        features (an advanced initial basis, projected steepest edge,
  8.1429 +        recursive updating values and reduced costs) the new LP solver
  8.1430 +        is faster and numerically more stable than the old one.
  8.1431 +
  8.1432 +        The new LP solver is available as API routine glp_simplex2 and
  8.1433 +        has the same purpose as API routine glp_call_rsm1. For detailed
  8.1434 +        specification see the file 'newapi.txt' in the directory 'doc'.
  8.1435 +
  8.1436 +        Now the new LP solver is also used by default to solve an
  8.1437 +        initial LP problem in the branch-and-bound routine glp_call_bbm1
  8.1438 +        instead the routine rsm1_driver. Note that the branch-and-bound
  8.1439 +        procedure itself is still based on rsm1_driver.
  8.1440 +
  8.1441 +        The new LP solver is also used as default solver in GLPSOL for
  8.1442 +        solving LP and MIP problems. In order to choose the old solver
  8.1443 +        the option '--old-sim' can be specified in the command line.
  8.1444 +
  8.1445 +GLPK 3.0.3 (release date: Oct 03, 2001)
  8.1446 +
  8.1447 +        Some minor changes were made in the simplex method routines in
  8.1448 +        order to improve numerical stability of the method.
  8.1449 +
  8.1450 +GLPK 3.0.2 (release date: Sep 24, 2001)
  8.1451 +
  8.1452 +        A new implementation of the basis maintaining routines was
  8.1453 +        included in the package. These routines, which are based on so
  8.1454 +        called FHV-factorization (a variety of LU-factorization) of the
  8.1455 +        basis matrix and Gustavson's data structures, allows performing
  8.1456 +        the main operations faster at the expense of some worsening
  8.1457 +        numerical accuracy.
  8.1458 +
  8.1459 +        AFI (Advanced Form of the Inverse), which is the form of the
  8.1460 +        basis matrix based on FHV-factorization, is available via the
  8.1461 +        parameter form = 3 (on API level) or via the option --afi (in
  8.1462 +        GLPSOL solver).
  8.1463 +
  8.1464 +GLPK 3.0.1 (release date: Aug 01, 2001)
  8.1465 +
  8.1466 +        Old GLPK API routines have been removed from the package.
  8.1467 +
  8.1468 +        New GLPK API routines were added:
  8.1469 +
  8.1470 +        - scaling routines;
  8.1471 +
  8.1472 +        - a routine for writing problem data in MPS format;
  8.1473 +
  8.1474 +        - a comprehensive driver to the simplex method;
  8.1475 +
  8.1476 +        - basis maintaining routines.
  8.1477 +
  8.1478 +        A description of the new API routines is given in the document
  8.1479 +        "Additional GLPK API Routines". This document is included into
  8.1480 +        the distribution in plain text format (see the file 'newapi.txt'
  8.1481 +        in the subdirectory 'doc').
  8.1482 +
  8.1483 +        Now the distribution includes a non-trivial example of using
  8.1484 +        GLPK as a base LP solver for Concorde, a well known program that
  8.1485 +        solves Traveling Salesman Problem (TSP). For further details see
  8.1486 +        comments in the file 'sample/lpglpk30.c'.
  8.1487 +
  8.1488 +GLPK 3.0 (release date: Jul 19, 2001)
  8.1489 +
  8.1490 +        Now GLPK is provided with new API, which being more flexible
  8.1491 +        can be used in more complex algorithmic schemes.
  8.1492 +
  8.1493 +        New edition of the document "GLPK User's Guide" is included in
  8.1494 +        the distribution. Now it completely corresponds to the new GLPK
  8.1495 +        API routines.
  8.1496 +
  8.1497 +        Old API routines are not removed yet from the package, however
  8.1498 +        they became obsolete and therefore should not be used. Since now
  8.1499 +        the header glpk.h corresponds to new API, in order to compile
  8.1500 +        existing programs that use old GLPK API routines the statement
  8.1501 +
  8.1502 +        #define GLP_OLD_API
  8.1503 +
  8.1504 +        should be inserted before the statement
  8.1505 +
  8.1506 +        #include "glpk.h"
  8.1507 +
  8.1508 +GLPK 2.4.1 (release date: Jun 14, 2001)
  8.1509 +
  8.1510 +        The document "Modeling language GLPK/L" is included into the
  8.1511 +        distribution in texinfo format.
  8.1512 +
  8.1513 +        New edition of the document "GLPK User's Guide" is included in
  8.1514 +        the distribution. Now it describes all additional API routines
  8.1515 +        which were recently added to the package.
  8.1516 +
  8.1517 +GLPK 2.4 (release date: May 10, 2001)
  8.1518 +
  8.1519 +        Now GLPK includes an implementation of a preliminary version
  8.1520 +        of the GLPK/L modeling language. This language is intended for
  8.1521 +        writing mathematcal programming models. The name GLPK/L is
  8.1522 +        derived from GNU Linear Programming Kit Language.
  8.1523 +
  8.1524 +        A brief description of the GLPK/L language is given in the
  8.1525 +        document "GLPK/L Modeling Language: A Brief Description". This
  8.1526 +        document is included into the distribution in plain text format
  8.1527 +        (see the file 'language.txt' in the subdirectory 'doc').
  8.1528 +
  8.1529 +        The language processor (which is a program that analyzes model
  8.1530 +        description written in GLPK/L and translates it to internal data
  8.1531 +        structures) is available as the GLPK API routine.
  8.1532 +
  8.1533 +        The stand-alone solver GLPSOL now is able: a) to process model
  8.1534 +        descriptions written in the GLPK/L language; b) to solve pure LP
  8.1535 +        problems using the interior point method (therefore the program
  8.1536 +        GLPIPM was removed from the package).
  8.1537 +
  8.1538 +GLPK 2.3 (release date: Apr 09, 2001)
  8.1539 +
  8.1540 +        New edition of the document "GLPK User's Guide" is included in
  8.1541 +        the distribution. Now it describes all additional API routines
  8.1542 +        which were recently added to the package.
  8.1543 +
  8.1544 +        The MIP solver was fully re-programmed in order to improve its
  8.1545 +        robustness and performance. In particular, a basis recovering
  8.1546 +        procedure was implemented (this procedure allows switching to
  8.1547 +        the primal simplex method in case when the dual simplex method
  8.1548 +        fails).
  8.1549 +
  8.1550 +GLPK 2.2 (release date: Mar 15, 2001)
  8.1551 +
  8.1552 +        Now GLPK includes a tentative implementation of the
  8.1553 +        branch-and-bound procedure based on the dual simplex method for
  8.1554 +        mixed integer linear programming (MIP).
  8.1555 +
  8.1556 +        Complete description of this new feature of the package is given
  8.1557 +        in the preliminary document "Mixed Integer Linear Programming
  8.1558 +        Using GLPK Version 2.2 (Supplement to GLPK User's Guide)". This
  8.1559 +        document is included into the distribution in plain text format
  8.1560 +        (see the file 'mip.txt' in the subdirectory 'doc').
  8.1561 +
  8.1562 +        The MIP solver (glp_integer) can be used as GLPK API routine in
  8.1563 +        the same way as the pure LP solver (glp_simplex).
  8.1564 +
  8.1565 +        The stand-alone program 'glpsol' is now able to solve LP as well
  8.1566 +        as MIP problems.
  8.1567 +
  8.1568 +        Note that the current version of GLPK MIP solver is based on
  8.1569 +        easiest heuristics for branching and backtrackng. Therefore the
  8.1570 +        solver is fit mainly for MIP problems which are not very hard
  8.1571 +        and have few integer variables.
  8.1572 +
  8.1573 +GLPK 2.1 (release date: Feb 19, 2001)
  8.1574 +
  8.1575 +        The document "GLPK Implementation of the Revised Simplex Method"
  8.1576 +        is included into the distribution. This document describes most
  8.1577 +        of routines related to the revised simplex method.
  8.1578 +
  8.1579 +GLPK 2.0 (release date: Jan 25, 2001)
  8.1580 +
  8.1581 +        Now GLPK includes a tentative implementation of the primal-dual
  8.1582 +        interior point method for large-scale linear programming.
  8.1583 +
  8.1584 +        The interior point solver can be used as GLPK API routine in the
  8.1585 +        same manner as the simplex method solver (glp_simplex):
  8.1586 +
  8.1587 +        ret = glp_interior();
  8.1588 +
  8.1589 +        Note that currently the interior point solver implemented in
  8.1590 +        GLPK doesn't include many important features, in particular:
  8.1591 +
  8.1592 +        * it can't process dense columns; therefore if the problem has
  8.1593 +          dense columns, the solving will be extremely inefficient;
  8.1594 +
  8.1595 +        * it has no special features against numerical unstability;
  8.1596 +          some problems may cause premature termination of the solving
  8.1597 +          when the matrix A*D*A' becomes ill-conditioned;
  8.1598 +
  8.1599 +        * it computes only values of primal (auxiliary and structural)
  8.1600 +          variables and doesn't compute values of dual variables (i.e.
  8.1601 +          reduced costs) which are just set to zero;
  8.1602 +
  8.1603 +        * it doesn't identify optimal basis corresponding to the found
  8.1604 +          interior point solution; all variables in the found solution
  8.1605 +          are just marked as basic variables.
  8.1606 +
  8.1607 +        GLPK also includes a stand-alone program 'glpipm' which is a
  8.1608 +        demo based on the interior point method. It may be used in the
  8.1609 +        same way as the program 'glpsol' that is based on the simplex
  8.1610 +        method.
     9.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     9.2 +++ b/deps/glpk/README	Sun Nov 06 20:59:10 2011 +0100
     9.3 @@ -0,0 +1,39 @@
     9.4 +                                                     Olga K. gewidmet
     9.5 +
     9.6 +GLPK (GNU Linear Programming Kit) Version 4.47
     9.7 +
     9.8 +Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008,
     9.9 +2009, 2010, 2011 Andrew Makhorin, Department for Applied Informatics,
    9.10 +Moscow Aviation Institute, Moscow, Russia. All rights reserved.
    9.11 +E-mail: <mao@gnu.org>.
    9.12 +
    9.13 +GLPK is part of the GNU Project released under the aegis of GNU.
    9.14 +
    9.15 +GLPK is free software: you can redistribute it and/or modify it
    9.16 +under the terms of the GNU General Public License as published by the
    9.17 +Free Software Foundation, either version 3 of the License, or (at your
    9.18 +option) any later version.
    9.19 +
    9.20 +See the file COPYING for the GNU General Public License.
    9.21 +
    9.22 +See the file INSTALL for compilation and installation instructions.
    9.23 +
    9.24 +The GLPK package is a set of routines written in ANSI C and organized
    9.25 +in the form of a callable library. This package is intended for solving
    9.26 +large-scale linear programming (LP), mixed integer linear programming
    9.27 +(MIP), and other related problems.
    9.28 +
    9.29 +The GLPK package includes the following main components:
    9.30 +
    9.31 +* implementation of the simplex method;
    9.32 +* implementation of the exact simplex method based on bignum (rational)
    9.33 +  arithmetic;
    9.34 +* implementation of the primal-dual interior-point method;
    9.35 +* implementation of the branch-and-cut method;
    9.36 +* application program interface (API);
    9.37 +* GNU MathProg modeling language (a subset of AMPL);
    9.38 +* GLPSOL, a stand-alone LP/MIP solver.
    9.39 +
    9.40 +See GLPK webpage <http://www.gnu.org/software/glpk/glpk.html>.
    9.41 +
    9.42 +Please report bugs to <bug-glpk@gnu.org>.
    10.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    10.2 +++ b/deps/glpk/THANKS	Sun Nov 06 20:59:10 2011 +0100
    10.3 @@ -0,0 +1,185 @@
    10.4 +Marco Atzeri <marco.atzeri@gmail.com> for buf report.
    10.5 +
    10.6 +Noli Sicad <nsicad@gmail.com> for testing glpk under Mac OS.
    10.7 +
    10.8 +Pietro Scionti <pietro.scionti@archinet.it> for report typos found in
    10.9 +the reference manual.
   10.10 +
   10.11 +Noli Sicad <nsicad@gmail.com> for example model in MathProg.
   10.12 +
   10.13 +Nigel Galloway <nigel_galloway@operamail.com> for example model in
   10.14 +MathProg.
   10.15 +
   10.16 +Xypron <xypron.glpk@gmx.de> for contribution and testing batch scripts
   10.17 +to build Glpk with MS Visual Studio 2010.
   10.18 +
   10.19 +Xypron <xypron.glpk@gmx.de> for improving the SQL table driver.
   10.20 +
   10.21 +Stefan Vigerske <stefan@math.hu-berlin.de> for bug report.
   10.22 +
   10.23 +Uday Venkatadri <Uday.Venkatadri@dal.ca> for bug report.
   10.24 +
   10.25 +Xypron <xypron.glpk@gmx.de> for bug fixing and some improvments in the
   10.26 +FPUMP module.
   10.27 +
   10.28 +Niels Klitgord <niels@bu.edu> for bug report.
   10.29 +
   10.30 +Thomas Kahle <tom111@gmx.de> for some suggestions.
   10.31 +
   10.32 +Jonathan Senning <Jonathan.Senning@gordon.edu> for bug report.
   10.33 +
   10.34 +Xypron <xypron.glpk@gmx.de> for testing GLPK on 64-bit platforms and
   10.35 +for maintaining Windows versions of the package.
   10.36 +
   10.37 +Nelson H. F. Beebe <beebe@math.utah.edu> for bug report.
   10.38 +
   10.39 +Larry D'Agostino <Larry.D'Agostino@gmacrescap.com> for example model in
   10.40 +MathProg.
   10.41 +
   10.42 +Marco Atzeri <marco_atzeri@yahoo.it> for bug report.
   10.43 +
   10.44 +Robert Wood <rgwood01@cox.net> for example model in MathProg.
   10.45 +
   10.46 +Sebastien Briais <sbriais@free.fr> for bug report.
   10.47 +
   10.48 +Kelly Westbrooks <kellywestbrooks@yahoo.com> for suggestions.
   10.49 +
   10.50 +Nigel Galloway <nigel_galloway@operamail.com> for example models in
   10.51 +MathProg.
   10.52 +
   10.53 +Xypron <xypron.glpk@gmx.de> for bug patch.
   10.54 +
   10.55 +Sebastian Nowozin <nowozin@gmail.com> for example models in MathProg.
   10.56 +
   10.57 +Stefan Vigerske <stefan@vigerske.de> for bug report.
   10.58 +
   10.59 +Luiz Bettoni <bettoni@cpgei.ct.utfpr.edu.br> for some suggestions.
   10.60 +
   10.61 +Nigel Galloway <nigel_galloway@operamail.com> for bug report.
   10.62 +
   10.63 +Peter Ingerfeld <peter.ingerfeld@mops-optimizer.com> for bug report.
   10.64 +
   10.65 +Heinrich Schuchardt <heinrich.schuchardt@gmx.de> for contribution of
   10.66 +makefiles and testing the package under 64-bit Windows. 
   10.67 +
   10.68 +Oscar Gustafsson <oscarg@isy.liu.se> for contribution of a new version
   10.69 +of the routine to write data in OPB (pseudo boolean) format.
   10.70 +
   10.71 +Heinrich Schuchardt <heinrich.schuchardt@gmx.de> for some patches for
   10.72 +the MathProg translator.
   10.73 +
   10.74 +Markus Pilz <pilz@cs.uni-bonn.de> for bug report.
   10.75 +
   10.76 +Anne-Laurence Putz <anne-laurence.putz@eurodecision.com> for bug
   10.77 +report.
   10.78 +
   10.79 +Robbie Morrison <robbie@actrix.co.nz> for correcting the glpk manual.
   10.80 +
   10.81 +Axel Simon <Axel.Simon@ens.fr> for bug report.
   10.82 +
   10.83 +Vijay Patil <vijay.patil@gmail.com> for testing the package under
   10.84 +Windows XP.
   10.85 +
   10.86 +Heinrich Schuchardt <heinrich.schuchardt@gmx.de> for contribution of
   10.87 +two MathProg table drivers for iODBC and MySQL.
   10.88 +
   10.89 +Rafael Laboissiere <rafael@debian.org> for useful advices concerning
   10.90 +shared library support under GNU/Linux.
   10.91 +
   10.92 +Nigel Galloway <Nigel_Galloway@operamail.com> for an example program
   10.93 +in C#.
   10.94 +
   10.95 +Enric Rodriguez <erodri@lsi.upc.edu> for bug report.
   10.96 +
   10.97 +Nigel Galloway <Nigel_Galloway@operamail.com> for an example MathProg
   10.98 +model.
   10.99 +
  10.100 +Roberto Bagnara <bagnara@cs.unipr.it> (Department of Mathematics,
  10.101 +University of Parma, Italy) for bug report.
  10.102 +
  10.103 +Peter T. Breuer <ptb@inv.it.uc3m.es> for bug report.
  10.104 +
  10.105 +Graham Rockwell <bionomicron@gmail.com> for bug report.
  10.106 +
  10.107 +Cedric[FR] <fox2113@wanadoo.fr> for bug report.
  10.108 +
  10.109 +Cameron Kellough <Cameron.Kellough@sri.com> for bug report.
  10.110 +
  10.111 +Oscar Gustafsson <oscarg@isy.liu.se> for contribution of a routine to
  10.112 +write data in OPB (pseudo boolean) format.
  10.113 +
  10.114 +Boris Wirtz <Boris.Wirtz@uni-oldenburg.de> for bug report.
  10.115 +
  10.116 +Sebastian Nowozin <nowozin@gmail.com> for three example MathProg
  10.117 +models.
  10.118 +
  10.119 +Rafael Laboissiere <rafael@debian.org> for useful advices concerning
  10.120 +shared library support.
  10.121 +
  10.122 +Dr. Harley Mackenzie <hjm@hardsoftware.com> for two example MathProg
  10.123 +models (curve fitting problem).
  10.124 +
  10.125 +Minh Ha Duong <haduong@centre-cired.fr> for fixing doc typos.
  10.126 +
  10.127 +Brady Hunsaker <hunsaker@engr.pitt.edu> for some suggestions concerning
  10.128 +MIP routines.
  10.129 +
  10.130 +Karel Zimmermann <kzimm@diamant.jouy.inra.fr> for bug report.
  10.131 +
  10.132 +Christophe Caron <caron@diamant.jouy.inra.fr> for bug report.
  10.133 +
  10.134 +Nicolo Giorgetti <giorgetti@dii.unisi.it> for contribution of GLPKMEX,
  10.135 +a Matlab MEX interface.
  10.136 +
  10.137 +Harley Mackenzie <hjm@bigpond.com> for contribution of GLPK FAQ.
  10.138 +
  10.139 +Andre Girard <andre@inrs-emt.uquebec.ca> for bug report.
  10.140 +
  10.141 +Morten Welinder <terra@gnu.org> for bug report.
  10.142 +
  10.143 +Brady Hunsaker <hunsaker@engr.pitt.edu> for contribution of a routine
  10.144 +for bounds sensitivity analysis.
  10.145 +
  10.146 +Chris Rosebrugh <cpr@pobox.com> for contribution of a new version of
  10.147 +GLPK JNI (Java Native Interface).
  10.148 +
  10.149 +Ivo van Baren <i.van.baren@freeler.nl> for contribution of GLPK DELI
  10.150 +(Delphi Interface).
  10.151 +
  10.152 +Andrew Hamilton-Wright <andrewhw@ieee.org> for bug report.
  10.153 +
  10.154 +Jiri Spitz <jiri.spitz@telecom.cz> for bug report.
  10.155 +
  10.156 +Giles Thompson <gwpt1@cus.cam.ac.uk> for bug report.
  10.157 +
  10.158 +Sebastien de Menten <sdementen@hotmail.com> for bug report.
  10.159 +
  10.160 +Kendall Demaree <kendal.demaree@verizon.net> for bug report.
  10.161 +
  10.162 +Bernhard Schmidt <schmidt@math.uni-augsburg.de> for bug report.
  10.163 +
  10.164 +Yuri Victorovich <yuri@gjt.org> for contribution of GLPK Java binding.
  10.165 +
  10.166 +Olivier <odwl@skynet.be> for bug report.
  10.167 +
  10.168 +Kjell Eikland <kjell.eikland@broadpark.no> for bug report.
  10.169 +
  10.170 +Ivan Luzzi <iluzzi@libero.it> for comments concerning CPLEX LP format.
  10.171 +
  10.172 +Peter Lee <plee@kinggee.com.au> for example LP model and bug report.
  10.173 +
  10.174 +Morten Welinder <terra@diku.dk> for bug report.
  10.175 +
  10.176 +Vlahos Kiriakos <Kiriakos.Vlahos@gs.com> for bug report.
  10.177 +
  10.178 +Flavio Keidi Miyazawa <fkm@ic.unicamp.br> for bug report.
  10.179 +
  10.180 +Hans Schwengeler <Hans.Schwengeler@unibas.ch> for bug report.
  10.181 +
  10.182 +Sami Farin <sfarin@ratol.fi> for bug report.
  10.183 +
  10.184 +Peter A. Huegler <phuegler@bsco.com> for bug report.
  10.185 +
  10.186 +Alexandre Oliva <oliva@lsd.ic.unicamp.br> for bug report.
  10.187 +
  10.188 +Andrew Hood <ajhood@fl.net.au> for bug report.
    11.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    11.2 +++ b/deps/glpk/aclocal.m4	Sun Nov 06 20:59:10 2011 +0100
    11.3 @@ -0,0 +1,956 @@
    11.4 +# generated automatically by aclocal 1.11.1 -*- Autoconf -*-
    11.5 +
    11.6 +# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004,
    11.7 +# 2005, 2006, 2007, 2008, 2009  Free Software Foundation, Inc.
    11.8 +# This file is free software; the Free Software Foundation
    11.9 +# gives unlimited permission to copy and/or distribute it,
   11.10 +# with or without modifications, as long as this notice is preserved.
   11.11 +
   11.12 +# This program is distributed in the hope that it will be useful,
   11.13 +# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
   11.14 +# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
   11.15 +# PARTICULAR PURPOSE.
   11.16 +
   11.17 +m4_ifndef([AC_AUTOCONF_VERSION],
   11.18 +  [m4_copy([m4_PACKAGE_VERSION], [AC_AUTOCONF_VERSION])])dnl
   11.19 +m4_if(m4_defn([AC_AUTOCONF_VERSION]), [2.65],,
   11.20 +[m4_warning([this file was generated for autoconf 2.65.
   11.21 +You have another version of autoconf.  It may work, but is not guaranteed to.
   11.22 +If you have problems, you may need to regenerate the build system entirely.
   11.23 +To do so, use the procedure documented by the package, typically `autoreconf'.])])
   11.24 +
   11.25 +# Copyright (C) 2002, 2003, 2005, 2006, 2007, 2008  Free Software Foundation, Inc.
   11.26 +#
   11.27 +# This file is free software; the Free Software Foundation
   11.28 +# gives unlimited permission to copy and/or distribute it,
   11.29 +# with or without modifications, as long as this notice is preserved.
   11.30 +
   11.31 +# AM_AUTOMAKE_VERSION(VERSION)
   11.32 +# ----------------------------
   11.33 +# Automake X.Y traces this macro to ensure aclocal.m4 has been
   11.34 +# generated from the m4 files accompanying Automake X.Y.
   11.35 +# (This private macro should not be called outside this file.)
   11.36 +AC_DEFUN([AM_AUTOMAKE_VERSION],
   11.37 +[am__api_version='1.11'
   11.38 +dnl Some users find AM_AUTOMAKE_VERSION and mistake it for a way to
   11.39 +dnl require some minimum version.  Point them to the right macro.
   11.40 +m4_if([$1], [1.11.1], [],
   11.41 +      [AC_FATAL([Do not call $0, use AM_INIT_AUTOMAKE([$1]).])])dnl
   11.42 +])
   11.43 +
   11.44 +# _AM_AUTOCONF_VERSION(VERSION)
   11.45 +# -----------------------------
   11.46 +# aclocal traces this macro to find the Autoconf version.
   11.47 +# This is a private macro too.  Using m4_define simplifies
   11.48 +# the logic in aclocal, which can simply ignore this definition.
   11.49 +m4_define([_AM_AUTOCONF_VERSION], [])
   11.50 +
   11.51 +# AM_SET_CURRENT_AUTOMAKE_VERSION
   11.52 +# -------------------------------
   11.53 +# Call AM_AUTOMAKE_VERSION and AM_AUTOMAKE_VERSION so they can be traced.
   11.54 +# This function is AC_REQUIREd by AM_INIT_AUTOMAKE.
   11.55 +AC_DEFUN([AM_SET_CURRENT_AUTOMAKE_VERSION],
   11.56 +[AM_AUTOMAKE_VERSION([1.11.1])dnl
   11.57 +m4_ifndef([AC_AUTOCONF_VERSION],
   11.58 +  [m4_copy([m4_PACKAGE_VERSION], [AC_AUTOCONF_VERSION])])dnl
   11.59 +_AM_AUTOCONF_VERSION(m4_defn([AC_AUTOCONF_VERSION]))])
   11.60 +
   11.61 +# AM_AUX_DIR_EXPAND                                         -*- Autoconf -*-
   11.62 +
   11.63 +# Copyright (C) 2001, 2003, 2005  Free Software Foundation, Inc.
   11.64 +#
   11.65 +# This file is free software; the Free Software Foundation
   11.66 +# gives unlimited permission to copy and/or distribute it,
   11.67 +# with or without modifications, as long as this notice is preserved.
   11.68 +
   11.69 +# For projects using AC_CONFIG_AUX_DIR([foo]), Autoconf sets
   11.70 +# $ac_aux_dir to `$srcdir/foo'.  In other projects, it is set to
   11.71 +# `$srcdir', `$srcdir/..', or `$srcdir/../..'.
   11.72 +#
   11.73 +# Of course, Automake must honor this variable whenever it calls a
   11.74 +# tool from the auxiliary directory.  The problem is that $srcdir (and
   11.75 +# therefore $ac_aux_dir as well) can be either absolute or relative,
   11.76 +# depending on how configure is run.  This is pretty annoying, since
   11.77 +# it makes $ac_aux_dir quite unusable in subdirectories: in the top
   11.78 +# source directory, any form will work fine, but in subdirectories a
   11.79 +# relative path needs to be adjusted first.
   11.80 +#
   11.81 +# $ac_aux_dir/missing
   11.82 +#    fails when called from a subdirectory if $ac_aux_dir is relative
   11.83 +# $top_srcdir/$ac_aux_dir/missing
   11.84 +#    fails if $ac_aux_dir is absolute,
   11.85 +#    fails when called from a subdirectory in a VPATH build with
   11.86 +#          a relative $ac_aux_dir
   11.87 +#
   11.88 +# The reason of the latter failure is that $top_srcdir and $ac_aux_dir
   11.89 +# are both prefixed by $srcdir.  In an in-source build this is usually
   11.90 +# harmless because $srcdir is `.', but things will broke when you
   11.91 +# start a VPATH build or use an absolute $srcdir.
   11.92 +#
   11.93 +# So we could use something similar to $top_srcdir/$ac_aux_dir/missing,
   11.94 +# iff we strip the leading $srcdir from $ac_aux_dir.  That would be:
   11.95 +#   am_aux_dir='\$(top_srcdir)/'`expr "$ac_aux_dir" : "$srcdir//*\(.*\)"`
   11.96 +# and then we would define $MISSING as
   11.97 +#   MISSING="\${SHELL} $am_aux_dir/missing"
   11.98 +# This will work as long as MISSING is not called from configure, because
   11.99 +# unfortunately $(top_srcdir) has no meaning in configure.
  11.100 +# However there are other variables, like CC, which are often used in
  11.101 +# configure, and could therefore not use this "fixed" $ac_aux_dir.
  11.102 +#
  11.103 +# Another solution, used here, is to always expand $ac_aux_dir to an
  11.104 +# absolute PATH.  The drawback is that using absolute paths prevent a
  11.105 +# configured tree to be moved without reconfiguration.
  11.106 +
  11.107 +AC_DEFUN([AM_AUX_DIR_EXPAND],
  11.108 +[dnl Rely on autoconf to set up CDPATH properly.
  11.109 +AC_PREREQ([2.50])dnl
  11.110 +# expand $ac_aux_dir to an absolute path
  11.111 +am_aux_dir=`cd $ac_aux_dir && pwd`
  11.112 +])
  11.113 +
  11.114 +# AM_CONDITIONAL                                            -*- Autoconf -*-
  11.115 +
  11.116 +# Copyright (C) 1997, 2000, 2001, 2003, 2004, 2005, 2006, 2008
  11.117 +# Free Software Foundation, Inc.
  11.118 +#
  11.119 +# This file is free software; the Free Software Foundation
  11.120 +# gives unlimited permission to copy and/or distribute it,
  11.121 +# with or without modifications, as long as this notice is preserved.
  11.122 +
  11.123 +# serial 9
  11.124 +
  11.125 +# AM_CONDITIONAL(NAME, SHELL-CONDITION)
  11.126 +# -------------------------------------
  11.127 +# Define a conditional.
  11.128 +AC_DEFUN([AM_CONDITIONAL],
  11.129 +[AC_PREREQ(2.52)dnl
  11.130 + ifelse([$1], [TRUE],  [AC_FATAL([$0: invalid condition: $1])],
  11.131 +	[$1], [FALSE], [AC_FATAL([$0: invalid condition: $1])])dnl
  11.132 +AC_SUBST([$1_TRUE])dnl
  11.133 +AC_SUBST([$1_FALSE])dnl
  11.134 +_AM_SUBST_NOTMAKE([$1_TRUE])dnl
  11.135 +_AM_SUBST_NOTMAKE([$1_FALSE])dnl
  11.136 +m4_define([_AM_COND_VALUE_$1], [$2])dnl
  11.137 +if $2; then
  11.138 +  $1_TRUE=
  11.139 +  $1_FALSE='#'
  11.140 +else
  11.141 +  $1_TRUE='#'
  11.142 +  $1_FALSE=
  11.143 +fi
  11.144 +AC_CONFIG_COMMANDS_PRE(
  11.145 +[if test -z "${$1_TRUE}" && test -z "${$1_FALSE}"; then
  11.146 +  AC_MSG_ERROR([[conditional "$1" was never defined.
  11.147 +Usually this means the macro was only invoked conditionally.]])
  11.148 +fi])])
  11.149 +
  11.150 +# Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2009
  11.151 +# Free Software Foundation, Inc.
  11.152 +#
  11.153 +# This file is free software; the Free Software Foundation
  11.154 +# gives unlimited permission to copy and/or distribute it,
  11.155 +# with or without modifications, as long as this notice is preserved.
  11.156 +
  11.157 +# serial 10
  11.158 +
  11.159 +# There are a few dirty hacks below to avoid letting `AC_PROG_CC' be
  11.160 +# written in clear, in which case automake, when reading aclocal.m4,
  11.161 +# will think it sees a *use*, and therefore will trigger all it's
  11.162 +# C support machinery.  Also note that it means that autoscan, seeing
  11.163 +# CC etc. in the Makefile, will ask for an AC_PROG_CC use...
  11.164 +
  11.165 +
  11.166 +# _AM_DEPENDENCIES(NAME)
  11.167 +# ----------------------
  11.168 +# See how the compiler implements dependency checking.
  11.169 +# NAME is "CC", "CXX", "GCJ", or "OBJC".
  11.170 +# We try a few techniques and use that to set a single cache variable.
  11.171 +#
  11.172 +# We don't AC_REQUIRE the corresponding AC_PROG_CC since the latter was
  11.173 +# modified to invoke _AM_DEPENDENCIES(CC); we would have a circular
  11.174 +# dependency, and given that the user is not expected to run this macro,
  11.175 +# just rely on AC_PROG_CC.
  11.176 +AC_DEFUN([_AM_DEPENDENCIES],
  11.177 +[AC_REQUIRE([AM_SET_DEPDIR])dnl
  11.178 +AC_REQUIRE([AM_OUTPUT_DEPENDENCY_COMMANDS])dnl
  11.179 +AC_REQUIRE([AM_MAKE_INCLUDE])dnl
  11.180 +AC_REQUIRE([AM_DEP_TRACK])dnl
  11.181 +
  11.182 +ifelse([$1], CC,   [depcc="$CC"   am_compiler_list=],
  11.183 +       [$1], CXX,  [depcc="$CXX"  am_compiler_list=],
  11.184 +       [$1], OBJC, [depcc="$OBJC" am_compiler_list='gcc3 gcc'],
  11.185 +       [$1], UPC,  [depcc="$UPC"  am_compiler_list=],
  11.186 +       [$1], GCJ,  [depcc="$GCJ"  am_compiler_list='gcc3 gcc'],
  11.187 +                   [depcc="$$1"   am_compiler_list=])
  11.188 +
  11.189 +AC_CACHE_CHECK([dependency style of $depcc],
  11.190 +               [am_cv_$1_dependencies_compiler_type],
  11.191 +[if test -z "$AMDEP_TRUE" && test -f "$am_depcomp"; then
  11.192 +  # We make a subdir and do the tests there.  Otherwise we can end up
  11.193 +  # making bogus files that we don't know about and never remove.  For
  11.194 +  # instance it was reported that on HP-UX the gcc test will end up
  11.195 +  # making a dummy file named `D' -- because `-MD' means `put the output
  11.196 +  # in D'.
  11.197 +  mkdir conftest.dir
  11.198 +  # Copy depcomp to subdir because otherwise we won't find it if we're
  11.199 +  # using a relative directory.
  11.200 +  cp "$am_depcomp" conftest.dir
  11.201 +  cd conftest.dir
  11.202 +  # We will build objects and dependencies in a subdirectory because
  11.203 +  # it helps to detect inapplicable dependency modes.  For instance
  11.204 +  # both Tru64's cc and ICC support -MD to output dependencies as a
  11.205 +  # side effect of compilation, but ICC will put the dependencies in
  11.206 +  # the current directory while Tru64 will put them in the object
  11.207 +  # directory.
  11.208 +  mkdir sub
  11.209 +
  11.210 +  am_cv_$1_dependencies_compiler_type=none
  11.211 +  if test "$am_compiler_list" = ""; then
  11.212 +     am_compiler_list=`sed -n ['s/^#*\([a-zA-Z0-9]*\))$/\1/p'] < ./depcomp`
  11.213 +  fi
  11.214 +  am__universal=false
  11.215 +  m4_case([$1], [CC],
  11.216 +    [case " $depcc " in #(
  11.217 +     *\ -arch\ *\ -arch\ *) am__universal=true ;;
  11.218 +     esac],
  11.219 +    [CXX],
  11.220 +    [case " $depcc " in #(
  11.221 +     *\ -arch\ *\ -arch\ *) am__universal=true ;;
  11.222 +     esac])
  11.223 +
  11.224 +  for depmode in $am_compiler_list; do
  11.225 +    # Setup a source with many dependencies, because some compilers
  11.226 +    # like to wrap large dependency lists on column 80 (with \), and
  11.227 +    # we should not choose a depcomp mode which is confused by this.
  11.228 +    #
  11.229 +    # We need to recreate these files for each test, as the compiler may
  11.230 +    # overwrite some of them when testing with obscure command lines.
  11.231 +    # This happens at least with the AIX C compiler.
  11.232 +    : > sub/conftest.c
  11.233 +    for i in 1 2 3 4 5 6; do
  11.234 +      echo '#include "conftst'$i'.h"' >> sub/conftest.c
  11.235 +      # Using `: > sub/conftst$i.h' creates only sub/conftst1.h with
  11.236 +      # Solaris 8's {/usr,}/bin/sh.
  11.237 +      touch sub/conftst$i.h
  11.238 +    done
  11.239 +    echo "${am__include} ${am__quote}sub/conftest.Po${am__quote}" > confmf
  11.240 +
  11.241 +    # We check with `-c' and `-o' for the sake of the "dashmstdout"
  11.242 +    # mode.  It turns out that the SunPro C++ compiler does not properly
  11.243 +    # handle `-M -o', and we need to detect this.  Also, some Intel
  11.244 +    # versions had trouble with output in subdirs
  11.245 +    am__obj=sub/conftest.${OBJEXT-o}
  11.246 +    am__minus_obj="-o $am__obj"
  11.247 +    case $depmode in
  11.248 +    gcc)
  11.249 +      # This depmode causes a compiler race in universal mode.
  11.250 +      test "$am__universal" = false || continue
  11.251 +      ;;
  11.252 +    nosideeffect)
  11.253 +      # after this tag, mechanisms are not by side-effect, so they'll
  11.254 +      # only be used when explicitly requested
  11.255 +      if test "x$enable_dependency_tracking" = xyes; then
  11.256 +	continue
  11.257 +      else
  11.258 +	break
  11.259 +      fi
  11.260 +      ;;
  11.261 +    msvisualcpp | msvcmsys)
  11.262 +      # This compiler won't grok `-c -o', but also, the minuso test has
  11.263 +      # not run yet.  These depmodes are late enough in the game, and
  11.264 +      # so weak that their functioning should not be impacted.
  11.265 +      am__obj=conftest.${OBJEXT-o}
  11.266 +      am__minus_obj=
  11.267 +      ;;
  11.268 +    none) break ;;
  11.269 +    esac
  11.270 +    if depmode=$depmode \
  11.271 +       source=sub/conftest.c object=$am__obj \
  11.272 +       depfile=sub/conftest.Po tmpdepfile=sub/conftest.TPo \
  11.273 +       $SHELL ./depcomp $depcc -c $am__minus_obj sub/conftest.c \
  11.274 +         >/dev/null 2>conftest.err &&
  11.275 +       grep sub/conftst1.h sub/conftest.Po > /dev/null 2>&1 &&
  11.276 +       grep sub/conftst6.h sub/conftest.Po > /dev/null 2>&1 &&
  11.277 +       grep $am__obj sub/conftest.Po > /dev/null 2>&1 &&
  11.278 +       ${MAKE-make} -s -f confmf > /dev/null 2>&1; then
  11.279 +      # icc doesn't choke on unknown options, it will just issue warnings
  11.280 +      # or remarks (even with -Werror).  So we grep stderr for any message
  11.281 +      # that says an option was ignored or not supported.
  11.282 +      # When given -MP, icc 7.0 and 7.1 complain thusly:
  11.283 +      #   icc: Command line warning: ignoring option '-M'; no argument required
  11.284 +      # The diagnosis changed in icc 8.0:
  11.285 +      #   icc: Command line remark: option '-MP' not supported
  11.286 +      if (grep 'ignoring option' conftest.err ||
  11.287 +          grep 'not supported' conftest.err) >/dev/null 2>&1; then :; else
  11.288 +        am_cv_$1_dependencies_compiler_type=$depmode
  11.289 +        break
  11.290 +      fi
  11.291 +    fi
  11.292 +  done
  11.293 +
  11.294 +  cd ..
  11.295 +  rm -rf conftest.dir
  11.296 +else
  11.297 +  am_cv_$1_dependencies_compiler_type=none
  11.298 +fi
  11.299 +])
  11.300 +AC_SUBST([$1DEPMODE], [depmode=$am_cv_$1_dependencies_compiler_type])
  11.301 +AM_CONDITIONAL([am__fastdep$1], [
  11.302 +  test "x$enable_dependency_tracking" != xno \
  11.303 +  && test "$am_cv_$1_dependencies_compiler_type" = gcc3])
  11.304 +])
  11.305 +
  11.306 +
  11.307 +# AM_SET_DEPDIR
  11.308 +# -------------
  11.309 +# Choose a directory name for dependency files.
  11.310 +# This macro is AC_REQUIREd in _AM_DEPENDENCIES
  11.311 +AC_DEFUN([AM_SET_DEPDIR],
  11.312 +[AC_REQUIRE([AM_SET_LEADING_DOT])dnl
  11.313 +AC_SUBST([DEPDIR], ["${am__leading_dot}deps"])dnl
  11.314 +])
  11.315 +
  11.316 +
  11.317 +# AM_DEP_TRACK
  11.318 +# ------------
  11.319 +AC_DEFUN([AM_DEP_TRACK],
  11.320 +[AC_ARG_ENABLE(dependency-tracking,
  11.321 +[  --disable-dependency-tracking  speeds up one-time build
  11.322 +  --enable-dependency-tracking   do not reject slow dependency extractors])
  11.323 +if test "x$enable_dependency_tracking" != xno; then
  11.324 +  am_depcomp="$ac_aux_dir/depcomp"
  11.325 +  AMDEPBACKSLASH='\'
  11.326 +fi
  11.327 +AM_CONDITIONAL([AMDEP], [test "x$enable_dependency_tracking" != xno])
  11.328 +AC_SUBST([AMDEPBACKSLASH])dnl
  11.329 +_AM_SUBST_NOTMAKE([AMDEPBACKSLASH])dnl
  11.330 +])
  11.331 +
  11.332 +# Generate code to set up dependency tracking.              -*- Autoconf -*-
  11.333 +
  11.334 +# Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2008
  11.335 +# Free Software Foundation, Inc.
  11.336 +#
  11.337 +# This file is free software; the Free Software Foundation
  11.338 +# gives unlimited permission to copy and/or distribute it,
  11.339 +# with or without modifications, as long as this notice is preserved.
  11.340 +
  11.341 +#serial 5
  11.342 +
  11.343 +# _AM_OUTPUT_DEPENDENCY_COMMANDS
  11.344 +# ------------------------------
  11.345 +AC_DEFUN([_AM_OUTPUT_DEPENDENCY_COMMANDS],
  11.346 +[{
  11.347 +  # Autoconf 2.62 quotes --file arguments for eval, but not when files
  11.348 +  # are listed without --file.  Let's play safe and only enable the eval
  11.349 +  # if we detect the quoting.
  11.350 +  case $CONFIG_FILES in
  11.351 +  *\'*) eval set x "$CONFIG_FILES" ;;
  11.352 +  *)   set x $CONFIG_FILES ;;
  11.353 +  esac
  11.354 +  shift
  11.355 +  for mf
  11.356 +  do
  11.357 +    # Strip MF so we end up with the name of the file.
  11.358 +    mf=`echo "$mf" | sed -e 's/:.*$//'`
  11.359 +    # Check whether this is an Automake generated Makefile or not.
  11.360 +    # We used to match only the files named `Makefile.in', but
  11.361 +    # some people rename them; so instead we look at the file content.
  11.362 +    # Grep'ing the first line is not enough: some people post-process
  11.363 +    # each Makefile.in and add a new line on top of each file to say so.
  11.364 +    # Grep'ing the whole file is not good either: AIX grep has a line
  11.365 +    # limit of 2048, but all sed's we know have understand at least 4000.
  11.366 +    if sed -n 's,^#.*generated by automake.*,X,p' "$mf" | grep X >/dev/null 2>&1; then
  11.367 +      dirpart=`AS_DIRNAME("$mf")`
  11.368 +    else
  11.369 +      continue
  11.370 +    fi
  11.371 +    # Extract the definition of DEPDIR, am__include, and am__quote
  11.372 +    # from the Makefile without running `make'.
  11.373 +    DEPDIR=`sed -n 's/^DEPDIR = //p' < "$mf"`
  11.374 +    test -z "$DEPDIR" && continue
  11.375 +    am__include=`sed -n 's/^am__include = //p' < "$mf"`
  11.376 +    test -z "am__include" && continue
  11.377 +    am__quote=`sed -n 's/^am__quote = //p' < "$mf"`
  11.378 +    # When using ansi2knr, U may be empty or an underscore; expand it
  11.379 +    U=`sed -n 's/^U = //p' < "$mf"`
  11.380 +    # Find all dependency output files, they are included files with
  11.381 +    # $(DEPDIR) in their names.  We invoke sed twice because it is the
  11.382 +    # simplest approach to changing $(DEPDIR) to its actual value in the
  11.383 +    # expansion.
  11.384 +    for file in `sed -n "
  11.385 +      s/^$am__include $am__quote\(.*(DEPDIR).*\)$am__quote"'$/\1/p' <"$mf" | \
  11.386 +	 sed -e 's/\$(DEPDIR)/'"$DEPDIR"'/g' -e 's/\$U/'"$U"'/g'`; do
  11.387 +      # Make sure the directory exists.
  11.388 +      test -f "$dirpart/$file" && continue
  11.389 +      fdir=`AS_DIRNAME(["$file"])`
  11.390 +      AS_MKDIR_P([$dirpart/$fdir])
  11.391 +      # echo "creating $dirpart/$file"
  11.392 +      echo '# dummy' > "$dirpart/$file"
  11.393 +    done
  11.394 +  done
  11.395 +}
  11.396 +])# _AM_OUTPUT_DEPENDENCY_COMMANDS
  11.397 +
  11.398 +
  11.399 +# AM_OUTPUT_DEPENDENCY_COMMANDS
  11.400 +# -----------------------------
  11.401 +# This macro should only be invoked once -- use via AC_REQUIRE.
  11.402 +#
  11.403 +# This code is only required when automatic dependency tracking
  11.404 +# is enabled.  FIXME.  This creates each `.P' file that we will
  11.405 +# need in order to bootstrap the dependency handling code.
  11.406 +AC_DEFUN([AM_OUTPUT_DEPENDENCY_COMMANDS],
  11.407 +[AC_CONFIG_COMMANDS([depfiles],
  11.408 +     [test x"$AMDEP_TRUE" != x"" || _AM_OUTPUT_DEPENDENCY_COMMANDS],
  11.409 +     [AMDEP_TRUE="$AMDEP_TRUE" ac_aux_dir="$ac_aux_dir"])
  11.410 +])
  11.411 +
  11.412 +# Do all the work for Automake.                             -*- Autoconf -*-
  11.413 +
  11.414 +# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004,
  11.415 +# 2005, 2006, 2008, 2009 Free Software Foundation, Inc.
  11.416 +#
  11.417 +# This file is free software; the Free Software Foundation
  11.418 +# gives unlimited permission to copy and/or distribute it,
  11.419 +# with or without modifications, as long as this notice is preserved.
  11.420 +
  11.421 +# serial 16
  11.422 +
  11.423 +# This macro actually does too much.  Some checks are only needed if
  11.424 +# your package does certain things.  But this isn't really a big deal.
  11.425 +
  11.426 +# AM_INIT_AUTOMAKE(PACKAGE, VERSION, [NO-DEFINE])
  11.427 +# AM_INIT_AUTOMAKE([OPTIONS])
  11.428 +# -----------------------------------------------
  11.429 +# The call with PACKAGE and VERSION arguments is the old style
  11.430 +# call (pre autoconf-2.50), which is being phased out.  PACKAGE
  11.431 +# and VERSION should now be passed to AC_INIT and removed from
  11.432 +# the call to AM_INIT_AUTOMAKE.
  11.433 +# We support both call styles for the transition.  After
  11.434 +# the next Automake release, Autoconf can make the AC_INIT
  11.435 +# arguments mandatory, and then we can depend on a new Autoconf
  11.436 +# release and drop the old call support.
  11.437 +AC_DEFUN([AM_INIT_AUTOMAKE],
  11.438 +[AC_PREREQ([2.62])dnl
  11.439 +dnl Autoconf wants to disallow AM_ names.  We explicitly allow
  11.440 +dnl the ones we care about.
  11.441 +m4_pattern_allow([^AM_[A-Z]+FLAGS$])dnl
  11.442 +AC_REQUIRE([AM_SET_CURRENT_AUTOMAKE_VERSION])dnl
  11.443 +AC_REQUIRE([AC_PROG_INSTALL])dnl
  11.444 +if test "`cd $srcdir && pwd`" != "`pwd`"; then
  11.445 +  # Use -I$(srcdir) only when $(srcdir) != ., so that make's output
  11.446 +  # is not polluted with repeated "-I."
  11.447 +  AC_SUBST([am__isrc], [' -I$(srcdir)'])_AM_SUBST_NOTMAKE([am__isrc])dnl
  11.448 +  # test to see if srcdir already configured
  11.449 +  if test -f $srcdir/config.status; then
  11.450 +    AC_MSG_ERROR([source directory already configured; run "make distclean" there first])
  11.451 +  fi
  11.452 +fi
  11.453 +
  11.454 +# test whether we have cygpath
  11.455 +if test -z "$CYGPATH_W"; then
  11.456 +  if (cygpath --version) >/dev/null 2>/dev/null; then
  11.457 +    CYGPATH_W='cygpath -w'
  11.458 +  else
  11.459 +    CYGPATH_W=echo
  11.460 +  fi
  11.461 +fi
  11.462 +AC_SUBST([CYGPATH_W])
  11.463 +
  11.464 +# Define the identity of the package.
  11.465 +dnl Distinguish between old-style and new-style calls.
  11.466 +m4_ifval([$2],
  11.467 +[m4_ifval([$3], [_AM_SET_OPTION([no-define])])dnl
  11.468 + AC_SUBST([PACKAGE], [$1])dnl
  11.469 + AC_SUBST([VERSION], [$2])],
  11.470 +[_AM_SET_OPTIONS([$1])dnl
  11.471 +dnl Diagnose old-style AC_INIT with new-style AM_AUTOMAKE_INIT.
  11.472 +m4_if(m4_ifdef([AC_PACKAGE_NAME], 1)m4_ifdef([AC_PACKAGE_VERSION], 1), 11,,
  11.473 +  [m4_fatal([AC_INIT should be called with package and version arguments])])dnl
  11.474 + AC_SUBST([PACKAGE], ['AC_PACKAGE_TARNAME'])dnl
  11.475 + AC_SUBST([VERSION], ['AC_PACKAGE_VERSION'])])dnl
  11.476 +
  11.477 +_AM_IF_OPTION([no-define],,
  11.478 +[AC_DEFINE_UNQUOTED(PACKAGE, "$PACKAGE", [Name of package])
  11.479 + AC_DEFINE_UNQUOTED(VERSION, "$VERSION", [Version number of package])])dnl
  11.480 +
  11.481 +# Some tools Automake needs.
  11.482 +AC_REQUIRE([AM_SANITY_CHECK])dnl
  11.483 +AC_REQUIRE([AC_ARG_PROGRAM])dnl
  11.484 +AM_MISSING_PROG(ACLOCAL, aclocal-${am__api_version})
  11.485 +AM_MISSING_PROG(AUTOCONF, autoconf)
  11.486 +AM_MISSING_PROG(AUTOMAKE, automake-${am__api_version})
  11.487 +AM_MISSING_PROG(AUTOHEADER, autoheader)
  11.488 +AM_MISSING_PROG(MAKEINFO, makeinfo)
  11.489 +AC_REQUIRE([AM_PROG_INSTALL_SH])dnl
  11.490 +AC_REQUIRE([AM_PROG_INSTALL_STRIP])dnl
  11.491 +AC_REQUIRE([AM_PROG_MKDIR_P])dnl
  11.492 +# We need awk for the "check" target.  The system "awk" is bad on
  11.493 +# some platforms.
  11.494 +AC_REQUIRE([AC_PROG_AWK])dnl
  11.495 +AC_REQUIRE([AC_PROG_MAKE_SET])dnl
  11.496 +AC_REQUIRE([AM_SET_LEADING_DOT])dnl
  11.497 +_AM_IF_OPTION([tar-ustar], [_AM_PROG_TAR([ustar])],
  11.498 +	      [_AM_IF_OPTION([tar-pax], [_AM_PROG_TAR([pax])],
  11.499 +			     [_AM_PROG_TAR([v7])])])
  11.500 +_AM_IF_OPTION([no-dependencies],,
  11.501 +[AC_PROVIDE_IFELSE([AC_PROG_CC],
  11.502 +		  [_AM_DEPENDENCIES(CC)],
  11.503 +		  [define([AC_PROG_CC],
  11.504 +			  defn([AC_PROG_CC])[_AM_DEPENDENCIES(CC)])])dnl
  11.505 +AC_PROVIDE_IFELSE([AC_PROG_CXX],
  11.506 +		  [_AM_DEPENDENCIES(CXX)],
  11.507 +		  [define([AC_PROG_CXX],
  11.508 +			  defn([AC_PROG_CXX])[_AM_DEPENDENCIES(CXX)])])dnl
  11.509 +AC_PROVIDE_IFELSE([AC_PROG_OBJC],
  11.510 +		  [_AM_DEPENDENCIES(OBJC)],
  11.511 +		  [define([AC_PROG_OBJC],
  11.512 +			  defn([AC_PROG_OBJC])[_AM_DEPENDENCIES(OBJC)])])dnl
  11.513 +])
  11.514 +_AM_IF_OPTION([silent-rules], [AC_REQUIRE([AM_SILENT_RULES])])dnl
  11.515 +dnl The `parallel-tests' driver may need to know about EXEEXT, so add the
  11.516 +dnl `am__EXEEXT' conditional if _AM_COMPILER_EXEEXT was seen.  This macro
  11.517 +dnl is hooked onto _AC_COMPILER_EXEEXT early, see below.
  11.518 +AC_CONFIG_COMMANDS_PRE(dnl
  11.519 +[m4_provide_if([_AM_COMPILER_EXEEXT],
  11.520 +  [AM_CONDITIONAL([am__EXEEXT], [test -n "$EXEEXT"])])])dnl
  11.521 +])
  11.522 +
  11.523 +dnl Hook into `_AC_COMPILER_EXEEXT' early to learn its expansion.  Do not
  11.524 +dnl add the conditional right here, as _AC_COMPILER_EXEEXT may be further
  11.525 +dnl mangled by Autoconf and run in a shell conditional statement.
  11.526 +m4_define([_AC_COMPILER_EXEEXT],
  11.527 +m4_defn([_AC_COMPILER_EXEEXT])[m4_provide([_AM_COMPILER_EXEEXT])])
  11.528 +
  11.529 +
  11.530 +# When config.status generates a header, we must update the stamp-h file.
  11.531 +# This file resides in the same directory as the config header
  11.532 +# that is generated.  The stamp files are numbered to have different names.
  11.533 +
  11.534 +# Autoconf calls _AC_AM_CONFIG_HEADER_HOOK (when defined) in the
  11.535 +# loop where config.status creates the headers, so we can generate
  11.536 +# our stamp files there.
  11.537 +AC_DEFUN([_AC_AM_CONFIG_HEADER_HOOK],
  11.538 +[# Compute $1's index in $config_headers.
  11.539 +_am_arg=$1
  11.540 +_am_stamp_count=1
  11.541 +for _am_header in $config_headers :; do
  11.542 +  case $_am_header in
  11.543 +    $_am_arg | $_am_arg:* )
  11.544 +      break ;;
  11.545 +    * )
  11.546 +      _am_stamp_count=`expr $_am_stamp_count + 1` ;;
  11.547 +  esac
  11.548 +done
  11.549 +echo "timestamp for $_am_arg" >`AS_DIRNAME(["$_am_arg"])`/stamp-h[]$_am_stamp_count])
  11.550 +
  11.551 +# Copyright (C) 2001, 2003, 2005, 2008  Free Software Foundation, Inc.
  11.552 +#
  11.553 +# This file is free software; the Free Software Foundation
  11.554 +# gives unlimited permission to copy and/or distribute it,
  11.555 +# with or without modifications, as long as this notice is preserved.
  11.556 +
  11.557 +# AM_PROG_INSTALL_SH
  11.558 +# ------------------
  11.559 +# Define $install_sh.
  11.560 +AC_DEFUN([AM_PROG_INSTALL_SH],
  11.561 +[AC_REQUIRE([AM_AUX_DIR_EXPAND])dnl
  11.562 +if test x"${install_sh}" != xset; then
  11.563 +  case $am_aux_dir in
  11.564 +  *\ * | *\	*)
  11.565 +    install_sh="\${SHELL} '$am_aux_dir/install-sh'" ;;
  11.566 +  *)
  11.567 +    install_sh="\${SHELL} $am_aux_dir/install-sh"
  11.568 +  esac
  11.569 +fi
  11.570 +AC_SUBST(install_sh)])
  11.571 +
  11.572 +# Copyright (C) 2003, 2005  Free Software Foundation, Inc.
  11.573 +#
  11.574 +# This file is free software; the Free Software Foundation
  11.575 +# gives unlimited permission to copy and/or distribute it,
  11.576 +# with or without modifications, as long as this notice is preserved.
  11.577 +
  11.578 +# serial 2
  11.579 +
  11.580 +# Check whether the underlying file-system supports filenames
  11.581 +# with a leading dot.  For instance MS-DOS doesn't.
  11.582 +AC_DEFUN([AM_SET_LEADING_DOT],
  11.583 +[rm -rf .tst 2>/dev/null
  11.584 +mkdir .tst 2>/dev/null
  11.585 +if test -d .tst; then
  11.586 +  am__leading_dot=.
  11.587 +else
  11.588 +  am__leading_dot=_
  11.589 +fi
  11.590 +rmdir .tst 2>/dev/null
  11.591 +AC_SUBST([am__leading_dot])])
  11.592 +
  11.593 +# Check to see how 'make' treats includes.	            -*- Autoconf -*-
  11.594 +
  11.595 +# Copyright (C) 2001, 2002, 2003, 2005, 2009  Free Software Foundation, Inc.
  11.596 +#
  11.597 +# This file is free software; the Free Software Foundation
  11.598 +# gives unlimited permission to copy and/or distribute it,
  11.599 +# with or without modifications, as long as this notice is preserved.
  11.600 +
  11.601 +# serial 4
  11.602 +
  11.603 +# AM_MAKE_INCLUDE()
  11.604 +# -----------------
  11.605 +# Check to see how make treats includes.
  11.606 +AC_DEFUN([AM_MAKE_INCLUDE],
  11.607 +[am_make=${MAKE-make}
  11.608 +cat > confinc << 'END'
  11.609 +am__doit:
  11.610 +	@echo this is the am__doit target
  11.611 +.PHONY: am__doit
  11.612 +END
  11.613 +# If we don't find an include directive, just comment out the code.
  11.614 +AC_MSG_CHECKING([for style of include used by $am_make])
  11.615 +am__include="#"
  11.616 +am__quote=
  11.617 +_am_result=none
  11.618 +# First try GNU make style include.
  11.619 +echo "include confinc" > confmf
  11.620 +# Ignore all kinds of additional output from `make'.
  11.621 +case `$am_make -s -f confmf 2> /dev/null` in #(
  11.622 +*the\ am__doit\ target*)
  11.623 +  am__include=include
  11.624 +  am__quote=
  11.625 +  _am_result=GNU
  11.626 +  ;;
  11.627 +esac
  11.628 +# Now try BSD make style include.
  11.629 +if test "$am__include" = "#"; then
  11.630 +   echo '.include "confinc"' > confmf
  11.631 +   case `$am_make -s -f confmf 2> /dev/null` in #(
  11.632 +   *the\ am__doit\ target*)
  11.633 +     am__include=.include
  11.634 +     am__quote="\""
  11.635 +     _am_result=BSD
  11.636 +     ;;
  11.637 +   esac
  11.638 +fi
  11.639 +AC_SUBST([am__include])
  11.640 +AC_SUBST([am__quote])
  11.641 +AC_MSG_RESULT([$_am_result])
  11.642 +rm -f confinc confmf
  11.643 +])
  11.644 +
  11.645 +# Fake the existence of programs that GNU maintainers use.  -*- Autoconf -*-
  11.646 +
  11.647 +# Copyright (C) 1997, 1999, 2000, 2001, 2003, 2004, 2005, 2008
  11.648 +# Free Software Foundation, Inc.
  11.649 +#
  11.650 +# This file is free software; the Free Software Foundation
  11.651 +# gives unlimited permission to copy and/or distribute it,
  11.652 +# with or without modifications, as long as this notice is preserved.
  11.653 +
  11.654 +# serial 6
  11.655 +
  11.656 +# AM_MISSING_PROG(NAME, PROGRAM)
  11.657 +# ------------------------------
  11.658 +AC_DEFUN([AM_MISSING_PROG],
  11.659 +[AC_REQUIRE([AM_MISSING_HAS_RUN])
  11.660 +$1=${$1-"${am_missing_run}$2"}
  11.661 +AC_SUBST($1)])
  11.662 +
  11.663 +
  11.664 +# AM_MISSING_HAS_RUN
  11.665 +# ------------------
  11.666 +# Define MISSING if not defined so far and test if it supports --run.
  11.667 +# If it does, set am_missing_run to use it, otherwise, to nothing.
  11.668 +AC_DEFUN([AM_MISSING_HAS_RUN],
  11.669 +[AC_REQUIRE([AM_AUX_DIR_EXPAND])dnl
  11.670 +AC_REQUIRE_AUX_FILE([missing])dnl
  11.671 +if test x"${MISSING+set}" != xset; then
  11.672 +  case $am_aux_dir in
  11.673 +  *\ * | *\	*)
  11.674 +    MISSING="\${SHELL} \"$am_aux_dir/missing\"" ;;
  11.675 +  *)
  11.676 +    MISSING="\${SHELL} $am_aux_dir/missing" ;;
  11.677 +  esac
  11.678 +fi
  11.679 +# Use eval to expand $SHELL
  11.680 +if eval "$MISSING --run true"; then
  11.681 +  am_missing_run="$MISSING --run "
  11.682 +else
  11.683 +  am_missing_run=
  11.684 +  AC_MSG_WARN([`missing' script is too old or missing])
  11.685 +fi
  11.686 +])
  11.687 +
  11.688 +# Copyright (C) 2003, 2004, 2005, 2006  Free Software Foundation, Inc.
  11.689 +#
  11.690 +# This file is free software; the Free Software Foundation
  11.691 +# gives unlimited permission to copy and/or distribute it,
  11.692 +# with or without modifications, as long as this notice is preserved.
  11.693 +
  11.694 +# AM_PROG_MKDIR_P
  11.695 +# ---------------
  11.696 +# Check for `mkdir -p'.
  11.697 +AC_DEFUN([AM_PROG_MKDIR_P],
  11.698 +[AC_PREREQ([2.60])dnl
  11.699 +AC_REQUIRE([AC_PROG_MKDIR_P])dnl
  11.700 +dnl Automake 1.8 to 1.9.6 used to define mkdir_p.  We now use MKDIR_P,
  11.701 +dnl while keeping a definition of mkdir_p for backward compatibility.
  11.702 +dnl @MKDIR_P@ is magic: AC_OUTPUT adjusts its value for each Makefile.
  11.703 +dnl However we cannot define mkdir_p as $(MKDIR_P) for the sake of
  11.704 +dnl Makefile.ins that do not define MKDIR_P, so we do our own
  11.705 +dnl adjustment using top_builddir (which is defined more often than
  11.706 +dnl MKDIR_P).
  11.707 +AC_SUBST([mkdir_p], ["$MKDIR_P"])dnl
  11.708 +case $mkdir_p in
  11.709 +  [[\\/$]]* | ?:[[\\/]]*) ;;
  11.710 +  */*) mkdir_p="\$(top_builddir)/$mkdir_p" ;;
  11.711 +esac
  11.712 +])
  11.713 +
  11.714 +# Helper functions for option handling.                     -*- Autoconf -*-
  11.715 +
  11.716 +# Copyright (C) 2001, 2002, 2003, 2005, 2008  Free Software Foundation, Inc.
  11.717 +#
  11.718 +# This file is free software; the Free Software Foundation
  11.719 +# gives unlimited permission to copy and/or distribute it,
  11.720 +# with or without modifications, as long as this notice is preserved.
  11.721 +
  11.722 +# serial 4
  11.723 +
  11.724 +# _AM_MANGLE_OPTION(NAME)
  11.725 +# -----------------------
  11.726 +AC_DEFUN([_AM_MANGLE_OPTION],
  11.727 +[[_AM_OPTION_]m4_bpatsubst($1, [[^a-zA-Z0-9_]], [_])])
  11.728 +
  11.729 +# _AM_SET_OPTION(NAME)
  11.730 +# ------------------------------
  11.731 +# Set option NAME.  Presently that only means defining a flag for this option.
  11.732 +AC_DEFUN([_AM_SET_OPTION],
  11.733 +[m4_define(_AM_MANGLE_OPTION([$1]), 1)])
  11.734 +
  11.735 +# _AM_SET_OPTIONS(OPTIONS)
  11.736 +# ----------------------------------
  11.737 +# OPTIONS is a space-separated list of Automake options.
  11.738 +AC_DEFUN([_AM_SET_OPTIONS],
  11.739 +[m4_foreach_w([_AM_Option], [$1], [_AM_SET_OPTION(_AM_Option)])])
  11.740 +
  11.741 +# _AM_IF_OPTION(OPTION, IF-SET, [IF-NOT-SET])
  11.742 +# -------------------------------------------
  11.743 +# Execute IF-SET if OPTION is set, IF-NOT-SET otherwise.
  11.744 +AC_DEFUN([_AM_IF_OPTION],
  11.745 +[m4_ifset(_AM_MANGLE_OPTION([$1]), [$2], [$3])])
  11.746 +
  11.747 +# Check to make sure that the build environment is sane.    -*- Autoconf -*-
  11.748 +
  11.749 +# Copyright (C) 1996, 1997, 2000, 2001, 2003, 2005, 2008
  11.750 +# Free Software Foundation, Inc.
  11.751 +#
  11.752 +# This file is free software; the Free Software Foundation
  11.753 +# gives unlimited permission to copy and/or distribute it,
  11.754 +# with or without modifications, as long as this notice is preserved.
  11.755 +
  11.756 +# serial 5
  11.757 +
  11.758 +# AM_SANITY_CHECK
  11.759 +# ---------------
  11.760 +AC_DEFUN([AM_SANITY_CHECK],
  11.761 +[AC_MSG_CHECKING([whether build environment is sane])
  11.762 +# Just in case
  11.763 +sleep 1
  11.764 +echo timestamp > conftest.file
  11.765 +# Reject unsafe characters in $srcdir or the absolute working directory
  11.766 +# name.  Accept space and tab only in the latter.
  11.767 +am_lf='
  11.768 +'
  11.769 +case `pwd` in
  11.770 +  *[[\\\"\#\$\&\'\`$am_lf]]*)
  11.771 +    AC_MSG_ERROR([unsafe absolute working directory name]);;
  11.772 +esac
  11.773 +case $srcdir in
  11.774 +  *[[\\\"\#\$\&\'\`$am_lf\ \	]]*)
  11.775 +    AC_MSG_ERROR([unsafe srcdir value: `$srcdir']);;
  11.776 +esac
  11.777 +
  11.778 +# Do `set' in a subshell so we don't clobber the current shell's
  11.779 +# arguments.  Must try -L first in case configure is actually a
  11.780 +# symlink; some systems play weird games with the mod time of symlinks
  11.781 +# (eg FreeBSD returns the mod time of the symlink's containing
  11.782 +# directory).
  11.783 +if (
  11.784 +   set X `ls -Lt "$srcdir/configure" conftest.file 2> /dev/null`
  11.785 +   if test "$[*]" = "X"; then
  11.786 +      # -L didn't work.
  11.787 +      set X `ls -t "$srcdir/configure" conftest.file`
  11.788 +   fi
  11.789 +   rm -f conftest.file
  11.790 +   if test "$[*]" != "X $srcdir/configure conftest.file" \
  11.791 +      && test "$[*]" != "X conftest.file $srcdir/configure"; then
  11.792 +
  11.793 +      # If neither matched, then we have a broken ls.  This can happen
  11.794 +      # if, for instance, CONFIG_SHELL is bash and it inherits a
  11.795 +      # broken ls alias from the environment.  This has actually
  11.796 +      # happened.  Such a system could not be considered "sane".
  11.797 +      AC_MSG_ERROR([ls -t appears to fail.  Make sure there is not a broken
  11.798 +alias in your environment])
  11.799 +   fi
  11.800 +
  11.801 +   test "$[2]" = conftest.file
  11.802 +   )
  11.803 +then
  11.804 +   # Ok.
  11.805 +   :
  11.806 +else
  11.807 +   AC_MSG_ERROR([newly created file is older than distributed files!
  11.808 +Check your system clock])
  11.809 +fi
  11.810 +AC_MSG_RESULT(yes)])
  11.811 +
  11.812 +# Copyright (C) 2001, 2003, 2005  Free Software Foundation, Inc.
  11.813 +#
  11.814 +# This file is free software; the Free Software Foundation
  11.815 +# gives unlimited permission to copy and/or distribute it,
  11.816 +# with or without modifications, as long as this notice is preserved.
  11.817 +
  11.818 +# AM_PROG_INSTALL_STRIP
  11.819 +# ---------------------
  11.820 +# One issue with vendor `install' (even GNU) is that you can't
  11.821 +# specify the program used to strip binaries.  This is especially
  11.822 +# annoying in cross-compiling environments, where the build's strip
  11.823 +# is unlikely to handle the host's binaries.
  11.824 +# Fortunately install-sh will honor a STRIPPROG variable, so we
  11.825 +# always use install-sh in `make install-strip', and initialize
  11.826 +# STRIPPROG with the value of the STRIP variable (set by the user).
  11.827 +AC_DEFUN([AM_PROG_INSTALL_STRIP],
  11.828 +[AC_REQUIRE([AM_PROG_INSTALL_SH])dnl
  11.829 +# Installed binaries are usually stripped using `strip' when the user
  11.830 +# run `make install-strip'.  However `strip' might not be the right
  11.831 +# tool to use in cross-compilation environments, therefore Automake
  11.832 +# will honor the `STRIP' environment variable to overrule this program.
  11.833 +dnl Don't test for $cross_compiling = yes, because it might be `maybe'.
  11.834 +if test "$cross_compiling" != no; then
  11.835 +  AC_CHECK_TOOL([STRIP], [strip], :)
  11.836 +fi
  11.837 +INSTALL_STRIP_PROGRAM="\$(install_sh) -c -s"
  11.838 +AC_SUBST([INSTALL_STRIP_PROGRAM])])
  11.839 +
  11.840 +# Copyright (C) 2006, 2008  Free Software Foundation, Inc.
  11.841 +#
  11.842 +# This file is free software; the Free Software Foundation
  11.843 +# gives unlimited permission to copy and/or distribute it,
  11.844 +# with or without modifications, as long as this notice is preserved.
  11.845 +
  11.846 +# serial 2
  11.847 +
  11.848 +# _AM_SUBST_NOTMAKE(VARIABLE)
  11.849 +# ---------------------------
  11.850 +# Prevent Automake from outputting VARIABLE = @VARIABLE@ in Makefile.in.
  11.851 +# This macro is traced by Automake.
  11.852 +AC_DEFUN([_AM_SUBST_NOTMAKE])
  11.853 +
  11.854 +# AM_SUBST_NOTMAKE(VARIABLE)
  11.855 +# ---------------------------
  11.856 +# Public sister of _AM_SUBST_NOTMAKE.
  11.857 +AC_DEFUN([AM_SUBST_NOTMAKE], [_AM_SUBST_NOTMAKE($@)])
  11.858 +
  11.859 +# Check how to create a tarball.                            -*- Autoconf -*-
  11.860 +
  11.861 +# Copyright (C) 2004, 2005  Free Software Foundation, Inc.
  11.862 +#
  11.863 +# This file is free software; the Free Software Foundation
  11.864 +# gives unlimited permission to copy and/or distribute it,
  11.865 +# with or without modifications, as long as this notice is preserved.
  11.866 +
  11.867 +# serial 2
  11.868 +
  11.869 +# _AM_PROG_TAR(FORMAT)
  11.870 +# --------------------
  11.871 +# Check how to create a tarball in format FORMAT.
  11.872 +# FORMAT should be one of `v7', `ustar', or `pax'.
  11.873 +#
  11.874 +# Substitute a variable $(am__tar) that is a command
  11.875 +# writing to stdout a FORMAT-tarball containing the directory
  11.876 +# $tardir.
  11.877 +#     tardir=directory && $(am__tar) > result.tar
  11.878 +#
  11.879 +# Substitute a variable $(am__untar) that extract such
  11.880 +# a tarball read from stdin.
  11.881 +#     $(am__untar) < result.tar
  11.882 +AC_DEFUN([_AM_PROG_TAR],
  11.883 +[# Always define AMTAR for backward compatibility.
  11.884 +AM_MISSING_PROG([AMTAR], [tar])
  11.885 +m4_if([$1], [v7],
  11.886 +     [am__tar='${AMTAR} chof - "$$tardir"'; am__untar='${AMTAR} xf -'],
  11.887 +     [m4_case([$1], [ustar],, [pax],,
  11.888 +              [m4_fatal([Unknown tar format])])
  11.889 +AC_MSG_CHECKING([how to create a $1 tar archive])
  11.890 +# Loop over all known methods to create a tar archive until one works.
  11.891 +_am_tools='gnutar m4_if([$1], [ustar], [plaintar]) pax cpio none'
  11.892 +_am_tools=${am_cv_prog_tar_$1-$_am_tools}
  11.893 +# Do not fold the above two line into one, because Tru64 sh and
  11.894 +# Solaris sh will not grok spaces in the rhs of `-'.
  11.895 +for _am_tool in $_am_tools
  11.896 +do
  11.897 +  case $_am_tool in
  11.898 +  gnutar)
  11.899 +    for _am_tar in tar gnutar gtar;
  11.900 +    do
  11.901 +      AM_RUN_LOG([$_am_tar --version]) && break
  11.902 +    done
  11.903 +    am__tar="$_am_tar --format=m4_if([$1], [pax], [posix], [$1]) -chf - "'"$$tardir"'
  11.904 +    am__tar_="$_am_tar --format=m4_if([$1], [pax], [posix], [$1]) -chf - "'"$tardir"'
  11.905 +    am__untar="$_am_tar -xf -"
  11.906 +    ;;
  11.907 +  plaintar)
  11.908 +    # Must skip GNU tar: if it does not support --format= it doesn't create
  11.909 +    # ustar tarball either.
  11.910 +    (tar --version) >/dev/null 2>&1 && continue
  11.911 +    am__tar='tar chf - "$$tardir"'
  11.912 +    am__tar_='tar chf - "$tardir"'
  11.913 +    am__untar='tar xf -'
  11.914 +    ;;
  11.915 +  pax)
  11.916 +    am__tar='pax -L -x $1 -w "$$tardir"'
  11.917 +    am__tar_='pax -L -x $1 -w "$tardir"'
  11.918 +    am__untar='pax -r'
  11.919 +    ;;
  11.920 +  cpio)
  11.921 +    am__tar='find "$$tardir" -print | cpio -o -H $1 -L'
  11.922 +    am__tar_='find "$tardir" -print | cpio -o -H $1 -L'
  11.923 +    am__untar='cpio -i -H $1 -d'
  11.924 +    ;;
  11.925 +  none)
  11.926 +    am__tar=false
  11.927 +    am__tar_=false
  11.928 +    am__untar=false
  11.929 +    ;;
  11.930 +  esac
  11.931 +
  11.932 +  # If the value was cached, stop now.  We just wanted to have am__tar
  11.933 +  # and am__untar set.
  11.934 +  test -n "${am_cv_prog_tar_$1}" && break
  11.935 +
  11.936 +  # tar/untar a dummy directory, and stop if the command works
  11.937 +  rm -rf conftest.dir
  11.938 +  mkdir conftest.dir
  11.939 +  echo GrepMe > conftest.dir/file
  11.940 +  AM_RUN_LOG([tardir=conftest.dir && eval $am__tar_ >conftest.tar])
  11.941 +  rm -rf conftest.dir
  11.942 +  if test -s conftest.tar; then
  11.943 +    AM_RUN_LOG([$am__untar <conftest.tar])
  11.944 +    grep GrepMe conftest.dir/file >/dev/null 2>&1 && break
  11.945 +  fi
  11.946 +done
  11.947 +rm -rf conftest.dir
  11.948 +
  11.949 +AC_CACHE_VAL([am_cv_prog_tar_$1], [am_cv_prog_tar_$1=$_am_tool])
  11.950 +AC_MSG_RESULT([$am_cv_prog_tar_$1])])
  11.951 +AC_SUBST([am__tar])
  11.952 +AC_SUBST([am__untar])
  11.953 +]) # _AM_PROG_TAR
  11.954 +
  11.955 +m4_include([m4/libtool.m4])
  11.956 +m4_include([m4/ltoptions.m4])
  11.957 +m4_include([m4/ltsugar.m4])
  11.958 +m4_include([m4/ltversion.m4])
  11.959 +m4_include([m4/lt~obsolete.m4])
    12.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    12.2 +++ b/deps/glpk/config.guess	Sun Nov 06 20:59:10 2011 +0100
    12.3 @@ -0,0 +1,1501 @@
    12.4 +#! /bin/sh
    12.5 +# Attempt to guess a canonical system name.
    12.6 +#   Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
    12.7 +#   2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009
    12.8 +#   Free Software Foundation, Inc.
    12.9 +
   12.10 +timestamp='2009-11-20'
   12.11 +
   12.12 +# This file is free software; you can redistribute it and/or modify it
   12.13 +# under the terms of the GNU General Public License as published by
   12.14 +# the Free Software Foundation; either version 2 of the License, or
   12.15 +# (at your option) any later version.
   12.16 +#
   12.17 +# This program is distributed in the hope that it will be useful, but
   12.18 +# WITHOUT ANY WARRANTY; without even the implied warranty of
   12.19 +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   12.20 +# General Public License for more details.
   12.21 +#
   12.22 +# You should have received a copy of the GNU General Public License
   12.23 +# along with this program; if not, write to the Free Software
   12.24 +# Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA
   12.25 +# 02110-1301, USA.
   12.26 +#
   12.27 +# As a special exception to the GNU General Public License, if you
   12.28 +# distribute this file as part of a program that contains a
   12.29 +# configuration script generated by Autoconf, you may include it under
   12.30 +# the same distribution terms that you use for the rest of that program.
   12.31 +
   12.32 +
   12.33 +# Originally written by Per Bothner.  Please send patches (context
   12.34 +# diff format) to <config-patches@gnu.org> and include a ChangeLog
   12.35 +# entry.
   12.36 +#
   12.37 +# This script attempts to guess a canonical system name similar to
   12.38 +# config.sub.  If it succeeds, it prints the system name on stdout, and
   12.39 +# exits with 0.  Otherwise, it exits with 1.
   12.40 +#
   12.41 +# You can get the latest version of this script from:
   12.42 +# http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.guess;hb=HEAD
   12.43 +
   12.44 +me=`echo "$0" | sed -e 's,.*/,,'`
   12.45 +
   12.46 +usage="\
   12.47 +Usage: $0 [OPTION]
   12.48 +
   12.49 +Output the configuration name of the system \`$me' is run on.
   12.50 +
   12.51 +Operation modes:
   12.52 +  -h, --help         print this help, then exit
   12.53 +  -t, --time-stamp   print date of last modification, then exit
   12.54 +  -v, --version      print version number, then exit
   12.55 +
   12.56 +Report bugs and patches to <config-patches@gnu.org>."
   12.57 +
   12.58 +version="\
   12.59 +GNU config.guess ($timestamp)
   12.60 +
   12.61 +Originally written by Per Bothner.
   12.62 +Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001,
   12.63 +2002, 2003, 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc.
   12.64 +
   12.65 +This is free software; see the source for copying conditions.  There is NO
   12.66 +warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE."
   12.67 +
   12.68 +help="
   12.69 +Try \`$me --help' for more information."
   12.70 +
   12.71 +# Parse command line
   12.72 +while test $# -gt 0 ; do
   12.73 +  case $1 in
   12.74 +    --time-stamp | --time* | -t )
   12.75 +       echo "$timestamp" ; exit ;;
   12.76 +    --version | -v )
   12.77 +       echo "$version" ; exit ;;
   12.78 +    --help | --h* | -h )
   12.79 +       echo "$usage"; exit ;;
   12.80 +    -- )     # Stop option processing
   12.81 +       shift; break ;;
   12.82 +    - )	# Use stdin as input.
   12.83 +       break ;;
   12.84 +    -* )
   12.85 +       echo "$me: invalid option $1$help" >&2
   12.86 +       exit 1 ;;
   12.87 +    * )
   12.88 +       break ;;
   12.89 +  esac
   12.90 +done
   12.91 +
   12.92 +if test $# != 0; then
   12.93 +  echo "$me: too many arguments$help" >&2
   12.94 +  exit 1
   12.95 +fi
   12.96 +
   12.97 +trap 'exit 1' 1 2 15
   12.98 +
   12.99 +# CC_FOR_BUILD -- compiler used by this script. Note that the use of a
  12.100 +# compiler to aid in system detection is discouraged as it requires
  12.101 +# temporary files to be created and, as you can see below, it is a
  12.102 +# headache to deal with in a portable fashion.
  12.103 +
  12.104 +# Historically, `CC_FOR_BUILD' used to be named `HOST_CC'. We still
  12.105 +# use `HOST_CC' if defined, but it is deprecated.
  12.106 +
  12.107 +# Portable tmp directory creation inspired by the Autoconf team.
  12.108 +
  12.109 +set_cc_for_build='
  12.110 +trap "exitcode=\$?; (rm -f \$tmpfiles 2>/dev/null; rmdir \$tmp 2>/dev/null) && exit \$exitcode" 0 ;
  12.111 +trap "rm -f \$tmpfiles 2>/dev/null; rmdir \$tmp 2>/dev/null; exit 1" 1 2 13 15 ;
  12.112 +: ${TMPDIR=/tmp} ;
  12.113 + { tmp=`(umask 077 && mktemp -d "$TMPDIR/cgXXXXXX") 2>/dev/null` && test -n "$tmp" && test -d "$tmp" ; } ||
  12.114 + { test -n "$RANDOM" && tmp=$TMPDIR/cg$$-$RANDOM && (umask 077 && mkdir $tmp) ; } ||
  12.115 + { tmp=$TMPDIR/cg-$$ && (umask 077 && mkdir $tmp) && echo "Warning: creating insecure temp directory" >&2 ; } ||
  12.116 + { echo "$me: cannot create a temporary directory in $TMPDIR" >&2 ; exit 1 ; } ;
  12.117 +dummy=$tmp/dummy ;
  12.118 +tmpfiles="$dummy.c $dummy.o $dummy.rel $dummy" ;
  12.119 +case $CC_FOR_BUILD,$HOST_CC,$CC in
  12.120 + ,,)    echo "int x;" > $dummy.c ;
  12.121 +	for c in cc gcc c89 c99 ; do
  12.122 +	  if ($c -c -o $dummy.o $dummy.c) >/dev/null 2>&1 ; then
  12.123 +	     CC_FOR_BUILD="$c"; break ;
  12.124 +	  fi ;
  12.125 +	done ;
  12.126 +	if test x"$CC_FOR_BUILD" = x ; then
  12.127 +	  CC_FOR_BUILD=no_compiler_found ;
  12.128 +	fi
  12.129 +	;;
  12.130 + ,,*)   CC_FOR_BUILD=$CC ;;
  12.131 + ,*,*)  CC_FOR_BUILD=$HOST_CC ;;
  12.132 +esac ; set_cc_for_build= ;'
  12.133 +
  12.134 +# This is needed to find uname on a Pyramid OSx when run in the BSD universe.
  12.135 +# (ghazi@noc.rutgers.edu 1994-08-24)
  12.136 +if (test -f /.attbin/uname) >/dev/null 2>&1 ; then
  12.137 +	PATH=$PATH:/.attbin ; export PATH
  12.138 +fi
  12.139 +
  12.140 +UNAME_MACHINE=`(uname -m) 2>/dev/null` || UNAME_MACHINE=unknown
  12.141 +UNAME_RELEASE=`(uname -r) 2>/dev/null` || UNAME_RELEASE=unknown
  12.142 +UNAME_SYSTEM=`(uname -s) 2>/dev/null`  || UNAME_SYSTEM=unknown
  12.143 +UNAME_VERSION=`(uname -v) 2>/dev/null` || UNAME_VERSION=unknown
  12.144 +
  12.145 +# Note: order is significant - the case branches are not exclusive.
  12.146 +
  12.147 +case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in
  12.148 +    *:NetBSD:*:*)
  12.149 +	# NetBSD (nbsd) targets should (where applicable) match one or
  12.150 +	# more of the tupples: *-*-netbsdelf*, *-*-netbsdaout*,
  12.151 +	# *-*-netbsdecoff* and *-*-netbsd*.  For targets that recently
  12.152 +	# switched to ELF, *-*-netbsd* would select the old
  12.153 +	# object file format.  This provides both forward
  12.154 +	# compatibility and a consistent mechanism for selecting the
  12.155 +	# object file format.
  12.156 +	#
  12.157 +	# Note: NetBSD doesn't particularly care about the vendor
  12.158 +	# portion of the name.  We always set it to "unknown".
  12.159 +	sysctl="sysctl -n hw.machine_arch"
  12.160 +	UNAME_MACHINE_ARCH=`(/sbin/$sysctl 2>/dev/null || \
  12.161 +	    /usr/sbin/$sysctl 2>/dev/null || echo unknown)`
  12.162 +	case "${UNAME_MACHINE_ARCH}" in
  12.163 +	    armeb) machine=armeb-unknown ;;
  12.164 +	    arm*) machine=arm-unknown ;;
  12.165 +	    sh3el) machine=shl-unknown ;;
  12.166 +	    sh3eb) machine=sh-unknown ;;
  12.167 +	    sh5el) machine=sh5le-unknown ;;
  12.168 +	    *) machine=${UNAME_MACHINE_ARCH}-unknown ;;
  12.169 +	esac
  12.170 +	# The Operating System including object format, if it has switched
  12.171 +	# to ELF recently, or will in the future.
  12.172 +	case "${UNAME_MACHINE_ARCH}" in
  12.173 +	    arm*|i386|m68k|ns32k|sh3*|sparc|vax)
  12.174 +		eval $set_cc_for_build
  12.175 +		if echo __ELF__ | $CC_FOR_BUILD -E - 2>/dev/null \
  12.176 +			| grep -q __ELF__
  12.177 +		then
  12.178 +		    # Once all utilities can be ECOFF (netbsdecoff) or a.out (netbsdaout).
  12.179 +		    # Return netbsd for either.  FIX?
  12.180 +		    os=netbsd
  12.181 +		else
  12.182 +		    os=netbsdelf
  12.183 +		fi
  12.184 +		;;
  12.185 +	    *)
  12.186 +	        os=netbsd
  12.187 +		;;
  12.188 +	esac
  12.189 +	# The OS release
  12.190 +	# Debian GNU/NetBSD machines have a different userland, and
  12.191 +	# thus, need a distinct triplet. However, they do not need
  12.192 +	# kernel version information, so it can be replaced with a
  12.193 +	# suitable tag, in the style of linux-gnu.
  12.194 +	case "${UNAME_VERSION}" in
  12.195 +	    Debian*)
  12.196 +		release='-gnu'
  12.197 +		;;
  12.198 +	    *)
  12.199 +		release=`echo ${UNAME_RELEASE}|sed -e 's/[-_].*/\./'`
  12.200 +		;;
  12.201 +	esac
  12.202 +	# Since CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM:
  12.203 +	# contains redundant information, the shorter form:
  12.204 +	# CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM is used.
  12.205 +	echo "${machine}-${os}${release}"
  12.206 +	exit ;;
  12.207 +    *:OpenBSD:*:*)
  12.208 +	UNAME_MACHINE_ARCH=`arch | sed 's/OpenBSD.//'`
  12.209 +	echo ${UNAME_MACHINE_ARCH}-unknown-openbsd${UNAME_RELEASE}
  12.210 +	exit ;;
  12.211 +    *:ekkoBSD:*:*)
  12.212 +	echo ${UNAME_MACHINE}-unknown-ekkobsd${UNAME_RELEASE}
  12.213 +	exit ;;
  12.214 +    *:SolidBSD:*:*)
  12.215 +	echo ${UNAME_MACHINE}-unknown-solidbsd${UNAME_RELEASE}
  12.216 +	exit ;;
  12.217 +    macppc:MirBSD:*:*)
  12.218 +	echo powerpc-unknown-mirbsd${UNAME_RELEASE}
  12.219 +	exit ;;
  12.220 +    *:MirBSD:*:*)
  12.221 +	echo ${UNAME_MACHINE}-unknown-mirbsd${UNAME_RELEASE}
  12.222 +	exit ;;
  12.223 +    alpha:OSF1:*:*)
  12.224 +	case $UNAME_RELEASE in
  12.225 +	*4.0)
  12.226 +		UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $3}'`
  12.227 +		;;
  12.228 +	*5.*)
  12.229 +	        UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $4}'`
  12.230 +		;;
  12.231 +	esac
  12.232 +	# According to Compaq, /usr/sbin/psrinfo has been available on
  12.233 +	# OSF/1 and Tru64 systems produced since 1995.  I hope that
  12.234 +	# covers most systems running today.  This code pipes the CPU
  12.235 +	# types through head -n 1, so we only detect the type of CPU 0.
  12.236 +	ALPHA_CPU_TYPE=`/usr/sbin/psrinfo -v | sed -n -e 's/^  The alpha \(.*\) processor.*$/\1/p' | head -n 1`
  12.237 +	case "$ALPHA_CPU_TYPE" in
  12.238 +	    "EV4 (21064)")
  12.239 +		UNAME_MACHINE="alpha" ;;
  12.240 +	    "EV4.5 (21064)")
  12.241 +		UNAME_MACHINE="alpha" ;;
  12.242 +	    "LCA4 (21066/21068)")
  12.243 +		UNAME_MACHINE="alpha" ;;
  12.244 +	    "EV5 (21164)")
  12.245 +		UNAME_MACHINE="alphaev5" ;;
  12.246 +	    "EV5.6 (21164A)")
  12.247 +		UNAME_MACHINE="alphaev56" ;;
  12.248 +	    "EV5.6 (21164PC)")
  12.249 +		UNAME_MACHINE="alphapca56" ;;
  12.250 +	    "EV5.7 (21164PC)")
  12.251 +		UNAME_MACHINE="alphapca57" ;;
  12.252 +	    "EV6 (21264)")
  12.253 +		UNAME_MACHINE="alphaev6" ;;
  12.254 +	    "EV6.7 (21264A)")
  12.255 +		UNAME_MACHINE="alphaev67" ;;
  12.256 +	    "EV6.8CB (21264C)")
  12.257 +		UNAME_MACHINE="alphaev68" ;;
  12.258 +	    "EV6.8AL (21264B)")
  12.259 +		UNAME_MACHINE="alphaev68" ;;
  12.260 +	    "EV6.8CX (21264D)")
  12.261 +		UNAME_MACHINE="alphaev68" ;;
  12.262 +	    "EV6.9A (21264/EV69A)")
  12.263 +		UNAME_MACHINE="alphaev69" ;;
  12.264 +	    "EV7 (21364)")
  12.265 +		UNAME_MACHINE="alphaev7" ;;
  12.266 +	    "EV7.9 (21364A)")
  12.267 +		UNAME_MACHINE="alphaev79" ;;
  12.268 +	esac
  12.269 +	# A Pn.n version is a patched version.
  12.270 +	# A Vn.n version is a released version.
  12.271 +	# A Tn.n version is a released field test version.
  12.272 +	# A Xn.n version is an unreleased experimental baselevel.
  12.273 +	# 1.2 uses "1.2" for uname -r.
  12.274 +	echo ${UNAME_MACHINE}-dec-osf`echo ${UNAME_RELEASE} | sed -e 's/^[PVTX]//' | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'`
  12.275 +	exit ;;
  12.276 +    Alpha\ *:Windows_NT*:*)
  12.277 +	# How do we know it's Interix rather than the generic POSIX subsystem?
  12.278 +	# Should we change UNAME_MACHINE based on the output of uname instead
  12.279 +	# of the specific Alpha model?
  12.280 +	echo alpha-pc-interix
  12.281 +	exit ;;
  12.282 +    21064:Windows_NT:50:3)
  12.283 +	echo alpha-dec-winnt3.5
  12.284 +	exit ;;
  12.285 +    Amiga*:UNIX_System_V:4.0:*)
  12.286 +	echo m68k-unknown-sysv4
  12.287 +	exit ;;
  12.288 +    *:[Aa]miga[Oo][Ss]:*:*)
  12.289 +	echo ${UNAME_MACHINE}-unknown-amigaos
  12.290 +	exit ;;
  12.291 +    *:[Mm]orph[Oo][Ss]:*:*)
  12.292 +	echo ${UNAME_MACHINE}-unknown-morphos
  12.293 +	exit ;;
  12.294 +    *:OS/390:*:*)
  12.295 +	echo i370-ibm-openedition
  12.296 +	exit ;;
  12.297 +    *:z/VM:*:*)
  12.298 +	echo s390-ibm-zvmoe
  12.299 +	exit ;;
  12.300 +    *:OS400:*:*)
  12.301 +        echo powerpc-ibm-os400
  12.302 +	exit ;;
  12.303 +    arm:RISC*:1.[012]*:*|arm:riscix:1.[012]*:*)
  12.304 +	echo arm-acorn-riscix${UNAME_RELEASE}
  12.305 +	exit ;;
  12.306 +    arm:riscos:*:*|arm:RISCOS:*:*)
  12.307 +	echo arm-unknown-riscos
  12.308 +	exit ;;
  12.309 +    SR2?01:HI-UX/MPP:*:* | SR8000:HI-UX/MPP:*:*)
  12.310 +	echo hppa1.1-hitachi-hiuxmpp
  12.311 +	exit ;;
  12.312 +    Pyramid*:OSx*:*:* | MIS*:OSx*:*:* | MIS*:SMP_DC-OSx*:*:*)
  12.313 +	# akee@wpdis03.wpafb.af.mil (Earle F. Ake) contributed MIS and NILE.
  12.314 +	if test "`(/bin/universe) 2>/dev/null`" = att ; then
  12.315 +		echo pyramid-pyramid-sysv3
  12.316 +	else
  12.317 +		echo pyramid-pyramid-bsd
  12.318 +	fi
  12.319 +	exit ;;
  12.320 +    NILE*:*:*:dcosx)
  12.321 +	echo pyramid-pyramid-svr4
  12.322 +	exit ;;
  12.323 +    DRS?6000:unix:4.0:6*)
  12.324 +	echo sparc-icl-nx6
  12.325 +	exit ;;
  12.326 +    DRS?6000:UNIX_SV:4.2*:7* | DRS?6000:isis:4.2*:7*)
  12.327 +	case `/usr/bin/uname -p` in
  12.328 +	    sparc) echo sparc-icl-nx7; exit ;;
  12.329 +	esac ;;
  12.330 +    s390x:SunOS:*:*)
  12.331 +	echo ${UNAME_MACHINE}-ibm-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
  12.332 +	exit ;;
  12.333 +    sun4H:SunOS:5.*:*)
  12.334 +	echo sparc-hal-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
  12.335 +	exit ;;
  12.336 +    sun4*:SunOS:5.*:* | tadpole*:SunOS:5.*:*)
  12.337 +	echo sparc-sun-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
  12.338 +	exit ;;
  12.339 +    i86pc:AuroraUX:5.*:* | i86xen:AuroraUX:5.*:*)
  12.340 +	echo i386-pc-auroraux${UNAME_RELEASE}
  12.341 +	exit ;;
  12.342 +    i86pc:SunOS:5.*:* | i86xen:SunOS:5.*:*)
  12.343 +	eval $set_cc_for_build
  12.344 +	SUN_ARCH="i386"
  12.345 +	# If there is a compiler, see if it is configured for 64-bit objects.
  12.346 +	# Note that the Sun cc does not turn __LP64__ into 1 like gcc does.
  12.347 +	# This test works for both compilers.
  12.348 +	if [ "$CC_FOR_BUILD" != 'no_compiler_found' ]; then
  12.349 +	    if (echo '#ifdef __amd64'; echo IS_64BIT_ARCH; echo '#endif') | \
  12.350 +		(CCOPTS= $CC_FOR_BUILD -E - 2>/dev/null) | \
  12.351 +		grep IS_64BIT_ARCH >/dev/null
  12.352 +	    then
  12.353 +		SUN_ARCH="x86_64"
  12.354 +	    fi
  12.355 +	fi
  12.356 +	echo ${SUN_ARCH}-pc-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
  12.357 +	exit ;;
  12.358 +    sun4*:SunOS:6*:*)
  12.359 +	# According to config.sub, this is the proper way to canonicalize
  12.360 +	# SunOS6.  Hard to guess exactly what SunOS6 will be like, but
  12.361 +	# it's likely to be more like Solaris than SunOS4.
  12.362 +	echo sparc-sun-solaris3`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
  12.363 +	exit ;;
  12.364 +    sun4*:SunOS:*:*)
  12.365 +	case "`/usr/bin/arch -k`" in
  12.366 +	    Series*|S4*)
  12.367 +		UNAME_RELEASE=`uname -v`
  12.368 +		;;
  12.369 +	esac
  12.370 +	# Japanese Language versions have a version number like `4.1.3-JL'.
  12.371 +	echo sparc-sun-sunos`echo ${UNAME_RELEASE}|sed -e 's/-/_/'`
  12.372 +	exit ;;
  12.373 +    sun3*:SunOS:*:*)
  12.374 +	echo m68k-sun-sunos${UNAME_RELEASE}
  12.375 +	exit ;;
  12.376 +    sun*:*:4.2BSD:*)
  12.377 +	UNAME_RELEASE=`(sed 1q /etc/motd | awk '{print substr($5,1,3)}') 2>/dev/null`
  12.378 +	test "x${UNAME_RELEASE}" = "x" && UNAME_RELEASE=3
  12.379 +	case "`/bin/arch`" in
  12.380 +	    sun3)
  12.381 +		echo m68k-sun-sunos${UNAME_RELEASE}
  12.382 +		;;
  12.383 +	    sun4)
  12.384 +		echo sparc-sun-sunos${UNAME_RELEASE}
  12.385 +		;;
  12.386 +	esac
  12.387 +	exit ;;
  12.388 +    aushp:SunOS:*:*)
  12.389 +	echo sparc-auspex-sunos${UNAME_RELEASE}
  12.390 +	exit ;;
  12.391 +    # The situation for MiNT is a little confusing.  The machine name
  12.392 +    # can be virtually everything (everything which is not
  12.393 +    # "atarist" or "atariste" at least should have a processor
  12.394 +    # > m68000).  The system name ranges from "MiNT" over "FreeMiNT"
  12.395 +    # to the lowercase version "mint" (or "freemint").  Finally
  12.396 +    # the system name "TOS" denotes a system which is actually not
  12.397 +    # MiNT.  But MiNT is downward compatible to TOS, so this should
  12.398 +    # be no problem.
  12.399 +    atarist[e]:*MiNT:*:* | atarist[e]:*mint:*:* | atarist[e]:*TOS:*:*)
  12.400 +        echo m68k-atari-mint${UNAME_RELEASE}
  12.401 +	exit ;;
  12.402 +    atari*:*MiNT:*:* | atari*:*mint:*:* | atarist[e]:*TOS:*:*)
  12.403 +	echo m68k-atari-mint${UNAME_RELEASE}
  12.404 +        exit ;;
  12.405 +    *falcon*:*MiNT:*:* | *falcon*:*mint:*:* | *falcon*:*TOS:*:*)
  12.406 +        echo m68k-atari-mint${UNAME_RELEASE}
  12.407 +	exit ;;
  12.408 +    milan*:*MiNT:*:* | milan*:*mint:*:* | *milan*:*TOS:*:*)
  12.409 +        echo m68k-milan-mint${UNAME_RELEASE}
  12.410 +        exit ;;
  12.411 +    hades*:*MiNT:*:* | hades*:*mint:*:* | *hades*:*TOS:*:*)
  12.412 +        echo m68k-hades-mint${UNAME_RELEASE}
  12.413 +        exit ;;
  12.414 +    *:*MiNT:*:* | *:*mint:*:* | *:*TOS:*:*)
  12.415 +        echo m68k-unknown-mint${UNAME_RELEASE}
  12.416 +        exit ;;
  12.417 +    m68k:machten:*:*)
  12.418 +	echo m68k-apple-machten${UNAME_RELEASE}
  12.419 +	exit ;;
  12.420 +    powerpc:machten:*:*)
  12.421 +	echo powerpc-apple-machten${UNAME_RELEASE}
  12.422 +	exit ;;
  12.423 +    RISC*:Mach:*:*)
  12.424 +	echo mips-dec-mach_bsd4.3
  12.425 +	exit ;;
  12.426 +    RISC*:ULTRIX:*:*)
  12.427 +	echo mips-dec-ultrix${UNAME_RELEASE}
  12.428 +	exit ;;
  12.429 +    VAX*:ULTRIX*:*:*)
  12.430 +	echo vax-dec-ultrix${UNAME_RELEASE}
  12.431 +	exit ;;
  12.432 +    2020:CLIX:*:* | 2430:CLIX:*:*)
  12.433 +	echo clipper-intergraph-clix${UNAME_RELEASE}
  12.434 +	exit ;;
  12.435 +    mips:*:*:UMIPS | mips:*:*:RISCos)
  12.436 +	eval $set_cc_for_build
  12.437 +	sed 's/^	//' << EOF >$dummy.c
  12.438 +#ifdef __cplusplus
  12.439 +#include <stdio.h>  /* for printf() prototype */
  12.440 +	int main (int argc, char *argv[]) {
  12.441 +#else
  12.442 +	int main (argc, argv) int argc; char *argv[]; {
  12.443 +#endif
  12.444 +	#if defined (host_mips) && defined (MIPSEB)
  12.445 +	#if defined (SYSTYPE_SYSV)
  12.446 +	  printf ("mips-mips-riscos%ssysv\n", argv[1]); exit (0);
  12.447 +	#endif
  12.448 +	#if defined (SYSTYPE_SVR4)
  12.449 +	  printf ("mips-mips-riscos%ssvr4\n", argv[1]); exit (0);
  12.450 +	#endif
  12.451 +	#if defined (SYSTYPE_BSD43) || defined(SYSTYPE_BSD)
  12.452 +	  printf ("mips-mips-riscos%sbsd\n", argv[1]); exit (0);
  12.453 +	#endif
  12.454 +	#endif
  12.455 +	  exit (-1);
  12.456 +	}
  12.457 +EOF
  12.458 +	$CC_FOR_BUILD -o $dummy $dummy.c &&
  12.459 +	  dummyarg=`echo "${UNAME_RELEASE}" | sed -n 's/\([0-9]*\).*/\1/p'` &&
  12.460 +	  SYSTEM_NAME=`$dummy $dummyarg` &&
  12.461 +	    { echo "$SYSTEM_NAME"; exit; }
  12.462 +	echo mips-mips-riscos${UNAME_RELEASE}
  12.463 +	exit ;;
  12.464 +    Motorola:PowerMAX_OS:*:*)
  12.465 +	echo powerpc-motorola-powermax
  12.466 +	exit ;;
  12.467 +    Motorola:*:4.3:PL8-*)
  12.468 +	echo powerpc-harris-powermax
  12.469 +	exit ;;
  12.470 +    Night_Hawk:*:*:PowerMAX_OS | Synergy:PowerMAX_OS:*:*)
  12.471 +	echo powerpc-harris-powermax
  12.472 +	exit ;;
  12.473 +    Night_Hawk:Power_UNIX:*:*)
  12.474 +	echo powerpc-harris-powerunix
  12.475 +	exit ;;
  12.476 +    m88k:CX/UX:7*:*)
  12.477 +	echo m88k-harris-cxux7
  12.478 +	exit ;;
  12.479 +    m88k:*:4*:R4*)
  12.480 +	echo m88k-motorola-sysv4
  12.481 +	exit ;;
  12.482 +    m88k:*:3*:R3*)
  12.483 +	echo m88k-motorola-sysv3
  12.484 +	exit ;;
  12.485 +    AViiON:dgux:*:*)
  12.486 +        # DG/UX returns AViiON for all architectures
  12.487 +        UNAME_PROCESSOR=`/usr/bin/uname -p`
  12.488 +	if [ $UNAME_PROCESSOR = mc88100 ] || [ $UNAME_PROCESSOR = mc88110 ]
  12.489 +	then
  12.490 +	    if [ ${TARGET_BINARY_INTERFACE}x = m88kdguxelfx ] || \
  12.491 +	       [ ${TARGET_BINARY_INTERFACE}x = x ]
  12.492 +	    then
  12.493 +		echo m88k-dg-dgux${UNAME_RELEASE}
  12.494 +	    else
  12.495 +		echo m88k-dg-dguxbcs${UNAME_RELEASE}
  12.496 +	    fi
  12.497 +	else
  12.498 +	    echo i586-dg-dgux${UNAME_RELEASE}
  12.499 +	fi
  12.500 + 	exit ;;
  12.501 +    M88*:DolphinOS:*:*)	# DolphinOS (SVR3)
  12.502 +	echo m88k-dolphin-sysv3
  12.503 +	exit ;;
  12.504 +    M88*:*:R3*:*)
  12.505 +	# Delta 88k system running SVR3
  12.506 +	echo m88k-motorola-sysv3
  12.507 +	exit ;;
  12.508 +    XD88*:*:*:*) # Tektronix XD88 system running UTekV (SVR3)
  12.509 +	echo m88k-tektronix-sysv3
  12.510 +	exit ;;
  12.511 +    Tek43[0-9][0-9]:UTek:*:*) # Tektronix 4300 system running UTek (BSD)
  12.512 +	echo m68k-tektronix-bsd
  12.513 +	exit ;;
  12.514 +    *:IRIX*:*:*)
  12.515 +	echo mips-sgi-irix`echo ${UNAME_RELEASE}|sed -e 's/-/_/g'`
  12.516 +	exit ;;
  12.517 +    ????????:AIX?:[12].1:2)   # AIX 2.2.1 or AIX 2.1.1 is RT/PC AIX.
  12.518 +	echo romp-ibm-aix     # uname -m gives an 8 hex-code CPU id
  12.519 +	exit ;;               # Note that: echo "'`uname -s`'" gives 'AIX '
  12.520 +    i*86:AIX:*:*)
  12.521 +	echo i386-ibm-aix
  12.522 +	exit ;;
  12.523 +    ia64:AIX:*:*)
  12.524 +	if [ -x /usr/bin/oslevel ] ; then
  12.525 +		IBM_REV=`/usr/bin/oslevel`
  12.526 +	else
  12.527 +		IBM_REV=${UNAME_VERSION}.${UNAME_RELEASE}
  12.528 +	fi
  12.529 +	echo ${UNAME_MACHINE}-ibm-aix${IBM_REV}
  12.530 +	exit ;;
  12.531 +    *:AIX:2:3)
  12.532 +	if grep bos325 /usr/include/stdio.h >/dev/null 2>&1; then
  12.533 +		eval $set_cc_for_build
  12.534 +		sed 's/^		//' << EOF >$dummy.c
  12.535 +		#include <sys/systemcfg.h>
  12.536 +
  12.537 +		main()
  12.538 +			{
  12.539 +			if (!__power_pc())
  12.540 +				exit(1);
  12.541 +			puts("powerpc-ibm-aix3.2.5");
  12.542 +			exit(0);
  12.543 +			}
  12.544 +EOF
  12.545 +		if $CC_FOR_BUILD -o $dummy $dummy.c && SYSTEM_NAME=`$dummy`
  12.546 +		then
  12.547 +			echo "$SYSTEM_NAME"
  12.548 +		else
  12.549 +			echo rs6000-ibm-aix3.2.5
  12.550 +		fi
  12.551 +	elif grep bos324 /usr/include/stdio.h >/dev/null 2>&1; then
  12.552 +		echo rs6000-ibm-aix3.2.4
  12.553 +	else
  12.554 +		echo rs6000-ibm-aix3.2
  12.555 +	fi
  12.556 +	exit ;;
  12.557 +    *:AIX:*:[456])
  12.558 +	IBM_CPU_ID=`/usr/sbin/lsdev -C -c processor -S available | sed 1q | awk '{ print $1 }'`
  12.559 +	if /usr/sbin/lsattr -El ${IBM_CPU_ID} | grep ' POWER' >/dev/null 2>&1; then
  12.560 +		IBM_ARCH=rs6000
  12.561 +	else
  12.562 +		IBM_ARCH=powerpc
  12.563 +	fi
  12.564 +	if [ -x /usr/bin/oslevel ] ; then
  12.565 +		IBM_REV=`/usr/bin/oslevel`
  12.566 +	else
  12.567 +		IBM_REV=${UNAME_VERSION}.${UNAME_RELEASE}
  12.568 +	fi
  12.569 +	echo ${IBM_ARCH}-ibm-aix${IBM_REV}
  12.570 +	exit ;;
  12.571 +    *:AIX:*:*)
  12.572 +	echo rs6000-ibm-aix
  12.573 +	exit ;;
  12.574 +    ibmrt:4.4BSD:*|romp-ibm:BSD:*)
  12.575 +	echo romp-ibm-bsd4.4
  12.576 +	exit ;;
  12.577 +    ibmrt:*BSD:*|romp-ibm:BSD:*)            # covers RT/PC BSD and
  12.578 +	echo romp-ibm-bsd${UNAME_RELEASE}   # 4.3 with uname added to
  12.579 +	exit ;;                             # report: romp-ibm BSD 4.3
  12.580 +    *:BOSX:*:*)
  12.581 +	echo rs6000-bull-bosx
  12.582 +	exit ;;
  12.583 +    DPX/2?00:B.O.S.:*:*)
  12.584 +	echo m68k-bull-sysv3
  12.585 +	exit ;;
  12.586 +    9000/[34]??:4.3bsd:1.*:*)
  12.587 +	echo m68k-hp-bsd
  12.588 +	exit ;;
  12.589 +    hp300:4.4BSD:*:* | 9000/[34]??:4.3bsd:2.*:*)
  12.590 +	echo m68k-hp-bsd4.4
  12.591 +	exit ;;
  12.592 +    9000/[34678]??:HP-UX:*:*)
  12.593 +	HPUX_REV=`echo ${UNAME_RELEASE}|sed -e 's/[^.]*.[0B]*//'`
  12.594 +	case "${UNAME_MACHINE}" in
  12.595 +	    9000/31? )            HP_ARCH=m68000 ;;
  12.596 +	    9000/[34]?? )         HP_ARCH=m68k ;;
  12.597 +	    9000/[678][0-9][0-9])
  12.598 +		if [ -x /usr/bin/getconf ]; then
  12.599 +		    sc_cpu_version=`/usr/bin/getconf SC_CPU_VERSION 2>/dev/null`
  12.600 +                    sc_kernel_bits=`/usr/bin/getconf SC_KERNEL_BITS 2>/dev/null`
  12.601 +                    case "${sc_cpu_version}" in
  12.602 +                      523) HP_ARCH="hppa1.0" ;; # CPU_PA_RISC1_0
  12.603 +                      528) HP_ARCH="hppa1.1" ;; # CPU_PA_RISC1_1
  12.604 +                      532)                      # CPU_PA_RISC2_0
  12.605 +                        case "${sc_kernel_bits}" in
  12.606 +                          32) HP_ARCH="hppa2.0n" ;;
  12.607 +                          64) HP_ARCH="hppa2.0w" ;;
  12.608 +			  '') HP_ARCH="hppa2.0" ;;   # HP-UX 10.20
  12.609 +                        esac ;;
  12.610 +                    esac
  12.611 +		fi
  12.612 +		if [ "${HP_ARCH}" = "" ]; then
  12.613 +		    eval $set_cc_for_build
  12.614 +		    sed 's/^              //' << EOF >$dummy.c
  12.615 +
  12.616 +              #define _HPUX_SOURCE
  12.617 +              #include <stdlib.h>
  12.618 +              #include <unistd.h>
  12.619 +
  12.620 +              int main ()
  12.621 +              {
  12.622 +              #if defined(_SC_KERNEL_BITS)
  12.623 +                  long bits = sysconf(_SC_KERNEL_BITS);
  12.624 +              #endif
  12.625 +                  long cpu  = sysconf (_SC_CPU_VERSION);
  12.626 +
  12.627 +                  switch (cpu)
  12.628 +              	{
  12.629 +              	case CPU_PA_RISC1_0: puts ("hppa1.0"); break;
  12.630 +              	case CPU_PA_RISC1_1: puts ("hppa1.1"); break;
  12.631 +              	case CPU_PA_RISC2_0:
  12.632 +              #if defined(_SC_KERNEL_BITS)
  12.633 +              	    switch (bits)
  12.634 +              		{
  12.635 +              		case 64: puts ("hppa2.0w"); break;
  12.636 +              		case 32: puts ("hppa2.0n"); break;
  12.637 +              		default: puts ("hppa2.0"); break;
  12.638 +              		} break;
  12.639 +              #else  /* !defined(_SC_KERNEL_BITS) */
  12.640 +              	    puts ("hppa2.0"); break;
  12.641 +              #endif
  12.642 +              	default: puts ("hppa1.0"); break;
  12.643 +              	}
  12.644 +                  exit (0);
  12.645 +              }
  12.646 +EOF
  12.647 +		    (CCOPTS= $CC_FOR_BUILD -o $dummy $dummy.c 2>/dev/null) && HP_ARCH=`$dummy`
  12.648 +		    test -z "$HP_ARCH" && HP_ARCH=hppa
  12.649 +		fi ;;
  12.650 +	esac
  12.651 +	if [ ${HP_ARCH} = "hppa2.0w" ]
  12.652 +	then
  12.653 +	    eval $set_cc_for_build
  12.654 +
  12.655 +	    # hppa2.0w-hp-hpux* has a 64-bit kernel and a compiler generating
  12.656 +	    # 32-bit code.  hppa64-hp-hpux* has the same kernel and a compiler
  12.657 +	    # generating 64-bit code.  GNU and HP use different nomenclature:
  12.658 +	    #
  12.659 +	    # $ CC_FOR_BUILD=cc ./config.guess
  12.660 +	    # => hppa2.0w-hp-hpux11.23
  12.661 +	    # $ CC_FOR_BUILD="cc +DA2.0w" ./config.guess
  12.662 +	    # => hppa64-hp-hpux11.23
  12.663 +
  12.664 +	    if echo __LP64__ | (CCOPTS= $CC_FOR_BUILD -E - 2>/dev/null) |
  12.665 +		grep -q __LP64__
  12.666 +	    then
  12.667 +		HP_ARCH="hppa2.0w"
  12.668 +	    else
  12.669 +		HP_ARCH="hppa64"
  12.670 +	    fi
  12.671 +	fi
  12.672 +	echo ${HP_ARCH}-hp-hpux${HPUX_REV}
  12.673 +	exit ;;
  12.674 +    ia64:HP-UX:*:*)
  12.675 +	HPUX_REV=`echo ${UNAME_RELEASE}|sed -e 's/[^.]*.[0B]*//'`
  12.676 +	echo ia64-hp-hpux${HPUX_REV}
  12.677 +	exit ;;
  12.678 +    3050*:HI-UX:*:*)
  12.679 +	eval $set_cc_for_build
  12.680 +	sed 's/^	//' << EOF >$dummy.c
  12.681 +	#include <unistd.h>
  12.682 +	int
  12.683 +	main ()
  12.684 +	{
  12.685 +	  long cpu = sysconf (_SC_CPU_VERSION);
  12.686 +	  /* The order matters, because CPU_IS_HP_MC68K erroneously returns
  12.687 +	     true for CPU_PA_RISC1_0.  CPU_IS_PA_RISC returns correct
  12.688 +	     results, however.  */
  12.689 +	  if (CPU_IS_PA_RISC (cpu))
  12.690 +	    {
  12.691 +	      switch (cpu)
  12.692 +		{
  12.693 +		  case CPU_PA_RISC1_0: puts ("hppa1.0-hitachi-hiuxwe2"); break;
  12.694 +		  case CPU_PA_RISC1_1: puts ("hppa1.1-hitachi-hiuxwe2"); break;
  12.695 +		  case CPU_PA_RISC2_0: puts ("hppa2.0-hitachi-hiuxwe2"); break;
  12.696 +		  default: puts ("hppa-hitachi-hiuxwe2"); break;
  12.697 +		}
  12.698 +	    }
  12.699 +	  else if (CPU_IS_HP_MC68K (cpu))
  12.700 +	    puts ("m68k-hitachi-hiuxwe2");
  12.701 +	  else puts ("unknown-hitachi-hiuxwe2");
  12.702 +	  exit (0);
  12.703 +	}
  12.704 +EOF
  12.705 +	$CC_FOR_BUILD -o $dummy $dummy.c && SYSTEM_NAME=`$dummy` &&
  12.706 +		{ echo "$SYSTEM_NAME"; exit; }
  12.707 +	echo unknown-hitachi-hiuxwe2
  12.708 +	exit ;;
  12.709 +    9000/7??:4.3bsd:*:* | 9000/8?[79]:4.3bsd:*:* )
  12.710 +	echo hppa1.1-hp-bsd
  12.711 +	exit ;;
  12.712 +    9000/8??:4.3bsd:*:*)
  12.713 +	echo hppa1.0-hp-bsd
  12.714 +	exit ;;
  12.715 +    *9??*:MPE/iX:*:* | *3000*:MPE/iX:*:*)
  12.716 +	echo hppa1.0-hp-mpeix
  12.717 +	exit ;;
  12.718 +    hp7??:OSF1:*:* | hp8?[79]:OSF1:*:* )
  12.719 +	echo hppa1.1-hp-osf
  12.720 +	exit ;;
  12.721 +    hp8??:OSF1:*:*)
  12.722 +	echo hppa1.0-hp-osf
  12.723 +	exit ;;
  12.724 +    i*86:OSF1:*:*)
  12.725 +	if [ -x /usr/sbin/sysversion ] ; then
  12.726 +	    echo ${UNAME_MACHINE}-unknown-osf1mk
  12.727 +	else
  12.728 +	    echo ${UNAME_MACHINE}-unknown-osf1
  12.729 +	fi
  12.730 +	exit ;;
  12.731 +    parisc*:Lites*:*:*)
  12.732 +	echo hppa1.1-hp-lites
  12.733 +	exit ;;
  12.734 +    C1*:ConvexOS:*:* | convex:ConvexOS:C1*:*)
  12.735 +	echo c1-convex-bsd
  12.736 +        exit ;;
  12.737 +    C2*:ConvexOS:*:* | convex:ConvexOS:C2*:*)
  12.738 +	if getsysinfo -f scalar_acc
  12.739 +	then echo c32-convex-bsd
  12.740 +	else echo c2-convex-bsd
  12.741 +	fi
  12.742 +        exit ;;
  12.743 +    C34*:ConvexOS:*:* | convex:ConvexOS:C34*:*)
  12.744 +	echo c34-convex-bsd
  12.745 +        exit ;;
  12.746 +    C38*:ConvexOS:*:* | convex:ConvexOS:C38*:*)
  12.747 +	echo c38-convex-bsd
  12.748 +        exit ;;
  12.749 +    C4*:ConvexOS:*:* | convex:ConvexOS:C4*:*)
  12.750 +	echo c4-convex-bsd
  12.751 +        exit ;;
  12.752 +    CRAY*Y-MP:*:*:*)
  12.753 +	echo ymp-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/'
  12.754 +	exit ;;
  12.755 +    CRAY*[A-Z]90:*:*:*)
  12.756 +	echo ${UNAME_MACHINE}-cray-unicos${UNAME_RELEASE} \
  12.757 +	| sed -e 's/CRAY.*\([A-Z]90\)/\1/' \
  12.758 +	      -e y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/ \
  12.759 +	      -e 's/\.[^.]*$/.X/'
  12.760 +	exit ;;
  12.761 +    CRAY*TS:*:*:*)
  12.762 +	echo t90-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/'
  12.763 +	exit ;;
  12.764 +    CRAY*T3E:*:*:*)
  12.765 +	echo alphaev5-cray-unicosmk${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/'
  12.766 +	exit ;;
  12.767 +    CRAY*SV1:*:*:*)
  12.768 +	echo sv1-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/'
  12.769 +	exit ;;
  12.770 +    *:UNICOS/mp:*:*)
  12.771 +	echo craynv-cray-unicosmp${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/'
  12.772 +	exit ;;
  12.773 +    F30[01]:UNIX_System_V:*:* | F700:UNIX_System_V:*:*)
  12.774 +	FUJITSU_PROC=`uname -m | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'`
  12.775 +        FUJITSU_SYS=`uname -p | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/\///'`
  12.776 +        FUJITSU_REL=`echo ${UNAME_RELEASE} | sed -e 's/ /_/'`
  12.777 +        echo "${FUJITSU_PROC}-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}"
  12.778 +        exit ;;
  12.779 +    5000:UNIX_System_V:4.*:*)
  12.780 +        FUJITSU_SYS=`uname -p | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/\///'`
  12.781 +        FUJITSU_REL=`echo ${UNAME_RELEASE} | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/ /_/'`
  12.782 +        echo "sparc-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}"
  12.783 +	exit ;;
  12.784 +    i*86:BSD/386:*:* | i*86:BSD/OS:*:* | *:Ascend\ Embedded/OS:*:*)
  12.785 +	echo ${UNAME_MACHINE}-pc-bsdi${UNAME_RELEASE}
  12.786 +	exit ;;
  12.787 +    sparc*:BSD/OS:*:*)
  12.788 +	echo sparc-unknown-bsdi${UNAME_RELEASE}
  12.789 +	exit ;;
  12.790 +    *:BSD/OS:*:*)
  12.791 +	echo ${UNAME_MACHINE}-unknown-bsdi${UNAME_RELEASE}
  12.792 +	exit ;;
  12.793 +    *:FreeBSD:*:*)
  12.794 +	case ${UNAME_MACHINE} in
  12.795 +	    pc98)
  12.796 +		echo i386-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` ;;
  12.797 +	    amd64)
  12.798 +		echo x86_64-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` ;;
  12.799 +	    *)
  12.800 +		echo ${UNAME_MACHINE}-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` ;;
  12.801 +	esac
  12.802 +	exit ;;
  12.803 +    i*:CYGWIN*:*)
  12.804 +	echo ${UNAME_MACHINE}-pc-cygwin
  12.805 +	exit ;;
  12.806 +    *:MINGW*:*)
  12.807 +	echo ${UNAME_MACHINE}-pc-mingw32
  12.808 +	exit ;;
  12.809 +    i*:windows32*:*)
  12.810 +    	# uname -m includes "-pc" on this system.
  12.811 +    	echo ${UNAME_MACHINE}-mingw32
  12.812 +	exit ;;
  12.813 +    i*:PW*:*)
  12.814 +	echo ${UNAME_MACHINE}-pc-pw32
  12.815 +	exit ;;
  12.816 +    *:Interix*:*)
  12.817 +    	case ${UNAME_MACHINE} in
  12.818 +	    x86)
  12.819 +		echo i586-pc-interix${UNAME_RELEASE}
  12.820 +		exit ;;
  12.821 +	    authenticamd | genuineintel | EM64T)
  12.822 +		echo x86_64-unknown-interix${UNAME_RELEASE}
  12.823 +		exit ;;
  12.824 +	    IA64)
  12.825 +		echo ia64-unknown-interix${UNAME_RELEASE}
  12.826 +		exit ;;
  12.827 +	esac ;;
  12.828 +    [345]86:Windows_95:* | [345]86:Windows_98:* | [345]86:Windows_NT:*)
  12.829 +	echo i${UNAME_MACHINE}-pc-mks
  12.830 +	exit ;;
  12.831 +    8664:Windows_NT:*)
  12.832 +	echo x86_64-pc-mks
  12.833 +	exit ;;
  12.834 +    i*:Windows_NT*:* | Pentium*:Windows_NT*:*)
  12.835 +	# How do we know it's Interix rather than the generic POSIX subsystem?
  12.836 +	# It also conflicts with pre-2.0 versions of AT&T UWIN. Should we
  12.837 +	# UNAME_MACHINE based on the output of uname instead of i386?
  12.838 +	echo i586-pc-interix
  12.839 +	exit ;;
  12.840 +    i*:UWIN*:*)
  12.841 +	echo ${UNAME_MACHINE}-pc-uwin
  12.842 +	exit ;;
  12.843 +    amd64:CYGWIN*:*:* | x86_64:CYGWIN*:*:*)
  12.844 +	echo x86_64-unknown-cygwin
  12.845 +	exit ;;
  12.846 +    p*:CYGWIN*:*)
  12.847 +	echo powerpcle-unknown-cygwin
  12.848 +	exit ;;
  12.849 +    prep*:SunOS:5.*:*)
  12.850 +	echo powerpcle-unknown-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
  12.851 +	exit ;;
  12.852 +    *:GNU:*:*)
  12.853 +	# the GNU system
  12.854 +	echo `echo ${UNAME_MACHINE}|sed -e 's,[-/].*$,,'`-unknown-gnu`echo ${UNAME_RELEASE}|sed -e 's,/.*$,,'`
  12.855 +	exit ;;
  12.856 +    *:GNU/*:*:*)
  12.857 +	# other systems with GNU libc and userland
  12.858 +	echo ${UNAME_MACHINE}-unknown-`echo ${UNAME_SYSTEM} | sed 's,^[^/]*/,,' | tr '[A-Z]' '[a-z]'``echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'`-gnu
  12.859 +	exit ;;
  12.860 +    i*86:Minix:*:*)
  12.861 +	echo ${UNAME_MACHINE}-pc-minix
  12.862 +	exit ;;
  12.863 +    alpha:Linux:*:*)
  12.864 +	case `sed -n '/^cpu model/s/^.*: \(.*\)/\1/p' < /proc/cpuinfo` in
  12.865 +	  EV5)   UNAME_MACHINE=alphaev5 ;;
  12.866 +	  EV56)  UNAME_MACHINE=alphaev56 ;;
  12.867 +	  PCA56) UNAME_MACHINE=alphapca56 ;;
  12.868 +	  PCA57) UNAME_MACHINE=alphapca56 ;;
  12.869 +	  EV6)   UNAME_MACHINE=alphaev6 ;;
  12.870 +	  EV67)  UNAME_MACHINE=alphaev67 ;;
  12.871 +	  EV68*) UNAME_MACHINE=alphaev68 ;;
  12.872 +        esac
  12.873 +	objdump --private-headers /bin/sh | grep -q ld.so.1
  12.874 +	if test "$?" = 0 ; then LIBC="libc1" ; else LIBC="" ; fi
  12.875 +	echo ${UNAME_MACHINE}-unknown-linux-gnu${LIBC}
  12.876 +	exit ;;
  12.877 +    arm*:Linux:*:*)
  12.878 +	eval $set_cc_for_build
  12.879 +	if echo __ARM_EABI__ | $CC_FOR_BUILD -E - 2>/dev/null \
  12.880 +	    | grep -q __ARM_EABI__
  12.881 +	then
  12.882 +	    echo ${UNAME_MACHINE}-unknown-linux-gnu
  12.883 +	else
  12.884 +	    echo ${UNAME_MACHINE}-unknown-linux-gnueabi
  12.885 +	fi
  12.886 +	exit ;;
  12.887 +    avr32*:Linux:*:*)
  12.888 +	echo ${UNAME_MACHINE}-unknown-linux-gnu
  12.889 +	exit ;;
  12.890 +    cris:Linux:*:*)
  12.891 +	echo cris-axis-linux-gnu
  12.892 +	exit ;;
  12.893 +    crisv32:Linux:*:*)
  12.894 +	echo crisv32-axis-linux-gnu
  12.895 +	exit ;;
  12.896 +    frv:Linux:*:*)
  12.897 +    	echo frv-unknown-linux-gnu
  12.898 +	exit ;;
  12.899 +    i*86:Linux:*:*)
  12.900 +	LIBC=gnu
  12.901 +	eval $set_cc_for_build
  12.902 +	sed 's/^	//' << EOF >$dummy.c
  12.903 +	#ifdef __dietlibc__
  12.904 +	LIBC=dietlibc
  12.905 +	#endif
  12.906 +EOF
  12.907 +	eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep '^LIBC'`
  12.908 +	echo "${UNAME_MACHINE}-pc-linux-${LIBC}"
  12.909 +	exit ;;
  12.910 +    ia64:Linux:*:*)
  12.911 +	echo ${UNAME_MACHINE}-unknown-linux-gnu
  12.912 +	exit ;;
  12.913 +    m32r*:Linux:*:*)
  12.914 +	echo ${UNAME_MACHINE}-unknown-linux-gnu
  12.915 +	exit ;;
  12.916 +    m68*:Linux:*:*)
  12.917 +	echo ${UNAME_MACHINE}-unknown-linux-gnu
  12.918 +	exit ;;
  12.919 +    mips:Linux:*:* | mips64:Linux:*:*)
  12.920 +	eval $set_cc_for_build
  12.921 +	sed 's/^	//' << EOF >$dummy.c
  12.922 +	#undef CPU
  12.923 +	#undef ${UNAME_MACHINE}
  12.924 +	#undef ${UNAME_MACHINE}el
  12.925 +	#if defined(__MIPSEL__) || defined(__MIPSEL) || defined(_MIPSEL) || defined(MIPSEL)
  12.926 +	CPU=${UNAME_MACHINE}el
  12.927 +	#else
  12.928 +	#if defined(__MIPSEB__) || defined(__MIPSEB) || defined(_MIPSEB) || defined(MIPSEB)
  12.929 +	CPU=${UNAME_MACHINE}
  12.930 +	#else
  12.931 +	CPU=
  12.932 +	#endif
  12.933 +	#endif
  12.934 +EOF
  12.935 +	eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep '^CPU'`
  12.936 +	test x"${CPU}" != x && { echo "${CPU}-unknown-linux-gnu"; exit; }
  12.937 +	;;
  12.938 +    or32:Linux:*:*)
  12.939 +	echo or32-unknown-linux-gnu
  12.940 +	exit ;;
  12.941 +    padre:Linux:*:*)
  12.942 +	echo sparc-unknown-linux-gnu
  12.943 +	exit ;;
  12.944 +    parisc64:Linux:*:* | hppa64:Linux:*:*)
  12.945 +	echo hppa64-unknown-linux-gnu
  12.946 +	exit ;;
  12.947 +    parisc:Linux:*:* | hppa:Linux:*:*)
  12.948 +	# Look for CPU level
  12.949 +	case `grep '^cpu[^a-z]*:' /proc/cpuinfo 2>/dev/null | cut -d' ' -f2` in
  12.950 +	  PA7*) echo hppa1.1-unknown-linux-gnu ;;
  12.951 +	  PA8*) echo hppa2.0-unknown-linux-gnu ;;
  12.952 +	  *)    echo hppa-unknown-linux-gnu ;;
  12.953 +	esac
  12.954 +	exit ;;
  12.955 +    ppc64:Linux:*:*)
  12.956 +	echo powerpc64-unknown-linux-gnu
  12.957 +	exit ;;
  12.958 +    ppc:Linux:*:*)
  12.959 +	echo powerpc-unknown-linux-gnu
  12.960 +	exit ;;
  12.961 +    s390:Linux:*:* | s390x:Linux:*:*)
  12.962 +	echo ${UNAME_MACHINE}-ibm-linux
  12.963 +	exit ;;
  12.964 +    sh64*:Linux:*:*)
  12.965 +    	echo ${UNAME_MACHINE}-unknown-linux-gnu
  12.966 +	exit ;;
  12.967 +    sh*:Linux:*:*)
  12.968 +	echo ${UNAME_MACHINE}-unknown-linux-gnu
  12.969 +	exit ;;
  12.970 +    sparc:Linux:*:* | sparc64:Linux:*:*)
  12.971 +	echo ${UNAME_MACHINE}-unknown-linux-gnu
  12.972 +	exit ;;
  12.973 +    vax:Linux:*:*)
  12.974 +	echo ${UNAME_MACHINE}-dec-linux-gnu
  12.975 +	exit ;;
  12.976 +    x86_64:Linux:*:*)
  12.977 +	echo x86_64-unknown-linux-gnu
  12.978 +	exit ;;
  12.979 +    xtensa*:Linux:*:*)
  12.980 +    	echo ${UNAME_MACHINE}-unknown-linux-gnu
  12.981 +	exit ;;
  12.982 +    i*86:DYNIX/ptx:4*:*)
  12.983 +	# ptx 4.0 does uname -s correctly, with DYNIX/ptx in there.
  12.984 +	# earlier versions are messed up and put the nodename in both
  12.985 +	# sysname and nodename.
  12.986 +	echo i386-sequent-sysv4
  12.987 +	exit ;;
  12.988 +    i*86:UNIX_SV:4.2MP:2.*)
  12.989 +        # Unixware is an offshoot of SVR4, but it has its own version
  12.990 +        # number series starting with 2...
  12.991 +        # I am not positive that other SVR4 systems won't match this,
  12.992 +	# I just have to hope.  -- rms.
  12.993 +        # Use sysv4.2uw... so that sysv4* matches it.
  12.994 +	echo ${UNAME_MACHINE}-pc-sysv4.2uw${UNAME_VERSION}
  12.995 +	exit ;;
  12.996 +    i*86:OS/2:*:*)
  12.997 +	# If we were able to find `uname', then EMX Unix compatibility
  12.998 +	# is probably installed.
  12.999 +	echo ${UNAME_MACHINE}-pc-os2-emx
 12.1000 +	exit ;;
 12.1001 +    i*86:XTS-300:*:STOP)
 12.1002 +	echo ${UNAME_MACHINE}-unknown-stop
 12.1003 +	exit ;;
 12.1004 +    i*86:atheos:*:*)
 12.1005 +	echo ${UNAME_MACHINE}-unknown-atheos
 12.1006 +	exit ;;
 12.1007 +    i*86:syllable:*:*)
 12.1008 +	echo ${UNAME_MACHINE}-pc-syllable
 12.1009 +	exit ;;
 12.1010 +    i*86:LynxOS:2.*:* | i*86:LynxOS:3.[01]*:* | i*86:LynxOS:4.[02]*:*)
 12.1011 +	echo i386-unknown-lynxos${UNAME_RELEASE}
 12.1012 +	exit ;;
 12.1013 +    i*86:*DOS:*:*)
 12.1014 +	echo ${UNAME_MACHINE}-pc-msdosdjgpp
 12.1015 +	exit ;;
 12.1016 +    i*86:*:4.*:* | i*86:SYSTEM_V:4.*:*)
 12.1017 +	UNAME_REL=`echo ${UNAME_RELEASE} | sed 's/\/MP$//'`
 12.1018 +	if grep Novell /usr/include/link.h >/dev/null 2>/dev/null; then
 12.1019 +		echo ${UNAME_MACHINE}-univel-sysv${UNAME_REL}
 12.1020 +	else
 12.1021 +		echo ${UNAME_MACHINE}-pc-sysv${UNAME_REL}
 12.1022 +	fi
 12.1023 +	exit ;;
 12.1024 +    i*86:*:5:[678]*)
 12.1025 +    	# UnixWare 7.x, OpenUNIX and OpenServer 6.
 12.1026 +	case `/bin/uname -X | grep "^Machine"` in
 12.1027 +	    *486*)	     UNAME_MACHINE=i486 ;;
 12.1028 +	    *Pentium)	     UNAME_MACHINE=i586 ;;
 12.1029 +	    *Pent*|*Celeron) UNAME_MACHINE=i686 ;;
 12.1030 +	esac
 12.1031 +	echo ${UNAME_MACHINE}-unknown-sysv${UNAME_RELEASE}${UNAME_SYSTEM}${UNAME_VERSION}
 12.1032 +	exit ;;
 12.1033 +    i*86:*:3.2:*)
 12.1034 +	if test -f /usr/options/cb.name; then
 12.1035 +		UNAME_REL=`sed -n 's/.*Version //p' </usr/options/cb.name`
 12.1036 +		echo ${UNAME_MACHINE}-pc-isc$UNAME_REL
 12.1037 +	elif /bin/uname -X 2>/dev/null >/dev/null ; then
 12.1038 +		UNAME_REL=`(/bin/uname -X|grep Release|sed -e 's/.*= //')`
 12.1039 +		(/bin/uname -X|grep i80486 >/dev/null) && UNAME_MACHINE=i486
 12.1040 +		(/bin/uname -X|grep '^Machine.*Pentium' >/dev/null) \
 12.1041 +			&& UNAME_MACHINE=i586
 12.1042 +		(/bin/uname -X|grep '^Machine.*Pent *II' >/dev/null) \
 12.1043 +			&& UNAME_MACHINE=i686
 12.1044 +		(/bin/uname -X|grep '^Machine.*Pentium Pro' >/dev/null) \
 12.1045 +			&& UNAME_MACHINE=i686
 12.1046 +		echo ${UNAME_MACHINE}-pc-sco$UNAME_REL
 12.1047 +	else
 12.1048 +		echo ${UNAME_MACHINE}-pc-sysv32
 12.1049 +	fi
 12.1050 +	exit ;;
 12.1051 +    pc:*:*:*)
 12.1052 +	# Left here for compatibility:
 12.1053 +        # uname -m prints for DJGPP always 'pc', but it prints nothing about
 12.1054 +        # the processor, so we play safe by assuming i586.
 12.1055 +	# Note: whatever this is, it MUST be the same as what config.sub
 12.1056 +	# prints for the "djgpp" host, or else GDB configury will decide that
 12.1057 +	# this is a cross-build.
 12.1058 +	echo i586-pc-msdosdjgpp
 12.1059 +        exit ;;
 12.1060 +    Intel:Mach:3*:*)
 12.1061 +	echo i386-pc-mach3
 12.1062 +	exit ;;
 12.1063 +    paragon:*:*:*)
 12.1064 +	echo i860-intel-osf1
 12.1065 +	exit ;;
 12.1066 +    i860:*:4.*:*) # i860-SVR4
 12.1067 +	if grep Stardent /usr/include/sys/uadmin.h >/dev/null 2>&1 ; then
 12.1068 +	  echo i860-stardent-sysv${UNAME_RELEASE} # Stardent Vistra i860-SVR4
 12.1069 +	else # Add other i860-SVR4 vendors below as they are discovered.
 12.1070 +	  echo i860-unknown-sysv${UNAME_RELEASE}  # Unknown i860-SVR4
 12.1071 +	fi
 12.1072 +	exit ;;
 12.1073 +    mini*:CTIX:SYS*5:*)
 12.1074 +	# "miniframe"
 12.1075 +	echo m68010-convergent-sysv
 12.1076 +	exit ;;
 12.1077 +    mc68k:UNIX:SYSTEM5:3.51m)
 12.1078 +	echo m68k-convergent-sysv
 12.1079 +	exit ;;
 12.1080 +    M680?0:D-NIX:5.3:*)
 12.1081 +	echo m68k-diab-dnix
 12.1082 +	exit ;;
 12.1083 +    M68*:*:R3V[5678]*:*)
 12.1084 +	test -r /sysV68 && { echo 'm68k-motorola-sysv'; exit; } ;;
 12.1085 +    3[345]??:*:4.0:3.0 | 3[34]??A:*:4.0:3.0 | 3[34]??,*:*:4.0:3.0 | 3[34]??/*:*:4.0:3.0 | 4400:*:4.0:3.0 | 4850:*:4.0:3.0 | SKA40:*:4.0:3.0 | SDS2:*:4.0:3.0 | SHG2:*:4.0:3.0 | S7501*:*:4.0:3.0)
 12.1086 +	OS_REL=''
 12.1087 +	test -r /etc/.relid \
 12.1088 +	&& OS_REL=.`sed -n 's/[^ ]* [^ ]* \([0-9][0-9]\).*/\1/p' < /etc/.relid`
 12.1089 +	/bin/uname -p 2>/dev/null | grep 86 >/dev/null \
 12.1090 +	  && { echo i486-ncr-sysv4.3${OS_REL}; exit; }
 12.1091 +	/bin/uname -p 2>/dev/null | /bin/grep entium >/dev/null \
 12.1092 +	  && { echo i586-ncr-sysv4.3${OS_REL}; exit; } ;;
 12.1093 +    3[34]??:*:4.0:* | 3[34]??,*:*:4.0:*)
 12.1094 +        /bin/uname -p 2>/dev/null | grep 86 >/dev/null \
 12.1095 +          && { echo i486-ncr-sysv4; exit; } ;;
 12.1096 +    NCR*:*:4.2:* | MPRAS*:*:4.2:*)
 12.1097 +	OS_REL='.3'
 12.1098 +	test -r /etc/.relid \
 12.1099 +	    && OS_REL=.`sed -n 's/[^ ]* [^ ]* \([0-9][0-9]\).*/\1/p' < /etc/.relid`
 12.1100 +	/bin/uname -p 2>/dev/null | grep 86 >/dev/null \
 12.1101 +	    && { echo i486-ncr-sysv4.3${OS_REL}; exit; }
 12.1102 +	/bin/uname -p 2>/dev/null | /bin/grep entium >/dev/null \
 12.1103 +	    && { echo i586-ncr-sysv4.3${OS_REL}; exit; }
 12.1104 +	/bin/uname -p 2>/dev/null | /bin/grep pteron >/dev/null \
 12.1105 +	    && { echo i586-ncr-sysv4.3${OS_REL}; exit; } ;;
 12.1106 +    m68*:LynxOS:2.*:* | m68*:LynxOS:3.0*:*)
 12.1107 +	echo m68k-unknown-lynxos${UNAME_RELEASE}
 12.1108 +	exit ;;
 12.1109 +    mc68030:UNIX_System_V:4.*:*)
 12.1110 +	echo m68k-atari-sysv4
 12.1111 +	exit ;;
 12.1112 +    TSUNAMI:LynxOS:2.*:*)
 12.1113 +	echo sparc-unknown-lynxos${UNAME_RELEASE}
 12.1114 +	exit ;;
 12.1115 +    rs6000:LynxOS:2.*:*)
 12.1116 +	echo rs6000-unknown-lynxos${UNAME_RELEASE}
 12.1117 +	exit ;;
 12.1118 +    PowerPC:LynxOS:2.*:* | PowerPC:LynxOS:3.[01]*:* | PowerPC:LynxOS:4.[02]*:*)
 12.1119 +	echo powerpc-unknown-lynxos${UNAME_RELEASE}
 12.1120 +	exit ;;
 12.1121 +    SM[BE]S:UNIX_SV:*:*)
 12.1122 +	echo mips-dde-sysv${UNAME_RELEASE}
 12.1123 +	exit ;;
 12.1124 +    RM*:ReliantUNIX-*:*:*)
 12.1125 +	echo mips-sni-sysv4
 12.1126 +	exit ;;
 12.1127 +    RM*:SINIX-*:*:*)
 12.1128 +	echo mips-sni-sysv4
 12.1129 +	exit ;;
 12.1130 +    *:SINIX-*:*:*)
 12.1131 +	if uname -p 2>/dev/null >/dev/null ; then
 12.1132 +		UNAME_MACHINE=`(uname -p) 2>/dev/null`
 12.1133 +		echo ${UNAME_MACHINE}-sni-sysv4
 12.1134 +	else
 12.1135 +		echo ns32k-sni-sysv
 12.1136 +	fi
 12.1137 +	exit ;;
 12.1138 +    PENTIUM:*:4.0*:*) # Unisys `ClearPath HMP IX 4000' SVR4/MP effort
 12.1139 +                      # says <Richard.M.Bartel@ccMail.Census.GOV>
 12.1140 +        echo i586-unisys-sysv4
 12.1141 +        exit ;;
 12.1142 +    *:UNIX_System_V:4*:FTX*)
 12.1143 +	# From Gerald Hewes <hewes@openmarket.com>.
 12.1144 +	# How about differentiating between stratus architectures? -djm
 12.1145 +	echo hppa1.1-stratus-sysv4
 12.1146 +	exit ;;
 12.1147 +    *:*:*:FTX*)
 12.1148 +	# From seanf@swdc.stratus.com.
 12.1149 +	echo i860-stratus-sysv4
 12.1150 +	exit ;;
 12.1151 +    i*86:VOS:*:*)
 12.1152 +	# From Paul.Green@stratus.com.
 12.1153 +	echo ${UNAME_MACHINE}-stratus-vos
 12.1154 +	exit ;;
 12.1155 +    *:VOS:*:*)
 12.1156 +	# From Paul.Green@stratus.com.
 12.1157 +	echo hppa1.1-stratus-vos
 12.1158 +	exit ;;
 12.1159 +    mc68*:A/UX:*:*)
 12.1160 +	echo m68k-apple-aux${UNAME_RELEASE}
 12.1161 +	exit ;;
 12.1162 +    news*:NEWS-OS:6*:*)
 12.1163 +	echo mips-sony-newsos6
 12.1164 +	exit ;;
 12.1165 +    R[34]000:*System_V*:*:* | R4000:UNIX_SYSV:*:* | R*000:UNIX_SV:*:*)
 12.1166 +	if [ -d /usr/nec ]; then
 12.1167 +	        echo mips-nec-sysv${UNAME_RELEASE}
 12.1168 +	else
 12.1169 +	        echo mips-unknown-sysv${UNAME_RELEASE}
 12.1170 +	fi
 12.1171 +        exit ;;
 12.1172 +    BeBox:BeOS:*:*)	# BeOS running on hardware made by Be, PPC only.
 12.1173 +	echo powerpc-be-beos
 12.1174 +	exit ;;
 12.1175 +    BeMac:BeOS:*:*)	# BeOS running on Mac or Mac clone, PPC only.
 12.1176 +	echo powerpc-apple-beos
 12.1177 +	exit ;;
 12.1178 +    BePC:BeOS:*:*)	# BeOS running on Intel PC compatible.
 12.1179 +	echo i586-pc-beos
 12.1180 +	exit ;;
 12.1181 +    BePC:Haiku:*:*)	# Haiku running on Intel PC compatible.
 12.1182 +	echo i586-pc-haiku
 12.1183 +	exit ;;
 12.1184 +    SX-4:SUPER-UX:*:*)
 12.1185 +	echo sx4-nec-superux${UNAME_RELEASE}
 12.1186 +	exit ;;
 12.1187 +    SX-5:SUPER-UX:*:*)
 12.1188 +	echo sx5-nec-superux${UNAME_RELEASE}
 12.1189 +	exit ;;
 12.1190 +    SX-6:SUPER-UX:*:*)
 12.1191 +	echo sx6-nec-superux${UNAME_RELEASE}
 12.1192 +	exit ;;
 12.1193 +    SX-7:SUPER-UX:*:*)
 12.1194 +	echo sx7-nec-superux${UNAME_RELEASE}
 12.1195 +	exit ;;
 12.1196 +    SX-8:SUPER-UX:*:*)
 12.1197 +	echo sx8-nec-superux${UNAME_RELEASE}
 12.1198 +	exit ;;
 12.1199 +    SX-8R:SUPER-UX:*:*)
 12.1200 +	echo sx8r-nec-superux${UNAME_RELEASE}
 12.1201 +	exit ;;
 12.1202 +    Power*:Rhapsody:*:*)
 12.1203 +	echo powerpc-apple-rhapsody${UNAME_RELEASE}
 12.1204 +	exit ;;
 12.1205 +    *:Rhapsody:*:*)
 12.1206 +	echo ${UNAME_MACHINE}-apple-rhapsody${UNAME_RELEASE}
 12.1207 +	exit ;;
 12.1208 +    *:Darwin:*:*)
 12.1209 +	UNAME_PROCESSOR=`uname -p` || UNAME_PROCESSOR=unknown
 12.1210 +	case $UNAME_PROCESSOR in
 12.1211 +	    i386)
 12.1212 +		eval $set_cc_for_build
 12.1213 +		if [ "$CC_FOR_BUILD" != 'no_compiler_found' ]; then
 12.1214 +		  if (echo '#ifdef __LP64__'; echo IS_64BIT_ARCH; echo '#endif') | \
 12.1215 +		      (CCOPTS= $CC_FOR_BUILD -E - 2>/dev/null) | \
 12.1216 +		      grep IS_64BIT_ARCH >/dev/null
 12.1217 +		  then
 12.1218 +		      UNAME_PROCESSOR="x86_64"
 12.1219 +		  fi
 12.1220 +		fi ;;
 12.1221 +	    unknown) UNAME_PROCESSOR=powerpc ;;
 12.1222 +	esac
 12.1223 +	echo ${UNAME_PROCESSOR}-apple-darwin${UNAME_RELEASE}
 12.1224 +	exit ;;
 12.1225 +    *:procnto*:*:* | *:QNX:[0123456789]*:*)
 12.1226 +	UNAME_PROCESSOR=`uname -p`
 12.1227 +	if test "$UNAME_PROCESSOR" = "x86"; then
 12.1228 +		UNAME_PROCESSOR=i386
 12.1229 +		UNAME_MACHINE=pc
 12.1230 +	fi
 12.1231 +	echo ${UNAME_PROCESSOR}-${UNAME_MACHINE}-nto-qnx${UNAME_RELEASE}
 12.1232 +	exit ;;
 12.1233 +    *:QNX:*:4*)
 12.1234 +	echo i386-pc-qnx
 12.1235 +	exit ;;
 12.1236 +    NSE-?:NONSTOP_KERNEL:*:*)
 12.1237 +	echo nse-tandem-nsk${UNAME_RELEASE}
 12.1238 +	exit ;;
 12.1239 +    NSR-?:NONSTOP_KERNEL:*:*)
 12.1240 +	echo nsr-tandem-nsk${UNAME_RELEASE}
 12.1241 +	exit ;;
 12.1242 +    *:NonStop-UX:*:*)
 12.1243 +	echo mips-compaq-nonstopux
 12.1244 +	exit ;;
 12.1245 +    BS2000:POSIX*:*:*)
 12.1246 +	echo bs2000-siemens-sysv
 12.1247 +	exit ;;
 12.1248 +    DS/*:UNIX_System_V:*:*)
 12.1249 +	echo ${UNAME_MACHINE}-${UNAME_SYSTEM}-${UNAME_RELEASE}
 12.1250 +	exit ;;
 12.1251 +    *:Plan9:*:*)
 12.1252 +	# "uname -m" is not consistent, so use $cputype instead. 386
 12.1253 +	# is converted to i386 for consistency with other x86
 12.1254 +	# operating systems.
 12.1255 +	if test "$cputype" = "386"; then
 12.1256 +	    UNAME_MACHINE=i386
 12.1257 +	else
 12.1258 +	    UNAME_MACHINE="$cputype"
 12.1259 +	fi
 12.1260 +	echo ${UNAME_MACHINE}-unknown-plan9
 12.1261 +	exit ;;
 12.1262 +    *:TOPS-10:*:*)
 12.1263 +	echo pdp10-unknown-tops10
 12.1264 +	exit ;;
 12.1265 +    *:TENEX:*:*)
 12.1266 +	echo pdp10-unknown-tenex
 12.1267 +	exit ;;
 12.1268 +    KS10:TOPS-20:*:* | KL10:TOPS-20:*:* | TYPE4:TOPS-20:*:*)
 12.1269 +	echo pdp10-dec-tops20
 12.1270 +	exit ;;
 12.1271 +    XKL-1:TOPS-20:*:* | TYPE5:TOPS-20:*:*)
 12.1272 +	echo pdp10-xkl-tops20
 12.1273 +	exit ;;
 12.1274 +    *:TOPS-20:*:*)
 12.1275 +	echo pdp10-unknown-tops20
 12.1276 +	exit ;;
 12.1277 +    *:ITS:*:*)
 12.1278 +	echo pdp10-unknown-its
 12.1279 +	exit ;;
 12.1280 +    SEI:*:*:SEIUX)
 12.1281 +        echo mips-sei-seiux${UNAME_RELEASE}
 12.1282 +	exit ;;
 12.1283 +    *:DragonFly:*:*)
 12.1284 +	echo ${UNAME_MACHINE}-unknown-dragonfly`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'`
 12.1285 +	exit ;;
 12.1286 +    *:*VMS:*:*)
 12.1287 +    	UNAME_MACHINE=`(uname -p) 2>/dev/null`
 12.1288 +	case "${UNAME_MACHINE}" in
 12.1289 +	    A*) echo alpha-dec-vms ; exit ;;
 12.1290 +	    I*) echo ia64-dec-vms ; exit ;;
 12.1291 +	    V*) echo vax-dec-vms ; exit ;;
 12.1292 +	esac ;;
 12.1293 +    *:XENIX:*:SysV)
 12.1294 +	echo i386-pc-xenix
 12.1295 +	exit ;;
 12.1296 +    i*86:skyos:*:*)
 12.1297 +	echo ${UNAME_MACHINE}-pc-skyos`echo ${UNAME_RELEASE}` | sed -e 's/ .*$//'
 12.1298 +	exit ;;
 12.1299 +    i*86:rdos:*:*)
 12.1300 +	echo ${UNAME_MACHINE}-pc-rdos
 12.1301 +	exit ;;
 12.1302 +    i*86:AROS:*:*)
 12.1303 +	echo ${UNAME_MACHINE}-pc-aros
 12.1304 +	exit ;;
 12.1305 +esac
 12.1306 +
 12.1307 +#echo '(No uname command or uname output not recognized.)' 1>&2
 12.1308 +#echo "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" 1>&2
 12.1309 +
 12.1310 +eval $set_cc_for_build
 12.1311 +cat >$dummy.c <<EOF
 12.1312 +#ifdef _SEQUENT_
 12.1313 +# include <sys/types.h>
 12.1314 +# include <sys/utsname.h>
 12.1315 +#endif
 12.1316 +main ()
 12.1317 +{
 12.1318 +#if defined (sony)
 12.1319 +#if defined (MIPSEB)
 12.1320 +  /* BFD wants "bsd" instead of "newsos".  Perhaps BFD should be changed,
 12.1321 +     I don't know....  */
 12.1322 +  printf ("mips-sony-bsd\n"); exit (0);
 12.1323 +#else
 12.1324 +#include <sys/param.h>
 12.1325 +  printf ("m68k-sony-newsos%s\n",
 12.1326 +#ifdef NEWSOS4
 12.1327 +          "4"
 12.1328 +#else
 12.1329 +	  ""
 12.1330 +#endif
 12.1331 +         ); exit (0);
 12.1332 +#endif
 12.1333 +#endif
 12.1334 +
 12.1335 +#if defined (__arm) && defined (__acorn) && defined (__unix)
 12.1336 +  printf ("arm-acorn-riscix\n"); exit (0);
 12.1337 +#endif
 12.1338 +
 12.1339 +#if defined (hp300) && !defined (hpux)
 12.1340 +  printf ("m68k-hp-bsd\n"); exit (0);
 12.1341 +#endif
 12.1342 +
 12.1343 +#if defined (NeXT)
 12.1344 +#if !defined (__ARCHITECTURE__)
 12.1345 +#define __ARCHITECTURE__ "m68k"
 12.1346 +#endif
 12.1347 +  int version;
 12.1348 +  version=`(hostinfo | sed -n 's/.*NeXT Mach \([0-9]*\).*/\1/p') 2>/dev/null`;
 12.1349 +  if (version < 4)
 12.1350 +    printf ("%s-next-nextstep%d\n", __ARCHITECTURE__, version);
 12.1351 +  else
 12.1352 +    printf ("%s-next-openstep%d\n", __ARCHITECTURE__, version);
 12.1353 +  exit (0);
 12.1354 +#endif
 12.1355 +
 12.1356 +#if defined (MULTIMAX) || defined (n16)
 12.1357 +#if defined (UMAXV)
 12.1358 +  printf ("ns32k-encore-sysv\n"); exit (0);
 12.1359 +#else
 12.1360 +#if defined (CMU)
 12.1361 +  printf ("ns32k-encore-mach\n"); exit (0);
 12.1362 +#else
 12.1363 +  printf ("ns32k-encore-bsd\n"); exit (0);
 12.1364 +#endif
 12.1365 +#endif
 12.1366 +#endif
 12.1367 +
 12.1368 +#if defined (__386BSD__)
 12.1369 +  printf ("i386-pc-bsd\n"); exit (0);
 12.1370 +#endif
 12.1371 +
 12.1372 +#if defined (sequent)
 12.1373 +#if defined (i386)
 12.1374 +  printf ("i386-sequent-dynix\n"); exit (0);
 12.1375 +#endif
 12.1376 +#if defined (ns32000)
 12.1377 +  printf ("ns32k-sequent-dynix\n"); exit (0);
 12.1378 +#endif
 12.1379 +#endif
 12.1380 +
 12.1381 +#if defined (_SEQUENT_)
 12.1382 +    struct utsname un;
 12.1383 +
 12.1384 +    uname(&un);
 12.1385 +
 12.1386 +    if (strncmp(un.version, "V2", 2) == 0) {
 12.1387 +	printf ("i386-sequent-ptx2\n"); exit (0);
 12.1388 +    }
 12.1389 +    if (strncmp(un.version, "V1", 2) == 0) { /* XXX is V1 correct? */
 12.1390 +	printf ("i386-sequent-ptx1\n"); exit (0);
 12.1391 +    }
 12.1392 +    printf ("i386-sequent-ptx\n"); exit (0);
 12.1393 +
 12.1394 +#endif
 12.1395 +
 12.1396 +#if defined (vax)
 12.1397 +# if !defined (ultrix)
 12.1398 +#  include <sys/param.h>
 12.1399 +#  if defined (BSD)
 12.1400 +#   if BSD == 43
 12.1401 +      printf ("vax-dec-bsd4.3\n"); exit (0);
 12.1402 +#   else
 12.1403 +#    if BSD == 199006
 12.1404 +      printf ("vax-dec-bsd4.3reno\n"); exit (0);
 12.1405 +#    else
 12.1406 +      printf ("vax-dec-bsd\n"); exit (0);
 12.1407 +#    endif
 12.1408 +#   endif
 12.1409 +#  else
 12.1410 +    printf ("vax-dec-bsd\n"); exit (0);
 12.1411 +#  endif
 12.1412 +# else
 12.1413 +    printf ("vax-dec-ultrix\n"); exit (0);
 12.1414 +# endif
 12.1415 +#endif
 12.1416 +
 12.1417 +#if defined (alliant) && defined (i860)
 12.1418 +  printf ("i860-alliant-bsd\n"); exit (0);
 12.1419 +#endif
 12.1420 +
 12.1421 +  exit (1);
 12.1422 +}
 12.1423 +EOF
 12.1424 +
 12.1425 +$CC_FOR_BUILD -o $dummy $dummy.c 2>/dev/null && SYSTEM_NAME=`$dummy` &&
 12.1426 +	{ echo "$SYSTEM_NAME"; exit; }
 12.1427 +
 12.1428 +# Apollos put the system type in the environment.
 12.1429 +
 12.1430 +test -d /usr/apollo && { echo ${ISP}-apollo-${SYSTYPE}; exit; }
 12.1431 +
 12.1432 +# Convex versions that predate uname can use getsysinfo(1)
 12.1433 +
 12.1434 +if [ -x /usr/convex/getsysinfo ]
 12.1435 +then
 12.1436 +    case `getsysinfo -f cpu_type` in
 12.1437 +    c1*)
 12.1438 +	echo c1-convex-bsd
 12.1439 +	exit ;;
 12.1440 +    c2*)
 12.1441 +	if getsysinfo -f scalar_acc
 12.1442 +	then echo c32-convex-bsd
 12.1443 +	else echo c2-convex-bsd
 12.1444 +	fi
 12.1445 +	exit ;;
 12.1446 +    c34*)
 12.1447 +	echo c34-convex-bsd
 12.1448 +	exit ;;
 12.1449 +    c38*)
 12.1450 +	echo c38-convex-bsd
 12.1451 +	exit ;;
 12.1452 +    c4*)
 12.1453 +	echo c4-convex-bsd
 12.1454 +	exit ;;
 12.1455 +    esac
 12.1456 +fi
 12.1457 +
 12.1458 +cat >&2 <<EOF
 12.1459 +$0: unable to guess system type
 12.1460 +
 12.1461 +This script, last modified $timestamp, has failed to recognize
 12.1462 +the operating system you are using. It is advised that you
 12.1463 +download the most up to date version of the config scripts from
 12.1464 +
 12.1465 +  http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.guess;hb=HEAD
 12.1466 +and
 12.1467 +  http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.sub;hb=HEAD
 12.1468 +
 12.1469 +If the version you run ($0) is already up to date, please
 12.1470 +send the following data and any information you think might be
 12.1471 +pertinent to <config-patches@gnu.org> in order to provide the needed
 12.1472 +information to handle your system.
 12.1473 +
 12.1474 +config.guess timestamp = $timestamp
 12.1475 +
 12.1476 +uname -m = `(uname -m) 2>/dev/null || echo unknown`
 12.1477 +uname -r = `(uname -r) 2>/dev/null || echo unknown`
 12.1478 +uname -s = `(uname -s) 2>/dev/null || echo unknown`
 12.1479 +uname -v = `(uname -v) 2>/dev/null || echo unknown`
 12.1480 +
 12.1481 +/usr/bin/uname -p = `(/usr/bin/uname -p) 2>/dev/null`
 12.1482 +/bin/uname -X     = `(/bin/uname -X) 2>/dev/null`
 12.1483 +
 12.1484 +hostinfo               = `(hostinfo) 2>/dev/null`
 12.1485 +/bin/universe          = `(/bin/universe) 2>/dev/null`
 12.1486 +/usr/bin/arch -k       = `(/usr/bin/arch -k) 2>/dev/null`
 12.1487 +/bin/arch              = `(/bin/arch) 2>/dev/null`
 12.1488 +/usr/bin/oslevel       = `(/usr/bin/oslevel) 2>/dev/null`
 12.1489 +/usr/convex/getsysinfo = `(/usr/convex/getsysinfo) 2>/dev/null`
 12.1490 +
 12.1491 +UNAME_MACHINE = ${UNAME_MACHINE}
 12.1492 +UNAME_RELEASE = ${UNAME_RELEASE}
 12.1493 +UNAME_SYSTEM  = ${UNAME_SYSTEM}
 12.1494 +UNAME_VERSION = ${UNAME_VERSION}
 12.1495 +EOF
 12.1496 +
 12.1497 +exit 1
 12.1498 +
 12.1499 +# Local variables:
 12.1500 +# eval: (add-hook 'write-file-hooks 'time-stamp)
 12.1501 +# time-stamp-start: "timestamp='"
 12.1502 +# time-stamp-format: "%:y-%02m-%02d"
 12.1503 +# time-stamp-end: "'"
 12.1504 +# End:
    13.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    13.2 +++ b/deps/glpk/config.h.in	Sun Nov 06 20:59:10 2011 +0100
    13.3 @@ -0,0 +1,27 @@
    13.4 +/* config.h.in (GLPK configuration template file) */
    13.5 +
    13.6 +#undef HAVE_SYS_TIME_H
    13.7 +/* defined if the <sys/time.h> header can be used */
    13.8 +
    13.9 +#undef HAVE_GETTIMEOFDAY
   13.10 +/* defined if the gettimeofday function can be used */
   13.11 +
   13.12 +#undef HAVE_GMP
   13.13 +/* defined if the GNU MP bignum library is available */
   13.14 +/* requires <gmp.h> and -lgmp */
   13.15 +
   13.16 +#undef HAVE_LTDL
   13.17 +/* defined if the GNU Libtool shared library support is enabled */
   13.18 +/* requires <ltdl.h> and -lltdl */
   13.19 +
   13.20 +#undef HAVE_DLFCN
   13.21 +/* defined if the POSIX shared library support is enabled */
   13.22 +/* requires <dlfcn.h> */
   13.23 +
   13.24 +#undef ODBC_DLNAME
   13.25 +/* ODBC shared library name if this feature is enabled */
   13.26 +
   13.27 +#undef MYSQL_DLNAME
   13.28 +/* MySQL shared library name if this feature is enabled */
   13.29 +
   13.30 +/* eof */
    14.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    14.2 +++ b/deps/glpk/config.sub	Sun Nov 06 20:59:10 2011 +0100
    14.3 @@ -0,0 +1,1705 @@
    14.4 +#! /bin/sh
    14.5 +# Configuration validation subroutine script.
    14.6 +#   Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
    14.7 +#   2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009
    14.8 +#   Free Software Foundation, Inc.
    14.9 +
   14.10 +timestamp='2009-11-20'
   14.11 +
   14.12 +# This file is (in principle) common to ALL GNU software.
   14.13 +# The presence of a machine in this file suggests that SOME GNU software
   14.14 +# can handle that machine.  It does not imply ALL GNU software can.
   14.15 +#
   14.16 +# This file is free software; you can redistribute it and/or modify
   14.17 +# it under the terms of the GNU General Public License as published by
   14.18 +# the Free Software Foundation; either version 2 of the License, or
   14.19 +# (at your option) any later version.
   14.20 +#
   14.21 +# This program is distributed in the hope that it will be useful,
   14.22 +# but WITHOUT ANY WARRANTY; without even the implied warranty of
   14.23 +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   14.24 +# GNU General Public License for more details.
   14.25 +#
   14.26 +# You should have received a copy of the GNU General Public License
   14.27 +# along with this program; if not, write to the Free Software
   14.28 +# Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA
   14.29 +# 02110-1301, USA.
   14.30 +#
   14.31 +# As a special exception to the GNU General Public License, if you
   14.32 +# distribute this file as part of a program that contains a
   14.33 +# configuration script generated by Autoconf, you may include it under
   14.34 +# the same distribution terms that you use for the rest of that program.
   14.35 +
   14.36 +
   14.37 +# Please send patches to <config-patches@gnu.org>.  Submit a context
   14.38 +# diff and a properly formatted GNU ChangeLog entry.
   14.39 +#
   14.40 +# Configuration subroutine to validate and canonicalize a configuration type.
   14.41 +# Supply the specified configuration type as an argument.
   14.42 +# If it is invalid, we print an error message on stderr and exit with code 1.
   14.43 +# Otherwise, we print the canonical config type on stdout and succeed.
   14.44 +
   14.45 +# You can get the latest version of this script from:
   14.46 +# http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.sub;hb=HEAD
   14.47 +
   14.48 +# This file is supposed to be the same for all GNU packages
   14.49 +# and recognize all the CPU types, system types and aliases
   14.50 +# that are meaningful with *any* GNU software.
   14.51 +# Each package is responsible for reporting which valid configurations
   14.52 +# it does not support.  The user should be able to distinguish
   14.53 +# a failure to support a valid configuration from a meaningless
   14.54 +# configuration.
   14.55 +
   14.56 +# The goal of this file is to map all the various variations of a given
   14.57 +# machine specification into a single specification in the form:
   14.58 +#	CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM
   14.59 +# or in some cases, the newer four-part form:
   14.60 +#	CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM
   14.61 +# It is wrong to echo any other type of specification.
   14.62 +
   14.63 +me=`echo "$0" | sed -e 's,.*/,,'`
   14.64 +
   14.65 +usage="\
   14.66 +Usage: $0 [OPTION] CPU-MFR-OPSYS
   14.67 +       $0 [OPTION] ALIAS
   14.68 +
   14.69 +Canonicalize a configuration name.
   14.70 +
   14.71 +Operation modes:
   14.72 +  -h, --help         print this help, then exit
   14.73 +  -t, --time-stamp   print date of last modification, then exit
   14.74 +  -v, --version      print version number, then exit
   14.75 +
   14.76 +Report bugs and patches to <config-patches@gnu.org>."
   14.77 +
   14.78 +version="\
   14.79 +GNU config.sub ($timestamp)
   14.80 +
   14.81 +Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001,
   14.82 +2002, 2003, 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc.
   14.83 +
   14.84 +This is free software; see the source for copying conditions.  There is NO
   14.85 +warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE."
   14.86 +
   14.87 +help="
   14.88 +Try \`$me --help' for more information."
   14.89 +
   14.90 +# Parse command line
   14.91 +while test $# -gt 0 ; do
   14.92 +  case $1 in
   14.93 +    --time-stamp | --time* | -t )
   14.94 +       echo "$timestamp" ; exit ;;
   14.95 +    --version | -v )
   14.96 +       echo "$version" ; exit ;;
   14.97 +    --help | --h* | -h )
   14.98 +       echo "$usage"; exit ;;
   14.99 +    -- )     # Stop option processing
  14.100 +       shift; break ;;
  14.101 +    - )	# Use stdin as input.
  14.102 +       break ;;
  14.103 +    -* )
  14.104 +       echo "$me: invalid option $1$help"
  14.105 +       exit 1 ;;
  14.106 +
  14.107 +    *local*)
  14.108 +       # First pass through any local machine types.
  14.109 +       echo $1
  14.110 +       exit ;;
  14.111 +
  14.112 +    * )
  14.113 +       break ;;
  14.114 +  esac
  14.115 +done
  14.116 +
  14.117 +case $# in
  14.118 + 0) echo "$me: missing argument$help" >&2
  14.119 +    exit 1;;
  14.120 + 1) ;;
  14.121 + *) echo "$me: too many arguments$help" >&2
  14.122 +    exit 1;;
  14.123 +esac
  14.124 +
  14.125 +# Separate what the user gave into CPU-COMPANY and OS or KERNEL-OS (if any).
  14.126 +# Here we must recognize all the valid KERNEL-OS combinations.
  14.127 +maybe_os=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\2/'`
  14.128 +case $maybe_os in
  14.129 +  nto-qnx* | linux-gnu* | linux-dietlibc | linux-newlib* | linux-uclibc* | \
  14.130 +  uclinux-uclibc* | uclinux-gnu* | kfreebsd*-gnu* | knetbsd*-gnu* | netbsd*-gnu* | \
  14.131 +  kopensolaris*-gnu* | \
  14.132 +  storm-chaos* | os2-emx* | rtmk-nova*)
  14.133 +    os=-$maybe_os
  14.134 +    basic_machine=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\1/'`
  14.135 +    ;;
  14.136 +  *)
  14.137 +    basic_machine=`echo $1 | sed 's/-[^-]*$//'`
  14.138 +    if [ $basic_machine != $1 ]
  14.139 +    then os=`echo $1 | sed 's/.*-/-/'`
  14.140 +    else os=; fi
  14.141 +    ;;
  14.142 +esac
  14.143 +
  14.144 +### Let's recognize common machines as not being operating systems so
  14.145 +### that things like config.sub decstation-3100 work.  We also
  14.146 +### recognize some manufacturers as not being operating systems, so we
  14.147 +### can provide default operating systems below.
  14.148 +case $os in
  14.149 +	-sun*os*)
  14.150 +		# Prevent following clause from handling this invalid input.
  14.151 +		;;
  14.152 +	-dec* | -mips* | -sequent* | -encore* | -pc532* | -sgi* | -sony* | \
  14.153 +	-att* | -7300* | -3300* | -delta* | -motorola* | -sun[234]* | \
  14.154 +	-unicom* | -ibm* | -next | -hp | -isi* | -apollo | -altos* | \
  14.155 +	-convergent* | -ncr* | -news | -32* | -3600* | -3100* | -hitachi* |\
  14.156 +	-c[123]* | -convex* | -sun | -crds | -omron* | -dg | -ultra | -tti* | \
  14.157 +	-harris | -dolphin | -highlevel | -gould | -cbm | -ns | -masscomp | \
  14.158 +	-apple | -axis | -knuth | -cray | -microblaze)
  14.159 +		os=
  14.160 +		basic_machine=$1
  14.161 +		;;
  14.162 +        -bluegene*)
  14.163 +	        os=-cnk
  14.164 +		;;
  14.165 +	-sim | -cisco | -oki | -wec | -winbond)
  14.166 +		os=
  14.167 +		basic_machine=$1
  14.168 +		;;
  14.169 +	-scout)
  14.170 +		;;
  14.171 +	-wrs)
  14.172 +		os=-vxworks
  14.173 +		basic_machine=$1
  14.174 +		;;
  14.175 +	-chorusos*)
  14.176 +		os=-chorusos
  14.177 +		basic_machine=$1
  14.178 +		;;
  14.179 + 	-chorusrdb)
  14.180 + 		os=-chorusrdb
  14.181 +		basic_machine=$1
  14.182 + 		;;
  14.183 +	-hiux*)
  14.184 +		os=-hiuxwe2
  14.185 +		;;
  14.186 +	-sco6)
  14.187 +		os=-sco5v6
  14.188 +		basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
  14.189 +		;;
  14.190 +	-sco5)
  14.191 +		os=-sco3.2v5
  14.192 +		basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
  14.193 +		;;
  14.194 +	-sco4)
  14.195 +		os=-sco3.2v4
  14.196 +		basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
  14.197 +		;;
  14.198 +	-sco3.2.[4-9]*)
  14.199 +		os=`echo $os | sed -e 's/sco3.2./sco3.2v/'`
  14.200 +		basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
  14.201 +		;;
  14.202 +	-sco3.2v[4-9]*)
  14.203 +		# Don't forget version if it is 3.2v4 or newer.
  14.204 +		basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
  14.205 +		;;
  14.206 +	-sco5v6*)
  14.207 +		# Don't forget version if it is 3.2v4 or newer.
  14.208 +		basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
  14.209 +		;;
  14.210 +	-sco*)
  14.211 +		os=-sco3.2v2
  14.212 +		basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
  14.213 +		;;
  14.214 +	-udk*)
  14.215 +		basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
  14.216 +		;;
  14.217 +	-isc)
  14.218 +		os=-isc2.2
  14.219 +		basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
  14.220 +		;;
  14.221 +	-clix*)
  14.222 +		basic_machine=clipper-intergraph
  14.223 +		;;
  14.224 +	-isc*)
  14.225 +		basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
  14.226 +		;;
  14.227 +	-lynx*)
  14.228 +		os=-lynxos
  14.229 +		;;
  14.230 +	-ptx*)
  14.231 +		basic_machine=`echo $1 | sed -e 's/86-.*/86-sequent/'`
  14.232 +		;;
  14.233 +	-windowsnt*)
  14.234 +		os=`echo $os | sed -e 's/windowsnt/winnt/'`
  14.235 +		;;
  14.236 +	-psos*)
  14.237 +		os=-psos
  14.238 +		;;
  14.239 +	-mint | -mint[0-9]*)
  14.240 +		basic_machine=m68k-atari
  14.241 +		os=-mint
  14.242 +		;;
  14.243 +esac
  14.244 +
  14.245 +# Decode aliases for certain CPU-COMPANY combinations.
  14.246 +case $basic_machine in
  14.247 +	# Recognize the basic CPU types without company name.
  14.248 +	# Some are omitted here because they have special meanings below.
  14.249 +	1750a | 580 \
  14.250 +	| a29k \
  14.251 +	| alpha | alphaev[4-8] | alphaev56 | alphaev6[78] | alphapca5[67] \
  14.252 +	| alpha64 | alpha64ev[4-8] | alpha64ev56 | alpha64ev6[78] | alpha64pca5[67] \
  14.253 +	| am33_2.0 \
  14.254 +	| arc | arm | arm[bl]e | arme[lb] | armv[2345] | armv[345][lb] | avr | avr32 \
  14.255 +	| bfin \
  14.256 +	| c4x | clipper \
  14.257 +	| d10v | d30v | dlx | dsp16xx \
  14.258 +	| fido | fr30 | frv \
  14.259 +	| h8300 | h8500 | hppa | hppa1.[01] | hppa2.0 | hppa2.0[nw] | hppa64 \
  14.260 +	| i370 | i860 | i960 | ia64 \
  14.261 +	| ip2k | iq2000 \
  14.262 +	| lm32 \
  14.263 +	| m32c | m32r | m32rle | m68000 | m68k | m88k \
  14.264 +	| maxq | mb | microblaze | mcore | mep | metag \
  14.265 +	| mips | mipsbe | mipseb | mipsel | mipsle \
  14.266 +	| mips16 \
  14.267 +	| mips64 | mips64el \
  14.268 +	| mips64octeon | mips64octeonel \
  14.269 +	| mips64orion | mips64orionel \
  14.270 +	| mips64r5900 | mips64r5900el \
  14.271 +	| mips64vr | mips64vrel \
  14.272 +	| mips64vr4100 | mips64vr4100el \
  14.273 +	| mips64vr4300 | mips64vr4300el \
  14.274 +	| mips64vr5000 | mips64vr5000el \
  14.275 +	| mips64vr5900 | mips64vr5900el \
  14.276 +	| mipsisa32 | mipsisa32el \
  14.277 +	| mipsisa32r2 | mipsisa32r2el \
  14.278 +	| mipsisa64 | mipsisa64el \
  14.279 +	| mipsisa64r2 | mipsisa64r2el \
  14.280 +	| mipsisa64sb1 | mipsisa64sb1el \
  14.281 +	| mipsisa64sr71k | mipsisa64sr71kel \
  14.282 +	| mipstx39 | mipstx39el \
  14.283 +	| mn10200 | mn10300 \
  14.284 +	| moxie \
  14.285 +	| mt \
  14.286 +	| msp430 \
  14.287 +	| nios | nios2 \
  14.288 +	| ns16k | ns32k \
  14.289 +	| or32 \
  14.290 +	| pdp10 | pdp11 | pj | pjl \
  14.291 +	| powerpc | powerpc64 | powerpc64le | powerpcle | ppcbe \
  14.292 +	| pyramid \
  14.293 +	| rx \
  14.294 +	| score \
  14.295 +	| sh | sh[1234] | sh[24]a | sh[24]aeb | sh[23]e | sh[34]eb | sheb | shbe | shle | sh[1234]le | sh3ele \
  14.296 +	| sh64 | sh64le \
  14.297 +	| sparc | sparc64 | sparc64b | sparc64v | sparc86x | sparclet | sparclite \
  14.298 +	| sparcv8 | sparcv9 | sparcv9b | sparcv9v \
  14.299 +	| spu | strongarm \
  14.300 +	| tahoe | thumb | tic4x | tic80 | tron \
  14.301 +	| ubicom32 \
  14.302 +	| v850 | v850e \
  14.303 +	| we32k \
  14.304 +	| x86 | xc16x | xscale | xscalee[bl] | xstormy16 | xtensa \
  14.305 +	| z8k | z80)
  14.306 +		basic_machine=$basic_machine-unknown
  14.307 +		;;
  14.308 +	m6811 | m68hc11 | m6812 | m68hc12 | picochip)
  14.309 +		# Motorola 68HC11/12.
  14.310 +		basic_machine=$basic_machine-unknown
  14.311 +		os=-none
  14.312 +		;;
  14.313 +	m88110 | m680[12346]0 | m683?2 | m68360 | m5200 | v70 | w65 | z8k)
  14.314 +		;;
  14.315 +	ms1)
  14.316 +		basic_machine=mt-unknown
  14.317 +		;;
  14.318 +
  14.319 +	# We use `pc' rather than `unknown'
  14.320 +	# because (1) that's what they normally are, and
  14.321 +	# (2) the word "unknown" tends to confuse beginning users.
  14.322 +	i*86 | x86_64)
  14.323 +	  basic_machine=$basic_machine-pc
  14.324 +	  ;;
  14.325 +	# Object if more than one company name word.
  14.326 +	*-*-*)
  14.327 +		echo Invalid configuration \`$1\': machine \`$basic_machine\' not recognized 1>&2
  14.328 +		exit 1
  14.329 +		;;
  14.330 +	# Recognize the basic CPU types with company name.
  14.331 +	580-* \
  14.332 +	| a29k-* \
  14.333 +	| alpha-* | alphaev[4-8]-* | alphaev56-* | alphaev6[78]-* \
  14.334 +	| alpha64-* | alpha64ev[4-8]-* | alpha64ev56-* | alpha64ev6[78]-* \
  14.335 +	| alphapca5[67]-* | alpha64pca5[67]-* | arc-* \
  14.336 +	| arm-*  | armbe-* | armle-* | armeb-* | armv*-* \
  14.337 +	| avr-* | avr32-* \
  14.338 +	| bfin-* | bs2000-* \
  14.339 +	| c[123]* | c30-* | [cjt]90-* | c4x-* | c54x-* | c55x-* | c6x-* \
  14.340 +	| clipper-* | craynv-* | cydra-* \
  14.341 +	| d10v-* | d30v-* | dlx-* \
  14.342 +	| elxsi-* \
  14.343 +	| f30[01]-* | f700-* | fido-* | fr30-* | frv-* | fx80-* \
  14.344 +	| h8300-* | h8500-* \
  14.345 +	| hppa-* | hppa1.[01]-* | hppa2.0-* | hppa2.0[nw]-* | hppa64-* \
  14.346 +	| i*86-* | i860-* | i960-* | ia64-* \
  14.347 +	| ip2k-* | iq2000-* \
  14.348 +	| lm32-* \
  14.349 +	| m32c-* | m32r-* | m32rle-* \
  14.350 +	| m68000-* | m680[012346]0-* | m68360-* | m683?2-* | m68k-* \
  14.351 +	| m88110-* | m88k-* | maxq-* | mcore-* | metag-* | microblaze-* \
  14.352 +	| mips-* | mipsbe-* | mipseb-* | mipsel-* | mipsle-* \
  14.353 +	| mips16-* \
  14.354 +	| mips64-* | mips64el-* \
  14.355 +	| mips64octeon-* | mips64octeonel-* \
  14.356 +	| mips64orion-* | mips64orionel-* \
  14.357 +	| mips64r5900-* | mips64r5900el-* \
  14.358 +	| mips64vr-* | mips64vrel-* \
  14.359 +	| mips64vr4100-* | mips64vr4100el-* \
  14.360 +	| mips64vr4300-* | mips64vr4300el-* \
  14.361 +	| mips64vr5000-* | mips64vr5000el-* \
  14.362 +	| mips64vr5900-* | mips64vr5900el-* \
  14.363 +	| mipsisa32-* | mipsisa32el-* \
  14.364 +	| mipsisa32r2-* | mipsisa32r2el-* \
  14.365 +	| mipsisa64-* | mipsisa64el-* \
  14.366 +	| mipsisa64r2-* | mipsisa64r2el-* \
  14.367 +	| mipsisa64sb1-* | mipsisa64sb1el-* \
  14.368 +	| mipsisa64sr71k-* | mipsisa64sr71kel-* \
  14.369 +	| mipstx39-* | mipstx39el-* \
  14.370 +	| mmix-* \
  14.371 +	| mt-* \
  14.372 +	| msp430-* \
  14.373 +	| nios-* | nios2-* \
  14.374 +	| none-* | np1-* | ns16k-* | ns32k-* \
  14.375 +	| orion-* \
  14.376 +	| pdp10-* | pdp11-* | pj-* | pjl-* | pn-* | power-* \
  14.377 +	| powerpc-* | powerpc64-* | powerpc64le-* | powerpcle-* | ppcbe-* \
  14.378 +	| pyramid-* \
  14.379 +	| romp-* | rs6000-* | rx-* \
  14.380 +	| sh-* | sh[1234]-* | sh[24]a-* | sh[24]aeb-* | sh[23]e-* | sh[34]eb-* | sheb-* | shbe-* \
  14.381 +	| shle-* | sh[1234]le-* | sh3ele-* | sh64-* | sh64le-* \
  14.382 +	| sparc-* | sparc64-* | sparc64b-* | sparc64v-* | sparc86x-* | sparclet-* \
  14.383 +	| sparclite-* \
  14.384 +	| sparcv8-* | sparcv9-* | sparcv9b-* | sparcv9v-* | strongarm-* | sv1-* | sx?-* \
  14.385 +	| tahoe-* | thumb-* \
  14.386 +	| tic30-* | tic4x-* | tic54x-* | tic55x-* | tic6x-* | tic80-* | tile-* \
  14.387 +	| tron-* \
  14.388 +	| ubicom32-* \
  14.389 +	| v850-* | v850e-* | vax-* \
  14.390 +	| we32k-* \
  14.391 +	| x86-* | x86_64-* | xc16x-* | xps100-* | xscale-* | xscalee[bl]-* \
  14.392 +	| xstormy16-* | xtensa*-* \
  14.393 +	| ymp-* \
  14.394 +	| z8k-* | z80-*)
  14.395 +		;;
  14.396 +	# Recognize the basic CPU types without company name, with glob match.
  14.397 +	xtensa*)
  14.398 +		basic_machine=$basic_machine-unknown
  14.399 +		;;
  14.400 +	# Recognize the various machine names and aliases which stand
  14.401 +	# for a CPU type and a company and sometimes even an OS.
  14.402 +	386bsd)
  14.403 +		basic_machine=i386-unknown
  14.404 +		os=-bsd
  14.405 +		;;
  14.406 +	3b1 | 7300 | 7300-att | att-7300 | pc7300 | safari | unixpc)
  14.407 +		basic_machine=m68000-att
  14.408 +		;;
  14.409 +	3b*)
  14.410 +		basic_machine=we32k-att
  14.411 +		;;
  14.412 +	a29khif)
  14.413 +		basic_machine=a29k-amd
  14.414 +		os=-udi
  14.415 +		;;
  14.416 +    	abacus)
  14.417 +		basic_machine=abacus-unknown
  14.418 +		;;
  14.419 +	adobe68k)
  14.420 +		basic_machine=m68010-adobe
  14.421 +		os=-scout
  14.422 +		;;
  14.423 +	alliant | fx80)
  14.424 +		basic_machine=fx80-alliant
  14.425 +		;;
  14.426 +	altos | altos3068)
  14.427 +		basic_machine=m68k-altos
  14.428 +		;;
  14.429 +	am29k)
  14.430 +		basic_machine=a29k-none
  14.431 +		os=-bsd
  14.432 +		;;
  14.433 +	amd64)
  14.434 +		basic_machine=x86_64-pc
  14.435 +		;;
  14.436 +	amd64-*)
  14.437 +		basic_machine=x86_64-`echo $basic_machine | sed 's/^[^-]*-//'`
  14.438 +		;;
  14.439 +	amdahl)
  14.440 +		basic_machine=580-amdahl
  14.441 +		os=-sysv
  14.442 +		;;
  14.443 +	amiga | amiga-*)
  14.444 +		basic_machine=m68k-unknown
  14.445 +		;;
  14.446 +	amigaos | amigados)
  14.447 +		basic_machine=m68k-unknown
  14.448 +		os=-amigaos
  14.449 +		;;
  14.450 +	amigaunix | amix)
  14.451 +		basic_machine=m68k-unknown
  14.452 +		os=-sysv4
  14.453 +		;;
  14.454 +	apollo68)
  14.455 +		basic_machine=m68k-apollo
  14.456 +		os=-sysv
  14.457 +		;;
  14.458 +	apollo68bsd)
  14.459 +		basic_machine=m68k-apollo
  14.460 +		os=-bsd
  14.461 +		;;
  14.462 +	aros)
  14.463 +		basic_machine=i386-pc
  14.464 +		os=-aros
  14.465 +		;;
  14.466 +	aux)
  14.467 +		basic_machine=m68k-apple
  14.468 +		os=-aux
  14.469 +		;;
  14.470 +	balance)
  14.471 +		basic_machine=ns32k-sequent
  14.472 +		os=-dynix
  14.473 +		;;
  14.474 +	blackfin)
  14.475 +		basic_machine=bfin-unknown
  14.476 +		os=-linux
  14.477 +		;;
  14.478 +	blackfin-*)
  14.479 +		basic_machine=bfin-`echo $basic_machine | sed 's/^[^-]*-//'`
  14.480 +		os=-linux
  14.481 +		;;
  14.482 +	bluegene*)
  14.483 +		basic_machine=powerpc-ibm
  14.484 +		os=-cnk
  14.485 +		;;
  14.486 +	c90)
  14.487 +		basic_machine=c90-cray
  14.488 +		os=-unicos
  14.489 +		;;
  14.490 +        cegcc)
  14.491 +		basic_machine=arm-unknown
  14.492 +		os=-cegcc
  14.493 +		;;
  14.494 +	convex-c1)
  14.495 +		basic_machine=c1-convex
  14.496 +		os=-bsd
  14.497 +		;;
  14.498 +	convex-c2)
  14.499 +		basic_machine=c2-convex
  14.500 +		os=-bsd
  14.501 +		;;
  14.502 +	convex-c32)
  14.503 +		basic_machine=c32-convex
  14.504 +		os=-bsd
  14.505 +		;;
  14.506 +	convex-c34)
  14.507 +		basic_machine=c34-convex
  14.508 +		os=-bsd
  14.509 +		;;
  14.510 +	convex-c38)
  14.511 +		basic_machine=c38-convex
  14.512 +		os=-bsd
  14.513 +		;;
  14.514 +	cray | j90)
  14.515 +		basic_machine=j90-cray
  14.516 +		os=-unicos
  14.517 +		;;
  14.518 +	craynv)
  14.519 +		basic_machine=craynv-cray
  14.520 +		os=-unicosmp
  14.521 +		;;
  14.522 +	cr16)
  14.523 +		basic_machine=cr16-unknown
  14.524 +		os=-elf
  14.525 +		;;
  14.526 +	crds | unos)
  14.527 +		basic_machine=m68k-crds
  14.528 +		;;
  14.529 +	crisv32 | crisv32-* | etraxfs*)
  14.530 +		basic_machine=crisv32-axis
  14.531 +		;;
  14.532 +	cris | cris-* | etrax*)
  14.533 +		basic_machine=cris-axis
  14.534 +		;;
  14.535 +	crx)
  14.536 +		basic_machine=crx-unknown
  14.537 +		os=-elf
  14.538 +		;;
  14.539 +	da30 | da30-*)
  14.540 +		basic_machine=m68k-da30
  14.541 +		;;
  14.542 +	decstation | decstation-3100 | pmax | pmax-* | pmin | dec3100 | decstatn)
  14.543 +		basic_machine=mips-dec
  14.544 +		;;
  14.545 +	decsystem10* | dec10*)
  14.546 +		basic_machine=pdp10-dec
  14.547 +		os=-tops10
  14.548 +		;;
  14.549 +	decsystem20* | dec20*)
  14.550 +		basic_machine=pdp10-dec
  14.551 +		os=-tops20
  14.552 +		;;
  14.553 +	delta | 3300 | motorola-3300 | motorola-delta \
  14.554 +	      | 3300-motorola | delta-motorola)
  14.555 +		basic_machine=m68k-motorola
  14.556 +		;;
  14.557 +	delta88)
  14.558 +		basic_machine=m88k-motorola
  14.559 +		os=-sysv3
  14.560 +		;;
  14.561 +	dicos)
  14.562 +		basic_machine=i686-pc
  14.563 +		os=-dicos
  14.564 +		;;
  14.565 +	djgpp)
  14.566 +		basic_machine=i586-pc
  14.567 +		os=-msdosdjgpp
  14.568 +		;;
  14.569 +	dpx20 | dpx20-*)
  14.570 +		basic_machine=rs6000-bull
  14.571 +		os=-bosx
  14.572 +		;;
  14.573 +	dpx2* | dpx2*-bull)
  14.574 +		basic_machine=m68k-bull
  14.575 +		os=-sysv3
  14.576 +		;;
  14.577 +	ebmon29k)
  14.578 +		basic_machine=a29k-amd
  14.579 +		os=-ebmon
  14.580 +		;;
  14.581 +	elxsi)
  14.582 +		basic_machine=elxsi-elxsi
  14.583 +		os=-bsd
  14.584 +		;;
  14.585 +	encore | umax | mmax)
  14.586 +		basic_machine=ns32k-encore
  14.587 +		;;
  14.588 +	es1800 | OSE68k | ose68k | ose | OSE)
  14.589 +		basic_machine=m68k-ericsson
  14.590 +		os=-ose
  14.591 +		;;
  14.592 +	fx2800)
  14.593 +		basic_machine=i860-alliant
  14.594 +		;;
  14.595 +	genix)
  14.596 +		basic_machine=ns32k-ns
  14.597 +		;;
  14.598 +	gmicro)
  14.599 +		basic_machine=tron-gmicro
  14.600 +		os=-sysv
  14.601 +		;;
  14.602 +	go32)
  14.603 +		basic_machine=i386-pc
  14.604 +		os=-go32
  14.605 +		;;
  14.606 +	h3050r* | hiux*)
  14.607 +		basic_machine=hppa1.1-hitachi
  14.608 +		os=-hiuxwe2
  14.609 +		;;
  14.610 +	h8300hms)
  14.611 +		basic_machine=h8300-hitachi
  14.612 +		os=-hms
  14.613 +		;;
  14.614 +	h8300xray)
  14.615 +		basic_machine=h8300-hitachi
  14.616 +		os=-xray
  14.617 +		;;
  14.618 +	h8500hms)
  14.619 +		basic_machine=h8500-hitachi
  14.620 +		os=-hms
  14.621 +		;;
  14.622 +	harris)
  14.623 +		basic_machine=m88k-harris
  14.624 +		os=-sysv3
  14.625 +		;;
  14.626 +	hp300-*)
  14.627 +		basic_machine=m68k-hp
  14.628 +		;;
  14.629 +	hp300bsd)
  14.630 +		basic_machine=m68k-hp
  14.631 +		os=-bsd
  14.632 +		;;
  14.633 +	hp300hpux)
  14.634 +		basic_machine=m68k-hp
  14.635 +		os=-hpux
  14.636 +		;;
  14.637 +	hp3k9[0-9][0-9] | hp9[0-9][0-9])
  14.638 +		basic_machine=hppa1.0-hp
  14.639 +		;;
  14.640 +	hp9k2[0-9][0-9] | hp9k31[0-9])
  14.641 +		basic_machine=m68000-hp
  14.642 +		;;
  14.643 +	hp9k3[2-9][0-9])
  14.644 +		basic_machine=m68k-hp
  14.645 +		;;
  14.646 +	hp9k6[0-9][0-9] | hp6[0-9][0-9])
  14.647 +		basic_machine=hppa1.0-hp
  14.648 +		;;
  14.649 +	hp9k7[0-79][0-9] | hp7[0-79][0-9])
  14.650 +		basic_machine=hppa1.1-hp
  14.651 +		;;
  14.652 +	hp9k78[0-9] | hp78[0-9])
  14.653 +		# FIXME: really hppa2.0-hp
  14.654 +		basic_machine=hppa1.1-hp
  14.655 +		;;
  14.656 +	hp9k8[67]1 | hp8[67]1 | hp9k80[24] | hp80[24] | hp9k8[78]9 | hp8[78]9 | hp9k893 | hp893)
  14.657 +		# FIXME: really hppa2.0-hp
  14.658 +		basic_machine=hppa1.1-hp
  14.659 +		;;
  14.660 +	hp9k8[0-9][13679] | hp8[0-9][13679])
  14.661 +		basic_machine=hppa1.1-hp
  14.662 +		;;
  14.663 +	hp9k8[0-9][0-9] | hp8[0-9][0-9])
  14.664 +		basic_machine=hppa1.0-hp
  14.665 +		;;
  14.666 +	hppa-next)
  14.667 +		os=-nextstep3
  14.668 +		;;
  14.669 +	hppaosf)
  14.670 +		basic_machine=hppa1.1-hp
  14.671 +		os=-osf
  14.672 +		;;
  14.673 +	hppro)
  14.674 +		basic_machine=hppa1.1-hp
  14.675 +		os=-proelf
  14.676 +		;;
  14.677 +	i370-ibm* | ibm*)
  14.678 +		basic_machine=i370-ibm
  14.679 +		;;
  14.680 +# I'm not sure what "Sysv32" means.  Should this be sysv3.2?
  14.681 +	i*86v32)
  14.682 +		basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'`
  14.683 +		os=-sysv32
  14.684 +		;;
  14.685 +	i*86v4*)
  14.686 +		basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'`
  14.687 +		os=-sysv4
  14.688 +		;;
  14.689 +	i*86v)
  14.690 +		basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'`
  14.691 +		os=-sysv
  14.692 +		;;
  14.693 +	i*86sol2)
  14.694 +		basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'`
  14.695 +		os=-solaris2
  14.696 +		;;
  14.697 +	i386mach)
  14.698 +		basic_machine=i386-mach
  14.699 +		os=-mach
  14.700 +		;;
  14.701 +	i386-vsta | vsta)
  14.702 +		basic_machine=i386-unknown
  14.703 +		os=-vsta
  14.704 +		;;
  14.705 +	iris | iris4d)
  14.706 +		basic_machine=mips-sgi
  14.707 +		case $os in
  14.708 +		    -irix*)
  14.709 +			;;
  14.710 +		    *)
  14.711 +			os=-irix4
  14.712 +			;;
  14.713 +		esac
  14.714 +		;;
  14.715 +	isi68 | isi)
  14.716 +		basic_machine=m68k-isi
  14.717 +		os=-sysv
  14.718 +		;;
  14.719 +	m68knommu)
  14.720 +		basic_machine=m68k-unknown
  14.721 +		os=-linux
  14.722 +		;;
  14.723 +	m68knommu-*)
  14.724 +		basic_machine=m68k-`echo $basic_machine | sed 's/^[^-]*-//'`
  14.725 +		os=-linux
  14.726 +		;;
  14.727 +	m88k-omron*)
  14.728 +		basic_machine=m88k-omron
  14.729 +		;;
  14.730 +	magnum | m3230)
  14.731 +		basic_machine=mips-mips
  14.732 +		os=-sysv
  14.733 +		;;
  14.734 +	merlin)
  14.735 +		basic_machine=ns32k-utek
  14.736 +		os=-sysv
  14.737 +		;;
  14.738 +        microblaze)
  14.739 +		basic_machine=microblaze-xilinx
  14.740 +		;;
  14.741 +	mingw32)
  14.742 +		basic_machine=i386-pc
  14.743 +		os=-mingw32
  14.744 +		;;
  14.745 +	mingw32ce)
  14.746 +		basic_machine=arm-unknown
  14.747 +		os=-mingw32ce
  14.748 +		;;
  14.749 +	miniframe)
  14.750 +		basic_machine=m68000-convergent
  14.751 +		;;
  14.752 +	*mint | -mint[0-9]* | *MiNT | *MiNT[0-9]*)
  14.753 +		basic_machine=m68k-atari
  14.754 +		os=-mint
  14.755 +		;;
  14.756 +	mips3*-*)
  14.757 +		basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'`
  14.758 +		;;
  14.759 +	mips3*)
  14.760 +		basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'`-unknown
  14.761 +		;;
  14.762 +	monitor)
  14.763 +		basic_machine=m68k-rom68k
  14.764 +		os=-coff
  14.765 +		;;
  14.766 +	morphos)
  14.767 +		basic_machine=powerpc-unknown
  14.768 +		os=-morphos
  14.769 +		;;
  14.770 +	msdos)
  14.771 +		basic_machine=i386-pc
  14.772 +		os=-msdos
  14.773 +		;;
  14.774 +	ms1-*)
  14.775 +		basic_machine=`echo $basic_machine | sed -e 's/ms1-/mt-/'`
  14.776 +		;;
  14.777 +	mvs)
  14.778 +		basic_machine=i370-ibm
  14.779 +		os=-mvs
  14.780 +		;;
  14.781 +	ncr3000)
  14.782 +		basic_machine=i486-ncr
  14.783 +		os=-sysv4
  14.784 +		;;
  14.785 +	netbsd386)
  14.786 +		basic_machine=i386-unknown
  14.787 +		os=-netbsd
  14.788 +		;;
  14.789 +	netwinder)
  14.790 +		basic_machine=armv4l-rebel
  14.791 +		os=-linux
  14.792 +		;;
  14.793 +	news | news700 | news800 | news900)
  14.794 +		basic_machine=m68k-sony
  14.795 +		os=-newsos
  14.796 +		;;
  14.797 +	news1000)
  14.798 +		basic_machine=m68030-sony
  14.799 +		os=-newsos
  14.800 +		;;
  14.801 +	news-3600 | risc-news)
  14.802 +		basic_machine=mips-sony
  14.803 +		os=-newsos
  14.804 +		;;
  14.805 +	necv70)
  14.806 +		basic_machine=v70-nec
  14.807 +		os=-sysv
  14.808 +		;;
  14.809 +	next | m*-next )
  14.810 +		basic_machine=m68k-next
  14.811 +		case $os in
  14.812 +		    -nextstep* )
  14.813 +			;;
  14.814 +		    -ns2*)
  14.815 +		      os=-nextstep2
  14.816 +			;;
  14.817 +		    *)
  14.818 +		      os=-nextstep3
  14.819 +			;;
  14.820 +		esac
  14.821 +		;;
  14.822 +	nh3000)
  14.823 +		basic_machine=m68k-harris
  14.824 +		os=-cxux
  14.825 +		;;
  14.826 +	nh[45]000)
  14.827 +		basic_machine=m88k-harris
  14.828 +		os=-cxux
  14.829 +		;;
  14.830 +	nindy960)
  14.831 +		basic_machine=i960-intel
  14.832 +		os=-nindy
  14.833 +		;;
  14.834 +	mon960)
  14.835 +		basic_machine=i960-intel
  14.836 +		os=-mon960
  14.837 +		;;
  14.838 +	nonstopux)
  14.839 +		basic_machine=mips-compaq
  14.840 +		os=-nonstopux
  14.841 +		;;
  14.842 +	np1)
  14.843 +		basic_machine=np1-gould
  14.844 +		;;
  14.845 +	nsr-tandem)
  14.846 +		basic_machine=nsr-tandem
  14.847 +		;;
  14.848 +	op50n-* | op60c-*)
  14.849 +		basic_machine=hppa1.1-oki
  14.850 +		os=-proelf
  14.851 +		;;
  14.852 +	openrisc | openrisc-*)
  14.853 +		basic_machine=or32-unknown
  14.854 +		;;
  14.855 +	os400)
  14.856 +		basic_machine=powerpc-ibm
  14.857 +		os=-os400
  14.858 +		;;
  14.859 +	OSE68000 | ose68000)
  14.860 +		basic_machine=m68000-ericsson
  14.861 +		os=-ose
  14.862 +		;;
  14.863 +	os68k)
  14.864 +		basic_machine=m68k-none
  14.865 +		os=-os68k
  14.866 +		;;
  14.867 +	pa-hitachi)
  14.868 +		basic_machine=hppa1.1-hitachi
  14.869 +		os=-hiuxwe2
  14.870 +		;;
  14.871 +	paragon)
  14.872 +		basic_machine=i860-intel
  14.873 +		os=-osf
  14.874 +		;;
  14.875 +	parisc)
  14.876 +		basic_machine=hppa-unknown
  14.877 +		os=-linux
  14.878 +		;;
  14.879 +	parisc-*)
  14.880 +		basic_machine=hppa-`echo $basic_machine | sed 's/^[^-]*-//'`
  14.881 +		os=-linux
  14.882 +		;;
  14.883 +	pbd)
  14.884 +		basic_machine=sparc-tti
  14.885 +		;;
  14.886 +	pbb)
  14.887 +		basic_machine=m68k-tti
  14.888 +		;;
  14.889 +	pc532 | pc532-*)
  14.890 +		basic_machine=ns32k-pc532
  14.891 +		;;
  14.892 +	pc98)
  14.893 +		basic_machine=i386-pc
  14.894 +		;;
  14.895 +	pc98-*)
  14.896 +		basic_machine=i386-`echo $basic_machine | sed 's/^[^-]*-//'`
  14.897 +		;;
  14.898 +	pentium | p5 | k5 | k6 | nexgen | viac3)
  14.899 +		basic_machine=i586-pc
  14.900 +		;;
  14.901 +	pentiumpro | p6 | 6x86 | athlon | athlon_*)
  14.902 +		basic_machine=i686-pc
  14.903 +		;;
  14.904 +	pentiumii | pentium2 | pentiumiii | pentium3)
  14.905 +		basic_machine=i686-pc
  14.906 +		;;
  14.907 +	pentium4)
  14.908 +		basic_machine=i786-pc
  14.909 +		;;
  14.910 +	pentium-* | p5-* | k5-* | k6-* | nexgen-* | viac3-*)
  14.911 +		basic_machine=i586-`echo $basic_machine | sed 's/^[^-]*-//'`
  14.912 +		;;
  14.913 +	pentiumpro-* | p6-* | 6x86-* | athlon-*)
  14.914 +		basic_machine=i686-`echo $basic_machine | sed 's/^[^-]*-//'`
  14.915 +		;;
  14.916 +	pentiumii-* | pentium2-* | pentiumiii-* | pentium3-*)
  14.917 +		basic_machine=i686-`echo $basic_machine | sed 's/^[^-]*-//'`
  14.918 +		;;
  14.919 +	pentium4-*)
  14.920 +		basic_machine=i786-`echo $basic_machine | sed 's/^[^-]*-//'`
  14.921 +		;;
  14.922 +	pn)
  14.923 +		basic_machine=pn-gould
  14.924 +		;;
  14.925 +	power)	basic_machine=power-ibm
  14.926 +		;;
  14.927 +	ppc)	basic_machine=powerpc-unknown
  14.928 +		;;
  14.929 +	ppc-*)	basic_machine=powerpc-`echo $basic_machine | sed 's/^[^-]*-//'`
  14.930 +		;;
  14.931 +	ppcle | powerpclittle | ppc-le | powerpc-little)
  14.932 +		basic_machine=powerpcle-unknown
  14.933 +		;;
  14.934 +	ppcle-* | powerpclittle-*)
  14.935 +		basic_machine=powerpcle-`echo $basic_machine | sed 's/^[^-]*-//'`
  14.936 +		;;
  14.937 +	ppc64)	basic_machine=powerpc64-unknown
  14.938 +		;;
  14.939 +	ppc64-*) basic_machine=powerpc64-`echo $basic_machine | sed 's/^[^-]*-//'`
  14.940 +		;;
  14.941 +	ppc64le | powerpc64little | ppc64-le | powerpc64-little)
  14.942 +		basic_machine=powerpc64le-unknown
  14.943 +		;;
  14.944 +	ppc64le-* | powerpc64little-*)
  14.945 +		basic_machine=powerpc64le-`echo $basic_machine | sed 's/^[^-]*-//'`
  14.946 +		;;
  14.947 +	ps2)
  14.948 +		basic_machine=i386-ibm
  14.949 +		;;
  14.950 +	pw32)
  14.951 +		basic_machine=i586-unknown
  14.952 +		os=-pw32
  14.953 +		;;
  14.954 +	rdos)
  14.955 +		basic_machine=i386-pc
  14.956 +		os=-rdos
  14.957 +		;;
  14.958 +	rom68k)
  14.959 +		basic_machine=m68k-rom68k
  14.960 +		os=-coff
  14.961 +		;;
  14.962 +	rm[46]00)
  14.963 +		basic_machine=mips-siemens
  14.964 +		;;
  14.965 +	rtpc | rtpc-*)
  14.966 +		basic_machine=romp-ibm
  14.967 +		;;
  14.968 +	s390 | s390-*)
  14.969 +		basic_machine=s390-ibm
  14.970 +		;;
  14.971 +	s390x | s390x-*)
  14.972 +		basic_machine=s390x-ibm
  14.973 +		;;
  14.974 +	sa29200)
  14.975 +		basic_machine=a29k-amd
  14.976 +		os=-udi
  14.977 +		;;
  14.978 +	sb1)
  14.979 +		basic_machine=mipsisa64sb1-unknown
  14.980 +		;;
  14.981 +	sb1el)
  14.982 +		basic_machine=mipsisa64sb1el-unknown
  14.983 +		;;
  14.984 +	sde)
  14.985 +		basic_machine=mipsisa32-sde
  14.986 +		os=-elf
  14.987 +		;;
  14.988 +	sei)
  14.989 +		basic_machine=mips-sei
  14.990 +		os=-seiux
  14.991 +		;;
  14.992 +	sequent)
  14.993 +		basic_machine=i386-sequent
  14.994 +		;;
  14.995 +	sh)
  14.996 +		basic_machine=sh-hitachi
  14.997 +		os=-hms
  14.998 +		;;
  14.999 +	sh5el)
 14.1000 +		basic_machine=sh5le-unknown
 14.1001 +		;;
 14.1002 +	sh64)
 14.1003 +		basic_machine=sh64-unknown
 14.1004 +		;;
 14.1005 +	sparclite-wrs | simso-wrs)
 14.1006 +		basic_machine=sparclite-wrs
 14.1007 +		os=-vxworks
 14.1008 +		;;
 14.1009 +	sps7)
 14.1010 +		basic_machine=m68k-bull
 14.1011 +		os=-sysv2
 14.1012 +		;;
 14.1013 +	spur)
 14.1014 +		basic_machine=spur-unknown
 14.1015 +		;;
 14.1016 +	st2000)
 14.1017 +		basic_machine=m68k-tandem
 14.1018 +		;;
 14.1019 +	stratus)
 14.1020 +		basic_machine=i860-stratus
 14.1021 +		os=-sysv4
 14.1022 +		;;
 14.1023 +	sun2)
 14.1024 +		basic_machine=m68000-sun
 14.1025 +		;;
 14.1026 +	sun2os3)
 14.1027 +		basic_machine=m68000-sun
 14.1028 +		os=-sunos3
 14.1029 +		;;
 14.1030 +	sun2os4)
 14.1031 +		basic_machine=m68000-sun
 14.1032 +		os=-sunos4
 14.1033 +		;;
 14.1034 +	sun3os3)
 14.1035 +		basic_machine=m68k-sun
 14.1036 +		os=-sunos3
 14.1037 +		;;
 14.1038 +	sun3os4)
 14.1039 +		basic_machine=m68k-sun
 14.1040 +		os=-sunos4
 14.1041 +		;;
 14.1042 +	sun4os3)
 14.1043 +		basic_machine=sparc-sun
 14.1044 +		os=-sunos3
 14.1045 +		;;
 14.1046 +	sun4os4)
 14.1047 +		basic_machine=sparc-sun
 14.1048 +		os=-sunos4
 14.1049 +		;;
 14.1050 +	sun4sol2)
 14.1051 +		basic_machine=sparc-sun
 14.1052 +		os=-solaris2
 14.1053 +		;;
 14.1054 +	sun3 | sun3-*)
 14.1055 +		basic_machine=m68k-sun
 14.1056 +		;;
 14.1057 +	sun4)
 14.1058 +		basic_machine=sparc-sun
 14.1059 +		;;
 14.1060 +	sun386 | sun386i | roadrunner)
 14.1061 +		basic_machine=i386-sun
 14.1062 +		;;
 14.1063 +	sv1)
 14.1064 +		basic_machine=sv1-cray
 14.1065 +		os=-unicos
 14.1066 +		;;
 14.1067 +	symmetry)
 14.1068 +		basic_machine=i386-sequent
 14.1069 +		os=-dynix
 14.1070 +		;;
 14.1071 +	t3e)
 14.1072 +		basic_machine=alphaev5-cray
 14.1073 +		os=-unicos
 14.1074 +		;;
 14.1075 +	t90)
 14.1076 +		basic_machine=t90-cray
 14.1077 +		os=-unicos
 14.1078 +		;;
 14.1079 +	tic54x | c54x*)
 14.1080 +		basic_machine=tic54x-unknown
 14.1081 +		os=-coff
 14.1082 +		;;
 14.1083 +	tic55x | c55x*)
 14.1084 +		basic_machine=tic55x-unknown
 14.1085 +		os=-coff
 14.1086 +		;;
 14.1087 +	tic6x | c6x*)
 14.1088 +		basic_machine=tic6x-unknown
 14.1089 +		os=-coff
 14.1090 +		;;
 14.1091 +	tile*)
 14.1092 +		basic_machine=tile-unknown
 14.1093 +		os=-linux-gnu
 14.1094 +		;;
 14.1095 +	tx39)
 14.1096 +		basic_machine=mipstx39-unknown
 14.1097 +		;;
 14.1098 +	tx39el)
 14.1099 +		basic_machine=mipstx39el-unknown
 14.1100 +		;;
 14.1101 +	toad1)
 14.1102 +		basic_machine=pdp10-xkl
 14.1103 +		os=-tops20
 14.1104 +		;;
 14.1105 +	tower | tower-32)
 14.1106 +		basic_machine=m68k-ncr
 14.1107 +		;;
 14.1108 +	tpf)
 14.1109 +		basic_machine=s390x-ibm
 14.1110 +		os=-tpf
 14.1111 +		;;
 14.1112 +	udi29k)
 14.1113 +		basic_machine=a29k-amd
 14.1114 +		os=-udi
 14.1115 +		;;
 14.1116 +	ultra3)
 14.1117 +		basic_machine=a29k-nyu
 14.1118 +		os=-sym1
 14.1119 +		;;
 14.1120 +	v810 | necv810)
 14.1121 +		basic_machine=v810-nec
 14.1122 +		os=-none
 14.1123 +		;;
 14.1124 +	vaxv)
 14.1125 +		basic_machine=vax-dec
 14.1126 +		os=-sysv
 14.1127 +		;;
 14.1128 +	vms)
 14.1129 +		basic_machine=vax-dec
 14.1130 +		os=-vms
 14.1131 +		;;
 14.1132 +	vpp*|vx|vx-*)
 14.1133 +		basic_machine=f301-fujitsu
 14.1134 +		;;
 14.1135 +	vxworks960)
 14.1136 +		basic_machine=i960-wrs
 14.1137 +		os=-vxworks
 14.1138 +		;;
 14.1139 +	vxworks68)
 14.1140 +		basic_machine=m68k-wrs
 14.1141 +		os=-vxworks
 14.1142 +		;;
 14.1143 +	vxworks29k)
 14.1144 +		basic_machine=a29k-wrs
 14.1145 +		os=-vxworks
 14.1146 +		;;
 14.1147 +	w65*)
 14.1148 +		basic_machine=w65-wdc
 14.1149 +		os=-none
 14.1150 +		;;
 14.1151 +	w89k-*)
 14.1152 +		basic_machine=hppa1.1-winbond
 14.1153 +		os=-proelf
 14.1154 +		;;
 14.1155 +	xbox)
 14.1156 +		basic_machine=i686-pc
 14.1157 +		os=-mingw32
 14.1158 +		;;
 14.1159 +	xps | xps100)
 14.1160 +		basic_machine=xps100-honeywell
 14.1161 +		;;
 14.1162 +	ymp)
 14.1163 +		basic_machine=ymp-cray
 14.1164 +		os=-unicos
 14.1165 +		;;
 14.1166 +	z8k-*-coff)
 14.1167 +		basic_machine=z8k-unknown
 14.1168 +		os=-sim
 14.1169 +		;;
 14.1170 +	z80-*-coff)
 14.1171 +		basic_machine=z80-unknown
 14.1172 +		os=-sim
 14.1173 +		;;
 14.1174 +	none)
 14.1175 +		basic_machine=none-none
 14.1176 +		os=-none
 14.1177 +		;;
 14.1178 +
 14.1179 +# Here we handle the default manufacturer of certain CPU types.  It is in
 14.1180 +# some cases the only manufacturer, in others, it is the most popular.
 14.1181 +	w89k)
 14.1182 +		basic_machine=hppa1.1-winbond
 14.1183 +		;;
 14.1184 +	op50n)
 14.1185 +		basic_machine=hppa1.1-oki
 14.1186 +		;;
 14.1187 +	op60c)
 14.1188 +		basic_machine=hppa1.1-oki
 14.1189 +		;;
 14.1190 +	romp)
 14.1191 +		basic_machine=romp-ibm
 14.1192 +		;;
 14.1193 +	mmix)
 14.1194 +		basic_machine=mmix-knuth
 14.1195 +		;;
 14.1196 +	rs6000)
 14.1197 +		basic_machine=rs6000-ibm
 14.1198 +		;;
 14.1199 +	vax)
 14.1200 +		basic_machine=vax-dec
 14.1201 +		;;
 14.1202 +	pdp10)
 14.1203 +		# there are many clones, so DEC is not a safe bet
 14.1204 +		basic_machine=pdp10-unknown
 14.1205 +		;;
 14.1206 +	pdp11)
 14.1207 +		basic_machine=pdp11-dec
 14.1208 +		;;
 14.1209 +	we32k)
 14.1210 +		basic_machine=we32k-att
 14.1211 +		;;
 14.1212 +	sh[1234] | sh[24]a | sh[24]aeb | sh[34]eb | sh[1234]le | sh[23]ele)
 14.1213 +		basic_machine=sh-unknown
 14.1214 +		;;
 14.1215 +	sparc | sparcv8 | sparcv9 | sparcv9b | sparcv9v)
 14.1216 +		basic_machine=sparc-sun
 14.1217 +		;;
 14.1218 +	cydra)
 14.1219 +		basic_machine=cydra-cydrome
 14.1220 +		;;
 14.1221 +	orion)
 14.1222 +		basic_machine=orion-highlevel
 14.1223 +		;;
 14.1224 +	orion105)
 14.1225 +		basic_machine=clipper-highlevel
 14.1226 +		;;
 14.1227 +	mac | mpw | mac-mpw)
 14.1228 +		basic_machine=m68k-apple
 14.1229 +		;;
 14.1230 +	pmac | pmac-mpw)
 14.1231 +		basic_machine=powerpc-apple
 14.1232 +		;;
 14.1233 +	*-unknown)
 14.1234 +		# Make sure to match an already-canonicalized machine name.
 14.1235 +		;;
 14.1236 +	*)
 14.1237 +		echo Invalid configuration \`$1\': machine \`$basic_machine\' not recognized 1>&2
 14.1238 +		exit 1
 14.1239 +		;;
 14.1240 +esac
 14.1241 +
 14.1242 +# Here we canonicalize certain aliases for manufacturers.
 14.1243 +case $basic_machine in
 14.1244 +	*-digital*)
 14.1245 +		basic_machine=`echo $basic_machine | sed 's/digital.*/dec/'`
 14.1246 +		;;
 14.1247 +	*-commodore*)
 14.1248 +		basic_machine=`echo $basic_machine | sed 's/commodore.*/cbm/'`
 14.1249 +		;;
 14.1250 +	*)
 14.1251 +		;;
 14.1252 +esac
 14.1253 +
 14.1254 +# Decode manufacturer-specific aliases for certain operating systems.
 14.1255 +
 14.1256 +if [ x"$os" != x"" ]
 14.1257 +then
 14.1258 +case $os in
 14.1259 +        # First match some system type aliases
 14.1260 +        # that might get confused with valid system types.
 14.1261 +	# -solaris* is a basic system type, with this one exception.
 14.1262 +        -auroraux)
 14.1263 +	        os=-auroraux
 14.1264 +		;;
 14.1265 +	-solaris1 | -solaris1.*)
 14.1266 +		os=`echo $os | sed -e 's|solaris1|sunos4|'`
 14.1267 +		;;
 14.1268 +	-solaris)
 14.1269 +		os=-solaris2
 14.1270 +		;;
 14.1271 +	-svr4*)
 14.1272 +		os=-sysv4
 14.1273 +		;;
 14.1274 +	-unixware*)
 14.1275 +		os=-sysv4.2uw
 14.1276 +		;;
 14.1277 +	-gnu/linux*)
 14.1278 +		os=`echo $os | sed -e 's|gnu/linux|linux-gnu|'`
 14.1279 +		;;
 14.1280 +	# First accept the basic system types.
 14.1281 +	# The portable systems comes first.
 14.1282 +	# Each alternative MUST END IN A *, to match a version number.
 14.1283 +	# -sysv* is not here because it comes later, after sysvr4.
 14.1284 +	-gnu* | -bsd* | -mach* | -minix* | -genix* | -ultrix* | -irix* \
 14.1285 +	      | -*vms* | -sco* | -esix* | -isc* | -aix* | -cnk* | -sunos | -sunos[34]*\
 14.1286 +	      | -hpux* | -unos* | -osf* | -luna* | -dgux* | -auroraux* | -solaris* \
 14.1287 +	      | -sym* | -kopensolaris* \
 14.1288 +	      | -amigaos* | -amigados* | -msdos* | -newsos* | -unicos* | -aof* \
 14.1289 +	      | -aos* | -aros* \
 14.1290 +	      | -nindy* | -vxsim* | -vxworks* | -ebmon* | -hms* | -mvs* \
 14.1291 +	      | -clix* | -riscos* | -uniplus* | -iris* | -rtu* | -xenix* \
 14.1292 +	      | -hiux* | -386bsd* | -knetbsd* | -mirbsd* | -netbsd* \
 14.1293 +	      | -openbsd* | -solidbsd* \
 14.1294 +	      | -ekkobsd* | -kfreebsd* | -freebsd* | -riscix* | -lynxos* \
 14.1295 +	      | -bosx* | -nextstep* | -cxux* | -aout* | -elf* | -oabi* \
 14.1296 +	      | -ptx* | -coff* | -ecoff* | -winnt* | -domain* | -vsta* \
 14.1297 +	      | -udi* | -eabi* | -lites* | -ieee* | -go32* | -aux* \
 14.1298 +	      | -chorusos* | -chorusrdb* | -cegcc* \
 14.1299 +	      | -cygwin* | -pe* | -psos* | -moss* | -proelf* | -rtems* \
 14.1300 +	      | -mingw32* | -linux-gnu* | -linux-newlib* | -linux-uclibc* \
 14.1301 +	      | -uxpv* | -beos* | -mpeix* | -udk* \
 14.1302 +	      | -interix* | -uwin* | -mks* | -rhapsody* | -darwin* | -opened* \
 14.1303 +	      | -openstep* | -oskit* | -conix* | -pw32* | -nonstopux* \
 14.1304 +	      | -storm-chaos* | -tops10* | -tenex* | -tops20* | -its* \
 14.1305 +	      | -os2* | -vos* | -palmos* | -uclinux* | -nucleus* \
 14.1306 +	      | -morphos* | -superux* | -rtmk* | -rtmk-nova* | -windiss* \
 14.1307 +	      | -powermax* | -dnix* | -nx6 | -nx7 | -sei* | -dragonfly* \
 14.1308 +	      | -skyos* | -haiku* | -rdos* | -toppers* | -drops* | -es*)
 14.1309 +	# Remember, each alternative MUST END IN *, to match a version number.
 14.1310 +		;;
 14.1311 +	-qnx*)
 14.1312 +		case $basic_machine in
 14.1313 +		    x86-* | i*86-*)
 14.1314 +			;;
 14.1315 +		    *)
 14.1316 +			os=-nto$os
 14.1317 +			;;
 14.1318 +		esac
 14.1319 +		;;
 14.1320 +	-nto-qnx*)
 14.1321 +		;;
 14.1322 +	-nto*)
 14.1323 +		os=`echo $os | sed -e 's|nto|nto-qnx|'`
 14.1324 +		;;
 14.1325 +	-sim | -es1800* | -hms* | -xray | -os68k* | -none* | -v88r* \
 14.1326 +	      | -windows* | -osx | -abug | -netware* | -os9* | -beos* | -haiku* \
 14.1327 +	      | -macos* | -mpw* | -magic* | -mmixware* | -mon960* | -lnews*)
 14.1328 +		;;
 14.1329 +	-mac*)
 14.1330 +		os=`echo $os | sed -e 's|mac|macos|'`
 14.1331 +		;;
 14.1332 +	-linux-dietlibc)
 14.1333 +		os=-linux-dietlibc
 14.1334 +		;;
 14.1335 +	-linux*)
 14.1336 +		os=`echo $os | sed -e 's|linux|linux-gnu|'`
 14.1337 +		;;
 14.1338 +	-sunos5*)
 14.1339 +		os=`echo $os | sed -e 's|sunos5|solaris2|'`
 14.1340 +		;;
 14.1341 +	-sunos6*)
 14.1342 +		os=`echo $os | sed -e 's|sunos6|solaris3|'`
 14.1343 +		;;
 14.1344 +	-opened*)
 14.1345 +		os=-openedition
 14.1346 +		;;
 14.1347 +        -os400*)
 14.1348 +		os=-os400
 14.1349 +		;;
 14.1350 +	-wince*)
 14.1351 +		os=-wince
 14.1352 +		;;
 14.1353 +	-osfrose*)
 14.1354 +		os=-osfrose
 14.1355 +		;;
 14.1356 +	-osf*)
 14.1357 +		os=-osf
 14.1358 +		;;
 14.1359 +	-utek*)
 14.1360 +		os=-bsd
 14.1361 +		;;
 14.1362 +	-dynix*)
 14.1363 +		os=-bsd
 14.1364 +		;;
 14.1365 +	-acis*)
 14.1366 +		os=-aos
 14.1367 +		;;
 14.1368 +	-atheos*)
 14.1369 +		os=-atheos
 14.1370 +		;;
 14.1371 +	-syllable*)
 14.1372 +		os=-syllable
 14.1373 +		;;
 14.1374 +	-386bsd)
 14.1375 +		os=-bsd
 14.1376 +		;;
 14.1377 +	-ctix* | -uts*)
 14.1378 +		os=-sysv
 14.1379 +		;;
 14.1380 +	-nova*)
 14.1381 +		os=-rtmk-nova
 14.1382 +		;;
 14.1383 +	-ns2 )
 14.1384 +		os=-nextstep2
 14.1385 +		;;
 14.1386 +	-nsk*)
 14.1387 +		os=-nsk
 14.1388 +		;;
 14.1389 +	# Preserve the version number of sinix5.
 14.1390 +	-sinix5.*)
 14.1391 +		os=`echo $os | sed -e 's|sinix|sysv|'`
 14.1392 +		;;
 14.1393 +	-sinix*)
 14.1394 +		os=-sysv4
 14.1395 +		;;
 14.1396 +        -tpf*)
 14.1397 +		os=-tpf
 14.1398 +		;;
 14.1399 +	-triton*)
 14.1400 +		os=-sysv3
 14.1401 +		;;
 14.1402 +	-oss*)
 14.1403 +		os=-sysv3
 14.1404 +		;;
 14.1405 +	-svr4)
 14.1406 +		os=-sysv4
 14.1407 +		;;
 14.1408 +	-svr3)
 14.1409 +		os=-sysv3
 14.1410 +		;;
 14.1411 +	-sysvr4)
 14.1412 +		os=-sysv4
 14.1413 +		;;
 14.1414 +	# This must come after -sysvr4.
 14.1415 +	-sysv*)
 14.1416 +		;;
 14.1417 +	-ose*)
 14.1418 +		os=-ose
 14.1419 +		;;
 14.1420 +	-es1800*)
 14.1421 +		os=-ose
 14.1422 +		;;
 14.1423 +	-xenix)
 14.1424 +		os=-xenix
 14.1425 +		;;
 14.1426 +	-*mint | -mint[0-9]* | -*MiNT | -MiNT[0-9]*)
 14.1427 +		os=-mint
 14.1428 +		;;
 14.1429 +	-aros*)
 14.1430 +		os=-aros
 14.1431 +		;;
 14.1432 +	-kaos*)
 14.1433 +		os=-kaos
 14.1434 +		;;
 14.1435 +	-zvmoe)
 14.1436 +		os=-zvmoe
 14.1437 +		;;
 14.1438 +	-dicos*)
 14.1439 +		os=-dicos
 14.1440 +		;;
 14.1441 +	-none)
 14.1442 +		;;
 14.1443 +	*)
 14.1444 +		# Get rid of the `-' at the beginning of $os.
 14.1445 +		os=`echo $os | sed 's/[^-]*-//'`
 14.1446 +		echo Invalid configuration \`$1\': system \`$os\' not recognized 1>&2
 14.1447 +		exit 1
 14.1448 +		;;
 14.1449 +esac
 14.1450 +else
 14.1451 +
 14.1452 +# Here we handle the default operating systems that come with various machines.
 14.1453 +# The value should be what the vendor currently ships out the door with their
 14.1454 +# machine or put another way, the most popular os provided with the machine.
 14.1455 +
 14.1456 +# Note that if you're going to try to match "-MANUFACTURER" here (say,
 14.1457 +# "-sun"), then you have to tell the case statement up towards the top
 14.1458 +# that MANUFACTURER isn't an operating system.  Otherwise, code above
 14.1459 +# will signal an error saying that MANUFACTURER isn't an operating
 14.1460 +# system, and we'll never get to this point.
 14.1461 +
 14.1462 +case $basic_machine in
 14.1463 +        score-*)
 14.1464 +		os=-elf
 14.1465 +		;;
 14.1466 +        spu-*)
 14.1467 +		os=-elf
 14.1468 +		;;
 14.1469 +	*-acorn)
 14.1470 +		os=-riscix1.2
 14.1471 +		;;
 14.1472 +	arm*-rebel)
 14.1473 +		os=-linux
 14.1474 +		;;
 14.1475 +	arm*-semi)
 14.1476 +		os=-aout
 14.1477 +		;;
 14.1478 +        c4x-* | tic4x-*)
 14.1479 +        	os=-coff
 14.1480 +		;;
 14.1481 +	# This must come before the *-dec entry.
 14.1482 +	pdp10-*)
 14.1483 +		os=-tops20
 14.1484 +		;;
 14.1485 +	pdp11-*)
 14.1486 +		os=-none
 14.1487 +		;;
 14.1488 +	*-dec | vax-*)
 14.1489 +		os=-ultrix4.2
 14.1490 +		;;
 14.1491 +	m68*-apollo)
 14.1492 +		os=-domain
 14.1493 +		;;
 14.1494 +	i386-sun)
 14.1495 +		os=-sunos4.0.2
 14.1496 +		;;
 14.1497 +	m68000-sun)
 14.1498 +		os=-sunos3
 14.1499 +		# This also exists in the configure program, but was not the
 14.1500 +		# default.
 14.1501 +		# os=-sunos4
 14.1502 +		;;
 14.1503 +	m68*-cisco)
 14.1504 +		os=-aout
 14.1505 +		;;
 14.1506 +        mep-*)
 14.1507 +		os=-elf
 14.1508 +		;;
 14.1509 +	mips*-cisco)
 14.1510 +		os=-elf
 14.1511 +		;;
 14.1512 +	mips*-*)
 14.1513 +		os=-elf
 14.1514 +		;;
 14.1515 +	or32-*)
 14.1516 +		os=-coff
 14.1517 +		;;
 14.1518 +	*-tti)	# must be before sparc entry or we get the wrong os.
 14.1519 +		os=-sysv3
 14.1520 +		;;
 14.1521 +	sparc-* | *-sun)
 14.1522 +		os=-sunos4.1.1
 14.1523 +		;;
 14.1524 +	*-be)
 14.1525 +		os=-beos
 14.1526 +		;;
 14.1527 +	*-haiku)
 14.1528 +		os=-haiku
 14.1529 +		;;
 14.1530 +	*-ibm)
 14.1531 +		os=-aix
 14.1532 +		;;
 14.1533 +    	*-knuth)
 14.1534 +		os=-mmixware
 14.1535 +		;;
 14.1536 +	*-wec)
 14.1537 +		os=-proelf
 14.1538 +		;;
 14.1539 +	*-winbond)
 14.1540 +		os=-proelf
 14.1541 +		;;
 14.1542 +	*-oki)
 14.1543 +		os=-proelf
 14.1544 +		;;
 14.1545 +	*-hp)
 14.1546 +		os=-hpux
 14.1547 +		;;
 14.1548 +	*-hitachi)
 14.1549 +		os=-hiux
 14.1550 +		;;
 14.1551 +	i860-* | *-att | *-ncr | *-altos | *-motorola | *-convergent)
 14.1552 +		os=-sysv
 14.1553 +		;;
 14.1554 +	*-cbm)
 14.1555 +		os=-amigaos
 14.1556 +		;;
 14.1557 +	*-dg)
 14.1558 +		os=-dgux
 14.1559 +		;;
 14.1560 +	*-dolphin)
 14.1561 +		os=-sysv3
 14.1562 +		;;
 14.1563 +	m68k-ccur)
 14.1564 +		os=-rtu
 14.1565 +		;;
 14.1566 +	m88k-omron*)
 14.1567 +		os=-luna
 14.1568 +		;;
 14.1569 +	*-next )
 14.1570 +		os=-nextstep
 14.1571 +		;;
 14.1572 +	*-sequent)
 14.1573 +		os=-ptx
 14.1574 +		;;
 14.1575 +	*-crds)
 14.1576 +		os=-unos
 14.1577 +		;;
 14.1578 +	*-ns)
 14.1579 +		os=-genix
 14.1580 +		;;
 14.1581 +	i370-*)
 14.1582 +		os=-mvs
 14.1583 +		;;
 14.1584 +	*-next)
 14.1585 +		os=-nextstep3
 14.1586 +		;;
 14.1587 +	*-gould)
 14.1588 +		os=-sysv
 14.1589 +		;;
 14.1590 +	*-highlevel)
 14.1591 +		os=-bsd
 14.1592 +		;;
 14.1593 +	*-encore)
 14.1594 +		os=-bsd
 14.1595 +		;;
 14.1596 +	*-sgi)
 14.1597 +		os=-irix
 14.1598 +		;;
 14.1599 +	*-siemens)
 14.1600 +		os=-sysv4
 14.1601 +		;;
 14.1602 +	*-masscomp)
 14.1603 +		os=-rtu
 14.1604 +		;;
 14.1605 +	f30[01]-fujitsu | f700-fujitsu)
 14.1606 +		os=-uxpv
 14.1607 +		;;
 14.1608 +	*-rom68k)
 14.1609 +		os=-coff
 14.1610 +		;;
 14.1611 +	*-*bug)
 14.1612 +		os=-coff
 14.1613 +		;;
 14.1614 +	*-apple)
 14.1615 +		os=-macos
 14.1616 +		;;
 14.1617 +	*-atari*)
 14.1618 +		os=-mint
 14.1619 +		;;
 14.1620 +	*)
 14.1621 +		os=-none
 14.1622 +		;;
 14.1623 +esac
 14.1624 +fi
 14.1625 +
 14.1626 +# Here we handle the case where we know the os, and the CPU type, but not the
 14.1627 +# manufacturer.  We pick the logical manufacturer.
 14.1628 +vendor=unknown
 14.1629 +case $basic_machine in
 14.1630 +	*-unknown)
 14.1631 +		case $os in
 14.1632 +			-riscix*)
 14.1633 +				vendor=acorn
 14.1634 +				;;
 14.1635 +			-sunos*)
 14.1636 +				vendor=sun
 14.1637 +				;;
 14.1638 +			-cnk*|-aix*)
 14.1639 +				vendor=ibm
 14.1640 +				;;
 14.1641 +			-beos*)
 14.1642 +				vendor=be
 14.1643 +				;;
 14.1644 +			-hpux*)
 14.1645 +				vendor=hp
 14.1646 +				;;
 14.1647 +			-mpeix*)
 14.1648 +				vendor=hp
 14.1649 +				;;
 14.1650 +			-hiux*)
 14.1651 +				vendor=hitachi
 14.1652 +				;;
 14.1653 +			-unos*)
 14.1654 +				vendor=crds
 14.1655 +				;;
 14.1656 +			-dgux*)
 14.1657 +				vendor=dg
 14.1658 +				;;
 14.1659 +			-luna*)
 14.1660 +				vendor=omron
 14.1661 +				;;
 14.1662 +			-genix*)
 14.1663 +				vendor=ns
 14.1664 +				;;
 14.1665 +			-mvs* | -opened*)
 14.1666 +				vendor=ibm
 14.1667 +				;;
 14.1668 +			-os400*)
 14.1669 +				vendor=ibm
 14.1670 +				;;
 14.1671 +			-ptx*)
 14.1672 +				vendor=sequent
 14.1673 +				;;
 14.1674 +			-tpf*)
 14.1675 +				vendor=ibm
 14.1676 +				;;
 14.1677 +			-vxsim* | -vxworks* | -windiss*)
 14.1678 +				vendor=wrs
 14.1679 +				;;
 14.1680 +			-aux*)
 14.1681 +				vendor=apple
 14.1682 +				;;
 14.1683 +			-hms*)
 14.1684 +				vendor=hitachi
 14.1685 +				;;
 14.1686 +			-mpw* | -macos*)
 14.1687 +				vendor=apple
 14.1688 +				;;
 14.1689 +			-*mint | -mint[0-9]* | -*MiNT | -MiNT[0-9]*)
 14.1690 +				vendor=atari
 14.1691 +				;;
 14.1692 +			-vos*)
 14.1693 +				vendor=stratus
 14.1694 +				;;
 14.1695 +		esac
 14.1696 +		basic_machine=`echo $basic_machine | sed "s/unknown/$vendor/"`
 14.1697 +		;;
 14.1698 +esac
 14.1699 +
 14.1700 +echo $basic_machine$os
 14.1701 +exit
 14.1702 +
 14.1703 +# Local variables:
 14.1704 +# eval: (add-hook 'write-file-hooks 'time-stamp)
 14.1705 +# time-stamp-start: "timestamp='"
 14.1706 +# time-stamp-format: "%:y-%02m-%02d"
 14.1707 +# time-stamp-end: "'"
 14.1708 +# End:
    15.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    15.2 +++ b/deps/glpk/configure	Sun Nov 06 20:59:10 2011 +0100
    15.3 @@ -0,0 +1,13297 @@
    15.4 +#! /bin/sh
    15.5 +# Guess values for system-dependent variables and create Makefiles.
    15.6 +# Generated by GNU Autoconf 2.65 for GLPK 4.47.
    15.7 +#
    15.8 +# Report bugs to <bug-glpk@gnu.org>.
    15.9 +#
   15.10 +#
   15.11 +# Copyright (C) 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001,
   15.12 +# 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009 Free Software Foundation,
   15.13 +# Inc.
   15.14 +#
   15.15 +#
   15.16 +# This configure script is free software; the Free Software Foundation
   15.17 +# gives unlimited permission to copy, distribute and modify it.
   15.18 +## -------------------- ##
   15.19 +## M4sh Initialization. ##
   15.20 +## -------------------- ##
   15.21 +
   15.22 +# Be more Bourne compatible
   15.23 +DUALCASE=1; export DUALCASE # for MKS sh
   15.24 +if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then :
   15.25 +  emulate sh
   15.26 +  NULLCMD=:
   15.27 +  # Pre-4.2 versions of Zsh do word splitting on ${1+"$@"}, which
   15.28 +  # is contrary to our usage.  Disable this feature.
   15.29 +  alias -g '${1+"$@"}'='"$@"'
   15.30 +  setopt NO_GLOB_SUBST
   15.31 +else
   15.32 +  case `(set -o) 2>/dev/null` in #(
   15.33 +  *posix*) :
   15.34 +    set -o posix ;; #(
   15.35 +  *) :
   15.36 +     ;;
   15.37 +esac
   15.38 +fi
   15.39 +
   15.40 +
   15.41 +as_nl='
   15.42 +'
   15.43 +export as_nl
   15.44 +# Printing a long string crashes Solaris 7 /usr/bin/printf.
   15.45 +as_echo='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\'
   15.46 +as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo
   15.47 +as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo$as_echo
   15.48 +# Prefer a ksh shell builtin over an external printf program on Solaris,
   15.49 +# but without wasting forks for bash or zsh.
   15.50 +if test -z "$BASH_VERSION$ZSH_VERSION" \
   15.51 +    && (test "X`print -r -- $as_echo`" = "X$as_echo") 2>/dev/null; then
   15.52 +  as_echo='print -r --'
   15.53 +  as_echo_n='print -rn --'
   15.54 +elif (test "X`printf %s $as_echo`" = "X$as_echo") 2>/dev/null; then
   15.55 +  as_echo='printf %s\n'
   15.56 +  as_echo_n='printf %s'
   15.57 +else
   15.58 +  if test "X`(/usr/ucb/echo -n -n $as_echo) 2>/dev/null`" = "X-n $as_echo"; then
   15.59 +    as_echo_body='eval /usr/ucb/echo -n "$1$as_nl"'
   15.60 +    as_echo_n='/usr/ucb/echo -n'
   15.61 +  else
   15.62 +    as_echo_body='eval expr "X$1" : "X\\(.*\\)"'
   15.63 +    as_echo_n_body='eval
   15.64 +      arg=$1;
   15.65 +      case $arg in #(
   15.66 +      *"$as_nl"*)
   15.67 +	expr "X$arg" : "X\\(.*\\)$as_nl";
   15.68 +	arg=`expr "X$arg" : ".*$as_nl\\(.*\\)"`;;
   15.69 +      esac;
   15.70 +      expr "X$arg" : "X\\(.*\\)" | tr -d "$as_nl"
   15.71 +    '
   15.72 +    export as_echo_n_body
   15.73 +    as_echo_n='sh -c $as_echo_n_body as_echo'
   15.74 +  fi
   15.75 +  export as_echo_body
   15.76 +  as_echo='sh -c $as_echo_body as_echo'
   15.77 +fi
   15.78 +
   15.79 +# The user is always right.
   15.80 +if test "${PATH_SEPARATOR+set}" != set; then
   15.81 +  PATH_SEPARATOR=:
   15.82 +  (PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 && {
   15.83 +    (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 ||
   15.84 +      PATH_SEPARATOR=';'
   15.85 +  }
   15.86 +fi
   15.87 +
   15.88 +
   15.89 +# IFS
   15.90 +# We need space, tab and new line, in precisely that order.  Quoting is
   15.91 +# there to prevent editors from complaining about space-tab.
   15.92 +# (If _AS_PATH_WALK were called with IFS unset, it would disable word
   15.93 +# splitting by setting IFS to empty value.)
   15.94 +IFS=" ""	$as_nl"
   15.95 +
   15.96 +# Find who we are.  Look in the path if we contain no directory separator.
   15.97 +case $0 in #((
   15.98 +  *[\\/]* ) as_myself=$0 ;;
   15.99 +  *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
  15.100 +for as_dir in $PATH
  15.101 +do
  15.102 +  IFS=$as_save_IFS
  15.103 +  test -z "$as_dir" && as_dir=.
  15.104 +    test -r "$as_dir/$0" && as_myself=$as_dir/$0 && break
  15.105 +  done
  15.106 +IFS=$as_save_IFS
  15.107 +
  15.108 +     ;;
  15.109 +esac
  15.110 +# We did not find ourselves, most probably we were run as `sh COMMAND'
  15.111 +# in which case we are not to be found in the path.
  15.112 +if test "x$as_myself" = x; then
  15.113 +  as_myself=$0
  15.114 +fi
  15.115 +if test ! -f "$as_myself"; then
  15.116 +  $as_echo "$as_myself: error: cannot find myself; rerun with an absolute file name" >&2
  15.117 +  exit 1
  15.118 +fi
  15.119 +
  15.120 +# Unset variables that we do not need and which cause bugs (e.g. in
  15.121 +# pre-3.0 UWIN ksh).  But do not cause bugs in bash 2.01; the "|| exit 1"
  15.122 +# suppresses any "Segmentation fault" message there.  '((' could
  15.123 +# trigger a bug in pdksh 5.2.14.
  15.124 +for as_var in BASH_ENV ENV MAIL MAILPATH
  15.125 +do eval test x\${$as_var+set} = xset \
  15.126 +  && ( (unset $as_var) || exit 1) >/dev/null 2>&1 && unset $as_var || :
  15.127 +done
  15.128 +PS1='$ '
  15.129 +PS2='> '
  15.130 +PS4='+ '
  15.131 +
  15.132 +# NLS nuisances.
  15.133 +LC_ALL=C
  15.134 +export LC_ALL
  15.135 +LANGUAGE=C
  15.136 +export LANGUAGE
  15.137 +
  15.138 +# CDPATH.
  15.139 +(unset CDPATH) >/dev/null 2>&1 && unset CDPATH
  15.140 +
  15.141 +if test "x$CONFIG_SHELL" = x; then
  15.142 +  as_bourne_compatible="if test -n \"\${ZSH_VERSION+set}\" && (emulate sh) >/dev/null 2>&1; then :
  15.143 +  emulate sh
  15.144 +  NULLCMD=:
  15.145 +  # Pre-4.2 versions of Zsh do word splitting on \${1+\"\$@\"}, which
  15.146 +  # is contrary to our usage.  Disable this feature.
  15.147 +  alias -g '\${1+\"\$@\"}'='\"\$@\"'
  15.148 +  setopt NO_GLOB_SUBST
  15.149 +else
  15.150 +  case \`(set -o) 2>/dev/null\` in #(
  15.151 +  *posix*) :
  15.152 +    set -o posix ;; #(
  15.153 +  *) :
  15.154 +     ;;
  15.155 +esac
  15.156 +fi
  15.157 +"
  15.158 +  as_required="as_fn_return () { (exit \$1); }
  15.159 +as_fn_success () { as_fn_return 0; }
  15.160 +as_fn_failure () { as_fn_return 1; }
  15.161 +as_fn_ret_success () { return 0; }
  15.162 +as_fn_ret_failure () { return 1; }
  15.163 +
  15.164 +exitcode=0
  15.165 +as_fn_success || { exitcode=1; echo as_fn_success failed.; }
  15.166 +as_fn_failure && { exitcode=1; echo as_fn_failure succeeded.; }
  15.167 +as_fn_ret_success || { exitcode=1; echo as_fn_ret_success failed.; }
  15.168 +as_fn_ret_failure && { exitcode=1; echo as_fn_ret_failure succeeded.; }
  15.169 +if ( set x; as_fn_ret_success y && test x = \"\$1\" ); then :
  15.170 +
  15.171 +else
  15.172 +  exitcode=1; echo positional parameters were not saved.
  15.173 +fi
  15.174 +test x\$exitcode = x0 || exit 1"
  15.175 +  as_suggested="  as_lineno_1=";as_suggested=$as_suggested$LINENO;as_suggested=$as_suggested" as_lineno_1a=\$LINENO
  15.176 +  as_lineno_2=";as_suggested=$as_suggested$LINENO;as_suggested=$as_suggested" as_lineno_2a=\$LINENO
  15.177 +  eval 'test \"x\$as_lineno_1'\$as_run'\" != \"x\$as_lineno_2'\$as_run'\" &&
  15.178 +  test \"x\`expr \$as_lineno_1'\$as_run' + 1\`\" = \"x\$as_lineno_2'\$as_run'\"' || exit 1
  15.179 +
  15.180 +  test -n \"\${ZSH_VERSION+set}\${BASH_VERSION+set}\" || (
  15.181 +    ECHO='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\'
  15.182 +    ECHO=\$ECHO\$ECHO\$ECHO\$ECHO\$ECHO
  15.183 +    ECHO=\$ECHO\$ECHO\$ECHO\$ECHO\$ECHO\$ECHO
  15.184 +    PATH=/empty FPATH=/empty; export PATH FPATH
  15.185 +    test \"X\`printf %s \$ECHO\`\" = \"X\$ECHO\" \\
  15.186 +      || test \"X\`print -r -- \$ECHO\`\" = \"X\$ECHO\" ) || exit 1
  15.187 +test \$(( 1 + 1 )) = 2 || exit 1"
  15.188 +  if (eval "$as_required") 2>/dev/null; then :
  15.189 +  as_have_required=yes
  15.190 +else
  15.191 +  as_have_required=no
  15.192 +fi
  15.193 +  if test x$as_have_required = xyes && (eval "$as_suggested") 2>/dev/null; then :
  15.194 +
  15.195 +else
  15.196 +  as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
  15.197 +as_found=false
  15.198 +for as_dir in /bin$PATH_SEPARATOR/usr/bin$PATH_SEPARATOR$PATH
  15.199 +do
  15.200 +  IFS=$as_save_IFS
  15.201 +  test -z "$as_dir" && as_dir=.
  15.202 +  as_found=:
  15.203 +  case $as_dir in #(
  15.204 +	 /*)
  15.205 +	   for as_base in sh bash ksh sh5; do
  15.206 +	     # Try only shells that exist, to save several forks.
  15.207 +	     as_shell=$as_dir/$as_base
  15.208 +	     if { test -f "$as_shell" || test -f "$as_shell.exe"; } &&
  15.209 +		    { $as_echo "$as_bourne_compatible""$as_required" | as_run=a "$as_shell"; } 2>/dev/null; then :
  15.210 +  CONFIG_SHELL=$as_shell as_have_required=yes
  15.211 +		   if { $as_echo "$as_bourne_compatible""$as_suggested" | as_run=a "$as_shell"; } 2>/dev/null; then :
  15.212 +  break 2
  15.213 +fi
  15.214 +fi
  15.215 +	   done;;
  15.216 +       esac
  15.217 +  as_found=false
  15.218 +done
  15.219 +$as_found || { if { test -f "$SHELL" || test -f "$SHELL.exe"; } &&
  15.220 +	      { $as_echo "$as_bourne_compatible""$as_required" | as_run=a "$SHELL"; } 2>/dev/null; then :
  15.221 +  CONFIG_SHELL=$SHELL as_have_required=yes
  15.222 +fi; }
  15.223 +IFS=$as_save_IFS
  15.224 +
  15.225 +
  15.226 +      if test "x$CONFIG_SHELL" != x; then :
  15.227 +  # We cannot yet assume a decent shell, so we have to provide a
  15.228 +	# neutralization value for shells without unset; and this also
  15.229 +	# works around shells that cannot unset nonexistent variables.
  15.230 +	BASH_ENV=/dev/null
  15.231 +	ENV=/dev/null
  15.232 +	(unset BASH_ENV) >/dev/null 2>&1 && unset BASH_ENV ENV
  15.233 +	export CONFIG_SHELL
  15.234 +	exec "$CONFIG_SHELL" "$as_myself" ${1+"$@"}
  15.235 +fi
  15.236 +
  15.237 +    if test x$as_have_required = xno; then :
  15.238 +  $as_echo "$0: This script requires a shell more modern than all"
  15.239 +  $as_echo "$0: the shells that I found on your system."
  15.240 +  if test x${ZSH_VERSION+set} = xset ; then
  15.241 +    $as_echo "$0: In particular, zsh $ZSH_VERSION has bugs and should"
  15.242 +    $as_echo "$0: be upgraded to zsh 4.3.4 or later."
  15.243 +  else
  15.244 +    $as_echo "$0: Please tell bug-autoconf@gnu.org and bug-glpk@gnu.org
  15.245 +$0: about your system, including any error possibly output
  15.246 +$0: before this message. Then install a modern shell, or
  15.247 +$0: manually run the script under such a shell if you do
  15.248 +$0: have one."
  15.249 +  fi
  15.250 +  exit 1
  15.251 +fi
  15.252 +fi
  15.253 +fi
  15.254 +SHELL=${CONFIG_SHELL-/bin/sh}
  15.255 +export SHELL
  15.256 +# Unset more variables known to interfere with behavior of common tools.
  15.257 +CLICOLOR_FORCE= GREP_OPTIONS=
  15.258 +unset CLICOLOR_FORCE GREP_OPTIONS
  15.259 +
  15.260 +## --------------------- ##
  15.261 +## M4sh Shell Functions. ##
  15.262 +## --------------------- ##
  15.263 +# as_fn_unset VAR
  15.264 +# ---------------
  15.265 +# Portably unset VAR.
  15.266 +as_fn_unset ()
  15.267 +{
  15.268 +  { eval $1=; unset $1;}
  15.269 +}
  15.270 +as_unset=as_fn_unset
  15.271 +
  15.272 +# as_fn_set_status STATUS
  15.273 +# -----------------------
  15.274 +# Set $? to STATUS, without forking.
  15.275 +as_fn_set_status ()
  15.276 +{
  15.277 +  return $1
  15.278 +} # as_fn_set_status
  15.279 +
  15.280 +# as_fn_exit STATUS
  15.281 +# -----------------
  15.282 +# Exit the shell with STATUS, even in a "trap 0" or "set -e" context.
  15.283 +as_fn_exit ()
  15.284 +{
  15.285 +  set +e
  15.286 +  as_fn_set_status $1
  15.287 +  exit $1
  15.288 +} # as_fn_exit
  15.289 +
  15.290 +# as_fn_mkdir_p
  15.291 +# -------------
  15.292 +# Create "$as_dir" as a directory, including parents if necessary.
  15.293 +as_fn_mkdir_p ()
  15.294 +{
  15.295 +
  15.296 +  case $as_dir in #(
  15.297 +  -*) as_dir=./$as_dir;;
  15.298 +  esac
  15.299 +  test -d "$as_dir" || eval $as_mkdir_p || {
  15.300 +    as_dirs=
  15.301 +    while :; do
  15.302 +      case $as_dir in #(
  15.303 +      *\'*) as_qdir=`$as_echo "$as_dir" | sed "s/'/'\\\\\\\\''/g"`;; #'(
  15.304 +      *) as_qdir=$as_dir;;
  15.305 +      esac
  15.306 +      as_dirs="'$as_qdir' $as_dirs"
  15.307 +      as_dir=`$as_dirname -- "$as_dir" ||
  15.308 +$as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
  15.309 +	 X"$as_dir" : 'X\(//\)[^/]' \| \
  15.310 +	 X"$as_dir" : 'X\(//\)$' \| \
  15.311 +	 X"$as_dir" : 'X\(/\)' \| . 2>/dev/null ||
  15.312 +$as_echo X"$as_dir" |
  15.313 +    sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{
  15.314 +	    s//\1/
  15.315 +	    q
  15.316 +	  }
  15.317 +	  /^X\(\/\/\)[^/].*/{
  15.318 +	    s//\1/
  15.319 +	    q
  15.320 +	  }
  15.321 +	  /^X\(\/\/\)$/{
  15.322 +	    s//\1/
  15.323 +	    q
  15.324 +	  }
  15.325 +	  /^X\(\/\).*/{
  15.326 +	    s//\1/
  15.327 +	    q
  15.328 +	  }
  15.329 +	  s/.*/./; q'`
  15.330 +      test -d "$as_dir" && break
  15.331 +    done
  15.332 +    test -z "$as_dirs" || eval "mkdir $as_dirs"
  15.333 +  } || test -d "$as_dir" || as_fn_error "cannot create directory $as_dir"
  15.334 +
  15.335 +
  15.336 +} # as_fn_mkdir_p
  15.337 +# as_fn_append VAR VALUE
  15.338 +# ----------------------
  15.339 +# Append the text in VALUE to the end of the definition contained in VAR. Take
  15.340 +# advantage of any shell optimizations that allow amortized linear growth over
  15.341 +# repeated appends, instead of the typical quadratic growth present in naive
  15.342 +# implementations.
  15.343 +if (eval "as_var=1; as_var+=2; test x\$as_var = x12") 2>/dev/null; then :
  15.344 +  eval 'as_fn_append ()
  15.345 +  {
  15.346 +    eval $1+=\$2
  15.347 +  }'
  15.348 +else
  15.349 +  as_fn_append ()
  15.350 +  {
  15.351 +    eval $1=\$$1\$2
  15.352 +  }
  15.353 +fi # as_fn_append
  15.354 +
  15.355 +# as_fn_arith ARG...
  15.356 +# ------------------
  15.357 +# Perform arithmetic evaluation on the ARGs, and store the result in the
  15.358 +# global $as_val. Take advantage of shells that can avoid forks. The arguments
  15.359 +# must be portable across $(()) and expr.
  15.360 +if (eval "test \$(( 1 + 1 )) = 2") 2>/dev/null; then :
  15.361 +  eval 'as_fn_arith ()
  15.362 +  {
  15.363 +    as_val=$(( $* ))
  15.364 +  }'
  15.365 +else
  15.366 +  as_fn_arith ()
  15.367 +  {
  15.368 +    as_val=`expr "$@" || test $? -eq 1`
  15.369 +  }
  15.370 +fi # as_fn_arith
  15.371 +
  15.372 +
  15.373 +# as_fn_error ERROR [LINENO LOG_FD]
  15.374 +# ---------------------------------
  15.375 +# Output "`basename $0`: error: ERROR" to stderr. If LINENO and LOG_FD are
  15.376 +# provided, also output the error to LOG_FD, referencing LINENO. Then exit the
  15.377 +# script with status $?, using 1 if that was 0.
  15.378 +as_fn_error ()
  15.379 +{
  15.380 +  as_status=$?; test $as_status -eq 0 && as_status=1
  15.381 +  if test "$3"; then
  15.382 +    as_lineno=${as_lineno-"$2"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
  15.383 +    $as_echo "$as_me:${as_lineno-$LINENO}: error: $1" >&$3
  15.384 +  fi
  15.385 +  $as_echo "$as_me: error: $1" >&2
  15.386 +  as_fn_exit $as_status
  15.387 +} # as_fn_error
  15.388 +
  15.389 +if expr a : '\(a\)' >/dev/null 2>&1 &&
  15.390 +   test "X`expr 00001 : '.*\(...\)'`" = X001; then
  15.391 +  as_expr=expr
  15.392 +else
  15.393 +  as_expr=false
  15.394 +fi
  15.395 +
  15.396 +if (basename -- /) >/dev/null 2>&1 && test "X`basename -- / 2>&1`" = "X/"; then
  15.397 +  as_basename=basename
  15.398 +else
  15.399 +  as_basename=false
  15.400 +fi
  15.401 +
  15.402 +if (as_dir=`dirname -- /` && test "X$as_dir" = X/) >/dev/null 2>&1; then
  15.403 +  as_dirname=dirname
  15.404 +else
  15.405 +  as_dirname=false
  15.406 +fi
  15.407 +
  15.408 +as_me=`$as_basename -- "$0" ||
  15.409 +$as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \
  15.410 +	 X"$0" : 'X\(//\)$' \| \
  15.411 +	 X"$0" : 'X\(/\)' \| . 2>/dev/null ||
  15.412 +$as_echo X/"$0" |
  15.413 +    sed '/^.*\/\([^/][^/]*\)\/*$/{
  15.414 +	    s//\1/
  15.415 +	    q
  15.416 +	  }
  15.417 +	  /^X\/\(\/\/\)$/{
  15.418 +	    s//\1/
  15.419 +	    q
  15.420 +	  }
  15.421 +	  /^X\/\(\/\).*/{
  15.422 +	    s//\1/
  15.423 +	    q
  15.424 +	  }
  15.425 +	  s/.*/./; q'`
  15.426 +
  15.427 +# Avoid depending upon Character Ranges.
  15.428 +as_cr_letters='abcdefghijklmnopqrstuvwxyz'
  15.429 +as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ'
  15.430 +as_cr_Letters=$as_cr_letters$as_cr_LETTERS
  15.431 +as_cr_digits='0123456789'
  15.432 +as_cr_alnum=$as_cr_Letters$as_cr_digits
  15.433 +
  15.434 +
  15.435 +  as_lineno_1=$LINENO as_lineno_1a=$LINENO
  15.436 +  as_lineno_2=$LINENO as_lineno_2a=$LINENO
  15.437 +  eval 'test "x$as_lineno_1'$as_run'" != "x$as_lineno_2'$as_run'" &&
  15.438 +  test "x`expr $as_lineno_1'$as_run' + 1`" = "x$as_lineno_2'$as_run'"' || {
  15.439 +  # Blame Lee E. McMahon (1931-1989) for sed's syntax.  :-)
  15.440 +  sed -n '
  15.441 +    p
  15.442 +    /[$]LINENO/=
  15.443 +  ' <$as_myself |
  15.444 +    sed '
  15.445 +      s/[$]LINENO.*/&-/
  15.446 +      t lineno
  15.447 +      b
  15.448 +      :lineno
  15.449 +      N
  15.450 +      :loop
  15.451 +      s/[$]LINENO\([^'$as_cr_alnum'_].*\n\)\(.*\)/\2\1\2/
  15.452 +      t loop
  15.453 +      s/-\n.*//
  15.454 +    ' >$as_me.lineno &&
  15.455 +  chmod +x "$as_me.lineno" ||
  15.456 +    { $as_echo "$as_me: error: cannot create $as_me.lineno; rerun with a POSIX shell" >&2; as_fn_exit 1; }
  15.457 +
  15.458 +  # Don't try to exec as it changes $[0], causing all sort of problems
  15.459 +  # (the dirname of $[0] is not the place where we might find the
  15.460 +  # original and so on.  Autoconf is especially sensitive to this).
  15.461 +  . "./$as_me.lineno"
  15.462 +  # Exit status is that of the last command.
  15.463 +  exit
  15.464 +}
  15.465 +
  15.466 +ECHO_C= ECHO_N= ECHO_T=
  15.467 +case `echo -n x` in #(((((
  15.468 +-n*)
  15.469 +  case `echo 'xy\c'` in
  15.470 +  *c*) ECHO_T='	';;	# ECHO_T is single tab character.
  15.471 +  xy)  ECHO_C='\c';;
  15.472 +  *)   echo `echo ksh88 bug on AIX 6.1` > /dev/null
  15.473 +       ECHO_T='	';;
  15.474 +  esac;;
  15.475 +*)
  15.476 +  ECHO_N='-n';;
  15.477 +esac
  15.478 +
  15.479 +rm -f conf$$ conf$$.exe conf$$.file
  15.480 +if test -d conf$$.dir; then
  15.481 +  rm -f conf$$.dir/conf$$.file
  15.482 +else
  15.483 +  rm -f conf$$.dir
  15.484 +  mkdir conf$$.dir 2>/dev/null
  15.485 +fi
  15.486 +if (echo >conf$$.file) 2>/dev/null; then
  15.487 +  if ln -s conf$$.file conf$$ 2>/dev/null; then
  15.488 +    as_ln_s='ln -s'
  15.489 +    # ... but there are two gotchas:
  15.490 +    # 1) On MSYS, both `ln -s file dir' and `ln file dir' fail.
  15.491 +    # 2) DJGPP < 2.04 has no symlinks; `ln -s' creates a wrapper executable.
  15.492 +    # In both cases, we have to default to `cp -p'.
  15.493 +    ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe ||
  15.494 +      as_ln_s='cp -p'
  15.495 +  elif ln conf$$.file conf$$ 2>/dev/null; then
  15.496 +    as_ln_s=ln
  15.497 +  else
  15.498 +    as_ln_s='cp -p'
  15.499 +  fi
  15.500 +else
  15.501 +  as_ln_s='cp -p'
  15.502 +fi
  15.503 +rm -f conf$$ conf$$.exe conf$$.dir/conf$$.file conf$$.file
  15.504 +rmdir conf$$.dir 2>/dev/null
  15.505 +
  15.506 +if mkdir -p . 2>/dev/null; then
  15.507 +  as_mkdir_p='mkdir -p "$as_dir"'
  15.508 +else
  15.509 +  test -d ./-p && rmdir ./-p
  15.510 +  as_mkdir_p=false
  15.511 +fi
  15.512 +
  15.513 +if test -x / >/dev/null 2>&1; then
  15.514 +  as_test_x='test -x'
  15.515 +else
  15.516 +  if ls -dL / >/dev/null 2>&1; then
  15.517 +    as_ls_L_option=L
  15.518 +  else
  15.519 +    as_ls_L_option=
  15.520 +  fi
  15.521 +  as_test_x='
  15.522 +    eval sh -c '\''
  15.523 +      if test -d "$1"; then
  15.524 +	test -d "$1/.";
  15.525 +      else
  15.526 +	case $1 in #(
  15.527 +	-*)set "./$1";;
  15.528 +	esac;
  15.529 +	case `ls -ld'$as_ls_L_option' "$1" 2>/dev/null` in #((
  15.530 +	???[sx]*):;;*)false;;esac;fi
  15.531 +    '\'' sh
  15.532 +  '
  15.533 +fi
  15.534 +as_executable_p=$as_test_x
  15.535 +
  15.536 +# Sed expression to map a string onto a valid CPP name.
  15.537 +as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'"
  15.538 +
  15.539 +# Sed expression to map a string onto a valid variable name.
  15.540 +as_tr_sh="eval sed 'y%*+%pp%;s%[^_$as_cr_alnum]%_%g'"
  15.541 +
  15.542 +SHELL=${CONFIG_SHELL-/bin/sh}
  15.543 +
  15.544 +
  15.545 +test -n "$DJDIR" || exec 7<&0 </dev/null
  15.546 +exec 6>&1
  15.547 +
  15.548 +# Name of the host.
  15.549 +# hostname on some systems (SVR3.2, Linux) returns a bogus exit status,
  15.550 +# so uname gets run too.
  15.551 +ac_hostname=`(hostname || uname -n) 2>/dev/null | sed 1q`
  15.552 +
  15.553 +#
  15.554 +# Initializations.
  15.555 +#
  15.556 +ac_default_prefix=/usr/local
  15.557 +ac_clean_files=
  15.558 +ac_config_libobj_dir=.
  15.559 +LIBOBJS=
  15.560 +cross_compiling=no
  15.561 +subdirs=
  15.562 +MFLAGS=
  15.563 +MAKEFLAGS=
  15.564 +
  15.565 +# Identity of this package.
  15.566 +PACKAGE_NAME='GLPK'
  15.567 +PACKAGE_TARNAME='glpk'
  15.568 +PACKAGE_VERSION='4.47'
  15.569 +PACKAGE_STRING='GLPK 4.47'
  15.570 +PACKAGE_BUGREPORT='bug-glpk@gnu.org'
  15.571 +PACKAGE_URL=''
  15.572 +
  15.573 +ac_unique_file="src/glpk.h"
  15.574 +# Factoring default headers for most tests.
  15.575 +ac_includes_default="\
  15.576 +#include <stdio.h>
  15.577 +#ifdef HAVE_SYS_TYPES_H
  15.578 +# include <sys/types.h>
  15.579 +#endif
  15.580 +#ifdef HAVE_SYS_STAT_H
  15.581 +# include <sys/stat.h>
  15.582 +#endif
  15.583 +#ifdef STDC_HEADERS
  15.584 +# include <stdlib.h>
  15.585 +# include <stddef.h>
  15.586 +#else
  15.587 +# ifdef HAVE_STDLIB_H
  15.588 +#  include <stdlib.h>
  15.589 +# endif
  15.590 +#endif
  15.591 +#ifdef HAVE_STRING_H
  15.592 +# if !defined STDC_HEADERS && defined HAVE_MEMORY_H
  15.593 +#  include <memory.h>
  15.594 +# endif
  15.595 +# include <string.h>
  15.596 +#endif
  15.597 +#ifdef HAVE_STRINGS_H
  15.598 +# include <strings.h>
  15.599 +#endif
  15.600 +#ifdef HAVE_INTTYPES_H
  15.601 +# include <inttypes.h>
  15.602 +#endif
  15.603 +#ifdef HAVE_STDINT_H
  15.604 +# include <stdint.h>
  15.605 +#endif
  15.606 +#ifdef HAVE_UNISTD_H
  15.607 +# include <unistd.h>
  15.608 +#endif"
  15.609 +
  15.610 +ac_subst_vars='am__EXEEXT_FALSE
  15.611 +am__EXEEXT_TRUE
  15.612 +LTLIBOBJS
  15.613 +LIBOBJS
  15.614 +CPP
  15.615 +OTOOL64
  15.616 +OTOOL
  15.617 +LIPO
  15.618 +NMEDIT
  15.619 +DSYMUTIL
  15.620 +RANLIB
  15.621 +AR
  15.622 +DLLTOOL
  15.623 +OBJDUMP
  15.624 +to_host_path_cmd
  15.625 +LN_S
  15.626 +NM
  15.627 +ac_ct_DUMPBIN
  15.628 +DUMPBIN
  15.629 +LD
  15.630 +FGREP
  15.631 +EGREP
  15.632 +GREP
  15.633 +SED
  15.634 +host_os
  15.635 +host_vendor
  15.636 +host_cpu
  15.637 +host
  15.638 +build_os
  15.639 +build_vendor
  15.640 +build_cpu
  15.641 +build
  15.642 +LIBTOOL
  15.643 +am__fastdepCC_FALSE
  15.644 +am__fastdepCC_TRUE
  15.645 +CCDEPMODE
  15.646 +AMDEPBACKSLASH
  15.647 +AMDEP_FALSE
  15.648 +AMDEP_TRUE
  15.649 +am__quote
  15.650 +am__include
  15.651 +DEPDIR
  15.652 +OBJEXT
  15.653 +EXEEXT
  15.654 +ac_ct_CC
  15.655 +CPPFLAGS
  15.656 +LDFLAGS
  15.657 +CFLAGS
  15.658 +CC
  15.659 +am__untar
  15.660 +am__tar
  15.661 +AMTAR
  15.662 +am__leading_dot
  15.663 +SET_MAKE
  15.664 +AWK
  15.665 +mkdir_p
  15.666 +MKDIR_P
  15.667 +INSTALL_STRIP_PROGRAM
  15.668 +STRIP
  15.669 +install_sh
  15.670 +MAKEINFO
  15.671 +AUTOHEADER
  15.672 +AUTOMAKE
  15.673 +AUTOCONF
  15.674 +ACLOCAL
  15.675 +VERSION
  15.676 +PACKAGE
  15.677 +CYGPATH_W
  15.678 +am__isrc
  15.679 +INSTALL_DATA
  15.680 +INSTALL_SCRIPT
  15.681 +INSTALL_PROGRAM
  15.682 +target_alias
  15.683 +host_alias
  15.684 +build_alias
  15.685 +LIBS
  15.686 +ECHO_T
  15.687 +ECHO_N
  15.688 +ECHO_C
  15.689 +DEFS
  15.690 +mandir
  15.691 +localedir
  15.692 +libdir
  15.693 +psdir
  15.694 +pdfdir
  15.695 +dvidir
  15.696 +htmldir
  15.697 +infodir
  15.698 +docdir
  15.699 +oldincludedir
  15.700 +includedir
  15.701 +localstatedir
  15.702 +sharedstatedir
  15.703 +sysconfdir
  15.704 +datadir
  15.705 +datarootdir
  15.706 +libexecdir
  15.707 +sbindir
  15.708 +bindir
  15.709 +program_transform_name
  15.710 +prefix
  15.711 +exec_prefix
  15.712 +PACKAGE_URL
  15.713 +PACKAGE_BUGREPORT
  15.714 +PACKAGE_STRING
  15.715 +PACKAGE_VERSION
  15.716 +PACKAGE_TARNAME
  15.717 +PACKAGE_NAME
  15.718 +PATH_SEPARATOR
  15.719 +SHELL'
  15.720 +ac_subst_files=''
  15.721 +ac_user_opts='
  15.722 +enable_option_checking
  15.723 +with_gmp
  15.724 +enable_dl
  15.725 +enable_odbc
  15.726 +enable_mysql
  15.727 +enable_dependency_tracking
  15.728 +enable_shared
  15.729 +enable_static
  15.730 +with_pic
  15.731 +enable_fast_install
  15.732 +with_gnu_ld
  15.733 +enable_libtool_lock
  15.734 +'
  15.735 +      ac_precious_vars='build_alias
  15.736 +host_alias
  15.737 +target_alias
  15.738 +CC
  15.739 +CFLAGS
  15.740 +LDFLAGS
  15.741 +LIBS
  15.742 +CPPFLAGS
  15.743 +CPP'
  15.744 +
  15.745 +
  15.746 +# Initialize some variables set by options.
  15.747 +ac_init_help=
  15.748 +ac_init_version=false
  15.749 +ac_unrecognized_opts=
  15.750 +ac_unrecognized_sep=
  15.751 +# The variables have the same names as the options, with
  15.752 +# dashes changed to underlines.
  15.753 +cache_file=/dev/null
  15.754 +exec_prefix=NONE
  15.755 +no_create=
  15.756 +no_recursion=
  15.757 +prefix=NONE
  15.758 +program_prefix=NONE
  15.759 +program_suffix=NONE
  15.760 +program_transform_name=s,x,x,
  15.761 +silent=
  15.762 +site=
  15.763 +srcdir=
  15.764 +verbose=
  15.765 +x_includes=NONE
  15.766 +x_libraries=NONE
  15.767 +
  15.768 +# Installation directory options.
  15.769 +# These are left unexpanded so users can "make install exec_prefix=/foo"
  15.770 +# and all the variables that are supposed to be based on exec_prefix
  15.771 +# by default will actually change.
  15.772 +# Use braces instead of parens because sh, perl, etc. also accept them.
  15.773 +# (The list follows the same order as the GNU Coding Standards.)
  15.774 +bindir='${exec_prefix}/bin'
  15.775 +sbindir='${exec_prefix}/sbin'
  15.776 +libexecdir='${exec_prefix}/libexec'
  15.777 +datarootdir='${prefix}/share'
  15.778 +datadir='${datarootdir}'
  15.779 +sysconfdir='${prefix}/etc'
  15.780 +sharedstatedir='${prefix}/com'
  15.781 +localstatedir='${prefix}/var'
  15.782 +includedir='${prefix}/include'
  15.783 +oldincludedir='/usr/include'
  15.784 +docdir='${datarootdir}/doc/${PACKAGE_TARNAME}'
  15.785 +infodir='${datarootdir}/info'
  15.786 +htmldir='${docdir}'
  15.787 +dvidir='${docdir}'
  15.788 +pdfdir='${docdir}'
  15.789 +psdir='${docdir}'
  15.790 +libdir='${exec_prefix}/lib'
  15.791 +localedir='${datarootdir}/locale'
  15.792 +mandir='${datarootdir}/man'
  15.793 +
  15.794 +ac_prev=
  15.795 +ac_dashdash=
  15.796 +for ac_option
  15.797 +do
  15.798 +  # If the previous option needs an argument, assign it.
  15.799 +  if test -n "$ac_prev"; then
  15.800 +    eval $ac_prev=\$ac_option
  15.801 +    ac_prev=
  15.802 +    continue
  15.803 +  fi
  15.804 +
  15.805 +  case $ac_option in
  15.806 +  *=*)	ac_optarg=`expr "X$ac_option" : '[^=]*=\(.*\)'` ;;
  15.807 +  *)	ac_optarg=yes ;;
  15.808 +  esac
  15.809 +
  15.810 +  # Accept the important Cygnus configure options, so we can diagnose typos.
  15.811 +
  15.812 +  case $ac_dashdash$ac_option in
  15.813 +  --)
  15.814 +    ac_dashdash=yes ;;
  15.815 +
  15.816 +  -bindir | --bindir | --bindi | --bind | --bin | --bi)
  15.817 +    ac_prev=bindir ;;
  15.818 +  -bindir=* | --bindir=* | --bindi=* | --bind=* | --bin=* | --bi=*)
  15.819 +    bindir=$ac_optarg ;;
  15.820 +
  15.821 +  -build | --build | --buil | --bui | --bu)
  15.822 +    ac_prev=build_alias ;;
  15.823 +  -build=* | --build=* | --buil=* | --bui=* | --bu=*)
  15.824 +    build_alias=$ac_optarg ;;
  15.825 +
  15.826 +  -cache-file | --cache-file | --cache-fil | --cache-fi \
  15.827 +  | --cache-f | --cache- | --cache | --cach | --cac | --ca | --c)
  15.828 +    ac_prev=cache_file ;;
  15.829 +  -cache-file=* | --cache-file=* | --cache-fil=* | --cache-fi=* \
  15.830 +  | --cache-f=* | --cache-=* | --cache=* | --cach=* | --cac=* | --ca=* | --c=*)
  15.831 +    cache_file=$ac_optarg ;;
  15.832 +
  15.833 +  --config-cache | -C)
  15.834 +    cache_file=config.cache ;;
  15.835 +
  15.836 +  -datadir | --datadir | --datadi | --datad)
  15.837 +    ac_prev=datadir ;;
  15.838 +  -datadir=* | --datadir=* | --datadi=* | --datad=*)
  15.839 +    datadir=$ac_optarg ;;
  15.840 +
  15.841 +  -datarootdir | --datarootdir | --datarootdi | --datarootd | --dataroot \
  15.842 +  | --dataroo | --dataro | --datar)
  15.843 +    ac_prev=datarootdir ;;
  15.844 +  -datarootdir=* | --datarootdir=* | --datarootdi=* | --datarootd=* \
  15.845 +  | --dataroot=* | --dataroo=* | --dataro=* | --datar=*)
  15.846 +    datarootdir=$ac_optarg ;;
  15.847 +
  15.848 +  -disable-* | --disable-*)
  15.849 +    ac_useropt=`expr "x$ac_option" : 'x-*disable-\(.*\)'`
  15.850 +    # Reject names that are not valid shell variable names.
  15.851 +    expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null &&
  15.852 +      as_fn_error "invalid feature name: $ac_useropt"
  15.853 +    ac_useropt_orig=$ac_useropt
  15.854 +    ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'`
  15.855 +    case $ac_user_opts in
  15.856 +      *"
  15.857 +"enable_$ac_useropt"
  15.858 +"*) ;;
  15.859 +      *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--disable-$ac_useropt_orig"
  15.860 +	 ac_unrecognized_sep=', ';;
  15.861 +    esac
  15.862 +    eval enable_$ac_useropt=no ;;
  15.863 +
  15.864 +  -docdir | --docdir | --docdi | --doc | --do)
  15.865 +    ac_prev=docdir ;;
  15.866 +  -docdir=* | --docdir=* | --docdi=* | --doc=* | --do=*)
  15.867 +    docdir=$ac_optarg ;;
  15.868 +
  15.869 +  -dvidir | --dvidir | --dvidi | --dvid | --dvi | --dv)
  15.870 +    ac_prev=dvidir ;;
  15.871 +  -dvidir=* | --dvidir=* | --dvidi=* | --dvid=* | --dvi=* | --dv=*)
  15.872 +    dvidir=$ac_optarg ;;
  15.873 +
  15.874 +  -enable-* | --enable-*)
  15.875 +    ac_useropt=`expr "x$ac_option" : 'x-*enable-\([^=]*\)'`
  15.876 +    # Reject names that are not valid shell variable names.
  15.877 +    expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null &&
  15.878 +      as_fn_error "invalid feature name: $ac_useropt"
  15.879 +    ac_useropt_orig=$ac_useropt
  15.880 +    ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'`
  15.881 +    case $ac_user_opts in
  15.882 +      *"
  15.883 +"enable_$ac_useropt"
  15.884 +"*) ;;
  15.885 +      *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--enable-$ac_useropt_orig"
  15.886 +	 ac_unrecognized_sep=', ';;
  15.887 +    esac
  15.888 +    eval enable_$ac_useropt=\$ac_optarg ;;
  15.889 +
  15.890 +  -exec-prefix | --exec_prefix | --exec-prefix | --exec-prefi \
  15.891 +  | --exec-pref | --exec-pre | --exec-pr | --exec-p | --exec- \
  15.892 +  | --exec | --exe | --ex)
  15.893 +    ac_prev=exec_prefix ;;
  15.894 +  -exec-prefix=* | --exec_prefix=* | --exec-prefix=* | --exec-prefi=* \
  15.895 +  | --exec-pref=* | --exec-pre=* | --exec-pr=* | --exec-p=* | --exec-=* \
  15.896 +  | --exec=* | --exe=* | --ex=*)
  15.897 +    exec_prefix=$ac_optarg ;;
  15.898 +
  15.899 +  -gas | --gas | --ga | --g)
  15.900 +    # Obsolete; use --with-gas.
  15.901 +    with_gas=yes ;;
  15.902 +
  15.903 +  -help | --help | --hel | --he | -h)
  15.904 +    ac_init_help=long ;;
  15.905 +  -help=r* | --help=r* | --hel=r* | --he=r* | -hr*)
  15.906 +    ac_init_help=recursive ;;
  15.907 +  -help=s* | --help=s* | --hel=s* | --he=s* | -hs*)
  15.908 +    ac_init_help=short ;;
  15.909 +
  15.910 +  -host | --host | --hos | --ho)
  15.911 +    ac_prev=host_alias ;;
  15.912 +  -host=* | --host=* | --hos=* | --ho=*)
  15.913 +    host_alias=$ac_optarg ;;
  15.914 +
  15.915 +  -htmldir | --htmldir | --htmldi | --htmld | --html | --htm | --ht)
  15.916 +    ac_prev=htmldir ;;
  15.917 +  -htmldir=* | --htmldir=* | --htmldi=* | --htmld=* | --html=* | --htm=* \
  15.918 +  | --ht=*)
  15.919 +    htmldir=$ac_optarg ;;
  15.920 +
  15.921 +  -includedir | --includedir | --includedi | --included | --include \
  15.922 +  | --includ | --inclu | --incl | --inc)
  15.923 +    ac_prev=includedir ;;
  15.924 +  -includedir=* | --includedir=* | --includedi=* | --included=* | --include=* \
  15.925 +  | --includ=* | --inclu=* | --incl=* | --inc=*)
  15.926 +    includedir=$ac_optarg ;;
  15.927 +
  15.928 +  -infodir | --infodir | --infodi | --infod | --info | --inf)
  15.929 +    ac_prev=infodir ;;
  15.930 +  -infodir=* | --infodir=* | --infodi=* | --infod=* | --info=* | --inf=*)
  15.931 +    infodir=$ac_optarg ;;
  15.932 +
  15.933 +  -libdir | --libdir | --libdi | --libd)
  15.934 +    ac_prev=libdir ;;
  15.935 +  -libdir=* | --libdir=* | --libdi=* | --libd=*)
  15.936 +    libdir=$ac_optarg ;;
  15.937 +
  15.938 +  -libexecdir | --libexecdir | --libexecdi | --libexecd | --libexec \
  15.939 +  | --libexe | --libex | --libe)
  15.940 +    ac_prev=libexecdir ;;
  15.941 +  -libexecdir=* | --libexecdir=* | --libexecdi=* | --libexecd=* | --libexec=* \
  15.942 +  | --libexe=* | --libex=* | --libe=*)
  15.943 +    libexecdir=$ac_optarg ;;
  15.944 +
  15.945 +  -localedir | --localedir | --localedi | --localed | --locale)
  15.946 +    ac_prev=localedir ;;
  15.947 +  -localedir=* | --localedir=* | --localedi=* | --localed=* | --locale=*)
  15.948 +    localedir=$ac_optarg ;;
  15.949 +
  15.950 +  -localstatedir | --localstatedir | --localstatedi | --localstated \
  15.951 +  | --localstate | --localstat | --localsta | --localst | --locals)
  15.952 +    ac_prev=localstatedir ;;
  15.953 +  -localstatedir=* | --localstatedir=* | --localstatedi=* | --localstated=* \
  15.954 +  | --localstate=* | --localstat=* | --localsta=* | --localst=* | --locals=*)
  15.955 +    localstatedir=$ac_optarg ;;
  15.956 +
  15.957 +  -mandir | --mandir | --mandi | --mand | --man | --ma | --m)
  15.958 +    ac_prev=mandir ;;
  15.959 +  -mandir=* | --mandir=* | --mandi=* | --mand=* | --man=* | --ma=* | --m=*)
  15.960 +    mandir=$ac_optarg ;;
  15.961 +
  15.962 +  -nfp | --nfp | --nf)
  15.963 +    # Obsolete; use --without-fp.
  15.964 +    with_fp=no ;;
  15.965 +
  15.966 +  -no-create | --no-create | --no-creat | --no-crea | --no-cre \
  15.967 +  | --no-cr | --no-c | -n)
  15.968 +    no_create=yes ;;
  15.969 +
  15.970 +  -no-recursion | --no-recursion | --no-recursio | --no-recursi \
  15.971 +  | --no-recurs | --no-recur | --no-recu | --no-rec | --no-re | --no-r)
  15.972 +    no_recursion=yes ;;
  15.973 +
  15.974 +  -oldincludedir | --oldincludedir | --oldincludedi | --oldincluded \
  15.975 +  | --oldinclude | --oldinclud | --oldinclu | --oldincl | --oldinc \
  15.976 +  | --oldin | --oldi | --old | --ol | --o)
  15.977 +    ac_prev=oldincludedir ;;
  15.978 +  -oldincludedir=* | --oldincludedir=* | --oldincludedi=* | --oldincluded=* \
  15.979 +  | --oldinclude=* | --oldinclud=* | --oldinclu=* | --oldincl=* | --oldinc=* \
  15.980 +  | --oldin=* | --oldi=* | --old=* | --ol=* | --o=*)
  15.981 +    oldincludedir=$ac_optarg ;;
  15.982 +
  15.983 +  -prefix | --prefix | --prefi | --pref | --pre | --pr | --p)
  15.984 +    ac_prev=prefix ;;
  15.985 +  -prefix=* | --prefix=* | --prefi=* | --pref=* | --pre=* | --pr=* | --p=*)
  15.986 +    prefix=$ac_optarg ;;
  15.987 +
  15.988 +  -program-prefix | --program-prefix | --program-prefi | --program-pref \
  15.989 +  | --program-pre | --program-pr | --program-p)
  15.990 +    ac_prev=program_prefix ;;
  15.991 +  -program-prefix=* | --program-prefix=* | --program-prefi=* \
  15.992 +  | --program-pref=* | --program-pre=* | --program-pr=* | --program-p=*)
  15.993 +    program_prefix=$ac_optarg ;;
  15.994 +
  15.995 +  -program-suffix | --program-suffix | --program-suffi | --program-suff \
  15.996 +  | --program-suf | --program-su | --program-s)
  15.997 +    ac_prev=program_suffix ;;
  15.998 +  -program-suffix=* | --program-suffix=* | --program-suffi=* \
  15.999 +  | --program-suff=* | --program-suf=* | --program-su=* | --program-s=*)
 15.1000 +    program_suffix=$ac_optarg ;;
 15.1001 +
 15.1002 +  -program-transform-name | --program-transform-name \
 15.1003 +  | --program-transform-nam | --program-transform-na \
 15.1004 +  | --program-transform-n | --program-transform- \
 15.1005 +  | --program-transform | --program-transfor \
 15.1006 +  | --program-transfo | --program-transf \
 15.1007 +  | --program-trans | --program-tran \
 15.1008 +  | --progr-tra | --program-tr | --program-t)
 15.1009 +    ac_prev=program_transform_name ;;
 15.1010 +  -program-transform-name=* | --program-transform-name=* \
 15.1011 +  | --program-transform-nam=* | --program-transform-na=* \
 15.1012 +  | --program-transform-n=* | --program-transform-=* \
 15.1013 +  | --program-transform=* | --program-transfor=* \
 15.1014 +  | --program-transfo=* | --program-transf=* \
 15.1015 +  | --program-trans=* | --program-tran=* \
 15.1016 +  | --progr-tra=* | --program-tr=* | --program-t=*)
 15.1017 +    program_transform_name=$ac_optarg ;;
 15.1018 +
 15.1019 +  -pdfdir | --pdfdir | --pdfdi | --pdfd | --pdf | --pd)
 15.1020 +    ac_prev=pdfdir ;;
 15.1021 +  -pdfdir=* | --pdfdir=* | --pdfdi=* | --pdfd=* | --pdf=* | --pd=*)
 15.1022 +    pdfdir=$ac_optarg ;;
 15.1023 +
 15.1024 +  -psdir | --psdir | --psdi | --psd | --ps)
 15.1025 +    ac_prev=psdir ;;
 15.1026 +  -psdir=* | --psdir=* | --psdi=* | --psd=* | --ps=*)
 15.1027 +    psdir=$ac_optarg ;;
 15.1028 +
 15.1029 +  -q | -quiet | --quiet | --quie | --qui | --qu | --q \
 15.1030 +  | -silent | --silent | --silen | --sile | --sil)
 15.1031 +    silent=yes ;;
 15.1032 +
 15.1033 +  -sbindir | --sbindir | --sbindi | --sbind | --sbin | --sbi | --sb)
 15.1034 +    ac_prev=sbindir ;;
 15.1035 +  -sbindir=* | --sbindir=* | --sbindi=* | --sbind=* | --sbin=* \
 15.1036 +  | --sbi=* | --sb=*)
 15.1037 +    sbindir=$ac_optarg ;;
 15.1038 +
 15.1039 +  -sharedstatedir | --sharedstatedir | --sharedstatedi \
 15.1040 +  | --sharedstated | --sharedstate | --sharedstat | --sharedsta \
 15.1041 +  | --sharedst | --shareds | --shared | --share | --shar \
 15.1042 +  | --sha | --sh)
 15.1043 +    ac_prev=sharedstatedir ;;
 15.1044 +  -sharedstatedir=* | --sharedstatedir=* | --sharedstatedi=* \
 15.1045 +  | --sharedstated=* | --sharedstate=* | --sharedstat=* | --sharedsta=* \
 15.1046 +  | --sharedst=* | --shareds=* | --shared=* | --share=* | --shar=* \
 15.1047 +  | --sha=* | --sh=*)
 15.1048 +    sharedstatedir=$ac_optarg ;;
 15.1049 +
 15.1050 +  -site | --site | --sit)
 15.1051 +    ac_prev=site ;;
 15.1052 +  -site=* | --site=* | --sit=*)
 15.1053 +    site=$ac_optarg ;;
 15.1054 +
 15.1055 +  -srcdir | --srcdir | --srcdi | --srcd | --src | --sr)
 15.1056 +    ac_prev=srcdir ;;
 15.1057 +  -srcdir=* | --srcdir=* | --srcdi=* | --srcd=* | --src=* | --sr=*)
 15.1058 +    srcdir=$ac_optarg ;;
 15.1059 +
 15.1060 +  -sysconfdir | --sysconfdir | --sysconfdi | --sysconfd | --sysconf \
 15.1061 +  | --syscon | --sysco | --sysc | --sys | --sy)
 15.1062 +    ac_prev=sysconfdir ;;
 15.1063 +  -sysconfdir=* | --sysconfdir=* | --sysconfdi=* | --sysconfd=* | --sysconf=* \
 15.1064 +  | --syscon=* | --sysco=* | --sysc=* | --sys=* | --sy=*)
 15.1065 +    sysconfdir=$ac_optarg ;;
 15.1066 +
 15.1067 +  -target | --target | --targe | --targ | --tar | --ta | --t)
 15.1068 +    ac_prev=target_alias ;;
 15.1069 +  -target=* | --target=* | --targe=* | --targ=* | --tar=* | --ta=* | --t=*)
 15.1070 +    target_alias=$ac_optarg ;;
 15.1071 +
 15.1072 +  -v | -verbose | --verbose | --verbos | --verbo | --verb)
 15.1073 +    verbose=yes ;;
 15.1074 +
 15.1075 +  -version | --version | --versio | --versi | --vers | -V)
 15.1076 +    ac_init_version=: ;;
 15.1077 +
 15.1078 +  -with-* | --with-*)
 15.1079 +    ac_useropt=`expr "x$ac_option" : 'x-*with-\([^=]*\)'`
 15.1080 +    # Reject names that are not valid shell variable names.
 15.1081 +    expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null &&
 15.1082 +      as_fn_error "invalid package name: $ac_useropt"
 15.1083 +    ac_useropt_orig=$ac_useropt
 15.1084 +    ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'`
 15.1085 +    case $ac_user_opts in
 15.1086 +      *"
 15.1087 +"with_$ac_useropt"
 15.1088 +"*) ;;
 15.1089 +      *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--with-$ac_useropt_orig"
 15.1090 +	 ac_unrecognized_sep=', ';;
 15.1091 +    esac
 15.1092 +    eval with_$ac_useropt=\$ac_optarg ;;
 15.1093 +
 15.1094 +  -without-* | --without-*)
 15.1095 +    ac_useropt=`expr "x$ac_option" : 'x-*without-\(.*\)'`
 15.1096 +    # Reject names that are not valid shell variable names.
 15.1097 +    expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null &&
 15.1098 +      as_fn_error "invalid package name: $ac_useropt"
 15.1099 +    ac_useropt_orig=$ac_useropt
 15.1100 +    ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'`
 15.1101 +    case $ac_user_opts in
 15.1102 +      *"
 15.1103 +"with_$ac_useropt"
 15.1104 +"*) ;;
 15.1105 +      *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--without-$ac_useropt_orig"
 15.1106 +	 ac_unrecognized_sep=', ';;
 15.1107 +    esac
 15.1108 +    eval with_$ac_useropt=no ;;
 15.1109 +
 15.1110 +  --x)
 15.1111 +    # Obsolete; use --with-x.
 15.1112 +    with_x=yes ;;
 15.1113 +
 15.1114 +  -x-includes | --x-includes | --x-include | --x-includ | --x-inclu \
 15.1115 +  | --x-incl | --x-inc | --x-in | --x-i)
 15.1116 +    ac_prev=x_includes ;;
 15.1117 +  -x-includes=* | --x-includes=* | --x-include=* | --x-includ=* | --x-inclu=* \
 15.1118 +  | --x-incl=* | --x-inc=* | --x-in=* | --x-i=*)
 15.1119 +    x_includes=$ac_optarg ;;
 15.1120 +
 15.1121 +  -x-libraries | --x-libraries | --x-librarie | --x-librari \
 15.1122 +  | --x-librar | --x-libra | --x-libr | --x-lib | --x-li | --x-l)
 15.1123 +    ac_prev=x_libraries ;;
 15.1124 +  -x-libraries=* | --x-libraries=* | --x-librarie=* | --x-librari=* \
 15.1125 +  | --x-librar=* | --x-libra=* | --x-libr=* | --x-lib=* | --x-li=* | --x-l=*)
 15.1126 +    x_libraries=$ac_optarg ;;
 15.1127 +
 15.1128 +  -*) as_fn_error "unrecognized option: \`$ac_option'
 15.1129 +Try \`$0 --help' for more information."
 15.1130 +    ;;
 15.1131 +
 15.1132 +  *=*)
 15.1133 +    ac_envvar=`expr "x$ac_option" : 'x\([^=]*\)='`
 15.1134 +    # Reject names that are not valid shell variable names.
 15.1135 +    case $ac_envvar in #(
 15.1136 +      '' | [0-9]* | *[!_$as_cr_alnum]* )
 15.1137 +      as_fn_error "invalid variable name: \`$ac_envvar'" ;;
 15.1138 +    esac
 15.1139 +    eval $ac_envvar=\$ac_optarg
 15.1140 +    export $ac_envvar ;;
 15.1141 +
 15.1142 +  *)
 15.1143 +    # FIXME: should be removed in autoconf 3.0.
 15.1144 +    $as_echo "$as_me: WARNING: you should use --build, --host, --target" >&2
 15.1145 +    expr "x$ac_option" : ".*[^-._$as_cr_alnum]" >/dev/null &&
 15.1146 +      $as_echo "$as_me: WARNING: invalid host type: $ac_option" >&2
 15.1147 +    : ${build_alias=$ac_option} ${host_alias=$ac_option} ${target_alias=$ac_option}
 15.1148 +    ;;
 15.1149 +
 15.1150 +  esac
 15.1151 +done
 15.1152 +
 15.1153 +if test -n "$ac_prev"; then
 15.1154 +  ac_option=--`echo $ac_prev | sed 's/_/-/g'`
 15.1155 +  as_fn_error "missing argument to $ac_option"
 15.1156 +fi
 15.1157 +
 15.1158 +if test -n "$ac_unrecognized_opts"; then
 15.1159 +  case $enable_option_checking in
 15.1160 +    no) ;;
 15.1161 +    fatal) as_fn_error "unrecognized options: $ac_unrecognized_opts" ;;
 15.1162 +    *)     $as_echo "$as_me: WARNING: unrecognized options: $ac_unrecognized_opts" >&2 ;;
 15.1163 +  esac
 15.1164 +fi
 15.1165 +
 15.1166 +# Check all directory arguments for consistency.
 15.1167 +for ac_var in	exec_prefix prefix bindir sbindir libexecdir datarootdir \
 15.1168 +		datadir sysconfdir sharedstatedir localstatedir includedir \
 15.1169 +		oldincludedir docdir infodir htmldir dvidir pdfdir psdir \
 15.1170 +		libdir localedir mandir
 15.1171 +do
 15.1172 +  eval ac_val=\$$ac_var
 15.1173 +  # Remove trailing slashes.
 15.1174 +  case $ac_val in
 15.1175 +    */ )
 15.1176 +      ac_val=`expr "X$ac_val" : 'X\(.*[^/]\)' \| "X$ac_val" : 'X\(.*\)'`
 15.1177 +      eval $ac_var=\$ac_val;;
 15.1178 +  esac
 15.1179 +  # Be sure to have absolute directory names.
 15.1180 +  case $ac_val in
 15.1181 +    [\\/$]* | ?:[\\/]* )  continue;;
 15.1182 +    NONE | '' ) case $ac_var in *prefix ) continue;; esac;;
 15.1183 +  esac
 15.1184 +  as_fn_error "expected an absolute directory name for --$ac_var: $ac_val"
 15.1185 +done
 15.1186 +
 15.1187 +# There might be people who depend on the old broken behavior: `$host'
 15.1188 +# used to hold the argument of --host etc.
 15.1189 +# FIXME: To remove some day.
 15.1190 +build=$build_alias
 15.1191 +host=$host_alias
 15.1192 +target=$target_alias
 15.1193 +
 15.1194 +# FIXME: To remove some day.
 15.1195 +if test "x$host_alias" != x; then
 15.1196 +  if test "x$build_alias" = x; then
 15.1197 +    cross_compiling=maybe
 15.1198 +    $as_echo "$as_me: WARNING: If you wanted to set the --build type, don't use --host.
 15.1199 +    If a cross compiler is detected then cross compile mode will be used." >&2
 15.1200 +  elif test "x$build_alias" != "x$host_alias"; then
 15.1201 +    cross_compiling=yes
 15.1202 +  fi
 15.1203 +fi
 15.1204 +
 15.1205 +ac_tool_prefix=
 15.1206 +test -n "$host_alias" && ac_tool_prefix=$host_alias-
 15.1207 +
 15.1208 +test "$silent" = yes && exec 6>/dev/null
 15.1209 +
 15.1210 +
 15.1211 +ac_pwd=`pwd` && test -n "$ac_pwd" &&
 15.1212 +ac_ls_di=`ls -di .` &&
 15.1213 +ac_pwd_ls_di=`cd "$ac_pwd" && ls -di .` ||
 15.1214 +  as_fn_error "working directory cannot be determined"
 15.1215 +test "X$ac_ls_di" = "X$ac_pwd_ls_di" ||
 15.1216 +  as_fn_error "pwd does not report name of working directory"
 15.1217 +
 15.1218 +
 15.1219 +# Find the source files, if location was not specified.
 15.1220 +if test -z "$srcdir"; then
 15.1221 +  ac_srcdir_defaulted=yes
 15.1222 +  # Try the directory containing this script, then the parent directory.
 15.1223 +  ac_confdir=`$as_dirname -- "$as_myself" ||
 15.1224 +$as_expr X"$as_myself" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
 15.1225 +	 X"$as_myself" : 'X\(//\)[^/]' \| \
 15.1226 +	 X"$as_myself" : 'X\(//\)$' \| \
 15.1227 +	 X"$as_myself" : 'X\(/\)' \| . 2>/dev/null ||
 15.1228 +$as_echo X"$as_myself" |
 15.1229 +    sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{
 15.1230 +	    s//\1/
 15.1231 +	    q
 15.1232 +	  }
 15.1233 +	  /^X\(\/\/\)[^/].*/{
 15.1234 +	    s//\1/
 15.1235 +	    q
 15.1236 +	  }
 15.1237 +	  /^X\(\/\/\)$/{
 15.1238 +	    s//\1/
 15.1239 +	    q
 15.1240 +	  }
 15.1241 +	  /^X\(\/\).*/{
 15.1242 +	    s//\1/
 15.1243 +	    q
 15.1244 +	  }
 15.1245 +	  s/.*/./; q'`
 15.1246 +  srcdir=$ac_confdir
 15.1247 +  if test ! -r "$srcdir/$ac_unique_file"; then
 15.1248 +    srcdir=..
 15.1249 +  fi
 15.1250 +else
 15.1251 +  ac_srcdir_defaulted=no
 15.1252 +fi
 15.1253 +if test ! -r "$srcdir/$ac_unique_file"; then
 15.1254 +  test "$ac_srcdir_defaulted" = yes && srcdir="$ac_confdir or .."
 15.1255 +  as_fn_error "cannot find sources ($ac_unique_file) in $srcdir"
 15.1256 +fi
 15.1257 +ac_msg="sources are in $srcdir, but \`cd $srcdir' does not work"
 15.1258 +ac_abs_confdir=`(
 15.1259 +	cd "$srcdir" && test -r "./$ac_unique_file" || as_fn_error "$ac_msg"
 15.1260 +	pwd)`
 15.1261 +# When building in place, set srcdir=.
 15.1262 +if test "$ac_abs_confdir" = "$ac_pwd"; then
 15.1263 +  srcdir=.
 15.1264 +fi
 15.1265 +# Remove unnecessary trailing slashes from srcdir.
 15.1266 +# Double slashes in file names in object file debugging info
 15.1267 +# mess up M-x gdb in Emacs.
 15.1268 +case $srcdir in
 15.1269 +*/) srcdir=`expr "X$srcdir" : 'X\(.*[^/]\)' \| "X$srcdir" : 'X\(.*\)'`;;
 15.1270 +esac
 15.1271 +for ac_var in $ac_precious_vars; do
 15.1272 +  eval ac_env_${ac_var}_set=\${${ac_var}+set}
 15.1273 +  eval ac_env_${ac_var}_value=\$${ac_var}
 15.1274 +  eval ac_cv_env_${ac_var}_set=\${${ac_var}+set}
 15.1275 +  eval ac_cv_env_${ac_var}_value=\$${ac_var}
 15.1276 +done
 15.1277 +
 15.1278 +#
 15.1279 +# Report the --help message.
 15.1280 +#
 15.1281 +if test "$ac_init_help" = "long"; then
 15.1282 +  # Omit some internal or obsolete options to make the list less imposing.
 15.1283 +  # This message is too long to be a string in the A/UX 3.1 sh.
 15.1284 +  cat <<_ACEOF
 15.1285 +\`configure' configures GLPK 4.47 to adapt to many kinds of systems.
 15.1286 +
 15.1287 +Usage: $0 [OPTION]... [VAR=VALUE]...
 15.1288 +
 15.1289 +To assign environment variables (e.g., CC, CFLAGS...), specify them as
 15.1290 +VAR=VALUE.  See below for descriptions of some of the useful variables.
 15.1291 +
 15.1292 +Defaults for the options are specified in brackets.
 15.1293 +
 15.1294 +Configuration:
 15.1295 +  -h, --help              display this help and exit
 15.1296 +      --help=short        display options specific to this package
 15.1297 +      --help=recursive    display the short help of all the included packages
 15.1298 +  -V, --version           display version information and exit
 15.1299 +  -q, --quiet, --silent   do not print \`checking...' messages
 15.1300 +      --cache-file=FILE   cache test results in FILE [disabled]
 15.1301 +  -C, --config-cache      alias for \`--cache-file=config.cache'
 15.1302 +  -n, --no-create         do not create output files
 15.1303 +      --srcdir=DIR        find the sources in DIR [configure dir or \`..']
 15.1304 +
 15.1305 +Installation directories:
 15.1306 +  --prefix=PREFIX         install architecture-independent files in PREFIX
 15.1307 +                          [$ac_default_prefix]
 15.1308 +  --exec-prefix=EPREFIX   install architecture-dependent files in EPREFIX
 15.1309 +                          [PREFIX]
 15.1310 +
 15.1311 +By default, \`make install' will install all the files in
 15.1312 +\`$ac_default_prefix/bin', \`$ac_default_prefix/lib' etc.  You can specify
 15.1313 +an installation prefix other than \`$ac_default_prefix' using \`--prefix',
 15.1314 +for instance \`--prefix=\$HOME'.
 15.1315 +
 15.1316 +For better control, use the options below.
 15.1317 +
 15.1318 +Fine tuning of the installation directories:
 15.1319 +  --bindir=DIR            user executables [EPREFIX/bin]
 15.1320 +  --sbindir=DIR           system admin executables [EPREFIX/sbin]
 15.1321 +  --libexecdir=DIR        program executables [EPREFIX/libexec]
 15.1322 +  --sysconfdir=DIR        read-only single-machine data [PREFIX/etc]
 15.1323 +  --sharedstatedir=DIR    modifiable architecture-independent data [PREFIX/com]
 15.1324 +  --localstatedir=DIR     modifiable single-machine data [PREFIX/var]
 15.1325 +  --libdir=DIR            object code libraries [EPREFIX/lib]
 15.1326 +  --includedir=DIR        C header files [PREFIX/include]
 15.1327 +  --oldincludedir=DIR     C header files for non-gcc [/usr/include]
 15.1328 +  --datarootdir=DIR       read-only arch.-independent data root [PREFIX/share]
 15.1329 +  --datadir=DIR           read-only architecture-independent data [DATAROOTDIR]
 15.1330 +  --infodir=DIR           info documentation [DATAROOTDIR/info]
 15.1331 +  --localedir=DIR         locale-dependent data [DATAROOTDIR/locale]
 15.1332 +  --mandir=DIR            man documentation [DATAROOTDIR/man]
 15.1333 +  --docdir=DIR            documentation root [DATAROOTDIR/doc/glpk]
 15.1334 +  --htmldir=DIR           html documentation [DOCDIR]
 15.1335 +  --dvidir=DIR            dvi documentation [DOCDIR]
 15.1336 +  --pdfdir=DIR            pdf documentation [DOCDIR]
 15.1337 +  --psdir=DIR             ps documentation [DOCDIR]
 15.1338 +_ACEOF
 15.1339 +
 15.1340 +  cat <<\_ACEOF
 15.1341 +
 15.1342 +Program names:
 15.1343 +  --program-prefix=PREFIX            prepend PREFIX to installed program names
 15.1344 +  --program-suffix=SUFFIX            append SUFFIX to installed program names
 15.1345 +  --program-transform-name=PROGRAM   run sed PROGRAM on installed program names
 15.1346 +
 15.1347 +System types:
 15.1348 +  --build=BUILD     configure for building on BUILD [guessed]
 15.1349 +  --host=HOST       cross-compile to build programs to run on HOST [BUILD]
 15.1350 +_ACEOF
 15.1351 +fi
 15.1352 +
 15.1353 +if test -n "$ac_init_help"; then
 15.1354 +  case $ac_init_help in
 15.1355 +     short | recursive ) echo "Configuration of GLPK 4.47:";;
 15.1356 +   esac
 15.1357 +  cat <<\_ACEOF
 15.1358 +
 15.1359 +Optional Features:
 15.1360 +  --disable-option-checking  ignore unrecognized --enable/--with options
 15.1361 +  --disable-FEATURE       do not include FEATURE (same as --enable-FEATURE=no)
 15.1362 +  --enable-FEATURE[=ARG]  include FEATURE [ARG=yes]
 15.1363 +  --enable-dl             enable shared library support [[default=no]]
 15.1364 +  --enable-odbc           enable MathProg ODBC support [[default=no]]
 15.1365 +  --enable-mysql          enable MathProg MySQL support [[default=no]]
 15.1366 +  --disable-dependency-tracking  speeds up one-time build
 15.1367 +  --enable-dependency-tracking   do not reject slow dependency extractors
 15.1368 +  --enable-shared[=PKGS]  build shared libraries [default=yes]
 15.1369 +  --enable-static[=PKGS]  build static libraries [default=yes]
 15.1370 +  --enable-fast-install[=PKGS]
 15.1371 +                          optimize for fast installation [default=yes]
 15.1372 +  --disable-libtool-lock  avoid locking (might break parallel builds)
 15.1373 +
 15.1374 +Optional Packages:
 15.1375 +  --with-PACKAGE[=ARG]    use PACKAGE [ARG=yes]
 15.1376 +  --without-PACKAGE       do not use PACKAGE (same as --with-PACKAGE=no)
 15.1377 +  --with-gmp              use GNU MP bignum library [[default=no]]
 15.1378 +  --with-pic              try to use only PIC/non-PIC objects [default=use
 15.1379 +                          both]
 15.1380 +  --with-gnu-ld           assume the C compiler uses GNU ld [default=no]
 15.1381 +
 15.1382 +Some influential environment variables:
 15.1383 +  CC          C compiler command
 15.1384 +  CFLAGS      C compiler flags
 15.1385 +  LDFLAGS     linker flags, e.g. -L<lib dir> if you have libraries in a
 15.1386 +              nonstandard directory <lib dir>
 15.1387 +  LIBS        libraries to pass to the linker, e.g. -l<library>
 15.1388 +  CPPFLAGS    (Objective) C/C++ preprocessor flags, e.g. -I<include dir> if
 15.1389 +              you have headers in a nonstandard directory <include dir>
 15.1390 +  CPP         C preprocessor
 15.1391 +
 15.1392 +Use these variables to override the choices made by `configure' or to help
 15.1393 +it to find libraries and programs with nonstandard names/locations.
 15.1394 +
 15.1395 +Report bugs to <bug-glpk@gnu.org>.
 15.1396 +_ACEOF
 15.1397 +ac_status=$?
 15.1398 +fi
 15.1399 +
 15.1400 +if test "$ac_init_help" = "recursive"; then
 15.1401 +  # If there are subdirs, report their specific --help.
 15.1402 +  for ac_dir in : $ac_subdirs_all; do test "x$ac_dir" = x: && continue
 15.1403 +    test -d "$ac_dir" ||
 15.1404 +      { cd "$srcdir" && ac_pwd=`pwd` && srcdir=. && test -d "$ac_dir"; } ||
 15.1405 +      continue
 15.1406 +    ac_builddir=.
 15.1407 +
 15.1408 +case "$ac_dir" in
 15.1409 +.) ac_dir_suffix= ac_top_builddir_sub=. ac_top_build_prefix= ;;
 15.1410 +*)
 15.1411 +  ac_dir_suffix=/`$as_echo "$ac_dir" | sed 's|^\.[\\/]||'`
 15.1412 +  # A ".." for each directory in $ac_dir_suffix.
 15.1413 +  ac_top_builddir_sub=`$as_echo "$ac_dir_suffix" | sed 's|/[^\\/]*|/..|g;s|/||'`
 15.1414 +  case $ac_top_builddir_sub in
 15.1415 +  "") ac_top_builddir_sub=. ac_top_build_prefix= ;;
 15.1416 +  *)  ac_top_build_prefix=$ac_top_builddir_sub/ ;;
 15.1417 +  esac ;;
 15.1418 +esac
 15.1419 +ac_abs_top_builddir=$ac_pwd
 15.1420 +ac_abs_builddir=$ac_pwd$ac_dir_suffix
 15.1421 +# for backward compatibility:
 15.1422 +ac_top_builddir=$ac_top_build_prefix
 15.1423 +
 15.1424 +case $srcdir in
 15.1425 +  .)  # We are building in place.
 15.1426 +    ac_srcdir=.
 15.1427 +    ac_top_srcdir=$ac_top_builddir_sub
 15.1428 +    ac_abs_top_srcdir=$ac_pwd ;;
 15.1429 +  [\\/]* | ?:[\\/]* )  # Absolute name.
 15.1430 +    ac_srcdir=$srcdir$ac_dir_suffix;
 15.1431 +    ac_top_srcdir=$srcdir
 15.1432 +    ac_abs_top_srcdir=$srcdir ;;
 15.1433 +  *) # Relative name.
 15.1434 +    ac_srcdir=$ac_top_build_prefix$srcdir$ac_dir_suffix
 15.1435 +    ac_top_srcdir=$ac_top_build_prefix$srcdir
 15.1436 +    ac_abs_top_srcdir=$ac_pwd/$srcdir ;;
 15.1437 +esac
 15.1438 +ac_abs_srcdir=$ac_abs_top_srcdir$ac_dir_suffix
 15.1439 +
 15.1440 +    cd "$ac_dir" || { ac_status=$?; continue; }
 15.1441 +    # Check for guested configure.
 15.1442 +    if test -f "$ac_srcdir/configure.gnu"; then
 15.1443 +      echo &&
 15.1444 +      $SHELL "$ac_srcdir/configure.gnu" --help=recursive
 15.1445 +    elif test -f "$ac_srcdir/configure"; then
 15.1446 +      echo &&
 15.1447 +      $SHELL "$ac_srcdir/configure" --help=recursive
 15.1448 +    else
 15.1449 +      $as_echo "$as_me: WARNING: no configuration information is in $ac_dir" >&2
 15.1450 +    fi || ac_status=$?
 15.1451 +    cd "$ac_pwd" || { ac_status=$?; break; }
 15.1452 +  done
 15.1453 +fi
 15.1454 +
 15.1455 +test -n "$ac_init_help" && exit $ac_status
 15.1456 +if $ac_init_version; then
 15.1457 +  cat <<\_ACEOF
 15.1458 +GLPK configure 4.47
 15.1459 +generated by GNU Autoconf 2.65
 15.1460 +
 15.1461 +Copyright (C) 2009 Free Software Foundation, Inc.
 15.1462 +This configure script is free software; the Free Software Foundation
 15.1463 +gives unlimited permission to copy, distribute and modify it.
 15.1464 +_ACEOF
 15.1465 +  exit
 15.1466 +fi
 15.1467 +
 15.1468 +## ------------------------ ##
 15.1469 +## Autoconf initialization. ##
 15.1470 +## ------------------------ ##
 15.1471 +
 15.1472 +# ac_fn_c_try_compile LINENO
 15.1473 +# --------------------------
 15.1474 +# Try to compile conftest.$ac_ext, and return whether this succeeded.
 15.1475 +ac_fn_c_try_compile ()
 15.1476 +{
 15.1477 +  as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
 15.1478 +  rm -f conftest.$ac_objext
 15.1479 +  if { { ac_try="$ac_compile"
 15.1480 +case "(($ac_try" in
 15.1481 +  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
 15.1482 +  *) ac_try_echo=$ac_try;;
 15.1483 +esac
 15.1484 +eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
 15.1485 +$as_echo "$ac_try_echo"; } >&5
 15.1486 +  (eval "$ac_compile") 2>conftest.err
 15.1487 +  ac_status=$?
 15.1488 +  if test -s conftest.err; then
 15.1489 +    grep -v '^ *+' conftest.err >conftest.er1
 15.1490 +    cat conftest.er1 >&5
 15.1491 +    mv -f conftest.er1 conftest.err
 15.1492 +  fi
 15.1493 +  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
 15.1494 +  test $ac_status = 0; } && {
 15.1495 +	 test -z "$ac_c_werror_flag" ||
 15.1496 +	 test ! -s conftest.err
 15.1497 +       } && test -s conftest.$ac_objext; then :
 15.1498 +  ac_retval=0
 15.1499 +else
 15.1500 +  $as_echo "$as_me: failed program was:" >&5
 15.1501 +sed 's/^/| /' conftest.$ac_ext >&5
 15.1502 +
 15.1503 +	ac_retval=1
 15.1504 +fi
 15.1505 +  eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;}
 15.1506 +  as_fn_set_status $ac_retval
 15.1507 +
 15.1508 +} # ac_fn_c_try_compile
 15.1509 +
 15.1510 +# ac_fn_c_try_link LINENO
 15.1511 +# -----------------------
 15.1512 +# Try to link conftest.$ac_ext, and return whether this succeeded.
 15.1513 +ac_fn_c_try_link ()
 15.1514 +{
 15.1515 +  as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
 15.1516 +  rm -f conftest.$ac_objext conftest$ac_exeext
 15.1517 +  if { { ac_try="$ac_link"
 15.1518 +case "(($ac_try" in
 15.1519 +  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
 15.1520 +  *) ac_try_echo=$ac_try;;
 15.1521 +esac
 15.1522 +eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
 15.1523 +$as_echo "$ac_try_echo"; } >&5
 15.1524 +  (eval "$ac_link") 2>conftest.err
 15.1525 +  ac_status=$?
 15.1526 +  if test -s conftest.err; then
 15.1527 +    grep -v '^ *+' conftest.err >conftest.er1
 15.1528 +    cat conftest.er1 >&5
 15.1529 +    mv -f conftest.er1 conftest.err
 15.1530 +  fi
 15.1531 +  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
 15.1532 +  test $ac_status = 0; } && {
 15.1533 +	 test -z "$ac_c_werror_flag" ||
 15.1534 +	 test ! -s conftest.err
 15.1535 +       } && test -s conftest$ac_exeext && {
 15.1536 +	 test "$cross_compiling" = yes ||
 15.1537 +	 $as_test_x conftest$ac_exeext
 15.1538 +       }; then :
 15.1539 +  ac_retval=0
 15.1540 +else
 15.1541 +  $as_echo "$as_me: failed program was:" >&5
 15.1542 +sed 's/^/| /' conftest.$ac_ext >&5
 15.1543 +
 15.1544 +	ac_retval=1
 15.1545 +fi
 15.1546 +  # Delete the IPA/IPO (Inter Procedural Analysis/Optimization) information
 15.1547 +  # created by the PGI compiler (conftest_ipa8_conftest.oo), as it would
 15.1548 +  # interfere with the next link command; also delete a directory that is
 15.1549 +  # left behind by Apple's compiler.  We do this before executing the actions.
 15.1550 +  rm -rf conftest.dSYM conftest_ipa8_conftest.oo
 15.1551 +  eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;}
 15.1552 +  as_fn_set_status $ac_retval
 15.1553 +
 15.1554 +} # ac_fn_c_try_link
 15.1555 +
 15.1556 +# ac_fn_c_check_header_compile LINENO HEADER VAR INCLUDES
 15.1557 +# -------------------------------------------------------
 15.1558 +# Tests whether HEADER exists and can be compiled using the include files in
 15.1559 +# INCLUDES, setting the cache variable VAR accordingly.
 15.1560 +ac_fn_c_check_header_compile ()
 15.1561 +{
 15.1562 +  as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
 15.1563 +  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5
 15.1564 +$as_echo_n "checking for $2... " >&6; }
 15.1565 +if { as_var=$3; eval "test \"\${$as_var+set}\" = set"; }; then :
 15.1566 +  $as_echo_n "(cached) " >&6
 15.1567 +else
 15.1568 +  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 15.1569 +/* end confdefs.h.  */
 15.1570 +$4
 15.1571 +#include <$2>
 15.1572 +_ACEOF
 15.1573 +if ac_fn_c_try_compile "$LINENO"; then :
 15.1574 +  eval "$3=yes"
 15.1575 +else
 15.1576 +  eval "$3=no"
 15.1577 +fi
 15.1578 +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
 15.1579 +fi
 15.1580 +eval ac_res=\$$3
 15.1581 +	       { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5
 15.1582 +$as_echo "$ac_res" >&6; }
 15.1583 +  eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;}
 15.1584 +
 15.1585 +} # ac_fn_c_check_header_compile
 15.1586 +
 15.1587 +# ac_fn_c_try_cpp LINENO
 15.1588 +# ----------------------
 15.1589 +# Try to preprocess conftest.$ac_ext, and return whether this succeeded.
 15.1590 +ac_fn_c_try_cpp ()
 15.1591 +{
 15.1592 +  as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
 15.1593 +  if { { ac_try="$ac_cpp conftest.$ac_ext"
 15.1594 +case "(($ac_try" in
 15.1595 +  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
 15.1596 +  *) ac_try_echo=$ac_try;;
 15.1597 +esac
 15.1598 +eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
 15.1599 +$as_echo "$ac_try_echo"; } >&5
 15.1600 +  (eval "$ac_cpp conftest.$ac_ext") 2>conftest.err
 15.1601 +  ac_status=$?
 15.1602 +  if test -s conftest.err; then
 15.1603 +    grep -v '^ *+' conftest.err >conftest.er1
 15.1604 +    cat conftest.er1 >&5
 15.1605 +    mv -f conftest.er1 conftest.err
 15.1606 +  fi
 15.1607 +  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
 15.1608 +  test $ac_status = 0; } >/dev/null && {
 15.1609 +	 test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" ||
 15.1610 +	 test ! -s conftest.err
 15.1611 +       }; then :
 15.1612 +  ac_retval=0
 15.1613 +else
 15.1614 +  $as_echo "$as_me: failed program was:" >&5
 15.1615 +sed 's/^/| /' conftest.$ac_ext >&5
 15.1616 +
 15.1617 +    ac_retval=1
 15.1618 +fi
 15.1619 +  eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;}
 15.1620 +  as_fn_set_status $ac_retval
 15.1621 +
 15.1622 +} # ac_fn_c_try_cpp
 15.1623 +
 15.1624 +# ac_fn_c_try_run LINENO
 15.1625 +# ----------------------
 15.1626 +# Try to link conftest.$ac_ext, and return whether this succeeded. Assumes
 15.1627 +# that executables *can* be run.
 15.1628 +ac_fn_c_try_run ()
 15.1629 +{
 15.1630 +  as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
 15.1631 +  if { { ac_try="$ac_link"
 15.1632 +case "(($ac_try" in
 15.1633 +  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
 15.1634 +  *) ac_try_echo=$ac_try;;
 15.1635 +esac
 15.1636 +eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
 15.1637 +$as_echo "$ac_try_echo"; } >&5
 15.1638 +  (eval "$ac_link") 2>&5
 15.1639 +  ac_status=$?
 15.1640 +  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
 15.1641 +  test $ac_status = 0; } && { ac_try='./conftest$ac_exeext'
 15.1642 +  { { case "(($ac_try" in
 15.1643 +  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
 15.1644 +  *) ac_try_echo=$ac_try;;
 15.1645 +esac
 15.1646 +eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
 15.1647 +$as_echo "$ac_try_echo"; } >&5
 15.1648 +  (eval "$ac_try") 2>&5
 15.1649 +  ac_status=$?
 15.1650 +  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
 15.1651 +  test $ac_status = 0; }; }; then :
 15.1652 +  ac_retval=0
 15.1653 +else
 15.1654 +  $as_echo "$as_me: program exited with status $ac_status" >&5
 15.1655 +       $as_echo "$as_me: failed program was:" >&5
 15.1656 +sed 's/^/| /' conftest.$ac_ext >&5
 15.1657 +
 15.1658 +       ac_retval=$ac_status
 15.1659 +fi
 15.1660 +  rm -rf conftest.dSYM conftest_ipa8_conftest.oo
 15.1661 +  eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;}
 15.1662 +  as_fn_set_status $ac_retval
 15.1663 +
 15.1664 +} # ac_fn_c_try_run
 15.1665 +
 15.1666 +# ac_fn_c_check_func LINENO FUNC VAR
 15.1667 +# ----------------------------------
 15.1668 +# Tests whether FUNC exists, setting the cache variable VAR accordingly
 15.1669 +ac_fn_c_check_func ()
 15.1670 +{
 15.1671 +  as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
 15.1672 +  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5
 15.1673 +$as_echo_n "checking for $2... " >&6; }
 15.1674 +if { as_var=$3; eval "test \"\${$as_var+set}\" = set"; }; then :
 15.1675 +  $as_echo_n "(cached) " >&6
 15.1676 +else
 15.1677 +  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 15.1678 +/* end confdefs.h.  */
 15.1679 +/* Define $2 to an innocuous variant, in case <limits.h> declares $2.
 15.1680 +   For example, HP-UX 11i <limits.h> declares gettimeofday.  */
 15.1681 +#define $2 innocuous_$2
 15.1682 +
 15.1683 +/* System header to define __stub macros and hopefully few prototypes,
 15.1684 +    which can conflict with char $2 (); below.
 15.1685 +    Prefer <limits.h> to <assert.h> if __STDC__ is defined, since
 15.1686 +    <limits.h> exists even on freestanding compilers.  */
 15.1687 +
 15.1688 +#ifdef __STDC__
 15.1689 +# include <limits.h>
 15.1690 +#else
 15.1691 +# include <assert.h>
 15.1692 +#endif
 15.1693 +
 15.1694 +#undef $2
 15.1695 +
 15.1696 +/* Override any GCC internal prototype to avoid an error.
 15.1697 +   Use char because int might match the return type of a GCC
 15.1698 +   builtin and then its argument prototype would still apply.  */
 15.1699 +#ifdef __cplusplus
 15.1700 +extern "C"
 15.1701 +#endif
 15.1702 +char $2 ();
 15.1703 +/* The GNU C library defines this for functions which it implements
 15.1704 +    to always fail with ENOSYS.  Some functions are actually named
 15.1705 +    something starting with __ and the normal name is an alias.  */
 15.1706 +#if defined __stub_$2 || defined __stub___$2
 15.1707 +choke me
 15.1708 +#endif
 15.1709 +
 15.1710 +int
 15.1711 +main ()
 15.1712 +{
 15.1713 +return $2 ();
 15.1714 +  ;
 15.1715 +  return 0;
 15.1716 +}
 15.1717 +_ACEOF
 15.1718 +if ac_fn_c_try_link "$LINENO"; then :
 15.1719 +  eval "$3=yes"
 15.1720 +else
 15.1721 +  eval "$3=no"
 15.1722 +fi
 15.1723 +rm -f core conftest.err conftest.$ac_objext \
 15.1724 +    conftest$ac_exeext conftest.$ac_ext
 15.1725 +fi
 15.1726 +eval ac_res=\$$3
 15.1727 +	       { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5
 15.1728 +$as_echo "$ac_res" >&6; }
 15.1729 +  eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;}
 15.1730 +
 15.1731 +} # ac_fn_c_check_func
 15.1732 +
 15.1733 +# ac_fn_c_check_header_mongrel LINENO HEADER VAR INCLUDES
 15.1734 +# -------------------------------------------------------
 15.1735 +# Tests whether HEADER exists, giving a warning if it cannot be compiled using
 15.1736 +# the include files in INCLUDES and setting the cache variable VAR
 15.1737 +# accordingly.
 15.1738 +ac_fn_c_check_header_mongrel ()
 15.1739 +{
 15.1740 +  as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
 15.1741 +  if { as_var=$3; eval "test \"\${$as_var+set}\" = set"; }; then :
 15.1742 +  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5
 15.1743 +$as_echo_n "checking for $2... " >&6; }
 15.1744 +if { as_var=$3; eval "test \"\${$as_var+set}\" = set"; }; then :
 15.1745 +  $as_echo_n "(cached) " >&6
 15.1746 +fi
 15.1747 +eval ac_res=\$$3
 15.1748 +	       { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5
 15.1749 +$as_echo "$ac_res" >&6; }
 15.1750 +else
 15.1751 +  # Is the header compilable?
 15.1752 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking $2 usability" >&5
 15.1753 +$as_echo_n "checking $2 usability... " >&6; }
 15.1754 +cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 15.1755 +/* end confdefs.h.  */
 15.1756 +$4
 15.1757 +#include <$2>
 15.1758 +_ACEOF
 15.1759 +if ac_fn_c_try_compile "$LINENO"; then :
 15.1760 +  ac_header_compiler=yes
 15.1761 +else
 15.1762 +  ac_header_compiler=no
 15.1763 +fi
 15.1764 +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
 15.1765 +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_header_compiler" >&5
 15.1766 +$as_echo "$ac_header_compiler" >&6; }
 15.1767 +
 15.1768 +# Is the header present?
 15.1769 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking $2 presence" >&5
 15.1770 +$as_echo_n "checking $2 presence... " >&6; }
 15.1771 +cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 15.1772 +/* end confdefs.h.  */
 15.1773 +#include <$2>
 15.1774 +_ACEOF
 15.1775 +if ac_fn_c_try_cpp "$LINENO"; then :
 15.1776 +  ac_header_preproc=yes
 15.1777 +else
 15.1778 +  ac_header_preproc=no
 15.1779 +fi
 15.1780 +rm -f conftest.err conftest.$ac_ext
 15.1781 +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_header_preproc" >&5
 15.1782 +$as_echo "$ac_header_preproc" >&6; }
 15.1783 +
 15.1784 +# So?  What about this header?
 15.1785 +case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in #((
 15.1786 +  yes:no: )
 15.1787 +    { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: accepted by the compiler, rejected by the preprocessor!" >&5
 15.1788 +$as_echo "$as_me: WARNING: $2: accepted by the compiler, rejected by the preprocessor!" >&2;}
 15.1789 +    { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: proceeding with the compiler's result" >&5
 15.1790 +$as_echo "$as_me: WARNING: $2: proceeding with the compiler's result" >&2;}
 15.1791 +    ;;
 15.1792 +  no:yes:* )
 15.1793 +    { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: present but cannot be compiled" >&5
 15.1794 +$as_echo "$as_me: WARNING: $2: present but cannot be compiled" >&2;}
 15.1795 +    { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2:     check for missing prerequisite headers?" >&5
 15.1796 +$as_echo "$as_me: WARNING: $2:     check for missing prerequisite headers?" >&2;}
 15.1797 +    { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: see the Autoconf documentation" >&5
 15.1798 +$as_echo "$as_me: WARNING: $2: see the Autoconf documentation" >&2;}
 15.1799 +    { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2:     section \"Present But Cannot Be Compiled\"" >&5
 15.1800 +$as_echo "$as_me: WARNING: $2:     section \"Present But Cannot Be Compiled\"" >&2;}
 15.1801 +    { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: proceeding with the compiler's result" >&5
 15.1802 +$as_echo "$as_me: WARNING: $2: proceeding with the compiler's result" >&2;}
 15.1803 +( cat <<\_ASBOX
 15.1804 +## ------------------------------- ##
 15.1805 +## Report this to bug-glpk@gnu.org ##
 15.1806 +## ------------------------------- ##
 15.1807 +_ASBOX
 15.1808 +     ) | sed "s/^/$as_me: WARNING:     /" >&2
 15.1809 +    ;;
 15.1810 +esac
 15.1811 +  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5
 15.1812 +$as_echo_n "checking for $2... " >&6; }
 15.1813 +if { as_var=$3; eval "test \"\${$as_var+set}\" = set"; }; then :
 15.1814 +  $as_echo_n "(cached) " >&6
 15.1815 +else
 15.1816 +  eval "$3=\$ac_header_compiler"
 15.1817 +fi
 15.1818 +eval ac_res=\$$3
 15.1819 +	       { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5
 15.1820 +$as_echo "$ac_res" >&6; }
 15.1821 +fi
 15.1822 +  eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;}
 15.1823 +
 15.1824 +} # ac_fn_c_check_header_mongrel
 15.1825 +cat >config.log <<_ACEOF
 15.1826 +This file contains any messages produced by compilers while
 15.1827 +running configure, to aid debugging if configure makes a mistake.
 15.1828 +
 15.1829 +It was created by GLPK $as_me 4.47, which was
 15.1830 +generated by GNU Autoconf 2.65.  Invocation command line was
 15.1831 +
 15.1832 +  $ $0 $@
 15.1833 +
 15.1834 +_ACEOF
 15.1835 +exec 5>>config.log
 15.1836 +{
 15.1837 +cat <<_ASUNAME
 15.1838 +## --------- ##
 15.1839 +## Platform. ##
 15.1840 +## --------- ##
 15.1841 +
 15.1842 +hostname = `(hostname || uname -n) 2>/dev/null | sed 1q`
 15.1843 +uname -m = `(uname -m) 2>/dev/null || echo unknown`
 15.1844 +uname -r = `(uname -r) 2>/dev/null || echo unknown`
 15.1845 +uname -s = `(uname -s) 2>/dev/null || echo unknown`
 15.1846 +uname -v = `(uname -v) 2>/dev/null || echo unknown`
 15.1847 +
 15.1848 +/usr/bin/uname -p = `(/usr/bin/uname -p) 2>/dev/null || echo unknown`
 15.1849 +/bin/uname -X     = `(/bin/uname -X) 2>/dev/null     || echo unknown`
 15.1850 +
 15.1851 +/bin/arch              = `(/bin/arch) 2>/dev/null              || echo unknown`
 15.1852 +/usr/bin/arch -k       = `(/usr/bin/arch -k) 2>/dev/null       || echo unknown`
 15.1853 +/usr/convex/getsysinfo = `(/usr/convex/getsysinfo) 2>/dev/null || echo unknown`
 15.1854 +/usr/bin/hostinfo      = `(/usr/bin/hostinfo) 2>/dev/null      || echo unknown`
 15.1855 +/bin/machine           = `(/bin/machine) 2>/dev/null           || echo unknown`
 15.1856 +/usr/bin/oslevel       = `(/usr/bin/oslevel) 2>/dev/null       || echo unknown`
 15.1857 +/bin/universe          = `(/bin/universe) 2>/dev/null          || echo unknown`
 15.1858 +
 15.1859 +_ASUNAME
 15.1860 +
 15.1861 +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
 15.1862 +for as_dir in $PATH
 15.1863 +do
 15.1864 +  IFS=$as_save_IFS
 15.1865 +  test -z "$as_dir" && as_dir=.
 15.1866 +    $as_echo "PATH: $as_dir"
 15.1867 +  done
 15.1868 +IFS=$as_save_IFS
 15.1869 +
 15.1870 +} >&5
 15.1871 +
 15.1872 +cat >&5 <<_ACEOF
 15.1873 +
 15.1874 +
 15.1875 +## ----------- ##
 15.1876 +## Core tests. ##
 15.1877 +## ----------- ##
 15.1878 +
 15.1879 +_ACEOF
 15.1880 +
 15.1881 +
 15.1882 +# Keep a trace of the command line.
 15.1883 +# Strip out --no-create and --no-recursion so they do not pile up.
 15.1884 +# Strip out --silent because we don't want to record it for future runs.
 15.1885 +# Also quote any args containing shell meta-characters.
 15.1886 +# Make two passes to allow for proper duplicate-argument suppression.
 15.1887 +ac_configure_args=
 15.1888 +ac_configure_args0=
 15.1889 +ac_configure_args1=
 15.1890 +ac_must_keep_next=false
 15.1891 +for ac_pass in 1 2
 15.1892 +do
 15.1893 +  for ac_arg
 15.1894 +  do
 15.1895 +    case $ac_arg in
 15.1896 +    -no-create | --no-c* | -n | -no-recursion | --no-r*) continue ;;
 15.1897 +    -q | -quiet | --quiet | --quie | --qui | --qu | --q \
 15.1898 +    | -silent | --silent | --silen | --sile | --sil)
 15.1899 +      continue ;;
 15.1900 +    *\'*)
 15.1901 +      ac_arg=`$as_echo "$ac_arg" | sed "s/'/'\\\\\\\\''/g"` ;;
 15.1902 +    esac
 15.1903 +    case $ac_pass in
 15.1904 +    1) as_fn_append ac_configure_args0 " '$ac_arg'" ;;
 15.1905 +    2)
 15.1906 +      as_fn_append ac_configure_args1 " '$ac_arg'"
 15.1907 +      if test $ac_must_keep_next = true; then
 15.1908 +	ac_must_keep_next=false # Got value, back to normal.
 15.1909 +      else
 15.1910 +	case $ac_arg in
 15.1911 +	  *=* | --config-cache | -C | -disable-* | --disable-* \
 15.1912 +	  | -enable-* | --enable-* | -gas | --g* | -nfp | --nf* \
 15.1913 +	  | -q | -quiet | --q* | -silent | --sil* | -v | -verb* \
 15.1914 +	  | -with-* | --with-* | -without-* | --without-* | --x)
 15.1915 +	    case "$ac_configure_args0 " in
 15.1916 +	      "$ac_configure_args1"*" '$ac_arg' "* ) continue ;;
 15.1917 +	    esac
 15.1918 +	    ;;
 15.1919 +	  -* ) ac_must_keep_next=true ;;
 15.1920 +	esac
 15.1921 +      fi
 15.1922 +      as_fn_append ac_configure_args " '$ac_arg'"
 15.1923 +      ;;
 15.1924 +    esac
 15.1925 +  done
 15.1926 +done
 15.1927 +{ ac_configure_args0=; unset ac_configure_args0;}
 15.1928 +{ ac_configure_args1=; unset ac_configure_args1;}
 15.1929 +
 15.1930 +# When interrupted or exit'd, cleanup temporary files, and complete
 15.1931 +# config.log.  We remove comments because anyway the quotes in there
 15.1932 +# would cause problems or look ugly.
 15.1933 +# WARNING: Use '\'' to represent an apostrophe within the trap.
 15.1934 +# WARNING: Do not start the trap code with a newline, due to a FreeBSD 4.0 bug.
 15.1935 +trap 'exit_status=$?
 15.1936 +  # Save into config.log some information that might help in debugging.
 15.1937 +  {
 15.1938 +    echo
 15.1939 +
 15.1940 +    cat <<\_ASBOX
 15.1941 +## ---------------- ##
 15.1942 +## Cache variables. ##
 15.1943 +## ---------------- ##
 15.1944 +_ASBOX
 15.1945 +    echo
 15.1946 +    # The following way of writing the cache mishandles newlines in values,
 15.1947 +(
 15.1948 +  for ac_var in `(set) 2>&1 | sed -n '\''s/^\([a-zA-Z_][a-zA-Z0-9_]*\)=.*/\1/p'\''`; do
 15.1949 +    eval ac_val=\$$ac_var
 15.1950 +    case $ac_val in #(
 15.1951 +    *${as_nl}*)
 15.1952 +      case $ac_var in #(
 15.1953 +      *_cv_*) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: cache variable $ac_var contains a newline" >&5
 15.1954 +$as_echo "$as_me: WARNING: cache variable $ac_var contains a newline" >&2;} ;;
 15.1955 +      esac
 15.1956 +      case $ac_var in #(
 15.1957 +      _ | IFS | as_nl) ;; #(
 15.1958 +      BASH_ARGV | BASH_SOURCE) eval $ac_var= ;; #(
 15.1959 +      *) { eval $ac_var=; unset $ac_var;} ;;
 15.1960 +      esac ;;
 15.1961 +    esac
 15.1962 +  done
 15.1963 +  (set) 2>&1 |
 15.1964 +    case $as_nl`(ac_space='\'' '\''; set) 2>&1` in #(
 15.1965 +    *${as_nl}ac_space=\ *)
 15.1966 +      sed -n \
 15.1967 +	"s/'\''/'\''\\\\'\'''\''/g;
 15.1968 +	  s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1='\''\\2'\''/p"
 15.1969 +      ;; #(
 15.1970 +    *)
 15.1971 +      sed -n "/^[_$as_cr_alnum]*_cv_[_$as_cr_alnum]*=/p"
 15.1972 +      ;;
 15.1973 +    esac |
 15.1974 +    sort
 15.1975 +)
 15.1976 +    echo
 15.1977 +
 15.1978 +    cat <<\_ASBOX
 15.1979 +## ----------------- ##
 15.1980 +## Output variables. ##
 15.1981 +## ----------------- ##
 15.1982 +_ASBOX
 15.1983 +    echo
 15.1984 +    for ac_var in $ac_subst_vars
 15.1985 +    do
 15.1986 +      eval ac_val=\$$ac_var
 15.1987 +      case $ac_val in
 15.1988 +      *\'\''*) ac_val=`$as_echo "$ac_val" | sed "s/'\''/'\''\\\\\\\\'\'''\''/g"`;;
 15.1989 +      esac
 15.1990 +      $as_echo "$ac_var='\''$ac_val'\''"
 15.1991 +    done | sort
 15.1992 +    echo
 15.1993 +
 15.1994 +    if test -n "$ac_subst_files"; then
 15.1995 +      cat <<\_ASBOX
 15.1996 +## ------------------- ##
 15.1997 +## File substitutions. ##
 15.1998 +## ------------------- ##
 15.1999 +_ASBOX
 15.2000 +      echo
 15.2001 +      for ac_var in $ac_subst_files
 15.2002 +      do
 15.2003 +	eval ac_val=\$$ac_var
 15.2004 +	case $ac_val in
 15.2005 +	*\'\''*) ac_val=`$as_echo "$ac_val" | sed "s/'\''/'\''\\\\\\\\'\'''\''/g"`;;
 15.2006 +	esac
 15.2007 +	$as_echo "$ac_var='\''$ac_val'\''"
 15.2008 +      done | sort
 15.2009 +      echo
 15.2010 +    fi
 15.2011 +
 15.2012 +    if test -s confdefs.h; then
 15.2013 +      cat <<\_ASBOX
 15.2014 +## ----------- ##
 15.2015 +## confdefs.h. ##
 15.2016 +## ----------- ##
 15.2017 +_ASBOX
 15.2018 +      echo
 15.2019 +      cat confdefs.h
 15.2020 +      echo
 15.2021 +    fi
 15.2022 +    test "$ac_signal" != 0 &&
 15.2023 +      $as_echo "$as_me: caught signal $ac_signal"
 15.2024 +    $as_echo "$as_me: exit $exit_status"
 15.2025 +  } >&5
 15.2026 +  rm -f core *.core core.conftest.* &&
 15.2027 +    rm -f -r conftest* confdefs* conf$$* $ac_clean_files &&
 15.2028 +    exit $exit_status
 15.2029 +' 0
 15.2030 +for ac_signal in 1 2 13 15; do
 15.2031 +  trap 'ac_signal='$ac_signal'; as_fn_exit 1' $ac_signal
 15.2032 +done
 15.2033 +ac_signal=0
 15.2034 +
 15.2035 +# confdefs.h avoids OS command line length limits that DEFS can exceed.
 15.2036 +rm -f -r conftest* confdefs.h
 15.2037 +
 15.2038 +$as_echo "/* confdefs.h */" > confdefs.h
 15.2039 +
 15.2040 +# Predefined preprocessor variables.
 15.2041 +
 15.2042 +cat >>confdefs.h <<_ACEOF
 15.2043 +#define PACKAGE_NAME "$PACKAGE_NAME"
 15.2044 +_ACEOF
 15.2045 +
 15.2046 +cat >>confdefs.h <<_ACEOF
 15.2047 +#define PACKAGE_TARNAME "$PACKAGE_TARNAME"
 15.2048 +_ACEOF
 15.2049 +
 15.2050 +cat >>confdefs.h <<_ACEOF
 15.2051 +#define PACKAGE_VERSION "$PACKAGE_VERSION"
 15.2052 +_ACEOF
 15.2053 +
 15.2054 +cat >>confdefs.h <<_ACEOF
 15.2055 +#define PACKAGE_STRING "$PACKAGE_STRING"
 15.2056 +_ACEOF
 15.2057 +
 15.2058 +cat >>confdefs.h <<_ACEOF
 15.2059 +#define PACKAGE_BUGREPORT "$PACKAGE_BUGREPORT"
 15.2060 +_ACEOF
 15.2061 +
 15.2062 +cat >>confdefs.h <<_ACEOF
 15.2063 +#define PACKAGE_URL "$PACKAGE_URL"
 15.2064 +_ACEOF
 15.2065 +
 15.2066 +
 15.2067 +# Let the site file select an alternate cache file if it wants to.
 15.2068 +# Prefer an explicitly selected file to automatically selected ones.
 15.2069 +ac_site_file1=NONE
 15.2070 +ac_site_file2=NONE
 15.2071 +if test -n "$CONFIG_SITE"; then
 15.2072 +  ac_site_file1=$CONFIG_SITE
 15.2073 +elif test "x$prefix" != xNONE; then
 15.2074 +  ac_site_file1=$prefix/share/config.site
 15.2075 +  ac_site_file2=$prefix/etc/config.site
 15.2076 +else
 15.2077 +  ac_site_file1=$ac_default_prefix/share/config.site
 15.2078 +  ac_site_file2=$ac_default_prefix/etc/config.site
 15.2079 +fi
 15.2080 +for ac_site_file in "$ac_site_file1" "$ac_site_file2"
 15.2081 +do
 15.2082 +  test "x$ac_site_file" = xNONE && continue
 15.2083 +  if test /dev/null != "$ac_site_file" && test -r "$ac_site_file"; then
 15.2084 +    { $as_echo "$as_me:${as_lineno-$LINENO}: loading site script $ac_site_file" >&5
 15.2085 +$as_echo "$as_me: loading site script $ac_site_file" >&6;}
 15.2086 +    sed 's/^/| /' "$ac_site_file" >&5
 15.2087 +    . "$ac_site_file"
 15.2088 +  fi
 15.2089 +done
 15.2090 +
 15.2091 +if test -r "$cache_file"; then
 15.2092 +  # Some versions of bash will fail to source /dev/null (special files
 15.2093 +  # actually), so we avoid doing that.  DJGPP emulates it as a regular file.
 15.2094 +  if test /dev/null != "$cache_file" && test -f "$cache_file"; then
 15.2095 +    { $as_echo "$as_me:${as_lineno-$LINENO}: loading cache $cache_file" >&5
 15.2096 +$as_echo "$as_me: loading cache $cache_file" >&6;}
 15.2097 +    case $cache_file in
 15.2098 +      [\\/]* | ?:[\\/]* ) . "$cache_file";;
 15.2099 +      *)                      . "./$cache_file";;
 15.2100 +    esac
 15.2101 +  fi
 15.2102 +else
 15.2103 +  { $as_echo "$as_me:${as_lineno-$LINENO}: creating cache $cache_file" >&5
 15.2104 +$as_echo "$as_me: creating cache $cache_file" >&6;}
 15.2105 +  >$cache_file
 15.2106 +fi
 15.2107 +
 15.2108 +# Check that the precious variables saved in the cache have kept the same
 15.2109 +# value.
 15.2110 +ac_cache_corrupted=false
 15.2111 +for ac_var in $ac_precious_vars; do
 15.2112 +  eval ac_old_set=\$ac_cv_env_${ac_var}_set
 15.2113 +  eval ac_new_set=\$ac_env_${ac_var}_set
 15.2114 +  eval ac_old_val=\$ac_cv_env_${ac_var}_value
 15.2115 +  eval ac_new_val=\$ac_env_${ac_var}_value
 15.2116 +  case $ac_old_set,$ac_new_set in
 15.2117 +    set,)
 15.2118 +      { $as_echo "$as_me:${as_lineno-$LINENO}: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&5
 15.2119 +$as_echo "$as_me: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&2;}
 15.2120 +      ac_cache_corrupted=: ;;
 15.2121 +    ,set)
 15.2122 +      { $as_echo "$as_me:${as_lineno-$LINENO}: error: \`$ac_var' was not set in the previous run" >&5
 15.2123 +$as_echo "$as_me: error: \`$ac_var' was not set in the previous run" >&2;}
 15.2124 +      ac_cache_corrupted=: ;;
 15.2125 +    ,);;
 15.2126 +    *)
 15.2127 +      if test "x$ac_old_val" != "x$ac_new_val"; then
 15.2128 +	# differences in whitespace do not lead to failure.
 15.2129 +	ac_old_val_w=`echo x $ac_old_val`
 15.2130 +	ac_new_val_w=`echo x $ac_new_val`
 15.2131 +	if test "$ac_old_val_w" != "$ac_new_val_w"; then
 15.2132 +	  { $as_echo "$as_me:${as_lineno-$LINENO}: error: \`$ac_var' has changed since the previous run:" >&5
 15.2133 +$as_echo "$as_me: error: \`$ac_var' has changed since the previous run:" >&2;}
 15.2134 +	  ac_cache_corrupted=:
 15.2135 +	else
 15.2136 +	  { $as_echo "$as_me:${as_lineno-$LINENO}: warning: ignoring whitespace changes in \`$ac_var' since the previous run:" >&5
 15.2137 +$as_echo "$as_me: warning: ignoring whitespace changes in \`$ac_var' since the previous run:" >&2;}
 15.2138 +	  eval $ac_var=\$ac_old_val
 15.2139 +	fi
 15.2140 +	{ $as_echo "$as_me:${as_lineno-$LINENO}:   former value:  \`$ac_old_val'" >&5
 15.2141 +$as_echo "$as_me:   former value:  \`$ac_old_val'" >&2;}
 15.2142 +	{ $as_echo "$as_me:${as_lineno-$LINENO}:   current value: \`$ac_new_val'" >&5
 15.2143 +$as_echo "$as_me:   current value: \`$ac_new_val'" >&2;}
 15.2144 +      fi;;
 15.2145 +  esac
 15.2146 +  # Pass precious variables to config.status.
 15.2147 +  if test "$ac_new_set" = set; then
 15.2148 +    case $ac_new_val in
 15.2149 +    *\'*) ac_arg=$ac_var=`$as_echo "$ac_new_val" | sed "s/'/'\\\\\\\\''/g"` ;;
 15.2150 +    *) ac_arg=$ac_var=$ac_new_val ;;
 15.2151 +    esac
 15.2152 +    case " $ac_configure_args " in
 15.2153 +      *" '$ac_arg' "*) ;; # Avoid dups.  Use of quotes ensures accuracy.
 15.2154 +      *) as_fn_append ac_configure_args " '$ac_arg'" ;;
 15.2155 +    esac
 15.2156 +  fi
 15.2157 +done
 15.2158 +if $ac_cache_corrupted; then
 15.2159 +  { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
 15.2160 +$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
 15.2161 +  { $as_echo "$as_me:${as_lineno-$LINENO}: error: changes in the environment can compromise the build" >&5
 15.2162 +$as_echo "$as_me: error: changes in the environment can compromise the build" >&2;}
 15.2163 +  as_fn_error "run \`make distclean' and/or \`rm $cache_file' and start over" "$LINENO" 5
 15.2164 +fi
 15.2165 +## -------------------- ##
 15.2166 +## Main body of script. ##
 15.2167 +## -------------------- ##
 15.2168 +
 15.2169 +ac_ext=c
 15.2170 +ac_cpp='$CPP $CPPFLAGS'
 15.2171 +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
 15.2172 +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
 15.2173 +ac_compiler_gnu=$ac_cv_c_compiler_gnu
 15.2174 +
 15.2175 +
 15.2176 +
 15.2177 +
 15.2178 +
 15.2179 +
 15.2180 +
 15.2181 +am__api_version='1.11'
 15.2182 +
 15.2183 +ac_aux_dir=
 15.2184 +for ac_dir in "$srcdir" "$srcdir/.." "$srcdir/../.."; do
 15.2185 +  for ac_t in install-sh install.sh shtool; do
 15.2186 +    if test -f "$ac_dir/$ac_t"; then
 15.2187 +      ac_aux_dir=$ac_dir
 15.2188 +      ac_install_sh="$ac_aux_dir/$ac_t -c"
 15.2189 +      break 2
 15.2190 +    fi
 15.2191 +  done
 15.2192 +done
 15.2193 +if test -z "$ac_aux_dir"; then
 15.2194 +  as_fn_error "cannot find install-sh, install.sh, or shtool in \"$srcdir\" \"$srcdir/..\" \"$srcdir/../..\"" "$LINENO" 5
 15.2195 +fi
 15.2196 +
 15.2197 +# These three variables are undocumented and unsupported,
 15.2198 +# and are intended to be withdrawn in a future Autoconf release.
 15.2199 +# They can cause serious problems if a builder's source tree is in a directory
 15.2200 +# whose full name contains unusual characters.
 15.2201 +ac_config_guess="$SHELL $ac_aux_dir/config.guess"  # Please don't use this var.
 15.2202 +ac_config_sub="$SHELL $ac_aux_dir/config.sub"  # Please don't use this var.
 15.2203 +ac_configure="$SHELL $ac_aux_dir/configure"  # Please don't use this var.
 15.2204 +
 15.2205 +
 15.2206 +# Find a good install program.  We prefer a C program (faster),
 15.2207 +# so one script is as good as another.  But avoid the broken or
 15.2208 +# incompatible versions:
 15.2209 +# SysV /etc/install, /usr/sbin/install
 15.2210 +# SunOS /usr/etc/install
 15.2211 +# IRIX /sbin/install
 15.2212 +# AIX /bin/install
 15.2213 +# AmigaOS /C/install, which installs bootblocks on floppy discs
 15.2214 +# AIX 4 /usr/bin/installbsd, which doesn't work without a -g flag
 15.2215 +# AFS /usr/afsws/bin/install, which mishandles nonexistent args
 15.2216 +# SVR4 /usr/ucb/install, which tries to use the nonexistent group "staff"
 15.2217 +# OS/2's system install, which has a completely different semantic
 15.2218 +# ./install, which can be erroneously created by make from ./install.sh.
 15.2219 +# Reject install programs that cannot install multiple files.
 15.2220 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for a BSD-compatible install" >&5
 15.2221 +$as_echo_n "checking for a BSD-compatible install... " >&6; }
 15.2222 +if test -z "$INSTALL"; then
 15.2223 +if test "${ac_cv_path_install+set}" = set; then :
 15.2224 +  $as_echo_n "(cached) " >&6
 15.2225 +else
 15.2226 +  as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
 15.2227 +for as_dir in $PATH
 15.2228 +do
 15.2229 +  IFS=$as_save_IFS
 15.2230 +  test -z "$as_dir" && as_dir=.
 15.2231 +    # Account for people who put trailing slashes in PATH elements.
 15.2232 +case $as_dir/ in #((
 15.2233 +  ./ | .// | /[cC]/* | \
 15.2234 +  /etc/* | /usr/sbin/* | /usr/etc/* | /sbin/* | /usr/afsws/bin/* | \
 15.2235 +  ?:[\\/]os2[\\/]install[\\/]* | ?:[\\/]OS2[\\/]INSTALL[\\/]* | \
 15.2236 +  /usr/ucb/* ) ;;
 15.2237 +  *)
 15.2238 +    # OSF1 and SCO ODT 3.0 have their own names for install.
 15.2239 +    # Don't use installbsd from OSF since it installs stuff as root
 15.2240 +    # by default.
 15.2241 +    for ac_prog in ginstall scoinst install; do
 15.2242 +      for ac_exec_ext in '' $ac_executable_extensions; do
 15.2243 +	if { test -f "$as_dir/$ac_prog$ac_exec_ext" && $as_test_x "$as_dir/$ac_prog$ac_exec_ext"; }; then
 15.2244 +	  if test $ac_prog = install &&
 15.2245 +	    grep dspmsg "$as_dir/$ac_prog$ac_exec_ext" >/dev/null 2>&1; then
 15.2246 +	    # AIX install.  It has an incompatible calling convention.
 15.2247 +	    :
 15.2248 +	  elif test $ac_prog = install &&
 15.2249 +	    grep pwplus "$as_dir/$ac_prog$ac_exec_ext" >/dev/null 2>&1; then
 15.2250 +	    # program-specific install script used by HP pwplus--don't use.
 15.2251 +	    :
 15.2252 +	  else
 15.2253 +	    rm -rf conftest.one conftest.two conftest.dir
 15.2254 +	    echo one > conftest.one
 15.2255 +	    echo two > conftest.two
 15.2256 +	    mkdir conftest.dir
 15.2257 +	    if "$as_dir/$ac_prog$ac_exec_ext" -c conftest.one conftest.two "`pwd`/conftest.dir" &&
 15.2258 +	      test -s conftest.one && test -s conftest.two &&
 15.2259 +	      test -s conftest.dir/conftest.one &&
 15.2260 +	      test -s conftest.dir/conftest.two
 15.2261 +	    then
 15.2262 +	      ac_cv_path_install="$as_dir/$ac_prog$ac_exec_ext -c"
 15.2263 +	      break 3
 15.2264 +	    fi
 15.2265 +	  fi
 15.2266 +	fi
 15.2267 +      done
 15.2268 +    done
 15.2269 +    ;;
 15.2270 +esac
 15.2271 +
 15.2272 +  done
 15.2273 +IFS=$as_save_IFS
 15.2274 +
 15.2275 +rm -rf conftest.one conftest.two conftest.dir
 15.2276 +
 15.2277 +fi
 15.2278 +  if test "${ac_cv_path_install+set}" = set; then
 15.2279 +    INSTALL=$ac_cv_path_install
 15.2280 +  else
 15.2281 +    # As a last resort, use the slow shell script.  Don't cache a
 15.2282 +    # value for INSTALL within a source directory, because that will
 15.2283 +    # break other packages using the cache if that directory is
 15.2284 +    # removed, or if the value is a relative name.
 15.2285 +    INSTALL=$ac_install_sh
 15.2286 +  fi
 15.2287 +fi
 15.2288 +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $INSTALL" >&5
 15.2289 +$as_echo "$INSTALL" >&6; }
 15.2290 +
 15.2291 +# Use test -z because SunOS4 sh mishandles braces in ${var-val}.
 15.2292 +# It thinks the first close brace ends the variable substitution.
 15.2293 +test -z "$INSTALL_PROGRAM" && INSTALL_PROGRAM='${INSTALL}'
 15.2294 +
 15.2295 +test -z "$INSTALL_SCRIPT" && INSTALL_SCRIPT='${INSTALL}'
 15.2296 +
 15.2297 +test -z "$INSTALL_DATA" && INSTALL_DATA='${INSTALL} -m 644'
 15.2298 +
 15.2299 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether build environment is sane" >&5
 15.2300 +$as_echo_n "checking whether build environment is sane... " >&6; }
 15.2301 +# Just in case
 15.2302 +sleep 1
 15.2303 +echo timestamp > conftest.file
 15.2304 +# Reject unsafe characters in $srcdir or the absolute working directory
 15.2305 +# name.  Accept space and tab only in the latter.
 15.2306 +am_lf='
 15.2307 +'
 15.2308 +case `pwd` in
 15.2309 +  *[\\\"\#\$\&\'\`$am_lf]*)
 15.2310 +    as_fn_error "unsafe absolute working directory name" "$LINENO" 5;;
 15.2311 +esac
 15.2312 +case $srcdir in
 15.2313 +  *[\\\"\#\$\&\'\`$am_lf\ \	]*)
 15.2314 +    as_fn_error "unsafe srcdir value: \`$srcdir'" "$LINENO" 5;;
 15.2315 +esac
 15.2316 +
 15.2317 +# Do `set' in a subshell so we don't clobber the current shell's
 15.2318 +# arguments.  Must try -L first in case configure is actually a
 15.2319 +# symlink; some systems play weird games with the mod time of symlinks
 15.2320 +# (eg FreeBSD returns the mod time of the symlink's containing
 15.2321 +# directory).
 15.2322 +if (
 15.2323 +   set X `ls -Lt "$srcdir/configure" conftest.file 2> /dev/null`
 15.2324 +   if test "$*" = "X"; then
 15.2325 +      # -L didn't work.
 15.2326 +      set X `ls -t "$srcdir/configure" conftest.file`
 15.2327 +   fi
 15.2328 +   rm -f conftest.file
 15.2329 +   if test "$*" != "X $srcdir/configure conftest.file" \
 15.2330 +      && test "$*" != "X conftest.file $srcdir/configure"; then
 15.2331 +
 15.2332 +      # If neither matched, then we have a broken ls.  This can happen
 15.2333 +      # if, for instance, CONFIG_SHELL is bash and it inherits a
 15.2334 +      # broken ls alias from the environment.  This has actually
 15.2335 +      # happened.  Such a system could not be considered "sane".
 15.2336 +      as_fn_error "ls -t appears to fail.  Make sure there is not a broken
 15.2337 +alias in your environment" "$LINENO" 5
 15.2338 +   fi
 15.2339 +
 15.2340 +   test "$2" = conftest.file
 15.2341 +   )
 15.2342 +then
 15.2343 +   # Ok.
 15.2344 +   :
 15.2345 +else
 15.2346 +   as_fn_error "newly created file is older than distributed files!
 15.2347 +Check your system clock" "$LINENO" 5
 15.2348 +fi
 15.2349 +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
 15.2350 +$as_echo "yes" >&6; }
 15.2351 +test "$program_prefix" != NONE &&
 15.2352 +  program_transform_name="s&^&$program_prefix&;$program_transform_name"
 15.2353 +# Use a double $ so make ignores it.
 15.2354 +test "$program_suffix" != NONE &&
 15.2355 +  program_transform_name="s&\$&$program_suffix&;$program_transform_name"
 15.2356 +# Double any \ or $.
 15.2357 +# By default was `s,x,x', remove it if useless.
 15.2358 +ac_script='s/[\\$]/&&/g;s/;s,x,x,$//'
 15.2359 +program_transform_name=`$as_echo "$program_transform_name" | sed "$ac_script"`
 15.2360 +
 15.2361 +# expand $ac_aux_dir to an absolute path
 15.2362 +am_aux_dir=`cd $ac_aux_dir && pwd`
 15.2363 +
 15.2364 +if test x"${MISSING+set}" != xset; then
 15.2365 +  case $am_aux_dir in
 15.2366 +  *\ * | *\	*)
 15.2367 +    MISSING="\${SHELL} \"$am_aux_dir/missing\"" ;;
 15.2368 +  *)
 15.2369 +    MISSING="\${SHELL} $am_aux_dir/missing" ;;
 15.2370 +  esac
 15.2371 +fi
 15.2372 +# Use eval to expand $SHELL
 15.2373 +if eval "$MISSING --run true"; then
 15.2374 +  am_missing_run="$MISSING --run "
 15.2375 +else
 15.2376 +  am_missing_run=
 15.2377 +  { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: \`missing' script is too old or missing" >&5
 15.2378 +$as_echo "$as_me: WARNING: \`missing' script is too old or missing" >&2;}
 15.2379 +fi
 15.2380 +
 15.2381 +if test x"${install_sh}" != xset; then
 15.2382 +  case $am_aux_dir in
 15.2383 +  *\ * | *\	*)
 15.2384 +    install_sh="\${SHELL} '$am_aux_dir/install-sh'" ;;
 15.2385 +  *)
 15.2386 +    install_sh="\${SHELL} $am_aux_dir/install-sh"
 15.2387 +  esac
 15.2388 +fi
 15.2389 +
 15.2390 +# Installed binaries are usually stripped using `strip' when the user
 15.2391 +# run `make install-strip'.  However `strip' might not be the right
 15.2392 +# tool to use in cross-compilation environments, therefore Automake
 15.2393 +# will honor the `STRIP' environment variable to overrule this program.
 15.2394 +if test "$cross_compiling" != no; then
 15.2395 +  if test -n "$ac_tool_prefix"; then
 15.2396 +  # Extract the first word of "${ac_tool_prefix}strip", so it can be a program name with args.
 15.2397 +set dummy ${ac_tool_prefix}strip; ac_word=$2
 15.2398 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
 15.2399 +$as_echo_n "checking for $ac_word... " >&6; }
 15.2400 +if test "${ac_cv_prog_STRIP+set}" = set; then :
 15.2401 +  $as_echo_n "(cached) " >&6
 15.2402 +else
 15.2403 +  if test -n "$STRIP"; then
 15.2404 +  ac_cv_prog_STRIP="$STRIP" # Let the user override the test.
 15.2405 +else
 15.2406 +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
 15.2407 +for as_dir in $PATH
 15.2408 +do
 15.2409 +  IFS=$as_save_IFS
 15.2410 +  test -z "$as_dir" && as_dir=.
 15.2411 +    for ac_exec_ext in '' $ac_executable_extensions; do
 15.2412 +  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
 15.2413 +    ac_cv_prog_STRIP="${ac_tool_prefix}strip"
 15.2414 +    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
 15.2415 +    break 2
 15.2416 +  fi
 15.2417 +done
 15.2418 +  done
 15.2419 +IFS=$as_save_IFS
 15.2420 +
 15.2421 +fi
 15.2422 +fi
 15.2423 +STRIP=$ac_cv_prog_STRIP
 15.2424 +if test -n "$STRIP"; then
 15.2425 +  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $STRIP" >&5
 15.2426 +$as_echo "$STRIP" >&6; }
 15.2427 +else
 15.2428 +  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
 15.2429 +$as_echo "no" >&6; }
 15.2430 +fi
 15.2431 +
 15.2432 +
 15.2433 +fi
 15.2434 +if test -z "$ac_cv_prog_STRIP"; then
 15.2435 +  ac_ct_STRIP=$STRIP
 15.2436 +  # Extract the first word of "strip", so it can be a program name with args.
 15.2437 +set dummy strip; ac_word=$2
 15.2438 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
 15.2439 +$as_echo_n "checking for $ac_word... " >&6; }
 15.2440 +if test "${ac_cv_prog_ac_ct_STRIP+set}" = set; then :
 15.2441 +  $as_echo_n "(cached) " >&6
 15.2442 +else
 15.2443 +  if test -n "$ac_ct_STRIP"; then
 15.2444 +  ac_cv_prog_ac_ct_STRIP="$ac_ct_STRIP" # Let the user override the test.
 15.2445 +else
 15.2446 +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
 15.2447 +for as_dir in $PATH
 15.2448 +do
 15.2449 +  IFS=$as_save_IFS
 15.2450 +  test -z "$as_dir" && as_dir=.
 15.2451 +    for ac_exec_ext in '' $ac_executable_extensions; do
 15.2452 +  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
 15.2453 +    ac_cv_prog_ac_ct_STRIP="strip"
 15.2454 +    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
 15.2455 +    break 2
 15.2456 +  fi
 15.2457 +done
 15.2458 +  done
 15.2459 +IFS=$as_save_IFS
 15.2460 +
 15.2461 +fi
 15.2462 +fi
 15.2463 +ac_ct_STRIP=$ac_cv_prog_ac_ct_STRIP
 15.2464 +if test -n "$ac_ct_STRIP"; then
 15.2465 +  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_STRIP" >&5
 15.2466 +$as_echo "$ac_ct_STRIP" >&6; }
 15.2467 +else
 15.2468 +  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
 15.2469 +$as_echo "no" >&6; }
 15.2470 +fi
 15.2471 +
 15.2472 +  if test "x$ac_ct_STRIP" = x; then
 15.2473 +    STRIP=":"
 15.2474 +  else
 15.2475 +    case $cross_compiling:$ac_tool_warned in
 15.2476 +yes:)
 15.2477 +{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5
 15.2478 +$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}
 15.2479 +ac_tool_warned=yes ;;
 15.2480 +esac
 15.2481 +    STRIP=$ac_ct_STRIP
 15.2482 +  fi
 15.2483 +else
 15.2484 +  STRIP="$ac_cv_prog_STRIP"
 15.2485 +fi
 15.2486 +
 15.2487 +fi
 15.2488 +INSTALL_STRIP_PROGRAM="\$(install_sh) -c -s"
 15.2489 +
 15.2490 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for a thread-safe mkdir -p" >&5
 15.2491 +$as_echo_n "checking for a thread-safe mkdir -p... " >&6; }
 15.2492 +if test -z "$MKDIR_P"; then
 15.2493 +  if test "${ac_cv_path_mkdir+set}" = set; then :
 15.2494 +  $as_echo_n "(cached) " >&6
 15.2495 +else
 15.2496 +  as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
 15.2497 +for as_dir in $PATH$PATH_SEPARATOR/opt/sfw/bin
 15.2498 +do
 15.2499 +  IFS=$as_save_IFS
 15.2500 +  test -z "$as_dir" && as_dir=.
 15.2501 +    for ac_prog in mkdir gmkdir; do
 15.2502 +	 for ac_exec_ext in '' $ac_executable_extensions; do
 15.2503 +	   { test -f "$as_dir/$ac_prog$ac_exec_ext" && $as_test_x "$as_dir/$ac_prog$ac_exec_ext"; } || continue
 15.2504 +	   case `"$as_dir/$ac_prog$ac_exec_ext" --version 2>&1` in #(
 15.2505 +	     'mkdir (GNU coreutils) '* | \
 15.2506 +	     'mkdir (coreutils) '* | \
 15.2507 +	     'mkdir (fileutils) '4.1*)
 15.2508 +	       ac_cv_path_mkdir=$as_dir/$ac_prog$ac_exec_ext
 15.2509 +	       break 3;;
 15.2510 +	   esac
 15.2511 +	 done
 15.2512 +       done
 15.2513 +  done
 15.2514 +IFS=$as_save_IFS
 15.2515 +
 15.2516 +fi
 15.2517 +
 15.2518 +  test -d ./--version && rmdir ./--version
 15.2519 +  if test "${ac_cv_path_mkdir+set}" = set; then
 15.2520 +    MKDIR_P="$ac_cv_path_mkdir -p"
 15.2521 +  else
 15.2522 +    # As a last resort, use the slow shell script.  Don't cache a
 15.2523 +    # value for MKDIR_P within a source directory, because that will
 15.2524 +    # break other packages using the cache if that directory is
 15.2525 +    # removed, or if the value is a relative name.
 15.2526 +    MKDIR_P="$ac_install_sh -d"
 15.2527 +  fi
 15.2528 +fi
 15.2529 +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $MKDIR_P" >&5
 15.2530 +$as_echo "$MKDIR_P" >&6; }
 15.2531 +
 15.2532 +mkdir_p="$MKDIR_P"
 15.2533 +case $mkdir_p in
 15.2534 +  [\\/$]* | ?:[\\/]*) ;;
 15.2535 +  */*) mkdir_p="\$(top_builddir)/$mkdir_p" ;;
 15.2536 +esac
 15.2537 +
 15.2538 +for ac_prog in gawk mawk nawk awk
 15.2539 +do
 15.2540 +  # Extract the first word of "$ac_prog", so it can be a program name with args.
 15.2541 +set dummy $ac_prog; ac_word=$2
 15.2542 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
 15.2543 +$as_echo_n "checking for $ac_word... " >&6; }
 15.2544 +if test "${ac_cv_prog_AWK+set}" = set; then :
 15.2545 +  $as_echo_n "(cached) " >&6
 15.2546 +else
 15.2547 +  if test -n "$AWK"; then
 15.2548 +  ac_cv_prog_AWK="$AWK" # Let the user override the test.
 15.2549 +else
 15.2550 +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
 15.2551 +for as_dir in $PATH
 15.2552 +do
 15.2553 +  IFS=$as_save_IFS
 15.2554 +  test -z "$as_dir" && as_dir=.
 15.2555 +    for ac_exec_ext in '' $ac_executable_extensions; do
 15.2556 +  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
 15.2557 +    ac_cv_prog_AWK="$ac_prog"
 15.2558 +    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
 15.2559 +    break 2
 15.2560 +  fi
 15.2561 +done
 15.2562 +  done
 15.2563 +IFS=$as_save_IFS
 15.2564 +
 15.2565 +fi
 15.2566 +fi
 15.2567 +AWK=$ac_cv_prog_AWK
 15.2568 +if test -n "$AWK"; then
 15.2569 +  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $AWK" >&5
 15.2570 +$as_echo "$AWK" >&6; }
 15.2571 +else
 15.2572 +  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
 15.2573 +$as_echo "no" >&6; }
 15.2574 +fi
 15.2575 +
 15.2576 +
 15.2577 +  test -n "$AWK" && break
 15.2578 +done
 15.2579 +
 15.2580 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether ${MAKE-make} sets \$(MAKE)" >&5
 15.2581 +$as_echo_n "checking whether ${MAKE-make} sets \$(MAKE)... " >&6; }
 15.2582 +set x ${MAKE-make}
 15.2583 +ac_make=`$as_echo "$2" | sed 's/+/p/g; s/[^a-zA-Z0-9_]/_/g'`
 15.2584 +if { as_var=ac_cv_prog_make_${ac_make}_set; eval "test \"\${$as_var+set}\" = set"; }; then :
 15.2585 +  $as_echo_n "(cached) " >&6
 15.2586 +else
 15.2587 +  cat >conftest.make <<\_ACEOF
 15.2588 +SHELL = /bin/sh
 15.2589 +all:
 15.2590 +	@echo '@@@%%%=$(MAKE)=@@@%%%'
 15.2591 +_ACEOF
 15.2592 +# GNU make sometimes prints "make[1]: Entering...", which would confuse us.
 15.2593 +case `${MAKE-make} -f conftest.make 2>/dev/null` in
 15.2594 +  *@@@%%%=?*=@@@%%%*)
 15.2595 +    eval ac_cv_prog_make_${ac_make}_set=yes;;
 15.2596 +  *)
 15.2597 +    eval ac_cv_prog_make_${ac_make}_set=no;;
 15.2598 +esac
 15.2599 +rm -f conftest.make
 15.2600 +fi
 15.2601 +if eval test \$ac_cv_prog_make_${ac_make}_set = yes; then
 15.2602 +  { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
 15.2603 +$as_echo "yes" >&6; }
 15.2604 +  SET_MAKE=
 15.2605 +else
 15.2606 +  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
 15.2607 +$as_echo "no" >&6; }
 15.2608 +  SET_MAKE="MAKE=${MAKE-make}"
 15.2609 +fi
 15.2610 +
 15.2611 +rm -rf .tst 2>/dev/null
 15.2612 +mkdir .tst 2>/dev/null
 15.2613 +if test -d .tst; then
 15.2614 +  am__leading_dot=.
 15.2615 +else
 15.2616 +  am__leading_dot=_
 15.2617 +fi
 15.2618 +rmdir .tst 2>/dev/null
 15.2619 +
 15.2620 +if test "`cd $srcdir && pwd`" != "`pwd`"; then
 15.2621 +  # Use -I$(srcdir) only when $(srcdir) != ., so that make's output
 15.2622 +  # is not polluted with repeated "-I."
 15.2623 +  am__isrc=' -I$(srcdir)'
 15.2624 +  # test to see if srcdir already configured
 15.2625 +  if test -f $srcdir/config.status; then
 15.2626 +    as_fn_error "source directory already configured; run \"make distclean\" there first" "$LINENO" 5
 15.2627 +  fi
 15.2628 +fi
 15.2629 +
 15.2630 +# test whether we have cygpath
 15.2631 +if test -z "$CYGPATH_W"; then
 15.2632 +  if (cygpath --version) >/dev/null 2>/dev/null; then
 15.2633 +    CYGPATH_W='cygpath -w'
 15.2634 +  else
 15.2635 +    CYGPATH_W=echo
 15.2636 +  fi
 15.2637 +fi
 15.2638 +
 15.2639 +
 15.2640 +# Define the identity of the package.
 15.2641 + PACKAGE='glpk'
 15.2642 + VERSION='4.47'
 15.2643 +
 15.2644 +
 15.2645 +cat >>confdefs.h <<_ACEOF
 15.2646 +#define PACKAGE "$PACKAGE"
 15.2647 +_ACEOF
 15.2648 +
 15.2649 +
 15.2650 +cat >>confdefs.h <<_ACEOF
 15.2651 +#define VERSION "$VERSION"
 15.2652 +_ACEOF
 15.2653 +
 15.2654 +# Some tools Automake needs.
 15.2655 +
 15.2656 +ACLOCAL=${ACLOCAL-"${am_missing_run}aclocal-${am__api_version}"}
 15.2657 +
 15.2658 +
 15.2659 +AUTOCONF=${AUTOCONF-"${am_missing_run}autoconf"}
 15.2660 +
 15.2661 +
 15.2662 +AUTOMAKE=${AUTOMAKE-"${am_missing_run}automake-${am__api_version}"}
 15.2663 +
 15.2664 +
 15.2665 +AUTOHEADER=${AUTOHEADER-"${am_missing_run}autoheader"}
 15.2666 +
 15.2667 +
 15.2668 +MAKEINFO=${MAKEINFO-"${am_missing_run}makeinfo"}
 15.2669 +
 15.2670 +# We need awk for the "check" target.  The system "awk" is bad on
 15.2671 +# some platforms.
 15.2672 +# Always define AMTAR for backward compatibility.
 15.2673 +
 15.2674 +AMTAR=${AMTAR-"${am_missing_run}tar"}
 15.2675 +
 15.2676 +am__tar='${AMTAR} chof - "$$tardir"'; am__untar='${AMTAR} xf -'
 15.2677 +
 15.2678 +
 15.2679 +
 15.2680 +
 15.2681 +
 15.2682 +
 15.2683 +ac_config_headers="$ac_config_headers config.h"
 15.2684 +
 15.2685 +
 15.2686 +
 15.2687 +# Check whether --with-gmp was given.
 15.2688 +if test "${with_gmp+set}" = set; then :
 15.2689 +  withval=$with_gmp; case $withval in
 15.2690 +      yes | no) ;;
 15.2691 +      *) as_fn_error "invalid value \`$withval' for --with-gmp" "$LINENO" 5;;
 15.2692 +      esac
 15.2693 +else
 15.2694 +  with_gmp=no
 15.2695 +fi
 15.2696 +
 15.2697 +
 15.2698 +# Check whether --enable-dl was given.
 15.2699 +if test "${enable_dl+set}" = set; then :
 15.2700 +  enableval=$enable_dl; case $enableval in
 15.2701 +      yes | ltdl | dlfcn | no) ;;
 15.2702 +      *) as_fn_error "invalid value \`$enableval' for --enable-dl" "$LINENO" 5;;
 15.2703 +      esac
 15.2704 +else
 15.2705 +  enable_dl=no
 15.2706 +fi
 15.2707 +
 15.2708 +
 15.2709 +# Check whether --enable-odbc was given.
 15.2710 +if test "${enable_odbc+set}" = set; then :
 15.2711 +  enableval=$enable_odbc; case $enableval in
 15.2712 +      yes | unix | no) ;;
 15.2713 +      *) as_fn_error "invalid value \`$enableval' for --enable-odbc" "$LINENO" 5;;
 15.2714 +      esac
 15.2715 +else
 15.2716 +  enable_odbc=no
 15.2717 +fi
 15.2718 +
 15.2719 +
 15.2720 +# Check whether --enable-mysql was given.
 15.2721 +if test "${enable_mysql+set}" = set; then :
 15.2722 +  enableval=$enable_mysql; case $enableval in
 15.2723 +      yes | no) ;;
 15.2724 +      *) as_fn_error "invalid value \`$enableval' for --enable-mysql" "$LINENO" 5;;
 15.2725 +      esac
 15.2726 +else
 15.2727 +  enable_mysql=no
 15.2728 +fi
 15.2729 +
 15.2730 +
 15.2731 +
 15.2732 +
 15.2733 +
 15.2734 +
 15.2735 +ac_ext=c
 15.2736 +ac_cpp='$CPP $CPPFLAGS'
 15.2737 +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
 15.2738 +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
 15.2739 +ac_compiler_gnu=$ac_cv_c_compiler_gnu
 15.2740 +if test -n "$ac_tool_prefix"; then
 15.2741 +  # Extract the first word of "${ac_tool_prefix}gcc", so it can be a program name with args.
 15.2742 +set dummy ${ac_tool_prefix}gcc; ac_word=$2
 15.2743 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
 15.2744 +$as_echo_n "checking for $ac_word... " >&6; }
 15.2745 +if test "${ac_cv_prog_CC+set}" = set; then :
 15.2746 +  $as_echo_n "(cached) " >&6
 15.2747 +else
 15.2748 +  if test -n "$CC"; then
 15.2749 +  ac_cv_prog_CC="$CC" # Let the user override the test.
 15.2750 +else
 15.2751 +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
 15.2752 +for as_dir in $PATH
 15.2753 +do
 15.2754 +  IFS=$as_save_IFS
 15.2755 +  test -z "$as_dir" && as_dir=.
 15.2756 +    for ac_exec_ext in '' $ac_executable_extensions; do
 15.2757 +  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
 15.2758 +    ac_cv_prog_CC="${ac_tool_prefix}gcc"
 15.2759 +    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
 15.2760 +    break 2
 15.2761 +  fi
 15.2762 +done
 15.2763 +  done
 15.2764 +IFS=$as_save_IFS
 15.2765 +
 15.2766 +fi
 15.2767 +fi
 15.2768 +CC=$ac_cv_prog_CC
 15.2769 +if test -n "$CC"; then
 15.2770 +  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5
 15.2771 +$as_echo "$CC" >&6; }
 15.2772 +else
 15.2773 +  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
 15.2774 +$as_echo "no" >&6; }
 15.2775 +fi
 15.2776 +
 15.2777 +
 15.2778 +fi
 15.2779 +if test -z "$ac_cv_prog_CC"; then
 15.2780 +  ac_ct_CC=$CC
 15.2781 +  # Extract the first word of "gcc", so it can be a program name with args.
 15.2782 +set dummy gcc; ac_word=$2
 15.2783 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
 15.2784 +$as_echo_n "checking for $ac_word... " >&6; }
 15.2785 +if test "${ac_cv_prog_ac_ct_CC+set}" = set; then :
 15.2786 +  $as_echo_n "(cached) " >&6
 15.2787 +else
 15.2788 +  if test -n "$ac_ct_CC"; then
 15.2789 +  ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test.
 15.2790 +else
 15.2791 +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
 15.2792 +for as_dir in $PATH
 15.2793 +do
 15.2794 +  IFS=$as_save_IFS
 15.2795 +  test -z "$as_dir" && as_dir=.
 15.2796 +    for ac_exec_ext in '' $ac_executable_extensions; do
 15.2797 +  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
 15.2798 +    ac_cv_prog_ac_ct_CC="gcc"
 15.2799 +    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
 15.2800 +    break 2
 15.2801 +  fi
 15.2802 +done
 15.2803 +  done
 15.2804 +IFS=$as_save_IFS
 15.2805 +
 15.2806 +fi
 15.2807 +fi
 15.2808 +ac_ct_CC=$ac_cv_prog_ac_ct_CC
 15.2809 +if test -n "$ac_ct_CC"; then
 15.2810 +  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_CC" >&5
 15.2811 +$as_echo "$ac_ct_CC" >&6; }
 15.2812 +else
 15.2813 +  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
 15.2814 +$as_echo "no" >&6; }
 15.2815 +fi
 15.2816 +
 15.2817 +  if test "x$ac_ct_CC" = x; then
 15.2818 +    CC=""
 15.2819 +  else
 15.2820 +    case $cross_compiling:$ac_tool_warned in
 15.2821 +yes:)
 15.2822 +{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5
 15.2823 +$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}
 15.2824 +ac_tool_warned=yes ;;
 15.2825 +esac
 15.2826 +    CC=$ac_ct_CC
 15.2827 +  fi
 15.2828 +else
 15.2829 +  CC="$ac_cv_prog_CC"
 15.2830 +fi
 15.2831 +
 15.2832 +if test -z "$CC"; then
 15.2833 +          if test -n "$ac_tool_prefix"; then
 15.2834 +    # Extract the first word of "${ac_tool_prefix}cc", so it can be a program name with args.
 15.2835 +set dummy ${ac_tool_prefix}cc; ac_word=$2
 15.2836 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
 15.2837 +$as_echo_n "checking for $ac_word... " >&6; }
 15.2838 +if test "${ac_cv_prog_CC+set}" = set; then :
 15.2839 +  $as_echo_n "(cached) " >&6
 15.2840 +else
 15.2841 +  if test -n "$CC"; then
 15.2842 +  ac_cv_prog_CC="$CC" # Let the user override the test.
 15.2843 +else
 15.2844 +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
 15.2845 +for as_dir in $PATH
 15.2846 +do
 15.2847 +  IFS=$as_save_IFS
 15.2848 +  test -z "$as_dir" && as_dir=.
 15.2849 +    for ac_exec_ext in '' $ac_executable_extensions; do
 15.2850 +  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
 15.2851 +    ac_cv_prog_CC="${ac_tool_prefix}cc"
 15.2852 +    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
 15.2853 +    break 2
 15.2854 +  fi
 15.2855 +done
 15.2856 +  done
 15.2857 +IFS=$as_save_IFS
 15.2858 +
 15.2859 +fi
 15.2860 +fi
 15.2861 +CC=$ac_cv_prog_CC
 15.2862 +if test -n "$CC"; then
 15.2863 +  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5
 15.2864 +$as_echo "$CC" >&6; }
 15.2865 +else
 15.2866 +  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
 15.2867 +$as_echo "no" >&6; }
 15.2868 +fi
 15.2869 +
 15.2870 +
 15.2871 +  fi
 15.2872 +fi
 15.2873 +if test -z "$CC"; then
 15.2874 +  # Extract the first word of "cc", so it can be a program name with args.
 15.2875 +set dummy cc; ac_word=$2
 15.2876 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
 15.2877 +$as_echo_n "checking for $ac_word... " >&6; }
 15.2878 +if test "${ac_cv_prog_CC+set}" = set; then :
 15.2879 +  $as_echo_n "(cached) " >&6
 15.2880 +else
 15.2881 +  if test -n "$CC"; then
 15.2882 +  ac_cv_prog_CC="$CC" # Let the user override the test.
 15.2883 +else
 15.2884 +  ac_prog_rejected=no
 15.2885 +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
 15.2886 +for as_dir in $PATH
 15.2887 +do
 15.2888 +  IFS=$as_save_IFS
 15.2889 +  test -z "$as_dir" && as_dir=.
 15.2890 +    for ac_exec_ext in '' $ac_executable_extensions; do
 15.2891 +  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
 15.2892 +    if test "$as_dir/$ac_word$ac_exec_ext" = "/usr/ucb/cc"; then
 15.2893 +       ac_prog_rejected=yes
 15.2894 +       continue
 15.2895 +     fi
 15.2896 +    ac_cv_prog_CC="cc"
 15.2897 +    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
 15.2898 +    break 2
 15.2899 +  fi
 15.2900 +done
 15.2901 +  done
 15.2902 +IFS=$as_save_IFS
 15.2903 +
 15.2904 +if test $ac_prog_rejected = yes; then
 15.2905 +  # We found a bogon in the path, so make sure we never use it.
 15.2906 +  set dummy $ac_cv_prog_CC
 15.2907 +  shift
 15.2908 +  if test $# != 0; then
 15.2909 +    # We chose a different compiler from the bogus one.
 15.2910 +    # However, it has the same basename, so the bogon will be chosen
 15.2911 +    # first if we set CC to just the basename; use the full file name.
 15.2912 +    shift
 15.2913 +    ac_cv_prog_CC="$as_dir/$ac_word${1+' '}$@"
 15.2914 +  fi
 15.2915 +fi
 15.2916 +fi
 15.2917 +fi
 15.2918 +CC=$ac_cv_prog_CC
 15.2919 +if test -n "$CC"; then
 15.2920 +  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5
 15.2921 +$as_echo "$CC" >&6; }
 15.2922 +else
 15.2923 +  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
 15.2924 +$as_echo "no" >&6; }
 15.2925 +fi
 15.2926 +
 15.2927 +
 15.2928 +fi
 15.2929 +if test -z "$CC"; then
 15.2930 +  if test -n "$ac_tool_prefix"; then
 15.2931 +  for ac_prog in cl.exe
 15.2932 +  do
 15.2933 +    # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args.
 15.2934 +set dummy $ac_tool_prefix$ac_prog; ac_word=$2
 15.2935 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
 15.2936 +$as_echo_n "checking for $ac_word... " >&6; }
 15.2937 +if test "${ac_cv_prog_CC+set}" = set; then :
 15.2938 +  $as_echo_n "(cached) " >&6
 15.2939 +else
 15.2940 +  if test -n "$CC"; then
 15.2941 +  ac_cv_prog_CC="$CC" # Let the user override the test.
 15.2942 +else
 15.2943 +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
 15.2944 +for as_dir in $PATH
 15.2945 +do
 15.2946 +  IFS=$as_save_IFS
 15.2947 +  test -z "$as_dir" && as_dir=.
 15.2948 +    for ac_exec_ext in '' $ac_executable_extensions; do
 15.2949 +  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
 15.2950 +    ac_cv_prog_CC="$ac_tool_prefix$ac_prog"
 15.2951 +    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
 15.2952 +    break 2
 15.2953 +  fi
 15.2954 +done
 15.2955 +  done
 15.2956 +IFS=$as_save_IFS
 15.2957 +
 15.2958 +fi
 15.2959 +fi
 15.2960 +CC=$ac_cv_prog_CC
 15.2961 +if test -n "$CC"; then
 15.2962 +  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5
 15.2963 +$as_echo "$CC" >&6; }
 15.2964 +else
 15.2965 +  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
 15.2966 +$as_echo "no" >&6; }
 15.2967 +fi
 15.2968 +
 15.2969 +
 15.2970 +    test -n "$CC" && break
 15.2971 +  done
 15.2972 +fi
 15.2973 +if test -z "$CC"; then
 15.2974 +  ac_ct_CC=$CC
 15.2975 +  for ac_prog in cl.exe
 15.2976 +do
 15.2977 +  # Extract the first word of "$ac_prog", so it can be a program name with args.
 15.2978 +set dummy $ac_prog; ac_word=$2
 15.2979 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
 15.2980 +$as_echo_n "checking for $ac_word... " >&6; }
 15.2981 +if test "${ac_cv_prog_ac_ct_CC+set}" = set; then :
 15.2982 +  $as_echo_n "(cached) " >&6
 15.2983 +else
 15.2984 +  if test -n "$ac_ct_CC"; then
 15.2985 +  ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test.
 15.2986 +else
 15.2987 +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
 15.2988 +for as_dir in $PATH
 15.2989 +do
 15.2990 +  IFS=$as_save_IFS
 15.2991 +  test -z "$as_dir" && as_dir=.
 15.2992 +    for ac_exec_ext in '' $ac_executable_extensions; do
 15.2993 +  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
 15.2994 +    ac_cv_prog_ac_ct_CC="$ac_prog"
 15.2995 +    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
 15.2996 +    break 2
 15.2997 +  fi
 15.2998 +done
 15.2999 +  done
 15.3000 +IFS=$as_save_IFS
 15.3001 +
 15.3002 +fi
 15.3003 +fi
 15.3004 +ac_ct_CC=$ac_cv_prog_ac_ct_CC
 15.3005 +if test -n "$ac_ct_CC"; then
 15.3006 +  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_CC" >&5
 15.3007 +$as_echo "$ac_ct_CC" >&6; }
 15.3008 +else
 15.3009 +  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
 15.3010 +$as_echo "no" >&6; }
 15.3011 +fi
 15.3012 +
 15.3013 +
 15.3014 +  test -n "$ac_ct_CC" && break
 15.3015 +done
 15.3016 +
 15.3017 +  if test "x$ac_ct_CC" = x; then
 15.3018 +    CC=""
 15.3019 +  else
 15.3020 +    case $cross_compiling:$ac_tool_warned in
 15.3021 +yes:)
 15.3022 +{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5
 15.3023 +$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}
 15.3024 +ac_tool_warned=yes ;;
 15.3025 +esac
 15.3026 +    CC=$ac_ct_CC
 15.3027 +  fi
 15.3028 +fi
 15.3029 +
 15.3030 +fi
 15.3031 +
 15.3032 +
 15.3033 +test -z "$CC" && { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
 15.3034 +$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
 15.3035 +as_fn_error "no acceptable C compiler found in \$PATH
 15.3036 +See \`config.log' for more details." "$LINENO" 5; }
 15.3037 +
 15.3038 +# Provide some information about the compiler.
 15.3039 +$as_echo "$as_me:${as_lineno-$LINENO}: checking for C compiler version" >&5
 15.3040 +set X $ac_compile
 15.3041 +ac_compiler=$2
 15.3042 +for ac_option in --version -v -V -qversion; do
 15.3043 +  { { ac_try="$ac_compiler $ac_option >&5"
 15.3044 +case "(($ac_try" in
 15.3045 +  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
 15.3046 +  *) ac_try_echo=$ac_try;;
 15.3047 +esac
 15.3048 +eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
 15.3049 +$as_echo "$ac_try_echo"; } >&5
 15.3050 +  (eval "$ac_compiler $ac_option >&5") 2>conftest.err
 15.3051 +  ac_status=$?
 15.3052 +  if test -s conftest.err; then
 15.3053 +    sed '10a\
 15.3054 +... rest of stderr output deleted ...
 15.3055 +         10q' conftest.err >conftest.er1
 15.3056 +    cat conftest.er1 >&5
 15.3057 +  fi
 15.3058 +  rm -f conftest.er1 conftest.err
 15.3059 +  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
 15.3060 +  test $ac_status = 0; }
 15.3061 +done
 15.3062 +
 15.3063 +cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 15.3064 +/* end confdefs.h.  */
 15.3065 +
 15.3066 +int
 15.3067 +main ()
 15.3068 +{
 15.3069 +
 15.3070 +  ;
 15.3071 +  return 0;
 15.3072 +}
 15.3073 +_ACEOF
 15.3074 +ac_clean_files_save=$ac_clean_files
 15.3075 +ac_clean_files="$ac_clean_files a.out a.out.dSYM a.exe b.out"
 15.3076 +# Try to create an executable without -o first, disregard a.out.
 15.3077 +# It will help us diagnose broken compilers, and finding out an intuition
 15.3078 +# of exeext.
 15.3079 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the C compiler works" >&5
 15.3080 +$as_echo_n "checking whether the C compiler works... " >&6; }
 15.3081 +ac_link_default=`$as_echo "$ac_link" | sed 's/ -o *conftest[^ ]*//'`
 15.3082 +
 15.3083 +# The possible output files:
 15.3084 +ac_files="a.out conftest.exe conftest a.exe a_out.exe b.out conftest.*"
 15.3085 +
 15.3086 +ac_rmfiles=
 15.3087 +for ac_file in $ac_files
 15.3088 +do
 15.3089 +  case $ac_file in
 15.3090 +    *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM | *.o | *.obj ) ;;
 15.3091 +    * ) ac_rmfiles="$ac_rmfiles $ac_file";;
 15.3092 +  esac
 15.3093 +done
 15.3094 +rm -f $ac_rmfiles
 15.3095 +
 15.3096 +if { { ac_try="$ac_link_default"
 15.3097 +case "(($ac_try" in
 15.3098 +  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
 15.3099 +  *) ac_try_echo=$ac_try;;
 15.3100 +esac
 15.3101 +eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
 15.3102 +$as_echo "$ac_try_echo"; } >&5
 15.3103 +  (eval "$ac_link_default") 2>&5
 15.3104 +  ac_status=$?
 15.3105 +  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
 15.3106 +  test $ac_status = 0; }; then :
 15.3107 +  # Autoconf-2.13 could set the ac_cv_exeext variable to `no'.
 15.3108 +# So ignore a value of `no', otherwise this would lead to `EXEEXT = no'
 15.3109 +# in a Makefile.  We should not override ac_cv_exeext if it was cached,
 15.3110 +# so that the user can short-circuit this test for compilers unknown to
 15.3111 +# Autoconf.
 15.3112 +for ac_file in $ac_files ''
 15.3113 +do
 15.3114 +  test -f "$ac_file" || continue
 15.3115 +  case $ac_file in
 15.3116 +    *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM | *.o | *.obj )
 15.3117 +	;;
 15.3118 +    [ab].out )
 15.3119 +	# We found the default executable, but exeext='' is most
 15.3120 +	# certainly right.
 15.3121 +	break;;
 15.3122 +    *.* )
 15.3123 +	if test "${ac_cv_exeext+set}" = set && test "$ac_cv_exeext" != no;
 15.3124 +	then :; else
 15.3125 +	   ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'`
 15.3126 +	fi
 15.3127 +	# We set ac_cv_exeext here because the later test for it is not
 15.3128 +	# safe: cross compilers may not add the suffix if given an `-o'
 15.3129 +	# argument, so we may need to know it at that point already.
 15.3130 +	# Even if this section looks crufty: it has the advantage of
 15.3131 +	# actually working.
 15.3132 +	break;;
 15.3133 +    * )
 15.3134 +	break;;
 15.3135 +  esac
 15.3136 +done
 15.3137 +test "$ac_cv_exeext" = no && ac_cv_exeext=
 15.3138 +
 15.3139 +else
 15.3140 +  ac_file=''
 15.3141 +fi
 15.3142 +if test -z "$ac_file"; then :
 15.3143 +  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
 15.3144 +$as_echo "no" >&6; }
 15.3145 +$as_echo "$as_me: failed program was:" >&5
 15.3146 +sed 's/^/| /' conftest.$ac_ext >&5
 15.3147 +
 15.3148 +{ { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
 15.3149 +$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
 15.3150 +{ as_fn_set_status 77
 15.3151 +as_fn_error "C compiler cannot create executables
 15.3152 +See \`config.log' for more details." "$LINENO" 5; }; }
 15.3153 +else
 15.3154 +  { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
 15.3155 +$as_echo "yes" >&6; }
 15.3156 +fi
 15.3157 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for C compiler default output file name" >&5
 15.3158 +$as_echo_n "checking for C compiler default output file name... " >&6; }
 15.3159 +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_file" >&5
 15.3160 +$as_echo "$ac_file" >&6; }
 15.3161 +ac_exeext=$ac_cv_exeext
 15.3162 +
 15.3163 +rm -f -r a.out a.out.dSYM a.exe conftest$ac_cv_exeext b.out
 15.3164 +ac_clean_files=$ac_clean_files_save
 15.3165 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for suffix of executables" >&5
 15.3166 +$as_echo_n "checking for suffix of executables... " >&6; }
 15.3167 +if { { ac_try="$ac_link"
 15.3168 +case "(($ac_try" in
 15.3169 +  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
 15.3170 +  *) ac_try_echo=$ac_try;;
 15.3171 +esac
 15.3172 +eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
 15.3173 +$as_echo "$ac_try_echo"; } >&5
 15.3174 +  (eval "$ac_link") 2>&5
 15.3175 +  ac_status=$?
 15.3176 +  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
 15.3177 +  test $ac_status = 0; }; then :
 15.3178 +  # If both `conftest.exe' and `conftest' are `present' (well, observable)
 15.3179 +# catch `conftest.exe'.  For instance with Cygwin, `ls conftest' will
 15.3180 +# work properly (i.e., refer to `conftest.exe'), while it won't with
 15.3181 +# `rm'.
 15.3182 +for ac_file in conftest.exe conftest conftest.*; do
 15.3183 +  test -f "$ac_file" || continue
 15.3184 +  case $ac_file in
 15.3185 +    *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM | *.o | *.obj ) ;;
 15.3186 +    *.* ) ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'`
 15.3187 +	  break;;
 15.3188 +    * ) break;;
 15.3189 +  esac
 15.3190 +done
 15.3191 +else
 15.3192 +  { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
 15.3193 +$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
 15.3194 +as_fn_error "cannot compute suffix of executables: cannot compile and link
 15.3195 +See \`config.log' for more details." "$LINENO" 5; }
 15.3196 +fi
 15.3197 +rm -f conftest conftest$ac_cv_exeext
 15.3198 +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_exeext" >&5
 15.3199 +$as_echo "$ac_cv_exeext" >&6; }
 15.3200 +
 15.3201 +rm -f conftest.$ac_ext
 15.3202 +EXEEXT=$ac_cv_exeext
 15.3203 +ac_exeext=$EXEEXT
 15.3204 +cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 15.3205 +/* end confdefs.h.  */
 15.3206 +#include <stdio.h>
 15.3207 +int
 15.3208 +main ()
 15.3209 +{
 15.3210 +FILE *f = fopen ("conftest.out", "w");
 15.3211 + return ferror (f) || fclose (f) != 0;
 15.3212 +
 15.3213 +  ;
 15.3214 +  return 0;
 15.3215 +}
 15.3216 +_ACEOF
 15.3217 +ac_clean_files="$ac_clean_files conftest.out"
 15.3218 +# Check that the compiler produces executables we can run.  If not, either
 15.3219 +# the compiler is broken, or we cross compile.
 15.3220 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we are cross compiling" >&5
 15.3221 +$as_echo_n "checking whether we are cross compiling... " >&6; }
 15.3222 +if test "$cross_compiling" != yes; then
 15.3223 +  { { ac_try="$ac_link"
 15.3224 +case "(($ac_try" in
 15.3225 +  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
 15.3226 +  *) ac_try_echo=$ac_try;;
 15.3227 +esac
 15.3228 +eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
 15.3229 +$as_echo "$ac_try_echo"; } >&5
 15.3230 +  (eval "$ac_link") 2>&5
 15.3231 +  ac_status=$?
 15.3232 +  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
 15.3233 +  test $ac_status = 0; }
 15.3234 +  if { ac_try='./conftest$ac_cv_exeext'
 15.3235 +  { { case "(($ac_try" in
 15.3236 +  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
 15.3237 +  *) ac_try_echo=$ac_try;;
 15.3238 +esac
 15.3239 +eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
 15.3240 +$as_echo "$ac_try_echo"; } >&5
 15.3241 +  (eval "$ac_try") 2>&5
 15.3242 +  ac_status=$?
 15.3243 +  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
 15.3244 +  test $ac_status = 0; }; }; then
 15.3245 +    cross_compiling=no
 15.3246 +  else
 15.3247 +    if test "$cross_compiling" = maybe; then
 15.3248 +	cross_compiling=yes
 15.3249 +    else
 15.3250 +	{ { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
 15.3251 +$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
 15.3252 +as_fn_error "cannot run C compiled programs.
 15.3253 +If you meant to cross compile, use \`--host'.
 15.3254 +See \`config.log' for more details." "$LINENO" 5; }
 15.3255 +    fi
 15.3256 +  fi
 15.3257 +fi
 15.3258 +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $cross_compiling" >&5
 15.3259 +$as_echo "$cross_compiling" >&6; }
 15.3260 +
 15.3261 +rm -f conftest.$ac_ext conftest$ac_cv_exeext conftest.out
 15.3262 +ac_clean_files=$ac_clean_files_save
 15.3263 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for suffix of object files" >&5
 15.3264 +$as_echo_n "checking for suffix of object files... " >&6; }
 15.3265 +if test "${ac_cv_objext+set}" = set; then :
 15.3266 +  $as_echo_n "(cached) " >&6
 15.3267 +else
 15.3268 +  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 15.3269 +/* end confdefs.h.  */
 15.3270 +
 15.3271 +int
 15.3272 +main ()
 15.3273 +{
 15.3274 +
 15.3275 +  ;
 15.3276 +  return 0;
 15.3277 +}
 15.3278 +_ACEOF
 15.3279 +rm -f conftest.o conftest.obj
 15.3280 +if { { ac_try="$ac_compile"
 15.3281 +case "(($ac_try" in
 15.3282 +  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
 15.3283 +  *) ac_try_echo=$ac_try;;
 15.3284 +esac
 15.3285 +eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
 15.3286 +$as_echo "$ac_try_echo"; } >&5
 15.3287 +  (eval "$ac_compile") 2>&5
 15.3288 +  ac_status=$?
 15.3289 +  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
 15.3290 +  test $ac_status = 0; }; then :
 15.3291 +  for ac_file in conftest.o conftest.obj conftest.*; do
 15.3292 +  test -f "$ac_file" || continue;
 15.3293 +  case $ac_file in
 15.3294 +    *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM ) ;;
 15.3295 +    *) ac_cv_objext=`expr "$ac_file" : '.*\.\(.*\)'`
 15.3296 +       break;;
 15.3297 +  esac
 15.3298 +done
 15.3299 +else
 15.3300 +  $as_echo "$as_me: failed program was:" >&5
 15.3301 +sed 's/^/| /' conftest.$ac_ext >&5
 15.3302 +
 15.3303 +{ { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
 15.3304 +$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
 15.3305 +as_fn_error "cannot compute suffix of object files: cannot compile
 15.3306 +See \`config.log' for more details." "$LINENO" 5; }
 15.3307 +fi
 15.3308 +rm -f conftest.$ac_cv_objext conftest.$ac_ext
 15.3309 +fi
 15.3310 +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_objext" >&5
 15.3311 +$as_echo "$ac_cv_objext" >&6; }
 15.3312 +OBJEXT=$ac_cv_objext
 15.3313 +ac_objext=$OBJEXT
 15.3314 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we are using the GNU C compiler" >&5
 15.3315 +$as_echo_n "checking whether we are using the GNU C compiler... " >&6; }
 15.3316 +if test "${ac_cv_c_compiler_gnu+set}" = set; then :
 15.3317 +  $as_echo_n "(cached) " >&6
 15.3318 +else
 15.3319 +  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 15.3320 +/* end confdefs.h.  */
 15.3321 +
 15.3322 +int
 15.3323 +main ()
 15.3324 +{
 15.3325 +#ifndef __GNUC__
 15.3326 +       choke me
 15.3327 +#endif
 15.3328 +
 15.3329 +  ;
 15.3330 +  return 0;
 15.3331 +}
 15.3332 +_ACEOF
 15.3333 +if ac_fn_c_try_compile "$LINENO"; then :
 15.3334 +  ac_compiler_gnu=yes
 15.3335 +else
 15.3336 +  ac_compiler_gnu=no
 15.3337 +fi
 15.3338 +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
 15.3339 +ac_cv_c_compiler_gnu=$ac_compiler_gnu
 15.3340 +
 15.3341 +fi
 15.3342 +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_c_compiler_gnu" >&5
 15.3343 +$as_echo "$ac_cv_c_compiler_gnu" >&6; }
 15.3344 +if test $ac_compiler_gnu = yes; then
 15.3345 +  GCC=yes
 15.3346 +else
 15.3347 +  GCC=
 15.3348 +fi
 15.3349 +ac_test_CFLAGS=${CFLAGS+set}
 15.3350 +ac_save_CFLAGS=$CFLAGS
 15.3351 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CC accepts -g" >&5
 15.3352 +$as_echo_n "checking whether $CC accepts -g... " >&6; }
 15.3353 +if test "${ac_cv_prog_cc_g+set}" = set; then :
 15.3354 +  $as_echo_n "(cached) " >&6
 15.3355 +else
 15.3356 +  ac_save_c_werror_flag=$ac_c_werror_flag
 15.3357 +   ac_c_werror_flag=yes
 15.3358 +   ac_cv_prog_cc_g=no
 15.3359 +   CFLAGS="-g"
 15.3360 +   cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 15.3361 +/* end confdefs.h.  */
 15.3362 +
 15.3363 +int
 15.3364 +main ()
 15.3365 +{
 15.3366 +
 15.3367 +  ;
 15.3368 +  return 0;
 15.3369 +}
 15.3370 +_ACEOF
 15.3371 +if ac_fn_c_try_compile "$LINENO"; then :
 15.3372 +  ac_cv_prog_cc_g=yes
 15.3373 +else
 15.3374 +  CFLAGS=""
 15.3375 +      cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 15.3376 +/* end confdefs.h.  */
 15.3377 +
 15.3378 +int
 15.3379 +main ()
 15.3380 +{
 15.3381 +
 15.3382 +  ;
 15.3383 +  return 0;
 15.3384 +}
 15.3385 +_ACEOF
 15.3386 +if ac_fn_c_try_compile "$LINENO"; then :
 15.3387 +
 15.3388 +else
 15.3389 +  ac_c_werror_flag=$ac_save_c_werror_flag
 15.3390 +	 CFLAGS="-g"
 15.3391 +	 cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 15.3392 +/* end confdefs.h.  */
 15.3393 +
 15.3394 +int
 15.3395 +main ()
 15.3396 +{
 15.3397 +
 15.3398 +  ;
 15.3399 +  return 0;
 15.3400 +}
 15.3401 +_ACEOF
 15.3402 +if ac_fn_c_try_compile "$LINENO"; then :
 15.3403 +  ac_cv_prog_cc_g=yes
 15.3404 +fi
 15.3405 +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
 15.3406 +fi
 15.3407 +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
 15.3408 +fi
 15.3409 +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
 15.3410 +   ac_c_werror_flag=$ac_save_c_werror_flag
 15.3411 +fi
 15.3412 +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cc_g" >&5
 15.3413 +$as_echo "$ac_cv_prog_cc_g" >&6; }
 15.3414 +if test "$ac_test_CFLAGS" = set; then
 15.3415 +  CFLAGS=$ac_save_CFLAGS
 15.3416 +elif test $ac_cv_prog_cc_g = yes; then
 15.3417 +  if test "$GCC" = yes; then
 15.3418 +    CFLAGS="-g -O2"
 15.3419 +  else
 15.3420 +    CFLAGS="-g"
 15.3421 +  fi
 15.3422 +else
 15.3423 +  if test "$GCC" = yes; then
 15.3424 +    CFLAGS="-O2"
 15.3425 +  else
 15.3426 +    CFLAGS=
 15.3427 +  fi
 15.3428 +fi
 15.3429 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $CC option to accept ISO C89" >&5
 15.3430 +$as_echo_n "checking for $CC option to accept ISO C89... " >&6; }
 15.3431 +if test "${ac_cv_prog_cc_c89+set}" = set; then :
 15.3432 +  $as_echo_n "(cached) " >&6
 15.3433 +else
 15.3434 +  ac_cv_prog_cc_c89=no
 15.3435 +ac_save_CC=$CC
 15.3436 +cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 15.3437 +/* end confdefs.h.  */
 15.3438 +#include <stdarg.h>
 15.3439 +#include <stdio.h>
 15.3440 +#include <sys/types.h>
 15.3441 +#include <sys/stat.h>
 15.3442 +/* Most of the following tests are stolen from RCS 5.7's src/conf.sh.  */
 15.3443 +struct buf { int x; };
 15.3444 +FILE * (*rcsopen) (struct buf *, struct stat *, int);
 15.3445 +static char *e (p, i)
 15.3446 +     char **p;
 15.3447 +     int i;
 15.3448 +{
 15.3449 +  return p[i];
 15.3450 +}
 15.3451 +static char *f (char * (*g) (char **, int), char **p, ...)
 15.3452 +{
 15.3453 +  char *s;
 15.3454 +  va_list v;
 15.3455 +  va_start (v,p);
 15.3456 +  s = g (p, va_arg (v,int));
 15.3457 +  va_end (v);
 15.3458 +  return s;
 15.3459 +}
 15.3460 +
 15.3461 +/* OSF 4.0 Compaq cc is some sort of almost-ANSI by default.  It has
 15.3462 +   function prototypes and stuff, but not '\xHH' hex character constants.
 15.3463 +   These don't provoke an error unfortunately, instead are silently treated
 15.3464 +   as 'x'.  The following induces an error, until -std is added to get
 15.3465 +   proper ANSI mode.  Curiously '\x00'!='x' always comes out true, for an
 15.3466 +   array size at least.  It's necessary to write '\x00'==0 to get something
 15.3467 +   that's true only with -std.  */
 15.3468 +int osf4_cc_array ['\x00' == 0 ? 1 : -1];
 15.3469 +
 15.3470 +/* IBM C 6 for AIX is almost-ANSI by default, but it replaces macro parameters
 15.3471 +   inside strings and character constants.  */
 15.3472 +#define FOO(x) 'x'
 15.3473 +int xlc6_cc_array[FOO(a) == 'x' ? 1 : -1];
 15.3474 +
 15.3475 +int test (int i, double x);
 15.3476 +struct s1 {int (*f) (int a);};
 15.3477 +struct s2 {int (*f) (double a);};
 15.3478 +int pairnames (int, char **, FILE *(*)(struct buf *, struct stat *, int), int, int);
 15.3479 +int argc;
 15.3480 +char **argv;
 15.3481 +int
 15.3482 +main ()
 15.3483 +{
 15.3484 +return f (e, argv, 0) != argv[0]  ||  f (e, argv, 1) != argv[1];
 15.3485 +  ;
 15.3486 +  return 0;
 15.3487 +}
 15.3488 +_ACEOF
 15.3489 +for ac_arg in '' -qlanglvl=extc89 -qlanglvl=ansi -std \
 15.3490 +	-Ae "-Aa -D_HPUX_SOURCE" "-Xc -D__EXTENSIONS__"
 15.3491 +do
 15.3492 +  CC="$ac_save_CC $ac_arg"
 15.3493 +  if ac_fn_c_try_compile "$LINENO"; then :
 15.3494 +  ac_cv_prog_cc_c89=$ac_arg
 15.3495 +fi
 15.3496 +rm -f core conftest.err conftest.$ac_objext
 15.3497 +  test "x$ac_cv_prog_cc_c89" != "xno" && break
 15.3498 +done
 15.3499 +rm -f conftest.$ac_ext
 15.3500 +CC=$ac_save_CC
 15.3501 +
 15.3502 +fi
 15.3503 +# AC_CACHE_VAL
 15.3504 +case "x$ac_cv_prog_cc_c89" in
 15.3505 +  x)
 15.3506 +    { $as_echo "$as_me:${as_lineno-$LINENO}: result: none needed" >&5
 15.3507 +$as_echo "none needed" >&6; } ;;
 15.3508 +  xno)
 15.3509 +    { $as_echo "$as_me:${as_lineno-$LINENO}: result: unsupported" >&5
 15.3510 +$as_echo "unsupported" >&6; } ;;
 15.3511 +  *)
 15.3512 +    CC="$CC $ac_cv_prog_cc_c89"
 15.3513 +    { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cc_c89" >&5
 15.3514 +$as_echo "$ac_cv_prog_cc_c89" >&6; } ;;
 15.3515 +esac
 15.3516 +if test "x$ac_cv_prog_cc_c89" != xno; then :
 15.3517 +
 15.3518 +fi
 15.3519 +
 15.3520 +ac_ext=c
 15.3521 +ac_cpp='$CPP $CPPFLAGS'
 15.3522 +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
 15.3523 +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
 15.3524 +ac_compiler_gnu=$ac_cv_c_compiler_gnu
 15.3525 +DEPDIR="${am__leading_dot}deps"
 15.3526 +
 15.3527 +ac_config_commands="$ac_config_commands depfiles"
 15.3528 +
 15.3529 +
 15.3530 +am_make=${MAKE-make}
 15.3531 +cat > confinc << 'END'
 15.3532 +am__doit:
 15.3533 +	@echo this is the am__doit target
 15.3534 +.PHONY: am__doit
 15.3535 +END
 15.3536 +# If we don't find an include directive, just comment out the code.
 15.3537 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for style of include used by $am_make" >&5
 15.3538 +$as_echo_n "checking for style of include used by $am_make... " >&6; }
 15.3539 +am__include="#"
 15.3540 +am__quote=
 15.3541 +_am_result=none
 15.3542 +# First try GNU make style include.
 15.3543 +echo "include confinc" > confmf
 15.3544 +# Ignore all kinds of additional output from `make'.
 15.3545 +case `$am_make -s -f confmf 2> /dev/null` in #(
 15.3546 +*the\ am__doit\ target*)
 15.3547 +  am__include=include
 15.3548 +  am__quote=
 15.3549 +  _am_result=GNU
 15.3550 +  ;;
 15.3551 +esac
 15.3552 +# Now try BSD make style include.
 15.3553 +if test "$am__include" = "#"; then
 15.3554 +   echo '.include "confinc"' > confmf
 15.3555 +   case `$am_make -s -f confmf 2> /dev/null` in #(
 15.3556 +   *the\ am__doit\ target*)
 15.3557 +     am__include=.include
 15.3558 +     am__quote="\""
 15.3559 +     _am_result=BSD
 15.3560 +     ;;
 15.3561 +   esac
 15.3562 +fi
 15.3563 +
 15.3564 +
 15.3565 +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $_am_result" >&5
 15.3566 +$as_echo "$_am_result" >&6; }
 15.3567 +rm -f confinc confmf
 15.3568 +
 15.3569 +# Check whether --enable-dependency-tracking was given.
 15.3570 +if test "${enable_dependency_tracking+set}" = set; then :
 15.3571 +  enableval=$enable_dependency_tracking;
 15.3572 +fi
 15.3573 +
 15.3574 +if test "x$enable_dependency_tracking" != xno; then
 15.3575 +  am_depcomp="$ac_aux_dir/depcomp"
 15.3576 +  AMDEPBACKSLASH='\'
 15.3577 +fi
 15.3578 + if test "x$enable_dependency_tracking" != xno; then
 15.3579 +  AMDEP_TRUE=
 15.3580 +  AMDEP_FALSE='#'
 15.3581 +else
 15.3582 +  AMDEP_TRUE='#'
 15.3583 +  AMDEP_FALSE=
 15.3584 +fi
 15.3585 +
 15.3586 +
 15.3587 +
 15.3588 +depcc="$CC"   am_compiler_list=
 15.3589 +
 15.3590 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking dependency style of $depcc" >&5
 15.3591 +$as_echo_n "checking dependency style of $depcc... " >&6; }
 15.3592 +if test "${am_cv_CC_dependencies_compiler_type+set}" = set; then :
 15.3593 +  $as_echo_n "(cached) " >&6
 15.3594 +else
 15.3595 +  if test -z "$AMDEP_TRUE" && test -f "$am_depcomp"; then
 15.3596 +  # We make a subdir and do the tests there.  Otherwise we can end up
 15.3597 +  # making bogus files that we don't know about and never remove.  For
 15.3598 +  # instance it was reported that on HP-UX the gcc test will end up
 15.3599 +  # making a dummy file named `D' -- because `-MD' means `put the output
 15.3600 +  # in D'.
 15.3601 +  mkdir conftest.dir
 15.3602 +  # Copy depcomp to subdir because otherwise we won't find it if we're
 15.3603 +  # using a relative directory.
 15.3604 +  cp "$am_depcomp" conftest.dir
 15.3605 +  cd conftest.dir
 15.3606 +  # We will build objects and dependencies in a subdirectory because
 15.3607 +  # it helps to detect inapplicable dependency modes.  For instance
 15.3608 +  # both Tru64's cc and ICC support -MD to output dependencies as a
 15.3609 +  # side effect of compilation, but ICC will put the dependencies in
 15.3610 +  # the current directory while Tru64 will put them in the object
 15.3611 +  # directory.
 15.3612 +  mkdir sub
 15.3613 +
 15.3614 +  am_cv_CC_dependencies_compiler_type=none
 15.3615 +  if test "$am_compiler_list" = ""; then
 15.3616 +     am_compiler_list=`sed -n 's/^#*\([a-zA-Z0-9]*\))$/\1/p' < ./depcomp`
 15.3617 +  fi
 15.3618 +  am__universal=false
 15.3619 +  case " $depcc " in #(
 15.3620 +     *\ -arch\ *\ -arch\ *) am__universal=true ;;
 15.3621 +     esac
 15.3622 +
 15.3623 +  for depmode in $am_compiler_list; do
 15.3624 +    # Setup a source with many dependencies, because some compilers
 15.3625 +    # like to wrap large dependency lists on column 80 (with \), and
 15.3626 +    # we should not choose a depcomp mode which is confused by this.
 15.3627 +    #
 15.3628 +    # We need to recreate these files for each test, as the compiler may
 15.3629 +    # overwrite some of them when testing with obscure command lines.
 15.3630 +    # This happens at least with the AIX C compiler.
 15.3631 +    : > sub/conftest.c
 15.3632 +    for i in 1 2 3 4 5 6; do
 15.3633 +      echo '#include "conftst'$i'.h"' >> sub/conftest.c
 15.3634 +      # Using `: > sub/conftst$i.h' creates only sub/conftst1.h with
 15.3635 +      # Solaris 8's {/usr,}/bin/sh.
 15.3636 +      touch sub/conftst$i.h
 15.3637 +    done
 15.3638 +    echo "${am__include} ${am__quote}sub/conftest.Po${am__quote}" > confmf
 15.3639 +
 15.3640 +    # We check with `-c' and `-o' for the sake of the "dashmstdout"
 15.3641 +    # mode.  It turns out that the SunPro C++ compiler does not properly
 15.3642 +    # handle `-M -o', and we need to detect this.  Also, some Intel
 15.3643 +    # versions had trouble with output in subdirs
 15.3644 +    am__obj=sub/conftest.${OBJEXT-o}
 15.3645 +    am__minus_obj="-o $am__obj"
 15.3646 +    case $depmode in
 15.3647 +    gcc)
 15.3648 +      # This depmode causes a compiler race in universal mode.
 15.3649 +      test "$am__universal" = false || continue
 15.3650 +      ;;
 15.3651 +    nosideeffect)
 15.3652 +      # after this tag, mechanisms are not by side-effect, so they'll
 15.3653 +      # only be used when explicitly requested
 15.3654 +      if test "x$enable_dependency_tracking" = xyes; then
 15.3655 +	continue
 15.3656 +      else
 15.3657 +	break
 15.3658 +      fi
 15.3659 +      ;;
 15.3660 +    msvisualcpp | msvcmsys)
 15.3661 +      # This compiler won't grok `-c -o', but also, the minuso test has
 15.3662 +      # not run yet.  These depmodes are late enough in the game, and
 15.3663 +      # so weak that their functioning should not be impacted.
 15.3664 +      am__obj=conftest.${OBJEXT-o}
 15.3665 +      am__minus_obj=
 15.3666 +      ;;
 15.3667 +    none) break ;;
 15.3668 +    esac
 15.3669 +    if depmode=$depmode \
 15.3670 +       source=sub/conftest.c object=$am__obj \
 15.3671 +       depfile=sub/conftest.Po tmpdepfile=sub/conftest.TPo \
 15.3672 +       $SHELL ./depcomp $depcc -c $am__minus_obj sub/conftest.c \
 15.3673 +         >/dev/null 2>conftest.err &&
 15.3674 +       grep sub/conftst1.h sub/conftest.Po > /dev/null 2>&1 &&
 15.3675 +       grep sub/conftst6.h sub/conftest.Po > /dev/null 2>&1 &&
 15.3676 +       grep $am__obj sub/conftest.Po > /dev/null 2>&1 &&
 15.3677 +       ${MAKE-make} -s -f confmf > /dev/null 2>&1; then
 15.3678 +      # icc doesn't choke on unknown options, it will just issue warnings
 15.3679 +      # or remarks (even with -Werror).  So we grep stderr for any message
 15.3680 +      # that says an option was ignored or not supported.
 15.3681 +      # When given -MP, icc 7.0 and 7.1 complain thusly:
 15.3682 +      #   icc: Command line warning: ignoring option '-M'; no argument required
 15.3683 +      # The diagnosis changed in icc 8.0:
 15.3684 +      #   icc: Command line remark: option '-MP' not supported
 15.3685 +      if (grep 'ignoring option' conftest.err ||
 15.3686 +          grep 'not supported' conftest.err) >/dev/null 2>&1; then :; else
 15.3687 +        am_cv_CC_dependencies_compiler_type=$depmode
 15.3688 +        break
 15.3689 +      fi
 15.3690 +    fi
 15.3691 +  done
 15.3692 +
 15.3693 +  cd ..
 15.3694 +  rm -rf conftest.dir
 15.3695 +else
 15.3696 +  am_cv_CC_dependencies_compiler_type=none
 15.3697 +fi
 15.3698 +
 15.3699 +fi
 15.3700 +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $am_cv_CC_dependencies_compiler_type" >&5
 15.3701 +$as_echo "$am_cv_CC_dependencies_compiler_type" >&6; }
 15.3702 +CCDEPMODE=depmode=$am_cv_CC_dependencies_compiler_type
 15.3703 +
 15.3704 + if
 15.3705 +  test "x$enable_dependency_tracking" != xno \
 15.3706 +  && test "$am_cv_CC_dependencies_compiler_type" = gcc3; then
 15.3707 +  am__fastdepCC_TRUE=
 15.3708 +  am__fastdepCC_FALSE='#'
 15.3709 +else
 15.3710 +  am__fastdepCC_TRUE='#'
 15.3711 +  am__fastdepCC_FALSE=
 15.3712 +fi
 15.3713 +
 15.3714 +
 15.3715 +
 15.3716 +case `pwd` in
 15.3717 +  *\ * | *\	*)
 15.3718 +    { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: Libtool does not cope well with whitespace in \`pwd\`" >&5
 15.3719 +$as_echo "$as_me: WARNING: Libtool does not cope well with whitespace in \`pwd\`" >&2;} ;;
 15.3720 +esac
 15.3721 +
 15.3722 +
 15.3723 +
 15.3724 +macro_version='2.2.7a'
 15.3725 +macro_revision='1.3140'
 15.3726 +
 15.3727 +
 15.3728 +
 15.3729 +
 15.3730 +
 15.3731 +
 15.3732 +
 15.3733 +
 15.3734 +
 15.3735 +
 15.3736 +
 15.3737 +
 15.3738 +
 15.3739 +ltmain="$ac_aux_dir/ltmain.sh"
 15.3740 +
 15.3741 +# Make sure we can run config.sub.
 15.3742 +$SHELL "$ac_aux_dir/config.sub" sun4 >/dev/null 2>&1 ||
 15.3743 +  as_fn_error "cannot run $SHELL $ac_aux_dir/config.sub" "$LINENO" 5
 15.3744 +
 15.3745 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking build system type" >&5
 15.3746 +$as_echo_n "checking build system type... " >&6; }
 15.3747 +if test "${ac_cv_build+set}" = set; then :
 15.3748 +  $as_echo_n "(cached) " >&6
 15.3749 +else
 15.3750 +  ac_build_alias=$build_alias
 15.3751 +test "x$ac_build_alias" = x &&
 15.3752 +  ac_build_alias=`$SHELL "$ac_aux_dir/config.guess"`
 15.3753 +test "x$ac_build_alias" = x &&
 15.3754 +  as_fn_error "cannot guess build type; you must specify one" "$LINENO" 5
 15.3755 +ac_cv_build=`$SHELL "$ac_aux_dir/config.sub" $ac_build_alias` ||
 15.3756 +  as_fn_error "$SHELL $ac_aux_dir/config.sub $ac_build_alias failed" "$LINENO" 5
 15.3757 +
 15.3758 +fi
 15.3759 +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_build" >&5
 15.3760 +$as_echo "$ac_cv_build" >&6; }
 15.3761 +case $ac_cv_build in
 15.3762 +*-*-*) ;;
 15.3763 +*) as_fn_error "invalid value of canonical build" "$LINENO" 5;;
 15.3764 +esac
 15.3765 +build=$ac_cv_build
 15.3766 +ac_save_IFS=$IFS; IFS='-'
 15.3767 +set x $ac_cv_build
 15.3768 +shift
 15.3769 +build_cpu=$1
 15.3770 +build_vendor=$2
 15.3771 +shift; shift
 15.3772 +# Remember, the first character of IFS is used to create $*,
 15.3773 +# except with old shells:
 15.3774 +build_os=$*
 15.3775 +IFS=$ac_save_IFS
 15.3776 +case $build_os in *\ *) build_os=`echo "$build_os" | sed 's/ /-/g'`;; esac
 15.3777 +
 15.3778 +
 15.3779 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking host system type" >&5
 15.3780 +$as_echo_n "checking host system type... " >&6; }
 15.3781 +if test "${ac_cv_host+set}" = set; then :
 15.3782 +  $as_echo_n "(cached) " >&6
 15.3783 +else
 15.3784 +  if test "x$host_alias" = x; then
 15.3785 +  ac_cv_host=$ac_cv_build
 15.3786 +else
 15.3787 +  ac_cv_host=`$SHELL "$ac_aux_dir/config.sub" $host_alias` ||
 15.3788 +    as_fn_error "$SHELL $ac_aux_dir/config.sub $host_alias failed" "$LINENO" 5
 15.3789 +fi
 15.3790 +
 15.3791 +fi
 15.3792 +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_host" >&5
 15.3793 +$as_echo "$ac_cv_host" >&6; }
 15.3794 +case $ac_cv_host in
 15.3795 +*-*-*) ;;
 15.3796 +*) as_fn_error "invalid value of canonical host" "$LINENO" 5;;
 15.3797 +esac
 15.3798 +host=$ac_cv_host
 15.3799 +ac_save_IFS=$IFS; IFS='-'
 15.3800 +set x $ac_cv_host
 15.3801 +shift
 15.3802 +host_cpu=$1
 15.3803 +host_vendor=$2
 15.3804 +shift; shift
 15.3805 +# Remember, the first character of IFS is used to create $*,
 15.3806 +# except with old shells:
 15.3807 +host_os=$*
 15.3808 +IFS=$ac_save_IFS
 15.3809 +case $host_os in *\ *) host_os=`echo "$host_os" | sed 's/ /-/g'`;; esac
 15.3810 +
 15.3811 +
 15.3812 +# Backslashify metacharacters that are still active within
 15.3813 +# double-quoted strings.
 15.3814 +sed_quote_subst='s/\(["`$\\]\)/\\\1/g'
 15.3815 +
 15.3816 +# Same as above, but do not quote variable references.
 15.3817 +double_quote_subst='s/\(["`\\]\)/\\\1/g'
 15.3818 +
 15.3819 +# Sed substitution to delay expansion of an escaped shell variable in a
 15.3820 +# double_quote_subst'ed string.
 15.3821 +delay_variable_subst='s/\\\\\\\\\\\$/\\\\\\$/g'
 15.3822 +
 15.3823 +# Sed substitution to delay expansion of an escaped single quote.
 15.3824 +delay_single_quote_subst='s/'\''/'\'\\\\\\\'\''/g'
 15.3825 +
 15.3826 +# Sed substitution to avoid accidental globbing in evaled expressions
 15.3827 +no_glob_subst='s/\*/\\\*/g'
 15.3828 +
 15.3829 +ECHO='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\'
 15.3830 +ECHO=$ECHO$ECHO$ECHO$ECHO$ECHO
 15.3831 +ECHO=$ECHO$ECHO$ECHO$ECHO$ECHO$ECHO
 15.3832 +
 15.3833 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking how to print strings" >&5
 15.3834 +$as_echo_n "checking how to print strings... " >&6; }
 15.3835 +# Test print first, because it will be a builtin if present.
 15.3836 +if test "X`print -r -- -n 2>/dev/null`" = X-n && \
 15.3837 +   test "X`print -r -- $ECHO 2>/dev/null`" = "X$ECHO"; then
 15.3838 +  ECHO='print -r --'
 15.3839 +elif test "X`printf %s $ECHO 2>/dev/null`" = "X$ECHO"; then
 15.3840 +  ECHO='printf %s\n'
 15.3841 +else
 15.3842 +  # Use this function as a fallback that always works.
 15.3843 +  func_fallback_echo ()
 15.3844 +  {
 15.3845 +    eval 'cat <<_LTECHO_EOF
 15.3846 +$1
 15.3847 +_LTECHO_EOF'
 15.3848 +  }
 15.3849 +  ECHO='func_fallback_echo'
 15.3850 +fi
 15.3851 +
 15.3852 +# func_echo_all arg...
 15.3853 +# Invoke $ECHO with all args, space-separated.
 15.3854 +func_echo_all ()
 15.3855 +{
 15.3856 +    $ECHO ""
 15.3857 +}
 15.3858 +
 15.3859 +case "$ECHO" in
 15.3860 +  printf*) { $as_echo "$as_me:${as_lineno-$LINENO}: result: printf" >&5
 15.3861 +$as_echo "printf" >&6; } ;;
 15.3862 +  print*) { $as_echo "$as_me:${as_lineno-$LINENO}: result: print -r" >&5
 15.3863 +$as_echo "print -r" >&6; } ;;
 15.3864 +  *) { $as_echo "$as_me:${as_lineno-$LINENO}: result: cat" >&5
 15.3865 +$as_echo "cat" >&6; } ;;
 15.3866 +esac
 15.3867 +
 15.3868 +
 15.3869 +
 15.3870 +
 15.3871 +
 15.3872 +
 15.3873 +
 15.3874 +
 15.3875 +
 15.3876 +
 15.3877 +
 15.3878 +
 15.3879 +
 15.3880 +
 15.3881 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for a sed that does not truncate output" >&5
 15.3882 +$as_echo_n "checking for a sed that does not truncate output... " >&6; }
 15.3883 +if test "${ac_cv_path_SED+set}" = set; then :
 15.3884 +  $as_echo_n "(cached) " >&6
 15.3885 +else
 15.3886 +            ac_script=s/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb/
 15.3887 +     for ac_i in 1 2 3 4 5 6 7; do
 15.3888 +       ac_script="$ac_script$as_nl$ac_script"
 15.3889 +     done
 15.3890 +     echo "$ac_script" 2>/dev/null | sed 99q >conftest.sed
 15.3891 +     { ac_script=; unset ac_script;}
 15.3892 +     if test -z "$SED"; then
 15.3893 +  ac_path_SED_found=false
 15.3894 +  # Loop through the user's path and test for each of PROGNAME-LIST
 15.3895 +  as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
 15.3896 +for as_dir in $PATH
 15.3897 +do
 15.3898 +  IFS=$as_save_IFS
 15.3899 +  test -z "$as_dir" && as_dir=.
 15.3900 +    for ac_prog in sed gsed; do
 15.3901 +    for ac_exec_ext in '' $ac_executable_extensions; do
 15.3902 +      ac_path_SED="$as_dir/$ac_prog$ac_exec_ext"
 15.3903 +      { test -f "$ac_path_SED" && $as_test_x "$ac_path_SED"; } || continue
 15.3904 +# Check for GNU ac_path_SED and select it if it is found.
 15.3905 +  # Check for GNU $ac_path_SED
 15.3906 +case `"$ac_path_SED" --version 2>&1` in
 15.3907 +*GNU*)
 15.3908 +  ac_cv_path_SED="$ac_path_SED" ac_path_SED_found=:;;
 15.3909 +*)
 15.3910 +  ac_count=0
 15.3911 +  $as_echo_n 0123456789 >"conftest.in"
 15.3912 +  while :
 15.3913 +  do
 15.3914 +    cat "conftest.in" "conftest.in" >"conftest.tmp"
 15.3915 +    mv "conftest.tmp" "conftest.in"
 15.3916 +    cp "conftest.in" "conftest.nl"
 15.3917 +    $as_echo '' >> "conftest.nl"
 15.3918 +    "$ac_path_SED" -f conftest.sed < "conftest.nl" >"conftest.out" 2>/dev/null || break
 15.3919 +    diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break
 15.3920 +    as_fn_arith $ac_count + 1 && ac_count=$as_val
 15.3921 +    if test $ac_count -gt ${ac_path_SED_max-0}; then
 15.3922 +      # Best one so far, save it but keep looking for a better one
 15.3923 +      ac_cv_path_SED="$ac_path_SED"
 15.3924 +      ac_path_SED_max=$ac_count
 15.3925 +    fi
 15.3926 +    # 10*(2^10) chars as input seems more than enough
 15.3927 +    test $ac_count -gt 10 && break
 15.3928 +  done
 15.3929 +  rm -f conftest.in conftest.tmp conftest.nl conftest.out;;
 15.3930 +esac
 15.3931 +
 15.3932 +      $ac_path_SED_found && break 3
 15.3933 +    done
 15.3934 +  done
 15.3935 +  done
 15.3936 +IFS=$as_save_IFS
 15.3937 +  if test -z "$ac_cv_path_SED"; then
 15.3938 +    as_fn_error "no acceptable sed could be found in \$PATH" "$LINENO" 5
 15.3939 +  fi
 15.3940 +else
 15.3941 +  ac_cv_path_SED=$SED
 15.3942 +fi
 15.3943 +
 15.3944 +fi
 15.3945 +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_SED" >&5
 15.3946 +$as_echo "$ac_cv_path_SED" >&6; }
 15.3947 + SED="$ac_cv_path_SED"
 15.3948 +  rm -f conftest.sed
 15.3949 +
 15.3950 +test -z "$SED" && SED=sed
 15.3951 +Xsed="$SED -e 1s/^X//"
 15.3952 +
 15.3953 +
 15.3954 +
 15.3955 +
 15.3956 +
 15.3957 +
 15.3958 +
 15.3959 +
 15.3960 +
 15.3961 +
 15.3962 +
 15.3963 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for grep that handles long lines and -e" >&5
 15.3964 +$as_echo_n "checking for grep that handles long lines and -e... " >&6; }
 15.3965 +if test "${ac_cv_path_GREP+set}" = set; then :
 15.3966 +  $as_echo_n "(cached) " >&6
 15.3967 +else
 15.3968 +  if test -z "$GREP"; then
 15.3969 +  ac_path_GREP_found=false
 15.3970 +  # Loop through the user's path and test for each of PROGNAME-LIST
 15.3971 +  as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
 15.3972 +for as_dir in $PATH$PATH_SEPARATOR/usr/xpg4/bin
 15.3973 +do
 15.3974 +  IFS=$as_save_IFS
 15.3975 +  test -z "$as_dir" && as_dir=.
 15.3976 +    for ac_prog in grep ggrep; do
 15.3977 +    for ac_exec_ext in '' $ac_executable_extensions; do
 15.3978 +      ac_path_GREP="$as_dir/$ac_prog$ac_exec_ext"
 15.3979 +      { test -f "$ac_path_GREP" && $as_test_x "$ac_path_GREP"; } || continue
 15.3980 +# Check for GNU ac_path_GREP and select it if it is found.
 15.3981 +  # Check for GNU $ac_path_GREP
 15.3982 +case `"$ac_path_GREP" --version 2>&1` in
 15.3983 +*GNU*)
 15.3984 +  ac_cv_path_GREP="$ac_path_GREP" ac_path_GREP_found=:;;
 15.3985 +*)
 15.3986 +  ac_count=0
 15.3987 +  $as_echo_n 0123456789 >"conftest.in"
 15.3988 +  while :
 15.3989 +  do
 15.3990 +    cat "conftest.in" "conftest.in" >"conftest.tmp"
 15.3991 +    mv "conftest.tmp" "conftest.in"
 15.3992 +    cp "conftest.in" "conftest.nl"
 15.3993 +    $as_echo 'GREP' >> "conftest.nl"
 15.3994 +    "$ac_path_GREP" -e 'GREP$' -e '-(cannot match)-' < "conftest.nl" >"conftest.out" 2>/dev/null || break
 15.3995 +    diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break
 15.3996 +    as_fn_arith $ac_count + 1 && ac_count=$as_val
 15.3997 +    if test $ac_count -gt ${ac_path_GREP_max-0}; then
 15.3998 +      # Best one so far, save it but keep looking for a better one
 15.3999 +      ac_cv_path_GREP="$ac_path_GREP"
 15.4000 +      ac_path_GREP_max=$ac_count
 15.4001 +    fi
 15.4002 +    # 10*(2^10) chars as input seems more than enough
 15.4003 +    test $ac_count -gt 10 && break
 15.4004 +  done
 15.4005 +  rm -f conftest.in conftest.tmp conftest.nl conftest.out;;
 15.4006 +esac
 15.4007 +
 15.4008 +      $ac_path_GREP_found && break 3
 15.4009 +    done
 15.4010 +  done
 15.4011 +  done
 15.4012 +IFS=$as_save_IFS
 15.4013 +  if test -z "$ac_cv_path_GREP"; then
 15.4014 +    as_fn_error "no acceptable grep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" "$LINENO" 5
 15.4015 +  fi
 15.4016 +else
 15.4017 +  ac_cv_path_GREP=$GREP
 15.4018 +fi
 15.4019 +
 15.4020 +fi
 15.4021 +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_GREP" >&5
 15.4022 +$as_echo "$ac_cv_path_GREP" >&6; }
 15.4023 + GREP="$ac_cv_path_GREP"
 15.4024 +
 15.4025 +
 15.4026 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for egrep" >&5
 15.4027 +$as_echo_n "checking for egrep... " >&6; }
 15.4028 +if test "${ac_cv_path_EGREP+set}" = set; then :
 15.4029 +  $as_echo_n "(cached) " >&6
 15.4030 +else
 15.4031 +  if echo a | $GREP -E '(a|b)' >/dev/null 2>&1
 15.4032 +   then ac_cv_path_EGREP="$GREP -E"
 15.4033 +   else
 15.4034 +     if test -z "$EGREP"; then
 15.4035 +  ac_path_EGREP_found=false
 15.4036 +  # Loop through the user's path and test for each of PROGNAME-LIST
 15.4037 +  as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
 15.4038 +for as_dir in $PATH$PATH_SEPARATOR/usr/xpg4/bin
 15.4039 +do
 15.4040 +  IFS=$as_save_IFS
 15.4041 +  test -z "$as_dir" && as_dir=.
 15.4042 +    for ac_prog in egrep; do
 15.4043 +    for ac_exec_ext in '' $ac_executable_extensions; do
 15.4044 +      ac_path_EGREP="$as_dir/$ac_prog$ac_exec_ext"
 15.4045 +      { test -f "$ac_path_EGREP" && $as_test_x "$ac_path_EGREP"; } || continue
 15.4046 +# Check for GNU ac_path_EGREP and select it if it is found.
 15.4047 +  # Check for GNU $ac_path_EGREP
 15.4048 +case `"$ac_path_EGREP" --version 2>&1` in
 15.4049 +*GNU*)
 15.4050 +  ac_cv_path_EGREP="$ac_path_EGREP" ac_path_EGREP_found=:;;
 15.4051 +*)
 15.4052 +  ac_count=0
 15.4053 +  $as_echo_n 0123456789 >"conftest.in"
 15.4054 +  while :
 15.4055 +  do
 15.4056 +    cat "conftest.in" "conftest.in" >"conftest.tmp"
 15.4057 +    mv "conftest.tmp" "conftest.in"
 15.4058 +    cp "conftest.in" "conftest.nl"
 15.4059 +    $as_echo 'EGREP' >> "conftest.nl"
 15.4060 +    "$ac_path_EGREP" 'EGREP$' < "conftest.nl" >"conftest.out" 2>/dev/null || break
 15.4061 +    diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break
 15.4062 +    as_fn_arith $ac_count + 1 && ac_count=$as_val
 15.4063 +    if test $ac_count -gt ${ac_path_EGREP_max-0}; then
 15.4064 +      # Best one so far, save it but keep looking for a better one
 15.4065 +      ac_cv_path_EGREP="$ac_path_EGREP"
 15.4066 +      ac_path_EGREP_max=$ac_count
 15.4067 +    fi
 15.4068 +    # 10*(2^10) chars as input seems more than enough
 15.4069 +    test $ac_count -gt 10 && break
 15.4070 +  done
 15.4071 +  rm -f conftest.in conftest.tmp conftest.nl conftest.out;;
 15.4072 +esac
 15.4073 +
 15.4074 +      $ac_path_EGREP_found && break 3
 15.4075 +    done
 15.4076 +  done
 15.4077 +  done
 15.4078 +IFS=$as_save_IFS
 15.4079 +  if test -z "$ac_cv_path_EGREP"; then
 15.4080 +    as_fn_error "no acceptable egrep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" "$LINENO" 5
 15.4081 +  fi
 15.4082 +else
 15.4083 +  ac_cv_path_EGREP=$EGREP
 15.4084 +fi
 15.4085 +
 15.4086 +   fi
 15.4087 +fi
 15.4088 +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_EGREP" >&5
 15.4089 +$as_echo "$ac_cv_path_EGREP" >&6; }
 15.4090 + EGREP="$ac_cv_path_EGREP"
 15.4091 +
 15.4092 +
 15.4093 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for fgrep" >&5
 15.4094 +$as_echo_n "checking for fgrep... " >&6; }
 15.4095 +if test "${ac_cv_path_FGREP+set}" = set; then :
 15.4096 +  $as_echo_n "(cached) " >&6
 15.4097 +else
 15.4098 +  if echo 'ab*c' | $GREP -F 'ab*c' >/dev/null 2>&1
 15.4099 +   then ac_cv_path_FGREP="$GREP -F"
 15.4100 +   else
 15.4101 +     if test -z "$FGREP"; then
 15.4102 +  ac_path_FGREP_found=false
 15.4103 +  # Loop through the user's path and test for each of PROGNAME-LIST
 15.4104 +  as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
 15.4105 +for as_dir in $PATH$PATH_SEPARATOR/usr/xpg4/bin
 15.4106 +do
 15.4107 +  IFS=$as_save_IFS
 15.4108 +  test -z "$as_dir" && as_dir=.
 15.4109 +    for ac_prog in fgrep; do
 15.4110 +    for ac_exec_ext in '' $ac_executable_extensions; do
 15.4111 +      ac_path_FGREP="$as_dir/$ac_prog$ac_exec_ext"
 15.4112 +      { test -f "$ac_path_FGREP" && $as_test_x "$ac_path_FGREP"; } || continue
 15.4113 +# Check for GNU ac_path_FGREP and select it if it is found.
 15.4114 +  # Check for GNU $ac_path_FGREP
 15.4115 +case `"$ac_path_FGREP" --version 2>&1` in
 15.4116 +*GNU*)
 15.4117 +  ac_cv_path_FGREP="$ac_path_FGREP" ac_path_FGREP_found=:;;
 15.4118 +*)
 15.4119 +  ac_count=0
 15.4120 +  $as_echo_n 0123456789 >"conftest.in"
 15.4121 +  while :
 15.4122 +  do
 15.4123 +    cat "conftest.in" "conftest.in" >"conftest.tmp"
 15.4124 +    mv "conftest.tmp" "conftest.in"
 15.4125 +    cp "conftest.in" "conftest.nl"
 15.4126 +    $as_echo 'FGREP' >> "conftest.nl"
 15.4127 +    "$ac_path_FGREP" FGREP < "conftest.nl" >"conftest.out" 2>/dev/null || break
 15.4128 +    diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break
 15.4129 +    as_fn_arith $ac_count + 1 && ac_count=$as_val
 15.4130 +    if test $ac_count -gt ${ac_path_FGREP_max-0}; then
 15.4131 +      # Best one so far, save it but keep looking for a better one
 15.4132 +      ac_cv_path_FGREP="$ac_path_FGREP"
 15.4133 +      ac_path_FGREP_max=$ac_count
 15.4134 +    fi
 15.4135 +    # 10*(2^10) chars as input seems more than enough
 15.4136 +    test $ac_count -gt 10 && break
 15.4137 +  done
 15.4138 +  rm -f conftest.in conftest.tmp conftest.nl conftest.out;;
 15.4139 +esac
 15.4140 +
 15.4141 +      $ac_path_FGREP_found && break 3
 15.4142 +    done
 15.4143 +  done
 15.4144 +  done
 15.4145 +IFS=$as_save_IFS
 15.4146 +  if test -z "$ac_cv_path_FGREP"; then
 15.4147 +    as_fn_error "no acceptable fgrep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" "$LINENO" 5
 15.4148 +  fi
 15.4149 +else
 15.4150 +  ac_cv_path_FGREP=$FGREP
 15.4151 +fi
 15.4152 +
 15.4153 +   fi
 15.4154 +fi
 15.4155 +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_FGREP" >&5
 15.4156 +$as_echo "$ac_cv_path_FGREP" >&6; }
 15.4157 + FGREP="$ac_cv_path_FGREP"
 15.4158 +
 15.4159 +
 15.4160 +test -z "$GREP" && GREP=grep
 15.4161 +
 15.4162 +
 15.4163 +
 15.4164 +
 15.4165 +
 15.4166 +
 15.4167 +
 15.4168 +
 15.4169 +
 15.4170 +
 15.4171 +
 15.4172 +
 15.4173 +
 15.4174 +
 15.4175 +
 15.4176 +
 15.4177 +
 15.4178 +
 15.4179 +
 15.4180 +# Check whether --with-gnu-ld was given.
 15.4181 +if test "${with_gnu_ld+set}" = set; then :
 15.4182 +  withval=$with_gnu_ld; test "$withval" = no || with_gnu_ld=yes
 15.4183 +else
 15.4184 +  with_gnu_ld=no
 15.4185 +fi
 15.4186 +
 15.4187 +ac_prog=ld
 15.4188 +if test "$GCC" = yes; then
 15.4189 +  # Check if gcc -print-prog-name=ld gives a path.
 15.4190 +  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for ld used by $CC" >&5
 15.4191 +$as_echo_n "checking for ld used by $CC... " >&6; }
 15.4192 +  case $host in
 15.4193 +  *-*-mingw*)
 15.4194 +    # gcc leaves a trailing carriage return which upsets mingw
 15.4195 +    ac_prog=`($CC -print-prog-name=ld) 2>&5 | tr -d '\015'` ;;
 15.4196 +  *)
 15.4197 +    ac_prog=`($CC -print-prog-name=ld) 2>&5` ;;
 15.4198 +  esac
 15.4199 +  case $ac_prog in
 15.4200 +    # Accept absolute paths.
 15.4201 +    [\\/]* | ?:[\\/]*)
 15.4202 +      re_direlt='/[^/][^/]*/\.\./'
 15.4203 +      # Canonicalize the pathname of ld
 15.4204 +      ac_prog=`$ECHO "$ac_prog"| $SED 's%\\\\%/%g'`
 15.4205 +      while $ECHO "$ac_prog" | $GREP "$re_direlt" > /dev/null 2>&1; do
 15.4206 +	ac_prog=`$ECHO $ac_prog| $SED "s%$re_direlt%/%"`
 15.4207 +      done
 15.4208 +      test -z "$LD" && LD="$ac_prog"
 15.4209 +      ;;
 15.4210 +  "")
 15.4211 +    # If it fails, then pretend we aren't using GCC.
 15.4212 +    ac_prog=ld
 15.4213 +    ;;
 15.4214 +  *)
 15.4215 +    # If it is relative, then search for the first ld in PATH.
 15.4216 +    with_gnu_ld=unknown
 15.4217 +    ;;
 15.4218 +  esac
 15.4219 +elif test "$with_gnu_ld" = yes; then
 15.4220 +  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for GNU ld" >&5
 15.4221 +$as_echo_n "checking for GNU ld... " >&6; }
 15.4222 +else
 15.4223 +  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for non-GNU ld" >&5
 15.4224 +$as_echo_n "checking for non-GNU ld... " >&6; }
 15.4225 +fi
 15.4226 +if test "${lt_cv_path_LD+set}" = set; then :
 15.4227 +  $as_echo_n "(cached) " >&6
 15.4228 +else
 15.4229 +  if test -z "$LD"; then
 15.4230 +  lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR
 15.4231 +  for ac_dir in $PATH; do
 15.4232 +    IFS="$lt_save_ifs"
 15.4233 +    test -z "$ac_dir" && ac_dir=.
 15.4234 +    if test -f "$ac_dir/$ac_prog" || test -f "$ac_dir/$ac_prog$ac_exeext"; then
 15.4235 +      lt_cv_path_LD="$ac_dir/$ac_prog"
 15.4236 +      # Check to see if the program is GNU ld.  I'd rather use --version,
 15.4237 +      # but apparently some variants of GNU ld only accept -v.
 15.4238 +      # Break only if it was the GNU/non-GNU ld that we prefer.
 15.4239 +      case `"$lt_cv_path_LD" -v 2>&1 </dev/null` in
 15.4240 +      *GNU* | *'with BFD'*)
 15.4241 +	test "$with_gnu_ld" != no && break
 15.4242 +	;;
 15.4243 +      *)
 15.4244 +	test "$with_gnu_ld" != yes && break
 15.4245 +	;;
 15.4246 +      esac
 15.4247 +    fi
 15.4248 +  done
 15.4249 +  IFS="$lt_save_ifs"
 15.4250 +else
 15.4251 +  lt_cv_path_LD="$LD" # Let the user override the test with a path.
 15.4252 +fi
 15.4253 +fi
 15.4254 +
 15.4255 +LD="$lt_cv_path_LD"
 15.4256 +if test -n "$LD"; then
 15.4257 +  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $LD" >&5
 15.4258 +$as_echo "$LD" >&6; }
 15.4259 +else
 15.4260 +  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
 15.4261 +$as_echo "no" >&6; }
 15.4262 +fi
 15.4263 +test -z "$LD" && as_fn_error "no acceptable ld found in \$PATH" "$LINENO" 5
 15.4264 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking if the linker ($LD) is GNU ld" >&5
 15.4265 +$as_echo_n "checking if the linker ($LD) is GNU ld... " >&6; }
 15.4266 +if test "${lt_cv_prog_gnu_ld+set}" = set; then :
 15.4267 +  $as_echo_n "(cached) " >&6
 15.4268 +else
 15.4269 +  # I'd rather use --version here, but apparently some GNU lds only accept -v.
 15.4270 +case `$LD -v 2>&1 </dev/null` in
 15.4271 +*GNU* | *'with BFD'*)
 15.4272 +  lt_cv_prog_gnu_ld=yes
 15.4273 +  ;;
 15.4274 +*)
 15.4275 +  lt_cv_prog_gnu_ld=no
 15.4276 +  ;;
 15.4277 +esac
 15.4278 +fi
 15.4279 +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_gnu_ld" >&5
 15.4280 +$as_echo "$lt_cv_prog_gnu_ld" >&6; }
 15.4281 +with_gnu_ld=$lt_cv_prog_gnu_ld
 15.4282 +
 15.4283 +
 15.4284 +
 15.4285 +
 15.4286 +
 15.4287 +
 15.4288 +
 15.4289 +
 15.4290 +
 15.4291 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for BSD- or MS-compatible name lister (nm)" >&5
 15.4292 +$as_echo_n "checking for BSD- or MS-compatible name lister (nm)... " >&6; }
 15.4293 +if test "${lt_cv_path_NM+set}" = set; then :
 15.4294 +  $as_echo_n "(cached) " >&6
 15.4295 +else
 15.4296 +  if test -n "$NM"; then
 15.4297 +  # Let the user override the test.
 15.4298 +  lt_cv_path_NM="$NM"
 15.4299 +else
 15.4300 +  lt_nm_to_check="${ac_tool_prefix}nm"
 15.4301 +  if test -n "$ac_tool_prefix" && test "$build" = "$host"; then
 15.4302 +    lt_nm_to_check="$lt_nm_to_check nm"
 15.4303 +  fi
 15.4304 +  for lt_tmp_nm in $lt_nm_to_check; do
 15.4305 +    lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR
 15.4306 +    for ac_dir in $PATH /usr/ccs/bin/elf /usr/ccs/bin /usr/ucb /bin; do
 15.4307 +      IFS="$lt_save_ifs"
 15.4308 +      test -z "$ac_dir" && ac_dir=.
 15.4309 +      tmp_nm="$ac_dir/$lt_tmp_nm"
 15.4310 +      if test -f "$tmp_nm" || test -f "$tmp_nm$ac_exeext" ; then
 15.4311 +	# Check to see if the nm accepts a BSD-compat flag.
 15.4312 +	# Adding the `sed 1q' prevents false positives on HP-UX, which says:
 15.4313 +	#   nm: unknown option "B" ignored
 15.4314 +	# Tru64's nm complains that /dev/null is an invalid object file
 15.4315 +	case `"$tmp_nm" -B /dev/null 2>&1 | sed '1q'` in
 15.4316 +	*/dev/null* | *'Invalid file or object type'*)
 15.4317 +	  lt_cv_path_NM="$tmp_nm -B"
 15.4318 +	  break
 15.4319 +	  ;;
 15.4320 +	*)
 15.4321 +	  case `"$tmp_nm" -p /dev/null 2>&1 | sed '1q'` in
 15.4322 +	  */dev/null*)
 15.4323 +	    lt_cv_path_NM="$tmp_nm -p"
 15.4324 +	    break
 15.4325 +	    ;;
 15.4326 +	  *)
 15.4327 +	    lt_cv_path_NM=${lt_cv_path_NM="$tmp_nm"} # keep the first match, but
 15.4328 +	    continue # so that we can try to find one that supports BSD flags
 15.4329 +	    ;;
 15.4330 +	  esac
 15.4331 +	  ;;
 15.4332 +	esac
 15.4333 +      fi
 15.4334 +    done
 15.4335 +    IFS="$lt_save_ifs"
 15.4336 +  done
 15.4337 +  : ${lt_cv_path_NM=no}
 15.4338 +fi
 15.4339 +fi
 15.4340 +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_path_NM" >&5
 15.4341 +$as_echo "$lt_cv_path_NM" >&6; }
 15.4342 +if test "$lt_cv_path_NM" != "no"; then
 15.4343 +  NM="$lt_cv_path_NM"
 15.4344 +else
 15.4345 +  # Didn't find any BSD compatible name lister, look for dumpbin.
 15.4346 +  if test -n "$DUMPBIN"; then :
 15.4347 +    # Let the user override the test.
 15.4348 +  else
 15.4349 +    if test -n "$ac_tool_prefix"; then
 15.4350 +  for ac_prog in dumpbin "link -dump"
 15.4351 +  do
 15.4352 +    # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args.
 15.4353 +set dummy $ac_tool_prefix$ac_prog; ac_word=$2
 15.4354 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
 15.4355 +$as_echo_n "checking for $ac_word... " >&6; }
 15.4356 +if test "${ac_cv_prog_DUMPBIN+set}" = set; then :
 15.4357 +  $as_echo_n "(cached) " >&6
 15.4358 +else
 15.4359 +  if test -n "$DUMPBIN"; then
 15.4360 +  ac_cv_prog_DUMPBIN="$DUMPBIN" # Let the user override the test.
 15.4361 +else
 15.4362 +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
 15.4363 +for as_dir in $PATH
 15.4364 +do
 15.4365 +  IFS=$as_save_IFS
 15.4366 +  test -z "$as_dir" && as_dir=.
 15.4367 +    for ac_exec_ext in '' $ac_executable_extensions; do
 15.4368 +  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
 15.4369 +    ac_cv_prog_DUMPBIN="$ac_tool_prefix$ac_prog"
 15.4370 +    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
 15.4371 +    break 2
 15.4372 +  fi
 15.4373 +done
 15.4374 +  done
 15.4375 +IFS=$as_save_IFS
 15.4376 +
 15.4377 +fi
 15.4378 +fi
 15.4379 +DUMPBIN=$ac_cv_prog_DUMPBIN
 15.4380 +if test -n "$DUMPBIN"; then
 15.4381 +  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $DUMPBIN" >&5
 15.4382 +$as_echo "$DUMPBIN" >&6; }
 15.4383 +else
 15.4384 +  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
 15.4385 +$as_echo "no" >&6; }
 15.4386 +fi
 15.4387 +
 15.4388 +
 15.4389 +    test -n "$DUMPBIN" && break
 15.4390 +  done
 15.4391 +fi
 15.4392 +if test -z "$DUMPBIN"; then
 15.4393 +  ac_ct_DUMPBIN=$DUMPBIN
 15.4394 +  for ac_prog in dumpbin "link -dump"
 15.4395 +do
 15.4396 +  # Extract the first word of "$ac_prog", so it can be a program name with args.
 15.4397 +set dummy $ac_prog; ac_word=$2
 15.4398 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
 15.4399 +$as_echo_n "checking for $ac_word... " >&6; }
 15.4400 +if test "${ac_cv_prog_ac_ct_DUMPBIN+set}" = set; then :
 15.4401 +  $as_echo_n "(cached) " >&6
 15.4402 +else
 15.4403 +  if test -n "$ac_ct_DUMPBIN"; then
 15.4404 +  ac_cv_prog_ac_ct_DUMPBIN="$ac_ct_DUMPBIN" # Let the user override the test.
 15.4405 +else
 15.4406 +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
 15.4407 +for as_dir in $PATH
 15.4408 +do
 15.4409 +  IFS=$as_save_IFS
 15.4410 +  test -z "$as_dir" && as_dir=.
 15.4411 +    for ac_exec_ext in '' $ac_executable_extensions; do
 15.4412 +  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
 15.4413 +    ac_cv_prog_ac_ct_DUMPBIN="$ac_prog"
 15.4414 +    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
 15.4415 +    break 2
 15.4416 +  fi
 15.4417 +done
 15.4418 +  done
 15.4419 +IFS=$as_save_IFS
 15.4420 +
 15.4421 +fi
 15.4422 +fi
 15.4423 +ac_ct_DUMPBIN=$ac_cv_prog_ac_ct_DUMPBIN
 15.4424 +if test -n "$ac_ct_DUMPBIN"; then
 15.4425 +  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_DUMPBIN" >&5
 15.4426 +$as_echo "$ac_ct_DUMPBIN" >&6; }
 15.4427 +else
 15.4428 +  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
 15.4429 +$as_echo "no" >&6; }
 15.4430 +fi
 15.4431 +
 15.4432 +
 15.4433 +  test -n "$ac_ct_DUMPBIN" && break
 15.4434 +done
 15.4435 +
 15.4436 +  if test "x$ac_ct_DUMPBIN" = x; then
 15.4437 +    DUMPBIN=":"
 15.4438 +  else
 15.4439 +    case $cross_compiling:$ac_tool_warned in
 15.4440 +yes:)
 15.4441 +{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5
 15.4442 +$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}
 15.4443 +ac_tool_warned=yes ;;
 15.4444 +esac
 15.4445 +    DUMPBIN=$ac_ct_DUMPBIN
 15.4446 +  fi
 15.4447 +fi
 15.4448 +
 15.4449 +    case `$DUMPBIN -symbols /dev/null 2>&1 | sed '1q'` in
 15.4450 +    *COFF*)
 15.4451 +      DUMPBIN="$DUMPBIN -symbols"
 15.4452 +      ;;
 15.4453 +    *)
 15.4454 +      DUMPBIN=:
 15.4455 +      ;;
 15.4456 +    esac
 15.4457 +  fi
 15.4458 +
 15.4459 +  if test "$DUMPBIN" != ":"; then
 15.4460 +    NM="$DUMPBIN"
 15.4461 +  fi
 15.4462 +fi
 15.4463 +test -z "$NM" && NM=nm
 15.4464 +
 15.4465 +
 15.4466 +
 15.4467 +
 15.4468 +
 15.4469 +
 15.4470 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking the name lister ($NM) interface" >&5
 15.4471 +$as_echo_n "checking the name lister ($NM) interface... " >&6; }
 15.4472 +if test "${lt_cv_nm_interface+set}" = set; then :
 15.4473 +  $as_echo_n "(cached) " >&6
 15.4474 +else
 15.4475 +  lt_cv_nm_interface="BSD nm"
 15.4476 +  echo "int some_variable = 0;" > conftest.$ac_ext
 15.4477 +  (eval echo "\"\$as_me:$LINENO: $ac_compile\"" >&5)
 15.4478 +  (eval "$ac_compile" 2>conftest.err)
 15.4479 +  cat conftest.err >&5
 15.4480 +  (eval echo "\"\$as_me:$LINENO: $NM \\\"conftest.$ac_objext\\\"\"" >&5)
 15.4481 +  (eval "$NM \"conftest.$ac_objext\"" 2>conftest.err > conftest.out)
 15.4482 +  cat conftest.err >&5
 15.4483 +  (eval echo "\"\$as_me:$LINENO: output\"" >&5)
 15.4484 +  cat conftest.out >&5
 15.4485 +  if $GREP 'External.*some_variable' conftest.out > /dev/null; then
 15.4486 +    lt_cv_nm_interface="MS dumpbin"
 15.4487 +  fi
 15.4488 +  rm -f conftest*
 15.4489 +fi
 15.4490 +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_nm_interface" >&5
 15.4491 +$as_echo "$lt_cv_nm_interface" >&6; }
 15.4492 +
 15.4493 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether ln -s works" >&5
 15.4494 +$as_echo_n "checking whether ln -s works... " >&6; }
 15.4495 +LN_S=$as_ln_s
 15.4496 +if test "$LN_S" = "ln -s"; then
 15.4497 +  { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
 15.4498 +$as_echo "yes" >&6; }
 15.4499 +else
 15.4500 +  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no, using $LN_S" >&5
 15.4501 +$as_echo "no, using $LN_S" >&6; }
 15.4502 +fi
 15.4503 +
 15.4504 +# find the maximum length of command line arguments
 15.4505 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking the maximum length of command line arguments" >&5
 15.4506 +$as_echo_n "checking the maximum length of command line arguments... " >&6; }
 15.4507 +if test "${lt_cv_sys_max_cmd_len+set}" = set; then :
 15.4508 +  $as_echo_n "(cached) " >&6
 15.4509 +else
 15.4510 +    i=0
 15.4511 +  teststring="ABCD"
 15.4512 +
 15.4513 +  case $build_os in
 15.4514 +  msdosdjgpp*)
 15.4515 +    # On DJGPP, this test can blow up pretty badly due to problems in libc
 15.4516 +    # (any single argument exceeding 2000 bytes causes a buffer overrun
 15.4517 +    # during glob expansion).  Even if it were fixed, the result of this
 15.4518 +    # check would be larger than it should be.
 15.4519 +    lt_cv_sys_max_cmd_len=12288;    # 12K is about right
 15.4520 +    ;;
 15.4521 +
 15.4522 +  gnu*)
 15.4523 +    # Under GNU Hurd, this test is not required because there is
 15.4524 +    # no limit to the length of command line arguments.
 15.4525 +    # Libtool will interpret -1 as no limit whatsoever
 15.4526 +    lt_cv_sys_max_cmd_len=-1;
 15.4527 +    ;;
 15.4528 +
 15.4529 +  cygwin* | mingw* | cegcc*)
 15.4530 +    # On Win9x/ME, this test blows up -- it succeeds, but takes
 15.4531 +    # about 5 minutes as the teststring grows exponentially.
 15.4532 +    # Worse, since 9x/ME are not pre-emptively multitasking,
 15.4533 +    # you end up with a "frozen" computer, even though with patience
 15.4534 +    # the test eventually succeeds (with a max line length of 256k).
 15.4535 +    # Instead, let's just punt: use the minimum linelength reported by
 15.4536 +    # all of the supported platforms: 8192 (on NT/2K/XP).
 15.4537 +    lt_cv_sys_max_cmd_len=8192;
 15.4538 +    ;;
 15.4539 +
 15.4540 +  mint*)
 15.4541 +    # On MiNT this can take a long time and run out of memory.
 15.4542 +    lt_cv_sys_max_cmd_len=8192;
 15.4543 +    ;;
 15.4544 +
 15.4545 +  amigaos*)
 15.4546 +    # On AmigaOS with pdksh, this test takes hours, literally.
 15.4547 +    # So we just punt and use a minimum line length of 8192.
 15.4548 +    lt_cv_sys_max_cmd_len=8192;
 15.4549 +    ;;
 15.4550 +
 15.4551 +  netbsd* | freebsd* | openbsd* | darwin* | dragonfly*)
 15.4552 +    # This has been around since 386BSD, at least.  Likely further.
 15.4553 +    if test -x /sbin/sysctl; then
 15.4554 +      lt_cv_sys_max_cmd_len=`/sbin/sysctl -n kern.argmax`
 15.4555 +    elif test -x /usr/sbin/sysctl; then
 15.4556 +      lt_cv_sys_max_cmd_len=`/usr/sbin/sysctl -n kern.argmax`
 15.4557 +    else
 15.4558 +      lt_cv_sys_max_cmd_len=65536	# usable default for all BSDs
 15.4559 +    fi
 15.4560 +    # And add a safety zone
 15.4561 +    lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \/ 4`
 15.4562 +    lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \* 3`
 15.4563 +    ;;
 15.4564 +
 15.4565 +  interix*)
 15.4566 +    # We know the value 262144 and hardcode it with a safety zone (like BSD)
 15.4567 +    lt_cv_sys_max_cmd_len=196608
 15.4568 +    ;;
 15.4569 +
 15.4570 +  osf*)
 15.4571 +    # Dr. Hans Ekkehard Plesser reports seeing a kernel panic running configure
 15.4572 +    # due to this test when exec_disable_arg_limit is 1 on Tru64. It is not
 15.4573 +    # nice to cause kernel panics so lets avoid the loop below.
 15.4574 +    # First set a reasonable default.
 15.4575 +    lt_cv_sys_max_cmd_len=16384
 15.4576 +    #
 15.4577 +    if test -x /sbin/sysconfig; then
 15.4578 +      case `/sbin/sysconfig -q proc exec_disable_arg_limit` in
 15.4579 +        *1*) lt_cv_sys_max_cmd_len=-1 ;;
 15.4580 +      esac
 15.4581 +    fi
 15.4582 +    ;;
 15.4583 +  sco3.2v5*)
 15.4584 +    lt_cv_sys_max_cmd_len=102400
 15.4585 +    ;;
 15.4586 +  sysv5* | sco5v6* | sysv4.2uw2*)
 15.4587 +    kargmax=`grep ARG_MAX /etc/conf/cf.d/stune 2>/dev/null`
 15.4588 +    if test -n "$kargmax"; then
 15.4589 +      lt_cv_sys_max_cmd_len=`echo $kargmax | sed 's/.*[	 ]//'`
 15.4590 +    else
 15.4591 +      lt_cv_sys_max_cmd_len=32768
 15.4592 +    fi
 15.4593 +    ;;
 15.4594 +  *)
 15.4595 +    lt_cv_sys_max_cmd_len=`(getconf ARG_MAX) 2> /dev/null`
 15.4596 +    if test -n "$lt_cv_sys_max_cmd_len"; then
 15.4597 +      lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \/ 4`
 15.4598 +      lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \* 3`
 15.4599 +    else
 15.4600 +      # Make teststring a little bigger before we do anything with it.
 15.4601 +      # a 1K string should be a reasonable start.
 15.4602 +      for i in 1 2 3 4 5 6 7 8 ; do
 15.4603 +        teststring=$teststring$teststring
 15.4604 +      done
 15.4605 +      SHELL=${SHELL-${CONFIG_SHELL-/bin/sh}}
 15.4606 +      # If test is not a shell built-in, we'll probably end up computing a
 15.4607 +      # maximum length that is only half of the actual maximum length, but
 15.4608 +      # we can't tell.
 15.4609 +      while { test "X"`func_fallback_echo "$teststring$teststring" 2>/dev/null` \
 15.4610 +	         = "X$teststring$teststring"; } >/dev/null 2>&1 &&
 15.4611 +	      test $i != 17 # 1/2 MB should be enough
 15.4612 +      do
 15.4613 +        i=`expr $i + 1`
 15.4614 +        teststring=$teststring$teststring
 15.4615 +      done
 15.4616 +      # Only check the string length outside the loop.
 15.4617 +      lt_cv_sys_max_cmd_len=`expr "X$teststring" : ".*" 2>&1`
 15.4618 +      teststring=
 15.4619 +      # Add a significant safety factor because C++ compilers can tack on
 15.4620 +      # massive amounts of additional arguments before passing them to the
 15.4621 +      # linker.  It appears as though 1/2 is a usable value.
 15.4622 +      lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \/ 2`
 15.4623 +    fi
 15.4624 +    ;;
 15.4625 +  esac
 15.4626 +
 15.4627 +fi
 15.4628 +
 15.4629 +if test -n $lt_cv_sys_max_cmd_len ; then
 15.4630 +  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_sys_max_cmd_len" >&5
 15.4631 +$as_echo "$lt_cv_sys_max_cmd_len" >&6; }
 15.4632 +else
 15.4633 +  { $as_echo "$as_me:${as_lineno-$LINENO}: result: none" >&5
 15.4634 +$as_echo "none" >&6; }
 15.4635 +fi
 15.4636 +max_cmd_len=$lt_cv_sys_max_cmd_len
 15.4637 +
 15.4638 +
 15.4639 +
 15.4640 +
 15.4641 +
 15.4642 +
 15.4643 +: ${CP="cp -f"}
 15.4644 +: ${MV="mv -f"}
 15.4645 +: ${RM="rm -f"}
 15.4646 +
 15.4647 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the shell understands some XSI constructs" >&5
 15.4648 +$as_echo_n "checking whether the shell understands some XSI constructs... " >&6; }
 15.4649 +# Try some XSI features
 15.4650 +xsi_shell=no
 15.4651 +( _lt_dummy="a/b/c"
 15.4652 +  test "${_lt_dummy##*/},${_lt_dummy%/*},"${_lt_dummy%"$_lt_dummy"}, \
 15.4653 +      = c,a/b,, \
 15.4654 +    && eval 'test $(( 1 + 1 )) -eq 2 \
 15.4655 +    && test "${#_lt_dummy}" -eq 5' ) >/dev/null 2>&1 \
 15.4656 +  && xsi_shell=yes
 15.4657 +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $xsi_shell" >&5
 15.4658 +$as_echo "$xsi_shell" >&6; }
 15.4659 +
 15.4660 +
 15.4661 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the shell understands \"+=\"" >&5
 15.4662 +$as_echo_n "checking whether the shell understands \"+=\"... " >&6; }
 15.4663 +lt_shell_append=no
 15.4664 +( foo=bar; set foo baz; eval "$1+=\$2" && test "$foo" = barbaz ) \
 15.4665 +    >/dev/null 2>&1 \
 15.4666 +  && lt_shell_append=yes
 15.4667 +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_shell_append" >&5
 15.4668 +$as_echo "$lt_shell_append" >&6; }
 15.4669 +
 15.4670 +
 15.4671 +if ( (MAIL=60; unset MAIL) || exit) >/dev/null 2>&1; then
 15.4672 +  lt_unset=unset
 15.4673 +else
 15.4674 +  lt_unset=false
 15.4675 +fi
 15.4676 +
 15.4677 +
 15.4678 +
 15.4679 +
 15.4680 +
 15.4681 +# test EBCDIC or ASCII
 15.4682 +case `echo X|tr X '\101'` in
 15.4683 + A) # ASCII based system
 15.4684 +    # \n is not interpreted correctly by Solaris 8 /usr/ucb/tr
 15.4685 +  lt_SP2NL='tr \040 \012'
 15.4686 +  lt_NL2SP='tr \015\012 \040\040'
 15.4687 +  ;;
 15.4688 + *) # EBCDIC based system
 15.4689 +  lt_SP2NL='tr \100 \n'
 15.4690 +  lt_NL2SP='tr \r\n \100\100'
 15.4691 +  ;;
 15.4692 +esac
 15.4693 +
 15.4694 +
 15.4695 +
 15.4696 +
 15.4697 +
 15.4698 +
 15.4699 +
 15.4700 +
 15.4701 +
 15.4702 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking how to convert $build paths to $host format" >&5
 15.4703 +$as_echo_n "checking how to convert $build paths to $host format... " >&6; }
 15.4704 +if test "${lt_cv_to_host_path_cmd+set}" = set; then :
 15.4705 +  $as_echo_n "(cached) " >&6
 15.4706 +else
 15.4707 +  case $host in
 15.4708 +  *mingw* )
 15.4709 +    case $build in
 15.4710 +      *mingw* ) # actually msys
 15.4711 +        lt_cv_to_host_path_cmd=func_msys_to_mingw_path_convert
 15.4712 +        ;;
 15.4713 +      *cygwin* )
 15.4714 +        lt_cv_to_host_path_cmd=func_cygwin_to_mingw_path_convert
 15.4715 +        ;;
 15.4716 +      * ) # otherwise, assume *nix
 15.4717 +        lt_cv_to_host_path_cmd=func_nix_to_mingw_path_convert
 15.4718 +        ;;
 15.4719 +    esac
 15.4720 +    ;;
 15.4721 +  *cygwin* )
 15.4722 +    case $build in
 15.4723 +      *mingw* ) # actually msys
 15.4724 +        lt_cv_to_host_path_cmd=func_msys_to_cygwin_path_convert
 15.4725 +        ;;
 15.4726 +      *cygwin* )
 15.4727 +        lt_cv_to_host_path_cmd=func_noop_path_convert
 15.4728 +        ;;
 15.4729 +      * ) # otherwise, assume *nix
 15.4730 +        lt_cv_to_host_path_cmd=func_nix_to_cygwin_path_convert
 15.4731 +        ;;
 15.4732 +    esac
 15.4733 +    ;;
 15.4734 +  * ) # unhandled hosts (and "normal" native builds)
 15.4735 +    lt_cv_to_host_path_cmd=func_noop_path_convert
 15.4736 +    ;;
 15.4737 +esac
 15.4738 +
 15.4739 +fi
 15.4740 +
 15.4741 +to_host_path_cmd=$lt_cv_to_host_path_cmd
 15.4742 +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_to_host_path_cmd" >&5
 15.4743 +$as_echo "$lt_cv_to_host_path_cmd" >&6; }
 15.4744 +
 15.4745 +
 15.4746 +
 15.4747 +
 15.4748 +
 15.4749 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $LD option to reload object files" >&5
 15.4750 +$as_echo_n "checking for $LD option to reload object files... " >&6; }
 15.4751 +if test "${lt_cv_ld_reload_flag+set}" = set; then :
 15.4752 +  $as_echo_n "(cached) " >&6
 15.4753 +else
 15.4754 +  lt_cv_ld_reload_flag='-r'
 15.4755 +fi
 15.4756 +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_ld_reload_flag" >&5
 15.4757 +$as_echo "$lt_cv_ld_reload_flag" >&6; }
 15.4758 +reload_flag=$lt_cv_ld_reload_flag
 15.4759 +case $reload_flag in
 15.4760 +"" | " "*) ;;
 15.4761 +*) reload_flag=" $reload_flag" ;;
 15.4762 +esac
 15.4763 +reload_cmds='$LD$reload_flag -o $output$reload_objs'
 15.4764 +case $host_os in
 15.4765 +  darwin*)
 15.4766 +    if test "$GCC" = yes; then
 15.4767 +      reload_cmds='$LTCC $LTCFLAGS -nostdlib ${wl}-r -o $output$reload_objs'
 15.4768 +    else
 15.4769 +      reload_cmds='$LD$reload_flag -o $output$reload_objs'
 15.4770 +    fi
 15.4771 +    ;;
 15.4772 +esac
 15.4773 +
 15.4774 +
 15.4775 +
 15.4776 +
 15.4777 +
 15.4778 +
 15.4779 +
 15.4780 +
 15.4781 +
 15.4782 +if test -n "$ac_tool_prefix"; then
 15.4783 +  # Extract the first word of "${ac_tool_prefix}objdump", so it can be a program name with args.
 15.4784 +set dummy ${ac_tool_prefix}objdump; ac_word=$2
 15.4785 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
 15.4786 +$as_echo_n "checking for $ac_word... " >&6; }
 15.4787 +if test "${ac_cv_prog_OBJDUMP+set}" = set; then :
 15.4788 +  $as_echo_n "(cached) " >&6
 15.4789 +else
 15.4790 +  if test -n "$OBJDUMP"; then
 15.4791 +  ac_cv_prog_OBJDUMP="$OBJDUMP" # Let the user override the test.
 15.4792 +else
 15.4793 +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
 15.4794 +for as_dir in $PATH
 15.4795 +do
 15.4796 +  IFS=$as_save_IFS
 15.4797 +  test -z "$as_dir" && as_dir=.
 15.4798 +    for ac_exec_ext in '' $ac_executable_extensions; do
 15.4799 +  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
 15.4800 +    ac_cv_prog_OBJDUMP="${ac_tool_prefix}objdump"
 15.4801 +    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
 15.4802 +    break 2
 15.4803 +  fi
 15.4804 +done
 15.4805 +  done
 15.4806 +IFS=$as_save_IFS
 15.4807 +
 15.4808 +fi
 15.4809 +fi
 15.4810 +OBJDUMP=$ac_cv_prog_OBJDUMP
 15.4811 +if test -n "$OBJDUMP"; then
 15.4812 +  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $OBJDUMP" >&5
 15.4813 +$as_echo "$OBJDUMP" >&6; }
 15.4814 +else
 15.4815 +  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
 15.4816 +$as_echo "no" >&6; }
 15.4817 +fi
 15.4818 +
 15.4819 +
 15.4820 +fi
 15.4821 +if test -z "$ac_cv_prog_OBJDUMP"; then
 15.4822 +  ac_ct_OBJDUMP=$OBJDUMP
 15.4823 +  # Extract the first word of "objdump", so it can be a program name with args.
 15.4824 +set dummy objdump; ac_word=$2
 15.4825 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
 15.4826 +$as_echo_n "checking for $ac_word... " >&6; }
 15.4827 +if test "${ac_cv_prog_ac_ct_OBJDUMP+set}" = set; then :
 15.4828 +  $as_echo_n "(cached) " >&6
 15.4829 +else
 15.4830 +  if test -n "$ac_ct_OBJDUMP"; then
 15.4831 +  ac_cv_prog_ac_ct_OBJDUMP="$ac_ct_OBJDUMP" # Let the user override the test.
 15.4832 +else
 15.4833 +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
 15.4834 +for as_dir in $PATH
 15.4835 +do
 15.4836 +  IFS=$as_save_IFS
 15.4837 +  test -z "$as_dir" && as_dir=.
 15.4838 +    for ac_exec_ext in '' $ac_executable_extensions; do
 15.4839 +  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
 15.4840 +    ac_cv_prog_ac_ct_OBJDUMP="objdump"
 15.4841 +    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
 15.4842 +    break 2
 15.4843 +  fi
 15.4844 +done
 15.4845 +  done
 15.4846 +IFS=$as_save_IFS
 15.4847 +
 15.4848 +fi
 15.4849 +fi
 15.4850 +ac_ct_OBJDUMP=$ac_cv_prog_ac_ct_OBJDUMP
 15.4851 +if test -n "$ac_ct_OBJDUMP"; then
 15.4852 +  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_OBJDUMP" >&5
 15.4853 +$as_echo "$ac_ct_OBJDUMP" >&6; }
 15.4854 +else
 15.4855 +  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
 15.4856 +$as_echo "no" >&6; }
 15.4857 +fi
 15.4858 +
 15.4859 +  if test "x$ac_ct_OBJDUMP" = x; then
 15.4860 +    OBJDUMP="false"
 15.4861 +  else
 15.4862 +    case $cross_compiling:$ac_tool_warned in
 15.4863 +yes:)
 15.4864 +{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5
 15.4865 +$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}
 15.4866 +ac_tool_warned=yes ;;
 15.4867 +esac
 15.4868 +    OBJDUMP=$ac_ct_OBJDUMP
 15.4869 +  fi
 15.4870 +else
 15.4871 +  OBJDUMP="$ac_cv_prog_OBJDUMP"
 15.4872 +fi
 15.4873 +
 15.4874 +test -z "$OBJDUMP" && OBJDUMP=objdump
 15.4875 +
 15.4876 +
 15.4877 +
 15.4878 +
 15.4879 +
 15.4880 +
 15.4881 +
 15.4882 +
 15.4883 +
 15.4884 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking how to recognize dependent libraries" >&5
 15.4885 +$as_echo_n "checking how to recognize dependent libraries... " >&6; }
 15.4886 +if test "${lt_cv_deplibs_check_method+set}" = set; then :
 15.4887 +  $as_echo_n "(cached) " >&6
 15.4888 +else
 15.4889 +  lt_cv_file_magic_cmd='$MAGIC_CMD'
 15.4890 +lt_cv_file_magic_test_file=
 15.4891 +lt_cv_deplibs_check_method='unknown'
 15.4892 +# Need to set the preceding variable on all platforms that support
 15.4893 +# interlibrary dependencies.
 15.4894 +# 'none' -- dependencies not supported.
 15.4895 +# `unknown' -- same as none, but documents that we really don't know.
 15.4896 +# 'pass_all' -- all dependencies passed with no checks.
 15.4897 +# 'test_compile' -- check by making test program.
 15.4898 +# 'file_magic [[regex]]' -- check by looking for files in library path
 15.4899 +# which responds to the $file_magic_cmd with a given extended regex.
 15.4900 +# If you have `file' or equivalent on your system and you're not sure
 15.4901 +# whether `pass_all' will *always* work, you probably want this one.
 15.4902 +
 15.4903 +case $host_os in
 15.4904 +aix[4-9]*)
 15.4905 +  lt_cv_deplibs_check_method=pass_all
 15.4906 +  ;;
 15.4907 +
 15.4908 +beos*)
 15.4909 +  lt_cv_deplibs_check_method=pass_all
 15.4910 +  ;;
 15.4911 +
 15.4912 +bsdi[45]*)
 15.4913 +  lt_cv_deplibs_check_method='file_magic ELF [0-9][0-9]*-bit [ML]SB (shared object|dynamic lib)'
 15.4914 +  lt_cv_file_magic_cmd='/usr/bin/file -L'
 15.4915 +  lt_cv_file_magic_test_file=/shlib/libc.so
 15.4916 +  ;;
 15.4917 +
 15.4918 +cygwin*)
 15.4919 +  # func_win32_libid is a shell function defined in ltmain.sh
 15.4920 +  lt_cv_deplibs_check_method='file_magic ^x86 archive import|^x86 DLL'
 15.4921 +  lt_cv_file_magic_cmd='func_win32_libid'
 15.4922 +  ;;
 15.4923 +
 15.4924 +mingw* | pw32*)
 15.4925 +  # Base MSYS/MinGW do not provide the 'file' command needed by
 15.4926 +  # func_win32_libid shell function, so use a weaker test based on 'objdump',
 15.4927 +  # unless we find 'file', for example because we are cross-compiling.
 15.4928 +  # func_win32_libid assumes BSD nm, so disallow it if using MS dumpbin.
 15.4929 +  if ( test "$lt_cv_nm_interface" = "BSD nm" && file / ) >/dev/null 2>&1; then
 15.4930 +    lt_cv_deplibs_check_method='file_magic ^x86 archive import|^x86 DLL'
 15.4931 +    lt_cv_file_magic_cmd='func_win32_libid'
 15.4932 +  else
 15.4933 +    lt_cv_deplibs_check_method='file_magic file format pei*-i386(.*architecture: i386)?'
 15.4934 +    lt_cv_file_magic_cmd='$OBJDUMP -f'
 15.4935 +  fi
 15.4936 +  ;;
 15.4937 +
 15.4938 +cegcc*)
 15.4939 +  # use the weaker test based on 'objdump'. See mingw*.
 15.4940 +  lt_cv_deplibs_check_method='file_magic file format pe-arm-.*little(.*architecture: arm)?'
 15.4941 +  lt_cv_file_magic_cmd='$OBJDUMP -f'
 15.4942 +  ;;
 15.4943 +
 15.4944 +darwin* | rhapsody*)
 15.4945 +  lt_cv_deplibs_check_method=pass_all
 15.4946 +  ;;
 15.4947 +
 15.4948 +freebsd* | dragonfly*)
 15.4949 +  if echo __ELF__ | $CC -E - | $GREP __ELF__ > /dev/null; then
 15.4950 +    case $host_cpu in
 15.4951 +    i*86 )
 15.4952 +      # Not sure whether the presence of OpenBSD here was a mistake.
 15.4953 +      # Let's accept both of them until this is cleared up.
 15.4954 +      lt_cv_deplibs_check_method='file_magic (FreeBSD|OpenBSD|DragonFly)/i[3-9]86 (compact )?demand paged shared library'
 15.4955 +      lt_cv_file_magic_cmd=/usr/bin/file
 15.4956 +      lt_cv_file_magic_test_file=`echo /usr/lib/libc.so.*`
 15.4957 +      ;;
 15.4958 +    esac
 15.4959 +  else
 15.4960 +    lt_cv_deplibs_check_method=pass_all
 15.4961 +  fi
 15.4962 +  ;;
 15.4963 +
 15.4964 +gnu*)
 15.4965 +  lt_cv_deplibs_check_method=pass_all
 15.4966 +  ;;
 15.4967 +
 15.4968 +haiku*)
 15.4969 +  lt_cv_deplibs_check_method=pass_all
 15.4970 +  ;;
 15.4971 +
 15.4972 +hpux10.20* | hpux11*)
 15.4973 +  lt_cv_file_magic_cmd=/usr/bin/file
 15.4974 +  case $host_cpu in
 15.4975 +  ia64*)
 15.4976 +    lt_cv_deplibs_check_method='file_magic (s[0-9][0-9][0-9]|ELF-[0-9][0-9]) shared object file - IA64'
 15.4977 +    lt_cv_file_magic_test_file=/usr/lib/hpux32/libc.so
 15.4978 +    ;;
 15.4979 +  hppa*64*)
 15.4980 +    lt_cv_deplibs_check_method='file_magic (s[0-9][0-9][0-9]|ELF[ -][0-9][0-9])(-bit)?( [LM]SB)? shared object( file)?[, -]* PA-RISC [0-9]\.[0-9]'
 15.4981 +    lt_cv_file_magic_test_file=/usr/lib/pa20_64/libc.sl
 15.4982 +    ;;
 15.4983 +  *)
 15.4984 +    lt_cv_deplibs_check_method='file_magic (s[0-9][0-9][0-9]|PA-RISC[0-9]\.[0-9]) shared library'
 15.4985 +    lt_cv_file_magic_test_file=/usr/lib/libc.sl
 15.4986 +    ;;
 15.4987 +  esac
 15.4988 +  ;;
 15.4989 +
 15.4990 +interix[3-9]*)
 15.4991 +  # PIC code is broken on Interix 3.x, that's why |\.a not |_pic\.a here
 15.4992 +  lt_cv_deplibs_check_method='match_pattern /lib[^/]+(\.so|\.a)$'
 15.4993 +  ;;
 15.4994 +
 15.4995 +irix5* | irix6* | nonstopux*)
 15.4996 +  case $LD in
 15.4997 +  *-32|*"-32 ") libmagic=32-bit;;
 15.4998 +  *-n32|*"-n32 ") libmagic=N32;;
 15.4999 +  *-64|*"-64 ") libmagic=64-bit;;
 15.5000 +  *) libmagic=never-match;;
 15.5001 +  esac
 15.5002 +  lt_cv_deplibs_check_method=pass_all
 15.5003 +  ;;
 15.5004 +
 15.5005 +# This must be Linux ELF.
 15.5006 +linux* | k*bsd*-gnu | kopensolaris*-gnu)
 15.5007 +  lt_cv_deplibs_check_method=pass_all
 15.5008 +  ;;
 15.5009 +
 15.5010 +netbsd*)
 15.5011 +  if echo __ELF__ | $CC -E - | $GREP __ELF__ > /dev/null; then
 15.5012 +    lt_cv_deplibs_check_method='match_pattern /lib[^/]+(\.so\.[0-9]+\.[0-9]+|_pic\.a)$'
 15.5013 +  else
 15.5014 +    lt_cv_deplibs_check_method='match_pattern /lib[^/]+(\.so|_pic\.a)$'
 15.5015 +  fi
 15.5016 +  ;;
 15.5017 +
 15.5018 +newos6*)
 15.5019 +  lt_cv_deplibs_check_method='file_magic ELF [0-9][0-9]*-bit [ML]SB (executable|dynamic lib)'
 15.5020 +  lt_cv_file_magic_cmd=/usr/bin/file
 15.5021 +  lt_cv_file_magic_test_file=/usr/lib/libnls.so
 15.5022 +  ;;
 15.5023 +
 15.5024 +*nto* | *qnx*)
 15.5025 +  lt_cv_deplibs_check_method=pass_all
 15.5026 +  ;;
 15.5027 +
 15.5028 +openbsd*)
 15.5029 +  if test -z "`echo __ELF__ | $CC -E - | $GREP __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then
 15.5030 +    lt_cv_deplibs_check_method='match_pattern /lib[^/]+(\.so\.[0-9]+\.[0-9]+|\.so|_pic\.a)$'
 15.5031 +  else
 15.5032 +    lt_cv_deplibs_check_method='match_pattern /lib[^/]+(\.so\.[0-9]+\.[0-9]+|_pic\.a)$'
 15.5033 +  fi
 15.5034 +  ;;
 15.5035 +
 15.5036 +osf3* | osf4* | osf5*)
 15.5037 +  lt_cv_deplibs_check_method=pass_all
 15.5038 +  ;;
 15.5039 +
 15.5040 +rdos*)
 15.5041 +  lt_cv_deplibs_check_method=pass_all
 15.5042 +  ;;
 15.5043 +
 15.5044 +solaris*)
 15.5045 +  lt_cv_deplibs_check_method=pass_all
 15.5046 +  ;;
 15.5047 +
 15.5048 +sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX* | sysv4*uw2*)
 15.5049 +  lt_cv_deplibs_check_method=pass_all
 15.5050 +  ;;
 15.5051 +
 15.5052 +sysv4 | sysv4.3*)
 15.5053 +  case $host_vendor in
 15.5054 +  motorola)
 15.5055 +    lt_cv_deplibs_check_method='file_magic ELF [0-9][0-9]*-bit [ML]SB (shared object|dynamic lib) M[0-9][0-9]* Version [0-9]'
 15.5056 +    lt_cv_file_magic_test_file=`echo /usr/lib/libc.so*`
 15.5057 +    ;;
 15.5058 +  ncr)
 15.5059 +    lt_cv_deplibs_check_method=pass_all
 15.5060 +    ;;
 15.5061 +  sequent)
 15.5062 +    lt_cv_file_magic_cmd='/bin/file'
 15.5063 +    lt_cv_deplibs_check_method='file_magic ELF [0-9][0-9]*-bit [LM]SB (shared object|dynamic lib )'
 15.5064 +    ;;
 15.5065 +  sni)
 15.5066 +    lt_cv_file_magic_cmd='/bin/file'
 15.5067 +    lt_cv_deplibs_check_method="file_magic ELF [0-9][0-9]*-bit [LM]SB dynamic lib"
 15.5068 +    lt_cv_file_magic_test_file=/lib/libc.so
 15.5069 +    ;;
 15.5070 +  siemens)
 15.5071 +    lt_cv_deplibs_check_method=pass_all
 15.5072 +    ;;
 15.5073 +  pc)
 15.5074 +    lt_cv_deplibs_check_method=pass_all
 15.5075 +    ;;
 15.5076 +  esac
 15.5077 +  ;;
 15.5078 +
 15.5079 +tpf*)
 15.5080 +  lt_cv_deplibs_check_method=pass_all
 15.5081 +  ;;
 15.5082 +esac
 15.5083 +
 15.5084 +fi
 15.5085 +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_deplibs_check_method" >&5
 15.5086 +$as_echo "$lt_cv_deplibs_check_method" >&6; }
 15.5087 +file_magic_cmd=$lt_cv_file_magic_cmd
 15.5088 +deplibs_check_method=$lt_cv_deplibs_check_method
 15.5089 +test -z "$deplibs_check_method" && deplibs_check_method=unknown
 15.5090 +
 15.5091 +
 15.5092 +
 15.5093 +
 15.5094 +
 15.5095 +
 15.5096 +
 15.5097 +
 15.5098 +
 15.5099 +
 15.5100 +
 15.5101 +
 15.5102 +if test -n "$ac_tool_prefix"; then
 15.5103 +  # Extract the first word of "${ac_tool_prefix}dlltool", so it can be a program name with args.
 15.5104 +set dummy ${ac_tool_prefix}dlltool; ac_word=$2
 15.5105 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
 15.5106 +$as_echo_n "checking for $ac_word... " >&6; }
 15.5107 +if test "${ac_cv_prog_DLLTOOL+set}" = set; then :
 15.5108 +  $as_echo_n "(cached) " >&6
 15.5109 +else
 15.5110 +  if test -n "$DLLTOOL"; then
 15.5111 +  ac_cv_prog_DLLTOOL="$DLLTOOL" # Let the user override the test.
 15.5112 +else
 15.5113 +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
 15.5114 +for as_dir in $PATH
 15.5115 +do
 15.5116 +  IFS=$as_save_IFS
 15.5117 +  test -z "$as_dir" && as_dir=.
 15.5118 +    for ac_exec_ext in '' $ac_executable_extensions; do
 15.5119 +  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
 15.5120 +    ac_cv_prog_DLLTOOL="${ac_tool_prefix}dlltool"
 15.5121 +    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
 15.5122 +    break 2
 15.5123 +  fi
 15.5124 +done
 15.5125 +  done
 15.5126 +IFS=$as_save_IFS
 15.5127 +
 15.5128 +fi
 15.5129 +fi
 15.5130 +DLLTOOL=$ac_cv_prog_DLLTOOL
 15.5131 +if test -n "$DLLTOOL"; then
 15.5132 +  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $DLLTOOL" >&5
 15.5133 +$as_echo "$DLLTOOL" >&6; }
 15.5134 +else
 15.5135 +  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
 15.5136 +$as_echo "no" >&6; }
 15.5137 +fi
 15.5138 +
 15.5139 +
 15.5140 +fi
 15.5141 +if test -z "$ac_cv_prog_DLLTOOL"; then
 15.5142 +  ac_ct_DLLTOOL=$DLLTOOL
 15.5143 +  # Extract the first word of "dlltool", so it can be a program name with args.
 15.5144 +set dummy dlltool; ac_word=$2
 15.5145 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
 15.5146 +$as_echo_n "checking for $ac_word... " >&6; }
 15.5147 +if test "${ac_cv_prog_ac_ct_DLLTOOL+set}" = set; then :
 15.5148 +  $as_echo_n "(cached) " >&6
 15.5149 +else
 15.5150 +  if test -n "$ac_ct_DLLTOOL"; then
 15.5151 +  ac_cv_prog_ac_ct_DLLTOOL="$ac_ct_DLLTOOL" # Let the user override the test.
 15.5152 +else
 15.5153 +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
 15.5154 +for as_dir in $PATH
 15.5155 +do
 15.5156 +  IFS=$as_save_IFS
 15.5157 +  test -z "$as_dir" && as_dir=.
 15.5158 +    for ac_exec_ext in '' $ac_executable_extensions; do
 15.5159 +  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
 15.5160 +    ac_cv_prog_ac_ct_DLLTOOL="dlltool"
 15.5161 +    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
 15.5162 +    break 2
 15.5163 +  fi
 15.5164 +done
 15.5165 +  done
 15.5166 +IFS=$as_save_IFS
 15.5167 +
 15.5168 +fi
 15.5169 +fi
 15.5170 +ac_ct_DLLTOOL=$ac_cv_prog_ac_ct_DLLTOOL
 15.5171 +if test -n "$ac_ct_DLLTOOL"; then
 15.5172 +  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_DLLTOOL" >&5
 15.5173 +$as_echo "$ac_ct_DLLTOOL" >&6; }
 15.5174 +else
 15.5175 +  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
 15.5176 +$as_echo "no" >&6; }
 15.5177 +fi
 15.5178 +
 15.5179 +  if test "x$ac_ct_DLLTOOL" = x; then
 15.5180 +    DLLTOOL="false"
 15.5181 +  else
 15.5182 +    case $cross_compiling:$ac_tool_warned in
 15.5183 +yes:)
 15.5184 +{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5
 15.5185 +$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}
 15.5186 +ac_tool_warned=yes ;;
 15.5187 +esac
 15.5188 +    DLLTOOL=$ac_ct_DLLTOOL
 15.5189 +  fi
 15.5190 +else
 15.5191 +  DLLTOOL="$ac_cv_prog_DLLTOOL"
 15.5192 +fi
 15.5193 +
 15.5194 +test -z "$DLLTOOL" && DLLTOOL=dlltool
 15.5195 +
 15.5196 +
 15.5197 +
 15.5198 +
 15.5199 +
 15.5200 +
 15.5201 +
 15.5202 +
 15.5203 +
 15.5204 +
 15.5205 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking how to associate runtime and link libraries" >&5
 15.5206 +$as_echo_n "checking how to associate runtime and link libraries... " >&6; }
 15.5207 +if test "${lt_cv_sharedlib_from_linklib_cmd+set}" = set; then :
 15.5208 +  $as_echo_n "(cached) " >&6
 15.5209 +else
 15.5210 +  lt_cv_sharedlib_from_linklib_cmd='unknown'
 15.5211 +
 15.5212 +case $host_os in
 15.5213 +cygwin* | mingw* | pw32* | cegcc*)
 15.5214 +  # two different shell functions defined in ltmain.sh
 15.5215 +  # decide which to use based on capabilities of $DLLTOOL
 15.5216 +  case `$DLLTOOL --help 2>&1` in
 15.5217 +  *--identify-strict*)
 15.5218 +    lt_cv_sharedlib_from_linklib_cmd=func_cygming_dll_for_implib
 15.5219 +    ;;
 15.5220 +  *)
 15.5221 +    lt_cv_sharedlib_from_linklib_cmd=func_cygming_dll_for_implib_fallback
 15.5222 +    ;;
 15.5223 +  esac
 15.5224 +  ;;
 15.5225 +*)
 15.5226 +  # fallback: assume linklib IS sharedlib
 15.5227 +  lt_cv_sharedlib_from_linklib_cmd="$ECHO"
 15.5228 +  ;;
 15.5229 +esac
 15.5230 +
 15.5231 +fi
 15.5232 +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_sharedlib_from_linklib_cmd" >&5
 15.5233 +$as_echo "$lt_cv_sharedlib_from_linklib_cmd" >&6; }
 15.5234 +sharedlib_from_linklib_cmd=$lt_cv_sharedlib_from_linklib_cmd
 15.5235 +test -z "$sharedlib_from_linklib_cmd" && sharedlib_from_linklib_cmd=$ECHO
 15.5236 +
 15.5237 +
 15.5238 +
 15.5239 +
 15.5240 +
 15.5241 +
 15.5242 +
 15.5243 +if test -n "$ac_tool_prefix"; then
 15.5244 +  # Extract the first word of "${ac_tool_prefix}ar", so it can be a program name with args.
 15.5245 +set dummy ${ac_tool_prefix}ar; ac_word=$2
 15.5246 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
 15.5247 +$as_echo_n "checking for $ac_word... " >&6; }
 15.5248 +if test "${ac_cv_prog_AR+set}" = set; then :
 15.5249 +  $as_echo_n "(cached) " >&6
 15.5250 +else
 15.5251 +  if test -n "$AR"; then
 15.5252 +  ac_cv_prog_AR="$AR" # Let the user override the test.
 15.5253 +else
 15.5254 +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
 15.5255 +for as_dir in $PATH
 15.5256 +do
 15.5257 +  IFS=$as_save_IFS
 15.5258 +  test -z "$as_dir" && as_dir=.
 15.5259 +    for ac_exec_ext in '' $ac_executable_extensions; do
 15.5260 +  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
 15.5261 +    ac_cv_prog_AR="${ac_tool_prefix}ar"
 15.5262 +    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
 15.5263 +    break 2
 15.5264 +  fi
 15.5265 +done
 15.5266 +  done
 15.5267 +IFS=$as_save_IFS
 15.5268 +
 15.5269 +fi
 15.5270 +fi
 15.5271 +AR=$ac_cv_prog_AR
 15.5272 +if test -n "$AR"; then
 15.5273 +  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $AR" >&5
 15.5274 +$as_echo "$AR" >&6; }
 15.5275 +else
 15.5276 +  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
 15.5277 +$as_echo "no" >&6; }
 15.5278 +fi
 15.5279 +
 15.5280 +
 15.5281 +fi
 15.5282 +if test -z "$ac_cv_prog_AR"; then
 15.5283 +  ac_ct_AR=$AR
 15.5284 +  # Extract the first word of "ar", so it can be a program name with args.
 15.5285 +set dummy ar; ac_word=$2
 15.5286 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
 15.5287 +$as_echo_n "checking for $ac_word... " >&6; }
 15.5288 +if test "${ac_cv_prog_ac_ct_AR+set}" = set; then :
 15.5289 +  $as_echo_n "(cached) " >&6
 15.5290 +else
 15.5291 +  if test -n "$ac_ct_AR"; then
 15.5292 +  ac_cv_prog_ac_ct_AR="$ac_ct_AR" # Let the user override the test.
 15.5293 +else
 15.5294 +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
 15.5295 +for as_dir in $PATH
 15.5296 +do
 15.5297 +  IFS=$as_save_IFS
 15.5298 +  test -z "$as_dir" && as_dir=.
 15.5299 +    for ac_exec_ext in '' $ac_executable_extensions; do
 15.5300 +  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
 15.5301 +    ac_cv_prog_ac_ct_AR="ar"
 15.5302 +    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
 15.5303 +    break 2
 15.5304 +  fi
 15.5305 +done
 15.5306 +  done
 15.5307 +IFS=$as_save_IFS
 15.5308 +
 15.5309 +fi
 15.5310 +fi
 15.5311 +ac_ct_AR=$ac_cv_prog_ac_ct_AR
 15.5312 +if test -n "$ac_ct_AR"; then
 15.5313 +  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_AR" >&5
 15.5314 +$as_echo "$ac_ct_AR" >&6; }
 15.5315 +else
 15.5316 +  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
 15.5317 +$as_echo "no" >&6; }
 15.5318 +fi
 15.5319 +
 15.5320 +  if test "x$ac_ct_AR" = x; then
 15.5321 +    AR="false"
 15.5322 +  else
 15.5323 +    case $cross_compiling:$ac_tool_warned in
 15.5324 +yes:)
 15.5325 +{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5
 15.5326 +$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}
 15.5327 +ac_tool_warned=yes ;;
 15.5328 +esac
 15.5329 +    AR=$ac_ct_AR
 15.5330 +  fi
 15.5331 +else
 15.5332 +  AR="$ac_cv_prog_AR"
 15.5333 +fi
 15.5334 +
 15.5335 +test -z "$AR" && AR=ar
 15.5336 +test -z "$AR_FLAGS" && AR_FLAGS=cru
 15.5337 +
 15.5338 +
 15.5339 +
 15.5340 +
 15.5341 +
 15.5342 +
 15.5343 +
 15.5344 +
 15.5345 +
 15.5346 +
 15.5347 +
 15.5348 +if test -n "$ac_tool_prefix"; then
 15.5349 +  # Extract the first word of "${ac_tool_prefix}strip", so it can be a program name with args.
 15.5350 +set dummy ${ac_tool_prefix}strip; ac_word=$2
 15.5351 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
 15.5352 +$as_echo_n "checking for $ac_word... " >&6; }
 15.5353 +if test "${ac_cv_prog_STRIP+set}" = set; then :
 15.5354 +  $as_echo_n "(cached) " >&6
 15.5355 +else
 15.5356 +  if test -n "$STRIP"; then
 15.5357 +  ac_cv_prog_STRIP="$STRIP" # Let the user override the test.
 15.5358 +else
 15.5359 +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
 15.5360 +for as_dir in $PATH
 15.5361 +do
 15.5362 +  IFS=$as_save_IFS
 15.5363 +  test -z "$as_dir" && as_dir=.
 15.5364 +    for ac_exec_ext in '' $ac_executable_extensions; do
 15.5365 +  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
 15.5366 +    ac_cv_prog_STRIP="${ac_tool_prefix}strip"
 15.5367 +    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
 15.5368 +    break 2
 15.5369 +  fi
 15.5370 +done
 15.5371 +  done
 15.5372 +IFS=$as_save_IFS
 15.5373 +
 15.5374 +fi
 15.5375 +fi
 15.5376 +STRIP=$ac_cv_prog_STRIP
 15.5377 +if test -n "$STRIP"; then
 15.5378 +  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $STRIP" >&5
 15.5379 +$as_echo "$STRIP" >&6; }
 15.5380 +else
 15.5381 +  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
 15.5382 +$as_echo "no" >&6; }
 15.5383 +fi
 15.5384 +
 15.5385 +
 15.5386 +fi
 15.5387 +if test -z "$ac_cv_prog_STRIP"; then
 15.5388 +  ac_ct_STRIP=$STRIP
 15.5389 +  # Extract the first word of "strip", so it can be a program name with args.
 15.5390 +set dummy strip; ac_word=$2
 15.5391 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
 15.5392 +$as_echo_n "checking for $ac_word... " >&6; }
 15.5393 +if test "${ac_cv_prog_ac_ct_STRIP+set}" = set; then :
 15.5394 +  $as_echo_n "(cached) " >&6
 15.5395 +else
 15.5396 +  if test -n "$ac_ct_STRIP"; then
 15.5397 +  ac_cv_prog_ac_ct_STRIP="$ac_ct_STRIP" # Let the user override the test.
 15.5398 +else
 15.5399 +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
 15.5400 +for as_dir in $PATH
 15.5401 +do
 15.5402 +  IFS=$as_save_IFS
 15.5403 +  test -z "$as_dir" && as_dir=.
 15.5404 +    for ac_exec_ext in '' $ac_executable_extensions; do
 15.5405 +  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
 15.5406 +    ac_cv_prog_ac_ct_STRIP="strip"
 15.5407 +    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
 15.5408 +    break 2
 15.5409 +  fi
 15.5410 +done
 15.5411 +  done
 15.5412 +IFS=$as_save_IFS
 15.5413 +
 15.5414 +fi
 15.5415 +fi
 15.5416 +ac_ct_STRIP=$ac_cv_prog_ac_ct_STRIP
 15.5417 +if test -n "$ac_ct_STRIP"; then
 15.5418 +  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_STRIP" >&5
 15.5419 +$as_echo "$ac_ct_STRIP" >&6; }
 15.5420 +else
 15.5421 +  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
 15.5422 +$as_echo "no" >&6; }
 15.5423 +fi
 15.5424 +
 15.5425 +  if test "x$ac_ct_STRIP" = x; then
 15.5426 +    STRIP=":"
 15.5427 +  else
 15.5428 +    case $cross_compiling:$ac_tool_warned in
 15.5429 +yes:)
 15.5430 +{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5
 15.5431 +$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}
 15.5432 +ac_tool_warned=yes ;;
 15.5433 +esac
 15.5434 +    STRIP=$ac_ct_STRIP
 15.5435 +  fi
 15.5436 +else
 15.5437 +  STRIP="$ac_cv_prog_STRIP"
 15.5438 +fi
 15.5439 +
 15.5440 +test -z "$STRIP" && STRIP=:
 15.5441 +
 15.5442 +
 15.5443 +
 15.5444 +
 15.5445 +
 15.5446 +
 15.5447 +if test -n "$ac_tool_prefix"; then
 15.5448 +  # Extract the first word of "${ac_tool_prefix}ranlib", so it can be a program name with args.
 15.5449 +set dummy ${ac_tool_prefix}ranlib; ac_word=$2
 15.5450 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
 15.5451 +$as_echo_n "checking for $ac_word... " >&6; }
 15.5452 +if test "${ac_cv_prog_RANLIB+set}" = set; then :
 15.5453 +  $as_echo_n "(cached) " >&6
 15.5454 +else
 15.5455 +  if test -n "$RANLIB"; then
 15.5456 +  ac_cv_prog_RANLIB="$RANLIB" # Let the user override the test.
 15.5457 +else
 15.5458 +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
 15.5459 +for as_dir in $PATH
 15.5460 +do
 15.5461 +  IFS=$as_save_IFS
 15.5462 +  test -z "$as_dir" && as_dir=.
 15.5463 +    for ac_exec_ext in '' $ac_executable_extensions; do
 15.5464 +  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
 15.5465 +    ac_cv_prog_RANLIB="${ac_tool_prefix}ranlib"
 15.5466 +    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
 15.5467 +    break 2
 15.5468 +  fi
 15.5469 +done
 15.5470 +  done
 15.5471 +IFS=$as_save_IFS
 15.5472 +
 15.5473 +fi
 15.5474 +fi
 15.5475 +RANLIB=$ac_cv_prog_RANLIB
 15.5476 +if test -n "$RANLIB"; then
 15.5477 +  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $RANLIB" >&5
 15.5478 +$as_echo "$RANLIB" >&6; }
 15.5479 +else
 15.5480 +  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
 15.5481 +$as_echo "no" >&6; }
 15.5482 +fi
 15.5483 +
 15.5484 +
 15.5485 +fi
 15.5486 +if test -z "$ac_cv_prog_RANLIB"; then
 15.5487 +  ac_ct_RANLIB=$RANLIB
 15.5488 +  # Extract the first word of "ranlib", so it can be a program name with args.
 15.5489 +set dummy ranlib; ac_word=$2
 15.5490 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
 15.5491 +$as_echo_n "checking for $ac_word... " >&6; }
 15.5492 +if test "${ac_cv_prog_ac_ct_RANLIB+set}" = set; then :
 15.5493 +  $as_echo_n "(cached) " >&6
 15.5494 +else
 15.5495 +  if test -n "$ac_ct_RANLIB"; then
 15.5496 +  ac_cv_prog_ac_ct_RANLIB="$ac_ct_RANLIB" # Let the user override the test.
 15.5497 +else
 15.5498 +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
 15.5499 +for as_dir in $PATH
 15.5500 +do
 15.5501 +  IFS=$as_save_IFS
 15.5502 +  test -z "$as_dir" && as_dir=.
 15.5503 +    for ac_exec_ext in '' $ac_executable_extensions; do
 15.5504 +  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
 15.5505 +    ac_cv_prog_ac_ct_RANLIB="ranlib"
 15.5506 +    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
 15.5507 +    break 2
 15.5508 +  fi
 15.5509 +done
 15.5510 +  done
 15.5511 +IFS=$as_save_IFS
 15.5512 +
 15.5513 +fi
 15.5514 +fi
 15.5515 +ac_ct_RANLIB=$ac_cv_prog_ac_ct_RANLIB
 15.5516 +if test -n "$ac_ct_RANLIB"; then
 15.5517 +  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_RANLIB" >&5
 15.5518 +$as_echo "$ac_ct_RANLIB" >&6; }
 15.5519 +else
 15.5520 +  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
 15.5521 +$as_echo "no" >&6; }
 15.5522 +fi
 15.5523 +
 15.5524 +  if test "x$ac_ct_RANLIB" = x; then
 15.5525 +    RANLIB=":"
 15.5526 +  else
 15.5527 +    case $cross_compiling:$ac_tool_warned in
 15.5528 +yes:)
 15.5529 +{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5
 15.5530 +$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}
 15.5531 +ac_tool_warned=yes ;;
 15.5532 +esac
 15.5533 +    RANLIB=$ac_ct_RANLIB
 15.5534 +  fi
 15.5535 +else
 15.5536 +  RANLIB="$ac_cv_prog_RANLIB"
 15.5537 +fi
 15.5538 +
 15.5539 +test -z "$RANLIB" && RANLIB=:
 15.5540 +
 15.5541 +
 15.5542 +
 15.5543 +
 15.5544 +
 15.5545 +
 15.5546 +# Determine commands to create old-style static archives.
 15.5547 +old_archive_cmds='$AR $AR_FLAGS $oldlib$oldobjs'
 15.5548 +old_postinstall_cmds='chmod 644 $oldlib'
 15.5549 +old_postuninstall_cmds=
 15.5550 +
 15.5551 +if test -n "$RANLIB"; then
 15.5552 +  case $host_os in
 15.5553 +  openbsd*)
 15.5554 +    old_postinstall_cmds="$old_postinstall_cmds~\$RANLIB -t \$oldlib"
 15.5555 +    ;;
 15.5556 +  *)
 15.5557 +    old_postinstall_cmds="$old_postinstall_cmds~\$RANLIB \$oldlib"
 15.5558 +    ;;
 15.5559 +  esac
 15.5560 +  old_archive_cmds="$old_archive_cmds~\$RANLIB \$oldlib"
 15.5561 +fi
 15.5562 +
 15.5563 +case $host_os in
 15.5564 +  darwin*)
 15.5565 +    lock_old_archive_extraction=yes ;;
 15.5566 +  *)
 15.5567 +    lock_old_archive_extraction=no ;;
 15.5568 +esac
 15.5569 +
 15.5570 +
 15.5571 +
 15.5572 +
 15.5573 +
 15.5574 +
 15.5575 +
 15.5576 +
 15.5577 +
 15.5578 +
 15.5579 +
 15.5580 +
 15.5581 +
 15.5582 +
 15.5583 +
 15.5584 +
 15.5585 +
 15.5586 +
 15.5587 +
 15.5588 +
 15.5589 +
 15.5590 +
 15.5591 +
 15.5592 +
 15.5593 +
 15.5594 +
 15.5595 +
 15.5596 +
 15.5597 +
 15.5598 +
 15.5599 +
 15.5600 +
 15.5601 +
 15.5602 +
 15.5603 +
 15.5604 +
 15.5605 +
 15.5606 +
 15.5607 +
 15.5608 +# If no C compiler was specified, use CC.
 15.5609 +LTCC=${LTCC-"$CC"}
 15.5610 +
 15.5611 +# If no C compiler flags were specified, use CFLAGS.
 15.5612 +LTCFLAGS=${LTCFLAGS-"$CFLAGS"}
 15.5613 +
 15.5614 +# Allow CC to be a program name with arguments.
 15.5615 +compiler=$CC
 15.5616 +
 15.5617 +
 15.5618 +# Check for command to grab the raw symbol name followed by C symbol from nm.
 15.5619 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking command to parse $NM output from $compiler object" >&5
 15.5620 +$as_echo_n "checking command to parse $NM output from $compiler object... " >&6; }
 15.5621 +if test "${lt_cv_sys_global_symbol_pipe+set}" = set; then :
 15.5622 +  $as_echo_n "(cached) " >&6
 15.5623 +else
 15.5624 +
 15.5625 +# These are sane defaults that work on at least a few old systems.
 15.5626 +# [They come from Ultrix.  What could be older than Ultrix?!! ;)]
 15.5627 +
 15.5628 +# Character class describing NM global symbol codes.
 15.5629 +symcode='[BCDEGRST]'
 15.5630 +
 15.5631 +# Regexp to match symbols that can be accessed directly from C.
 15.5632 +sympat='\([_A-Za-z][_A-Za-z0-9]*\)'
 15.5633 +
 15.5634 +# Define system-specific variables.
 15.5635 +case $host_os in
 15.5636 +aix*)
 15.5637 +  symcode='[BCDT]'
 15.5638 +  ;;
 15.5639 +cygwin* | mingw* | pw32* | cegcc*)
 15.5640 +  symcode='[ABCDGISTW]'
 15.5641 +  ;;
 15.5642 +hpux*)
 15.5643 +  if test "$host_cpu" = ia64; then
 15.5644 +    symcode='[ABCDEGRST]'
 15.5645 +  fi
 15.5646 +  ;;
 15.5647 +irix* | nonstopux*)
 15.5648 +  symcode='[BCDEGRST]'
 15.5649 +  ;;
 15.5650 +osf*)
 15.5651 +  symcode='[BCDEGQRST]'
 15.5652 +  ;;
 15.5653 +solaris*)
 15.5654 +  symcode='[BDRT]'
 15.5655 +  ;;
 15.5656 +sco3.2v5*)
 15.5657 +  symcode='[DT]'
 15.5658 +  ;;
 15.5659 +sysv4.2uw2*)
 15.5660 +  symcode='[DT]'
 15.5661 +  ;;
 15.5662 +sysv5* | sco5v6* | unixware* | OpenUNIX*)
 15.5663 +  symcode='[ABDT]'
 15.5664 +  ;;
 15.5665 +sysv4)
 15.5666 +  symcode='[DFNSTU]'
 15.5667 +  ;;
 15.5668 +esac
 15.5669 +
 15.5670 +# If we're using GNU nm, then use its standard symbol codes.
 15.5671 +case `$NM -V 2>&1` in
 15.5672 +*GNU* | *'with BFD'*)
 15.5673 +  symcode='[ABCDGIRSTW]' ;;
 15.5674 +esac
 15.5675 +
 15.5676 +# Transform an extracted symbol line into a proper C declaration.
 15.5677 +# Some systems (esp. on ia64) link data and code symbols differently,
 15.5678 +# so use this general approach.
 15.5679 +lt_cv_sys_global_symbol_to_cdecl="sed -n -e 's/^T .* \(.*\)$/extern int \1();/p' -e 's/^$symcode* .* \(.*\)$/extern char \1;/p'"
 15.5680 +
 15.5681 +# Transform an extracted symbol line into symbol name and symbol address
 15.5682 +lt_cv_sys_global_symbol_to_c_name_address="sed -n -e 's/^: \([^ ]*\)[ ]*$/  {\\\"\1\\\", (void *) 0},/p' -e 's/^$symcode* \([^ ]*\) \([^ ]*\)$/  {\"\2\", (void *) \&\2},/p'"
 15.5683 +lt_cv_sys_global_symbol_to_c_name_address_lib_prefix="sed -n -e 's/^: \([^ ]*\)[ ]*$/  {\\\"\1\\\", (void *) 0},/p' -e 's/^$symcode* \([^ ]*\) \(lib[^ ]*\)$/  {\"\2\", (void *) \&\2},/p' -e 's/^$symcode* \([^ ]*\) \([^ ]*\)$/  {\"lib\2\", (void *) \&\2},/p'"
 15.5684 +
 15.5685 +# Handle CRLF in mingw tool chain
 15.5686 +opt_cr=
 15.5687 +case $build_os in
 15.5688 +mingw*)
 15.5689 +  opt_cr=`$ECHO 'x\{0,1\}' | tr x '\015'` # option cr in regexp
 15.5690 +  ;;
 15.5691 +esac
 15.5692 +
 15.5693 +# Try without a prefix underscore, then with it.
 15.5694 +for ac_symprfx in "" "_"; do
 15.5695 +
 15.5696 +  # Transform symcode, sympat, and symprfx into a raw symbol and a C symbol.
 15.5697 +  symxfrm="\\1 $ac_symprfx\\2 \\2"
 15.5698 +
 15.5699 +  # Write the raw and C identifiers.
 15.5700 +  if test "$lt_cv_nm_interface" = "MS dumpbin"; then
 15.5701 +    # Fake it for dumpbin and say T for any non-static function
 15.5702 +    # and D for any global variable.
 15.5703 +    # Also find C++ and __fastcall symbols from MSVC++,
 15.5704 +    # which start with @ or ?.
 15.5705 +    lt_cv_sys_global_symbol_pipe="$AWK '"\
 15.5706 +"     {last_section=section; section=\$ 3};"\
 15.5707 +"     /Section length .*#relocs.*(pick any)/{hide[last_section]=1};"\
 15.5708 +"     \$ 0!~/External *\|/{next};"\
 15.5709 +"     / 0+ UNDEF /{next}; / UNDEF \([^|]\)*()/{next};"\
 15.5710 +"     {if(hide[section]) next};"\
 15.5711 +"     {f=0}; \$ 0~/\(\).*\|/{f=1}; {printf f ? \"T \" : \"D \"};"\
 15.5712 +"     {split(\$ 0, a, /\||\r/); split(a[2], s)};"\
 15.5713 +"     s[1]~/^[@?]/{print s[1], s[1]; next};"\
 15.5714 +"     s[1]~prfx {split(s[1],t,\"@\"); print t[1], substr(t[1],length(prfx))}"\
 15.5715 +"     ' prfx=^$ac_symprfx"
 15.5716 +  else
 15.5717 +    lt_cv_sys_global_symbol_pipe="sed -n -e 's/^.*[	 ]\($symcode$symcode*\)[	 ][	 ]*$ac_symprfx$sympat$opt_cr$/$symxfrm/p'"
 15.5718 +  fi
 15.5719 +
 15.5720 +  # Check to see that the pipe works correctly.
 15.5721 +  pipe_works=no
 15.5722 +
 15.5723 +  rm -f conftest*
 15.5724 +  cat > conftest.$ac_ext <<_LT_EOF
 15.5725 +#ifdef __cplusplus
 15.5726 +extern "C" {
 15.5727 +#endif
 15.5728 +char nm_test_var;
 15.5729 +void nm_test_func(void);
 15.5730 +void nm_test_func(void){}
 15.5731 +#ifdef __cplusplus
 15.5732 +}
 15.5733 +#endif
 15.5734 +int main(){nm_test_var='a';nm_test_func();return(0);}
 15.5735 +_LT_EOF
 15.5736 +
 15.5737 +  if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5
 15.5738 +  (eval $ac_compile) 2>&5
 15.5739 +  ac_status=$?
 15.5740 +  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
 15.5741 +  test $ac_status = 0; }; then
 15.5742 +    # Now try to grab the symbols.
 15.5743 +    nlist=conftest.nm
 15.5744 +    if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$NM conftest.$ac_objext \| "$lt_cv_sys_global_symbol_pipe" \> $nlist\""; } >&5
 15.5745 +  (eval $NM conftest.$ac_objext \| "$lt_cv_sys_global_symbol_pipe" \> $nlist) 2>&5
 15.5746 +  ac_status=$?
 15.5747 +  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
 15.5748 +  test $ac_status = 0; } && test -s "$nlist"; then
 15.5749 +      # Try sorting and uniquifying the output.
 15.5750 +      if sort "$nlist" | uniq > "$nlist"T; then
 15.5751 +	mv -f "$nlist"T "$nlist"
 15.5752 +      else
 15.5753 +	rm -f "$nlist"T
 15.5754 +      fi
 15.5755 +
 15.5756 +      # Make sure that we snagged all the symbols we need.
 15.5757 +      if $GREP ' nm_test_var$' "$nlist" >/dev/null; then
 15.5758 +	if $GREP ' nm_test_func$' "$nlist" >/dev/null; then
 15.5759 +	  cat <<_LT_EOF > conftest.$ac_ext
 15.5760 +#ifdef __cplusplus
 15.5761 +extern "C" {
 15.5762 +#endif
 15.5763 +
 15.5764 +_LT_EOF
 15.5765 +	  # Now generate the symbol file.
 15.5766 +	  eval "$lt_cv_sys_global_symbol_to_cdecl"' < "$nlist" | $GREP -v main >> conftest.$ac_ext'
 15.5767 +
 15.5768 +	  cat <<_LT_EOF >> conftest.$ac_ext
 15.5769 +
 15.5770 +/* The mapping between symbol names and symbols.  */
 15.5771 +const struct {
 15.5772 +  const char *name;
 15.5773 +  void       *address;
 15.5774 +}
 15.5775 +lt__PROGRAM__LTX_preloaded_symbols[] =
 15.5776 +{
 15.5777 +  { "@PROGRAM@", (void *) 0 },
 15.5778 +_LT_EOF
 15.5779 +	  $SED "s/^$symcode$symcode* \(.*\) \(.*\)$/  {\"\2\", (void *) \&\2},/" < "$nlist" | $GREP -v main >> conftest.$ac_ext
 15.5780 +	  cat <<\_LT_EOF >> conftest.$ac_ext
 15.5781 +  {0, (void *) 0}
 15.5782 +};
 15.5783 +
 15.5784 +/* This works around a problem in FreeBSD linker */
 15.5785 +#ifdef FREEBSD_WORKAROUND
 15.5786 +static const void *lt_preloaded_setup() {
 15.5787 +  return lt__PROGRAM__LTX_preloaded_symbols;
 15.5788 +}
 15.5789 +#endif
 15.5790 +
 15.5791 +#ifdef __cplusplus
 15.5792 +}
 15.5793 +#endif
 15.5794 +_LT_EOF
 15.5795 +	  # Now try linking the two files.
 15.5796 +	  mv conftest.$ac_objext conftstm.$ac_objext
 15.5797 +	  lt_save_LIBS="$LIBS"
 15.5798 +	  lt_save_CFLAGS="$CFLAGS"
 15.5799 +	  LIBS="conftstm.$ac_objext"
 15.5800 +	  CFLAGS="$CFLAGS$lt_prog_compiler_no_builtin_flag"
 15.5801 +	  if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_link\""; } >&5
 15.5802 +  (eval $ac_link) 2>&5
 15.5803 +  ac_status=$?
 15.5804 +  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
 15.5805 +  test $ac_status = 0; } && test -s conftest${ac_exeext}; then
 15.5806 +	    pipe_works=yes
 15.5807 +	  fi
 15.5808 +	  LIBS="$lt_save_LIBS"
 15.5809 +	  CFLAGS="$lt_save_CFLAGS"
 15.5810 +	else
 15.5811 +	  echo "cannot find nm_test_func in $nlist" >&5
 15.5812 +	fi
 15.5813 +      else
 15.5814 +	echo "cannot find nm_test_var in $nlist" >&5
 15.5815 +      fi
 15.5816 +    else
 15.5817 +      echo "cannot run $lt_cv_sys_global_symbol_pipe" >&5
 15.5818 +    fi
 15.5819 +  else
 15.5820 +    echo "$progname: failed program was:" >&5
 15.5821 +    cat conftest.$ac_ext >&5
 15.5822 +  fi
 15.5823 +  rm -rf conftest* conftst*
 15.5824 +
 15.5825 +  # Do not use the global_symbol_pipe unless it works.
 15.5826 +  if test "$pipe_works" = yes; then
 15.5827 +    break
 15.5828 +  else
 15.5829 +    lt_cv_sys_global_symbol_pipe=
 15.5830 +  fi
 15.5831 +done
 15.5832 +
 15.5833 +fi
 15.5834 +
 15.5835 +if test -z "$lt_cv_sys_global_symbol_pipe"; then
 15.5836 +  lt_cv_sys_global_symbol_to_cdecl=
 15.5837 +fi
 15.5838 +if test -z "$lt_cv_sys_global_symbol_pipe$lt_cv_sys_global_symbol_to_cdecl"; then
 15.5839 +  { $as_echo "$as_me:${as_lineno-$LINENO}: result: failed" >&5
 15.5840 +$as_echo "failed" >&6; }
 15.5841 +else
 15.5842 +  { $as_echo "$as_me:${as_lineno-$LINENO}: result: ok" >&5
 15.5843 +$as_echo "ok" >&6; }
 15.5844 +fi
 15.5845 +
 15.5846 +
 15.5847 +
 15.5848 +
 15.5849 +
 15.5850 +
 15.5851 +
 15.5852 +
 15.5853 +
 15.5854 +
 15.5855 +
 15.5856 +
 15.5857 +
 15.5858 +
 15.5859 +
 15.5860 +
 15.5861 +
 15.5862 +
 15.5863 +
 15.5864 +
 15.5865 +
 15.5866 +
 15.5867 +
 15.5868 +# Check whether --enable-libtool-lock was given.
 15.5869 +if test "${enable_libtool_lock+set}" = set; then :
 15.5870 +  enableval=$enable_libtool_lock;
 15.5871 +fi
 15.5872 +
 15.5873 +test "x$enable_libtool_lock" != xno && enable_libtool_lock=yes
 15.5874 +
 15.5875 +# Some flags need to be propagated to the compiler or linker for good
 15.5876 +# libtool support.
 15.5877 +case $host in
 15.5878 +ia64-*-hpux*)
 15.5879 +  # Find out which ABI we are using.
 15.5880 +  echo 'int i;' > conftest.$ac_ext
 15.5881 +  if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5
 15.5882 +  (eval $ac_compile) 2>&5
 15.5883 +  ac_status=$?
 15.5884 +  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
 15.5885 +  test $ac_status = 0; }; then
 15.5886 +    case `/usr/bin/file conftest.$ac_objext` in
 15.5887 +      *ELF-32*)
 15.5888 +	HPUX_IA64_MODE="32"
 15.5889 +	;;
 15.5890 +      *ELF-64*)
 15.5891 +	HPUX_IA64_MODE="64"
 15.5892 +	;;
 15.5893 +    esac
 15.5894 +  fi
 15.5895 +  rm -rf conftest*
 15.5896 +  ;;
 15.5897 +*-*-irix6*)
 15.5898 +  # Find out which ABI we are using.
 15.5899 +  echo '#line '$LINENO' "configure"' > conftest.$ac_ext
 15.5900 +  if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5
 15.5901 +  (eval $ac_compile) 2>&5
 15.5902 +  ac_status=$?
 15.5903 +  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
 15.5904 +  test $ac_status = 0; }; then
 15.5905 +    if test "$lt_cv_prog_gnu_ld" = yes; then
 15.5906 +      case `/usr/bin/file conftest.$ac_objext` in
 15.5907 +	*32-bit*)
 15.5908 +	  LD="${LD-ld} -melf32bsmip"
 15.5909 +	  ;;
 15.5910 +	*N32*)
 15.5911 +	  LD="${LD-ld} -melf32bmipn32"
 15.5912 +	  ;;
 15.5913 +	*64-bit*)
 15.5914 +	  LD="${LD-ld} -melf64bmip"
 15.5915 +	;;
 15.5916 +      esac
 15.5917 +    else
 15.5918 +      case `/usr/bin/file conftest.$ac_objext` in
 15.5919 +	*32-bit*)
 15.5920 +	  LD="${LD-ld} -32"
 15.5921 +	  ;;
 15.5922 +	*N32*)
 15.5923 +	  LD="${LD-ld} -n32"
 15.5924 +	  ;;
 15.5925 +	*64-bit*)
 15.5926 +	  LD="${LD-ld} -64"
 15.5927 +	  ;;
 15.5928 +      esac
 15.5929 +    fi
 15.5930 +  fi
 15.5931 +  rm -rf conftest*
 15.5932 +  ;;
 15.5933 +
 15.5934 +x86_64-*kfreebsd*-gnu|x86_64-*linux*|ppc*-*linux*|powerpc*-*linux*| \
 15.5935 +s390*-*linux*|s390*-*tpf*|sparc*-*linux*)
 15.5936 +  # Find out which ABI we are using.
 15.5937 +  echo 'int i;' > conftest.$ac_ext
 15.5938 +  if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5
 15.5939 +  (eval $ac_compile) 2>&5
 15.5940 +  ac_status=$?
 15.5941 +  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
 15.5942 +  test $ac_status = 0; }; then
 15.5943 +    case `/usr/bin/file conftest.o` in
 15.5944 +      *32-bit*)
 15.5945 +	case $host in
 15.5946 +	  x86_64-*kfreebsd*-gnu)
 15.5947 +	    LD="${LD-ld} -m elf_i386_fbsd"
 15.5948 +	    ;;
 15.5949 +	  x86_64-*linux*)
 15.5950 +	    LD="${LD-ld} -m elf_i386"
 15.5951 +	    ;;
 15.5952 +	  ppc64-*linux*|powerpc64-*linux*)
 15.5953 +	    LD="${LD-ld} -m elf32ppclinux"
 15.5954 +	    ;;
 15.5955 +	  s390x-*linux*)
 15.5956 +	    LD="${LD-ld} -m elf_s390"
 15.5957 +	    ;;
 15.5958 +	  sparc64-*linux*)
 15.5959 +	    LD="${LD-ld} -m elf32_sparc"
 15.5960 +	    ;;
 15.5961 +	esac
 15.5962 +	;;
 15.5963 +      *64-bit*)
 15.5964 +	case $host in
 15.5965 +	  x86_64-*kfreebsd*-gnu)
 15.5966 +	    LD="${LD-ld} -m elf_x86_64_fbsd"
 15.5967 +	    ;;
 15.5968 +	  x86_64-*linux*)
 15.5969 +	    LD="${LD-ld} -m elf_x86_64"
 15.5970 +	    ;;
 15.5971 +	  ppc*-*linux*|powerpc*-*linux*)
 15.5972 +	    LD="${LD-ld} -m elf64ppc"
 15.5973 +	    ;;
 15.5974 +	  s390*-*linux*|s390*-*tpf*)
 15.5975 +	    LD="${LD-ld} -m elf64_s390"
 15.5976 +	    ;;
 15.5977 +	  sparc*-*linux*)
 15.5978 +	    LD="${LD-ld} -m elf64_sparc"
 15.5979 +	    ;;
 15.5980 +	esac
 15.5981 +	;;
 15.5982 +    esac
 15.5983 +  fi
 15.5984 +  rm -rf conftest*
 15.5985 +  ;;
 15.5986 +
 15.5987 +*-*-sco3.2v5*)
 15.5988 +  # On SCO OpenServer 5, we need -belf to get full-featured binaries.
 15.5989 +  SAVE_CFLAGS="$CFLAGS"
 15.5990 +  CFLAGS="$CFLAGS -belf"
 15.5991 +  { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the C compiler needs -belf" >&5
 15.5992 +$as_echo_n "checking whether the C compiler needs -belf... " >&6; }
 15.5993 +if test "${lt_cv_cc_needs_belf+set}" = set; then :
 15.5994 +  $as_echo_n "(cached) " >&6
 15.5995 +else
 15.5996 +  ac_ext=c
 15.5997 +ac_cpp='$CPP $CPPFLAGS'
 15.5998 +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
 15.5999 +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
 15.6000 +ac_compiler_gnu=$ac_cv_c_compiler_gnu
 15.6001 +
 15.6002 +     cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 15.6003 +/* end confdefs.h.  */
 15.6004 +
 15.6005 +int
 15.6006 +main ()
 15.6007 +{
 15.6008 +
 15.6009 +  ;
 15.6010 +  return 0;
 15.6011 +}
 15.6012 +_ACEOF
 15.6013 +if ac_fn_c_try_link "$LINENO"; then :
 15.6014 +  lt_cv_cc_needs_belf=yes
 15.6015 +else
 15.6016 +  lt_cv_cc_needs_belf=no
 15.6017 +fi
 15.6018 +rm -f core conftest.err conftest.$ac_objext \
 15.6019 +    conftest$ac_exeext conftest.$ac_ext
 15.6020 +     ac_ext=c
 15.6021 +ac_cpp='$CPP $CPPFLAGS'
 15.6022 +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
 15.6023 +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
 15.6024 +ac_compiler_gnu=$ac_cv_c_compiler_gnu
 15.6025 +
 15.6026 +fi
 15.6027 +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_cc_needs_belf" >&5
 15.6028 +$as_echo "$lt_cv_cc_needs_belf" >&6; }
 15.6029 +  if test x"$lt_cv_cc_needs_belf" != x"yes"; then
 15.6030 +    # this is probably gcc 2.8.0, egcs 1.0 or newer; no need for -belf
 15.6031 +    CFLAGS="$SAVE_CFLAGS"
 15.6032 +  fi
 15.6033 +  ;;
 15.6034 +sparc*-*solaris*)
 15.6035 +  # Find out which ABI we are using.
 15.6036 +  echo 'int i;' > conftest.$ac_ext
 15.6037 +  if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5
 15.6038 +  (eval $ac_compile) 2>&5
 15.6039 +  ac_status=$?
 15.6040 +  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
 15.6041 +  test $ac_status = 0; }; then
 15.6042 +    case `/usr/bin/file conftest.o` in
 15.6043 +    *64-bit*)
 15.6044 +      case $lt_cv_prog_gnu_ld in
 15.6045 +      yes*) LD="${LD-ld} -m elf64_sparc" ;;
 15.6046 +      *)
 15.6047 +	if ${LD-ld} -64 -r -o conftest2.o conftest.o >/dev/null 2>&1; then
 15.6048 +	  LD="${LD-ld} -64"
 15.6049 +	fi
 15.6050 +	;;
 15.6051 +      esac
 15.6052 +      ;;
 15.6053 +    esac
 15.6054 +  fi
 15.6055 +  rm -rf conftest*
 15.6056 +  ;;
 15.6057 +esac
 15.6058 +
 15.6059 +need_locks="$enable_libtool_lock"
 15.6060 +
 15.6061 +
 15.6062 +  case $host_os in
 15.6063 +    rhapsody* | darwin*)
 15.6064 +    if test -n "$ac_tool_prefix"; then
 15.6065 +  # Extract the first word of "${ac_tool_prefix}dsymutil", so it can be a program name with args.
 15.6066 +set dummy ${ac_tool_prefix}dsymutil; ac_word=$2
 15.6067 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
 15.6068 +$as_echo_n "checking for $ac_word... " >&6; }
 15.6069 +if test "${ac_cv_prog_DSYMUTIL+set}" = set; then :
 15.6070 +  $as_echo_n "(cached) " >&6
 15.6071 +else
 15.6072 +  if test -n "$DSYMUTIL"; then
 15.6073 +  ac_cv_prog_DSYMUTIL="$DSYMUTIL" # Let the user override the test.
 15.6074 +else
 15.6075 +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
 15.6076 +for as_dir in $PATH
 15.6077 +do
 15.6078 +  IFS=$as_save_IFS
 15.6079 +  test -z "$as_dir" && as_dir=.
 15.6080 +    for ac_exec_ext in '' $ac_executable_extensions; do
 15.6081 +  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
 15.6082 +    ac_cv_prog_DSYMUTIL="${ac_tool_prefix}dsymutil"
 15.6083 +    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
 15.6084 +    break 2
 15.6085 +  fi
 15.6086 +done
 15.6087 +  done
 15.6088 +IFS=$as_save_IFS
 15.6089 +
 15.6090 +fi
 15.6091 +fi
 15.6092 +DSYMUTIL=$ac_cv_prog_DSYMUTIL
 15.6093 +if test -n "$DSYMUTIL"; then
 15.6094 +  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $DSYMUTIL" >&5
 15.6095 +$as_echo "$DSYMUTIL" >&6; }
 15.6096 +else
 15.6097 +  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
 15.6098 +$as_echo "no" >&6; }
 15.6099 +fi
 15.6100 +
 15.6101 +
 15.6102 +fi
 15.6103 +if test -z "$ac_cv_prog_DSYMUTIL"; then
 15.6104 +  ac_ct_DSYMUTIL=$DSYMUTIL
 15.6105 +  # Extract the first word of "dsymutil", so it can be a program name with args.
 15.6106 +set dummy dsymutil; ac_word=$2
 15.6107 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
 15.6108 +$as_echo_n "checking for $ac_word... " >&6; }
 15.6109 +if test "${ac_cv_prog_ac_ct_DSYMUTIL+set}" = set; then :
 15.6110 +  $as_echo_n "(cached) " >&6
 15.6111 +else
 15.6112 +  if test -n "$ac_ct_DSYMUTIL"; then
 15.6113 +  ac_cv_prog_ac_ct_DSYMUTIL="$ac_ct_DSYMUTIL" # Let the user override the test.
 15.6114 +else
 15.6115 +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
 15.6116 +for as_dir in $PATH
 15.6117 +do
 15.6118 +  IFS=$as_save_IFS
 15.6119 +  test -z "$as_dir" && as_dir=.
 15.6120 +    for ac_exec_ext in '' $ac_executable_extensions; do
 15.6121 +  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
 15.6122 +    ac_cv_prog_ac_ct_DSYMUTIL="dsymutil"
 15.6123 +    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
 15.6124 +    break 2
 15.6125 +  fi
 15.6126 +done
 15.6127 +  done
 15.6128 +IFS=$as_save_IFS
 15.6129 +
 15.6130 +fi
 15.6131 +fi
 15.6132 +ac_ct_DSYMUTIL=$ac_cv_prog_ac_ct_DSYMUTIL
 15.6133 +if test -n "$ac_ct_DSYMUTIL"; then
 15.6134 +  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_DSYMUTIL" >&5
 15.6135 +$as_echo "$ac_ct_DSYMUTIL" >&6; }
 15.6136 +else
 15.6137 +  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
 15.6138 +$as_echo "no" >&6; }
 15.6139 +fi
 15.6140 +
 15.6141 +  if test "x$ac_ct_DSYMUTIL" = x; then
 15.6142 +    DSYMUTIL=":"
 15.6143 +  else
 15.6144 +    case $cross_compiling:$ac_tool_warned in
 15.6145 +yes:)
 15.6146 +{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5
 15.6147 +$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}
 15.6148 +ac_tool_warned=yes ;;
 15.6149 +esac
 15.6150 +    DSYMUTIL=$ac_ct_DSYMUTIL
 15.6151 +  fi
 15.6152 +else
 15.6153 +  DSYMUTIL="$ac_cv_prog_DSYMUTIL"
 15.6154 +fi
 15.6155 +
 15.6156 +    if test -n "$ac_tool_prefix"; then
 15.6157 +  # Extract the first word of "${ac_tool_prefix}nmedit", so it can be a program name with args.
 15.6158 +set dummy ${ac_tool_prefix}nmedit; ac_word=$2
 15.6159 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
 15.6160 +$as_echo_n "checking for $ac_word... " >&6; }
 15.6161 +if test "${ac_cv_prog_NMEDIT+set}" = set; then :
 15.6162 +  $as_echo_n "(cached) " >&6
 15.6163 +else
 15.6164 +  if test -n "$NMEDIT"; then
 15.6165 +  ac_cv_prog_NMEDIT="$NMEDIT" # Let the user override the test.
 15.6166 +else
 15.6167 +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
 15.6168 +for as_dir in $PATH
 15.6169 +do
 15.6170 +  IFS=$as_save_IFS
 15.6171 +  test -z "$as_dir" && as_dir=.
 15.6172 +    for ac_exec_ext in '' $ac_executable_extensions; do
 15.6173 +  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
 15.6174 +    ac_cv_prog_NMEDIT="${ac_tool_prefix}nmedit"
 15.6175 +    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
 15.6176 +    break 2
 15.6177 +  fi
 15.6178 +done
 15.6179 +  done
 15.6180 +IFS=$as_save_IFS
 15.6181 +
 15.6182 +fi
 15.6183 +fi
 15.6184 +NMEDIT=$ac_cv_prog_NMEDIT
 15.6185 +if test -n "$NMEDIT"; then
 15.6186 +  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $NMEDIT" >&5
 15.6187 +$as_echo "$NMEDIT" >&6; }
 15.6188 +else
 15.6189 +  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
 15.6190 +$as_echo "no" >&6; }
 15.6191 +fi
 15.6192 +
 15.6193 +
 15.6194 +fi
 15.6195 +if test -z "$ac_cv_prog_NMEDIT"; then
 15.6196 +  ac_ct_NMEDIT=$NMEDIT
 15.6197 +  # Extract the first word of "nmedit", so it can be a program name with args.
 15.6198 +set dummy nmedit; ac_word=$2
 15.6199 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
 15.6200 +$as_echo_n "checking for $ac_word... " >&6; }
 15.6201 +if test "${ac_cv_prog_ac_ct_NMEDIT+set}" = set; then :
 15.6202 +  $as_echo_n "(cached) " >&6
 15.6203 +else
 15.6204 +  if test -n "$ac_ct_NMEDIT"; then
 15.6205 +  ac_cv_prog_ac_ct_NMEDIT="$ac_ct_NMEDIT" # Let the user override the test.
 15.6206 +else
 15.6207 +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
 15.6208 +for as_dir in $PATH
 15.6209 +do
 15.6210 +  IFS=$as_save_IFS
 15.6211 +  test -z "$as_dir" && as_dir=.
 15.6212 +    for ac_exec_ext in '' $ac_executable_extensions; do
 15.6213 +  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
 15.6214 +    ac_cv_prog_ac_ct_NMEDIT="nmedit"
 15.6215 +    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
 15.6216 +    break 2
 15.6217 +  fi
 15.6218 +done
 15.6219 +  done
 15.6220 +IFS=$as_save_IFS
 15.6221 +
 15.6222 +fi
 15.6223 +fi
 15.6224 +ac_ct_NMEDIT=$ac_cv_prog_ac_ct_NMEDIT
 15.6225 +if test -n "$ac_ct_NMEDIT"; then
 15.6226 +  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_NMEDIT" >&5
 15.6227 +$as_echo "$ac_ct_NMEDIT" >&6; }
 15.6228 +else
 15.6229 +  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
 15.6230 +$as_echo "no" >&6; }
 15.6231 +fi
 15.6232 +
 15.6233 +  if test "x$ac_ct_NMEDIT" = x; then
 15.6234 +    NMEDIT=":"
 15.6235 +  else
 15.6236 +    case $cross_compiling:$ac_tool_warned in
 15.6237 +yes:)
 15.6238 +{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5
 15.6239 +$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}
 15.6240 +ac_tool_warned=yes ;;
 15.6241 +esac
 15.6242 +    NMEDIT=$ac_ct_NMEDIT
 15.6243 +  fi
 15.6244 +else
 15.6245 +  NMEDIT="$ac_cv_prog_NMEDIT"
 15.6246 +fi
 15.6247 +
 15.6248 +    if test -n "$ac_tool_prefix"; then
 15.6249 +  # Extract the first word of "${ac_tool_prefix}lipo", so it can be a program name with args.
 15.6250 +set dummy ${ac_tool_prefix}lipo; ac_word=$2
 15.6251 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
 15.6252 +$as_echo_n "checking for $ac_word... " >&6; }
 15.6253 +if test "${ac_cv_prog_LIPO+set}" = set; then :
 15.6254 +  $as_echo_n "(cached) " >&6
 15.6255 +else
 15.6256 +  if test -n "$LIPO"; then
 15.6257 +  ac_cv_prog_LIPO="$LIPO" # Let the user override the test.
 15.6258 +else
 15.6259 +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
 15.6260 +for as_dir in $PATH
 15.6261 +do
 15.6262 +  IFS=$as_save_IFS
 15.6263 +  test -z "$as_dir" && as_dir=.
 15.6264 +    for ac_exec_ext in '' $ac_executable_extensions; do
 15.6265 +  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
 15.6266 +    ac_cv_prog_LIPO="${ac_tool_prefix}lipo"
 15.6267 +    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
 15.6268 +    break 2
 15.6269 +  fi
 15.6270 +done
 15.6271 +  done
 15.6272 +IFS=$as_save_IFS
 15.6273 +
 15.6274 +fi
 15.6275 +fi
 15.6276 +LIPO=$ac_cv_prog_LIPO
 15.6277 +if test -n "$LIPO"; then
 15.6278 +  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $LIPO" >&5
 15.6279 +$as_echo "$LIPO" >&6; }
 15.6280 +else
 15.6281 +  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
 15.6282 +$as_echo "no" >&6; }
 15.6283 +fi
 15.6284 +
 15.6285 +
 15.6286 +fi
 15.6287 +if test -z "$ac_cv_prog_LIPO"; then
 15.6288 +  ac_ct_LIPO=$LIPO
 15.6289 +  # Extract the first word of "lipo", so it can be a program name with args.
 15.6290 +set dummy lipo; ac_word=$2
 15.6291 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
 15.6292 +$as_echo_n "checking for $ac_word... " >&6; }
 15.6293 +if test "${ac_cv_prog_ac_ct_LIPO+set}" = set; then :
 15.6294 +  $as_echo_n "(cached) " >&6
 15.6295 +else
 15.6296 +  if test -n "$ac_ct_LIPO"; then
 15.6297 +  ac_cv_prog_ac_ct_LIPO="$ac_ct_LIPO" # Let the user override the test.
 15.6298 +else
 15.6299 +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
 15.6300 +for as_dir in $PATH
 15.6301 +do
 15.6302 +  IFS=$as_save_IFS
 15.6303 +  test -z "$as_dir" && as_dir=.
 15.6304 +    for ac_exec_ext in '' $ac_executable_extensions; do
 15.6305 +  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
 15.6306 +    ac_cv_prog_ac_ct_LIPO="lipo"
 15.6307 +    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
 15.6308 +    break 2
 15.6309 +  fi
 15.6310 +done
 15.6311 +  done
 15.6312 +IFS=$as_save_IFS
 15.6313 +
 15.6314 +fi
 15.6315 +fi
 15.6316 +ac_ct_LIPO=$ac_cv_prog_ac_ct_LIPO
 15.6317 +if test -n "$ac_ct_LIPO"; then
 15.6318 +  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_LIPO" >&5
 15.6319 +$as_echo "$ac_ct_LIPO" >&6; }
 15.6320 +else
 15.6321 +  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
 15.6322 +$as_echo "no" >&6; }
 15.6323 +fi
 15.6324 +
 15.6325 +  if test "x$ac_ct_LIPO" = x; then
 15.6326 +    LIPO=":"
 15.6327 +  else
 15.6328 +    case $cross_compiling:$ac_tool_warned in
 15.6329 +yes:)
 15.6330 +{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5
 15.6331 +$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}
 15.6332 +ac_tool_warned=yes ;;
 15.6333 +esac
 15.6334 +    LIPO=$ac_ct_LIPO
 15.6335 +  fi
 15.6336 +else
 15.6337 +  LIPO="$ac_cv_prog_LIPO"
 15.6338 +fi
 15.6339 +
 15.6340 +    if test -n "$ac_tool_prefix"; then
 15.6341 +  # Extract the first word of "${ac_tool_prefix}otool", so it can be a program name with args.
 15.6342 +set dummy ${ac_tool_prefix}otool; ac_word=$2
 15.6343 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
 15.6344 +$as_echo_n "checking for $ac_word... " >&6; }
 15.6345 +if test "${ac_cv_prog_OTOOL+set}" = set; then :
 15.6346 +  $as_echo_n "(cached) " >&6
 15.6347 +else
 15.6348 +  if test -n "$OTOOL"; then
 15.6349 +  ac_cv_prog_OTOOL="$OTOOL" # Let the user override the test.
 15.6350 +else
 15.6351 +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
 15.6352 +for as_dir in $PATH
 15.6353 +do
 15.6354 +  IFS=$as_save_IFS
 15.6355 +  test -z "$as_dir" && as_dir=.
 15.6356 +    for ac_exec_ext in '' $ac_executable_extensions; do
 15.6357 +  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
 15.6358 +    ac_cv_prog_OTOOL="${ac_tool_prefix}otool"
 15.6359 +    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
 15.6360 +    break 2
 15.6361 +  fi
 15.6362 +done
 15.6363 +  done
 15.6364 +IFS=$as_save_IFS
 15.6365 +
 15.6366 +fi
 15.6367 +fi
 15.6368 +OTOOL=$ac_cv_prog_OTOOL
 15.6369 +if test -n "$OTOOL"; then
 15.6370 +  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $OTOOL" >&5
 15.6371 +$as_echo "$OTOOL" >&6; }
 15.6372 +else
 15.6373 +  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
 15.6374 +$as_echo "no" >&6; }
 15.6375 +fi
 15.6376 +
 15.6377 +
 15.6378 +fi
 15.6379 +if test -z "$ac_cv_prog_OTOOL"; then
 15.6380 +  ac_ct_OTOOL=$OTOOL
 15.6381 +  # Extract the first word of "otool", so it can be a program name with args.
 15.6382 +set dummy otool; ac_word=$2
 15.6383 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
 15.6384 +$as_echo_n "checking for $ac_word... " >&6; }
 15.6385 +if test "${ac_cv_prog_ac_ct_OTOOL+set}" = set; then :
 15.6386 +  $as_echo_n "(cached) " >&6
 15.6387 +else
 15.6388 +  if test -n "$ac_ct_OTOOL"; then
 15.6389 +  ac_cv_prog_ac_ct_OTOOL="$ac_ct_OTOOL" # Let the user override the test.
 15.6390 +else
 15.6391 +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
 15.6392 +for as_dir in $PATH
 15.6393 +do
 15.6394 +  IFS=$as_save_IFS
 15.6395 +  test -z "$as_dir" && as_dir=.
 15.6396 +    for ac_exec_ext in '' $ac_executable_extensions; do
 15.6397 +  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
 15.6398 +    ac_cv_prog_ac_ct_OTOOL="otool"
 15.6399 +    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
 15.6400 +    break 2
 15.6401 +  fi
 15.6402 +done
 15.6403 +  done
 15.6404 +IFS=$as_save_IFS
 15.6405 +
 15.6406 +fi
 15.6407 +fi
 15.6408 +ac_ct_OTOOL=$ac_cv_prog_ac_ct_OTOOL
 15.6409 +if test -n "$ac_ct_OTOOL"; then
 15.6410 +  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_OTOOL" >&5
 15.6411 +$as_echo "$ac_ct_OTOOL" >&6; }
 15.6412 +else
 15.6413 +  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
 15.6414 +$as_echo "no" >&6; }
 15.6415 +fi
 15.6416 +
 15.6417 +  if test "x$ac_ct_OTOOL" = x; then
 15.6418 +    OTOOL=":"
 15.6419 +  else
 15.6420 +    case $cross_compiling:$ac_tool_warned in
 15.6421 +yes:)
 15.6422 +{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5
 15.6423 +$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}
 15.6424 +ac_tool_warned=yes ;;
 15.6425 +esac
 15.6426 +    OTOOL=$ac_ct_OTOOL
 15.6427 +  fi
 15.6428 +else
 15.6429 +  OTOOL="$ac_cv_prog_OTOOL"
 15.6430 +fi
 15.6431 +
 15.6432 +    if test -n "$ac_tool_prefix"; then
 15.6433 +  # Extract the first word of "${ac_tool_prefix}otool64", so it can be a program name with args.
 15.6434 +set dummy ${ac_tool_prefix}otool64; ac_word=$2
 15.6435 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
 15.6436 +$as_echo_n "checking for $ac_word... " >&6; }
 15.6437 +if test "${ac_cv_prog_OTOOL64+set}" = set; then :
 15.6438 +  $as_echo_n "(cached) " >&6
 15.6439 +else
 15.6440 +  if test -n "$OTOOL64"; then
 15.6441 +  ac_cv_prog_OTOOL64="$OTOOL64" # Let the user override the test.
 15.6442 +else
 15.6443 +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
 15.6444 +for as_dir in $PATH
 15.6445 +do
 15.6446 +  IFS=$as_save_IFS
 15.6447 +  test -z "$as_dir" && as_dir=.
 15.6448 +    for ac_exec_ext in '' $ac_executable_extensions; do
 15.6449 +  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
 15.6450 +    ac_cv_prog_OTOOL64="${ac_tool_prefix}otool64"
 15.6451 +    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
 15.6452 +    break 2
 15.6453 +  fi
 15.6454 +done
 15.6455 +  done
 15.6456 +IFS=$as_save_IFS
 15.6457 +
 15.6458 +fi
 15.6459 +fi
 15.6460 +OTOOL64=$ac_cv_prog_OTOOL64
 15.6461 +if test -n "$OTOOL64"; then
 15.6462 +  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $OTOOL64" >&5
 15.6463 +$as_echo "$OTOOL64" >&6; }
 15.6464 +else
 15.6465 +  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
 15.6466 +$as_echo "no" >&6; }
 15.6467 +fi
 15.6468 +
 15.6469 +
 15.6470 +fi
 15.6471 +if test -z "$ac_cv_prog_OTOOL64"; then
 15.6472 +  ac_ct_OTOOL64=$OTOOL64
 15.6473 +  # Extract the first word of "otool64", so it can be a program name with args.
 15.6474 +set dummy otool64; ac_word=$2
 15.6475 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
 15.6476 +$as_echo_n "checking for $ac_word... " >&6; }
 15.6477 +if test "${ac_cv_prog_ac_ct_OTOOL64+set}" = set; then :
 15.6478 +  $as_echo_n "(cached) " >&6
 15.6479 +else
 15.6480 +  if test -n "$ac_ct_OTOOL64"; then
 15.6481 +  ac_cv_prog_ac_ct_OTOOL64="$ac_ct_OTOOL64" # Let the user override the test.
 15.6482 +else
 15.6483 +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
 15.6484 +for as_dir in $PATH
 15.6485 +do
 15.6486 +  IFS=$as_save_IFS
 15.6487 +  test -z "$as_dir" && as_dir=.
 15.6488 +    for ac_exec_ext in '' $ac_executable_extensions; do
 15.6489 +  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
 15.6490 +    ac_cv_prog_ac_ct_OTOOL64="otool64"
 15.6491 +    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
 15.6492 +    break 2
 15.6493 +  fi
 15.6494 +done
 15.6495 +  done
 15.6496 +IFS=$as_save_IFS
 15.6497 +
 15.6498 +fi
 15.6499 +fi
 15.6500 +ac_ct_OTOOL64=$ac_cv_prog_ac_ct_OTOOL64
 15.6501 +if test -n "$ac_ct_OTOOL64"; then
 15.6502 +  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_OTOOL64" >&5
 15.6503 +$as_echo "$ac_ct_OTOOL64" >&6; }
 15.6504 +else
 15.6505 +  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
 15.6506 +$as_echo "no" >&6; }
 15.6507 +fi
 15.6508 +
 15.6509 +  if test "x$ac_ct_OTOOL64" = x; then
 15.6510 +    OTOOL64=":"
 15.6511 +  else
 15.6512 +    case $cross_compiling:$ac_tool_warned in
 15.6513 +yes:)
 15.6514 +{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5
 15.6515 +$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}
 15.6516 +ac_tool_warned=yes ;;
 15.6517 +esac
 15.6518 +    OTOOL64=$ac_ct_OTOOL64
 15.6519 +  fi
 15.6520 +else
 15.6521 +  OTOOL64="$ac_cv_prog_OTOOL64"
 15.6522 +fi
 15.6523 +
 15.6524 +
 15.6525 +
 15.6526 +
 15.6527 +
 15.6528 +
 15.6529 +
 15.6530 +
 15.6531 +
 15.6532 +
 15.6533 +
 15.6534 +
 15.6535 +
 15.6536 +
 15.6537 +
 15.6538 +
 15.6539 +
 15.6540 +
 15.6541 +
 15.6542 +
 15.6543 +
 15.6544 +
 15.6545 +
 15.6546 +
 15.6547 +
 15.6548 +
 15.6549 +
 15.6550 +    { $as_echo "$as_me:${as_lineno-$LINENO}: checking for -single_module linker flag" >&5
 15.6551 +$as_echo_n "checking for -single_module linker flag... " >&6; }
 15.6552 +if test "${lt_cv_apple_cc_single_mod+set}" = set; then :
 15.6553 +  $as_echo_n "(cached) " >&6
 15.6554 +else
 15.6555 +  lt_cv_apple_cc_single_mod=no
 15.6556 +      if test -z "${LT_MULTI_MODULE}"; then
 15.6557 +	# By default we will add the -single_module flag. You can override
 15.6558 +	# by either setting the environment variable LT_MULTI_MODULE
 15.6559 +	# non-empty at configure time, or by adding -multi_module to the
 15.6560 +	# link flags.
 15.6561 +	rm -rf libconftest.dylib*
 15.6562 +	echo "int foo(void){return 1;}" > conftest.c
 15.6563 +	echo "$LTCC $LTCFLAGS $LDFLAGS -o libconftest.dylib \
 15.6564 +-dynamiclib -Wl,-single_module conftest.c" >&5
 15.6565 +	$LTCC $LTCFLAGS $LDFLAGS -o libconftest.dylib \
 15.6566 +	  -dynamiclib -Wl,-single_module conftest.c 2>conftest.err
 15.6567 +        _lt_result=$?
 15.6568 +	if test -f libconftest.dylib && test ! -s conftest.err && test $_lt_result = 0; then
 15.6569 +	  lt_cv_apple_cc_single_mod=yes
 15.6570 +	else
 15.6571 +	  cat conftest.err >&5
 15.6572 +	fi
 15.6573 +	rm -rf libconftest.dylib*
 15.6574 +	rm -f conftest.*
 15.6575 +      fi
 15.6576 +fi
 15.6577 +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_apple_cc_single_mod" >&5
 15.6578 +$as_echo "$lt_cv_apple_cc_single_mod" >&6; }
 15.6579 +    { $as_echo "$as_me:${as_lineno-$LINENO}: checking for -exported_symbols_list linker flag" >&5
 15.6580 +$as_echo_n "checking for -exported_symbols_list linker flag... " >&6; }
 15.6581 +if test "${lt_cv_ld_exported_symbols_list+set}" = set; then :
 15.6582 +  $as_echo_n "(cached) " >&6
 15.6583 +else
 15.6584 +  lt_cv_ld_exported_symbols_list=no
 15.6585 +      save_LDFLAGS=$LDFLAGS
 15.6586 +      echo "_main" > conftest.sym
 15.6587 +      LDFLAGS="$LDFLAGS -Wl,-exported_symbols_list,conftest.sym"
 15.6588 +      cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 15.6589 +/* end confdefs.h.  */
 15.6590 +
 15.6591 +int
 15.6592 +main ()
 15.6593 +{
 15.6594 +
 15.6595 +  ;
 15.6596 +  return 0;
 15.6597 +}
 15.6598 +_ACEOF
 15.6599 +if ac_fn_c_try_link "$LINENO"; then :
 15.6600 +  lt_cv_ld_exported_symbols_list=yes
 15.6601 +else
 15.6602 +  lt_cv_ld_exported_symbols_list=no
 15.6603 +fi
 15.6604 +rm -f core conftest.err conftest.$ac_objext \
 15.6605 +    conftest$ac_exeext conftest.$ac_ext
 15.6606 +	LDFLAGS="$save_LDFLAGS"
 15.6607 +
 15.6608 +fi
 15.6609 +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_ld_exported_symbols_list" >&5
 15.6610 +$as_echo "$lt_cv_ld_exported_symbols_list" >&6; }
 15.6611 +    { $as_echo "$as_me:${as_lineno-$LINENO}: checking for -force_load linker flag" >&5
 15.6612 +$as_echo_n "checking for -force_load linker flag... " >&6; }
 15.6613 +if test "${lt_cv_ld_force_load+set}" = set; then :
 15.6614 +  $as_echo_n "(cached) " >&6
 15.6615 +else
 15.6616 +  lt_cv_ld_force_load=no
 15.6617 +      cat > conftest.c << _LT_EOF
 15.6618 +int forced_loaded() { return 2;}
 15.6619 +_LT_EOF
 15.6620 +      echo "$LTCC $LTCFLAGS -c -o conftest.o conftest.c" >&5
 15.6621 +      $LTCC $LTCFLAGS -c -o conftest.o conftest.c 2>&5
 15.6622 +      echo "$AR cru libconftest.a conftest.o" >&5
 15.6623 +      $AR cru libconftest.a conftest.o 2>&5
 15.6624 +      cat > conftest.c << _LT_EOF
 15.6625 +int main() { return 0;}
 15.6626 +_LT_EOF
 15.6627 +      echo "$LTCC $LTCFLAGS $LDFLAGS -o conftest conftest.c -Wl,-force_load,./libconftest.a" >&5
 15.6628 +      $LTCC $LTCFLAGS $LDFLAGS -o conftest conftest.c -Wl,-force_load,./libconftest.a 2>conftest.err
 15.6629 +      _lt_result=$?
 15.6630 +      if test -f conftest && test ! -s conftest.err && test $_lt_result = 0 && $GREP forced_load conftest 2>&1 >/dev/null; then
 15.6631 +	lt_cv_ld_force_load=yes
 15.6632 +      else
 15.6633 +	cat conftest.err >&5
 15.6634 +      fi
 15.6635 +        rm -f conftest.err libconftest.a conftest conftest.c
 15.6636 +        rm -rf conftest.dSYM
 15.6637 +
 15.6638 +fi
 15.6639 +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_ld_force_load" >&5
 15.6640 +$as_echo "$lt_cv_ld_force_load" >&6; }
 15.6641 +    case $host_os in
 15.6642 +    rhapsody* | darwin1.[012])
 15.6643 +      _lt_dar_allow_undefined='${wl}-undefined ${wl}suppress' ;;
 15.6644 +    darwin1.*)
 15.6645 +      _lt_dar_allow_undefined='${wl}-flat_namespace ${wl}-undefined ${wl}suppress' ;;
 15.6646 +    darwin*) # darwin 5.x on
 15.6647 +      # if running on 10.5 or later, the deployment target defaults
 15.6648 +      # to the OS version, if on x86, and 10.4, the deployment
 15.6649 +      # target defaults to 10.4. Don't you love it?
 15.6650 +      case ${MACOSX_DEPLOYMENT_TARGET-10.0},$host in
 15.6651 +	10.0,*86*-darwin8*|10.0,*-darwin[91]*)
 15.6652 +	  _lt_dar_allow_undefined='${wl}-undefined ${wl}dynamic_lookup' ;;
 15.6653 +	10.[012]*)
 15.6654 +	  _lt_dar_allow_undefined='${wl}-flat_namespace ${wl}-undefined ${wl}suppress' ;;
 15.6655 +	10.*)
 15.6656 +	  _lt_dar_allow_undefined='${wl}-undefined ${wl}dynamic_lookup' ;;
 15.6657 +      esac
 15.6658 +    ;;
 15.6659 +  esac
 15.6660 +    if test "$lt_cv_apple_cc_single_mod" = "yes"; then
 15.6661 +      _lt_dar_single_mod='$single_module'
 15.6662 +    fi
 15.6663 +    if test "$lt_cv_ld_exported_symbols_list" = "yes"; then
 15.6664 +      _lt_dar_export_syms=' ${wl}-exported_symbols_list,$output_objdir/${libname}-symbols.expsym'
 15.6665 +    else
 15.6666 +      _lt_dar_export_syms='~$NMEDIT -s $output_objdir/${libname}-symbols.expsym ${lib}'
 15.6667 +    fi
 15.6668 +    if test "$DSYMUTIL" != ":" && test "$lt_cv_ld_force_load" = "no"; then
 15.6669 +      _lt_dsymutil='~$DSYMUTIL $lib || :'
 15.6670 +    else
 15.6671 +      _lt_dsymutil=
 15.6672 +    fi
 15.6673 +    ;;
 15.6674 +  esac
 15.6675 +
 15.6676 +ac_ext=c
 15.6677 +ac_cpp='$CPP $CPPFLAGS'
 15.6678 +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
 15.6679 +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
 15.6680 +ac_compiler_gnu=$ac_cv_c_compiler_gnu
 15.6681 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking how to run the C preprocessor" >&5
 15.6682 +$as_echo_n "checking how to run the C preprocessor... " >&6; }
 15.6683 +# On Suns, sometimes $CPP names a directory.
 15.6684 +if test -n "$CPP" && test -d "$CPP"; then
 15.6685 +  CPP=
 15.6686 +fi
 15.6687 +if test -z "$CPP"; then
 15.6688 +  if test "${ac_cv_prog_CPP+set}" = set; then :
 15.6689 +  $as_echo_n "(cached) " >&6
 15.6690 +else
 15.6691 +      # Double quotes because CPP needs to be expanded
 15.6692 +    for CPP in "$CC -E" "$CC -E -traditional-cpp" "/lib/cpp"
 15.6693 +    do
 15.6694 +      ac_preproc_ok=false
 15.6695 +for ac_c_preproc_warn_flag in '' yes
 15.6696 +do
 15.6697 +  # Use a header file that comes with gcc, so configuring glibc
 15.6698 +  # with a fresh cross-compiler works.
 15.6699 +  # Prefer <limits.h> to <assert.h> if __STDC__ is defined, since
 15.6700 +  # <limits.h> exists even on freestanding compilers.
 15.6701 +  # On the NeXT, cc -E runs the code through the compiler's parser,
 15.6702 +  # not just through cpp. "Syntax error" is here to catch this case.
 15.6703 +  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 15.6704 +/* end confdefs.h.  */
 15.6705 +#ifdef __STDC__
 15.6706 +# include <limits.h>
 15.6707 +#else
 15.6708 +# include <assert.h>
 15.6709 +#endif
 15.6710 +		     Syntax error
 15.6711 +_ACEOF
 15.6712 +if ac_fn_c_try_cpp "$LINENO"; then :
 15.6713 +
 15.6714 +else
 15.6715 +  # Broken: fails on valid input.
 15.6716 +continue
 15.6717 +fi
 15.6718 +rm -f conftest.err conftest.$ac_ext
 15.6719 +
 15.6720 +  # OK, works on sane cases.  Now check whether nonexistent headers
 15.6721 +  # can be detected and how.
 15.6722 +  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 15.6723 +/* end confdefs.h.  */
 15.6724 +#include <ac_nonexistent.h>
 15.6725 +_ACEOF
 15.6726 +if ac_fn_c_try_cpp "$LINENO"; then :
 15.6727 +  # Broken: success on invalid input.
 15.6728 +continue
 15.6729 +else
 15.6730 +  # Passes both tests.
 15.6731 +ac_preproc_ok=:
 15.6732 +break
 15.6733 +fi
 15.6734 +rm -f conftest.err conftest.$ac_ext
 15.6735 +
 15.6736 +done
 15.6737 +# Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped.
 15.6738 +rm -f conftest.err conftest.$ac_ext
 15.6739 +if $ac_preproc_ok; then :
 15.6740 +  break
 15.6741 +fi
 15.6742 +
 15.6743 +    done
 15.6744 +    ac_cv_prog_CPP=$CPP
 15.6745 +
 15.6746 +fi
 15.6747 +  CPP=$ac_cv_prog_CPP
 15.6748 +else
 15.6749 +  ac_cv_prog_CPP=$CPP
 15.6750 +fi
 15.6751 +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $CPP" >&5
 15.6752 +$as_echo "$CPP" >&6; }
 15.6753 +ac_preproc_ok=false
 15.6754 +for ac_c_preproc_warn_flag in '' yes
 15.6755 +do
 15.6756 +  # Use a header file that comes with gcc, so configuring glibc
 15.6757 +  # with a fresh cross-compiler works.
 15.6758 +  # Prefer <limits.h> to <assert.h> if __STDC__ is defined, since
 15.6759 +  # <limits.h> exists even on freestanding compilers.
 15.6760 +  # On the NeXT, cc -E runs the code through the compiler's parser,
 15.6761 +  # not just through cpp. "Syntax error" is here to catch this case.
 15.6762 +  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 15.6763 +/* end confdefs.h.  */
 15.6764 +#ifdef __STDC__
 15.6765 +# include <limits.h>
 15.6766 +#else
 15.6767 +# include <assert.h>
 15.6768 +#endif
 15.6769 +		     Syntax error
 15.6770 +_ACEOF
 15.6771 +if ac_fn_c_try_cpp "$LINENO"; then :
 15.6772 +
 15.6773 +else
 15.6774 +  # Broken: fails on valid input.
 15.6775 +continue
 15.6776 +fi
 15.6777 +rm -f conftest.err conftest.$ac_ext
 15.6778 +
 15.6779 +  # OK, works on sane cases.  Now check whether nonexistent headers
 15.6780 +  # can be detected and how.
 15.6781 +  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 15.6782 +/* end confdefs.h.  */
 15.6783 +#include <ac_nonexistent.h>
 15.6784 +_ACEOF
 15.6785 +if ac_fn_c_try_cpp "$LINENO"; then :
 15.6786 +  # Broken: success on invalid input.
 15.6787 +continue
 15.6788 +else
 15.6789 +  # Passes both tests.
 15.6790 +ac_preproc_ok=:
 15.6791 +break
 15.6792 +fi
 15.6793 +rm -f conftest.err conftest.$ac_ext
 15.6794 +
 15.6795 +done
 15.6796 +# Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped.
 15.6797 +rm -f conftest.err conftest.$ac_ext
 15.6798 +if $ac_preproc_ok; then :
 15.6799 +
 15.6800 +else
 15.6801 +  { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
 15.6802 +$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
 15.6803 +as_fn_error "C preprocessor \"$CPP\" fails sanity check
 15.6804 +See \`config.log' for more details." "$LINENO" 5; }
 15.6805 +fi
 15.6806 +
 15.6807 +ac_ext=c
 15.6808 +ac_cpp='$CPP $CPPFLAGS'
 15.6809 +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
 15.6810 +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
 15.6811 +ac_compiler_gnu=$ac_cv_c_compiler_gnu
 15.6812 +
 15.6813 +
 15.6814 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for ANSI C header files" >&5
 15.6815 +$as_echo_n "checking for ANSI C header files... " >&6; }
 15.6816 +if test "${ac_cv_header_stdc+set}" = set; then :
 15.6817 +  $as_echo_n "(cached) " >&6
 15.6818 +else
 15.6819 +  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 15.6820 +/* end confdefs.h.  */
 15.6821 +#include <stdlib.h>
 15.6822 +#include <stdarg.h>
 15.6823 +#include <string.h>
 15.6824 +#include <float.h>
 15.6825 +
 15.6826 +int
 15.6827 +main ()
 15.6828 +{
 15.6829 +
 15.6830 +  ;
 15.6831 +  return 0;
 15.6832 +}
 15.6833 +_ACEOF
 15.6834 +if ac_fn_c_try_compile "$LINENO"; then :
 15.6835 +  ac_cv_header_stdc=yes
 15.6836 +else
 15.6837 +  ac_cv_header_stdc=no
 15.6838 +fi
 15.6839 +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
 15.6840 +
 15.6841 +if test $ac_cv_header_stdc = yes; then
 15.6842 +  # SunOS 4.x string.h does not declare mem*, contrary to ANSI.
 15.6843 +  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 15.6844 +/* end confdefs.h.  */
 15.6845 +#include <string.h>
 15.6846 +
 15.6847 +_ACEOF
 15.6848 +if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
 15.6849 +  $EGREP "memchr" >/dev/null 2>&1; then :
 15.6850 +
 15.6851 +else
 15.6852 +  ac_cv_header_stdc=no
 15.6853 +fi
 15.6854 +rm -f conftest*
 15.6855 +
 15.6856 +fi
 15.6857 +
 15.6858 +if test $ac_cv_header_stdc = yes; then
 15.6859 +  # ISC 2.0.2 stdlib.h does not declare free, contrary to ANSI.
 15.6860 +  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 15.6861 +/* end confdefs.h.  */
 15.6862 +#include <stdlib.h>
 15.6863 +
 15.6864 +_ACEOF
 15.6865 +if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
 15.6866 +  $EGREP "free" >/dev/null 2>&1; then :
 15.6867 +
 15.6868 +else
 15.6869 +  ac_cv_header_stdc=no
 15.6870 +fi
 15.6871 +rm -f conftest*
 15.6872 +
 15.6873 +fi
 15.6874 +
 15.6875 +if test $ac_cv_header_stdc = yes; then
 15.6876 +  # /bin/cc in Irix-4.0.5 gets non-ANSI ctype macros unless using -ansi.
 15.6877 +  if test "$cross_compiling" = yes; then :
 15.6878 +  :
 15.6879 +else
 15.6880 +  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 15.6881 +/* end confdefs.h.  */
 15.6882 +#include <ctype.h>
 15.6883 +#include <stdlib.h>
 15.6884 +#if ((' ' & 0x0FF) == 0x020)
 15.6885 +# define ISLOWER(c) ('a' <= (c) && (c) <= 'z')
 15.6886 +# define TOUPPER(c) (ISLOWER(c) ? 'A' + ((c) - 'a') : (c))
 15.6887 +#else
 15.6888 +# define ISLOWER(c) \
 15.6889 +		   (('a' <= (c) && (c) <= 'i') \
 15.6890 +		     || ('j' <= (c) && (c) <= 'r') \
 15.6891 +		     || ('s' <= (c) && (c) <= 'z'))
 15.6892 +# define TOUPPER(c) (ISLOWER(c) ? ((c) | 0x40) : (c))
 15.6893 +#endif
 15.6894 +
 15.6895 +#define XOR(e, f) (((e) && !(f)) || (!(e) && (f)))
 15.6896 +int
 15.6897 +main ()
 15.6898 +{
 15.6899 +  int i;
 15.6900 +  for (i = 0; i < 256; i++)
 15.6901 +    if (XOR (islower (i), ISLOWER (i))
 15.6902 +	|| toupper (i) != TOUPPER (i))
 15.6903 +      return 2;
 15.6904 +  return 0;
 15.6905 +}
 15.6906 +_ACEOF
 15.6907 +if ac_fn_c_try_run "$LINENO"; then :
 15.6908 +
 15.6909 +else
 15.6910 +  ac_cv_header_stdc=no
 15.6911 +fi
 15.6912 +rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
 15.6913 +  conftest.$ac_objext conftest.beam conftest.$ac_ext
 15.6914 +fi
 15.6915 +
 15.6916 +fi
 15.6917 +fi
 15.6918 +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_header_stdc" >&5
 15.6919 +$as_echo "$ac_cv_header_stdc" >&6; }
 15.6920 +if test $ac_cv_header_stdc = yes; then
 15.6921 +
 15.6922 +$as_echo "#define STDC_HEADERS 1" >>confdefs.h
 15.6923 +
 15.6924 +fi
 15.6925 +
 15.6926 +# On IRIX 5.3, sys/types and inttypes.h are conflicting.
 15.6927 +for ac_header in sys/types.h sys/stat.h stdlib.h string.h memory.h strings.h \
 15.6928 +		  inttypes.h stdint.h unistd.h
 15.6929 +do :
 15.6930 +  as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh`
 15.6931 +ac_fn_c_check_header_compile "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default
 15.6932 +"
 15.6933 +eval as_val=\$$as_ac_Header
 15.6934 +   if test "x$as_val" = x""yes; then :
 15.6935 +  cat >>confdefs.h <<_ACEOF
 15.6936 +#define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1
 15.6937 +_ACEOF
 15.6938 +
 15.6939 +fi
 15.6940 +
 15.6941 +done
 15.6942 +
 15.6943 +
 15.6944 +for ac_header in dlfcn.h
 15.6945 +do :
 15.6946 +  ac_fn_c_check_header_compile "$LINENO" "dlfcn.h" "ac_cv_header_dlfcn_h" "$ac_includes_default
 15.6947 +"
 15.6948 +if test "x$ac_cv_header_dlfcn_h" = x""yes; then :
 15.6949 +  cat >>confdefs.h <<_ACEOF
 15.6950 +#define HAVE_DLFCN_H 1
 15.6951 +_ACEOF
 15.6952 +
 15.6953 +fi
 15.6954 +
 15.6955 +done
 15.6956 +
 15.6957 +
 15.6958 +
 15.6959 +
 15.6960 +
 15.6961 +# Set options
 15.6962 +
 15.6963 +
 15.6964 +
 15.6965 +        enable_dlopen=no
 15.6966 +
 15.6967 +
 15.6968 +  enable_win32_dll=no
 15.6969 +
 15.6970 +
 15.6971 +            # Check whether --enable-shared was given.
 15.6972 +if test "${enable_shared+set}" = set; then :
 15.6973 +  enableval=$enable_shared; p=${PACKAGE-default}
 15.6974 +    case $enableval in
 15.6975 +    yes) enable_shared=yes ;;
 15.6976 +    no) enable_shared=no ;;
 15.6977 +    *)
 15.6978 +      enable_shared=no
 15.6979 +      # Look at the argument we got.  We use all the common list separators.
 15.6980 +      lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR,"
 15.6981 +      for pkg in $enableval; do
 15.6982 +	IFS="$lt_save_ifs"
 15.6983 +	if test "X$pkg" = "X$p"; then
 15.6984 +	  enable_shared=yes
 15.6985 +	fi
 15.6986 +      done
 15.6987 +      IFS="$lt_save_ifs"
 15.6988 +      ;;
 15.6989 +    esac
 15.6990 +else
 15.6991 +  enable_shared=yes
 15.6992 +fi
 15.6993 +
 15.6994 +
 15.6995 +
 15.6996 +
 15.6997 +
 15.6998 +
 15.6999 +
 15.7000 +
 15.7001 +
 15.7002 +  # Check whether --enable-static was given.
 15.7003 +if test "${enable_static+set}" = set; then :
 15.7004 +  enableval=$enable_static; p=${PACKAGE-default}
 15.7005 +    case $enableval in
 15.7006 +    yes) enable_static=yes ;;
 15.7007 +    no) enable_static=no ;;
 15.7008 +    *)
 15.7009 +     enable_static=no
 15.7010 +      # Look at the argument we got.  We use all the common list separators.
 15.7011 +      lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR,"
 15.7012 +      for pkg in $enableval; do
 15.7013 +	IFS="$lt_save_ifs"
 15.7014 +	if test "X$pkg" = "X$p"; then
 15.7015 +	  enable_static=yes
 15.7016 +	fi
 15.7017 +      done
 15.7018 +      IFS="$lt_save_ifs"
 15.7019 +      ;;
 15.7020 +    esac
 15.7021 +else
 15.7022 +  enable_static=yes
 15.7023 +fi
 15.7024 +
 15.7025 +
 15.7026 +
 15.7027 +
 15.7028 +
 15.7029 +
 15.7030 +
 15.7031 +
 15.7032 +
 15.7033 +
 15.7034 +# Check whether --with-pic was given.
 15.7035 +if test "${with_pic+set}" = set; then :
 15.7036 +  withval=$with_pic; pic_mode="$withval"
 15.7037 +else
 15.7038 +  pic_mode=default
 15.7039 +fi
 15.7040 +
 15.7041 +
 15.7042 +test -z "$pic_mode" && pic_mode=default
 15.7043 +
 15.7044 +
 15.7045 +
 15.7046 +
 15.7047 +
 15.7048 +
 15.7049 +
 15.7050 +  # Check whether --enable-fast-install was given.
 15.7051 +if test "${enable_fast_install+set}" = set; then :
 15.7052 +  enableval=$enable_fast_install; p=${PACKAGE-default}
 15.7053 +    case $enableval in
 15.7054 +    yes) enable_fast_install=yes ;;
 15.7055 +    no) enable_fast_install=no ;;
 15.7056 +    *)
 15.7057 +      enable_fast_install=no
 15.7058 +      # Look at the argument we got.  We use all the common list separators.
 15.7059 +      lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR,"
 15.7060 +      for pkg in $enableval; do
 15.7061 +	IFS="$lt_save_ifs"
 15.7062 +	if test "X$pkg" = "X$p"; then
 15.7063 +	  enable_fast_install=yes
 15.7064 +	fi
 15.7065 +      done
 15.7066 +      IFS="$lt_save_ifs"
 15.7067 +      ;;
 15.7068 +    esac
 15.7069 +else
 15.7070 +  enable_fast_install=yes
 15.7071 +fi
 15.7072 +
 15.7073 +
 15.7074 +
 15.7075 +
 15.7076 +
 15.7077 +
 15.7078 +
 15.7079 +
 15.7080 +
 15.7081 +
 15.7082 +
 15.7083 +# This can be used to rebuild libtool when needed
 15.7084 +LIBTOOL_DEPS="$ltmain"
 15.7085 +
 15.7086 +# Always use our own libtool.
 15.7087 +LIBTOOL='$(SHELL) $(top_builddir)/libtool'
 15.7088 +
 15.7089 +
 15.7090 +
 15.7091 +
 15.7092 +
 15.7093 +
 15.7094 +
 15.7095 +
 15.7096 +
 15.7097 +
 15.7098 +
 15.7099 +
 15.7100 +
 15.7101 +
 15.7102 +
 15.7103 +
 15.7104 +
 15.7105 +
 15.7106 +
 15.7107 +
 15.7108 +
 15.7109 +
 15.7110 +
 15.7111 +
 15.7112 +
 15.7113 +
 15.7114 +test -z "$LN_S" && LN_S="ln -s"
 15.7115 +
 15.7116 +
 15.7117 +
 15.7118 +
 15.7119 +
 15.7120 +
 15.7121 +
 15.7122 +
 15.7123 +
 15.7124 +
 15.7125 +
 15.7126 +
 15.7127 +
 15.7128 +
 15.7129 +if test -n "${ZSH_VERSION+set}" ; then
 15.7130 +   setopt NO_GLOB_SUBST
 15.7131 +fi
 15.7132 +
 15.7133 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for objdir" >&5
 15.7134 +$as_echo_n "checking for objdir... " >&6; }
 15.7135 +if test "${lt_cv_objdir+set}" = set; then :
 15.7136 +  $as_echo_n "(cached) " >&6
 15.7137 +else
 15.7138 +  rm -f .libs 2>/dev/null
 15.7139 +mkdir .libs 2>/dev/null
 15.7140 +if test -d .libs; then
 15.7141 +  lt_cv_objdir=.libs
 15.7142 +else
 15.7143 +  # MS-DOS does not allow filenames that begin with a dot.
 15.7144 +  lt_cv_objdir=_libs
 15.7145 +fi
 15.7146 +rmdir .libs 2>/dev/null
 15.7147 +fi
 15.7148 +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_objdir" >&5
 15.7149 +$as_echo "$lt_cv_objdir" >&6; }
 15.7150 +objdir=$lt_cv_objdir
 15.7151 +
 15.7152 +
 15.7153 +
 15.7154 +
 15.7155 +
 15.7156 +cat >>confdefs.h <<_ACEOF
 15.7157 +#define LT_OBJDIR "$lt_cv_objdir/"
 15.7158 +_ACEOF
 15.7159 +
 15.7160 +
 15.7161 +
 15.7162 +
 15.7163 +case $host_os in
 15.7164 +aix3*)
 15.7165 +  # AIX sometimes has problems with the GCC collect2 program.  For some
 15.7166 +  # reason, if we set the COLLECT_NAMES environment variable, the problems
 15.7167 +  # vanish in a puff of smoke.
 15.7168 +  if test "X${COLLECT_NAMES+set}" != Xset; then
 15.7169 +    COLLECT_NAMES=
 15.7170 +    export COLLECT_NAMES
 15.7171 +  fi
 15.7172 +  ;;
 15.7173 +esac
 15.7174 +
 15.7175 +# Global variables:
 15.7176 +ofile=libtool
 15.7177 +can_build_shared=yes
 15.7178 +
 15.7179 +# All known linkers require a `.a' archive for static linking (except MSVC,
 15.7180 +# which needs '.lib').
 15.7181 +libext=a
 15.7182 +
 15.7183 +with_gnu_ld="$lt_cv_prog_gnu_ld"
 15.7184 +
 15.7185 +old_CC="$CC"
 15.7186 +old_CFLAGS="$CFLAGS"
 15.7187 +
 15.7188 +# Set sane defaults for various variables
 15.7189 +test -z "$CC" && CC=cc
 15.7190 +test -z "$LTCC" && LTCC=$CC
 15.7191 +test -z "$LTCFLAGS" && LTCFLAGS=$CFLAGS
 15.7192 +test -z "$LD" && LD=ld
 15.7193 +test -z "$ac_objext" && ac_objext=o
 15.7194 +
 15.7195 +for cc_temp in $compiler""; do
 15.7196 +  case $cc_temp in
 15.7197 +    compile | *[\\/]compile | ccache | *[\\/]ccache ) ;;
 15.7198 +    distcc | *[\\/]distcc | purify | *[\\/]purify ) ;;
 15.7199 +    \-*) ;;
 15.7200 +    *) break;;
 15.7201 +  esac
 15.7202 +done
 15.7203 +cc_basename=`$ECHO "$cc_temp" | $SED "s%.*/%%; s%^$host_alias-%%"`
 15.7204 +
 15.7205 +
 15.7206 +# Only perform the check for file, if the check method requires it
 15.7207 +test -z "$MAGIC_CMD" && MAGIC_CMD=file
 15.7208 +case $deplibs_check_method in
 15.7209 +file_magic*)
 15.7210 +  if test "$file_magic_cmd" = '$MAGIC_CMD'; then
 15.7211 +    { $as_echo "$as_me:${as_lineno-$LINENO}: checking for ${ac_tool_prefix}file" >&5
 15.7212 +$as_echo_n "checking for ${ac_tool_prefix}file... " >&6; }
 15.7213 +if test "${lt_cv_path_MAGIC_CMD+set}" = set; then :
 15.7214 +  $as_echo_n "(cached) " >&6
 15.7215 +else
 15.7216 +  case $MAGIC_CMD in
 15.7217 +[\\/*] |  ?:[\\/]*)
 15.7218 +  lt_cv_path_MAGIC_CMD="$MAGIC_CMD" # Let the user override the test with a path.
 15.7219 +  ;;
 15.7220 +*)
 15.7221 +  lt_save_MAGIC_CMD="$MAGIC_CMD"
 15.7222 +  lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR
 15.7223 +  ac_dummy="/usr/bin$PATH_SEPARATOR$PATH"
 15.7224 +  for ac_dir in $ac_dummy; do
 15.7225 +    IFS="$lt_save_ifs"
 15.7226 +    test -z "$ac_dir" && ac_dir=.
 15.7227 +    if test -f $ac_dir/${ac_tool_prefix}file; then
 15.7228 +      lt_cv_path_MAGIC_CMD="$ac_dir/${ac_tool_prefix}file"
 15.7229 +      if test -n "$file_magic_test_file"; then
 15.7230 +	case $deplibs_check_method in
 15.7231 +	"file_magic "*)
 15.7232 +	  file_magic_regex=`expr "$deplibs_check_method" : "file_magic \(.*\)"`
 15.7233 +	  MAGIC_CMD="$lt_cv_path_MAGIC_CMD"
 15.7234 +	  if eval $file_magic_cmd \$file_magic_test_file 2> /dev/null |
 15.7235 +	    $EGREP "$file_magic_regex" > /dev/null; then
 15.7236 +	    :
 15.7237 +	  else
 15.7238 +	    cat <<_LT_EOF 1>&2
 15.7239 +
 15.7240 +*** Warning: the command libtool uses to detect shared libraries,
 15.7241 +*** $file_magic_cmd, produces output that libtool cannot recognize.
 15.7242 +*** The result is that libtool may fail to recognize shared libraries
 15.7243 +*** as such.  This will affect the creation of libtool libraries that
 15.7244 +*** depend on shared libraries, but programs linked with such libtool
 15.7245 +*** libraries will work regardless of this problem.  Nevertheless, you
 15.7246 +*** may want to report the problem to your system manager and/or to
 15.7247 +*** bug-libtool@gnu.org
 15.7248 +
 15.7249 +_LT_EOF
 15.7250 +	  fi ;;
 15.7251 +	esac
 15.7252 +      fi
 15.7253 +      break
 15.7254 +    fi
 15.7255 +  done
 15.7256 +  IFS="$lt_save_ifs"
 15.7257 +  MAGIC_CMD="$lt_save_MAGIC_CMD"
 15.7258 +  ;;
 15.7259 +esac
 15.7260 +fi
 15.7261 +
 15.7262 +MAGIC_CMD="$lt_cv_path_MAGIC_CMD"
 15.7263 +if test -n "$MAGIC_CMD"; then
 15.7264 +  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $MAGIC_CMD" >&5
 15.7265 +$as_echo "$MAGIC_CMD" >&6; }
 15.7266 +else
 15.7267 +  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
 15.7268 +$as_echo "no" >&6; }
 15.7269 +fi
 15.7270 +
 15.7271 +
 15.7272 +
 15.7273 +
 15.7274 +
 15.7275 +if test -z "$lt_cv_path_MAGIC_CMD"; then
 15.7276 +  if test -n "$ac_tool_prefix"; then
 15.7277 +    { $as_echo "$as_me:${as_lineno-$LINENO}: checking for file" >&5
 15.7278 +$as_echo_n "checking for file... " >&6; }
 15.7279 +if test "${lt_cv_path_MAGIC_CMD+set}" = set; then :
 15.7280 +  $as_echo_n "(cached) " >&6
 15.7281 +else
 15.7282 +  case $MAGIC_CMD in
 15.7283 +[\\/*] |  ?:[\\/]*)
 15.7284 +  lt_cv_path_MAGIC_CMD="$MAGIC_CMD" # Let the user override the test with a path.
 15.7285 +  ;;
 15.7286 +*)
 15.7287 +  lt_save_MAGIC_CMD="$MAGIC_CMD"
 15.7288 +  lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR
 15.7289 +  ac_dummy="/usr/bin$PATH_SEPARATOR$PATH"
 15.7290 +  for ac_dir in $ac_dummy; do
 15.7291 +    IFS="$lt_save_ifs"
 15.7292 +    test -z "$ac_dir" && ac_dir=.
 15.7293 +    if test -f $ac_dir/file; then
 15.7294 +      lt_cv_path_MAGIC_CMD="$ac_dir/file"
 15.7295 +      if test -n "$file_magic_test_file"; then
 15.7296 +	case $deplibs_check_method in
 15.7297 +	"file_magic "*)
 15.7298 +	  file_magic_regex=`expr "$deplibs_check_method" : "file_magic \(.*\)"`
 15.7299 +	  MAGIC_CMD="$lt_cv_path_MAGIC_CMD"
 15.7300 +	  if eval $file_magic_cmd \$file_magic_test_file 2> /dev/null |
 15.7301 +	    $EGREP "$file_magic_regex" > /dev/null; then
 15.7302 +	    :
 15.7303 +	  else
 15.7304 +	    cat <<_LT_EOF 1>&2
 15.7305 +
 15.7306 +*** Warning: the command libtool uses to detect shared libraries,
 15.7307 +*** $file_magic_cmd, produces output that libtool cannot recognize.
 15.7308 +*** The result is that libtool may fail to recognize shared libraries
 15.7309 +*** as such.  This will affect the creation of libtool libraries that
 15.7310 +*** depend on shared libraries, but programs linked with such libtool
 15.7311 +*** libraries will work regardless of this problem.  Nevertheless, you
 15.7312 +*** may want to report the problem to your system manager and/or to
 15.7313 +*** bug-libtool@gnu.org
 15.7314 +
 15.7315 +_LT_EOF
 15.7316 +	  fi ;;
 15.7317 +	esac
 15.7318 +      fi
 15.7319 +      break
 15.7320 +    fi
 15.7321 +  done
 15.7322 +  IFS="$lt_save_ifs"
 15.7323 +  MAGIC_CMD="$lt_save_MAGIC_CMD"
 15.7324 +  ;;
 15.7325 +esac
 15.7326 +fi
 15.7327 +
 15.7328 +MAGIC_CMD="$lt_cv_path_MAGIC_CMD"
 15.7329 +if test -n "$MAGIC_CMD"; then
 15.7330 +  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $MAGIC_CMD" >&5
 15.7331 +$as_echo "$MAGIC_CMD" >&6; }
 15.7332 +else
 15.7333 +  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
 15.7334 +$as_echo "no" >&6; }
 15.7335 +fi
 15.7336 +
 15.7337 +
 15.7338 +  else
 15.7339 +    MAGIC_CMD=:
 15.7340 +  fi
 15.7341 +fi
 15.7342 +
 15.7343 +  fi
 15.7344 +  ;;
 15.7345 +esac
 15.7346 +
 15.7347 +# Use C for the default configuration in the libtool script
 15.7348 +
 15.7349 +lt_save_CC="$CC"
 15.7350 +ac_ext=c
 15.7351 +ac_cpp='$CPP $CPPFLAGS'
 15.7352 +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
 15.7353 +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
 15.7354 +ac_compiler_gnu=$ac_cv_c_compiler_gnu
 15.7355 +
 15.7356 +
 15.7357 +# Source file extension for C test sources.
 15.7358 +ac_ext=c
 15.7359 +
 15.7360 +# Object file extension for compiled C test sources.
 15.7361 +objext=o
 15.7362 +objext=$objext
 15.7363 +
 15.7364 +# Code to be used in simple compile tests
 15.7365 +lt_simple_compile_test_code="int some_variable = 0;"
 15.7366 +
 15.7367 +# Code to be used in simple link tests
 15.7368 +lt_simple_link_test_code='int main(){return(0);}'
 15.7369 +
 15.7370 +
 15.7371 +
 15.7372 +
 15.7373 +
 15.7374 +
 15.7375 +
 15.7376 +# If no C compiler was specified, use CC.
 15.7377 +LTCC=${LTCC-"$CC"}
 15.7378 +
 15.7379 +# If no C compiler flags were specified, use CFLAGS.
 15.7380 +LTCFLAGS=${LTCFLAGS-"$CFLAGS"}
 15.7381 +
 15.7382 +# Allow CC to be a program name with arguments.
 15.7383 +compiler=$CC
 15.7384 +
 15.7385 +# Save the default compiler, since it gets overwritten when the other
 15.7386 +# tags are being tested, and _LT_TAGVAR(compiler, []) is a NOP.
 15.7387 +compiler_DEFAULT=$CC
 15.7388 +
 15.7389 +# save warnings/boilerplate of simple test code
 15.7390 +ac_outfile=conftest.$ac_objext
 15.7391 +echo "$lt_simple_compile_test_code" >conftest.$ac_ext
 15.7392 +eval "$ac_compile" 2>&1 >/dev/null | $SED '/^$/d; /^ *+/d' >conftest.err
 15.7393 +_lt_compiler_boilerplate=`cat conftest.err`
 15.7394 +$RM conftest*
 15.7395 +
 15.7396 +ac_outfile=conftest.$ac_objext
 15.7397 +echo "$lt_simple_link_test_code" >conftest.$ac_ext
 15.7398 +eval "$ac_link" 2>&1 >/dev/null | $SED '/^$/d; /^ *+/d' >conftest.err
 15.7399 +_lt_linker_boilerplate=`cat conftest.err`
 15.7400 +$RM -r conftest*
 15.7401 +
 15.7402 +
 15.7403 +## CAVEAT EMPTOR:
 15.7404 +## There is no encapsulation within the following macros, do not change
 15.7405 +## the running order or otherwise move them around unless you know exactly
 15.7406 +## what you are doing...
 15.7407 +if test -n "$compiler"; then
 15.7408 +
 15.7409 +lt_prog_compiler_no_builtin_flag=
 15.7410 +
 15.7411 +if test "$GCC" = yes; then
 15.7412 +  case $cc_basename in
 15.7413 +  nvcc*)
 15.7414 +    lt_prog_compiler_no_builtin_flag=' -Xcompiler -fno-builtin' ;;
 15.7415 +  *)
 15.7416 +    lt_prog_compiler_no_builtin_flag=' -fno-builtin' ;;
 15.7417 +  esac
 15.7418 +
 15.7419 +  { $as_echo "$as_me:${as_lineno-$LINENO}: checking if $compiler supports -fno-rtti -fno-exceptions" >&5
 15.7420 +$as_echo_n "checking if $compiler supports -fno-rtti -fno-exceptions... " >&6; }
 15.7421 +if test "${lt_cv_prog_compiler_rtti_exceptions+set}" = set; then :
 15.7422 +  $as_echo_n "(cached) " >&6
 15.7423 +else
 15.7424 +  lt_cv_prog_compiler_rtti_exceptions=no
 15.7425 +   ac_outfile=conftest.$ac_objext
 15.7426 +   echo "$lt_simple_compile_test_code" > conftest.$ac_ext
 15.7427 +   lt_compiler_flag="-fno-rtti -fno-exceptions"
 15.7428 +   # Insert the option either (1) after the last *FLAGS variable, or
 15.7429 +   # (2) before a word containing "conftest.", or (3) at the end.
 15.7430 +   # Note that $ac_compile itself does not contain backslashes and begins
 15.7431 +   # with a dollar sign (not a hyphen), so the echo should work correctly.
 15.7432 +   # The option is referenced via a variable to avoid confusing sed.
 15.7433 +   lt_compile=`echo "$ac_compile" | $SED \
 15.7434 +   -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
 15.7435 +   -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
 15.7436 +   -e 's:$: $lt_compiler_flag:'`
 15.7437 +   (eval echo "\"\$as_me:$LINENO: $lt_compile\"" >&5)
 15.7438 +   (eval "$lt_compile" 2>conftest.err)
 15.7439 +   ac_status=$?
 15.7440 +   cat conftest.err >&5
 15.7441 +   echo "$as_me:$LINENO: \$? = $ac_status" >&5
 15.7442 +   if (exit $ac_status) && test -s "$ac_outfile"; then
 15.7443 +     # The compiler can only warn and ignore the option if not recognized
 15.7444 +     # So say no if there are warnings other than the usual output.
 15.7445 +     $ECHO "$_lt_compiler_boilerplate" | $SED '/^$/d' >conftest.exp
 15.7446 +     $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2
 15.7447 +     if test ! -s conftest.er2 || diff conftest.exp conftest.er2 >/dev/null; then
 15.7448 +       lt_cv_prog_compiler_rtti_exceptions=yes
 15.7449 +     fi
 15.7450 +   fi
 15.7451 +   $RM conftest*
 15.7452 +
 15.7453 +fi
 15.7454 +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler_rtti_exceptions" >&5
 15.7455 +$as_echo "$lt_cv_prog_compiler_rtti_exceptions" >&6; }
 15.7456 +
 15.7457 +if test x"$lt_cv_prog_compiler_rtti_exceptions" = xyes; then
 15.7458 +    lt_prog_compiler_no_builtin_flag="$lt_prog_compiler_no_builtin_flag -fno-rtti -fno-exceptions"
 15.7459 +else
 15.7460 +    :
 15.7461 +fi
 15.7462 +
 15.7463 +fi
 15.7464 +
 15.7465 +
 15.7466 +
 15.7467 +
 15.7468 +
 15.7469 +
 15.7470 +  lt_prog_compiler_wl=
 15.7471 +lt_prog_compiler_pic=
 15.7472 +lt_prog_compiler_static=
 15.7473 +
 15.7474 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $compiler option to produce PIC" >&5
 15.7475 +$as_echo_n "checking for $compiler option to produce PIC... " >&6; }
 15.7476 +
 15.7477 +  if test "$GCC" = yes; then
 15.7478 +    lt_prog_compiler_wl='-Wl,'
 15.7479 +    lt_prog_compiler_static='-static'
 15.7480 +
 15.7481 +    case $host_os in
 15.7482 +      aix*)
 15.7483 +      # All AIX code is PIC.
 15.7484 +      if test "$host_cpu" = ia64; then
 15.7485 +	# AIX 5 now supports IA64 processor
 15.7486 +	lt_prog_compiler_static='-Bstatic'
 15.7487 +      fi
 15.7488 +      ;;
 15.7489 +
 15.7490 +    amigaos*)
 15.7491 +      case $host_cpu in
 15.7492 +      powerpc)
 15.7493 +            # see comment about AmigaOS4 .so support
 15.7494 +            lt_prog_compiler_pic='-fPIC'
 15.7495 +        ;;
 15.7496 +      m68k)
 15.7497 +            # FIXME: we need at least 68020 code to build shared libraries, but
 15.7498 +            # adding the `-m68020' flag to GCC prevents building anything better,
 15.7499 +            # like `-m68040'.
 15.7500 +            lt_prog_compiler_pic='-m68020 -resident32 -malways-restore-a4'
 15.7501 +        ;;
 15.7502 +      esac
 15.7503 +      ;;
 15.7504 +
 15.7505 +    beos* | irix5* | irix6* | nonstopux* | osf3* | osf4* | osf5*)
 15.7506 +      # PIC is the default for these OSes.
 15.7507 +      ;;
 15.7508 +
 15.7509 +    mingw* | cygwin* | pw32* | os2* | cegcc*)
 15.7510 +      # This hack is so that the source file can tell whether it is being
 15.7511 +      # built for inclusion in a dll (and should export symbols for example).
 15.7512 +      # Although the cygwin gcc ignores -fPIC, still need this for old-style
 15.7513 +      # (--disable-auto-import) libraries
 15.7514 +      lt_prog_compiler_pic='-DDLL_EXPORT'
 15.7515 +      ;;
 15.7516 +
 15.7517 +    darwin* | rhapsody*)
 15.7518 +      # PIC is the default on this platform
 15.7519 +      # Common symbols not allowed in MH_DYLIB files
 15.7520 +      lt_prog_compiler_pic='-fno-common'
 15.7521 +      ;;
 15.7522 +
 15.7523 +    haiku*)
 15.7524 +      # PIC is the default for Haiku.
 15.7525 +      # The "-static" flag exists, but is broken.
 15.7526 +      lt_prog_compiler_static=
 15.7527 +      ;;
 15.7528 +
 15.7529 +    hpux*)
 15.7530 +      # PIC is the default for 64-bit PA HP-UX, but not for 32-bit
 15.7531 +      # PA HP-UX.  On IA64 HP-UX, PIC is the default but the pic flag
 15.7532 +      # sets the default TLS model and affects inlining.
 15.7533 +      case $host_cpu in
 15.7534 +      hppa*64*)
 15.7535 +	# +Z the default
 15.7536 +	;;
 15.7537 +      *)
 15.7538 +	lt_prog_compiler_pic='-fPIC'
 15.7539 +	;;
 15.7540 +      esac
 15.7541 +      ;;
 15.7542 +
 15.7543 +    interix[3-9]*)
 15.7544 +      # Interix 3.x gcc -fpic/-fPIC options generate broken code.
 15.7545 +      # Instead, we relocate shared libraries at runtime.
 15.7546 +      ;;
 15.7547 +
 15.7548 +    msdosdjgpp*)
 15.7549 +      # Just because we use GCC doesn't mean we suddenly get shared libraries
 15.7550 +      # on systems that don't support them.
 15.7551 +      lt_prog_compiler_can_build_shared=no
 15.7552 +      enable_shared=no
 15.7553 +      ;;
 15.7554 +
 15.7555 +    *nto* | *qnx*)
 15.7556 +      # QNX uses GNU C++, but need to define -shared option too, otherwise
 15.7557 +      # it will coredump.
 15.7558 +      lt_prog_compiler_pic='-fPIC -shared'
 15.7559 +      ;;
 15.7560 +
 15.7561 +    sysv4*MP*)
 15.7562 +      if test -d /usr/nec; then
 15.7563 +	lt_prog_compiler_pic=-Kconform_pic
 15.7564 +      fi
 15.7565 +      ;;
 15.7566 +
 15.7567 +    *)
 15.7568 +      lt_prog_compiler_pic='-fPIC'
 15.7569 +      ;;
 15.7570 +    esac
 15.7571 +
 15.7572 +    case $cc_basename in
 15.7573 +    nvcc*) # Cuda Compiler Driver 2.2
 15.7574 +      lt_prog_compiler_wl='-Xlinker '
 15.7575 +      lt_prog_compiler_pic='-Xcompiler -fPIC'
 15.7576 +      ;;
 15.7577 +    esac
 15.7578 +  else
 15.7579 +    # PORTME Check for flag to pass linker flags through the system compiler.
 15.7580 +    case $host_os in
 15.7581 +    aix*)
 15.7582 +      lt_prog_compiler_wl='-Wl,'
 15.7583 +      if test "$host_cpu" = ia64; then
 15.7584 +	# AIX 5 now supports IA64 processor
 15.7585 +	lt_prog_compiler_static='-Bstatic'
 15.7586 +      else
 15.7587 +	lt_prog_compiler_static='-bnso -bI:/lib/syscalls.exp'
 15.7588 +      fi
 15.7589 +      ;;
 15.7590 +
 15.7591 +    mingw* | cygwin* | pw32* | os2* | cegcc*)
 15.7592 +      # This hack is so that the source file can tell whether it is being
 15.7593 +      # built for inclusion in a dll (and should export symbols for example).
 15.7594 +      lt_prog_compiler_pic='-DDLL_EXPORT'
 15.7595 +      ;;
 15.7596 +
 15.7597 +    hpux9* | hpux10* | hpux11*)
 15.7598 +      lt_prog_compiler_wl='-Wl,'
 15.7599 +      # PIC is the default for IA64 HP-UX and 64-bit HP-UX, but
 15.7600 +      # not for PA HP-UX.
 15.7601 +      case $host_cpu in
 15.7602 +      hppa*64*|ia64*)
 15.7603 +	# +Z the default
 15.7604 +	;;
 15.7605 +      *)
 15.7606 +	lt_prog_compiler_pic='+Z'
 15.7607 +	;;
 15.7608 +      esac
 15.7609 +      # Is there a better lt_prog_compiler_static that works with the bundled CC?
 15.7610 +      lt_prog_compiler_static='${wl}-a ${wl}archive'
 15.7611 +      ;;
 15.7612 +
 15.7613 +    irix5* | irix6* | nonstopux*)
 15.7614 +      lt_prog_compiler_wl='-Wl,'
 15.7615 +      # PIC (with -KPIC) is the default.
 15.7616 +      lt_prog_compiler_static='-non_shared'
 15.7617 +      ;;
 15.7618 +
 15.7619 +    linux* | k*bsd*-gnu | kopensolaris*-gnu)
 15.7620 +      case $cc_basename in
 15.7621 +      # old Intel for x86_64 which still supported -KPIC.
 15.7622 +      ecc*)
 15.7623 +	lt_prog_compiler_wl='-Wl,'
 15.7624 +	lt_prog_compiler_pic='-KPIC'
 15.7625 +	lt_prog_compiler_static='-static'
 15.7626 +        ;;
 15.7627 +      # icc used to be incompatible with GCC.
 15.7628 +      # ICC 10 doesn't accept -KPIC any more.
 15.7629 +      icc* | ifort*)
 15.7630 +	lt_prog_compiler_wl='-Wl,'
 15.7631 +	lt_prog_compiler_pic='-fPIC'
 15.7632 +	lt_prog_compiler_static='-static'
 15.7633 +        ;;
 15.7634 +      # Lahey Fortran 8.1.
 15.7635 +      lf95*)
 15.7636 +	lt_prog_compiler_wl='-Wl,'
 15.7637 +	lt_prog_compiler_pic='--shared'
 15.7638 +	lt_prog_compiler_static='--static'
 15.7639 +	;;
 15.7640 +      pgcc* | pgf77* | pgf90* | pgf95* | pgfortran*)
 15.7641 +        # Portland Group compilers (*not* the Pentium gcc compiler,
 15.7642 +	# which looks to be a dead project)
 15.7643 +	lt_prog_compiler_wl='-Wl,'
 15.7644 +	lt_prog_compiler_pic='-fpic'
 15.7645 +	lt_prog_compiler_static='-Bstatic'
 15.7646 +        ;;
 15.7647 +      ccc*)
 15.7648 +        lt_prog_compiler_wl='-Wl,'
 15.7649 +        # All Alpha code is PIC.
 15.7650 +        lt_prog_compiler_static='-non_shared'
 15.7651 +        ;;
 15.7652 +      xl* | bgxl* | bgf* | mpixl*)
 15.7653 +	# IBM XL C 8.0/Fortran 10.1, 11.1 on PPC and BlueGene
 15.7654 +	lt_prog_compiler_wl='-Wl,'
 15.7655 +	lt_prog_compiler_pic='-qpic'
 15.7656 +	lt_prog_compiler_static='-qstaticlink'
 15.7657 +	;;
 15.7658 +      *)
 15.7659 +	case `$CC -V 2>&1 | sed 5q` in
 15.7660 +	*Sun\ F* | *Sun*Fortran*)
 15.7661 +	  # Sun Fortran 8.3 passes all unrecognized flags to the linker
 15.7662 +	  lt_prog_compiler_pic='-KPIC'
 15.7663 +	  lt_prog_compiler_static='-Bstatic'
 15.7664 +	  lt_prog_compiler_wl=''
 15.7665 +	  ;;
 15.7666 +	*Sun\ C*)
 15.7667 +	  # Sun C 5.9
 15.7668 +	  lt_prog_compiler_pic='-KPIC'
 15.7669 +	  lt_prog_compiler_static='-Bstatic'
 15.7670 +	  lt_prog_compiler_wl='-Wl,'
 15.7671 +	  ;;
 15.7672 +	esac
 15.7673 +	;;
 15.7674 +      esac
 15.7675 +      ;;
 15.7676 +
 15.7677 +    newsos6)
 15.7678 +      lt_prog_compiler_pic='-KPIC'
 15.7679 +      lt_prog_compiler_static='-Bstatic'
 15.7680 +      ;;
 15.7681 +
 15.7682 +    *nto* | *qnx*)
 15.7683 +      # QNX uses GNU C++, but need to define -shared option too, otherwise
 15.7684 +      # it will coredump.
 15.7685 +      lt_prog_compiler_pic='-fPIC -shared'
 15.7686 +      ;;
 15.7687 +
 15.7688 +    osf3* | osf4* | osf5*)
 15.7689 +      lt_prog_compiler_wl='-Wl,'
 15.7690 +      # All OSF/1 code is PIC.
 15.7691 +      lt_prog_compiler_static='-non_shared'
 15.7692 +      ;;
 15.7693 +
 15.7694 +    rdos*)
 15.7695 +      lt_prog_compiler_static='-non_shared'
 15.7696 +      ;;
 15.7697 +
 15.7698 +    solaris*)
 15.7699 +      lt_prog_compiler_pic='-KPIC'
 15.7700 +      lt_prog_compiler_static='-Bstatic'
 15.7701 +      case $cc_basename in
 15.7702 +      f77* | f90* | f95*)
 15.7703 +	lt_prog_compiler_wl='-Qoption ld ';;
 15.7704 +      *)
 15.7705 +	lt_prog_compiler_wl='-Wl,';;
 15.7706 +      esac
 15.7707 +      ;;
 15.7708 +
 15.7709 +    sunos4*)
 15.7710 +      lt_prog_compiler_wl='-Qoption ld '
 15.7711 +      lt_prog_compiler_pic='-PIC'
 15.7712 +      lt_prog_compiler_static='-Bstatic'
 15.7713 +      ;;
 15.7714 +
 15.7715 +    sysv4 | sysv4.2uw2* | sysv4.3*)
 15.7716 +      lt_prog_compiler_wl='-Wl,'
 15.7717 +      lt_prog_compiler_pic='-KPIC'
 15.7718 +      lt_prog_compiler_static='-Bstatic'
 15.7719 +      ;;
 15.7720 +
 15.7721 +    sysv4*MP*)
 15.7722 +      if test -d /usr/nec ;then
 15.7723 +	lt_prog_compiler_pic='-Kconform_pic'
 15.7724 +	lt_prog_compiler_static='-Bstatic'
 15.7725 +      fi
 15.7726 +      ;;
 15.7727 +
 15.7728 +    sysv5* | unixware* | sco3.2v5* | sco5v6* | OpenUNIX*)
 15.7729 +      lt_prog_compiler_wl='-Wl,'
 15.7730 +      lt_prog_compiler_pic='-KPIC'
 15.7731 +      lt_prog_compiler_static='-Bstatic'
 15.7732 +      ;;
 15.7733 +
 15.7734 +    unicos*)
 15.7735 +      lt_prog_compiler_wl='-Wl,'
 15.7736 +      lt_prog_compiler_can_build_shared=no
 15.7737 +      ;;
 15.7738 +
 15.7739 +    uts4*)
 15.7740 +      lt_prog_compiler_pic='-pic'
 15.7741 +      lt_prog_compiler_static='-Bstatic'
 15.7742 +      ;;
 15.7743 +
 15.7744 +    *)
 15.7745 +      lt_prog_compiler_can_build_shared=no
 15.7746 +      ;;
 15.7747 +    esac
 15.7748 +  fi
 15.7749 +
 15.7750 +case $host_os in
 15.7751 +  # For platforms which do not support PIC, -DPIC is meaningless:
 15.7752 +  *djgpp*)
 15.7753 +    lt_prog_compiler_pic=
 15.7754 +    ;;
 15.7755 +  *)
 15.7756 +    lt_prog_compiler_pic="$lt_prog_compiler_pic -DPIC"
 15.7757 +    ;;
 15.7758 +esac
 15.7759 +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_prog_compiler_pic" >&5
 15.7760 +$as_echo "$lt_prog_compiler_pic" >&6; }
 15.7761 +
 15.7762 +
 15.7763 +
 15.7764 +
 15.7765 +
 15.7766 +
 15.7767 +#
 15.7768 +# Check to make sure the PIC flag actually works.
 15.7769 +#
 15.7770 +if test -n "$lt_prog_compiler_pic"; then
 15.7771 +  { $as_echo "$as_me:${as_lineno-$LINENO}: checking if $compiler PIC flag $lt_prog_compiler_pic works" >&5
 15.7772 +$as_echo_n "checking if $compiler PIC flag $lt_prog_compiler_pic works... " >&6; }
 15.7773 +if test "${lt_cv_prog_compiler_pic_works+set}" = set; then :
 15.7774 +  $as_echo_n "(cached) " >&6
 15.7775 +else
 15.7776 +  lt_cv_prog_compiler_pic_works=no
 15.7777 +   ac_outfile=conftest.$ac_objext
 15.7778 +   echo "$lt_simple_compile_test_code" > conftest.$ac_ext
 15.7779 +   lt_compiler_flag="$lt_prog_compiler_pic -DPIC"
 15.7780 +   # Insert the option either (1) after the last *FLAGS variable, or
 15.7781 +   # (2) before a word containing "conftest.", or (3) at the end.
 15.7782 +   # Note that $ac_compile itself does not contain backslashes and begins
 15.7783 +   # with a dollar sign (not a hyphen), so the echo should work correctly.
 15.7784 +   # The option is referenced via a variable to avoid confusing sed.
 15.7785 +   lt_compile=`echo "$ac_compile" | $SED \
 15.7786 +   -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
 15.7787 +   -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
 15.7788 +   -e 's:$: $lt_compiler_flag:'`
 15.7789 +   (eval echo "\"\$as_me:$LINENO: $lt_compile\"" >&5)
 15.7790 +   (eval "$lt_compile" 2>conftest.err)
 15.7791 +   ac_status=$?
 15.7792 +   cat conftest.err >&5
 15.7793 +   echo "$as_me:$LINENO: \$? = $ac_status" >&5
 15.7794 +   if (exit $ac_status) && test -s "$ac_outfile"; then
 15.7795 +     # The compiler can only warn and ignore the option if not recognized
 15.7796 +     # So say no if there are warnings other than the usual output.
 15.7797 +     $ECHO "$_lt_compiler_boilerplate" | $SED '/^$/d' >conftest.exp
 15.7798 +     $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2
 15.7799 +     if test ! -s conftest.er2 || diff conftest.exp conftest.er2 >/dev/null; then
 15.7800 +       lt_cv_prog_compiler_pic_works=yes
 15.7801 +     fi
 15.7802 +   fi
 15.7803 +   $RM conftest*
 15.7804 +
 15.7805 +fi
 15.7806 +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler_pic_works" >&5
 15.7807 +$as_echo "$lt_cv_prog_compiler_pic_works" >&6; }
 15.7808 +
 15.7809 +if test x"$lt_cv_prog_compiler_pic_works" = xyes; then
 15.7810 +    case $lt_prog_compiler_pic in
 15.7811 +     "" | " "*) ;;
 15.7812 +     *) lt_prog_compiler_pic=" $lt_prog_compiler_pic" ;;
 15.7813 +     esac
 15.7814 +else
 15.7815 +    lt_prog_compiler_pic=
 15.7816 +     lt_prog_compiler_can_build_shared=no
 15.7817 +fi
 15.7818 +
 15.7819 +fi
 15.7820 +
 15.7821 +
 15.7822 +
 15.7823 +
 15.7824 +
 15.7825 +
 15.7826 +#
 15.7827 +# Check to make sure the static flag actually works.
 15.7828 +#
 15.7829 +wl=$lt_prog_compiler_wl eval lt_tmp_static_flag=\"$lt_prog_compiler_static\"
 15.7830 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking if $compiler static flag $lt_tmp_static_flag works" >&5
 15.7831 +$as_echo_n "checking if $compiler static flag $lt_tmp_static_flag works... " >&6; }
 15.7832 +if test "${lt_cv_prog_compiler_static_works+set}" = set; then :
 15.7833 +  $as_echo_n "(cached) " >&6
 15.7834 +else
 15.7835 +  lt_cv_prog_compiler_static_works=no
 15.7836 +   save_LDFLAGS="$LDFLAGS"
 15.7837 +   LDFLAGS="$LDFLAGS $lt_tmp_static_flag"
 15.7838 +   echo "$lt_simple_link_test_code" > conftest.$ac_ext
 15.7839 +   if (eval $ac_link 2>conftest.err) && test -s conftest$ac_exeext; then
 15.7840 +     # The linker can only warn and ignore the option if not recognized
 15.7841 +     # So say no if there are warnings
 15.7842 +     if test -s conftest.err; then
 15.7843 +       # Append any errors to the config.log.
 15.7844 +       cat conftest.err 1>&5
 15.7845 +       $ECHO "$_lt_linker_boilerplate" | $SED '/^$/d' > conftest.exp
 15.7846 +       $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2
 15.7847 +       if diff conftest.exp conftest.er2 >/dev/null; then
 15.7848 +         lt_cv_prog_compiler_static_works=yes
 15.7849 +       fi
 15.7850 +     else
 15.7851 +       lt_cv_prog_compiler_static_works=yes
 15.7852 +     fi
 15.7853 +   fi
 15.7854 +   $RM -r conftest*
 15.7855 +   LDFLAGS="$save_LDFLAGS"
 15.7856 +
 15.7857 +fi
 15.7858 +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler_static_works" >&5
 15.7859 +$as_echo "$lt_cv_prog_compiler_static_works" >&6; }
 15.7860 +
 15.7861 +if test x"$lt_cv_prog_compiler_static_works" = xyes; then
 15.7862 +    :
 15.7863 +else
 15.7864 +    lt_prog_compiler_static=
 15.7865 +fi
 15.7866 +
 15.7867 +
 15.7868 +
 15.7869 +
 15.7870 +
 15.7871 +
 15.7872 +
 15.7873 +  { $as_echo "$as_me:${as_lineno-$LINENO}: checking if $compiler supports -c -o file.$ac_objext" >&5
 15.7874 +$as_echo_n "checking if $compiler supports -c -o file.$ac_objext... " >&6; }
 15.7875 +if test "${lt_cv_prog_compiler_c_o+set}" = set; then :
 15.7876 +  $as_echo_n "(cached) " >&6
 15.7877 +else
 15.7878 +  lt_cv_prog_compiler_c_o=no
 15.7879 +   $RM -r conftest 2>/dev/null
 15.7880 +   mkdir conftest
 15.7881 +   cd conftest
 15.7882 +   mkdir out
 15.7883 +   echo "$lt_simple_compile_test_code" > conftest.$ac_ext
 15.7884 +
 15.7885 +   lt_compiler_flag="-o out/conftest2.$ac_objext"
 15.7886 +   # Insert the option either (1) after the last *FLAGS variable, or
 15.7887 +   # (2) before a word containing "conftest.", or (3) at the end.
 15.7888 +   # Note that $ac_compile itself does not contain backslashes and begins
 15.7889 +   # with a dollar sign (not a hyphen), so the echo should work correctly.
 15.7890 +   lt_compile=`echo "$ac_compile" | $SED \
 15.7891 +   -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
 15.7892 +   -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
 15.7893 +   -e 's:$: $lt_compiler_flag:'`
 15.7894 +   (eval echo "\"\$as_me:$LINENO: $lt_compile\"" >&5)
 15.7895 +   (eval "$lt_compile" 2>out/conftest.err)
 15.7896 +   ac_status=$?
 15.7897 +   cat out/conftest.err >&5
 15.7898 +   echo "$as_me:$LINENO: \$? = $ac_status" >&5
 15.7899 +   if (exit $ac_status) && test -s out/conftest2.$ac_objext
 15.7900 +   then
 15.7901 +     # The compiler can only warn and ignore the option if not recognized
 15.7902 +     # So say no if there are warnings
 15.7903 +     $ECHO "$_lt_compiler_boilerplate" | $SED '/^$/d' > out/conftest.exp
 15.7904 +     $SED '/^$/d; /^ *+/d' out/conftest.err >out/conftest.er2
 15.7905 +     if test ! -s out/conftest.er2 || diff out/conftest.exp out/conftest.er2 >/dev/null; then
 15.7906 +       lt_cv_prog_compiler_c_o=yes
 15.7907 +     fi
 15.7908 +   fi
 15.7909 +   chmod u+w . 2>&5
 15.7910 +   $RM conftest*
 15.7911 +   # SGI C++ compiler will create directory out/ii_files/ for
 15.7912 +   # template instantiation
 15.7913 +   test -d out/ii_files && $RM out/ii_files/* && rmdir out/ii_files
 15.7914 +   $RM out/* && rmdir out
 15.7915 +   cd ..
 15.7916 +   $RM -r conftest
 15.7917 +   $RM conftest*
 15.7918 +
 15.7919 +fi
 15.7920 +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler_c_o" >&5
 15.7921 +$as_echo "$lt_cv_prog_compiler_c_o" >&6; }
 15.7922 +
 15.7923 +
 15.7924 +
 15.7925 +
 15.7926 +
 15.7927 +
 15.7928 +  { $as_echo "$as_me:${as_lineno-$LINENO}: checking if $compiler supports -c -o file.$ac_objext" >&5
 15.7929 +$as_echo_n "checking if $compiler supports -c -o file.$ac_objext... " >&6; }
 15.7930 +if test "${lt_cv_prog_compiler_c_o+set}" = set; then :
 15.7931 +  $as_echo_n "(cached) " >&6
 15.7932 +else
 15.7933 +  lt_cv_prog_compiler_c_o=no
 15.7934 +   $RM -r conftest 2>/dev/null
 15.7935 +   mkdir conftest
 15.7936 +   cd conftest
 15.7937 +   mkdir out
 15.7938 +   echo "$lt_simple_compile_test_code" > conftest.$ac_ext
 15.7939 +
 15.7940 +   lt_compiler_flag="-o out/conftest2.$ac_objext"
 15.7941 +   # Insert the option either (1) after the last *FLAGS variable, or
 15.7942 +   # (2) before a word containing "conftest.", or (3) at the end.
 15.7943 +   # Note that $ac_compile itself does not contain backslashes and begins
 15.7944 +   # with a dollar sign (not a hyphen), so the echo should work correctly.
 15.7945 +   lt_compile=`echo "$ac_compile" | $SED \
 15.7946 +   -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
 15.7947 +   -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
 15.7948 +   -e 's:$: $lt_compiler_flag:'`
 15.7949 +   (eval echo "\"\$as_me:$LINENO: $lt_compile\"" >&5)
 15.7950 +   (eval "$lt_compile" 2>out/conftest.err)
 15.7951 +   ac_status=$?
 15.7952 +   cat out/conftest.err >&5
 15.7953 +   echo "$as_me:$LINENO: \$? = $ac_status" >&5
 15.7954 +   if (exit $ac_status) && test -s out/conftest2.$ac_objext
 15.7955 +   then
 15.7956 +     # The compiler can only warn and ignore the option if not recognized
 15.7957 +     # So say no if there are warnings
 15.7958 +     $ECHO "$_lt_compiler_boilerplate" | $SED '/^$/d' > out/conftest.exp
 15.7959 +     $SED '/^$/d; /^ *+/d' out/conftest.err >out/conftest.er2
 15.7960 +     if test ! -s out/conftest.er2 || diff out/conftest.exp out/conftest.er2 >/dev/null; then
 15.7961 +       lt_cv_prog_compiler_c_o=yes
 15.7962 +     fi
 15.7963 +   fi
 15.7964 +   chmod u+w . 2>&5
 15.7965 +   $RM conftest*
 15.7966 +   # SGI C++ compiler will create directory out/ii_files/ for
 15.7967 +   # template instantiation
 15.7968 +   test -d out/ii_files && $RM out/ii_files/* && rmdir out/ii_files
 15.7969 +   $RM out/* && rmdir out
 15.7970 +   cd ..
 15.7971 +   $RM -r conftest
 15.7972 +   $RM conftest*
 15.7973 +
 15.7974 +fi
 15.7975 +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler_c_o" >&5
 15.7976 +$as_echo "$lt_cv_prog_compiler_c_o" >&6; }
 15.7977 +
 15.7978 +
 15.7979 +
 15.7980 +
 15.7981 +hard_links="nottested"
 15.7982 +if test "$lt_cv_prog_compiler_c_o" = no && test "$need_locks" != no; then
 15.7983 +  # do not overwrite the value of need_locks provided by the user
 15.7984 +  { $as_echo "$as_me:${as_lineno-$LINENO}: checking if we can lock with hard links" >&5
 15.7985 +$as_echo_n "checking if we can lock with hard links... " >&6; }
 15.7986 +  hard_links=yes
 15.7987 +  $RM conftest*
 15.7988 +  ln conftest.a conftest.b 2>/dev/null && hard_links=no
 15.7989 +  touch conftest.a
 15.7990 +  ln conftest.a conftest.b 2>&5 || hard_links=no
 15.7991 +  ln conftest.a conftest.b 2>/dev/null && hard_links=no
 15.7992 +  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $hard_links" >&5
 15.7993 +$as_echo "$hard_links" >&6; }
 15.7994 +  if test "$hard_links" = no; then
 15.7995 +    { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: \`$CC' does not support \`-c -o', so \`make -j' may be unsafe" >&5
 15.7996 +$as_echo "$as_me: WARNING: \`$CC' does not support \`-c -o', so \`make -j' may be unsafe" >&2;}
 15.7997 +    need_locks=warn
 15.7998 +  fi
 15.7999 +else
 15.8000 +  need_locks=no
 15.8001 +fi
 15.8002 +
 15.8003 +
 15.8004 +
 15.8005 +
 15.8006 +
 15.8007 +
 15.8008 +  { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the $compiler linker ($LD) supports shared libraries" >&5
 15.8009 +$as_echo_n "checking whether the $compiler linker ($LD) supports shared libraries... " >&6; }
 15.8010 +
 15.8011 +  runpath_var=
 15.8012 +  allow_undefined_flag=
 15.8013 +  always_export_symbols=no
 15.8014 +  archive_cmds=
 15.8015 +  archive_expsym_cmds=
 15.8016 +  compiler_needs_object=no
 15.8017 +  enable_shared_with_static_runtimes=no
 15.8018 +  export_dynamic_flag_spec=
 15.8019 +  export_symbols_cmds='$NM $libobjs $convenience | $global_symbol_pipe | $SED '\''s/.* //'\'' | sort | uniq > $export_symbols'
 15.8020 +  hardcode_automatic=no
 15.8021 +  hardcode_direct=no
 15.8022 +  hardcode_direct_absolute=no
 15.8023 +  hardcode_libdir_flag_spec=
 15.8024 +  hardcode_libdir_flag_spec_ld=
 15.8025 +  hardcode_libdir_separator=
 15.8026 +  hardcode_minus_L=no
 15.8027 +  hardcode_shlibpath_var=unsupported
 15.8028 +  inherit_rpath=no
 15.8029 +  link_all_deplibs=unknown
 15.8030 +  module_cmds=
 15.8031 +  module_expsym_cmds=
 15.8032 +  old_archive_from_new_cmds=
 15.8033 +  old_archive_from_expsyms_cmds=
 15.8034 +  thread_safe_flag_spec=
 15.8035 +  whole_archive_flag_spec=
 15.8036 +  # include_expsyms should be a list of space-separated symbols to be *always*
 15.8037 +  # included in the symbol list
 15.8038 +  include_expsyms=
 15.8039 +  # exclude_expsyms can be an extended regexp of symbols to exclude
 15.8040 +  # it will be wrapped by ` (' and `)$', so one must not match beginning or
 15.8041 +  # end of line.  Example: `a|bc|.*d.*' will exclude the symbols `a' and `bc',
 15.8042 +  # as well as any symbol that contains `d'.
 15.8043 +  exclude_expsyms='_GLOBAL_OFFSET_TABLE_|_GLOBAL__F[ID]_.*'
 15.8044 +  # Although _GLOBAL_OFFSET_TABLE_ is a valid symbol C name, most a.out
 15.8045 +  # platforms (ab)use it in PIC code, but their linkers get confused if
 15.8046 +  # the symbol is explicitly referenced.  Since portable code cannot
 15.8047 +  # rely on this symbol name, it's probably fine to never include it in
 15.8048 +  # preloaded symbol tables.
 15.8049 +  # Exclude shared library initialization/finalization symbols.
 15.8050 +  extract_expsyms_cmds=
 15.8051 +
 15.8052 +  case $host_os in
 15.8053 +  cygwin* | mingw* | pw32* | cegcc*)
 15.8054 +    # FIXME: the MSVC++ port hasn't been tested in a loooong time
 15.8055 +    # When not using gcc, we currently assume that we are using
 15.8056 +    # Microsoft Visual C++.
 15.8057 +    if test "$GCC" != yes; then
 15.8058 +      with_gnu_ld=no
 15.8059 +    fi
 15.8060 +    ;;
 15.8061 +  interix*)
 15.8062 +    # we just hope/assume this is gcc and not c89 (= MSVC++)
 15.8063 +    with_gnu_ld=yes
 15.8064 +    ;;
 15.8065 +  openbsd*)
 15.8066 +    with_gnu_ld=no
 15.8067 +    ;;
 15.8068 +  esac
 15.8069 +
 15.8070 +  ld_shlibs=yes
 15.8071 +
 15.8072 +  # On some targets, GNU ld is compatible enough with the native linker
 15.8073 +  # that we're better off using the native interface for both.
 15.8074 +  lt_use_gnu_ld_interface=no
 15.8075 +  if test "$with_gnu_ld" = yes; then
 15.8076 +    case $host_os in
 15.8077 +      aix*)
 15.8078 +	# The AIX port of GNU ld has always aspired to compatibility
 15.8079 +	# with the native linker.  However, as the warning in the GNU ld
 15.8080 +	# block says, versions before 2.19.5* couldn't really create working
 15.8081 +	# shared libraries, regardless of the interface used.
 15.8082 +	case `$LD -v 2>&1` in
 15.8083 +	  *\ \(GNU\ Binutils\)\ 2.19.5*) ;;
 15.8084 +	  *\ \(GNU\ Binutils\)\ 2.[2-9]*) ;;
 15.8085 +	  *\ \(GNU\ Binutils\)\ [3-9]*) ;;
 15.8086 +	  *)
 15.8087 +	    lt_use_gnu_ld_interface=yes
 15.8088 +	    ;;
 15.8089 +	esac
 15.8090 +	;;
 15.8091 +      *)
 15.8092 +	lt_use_gnu_ld_interface=yes
 15.8093 +	;;
 15.8094 +    esac
 15.8095 +  fi
 15.8096 +
 15.8097 +  if test "$lt_use_gnu_ld_interface" = yes; then
 15.8098 +    # If archive_cmds runs LD, not CC, wlarc should be empty
 15.8099 +    wlarc='${wl}'
 15.8100 +
 15.8101 +    # Set some defaults for GNU ld with shared library support. These
 15.8102 +    # are reset later if shared libraries are not supported. Putting them
 15.8103 +    # here allows them to be overridden if necessary.
 15.8104 +    runpath_var=LD_RUN_PATH
 15.8105 +    hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir'
 15.8106 +    export_dynamic_flag_spec='${wl}--export-dynamic'
 15.8107 +    # ancient GNU ld didn't support --whole-archive et. al.
 15.8108 +    if $LD --help 2>&1 | $GREP 'no-whole-archive' > /dev/null; then
 15.8109 +      whole_archive_flag_spec="$wlarc"'--whole-archive$convenience '"$wlarc"'--no-whole-archive'
 15.8110 +    else
 15.8111 +      whole_archive_flag_spec=
 15.8112 +    fi
 15.8113 +    supports_anon_versioning=no
 15.8114 +    case `$LD -v 2>&1` in
 15.8115 +      *GNU\ gold*) supports_anon_versioning=yes ;;
 15.8116 +      *\ [01].* | *\ 2.[0-9].* | *\ 2.10.*) ;; # catch versions < 2.11
 15.8117 +      *\ 2.11.93.0.2\ *) supports_anon_versioning=yes ;; # RH7.3 ...
 15.8118 +      *\ 2.11.92.0.12\ *) supports_anon_versioning=yes ;; # Mandrake 8.2 ...
 15.8119 +      *\ 2.11.*) ;; # other 2.11 versions
 15.8120 +      *) supports_anon_versioning=yes ;;
 15.8121 +    esac
 15.8122 +
 15.8123 +    # See if GNU ld supports shared libraries.
 15.8124 +    case $host_os in
 15.8125 +    aix[3-9]*)
 15.8126 +      # On AIX/PPC, the GNU linker is very broken
 15.8127 +      if test "$host_cpu" != ia64; then
 15.8128 +	ld_shlibs=no
 15.8129 +	cat <<_LT_EOF 1>&2
 15.8130 +
 15.8131 +*** Warning: the GNU linker, at least up to release 2.19, is reported
 15.8132 +*** to be unable to reliably create shared libraries on AIX.
 15.8133 +*** Therefore, libtool is disabling shared libraries support.  If you
 15.8134 +*** really care for shared libraries, you may want to install binutils
 15.8135 +*** 2.20 or above, or modify your PATH so that a non-GNU linker is found.
 15.8136 +*** You will then need to restart the configuration process.
 15.8137 +
 15.8138 +_LT_EOF
 15.8139 +      fi
 15.8140 +      ;;
 15.8141 +
 15.8142 +    amigaos*)
 15.8143 +      case $host_cpu in
 15.8144 +      powerpc)
 15.8145 +            # see comment about AmigaOS4 .so support
 15.8146 +            archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
 15.8147 +            archive_expsym_cmds=''
 15.8148 +        ;;
 15.8149 +      m68k)
 15.8150 +            archive_cmds='$RM $output_objdir/a2ixlibrary.data~$ECHO "#define NAME $libname" > $output_objdir/a2ixlibrary.data~$ECHO "#define LIBRARY_ID 1" >> $output_objdir/a2ixlibrary.data~$ECHO "#define VERSION $major" >> $output_objdir/a2ixlibrary.data~$ECHO "#define REVISION $revision" >> $output_objdir/a2ixlibrary.data~$AR $AR_FLAGS $lib $libobjs~$RANLIB $lib~(cd $output_objdir && a2ixlibrary -32)'
 15.8151 +            hardcode_libdir_flag_spec='-L$libdir'
 15.8152 +            hardcode_minus_L=yes
 15.8153 +        ;;
 15.8154 +      esac
 15.8155 +      ;;
 15.8156 +
 15.8157 +    beos*)
 15.8158 +      if $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then
 15.8159 +	allow_undefined_flag=unsupported
 15.8160 +	# Joseph Beckenbach <jrb3@best.com> says some releases of gcc
 15.8161 +	# support --undefined.  This deserves some investigation.  FIXME
 15.8162 +	archive_cmds='$CC -nostart $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
 15.8163 +      else
 15.8164 +	ld_shlibs=no
 15.8165 +      fi
 15.8166 +      ;;
 15.8167 +
 15.8168 +    cygwin* | mingw* | pw32* | cegcc*)
 15.8169 +      # _LT_TAGVAR(hardcode_libdir_flag_spec, ) is actually meaningless,
 15.8170 +      # as there is no search path for DLLs.
 15.8171 +      hardcode_libdir_flag_spec='-L$libdir'
 15.8172 +      export_dynamic_flag_spec='${wl}--export-all-symbols'
 15.8173 +      allow_undefined_flag=unsupported
 15.8174 +      always_export_symbols=no
 15.8175 +      enable_shared_with_static_runtimes=yes
 15.8176 +      export_symbols_cmds='$NM $libobjs $convenience | $global_symbol_pipe | $SED -e '\''/^[BCDGRS][ ]/s/.*[ ]\([^ ]*\)/\1 DATA/;s/^.*[ ]__nm__\([^ ]*\)[ ][^ ]*/\1 DATA/;/^I[ ]/d;/^[AITW][ ]/s/.* //'\'' | sort | uniq > $export_symbols'
 15.8177 +      exclude_expsyms='[_]+GLOBAL_OFFSET_TABLE_|[_]+GLOBAL__[FID]_.*|[_]+head_[A-Za-z0-9_]+_dll|[A-Za-z0-9_]+_dll_iname'
 15.8178 +
 15.8179 +      if $LD --help 2>&1 | $GREP 'auto-import' > /dev/null; then
 15.8180 +        archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib'
 15.8181 +	# If the export-symbols file already is a .def file (1st line
 15.8182 +	# is EXPORTS), use it as is; otherwise, prepend...
 15.8183 +	archive_expsym_cmds='if test "x`$SED 1q $export_symbols`" = xEXPORTS; then
 15.8184 +	  cp $export_symbols $output_objdir/$soname.def;
 15.8185 +	else
 15.8186 +	  echo EXPORTS > $output_objdir/$soname.def;
 15.8187 +	  cat $export_symbols >> $output_objdir/$soname.def;
 15.8188 +	fi~
 15.8189 +	$CC -shared $output_objdir/$soname.def $libobjs $deplibs $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib'
 15.8190 +      else
 15.8191 +	ld_shlibs=no
 15.8192 +      fi
 15.8193 +      ;;
 15.8194 +
 15.8195 +    haiku*)
 15.8196 +      archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
 15.8197 +      link_all_deplibs=yes
 15.8198 +      ;;
 15.8199 +
 15.8200 +    interix[3-9]*)
 15.8201 +      hardcode_direct=no
 15.8202 +      hardcode_shlibpath_var=no
 15.8203 +      hardcode_libdir_flag_spec='${wl}-rpath,$libdir'
 15.8204 +      export_dynamic_flag_spec='${wl}-E'
 15.8205 +      # Hack: On Interix 3.x, we cannot compile PIC because of a broken gcc.
 15.8206 +      # Instead, shared libraries are loaded at an image base (0x10000000 by
 15.8207 +      # default) and relocated if they conflict, which is a slow very memory
 15.8208 +      # consuming and fragmenting process.  To avoid this, we pick a random,
 15.8209 +      # 256 KiB-aligned image base between 0x50000000 and 0x6FFC0000 at link
 15.8210 +      # time.  Moving up from 0x10000000 also allows more sbrk(2) space.
 15.8211 +      archive_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib'
 15.8212 +      archive_expsym_cmds='sed "s,^,_," $export_symbols >$output_objdir/$soname.expsym~$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--retain-symbols-file,$output_objdir/$soname.expsym ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib'
 15.8213 +      ;;
 15.8214 +
 15.8215 +    gnu* | linux* | tpf* | k*bsd*-gnu | kopensolaris*-gnu)
 15.8216 +      tmp_diet=no
 15.8217 +      if test "$host_os" = linux-dietlibc; then
 15.8218 +	case $cc_basename in
 15.8219 +	  diet\ *) tmp_diet=yes;;	# linux-dietlibc with static linking (!diet-dyn)
 15.8220 +	esac
 15.8221 +      fi
 15.8222 +      if $LD --help 2>&1 | $EGREP ': supported targets:.* elf' > /dev/null \
 15.8223 +	 && test "$tmp_diet" = no
 15.8224 +      then
 15.8225 +	tmp_addflag=
 15.8226 +	tmp_sharedflag='-shared'
 15.8227 +	case $cc_basename,$host_cpu in
 15.8228 +        pgcc*)				# Portland Group C compiler
 15.8229 +	  whole_archive_flag_spec='${wl}--whole-archive`for conv in $convenience\"\"; do test  -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` ${wl}--no-whole-archive'
 15.8230 +	  tmp_addflag=' $pic_flag'
 15.8231 +	  ;;
 15.8232 +	pgf77* | pgf90* | pgf95* | pgfortran*)
 15.8233 +					# Portland Group f77 and f90 compilers
 15.8234 +	  whole_archive_flag_spec='${wl}--whole-archive`for conv in $convenience\"\"; do test  -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` ${wl}--no-whole-archive'
 15.8235 +	  tmp_addflag=' $pic_flag -Mnomain' ;;
 15.8236 +	ecc*,ia64* | icc*,ia64*)	# Intel C compiler on ia64
 15.8237 +	  tmp_addflag=' -i_dynamic' ;;
 15.8238 +	efc*,ia64* | ifort*,ia64*)	# Intel Fortran compiler on ia64
 15.8239 +	  tmp_addflag=' -i_dynamic -nofor_main' ;;
 15.8240 +	ifc* | ifort*)			# Intel Fortran compiler
 15.8241 +	  tmp_addflag=' -nofor_main' ;;
 15.8242 +	lf95*)				# Lahey Fortran 8.1
 15.8243 +	  whole_archive_flag_spec=
 15.8244 +	  tmp_sharedflag='--shared' ;;
 15.8245 +	xl[cC]* | bgxl[cC]* | mpixl[cC]*) # IBM XL C 8.0 on PPC (deal with xlf below)
 15.8246 +	  tmp_sharedflag='-qmkshrobj'
 15.8247 +	  tmp_addflag= ;;
 15.8248 +	nvcc*)	# Cuda Compiler Driver 2.2
 15.8249 +	  whole_archive_flag_spec='${wl}--whole-archive`for conv in $convenience\"\"; do test  -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` ${wl}--no-whole-archive'
 15.8250 +	  compiler_needs_object=yes
 15.8251 +	  ;;
 15.8252 +	esac
 15.8253 +	case `$CC -V 2>&1 | sed 5q` in
 15.8254 +	*Sun\ C*)			# Sun C 5.9
 15.8255 +	  whole_archive_flag_spec='${wl}--whole-archive`new_convenience=; for conv in $convenience\"\"; do test -z \"$conv\" || new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` ${wl}--no-whole-archive'
 15.8256 +	  compiler_needs_object=yes
 15.8257 +	  tmp_sharedflag='-G' ;;
 15.8258 +	*Sun\ F*)			# Sun Fortran 8.3
 15.8259 +	  tmp_sharedflag='-G' ;;
 15.8260 +	esac
 15.8261 +	archive_cmds='$CC '"$tmp_sharedflag""$tmp_addflag"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
 15.8262 +
 15.8263 +        if test "x$supports_anon_versioning" = xyes; then
 15.8264 +          archive_expsym_cmds='echo "{ global:" > $output_objdir/$libname.ver~
 15.8265 +	    cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~
 15.8266 +	    echo "local: *; };" >> $output_objdir/$libname.ver~
 15.8267 +	    $CC '"$tmp_sharedflag""$tmp_addflag"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-version-script ${wl}$output_objdir/$libname.ver -o $lib'
 15.8268 +        fi
 15.8269 +
 15.8270 +	case $cc_basename in
 15.8271 +	xlf* | bgf* | bgxlf* | mpixlf*)
 15.8272 +	  # IBM XL Fortran 10.1 on PPC cannot create shared libs itself
 15.8273 +	  whole_archive_flag_spec='--whole-archive$convenience --no-whole-archive'
 15.8274 +	  hardcode_libdir_flag_spec=
 15.8275 +	  hardcode_libdir_flag_spec_ld='-rpath $libdir'
 15.8276 +	  archive_cmds='$LD -shared $libobjs $deplibs $compiler_flags -soname $soname -o $lib'
 15.8277 +	  if test "x$supports_anon_versioning" = xyes; then
 15.8278 +	    archive_expsym_cmds='echo "{ global:" > $output_objdir/$libname.ver~
 15.8279 +	      cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~
 15.8280 +	      echo "local: *; };" >> $output_objdir/$libname.ver~
 15.8281 +	      $LD -shared $libobjs $deplibs $compiler_flags -soname $soname -version-script $output_objdir/$libname.ver -o $lib'
 15.8282 +	  fi
 15.8283 +	  ;;
 15.8284 +	esac
 15.8285 +      else
 15.8286 +        ld_shlibs=no
 15.8287 +      fi
 15.8288 +      ;;
 15.8289 +
 15.8290 +    netbsd*)
 15.8291 +      if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then
 15.8292 +	archive_cmds='$LD -Bshareable $libobjs $deplibs $linker_flags -o $lib'
 15.8293 +	wlarc=
 15.8294 +      else
 15.8295 +	archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
 15.8296 +	archive_expsym_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
 15.8297 +      fi
 15.8298 +      ;;
 15.8299 +
 15.8300 +    solaris*)
 15.8301 +      if $LD -v 2>&1 | $GREP 'BFD 2\.8' > /dev/null; then
 15.8302 +	ld_shlibs=no
 15.8303 +	cat <<_LT_EOF 1>&2
 15.8304 +
 15.8305 +*** Warning: The releases 2.8.* of the GNU linker cannot reliably
 15.8306 +*** create shared libraries on Solaris systems.  Therefore, libtool
 15.8307 +*** is disabling shared libraries support.  We urge you to upgrade GNU
 15.8308 +*** binutils to release 2.9.1 or newer.  Another option is to modify
 15.8309 +*** your PATH or compiler configuration so that the native linker is
 15.8310 +*** used, and then restart.
 15.8311 +
 15.8312 +_LT_EOF
 15.8313 +      elif $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then
 15.8314 +	archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
 15.8315 +	archive_expsym_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
 15.8316 +      else
 15.8317 +	ld_shlibs=no
 15.8318 +      fi
 15.8319 +      ;;
 15.8320 +
 15.8321 +    sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX*)
 15.8322 +      case `$LD -v 2>&1` in
 15.8323 +        *\ [01].* | *\ 2.[0-9].* | *\ 2.1[0-5].*)
 15.8324 +	ld_shlibs=no
 15.8325 +	cat <<_LT_EOF 1>&2
 15.8326 +
 15.8327 +*** Warning: Releases of the GNU linker prior to 2.16.91.0.3 can not
 15.8328 +*** reliably create shared libraries on SCO systems.  Therefore, libtool
 15.8329 +*** is disabling shared libraries support.  We urge you to upgrade GNU
 15.8330 +*** binutils to release 2.16.91.0.3 or newer.  Another option is to modify
 15.8331 +*** your PATH or compiler configuration so that the native linker is
 15.8332 +*** used, and then restart.
 15.8333 +
 15.8334 +_LT_EOF
 15.8335 +	;;
 15.8336 +	*)
 15.8337 +	  # For security reasons, it is highly recommended that you always
 15.8338 +	  # use absolute paths for naming shared libraries, and exclude the
 15.8339 +	  # DT_RUNPATH tag from executables and libraries.  But doing so
 15.8340 +	  # requires that you compile everything twice, which is a pain.
 15.8341 +	  if $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then
 15.8342 +	    hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir'
 15.8343 +	    archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
 15.8344 +	    archive_expsym_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
 15.8345 +	  else
 15.8346 +	    ld_shlibs=no
 15.8347 +	  fi
 15.8348 +	;;
 15.8349 +      esac
 15.8350 +      ;;
 15.8351 +
 15.8352 +    sunos4*)
 15.8353 +      archive_cmds='$LD -assert pure-text -Bshareable -o $lib $libobjs $deplibs $linker_flags'
 15.8354 +      wlarc=
 15.8355 +      hardcode_direct=yes
 15.8356 +      hardcode_shlibpath_var=no
 15.8357 +      ;;
 15.8358 +
 15.8359 +    *)
 15.8360 +      if $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then
 15.8361 +	archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
 15.8362 +	archive_expsym_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
 15.8363 +      else
 15.8364 +	ld_shlibs=no
 15.8365 +      fi
 15.8366 +      ;;
 15.8367 +    esac
 15.8368 +
 15.8369 +    if test "$ld_shlibs" = no; then
 15.8370 +      runpath_var=
 15.8371 +      hardcode_libdir_flag_spec=
 15.8372 +      export_dynamic_flag_spec=
 15.8373 +      whole_archive_flag_spec=
 15.8374 +    fi
 15.8375 +  else
 15.8376 +    # PORTME fill in a description of your system's linker (not GNU ld)
 15.8377 +    case $host_os in
 15.8378 +    aix3*)
 15.8379 +      allow_undefined_flag=unsupported
 15.8380 +      always_export_symbols=yes
 15.8381 +      archive_expsym_cmds='$LD -o $output_objdir/$soname $libobjs $deplibs $linker_flags -bE:$export_symbols -T512 -H512 -bM:SRE~$AR $AR_FLAGS $lib $output_objdir/$soname'
 15.8382 +      # Note: this linker hardcodes the directories in LIBPATH if there
 15.8383 +      # are no directories specified by -L.
 15.8384 +      hardcode_minus_L=yes
 15.8385 +      if test "$GCC" = yes && test -z "$lt_prog_compiler_static"; then
 15.8386 +	# Neither direct hardcoding nor static linking is supported with a
 15.8387 +	# broken collect2.
 15.8388 +	hardcode_direct=unsupported
 15.8389 +      fi
 15.8390 +      ;;
 15.8391 +
 15.8392 +    aix[4-9]*)
 15.8393 +      if test "$host_cpu" = ia64; then
 15.8394 +	# On IA64, the linker does run time linking by default, so we don't
 15.8395 +	# have to do anything special.
 15.8396 +	aix_use_runtimelinking=no
 15.8397 +	exp_sym_flag='-Bexport'
 15.8398 +	no_entry_flag=""
 15.8399 +      else
 15.8400 +	# If we're using GNU nm, then we don't want the "-C" option.
 15.8401 +	# -C means demangle to AIX nm, but means don't demangle with GNU nm
 15.8402 +	# Also, AIX nm treats weak defined symbols like other global
 15.8403 +	# defined symbols, whereas GNU nm marks them as "W".
 15.8404 +	if $NM -V 2>&1 | $GREP 'GNU' > /dev/null; then
 15.8405 +	  export_symbols_cmds='$NM -Bpg $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B") || (\$ 2 == "W")) && (substr(\$ 3,1,1) != ".")) { print \$ 3 } }'\'' | sort -u > $export_symbols'
 15.8406 +	else
 15.8407 +	  export_symbols_cmds='$NM -BCpg $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B")) && (substr(\$ 3,1,1) != ".")) { print \$ 3 } }'\'' | sort -u > $export_symbols'
 15.8408 +	fi
 15.8409 +	aix_use_runtimelinking=no
 15.8410 +
 15.8411 +	# Test if we are trying to use run time linking or normal
 15.8412 +	# AIX style linking. If -brtl is somewhere in LDFLAGS, we
 15.8413 +	# need to do runtime linking.
 15.8414 +	case $host_os in aix4.[23]|aix4.[23].*|aix[5-9]*)
 15.8415 +	  for ld_flag in $LDFLAGS; do
 15.8416 +	  if (test $ld_flag = "-brtl" || test $ld_flag = "-Wl,-brtl"); then
 15.8417 +	    aix_use_runtimelinking=yes
 15.8418 +	    break
 15.8419 +	  fi
 15.8420 +	  done
 15.8421 +	  ;;
 15.8422 +	esac
 15.8423 +
 15.8424 +	exp_sym_flag='-bexport'
 15.8425 +	no_entry_flag='-bnoentry'
 15.8426 +      fi
 15.8427 +
 15.8428 +      # When large executables or shared objects are built, AIX ld can
 15.8429 +      # have problems creating the table of contents.  If linking a library
 15.8430 +      # or program results in "error TOC overflow" add -mminimal-toc to
 15.8431 +      # CXXFLAGS/CFLAGS for g++/gcc.  In the cases where that is not
 15.8432 +      # enough to fix the problem, add -Wl,-bbigtoc to LDFLAGS.
 15.8433 +
 15.8434 +      archive_cmds=''
 15.8435 +      hardcode_direct=yes
 15.8436 +      hardcode_direct_absolute=yes
 15.8437 +      hardcode_libdir_separator=':'
 15.8438 +      link_all_deplibs=yes
 15.8439 +      file_list_spec='${wl}-f,'
 15.8440 +
 15.8441 +      if test "$GCC" = yes; then
 15.8442 +	case $host_os in aix4.[012]|aix4.[012].*)
 15.8443 +	# We only want to do this on AIX 4.2 and lower, the check
 15.8444 +	# below for broken collect2 doesn't work under 4.3+
 15.8445 +	  collect2name=`${CC} -print-prog-name=collect2`
 15.8446 +	  if test -f "$collect2name" &&
 15.8447 +	   strings "$collect2name" | $GREP resolve_lib_name >/dev/null
 15.8448 +	  then
 15.8449 +	  # We have reworked collect2
 15.8450 +	  :
 15.8451 +	  else
 15.8452 +	  # We have old collect2
 15.8453 +	  hardcode_direct=unsupported
 15.8454 +	  # It fails to find uninstalled libraries when the uninstalled
 15.8455 +	  # path is not listed in the libpath.  Setting hardcode_minus_L
 15.8456 +	  # to unsupported forces relinking
 15.8457 +	  hardcode_minus_L=yes
 15.8458 +	  hardcode_libdir_flag_spec='-L$libdir'
 15.8459 +	  hardcode_libdir_separator=
 15.8460 +	  fi
 15.8461 +	  ;;
 15.8462 +	esac
 15.8463 +	shared_flag='-shared'
 15.8464 +	if test "$aix_use_runtimelinking" = yes; then
 15.8465 +	  shared_flag="$shared_flag "'${wl}-G'
 15.8466 +	fi
 15.8467 +      else
 15.8468 +	# not using gcc
 15.8469 +	if test "$host_cpu" = ia64; then
 15.8470 +	# VisualAge C++, Version 5.5 for AIX 5L for IA-64, Beta 3 Release
 15.8471 +	# chokes on -Wl,-G. The following line is correct:
 15.8472 +	  shared_flag='-G'
 15.8473 +	else
 15.8474 +	  if test "$aix_use_runtimelinking" = yes; then
 15.8475 +	    shared_flag='${wl}-G'
 15.8476 +	  else
 15.8477 +	    shared_flag='${wl}-bM:SRE'
 15.8478 +	  fi
 15.8479 +	fi
 15.8480 +      fi
 15.8481 +
 15.8482 +      export_dynamic_flag_spec='${wl}-bexpall'
 15.8483 +      # It seems that -bexpall does not export symbols beginning with
 15.8484 +      # underscore (_), so it is better to generate a list of symbols to export.
 15.8485 +      always_export_symbols=yes
 15.8486 +      if test "$aix_use_runtimelinking" = yes; then
 15.8487 +	# Warning - without using the other runtime loading flags (-brtl),
 15.8488 +	# -berok will link without error, but may produce a broken library.
 15.8489 +	allow_undefined_flag='-berok'
 15.8490 +        # Determine the default libpath from the value encoded in an
 15.8491 +        # empty executable.
 15.8492 +        cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 15.8493 +/* end confdefs.h.  */
 15.8494 +
 15.8495 +int
 15.8496 +main ()
 15.8497 +{
 15.8498 +
 15.8499 +  ;
 15.8500 +  return 0;
 15.8501 +}
 15.8502 +_ACEOF
 15.8503 +if ac_fn_c_try_link "$LINENO"; then :
 15.8504 +
 15.8505 +lt_aix_libpath_sed='
 15.8506 +    /Import File Strings/,/^$/ {
 15.8507 +	/^0/ {
 15.8508 +	    s/^0  *\(.*\)$/\1/
 15.8509 +	    p
 15.8510 +	}
 15.8511 +    }'
 15.8512 +aix_libpath=`dump -H conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"`
 15.8513 +# Check for a 64-bit object if we didn't find anything.
 15.8514 +if test -z "$aix_libpath"; then
 15.8515 +  aix_libpath=`dump -HX64 conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"`
 15.8516 +fi
 15.8517 +fi
 15.8518 +rm -f core conftest.err conftest.$ac_objext \
 15.8519 +    conftest$ac_exeext conftest.$ac_ext
 15.8520 +if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi
 15.8521 +
 15.8522 +        hardcode_libdir_flag_spec='${wl}-blibpath:$libdir:'"$aix_libpath"
 15.8523 +        archive_expsym_cmds='$CC -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags `if test "x${allow_undefined_flag}" != "x"; then func_echo_all "${wl}${allow_undefined_flag}"; else :; fi` '"\${wl}$exp_sym_flag:\$export_symbols $shared_flag"
 15.8524 +      else
 15.8525 +	if test "$host_cpu" = ia64; then
 15.8526 +	  hardcode_libdir_flag_spec='${wl}-R $libdir:/usr/lib:/lib'
 15.8527 +	  allow_undefined_flag="-z nodefs"
 15.8528 +	  archive_expsym_cmds="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags ${wl}${allow_undefined_flag} '"\${wl}$exp_sym_flag:\$export_symbols"
 15.8529 +	else
 15.8530 +	 # Determine the default libpath from the value encoded in an
 15.8531 +	 # empty executable.
 15.8532 +	 cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 15.8533 +/* end confdefs.h.  */
 15.8534 +
 15.8535 +int
 15.8536 +main ()
 15.8537 +{
 15.8538 +
 15.8539 +  ;
 15.8540 +  return 0;
 15.8541 +}
 15.8542 +_ACEOF
 15.8543 +if ac_fn_c_try_link "$LINENO"; then :
 15.8544 +
 15.8545 +lt_aix_libpath_sed='
 15.8546 +    /Import File Strings/,/^$/ {
 15.8547 +	/^0/ {
 15.8548 +	    s/^0  *\(.*\)$/\1/
 15.8549 +	    p
 15.8550 +	}
 15.8551 +    }'
 15.8552 +aix_libpath=`dump -H conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"`
 15.8553 +# Check for a 64-bit object if we didn't find anything.
 15.8554 +if test -z "$aix_libpath"; then
 15.8555 +  aix_libpath=`dump -HX64 conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"`
 15.8556 +fi
 15.8557 +fi
 15.8558 +rm -f core conftest.err conftest.$ac_objext \
 15.8559 +    conftest$ac_exeext conftest.$ac_ext
 15.8560 +if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi
 15.8561 +
 15.8562 +	 hardcode_libdir_flag_spec='${wl}-blibpath:$libdir:'"$aix_libpath"
 15.8563 +	  # Warning - without using the other run time loading flags,
 15.8564 +	  # -berok will link without error, but may produce a broken library.
 15.8565 +	  no_undefined_flag=' ${wl}-bernotok'
 15.8566 +	  allow_undefined_flag=' ${wl}-berok'
 15.8567 +	  if test "$with_gnu_ld" = yes; then
 15.8568 +	    # We only use this code for GNU lds that support --whole-archive.
 15.8569 +	    whole_archive_flag_spec='${wl}--whole-archive$convenience ${wl}--no-whole-archive'
 15.8570 +	  else
 15.8571 +	    # Exported symbols can be pulled into shared objects from archives
 15.8572 +	    whole_archive_flag_spec='$convenience'
 15.8573 +	  fi
 15.8574 +	  archive_cmds_need_lc=yes
 15.8575 +	  # This is similar to how AIX traditionally builds its shared libraries.
 15.8576 +	  archive_expsym_cmds="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs ${wl}-bnoentry $compiler_flags ${wl}-bE:$export_symbols${allow_undefined_flag}~$AR $AR_FLAGS $output_objdir/$libname$release.a $output_objdir/$soname'
 15.8577 +	fi
 15.8578 +      fi
 15.8579 +      ;;
 15.8580 +
 15.8581 +    amigaos*)
 15.8582 +      case $host_cpu in
 15.8583 +      powerpc)
 15.8584 +            # see comment about AmigaOS4 .so support
 15.8585 +            archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
 15.8586 +            archive_expsym_cmds=''
 15.8587 +        ;;
 15.8588 +      m68k)
 15.8589 +            archive_cmds='$RM $output_objdir/a2ixlibrary.data~$ECHO "#define NAME $libname" > $output_objdir/a2ixlibrary.data~$ECHO "#define LIBRARY_ID 1" >> $output_objdir/a2ixlibrary.data~$ECHO "#define VERSION $major" >> $output_objdir/a2ixlibrary.data~$ECHO "#define REVISION $revision" >> $output_objdir/a2ixlibrary.data~$AR $AR_FLAGS $lib $libobjs~$RANLIB $lib~(cd $output_objdir && a2ixlibrary -32)'
 15.8590 +            hardcode_libdir_flag_spec='-L$libdir'
 15.8591 +            hardcode_minus_L=yes
 15.8592 +        ;;
 15.8593 +      esac
 15.8594 +      ;;
 15.8595 +
 15.8596 +    bsdi[45]*)
 15.8597 +      export_dynamic_flag_spec=-rdynamic
 15.8598 +      ;;
 15.8599 +
 15.8600 +    cygwin* | mingw* | pw32* | cegcc*)
 15.8601 +      # When not using gcc, we currently assume that we are using
 15.8602 +      # Microsoft Visual C++.
 15.8603 +      # hardcode_libdir_flag_spec is actually meaningless, as there is
 15.8604 +      # no search path for DLLs.
 15.8605 +      hardcode_libdir_flag_spec=' '
 15.8606 +      allow_undefined_flag=unsupported
 15.8607 +      # Tell ltmain to make .lib files, not .a files.
 15.8608 +      libext=lib
 15.8609 +      # Tell ltmain to make .dll files, not .so files.
 15.8610 +      shrext_cmds=".dll"
 15.8611 +      # FIXME: Setting linknames here is a bad hack.
 15.8612 +      archive_cmds='$CC -o $lib $libobjs $compiler_flags `func_echo_all "$deplibs" | $SED '\''s/ -lc$//'\''` -link -dll~linknames='
 15.8613 +      # The linker will automatically build a .lib file if we build a DLL.
 15.8614 +      old_archive_from_new_cmds='true'
 15.8615 +      # FIXME: Should let the user specify the lib program.
 15.8616 +      old_archive_cmds='lib -OUT:$oldlib$oldobjs$old_deplibs'
 15.8617 +      fix_srcfile_path='`cygpath -w "$srcfile"`'
 15.8618 +      enable_shared_with_static_runtimes=yes
 15.8619 +      ;;
 15.8620 +
 15.8621 +    darwin* | rhapsody*)
 15.8622 +
 15.8623 +
 15.8624 +  archive_cmds_need_lc=no
 15.8625 +  hardcode_direct=no
 15.8626 +  hardcode_automatic=yes
 15.8627 +  hardcode_shlibpath_var=unsupported
 15.8628 +  if test "$lt_cv_ld_force_load" = "yes"; then
 15.8629 +    whole_archive_flag_spec='`for conv in $convenience\"\"; do test  -n \"$conv\" && new_convenience=\"$new_convenience ${wl}-force_load,$conv\"; done; func_echo_all \"$new_convenience\"`'
 15.8630 +  else
 15.8631 +    whole_archive_flag_spec=''
 15.8632 +  fi
 15.8633 +  link_all_deplibs=yes
 15.8634 +  allow_undefined_flag="$_lt_dar_allow_undefined"
 15.8635 +  case $cc_basename in
 15.8636 +     ifort*) _lt_dar_can_shared=yes ;;
 15.8637 +     *) _lt_dar_can_shared=$GCC ;;
 15.8638 +  esac
 15.8639 +  if test "$_lt_dar_can_shared" = "yes"; then
 15.8640 +    output_verbose_link_cmd=func_echo_all
 15.8641 +    archive_cmds="\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring $_lt_dar_single_mod${_lt_dsymutil}"
 15.8642 +    module_cmds="\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dsymutil}"
 15.8643 +    archive_expsym_cmds="sed 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring ${_lt_dar_single_mod}${_lt_dar_export_syms}${_lt_dsymutil}"
 15.8644 +    module_expsym_cmds="sed -e 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dar_export_syms}${_lt_dsymutil}"
 15.8645 +
 15.8646 +  else
 15.8647 +  ld_shlibs=no
 15.8648 +  fi
 15.8649 +
 15.8650 +      ;;
 15.8651 +
 15.8652 +    dgux*)
 15.8653 +      archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
 15.8654 +      hardcode_libdir_flag_spec='-L$libdir'
 15.8655 +      hardcode_shlibpath_var=no
 15.8656 +      ;;
 15.8657 +
 15.8658 +    freebsd1*)
 15.8659 +      ld_shlibs=no
 15.8660 +      ;;
 15.8661 +
 15.8662 +    # FreeBSD 2.2.[012] allows us to include c++rt0.o to get C++ constructor
 15.8663 +    # support.  Future versions do this automatically, but an explicit c++rt0.o
 15.8664 +    # does not break anything, and helps significantly (at the cost of a little
 15.8665 +    # extra space).
 15.8666 +    freebsd2.2*)
 15.8667 +      archive_cmds='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags /usr/lib/c++rt0.o'
 15.8668 +      hardcode_libdir_flag_spec='-R$libdir'
 15.8669 +      hardcode_direct=yes
 15.8670 +      hardcode_shlibpath_var=no
 15.8671 +      ;;
 15.8672 +
 15.8673 +    # Unfortunately, older versions of FreeBSD 2 do not have this feature.
 15.8674 +    freebsd2*)
 15.8675 +      archive_cmds='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags'
 15.8676 +      hardcode_direct=yes
 15.8677 +      hardcode_minus_L=yes
 15.8678 +      hardcode_shlibpath_var=no
 15.8679 +      ;;
 15.8680 +
 15.8681 +    # FreeBSD 3 and greater uses gcc -shared to do shared libraries.
 15.8682 +    freebsd* | dragonfly*)
 15.8683 +      archive_cmds='$CC -shared -o $lib $libobjs $deplibs $compiler_flags'
 15.8684 +      hardcode_libdir_flag_spec='-R$libdir'
 15.8685 +      hardcode_direct=yes
 15.8686 +      hardcode_shlibpath_var=no
 15.8687 +      ;;
 15.8688 +
 15.8689 +    hpux9*)
 15.8690 +      if test "$GCC" = yes; then
 15.8691 +	archive_cmds='$RM $output_objdir/$soname~$CC -shared -fPIC ${wl}+b ${wl}$install_libdir -o $output_objdir/$soname $libobjs $deplibs $compiler_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib'
 15.8692 +      else
 15.8693 +	archive_cmds='$RM $output_objdir/$soname~$LD -b +b $install_libdir -o $output_objdir/$soname $libobjs $deplibs $linker_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib'
 15.8694 +      fi
 15.8695 +      hardcode_libdir_flag_spec='${wl}+b ${wl}$libdir'
 15.8696 +      hardcode_libdir_separator=:
 15.8697 +      hardcode_direct=yes
 15.8698 +
 15.8699 +      # hardcode_minus_L: Not really in the search PATH,
 15.8700 +      # but as the default location of the library.
 15.8701 +      hardcode_minus_L=yes
 15.8702 +      export_dynamic_flag_spec='${wl}-E'
 15.8703 +      ;;
 15.8704 +
 15.8705 +    hpux10*)
 15.8706 +      if test "$GCC" = yes && test "$with_gnu_ld" = no; then
 15.8707 +	archive_cmds='$CC -shared -fPIC ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags'
 15.8708 +      else
 15.8709 +	archive_cmds='$LD -b +h $soname +b $install_libdir -o $lib $libobjs $deplibs $linker_flags'
 15.8710 +      fi
 15.8711 +      if test "$with_gnu_ld" = no; then
 15.8712 +	hardcode_libdir_flag_spec='${wl}+b ${wl}$libdir'
 15.8713 +	hardcode_libdir_flag_spec_ld='+b $libdir'
 15.8714 +	hardcode_libdir_separator=:
 15.8715 +	hardcode_direct=yes
 15.8716 +	hardcode_direct_absolute=yes
 15.8717 +	export_dynamic_flag_spec='${wl}-E'
 15.8718 +	# hardcode_minus_L: Not really in the search PATH,
 15.8719 +	# but as the default location of the library.
 15.8720 +	hardcode_minus_L=yes
 15.8721 +      fi
 15.8722 +      ;;
 15.8723 +
 15.8724 +    hpux11*)
 15.8725 +      if test "$GCC" = yes && test "$with_gnu_ld" = no; then
 15.8726 +	case $host_cpu in
 15.8727 +	hppa*64*)
 15.8728 +	  archive_cmds='$CC -shared ${wl}+h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags'
 15.8729 +	  ;;
 15.8730 +	ia64*)
 15.8731 +	  archive_cmds='$CC -shared -fPIC ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $libobjs $deplibs $compiler_flags'
 15.8732 +	  ;;
 15.8733 +	*)
 15.8734 +	  archive_cmds='$CC -shared -fPIC ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags'
 15.8735 +	  ;;
 15.8736 +	esac
 15.8737 +      else
 15.8738 +	case $host_cpu in
 15.8739 +	hppa*64*)
 15.8740 +	  archive_cmds='$CC -b ${wl}+h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags'
 15.8741 +	  ;;
 15.8742 +	ia64*)
 15.8743 +	  archive_cmds='$CC -b ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $libobjs $deplibs $compiler_flags'
 15.8744 +	  ;;
 15.8745 +	*)
 15.8746 +
 15.8747 +	  # Older versions of the 11.00 compiler do not understand -b yet
 15.8748 +	  # (HP92453-01 A.11.01.20 doesn't, HP92453-01 B.11.X.35175-35176.GP does)
 15.8749 +	  { $as_echo "$as_me:${as_lineno-$LINENO}: checking if $CC understands -b" >&5
 15.8750 +$as_echo_n "checking if $CC understands -b... " >&6; }
 15.8751 +if test "${lt_cv_prog_compiler__b+set}" = set; then :
 15.8752 +  $as_echo_n "(cached) " >&6
 15.8753 +else
 15.8754 +  lt_cv_prog_compiler__b=no
 15.8755 +   save_LDFLAGS="$LDFLAGS"
 15.8756 +   LDFLAGS="$LDFLAGS -b"
 15.8757 +   echo "$lt_simple_link_test_code" > conftest.$ac_ext
 15.8758 +   if (eval $ac_link 2>conftest.err) && test -s conftest$ac_exeext; then
 15.8759 +     # The linker can only warn and ignore the option if not recognized
 15.8760 +     # So say no if there are warnings
 15.8761 +     if test -s conftest.err; then
 15.8762 +       # Append any errors to the config.log.
 15.8763 +       cat conftest.err 1>&5
 15.8764 +       $ECHO "$_lt_linker_boilerplate" | $SED '/^$/d' > conftest.exp
 15.8765 +       $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2
 15.8766 +       if diff conftest.exp conftest.er2 >/dev/null; then
 15.8767 +         lt_cv_prog_compiler__b=yes
 15.8768 +       fi
 15.8769 +     else
 15.8770 +       lt_cv_prog_compiler__b=yes
 15.8771 +     fi
 15.8772 +   fi
 15.8773 +   $RM -r conftest*
 15.8774 +   LDFLAGS="$save_LDFLAGS"
 15.8775 +
 15.8776 +fi
 15.8777 +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler__b" >&5
 15.8778 +$as_echo "$lt_cv_prog_compiler__b" >&6; }
 15.8779 +
 15.8780 +if test x"$lt_cv_prog_compiler__b" = xyes; then
 15.8781 +    archive_cmds='$CC -b ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags'
 15.8782 +else
 15.8783 +    archive_cmds='$LD -b +h $soname +b $install_libdir -o $lib $libobjs $deplibs $linker_flags'
 15.8784 +fi
 15.8785 +
 15.8786 +	  ;;
 15.8787 +	esac
 15.8788 +      fi
 15.8789 +      if test "$with_gnu_ld" = no; then
 15.8790 +	hardcode_libdir_flag_spec='${wl}+b ${wl}$libdir'
 15.8791 +	hardcode_libdir_separator=:
 15.8792 +
 15.8793 +	case $host_cpu in
 15.8794 +	hppa*64*|ia64*)
 15.8795 +	  hardcode_direct=no
 15.8796 +	  hardcode_shlibpath_var=no
 15.8797 +	  ;;
 15.8798 +	*)
 15.8799 +	  hardcode_direct=yes
 15.8800 +	  hardcode_direct_absolute=yes
 15.8801 +	  export_dynamic_flag_spec='${wl}-E'
 15.8802 +
 15.8803 +	  # hardcode_minus_L: Not really in the search PATH,
 15.8804 +	  # but as the default location of the library.
 15.8805 +	  hardcode_minus_L=yes
 15.8806 +	  ;;
 15.8807 +	esac
 15.8808 +      fi
 15.8809 +      ;;
 15.8810 +
 15.8811 +    irix5* | irix6* | nonstopux*)
 15.8812 +      if test "$GCC" = yes; then
 15.8813 +	archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version ${wl}$verstring"` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib'
 15.8814 +	# Try to use the -exported_symbol ld option, if it does not
 15.8815 +	# work, assume that -exports_file does not work either and
 15.8816 +	# implicitly export all symbols.
 15.8817 +        save_LDFLAGS="$LDFLAGS"
 15.8818 +        LDFLAGS="$LDFLAGS -shared ${wl}-exported_symbol ${wl}foo ${wl}-update_registry ${wl}/dev/null"
 15.8819 +        cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 15.8820 +/* end confdefs.h.  */
 15.8821 +int foo(void) {}
 15.8822 +_ACEOF
 15.8823 +if ac_fn_c_try_link "$LINENO"; then :
 15.8824 +  archive_expsym_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version ${wl}$verstring"` ${wl}-update_registry ${wl}${output_objdir}/so_locations ${wl}-exports_file ${wl}$export_symbols -o $lib'
 15.8825 +
 15.8826 +fi
 15.8827 +rm -f core conftest.err conftest.$ac_objext \
 15.8828 +    conftest$ac_exeext conftest.$ac_ext
 15.8829 +        LDFLAGS="$save_LDFLAGS"
 15.8830 +      else
 15.8831 +	archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry ${output_objdir}/so_locations -o $lib'
 15.8832 +	archive_expsym_cmds='$CC -shared $libobjs $deplibs $compiler_flags -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry ${output_objdir}/so_locations -exports_file $export_symbols -o $lib'
 15.8833 +      fi
 15.8834 +      archive_cmds_need_lc='no'
 15.8835 +      hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir'
 15.8836 +      hardcode_libdir_separator=:
 15.8837 +      inherit_rpath=yes
 15.8838 +      link_all_deplibs=yes
 15.8839 +      ;;
 15.8840 +
 15.8841 +    netbsd*)
 15.8842 +      if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then
 15.8843 +	archive_cmds='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags'  # a.out
 15.8844 +      else
 15.8845 +	archive_cmds='$LD -shared -o $lib $libobjs $deplibs $linker_flags'      # ELF
 15.8846 +      fi
 15.8847 +      hardcode_libdir_flag_spec='-R$libdir'
 15.8848 +      hardcode_direct=yes
 15.8849 +      hardcode_shlibpath_var=no
 15.8850 +      ;;
 15.8851 +
 15.8852 +    newsos6)
 15.8853 +      archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
 15.8854 +      hardcode_direct=yes
 15.8855 +      hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir'
 15.8856 +      hardcode_libdir_separator=:
 15.8857 +      hardcode_shlibpath_var=no
 15.8858 +      ;;
 15.8859 +
 15.8860 +    *nto* | *qnx*)
 15.8861 +      ;;
 15.8862 +
 15.8863 +    openbsd*)
 15.8864 +      if test -f /usr/libexec/ld.so; then
 15.8865 +	hardcode_direct=yes
 15.8866 +	hardcode_shlibpath_var=no
 15.8867 +	hardcode_direct_absolute=yes
 15.8868 +	if test -z "`echo __ELF__ | $CC -E - | $GREP __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then
 15.8869 +	  archive_cmds='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags'
 15.8870 +	  archive_expsym_cmds='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags ${wl}-retain-symbols-file,$export_symbols'
 15.8871 +	  hardcode_libdir_flag_spec='${wl}-rpath,$libdir'
 15.8872 +	  export_dynamic_flag_spec='${wl}-E'
 15.8873 +	else
 15.8874 +	  case $host_os in
 15.8875 +	   openbsd[01].* | openbsd2.[0-7] | openbsd2.[0-7].*)
 15.8876 +	     archive_cmds='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags'
 15.8877 +	     hardcode_libdir_flag_spec='-R$libdir'
 15.8878 +	     ;;
 15.8879 +	   *)
 15.8880 +	     archive_cmds='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags'
 15.8881 +	     hardcode_libdir_flag_spec='${wl}-rpath,$libdir'
 15.8882 +	     ;;
 15.8883 +	  esac
 15.8884 +	fi
 15.8885 +      else
 15.8886 +	ld_shlibs=no
 15.8887 +      fi
 15.8888 +      ;;
 15.8889 +
 15.8890 +    os2*)
 15.8891 +      hardcode_libdir_flag_spec='-L$libdir'
 15.8892 +      hardcode_minus_L=yes
 15.8893 +      allow_undefined_flag=unsupported
 15.8894 +      archive_cmds='$ECHO "LIBRARY $libname INITINSTANCE" > $output_objdir/$libname.def~$ECHO "DESCRIPTION \"$libname\"" >> $output_objdir/$libname.def~echo DATA >> $output_objdir/$libname.def~echo " SINGLE NONSHARED" >> $output_objdir/$libname.def~echo EXPORTS >> $output_objdir/$libname.def~emxexp $libobjs >> $output_objdir/$libname.def~$CC -Zdll -Zcrtdll -o $lib $libobjs $deplibs $compiler_flags $output_objdir/$libname.def'
 15.8895 +      old_archive_from_new_cmds='emximp -o $output_objdir/$libname.a $output_objdir/$libname.def'
 15.8896 +      ;;
 15.8897 +
 15.8898 +    osf3*)
 15.8899 +      if test "$GCC" = yes; then
 15.8900 +	allow_undefined_flag=' ${wl}-expect_unresolved ${wl}\*'
 15.8901 +	archive_cmds='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version ${wl}$verstring"` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib'
 15.8902 +      else
 15.8903 +	allow_undefined_flag=' -expect_unresolved \*'
 15.8904 +	archive_cmds='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry ${output_objdir}/so_locations -o $lib'
 15.8905 +      fi
 15.8906 +      archive_cmds_need_lc='no'
 15.8907 +      hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir'
 15.8908 +      hardcode_libdir_separator=:
 15.8909 +      ;;
 15.8910 +
 15.8911 +    osf4* | osf5*)	# as osf3* with the addition of -msym flag
 15.8912 +      if test "$GCC" = yes; then
 15.8913 +	allow_undefined_flag=' ${wl}-expect_unresolved ${wl}\*'
 15.8914 +	archive_cmds='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags ${wl}-msym ${wl}-soname ${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version ${wl}$verstring"` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib'
 15.8915 +	hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir'
 15.8916 +      else
 15.8917 +	allow_undefined_flag=' -expect_unresolved \*'
 15.8918 +	archive_cmds='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags -msym -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry ${output_objdir}/so_locations -o $lib'
 15.8919 +	archive_expsym_cmds='for i in `cat $export_symbols`; do printf "%s %s\\n" -exported_symbol "\$i" >> $lib.exp; done; printf "%s\\n" "-hidden">> $lib.exp~
 15.8920 +	$CC -shared${allow_undefined_flag} ${wl}-input ${wl}$lib.exp $compiler_flags $libobjs $deplibs -soname $soname `test -n "$verstring" && $ECHO "-set_version $verstring"` -update_registry ${output_objdir}/so_locations -o $lib~$RM $lib.exp'
 15.8921 +
 15.8922 +	# Both c and cxx compiler support -rpath directly
 15.8923 +	hardcode_libdir_flag_spec='-rpath $libdir'
 15.8924 +      fi
 15.8925 +      archive_cmds_need_lc='no'
 15.8926 +      hardcode_libdir_separator=:
 15.8927 +      ;;
 15.8928 +
 15.8929 +    solaris*)
 15.8930 +      no_undefined_flag=' -z defs'
 15.8931 +      if test "$GCC" = yes; then
 15.8932 +	wlarc='${wl}'
 15.8933 +	archive_cmds='$CC -shared ${wl}-z ${wl}text ${wl}-h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags'
 15.8934 +	archive_expsym_cmds='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~
 15.8935 +	  $CC -shared ${wl}-z ${wl}text ${wl}-M ${wl}$lib.exp ${wl}-h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags~$RM $lib.exp'
 15.8936 +      else
 15.8937 +	case `$CC -V 2>&1` in
 15.8938 +	*"Compilers 5.0"*)
 15.8939 +	  wlarc=''
 15.8940 +	  archive_cmds='$LD -G${allow_undefined_flag} -h $soname -o $lib $libobjs $deplibs $linker_flags'
 15.8941 +	  archive_expsym_cmds='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~
 15.8942 +	  $LD -G${allow_undefined_flag} -M $lib.exp -h $soname -o $lib $libobjs $deplibs $linker_flags~$RM $lib.exp'
 15.8943 +	  ;;
 15.8944 +	*)
 15.8945 +	  wlarc='${wl}'
 15.8946 +	  archive_cmds='$CC -G${allow_undefined_flag} -h $soname -o $lib $libobjs $deplibs $compiler_flags'
 15.8947 +	  archive_expsym_cmds='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~
 15.8948 +	  $CC -G${allow_undefined_flag} -M $lib.exp -h $soname -o $lib $libobjs $deplibs $compiler_flags~$RM $lib.exp'
 15.8949 +	  ;;
 15.8950 +	esac
 15.8951 +      fi
 15.8952 +      hardcode_libdir_flag_spec='-R$libdir'
 15.8953 +      hardcode_shlibpath_var=no
 15.8954 +      case $host_os in
 15.8955 +      solaris2.[0-5] | solaris2.[0-5].*) ;;
 15.8956 +      *)
 15.8957 +	# The compiler driver will combine and reorder linker options,
 15.8958 +	# but understands `-z linker_flag'.  GCC discards it without `$wl',
 15.8959 +	# but is careful enough not to reorder.
 15.8960 +	# Supported since Solaris 2.6 (maybe 2.5.1?)
 15.8961 +	if test "$GCC" = yes; then
 15.8962 +	  whole_archive_flag_spec='${wl}-z ${wl}allextract$convenience ${wl}-z ${wl}defaultextract'
 15.8963 +	else
 15.8964 +	  whole_archive_flag_spec='-z allextract$convenience -z defaultextract'
 15.8965 +	fi
 15.8966 +	;;
 15.8967 +      esac
 15.8968 +      link_all_deplibs=yes
 15.8969 +      ;;
 15.8970 +
 15.8971 +    sunos4*)
 15.8972 +      if test "x$host_vendor" = xsequent; then
 15.8973 +	# Use $CC to link under sequent, because it throws in some extra .o
 15.8974 +	# files that make .init and .fini sections work.
 15.8975 +	archive_cmds='$CC -G ${wl}-h $soname -o $lib $libobjs $deplibs $compiler_flags'
 15.8976 +      else
 15.8977 +	archive_cmds='$LD -assert pure-text -Bstatic -o $lib $libobjs $deplibs $linker_flags'
 15.8978 +      fi
 15.8979 +      hardcode_libdir_flag_spec='-L$libdir'
 15.8980 +      hardcode_direct=yes
 15.8981 +      hardcode_minus_L=yes
 15.8982 +      hardcode_shlibpath_var=no
 15.8983 +      ;;
 15.8984 +
 15.8985 +    sysv4)
 15.8986 +      case $host_vendor in
 15.8987 +	sni)
 15.8988 +	  archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
 15.8989 +	  hardcode_direct=yes # is this really true???
 15.8990 +	;;
 15.8991 +	siemens)
 15.8992 +	  ## LD is ld it makes a PLAMLIB
 15.8993 +	  ## CC just makes a GrossModule.
 15.8994 +	  archive_cmds='$LD -G -o $lib $libobjs $deplibs $linker_flags'
 15.8995 +	  reload_cmds='$CC -r -o $output$reload_objs'
 15.8996 +	  hardcode_direct=no
 15.8997 +        ;;
 15.8998 +	motorola)
 15.8999 +	  archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
 15.9000 +	  hardcode_direct=no #Motorola manual says yes, but my tests say they lie
 15.9001 +	;;
 15.9002 +      esac
 15.9003 +      runpath_var='LD_RUN_PATH'
 15.9004 +      hardcode_shlibpath_var=no
 15.9005 +      ;;
 15.9006 +
 15.9007 +    sysv4.3*)
 15.9008 +      archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
 15.9009 +      hardcode_shlibpath_var=no
 15.9010 +      export_dynamic_flag_spec='-Bexport'
 15.9011 +      ;;
 15.9012 +
 15.9013 +    sysv4*MP*)
 15.9014 +      if test -d /usr/nec; then
 15.9015 +	archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
 15.9016 +	hardcode_shlibpath_var=no
 15.9017 +	runpath_var=LD_RUN_PATH
 15.9018 +	hardcode_runpath_var=yes
 15.9019 +	ld_shlibs=yes
 15.9020 +      fi
 15.9021 +      ;;
 15.9022 +
 15.9023 +    sysv4*uw2* | sysv5OpenUNIX* | sysv5UnixWare7.[01].[10]* | unixware7* | sco3.2v5.0.[024]*)
 15.9024 +      no_undefined_flag='${wl}-z,text'
 15.9025 +      archive_cmds_need_lc=no
 15.9026 +      hardcode_shlibpath_var=no
 15.9027 +      runpath_var='LD_RUN_PATH'
 15.9028 +
 15.9029 +      if test "$GCC" = yes; then
 15.9030 +	archive_cmds='$CC -shared ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
 15.9031 +	archive_expsym_cmds='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
 15.9032 +      else
 15.9033 +	archive_cmds='$CC -G ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
 15.9034 +	archive_expsym_cmds='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
 15.9035 +      fi
 15.9036 +      ;;
 15.9037 +
 15.9038 +    sysv5* | sco3.2v5* | sco5v6*)
 15.9039 +      # Note: We can NOT use -z defs as we might desire, because we do not
 15.9040 +      # link with -lc, and that would cause any symbols used from libc to
 15.9041 +      # always be unresolved, which means just about no library would
 15.9042 +      # ever link correctly.  If we're not using GNU ld we use -z text
 15.9043 +      # though, which does catch some bad symbols but isn't as heavy-handed
 15.9044 +      # as -z defs.
 15.9045 +      no_undefined_flag='${wl}-z,text'
 15.9046 +      allow_undefined_flag='${wl}-z,nodefs'
 15.9047 +      archive_cmds_need_lc=no
 15.9048 +      hardcode_shlibpath_var=no
 15.9049 +      hardcode_libdir_flag_spec='${wl}-R,$libdir'
 15.9050 +      hardcode_libdir_separator=':'
 15.9051 +      link_all_deplibs=yes
 15.9052 +      export_dynamic_flag_spec='${wl}-Bexport'
 15.9053 +      runpath_var='LD_RUN_PATH'
 15.9054 +
 15.9055 +      if test "$GCC" = yes; then
 15.9056 +	archive_cmds='$CC -shared ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
 15.9057 +	archive_expsym_cmds='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
 15.9058 +      else
 15.9059 +	archive_cmds='$CC -G ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
 15.9060 +	archive_expsym_cmds='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
 15.9061 +      fi
 15.9062 +      ;;
 15.9063 +
 15.9064 +    uts4*)
 15.9065 +      archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
 15.9066 +      hardcode_libdir_flag_spec='-L$libdir'
 15.9067 +      hardcode_shlibpath_var=no
 15.9068 +      ;;
 15.9069 +
 15.9070 +    *)
 15.9071 +      ld_shlibs=no
 15.9072 +      ;;
 15.9073 +    esac
 15.9074 +
 15.9075 +    if test x$host_vendor = xsni; then
 15.9076 +      case $host in
 15.9077 +      sysv4 | sysv4.2uw2* | sysv4.3* | sysv5*)
 15.9078 +	export_dynamic_flag_spec='${wl}-Blargedynsym'
 15.9079 +	;;
 15.9080 +      esac
 15.9081 +    fi
 15.9082 +  fi
 15.9083 +
 15.9084 +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ld_shlibs" >&5
 15.9085 +$as_echo "$ld_shlibs" >&6; }
 15.9086 +test "$ld_shlibs" = no && can_build_shared=no
 15.9087 +
 15.9088 +with_gnu_ld=$with_gnu_ld
 15.9089 +
 15.9090 +
 15.9091 +
 15.9092 +
 15.9093 +
 15.9094 +
 15.9095 +
 15.9096 +
 15.9097 +
 15.9098 +
 15.9099 +
 15.9100 +
 15.9101 +
 15.9102 +
 15.9103 +
 15.9104 +#
 15.9105 +# Do we need to explicitly link libc?
 15.9106 +#
 15.9107 +case "x$archive_cmds_need_lc" in
 15.9108 +x|xyes)
 15.9109 +  # Assume -lc should be added
 15.9110 +  archive_cmds_need_lc=yes
 15.9111 +
 15.9112 +  if test "$enable_shared" = yes && test "$GCC" = yes; then
 15.9113 +    case $archive_cmds in
 15.9114 +    *'~'*)
 15.9115 +      # FIXME: we may have to deal with multi-command sequences.
 15.9116 +      ;;
 15.9117 +    '$CC '*)
 15.9118 +      # Test whether the compiler implicitly links with -lc since on some
 15.9119 +      # systems, -lgcc has to come before -lc. If gcc already passes -lc
 15.9120 +      # to ld, don't add -lc before -lgcc.
 15.9121 +      { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether -lc should be explicitly linked in" >&5
 15.9122 +$as_echo_n "checking whether -lc should be explicitly linked in... " >&6; }
 15.9123 +if test "${lt_cv_archive_cmds_need_lc+set}" = set; then :
 15.9124 +  $as_echo_n "(cached) " >&6
 15.9125 +else
 15.9126 +  $RM conftest*
 15.9127 +	echo "$lt_simple_compile_test_code" > conftest.$ac_ext
 15.9128 +
 15.9129 +	if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5
 15.9130 +  (eval $ac_compile) 2>&5
 15.9131 +  ac_status=$?
 15.9132 +  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
 15.9133 +  test $ac_status = 0; } 2>conftest.err; then
 15.9134 +	  soname=conftest
 15.9135 +	  lib=conftest
 15.9136 +	  libobjs=conftest.$ac_objext
 15.9137 +	  deplibs=
 15.9138 +	  wl=$lt_prog_compiler_wl
 15.9139 +	  pic_flag=$lt_prog_compiler_pic
 15.9140 +	  compiler_flags=-v
 15.9141 +	  linker_flags=-v
 15.9142 +	  verstring=
 15.9143 +	  output_objdir=.
 15.9144 +	  libname=conftest
 15.9145 +	  lt_save_allow_undefined_flag=$allow_undefined_flag
 15.9146 +	  allow_undefined_flag=
 15.9147 +	  if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$archive_cmds 2\>\&1 \| $GREP \" -lc \" \>/dev/null 2\>\&1\""; } >&5
 15.9148 +  (eval $archive_cmds 2\>\&1 \| $GREP \" -lc \" \>/dev/null 2\>\&1) 2>&5
 15.9149 +  ac_status=$?
 15.9150 +  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
 15.9151 +  test $ac_status = 0; }
 15.9152 +	  then
 15.9153 +	    lt_cv_archive_cmds_need_lc=no
 15.9154 +	  else
 15.9155 +	    lt_cv_archive_cmds_need_lc=yes
 15.9156 +	  fi
 15.9157 +	  allow_undefined_flag=$lt_save_allow_undefined_flag
 15.9158 +	else
 15.9159 +	  cat conftest.err 1>&5
 15.9160 +	fi
 15.9161 +	$RM conftest*
 15.9162 +
 15.9163 +fi
 15.9164 +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_archive_cmds_need_lc" >&5
 15.9165 +$as_echo "$lt_cv_archive_cmds_need_lc" >&6; }
 15.9166 +      archive_cmds_need_lc=$lt_cv_archive_cmds_need_lc
 15.9167 +      ;;
 15.9168 +    esac
 15.9169 +  fi
 15.9170 +  ;;
 15.9171 +esac
 15.9172 +
 15.9173 +
 15.9174 +
 15.9175 +
 15.9176 +
 15.9177 +
 15.9178 +
 15.9179 +
 15.9180 +
 15.9181 +
 15.9182 +
 15.9183 +
 15.9184 +
 15.9185 +
 15.9186 +
 15.9187 +
 15.9188 +
 15.9189 +
 15.9190 +
 15.9191 +
 15.9192 +
 15.9193 +
 15.9194 +
 15.9195 +
 15.9196 +
 15.9197 +
 15.9198 +
 15.9199 +
 15.9200 +
 15.9201 +
 15.9202 +
 15.9203 +
 15.9204 +
 15.9205 +
 15.9206 +
 15.9207 +
 15.9208 +
 15.9209 +
 15.9210 +
 15.9211 +
 15.9212 +
 15.9213 +
 15.9214 +
 15.9215 +
 15.9216 +
 15.9217 +
 15.9218 +
 15.9219 +
 15.9220 +
 15.9221 +
 15.9222 +
 15.9223 +
 15.9224 +
 15.9225 +
 15.9226 +
 15.9227 +
 15.9228 +
 15.9229 +
 15.9230 +
 15.9231 +
 15.9232 +
 15.9233 +
 15.9234 +
 15.9235 +
 15.9236 +
 15.9237 +
 15.9238 +
 15.9239 +
 15.9240 +
 15.9241 +
 15.9242 +
 15.9243 +
 15.9244 +
 15.9245 +
 15.9246 +
 15.9247 +
 15.9248 +
 15.9249 +
 15.9250 +
 15.9251 +
 15.9252 +
 15.9253 +
 15.9254 +
 15.9255 +
 15.9256 +
 15.9257 +
 15.9258 +
 15.9259 +
 15.9260 +
 15.9261 +
 15.9262 +
 15.9263 +
 15.9264 +
 15.9265 +
 15.9266 +
 15.9267 +
 15.9268 +
 15.9269 +
 15.9270 +
 15.9271 +
 15.9272 +
 15.9273 +
 15.9274 +
 15.9275 +
 15.9276 +
 15.9277 +
 15.9278 +
 15.9279 +
 15.9280 +
 15.9281 +
 15.9282 +
 15.9283 +
 15.9284 +
 15.9285 +
 15.9286 +
 15.9287 +
 15.9288 +
 15.9289 +
 15.9290 +
 15.9291 +
 15.9292 +
 15.9293 +
 15.9294 +
 15.9295 +
 15.9296 +
 15.9297 +
 15.9298 +
 15.9299 +
 15.9300 +
 15.9301 +
 15.9302 +
 15.9303 +
 15.9304 +
 15.9305 +
 15.9306 +
 15.9307 +
 15.9308 +
 15.9309 +
 15.9310 +
 15.9311 +
 15.9312 +
 15.9313 +
 15.9314 +
 15.9315 +
 15.9316 +
 15.9317 +
 15.9318 +
 15.9319 +
 15.9320 +
 15.9321 +
 15.9322 +
 15.9323 +
 15.9324 +
 15.9325 +
 15.9326 +
 15.9327 +
 15.9328 +
 15.9329 +  { $as_echo "$as_me:${as_lineno-$LINENO}: checking dynamic linker characteristics" >&5
 15.9330 +$as_echo_n "checking dynamic linker characteristics... " >&6; }
 15.9331 +
 15.9332 +if test "$GCC" = yes; then
 15.9333 +  case $host_os in
 15.9334 +    darwin*) lt_awk_arg="/^libraries:/,/LR/" ;;
 15.9335 +    *) lt_awk_arg="/^libraries:/" ;;
 15.9336 +  esac
 15.9337 +  case $host_os in
 15.9338 +    mingw* | cegcc*) lt_sed_strip_eq="s,=\([A-Za-z]:\),\1,g" ;;
 15.9339 +    *) lt_sed_strip_eq="s,=/,/,g" ;;
 15.9340 +  esac
 15.9341 +  lt_search_path_spec=`$CC -print-search-dirs | awk $lt_awk_arg | $SED -e "s/^libraries://" -e $lt_sed_strip_eq`
 15.9342 +  case $lt_search_path_spec in
 15.9343 +  *\;*)
 15.9344 +    # if the path contains ";" then we assume it to be the separator
 15.9345 +    # otherwise default to the standard path separator (i.e. ":") - it is
 15.9346 +    # assumed that no part of a normal pathname contains ";" but that should
 15.9347 +    # okay in the real world where ";" in dirpaths is itself problematic.
 15.9348 +    lt_search_path_spec=`$ECHO "$lt_search_path_spec" | $SED 's/;/ /g'`
 15.9349 +    ;;
 15.9350 +  *)
 15.9351 +    lt_search_path_spec=`$ECHO "$lt_search_path_spec" | $SED "s/$PATH_SEPARATOR/ /g"`
 15.9352 +    ;;
 15.9353 +  esac
 15.9354 +  # Ok, now we have the path, separated by spaces, we can step through it
 15.9355 +  # and add multilib dir if necessary.
 15.9356 +  lt_tmp_lt_search_path_spec=
 15.9357 +  lt_multi_os_dir=`$CC $CPPFLAGS $CFLAGS $LDFLAGS -print-multi-os-directory 2>/dev/null`
 15.9358 +  for lt_sys_path in $lt_search_path_spec; do
 15.9359 +    if test -d "$lt_sys_path/$lt_multi_os_dir"; then
 15.9360 +      lt_tmp_lt_search_path_spec="$lt_tmp_lt_search_path_spec $lt_sys_path/$lt_multi_os_dir"
 15.9361 +    else
 15.9362 +      test -d "$lt_sys_path" && \
 15.9363 +	lt_tmp_lt_search_path_spec="$lt_tmp_lt_search_path_spec $lt_sys_path"
 15.9364 +    fi
 15.9365 +  done
 15.9366 +  lt_search_path_spec=`$ECHO "$lt_tmp_lt_search_path_spec" | awk '
 15.9367 +BEGIN {RS=" "; FS="/|\n";} {
 15.9368 +  lt_foo="";
 15.9369 +  lt_count=0;
 15.9370 +  for (lt_i = NF; lt_i > 0; lt_i--) {
 15.9371 +    if ($lt_i != "" && $lt_i != ".") {
 15.9372 +      if ($lt_i == "..") {
 15.9373 +        lt_count++;
 15.9374 +      } else {
 15.9375 +        if (lt_count == 0) {
 15.9376 +          lt_foo="/" $lt_i lt_foo;
 15.9377 +        } else {
 15.9378 +          lt_count--;
 15.9379 +        }
 15.9380 +      }
 15.9381 +    }
 15.9382 +  }
 15.9383 +  if (lt_foo != "") { lt_freq[lt_foo]++; }
 15.9384 +  if (lt_freq[lt_foo] == 1) { print lt_foo; }
 15.9385 +}'`
 15.9386 +  # AWK program above erroneously prepends '/' to C:/dos/paths
 15.9387 +  # for these hosts.
 15.9388 +  case $host_os in
 15.9389 +    mingw* | cegcc*) lt_search_path_spec=`$ECHO "$lt_search_path_spec" |\
 15.9390 +      $SED 's,/\([A-Za-z]:\),\1,g'` ;;
 15.9391 +  esac
 15.9392 +  sys_lib_search_path_spec=`$ECHO "$lt_search_path_spec" | $lt_NL2SP`
 15.9393 +else
 15.9394 +  sys_lib_search_path_spec="/lib /usr/lib /usr/local/lib"
 15.9395 +fi
 15.9396 +library_names_spec=
 15.9397 +libname_spec='lib$name'
 15.9398 +soname_spec=
 15.9399 +shrext_cmds=".so"
 15.9400 +postinstall_cmds=
 15.9401 +postuninstall_cmds=
 15.9402 +finish_cmds=
 15.9403 +finish_eval=
 15.9404 +shlibpath_var=
 15.9405 +shlibpath_overrides_runpath=unknown
 15.9406 +version_type=none
 15.9407 +dynamic_linker="$host_os ld.so"
 15.9408 +sys_lib_dlsearch_path_spec="/lib /usr/lib"
 15.9409 +need_lib_prefix=unknown
 15.9410 +hardcode_into_libs=no
 15.9411 +
 15.9412 +# when you set need_version to no, make sure it does not cause -set_version
 15.9413 +# flags to be left without arguments
 15.9414 +need_version=unknown
 15.9415 +
 15.9416 +case $host_os in
 15.9417 +aix3*)
 15.9418 +  version_type=linux
 15.9419 +  library_names_spec='${libname}${release}${shared_ext}$versuffix $libname.a'
 15.9420 +  shlibpath_var=LIBPATH
 15.9421 +
 15.9422 +  # AIX 3 has no versioning support, so we append a major version to the name.
 15.9423 +  soname_spec='${libname}${release}${shared_ext}$major'
 15.9424 +  ;;
 15.9425 +
 15.9426 +aix[4-9]*)
 15.9427 +  version_type=linux
 15.9428 +  need_lib_prefix=no
 15.9429 +  need_version=no
 15.9430 +  hardcode_into_libs=yes
 15.9431 +  if test "$host_cpu" = ia64; then
 15.9432 +    # AIX 5 supports IA64
 15.9433 +    library_names_spec='${libname}${release}${shared_ext}$major ${libname}${release}${shared_ext}$versuffix $libname${shared_ext}'
 15.9434 +    shlibpath_var=LD_LIBRARY_PATH
 15.9435 +  else
 15.9436 +    # With GCC up to 2.95.x, collect2 would create an import file
 15.9437 +    # for dependence libraries.  The import file would start with
 15.9438 +    # the line `#! .'.  This would cause the generated library to
 15.9439 +    # depend on `.', always an invalid library.  This was fixed in
 15.9440 +    # development snapshots of GCC prior to 3.0.
 15.9441 +    case $host_os in
 15.9442 +      aix4 | aix4.[01] | aix4.[01].*)
 15.9443 +      if { echo '#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 97)'
 15.9444 +	   echo ' yes '
 15.9445 +	   echo '#endif'; } | ${CC} -E - | $GREP yes > /dev/null; then
 15.9446 +	:
 15.9447 +      else
 15.9448 +	can_build_shared=no
 15.9449 +      fi
 15.9450 +      ;;
 15.9451 +    esac
 15.9452 +    # AIX (on Power*) has no versioning support, so currently we can not hardcode correct
 15.9453 +    # soname into executable. Probably we can add versioning support to
 15.9454 +    # collect2, so additional links can be useful in future.
 15.9455 +    if test "$aix_use_runtimelinking" = yes; then
 15.9456 +      # If using run time linking (on AIX 4.2 or later) use lib<name>.so
 15.9457 +      # instead of lib<name>.a to let people know that these are not
 15.9458 +      # typical AIX shared libraries.
 15.9459 +      library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
 15.9460 +    else
 15.9461 +      # We preserve .a as extension for shared libraries through AIX4.2
 15.9462 +      # and later when we are not doing run time linking.
 15.9463 +      library_names_spec='${libname}${release}.a $libname.a'
 15.9464 +      soname_spec='${libname}${release}${shared_ext}$major'
 15.9465 +    fi
 15.9466 +    shlibpath_var=LIBPATH
 15.9467 +  fi
 15.9468 +  ;;
 15.9469 +
 15.9470 +amigaos*)
 15.9471 +  case $host_cpu in
 15.9472 +  powerpc)
 15.9473 +    # Since July 2007 AmigaOS4 officially supports .so libraries.
 15.9474 +    # When compiling the executable, add -use-dynld -Lsobjs: to the compileline.
 15.9475 +    library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
 15.9476 +    ;;
 15.9477 +  m68k)
 15.9478 +    library_names_spec='$libname.ixlibrary $libname.a'
 15.9479 +    # Create ${libname}_ixlibrary.a entries in /sys/libs.
 15.9480 +    finish_eval='for lib in `ls $libdir/*.ixlibrary 2>/dev/null`; do libname=`func_echo_all "$lib" | $SED '\''s%^.*/\([^/]*\)\.ixlibrary$%\1%'\''`; test $RM /sys/libs/${libname}_ixlibrary.a; $show "cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a"; cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a || exit 1; done'
 15.9481 +    ;;
 15.9482 +  esac
 15.9483 +  ;;
 15.9484 +
 15.9485 +beos*)
 15.9486 +  library_names_spec='${libname}${shared_ext}'
 15.9487 +  dynamic_linker="$host_os ld.so"
 15.9488 +  shlibpath_var=LIBRARY_PATH
 15.9489 +  ;;
 15.9490 +
 15.9491 +bsdi[45]*)
 15.9492 +  version_type=linux
 15.9493 +  need_version=no
 15.9494 +  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
 15.9495 +  soname_spec='${libname}${release}${shared_ext}$major'
 15.9496 +  finish_cmds='PATH="\$PATH:/sbin" ldconfig $libdir'
 15.9497 +  shlibpath_var=LD_LIBRARY_PATH
 15.9498 +  sys_lib_search_path_spec="/shlib /usr/lib /usr/X11/lib /usr/contrib/lib /lib /usr/local/lib"
 15.9499 +  sys_lib_dlsearch_path_spec="/shlib /usr/lib /usr/local/lib"
 15.9500 +  # the default ld.so.conf also contains /usr/contrib/lib and
 15.9501 +  # /usr/X11R6/lib (/usr/X11 is a link to /usr/X11R6), but let us allow
 15.9502 +  # libtool to hard-code these into programs
 15.9503 +  ;;
 15.9504 +
 15.9505 +cygwin* | mingw* | pw32* | cegcc*)
 15.9506 +  version_type=windows
 15.9507 +  shrext_cmds=".dll"
 15.9508 +  need_version=no
 15.9509 +  need_lib_prefix=no
 15.9510 +
 15.9511 +  case $GCC,$host_os in
 15.9512 +  yes,cygwin* | yes,mingw* | yes,pw32* | yes,cegcc*)
 15.9513 +    library_names_spec='$libname.dll.a'
 15.9514 +    # DLL is installed to $(libdir)/../bin by postinstall_cmds
 15.9515 +    postinstall_cmds='base_file=`basename \${file}`~
 15.9516 +      dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\${base_file}'\''i; echo \$dlname'\''`~
 15.9517 +      dldir=$destdir/`dirname \$dlpath`~
 15.9518 +      test -d \$dldir || mkdir -p \$dldir~
 15.9519 +      $install_prog $dir/$dlname \$dldir/$dlname~
 15.9520 +      chmod a+x \$dldir/$dlname~
 15.9521 +      if test -n '\''$stripme'\'' && test -n '\''$striplib'\''; then
 15.9522 +        eval '\''$striplib \$dldir/$dlname'\'' || exit \$?;
 15.9523 +      fi'
 15.9524 +    postuninstall_cmds='dldll=`$SHELL 2>&1 -c '\''. $file; echo \$dlname'\''`~
 15.9525 +      dlpath=$dir/\$dldll~
 15.9526 +       $RM \$dlpath'
 15.9527 +    shlibpath_overrides_runpath=yes
 15.9528 +
 15.9529 +    case $host_os in
 15.9530 +    cygwin*)
 15.9531 +      # Cygwin DLLs use 'cyg' prefix rather than 'lib'
 15.9532 +      soname_spec='`echo ${libname} | sed -e 's/^lib/cyg/'``echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext}'
 15.9533 +
 15.9534 +      sys_lib_search_path_spec="$sys_lib_search_path_spec /usr/lib/w32api"
 15.9535 +      ;;
 15.9536 +    mingw* | cegcc*)
 15.9537 +      # MinGW DLLs use traditional 'lib' prefix
 15.9538 +      soname_spec='${libname}`echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext}'
 15.9539 +      ;;
 15.9540 +    pw32*)
 15.9541 +      # pw32 DLLs use 'pw' prefix rather than 'lib'
 15.9542 +      library_names_spec='`echo ${libname} | sed -e 's/^lib/pw/'``echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext}'
 15.9543 +      ;;
 15.9544 +    esac
 15.9545 +    ;;
 15.9546 +
 15.9547 +  *)
 15.9548 +    library_names_spec='${libname}`echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext} $libname.lib'
 15.9549 +    ;;
 15.9550 +  esac
 15.9551 +  dynamic_linker='Win32 ld.exe'
 15.9552 +  # FIXME: first we should search . and the directory the executable is in
 15.9553 +  shlibpath_var=PATH
 15.9554 +  ;;
 15.9555 +
 15.9556 +darwin* | rhapsody*)
 15.9557 +  dynamic_linker="$host_os dyld"
 15.9558 +  version_type=darwin
 15.9559 +  need_lib_prefix=no
 15.9560 +  need_version=no
 15.9561 +  library_names_spec='${libname}${release}${major}$shared_ext ${libname}$shared_ext'
 15.9562 +  soname_spec='${libname}${release}${major}$shared_ext'
 15.9563 +  shlibpath_overrides_runpath=yes
 15.9564 +  shlibpath_var=DYLD_LIBRARY_PATH
 15.9565 +  shrext_cmds='`test .$module = .yes && echo .so || echo .dylib`'
 15.9566 +
 15.9567 +  sys_lib_search_path_spec="$sys_lib_search_path_spec /usr/local/lib"
 15.9568 +  sys_lib_dlsearch_path_spec='/usr/local/lib /lib /usr/lib'
 15.9569 +  ;;
 15.9570 +
 15.9571 +dgux*)
 15.9572 +  version_type=linux
 15.9573 +  need_lib_prefix=no
 15.9574 +  need_version=no
 15.9575 +  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname$shared_ext'
 15.9576 +  soname_spec='${libname}${release}${shared_ext}$major'
 15.9577 +  shlibpath_var=LD_LIBRARY_PATH
 15.9578 +  ;;
 15.9579 +
 15.9580 +freebsd1*)
 15.9581 +  dynamic_linker=no
 15.9582 +  ;;
 15.9583 +
 15.9584 +freebsd* | dragonfly*)
 15.9585 +  # DragonFly does not have aout.  When/if they implement a new
 15.9586 +  # versioning mechanism, adjust this.
 15.9587 +  if test -x /usr/bin/objformat; then
 15.9588 +    objformat=`/usr/bin/objformat`
 15.9589 +  else
 15.9590 +    case $host_os in
 15.9591 +    freebsd[123]*) objformat=aout ;;
 15.9592 +    *) objformat=elf ;;
 15.9593 +    esac
 15.9594 +  fi
 15.9595 +  version_type=freebsd-$objformat
 15.9596 +  case $version_type in
 15.9597 +    freebsd-elf*)
 15.9598 +      library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext} $libname${shared_ext}'
 15.9599 +      need_version=no
 15.9600 +      need_lib_prefix=no
 15.9601 +      ;;
 15.9602 +    freebsd-*)
 15.9603 +      library_names_spec='${libname}${release}${shared_ext}$versuffix $libname${shared_ext}$versuffix'
 15.9604 +      need_version=yes
 15.9605 +      ;;
 15.9606 +  esac
 15.9607 +  shlibpath_var=LD_LIBRARY_PATH
 15.9608 +  case $host_os in
 15.9609 +  freebsd2*)
 15.9610 +    shlibpath_overrides_runpath=yes
 15.9611 +    ;;
 15.9612 +  freebsd3.[01]* | freebsdelf3.[01]*)
 15.9613 +    shlibpath_overrides_runpath=yes
 15.9614 +    hardcode_into_libs=yes
 15.9615 +    ;;
 15.9616 +  freebsd3.[2-9]* | freebsdelf3.[2-9]* | \
 15.9617 +  freebsd4.[0-5] | freebsdelf4.[0-5] | freebsd4.1.1 | freebsdelf4.1.1)
 15.9618 +    shlibpath_overrides_runpath=no
 15.9619 +    hardcode_into_libs=yes
 15.9620 +    ;;
 15.9621 +  *) # from 4.6 on, and DragonFly
 15.9622 +    shlibpath_overrides_runpath=yes
 15.9623 +    hardcode_into_libs=yes
 15.9624 +    ;;
 15.9625 +  esac
 15.9626 +  ;;
 15.9627 +
 15.9628 +gnu*)
 15.9629 +  version_type=linux
 15.9630 +  need_lib_prefix=no
 15.9631 +  need_version=no
 15.9632 +  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}${major} ${libname}${shared_ext}'
 15.9633 +  soname_spec='${libname}${release}${shared_ext}$major'
 15.9634 +  shlibpath_var=LD_LIBRARY_PATH
 15.9635 +  hardcode_into_libs=yes
 15.9636 +  ;;
 15.9637 +
 15.9638 +haiku*)
 15.9639 +  version_type=linux
 15.9640 +  need_lib_prefix=no
 15.9641 +  need_version=no
 15.9642 +  dynamic_linker="$host_os runtime_loader"
 15.9643 +  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}${major} ${libname}${shared_ext}'
 15.9644 +  soname_spec='${libname}${release}${shared_ext}$major'
 15.9645 +  shlibpath_var=LIBRARY_PATH
 15.9646 +  shlibpath_overrides_runpath=yes
 15.9647 +  sys_lib_dlsearch_path_spec='/boot/home/config/lib /boot/common/lib /boot/beos/system/lib'
 15.9648 +  hardcode_into_libs=yes
 15.9649 +  ;;
 15.9650 +
 15.9651 +hpux9* | hpux10* | hpux11*)
 15.9652 +  # Give a soname corresponding to the major version so that dld.sl refuses to
 15.9653 +  # link against other versions.
 15.9654 +  version_type=sunos
 15.9655 +  need_lib_prefix=no
 15.9656 +  need_version=no
 15.9657 +  case $host_cpu in
 15.9658 +  ia64*)
 15.9659 +    shrext_cmds='.so'
 15.9660 +    hardcode_into_libs=yes
 15.9661 +    dynamic_linker="$host_os dld.so"
 15.9662 +    shlibpath_var=LD_LIBRARY_PATH
 15.9663 +    shlibpath_overrides_runpath=yes # Unless +noenvvar is specified.
 15.9664 +    library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
 15.9665 +    soname_spec='${libname}${release}${shared_ext}$major'
 15.9666 +    if test "X$HPUX_IA64_MODE" = X32; then
 15.9667 +      sys_lib_search_path_spec="/usr/lib/hpux32 /usr/local/lib/hpux32 /usr/local/lib"
 15.9668 +    else
 15.9669 +      sys_lib_search_path_spec="/usr/lib/hpux64 /usr/local/lib/hpux64"
 15.9670 +    fi
 15.9671 +    sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec
 15.9672 +    ;;
 15.9673 +  hppa*64*)
 15.9674 +    shrext_cmds='.sl'
 15.9675 +    hardcode_into_libs=yes
 15.9676 +    dynamic_linker="$host_os dld.sl"
 15.9677 +    shlibpath_var=LD_LIBRARY_PATH # How should we handle SHLIB_PATH
 15.9678 +    shlibpath_overrides_runpath=yes # Unless +noenvvar is specified.
 15.9679 +    library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
 15.9680 +    soname_spec='${libname}${release}${shared_ext}$major'
 15.9681 +    sys_lib_search_path_spec="/usr/lib/pa20_64 /usr/ccs/lib/pa20_64"
 15.9682 +    sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec
 15.9683 +    ;;
 15.9684 +  *)
 15.9685 +    shrext_cmds='.sl'
 15.9686 +    dynamic_linker="$host_os dld.sl"
 15.9687 +    shlibpath_var=SHLIB_PATH
 15.9688 +    shlibpath_overrides_runpath=no # +s is required to enable SHLIB_PATH
 15.9689 +    library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
 15.9690 +    soname_spec='${libname}${release}${shared_ext}$major'
 15.9691 +    ;;
 15.9692 +  esac
 15.9693 +  # HP-UX runs *really* slowly unless shared libraries are mode 555, ...
 15.9694 +  postinstall_cmds='chmod 555 $lib'
 15.9695 +  # or fails outright, so override atomically:
 15.9696 +  install_override_mode=555
 15.9697 +  ;;
 15.9698 +
 15.9699 +interix[3-9]*)
 15.9700 +  version_type=linux
 15.9701 +  need_lib_prefix=no
 15.9702 +  need_version=no
 15.9703 +  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}'
 15.9704 +  soname_spec='${libname}${release}${shared_ext}$major'
 15.9705 +  dynamic_linker='Interix 3.x ld.so.1 (PE, like ELF)'
 15.9706 +  shlibpath_var=LD_LIBRARY_PATH
 15.9707 +  shlibpath_overrides_runpath=no
 15.9708 +  hardcode_into_libs=yes
 15.9709 +  ;;
 15.9710 +
 15.9711 +irix5* | irix6* | nonstopux*)
 15.9712 +  case $host_os in
 15.9713 +    nonstopux*) version_type=nonstopux ;;
 15.9714 +    *)
 15.9715 +	if test "$lt_cv_prog_gnu_ld" = yes; then
 15.9716 +		version_type=linux
 15.9717 +	else
 15.9718 +		version_type=irix
 15.9719 +	fi ;;
 15.9720 +  esac
 15.9721 +  need_lib_prefix=no
 15.9722 +  need_version=no
 15.9723 +  soname_spec='${libname}${release}${shared_ext}$major'
 15.9724 +  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${release}${shared_ext} $libname${shared_ext}'
 15.9725 +  case $host_os in
 15.9726 +  irix5* | nonstopux*)
 15.9727 +    libsuff= shlibsuff=
 15.9728 +    ;;
 15.9729 +  *)
 15.9730 +    case $LD in # libtool.m4 will add one of these switches to LD
 15.9731 +    *-32|*"-32 "|*-melf32bsmip|*"-melf32bsmip ")
 15.9732 +      libsuff= shlibsuff= libmagic=32-bit;;
 15.9733 +    *-n32|*"-n32 "|*-melf32bmipn32|*"-melf32bmipn32 ")
 15.9734 +      libsuff=32 shlibsuff=N32 libmagic=N32;;
 15.9735 +    *-64|*"-64 "|*-melf64bmip|*"-melf64bmip ")
 15.9736 +      libsuff=64 shlibsuff=64 libmagic=64-bit;;
 15.9737 +    *) libsuff= shlibsuff= libmagic=never-match;;
 15.9738 +    esac
 15.9739 +    ;;
 15.9740 +  esac
 15.9741 +  shlibpath_var=LD_LIBRARY${shlibsuff}_PATH
 15.9742 +  shlibpath_overrides_runpath=no
 15.9743 +  sys_lib_search_path_spec="/usr/lib${libsuff} /lib${libsuff} /usr/local/lib${libsuff}"
 15.9744 +  sys_lib_dlsearch_path_spec="/usr/lib${libsuff} /lib${libsuff}"
 15.9745 +  hardcode_into_libs=yes
 15.9746 +  ;;
 15.9747 +
 15.9748 +# No shared lib support for Linux oldld, aout, or coff.
 15.9749 +linux*oldld* | linux*aout* | linux*coff*)
 15.9750 +  dynamic_linker=no
 15.9751 +  ;;
 15.9752 +
 15.9753 +# This must be Linux ELF.
 15.9754 +linux* | k*bsd*-gnu | kopensolaris*-gnu)
 15.9755 +  version_type=linux
 15.9756 +  need_lib_prefix=no
 15.9757 +  need_version=no
 15.9758 +  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
 15.9759 +  soname_spec='${libname}${release}${shared_ext}$major'
 15.9760 +  finish_cmds='PATH="\$PATH:/sbin" ldconfig -n $libdir'
 15.9761 +  shlibpath_var=LD_LIBRARY_PATH
 15.9762 +  shlibpath_overrides_runpath=no
 15.9763 +
 15.9764 +  # Some binutils ld are patched to set DT_RUNPATH
 15.9765 +  if test "${lt_cv_shlibpath_overrides_runpath+set}" = set; then :
 15.9766 +  $as_echo_n "(cached) " >&6
 15.9767 +else
 15.9768 +  lt_cv_shlibpath_overrides_runpath=no
 15.9769 +    save_LDFLAGS=$LDFLAGS
 15.9770 +    save_libdir=$libdir
 15.9771 +    eval "libdir=/foo; wl=\"$lt_prog_compiler_wl\"; \
 15.9772 +	 LDFLAGS=\"\$LDFLAGS $hardcode_libdir_flag_spec\""
 15.9773 +    cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 15.9774 +/* end confdefs.h.  */
 15.9775 +
 15.9776 +int
 15.9777 +main ()
 15.9778 +{
 15.9779 +
 15.9780 +  ;
 15.9781 +  return 0;
 15.9782 +}
 15.9783 +_ACEOF
 15.9784 +if ac_fn_c_try_link "$LINENO"; then :
 15.9785 +  if  ($OBJDUMP -p conftest$ac_exeext) 2>/dev/null | grep "RUNPATH.*$libdir" >/dev/null; then :
 15.9786 +  lt_cv_shlibpath_overrides_runpath=yes
 15.9787 +fi
 15.9788 +fi
 15.9789 +rm -f core conftest.err conftest.$ac_objext \
 15.9790 +    conftest$ac_exeext conftest.$ac_ext
 15.9791 +    LDFLAGS=$save_LDFLAGS
 15.9792 +    libdir=$save_libdir
 15.9793 +
 15.9794 +fi
 15.9795 +
 15.9796 +  shlibpath_overrides_runpath=$lt_cv_shlibpath_overrides_runpath
 15.9797 +
 15.9798 +  # This implies no fast_install, which is unacceptable.
 15.9799 +  # Some rework will be needed to allow for fast_install
 15.9800 +  # before this can be enabled.
 15.9801 +  hardcode_into_libs=yes
 15.9802 +
 15.9803 +  # Append ld.so.conf contents to the search path
 15.9804 +  if test -f /etc/ld.so.conf; then
 15.9805 +    lt_ld_extra=`awk '/^include / { system(sprintf("cd /etc; cat %s 2>/dev/null", \$2)); skip = 1; } { if (!skip) print \$0; skip = 0; }' < /etc/ld.so.conf | $SED -e 's/#.*//;/^[	 ]*hwcap[	 ]/d;s/[:,	]/ /g;s/=[^=]*$//;s/=[^= ]* / /g;s/"//g;/^$/d' | tr '\n' ' '`
 15.9806 +    sys_lib_dlsearch_path_spec="/lib /usr/lib $lt_ld_extra"
 15.9807 +  fi
 15.9808 +
 15.9809 +  # We used to test for /lib/ld.so.1 and disable shared libraries on
 15.9810 +  # powerpc, because MkLinux only supported shared libraries with the
 15.9811 +  # GNU dynamic linker.  Since this was broken with cross compilers,
 15.9812 +  # most powerpc-linux boxes support dynamic linking these days and
 15.9813 +  # people can always --disable-shared, the test was removed, and we
 15.9814 +  # assume the GNU/Linux dynamic linker is in use.
 15.9815 +  dynamic_linker='GNU/Linux ld.so'
 15.9816 +  ;;
 15.9817 +
 15.9818 +netbsd*)
 15.9819 +  version_type=sunos
 15.9820 +  need_lib_prefix=no
 15.9821 +  need_version=no
 15.9822 +  if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then
 15.9823 +    library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix'
 15.9824 +    finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir'
 15.9825 +    dynamic_linker='NetBSD (a.out) ld.so'
 15.9826 +  else
 15.9827 +    library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}'
 15.9828 +    soname_spec='${libname}${release}${shared_ext}$major'
 15.9829 +    dynamic_linker='NetBSD ld.elf_so'
 15.9830 +  fi
 15.9831 +  shlibpath_var=LD_LIBRARY_PATH
 15.9832 +  shlibpath_overrides_runpath=yes
 15.9833 +  hardcode_into_libs=yes
 15.9834 +  ;;
 15.9835 +
 15.9836 +newsos6)
 15.9837 +  version_type=linux
 15.9838 +  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
 15.9839 +  shlibpath_var=LD_LIBRARY_PATH
 15.9840 +  shlibpath_overrides_runpath=yes
 15.9841 +  ;;
 15.9842 +
 15.9843 +*nto* | *qnx*)
 15.9844 +  version_type=qnx
 15.9845 +  need_lib_prefix=no
 15.9846 +  need_version=no
 15.9847 +  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
 15.9848 +  soname_spec='${libname}${release}${shared_ext}$major'
 15.9849 +  shlibpath_var=LD_LIBRARY_PATH
 15.9850 +  shlibpath_overrides_runpath=no
 15.9851 +  hardcode_into_libs=yes
 15.9852 +  dynamic_linker='ldqnx.so'
 15.9853 +  ;;
 15.9854 +
 15.9855 +openbsd*)
 15.9856 +  version_type=sunos
 15.9857 +  sys_lib_dlsearch_path_spec="/usr/lib"
 15.9858 +  need_lib_prefix=no
 15.9859 +  # Some older versions of OpenBSD (3.3 at least) *do* need versioned libs.
 15.9860 +  case $host_os in
 15.9861 +    openbsd3.3 | openbsd3.3.*)	need_version=yes ;;
 15.9862 +    *)				need_version=no  ;;
 15.9863 +  esac
 15.9864 +  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix'
 15.9865 +  finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir'
 15.9866 +  shlibpath_var=LD_LIBRARY_PATH
 15.9867 +  if test -z "`echo __ELF__ | $CC -E - | $GREP __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then
 15.9868 +    case $host_os in
 15.9869 +      openbsd2.[89] | openbsd2.[89].*)
 15.9870 +	shlibpath_overrides_runpath=no
 15.9871 +	;;
 15.9872 +      *)
 15.9873 +	shlibpath_overrides_runpath=yes
 15.9874 +	;;
 15.9875 +      esac
 15.9876 +  else
 15.9877 +    shlibpath_overrides_runpath=yes
 15.9878 +  fi
 15.9879 +  ;;
 15.9880 +
 15.9881 +os2*)
 15.9882 +  libname_spec='$name'
 15.9883 +  shrext_cmds=".dll"
 15.9884 +  need_lib_prefix=no
 15.9885 +  library_names_spec='$libname${shared_ext} $libname.a'
 15.9886 +  dynamic_linker='OS/2 ld.exe'
 15.9887 +  shlibpath_var=LIBPATH
 15.9888 +  ;;
 15.9889 +
 15.9890 +osf3* | osf4* | osf5*)
 15.9891 +  version_type=osf
 15.9892 +  need_lib_prefix=no
 15.9893 +  need_version=no
 15.9894 +  soname_spec='${libname}${release}${shared_ext}$major'
 15.9895 +  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
 15.9896 +  shlibpath_var=LD_LIBRARY_PATH
 15.9897 +  sys_lib_search_path_spec="/usr/shlib /usr/ccs/lib /usr/lib/cmplrs/cc /usr/lib /usr/local/lib /var/shlib"
 15.9898 +  sys_lib_dlsearch_path_spec="$sys_lib_search_path_spec"
 15.9899 +  ;;
 15.9900 +
 15.9901 +rdos*)
 15.9902 +  dynamic_linker=no
 15.9903 +  ;;
 15.9904 +
 15.9905 +solaris*)
 15.9906 +  version_type=linux
 15.9907 +  need_lib_prefix=no
 15.9908 +  need_version=no
 15.9909 +  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
 15.9910 +  soname_spec='${libname}${release}${shared_ext}$major'
 15.9911 +  shlibpath_var=LD_LIBRARY_PATH
 15.9912 +  shlibpath_overrides_runpath=yes
 15.9913 +  hardcode_into_libs=yes
 15.9914 +  # ldd complains unless libraries are executable
 15.9915 +  postinstall_cmds='chmod +x $lib'
 15.9916 +  ;;
 15.9917 +
 15.9918 +sunos4*)
 15.9919 +  version_type=sunos
 15.9920 +  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix'
 15.9921 +  finish_cmds='PATH="\$PATH:/usr/etc" ldconfig $libdir'
 15.9922 +  shlibpath_var=LD_LIBRARY_PATH
 15.9923 +  shlibpath_overrides_runpath=yes
 15.9924 +  if test "$with_gnu_ld" = yes; then
 15.9925 +    need_lib_prefix=no
 15.9926 +  fi
 15.9927 +  need_version=yes
 15.9928 +  ;;
 15.9929 +
 15.9930 +sysv4 | sysv4.3*)
 15.9931 +  version_type=linux
 15.9932 +  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
 15.9933 +  soname_spec='${libname}${release}${shared_ext}$major'
 15.9934 +  shlibpath_var=LD_LIBRARY_PATH
 15.9935 +  case $host_vendor in
 15.9936 +    sni)
 15.9937 +      shlibpath_overrides_runpath=no
 15.9938 +      need_lib_prefix=no
 15.9939 +      runpath_var=LD_RUN_PATH
 15.9940 +      ;;
 15.9941 +    siemens)
 15.9942 +      need_lib_prefix=no
 15.9943 +      ;;
 15.9944 +    motorola)
 15.9945 +      need_lib_prefix=no
 15.9946 +      need_version=no
 15.9947 +      shlibpath_overrides_runpath=no
 15.9948 +      sys_lib_search_path_spec='/lib /usr/lib /usr/ccs/lib'
 15.9949 +      ;;
 15.9950 +  esac
 15.9951 +  ;;
 15.9952 +
 15.9953 +sysv4*MP*)
 15.9954 +  if test -d /usr/nec ;then
 15.9955 +    version_type=linux
 15.9956 +    library_names_spec='$libname${shared_ext}.$versuffix $libname${shared_ext}.$major $libname${shared_ext}'
 15.9957 +    soname_spec='$libname${shared_ext}.$major'
 15.9958 +    shlibpath_var=LD_LIBRARY_PATH
 15.9959 +  fi
 15.9960 +  ;;
 15.9961 +
 15.9962 +sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX* | sysv4*uw2*)
 15.9963 +  version_type=freebsd-elf
 15.9964 +  need_lib_prefix=no
 15.9965 +  need_version=no
 15.9966 +  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext} $libname${shared_ext}'
 15.9967 +  soname_spec='${libname}${release}${shared_ext}$major'
 15.9968 +  shlibpath_var=LD_LIBRARY_PATH
 15.9969 +  shlibpath_overrides_runpath=yes
 15.9970 +  hardcode_into_libs=yes
 15.9971 +  if test "$with_gnu_ld" = yes; then
 15.9972 +    sys_lib_search_path_spec='/usr/local/lib /usr/gnu/lib /usr/ccs/lib /usr/lib /lib'
 15.9973 +  else
 15.9974 +    sys_lib_search_path_spec='/usr/ccs/lib /usr/lib'
 15.9975 +    case $host_os in
 15.9976 +      sco3.2v5*)
 15.9977 +        sys_lib_search_path_spec="$sys_lib_search_path_spec /lib"
 15.9978 +	;;
 15.9979 +    esac
 15.9980 +  fi
 15.9981 +  sys_lib_dlsearch_path_spec='/usr/lib'
 15.9982 +  ;;
 15.9983 +
 15.9984 +tpf*)
 15.9985 +  # TPF is a cross-target only.  Preferred cross-host = GNU/Linux.
 15.9986 +  version_type=linux
 15.9987 +  need_lib_prefix=no
 15.9988 +  need_version=no
 15.9989 +  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
 15.9990 +  shlibpath_var=LD_LIBRARY_PATH
 15.9991 +  shlibpath_overrides_runpath=no
 15.9992 +  hardcode_into_libs=yes
 15.9993 +  ;;
 15.9994 +
 15.9995 +uts4*)
 15.9996 +  version_type=linux
 15.9997 +  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
 15.9998 +  soname_spec='${libname}${release}${shared_ext}$major'
 15.9999 +  shlibpath_var=LD_LIBRARY_PATH
15.10000 +  ;;
15.10001 +
15.10002 +*)
15.10003 +  dynamic_linker=no
15.10004 +  ;;
15.10005 +esac
15.10006 +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $dynamic_linker" >&5
15.10007 +$as_echo "$dynamic_linker" >&6; }
15.10008 +test "$dynamic_linker" = no && can_build_shared=no
15.10009 +
15.10010 +variables_saved_for_relink="PATH $shlibpath_var $runpath_var"
15.10011 +if test "$GCC" = yes; then
15.10012 +  variables_saved_for_relink="$variables_saved_for_relink GCC_EXEC_PREFIX COMPILER_PATH LIBRARY_PATH"
15.10013 +fi
15.10014 +
15.10015 +if test "${lt_cv_sys_lib_search_path_spec+set}" = set; then
15.10016 +  sys_lib_search_path_spec="$lt_cv_sys_lib_search_path_spec"
15.10017 +fi
15.10018 +if test "${lt_cv_sys_lib_dlsearch_path_spec+set}" = set; then
15.10019 +  sys_lib_dlsearch_path_spec="$lt_cv_sys_lib_dlsearch_path_spec"
15.10020 +fi
15.10021 +
15.10022 +
15.10023 +
15.10024 +
15.10025 +
15.10026 +
15.10027 +
15.10028 +
15.10029 +
15.10030 +
15.10031 +
15.10032 +
15.10033 +
15.10034 +
15.10035 +
15.10036 +
15.10037 +
15.10038 +
15.10039 +
15.10040 +
15.10041 +
15.10042 +
15.10043 +
15.10044 +
15.10045 +
15.10046 +
15.10047 +
15.10048 +
15.10049 +
15.10050 +
15.10051 +
15.10052 +
15.10053 +
15.10054 +
15.10055 +
15.10056 +
15.10057 +
15.10058 +
15.10059 +
15.10060 +
15.10061 +
15.10062 +
15.10063 +
15.10064 +
15.10065 +
15.10066 +
15.10067 +
15.10068 +
15.10069 +
15.10070 +
15.10071 +
15.10072 +
15.10073 +
15.10074 +
15.10075 +
15.10076 +
15.10077 +
15.10078 +
15.10079 +
15.10080 +
15.10081 +
15.10082 +
15.10083 +
15.10084 +
15.10085 +
15.10086 +
15.10087 +
15.10088 +
15.10089 +
15.10090 +
15.10091 +
15.10092 +
15.10093 +
15.10094 +
15.10095 +
15.10096 +
15.10097 +
15.10098 +
15.10099 +
15.10100 +
15.10101 +
15.10102 +
15.10103 +
15.10104 +
15.10105 +
15.10106 +
15.10107 +
15.10108 +
15.10109 +
15.10110 +
15.10111 +
15.10112 +
15.10113 +  { $as_echo "$as_me:${as_lineno-$LINENO}: checking how to hardcode library paths into programs" >&5
15.10114 +$as_echo_n "checking how to hardcode library paths into programs... " >&6; }
15.10115 +hardcode_action=
15.10116 +if test -n "$hardcode_libdir_flag_spec" ||
15.10117 +   test -n "$runpath_var" ||
15.10118 +   test "X$hardcode_automatic" = "Xyes" ; then
15.10119 +
15.10120 +  # We can hardcode non-existent directories.
15.10121 +  if test "$hardcode_direct" != no &&
15.10122 +     # If the only mechanism to avoid hardcoding is shlibpath_var, we
15.10123 +     # have to relink, otherwise we might link with an installed library
15.10124 +     # when we should be linking with a yet-to-be-installed one
15.10125 +     ## test "$_LT_TAGVAR(hardcode_shlibpath_var, )" != no &&
15.10126 +     test "$hardcode_minus_L" != no; then
15.10127 +    # Linking always hardcodes the temporary library directory.
15.10128 +    hardcode_action=relink
15.10129 +  else
15.10130 +    # We can link without hardcoding, and we can hardcode nonexisting dirs.
15.10131 +    hardcode_action=immediate
15.10132 +  fi
15.10133 +else
15.10134 +  # We cannot hardcode anything, or else we can only hardcode existing
15.10135 +  # directories.
15.10136 +  hardcode_action=unsupported
15.10137 +fi
15.10138 +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $hardcode_action" >&5
15.10139 +$as_echo "$hardcode_action" >&6; }
15.10140 +
15.10141 +if test "$hardcode_action" = relink ||
15.10142 +   test "$inherit_rpath" = yes; then
15.10143 +  # Fast installation is not supported
15.10144 +  enable_fast_install=no
15.10145 +elif test "$shlibpath_overrides_runpath" = yes ||
15.10146 +     test "$enable_shared" = no; then
15.10147 +  # Fast installation is not necessary
15.10148 +  enable_fast_install=needless
15.10149 +fi
15.10150 +
15.10151 +
15.10152 +
15.10153 +
15.10154 +
15.10155 +
15.10156 +  if test "x$enable_dlopen" != xyes; then
15.10157 +  enable_dlopen=unknown
15.10158 +  enable_dlopen_self=unknown
15.10159 +  enable_dlopen_self_static=unknown
15.10160 +else
15.10161 +  lt_cv_dlopen=no
15.10162 +  lt_cv_dlopen_libs=
15.10163 +
15.10164 +  case $host_os in
15.10165 +  beos*)
15.10166 +    lt_cv_dlopen="load_add_on"
15.10167 +    lt_cv_dlopen_libs=
15.10168 +    lt_cv_dlopen_self=yes
15.10169 +    ;;
15.10170 +
15.10171 +  mingw* | pw32* | cegcc*)
15.10172 +    lt_cv_dlopen="LoadLibrary"
15.10173 +    lt_cv_dlopen_libs=
15.10174 +    ;;
15.10175 +
15.10176 +  cygwin*)
15.10177 +    lt_cv_dlopen="dlopen"
15.10178 +    lt_cv_dlopen_libs=
15.10179 +    ;;
15.10180 +
15.10181 +  darwin*)
15.10182 +  # if libdl is installed we need to link against it
15.10183 +    { $as_echo "$as_me:${as_lineno-$LINENO}: checking for dlopen in -ldl" >&5
15.10184 +$as_echo_n "checking for dlopen in -ldl... " >&6; }
15.10185 +if test "${ac_cv_lib_dl_dlopen+set}" = set; then :
15.10186 +  $as_echo_n "(cached) " >&6
15.10187 +else
15.10188 +  ac_check_lib_save_LIBS=$LIBS
15.10189 +LIBS="-ldl  $LIBS"
15.10190 +cat confdefs.h - <<_ACEOF >conftest.$ac_ext
15.10191 +/* end confdefs.h.  */
15.10192 +
15.10193 +/* Override any GCC internal prototype to avoid an error.
15.10194 +   Use char because int might match the return type of a GCC
15.10195 +   builtin and then its argument prototype would still apply.  */
15.10196 +#ifdef __cplusplus
15.10197 +extern "C"
15.10198 +#endif
15.10199 +char dlopen ();
15.10200 +int
15.10201 +main ()
15.10202 +{
15.10203 +return dlopen ();
15.10204 +  ;
15.10205 +  return 0;
15.10206 +}
15.10207 +_ACEOF
15.10208 +if ac_fn_c_try_link "$LINENO"; then :
15.10209 +  ac_cv_lib_dl_dlopen=yes
15.10210 +else
15.10211 +  ac_cv_lib_dl_dlopen=no
15.10212 +fi
15.10213 +rm -f core conftest.err conftest.$ac_objext \
15.10214 +    conftest$ac_exeext conftest.$ac_ext
15.10215 +LIBS=$ac_check_lib_save_LIBS
15.10216 +fi
15.10217 +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_dl_dlopen" >&5
15.10218 +$as_echo "$ac_cv_lib_dl_dlopen" >&6; }
15.10219 +if test "x$ac_cv_lib_dl_dlopen" = x""yes; then :
15.10220 +  lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-ldl"
15.10221 +else
15.10222 +
15.10223 +    lt_cv_dlopen="dyld"
15.10224 +    lt_cv_dlopen_libs=
15.10225 +    lt_cv_dlopen_self=yes
15.10226 +
15.10227 +fi
15.10228 +
15.10229 +    ;;
15.10230 +
15.10231 +  *)
15.10232 +    ac_fn_c_check_func "$LINENO" "shl_load" "ac_cv_func_shl_load"
15.10233 +if test "x$ac_cv_func_shl_load" = x""yes; then :
15.10234 +  lt_cv_dlopen="shl_load"
15.10235 +else
15.10236 +  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for shl_load in -ldld" >&5
15.10237 +$as_echo_n "checking for shl_load in -ldld... " >&6; }
15.10238 +if test "${ac_cv_lib_dld_shl_load+set}" = set; then :
15.10239 +  $as_echo_n "(cached) " >&6
15.10240 +else
15.10241 +  ac_check_lib_save_LIBS=$LIBS
15.10242 +LIBS="-ldld  $LIBS"
15.10243 +cat confdefs.h - <<_ACEOF >conftest.$ac_ext
15.10244 +/* end confdefs.h.  */
15.10245 +
15.10246 +/* Override any GCC internal prototype to avoid an error.
15.10247 +   Use char because int might match the return type of a GCC
15.10248 +   builtin and then its argument prototype would still apply.  */
15.10249 +#ifdef __cplusplus
15.10250 +extern "C"
15.10251 +#endif
15.10252 +char shl_load ();
15.10253 +int
15.10254 +main ()
15.10255 +{
15.10256 +return shl_load ();
15.10257 +  ;
15.10258 +  return 0;
15.10259 +}
15.10260 +_ACEOF
15.10261 +if ac_fn_c_try_link "$LINENO"; then :
15.10262 +  ac_cv_lib_dld_shl_load=yes
15.10263 +else
15.10264 +  ac_cv_lib_dld_shl_load=no
15.10265 +fi
15.10266 +rm -f core conftest.err conftest.$ac_objext \
15.10267 +    conftest$ac_exeext conftest.$ac_ext
15.10268 +LIBS=$ac_check_lib_save_LIBS
15.10269 +fi
15.10270 +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_dld_shl_load" >&5
15.10271 +$as_echo "$ac_cv_lib_dld_shl_load" >&6; }
15.10272 +if test "x$ac_cv_lib_dld_shl_load" = x""yes; then :
15.10273 +  lt_cv_dlopen="shl_load" lt_cv_dlopen_libs="-ldld"
15.10274 +else
15.10275 +  ac_fn_c_check_func "$LINENO" "dlopen" "ac_cv_func_dlopen"
15.10276 +if test "x$ac_cv_func_dlopen" = x""yes; then :
15.10277 +  lt_cv_dlopen="dlopen"
15.10278 +else
15.10279 +  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for dlopen in -ldl" >&5
15.10280 +$as_echo_n "checking for dlopen in -ldl... " >&6; }
15.10281 +if test "${ac_cv_lib_dl_dlopen+set}" = set; then :
15.10282 +  $as_echo_n "(cached) " >&6
15.10283 +else
15.10284 +  ac_check_lib_save_LIBS=$LIBS
15.10285 +LIBS="-ldl  $LIBS"
15.10286 +cat confdefs.h - <<_ACEOF >conftest.$ac_ext
15.10287 +/* end confdefs.h.  */
15.10288 +
15.10289 +/* Override any GCC internal prototype to avoid an error.
15.10290 +   Use char because int might match the return type of a GCC
15.10291 +   builtin and then its argument prototype would still apply.  */
15.10292 +#ifdef __cplusplus
15.10293 +extern "C"
15.10294 +#endif
15.10295 +char dlopen ();
15.10296 +int
15.10297 +main ()
15.10298 +{
15.10299 +return dlopen ();
15.10300 +  ;
15.10301 +  return 0;
15.10302 +}
15.10303 +_ACEOF
15.10304 +if ac_fn_c_try_link "$LINENO"; then :
15.10305 +  ac_cv_lib_dl_dlopen=yes
15.10306 +else
15.10307 +  ac_cv_lib_dl_dlopen=no
15.10308 +fi
15.10309 +rm -f core conftest.err conftest.$ac_objext \
15.10310 +    conftest$ac_exeext conftest.$ac_ext
15.10311 +LIBS=$ac_check_lib_save_LIBS
15.10312 +fi
15.10313 +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_dl_dlopen" >&5
15.10314 +$as_echo "$ac_cv_lib_dl_dlopen" >&6; }
15.10315 +if test "x$ac_cv_lib_dl_dlopen" = x""yes; then :
15.10316 +  lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-ldl"
15.10317 +else
15.10318 +  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for dlopen in -lsvld" >&5
15.10319 +$as_echo_n "checking for dlopen in -lsvld... " >&6; }
15.10320 +if test "${ac_cv_lib_svld_dlopen+set}" = set; then :
15.10321 +  $as_echo_n "(cached) " >&6
15.10322 +else
15.10323 +  ac_check_lib_save_LIBS=$LIBS
15.10324 +LIBS="-lsvld  $LIBS"
15.10325 +cat confdefs.h - <<_ACEOF >conftest.$ac_ext
15.10326 +/* end confdefs.h.  */
15.10327 +
15.10328 +/* Override any GCC internal prototype to avoid an error.
15.10329 +   Use char because int might match the return type of a GCC
15.10330 +   builtin and then its argument prototype would still apply.  */
15.10331 +#ifdef __cplusplus
15.10332 +extern "C"
15.10333 +#endif
15.10334 +char dlopen ();
15.10335 +int
15.10336 +main ()
15.10337 +{
15.10338 +return dlopen ();
15.10339 +  ;
15.10340 +  return 0;
15.10341 +}
15.10342 +_ACEOF
15.10343 +if ac_fn_c_try_link "$LINENO"; then :
15.10344 +  ac_cv_lib_svld_dlopen=yes
15.10345 +else
15.10346 +  ac_cv_lib_svld_dlopen=no
15.10347 +fi
15.10348 +rm -f core conftest.err conftest.$ac_objext \
15.10349 +    conftest$ac_exeext conftest.$ac_ext
15.10350 +LIBS=$ac_check_lib_save_LIBS
15.10351 +fi
15.10352 +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_svld_dlopen" >&5
15.10353 +$as_echo "$ac_cv_lib_svld_dlopen" >&6; }
15.10354 +if test "x$ac_cv_lib_svld_dlopen" = x""yes; then :
15.10355 +  lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-lsvld"
15.10356 +else
15.10357 +  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for dld_link in -ldld" >&5
15.10358 +$as_echo_n "checking for dld_link in -ldld... " >&6; }
15.10359 +if test "${ac_cv_lib_dld_dld_link+set}" = set; then :
15.10360 +  $as_echo_n "(cached) " >&6
15.10361 +else
15.10362 +  ac_check_lib_save_LIBS=$LIBS
15.10363 +LIBS="-ldld  $LIBS"
15.10364 +cat confdefs.h - <<_ACEOF >conftest.$ac_ext
15.10365 +/* end confdefs.h.  */
15.10366 +
15.10367 +/* Override any GCC internal prototype to avoid an error.
15.10368 +   Use char because int might match the return type of a GCC
15.10369 +   builtin and then its argument prototype would still apply.  */
15.10370 +#ifdef __cplusplus
15.10371 +extern "C"
15.10372 +#endif
15.10373 +char dld_link ();
15.10374 +int
15.10375 +main ()
15.10376 +{
15.10377 +return dld_link ();
15.10378 +  ;
15.10379 +  return 0;
15.10380 +}
15.10381 +_ACEOF
15.10382 +if ac_fn_c_try_link "$LINENO"; then :
15.10383 +  ac_cv_lib_dld_dld_link=yes
15.10384 +else
15.10385 +  ac_cv_lib_dld_dld_link=no
15.10386 +fi
15.10387 +rm -f core conftest.err conftest.$ac_objext \
15.10388 +    conftest$ac_exeext conftest.$ac_ext
15.10389 +LIBS=$ac_check_lib_save_LIBS
15.10390 +fi
15.10391 +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_dld_dld_link" >&5
15.10392 +$as_echo "$ac_cv_lib_dld_dld_link" >&6; }
15.10393 +if test "x$ac_cv_lib_dld_dld_link" = x""yes; then :
15.10394 +  lt_cv_dlopen="dld_link" lt_cv_dlopen_libs="-ldld"
15.10395 +fi
15.10396 +
15.10397 +
15.10398 +fi
15.10399 +
15.10400 +
15.10401 +fi
15.10402 +
15.10403 +
15.10404 +fi
15.10405 +
15.10406 +
15.10407 +fi
15.10408 +
15.10409 +
15.10410 +fi
15.10411 +
15.10412 +    ;;
15.10413 +  esac
15.10414 +
15.10415 +  if test "x$lt_cv_dlopen" != xno; then
15.10416 +    enable_dlopen=yes
15.10417 +  else
15.10418 +    enable_dlopen=no
15.10419 +  fi
15.10420 +
15.10421 +  case $lt_cv_dlopen in
15.10422 +  dlopen)
15.10423 +    save_CPPFLAGS="$CPPFLAGS"
15.10424 +    test "x$ac_cv_header_dlfcn_h" = xyes && CPPFLAGS="$CPPFLAGS -DHAVE_DLFCN_H"
15.10425 +
15.10426 +    save_LDFLAGS="$LDFLAGS"
15.10427 +    wl=$lt_prog_compiler_wl eval LDFLAGS=\"\$LDFLAGS $export_dynamic_flag_spec\"
15.10428 +
15.10429 +    save_LIBS="$LIBS"
15.10430 +    LIBS="$lt_cv_dlopen_libs $LIBS"
15.10431 +
15.10432 +    { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether a program can dlopen itself" >&5
15.10433 +$as_echo_n "checking whether a program can dlopen itself... " >&6; }
15.10434 +if test "${lt_cv_dlopen_self+set}" = set; then :
15.10435 +  $as_echo_n "(cached) " >&6
15.10436 +else
15.10437 +  	  if test "$cross_compiling" = yes; then :
15.10438 +  lt_cv_dlopen_self=cross
15.10439 +else
15.10440 +  lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
15.10441 +  lt_status=$lt_dlunknown
15.10442 +  cat > conftest.$ac_ext <<_LT_EOF
15.10443 +#line $LINENO "configure"
15.10444 +#include "confdefs.h"
15.10445 +
15.10446 +#if HAVE_DLFCN_H
15.10447 +#include <dlfcn.h>
15.10448 +#endif
15.10449 +
15.10450 +#include <stdio.h>
15.10451 +
15.10452 +#ifdef RTLD_GLOBAL
15.10453 +#  define LT_DLGLOBAL		RTLD_GLOBAL
15.10454 +#else
15.10455 +#  ifdef DL_GLOBAL
15.10456 +#    define LT_DLGLOBAL		DL_GLOBAL
15.10457 +#  else
15.10458 +#    define LT_DLGLOBAL		0
15.10459 +#  endif
15.10460 +#endif
15.10461 +
15.10462 +/* We may have to define LT_DLLAZY_OR_NOW in the command line if we
15.10463 +   find out it does not work in some platform. */
15.10464 +#ifndef LT_DLLAZY_OR_NOW
15.10465 +#  ifdef RTLD_LAZY
15.10466 +#    define LT_DLLAZY_OR_NOW		RTLD_LAZY
15.10467 +#  else
15.10468 +#    ifdef DL_LAZY
15.10469 +#      define LT_DLLAZY_OR_NOW		DL_LAZY
15.10470 +#    else
15.10471 +#      ifdef RTLD_NOW
15.10472 +#        define LT_DLLAZY_OR_NOW	RTLD_NOW
15.10473 +#      else
15.10474 +#        ifdef DL_NOW
15.10475 +#          define LT_DLLAZY_OR_NOW	DL_NOW
15.10476 +#        else
15.10477 +#          define LT_DLLAZY_OR_NOW	0
15.10478 +#        endif
15.10479 +#      endif
15.10480 +#    endif
15.10481 +#  endif
15.10482 +#endif
15.10483 +
15.10484 +/* When -fvisbility=hidden is used, assume the code has been annotated
15.10485 +   correspondingly for the symbols needed.  */
15.10486 +#if defined(__GNUC__) && (((__GNUC__ == 3) && (__GNUC_MINOR__ >= 3)) || (__GNUC__ > 3))
15.10487 +void fnord () __attribute__((visibility("default")));
15.10488 +#endif
15.10489 +
15.10490 +void fnord () { int i=42; }
15.10491 +int main ()
15.10492 +{
15.10493 +  void *self = dlopen (0, LT_DLGLOBAL|LT_DLLAZY_OR_NOW);
15.10494 +  int status = $lt_dlunknown;
15.10495 +
15.10496 +  if (self)
15.10497 +    {
15.10498 +      if (dlsym (self,"fnord"))       status = $lt_dlno_uscore;
15.10499 +      else
15.10500 +        {
15.10501 +	  if (dlsym( self,"_fnord"))  status = $lt_dlneed_uscore;
15.10502 +          else puts (dlerror ());
15.10503 +	}
15.10504 +      /* dlclose (self); */
15.10505 +    }
15.10506 +  else
15.10507 +    puts (dlerror ());
15.10508 +
15.10509 +  return status;
15.10510 +}
15.10511 +_LT_EOF
15.10512 +  if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_link\""; } >&5
15.10513 +  (eval $ac_link) 2>&5
15.10514 +  ac_status=$?
15.10515 +  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
15.10516 +  test $ac_status = 0; } && test -s conftest${ac_exeext} 2>/dev/null; then
15.10517 +    (./conftest; exit; ) >&5 2>/dev/null
15.10518 +    lt_status=$?
15.10519 +    case x$lt_status in
15.10520 +      x$lt_dlno_uscore) lt_cv_dlopen_self=yes ;;
15.10521 +      x$lt_dlneed_uscore) lt_cv_dlopen_self=yes ;;
15.10522 +      x$lt_dlunknown|x*) lt_cv_dlopen_self=no ;;
15.10523 +    esac
15.10524 +  else :
15.10525 +    # compilation failed
15.10526 +    lt_cv_dlopen_self=no
15.10527 +  fi
15.10528 +fi
15.10529 +rm -fr conftest*
15.10530 +
15.10531 +
15.10532 +fi
15.10533 +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_dlopen_self" >&5
15.10534 +$as_echo "$lt_cv_dlopen_self" >&6; }
15.10535 +
15.10536 +    if test "x$lt_cv_dlopen_self" = xyes; then
15.10537 +      wl=$lt_prog_compiler_wl eval LDFLAGS=\"\$LDFLAGS $lt_prog_compiler_static\"
15.10538 +      { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether a statically linked program can dlopen itself" >&5
15.10539 +$as_echo_n "checking whether a statically linked program can dlopen itself... " >&6; }
15.10540 +if test "${lt_cv_dlopen_self_static+set}" = set; then :
15.10541 +  $as_echo_n "(cached) " >&6
15.10542 +else
15.10543 +  	  if test "$cross_compiling" = yes; then :
15.10544 +  lt_cv_dlopen_self_static=cross
15.10545 +else
15.10546 +  lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
15.10547 +  lt_status=$lt_dlunknown
15.10548 +  cat > conftest.$ac_ext <<_LT_EOF
15.10549 +#line $LINENO "configure"
15.10550 +#include "confdefs.h"
15.10551 +
15.10552 +#if HAVE_DLFCN_H
15.10553 +#include <dlfcn.h>
15.10554 +#endif
15.10555 +
15.10556 +#include <stdio.h>
15.10557 +
15.10558 +#ifdef RTLD_GLOBAL
15.10559 +#  define LT_DLGLOBAL		RTLD_GLOBAL
15.10560 +#else
15.10561 +#  ifdef DL_GLOBAL
15.10562 +#    define LT_DLGLOBAL		DL_GLOBAL
15.10563 +#  else
15.10564 +#    define LT_DLGLOBAL		0
15.10565 +#  endif
15.10566 +#endif
15.10567 +
15.10568 +/* We may have to define LT_DLLAZY_OR_NOW in the command line if we
15.10569 +   find out it does not work in some platform. */
15.10570 +#ifndef LT_DLLAZY_OR_NOW
15.10571 +#  ifdef RTLD_LAZY
15.10572 +#    define LT_DLLAZY_OR_NOW		RTLD_LAZY
15.10573 +#  else
15.10574 +#    ifdef DL_LAZY
15.10575 +#      define LT_DLLAZY_OR_NOW		DL_LAZY
15.10576 +#    else
15.10577 +#      ifdef RTLD_NOW
15.10578 +#        define LT_DLLAZY_OR_NOW	RTLD_NOW
15.10579 +#      else
15.10580 +#        ifdef DL_NOW
15.10581 +#          define LT_DLLAZY_OR_NOW	DL_NOW
15.10582 +#        else
15.10583 +#          define LT_DLLAZY_OR_NOW	0
15.10584 +#        endif
15.10585 +#      endif
15.10586 +#    endif
15.10587 +#  endif
15.10588 +#endif
15.10589 +
15.10590 +/* When -fvisbility=hidden is used, assume the code has been annotated
15.10591 +   correspondingly for the symbols needed.  */
15.10592 +#if defined(__GNUC__) && (((__GNUC__ == 3) && (__GNUC_MINOR__ >= 3)) || (__GNUC__ > 3))
15.10593 +void fnord () __attribute__((visibility("default")));
15.10594 +#endif
15.10595 +
15.10596 +void fnord () { int i=42; }
15.10597 +int main ()
15.10598 +{
15.10599 +  void *self = dlopen (0, LT_DLGLOBAL|LT_DLLAZY_OR_NOW);
15.10600 +  int status = $lt_dlunknown;
15.10601 +
15.10602 +  if (self)
15.10603 +    {
15.10604 +      if (dlsym (self,"fnord"))       status = $lt_dlno_uscore;
15.10605 +      else
15.10606 +        {
15.10607 +	  if (dlsym( self,"_fnord"))  status = $lt_dlneed_uscore;
15.10608 +          else puts (dlerror ());
15.10609 +	}
15.10610 +      /* dlclose (self); */
15.10611 +    }
15.10612 +  else
15.10613 +    puts (dlerror ());
15.10614 +
15.10615 +  return status;
15.10616 +}
15.10617 +_LT_EOF
15.10618 +  if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_link\""; } >&5
15.10619 +  (eval $ac_link) 2>&5
15.10620 +  ac_status=$?
15.10621 +  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
15.10622 +  test $ac_status = 0; } && test -s conftest${ac_exeext} 2>/dev/null; then
15.10623 +    (./conftest; exit; ) >&5 2>/dev/null
15.10624 +    lt_status=$?
15.10625 +    case x$lt_status in
15.10626 +      x$lt_dlno_uscore) lt_cv_dlopen_self_static=yes ;;
15.10627 +      x$lt_dlneed_uscore) lt_cv_dlopen_self_static=yes ;;
15.10628 +      x$lt_dlunknown|x*) lt_cv_dlopen_self_static=no ;;
15.10629 +    esac
15.10630 +  else :
15.10631 +    # compilation failed
15.10632 +    lt_cv_dlopen_self_static=no
15.10633 +  fi
15.10634 +fi
15.10635 +rm -fr conftest*
15.10636 +
15.10637 +
15.10638 +fi
15.10639 +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_dlopen_self_static" >&5
15.10640 +$as_echo "$lt_cv_dlopen_self_static" >&6; }
15.10641 +    fi
15.10642 +
15.10643 +    CPPFLAGS="$save_CPPFLAGS"
15.10644 +    LDFLAGS="$save_LDFLAGS"
15.10645 +    LIBS="$save_LIBS"
15.10646 +    ;;
15.10647 +  esac
15.10648 +
15.10649 +  case $lt_cv_dlopen_self in
15.10650 +  yes|no) enable_dlopen_self=$lt_cv_dlopen_self ;;
15.10651 +  *) enable_dlopen_self=unknown ;;
15.10652 +  esac
15.10653 +
15.10654 +  case $lt_cv_dlopen_self_static in
15.10655 +  yes|no) enable_dlopen_self_static=$lt_cv_dlopen_self_static ;;
15.10656 +  *) enable_dlopen_self_static=unknown ;;
15.10657 +  esac
15.10658 +fi
15.10659 +
15.10660 +
15.10661 +
15.10662 +
15.10663 +
15.10664 +
15.10665 +
15.10666 +
15.10667 +
15.10668 +
15.10669 +
15.10670 +
15.10671 +
15.10672 +
15.10673 +
15.10674 +
15.10675 +
15.10676 +striplib=
15.10677 +old_striplib=
15.10678 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether stripping libraries is possible" >&5
15.10679 +$as_echo_n "checking whether stripping libraries is possible... " >&6; }
15.10680 +if test -n "$STRIP" && $STRIP -V 2>&1 | $GREP "GNU strip" >/dev/null; then
15.10681 +  test -z "$old_striplib" && old_striplib="$STRIP --strip-debug"
15.10682 +  test -z "$striplib" && striplib="$STRIP --strip-unneeded"
15.10683 +  { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
15.10684 +$as_echo "yes" >&6; }
15.10685 +else
15.10686 +# FIXME - insert some real tests, host_os isn't really good enough
15.10687 +  case $host_os in
15.10688 +  darwin*)
15.10689 +    if test -n "$STRIP" ; then
15.10690 +      striplib="$STRIP -x"
15.10691 +      old_striplib="$STRIP -S"
15.10692 +      { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
15.10693 +$as_echo "yes" >&6; }
15.10694 +    else
15.10695 +      { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
15.10696 +$as_echo "no" >&6; }
15.10697 +    fi
15.10698 +    ;;
15.10699 +  *)
15.10700 +    { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
15.10701 +$as_echo "no" >&6; }
15.10702 +    ;;
15.10703 +  esac
15.10704 +fi
15.10705 +
15.10706 +
15.10707 +
15.10708 +
15.10709 +
15.10710 +
15.10711 +
15.10712 +
15.10713 +
15.10714 +
15.10715 +
15.10716 +
15.10717 +  # Report which library types will actually be built
15.10718 +  { $as_echo "$as_me:${as_lineno-$LINENO}: checking if libtool supports shared libraries" >&5
15.10719 +$as_echo_n "checking if libtool supports shared libraries... " >&6; }
15.10720 +  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $can_build_shared" >&5
15.10721 +$as_echo "$can_build_shared" >&6; }
15.10722 +
15.10723 +  { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether to build shared libraries" >&5
15.10724 +$as_echo_n "checking whether to build shared libraries... " >&6; }
15.10725 +  test "$can_build_shared" = "no" && enable_shared=no
15.10726 +
15.10727 +  # On AIX, shared libraries and static libraries use the same namespace, and
15.10728 +  # are all built from PIC.
15.10729 +  case $host_os in
15.10730 +  aix3*)
15.10731 +    test "$enable_shared" = yes && enable_static=no
15.10732 +    if test -n "$RANLIB"; then
15.10733 +      archive_cmds="$archive_cmds~\$RANLIB \$lib"
15.10734 +      postinstall_cmds='$RANLIB $lib'
15.10735 +    fi
15.10736 +    ;;
15.10737 +
15.10738 +  aix[4-9]*)
15.10739 +    if test "$host_cpu" != ia64 && test "$aix_use_runtimelinking" = no ; then
15.10740 +      test "$enable_shared" = yes && enable_static=no
15.10741 +    fi
15.10742 +    ;;
15.10743 +  esac
15.10744 +  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $enable_shared" >&5
15.10745 +$as_echo "$enable_shared" >&6; }
15.10746 +
15.10747 +  { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether to build static libraries" >&5
15.10748 +$as_echo_n "checking whether to build static libraries... " >&6; }
15.10749 +  # Make sure either enable_shared or enable_static is yes.
15.10750 +  test "$enable_shared" = yes || enable_static=yes
15.10751 +  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $enable_static" >&5
15.10752 +$as_echo "$enable_static" >&6; }
15.10753 +
15.10754 +
15.10755 +
15.10756 +
15.10757 +fi
15.10758 +ac_ext=c
15.10759 +ac_cpp='$CPP $CPPFLAGS'
15.10760 +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
15.10761 +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
15.10762 +ac_compiler_gnu=$ac_cv_c_compiler_gnu
15.10763 +
15.10764 +CC="$lt_save_CC"
15.10765 +
15.10766 +
15.10767 +
15.10768 +
15.10769 +
15.10770 +
15.10771 +
15.10772 +
15.10773 +
15.10774 +
15.10775 +
15.10776 +
15.10777 +
15.10778 +        ac_config_commands="$ac_config_commands libtool"
15.10779 +
15.10780 +
15.10781 +
15.10782 +
15.10783 +# Only expand once:
15.10784 +
15.10785 +
15.10786 +
15.10787 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for exp in -lm" >&5
15.10788 +$as_echo_n "checking for exp in -lm... " >&6; }
15.10789 +if test "${ac_cv_lib_m_exp+set}" = set; then :
15.10790 +  $as_echo_n "(cached) " >&6
15.10791 +else
15.10792 +  ac_check_lib_save_LIBS=$LIBS
15.10793 +LIBS="-lm  $LIBS"
15.10794 +cat confdefs.h - <<_ACEOF >conftest.$ac_ext
15.10795 +/* end confdefs.h.  */
15.10796 +
15.10797 +/* Override any GCC internal prototype to avoid an error.
15.10798 +   Use char because int might match the return type of a GCC
15.10799 +   builtin and then its argument prototype would still apply.  */
15.10800 +#ifdef __cplusplus
15.10801 +extern "C"
15.10802 +#endif
15.10803 +char exp ();
15.10804 +int
15.10805 +main ()
15.10806 +{
15.10807 +return exp ();
15.10808 +  ;
15.10809 +  return 0;
15.10810 +}
15.10811 +_ACEOF
15.10812 +if ac_fn_c_try_link "$LINENO"; then :
15.10813 +  ac_cv_lib_m_exp=yes
15.10814 +else
15.10815 +  ac_cv_lib_m_exp=no
15.10816 +fi
15.10817 +rm -f core conftest.err conftest.$ac_objext \
15.10818 +    conftest$ac_exeext conftest.$ac_ext
15.10819 +LIBS=$ac_check_lib_save_LIBS
15.10820 +fi
15.10821 +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_m_exp" >&5
15.10822 +$as_echo "$ac_cv_lib_m_exp" >&6; }
15.10823 +if test "x$ac_cv_lib_m_exp" = x""yes; then :
15.10824 +  cat >>confdefs.h <<_ACEOF
15.10825 +#define HAVE_LIBM 1
15.10826 +_ACEOF
15.10827 +
15.10828 +  LIBS="-lm $LIBS"
15.10829 +
15.10830 +fi
15.10831 +
15.10832 +
15.10833 +ac_fn_c_check_header_mongrel "$LINENO" "sys/time.h" "ac_cv_header_sys_time_h" "$ac_includes_default"
15.10834 +if test "x$ac_cv_header_sys_time_h" = x""yes; then :
15.10835 +
15.10836 +$as_echo "#define HAVE_SYS_TIME_H 1" >>confdefs.h
15.10837 +
15.10838 +fi
15.10839 +
15.10840 +
15.10841 +
15.10842 +ac_fn_c_check_func "$LINENO" "gettimeofday" "ac_cv_func_gettimeofday"
15.10843 +if test "x$ac_cv_func_gettimeofday" = x""yes; then :
15.10844 +
15.10845 +$as_echo "#define HAVE_GETTIMEOFDAY 1" >>confdefs.h
15.10846 +
15.10847 +fi
15.10848 +
15.10849 +
15.10850 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether to use GNU MP bignum library" >&5
15.10851 +$as_echo_n "checking whether to use GNU MP bignum library... " >&6; }
15.10852 +if test "$with_gmp" = "yes"; then
15.10853 +   { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
15.10854 +$as_echo "yes" >&6; }
15.10855 +
15.10856 +$as_echo "#define HAVE_GMP 1" >>confdefs.h
15.10857 +
15.10858 +   LIBS="-lgmp $LIBS"
15.10859 +else
15.10860 +   { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
15.10861 +$as_echo "no" >&6; }
15.10862 +fi
15.10863 +
15.10864 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether to enable shared library support" >&5
15.10865 +$as_echo_n "checking whether to enable shared library support... " >&6; }
15.10866 +if test "$enable_dl" = "yes"; then
15.10867 +   { $as_echo "$as_me:${as_lineno-$LINENO}: result: ltdl" >&5
15.10868 +$as_echo "ltdl" >&6; }
15.10869 +
15.10870 +$as_echo "#define HAVE_LTDL 1" >>confdefs.h
15.10871 +
15.10872 +   LIBS="-lltdl $LIBS"
15.10873 +elif test "$enable_dl" = "ltdl"; then
15.10874 +   { $as_echo "$as_me:${as_lineno-$LINENO}: result: ltdl" >&5
15.10875 +$as_echo "ltdl" >&6; }
15.10876 +
15.10877 +$as_echo "#define HAVE_LTDL 1" >>confdefs.h
15.10878 +
15.10879 +   LIBS="-lltdl $LIBS"
15.10880 +elif test "$enable_dl" = "dlfcn"; then
15.10881 +   { $as_echo "$as_me:${as_lineno-$LINENO}: result: dlfcn" >&5
15.10882 +$as_echo "dlfcn" >&6; }
15.10883 +
15.10884 +$as_echo "#define HAVE_DLFCN 1" >>confdefs.h
15.10885 +
15.10886 +else
15.10887 +   { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
15.10888 +$as_echo "no" >&6; }
15.10889 +fi
15.10890 +
15.10891 +case $host_os in
15.10892 +   darwin* | macosx*)
15.10893 +      LIBIODBC="libiodbc.dylib"
15.10894 +      LIBODBC="libodbc.dylib"
15.10895 +      LIBMYSQL="libmysqlclient.dylib"
15.10896 +      ;;
15.10897 +   *)
15.10898 +      LIBIODBC="libiodbc.so"
15.10899 +      LIBODBC="libodbc.so"
15.10900 +      LIBMYSQL="libmysqlclient.so"
15.10901 +      ;;
15.10902 +esac
15.10903 +
15.10904 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether to enable MathProg ODBC support" >&5
15.10905 +$as_echo_n "checking whether to enable MathProg ODBC support... " >&6; }
15.10906 +if test "$enable_odbc" = "yes"; then
15.10907 +   if test "$enable_dl" = "no"; then
15.10908 +      as_fn_error "--enable-odbc requires --enable-dl" "$LINENO" 5
15.10909 +   fi
15.10910 +   { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
15.10911 +$as_echo "yes" >&6; }
15.10912 +
15.10913 +cat >>confdefs.h <<_ACEOF
15.10914 +#define ODBC_DLNAME "$LIBIODBC"
15.10915 +_ACEOF
15.10916 +
15.10917 +elif test "$enable_odbc" = "unix"; then
15.10918 +   if test "$enable_dl" = "no"; then
15.10919 +      as_fn_error "--enable-odbc requires --enable-dl" "$LINENO" 5
15.10920 +   fi
15.10921 +   { $as_echo "$as_me:${as_lineno-$LINENO}: result: unix" >&5
15.10922 +$as_echo "unix" >&6; }
15.10923 +
15.10924 +cat >>confdefs.h <<_ACEOF
15.10925 +#define ODBC_DLNAME "$LIBODBC"
15.10926 +_ACEOF
15.10927 +
15.10928 +else
15.10929 +   { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
15.10930 +$as_echo "no" >&6; }
15.10931 +fi
15.10932 +
15.10933 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether to enable MathProg MySQL support" >&5
15.10934 +$as_echo_n "checking whether to enable MathProg MySQL support... " >&6; }
15.10935 +if test "$enable_mysql" = "yes"; then
15.10936 +   if test "$enable_dl" = "no"; then
15.10937 +      as_fn_error "--enable-mysql requires --enable-dl" "$LINENO" 5
15.10938 +   fi
15.10939 +   { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
15.10940 +$as_echo "yes" >&6; }
15.10941 +   CPPFLAGS="-I/usr/include/mysql $CPPFLAGS"
15.10942 +
15.10943 +cat >>confdefs.h <<_ACEOF
15.10944 +#define MYSQL_DLNAME "$LIBMYSQL"
15.10945 +_ACEOF
15.10946 +
15.10947 +else
15.10948 +   { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
15.10949 +$as_echo "no" >&6; }
15.10950 +fi
15.10951 +
15.10952 +ac_config_files="$ac_config_files src/Makefile examples/Makefile Makefile"
15.10953 +
15.10954 +cat >confcache <<\_ACEOF
15.10955 +# This file is a shell script that caches the results of configure
15.10956 +# tests run on this system so they can be shared between configure
15.10957 +# scripts and configure runs, see configure's option --config-cache.
15.10958 +# It is not useful on other systems.  If it contains results you don't
15.10959 +# want to keep, you may remove or edit it.
15.10960 +#
15.10961 +# config.status only pays attention to the cache file if you give it
15.10962 +# the --recheck option to rerun configure.
15.10963 +#
15.10964 +# `ac_cv_env_foo' variables (set or unset) will be overridden when
15.10965 +# loading this file, other *unset* `ac_cv_foo' will be assigned the
15.10966 +# following values.
15.10967 +
15.10968 +_ACEOF
15.10969 +
15.10970 +# The following way of writing the cache mishandles newlines in values,
15.10971 +# but we know of no workaround that is simple, portable, and efficient.
15.10972 +# So, we kill variables containing newlines.
15.10973 +# Ultrix sh set writes to stderr and can't be redirected directly,
15.10974 +# and sets the high bit in the cache file unless we assign to the vars.
15.10975 +(
15.10976 +  for ac_var in `(set) 2>&1 | sed -n 's/^\([a-zA-Z_][a-zA-Z0-9_]*\)=.*/\1/p'`; do
15.10977 +    eval ac_val=\$$ac_var
15.10978 +    case $ac_val in #(
15.10979 +    *${as_nl}*)
15.10980 +      case $ac_var in #(
15.10981 +      *_cv_*) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: cache variable $ac_var contains a newline" >&5
15.10982 +$as_echo "$as_me: WARNING: cache variable $ac_var contains a newline" >&2;} ;;
15.10983 +      esac
15.10984 +      case $ac_var in #(
15.10985 +      _ | IFS | as_nl) ;; #(
15.10986 +      BASH_ARGV | BASH_SOURCE) eval $ac_var= ;; #(
15.10987 +      *) { eval $ac_var=; unset $ac_var;} ;;
15.10988 +      esac ;;
15.10989 +    esac
15.10990 +  done
15.10991 +
15.10992 +  (set) 2>&1 |
15.10993 +    case $as_nl`(ac_space=' '; set) 2>&1` in #(
15.10994 +    *${as_nl}ac_space=\ *)
15.10995 +      # `set' does not quote correctly, so add quotes: double-quote
15.10996 +      # substitution turns \\\\ into \\, and sed turns \\ into \.
15.10997 +      sed -n \
15.10998 +	"s/'/'\\\\''/g;
15.10999 +	  s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1='\\2'/p"
15.11000 +      ;; #(
15.11001 +    *)
15.11002 +      # `set' quotes correctly as required by POSIX, so do not add quotes.
15.11003 +      sed -n "/^[_$as_cr_alnum]*_cv_[_$as_cr_alnum]*=/p"
15.11004 +      ;;
15.11005 +    esac |
15.11006 +    sort
15.11007 +) |
15.11008 +  sed '
15.11009 +     /^ac_cv_env_/b end
15.11010 +     t clear
15.11011 +     :clear
15.11012 +     s/^\([^=]*\)=\(.*[{}].*\)$/test "${\1+set}" = set || &/
15.11013 +     t end
15.11014 +     s/^\([^=]*\)=\(.*\)$/\1=${\1=\2}/
15.11015 +     :end' >>confcache
15.11016 +if diff "$cache_file" confcache >/dev/null 2>&1; then :; else
15.11017 +  if test -w "$cache_file"; then
15.11018 +    test "x$cache_file" != "x/dev/null" &&
15.11019 +      { $as_echo "$as_me:${as_lineno-$LINENO}: updating cache $cache_file" >&5
15.11020 +$as_echo "$as_me: updating cache $cache_file" >&6;}
15.11021 +    cat confcache >$cache_file
15.11022 +  else
15.11023 +    { $as_echo "$as_me:${as_lineno-$LINENO}: not updating unwritable cache $cache_file" >&5
15.11024 +$as_echo "$as_me: not updating unwritable cache $cache_file" >&6;}
15.11025 +  fi
15.11026 +fi
15.11027 +rm -f confcache
15.11028 +
15.11029 +test "x$prefix" = xNONE && prefix=$ac_default_prefix
15.11030 +# Let make expand exec_prefix.
15.11031 +test "x$exec_prefix" = xNONE && exec_prefix='${prefix}'
15.11032 +
15.11033 +DEFS=-DHAVE_CONFIG_H
15.11034 +
15.11035 +ac_libobjs=
15.11036 +ac_ltlibobjs=
15.11037 +for ac_i in : $LIBOBJS; do test "x$ac_i" = x: && continue
15.11038 +  # 1. Remove the extension, and $U if already installed.
15.11039 +  ac_script='s/\$U\././;s/\.o$//;s/\.obj$//'
15.11040 +  ac_i=`$as_echo "$ac_i" | sed "$ac_script"`
15.11041 +  # 2. Prepend LIBOBJDIR.  When used with automake>=1.10 LIBOBJDIR
15.11042 +  #    will be set to the directory where LIBOBJS objects are built.
15.11043 +  as_fn_append ac_libobjs " \${LIBOBJDIR}$ac_i\$U.$ac_objext"
15.11044 +  as_fn_append ac_ltlibobjs " \${LIBOBJDIR}$ac_i"'$U.lo'
15.11045 +done
15.11046 +LIBOBJS=$ac_libobjs
15.11047 +
15.11048 +LTLIBOBJS=$ac_ltlibobjs
15.11049 +
15.11050 +
15.11051 + if test -n "$EXEEXT"; then
15.11052 +  am__EXEEXT_TRUE=
15.11053 +  am__EXEEXT_FALSE='#'
15.11054 +else
15.11055 +  am__EXEEXT_TRUE='#'
15.11056 +  am__EXEEXT_FALSE=
15.11057 +fi
15.11058 +
15.11059 +if test -z "${AMDEP_TRUE}" && test -z "${AMDEP_FALSE}"; then
15.11060 +  as_fn_error "conditional \"AMDEP\" was never defined.
15.11061 +Usually this means the macro was only invoked conditionally." "$LINENO" 5
15.11062 +fi
15.11063 +if test -z "${am__fastdepCC_TRUE}" && test -z "${am__fastdepCC_FALSE}"; then
15.11064 +  as_fn_error "conditional \"am__fastdepCC\" was never defined.
15.11065 +Usually this means the macro was only invoked conditionally." "$LINENO" 5
15.11066 +fi
15.11067 +
15.11068 +: ${CONFIG_STATUS=./config.status}
15.11069 +ac_write_fail=0
15.11070 +ac_clean_files_save=$ac_clean_files
15.11071 +ac_clean_files="$ac_clean_files $CONFIG_STATUS"
15.11072 +{ $as_echo "$as_me:${as_lineno-$LINENO}: creating $CONFIG_STATUS" >&5
15.11073 +$as_echo "$as_me: creating $CONFIG_STATUS" >&6;}
15.11074 +as_write_fail=0
15.11075 +cat >$CONFIG_STATUS <<_ASEOF || as_write_fail=1
15.11076 +#! $SHELL
15.11077 +# Generated by $as_me.
15.11078 +# Run this file to recreate the current configuration.
15.11079 +# Compiler output produced by configure, useful for debugging
15.11080 +# configure, is in config.log if it exists.
15.11081 +
15.11082 +debug=false
15.11083 +ac_cs_recheck=false
15.11084 +ac_cs_silent=false
15.11085 +
15.11086 +SHELL=\${CONFIG_SHELL-$SHELL}
15.11087 +export SHELL
15.11088 +_ASEOF
15.11089 +cat >>$CONFIG_STATUS <<\_ASEOF || as_write_fail=1
15.11090 +## -------------------- ##
15.11091 +## M4sh Initialization. ##
15.11092 +## -------------------- ##
15.11093 +
15.11094 +# Be more Bourne compatible
15.11095 +DUALCASE=1; export DUALCASE # for MKS sh
15.11096 +if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then :
15.11097 +  emulate sh
15.11098 +  NULLCMD=:
15.11099 +  # Pre-4.2 versions of Zsh do word splitting on ${1+"$@"}, which
15.11100 +  # is contrary to our usage.  Disable this feature.
15.11101 +  alias -g '${1+"$@"}'='"$@"'
15.11102 +  setopt NO_GLOB_SUBST
15.11103 +else
15.11104 +  case `(set -o) 2>/dev/null` in #(
15.11105 +  *posix*) :
15.11106 +    set -o posix ;; #(
15.11107 +  *) :
15.11108 +     ;;
15.11109 +esac
15.11110 +fi
15.11111 +
15.11112 +
15.11113 +as_nl='
15.11114 +'
15.11115 +export as_nl
15.11116 +# Printing a long string crashes Solaris 7 /usr/bin/printf.
15.11117 +as_echo='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\'
15.11118 +as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo
15.11119 +as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo$as_echo
15.11120 +# Prefer a ksh shell builtin over an external printf program on Solaris,
15.11121 +# but without wasting forks for bash or zsh.
15.11122 +if test -z "$BASH_VERSION$ZSH_VERSION" \
15.11123 +    && (test "X`print -r -- $as_echo`" = "X$as_echo") 2>/dev/null; then
15.11124 +  as_echo='print -r --'
15.11125 +  as_echo_n='print -rn --'
15.11126 +elif (test "X`printf %s $as_echo`" = "X$as_echo") 2>/dev/null; then
15.11127 +  as_echo='printf %s\n'
15.11128 +  as_echo_n='printf %s'
15.11129 +else
15.11130 +  if test "X`(/usr/ucb/echo -n -n $as_echo) 2>/dev/null`" = "X-n $as_echo"; then
15.11131 +    as_echo_body='eval /usr/ucb/echo -n "$1$as_nl"'
15.11132 +    as_echo_n='/usr/ucb/echo -n'
15.11133 +  else
15.11134 +    as_echo_body='eval expr "X$1" : "X\\(.*\\)"'
15.11135 +    as_echo_n_body='eval
15.11136 +      arg=$1;
15.11137 +      case $arg in #(
15.11138 +      *"$as_nl"*)
15.11139 +	expr "X$arg" : "X\\(.*\\)$as_nl";
15.11140 +	arg=`expr "X$arg" : ".*$as_nl\\(.*\\)"`;;
15.11141 +      esac;
15.11142 +      expr "X$arg" : "X\\(.*\\)" | tr -d "$as_nl"
15.11143 +    '
15.11144 +    export as_echo_n_body
15.11145 +    as_echo_n='sh -c $as_echo_n_body as_echo'
15.11146 +  fi
15.11147 +  export as_echo_body
15.11148 +  as_echo='sh -c $as_echo_body as_echo'
15.11149 +fi
15.11150 +
15.11151 +# The user is always right.
15.11152 +if test "${PATH_SEPARATOR+set}" != set; then
15.11153 +  PATH_SEPARATOR=:
15.11154 +  (PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 && {
15.11155 +    (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 ||
15.11156 +      PATH_SEPARATOR=';'
15.11157 +  }
15.11158 +fi
15.11159 +
15.11160 +
15.11161 +# IFS
15.11162 +# We need space, tab and new line, in precisely that order.  Quoting is
15.11163 +# there to prevent editors from complaining about space-tab.
15.11164 +# (If _AS_PATH_WALK were called with IFS unset, it would disable word
15.11165 +# splitting by setting IFS to empty value.)
15.11166 +IFS=" ""	$as_nl"
15.11167 +
15.11168 +# Find who we are.  Look in the path if we contain no directory separator.
15.11169 +case $0 in #((
15.11170 +  *[\\/]* ) as_myself=$0 ;;
15.11171 +  *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
15.11172 +for as_dir in $PATH
15.11173 +do
15.11174 +  IFS=$as_save_IFS
15.11175 +  test -z "$as_dir" && as_dir=.
15.11176 +    test -r "$as_dir/$0" && as_myself=$as_dir/$0 && break
15.11177 +  done
15.11178 +IFS=$as_save_IFS
15.11179 +
15.11180 +     ;;
15.11181 +esac
15.11182 +# We did not find ourselves, most probably we were run as `sh COMMAND'
15.11183 +# in which case we are not to be found in the path.
15.11184 +if test "x$as_myself" = x; then
15.11185 +  as_myself=$0
15.11186 +fi
15.11187 +if test ! -f "$as_myself"; then
15.11188 +  $as_echo "$as_myself: error: cannot find myself; rerun with an absolute file name" >&2
15.11189 +  exit 1
15.11190 +fi
15.11191 +
15.11192 +# Unset variables that we do not need and which cause bugs (e.g. in
15.11193 +# pre-3.0 UWIN ksh).  But do not cause bugs in bash 2.01; the "|| exit 1"
15.11194 +# suppresses any "Segmentation fault" message there.  '((' could
15.11195 +# trigger a bug in pdksh 5.2.14.
15.11196 +for as_var in BASH_ENV ENV MAIL MAILPATH
15.11197 +do eval test x\${$as_var+set} = xset \
15.11198 +  && ( (unset $as_var) || exit 1) >/dev/null 2>&1 && unset $as_var || :
15.11199 +done
15.11200 +PS1='$ '
15.11201 +PS2='> '
15.11202 +PS4='+ '
15.11203 +
15.11204 +# NLS nuisances.
15.11205 +LC_ALL=C
15.11206 +export LC_ALL
15.11207 +LANGUAGE=C
15.11208 +export LANGUAGE
15.11209 +
15.11210 +# CDPATH.
15.11211 +(unset CDPATH) >/dev/null 2>&1 && unset CDPATH
15.11212 +
15.11213 +
15.11214 +# as_fn_error ERROR [LINENO LOG_FD]
15.11215 +# ---------------------------------
15.11216 +# Output "`basename $0`: error: ERROR" to stderr. If LINENO and LOG_FD are
15.11217 +# provided, also output the error to LOG_FD, referencing LINENO. Then exit the
15.11218 +# script with status $?, using 1 if that was 0.
15.11219 +as_fn_error ()
15.11220 +{
15.11221 +  as_status=$?; test $as_status -eq 0 && as_status=1
15.11222 +  if test "$3"; then
15.11223 +    as_lineno=${as_lineno-"$2"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
15.11224 +    $as_echo "$as_me:${as_lineno-$LINENO}: error: $1" >&$3
15.11225 +  fi
15.11226 +  $as_echo "$as_me: error: $1" >&2
15.11227 +  as_fn_exit $as_status
15.11228 +} # as_fn_error
15.11229 +
15.11230 +
15.11231 +# as_fn_set_status STATUS
15.11232 +# -----------------------
15.11233 +# Set $? to STATUS, without forking.
15.11234 +as_fn_set_status ()
15.11235 +{
15.11236 +  return $1
15.11237 +} # as_fn_set_status
15.11238 +
15.11239 +# as_fn_exit STATUS
15.11240 +# -----------------
15.11241 +# Exit the shell with STATUS, even in a "trap 0" or "set -e" context.
15.11242 +as_fn_exit ()
15.11243 +{
15.11244 +  set +e
15.11245 +  as_fn_set_status $1
15.11246 +  exit $1
15.11247 +} # as_fn_exit
15.11248 +
15.11249 +# as_fn_unset VAR
15.11250 +# ---------------
15.11251 +# Portably unset VAR.
15.11252 +as_fn_unset ()
15.11253 +{
15.11254 +  { eval $1=; unset $1;}
15.11255 +}
15.11256 +as_unset=as_fn_unset
15.11257 +# as_fn_append VAR VALUE
15.11258 +# ----------------------
15.11259 +# Append the text in VALUE to the end of the definition contained in VAR. Take
15.11260 +# advantage of any shell optimizations that allow amortized linear growth over
15.11261 +# repeated appends, instead of the typical quadratic growth present in naive
15.11262 +# implementations.
15.11263 +if (eval "as_var=1; as_var+=2; test x\$as_var = x12") 2>/dev/null; then :
15.11264 +  eval 'as_fn_append ()
15.11265 +  {
15.11266 +    eval $1+=\$2
15.11267 +  }'
15.11268 +else
15.11269 +  as_fn_append ()
15.11270 +  {
15.11271 +    eval $1=\$$1\$2
15.11272 +  }
15.11273 +fi # as_fn_append
15.11274 +
15.11275 +# as_fn_arith ARG...
15.11276 +# ------------------
15.11277 +# Perform arithmetic evaluation on the ARGs, and store the result in the
15.11278 +# global $as_val. Take advantage of shells that can avoid forks. The arguments
15.11279 +# must be portable across $(()) and expr.
15.11280 +if (eval "test \$(( 1 + 1 )) = 2") 2>/dev/null; then :
15.11281 +  eval 'as_fn_arith ()
15.11282 +  {
15.11283 +    as_val=$(( $* ))
15.11284 +  }'
15.11285 +else
15.11286 +  as_fn_arith ()
15.11287 +  {
15.11288 +    as_val=`expr "$@" || test $? -eq 1`
15.11289 +  }
15.11290 +fi # as_fn_arith
15.11291 +
15.11292 +
15.11293 +if expr a : '\(a\)' >/dev/null 2>&1 &&
15.11294 +   test "X`expr 00001 : '.*\(...\)'`" = X001; then
15.11295 +  as_expr=expr
15.11296 +else
15.11297 +  as_expr=false
15.11298 +fi
15.11299 +
15.11300 +if (basename -- /) >/dev/null 2>&1 && test "X`basename -- / 2>&1`" = "X/"; then
15.11301 +  as_basename=basename
15.11302 +else
15.11303 +  as_basename=false
15.11304 +fi
15.11305 +
15.11306 +if (as_dir=`dirname -- /` && test "X$as_dir" = X/) >/dev/null 2>&1; then
15.11307 +  as_dirname=dirname
15.11308 +else
15.11309 +  as_dirname=false
15.11310 +fi
15.11311 +
15.11312 +as_me=`$as_basename -- "$0" ||
15.11313 +$as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \
15.11314 +	 X"$0" : 'X\(//\)$' \| \
15.11315 +	 X"$0" : 'X\(/\)' \| . 2>/dev/null ||
15.11316 +$as_echo X/"$0" |
15.11317 +    sed '/^.*\/\([^/][^/]*\)\/*$/{
15.11318 +	    s//\1/
15.11319 +	    q
15.11320 +	  }
15.11321 +	  /^X\/\(\/\/\)$/{
15.11322 +	    s//\1/
15.11323 +	    q
15.11324 +	  }
15.11325 +	  /^X\/\(\/\).*/{
15.11326 +	    s//\1/
15.11327 +	    q
15.11328 +	  }
15.11329 +	  s/.*/./; q'`
15.11330 +
15.11331 +# Avoid depending upon Character Ranges.
15.11332 +as_cr_letters='abcdefghijklmnopqrstuvwxyz'
15.11333 +as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ'
15.11334 +as_cr_Letters=$as_cr_letters$as_cr_LETTERS
15.11335 +as_cr_digits='0123456789'
15.11336 +as_cr_alnum=$as_cr_Letters$as_cr_digits
15.11337 +
15.11338 +ECHO_C= ECHO_N= ECHO_T=
15.11339 +case `echo -n x` in #(((((
15.11340 +-n*)
15.11341 +  case `echo 'xy\c'` in
15.11342 +  *c*) ECHO_T='	';;	# ECHO_T is single tab character.
15.11343 +  xy)  ECHO_C='\c';;
15.11344 +  *)   echo `echo ksh88 bug on AIX 6.1` > /dev/null
15.11345 +       ECHO_T='	';;
15.11346 +  esac;;
15.11347 +*)
15.11348 +  ECHO_N='-n';;
15.11349 +esac
15.11350 +
15.11351 +rm -f conf$$ conf$$.exe conf$$.file
15.11352 +if test -d conf$$.dir; then
15.11353 +  rm -f conf$$.dir/conf$$.file
15.11354 +else
15.11355 +  rm -f conf$$.dir
15.11356 +  mkdir conf$$.dir 2>/dev/null
15.11357 +fi
15.11358 +if (echo >conf$$.file) 2>/dev/null; then
15.11359 +  if ln -s conf$$.file conf$$ 2>/dev/null; then
15.11360 +    as_ln_s='ln -s'
15.11361 +    # ... but there are two gotchas:
15.11362 +    # 1) On MSYS, both `ln -s file dir' and `ln file dir' fail.
15.11363 +    # 2) DJGPP < 2.04 has no symlinks; `ln -s' creates a wrapper executable.
15.11364 +    # In both cases, we have to default to `cp -p'.
15.11365 +    ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe ||
15.11366 +      as_ln_s='cp -p'
15.11367 +  elif ln conf$$.file conf$$ 2>/dev/null; then
15.11368 +    as_ln_s=ln
15.11369 +  else
15.11370 +    as_ln_s='cp -p'
15.11371 +  fi
15.11372 +else
15.11373 +  as_ln_s='cp -p'
15.11374 +fi
15.11375 +rm -f conf$$ conf$$.exe conf$$.dir/conf$$.file conf$$.file
15.11376 +rmdir conf$$.dir 2>/dev/null
15.11377 +
15.11378 +
15.11379 +# as_fn_mkdir_p
15.11380 +# -------------
15.11381 +# Create "$as_dir" as a directory, including parents if necessary.
15.11382 +as_fn_mkdir_p ()
15.11383 +{
15.11384 +
15.11385 +  case $as_dir in #(
15.11386 +  -*) as_dir=./$as_dir;;
15.11387 +  esac
15.11388 +  test -d "$as_dir" || eval $as_mkdir_p || {
15.11389 +    as_dirs=
15.11390 +    while :; do
15.11391 +      case $as_dir in #(
15.11392 +      *\'*) as_qdir=`$as_echo "$as_dir" | sed "s/'/'\\\\\\\\''/g"`;; #'(
15.11393 +      *) as_qdir=$as_dir;;
15.11394 +      esac
15.11395 +      as_dirs="'$as_qdir' $as_dirs"
15.11396 +      as_dir=`$as_dirname -- "$as_dir" ||
15.11397 +$as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
15.11398 +	 X"$as_dir" : 'X\(//\)[^/]' \| \
15.11399 +	 X"$as_dir" : 'X\(//\)$' \| \
15.11400 +	 X"$as_dir" : 'X\(/\)' \| . 2>/dev/null ||
15.11401 +$as_echo X"$as_dir" |
15.11402 +    sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{
15.11403 +	    s//\1/
15.11404 +	    q
15.11405 +	  }
15.11406 +	  /^X\(\/\/\)[^/].*/{
15.11407 +	    s//\1/
15.11408 +	    q
15.11409 +	  }
15.11410 +	  /^X\(\/\/\)$/{
15.11411 +	    s//\1/
15.11412 +	    q
15.11413 +	  }
15.11414 +	  /^X\(\/\).*/{
15.11415 +	    s//\1/
15.11416 +	    q
15.11417 +	  }
15.11418 +	  s/.*/./; q'`
15.11419 +      test -d "$as_dir" && break
15.11420 +    done
15.11421 +    test -z "$as_dirs" || eval "mkdir $as_dirs"
15.11422 +  } || test -d "$as_dir" || as_fn_error "cannot create directory $as_dir"
15.11423 +
15.11424 +
15.11425 +} # as_fn_mkdir_p
15.11426 +if mkdir -p . 2>/dev/null; then
15.11427 +  as_mkdir_p='mkdir -p "$as_dir"'
15.11428 +else
15.11429 +  test -d ./-p && rmdir ./-p
15.11430 +  as_mkdir_p=false
15.11431 +fi
15.11432 +
15.11433 +if test -x / >/dev/null 2>&1; then
15.11434 +  as_test_x='test -x'
15.11435 +else
15.11436 +  if ls -dL / >/dev/null 2>&1; then
15.11437 +    as_ls_L_option=L
15.11438 +  else
15.11439 +    as_ls_L_option=
15.11440 +  fi
15.11441 +  as_test_x='
15.11442 +    eval sh -c '\''
15.11443 +      if test -d "$1"; then
15.11444 +	test -d "$1/.";
15.11445 +      else
15.11446 +	case $1 in #(
15.11447 +	-*)set "./$1";;
15.11448 +	esac;
15.11449 +	case `ls -ld'$as_ls_L_option' "$1" 2>/dev/null` in #((
15.11450 +	???[sx]*):;;*)false;;esac;fi
15.11451 +    '\'' sh
15.11452 +  '
15.11453 +fi
15.11454 +as_executable_p=$as_test_x
15.11455 +
15.11456 +# Sed expression to map a string onto a valid CPP name.
15.11457 +as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'"
15.11458 +
15.11459 +# Sed expression to map a string onto a valid variable name.
15.11460 +as_tr_sh="eval sed 'y%*+%pp%;s%[^_$as_cr_alnum]%_%g'"
15.11461 +
15.11462 +
15.11463 +exec 6>&1
15.11464 +## ----------------------------------- ##
15.11465 +## Main body of $CONFIG_STATUS script. ##
15.11466 +## ----------------------------------- ##
15.11467 +_ASEOF
15.11468 +test $as_write_fail = 0 && chmod +x $CONFIG_STATUS || ac_write_fail=1
15.11469 +
15.11470 +cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
15.11471 +# Save the log message, to keep $0 and so on meaningful, and to
15.11472 +# report actual input values of CONFIG_FILES etc. instead of their
15.11473 +# values after options handling.
15.11474 +ac_log="
15.11475 +This file was extended by GLPK $as_me 4.47, which was
15.11476 +generated by GNU Autoconf 2.65.  Invocation command line was
15.11477 +
15.11478 +  CONFIG_FILES    = $CONFIG_FILES
15.11479 +  CONFIG_HEADERS  = $CONFIG_HEADERS
15.11480 +  CONFIG_LINKS    = $CONFIG_LINKS
15.11481 +  CONFIG_COMMANDS = $CONFIG_COMMANDS
15.11482 +  $ $0 $@
15.11483 +
15.11484 +on `(hostname || uname -n) 2>/dev/null | sed 1q`
15.11485 +"
15.11486 +
15.11487 +_ACEOF
15.11488 +
15.11489 +case $ac_config_files in *"
15.11490 +"*) set x $ac_config_files; shift; ac_config_files=$*;;
15.11491 +esac
15.11492 +
15.11493 +case $ac_config_headers in *"
15.11494 +"*) set x $ac_config_headers; shift; ac_config_headers=$*;;
15.11495 +esac
15.11496 +
15.11497 +
15.11498 +cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
15.11499 +# Files that config.status was made for.
15.11500 +config_files="$ac_config_files"
15.11501 +config_headers="$ac_config_headers"
15.11502 +config_commands="$ac_config_commands"
15.11503 +
15.11504 +_ACEOF
15.11505 +
15.11506 +cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
15.11507 +ac_cs_usage="\
15.11508 +\`$as_me' instantiates files and other configuration actions
15.11509 +from templates according to the current configuration.  Unless the files
15.11510 +and actions are specified as TAGs, all are instantiated by default.
15.11511 +
15.11512 +Usage: $0 [OPTION]... [TAG]...
15.11513 +
15.11514 +  -h, --help       print this help, then exit
15.11515 +  -V, --version    print version number and configuration settings, then exit
15.11516 +      --config     print configuration, then exit
15.11517 +  -q, --quiet, --silent
15.11518 +                   do not print progress messages
15.11519 +  -d, --debug      don't remove temporary files
15.11520 +      --recheck    update $as_me by reconfiguring in the same conditions
15.11521 +      --file=FILE[:TEMPLATE]
15.11522 +                   instantiate the configuration file FILE
15.11523 +      --header=FILE[:TEMPLATE]
15.11524 +                   instantiate the configuration header FILE
15.11525 +
15.11526 +Configuration files:
15.11527 +$config_files
15.11528 +
15.11529 +Configuration headers:
15.11530 +$config_headers
15.11531 +
15.11532 +Configuration commands:
15.11533 +$config_commands
15.11534 +
15.11535 +Report bugs to <bug-glpk@gnu.org>."
15.11536 +
15.11537 +_ACEOF
15.11538 +cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
15.11539 +ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`"
15.11540 +ac_cs_version="\\
15.11541 +GLPK config.status 4.47
15.11542 +configured by $0, generated by GNU Autoconf 2.65,
15.11543 +  with options \\"\$ac_cs_config\\"
15.11544 +
15.11545 +Copyright (C) 2009 Free Software Foundation, Inc.
15.11546 +This config.status script is free software; the Free Software Foundation
15.11547 +gives unlimited permission to copy, distribute and modify it."
15.11548 +
15.11549 +ac_pwd='$ac_pwd'
15.11550 +srcdir='$srcdir'
15.11551 +INSTALL='$INSTALL'
15.11552 +MKDIR_P='$MKDIR_P'
15.11553 +AWK='$AWK'
15.11554 +test -n "\$AWK" || AWK=awk
15.11555 +_ACEOF
15.11556 +
15.11557 +cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
15.11558 +# The default lists apply if the user does not specify any file.
15.11559 +ac_need_defaults=:
15.11560 +while test $# != 0
15.11561 +do
15.11562 +  case $1 in
15.11563 +  --*=*)
15.11564 +    ac_option=`expr "X$1" : 'X\([^=]*\)='`
15.11565 +    ac_optarg=`expr "X$1" : 'X[^=]*=\(.*\)'`
15.11566 +    ac_shift=:
15.11567 +    ;;
15.11568 +  *)
15.11569 +    ac_option=$1
15.11570 +    ac_optarg=$2
15.11571 +    ac_shift=shift
15.11572 +    ;;
15.11573 +  esac
15.11574 +
15.11575 +  case $ac_option in
15.11576 +  # Handling of the options.
15.11577 +  -recheck | --recheck | --rechec | --reche | --rech | --rec | --re | --r)
15.11578 +    ac_cs_recheck=: ;;
15.11579 +  --version | --versio | --versi | --vers | --ver | --ve | --v | -V )
15.11580 +    $as_echo "$ac_cs_version"; exit ;;
15.11581 +  --config | --confi | --conf | --con | --co | --c )
15.11582 +    $as_echo "$ac_cs_config"; exit ;;
15.11583 +  --debug | --debu | --deb | --de | --d | -d )
15.11584 +    debug=: ;;
15.11585 +  --file | --fil | --fi | --f )
15.11586 +    $ac_shift
15.11587 +    case $ac_optarg in
15.11588 +    *\'*) ac_optarg=`$as_echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"` ;;
15.11589 +    esac
15.11590 +    as_fn_append CONFIG_FILES " '$ac_optarg'"
15.11591 +    ac_need_defaults=false;;
15.11592 +  --header | --heade | --head | --hea )
15.11593 +    $ac_shift
15.11594 +    case $ac_optarg in
15.11595 +    *\'*) ac_optarg=`$as_echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"` ;;
15.11596 +    esac
15.11597 +    as_fn_append CONFIG_HEADERS " '$ac_optarg'"
15.11598 +    ac_need_defaults=false;;
15.11599 +  --he | --h)
15.11600 +    # Conflict between --help and --header
15.11601 +    as_fn_error "ambiguous option: \`$1'
15.11602 +Try \`$0 --help' for more information.";;
15.11603 +  --help | --hel | -h )
15.11604 +    $as_echo "$ac_cs_usage"; exit ;;
15.11605 +  -q | -quiet | --quiet | --quie | --qui | --qu | --q \
15.11606 +  | -silent | --silent | --silen | --sile | --sil | --si | --s)
15.11607 +    ac_cs_silent=: ;;
15.11608 +
15.11609 +  # This is an error.
15.11610 +  -*) as_fn_error "unrecognized option: \`$1'
15.11611 +Try \`$0 --help' for more information." ;;
15.11612 +
15.11613 +  *) as_fn_append ac_config_targets " $1"
15.11614 +     ac_need_defaults=false ;;
15.11615 +
15.11616 +  esac
15.11617 +  shift
15.11618 +done
15.11619 +
15.11620 +ac_configure_extra_args=
15.11621 +
15.11622 +if $ac_cs_silent; then
15.11623 +  exec 6>/dev/null
15.11624 +  ac_configure_extra_args="$ac_configure_extra_args --silent"
15.11625 +fi
15.11626 +
15.11627 +_ACEOF
15.11628 +cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
15.11629 +if \$ac_cs_recheck; then
15.11630 +  set X '$SHELL' '$0' $ac_configure_args \$ac_configure_extra_args --no-create --no-recursion
15.11631 +  shift
15.11632 +  \$as_echo "running CONFIG_SHELL=$SHELL \$*" >&6
15.11633 +  CONFIG_SHELL='$SHELL'
15.11634 +  export CONFIG_SHELL
15.11635 +  exec "\$@"
15.11636 +fi
15.11637 +
15.11638 +_ACEOF
15.11639 +cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
15.11640 +exec 5>>config.log
15.11641 +{
15.11642 +  echo
15.11643 +  sed 'h;s/./-/g;s/^.../## /;s/...$/ ##/;p;x;p;x' <<_ASBOX
15.11644 +## Running $as_me. ##
15.11645 +_ASBOX
15.11646 +  $as_echo "$ac_log"
15.11647 +} >&5
15.11648 +
15.11649 +_ACEOF
15.11650 +cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
15.11651 +#
15.11652 +# INIT-COMMANDS
15.11653 +#
15.11654 +AMDEP_TRUE="$AMDEP_TRUE" ac_aux_dir="$ac_aux_dir"
15.11655 +
15.11656 +
15.11657 +# The HP-UX ksh and POSIX shell print the target directory to stdout
15.11658 +# if CDPATH is set.
15.11659 +(unset CDPATH) >/dev/null 2>&1 && unset CDPATH
15.11660 +
15.11661 +sed_quote_subst='$sed_quote_subst'
15.11662 +double_quote_subst='$double_quote_subst'
15.11663 +delay_variable_subst='$delay_variable_subst'
15.11664 +macro_version='`$ECHO "$macro_version" | $SED "$delay_single_quote_subst"`'
15.11665 +macro_revision='`$ECHO "$macro_revision" | $SED "$delay_single_quote_subst"`'
15.11666 +enable_shared='`$ECHO "$enable_shared" | $SED "$delay_single_quote_subst"`'
15.11667 +enable_static='`$ECHO "$enable_static" | $SED "$delay_single_quote_subst"`'
15.11668 +pic_mode='`$ECHO "$pic_mode" | $SED "$delay_single_quote_subst"`'
15.11669 +enable_fast_install='`$ECHO "$enable_fast_install" | $SED "$delay_single_quote_subst"`'
15.11670 +SHELL='`$ECHO "$SHELL" | $SED "$delay_single_quote_subst"`'
15.11671 +ECHO='`$ECHO "$ECHO" | $SED "$delay_single_quote_subst"`'
15.11672 +host_alias='`$ECHO "$host_alias" | $SED "$delay_single_quote_subst"`'
15.11673 +host='`$ECHO "$host" | $SED "$delay_single_quote_subst"`'
15.11674 +host_os='`$ECHO "$host_os" | $SED "$delay_single_quote_subst"`'
15.11675 +build_alias='`$ECHO "$build_alias" | $SED "$delay_single_quote_subst"`'
15.11676 +build='`$ECHO "$build" | $SED "$delay_single_quote_subst"`'
15.11677 +build_os='`$ECHO "$build_os" | $SED "$delay_single_quote_subst"`'
15.11678 +SED='`$ECHO "$SED" | $SED "$delay_single_quote_subst"`'
15.11679 +Xsed='`$ECHO "$Xsed" | $SED "$delay_single_quote_subst"`'
15.11680 +GREP='`$ECHO "$GREP" | $SED "$delay_single_quote_subst"`'
15.11681 +EGREP='`$ECHO "$EGREP" | $SED "$delay_single_quote_subst"`'
15.11682 +FGREP='`$ECHO "$FGREP" | $SED "$delay_single_quote_subst"`'
15.11683 +LD='`$ECHO "$LD" | $SED "$delay_single_quote_subst"`'
15.11684 +NM='`$ECHO "$NM" | $SED "$delay_single_quote_subst"`'
15.11685 +LN_S='`$ECHO "$LN_S" | $SED "$delay_single_quote_subst"`'
15.11686 +max_cmd_len='`$ECHO "$max_cmd_len" | $SED "$delay_single_quote_subst"`'
15.11687 +ac_objext='`$ECHO "$ac_objext" | $SED "$delay_single_quote_subst"`'
15.11688 +exeext='`$ECHO "$exeext" | $SED "$delay_single_quote_subst"`'
15.11689 +lt_unset='`$ECHO "$lt_unset" | $SED "$delay_single_quote_subst"`'
15.11690 +lt_SP2NL='`$ECHO "$lt_SP2NL" | $SED "$delay_single_quote_subst"`'
15.11691 +lt_NL2SP='`$ECHO "$lt_NL2SP" | $SED "$delay_single_quote_subst"`'
15.11692 +lt_cv_to_host_path_cmd='`$ECHO "$lt_cv_to_host_path_cmd" | $SED "$delay_single_quote_subst"`'
15.11693 +reload_flag='`$ECHO "$reload_flag" | $SED "$delay_single_quote_subst"`'
15.11694 +reload_cmds='`$ECHO "$reload_cmds" | $SED "$delay_single_quote_subst"`'
15.11695 +OBJDUMP='`$ECHO "$OBJDUMP" | $SED "$delay_single_quote_subst"`'
15.11696 +deplibs_check_method='`$ECHO "$deplibs_check_method" | $SED "$delay_single_quote_subst"`'
15.11697 +file_magic_cmd='`$ECHO "$file_magic_cmd" | $SED "$delay_single_quote_subst"`'
15.11698 +DLLTOOL='`$ECHO "$DLLTOOL" | $SED "$delay_single_quote_subst"`'
15.11699 +sharedlib_from_linklib_cmd='`$ECHO "$sharedlib_from_linklib_cmd" | $SED "$delay_single_quote_subst"`'
15.11700 +AR='`$ECHO "$AR" | $SED "$delay_single_quote_subst"`'
15.11701 +AR_FLAGS='`$ECHO "$AR_FLAGS" | $SED "$delay_single_quote_subst"`'
15.11702 +STRIP='`$ECHO "$STRIP" | $SED "$delay_single_quote_subst"`'
15.11703 +RANLIB='`$ECHO "$RANLIB" | $SED "$delay_single_quote_subst"`'
15.11704 +old_postinstall_cmds='`$ECHO "$old_postinstall_cmds" | $SED "$delay_single_quote_subst"`'
15.11705 +old_postuninstall_cmds='`$ECHO "$old_postuninstall_cmds" | $SED "$delay_single_quote_subst"`'
15.11706 +old_archive_cmds='`$ECHO "$old_archive_cmds" | $SED "$delay_single_quote_subst"`'
15.11707 +lock_old_archive_extraction='`$ECHO "$lock_old_archive_extraction" | $SED "$delay_single_quote_subst"`'
15.11708 +CC='`$ECHO "$CC" | $SED "$delay_single_quote_subst"`'
15.11709 +CFLAGS='`$ECHO "$CFLAGS" | $SED "$delay_single_quote_subst"`'
15.11710 +compiler='`$ECHO "$compiler" | $SED "$delay_single_quote_subst"`'
15.11711 +GCC='`$ECHO "$GCC" | $SED "$delay_single_quote_subst"`'
15.11712 +lt_cv_sys_global_symbol_pipe='`$ECHO "$lt_cv_sys_global_symbol_pipe" | $SED "$delay_single_quote_subst"`'
15.11713 +lt_cv_sys_global_symbol_to_cdecl='`$ECHO "$lt_cv_sys_global_symbol_to_cdecl" | $SED "$delay_single_quote_subst"`'
15.11714 +lt_cv_sys_global_symbol_to_c_name_address='`$ECHO "$lt_cv_sys_global_symbol_to_c_name_address" | $SED "$delay_single_quote_subst"`'
15.11715 +lt_cv_sys_global_symbol_to_c_name_address_lib_prefix='`$ECHO "$lt_cv_sys_global_symbol_to_c_name_address_lib_prefix" | $SED "$delay_single_quote_subst"`'
15.11716 +objdir='`$ECHO "$objdir" | $SED "$delay_single_quote_subst"`'
15.11717 +MAGIC_CMD='`$ECHO "$MAGIC_CMD" | $SED "$delay_single_quote_subst"`'
15.11718 +lt_prog_compiler_no_builtin_flag='`$ECHO "$lt_prog_compiler_no_builtin_flag" | $SED "$delay_single_quote_subst"`'
15.11719 +lt_prog_compiler_wl='`$ECHO "$lt_prog_compiler_wl" | $SED "$delay_single_quote_subst"`'
15.11720 +lt_prog_compiler_pic='`$ECHO "$lt_prog_compiler_pic" | $SED "$delay_single_quote_subst"`'
15.11721 +lt_prog_compiler_static='`$ECHO "$lt_prog_compiler_static" | $SED "$delay_single_quote_subst"`'
15.11722 +lt_cv_prog_compiler_c_o='`$ECHO "$lt_cv_prog_compiler_c_o" | $SED "$delay_single_quote_subst"`'
15.11723 +need_locks='`$ECHO "$need_locks" | $SED "$delay_single_quote_subst"`'
15.11724 +DSYMUTIL='`$ECHO "$DSYMUTIL" | $SED "$delay_single_quote_subst"`'
15.11725 +NMEDIT='`$ECHO "$NMEDIT" | $SED "$delay_single_quote_subst"`'
15.11726 +LIPO='`$ECHO "$LIPO" | $SED "$delay_single_quote_subst"`'
15.11727 +OTOOL='`$ECHO "$OTOOL" | $SED "$delay_single_quote_subst"`'
15.11728 +OTOOL64='`$ECHO "$OTOOL64" | $SED "$delay_single_quote_subst"`'
15.11729 +libext='`$ECHO "$libext" | $SED "$delay_single_quote_subst"`'
15.11730 +shrext_cmds='`$ECHO "$shrext_cmds" | $SED "$delay_single_quote_subst"`'
15.11731 +extract_expsyms_cmds='`$ECHO "$extract_expsyms_cmds" | $SED "$delay_single_quote_subst"`'
15.11732 +archive_cmds_need_lc='`$ECHO "$archive_cmds_need_lc" | $SED "$delay_single_quote_subst"`'
15.11733 +enable_shared_with_static_runtimes='`$ECHO "$enable_shared_with_static_runtimes" | $SED "$delay_single_quote_subst"`'
15.11734 +export_dynamic_flag_spec='`$ECHO "$export_dynamic_flag_spec" | $SED "$delay_single_quote_subst"`'
15.11735 +whole_archive_flag_spec='`$ECHO "$whole_archive_flag_spec" | $SED "$delay_single_quote_subst"`'
15.11736 +compiler_needs_object='`$ECHO "$compiler_needs_object" | $SED "$delay_single_quote_subst"`'
15.11737 +old_archive_from_new_cmds='`$ECHO "$old_archive_from_new_cmds" | $SED "$delay_single_quote_subst"`'
15.11738 +old_archive_from_expsyms_cmds='`$ECHO "$old_archive_from_expsyms_cmds" | $SED "$delay_single_quote_subst"`'
15.11739 +archive_cmds='`$ECHO "$archive_cmds" | $SED "$delay_single_quote_subst"`'
15.11740 +archive_expsym_cmds='`$ECHO "$archive_expsym_cmds" | $SED "$delay_single_quote_subst"`'
15.11741 +module_cmds='`$ECHO "$module_cmds" | $SED "$delay_single_quote_subst"`'
15.11742 +module_expsym_cmds='`$ECHO "$module_expsym_cmds" | $SED "$delay_single_quote_subst"`'
15.11743 +with_gnu_ld='`$ECHO "$with_gnu_ld" | $SED "$delay_single_quote_subst"`'
15.11744 +allow_undefined_flag='`$ECHO "$allow_undefined_flag" | $SED "$delay_single_quote_subst"`'
15.11745 +no_undefined_flag='`$ECHO "$no_undefined_flag" | $SED "$delay_single_quote_subst"`'
15.11746 +hardcode_libdir_flag_spec='`$ECHO "$hardcode_libdir_flag_spec" | $SED "$delay_single_quote_subst"`'
15.11747 +hardcode_libdir_flag_spec_ld='`$ECHO "$hardcode_libdir_flag_spec_ld" | $SED "$delay_single_quote_subst"`'
15.11748 +hardcode_libdir_separator='`$ECHO "$hardcode_libdir_separator" | $SED "$delay_single_quote_subst"`'
15.11749 +hardcode_direct='`$ECHO "$hardcode_direct" | $SED "$delay_single_quote_subst"`'
15.11750 +hardcode_direct_absolute='`$ECHO "$hardcode_direct_absolute" | $SED "$delay_single_quote_subst"`'
15.11751 +hardcode_minus_L='`$ECHO "$hardcode_minus_L" | $SED "$delay_single_quote_subst"`'
15.11752 +hardcode_shlibpath_var='`$ECHO "$hardcode_shlibpath_var" | $SED "$delay_single_quote_subst"`'
15.11753 +hardcode_automatic='`$ECHO "$hardcode_automatic" | $SED "$delay_single_quote_subst"`'
15.11754 +inherit_rpath='`$ECHO "$inherit_rpath" | $SED "$delay_single_quote_subst"`'
15.11755 +link_all_deplibs='`$ECHO "$link_all_deplibs" | $SED "$delay_single_quote_subst"`'
15.11756 +fix_srcfile_path='`$ECHO "$fix_srcfile_path" | $SED "$delay_single_quote_subst"`'
15.11757 +always_export_symbols='`$ECHO "$always_export_symbols" | $SED "$delay_single_quote_subst"`'
15.11758 +export_symbols_cmds='`$ECHO "$export_symbols_cmds" | $SED "$delay_single_quote_subst"`'
15.11759 +exclude_expsyms='`$ECHO "$exclude_expsyms" | $SED "$delay_single_quote_subst"`'
15.11760 +include_expsyms='`$ECHO "$include_expsyms" | $SED "$delay_single_quote_subst"`'
15.11761 +prelink_cmds='`$ECHO "$prelink_cmds" | $SED "$delay_single_quote_subst"`'
15.11762 +file_list_spec='`$ECHO "$file_list_spec" | $SED "$delay_single_quote_subst"`'
15.11763 +variables_saved_for_relink='`$ECHO "$variables_saved_for_relink" | $SED "$delay_single_quote_subst"`'
15.11764 +need_lib_prefix='`$ECHO "$need_lib_prefix" | $SED "$delay_single_quote_subst"`'
15.11765 +need_version='`$ECHO "$need_version" | $SED "$delay_single_quote_subst"`'
15.11766 +version_type='`$ECHO "$version_type" | $SED "$delay_single_quote_subst"`'
15.11767 +runpath_var='`$ECHO "$runpath_var" | $SED "$delay_single_quote_subst"`'
15.11768 +shlibpath_var='`$ECHO "$shlibpath_var" | $SED "$delay_single_quote_subst"`'
15.11769 +shlibpath_overrides_runpath='`$ECHO "$shlibpath_overrides_runpath" | $SED "$delay_single_quote_subst"`'
15.11770 +libname_spec='`$ECHO "$libname_spec" | $SED "$delay_single_quote_subst"`'
15.11771 +library_names_spec='`$ECHO "$library_names_spec" | $SED "$delay_single_quote_subst"`'
15.11772 +soname_spec='`$ECHO "$soname_spec" | $SED "$delay_single_quote_subst"`'
15.11773 +install_override_mode='`$ECHO "$install_override_mode" | $SED "$delay_single_quote_subst"`'
15.11774 +postinstall_cmds='`$ECHO "$postinstall_cmds" | $SED "$delay_single_quote_subst"`'
15.11775 +postuninstall_cmds='`$ECHO "$postuninstall_cmds" | $SED "$delay_single_quote_subst"`'
15.11776 +finish_cmds='`$ECHO "$finish_cmds" | $SED "$delay_single_quote_subst"`'
15.11777 +finish_eval='`$ECHO "$finish_eval" | $SED "$delay_single_quote_subst"`'
15.11778 +hardcode_into_libs='`$ECHO "$hardcode_into_libs" | $SED "$delay_single_quote_subst"`'
15.11779 +sys_lib_search_path_spec='`$ECHO "$sys_lib_search_path_spec" | $SED "$delay_single_quote_subst"`'
15.11780 +sys_lib_dlsearch_path_spec='`$ECHO "$sys_lib_dlsearch_path_spec" | $SED "$delay_single_quote_subst"`'
15.11781 +hardcode_action='`$ECHO "$hardcode_action" | $SED "$delay_single_quote_subst"`'
15.11782 +enable_dlopen='`$ECHO "$enable_dlopen" | $SED "$delay_single_quote_subst"`'
15.11783 +enable_dlopen_self='`$ECHO "$enable_dlopen_self" | $SED "$delay_single_quote_subst"`'
15.11784 +enable_dlopen_self_static='`$ECHO "$enable_dlopen_self_static" | $SED "$delay_single_quote_subst"`'
15.11785 +old_striplib='`$ECHO "$old_striplib" | $SED "$delay_single_quote_subst"`'
15.11786 +striplib='`$ECHO "$striplib" | $SED "$delay_single_quote_subst"`'
15.11787 +
15.11788 +LTCC='$LTCC'
15.11789 +LTCFLAGS='$LTCFLAGS'
15.11790 +compiler='$compiler_DEFAULT'
15.11791 +
15.11792 +# A function that is used when there is no print builtin or printf.
15.11793 +func_fallback_echo ()
15.11794 +{
15.11795 +  eval 'cat <<_LTECHO_EOF
15.11796 +\$1
15.11797 +_LTECHO_EOF'
15.11798 +}
15.11799 +
15.11800 +# Quote evaled strings.
15.11801 +for var in SHELL \
15.11802 +ECHO \
15.11803 +SED \
15.11804 +GREP \
15.11805 +EGREP \
15.11806 +FGREP \
15.11807 +LD \
15.11808 +NM \
15.11809 +LN_S \
15.11810 +lt_SP2NL \
15.11811 +lt_NL2SP \
15.11812 +reload_flag \
15.11813 +OBJDUMP \
15.11814 +deplibs_check_method \
15.11815 +file_magic_cmd \
15.11816 +DLLTOOL \
15.11817 +sharedlib_from_linklib_cmd \
15.11818 +AR \
15.11819 +AR_FLAGS \
15.11820 +STRIP \
15.11821 +RANLIB \
15.11822 +CC \
15.11823 +CFLAGS \
15.11824 +compiler \
15.11825 +lt_cv_sys_global_symbol_pipe \
15.11826 +lt_cv_sys_global_symbol_to_cdecl \
15.11827 +lt_cv_sys_global_symbol_to_c_name_address \
15.11828 +lt_cv_sys_global_symbol_to_c_name_address_lib_prefix \
15.11829 +lt_prog_compiler_no_builtin_flag \
15.11830 +lt_prog_compiler_wl \
15.11831 +lt_prog_compiler_pic \
15.11832 +lt_prog_compiler_static \
15.11833 +lt_cv_prog_compiler_c_o \
15.11834 +need_locks \
15.11835 +DSYMUTIL \
15.11836 +NMEDIT \
15.11837 +LIPO \
15.11838 +OTOOL \
15.11839 +OTOOL64 \
15.11840 +shrext_cmds \
15.11841 +export_dynamic_flag_spec \
15.11842 +whole_archive_flag_spec \
15.11843 +compiler_needs_object \
15.11844 +with_gnu_ld \
15.11845 +allow_undefined_flag \
15.11846 +no_undefined_flag \
15.11847 +hardcode_libdir_flag_spec \
15.11848 +hardcode_libdir_flag_spec_ld \
15.11849 +hardcode_libdir_separator \
15.11850 +fix_srcfile_path \
15.11851 +exclude_expsyms \
15.11852 +include_expsyms \
15.11853 +file_list_spec \
15.11854 +variables_saved_for_relink \
15.11855 +libname_spec \
15.11856 +library_names_spec \
15.11857 +soname_spec \
15.11858 +install_override_mode \
15.11859 +finish_eval \
15.11860 +old_striplib \
15.11861 +striplib; do
15.11862 +    case \`eval \\\\\$ECHO \\\\""\\\\\$\$var"\\\\"\` in
15.11863 +    *[\\\\\\\`\\"\\\$]*)
15.11864 +      eval "lt_\$var=\\\\\\"\\\`\\\$ECHO \\"\\\$\$var\\" | \\\$SED \\"\\\$sed_quote_subst\\"\\\`\\\\\\""
15.11865 +      ;;
15.11866 +    *)
15.11867 +      eval "lt_\$var=\\\\\\"\\\$\$var\\\\\\""
15.11868 +      ;;
15.11869 +    esac
15.11870 +done
15.11871 +
15.11872 +# Double-quote double-evaled strings.
15.11873 +for var in reload_cmds \
15.11874 +old_postinstall_cmds \
15.11875 +old_postuninstall_cmds \
15.11876 +old_archive_cmds \
15.11877 +extract_expsyms_cmds \
15.11878 +old_archive_from_new_cmds \
15.11879 +old_archive_from_expsyms_cmds \
15.11880 +archive_cmds \
15.11881 +archive_expsym_cmds \
15.11882 +module_cmds \
15.11883 +module_expsym_cmds \
15.11884 +export_symbols_cmds \
15.11885 +prelink_cmds \
15.11886 +postinstall_cmds \
15.11887 +postuninstall_cmds \
15.11888 +finish_cmds \
15.11889 +sys_lib_search_path_spec \
15.11890 +sys_lib_dlsearch_path_spec; do
15.11891 +    case \`eval \\\\\$ECHO \\\\""\\\\\$\$var"\\\\"\` in
15.11892 +    *[\\\\\\\`\\"\\\$]*)
15.11893 +      eval "lt_\$var=\\\\\\"\\\`\\\$ECHO \\"\\\$\$var\\" | \\\$SED -e \\"\\\$double_quote_subst\\" -e \\"\\\$sed_quote_subst\\" -e \\"\\\$delay_variable_subst\\"\\\`\\\\\\""
15.11894 +      ;;
15.11895 +    *)
15.11896 +      eval "lt_\$var=\\\\\\"\\\$\$var\\\\\\""
15.11897 +      ;;
15.11898 +    esac
15.11899 +done
15.11900 +
15.11901 +ac_aux_dir='$ac_aux_dir'
15.11902 +xsi_shell='$xsi_shell'
15.11903 +lt_shell_append='$lt_shell_append'
15.11904 +
15.11905 +# See if we are running on zsh, and set the options which allow our
15.11906 +# commands through without removal of \ escapes INIT.
15.11907 +if test -n "\${ZSH_VERSION+set}" ; then
15.11908 +   setopt NO_GLOB_SUBST
15.11909 +fi
15.11910 +
15.11911 +
15.11912 +    PACKAGE='$PACKAGE'
15.11913 +    VERSION='$VERSION'
15.11914 +    TIMESTAMP='$TIMESTAMP'
15.11915 +    RM='$RM'
15.11916 +    ofile='$ofile'
15.11917 +
15.11918 +
15.11919 +
15.11920 +
15.11921 +_ACEOF
15.11922 +
15.11923 +cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
15.11924 +
15.11925 +# Handling of arguments.
15.11926 +for ac_config_target in $ac_config_targets
15.11927 +do
15.11928 +  case $ac_config_target in
15.11929 +    "config.h") CONFIG_HEADERS="$CONFIG_HEADERS config.h" ;;
15.11930 +    "depfiles") CONFIG_COMMANDS="$CONFIG_COMMANDS depfiles" ;;
15.11931 +    "libtool") CONFIG_COMMANDS="$CONFIG_COMMANDS libtool" ;;
15.11932 +    "src/Makefile") CONFIG_FILES="$CONFIG_FILES src/Makefile" ;;
15.11933 +    "examples/Makefile") CONFIG_FILES="$CONFIG_FILES examples/Makefile" ;;
15.11934 +    "Makefile") CONFIG_FILES="$CONFIG_FILES Makefile" ;;
15.11935 +
15.11936 +  *) as_fn_error "invalid argument: \`$ac_config_target'" "$LINENO" 5;;
15.11937 +  esac
15.11938 +done
15.11939 +
15.11940 +
15.11941 +# If the user did not use the arguments to specify the items to instantiate,
15.11942 +# then the envvar interface is used.  Set only those that are not.
15.11943 +# We use the long form for the default assignment because of an extremely
15.11944 +# bizarre bug on SunOS 4.1.3.
15.11945 +if $ac_need_defaults; then
15.11946 +  test "${CONFIG_FILES+set}" = set || CONFIG_FILES=$config_files
15.11947 +  test "${CONFIG_HEADERS+set}" = set || CONFIG_HEADERS=$config_headers
15.11948 +  test "${CONFIG_COMMANDS+set}" = set || CONFIG_COMMANDS=$config_commands
15.11949 +fi
15.11950 +
15.11951 +# Have a temporary directory for convenience.  Make it in the build tree
15.11952 +# simply because there is no reason against having it here, and in addition,
15.11953 +# creating and moving files from /tmp can sometimes cause problems.
15.11954 +# Hook for its removal unless debugging.
15.11955 +# Note that there is a small window in which the directory will not be cleaned:
15.11956 +# after its creation but before its name has been assigned to `$tmp'.
15.11957 +$debug ||
15.11958 +{
15.11959 +  tmp=
15.11960 +  trap 'exit_status=$?
15.11961 +  { test -z "$tmp" || test ! -d "$tmp" || rm -fr "$tmp"; } && exit $exit_status
15.11962 +' 0
15.11963 +  trap 'as_fn_exit 1' 1 2 13 15
15.11964 +}
15.11965 +# Create a (secure) tmp directory for tmp files.
15.11966 +
15.11967 +{
15.11968 +  tmp=`(umask 077 && mktemp -d "./confXXXXXX") 2>/dev/null` &&
15.11969 +  test -n "$tmp" && test -d "$tmp"
15.11970 +}  ||
15.11971 +{
15.11972 +  tmp=./conf$$-$RANDOM
15.11973 +  (umask 077 && mkdir "$tmp")
15.11974 +} || as_fn_error "cannot create a temporary directory in ." "$LINENO" 5
15.11975 +
15.11976 +# Set up the scripts for CONFIG_FILES section.
15.11977 +# No need to generate them if there are no CONFIG_FILES.
15.11978 +# This happens for instance with `./config.status config.h'.
15.11979 +if test -n "$CONFIG_FILES"; then
15.11980 +
15.11981 +
15.11982 +ac_cr=`echo X | tr X '\015'`
15.11983 +# On cygwin, bash can eat \r inside `` if the user requested igncr.
15.11984 +# But we know of no other shell where ac_cr would be empty at this
15.11985 +# point, so we can use a bashism as a fallback.
15.11986 +if test "x$ac_cr" = x; then
15.11987 +  eval ac_cr=\$\'\\r\'
15.11988 +fi
15.11989 +ac_cs_awk_cr=`$AWK 'BEGIN { print "a\rb" }' </dev/null 2>/dev/null`
15.11990 +if test "$ac_cs_awk_cr" = "a${ac_cr}b"; then
15.11991 +  ac_cs_awk_cr='\r'
15.11992 +else
15.11993 +  ac_cs_awk_cr=$ac_cr
15.11994 +fi
15.11995 +
15.11996 +echo 'BEGIN {' >"$tmp/subs1.awk" &&
15.11997 +_ACEOF
15.11998 +
15.11999 +
15.12000 +{
15.12001 +  echo "cat >conf$$subs.awk <<_ACEOF" &&
15.12002 +  echo "$ac_subst_vars" | sed 's/.*/&!$&$ac_delim/' &&
15.12003 +  echo "_ACEOF"
15.12004 +} >conf$$subs.sh ||
15.12005 +  as_fn_error "could not make $CONFIG_STATUS" "$LINENO" 5
15.12006 +ac_delim_num=`echo "$ac_subst_vars" | grep -c '$'`
15.12007 +ac_delim='%!_!# '
15.12008 +for ac_last_try in false false false false false :; do
15.12009 +  . ./conf$$subs.sh ||
15.12010 +    as_fn_error "could not make $CONFIG_STATUS" "$LINENO" 5
15.12011 +
15.12012 +  ac_delim_n=`sed -n "s/.*$ac_delim\$/X/p" conf$$subs.awk | grep -c X`
15.12013 +  if test $ac_delim_n = $ac_delim_num; then
15.12014 +    break
15.12015 +  elif $ac_last_try; then
15.12016 +    as_fn_error "could not make $CONFIG_STATUS" "$LINENO" 5
15.12017 +  else
15.12018 +    ac_delim="$ac_delim!$ac_delim _$ac_delim!! "
15.12019 +  fi
15.12020 +done
15.12021 +rm -f conf$$subs.sh
15.12022 +
15.12023 +cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
15.12024 +cat >>"\$tmp/subs1.awk" <<\\_ACAWK &&
15.12025 +_ACEOF
15.12026 +sed -n '
15.12027 +h
15.12028 +s/^/S["/; s/!.*/"]=/
15.12029 +p
15.12030 +g
15.12031 +s/^[^!]*!//
15.12032 +:repl
15.12033 +t repl
15.12034 +s/'"$ac_delim"'$//
15.12035 +t delim
15.12036 +:nl
15.12037 +h
15.12038 +s/\(.\{148\}\)..*/\1/
15.12039 +t more1
15.12040 +s/["\\]/\\&/g; s/^/"/; s/$/\\n"\\/
15.12041 +p
15.12042 +n
15.12043 +b repl
15.12044 +:more1
15.12045 +s/["\\]/\\&/g; s/^/"/; s/$/"\\/
15.12046 +p
15.12047 +g
15.12048 +s/.\{148\}//
15.12049 +t nl
15.12050 +:delim
15.12051 +h
15.12052 +s/\(.\{148\}\)..*/\1/
15.12053 +t more2
15.12054 +s/["\\]/\\&/g; s/^/"/; s/$/"/
15.12055 +p
15.12056 +b
15.12057 +:more2
15.12058 +s/["\\]/\\&/g; s/^/"/; s/$/"\\/
15.12059 +p
15.12060 +g
15.12061 +s/.\{148\}//
15.12062 +t delim
15.12063 +' <conf$$subs.awk | sed '
15.12064 +/^[^""]/{
15.12065 +  N
15.12066 +  s/\n//
15.12067 +}
15.12068 +' >>$CONFIG_STATUS || ac_write_fail=1
15.12069 +rm -f conf$$subs.awk
15.12070 +cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
15.12071 +_ACAWK
15.12072 +cat >>"\$tmp/subs1.awk" <<_ACAWK &&
15.12073 +  for (key in S) S_is_set[key] = 1
15.12074 +  FS = ""
15.12075 +
15.12076 +}
15.12077 +{
15.12078 +  line = $ 0
15.12079 +  nfields = split(line, field, "@")
15.12080 +  substed = 0
15.12081 +  len = length(field[1])
15.12082 +  for (i = 2; i < nfields; i++) {
15.12083 +    key = field[i]
15.12084 +    keylen = length(key)
15.12085 +    if (S_is_set[key]) {
15.12086 +      value = S[key]
15.12087 +      line = substr(line, 1, len) "" value "" substr(line, len + keylen + 3)
15.12088 +      len += length(value) + length(field[++i])
15.12089 +      substed = 1
15.12090 +    } else
15.12091 +      len += 1 + keylen
15.12092 +  }
15.12093 +
15.12094 +  print line
15.12095 +}
15.12096 +
15.12097 +_ACAWK
15.12098 +_ACEOF
15.12099 +cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
15.12100 +if sed "s/$ac_cr//" < /dev/null > /dev/null 2>&1; then
15.12101 +  sed "s/$ac_cr\$//; s/$ac_cr/$ac_cs_awk_cr/g"
15.12102 +else
15.12103 +  cat
15.12104 +fi < "$tmp/subs1.awk" > "$tmp/subs.awk" \
15.12105 +  || as_fn_error "could not setup config files machinery" "$LINENO" 5
15.12106 +_ACEOF
15.12107 +
15.12108 +# VPATH may cause trouble with some makes, so we remove $(srcdir),
15.12109 +# ${srcdir} and @srcdir@ from VPATH if srcdir is ".", strip leading and
15.12110 +# trailing colons and then remove the whole line if VPATH becomes empty
15.12111 +# (actually we leave an empty line to preserve line numbers).
15.12112 +if test "x$srcdir" = x.; then
15.12113 +  ac_vpsub='/^[	 ]*VPATH[	 ]*=/{
15.12114 +s/:*\$(srcdir):*/:/
15.12115 +s/:*\${srcdir}:*/:/
15.12116 +s/:*@srcdir@:*/:/
15.12117 +s/^\([^=]*=[	 ]*\):*/\1/
15.12118 +s/:*$//
15.12119 +s/^[^=]*=[	 ]*$//
15.12120 +}'
15.12121 +fi
15.12122 +
15.12123 +cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
15.12124 +fi # test -n "$CONFIG_FILES"
15.12125 +
15.12126 +# Set up the scripts for CONFIG_HEADERS section.
15.12127 +# No need to generate them if there are no CONFIG_HEADERS.
15.12128 +# This happens for instance with `./config.status Makefile'.
15.12129 +if test -n "$CONFIG_HEADERS"; then
15.12130 +cat >"$tmp/defines.awk" <<\_ACAWK ||
15.12131 +BEGIN {
15.12132 +_ACEOF
15.12133 +
15.12134 +# Transform confdefs.h into an awk script `defines.awk', embedded as
15.12135 +# here-document in config.status, that substitutes the proper values into
15.12136 +# config.h.in to produce config.h.
15.12137 +
15.12138 +# Create a delimiter string that does not exist in confdefs.h, to ease
15.12139 +# handling of long lines.
15.12140 +ac_delim='%!_!# '
15.12141 +for ac_last_try in false false :; do
15.12142 +  ac_t=`sed -n "/$ac_delim/p" confdefs.h`
15.12143 +  if test -z "$ac_t"; then
15.12144 +    break
15.12145 +  elif $ac_last_try; then
15.12146 +    as_fn_error "could not make $CONFIG_HEADERS" "$LINENO" 5
15.12147 +  else
15.12148 +    ac_delim="$ac_delim!$ac_delim _$ac_delim!! "
15.12149 +  fi
15.12150 +done
15.12151 +
15.12152 +# For the awk script, D is an array of macro values keyed by name,
15.12153 +# likewise P contains macro parameters if any.  Preserve backslash
15.12154 +# newline sequences.
15.12155 +
15.12156 +ac_word_re=[_$as_cr_Letters][_$as_cr_alnum]*
15.12157 +sed -n '
15.12158 +s/.\{148\}/&'"$ac_delim"'/g
15.12159 +t rset
15.12160 +:rset
15.12161 +s/^[	 ]*#[	 ]*define[	 ][	 ]*/ /
15.12162 +t def
15.12163 +d
15.12164 +:def
15.12165 +s/\\$//
15.12166 +t bsnl
15.12167 +s/["\\]/\\&/g
15.12168 +s/^ \('"$ac_word_re"'\)\(([^()]*)\)[	 ]*\(.*\)/P["\1"]="\2"\
15.12169 +D["\1"]=" \3"/p
15.12170 +s/^ \('"$ac_word_re"'\)[	 ]*\(.*\)/D["\1"]=" \2"/p
15.12171 +d
15.12172 +:bsnl
15.12173 +s/["\\]/\\&/g
15.12174 +s/^ \('"$ac_word_re"'\)\(([^()]*)\)[	 ]*\(.*\)/P["\1"]="\2"\
15.12175 +D["\1"]=" \3\\\\\\n"\\/p
15.12176 +t cont
15.12177 +s/^ \('"$ac_word_re"'\)[	 ]*\(.*\)/D["\1"]=" \2\\\\\\n"\\/p
15.12178 +t cont
15.12179 +d
15.12180 +:cont
15.12181 +n
15.12182 +s/.\{148\}/&'"$ac_delim"'/g
15.12183 +t clear
15.12184 +:clear
15.12185 +s/\\$//
15.12186 +t bsnlc
15.12187 +s/["\\]/\\&/g; s/^/"/; s/$/"/p
15.12188 +d
15.12189 +:bsnlc
15.12190 +s/["\\]/\\&/g; s/^/"/; s/$/\\\\\\n"\\/p
15.12191 +b cont
15.12192 +' <confdefs.h | sed '
15.12193 +s/'"$ac_delim"'/"\\\
15.12194 +"/g' >>$CONFIG_STATUS || ac_write_fail=1
15.12195 +
15.12196 +cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
15.12197 +  for (key in D) D_is_set[key] = 1
15.12198 +  FS = ""
15.12199 +}
15.12200 +/^[\t ]*#[\t ]*(define|undef)[\t ]+$ac_word_re([\t (]|\$)/ {
15.12201 +  line = \$ 0
15.12202 +  split(line, arg, " ")
15.12203 +  if (arg[1] == "#") {
15.12204 +    defundef = arg[2]
15.12205 +    mac1 = arg[3]
15.12206 +  } else {
15.12207 +    defundef = substr(arg[1], 2)
15.12208 +    mac1 = arg[2]
15.12209 +  }
15.12210 +  split(mac1, mac2, "(") #)
15.12211 +  macro = mac2[1]
15.12212 +  prefix = substr(line, 1, index(line, defundef) - 1)
15.12213 +  if (D_is_set[macro]) {
15.12214 +    # Preserve the white space surrounding the "#".
15.12215 +    print prefix "define", macro P[macro] D[macro]
15.12216 +    next
15.12217 +  } else {
15.12218 +    # Replace #undef with comments.  This is necessary, for example,
15.12219 +    # in the case of _POSIX_SOURCE, which is predefined and required
15.12220 +    # on some systems where configure will not decide to define it.
15.12221 +    if (defundef == "undef") {
15.12222 +      print "/*", prefix defundef, macro, "*/"
15.12223 +      next
15.12224 +    }
15.12225 +  }
15.12226 +}
15.12227 +{ print }
15.12228 +_ACAWK
15.12229 +_ACEOF
15.12230 +cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
15.12231 +  as_fn_error "could not setup config headers machinery" "$LINENO" 5
15.12232 +fi # test -n "$CONFIG_HEADERS"
15.12233 +
15.12234 +
15.12235 +eval set X "  :F $CONFIG_FILES  :H $CONFIG_HEADERS    :C $CONFIG_COMMANDS"
15.12236 +shift
15.12237 +for ac_tag
15.12238 +do
15.12239 +  case $ac_tag in
15.12240 +  :[FHLC]) ac_mode=$ac_tag; continue;;
15.12241 +  esac
15.12242 +  case $ac_mode$ac_tag in
15.12243 +  :[FHL]*:*);;
15.12244 +  :L* | :C*:*) as_fn_error "invalid tag \`$ac_tag'" "$LINENO" 5;;
15.12245 +  :[FH]-) ac_tag=-:-;;
15.12246 +  :[FH]*) ac_tag=$ac_tag:$ac_tag.in;;
15.12247 +  esac
15.12248 +  ac_save_IFS=$IFS
15.12249 +  IFS=:
15.12250 +  set x $ac_tag
15.12251 +  IFS=$ac_save_IFS
15.12252 +  shift
15.12253 +  ac_file=$1
15.12254 +  shift
15.12255 +
15.12256 +  case $ac_mode in
15.12257 +  :L) ac_source=$1;;
15.12258 +  :[FH])
15.12259 +    ac_file_inputs=
15.12260 +    for ac_f
15.12261 +    do
15.12262 +      case $ac_f in
15.12263 +      -) ac_f="$tmp/stdin";;
15.12264 +      *) # Look for the file first in the build tree, then in the source tree
15.12265 +	 # (if the path is not absolute).  The absolute path cannot be DOS-style,
15.12266 +	 # because $ac_f cannot contain `:'.
15.12267 +	 test -f "$ac_f" ||
15.12268 +	   case $ac_f in
15.12269 +	   [\\/$]*) false;;
15.12270 +	   *) test -f "$srcdir/$ac_f" && ac_f="$srcdir/$ac_f";;
15.12271 +	   esac ||
15.12272 +	   as_fn_error "cannot find input file: \`$ac_f'" "$LINENO" 5;;
15.12273 +      esac
15.12274 +      case $ac_f in *\'*) ac_f=`$as_echo "$ac_f" | sed "s/'/'\\\\\\\\''/g"`;; esac
15.12275 +      as_fn_append ac_file_inputs " '$ac_f'"
15.12276 +    done
15.12277 +
15.12278 +    # Let's still pretend it is `configure' which instantiates (i.e., don't
15.12279 +    # use $as_me), people would be surprised to read:
15.12280 +    #    /* config.h.  Generated by config.status.  */
15.12281 +    configure_input='Generated from '`
15.12282 +	  $as_echo "$*" | sed 's|^[^:]*/||;s|:[^:]*/|, |g'
15.12283 +	`' by configure.'
15.12284 +    if test x"$ac_file" != x-; then
15.12285 +      configure_input="$ac_file.  $configure_input"
15.12286 +      { $as_echo "$as_me:${as_lineno-$LINENO}: creating $ac_file" >&5
15.12287 +$as_echo "$as_me: creating $ac_file" >&6;}
15.12288 +    fi
15.12289 +    # Neutralize special characters interpreted by sed in replacement strings.
15.12290 +    case $configure_input in #(
15.12291 +    *\&* | *\|* | *\\* )
15.12292 +       ac_sed_conf_input=`$as_echo "$configure_input" |
15.12293 +       sed 's/[\\\\&|]/\\\\&/g'`;; #(
15.12294 +    *) ac_sed_conf_input=$configure_input;;
15.12295 +    esac
15.12296 +
15.12297 +    case $ac_tag in
15.12298 +    *:-:* | *:-) cat >"$tmp/stdin" \
15.12299 +      || as_fn_error "could not create $ac_file" "$LINENO" 5 ;;
15.12300 +    esac
15.12301 +    ;;
15.12302 +  esac
15.12303 +
15.12304 +  ac_dir=`$as_dirname -- "$ac_file" ||
15.12305 +$as_expr X"$ac_file" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
15.12306 +	 X"$ac_file" : 'X\(//\)[^/]' \| \
15.12307 +	 X"$ac_file" : 'X\(//\)$' \| \
15.12308 +	 X"$ac_file" : 'X\(/\)' \| . 2>/dev/null ||
15.12309 +$as_echo X"$ac_file" |
15.12310 +    sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{
15.12311 +	    s//\1/
15.12312 +	    q
15.12313 +	  }
15.12314 +	  /^X\(\/\/\)[^/].*/{
15.12315 +	    s//\1/
15.12316 +	    q
15.12317 +	  }
15.12318 +	  /^X\(\/\/\)$/{
15.12319 +	    s//\1/
15.12320 +	    q
15.12321 +	  }
15.12322 +	  /^X\(\/\).*/{
15.12323 +	    s//\1/
15.12324 +	    q
15.12325 +	  }
15.12326 +	  s/.*/./; q'`
15.12327 +  as_dir="$ac_dir"; as_fn_mkdir_p
15.12328 +  ac_builddir=.
15.12329 +
15.12330 +case "$ac_dir" in
15.12331 +.) ac_dir_suffix= ac_top_builddir_sub=. ac_top_build_prefix= ;;
15.12332 +*)
15.12333 +  ac_dir_suffix=/`$as_echo "$ac_dir" | sed 's|^\.[\\/]||'`
15.12334 +  # A ".." for each directory in $ac_dir_suffix.
15.12335 +  ac_top_builddir_sub=`$as_echo "$ac_dir_suffix" | sed 's|/[^\\/]*|/..|g;s|/||'`
15.12336 +  case $ac_top_builddir_sub in
15.12337 +  "") ac_top_builddir_sub=. ac_top_build_prefix= ;;
15.12338 +  *)  ac_top_build_prefix=$ac_top_builddir_sub/ ;;
15.12339 +  esac ;;
15.12340 +esac
15.12341 +ac_abs_top_builddir=$ac_pwd
15.12342 +ac_abs_builddir=$ac_pwd$ac_dir_suffix
15.12343 +# for backward compatibility:
15.12344 +ac_top_builddir=$ac_top_build_prefix
15.12345 +
15.12346 +case $srcdir in
15.12347 +  .)  # We are building in place.
15.12348 +    ac_srcdir=.
15.12349 +    ac_top_srcdir=$ac_top_builddir_sub
15.12350 +    ac_abs_top_srcdir=$ac_pwd ;;
15.12351 +  [\\/]* | ?:[\\/]* )  # Absolute name.
15.12352 +    ac_srcdir=$srcdir$ac_dir_suffix;
15.12353 +    ac_top_srcdir=$srcdir
15.12354 +    ac_abs_top_srcdir=$srcdir ;;
15.12355 +  *) # Relative name.
15.12356 +    ac_srcdir=$ac_top_build_prefix$srcdir$ac_dir_suffix
15.12357 +    ac_top_srcdir=$ac_top_build_prefix$srcdir
15.12358 +    ac_abs_top_srcdir=$ac_pwd/$srcdir ;;
15.12359 +esac
15.12360 +ac_abs_srcdir=$ac_abs_top_srcdir$ac_dir_suffix
15.12361 +
15.12362 +
15.12363 +  case $ac_mode in
15.12364 +  :F)
15.12365 +  #
15.12366 +  # CONFIG_FILE
15.12367 +  #
15.12368 +
15.12369 +  case $INSTALL in
15.12370 +  [\\/$]* | ?:[\\/]* ) ac_INSTALL=$INSTALL ;;
15.12371 +  *) ac_INSTALL=$ac_top_build_prefix$INSTALL ;;
15.12372 +  esac
15.12373 +  ac_MKDIR_P=$MKDIR_P
15.12374 +  case $MKDIR_P in
15.12375 +  [\\/$]* | ?:[\\/]* ) ;;
15.12376 +  */*) ac_MKDIR_P=$ac_top_build_prefix$MKDIR_P ;;
15.12377 +  esac
15.12378 +_ACEOF
15.12379 +
15.12380 +cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
15.12381 +# If the template does not know about datarootdir, expand it.
15.12382 +# FIXME: This hack should be removed a few years after 2.60.
15.12383 +ac_datarootdir_hack=; ac_datarootdir_seen=
15.12384 +ac_sed_dataroot='
15.12385 +/datarootdir/ {
15.12386 +  p
15.12387 +  q
15.12388 +}
15.12389 +/@datadir@/p
15.12390 +/@docdir@/p
15.12391 +/@infodir@/p
15.12392 +/@localedir@/p
15.12393 +/@mandir@/p'
15.12394 +case `eval "sed -n \"\$ac_sed_dataroot\" $ac_file_inputs"` in
15.12395 +*datarootdir*) ac_datarootdir_seen=yes;;
15.12396 +*@datadir@*|*@docdir@*|*@infodir@*|*@localedir@*|*@mandir@*)
15.12397 +  { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $ac_file_inputs seems to ignore the --datarootdir setting" >&5
15.12398 +$as_echo "$as_me: WARNING: $ac_file_inputs seems to ignore the --datarootdir setting" >&2;}
15.12399 +_ACEOF
15.12400 +cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
15.12401 +  ac_datarootdir_hack='
15.12402 +  s&@datadir@&$datadir&g
15.12403 +  s&@docdir@&$docdir&g
15.12404 +  s&@infodir@&$infodir&g
15.12405 +  s&@localedir@&$localedir&g
15.12406 +  s&@mandir@&$mandir&g
15.12407 +  s&\\\${datarootdir}&$datarootdir&g' ;;
15.12408 +esac
15.12409 +_ACEOF
15.12410 +
15.12411 +# Neutralize VPATH when `$srcdir' = `.'.
15.12412 +# Shell code in configure.ac might set extrasub.
15.12413 +# FIXME: do we really want to maintain this feature?
15.12414 +cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
15.12415 +ac_sed_extra="$ac_vpsub
15.12416 +$extrasub
15.12417 +_ACEOF
15.12418 +cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
15.12419 +:t
15.12420 +/@[a-zA-Z_][a-zA-Z_0-9]*@/!b
15.12421 +s|@configure_input@|$ac_sed_conf_input|;t t
15.12422 +s&@top_builddir@&$ac_top_builddir_sub&;t t
15.12423 +s&@top_build_prefix@&$ac_top_build_prefix&;t t
15.12424 +s&@srcdir@&$ac_srcdir&;t t
15.12425 +s&@abs_srcdir@&$ac_abs_srcdir&;t t
15.12426 +s&@top_srcdir@&$ac_top_srcdir&;t t
15.12427 +s&@abs_top_srcdir@&$ac_abs_top_srcdir&;t t
15.12428 +s&@builddir@&$ac_builddir&;t t
15.12429 +s&@abs_builddir@&$ac_abs_builddir&;t t
15.12430 +s&@abs_top_builddir@&$ac_abs_top_builddir&;t t
15.12431 +s&@INSTALL@&$ac_INSTALL&;t t
15.12432 +s&@MKDIR_P@&$ac_MKDIR_P&;t t
15.12433 +$ac_datarootdir_hack
15.12434 +"
15.12435 +eval sed \"\$ac_sed_extra\" "$ac_file_inputs" | $AWK -f "$tmp/subs.awk" >$tmp/out \
15.12436 +  || as_fn_error "could not create $ac_file" "$LINENO" 5
15.12437 +
15.12438 +test -z "$ac_datarootdir_hack$ac_datarootdir_seen" &&
15.12439 +  { ac_out=`sed -n '/\${datarootdir}/p' "$tmp/out"`; test -n "$ac_out"; } &&
15.12440 +  { ac_out=`sed -n '/^[	 ]*datarootdir[	 ]*:*=/p' "$tmp/out"`; test -z "$ac_out"; } &&
15.12441 +  { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $ac_file contains a reference to the variable \`datarootdir'
15.12442 +which seems to be undefined.  Please make sure it is defined." >&5
15.12443 +$as_echo "$as_me: WARNING: $ac_file contains a reference to the variable \`datarootdir'
15.12444 +which seems to be undefined.  Please make sure it is defined." >&2;}
15.12445 +
15.12446 +  rm -f "$tmp/stdin"
15.12447 +  case $ac_file in
15.12448 +  -) cat "$tmp/out" && rm -f "$tmp/out";;
15.12449 +  *) rm -f "$ac_file" && mv "$tmp/out" "$ac_file";;
15.12450 +  esac \
15.12451 +  || as_fn_error "could not create $ac_file" "$LINENO" 5
15.12452 + ;;
15.12453 +  :H)
15.12454 +  #
15.12455 +  # CONFIG_HEADER
15.12456 +  #
15.12457 +  if test x"$ac_file" != x-; then
15.12458 +    {
15.12459 +      $as_echo "/* $configure_input  */" \
15.12460 +      && eval '$AWK -f "$tmp/defines.awk"' "$ac_file_inputs"
15.12461 +    } >"$tmp/config.h" \
15.12462 +      || as_fn_error "could not create $ac_file" "$LINENO" 5
15.12463 +    if diff "$ac_file" "$tmp/config.h" >/dev/null 2>&1; then
15.12464 +      { $as_echo "$as_me:${as_lineno-$LINENO}: $ac_file is unchanged" >&5
15.12465 +$as_echo "$as_me: $ac_file is unchanged" >&6;}
15.12466 +    else
15.12467 +      rm -f "$ac_file"
15.12468 +      mv "$tmp/config.h" "$ac_file" \
15.12469 +	|| as_fn_error "could not create $ac_file" "$LINENO" 5
15.12470 +    fi
15.12471 +  else
15.12472 +    $as_echo "/* $configure_input  */" \
15.12473 +      && eval '$AWK -f "$tmp/defines.awk"' "$ac_file_inputs" \
15.12474 +      || as_fn_error "could not create -" "$LINENO" 5
15.12475 +  fi
15.12476 +# Compute "$ac_file"'s index in $config_headers.
15.12477 +_am_arg="$ac_file"
15.12478 +_am_stamp_count=1
15.12479 +for _am_header in $config_headers :; do
15.12480 +  case $_am_header in
15.12481 +    $_am_arg | $_am_arg:* )
15.12482 +      break ;;
15.12483 +    * )
15.12484 +      _am_stamp_count=`expr $_am_stamp_count + 1` ;;
15.12485 +  esac
15.12486 +done
15.12487 +echo "timestamp for $_am_arg" >`$as_dirname -- "$_am_arg" ||
15.12488 +$as_expr X"$_am_arg" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
15.12489 +	 X"$_am_arg" : 'X\(//\)[^/]' \| \
15.12490 +	 X"$_am_arg" : 'X\(//\)$' \| \
15.12491 +	 X"$_am_arg" : 'X\(/\)' \| . 2>/dev/null ||
15.12492 +$as_echo X"$_am_arg" |
15.12493 +    sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{
15.12494 +	    s//\1/
15.12495 +	    q
15.12496 +	  }
15.12497 +	  /^X\(\/\/\)[^/].*/{
15.12498 +	    s//\1/
15.12499 +	    q
15.12500 +	  }
15.12501 +	  /^X\(\/\/\)$/{
15.12502 +	    s//\1/
15.12503 +	    q
15.12504 +	  }
15.12505 +	  /^X\(\/\).*/{
15.12506 +	    s//\1/
15.12507 +	    q
15.12508 +	  }
15.12509 +	  s/.*/./; q'`/stamp-h$_am_stamp_count
15.12510 + ;;
15.12511 +
15.12512 +  :C)  { $as_echo "$as_me:${as_lineno-$LINENO}: executing $ac_file commands" >&5
15.12513 +$as_echo "$as_me: executing $ac_file commands" >&6;}
15.12514 + ;;
15.12515 +  esac
15.12516 +
15.12517 +
15.12518 +  case $ac_file$ac_mode in
15.12519 +    "depfiles":C) test x"$AMDEP_TRUE" != x"" || {
15.12520 +  # Autoconf 2.62 quotes --file arguments for eval, but not when files
15.12521 +  # are listed without --file.  Let's play safe and only enable the eval
15.12522 +  # if we detect the quoting.
15.12523 +  case $CONFIG_FILES in
15.12524 +  *\'*) eval set x "$CONFIG_FILES" ;;
15.12525 +  *)   set x $CONFIG_FILES ;;
15.12526 +  esac
15.12527 +  shift
15.12528 +  for mf
15.12529 +  do
15.12530 +    # Strip MF so we end up with the name of the file.
15.12531 +    mf=`echo "$mf" | sed -e 's/:.*$//'`
15.12532 +    # Check whether this is an Automake generated Makefile or not.
15.12533 +    # We used to match only the files named `Makefile.in', but
15.12534 +    # some people rename them; so instead we look at the file content.
15.12535 +    # Grep'ing the first line is not enough: some people post-process
15.12536 +    # each Makefile.in and add a new line on top of each file to say so.
15.12537 +    # Grep'ing the whole file is not good either: AIX grep has a line
15.12538 +    # limit of 2048, but all sed's we know have understand at least 4000.
15.12539 +    if sed -n 's,^#.*generated by automake.*,X,p' "$mf" | grep X >/dev/null 2>&1; then
15.12540 +      dirpart=`$as_dirname -- "$mf" ||
15.12541 +$as_expr X"$mf" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
15.12542 +	 X"$mf" : 'X\(//\)[^/]' \| \
15.12543 +	 X"$mf" : 'X\(//\)$' \| \
15.12544 +	 X"$mf" : 'X\(/\)' \| . 2>/dev/null ||
15.12545 +$as_echo X"$mf" |
15.12546 +    sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{
15.12547 +	    s//\1/
15.12548 +	    q
15.12549 +	  }
15.12550 +	  /^X\(\/\/\)[^/].*/{
15.12551 +	    s//\1/
15.12552 +	    q
15.12553 +	  }
15.12554 +	  /^X\(\/\/\)$/{
15.12555 +	    s//\1/
15.12556 +	    q
15.12557 +	  }
15.12558 +	  /^X\(\/\).*/{
15.12559 +	    s//\1/
15.12560 +	    q
15.12561 +	  }
15.12562 +	  s/.*/./; q'`
15.12563 +    else
15.12564 +      continue
15.12565 +    fi
15.12566 +    # Extract the definition of DEPDIR, am__include, and am__quote
15.12567 +    # from the Makefile without running `make'.
15.12568 +    DEPDIR=`sed -n 's/^DEPDIR = //p' < "$mf"`
15.12569 +    test -z "$DEPDIR" && continue
15.12570 +    am__include=`sed -n 's/^am__include = //p' < "$mf"`
15.12571 +    test -z "am__include" && continue
15.12572 +    am__quote=`sed -n 's/^am__quote = //p' < "$mf"`
15.12573 +    # When using ansi2knr, U may be empty or an underscore; expand it
15.12574 +    U=`sed -n 's/^U = //p' < "$mf"`
15.12575 +    # Find all dependency output files, they are included files with
15.12576 +    # $(DEPDIR) in their names.  We invoke sed twice because it is the
15.12577 +    # simplest approach to changing $(DEPDIR) to its actual value in the
15.12578 +    # expansion.
15.12579 +    for file in `sed -n "
15.12580 +      s/^$am__include $am__quote\(.*(DEPDIR).*\)$am__quote"'$/\1/p' <"$mf" | \
15.12581 +	 sed -e 's/\$(DEPDIR)/'"$DEPDIR"'/g' -e 's/\$U/'"$U"'/g'`; do
15.12582 +      # Make sure the directory exists.
15.12583 +      test -f "$dirpart/$file" && continue
15.12584 +      fdir=`$as_dirname -- "$file" ||
15.12585 +$as_expr X"$file" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
15.12586 +	 X"$file" : 'X\(//\)[^/]' \| \
15.12587 +	 X"$file" : 'X\(//\)$' \| \
15.12588 +	 X"$file" : 'X\(/\)' \| . 2>/dev/null ||
15.12589 +$as_echo X"$file" |
15.12590 +    sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{
15.12591 +	    s//\1/
15.12592 +	    q
15.12593 +	  }
15.12594 +	  /^X\(\/\/\)[^/].*/{
15.12595 +	    s//\1/
15.12596 +	    q
15.12597 +	  }
15.12598 +	  /^X\(\/\/\)$/{
15.12599 +	    s//\1/
15.12600 +	    q
15.12601 +	  }
15.12602 +	  /^X\(\/\).*/{
15.12603 +	    s//\1/
15.12604 +	    q
15.12605 +	  }
15.12606 +	  s/.*/./; q'`
15.12607 +      as_dir=$dirpart/$fdir; as_fn_mkdir_p
15.12608 +      # echo "creating $dirpart/$file"
15.12609 +      echo '# dummy' > "$dirpart/$file"
15.12610 +    done
15.12611 +  done
15.12612 +}
15.12613 + ;;
15.12614 +    "libtool":C)
15.12615 +
15.12616 +    # See if we are running on zsh, and set the options which allow our
15.12617 +    # commands through without removal of \ escapes.
15.12618 +    if test -n "${ZSH_VERSION+set}" ; then
15.12619 +      setopt NO_GLOB_SUBST
15.12620 +    fi
15.12621 +
15.12622 +    cfgfile="${ofile}T"
15.12623 +    trap "$RM \"$cfgfile\"; exit 1" 1 2 15
15.12624 +    $RM "$cfgfile"
15.12625 +
15.12626 +    cat <<_LT_EOF >> "$cfgfile"
15.12627 +#! $SHELL
15.12628 +
15.12629 +# `$ECHO "$ofile" | sed 's%^.*/%%'` - Provide generalized library-building support services.
15.12630 +# Generated automatically by $as_me ($PACKAGE$TIMESTAMP) $VERSION
15.12631 +# Libtool was configured on host `(hostname || uname -n) 2>/dev/null | sed 1q`:
15.12632 +# NOTE: Changes made to this file will be lost: look at ltmain.sh.
15.12633 +#
15.12634 +#   Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2003, 2004, 2005,
15.12635 +#                 2006, 2007, 2008, 2009 Free Software Foundation, Inc.
15.12636 +#   Written by Gordon Matzigkeit, 1996
15.12637 +#
15.12638 +#   This file is part of GNU Libtool.
15.12639 +#
15.12640 +# GNU Libtool is free software; you can redistribute it and/or
15.12641 +# modify it under the terms of the GNU General Public License as
15.12642 +# published by the Free Software Foundation; either version 2 of
15.12643 +# the License, or (at your option) any later version.
15.12644 +#
15.12645 +# As a special exception to the GNU General Public License,
15.12646 +# if you distribute this file as part of a program or library that
15.12647 +# is built using GNU Libtool, you may include this file under the
15.12648 +# same distribution terms that you use for the rest of that program.
15.12649 +#
15.12650 +# GNU Libtool is distributed in the hope that it will be useful,
15.12651 +# but WITHOUT ANY WARRANTY; without even the implied warranty of
15.12652 +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15.12653 +# GNU General Public License for more details.
15.12654 +#
15.12655 +# You should have received a copy of the GNU General Public License
15.12656 +# along with GNU Libtool; see the file COPYING.  If not, a copy
15.12657 +# can be downloaded from http://www.gnu.org/licenses/gpl.html, or
15.12658 +# obtained by writing to the Free Software Foundation, Inc.,
15.12659 +# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
15.12660 +
15.12661 +
15.12662 +# The names of the tagged configurations supported by this script.
15.12663 +available_tags=""
15.12664 +
15.12665 +# ### BEGIN LIBTOOL CONFIG
15.12666 +
15.12667 +# Which release of libtool.m4 was used?
15.12668 +macro_version=$macro_version
15.12669 +macro_revision=$macro_revision
15.12670 +
15.12671 +# Whether or not to build shared libraries.
15.12672 +build_libtool_libs=$enable_shared
15.12673 +
15.12674 +# Whether or not to build static libraries.
15.12675 +build_old_libs=$enable_static
15.12676 +
15.12677 +# What type of objects to build.
15.12678 +pic_mode=$pic_mode
15.12679 +
15.12680 +# Whether or not to optimize for fast installation.
15.12681 +fast_install=$enable_fast_install
15.12682 +
15.12683 +# Shell to use when invoking shell scripts.
15.12684 +SHELL=$lt_SHELL
15.12685 +
15.12686 +# An echo program that protects backslashes.
15.12687 +ECHO=$lt_ECHO
15.12688 +
15.12689 +# The host system.
15.12690 +host_alias=$host_alias
15.12691 +host=$host
15.12692 +host_os=$host_os
15.12693 +
15.12694 +# The build system.
15.12695 +build_alias=$build_alias
15.12696 +build=$build
15.12697 +build_os=$build_os
15.12698 +
15.12699 +# A sed program that does not truncate output.
15.12700 +SED=$lt_SED
15.12701 +
15.12702 +# Sed that helps us avoid accidentally triggering echo(1) options like -n.
15.12703 +Xsed="\$SED -e 1s/^X//"
15.12704 +
15.12705 +# A grep program that handles long lines.
15.12706 +GREP=$lt_GREP
15.12707 +
15.12708 +# An ERE matcher.
15.12709 +EGREP=$lt_EGREP
15.12710 +
15.12711 +# A literal string matcher.
15.12712 +FGREP=$lt_FGREP
15.12713 +
15.12714 +# A BSD- or MS-compatible name lister.
15.12715 +NM=$lt_NM
15.12716 +
15.12717 +# Whether we need soft or hard links.
15.12718 +LN_S=$lt_LN_S
15.12719 +
15.12720 +# What is the maximum length of a command?
15.12721 +max_cmd_len=$max_cmd_len
15.12722 +
15.12723 +# Object file suffix (normally "o").
15.12724 +objext=$ac_objext
15.12725 +
15.12726 +# Executable file suffix (normally "").
15.12727 +exeext=$exeext
15.12728 +
15.12729 +# whether the shell understands "unset".
15.12730 +lt_unset=$lt_unset
15.12731 +
15.12732 +# turn spaces into newlines.
15.12733 +SP2NL=$lt_lt_SP2NL
15.12734 +
15.12735 +# turn newlines into spaces.
15.12736 +NL2SP=$lt_lt_NL2SP
15.12737 +
15.12738 +# convert \$build paths to \$host format.
15.12739 +to_host_path_cmd=$lt_cv_to_host_path_cmd
15.12740 +
15.12741 +# An object symbol dumper.
15.12742 +OBJDUMP=$lt_OBJDUMP
15.12743 +
15.12744 +# Method to check whether dependent libraries are shared objects.
15.12745 +deplibs_check_method=$lt_deplibs_check_method
15.12746 +
15.12747 +# Command to use when deplibs_check_method == "file_magic".
15.12748 +file_magic_cmd=$lt_file_magic_cmd
15.12749 +
15.12750 +# DLL creation program.
15.12751 +DLLTOOL=$lt_DLLTOOL
15.12752 +
15.12753 +# Command to associate shared and link libraries.
15.12754 +sharedlib_from_linklib_cmd=$lt_sharedlib_from_linklib_cmd
15.12755 +
15.12756 +# The archiver.
15.12757 +AR=$lt_AR
15.12758 +AR_FLAGS=$lt_AR_FLAGS
15.12759 +
15.12760 +# A symbol stripping program.
15.12761 +STRIP=$lt_STRIP
15.12762 +
15.12763 +# Commands used to install an old-style archive.
15.12764 +RANLIB=$lt_RANLIB
15.12765 +old_postinstall_cmds=$lt_old_postinstall_cmds
15.12766 +old_postuninstall_cmds=$lt_old_postuninstall_cmds
15.12767 +
15.12768 +# Whether to use a lock for old archive extraction.
15.12769 +lock_old_archive_extraction=$lock_old_archive_extraction
15.12770 +
15.12771 +# A C compiler.
15.12772 +LTCC=$lt_CC
15.12773 +
15.12774 +# LTCC compiler flags.
15.12775 +LTCFLAGS=$lt_CFLAGS
15.12776 +
15.12777 +# Take the output of nm and produce a listing of raw symbols and C names.
15.12778 +global_symbol_pipe=$lt_lt_cv_sys_global_symbol_pipe
15.12779 +
15.12780 +# Transform the output of nm in a proper C declaration.
15.12781 +global_symbol_to_cdecl=$lt_lt_cv_sys_global_symbol_to_cdecl
15.12782 +
15.12783 +# Transform the output of nm in a C name address pair.
15.12784 +global_symbol_to_c_name_address=$lt_lt_cv_sys_global_symbol_to_c_name_address
15.12785 +
15.12786 +# Transform the output of nm in a C name address pair when lib prefix is needed.
15.12787 +global_symbol_to_c_name_address_lib_prefix=$lt_lt_cv_sys_global_symbol_to_c_name_address_lib_prefix
15.12788 +
15.12789 +# The name of the directory that contains temporary libtool files.
15.12790 +objdir=$objdir
15.12791 +
15.12792 +# Used to examine libraries when file_magic_cmd begins with "file".
15.12793 +MAGIC_CMD=$MAGIC_CMD
15.12794 +
15.12795 +# Must we lock files when doing compilation?
15.12796 +need_locks=$lt_need_locks
15.12797 +
15.12798 +# Tool to manipulate archived DWARF debug symbol files on Mac OS X.
15.12799 +DSYMUTIL=$lt_DSYMUTIL
15.12800 +
15.12801 +# Tool to change global to local symbols on Mac OS X.
15.12802 +NMEDIT=$lt_NMEDIT
15.12803 +
15.12804 +# Tool to manipulate fat objects and archives on Mac OS X.
15.12805 +LIPO=$lt_LIPO
15.12806 +
15.12807 +# ldd/readelf like tool for Mach-O binaries on Mac OS X.
15.12808 +OTOOL=$lt_OTOOL
15.12809 +
15.12810 +# ldd/readelf like tool for 64 bit Mach-O binaries on Mac OS X 10.4.
15.12811 +OTOOL64=$lt_OTOOL64
15.12812 +
15.12813 +# Old archive suffix (normally "a").
15.12814 +libext=$libext
15.12815 +
15.12816 +# Shared library suffix (normally ".so").
15.12817 +shrext_cmds=$lt_shrext_cmds
15.12818 +
15.12819 +# The commands to extract the exported symbol list from a shared archive.
15.12820 +extract_expsyms_cmds=$lt_extract_expsyms_cmds
15.12821 +
15.12822 +# Variables whose values should be saved in libtool wrapper scripts and
15.12823 +# restored at link time.
15.12824 +variables_saved_for_relink=$lt_variables_saved_for_relink
15.12825 +
15.12826 +# Do we need the "lib" prefix for modules?
15.12827 +need_lib_prefix=$need_lib_prefix
15.12828 +
15.12829 +# Do we need a version for libraries?
15.12830 +need_version=$need_version
15.12831 +
15.12832 +# Library versioning type.
15.12833 +version_type=$version_type
15.12834 +
15.12835 +# Shared library runtime path variable.
15.12836 +runpath_var=$runpath_var
15.12837 +
15.12838 +# Shared library path variable.
15.12839 +shlibpath_var=$shlibpath_var
15.12840 +
15.12841 +# Is shlibpath searched before the hard-coded library search path?
15.12842 +shlibpath_overrides_runpath=$shlibpath_overrides_runpath
15.12843 +
15.12844 +# Format of library name prefix.
15.12845 +libname_spec=$lt_libname_spec
15.12846 +
15.12847 +# List of archive names.  First name is the real one, the rest are links.
15.12848 +# The last name is the one that the linker finds with -lNAME
15.12849 +library_names_spec=$lt_library_names_spec
15.12850 +
15.12851 +# The coded name of the library, if different from the real name.
15.12852 +soname_spec=$lt_soname_spec
15.12853 +
15.12854 +# Permission mode override for installation of shared libraries.
15.12855 +install_override_mode=$lt_install_override_mode
15.12856 +
15.12857 +# Command to use after installation of a shared archive.
15.12858 +postinstall_cmds=$lt_postinstall_cmds
15.12859 +
15.12860 +# Command to use after uninstallation of a shared archive.
15.12861 +postuninstall_cmds=$lt_postuninstall_cmds
15.12862 +
15.12863 +# Commands used to finish a libtool library installation in a directory.
15.12864 +finish_cmds=$lt_finish_cmds
15.12865 +
15.12866 +# As "finish_cmds", except a single script fragment to be evaled but
15.12867 +# not shown.
15.12868 +finish_eval=$lt_finish_eval
15.12869 +
15.12870 +# Whether we should hardcode library paths into libraries.
15.12871 +hardcode_into_libs=$hardcode_into_libs
15.12872 +
15.12873 +# Compile-time system search path for libraries.
15.12874 +sys_lib_search_path_spec=$lt_sys_lib_search_path_spec
15.12875 +
15.12876 +# Run-time system search path for libraries.
15.12877 +sys_lib_dlsearch_path_spec=$lt_sys_lib_dlsearch_path_spec
15.12878 +
15.12879 +# Whether dlopen is supported.
15.12880 +dlopen_support=$enable_dlopen
15.12881 +
15.12882 +# Whether dlopen of programs is supported.
15.12883 +dlopen_self=$enable_dlopen_self
15.12884 +
15.12885 +# Whether dlopen of statically linked programs is supported.
15.12886 +dlopen_self_static=$enable_dlopen_self_static
15.12887 +
15.12888 +# Commands to strip libraries.
15.12889 +old_striplib=$lt_old_striplib
15.12890 +striplib=$lt_striplib
15.12891 +
15.12892 +
15.12893 +# The linker used to build libraries.
15.12894 +LD=$lt_LD
15.12895 +
15.12896 +# How to create reloadable object files.
15.12897 +reload_flag=$lt_reload_flag
15.12898 +reload_cmds=$lt_reload_cmds
15.12899 +
15.12900 +# Commands used to build an old-style archive.
15.12901 +old_archive_cmds=$lt_old_archive_cmds
15.12902 +
15.12903 +# A language specific compiler.
15.12904 +CC=$lt_compiler
15.12905 +
15.12906 +# Is the compiler the GNU compiler?
15.12907 +with_gcc=$GCC
15.12908 +
15.12909 +# Compiler flag to turn off builtin functions.
15.12910 +no_builtin_flag=$lt_lt_prog_compiler_no_builtin_flag
15.12911 +
15.12912 +# How to pass a linker flag through the compiler.
15.12913 +wl=$lt_lt_prog_compiler_wl
15.12914 +
15.12915 +# Additional compiler flags for building library objects.
15.12916 +pic_flag=$lt_lt_prog_compiler_pic
15.12917 +
15.12918 +# Compiler flag to prevent dynamic linking.
15.12919 +link_static_flag=$lt_lt_prog_compiler_static
15.12920 +
15.12921 +# Does compiler simultaneously support -c and -o options?
15.12922 +compiler_c_o=$lt_lt_cv_prog_compiler_c_o
15.12923 +
15.12924 +# Whether or not to add -lc for building shared libraries.
15.12925 +build_libtool_need_lc=$archive_cmds_need_lc
15.12926 +
15.12927 +# Whether or not to disallow shared libs when runtime libs are static.
15.12928 +allow_libtool_libs_with_static_runtimes=$enable_shared_with_static_runtimes
15.12929 +
15.12930 +# Compiler flag to allow reflexive dlopens.
15.12931 +export_dynamic_flag_spec=$lt_export_dynamic_flag_spec
15.12932 +
15.12933 +# Compiler flag to generate shared objects directly from archives.
15.12934 +whole_archive_flag_spec=$lt_whole_archive_flag_spec
15.12935 +
15.12936 +# Whether the compiler copes with passing no objects directly.
15.12937 +compiler_needs_object=$lt_compiler_needs_object
15.12938 +
15.12939 +# Create an old-style archive from a shared archive.
15.12940 +old_archive_from_new_cmds=$lt_old_archive_from_new_cmds
15.12941 +
15.12942 +# Create a temporary old-style archive to link instead of a shared archive.
15.12943 +old_archive_from_expsyms_cmds=$lt_old_archive_from_expsyms_cmds
15.12944 +
15.12945 +# Commands used to build a shared archive.
15.12946 +archive_cmds=$lt_archive_cmds
15.12947 +archive_expsym_cmds=$lt_archive_expsym_cmds
15.12948 +
15.12949 +# Commands used to build a loadable module if different from building
15.12950 +# a shared archive.
15.12951 +module_cmds=$lt_module_cmds
15.12952 +module_expsym_cmds=$lt_module_expsym_cmds
15.12953 +
15.12954 +# Whether we are building with GNU ld or not.
15.12955 +with_gnu_ld=$lt_with_gnu_ld
15.12956 +
15.12957 +# Flag that allows shared libraries with undefined symbols to be built.
15.12958 +allow_undefined_flag=$lt_allow_undefined_flag
15.12959 +
15.12960 +# Flag that enforces no undefined symbols.
15.12961 +no_undefined_flag=$lt_no_undefined_flag
15.12962 +
15.12963 +# Flag to hardcode \$libdir into a binary during linking.
15.12964 +# This must work even if \$libdir does not exist
15.12965 +hardcode_libdir_flag_spec=$lt_hardcode_libdir_flag_spec
15.12966 +
15.12967 +# If ld is used when linking, flag to hardcode \$libdir into a binary
15.12968 +# during linking.  This must work even if \$libdir does not exist.
15.12969 +hardcode_libdir_flag_spec_ld=$lt_hardcode_libdir_flag_spec_ld
15.12970 +
15.12971 +# Whether we need a single "-rpath" flag with a separated argument.
15.12972 +hardcode_libdir_separator=$lt_hardcode_libdir_separator
15.12973 +
15.12974 +# Set to "yes" if using DIR/libNAME\${shared_ext} during linking hardcodes
15.12975 +# DIR into the resulting binary.
15.12976 +hardcode_direct=$hardcode_direct
15.12977 +
15.12978 +# Set to "yes" if using DIR/libNAME\${shared_ext} during linking hardcodes
15.12979 +# DIR into the resulting binary and the resulting library dependency is
15.12980 +# "absolute",i.e impossible to change by setting \${shlibpath_var} if the
15.12981 +# library is relocated.
15.12982 +hardcode_direct_absolute=$hardcode_direct_absolute
15.12983 +
15.12984 +# Set to "yes" if using the -LDIR flag during linking hardcodes DIR
15.12985 +# into the resulting binary.
15.12986 +hardcode_minus_L=$hardcode_minus_L
15.12987 +
15.12988 +# Set to "yes" if using SHLIBPATH_VAR=DIR during linking hardcodes DIR
15.12989 +# into the resulting binary.
15.12990 +hardcode_shlibpath_var=$hardcode_shlibpath_var
15.12991 +
15.12992 +# Set to "yes" if building a shared library automatically hardcodes DIR
15.12993 +# into the library and all subsequent libraries and executables linked
15.12994 +# against it.
15.12995 +hardcode_automatic=$hardcode_automatic
15.12996 +
15.12997 +# Set to yes if linker adds runtime paths of dependent libraries
15.12998 +# to runtime path list.
15.12999 +inherit_rpath=$inherit_rpath
15.13000 +
15.13001 +# Whether libtool must link a program against all its dependency libraries.
15.13002 +link_all_deplibs=$link_all_deplibs
15.13003 +
15.13004 +# Fix the shell variable \$srcfile for the compiler.
15.13005 +fix_srcfile_path=$lt_fix_srcfile_path
15.13006 +
15.13007 +# Set to "yes" if exported symbols are required.
15.13008 +always_export_symbols=$always_export_symbols
15.13009 +
15.13010 +# The commands to list exported symbols.
15.13011 +export_symbols_cmds=$lt_export_symbols_cmds
15.13012 +
15.13013 +# Symbols that should not be listed in the preloaded symbols.
15.13014 +exclude_expsyms=$lt_exclude_expsyms
15.13015 +
15.13016 +# Symbols that must always be exported.
15.13017 +include_expsyms=$lt_include_expsyms
15.13018 +
15.13019 +# Commands necessary for linking programs (against libraries) with templates.
15.13020 +prelink_cmds=$lt_prelink_cmds
15.13021 +
15.13022 +# Specify filename containing input files.
15.13023 +file_list_spec=$lt_file_list_spec
15.13024 +
15.13025 +# How to hardcode a shared library path into an executable.
15.13026 +hardcode_action=$hardcode_action
15.13027 +
15.13028 +# ### END LIBTOOL CONFIG
15.13029 +
15.13030 +_LT_EOF
15.13031 +
15.13032 +  case $host_os in
15.13033 +  aix3*)
15.13034 +    cat <<\_LT_EOF >> "$cfgfile"
15.13035 +# AIX sometimes has problems with the GCC collect2 program.  For some
15.13036 +# reason, if we set the COLLECT_NAMES environment variable, the problems
15.13037 +# vanish in a puff of smoke.
15.13038 +if test "X${COLLECT_NAMES+set}" != Xset; then
15.13039 +  COLLECT_NAMES=
15.13040 +  export COLLECT_NAMES
15.13041 +fi
15.13042 +_LT_EOF
15.13043 +    ;;
15.13044 +  esac
15.13045 +
15.13046 +
15.13047 +ltmain="$ac_aux_dir/ltmain.sh"
15.13048 +
15.13049 +
15.13050 +  # We use sed instead of cat because bash on DJGPP gets confused if
15.13051 +  # if finds mixed CR/LF and LF-only lines.  Since sed operates in
15.13052 +  # text mode, it properly converts lines to CR/LF.  This bash problem
15.13053 +  # is reportedly fixed, but why not run on old versions too?
15.13054 +  sed '/^# Generated shell functions inserted here/q' "$ltmain" >> "$cfgfile" \
15.13055 +    || (rm -f "$cfgfile"; exit 1)
15.13056 +
15.13057 +  case $xsi_shell in
15.13058 +  yes)
15.13059 +    cat << \_LT_EOF >> "$cfgfile"
15.13060 +
15.13061 +# func_dirname file append nondir_replacement
15.13062 +# Compute the dirname of FILE.  If nonempty, add APPEND to the result,
15.13063 +# otherwise set result to NONDIR_REPLACEMENT.
15.13064 +func_dirname ()
15.13065 +{
15.13066 +  case ${1} in
15.13067 +    */*) func_dirname_result="${1%/*}${2}" ;;
15.13068 +    *  ) func_dirname_result="${3}" ;;
15.13069 +  esac
15.13070 +}
15.13071 +
15.13072 +# func_basename file
15.13073 +func_basename ()
15.13074 +{
15.13075 +  func_basename_result="${1##*/}"
15.13076 +}
15.13077 +
15.13078 +# func_dirname_and_basename file append nondir_replacement
15.13079 +# perform func_basename and func_dirname in a single function
15.13080 +# call:
15.13081 +#   dirname:  Compute the dirname of FILE.  If nonempty,
15.13082 +#             add APPEND to the result, otherwise set result
15.13083 +#             to NONDIR_REPLACEMENT.
15.13084 +#             value returned in "$func_dirname_result"
15.13085 +#   basename: Compute filename of FILE.
15.13086 +#             value retuned in "$func_basename_result"
15.13087 +# Implementation must be kept synchronized with func_dirname
15.13088 +# and func_basename. For efficiency, we do not delegate to
15.13089 +# those functions but instead duplicate the functionality here.
15.13090 +func_dirname_and_basename ()
15.13091 +{
15.13092 +  case ${1} in
15.13093 +    */*) func_dirname_result="${1%/*}${2}" ;;
15.13094 +    *  ) func_dirname_result="${3}" ;;
15.13095 +  esac
15.13096 +  func_basename_result="${1##*/}"
15.13097 +}
15.13098 +
15.13099 +# func_stripname prefix suffix name
15.13100 +# strip PREFIX and SUFFIX off of NAME.
15.13101 +# PREFIX and SUFFIX must not contain globbing or regex special
15.13102 +# characters, hashes, percent signs, but SUFFIX may contain a leading
15.13103 +# dot (in which case that matches only a dot).
15.13104 +func_stripname ()
15.13105 +{
15.13106 +  # pdksh 5.2.14 does not do ${X%$Y} correctly if both X and Y are
15.13107 +  # positional parameters, so assign one to ordinary parameter first.
15.13108 +  func_stripname_result=${3}
15.13109 +  func_stripname_result=${func_stripname_result#"${1}"}
15.13110 +  func_stripname_result=${func_stripname_result%"${2}"}
15.13111 +}
15.13112 +
15.13113 +# func_opt_split
15.13114 +func_opt_split ()
15.13115 +{
15.13116 +  func_opt_split_opt=${1%%=*}
15.13117 +  func_opt_split_arg=${1#*=}
15.13118 +}
15.13119 +
15.13120 +# func_lo2o object
15.13121 +func_lo2o ()
15.13122 +{
15.13123 +  case ${1} in
15.13124 +    *.lo) func_lo2o_result=${1%.lo}.${objext} ;;
15.13125 +    *)    func_lo2o_result=${1} ;;
15.13126 +  esac
15.13127 +}
15.13128 +
15.13129 +# func_xform libobj-or-source
15.13130 +func_xform ()
15.13131 +{
15.13132 +  func_xform_result=${1%.*}.lo
15.13133 +}
15.13134 +
15.13135 +# func_arith arithmetic-term...
15.13136 +func_arith ()
15.13137 +{
15.13138 +  func_arith_result=$(( $* ))
15.13139 +}
15.13140 +
15.13141 +# func_len string
15.13142 +# STRING may not start with a hyphen.
15.13143 +func_len ()
15.13144 +{
15.13145 +  func_len_result=${#1}
15.13146 +}
15.13147 +
15.13148 +_LT_EOF
15.13149 +    ;;
15.13150 +  *) # Bourne compatible functions.
15.13151 +    cat << \_LT_EOF >> "$cfgfile"
15.13152 +
15.13153 +# func_dirname file append nondir_replacement
15.13154 +# Compute the dirname of FILE.  If nonempty, add APPEND to the result,
15.13155 +# otherwise set result to NONDIR_REPLACEMENT.
15.13156 +func_dirname ()
15.13157 +{
15.13158 +  # Extract subdirectory from the argument.
15.13159 +  func_dirname_result=`$ECHO "${1}" | $SED "$dirname"`
15.13160 +  if test "X$func_dirname_result" = "X${1}"; then
15.13161 +    func_dirname_result="${3}"
15.13162 +  else
15.13163 +    func_dirname_result="$func_dirname_result${2}"
15.13164 +  fi
15.13165 +}
15.13166 +
15.13167 +# func_basename file
15.13168 +func_basename ()
15.13169 +{
15.13170 +  func_basename_result=`$ECHO "${1}" | $SED "$basename"`
15.13171 +}
15.13172 +
15.13173 +
15.13174 +# func_stripname prefix suffix name
15.13175 +# strip PREFIX and SUFFIX off of NAME.
15.13176 +# PREFIX and SUFFIX must not contain globbing or regex special
15.13177 +# characters, hashes, percent signs, but SUFFIX may contain a leading
15.13178 +# dot (in which case that matches only a dot).
15.13179 +# func_strip_suffix prefix name
15.13180 +func_stripname ()
15.13181 +{
15.13182 +  case ${2} in
15.13183 +    .*) func_stripname_result=`$ECHO "${3}" | $SED "s%^${1}%%; s%\\\\${2}\$%%"`;;
15.13184 +    *)  func_stripname_result=`$ECHO "${3}" | $SED "s%^${1}%%; s%${2}\$%%"`;;
15.13185 +  esac
15.13186 +}
15.13187 +
15.13188 +# sed scripts:
15.13189 +my_sed_long_opt='1s/^\(-[^=]*\)=.*/\1/;q'
15.13190 +my_sed_long_arg='1s/^-[^=]*=//'
15.13191 +
15.13192 +# func_opt_split
15.13193 +func_opt_split ()
15.13194 +{
15.13195 +  func_opt_split_opt=`$ECHO "${1}" | $SED "$my_sed_long_opt"`
15.13196 +  func_opt_split_arg=`$ECHO "${1}" | $SED "$my_sed_long_arg"`
15.13197 +}
15.13198 +
15.13199 +# func_lo2o object
15.13200 +func_lo2o ()
15.13201 +{
15.13202 +  func_lo2o_result=`$ECHO "${1}" | $SED "$lo2o"`
15.13203 +}
15.13204 +
15.13205 +# func_xform libobj-or-source
15.13206 +func_xform ()
15.13207 +{
15.13208 +  func_xform_result=`$ECHO "${1}" | $SED 's/\.[^.]*$/.lo/'`
15.13209 +}
15.13210 +
15.13211 +# func_arith arithmetic-term...
15.13212 +func_arith ()
15.13213 +{
15.13214 +  func_arith_result=`expr "$@"`
15.13215 +}
15.13216 +
15.13217 +# func_len string
15.13218 +# STRING may not start with a hyphen.
15.13219 +func_len ()
15.13220 +{
15.13221 +  func_len_result=`expr "$1" : ".*" 2>/dev/null || echo $max_cmd_len`
15.13222 +}
15.13223 +
15.13224 +_LT_EOF
15.13225 +esac
15.13226 +
15.13227 +case $lt_shell_append in
15.13228 +  yes)
15.13229 +    cat << \_LT_EOF >> "$cfgfile"
15.13230 +
15.13231 +# func_append var value
15.13232 +# Append VALUE to the end of shell variable VAR.
15.13233 +func_append ()
15.13234 +{
15.13235 +  eval "$1+=\$2"
15.13236 +}
15.13237 +_LT_EOF
15.13238 +    ;;
15.13239 +  *)
15.13240 +    cat << \_LT_EOF >> "$cfgfile"
15.13241 +
15.13242 +# func_append var value
15.13243 +# Append VALUE to the end of shell variable VAR.
15.13244 +func_append ()
15.13245 +{
15.13246 +  eval "$1=\$$1\$2"
15.13247 +}
15.13248 +
15.13249 +_LT_EOF
15.13250 +    ;;
15.13251 +  esac
15.13252 +
15.13253 +
15.13254 +  sed -n '/^# Generated shell functions inserted here/,$p' "$ltmain" >> "$cfgfile" \
15.13255 +    || (rm -f "$cfgfile"; exit 1)
15.13256 +
15.13257 +  mv -f "$cfgfile" "$ofile" ||
15.13258 +    (rm -f "$ofile" && cp "$cfgfile" "$ofile" && rm -f "$cfgfile")
15.13259 +  chmod +x "$ofile"
15.13260 +
15.13261 + ;;
15.13262 +
15.13263 +  esac
15.13264 +done # for ac_tag
15.13265 +
15.13266 +
15.13267 +as_fn_exit 0
15.13268 +_ACEOF
15.13269 +ac_clean_files=$ac_clean_files_save
15.13270 +
15.13271 +test $ac_write_fail = 0 ||
15.13272 +  as_fn_error "write failure creating $CONFIG_STATUS" "$LINENO" 5
15.13273 +
15.13274 +
15.13275 +# configure is writing to config.log, and then calls config.status.
15.13276 +# config.status does its own redirection, appending to config.log.
15.13277 +# Unfortunately, on DOS this fails, as config.log is still kept open
15.13278 +# by configure, so config.status won't be able to write to it; its
15.13279 +# output is simply discarded.  So we exec the FD to /dev/null,
15.13280 +# effectively closing config.log, so it can be properly (re)opened and
15.13281 +# appended to by config.status.  When coming back to configure, we
15.13282 +# need to make the FD available again.
15.13283 +if test "$no_create" != yes; then
15.13284 +  ac_cs_success=:
15.13285 +  ac_config_status_args=
15.13286 +  test "$silent" = yes &&
15.13287 +    ac_config_status_args="$ac_config_status_args --quiet"
15.13288 +  exec 5>/dev/null
15.13289 +  $SHELL $CONFIG_STATUS $ac_config_status_args || ac_cs_success=false
15.13290 +  exec 5>>config.log
15.13291 +  # Use ||, not &&, to avoid exiting from the if with $? = 1, which
15.13292 +  # would make configure fail if this is the last instruction.
15.13293 +  $ac_cs_success || as_fn_exit $?
15.13294 +fi
15.13295 +if test -n "$ac_unrecognized_opts" && test "$enable_option_checking" != no; then
15.13296 +  { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: unrecognized options: $ac_unrecognized_opts" >&5
15.13297 +$as_echo "$as_me: WARNING: unrecognized options: $ac_unrecognized_opts" >&2;}
15.13298 +fi
15.13299 +
15.13300 +
    16.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    16.2 +++ b/deps/glpk/configure.ac	Sun Nov 06 20:59:10 2011 +0100
    16.3 @@ -0,0 +1,141 @@
    16.4 +dnl Process this file with autoconf to produce a configure script
    16.5 +
    16.6 +AC_INIT([GLPK], [4.47], [bug-glpk@gnu.org])
    16.7 +
    16.8 +AC_CONFIG_SRCDIR([src/glpk.h])
    16.9 +
   16.10 +AC_CONFIG_MACRO_DIR([m4])
   16.11 +
   16.12 +AM_INIT_AUTOMAKE
   16.13 +
   16.14 +AC_CONFIG_HEADERS([config.h])
   16.15 +
   16.16 +AC_ARG_WITH(gmp,
   16.17 +AC_HELP_STRING([--with-gmp],
   16.18 +   [use GNU MP bignum library [[default=no]]]),
   16.19 +   [case $withval in
   16.20 +      yes | no) ;;
   16.21 +      *) AC_MSG_ERROR([invalid value `$withval' for --with-gmp]);;
   16.22 +      esac],
   16.23 +   [with_gmp=no])
   16.24 +
   16.25 +AC_ARG_ENABLE(dl,
   16.26 +AC_HELP_STRING([--enable-dl],
   16.27 +   [enable shared library support [[default=no]]]),
   16.28 +   [case $enableval in
   16.29 +      yes | ltdl | dlfcn | no) ;;
   16.30 +      *) AC_MSG_ERROR([invalid value `$enableval' for --enable-dl]);;
   16.31 +      esac],
   16.32 +   [enable_dl=no])
   16.33 +
   16.34 +AC_ARG_ENABLE(odbc,
   16.35 +AC_HELP_STRING([--enable-odbc],
   16.36 +   [enable MathProg ODBC support [[default=no]]]),
   16.37 +   [case $enableval in
   16.38 +      yes | unix | no) ;;
   16.39 +      *) AC_MSG_ERROR([invalid value `$enableval' for --enable-odbc]);;
   16.40 +      esac],
   16.41 +   [enable_odbc=no])
   16.42 +
   16.43 +AC_ARG_ENABLE(mysql,
   16.44 +AC_HELP_STRING([--enable-mysql],
   16.45 +   [enable MathProg MySQL support [[default=no]]]),
   16.46 +   [case $enableval in
   16.47 +      yes | no) ;;
   16.48 +      *) AC_MSG_ERROR([invalid value `$enableval' for --enable-mysql]);;
   16.49 +      esac],
   16.50 +   [enable_mysql=no])
   16.51 +
   16.52 +dnl Disable unnecessary libtool tests
   16.53 +define([AC_LIBTOOL_LANG_CXX_CONFIG], [:])
   16.54 +define([AC_LIBTOOL_LANG_F77_CONFIG], [:])
   16.55 +define([AC_LIBTOOL_LANG_GCJ_CONFIG], [:])
   16.56 +
   16.57 +dnl Check for programs
   16.58 +AC_PROG_CC
   16.59 +AC_PROG_INSTALL
   16.60 +AC_PROG_LIBTOOL
   16.61 +
   16.62 +dnl Check for math library
   16.63 +AC_CHECK_LIB([m], [exp])
   16.64 +
   16.65 +dnl Check for <sys/time.h> header
   16.66 +AC_CHECK_HEADER([sys/time.h],
   16.67 +   AC_DEFINE([HAVE_SYS_TIME_H], [1], [N/A]))
   16.68 +
   16.69 +dnl Check for gettimeofday function
   16.70 +AC_CHECK_FUNC([gettimeofday],
   16.71 +   AC_DEFINE([HAVE_GETTIMEOFDAY], [1], [N/A]))
   16.72 +
   16.73 +AC_MSG_CHECKING([whether to use GNU MP bignum library])
   16.74 +if test "$with_gmp" = "yes"; then
   16.75 +   AC_MSG_RESULT([yes])
   16.76 +   AC_DEFINE([HAVE_GMP], [1], [N/A])
   16.77 +   LIBS="-lgmp $LIBS"
   16.78 +else
   16.79 +   AC_MSG_RESULT([no])
   16.80 +fi
   16.81 +
   16.82 +AC_MSG_CHECKING([whether to enable shared library support])
   16.83 +if test "$enable_dl" = "yes"; then
   16.84 +   AC_MSG_RESULT([ltdl])
   16.85 +   AC_DEFINE([HAVE_LTDL], [1], [N/A])
   16.86 +   LIBS="-lltdl $LIBS"
   16.87 +elif test "$enable_dl" = "ltdl"; then
   16.88 +   AC_MSG_RESULT([ltdl])
   16.89 +   AC_DEFINE([HAVE_LTDL], [1], [N/A])
   16.90 +   LIBS="-lltdl $LIBS"
   16.91 +elif test "$enable_dl" = "dlfcn"; then
   16.92 +   AC_MSG_RESULT([dlfcn])
   16.93 +   AC_DEFINE([HAVE_DLFCN], [1], [N/A])
   16.94 +else
   16.95 +   AC_MSG_RESULT([no])
   16.96 +fi
   16.97 +
   16.98 +case $host_os in
   16.99 +   darwin* | macosx*)
  16.100 +      LIBIODBC="libiodbc.dylib"
  16.101 +      LIBODBC="libodbc.dylib"
  16.102 +      LIBMYSQL="libmysqlclient.dylib"
  16.103 +      ;;
  16.104 +   *)
  16.105 +      LIBIODBC="libiodbc.so"
  16.106 +      LIBODBC="libodbc.so"
  16.107 +      LIBMYSQL="libmysqlclient.so"
  16.108 +      ;;
  16.109 +esac
  16.110 +
  16.111 +AC_MSG_CHECKING([whether to enable MathProg ODBC support])
  16.112 +if test "$enable_odbc" = "yes"; then
  16.113 +   if test "$enable_dl" = "no"; then
  16.114 +      AC_MSG_ERROR([--enable-odbc requires --enable-dl])
  16.115 +   fi
  16.116 +   AC_MSG_RESULT([yes])
  16.117 +   AC_DEFINE_UNQUOTED([ODBC_DLNAME], ["$LIBIODBC"], [N/A])
  16.118 +elif test "$enable_odbc" = "unix"; then
  16.119 +   if test "$enable_dl" = "no"; then
  16.120 +      AC_MSG_ERROR([--enable-odbc requires --enable-dl])
  16.121 +   fi
  16.122 +   AC_MSG_RESULT([unix])
  16.123 +   AC_DEFINE_UNQUOTED([ODBC_DLNAME], ["$LIBODBC"], [N/A])
  16.124 +else
  16.125 +   AC_MSG_RESULT([no])
  16.126 +fi
  16.127 +
  16.128 +AC_MSG_CHECKING([whether to enable MathProg MySQL support])
  16.129 +if test "$enable_mysql" = "yes"; then
  16.130 +   if test "$enable_dl" = "no"; then
  16.131 +      AC_MSG_ERROR([--enable-mysql requires --enable-dl])
  16.132 +   fi
  16.133 +   AC_MSG_RESULT([yes])
  16.134 +   CPPFLAGS="-I/usr/include/mysql $CPPFLAGS"
  16.135 +   AC_DEFINE_UNQUOTED([MYSQL_DLNAME], ["$LIBMYSQL"], [N/A])
  16.136 +else
  16.137 +   AC_MSG_RESULT([no])
  16.138 +fi
  16.139 +
  16.140 +AC_CONFIG_FILES(
  16.141 +   [src/Makefile examples/Makefile Makefile])
  16.142 +AC_OUTPUT
  16.143 +
  16.144 +dnl eof
    17.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    17.2 +++ b/deps/glpk/depcomp	Sun Nov 06 20:59:10 2011 +0100
    17.3 @@ -0,0 +1,630 @@
    17.4 +#! /bin/sh
    17.5 +# depcomp - compile a program generating dependencies as side-effects
    17.6 +
    17.7 +scriptversion=2009-04-28.21; # UTC
    17.8 +
    17.9 +# Copyright (C) 1999, 2000, 2003, 2004, 2005, 2006, 2007, 2009 Free
   17.10 +# Software Foundation, Inc.
   17.11 +
   17.12 +# This program is free software; you can redistribute it and/or modify
   17.13 +# it under the terms of the GNU General Public License as published by
   17.14 +# the Free Software Foundation; either version 2, or (at your option)
   17.15 +# any later version.
   17.16 +
   17.17 +# This program is distributed in the hope that it will be useful,
   17.18 +# but WITHOUT ANY WARRANTY; without even the implied warranty of
   17.19 +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   17.20 +# GNU General Public License for more details.
   17.21 +
   17.22 +# You should have received a copy of the GNU General Public License
   17.23 +# along with this program.  If not, see <http://www.gnu.org/licenses/>.
   17.24 +
   17.25 +# As a special exception to the GNU General Public License, if you
   17.26 +# distribute this file as part of a program that contains a
   17.27 +# configuration script generated by Autoconf, you may include it under
   17.28 +# the same distribution terms that you use for the rest of that program.
   17.29 +
   17.30 +# Originally written by Alexandre Oliva <oliva@dcc.unicamp.br>.
   17.31 +
   17.32 +case $1 in
   17.33 +  '')
   17.34 +     echo "$0: No command.  Try \`$0 --help' for more information." 1>&2
   17.35 +     exit 1;
   17.36 +     ;;
   17.37 +  -h | --h*)
   17.38 +    cat <<\EOF
   17.39 +Usage: depcomp [--help] [--version] PROGRAM [ARGS]
   17.40 +
   17.41 +Run PROGRAMS ARGS to compile a file, generating dependencies
   17.42 +as side-effects.
   17.43 +
   17.44 +Environment variables:
   17.45 +  depmode     Dependency tracking mode.
   17.46 +  source      Source file read by `PROGRAMS ARGS'.
   17.47 +  object      Object file output by `PROGRAMS ARGS'.
   17.48 +  DEPDIR      directory where to store dependencies.
   17.49 +  depfile     Dependency file to output.
   17.50 +  tmpdepfile  Temporary file to use when outputing dependencies.
   17.51 +  libtool     Whether libtool is used (yes/no).
   17.52 +
   17.53 +Report bugs to <bug-automake@gnu.org>.
   17.54 +EOF
   17.55 +    exit $?
   17.56 +    ;;
   17.57 +  -v | --v*)
   17.58 +    echo "depcomp $scriptversion"
   17.59 +    exit $?
   17.60 +    ;;
   17.61 +esac
   17.62 +
   17.63 +if test -z "$depmode" || test -z "$source" || test -z "$object"; then
   17.64 +  echo "depcomp: Variables source, object and depmode must be set" 1>&2
   17.65 +  exit 1
   17.66 +fi
   17.67 +
   17.68 +# Dependencies for sub/bar.o or sub/bar.obj go into sub/.deps/bar.Po.
   17.69 +depfile=${depfile-`echo "$object" |
   17.70 +  sed 's|[^\\/]*$|'${DEPDIR-.deps}'/&|;s|\.\([^.]*\)$|.P\1|;s|Pobj$|Po|'`}
   17.71 +tmpdepfile=${tmpdepfile-`echo "$depfile" | sed 's/\.\([^.]*\)$/.T\1/'`}
   17.72 +
   17.73 +rm -f "$tmpdepfile"
   17.74 +
   17.75 +# Some modes work just like other modes, but use different flags.  We
   17.76 +# parameterize here, but still list the modes in the big case below,
   17.77 +# to make depend.m4 easier to write.  Note that we *cannot* use a case
   17.78 +# here, because this file can only contain one case statement.
   17.79 +if test "$depmode" = hp; then
   17.80 +  # HP compiler uses -M and no extra arg.
   17.81 +  gccflag=-M
   17.82 +  depmode=gcc
   17.83 +fi
   17.84 +
   17.85 +if test "$depmode" = dashXmstdout; then
   17.86 +   # This is just like dashmstdout with a different argument.
   17.87 +   dashmflag=-xM
   17.88 +   depmode=dashmstdout
   17.89 +fi
   17.90 +
   17.91 +cygpath_u="cygpath -u -f -"
   17.92 +if test "$depmode" = msvcmsys; then
   17.93 +   # This is just like msvisualcpp but w/o cygpath translation.
   17.94 +   # Just convert the backslash-escaped backslashes to single forward
   17.95 +   # slashes to satisfy depend.m4
   17.96 +   cygpath_u="sed s,\\\\\\\\,/,g"
   17.97 +   depmode=msvisualcpp
   17.98 +fi
   17.99 +
  17.100 +case "$depmode" in
  17.101 +gcc3)
  17.102 +## gcc 3 implements dependency tracking that does exactly what
  17.103 +## we want.  Yay!  Note: for some reason libtool 1.4 doesn't like
  17.104 +## it if -MD -MP comes after the -MF stuff.  Hmm.
  17.105 +## Unfortunately, FreeBSD c89 acceptance of flags depends upon
  17.106 +## the command line argument order; so add the flags where they
  17.107 +## appear in depend2.am.  Note that the slowdown incurred here
  17.108 +## affects only configure: in makefiles, %FASTDEP% shortcuts this.
  17.109 +  for arg
  17.110 +  do
  17.111 +    case $arg in
  17.112 +    -c) set fnord "$@" -MT "$object" -MD -MP -MF "$tmpdepfile" "$arg" ;;
  17.113 +    *)  set fnord "$@" "$arg" ;;
  17.114 +    esac
  17.115 +    shift # fnord
  17.116 +    shift # $arg
  17.117 +  done
  17.118 +  "$@"
  17.119 +  stat=$?
  17.120 +  if test $stat -eq 0; then :
  17.121 +  else
  17.122 +    rm -f "$tmpdepfile"
  17.123 +    exit $stat
  17.124 +  fi
  17.125 +  mv "$tmpdepfile" "$depfile"
  17.126 +  ;;
  17.127 +
  17.128 +gcc)
  17.129 +## There are various ways to get dependency output from gcc.  Here's
  17.130 +## why we pick this rather obscure method:
  17.131 +## - Don't want to use -MD because we'd like the dependencies to end
  17.132 +##   up in a subdir.  Having to rename by hand is ugly.
  17.133 +##   (We might end up doing this anyway to support other compilers.)
  17.134 +## - The DEPENDENCIES_OUTPUT environment variable makes gcc act like
  17.135 +##   -MM, not -M (despite what the docs say).
  17.136 +## - Using -M directly means running the compiler twice (even worse
  17.137 +##   than renaming).
  17.138 +  if test -z "$gccflag"; then
  17.139 +    gccflag=-MD,
  17.140 +  fi
  17.141 +  "$@" -Wp,"$gccflag$tmpdepfile"
  17.142 +  stat=$?
  17.143 +  if test $stat -eq 0; then :
  17.144 +  else
  17.145 +    rm -f "$tmpdepfile"
  17.146 +    exit $stat
  17.147 +  fi
  17.148 +  rm -f "$depfile"
  17.149 +  echo "$object : \\" > "$depfile"
  17.150 +  alpha=ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz
  17.151 +## The second -e expression handles DOS-style file names with drive letters.
  17.152 +  sed -e 's/^[^:]*: / /' \
  17.153 +      -e 's/^['$alpha']:\/[^:]*: / /' < "$tmpdepfile" >> "$depfile"
  17.154 +## This next piece of magic avoids the `deleted header file' problem.
  17.155 +## The problem is that when a header file which appears in a .P file
  17.156 +## is deleted, the dependency causes make to die (because there is
  17.157 +## typically no way to rebuild the header).  We avoid this by adding
  17.158 +## dummy dependencies for each header file.  Too bad gcc doesn't do
  17.159 +## this for us directly.
  17.160 +  tr ' ' '
  17.161 +' < "$tmpdepfile" |
  17.162 +## Some versions of gcc put a space before the `:'.  On the theory
  17.163 +## that the space means something, we add a space to the output as
  17.164 +## well.
  17.165 +## Some versions of the HPUX 10.20 sed can't process this invocation
  17.166 +## correctly.  Breaking it into two sed invocations is a workaround.
  17.167 +    sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile"
  17.168 +  rm -f "$tmpdepfile"
  17.169 +  ;;
  17.170 +
  17.171 +hp)
  17.172 +  # This case exists only to let depend.m4 do its work.  It works by
  17.173 +  # looking at the text of this script.  This case will never be run,
  17.174 +  # since it is checked for above.
  17.175 +  exit 1
  17.176 +  ;;
  17.177 +
  17.178 +sgi)
  17.179 +  if test "$libtool" = yes; then
  17.180 +    "$@" "-Wp,-MDupdate,$tmpdepfile"
  17.181 +  else
  17.182 +    "$@" -MDupdate "$tmpdepfile"
  17.183 +  fi
  17.184 +  stat=$?
  17.185 +  if test $stat -eq 0; then :
  17.186 +  else
  17.187 +    rm -f "$tmpdepfile"
  17.188 +    exit $stat
  17.189 +  fi
  17.190 +  rm -f "$depfile"
  17.191 +
  17.192 +  if test -f "$tmpdepfile"; then  # yes, the sourcefile depend on other files
  17.193 +    echo "$object : \\" > "$depfile"
  17.194 +
  17.195 +    # Clip off the initial element (the dependent).  Don't try to be
  17.196 +    # clever and replace this with sed code, as IRIX sed won't handle
  17.197 +    # lines with more than a fixed number of characters (4096 in
  17.198 +    # IRIX 6.2 sed, 8192 in IRIX 6.5).  We also remove comment lines;
  17.199 +    # the IRIX cc adds comments like `#:fec' to the end of the
  17.200 +    # dependency line.
  17.201 +    tr ' ' '
  17.202 +' < "$tmpdepfile" \
  17.203 +    | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' | \
  17.204 +    tr '
  17.205 +' ' ' >> "$depfile"
  17.206 +    echo >> "$depfile"
  17.207 +
  17.208 +    # The second pass generates a dummy entry for each header file.
  17.209 +    tr ' ' '
  17.210 +' < "$tmpdepfile" \
  17.211 +   | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' -e 's/$/:/' \
  17.212 +   >> "$depfile"
  17.213 +  else
  17.214 +    # The sourcefile does not contain any dependencies, so just
  17.215 +    # store a dummy comment line, to avoid errors with the Makefile
  17.216 +    # "include basename.Plo" scheme.
  17.217 +    echo "#dummy" > "$depfile"
  17.218 +  fi
  17.219 +  rm -f "$tmpdepfile"
  17.220 +  ;;
  17.221 +
  17.222 +aix)
  17.223 +  # The C for AIX Compiler uses -M and outputs the dependencies
  17.224 +  # in a .u file.  In older versions, this file always lives in the
  17.225 +  # current directory.  Also, the AIX compiler puts `$object:' at the
  17.226 +  # start of each line; $object doesn't have directory information.
  17.227 +  # Version 6 uses the directory in both cases.
  17.228 +  dir=`echo "$object" | sed -e 's|/[^/]*$|/|'`
  17.229 +  test "x$dir" = "x$object" && dir=
  17.230 +  base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'`
  17.231 +  if test "$libtool" = yes; then
  17.232 +    tmpdepfile1=$dir$base.u
  17.233 +    tmpdepfile2=$base.u
  17.234 +    tmpdepfile3=$dir.libs/$base.u
  17.235 +    "$@" -Wc,-M
  17.236 +  else
  17.237 +    tmpdepfile1=$dir$base.u
  17.238 +    tmpdepfile2=$dir$base.u
  17.239 +    tmpdepfile3=$dir$base.u
  17.240 +    "$@" -M
  17.241 +  fi
  17.242 +  stat=$?
  17.243 +
  17.244 +  if test $stat -eq 0; then :
  17.245 +  else
  17.246 +    rm -f "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3"
  17.247 +    exit $stat
  17.248 +  fi
  17.249 +
  17.250 +  for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3"
  17.251 +  do
  17.252 +    test -f "$tmpdepfile" && break
  17.253 +  done
  17.254 +  if test -f "$tmpdepfile"; then
  17.255 +    # Each line is of the form `foo.o: dependent.h'.
  17.256 +    # Do two passes, one to just change these to
  17.257 +    # `$object: dependent.h' and one to simply `dependent.h:'.
  17.258 +    sed -e "s,^.*\.[a-z]*:,$object:," < "$tmpdepfile" > "$depfile"
  17.259 +    # That's a tab and a space in the [].
  17.260 +    sed -e 's,^.*\.[a-z]*:[	 ]*,,' -e 's,$,:,' < "$tmpdepfile" >> "$depfile"
  17.261 +  else
  17.262 +    # The sourcefile does not contain any dependencies, so just
  17.263 +    # store a dummy comment line, to avoid errors with the Makefile
  17.264 +    # "include basename.Plo" scheme.
  17.265 +    echo "#dummy" > "$depfile"
  17.266 +  fi
  17.267 +  rm -f "$tmpdepfile"
  17.268 +  ;;
  17.269 +
  17.270 +icc)
  17.271 +  # Intel's C compiler understands `-MD -MF file'.  However on
  17.272 +  #    icc -MD -MF foo.d -c -o sub/foo.o sub/foo.c
  17.273 +  # ICC 7.0 will fill foo.d with something like
  17.274 +  #    foo.o: sub/foo.c
  17.275 +  #    foo.o: sub/foo.h
  17.276 +  # which is wrong.  We want:
  17.277 +  #    sub/foo.o: sub/foo.c
  17.278 +  #    sub/foo.o: sub/foo.h
  17.279 +  #    sub/foo.c:
  17.280 +  #    sub/foo.h:
  17.281 +  # ICC 7.1 will output
  17.282 +  #    foo.o: sub/foo.c sub/foo.h
  17.283 +  # and will wrap long lines using \ :
  17.284 +  #    foo.o: sub/foo.c ... \
  17.285 +  #     sub/foo.h ... \
  17.286 +  #     ...
  17.287 +
  17.288 +  "$@" -MD -MF "$tmpdepfile"
  17.289 +  stat=$?
  17.290 +  if test $stat -eq 0; then :
  17.291 +  else
  17.292 +    rm -f "$tmpdepfile"
  17.293 +    exit $stat
  17.294 +  fi
  17.295 +  rm -f "$depfile"
  17.296 +  # Each line is of the form `foo.o: dependent.h',
  17.297 +  # or `foo.o: dep1.h dep2.h \', or ` dep3.h dep4.h \'.
  17.298 +  # Do two passes, one to just change these to
  17.299 +  # `$object: dependent.h' and one to simply `dependent.h:'.
  17.300 +  sed "s,^[^:]*:,$object :," < "$tmpdepfile" > "$depfile"
  17.301 +  # Some versions of the HPUX 10.20 sed can't process this invocation
  17.302 +  # correctly.  Breaking it into two sed invocations is a workaround.
  17.303 +  sed 's,^[^:]*: \(.*\)$,\1,;s/^\\$//;/^$/d;/:$/d' < "$tmpdepfile" |
  17.304 +    sed -e 's/$/ :/' >> "$depfile"
  17.305 +  rm -f "$tmpdepfile"
  17.306 +  ;;
  17.307 +
  17.308 +hp2)
  17.309 +  # The "hp" stanza above does not work with aCC (C++) and HP's ia64
  17.310 +  # compilers, which have integrated preprocessors.  The correct option
  17.311 +  # to use with these is +Maked; it writes dependencies to a file named
  17.312 +  # 'foo.d', which lands next to the object file, wherever that
  17.313 +  # happens to be.
  17.314 +  # Much of this is similar to the tru64 case; see comments there.
  17.315 +  dir=`echo "$object" | sed -e 's|/[^/]*$|/|'`
  17.316 +  test "x$dir" = "x$object" && dir=
  17.317 +  base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'`
  17.318 +  if test "$libtool" = yes; then
  17.319 +    tmpdepfile1=$dir$base.d
  17.320 +    tmpdepfile2=$dir.libs/$base.d
  17.321 +    "$@" -Wc,+Maked
  17.322 +  else
  17.323 +    tmpdepfile1=$dir$base.d
  17.324 +    tmpdepfile2=$dir$base.d
  17.325 +    "$@" +Maked
  17.326 +  fi
  17.327 +  stat=$?
  17.328 +  if test $stat -eq 0; then :
  17.329 +  else
  17.330 +     rm -f "$tmpdepfile1" "$tmpdepfile2"
  17.331 +     exit $stat
  17.332 +  fi
  17.333 +
  17.334 +  for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2"
  17.335 +  do
  17.336 +    test -f "$tmpdepfile" && break
  17.337 +  done
  17.338 +  if test -f "$tmpdepfile"; then
  17.339 +    sed -e "s,^.*\.[a-z]*:,$object:," "$tmpdepfile" > "$depfile"
  17.340 +    # Add `dependent.h:' lines.
  17.341 +    sed -ne '2,${
  17.342 +	       s/^ *//
  17.343 +	       s/ \\*$//
  17.344 +	       s/$/:/
  17.345 +	       p
  17.346 +	     }' "$tmpdepfile" >> "$depfile"
  17.347 +  else
  17.348 +    echo "#dummy" > "$depfile"
  17.349 +  fi
  17.350 +  rm -f "$tmpdepfile" "$tmpdepfile2"
  17.351 +  ;;
  17.352 +
  17.353 +tru64)
  17.354 +   # The Tru64 compiler uses -MD to generate dependencies as a side
  17.355 +   # effect.  `cc -MD -o foo.o ...' puts the dependencies into `foo.o.d'.
  17.356 +   # At least on Alpha/Redhat 6.1, Compaq CCC V6.2-504 seems to put
  17.357 +   # dependencies in `foo.d' instead, so we check for that too.
  17.358 +   # Subdirectories are respected.
  17.359 +   dir=`echo "$object" | sed -e 's|/[^/]*$|/|'`
  17.360 +   test "x$dir" = "x$object" && dir=
  17.361 +   base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'`
  17.362 +
  17.363 +   if test "$libtool" = yes; then
  17.364 +      # With Tru64 cc, shared objects can also be used to make a
  17.365 +      # static library.  This mechanism is used in libtool 1.4 series to
  17.366 +      # handle both shared and static libraries in a single compilation.
  17.367 +      # With libtool 1.4, dependencies were output in $dir.libs/$base.lo.d.
  17.368 +      #
  17.369 +      # With libtool 1.5 this exception was removed, and libtool now
  17.370 +      # generates 2 separate objects for the 2 libraries.  These two
  17.371 +      # compilations output dependencies in $dir.libs/$base.o.d and
  17.372 +      # in $dir$base.o.d.  We have to check for both files, because
  17.373 +      # one of the two compilations can be disabled.  We should prefer
  17.374 +      # $dir$base.o.d over $dir.libs/$base.o.d because the latter is
  17.375 +      # automatically cleaned when .libs/ is deleted, while ignoring
  17.376 +      # the former would cause a distcleancheck panic.
  17.377 +      tmpdepfile1=$dir.libs/$base.lo.d   # libtool 1.4
  17.378 +      tmpdepfile2=$dir$base.o.d          # libtool 1.5
  17.379 +      tmpdepfile3=$dir.libs/$base.o.d    # libtool 1.5
  17.380 +      tmpdepfile4=$dir.libs/$base.d      # Compaq CCC V6.2-504
  17.381 +      "$@" -Wc,-MD
  17.382 +   else
  17.383 +      tmpdepfile1=$dir$base.o.d
  17.384 +      tmpdepfile2=$dir$base.d
  17.385 +      tmpdepfile3=$dir$base.d
  17.386 +      tmpdepfile4=$dir$base.d
  17.387 +      "$@" -MD
  17.388 +   fi
  17.389 +
  17.390 +   stat=$?
  17.391 +   if test $stat -eq 0; then :
  17.392 +   else
  17.393 +      rm -f "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" "$tmpdepfile4"
  17.394 +      exit $stat
  17.395 +   fi
  17.396 +
  17.397 +   for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" "$tmpdepfile4"
  17.398 +   do
  17.399 +     test -f "$tmpdepfile" && break
  17.400 +   done
  17.401 +   if test -f "$tmpdepfile"; then
  17.402 +      sed -e "s,^.*\.[a-z]*:,$object:," < "$tmpdepfile" > "$depfile"
  17.403 +      # That's a tab and a space in the [].
  17.404 +      sed -e 's,^.*\.[a-z]*:[	 ]*,,' -e 's,$,:,' < "$tmpdepfile" >> "$depfile"
  17.405 +   else
  17.406 +      echo "#dummy" > "$depfile"
  17.407 +   fi
  17.408 +   rm -f "$tmpdepfile"
  17.409 +   ;;
  17.410 +
  17.411 +#nosideeffect)
  17.412 +  # This comment above is used by automake to tell side-effect
  17.413 +  # dependency tracking mechanisms from slower ones.
  17.414 +
  17.415 +dashmstdout)
  17.416 +  # Important note: in order to support this mode, a compiler *must*
  17.417 +  # always write the preprocessed file to stdout, regardless of -o.
  17.418 +  "$@" || exit $?
  17.419 +
  17.420 +  # Remove the call to Libtool.
  17.421 +  if test "$libtool" = yes; then
  17.422 +    while test "X$1" != 'X--mode=compile'; do
  17.423 +      shift
  17.424 +    done
  17.425 +    shift
  17.426 +  fi
  17.427 +
  17.428 +  # Remove `-o $object'.
  17.429 +  IFS=" "
  17.430 +  for arg
  17.431 +  do
  17.432 +    case $arg in
  17.433 +    -o)
  17.434 +      shift
  17.435 +      ;;
  17.436 +    $object)
  17.437 +      shift
  17.438 +      ;;
  17.439 +    *)
  17.440 +      set fnord "$@" "$arg"
  17.441 +      shift # fnord
  17.442 +      shift # $arg
  17.443 +      ;;
  17.444 +    esac
  17.445 +  done
  17.446 +
  17.447 +  test -z "$dashmflag" && dashmflag=-M
  17.448 +  # Require at least two characters before searching for `:'
  17.449 +  # in the target name.  This is to cope with DOS-style filenames:
  17.450 +  # a dependency such as `c:/foo/bar' could be seen as target `c' otherwise.
  17.451 +  "$@" $dashmflag |
  17.452 +    sed 's:^[  ]*[^: ][^:][^:]*\:[    ]*:'"$object"'\: :' > "$tmpdepfile"
  17.453 +  rm -f "$depfile"
  17.454 +  cat < "$tmpdepfile" > "$depfile"
  17.455 +  tr ' ' '
  17.456 +' < "$tmpdepfile" | \
  17.457 +## Some versions of the HPUX 10.20 sed can't process this invocation
  17.458 +## correctly.  Breaking it into two sed invocations is a workaround.
  17.459 +    sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile"
  17.460 +  rm -f "$tmpdepfile"
  17.461 +  ;;
  17.462 +
  17.463 +dashXmstdout)
  17.464 +  # This case only exists to satisfy depend.m4.  It is never actually
  17.465 +  # run, as this mode is specially recognized in the preamble.
  17.466 +  exit 1
  17.467 +  ;;
  17.468 +
  17.469 +makedepend)
  17.470 +  "$@" || exit $?
  17.471 +  # Remove any Libtool call
  17.472 +  if test "$libtool" = yes; then
  17.473 +    while test "X$1" != 'X--mode=compile'; do
  17.474 +      shift
  17.475 +    done
  17.476 +    shift
  17.477 +  fi
  17.478 +  # X makedepend
  17.479 +  shift
  17.480 +  cleared=no eat=no
  17.481 +  for arg
  17.482 +  do
  17.483 +    case $cleared in
  17.484 +    no)
  17.485 +      set ""; shift
  17.486 +      cleared=yes ;;
  17.487 +    esac
  17.488 +    if test $eat = yes; then
  17.489 +      eat=no
  17.490 +      continue
  17.491 +    fi
  17.492 +    case "$arg" in
  17.493 +    -D*|-I*)
  17.494 +      set fnord "$@" "$arg"; shift ;;
  17.495 +    # Strip any option that makedepend may not understand.  Remove
  17.496 +    # the object too, otherwise makedepend will parse it as a source file.
  17.497 +    -arch)
  17.498 +      eat=yes ;;
  17.499 +    -*|$object)
  17.500 +      ;;
  17.501 +    *)
  17.502 +      set fnord "$@" "$arg"; shift ;;
  17.503 +    esac
  17.504 +  done
  17.505 +  obj_suffix=`echo "$object" | sed 's/^.*\././'`
  17.506 +  touch "$tmpdepfile"
  17.507 +  ${MAKEDEPEND-makedepend} -o"$obj_suffix" -f"$tmpdepfile" "$@"
  17.508 +  rm -f "$depfile"
  17.509 +  cat < "$tmpdepfile" > "$depfile"
  17.510 +  sed '1,2d' "$tmpdepfile" | tr ' ' '
  17.511 +' | \
  17.512 +## Some versions of the HPUX 10.20 sed can't process this invocation
  17.513 +## correctly.  Breaking it into two sed invocations is a workaround.
  17.514 +    sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile"
  17.515 +  rm -f "$tmpdepfile" "$tmpdepfile".bak
  17.516 +  ;;
  17.517 +
  17.518 +cpp)
  17.519 +  # Important note: in order to support this mode, a compiler *must*
  17.520 +  # always write the preprocessed file to stdout.
  17.521 +  "$@" || exit $?
  17.522 +
  17.523 +  # Remove the call to Libtool.
  17.524 +  if test "$libtool" = yes; then
  17.525 +    while test "X$1" != 'X--mode=compile'; do
  17.526 +      shift
  17.527 +    done
  17.528 +    shift
  17.529 +  fi
  17.530 +
  17.531 +  # Remove `-o $object'.
  17.532 +  IFS=" "
  17.533 +  for arg
  17.534 +  do
  17.535 +    case $arg in
  17.536 +    -o)
  17.537 +      shift
  17.538 +      ;;
  17.539 +    $object)
  17.540 +      shift
  17.541 +      ;;
  17.542 +    *)
  17.543 +      set fnord "$@" "$arg"
  17.544 +      shift # fnord
  17.545 +      shift # $arg
  17.546 +      ;;
  17.547 +    esac
  17.548 +  done
  17.549 +
  17.550 +  "$@" -E |
  17.551 +    sed -n -e '/^# [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' \
  17.552 +       -e '/^#line [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' |
  17.553 +    sed '$ s: \\$::' > "$tmpdepfile"
  17.554 +  rm -f "$depfile"
  17.555 +  echo "$object : \\" > "$depfile"
  17.556 +  cat < "$tmpdepfile" >> "$depfile"
  17.557 +  sed < "$tmpdepfile" '/^$/d;s/^ //;s/ \\$//;s/$/ :/' >> "$depfile"
  17.558 +  rm -f "$tmpdepfile"
  17.559 +  ;;
  17.560 +
  17.561 +msvisualcpp)
  17.562 +  # Important note: in order to support this mode, a compiler *must*
  17.563 +  # always write the preprocessed file to stdout.
  17.564 +  "$@" || exit $?
  17.565 +
  17.566 +  # Remove the call to Libtool.
  17.567 +  if test "$libtool" = yes; then
  17.568 +    while test "X$1" != 'X--mode=compile'; do
  17.569 +      shift
  17.570 +    done
  17.571 +    shift
  17.572 +  fi
  17.573 +
  17.574 +  IFS=" "
  17.575 +  for arg
  17.576 +  do
  17.577 +    case "$arg" in
  17.578 +    -o)
  17.579 +      shift
  17.580 +      ;;
  17.581 +    $object)
  17.582 +      shift
  17.583 +      ;;
  17.584 +    "-Gm"|"/Gm"|"-Gi"|"/Gi"|"-ZI"|"/ZI")
  17.585 +	set fnord "$@"
  17.586 +	shift
  17.587 +	shift
  17.588 +	;;
  17.589 +    *)
  17.590 +	set fnord "$@" "$arg"
  17.591 +	shift
  17.592 +	shift
  17.593 +	;;
  17.594 +    esac
  17.595 +  done
  17.596 +  "$@" -E 2>/dev/null |
  17.597 +  sed -n '/^#line [0-9][0-9]* "\([^"]*\)"/ s::\1:p' | $cygpath_u | sort -u > "$tmpdepfile"
  17.598 +  rm -f "$depfile"
  17.599 +  echo "$object : \\" > "$depfile"
  17.600 +  sed < "$tmpdepfile" -n -e 's% %\\ %g' -e '/^\(.*\)$/ s::	\1 \\:p' >> "$depfile"
  17.601 +  echo "	" >> "$depfile"
  17.602 +  sed < "$tmpdepfile" -n -e 's% %\\ %g' -e '/^\(.*\)$/ s::\1\::p' >> "$depfile"
  17.603 +  rm -f "$tmpdepfile"
  17.604 +  ;;
  17.605 +
  17.606 +msvcmsys)
  17.607 +  # This case exists only to let depend.m4 do its work.  It works by
  17.608 +  # looking at the text of this script.  This case will never be run,
  17.609 +  # since it is checked for above.
  17.610 +  exit 1
  17.611 +  ;;
  17.612 +
  17.613 +none)
  17.614 +  exec "$@"
  17.615 +  ;;
  17.616 +
  17.617 +*)
  17.618 +  echo "Unknown depmode $depmode" 1>&2
  17.619 +  exit 1
  17.620 +  ;;
  17.621 +esac
  17.622 +
  17.623 +exit 0
  17.624 +
  17.625 +# Local Variables:
  17.626 +# mode: shell-script
  17.627 +# sh-indentation: 2
  17.628 +# eval: (add-hook 'write-file-hooks 'time-stamp)
  17.629 +# time-stamp-start: "scriptversion="
  17.630 +# time-stamp-format: "%:y-%02m-%02d.%02H"
  17.631 +# time-stamp-time-zone: "UTC"
  17.632 +# time-stamp-end: "; # UTC"
  17.633 +# End:
    18.1 Binary file deps/glpk/doc/cnfsat.pdf has changed
    19.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    19.2 +++ b/deps/glpk/doc/cnfsat.tex	Sun Nov 06 20:59:10 2011 +0100
    19.3 @@ -0,0 +1,380 @@
    19.4 +%* cnfsat.tex *%
    19.5 +
    19.6 +\documentclass[11pt,draft]{article}
    19.7 +
    19.8 +\begin{document}
    19.9 +
   19.10 +\title{CNF Satisfiability Problem}
   19.11 +
   19.12 +\author{Andrew Makhorin {\tt<mao@gnu.org>}}
   19.13 +
   19.14 +\date{August 2011}
   19.15 +
   19.16 +\maketitle
   19.17 +
   19.18 +\section{Introduction}
   19.19 +
   19.20 +The {\it Satisfiability Problem (SAT)} is a classic combinatorial
   19.21 +problem. Given a Boolean formula of $n$ variables
   19.22 +$$f(x_1,x_2,\dots,x_n),\eqno(1.1)$$
   19.23 +this problem is to find such values of the variables, on which the
   19.24 +formula takes on the value {\it true}.
   19.25 +
   19.26 +The {\it CNF Satisfiability Problem (CNF-SAT)} is a version of the
   19.27 +Satisfiability Problem, where the Boolean formula (1.1) is specified
   19.28 +in the {\it Conjunctive Normal Form (CNF)}, that means that it is a
   19.29 +conjunction of {\it clauses}, where a clause is a disjunction of
   19.30 +{\it literals}, and a literal is a variable or its negation.
   19.31 +For example:
   19.32 +$$(x_1\vee x_2)\;\&\;(\neg x_2\vee x_3\vee\neg x_4)\;\&\;(\neg
   19.33 +x_1\vee x_4).\eqno(1.2)$$
   19.34 +Here $x_1$, $x_2$, $x_3$, $x_4$ are Boolean variables to be assigned,
   19.35 +$\neg$ means
   19.36 +negation (logical {\it not}), $\vee$ means disjunction (logical
   19.37 +{\it or}), and $\&$ means conjunction (logical {\it and}). One may
   19.38 +note that the formula (1.2) is {\it satisfiable}, because on
   19.39 +$x_1$ = {\it true}, $x_2$ = {\it false}, $x_3$ = {\it false}, and
   19.40 +$x_4$ = {\it true} it takes on the value {\it true}. If a formula
   19.41 +is not satisfiable, it is called {\it unsatisfiable}, that means that
   19.42 +it takes on the value {\it false} on any values of its variables.
   19.43 +
   19.44 +Any CNF-SAT problem can be easily translated to a 0-1 programming
   19.45 +problem as follows. A Boolean variable $x$ can be modeled by a binary
   19.46 +variable in a natural way: $x=1$ means that $x$ takes on the value
   19.47 +{\it true}, and $x=0$ means that $x$ takes on the value {\it false}.
   19.48 +Then, if a literal is a negated variable, i.e. $t=\neg x$, it can
   19.49 +be expressed as $t=1-x$. Since a formula in CNF is a conjunction of
   19.50 +clauses, to provide its satisfiability we should require all its
   19.51 +clauses to  take on the value {\it true}. A particular clause is
   19.52 +a disjunction of literals:
   19.53 +$$t\vee t'\vee t''\dots ,\eqno(1.3)$$
   19.54 +so it takes on the value {\it true} iff at least one of its literals
   19.55 +takes on the value {\it true}, that can be expressed as the following
   19.56 +inequality constraint:
   19.57 +$$t+t'+t''+\dots\geq 1.\eqno(1.4)$$
   19.58 +Note that no objective function is used in this case, because only
   19.59 +a feasible solution needs to be found.
   19.60 +
   19.61 +For example, the formula (1.2) can be translated to the following
   19.62 +constraints:
   19.63 +$$\begin{array}{c@{\ }c@{\ }c@{\ }c@{\ }c@{\ }c@{\ }c@{\ }c@{\ }c}
   19.64 +x_1&+&x_2&&&&&\geq&1\\
   19.65 +&&(1-x_2)&+&x_3&+&(1-x_4)&\geq&1\\
   19.66 +(1-x_1)&&&&&+&x_4&\geq&1\\
   19.67 +\end{array}$$
   19.68 +$$x_1, x_2, x_3, x_4\in\{0,1\}$$
   19.69 +Carrying out all constant terms to the right-hand side gives
   19.70 +corresponding 0-1 programming problem in the standard format:
   19.71 +$$\begin{array}{r@{\ }c@{\ }c@{\ }c@{\ }c@{\ }c@{\ }c@{\ }c@{\ }r}
   19.72 +x_1&+&x_2&&&&&\geq&1\\
   19.73 +&-&x_2&+&x_3&-&x_4&\geq&-1\\
   19.74 +-x_1&&&&&+&x_4&\geq&0\\
   19.75 +\end{array}$$
   19.76 +$$x_1, x_2, x_3, x_4\in\{0,1\}$$
   19.77 +
   19.78 +In general case translation of a CNF-SAT problem results in the
   19.79 +following 0-1 programming problem:
   19.80 +$$\sum_{j\in J^+_i}x_j-\sum_{j\in J^-_i}x_j\geq 1-|J^-_i|,
   19.81 +\ \ \ i=1,\dots,m\eqno(1.5)$$
   19.82 +$$x_j\in\{0,1\},\ \ \ j=1,\dots,n\eqno(1.6)$$
   19.83 +where $n$ is the number of variables, $m$ is the number of clauses
   19.84 +(inequality constraints), $J^+_i\subseteq\{1,\dots,n\}$ is a subset
   19.85 +of variables, whose literals in $i$-th clause do not have negation,
   19.86 +and $J^-_i\subseteq\{1,\dots,n\}$ is a subset of variables, whose
   19.87 +literals in $i$-th clause are negations of that variables. It is
   19.88 +assumed that $J^+_i\cap J^-_i=\emptyset$ for all $i$.
   19.89 +
   19.90 +\newpage
   19.91 +
   19.92 +\section{GLPK API Routines}
   19.93 +
   19.94 +\subsection{glp\_read\_cnfsat---read CNF-SAT problem data in\\DIMACS
   19.95 +format}
   19.96 +
   19.97 +\subsubsection*{Synopsis}
   19.98 +
   19.99 +\begin{verbatim}
  19.100 +int glp_read_cnfsat(glp_prob *P, const char *fname);
  19.101 +\end{verbatim}
  19.102 +
  19.103 +\subsubsection*{Description}
  19.104 +
  19.105 +The routine \verb|glp_read_cnfsat| reads the CNF-SAT problem data from
  19.106 +a text file in DIMACS format and automatically translates the data to
  19.107 +corresponding 0-1 programming problem instance (1.5)--(1.6).
  19.108 +
  19.109 +The parameter \verb|P| specifies the problem object, to which the
  19.110 +0-1 programming problem instance should be stored. Note that before
  19.111 +reading data the current content of the problem object is completely
  19.112 +erased with the routine \verb|glp_erase_prob|.
  19.113 +
  19.114 +The character string \verb|fname| specifies the name of a text file
  19.115 +to be read in. (If the file name ends with the suffix `\verb|.gz|',
  19.116 +the file is assumed to be compressed, in which case the routine
  19.117 +decompresses it ``on the fly''.)
  19.118 +
  19.119 +\subsubsection*{Returns}
  19.120 +
  19.121 +If the operation was successful, the routine returns zero. Otherwise,
  19.122 +it prints an error message and returns non-zero.
  19.123 +
  19.124 +\subsubsection*{DIMACS CNF-SAT problem format\footnote{This material
  19.125 +is based on the paper ``Satisfiability Suggested Format'', which is
  19.126 +publicly available at {\tt http://dimacs.rutgers.edu/}.}}
  19.127 +
  19.128 +The DIMACS input file is a plain ASCII text file. It contains lines of
  19.129 +several types described below. A line is terminated with an end-of-line
  19.130 +character. Fields in each line are separated by at least one blank
  19.131 +space.
  19.132 +
  19.133 +\paragraph{Comment lines.} Comment lines give human-readable
  19.134 +information about the file and are ignored by programs. Comment lines
  19.135 +can appear anywhere in the file. Each comment line begins with a
  19.136 +lower-case character \verb|c|.
  19.137 +
  19.138 +\begin{verbatim}
  19.139 +   c This is a comment line
  19.140 +\end{verbatim}
  19.141 +
  19.142 +\newpage
  19.143 +
  19.144 +\paragraph{Problem line.} There is one problem line per data file. The
  19.145 +problem line must appear before any clause lines. It has the following
  19.146 +format:
  19.147 +
  19.148 +\begin{verbatim}
  19.149 +   p cnf VARIABLES CLAUSES
  19.150 +\end{verbatim}
  19.151 +
  19.152 +\noindent
  19.153 +The lower-case character \verb|p| signifies that this is a problem
  19.154 +line. The three character problem designator \verb|cnf| identifies the
  19.155 +file as containing specification information for the CNF-SAT problem.
  19.156 +The \verb|VARIABLES| field contains an integer value specifying $n$,
  19.157 +the number of variables in the instance. The \verb|CLAUSES| field
  19.158 +contains an integer value specifying $m$, the number of clauses in the
  19.159 +instance.
  19.160 +
  19.161 +\paragraph{Clauses.} The clauses appear immediately after the problem
  19.162 +line. The variables are assumed to be numbered from 1 up to $n$. It is
  19.163 +not necessary that every variable appears in the instance. Each clause
  19.164 +is represented by a sequence of numbers separated by either a space,
  19.165 +tab, or new-line character. The non-negated version of a variable $j$
  19.166 +is represented by $j$; the negated version is represented by $-j$. Each
  19.167 +clause is terminated by the value 0. Unlike many formats that represent
  19.168 +the end of a clause by a new-line character, this format allows clauses
  19.169 +to be on multiple lines.
  19.170 +
  19.171 +\paragraph{Example.} Below here is an example of the data file in
  19.172 +DIMACS format corresponding to the CNF-SAT problem (1.2).
  19.173 +
  19.174 +\begin{footnotesize}
  19.175 +\begin{verbatim}
  19.176 +c sample.cnf
  19.177 +c
  19.178 +c This is an example of the CNF-SAT problem data
  19.179 +c in DIMACS format.
  19.180 +c
  19.181 +p cnf 4 3
  19.182 +1 2 0
  19.183 +-4 3
  19.184 +-2 0
  19.185 +-1 4 0
  19.186 +c
  19.187 +c eof
  19.188 +\end{verbatim}
  19.189 +\end{footnotesize}
  19.190 +
  19.191 +\newpage
  19.192 +
  19.193 +\subsection{glp\_check\_cnfsat---check for CNF-SAT problem instance}
  19.194 +
  19.195 +\subsubsection*{Synopsis}
  19.196 +
  19.197 +\begin{verbatim}
  19.198 +int glp_check_cnfsat(glp_prob *P);
  19.199 +\end{verbatim}
  19.200 +
  19.201 +\subsubsection*{Description}
  19.202 +
  19.203 +The routine \verb|glp_check_cnfsat| checks if the specified problem
  19.204 +object \verb|P| contains a 0-1 programming problem instance in the
  19.205 +format (1.5)--(1.6) and therefore encodes a CNF-SAT problem instance.
  19.206 +
  19.207 +\subsubsection*{Returns}
  19.208 +
  19.209 +If the specified problem object has the format (1.5)--(1.6), the
  19.210 +routine returns zero, otherwise non-zero.
  19.211 +
  19.212 +\subsection{glp\_write\_cnfsat---write CNF-SAT problem data in\\DIMACS
  19.213 +format}
  19.214 +
  19.215 +\subsubsection*{Synopsis}
  19.216 +
  19.217 +\begin{verbatim}
  19.218 +int glp_write_cnfsat(glp_prob *P, const char *fname);
  19.219 +\end{verbatim}
  19.220 +
  19.221 +\subsubsection*{Description}
  19.222 +
  19.223 +The routine \verb|glp_write_cnfsat| automatically translates the
  19.224 +specified 0-1 programming problem instance (1.5)--(1.6) to a CNF-SAT
  19.225 +problem instance and writes the problem data to a text file in DIMACS
  19.226 +format.
  19.227 +
  19.228 +The parameter \verb|P| is the problem object, which should specify
  19.229 +a 0-1 programming problem instance in the format (1.5)--(1.6).
  19.230 +
  19.231 +The character string \verb|fname| specifies a name of the output text
  19.232 +file to be written. (If the file name ends with suffix `\verb|.gz|',
  19.233 +the file is assumed to be compressed, in which case the routine
  19.234 +performs automatic compression on writing that file.)
  19.235 +
  19.236 +\subsubsection*{Returns}
  19.237 +
  19.238 +If the operation was successful, the routine returns zero. Otherwise,
  19.239 +it prints an error message and returns non-zero.
  19.240 +
  19.241 +\newpage
  19.242 +
  19.243 +\subsection{glp\_minisat1---solve CNF-SAT problem instance with\\
  19.244 +MiniSat solver}
  19.245 +
  19.246 +\subsubsection*{Synopsis}
  19.247 +
  19.248 +\begin{verbatim}
  19.249 +int glp_minisat1(glp_prob *P);
  19.250 +\end{verbatim}
  19.251 +
  19.252 +\subsubsection*{Description}
  19.253 +
  19.254 +The routine \verb|glp_minisat1| is a driver to MiniSat, a CNF-SAT
  19.255 +solver developed by Niklas E\'en and Niklas S\"orensson, Chalmers
  19.256 +University of Technology, Sweden.\footnote{The MiniSat software module
  19.257 +is {\it not} part of GLPK, but is used with GLPK and included in the
  19.258 +distribution.}
  19.259 +
  19.260 +It is assumed that the specified problem object \verb|P| contains
  19.261 +a 0-1 programming problem instance in the format (1.5)--(1.6) and
  19.262 +therefore encodes a CNF-SAT problem instance.
  19.263 +
  19.264 +If the problem instance has been successfully solved to the end, the
  19.265 +routine \verb|glp_minisat1| returns 0. In this case the routine
  19.266 +\verb|glp_mip_status| can be used to determine the solution status:
  19.267 +
  19.268 +\verb|GLP_OPT| means that the solver found an integer feasible
  19.269 +solution and therefore the corresponding CNF-SAT instance is
  19.270 +satisfiable;
  19.271 +
  19.272 +\verb|GLP_NOFEAS| means that no integer feasible solution exists and
  19.273 +therefore the corresponding CNF-SAT instance is unsatisfiable.
  19.274 +
  19.275 +If an integer feasible solution was found, corresponding values of
  19.276 +binary variables can be retrieved with the routine
  19.277 +\verb|glp_mip_col_val|.
  19.278 +
  19.279 +\subsubsection*{Returns}
  19.280 +
  19.281 +\begin{tabular}{@{}p{25mm}p{97.3mm}@{}}
  19.282 +0 & The MIP problem instance has been successfully solved. (This code
  19.283 +does {\it not} necessarily mean that the solver has found feasible
  19.284 +solution. It only means that the solution process was successful.)\\
  19.285 +\verb|GLP_EDATA| & The specified problem object contains a MIP instance
  19.286 +which does {\it not} have the format (1.5)--(1.6).\\
  19.287 +\verb|GLP_EFAIL| & The solution process was unsuccessful because of the
  19.288 +solver failure.\\
  19.289 +\end{tabular}
  19.290 +
  19.291 +\newpage
  19.292 +
  19.293 +\subsection{glp\_intfeas1---solve integer feasibility problem}
  19.294 +
  19.295 +\subsubsection*{Synopsis}
  19.296 +
  19.297 +\begin{verbatim}
  19.298 +int glp_intfeas1(glp_prob *P, int use_bound, int obj_bound);
  19.299 +\end{verbatim}
  19.300 +
  19.301 +\subsubsection*{Description}
  19.302 +
  19.303 +The routine \verb|glp_intfeas1| is a tentative implementation of
  19.304 +an integer feasibility solver based on a CNF-SAT solver (currently
  19.305 +it is MiniSat; see Subsection 2.4).
  19.306 +
  19.307 +If the parameter \verb|use_bound| is zero, the routine searches for
  19.308 +{\it any} integer feasibile solution to the specified integer
  19.309 +programming problem. Note that in this case the objective function is
  19.310 +ignored.
  19.311 +
  19.312 +If the parameter \verb|use_bound| is non-zero, the routine searches for
  19.313 +an integer feasible solution, which provides a value of the objective
  19.314 +function not worse than \verb|obj_bound|. In other word, the parameter
  19.315 +\verb|obj_bound| specifies an upper (in case of minimization) or lower
  19.316 +(in case of maximization) bound to the objective function.
  19.317 +
  19.318 +If the specified problem has been successfully solved to the end, the
  19.319 +routine \verb|glp_intfeas1| returns 0. In this case the routine
  19.320 +\verb|glp_mip_status| can be used to determine the solution status:
  19.321 +
  19.322 +\begin{itemize}
  19.323 +\item {\tt GLP\_FEAS} means that the solver found an integer feasible
  19.324 +solution;
  19.325 +
  19.326 +\item {\tt GLP\_NOFEAS} means that the problem has no integer feasible
  19.327 +solution (if {\tt use\_bound} is zero) or it has no integer feasible
  19.328 +solution, which is not worse than {\tt obj\_bound} (if {\tt use\_bound}
  19.329 +is non-zero).
  19.330 +\end{itemize}
  19.331 +
  19.332 +If an integer feasible solution was found, corresponding values of
  19.333 +variables (columns) can be retrieved with the routine
  19.334 +\verb|glp_mip_col_val|.
  19.335 +
  19.336 +\subsubsection*{Usage Notes}
  19.337 +
  19.338 +The integer programming problem specified by the parameter \verb|P|
  19.339 +should satisfy to the following requirements:
  19.340 +
  19.341 +\begin{enumerate}
  19.342 +\item All variables (columns) should be either binary ({\tt GLP\_BV})
  19.343 +or fixed at integer values ({\tt GLP\_FX}).
  19.344 +
  19.345 +\item All constraint and objective coefficients should be integer
  19.346 +numbers in the range $[-2^{31},\ +2^{31}-1]$.
  19.347 +\end{enumerate}
  19.348 +
  19.349 +Though there are no special requirements to the constraints,
  19.350 +currently the routine \verb|glp_intfeas1| is efficient mainly for
  19.351 +problems, where most constraints (rows) fall into the following three
  19.352 +classes:
  19.353 +
  19.354 +\begin{enumerate}
  19.355 +\item Covering inequalities
  19.356 +$$\sum_{j}t_j\geq 1,$$
  19.357 +where $t_j=x_j$ or $t_j=1-x_j$, $x_j$ is a binary variable.
  19.358 +
  19.359 +\item Packing inequalities
  19.360 +$$\sum_{j}t_j\leq 1.$$
  19.361 +
  19.362 +\item Partitioning equalities (SOS1 constraints)
  19.363 +$$\sum_{j}t_j=1.$$
  19.364 +\end{enumerate}
  19.365 +
  19.366 +\subsubsection*{Returns}
  19.367 +
  19.368 +\begin{tabular}{@{}p{25mm}p{97.3mm}@{}}
  19.369 +0 & The problem has been successfully solved. (This code does {\it not}
  19.370 +necessarily mean that the solver has found an integer feasible solution.
  19.371 +It only means that the solution process was successful.)\\
  19.372 +
  19.373 +\verb|GLP_EDATA| & The specified problem object does not satisfy to the
  19.374 +requirements listed in Paragraph `Usage Notes'.\\
  19.375 +
  19.376 +\verb|GLP_ERANGE| & An integer overflow occured on translating the
  19.377 +specified problem to a CNF-SAT problem.\\
  19.378 +
  19.379 +\verb|GLP_EFAIL| & The solution process was unsuccessful because of the
  19.380 +solver failure.\\
  19.381 +\end{tabular}
  19.382 +
  19.383 +\end{document}
    20.1 Binary file deps/glpk/doc/glpk.pdf has changed
    21.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    21.2 +++ b/deps/glpk/doc/glpk.tex	Sun Nov 06 20:59:10 2011 +0100
    21.3 @@ -0,0 +1,128 @@
    21.4 +%* glpk.tex *%
    21.5 +
    21.6 +%***********************************************************************
    21.7 +%  This code is part of GLPK (GNU Linear Programming Kit).
    21.8 +%
    21.9 +%  Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008,
   21.10 +%  2009, 2010 Andrew Makhorin, Department for Applied Informatics,
   21.11 +%  Moscow Aviation Institute, Moscow, Russia. All rights reserved.
   21.12 +%  E-mail: <mao@gnu.org>.
   21.13 +%
   21.14 +%  GLPK is free software: you can redistribute it and/or modify it
   21.15 +%  under the terms of the GNU General Public License as published by
   21.16 +%  the Free Software Foundation, either version 3 of the License, or
   21.17 +%  (at your option) any later version.
   21.18 +%
   21.19 +%  GLPK is distributed in the hope that it will be useful, but WITHOUT
   21.20 +%  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
   21.21 +%  or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
   21.22 +%  License for more details.
   21.23 +%
   21.24 +%  You should have received a copy of the GNU General Public License
   21.25 +%  along with GLPK. If not, see <http://www.gnu.org/licenses/>.
   21.26 +%***********************************************************************
   21.27 +
   21.28 +\documentclass[11pt]{report}
   21.29 +\usepackage{amssymb}
   21.30 +\usepackage{lscape}
   21.31 +\usepackage[dvipdfm,linktocpage,colorlinks,linkcolor=blue,
   21.32 +urlcolor=blue]{hyperref}
   21.33 +\usepackage[all]{xy}
   21.34 +
   21.35 +\renewcommand\contentsname{\sf\bfseries Contents}
   21.36 +\renewcommand\chaptername{\sf\bfseries Chapter}
   21.37 +\renewcommand\appendixname{\sf\bfseries Appendix}
   21.38 +
   21.39 +\begin{document}
   21.40 +
   21.41 +\thispagestyle{empty}
   21.42 +
   21.43 +\begin{center}
   21.44 +
   21.45 +\vspace*{1in}
   21.46 +
   21.47 +\begin{huge}
   21.48 +\sf\bfseries GNU Linear Programming Kit
   21.49 +\end{huge}
   21.50 +
   21.51 +\vspace{0.5in}
   21.52 +
   21.53 +\begin{LARGE}
   21.54 +\sf Reference Manual
   21.55 +\end{LARGE}
   21.56 +
   21.57 +\vspace{0.5in}
   21.58 +
   21.59 +\begin{LARGE}
   21.60 +\sf for GLPK Version 4.45
   21.61 +\end{LARGE}
   21.62 +
   21.63 +\vspace{0.5in}
   21.64 +\begin{Large}
   21.65 +\sf (DRAFT, December 2010)
   21.66 +\end{Large}
   21.67 +\end{center}
   21.68 +
   21.69 +\newpage
   21.70 +
   21.71 +\vspace*{1in}
   21.72 +
   21.73 +\vfill
   21.74 +
   21.75 +\noindent
   21.76 +The GLPK package is part of the GNU Project released under the aegis of
   21.77 +GNU.
   21.78 +
   21.79 +\medskip \noindent
   21.80 +Copyright \copyright{} 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007,
   21.81 +2008, 2009, 2010 Andrew Makhorin, Department for Applied Informatics,
   21.82 +Moscow Aviation Institute, Moscow, Russia. All rights reserved.
   21.83 +
   21.84 +\medskip \noindent
   21.85 +Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
   21.86 +02110-1301, USA.
   21.87 +
   21.88 +\medskip \noindent
   21.89 +Permission is granted to make and distribute verbatim copies of this
   21.90 +manual provided the copyright notice and this permission notice are
   21.91 +preserved on all copies.
   21.92 +
   21.93 +\medskip \noindent
   21.94 +Permission is granted to copy and distribute modified versions of this
   21.95 +manual under the conditions for verbatim copying, provided also that the
   21.96 +entire resulting derived work is distributed under the terms of
   21.97 +a permission notice identical to this one.
   21.98 +
   21.99 +\medskip \noindent
  21.100 +Permission is granted to copy and distribute translations of this manual
  21.101 +into another language, under the above conditions for modified versions.
  21.102 +
  21.103 +\tableofcontents
  21.104 +
  21.105 +\include{glpk01}
  21.106 +
  21.107 +\include{glpk02}
  21.108 +
  21.109 +\include{glpk03}
  21.110 +
  21.111 +\include{glpk04}
  21.112 +
  21.113 +\include{glpk05}
  21.114 +
  21.115 +\include{glpk06}
  21.116 +
  21.117 +\appendix
  21.118 +
  21.119 +\include{glpk07}
  21.120 +
  21.121 +\include{glpk08}
  21.122 +
  21.123 +\include{glpk09}
  21.124 +
  21.125 +\include{glpk10}
  21.126 +
  21.127 +\include{glpk11}
  21.128 +
  21.129 +\include{glpk12}
  21.130 +
  21.131 +\end{document}
    22.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    22.2 +++ b/deps/glpk/doc/glpk01.tex	Sun Nov 06 20:59:10 2011 +0100
    22.3 @@ -0,0 +1,348 @@
    22.4 +%* glpk01.tex *%
    22.5 +
    22.6 +\chapter{Introduction}
    22.7 +
    22.8 +GLPK (\underline{G}NU \underline{L}inear \underline{P}rogramming
    22.9 +\underline{K}it) is a set of routines written in the ANSI C programming
   22.10 +language and organized in the form of a callable library. It is intended
   22.11 +for solving linear programming (LP), mixed integer programming (MIP),
   22.12 +and other related problems.
   22.13 +
   22.14 +\section{LP problem}
   22.15 +\label{seclp}
   22.16 +
   22.17 +GLPK assumes the following formulation of {\it linear programming (LP)}
   22.18 +problem:
   22.19 +
   22.20 +\medskip
   22.21 +
   22.22 +\noindent
   22.23 +\hspace{.5in} minimize (or maximize)
   22.24 +$$z = c_1x_{m+1} + c_2x_{m+2} + \dots + c_nx_{m+n} + c_0 \eqno (1.1)$$
   22.25 +\hspace{.5in} subject to linear constraints
   22.26 +$$
   22.27 +\begin{array}{r@{\:}c@{\:}r@{\:}c@{\:}r@{\:}c@{\:}r}
   22.28 +x_1&=&a_{11}x_{m+1}&+&a_{12}x_{m+2}&+ \dots +&a_{1n}x_{m+n} \\
   22.29 +x_2&=&a_{21}x_{m+1}&+&a_{22}x_{m+2}&+ \dots +&a_{2n}x_{m+n} \\
   22.30 +\multicolumn{7}{c}
   22.31 +{.\ \ .\ \ .\ \ .\ \ .\ \ .\ \ .\ \ .\ \ .\ \ .\ \ .\ \ .\ \ .\ \ .} \\
   22.32 +x_m&=&a_{m1}x_{m+1}&+&a_{m2}x_{m+2}&+ \dots +&a_{mn}x_{m+n} \\
   22.33 +\end{array} \eqno (1.2)
   22.34 +$$
   22.35 +\hspace{.5in} and bounds of variables
   22.36 +$$
   22.37 +\begin{array}{r@{\:}c@{\:}c@{\:}c@{\:}l}
   22.38 +l_1&\leq&x_1&\leq&u_1 \\
   22.39 +l_2&\leq&x_2&\leq&u_2 \\
   22.40 +\multicolumn{5}{c}{.\ \ .\ \ .\ \ .\ \ .}\\
   22.41 +l_{m+n}&\leq&x_{m+n}&\leq&u_{m+n} \\
   22.42 +\end{array} \eqno (1.3)
   22.43 +$$
   22.44 +where: $x_1, x_2, \dots, x_m$ are auxiliary variables;
   22.45 +$x_{m+1}, x_{m+2}, \dots, x_{m+n}$ are\linebreak structural variables;
   22.46 +$z$ is the objective function;
   22.47 +$c_1, c_2, \dots, c_n$ are objective coefficients;
   22.48 +$c_0$ is the constant term (``shift'') of the objective function;
   22.49 +$a_{11}, a_{12}, \dots, a_{mn}$ are constraint coefficients;
   22.50 +$l_1, l_2, \dots, l_{m+n}$ are lower bounds of variables;
   22.51 +$u_1, u_2, \dots, u_{m+n}$ are upper bounds of variables.
   22.52 +
   22.53 +Auxiliary variables are also called {\it rows}, because they correspond
   22.54 +to rows of the constraint matrix (i.e. a matrix built of the constraint
   22.55 +coefficients). Similarly, structural variables are also called
   22.56 +{\it columns}, because they correspond to columns of the constraint
   22.57 +matrix.
   22.58 +
   22.59 +Bounds of variables can be finite as well as infinite. Besides, lower
   22.60 +and upper bounds can be equal to each other. Thus, the following types
   22.61 +of variables are possible:
   22.62 +\begin{center}
   22.63 +\begin{tabular}{r@{}c@{}ll}
   22.64 +\multicolumn{3}{c}{Bounds of variable} & Type of variable \\
   22.65 +\hline
   22.66 +$-\infty <$ &$\ x_k\ $& $< +\infty$ & Free (unbounded) variable \\
   22.67 +$l_k \leq$ &$\ x_k\ $& $< +\infty$  & Variable with lower bound \\
   22.68 +$-\infty <$ &$\ x_k\ $& $\leq u_k$  & Variable with upper bound \\
   22.69 +$l_k \leq$ &$\ x_k\ $& $\leq u_k$   & Double-bounded variable \\
   22.70 +$l_k =$ &$\ x_k\ $& $= u_k$         & Fixed variable \\
   22.71 +\end{tabular}
   22.72 +\end{center}
   22.73 +\noindent
   22.74 +Note that the types of variables shown above are applicable to
   22.75 +structural as well as to auxiliary variables.
   22.76 +
   22.77 +To solve the LP problem (1.1)---(1.3) is to find such values of all
   22.78 +structural and auxiliary variables, which:
   22.79 +
   22.80 +$\bullet$ satisfy to all the linear constraints (1.2), and
   22.81 +
   22.82 +$\bullet$ are within their bounds (1.3), and
   22.83 +
   22.84 +$\bullet$ provide the smallest (in case of minimization) or the largest
   22.85 +(in case of maximization) value of the objective function (1.1).
   22.86 +
   22.87 +\section{MIP problem}
   22.88 +
   22.89 +{\it Mixed integer linear programming (MIP)} problem is LP problem in
   22.90 +which some variables are additionally required to be integer.
   22.91 +
   22.92 +GLPK assumes that MIP problem has the same formulation as ordinary
   22.93 +(pure) LP problem (1.1)---(1.3), i.e. includes auxiliary and structural
   22.94 +variables, which may have lower and/or upper bounds. However, in case of
   22.95 +MIP problem some variables may be required to be integer. This
   22.96 +additional constraint means that a value of each {\it integer variable}
   22.97 +must be only integer number. (Should note that GLPK allows only
   22.98 +structural variables to be of integer kind.)
   22.99 +
  22.100 +\section{Using the package}
  22.101 +
  22.102 +\subsection{Brief example}
  22.103 +
  22.104 +In order to understand what GLPK is from the user's standpoint,
  22.105 +consider the following simple LP problem:
  22.106 +
  22.107 +\medskip
  22.108 +
  22.109 +\noindent
  22.110 +\hspace{.5in} maximize
  22.111 +$$z = 10 x_1 + 6 x_2 + 4 x_3$$
  22.112 +\hspace{.5in} subject to
  22.113 +$$
  22.114 +\begin{array}{r@{\:}c@{\:}r@{\:}c@{\:}r@{\:}c@{\:}r}
  22.115 +x_1 &+&x_2 &+&x_3 &\leq 100 \\
  22.116 +10 x_1 &+& 4 x_2 & +&5 x_3 & \leq 600 \\
  22.117 +2 x_1 &+& 2 x_2 & +& 6 x_3 & \leq 300 \\
  22.118 +\end{array}
  22.119 +$$
  22.120 +\hspace{.5in} where all variables are non-negative
  22.121 +$$x_1 \geq 0, \ x_2 \geq 0, \ x_3 \geq 0$$
  22.122 +
  22.123 +At first this LP problem should be transformed to the standard form
  22.124 +(1.1)---(1.3). This can be easily done by introducing auxiliary
  22.125 +variables, by one for each original inequality constraint. Thus, the
  22.126 +problem can be reformulated as follows:
  22.127 +
  22.128 +\medskip
  22.129 +
  22.130 +\noindent
  22.131 +\hspace{.5in} maximize
  22.132 +$$z = 10 x_1 + 6 x_2 + 4 x_3$$
  22.133 +\hspace{.5in} subject to
  22.134 +$$
  22.135 +\begin{array}{r@{\:}c@{\:}r@{\:}c@{\:}r@{\:}c@{\:}r}
  22.136 +p& = &x_1 &+&x_2 &+&x_3 \\
  22.137 +q& = &10 x_1 &+& 4 x_2 &+& 5 x_3 \\
  22.138 +r& = &2  x_1 &+& 2 x_2 &+& 6 x_3 \\
  22.139 +\end{array}
  22.140 +$$
  22.141 +\hspace{.5in} and bounds of variables
  22.142 +$$
  22.143 +\begin{array}{ccc}
  22.144 +\nonumber -\infty < p \leq 100 && 0 \leq x_1 < +\infty \\
  22.145 +\nonumber -\infty < q \leq 600 && 0 \leq x_2 < +\infty \\
  22.146 +\nonumber -\infty < r \leq 300 && 0 \leq x_3 < +\infty \\
  22.147 +\end{array}
  22.148 +$$
  22.149 +where $p, q, r$ are auxiliary variables (rows), and $x_1, x_2, x_3$ are
  22.150 +structural variables (columns).
  22.151 +
  22.152 +The example C program shown below uses GLPK API routines in order to
  22.153 +solve this LP problem.\footnote{If you just need to solve LP or MIP
  22.154 +instance, you may write it in MPS or CPLEX LP format and then use the
  22.155 +GLPK stand-alone solver to obtain a solution. This is much less
  22.156 +time-consuming than programming in C with GLPK API routines.}
  22.157 +
  22.158 +\newpage
  22.159 +
  22.160 +\begin{verbatim}
  22.161 +/* sample.c */
  22.162 +
  22.163 +#include <stdio.h>
  22.164 +#include <stdlib.h>
  22.165 +#include <glpk.h>
  22.166 +
  22.167 +int main(void)
  22.168 +{     glp_prob *lp;
  22.169 +      int ia[1+1000], ja[1+1000];
  22.170 +      double ar[1+1000], z, x1, x2, x3;
  22.171 +s1:   lp = glp_create_prob();
  22.172 +s2:   glp_set_prob_name(lp, "sample");
  22.173 +s3:   glp_set_obj_dir(lp, GLP_MAX);
  22.174 +s4:   glp_add_rows(lp, 3);
  22.175 +s5:   glp_set_row_name(lp, 1, "p");
  22.176 +s6:   glp_set_row_bnds(lp, 1, GLP_UP, 0.0, 100.0);
  22.177 +s7:   glp_set_row_name(lp, 2, "q");
  22.178 +s8:   glp_set_row_bnds(lp, 2, GLP_UP, 0.0, 600.0);
  22.179 +s9:   glp_set_row_name(lp, 3, "r");
  22.180 +s10:  glp_set_row_bnds(lp, 3, GLP_UP, 0.0, 300.0);
  22.181 +s11:  glp_add_cols(lp, 3);
  22.182 +s12:  glp_set_col_name(lp, 1, "x1");
  22.183 +s13:  glp_set_col_bnds(lp, 1, GLP_LO, 0.0, 0.0);
  22.184 +s14:  glp_set_obj_coef(lp, 1, 10.0);
  22.185 +s15:  glp_set_col_name(lp, 2, "x2");
  22.186 +s16:  glp_set_col_bnds(lp, 2, GLP_LO, 0.0, 0.0);
  22.187 +s17:  glp_set_obj_coef(lp, 2, 6.0);
  22.188 +s18:  glp_set_col_name(lp, 3, "x3");
  22.189 +s19:  glp_set_col_bnds(lp, 3, GLP_LO, 0.0, 0.0);
  22.190 +s20:  glp_set_obj_coef(lp, 3, 4.0);
  22.191 +s21:  ia[1] = 1, ja[1] = 1, ar[1] =  1.0; /* a[1,1] =  1 */
  22.192 +s22:  ia[2] = 1, ja[2] = 2, ar[2] =  1.0; /* a[1,2] =  1 */
  22.193 +s23:  ia[3] = 1, ja[3] = 3, ar[3] =  1.0; /* a[1,3] =  1 */
  22.194 +s24:  ia[4] = 2, ja[4] = 1, ar[4] = 10.0; /* a[2,1] = 10 */
  22.195 +s25:  ia[5] = 3, ja[5] = 1, ar[5] =  2.0; /* a[3,1] =  2 */
  22.196 +s26:  ia[6] = 2, ja[6] = 2, ar[6] =  4.0; /* a[2,2] =  4 */
  22.197 +s27:  ia[7] = 3, ja[7] = 2, ar[7] =  2.0; /* a[3,2] =  2 */
  22.198 +s28:  ia[8] = 2, ja[8] = 3, ar[8] =  5.0; /* a[2,3] =  5 */
  22.199 +s29:  ia[9] = 3, ja[9] = 3, ar[9] =  6.0; /* a[3,3] =  6 */
  22.200 +s30:  glp_load_matrix(lp, 9, ia, ja, ar);
  22.201 +s31:  glp_simplex(lp, NULL);
  22.202 +s32:  z = glp_get_obj_val(lp);
  22.203 +s33:  x1 = glp_get_col_prim(lp, 1);
  22.204 +s34:  x2 = glp_get_col_prim(lp, 2);
  22.205 +s35:  x3 = glp_get_col_prim(lp, 3);
  22.206 +s36:  printf("\nz = %g; x1 = %g; x2 = %g; x3 = %g\n",
  22.207 +         z, x1, x2, x3);
  22.208 +s37:  glp_delete_prob(lp);
  22.209 +      return 0;
  22.210 +}
  22.211 +
  22.212 +/* eof */
  22.213 +\end{verbatim}
  22.214 +
  22.215 +The statement \verb|s1| creates a problem object. Being created the
  22.216 +object is initially empty. The statement \verb|s2| assigns a symbolic
  22.217 +name to the problem object.
  22.218 +
  22.219 +The statement \verb|s3| calls the routine \verb|glp_set_obj_dir| in
  22.220 +order to set the optimization direction flag, where \verb|GLP_MAX| means
  22.221 +maximization.
  22.222 +
  22.223 +The statement \verb|s4| adds three rows to the problem object.
  22.224 +
  22.225 +The statement \verb|s5| assigns the symbolic name `\verb|p|' to the
  22.226 +first row, and the statement \verb|s6| sets the type and bounds of the
  22.227 +first row, where \verb|GLP_UP| means that the row has an upper bound.
  22.228 +The statements \verb|s7|, \verb|s8|, \verb|s9|, \verb|s10| are used in
  22.229 +the same way in order to assign the symbolic names `\verb|q|' and
  22.230 +`\verb|r|' to the second and third rows and set their types and bounds.
  22.231 +
  22.232 +The statement \verb|s11| adds three columns to the problem object.
  22.233 +
  22.234 +The statement \verb|s12| assigns the symbolic name `\verb|x1|' to the
  22.235 +first column, the statement \verb|s13| sets the type and bounds of the
  22.236 +first column, where \verb|GLP_LO| means that the column has an lower
  22.237 +bound, and the statement \verb|s14| sets the objective coefficient for
  22.238 +the first column. The statements \verb|s15|---\verb|s20| are used in the
  22.239 +same way in order to assign the symbolic names `\verb|x2|' and
  22.240 +`\verb|x3|' to the second and third columns and set their types, bounds,
  22.241 +and objective coefficients.
  22.242 +
  22.243 +The statements \verb|s21|---\verb|s29| prepare non-zero elements of the
  22.244 +constraint matrix (i.e. constraint coefficients). Row indices of each
  22.245 +element are stored in the array \verb|ia|, column indices are stored in
  22.246 +the array \verb|ja|, and numerical values of corresponding elements are
  22.247 +stored in the array \verb|ar|. Then the statement \verb|s30| calls
  22.248 +the routine \verb|glp_load_matrix|, which loads information from these
  22.249 +three arrays into the problem object.
  22.250 +
  22.251 +Now all data have been entered into the problem object, and therefore
  22.252 +the statement \verb|s31| calls the routine \verb|glp_simplex|, which is
  22.253 +a driver to the simplex method, in order to solve the LP problem. This
  22.254 +routine finds an optimal solution and stores all relevant information
  22.255 +back into the problem object.
  22.256 +
  22.257 +The statement \verb|s32| obtains a computed value of the objective
  22.258 +function, and the statements \verb|s33|---\verb|s35| obtain computed
  22.259 +values of structural variables (columns), which correspond to the
  22.260 +optimal basic solution found by the solver.
  22.261 +
  22.262 +The statement \verb|s36| writes the optimal solution to the standard
  22.263 +output. The printout may look like follows:
  22.264 +
  22.265 +{\footnotesize
  22.266 +\begin{verbatim}
  22.267 +*     0:   objval =   0.000000000e+00   infeas =   0.000000000e+00 (0)
  22.268 +*     2:   objval =   7.333333333e+02   infeas =   0.000000000e+00 (0)
  22.269 +OPTIMAL SOLUTION FOUND
  22.270 +
  22.271 +z = 733.333; x1 = 33.3333; x2 = 66.6667; x3 = 0
  22.272 +\end{verbatim}
  22.273 +
  22.274 +}
  22.275 +
  22.276 +Finally, the statement \verb|s37| calls the routine
  22.277 +\verb|glp_delete_prob|, which frees all the memory allocated to the
  22.278 +problem object.
  22.279 +
  22.280 +\subsection{Compiling}
  22.281 +
  22.282 +The GLPK package has the only header file \verb|glpk.h|, which should
  22.283 +be available on compiling a C (or C++) program using GLPK API routines.
  22.284 +
  22.285 +If the header file is installed in the default location
  22.286 +\verb|/usr/local/include|, the following typical command may be used to
  22.287 +compile, say, the example C program described above with the GNU C
  22.288 +compiler:
  22.289 +
  22.290 +\begin{verbatim}
  22.291 +   $ gcc -c sample.c
  22.292 +\end{verbatim}
  22.293 +
  22.294 +If \verb|glpk.h| is not in the default location, the corresponding
  22.295 +directory containing it should be made known to the C compiler through
  22.296 +\verb|-I| option, for example:
  22.297 +
  22.298 +\begin{verbatim}
  22.299 +   $ gcc -I/foo/bar/glpk-4.15/include -c sample.c
  22.300 +\end{verbatim}
  22.301 +
  22.302 +In any case the compilation results in an object file \verb|sample.o|.
  22.303 +
  22.304 +\subsection{Linking}
  22.305 +
  22.306 +The GLPK library is a single file \verb|libglpk.a|. (On systems which
  22.307 +support shared libraries there may be also a shared version of the
  22.308 +library \verb|libglpk.so|.)
  22.309 +
  22.310 +If the library is installed in the default
  22.311 +location \verb|/usr/local/lib|, the following typical command may be
  22.312 +used to link, say, the example C program described above against with
  22.313 +the library:
  22.314 +
  22.315 +\begin{verbatim}
  22.316 +   $ gcc sample.o -lglpk -lm
  22.317 +\end{verbatim}
  22.318 +
  22.319 +If the GLPK library is not in the default location, the corresponding
  22.320 +directory containing it should be made known to the linker through
  22.321 +\verb|-L| option, for example:
  22.322 +
  22.323 +\begin{verbatim}
  22.324 +   $ gcc -L/foo/bar/glpk-4.15 sample.o -lglpk -lm
  22.325 +\end{verbatim}
  22.326 +
  22.327 +Depending on configuration of the package linking against with the GLPK
  22.328 +library may require the following optional libraries:
  22.329 +
  22.330 +\bigskip
  22.331 +
  22.332 +\begin{tabular}{@{}ll}
  22.333 +\verb|-lgmp|  & the GNU MP bignum library; \\
  22.334 +\verb|-lz|    & the zlib data compression library; \\
  22.335 +\verb|-lltdl| & the GNU ltdl shared support library. \\
  22.336 +\end{tabular}
  22.337 +
  22.338 +\bigskip
  22.339 +
  22.340 +\noindent
  22.341 +in which case corresponding libraries should be also made known to the
  22.342 +linker, for example:
  22.343 +
  22.344 +\begin{verbatim}
  22.345 +   $ gcc sample.o -lglpk -lz -lltdl -lm
  22.346 +\end{verbatim}
  22.347 +
  22.348 +For more details about configuration options of the GLPK package see
  22.349 +Appendix \ref{install}, page \pageref{install}.
  22.350 +
  22.351 +%* eof *%
    23.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    23.2 +++ b/deps/glpk/doc/glpk02.tex	Sun Nov 06 20:59:10 2011 +0100
    23.3 @@ -0,0 +1,3406 @@
    23.4 +%* glpk02.tex *%
    23.5 +
    23.6 +\chapter{Basic API Routines}
    23.7 +
    23.8 +This chapter describes GLPK API routines intended for using in
    23.9 +application programs.
   23.10 +
   23.11 +\subsubsection*{Library header}
   23.12 +
   23.13 +All GLPK API data types and routines are defined in the header file
   23.14 +\verb|glpk.h|. It should be included in all source files which use
   23.15 +GLPK API, either directly or indirectly through some other header file
   23.16 +as follows:
   23.17 +
   23.18 +\begin{verbatim}
   23.19 +   #include <glpk.h>
   23.20 +\end{verbatim}
   23.21 +
   23.22 +\subsubsection*{Error handling}
   23.23 +
   23.24 +If some GLPK API routine detects erroneous or incorrect data passed by
   23.25 +the application program, it writes appropriate diagnostic messages to
   23.26 +the terminal and then abnormally terminates the application program.
   23.27 +In most practical cases this allows to simplify programming by avoiding
   23.28 +numerous checks of return codes. Thus, in order to prevent crashing the
   23.29 +application program should check all data, which are suspected to be
   23.30 +incorrect, before calling GLPK API routines.
   23.31 +
   23.32 +Should note that this kind of error handling is used only in cases of
   23.33 +incorrect data passed by the application program. If, for example, the
   23.34 +application program calls some GLPK API routine to read data from an
   23.35 +input file and these data are incorrect, the GLPK API routine reports
   23.36 +about error in the usual way by means of the return code.
   23.37 +
   23.38 +\subsubsection*{Thread safety}
   23.39 +
   23.40 +Currently GLPK API routines are non-reentrant and therefore cannot be
   23.41 +used in multi-threaded programs.
   23.42 +
   23.43 +\subsubsection*{Array indexing}
   23.44 +
   23.45 +Normally all GLPK API routines start array indexing from 1, not from 0
   23.46 +(except the specially stipulated cases). This means, for example, that
   23.47 +if some vector $x$ of the length $n$ is passed as an array to some GLPK
   23.48 +API routine, the latter expects vector components to be placed in
   23.49 +locations \verb|x[1]|, \verb|x[2]|, \dots, \verb|x[n]|, and the location
   23.50 +\verb|x[0]| normally is not used.
   23.51 +
   23.52 +In order to avoid indexing errors it is most convenient and most
   23.53 +reliable to declare the array \verb|x| as follows:
   23.54 +
   23.55 +\begin{verbatim}
   23.56 +   double x[1+n];
   23.57 +\end{verbatim}
   23.58 +
   23.59 +\noindent
   23.60 +or to allocate it as follows:
   23.61 +
   23.62 +\begin{verbatim}
   23.63 +   double *x;
   23.64 +   . . .
   23.65 +   x = calloc(1+n, sizeof(double));
   23.66 +\end{verbatim}
   23.67 +
   23.68 +\noindent
   23.69 +In both cases one extra location \verb|x[0]| is reserved that allows
   23.70 +passing the array to GLPK routines in a usual way.
   23.71 +
   23.72 +\section{Problem object}
   23.73 +
   23.74 +All GLPK API routines deal with so called {\it problem object}, which
   23.75 +is a program object of type \verb|glp_prob| and intended to represent
   23.76 +a particular LP or MIP instance.
   23.77 +
   23.78 +The type \verb|glp_prob| is a data structure declared in the header
   23.79 +file \verb|glpk.h| as follows:
   23.80 +
   23.81 +\begin{verbatim}
   23.82 +   typedef struct { ... } glp_prob;
   23.83 +\end{verbatim}
   23.84 +
   23.85 +Problem objects (i.e. program objects of the \verb|glp_prob| type) are
   23.86 +allocated and managed internally by the GLPK API routines. The
   23.87 +application program should never use any members of the \verb|glp_prob|
   23.88 +structure directly and should deal only with pointers to these objects
   23.89 +(that is, \verb|glp_prob *| values).
   23.90 +
   23.91 +\pagebreak
   23.92 +
   23.93 +The problem object consists of five segments, which are:
   23.94 +
   23.95 +$\bullet$ problem segment,
   23.96 +
   23.97 +$\bullet$ basis segment,
   23.98 +
   23.99 +$\bullet$ interior point segment,
  23.100 +
  23.101 +$\bullet$ MIP segment, and
  23.102 +
  23.103 +$\bullet$ control parameters and statistics segment.
  23.104 +
  23.105 +\subsubsection*{Problem segment}
  23.106 +
  23.107 +The {\it problem segment} contains original LP/MIP data, which
  23.108 +corresponds to the problem formulation (1.1)---(1.3) (see Section
  23.109 +\ref{seclp}, page \pageref{seclp}). It includes the following
  23.110 +components:
  23.111 +
  23.112 +$\bullet$ rows (auxiliary variables),
  23.113 +
  23.114 +$\bullet$ columns (structural variables),
  23.115 +
  23.116 +$\bullet$ objective function, and
  23.117 +
  23.118 +$\bullet$ constraint matrix.
  23.119 +
  23.120 +Rows and columns have the same set of the following attributes:
  23.121 +
  23.122 +$\bullet$ ordinal number,
  23.123 +
  23.124 +$\bullet$ symbolic name (1 up to 255 arbitrary graphic characters),
  23.125 +
  23.126 +$\bullet$ type (free, lower bound, upper bound, double bound, fixed),
  23.127 +
  23.128 +$\bullet$ numerical values of lower and upper bounds,
  23.129 +
  23.130 +$\bullet$ scale factor.
  23.131 +
  23.132 +{\it Ordinal numbers} are intended for referencing rows and columns.
  23.133 +Row ordinal numbers are integers $1, 2, \dots, m$, and column ordinal
  23.134 +numbers are integers $1, 2, \dots, n$, where $m$ and $n$ are,
  23.135 +respectively, the current number of rows and columns in the problem
  23.136 +object.
  23.137 +
  23.138 +{\it Symbolic names} are intended for informational purposes. They also
  23.139 +can be used for referencing rows and columns.
  23.140 +
  23.141 +{\it Types and bounds} of rows (auxiliary variables) and columns
  23.142 +(structural variables) are explained above (see Section \ref{seclp},
  23.143 +page \pageref{seclp}).
  23.144 +
  23.145 +{\it Scale factors} are used internally for scaling rows and columns of
  23.146 +the constraint matrix.
  23.147 +
  23.148 +Information about the {\it objective function} includes numerical
  23.149 +values of objective coefficients and a flag, which defines the
  23.150 +optimization direction (i.e. minimization or maximization).
  23.151 +
  23.152 +The {\it constraint matrix} is a $m \times n$ rectangular matrix built
  23.153 +of constraint coefficients $a_{ij}$, which defines the system of linear
  23.154 +constraints (1.2) (see Section \ref{seclp}, page \pageref{seclp}). This
  23.155 +matrix is stored in the problem object in both row-wise and column-wise
  23.156 +sparse formats.
  23.157 +
  23.158 +Once the problem object has been created, the application program can
  23.159 +access and modify any components of the problem segment in arbitrary
  23.160 +order.
  23.161 +
  23.162 +\subsubsection*{Basis segment}
  23.163 +
  23.164 +The {\it basis segment} of the problem object keeps information related
  23.165 +to the current basic solution. It includes:
  23.166 +
  23.167 +$\bullet$ row and column statuses,
  23.168 +
  23.169 +$\bullet$ basic solution statuses,
  23.170 +
  23.171 +$\bullet$ factorization of the current basis matrix, and
  23.172 +
  23.173 +$\bullet$ basic solution components.
  23.174 +
  23.175 +The {\it row and column statuses} define which rows and columns are
  23.176 +basic and which are non-basic. These statuses may be assigned either by
  23.177 +the application program of by some API routines. Note that these
  23.178 +statuses are always defined independently on whether the corresponding
  23.179 +basis is valid or not.
  23.180 +
  23.181 +The {\it basic solution statuses} include the {\it primal status} and
  23.182 +the {\it dual status}, which are set by the simplex-based solver once
  23.183 +the problem has been solved. The primal status shows whether a primal
  23.184 +basic solution is feasible, infeasible, or undefined. The dual status
  23.185 +shows the same for a dual basic solution.
  23.186 +
  23.187 +The {\it factorization of the basis matrix} is some factorized form
  23.188 +(like LU-factorization) of the current basis matrix (defined by the
  23.189 +current row and column statuses). The factorization is used by the
  23.190 +simplex-based solver and kept when the solver terminates the search.
  23.191 +This feature allows efficiently reoptimizing the problem after some
  23.192 +modifications (for example, after changing some bounds or objective
  23.193 +coefficients). It also allows performing the post-optimal analysis (for
  23.194 +example, computing components of the simplex table, etc.).
  23.195 +
  23.196 +The {\it basic solution components} include primal and dual values of
  23.197 +all auxiliary and structural variables for the most recently obtained
  23.198 +basic solution.
  23.199 +
  23.200 +\subsubsection*{Interior point segment}
  23.201 +
  23.202 +The {\it interior point segment} is automatically allocated after the
  23.203 +problem has been solved using the interior point solver. It contains
  23.204 +interior point solution components, which include the solution status,
  23.205 +and primal and dual values of all auxiliary and structural variables.
  23.206 +
  23.207 +\subsubsection*{MIP segment}
  23.208 +
  23.209 +The {\it MIP segment} is used only for MIP problems. This segment
  23.210 +includes:
  23.211 +
  23.212 +$\bullet$ column kinds,
  23.213 +
  23.214 +$\bullet$ MIP solution status, and
  23.215 +
  23.216 +$\bullet$ MIP solution components.
  23.217 +
  23.218 +The {\it column kinds} define which columns (i.e. structural variables)
  23.219 +are integer and which are continuous.
  23.220 +
  23.221 +The {\it MIP solution status} is set by the MIP solver and shows whether
  23.222 +a MIP solution is integer optimal, integer feasible (non-optimal), or
  23.223 +undefined.
  23.224 +
  23.225 +The {\it MIP solution components} are computed by the MIP solver and
  23.226 +include primal values of all auxiliary and structural variables for the
  23.227 +most recently obtained MIP solution.
  23.228 +
  23.229 +Note that in case of MIP problem the basis segment corresponds to
  23.230 +the optimal solution of LP relaxation, which is also available to the
  23.231 +application program.
  23.232 +
  23.233 +Currently the search tree is not kept in the MIP segment. Therefore if
  23.234 +the search has been terminated, it cannot be continued.
  23.235 +
  23.236 +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  23.237 +
  23.238 +\newpage
  23.239 +
  23.240 +\section{Problem creating and modifying routines}
  23.241 +
  23.242 +\subsection{glp\_create\_prob---create problem object}
  23.243 +
  23.244 +\subsubsection*{Synopsis}
  23.245 +
  23.246 +\begin{verbatim}
  23.247 +glp_prob *glp_create_prob(void);
  23.248 +\end{verbatim}
  23.249 +
  23.250 +\subsubsection*{Description}
  23.251 +
  23.252 +The routine \verb|glp_create_prob| creates a new problem object, which
  23.253 +initially is ``empty'', i.e. has no rows and columns.
  23.254 +
  23.255 +\subsubsection*{Returns}
  23.256 +
  23.257 +The routine returns a pointer to the created object, which should be
  23.258 +used in any subsequent operations on this object.
  23.259 +
  23.260 +\subsection{glp\_set\_prob\_name---assign (change) problem name}
  23.261 +
  23.262 +\subsubsection*{Synopsis}
  23.263 +
  23.264 +\begin{verbatim}
  23.265 +void glp_set_prob_name(glp_prob *lp, const char *name);
  23.266 +\end{verbatim}
  23.267 +
  23.268 +\subsubsection*{Description}
  23.269 +
  23.270 +The routine \verb|glp_set_prob_name| assigns a given symbolic
  23.271 +\verb|name| (1 up to 255 characters) to the specified problem object.
  23.272 +
  23.273 +If the parameter \verb|name| is \verb|NULL| or empty string, the routine
  23.274 +erases an existing symbolic name of the problem object.
  23.275 +
  23.276 +\subsection{glp\_set\_obj\_name---assign (change) objective function
  23.277 +name}
  23.278 +
  23.279 +\subsubsection*{Synopsis}
  23.280 +
  23.281 +\begin{verbatim}
  23.282 +void glp_set_obj_name(glp_prob *lp, const char *name);
  23.283 +\end{verbatim}
  23.284 +
  23.285 +\subsubsection*{Description}
  23.286 +
  23.287 +The routine \verb|glp_set_obj_name| assigns a given symbolic
  23.288 +\verb|name| (1 up to 255 characters) to the objective function of the
  23.289 +specified problem object.
  23.290 +
  23.291 +If the parameter \verb|name| is \verb|NULL| or empty string, the routine
  23.292 +erases an existing symbolic name of the objective function.
  23.293 +
  23.294 +\subsection{glp\_set\_obj\_dir---set (change) optimization direction\\
  23.295 +flag}
  23.296 +
  23.297 +\subsubsection*{Synopsis}
  23.298 +
  23.299 +\begin{verbatim}
  23.300 +void glp_set_obj_dir(glp_prob *lp, int dir);
  23.301 +\end{verbatim}
  23.302 +
  23.303 +\subsubsection*{Description}
  23.304 +
  23.305 +The routine \verb|glp_set_obj_dir| sets (changes) the optimization
  23.306 +direction flag (i.e. ``sense'' of the objective function) as specified
  23.307 +by the parameter \verb|dir|:
  23.308 +
  23.309 +\begin{tabular}{@{}ll}
  23.310 +\verb|GLP_MIN| & minimization; \\
  23.311 +\verb|GLP_MAX| & maximization. \\
  23.312 +\end{tabular}
  23.313 +
  23.314 +\noindent
  23.315 +(Note that by default the problem is minimization.)
  23.316 +
  23.317 +\subsection{glp\_add\_rows---add new rows to problem object}
  23.318 +
  23.319 +\subsubsection*{Synopsis}
  23.320 +
  23.321 +\begin{verbatim}
  23.322 +int glp_add_rows(glp_prob *lp, int nrs);
  23.323 +\end{verbatim}
  23.324 +
  23.325 +\subsubsection*{Description}
  23.326 +
  23.327 +The routine \verb|glp_add_rows| adds \verb|nrs| rows (constraints) to
  23.328 +the specified problem object. New rows are always added to the end of
  23.329 +the row list, so the ordinal numbers of existing rows are not changed.
  23.330 +
  23.331 +Being added each new row is initially free (unbounded) and has empty
  23.332 +list of the constraint coefficients.
  23.333 +
  23.334 +\subsubsection*{Returns}
  23.335 +
  23.336 +The routine \verb|glp_add_rows| returns the ordinal number of the first
  23.337 +new row added to the problem object.
  23.338 +
  23.339 +\newpage
  23.340 +
  23.341 +\subsection{glp\_add\_cols---add new columns to problem object}
  23.342 +
  23.343 +\subsubsection*{Synopsis}
  23.344 +
  23.345 +\begin{verbatim}
  23.346 +int glp_add_cols(glp_prob *lp, int ncs);
  23.347 +\end{verbatim}
  23.348 +
  23.349 +\subsubsection*{Description}
  23.350 +
  23.351 +The routine \verb|glp_add_cols| adds \verb|ncs| columns (structural
  23.352 +variables) to the specified problem object. New columns are always added
  23.353 +to the end of the column list, so the ordinal numbers of existing
  23.354 +columns are not changed.
  23.355 +
  23.356 +Being added each new column is initially fixed at zero and has empty
  23.357 +list of the constraint coefficients.
  23.358 +
  23.359 +\subsubsection*{Returns}
  23.360 +
  23.361 +The routine \verb|glp_add_cols| returns the ordinal number of the first
  23.362 +new column added to the problem object.
  23.363 +
  23.364 +\subsection{glp\_set\_row\_name---assign (change) row name}
  23.365 +
  23.366 +\subsubsection*{Synopsis}
  23.367 +
  23.368 +\begin{verbatim}
  23.369 +void glp_set_row_name(glp_prob *lp, int i, const char *name);
  23.370 +\end{verbatim}
  23.371 +
  23.372 +\subsubsection*{Description}
  23.373 +
  23.374 +The routine \verb|glp_set_row_name| assigns a given symbolic
  23.375 +\verb|name| (1 up to 255 characters) to \verb|i|-th row (auxiliary
  23.376 +variable) of the specified problem object.
  23.377 +
  23.378 +If the parameter \verb|name| is \verb|NULL| or empty string, the routine
  23.379 +erases an existing name of $i$-th row.
  23.380 +
  23.381 +\subsection{glp\_set\_col\_name---assign (change) column name}
  23.382 +
  23.383 +\subsubsection*{Synopsis}
  23.384 +
  23.385 +\begin{verbatim}
  23.386 +void glp_set_col_name(glp_prob *lp, int j, const char *name);
  23.387 +\end{verbatim}
  23.388 +
  23.389 +\subsubsection*{Description}
  23.390 +
  23.391 +The routine \verb|glp_set_col_name| assigns a given symbolic
  23.392 +\verb|name| (1 up to 255 characters) to \verb|j|-th column (structural
  23.393 +variable) of the specified problem object.
  23.394 +
  23.395 +If the parameter \verb|name| is \verb|NULL| or empty string, the routine
  23.396 +erases an existing name of $j$-th column.
  23.397 +
  23.398 +\subsection{glp\_set\_row\_bnds---set (change) row bounds}
  23.399 +
  23.400 +\subsubsection*{Synopsis}
  23.401 +
  23.402 +\begin{verbatim}
  23.403 +void glp_set_row_bnds(glp_prob *lp, int i, int type,
  23.404 +      double lb, double ub);
  23.405 +\end{verbatim}
  23.406 +
  23.407 +\subsubsection*{Description}
  23.408 +
  23.409 +The routine \verb|glp_set_row_bnds| sets (changes) the type and bounds
  23.410 +of \verb|i|-th row (auxiliary variable) of the specified problem object.
  23.411 +
  23.412 +The parameters \verb|type|, \verb|lb|, and \verb|ub| specify the type,
  23.413 +lower bound, and upper bound, respectively, as follows:
  23.414 +
  23.415 +\begin{center}
  23.416 +\begin{tabular}{cr@{}c@{}ll}
  23.417 +Type & \multicolumn{3}{c}{Bounds} & Comment \\
  23.418 +\hline
  23.419 +\verb|GLP_FR| & $-\infty <$ &$\ x\ $& $< +\infty$
  23.420 +   & Free (unbounded) variable \\
  23.421 +\verb|GLP_LO| & $lb \leq$ &$\ x\ $& $< +\infty$
  23.422 +   & Variable with lower bound \\
  23.423 +\verb|GLP_UP| & $-\infty <$ &$\ x\ $& $\leq ub$
  23.424 +   & Variable with upper bound \\
  23.425 +\verb|GLP_DB| & $lb \leq$ &$\ x\ $& $\leq ub$
  23.426 +   & Double-bounded variable \\
  23.427 +\verb|GLP_FX| & $lb =$ &$\ x\ $& $= ub$
  23.428 +   & Fixed variable \\
  23.429 +\end{tabular}
  23.430 +\end{center}
  23.431 +
  23.432 +\noindent
  23.433 +where $x$ is the auxiliary variable associated with $i$-th row.
  23.434 +
  23.435 +If the row has no lower bound, the parameter \verb|lb| is ignored. If
  23.436 +the row has no upper bound, the parameter \verb|ub| is ignored. If the
  23.437 +row is an equality constraint (i.e. the corresponding auxiliary variable
  23.438 +is of fixed type), only the parameter \verb|lb| is used while the
  23.439 +parameter \verb|ub| is ignored.
  23.440 +
  23.441 +Being added to the problem object each row is initially free, i.e. its
  23.442 +type is \verb|GLP_FR|.
  23.443 +
  23.444 +\newpage
  23.445 +
  23.446 +\subsection{glp\_set\_col\_bnds---set (change) column bounds}
  23.447 +
  23.448 +\subsubsection*{Synopsis}
  23.449 +
  23.450 +\begin{verbatim}
  23.451 +void glp_set_col_bnds(glp_prob *lp, int j, int type,
  23.452 +      double lb, double ub);
  23.453 +\end{verbatim}
  23.454 +
  23.455 +\subsubsection*{Description}
  23.456 +
  23.457 +The routine \verb|glp_set_col_bnds| sets (changes) the type and bounds
  23.458 +of \verb|j|-th column (structural variable) of the specified problem
  23.459 +object.
  23.460 +
  23.461 +The parameters \verb|type|, \verb|lb|, and \verb|ub| specify the type,
  23.462 +lower bound, and upper bound, respectively, as follows:
  23.463 +
  23.464 +\begin{center}
  23.465 +\begin{tabular}{cr@{}c@{}ll}
  23.466 +Type & \multicolumn{3}{c}{Bounds} & Comment \\
  23.467 +\hline
  23.468 +\verb|GLP_FR| & $-\infty <$ &$\ x\ $& $< +\infty$
  23.469 +   & Free (unbounded) variable \\
  23.470 +\verb|GLP_LO| & $lb \leq$ &$\ x\ $& $< +\infty$
  23.471 +   & Variable with lower bound \\
  23.472 +\verb|GLP_UP| & $-\infty <$ &$\ x\ $& $\leq ub$
  23.473 +   & Variable with upper bound \\
  23.474 +\verb|GLP_DB| & $lb \leq$ &$\ x\ $& $\leq ub$
  23.475 +   & Double-bounded variable \\
  23.476 +\verb|GLP_FX| & $lb =$ &$\ x\ $& $= ub$
  23.477 +   & Fixed variable \\
  23.478 +\end{tabular}
  23.479 +\end{center}
  23.480 +
  23.481 +\noindent
  23.482 +where $x$ is the structural variable associated with $j$-th column.
  23.483 +
  23.484 +If the column has no lower bound, the parameter \verb|lb| is ignored.
  23.485 +If the column has no upper bound, the parameter \verb|ub| is ignored.
  23.486 +If the column is of fixed type, only the parameter \verb|lb| is used
  23.487 +while the parameter \verb|ub| is ignored.
  23.488 +
  23.489 +Being added to the problem object each column is initially fixed at
  23.490 +zero, i.e. its type is \verb|GLP_FX| and both bounds are 0.
  23.491 +
  23.492 +\subsection{glp\_set\_obj\_coef---set (change) objective coefficient
  23.493 +or constant term}
  23.494 +
  23.495 +\subsubsection*{Synopsis}
  23.496 +
  23.497 +\begin{verbatim}
  23.498 +void glp_set_obj_coef(glp_prob *lp, int j, double coef);
  23.499 +\end{verbatim}
  23.500 +
  23.501 +\subsubsection*{Description}
  23.502 +
  23.503 +The routine \verb|glp_set_obj_coef| sets (changes) the objective
  23.504 +coefficient at \verb|j|-th column (structural variable). A new value of
  23.505 +the objective coefficient is specified by the parameter \verb|coef|.
  23.506 +
  23.507 +If the parameter \verb|j| is 0, the routine sets (changes) the constant
  23.508 +term (``shift'') of the objective function.
  23.509 +
  23.510 +\subsection{glp\_set\_mat\_row---set (replace) row of the constraint
  23.511 +matrix}
  23.512 +
  23.513 +\subsubsection*{Synopsis}
  23.514 +
  23.515 +\begin{verbatim}
  23.516 +void glp_set_mat_row(glp_prob *lp, int i, int len,
  23.517 +      const int ind[], const double val[]);
  23.518 +\end{verbatim}
  23.519 +
  23.520 +\subsubsection*{Description}
  23.521 +
  23.522 +The routine \verb|glp_set_mat_row| stores (replaces) the contents of
  23.523 +\verb|i|-th row of the constraint matrix of the specified problem
  23.524 +object.
  23.525 +
  23.526 +Column indices and numerical values of new row elements must be placed
  23.527 +in locations \verb|ind[1]|, \dots, \verb|ind[len]| and \verb|val[1]|,
  23.528 +\dots, \verb|val[len]|, respectively, where $0 \leq$ \verb|len| $\leq n$
  23.529 +is the new length of $i$-th row, $n$ is the current number of columns in
  23.530 +the problem object. Elements with identical column indices are not
  23.531 +allowed. Zero elements are allowed, but they are not stored in the
  23.532 +constraint matrix.
  23.533 +
  23.534 +If the parameter \verb|len| is 0, the parameters \verb|ind| and/or
  23.535 +\verb|val| can be specified as \verb|NULL|.
  23.536 +
  23.537 +\subsection{glp\_set\_mat\_col---set (replace) column of the
  23.538 +constr\-aint matrix}
  23.539 +
  23.540 +\subsubsection*{Synopsis}
  23.541 +
  23.542 +\begin{verbatim}
  23.543 +void glp_set_mat_col(glp_prob *lp, int j, int len,
  23.544 +      const int ind[], const double val[]);
  23.545 +\end{verbatim}
  23.546 +
  23.547 +\subsubsection*{Description}
  23.548 +
  23.549 +The routine \verb|glp_set_mat_col| stores (replaces) the contents of
  23.550 +\verb|j|-th column of the constraint matrix of the specified problem
  23.551 +object.
  23.552 +
  23.553 +Row indices and numerical values of new column elements must be placed
  23.554 +in locations \verb|ind[1]|, \dots, \verb|ind[len]| and \verb|val[1]|,
  23.555 +\dots, \verb|val[len]|, respectively, where $0 \leq$ \verb|len| $\leq m$
  23.556 +is the new length of $j$-th column, $m$ is the current number of rows in
  23.557 +the problem object. Elements with identical row indices are not allowed.
  23.558 +Zero elements are allowed, but they are not stored in the constraint
  23.559 +matrix.
  23.560 +
  23.561 +If the parameter \verb|len| is 0, the parameters \verb|ind| and/or
  23.562 +\verb|val| can be specified as \verb|NULL|.
  23.563 +
  23.564 +\subsection{glp\_load\_matrix---load (replace) the whole constraint
  23.565 +matrix}
  23.566 +
  23.567 +\subsubsection*{Synopsis}
  23.568 +
  23.569 +\begin{verbatim}
  23.570 +void glp_load_matrix(glp_prob *lp, int ne, const int ia[],
  23.571 +      const int ja[], const double ar[]);
  23.572 +\end{verbatim}
  23.573 +
  23.574 +\subsubsection*{Description}
  23.575 +
  23.576 +The routine \verb|glp_load_matrix| loads the constraint matrix passed
  23.577 +in  the arrays \verb|ia|, \verb|ja|, and \verb|ar| into the specified
  23.578 +problem object. Before loading the current contents of the constraint
  23.579 +matrix is destroyed.
  23.580 +
  23.581 +Constraint coefficients (elements of the constraint matrix) must be
  23.582 +specified as triplets (\verb|ia[k]|, \verb|ja[k]|, \verb|ar[k]|) for
  23.583 +$k=1,\dots,ne$, where \verb|ia[k]| is the row index, \verb|ja[k]| is
  23.584 +the column index, and \verb|ar[k]| is a numeric value of corresponding
  23.585 +constraint coefficient. The parameter \verb|ne| specifies the total
  23.586 +number of (non-zero) elements in the matrix to be loaded. Coefficients
  23.587 +with identical indices are not allowed. Zero coefficients are allowed,
  23.588 +however, they are not stored in the constraint matrix.
  23.589 +
  23.590 +If the parameter \verb|ne| is 0, the parameters \verb|ia|, \verb|ja|,
  23.591 +and/or \verb|ar| can be specified as \verb|NULL|.
  23.592 +
  23.593 +\subsection{glp\_check\_dup---check for duplicate elements in sparse
  23.594 +matrix}
  23.595 +
  23.596 +\subsubsection*{Synopsis}
  23.597 +
  23.598 +\begin{verbatim}
  23.599 +int glp_check_dup(int m, int n, int ne, const int ia[],
  23.600 +   const int ja[]);
  23.601 +\end{verbatim}
  23.602 +
  23.603 +\subsubsection*{Description}
  23.604 +
  23.605 +The routine \verb|glp_check_dup checks| for duplicate elements (that
  23.606 +is, elements with identical indices) in a sparse matrix specified in
  23.607 +the coordinate format.
  23.608 +
  23.609 +The parameters $m$ and $n$ specifies, respectively, the number of rows
  23.610 +and columns in the matrix, $m\geq 0$, $n\geq 0$.
  23.611 +
  23.612 +The parameter {\it ne} specifies the number of (structurally) non-zero
  23.613 +elements in the matrix, {\it ne} $\geq 0$.
  23.614 +
  23.615 +Elements of the matrix are specified as doublets $(ia[k],ja[k])$ for
  23.616 +$k=1,\dots,ne$, where $ia[k]$ is a row index, $ja[k]$ is a column index.
  23.617 +
  23.618 +The routine \verb|glp_check_dup| can be used prior to a call to the
  23.619 +routine \verb|glp_load_matrix| to check that the constraint matrix to
  23.620 +be loaded has no duplicate elements.
  23.621 +
  23.622 +\subsubsection*{Returns}
  23.623 +
  23.624 +The routine \verb|glp_check_dup| returns one of the following values:
  23.625 +
  23.626 +\noindent
  23.627 +\begin{tabular}{@{}r@{\ }c@{\ }l@{}}
  23.628 +0&---&the matrix has no duplicate elements;\\
  23.629 +$-k$&---&indices $ia[k]$ or/and $ja[k]$ are out of range;\\
  23.630 +$+k$&---&element $(ia[k],ja[k])$ is duplicate.\\
  23.631 +\end{tabular}
  23.632 +
  23.633 +\subsection{glp\_sort\_matrix---sort elements of the constraint matrix}
  23.634 +
  23.635 +\subsubsection*{Synopsis}
  23.636 +
  23.637 +\begin{verbatim}
  23.638 +void glp_sort_matrix(glp_prob *P);
  23.639 +\end{verbatim}
  23.640 +
  23.641 +\subsubsection*{Description}
  23.642 +
  23.643 +The routine \verb|glp_sort_matrix| sorts elements of the constraint
  23.644 +matrix rebuilding its row and column linked lists. On exit from the
  23.645 +routine the constraint matrix is not changed, however, elements in the
  23.646 +row linked lists become ordered by ascending column indices, and the
  23.647 +elements in the column linked lists become ordered by ascending row
  23.648 +indices.
  23.649 +
  23.650 +\subsection{glp\_del\_rows---delete rows from problem object}
  23.651 +
  23.652 +\subsubsection*{Synopsis}
  23.653 +
  23.654 +\begin{verbatim}
  23.655 +void glp_del_rows(glp_prob *lp, int nrs, const int num[]);
  23.656 +\end{verbatim}
  23.657 +
  23.658 +\subsubsection*{Description}
  23.659 +
  23.660 +The routine \verb|glp_del_rows| deletes rows from the specified problem
  23.661 +ob-\linebreak ject. Ordinal numbers of rows to be deleted should be
  23.662 +placed in locations \verb|num[1]|, \dots, \verb|num[nrs]|, where
  23.663 +${\tt nrs}>0$.
  23.664 +
  23.665 +Note that deleting rows involves changing ordinal numbers of other
  23.666 +rows remaining in the problem object. New ordinal numbers of the
  23.667 +remaining rows are assigned under the assumption that the original
  23.668 +order of rows is not changed. Let, for example, before deletion there
  23.669 +be five rows $a$, $b$, $c$, $d$, $e$ with ordinal numbers 1, 2, 3, 4, 5,
  23.670 +and let rows $b$ and $d$ have been deleted. Then after deletion the
  23.671 +remaining rows $a$, $c$, $e$ are assigned new oridinal numbers 1, 2, 3.
  23.672 +
  23.673 +\subsection{glp\_del\_cols---delete columns from problem object}
  23.674 +
  23.675 +\subsubsection*{Synopsis}
  23.676 +
  23.677 +\begin{verbatim}
  23.678 +void glp_del_cols(glp_prob *lp, int ncs, const int num[]);
  23.679 +\end{verbatim}
  23.680 +
  23.681 +\subsubsection*{Description}
  23.682 +
  23.683 +The routine \verb|glp_del_cols| deletes columns from the specified
  23.684 +problem object. Ordinal numbers of columns to be deleted should be
  23.685 +placed in locations \verb|num[1]|, \dots, \verb|num[ncs]|, where
  23.686 +${\tt ncs}>0$.
  23.687 +
  23.688 +Note that deleting columns involves changing ordinal numbers of other
  23.689 +columns remaining in the problem object. New ordinal numbers of the
  23.690 +remaining columns are assigned under the assumption that the original
  23.691 +order of columns is not changed. Let, for example, before deletion there
  23.692 +be six columns $p$, $q$, $r$, $s$, $t$, $u$ with ordinal numbers 1, 2,
  23.693 +3, 4, 5, 6, and let columns $p$, $q$, $s$ have been deleted. Then after
  23.694 +deletion the remaining columns $r$, $t$, $u$ are assigned new ordinal
  23.695 +numbers 1, 2, 3.
  23.696 +
  23.697 +\subsection{glp\_copy\_prob---copy problem object content}
  23.698 +
  23.699 +\subsubsection*{Synopsis}
  23.700 +
  23.701 +\begin{verbatim}
  23.702 +void glp_copy_prob(glp_prob *dest, glp_prob *prob, int names);
  23.703 +\end{verbatim}
  23.704 +
  23.705 +\subsubsection*{Description}
  23.706 +
  23.707 +The routine \verb|glp_copy_prob| copies the content of the problem
  23.708 +object \verb|prob| to the problem object \verb|dest|.
  23.709 +
  23.710 +The parameter \verb|names| is a flag. If it is \verb|GLP_ON|,
  23.711 +the routine also copies all symbolic names; otherwise, if it is
  23.712 +\verb|GLP_OFF|, no symbolic names are copied.
  23.713 +
  23.714 +\newpage
  23.715 +
  23.716 +\subsection{glp\_erase\_prob---erase problem object content}
  23.717 +
  23.718 +\subsubsection*{Synopsis}
  23.719 +
  23.720 +\begin{verbatim}
  23.721 +void glp_erase_prob(glp_prob *lp);
  23.722 +\end{verbatim}
  23.723 +
  23.724 +\subsubsection*{Description}
  23.725 +
  23.726 +The routine \verb|glp_erase_prob| erases the content of the specified
  23.727 +problem object. The effect of this operation is the same as if the
  23.728 +problem object would be deleted with the routine \verb|glp_delete_prob|
  23.729 +and then created anew with the routine \verb|glp_create_prob|, with the
  23.730 +only exception that the handle (pointer) to the problem object remains
  23.731 +valid.
  23.732 +
  23.733 +\subsection{glp\_delete\_prob---delete problem object}
  23.734 +
  23.735 +\subsubsection*{Synopsis}
  23.736 +
  23.737 +\begin{verbatim}
  23.738 +void glp_delete_prob(glp_prob *lp);
  23.739 +\end{verbatim}
  23.740 +
  23.741 +\subsubsection*{Description}
  23.742 +
  23.743 +The routine \verb|glp_delete_prob| deletes a problem object, which the
  23.744 +parameter \verb|lp| points to, freeing all the memory allocated to this
  23.745 +object.
  23.746 +
  23.747 +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  23.748 +
  23.749 +\newpage
  23.750 +
  23.751 +\section{Problem retrieving routines}
  23.752 +
  23.753 +\subsection{glp\_get\_prob\_name---retrieve problem name}
  23.754 +
  23.755 +\subsubsection*{Synopsis}
  23.756 +
  23.757 +\begin{verbatim}
  23.758 +const char *glp_get_prob_name(glp_prob *lp);
  23.759 +\end{verbatim}
  23.760 +
  23.761 +\subsubsection*{Returns}
  23.762 +
  23.763 +The routine \verb|glp_get_prob_name| returns a pointer to an internal
  23.764 +buffer, which contains symbolic name of the problem. However, if the
  23.765 +problem has no assigned name, the routine returns \verb|NULL|.
  23.766 +
  23.767 +\subsection{glp\_get\_obj\_name---retrieve objective function name}
  23.768 +
  23.769 +\subsubsection*{Synopsis}
  23.770 +
  23.771 +\begin{verbatim}
  23.772 +const char *glp_get_obj_name(glp_prob *lp);
  23.773 +\end{verbatim}
  23.774 +
  23.775 +\subsubsection*{Returns}
  23.776 +
  23.777 +The routine \verb|glp_get_obj_name| returns a pointer to an internal
  23.778 +buffer, which contains symbolic name assigned to the objective
  23.779 +function. However, if the objective function has no assigned name, the
  23.780 +routine returns \verb|NULL|.
  23.781 +
  23.782 +\subsection{glp\_get\_obj\_dir---retrieve optimization direction flag}
  23.783 +
  23.784 +\subsubsection*{Synopsis}
  23.785 +
  23.786 +\begin{verbatim}
  23.787 +int glp_get_obj_dir(glp_prob *lp);
  23.788 +\end{verbatim}
  23.789 +
  23.790 +\subsubsection*{Returns}
  23.791 +
  23.792 +The routine \verb|glp_get_obj_dir| returns the optimization direction
  23.793 +flag (i.e. ``sense'' of the objective function):
  23.794 +
  23.795 +\begin{tabular}{@{}ll}
  23.796 +\verb|GLP_MIN| & minimization; \\
  23.797 +\verb|GLP_MAX| & maximization. \\
  23.798 +\end{tabular}
  23.799 +
  23.800 +\pagebreak
  23.801 +
  23.802 +\subsection{glp\_get\_num\_rows---retrieve number of rows}
  23.803 +
  23.804 +\subsubsection*{Synopsis}
  23.805 +
  23.806 +\begin{verbatim}
  23.807 +int glp_get_num_rows(glp_prob *lp);
  23.808 +\end{verbatim}
  23.809 +
  23.810 +\subsubsection*{Returns}
  23.811 +
  23.812 +The routine \verb|glp_get_num_rows| returns the current number of rows
  23.813 +in the specified problem object.
  23.814 +
  23.815 +\subsection{glp\_get\_num\_cols---retrieve number of columns}
  23.816 +
  23.817 +\subsubsection*{Synopsis}
  23.818 +
  23.819 +\begin{verbatim}
  23.820 +int glp_get_num_cols(glp_prob *lp);
  23.821 +\end{verbatim}
  23.822 +
  23.823 +\subsubsection*{Returns}
  23.824 +
  23.825 +The routine \verb|glp_get_num_cols| returns the current number of
  23.826 +columns the specified problem object.
  23.827 +
  23.828 +\subsection{glp\_get\_row\_name---retrieve row name}
  23.829 +
  23.830 +\subsubsection*{Synopsis}
  23.831 +
  23.832 +\begin{verbatim}
  23.833 +const char *glp_get_row_name(glp_prob *lp, int i);
  23.834 +\end{verbatim}
  23.835 +
  23.836 +\subsubsection*{Returns}
  23.837 +
  23.838 +The routine \verb|glp_get_row_name| returns a pointer to an internal
  23.839 +buffer, which contains a symbolic name assigned to \verb|i|-th row.
  23.840 +However, if the row has no assigned name, the routine returns
  23.841 +\verb|NULL|.
  23.842 +
  23.843 +\subsection{glp\_get\_col\_name---retrieve column name}
  23.844 +
  23.845 +\subsubsection*{Synopsis}
  23.846 +
  23.847 +\begin{verbatim}
  23.848 +const char *glp_get_col_name(glp_prob *lp, int j);
  23.849 +\end{verbatim}
  23.850 +
  23.851 +\subsubsection*{Returns}
  23.852 +
  23.853 +The routine \verb|glp_get_col_name| returns a pointer to an internal
  23.854 +buffer, which contains a symbolic name assigned to \verb|j|-th column.
  23.855 +However, if the column has no assigned name, the routine returns
  23.856 +\verb|NULL|.
  23.857 +
  23.858 +\subsection{glp\_get\_row\_type---retrieve row type}
  23.859 +
  23.860 +\subsubsection*{Synopsis}
  23.861 +
  23.862 +\begin{verbatim}
  23.863 +int glp_get_row_type(glp_prob *lp, int i);
  23.864 +\end{verbatim}
  23.865 +
  23.866 +\subsubsection*{Returns}
  23.867 +
  23.868 +The routine \verb|glp_get_row_type| returns the type of \verb|i|-th
  23.869 +row, i.e. the type of corresponding auxiliary variable, as follows:
  23.870 +
  23.871 +\begin{tabular}{@{}ll}
  23.872 +\verb|GLP_FR| & free (unbounded) variable; \\
  23.873 +\verb|GLP_LO| & variable with lower bound; \\
  23.874 +\verb|GLP_UP| & variable with upper bound; \\
  23.875 +\verb|GLP_DB| & double-bounded variable; \\
  23.876 +\verb|GLP_FX| & fixed variable. \\
  23.877 +\end{tabular}
  23.878 +
  23.879 +\subsection{glp\_get\_row\_lb---retrieve row lower bound}
  23.880 +
  23.881 +\subsubsection*{Synopsis}
  23.882 +
  23.883 +\begin{verbatim}
  23.884 +double glp_get_row_lb(glp_prob *lp, int i);
  23.885 +\end{verbatim}
  23.886 +
  23.887 +\subsubsection*{Returns}
  23.888 +
  23.889 +The routine \verb|glp_get_row_lb| returns the lower bound of
  23.890 +\verb|i|-th row, i.e. the lower bound of corresponding auxiliary
  23.891 +variable. However, if the row has no lower bound, the routine returns
  23.892 +\verb|-DBL_MAX|.
  23.893 +
  23.894 +\subsection{glp\_get\_row\_ub---retrieve row upper bound}
  23.895 +
  23.896 +\subsubsection*{Synopsis}
  23.897 +
  23.898 +\begin{verbatim}
  23.899 +double glp_get_row_ub(glp_prob *lp, int i);
  23.900 +\end{verbatim}
  23.901 +
  23.902 +\subsubsection*{Returns}
  23.903 +
  23.904 +The routine \verb|glp_get_row_ub| returns the upper bound of
  23.905 +\verb|i|-th row, i.e. the upper bound of corresponding auxiliary
  23.906 +variable. However, if the row has no upper bound, the routine returns
  23.907 +\verb|+DBL_MAX|.
  23.908 +
  23.909 +\subsection{glp\_get\_col\_type---retrieve column type}
  23.910 +
  23.911 +\subsubsection*{Synopsis}
  23.912 +
  23.913 +\begin{verbatim}
  23.914 +int glp_get_col_type(glp_prob *lp, int j);
  23.915 +\end{verbatim}
  23.916 +
  23.917 +\subsubsection*{Returns}
  23.918 +
  23.919 +The routine \verb|glp_get_col_type| returns the type of \verb|j|-th
  23.920 +column, i.e. the type of corresponding structural variable, as follows:
  23.921 +
  23.922 +\begin{tabular}{@{}ll}
  23.923 +\verb|GLP_FR| & free (unbounded) variable; \\
  23.924 +\verb|GLP_LO| & variable with lower bound; \\
  23.925 +\verb|GLP_UP| & variable with upper bound; \\
  23.926 +\verb|GLP_DB| & double-bounded variable; \\
  23.927 +\verb|GLP_FX| & fixed variable. \\
  23.928 +\end{tabular}
  23.929 +
  23.930 +\subsection{glp\_get\_col\_lb---retrieve column lower bound}
  23.931 +
  23.932 +\subsubsection*{Synopsis}
  23.933 +
  23.934 +\begin{verbatim}
  23.935 +double glp_get_col_lb(glp_prob *lp, int j);
  23.936 +\end{verbatim}
  23.937 +
  23.938 +\subsubsection*{Returns}
  23.939 +
  23.940 +The routine \verb|glp_get_col_lb| returns the lower bound of
  23.941 +\verb|j|-th column, i.e. the lower bound of corresponding structural
  23.942 +variable. However, if the column has no lower bound, the routine returns
  23.943 +\verb|-DBL_MAX|.
  23.944 +
  23.945 +\subsection{glp\_get\_col\_ub---retrieve column upper bound}
  23.946 +
  23.947 +\subsubsection*{Synopsis}
  23.948 +
  23.949 +\begin{verbatim}
  23.950 +double glp_get_col_ub(glp_prob *lp, int j);
  23.951 +\end{verbatim}
  23.952 +
  23.953 +\subsubsection*{Returns}
  23.954 +
  23.955 +The routine \verb|glp_get_col_ub| returns the upper bound of
  23.956 +\verb|j|-th column, i.e. the upper bound of corresponding structural
  23.957 +variable. However, if the column has no upper bound, the routine returns
  23.958 +\verb|+DBL_MAX|.
  23.959 +
  23.960 +\subsection{glp\_get\_obj\_coef---retrieve objective coefficient or\\
  23.961 +constant term}
  23.962 +
  23.963 +\subsubsection*{Synopsis}
  23.964 +
  23.965 +\begin{verbatim}
  23.966 +double glp_get_obj_coef(glp_prob *lp, int j);
  23.967 +\end{verbatim}
  23.968 +
  23.969 +\subsubsection*{Returns}
  23.970 +
  23.971 +The routine \verb|glp_get_obj_coef| returns the objective coefficient
  23.972 +at \verb|j|-th structural variable (column).
  23.973 +
  23.974 +If the parameter \verb|j| is 0, the routine returns the constant term
  23.975 +(``shift'') of the objective function.
  23.976 +
  23.977 +\subsection{glp\_get\_num\_nz---retrieve number of constraint
  23.978 +coefficients}
  23.979 +
  23.980 +\subsubsection*{Synopsis}
  23.981 +
  23.982 +\begin{verbatim}
  23.983 +int glp_get_num_nz(glp_prob *lp);
  23.984 +\end{verbatim}
  23.985 +
  23.986 +\subsubsection*{Returns}
  23.987 +
  23.988 +The routine \verb|glp_get_num_nz| returns the number of non-zero
  23.989 +elements in the constraint matrix of the specified problem object.
  23.990 +
  23.991 +\subsection{glp\_get\_mat\_row---retrieve row of the constraint
  23.992 +matrix}
  23.993 +
  23.994 +\subsubsection*{Synopsis}
  23.995 +
  23.996 +\begin{verbatim}
  23.997 +int glp_get_mat_row(glp_prob *lp, int i, int ind[],
  23.998 +      double val[]);
  23.999 +\end{verbatim}
 23.1000 +
 23.1001 +\subsubsection*{Description}
 23.1002 +
 23.1003 +The routine \verb|glp_get_mat_row| scans (non-zero) elements of
 23.1004 +\verb|i|-th row of the constraint matrix of the specified problem object
 23.1005 +and stores their column indices and numeric values to locations
 23.1006 +\verb|ind[1]|, \dots, \verb|ind[len]| and \verb|val[1]|, \dots,
 23.1007 +\verb|val[len]|, respectively, where $0\leq{\tt len}\leq n$ is the
 23.1008 +number of elements in $i$-th row, $n$ is the number of columns.
 23.1009 +
 23.1010 +The parameter \verb|ind| and/or \verb|val| can be specified as
 23.1011 +\verb|NULL|, in which case corresponding information is not stored.
 23.1012 +
 23.1013 +\subsubsection*{Returns}
 23.1014 +
 23.1015 +The routine \verb|glp_get_mat_row| returns the length \verb|len|, i.e.
 23.1016 +the number of (non-zero) elements in \verb|i|-th row.
 23.1017 +
 23.1018 +\subsection{glp\_get\_mat\_col---retrieve column of the constraint\\
 23.1019 +matrix}
 23.1020 +
 23.1021 +\subsubsection*{Synopsis}
 23.1022 +
 23.1023 +\begin{verbatim}
 23.1024 +int glp_get_mat_col(glp_prob *lp, int j, int ind[],
 23.1025 +      double val[]);
 23.1026 +\end{verbatim}
 23.1027 +
 23.1028 +\subsubsection*{Description}
 23.1029 +
 23.1030 +The routine \verb|glp_get_mat_col| scans (non-zero) elements of
 23.1031 +\verb|j|-th column of the constraint matrix of the specified problem
 23.1032 +object and stores their row indices and numeric values to locations
 23.1033 +\verb|ind[1]|, \dots, \verb|ind[len]| and \verb|val[1]|, \dots,
 23.1034 +\verb|val[len]|, respectively, where $0\leq{\tt len}\leq m$ is the
 23.1035 +number of elements in $j$-th column, $m$ is the number of rows.
 23.1036 +
 23.1037 +The parameter \verb|ind| and/or \verb|val| can be specified as
 23.1038 +\verb|NULL|, in which case corresponding information is not stored.
 23.1039 +
 23.1040 +\subsubsection*{Returns}
 23.1041 +
 23.1042 +The routine \verb|glp_get_mat_col| returns the length \verb|len|, i.e.
 23.1043 +the number of (non-zero) elements in \verb|j|-th column.
 23.1044 +
 23.1045 +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 23.1046 +
 23.1047 +\newpage
 23.1048 +
 23.1049 +\section{Row and column searching routines}
 23.1050 +
 23.1051 +\subsection{glp\_create\_index---create the name index}
 23.1052 +
 23.1053 +\subsubsection*{Synopsis}
 23.1054 +
 23.1055 +\begin{verbatim}
 23.1056 +void glp_create_index(glp_prob *lp);
 23.1057 +\end{verbatim}
 23.1058 +
 23.1059 +\subsubsection*{Description}
 23.1060 +
 23.1061 +The routine \verb|glp_create_index| creates the name index for the
 23.1062 +specified problem object. The name index is an auxiliary data structure,
 23.1063 +which is intended to quickly (i.e. for logarithmic time) find rows and
 23.1064 +columns by their names.
 23.1065 +
 23.1066 +This routine can be called at any time. If the name index already
 23.1067 +exists, the routine does nothing.
 23.1068 +
 23.1069 +\subsection{glp\_find\_row---find row by its name}
 23.1070 +
 23.1071 +\subsubsection*{Synopsis}
 23.1072 +
 23.1073 +\begin{verbatim}
 23.1074 +int glp_find_row(glp_prob *lp, const char *name);
 23.1075 +\end{verbatim}
 23.1076 +
 23.1077 +\subsubsection*{Returns}
 23.1078 +
 23.1079 +The routine \verb|glp_find_row| returns the ordinal number of a row,
 23.1080 +which is assigned (by the routine \verb|glp_set_row_name|) the specified
 23.1081 +symbolic \verb|name|. If no such row exists, the routine returns 0.
 23.1082 +
 23.1083 +\subsection{glp\_find\_col---find column by its name}
 23.1084 +
 23.1085 +\subsubsection*{Synopsis}
 23.1086 +
 23.1087 +\begin{verbatim}
 23.1088 +int glp_find_col(glp_prob *lp, const char *name);
 23.1089 +\end{verbatim}
 23.1090 +
 23.1091 +\subsubsection*{Returns}
 23.1092 +
 23.1093 +The routine \verb|glp_find_col| returns the ordinal number of a column,
 23.1094 +which is assigned (by the routine \verb|glp_set_col_name|) the specified
 23.1095 +symbolic \verb|name|. If no such column exists, the routine returns 0.
 23.1096 +
 23.1097 +\subsection{glp\_delete\_index---delete the name index}
 23.1098 +
 23.1099 +\subsubsection*{Synopsis}
 23.1100 +
 23.1101 +\begin{verbatim}
 23.1102 +void glp_delete_index(glp_prob *lp);
 23.1103 +\end{verbatim}
 23.1104 +
 23.1105 +\subsubsection*{Description}
 23.1106 +
 23.1107 +The routine \verb|glp_delete_index| deletes the name index previously
 23.1108 +created by the routine \verb|glp_create_index| and frees the memory
 23.1109 +allocated to this auxiliary data structure.
 23.1110 +
 23.1111 +This routine can be called at any time. If the name index does not
 23.1112 +exist, the routine does nothing.
 23.1113 +
 23.1114 +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 23.1115 +
 23.1116 +\newpage
 23.1117 +
 23.1118 +\section{Problem scaling routines}
 23.1119 +
 23.1120 +\subsection{Background}
 23.1121 +
 23.1122 +In GLPK the {\it scaling} means a linear transformation applied to the
 23.1123 +constraint matrix to improve its numerical properties.\footnote{In many
 23.1124 +cases a proper scaling allows making the constraint matrix to be better
 23.1125 +conditioned, i.e. decreasing its condition number, that makes
 23.1126 +computations numerically more stable.}
 23.1127 +
 23.1128 +The main equality is the following:
 23.1129 +$$\widetilde{A}=RAS,\eqno(2.1)$$
 23.1130 +where $A=(a_{ij})$ is the original constraint matrix, $R=(r_{ii})>0$ is
 23.1131 +a diagonal matrix used to scale rows (constraints), $S=(s_{jj})>0$ is a
 23.1132 +diagonal matrix used to scale columns (variables), $\widetilde{A}$ is
 23.1133 +the scaled constraint matrix.
 23.1134 +
 23.1135 +From (2.1) it follows that in the {\it scaled} problem instance each
 23.1136 +original constraint coefficient $a_{ij}$ is replaced by corresponding
 23.1137 +scaled constraint coefficient:
 23.1138 +$$\widetilde{a}_{ij}=r_{ii}a_{ij}s_{jj}.\eqno(2.2)$$
 23.1139 +
 23.1140 +Note that the scaling is performed internally and therefore
 23.1141 +transparently to the user. This means that on API level the user always
 23.1142 +deal with unscaled data.
 23.1143 +
 23.1144 +Scale factors $r_{ii}$ and $s_{jj}$ can be set or changed at any time
 23.1145 +either directly by the application program in a problem specific way
 23.1146 +(with the routines \verb|glp_set_rii| and \verb|glp_set_sjj|), or by
 23.1147 +some API routines intended for automatic scaling.
 23.1148 +
 23.1149 +\subsection{glp\_set\_rii---set (change) row scale factor}
 23.1150 +
 23.1151 +\subsubsection*{Synopsis}
 23.1152 +
 23.1153 +\begin{verbatim}
 23.1154 +void glp_set_rii(glp_prob *lp, int i, double rii);
 23.1155 +\end{verbatim}
 23.1156 +
 23.1157 +\subsubsection*{Description}
 23.1158 +
 23.1159 +The routine \verb|glp_set_rii| sets (changes) the scale factor $r_{ii}$
 23.1160 +for $i$-th row of the specified problem object.
 23.1161 +
 23.1162 +\subsection{glp\_set\_sjj---set (change) column scale factor}
 23.1163 +
 23.1164 +\subsubsection*{Synopsis}
 23.1165 +
 23.1166 +\begin{verbatim}
 23.1167 +void glp_set_sjj(glp_prob *lp, int j, double sjj);
 23.1168 +\end{verbatim}
 23.1169 +
 23.1170 +\subsubsection*{Description}
 23.1171 +
 23.1172 +The routine \verb|glp_set_sjj| sets (changes) the scale factor $s_{jj}$
 23.1173 +for $j$-th column of the specified problem object.
 23.1174 +
 23.1175 +\subsection{glp\_get\_rii---retrieve row scale factor}
 23.1176 +
 23.1177 +\subsubsection*{Synopsis}
 23.1178 +
 23.1179 +\begin{verbatim}
 23.1180 +double glp_get_rii(glp_prob *lp, int i);
 23.1181 +\end{verbatim}
 23.1182 +
 23.1183 +\subsubsection*{Returns}
 23.1184 +
 23.1185 +The routine \verb|glp_get_rii| returns current scale factor $r_{ii}$ for
 23.1186 +$i$-th row of the specified problem object.
 23.1187 +
 23.1188 +\subsection{glp\_get\_sjj---retrieve column scale factor}
 23.1189 +
 23.1190 +\subsubsection*{Synopsis}
 23.1191 +
 23.1192 +\begin{verbatim}
 23.1193 +double glp_get_sjj(glp_prob *lp, int j);
 23.1194 +\end{verbatim}
 23.1195 +
 23.1196 +\subsubsection*{Returns}
 23.1197 +
 23.1198 +The routine \verb|glp_get_sjj| returns current scale factor $s_{jj}$ for
 23.1199 +$j$-th column of the specified problem object.
 23.1200 +
 23.1201 +\subsection{glp\_scale\_prob---scale problem data}
 23.1202 +
 23.1203 +\subsubsection*{Synopsis}
 23.1204 +
 23.1205 +\begin{verbatim}
 23.1206 +void glp_scale_prob(glp_prob *lp, int flags);
 23.1207 +\end{verbatim}
 23.1208 +
 23.1209 +\subsubsection*{Description}
 23.1210 +
 23.1211 +The routine \verb|glp_scale_prob| performs automatic scaling of problem
 23.1212 +data for the specified problem object.
 23.1213 +
 23.1214 +The parameter \verb|flags| specifies scaling options used by the
 23.1215 +routine. The options can be combined with the bitwise OR operator and
 23.1216 +may be the following:
 23.1217 +
 23.1218 +\begin{tabular}{@{}ll}
 23.1219 +\verb|GLP_SF_GM| & perform geometric mean scaling;\\
 23.1220 +\verb|GLP_SF_EQ| & perform equilibration scaling;\\
 23.1221 +\verb|GLP_SF_2N| & round scale factors to nearest power of two;\\
 23.1222 +\verb|GLP_SF_SKIP| & skip scaling, if the problem is well scaled.\\
 23.1223 +\end{tabular}
 23.1224 +
 23.1225 +The parameter \verb|flags| may be specified as \verb|GLP_SF_AUTO|, in
 23.1226 +which case the routine chooses the scaling options automatically.
 23.1227 +
 23.1228 +\subsection{glp\_unscale\_prob---unscale problem data}
 23.1229 +
 23.1230 +\subsubsection*{Synopsis}
 23.1231 +
 23.1232 +\begin{verbatim}
 23.1233 +void glp_unscale_prob(glp_prob *lp);
 23.1234 +\end{verbatim}
 23.1235 +
 23.1236 +The routine \verb|glp_unscale_prob| performs unscaling of problem data
 23.1237 +for the specified problem object.
 23.1238 +
 23.1239 +``Unscaling'' means replacing the current scaling matrices $R$ and $S$
 23.1240 +by unity matrices that cancels the scaling effect.
 23.1241 +
 23.1242 +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 23.1243 +
 23.1244 +\newpage
 23.1245 +
 23.1246 +\section{LP basis constructing routines}
 23.1247 +
 23.1248 +\subsection{Background}
 23.1249 +
 23.1250 +To start the search the simplex method needs a valid initial basis. In
 23.1251 +GLPK the basis is completely defined by a set of {\it statuses} assigned
 23.1252 +to {\it all} (auxiliary and structural) variables, where the status may
 23.1253 +be one of the following:
 23.1254 +
 23.1255 +\begin{tabular}{@{}ll}
 23.1256 +\verb|GLP_BS| & basic variable;\\
 23.1257 +\verb|GLP_NL| & non-basic variable having active lower bound;\\
 23.1258 +\verb|GLP_NU| & non-basic variable having active upper bound;\\
 23.1259 +\verb|GLP_NF| & non-basic free variable;\\
 23.1260 +\verb|GLP_NS| & non-basic fixed variable.\\
 23.1261 +\end{tabular}
 23.1262 +
 23.1263 +The basis is {\it valid}, if the basis matrix, which is a matrix built
 23.1264 +of columns of the augmented constraint matrix $(I\:|-A)$ corresponding
 23.1265 +to basic variables, is non-singular. This, in particular, means that
 23.1266 +the number of basic variables must be the same as the number of rows in
 23.1267 +the problem object. (For more details see Section \ref{lpbasis}, page
 23.1268 +\pageref{lpbasis}.)
 23.1269 +
 23.1270 +Any initial basis may be constructed (or restored) with the API
 23.1271 +routines \verb|glp_set_row_stat| and \verb|glp_set_col_stat| by
 23.1272 +assigning appropriate statuses to auxiliary and structural variables.
 23.1273 +Another way to construct an initial basis is to use API routines like
 23.1274 +\verb|glp_adv_basis|, which implement so called
 23.1275 +{\it crashing}.\footnote{This term is from early linear programming
 23.1276 +systems and means a heuristic to construct a valid initial basis.} Note
 23.1277 +that on normal exit the simplex solver remains the basis valid, so in
 23.1278 +case of reoptimization there is no need to construct an initial basis
 23.1279 +from scratch.
 23.1280 +
 23.1281 +\subsection{glp\_set\_row\_stat---set (change) row status}
 23.1282 +
 23.1283 +\subsubsection*{Synopsis}
 23.1284 +
 23.1285 +\begin{verbatim}
 23.1286 +void glp_set_row_stat(glp_prob *lp, int i, int stat);
 23.1287 +\end{verbatim}
 23.1288 +
 23.1289 +\subsubsection*{Description}
 23.1290 +
 23.1291 +The routine \verb|glp_set_row_stat| sets (changes) the current status
 23.1292 +of \verb|i|-th row (auxiliary variable) as specified by the parameter
 23.1293 +\verb|stat|:
 23.1294 +
 23.1295 +\begin{tabular}{@{}lp{104.2mm}@{}}
 23.1296 +\verb|GLP_BS| & make the row basic (make the constraint inactive); \\
 23.1297 +\verb|GLP_NL| & make the row non-basic (make the constraint active); \\
 23.1298 +\end{tabular}
 23.1299 +
 23.1300 +\newpage
 23.1301 +
 23.1302 +\begin{tabular}{@{}lp{104.2mm}@{}}
 23.1303 +\verb|GLP_NU| & make the row non-basic and set it to the upper bound;
 23.1304 +   if the row is not double-bounded, this status is equivalent to
 23.1305 +   \verb|GLP_NL| (only in the case of this routine); \\
 23.1306 +\verb|GLP_NF| & the same as \verb|GLP_NL| (only in the case of this
 23.1307 +   routine); \\
 23.1308 +\verb|GLP_NS| & the same as \verb|GLP_NL| (only in the case of this
 23.1309 +   routine). \\
 23.1310 +\end{tabular}
 23.1311 +
 23.1312 +\subsection{glp\_set\_col\_stat---set (change) column status}
 23.1313 +
 23.1314 +\subsubsection*{Synopsis}
 23.1315 +
 23.1316 +\begin{verbatim}
 23.1317 +void glp_set_col_stat(glp_prob *lp, int j, int stat);
 23.1318 +\end{verbatim}
 23.1319 +
 23.1320 +\subsubsection*{Description}
 23.1321 +
 23.1322 +The routine \verb|glp_set_col_stat sets| (changes) the current status
 23.1323 +of \verb|j|-th column (structural variable) as specified by the
 23.1324 +parameter \verb|stat|:
 23.1325 +
 23.1326 +\begin{tabular}{@{}lp{104.2mm}@{}}
 23.1327 +\verb|GLP_BS| & make the column basic; \\
 23.1328 +\verb|GLP_NL| & make the column non-basic; \\
 23.1329 +\verb|GLP_NU| & make the column non-basic and set it to the upper
 23.1330 +   bound; if the column is not double-bounded, this status is equivalent
 23.1331 +   to \verb|GLP_NL| (only in the case of this routine); \\
 23.1332 +\verb|GLP_NF| & the same as \verb|GLP_NL| (only in the case of this
 23.1333 +   routine); \\
 23.1334 +\verb|GLP_NS| & the same as \verb|GLP_NL| (only in the case of this
 23.1335 +   routine).
 23.1336 +\end{tabular}
 23.1337 +
 23.1338 +\subsection{glp\_std\_basis---construct standard initial LP basis}
 23.1339 +
 23.1340 +\subsubsection*{Synopsis}
 23.1341 +
 23.1342 +\begin{verbatim}
 23.1343 +void glp_std_basis(glp_prob *lp);
 23.1344 +\end{verbatim}
 23.1345 +
 23.1346 +\subsubsection*{Description}
 23.1347 +
 23.1348 +The routine \verb|glp_std_basis| constructs the ``standard'' (trivial)
 23.1349 +initial LP basis for the specified problem object.
 23.1350 +
 23.1351 +In the ``standard'' LP basis all auxiliary variables (rows) are basic,
 23.1352 +and all structural variables (columns) are non-basic (so the
 23.1353 +corresponding basis matrix is unity).
 23.1354 +
 23.1355 +\newpage
 23.1356 +
 23.1357 +\subsection{glp\_adv\_basis---construct advanced initial LP basis}
 23.1358 +
 23.1359 +\subsubsection*{Synopsis}
 23.1360 +
 23.1361 +\begin{verbatim}
 23.1362 +void glp_adv_basis(glp_prob *lp, int flags);
 23.1363 +\end{verbatim}
 23.1364 +
 23.1365 +\subsubsection*{Description}
 23.1366 +
 23.1367 +The routine \verb|glp_adv_basis| constructs an advanced initial LP
 23.1368 +basis for the specified problem object.
 23.1369 +
 23.1370 +The parameter \verb|flags| is reserved for use in the future and must
 23.1371 +be specified as zero.
 23.1372 +
 23.1373 +In order to construct the advanced initial LP basis the routine does
 23.1374 +the following:
 23.1375 +
 23.1376 +1) includes in the basis all non-fixed auxiliary variables;
 23.1377 +
 23.1378 +2) includes in the basis as many non-fixed structural variables as
 23.1379 +possible keeping the triangular form of the basis matrix;
 23.1380 +
 23.1381 +3) includes in the basis appropriate (fixed) auxiliary variables to
 23.1382 +complete the basis.
 23.1383 +
 23.1384 +As a result the initial LP basis has as few fixed variables as possible
 23.1385 +and the corresponding basis matrix is triangular.
 23.1386 +
 23.1387 +\subsection{glp\_cpx\_basis---construct Bixby's initial LP basis}
 23.1388 +
 23.1389 +\subsubsection*{Synopsis}
 23.1390 +
 23.1391 +\begin{verbatim}
 23.1392 +void glp_cpx_basis(glp_prob *lp);
 23.1393 +\end{verbatim}
 23.1394 +
 23.1395 +\subsubsection*{Description}
 23.1396 +
 23.1397 +The routine \verb|glp_cpx_basis| constructs an initial basis for the
 23.1398 +specified problem object with the algorithm proposed by
 23.1399 +R.~Bixby.\footnote{Robert E. Bixby, ``Implementing the Simplex Method:
 23.1400 +The Initial Basis.'' ORSA Journal on Computing, Vol. 4, No. 3, 1992,
 23.1401 +pp. 267-84.}
 23.1402 +
 23.1403 +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 23.1404 +
 23.1405 +\newpage
 23.1406 +
 23.1407 +\section{Simplex method routines}
 23.1408 +
 23.1409 +The {\it simplex method} is a well known efficient numerical procedure
 23.1410 +to solve LP problems.
 23.1411 +
 23.1412 +On each iteration the simplex method transforms the original system of
 23.1413 +equaility constraints (1.2) resolving them through different sets of
 23.1414 +variables to an equivalent system called {\it the simplex table} (or
 23.1415 +sometimes {\it the simplex tableau}), which has the following form:
 23.1416 +$$
 23.1417 +\begin{array}{r@{\:}c@{\:}r@{\:}c@{\:}r@{\:}c@{\:}r}
 23.1418 +z&=&d_1(x_N)_1&+&d_2(x_N)_2&+ \dots +&d_n(x_N)_n \\
 23.1419 +(x_B)_1&=&\xi_{11}(x_N)_1& +& \xi_{12}(x_N)_2& + \dots +&
 23.1420 +   \xi_{1n}(x_N)_n \\
 23.1421 +(x_B)_2&=& \xi_{21}(x_N)_1& +& \xi_{22}(x_N)_2& + \dots +&
 23.1422 +   \xi_{2n}(x_N)_n \\
 23.1423 +\multicolumn{7}{c}
 23.1424 +{.\ \ .\ \ .\ \ .\ \ .\ \ .\ \ .\ \ .\ \ .\ \ .\ \ .\ \ .\ \ .\ \ .} \\
 23.1425 +(x_B)_m&=&\xi_{m1}(x_N)_1& +& \xi_{m2}(x_N)_2& + \dots +&
 23.1426 +   \xi_{mn}(x_N)_n \\
 23.1427 +\end{array} \eqno (2.3)
 23.1428 +$$
 23.1429 +where: $(x_B)_1, (x_B)_2, \dots, (x_B)_m$ are basic variables;
 23.1430 +$(x_N)_1, (x_N)_2, \dots, (x_N)_n$ are non-basic variables;
 23.1431 +$d_1, d_2, \dots, d_n$ are reduced costs;
 23.1432 +$\xi_{11}, \xi_{12}, \dots, \xi_{mn}$ are coefficients of the
 23.1433 +simplex table. (May note that the original LP problem (1.1)---(1.3) also
 23.1434 +has the form of a simplex table, where all equalities are resolved
 23.1435 +through auxiliary variables.)
 23.1436 +
 23.1437 +From the linear programming theory it is known that if an optimal
 23.1438 +solution of the LP problem (1.1)---(1.3) exists, it can always be
 23.1439 +written in the form (2.3), where non-basic variables are set on their
 23.1440 +bounds while values of the objective function and basic variables are
 23.1441 +determined by the corresponding equalities of the simplex table.
 23.1442 +
 23.1443 +A set of values of all basic and non-basic variables determined by the
 23.1444 +simplex table is called {\it basic solution}. If all basic variables are
 23.1445 +within their bounds, the basic solution is called {\it (primal)
 23.1446 +feasible}, otherwise it is called {\it (primal) infeasible}. A feasible
 23.1447 +basic solution, which provides a smallest (in case of minimization) or
 23.1448 +a largest (in case of maximization) value of the objective function is
 23.1449 +called {\it optimal}. Therefore, for solving LP problem the simplex
 23.1450 +method tries to find its optimal basic solution.
 23.1451 +
 23.1452 +Primal feasibility of some basic solution may be stated by simple
 23.1453 +checking if all basic variables are within their bounds. Basic solution
 23.1454 +is optimal if additionally the following optimality conditions are
 23.1455 +satisfied for all non-basic variables:
 23.1456 +\begin{center}
 23.1457 +\begin{tabular}{lcc}
 23.1458 +Status of $(x_N)_j$ & Minimization & Maximization \\
 23.1459 +\hline
 23.1460 +$(x_N)_j$ is free & $d_j = 0$ & $d_j = 0$ \\
 23.1461 +$(x_N)_j$ is on its lower bound & $d_j \geq 0$ & $d_j \leq 0$ \\
 23.1462 +$(x_N)_j$ is on its upper bound & $d_j \leq 0$ & $d_j \geq 0$ \\
 23.1463 +\end{tabular}
 23.1464 +\end{center}
 23.1465 +In other words, basic solution is optimal if there is no non-basic
 23.1466 +variable, which changing in the feasible direction (i.e. increasing if
 23.1467 +it is free or on its lower bound, or decreasing if it is free or on its
 23.1468 +upper bound) can improve (i.e. decrease in case of minimization or
 23.1469 +increase in case of maximization) the objective function.
 23.1470 +
 23.1471 +If all non-basic variables satisfy to the optimality conditions shown
 23.1472 +above (independently on whether basic variables are within their bounds
 23.1473 +or not), the basic solution is called {\it dual feasible}, otherwise it
 23.1474 +is called {\it dual infeasible}.
 23.1475 +
 23.1476 +It may happen that some LP problem has no primal feasible solution due
 23.1477 +to incorrect formulation---this means that its constraints conflict
 23.1478 +with each other. It also may happen that some LP problem has unbounded
 23.1479 +solution again due to incorrect formulation---this means that some
 23.1480 +non-basic variable can improve the objective function, i.e. the
 23.1481 +optimality conditions are violated, and at the same time this variable
 23.1482 +can infinitely change in the feasible direction meeting no resistance
 23.1483 +from basic variables. (May note that in the latter case the LP problem
 23.1484 +has no dual feasible solution.)
 23.1485 +
 23.1486 +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 23.1487 +
 23.1488 +\subsection{glp\_simplex---solve LP problem with the primal or dual
 23.1489 +simplex method}
 23.1490 +
 23.1491 +\subsubsection*{Synopsis}
 23.1492 +
 23.1493 +\begin{verbatim}
 23.1494 +int glp_simplex(glp_prob *lp, const glp_smcp *parm);
 23.1495 +\end{verbatim}
 23.1496 +
 23.1497 +\subsubsection*{Description}
 23.1498 +
 23.1499 +The routine \verb|glp_simplex| is a driver to the LP solver based on
 23.1500 +the simplex method. This routine retrieves problem data from the
 23.1501 +specified problem object, calls the solver to solve the problem
 23.1502 +instance, and stores results of computations back into the problem
 23.1503 +object.
 23.1504 +
 23.1505 +The simplex solver has a set of control parameters. Values of the
 23.1506 +control parameters can be passed in the structure \verb|glp_smcp|,
 23.1507 +which the parameter \verb|parm| points to. For detailed description of
 23.1508 +this structure see paragraph ``Control parameters'' below.
 23.1509 +Before specifying some control parameters the application program
 23.1510 +should initialize the structure \verb|glp_smcp| by default values of
 23.1511 +all control parameters using the routine \verb|glp_init_smcp| (see the
 23.1512 +next subsection). This is needed for backward compatibility, because in
 23.1513 +the future there may appear new members in the structure
 23.1514 +\verb|glp_smcp|.
 23.1515 +
 23.1516 +The parameter \verb|parm| can be specified as \verb|NULL|, in which
 23.1517 +case the solver uses default settings.
 23.1518 +
 23.1519 +\subsubsection*{Returns}
 23.1520 +
 23.1521 +\def\arraystretch{1}
 23.1522 +
 23.1523 +\begin{tabular}{@{}p{25mm}p{97.3mm}@{}}
 23.1524 +0 & The LP problem instance has been successfully solved. (This code
 23.1525 +does {\it not} necessarily mean that the solver has found optimal
 23.1526 +solution. It only means that the solution process was successful.) \\
 23.1527 +\verb|GLP_EBADB| & Unable to start the search, because the initial basis
 23.1528 +specified in the problem object is invalid---the number of basic
 23.1529 +(auxiliary and structural) variables is not the same as the number of
 23.1530 +rows in the problem object.\\
 23.1531 +\verb|GLP_ESING| & Unable to start the search, because the basis matrix
 23.1532 +corresponding to the initial basis is singular within the working
 23.1533 +precision.\\
 23.1534 +\verb|GLP_ECOND| & Unable to start the search, because the basis matrix
 23.1535 +corresponding to the initial basis is ill-conditioned, i.e. its
 23.1536 +condition number is too large.\\
 23.1537 +\verb|GLP_EBOUND| & Unable to start the search, because some
 23.1538 +double-bounded (auxiliary or structural) variables have incorrect
 23.1539 +bounds.\\
 23.1540 +\verb|GLP_EFAIL| & The search was prematurely terminated due to the
 23.1541 +solver failure.\\
 23.1542 +\verb|GLP_EOBJLL| & The search was prematurely terminated, because the
 23.1543 +objective function being maximized has reached its lower limit and
 23.1544 +continues decreasing (the dual simplex only).\\
 23.1545 +\verb|GLP_EOBJUL| & The search was prematurely terminated, because the
 23.1546 +objective function being minimized has reached its upper limit and
 23.1547 +continues increasing (the dual simplex only).\\
 23.1548 +\verb|GLP_EITLIM| & The search was prematurely terminated, because the
 23.1549 +simplex iteration limit has been exceeded.\\
 23.1550 +\verb|GLP_ETMLIM| & The search was prematurely terminated, because the
 23.1551 +time limit has been exceeded.\\
 23.1552 +\verb|GLP_ENOPFS| & The LP problem instance has no primal feasible
 23.1553 +solution (only if the LP presolver is used).\\
 23.1554 +\verb|GLP_ENODFS| & The LP problem instance has no dual feasible
 23.1555 +solution (only if the LP presolver is used).\\
 23.1556 +\end{tabular}
 23.1557 +
 23.1558 +\subsubsection*{Built-in LP presolver}
 23.1559 +
 23.1560 +The simplex solver has {\it built-in LP presolver}. It is a subprogram
 23.1561 +that transforms the original LP problem specified in the problem object
 23.1562 +to an equivalent LP problem, which may be easier for solving with the
 23.1563 +simplex method than the original one. This is attained mainly due to
 23.1564 +reducing the problem size and improving its numeric properties (for
 23.1565 +example, by removing some inactive constraints or by fixing some
 23.1566 +non-basic variables). Once the transformed LP problem has been solved,
 23.1567 +the presolver transforms its basic solution back to the corresponding
 23.1568 +basic solution of the original problem.
 23.1569 +
 23.1570 +Presolving is an optional feature of the routine \verb|glp_simplex|,
 23.1571 +and by default it is disabled. In order to enable the LP presolver the
 23.1572 +control parameter \verb|presolve| should be set to \verb|GLP_ON| (see
 23.1573 +paragraph ``Control parameters'' below). Presolving may be used when
 23.1574 +the problem instance is solved for the first time. However, on
 23.1575 +performing re-optimization the presolver should be disabled.
 23.1576 +
 23.1577 +The presolving procedure is transparent to the API user in the sense
 23.1578 +that all necessary processing is performed internally, and a basic
 23.1579 +solution of the original problem recovered by the presolver is the same
 23.1580 +as if it were computed directly, i.e. without presolving.
 23.1581 +
 23.1582 +Note that the presolver is able to recover only optimal solutions. If
 23.1583 +a computed solution is infeasible or non-optimal, the corresponding
 23.1584 +solution of the original problem cannot be recovered and therefore
 23.1585 +remains undefined. If you need to know a basic solution even if it is
 23.1586 +infeasible or non-optimal, the presolver should be disabled.
 23.1587 +
 23.1588 +\subsubsection*{Terminal output}
 23.1589 +
 23.1590 +Solving large problem instances may take a long time, so the solver
 23.1591 +reports some information about the current basic solution, which is sent
 23.1592 +to the terminal. This information has the following format:
 23.1593 +
 23.1594 +\begin{verbatim}
 23.1595 +nnn:  obj = xxx  infeas = yyy (ddd)
 23.1596 +\end{verbatim}
 23.1597 +
 23.1598 +\noindent
 23.1599 +where: `\verb|nnn|' is the iteration number, `\verb|xxx|' is the
 23.1600 +current value of the objective function (it is is unscaled and has
 23.1601 +correct sign); `\verb|yyy|' is the current sum of primal or dual
 23.1602 +infeasibilities (it is scaled and therefore may be used only for visual
 23.1603 +estimating), `\verb|ddd|' is the current number of fixed basic
 23.1604 +variables.
 23.1605 +
 23.1606 +The symbol preceding the iteration number indicates which phase of the
 23.1607 +simplex method is in effect:
 23.1608 +
 23.1609 +{\it Blank} means that the solver is searching for primal feasible
 23.1610 +solution using the primal simplex or for dual feasible solution using
 23.1611 +the dual simplex;
 23.1612 +
 23.1613 +{\it Asterisk} (\verb|*|) means that the solver is searching for
 23.1614 +optimal solution using the primal simplex;
 23.1615 +
 23.1616 +{\it Vertical dash} (\verb/|/) means that the solver is searching for
 23.1617 +optimal solution using the dual simplex.
 23.1618 +
 23.1619 +\subsubsection*{Control parameters}
 23.1620 +
 23.1621 +This paragraph describes all control parameters currently used in the
 23.1622 +simplex solver. Symbolic names of control parameters are names of
 23.1623 +corresponding members in the structure \verb|glp_smcp|.
 23.1624 +
 23.1625 +\medskip
 23.1626 +
 23.1627 +\noindent\begin{tabular}{@{}p{17pt}@{}p{120.5mm}@{}}
 23.1628 +\multicolumn{2}{@{}l}{{\tt int msg\_lev} (default: {\tt GLP\_MSG\_ALL})}
 23.1629 +\\
 23.1630 +&Message level for terminal output:\\
 23.1631 +&\verb|GLP_MSG_OFF|---no output;\\
 23.1632 +&\verb|GLP_MSG_ERR|---error and warning messages only;\\
 23.1633 +&\verb|GLP_MSG_ON |---normal output;\\
 23.1634 +&\verb|GLP_MSG_ALL|---full output (including informational messages).
 23.1635 +\\
 23.1636 +\end{tabular}
 23.1637 +
 23.1638 +\medskip
 23.1639 +
 23.1640 +\noindent\begin{tabular}{@{}p{17pt}@{}p{120.5mm}@{}}
 23.1641 +\multicolumn{2}{@{}l}{{\tt int meth} (default: {\tt GLP\_PRIMAL})}
 23.1642 +\\
 23.1643 +&Simplex method option:\\
 23.1644 +&\verb|GLP_PRIMAL|---use two-phase primal simplex;\\
 23.1645 +&\verb|GLP_DUAL  |---use two-phase dual simplex;\\
 23.1646 +&\verb|GLP_DUALP |---use two-phase dual simplex, and if it fails,
 23.1647 +switch to the\\
 23.1648 +&\verb|            |$\:$ primal simplex.\\
 23.1649 +\end{tabular}
 23.1650 +
 23.1651 +\medskip
 23.1652 +
 23.1653 +\noindent\begin{tabular}{@{}p{17pt}@{}p{120.5mm}@{}}
 23.1654 +\multicolumn{2}{@{}l}{{\tt int pricing} (default: {\tt GLP\_PT\_PSE})}
 23.1655 +\\
 23.1656 +&Pricing technique:\\
 23.1657 +&\verb|GLP_PT_STD|---standard (textbook);\\
 23.1658 +&\verb|GLP_PT_PSE|---projected steepest edge.\\
 23.1659 +\end{tabular}
 23.1660 +
 23.1661 +\medskip
 23.1662 +
 23.1663 +\noindent\begin{tabular}{@{}p{17pt}@{}p{120.5mm}@{}}
 23.1664 +\multicolumn{2}{@{}l}{{\tt int r\_test} (default: {\tt GLP\_RT\_HAR})}
 23.1665 +\\
 23.1666 +&Ratio test technique:\\
 23.1667 +&\verb|GLP_RT_STD|---standard (textbook);\\
 23.1668 +&\verb|GLP_RT_HAR|---Harris' two-pass ratio test.\\
 23.1669 +\end{tabular}
 23.1670 +
 23.1671 +\medskip
 23.1672 +
 23.1673 +\noindent\begin{tabular}{@{}p{17pt}@{}p{120.5mm}@{}}
 23.1674 +\multicolumn{2}{@{}l}{{\tt double tol\_bnd} (default: {\tt 1e-7})}
 23.1675 +\\
 23.1676 +&Tolerance used to check if the basic solution is primal feasible.
 23.1677 +(Do not change this parameter without detailed understanding its
 23.1678 +purpose.)\\
 23.1679 +\end{tabular}
 23.1680 +
 23.1681 +\medskip
 23.1682 +
 23.1683 +\noindent\begin{tabular}{@{}p{17pt}@{}p{120.5mm}@{}}
 23.1684 +\multicolumn{2}{@{}l}{{\tt double tol\_dj} (default: {\tt 1e-7})}
 23.1685 +\\
 23.1686 +&Tolerance used to check if the basic solution is dual feasible.
 23.1687 +(Do not change this parameter without detailed understanding its
 23.1688 +purpose.)\\
 23.1689 +\end{tabular}
 23.1690 +
 23.1691 +\medskip
 23.1692 +
 23.1693 +\noindent\begin{tabular}{@{}p{17pt}@{}p{120.5mm}@{}}
 23.1694 +\multicolumn{2}{@{}l}{{\tt double tol\_piv} (default: {\tt 1e-10})}
 23.1695 +\\
 23.1696 +&Tolerance used to choose eligble pivotal elements of the simplex table.
 23.1697 +(Do not change this parameter without detailed understanding its
 23.1698 +purpose.)\\
 23.1699 +\end{tabular}
 23.1700 +
 23.1701 +\medskip
 23.1702 +
 23.1703 +\noindent\begin{tabular}{@{}p{17pt}@{}p{120.5mm}@{}}
 23.1704 +\multicolumn{2}{@{}l}{{\tt double obj\_ll} (default: {\tt -DBL\_MAX})}
 23.1705 +\\
 23.1706 +&Lower limit of the objective function. If the objective function
 23.1707 +reaches this limit and continues decreasing, the solver terminates the
 23.1708 +search. (Used in the dual simplex only.)\\
 23.1709 +\end{tabular}
 23.1710 +
 23.1711 +\medskip
 23.1712 +
 23.1713 +\noindent\begin{tabular}{@{}p{17pt}@{}p{120.5mm}@{}}
 23.1714 +\multicolumn{2}{@{}l}{{\tt double obj\_ul} (default: {\tt +DBL\_MAX})}
 23.1715 +\\
 23.1716 +&Upper limit of the objective function. If the objective function
 23.1717 +reaches this limit and continues increasing, the solver terminates the
 23.1718 +search. (Used in the dual simplex only.)\\
 23.1719 +\end{tabular}
 23.1720 +
 23.1721 +\medskip
 23.1722 +
 23.1723 +\noindent\begin{tabular}{@{}p{17pt}@{}p{120.5mm}@{}}
 23.1724 +\multicolumn{2}{@{}l}{{\tt int it\_lim} (default: {\tt INT\_MAX})}
 23.1725 +\\
 23.1726 +&Simplex iteration limit.\\
 23.1727 +\end{tabular}
 23.1728 +
 23.1729 +\medskip
 23.1730 +
 23.1731 +\noindent\begin{tabular}{@{}p{17pt}@{}p{120.5mm}@{}}
 23.1732 +\multicolumn{2}{@{}l}{{\tt int tm\_lim} (default: {\tt INT\_MAX})}
 23.1733 +\\
 23.1734 +&Searching time limit, in milliseconds.\\
 23.1735 +\end{tabular}
 23.1736 +
 23.1737 +\medskip
 23.1738 +
 23.1739 +\noindent\begin{tabular}{@{}p{17pt}@{}p{120.5mm}@{}}
 23.1740 +\multicolumn{2}{@{}l}{{\tt int out\_frq} (default: {\tt 500})}
 23.1741 +\\
 23.1742 +&Output frequency, in iterations. This parameter specifies how
 23.1743 +frequently the solver sends information about the solution process to
 23.1744 +the terminal.\\
 23.1745 +\end{tabular}
 23.1746 +
 23.1747 +\medskip
 23.1748 +
 23.1749 +\noindent\begin{tabular}{@{}p{17pt}@{}p{120.5mm}@{}}
 23.1750 +\multicolumn{2}{@{}l}{{\tt int out\_dly} (default: {\tt 0})}
 23.1751 +\\
 23.1752 +&Output delay, in milliseconds. This parameter specifies how long the
 23.1753 +solver should delay sending information about the solution process to
 23.1754 +the terminal.\\
 23.1755 +\end{tabular}
 23.1756 +
 23.1757 +\medskip
 23.1758 +
 23.1759 +\noindent\begin{tabular}{@{}p{17pt}@{}p{120.5mm}@{}}
 23.1760 +\multicolumn{2}{@{}l}{{\tt int presolve} (default: {\tt GLP\_OFF})}
 23.1761 +\\
 23.1762 +&LP presolver option:\\
 23.1763 +&\verb|GLP_ON |---enable using the LP presolver;\\
 23.1764 +&\verb|GLP_OFF|---disable using the LP presolver.\\
 23.1765 +\end{tabular}
 23.1766 +
 23.1767 +\subsubsection*{Example 1}
 23.1768 +
 23.1769 +The following main program reads LP problem instance in fixed MPS
 23.1770 +format from file \verb|25fv47.mps|,\footnote{This instance in fixed MPS
 23.1771 +format can be found in the Netlib LP collection; see
 23.1772 +{\tt ftp://ftp.netlib.org/lp/data/}.} constructs an advanced initial
 23.1773 +basis, solves the instance with the primal simplex method (by default),
 23.1774 +and writes the solution to file \verb|25fv47.txt|.
 23.1775 +
 23.1776 +\newpage
 23.1777 +
 23.1778 +\begin{footnotesize}
 23.1779 +\begin{verbatim}
 23.1780 +/* spxsamp1.c */
 23.1781 +
 23.1782 +#include <stdio.h>
 23.1783 +#include <stdlib.h>
 23.1784 +#include <glpk.h>
 23.1785 +
 23.1786 +int main(void)
 23.1787 +{     glp_prob *P;
 23.1788 +      P = glp_create_prob();
 23.1789 +      glp_read_mps(P, GLP_MPS_DECK, NULL, "25fv47.mps");
 23.1790 +      glp_adv_basis(P, 0);
 23.1791 +      glp_simplex(P, NULL);
 23.1792 +      glp_print_sol(P, "25fv47.txt");
 23.1793 +      glp_delete_prob(P);
 23.1794 +      return 0;
 23.1795 +}
 23.1796 +
 23.1797 +/* eof */
 23.1798 +\end{verbatim}
 23.1799 +\end{footnotesize}
 23.1800 +
 23.1801 +\noindent
 23.1802 +Below here is shown the terminal output from this example program.
 23.1803 +
 23.1804 +\begin{footnotesize}
 23.1805 +\begin{verbatim}
 23.1806 +Reading problem data from `25fv47.mps'...
 23.1807 +Problem: 25FV47
 23.1808 +Objective: R0000
 23.1809 +822 rows, 1571 columns, 11127 non-zeros
 23.1810 +6919 records were read
 23.1811 +Crashing...
 23.1812 +Size of triangular part = 799
 23.1813 +      0: obj =   1.627307307e+04  infeas =  5.194e+04 (23)
 23.1814 +    200: obj =   1.474901610e+04  infeas =  1.233e+04 (19)
 23.1815 +    400: obj =   1.343909995e+04  infeas =  3.648e+03 (13)
 23.1816 +    600: obj =   1.756052217e+04  infeas =  4.179e+02 (7)
 23.1817 +*   775: obj =   1.789251591e+04  infeas =  4.982e-14 (1)
 23.1818 +*   800: obj =   1.663354510e+04  infeas =  2.857e-14 (1)
 23.1819 +*  1000: obj =   1.024935068e+04  infeas =  1.958e-12 (1)
 23.1820 +*  1200: obj =   7.860174791e+03  infeas =  2.810e-29 (1)
 23.1821 +*  1400: obj =   6.642378184e+03  infeas =  2.036e-16 (1)
 23.1822 +*  1600: obj =   6.037014568e+03  infeas =  0.000e+00 (1)
 23.1823 +*  1800: obj =   5.662171307e+03  infeas =  6.447e-15 (1)
 23.1824 +*  2000: obj =   5.528146165e+03  infeas =  9.764e-13 (1)
 23.1825 +*  2125: obj =   5.501845888e+03  infeas =  0.000e+00 (1)
 23.1826 +OPTIMAL SOLUTION FOUND
 23.1827 +Writing basic solution to `25fv47.txt'...
 23.1828 +\end{verbatim}
 23.1829 +\end{footnotesize}
 23.1830 +
 23.1831 +\newpage
 23.1832 +
 23.1833 +\subsubsection*{Example 2}
 23.1834 +
 23.1835 +The following main program solves the same LP problem instance as in
 23.1836 +Example 1 above, however, it uses the dual simplex method, which starts
 23.1837 +from the standard initial basis.
 23.1838 +
 23.1839 +\begin{footnotesize}
 23.1840 +\begin{verbatim}
 23.1841 +/* spxsamp2.c */
 23.1842 +
 23.1843 +#include <stdio.h>
 23.1844 +#include <stdlib.h>
 23.1845 +#include <glpk.h>
 23.1846 +
 23.1847 +int main(void)
 23.1848 +{     glp_prob *P;
 23.1849 +      glp_smcp parm;
 23.1850 +      P = glp_create_prob();
 23.1851 +      glp_read_mps(P, GLP_MPS_DECK, NULL, "25fv47.mps");
 23.1852 +      glp_init_smcp(&parm);
 23.1853 +      parm.meth = GLP_DUAL;
 23.1854 +      glp_simplex(P, &parm);
 23.1855 +      glp_print_sol(P, "25fv47.txt");
 23.1856 +      glp_delete_prob(P);
 23.1857 +      return 0;
 23.1858 +}
 23.1859 +
 23.1860 +/* eof */
 23.1861 +\end{verbatim}
 23.1862 +\end{footnotesize}
 23.1863 +
 23.1864 +\noindent
 23.1865 +Below here is shown the terminal output from this example program.
 23.1866 +
 23.1867 +\begin{footnotesize}
 23.1868 +\begin{verbatim}
 23.1869 +Reading problem data from `25fv47.mps'...
 23.1870 +Problem: 25FV47
 23.1871 +Objective: R0000
 23.1872 +822 rows, 1571 columns, 11127 non-zeros
 23.1873 +6919 records were read
 23.1874 +      0:                          infeas =  1.223e+03 (516)
 23.1875 +    200:                          infeas =  7.000e+00 (471)
 23.1876 +    240:                          infeas =  1.106e-14 (461)
 23.1877 +|   400: obj =  -5.394267152e+03  infeas =  5.571e-16 (391)
 23.1878 +|   600: obj =  -4.586395752e+03  infeas =  1.389e-15 (340)
 23.1879 +|   800: obj =  -4.158268146e+03  infeas =  1.640e-15 (264)
 23.1880 +|  1000: obj =  -3.725320045e+03  infeas =  5.181e-15 (245)
 23.1881 +|  1200: obj =  -3.104802163e+03  infeas =  1.019e-14 (210)
 23.1882 +|  1400: obj =  -2.584190499e+03  infeas =  8.865e-15 (178)
 23.1883 +|  1600: obj =  -2.073852927e+03  infeas =  7.867e-15 (142)
 23.1884 +|  1800: obj =  -1.164037407e+03  infeas =  8.792e-15 (109)
 23.1885 +|  2000: obj =  -4.370590250e+02  infeas =  2.591e-14 (85)
 23.1886 +|  2200: obj =   1.068240144e+03  infeas =  1.025e-13 (70)
 23.1887 +|  2400: obj =   1.607481126e+03  infeas =  3.272e-14 (67)
 23.1888 +|  2600: obj =   3.038230551e+03  infeas =  4.850e-14 (52)
 23.1889 +|  2800: obj =   4.316238187e+03  infeas =  2.622e-14 (36)
 23.1890 +|  3000: obj =   5.443842629e+03  infeas =  3.976e-15 (11)
 23.1891 +|  3060: obj =   5.501845888e+03  infeas =  8.806e-15 (2)
 23.1892 +OPTIMAL SOLUTION FOUND
 23.1893 +Writing basic solution to `25fv47.txt'...
 23.1894 +\end{verbatim}
 23.1895 +\end{footnotesize}
 23.1896 +
 23.1897 +\subsection{glp\_exact---solve LP problem in exact arithmetic}
 23.1898 +
 23.1899 +\subsubsection*{Synopsis}
 23.1900 +
 23.1901 +\begin{verbatim}
 23.1902 +int glp_exact(glp_prob *lp, const glp_smcp *parm);
 23.1903 +\end{verbatim}
 23.1904 +
 23.1905 +\subsubsection*{Description}
 23.1906 +
 23.1907 +The routine \verb|glp_exact| is a tentative implementation of the
 23.1908 +primal two-phase simplex method based on exact (rational) arithmetic.
 23.1909 +It is similar to the routine \verb|glp_simplex|, however, for all
 23.1910 +internal computations it uses arithmetic of rational numbers, which is
 23.1911 +exact in mathematical sense, i.e. free of round-off errors unlike
 23.1912 +floating-point arithmetic.
 23.1913 +
 23.1914 +Note that the routine \verb|glp_exact| uses only two control parameters
 23.1915 +passed in the structure \verb|glp_smcp|, namely, \verb|it_lim| and
 23.1916 +\verb|tm_lim|.
 23.1917 +
 23.1918 +\subsubsection*{Returns}
 23.1919 +
 23.1920 +\def\arraystretch{1}
 23.1921 +
 23.1922 +\begin{tabular}{@{}p{25mm}p{97.3mm}@{}}
 23.1923 +0 & The LP problem instance has been successfully solved. (This code
 23.1924 +does {\it not} necessarily mean that the solver has found optimal
 23.1925 +solution. It only means that the solution process was successful.) \\
 23.1926 +\verb|GLP_EBADB| & Unable to start the search, because the initial basis
 23.1927 +specified in the problem object is invalid---the number of basic
 23.1928 +(auxiliary and structural) variables is not the same as the number of
 23.1929 +rows in the problem object.\\
 23.1930 +\verb|GLP_ESING| & Unable to start the search, because the basis matrix
 23.1931 +corresponding to the initial basis is exactly singular.\\
 23.1932 +\verb|GLP_EBOUND| & Unable to start the search, because some
 23.1933 +double-bounded (auxiliary or structural) variables have incorrect
 23.1934 +bounds.\\
 23.1935 +\verb|GLP_EFAIL| & The problem instance has no rows/columns.\\
 23.1936 +\verb|GLP_EITLIM| & The search was prematurely terminated, because the
 23.1937 +simplex iteration limit has been exceeded.\\
 23.1938 +\verb|GLP_ETMLIM| & The search was prematurely terminated, because the
 23.1939 +time limit has been exceeded.\\
 23.1940 +\end{tabular}
 23.1941 +
 23.1942 +\subsubsection*{Comments}
 23.1943 +
 23.1944 +Computations in exact arithmetic are very time consuming, so solving
 23.1945 +LP problem with the routine \verb|glp_exact| from the very beginning is
 23.1946 +not a good idea. It is much better at first to find an optimal basis
 23.1947 +with the routine \verb|glp_simplex| and only then to call
 23.1948 +\verb|glp_exact|, in which case only a few simplex iterations need to
 23.1949 +be performed in exact arithmetic.
 23.1950 +
 23.1951 +\subsection{glp\_init\_smcp---initialize simplex solver control
 23.1952 +parameters}
 23.1953 +
 23.1954 +\subsubsection*{Synopsis}
 23.1955 +
 23.1956 +\begin{verbatim}
 23.1957 +int glp_init_smcp(glp_smcp *parm);
 23.1958 +\end{verbatim}
 23.1959 +
 23.1960 +\subsubsection*{Description}
 23.1961 +
 23.1962 +The routine \verb|glp_init_smcp| initializes control parameters, which
 23.1963 +are used by the simplex solver, with default values.
 23.1964 +
 23.1965 +Default values of the control parameters are stored in a \verb|glp_smcp|
 23.1966 +structure, which the parameter \verb|parm| points to.
 23.1967 +
 23.1968 +\subsection{glp\_get\_status---determine generic status of basic
 23.1969 +solution}
 23.1970 +
 23.1971 +\subsubsection*{Synopsis}
 23.1972 +
 23.1973 +\begin{verbatim}
 23.1974 +int glp_get_status(glp_prob *lp);
 23.1975 +\end{verbatim}
 23.1976 +
 23.1977 +\subsubsection*{Returns}
 23.1978 +
 23.1979 +The routine \verb|glp_get_status| reports the generic status of the
 23.1980 +current basic solution for the specified problem object as follows:
 23.1981 +
 23.1982 +\begin{tabular}{@{}ll}
 23.1983 +\verb|GLP_OPT|    & solution is optimal; \\
 23.1984 +\verb|GLP_FEAS|   & solution is feasible; \\
 23.1985 +\verb|GLP_INFEAS| & solution is infeasible; \\
 23.1986 +\verb|GLP_NOFEAS| & problem has no feasible solution; \\
 23.1987 +\verb|GLP_UNBND|  & problem has unbounded solution; \\
 23.1988 +\verb|GLP_UNDEF|  & solution is undefined. \\
 23.1989 +\end{tabular}
 23.1990 +
 23.1991 +More detailed information about the status of basic solution can be
 23.1992 +retrieved with the routines \verb|glp_get_prim_stat| and
 23.1993 +\verb|glp_get_dual_stat|.
 23.1994 +
 23.1995 +\newpage
 23.1996 +
 23.1997 +\subsection{glp\_get\_prim\_stat---retrieve status of primal basic
 23.1998 +solution}
 23.1999 +
 23.2000 +\subsubsection*{Synopsis}
 23.2001 +
 23.2002 +\begin{verbatim}
 23.2003 +int glp_get_prim_stat(glp_prob *lp);
 23.2004 +\end{verbatim}
 23.2005 +
 23.2006 +\subsubsection*{Returns}
 23.2007 +
 23.2008 +The routine \verb|glp_get_prim_stat| reports the status of the primal
 23.2009 +basic solution for the specified problem object as follows:
 23.2010 +
 23.2011 +\begin{tabular}{@{}ll}
 23.2012 +\verb|GLP_UNDEF|  & primal solution is undefined; \\
 23.2013 +\verb|GLP_FEAS|   & primal solution is feasible; \\
 23.2014 +\verb|GLP_INFEAS| & primal solution is infeasible; \\
 23.2015 +\verb|GLP_NOFEAS| & no primal feasible solution exists. \\
 23.2016 +\end{tabular}
 23.2017 +
 23.2018 +\subsection{glp\_get\_dual\_stat---retrieve status of dual basic
 23.2019 +solution}
 23.2020 +
 23.2021 +\subsubsection*{Synopsis}
 23.2022 +
 23.2023 +\begin{verbatim}
 23.2024 +int glp_get_dual_stat(glp_prob *lp);
 23.2025 +\end{verbatim}
 23.2026 +
 23.2027 +\subsubsection*{Returns}
 23.2028 +
 23.2029 +The routine \verb|glp_get_dual_stat| reports the status of the dual
 23.2030 +basic solution for the specified problem object as follows:
 23.2031 +
 23.2032 +\begin{tabular}{@{}ll}
 23.2033 +\verb|GLP_UNDEF|  & dual solution is undefined; \\
 23.2034 +\verb|GLP_FEAS|   & dual solution is feasible; \\
 23.2035 +\verb|GLP_INFEAS| & dual solution is infeasible; \\
 23.2036 +\verb|GLP_NOFEAS| & no dual feasible solution exists. \\
 23.2037 +\end{tabular}
 23.2038 +
 23.2039 +\subsection{glp\_get\_obj\_val---retrieve objective value}
 23.2040 +
 23.2041 +\subsubsection*{Synopsis}
 23.2042 +
 23.2043 +\begin{verbatim}
 23.2044 +double glp_get_obj_val(glp_prob *lp);
 23.2045 +\end{verbatim}
 23.2046 +
 23.2047 +\subsubsection*{Returns}
 23.2048 +
 23.2049 +The routine \verb|glp_get_obj_val| returns current value of the
 23.2050 +objective function.
 23.2051 +
 23.2052 +\subsection{glp\_get\_row\_stat---retrieve row status}
 23.2053 +
 23.2054 +\subsubsection*{Synopsis}
 23.2055 +
 23.2056 +\begin{verbatim}
 23.2057 +int glp_get_row_stat(glp_prob *lp, int i);
 23.2058 +\end{verbatim}
 23.2059 +
 23.2060 +\subsubsection*{Returns}
 23.2061 +
 23.2062 +The routine \verb|glp_get_row_stat| returns current status assigned to
 23.2063 +the auxiliary variable associated with \verb|i|-th row as follows:
 23.2064 +
 23.2065 +\begin{tabular}{@{}ll}
 23.2066 +\verb|GLP_BS| & basic variable; \\
 23.2067 +\verb|GLP_NL| & non-basic variable on its lower bound; \\
 23.2068 +\verb|GLP_NU| & non-basic variable on its upper bound; \\
 23.2069 +\verb|GLP_NF| & non-basic free (unbounded) variable; \\
 23.2070 +\verb|GLP_NS| & non-basic fixed variable. \\
 23.2071 +\end{tabular}
 23.2072 +
 23.2073 +\subsection{glp\_get\_row\_prim---retrieve row primal value}
 23.2074 +
 23.2075 +\subsubsection*{Synopsis}
 23.2076 +
 23.2077 +\begin{verbatim}
 23.2078 +double glp_get_row_prim(glp_prob *lp, int i);
 23.2079 +\end{verbatim}
 23.2080 +
 23.2081 +\subsubsection*{Returns}
 23.2082 +
 23.2083 +The routine \verb|glp_get_row_prim| returns primal value of the
 23.2084 +auxiliary variable associated with \verb|i|-th row.
 23.2085 +
 23.2086 +\subsection{glp\_get\_row\_dual---retrieve row dual value}
 23.2087 +
 23.2088 +\subsubsection*{Synopsis}
 23.2089 +
 23.2090 +\begin{verbatim}
 23.2091 +double glp_get_row_dual(glp_prob *lp, int i);
 23.2092 +\end{verbatim}
 23.2093 +
 23.2094 +\subsubsection*{Returns}
 23.2095 +
 23.2096 +The routine \verb|glp_get_row_dual| returns dual value (i.e. reduced
 23.2097 +cost) of the auxiliary variable associated with \verb|i|-th row.
 23.2098 +
 23.2099 +\newpage
 23.2100 +
 23.2101 +\subsection{glp\_get\_col\_stat---retrieve column status}
 23.2102 +
 23.2103 +\subsubsection*{Synopsis}
 23.2104 +
 23.2105 +\begin{verbatim}
 23.2106 +int glp_get_col_stat(glp_prob *lp, int j);
 23.2107 +\end{verbatim}
 23.2108 +
 23.2109 +\subsubsection*{Returns}
 23.2110 +
 23.2111 +The routine \verb|glp_get_col_stat| returns current status assigned to
 23.2112 +the structural variable associated with \verb|j|-th column as follows:
 23.2113 +
 23.2114 +\begin{tabular}{@{}ll}
 23.2115 +\verb|GLP_BS| & basic variable; \\
 23.2116 +\verb|GLP_NL| & non-basic variable on its lower bound; \\
 23.2117 +\verb|GLP_NU| & non-basic variable on its upper bound; \\
 23.2118 +\verb|GLP_NF| & non-basic free (unbounded) variable; \\
 23.2119 +\verb|GLP_NS| & non-basic fixed variable. \\
 23.2120 +\end{tabular}
 23.2121 +
 23.2122 +\subsection{glp\_get\_col\_prim---retrieve column primal value}
 23.2123 +
 23.2124 +\subsubsection*{Synopsis}
 23.2125 +
 23.2126 +\begin{verbatim}
 23.2127 +double glp_get_col_prim(glp_prob *lp, int j);
 23.2128 +\end{verbatim}
 23.2129 +
 23.2130 +\subsubsection*{Returns}
 23.2131 +
 23.2132 +The routine \verb|glp_get_col_prim| returns primal value of the
 23.2133 +structural variable associated with \verb|j|-th column.
 23.2134 +
 23.2135 +\subsection{glp\_get\_col\_dual---retrieve column dual value}
 23.2136 +
 23.2137 +\subsubsection*{Synopsis}
 23.2138 +
 23.2139 +\begin{verbatim}
 23.2140 +double glp_get_col_dual(glp_prob *lp, int j);
 23.2141 +\end{verbatim}
 23.2142 +
 23.2143 +\subsubsection*{Returns}
 23.2144 +
 23.2145 +The routine \verb|glp_get_col_dual| returns dual value (i.e. reduced
 23.2146 +cost) of the structural variable associated with \verb|j|-th column.
 23.2147 +
 23.2148 +\newpage
 23.2149 +
 23.2150 +\subsection{glp\_get\_unbnd\_ray---determine variable causing\\
 23.2151 +unboundedness}
 23.2152 +
 23.2153 +\subsubsection*{Synopsis}
 23.2154 +
 23.2155 +\begin{verbatim}
 23.2156 +int glp_get_unbnd_ray(glp_prob *lp);
 23.2157 +\end{verbatim}
 23.2158 +
 23.2159 +\subsubsection*{Returns}
 23.2160 +
 23.2161 +The routine \verb|glp_get_unbnd_ray| returns the number $k$ of
 23.2162 +a variable, which causes primal or dual unboundedness.
 23.2163 +If $1\leq k\leq m$, it is $k$-th auxiliary variable, and if
 23.2164 +$m+1\leq k\leq m+n$, it is $(k-m)$-th structural variable, where $m$ is
 23.2165 +the number of rows, $n$ is the number of columns in the problem object.
 23.2166 +If such variable is not defined, the routine returns 0.
 23.2167 +
 23.2168 +\subsubsection*{Comments}
 23.2169 +
 23.2170 +If it is not exactly known which version of the simplex solver
 23.2171 +detected unboundedness, i.e. whether the unboundedness is primal or
 23.2172 +dual, it is sufficient to check the status of the variable
 23.2173 +with the routine \verb|glp_get_row_stat| or \verb|glp_get_col_stat|.
 23.2174 +If the variable is non-basic, the unboundedness is primal, otherwise,
 23.2175 +if the variable is basic, the unboundedness is dual (the latter case
 23.2176 +means that the problem has no primal feasible dolution).
 23.2177 +
 23.2178 +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 23.2179 +
 23.2180 +\newpage
 23.2181 +
 23.2182 +\section{Interior-point method routines}
 23.2183 +
 23.2184 +{\it Interior-point methods} (also known as {\it barrier methods}) are
 23.2185 +more modern and powerful numerical methods for large-scale linear
 23.2186 +programming. Such methods are especially efficient for very sparse LP
 23.2187 +problems and allow solving such problems much faster than the simplex
 23.2188 +method.
 23.2189 +
 23.2190 +In brief, the GLPK interior-point solver works as follows.
 23.2191 +
 23.2192 +At first, the solver transforms the original LP to a {\it working} LP
 23.2193 +in the standard format:
 23.2194 +
 23.2195 +\medskip
 23.2196 +
 23.2197 +\noindent
 23.2198 +\hspace{.5in} minimize
 23.2199 +$$z = c_1x_{m+1} + c_2x_{m+2} + \dots + c_nx_{m+n} + c_0 \eqno (2.4)$$
 23.2200 +\hspace{.5in} subject to linear constraints
 23.2201 +$$
 23.2202 +\begin{array}{r@{\:}c@{\:}r@{\:}c@{\:}r@{\:}c@{\:}l}
 23.2203 +a_{11}x_{m+1}&+&a_{12}x_{m+2}&+ \dots +&a_{1n}x_{m+n}&=&b_1 \\
 23.2204 +a_{21}x_{m+1}&+&a_{22}x_{m+2}&+ \dots +&a_{2n}x_{m+n}&=&b_2 \\
 23.2205 +\multicolumn{7}{c}
 23.2206 +{.\ \ .\ \ .\ \ .\ \ .\ \ .\ \ .\ \ .\ \ .\ \ .\ \ .\ \ .\ \ .\ \ .} \\
 23.2207 +a_{m1}x_{m+1}&+&a_{m2}x_{m+2}&+ \dots +&a_{mn}x_{m+n}&=&b_m \\
 23.2208 +\end{array} \eqno (2.5)
 23.2209 +$$
 23.2210 +\hspace{.5in} and non-negative variables
 23.2211 +$$x_1\geq 0,\ \ x_2\geq 0,\ \ \dots,\ \ x_n\geq 0 \eqno(2.6)$$
 23.2212 +where: $z$ is the objective function; $x_1$, \dots, $x_n$ are variables;
 23.2213 +$c_1$, \dots, $c_n$ are objective coefficients; $c_0$ is a constant term
 23.2214 +of the objective function;\linebreak $a_{11}$, \dots, $a_{mn}$ are
 23.2215 +constraint coefficients; $b_1$, \dots, $b_m$ are right-hand sides.
 23.2216 +
 23.2217 +Using vector and matrix notations the working LP (2.4)---(2.6) can be
 23.2218 +written as follows:
 23.2219 +$$z=c^Tx+c_0\ \rightarrow\ \min,\eqno(2.7)$$
 23.2220 +$$Ax=b,\eqno(2.8)$$
 23.2221 +$$x\geq 0,\eqno(2.9)$$
 23.2222 +where: $x=(x_j)$ is $n$-vector of variables, $c=(c_j)$ is $n$-vector of
 23.2223 +objective coefficients, $A=(a_{ij})$ is $m\times n$-matrix of
 23.2224 +constraint coefficients, and $b=(b_i)$ is $m$-vector of right-hand
 23.2225 +sides.
 23.2226 +
 23.2227 +Karush--Kuhn--Tucker optimality conditions for LP (2.7)---(2.9) are the
 23.2228 +following:
 23.2229 +
 23.2230 +\newpage
 23.2231 +
 23.2232 +$$Ax=b,\eqno(2.10)$$
 23.2233 +$$A^T\pi+\lambda=c,\eqno(2.11)$$
 23.2234 +$$\lambda^Tx=0,\eqno(2.12)$$
 23.2235 +$$x\geq 0,\ \ \lambda\geq 0,\eqno(2.13)$$
 23.2236 +where: $\pi$ is $m$-vector of Lagrange multipliers (dual variables) for
 23.2237 +equality constraints (2.8), $\lambda$ is $n$-vector of Lagrange
 23.2238 +multipliers (dual variables) for non-negativity constraints (2.9),
 23.2239 +(2.10) is the primal feasibility condition, (2.11) is the dual
 23.2240 +feasibility condition, (2.12) is the primal-dual complementarity
 23.2241 +condition, and (2.13) is the non-negativity conditions.
 23.2242 +
 23.2243 +The main idea of the primal-dual interior-point method is based on
 23.2244 +finding a point in the primal-dual space (i.e. in the space of all
 23.2245 +primal and dual variables $x$, $\pi$, and $\lambda$), which satisfies
 23.2246 +to all optimality conditions (2.10)---(2.13). Obviously, $x$-component
 23.2247 +of such point then provides an optimal solution to the working LP
 23.2248 +(2.7)---(2.9).
 23.2249 +
 23.2250 +To find the optimal point $(x^*,\pi^*,\lambda^*)$ the interior-point
 23.2251 +method attempts to solve the system of equations (2.10)---(2.12), which
 23.2252 +is closed in the sense that the number of variables $x_j$, $\pi_i$, and
 23.2253 +$\lambda_j$ and the number equations are the same and equal to $m+2n$.
 23.2254 +Due to condition (2.12) this system of equations is non-linear, so it
 23.2255 +can be solved with a version of {\it Newton's method} provided with
 23.2256 +additional rules to keep the current point within the positive orthant
 23.2257 +as required by the non-negativity conditions (2.13).
 23.2258 +
 23.2259 +Finally, once the optimal point $(x^*,\pi^*,\lambda^*)$ has been found,
 23.2260 +the solver performs inverse transformations to recover corresponding
 23.2261 +solution to the original LP passed to the solver from the application
 23.2262 +program.
 23.2263 +
 23.2264 +\subsection{glp\_interior---solve LP problem with the interior-point
 23.2265 +method}
 23.2266 +
 23.2267 +\subsubsection*{Synopsis}
 23.2268 +
 23.2269 +\begin{verbatim}
 23.2270 +int glp_interior(glp_prob *P, const glp_iptcp *parm);
 23.2271 +\end{verbatim}
 23.2272 +
 23.2273 +\subsubsection*{Description}
 23.2274 +
 23.2275 +The routine \verb|glp_interior| is a driver to the LP solver based on
 23.2276 +the primal-dual interior-point method. This routine retrieves problem
 23.2277 +data from the specified problem object, calls the solver to solve the
 23.2278 +problem instance, and stores results of computations back into the
 23.2279 +problem object.
 23.2280 +
 23.2281 +The interior-point solver has a set of control parameters. Values of
 23.2282 +the control parameters can be passed in the structure \verb|glp_iptcp|,
 23.2283 +which the parameter \verb|parm| points to. For detailed description of
 23.2284 +this structure see paragraph ``Control parameters'' below. Before
 23.2285 +specifying some control parameters the application program should
 23.2286 +initialize the structure \verb|glp_iptcp| by default values of all
 23.2287 +control parameters using the routine \verb|glp_init_iptcp| (see the
 23.2288 +next subsection). This is needed for backward compatibility, because in
 23.2289 +the future there may appear new members in the structure
 23.2290 +\verb|glp_iptcp|.
 23.2291 +
 23.2292 +The parameter \verb|parm| can be specified as \verb|NULL|, in which
 23.2293 +case the solver uses default settings.
 23.2294 +
 23.2295 +\subsubsection*{Returns}
 23.2296 +
 23.2297 +\def\arraystretch{1}
 23.2298 +
 23.2299 +\begin{tabular}{@{}p{25mm}p{97.3mm}@{}}
 23.2300 +0 & The LP problem instance has been successfully solved. (This code
 23.2301 +does {\it not} necessarily mean that the solver has found optimal
 23.2302 +solution. It only means that the solution process was successful.) \\
 23.2303 +\verb|GLP_EFAIL| & The problem has no rows/columns.\\
 23.2304 +\verb|GLP_ENOCVG| & Very slow convergence or divergence.\\
 23.2305 +\verb|GLP_EITLIM| & Iteration limit exceeded.\\
 23.2306 +\verb|GLP_EINSTAB| & Numerical instability on solving Newtonian
 23.2307 +system.\\
 23.2308 +\end{tabular}
 23.2309 +
 23.2310 +\subsubsection*{Comments}
 23.2311 +
 23.2312 +The routine \verb|glp_interior| implements an easy version of
 23.2313 +the primal-dual interior-point method based on Mehrotra's
 23.2314 +technique.\footnote{S. Mehrotra. On the implementation of a primal-dual
 23.2315 +interior point method. SIAM J. on Optim., 2(4), pp. 575-601, 1992.}
 23.2316 +
 23.2317 +Note that currently the GLPK interior-point solver does not include
 23.2318 +many important features, in particular:
 23.2319 +
 23.2320 +$\bullet$ it is not able to process dense columns. Thus, if the
 23.2321 +constraint matrix of the LP problem has dense columns, the solving
 23.2322 +process may be inefficient;
 23.2323 +
 23.2324 +$\bullet$ it has no features against numerical instability. For some
 23.2325 +LP problems premature termination may happen if the matrix $ADA^T$
 23.2326 +becomes singular or ill-conditioned;
 23.2327 +
 23.2328 +$\bullet$ it is not able to identify the optimal basis, which
 23.2329 +corresponds to the interior-point solution found.
 23.2330 +
 23.2331 +\newpage
 23.2332 +
 23.2333 +\subsubsection*{Terminal output}
 23.2334 +
 23.2335 +Solving large LP problems may take a long time, so the solver reports
 23.2336 +some information about every interior-point iteration,\footnote{Unlike
 23.2337 +the simplex method the interior point method usually needs 30---50
 23.2338 +iterations (independently on the problem size) in order to find an
 23.2339 +optimal solution.} which is sent to the terminal. This information has
 23.2340 +the following format:
 23.2341 +
 23.2342 +\begin{verbatim}
 23.2343 +nnn: obj = fff; rpi = ppp; rdi = ddd; gap = ggg
 23.2344 +\end{verbatim}
 23.2345 +
 23.2346 +\noindent where: \verb|nnn| is iteration number, \verb|fff| is the
 23.2347 +current value of the objective function (in the case of maximization it
 23.2348 +has wrong sign), \verb|ppp| is the current relative primal
 23.2349 +infeasibility (cf. (2.10)):
 23.2350 +$$\frac{\|Ax^{(k)}-b\|}{1+\|b\|},\eqno(2.14)$$
 23.2351 +\verb|ddd| is the current relative dual infeasibility (cf. (2.11)):
 23.2352 +$$\frac{\|A^T\pi^{(k)}+\lambda^{(k)}-c\|}{1+\|c\|},\eqno(2.15)$$
 23.2353 +\verb|ggg| is the current primal-dual gap (cf. (2.12)):
 23.2354 +$$\frac{|c^Tx^{(k)}-b^T\pi^{(k)}|}{1+|c^Tx^{(k)}|},\eqno(2.16)$$
 23.2355 +and $[x^{(k)},\pi^{(k)},\lambda^{(k)}]$ is the current point on $k$-th
 23.2356 +iteration, $k=0,1,2,\dots$\ . Note that all solution components are
 23.2357 +internally scaled, so information sent to the terminal is suitable only
 23.2358 +for visual inspection.
 23.2359 +
 23.2360 +\subsubsection*{Control parameters}
 23.2361 +
 23.2362 +This paragraph describes all control parameters currently used in the
 23.2363 +interior-point solver. Symbolic names of control parameters are names of
 23.2364 +corresponding members in the structure \verb|glp_iptcp|.
 23.2365 +
 23.2366 +\medskip
 23.2367 +
 23.2368 +\noindent\begin{tabular}{@{}p{17pt}@{}p{120.5mm}@{}}
 23.2369 +\multicolumn{2}{@{}l}{{\tt int msg\_lev} (default: {\tt GLP\_MSG\_ALL})}
 23.2370 +\\
 23.2371 +&Message level for terminal output:\\
 23.2372 +&\verb|GLP_MSG_OFF|---no output;\\
 23.2373 +&\verb|GLP_MSG_ERR|---error and warning messages only;\\
 23.2374 +&\verb|GLP_MSG_ON |---normal output;\\
 23.2375 +&\verb|GLP_MSG_ALL|---full output (including informational messages).
 23.2376 +\\
 23.2377 +\end{tabular}
 23.2378 +
 23.2379 +\medskip
 23.2380 +
 23.2381 +\noindent\begin{tabular}{@{}p{17pt}@{}p{120.5mm}@{}}
 23.2382 +\multicolumn{2}{@{}l}{{\tt int ord\_alg} (default: {\tt GLP\_ORD\_AMD})}
 23.2383 +\\
 23.2384 +&Ordering algorithm used prior to Cholesky factorization:\\
 23.2385 +&\verb|GLP_ORD_NONE  |---use natural (original) ordering;\\
 23.2386 +&\verb|GLP_ORD_QMD   |---quotient minimum degree (QMD);\\
 23.2387 +&\verb|GLP_ORD_AMD   |---approximate minimum degree (AMD);\\
 23.2388 +&\verb|GLP_ORD_SYMAMD|---approximate minimum degree (SYMAMD).\\
 23.2389 +\end{tabular}
 23.2390 +
 23.2391 +\subsubsection*{Example}
 23.2392 +
 23.2393 +The following main program reads LP problem instance in fixed MPS
 23.2394 +format from file \verb|25fv47.mps|,\footnote{This instance in fixed MPS
 23.2395 +format can be found in the Netlib LP collection; see
 23.2396 +{\tt ftp://ftp.netlib.org/lp/data/}.} solves it with the interior-point
 23.2397 +solver, and writes the solution to file \verb|25fv47.txt|.
 23.2398 +
 23.2399 +\begin{footnotesize}
 23.2400 +\begin{verbatim}
 23.2401 +/* iptsamp.c */
 23.2402 +
 23.2403 +#include <stdio.h>
 23.2404 +#include <stdlib.h>
 23.2405 +#include <glpk.h>
 23.2406 +
 23.2407 +int main(void)
 23.2408 +{     glp_prob *P;
 23.2409 +      P = glp_create_prob();
 23.2410 +      glp_read_mps(P, GLP_MPS_DECK, NULL, "25fv47.mps");
 23.2411 +      glp_interior(P, NULL);
 23.2412 +      glp_print_ipt(P, "25fv47.txt");
 23.2413 +      glp_delete_prob(P);
 23.2414 +      return 0;
 23.2415 +}
 23.2416 +
 23.2417 +/* eof */
 23.2418 +\end{verbatim}
 23.2419 +\end{footnotesize}
 23.2420 +
 23.2421 +\noindent
 23.2422 +Below here is shown the terminal output from this example program.
 23.2423 +
 23.2424 +\begin{footnotesize}
 23.2425 +\begin{verbatim}
 23.2426 +Reading problem data from `25fv47.mps'...
 23.2427 +Problem: 25FV47
 23.2428 +Objective: R0000
 23.2429 +822 rows, 1571 columns, 11127 non-zeros
 23.2430 +6919 records were read
 23.2431 +Original LP has 822 row(s), 1571 column(s), and 11127 non-zero(s)
 23.2432 +Working LP has 821 row(s), 1876 column(s), and 10705 non-zero(s)
 23.2433 +Matrix A has 10705 non-zeros
 23.2434 +Matrix S = A*A' has 11895 non-zeros (upper triangle)
 23.2435 +Minimal degree ordering...
 23.2436 +Computing Cholesky factorization S = L'*L...
 23.2437 +Matrix L has 35411 non-zeros
 23.2438 +Guessing initial point...
 23.2439 +Optimization begins...
 23.2440 +  0: obj =   1.823377629e+05; rpi =  1.3e+01; rdi =  1.4e+01; gap =  9.3e-01
 23.2441 +  1: obj =   9.260045192e+04; rpi =  5.3e+00; rdi =  5.6e+00; gap =  6.8e+00
 23.2442 +  2: obj =   3.596999742e+04; rpi =  1.5e+00; rdi =  1.2e+00; gap =  1.8e+01
 23.2443 +  3: obj =   1.989627568e+04; rpi =  4.7e-01; rdi =  3.0e-01; gap =  1.9e+01
 23.2444 +  4: obj =   1.430215557e+04; rpi =  1.1e-01; rdi =  8.6e-02; gap =  1.4e+01
 23.2445 +  5: obj =   1.155716505e+04; rpi =  2.3e-02; rdi =  2.4e-02; gap =  6.8e+00
 23.2446 +  6: obj =   9.660273208e+03; rpi =  6.7e-03; rdi =  4.6e-03; gap =  3.9e+00
 23.2447 +  7: obj =   8.694348283e+03; rpi =  3.7e-03; rdi =  1.7e-03; gap =  2.0e+00
 23.2448 +  8: obj =   8.019543639e+03; rpi =  2.4e-03; rdi =  3.9e-04; gap =  1.0e+00
 23.2449 +  9: obj =   7.122676293e+03; rpi =  1.2e-03; rdi =  1.5e-04; gap =  6.6e-01
 23.2450 + 10: obj =   6.514534518e+03; rpi =  6.1e-04; rdi =  4.3e-05; gap =  4.1e-01
 23.2451 + 11: obj =   6.361572203e+03; rpi =  4.8e-04; rdi =  2.2e-05; gap =  3.0e-01
 23.2452 + 12: obj =   6.203355508e+03; rpi =  3.2e-04; rdi =  1.7e-05; gap =  2.6e-01
 23.2453 + 13: obj =   6.032943411e+03; rpi =  2.0e-04; rdi =  9.3e-06; gap =  2.1e-01
 23.2454 + 14: obj =   5.796553021e+03; rpi =  9.8e-05; rdi =  3.2e-06; gap =  1.0e-01
 23.2455 + 15: obj =   5.667032431e+03; rpi =  4.4e-05; rdi =  1.1e-06; gap =  5.6e-02
 23.2456 + 16: obj =   5.613911867e+03; rpi =  2.5e-05; rdi =  4.1e-07; gap =  3.5e-02
 23.2457 + 17: obj =   5.560572626e+03; rpi =  9.9e-06; rdi =  2.3e-07; gap =  2.1e-02
 23.2458 + 18: obj =   5.537276001e+03; rpi =  5.5e-06; rdi =  8.4e-08; gap =  1.1e-02
 23.2459 + 19: obj =   5.522746942e+03; rpi =  2.2e-06; rdi =  4.0e-08; gap =  6.7e-03
 23.2460 + 20: obj =   5.509956679e+03; rpi =  7.5e-07; rdi =  1.8e-08; gap =  2.9e-03
 23.2461 + 21: obj =   5.504571733e+03; rpi =  1.6e-07; rdi =  5.8e-09; gap =  1.1e-03
 23.2462 + 22: obj =   5.502576367e+03; rpi =  3.4e-08; rdi =  1.0e-09; gap =  2.5e-04
 23.2463 + 23: obj =   5.502057119e+03; rpi =  8.1e-09; rdi =  3.0e-10; gap =  7.7e-05
 23.2464 + 24: obj =   5.501885996e+03; rpi =  9.4e-10; rdi =  1.2e-10; gap =  2.4e-05
 23.2465 + 25: obj =   5.501852464e+03; rpi =  1.4e-10; rdi =  1.2e-11; gap =  3.0e-06
 23.2466 + 26: obj =   5.501846549e+03; rpi =  1.4e-11; rdi =  1.2e-12; gap =  3.0e-07
 23.2467 + 27: obj =   5.501845954e+03; rpi =  1.4e-12; rdi =  1.2e-13; gap =  3.0e-08
 23.2468 + 28: obj =   5.501845895e+03; rpi =  1.5e-13; rdi =  1.2e-14; gap =  3.0e-09
 23.2469 +OPTIMAL SOLUTION FOUND
 23.2470 +Writing interior-point solution to `25fv47.txt'...
 23.2471 +\end{verbatim}
 23.2472 +\end{footnotesize}
 23.2473 +
 23.2474 +\subsection{glp\_init\_iptcp---initialize interior-point solver control
 23.2475 +parameters}
 23.2476 +
 23.2477 +\subsubsection*{Synopsis}
 23.2478 +
 23.2479 +\begin{verbatim}
 23.2480 +int glp_init_iptcp(glp_iptcp *parm);
 23.2481 +\end{verbatim}
 23.2482 +
 23.2483 +\subsubsection*{Description}
 23.2484 +
 23.2485 +The routine \verb|glp_init_iptcp| initializes control parameters, which
 23.2486 +are used by the interior-point solver, with default values.
 23.2487 +
 23.2488 +Default values of the control parameters are stored in the structure
 23.2489 +\verb|glp_iptcp|, which the parameter \verb|parm| points to.
 23.2490 +
 23.2491 +\subsection{glp\_ipt\_status---determine solution status}
 23.2492 +
 23.2493 +\subsubsection*{Synopsis}
 23.2494 +
 23.2495 +\begin{verbatim}
 23.2496 +int glp_ipt_status(glp_prob *lp);
 23.2497 +\end{verbatim}
 23.2498 +
 23.2499 +\subsubsection*{Returns}
 23.2500 +
 23.2501 +The routine \verb|glp_ipt_status| reports the status of a solution
 23.2502 +found by the interior-point solver as follows:
 23.2503 +
 23.2504 +\begin{tabular}{@{}p{25mm}p{91.3mm}@{}}
 23.2505 +\verb|GLP_UNDEF| & interior-point solution is undefined. \\
 23.2506 +\verb|GLP_OPT|   & interior-point solution is optimal. \\
 23.2507 +\verb|GLP_INFEAS|& interior-point solution is infeasible. \\
 23.2508 +\verb|GLP_NOFEAS|& no feasible primal-dual solution exists.\\
 23.2509 +\end{tabular}
 23.2510 +
 23.2511 +\subsection{glp\_ipt\_obj\_val---retrieve objective value}
 23.2512 +
 23.2513 +\subsubsection*{Synopsis}
 23.2514 +
 23.2515 +\begin{verbatim}
 23.2516 +double glp_ipt_obj_val(glp_prob *lp);
 23.2517 +\end{verbatim}
 23.2518 +
 23.2519 +\subsubsection*{Returns}
 23.2520 +
 23.2521 +The routine \verb|glp_ipt_obj_val| returns value of the objective
 23.2522 +function for interior-point solution.
 23.2523 +
 23.2524 +\subsection{glp\_ipt\_row\_prim---retrieve row primal value}
 23.2525 +
 23.2526 +\subsubsection*{Synopsis}
 23.2527 +
 23.2528 +\begin{verbatim}
 23.2529 +double glp_ipt_row_prim(glp_prob *lp, int i);
 23.2530 +\end{verbatim}
 23.2531 +
 23.2532 +\subsubsection*{Returns}
 23.2533 +
 23.2534 +The routine \verb|glp_ipt_row_prim| returns primal value of the
 23.2535 +auxiliary variable associated with \verb|i|-th row.
 23.2536 +
 23.2537 +\newpage
 23.2538 +
 23.2539 +\subsection{glp\_ipt\_row\_dual---retrieve row dual value}
 23.2540 +
 23.2541 +\subsubsection*{Synopsis}
 23.2542 +
 23.2543 +\begin{verbatim}
 23.2544 +double glp_ipt_row_dual(glp_prob *lp, int i);
 23.2545 +\end{verbatim}
 23.2546 +
 23.2547 +\subsubsection*{Returns}
 23.2548 +
 23.2549 +The routine \verb|glp_ipt_row_dual| returns dual value (i.e. reduced
 23.2550 +cost) of the auxiliary variable associated with \verb|i|-th row.
 23.2551 +
 23.2552 +\subsection{glp\_ipt\_col\_prim---retrieve column primal value}
 23.2553 +
 23.2554 +\subsubsection*{Synopsis}
 23.2555 +
 23.2556 +\begin{verbatim}
 23.2557 +double glp_ipt_col_prim(glp_prob *lp, int j);
 23.2558 +\end{verbatim}
 23.2559 +
 23.2560 +\subsubsection*{Returns}
 23.2561 +
 23.2562 +The routine \verb|glp_ipt_col_prim| returns primal value of the
 23.2563 +structural variable associated with \verb|j|-th column.
 23.2564 +
 23.2565 +\subsection{glp\_ipt\_col\_dual---retrieve column dual value}
 23.2566 +
 23.2567 +\subsubsection*{Synopsis}
 23.2568 +
 23.2569 +\begin{verbatim}
 23.2570 +double glp_ipt_col_dual(glp_prob *lp, int j);
 23.2571 +\end{verbatim}
 23.2572 +
 23.2573 +\subsubsection*{Returns}
 23.2574 +
 23.2575 +The routine \verb|glp_ipt_col_dual| returns dual value (i.e. reduced
 23.2576 +cost) of the structural variable associated with \verb|j|-th column.
 23.2577 +
 23.2578 +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 23.2579 +
 23.2580 +\newpage
 23.2581 +
 23.2582 +\section{Mixed integer programming routines}
 23.2583 +
 23.2584 +\subsection{glp\_set\_col\_kind---set (change) column kind}
 23.2585 +
 23.2586 +\subsubsection*{Synopsis}
 23.2587 +
 23.2588 +\begin{verbatim}
 23.2589 +void glp_set_col_kind(glp_prob *mip, int j, int kind);
 23.2590 +\end{verbatim}
 23.2591 +
 23.2592 +\subsubsection*{Description}
 23.2593 +
 23.2594 +The routine \verb|glp_set_col_kind| sets (changes) the kind of
 23.2595 +\verb|j|-th column (structural variable) as specified by the parameter
 23.2596 +\verb|kind|:
 23.2597 +
 23.2598 +\begin{tabular}{@{}ll}
 23.2599 +\verb|GLP_CV| & continuous variable; \\
 23.2600 +\verb|GLP_IV| & integer variable; \\
 23.2601 +\verb|GLP_BV| & binary variable. \\
 23.2602 +\end{tabular}
 23.2603 +
 23.2604 +%If a column is set to \verb|GLP_IV|, its bounds must be exact integer
 23.2605 +%numbers with no tolerance, such that the condition
 23.2606 +%\verb|bnd == floor(bnd)| would hold.
 23.2607 +
 23.2608 +Setting a column to \verb|GLP_BV| has the same effect as if it were
 23.2609 +set to \verb|GLP_IV|, its lower bound were set 0, and its upper bound
 23.2610 +were set to 1.
 23.2611 +
 23.2612 +\subsection{glp\_get\_col\_kind---retrieve column kind}
 23.2613 +
 23.2614 +\subsubsection*{Synopsis}
 23.2615 +
 23.2616 +\begin{verbatim}
 23.2617 +int glp_get_col_kind(glp_prob *mip, int j);
 23.2618 +\end{verbatim}
 23.2619 +
 23.2620 +\subsubsection*{Returns}
 23.2621 +
 23.2622 +The routine \verb|glp_get_col_kind| returns the kind of \verb|j|-th
 23.2623 +column (structural variable) as follows:
 23.2624 +
 23.2625 +\begin{tabular}{@{}ll}
 23.2626 +\verb|GLP_CV| & continuous variable; \\
 23.2627 +\verb|GLP_IV| & integer variable; \\
 23.2628 +\verb|GLP_BV| & binary variable. \\
 23.2629 +\end{tabular}
 23.2630 +
 23.2631 +\subsection{glp\_get\_num\_int---retrieve number of integer columns}
 23.2632 +
 23.2633 +\subsubsection*{Synopsis}
 23.2634 +
 23.2635 +\begin{verbatim}
 23.2636 +int glp_get_num_int(glp_prob *mip);
 23.2637 +\end{verbatim}
 23.2638 +
 23.2639 +\subsubsection*{Returns}
 23.2640 +
 23.2641 +The routine \verb|glp_get_num_int| returns the number of columns
 23.2642 +(structural variables), which are marked as integer. Note that this
 23.2643 +number {\it does} include binary columns.
 23.2644 +
 23.2645 +\subsection{glp\_get\_num\_bin---retrieve number of binary columns}
 23.2646 +
 23.2647 +\subsubsection*{Synopsis}
 23.2648 +
 23.2649 +\begin{verbatim}
 23.2650 +int glp_get_num_bin(glp_prob *mip);
 23.2651 +\end{verbatim}
 23.2652 +
 23.2653 +\subsubsection*{Returns}
 23.2654 +
 23.2655 +The routine \verb|glp_get_num_bin| returns the number of columns
 23.2656 +(structural variables), which are marked as integer and whose lower
 23.2657 +bound is zero and upper bound is one.
 23.2658 +
 23.2659 +\subsection{glp\_intopt---solve MIP problem with the branch-and-cut
 23.2660 +method}
 23.2661 +
 23.2662 +\subsubsection*{Synopsis}
 23.2663 +
 23.2664 +\begin{verbatim}
 23.2665 +int glp_intopt(glp_prob *mip, const glp_iocp *parm);
 23.2666 +\end{verbatim}
 23.2667 +
 23.2668 +\subsubsection*{Description}
 23.2669 +
 23.2670 +The routine \verb|glp_intopt| is a driver to the MIP solver based on
 23.2671 +the branch-and-cut method, which is a hybrid of branch-and-bound and
 23.2672 +cutting plane methods.
 23.2673 +
 23.2674 +If the presolver is disabled (see paragraph ``Control parameters''
 23.2675 +below), on entry to the routine \verb|glp_intopt| the problem object,
 23.2676 +which the parameter \verb|mip| points to, should contain optimal
 23.2677 +solution to LP relaxation (it can be obtained, for example, with the
 23.2678 +routine \verb|glp_simplex|). Otherwise, if the presolver is enabled, it
 23.2679 +is not necessary.
 23.2680 +
 23.2681 +The MIP solver has a set of control parameters. Values of the control
 23.2682 +parameters can be passed in the structure \verb|glp_iocp|, which the
 23.2683 +parameter \verb|parm| points to. For detailed description of this
 23.2684 +structure see paragraph ``Control parameters'' below. Before specifying
 23.2685 +some control parameters the application program should initialize the
 23.2686 +structure \verb|glp_iocp| by default values of all control parameters
 23.2687 +using the routine \verb|glp_init_iocp| (see the next subsection). This
 23.2688 +is needed for backward compatibility, because in the future there may
 23.2689 +appear new members in the structure \verb|glp_iocp|.
 23.2690 +
 23.2691 +The parameter \verb|parm| can be specified as \verb|NULL|, in which case
 23.2692 +the solver uses default settings.
 23.2693 +
 23.2694 +Note that the GLPK branch-and-cut solver is not perfect, so it is unable
 23.2695 +to solve hard or very large scale MIP instances for a reasonable time.
 23.2696 +
 23.2697 +\subsubsection*{Returns}
 23.2698 +
 23.2699 +\def\arraystretch{1}
 23.2700 +
 23.2701 +\begin{tabular}{@{}p{25mm}p{97.3mm}@{}}
 23.2702 +0 & The MIP problem instance has been successfully solved. (This code
 23.2703 +does {\it not} necessarily mean that the solver has found optimal
 23.2704 +solution. It only means that the solution process was successful.) \\
 23.2705 +\verb|GLP_EBOUND| & Unable to start the search, because some
 23.2706 +double-bounded variables have incorrect bounds or some integer variables
 23.2707 +have non-integer (fractional) bounds.\\
 23.2708 +\verb|GLP_EROOT| & Unable to start the search, because optimal basis for
 23.2709 +initial LP relaxation is not provided. (This code may appear only if the
 23.2710 +presolver is disabled.)\\
 23.2711 +\verb|GLP_ENOPFS| & Unable to start the search, because LP relaxation
 23.2712 +of the MIP problem instance has no primal feasible solution. (This code
 23.2713 +may appear only if the presolver is enabled.)\\
 23.2714 +\verb|GLP_ENODFS| & Unable to start the search, because LP relaxation
 23.2715 +of the MIP problem instance has no dual feasible solution. In other
 23.2716 +word, this code means that if the LP relaxation has at least one primal
 23.2717 +feasible solution, its optimal solution is unbounded, so if the MIP
 23.2718 +problem has at least one integer feasible solution, its (integer)
 23.2719 +optimal solution is also unbounded. (This code may appear only if the
 23.2720 +presolver is enabled.)\\
 23.2721 +\verb|GLP_EFAIL| & The search was prematurely terminated due to the
 23.2722 +solver failure.\\
 23.2723 +\verb|GLP_EMIPGAP| & The search was prematurely terminated, because the
 23.2724 +relative mip gap tolerance has been reached.\\
 23.2725 +\verb|GLP_ETMLIM| & The search was prematurely terminated, because the
 23.2726 +time limit has been exceeded.\\
 23.2727 +\verb|GLP_ESTOP| & The search was prematurely terminated by application.
 23.2728 +(This code may appear only if the advanced solver interface is used.)\\
 23.2729 +\end{tabular}
 23.2730 +
 23.2731 +\subsubsection*{Built-in MIP presolver}
 23.2732 +
 23.2733 +The branch-and-cut solver has {\it built-in MIP presolver}. It is
 23.2734 +a subprogram that transforms the original MIP problem specified in the
 23.2735 +problem object to an equivalent MIP problem, which may be easier for
 23.2736 +solving with the branch-and-cut method than the original one. For
 23.2737 +example, the presolver can remove redundant constraints and variables,
 23.2738 +whose optimal values are known, perform bound and coefficient reduction,
 23.2739 +etc. Once the transformed MIP problem has been solved, the presolver
 23.2740 +transforms its solution back to corresponding solution of the original
 23.2741 +problem.
 23.2742 +
 23.2743 +Presolving is an optional feature of the routine \verb|glp_intopt|, and
 23.2744 +by default it is disabled. In order to enable the MIP presolver, the
 23.2745 +control parameter \verb|presolve| should be set to \verb|GLP_ON| (see
 23.2746 +paragraph ``Control parameters'' below).
 23.2747 +
 23.2748 +\subsubsection*{Advanced solver interface}
 23.2749 +
 23.2750 +The routine \verb|glp_intopt| allows the user to control the
 23.2751 +branch-and-cut search by passing to the solver a user-defined callback
 23.2752 +routine. For more details see Chapter ``Branch-and-Cut API Routines''.
 23.2753 +
 23.2754 +\subsubsection*{Terminal output}
 23.2755 +
 23.2756 +Solving a MIP problem may take a long time, so the solver reports some
 23.2757 +information about best known solutions, which is sent to the terminal.
 23.2758 +This information has the following format:
 23.2759 +
 23.2760 +\begin{verbatim}
 23.2761 ++nnn: mip = xxx <rho> yyy gap (ppp; qqq)
 23.2762 +\end{verbatim}
 23.2763 +
 23.2764 +\noindent
 23.2765 +where: `\verb|nnn|' is the simplex iteration number; `\verb|xxx|' is a
 23.2766 +value of the objective function for the best known integer feasible
 23.2767 +solution (if no integer feasible solution has been found yet,
 23.2768 +`\verb|xxx|' is the text `\verb|not found yet|'); `\verb|rho|' is the
 23.2769 +string `\verb|>=|' (in case of minimization) or `\verb|<=|' (in case of
 23.2770 +maximization); `\verb|yyy|' is a global bound for exact integer optimum
 23.2771 +(i.e. the exact integer optimum is always in the range from `\verb|xxx|'
 23.2772 +to `\verb|yyy|'); `\verb|gap|' is the relative mip gap, in percents,
 23.2773 +computed as $gap=|xxx-yyy|/(|xxx|+{\tt DBL\_EPSILON})\cdot 100\%$ (if
 23.2774 +$gap$ is greater than $999.9\%$, it is not printed); `\verb|ppp|' is the
 23.2775 +number of subproblems in the active list, `\verb|qqq|' is the number of
 23.2776 +subproblems which have been already fathomed and therefore removed from
 23.2777 +the branch-and-bound search tree.
 23.2778 +
 23.2779 +\subsubsection{Control parameters}
 23.2780 +
 23.2781 +This paragraph describes all control parameters currently used in the
 23.2782 +MIP solver. Symbolic names of control parameters are names of
 23.2783 +corresponding members in the structure \verb|glp_iocp|.
 23.2784 +
 23.2785 +\medskip
 23.2786 +
 23.2787 +\noindent\begin{tabular}{@{}p{17pt}@{}p{120.5mm}@{}}
 23.2788 +\multicolumn{2}{@{}l}{{\tt int msg\_lev} (default: {\tt GLP\_MSG\_ALL})}
 23.2789 +\\
 23.2790 +&Message level for terminal output:\\
 23.2791 +&\verb|GLP_MSG_OFF|---no output;\\
 23.2792 +&\verb|GLP_MSG_ERR|---error and warning messages only;\\
 23.2793 +&\verb|GLP_MSG_ON |---normal output;\\
 23.2794 +&\verb|GLP_MSG_ALL|---full output (including informational messages).
 23.2795 +\\
 23.2796 +\end{tabular}
 23.2797 +
 23.2798 +\medskip
 23.2799 +
 23.2800 +\noindent\begin{tabular}{@{}p{17pt}@{}p{120.5mm}@{}}
 23.2801 +\multicolumn{2}{@{}l}{{\tt int br\_tech} (default: {\tt GLP\_BR\_DTH})}
 23.2802 +\\
 23.2803 +&Branching technique option:\\
 23.2804 +&\verb|GLP_BR_FFV|---first fractional variable;\\
 23.2805 +&\verb|GLP_BR_LFV|---last fractional variable;\\
 23.2806 +&\verb|GLP_BR_MFV|---most fractional variable;\\
 23.2807 +&\verb|GLP_BR_DTH|---heuristic by Driebeck and Tomlin;\\
 23.2808 +&\verb|GLP_BR_PCH|---hybrid pseudocost heuristic.\\
 23.2809 +\end{tabular}
 23.2810 +
 23.2811 +\medskip
 23.2812 +
 23.2813 +\noindent\begin{tabular}{@{}p{17pt}@{}p{120.5mm}@{}}
 23.2814 +\multicolumn{2}{@{}l}{{\tt int bt\_tech} (default: {\tt GLP\_BT\_BLB})}
 23.2815 +\\
 23.2816 +&Backtracking technique option:\\
 23.2817 +&\verb|GLP_BT_DFS|---depth first search;\\
 23.2818 +&\verb|GLP_BT_BFS|---breadth first search;\\
 23.2819 +&\verb|GLP_BT_BLB|---best local bound;\\
 23.2820 +&\verb|GLP_BT_BPH|---best projection heuristic.\\
 23.2821 +\end{tabular}
 23.2822 +
 23.2823 +\medskip
 23.2824 +
 23.2825 +\noindent\begin{tabular}{@{}p{17pt}@{}p{120.5mm}@{}}
 23.2826 +\multicolumn{2}{@{}l}{{\tt int pp\_tech} (default: {\tt GLP\_PP\_ALL})}
 23.2827 +\\
 23.2828 +&Preprocessing technique option:\\
 23.2829 +&\verb|GLP_PP_NONE|---disable preprocessing;\\
 23.2830 +&\verb|GLP_PP_ROOT|---perform preprocessing only on the root level;\\
 23.2831 +&\verb|GLP_PP_ALL |---perform preprocessing on all levels.\\
 23.2832 +\end{tabular}
 23.2833 +
 23.2834 +\medskip
 23.2835 +
 23.2836 +\noindent\begin{tabular}{@{}p{17pt}@{}p{120.5mm}@{}}
 23.2837 +\multicolumn{2}{@{}l}{{\tt int fp\_heur} (default: {\tt GLP\_OFF})}
 23.2838 +\\
 23.2839 +&Feasibility pump heuristic option:\\
 23.2840 +&\verb|GLP_ON |---enable applying the feasibility pump heuristic;\\
 23.2841 +&\verb|GLP_OFF|---disable applying the feasibility pump heuristic.\\
 23.2842 +\end{tabular}
 23.2843 +
 23.2844 +\medskip
 23.2845 +
 23.2846 +\noindent\begin{tabular}{@{}p{17pt}@{}p{120.5mm}@{}}
 23.2847 +\multicolumn{2}{@{}l}{{\tt int gmi\_cuts} (default: {\tt GLP\_OFF})}\\
 23.2848 +&Gomory's mixed integer cut option:\\
 23.2849 +&\verb|GLP_ON |---enable generating Gomory's cuts;\\
 23.2850 +&\verb|GLP_OFF|---disable generating Gomory's cuts.\\
 23.2851 +\end{tabular}
 23.2852 +
 23.2853 +\medskip
 23.2854 +
 23.2855 +\noindent\begin{tabular}{@{}p{17pt}@{}p{120.5mm}@{}}
 23.2856 +\multicolumn{2}{@{}l}{{\tt int mir\_cuts} (default: {\tt GLP\_OFF})}\\
 23.2857 +&Mixed integer rounding (MIR) cut option:\\
 23.2858 +&\verb|GLP_ON |---enable generating MIR cuts;\\
 23.2859 +&\verb|GLP_OFF|---disable generating MIR cuts.\\
 23.2860 +\end{tabular}
 23.2861 +
 23.2862 +\medskip
 23.2863 +
 23.2864 +\noindent\begin{tabular}{@{}p{17pt}@{}p{120.5mm}@{}}
 23.2865 +\multicolumn{2}{@{}l}{{\tt int cov\_cuts} (default: {\tt GLP\_OFF})}\\
 23.2866 +&Mixed cover cut option:\\
 23.2867 +&\verb|GLP_ON |---enable generating mixed cover cuts;\\
 23.2868 +&\verb|GLP_OFF|---disable generating mixed cover cuts.\\
 23.2869 +\end{tabular}
 23.2870 +
 23.2871 +\medskip
 23.2872 +
 23.2873 +\noindent\begin{tabular}{@{}p{17pt}@{}p{120.5mm}@{}}
 23.2874 +\multicolumn{2}{@{}l}{{\tt int clq\_cuts} (default: {\tt GLP\_OFF})}\\
 23.2875 +&Clique cut option:\\
 23.2876 +&\verb|GLP_ON |---enable generating clique cuts;\\
 23.2877 +&\verb|GLP_OFF|---disable generating clique cuts.\\
 23.2878 +\end{tabular}
 23.2879 +
 23.2880 +\medskip
 23.2881 +
 23.2882 +\noindent\begin{tabular}{@{}p{17pt}@{}p{120.5mm}@{}}
 23.2883 +\multicolumn{2}{@{}l}{{\tt double tol\_int} (default: {\tt 1e-5})}\\
 23.2884 +&Absolute tolerance used to check if optimal solution to the current LP
 23.2885 +relaxation is integer feasible. (Do not change this parameter without
 23.2886 +detailed understanding its purpose.)\\
 23.2887 +\end{tabular}
 23.2888 +
 23.2889 +\medskip
 23.2890 +
 23.2891 +\noindent\begin{tabular}{@{}p{17pt}@{}p{120.5mm}@{}}
 23.2892 +\multicolumn{2}{@{}l}{{\tt double tol\_obj} (default: {\tt 1e-7})}\\
 23.2893 +&Relative tolerance used to check if the objective value in optimal
 23.2894 +solution to the current LP relaxation is not better than in the best
 23.2895 +known integer feasible solution. (Do not change this parameter without
 23.2896 +detailed understanding its purpose.)\\
 23.2897 +\end{tabular}
 23.2898 +
 23.2899 +\medskip
 23.2900 +
 23.2901 +\noindent\begin{tabular}{@{}p{17pt}@{}p{120.5mm}@{}}
 23.2902 +\multicolumn{2}{@{}l}{{\tt double mip\_gap} (default: {\tt 0.0})}\\
 23.2903 +&The relative mip gap tolerance. If the relative mip gap for currently
 23.2904 +known best integer feasible solution falls below this tolerance, the
 23.2905 +solver terminates the search. This allows obtainig suboptimal integer
 23.2906 +feasible solutions if solving the problem to optimality takes too long
 23.2907 +time.\\
 23.2908 +\end{tabular}
 23.2909 +
 23.2910 +\medskip
 23.2911 +
 23.2912 +\noindent\begin{tabular}{@{}p{17pt}@{}p{120.5mm}@{}}
 23.2913 +\multicolumn{2}{@{}l}{{\tt int tm\_lim} (default: {\tt INT\_MAX})}\\
 23.2914 +&Searching time limit, in milliseconds.\\
 23.2915 +\end{tabular}
 23.2916 +
 23.2917 +\medskip
 23.2918 +
 23.2919 +\noindent\begin{tabular}{@{}p{17pt}@{}p{120.5mm}@{}}
 23.2920 +\multicolumn{2}{@{}l}{{\tt int out\_frq} (default: {\tt 5000})}\\
 23.2921 +&Output frequency, in milliseconds. This parameter specifies how
 23.2922 +frequently the solver sends information about the solution process to
 23.2923 +the terminal.\\
 23.2924 +\end{tabular}
 23.2925 +
 23.2926 +\medskip
 23.2927 +
 23.2928 +\noindent\begin{tabular}{@{}p{17pt}@{}p{120.5mm}@{}}
 23.2929 +\multicolumn{2}{@{}l}{{\tt int out\_dly} (default: {\tt 10000})}\\
 23.2930 +&Output delay, in milliseconds. This parameter specifies how long the
 23.2931 +solver should delay sending information about solution of the current
 23.2932 +LP relaxation with the simplex method to the terminal.\\
 23.2933 +\end{tabular}
 23.2934 +
 23.2935 +\medskip
 23.2936 +
 23.2937 +\noindent\begin{tabular}{@{}p{17pt}@{}p{120.5mm}@{}}
 23.2938 +\multicolumn{2}{@{}l}
 23.2939 +{{\tt void (*cb\_func)(glp\_tree *tree, void *info)}
 23.2940 +(default: {\tt NULL})}\\
 23.2941 +&Entry point to the user-defined callback routine. \verb|NULL| means
 23.2942 +the advanced solver interface is not used. For more details see Chapter
 23.2943 +``Branch-and-Cut API Routines''.\\
 23.2944 +\end{tabular}
 23.2945 +
 23.2946 +\medskip
 23.2947 +
 23.2948 +\noindent\begin{tabular}{@{}p{17pt}@{}p{120.5mm}@{}}
 23.2949 +\multicolumn{2}{@{}l}{{\tt void *cb\_info} (default: {\tt NULL})}\\
 23.2950 +&Transit pointer passed to the routine \verb|cb_func| (see above).\\
 23.2951 +\end{tabular}
 23.2952 +
 23.2953 +\medskip
 23.2954 +
 23.2955 +\noindent\begin{tabular}{@{}p{17pt}@{}p{120.5mm}@{}}
 23.2956 +\multicolumn{2}{@{}l}{{\tt int cb\_size} (default: {\tt 0})}\\
 23.2957 +&The number of extra (up to 256) bytes allocated for each node of the
 23.2958 +branch-and-bound tree to store application-specific data. On creating
 23.2959 +a node these bytes are initialized by binary zeros.\\
 23.2960 +\end{tabular}
 23.2961 +
 23.2962 +\medskip
 23.2963 +
 23.2964 +\noindent\begin{tabular}{@{}p{17pt}@{}p{120.5mm}@{}}
 23.2965 +\multicolumn{2}{@{}l}{{\tt int presolve} (default: {\tt GLP\_OFF})}\\
 23.2966 +&MIP presolver option:\\
 23.2967 +&\verb|GLP_ON |---enable using the MIP presolver;\\
 23.2968 +&\verb|GLP_OFF|---disable using the MIP presolver.\\
 23.2969 +\end{tabular}
 23.2970 +
 23.2971 +\medskip
 23.2972 +
 23.2973 +\noindent\begin{tabular}{@{}p{17pt}@{}p{120.5mm}@{}}
 23.2974 +\multicolumn{2}{@{}l}{{\tt int binarize} (default: {\tt GLP\_OFF})}\\
 23.2975 +&Binarization option (used only if the presolver is enabled):\\
 23.2976 +&\verb|GLP_ON |---replace general integer variables by binary ones;\\
 23.2977 +&\verb|GLP_OFF|---do not use binarization.\\
 23.2978 +\end{tabular}
 23.2979 +
 23.2980 +\subsection{glp\_init\_iocp---initialize integer optimizer control
 23.2981 +parameters}
 23.2982 +
 23.2983 +\subsubsection*{Synopsis}
 23.2984 +
 23.2985 +\begin{verbatim}
 23.2986 +void glp_init_iocp(glp_iocp *parm);
 23.2987 +\end{verbatim}
 23.2988 +
 23.2989 +\subsubsection*{Description}
 23.2990 +
 23.2991 +The routine \verb|glp_init_iocp| initializes control parameters, which
 23.2992 +are used by the branch-and-cut solver, with default values.
 23.2993 +
 23.2994 +Default values of the control parameters are stored in a \verb|glp_iocp|
 23.2995 +structure, which the parameter \verb|parm| points to.
 23.2996 +
 23.2997 +\subsection{glp\_mip\_status---determine status of MIP solution}
 23.2998 +
 23.2999 +\subsubsection*{Synopsis}
 23.3000 +
 23.3001 +\begin{verbatim}
 23.3002 +int glp_mip_status(glp_prob *mip);
 23.3003 +\end{verbatim}
 23.3004 +
 23.3005 +\subsubsection*{Returns}
 23.3006 +
 23.3007 +The routine \verb|glp_mip_status| reports the status of a MIP solution
 23.3008 +found by the MIP solver as follows:
 23.3009 +
 23.3010 +\smallskip
 23.3011 +
 23.3012 +\begin{tabular}{@{}p{25mm}p{91.3mm}@{}}
 23.3013 +\verb|GLP_UNDEF| & MIP solution is undefined. \\
 23.3014 +\verb|GLP_OPT|   & MIP solution is integer optimal. \\
 23.3015 +\verb|GLP_FEAS|  & MIP solution is integer feasible, however, its
 23.3016 +   optimality (or non-optimality) has not been proven, perhaps due to
 23.3017 +   premature termination of the search. \\
 23.3018 +\end{tabular}
 23.3019 +
 23.3020 +\begin{tabular}{@{}p{25mm}p{91.3mm}@{}}
 23.3021 +\verb|GLP_NOFEAS| & problem has no integer feasible solution (proven by
 23.3022 +   the solver). \\
 23.3023 +\end{tabular}
 23.3024 +
 23.3025 +\subsection{glp\_mip\_obj\_val---retrieve objective value}
 23.3026 +
 23.3027 +\subsubsection*{Synopsis}
 23.3028 +
 23.3029 +\begin{verbatim}
 23.3030 +double glp_mip_obj_val(glp_prob *mip);
 23.3031 +\end{verbatim}
 23.3032 +
 23.3033 +\subsubsection*{Returns}
 23.3034 +
 23.3035 +The routine \verb|glp_mip_obj_val| returns value of the objective
 23.3036 +function for MIP solution.
 23.3037 +
 23.3038 +\subsection{glp\_mip\_row\_val---retrieve row value}
 23.3039 +
 23.3040 +\subsubsection*{Synopsis}
 23.3041 +
 23.3042 +\begin{verbatim}
 23.3043 +double glp_mip_row_val(glp_prob *mip, int i);
 23.3044 +\end{verbatim}
 23.3045 +
 23.3046 +\subsubsection*{Returns}
 23.3047 +
 23.3048 +The routine \verb|glp_mip_row_val| returns value of the auxiliary
 23.3049 +variable associated with \verb|i|-th row for MIP solution.
 23.3050 +
 23.3051 +\subsection{glp\_mip\_col\_val---retrieve column value}
 23.3052 +
 23.3053 +\subsubsection*{Synopsis}
 23.3054 +
 23.3055 +\begin{verbatim}
 23.3056 +double glp_mip_col_val(glp_prob *mip, int j);
 23.3057 +\end{verbatim}
 23.3058 +
 23.3059 +\subsubsection*{Returns}
 23.3060 +
 23.3061 +The routine \verb|glp_mip_col_val| returns value of the structural
 23.3062 +variable associated with \verb|j|-th column for MIP solution.
 23.3063 +
 23.3064 +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 23.3065 +
 23.3066 +\newpage
 23.3067 +
 23.3068 +\section{Additional routines}
 23.3069 +
 23.3070 +\subsection{lpx\_check\_kkt---check Karush-Kuhn-Tucker optimality
 23.3071 +conditions}
 23.3072 +
 23.3073 +\subsubsection*{Synopsis}
 23.3074 +
 23.3075 +\begin{verbatim}
 23.3076 +void lpx_check_kkt(glp_prob *lp, int scaled, LPXKKT *kkt);
 23.3077 +\end{verbatim}
 23.3078 +
 23.3079 +\subsubsection*{Description}
 23.3080 +
 23.3081 +The routine \verb|lpx_check_kkt| checks Karush-Kuhn-Tucker optimality
 23.3082 +conditions for basic solution. It is assumed that both primal and dual
 23.3083 +components of basic solution are valid.
 23.3084 +
 23.3085 +If the parameter \verb|scaled| is zero, the optimality conditions are
 23.3086 +checked for the original, unscaled LP problem. Otherwise, if the
 23.3087 +parameter \verb|scaled| is non-zero, the routine checks the conditions
 23.3088 +for an internally scaled LP problem.
 23.3089 +
 23.3090 +The parameter \verb|kkt| is a pointer to the structure \verb|LPXKKT|,
 23.3091 +to which the routine stores results of the check. Members of this
 23.3092 +structure are shown in the table below.
 23.3093 +
 23.3094 +\begin{table}[h]
 23.3095 +\begin{center}
 23.3096 +\begin{tabular}{@{}c|l|l@{}}
 23.3097 +Condition & Member & Comment \\
 23.3098 +\hline
 23.3099 +(KKT.PE) & \verb|pe_ae_max| &
 23.3100 +         Largest absolute error \\
 23.3101 +         & \verb|pe_ae_row| &
 23.3102 +         Number of row with largest absolute error \\
 23.3103 +         & \verb|pe_re_max| &
 23.3104 +         Largest relative error \\
 23.3105 +         & \verb|pe_re_row| &
 23.3106 +         Number of row with largest relative error \\
 23.3107 +         & \verb|pe_quality| &
 23.3108 +         Quality of primal solution \\
 23.3109 +\hline
 23.3110 +(KKT.PB) & \verb|pb_ae_max| &
 23.3111 +         Largest absolute error \\
 23.3112 +         & \verb|pb_ae_ind| &
 23.3113 +         Number of variable with largest absolute error \\
 23.3114 +         & \verb|pb_re_max| &
 23.3115 +         Largest relative error \\
 23.3116 +         & \verb|pb_re_ind| &
 23.3117 +         Number of variable with largest relative error \\
 23.3118 +         & \verb|pb_quality| &
 23.3119 +         Quality of primal feasibility \\
 23.3120 +\hline
 23.3121 +(KKT.DE) & \verb|de_ae_max| &
 23.3122 +         Largest absolute error \\
 23.3123 +         & \verb|de_ae_col| &
 23.3124 +         Number of column with largest absolute error \\
 23.3125 +         & \verb|de_re_max| &
 23.3126 +         Largest relative error \\
 23.3127 +         & \verb|de_re_col| &
 23.3128 +         Number of column with largest relative error \\
 23.3129 +         & \verb|de_quality| &
 23.3130 +         Quality of dual solution \\
 23.3131 +\hline
 23.3132 +(KKT.DB) & \verb|db_ae_max| &
 23.3133 +         Largest absolute error \\
 23.3134 +         & \verb|db_ae_ind| &
 23.3135 +         Number of variable with largest absolute error \\
 23.3136 +         & \verb|db_re_max| &
 23.3137 +         Largest relative error \\
 23.3138 +         & \verb|db_re_ind| &
 23.3139 +         Number of variable with largest relative error \\
 23.3140 +         & \verb|db_quality| &
 23.3141 +         Quality of dual feasibility \\
 23.3142 +\end{tabular}
 23.3143 +\end{center}
 23.3144 +\end{table}
 23.3145 +
 23.3146 +The routine performs all computations using only components of the
 23.3147 +given LP problem and the current basic solution.
 23.3148 +
 23.3149 +\subsubsection*{Background}
 23.3150 +
 23.3151 +The first condition checked by the routine is:
 23.3152 +$$x_R - A x_S = 0, \eqno{\rm (KKT.PE)}$$
 23.3153 +where $x_R$ is the subvector of auxiliary variables (rows), $x_S$ is the
 23.3154 +subvector of structural variables (columns), $A$ is the constraint
 23.3155 +matrix. This condition expresses the requirement that all primal
 23.3156 +variables must satisfy to the system of equality constraints of the
 23.3157 +original LP problem. In case of exact arithmetic this condition would be
 23.3158 +satisfied for any basic solution; however, in case of inexact
 23.3159 +(floating-point) arithmetic, this condition shows how accurate the
 23.3160 +primal basic solution is, that depends on accuracy of a representation
 23.3161 +of the basis matrix used by the simplex method routines.
 23.3162 +
 23.3163 +The second condition checked by the routine is:
 23.3164 +$$l_k \leq x_k \leq u_k {\rm \ \ \ for\ all}\ k=1,\dots,m+n,
 23.3165 +\eqno{\rm (KKT.PB)}$$
 23.3166 +where $x_k$ is auxiliary ($1\leq k\leq m$) or structural
 23.3167 +($m+1\leq k\leq m+n$) variable, $l_k$ and $u_k$ are, respectively,
 23.3168 +lower and upper bounds of the variable $x_k$ (including cases of
 23.3169 +infinite bounds). This condition expresses the requirement that all
 23.3170 +primal variables must satisfy to bound constraints of the original LP
 23.3171 +problem. Since in case of basic solution all non-basic variables are
 23.3172 +placed on their bounds, actually the condition (KKT.PB) needs to be
 23.3173 +checked for basic variables only. If the primal basic solution has
 23.3174 +sufficient accuracy, this condition shows primal feasibility of the
 23.3175 +solution.
 23.3176 +
 23.3177 +The third condition checked by the routine is:
 23.3178 +$${\rm grad}\;Z = c = (\tilde{A})^T \pi + d,$$
 23.3179 +where $Z$ is the objective function, $c$ is the vector of objective
 23.3180 +coefficients, $(\tilde{A})^T$ is a matrix transposed to the expanded
 23.3181 +constraint matrix $\tilde{A} = (I|-A)$, $\pi$ is a vector of Lagrange
 23.3182 +multipliers that correspond to equality constraints of the original LP
 23.3183 +problem, $d$ is a vector of Lagrange multipliers that correspond to
 23.3184 +bound constraints for all (auxiliary and structural) variables of the
 23.3185 +original LP problem. Geometrically the third condition expresses the
 23.3186 +requirement that the gradient of the objective function must belong to
 23.3187 +the orthogonal complement of a linear subspace defined by the equality
 23.3188 +and active bound constraints, i.e. that the gradient must be a linear
 23.3189 +combination of normals to the constraint planes, where Lagrange
 23.3190 +multipliers $\pi$ and $d$ are coefficients of that linear combination.
 23.3191 +
 23.3192 +To eliminate the vector $\pi$ the third condition can be rewritten as:
 23.3193 +$$
 23.3194 +\left(\begin{array}{@{}c@{}}I \\ -A^T\end{array}\right) \pi =
 23.3195 +\left(\begin{array}{@{}c@{}}d_R \\ d_S\end{array}\right) +
 23.3196 +\left(\begin{array}{@{}c@{}}c_R \\ c_S\end{array}\right),
 23.3197 +$$
 23.3198 +or, equivalently:
 23.3199 +$$
 23.3200 +\begin{array}{r@{}c@{}c}
 23.3201 +\pi + d_R&\ =\ &c_R, \\
 23.3202 +-A^T\pi + d_S&\ =\ &c_S. \\
 23.3203 +\end{array}
 23.3204 +$$
 23.3205 +Then substituting the vector $\pi$ from the first equation into the
 23.3206 +second one we have:
 23.3207 +$$A^T (d_R - c_R) + (d_S - c_S) = 0, \eqno{\rm (KKT.DE)}$$
 23.3208 +where $d_R$ is the subvector of reduced costs of auxiliary variables
 23.3209 +(rows), $d_S$ is the subvector of reduced costs of structural variables
 23.3210 +(columns), $c_R$ and $c_S$ are subvectors of objective coefficients at,
 23.3211 +respectively, auxiliary and structural variables, $A^T$ is a matrix
 23.3212 +transposed to the constraint matrix of the original LP problem. In case
 23.3213 +of exact arithmetic this condition would be satisfied for any basic
 23.3214 +solution; however, in case of inexact (floating-point) arithmetic, this
 23.3215 +condition shows how accurate the dual basic solution is, that depends on
 23.3216 +accuracy of a representation of the basis matrix used by the simplex
 23.3217 +method routines.
 23.3218 +
 23.3219 +The last, fourth condition checked by the routine is (KKT.DB):
 23.3220 +
 23.3221 +\medskip
 23.3222 +
 23.3223 +\begin{tabular}{r@{}c@{}ll}
 23.3224 +&$\ d_k\ $& $=0,$&if $x_k$ is basic or free non-basic variable \\
 23.3225 +$0\leq$&$\ d_k\ $&$<+\infty$&if $x_k$ is non-basic on its lower
 23.3226 +(minimization) \\
 23.3227 +&&&or upper (maximization) bound \\
 23.3228 +$-\infty<$&$\ d_k\ $&$\leq 0$&if $x_k$ is non-basic on its upper
 23.3229 +(minimization) \\
 23.3230 +&&&or lower (maximization) bound \\
 23.3231 +$-\infty<$&$\ d_k\ $&$<+\infty$&if $x_k$ is non-basic fixed variable \\
 23.3232 +\end{tabular}
 23.3233 +
 23.3234 +\medskip
 23.3235 +
 23.3236 +\noindent
 23.3237 +for all $k=1,\dots,m+n$, where $d_k$ is a reduced cost (Lagrange
 23.3238 +multiplier) of auxiliary ($1\leq k\leq m$) or structural
 23.3239 +($m+1\leq k\leq m+n$) variable $x_k$. Geometrically this condition
 23.3240 +expresses the requirement that constraints of the original problem must
 23.3241 +"hold" the point preventing its movement along the anti-gradient (in
 23.3242 +case of minimization) or the gradient (in case of maximization) of the
 23.3243 +objective function. Since in case of basic solution reduced costs of
 23.3244 +all basic variables are placed on their (zero) bounds, actually the
 23.3245 +condition (KKT.DB) needs to be checked for non-basic variables only.
 23.3246 +If the dual basic solution has sufficient accuracy, this condition shows
 23.3247 +dual feasibility of the solution.
 23.3248 +
 23.3249 +Should note that the complete set of Karush-Kuhn-Tucker optimality
 23.3250 +conditions also includes the fifth, so called complementary slackness
 23.3251 +condition, which expresses the requirement that at least either a primal
 23.3252 +variable $x_k$ or its dual counterpart $d_k$ must be on its bound for
 23.3253 +all $k=1,\dots,m+n$. However, being always satisfied by definition for
 23.3254 +any basic solution that condition is not checked by the routine.
 23.3255 +
 23.3256 +To check the first condition (KKT.PE) the routine computes a vector of
 23.3257 +residuals:
 23.3258 +$$g = x_R - A x_S,$$
 23.3259 +determines component of this vector that correspond to largest absolute
 23.3260 +and relative errors:
 23.3261 +
 23.3262 +\medskip
 23.3263 +
 23.3264 +\hspace{30mm}
 23.3265 +\verb|pe_ae_max| $\displaystyle{= \max_{1\leq i\leq m}|g_i|}$,
 23.3266 +
 23.3267 +\medskip
 23.3268 +
 23.3269 +\hspace{30mm}
 23.3270 +\verb|pe_re_max| $\displaystyle{= \max_{1\leq i\leq m}
 23.3271 +\frac{|g_i|}{1+|(x_R)_i|}}$,
 23.3272 +
 23.3273 +\medskip
 23.3274 +
 23.3275 +\noindent
 23.3276 +and stores these quantities and corresponding row indices to the
 23.3277 +structure \verb|LPXKKT|.
 23.3278 +
 23.3279 +To check the second condition (KKT.PB) the routine computes a vector
 23.3280 +of residuals:
 23.3281 +$$
 23.3282 +h_k = \left\{
 23.3283 +\begin{array}{ll}
 23.3284 +0,         & {\rm if}\ l_k \leq x_k \leq u_k \\
 23.3285 +x_k - l_k, & {\rm if}\ x_k < l_k \\
 23.3286 +x_k - u_k, & {\rm if}\ x_k > u_k \\
 23.3287 +\end{array}
 23.3288 +\right.
 23.3289 +$$
 23.3290 +for all $k=1,\dots,m+n$, determines components of this vector that
 23.3291 +correspond to largest absolute and relative errors:
 23.3292 +
 23.3293 +\medskip
 23.3294 +
 23.3295 +\hspace{30mm}
 23.3296 +\verb|pb_ae_max| $\displaystyle{= \max_{1\leq k \leq m+n}|h_k|}$,
 23.3297 +
 23.3298 +\medskip
 23.3299 +
 23.3300 +\hspace{30mm}
 23.3301 +\verb|pb_re_max| $\displaystyle{= \max_{1\leq k \leq m+n}
 23.3302 +\frac{|h_k|}{1+|x_k|}}$,
 23.3303 +
 23.3304 +\medskip
 23.3305 +
 23.3306 +\noindent
 23.3307 +and stores these quantities and corresponding variable indices to the
 23.3308 +structure \verb|LPXKKT|.
 23.3309 +
 23.3310 +To check the third condition (KKT.DE) the routine computes a vector of
 23.3311 +residuals:
 23.3312 +$$u = A^T (d_R - c_R) + (d_S - c_S),$$
 23.3313 +determines components of this vector that correspond to largest
 23.3314 +absolute and relative errors:
 23.3315 +
 23.3316 +\medskip
 23.3317 +
 23.3318 +\hspace{30mm}
 23.3319 +\verb|de_ae_max| $\displaystyle{= \max_{1\leq j\leq n}|u_j|}$,
 23.3320 +
 23.3321 +\medskip
 23.3322 +
 23.3323 +\hspace{30mm}
 23.3324 +\verb|de_re_max| $\displaystyle{= \max_{1\leq j\leq n}
 23.3325 +\frac{|u_j|}{1+|(d_S)_j - (c_S)_j|}}$,
 23.3326 +
 23.3327 +\medskip
 23.3328 +
 23.3329 +\noindent
 23.3330 +and stores these quantities and corresponding column indices to the
 23.3331 +structure \verb|LPXKKT|.
 23.3332 +
 23.3333 +To check the fourth condition (KKT.DB) the routine computes a vector
 23.3334 +of residuals:
 23.3335 +
 23.3336 +$$
 23.3337 +v_k = \left\{
 23.3338 +\begin{array}{ll}
 23.3339 +0,         & {\rm if}\ d_k\ {\rm has\ correct\ sign} \\
 23.3340 +d_k,       & {\rm if}\ d_k\ {\rm has\ wrong\ sign} \\
 23.3341 +\end{array}
 23.3342 +\right.
 23.3343 +$$
 23.3344 +for all $k=1,\dots,m+n$, determines components of this vector that
 23.3345 +correspond to largest absolute and relative errors:
 23.3346 +
 23.3347 +\medskip
 23.3348 +
 23.3349 +\hspace{30mm}
 23.3350 +\verb|db_ae_max| $\displaystyle{= \max_{1\leq k\leq m+n}|v_k|}$,
 23.3351 +
 23.3352 +\medskip
 23.3353 +
 23.3354 +\hspace{30mm}
 23.3355 +\verb|db_re_max| $\displaystyle{= \max_{1\leq k\leq m+n}
 23.3356 +\frac{|v_k|}{1+|d_k - c_k|}}$,
 23.3357 +
 23.3358 +\medskip
 23.3359 +
 23.3360 +\noindent
 23.3361 +and stores these quantities and corresponding variable indices to the
 23.3362 +structure \verb|LPXKKT|.
 23.3363 +
 23.3364 +Using the relative errors for all the four conditions listed above the
 23.3365 +routine
 23.3366 +\verb|lpx_check_kkt| also estimates a "quality" of the basic solution
 23.3367 +from the standpoint of these conditions and stores corresponding
 23.3368 +quality indicators to the structure \verb|LPXKKT|:
 23.3369 +
 23.3370 +\verb|pe_quality|---quality of primal solution;
 23.3371 +
 23.3372 +\verb|pb_quality|---quality of primal feasibility;
 23.3373 +
 23.3374 +\verb|de_quality|---quality of dual solution;
 23.3375 +
 23.3376 +\verb|db_quality|---quality of dual feasibility.
 23.3377 +
 23.3378 +Each of these indicators is assigned to one of the following four
 23.3379 +values:
 23.3380 +
 23.3381 +\verb|'H'| means high quality,
 23.3382 +
 23.3383 +\verb|'M'| means medium quality,
 23.3384 +
 23.3385 +\verb|'L'| means low quality, or
 23.3386 +
 23.3387 +\verb|'?'| means wrong or infeasible solution.
 23.3388 +
 23.3389 +If all the indicators show high or medium quality (for an internally
 23.3390 +scaled LP problem, i.e. when the parameter \verb|scaled| in a call to
 23.3391 +the routine \verb|lpx_check_kkt| is non-zero), the user can be sure that
 23.3392 +the obtained basic solution is quite accurate.
 23.3393 +
 23.3394 +If some of the indicators show low quality, the solution can still be
 23.3395 +considered as relevant, though an additional analysis is needed
 23.3396 +depending on which indicator shows low quality.
 23.3397 +
 23.3398 +If the indicator \verb|pe_quality| is assigned to \verb|'?'|, the
 23.3399 +primal solution is wrong. If the indicator \verb|de_quality| is assigned
 23.3400 +to \verb|'?'|, the dual solution is wrong.
 23.3401 +
 23.3402 +If the indicator \verb|db_quality| is assigned to \verb|'?'| while
 23.3403 +other indicators show a good quality, this means that the current
 23.3404 +basic solution being primal feasible is not dual feasible. Similarly,
 23.3405 +if the indicator \verb|pb_quality| is assigned to \verb|'?'| while
 23.3406 +other indicators are not, this means that the current basic solution
 23.3407 +being dual feasible is not primal feasible.
 23.3408 +
 23.3409 +%* eof *%
    24.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    24.2 +++ b/deps/glpk/doc/glpk03.tex	Sun Nov 06 20:59:10 2011 +0100
    24.3 @@ -0,0 +1,1577 @@
    24.4 +%* glpk03.tex *%
    24.5 +
    24.6 +\chapter{Utility API routines}
    24.7 +
    24.8 +\section{Problem data reading/writing routines}
    24.9 +
   24.10 +\subsection{glp\_read\_mps---read problem data in MPS format}
   24.11 +
   24.12 +\subsubsection*{Synopsis}
   24.13 +
   24.14 +\begin{verbatim}
   24.15 +int glp_read_mps(glp_prob *lp, int fmt, const void *parm,
   24.16 +      const char *fname);
   24.17 +\end{verbatim}
   24.18 +
   24.19 +\subsubsection*{Description}
   24.20 +
   24.21 +The routine \verb|glp_read_mps| reads problem data in MPS format from a
   24.22 +text file. (The MPS format is described in Appendix \ref{champs}, page
   24.23 +\pageref{champs}.)
   24.24 +
   24.25 +The parameter \verb|fmt| specifies the MPS format version as follows:
   24.26 +
   24.27 +\begin{tabular}{@{}ll}
   24.28 +\verb|GLP_MPS_DECK| & fixed (ancient) MPS format; \\
   24.29 +\verb|GLP_MPS_FILE| & free (modern) MPS format. \\
   24.30 +\end{tabular}
   24.31 +
   24.32 +The parameter \verb|parm| is reserved for use in the future and must be
   24.33 +specified as \verb|NULL|.
   24.34 +
   24.35 +The character string \verb|fname| specifies a name of the text file to
   24.36 +be read in. (If the file name ends with suffix `\verb|.gz|', the file is
   24.37 +assumed to be compressed, in which case the routine \verb|glp_read_mps|
   24.38 +decompresses it ``on the fly''.)
   24.39 +
   24.40 +Note that before reading data the current content of the problem object
   24.41 +is completely erased with the routine \verb|glp_erase_prob|.
   24.42 +
   24.43 +\subsubsection*{Returns}
   24.44 +
   24.45 +If the operation was successful, the routine \verb|glp_read_mps|
   24.46 +returns zero. Otherwise, it prints an error message and returns
   24.47 +non-zero.
   24.48 +
   24.49 +\subsection{glp\_write\_mps---write problem data in MPS format}
   24.50 +
   24.51 +\subsubsection*{Synopsis}
   24.52 +
   24.53 +\begin{verbatim}
   24.54 +int glp_write_mps(glp_prob *lp, int fmt, const void *parm,
   24.55 +      const char *fname);
   24.56 +\end{verbatim}
   24.57 +
   24.58 +\subsubsection*{Description}
   24.59 +
   24.60 +The routine \verb|glp_write_mps| writes problem data in MPS format to a
   24.61 +text file. (The MPS format is described in Appendix \ref{champs}, page
   24.62 +\pageref{champs}.)
   24.63 +
   24.64 +The parameter \verb|fmt| specifies the MPS format version as follows:
   24.65 +
   24.66 +\begin{tabular}{@{}ll}
   24.67 +\verb|GLP_MPS_DECK| & fixed (ancient) MPS format; \\
   24.68 +\verb|GLP_MPS_FILE| & free (modern) MPS format. \\
   24.69 +\end{tabular}
   24.70 +
   24.71 +The parameter \verb|parm| is reserved for use in the future and must be
   24.72 +specified as \verb|NULL|.
   24.73 +
   24.74 +The character string \verb|fname| specifies a name of the text file to
   24.75 +be written out. (If the file name ends with suffix `\verb|.gz|', the
   24.76 +file is assumed to be compressed, in which case the routine
   24.77 +\verb|glp_write_mps| performs automatic compression on writing it.)
   24.78 +
   24.79 +\subsubsection*{Returns}
   24.80 +
   24.81 +If the operation was successful, the routine \verb|glp_write_mps|
   24.82 +returns zero. Otherwise, it prints an error message and returns
   24.83 +non-zero.
   24.84 +
   24.85 +\subsection{glp\_read\_lp---read problem data in CPLEX LP format}
   24.86 +
   24.87 +\subsubsection*{Synopsis}
   24.88 +
   24.89 +\begin{verbatim}
   24.90 +int glp_read_lp(glp_prob *lp, const void *parm,
   24.91 +      const char *fname);
   24.92 +\end{verbatim}
   24.93 +
   24.94 +\subsubsection*{Description}
   24.95 +
   24.96 +The routine \verb|glp_read_lp| reads problem data in CPLEX LP format
   24.97 +from a text file. (The CPLEX LP format is described in Appendix
   24.98 +\ref{chacplex}, page \pageref{chacplex}.)
   24.99 +
  24.100 +The parameter \verb|parm| is reserved for use in the future and must be
  24.101 +specified as \verb|NULL|.
  24.102 +
  24.103 +The character string \verb|fname| specifies a name of the text file to
  24.104 +be read in. (If the file name ends with suffix `\verb|.gz|', the file is
  24.105 +assumed to be compressed, in which case the routine \verb|glp_read_lp|
  24.106 +decompresses it ``on the fly''.)
  24.107 +
  24.108 +Note that before reading data the current content of the problem object
  24.109 +is completely erased with the routine \verb|glp_erase_prob|.
  24.110 +
  24.111 +\subsubsection*{Returns}
  24.112 +
  24.113 +If the operation was successful, the routine \verb|glp_read_lp| returns
  24.114 +zero. Otherwise, it prints an error message and returns non-zero.
  24.115 +
  24.116 +\subsection{glp\_write\_lp---write problem data in CPLEX LP format}
  24.117 +
  24.118 +\subsubsection*{Synopsis}
  24.119 +
  24.120 +\begin{verbatim}
  24.121 +int glp_write_lp(glp_prob *lp, const void *parm,
  24.122 +      const char *fname);
  24.123 +\end{verbatim}
  24.124 +
  24.125 +\subsubsection*{Description}
  24.126 +
  24.127 +The routine \verb|glp_write_lp| writes problem data in CPLEX LP format
  24.128 +to a text file. (The CPLEX LP format is described in Appendix
  24.129 +\ref{chacplex}, page \pageref{chacplex}.)
  24.130 +
  24.131 +The parameter \verb|parm| is reserved for use in the future and must be
  24.132 +specified as \verb|NULL|.
  24.133 +
  24.134 +The character string \verb|fname| specifies a name of the text file to
  24.135 +be written out. (If the file name ends with suffix `\verb|.gz|', the
  24.136 +file is assumed to be compressed, in which case the routine
  24.137 +\verb|glp_write_lp| performs automatic compression on writing it.)
  24.138 +
  24.139 +\subsubsection*{Returns}
  24.140 +
  24.141 +If the operation was successful, the routine \verb|glp_write_lp|
  24.142 +returns zero. Otherwise, it prints an error message and returns
  24.143 +non-zero.
  24.144 +
  24.145 +\subsection{glp\_read\_prob---read problem data in GLPK format}
  24.146 +
  24.147 +\subsubsection*{Synopsis}
  24.148 +
  24.149 +\begin{verbatim}
  24.150 +int glp_read_prob(glp_prob *P, int flags, const char *fname);
  24.151 +\end{verbatim}
  24.152 +
  24.153 +\subsubsection*{Description}
  24.154 +
  24.155 +The routine \verb|glp_read_prob| reads problem data in the GLPK LP/MIP
  24.156 +format from a text file. (For description of the GLPK LP/MIP format see
  24.157 +below.)
  24.158 +
  24.159 +The parameter \verb|flags| is reserved for use in the future and should
  24.160 +be specified as zero.
  24.161 +
  24.162 +The character string \verb|fname| specifies a name of the text file to
  24.163 +be read in. (If the file name ends with suffix `\verb|.gz|', the file
  24.164 +is assumed to be compressed, in which case the routine
  24.165 +\verb|glp_read_prob| decompresses it ``on the fly''.)
  24.166 +
  24.167 +Note that before reading data the current content of the problem object
  24.168 +is completely erased with the routine \verb|glp_erase_prob|.
  24.169 +
  24.170 +\subsubsection*{Returns}
  24.171 +
  24.172 +If the operation was successful, the routine \verb|glp_read_prob|
  24.173 +returns zero. Otherwise, it prints an error message and returns
  24.174 +non-zero.
  24.175 +
  24.176 +\subsubsection*{GLPK LP/MIP format}
  24.177 +
  24.178 +The GLPK LP/MIP format is a DIMACS-like format.\footnote{The DIMACS
  24.179 +formats were developed by the Center for Discrete Mathematics and
  24.180 +Theoretical Computer Science (DIMACS) to facilitate exchange of problem
  24.181 +data. For details see: {\tt <http://dimacs.rutgers.edu/Challenges/>}. }
  24.182 +The file in this format is a plain ASCII text file containing lines of
  24.183 +several types described below. A line is terminated with the end-of-line
  24.184 +character. Fields in each line are separated by at least one blank
  24.185 +space. Each line begins with a one-character designator to identify the
  24.186 +line type.
  24.187 +
  24.188 +The first line of the data file must be the problem line (except
  24.189 +optional comment lines, which may precede the problem line). The last
  24.190 +line of the data file must be the end line. Other lines may follow in
  24.191 +arbitrary order, however, duplicate lines are not allowed.
  24.192 +
  24.193 +\paragraph{Comment lines.} Comment lines give human-readable
  24.194 +information about the data file and are ignored by GLPK routines.
  24.195 +Comment lines can appear anywhere in the data file. Each comment line
  24.196 +begins with the lower-case character \verb|c|.
  24.197 +
  24.198 +\begin{verbatim}
  24.199 +   c This is an example of comment line
  24.200 +\end{verbatim}
  24.201 +
  24.202 +\paragraph{Problem line.} There must be exactly one problem line in the
  24.203 +data file. This line must appear before any other lines except comment
  24.204 +lines and has the following format:
  24.205 +
  24.206 +\begin{verbatim}
  24.207 +   p CLASS DIR ROWS COLS NONZ
  24.208 +\end{verbatim}
  24.209 +
  24.210 +The lower-case letter \verb|p| specifies that this is the problem line.
  24.211 +
  24.212 +The \verb|CLASS| field defines the problem class and can contain either
  24.213 +the keyword \verb|lp| (that means linear programming problem) or
  24.214 +\verb|mip| (that means mixed integer programming problem).
  24.215 +
  24.216 +The \verb|DIR| field defines the optimization direction (that is, the
  24.217 +objective function sense) and can contain either the keyword \verb|min|
  24.218 +(that means minimization) or \verb|max| (that means maximization).
  24.219 +
  24.220 +The \verb|ROWS|, \verb|COLS|, and \verb|NONZ| fields contain
  24.221 +non-negative integer values specifying, respectively, the number of
  24.222 +rows (constraints), columns (variables), and non-zero constraint
  24.223 +coefficients in the problem instance. Note that \verb|NONZ| value does
  24.224 +not account objective coefficients.
  24.225 +
  24.226 +\paragraph{Row descriptors.} There must be at most one row descriptor
  24.227 +line in the data file for each row (constraint). This line has one of
  24.228 +the following formats:
  24.229 +
  24.230 +\begin{verbatim}
  24.231 +   i ROW f
  24.232 +   i ROW l RHS
  24.233 +   i ROW u RHS
  24.234 +   i ROW d RHS1 RHS2
  24.235 +   i ROW s RHS
  24.236 +\end{verbatim}
  24.237 +
  24.238 +The lower-case letter \verb|i| specifies that this is the row
  24.239 +descriptor line.
  24.240 +
  24.241 +The \verb|ROW| field specifies the row ordinal number, an integer
  24.242 +between 1 and $m$, where $m$ is the number of rows in the problem
  24.243 +instance.
  24.244 +
  24.245 +The next lower-case letter specifies the row type as follows:
  24.246 +
  24.247 +\verb|f| --- free (unbounded) row: $-\infty<\sum a_jx_j<+\infty$;
  24.248 +
  24.249 +\verb|l| --- inequality constraint of `$\geq$' type:
  24.250 +$\sum a_jx_j\geq b$;
  24.251 +
  24.252 +\verb|u| --- inequality constraint of `$\leq$' type:
  24.253 +$\sum a_jx_j\leq b$;
  24.254 +
  24.255 +\verb|d| --- double-sided inequality constraint:
  24.256 +$b_1\leq\sum a_jx_j\leq b_2$;
  24.257 +
  24.258 +\verb|s| --- equality constraint: $\sum a_jx_j=b$.
  24.259 +
  24.260 +The \verb|RHS| field contains a floaing-point value specifying the
  24.261 +row right-hand side. The \verb|RHS1| and \verb|RHS2| fields contain
  24.262 +floating-point values specifying, respectively, the lower and upper
  24.263 +right-hand sides for the double-sided row.
  24.264 +
  24.265 +If for some row its descriptor line does not appear in the data file,
  24.266 +by default that row is assumed to be an equality constraint with zero
  24.267 +right-hand side.
  24.268 +
  24.269 +\paragraph{Column descriptors.} There must be at most one column
  24.270 +descriptor line in the data file for each column (variable). This line
  24.271 +has one of the following formats depending on the problem class
  24.272 +specified in the problem line:
  24.273 +
  24.274 +\bigskip
  24.275 +
  24.276 +\begin{tabular}{@{}l@{\hspace*{40pt}}l}
  24.277 +LP class & MIP class \\
  24.278 +\hline
  24.279 +\verb|j COL f|           & \verb|j COL KIND f|           \\
  24.280 +\verb|j COL l BND|       & \verb|j COL KIND l BND|       \\
  24.281 +\verb|j COL u BND|       & \verb|j COL KIND u BND|       \\
  24.282 +\verb|j COL d BND1 BND2| & \verb|j COL KIND d BND1 BND2| \\
  24.283 +\verb|j COL s BND|       & \verb|j COL KIND s BND|       \\
  24.284 +\end{tabular}
  24.285 +
  24.286 +\bigskip
  24.287 +
  24.288 +The lower-case letter \verb|j| specifies that this is the column
  24.289 +descriptor line.
  24.290 +
  24.291 +The \verb|COL| field specifies the column ordinal number, an integer
  24.292 +between 1 and $n$, where $n$ is the number of columns in the problem
  24.293 +instance.
  24.294 +
  24.295 +The \verb|KIND| field is used only for MIP problems and specifies the
  24.296 +column kind as follows:
  24.297 +
  24.298 +\verb|c| --- continuous column;
  24.299 +
  24.300 +\verb|i| --- integer column;
  24.301 +
  24.302 +\verb|b| --- binary column (in this case all remaining fields must be
  24.303 +omitted).
  24.304 +
  24.305 +The next lower-case letter specifies the column type as follows:
  24.306 +
  24.307 +\verb|f| --- free (unbounded) column: $-\infty<x<+\infty$;
  24.308 +
  24.309 +\verb|l| --- column with lower bound: $x\geq l$;
  24.310 +
  24.311 +\verb|u| --- column with upper bound: $x\leq u$;
  24.312 +
  24.313 +\verb|d| --- double-bounded column: $l\leq x\leq u$;
  24.314 +
  24.315 +\verb|s| --- fixed column: $x=s$.
  24.316 +
  24.317 +The \verb|BND| field contains a floating-point value that specifies the
  24.318 +column bound. The \verb|BND1| and \verb|BND2| fields contain
  24.319 +floating-point values specifying, respectively, the lower and upper
  24.320 +bounds for the double-bounded column.
  24.321 +
  24.322 +If for some column its descriptor line does not appear in the file, by
  24.323 +default that column is assumed to be non-negative (in case of LP class)
  24.324 +or binary (in case of MIP class).
  24.325 +
  24.326 +\paragraph{Coefficient descriptors.} There must be exactly one
  24.327 +coefficient descriptor line in the data file for each non-zero
  24.328 +objective or constraint coefficient. This line has the following format:
  24.329 +
  24.330 +\begin{verbatim}
  24.331 +   a ROW COL VAL
  24.332 +\end{verbatim}
  24.333 +
  24.334 +The lower-case letter \verb|a| specifies that this is the coefficient
  24.335 +descriptor line.
  24.336 +
  24.337 +For objective coefficients the \verb|ROW| field must contain 0. For
  24.338 +constraint coefficients the \verb|ROW| field specifies the row ordinal
  24.339 +number, an integer between 1 and $m$, where $m$ is the number of rows
  24.340 +in the problem instance.
  24.341 +
  24.342 +The \verb|COL| field specifies the column ordinal number, an integer
  24.343 +between 1 and $n$, where $n$ is the number of columns in the problem
  24.344 +instance.
  24.345 +
  24.346 +If both the \verb|ROW| and \verb|COL| fields contain 0, the line
  24.347 +specifies the constant term (``shift'') of the objective function
  24.348 +rather than objective coefficient.
  24.349 +
  24.350 +The \verb|VAL| field contains a floating-point coefficient value (it is
  24.351 +allowed to specify zero value in this field).
  24.352 +
  24.353 +The number of constraint coefficient descriptor lines must be exactly
  24.354 +the same as specified in the field \verb|NONZ| of the problem line.
  24.355 +
  24.356 +\paragraph{Symbolic name descriptors.} There must be at most one
  24.357 +symbolic name descriptor line for the problem instance, objective
  24.358 +function, each row (constraint), and each column (variable). This line
  24.359 +has one of the following formats:
  24.360 +
  24.361 +\begin{verbatim}
  24.362 +   n p NAME
  24.363 +   n z NAME
  24.364 +   n i ROW NAME
  24.365 +   n j COL NAME
  24.366 +\end{verbatim}
  24.367 +
  24.368 +The lower-case letter \verb|n| specifies that this is the symbolic name
  24.369 +descriptor line.
  24.370 +
  24.371 +The next lower-case letter specifies which object should be assigned a
  24.372 +symbolic name:
  24.373 +
  24.374 +\verb|p| --- problem instance;
  24.375 +
  24.376 +\verb|z| --- objective function;
  24.377 +
  24.378 +\verb|i| --- row (constraint);
  24.379 +
  24.380 +\verb|j| --- column (variable).
  24.381 +
  24.382 +The \verb|ROW| field specifies the row ordinal number, an integer
  24.383 +between 1 and $m$, where $m$ is the number of rows in the problem
  24.384 +instance.
  24.385 +
  24.386 +The \verb|COL| field specifies the column ordinal number, an integer
  24.387 +between 1 and $n$, where $n$ is the number of columns in the problem
  24.388 +instance.
  24.389 +
  24.390 +The \verb|NAME| field contains the symbolic name, a sequence from 1 to
  24.391 +255 arbitrary graphic ASCII characters, assigned to corresponding
  24.392 +object.
  24.393 +
  24.394 +\paragraph{End line.} There must be exactly one end line in the data
  24.395 +file. This line must appear last in the file and has the following
  24.396 +format:
  24.397 +
  24.398 +\begin{verbatim}
  24.399 +   e
  24.400 +\end{verbatim}
  24.401 +
  24.402 +The lower-case letter \verb|e| specifies that this is the end line.
  24.403 +Anything that follows the end line is ignored by GLPK routines.
  24.404 +
  24.405 +\subsubsection*{Example of data file in GLPK LP/MIP format}
  24.406 +
  24.407 +The following example of a data file in GLPK LP/MIP format specifies
  24.408 +the same LP problem as in Subsection ``Example of MPS file''.
  24.409 +
  24.410 +\begin{center}
  24.411 +\footnotesize\tt
  24.412 +\begin{tabular}{l@{\hspace*{50pt}}}
  24.413 +p lp min 8 7 48   \\
  24.414 +n p PLAN          \\
  24.415 +n z VALUE         \\
  24.416 +i 1 f             \\
  24.417 +n i 1 VALUE       \\
  24.418 +i 2 s 2000        \\
  24.419 +n i 2 YIELD       \\
  24.420 +i 3 u 60          \\
  24.421 +n i 3 FE          \\
  24.422 +i 4 u 100         \\
  24.423 +n i 4 CU          \\
  24.424 +i 5 u 40          \\
  24.425 +n i 5 MN          \\
  24.426 +i 6 u 30          \\
  24.427 +n i 6 MG          \\
  24.428 +i 7 l 1500        \\
  24.429 +n i 7 AL          \\
  24.430 +i 8 d 250 300     \\
  24.431 +n i 8 SI          \\
  24.432 +j 1 d 0 200       \\
  24.433 +n j 1 BIN1        \\
  24.434 +j 2 d 0 2500      \\
  24.435 +n j 2 BIN2        \\
  24.436 +j 3 d 400 800     \\
  24.437 +n j 3 BIN3        \\
  24.438 +j 4 d 100 700     \\
  24.439 +n j 4 BIN4        \\
  24.440 +j 5 d 0 1500      \\
  24.441 +n j 5 BIN5        \\
  24.442 +n j 6 ALUM        \\
  24.443 +n j 7 SILICON     \\
  24.444 +a 0 1 0.03        \\
  24.445 +a 0 2 0.08        \\
  24.446 +a 0 3 0.17        \\
  24.447 +a 0 4 0.12        \\
  24.448 +a 0 5 0.15        \\
  24.449 +a 0 6 0.21        \\
  24.450 +a 0 7 0.38        \\
  24.451 +a 1 1 0.03        \\
  24.452 +a 1 2 0.08        \\
  24.453 +a 1 3 0.17        \\
  24.454 +a 1 4 0.12        \\
  24.455 +a 1 5 0.15        \\
  24.456 +a 1 6 0.21        \\
  24.457 +\end{tabular}
  24.458 +\begin{tabular}{|@{\hspace*{80pt}}l}
  24.459 +a 1 7 0.38        \\
  24.460 +a 2 1 1           \\
  24.461 +a 2 2 1           \\
  24.462 +a 2 3 1           \\
  24.463 +a 2 4 1           \\
  24.464 +a 2 5 1           \\
  24.465 +a 2 6 1           \\
  24.466 +a 2 7 1           \\
  24.467 +a 3 1 0.15        \\
  24.468 +a 3 2 0.04        \\
  24.469 +a 3 3 0.02        \\
  24.470 +a 3 4 0.04        \\
  24.471 +a 3 5 0.02        \\
  24.472 +a 3 6 0.01        \\
  24.473 +a 3 7 0.03        \\
  24.474 +a 4 1 0.03        \\
  24.475 +a 4 2 0.05        \\
  24.476 +a 4 3 0.08        \\
  24.477 +a 4 4 0.02        \\
  24.478 +a 4 5 0.06        \\
  24.479 +a 4 6 0.01        \\
  24.480 +a 5 1 0.02        \\
  24.481 +a 5 2 0.04        \\
  24.482 +a 5 3 0.01        \\
  24.483 +a 5 4 0.02        \\
  24.484 +a 5 5 0.02        \\
  24.485 +a 6 1 0.02        \\
  24.486 +a 6 2 0.03        \\
  24.487 +a 6 5 0.01        \\
  24.488 +a 7 1 0.7         \\
  24.489 +a 7 2 0.75        \\
  24.490 +a 7 3 0.8         \\
  24.491 +a 7 4 0.75        \\
  24.492 +a 7 5 0.8         \\
  24.493 +a 7 6 0.97        \\
  24.494 +a 8 1 0.02        \\
  24.495 +a 8 2 0.06        \\
  24.496 +a 8 3 0.08        \\
  24.497 +a 8 4 0.12        \\
  24.498 +a 8 5 0.02        \\
  24.499 +a 8 6 0.01        \\
  24.500 +a 8 7 0.97        \\
  24.501 +e o f             \\
  24.502 +\\
  24.503 +\end{tabular}
  24.504 +\end{center}
  24.505 +
  24.506 +\newpage
  24.507 +
  24.508 +\subsection{glp\_write\_prob---write problem data in GLPK format}
  24.509 +
  24.510 +\subsubsection*{Synopsis}
  24.511 +
  24.512 +\begin{verbatim}
  24.513 +int glp_write_prob(glp_prob *P, int flags, const char *fname);
  24.514 +\end{verbatim}
  24.515 +
  24.516 +\subsubsection*{Description}
  24.517 +
  24.518 +The routine \verb|glp_write_prob| writes problem data in the GLPK
  24.519 +LP/MIP format to a text file. (For description of the GLPK LP/MIP
  24.520 +format see Subsection ``Read problem data in GLPK format''.)
  24.521 +
  24.522 +The parameter \verb|flags| is reserved for use in the future and should
  24.523 +be specified as zero.
  24.524 +
  24.525 +The character string \verb|fname| specifies a name of the text file to
  24.526 +be written out. (If the file name ends with suffix `\verb|.gz|', the
  24.527 +file is assumed to be compressed, in which case the routine
  24.528 +\verb|glp_write_prob| performs automatic compression on writing it.)
  24.529 +
  24.530 +\subsubsection*{Returns}
  24.531 +
  24.532 +If the operation was successful, the routine \verb|glp_read_prob|
  24.533 +returns zero. Otherwise, it prints an error message and returns
  24.534 +non-zero.
  24.535 +
  24.536 +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  24.537 +
  24.538 +\newpage
  24.539 +
  24.540 +\section{Routines for processing MathProg models}
  24.541 +
  24.542 +\subsection{Introduction}
  24.543 +
  24.544 +GLPK supports the {\it GNU MathProg modeling language}.\footnote{The
  24.545 +GNU MathProg modeling language is a subset of the AMPL language. For
  24.546 +its detailed description see the document ``Modeling Language GNU
  24.547 +MathProg: Language Reference'' included in the GLPK distribution.}
  24.548 +As a rule, models written in MathProg are solved with the GLPK LP/MIP
  24.549 +stand-alone solver \verb|glpsol| (see Appendix D) and do not need any
  24.550 +programming with API routines. However, for various reasons the user
  24.551 +may need to process MathProg models directly in his/her application
  24.552 +program, in which case he/she may use API routines described in this
  24.553 +section. These routines provide an interface to the {\it MathProg
  24.554 +translator}, a component of GLPK, which translates MathProg models into
  24.555 +an internal code and then interprets (executes) this code.
  24.556 +
  24.557 +The processing of a model written in GNU MathProg includes several
  24.558 +steps, which should be performed in the following order:
  24.559 +
  24.560 +\begin{enumerate}
  24.561 +\item{\it Allocating the workspace.}
  24.562 +The translator allocates the workspace, an internal data structure used
  24.563 +on all subsequent steps.
  24.564 +\item{\it Reading model section.} The translator reads model section
  24.565 +and, optionally, data section from a specified text file and translates
  24.566 +them into the internal code. If necessary, on this step data section
  24.567 +may be ignored.
  24.568 +\item{\it Reading data section(s).} The translator reads one or more
  24.569 +data sections from specified text file(s) and translates them into the
  24.570 +internal code.
  24.571 +\item{\it Generating the model.} The translator executes the internal
  24.572 +code to evaluate the content of the model objects such as sets,
  24.573 +parameters, variables, constraints, and objectives. On this step the
  24.574 +execution is suspended at the solve statement.
  24.575 +\item {\it Building the problem object.} The translator obtains all
  24.576 +necessary information from the workspace and builds the standard
  24.577 +problem object (that is, the program object of type \verb|glp_prob|).
  24.578 +\item{\it Solving the problem.} On this step the problem object built
  24.579 +on the previous step is passed to a solver, which solves the problem
  24.580 +instance and stores its solution back to the problem object.
  24.581 +\item{\it Postsolving the model.} The translator copies the solution
  24.582 +from the problem object to the workspace and then executes the internal
  24.583 +code from the solve statement to the end of the model. (If model has
  24.584 +no solve statement, the translator does nothing on this step.)
  24.585 +\item{\it Freeing the workspace.} The translator frees all the memory
  24.586 +allocated to the workspace.
  24.587 +\end{enumerate}
  24.588 +
  24.589 +Note that the MathProg translator performs no error correction, so if
  24.590 +any of steps 2 to 7 fails (due to errors in the model), the application
  24.591 +program should terminate processing and go to step 8.
  24.592 +
  24.593 +\subsubsection*{Example 1}
  24.594 +
  24.595 +In this example the program reads model and data sections from input
  24.596 +file \verb|egypt.mod|\footnote{This is an example model included in
  24.597 +the GLPK distribution.} and writes the model to output file
  24.598 +\verb|egypt.mps| in free MPS format (see Appendix B). No solution is
  24.599 +performed.
  24.600 +
  24.601 +\begin{small}
  24.602 +\begin{verbatim}
  24.603 +/* mplsamp1.c */
  24.604 +
  24.605 +#include <stdio.h>
  24.606 +#include <stdlib.h>
  24.607 +#include <glpk.h>
  24.608 +
  24.609 +int main(void)
  24.610 +{     glp_prob *lp;
  24.611 +      glp_tran *tran;
  24.612 +      int ret;
  24.613 +      lp = glp_create_prob();
  24.614 +      tran = glp_mpl_alloc_wksp();
  24.615 +      ret = glp_mpl_read_model(tran, "egypt.mod", 0);
  24.616 +      if (ret != 0)
  24.617 +      {  fprintf(stderr, "Error on translating model\n");
  24.618 +         goto skip;
  24.619 +      }
  24.620 +      ret = glp_mpl_generate(tran, NULL);
  24.621 +      if (ret != 0)
  24.622 +      {  fprintf(stderr, "Error on generating model\n");
  24.623 +         goto skip;
  24.624 +      }
  24.625 +      glp_mpl_build_prob(tran, lp);
  24.626 +      ret = glp_write_mps(lp, GLP_MPS_FILE, NULL, "egypt.mps");
  24.627 +      if (ret != 0)
  24.628 +         fprintf(stderr, "Error on writing MPS file\n");
  24.629 +skip: glp_mpl_free_wksp(tran);
  24.630 +      glp_delete_prob(lp);
  24.631 +      return 0;
  24.632 +}
  24.633 +
  24.634 +/* eof */
  24.635 +\end{verbatim}
  24.636 +\end{small}
  24.637 +
  24.638 +\subsubsection*{Example 2}
  24.639 +
  24.640 +In this example the program reads model section from file
  24.641 +\verb|sudoku.mod|\footnote{This is an example model which is included
  24.642 +in the GLPK distribution along with alternative data file
  24.643 +{\tt sudoku.dat}.} ignoring data section in this file, reads alternative
  24.644 +data section from file \verb|sudoku.dat|, solves the problem instance
  24.645 +and passes the solution found back to the model.
  24.646 +
  24.647 +\begin{small}
  24.648 +\begin{verbatim}
  24.649 +/* mplsamp2.c */
  24.650 +
  24.651 +#include <stdio.h>
  24.652 +#include <stdlib.h>
  24.653 +#include <glpk.h>
  24.654 +
  24.655 +int main(void)
  24.656 +{     glp_prob *mip;
  24.657 +      glp_tran *tran;
  24.658 +      int ret;
  24.659 +      mip = glp_create_prob();
  24.660 +      tran = glp_mpl_alloc_wksp();
  24.661 +      ret = glp_mpl_read_model(tran, "sudoku.mod", 1);
  24.662 +      if (ret != 0)
  24.663 +      {  fprintf(stderr, "Error on translating model\n");
  24.664 +         goto skip;
  24.665 +      }
  24.666 +      ret = glp_mpl_read_data(tran, "sudoku.dat");
  24.667 +      if (ret != 0)
  24.668 +      {  fprintf(stderr, "Error on translating data\n");
  24.669 +         goto skip;
  24.670 +      }
  24.671 +      ret = glp_mpl_generate(tran, NULL);
  24.672 +      if (ret != 0)
  24.673 +      {  fprintf(stderr, "Error on generating model\n");
  24.674 +         goto skip;
  24.675 +      }
  24.676 +      glp_mpl_build_prob(tran, mip);
  24.677 +      glp_simplex(mip, NULL);
  24.678 +      glp_intopt(mip, NULL);
  24.679 +      ret = glp_mpl_postsolve(tran, mip, GLP_MIP);
  24.680 +      if (ret != 0)
  24.681 +         fprintf(stderr, "Error on postsolving model\n");
  24.682 +skip: glp_mpl_free_wksp(tran);
  24.683 +      glp_delete_prob(mip);
  24.684 +      return 0;
  24.685 +}
  24.686 +
  24.687 +/* eof */
  24.688 +\end{verbatim}
  24.689 +\end{small}
  24.690 +
  24.691 +\subsection{glp\_mpl\_alloc\_wksp---allocate the translator workspace}
  24.692 +
  24.693 +\subsubsection*{Synopsis}
  24.694 +
  24.695 +\begin{verbatim}
  24.696 +glp_tran *glp_mpl_alloc_wksp(void);
  24.697 +\end{verbatim}
  24.698 +
  24.699 +\subsubsection*{Description}
  24.700 +
  24.701 +The routine \verb|glp_mpl_alloc_wksp| allocates the MathProg translator
  24.702 +work\-space. (Note that multiple instances of the workspace may be
  24.703 +allocated, if necessary.)
  24.704 +
  24.705 +\subsubsection*{Returns}
  24.706 +
  24.707 +The routine returns a pointer to the workspace, which should be used in
  24.708 +all subsequent operations.
  24.709 +
  24.710 +\subsection{glp\_mpl\_read\_model---read and translate model section}
  24.711 +
  24.712 +\subsubsection*{Synopsis}
  24.713 +
  24.714 +\begin{verbatim}
  24.715 +int glp_mpl_read_model(glp_tran *tran, const char *fname,
  24.716 +      int skip);
  24.717 +\end{verbatim}
  24.718 +
  24.719 +\subsubsection*{Description}
  24.720 +
  24.721 +The routine \verb|glp_mpl_read_model| reads model section and,
  24.722 +optionally, data section, which may follow the model section, from a
  24.723 +text file, whose name is the character string \verb|fname|, performs
  24.724 +translation of model statements and data blocks, and stores all the
  24.725 +information in the workspace.
  24.726 +
  24.727 +The parameter \verb|skip| is a flag. If the input file contains the
  24.728 +data section and this flag is non-zero, the data section is not read as
  24.729 +if there were no data section and a warning message is printed. This
  24.730 +allows reading data section(s) from other file(s).
  24.731 +
  24.732 +\subsubsection*{Returns}
  24.733 +
  24.734 +If the operation is successful, the routine returns zero. Otherwise
  24.735 +the routine prints an error message and returns non-zero.
  24.736 +
  24.737 +\subsection{glp\_mpl\_read\_data---read and translate data section}
  24.738 +
  24.739 +\subsubsection*{Synopsis}
  24.740 +
  24.741 +\begin{verbatim}
  24.742 +int glp_mpl_read_data(glp_tran *tran, const char *fname);
  24.743 +\end{verbatim}
  24.744 +
  24.745 +\subsubsection*{Description}
  24.746 +
  24.747 +The routine \verb|glp_mpl_read_data| reads data section from a text
  24.748 +file, whose name is the character string \verb|fname|, performs
  24.749 +translation of data blocks, and stores the data read in the translator
  24.750 +workspace. If necessary, this routine may be called more than once.
  24.751 +
  24.752 +\subsubsection*{Returns}
  24.753 +
  24.754 +If the operation is successful, the routine returns zero. Otherwise
  24.755 +the routine prints an error message and returns non-zero.
  24.756 +
  24.757 +\subsection{glp\_mpl\_generate---generate the model}
  24.758 +
  24.759 +\subsubsection*{Synopsis}
  24.760 +
  24.761 +\begin{verbatim}
  24.762 +int glp_mpl_generate(glp_tran *tran, const char *fname);
  24.763 +\end{verbatim}
  24.764 +
  24.765 +\subsubsection*{Description}
  24.766 +
  24.767 +The routine \verb|glp_mpl_generate| generates the model using its
  24.768 +description stored in the translator workspace. This operation means
  24.769 +generating all variables, constraints, and objectives, executing check
  24.770 +and display statements, which precede the solve statement (if it is
  24.771 +presented).
  24.772 +
  24.773 +The character string \verb|fname| specifies the name of an output text
  24.774 +file, to which output produced by display statements should be written.
  24.775 +If \verb|fname| is \verb|NULL|, the output is sent to the terminal.
  24.776 +
  24.777 +\subsubsection*{Returns}
  24.778 +
  24.779 +If the operation is successful, the routine returns zero. Otherwise
  24.780 +the routine prints an error message and returns non-zero.
  24.781 +
  24.782 +\subsection{glp\_mpl\_build\_prob---build problem instance from the
  24.783 +model}
  24.784 +
  24.785 +\subsubsection*{Synopsis}
  24.786 +
  24.787 +\begin{verbatim}
  24.788 +void glp_mpl_build_prob(glp_tran *tran, glp_prob *prob);
  24.789 +\end{verbatim}
  24.790 +
  24.791 +\subsubsection*{Description}
  24.792 +
  24.793 +The routine \verb|glp_mpl_build_prob| obtains all necessary information
  24.794 +from the translator workspace and stores it in the specified problem
  24.795 +object \verb|prob|. Note that before building the current content of
  24.796 +the problem object is erased with the routine \verb|glp_erase_prob|.
  24.797 +
  24.798 +\subsection{glp\_mpl\_postsolve---postsolve the model}
  24.799 +
  24.800 +\subsubsection*{Synopsis}
  24.801 +
  24.802 +\begin{verbatim}
  24.803 +int glp_mpl_postsolve(glp_tran *tran, glp_prob *prob,
  24.804 +      int sol);
  24.805 +\end{verbatim}
  24.806 +
  24.807 +\subsubsection*{Description}
  24.808 +
  24.809 +The routine \verb|glp_mpl_postsolve| copies the solution from the
  24.810 +specified problem object \verb|prob| to the translator workspace and
  24.811 +then executes all the remaining model statements, which follow the
  24.812 +solve statement.
  24.813 +
  24.814 +The parameter \verb|sol| specifies which solution should be copied
  24.815 +from the problem object to the workspace as follows:
  24.816 +
  24.817 +\begin{tabular}{@{}ll}
  24.818 +\verb|GLP_SOL| & basic solution; \\
  24.819 +\verb|GLP_IPT| & interior-point solution; \\
  24.820 +\verb|GLP_MIP| & mixed integer solution. \\
  24.821 +\end{tabular}
  24.822 +
  24.823 +\subsubsection*{Returns}
  24.824 +
  24.825 +If the operation is successful, the routine returns zero. Otherwise
  24.826 +the routine prints an error message and returns non-zero.
  24.827 +
  24.828 +\subsection{glp\_mpl\_free\_wksp---free the translator workspace}
  24.829 +
  24.830 +\subsubsection*{Synopsis}
  24.831 +
  24.832 +\begin{verbatim}
  24.833 +void glp_mpl_free_wksp(glp_tran *tran);
  24.834 +\end{verbatim}
  24.835 +
  24.836 +\subsubsection*{Description}
  24.837 +
  24.838 +The routine \verb|glp_mpl_free_wksp| frees all the memory allocated to
  24.839 +the translator workspace. It also frees all other resources, which are
  24.840 +still used by the translator.
  24.841 +
  24.842 +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  24.843 +
  24.844 +\newpage
  24.845 +
  24.846 +\section{Problem solution reading/writing routines}
  24.847 +
  24.848 +\subsection{glp\_print\_sol---write basic solution in printable format}
  24.849 +
  24.850 +\subsubsection*{Synopsis}
  24.851 +
  24.852 +\begin{verbatim}
  24.853 +int glp_print_sol(glp_prob *lp, const char *fname);
  24.854 +\end{verbatim}
  24.855 +
  24.856 +\subsubsection*{Description}
  24.857 +
  24.858 +The routine \verb|glp_print_sol writes| the current basic solution of
  24.859 +an LP problem, which is specified by the pointer \verb|lp|, to a text
  24.860 +file, whose name is the character string \verb|fname|, in printable
  24.861 +format.
  24.862 +
  24.863 +Information reported by the routine \verb|glp_print_sol| is intended
  24.864 +mainly for visual analysis.
  24.865 +
  24.866 +\subsubsection*{Returns}
  24.867 +
  24.868 +If no errors occurred, the routine returns zero. Otherwise the routine
  24.869 +prints an error message and returns non-zero.
  24.870 +
  24.871 +\subsection{glp\_read\_sol---read basic solution from text file}
  24.872 +
  24.873 +\subsubsection*{Synopsis}
  24.874 +
  24.875 +\begin{verbatim}
  24.876 +int glp_read_sol(glp_prob *lp, const char *fname);
  24.877 +\end{verbatim}
  24.878 +
  24.879 +\subsubsection*{Description}
  24.880 +
  24.881 +The routine \verb|glp_read_sol| reads basic solution from a text file
  24.882 +whose name is specified by the parameter \verb|fname| into the problem
  24.883 +object.
  24.884 +
  24.885 +For the file format see description of the routine \verb|glp_write_sol|.
  24.886 +
  24.887 +\subsubsection*{Returns}
  24.888 +
  24.889 +On success the routine returns zero, otherwise non-zero.
  24.890 +
  24.891 +\newpage
  24.892 +
  24.893 +\subsection{glp\_write\_sol---write basic solution to text file}
  24.894 +
  24.895 +\subsubsection*{Synopsis}
  24.896 +
  24.897 +\begin{verbatim}
  24.898 +int glp_write_sol(glp_prob *lp, const char *fname);
  24.899 +\end{verbatim}
  24.900 +
  24.901 +\subsubsection*{Description}
  24.902 +
  24.903 +The routine \verb|glp_write_sol| writes the current basic solution to a
  24.904 +text file whose name is specified by the parameter \verb|fname|. This
  24.905 +file can be read back with the routine \verb|glp_read_sol|.
  24.906 +
  24.907 +\subsubsection*{Returns}
  24.908 +
  24.909 +On success the routine returns zero, otherwise non-zero.
  24.910 +
  24.911 +\subsubsection*{File format}
  24.912 +
  24.913 +The file created by the routine \verb|glp_write_sol| is a plain text
  24.914 +file, which contains the following information:
  24.915 +
  24.916 +\begin{verbatim}
  24.917 +   m n
  24.918 +   p_stat d_stat obj_val
  24.919 +   r_stat[1] r_prim[1] r_dual[1]
  24.920 +   . . .
  24.921 +   r_stat[m] r_prim[m] r_dual[m]
  24.922 +   c_stat[1] c_prim[1] c_dual[1]
  24.923 +   . . .
  24.924 +   c_stat[n] c_prim[n] c_dual[n]
  24.925 +\end{verbatim}
  24.926 +
  24.927 +\noindent
  24.928 +where:
  24.929 +
  24.930 +\noindent
  24.931 +$m$ is the number of rows (auxiliary variables);
  24.932 +
  24.933 +\noindent
  24.934 +$n$ is the number of columns (structural variables);
  24.935 +
  24.936 +\noindent
  24.937 +\verb|p_stat| is the primal status of the basic solution
  24.938 +(\verb|GLP_UNDEF| = 1, \verb|GLP_FEAS| = 2, \verb|GLP_INFEAS| = 3, or
  24.939 +\verb|GLP_NOFEAS| = 4);
  24.940 +
  24.941 +\noindent
  24.942 +\verb|d_stat| is the dual status of the basic solution
  24.943 +(\verb|GLP_UNDEF| = 1, \verb|GLP_FEAS| = 2, \verb|GLP_INFEAS| = 3, or
  24.944 +\verb|GLP_NOFEAS| = 4);
  24.945 +
  24.946 +\noindent
  24.947 +\verb|obj_val| is the objective value;
  24.948 +
  24.949 +\noindent
  24.950 +\verb|r_stat[i]|, $i=1,\dots,m$, is the status of $i$-th row
  24.951 +(\verb|GLP_BS| = 1, \verb|GLP_NL| = 2, \verb|GLP_NU| = 3,
  24.952 +\verb|GLP_NF| = 4, or \verb|GLP_NS| = 5);
  24.953 +
  24.954 +\noindent
  24.955 +\verb|r_prim[i]|, $i=1,\dots,m$, is the primal value of $i$-th row;
  24.956 +
  24.957 +\noindent
  24.958 +\verb|r_dual[i]|, $i=1,\dots,m$, is the dual value of $i$-th row;
  24.959 +
  24.960 +\noindent
  24.961 +\verb|c_stat[j]|, $j=1,\dots,n$, is the status of $j$-th column
  24.962 +(\verb|GLP_BS| = 1, \verb|GLP_NL| = 2, \verb|GLP_NU| = 3,
  24.963 +\verb|GLP_NF| = 4, or \verb|GLP_NS| = 5);
  24.964 +
  24.965 +\noindent
  24.966 +\verb|c_prim[j]|, $j=1,\dots,n$, is the primal value of $j$-th column;
  24.967 +
  24.968 +\noindent
  24.969 +\verb|c_dual[j]|, $j=1,\dots,n$, is the dual value of $j$-th column.
  24.970 +
  24.971 +\subsection{glp\_print\_ipt---write interior-point solution in
  24.972 +printable format}
  24.973 +
  24.974 +\subsubsection*{Synopsis}
  24.975 +
  24.976 +\begin{verbatim}
  24.977 +int glp_print_ipt(glp_prob *lp, const char *fname);
  24.978 +\end{verbatim}
  24.979 +
  24.980 +\subsubsection*{Description}
  24.981 +
  24.982 +The routine \verb|glp_print_ipt| writes the current interior point
  24.983 +solution  of an LP problem, which the parameter \verb|lp| points to, to
  24.984 +a text file, whose name is the character string \verb|fname|, in
  24.985 +printable format.
  24.986 +
  24.987 +Information reported by the routine \verb|glp_print_ipt| is intended
  24.988 +mainly for visual analysis.
  24.989 +
  24.990 +\subsubsection*{Returns}
  24.991 +
  24.992 +If no errors occurred, the routine returns zero. Otherwise the routine
  24.993 +prints an error message and returns non-zero.
  24.994 +
  24.995 +\subsection{glp\_read\_ipt---read interior-point solution from text
  24.996 +file}
  24.997 +
  24.998 +\subsubsection*{Synopsis}
  24.999 +
 24.1000 +\begin{verbatim}
 24.1001 +int glp_read_ipt(glp_prob *lp, const char *fname);
 24.1002 +\end{verbatim}
 24.1003 +
 24.1004 +\subsubsection*{Description}
 24.1005 +
 24.1006 +The routine \verb|glp_read_ipt| reads interior-point solution from a
 24.1007 +text file whose name is specified by the parameter \verb|fname| into the
 24.1008 +problem object.
 24.1009 +
 24.1010 +For the file format see description of the routine \verb|glp_write_ipt|.
 24.1011 +
 24.1012 +\subsubsection*{Returns}
 24.1013 +
 24.1014 +On success the routine returns zero, otherwise non-zero.
 24.1015 +
 24.1016 +\subsection{glp\_write\_ipt---write interior-point solution to text
 24.1017 +file}
 24.1018 +
 24.1019 +\subsubsection*{Synopsis}
 24.1020 +
 24.1021 +\begin{verbatim}
 24.1022 +int glp_write_ipt(glp_prob *lp, const char *fname);
 24.1023 +\end{verbatim}
 24.1024 +
 24.1025 +\subsubsection*{Description}
 24.1026 +
 24.1027 +The routine \verb|glp_write_ipt| writes the current interior-point
 24.1028 +solution to a text file whose name is specified by the parameter
 24.1029 +\verb|fname|. This file can be read back with the routine
 24.1030 +\verb|glp_read_ipt|.
 24.1031 +
 24.1032 +\subsubsection*{Returns}
 24.1033 +
 24.1034 +On success the routine returns zero, otherwise non-zero.
 24.1035 +
 24.1036 +\subsubsection*{File format}
 24.1037 +
 24.1038 +The file created by the routine \verb|glp_write_ipt| is a plain text
 24.1039 +file, which contains the following information:
 24.1040 +
 24.1041 +\begin{verbatim}
 24.1042 +   m n
 24.1043 +   stat obj_val
 24.1044 +   r_prim[1] r_dual[1]
 24.1045 +   . . .
 24.1046 +   r_prim[m] r_dual[m]
 24.1047 +   c_prim[1] c_dual[1]
 24.1048 +   . . .
 24.1049 +   c_prim[n] c_dual[n]
 24.1050 +\end{verbatim}
 24.1051 +
 24.1052 +\noindent
 24.1053 +where:
 24.1054 +
 24.1055 +\noindent
 24.1056 +$m$ is the number of rows (auxiliary variables);
 24.1057 +
 24.1058 +\noindent
 24.1059 +$n$ is the number of columns (structural variables);
 24.1060 +
 24.1061 +\noindent
 24.1062 +\verb|stat| is the solution status (\verb|GLP_UNDEF| = 1 or
 24.1063 +\verb|GLP_OPT| = 5);
 24.1064 +
 24.1065 +\noindent
 24.1066 +\verb|obj_val| is the objective value;
 24.1067 +
 24.1068 +\noindent
 24.1069 +\verb|r_prim[i]|, $i=1,\dots,m$, is the primal value of $i$-th row;
 24.1070 +
 24.1071 +\noindent
 24.1072 +\verb|r_dual[i]|, $i=1,\dots,m$, is the dual value of $i$-th row;
 24.1073 +
 24.1074 +\noindent
 24.1075 +\verb|c_prim[j]|, $j=1,\dots,n$, is the primal value of $j$-th column;
 24.1076 +
 24.1077 +\noindent
 24.1078 +\verb|c_dual[j]|, $j=1,\dots,n$, is the dual value of $j$-th column.
 24.1079 +
 24.1080 +\subsection{glp\_print\_mip---write MIP solution in printable format}
 24.1081 +
 24.1082 +\subsubsection*{Synopsis}
 24.1083 +
 24.1084 +\begin{verbatim}
 24.1085 +int glp_print_mip(glp_prob *lp, const char *fname);
 24.1086 +\end{verbatim}
 24.1087 +
 24.1088 +\subsubsection*{Description}
 24.1089 +
 24.1090 +The routine \verb|glp_print_mip| writes a best known integer solution
 24.1091 +of a MIP problem, which is specified by the pointer \verb|lp|, to a text
 24.1092 +file, whose name is the character string \verb|fname|, in printable
 24.1093 +format.
 24.1094 +
 24.1095 +Information reported by the routine \verb|glp_print_mip| is intended
 24.1096 +mainly for visual analysis.
 24.1097 +
 24.1098 +\subsubsection*{Returns}
 24.1099 +
 24.1100 +If no errors occurred, the routine returns zero. Otherwise the routine
 24.1101 +prints an error message and returns non-zero.
 24.1102 +
 24.1103 +\newpage
 24.1104 +
 24.1105 +\subsection{glp\_read\_mip---read MIP solution from text file}
 24.1106 +
 24.1107 +\subsubsection*{Synopsis}
 24.1108 +
 24.1109 +\begin{verbatim}
 24.1110 +int glp_read_mip(glp_prob *mip, const char *fname);
 24.1111 +\end{verbatim}
 24.1112 +
 24.1113 +\subsubsection*{Description}
 24.1114 +
 24.1115 +The routine \verb|glp_read_mip| reads MIP solution from a text file
 24.1116 +whose name is specified by the parameter \verb|fname| into the problem
 24.1117 +object.
 24.1118 +
 24.1119 +For the file format see description of the routine \verb|glp_write_mip|.
 24.1120 +
 24.1121 +\subsubsection*{Returns}
 24.1122 +
 24.1123 +On success the routine returns zero, otherwise non-zero.
 24.1124 +
 24.1125 +\subsection{glp\_write\_mip---write MIP solution to text file}
 24.1126 +
 24.1127 +\subsubsection*{Synopsis}
 24.1128 +
 24.1129 +\begin{verbatim}
 24.1130 +int glp_write_mip(glp_prob *mip, const char *fname);
 24.1131 +\end{verbatim}
 24.1132 +
 24.1133 +\subsubsection*{Description}
 24.1134 +
 24.1135 +The routine \verb|glp_write_mip| writes the current MIP solution to a
 24.1136 +text file whose name is specified by the parameter \verb|fname|. This
 24.1137 +file can be read back with the routine \verb|glp_read_mip|.
 24.1138 +
 24.1139 +\subsubsection*{Returns}
 24.1140 +
 24.1141 +On success the routine returns zero, otherwise non-zero.
 24.1142 +
 24.1143 +\subsubsection*{File format}
 24.1144 +
 24.1145 +The file created by the routine \verb|glp_write_sol| is a plain text
 24.1146 +file, which contains the following information:
 24.1147 +
 24.1148 +\begin{verbatim}
 24.1149 +   m n
 24.1150 +   stat obj_val
 24.1151 +   r_val[1]
 24.1152 +   . . .
 24.1153 +   r_val[m]
 24.1154 +   c_val[1]
 24.1155 +   . . .
 24.1156 +   c_val[n]
 24.1157 +\end{verbatim}
 24.1158 +
 24.1159 +\noindent
 24.1160 +where:
 24.1161 +
 24.1162 +\noindent
 24.1163 +$m$ is the number of rows (auxiliary variables);
 24.1164 +
 24.1165 +\noindent
 24.1166 +$n$ is the number of columns (structural variables);
 24.1167 +
 24.1168 +\noindent
 24.1169 +\verb|stat| is the solution status (\verb|GLP_UNDEF| = 1,
 24.1170 +\verb|GLP_FEAS| = 2, \verb|GLP_NOFEAS| = 4, or \verb|GLP_OPT| = 5);
 24.1171 +
 24.1172 +\noindent
 24.1173 +\verb|obj_val| is the objective value;
 24.1174 +
 24.1175 +\noindent
 24.1176 +\verb|r_val[i]|, $i=1,\dots,m$, is the value of $i$-th row;
 24.1177 +
 24.1178 +\noindent
 24.1179 +\verb|c_val[j]|, $j=1,\dots,n$, is the value of $j$-th column.
 24.1180 +
 24.1181 +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 24.1182 +
 24.1183 +\newpage
 24.1184 +
 24.1185 +\section{Post-optimal analysis routines}
 24.1186 +
 24.1187 +\subsection{glp\_print\_ranges---print sensitivity analysis report}
 24.1188 +
 24.1189 +\subsubsection*{Synopsis}
 24.1190 +
 24.1191 +\begin{verbatim}
 24.1192 +int glp_print_ranges(glp_prob *P, int len, const int list[],
 24.1193 +      int flags, const char *fname);
 24.1194 +\end{verbatim}
 24.1195 +
 24.1196 +\subsubsection*{Description}
 24.1197 +
 24.1198 +The routine \verb|glp_print_ranges| performs sensitivity analysis of
 24.1199 +current optimal basic solution and writes the analysis report in
 24.1200 +human-readable format to a text file, whose name is the character
 24.1201 +string {\it fname}. (Detailed description of the report structure is
 24.1202 +given below.)
 24.1203 +
 24.1204 +The parameter {\it len} specifies the length of the row/column list.
 24.1205 +
 24.1206 +The array {\it list} specifies ordinal number of rows and columns to be
 24.1207 +analyzed. The ordinal numbers should be passed in locations
 24.1208 +{\it list}[1], {\it list}[2], \dots, {\it list}[{\it len}]. Ordinal
 24.1209 +numbers from 1 to $m$ refer to rows, and ordinal numbers from $m+1$ to
 24.1210 +$m+n$ refer to columns, where $m$ and $n$ are, resp., the total number
 24.1211 +of rows and columns in the problem object. Rows and columns appear in
 24.1212 +the analysis report in the same order as they follow in the array list.
 24.1213 +
 24.1214 +It is allowed to specify $len=0$, in which case the array {\it list} is
 24.1215 +not used (so it can be specified as \verb|NULL|), and the routine
 24.1216 +performs analysis for all rows and columns of the problem object.
 24.1217 +
 24.1218 +The parameter {\it flags} is reserved for use in the future and must be
 24.1219 +specified as zero.
 24.1220 +
 24.1221 +On entry to the routine \verb|glp_print_ranges| the current basic
 24.1222 +solution must be optimal and the basis factorization must exist.
 24.1223 +The application program can check that with the routine
 24.1224 +\verb|glp_bf_exists|, and if the factorization does
 24.1225 +not exist, compute it with the routine \verb|glp_factorize|. Note that
 24.1226 +if the LP preprocessor is not used, on normal exit from the simplex
 24.1227 +solver routine \verb|glp_simplex| the basis factorization always exists.
 24.1228 +
 24.1229 +\subsubsection*{Returns}
 24.1230 +
 24.1231 +If the operation was successful, the routine \verb|glp_print_ranges|
 24.1232 +returns zero. Otherwise, it prints an error message and returns
 24.1233 +non-zero.
 24.1234 +
 24.1235 +\subsubsection*{Analysis report example}
 24.1236 +
 24.1237 +An example of the sensitivity analysis report is shown on the next two
 24.1238 +pages. This example corresponds to the example of LP problem described
 24.1239 +in Subsection ``Example of MPS file''.
 24.1240 +
 24.1241 +\subsubsection*{Structure of the analysis report}
 24.1242 +
 24.1243 +For each row and column specified in the array {\it list} the routine
 24.1244 +prints two lines containing generic information and analysis
 24.1245 +information, which depends on the status of corresponding row or column.
 24.1246 +
 24.1247 +Note that analysis of a row is analysis of its auxiliary variable,
 24.1248 +which is equal to the row linear form $\sum a_jx_j$, and analysis of
 24.1249 +a column is analysis of corresponding structural variable. Therefore,
 24.1250 +formally, on performing the sensitivity analysis there is no difference
 24.1251 +between rows and columns.
 24.1252 +
 24.1253 +\bigskip
 24.1254 +
 24.1255 +\noindent
 24.1256 +{\it Generic information}
 24.1257 +
 24.1258 +\medskip
 24.1259 +
 24.1260 +\noindent
 24.1261 +{\tt No.} is the row or column ordinal number in the problem object.
 24.1262 +Rows are numbered from 1 to $m$, and columns are numbered from 1 to $n$,
 24.1263 +where $m$ and $n$ are, resp., the total number of rows and columns in
 24.1264 +the problem object.
 24.1265 +
 24.1266 +\medskip
 24.1267 +
 24.1268 +\noindent
 24.1269 +{\tt Row name} is the symbolic name assigned to the row. If the row has
 24.1270 +no name assigned, this field contains blanks.
 24.1271 +
 24.1272 +\medskip
 24.1273 +
 24.1274 +\noindent
 24.1275 +{\tt Column name} is the symbolic name assigned to the column. If the
 24.1276 +column has no name assigned, this field contains blanks.
 24.1277 +
 24.1278 +\medskip
 24.1279 +
 24.1280 +\noindent
 24.1281 +{\tt St} is the status of the row or column in the optimal solution:
 24.1282 +
 24.1283 +{\tt BS} --- non-active constraint (row), basic column;
 24.1284 +
 24.1285 +{\tt NL} --- inequality constraint having its lower right-hand side
 24.1286 +active (row), non-basic column having its lower bound active;
 24.1287 +
 24.1288 +{\tt NU} --- inequality constraint having its upper right-hand side
 24.1289 +active (row), non-basic column having its upper bound active;
 24.1290 +
 24.1291 +{\tt NS} --- active equality constraint (row), non-basic fixed column.
 24.1292 +
 24.1293 +{\tt NF} --- active free row, non-basic free (unbounded) column. (This
 24.1294 +case means that the optimal solution is dual degenerate.)
 24.1295 +
 24.1296 +\medskip
 24.1297 +
 24.1298 +\noindent
 24.1299 +{\tt Activity} is the (primal) value of the auxiliary variable (row) or
 24.1300 +structural variable (column) in the optimal solution.
 24.1301 +
 24.1302 +\medskip
 24.1303 +
 24.1304 +\noindent
 24.1305 +{\tt Slack} is the (primal) value of the row slack variable.
 24.1306 +
 24.1307 +\medskip
 24.1308 +
 24.1309 +\noindent
 24.1310 +{\tt Obj coef} is the objective coefficient of the column (structural
 24.1311 +variable).
 24.1312 +
 24.1313 +\begin{landscape}
 24.1314 +\begin{scriptsize}
 24.1315 +\begin{verbatim}
 24.1316 +GLPK 4.42 - SENSITIVITY ANALYSIS REPORT                                                                         Page   1
 24.1317 +
 24.1318 +Problem:    PLAN
 24.1319 +Objective:  VALUE = 296.2166065 (MINimum)
 24.1320 +
 24.1321 +   No. Row name     St      Activity         Slack   Lower bound       Activity      Obj coef  Obj value at Limiting
 24.1322 +                                          Marginal   Upper bound          range         range   break point variable
 24.1323 +------ ------------ -- ------------- ------------- -------------  ------------- ------------- ------------- ------------
 24.1324 +     1 VALUE        BS     296.21661    -296.21661          -Inf      299.25255      -1.00000        .      MN
 24.1325 +                                            .               +Inf      296.21661          +Inf          +Inf
 24.1326 +
 24.1327 +     2 YIELD        NS    2000.00000        .         2000.00000     1995.06864          -Inf     296.28365 BIN3
 24.1328 +                                           -.01360    2000.00000     2014.03479          +Inf     296.02579 CU
 24.1329 +
 24.1330 +     3 FE           NU      60.00000        .               -Inf       55.89016          -Inf     306.77162 BIN4
 24.1331 +                                          -2.56823      60.00000       62.69978       2.56823     289.28294 BIN3
 24.1332 +
 24.1333 +     4 CU           BS      83.96751      16.03249          -Inf       93.88467       -.30613     270.51157 MN
 24.1334 +                                            .          100.00000       79.98213        .21474     314.24798 BIN5
 24.1335 +
 24.1336 +     5 MN           NU      40.00000        .               -Inf       34.42336          -Inf     299.25255 BIN4
 24.1337 +                                           -.54440      40.00000       41.68691        .54440     295.29825 BIN3
 24.1338 +
 24.1339 +     6 MG           BS      19.96029      10.03971          -Inf       24.74427      -1.79618     260.36433 BIN1
 24.1340 +                                            .           30.00000        9.40292        .28757     301.95652 MN
 24.1341 +
 24.1342 +     7 AL           NL    1500.00000        .         1500.00000     1485.78425       -.25199     292.63444 CU
 24.1343 +                                            .25199          +Inf     1504.92126          +Inf     297.45669 BIN3
 24.1344 +
 24.1345 +     8 SI           NL     250.00000      50.00000     250.00000      235.32871       -.48520     289.09812 CU
 24.1346 +                                            .48520     300.00000      255.06073          +Inf     298.67206 BIN3
 24.1347 +\end{verbatim}
 24.1348 +\end{scriptsize}
 24.1349 +\end{landscape}
 24.1350 +
 24.1351 +\begin{landscape}
 24.1352 +\begin{scriptsize}
 24.1353 +\begin{verbatim}
 24.1354 +GLPK 4.42 - SENSITIVITY ANALYSIS REPORT                                                                         Page   2
 24.1355 +
 24.1356 +Problem:    PLAN
 24.1357 +Objective:  VALUE = 296.2166065 (MINimum)
 24.1358 +
 24.1359 +   No. Column name  St      Activity      Obj coef   Lower bound       Activity      Obj coef  Obj value at Limiting
 24.1360 +                                          Marginal   Upper bound          range         range   break point variable
 24.1361 +------ ------------ -- ------------- ------------- -------------  ------------- ------------- ------------- ------------
 24.1362 +     1 BIN1         NL        .             .03000        .           -28.82475       -.22362     288.90594 BIN4
 24.1363 +                                            .25362     200.00000       33.88040          +Inf     304.80951 BIN4
 24.1364 +
 24.1365 +     2 BIN2         BS     665.34296        .08000        .           802.22222        .01722     254.44822 BIN1
 24.1366 +                                            .         2500.00000      313.43066        .08863     301.95652 MN
 24.1367 +
 24.1368 +     3 BIN3         BS     490.25271        .17000     400.00000      788.61314        .15982     291.22807 MN
 24.1369 +                                            .          800.00000     -347.42857        .17948     300.86548 BIN5
 24.1370 +
 24.1371 +     4 BIN4         BS     424.18773        .12000     100.00000      710.52632        .10899     291.54745 MN
 24.1372 +                                            .          700.00000     -256.15524        .14651     307.46010 BIN1
 24.1373 +
 24.1374 +     5 BIN5         NL        .             .15000        .          -201.78739        .13544     293.27940 BIN3
 24.1375 +                                            .01456    1500.00000       58.79586          +Inf     297.07244 BIN3
 24.1376 +
 24.1377 +     6 ALUM         BS     299.63899        .21000        .           358.26772        .18885     289.87879 AL
 24.1378 +                                            .               +Inf      112.40876        .22622     301.07527 MN
 24.1379 +
 24.1380 +     7 SILICON      BS     120.57762        .38000        .           124.27093        .14828     268.27586 BIN5
 24.1381 +                                            .               +Inf       85.54745        .46667     306.66667 MN
 24.1382 +
 24.1383 +End of report
 24.1384 +\end{verbatim}
 24.1385 +\end{scriptsize}
 24.1386 +\end{landscape}
 24.1387 +
 24.1388 +\noindent
 24.1389 +{\tt Marginal} is the reduced cost (dual activity) of the auxiliary
 24.1390 +variable (row) or structural variable (column).
 24.1391 +
 24.1392 +\medskip
 24.1393 +
 24.1394 +\noindent
 24.1395 +{\tt Lower bound} is the lower right-hand side (row) or lower bound
 24.1396 +(column). If the row or column has no lower bound, this field contains
 24.1397 +{\tt -Inf}.
 24.1398 +
 24.1399 +\medskip
 24.1400 +
 24.1401 +\noindent
 24.1402 +{\tt Upper bound} is the upper right-hand side (row) or upper bound
 24.1403 +(column). If the row or column has no upper bound, this field contains
 24.1404 +{\tt +Inf}.
 24.1405 +
 24.1406 +\bigskip
 24.1407 +
 24.1408 +\noindent
 24.1409 +{\it Sensitivity analysis of active bounds}
 24.1410 +
 24.1411 +\medskip
 24.1412 +
 24.1413 +\noindent
 24.1414 +The sensitivity analysis of active bounds is performed only for rows,
 24.1415 +which are active constraints, and only for non-basic columns, because
 24.1416 +inactive constraints and basic columns have no active bounds.
 24.1417 +
 24.1418 +For every auxiliary (row) or structural (column) non-basic variable the
 24.1419 +routine starts changing its active bound in both direction. The first
 24.1420 +of the two lines in the report corresponds to decreasing, and the
 24.1421 +second line corresponds to increasing of the active bound. Since the
 24.1422 +variable being analyzed is non-basic, its activity, which is equal to
 24.1423 +its active bound, also starts changing. This changing leads to changing
 24.1424 +of basic (auxiliary and structural) variables, which depend on the
 24.1425 +non-basic variable. The current basis remains primal feasible and
 24.1426 +therefore optimal while values of all basic variables are primal
 24.1427 +feasible, i.e. are within their bounds. Therefore, if some basic
 24.1428 +variable called the {\it limiting variable} reaches its (lower or
 24.1429 +upper) bound first, before any other basic variables, it thereby limits
 24.1430 +further changing of the non-basic variable, because otherwise the
 24.1431 +current basis would become primal infeasible. The point, at which this
 24.1432 +happens, is called the {\it break point}. Note that there are two break
 24.1433 +points: the lower break point, which corresponds to decreasing of the
 24.1434 +non-basic variable, and the upper break point, which corresponds to
 24.1435 +increasing of the non-basic variable.
 24.1436 +
 24.1437 +In the analysis report values of the non-basic variable (i.e. of its
 24.1438 +active bound) being analyzed at both lower and upper break points are
 24.1439 +printed in the field `{\tt Activity range}'. Corresponding values of
 24.1440 +the objective function are printed in the field `{\tt Obj value at
 24.1441 +break point}', and symbolic names of corresponding limiting basic
 24.1442 +variables are printed in the field `{\tt Limiting variable}'.
 24.1443 +If the active bound can decrease or/and increase unlimitedly, the field
 24.1444 +`{\tt Activity range}' contains {\tt -Inf} or/and {\tt +Inf}, resp.
 24.1445 +
 24.1446 +For example (see the example report above), row SI is a double-sided
 24.1447 +constraint, which is active on its lower bound (right-hand side), and
 24.1448 +its activity in the optimal solution being equal to the lower bound is
 24.1449 +250. The activity range for this row is $[235.32871,255.06073]$. This
 24.1450 +means that the basis remains optimal while the lower bound is
 24.1451 +increasing up to 255.06073, and further increasing is limited by
 24.1452 +(structural) variable BIN3. If the lower bound reaches this upper break
 24.1453 +point, the objective value becomes equal to 298.67206.
 24.1454 +
 24.1455 +Note that if the basis does not change, the objective function depends
 24.1456 +on the non-basic variable linearly, and the per-unit change of the
 24.1457 +objective function is the reduced cost (marginal value) of the
 24.1458 +non-basic variable.
 24.1459 +
 24.1460 +\bigskip
 24.1461 +
 24.1462 +\noindent
 24.1463 +{\it Sensitivity analysis of objective coefficients at non-basic
 24.1464 +variables}
 24.1465 +
 24.1466 +\medskip
 24.1467 +
 24.1468 +\noindent
 24.1469 +The sensitivity analysis of the objective coefficient at a non-basic
 24.1470 +variable is quite simple, because in this case change in the objective
 24.1471 +coefficient leads to equivalent change in the reduced cost (marginal
 24.1472 +value).
 24.1473 +
 24.1474 +For every auxiliary (row) or structural (column) non-basic variable the
 24.1475 +routine starts changing its objective coefficient in both direction.
 24.1476 +(Note that auxiliary variables are not included in the objective
 24.1477 +function and therefore always have zero objective coefficients.) The
 24.1478 +first of the two lines in the report corresponds to decreasing, and the
 24.1479 +second line corresponds to increasing of the objective coefficient.
 24.1480 +This changing leads to changing of the reduced cost of the non-basic
 24.1481 +variable to be analyzed and does affect reduced costs of all other
 24.1482 +non-basic variables. The current basis remains dual feasible and
 24.1483 +therefore optimal while the reduced cost keeps its sign. Therefore, if
 24.1484 +the reduced cost reaches zero, it limits further changing of the
 24.1485 +objective coefficient (if only the non-basic variable is non-fixed).
 24.1486 +
 24.1487 +In the analysis report minimal and maximal values of the objective
 24.1488 +coefficient, on which the basis remains optimal, are printed in the
 24.1489 +field `\verb|Obj coef range|'. If the objective coefficient can
 24.1490 +decrease or/and increase unlimitedly, this field contains {\tt -Inf}
 24.1491 +or/and {\tt +Inf}, resp.
 24.1492 +
 24.1493 +For example (see the example report above), column BIN5 is non-basic
 24.1494 +having its lower bound active. Its objective coefficient is 0.15, and
 24.1495 +reduced cost in the optimal solution 0.01456. The column lower bound
 24.1496 +remains active while the column reduced cost remains non-negative,
 24.1497 +thus, minimal value of the objective coefficient, on which the current
 24.1498 +basis still remains optimal, is $0.15-0.01456=0.13644$, that is
 24.1499 +indicated in the field `\verb|Obj coef range|'.
 24.1500 +
 24.1501 +\bigskip
 24.1502 +
 24.1503 +\noindent
 24.1504 +{\it Sensitivity analysis of objective coefficients at basic variables}
 24.1505 +
 24.1506 +\medskip
 24.1507 +
 24.1508 +\noindent
 24.1509 +To perform sensitivity analysis for every auxiliary (row) or structural
 24.1510 +(column) variable the routine starts changing its objective coefficient
 24.1511 +in both direction. (Note that auxiliary variables are not included in
 24.1512 +the objective function and therefore always have zero objective
 24.1513 +coefficients.) The first of the two lines in the report corresponds to
 24.1514 +decreasing, and the second line corresponds to increasing of the
 24.1515 +objective coefficient. This changing leads to changing of reduced costs
 24.1516 +of non-basic variables. The current basis remains dual feasible and
 24.1517 +therefore optimal while reduced costs of all non-basic variables
 24.1518 +(except fixed variables) keep their signs. Therefore, if the reduced
 24.1519 +cost of some non-basic non-fixed variable called the {\it limiting
 24.1520 +variable} reaches zero first, before reduced cost of any other
 24.1521 +non-basic non-fixed variable, it thereby limits further changing of the
 24.1522 +objective coefficient, because otherwise the current basis would become
 24.1523 +dual infeasible (non-optimal). The point, at which this happens, is
 24.1524 +called the {\it break point}. Note that there are two break points: the
 24.1525 +lower break point, which corresponds to decreasing of the objective
 24.1526 +coefficient, and the upper break point, which corresponds to increasing
 24.1527 +of the objective coefficient. Let the objective coefficient reach its
 24.1528 +limit value and continue changing a bit further in the same direction
 24.1529 +that makes the current basis dual infeasible (non-optimal). Then the
 24.1530 +reduced cost of the non-basic limiting variable becomes ``a bit'' dual
 24.1531 +infeasible that forces the limiting variable to enter the basis
 24.1532 +replacing there some basic variable, which leaves the basis to keep its
 24.1533 +primal feasibility. It should be understood that if we change the
 24.1534 +current basis in this way exactly at the break point, both the current
 24.1535 +and adjacent bases will be optimal with the same objective value,
 24.1536 +because at the break point the limiting variable has zero reduced cost.
 24.1537 +On the other hand, in the adjacent basis the value of the limiting
 24.1538 +variable changes, because there it becomes basic, that leads to
 24.1539 +changing of the value of the basic variable being analyzed. Note that
 24.1540 +on determining the adjacent basis the bounds of the analyzed basic
 24.1541 +variable are ignored as if it were a free (unbounded) variable, so it
 24.1542 +cannot leave the current basis.
 24.1543 +
 24.1544 +In the analysis report lower and upper limits of the objective
 24.1545 +coefficient at the basic variable being analyzed, when the basis
 24.1546 +remains optimal, are printed in the field `{\tt Obj coef range}'.
 24.1547 +Corresponding values of the objective function at both lower and upper
 24.1548 +break points are printed in the field `{\tt Obj value at break point}',
 24.1549 +symbolic names of corresponding non-basic limiting variables are
 24.1550 +printed in the field `{\tt Limiting variable}', and values of the basic
 24.1551 +variable, which it would take on in the adjacent bases (as was
 24.1552 +explained above) are printed in the field `{\tt Activity range}'.
 24.1553 +If the objective coefficient can increase or/and decrease unlimitedly,
 24.1554 +the field `{\tt Obj coef range}' contains {\tt -Inf} and/or {\tt +Inf},
 24.1555 +resp. It also may happen that no dual feasible adjacent basis exists
 24.1556 +(i.e. on entering the basis the limiting variable can increase or
 24.1557 +decrease unlimitedly), in which case the field `{\tt Activity range}'
 24.1558 +contains {\tt -Inf} and/or {\tt +Inf}.
 24.1559 +
 24.1560 +\newpage
 24.1561 +
 24.1562 +For example (see the example report above), structural variable
 24.1563 +(column) BIN3 is basic, its optimal value is 490.25271, and its
 24.1564 +objective coefficient is 0.17. The objective coefficient range for this
 24.1565 +column is $[0.15982,0.17948]$. This means that the basis remains
 24.1566 +optimal while the objective coefficient is decreasing down to 0.15982,
 24.1567 +and further decreasing is limited by (auxiliary) variable MN. If we
 24.1568 +make the objective coefficient a bit less than 0.15982, the limiting
 24.1569 +variable MN will enter the basis, and in that adjacent basis the
 24.1570 +structural variable BIN3 will take on new optimal value 788.61314. At
 24.1571 +the lower break point, where the objective coefficient is exactly
 24.1572 +0.15982, the objective function takes on the value 291.22807 in both
 24.1573 +the current and adjacent bases.
 24.1574 +
 24.1575 +Note that if the basis does not change, the objective function depends
 24.1576 +on the objective coefficient at the basic variable linearly, and the
 24.1577 +per-unit change of the objective function is the value of the basic
 24.1578 +variable.
 24.1579 +
 24.1580 +%* eof *%
    25.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    25.2 +++ b/deps/glpk/doc/glpk04.tex	Sun Nov 06 20:59:10 2011 +0100
    25.3 @@ -0,0 +1,1411 @@
    25.4 +%* glpk04.tex *%
    25.5 +
    25.6 +\chapter{Advanced API Routines}
    25.7 +
    25.8 +\section{Background}
    25.9 +\label{basbgd}
   25.10 +
   25.11 +Using vector and matrix notations LP problem (1.1)---(1.3) (see Section
   25.12 +\ref{seclp}, page \pageref{seclp}) can be stated as follows:
   25.13 +
   25.14 +\medskip
   25.15 +
   25.16 +\noindent
   25.17 +\hspace{.5in} minimize (or maximize)
   25.18 +$$z=c^Tx_S+c_0\eqno(3.1)$$
   25.19 +\hspace{.5in} subject to linear constraints
   25.20 +$$x_R=Ax_S\eqno(3.2)$$
   25.21 +\hspace{.5in} and bounds of variables
   25.22 +$$
   25.23 +\begin{array}{l@{\ }c@{\ }l@{\ }c@{\ }l}
   25.24 +l_R&\leq&x_R&\leq&u_R\\
   25.25 +l_S&\leq&x_S&\leq&u_S\\
   25.26 +\end{array}\eqno(3.3)
   25.27 +$$
   25.28 +where:
   25.29 +
   25.30 +\noindent
   25.31 +$x_R=(x_1,\dots,x_m)$ is the vector of auxiliary variables;
   25.32 +
   25.33 +\noindent
   25.34 +$x_S=(x_{m+1},\dots,x_{m+n})$ is the vector of structural
   25.35 +variables;
   25.36 +
   25.37 +\noindent
   25.38 +$z$ is the objective function;
   25.39 +
   25.40 +\noindent
   25.41 +$c=(c_1,\dots,c_n)$ is the vector of objective coefficients;
   25.42 +
   25.43 +\noindent
   25.44 +$c_0$ is the constant term (``shift'') of the objective function;
   25.45 +
   25.46 +\noindent
   25.47 +$A=(a_{11},\dots,a_{mn})$ is the constraint matrix;
   25.48 +
   25.49 +\noindent
   25.50 +$l_R=(l_1,\dots,l_m)$ is the vector of lower bounds of auxiliary
   25.51 +variables;
   25.52 +
   25.53 +\noindent
   25.54 +$u_R=(u_1,\dots,u_m)$ is the vector of upper bounds of auxiliary
   25.55 +variables;
   25.56 +
   25.57 +\noindent
   25.58 +$l_S=(l_{m+1},\dots,l_{m+n})$ is the vector of lower bounds of
   25.59 +structural variables;
   25.60 +
   25.61 +\noindent
   25.62 +$u_S=(u_{m+1},\dots,u_{m+n})$ is the vector of upper bounds of
   25.63 +structural variables.
   25.64 +
   25.65 +\medskip
   25.66 +
   25.67 +From the simplex method's standpoint there is no difference between
   25.68 +auxiliary and structural variables. This allows combining all these
   25.69 +variables into one vector that leads to the following problem statement:
   25.70 +
   25.71 +\medskip
   25.72 +
   25.73 +\noindent
   25.74 +\hspace{.5in} minimize (or maximize)
   25.75 +$$z=(0\ |\ c)^Tx+c_0\eqno(3.4)$$
   25.76 +\hspace{.5in} subject to linear constraints
   25.77 +$$(I\ |-\!A)x=0\eqno(3.5)$$
   25.78 +\hspace{.5in} and bounds of variables
   25.79 +$$l\leq x\leq u\eqno(3.6)$$
   25.80 +where:
   25.81 +
   25.82 +\noindent
   25.83 +$x=(x_R\ |\ x_S)$ is the $(m+n)$-vector of (all) variables;
   25.84 +
   25.85 +\noindent
   25.86 +$(0\ |\ c)$ is the $(m+n)$-vector of objective
   25.87 +coefficients;\footnote{Subvector 0 corresponds to objective coefficients
   25.88 +at auxiliary variables.}
   25.89 +
   25.90 +\noindent
   25.91 +$(I\ |-\!A)$ is the {\it augmented} constraint
   25.92 +$m\times(m+n)$-matrix;\footnote{Note that due to auxiliary variables
   25.93 +matrix $(I\ |-\!A)$ contains the unity submatrix and therefore has full
   25.94 +rank. This means, in particular, that the system (3.5) has no linearly
   25.95 +dependent constraints.}
   25.96 +
   25.97 +\noindent
   25.98 +$l=(l_R\ |\ l_S)$ is the $(m+n)$-vector of lower bounds of (all)
   25.99 +variables;
  25.100 +
  25.101 +\noindent
  25.102 +$u=(u_R\ |\ u_S)$ is the $(m+n)$-vector of upper bounds of (all)
  25.103 +variables.
  25.104 +
  25.105 +\medskip
  25.106 +
  25.107 +By definition an {\it LP basic solution} geometrically is a point in
  25.108 +the space of all variables, which is the intersection of planes
  25.109 +corresponding to active constraints\footnote{A constraint is called
  25.110 +{\it active} if in a given point it is satisfied as equality, otherwise
  25.111 +it is called {\it inactive}.}. The space of all variables has the
  25.112 +dimension $m+n$, therefore, to define some basic solution we have to
  25.113 +define $m+n$ active constraints. Note that $m$ constraints (3.5) being
  25.114 +linearly independent equalities are always active, so remaining $n$
  25.115 +active constraints can be chosen only from bound constraints (3.6).
  25.116 +
  25.117 +A variable is called {\it non-basic}, if its (lower or upper) bound is
  25.118 +active, otherwise it is called {\it basic}. Since, as was said above,
  25.119 +exactly $n$ bound constraints must be active, in any basic solution
  25.120 +there are always $n$ non-basic variables and $m$ basic variables.
  25.121 +(Note that a free variable also can be non-basic. Although such
  25.122 +variable has no bounds, we can think it as the difference between two
  25.123 +non-negative variables, which both are non-basic in this case.)
  25.124 +
  25.125 +Now consider how to determine numeric values of all variables for a
  25.126 +given basic solution.
  25.127 +
  25.128 +Let $\Pi$ be an appropriate permutation matrix of the order $(m+n)$.
  25.129 +Then we can write:
  25.130 +$$\left(\begin{array}{@{}c@{}}x_B\\x_N\\\end{array}\right)=
  25.131 +\Pi\left(\begin{array}{@{}c@{}}x_R\\x_S\\\end{array}\right)=\Pi x,
  25.132 +\eqno(3.7)$$
  25.133 +where $x_B$ is the vector of basic variables, $x_N$ is the vector of
  25.134 +non-basic variables, $x=(x_R\ |\ x_S)$ is the vector of all variables
  25.135 +in the original order. In this case the system of linear constraints
  25.136 +(3.5) can be rewritten as follows:
  25.137 +$$(I\ |-\!A)\Pi^T\Pi x=0\ \ \ \Rightarrow\ \ \ (B\ |\ N)
  25.138 +\left(\begin{array}{@{}c@{}}x_B\\x_N\\\end{array}\right)=0,\eqno(3.8)$$
  25.139 +where
  25.140 +$$(B\ |\ N)=(I\ |-\!A)\Pi^T.\eqno(3.9)$$
  25.141 +Matrix $B$ is a square non-singular $m\times m$-matrix, which is
  25.142 +composed from columns of the augmented constraint matrix corresponding
  25.143 +to basic variables. It is called the {\it basis matrix} or simply the
  25.144 +{\it basis}. Matrix $N$ is a rectangular $m\times n$-matrix, which is
  25.145 +composed from columns of the augmented constraint matrix corresponding
  25.146 +to non-basic variables.
  25.147 +
  25.148 +From (3.8) it follows that:
  25.149 +$$Bx_B+Nx_N=0,\eqno(3.10)$$
  25.150 +therefore,
  25.151 +$$x_B=-B^{-1}Nx_N.\eqno(3.11)$$
  25.152 +Thus, the formula (3.11) shows how to determine numeric values of basic
  25.153 +variables $x_B$ assuming that non-basic variables $x_N$ are fixed on
  25.154 +their active bounds.
  25.155 +
  25.156 +The $m\times n$-matrix
  25.157 +$$\Xi=-B^{-1}N,\eqno(3.12)$$
  25.158 +which appears in (3.11), is called the {\it simplex
  25.159 +tableau}.\footnote{This definition corresponds to the GLPK
  25.160 +implementation.} It shows how basic variables depend on non-basic
  25.161 +variables:
  25.162 +$$x_B=\Xi x_N.\eqno(3.13)$$
  25.163 +
  25.164 +The system (3.13) is equivalent to the system (3.5) in the sense that
  25.165 +they both define the same set of points in the space of (primal)
  25.166 +variables, which satisfy to these systems. If, moreover, values of all
  25.167 +basic variables satisfy to their bound constraints (3.3), the
  25.168 +corresponding basic solution is called {\it (primal) feasible},
  25.169 +otherwise {\it (primal) infeasible}. It is understood that any (primal)
  25.170 +feasible basic solution satisfy to all constraints (3.2) and (3.3).
  25.171 +
  25.172 +The LP theory says that if LP has optimal solution, it has (at least
  25.173 +one) basic feasible solution, which corresponds to the optimum. And the
  25.174 +most natural way to determine whether a given basic solution is optimal
  25.175 +or not is to use the Karush---Kuhn---Tucker optimality conditions.
  25.176 +
  25.177 +\def\arraystretch{1.5}
  25.178 +
  25.179 +For the problem statement (3.4)---(3.6) the optimality conditions are
  25.180 +the following:\footnote{These conditions can be appiled to any solution,
  25.181 +not only to a basic solution.}
  25.182 +$$(I\ |-\!A)x=0\eqno(3.14)$$
  25.183 +$$(I\ |-\!A)^T\pi+\lambda_l+\lambda_u=\nabla z=(0\ |\ c)^T\eqno(3.15)$$
  25.184 +$$l\leq x\leq u\eqno(3.16)$$
  25.185 +$$\lambda_l\geq 0,\ \ \lambda_u\leq 0\ \ \mbox{(minimization)}
  25.186 +\eqno(3.17)$$
  25.187 +$$\lambda_l\leq 0,\ \ \lambda_u\geq 0\ \ \mbox{(maximization)}
  25.188 +\eqno(3.18)$$
  25.189 +$$(\lambda_l)_k(x_k-l_k)=0,\ \ (\lambda_u)_k(x_k-u_k)=0,\ \ k=1,2,\dots,
  25.190 +m+n\eqno(3.19)$$
  25.191 +where:
  25.192 +$\pi=(\pi_1,\pi_2,\dots,\pi_m)$ is a $m$-vector of Lagrange
  25.193 +multipliers for equality constraints (3.5);
  25.194 +$\lambda_l=[(\lambda_l)_1,(\lambda_l)_2,\dots,(\lambda_l)_n]$ is a
  25.195 +$n$-vector of Lagrange multipliers for lower bound constraints (3.6);
  25.196 +$\lambda_u=[(\lambda_u)_1,(\lambda_u)_2,\dots,(\lambda_u)_n]$ is a
  25.197 +$n$-vector of Lagrange multipliers for upper bound constraints (3.6).
  25.198 +
  25.199 +Condition (3.14) is the {\it primal} (original) system of equality
  25.200 +constraints (3.5).
  25.201 +
  25.202 +Condition (3.15) is the {\it dual} system of equality constraints.
  25.203 +It requires the gradient of the objective function to be a linear
  25.204 +combination of normals to the planes defined by constraints of the
  25.205 +original problem.
  25.206 +
  25.207 +Condition (3.16) is the primal (original) system of bound constraints
  25.208 +(3.6).
  25.209 +
  25.210 +Condition (3.17) (or (3.18) in case of maximization) is the dual system
  25.211 +of bound constraints.
  25.212 +
  25.213 +Condition (3.19) is the {\it complementary slackness condition}. It
  25.214 +requires, for each original (auxiliary or structural) variable $x_k$,
  25.215 +that either its (lower or upper) bound must be active, or zero bound of
  25.216 +the corresponding Lagrange multiplier ($(\lambda_l)_k$ or
  25.217 +$(\lambda_u)_k$) must be active.
  25.218 +
  25.219 +In GLPK two multipliers $(\lambda_l)_k$ and $(\lambda_u)_k$ for each
  25.220 +primal (original) variable $x_k$, $k=1,2,\dots,m+n$, are combined into
  25.221 +one multiplier:
  25.222 +$$\lambda_k=(\lambda_l)_k+(\lambda_u)_k,\eqno(3.20)$$
  25.223 +which is called a {\it dual variable} for $x_k$. This {\it cannot} lead
  25.224 +to the ambiguity, because both lower and upper bounds of $x_k$ cannot be
  25.225 +active at the same time,\footnote{If $x_k$ is a fixed variable, we can
  25.226 +think it as double-bounded variable $l_k\leq x_k\leq u_k$, where
  25.227 +$l_k=u_k.$} so at least one of $(\lambda_l)_k$ and $(\lambda_u)_k$ must
  25.228 +be equal to zero, and because these multipliers have different signs,
  25.229 +the combined multiplier, which is their sum, uniquely defines each of
  25.230 +them.
  25.231 +
  25.232 +\def\arraystretch{1}
  25.233 +
  25.234 +Using dual variables $\lambda_k$ the dual system of bound constraints
  25.235 +(3.17) and (3.18) can be written in the form of so called {\it ``rule of
  25.236 +signs''} as follows:
  25.237 +
  25.238 +\begin{center}
  25.239 +\begin{tabular}{|@{\,}c@{$\,$}|@{$\,$}c@{$\,$}|@{$\,$}c@{$\,$}|
  25.240 +@{$\,$}c|c@{$\,$}|@{$\,$}c@{$\,$}|@{$\,$}c@{$\,$}|}
  25.241 +\hline
  25.242 +Original bound&\multicolumn{3}{c|}{Minimization}&\multicolumn{3}{c|}
  25.243 +{Maximization}\\
  25.244 +\cline{2-7}
  25.245 +constraint&$(\lambda_l)_k$&$(\lambda_u)_k$&$(\lambda_l)_k+
  25.246 +(\lambda_u)_k$&$(\lambda_l)_k$&$(\lambda_u)_k$&$(\lambda_l)_k+
  25.247 +(\lambda_u)_k$\\
  25.248 +\hline
  25.249 +$-\infty<x_k<+\infty$&$=0$&$=0$&$\lambda_k=0$&$=0$&$=0$&$\lambda_k=0$\\
  25.250 +$x_k\geq l_k$&$\geq 0$&$=0$&$\lambda_k\geq 0$&$\leq 0$&$=0$&$\lambda_k
  25.251 +\leq0$\\
  25.252 +$x_k\leq u_k$&$=0$&$\leq 0$&$\lambda_k\leq 0$&$=0$&$\geq 0$&$\lambda_k
  25.253 +\geq0$\\
  25.254 +$l_k\leq x_k\leq u_k$&$\geq 0$& $\leq 0$& $-\infty\!<\!\lambda_k\!<
  25.255 +\!+\infty$
  25.256 +&$\leq 0$& $\geq 0$& $-\infty\!<\!\lambda_k\!<\!+\infty$\\
  25.257 +$x_k=l_k=u_k$&$\geq 0$& $\leq 0$& $-\infty\!<\!\lambda_k\!<\!+\infty$&
  25.258 +$\leq 0$&
  25.259 +$\geq 0$& $-\infty\!<\!\lambda_k\!<\!+\infty$\\
  25.260 +\hline
  25.261 +\end{tabular}
  25.262 +\end{center}
  25.263 +
  25.264 +May note that each primal variable $x_k$ has its dual counterpart
  25.265 +$\lambda_k$ and vice versa. This allows applying the same partition for
  25.266 +the vector of dual variables as (3.7):
  25.267 +$$\left(\begin{array}{@{}c@{}}\lambda_B\\\lambda_N\\\end{array}\right)=
  25.268 +\Pi\lambda,\eqno(3.21)$$
  25.269 +where $\lambda_B$ is a vector of dual variables for basic variables
  25.270 +$x_B$, $\lambda_N$ is a vector of dual variables for non-basic variables
  25.271 +$x_N$.
  25.272 +
  25.273 +By definition, bounds of basic variables are inactive constraints, so in
  25.274 +any basic solution $\lambda_B=0$. Corresponding values of dual variables
  25.275 +$\lambda_N$ for non-basic variables $x_N$ can be determined in the
  25.276 +following way. From the dual system (3.15) we have:
  25.277 +$$(I\ |-\!A)^T\pi+\lambda=(0\ |\ c)^T,\eqno(3.22)$$
  25.278 +so multiplying both sides of (3.22) by matrix $\Pi$ gives:
  25.279 +$$\Pi(I\ |-\!A)^T\pi+\Pi\lambda=\Pi(0\ |\ c)^T.\eqno(3.23)$$
  25.280 +From (3.9) it follows that
  25.281 +$$\Pi(I\ |-\!A)^T=[(I\ |-\!A)\Pi^T]^T=(B\ |\ N)^T.\eqno(3.24)$$
  25.282 +Further, we can apply the partition (3.7) also to the vector of
  25.283 +objective coefficients (see (3.4)):
  25.284 +$$\left(\begin{array}{@{}c@{}}c_B\\c_N\\\end{array}\right)=
  25.285 +\Pi\left(\begin{array}{@{}c@{}}0\\c\\\end{array}\right),\eqno(3.25)$$
  25.286 +where $c_B$ is a vector of objective coefficients at basic variables,
  25.287 +$c_N$ is a vector of objective coefficients at non-basic variables.
  25.288 +Now, substituting (3.24), (3.21), and (3.25) into (3.23), leads to:
  25.289 +$$(B\ |\ N)^T\pi+(\lambda_B\ |\ \lambda_N)^T=(c_B\ |\ c_N)^T,
  25.290 +\eqno(3.26)$$
  25.291 +and transposing both sides of (3.26) gives the system:
  25.292 +$$\left(\begin{array}{@{}c@{}}B^T\\N^T\\\end{array}\right)\pi+
  25.293 +\left(\begin{array}{@{}c@{}}\lambda_B\\\lambda_N\\\end{array}\right)=
  25.294 +\left(\begin{array}{@{}c@{}}c_B\\c_T\\\end{array}\right),\eqno(3.27)$$
  25.295 +which can be written as follows:
  25.296 +$$\left\{
  25.297 +\begin{array}{@{\ }r@{\ }c@{\ }r@{\ }c@{\ }l@{\ }}
  25.298 +B^T\pi&+&\lambda_B&=&c_B\\
  25.299 +N^T\pi&+&\lambda_N&=&c_N\\
  25.300 +\end{array}
  25.301 +\right.\eqno(3.28)
  25.302 +$$
  25.303 +Lagrange multipliers $\pi=(\pi_i)$ correspond to equality constraints
  25.304 +(3.5) and therefore can have any sign. This allows resolving the first
  25.305 +subsystem of (3.28) as follows:\footnote{$B^{-T}$ means $(B^T)^{-1}=
  25.306 +(B^{-1})^T$.}
  25.307 +$$\pi=B^{-T}(c_B-\lambda_B)=-B^{-T}\lambda_B+B^{-T}c_B,\eqno(3.29)$$
  25.308 +and substitution of $\pi$ from (3.29) into the second subsystem of
  25.309 +(3.28) gives:
  25.310 +$$\lambda_N=-N^T\pi+c_N=N^TB^{-T}\lambda_B+(c_N-N^TB^{-T}c_B).
  25.311 +\eqno(3.30)$$
  25.312 +The latter system can be written in the following final form:
  25.313 +$$\lambda_N=-\Xi^T\lambda_B+d,\eqno(3.31)$$
  25.314 +where $\Xi$ is the simplex tableau (see (3.12)), and
  25.315 +$$d=c_N-N^TB^{-T}c_B=c_N+\Xi^Tc_B\eqno(3.32)$$
  25.316 +is the vector of so called {\it reduced costs} of non-basic variables.
  25.317 +
  25.318 +\pagebreak
  25.319 +
  25.320 +Above it was said that in any basic solution $\lambda_B=0$, so
  25.321 +$\lambda_N=d$ as it follows from (3.31).
  25.322 +
  25.323 +The system (3.31) is equivalent to the system (3.15) in the sense that
  25.324 +they both define the same set of points in the space of dual variables
  25.325 +$\lambda$, which satisfy to these systems. If, moreover, values of all
  25.326 +dual variables $\lambda_N$ (i.e. reduced costs $d$) satisfy to their
  25.327 +bound constraints (i.e. to the ``rule of signs''; see the table above),
  25.328 +the corresponding basic solution is called {\it dual feasible},
  25.329 +otherwise {\it dual infeasible}. It is understood that any dual feasible
  25.330 +solution satisfy to all constraints (3.15) and (3.17) (or (3.18) in case
  25.331 +of maximization).
  25.332 +
  25.333 +It can be easily shown that the complementary slackness condition
  25.334 +(3.19) is always satisfied for {\it any} basic solution. Therefore,
  25.335 +a basic solution\footnote{It is assumed that a complete basic solution
  25.336 +has the form $(x,\lambda)$, i.e. it includes primal as well as dual
  25.337 +variables.} is {\it optimal} if and only if it is primal and dual
  25.338 +feasible, because in this case it satifies to all the optimality
  25.339 +conditions (3.14)---(3.19).
  25.340 +
  25.341 +\def\arraystretch{1.5}
  25.342 +
  25.343 +The meaning of reduced costs $d=(d_j)$ of non-basic variables can be
  25.344 +explained in the following way. From (3.4), (3.7), and (3.25) it follows
  25.345 +that:
  25.346 +$$z=c_B^Tx_B+c_N^Tx_N+c_0.\eqno(3.33)$$
  25.347 +Substituting $x_B$ from (3.11) into (3.33) we can eliminate basic
  25.348 +variables and express the objective only through non-basic variables:
  25.349 +$$
  25.350 +\begin{array}{r@{\ }c@{\ }l}
  25.351 +z&=&c_B^T(-B^{-1}Nx_N)+c_N^Tx_N+c_0=\\
  25.352 +&=&(c_N^T-c_B^TB^{-1}N)x_N+c_0=\\
  25.353 +&=&(c_N-N^TB^{-T}c_B)^Tx_N+c_0=\\
  25.354 +&=&d^Tx_N+c_0.
  25.355 +\end{array}\eqno(3.34)
  25.356 +$$
  25.357 +From (3.34) it is seen that reduced cost $d_j$ shows how the objective
  25.358 +function $z$ depends on non-basic variable $(x_N)_j$ in the neighborhood
  25.359 +of the current basic solution, i.e. while the current basis remains
  25.360 +unchanged.
  25.361 +
  25.362 +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  25.363 +
  25.364 +\newpage
  25.365 +
  25.366 +\section{LP basis routines}
  25.367 +\label{lpbasis}
  25.368 +
  25.369 +\subsection{glp\_bf\_exists---check if the basis factorization exists}
  25.370 +
  25.371 +\subsubsection*{Synopsis}
  25.372 +
  25.373 +\begin{verbatim}
  25.374 +int glp_bf_exists(glp_prob *lp);
  25.375 +\end{verbatim}
  25.376 +
  25.377 +\subsubsection*{Returns}
  25.378 +
  25.379 +If the basis factorization for the current basis associated with the
  25.380 +specified problem object exists and therefore is available for
  25.381 +computations, the routine \verb|glp_bf_exists| returns non-zero.
  25.382 +Otherwise the routine returns zero.
  25.383 +
  25.384 +\subsubsection*{Comments}
  25.385 +
  25.386 +Let the problem object have $m$ rows and $n$ columns. In GLPK the
  25.387 +{\it basis matrix} $B$ is a square non-singular matrix of the order $m$,
  25.388 +whose columns correspond to basic (auxiliary and/or structural)
  25.389 +variables. It is defined by the following main
  25.390 +equality:\footnote{For more details see Subsection \ref{basbgd},
  25.391 +page \pageref{basbgd}.}
  25.392 +$$(B\ |\ N)=(I\ |-\!A)\Pi^T,$$
  25.393 +where $I$ is the unity matrix of the order $m$, whose columns correspond
  25.394 +to auxiliary variables; $A$ is the original constraint
  25.395 +$m\times n$-matrix, whose columns correspond to structural variables;
  25.396 +$(I\ |-\!A)$ is the augmented constraint\linebreak
  25.397 +$m\times(m+n)$-matrix, whose columns correspond to all (auxiliary and
  25.398 +structural) variables following in the original order; $\Pi$ is a
  25.399 +permutation matrix of the order $m+n$; and $N$ is a rectangular
  25.400 +$m\times n$-matrix, whose columns correspond to non-basic (auxiliary
  25.401 +and/or structural) variables.
  25.402 +
  25.403 +For various reasons it may be necessary to solve linear systems with
  25.404 +matrix $B$. To provide this possibility the GLPK implementation
  25.405 +maintains an invertable form of $B$ (that is, some representation of
  25.406 +$B^{-1}$) called the {\it basis factorization}, which is an internal
  25.407 +component of the problem object. Typically, the basis factorization is
  25.408 +computed by the simplex solver, which keeps it in the problem object
  25.409 +to be available for other computations.
  25.410 +
  25.411 +Should note that any changes in the problem object, which affects the
  25.412 +basis matrix (e.g. changing the status of a row or column, changing
  25.413 +a basic column of the constraint matrix, removing an active constraint,
  25.414 +etc.), invalidates the basis factorization. So before calling any API
  25.415 +routine, which uses the basis factorization, the application program
  25.416 +must make sure (using the routine \verb|glp_bf_exists|) that the
  25.417 +factorization exists and therefore available for computations.
  25.418 +
  25.419 +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  25.420 +
  25.421 +\subsection{glp\_factorize---compute the basis factorization}
  25.422 +
  25.423 +\subsubsection*{Synopsis}
  25.424 +
  25.425 +\begin{verbatim}
  25.426 +int glp_factorize(glp_prob *lp);
  25.427 +\end{verbatim}
  25.428 +
  25.429 +\subsubsection*{Description}
  25.430 +
  25.431 +The routine \verb|glp_factorize| computes the basis factorization for
  25.432 +the current basis associated with the specified problem
  25.433 +object.\footnote{The current basis is defined by the current statuses
  25.434 +of rows (auxiliary variables) and columns (structural variables).}
  25.435 +
  25.436 +The basis factorization is computed from ``scratch'' even if it exists,
  25.437 +so the application program may use the routine \verb|glp_bf_exists|,
  25.438 +and, if the basis factorization already exists, not to call the routine
  25.439 +\verb|glp_factorize| to prevent an extra work.
  25.440 +
  25.441 +The routine \verb|glp_factorize| {\it does not} compute components of
  25.442 +the basic solution (i.e. primal and dual values).
  25.443 +
  25.444 +\subsubsection*{Returns}
  25.445 +
  25.446 +\begin{tabular}{@{}p{25mm}p{97.3mm}@{}}
  25.447 +0 & The basis factorization has been successfully computed.\\
  25.448 +\verb|GLP_EBADB| & The basis matrix is invalid, because the number of
  25.449 +basic (auxiliary and structural) variables is not the same as the number
  25.450 +of rows in the problem object.\\
  25.451 +\verb|GLP_ESING| & The basis matrix is singular within the working
  25.452 +precision.\\
  25.453 +\verb|GLP_ECOND| & The basis matrix is ill-conditioned, i.e. its
  25.454 +condition number is too large.\\
  25.455 +\end{tabular}
  25.456 +
  25.457 +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  25.458 +
  25.459 +\newpage
  25.460 +
  25.461 +\subsection{glp\_bf\_updated---check if the basis factorization has\\
  25.462 +been updated}
  25.463 +
  25.464 +\subsubsection*{Synopsis}
  25.465 +
  25.466 +\begin{verbatim}
  25.467 +int glp_bf_updated(glp_prob *lp);
  25.468 +\end{verbatim}
  25.469 +
  25.470 +\subsubsection*{Returns}
  25.471 +
  25.472 +If the basis factorization has been just computed from ``scratch'', the
  25.473 +routine \verb|glp_bf_updated| returns zero. Otherwise, if the
  25.474 +factorization has been updated at least once, the routine returns
  25.475 +non-zero.
  25.476 +
  25.477 +\subsubsection*{Comments}
  25.478 +
  25.479 +{\it Updating} the basis factorization means recomputing it to reflect
  25.480 +changes in the basis matrix. For example, on every iteration of the
  25.481 +simplex method some column of the current basis matrix is replaced by a
  25.482 +new column that gives a new basis matrix corresponding to the adjacent
  25.483 +basis. In this case computing the basis factorization for the adjacent
  25.484 +basis from ``scratch'' (as the routine \verb|glp_factorize| does) would
  25.485 +be too time-consuming.
  25.486 +
  25.487 +On the other hand, since the basis factorization update is a numeric
  25.488 +computational procedure, applying it many times may lead to accumulating
  25.489 +round-off errors. Therefore the basis is periodically refactorized
  25.490 +(reinverted) from ``scratch'' (with the routine \verb|glp_factorize|)
  25.491 +that allows improving its numerical properties.
  25.492 +
  25.493 +The routine \verb|glp_bf_updated| allows determining if the basis
  25.494 +factorization has been updated at least once since it was computed from
  25.495 +``scratch''.
  25.496 +
  25.497 +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  25.498 +
  25.499 +\newpage
  25.500 +
  25.501 +\subsection{glp\_get\_bfcp---retrieve basis factorization control
  25.502 +parameters}
  25.503 +
  25.504 +\subsubsection*{Synopsis}
  25.505 +
  25.506 +\begin{verbatim}
  25.507 +void glp_get_bfcp(glp_prob *lp, glp_bfcp *parm);
  25.508 +\end{verbatim}
  25.509 +
  25.510 +\subsubsection*{Description}
  25.511 +
  25.512 +The routine \verb|glp_get_bfcp| retrieves control parameters, which are
  25.513 +used on computing and updating the basis factorization associated with
  25.514 +the specified problem object.
  25.515 +
  25.516 +Current values of the control parameters are stored in a \verb|glp_bfcp|
  25.517 +structure, which the parameter \verb|parm| points to. For a detailed
  25.518 +description of the structure \verb|glp_bfcp| see comments to the routine
  25.519 +\verb|glp_set_bfcp| in the next subsection.
  25.520 +
  25.521 +\subsubsection*{Comments}
  25.522 +
  25.523 +The purpose of the routine \verb|glp_get_bfcp| is two-fold. First, it
  25.524 +allows the application program obtaining current values of control
  25.525 +parameters used by internal GLPK routines, which compute and update the
  25.526 +basis factorization.
  25.527 +
  25.528 +The second purpose of this routine is to provide proper values for all
  25.529 +fields of the structure \verb|glp_bfcp| in the case when the application
  25.530 +program needs to change some control parameters.
  25.531 +
  25.532 +\subsection{glp\_set\_bfcp---change basis factorization control
  25.533 +parameters}
  25.534 +
  25.535 +\subsubsection*{Synopsis}
  25.536 +
  25.537 +\begin{verbatim}
  25.538 +void glp_set_bfcp(glp_prob *lp, const glp_bfcp *parm);
  25.539 +\end{verbatim}
  25.540 +
  25.541 +\subsubsection*{Description}
  25.542 +
  25.543 +The routine \verb|glp_set_bfcp| changes control parameters, which are
  25.544 +used by internal GLPK routines on computing and updating the basis
  25.545 +factorization associated with the specified problem object.
  25.546 +
  25.547 +New values of the control parameters should be passed in a structure
  25.548 +\verb|glp_bfcp|, which the parameter \verb|parm| points to. For a
  25.549 +detailed description of the structure \verb|glp_bfcp| see paragraph
  25.550 +``Control parameters'' below.
  25.551 +
  25.552 +The parameter \verb|parm| can be specified as \verb|NULL|, in which case
  25.553 +all control parameters are reset to their default values.
  25.554 +
  25.555 +\subsubsection*{Comments}
  25.556 +
  25.557 +Before changing some control parameters with the routine
  25.558 +\verb|glp_set_bfcp| the application program should retrieve current
  25.559 +values of all control parameters with the routine \verb|glp_get_bfcp|.
  25.560 +This is needed for backward compatibility, because in the future there
  25.561 +may appear new members in the structure \verb|glp_bfcp|.
  25.562 +
  25.563 +Note that new values of control parameters come into effect on a next
  25.564 +computation of the basis factorization, not immediately.
  25.565 +
  25.566 +\subsubsection*{Example}
  25.567 +
  25.568 +\begin{verbatim}
  25.569 +glp_prob *lp;
  25.570 +glp_bfcp parm;
  25.571 +. . .
  25.572 +/* retrieve current values of control parameters */
  25.573 +glp_get_bfcp(lp, &parm);
  25.574 +/* change the threshold pivoting tolerance */
  25.575 +parm.piv_tol = 0.05;
  25.576 +/* set new values of control parameters */
  25.577 +glp_set_bfcp(lp, &parm);
  25.578 +. . .
  25.579 +\end{verbatim}
  25.580 +
  25.581 +\subsubsection*{Control parameters}
  25.582 +
  25.583 +This paragraph describes all basis factorization control parameters
  25.584 +currently used in the package. Symbolic names of control parameters are
  25.585 +names of corresponding members in the structure \verb|glp_bfcp|.
  25.586 +
  25.587 +\def\arraystretch{1}
  25.588 +
  25.589 +\medskip
  25.590 +
  25.591 +\noindent\begin{tabular}{@{}p{17pt}@{}p{120.5mm}@{}}
  25.592 +\multicolumn{2}{@{}l}{{\tt int type} (default: {\tt GLP\_BF\_FT})} \\
  25.593 +&Basis factorization type:\\
  25.594 +&\verb|GLP_BF_FT|---$LU$ + Forrest--Tomlin update;\\
  25.595 +&\verb|GLP_BF_BG|---$LU$ + Schur complement + Bartels--Golub update;\\
  25.596 +&\verb|GLP_BF_GR|---$LU$ + Schur complement + Givens rotation update.
  25.597 +\\
  25.598 +&In case of \verb|GLP_BF_FT| the update is applied to matrix $U$, while
  25.599 +in cases of \verb|GLP_BF_BG| and \verb|GLP_BF_GR| the update is applied
  25.600 +to the Schur complement.
  25.601 +\end{tabular}
  25.602 +
  25.603 +\medskip
  25.604 +
  25.605 +\noindent\begin{tabular}{@{}p{17pt}@{}p{120.5mm}@{}}
  25.606 +\multicolumn{2}{@{}l}{{\tt int lu\_size} (default: {\tt 0})} \\
  25.607 +&The initial size of the Sparse Vector Area, in non-zeros, used on
  25.608 +computing $LU$-factorization of the basis matrix for the first time.
  25.609 +If this parameter is set to 0, the initial SVA size is determined
  25.610 +automatically.\\
  25.611 +\end{tabular}
  25.612 +
  25.613 +\medskip
  25.614 +
  25.615 +\noindent\begin{tabular}{@{}p{17pt}@{}p{120.5mm}@{}}
  25.616 +\multicolumn{2}{@{}l}{{\tt double piv\_tol} (default: {\tt 0.10})} \\
  25.617 +&Threshold pivoting (Markowitz) tolerance, 0 $<$ \verb|piv_tol| $<$ 1,
  25.618 +used on computing $LU$-factorization of the basis matrix. Element
  25.619 +$u_{ij}$ of the active submatrix of factor $U$ fits to be pivot if it
  25.620 +satisfies to the stability criterion
  25.621 +$|u_{ij}| >= {\tt piv\_tol}\cdot\max|u_{i*}|$, i.e. if it is not very
  25.622 +small in the magnitude among other elements in the same row. Decreasing
  25.623 +this parameter may lead to better sparsity at the expense of numerical
  25.624 +accuracy, and vice versa.\\
  25.625 +\end{tabular}
  25.626 +
  25.627 +\medskip
  25.628 +
  25.629 +\noindent\begin{tabular}{@{}p{17pt}@{}p{120.5mm}@{}}
  25.630 +\multicolumn{2}{@{}l}{{\tt int piv\_lim} (default: {\tt 4})} \\
  25.631 +&This parameter is used on computing $LU$-factorization of the basis
  25.632 +matrix and specifies how many pivot candidates needs to be considered
  25.633 +on choosing a pivot element, \verb|piv_lim| $\geq$ 1. If \verb|piv_lim|
  25.634 +candidates have been considered, the pivoting routine prematurely
  25.635 +terminates the search with the best candidate found.\\
  25.636 +\end{tabular}
  25.637 +
  25.638 +\medskip
  25.639 +
  25.640 +\noindent\begin{tabular}{@{}p{17pt}@{}p{120.5mm}@{}}
  25.641 +\multicolumn{2}{@{}l}{{\tt int suhl} (default: {\tt GLP\_ON})} \\
  25.642 +&This parameter is used on computing $LU$-factorization of the basis
  25.643 +matrix. Being set to {\tt GLP\_ON} it enables applying the following
  25.644 +heuristic proposed by Uwe Suhl: if a column of the active submatrix has
  25.645 +no eligible pivot candidates, it is no more considered until it becomes
  25.646 +a column singleton. In many cases this allows reducing the time needed
  25.647 +for pivot searching. To disable this heuristic the parameter \verb|suhl|
  25.648 +should be set to {\tt GLP\_OFF}.\\
  25.649 +\end{tabular}
  25.650 +
  25.651 +\medskip
  25.652 +
  25.653 +\noindent\begin{tabular}{@{}p{17pt}@{}p{120.5mm}@{}}
  25.654 +\multicolumn{2}{@{}l}{{\tt double eps\_tol} (default: {\tt 1e-15})} \\
  25.655 +&Epsilon tolerance, \verb|eps_tol| $\geq$ 0, used on computing
  25.656 +$LU$-factorization of the basis matrix. If an element of the active
  25.657 +submatrix of factor $U$ is less than \verb|eps_tol| in the magnitude,
  25.658 +it is replaced by exact zero.\\
  25.659 +\end{tabular}
  25.660 +
  25.661 +\medskip
  25.662 +
  25.663 +\noindent\begin{tabular}{@{}p{17pt}@{}p{120.5mm}@{}}
  25.664 +\multicolumn{2}{@{}l}{{\tt double max\_gro} (default: {\tt 1e+10})} \\
  25.665 +&Maximal growth of elements of factor $U$, \verb|max_gro| $\geq$ 1,
  25.666 +allowable on computing $LU$-factorization of the basis matrix. If on
  25.667 +some elimination step the ratio $u_{big}/b_{max}$ (where $u_{big}$ is
  25.668 +the largest magnitude of elements of factor $U$ appeared in its active
  25.669 +submatrix during all the factorization process, $b_{max}$ is the largest
  25.670 +magnitude of elements of the basis matrix to be factorized), the basis
  25.671 +matrix is considered as ill-conditioned.\\
  25.672 +\end{tabular}
  25.673 +
  25.674 +\medskip
  25.675 +
  25.676 +\noindent\begin{tabular}{@{}p{17pt}@{}p{120.5mm}@{}}
  25.677 +\multicolumn{2}{@{}l}{{\tt int nfs\_max} (default: {\tt 100})} \\
  25.678 +&Maximal number of additional row-like factors (entries of the eta
  25.679 +file), \verb|nfs_max| $\geq$ 1, which can be added to $LU$-factorization
  25.680 +of the basis matrix on updating it with the Forrest--Tomlin technique.
  25.681 +This parameter is used only once, before $LU$-factorization is computed
  25.682 +for the first time, to allocate working arrays. As a rule, each update
  25.683 +adds one new factor (however, some updates may need no addition), so
  25.684 +this parameter limits the number of updates between refactorizations.\\
  25.685 +\end{tabular}
  25.686 +
  25.687 +\medskip
  25.688 +
  25.689 +\noindent\begin{tabular}{@{}p{17pt}@{}p{120.5mm}@{}}
  25.690 +\multicolumn{2}{@{}l}{{\tt double upd\_tol} (default: {\tt 1e-6})} \\
  25.691 +&Update tolerance, 0 $<$ \verb|upd_tol| $<$ 1, used on updating
  25.692 +$LU$-factorization of the basis matrix with the Forrest--Tomlin
  25.693 +technique. If after updating the magnitude of some diagonal element
  25.694 +$u_{kk}$ of factor $U$ becomes less than
  25.695 +${\tt upd\_tol}\cdot\max(|u_{k*}|, |u_{*k}|)$, the factorization is
  25.696 +considered as inaccurate.\\
  25.697 +\end{tabular}
  25.698 +
  25.699 +\medskip
  25.700 +
  25.701 +\noindent\begin{tabular}{@{}p{17pt}@{}p{120.5mm}@{}}
  25.702 +\multicolumn{2}{@{}l}{{\tt int nrs\_max} (default: {\tt 100})} \\
  25.703 +&Maximal number of additional rows and columns, \verb|nrs_max| $\geq$ 1,
  25.704 +which can be added to $LU$-factorization of the basis matrix on updating
  25.705 +it with the Schur complement technique. This parameter is used only
  25.706 +once, before $LU$-factorization is computed for the first time, to
  25.707 +allocate working arrays. As a rule, each update adds one new row and
  25.708 +column (however, some updates may need no addition), so this parameter
  25.709 +limits the number of updates between refactorizations.\\
  25.710 +\end{tabular}
  25.711 +
  25.712 +\medskip
  25.713 +
  25.714 +\noindent\begin{tabular}{@{}p{17pt}@{}p{120.5mm}@{}}
  25.715 +\multicolumn{2}{@{}l}{{\tt int rs\_size} (default: {\tt 0})} \\
  25.716 +&The initial size of the Sparse Vector Area, in non-zeros, used to
  25.717 +store non-zero elements of additional rows and columns introduced on
  25.718 +updating $LU$-factorization of the basis matrix with the Schur
  25.719 +complement technique. If this parameter is set to 0, the initial SVA
  25.720 +size is determined automatically.\\
  25.721 +\end{tabular}
  25.722 +
  25.723 +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  25.724 +
  25.725 +\newpage
  25.726 +
  25.727 +\subsection{glp\_get\_bhead---retrieve the basis header information}
  25.728 +
  25.729 +\subsubsection*{Synopsis}
  25.730 +
  25.731 +\begin{verbatim}
  25.732 +int glp_get_bhead(glp_prob *lp, int k);
  25.733 +\end{verbatim}
  25.734 +
  25.735 +\subsubsection*{Description}
  25.736 +
  25.737 +The routine \verb|glp_get_bhead| returns the basis header information
  25.738 +for the current basis associated with the specified problem object.
  25.739 +
  25.740 +\subsubsection*{Returns}
  25.741 +
  25.742 +If basic variable $(x_B)_k$, $1\leq k\leq m$, is $i$-th auxiliary
  25.743 +variable ($1\leq i\leq m$), the routine returns $i$. Otherwise, if
  25.744 +$(x_B)_k$ is $j$-th structural variable ($1\leq j\leq n$), the routine
  25.745 +returns $m+j$. Here $m$ is the number of rows and $n$ is the number of
  25.746 +columns in the problem object.
  25.747 +
  25.748 +\subsubsection*{Comments}
  25.749 +
  25.750 +Sometimes the application program may need to know which original
  25.751 +(auxiliary and structural) variable correspond to a given basic
  25.752 +variable, or, that is the same, which column of the augmented constraint
  25.753 +matrix $(I\ |-\!A)$ correspond to a given column of the basis matrix
  25.754 +$B$.
  25.755 +
  25.756 +\def\arraystretch{1}
  25.757 +
  25.758 +The correspondence is defined as follows:\footnote{For more details see
  25.759 +Subsection \ref{basbgd}, page \pageref{basbgd}.}
  25.760 +$$\left(\begin{array}{@{}c@{}}x_B\\x_N\\\end{array}\right)=
  25.761 +\Pi\left(\begin{array}{@{}c@{}}x_R\\x_S\\\end{array}\right)
  25.762 +\ \ \Leftrightarrow
  25.763 +\ \ \left(\begin{array}{@{}c@{}}x_R\\x_S\\\end{array}\right)=
  25.764 +\Pi^T\left(\begin{array}{@{}c@{}}x_B\\x_N\\\end{array}\right),$$
  25.765 +where $x_B$ is the vector of basic variables, $x_N$ is the vector of
  25.766 +non-basic variables, $x_R$ is the vector of auxiliary variables
  25.767 +following in their original order,\footnote{The original order of
  25.768 +auxiliary and structural variables is defined by the ordinal numbers
  25.769 +of corresponding rows and columns in the problem object.} $x_S$ is the
  25.770 +vector of structural variables following in their original order, $\Pi$
  25.771 +is a permutation matrix (which is a component of the basis
  25.772 +factorization).
  25.773 +
  25.774 +Thus, if $(x_B)_k=(x_R)_i$ is $i$-th auxiliary variable, the routine
  25.775 +returns $i$, and if $(x_B)_k=(x_S)_j$ is $j$-th structural variable,
  25.776 +the routine returns $m+j$, where $m$ is the number of rows in the
  25.777 +problem object.
  25.778 +
  25.779 +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  25.780 +
  25.781 +\newpage
  25.782 +
  25.783 +\subsection{glp\_get\_row\_bind---retrieve row index in the basis\\
  25.784 +header}
  25.785 +
  25.786 +\subsubsection*{Synopsis}
  25.787 +
  25.788 +\begin{verbatim}
  25.789 +int glp_get_row_bind(glp_prob *lp, int i);
  25.790 +\end{verbatim}
  25.791 +
  25.792 +\subsubsection*{Returns}
  25.793 +
  25.794 +The routine \verb|glp_get_row_bind| returns the index $k$ of basic
  25.795 +variable $(x_B)_k$, $1\leq k\leq m$, which is $i$-th auxiliary variable
  25.796 +(that is, the auxiliary variable corresponding to $i$-th row),
  25.797 +$1\leq i\leq m$, in the current basis associated with the specified
  25.798 +problem object, where $m$ is the number of rows. However, if $i$-th
  25.799 +auxiliary variable is non-basic, the routine returns zero.
  25.800 +
  25.801 +\subsubsection*{Comments}
  25.802 +
  25.803 +The routine \verb|glp_get_row_bind| is an inverse to the routine
  25.804 +\verb|glp_get_bhead|: if \verb|glp_get_bhead|$(lp,k)$ returns $i$,
  25.805 +\verb|glp_get_row_bind|$(lp,i)$ returns $k$, and vice versa.
  25.806 +
  25.807 +\subsection{glp\_get\_col\_bind---retrieve column index in the basis
  25.808 +header}
  25.809 +
  25.810 +\subsubsection*{Synopsis}
  25.811 +
  25.812 +\begin{verbatim}
  25.813 +int glp_get_col_bind(glp_prob *lp, int j);
  25.814 +\end{verbatim}
  25.815 +
  25.816 +\subsubsection*{Returns}
  25.817 +
  25.818 +The routine \verb|glp_get_col_bind| returns the index $k$ of basic
  25.819 +variable $(x_B)_k$, $1\leq k\leq m$, which is $j$-th structural
  25.820 +variable (that is, the structural variable corresponding to $j$-th
  25.821 +column), $1\leq j\leq n$, in the current basis associated with the
  25.822 +specified problem object, where $m$ is the number of rows, $n$ is the
  25.823 +number of columns. However, if $j$-th structural variable is non-basic,
  25.824 +the routine returns zero.
  25.825 +
  25.826 +\subsubsection*{Comments}
  25.827 +
  25.828 +The routine \verb|glp_get_col_bind| is an inverse to the routine
  25.829 +\verb|glp_get_bhead|: if \verb|glp_get_bhead|$(lp,k)$ returns $m+j$,
  25.830 +\verb|glp_get_col_bind|$(lp,j)$ returns $k$, and vice versa.
  25.831 +
  25.832 +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  25.833 +
  25.834 +\newpage
  25.835 +
  25.836 +\subsection{glp\_ftran---perform forward transformation}
  25.837 +
  25.838 +\subsubsection*{Synopsis}
  25.839 +
  25.840 +\begin{verbatim}
  25.841 +void glp_ftran(glp_prob *lp, double x[]);
  25.842 +\end{verbatim}
  25.843 +
  25.844 +\subsubsection*{Description}
  25.845 +
  25.846 +The routine \verb|glp_ftran| performs forward transformation (FTRAN),
  25.847 +i.e. it solves the system $Bx=b$, where $B$ is the basis matrix
  25.848 +associated with the specified problem object, $x$ is the vector of
  25.849 +unknowns to be computed, $b$ is the vector of right-hand sides.
  25.850 +
  25.851 +On entry to the routine elements of the vector $b$ should be stored in
  25.852 +locations \verb|x[1]|, \dots, \verb|x[m]|, where $m$ is the number of
  25.853 +rows. On exit the routine stores elements of the vector $x$ in the same
  25.854 +locations.
  25.855 +
  25.856 +\subsection{glp\_btran---perform backward transformation}
  25.857 +
  25.858 +\subsubsection*{Synopsis}
  25.859 +
  25.860 +\begin{verbatim}
  25.861 +void glp_btran(glp_prob *lp, double x[]);
  25.862 +\end{verbatim}
  25.863 +
  25.864 +\subsubsection*{Description}
  25.865 +
  25.866 +The routine \verb|glp_btran| performs backward transformation (BTRAN),
  25.867 +i.e. it solves the system $B^Tx=b$, where $B^T$ is a matrix transposed
  25.868 +to the basis matrix $B$ associated with the specified problem object,
  25.869 +$x$ is the vector of unknowns to be computed, $b$ is the vector of
  25.870 +right-hand sides.
  25.871 +
  25.872 +On entry to the routine elements of the vector $b$ should be stored in
  25.873 +locations \verb|x[1]|, \dots, \verb|x[m]|, where $m$ is the number of
  25.874 +rows. On exit the routine stores elements of the vector $x$ in the same
  25.875 +locations.
  25.876 +
  25.877 +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  25.878 +
  25.879 +\newpage
  25.880 +
  25.881 +\subsection{glp\_warm\_up---``warm up'' LP basis}
  25.882 +
  25.883 +\subsubsection*{Synopsis}
  25.884 +
  25.885 +\begin{verbatim}
  25.886 +int glp_warm_up(glp_prob *P);
  25.887 +\end{verbatim}
  25.888 +
  25.889 +\subsubsection*{Description}
  25.890 +
  25.891 +The routine \verb|glp_warm_up| ``warms up'' the LP basis for the
  25.892 +specified problem object using current statuses assigned to rows and
  25.893 +columns (that is, to auxiliary and structural variables).
  25.894 +
  25.895 +This operation includes computing factorization of the basis matrix
  25.896 +(if it does not exist), computing primal and dual components of basic
  25.897 +solution, and determining the solution status.
  25.898 +
  25.899 +\subsubsection*{Returns}
  25.900 +
  25.901 +\begin{tabular}{@{}p{25mm}p{97.3mm}@{}}
  25.902 +0 & The operation has been successfully performed.\\
  25.903 +\verb|GLP_EBADB| & The basis matrix is invalid, because the number of
  25.904 +basic (auxiliary and structural) variables is not the same as the number
  25.905 +of rows in the problem object.\\
  25.906 +\verb|GLP_ESING| & The basis matrix is singular within the working
  25.907 +precision.\\
  25.908 +\verb|GLP_ECOND| & The basis matrix is ill-conditioned, i.e. its
  25.909 +condition number is too large.\\
  25.910 +\end{tabular}
  25.911 +
  25.912 +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  25.913 +
  25.914 +\newpage
  25.915 +
  25.916 +\section{Simplex tableau routines}
  25.917 +
  25.918 +\subsection{glp\_eval\_tab\_row---compute row of the tableau}
  25.919 +
  25.920 +\subsubsection*{Synopsis}
  25.921 +
  25.922 +\begin{verbatim}
  25.923 +int glp_eval_tab_row(glp_prob *lp, int k, int ind[],
  25.924 +      double val[]);
  25.925 +\end{verbatim}
  25.926 +
  25.927 +\subsubsection*{Description}
  25.928 +
  25.929 +The routine \verb|glp_eval_tab_row| computes a row of the current
  25.930 +simplex tableau (see Subsection 3.1.1, formula (3.12)), which (row)
  25.931 +corresponds to some basic variable specified by the parameter $k$ as
  25.932 +follows: if $1\leq k\leq m$, the basic variable is $k$-th auxiliary
  25.933 +variable, and if $m+1\leq k\leq m+n$, the basic variable is $(k-m)$-th
  25.934 +structural variable, where $m$ is the number of rows and $n$ is the
  25.935 +number of columns in the specified problem object. The basis
  25.936 +factorization must exist.
  25.937 +
  25.938 +The computed row shows how the specified basic variable depends on
  25.939 +non-basic variables:
  25.940 +$$x_k=(x_B)_i=\xi_{i1}(x_N)_1+\xi_{i2}(x_N)_2+\dots+\xi_{in}(x_N)_n,$$
  25.941 +where $\xi_{i1}$, $\xi_{i2}$, \dots, $\xi_{in}$ are elements of the
  25.942 +simplex table row, $(x_N)_1$, $(x_N)_2$, \dots, $(x_N)_n$ are non-basic
  25.943 +(auxiliary and structural) variables.
  25.944 +
  25.945 +The routine stores column indices and corresponding numeric values of
  25.946 +non-zero elements of the computed row in unordered sparse format in
  25.947 +locations \verb|ind[1]|, \dots, \verb|ind[len]| and \verb|val[1]|,
  25.948 +\dots, \verb|val[len]|, respectively, where $0\leq{\tt len}\leq n$ is
  25.949 +the number of non-zero elements in the row returned on exit.
  25.950 +
  25.951 +Element indices stored in the array \verb|ind| have the same sense as
  25.952 +index $k$, i.e. indices 1 to $m$ denote auxiliary variables while
  25.953 +indices $m+1$ to $m+n$ denote structural variables (all these variables
  25.954 +are obviously non-basic by definition).
  25.955 +
  25.956 +\subsubsection*{Returns}
  25.957 +
  25.958 +The routine \verb|glp_eval_tab_row| returns \verb|len|, which is the
  25.959 +number of non-zero elements in the simplex table row stored in the
  25.960 +arrays \verb|ind| and \verb|val|.
  25.961 +
  25.962 +\subsubsection*{Comments}
  25.963 +
  25.964 +A row of the simplex table is computed as follows. At first, the
  25.965 +routine checks that the specified variable $x_k$ is basic and uses the
  25.966 +permutation matrix $\Pi$ (3.7) to determine index $i$ of basic variable
  25.967 +$(x_B)_i$, which corresponds to $x_k$.
  25.968 +
  25.969 +The row to be computed is $i$-th row of the matrix $\Xi$ (3.12),
  25.970 +therefore:
  25.971 +$$\xi_i=e_i^T\Xi=-e_i^TB^{-1}N=-(B^{-T}e_i)^TN,$$
  25.972 +where $e_i$ is $i$-th unity vector. So the routine performs BTRAN to
  25.973 +obtain $i$-th row of the inverse $B^{-1}$:
  25.974 +$$\varrho_i=B^{-T}e_i,$$
  25.975 +and then computes elements of the simplex table row as inner products:
  25.976 +$$\xi_{ij}=-\varrho_i^TN_j,\ \ j=1,2,\dots,n,$$
  25.977 +where $N_j$ is $j$-th column of matrix $N$ (3.9), which (column)
  25.978 +corresponds to non-basic variable $(x_N)_j$. The permutation matrix
  25.979 +$\Pi$ is used again to convert indices $j$ of non-basic columns to
  25.980 +original ordinal numbers of auxiliary and structural variables.
  25.981 +
  25.982 +\subsection{glp\_eval\_tab\_col---compute column of the tableau}
  25.983 +
  25.984 +\subsubsection*{Synopsis}
  25.985 +
  25.986 +\begin{verbatim}
  25.987 +int glp_eval_tab_col(glp_prob *lp, int k, int ind[],
  25.988 +      double val[]);
  25.989 +\end{verbatim}
  25.990 +
  25.991 +\subsubsection*{Description}
  25.992 +
  25.993 +The routine \verb|glp_eval_tab_col| computes a column of the current
  25.994 +simplex tableau (see Subsection 3.1.1, formula (3.12)), which (column)
  25.995 +corresponds to some non-basic variable specified by the parameter $k$:
  25.996 +if $1\leq k\leq m$, the non-basic variable is $k$-th auxiliary variable,
  25.997 +and if $m+1\leq k\leq m+n$, the non-basic variable is $(k-m)$-th
  25.998 +structural variable, where $m$ is the number of rows and $n$ is the
  25.999 +number of columns in the specified problem object. The basis
 25.1000 +factorization must exist.
 25.1001 +
 25.1002 +The computed column shows how basic variables depends on the specified
 25.1003 +non-basic variable $x_k=(x_N)_j$:
 25.1004 +$$
 25.1005 +\begin{array}{r@{\ }c@{\ }l@{\ }l}
 25.1006 +(x_B)_1&=&\dots+\xi_{1j}(x_N)_j&+\dots\\
 25.1007 +(x_B)_2&=&\dots+\xi_{2j}(x_N)_j&+\dots\\
 25.1008 +.\ \ .&.&.\ \ .\ \ .\ \ .\ \ .\ \ .\ \ .\\
 25.1009 +(x_B)_m&=&\dots+\xi_{mj}(x_N)_j&+\dots\\
 25.1010 +\end{array}
 25.1011 +$$
 25.1012 +where $\xi_{1j}$, $\xi_{2j}$, \dots, $\xi_{mj}$ are elements of the
 25.1013 +simplex table column, $(x_B)_1$, $(x_B)_2$, \dots, $(x_B)_m$ are basic
 25.1014 +(auxiliary and structural) variables.
 25.1015 +
 25.1016 +The routine stores row indices and corresponding numeric values of
 25.1017 +non-zero elements of the computed column in unordered sparse format in
 25.1018 +locations \verb|ind[1]|, \dots, \verb|ind[len]| and \verb|val[1]|,
 25.1019 +\dots, \verb|val[len]|, respectively, where $0\leq{\tt len}\leq m$ is
 25.1020 +the number of non-zero elements in the column returned on exit.
 25.1021 +
 25.1022 +Element indices stored in the array \verb|ind| have the same sense as
 25.1023 +index $k$, i.e. indices 1 to $m$ denote auxiliary variables while
 25.1024 +indices $m+1$ to $m+n$ denote structural variables (all these variables
 25.1025 +are obviously basic by definition).
 25.1026 +
 25.1027 +\subsubsection*{Returns}
 25.1028 +
 25.1029 +The routine \verb|glp_eval_tab_col| returns \verb|len|, which is the
 25.1030 +number of non-zero elements in the simplex table column stored in the
 25.1031 +arrays \verb|ind| and \verb|val|.
 25.1032 +
 25.1033 +\subsubsection*{Comments}
 25.1034 +
 25.1035 +A column of the simplex table is computed as follows. At first, the
 25.1036 +routine checks that the specified variable $x_k$ is non-basic and uses
 25.1037 +the permutation matrix $\Pi$ (3.7) to determine index $j$ of non-basic
 25.1038 +variable $(x_N)_j$, which corresponds to $x_k$.
 25.1039 +
 25.1040 +The column to be computed is $j$-th column of the matrix $\Xi$ (3.12),
 25.1041 +therefore:
 25.1042 +$$\Xi_j=\Xi e_j=-B^{-1}Ne_j=-B^{-1}N_j,$$
 25.1043 +where $e_j$ is $j$-th unity vector, $N_j$ is $j$-th column of matrix
 25.1044 +$N$ (3.9). So the routine performs FTRAN to transform $N_j$ to the
 25.1045 +simplex table column $\Xi_j=(\xi_{ij})$ and uses the permutation matrix
 25.1046 +$\Pi$ to convert row indices $i$ to original ordinal numbers of
 25.1047 +auxiliary and structural variables.
 25.1048 +
 25.1049 +\newpage
 25.1050 +
 25.1051 +\subsection{glp\_transform\_row---transform explicitly specified\\
 25.1052 +row}
 25.1053 +
 25.1054 +\subsubsection*{Synopsis}
 25.1055 +
 25.1056 +\begin{verbatim}
 25.1057 +int glp_transform_row(glp_prob *P, int len, int ind[],
 25.1058 +      double val[]);
 25.1059 +\end{verbatim}
 25.1060 +
 25.1061 +\subsubsection*{Description}
 25.1062 +
 25.1063 +The routine \verb|glp_transform_row| performs the same operation as the
 25.1064 +routine \verb|glp_eval_tab_row| with exception that the row to be
 25.1065 +transformed is specified explicitly as a sparse vector.
 25.1066 +
 25.1067 +The explicitly specified row may be thought as a linear form:
 25.1068 +$$x=a_1x_{m+1}+a_2x_{m+2}+\dots+a_nx_{m+n},$$
 25.1069 +where $x$ is an auxiliary variable for this row, $a_j$ are coefficients
 25.1070 +of the linear form, $x_{m+j}$ are structural variables.
 25.1071 +
 25.1072 +On entry column indices and numerical values of non-zero coefficients
 25.1073 +$a_j$ of the specified row should be placed in locations \verb|ind[1]|,
 25.1074 +\dots, \verb|ind[len]| and \verb|val[1]|, \dots, \verb|val[len]|, where
 25.1075 +\verb|len| is number of non-zero coefficients.
 25.1076 +
 25.1077 +This routine uses the system of equality constraints and the current
 25.1078 +basis in order to express the auxiliary variable $x$ through the current
 25.1079 +non-basic variables (as if the transformed row were added to the problem
 25.1080 +object and the auxiliary variable $x$ were basic), i.e. the resultant
 25.1081 +row has the form:
 25.1082 +$$x=\xi_1(x_N)_1+\xi_2(x_N)_2+\dots+\xi_n(x_N)_n,$$
 25.1083 +where $\xi_j$ are influence coefficients, $(x_N)_j$ are non-basic
 25.1084 +(auxiliary and structural) variables, $n$ is the number of columns in
 25.1085 +the problem object.
 25.1086 +
 25.1087 +On exit the routine stores indices and numerical values of non-zero
 25.1088 +coefficients $\xi_j$ of the resultant row in locations \verb|ind[1]|,
 25.1089 +\dots, \verb|ind[len']| and \verb|val[1]|, \dots, \verb|val[len']|,
 25.1090 +where $0\leq{\tt len'}\leq n$ is the number of non-zero coefficients in
 25.1091 +the resultant row returned by the routine. Note that indices of
 25.1092 +non-basic variables stored in the array \verb|ind| correspond to
 25.1093 +original ordinal numbers of variables: indices 1 to $m$ mean auxiliary
 25.1094 +variables and indices $m+1$ to $m+n$ mean structural ones.
 25.1095 +
 25.1096 +\subsubsection*{Returns}
 25.1097 +
 25.1098 +The routine \verb|glp_transform_row| returns \verb|len'|, the number of
 25.1099 +non-zero coefficients in the resultant row stored in the arrays
 25.1100 +\verb|ind| and \verb|val|.
 25.1101 +
 25.1102 +\subsection{glp\_transform\_col---transform explicitly specified\\
 25.1103 +column}
 25.1104 +
 25.1105 +\subsubsection*{Synopsis}
 25.1106 +
 25.1107 +\begin{verbatim}
 25.1108 +int glp_transform_col(glp_prob *P, int len, int ind[],
 25.1109 +      double val[]);
 25.1110 +\end{verbatim}
 25.1111 +
 25.1112 +\subsubsection*{Description}
 25.1113 +
 25.1114 +The routine \verb|glp_transform_col| performs the same operation as the
 25.1115 +routine \verb|glp_eval_tab_col| with exception that the column to be
 25.1116 +transformed is specified explicitly as a sparse vector.
 25.1117 +
 25.1118 +The explicitly specified column may be thought as it were added to
 25.1119 +the original system of equality constraints:
 25.1120 +$$
 25.1121 +\begin{array}{l@{\ }c@{\ }r@{\ }c@{\ }r@{\ }c@{\ }r}
 25.1122 +x_1&=&a_{11}x_{m+1}&+\dots+&a_{1n}x_{m+n}&+&a_1x \\
 25.1123 +x_2&=&a_{21}x_{m+1}&+\dots+&a_{2n}x_{m+n}&+&a_2x \\
 25.1124 +\multicolumn{7}{c}
 25.1125 +{.\ \ .\ \ .\ \ .\ \ .\ \ .\ \ .\ \ .\ \ .\ \ .\ \ .\ \ .\ \ .\ \ .}\\
 25.1126 +x_m&=&a_{m1}x_{m+1}&+\dots+&a_{mn}x_{m+n}&+&a_mx \\
 25.1127 +\end{array}
 25.1128 +$$
 25.1129 +where $x_i$ are auxiliary variables, $x_{m+j}$ are structural variables
 25.1130 +(presented in the problem object), $x$ is a structural variable for the
 25.1131 +explicitly specified column, $a_i$ are constraint coefficients at $x$.
 25.1132 +
 25.1133 +On entry row indices and numerical values of non-zero coefficients
 25.1134 +$a_i$ of the specified column should be placed in locations
 25.1135 +\verb|ind[1]|, \dots, \verb|ind[len]| and \verb|val[1]|, \dots,
 25.1136 +\verb|val[len]|, where \verb|len| is number of non-zero coefficients.
 25.1137 +
 25.1138 +This routine uses the system of equality constraints and the current
 25.1139 +basis in order to express the current basic variables through the
 25.1140 +structural variable $x$ (as if the transformed column were added to the
 25.1141 +problem object and the variable $x$ were non-basic):
 25.1142 +$$
 25.1143 +\begin{array}{l@{\ }c@{\ }r}
 25.1144 +(x_B)_1&=\dots+&\xi_{1}x\\
 25.1145 +(x_B)_2&=\dots+&\xi_{2}x\\
 25.1146 +\multicolumn{3}{c}{.\ \ .\ \ .\ \ .\ \ .\ \ .}\\
 25.1147 +(x_B)_m&=\dots+&\xi_{m}x\\
 25.1148 +\end{array}
 25.1149 +$$
 25.1150 +where $\xi_i$ are influence coefficients, $x_B$ are basic (auxiliary
 25.1151 +and structural) variables, $m$ is the number of rows in the problem
 25.1152 +object.
 25.1153 +
 25.1154 +On exit the routine stores indices and numerical values of non-zero
 25.1155 +coefficients $\xi_i$ of the resultant column in locations \verb|ind[1]|,
 25.1156 +\dots, \verb|ind[len']| and \verb|val[1]|, \dots, \verb|val[len']|,
 25.1157 +where $0\leq{\tt len'}\leq m$ is the number of non-zero coefficients in
 25.1158 +the resultant column returned by the routine. Note that indices of basic
 25.1159 +variables stored in the array \verb|ind| correspond to original ordinal
 25.1160 +numbers of variables, i.e. indices 1 to $m$ mean auxiliary variables,
 25.1161 +indices $m+1$ to $m+n$ mean structural ones.
 25.1162 +
 25.1163 +\subsubsection*{Returns}
 25.1164 +
 25.1165 +The routine \verb|glp_transform_col| returns \verb|len'|, the number of
 25.1166 +non-zero coefficients in the resultant column stored in the arrays
 25.1167 +\verb|ind| and \verb|val|.
 25.1168 +
 25.1169 +\subsection{glp\_prim\_rtest---perform primal ratio test}
 25.1170 +
 25.1171 +\subsubsection*{Synopsis}
 25.1172 +
 25.1173 +\begin{verbatim}
 25.1174 +int glp_prim_rtest(glp_prob *P, int len, const int ind[],
 25.1175 +      const double val[], int dir, double eps);
 25.1176 +\end{verbatim}
 25.1177 +
 25.1178 +\subsubsection*{Description}
 25.1179 +
 25.1180 +The routine \verb|glp_prim_rtest| performs the primal ratio test using
 25.1181 +an explicitly specified column of the simplex table.
 25.1182 +
 25.1183 +The current basic solution associated with the LP problem object must be
 25.1184 +primal feasible.
 25.1185 +
 25.1186 +The explicitly specified column of the simplex table shows how the basic
 25.1187 +variables $x_B$ depend on some non-basic variable $x$ (which is not
 25.1188 +necessarily presented in the problem object):
 25.1189 +$$
 25.1190 +\begin{array}{l@{\ }c@{\ }r}
 25.1191 +(x_B)_1&=\dots+&\xi_{1}x\\
 25.1192 +(x_B)_2&=\dots+&\xi_{2}x\\
 25.1193 +\multicolumn{3}{c}{.\ \ .\ \ .\ \ .\ \ .\ \ .}\\
 25.1194 +(x_B)_m&=\dots+&\xi_{m}x\\
 25.1195 +\end{array}
 25.1196 +$$
 25.1197 +
 25.1198 +The column is specifed on entry to the routine in sparse format. Ordinal
 25.1199 +numbers of basic variables $(x_B)_i$ should be placed in locations
 25.1200 +\verb|ind[1]|, \dots, \verb|ind[len]|, where ordinal number 1 to $m$
 25.1201 +denote auxiliary variables, and ordinal numbers $m+1$ to $m+n$ denote
 25.1202 +structural variables. The corresponding non-zero coefficients $\xi_i$
 25.1203 +should be placed in locations \verb|val[1]|, \dots, \verb|val[len]|. The
 25.1204 +arrays \verb|ind| and \verb|val| are not changed by the routine.
 25.1205 +
 25.1206 +The parameter \verb|dir| specifies direction in which the variable $x$
 25.1207 +changes on entering the basis: $+1$ means increasing, $-1$ means
 25.1208 +decreasing.
 25.1209 +
 25.1210 +The parameter \verb|eps| is an absolute tolerance (small positive
 25.1211 +number, say, $10^{-9}$) used by the routine to skip $\xi_i$'s whose
 25.1212 +magnitude is less than \verb|eps|.
 25.1213 +
 25.1214 +The routine determines which basic variable (among those specified in
 25.1215 +\verb|ind[1]|, \dots, \verb|ind[len]|) reaches its (lower or upper)
 25.1216 +bound first before any other basic variables do, and which, therefore,
 25.1217 +should leave the basis in order to keep primal feasibility.
 25.1218 +
 25.1219 +\subsubsection*{Returns}
 25.1220 +
 25.1221 +The routine \verb|glp_prim_rtest| returns the index, \verb|piv|, in the
 25.1222 +arrays \verb|ind| and \verb|val| corresponding to the pivot element
 25.1223 +chosen, $1\leq$ \verb|piv| $\leq$ \verb|len|. If the adjacent basic
 25.1224 +solution is primal unbounded, and therefore the choice cannot be made,
 25.1225 +the routine returns zero.
 25.1226 +
 25.1227 +\subsubsection*{Comments}
 25.1228 +
 25.1229 +If the non-basic variable $x$ is presented in the LP problem object, the
 25.1230 +input column can be computed with the routine \verb|glp_eval_tab_col|;
 25.1231 +otherwise, it can be computed with the routine \verb|glp_transform_col|.
 25.1232 +
 25.1233 +\subsection{glp\_dual\_rtest---perform dual ratio test}
 25.1234 +
 25.1235 +\subsubsection*{Synopsis}
 25.1236 +
 25.1237 +\begin{verbatim}
 25.1238 +int glp_dual_rtest(glp_prob *P, int len, const int ind[],
 25.1239 +      const double val[], int dir, double eps);
 25.1240 +\end{verbatim}
 25.1241 +
 25.1242 +\subsubsection*{Description}
 25.1243 +
 25.1244 +The routine \verb|glp_dual_rtest| performs the dual ratio test using
 25.1245 +an explicitly specified row of the simplex table.
 25.1246 +
 25.1247 +The current basic solution associated with the LP problem object must be
 25.1248 +dual feasible.
 25.1249 +
 25.1250 +The explicitly specified row of the simplex table is a linear form
 25.1251 +that shows how some basic variable $x$ (which is not necessarily
 25.1252 +presented in the problem object) depends on non-basic variables $x_N$:
 25.1253 +$$x=\xi_1(x_N)_1+\xi_2(x_N)_2+\dots+\xi_n(x_N)_n.$$
 25.1254 +
 25.1255 +The row is specified on entry to the routine in sparse format. Ordinal
 25.1256 +numbers of non-basic variables $(x_N)_j$ should be placed in locations
 25.1257 +\verb|ind[1]|, \dots, \verb|ind[len]|, where ordinal numbers 1 to $m$
 25.1258 +denote auxiliary variables, and ordinal numbers $m+1$ to $m+n$ denote
 25.1259 +structural variables. The corresponding non-zero coefficients $\xi_j$
 25.1260 +should be placed in locations \verb|val[1]|, \dots, \verb|val[len]|.
 25.1261 +The arrays \verb|ind| and \verb|val| are not changed by the routine.
 25.1262 +
 25.1263 +The parameter \verb|dir| specifies direction in which the variable $x$
 25.1264 +changes on leaving the basis: $+1$ means that $x$ goes on its lower
 25.1265 +bound, so its reduced cost (dual variable) is increasing (minimization)
 25.1266 +or decreasing (maximization); $-1$ means that $x$ goes on its upper
 25.1267 +bound, so its reduced cost is decreasing (minimization) or increasing
 25.1268 +(maximization).
 25.1269 +
 25.1270 +The parameter \verb|eps| is an absolute tolerance (small positive
 25.1271 +number, say, $10^{-9}$) used by the routine to skip $\xi_j$'s whose
 25.1272 +magnitude is less than \verb|eps|.
 25.1273 +
 25.1274 +The routine determines which non-basic variable (among those specified
 25.1275 +in \verb|ind[1]|, \dots, \verb|ind[len]|) should enter the basis in
 25.1276 +order to keep dual feasibility, because its reduced cost reaches the
 25.1277 +(zero) bound first before this occurs for any other non-basic variables.
 25.1278 +
 25.1279 +\subsubsection*{Returns}
 25.1280 +
 25.1281 +The routine \verb|glp_dual_rtest| returns the index, \verb|piv|, in the
 25.1282 +arrays \verb|ind| and \verb|val| corresponding to the pivot element
 25.1283 +chosen, $1\leq$ \verb|piv| $\leq$ \verb|len|. If the adjacent basic
 25.1284 +solution is dual unbounded, and therefore the choice cannot be made,
 25.1285 +the routine returns zero.
 25.1286 +
 25.1287 +\subsubsection*{Comments}
 25.1288 +
 25.1289 +If the basic variable $x$ is presented in the LP problem object, the
 25.1290 +input row can be computed with the routine \verb|glp_eval_tab_row|;
 25.1291 +otherwise, it can be computed with the routine \verb|glp_transform_row|.
 25.1292 +
 25.1293 +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 25.1294 +
 25.1295 +\newpage
 25.1296 +
 25.1297 +\section{Post-optimal analysis routines}
 25.1298 +
 25.1299 +\subsection{glp\_analyze\_bound---analyze active bound of non-basic
 25.1300 +variable}
 25.1301 +
 25.1302 +\subsubsection*{Synopsis}
 25.1303 +
 25.1304 +\begin{verbatim}
 25.1305 +void glp_analyze_bound(glp_prob *P, int k, double *limit1,
 25.1306 +      int *var1, double *limit2, int *var2);
 25.1307 +\end{verbatim}
 25.1308 +
 25.1309 +\subsubsection*{Description}
 25.1310 +
 25.1311 +The routine \verb|glp_analyze_bound| analyzes the effect of varying the
 25.1312 +active bound of specified non-basic variable.
 25.1313 +
 25.1314 +The non-basic variable is specified by the parameter $k$, where
 25.1315 +$1\leq k\leq m$ means auxiliary variable of corresponding row, and
 25.1316 +$m+1\leq k\leq m+n$ means structural variable (column).
 25.1317 +
 25.1318 +Note that the current basic solution must be optimal, and the basis
 25.1319 +factorization must exist.
 25.1320 +
 25.1321 +Results of the analysis have the following meaning.
 25.1322 +
 25.1323 +\verb|value1| is the minimal value of the active bound, at which the
 25.1324 +basis still remains primal feasible and thus optimal. \verb|-DBL_MAX|
 25.1325 +means that the active bound has no lower limit.
 25.1326 +
 25.1327 +\verb|var1| is the ordinal number of an auxiliary (1 to $m$) or
 25.1328 +structural ($m+1$ to $m+n$) basic variable, which reaches its bound
 25.1329 +first and thereby limits further decreasing the active bound being
 25.1330 +analyzed. if \verb|value1| = \verb|-DBL_MAX|, \verb|var1| is set to 0.
 25.1331 +
 25.1332 +\verb|value2| is the maximal value of the active bound, at which the
 25.1333 +basis still remains primal feasible and thus optimal. \verb|+DBL_MAX|
 25.1334 +means that the active bound has no upper limit.
 25.1335 +
 25.1336 +\verb|var2| is the ordinal number of an auxiliary (1 to $m$) or
 25.1337 +structural ($m+1$ to $m+n$) basic variable, which reaches its bound
 25.1338 +first and thereby limits further increasing the active bound being
 25.1339 +analyzed. if \verb|value2| = \verb|+DBL_MAX|, \verb|var2| is set to 0.
 25.1340 +
 25.1341 +The parameters \verb|value1|, \verb|var1|, \verb|value2|, \verb|var2|
 25.1342 +can be specified as \verb|NULL|, in which case corresponding information
 25.1343 +is not stored.
 25.1344 +
 25.1345 +\newpage
 25.1346 +
 25.1347 +\subsection{glp\_analyze\_coef---analyze objective coefficient at basic
 25.1348 +variable}
 25.1349 +
 25.1350 +\subsubsection*{Synopsis}
 25.1351 +
 25.1352 +\begin{verbatim}
 25.1353 +void glp_analyze_coef(glp_prob *P, int k, double *coef1,
 25.1354 +      int *var1, double *value1, double *coef2, int *var2,
 25.1355 +      double *value2);
 25.1356 +\end{verbatim}
 25.1357 +
 25.1358 +\subsubsection*{Description}
 25.1359 +
 25.1360 +The routine \verb|glp_analyze_coef| analyzes the effect of varying the
 25.1361 +objective coefficient at specified basic variable.
 25.1362 +
 25.1363 +The basic variable is specified by the parameter $k$, where
 25.1364 +$1\leq k\leq m$ means auxiliary variable of corresponding row, and
 25.1365 +$m+1\leq k\leq m+n$ means structural variable (column).
 25.1366 +
 25.1367 +Note that the current basic solution must be optimal, and the basis
 25.1368 +factorization must exist.
 25.1369 +
 25.1370 +Results of the analysis have the following meaning.
 25.1371 +
 25.1372 +\verb|coef1| is the minimal value of the objective coefficient, at
 25.1373 +which the basis still remains dual feasible and thus optimal.
 25.1374 +\verb|-DBL_MAX| means that the objective coefficient has no lower limit.
 25.1375 +
 25.1376 +\verb|var1| is the ordinal number of an auxiliary (1 to $m$) or
 25.1377 +structural ($m+1$ to $m+n$) non-basic variable, whose reduced cost
 25.1378 +reaches its zero bound first and thereby limits further decreasing the
 25.1379 +objective coefficient being analyzed. If \verb|coef1| = \verb|-DBL_MAX|,
 25.1380 +\verb|var1| is set to 0.
 25.1381 +
 25.1382 +\verb|value1| is value of the basic variable being analyzed in an
 25.1383 +adjacent basis, which is defined as follows. Let the objective
 25.1384 +coefficient reaches its minimal value (\verb|coef1|) and continues
 25.1385 +decreasing. Then the reduced cost of the limiting non-basic variable
 25.1386 +(\verb|var1|) becomes dual infeasible and the current basis becomes
 25.1387 +non-optimal that forces the limiting non-basic variable to enter the
 25.1388 +basis replacing there some basic variable that leaves the basis to keep
 25.1389 +primal feasibility. Should note that on determining the adjacent basis
 25.1390 +current bounds of the basic variable being analyzed are ignored as if
 25.1391 +it were free (unbounded) variable, so it cannot leave the basis. It may
 25.1392 +happen that no dual feasible adjacent basis exists, in which case
 25.1393 +\verb|value1| is set to \verb|-DBL_MAX| or \verb|+DBL_MAX|.
 25.1394 +
 25.1395 +\verb|coef2| is the maximal value of the objective coefficient, at
 25.1396 +which the basis still remains dual feasible and thus optimal.
 25.1397 +\verb|+DBL_MAX| means that the objective coefficient has no upper limit.
 25.1398 +
 25.1399 +\verb|var2| is the ordinal number of an auxiliary (1 to $m$) or
 25.1400 +structural ($m+1$ to $m+n$) non-basic variable, whose reduced cost
 25.1401 +reaches its zero bound first and thereby limits further increasing the
 25.1402 +objective coefficient being analyzed. If \verb|coef2| = \verb|+DBL_MAX|,
 25.1403 +\verb|var2| is set to 0.
 25.1404 +
 25.1405 +\verb|value2| is value of the basic variable being analyzed in an
 25.1406 +adjacent basis, which is defined exactly in the same way as
 25.1407 +\verb|value1| above with exception that now the objective coefficient
 25.1408 +is increasing.
 25.1409 +
 25.1410 +The parameters \verb|coef1|, \verb|var1|, \verb|value1|, \verb|coef2|,
 25.1411 +\verb|var2|, \verb|value2| can be specified as \verb|NULL|, in which
 25.1412 +case corresponding information is not stored.
 25.1413 +
 25.1414 +%* eof *%
    26.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    26.2 +++ b/deps/glpk/doc/glpk05.tex	Sun Nov 06 20:59:10 2011 +0100
    26.3 @@ -0,0 +1,1100 @@
    26.4 +%* glpk05.tex *%
    26.5 +
    26.6 +\chapter{Branch-and-Cut API Routines}
    26.7 +
    26.8 +\section{Introduction}
    26.9 +
   26.10 +\subsection{Using the callback routine}
   26.11 +
   26.12 +The GLPK MIP solver based on the branch-and-cut method allows the
   26.13 +application program to control the solution process. This is attained
   26.14 +by means of the user-defined callback routine, which is called by the
   26.15 +solver at various points of the branch-and-cut algorithm.
   26.16 +
   26.17 +The callback routine passed to the MIP solver should be written by the
   26.18 +user and has the following specification:\footnote{The name
   26.19 +{\tt foo\_bar} used here is a placeholder for the callback routine
   26.20 +name.}
   26.21 +
   26.22 +\begin{verbatim}
   26.23 +   void foo_bar(glp_tree *tree, void *info);
   26.24 +\end{verbatim}
   26.25 +
   26.26 +\noindent
   26.27 +where \verb|tree| is a pointer to the data structure \verb|glp_tree|,
   26.28 +which should be used on subsequent calls to branch-and-cut interface
   26.29 +routines, and \verb|info| is a transit pointer passed to the routine
   26.30 +\verb|glp_intopt|, which may be used by the application program to pass
   26.31 +some external data to the callback routine.
   26.32 +
   26.33 +The callback routine is passed to the MIP solver through the control
   26.34 +parameter structure \verb|glp_iocp| (see Chapter ``Basic API Routines'',
   26.35 +Section ``Mixed integer programming routines'', Subsection ``Solve MIP
   26.36 +problem with the branch-and-cut method'') as follows:
   26.37 +
   26.38 +\newpage
   26.39 +
   26.40 +\begin{verbatim}
   26.41 +   glp_prob *mip;
   26.42 +   glp_iocp parm;
   26.43 +   . . .
   26.44 +   glp_init_iocp(&parm);
   26.45 +   . . .
   26.46 +   parm.cb_func = foo_bar;
   26.47 +   parm.cb_info = ... ;
   26.48 +   ret = glp_intopt(mip, &parm);
   26.49 +   . . .
   26.50 +\end{verbatim}
   26.51 +
   26.52 +To determine why it is being called by the MIP solver the callback
   26.53 +routine should use the routine \verb|glp_ios_reason| (described in this
   26.54 +section below), which returns a code indicating the reason for calling.
   26.55 +Depending on the reason the callback routine may perform necessary
   26.56 +actions to control the solution process.
   26.57 +
   26.58 +The reason codes, which correspond to various point of the
   26.59 +branch-and-cut algorithm implemented in the MIP solver, are described
   26.60 +in Subsection ``Reasons for calling the callback routine'' below.
   26.61 +
   26.62 +To ignore calls for reasons, which are not processed by the callback
   26.63 +routine, it should just return to the MIP solver doing nothing. For
   26.64 +example:
   26.65 +
   26.66 +\begin{verbatim}
   26.67 +void foo_bar(glp_tree *tree, void *info)
   26.68 +{     . . .
   26.69 +      switch (glp_ios_reason(tree))
   26.70 +      {  case GLP_IBRANCH:
   26.71 +            . . .
   26.72 +            break;
   26.73 +         case GLP_ISELECT:
   26.74 +            . . .
   26.75 +            break;
   26.76 +         default:
   26.77 +            /* ignore call for other reasons */
   26.78 +            break;
   26.79 +      }
   26.80 +      return;
   26.81 +}
   26.82 +\end{verbatim}
   26.83 +
   26.84 +To control the solution process as well as to obtain necessary
   26.85 +information the callback routine may use the branch-and-cut API
   26.86 +routines described in this chapter. Names of all these routines begin
   26.87 +with `\verb|glp_ios_|'.
   26.88 +
   26.89 +\subsection{Branch-and-cut algorithm}
   26.90 +
   26.91 +This section gives a schematic description of the branch-and-cut
   26.92 +algorithm as it is implemented in the GLPK MIP solver.
   26.93 +
   26.94 +\medskip
   26.95 +
   26.96 +{\it 1. Initialization}
   26.97 +
   26.98 +Set $L:=\{P_0\}$, where $L$ is the {\it active list} (i.e. the list of
   26.99 +active subproblems), $P_0$ is the original MIP problem to be solved.
  26.100 +
  26.101 +Set $z^{\it best}:=+\infty$ (in case of minimization) or
  26.102 +$z^{\it best}:=-\infty$ (in case of maximization), where $z^{\it best}$
  26.103 +is {\it incumbent value}, i.e. an upper (minimization) or lower
  26.104 +(maximization) global bound for $z^{\it opt}$, the optimal objective
  26.105 +value for $P^0$.
  26.106 +
  26.107 +\medskip
  26.108 +
  26.109 +{\it 2. Subproblem selection}
  26.110 +
  26.111 +If $L=\varnothing$ then GO TO 9.
  26.112 +
  26.113 +Select $P\in L$, i.e. make active subproblem $P$ current.
  26.114 +
  26.115 +\medskip
  26.116 +
  26.117 +{\it 3. Solving LP relaxation}
  26.118 +
  26.119 +Solve $P^{\it LP}$, which is LP relaxation of $P$.
  26.120 +
  26.121 +If $P^{\it LP}$ has no primal feasible solution then GO TO 8.
  26.122 +
  26.123 +Let $z^{\it LP}$ be the optimal objective value for $P^{\it LP}$.
  26.124 +
  26.125 +If $z^{\it LP}\geq z^{\it best}$ (in case of minimization) or
  26.126 +$z^{\it LP}\leq z^{\rm best}$ (in case of maximization) then GO TO 8.
  26.127 +
  26.128 +\medskip
  26.129 +
  26.130 +{\it 4. Adding ``lazy'' constraints}
  26.131 +
  26.132 +Let $x^{\it LP}$ be the optimal solution to $P^{\it LP}$.
  26.133 +
  26.134 +If there are ``lazy'' constraints (i.e. essential constraints not
  26.135 +included in the original MIP problem $P_0$), which are violated at the
  26.136 +optimal point $x^{\it LP}$, add them to $P$, and GO TO 3.
  26.137 +
  26.138 +\medskip
  26.139 +
  26.140 +{\it 5. Check for integrality}
  26.141 +
  26.142 +Let $x_j$ be a variable, which is required to be integer, and let
  26.143 +$x^{\it LP}_j\in x^{\it LP}$ be its value in the optimal solution to
  26.144 +$P^{\it LP}$.
  26.145 +
  26.146 +If $x^{\it LP}_j$ are integral for all integer variables, then a better
  26.147 +integer feasible solution is found. Store its components, set
  26.148 +$z^{\it best}:=z^{\it LP}$, and GO TO 8.
  26.149 +
  26.150 +\medskip
  26.151 +
  26.152 +{\it 6. Adding cutting planes}
  26.153 +
  26.154 +If there are cutting planes (i.e. valid constraints for $P$),
  26.155 +which are violated at the optimal point $x^{\it LP}$, add them to $P$,
  26.156 +and GO TO 3.
  26.157 +
  26.158 +\medskip
  26.159 +
  26.160 +{\it 7. Branching}
  26.161 +
  26.162 +Select {\it branching variable} $x_j$, i.e. a variable, which is
  26.163 +required to be integer, and whose value $x^{\it LP}_j\in x^{\it LP}$ is
  26.164 +fractional in the optimal solution to $P^{\it LP}$.
  26.165 +
  26.166 +Create new subproblem $P^D$ (so called {\it down branch}), which is
  26.167 +identical to the current subproblem $P$ with exception that the upper
  26.168 +bound of $x_j$ is replaced by $\lfloor x^{\it LP}_j\rfloor$. (For
  26.169 +example, if $x^{\it LP}_j=3.14$, the new upper bound of $x_j$ in the
  26.170 +down branch will be $\lfloor 3.14\rfloor=3$.)
  26.171 +
  26.172 +Create new subproblem $P^U$ (so called {\it up branch}), which is
  26.173 +identical to the current subproblem $P$ with exception that the lower
  26.174 +bound of $x_j$ is replaced by $\lceil x^{\it LP}_j\rceil$. (For example,
  26.175 +if $x^{\it LP}_j=3.14$, the new lower bound of $x_j$ in the up branch
  26.176 +will be $\lceil 3.14\rceil=4$.)
  26.177 +
  26.178 +Set $L:=(L\backslash\{P\})\cup\{P^D,P^U\}$, i.e. remove the current
  26.179 +subproblem $P$ from the active list $L$ and add two new subproblems
  26.180 +$P^D$ and $P^U$ to it. Then GO TO 2.
  26.181 +
  26.182 +\medskip
  26.183 +
  26.184 +{\it 8. Pruning}
  26.185 +
  26.186 +Remove from the active list $L$ all subproblems (including the current
  26.187 +one), whose local bound $\widetilde{z}$ is not better than the global
  26.188 +bound $z^{\it best}$, i.e. set $L:=L\backslash\{P\}$ for all $P$, where
  26.189 +$\widetilde{z}\geq z^{\it best}$ (in case of minimization) or
  26.190 +$\widetilde{z}\leq z^{\it best}$ (in case of maximization), and then
  26.191 +GO TO 2.
  26.192 +
  26.193 +The local bound $\widetilde{z}$ for subproblem $P$ is an lower
  26.194 +(minimization) or upper (maximization) bound for integer optimal
  26.195 +solution to {\it this} subproblem (not to the original problem). This
  26.196 +bound is local in the sense that only subproblems in the subtree rooted
  26.197 +at node $P$ cannot have better integer feasible solutions. Note that
  26.198 +the local bound is not necessarily the optimal objective value to LP
  26.199 +relaxation $P^{\it LP}$.
  26.200 +
  26.201 +\medskip
  26.202 +
  26.203 +{\it 9. Termination}
  26.204 +
  26.205 +If $z^{\it best}=+\infty$ (in case of minimization) or
  26.206 +$z^{\it best}=-\infty$ (in case of maximization), the original problem
  26.207 +$P_0$ has no integer feasible solution. Otherwise, the last integer
  26.208 +feasible solution stored on step 5 is the integer optimal solution to
  26.209 +the original problem $P_0$ with $z^{\it opt}=z^{\it best}$. STOP.
  26.210 +
  26.211 +\subsection{The search tree}
  26.212 +
  26.213 +On the branching step of the branch-and-cut algorithm the current
  26.214 +subproblem is divided into two\footnote{In more general cases the
  26.215 +current subproblem may be divided into more than two subproblems.
  26.216 +However, currently such feature is not used in GLPK.} new subproblems,
  26.217 +so the set of all subproblems can be represented in the form of a rooted
  26.218 +tree, which is called the {\it search} or {\it branch-and-bound} tree.
  26.219 +An example of the search tree is shown on Fig.~1. Each node of the
  26.220 +search tree corresponds to a subproblem, so the terms `node' and
  26.221 +`subproblem' may be used synonymously.
  26.222 +
  26.223 +\newpage
  26.224 +
  26.225 +\begin{figure}[t]
  26.226 +\noindent\hfil
  26.227 +\xymatrix @R=20pt @C=10pt
  26.228 +{&&&&&&*+<14pt>[o][F=]{A}\ar@{-}[dllll]\ar@{-}[dr]\ar@{-}[drrrr]&&&&\\
  26.229 +&&*+<14pt>[o][F=]{B}\ar@{-}[dl]\ar@{-}[dr]&&&&&*+<14pt>[o][F=]{C}
  26.230 +\ar@{-}[dll]\ar@{-}[dr]\ar@{-}[drrr]&&&*+<14pt>[o][F-]{\times}\\
  26.231 +&*+<14pt>[o][F-]{\times}\ar@{-}[dl]\ar@{-}[d]\ar@{-}[dr]&&
  26.232 +*+<14pt>[o][F-]{D}&&*+<14pt>[o][F=]{E}\ar@{-}[dl]\ar@{-}[dr]&&&
  26.233 +*+<14pt>[o][F=]{F}\ar@{-}[dl]\ar@{-}[dr]&&*+<14pt>[o][F-]{G}\\
  26.234 +*+<14pt>[o][F-]{\times}&*+<14pt>[o][F-]{\times}&*+<14pt>[o][F-]{\times}
  26.235 +&&*+<14pt>[][F-]{H}&&*+<14pt>[o][F-]{I}&*+<14pt>[o][F-]{\times}&&
  26.236 +*+<14pt>[o][F-]{J}&\\}
  26.237 +
  26.238 +\bigskip
  26.239 +
  26.240 +\noindent\hspace{.8in}
  26.241 +\xymatrix @R=11pt
  26.242 +{*+<20pt>[][F-]{}&*\txt{\makebox[1in][l]{Current}}&&
  26.243 +*+<20pt>[o][F-]{}&*\txt{\makebox[1in][l]{Active}}\\
  26.244 +*+<20pt>[o][F=]{}&*\txt{\makebox[1in][l]{Non-active}}&&
  26.245 +*+<14pt>[o][F-]{\times}&*\txt{\makebox[1in][l]{Fathomed}}\\
  26.246 +}
  26.247 +
  26.248 +\begin{center}
  26.249 +Fig. 1. An example of the search tree.
  26.250 +\end{center}
  26.251 +\end{figure}
  26.252 +
  26.253 +In GLPK each node may have one of the following four statuses:
  26.254 +
  26.255 +$\bullet$ {\it current node} is the active node currently being
  26.256 +processed;
  26.257 +
  26.258 +$\bullet$ {\it active node} is a leaf node, which still has to be
  26.259 +processed;
  26.260 +
  26.261 +$\bullet$ {\it non-active node} is a node, which has been processed,
  26.262 +but not fathomed;
  26.263 +
  26.264 +$\bullet$ {\it fathomed node} is a node, which has been processed and
  26.265 +fathomed.
  26.266 +
  26.267 +In the data structure representing the search tree GLPK keeps only
  26.268 +current, active, and non-active nodes. Once a node has been fathomed,
  26.269 +it is removed from the tree data structure.
  26.270 +
  26.271 +Being created each node of the search tree is assigned a distinct
  26.272 +positive integer called the {\it subproblem reference number}, which
  26.273 +may be used by the application program to specify a particular node of
  26.274 +the tree. The root node corresponding to the original problem to be
  26.275 +solved is always assigned the reference number 1.
  26.276 +
  26.277 +\subsection{Current subproblem}
  26.278 +
  26.279 +The current subproblem is a MIP problem corresponding to the current
  26.280 +node of the search tree. It is represented as the GLPK problem object
  26.281 +(\verb|glp_prob|) that allows the application program using API routines
  26.282 +to access its content in the standard way. If the MIP presolver is not
  26.283 +used, it is the original problem object passed to the routine
  26.284 +\verb|glp_intopt|; otherwise, it is an internal problem object built by
  26.285 +the MIP presolver.
  26.286 +
  26.287 +Note that the problem object is used by the MIP solver itself during
  26.288 +the solution process for various purposes (to solve LP relaxations, to
  26.289 +perfom branching, etc.), and even if the MIP presolver is not used, the
  26.290 +current content of the problem object may differ from its original
  26.291 +content. For example, it may have additional rows, bounds of some rows
  26.292 +and columns may be changed, etc. In particular, LP segment of the
  26.293 +problem object corresponds to LP relaxation of the current subproblem.
  26.294 +However, on exit from the MIP solver the content of the problem object
  26.295 +is restored to its original state.
  26.296 +
  26.297 +To obtain information from the problem object the application program
  26.298 +may use any API routines, which do not change the object. Using API
  26.299 +routines, which change the problem object, is restricted to stipulated
  26.300 +cases.
  26.301 +
  26.302 +\subsection{The cut pool}
  26.303 +
  26.304 +The {\it cut pool} is a set of cutting plane constraints maintained by
  26.305 +the MIP solver. It is used by the GLPK cut generation routines and may
  26.306 +be used by the application program in the same way, i.e. rather than
  26.307 +to add cutting plane constraints directly to the problem object the
  26.308 +application program may store them to the cut pool. In the latter case
  26.309 +the solver looks through the cut pool, selects efficient constraints,
  26.310 +and adds them to the problem object.
  26.311 +
  26.312 +\subsection{Reasons for calling the callback routine}
  26.313 +
  26.314 +The callback routine may be called by the MIP solver for the following
  26.315 +reasons.
  26.316 +
  26.317 +\subsubsection*{Request for subproblem selection}
  26.318 +
  26.319 +The callback routine is called with the reason code \verb|GLP_ISELECT|
  26.320 +if the current subproblem has been fathomed and therefore there is no
  26.321 +current subproblem.
  26.322 +
  26.323 +In response the callback routine may select some subproblem from the
  26.324 +active list and pass its reference number to the solver using the
  26.325 +routine \verb|glp_ios_select_node|, in which case the solver continues
  26.326 +the search from the specified active subproblem. If no selection is made
  26.327 +by the callback routine, the solver uses a backtracking technique
  26.328 +specified by the control parameter \verb|bt_tech|.
  26.329 +
  26.330 +To explore the active list (i.e. active nodes of the branch-and-bound
  26.331 +tree) the callback routine may use the routines \verb|glp_ios_next_node|
  26.332 +and \verb|glp_ios_prev_node|.
  26.333 +
  26.334 +\subsubsection*{Request for preprocessing}
  26.335 +
  26.336 +The callback routine is called with the reason code \verb|GLP_IPREPRO|
  26.337 +if the current subproblem has just been selected from the active list
  26.338 +and its LP relaxation is not solved yet.
  26.339 +
  26.340 +In response the callback routine may perform some preprocessing of the
  26.341 +current subproblem like tightening bounds of some variables or removing
  26.342 +bounds of some redundant constraints.
  26.343 +
  26.344 +\subsubsection*{Request for row generation}
  26.345 +
  26.346 +The callback routine is called with the reason code \verb|GLP_IROWGEN|
  26.347 +if LP relaxation of the current subproblem has just been solved to
  26.348 +optimality and its objective value is better than the best known integer
  26.349 +feasible solution.
  26.350 +
  26.351 +In response the callback routine may add one or more ``lazy''
  26.352 +constraints (rows), which are violated by the current optimal solution
  26.353 +of LP relaxation, using API routines \verb|glp_add_rows|,
  26.354 +\verb|glp_set_row_name|, \verb|glp_set_row_bnds|, and
  26.355 +\verb|glp_set_mat_row|, in which case the solver will perform
  26.356 +re-optimization of LP relaxation. If there are no violated constraints,
  26.357 +the callback routine should just return.
  26.358 +
  26.359 +Optimal solution components for LP relaxation can be obtained with API
  26.360 +routines \verb|glp_get_obj_val|, \verb|glp_get_row_prim|,
  26.361 +\verb|glp_get_row_dual|, \verb|glp_get_col_prim|, and
  26.362 +\verb|glp_get_col_dual|.
  26.363 +
  26.364 +\subsubsection*{Request for heuristic solution}
  26.365 +
  26.366 +The callback routine is called with the reason code \verb|GLP_IHEUR|
  26.367 +if LP relaxation of the current subproblem being solved to optimality
  26.368 +is integer infeasible (i.e. values of some structural variables of
  26.369 +integer kind are fractional), though its objective value is better than
  26.370 +the best known integer feasible solution.
  26.371 +
  26.372 +In response the callback routine may try applying a primal heuristic
  26.373 +to find an integer feasible solution,\footnote{Integer feasible to the
  26.374 +original MIP problem, not to the current subproblem.} which is better
  26.375 +than the best known one. In case of success the callback routine may
  26.376 +store such better solution in the problem object using the routine
  26.377 +\verb|glp_ios_heur_sol|.
  26.378 +
  26.379 +\subsubsection*{Request for cut generation}
  26.380 +
  26.381 +The callback routine is called with the reason code \verb|GLP_ICUTGEN|
  26.382 +if LP relaxation of the current subproblem being solved to optimality
  26.383 +is integer infeasible (i.e. values of some structural variables of
  26.384 +integer kind are fractional), though its objective value is better than
  26.385 +the best known integer feasible solution.
  26.386 +
  26.387 +In response the callback routine may reformulate the {\it current}
  26.388 +subproblem (before it will be splitted up due to branching) by adding to
  26.389 +the problem object one or more {\it cutting plane constraints}, which
  26.390 +cut off the fractional optimal point from the MIP
  26.391 +polytope.\footnote{Since these constraints are added to the current
  26.392 +subproblem, they may be globally as well as locally valid.}
  26.393 +
  26.394 +Adding cutting plane constraints may be performed in two ways.
  26.395 +One way is the same as for the reason code \verb|GLP_IROWGEN| (see
  26.396 +above), in which case the callback routine adds new rows corresponding
  26.397 +to cutting plane constraints directly to the current subproblem.
  26.398 +
  26.399 +The other way is to add cutting plane constraints to the {\it cut pool},
  26.400 +a set of cutting plane constraints maintained by the solver, rather than
  26.401 +directly to the current subproblem. In this case after return from the
  26.402 +callback routine the solver looks through the cut pool, selects
  26.403 +efficient cutting plane constraints, adds them to the current
  26.404 +subproblem, drops other constraints, and then performs re-optimization.
  26.405 +
  26.406 +\subsubsection*{Request for branching}
  26.407 +
  26.408 +The callback routine is called with the reason code \verb|GLP_IBRANCH|
  26.409 +if LP relaxation of the current subproblem being solved to optimality
  26.410 +is integer infeasible (i.e. values of some structural variables of
  26.411 +integer kind are fractional), though its objective value is better than
  26.412 +the best known integer feasible solution.
  26.413 +
  26.414 +In response the callback routine may choose some variable suitable for
  26.415 +branching (i.e. integer variable, whose value in optimal solution to
  26.416 +LP relaxation of the current subproblem is fractional) and pass its
  26.417 +ordinal number to the solver using the routine
  26.418 +\verb|glp_ios_branch_upon|, in which case the solver splits the current
  26.419 +subproblem in two new subproblems and continues the search. If no choice
  26.420 +is made by the callback routine, the solver uses a branching technique
  26.421 +specified by the control parameter \verb|br_tech|.
  26.422 +
  26.423 +\subsubsection*{Better integer solution found}
  26.424 +
  26.425 +The callback routine is called with the reason code \verb|GLP_IBINGO|
  26.426 +if LP relaxation of the current subproblem being solved to optimality
  26.427 +is integer feasible (i.e. values of all structural variables of integer
  26.428 +kind are integral within the working precision) and its objective value
  26.429 +is better than the best known integer feasible solution.
  26.430 +
  26.431 +Optimal solution components for LP relaxation can be obtained in the
  26.432 +same way as for the reason code \verb|GLP_IROWGEN| (see above).
  26.433 +
  26.434 +Components of the new MIP solution can be obtained with API routines
  26.435 +\verb|glp_mip_obj_val|, \verb|glp_mip_row_val|, and
  26.436 +\verb|glp_mip_col_val|. Note, however, that due to row/cut generation
  26.437 +there may be additional rows in the problem object.
  26.438 +
  26.439 +The difference between optimal solution to LP relaxation and
  26.440 +corresponding MIP solution is that in the former case some structural
  26.441 +variables of integer kind (namely, basic variables) may have values,
  26.442 +which are close to nearest integers within the working precision, while
  26.443 +in the latter case all such variables have exact integral values.
  26.444 +
  26.445 +The reason \verb|GLP_IBINGO| is intended only for informational
  26.446 +purposes, so the callback routine should not modify the problem object
  26.447 +in this case.
  26.448 +
  26.449 +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  26.450 +
  26.451 +\newpage
  26.452 +
  26.453 +\section{Basic routines}
  26.454 +
  26.455 +\subsection{glp\_ios\_reason---determine reason for calling the
  26.456 +callback routine}
  26.457 +
  26.458 +\subsubsection*{Synopsis}
  26.459 +
  26.460 +\begin{verbatim}
  26.461 +int glp_ios_reason(glp_tree *tree);
  26.462 +\end{verbatim}
  26.463 +
  26.464 +\subsubsection*{Returns}
  26.465 +
  26.466 +The routine \verb|glp_ios_reason| returns a code, which indicates why
  26.467 +the user-defined callback routine is being called:
  26.468 +
  26.469 +\verb|GLP_ISELECT|---request for subproblem selection;
  26.470 +
  26.471 +\verb|GLP_IPREPRO|---request for preprocessing;
  26.472 +
  26.473 +\verb|GLP_IROWGEN|---request for row generation;
  26.474 +
  26.475 +\verb|GLP_IHEUR  |---request for heuristic solution;
  26.476 +
  26.477 +\verb|GLP_ICUTGEN|---request for cut generation;
  26.478 +
  26.479 +\verb|GLP_IBRANCH|---request for branching;
  26.480 +
  26.481 +\verb|GLP_IBINGO |---better integer solution found.
  26.482 +
  26.483 +\subsection{glp\_ios\_get\_prob---access the problem object}
  26.484 +
  26.485 +\subsubsection*{Synopsis}
  26.486 +
  26.487 +\begin{verbatim}
  26.488 +glp_prob *glp_ios_get_prob(glp_tree *tree);
  26.489 +\end{verbatim}
  26.490 +
  26.491 +\subsubsection*{Description}
  26.492 +
  26.493 +The routine \verb|glp_ios_get_prob| can be called from the user-defined
  26.494 +callback routine to access the problem object, which is used by the MIP
  26.495 +solver. It is the original problem object passed to the routine
  26.496 +\verb|glp_intopt| if the MIP presolver is not used; otherwise it is an
  26.497 +internal problem object built by the presolver.
  26.498 +
  26.499 +\subsubsection*{Returns}
  26.500 +
  26.501 +The routine \verb|glp_ios_get_prob| returns a pointer to the problem
  26.502 +object used by the MIP solver.
  26.503 +
  26.504 +\subsubsection*{Comments}
  26.505 +
  26.506 +To obtain various information about the problem instance the callback
  26.507 +routine can access the problem object (i.e. the object of type
  26.508 +\verb|glp_prob|) using the routine \verb|glp_ios_get_prob|. It is the
  26.509 +original problem object passed to the routine \verb|glp_intopt| if the
  26.510 +MIP presolver is not used; otherwise it is an internal problem object
  26.511 +built by the presolver.
  26.512 +
  26.513 +\subsection{glp\_ios\_row\_attr---determine additional row attributes}
  26.514 +
  26.515 +\subsubsection*{Synopsis}
  26.516 +
  26.517 +\begin{verbatim}
  26.518 +void glp_ios_row_attr(glp_tree *tree, int i, glp_attr *attr);
  26.519 +\end{verbatim}
  26.520 +
  26.521 +\subsubsection*{Description}
  26.522 +
  26.523 +The routine \verb|glp_ios_row_attr| retrieves additional attributes of
  26.524 +$i$-th row of the current subproblem and stores them in the structure
  26.525 +\verb|glp_attr|, which the parameter \verb|attr| points to.
  26.526 +
  26.527 +The structure \verb|glp_attr| has the following fields:
  26.528 +
  26.529 +\medskip
  26.530 +
  26.531 +\noindent\begin{tabular}{@{}p{17pt}@{}p{120.5mm}@{}}
  26.532 +\multicolumn{2}{@{}l}{{\tt int level}}\\
  26.533 +&Subproblem level at which the row was created. (If \verb|level| = 0,
  26.534 +the row was added either to the original problem object passed to the
  26.535 +routine \verb|glp_intopt| or to the root subproblem on generating
  26.536 +``lazy'' or/and cutting plane constraints.)\\
  26.537 +\end{tabular}
  26.538 +
  26.539 +\medskip
  26.540 +
  26.541 +\noindent\begin{tabular}{@{}p{17pt}@{}p{120.5mm}@{}}
  26.542 +\multicolumn{2}{@{}l}{{\tt int origin}}\\
  26.543 +&The row origin flag:\\
  26.544 +&\verb|GLP_RF_REG |---regular constraint;\\
  26.545 +&\verb|GLP_RF_LAZY|---``lazy'' constraint;\\
  26.546 +&\verb|GLP_RF_CUT |---cutting plane constraint.\\
  26.547 +\end{tabular}
  26.548 +
  26.549 +\medskip
  26.550 +
  26.551 +\noindent\begin{tabular}{@{}p{17pt}@{}p{120.5mm}@{}}
  26.552 +\multicolumn{2}{@{}l}{{\tt int klass}}\\
  26.553 +&The row class descriptor, which is a number passed to the routine
  26.554 +\verb|glp_ios_add_row| as its third parameter. If the row is a cutting
  26.555 +plane constraint generated by the solver, its class may be the
  26.556 +following:\\
  26.557 +&\verb|GLP_RF_GMI |---Gomory's mixed integer cut;\\
  26.558 +&\verb|GLP_RF_MIR |---mixed integer rounding cut;\\
  26.559 +&\verb|GLP_RF_COV |---mixed cover cut;\\
  26.560 +&\verb|GLP_RF_CLQ |---clique cut.\\
  26.561 +\end{tabular}
  26.562 +
  26.563 +\newpage
  26.564 +
  26.565 +\subsection{glp\_ios\_mip\_gap---compute relative MIP gap}
  26.566 +
  26.567 +\subsubsection*{Synopsis}
  26.568 +
  26.569 +\begin{verbatim}
  26.570 +double glp_ios_mip_gap(glp_tree *tree);
  26.571 +\end{verbatim}
  26.572 +
  26.573 +\subsubsection*{Description}
  26.574 +
  26.575 +The routine \verb|glp_ios_mip_gap| computes the relative MIP gap (also
  26.576 +called {\it duality gap}) with the following formula:
  26.577 +$${\tt gap} = \frac{|{\tt best\_mip} - {\tt best\_bnd}|}
  26.578 +{|{\tt best\_mip}| + {\tt DBL\_EPSILON}}$$
  26.579 +where \verb|best_mip| is the best integer feasible solution found so
  26.580 +far, \verb|best_bnd| is the best (global) bound. If no integer feasible
  26.581 +solution has been found yet, \verb|gap| is set to \verb|DBL_MAX|.
  26.582 +
  26.583 +\subsubsection*{Returns}
  26.584 +
  26.585 +The routine \verb|glp_ios_mip_gap| returns the relative MIP gap.
  26.586 +
  26.587 +\subsubsection*{Comments}
  26.588 +
  26.589 +The relative MIP gap is used to measure the quality of the best integer
  26.590 +feasible solution found so far, because the optimal solution value
  26.591 +$z^*$ for the original MIP problem always lies in the range
  26.592 +$${\tt best\_bnd}\leq z^*\leq{\tt best\_mip}$$
  26.593 +in case of minimization, or in the range
  26.594 +$${\tt best\_mip}\leq z^*\leq{\tt best\_bnd}$$
  26.595 +in case of maximization.
  26.596 +
  26.597 +To express the relative MIP gap in percents the value returned by the
  26.598 +routine \verb|glp_ios_mip_gap| should be multiplied by 100\%.
  26.599 +
  26.600 +\newpage
  26.601 +
  26.602 +\subsection{glp\_ios\_node\_data---access application-specific data}
  26.603 +
  26.604 +\subsubsection*{Synopsis}
  26.605 +
  26.606 +\begin{verbatim}
  26.607 +void *glp_ios_node_data(glp_tree *tree, int p);
  26.608 +\end{verbatim}
  26.609 +
  26.610 +\subsubsection*{Description}
  26.611 +
  26.612 +The routine \verb|glp_ios_node_data| allows the application accessing a
  26.613 +memory block allocated for the subproblem (which may be active or
  26.614 +inactive), whose reference number is $p$.
  26.615 +
  26.616 +The size of the block is defined by the control parameter \verb|cb_size|
  26.617 +passed to the routine \verb|glp_intopt|. The block is initialized by
  26.618 +binary zeros on creating corresponding subproblem, and its contents is
  26.619 +kept until the subproblem will be removed from the tree.
  26.620 +
  26.621 +The application may use these memory blocks to store specific data for
  26.622 +each subproblem.
  26.623 +
  26.624 +\subsubsection*{Returns}
  26.625 +
  26.626 +The routine \verb|glp_ios_node_data| returns a pointer to the memory
  26.627 +block for the specified subproblem. Note that if \verb|cb_size| = 0, the
  26.628 +routine returns a null pointer.
  26.629 +
  26.630 +\subsection{glp\_ios\_select\_node---select subproblem to continue the
  26.631 +search}
  26.632 +
  26.633 +\subsubsection*{Synopsis}
  26.634 +
  26.635 +\begin{verbatim}
  26.636 +void glp_ios_select_node(glp_tree *tree, int p);
  26.637 +\end{verbatim}
  26.638 +
  26.639 +\subsubsection*{Description}
  26.640 +
  26.641 +The routine \verb|glp_ios_select_node| can be called from the
  26.642 +user-defined callback routine in response to the reason
  26.643 +\verb|GLP_ISELECT| to select an active subproblem, whose reference
  26.644 +number is $p$. The search will be continued from the subproblem
  26.645 +selected.
  26.646 +
  26.647 +\newpage
  26.648 +
  26.649 +\subsection{glp\_ios\_heur\_sol---provide solution found by heuristic}
  26.650 +
  26.651 +\subsubsection*{Synopsis}
  26.652 +
  26.653 +\begin{verbatim}
  26.654 +int glp_ios_heur_sol(glp_tree *tree, const double x[]);
  26.655 +\end{verbatim}
  26.656 +
  26.657 +\subsubsection*{Description}
  26.658 +
  26.659 +The routine \verb|glp_ios_heur_sol| can be called from the user-defined
  26.660 +callback routine in response to the reason \verb|GLP_IHEUR| to provide
  26.661 +an integer feasible solution found by a primal heuristic.
  26.662 +
  26.663 +Primal values of {\it all} variables (columns) found by the heuristic
  26.664 +should be placed in locations $x[1]$, \dots, $x[n]$, where $n$ is the
  26.665 +number of columns in the original problem object. Note that the routine
  26.666 +\verb|glp_ios_heur_sol| does {\it not} check primal feasibility of the
  26.667 +solution provided.
  26.668 +
  26.669 +Using the solution passed in the array $x$ the routine computes value
  26.670 +of the objective function. If the objective value is better than the
  26.671 +best known integer feasible solution, the routine computes values of
  26.672 +auxiliary variables (rows) and stores all solution components in the
  26.673 +problem object.
  26.674 +
  26.675 +\subsubsection*{Returns}
  26.676 +
  26.677 +If the provided solution is accepted, the routine
  26.678 +\verb|glp_ios_heur_sol| returns zero. Otherwise, if the provided
  26.679 +solution is rejected, the routine returns non-zero.
  26.680 +
  26.681 +\subsection{glp\_ios\_can\_branch---check if can branch upon specified
  26.682 +variable}
  26.683 +
  26.684 +\subsubsection*{Synopsis}
  26.685 +
  26.686 +\begin{verbatim}
  26.687 +int glp_ios_can_branch(glp_tree *tree, int j);
  26.688 +\end{verbatim}
  26.689 +
  26.690 +\subsubsection*{Returns}
  26.691 +
  26.692 +If $j$-th variable (column) can be used to branch upon, the routine
  26.693 +returns non-zero, otherwise zero.
  26.694 +
  26.695 +\newpage
  26.696 +
  26.697 +\subsection{glp\_ios\_branch\_upon---choose variable to branch upon}
  26.698 +
  26.699 +\subsubsection*{Synopsis}
  26.700 +
  26.701 +\begin{verbatim}
  26.702 +void glp_ios_branch_upon(glp_tree *tree, int j, int sel);
  26.703 +\end{verbatim}
  26.704 +
  26.705 +\subsubsection*{Description}
  26.706 +
  26.707 +The routine \verb|glp_ios_branch_upon| can be called from the
  26.708 +user-defined callback routine in response to the reason
  26.709 +\verb|GLP_IBRANCH| to choose a branching variable, whose ordinal number
  26.710 +is $j$. Should note that only variables, for which the routine
  26.711 +\verb|glp_ios_can_branch| returns non-zero, can be used to branch upon.
  26.712 +
  26.713 +The parameter \verb|sel| is a flag that indicates which branch
  26.714 +(subproblem) should be selected next to continue the search:
  26.715 +
  26.716 +\verb|GLP_DN_BRNCH|---select down-branch;
  26.717 +
  26.718 +\verb|GLP_UP_BRNCH|---select up-branch;
  26.719 +
  26.720 +\verb|GLP_NO_BRNCH|---use general selection technique.
  26.721 +
  26.722 +\subsubsection*{Comments}
  26.723 +
  26.724 +On branching the solver removes the current active subproblem from the
  26.725 +active list and creates two new subproblems ({\it down-} and {\it
  26.726 +up-branches}), which are added to the end of the active list. Note that
  26.727 +the down-branch is created before the up-branch, so the last active
  26.728 +subproblem will be the up-branch.
  26.729 +
  26.730 +The down- and up-branches are identical to the current subproblem with
  26.731 +exception that in the down-branch the upper bound of $x_j$, the variable
  26.732 +chosen to branch upon, is replaced by $\lfloor x_j^*\rfloor$, while in
  26.733 +the up-branch the lower bound of $x_j$ is replaced by
  26.734 +$\lceil x_j^*\rceil$, where $x_j^*$ is the value of $x_j$ in optimal
  26.735 +solution to LP relaxation of the current subproblem. For example, if
  26.736 +$x_j^*=3.14$, the new upper bound of $x_j$ in the down-branch is
  26.737 +$\lfloor 3.14\rfloor=3$, and the new lower bound in the up-branch is
  26.738 +$\lceil 3.14\rceil=4$.)
  26.739 +
  26.740 +Additionally the callback routine may select either down- or up-branch,
  26.741 +from which the solver will continue the search. If none of the branches
  26.742 +is selected, a general selection technique will be used.
  26.743 +
  26.744 +\newpage
  26.745 +
  26.746 +\subsection{glp\_ios\_terminate---terminate the solution process}
  26.747 +
  26.748 +\subsubsection*{Synopsis}
  26.749 +
  26.750 +\begin{verbatim}
  26.751 +void glp_ios_terminate(glp_tree *tree);
  26.752 +\end{verbatim}
  26.753 +
  26.754 +\subsubsection*{Description}
  26.755 +
  26.756 +The routine \verb|glp_ios_terminate| sets a flag indicating that the
  26.757 +MIP solver should prematurely terminate the search.
  26.758 +
  26.759 +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  26.760 +
  26.761 +\newpage
  26.762 +
  26.763 +\section{The search tree exploring routines}
  26.764 +
  26.765 +\subsection{glp\_ios\_tree\_size---determine size of the search tree}
  26.766 +
  26.767 +\subsubsection*{Synopsis}
  26.768 +
  26.769 +\begin{verbatim}
  26.770 +void glp_ios_tree_size(glp_tree *tree, int *a_cnt, int *n_cnt,
  26.771 +      int *t_cnt);
  26.772 +\end{verbatim}
  26.773 +
  26.774 +\subsubsection*{Description}
  26.775 +
  26.776 +The routine \verb|glp_ios_tree_size| stores the following three counts
  26.777 +which characterize the current size of the search tree:
  26.778 +
  26.779 +\verb|a_cnt| is the current number of active nodes, i.e. the current
  26.780 +size of the active list;
  26.781 +
  26.782 +\verb|n_cnt| is the current number of all (active and inactive) nodes;
  26.783 +
  26.784 +\verb|t_cnt| is the total number of nodes including those which have
  26.785 +been already removed from the tree. This count is increased whenever
  26.786 +a new node appears in the tree and never decreased.
  26.787 +
  26.788 +If some of the parameters \verb|a_cnt|, \verb|n_cnt|, \verb|t_cnt| is
  26.789 +a null pointer, the corresponding count is not stored.
  26.790 +
  26.791 +\subsection{glp\_ios\_curr\_node---determine current active subprob-\\
  26.792 +lem}
  26.793 +
  26.794 +\subsubsection*{Synopsis}
  26.795 +
  26.796 +\begin{verbatim}
  26.797 +int glp_ios_curr_node(glp_tree *tree);
  26.798 +\end{verbatim}
  26.799 +
  26.800 +\subsubsection*{Returns}
  26.801 +
  26.802 +The routine \verb|glp_ios_curr_node| returns the reference number of the
  26.803 +current active subproblem. However, if the current subproblem does not
  26.804 +exist, the routine returns zero.
  26.805 +
  26.806 +\newpage
  26.807 +
  26.808 +\subsection{glp\_ios\_next\_node---determine next active subproblem}
  26.809 +
  26.810 +\subsubsection*{Synopsis}
  26.811 +
  26.812 +\begin{verbatim}
  26.813 +int glp_ios_next_node(glp_tree *tree, int p);
  26.814 +\end{verbatim}
  26.815 +
  26.816 +\subsubsection*{Returns}
  26.817 +
  26.818 +If the parameter $p$ is zero, the routine \verb|glp_ios_next_node|
  26.819 +returns the reference number of the first active subproblem. However,
  26.820 +if the tree is empty, zero is returned.
  26.821 +
  26.822 +If the parameter $p$ is not zero, it must specify the reference number
  26.823 +of some active subproblem, in which case the routine returns the
  26.824 +reference number of the next active subproblem. However, if there is
  26.825 +no next active subproblem in the list, zero is returned.
  26.826 +
  26.827 +All subproblems in the active list are ordered chronologically, i.e.
  26.828 +subproblem $A$ precedes subproblem $B$ if $A$ was created before $B$.
  26.829 +
  26.830 +\subsection{glp\_ios\_prev\_node---determine previous active subproblem}
  26.831 +
  26.832 +\subsubsection*{Synopsis}
  26.833 +
  26.834 +\begin{verbatim}
  26.835 +int glp_ios_prev_node(glp_tree *tree, int p);
  26.836 +\end{verbatim}
  26.837 +
  26.838 +\subsubsection*{Returns}
  26.839 +
  26.840 +If the parameter $p$ is zero, the routine \verb|glp_ios_prev_node|
  26.841 +returns the reference number of the last active subproblem. However, if
  26.842 +the tree is empty, zero is returned.
  26.843 +
  26.844 +If the parameter $p$ is not zero, it must specify the reference number
  26.845 +of some active subproblem, in which case the routine returns the
  26.846 +reference number of the previous active subproblem. However, if there
  26.847 +is no previous active subproblem in the list, zero is returned.
  26.848 +
  26.849 +All subproblems in the active list are ordered chronologically, i.e.
  26.850 +subproblem $A$ precedes subproblem $B$ if $A$ was created before $B$.
  26.851 +
  26.852 +\newpage
  26.853 +
  26.854 +\subsection{glp\_ios\_up\_node---determine parent subproblem}
  26.855 +
  26.856 +\subsubsection*{Synopsis}
  26.857 +
  26.858 +\begin{verbatim}
  26.859 +int glp_ios_up_node(glp_tree *tree, int p);
  26.860 +\end{verbatim}
  26.861 +
  26.862 +\subsubsection*{Returns}
  26.863 +
  26.864 +The parameter $p$ must specify the reference number of some (active or
  26.865 +inactive) subproblem, in which case the routine \verb|iet_get_up_node|
  26.866 +returns the reference number of its parent subproblem. However, if the
  26.867 +specified subproblem is the root of the tree and, therefore, has
  26.868 +no parent, the routine returns zero.
  26.869 +
  26.870 +\subsection{glp\_ios\_node\_level---determine subproblem level}
  26.871 +
  26.872 +\subsubsection*{Synopsis}
  26.873 +
  26.874 +\begin{verbatim}
  26.875 +int glp_ios_node_level(glp_tree *tree, int p);
  26.876 +\end{verbatim}
  26.877 +
  26.878 +\subsubsection*{Returns}
  26.879 +
  26.880 +The routine \verb|glp_ios_node_level| returns the level of the
  26.881 +subproblem,\linebreak whose reference number is $p$, in the
  26.882 +branch-and-bound tree. (The root subproblem has level 0, and the level
  26.883 +of any other subproblem is the level of its parent plus one.)
  26.884 +
  26.885 +\subsection{glp\_ios\_node\_bound---determine subproblem local\\bound}
  26.886 +
  26.887 +\subsubsection*{Synopsis}
  26.888 +
  26.889 +\begin{verbatim}
  26.890 +double glp_ios_node_bound(glp_tree *tree, int p);
  26.891 +\end{verbatim}
  26.892 +
  26.893 +\subsubsection*{Returns}
  26.894 +
  26.895 +The routine \verb|glp_ios_node_bound| returns the local bound for
  26.896 +(active or inactive) subproblem, whose reference number is $p$.
  26.897 +
  26.898 +\subsubsection*{Comments}
  26.899 +
  26.900 +The local bound for subproblem $p$ is an lower (minimization) or upper
  26.901 +(maximization) bound for integer optimal solution to {\it this}
  26.902 +subproblem (not to the original problem). This bound is local in the
  26.903 +sense that only subproblems in the subtree rooted at node $p$ cannot
  26.904 +have better integer feasible solutions.
  26.905 +
  26.906 +On creating a subproblem (due to the branching step) its local bound is
  26.907 +inherited from its parent and then may get only stronger (never weaker).
  26.908 +For the root subproblem its local bound is initially set to
  26.909 +\verb|-DBL_MAX| (minimization) or \verb|+DBL_MAX| (maximization) and
  26.910 +then improved as the root LP relaxation has been solved.
  26.911 +
  26.912 +Note that the local bound is not necessarily the optimal objective value
  26.913 +to corresponding LP relaxation.
  26.914 +
  26.915 +\subsection{glp\_ios\_best\_node---find active subproblem with best
  26.916 +local bound}
  26.917 +
  26.918 +\subsubsection*{Synopsis}
  26.919 +
  26.920 +\begin{verbatim}
  26.921 +int glp_ios_best_node(glp_tree *tree);
  26.922 +\end{verbatim}
  26.923 +
  26.924 +\subsubsection*{Returns}
  26.925 +
  26.926 +The routine \verb|glp_ios_best_node| returns the reference number of
  26.927 +the active subproblem, whose local bound is best (i.e. smallest in case
  26.928 +of minimization or largest in case of maximization). However, if the
  26.929 +tree is empty, the routine returns zero.
  26.930 +
  26.931 +\subsubsection*{Comments}
  26.932 +
  26.933 +The best local bound is an lower (minimization) or upper (maximization)
  26.934 +bound for integer optimal solution to the original MIP problem.
  26.935 +
  26.936 +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  26.937 +
  26.938 +\newpage
  26.939 +
  26.940 +\section{The cut pool routines}
  26.941 +
  26.942 +\subsection{glp\_ios\_pool\_size---determine current size of the cut\\
  26.943 +pool}
  26.944 +
  26.945 +\subsubsection*{Synopsis}
  26.946 +
  26.947 +\begin{verbatim}
  26.948 +int glp_ios_pool_size(glp_tree *tree);
  26.949 +\end{verbatim}
  26.950 +
  26.951 +\subsubsection*{Returns}
  26.952 +
  26.953 +The routine \verb|glp_ios_pool_size| returns the current size of the
  26.954 +cut pool, that is, the number of cutting plane constraints currently
  26.955 +added to it.
  26.956 +
  26.957 +\subsection{glp\_ios\_add\_row---add constraint to the cut pool}
  26.958 +
  26.959 +\subsubsection*{Synopsis}
  26.960 +
  26.961 +\begin{verbatim}
  26.962 +int glp_ios_add_row(glp_tree *tree, const char *name,
  26.963 +      int klass, int flags, int len, const int ind[],
  26.964 +      const double val[], int type, double rhs);
  26.965 +\end{verbatim}
  26.966 +
  26.967 +\subsubsection*{Description}
  26.968 +
  26.969 +The routine \verb|glp_ios_add_row| adds specified row (cutting plane
  26.970 +constraint) to the cut pool.
  26.971 +
  26.972 +The cutting plane constraint should have the following format:
  26.973 +$$\sum_{j\in J}a_jx_j\left\{\begin{array}{@{}c@{}}\geq\\\leq\\
  26.974 +\end{array}\right\}b,$$
  26.975 +where $J$ is a set of indices (ordinal numbers) of structural variables,
  26.976 +$a_j$ are constraint coefficients, $x_j$ are structural variables, $b$
  26.977 +is the right-hand side.
  26.978 +
  26.979 +The parameter \verb|name| specifies a symbolic name assigned to the
  26.980 +constraint (1 up to 255 characters). If it is \verb|NULL| or an empty
  26.981 +string, no name is assigned.
  26.982 +
  26.983 +The parameter \verb|klass| specifies the constraint class, which must
  26.984 +be either zero or a number in the range from 101 to 200. The application
  26.985 +may use this attribute to distinguish between cutting plane constraints
  26.986 +of different classes.\footnote{Constraint classes numbered from 1 to 100
  26.987 +are reserved for GLPK cutting plane generators.}
  26.988 +
  26.989 +The parameter \verb|flags| currently is not used and must be zero.
  26.990 +
  26.991 +Ordinal numbers of structural variables (i.e. column indices) $j\in J$
  26.992 +and numerical values of corresponding constraint coefficients $a_j$ must
  26.993 +be placed in locations \verb|ind[1]|, \dots, \verb|ind[len]| and
  26.994 +\verb|val[1]|, \dots, \verb|val[len]|, respectively, where
  26.995 +${\tt len}=|J|$ is the number of constraint coefficients,
  26.996 +$0\leq{\tt len}\leq n$, and $n$ is the number of columns in the problem
  26.997 +object. Coefficients with identical column indices are not allowed.
  26.998 +Zero coefficients are allowed, however, they are ignored.
  26.999 +
 26.1000 +The parameter \verb|type| specifies the constraint type as follows:
 26.1001 +
 26.1002 +\verb|GLP_LO| means inequality constraint $\Sigma a_jx_j\geq b$;
 26.1003 +
 26.1004 +\verb|GLP_UP| means inequality constraint $\Sigma a_jx_j\leq b$;
 26.1005 +
 26.1006 +The parameter \verb|rhs| specifies the right-hand side $b$.
 26.1007 +
 26.1008 +All cutting plane constraints in the cut pool are identified by their
 26.1009 +ordinal numbers 1, 2, \dots, $size$, where $size$ is the current size
 26.1010 +of the cut pool. New constraints are always added to the end of the cut
 26.1011 +pool, thus, ordinal numbers of previously added constraints are not
 26.1012 +changed.
 26.1013 +
 26.1014 +\subsubsection*{Returns}
 26.1015 +
 26.1016 +The routine \verb|glp_ios_add_row| returns the ordinal number of the
 26.1017 +cutting plane constraint added, which is the new size of the cut pool.
 26.1018 +
 26.1019 +\subsubsection*{Example}
 26.1020 +
 26.1021 +\begin{verbatim}
 26.1022 +/* generate triangle cutting plane:
 26.1023 +   x[i] + x[j] + x[k] <= 1 */
 26.1024 +. . .
 26.1025 +/* add the constraint to the cut pool */
 26.1026 +ind[1] = i, val[1] = 1.0;
 26.1027 +ind[2] = j, val[2] = 1.0;
 26.1028 +ind[3] = k, val[3] = 1.0;
 26.1029 +glp_ios_add_row(tree, NULL, TRIANGLE_CUT, 0, 3, ind, val,
 26.1030 +                GLP_UP, 1.0);
 26.1031 +\end{verbatim}
 26.1032 +
 26.1033 +\subsubsection*{Comments}
 26.1034 +
 26.1035 +Cutting plane constraints added to the cut pool are intended to be then
 26.1036 +added only to the {\it current} subproblem, so these constraints can be
 26.1037 +globally as well as locally valid. However, adding a constraint to the
 26.1038 +cut pool does not mean that it will be added to the current
 26.1039 +subproblem---it depends on the solver's decision: if the constraint
 26.1040 +seems to be efficient, it is moved from the pool to the current
 26.1041 +subproblem, otherwise it is simply dropped.\footnote{Globally valid
 26.1042 +constraints could be saved and then re-used for other subproblems, but
 26.1043 +currently such feature is not implemented.}
 26.1044 +
 26.1045 +Normally, every time the callback routine is called for cut generation,
 26.1046 +the cut pool is empty. On the other hand, the solver itself can generate
 26.1047 +cutting plane constraints (like Gomory's or mixed integer rounding
 26.1048 +cuts), in which case the cut pool may be non-empty.
 26.1049 +
 26.1050 +\subsection{glp\_ios\_del\_row---remove constraint from the cut pool}
 26.1051 +
 26.1052 +\subsubsection*{Synopsis}
 26.1053 +
 26.1054 +\begin{verbatim}
 26.1055 +void glp_ios_del_row(glp_tree *tree, int i);
 26.1056 +\end{verbatim}
 26.1057 +
 26.1058 +\subsubsection*{Description}
 26.1059 +
 26.1060 +The routine \verb|glp_ios_del_row| deletes $i$-th row (cutting plane
 26.1061 +constraint) from the cut pool, where $1\leq i\leq size$ is the ordinal
 26.1062 +number of the constraint in the pool, $size$ is the current size of the
 26.1063 +cut pool.
 26.1064 +
 26.1065 +Note that deleting a constraint from the cut pool leads to changing
 26.1066 +ordinal numbers of other constraints remaining in the pool. New ordinal
 26.1067 +numbers of the remaining constraints are assigned under assumption that
 26.1068 +the original order of constraints is not changed. Let, for example,
 26.1069 +there be four constraints $a$, $b$, $c$ and $d$ in the cut pool, which
 26.1070 +have ordinal numbers 1, 2, 3 and 4, respectively, and let constraint
 26.1071 +$b$ have been deleted. Then after deletion the remaining constraint $a$,
 26.1072 +$c$ and $d$ are assigned new ordinal numbers 1, 2 and 3, respectively.
 26.1073 +
 26.1074 +To find the constraint to be deleted the routine \verb|glp_ios_del_row|
 26.1075 +uses ``smart'' linear search, so it is recommended to remove constraints
 26.1076 +in a natural or reverse order and avoid removing them in a random order.
 26.1077 +
 26.1078 +\subsubsection*{Example}
 26.1079 +
 26.1080 +\begin{verbatim}
 26.1081 +/* keep first 10 constraints in the cut pool and remove other
 26.1082 +   constraints */
 26.1083 +while (glp_ios_pool_size(tree) > 10)
 26.1084 +   glp_ios_del_row(tree, glp_ios_pool_size(tree));
 26.1085 +\end{verbatim}
 26.1086 +
 26.1087 +\newpage
 26.1088 +
 26.1089 +\subsection{glp\_ios\_clear\_pool---remove all constraints from the cut
 26.1090 +pool}
 26.1091 +
 26.1092 +\subsubsection*{Synopsis}
 26.1093 +
 26.1094 +\begin{verbatim}
 26.1095 +void glp_ios_clear_pool(glp_tree *tree);
 26.1096 +\end{verbatim}
 26.1097 +
 26.1098 +\subsubsection*{Description}
 26.1099 +
 26.1100 +The routine \verb|glp_ios_clear_pool| makes the cut pool empty deleting
 26.1101 +all existing rows (cutting plane constraints) from it.
 26.1102 +
 26.1103 +%* eof *%
    27.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    27.2 +++ b/deps/glpk/doc/glpk06.tex	Sun Nov 06 20:59:10 2011 +0100
    27.3 @@ -0,0 +1,896 @@
    27.4 +%* glpk06.tex *%
    27.5 +
    27.6 +\chapter{Miscellaneous API Routines}
    27.7 +
    27.8 +\section{GLPK environment routines}
    27.9 +
   27.10 +\subsection{glp\_long---64-bit integer data type}
   27.11 +
   27.12 +Some GLPK API routines use 64-bit integer data type, which is declared
   27.13 +in the header \verb|glpk.h| as follows:
   27.14 +
   27.15 +\begin{verbatim}
   27.16 +typedef struct { int lo, hi; } glp_long;
   27.17 +\end{verbatim}
   27.18 +
   27.19 +\noindent
   27.20 +where \verb|lo| contains low 32 bits, and \verb|hi| contains high 32
   27.21 +bits of 64-bit integer value.\footnote{GLPK conforms to ILP32, LLP64,
   27.22 +and LP64 programming models, where the built-in type {\tt int}
   27.23 +corresponds to 32-bit integers.}
   27.24 +
   27.25 +\subsection{glp\_init\_env---initialize GLPK environment}
   27.26 +
   27.27 +\subsubsection*{Synopsis}
   27.28 +
   27.29 +\begin{verbatim}
   27.30 +int glp_init_env(void);
   27.31 +\end{verbatim}
   27.32 +
   27.33 +\subsubsection*{Description}
   27.34 +
   27.35 +The routine \verb|glp_init_env| initializes the GLPK environment.
   27.36 +Normally the application program does not need to call this routine,
   27.37 +because it is called automatically on the first call to any API routine.
   27.38 +
   27.39 +\newpage
   27.40 +
   27.41 +\subsubsection*{Returns}
   27.42 +
   27.43 +The routine \verb|glp_init_env| returns one of the following codes:
   27.44 +
   27.45 +\noindent
   27.46 +0 --- initialization successful;
   27.47 +
   27.48 +\noindent
   27.49 +1 --- environment is already initialized;
   27.50 +
   27.51 +\noindent
   27.52 +2 --- initialization failed (insufficient memory);
   27.53 +
   27.54 +\noindent
   27.55 +3 --- initialization failed (unsupported programming model).
   27.56 +
   27.57 +\subsection{glp\_version---determine library version}
   27.58 +
   27.59 +\subsubsection*{Synopsis}
   27.60 +
   27.61 +\begin{verbatim}
   27.62 +const char *glp_version(void);
   27.63 +\end{verbatim}
   27.64 +
   27.65 +\subsubsection*{Returns}
   27.66 +
   27.67 +The routine \verb|glp_version| returns a pointer to a null-terminated
   27.68 +character string, which specifies the version of the GLPK library in
   27.69 +the form \verb|"X.Y"|, where `\verb|X|' is the major version number, and
   27.70 +`\verb|Y|' is the minor version number, for example, \verb|"4.16"|.
   27.71 +
   27.72 +\subsubsection*{Example}
   27.73 +
   27.74 +\begin{footnotesize}
   27.75 +\begin{verbatim}
   27.76 +printf("GLPK version is %s\n", glp_version());
   27.77 +\end{verbatim}
   27.78 +\end{footnotesize}
   27.79 +
   27.80 +\subsection{glp\_free\_env---free GLPK environment}
   27.81 +
   27.82 +\subsubsection*{Synopsis}
   27.83 +
   27.84 +\begin{verbatim}
   27.85 +int glp_free_env(void);
   27.86 +\end{verbatim}
   27.87 +
   27.88 +\subsubsection*{Description}
   27.89 +
   27.90 +The routine \verb|glp_free_env| frees all resources used by GLPK
   27.91 +routines (memory blocks, etc.) which are currently still in use.
   27.92 +
   27.93 +Normally the application program does not need to call this routine,
   27.94 +because GLPK routines always free all unused resources. However, if
   27.95 +the application program even has deleted all problem objects, there
   27.96 +will be several memory blocks still allocated for the internal library
   27.97 +needs. For some reasons the application program may want GLPK to free
   27.98 +this memory, in which case it should call \verb|glp_free_env|.
   27.99 +
  27.100 +Note that a call to \verb|glp_free_env| invalidates all problem objects
  27.101 +which still exist.
  27.102 +
  27.103 +\subsubsection*{Returns}
  27.104 +
  27.105 +The routine \verb|glp_free_env| returns one of the following codes:
  27.106 +
  27.107 +\noindent
  27.108 +0 --- termination successful;
  27.109 +
  27.110 +\noindent
  27.111 +1 --- environment is inactive (was not initialized).
  27.112 +
  27.113 +\subsection{glp\_printf---write formatted output to terminal}
  27.114 +
  27.115 +\subsubsection*{Synopsis}
  27.116 +
  27.117 +\begin{verbatim}
  27.118 +void glp_printf(const char *fmt, ...);
  27.119 +\end{verbatim}
  27.120 +
  27.121 +\subsubsection*{Description}
  27.122 +
  27.123 +The routine \verb|glp_printf| uses the format control string
  27.124 +\verb|fmt| to format its parameters and writes the formatted output to
  27.125 +the terminal.
  27.126 +
  27.127 +This routine is a replacement of the standard C function
  27.128 +\verb|printf| and used by all GLPK routines to perform terminal
  27.129 +output. The application program may use \verb|glp_printf| for the same
  27.130 +purpose that allows controlling its terminal output with the routines
  27.131 +\verb|glp_term_out| and \verb|glp_term_hook|.
  27.132 +
  27.133 +\subsection{glp\_vprintf---write formatted output to terminal}
  27.134 +
  27.135 +\subsubsection*{Synopsis}
  27.136 +
  27.137 +\begin{verbatim}
  27.138 +void glp_vprintf(const char *fmt, va_list arg);
  27.139 +\end{verbatim}
  27.140 +
  27.141 +\subsubsection*{Description}
  27.142 +
  27.143 +The routine \verb|glp_vprintf| uses the format control string
  27.144 +\verb|fmt| to format its parameters specified by the list \verb|arg|
  27.145 +and writes the formatted output to the terminal.
  27.146 +
  27.147 +This routine is a replacement of the standard C function
  27.148 +\verb|vprintf| and used by all GLPK routines to perform terminal
  27.149 +output. The application program may use \verb|glp_vprintf| for the same
  27.150 +purpose that allows controlling its terminal output with the routines
  27.151 +\verb|glp_term_out| and \verb|glp_term_hook|.
  27.152 +
  27.153 +\newpage
  27.154 +
  27.155 +\subsection{glp\_term\_out---enable/disable terminal output}
  27.156 +
  27.157 +\subsubsection*{Synopsis}
  27.158 +
  27.159 +\begin{verbatim}
  27.160 +int glp_term_out(int flag);
  27.161 +\end{verbatim}
  27.162 +
  27.163 +\subsubsection*{Description}
  27.164 +
  27.165 +Depending on the parameter flag the routine \verb|glp_term_out| enables
  27.166 +or disables terminal output performed by glpk routines:
  27.167 +
  27.168 +\verb|GLP_ON | --- enable terminal output;
  27.169 +
  27.170 +\verb|GLP_OFF| --- disable terminal output.
  27.171 +
  27.172 +\subsubsection*{Returns}
  27.173 +
  27.174 +The routine \verb|glp_term_out| returns the previous value of the
  27.175 +terminal output flag (\verb|GLP_ON| or \verb|GLP_OFF|).
  27.176 +
  27.177 +\subsection{glp\_term\_hook---intercept terminal output}
  27.178 +
  27.179 +\subsubsection*{Synopsis}
  27.180 +
  27.181 +\begin{verbatim}
  27.182 +void glp_term_hook(int (*func)(void *info, const char *s),
  27.183 +      void *info);
  27.184 +\end{verbatim}
  27.185 +
  27.186 +\subsubsection*{Description}
  27.187 +
  27.188 +The routine \verb|glp_term_hook| installs the user-defined hook routine
  27.189 +to intercept all terminal output performed by GLPK routines.
  27.190 +
  27.191 +%This feature can be used to redirect the terminal output to other
  27.192 +%destination, for example, to a file or a text window.
  27.193 +
  27.194 +The parameter {\it func} specifies the user-defined hook routine. It is
  27.195 +called from an internal printing routine, which passes to it two
  27.196 +parameters: {\it info} and {\it s}. The parameter {\it info} is a
  27.197 +transit pointer specified in corresponding call to the routine
  27.198 +\verb|glp_term_hook|; it may be used to pass some additional information
  27.199 +to the hook routine. The parameter {\it s} is a pointer to the null
  27.200 +terminated character string, which is intended to be written to the
  27.201 +terminal. If the hook routine returns zero, the printing routine writes
  27.202 +the string {\it s} to the terminal in a usual way; otherwise, if the
  27.203 +hook routine returns non-zero, no terminal output is performed.
  27.204 +
  27.205 +To uninstall the hook routine both parameters {\it func} and {\it info}
  27.206 +should be specified as \verb|NULL|.
  27.207 +
  27.208 +\newpage
  27.209 +
  27.210 +\subsubsection*{Example}
  27.211 +
  27.212 +\begin{footnotesize}
  27.213 +\begin{verbatim}
  27.214 +static int hook(void *info, const char *s)
  27.215 +{     FILE *foo = info;
  27.216 +      fputs(s, foo);
  27.217 +      return 1;
  27.218 +}
  27.219 +
  27.220 +int main(void)
  27.221 +{     FILE *foo;
  27.222 +      . . .
  27.223 +      /* redirect terminal output */
  27.224 +      glp_term_hook(hook, foo);
  27.225 +      . . .
  27.226 +      /* resume terminal output */
  27.227 +      glp_term_hook(NULL, NULL);
  27.228 +      . . .
  27.229 +}
  27.230 +\end{verbatim}
  27.231 +\end{footnotesize}
  27.232 +
  27.233 +\subsection{glp\_open\_tee---start copying terminal output}
  27.234 +
  27.235 +\subsubsection*{Synopsis}
  27.236 +
  27.237 +\begin{verbatim}
  27.238 +int glp_open_tee(const char *fname);
  27.239 +\end{verbatim}
  27.240 +
  27.241 +\subsubsection*{Description}
  27.242 +
  27.243 +The routine \verb|glp_open_tee| starts copying all the terminal output
  27.244 +to an output text file, whose name is specified by the character string
  27.245 +\verb|fname|.
  27.246 +
  27.247 +\subsubsection*{Returns}
  27.248 +
  27.249 +The routine \verb|glp_open_tee| returns one of the following codes:
  27.250 +
  27.251 +\noindent
  27.252 +0 --- operation successful;
  27.253 +
  27.254 +\noindent
  27.255 +1 --- copying terminal output is already active;
  27.256 +
  27.257 +\noindent
  27.258 +2 --- unable to create output file.
  27.259 +
  27.260 +\newpage
  27.261 +
  27.262 +\subsection{glp\_close\_tee---stop copying terminal output}
  27.263 +
  27.264 +\subsubsection*{Synopsis}
  27.265 +
  27.266 +\begin{verbatim}
  27.267 +int glp_close_tee(void);
  27.268 +\end{verbatim}
  27.269 +
  27.270 +\subsubsection*{Description}
  27.271 +
  27.272 +The routine \verb|glp_close_tee| stops copying the terminal output to
  27.273 +the output text file previously open by the routine \verb|glp_open_tee|
  27.274 +closing that file.
  27.275 +
  27.276 +\subsubsection*{Returns}
  27.277 +
  27.278 +The routine \verb|glp_close_tee| returns one of the following codes:
  27.279 +
  27.280 +\noindent
  27.281 +0 --- operation successful;
  27.282 +
  27.283 +\noindent
  27.284 +1 --- copying terminal output was not started.
  27.285 +
  27.286 +\subsection{glp\_error---display error message and terminate execution}
  27.287 +
  27.288 +\subsubsection*{Synopsis}
  27.289 +
  27.290 +\begin{verbatim}
  27.291 +void glp_error(const char *fmt, ...);
  27.292 +\end{verbatim}
  27.293 +
  27.294 +\subsubsection*{Description}
  27.295 +
  27.296 +The routine \verb|glp_error| (implemented as a macro) formats its
  27.297 +parameters using the format control string \verb|fmt|, writes the
  27.298 +formatted message to the terminal, and then abnormally terminates the
  27.299 +program.
  27.300 +
  27.301 +\subsection{glp\_assert---check logical condition}
  27.302 +
  27.303 +\subsubsection*{Synopsis}
  27.304 +
  27.305 +\begin{verbatim}
  27.306 +void glp_assert(int expr);
  27.307 +\end{verbatim}
  27.308 +
  27.309 +\subsubsection*{Description}
  27.310 +
  27.311 +The routine \verb|glp_assert| (implemented as a macro) checks
  27.312 +a logical condition specified by the expression \verb|expr|. If the
  27.313 +condition is true (non-zero), the routine does nothing; otherwise, if
  27.314 +the condition is false (zero), the routine prints an error message and
  27.315 +abnormally terminates the program.
  27.316 +
  27.317 +This routine is a replacement of the standard C function \verb|assert|
  27.318 +and used by all GLPK routines to check program logic. The application
  27.319 +program may use \verb|glp_assert| for the same purpose.
  27.320 +
  27.321 +\subsection{glp\_error\_hook---install hook to intercept abnormal
  27.322 +termination}
  27.323 +
  27.324 +\subsubsection*{Synopsis}
  27.325 +
  27.326 +\begin{verbatim}
  27.327 +void glp_error_hook(void (*func)(void *info), void *info);
  27.328 +\end{verbatim}
  27.329 +
  27.330 +\subsubsection*{Description}
  27.331 +
  27.332 +The routine \verb|glp_error_hook| installs a user-defined hook routine
  27.333 +to intercept abnormal termination.
  27.334 +
  27.335 +The parameter \verb|func| specifies the user-defined hook routine. It
  27.336 +is called from the routine \verb|glp_error| before the latter calls the
  27.337 +abort function to abnormally terminate the application program because
  27.338 +of fatal error. The parameter \verb|info| is a transit pointer,
  27.339 +specified in the corresponding call to the routine
  27.340 +\verb|glp_error_hook|; it may be used to pass some information to the
  27.341 +hook routine.
  27.342 +
  27.343 +To uninstall the hook routine the parameters \verb|func| and \verb|info|
  27.344 +should be specified as \verb|NULL|.
  27.345 +
  27.346 +\subsubsection*{Usage note}
  27.347 +
  27.348 +If the hook routine returns, the application program is abnormally
  27.349 +terminated. To prevent abnormal termnation the hook routine may perform
  27.350 +a global jump using the standard function \verb|longjmp|, in which case
  27.351 +the application program {\it must} call the routine \verb|glp_free_env|.
  27.352 +
  27.353 +\subsection{glp\_malloc---allocate memory block}
  27.354 +
  27.355 +\subsubsection*{Synopsis}
  27.356 +
  27.357 +\begin{verbatim}
  27.358 +void *glp_malloc(int size);
  27.359 +\end{verbatim}
  27.360 +
  27.361 +\subsubsection*{Description}
  27.362 +
  27.363 +The routine \verb|glp_malloc| dynamically allocates a memory block of
  27.364 +\verb|size| bytes long. Should note that:
  27.365 +
  27.366 +1) the parameter \verb|size| must be positive;
  27.367 +
  27.368 +2) being allocated the memory block contains arbitrary data, that is,
  27.369 +it is {\it not} initialized by binary zeros;
  27.370 +
  27.371 +3) if the block cannot be allocated due to insufficient memory, the
  27.372 +routine prints an error message and abnormally terminates the program.
  27.373 +
  27.374 +This routine is a replacement of the standard C function \verb|malloc|
  27.375 +and used by all GLPK routines for dynamic memory allocation. The
  27.376 +application program may use \verb|glp_malloc| for the same purpose.
  27.377 +
  27.378 +\subsubsection*{Returns}
  27.379 +
  27.380 +The routine \verb|glp_malloc| returns a pointer to the memory block
  27.381 +allocated. To free this block the routine \verb|glp_free| (not the
  27.382 +standard C function \verb|free|!) must be used.
  27.383 +
  27.384 +\subsection{glp\_calloc---allocate memory block}
  27.385 +
  27.386 +\subsubsection*{Synopsis}
  27.387 +
  27.388 +\begin{verbatim}
  27.389 +void *glp_calloc(int n, int size);
  27.390 +\end{verbatim}
  27.391 +
  27.392 +\subsubsection*{Description}
  27.393 +
  27.394 +The routine \verb|glp_calloc| dynamically allocates a memory block of
  27.395 +\verb|n|$\times$\verb|size| bytes long. Should note that:
  27.396 +
  27.397 +1) both parameters \verb|n| and \verb|size| must be positive;
  27.398 +
  27.399 +2) being allocated the memory block contains arbitrary data, that is,
  27.400 +it is {\it not} initialized by binary zeros;
  27.401 +
  27.402 +3) if the block cannot be allocated due to insufficient memory, the
  27.403 +routine prints an error message and abnormally terminates the program.
  27.404 +
  27.405 +This routine is a replacement of the standard C function \verb|calloc|
  27.406 +(with exception that the block is not cleaned) and used by all GLPK
  27.407 +routines for dynamic memory allocation. The application program may use
  27.408 +\verb|glp_calloc| for the same purpose.
  27.409 +
  27.410 +\subsubsection*{Returns}
  27.411 +
  27.412 +The routine \verb|glp_calloc| returns a pointer to the memory block
  27.413 +allocated. To free this block the routine \verb|glp_free| (not the
  27.414 +standard C function \verb|free|!) must be used.
  27.415 +
  27.416 +\subsection{glp\_free---free memory block}
  27.417 +
  27.418 +\subsubsection*{Synopsis}
  27.419 +
  27.420 +\begin{verbatim}
  27.421 +void glp_free(void *ptr);
  27.422 +\end{verbatim}
  27.423 +
  27.424 +\subsubsection*{Description}
  27.425 +
  27.426 +The routine \verb|glp_free| frees (deallocates) a memory block pointed
  27.427 +to by \verb|ptr|, which was previously allocated by the routine
  27.428 +\verb|glp_malloc| or \verb|glp_calloc|. Note that the pointer \verb|ptr|
  27.429 +must valid and must not be \verb|NULL|.
  27.430 +
  27.431 +This routine is a replacement of the standard C function \verb|free|
  27.432 +and used by all GLPK routines for dynamic memory allocation. The
  27.433 +application program may use \verb|glp_free| for the same purpose.
  27.434 +
  27.435 +\subsection{glp\_mem\_usage---get memory usage information}
  27.436 +
  27.437 +\subsubsection*{Synopsis}
  27.438 +
  27.439 +\begin{verbatim}
  27.440 +void glp_mem_usage(int *count, int *cpeak, glp_long *total,
  27.441 +      glp_long *tpeak);
  27.442 +\end{verbatim}
  27.443 +
  27.444 +\subsubsection*{Description}
  27.445 +
  27.446 +The routine \verb|glp_mem_usage| reports some information about
  27.447 +utilization of the memory by the routines \verb|glp_malloc|,
  27.448 +\verb|glp_calloc|, and \verb|glp_free|. Information is stored to
  27.449 +locations specified by corresponding parameters (see below). Any
  27.450 +parameter can be specified as \verb|NULL|, in which case corresponding
  27.451 +information is not stored.
  27.452 +
  27.453 +\verb|*count| is the number of currently allocated memory blocks.
  27.454 +
  27.455 +\verb|*cpeak| is the peak value of \verb|*count| reached since the
  27.456 +initialization of the GLPK library environment.
  27.457 +
  27.458 +\verb|*total| is the total amount, in bytes, of currently allocated
  27.459 +memory blocks.
  27.460 +
  27.461 +\verb|*tpeak| is the peak value of \verb|*total| reached since the
  27.462 +initialization of the GLPK library envirionment.
  27.463 +
  27.464 +\subsubsection*{Example}
  27.465 +
  27.466 +\begin{footnotesize}
  27.467 +\begin{verbatim}
  27.468 +glp_mem_usage(&count, NULL, NULL, NULL);
  27.469 +printf("%d memory block(s) are still allocated\n", count);
  27.470 +\end{verbatim}
  27.471 +\end{footnotesize}
  27.472 +
  27.473 +\subsection{glp\_mem\_limit---set memory usage limit}
  27.474 +
  27.475 +\subsubsection*{Synopsis}
  27.476 +
  27.477 +\begin{verbatim}
  27.478 +void glp_mem_limit(int limit);
  27.479 +\end{verbatim}
  27.480 +
  27.481 +\subsubsection*{Description}
  27.482 +
  27.483 +The routine \verb|glp_mem_limit| limits the amount of memory available
  27.484 +for dynamic allocation (with the routines \verb|glp_malloc| and
  27.485 +\verb|glp_calloc|) to \verb|limit| megabytes.
  27.486 +
  27.487 +\subsection{glp\_time---determine current universal time}
  27.488 +
  27.489 +\subsubsection*{Synopsis}
  27.490 +
  27.491 +\begin{verbatim}
  27.492 +glp_long glp_time(void);
  27.493 +\end{verbatim}
  27.494 +
  27.495 +\subsection*{Returns}
  27.496 +
  27.497 +The routine \verb|glp_time| returns the current universal time (UTC),
  27.498 +in milliseconds, elapsed since 00:00:00 GMT January 1, 1970.
  27.499 +
  27.500 +\subsection{glp\_difftime---compute difference between two time values}
  27.501 +
  27.502 +\subsubsection*{Synopsis}
  27.503 +
  27.504 +\begin{verbatim}
  27.505 +double glp_difftime(glp_long t1, glp_long t0);
  27.506 +\end{verbatim}
  27.507 +
  27.508 +\subsection*{Returns}
  27.509 +
  27.510 +The routine \verb|glp_difftime| returns the difference between two time
  27.511 +values \verb|t1| and \verb|t0|, expressed in seconds.
  27.512 +
  27.513 +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  27.514 +
  27.515 +\newpage
  27.516 +
  27.517 +\section{Plain data file reading routines}
  27.518 +
  27.519 +\subsection{Introduction}
  27.520 +
  27.521 +On developing simple applications to solve optimization problems it is
  27.522 +often needed to read data from plain text files. To do this the standard
  27.523 +C function \verb|fscanf| may be used, however, it is not convenient; for
  27.524 +example, if it scans an integer number according to the format
  27.525 +specification `\verb|%d|', and that number is coded incorrectly,
  27.526 +no diagnostics is provided.
  27.527 +
  27.528 +This section describes a set of GLPK API routines, which may be used in
  27.529 +application programs to simplify reading data from plain text files.
  27.530 +
  27.531 +\subsubsection*{Example 1}
  27.532 +
  27.533 +The following main program reads ten integer numbers from plain text
  27.534 +file \verb|data.txt| and prints their sum.
  27.535 +
  27.536 +\begin{footnotesize}
  27.537 +\begin{verbatim}
  27.538 +/* sdfsamp1.c */
  27.539 +
  27.540 +#include <stdio.h>
  27.541 +#include <stdlib.h>
  27.542 +#include <glpk.h>
  27.543 +
  27.544 +int main(void)
  27.545 +{     glp_data *data;
  27.546 +      int j, num, sum;
  27.547 +      /* open plain data file */
  27.548 +      data = glp_sdf_open_file("data.txt");
  27.549 +      if (data == NULL) exit(EXIT_FAILURE);
  27.550 +      sum = 0;
  27.551 +      for (j = 1; j <= 10; j++)
  27.552 +      {  /* read next integer number */
  27.553 +         num = glp_sdf_read_int(data);
  27.554 +         sum += num;
  27.555 +      }
  27.556 +      printf("sum = %d\n", sum);
  27.557 +      /* close plain data file */
  27.558 +      glp_sdf_close_file(data);
  27.559 +      return 0;
  27.560 +}
  27.561 +
  27.562 +/* eof */
  27.563 +\end{verbatim}
  27.564 +\end{footnotesize}
  27.565 +
  27.566 +The input data are coded in free format. For example, the file
  27.567 +\verb|data.txt| may look like this:
  27.568 +
  27.569 +\begin{footnotesize}
  27.570 +\begin{verbatim}
  27.571 +123 65 432 890 -12 743 895 -7 111 326
  27.572 +\end{verbatim}
  27.573 +\end{footnotesize}
  27.574 +
  27.575 +\noindent
  27.576 +or like this:
  27.577 +
  27.578 +\begin{footnotesize}
  27.579 +\begin{verbatim}
  27.580 +123   65  432  890  -12
  27.581 +743  895   -7  111  326
  27.582 +\end{verbatim}
  27.583 +\end{footnotesize}
  27.584 +
  27.585 +\noindent
  27.586 +If the input data file contains incorrect data, the routine
  27.587 +\verb|glp_sdf_read_int| prints an error message and, if no error
  27.588 +handling is provided by the application program, abnormally terminates
  27.589 +program execution. For example, the file \verb|data.txt| could contain
  27.590 +the following data:
  27.591 +
  27.592 +\begin{footnotesize}
  27.593 +\begin{verbatim}
  27.594 +123   65  432  890  -12
  27.595 +743  895   =7  111  326
  27.596 +\end{verbatim}
  27.597 +\end{footnotesize}
  27.598 +
  27.599 +\noindent
  27.600 +in which case the error message would be the following:
  27.601 +
  27.602 +\begin{footnotesize}
  27.603 +\begin{verbatim}
  27.604 +data.txt:2: cannot convert `=7' to integer
  27.605 +\end{verbatim}
  27.606 +\end{footnotesize}
  27.607 +
  27.608 +\subsubsection*{Example 2}
  27.609 +
  27.610 +As it was said above, by default any attempt to read incorrect data
  27.611 +leads to abnormal termination. However, sometimes it is desirable to
  27.612 +catch such errors. This feature is illustrated by the following main
  27.613 +program, which does the same job as in the previous example.
  27.614 +
  27.615 +\begin{footnotesize}
  27.616 +\begin{verbatim}
  27.617 +/* sdfsamp2.c */
  27.618 +
  27.619 +#include <setjmp.h>
  27.620 +#include <stdio.h>
  27.621 +#include <stdlib.h>
  27.622 +#include <glpk.h>
  27.623 +
  27.624 +int main(void)
  27.625 +{     glp_data *data;
  27.626 +      jmp_buf jump;
  27.627 +      int j, num, sum, ret;
  27.628 +      /* open plain data file */
  27.629 +      data = glp_sdf_open_file("data.txt");
  27.630 +      if (data == NULL)
  27.631 +      {  ret = EXIT_FAILURE;
  27.632 +         goto done;
  27.633 +      }
  27.634 +      /* set up error handling */
  27.635 +      if (setjmp(jump))
  27.636 +      {  ret = EXIT_FAILURE;
  27.637 +         goto done;
  27.638 +      }
  27.639 +      glp_sdf_set_jump(data, jump);
  27.640 +      /* read and process data */
  27.641 +      sum = 0;
  27.642 +      for (j = 1; j <= 10; j++)
  27.643 +      {  /* read next integer number */
  27.644 +         num = glp_sdf_read_int(data);
  27.645 +         if (abs(num) > 1000)
  27.646 +            glp_sdf_error(data, "integer %d too big\n", num);
  27.647 +         if (num < 0)
  27.648 +            glp_sdf_warning(data, "integer %d is negative\n", num);
  27.649 +         sum += num;
  27.650 +      }
  27.651 +      printf("sum = %d\n", sum);
  27.652 +      ret = EXIT_SUCCESS;
  27.653 +done: /* close plain data file */
  27.654 +      if (data != NULL) glp_sdf_close_file(data);
  27.655 +      return ret;
  27.656 +}
  27.657 +
  27.658 +/* eof */
  27.659 +\end{verbatim}
  27.660 +\end{footnotesize}
  27.661 +
  27.662 +\subsection{glp\_sdf\_open\_file---open plain data file}
  27.663 +
  27.664 +\subsubsection*{Synopsis}
  27.665 +
  27.666 +\begin{verbatim}
  27.667 +glp_data *glp_sdf_open_file(const char *fname);
  27.668 +\end{verbatim}
  27.669 +
  27.670 +\subsubsection*{Description}
  27.671 +
  27.672 +The routine \verb|glp_sdf_open_file| opens a plain data file, whose
  27.673 +name is specified by the character string \verb|fname|.
  27.674 +
  27.675 +\subsubsection*{Returns}
  27.676 +
  27.677 +If the operation was successful, the routine \verb|glp_sdf_open_file|
  27.678 +returns a pointer to the opaque program object of the type
  27.679 +\verb|glp_data|\footnote{This data structure is declared in the header
  27.680 +file {\tt glpk.h}.} associated with the plain data file. Otherwise, if
  27.681 +the operation failed, the routine prints an error message and returns
  27.682 +\verb|NULL|.
  27.683 +
  27.684 +\subsubsection*{Note}
  27.685 +
  27.686 +The application program should use the pointer returned by the routine
  27.687 +\verb|glp_sdf_open_file| to perform all subsequent operations on the
  27.688 +data file.
  27.689 +
  27.690 +\newpage
  27.691 +
  27.692 +\subsection{glp\_sdf\_set\_jump---set up error handling}
  27.693 +
  27.694 +\subsubsection*{Synopsis}
  27.695 +
  27.696 +\begin{verbatim}
  27.697 +void glp_sdf_set_jump(glp_data *data, jmp_buf jump);
  27.698 +\end{verbatim}
  27.699 +
  27.700 +\subsubsection*{Description}
  27.701 +
  27.702 +The routine \verb|glp_sdf_set_jump| sets up error handling for the
  27.703 +plain data file specified by the parameter \verb|data|.
  27.704 +
  27.705 +The parameter \verb|jump| specifies the environment buffer, which must
  27.706 +be initialized with the standard C function \verb|setjmp| prior to call
  27.707 +to the routine \verb|glp_sdf_set_jump|. Detecting any incorrect data in
  27.708 +the corresponding plain data file will cause non-local ``go to'' by
  27.709 +a call to the standard C function \verb|longjmp|.
  27.710 +
  27.711 +The parameter \verb|jump| can be specified as \verb|NULL|, in which
  27.712 +case the routine \verb|glp_sdf_set_jump| restores the default behavior,
  27.713 +in which case detecting incorrect data leads to abnormal termination.
  27.714 +
  27.715 +\subsection{glp\_sdf\_error---print error message}
  27.716 +
  27.717 +\subsubsection*{Synopsis}
  27.718 +
  27.719 +\begin{verbatim}
  27.720 +void glp_sdf_error(glp_data *data, const char *fmt, ...);
  27.721 +\end{verbatim}
  27.722 +
  27.723 +\subsubsection*{Description}
  27.724 +
  27.725 +The routine \verb|glp_sdf_error| prints an error message related to the
  27.726 +plain data file specified by the parameter \verb|data|. If error handing
  27.727 +was not previously provided, the routine then abnormally terminates
  27.728 +execution of the application program. Otherwise, it signals about the
  27.729 +error by a call to the standard C function \verb|longjmp|.
  27.730 +
  27.731 +The character string \verb|fmt| and optional parameters following it
  27.732 +have the same meaning as for the standard C function \verb|printf|.
  27.733 +
  27.734 +The message produced by the routine \verb|glp_sdf_error| looks like
  27.735 +follows:
  27.736 +
  27.737 +\medskip
  27.738 +
  27.739 +{\it file}{\tt :}{\it line}{\tt :} {\it message text}
  27.740 +
  27.741 +\medskip
  27.742 +
  27.743 +\noindent
  27.744 +where {\it file} is the filename passed to the routine
  27.745 +\verb|glp_sdf_open| and {\it line} is the current line number.
  27.746 +
  27.747 +\newpage
  27.748 +
  27.749 +\subsection{glp\_sdf\_warning---print warning message}
  27.750 +
  27.751 +\subsubsection*{Synopsis}
  27.752 +
  27.753 +\begin{verbatim}
  27.754 +void glp_sdf_warning(glp_data *data, const char *fmt, ...);
  27.755 +\end{verbatim}
  27.756 +
  27.757 +\subsubsection*{Description}
  27.758 +
  27.759 +The routine \verb|glp_sdf_warning| prints a warning message related to
  27.760 +the plain data file specified by the parameter \verb|data|.
  27.761 +
  27.762 +The character string \verb|fmt| and optional parameters following it
  27.763 +have the same meaning as for the standard C function \verb|printf|.
  27.764 +
  27.765 +The message produced by the routine \verb|glp_sdf_warning| looks like
  27.766 +follows:
  27.767 +
  27.768 +\medskip
  27.769 +
  27.770 +{\it file}{\tt :}{\it line}\verb|: warning:| {\it message text}
  27.771 +
  27.772 +\medskip
  27.773 +
  27.774 +\noindent
  27.775 +where {\it file} is the filename passed to the routine
  27.776 +\verb|glp_sdf_open| and {\it line} is the current line number.
  27.777 +
  27.778 +\subsection{glp\_sdf\_read\_int---read integer number}
  27.779 +
  27.780 +\subsubsection*{Synopsis}
  27.781 +
  27.782 +\begin{verbatim}
  27.783 +int glp_sdf_read_int(glp_data *data);
  27.784 +\end{verbatim}
  27.785 +
  27.786 +\subsubsection*{Description}
  27.787 +
  27.788 +The routine \verb|glp_sdf_read_int| skips optional white-space
  27.789 +characters and then reads an integer number from the plain data file
  27.790 +specified by the parameter \verb|data|. If the operation failed, the
  27.791 +routine \verb|glp_sdf_read_int| calls the routine \verb|glp_sdf_error|
  27.792 +(see above).
  27.793 +
  27.794 +\subsubsection*{Returns}
  27.795 +
  27.796 +The routine \verb|glp_sdf_read_int| returns the integer number read.
  27.797 +
  27.798 +\newpage
  27.799 +
  27.800 +\subsection{glp\_sdf\_read\_num---read floating-point number}
  27.801 +
  27.802 +\subsubsection*{Synopsis}
  27.803 +
  27.804 +\begin{verbatim}
  27.805 +double glp_sdf_read_num(glp_data *data);
  27.806 +\end{verbatim}
  27.807 +
  27.808 +\subsubsection*{Description}
  27.809 +
  27.810 +The routine \verb|glp_sdf_read_num| skips optional white-space
  27.811 +characters and then reads a floating-point number from the plain data
  27.812 +file specified by the parameter \verb|data|. If the operation failed,
  27.813 +the routine \verb|glp_sdf_num| calls the routine \verb|glp_sdf_error|
  27.814 +(see above).
  27.815 +
  27.816 +\subsubsection*{Returns}
  27.817 +
  27.818 +The routine \verb|glp_sdf_read_num| returns the floating-point number
  27.819 +read.
  27.820 +
  27.821 +\subsection{glp\_sdf\_read\_item---read data item}
  27.822 +
  27.823 +\subsubsection*{Synopsis}
  27.824 +
  27.825 +\begin{verbatim}
  27.826 +const char *glp_sdf_read_item(glp_data *data);
  27.827 +\end{verbatim}
  27.828 +
  27.829 +\subsubsection*{Description}
  27.830 +
  27.831 +The routine \verb|glp_sdf_read_item| skips optional white-space
  27.832 +characters and then reads a data item from the plain data file specified
  27.833 +by the parameter \verb|data|. If the operation failed, the routine
  27.834 +\verb|glp_sdf_read_item| calls the routine \verb|glp_sdf_error| (see
  27.835 +above).
  27.836 +
  27.837 +{\it Data item} is a sequence of 1 to 255 arbitrary graphic characters
  27.838 +delimited by white-space characters. Data items may be used to represent
  27.839 +symbolic names, identifiers, etc.
  27.840 +
  27.841 +\subsubsection*{Returns}
  27.842 +
  27.843 +The routine \verb|glp_sdf_read_item| returns a pointer to the internal
  27.844 +buffer, which contains the data item read in the form of a
  27.845 +null-terminated character string.
  27.846 +
  27.847 +\newpage
  27.848 +
  27.849 +\subsection{glp\_sdf\_read\_text---read text until end of line}
  27.850 +
  27.851 +\subsubsection*{Synopsis}
  27.852 +
  27.853 +\begin{verbatim}
  27.854 +const char *glp_sdf_read_text(glp_data *data);
  27.855 +\end{verbatim}
  27.856 +
  27.857 +\subsubsection*{Description}
  27.858 +
  27.859 +The routine \verb|glp_sdf_read_text| reads a text from the plain data
  27.860 +file specified by the parameter \verb|data|.
  27.861 +
  27.862 +Reading starts from the current position and extends until end of the
  27.863 +current line. Initial and trailing white-space characters as well as
  27.864 +the newline character are not included in the text.
  27.865 +
  27.866 +\subsubsection*{Returns}
  27.867 +
  27.868 +The routine \verb|glp_sdf_read_text| returns a pointer to the internal
  27.869 +buffer, which contains the text read in the form of a null-terminated
  27.870 +character string.
  27.871 +
  27.872 +\subsection{glp\_sdf\_line---determine current line number}
  27.873 +
  27.874 +\subsubsection*{Synopsis}
  27.875 +
  27.876 +\begin{verbatim}
  27.877 +int glp_sdf_line(glp_data *data);
  27.878 +\end{verbatim}
  27.879 +
  27.880 +\subsubsection*{Returns}
  27.881 +
  27.882 +The routine \verb|glp_sdf_line| returns the current line number for the
  27.883 +plain data file specified by the parameter \verb|data|.
  27.884 +
  27.885 +\subsection{glp\_sdf\_close\_file---close plain data file}
  27.886 +
  27.887 +\subsubsection*{Synopsis}
  27.888 +
  27.889 +\begin{verbatim}
  27.890 +void glp_sdf_close_file(glp_data *data);
  27.891 +\end{verbatim}
  27.892 +
  27.893 +\subsubsection*{Description}
  27.894 +
  27.895 +The routine \verb|glp_sdf_close_file| closes the plain data file
  27.896 +specified by the parameter \verb|data| and frees all the resources
  27.897 +allocated to this program object.
  27.898 +
  27.899 +%* eof *%
    28.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    28.2 +++ b/deps/glpk/doc/glpk07.tex	Sun Nov 06 20:59:10 2011 +0100
    28.3 @@ -0,0 +1,336 @@
    28.4 +%* glpk07.tex *%
    28.5 +
    28.6 +\chapter{Installing GLPK on Your Computer}
    28.7 +\label{install}
    28.8 +
    28.9 +\section{Downloading the distribution tarball}
   28.10 +
   28.11 +The distribution tarball of the most recent version of the GLPK
   28.12 +package can be found on \url{http://ftp.gnu.org/gnu/glpk/} [via http]
   28.13 +and \url{ftp://ftp.gnu.org/gnu/glpk/} [via FTP]. It can also be found
   28.14 +on one of the FTP mirrors; see \url{http://www.gnu.org/prep/ftp.html}.
   28.15 +Please use a mirror if possible.
   28.16 +
   28.17 +To make sure that the GLPK distribution tarball you have downloaded is
   28.18 +intact you need to download the corresponding `\verb|.sig|' file and
   28.19 +run a command like this:
   28.20 +
   28.21 +\begin{verbatim}
   28.22 +   gpg --verify glpk-4.38.tar.gz.sig
   28.23 +\end{verbatim}
   28.24 +
   28.25 +\noindent
   28.26 +If that command fails because you do not have the required public key,
   28.27 +run the following command to import it:
   28.28 +
   28.29 +\begin{verbatim}
   28.30 +   gpg --keyserver keys.gnupg.net --recv-keys 5981E818
   28.31 +\end{verbatim}
   28.32 +
   28.33 +\noindent
   28.34 +and then re-run the previous command.
   28.35 +
   28.36 +\section{Unpacking the distribution tarball}
   28.37 +
   28.38 +The GLPK package (like all other GNU software) is distributed in the
   28.39 +form of packed archive. This is one file named \verb|glpk-X.Y.tar.gz|,
   28.40 +where {\it X} is the major version number and {\it Y} is the minor
   28.41 +version number.
   28.42 +
   28.43 +In order to prepare the distribution for installation you should:
   28.44 +
   28.45 +\medskip
   28.46 +
   28.47 +1. Copy the GLPK distribution file to a working subdirectory.
   28.48 +
   28.49 +\medskip
   28.50 +
   28.51 +2. Unpack the distribution file with the following command:
   28.52 +
   28.53 +\begin{verbatim}
   28.54 +   gzip -d glpk-X.Y.tar.gz
   28.55 +\end{verbatim}
   28.56 +
   28.57 +\noindent
   28.58 +that renames the distribution file to \verb|glpk-X.Y.tar|.
   28.59 +
   28.60 +\medskip
   28.61 +
   28.62 +3. Unarchive the distribution file with the following command:
   28.63 +
   28.64 +\begin{verbatim}
   28.65 +   tar -x < glpk-X.Y.tar
   28.66 +\end{verbatim}
   28.67 +
   28.68 +\noindent
   28.69 +that automatically creates the subdirectory \verb|glpk-X.Y| containing
   28.70 +the GLPK distribution.
   28.71 +
   28.72 +
   28.73 +\section{Configuring the package}
   28.74 +
   28.75 +After unpacking and unarchiving the GLPK distribution you should
   28.76 +configure the package, i.e. automatically tune it for your platform.
   28.77 +
   28.78 +Normally, you should just \verb|cd| to the subdirectory
   28.79 +\verb|glpk-X.Y| and run the configure script, e.g.
   28.80 +
   28.81 +\begin{verbatim}
   28.82 +   ./configure
   28.83 +\end{verbatim}
   28.84 +
   28.85 +The `\verb|configure|' shell script attempts to guess correct values
   28.86 +for various system-dependent variables used during compilation. It uses
   28.87 +those values to create a `\verb|Makefile|' in each directory of the
   28.88 +package. It also creates file `\verb|config.h|' containing
   28.89 +platform-dependent definitions. Finally, it creates a shell script
   28.90 +`\verb|config.status|' that you can run in the future to recreate the
   28.91 +current configuration, a file `\verb|config.cache|' that saves the
   28.92 +results of its tests to speed up reconfiguring, and a file
   28.93 +`\verb|config.log|' containing compiler output (useful mainly for
   28.94 +debugging `\verb|configure|').
   28.95 +
   28.96 +Running `\verb|configure|' takes about a few minutes. While it is
   28.97 +running, it displays some informational messages that tell you what it
   28.98 +is doing. If you don't want to see these messages, run
   28.99 +`\verb|configure|' with its standard output redirected to
  28.100 +`\verb|dev/null|'; for example, `\verb|./configure > /dev/null|'.
  28.101 +
  28.102 +By default both static and shared versions of the GLPK library will be
  28.103 +compiled. Compilation of the shared librariy can be turned off by
  28.104 +specifying the `\verb|--disable-shared|' option to `\verb|configure|',
  28.105 +e.g.
  28.106 +
  28.107 +\begin{verbatim}
  28.108 +   ./configure --disable-shared
  28.109 +\end{verbatim}
  28.110 +
  28.111 +\noindent
  28.112 +If you encounter problems building the library try using the above
  28.113 +option, because some platforms do not support shared libraries.
  28.114 +
  28.115 +\newpage
  28.116 +
  28.117 +The GLPK package has some optional features listed below. By default
  28.118 +all these features are disabled. To enable a feature the corresponding
  28.119 +option should be passed to the configure script.
  28.120 +
  28.121 +\bigskip
  28.122 +
  28.123 +\noindent
  28.124 +\verb|--with-gmp         | Enable using the GNU MP bignum library
  28.125 +
  28.126 +\medskip
  28.127 +
  28.128 +This feature allows the exact simplex solver to use the GNU MP bignum
  28.129 +library. If it is disabled, the exact simplex solver uses the GLPK
  28.130 +bignum module, which provides the same functionality as GNU MP, however,
  28.131 +it is much less efficient.
  28.132 +
  28.133 +For details about the GNU MP bignum library see its web page at
  28.134 +\url{http://gmplib.org/}.
  28.135 +
  28.136 +\bigskip
  28.137 +
  28.138 +\noindent
  28.139 +\verb|--with-zlib        |
  28.140 +Enable using the zlib data compression library
  28.141 +
  28.142 +\medskip
  28.143 +
  28.144 +This feature allows GLPK API routines and the stand-alone solver to
  28.145 +read and write compressed data files performing compression and
  28.146 +decompression ``on the fly'' (compressed data files are recognized by
  28.147 +suffix `\verb|.gz|' in the file name). It may be useful in case of
  28.148 +large MPS files to save the disk space.
  28.149 +
  28.150 +For details about the zlib compression library see its web page at
  28.151 +\url{http://www.zlib.net/}.
  28.152 +
  28.153 +\bigskip
  28.154 +
  28.155 +\noindent
  28.156 +\verb|--enable-dl        | The same as `\verb|--enable-dl=ltdl|'
  28.157 +
  28.158 +\noindent
  28.159 +\verb|--enable-dl=ltdl   | Enable shared library support (GNU)
  28.160 +
  28.161 +\noindent
  28.162 +\verb|--enable-dl=dlfcn  | Enable shared library support (POSIX)
  28.163 +
  28.164 +\medskip
  28.165 +
  28.166 +Currently this feature is only needed to provide dynamic linking to
  28.167 +ODBC and MySQL shared libraries (see below).
  28.168 +
  28.169 +For details about the GNU shared library support see the manual at
  28.170 +\url{http://www.gnu.org/software/libtool/manual/}.
  28.171 +
  28.172 +\bigskip
  28.173 +
  28.174 +\noindent
  28.175 +\verb|--enable-odbc      |
  28.176 +Enable using ODBC table driver (\verb|libiodbc|)
  28.177 +
  28.178 +\noindent
  28.179 +\verb|--enable-odbc=unix |
  28.180 +Enable using ODBC table driver (\verb|libodbc|)
  28.181 +
  28.182 +\medskip
  28.183 +
  28.184 +This feature allows transmitting data between MathProg model objects
  28.185 +and relational databases accessed through ODBC.
  28.186 +
  28.187 +For more details about this feature see the supplement ``Using Data
  28.188 +Tables in the GNU MathProg Modeling Language'' (\verb|doc/tables.pdf|).
  28.189 +
  28.190 +\bigskip
  28.191 +
  28.192 +\noindent
  28.193 +\verb|--enable-mysql     |
  28.194 +Enable using MySQL table driver (\verb|libmysql|)
  28.195 +
  28.196 +\medskip
  28.197 +
  28.198 +This feature allows transmitting data between MathProg model objects
  28.199 +and MySQL relational databases.
  28.200 +
  28.201 +For more details about this feature see the supplement ``Using Data
  28.202 +Tables in the GNU MathProg Modeling Language'' (\verb|doc/tables.pdf|).
  28.203 +
  28.204 +\section{Compiling the package}
  28.205 +
  28.206 +Normally, you can compile (build) the package by typing the command:
  28.207 +
  28.208 +\begin{verbatim}
  28.209 +   make
  28.210 +\end{verbatim}
  28.211 +
  28.212 +\noindent
  28.213 +It reads `\verb|Makefile|' generated by `\verb|configure|' and performs
  28.214 +all necessary jobs.
  28.215 +
  28.216 +If you want, you can override the `\verb|make|' variables \verb|CFLAGS|
  28.217 +and \verb|LDFLAGS| like this:
  28.218 +
  28.219 +\begin{verbatim}
  28.220 +   make CFLAGS=-O2 LDFLAGS=-s
  28.221 +\end{verbatim}
  28.222 +
  28.223 +To compile the package in a different directory from the one containing
  28.224 +the source code, you must use a version of `\verb|make|' that supports
  28.225 +`\verb|VPATH|' variable, such as GNU `\verb|make|'. `\verb|cd|' to the
  28.226 +directory where you want the object files and executables to go and run
  28.227 +the `\verb|configure|' script. `\verb|configure|' automatically checks
  28.228 +for the source code in the directory that `\verb|configure|' is in and
  28.229 +in `\verb|..|'. If for some reason `\verb|configure|' is not in the
  28.230 +source code directory that you are configuring, then it will report that
  28.231 +it can't find the source code. In that case, run `\verb|configure|' with
  28.232 +the option `\verb|--srcdir=DIR|', where \verb|DIR| is the directory that
  28.233 +contains the source code.
  28.234 +
  28.235 +Some systems require unusual options for compilation or linking that
  28.236 +the `\verb|configure|' script does not know about. You can give
  28.237 +`\verb|configure|' initial values for variables by setting them in the
  28.238 +environment. Using a Bourne-compatible shell, you can do that on the
  28.239 +command line like this:
  28.240 +
  28.241 +\begin{verbatim}
  28.242 +   CC=c89 CFLAGS=-O2 LIBS=-lposix ./configure
  28.243 +\end{verbatim}
  28.244 +
  28.245 +\noindent
  28.246 +Or on systems that have the `\verb|env|' program, you can do it like
  28.247 +this:
  28.248 +
  28.249 +\begin{verbatim}
  28.250 +   env CPPFLAGS=-I/usr/local/include LDFLAGS=-s ./configure
  28.251 +\end{verbatim}
  28.252 +
  28.253 +Here are the `\verb|make|' variables that you might want to override
  28.254 +with environment variables when running `\verb|configure|'.
  28.255 +
  28.256 +For these variables, any value given in the environment overrides the
  28.257 +value that `\verb|configure|' would choose:
  28.258 +
  28.259 +\medskip
  28.260 +
  28.261 +\noindent
  28.262 +\verb|CC      | C compiler program. The default is `\verb|cc|'.
  28.263 +
  28.264 +\medskip
  28.265 +
  28.266 +\noindent
  28.267 +\verb|INSTALL | Program used to install files. The default value is
  28.268 +`\verb|install|' if
  28.269 +
  28.270 +\noindent
  28.271 +\verb|        | you have it, otherwise `\verb|cp|'.
  28.272 +
  28.273 +\medskip
  28.274 +
  28.275 +For these variables, any value given in the environment is added to the
  28.276 +value that `\verb|configure|' chooses:
  28.277 +
  28.278 +\medskip
  28.279 +
  28.280 +\noindent
  28.281 +\verb|DEFS    | Configuration options, in the form
  28.282 +`\verb|-Dfoo -Dbar| \dots'.
  28.283 +
  28.284 +\medskip
  28.285 +
  28.286 +\noindent
  28.287 +\verb|LIBS    | Libraries to link with, in the form
  28.288 +`\verb|-lfoo -lbar| \dots'.
  28.289 +
  28.290 +\section{Checking the package}
  28.291 +
  28.292 +To check the package, i.e. to run some tests included in the package,
  28.293 +you can use the following command:
  28.294 +
  28.295 +\begin{verbatim}
  28.296 +   make check
  28.297 +\end{verbatim}
  28.298 +
  28.299 +\section{Installing the package}
  28.300 +
  28.301 +Normally, to install the GLPK package you should type the following
  28.302 +command:
  28.303 +
  28.304 +\begin{verbatim}
  28.305 +   make install
  28.306 +\end{verbatim}
  28.307 +
  28.308 +\noindent
  28.309 +By default, `\verb|make install|' will install the package's files in
  28.310 +`\verb|usr/local/bin|', `\verb|usr/local/lib|', etc. You can specify an
  28.311 +installation prefix other than `\verb|/usr/local|' by giving
  28.312 +`\verb|configure|' the option `\verb|--prefix=PATH|'. Alternately, you
  28.313 +can do so by consistently giving a value for the `\verb|prefix|'
  28.314 +variable when you run `\verb|make|', e.g.
  28.315 +
  28.316 +\begin{verbatim}
  28.317 +   make prefix=/usr/gnu
  28.318 +   make prefix=/usr/gnu install
  28.319 +\end{verbatim}
  28.320 +
  28.321 +After installing you can remove the program binaries and object files
  28.322 +from the source directory by typing `\verb|make clean|'. To remove all
  28.323 +files that `\verb|configure|' created (`\verb|Makefile|',
  28.324 +`\verb|config.status|', etc.), just type `\verb|make distclean|'.
  28.325 +
  28.326 +The file `\verb|configure.ac|' is used to create `\verb|configure|' by
  28.327 +a program called `\verb|autoconf|'. You only need it if you want to
  28.328 +remake `\verb|configure|' using a newer version of `\verb|autoconf|'.
  28.329 +
  28.330 +\section{Uninstalling the package}
  28.331 +
  28.332 +To uninstall the GLPK package, i.e. to remove all the package's files
  28.333 +from the system places, you can use the following command:
  28.334 +
  28.335 +\begin{verbatim}
  28.336 +   make uninstall
  28.337 +\end{verbatim}
  28.338 +
  28.339 +%* eof *%
    29.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    29.2 +++ b/deps/glpk/doc/glpk08.tex	Sun Nov 06 20:59:10 2011 +0100
    29.3 @@ -0,0 +1,696 @@
    29.4 +%* glpk08.tex *%
    29.5 +
    29.6 +\chapter{MPS Format}
    29.7 +\label{champs}
    29.8 +
    29.9 +\section{Fixed MPS Format}
   29.10 +\label{secmps}
   29.11 +
   29.12 +The MPS format\footnote{The MPS format was developed in 1960's by IBM
   29.13 +as input format for their mathematical programming system MPS/360.
   29.14 +Today the MPS format is a most widely used format understood by most
   29.15 +mathematical programming packages. This appendix describes only the
   29.16 +features of the MPS format, which are implemented in the GLPK package.}
   29.17 +is intended for coding LP/MIP problem data. This format assumes the
   29.18 +formulation of LP/MIP problem (1.1)---(1.3) (see Section \ref{seclp},
   29.19 +page \pageref{seclp}).
   29.20 +
   29.21 +{\it MPS file} is a text file, which contains two types of
   29.22 +cards\footnote{In 1960's MPS file was a deck of 80-column punched cards,
   29.23 +so the author decided to keep the word ``card'', which may be understood
   29.24 +as ``line of text file''.}: indicator cards and data cards.
   29.25 +
   29.26 +Indicator cards determine a kind of succeeding data. Each indicator card
   29.27 +has one word in uppercase letters beginning in column 1.
   29.28 +
   29.29 +Data cards contain problem data. Each data card is divided into six
   29.30 +fixed fields:
   29.31 +
   29.32 +\begin{center}
   29.33 +\begin{tabular}{lcccccc}
   29.34 +& Field 1 & Field 2 & Field 3 & Field 4 & Field 5 & Feld 6 \\
   29.35 +\hline
   29.36 +Columns & 2---3 & 5---12 & 15---22 & 25---36 & 40---47 & 50---61 \\
   29.37 +Contents & Code & Name & Name & Number & Name & Number \\
   29.38 +\end{tabular}
   29.39 +\end{center}
   29.40 +
   29.41 +On a particular data card some fields may be optional.
   29.42 +
   29.43 +Names are used to identify rows, columns, and some vectors (see below).
   29.44 +
   29.45 +Aligning the indicator code in the field 1 to the left margin is
   29.46 +optional.
   29.47 +
   29.48 +All names specified in the fields 2, 3, and 5 should contain from 1 up
   29.49 +to 8 arbitrary characters (except control characters). If a name is
   29.50 +placed in the field 3 or 5, its first character should not be the dollar
   29.51 +sign `\verb|$|'. If a name contains spaces, the spaces are ignored.
   29.52 +
   29.53 +All numerical values in the fields 4 and 6 should be coded in the form
   29.54 +$sxx$\verb|E|$syy$, where $s$ is the plus `\verb|+|' or the minus
   29.55 +`\verb|-|' sign, $xx$ is a real number with optional decimal point,
   29.56 +$yy$ is an integer decimal exponent. Any number should contain up to 12
   29.57 +characters. If the sign $s$ is omitted, the plus sign is assumed. The
   29.58 +exponent part is optional. If a number contains spaces, the spaces are
   29.59 +ignored.
   29.60 +
   29.61 +If a card has the asterisk `\verb|*|' in the column 1, this card is
   29.62 +considered as a comment and ignored. Besides, if the first character in
   29.63 +the field 3 or 5 is the dollar sign `\verb|$|', all characters from the
   29.64 +dollar sign to the end of card are considered as a comment and ignored.
   29.65 +
   29.66 +MPS file should contain cards in the following order:
   29.67 +
   29.68 +$\bullet$ NAME indicator card;
   29.69 +
   29.70 +$\bullet$ ROWS indicator card;
   29.71 +
   29.72 +$\bullet$ data cards specifying rows (constraints);
   29.73 +
   29.74 +$\bullet$ COLUMNS indicator card;
   29.75 +
   29.76 +$\bullet$ data cards specifying columns (structural variables) and
   29.77 +constraint coefficients;
   29.78 +
   29.79 +$\bullet$ RHS indicator card;
   29.80 +
   29.81 +$\bullet$ data cards specifying right-hand sides of constraints;
   29.82 +
   29.83 +$\bullet$ RANGES indicator card;
   29.84 +
   29.85 +$\bullet$ data cards specifying ranges for double-bounded constraints;
   29.86 +
   29.87 +$\bullet$ BOUNDS indicator card;
   29.88 +
   29.89 +$\bullet$ data cards specifying types and bounds of structural
   29.90 +variables;
   29.91 +
   29.92 +$\bullet$ ENDATA indicator card.
   29.93 +
   29.94 +{\it Section} is a group of cards consisting of an indicator card and
   29.95 +data cards succeeding this indicator card. For example, the ROWS section
   29.96 +consists of the ROWS indicator card and data cards specifying rows.
   29.97 +
   29.98 +The sections RHS, RANGES, and BOUNDS are optional and may be omitted.
   29.99 +
  29.100 +\section{Free MPS Format}
  29.101 +
  29.102 +{\it Free MPS format} is an improved version of the standard (fixed)
  29.103 +MPS format described above.\footnote{This format was developed in the
  29.104 +beginning of 1990's by IBM as an alternative to the standard fixed MPS
  29.105 +format for Optimization Subroutine Library (OSL).} Note that all
  29.106 +changes in free MPS format concern only the coding of data while the
  29.107 +structure of data is the same for both fixed and free versions of the
  29.108 +MPS format.
  29.109 +
  29.110 +In free MPS format indicator and data records\footnote{{\it Record} in
  29.111 +free MPS format has the same meaning as {\it card} in fixed MPS format.}
  29.112 +may have arbitrary length not limited to 80 characters. Fields of data
  29.113 +records have no predefined positions, i.e. the fields may begin in any
  29.114 +position, except position 1, which must be blank, and must be separated
  29.115 +from each other by one or more blanks. However, the fields must appear
  29.116 +in the same order as in fixed MPS format.
  29.117 +
  29.118 +Symbolic names in fields 2, 3, and 5 may be longer than 8
  29.119 +characters\footnote{GLPK allows symbolic names having up to 255
  29.120 +characters.}
  29.121 +and must not contain embedded blanks.
  29.122 +
  29.123 +Numeric values in fields 4 and 6 are limited to 12 characters and must
  29.124 +not contain embedded blanks.
  29.125 +
  29.126 +Only six fields on each data record are used. Any other fields are
  29.127 +ignored.
  29.128 +
  29.129 +If the first character of any field (not necessarily fields 3 and 5)
  29.130 +is the dollar sign (\$), all characters from the dollar sign to the end
  29.131 +of record are considered as a comment and ignored.
  29.132 +
  29.133 +\section{NAME indicator card}
  29.134 +
  29.135 +The NAME indicator card should be the first card in the MPS file (except
  29.136 +optional comment cards, which may precede the NAME card). This card
  29.137 +should contain the word \verb|NAME| in the columns 1---4 and the problem
  29.138 +name in the field 3. The problem name is optional and may be omitted.
  29.139 +
  29.140 +\section{ROWS section}
  29.141 +\label{secrows}
  29.142 +
  29.143 +The ROWS section should start with the indicator card, which contains
  29.144 +the word \verb|ROWS| in the columns 1---4.
  29.145 +
  29.146 +Each data card in the ROWS section specifies one row (constraint) of the
  29.147 +problem. All these data cards have the following format.
  29.148 +
  29.149 +`\verb|N|' in the field 1 means that the row is free (unbounded):
  29.150 +$$-\infty < x_i = a_{i1}x_{m+1} + a_{i2}x_{m+2} + \dots + a_{in}x_{m+n}
  29.151 +< +\infty;$$
  29.152 +
  29.153 +`\verb|L|' in the field 1 means that the row is of ``less than or equal
  29.154 +to'' type:
  29.155 +$$-\infty < x_i = a_{i1}x_{m+1} + a_{i2}x_{m+2} + \dots + a_{in}x_{m+n}
  29.156 +\leq b_i;$$
  29.157 +
  29.158 +`\verb|G|' in the field 1 means that the row is of ``greater than or
  29.159 +equal to'' type:
  29.160 +$$b_i \leq x_i = a_{i1}x_{m+1} + a_{i2}x_{m+2} + \dots + a_{in}x_{m+n}
  29.161 +< +\infty;$$
  29.162 +
  29.163 +`\verb|E|' in the field 1 means that the row is of ``equal to'' type:
  29.164 +$$x_i = a_{i1}x_{m+1} + a_{i2}x_{m+2} + \dots + a_{in}x_{m+n} \leq
  29.165 +b_i,$$
  29.166 +where $b_i$ is a right-hand side. Note that each constraint has a
  29.167 +corresponding implictly defined auxiliary variable ($x_i$ above), whose
  29.168 +value is a value of the corresponding linear form, therefore row bounds
  29.169 +can be considered as bounds of such auxiliary variable.
  29.170 +
  29.171 +The filed 2 specifies a row name (which is considered as the name of
  29.172 +the corresponding auxiliary variable).
  29.173 +
  29.174 +The fields 3, 4, 5, and 6 are not used and should be empty.
  29.175 +
  29.176 +Numerical values of all non-zero right-hand sides $b_i$ should be
  29.177 +specified in the RHS section (see below). All double-bounded (ranged)
  29.178 +constraints should be specified in the RANGES section (see below).
  29.179 +
  29.180 +\section{COLUMNS section}
  29.181 +
  29.182 +The COLUMNS section should start with the indicator card, which contains
  29.183 +the word \verb|COLUMNS| in the columns 1---7.
  29.184 +
  29.185 +Each data card in the COLUMNS section specifies one or two constraint
  29.186 +coefficients $a_{ij}$ and also introduces names of columns, i.e. names
  29.187 +of structural variables. All these data cards have the following format.
  29.188 +
  29.189 +The field 1 is not used and should be empty.
  29.190 +
  29.191 +The field 2 specifies a column name. If this field is empty, the column
  29.192 +name from the immediately preceeding data card is assumed.
  29.193 +
  29.194 +The field 3 specifies a row name defined in the ROWS section.
  29.195 +
  29.196 +The field 4 specifies a numerical value of the constraint coefficient
  29.197 +$a_{ij}$, which is placed in the corresponding row and column.
  29.198 +
  29.199 +The fields 5 and 6 are optional. If they are used, they should contain
  29.200 +a second pair ``row name---constraint coefficient'' for the same column.
  29.201 +
  29.202 +Elements of the constraint matrix (i.e. constraint coefficients) should
  29.203 +be enumerated in the column wise manner: all elements for the current
  29.204 +column should be specified before elements for the next column. However,
  29.205 +the order of rows in the COLUMNS section may differ from the order of
  29.206 +rows in the ROWS section.
  29.207 +
  29.208 +Constraint coefficients not specified in the COLUMNS section are
  29.209 +considered as zeros. Therefore zero coefficients may be omitted,
  29.210 +although it is allowed to explicitly specify them.
  29.211 +
  29.212 +\section{RHS section}
  29.213 +
  29.214 +The RHS section should start with the indicator card, which contains the
  29.215 +word \verb|RHS| in the columns 1---3.
  29.216 +
  29.217 +Each data card in the RHS section specifies one or two right-hand sides
  29.218 +$b_i$ (see Section \ref{secrows}, page \pageref{secrows}). All these
  29.219 +data cards have the following format.
  29.220 +
  29.221 +The field 1 is not used and should be empty.
  29.222 +
  29.223 +The field 2 specifies a name of the right-hand side (RHS)
  29.224 +vector\footnote{This feature allows the user to specify several RHS
  29.225 +vectors in the same MPS file. However, before solving the problem a
  29.226 +particular RHS vector should be chosen.}. If this field is empty, the
  29.227 +RHS vector name from the immediately preceeding data card is assumed.
  29.228 +
  29.229 +The field 3 specifies a row name defined in the ROWS section.
  29.230 +
  29.231 +The field 4 specifies a right-hand side $b_i$ for the row, whose name is
  29.232 +specified in the field 3. Depending on the row type $b_i$ is a lower
  29.233 +bound (for the row of \verb|G| type), an upper bound (for the row of
  29.234 +\verb|L| type), or a fixed value (for the row of \verb|E|
  29.235 +type).\footnote{If the row is of {\tt N} type, $b_i$ is considered as
  29.236 +a constant term of the corresponding linear form. Should note, however,
  29.237 +this convention is non-standard.}
  29.238 +
  29.239 +The fields 5 and 6 are optional. If they are used, they should contain
  29.240 +a second pair ``row name---right-hand side'' for the same RHS vector.
  29.241 +
  29.242 +All right-hand sides for the current RHS vector should be specified
  29.243 +before right-hand sides for the next RHS vector. However, the order of
  29.244 +rows in the RHS section may differ from the order of rows in the ROWS
  29.245 +section.
  29.246 +
  29.247 +Right-hand sides not specified in the RHS section are considered as
  29.248 +zeros. Therefore zero right-hand sides may be omitted, although it is
  29.249 +allowed to explicitly specify them.
  29.250 +
  29.251 +\section{RANGES section}
  29.252 +
  29.253 +The RANGES section should start with the indicator card, which contains
  29.254 +the word \verb|RANGES| in the columns 1---6.
  29.255 +
  29.256 +Each data card in the RANGES section specifies one or two ranges for
  29.257 +double-side constraints, i.e. for constraints that are of the types
  29.258 +\verb|L| and \verb|G| at the same time:
  29.259 +$$l_i \leq x_i = a_{i1}x_{m+1} + a_{i2}x_{m+2} + \dots + a_{in}x_{m+n}
  29.260 +\leq u_i,$$
  29.261 +where $l_i$ is a lower bound, $u_i$ is an upper bound. All these data
  29.262 +cards have the following format.
  29.263 +
  29.264 +The field 1 is not used and should be empty.
  29.265 +
  29.266 +The field 2 specifies a name of the range vector\footnote{This feature
  29.267 +allows the user to specify several range vectors in the same MPS file.
  29.268 +However, before solving the problem a particular range vector should be
  29.269 +chosen.}. If this field is empty, the range vector name from the
  29.270 +immediately preceeding data card is assumed.
  29.271 +
  29.272 +The field 3 specifies a row name defined in the ROWS section.
  29.273 +
  29.274 +The field 4 specifies a range value $r_i$ (see the table below) for the
  29.275 +row, whose name is specified in the field 3.
  29.276 +
  29.277 +The fields 5 and 6 are optional. If they are used, they should contain
  29.278 +a second pair ``row name---range value'' for the same range vector.
  29.279 +
  29.280 +All range values for the current range vector should be specified before
  29.281 +range values for the next range vector. However, the order of rows in
  29.282 +the RANGES section may differ from the order of rows in the ROWS
  29.283 +section.
  29.284 +
  29.285 +For each double-side constraint specified in the RANGES section its
  29.286 +lower and upper bounds are determined as follows:
  29.287 +
  29.288 +\begin{center}
  29.289 +\begin{tabular}{cccc}
  29.290 +Row type & Sign of $r_i$ & Lower bound & Upper bound \\
  29.291 +\hline
  29.292 +{\tt G} & $+$ or $-$ & $b_i$ & $b_i + |r_i|$ \\
  29.293 +{\tt L} & $+$ or $-$ & $b_i - |r_i|$ & $b_i$ \\
  29.294 +{\tt E} & $+$ & $b_i$ & $b_i + |r_i|$ \\
  29.295 +{\tt E} & $-$ & $b_i - |r_i|$ & $b_i$ \\
  29.296 +\end{tabular}
  29.297 +\end{center}
  29.298 +
  29.299 +\noindent
  29.300 +where $b_i$ is a right-hand side specified in the RHS section (if $b_i$
  29.301 +is not specified, it is considered as zero), $r_i$ is a range value
  29.302 +specified in the RANGES section.
  29.303 +
  29.304 +\section{BOUNDS section}
  29.305 +\label{secbounds}
  29.306 +
  29.307 +The BOUNDS section should start with the indicator card, which contains
  29.308 +the word \verb|BOUNDS| in the columns 1---6.
  29.309 +
  29.310 +Each data card in the BOUNDS section specifies one (lower or upper)
  29.311 +bound for one structural variable (column). All these data cards have
  29.312 +the following format.
  29.313 +
  29.314 +The indicator in the field 1 specifies the bound type:
  29.315 +
  29.316 +\begin{tabular}{@{}ll}
  29.317 +\verb|LO| & lower bound; \\
  29.318 +\verb|UP| & upper bound; \\
  29.319 +\verb|FX| & fixed variable (lower and upper bounds are equal); \\
  29.320 +\verb|FR| & free variable (no bounds); \\
  29.321 +\verb|MI| & no lower bound (lower bound is ``minus infinity''); \\
  29.322 +\verb|PL| & no upper bound (upper bound is ``plus infinity''); \\
  29.323 +\end{tabular}
  29.324 +
  29.325 +The field 2 specifies a name of the bound vector\footnote{This feature
  29.326 +allows the user to specify several bound vectors in the same MPS file.
  29.327 +However, before solving the problem a particular bound vector should be
  29.328 +chosen.}. If this field is empty, the bound vector name from the
  29.329 +immediately preceeding data card is assumed.
  29.330 +
  29.331 +The field 3 specifies a column name defined in the COLUMNS section.
  29.332 +
  29.333 +The field 4 specifies a bound value. If the bound type in the field 1
  29.334 +differs from \verb|LO|, \verb|UP|, and \verb|FX|, the value in the field
  29.335 +4 is ignored and may be omitted.
  29.336 +
  29.337 +The fields 5 and 6 are not used and should be empty.
  29.338 +
  29.339 +All bound values for the current bound vector should be specified before
  29.340 +bound values for the next bound vector. However, the order of columns in
  29.341 +the BOUNDS section may differ from the order of columns in the COLUMNS
  29.342 +section. Specification of a lower bound should precede specification of
  29.343 +an upper bound for the same column (if both the lower and upper bounds
  29.344 +are explicitly specified).
  29.345 +
  29.346 +By default, all columns (structural variables) are non-negative, i.e.
  29.347 +have zero lower bound and no upper bound. Lower ($l_j$) and upper
  29.348 +($u_j$) bounds of some column (structural variable $x_j$) are set in the
  29.349 +following way, where $s_j$ is a corresponding bound value explicitly
  29.350 +specified in the BOUNDS section:
  29.351 +
  29.352 +\begin{tabular}{@{}ll}
  29.353 +\verb|LO| & sets $l_j$ to $s_j$; \\
  29.354 +\verb|UP| & sets $u_j$ to $s_j$; \\
  29.355 +\verb|FX| & sets both $l_j$ and $u_j$ to $s_j$; \\
  29.356 +\verb|FR| & sets $l_j$ to $-\infty$ and $u_j$ to $+\infty$; \\
  29.357 +\verb|MI| & sets $l_j$ to $-\infty$; \\
  29.358 +\verb|PL| & sets $u_j$ to $+\infty$. \\
  29.359 +\end{tabular}
  29.360 +
  29.361 +\section{ENDATA indicator card}
  29.362 +
  29.363 +The ENDATA indicator card should be the last card of MPS file (except
  29.364 +optional comment cards, which may follow the ENDATA card). This card
  29.365 +should contain the word \verb|ENDATA| in the columns 1---6.
  29.366 +
  29.367 +\section{Specifying objective function}
  29.368 +
  29.369 +It is impossible to explicitly specify the objective function and
  29.370 +optimization direction in the MPS file. However, the following implicit
  29.371 +rule is used by default: the first row of \verb|N| type is considered
  29.372 +as a row of the objective function (i.e. the objective function is the
  29.373 +corresponding auxiliary variable), which should be {\it minimized}.
  29.374 +
  29.375 +GLPK also allows specifying a constant term of the objective function
  29.376 +as a right-hand side of the corresponding row in the RHS section.
  29.377 +
  29.378 +\section{Example of MPS file}
  29.379 +\label{secmpsex}
  29.380 +
  29.381 +In order to illustrate what the MPS format is, consider the following
  29.382 +example of LP problem:
  29.383 +
  29.384 +\medskip
  29.385 +\noindent minimize
  29.386 +$$
  29.387 +value = .03\ bin_1 + .08\ bin_2 + .17\ bin_3 + .12\ bin_4 + .15\ bin_5
  29.388 ++ .21\ al + .38\ si
  29.389 +$$
  29.390 +
  29.391 +\noindent subject to linear constraints
  29.392 +$$
  29.393 +\begin{array}{@{}l@{\:}l@{}}
  29.394 +yield &= \ \ \ \ \;bin_1 + \ \ \ \ \;bin_2 + \ \ \ \ \;bin_3 +
  29.395 +         \ \ \ \ \;bin_4 + \ \ \ \ \;bin_5 + \ \ \ \ \;al +
  29.396 +         \ \ \ \ \;si \\
  29.397 +FE    &= .15\ bin_1 + .04\ bin_2 + .02\ bin_3 + .04\ bin_4 + .02\ bin_5
  29.398 +         + .01\ al + .03\ si \\
  29.399 +CU    &= .03\ bin_1 + .05\ bin_2 + .08\ bin_3 + .02\ bin_4 + .06\ bin_5
  29.400 +         + .01\ al \\
  29.401 +MN    &= .02\ bin_1 + .04\ bin_2 + .01\ bin_3 + .02\ bin_4 + .02\ bin_5
  29.402 +         \\
  29.403 +MG    &= .02\ bin_1 + .03\ bin_2
  29.404 +\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ + .01\ bin_5 \\
  29.405 +AL    &= .70\ bin_1 + .75\ bin_2 + .80\ bin_3 + .75\ bin_4 + .80\ bin_5
  29.406 +         + .97\ al \\
  29.407 +SI    &= .02\ bin_1 + .06\ bin_2 + .08\ bin_3 + .12\ bin_4 + .02\ bin_5
  29.408 +         + .01\ al + .97\ si \\
  29.409 +\end{array}
  29.410 +$$
  29.411 +and bounds of (auxiliary and structural) variables
  29.412 +$$
  29.413 +\begin{array}{r@{\ }l@{\ }l@{\ }l@{\ }rcr@{\ }l@{\ }l@{\ }l@{\ }r}
  29.414 +&&yield&=&2000&&0&\leq&bin_1&\leq&200\\
  29.415 +-\infty&<&FE&\leq&60&&0&\leq&bin_2&\leq&2500\\
  29.416 +-\infty&<&CU&\leq&100&&400&\leq&bin_3&\leq&800\\
  29.417 +-\infty&<&MN&\leq&40&&100&\leq&bin_4&\leq&700\\
  29.418 +-\infty&<&MG&\leq&30&&0&\leq&bin_5&\leq&1500\\
  29.419 +1500&\leq&AL&<&+\infty&&0&\leq&al&<&+\infty\\
  29.420 +250&\leq&SI&\leq&300&&0&\leq&si&<&+\infty\\
  29.421 +\end{array}
  29.422 +$$
  29.423 +
  29.424 +A complete MPS file which specifies data for this example is shown
  29.425 +below (the first two comment lines show card positions).
  29.426 +
  29.427 +\begin{verbatim}
  29.428 +*000000001111111111222222222233333333334444444444555555555566
  29.429 +*234567890123456789012345678901234567890123456789012345678901
  29.430 +NAME          PLAN
  29.431 +ROWS
  29.432 + N  VALUE
  29.433 + E  YIELD
  29.434 + L  FE
  29.435 + L  CU
  29.436 + L  MN
  29.437 + L  MG
  29.438 + G  AL
  29.439 + L  SI
  29.440 +COLUMNS
  29.441 +    BIN1      VALUE           .03000   YIELD          1.00000
  29.442 +              FE              .15000   CU              .03000
  29.443 +              MN              .02000   MG              .02000
  29.444 +              AL              .70000   SI              .02000
  29.445 +    BIN2      VALUE           .08000   YIELD          1.00000
  29.446 +              FE              .04000   CU              .05000
  29.447 +              MN              .04000   MG              .03000
  29.448 +              AL              .75000   SI              .06000
  29.449 +    BIN3      VALUE           .17000   YIELD          1.00000
  29.450 +              FE              .02000   CU              .08000
  29.451 +              MN              .01000   AL              .80000
  29.452 +              SI              .08000
  29.453 +    BIN4      VALUE           .12000   YIELD          1.00000
  29.454 +              FE              .04000   CU              .02000
  29.455 +              MN              .02000   AL              .75000
  29.456 +              SI              .12000
  29.457 +    BIN5      VALUE           .15000   YIELD          1.00000
  29.458 +              FE              .02000   CU              .06000
  29.459 +              MN              .02000   MG              .01000
  29.460 +              AL              .80000   SI              .02000
  29.461 +    ALUM      VALUE           .21000   YIELD          1.00000
  29.462 +              FE              .01000   CU              .01000
  29.463 +              AL              .97000   SI              .01000
  29.464 +    SILICON   VALUE           .38000   YIELD          1.00000
  29.465 +              FE              .03000   SI              .97000
  29.466 +RHS
  29.467 +    RHS1      YIELD       2000.00000   FE            60.00000
  29.468 +              CU           100.00000   MN            40.00000
  29.469 +              SI           300.00000
  29.470 +              MG            30.00000   AL          1500.00000
  29.471 +RANGES
  29.472 +    RNG1      SI            50.00000
  29.473 +BOUNDS
  29.474 + UP BND1      BIN1         200.00000
  29.475 + UP           BIN2        2500.00000
  29.476 + LO           BIN3         400.00000
  29.477 + UP           BIN3         800.00000
  29.478 + LO           BIN4         100.00000
  29.479 + UP           BIN4         700.00000
  29.480 + UP           BIN5        1500.00000
  29.481 +ENDATA
  29.482 +\end{verbatim}
  29.483 +
  29.484 +\section{MIP features}
  29.485 +
  29.486 +The MPS format provides two ways for introducing integer variables into
  29.487 +the problem.
  29.488 +
  29.489 +The first way is most general and based on using special marker cards
  29.490 +INTORG and INTEND. These marker cards are placed in the COLUMNS section.
  29.491 +The INTORG card indicates the start of a group of integer variables
  29.492 +(columns), and the card INTEND indicates the end of the group. The MPS
  29.493 +file may contain arbitrary number of the marker cards.
  29.494 +
  29.495 +The marker cards have the same format as the data cards (see Section
  29.496 +\ref{secmps}, page \pageref{secmps}).
  29.497 +
  29.498 +The fields 1, 2, and 6 are not used and should be empty.
  29.499 +
  29.500 +The field 2 should contain a marker name. This name may be arbitrary.
  29.501 +
  29.502 +The field 3 should contain the word \verb|'MARKER'| (including
  29.503 +apostrophes).
  29.504 +
  29.505 +The field 5 should contain either the word \verb|'INTORG'| (including
  29.506 +apostrophes) for the marker card, which begins a group of integer
  29.507 +columns, or the word \verb|'INTEND'| (including apostrophes) for the
  29.508 +marker card, which ends the group.
  29.509 +
  29.510 +The second way is less general but more convenient in some cases. It
  29.511 +allows the user declaring integer columns using three additional types
  29.512 +of bounds, which are specified in the field 1 of data cards in the
  29.513 +BOUNDS section (see Section \ref{secbounds}, page \pageref{secbounds}):
  29.514 +
  29.515 +\begin{tabular}{@{}lp{112.3mm}@{}}
  29.516 +\verb|LI| & lower integer. This bound type specifies that the
  29.517 +corresponding column (structural variable), whose name is specified in
  29.518 +field 3, is of integer kind. In this case an lower bound of the
  29.519 +column should be specified in field 4 (like in the case of \verb|LO|
  29.520 +bound type). \\
  29.521 +\verb|UI| & upper integer. This bound type specifies that the
  29.522 +corresponding column (structural variable), whose name is specified in
  29.523 +field 3, is of integer kind. In this case an upper bound of the
  29.524 +column should be specified in field 4 (like in the case of \verb|UP|
  29.525 +bound type). \\
  29.526 +\end{tabular}
  29.527 +
  29.528 +\pagebreak
  29.529 +
  29.530 +\begin{tabular}{@{}lp{112.3mm}@{}}
  29.531 +\verb|BV| & binary variable. This bound type specifies that the
  29.532 +corresponding column (structural variable), whose name is specified in
  29.533 +the field 3, is of integer kind, its lower bound is zero, and its upper
  29.534 +bound is one (thus, such variable being of integer kind can have only
  29.535 +two values zero and one). In this case a numeric value specified in the
  29.536 +field 4 is ignored and may be omitted.\\
  29.537 +\end{tabular}
  29.538 +
  29.539 +Consider the following example of MIP problem:
  29.540 +
  29.541 +\medskip
  29.542 +
  29.543 +\noindent
  29.544 +\hspace{1in} minimize
  29.545 +$$Z = 3 x_1 + 7 x_2 - x_3 + x4$$
  29.546 +\hspace{1in} subject to linear constraints
  29.547 +$$
  29.548 +\begin{array}{c}
  29.549 +\nonumber r_1 = 2   x_1 - \ \ x_2 + \ \ x_3 - \ \;x_4 \\
  29.550 +\nonumber r_2 = \ \;x_1 - \ \;x_2 - 6   x_3 + 4   x_4 \\
  29.551 +\nonumber r_3 = 5   x_1 +   3 x_2 \ \ \ \ \ \ \ \ \ + \ \ x_4 \\
  29.552 +\end{array}
  29.553 +$$
  29.554 +\hspace{1in} and bound of variables
  29.555 +$$
  29.556 +\begin{array}{cccl}
  29.557 +\nonumber 1 \leq r_1 < +\infty && 0 \leq x_1 \leq 4 &{\rm(continuous)}\\
  29.558 +\nonumber 8 \leq r_2 < +\infty && 2 \leq x_2 \leq 5 &{\rm(integer)}   \\
  29.559 +\nonumber 5 \leq r_3 < +\infty && 0 \leq x_3 \leq 1 &{\rm(integer)}   \\
  29.560 +\nonumber                      && 3 \leq x_4 \leq 8 &{\rm(continuous)}\\
  29.561 +\end{array}
  29.562 +$$
  29.563 +
  29.564 +The corresponding MPS file may look like the following:
  29.565 +
  29.566 +\begin{verbatim}
  29.567 +NAME          SAMP1
  29.568 +ROWS
  29.569 + N  Z
  29.570 + G  R1
  29.571 + G  R2
  29.572 + G  R3
  29.573 +COLUMNS
  29.574 +    X1        R1                2.0    R2                 1.0
  29.575 +    X1        R3                5.0    Z                  3.0
  29.576 +    MARK0001  'MARKER'                 'INTORG'
  29.577 +    X2        R1               -1.0    R2                -1.0
  29.578 +    X2        R3                3.0    Z                  7.0
  29.579 +    X3        R1                1.0    R2                -6.0
  29.580 +    X3        Z                -1.0
  29.581 +    MARK0002  'MARKER'                 'INTEND'
  29.582 +    X4        R1               -1.0    R2                 4.0
  29.583 +    X4        R3                1.0    Z                  1.0
  29.584 +RHS
  29.585 +    RHS1      R1                1.0
  29.586 +    RHS1      R2                8.0
  29.587 +    RHS1      R3                5.0
  29.588 +BOUNDS
  29.589 + UP BND1      X1                4.0
  29.590 + LO BND1      X2                2.0
  29.591 + UP BND1      X2                5.0
  29.592 + UP BND1      X3                1.0
  29.593 + LO BND1      X4                3.0
  29.594 + UP BND1      X4                8.0
  29.595 +ENDATA
  29.596 +\end{verbatim}
  29.597 +
  29.598 +The same example may be coded without INTORG/INTEND markers using the
  29.599 +bound type UI for the variable $x_2$ and the bound type BV for the
  29.600 +variable $x_3$:
  29.601 +
  29.602 +\begin{verbatim}
  29.603 +NAME          SAMP2
  29.604 +ROWS
  29.605 + N  Z
  29.606 + G  R1
  29.607 + G  R2
  29.608 + G  R3
  29.609 +COLUMNS
  29.610 +    X1        R1                2.0    R2                 1.0
  29.611 +    X1        R3                5.0    Z                  3.0
  29.612 +    X2        R1               -1.0    R2                -1.0
  29.613 +    X2        R3                3.0    Z                  7.0
  29.614 +    X3        R1                1.0    R2                -6.0
  29.615 +    X3        Z                -1.0
  29.616 +    X4        R1               -1.0    R2                 4.0
  29.617 +    X4        R3                1.0    Z                  1.0
  29.618 +RHS
  29.619 +    RHS1      R1                1.0
  29.620 +    RHS1      R2                8.0
  29.621 +    RHS1      R3                5.0
  29.622 +BOUNDS
  29.623 + UP BND1      X1                4.0
  29.624 + LO BND1      X2                2.0
  29.625 + UI BND1      X2                5.0
  29.626 + BV BND1      X3
  29.627 + LO BND1      X4                3.0
  29.628 + UP BND1      X4                8.0
  29.629 +ENDATA
  29.630 +\end{verbatim}
  29.631 +
  29.632 +%\section{Specifying predefined basis}
  29.633 +%\label{secbas}
  29.634 +%
  29.635 +%The MPS format can also be used to specify some predefined basis for an
  29.636 +%LP problem, i.e. to specify which rows and columns are basic and which
  29.637 +%are non-basic.
  29.638 +%
  29.639 +%The order of a basis file in the MPS format is:
  29.640 +%
  29.641 +%$\bullet$ NAME indicator card;
  29.642 +%
  29.643 +%$\bullet$ data cards (can appear in arbitrary order);
  29.644 +%
  29.645 +%$\bullet$ ENDATA indicator card.
  29.646 +%
  29.647 +%Each data card specifies either a pair "basic column---non-basic row"
  29.648 +%or a non-basic column. All the data cards have the following format.
  29.649 +%
  29.650 +%`\verb|XL|' in the field 1 means that a column, whose name is given in
  29.651 +%the field 2, is basic, and a row, whose name is given in the field 3,
  29.652 +%is non-basic and placed on its lower bound.
  29.653 +%
  29.654 +%`\verb|XU|' in the field 1 means that a column, whose name is given in
  29.655 +%the field 2, is basic, and a row, whose name is given in the field 3,
  29.656 +%is non-basic and placed on its upper bound.
  29.657 +%
  29.658 +%`\verb|LL|' in the field 1 means that a column, whose name is given in
  29.659 +%the field 3, is non-basic and placed on its lower bound.
  29.660 +%
  29.661 +%`\verb|UL|' in the field 1 means that a column, whose name is given in
  29.662 +%the field 3, is non-basic and placed on its upper bound.
  29.663 +%
  29.664 +%The field 2 contains a column name.
  29.665 +%
  29.666 +%If the indicator given in the field 1 is `\verb|XL|' or `\verb|XU|',
  29.667 +%the field 3 contains a row name. Otherwise, if the indicator is
  29.668 +%`\verb|LL|' or `\verb|UL|', the field 3 is not used and should be
  29.669 +%empty.
  29.670 +%
  29.671 +%The field 4, 5, and 6 are not used and should be empty.
  29.672 +%
  29.673 +%A basis file in the MPS format acts like a patch: it doesn't specify
  29.674 +%a basis completely, instead that it is just shows in what a given basis
  29.675 +%differs from the "standard" basis, where all rows (auxiliary variables)
  29.676 +%are assumed to be basic and all columns (structural variables) are
  29.677 +%assumed to be non-basic.
  29.678 +%
  29.679 +%As an example here is a basis file that specifies an optimal basis
  29.680 +%for the example LP problem given in Section \ref{secmpsex},
  29.681 +%Page \pageref{secmpsex}:
  29.682 +%
  29.683 +%\pagebreak
  29.684 +%
  29.685 +%\begin{verbatim}
  29.686 +%*000000001111111111222222222233333333334444444444555555555566
  29.687 +%*234567890123456789012345678901234567890123456789012345678901
  29.688 +%NAME          PLAN
  29.689 +% XL BIN2      YIELD
  29.690 +% XL BIN3      FE
  29.691 +% XL BIN4      MN
  29.692 +% XL ALUM      AL
  29.693 +% XL SILICON   SI
  29.694 +% LL BIN1
  29.695 +% LL BIN5
  29.696 +%ENDATA
  29.697 +%\end{verbatim}
  29.698 +
  29.699 +%* eof *%
    30.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    30.2 +++ b/deps/glpk/doc/glpk09.tex	Sun Nov 06 20:59:10 2011 +0100
    30.3 @@ -0,0 +1,413 @@
    30.4 +%* glpk09.tex *%
    30.5 +
    30.6 +\chapter{CPLEX LP Format}
    30.7 +\label{chacplex}
    30.8 +
    30.9 +\section{Prelude}
   30.10 +
   30.11 +The CPLEX LP format\footnote{The CPLEX LP format was developed in
   30.12 +the end of 1980's by CPLEX Optimization, Inc. as an input format for
   30.13 +the CPLEX linear programming system. Although the CPLEX LP format is
   30.14 +not as widely used as the MPS format, being row-oriented it is more
   30.15 +convenient for coding mathematical programming models by human. This
   30.16 +appendix describes only the features of the CPLEX LP format which are
   30.17 +implemented in the GLPK package.} is intended for coding LP/MIP problem
   30.18 +data. It is a row-oriented format that assumes the formulation of LP/MIP
   30.19 +problem (1.1)---(1.3) (see Section \ref{seclp}, page \pageref{seclp}).
   30.20 +
   30.21 +CPLEX LP file is a plain text file written in CPLEX LP format. Each text
   30.22 +line of this file may contain up to 255 characters\footnote{GLPK allows
   30.23 +text lines of arbitrary length.}. Blank lines are ignored. If a line
   30.24 +contains the backslash character ($\backslash$), this character and
   30.25 +everything that follows it until the end of line are considered as a
   30.26 +comment and also ignored.
   30.27 +
   30.28 +An LP file is coded by the user using the following elements:
   30.29 +
   30.30 +$\bullet$ keywords;
   30.31 +
   30.32 +$\bullet$ symbolic names;
   30.33 +
   30.34 +$\bullet$ numeric constants;
   30.35 +
   30.36 +$\bullet$ delimiters;
   30.37 +
   30.38 +$\bullet$ blanks.
   30.39 +
   30.40 +\newpage
   30.41 +
   30.42 +{\it Keywords} which may be used in the LP file are the following:
   30.43 +
   30.44 +\begin{verbatim}
   30.45 +      minimize        minimum        min
   30.46 +      maximize        maximum        max
   30.47 +      subject to      such that      s.t.      st.      st
   30.48 +      bounds          bound
   30.49 +      general         generals       gen
   30.50 +      integer         integers       int
   30.51 +      binary          binaries       bin
   30.52 +      infinity        inf
   30.53 +      free
   30.54 +      end
   30.55 +\end{verbatim}
   30.56 +
   30.57 +\noindent
   30.58 +All the keywords are case insensitive. Keywords given above on the same
   30.59 +line are equivalent. Any keyword (except \verb|infinity|, \verb|inf|,
   30.60 +and \verb|free|) being used in the LP file must start at the beginning
   30.61 +of a text line.
   30.62 +
   30.63 +{\it Symbolic names} are used to identify the objective function,
   30.64 +constraints (rows), and variables (columns). All symbolic names are case
   30.65 +sensitive and may contain up to 16 alphanumeric characters\footnote{GLPK
   30.66 +allows symbolic names having up to 255 characters.} (\verb|a|, \dots,
   30.67 +\verb|z|, \verb|A|, \dots, \verb|Z|, \verb|0|, \dots, \verb|9|) as well
   30.68 +as the following characters:
   30.69 +
   30.70 +\begin{verbatim}
   30.71 +!  "  #  $  %  &  (  )  /  ,  .  ;  ?  @  _  `  '  {  }  |  ~
   30.72 +\end{verbatim}
   30.73 +
   30.74 +\noindent
   30.75 +with exception that no symbolic name can begin with a digit or a period.
   30.76 +
   30.77 +{\it Numeric constants} are used to denote constraint and objective
   30.78 +coefficients, right-hand sides of constraints, and bounds of variables.
   30.79 +They are coded in the standard form $xx$\verb|E|$syy$, where $xx$ is
   30.80 +a real number with optional decimal point, $s$ is a sign (\verb|+| or
   30.81 +\verb|-|), $yy$ is an integer decimal exponent. Numeric constants may
   30.82 +contain arbitrary number of characters. The exponent part is optional.
   30.83 +The letter `\verb|E|' can be coded as `\verb|e|'. If the sign $s$ is
   30.84 +omitted, plus is assumed.
   30.85 +
   30.86 +{\it Delimiters} that may be used in the LP file are the following:
   30.87 +
   30.88 +\begin{verbatim}
   30.89 +      :
   30.90 +      +
   30.91 +      -
   30.92 +      <   <=   =<
   30.93 +      >   >=   =>
   30.94 +      =
   30.95 +\end{verbatim}
   30.96 +
   30.97 +\noindent
   30.98 +Delimiters given above on the same line are equivalent. The meaning of
   30.99 +the delimiters will be explained below.
  30.100 +
  30.101 +{\it Blanks} are non-significant characters. They may be used freely to
  30.102 +improve readability of the LP file. Besides, blanks should be used to
  30.103 +separate elements from each other if there is no other way to do that
  30.104 +(for example, to separate a keyword from a following symbolic name).
  30.105 +
  30.106 +The order of an LP file is:
  30.107 +
  30.108 +$\bullet$ objective function definition;
  30.109 +
  30.110 +$\bullet$ constraints section;
  30.111 +
  30.112 +$\bullet$ bounds section;
  30.113 +
  30.114 +$\bullet$ general, integer, and binary sections (can appear in arbitrary
  30.115 +order);
  30.116 +
  30.117 +$\bullet$ end keyword.
  30.118 +
  30.119 +These components are discussed in following sections.
  30.120 +
  30.121 +\section{Objective function definition}
  30.122 +
  30.123 +The objective function definition must appear first in the LP file. It
  30.124 +defines the objective function and specifies the optimization direction.
  30.125 +
  30.126 +The objective function definition has the following form:
  30.127 +$$
  30.128 +\left\{
  30.129 +\begin{array}{@{}c@{}}
  30.130 +{\tt minimize} \\ {\tt maximize}
  30.131 +\end{array}
  30.132 +\right\}\ f\ {\tt :}\ s\ c\ x\ s\ c\ x\ \dots\ s\ c\ x
  30.133 +$$
  30.134 +where $f$ is a symbolic name of the objective function, $s$ is a sign
  30.135 +\verb|+| or \verb|-|, $c$ is a numeric constant that denotes an
  30.136 +objective coefficient, $x$ is a symbolic name of a variable.
  30.137 +
  30.138 +If necessary, the objective function definition can be continued on as
  30.139 +many text lines as desired.
  30.140 +
  30.141 +The name of the objective function is optional and may be omitted
  30.142 +(together with the semicolon that follows it). In this case the default
  30.143 +name `\verb|obj|' is assigned to the objective function.
  30.144 +
  30.145 +If the very first sign $s$ is omitted, the sign plus is assumed. Other
  30.146 +signs cannot be omitted.
  30.147 +
  30.148 +If some objective coefficient $c$ is omitted, 1 is assumed.
  30.149 +
  30.150 +Symbolic names $x$ used to denote variables are recognized by context
  30.151 +and therefore needn't to be declared somewhere else.
  30.152 +
  30.153 +Here is an example of the objective function definition:
  30.154 +
  30.155 +\begin{verbatim}
  30.156 +   Minimize Z : - x1 + 2 x2 - 3.5 x3 + 4.997e3x(4) + x5 + x6 +
  30.157 +      x7 - .01x8
  30.158 +\end{verbatim}
  30.159 +
  30.160 +\section{Constraints section}
  30.161 +
  30.162 +The constraints section must follow the objective function definition.
  30.163 +It defines a system of equality and/or inequality constraints.
  30.164 +
  30.165 +The constraint section has the following form:
  30.166 +
  30.167 +\begin{center}
  30.168 +\begin{tabular}{l}
  30.169 +\verb|subject to| \\
  30.170 +{\it constraint}$_1$ \\
  30.171 +{\it constraint}$_2$ \\
  30.172 +\hspace{20pt}\dots \\
  30.173 +{\it constraint}$_m$ \\
  30.174 +\end{tabular}
  30.175 +\end{center}
  30.176 +
  30.177 +\noindent where {\it constraint}$_i, i=1,\dots,m,$ is a particular
  30.178 +constraint definition.
  30.179 +
  30.180 +Each constraint definition can be continued on as many text lines as
  30.181 +desired. However, each constraint definition must begin on a new line
  30.182 +except the very first constraint definition which can begin on the same
  30.183 +line as the keyword `\verb|subject to|'.
  30.184 +
  30.185 +Constraint definitions have the following form:
  30.186 +$$
  30.187 +r\ {\tt:}\ s\ c\ x\ s\ c\ x\ \dots\ s\ c\ x
  30.188 +\ \left\{
  30.189 +\begin{array}{@{}c@{}}
  30.190 +\mbox{\tt<=} \\ \mbox{\tt>=} \\ \mbox{\tt=}
  30.191 +\end{array}
  30.192 +\right\}\ b
  30.193 +$$
  30.194 +where $r$ is a symbolic name of a constraint, $s$ is a sign \verb|+| or
  30.195 +\verb|-|, $c$ is a numeric constant that denotes a constraint
  30.196 +coefficient, $x$ is a symbolic name of a variable, $b$ is a right-hand
  30.197 +side.
  30.198 +
  30.199 +The name $r$ of a constraint (which is the name of the corresponding
  30.200 +auxiliary variable) is optional and may be omitted (together with the
  30.201 +semicolon that follows it). In this case the default names like
  30.202 +`\verb|r.nnn|' are assigned to unnamed constraints.
  30.203 +
  30.204 +The linear form $s\ c\ x\ s\ c\ x\ \dots\ s\ c\ x$ in the left-hand
  30.205 +side of a constraint definition has exactly the same meaning as in the
  30.206 +case of the objective function definition (see above).
  30.207 +
  30.208 +After the linear form one of the following delimiters that indicate
  30.209 +the constraint sense must be specified:
  30.210 +
  30.211 +\verb|<=| \ means `less than or equal to'
  30.212 +
  30.213 +\verb|>=| \ means `greater than or equal to'
  30.214 +
  30.215 +\verb|= | \ means `equal to'
  30.216 +
  30.217 +The right hand side $b$ is a numeric constant with an optional sign.
  30.218 +
  30.219 +Here is an example of the constraints section:
  30.220 +
  30.221 +\begin{verbatim}
  30.222 +   Subject To
  30.223 +      one: y1 + 3 a1 - a2 - b >= 1.5
  30.224 +      y2 + 2 a3 + 2
  30.225 +         a4 - b >= -1.5
  30.226 +      two : y4 + 3 a1 + 4 a5 - b <= +1
  30.227 +      .20y5 + 5 a2 - b = 0
  30.228 +      1.7 y6 - a6 + 5 a777 - b >= 1
  30.229 +\end{verbatim}
  30.230 +
  30.231 +(Should note that it is impossible to express ranged constraints in the
  30.232 +CPLEX LP format. Each a ranged constraint can be coded as two
  30.233 +constraints with identical linear forms in the left-hand side, one of
  30.234 +which specifies a lower bound and other does an upper one of the
  30.235 +original ranged constraint.)
  30.236 +
  30.237 +\section{Bounds section}
  30.238 +
  30.239 +The bounds section is intended to define bounds of variables. This
  30.240 +section is optional; if it is specified, it must follow the constraints
  30.241 +section. If the bound section is omitted, all variables are assumed to
  30.242 +be non-negative (i.e. that they have zero lower bound and no upper
  30.243 +bound).
  30.244 +
  30.245 +The bounds section has the following form:
  30.246 +
  30.247 +\begin{center}
  30.248 +\begin{tabular}{l}
  30.249 +\verb|bounds| \\
  30.250 +{\it definition}$_1$ \\
  30.251 +{\it definition}$_2$ \\
  30.252 +\hspace{20pt}\dots \\
  30.253 +{\it definition}$_p$ \\
  30.254 +\end{tabular}
  30.255 +\end{center}
  30.256 +
  30.257 +\noindent
  30.258 +where {\it definition}$_k, k=1,\dots,p,$ is a particular bound
  30.259 +definition.
  30.260 +
  30.261 +Each bound definition must begin on a new line\footnote{The GLPK
  30.262 +implementation allows several bound definitions to be placed on the same
  30.263 +line.} except the very first bound definition which can begin on the
  30.264 +same line as the keyword `\verb|bounds|'.
  30.265 +
  30.266 +Syntactically constraint definitions can have one of the following six
  30.267 +forms:
  30.268 +
  30.269 +\begin{center}
  30.270 +\begin{tabular}{ll}
  30.271 +$x$ \verb|>=| $l$ &              specifies a lower bound \\
  30.272 +$l$ \verb|<=| $x$ &              specifies a lower bound \\
  30.273 +$x$ \verb|<=| $u$ &              specifies an upper bound \\
  30.274 +$l$ \verb|<=| $x$ \verb|<=| $u$ &specifies both lower and upper bounds\\
  30.275 +$x$ \verb|=| $t$                &specifies a fixed value \\
  30.276 +$x$ \verb|free|                 &specifies free variable
  30.277 +\end{tabular}
  30.278 +\end{center}
  30.279 +
  30.280 +\noindent
  30.281 +where $x$ is a symbolic name of a variable, $l$ is a numeric constant
  30.282 +with an optional sign that defines a lower bound of the variable or
  30.283 +\verb|-inf| that means that the variable has no lower bound, $u$ is a
  30.284 +numeric constant with an optional sign that defines an upper bound of
  30.285 +the variable or \verb|+inf| that means that the variable has no upper
  30.286 +bound, $t$ is a numeric constant with an optional sign that defines a
  30.287 +fixed value of the variable.
  30.288 +
  30.289 +By default all variables are non-negative, i.e. have zero lower bound
  30.290 +and no upper bound. Therefore definitions of these default bounds can be
  30.291 +omitted in the bounds section.
  30.292 +
  30.293 +Here is an example of the bounds section:
  30.294 +
  30.295 +\begin{verbatim}
  30.296 +   Bounds
  30.297 +      -inf <= a1 <= 100
  30.298 +      -100 <= a2
  30.299 +      b <= 100
  30.300 +      x2 = +123.456
  30.301 +      x3 free
  30.302 +\end{verbatim}
  30.303 +
  30.304 +\section{General, integer, and binary sections}
  30.305 +
  30.306 +The general, integer, and binary sections are intended to define
  30.307 +some variables as integer or binary. All these sections are optional
  30.308 +and needed only in case of MIP problems. If they are specified, they
  30.309 +must follow the bounds section or, if the latter is omitted, the
  30.310 +constraints section.
  30.311 +
  30.312 +All the general, integer, and binary sections have the same form as
  30.313 +follows:
  30.314 +
  30.315 +\begin{center}
  30.316 +\begin{tabular}{l}
  30.317 +$
  30.318 +\left\{
  30.319 +\begin{array}{@{}l@{}}
  30.320 +\verb|general| \\
  30.321 +\verb|integer| \\
  30.322 +\verb|binary | \\
  30.323 +\end{array}
  30.324 +\right\}
  30.325 +$ \\
  30.326 +\hspace{10pt}$x_1$ \\
  30.327 +\hspace{10pt}$x_2$ \\
  30.328 +\hspace{10pt}\dots \\
  30.329 +\hspace{10pt}$x_q$ \\
  30.330 +\end{tabular}
  30.331 +\end{center}
  30.332 +
  30.333 +\noindent
  30.334 +where $x_k$ is a symbolic name of variable, $k=1,\dots,q$.
  30.335 +
  30.336 +Each symbolic name must begin on a new line\footnote{The GLPK
  30.337 +implementation allows several symbolic names to be placed on the same
  30.338 +line.} except the very first symbolic name which can begin on the same
  30.339 +line as the keyword `\verb|general|', `\verb|integer|', or
  30.340 +`\verb|binary|'.
  30.341 +
  30.342 +If a variable appears in the general or the integer section, it is
  30.343 +assumed to be general integer variable. If a variable appears in the
  30.344 +binary section, it is assumed to be binary variable, i.e. an integer
  30.345 +variable whose lower bound is zero and upper bound is one. (Note that
  30.346 +if bounds of a variable are specified in the bounds section and then
  30.347 +the variable appears in the binary section, its previously specified
  30.348 +bounds are ignored.)
  30.349 +
  30.350 +Here is an example of the integer section:
  30.351 +
  30.352 +\begin{verbatim}
  30.353 +   Integer
  30.354 +      z12
  30.355 +      z22
  30.356 +      z35
  30.357 +\end{verbatim}
  30.358 +
  30.359 +\section{End keyword}
  30.360 +
  30.361 +The keyword `\verb|end|' is intended to end the LP file. It must begin
  30.362 +on a separate line and no other elements (except comments and blank
  30.363 +lines) must follow it. Although this keyword is optional, it is strongly
  30.364 +recommended to include it in the LP file.
  30.365 +
  30.366 +\section{Example of CPLEX LP file}
  30.367 +
  30.368 +Here is a complete example of CPLEX LP file that corresponds to the
  30.369 +example given in Section \ref{secmpsex}, page \pageref{secmpsex}.
  30.370 +
  30.371 +{\footnotesize
  30.372 +\begin{verbatim}
  30.373 +\* plan.lp *\
  30.374 +
  30.375 +Minimize
  30.376 +   value: .03 bin1 + .08 bin2 + .17 bin3 + .12 bin4 + .15 bin5 +
  30.377 +          .21 alum + .38 silicon
  30.378 +
  30.379 +Subject To
  30.380 +   yield:     bin1 +     bin2 +     bin3 +     bin4 +     bin5 +
  30.381 +              alum +     silicon                                 =  2000
  30.382 +
  30.383 +   fe:    .15 bin1 + .04 bin2 + .02 bin3 + .04 bin4 + .02 bin5 +
  30.384 +          .01 alum + .03 silicon                                 <=   60
  30.385 +
  30.386 +   cu:    .03 bin1 + .05 bin2 + .08 bin3 + .02 bin4 + .06 bin5 +
  30.387 +          .01 alum                                               <=  100
  30.388 +
  30.389 +   mn:    .02 bin1 + .04 bin2 + .01 bin3 + .02 bin4 + .02 bin5   <=   40
  30.390 +
  30.391 +   mg:    .02 bin1 + .03 bin2                       + .01 bin5   <=   30
  30.392 +
  30.393 +   al:    .70 bin1 + .75 bin2 + .80 bin3 + .75 bin4 + .80 bin5 +
  30.394 +          .97 alum                                               >= 1500
  30.395 +
  30.396 +   si1:   .02 bin1 + .06 bin2 + .08 bin3 + .12 bin4 + .02 bin5 +
  30.397 +          .01 alum + .97 silicon                                 >=  250
  30.398 +
  30.399 +   si2:   .02 bin1 + .06 bin2 + .08 bin3 + .12 bin4 + .02 bin5 +
  30.400 +          .01 alum + .97 silicon                                 <=  300
  30.401 +
  30.402 +Bounds
  30.403 +          bin1 <=  200
  30.404 +          bin2 <= 2500
  30.405 +   400 <= bin3 <=  800
  30.406 +   100 <= bin4 <=  700
  30.407 +          bin5 <= 1500
  30.408 +
  30.409 +End
  30.410 +
  30.411 +\* eof *\
  30.412 +\end{verbatim}
  30.413 +
  30.414 +}
  30.415 +
  30.416 +%* eof *%
    31.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    31.2 +++ b/deps/glpk/doc/glpk10.tex	Sun Nov 06 20:59:10 2011 +0100
    31.3 @@ -0,0 +1,210 @@
    31.4 +%* glpk10.tex *%
    31.5 +
    31.6 +\chapter{Stand-alone LP/MIP Solver}
    31.7 +\label{chaglpsol}
    31.8 +
    31.9 +The GLPK package includes the program \verb|glpsol|, which is a
   31.10 +stand-alone LP/MIP solver. This program can be invoked from the command
   31.11 +line of from the shell to read LP/MIP problem data in any format
   31.12 +supported by GLPK, solve the problem, and write the problem solution
   31.13 +obtained to an output text file.
   31.14 +
   31.15 +\subsubsection*{Usage}
   31.16 +
   31.17 +\noindent
   31.18 +\verb|glpsol| [{\it options\dots}] [{\it filename}]
   31.19 +
   31.20 +\subsubsection*{General options}
   31.21 +
   31.22 +\noindent
   31.23 +\begin{tabular}{@{}p{30mm}p{92.3mm}@{}}
   31.24 +\verb|--mps|      &  read LP/MIP problem in fixed MPS format \\
   31.25 +\verb|--freemps|  &  read LP/MIP problem in free MPS format (default)\\
   31.26 +\verb|--lp|       &  read LP/MIP problem in CPLEX LP format \\
   31.27 +\verb|--glp|      &  read LP/MIP problem in GLPK format \\
   31.28 +\verb|--math|     &  read LP/MIP model written in GNU MathProg modeling
   31.29 +                     language \\
   31.30 +\multicolumn{2}{@{}l}{{\tt -m} {\it filename}, {\tt --model}
   31.31 +{\it filename}} \\
   31.32 +                  &  read model section and optional data section from
   31.33 +                     {\it filename} (the same as \verb|--math|) \\
   31.34 +\multicolumn{2}{@{}l}{{\tt -d} {\it filename}, {\tt --data}
   31.35 +{\it filename}} \\
   31.36 +                  &  read data section from {\it filename}
   31.37 +                     (for \verb|--math| only); if model file also has
   31.38 +                     data section, that section is ignored \\
   31.39 +\multicolumn{2}{@{}l}{{\tt -y} {\it filename}, {\tt --display}
   31.40 +{\it filename}} \\
   31.41 +                  &  send display output to {\it filename}
   31.42 +                     (for \verb|--math| only); by default the output is
   31.43 +                     sent to \verb|stdout| \\
   31.44 +\end{tabular}
   31.45 +
   31.46 +\noindent
   31.47 +\begin{tabular}{@{}p{30mm}p{92.3mm}@{}}
   31.48 +\verb|--seed| {\it value}
   31.49 +                  &  initialize pseudo-random number generator used in
   31.50 +                     MathProg model with specified seed (any integer);
   31.51 +                     if the seed value is specified as \verb|?|
   31.52 +                     (question mark), some random seed will be used\\
   31.53 +\verb|--mincost|  &  read min-cost flow problem in DIMACS format\\
   31.54 +\verb|--maxflow|  &  read maximum flow problem in DIMACS format\\
   31.55 +\verb|--simplex|  &  use simplex method (default) \\
   31.56 +\verb|--interior| &  use interior point method (for pure LP only) \\
   31.57 +\multicolumn{2}{@{}l}{{\tt -r} {\it filename}, {\tt --read}
   31.58 +{\it filename}} \\
   31.59 +                  &  read solution from {\it filename} rather to find
   31.60 +                     it with the solver \\
   31.61 +\verb|--min|      &  minimization \\
   31.62 +\verb|--max|      &  maximization \\
   31.63 +\verb|--scale|    &  scale problem (default) \\
   31.64 +\verb|--noscale|  &  do not scale problem \\
   31.65 +\multicolumn{2}{@{}l}{{\tt -o} {\it filename}, {\tt --output}
   31.66 +{\it filename}} \\
   31.67 +                  &  write solution to {\it filename} in printable
   31.68 +                     format \\
   31.69 +\multicolumn{2}{@{}l}{{\tt -w} {\it filename}, {\tt --write}
   31.70 +{\it filename}} \\
   31.71 +                  &  write solution to {\it filename} in plain text
   31.72 +                     format \\
   31.73 +\multicolumn{2}{@{}l}{{\tt --ranges} {\it filename}} \\
   31.74 +                  &  write sensitivity analysis report to {\it filename}
   31.75 +                     in printable format (simplex only) \\
   31.76 +\verb|--tmlim| {\it nnn}
   31.77 +                  &  limit solution time to {\it nnn} seconds
   31.78 +                     (\verb|--tmlim 0| allows obtaining solution at
   31.79 +                     initial point) \\
   31.80 +\verb|--memlim| {\it nnn}
   31.81 +                  &  limit available memory to {\it nnn} megabytes \\
   31.82 +\verb|--check|    &  do not solve problem, check input data only \\
   31.83 +\verb|--name| {\it probname}
   31.84 +                  &  change problem name to {\it probname} \\
   31.85 +\verb|--wmps| {\it filename}
   31.86 +                  &  write problem to {\it filename} in fixed MPS
   31.87 +                     format \\
   31.88 +\multicolumn{2}{@{}l}{{\tt --wfreemps} {\it filename}} \\
   31.89 +                  &  write problem to {\it filename} in free MPS
   31.90 +                     format \\
   31.91 +\verb|--wlp| {\it filename}
   31.92 +                  &  write problem to {\it filename} in CPLEX LP
   31.93 +                     format \\
   31.94 +\verb|--wglp| {\it filename}
   31.95 +                  &  write problem to {\it filename} in GLPK format \\
   31.96 +\verb|--log| {\it filename}
   31.97 +                  &  write copy of terminal output to {\it filename} \\
   31.98 +\verb|-h|, \verb|--help|
   31.99 +                  &  display this help information and exit \\
  31.100 +\verb|-v|, \verb|--version|
  31.101 +                  &  display program version and exit \\
  31.102 +\end{tabular}
  31.103 +
  31.104 +\subsection*{LP basis factorization options}
  31.105 +
  31.106 +\noindent
  31.107 +\begin{tabular}{@{}p{30mm}p{92.3mm}@{}}
  31.108 +\verb|--luf|      &  LU + Forrest--Tomlin update \\
  31.109 +                  &  (faster, less stable; default) \\
  31.110 +\verb|--cbg|      &  LU + Schur complement + Bartels--Golub update \\
  31.111 +                  &  (slower, more stable) \\
  31.112 +\verb|--cgr|      &  LU + Schur complement + Givens rotation update \\
  31.113 +                  &  (slower, more stable) \\
  31.114 +\end{tabular}
  31.115 +
  31.116 +\subsubsection*{Options specific to the simplex solver}
  31.117 +
  31.118 +\noindent
  31.119 +\begin{tabular}{@{}p{30mm}p{92.3mm}@{}}
  31.120 +\verb|--primal|   &  use primal simplex (default) \\
  31.121 +\verb|--dual|     &  use dual simplex \\
  31.122 +\verb|--std|      &  use standard initial basis of all slacks \\
  31.123 +\verb|--adv|      &  use advanced initial basis (default) \\
  31.124 +\verb|--bib|      &  use Bixby's initial basis\\
  31.125 +\verb|--ini| {\it filename}
  31.126 +                  &  use as initial basis previously saved with
  31.127 +                     \verb|-w| \\
  31.128 +                  & (disables LP presolver) \\
  31.129 +\verb|--steep|    &  use steepest edge technique (default) \\
  31.130 +\verb|--nosteep|  &  use standard ``textbook'' pricing \\
  31.131 +\verb|--relax|    &  use Harris' two-pass ratio test (default) \\
  31.132 +\verb|--norelax|  &  use standard ``textbook'' ratio test \\
  31.133 +\verb|--presol|   &  use LP presolver (default; assumes \verb|--scale|
  31.134 +                     and \verb|--adv|) \\
  31.135 +\verb|--nopresol| &  do not use LP presolver \\
  31.136 +\verb|--exact|    & use simplex method based on exact arithmetic \\
  31.137 +\verb|--xcheck|   & check final basis using exact arithmetic \\
  31.138 +\end{tabular}
  31.139 +
  31.140 +\subsubsection*{Options specific to the interior-point solver}
  31.141 +
  31.142 +\noindent
  31.143 +\begin{tabular}{@{}p{30mm}p{92.3mm}@{}}
  31.144 +\verb|--nord|     &  use natural (original) ordering \\
  31.145 +\verb|--qmd|      &  use quotient minimum degree ordering \\
  31.146 +\verb|--amd|      &  use approximate minimum degree ordering (default)\\
  31.147 +\verb|--symamd|   &  use approximate minimum degree ordering \\
  31.148 +\end{tabular}
  31.149 +
  31.150 +\subsubsection*{Options specific to the MIP solver}
  31.151 +
  31.152 +\noindent
  31.153 +\begin{tabular}{@{}p{30mm}p{92.3mm}@{}}
  31.154 +\verb|--nomip|    &  consider all integer variables as continuous
  31.155 +                     (allows solving MIP as pure LP) \\
  31.156 +\verb|--first|    &  branch on first integer variable \\
  31.157 +\verb|--last|     &  branch on last integer variable \\
  31.158 +\verb|--mostf|    &  branch on most fractional variable \\
  31.159 +\end{tabular}
  31.160 +
  31.161 +\noindent
  31.162 +\begin{tabular}{@{}p{30mm}p{92.3mm}@{}}
  31.163 +\verb|--drtom|    &  branch using heuristic by Driebeck and Tomlin
  31.164 +                     (default) \\
  31.165 +\verb|--pcost|    &  branch using hybrid pseudocost heuristic (may be
  31.166 +                     useful for hard instances) \\
  31.167 +\verb|--dfs|      &  backtrack using depth first search \\
  31.168 +\verb|--bfs|      &  backtrack using breadth first search \\
  31.169 +\verb|--bestp|    &  backtrack using the best projection heuristic
  31.170 +                     (default) \\
  31.171 +\verb|--bestb|    &  backtrack using node with best local bound \\
  31.172 +\verb|--intopt|   &  use MIP presolver (default)\\
  31.173 +\verb|--nointopt| &  do not use MIP presolver\\
  31.174 +\verb|--binarize| &  replace general integer variables by binary ones
  31.175 +                     (assumes \verb|--intopt|)\\
  31.176 +\verb|--fpump|    & apply feasibility pump heuristic\\
  31.177 +\verb|--gomory|   &  generate Gomory's mixed integer cuts\\
  31.178 +\verb|--mir|      &  generate MIR (mixed integer rounding) cuts\\
  31.179 +\verb|--cover|    &  generate mixed cover cuts\\
  31.180 +\verb|--clique|   &  generate clique cuts\\
  31.181 +\verb|--cuts|     &  generate cuts of all classes above (assumes
  31.182 +                     \verb|--intopt|)\\
  31.183 +\verb|--mipgap| {\it tol}
  31.184 +                  & set relative mip gap tolerance to {\it tol}\\
  31.185 +\end{tabular}
  31.186 +
  31.187 +\bigskip
  31.188 +
  31.189 +\noindent
  31.190 +For description of the MPS format see Appendix \ref{champs},
  31.191 +page \pageref{champs}.
  31.192 +
  31.193 +\bigskip
  31.194 +
  31.195 +\noindent
  31.196 +For description of the CPLEX LP format see Appendix \ref{chacplex},
  31.197 +page \pageref{chacplex}.
  31.198 +
  31.199 +\bigskip
  31.200 +
  31.201 +\noindent
  31.202 +For description of the modeling language see the document ``Modeling
  31.203 +Language GNU MathProg: Language Reference'' included in the GLPK
  31.204 +distribution.
  31.205 +
  31.206 +\bigskip
  31.207 +
  31.208 +\noindent
  31.209 +For description of the DIMACS min-cost flow problem format and DIMACS
  31.210 +maximum flow problem format see the document ``GLPK: Graph and Network
  31.211 +Routines'' included in the GLPK distribution.
  31.212 +
  31.213 +%* eof *%
    32.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    32.2 +++ b/deps/glpk/doc/glpk11.tex	Sun Nov 06 20:59:10 2011 +0100
    32.3 @@ -0,0 +1,124 @@
    32.4 +%* glpk11.tex *%
    32.5 +
    32.6 +\begin{footnotesize}
    32.7 +
    32.8 +\chapter{External Software Modules Used In GLPK}
    32.9 +
   32.10 +In the GLPK package there are used some external software modules
   32.11 +listed in this Appendix. Note that these modules are {\it not} part of
   32.12 +GLPK, but are used with GLPK and included in the distribution.
   32.13 +
   32.14 +\section{AMD}
   32.15 +
   32.16 +AMD Version 2.2, Copyright {\copyright} 2007 by Timothy A. Davis,
   32.17 +Patrick R. Amestoy, and Iain S. Duff.  All Rights Reserved.
   32.18 +
   32.19 +\subsection*{Description}
   32.20 +
   32.21 +AMD is a set of routines for pre-ordering sparse matrices prior to
   32.22 +Cholesky or LU factorization, using the approximate minimum degree
   32.23 +ordering algorithm.
   32.24 +
   32.25 +\subsection*{License}
   32.26 +
   32.27 +This library is free software; you can redistribute it and/or
   32.28 +modify it under the terms of the GNU Lesser General Public License
   32.29 +as published by the Free Software Foundation; either version 2.1 of
   32.30 +the License, or (at your option) any later version.
   32.31 +
   32.32 +This library is distributed in the hope that it will be useful,
   32.33 +but WITHOUT ANY WARRANTY; without even the implied warranty of
   32.34 +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   32.35 +Lesser General Public License for more details.
   32.36 +
   32.37 +You should have received a copy of the GNU Lesser General Public
   32.38 +License along with this library; if not, write to the Free Software
   32.39 +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301
   32.40 +USA.
   32.41 +
   32.42 +Permission is hereby granted to use or copy this program under the
   32.43 +terms of the GNU LGPL, provided that the Copyright, this License,
   32.44 +and the Availability of the original version is retained on all
   32.45 +copies.  User documentation of any code that uses this code or any
   32.46 +modified version of this code must cite the Copyright, this License,
   32.47 +the Availability note, and ``Used by permission.''  Permission to
   32.48 +modify the code and to distribute modified code is granted, provided
   32.49 +the Copyright, this License, and the Availability note are retained,
   32.50 +and a notice that the code was modified is included.
   32.51 +
   32.52 +AMD is available under alternate licences; contact T. Davis for
   32.53 +details.
   32.54 +
   32.55 +\subsection*{Availability}
   32.56 +
   32.57 +\verb|http://www.cise.ufl.edu/research/sparse/amd|
   32.58 +
   32.59 +\bigskip
   32.60 +
   32.61 +\noindent
   32.62 +Used by permission.
   32.63 +
   32.64 +\section{COLAMD/SYMAMD}
   32.65 +
   32.66 +COLAMD/SYMAMD Version 2.7, Copyright {\copyright} 1998-2007, Timothy A.
   32.67 +Davis, All Rights Reserved.
   32.68 +
   32.69 +\subsection*{Description}
   32.70 +
   32.71 +\paragraph{colamd:} an approximate minimum degree column ordering
   32.72 +algorithm, for LU factorization of symmetric or unsymmetric matrices,
   32.73 +QR factorization, least squares, interior point methods for linear
   32.74 +programming problems, and other related problems.
   32.75 +
   32.76 +\paragraph{symamd:} an approximate minimum degree ordering algorithm
   32.77 +for Cholesky factorization of symmetric matrices.
   32.78 +
   32.79 +\subsection*{Authors}
   32.80 +
   32.81 +The authors of the code itself are Stefan I. Larimore and Timothy A.
   32.82 +Davis (davis at cise.ufl.edu), University of Florida.  The algorithm
   32.83 +was developed in collaboration with John Gilbert, Xerox PARC, and
   32.84 +Esmond Ng, Oak Ridge National Laboratory.
   32.85 +
   32.86 +\subsection*{License}
   32.87 +
   32.88 +This library is free software; you can redistribute it and/or
   32.89 +modify it under the terms of the GNU Lesser General Public License
   32.90 +as published by the Free Software Foundation; either version 2.1 of
   32.91 +the License, or (at your option) any later version.
   32.92 +
   32.93 +This library is distributed in the hope that it will be useful,
   32.94 +but WITHOUT ANY WARRANTY; without even the implied warranty of
   32.95 +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   32.96 +Lesser General Public License for more details.
   32.97 +
   32.98 +You should have received a copy of the GNU Lesser General Public
   32.99 +License along with this library; if not, write to the Free Software
  32.100 +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301
  32.101 +USA.
  32.102 +
  32.103 +Permission is hereby granted to use or copy this program under the
  32.104 +terms of the GNU LGPL, provided that the Copyright, this License,
  32.105 +and the Availability of the original version is retained on all
  32.106 +copies.  User documentation of any code that uses this code or any
  32.107 +modified version of this code must cite the Copyright, this License,
  32.108 +the Availability note, and ``Used by permission.''  Permission to
  32.109 +modify the code and to distribute modified code is granted, provided
  32.110 +the Copyright, this License, and the Availability note are retained,
  32.111 +and a notice that the code was modified is included.
  32.112 +
  32.113 +COLAMD is also available under alternate licenses, contact T. Davis for
  32.114 +details.
  32.115 +
  32.116 +\subsection*{Availability}
  32.117 +
  32.118 +\verb|http://www.cise.ufl.edu/research/sparse/colamd|
  32.119 +
  32.120 +\bigskip
  32.121 +
  32.122 +\noindent
  32.123 +Used by permission.
  32.124 +
  32.125 +\end{footnotesize}
  32.126 +
  32.127 +%* eof *%
    33.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    33.2 +++ b/deps/glpk/doc/glpk12.tex	Sun Nov 06 20:59:10 2011 +0100
    33.3 @@ -0,0 +1,726 @@
    33.4 +%* glpk12.tex *%
    33.5 +
    33.6 +\begin{footnotesize}
    33.7 +
    33.8 +\chapter*{\sf\bfseries GNU General Public License}
    33.9 +\addcontentsline{toc}{chapter}{GNU General Public License}
   33.10 +
   33.11 +\begin{center}
   33.12 +{\bf Version 3, 29 June 2007}
   33.13 +\end{center}
   33.14 +
   33.15 +\begin{quotation}
   33.16 +\noindent
   33.17 +Copyright {\copyright} 2007 Free Software Foundation, Inc.
   33.18 +\verb|<http://fsf.org/>|
   33.19 +\end{quotation}
   33.20 +
   33.21 +\begin{quotation}
   33.22 +\noindent
   33.23 +Everyone is permitted to copy and distribute verbatim copies
   33.24 +of this license document, but changing it is not allowed.
   33.25 +\end{quotation}
   33.26 +
   33.27 +\section*{Preamble}
   33.28 +
   33.29 +\noindent\indent
   33.30 +  The GNU General Public License is a free, copyleft license for
   33.31 +software and other kinds of works.
   33.32 +
   33.33 +  The licenses for most software and other practical works are designed
   33.34 +to take away your freedom to share and change the works.  By contrast,
   33.35 +the GNU General Public License is intended to guarantee your freedom to
   33.36 +share and change all versions of a program--to make sure it remains free
   33.37 +software for all its users.  We, the Free Software Foundation, use the
   33.38 +GNU General Public License for most of our software; it applies also to
   33.39 +any other work released this way by its authors.  You can apply it to
   33.40 +your programs, too.
   33.41 +
   33.42 +  When we speak of free software, we are referring to freedom, not
   33.43 +price.  Our General Public Licenses are designed to make sure that you
   33.44 +have the freedom to distribute copies of free software (and charge for
   33.45 +them if you wish), that you receive source code or can get it if you
   33.46 +want it, that you can change the software or use pieces of it in new
   33.47 +free programs, and that you know you can do these things.
   33.48 +
   33.49 +  To protect your rights, we need to prevent others from denying you
   33.50 +these rights or asking you to surrender the rights.  Therefore, you have
   33.51 +certain responsibilities if you distribute copies of the software, or if
   33.52 +you modify it: responsibilities to respect the freedom of others.
   33.53 +
   33.54 +  For example, if you distribute copies of such a program, whether
   33.55 +gratis or for a fee, you must pass on to the recipients the same
   33.56 +freedoms that you received.  You must make sure that they, too, receive
   33.57 +or can get the source code.  And you must show them these terms so they
   33.58 +know their rights.
   33.59 +
   33.60 +  Developers that use the GNU GPL protect your rights with two steps:
   33.61 +(1) assert copyright on the software, and (2) offer you this License
   33.62 +giving you legal permission to copy, distribute and/or modify it.
   33.63 +
   33.64 +  For the developers' and authors' protection, the GPL clearly explains
   33.65 +that there is no warranty for this free software.  For both users' and
   33.66 +authors' sake, the GPL requires that modified versions be marked as
   33.67 +changed, so that their problems will not be attributed erroneously to
   33.68 +authors of previous versions.
   33.69 +
   33.70 +  Some devices are designed to deny users access to install or run
   33.71 +modified versions of the software inside them, although the manufacturer
   33.72 +can do so.  This is fundamentally incompatible with the aim of
   33.73 +protecting users' freedom to change the software.  The systematic
   33.74 +pattern of such abuse occurs in the area of products for individuals to
   33.75 +use, which is precisely where it is most unacceptable.  Therefore, we
   33.76 +have designed this version of the GPL to prohibit the practice for those
   33.77 +products.  If such problems arise substantially in other domains, we
   33.78 +stand ready to extend this provision to those domains in future versions
   33.79 +of the GPL, as needed to protect the freedom of users.
   33.80 +
   33.81 +  Finally, every program is threatened constantly by software patents.
   33.82 +States should not allow patents to restrict development and use of
   33.83 +software on general-purpose computers, but in those that do, we wish to
   33.84 +avoid the special danger that patents applied to a free program could
   33.85 +make it effectively proprietary.  To prevent this, the GPL assures that
   33.86 +patents cannot be used to render the program non-free.
   33.87 +
   33.88 +  The precise terms and conditions for copying, distribution and
   33.89 +modification follow.
   33.90 +
   33.91 +\section*{TERMS AND CONDITIONS}
   33.92 +
   33.93 +\subsubsection*{0. Definitions.}
   33.94 +
   33.95 +\noindent\indent
   33.96 +  ``This License'' refers to version 3 of the GNU General Public
   33.97 +License.
   33.98 +
   33.99 +  ``Copyright'' also means copyright-like laws that apply to other kinds
  33.100 +of works, such as semiconductor masks.
  33.101 +
  33.102 +  ``The Program'' refers to any copyrightable work licensed under this
  33.103 +License.  Each licensee is addressed as ``you''.  ``Licensees'' and
  33.104 +``recipients'' may be individuals or organizations.
  33.105 +
  33.106 +  To ``modify'' a work means to copy from or adapt all or part of the
  33.107 +work in a fashion requiring copyright permission, other than the making
  33.108 +of an exact copy.  The resulting work is called a ``modified version''
  33.109 +of the earlier work or a work ``based on'' the earlier work.
  33.110 +
  33.111 +  A ``covered work'' means either the unmodified Program or a work based
  33.112 +on the Program.
  33.113 +
  33.114 +  To ``propagate'' a work means to do anything with it that, without
  33.115 +permission, would make you directly or secondarily liable for
  33.116 +infringement under applicable copyright law, except executing it on a
  33.117 +computer or modifying a private copy.  Propagation includes copying,
  33.118 +distribution (with or without modification), making available to the
  33.119 +public, and in some countries other activities as well.
  33.120 +
  33.121 +  To ``convey'' a work means any kind of propagation that enables other
  33.122 +parties to make or receive copies.  Mere interaction with a user through
  33.123 +a computer network, with no transfer of a copy, is not conveying.
  33.124 +
  33.125 +  An interactive user interface displays ``Appropriate Legal Notices''
  33.126 +to the extent that it includes a convenient and prominently visible
  33.127 +feature that (1) displays an appropriate copyright notice, and (2)
  33.128 +tells the user that there is no warranty for the work (except to the
  33.129 +extent that warranties are provided), that licensees may convey the
  33.130 +work under this License, and how to view a copy of this License.  If
  33.131 +the interface presents a list of user commands or options, such as a
  33.132 +menu, a prominent item in the list meets this criterion.
  33.133 +
  33.134 +\subsubsection*{1. Source Code.}
  33.135 +
  33.136 +\noindent\indent
  33.137 +  The ``source code'' for a work means the preferred form of the work
  33.138 +for making modifications to it.  ``Object code'' means any non-source
  33.139 +form of a work.
  33.140 +
  33.141 +  A ``Standard Interface'' means an interface that either is an official
  33.142 +standard defined by a recognized standards body, or, in the case of
  33.143 +interfaces specified for a particular programming language, one that
  33.144 +is widely used among developers working in that language.
  33.145 +
  33.146 +  The ``System Libraries'' of an executable work include anything, other
  33.147 +than the work as a whole, that (a) is included in the normal form of
  33.148 +packaging a Major Component, but which is not part of that Major
  33.149 +Component, and (b) serves only to enable use of the work with that
  33.150 +Major Component, or to implement a Standard Interface for which an
  33.151 +implementation is available to the public in source code form.  A
  33.152 +``Major Component'', in this context, means a major essential component
  33.153 +(kernel, window system, and so on) of the specific operating system
  33.154 +(if any) on which the executable work runs, or a compiler used to
  33.155 +produce the work, or an object code interpreter used to run it.
  33.156 +
  33.157 +  The ``Corresponding Source'' for a work in object code form means all
  33.158 +the source code needed to generate, install, and (for an executable
  33.159 +work) run the object code and to modify the work, including scripts to
  33.160 +control those activities.  However, it does not include the work's
  33.161 +System Libraries, or general-purpose tools or generally available free
  33.162 +programs which are used unmodified in performing those activities but
  33.163 +which are not part of the work.  For example, Corresponding Source
  33.164 +includes interface definition files associated with source files for
  33.165 +the work, and the source code for shared libraries and dynamically
  33.166 +linked subprograms that the work is specifically designed to require,
  33.167 +such as by intimate data communication or control flow between those
  33.168 +subprograms and other parts of the work.
  33.169 +
  33.170 +  The Corresponding Source need not include anything that users
  33.171 +can regenerate automatically from other parts of the Corresponding
  33.172 +Source.
  33.173 +
  33.174 +  The Corresponding Source for a work in source code form is that
  33.175 +same work.
  33.176 +
  33.177 +\subsubsection*{2. Basic Permissions.}
  33.178 +
  33.179 +\noindent\indent
  33.180 +  All rights granted under this License are granted for the term of
  33.181 +copyright on the Program, and are irrevocable provided the stated
  33.182 +conditions are met.  This License explicitly affirms your unlimited
  33.183 +permission to run the unmodified Program.  The output from running a
  33.184 +covered work is covered by this License only if the output, given its
  33.185 +content, constitutes a covered work.  This License acknowledges your
  33.186 +rights of fair use or other equivalent, as provided by copyright law.
  33.187 +
  33.188 +  You may make, run and propagate covered works that you do not
  33.189 +convey, without conditions so long as your license otherwise remains
  33.190 +in force.  You may convey covered works to others for the sole purpose
  33.191 +of having them make modifications exclusively for you, or provide you
  33.192 +with facilities for running those works, provided that you comply with
  33.193 +the terms of this License in conveying all material for which you do
  33.194 +not control copyright.  Those thus making or running the covered works
  33.195 +for you must do so exclusively on your behalf, under your direction
  33.196 +and control, on terms that prohibit them from making any copies of
  33.197 +your copyrighted material outside their relationship with you.
  33.198 +
  33.199 +  Conveying under any other circumstances is permitted solely under
  33.200 +the conditions stated below.  Sublicensing is not allowed; section 10
  33.201 +makes it unnecessary.
  33.202 +
  33.203 +\subsubsection*{3. Protecting Users' Legal Rights From
  33.204 +Anti-Circumvention Law.}
  33.205 +
  33.206 +\noindent\indent
  33.207 +  No covered work shall be deemed part of an effective technological
  33.208 +measure under any applicable law fulfilling obligations under article
  33.209 +11 of the WIPO copyright treaty adopted on 20 December 1996, or
  33.210 +similar laws prohibiting or restricting circumvention of such
  33.211 +measures.
  33.212 +
  33.213 +  When you convey a covered work, you waive any legal power to forbid
  33.214 +circumvention of technological measures to the extent such circumvention
  33.215 +is effected by exercising rights under this License with respect to
  33.216 +the covered work, and you disclaim any intention to limit operation or
  33.217 +modification of the work as a means of enforcing, against the work's
  33.218 +users, your or third parties' legal rights to forbid circumvention of
  33.219 +technological measures.
  33.220 +
  33.221 +\subsubsection*{4. Conveying Verbatim Copies.}
  33.222 +
  33.223 +\noindent\indent
  33.224 +  You may convey verbatim copies of the Program's source code as you
  33.225 +receive it, in any medium, provided that you conspicuously and
  33.226 +appropriately publish on each copy an appropriate copyright notice;
  33.227 +keep intact all notices stating that this License and any
  33.228 +non-permissive terms added in accord with section 7 apply to the code;
  33.229 +keep intact all notices of the absence of any warranty; and give all
  33.230 +recipients a copy of this License along with the Program.
  33.231 +
  33.232 +  You may charge any price or no price for each copy that you convey,
  33.233 +and you may offer support or warranty protection for a fee.
  33.234 +
  33.235 +\subsubsection*{5. Conveying Modified Source Versions.}
  33.236 +
  33.237 +  You may convey a work based on the Program, or the modifications to
  33.238 +produce it from the Program, in the form of source code under the
  33.239 +terms of section 4, provided that you also meet all of these conditions:
  33.240 +
  33.241 +    a) The work must carry prominent notices stating that you modified
  33.242 +    it, and giving a relevant date.
  33.243 +
  33.244 +    b) The work must carry prominent notices stating that it is
  33.245 +    released under this License and any conditions added under section
  33.246 +    7.  This requirement modifies the requirement in section 4 to
  33.247 +    ``keep intact all notices''.
  33.248 +
  33.249 +    c) You must license the entire work, as a whole, under this
  33.250 +    License to anyone who comes into possession of a copy.  This
  33.251 +    License will therefore apply, along with any applicable section 7
  33.252 +    additional terms, to the whole of the work, and all its parts,
  33.253 +    regardless of how they are packaged.  This License gives no
  33.254 +    permission to license the work in any other way, but it does not
  33.255 +    invalidate such permission if you have separately received it.
  33.256 +
  33.257 +    d) If the work has interactive user interfaces, each must display
  33.258 +    Appropriate Legal Notices; however, if the Program has interactive
  33.259 +    interfaces that do not display Appropriate Legal Notices, your
  33.260 +    work need not make them do so.
  33.261 +
  33.262 +  A compilation of a covered work with other separate and independent
  33.263 +works, which are not by their nature extensions of the covered work,
  33.264 +and which are not combined with it such as to form a larger program,
  33.265 +in or on a volume of a storage or distribution medium, is called an
  33.266 +``aggregate'' if the compilation and its resulting copyright are not
  33.267 +used to limit the access or legal rights of the compilation's users
  33.268 +beyond what the individual works permit.  Inclusion of a covered work
  33.269 +in an aggregate does not cause this License to apply to the other
  33.270 +parts of the aggregate.
  33.271 +
  33.272 +\subsubsection*{6. Conveying Non-Source Forms.}
  33.273 +
  33.274 +  You may convey a covered work in object code form under the terms
  33.275 +of sections 4 and 5, provided that you also convey the
  33.276 +machine-readable Corresponding Source under the terms of this License,
  33.277 +in one of these ways:
  33.278 +
  33.279 +    a) Convey the object code in, or embodied in, a physical product
  33.280 +    (including a physical distribution medium), accompanied by the
  33.281 +    Corresponding Source fixed on a durable physical medium
  33.282 +    customarily used for software interchange.
  33.283 +
  33.284 +    b) Convey the object code in, or embodied in, a physical product
  33.285 +    (including a physical distribution medium), accompanied by a
  33.286 +    written offer, valid for at least three years and valid for as
  33.287 +    long as you offer spare parts or customer support for that product
  33.288 +    model, to give anyone who possesses the object code either (1) a
  33.289 +    copy of the Corresponding Source for all the software in the
  33.290 +    product that is covered by this License, on a durable physical
  33.291 +    medium customarily used for software interchange, for a price no
  33.292 +    more than your reasonable cost of physically performing this
  33.293 +    conveying of source, or (2) access to copy the
  33.294 +    Corresponding Source from a network server at no charge.
  33.295 +
  33.296 +    c) Convey individual copies of the object code with a copy of the
  33.297 +    written offer to provide the Corresponding Source.  This
  33.298 +    alternative is allowed only occasionally and noncommercially, and
  33.299 +    only if you received the object code with such an offer, in accord
  33.300 +    with subsection 6b.
  33.301 +
  33.302 +    d) Convey the object code by offering access from a designated
  33.303 +    place (gratis or for a charge), and offer equivalent access to the
  33.304 +    Corresponding Source in the same way through the same place at no
  33.305 +    further charge.  You need not require recipients to copy the
  33.306 +    Corresponding Source along with the object code.  If the place to
  33.307 +    copy the object code is a network server, the Corresponding Source
  33.308 +    may be on a different server (operated by you or a third party)
  33.309 +    that supports equivalent copying facilities, provided you maintain
  33.310 +    clear directions next to the object code saying where to find the
  33.311 +    Corresponding Source.  Regardless of what server hosts the
  33.312 +    Corresponding Source, you remain obligated to ensure that it is
  33.313 +    available for as long as needed to satisfy these requirements.
  33.314 +
  33.315 +    e) Convey the object code using peer-to-peer transmission, provided
  33.316 +    you inform other peers where the object code and Corresponding
  33.317 +    Source of the work are being offered to the general public at no
  33.318 +    charge under subsection 6d.
  33.319 +
  33.320 +  A separable portion of the object code, whose source code is excluded
  33.321 +from the Corresponding Source as a System Library, need not be
  33.322 +included in conveying the object code work.
  33.323 +
  33.324 +  A ``User Product'' is either (1) a ``consumer product'', which means
  33.325 +any tangible personal property which is normally used for personal,
  33.326 +family, or household purposes, or (2) anything designed or sold for
  33.327 +incorporation into a dwelling.  In determining whether a product is a
  33.328 +consumer product, doubtful cases shall be resolved in favor of coverage.
  33.329 +For a particular product received by a particular user, ``normally
  33.330 +used'' refers to a typical or common use of that class of product,
  33.331 +regardless of the status of the particular user or of the way in which
  33.332 +the particular user actually uses, or expects or is expected to use, the
  33.333 +product.  A product is a consumer product regardless of whether the
  33.334 +product has substantial commercial, industrial or non-consumer uses,
  33.335 +unless such uses represent the only significant mode of use of the
  33.336 +product.
  33.337 +
  33.338 +  ``Installation Information'' for a User Product means any methods,
  33.339 +procedures, authorization keys, or other information required to install
  33.340 +and execute modified versions of a covered work in that User Product
  33.341 +from a modified version of its Corresponding Source.  The information
  33.342 +must suffice to ensure that the continued functioning of the modified
  33.343 +object code is in no case prevented or interfered with solely because
  33.344 +modification has been made.
  33.345 +
  33.346 +  If you convey an object code work under this section in, or with, or
  33.347 +specifically for use in, a User Product, and the conveying occurs as
  33.348 +part of a transaction in which the right of possession and use of the
  33.349 +User Product is transferred to the recipient in perpetuity or for a
  33.350 +fixed term (regardless of how the transaction is characterized), the
  33.351 +Corresponding Source conveyed under this section must be accompanied
  33.352 +by the Installation Information.  But this requirement does not apply
  33.353 +if neither you nor any third party retains the ability to install
  33.354 +modified object code on the User Product (for example, the work has
  33.355 +been installed in ROM).
  33.356 +
  33.357 +  The requirement to provide Installation Information does not include a
  33.358 +requirement to continue to provide support service, warranty, or updates
  33.359 +for a work that has been modified or installed by the recipient, or for
  33.360 +the User Product in which it has been modified or installed.  Access to
  33.361 +a network may be denied when the modification itself materially and
  33.362 +adversely affects the operation of the network or violates the rules and
  33.363 +protocols for communication across the network.
  33.364 +
  33.365 +  Corresponding Source conveyed, and Installation Information provided,
  33.366 +in accord with this section must be in a format that is publicly
  33.367 +documented (and with an implementation available to the public in
  33.368 +source code form), and must require no special password or key for
  33.369 +unpacking, reading or copying.
  33.370 +
  33.371 +\subsubsection*{7. Additional Terms.}
  33.372 +
  33.373 +\noindent\indent
  33.374 +  ``Additional permissions'' are terms that supplement the terms of this
  33.375 +License by making exceptions from one or more of its conditions.
  33.376 +Additional permissions that are applicable to the entire Program shall
  33.377 +be treated as though they were included in this License, to the extent
  33.378 +that they are valid under applicable law.  If additional permissions
  33.379 +apply only to part of the Program, that part may be used separately
  33.380 +under those permissions, but the entire Program remains governed by
  33.381 +this License without regard to the additional permissions.
  33.382 +
  33.383 +  When you convey a copy of a covered work, you may at your option
  33.384 +remove any additional permissions from that copy, or from any part of
  33.385 +it.  (Additional permissions may be written to require their own
  33.386 +removal in certain cases when you modify the work.)  You may place
  33.387 +additional permissions on material, added by you to a covered work,
  33.388 +for which you have or can give appropriate copyright permission.
  33.389 +
  33.390 +  Notwithstanding any other provision of this License, for material you
  33.391 +add to a covered work, you may (if authorized by the copyright holders
  33.392 +of that material) supplement the terms of this License with terms:
  33.393 +
  33.394 +    a) Disclaiming warranty or limiting liability differently from the
  33.395 +    terms of sections 15 and 16 of this License; or
  33.396 +
  33.397 +    b) Requiring preservation of specified reasonable legal notices or
  33.398 +    author attributions in that material or in the Appropriate Legal
  33.399 +    Notices displayed by works containing it; or
  33.400 +
  33.401 +    c) Prohibiting misrepresentation of the origin of that material, or
  33.402 +    requiring that modified versions of such material be marked in
  33.403 +    reasonable ways as different from the original version; or
  33.404 +
  33.405 +    d) Limiting the use for publicity purposes of names of licensors or
  33.406 +    authors of the material; or
  33.407 +
  33.408 +    e) Declining to grant rights under trademark law for use of some
  33.409 +    trade names, trademarks, or service marks; or
  33.410 +
  33.411 +    f) Requiring indemnification of licensors and authors of that
  33.412 +    material by anyone who conveys the material (or modified versions of
  33.413 +    it) with contractual assumptions of liability to the recipient, for
  33.414 +    any liability that these contractual assumptions directly impose on
  33.415 +    those licensors and authors.
  33.416 +
  33.417 +  All other non-permissive additional terms are considered ``further
  33.418 +restrictions'' within the meaning of section 10.  If the Program as you
  33.419 +received it, or any part of it, contains a notice stating that it is
  33.420 +governed by this License along with a term that is a further
  33.421 +restriction, you may remove that term.  If a license document contains
  33.422 +a further restriction but permits relicensing or conveying under this
  33.423 +License, you may add to a covered work material governed by the terms
  33.424 +of that license document, provided that the further restriction does
  33.425 +not survive such relicensing or conveying.
  33.426 +
  33.427 +  If you add terms to a covered work in accord with this section, you
  33.428 +must place, in the relevant source files, a statement of the
  33.429 +additional terms that apply to those files, or a notice indicating
  33.430 +where to find the applicable terms.
  33.431 +
  33.432 +  Additional terms, permissive or non-permissive, may be stated in the
  33.433 +form of a separately written license, or stated as exceptions;
  33.434 +the above requirements apply either way.
  33.435 +
  33.436 +\subsubsection*{8. Termination.}
  33.437 +
  33.438 +\noindent\indent
  33.439 +  You may not propagate or modify a covered work except as expressly
  33.440 +provided under this License.  Any attempt otherwise to propagate or
  33.441 +modify it is void, and will automatically terminate your rights under
  33.442 +this License (including any patent licenses granted under the third
  33.443 +paragraph of section 11).
  33.444 +
  33.445 +  However, if you cease all violation of this License, then your
  33.446 +license from a particular copyright holder is reinstated (a)
  33.447 +provisionally, unless and until the copyright holder explicitly and
  33.448 +finally terminates your license, and (b) permanently, if the copyright
  33.449 +holder fails to notify you of the violation by some reasonable means
  33.450 +prior to 60 days after the cessation.
  33.451 +
  33.452 +  Moreover, your license from a particular copyright holder is
  33.453 +reinstated permanently if the copyright holder notifies you of the
  33.454 +violation by some reasonable means, this is the first time you have
  33.455 +received notice of violation of this License (for any work) from that
  33.456 +copyright holder, and you cure the violation prior to 30 days after
  33.457 +your receipt of the notice.
  33.458 +
  33.459 +  Termination of your rights under this section does not terminate the
  33.460 +licenses of parties who have received copies or rights from you under
  33.461 +this License.  If your rights have been terminated and not permanently
  33.462 +reinstated, you do not qualify to receive new licenses for the same
  33.463 +material under section 10.
  33.464 +
  33.465 +\subsubsection*{9. Acceptance Not Required for Having Copies.}
  33.466 +
  33.467 +\noindent\indent
  33.468 +  You are not required to accept this License in order to receive or
  33.469 +run a copy of the Program.  Ancillary propagation of a covered work
  33.470 +occurring solely as a consequence of using peer-to-peer transmission
  33.471 +to receive a copy likewise does not require acceptance.  However,
  33.472 +nothing other than this License grants you permission to propagate or
  33.473 +modify any covered work.  These actions infringe copyright if you do
  33.474 +not accept this License.  Therefore, by modifying or propagating a
  33.475 +covered work, you indicate your acceptance of this License to do so.
  33.476 +
  33.477 +\subsubsection*{10. Automatic Licensing of Downstream Recipients.}
  33.478 +
  33.479 +\noindent\indent
  33.480 +  Each time you convey a covered work, the recipient automatically
  33.481 +receives a license from the original licensors, to run, modify and
  33.482 +propagate that work, subject to this License.  You are not responsible
  33.483 +for enforcing compliance by third parties with this License.
  33.484 +
  33.485 +  An ``entity transaction'' is a transaction transferring control of an
  33.486 +organization, or substantially all assets of one, or subdividing an
  33.487 +organization, or merging organizations.  If propagation of a covered
  33.488 +work results from an entity transaction, each party to that
  33.489 +transaction who receives a copy of the work also receives whatever
  33.490 +licenses to the work the party's predecessor in interest had or could
  33.491 +give under the previous paragraph, plus a right to possession of the
  33.492 +Corresponding Source of the work from the predecessor in interest, if
  33.493 +the predecessor has it or can get it with reasonable efforts.
  33.494 +
  33.495 +  You may not impose any further restrictions on the exercise of the
  33.496 +rights granted or affirmed under this License.  For example, you may
  33.497 +not impose a license fee, royalty, or other charge for exercise of
  33.498 +rights granted under this License, and you may not initiate litigation
  33.499 +(including a cross-claim or counterclaim in a lawsuit) alleging that
  33.500 +any patent claim is infringed by making, using, selling, offering for
  33.501 +sale, or importing the Program or any portion of it.
  33.502 +
  33.503 +\subsubsection*{11. Patents.}
  33.504 +
  33.505 +\noindent\indent
  33.506 +  A ``contributor'' is a copyright holder who authorizes use under this
  33.507 +License of the Program or a work on which the Program is based.  The
  33.508 +work thus licensed is called the contributor's ``contributor version''.
  33.509 +
  33.510 +  A contributor's ``essential patent claims'' are all patent claims
  33.511 +owned or controlled by the contributor, whether already acquired or
  33.512 +hereafter acquired, that would be infringed by some manner, permitted
  33.513 +by this License, of making, using, or selling its contributor version,
  33.514 +but do not include claims that would be infringed only as a
  33.515 +consequence of further modification of the contributor version.  For
  33.516 +purposes of this definition, ``control'' includes the right to grant
  33.517 +patent sublicenses in a manner consistent with the requirements of
  33.518 +this License.
  33.519 +
  33.520 +  Each contributor grants you a non-exclusive, worldwide, royalty-free
  33.521 +patent license under the contributor's essential patent claims, to
  33.522 +make, use, sell, offer for sale, import and otherwise run, modify and
  33.523 +propagate the contents of its contributor version.
  33.524 +
  33.525 +  In the following three paragraphs, a ``patent license'' is any express
  33.526 +agreement or commitment, however denominated, not to enforce a patent
  33.527 +(such as an express permission to practice a patent or covenant not to
  33.528 +sue for patent infringement).  To ``grant'' such a patent license to a
  33.529 +party means to make such an agreement or commitment not to enforce a
  33.530 +patent against the party.
  33.531 +
  33.532 +  If you convey a covered work, knowingly relying on a patent license,
  33.533 +and the Corresponding Source of the work is not available for anyone
  33.534 +to copy, free of charge and under the terms of this License, through a
  33.535 +publicly available network server or other readily accessible means,
  33.536 +then you must either (1) cause the Corresponding Source to be so
  33.537 +available, or (2) arrange to deprive yourself of the benefit of the
  33.538 +patent license for this particular work, or (3) arrange, in a manner
  33.539 +consistent with the requirements of this License, to extend the patent
  33.540 +license to downstream recipients.  ``Knowingly relying'' means you have
  33.541 +actual knowledge that, but for the patent license, your conveying the
  33.542 +covered work in a country, or your recipient's use of the covered work
  33.543 +in a country, would infringe one or more identifiable patents in that
  33.544 +country that you have reason to believe are valid.
  33.545 +
  33.546 +  If, pursuant to or in connection with a single transaction or
  33.547 +arrangement, you convey, or propagate by procuring conveyance of, a
  33.548 +covered work, and grant a patent license to some of the parties
  33.549 +receiving the covered work authorizing them to use, propagate, modify
  33.550 +or convey a specific copy of the covered work, then the patent license
  33.551 +you grant is automatically extended to all recipients of the covered
  33.552 +work and works based on it.
  33.553 +
  33.554 +  A patent license is ``discriminatory'' if it does not include within
  33.555 +the scope of its coverage, prohibits the exercise of, or is
  33.556 +conditioned on the non-exercise of one or more of the rights that are
  33.557 +specifically granted under this License.  You may not convey a covered
  33.558 +work if you are a party to an arrangement with a third party that is
  33.559 +in the business of distributing software, under which you make payment
  33.560 +to the third party based on the extent of your activity of conveying
  33.561 +the work, and under which the third party grants, to any of the
  33.562 +parties who would receive the covered work from you, a discriminatory
  33.563 +patent license (a) in connection with copies of the covered work
  33.564 +conveyed by you (or copies made from those copies), or (b) primarily
  33.565 +for and in connection with specific products or compilations that
  33.566 +contain the covered work, unless you entered into that arrangement,
  33.567 +or that patent license was granted, prior to 28 March 2007.
  33.568 +
  33.569 +  Nothing in this License shall be construed as excluding or limiting
  33.570 +any implied license or other defenses to infringement that may
  33.571 +otherwise be available to you under applicable patent law.
  33.572 +
  33.573 +\subsubsection*{12. No Surrender of Others' Freedom.}
  33.574 +
  33.575 +\noindent\indent
  33.576 +  If conditions are imposed on you (whether by court order, agreement or
  33.577 +otherwise) that contradict the conditions of this License, they do not
  33.578 +excuse you from the conditions of this License.  If you cannot convey a
  33.579 +covered work so as to satisfy simultaneously your obligations under this
  33.580 +License and any other pertinent obligations, then as a consequence you
  33.581 +may not convey it at all.  For example, if you agree to terms that
  33.582 +obligate you to collect a royalty for further conveying from those to
  33.583 +whom you convey the Program, the only way you could satisfy both those
  33.584 +terms and this License would be to refrain entirely from conveying the
  33.585 +Program.
  33.586 +
  33.587 +\subsubsection*{13. Use with the GNU Affero General Public License.}
  33.588 +
  33.589 +\noindent\indent
  33.590 +  Notwithstanding any other provision of this License, you have
  33.591 +permission to link or combine any covered work with a work licensed
  33.592 +under version 3 of the GNU Affero General Public License into a single
  33.593 +combined work, and to convey the resulting work.  The terms of this
  33.594 +License will continue to apply to the part which is the covered work,
  33.595 +but the special requirements of the GNU Affero General Public License,
  33.596 +section 13, concerning interaction through a network will apply to the
  33.597 +combination as such.
  33.598 +
  33.599 +\subsubsection*{14. Revised Versions of this License.}
  33.600 +
  33.601 +\noindent\indent
  33.602 +  The Free Software Foundation may publish revised and/or new versions
  33.603 +of the GNU General Public License from time to time.  Such new versions
  33.604 +will be similar in spirit to the present version, but may differ in
  33.605 +detail to address new problems or concerns.
  33.606 +
  33.607 +  Each version is given a distinguishing version number.  If the
  33.608 +Program specifies that a certain numbered version of the GNU General
  33.609 +Public License ``or any later version'' applies to it, you have the
  33.610 +option of following the terms and conditions either of that numbered
  33.611 +version or of any later version published by the Free Software
  33.612 +Foundation.  If the Program does not specify a version number of the
  33.613 +GNU General Public License, you may choose any version ever published
  33.614 +by the Free Software Foundation.
  33.615 +
  33.616 +  If the Program specifies that a proxy can decide which future
  33.617 +versions of the GNU General Public License can be used, that proxy's
  33.618 +public statement of acceptance of a version permanently authorizes you
  33.619 +to choose that version for the Program.
  33.620 +
  33.621 +  Later license versions may give you additional or different
  33.622 +permissions.  However, no additional obligations are imposed on any
  33.623 +author or copyright holder as a result of your choosing to follow a
  33.624 +later version.
  33.625 +
  33.626 +\subsubsection*{15. Disclaimer of Warranty.}
  33.627 +
  33.628 +\noindent\indent
  33.629 +  THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
  33.630 +APPLICABLE LAW.  EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
  33.631 +HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM ``AS IS'' WITHOUT
  33.632 +WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT
  33.633 +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
  33.634 +PARTICULAR PURPOSE.  THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE
  33.635 +OF THE PROGRAM IS WITH YOU.  SHOULD THE PROGRAM PROVE DEFECTIVE, YOU
  33.636 +ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
  33.637 +
  33.638 +\subsubsection*{16. Limitation of Liability.}
  33.639 +
  33.640 +\noindent\indent
  33.641 +  IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
  33.642 +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR
  33.643 +CONVEYS THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
  33.644 +INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES
  33.645 +ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT
  33.646 +NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES
  33.647 +SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE
  33.648 +WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN
  33.649 +ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
  33.650 +
  33.651 +\subsubsection*{17. Interpretation of Sections 15 and 16.}
  33.652 +
  33.653 +\noindent\indent
  33.654 +  If the disclaimer of warranty and limitation of liability provided
  33.655 +above cannot be given local legal effect according to their terms,
  33.656 +reviewing courts shall apply local law that most closely approximates
  33.657 +an absolute waiver of all civil liability in connection with the
  33.658 +Program, unless a warranty or assumption of liability accompanies a
  33.659 +copy of the Program in return for a fee.
  33.660 +
  33.661 +\section*{END OF TERMS AND CONDITIONS}
  33.662 +
  33.663 +\newpage
  33.664 +
  33.665 +\section*{How to Apply These Terms to Your New Programs}
  33.666 +
  33.667 +\noindent\indent
  33.668 +  If you develop a new program, and you want it to be of the greatest
  33.669 +possible use to the public, the best way to achieve this is to make it
  33.670 +free software which everyone can redistribute and change under these
  33.671 +terms.
  33.672 +
  33.673 +  To do so, attach the following notices to the program.  It is safest
  33.674 +to attach them to the start of each source file to most effectively
  33.675 +state the exclusion of warranty; and each file should have at least
  33.676 +the ``copyright'' line and a pointer to where the full notice is found.
  33.677 +
  33.678 +\begin{verbatim}
  33.679 +<one line to give the program's name and a brief idea of what it does.>
  33.680 +Copyright (C) <year>  <name of author>
  33.681 +
  33.682 +This program is free software: you can redistribute it and/or modify
  33.683 +it under the terms of the GNU General Public License as published by
  33.684 +the Free Software Foundation, either version 3 of the License, or
  33.685 +(at your option) any later version.
  33.686 +
  33.687 +This program is distributed in the hope that it will be useful,
  33.688 +but WITHOUT ANY WARRANTY; without even the implied warranty of
  33.689 +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  33.690 +GNU General Public License for more details.
  33.691 +
  33.692 +You should have received a copy of the GNU General Public License
  33.693 +along with this program.  If not, see <http://www.gnu.org/licenses/>.
  33.694 +\end{verbatim}
  33.695 +
  33.696 +\noindent
  33.697 +Also add information on how to contact you by electronic and paper mail.
  33.698 +
  33.699 +  If the program does terminal interaction, make it output a short
  33.700 +notice like this when it starts in an interactive mode:
  33.701 +
  33.702 +\begin{verbatim}
  33.703 +<program>  Copyright (C) <year>  <name of author>
  33.704 +This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
  33.705 +This is free software, and you are welcome to redistribute it
  33.706 +under certain conditions; type `show c' for details.
  33.707 +\end{verbatim}
  33.708 +
  33.709 +\noindent
  33.710 +The hypothetical commands `show w' and `show c' should show the
  33.711 +appropriate parts of the General Public License.  Of course, your
  33.712 +program's commands might be different; for a GUI interface, you would
  33.713 +use an ``about box''.
  33.714 +
  33.715 +  You should also get your employer (if you work as a programmer) or
  33.716 +school, if any, to sign a ``copyright disclaimer'' for the program, if
  33.717 +necessary. For more information on this, and how to apply and follow the
  33.718 +GNU GPL, see \verb|<http://www.gnu.org/licenses/>|.
  33.719 +
  33.720 +  The GNU General Public License does not permit incorporating your
  33.721 +program into proprietary programs.  If your program is a subroutine
  33.722 +library, you may consider it more useful to permit linking proprietary
  33.723 +applications with the library.  If this is what you want to do, use the
  33.724 +GNU Lesser General Public License instead of this License.  But first,
  33.725 +please read \verb|<http://www.gnu.org/philosophy/why-not-lgpl.html>|.
  33.726 +
  33.727 +\end{footnotesize}
  33.728 +
  33.729 +%* eof *%
    34.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    34.2 +++ b/deps/glpk/doc/glpk_faq.txt	Sun Nov 06 20:59:10 2011 +0100
    34.3 @@ -0,0 +1,435 @@
    34.4 +
    34.5 +GNU Linear Programming Kit FAQ
    34.6 +
    34.7 +  Summary: Frequently Asked Questions about the GNU Linear Programming Kit
    34.8 +
    34.9 +  Author: Dr. Harley Mackenzie <hjm@hardsoftware.com>                     
   34.10 +
   34.11 +  Posting-Frequency: Monthly                                              
   34.12 +
   34.13 +  Language: English                                                       
   34.14 +
   34.15 +  $Date: 2004/01/09 05:57:57 $                                            
   34.16 +
   34.17 +  $Revision: 1.6 $                                                        
   34.18 +
   34.19 +
   34.20 +
   34.21 +Introduction
   34.22 +
   34.23 +  Q. What is GPLK?                                                        
   34.24 +
   34.25 +  A. GLPK stands for the GNU Linear Programming Kit. The GLPK package is  
   34.26 +  a set of routines written in ANSI C and organized in the form of a      
   34.27 +  callable library. This package is intended for solving large-scale      
   34.28 +  linear programming (LP), mixed integer linear programming (MIP), and    
   34.29 +  other related problems.                                                 
   34.30 +
   34.31 +  The GLPK package includes the following main components:                
   34.32 +
   34.33 +    * implementation of the simplex method,                                   
   34.34 +
   34.35 +    * implementation of the primal-dual interior point method,                
   34.36 +
   34.37 +    * implementation of the branch-and-bound method,                          
   34.38 +
   34.39 +    * application program interface (API),                                    
   34.40 +
   34.41 +    * GNU MathProg modeling language (a subset of AMPL),                      
   34.42 +
   34.43 +    * GLPSOL, a stand-alone LP/MIP solver.                                    
   34.44 +
   34.45 +
   34.46 +  Q. Who develops and maintains GLPK?                                     
   34.47 +
   34.48 +  A. GLPK is currently developed and maintained by Andrew Makhorin,       
   34.49 +  Department for Applied Informatics, Moscow Aviation Institute, Moscow,  
   34.50 +  Russia. Andrew's email address is <mao@mai2.rcnet.ru> and his postal    
   34.51 +  address is 125871, Russia, Moscow, Volokolamskoye sh., 4, Moscow        
   34.52 +  Aviation Institute, Andrew O. Makhorin                                  
   34.53 +
   34.54 +
   34.55 +  Q. How is GLPK licensed?                                                
   34.56 +
   34.57 +  A. GLPK is currently licensed under the GNU General Public License      
   34.58 +  (GPL). GLPK is free software; you can redistribute it and/or modify it  
   34.59 +  under the terms of the GNU General Public License as published by the   
   34.60 +  Free Software Foundation; either version 2, or (at your option) any     
   34.61 +  later version.                                                          
   34.62 +
   34.63 +  GLPK is not licensed under the Lesser General Public License (LGPL) as  
   34.64 +  distinct from other free LP codes such as lp_solve. The most            
   34.65 +  significant implication is that code that is linked to the GLPK library 
   34.66 +  must be released under the GPL, whereas with the LGPL, code linked to   
   34.67 +  the library does not have to be released under the same license.        
   34.68 +
   34.69 +
   34.70 +  Q. Where is the GLPK home page?                                         
   34.71 +
   34.72 +  The GLPK home page is part of the GNU web site and can found at         
   34.73 +  <http://www.gnu.org/software/glpk/glpk.html>.                           
   34.74 +
   34.75 +
   34.76 +  Q. How do I download and install GLPK?                                  
   34.77 +
   34.78 +  A. The GLPK source distribution can be found in the subdirectory        
   34.79 +  /gnu/glpk/ on your favorite GNU mirror                                  
   34.80 +  <http://www.gnu.org/prep/ftp.html> and can be compiled directly from    
   34.81 +  the source.                                                             
   34.82 +
   34.83 +  The GLPK package (like all other GNU software) is distributed in the    
   34.84 +  form of packed archive. This is one file named 'glpk-x.y.tar.gz', where 
   34.85 +  x is the major version number and y is the minor version number.        
   34.86 +
   34.87 +  In order to prepare the distribution for installation you should:       
   34.88 +
   34.89 +    1. Copy the GLPK distribution file to some subdirectory.                   
   34.90 +
   34.91 +    2. Enter the command 'gzip -d glpk-x.y.tar.gz' in order to unpack the      
   34.92 +       distribution file. After unpacking the name of the distribution file    
   34.93 +       will be automatically changed to 'glpk-x.y.tar'.                        
   34.94 +
   34.95 +    3. Enter the command 'tar -x < glpk-x.y.tar' in order to unarchive the     
   34.96 +       distribution. After this operation the subdirectory 'glpk-x.y' which is 
   34.97 +       the GLPK distribution will have been automatically created.             
   34.98 +
   34.99 +  After you have unpacked and unarchived GLPK distribution you should     
  34.100 +  configure the package, and compiled the application. The result of      
  34.101 +  compilation is:                                                         
  34.102 +
  34.103 +    * the file 'libglpk.a', which is a library archive containing object code 
  34.104 +      for all GLPK routines; and                                              
  34.105 +
  34.106 +    * the program 'glpsol', which is a stand-alone LP/MIP solver.             
  34.107 +
  34.108 +  Complete compilation and installation instructions are included in the  
  34.109 +  INSTALL file included with the distribution.                            
  34.110 +
  34.111 +  The distribution includes make files for the Microsoft Visual C/C++     
  34.112 +  version 6 and Borland C/C++ version 5 and by default compiles and links 
  34.113 +  a glpk*.lib library file, a glpk*.dll DLL file and an glpsol.exe        
  34.114 +  application file. A GNU Windows 4.1 binary, source and documentation    
  34.115 +  compiled using the mingw32 C/C++ compiler is also available from        
  34.116 +  <http://gnuwin32.sourceforge.net/packages/glpk.htm>.                    
  34.117 +
  34.118 +
  34.119 +  Q. Is there a GLPK mailing list or newsgroup?                           
  34.120 +
  34.121 +  A. GLPK has two mailing lists: <help-glpk@gnu.org> and                  
  34.122 +  <bug-glpk@gnu.org>.                                                     
  34.123 +
  34.124 +  The main discussion list is <help-glpk@gnu.org>, and is used to discuss 
  34.125 +  all aspects of GLPK, including its development and porting. There is    
  34.126 +  also a special list used for reporting bugs at <bug-glpk@gnu.org>.      
  34.127 +
  34.128 +  To subscribe to any GLPK mailing list, send an empty mail with a        
  34.129 +  Subject: header line of just "subscribe" to the relevant -request list. 
  34.130 +  For example, to subscribe yourself to the main list, you would send     
  34.131 +  mail to <help-glpk-request@gnu.org> with no body and a Subject: header  
  34.132 +  line of just "subscribe".                                               
  34.133 +
  34.134 +  Another way to subscribe to the GLP mailing lists is to visit the web   
  34.135 +  pages <http://mail.gnu.org/mailman/listinfo/help-glpk> and              
  34.136 +  <http://mail.gnu.org/mailman/listinfo/bug-glpk>.                        
  34.137 +
  34.138 +  Currently there are no newsgroups dedicated to GLPK.                    
  34.139 +
  34.140 +
  34.141 +  Q. Who maintains this FAQ and how do I contribute to this FAQ?          
  34.142 +
  34.143 +  A. The present maintainer of this FAQ is Dr. Harley Mackenzie, HARD     
  34.144 +  software, although the content of the FAQ is derived from many sources  
  34.145 +  such as GLPK documentation, GLPK email archives and original content.   
  34.146 +
  34.147 +  Harley's email address is <hjm@hardsoftware.com> and his postal address 
  34.148 +  is c/o HARD software, PO Box 8004, Newtown, Victoria 3220, Australia.   
  34.149 +
  34.150 +  All contributions to this FAQ, such as questions and (preferably)       
  34.151 +  answers should be sent to the <hjm@hardsoftware.com> email address.     
  34.152 +  This FAQ is copyright Harley Mackenzie 2003 and is released under the   
  34.153 +  same license, terms and conditions as GLPK, that is, GPL version 2 or   
  34.154 +  later.                                                                  
  34.155 +
  34.156 +  Contributions are not directly referenced in the body of the FAQ as     
  34.157 +  this would become unmanageable and messy, but rather as a list of       
  34.158 +  contributors to this FAQ. If you are the author of any information      
  34.159 +  included in this FAQ and you do not want your content to be included,   
  34.160 +  please contact the FAQ maintainer and your material will be removed.    
  34.161 +  Also if you have not been correctly included as a contributor to this   
  34.162 +  FAQ, your details have changed, or you do not want your name listed in  
  34.163 +  the list of contributors, please contact the FAQ maintainer for         
  34.164 +  correction.                                                             
  34.165 +
  34.166 +
  34.167 +  Q. Where can I download this FAQ?                                       
  34.168 +
  34.169 +  The latest version of the GLPK FAQ is available to download from        
  34.170 +  <http://www.hardsoftware.com/downloads.php#GLPK+FAQ> in the following   
  34.171 +  formats:                                                                
  34.172 +
  34.173 +    * DocBook                                                                 
  34.174 +
  34.175 +    * Formatted text                                                          
  34.176 +
  34.177 +    * Adobe PDF                                                               
  34.178 +
  34.179 +
  34.180 +  Q. Who are the FAQ contributors?                                        
  34.181 +
  34.182 +  A. The FAQ contents were created from the following sources:            
  34.183 +
  34.184 +    * Michael Hennebry                                                        
  34.185 +
  34.186 +    * http://www-unix.mcs.anl.gov/otc/Guide/faq/linear-programming-faq.html   
  34.187 +
  34.188 +    * Harley Mackenzie, HARD software Pty. Ltd.                               
  34.189 +
  34.190 +    * Andrew Makhorin, Department for Applied Informatics, Moscow Aviation    
  34.191 +      Institute                                                               
  34.192 +
  34.193 +
  34.194 +GLPK functions & features
  34.195 +
  34.196 +  Q. What is the current state of GLPK development?                       
  34.197 +
  34.198 +  A. GLPK is a work in progress and is presently under continual          
  34.199 +  development. As of the current version 4.3, GLPK is a simplex-based     
  34.200 +  solver is able to handle problems with up to 100,000 constraints. In    
  34.201 +  particular, it successfully solves all instances from netlib (see the   
  34.202 +  file bench.txt included in the GLPK distribution). The interior-point   
  34.203 +  solver is not very robust as it is unable to handle dense columns,      
  34.204 +  sometimes terminates due to numeric instability or slow convergence.    
  34.205 +
  34.206 +  The Mixed Integer Programming (MIP) solver currently is based on        
  34.207 +  branch-and-bound, so it is unable to solve hard or very large problems  
  34.208 +  with a probable practical limit of 100-200 integer variables. However,  
  34.209 +  sometimes it is able to solve larger problems of up to 1000 integer     
  34.210 +  variables, although the size that depends on properties of particular   
  34.211 +  problem.                                                                
  34.212 +
  34.213 +
  34.214 +  Q. How does GLPK compare with other LP codes?                           
  34.215 +
  34.216 +  A. I think that on very large-scale instances CPLEX 8.0 dual simplex is 
  34.217 +  10-100 times faster than the GLPK simplex solver and, of course, much   
  34.218 +  more robust. In many cases GLPK is faster and more robust than lp_solve 
  34.219 +  4.0 for pure LPs as well as MIP's. See the bench.txt file in the GLPK   
  34.220 +  distribution doc directory for GLPK netlib benchmark results.           
  34.221 +
  34.222 +  You can find benchmarks for some LP and MIP solvers such as CPLEX,      
  34.223 +  GLPK, lp_solve, and OSL on Hans Mittelmann's webpage at                 
  34.224 +  <http://plato.asu.edu/bench.html>.                                      
  34.225 +
  34.226 +
  34.227 +  Q. What are the differences between AMPL and GNU MathProg?              
  34.228 +
  34.229 +  A. The subset of AMPL implemented in MathProg approximately corresponds 
  34.230 +  to AMPL status in 1990, because it is mainly based on the paper Robert  
  34.231 +  Fourer, David M Gay and Brian W Kernighan (1990), "A Modeling Language  
  34.232 +  for Mathematical Programming", Management Science, Vol 36, pp. 519-554  
  34.233 +  and is available at                                                     
  34.234 +  <http://users.iems.nwu.edu/~4er/WRITINGS/amplmod.pdf>.                  
  34.235 +
  34.236 +  The GNU MathProg translator was developed as part of GLPK. However, GNU 
  34.237 +  MathProg can be easily used in other applications as there is a set of  
  34.238 +  MathProg interface routines designed for use in other applications.     
  34.239 +
  34.240 +
  34.241 +  Q. What input file formats does GLPK support?                           
  34.242 +
  34.243 +  A. GLPK presently can read input and output LP model files in three     
  34.244 +  supported formats:                                                      
  34.245 +
  34.246 +    * MPS format - which is a column oriented and widely supported file       
  34.247 +      format but has poor human readability.                                  
  34.248 +
  34.249 +    * CPLEX format - which is an easily readable row oriented format.         
  34.250 +
  34.251 +    * GNU MathProg - which is an AMPL like mathematical modeling language.    
  34.252 +
  34.253 +
  34.254 +  Q. What interfaces are available for GLPK?                              
  34.255 +
  34.256 +  A. The GLPK package is in fact a C API that can be either by statically 
  34.257 +  or dynamically linked directly with many programming systems.           
  34.258 +
  34.259 +  Presently there are three contributed external interfaces included with 
  34.260 +  the GLPK package:                                                       
  34.261 +
  34.262 +    * GLPK Java Native Interface (JNI)                                        
  34.263 +
  34.264 +    * GLPK Delphi Interface (DELI)                                            
  34.265 +
  34.266 +    * GLPKMEX Matlab MEX interface                                            
  34.267 +
  34.268 +  There is an unofficial Microsoft Visual Basic, Tcl/Tk and Java GLPK     
  34.269 +  interface available at                                                  
  34.270 +  <http://gottfried.lindner.bei.t-online.de/glpk.htm>.                    
  34.271 +
  34.272 +  There are other language interfaces under development, including a Perl 
  34.273 +  interface currently being developed by the FAQ maintainer, Dr. Harley   
  34.274 +  Mackenzie <hjm@hardsoftware.com>.                                       
  34.275 +
  34.276 +
  34.277 +  Q. Where can I find some examples?                                      
  34.278 +
  34.279 +  A. The GLPK package distribution contains many examples written in GNU  
  34.280 +  MathProg (*.mod), C API calls (*.c), CPLEX input file format (*.lpt),   
  34.281 +  MPS format (*.mps) as well as some specific Traveling Salesman examples 
  34.282 +  (*.tsp).                                                                
  34.283 +
  34.284 +  All of the examples can be found in the GLPK distribution examples      
  34.285 +  sub-directory.                                                          
  34.286 +
  34.287 +
  34.288 +  Q. What are the future plans for GLPK?                                  
  34.289 +
  34.290 +  A. Developments planned for GLPK include improving the existing key     
  34.291 +  GLPK components, such as developing a more robust and more efficient    
  34.292 +  implementation of the simplex-based and interior-point solvers. Future  
  34.293 +  GLPK enhancements planned are implementing a branch-and-cut solver, a   
  34.294 +  MIP pre-processor, post-optimal and sensitivity analysis and possibly   
  34.295 +  network simplex and quadratic programming solvers.                      
  34.296 +
  34.297 +
  34.298 +  Q. How do I report a GLPK bug?                                          
  34.299 +
  34.300 +  A. If you think you have found a bug in GLPK, then you should send as   
  34.301 +  complete a report as possible to <bug-glpk@gnu.org>.                    
  34.302 +
  34.303 +
  34.304 +  Q. How do I contribute to the GLPK development?                         
  34.305 +
  34.306 +  A. At present new GLPK development patches should be emailed to Andrew  
  34.307 +  Makhorin <mao@mai2.rcnet.ru >, with sufficient documentation and test   
  34.308 +  code to explain the nature of the patch, how to install it and the      
  34.309 +  implications of its use. Before commencing any major GLPK development   
  34.310 +  for inclusion in the GLPK distribution, it would be a good idea to      
  34.311 +  discuss the idea on the GLPK mailing list.                              
  34.312 +
  34.313 +
  34.314 +  Q. How do I compile and link a GLPK application on a UNIX platform?     
  34.315 +
  34.316 +  A. To compile a GLPK application on a UNIX platform, then compiler must 
  34.317 +  be able to include the GLPK include files and link to the GLPK library. 
  34.318 +  For example, on a system where the GLPK system is installed:            
  34.319 +
  34.320 +  gcc mylp.c -o mylp -lglpk                                               
  34.321 +
  34.322 +  or specify the include files and libglpk.a explicitly, if GLPK is not   
  34.323 +  installed.                                                              
  34.324 +
  34.325 +
  34.326 +  Q. How do I compile and link a GLPK application on a Win32 platform?    
  34.327 +
  34.328 +  A. On a Win32 platform, GLPK is implemented either as a Win32 Dynamic   
  34.329 +  Link Library (DLL) or can be statically linked to the glpk*.lib file.   
  34.330 +  As with the UNIX instructions, a GLPK application must set a path to    
  34.331 +  the GLPK include files and also reference the GLPK library if           
  34.332 +  statically linked.                                                      
  34.333 +
  34.334 +
  34.335 +  Q. How do I limit the GLPK execution time?                              
  34.336 +
  34.337 +  A. You can limit the computing time by setting the control parameter    
  34.338 +  LPX_K_TMLIM via the API routine lpx_set_real_parm . At present there is 
  34.339 +  no way of limiting the execution time of glpsol without changing the    
  34.340 +  source and recompiling a specific version.                              
  34.341 +
  34.342 +
  34.343 +GLPK Linear Programming
  34.344 +
  34.345 +  Q. What is Linear Programming and how does it work?                     
  34.346 +
  34.347 +  A. Linear Programming is a mathematical technique that is a generic     
  34.348 +  method for solving certain systems of equations with linear terms. The  
  34.349 +  real power of LP's are that they have many practical applications and   
  34.350 +  have proven to be a powerful and robust tool.                           
  34.351 +
  34.352 +  The best single source of information on LP's is the Linear Programming 
  34.353 +  FAQ                                                                     
  34.354 +  <http://www-unix.mcs.anl.gov/otc/Guide/faq/linear-programming-faq.html> 
  34.355 +  that has information on LP's and MIP's, includes a comprehensive list   
  34.356 +  of available LP software and has many LP references for further study.  
  34.357 +
  34.358 +
  34.359 +  Q. How do I determine the stability of an LP solution?                  
  34.360 +
  34.361 +  A. You can perform sensitivity analysis by specifying the --bounds      
  34.362 +  option for glpsol as:                                                   
  34.363 +
  34.364 +  glpsol ... --bounds filename                                            
  34.365 +
  34.366 +  in which case the solver writes results of the analysis to the          
  34.367 +  specified filename in plain text format. The corresponding API routine  
  34.368 +  is lpx_print_sens_bnds() .                                              
  34.369 +
  34.370 +
  34.371 +  Q. How do I determine which constraints are causing infeasibility?      
  34.372 +
  34.373 +  A straightforward way to find such a set of constraints is to drop      
  34.374 +  constraints one at a time. If dropping a constraint results in a        
  34.375 +  solvable problem, pick it up and go on to the next constraint. After    
  34.376 +  applying phase 1 to an infeasible problem, all basic satisfied          
  34.377 +  constraints may be dropped.                                             
  34.378 +
  34.379 +  If the problem has a feasible dual, then running the dual simplex       
  34.380 +  method is a more direct approach. After the last pivot, the nonbasic    
  34.381 +  constraints and one of the violated constraints will constitute a       
  34.382 +  minimal set. The GLPK simplex table routines will allow you to pick a   
  34.383 +  correct constraint from the violated ones.                              
  34.384 +
  34.385 +  Note that the GLPK pre-solver needs to be turned off for the preceding  
  34.386 +  technique to work, otherwise GLPK does not keep the basis of an         
  34.387 +  infeasible solution.                                                    
  34.388 +
  34.389 +  Also a more detailed methodology has been posted on the mail list       
  34.390 +  archive at                                                              
  34.391 +  <http://mail.gnu.org/archive/html/help-glpk/2003-09/msg00017.html>.     
  34.392 +
  34.393 +
  34.394 +  Q. What is the difference between checks and constraints?               
  34.395 +
  34.396 +  A. Check statements are intended to check that all data specified by    
  34.397 +  the user of the model are correct, mainly in the data section of a      
  34.398 +  MathProg model. For example, if some parameter means the number of      
  34.399 +  nodes in a network, it must be positive integer, that is just the       
  34.400 +  condition to be checked in the check statement (although in this case   
  34.401 +  such condition may be also checked directly in the parameter            
  34.402 +  statement). Note that check statements are performed when the           
  34.403 +  translator is generating the model, so they cannot include variables.   
  34.404 +
  34.405 +  Constraints are conditions that are expressed in terms of variables and 
  34.406 +  resolved by the solver after the model has been completely generated.   
  34.407 +  If all data specified in the model are correct a priori, check          
  34.408 +  statements are not needed and can be omitted, while constraints are     
  34.409 +  essential components of the model and therefore cannot be omitted.      
  34.410 +
  34.411 +
  34.412 +GLPK Integer Programming 
  34.413 +
  34.414 +  Q. What is Integer Programming and how does it work?                    
  34.415 +
  34.416 +  A. Integer LP models are ones whose variables are constrained to take   
  34.417 +  integer or whole number (as opposed to fractional) values. It may not   
  34.418 +  be obvious that integer programming is a very much harder problem than  
  34.419 +  ordinary linear programming, but that is nonetheless the case, in both  
  34.420 +  theory and practice.                                                    
  34.421 +
  34.422 +
  34.423 +  Q. What is the Integer Optimization Suite (IOS)?                        
  34.424 +
  34.425 +  A. IOS is a framework to implement implicit enumeration methods based   
  34.426 +  on LP relaxation (like branch-and-bound and branch-and-cut). Currently  
  34.427 +  IOS includes only basic features (the enumeration tree, API routines,   
  34.428 +  and the driver) and is not completely documented.                       
  34.429 +
  34.430 +
  34.431 +  Q. I have just changed an LP to a MIP and now it doesn't work?          
  34.432 +
  34.433 +  A. If you have an existing LP that is working and you change to an MIP  
  34.434 +  and receive a "lpx_integer: optimal solution of LP relaxation required" 
  34.435 +  204 (==LPX_E_FAULT) error, you probably have not called the LP solution 
  34.436 +  method lpx_simplex() before lpx_integer() . The MIP routines use the LP 
  34.437 +  solution as part of the MIP solution methodology.                       
  34.438 +
    35.1 Binary file deps/glpk/doc/gmpl.pdf has changed
    36.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    36.2 +++ b/deps/glpk/doc/gmpl.tex	Sun Nov 06 20:59:10 2011 +0100
    36.3 @@ -0,0 +1,4653 @@
    36.4 +%* gmpl.tex *%
    36.5 +
    36.6 +%***********************************************************************
    36.7 +%  This code is part of GLPK (GNU Linear Programming Kit).
    36.8 +%
    36.9 +%  Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008,
   36.10 +%  2009, 2010 Andrew Makhorin, Department for Applied Informatics,
   36.11 +%  Moscow Aviation Institute, Moscow, Russia. All rights reserved.
   36.12 +%  E-mail: <mao@gnu.org>.
   36.13 +%
   36.14 +%  GLPK is free software: you can redistribute it and/or modify it
   36.15 +%  under the terms of the GNU General Public License as published by
   36.16 +%  the Free Software Foundation, either version 3 of the License, or
   36.17 +%  (at your option) any later version.
   36.18 +%
   36.19 +%  GLPK is distributed in the hope that it will be useful, but WITHOUT
   36.20 +%  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
   36.21 +%  or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
   36.22 +%  License for more details.
   36.23 +%
   36.24 +%  You should have received a copy of the GNU General Public License
   36.25 +%  along with GLPK. If not, see <http://www.gnu.org/licenses/>.
   36.26 +%***********************************************************************
   36.27 +
   36.28 +\documentclass[10pt]{article}
   36.29 +\usepackage[dvipdfm,linktocpage,colorlinks,linkcolor=blue]{hyperref}
   36.30 +
   36.31 +\begin{document}
   36.32 +
   36.33 +\thispagestyle{empty}
   36.34 +
   36.35 +\begin{center}
   36.36 +
   36.37 +\vspace*{1in}
   36.38 +
   36.39 +\begin{huge}
   36.40 +\sf\bfseries Modeling Language GNU MathProg
   36.41 +\end{huge}
   36.42 +
   36.43 +\vspace{0.5in}
   36.44 +
   36.45 +\begin{LARGE}
   36.46 +\sf Language Reference
   36.47 +\end{LARGE}
   36.48 +
   36.49 +\vspace{0.5in}
   36.50 +
   36.51 +\begin{LARGE}
   36.52 +\sf for GLPK Version 4.45
   36.53 +\end{LARGE}
   36.54 +
   36.55 +\vspace{0.5in}
   36.56 +\begin{Large}
   36.57 +\sf (DRAFT, December 2010)
   36.58 +\end{Large}
   36.59 +
   36.60 +\end{center}
   36.61 +
   36.62 +\newpage
   36.63 +
   36.64 +\vspace*{1in}
   36.65 +
   36.66 +\vfill
   36.67 +
   36.68 +\noindent
   36.69 +The GLPK package is part of the GNU Project released under the aegis of
   36.70 +GNU.
   36.71 +
   36.72 +\medskip\noindent
   36.73 +Copyright \copyright{} 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007,
   36.74 +2008, 2009, 2010 Andrew Makhorin, Department for Applied Informatics,
   36.75 +Moscow Aviation Institute, Moscow, Russia. All rights reserved.
   36.76 +
   36.77 +\medskip\noindent
   36.78 +Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,
   36.79 +MA 02110-1301, USA.
   36.80 +
   36.81 +\medskip\noindent
   36.82 +Permission is granted to make and distribute verbatim copies of this
   36.83 +manual provided the copyright notice and this permission notice are
   36.84 +preserved on all copies.
   36.85 +
   36.86 +\medskip\noindent
   36.87 +Permission is granted to copy and distribute modified versions of this
   36.88 +manual under the conditions for verbatim copying, provided also that
   36.89 +the entire resulting derived work is distributed under the terms of
   36.90 +a permission notice identical to this one.
   36.91 +
   36.92 +\medskip\noindent
   36.93 +Permission is granted to copy and distribute translations of this
   36.94 +manual into another language, under the above conditions for modified
   36.95 +versions.
   36.96 +
   36.97 +\newpage
   36.98 +
   36.99 +\tableofcontents
  36.100 +
  36.101 +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  36.102 +
  36.103 +\newpage
  36.104 +
  36.105 +\section{Introduction}
  36.106 +
  36.107 +{\it GNU MathProg} is a modeling language intended for describing
  36.108 +linear mathematical programming models.\footnote{The GNU MathProg
  36.109 +language is a subset of the AMPL language. Its GLPK implementation is
  36.110 +mainly based on the paper: {\it Robert Fourer}, {\it David M. Gay}, and
  36.111 +{\it Brian W. Kernighan}, ``A Modeling Language for Mathematical
  36.112 +Programming.'' {\it Management Science} 36 (1990)\linebreak pp. 519-54.}
  36.113 +
  36.114 +Model descriptions written in the GNU MathProg language consist of
  36.115 +a set of statements and data blocks constructed by the user from the
  36.116 +language elements described in this document.
  36.117 +
  36.118 +In a process called {\it translation}, a program called the {\it model
  36.119 +translator} analyzes the model description and translates it into
  36.120 +internal data structures, which may be then used either for generating
  36.121 +mathematical programming problem instance or directly by a program
  36.122 +called the {\it solver} to obtain numeric solution of the problem.
  36.123 +
  36.124 +\subsection{Linear programming problem}
  36.125 +\label{problem}
  36.126 +
  36.127 +In MathProg the linear programming (LP) problem is stated as follows:
  36.128 +
  36.129 +\medskip
  36.130 +
  36.131 +\noindent\hspace{.7in}minimize (or maximize)
  36.132 +$$z=c_1x_1+c_2x_2+\dots+c_nx_n+c_0\eqno(1.1)$$
  36.133 +\noindent\hspace{.7in}subject to linear constraints
  36.134 +$$
  36.135 +\begin{array}{l@{\ }c@{\ }r@{\ }c@{\ }r@{\ }c@{\ }r@{\ }c@{\ }l}
  36.136 +L_1&\leq&a_{11}x_1&+&a_{12}x_2&+\dots+&a_{1n}x_n&\leq&U_1\\
  36.137 +L_2&\leq&a_{21}x_1&+&a_{22}x_2&+\dots+&a_{2n}x_n&\leq&U_2\\
  36.138 +\multicolumn{9}{c}{.\ \ .\ \ .\ \ .\ \ .\ \ .\ \ .\ \ .\ \ .}\\
  36.139 +L_m&\leq&a_{m1}x_1&+&a_{m2}x_2&+\dots+&a_{mn}x_n&\leq&U_m\\
  36.140 +\end{array}\eqno(1.2)
  36.141 +$$
  36.142 +\noindent\hspace{.7in}and bounds of variables
  36.143 +$$
  36.144 +\begin{array}{l@{\ }c@{\ }c@{\ }c@{\ }l}
  36.145 +l_1&\leq&x_1&\leq&u_1\\
  36.146 +l_2&\leq&x_2&\leq&u_2\\
  36.147 +\multicolumn{5}{c}{.\ \ .\ \ .\ \ .\ \ .}\\
  36.148 +l_n&\leq&x_n&\leq&u_n\\
  36.149 +\end{array}\eqno(1.3)
  36.150 +$$
  36.151 +where $x_1$, $x_2$, \dots, $x_n$ are variables; $z$ is the objective
  36.152 +function; $c_1$, $c_2$, \dots, $c_n$ are objective coefficients; $c_0$
  36.153 +is the constant term (``shift'') of the objective function; $a_{11}$,
  36.154 +$a_{12}$, \dots, $a_{mn}$ are constraint coefficients; $L_1$, $L_2$,
  36.155 +\dots, $L_m$ are lower constraint bounds; $U_1$, $U_2$, \dots, $U_m$
  36.156 +are upper constraint bounds; $l_1$, $l_2$, \dots, $l_n$ are lower
  36.157 +bounds of variables; $u_1$, $u_2$, \dots, $u_n$ are upper bounds of
  36.158 +variables.
  36.159 +
  36.160 +Bounds of variables and constraint bounds can be finite as well as
  36.161 +infinite. Besides, lower bounds can be equal to corresponding upper
  36.162 +bounds. Thus, the following types of variables and constraints are
  36.163 +allowed:
  36.164 +
  36.165 +\newpage
  36.166 +
  36.167 +\begin{tabular}{@{}r@{\ }c@{\ }c@{\ }c@{\ }l@{\hspace*{38pt}}l}
  36.168 +$-\infty$&$<$&$x$&$<$&$+\infty$&Free (unbounded) variable\\
  36.169 +$l$&$\leq$&$x$&$<$&$+\infty$&Variable with lower bound\\
  36.170 +$-\infty$&$<$&$x$&$\leq$&$u$&Variable with upper bound\\
  36.171 +$l$&$\leq$&$x$&$\leq$&$u$&Double-bounded variable\\
  36.172 +$l$&$=$&$x$&=&$u$&Fixed variable\\
  36.173 +\end{tabular}
  36.174 +
  36.175 +\bigskip
  36.176 +
  36.177 +\begin{tabular}{@{}r@{\ }c@{\ }c@{\ }c@{\ }ll}
  36.178 +$-\infty$&$<$&$\sum a_jx_j$&$<$&$+\infty$&Free (unbounded) linear
  36.179 +form\\
  36.180 +$L$&$\leq$&$\sum a_jx_j$&$<$&$+\infty$&Inequality constraint ``greater
  36.181 +than or equal to''\\
  36.182 +$-\infty$&$<$&$\sum a_jx_j$&$\leq$&$U$&Inequality constraint ``less
  36.183 +than or equal to''\\
  36.184 +$L$&$\leq$&$\sum a_jx_j$&$\leq$&$U$&Double-bounded inequality
  36.185 +constraint\\
  36.186 +$L$&$=$&$\sum a_jx_j$&=&$U$&Equality constraint\\
  36.187 +\end{tabular}
  36.188 +
  36.189 +\bigskip
  36.190 +
  36.191 +In addition to pure LP problems MathProg also allows mixed integer
  36.192 +linear programming (MIP) problems, where some or all variables are
  36.193 +restricted to be integer or binary.
  36.194 +
  36.195 +\subsection{Model objects}
  36.196 +
  36.197 +In MathProg the model is described in terms of sets, parameters,
  36.198 +variables, constraints, and objectives, which are called {\it model
  36.199 +objects}.
  36.200 +
  36.201 +The user introduces particular model objects using the language
  36.202 +statements. Each model object is provided with a symbolic name that
  36.203 +uniquely identifies the object and is intended for referencing purposes.
  36.204 +
  36.205 +Model objects, including sets, can be multidimensional arrays built
  36.206 +over indexing sets. Formally, $n$-dimensional array $A$ is the mapping:
  36.207 +$$A:\Delta\rightarrow\Xi,\eqno(1.4)$$
  36.208 +where $\Delta\subseteq S_1\times\dots\times S_n$ is a subset of the
  36.209 +Cartesian product of indexing sets,\linebreak $\Xi$ is a set of array members.
  36.210 +In MathProg the set $\Delta$ is called the {\it subscript domain}. Its
  36.211 +members are $n$-tuples $(i_1,\dots,i_n)$, where $i_1\in S_1$, \dots,
  36.212 +$i_n\in S_n$.
  36.213 +
  36.214 +If $n=0$, the Cartesian product above has exactly one member (namely,
  36.215 +\linebreak 0-tuple), so it is convenient to think scalar objects as
  36.216 +0-dimensional arrays having one member.
  36.217 +
  36.218 +The type of array members is determined by the type of corresponding
  36.219 +model object as follows:
  36.220 +
  36.221 +\medskip
  36.222 +
  36.223 +\noindent\hfil
  36.224 +\begin{tabular}{@{}ll@{}}
  36.225 +Model object&Array member\\
  36.226 +\hline
  36.227 +Set&Elemental plain set\\
  36.228 +Parameter&Number or symbol\\
  36.229 +Variable&Elemental variable\\
  36.230 +Constraint&Elemental constraint\\
  36.231 +Objective&Elemental objective\\
  36.232 +\end{tabular}
  36.233 +
  36.234 +\medskip
  36.235 +
  36.236 +In order to refer to a particular object member the object should be
  36.237 +provided with {\it subscripts}. For example, if $a$ is a 2-dimensional
  36.238 +parameter defined over $I\times J$, a reference to its particular
  36.239 +member can be written as $a[i,j]$, where $i\in I$ and $j\in J$. It is
  36.240 +understood that scalar objects being 0-dimensional need no subscripts.
  36.241 +
  36.242 +\subsection{Structure of model description}
  36.243 +
  36.244 +It is sometimes desirable to write a model which, at various points,
  36.245 +may require different data for each problem instance to be solved using
  36.246 +that model. For this reason in MathProg the model description consists
  36.247 +of two parts: the {\it model section} and the {\it data section}.
  36.248 +
  36.249 +The model section is a main part of the model description that contains
  36.250 +declarations of model objects and is common for all problems based on
  36.251 +the corresponding model.
  36.252 +
  36.253 +The data section is an optional part of the model description that
  36.254 +contains data specific for a particular problem instance.
  36.255 +
  36.256 +Depending on what is more convenient the model and data sections can be
  36.257 +placed either in one file or in two separate files. The latter feature
  36.258 +allows having arbitrary number of different data sections to be used
  36.259 +with the same model section.
  36.260 +
  36.261 +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  36.262 +
  36.263 +\newpage
  36.264 +
  36.265 +\section{Coding model description}
  36.266 +\label{coding}
  36.267 +
  36.268 +The model description is coded in plain text format using ASCII
  36.269 +character set. Characters valid in the model description are the
  36.270 +following:
  36.271 +
  36.272 +\begin{itemize}
  36.273 +\item alphabetic characters:\\
  36.274 +\verb|A B C D E F G H I J K L M N O P Q R S T U V W X Y Z|\\
  36.275 +\verb|a b c d e f g h i j k l m n o p q r s t u v w x y z _|
  36.276 +\item numeric characters:\\
  36.277 +\verb|0 1 2 3 4 5 6 7 8 9|
  36.278 +\item special characters:\\
  36.279 +\verb?! " # & ' ( ) * + , - . / : ; < = > [ ] ^ { | }?
  36.280 +\item white-space characters:\\
  36.281 +\verb|SP HT CR NL VT FF|
  36.282 +\end{itemize}
  36.283 +
  36.284 +Within string literals and comments any ASCII characters (except
  36.285 +control characters) are valid.
  36.286 +
  36.287 +White-space characters are non-significant. They can be used freely
  36.288 +between lexical units to improve readability of the model description.
  36.289 +They are also used to separate lexical units from each other if there
  36.290 +is no other way to do that.
  36.291 +
  36.292 +Syntactically model description is a sequence of lexical units in the
  36.293 +following categories:
  36.294 +
  36.295 +\begin{itemize}
  36.296 +\item symbolic names;
  36.297 +\item numeric literals;
  36.298 +\item string literals;
  36.299 +\item keywords;
  36.300 +\item delimiters;
  36.301 +\item comments.
  36.302 +\end{itemize}
  36.303 +
  36.304 +The lexical units of the language are discussed below.
  36.305 +
  36.306 +\subsection{Symbolic names}
  36.307 +
  36.308 +A {\it symbolic name} consists of alphabetic and numeric characters,
  36.309 +the first of which must be alphabetic. All symbolic names are distinct
  36.310 +(case sensitive).
  36.311 +
  36.312 +\medskip
  36.313 +
  36.314 +\noindent{\bf Examples}
  36.315 +
  36.316 +\medskip
  36.317 +
  36.318 +\noindent\verb|alpha123|
  36.319 +
  36.320 +\noindent\verb|This_is_a_name|
  36.321 +
  36.322 +\noindent\verb|_P123_abc_321|
  36.323 +
  36.324 +\newpage
  36.325 +
  36.326 +Symbolic names are used to identify model objects (sets, parameters,
  36.327 +variables, constraints, objectives) and dummy indices.
  36.328 +
  36.329 +All symbolic names (except names of dummy indices) must be unique, i.e.
  36.330 +the model description must have no objects with identical names.
  36.331 +Symbolic names of dummy indices must be unique within the scope, where
  36.332 +they are valid.
  36.333 +
  36.334 +\subsection{Numeric literals}
  36.335 +
  36.336 +A {\it numeric literal} has the form {\it xx}{\tt E}{\it syy}, where
  36.337 +{\it xx} is a number with optional decimal point, {\it s} is the sign
  36.338 +{\tt+} or {\tt-}, {\it yy} is a decimal exponent. The letter {\tt E} is
  36.339 +case insensitive and can be coded as {\tt e}.
  36.340 +
  36.341 +\medskip
  36.342 +
  36.343 +\noindent{\bf Examples}
  36.344 +
  36.345 +\medskip
  36.346 +
  36.347 +\noindent\verb|123|
  36.348 +
  36.349 +\noindent\verb|3.14159|
  36.350 +
  36.351 +\noindent\verb|56.E+5|
  36.352 +
  36.353 +\noindent\verb|.78|
  36.354 +
  36.355 +\noindent\verb|123.456e-7|
  36.356 +
  36.357 +\medskip
  36.358 +
  36.359 +Numeric literals are used to represent numeric quantities. They have
  36.360 +obvious fixed meaning.
  36.361 +
  36.362 +\subsection{String literals}
  36.363 +
  36.364 +A {\it string literal} is a sequence of arbitrary characters enclosed
  36.365 +either in single quotes or in double quotes. Both these forms are
  36.366 +equivalent.
  36.367 +
  36.368 +If the single quote is part of a string literal enclosed in single
  36.369 +quotes, it must be coded twice. Analogously, if the double quote is
  36.370 +part of a string literal enclosed in double quotes, it must be coded
  36.371 +twice.
  36.372 +
  36.373 +\medskip
  36.374 +
  36.375 +\noindent{\bf Examples}
  36.376 +
  36.377 +\medskip
  36.378 +
  36.379 +\noindent\verb|'This is a string'|
  36.380 +
  36.381 +\noindent\verb|"This is another string"|
  36.382 +
  36.383 +\noindent\verb|'1 + 2 = 3'|
  36.384 +
  36.385 +\noindent\verb|'That''s all'|
  36.386 +
  36.387 +\noindent\verb|"She said: ""No"""|
  36.388 +
  36.389 +\medskip
  36.390 +
  36.391 +String literals are used to represent symbolic quantities.
  36.392 +
  36.393 +\subsection{Keywords}
  36.394 +
  36.395 +A {\it keyword} is a sequence of alphabetic characters and possibly
  36.396 +some special characters.
  36.397 +
  36.398 +All keywords fall into two categories: {\it reserved keywords}, which
  36.399 +cannot be used as symbolic names, and {\it non-reserved keywords},
  36.400 +which being recognized by context can be used as symbolic names.
  36.401 +
  36.402 +\newpage
  36.403 +
  36.404 +The reserved keywords are the following:
  36.405 +
  36.406 +\medskip
  36.407 +
  36.408 +\noindent\hfil
  36.409 +\begin{tabular}{@{}p{.7in}p{.7in}p{.7in}p{.7in}@{}}
  36.410 +{\tt and}&{\tt else}&{\tt mod}&{\tt union}\\
  36.411 +{\tt by}&{\tt if}&{\tt not}&{\tt within}\\
  36.412 +{\tt cross}&{\tt in}&{\tt or}\\
  36.413 +{\tt diff}&{\tt inter}&{\tt symdiff}\\
  36.414 +{\tt div}&{\tt less}&{\tt then}\\
  36.415 +\end{tabular}
  36.416 +
  36.417 +\medskip
  36.418 +
  36.419 +Non-reserved keywords are described in following sections.
  36.420 +
  36.421 +All the keywords have fixed meaning, which will be explained on
  36.422 +discussion of corresponding syntactic constructions, where the keywords
  36.423 +are used.
  36.424 +
  36.425 +\subsection{Delimiters}
  36.426 +
  36.427 +A {\it delimiter} is either a single special character or a sequence of
  36.428 +two special characters as follows:
  36.429 +
  36.430 +\medskip
  36.431 +
  36.432 +\noindent\hfil
  36.433 +\begin{tabular}{@{}p{.3in}p{.3in}p{.3in}p{.3in}p{.3in}p{.3in}@{}}
  36.434 +{\tt+}&{\tt\textasciicircum}&{\tt==}&{\tt!}&{\tt:}&{\tt)}\\
  36.435 +{\tt-}&{\tt\&}&{\tt>=}&{\tt\&\&}&{\tt;}&{\tt[}\\
  36.436 +{\tt*}&{\tt<}&{\tt>}&{\tt||}&{\tt:=}&{\tt|}\\
  36.437 +{\tt/}&{\tt<=}&{\tt<>}&{\tt.}&{\tt..}&{\tt\{}\\
  36.438 +{\tt**}&{\tt=}&{\tt!=}&{\tt,}&{\tt(}&{\tt\}}\\
  36.439 +\end{tabular}
  36.440 +
  36.441 +\medskip
  36.442 +
  36.443 +If the delimiter consists of two characters, there must be no spaces
  36.444 +between the characters.
  36.445 +
  36.446 +All the delimiters have fixed meaning, which will be explained on
  36.447 +discussion corresponding syntactic constructions, where the delimiters
  36.448 +are used.
  36.449 +
  36.450 +\subsection{Comments}
  36.451 +
  36.452 +For documenting purposes the model description can be provided with
  36.453 +{\it comments}, which may have two different forms. The first form is
  36.454 +a {\it single-line comment}, which begins with the character {\tt\#}
  36.455 +and extends until end of line. The second form is a {\it comment
  36.456 +sequence}, which is a sequence of any characters enclosed within
  36.457 +{\tt/*} and {\tt*/}.
  36.458 +
  36.459 +\medskip
  36.460 +
  36.461 +\noindent{\bf Examples}
  36.462 +
  36.463 +\medskip
  36.464 +
  36.465 +\noindent\verb|param n := 10; # This is a comment|
  36.466 +
  36.467 +\noindent\verb|/* This is another comment */|
  36.468 +
  36.469 +\medskip
  36.470 +
  36.471 +Comments are ignored by the model translator and can appear anywhere in
  36.472 +the model description, where white-space characters are allowed.
  36.473 +
  36.474 +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  36.475 +
  36.476 +\newpage
  36.477 +
  36.478 +\section{Expressions}
  36.479 +
  36.480 +An {\it expression} is a rule for computing a value. In model
  36.481 +description expressions are used as constituents of certain statements.
  36.482 +
  36.483 +In general case expressions consist of operands and operators.
  36.484 +
  36.485 +Depending on the type of the resultant value all expressions fall into
  36.486 +the following categories:
  36.487 +
  36.488 +\begin{itemize}
  36.489 +\item numeric expressions;
  36.490 +\item symbolic expressions;
  36.491 +\item indexing expressions;
  36.492 +\item set expressions;
  36.493 +\item logical expressions;
  36.494 +\item linear expressions.
  36.495 +\end{itemize}
  36.496 +
  36.497 +\subsection{Numeric expressions}
  36.498 +
  36.499 +A {\it numeric expression} is a rule for computing a single numeric
  36.500 +value represented as a floating-point number.
  36.501 +
  36.502 +The primary numeric expression may be a numeric literal, dummy index,
  36.503 +unsubscripted parameter, subscripted parameter, built-in function
  36.504 +reference, iterated numeric expression, conditional numeric expression,
  36.505 +or another numeric expression enclosed in parentheses.
  36.506 +
  36.507 +\medskip
  36.508 +
  36.509 +\noindent{\bf Examples}
  36.510 +
  36.511 +\medskip
  36.512 +
  36.513 +\noindent
  36.514 +\begin{tabular}{@{}ll@{}}
  36.515 +\verb|1.23|&(numeric literal)\\
  36.516 +\verb|j|&(dummy index)\\
  36.517 +\verb|time|&(unsubscripted parameter)\\
  36.518 +\verb|a['May 2003',j+1]|&(subscripted parameter)\\
  36.519 +\verb|abs(b[i,j])|&(function reference)\\
  36.520 +\verb|sum{i in S diff T} alpha[i] * b[i,j]|&(iterated expression)\\
  36.521 +\verb|if i in I then 2 * p else q[i+1]|&(conditional expression)\\
  36.522 +\verb|(b[i,j] + .5 * c)|&(parenthesized expression)\\
  36.523 +\end{tabular}
  36.524 +
  36.525 +\medskip
  36.526 +
  36.527 +More general numeric expressions containing two or more primary numeric
  36.528 +expressions may be constructed by using certain arithmetic operators.
  36.529 +
  36.530 +\medskip
  36.531 +
  36.532 +\noindent{\bf Examples}
  36.533 +
  36.534 +\medskip
  36.535 +
  36.536 +\noindent\verb|j+1|
  36.537 +
  36.538 +\noindent\verb|2 * a[i-1,j+1] - b[i,j]|
  36.539 +
  36.540 +\noindent\verb|sum{j in J} a[i,j] * x[j] + sum{k in K} b[i,k] * x[k]|
  36.541 +
  36.542 +\noindent\verb|(if i in I then 2 * p else q[i+1]) / (a[i,j] + 1.5)|
  36.543 +
  36.544 +\subsubsection{Numeric literals}
  36.545 +
  36.546 +If the primary numeric expression is a numeric literal, the resultant
  36.547 +value is obvious.
  36.548 +
  36.549 +\subsubsection{Dummy indices}
  36.550 +
  36.551 +If the primary numeric expression is a dummy index, the resultant value
  36.552 +is current value assigned to that dummy index.
  36.553 +
  36.554 +\subsubsection{Unsubscripted parameters}
  36.555 +
  36.556 +If the primary numeric expression is an unsubscripted parameter (which
  36.557 +must be 0-dimensional), the resultant value is the value of that
  36.558 +parameter.
  36.559 +
  36.560 +\subsubsection{Subscripted parameters}
  36.561 +
  36.562 +The primary numeric expression, which refers to a subscripted parameter,
  36.563 +has the following syntactic form:
  36.564 +
  36.565 +\medskip
  36.566 +
  36.567 +\noindent\hfil
  36.568 +{\it name}{\tt[}$i_1${\tt,} $i_2${\tt,} \dots{\tt,} $i_n${\tt]}
  36.569 +
  36.570 +\medskip
  36.571 +
  36.572 +\noindent where {\it name} is the symbolic name of the parameter,
  36.573 +$i_1$, $i_2$, \dots, $i_n$ are subscripts.
  36.574 +
  36.575 +Each subscript must be a numeric or symbolic expression. The number of
  36.576 +subscripts in the subscript list must be the same as the dimension of
  36.577 +the parameter with which the subscript list is associated.
  36.578 +
  36.579 +Actual values of subscript expressions are used to identify
  36.580 +a particular member of the parameter that determines the resultant
  36.581 +value of the primary expression.
  36.582 +
  36.583 +\subsubsection{Function references}
  36.584 +
  36.585 +In MathProg there exist the following built-in functions which may be
  36.586 +used in numeric expressions:
  36.587 +
  36.588 +\medskip
  36.589 +
  36.590 +\begin{tabular}{@{}p{96pt}p{222pt}@{}}
  36.591 +{\tt abs(}$x${\tt)}&$|x|$, absolute value of $x$\\
  36.592 +{\tt atan(}$x${\tt)}&$\arctan x$, principal value of the arc tangent of
  36.593 +$x$ (in radians)\\
  36.594 +{\tt atan(}$y${\tt,} $x${\tt)}&$\arctan y/x$, principal value of the
  36.595 +arc tangent of $y/x$ (in radians). In this case the signs of both
  36.596 +arguments $y$ and $x$ are used to determine the quadrant of the
  36.597 +resultant value\\
  36.598 +{\tt card(}$X${\tt)}&$|X|$, cardinality (the number of elements) of
  36.599 +set $X$\\
  36.600 +{\tt ceil(}$x${\tt)}&$\lceil x\rceil$, smallest integer not less than
  36.601 +$x$ (``ceiling of $x$'')\\
  36.602 +{\tt cos(}$x${\tt)}&$\cos x$, cosine of $x$ (in radians)\\
  36.603 +{\tt exp(}$x${\tt)}&$e^x$, base-$e$ exponential of $x$\\
  36.604 +{\tt floor(}$x${\tt)}&$\lfloor x\rfloor$, largest integer not greater
  36.605 +than $x$ (``floor of $x$'')\\
  36.606 +\end{tabular}
  36.607 +
  36.608 +\begin{tabular}{@{}p{96pt}p{222pt}@{}}
  36.609 +{\tt gmtime()}&the number of seconds elapsed since 00:00:00~Jan~1, 1970,
  36.610 +Coordinated Universal Time (for details see Subsection \ref{gmtime},
  36.611 +page \pageref{gmtime})\\
  36.612 +{\tt length(}$s${\tt)}&$|s|$, length of character string $s$\\
  36.613 +{\tt log(}$x${\tt)}&$\log x$, natural logarithm of $x$\\
  36.614 +{\tt log10(}$x${\tt)}&$\log_{10}x$, common (decimal) logarithm of $x$\\
  36.615 +{\tt max(}$x_1${\tt,} $x_2${\tt,} \dots{\tt,} $x_n${\tt)}&the largest
  36.616 +of values $x_1$, $x_2$, \dots, $x_n$\\
  36.617 +{\tt min(}$x_1${\tt,} $x_2${\tt,} \dots{\tt,} $x_n${\tt)}&the smallest
  36.618 +of values $x_1$, $x_2$, \dots, $x_n$\\
  36.619 +{\tt round(}$x${\tt)}&rounding $x$ to nearest integer\\
  36.620 +{\tt round(}$x${\tt,} $n${\tt)}&rounding $x$ to $n$ fractional decimal
  36.621 +digits\\
  36.622 +{\tt sin(}$x${\tt)}&$\sin x$, sine of $x$ (in radians)\\
  36.623 +{\tt sqrt(}$x${\tt)}&$\sqrt{x}$, non-negative square root of $x$\\
  36.624 +{\tt str2time(}$s${\tt,} $f${\tt)}&converting character string $s$ to
  36.625 +calendar time (for details see Subsection \ref{str2time}, page
  36.626 +\pageref{str2time})\\
  36.627 +{\tt trunc(}$x${\tt)}&truncating $x$ to nearest integer\\
  36.628 +{\tt trunc(}$x${\tt,} $n${\tt)}&truncating $x$ to $n$ fractional
  36.629 +decimal digits\\
  36.630 +{\tt Irand224()}&generating pseudo-random integer uniformly distributed
  36.631 +in $[0,2^{24})$\\
  36.632 +{\tt Uniform01()}&generating pseudo-random number uniformly distributed
  36.633 +in $[0,1)$\\
  36.634 +{\tt Uniform(}$a${\tt,} $b${\tt)}&generating pseudo-random number
  36.635 +uniformly distributed in $[a,b)$\\
  36.636 +{\tt Normal01()}&generating Gaussian pseudo-random variate with
  36.637 +$\mu=0$ and $\sigma=1$\\
  36.638 +{\tt Normal(}$\mu${\tt,} $\sigma${\tt)}&generating Gaussian
  36.639 +pseudo-random variate with given $\mu$ and $\sigma$\\
  36.640 +\end{tabular}
  36.641 +
  36.642 +\medskip
  36.643 +
  36.644 +Arguments of all built-in functions, except {\tt card}, {\tt length},
  36.645 +and {\tt str2time}, must be numeric expressions. The argument of
  36.646 +{\tt card} must be a set expression. The argument of {\tt length} and
  36.647 +both arguments of {\tt str2time} must be symbolic expressions.
  36.648 +
  36.649 +The resultant value of the numeric expression, which is a function
  36.650 +reference, is the result of applying the function to its argument(s).
  36.651 +
  36.652 +Note that each pseudo-random generator function has a latent argument
  36.653 +(i.e. some internal state), which is changed whenever the function has
  36.654 +been applied. Thus, if the function is applied repeatedly even to
  36.655 +identical arguments, due to the side effect different resultant values
  36.656 +are always produced.
  36.657 +
  36.658 +\subsubsection{Iterated expressions}
  36.659 +\label{itexpr}
  36.660 +
  36.661 +An {\it iterated numeric expression} is a primary numeric expression,
  36.662 +which has the following syntactic form:
  36.663 +
  36.664 +\medskip
  36.665 +
  36.666 +\noindent\hfil
  36.667 +{\it iterated-operator indexing-expression integrand}
  36.668 +
  36.669 +\medskip
  36.670 +
  36.671 +\noindent where {\it iterated-operator} is the symbolic name of the
  36.672 +iterated operator to be performed (see below), {\it indexing-expression}
  36.673 +is an indexing expression which introduces dummy indices and controls
  36.674 +iterating, {\it integrand} is a numeric expression that participates in
  36.675 +the operation.
  36.676 +
  36.677 +In MathProg there exist four iterated operators, which may be used in
  36.678 +numeric expressions:
  36.679 +
  36.680 +\medskip
  36.681 +
  36.682 +\noindent\hfil
  36.683 +\begin{tabular}{@{}lll@{}}
  36.684 +{\tt sum}&summation&$\displaystyle\sum_{(i_1,\dots,i_n)\in\Delta}
  36.685 +f(i_1,\dots,i_n)$\\
  36.686 +{\tt prod}&production&$\displaystyle\prod_{(i_1,\dots,i_n)\in\Delta}
  36.687 +f(i_1,\dots,i_n)$\\
  36.688 +{\tt min}&minimum&$\displaystyle\min_{(i_1,\dots,i_n)\in\Delta}
  36.689 +f(i_1,\dots,i_n)$\\
  36.690 +{\tt max}&maximum&$\displaystyle\max_{(i_1,\dots,i_n)\in\Delta}
  36.691 +f(i_1,\dots,i_n)$\\
  36.692 +\end{tabular}
  36.693 +
  36.694 +\medskip
  36.695 +
  36.696 +\noindent where $i_1$, \dots, $i_n$ are dummy indices introduced in
  36.697 +the indexing expression, $\Delta$ is the domain, a set of $n$-tuples
  36.698 +specified by the indexing expression which defines particular values
  36.699 +assigned to the dummy indices on performing the iterated operation,
  36.700 +$f(i_1,\dots,i_n)$ is the integrand, a numeric expression whose
  36.701 +resultant value depends on the dummy indices.
  36.702 +
  36.703 +The resultant value of an iterated numeric expression is the result of
  36.704 +applying of the iterated operator to its integrand over all $n$-tuples
  36.705 +contained in the domain.
  36.706 +
  36.707 +\subsubsection{Conditional expressions}
  36.708 +\label{ifthen}
  36.709 +
  36.710 +A {\it conditional numeric expression} is a primary numeric expression,
  36.711 +which has one of the following two syntactic forms:
  36.712 +
  36.713 +\medskip
  36.714 +
  36.715 +\noindent\hfil
  36.716 +{\tt if} $b$ {\tt then} $x$ {\tt else} $y$
  36.717 +
  36.718 +\medskip
  36.719 +
  36.720 +\noindent\hspace{126.5pt}
  36.721 +{\tt if} $b$ {\tt then} $x$
  36.722 +
  36.723 +\medskip
  36.724 +
  36.725 +\noindent where $b$ is an logical expression, $x$ and $y$ are numeric
  36.726 +expressions.
  36.727 +
  36.728 +The resultant value of the conditional expression depends on the value
  36.729 +of the logical expression that follows the keyword {\tt if}. If it
  36.730 +takes on the value {\it true}, the value of the conditional expression
  36.731 +is the value of the expression that follows the keyword {\tt then}.
  36.732 +Otherwise, if the logical expression takes on the value {\it false},
  36.733 +the value of the conditional expression is the value of the expression
  36.734 +that follows the keyword {\it else}. If the second, reduced form of the
  36.735 +conditional expression is used and the logical expression takes on the
  36.736 +value {\it false}, the resultant value of the conditional expression is
  36.737 +zero.
  36.738 +
  36.739 +\subsubsection{Parenthesized expressions}
  36.740 +
  36.741 +Any numeric expression may be enclosed in parentheses that
  36.742 +syntactically makes it a primary numeric expression.
  36.743 +
  36.744 +Parentheses may be used in numeric expressions, as in algebra, to
  36.745 +specify the desired order in which operations are to be performed.
  36.746 +Where parentheses are used, the expression within the parentheses is
  36.747 +evaluated before the resultant value is used.
  36.748 +
  36.749 +The resultant value of the parenthesized expression is the same as the
  36.750 +value of the expression enclosed within parentheses.
  36.751 +
  36.752 +\subsubsection{Arithmetic operators}
  36.753 +
  36.754 +In MathProg there exist the following arithmetic operators, which may
  36.755 +be used in numeric expressions:
  36.756 +
  36.757 +\medskip
  36.758 +
  36.759 +\begin{tabular}{@{}p{96pt}p{222pt}@{}}
  36.760 +{\tt +} $x$&unary plus\\
  36.761 +{\tt -} $x$&unary minus\\
  36.762 +$x$ {\tt +} $y$&addition\\
  36.763 +$x$ {\tt -} $y$&subtraction\\
  36.764 +$x$ {\tt less} $y$&positive difference (if $x<y$ then 0 else $x-y$)\\
  36.765 +$x$ {\tt *} $y$&multiplication\\
  36.766 +$x$ {\tt /} $y$&division\\
  36.767 +$x$ {\tt div} $y$&quotient of exact division\\
  36.768 +$x$ {\tt mod} $y$&remainder of exact division\\
  36.769 +$x$ {\tt **} $y$, $x$ {\tt\textasciicircum} $y$&exponentiation (raising
  36.770 +to power)\\
  36.771 +\end{tabular}
  36.772 +
  36.773 +\medskip
  36.774 +
  36.775 +\noindent where $x$ and $y$ are numeric expressions.
  36.776 +
  36.777 +If the expression includes more than one arithmetic operator, all
  36.778 +operators are performed from left to right according to the hierarchy
  36.779 +of operations (see below) with the only exception that the
  36.780 +exponentiaion operators are performed from right to left.
  36.781 +
  36.782 +The resultant value of the expression, which contains arithmetic
  36.783 +operators, is the result of applying the operators to their operands.
  36.784 +
  36.785 +\subsubsection{Hierarchy of operations}
  36.786 +\label{hierarchy}
  36.787 +
  36.788 +The following list shows the hierarchy of operations in numeric
  36.789 +expressions:
  36.790 +
  36.791 +\medskip
  36.792 +
  36.793 +\noindent\hfil
  36.794 +\begin{tabular}{@{}ll@{}}
  36.795 +Operation&Hierarchy\\
  36.796 +\hline
  36.797 +Evaluation of functions ({\tt abs}, {\tt ceil}, etc.)&1st\\
  36.798 +Exponentiation ({\tt**}, {\tt\textasciicircum})&2nd\\
  36.799 +Unary plus and minus ({\tt+}, {\tt-})&3rd\\
  36.800 +Multiplication and division ({\tt*}, {\tt/}, {\tt div}, {\tt mod})&4th\\
  36.801 +Iterated operations ({\tt sum}, {\tt prod}, {\tt min}, {\tt max})&5th\\
  36.802 +Addition and subtraction ({\tt+}, {\tt-}, {\tt less})&6th\\
  36.803 +Conditional evaluation ({\tt if} \dots {\tt then} \dots {\tt else})&
  36.804 +7th\\
  36.805 +\end{tabular}
  36.806 +
  36.807 +\medskip
  36.808 +
  36.809 +This hierarchy is used to determine which of two consecutive operations
  36.810 +is performed first. If the first operator is higher than or equal to
  36.811 +the second, the first operation is performed. If it is not, the second
  36.812 +operator is compared to the third, etc. When the end of the expression
  36.813 +is reached, all of the remaining operations are performed in the
  36.814 +reverse order.
  36.815 +
  36.816 +\newpage
  36.817 +
  36.818 +\subsection{Symbolic expressions}
  36.819 +
  36.820 +A {\it symbolic expression} is a rule for computing a single symbolic
  36.821 +value represented as a character string.
  36.822 +
  36.823 +The primary symbolic expression may be a string literal, dummy index,
  36.824 +unsubscripted parameter, subscripted parameter, built-in function
  36.825 +reference, conditional symbolic expression, or another symbolic
  36.826 +expression enclosed in parentheses.
  36.827 +
  36.828 +It is also allowed to use a numeric expression as the primary symbolic
  36.829 +expression, in which case the resultant value of the numeric expression
  36.830 +is automatically converted to the symbolic type.
  36.831 +
  36.832 +\medskip
  36.833 +
  36.834 +\noindent{\bf Examples}
  36.835 +
  36.836 +\medskip
  36.837 +
  36.838 +\noindent
  36.839 +\begin{tabular}{@{}ll@{}}
  36.840 +\verb|'May 2003'|&(string literal)\\
  36.841 +\verb|j|&(dummy index)\\
  36.842 +\verb|p|&(unsubscripted parameter)\\
  36.843 +\verb|s['abc',j+1]|&(subscripted parameter)\\
  36.844 +\verb|substr(name[i],k+1,3)|&(function reference)\\
  36.845 +\verb|if i in I then s[i,j] else t[i+1]|&(conditional expression)\\
  36.846 +\verb|((10 * b[i,j]) & '.bis')|&(parenthesized expression)\\
  36.847 +\end{tabular}
  36.848 +
  36.849 +\medskip
  36.850 +
  36.851 +More general symbolic expressions containing two or more primary
  36.852 +symbolic expressions may be constructed by using the concatenation
  36.853 +operator.
  36.854 +
  36.855 +\medskip
  36.856 +
  36.857 +\noindent{\bf Examples}
  36.858 +
  36.859 +\medskip
  36.860 +
  36.861 +\noindent\verb|'abc[' & i & ',' & j & ']'|
  36.862 +
  36.863 +\noindent\verb|"from " & city[i] & " to " & city[j]|
  36.864 +
  36.865 +\medskip
  36.866 +
  36.867 +The principles of evaluation of symbolic expressions are completely
  36.868 +analogous to the ones given for numeric expressions (see above).
  36.869 +
  36.870 +\subsubsection{Function references}
  36.871 +
  36.872 +In MathProg there exist the following built-in functions which may be
  36.873 +used in symbolic expressions:
  36.874 +
  36.875 +\medskip
  36.876 +
  36.877 +\begin{tabular}{@{}p{96pt}p{222pt}@{}}
  36.878 +{\tt substr(}$s${\tt,} $x${\tt)}&substring of $s$ starting from
  36.879 +position $x$\\
  36.880 +{\tt substr(}$s${\tt,} $x${\tt,} $y${\tt)}&substring of $s$ starting
  36.881 +from position $x$ and having length $y$\\
  36.882 +{\tt time2str(}$t${\tt,} $f${\tt)}&converting calendar time to
  36.883 +character string (for details see Subsection \ref{time2str}, page
  36.884 +\pageref{time2str})\\
  36.885 +\end{tabular}
  36.886 +
  36.887 +\medskip
  36.888 +
  36.889 +The first argument of {\tt substr} must be a symbolic expression while
  36.890 +its second and optional third arguments must be numeric expressions.
  36.891 +
  36.892 +The first argument of {\tt time2str} must be a numeric expression, and
  36.893 +its second argument must be a symbolic expression.
  36.894 +
  36.895 +The resultant value of the symbolic expression, which is a function
  36.896 +reference, is the result of applying the function to its arguments.
  36.897 +
  36.898 +\subsubsection{Symbolic operators}
  36.899 +
  36.900 +Currently in MathProg there exists the only symbolic operator:
  36.901 +
  36.902 +\medskip
  36.903 +
  36.904 +\noindent\hfil
  36.905 +{\tt s \& t}
  36.906 +
  36.907 +\medskip
  36.908 +
  36.909 +\noindent where $s$ and $t$ are symbolic expressions. This operator
  36.910 +means concatenation of its two symbolic operands, which are character
  36.911 +strings.
  36.912 +
  36.913 +\subsubsection{Hierarchy of operations}
  36.914 +
  36.915 +The following list shows the hierarchy of operations in symbolic
  36.916 +expressions:
  36.917 +
  36.918 +\medskip
  36.919 +
  36.920 +\noindent\hfil
  36.921 +\begin{tabular}{@{}ll@{}}
  36.922 +Operation&Hierarchy\\
  36.923 +\hline
  36.924 +Evaluation of numeric operations&1st-7th\\
  36.925 +Concatenation ({\tt\&})&8th\\
  36.926 +Conditional evaluation ({\tt if} \dots {\tt then} \dots {\tt else})&
  36.927 +7th\\
  36.928 +\end{tabular}
  36.929 +
  36.930 +\medskip
  36.931 +
  36.932 +This hierarchy has the same meaning as was explained above for numeric
  36.933 +expressions (see Subsection \ref{hierarchy}, page \pageref{hierarchy}).
  36.934 +
  36.935 +\subsection{Indexing expressions and dummy indices}
  36.936 +\label{indexing}
  36.937 +
  36.938 +An {\it indexing expression} is an auxiliary construction, which
  36.939 +specifies a plain set of $n$-tuples and introduces dummy indices. It
  36.940 +has two syntactic forms:
  36.941 +
  36.942 +\medskip
  36.943 +
  36.944 +\noindent\hspace{73.5pt}
  36.945 +{\tt\{} {\it entry}$_1${\tt,} {\it entry}$_2${\tt,} \dots{\tt,}
  36.946 +{\it entry}$_m$ {\tt\}}
  36.947 +
  36.948 +\medskip
  36.949 +
  36.950 +\noindent\hfil
  36.951 +{\tt\{} {\it entry}$_1${\tt,} {\it entry}$_2${\tt,} \dots{\tt,}
  36.952 +{\it entry}$_m$ {\tt:} {\it predicate} {\tt\}}
  36.953 +
  36.954 +\medskip
  36.955 +
  36.956 +\noindent where {\it entry}{$_1$}, {\it entry}{$_2$}, \dots,
  36.957 +{\it entry}{$_m$} are indexing entries, {\it predicate} is a logical
  36.958 +expression that specifies an optional predicate (logical condition).
  36.959 +
  36.960 +Each {\it indexing entry} in the indexing expression has one of the
  36.961 +following three forms:
  36.962 +
  36.963 +\medskip
  36.964 +
  36.965 +\noindent\hspace{123pt}
  36.966 +$i$ {\tt in} $S$
  36.967 +
  36.968 +\medskip
  36.969 +
  36.970 +\noindent\hfil
  36.971 +{\tt(}$i_1${\tt,} $i_2${\tt,} \dots{\tt,}$i_n${\tt)} {\tt in} $S$
  36.972 +
  36.973 +\medskip
  36.974 +
  36.975 +\noindent\hspace{123pt}
  36.976 +$S$
  36.977 +
  36.978 +\medskip
  36.979 +
  36.980 +\noindent where $i_1$, $i_2$, \dots, $i_n$ are indices, $S$ is a set
  36.981 +expression (discussed in the next section) that specifies the basic set.
  36.982 +
  36.983 +The number of indices in the indexing entry must be the same as the
  36.984 +dimension of the basic set $S$, i.e. if $S$ consists of 1-tuples, the
  36.985 +first form must be used, and if $S$ consists of $n$-tuples, where
  36.986 +$n>1$, the second form must be used.
  36.987 +
  36.988 +If the first form of the indexing entry is used, the index $i$ can be
  36.989 +a dummy index only (see below). If the second form is used, the indices
  36.990 +$i_1$, $i_2$, \dots, $i_n$ can be either dummy indices or some numeric
  36.991 +or symbolic expressions, where at least one index must be a dummy index.
  36.992 +The third, reduced form of the indexing entry has the same effect as if
  36.993 +there were $i$ (if $S$ is 1-dimensional) or $i_1$, $i_2$, \dots, $i_n$
  36.994 +(if $S$ is $n$-dimensional) all specified as dummy indices.
  36.995 +
  36.996 +A {\it dummy index} is an auxiliary model object, which acts like an
  36.997 +individual variable. Values assigned to dummy indices are components of
  36.998 +$n$-tuples from basic sets, i.e. some numeric and symbolic quantities.
  36.999 +
 36.1000 +For referencing purposes dummy indices can be provided with symbolic
 36.1001 +names. However, unlike other model objects (sets, parameters, etc.)
 36.1002 +dummy indices need not be explicitly declared. Each {\it undeclared}
 36.1003 +symbolic name being used in the indexing position of an indexing entry
 36.1004 +is recognized as the symbolic name of corresponding dummy index.
 36.1005 +
 36.1006 +Symbolic names of dummy indices are valid only within the scope of the
 36.1007 +indexing expression, where the dummy indices were introduced. Beyond
 36.1008 +the scope the dummy indices are completely inaccessible, so the same
 36.1009 +symbolic names may be used for other purposes, in particular, to
 36.1010 +represent dummy indices in other indexing expressions.
 36.1011 +
 36.1012 +The scope of indexing expression, where implicit declarations of dummy
 36.1013 +indices are valid, depends on the context, in which the indexing
 36.1014 +expression is used:
 36.1015 +
 36.1016 +\begin{enumerate}
 36.1017 +\item If the indexing expression is used in iterated operator, its
 36.1018 +scope extends until the end of the integrand.
 36.1019 +\item If the indexing expression is used as a primary set expression,
 36.1020 +its scope extends until the end of that indexing expression.
 36.1021 +\item If the indexing expression is used to define the subscript domain
 36.1022 +in declarations of some model objects, its scope extends until the end
 36.1023 +of the corresponding statement.
 36.1024 +\end{enumerate}
 36.1025 +
 36.1026 +The indexing mechanism implemented by means of indexing expressions is
 36.1027 +best explained by some examples discussed below.
 36.1028 +
 36.1029 +Let there be given three sets:
 36.1030 +
 36.1031 +\medskip
 36.1032 +
 36.1033 +\noindent\hspace{33.5pt}
 36.1034 +$A=\{4,7,9\}$,
 36.1035 +
 36.1036 +\medskip
 36.1037 +
 36.1038 +\noindent\hfil
 36.1039 +$B=\{(1,Jan),(1,Feb),(2,Mar),(2,Apr),(3,May),(3,Jun)\}$,
 36.1040 +
 36.1041 +\medskip
 36.1042 +
 36.1043 +\noindent\hspace{33.5pt}
 36.1044 +$C=\{a,b,c\}$,
 36.1045 +
 36.1046 +\medskip
 36.1047 +
 36.1048 +\noindent where $A$ and $C$ consist of 1-tuples (singlets), $B$
 36.1049 +consists of 2-tuples (doublets). Consider the following indexing
 36.1050 +expression:
 36.1051 +
 36.1052 +\medskip
 36.1053 +
 36.1054 +\noindent\hfil
 36.1055 +{\tt\{i in A, (j,k) in B, l in C\}}
 36.1056 +
 36.1057 +\medskip
 36.1058 +
 36.1059 +\noindent where {\tt i}, {\tt j}, {\tt k}, and {\tt l} are dummy
 36.1060 +indices.
 36.1061 +
 36.1062 +Although MathProg is not a procedural language, for any indexing
 36.1063 +expression an equivalent algorithmic description can be given. In
 36.1064 +particular, the algorithmic description of the indexing expression
 36.1065 +above could look like follows:
 36.1066 +
 36.1067 +\medskip
 36.1068 +
 36.1069 +\noindent\hfil
 36.1070 +\begin{tabular}{@{}l@{}}
 36.1071 +{\bf for all} $i\in A$ {\bf do}\\
 36.1072 +\hspace{12pt}{\bf for all} $(j,k)\in B$ {\bf do}\\
 36.1073 +\hspace{24pt}{\bf for all} $l\in C$ {\bf do}\\
 36.1074 +\hspace{36pt}{\it action};\\
 36.1075 +\end{tabular}
 36.1076 +
 36.1077 +\newpage
 36.1078 +
 36.1079 +\noindent where the dummy indices $i$, $j$, $k$, $l$ are consecutively
 36.1080 +assigned corresponding components of $n$-tuples from the basic sets $A$,
 36.1081 +$B$, $C$, and {\it action} is some action that depends on the context,
 36.1082 +where the indexing expression is used. For example, if the action were
 36.1083 +printing current values of dummy indices, the printout would look like
 36.1084 +follows:
 36.1085 +
 36.1086 +\medskip
 36.1087 +
 36.1088 +\noindent\hfil
 36.1089 +\begin{tabular}{@{}llll@{}}
 36.1090 +$i=4$&$j=1$&$k=Jan$&$l=a$\\
 36.1091 +$i=4$&$j=1$&$k=Jan$&$l=b$\\
 36.1092 +$i=4$&$j=1$&$k=Jan$&$l=c$\\
 36.1093 +$i=4$&$j=1$&$k=Feb$&$l=a$\\
 36.1094 +$i=4$&$j=1$&$k=Feb$&$l=b$\\
 36.1095 +\multicolumn{4}{c}{.\ \ .\ \ .\ \ .\ \ .\ \ .\ \ .}\\
 36.1096 +$i=9$&$j=3$&$k=Jun$&$l=b$\\
 36.1097 +$i=9$&$j=3$&$k=Jun$&$l=c$\\
 36.1098 +\end{tabular}
 36.1099 +
 36.1100 +\medskip
 36.1101 +
 36.1102 +Let the example indexing expression be used in the following iterated
 36.1103 +operation:
 36.1104 +
 36.1105 +\medskip
 36.1106 +
 36.1107 +\noindent\hfil
 36.1108 +{\tt sum\{i in A, (j,k) in B, l in C\} p[i,j,k,l]}
 36.1109 +
 36.1110 +\medskip
 36.1111 +
 36.1112 +\noindent where {\tt p} is a 4-dimensional numeric parameter or some
 36.1113 +numeric expression whose resultant value depends on {\tt i}, {\tt j},
 36.1114 +{\tt k}, and {\tt l}. In this case the action is summation, so the
 36.1115 +resultant value of the primary numeric expression is:
 36.1116 +$$\sum_{i\in A,(j,k)\in B,l\in C}(p_{ijkl}).$$
 36.1117 +
 36.1118 +Now let the example indexing expression be used as a primary set
 36.1119 +expression. In this case the action is gathering all 4-tuples
 36.1120 +(quadruplets) of the form $(i,j,k,l)$ in one set, so the resultant
 36.1121 +value of such operation is simply the Cartesian product of the basic
 36.1122 +sets:
 36.1123 +$$A\times B\times C=\{(i,j,k,l):i\in A,(j,k)\in B,l\in C\}.$$
 36.1124 +Note that in this case the same indexing expression might be written in
 36.1125 +the reduced form:
 36.1126 +
 36.1127 +\medskip
 36.1128 +
 36.1129 +\noindent\hfil
 36.1130 +{\tt\{A, B, C\}}
 36.1131 +
 36.1132 +\medskip
 36.1133 +
 36.1134 +\noindent because the dummy indices $i$, $j$, $k$, and $l$ are not
 36.1135 +referenced and therefore their symbolic names need not be specified.
 36.1136 +
 36.1137 +Finally, let the example indexing expression be used as the subscript
 36.1138 +domain in the declaration of a 4-dimensional model object, say,
 36.1139 +a numeric parameter:
 36.1140 +
 36.1141 +\medskip
 36.1142 +
 36.1143 +\noindent\hfil
 36.1144 +{\tt param p\{i in A, (j,k) in B, l in C\}} \dots {\tt;}
 36.1145 +
 36.1146 +\medskip
 36.1147 +
 36.1148 +\noindent In this case the action is generating the parameter members,
 36.1149 +where each member has the form $p[i,j,k,l]$.
 36.1150 +
 36.1151 +As was said above, some indices in the second form of indexing entries
 36.1152 +may be numeric or symbolic expressions, not only dummy indices. In this
 36.1153 +case resultant values of such expressions play role of some logical
 36.1154 +conditions to select only that $n$-tuples from the Cartesian product of
 36.1155 +basic sets that satisfy these conditions.
 36.1156 +
 36.1157 +Consider, for example, the following indexing expression:
 36.1158 +
 36.1159 +\medskip
 36.1160 +
 36.1161 +\noindent\hfil
 36.1162 +{\tt\{i in A, (i-1,k) in B, l in C\}}
 36.1163 +
 36.1164 +\medskip
 36.1165 +
 36.1166 +\noindent where {\tt i}, {\tt k}, {\tt l} are dummy indices, and
 36.1167 +{\tt i-1} is a numeric expression. The algorithmic decsription of this
 36.1168 +indexing expression is the following:
 36.1169 +
 36.1170 +\medskip
 36.1171 +
 36.1172 +\noindent\hfil
 36.1173 +\begin{tabular}{@{}l@{}}
 36.1174 +{\bf for all} $i\in A$ {\bf do}\\
 36.1175 +\hspace{12pt}{\bf for all} $(j,k)\in B$ {\bf and} $j=i-1$ {\bf do}\\
 36.1176 +\hspace{24pt}{\bf for all} $l\in C$ {\bf do}\\
 36.1177 +\hspace{36pt}{\it action};\\
 36.1178 +\end{tabular}
 36.1179 +
 36.1180 +\medskip
 36.1181 +
 36.1182 +\noindent Thus, if this indexing expression were used as a primary set
 36.1183 +expression, the resultant set would be the following:
 36.1184 +$$\{(4,May,a),(4,May,b),(4,May,c),(4,Jun,a),(4,Jun,b),(4,Jun,c)\}.$$
 36.1185 +Should note that in this case the resultant set consists of 3-tuples,
 36.1186 +not of 4-tuples, because in the indexing expression there is no dummy
 36.1187 +index that corresponds to the first component of 2-tuples from the set
 36.1188 +$B$.
 36.1189 +
 36.1190 +The general rule is: the number of components of $n$-tuples defined by
 36.1191 +an indexing expression is the same as the number of dummy indices in
 36.1192 +that expression, where the correspondence between dummy indices and
 36.1193 +components on $n$-tuples in the resultant set is positional, i.e. the
 36.1194 +first dummy index corresponds to the first component, the second dummy
 36.1195 +index corresponds to the second component, etc.
 36.1196 +
 36.1197 +In some cases it is needed to select a subset from the Cartesian
 36.1198 +product of some sets. This may be attained by using an optional logical
 36.1199 +predicate, which is specified in the indexing expression.
 36.1200 +
 36.1201 +Consider, for example, the following indexing expression:
 36.1202 +
 36.1203 +\medskip
 36.1204 +
 36.1205 +\noindent\hfil
 36.1206 +{\tt\{i in A, (j,k) in B, l in C: i <= 5 and k <> 'Mar'\}}
 36.1207 +
 36.1208 +\medskip
 36.1209 +
 36.1210 +\noindent where the logical expression following the colon is a
 36.1211 +predicate. The algorithmic description of this indexing expression is
 36.1212 +the following:
 36.1213 +
 36.1214 +\medskip
 36.1215 +
 36.1216 +\noindent\hfil
 36.1217 +\begin{tabular}{@{}l@{}}
 36.1218 +{\bf for all} $i\in A$ {\bf do}\\
 36.1219 +\hspace{12pt}{\bf for all} $(j,k)\in B$ {\bf do}\\
 36.1220 +\hspace{24pt}{\bf for all} $l\in C$ {\bf do}\\
 36.1221 +\hspace{36pt}{\bf if} $i\leq 5$ {\bf and} $l\neq`Mar'$ {\bf then}\\
 36.1222 +\hspace{48pt}{\it action};\\
 36.1223 +\end{tabular}
 36.1224 +
 36.1225 +\medskip
 36.1226 +
 36.1227 +\noindent Thus, if this indexing expression were used as a primary set
 36.1228 +expression, the resultant set would be the following:
 36.1229 +$$\{(4,1,Jan,a),(4,1,Feb,a),(4,2,Apr,a),\dots,(4,3,Jun,c)\}.$$
 36.1230 +
 36.1231 +If no predicate is specified in the indexing expression, one, which
 36.1232 +takes on the value {\it true}, is assumed.
 36.1233 +
 36.1234 +\subsection{Set expressions}
 36.1235 +
 36.1236 +A {\it set expression} is a rule for computing an elemental set, i.e.
 36.1237 +a collection of $n$-tuples, where components of $n$-tuples are numeric
 36.1238 +and symbolic quantities.
 36.1239 +
 36.1240 +The primary set expression may be a literal set, unsubscripted set,
 36.1241 +subscripted set, ``arithmetic'' set, indexing expression, iterated set
 36.1242 +expression, conditional set expression, or another set expression
 36.1243 +enclosed in parentheses.
 36.1244 +
 36.1245 +\medskip
 36.1246 +
 36.1247 +\noindent{\bf Examples}
 36.1248 +
 36.1249 +\medskip
 36.1250 +
 36.1251 +\noindent
 36.1252 +\begin{tabular}{@{}ll@{}}
 36.1253 +\verb|{(123,'aa'), (i,'bb'), (j-1,'cc')}|&(literal set)\\
 36.1254 +\verb|I|&(unsubscripted set)\\
 36.1255 +\verb|S[i-1,j+1]|&(subscripted set)\\
 36.1256 +\verb|1..t-1 by 2|&(``arithmetic'' set)\\
 36.1257 +\verb|{t in 1..T, (t+1,j) in S: (t,j) in F}|&(indexing expression)\\
 36.1258 +\verb|setof{i in I, j in J}(i+1,j-1)|&(iterated expression)\\
 36.1259 +\verb|if i < j then S[i] else F diff S[j]|&(conditional expression)\\
 36.1260 +\verb|(1..10 union 21..30)|&(parenthesized expression)\\
 36.1261 +\end{tabular}
 36.1262 +
 36.1263 +\medskip
 36.1264 +
 36.1265 +More general set expressions containing two or more primary set
 36.1266 +expressions may be constructed by using certain set operators.
 36.1267 +
 36.1268 +\medskip
 36.1269 +
 36.1270 +\noindent{\bf Examples}
 36.1271 +
 36.1272 +\medskip
 36.1273 +
 36.1274 +\noindent\verb|(A union B) inter (I cross J)|
 36.1275 +
 36.1276 +\noindent
 36.1277 +\verb|1..10 cross (if i < j then {'a', 'b', 'c'} else {'d', 'e', 'f'})|
 36.1278 +
 36.1279 +\subsubsection{Literal sets}
 36.1280 +
 36.1281 +A {\it literal set} is a primary set expression, which has the
 36.1282 +following two syntactic forms:
 36.1283 +
 36.1284 +\medskip
 36.1285 +
 36.1286 +\noindent\hspace{39pt}
 36.1287 +{\tt\{}$e_1${\tt,} $e_2${\tt,} \dots{\tt,} $e_m${\tt\}}
 36.1288 +
 36.1289 +\medskip
 36.1290 +
 36.1291 +\noindent\hfil
 36.1292 +{\tt\{(}$e_{11}${\tt,} \dots{\tt,} $e_{1n}${\tt),}
 36.1293 +{\tt(}$e_{21}${\tt,} \dots{\tt,} $e_{2n}${\tt),} \dots{\tt,}
 36.1294 +{\tt(}$e_{m1}${\tt,} \dots{\tt,} $e_{mn}${\tt)\}}
 36.1295 +
 36.1296 +\medskip
 36.1297 +
 36.1298 +\noindent where $e_1$, \dots, $e_m$, $e_{11}$, \dots, $e_{mn}$ are
 36.1299 +numeric or symbolic expressions.
 36.1300 +
 36.1301 +If the first form is used, the resultant set consists of 1-tuples
 36.1302 +(singlets) enumerated within the curly braces. It is allowed to specify
 36.1303 +an empty set as {\tt\{\ \}}, which has no 1-tuples. If the second form
 36.1304 +is used, the resultant set consists of $n$-tuples enumerated within the
 36.1305 +curly braces, where a particular $n$-tuple consists of corresponding
 36.1306 +components enumerated within the parentheses. All $n$-tuples must have
 36.1307 +the same number of components.
 36.1308 +
 36.1309 +\subsubsection{Unsubscripted sets}
 36.1310 +
 36.1311 +If the primary set expression is an unsubscripted set (which must be
 36.1312 +0-dimen\-sional), the resultant set is an elemental set associated with
 36.1313 +the corresponding set object.
 36.1314 +
 36.1315 +\newpage
 36.1316 +
 36.1317 +\subsubsection{Subscripted sets}
 36.1318 +
 36.1319 +The primary set expression, which refers to a subscripted set, has the
 36.1320 +following syntactic form:
 36.1321 +
 36.1322 +\medskip
 36.1323 +
 36.1324 +\noindent\hfil
 36.1325 +{\it name}{\tt[}$i_1${\tt,} $i_2${\tt,} \dots{\tt,} $i_n${\tt]}
 36.1326 +
 36.1327 +\medskip
 36.1328 +
 36.1329 +\noindent where {\it name} is the symbolic name of the set object,
 36.1330 +$i_1$, $i_2$, \dots, $i_n$ are subscripts.
 36.1331 +
 36.1332 +Each subscript must be a numeric or symbolic expression. The number of
 36.1333 +subscripts in the subscript list must be the same as the dimension of
 36.1334 +the set object with which the subscript list is associated.
 36.1335 +
 36.1336 +Actual values of subscript expressions are used to identify a
 36.1337 +particular member of the set object that determines the resultant set.
 36.1338 +
 36.1339 +\subsubsection{``Arithmetic'' sets}
 36.1340 +
 36.1341 +The primary set expression, which is an ``arithmetic'' set, has the
 36.1342 +following two syntactic forms:
 36.1343 +
 36.1344 +\medskip
 36.1345 +
 36.1346 +\noindent\hfil
 36.1347 +$t_0$ {\tt..} $t_1$ {\tt by} $\delta t$
 36.1348 +
 36.1349 +\medskip
 36.1350 +
 36.1351 +\noindent\hspace{138.5pt}
 36.1352 +$t_0$ {\tt..} $t_1$
 36.1353 +
 36.1354 +\medskip
 36.1355 +
 36.1356 +\noindent where $t_0$, $t_1$, and $\delta t$ are numeric expressions
 36.1357 +(the value of $\delta t$ must not be zero). The second form is
 36.1358 +equivalent to the first form, where $\delta t=1$.
 36.1359 +
 36.1360 +If $\delta t>0$, the resultant set is determined as follows:
 36.1361 +$$\{t:\exists k\in{\cal Z}(t=t_0+k\delta t,\ t_0\leq t\leq t_1)\}.$$
 36.1362 +Otherwise, if $\delta t<0$, the resultant set is determined as follows:
 36.1363 +$$\{t:\exists k\in{\cal Z}(t=t_0+k\delta t,\ t_1\leq t\leq t_0)\}.$$
 36.1364 +
 36.1365 +\subsubsection{Indexing expressions}
 36.1366 +
 36.1367 +If the primary set expression is an indexing expression, the resultant
 36.1368 +set is determined as described above in Subsection \ref{indexing}, page
 36.1369 +\pageref{indexing}.
 36.1370 +
 36.1371 +\subsubsection{Iterated expressions}
 36.1372 +
 36.1373 +An {\it iterated set expression} is a primary set expression, which has
 36.1374 +the following syntactic form:
 36.1375 +
 36.1376 +\medskip
 36.1377 +
 36.1378 +\noindent\hfil
 36.1379 +{\tt setof} {\it indexing-expression} {\it integrand}
 36.1380 +
 36.1381 +\medskip
 36.1382 +
 36.1383 +\noindent where {\it indexing-expression} is an indexing expression,
 36.1384 +which introduces dummy indices and controls iterating, {\it integrand}
 36.1385 +is either a single numeric or symbolic expression or a list of numeric
 36.1386 +and symbolic expressions separated by commae and enclosed in
 36.1387 +parentheses.
 36.1388 +
 36.1389 +If the integrand is a single numeric or symbolic expression, the
 36.1390 +resultant set consists of 1-tuples and is determined as follows:
 36.1391 +$$\{x:(i_1,\dots,i_n)\in\Delta\},$$
 36.1392 +\noindent where $x$ is a value of the integrand, $i_1$, \dots, $i_n$
 36.1393 +are dummy indices introduced in the indexing expression, $\Delta$ is
 36.1394 +the domain, a set of $n$-tuples specified by the indexing expression,
 36.1395 +which defines particular values assigned to the dummy indices on
 36.1396 +performing the iterated operation.
 36.1397 +
 36.1398 +If the integrand is a list containing $m$ numeric and symbolic
 36.1399 +expressions, the resultant set consists of $m$-tuples and is determined
 36.1400 +as follows:
 36.1401 +$$\{(x_1,\dots,x_m):(i_1,\dots,i_n)\in\Delta\},$$
 36.1402 +where $x_1$, \dots, $x_m$ are values of the expressions in the
 36.1403 +integrand list, $i_1$, \dots, $i_n$ and $\Delta$ have the same meaning
 36.1404 +as above.
 36.1405 +
 36.1406 +\subsubsection{Conditional expressions}
 36.1407 +
 36.1408 +A {\it conditional set expression} is a primary set expression that has
 36.1409 +the following syntactic form:
 36.1410 +
 36.1411 +\medskip
 36.1412 +
 36.1413 +\noindent\hfil
 36.1414 +{\tt if} $b$ {\tt then} $X$ {\tt else} $Y$
 36.1415 +
 36.1416 +\medskip
 36.1417 +
 36.1418 +\noindent where $b$ is an logical expression, $X$ and $Y$ are set
 36.1419 +expressions, which must define sets of the same dimension.
 36.1420 +
 36.1421 +The resultant value of the conditional expression depends on the value
 36.1422 +of the logical expression that follows the keyword {\tt if}. If it
 36.1423 +takes on the value {\it true}, the resultant set is the value of the
 36.1424 +expression that follows the keyword {\tt then}. Otherwise, if the
 36.1425 +logical expression takes on the value {\it false}, the resultant set is
 36.1426 +the value of the expression that follows the keyword {\tt else}.
 36.1427 +
 36.1428 +\subsubsection{Parenthesized expressions}
 36.1429 +
 36.1430 +Any set expression may be enclosed in parentheses that syntactically
 36.1431 +makes it a primary set expression.
 36.1432 +
 36.1433 +Parentheses may be used in set expressions, as in algebra, to specify
 36.1434 +the desired order in which operations are to be performed. Where
 36.1435 +parentheses are used, the expression within the parentheses is
 36.1436 +evaluated before the resultant value is used.
 36.1437 +
 36.1438 +The resultant value of the parenthesized expression is the same as the
 36.1439 +value of the expression enclosed within parentheses.
 36.1440 +
 36.1441 +\subsubsection{Set operators}
 36.1442 +
 36.1443 +In MathProg there exist the following set operators, which may be used
 36.1444 +in set expressions:
 36.1445 +
 36.1446 +\medskip
 36.1447 +
 36.1448 +\begin{tabular}{@{}p{96pt}p{222pt}@{}}
 36.1449 +$X$ {\tt union} $Y$&union $X\cup Y$\\
 36.1450 +$X$ {\tt diff} $Y$&difference $X\backslash Y$\\
 36.1451 +$X$ {\tt symdiff} $Y$&symmetric difference $X\oplus Y$\\
 36.1452 +$X$ {\tt inter} $Y$&intersection $X\cap Y$\\
 36.1453 +$X$ {\tt cross} $Y$&cross (Cartesian) product $X\times Y$\\
 36.1454 +\end{tabular}
 36.1455 +
 36.1456 +\medskip
 36.1457 +
 36.1458 +\noindent where $X$ and Y are set expressions, which must define sets
 36.1459 +of the identical dimension (except the Cartesian product).
 36.1460 +
 36.1461 +If the expression includes more than one set operator, all operators
 36.1462 +are performed from left to right according to the hierarchy of
 36.1463 +operations (see below).
 36.1464 +
 36.1465 +The resultant value of the expression, which contains set operators, is
 36.1466 +the result of applying the operators to their operands.
 36.1467 +
 36.1468 +The dimension of the resultant set, i.e. the dimension of $n$-tuples,
 36.1469 +of which the resultant set consists of, is the same as the dimension of
 36.1470 +the operands, except the Cartesian product, where the dimension of the
 36.1471 +resultant set is the sum of the dimensions of its operands.
 36.1472 +
 36.1473 +\subsubsection{Hierarchy of operations}
 36.1474 +
 36.1475 +The following list shows the hierarchy of operations in set
 36.1476 +expressions:
 36.1477 +
 36.1478 +\medskip
 36.1479 +
 36.1480 +\noindent\hfil
 36.1481 +\begin{tabular}{@{}ll@{}}
 36.1482 +Operation&Hierarchy\\
 36.1483 +\hline
 36.1484 +Evaluation of numeric operations&1st-7th\\
 36.1485 +Evaluation of symbolic operations&8th-9th\\
 36.1486 +Evaluation of iterated or ``arithmetic'' set ({\tt setof}, {\tt..})&
 36.1487 +10th\\
 36.1488 +Cartesian product ({\tt cross})&11th\\
 36.1489 +Intersection ({\tt inter})&12th\\
 36.1490 +Union and difference ({\tt union}, {\tt diff}, {\tt symdiff})&13th\\
 36.1491 +Conditional evaluation ({\tt if} \dots {\tt then} \dots {\tt else})&
 36.1492 +14th\\
 36.1493 +\end{tabular}
 36.1494 +
 36.1495 +\medskip
 36.1496 +
 36.1497 +This hierarchy has the same meaning as was explained above for numeric
 36.1498 +expressions (see Subsection \ref{hierarchy}, page \pageref{hierarchy}).
 36.1499 +
 36.1500 +\subsection{Logical expressions}
 36.1501 +
 36.1502 +A {\it logical expression} is a rule for computing a single logical
 36.1503 +value, which can be either {\it true} or {\it false}.
 36.1504 +
 36.1505 +The primary logical expression may be a numeric expression, relational
 36.1506 +expression, iterated logical expression, or another logical expression
 36.1507 +enclosed in parentheses.
 36.1508 +
 36.1509 +\medskip
 36.1510 +
 36.1511 +\noindent{\bf Examples}
 36.1512 +
 36.1513 +\medskip
 36.1514 +
 36.1515 +\noindent
 36.1516 +\begin{tabular}{@{}ll@{}}
 36.1517 +\verb|i+1|&(numeric expression)\\
 36.1518 +\verb|a[i,j] < 1.5|&(relational expression)\\
 36.1519 +\verb|s[i+1,j-1] <> 'Mar'|&(relational expression)\\
 36.1520 +\verb|(i+1,'Jan') not in I cross J|&(relational expression)\\
 36.1521 +\verb|S union T within A[i] inter B[j]|&(relational expression)\\
 36.1522 +\verb|forall{i in I, j in J} a[i,j] < .5 * b|&(iterated expression)\\
 36.1523 +\verb|(a[i,j] < 1.5 or b[i] >= a[i,j])|&(parenthesized expression)\\
 36.1524 +\end{tabular}
 36.1525 +
 36.1526 +\medskip
 36.1527 +
 36.1528 +More general logical expressions containing two or more primary logical
 36.1529 +expressions may be constructed by using certain logical operators.
 36.1530 +
 36.1531 +\newpage
 36.1532 +
 36.1533 +\noindent{\bf Examples}
 36.1534 +
 36.1535 +\medskip
 36.1536 +
 36.1537 +\noindent\verb|not (a[i,j] < 1.5 or b[i] >= a[i,j]) and (i,j) in S|
 36.1538 +
 36.1539 +\noindent\verb|(i,j) in S or (i,j) not in T diff U|
 36.1540 +
 36.1541 +\subsubsection{Numeric expressions}
 36.1542 +
 36.1543 +The resultant value of the primary logical expression, which is a
 36.1544 +numeric expression, is {\it true}, if the resultant value of the
 36.1545 +numeric expression is non-zero. Otherwise the resultant value of the
 36.1546 +logical expression is {\it false}.
 36.1547 +
 36.1548 +\subsubsection{Relational operators}
 36.1549 +
 36.1550 +In MathProg there exist the following relational operators, which may
 36.1551 +be used in logical expressions:
 36.1552 +
 36.1553 +\medskip
 36.1554 +
 36.1555 +\begin{tabular}{@{}ll@{}}
 36.1556 +$x$ {\tt<} $y$&test on $x<y$\\
 36.1557 +$x$ {\tt<=} $y$&test on $x\leq y$\\
 36.1558 +$x$ {\tt=} $y$, $x$ {\tt==} $y$&test on $x=y$\\
 36.1559 +$x$ {\tt>=} $y$&test on $x\geq y$\\
 36.1560 +$x$ {\tt>} $y$&test on $x>y$\\
 36.1561 +$x$ {\tt<>} $y$, $x$ {\tt!=} $y$&test on $x\neq y$\\
 36.1562 +$x$ {\tt in} $Y$&test on $x\in Y$\\
 36.1563 +{\tt(}$x_1${\tt,}\dots{\tt,}$x_n${\tt)} {\tt in} $Y$&test on
 36.1564 +$(x_1,\dots,x_n)\in Y$\\
 36.1565 +$x$ {\tt not} {\tt in} $Y$, $x$ {\tt!in} $Y$&test on $x\not\in Y$\\
 36.1566 +{\tt(}$x_1${\tt,}\dots{\tt,}$x_n${\tt)} {\tt not} {\tt in} $Y$,
 36.1567 +{\tt(}$x_1${\tt,}\dots{\tt,}$x_n${\tt)} {\tt !in} $Y$&test on
 36.1568 +$(x_1,\dots,x_n)\not\in Y$\\
 36.1569 +$X$ {\tt within} $Y$&test on $X\subseteq Y$\\
 36.1570 +$X$ {\tt not} {\tt within} $Y$, $X$ {\tt !within} $Y$&test on
 36.1571 +$X\not\subseteq Y$\\
 36.1572 +\end{tabular}
 36.1573 +
 36.1574 +\medskip
 36.1575 +
 36.1576 +\noindent where $x$, $x_1$, \dots, $x_n$, $y$ are numeric or symbolic
 36.1577 +expressions, $X$ and $Y$ are set expression.
 36.1578 +
 36.1579 +{\it Notes:}
 36.1580 +
 36.1581 +1. In the operations {\tt in}, {\tt not in}, and {\tt !in} the
 36.1582 +number of components in the first operands must be the same as the
 36.1583 +dimension of the second operand.
 36.1584 +
 36.1585 +2. In the operations {\tt within}, {\tt not within}, and {\tt !within}
 36.1586 +both operands must have identical dimension.
 36.1587 +
 36.1588 +All the relational operators listed above have their conventional
 36.1589 +mathematical meaning. The resultant value is {\it true}, if
 36.1590 +corresponding relation is satisfied for its operands, otherwise
 36.1591 +{\it false}. (Note that symbolic values are ordered lexicographically,
 36.1592 +and any numeric value precedes any symbolic value.)
 36.1593 +
 36.1594 +\subsubsection{Iterated expressions}
 36.1595 +
 36.1596 +An {\it iterated logical expression} is a primary logical expression,
 36.1597 +which has the following syntactic form:
 36.1598 +
 36.1599 +\medskip
 36.1600 +
 36.1601 +\noindent\hfil
 36.1602 +{\it iterated-operator} {\it indexing-expression} {\it integrand}
 36.1603 +
 36.1604 +\medskip
 36.1605 +
 36.1606 +\noindent where {\it iterated-operator} is the symbolic name of the
 36.1607 +iterated operator to be performed (see below), {\it indexing-expression}
 36.1608 +is an indexing expression which introduces dummy indices and controls
 36.1609 +iterating, {\it integrand} is a numeric expression that participates in
 36.1610 +the operation.
 36.1611 +
 36.1612 +In MathProg there exist two iterated operators, which may be used in
 36.1613 +logical expressions:
 36.1614 +
 36.1615 +\medskip
 36.1616 +
 36.1617 +\noindent\hfil
 36.1618 +\begin{tabular}{@{}lll@{}}
 36.1619 +{\tt forall}&$\forall$-quantification&$\displaystyle
 36.1620 +\forall(i_1,\dots,i_n)\in\Delta[f(i_1,\dots,i_n)],$\\
 36.1621 +{\tt exists}&$\exists$-quantification&$\displaystyle
 36.1622 +\exists(i_1,\dots,i_n)\in\Delta[f(i_1,\dots,i_n)],$\\
 36.1623 +\end{tabular}
 36.1624 +
 36.1625 +\medskip
 36.1626 +
 36.1627 +\noindent where $i_1$, \dots, $i_n$ are dummy indices introduced in
 36.1628 +the indexing expression, $\Delta$ is the domain, a set of $n$-tuples
 36.1629 +specified by the indexing expression which defines particular values
 36.1630 +assigned to the dummy indices on performing the iterated operation,
 36.1631 +$f(i_1,\dots,i_n)$ is the integrand, a logical expression whose
 36.1632 +resultant value depends on the dummy indices.
 36.1633 +
 36.1634 +For $\forall$-quantification the resultant value of the iterated
 36.1635 +logical expression is {\it true}, if the value of the integrand is
 36.1636 +{\it true} for all $n$-tuples contained in the domain, otherwise
 36.1637 +{\it false}.
 36.1638 +
 36.1639 +For $\exists$-quantification the resultant value of the iterated
 36.1640 +logical expression is {\it false}, if the value of the integrand is
 36.1641 +{\it false} for all $n$-tuples contained in the domain, otherwise
 36.1642 +{\it true}.
 36.1643 +
 36.1644 +\subsubsection{Parenthesized expressions}
 36.1645 +
 36.1646 +Any logical expression may be enclosed in parentheses that
 36.1647 +syntactically makes it a primary logical expression.
 36.1648 +
 36.1649 +Parentheses may be used in logical expressions, as in algebra, to
 36.1650 +specify the desired order in which operations are to be performed.
 36.1651 +Where parentheses are used, the expression within the parentheses is
 36.1652 +evaluated before the resultant value is used.
 36.1653 +
 36.1654 +The resultant value of the parenthesized expression is the same as the
 36.1655 +value of the expression enclosed within parentheses.
 36.1656 +
 36.1657 +\subsubsection{Logical operators}
 36.1658 +
 36.1659 +In MathProg there exist the following logical operators, which may be
 36.1660 +used in logical expressions:
 36.1661 +
 36.1662 +\medskip
 36.1663 +
 36.1664 +\begin{tabular}{@{}p{96pt}p{222pt}@{}}
 36.1665 +{\tt not} $x$, {\tt!}$x$&negation $\neg\ x$\\
 36.1666 +$x$ {\tt and} $y$, $x$ {\tt\&\&} $y$&conjunction (logical ``and'')
 36.1667 +$x\;\&\;y$\\
 36.1668 +$x$ {\tt or} $y$, $x$ {\tt||} $y$&disjunction (logical ``or'')
 36.1669 +$x\vee y$\\
 36.1670 +\end{tabular}
 36.1671 +
 36.1672 +\medskip
 36.1673 +
 36.1674 +\noindent where $x$ and $y$ are logical expressions.
 36.1675 +
 36.1676 +If the expression includes more than one logical operator, all
 36.1677 +operators are performed from left to right according to the hierarchy
 36.1678 +of the operations (see below). The resultant value of the expression,
 36.1679 +which contains logical operators, is the result of applying the
 36.1680 +operators to their operands.
 36.1681 +
 36.1682 +\subsubsection{Hierarchy of operations}
 36.1683 +
 36.1684 +The following list shows the hierarchy of operations in logical
 36.1685 +expressions:
 36.1686 +
 36.1687 +\medskip
 36.1688 +
 36.1689 +\noindent\hfil
 36.1690 +\begin{tabular}{@{}ll@{}}
 36.1691 +Operation&Hierarchy\\
 36.1692 +\hline
 36.1693 +Evaluation of numeric operations&1st-7th\\
 36.1694 +Evaluation of symbolic operations&8th-9th\\
 36.1695 +Evaluation of set operations&10th-14th\\
 36.1696 +Relational operations ({\tt<}, {\tt<=}, etc.)&15th\\
 36.1697 +Negation ({\tt not}, {\tt!})&16th\\
 36.1698 +Conjunction ({\tt and}, {\tt\&\&})&17th\\
 36.1699 +$\forall$- and $\exists$-quantification ({\tt forall}, {\tt exists})&
 36.1700 +18th\\
 36.1701 +Disjunction ({\tt or}, {\tt||})&19th\\
 36.1702 +\end{tabular}
 36.1703 +
 36.1704 +\medskip
 36.1705 +
 36.1706 +This hierarchy has the same meaning as was explained above for numeric
 36.1707 +expressions (see Subsection \ref{hierarchy}, page \pageref{hierarchy}).
 36.1708 +
 36.1709 +\subsection{Linear expressions}
 36.1710 +
 36.1711 +An {\it linear expression} is a rule for computing so called
 36.1712 +a {\it linear form} or simply a {\it formula}, which is a linear (or
 36.1713 +affine) function of elemental variables.
 36.1714 +
 36.1715 +The primary linear expression may be an unsubscripted variable,
 36.1716 +subscripted variable, iterated linear expression, conditional linear
 36.1717 +expression, or another linear expression enclosed in parentheses.
 36.1718 +
 36.1719 +It is also allowed to use a numeric expression as the primary linear
 36.1720 +expression, in which case the resultant value of the numeric expression
 36.1721 +is automatically converted to a formula that includes the constant term
 36.1722 +only.
 36.1723 +
 36.1724 +\medskip
 36.1725 +
 36.1726 +\noindent{\bf Examples}
 36.1727 +
 36.1728 +\medskip
 36.1729 +
 36.1730 +\noindent
 36.1731 +\begin{tabular}{@{}ll@{}}
 36.1732 +\verb|z|&(unsubscripted variable)\\
 36.1733 +\verb|x[i,j]|&(subscripted variable)\\
 36.1734 +\verb|sum{j in J} (a[i] * x[i,j] + 3 * y)|&(iterated expression)\\
 36.1735 +\verb|if i in I then x[i,j] else 1.5 * z + 3|&(conditional expression)\\
 36.1736 +\verb|(a[i,j] * x[i,j] + y[i-1] + .1)|&(parenthesized expression)\\
 36.1737 +\end{tabular}
 36.1738 +
 36.1739 +\medskip
 36.1740 +
 36.1741 +More general linear expressions containing two or more primary linear
 36.1742 +expressions may be constructed by using certain arithmetic operators.
 36.1743 +
 36.1744 +\medskip
 36.1745 +
 36.1746 +\noindent{\bf Examples}
 36.1747 +
 36.1748 +\medskip
 36.1749 +
 36.1750 +\noindent\verb|2 * x[i-1,j+1] + 3.5 * y[k] + .5 * z|
 36.1751 +
 36.1752 +\noindent\verb|(- x[i,j] + 3.5 * y[k]) / sum{t in T} abs(d[i,j,t])|
 36.1753 +
 36.1754 +\subsubsection{Unsubscripted variables}
 36.1755 +
 36.1756 +If the primary linear expression is an unsubscripted variable (which
 36.1757 +must be 0-dimensional), the resultant formula is that unsubscripted
 36.1758 +variable.
 36.1759 +
 36.1760 +\subsubsection{Subscripted variables}
 36.1761 +
 36.1762 +The primary linear expression, which refers to a subscripted variable,
 36.1763 +has the following syntactic form:
 36.1764 +
 36.1765 +\medskip
 36.1766 +
 36.1767 +\noindent\hfil
 36.1768 +{\it name}{\tt[}$i_1${\tt,} $i_2${\tt,} \dots{\tt,} $i_n${\tt]}
 36.1769 +
 36.1770 +\medskip
 36.1771 +
 36.1772 +\noindent where {\it name} is the symbolic name of the model variable,
 36.1773 +$i_1$, $i_2$, \dots, $i_n$ are subscripts.
 36.1774 +
 36.1775 +Each subscript must be a numeric or symbolic expression. The number of
 36.1776 +subscripts in the subscript list must be the same as the dimension of
 36.1777 +the model variable with which the subscript list is associated.
 36.1778 +
 36.1779 +Actual values of the subscript expressions are used to identify a
 36.1780 +particular member of the model variable that determines the resultant
 36.1781 +formula, which is an elemental variable associated with corresponding
 36.1782 +member.
 36.1783 +
 36.1784 +\subsubsection{Iterated expressions}
 36.1785 +
 36.1786 +An {\it iterated linear expression} is a primary linear expression,
 36.1787 +which has the following syntactic form:
 36.1788 +
 36.1789 +\medskip
 36.1790 +
 36.1791 +\noindent\hfil
 36.1792 +{\tt sum} {\it indexing-expression} {\it integrand}
 36.1793 +
 36.1794 +\medskip
 36.1795 +
 36.1796 +\noindent where {\it indexing-expression} is an indexing expression,
 36.1797 +which introduces dummy indices and controls iterating, {\it integrand}
 36.1798 +is a linear expression that participates in the operation.
 36.1799 +
 36.1800 +The iterated linear expression is evaluated exactly in the same way as
 36.1801 +the iterated numeric expression (see Subection \ref{itexpr}, page
 36.1802 +\pageref{itexpr}) with exception that the integrand participated in the
 36.1803 +summation is a formula, not a numeric value.
 36.1804 +
 36.1805 +\subsubsection{Conditional expressions}
 36.1806 +
 36.1807 +A {\it conditional linear expression} is a primary linear expression,
 36.1808 +which has one of the following two syntactic forms:
 36.1809 +
 36.1810 +\medskip
 36.1811 +
 36.1812 +\noindent\hfil
 36.1813 +{\tt if} $b$ {\tt then} $f$ {\tt else} $g$
 36.1814 +
 36.1815 +\medskip
 36.1816 +
 36.1817 +\noindent\hspace{127pt}
 36.1818 +{\tt if} $b$ {\tt then} $f$
 36.1819 +
 36.1820 +\medskip
 36.1821 +
 36.1822 +\noindent where $b$ is an logical expression, $f$ and $g$ are linear
 36.1823 +expressions.
 36.1824 +
 36.1825 +The conditional linear expression is evaluated exactly in the same way
 36.1826 +as the conditional numeric expression (see Subsection \ref{ifthen},
 36.1827 +page \pageref{ifthen}) with exception that operands participated in the
 36.1828 +operation are formulae, not numeric values.
 36.1829 +
 36.1830 +\subsubsection{Parenthesized expressions}
 36.1831 +
 36.1832 +Any linear expression may be enclosed in parentheses that syntactically
 36.1833 +makes it a primary linear expression.
 36.1834 +
 36.1835 +Parentheses may be used in linear expressions, as in algebra, to
 36.1836 +specify the desired order in which operations are to be performed.
 36.1837 +Where parentheses are used, the expression within the parentheses is
 36.1838 +evaluated before the resultant formula is used.
 36.1839 +
 36.1840 +The resultant value of the parenthesized expression is the same as the
 36.1841 +value of the expression enclosed within parentheses.
 36.1842 +
 36.1843 +\subsubsection{Arithmetic operators}
 36.1844 +
 36.1845 +In MathProg there exists the following arithmetic operators, which may
 36.1846 +be used in linear expressions:
 36.1847 +
 36.1848 +\medskip
 36.1849 +
 36.1850 +\begin{tabular}{@{}p{96pt}p{222pt}@{}}
 36.1851 +{\tt+} $f$&unary plus\\
 36.1852 +{\tt-} $f$&unary minus\\
 36.1853 +$f$ {\tt+} $g$&addition\\
 36.1854 +$f$ {\tt-} $g$&subtraction\\
 36.1855 +$x$ {\tt*} $f$, $f$ {\tt*} $x$&multiplication\\
 36.1856 +$f$ {\tt/} $x$&division
 36.1857 +\end{tabular}
 36.1858 +
 36.1859 +\medskip
 36.1860 +
 36.1861 +\noindent where $f$ and $g$ are linear expressions, $x$ is a numeric
 36.1862 +expression (more precisely, a linear expression containing only the
 36.1863 +constant term).
 36.1864 +
 36.1865 +If the expression includes more than one arithmetic operator, all
 36.1866 +operators are performed from left to right according to the hierarchy
 36.1867 +of operations (see below). The resultant value of the expression, which
 36.1868 +contains arithmetic operators, is the result of applying the operators
 36.1869 +to their operands.
 36.1870 +
 36.1871 +\subsubsection{Hierarchy of operations}
 36.1872 +
 36.1873 +The hierarchy of arithmetic operations used in linear expressions is
 36.1874 +the same as for numeric expressions (see Subsection \ref{hierarchy},
 36.1875 +page \pageref{hierarchy}).
 36.1876 +
 36.1877 +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 36.1878 +
 36.1879 +\newpage
 36.1880 +
 36.1881 +\section{Statements}
 36.1882 +
 36.1883 +{\it Statements} are basic units of the model description. In MathProg
 36.1884 +all statements are divided into two categories: declaration statements
 36.1885 +and functional statements.
 36.1886 +
 36.1887 +{\it Declaration statements} (set statement, parameter statement,
 36.1888 +variable statement, constraint statement, and objective statement) are
 36.1889 +used to declare model objects of certain kinds and define certain
 36.1890 +properties of such objects.
 36.1891 +
 36.1892 +{\it Functional statements} (solve statement, check statement, display
 36.1893 +statement, printf statement, loop statement) are intended for
 36.1894 +performing some specific actions.
 36.1895 +
 36.1896 +Note that declaration statements may follow in arbitrary order, which
 36.1897 +does not affect the result of translation. However, any model object
 36.1898 +must be declared before it is referenced in other statements.
 36.1899 +
 36.1900 +\subsection{Set statement}
 36.1901 +
 36.1902 +\medskip
 36.1903 +
 36.1904 +\framebox[345pt][l]{
 36.1905 +\parbox[c][24pt]{345pt}{
 36.1906 +\hspace{6pt} {\tt set} {\it name} {\it alias} {\it domain} {\tt,}
 36.1907 +{\it attrib} {\tt,} \dots {\tt,} {\it attrib} {\tt;}
 36.1908 +}}
 36.1909 +
 36.1910 +\setlength{\leftmargini}{60pt}
 36.1911 +
 36.1912 +\begin{description}
 36.1913 +\item[{\rm Where:}\hspace*{23pt}] {\it name} is a symbolic name of the
 36.1914 +set;
 36.1915 +\item[\hspace*{54pt}] {\it alias} is an optional string literal, which
 36.1916 +specifies an alias of the set;
 36.1917 +\item[\hspace*{54pt}] {\it domain} is an optional indexing expression,
 36.1918 +which specifies a subscript domain of the set;
 36.1919 +\item[\hspace*{54pt}] {\it attrib}, \dots, {\it attrib} are optional
 36.1920 +attributes of the set. (Commae preceding attributes may be omitted.)
 36.1921 +\end{description}
 36.1922 +
 36.1923 +\noindent Optional attributes:
 36.1924 +
 36.1925 +\begin{description}
 36.1926 +\item[{\tt dimen} $n$\hspace*{19pt}] specifies the dimension of
 36.1927 +$n$-tuples, which the set consists of;
 36.1928 +\item[{\tt within} {\it expression}]\hspace*{0pt}\\
 36.1929 +specifies a superset which restricts the set or all its members
 36.1930 +(elemental sets) to be within that superset;
 36.1931 +\item[{\tt:=} {\it expression}]\hspace*{0pt}\\
 36.1932 +specifies an elemental set assigned to the set or its members;
 36.1933 +\item[{\tt default} {\it expression}]\hspace*{0pt}\\
 36.1934 +specifies an elemental set assigned to the set or its members whenever
 36.1935 +no appropriate data are available in the data section.
 36.1936 +\end{description}
 36.1937 +
 36.1938 +\newpage
 36.1939 +
 36.1940 +\noindent{\bf Examples}
 36.1941 +
 36.1942 +\begin{verbatim}
 36.1943 +set V;
 36.1944 +set E within V cross V;
 36.1945 +set step{s in 1..maxiter} dimen 2 := if s = 1 then E else
 36.1946 +   step[s-1] union setof{k in V, (i,k) in step[s-1], (k,j)
 36.1947 +   in step[s-1]}(i,j);
 36.1948 +set A{i in I, j in J}, within B[i+1] cross C[j-1], within
 36.1949 +   D diff E, default {('abc',123), (321,'cba')};
 36.1950 +\end{verbatim}
 36.1951 +
 36.1952 +The set statement declares a set. If the subscript domain is not
 36.1953 +specified, the set is a simple set, otherwise it is an array of
 36.1954 +elemental sets.
 36.1955 +
 36.1956 +The {\tt dimen} attribute specifies the dimension of $n$-tuples, which
 36.1957 +the set (if it is a simple set) or its members (if the set is an array
 36.1958 +of elemental sets) consist of, where $n$ must be unsigned integer from
 36.1959 +1 to 20. At most one {\tt dimen} attribute can be specified. If the
 36.1960 +{\tt dimen} attribute is not specified, the dimension of\linebreak
 36.1961 +$n$-tuples is implicitly determined by other attributes (for example,
 36.1962 +if there is a set expression that follows {\tt:=} or the keyword
 36.1963 +{\tt default}, the dimension of $n$-tuples of corresponding elemental
 36.1964 +set is used). If no dimension information is available, {\tt dimen 1}
 36.1965 +is assumed.
 36.1966 +
 36.1967 +The {\tt within} attribute specifies a set expression whose resultant
 36.1968 +value is a superset used to restrict the set (if it is a simple set) or
 36.1969 +its members (if the set is an array of elemental sets) to be within
 36.1970 +that superset. Arbitrary number of {\tt within} attributes may be
 36.1971 +specified in the same set statement.
 36.1972 +
 36.1973 +The assign ({\tt:=}) attribute specifies a set expression used to
 36.1974 +evaluate elemental set(s) assigned to the set (if it is a simple set)
 36.1975 +or its members (if the set is an array of elemental sets). If the
 36.1976 +assign attribute is specified, the set is {\it computable} and
 36.1977 +therefore needs no data to be provided in the data section. If the
 36.1978 +assign attribute is not specified, the set must be provided with data
 36.1979 +in the data section. At most one assign or default attribute can be
 36.1980 +specified for the same set.
 36.1981 +
 36.1982 +The {\tt default} attribute specifies a set expression used to evaluate
 36.1983 +elemental set(s) assigned to the set (if it is a simple set) or its
 36.1984 +members (if the set is an array of elemental sets) whenever
 36.1985 +no appropriate data are available in the data section. If neither
 36.1986 +assign nor default attribute is specified, missing data will cause an
 36.1987 +error.
 36.1988 +
 36.1989 +\subsection{Parameter statement}
 36.1990 +
 36.1991 +\medskip
 36.1992 +
 36.1993 +\framebox[345pt][l]{
 36.1994 +\parbox[c][24pt]{345pt}{
 36.1995 +\hspace{6pt} {\tt param} {\it name} {\it alias} {\it domain} {\tt,}
 36.1996 +{\it attrib} {\tt,} \dots {\tt,} {\it attrib} {\tt;}
 36.1997 +}}
 36.1998 +
 36.1999 +\setlength{\leftmargini}{60pt}
 36.2000 +
 36.2001 +\begin{description}
 36.2002 +\item[{\rm Where:}\hspace*{23pt}] {\it name} is a symbolic name of the
 36.2003 +parameter;
 36.2004 +\item[\hspace*{54pt}] {\it alias} is an optional string literal, which
 36.2005 +specifies an alias of the parameter;
 36.2006 +\item[\hspace*{54pt}] {\it domain} is an optional indexing expression,
 36.2007 +which specifies a subscript domain of the parameter;
 36.2008 +\item[\hspace*{54pt}] {\it attrib}, \dots, {\it attrib} are optional
 36.2009 +attributes of the parameter. (Commae preceding attributes may be
 36.2010 +omitted.)
 36.2011 +\end{description}
 36.2012 +
 36.2013 +\noindent Optional attributes:
 36.2014 +
 36.2015 +\begin{description}
 36.2016 +\item[{\tt integer}\hspace*{18.5pt}] specifies that the parameter is
 36.2017 +integer;
 36.2018 +\item[{\tt binary}\hspace*{24pt}] specifies that the parameter is
 36.2019 +binary;
 36.2020 +\item[{\tt symbolic}\hspace*{13.5pt}] specifies that the parameter is
 36.2021 +symbolic;
 36.2022 +\item[{\it relation expression}]\hspace*{0pt}\\
 36.2023 +(where {\it relation} is one of: {\tt<}, {\tt<=}, {\tt=}, {\tt==},
 36.2024 +{\tt>=}, {\tt>}, {\tt<>}, {\tt!=})\\
 36.2025 +specifies a condition that restricts the parameter or its members to
 36.2026 +satisfy that condition;
 36.2027 +\item[{\tt in} {\it expression}]\hspace*{0pt}\\
 36.2028 +specifies a superset that restricts the parameter or its members to be
 36.2029 +in that superset;
 36.2030 +\item[{\tt:=} {\it expression}]\hspace*{0pt}\\
 36.2031 +specifies a value assigned to the parameter or its members;
 36.2032 +\item[{\tt default} {\it expression}]\hspace*{0pt}\\
 36.2033 +specifies a value assigned to the parameter or its members whenever
 36.2034 +no appropriate data are available in the data section.
 36.2035 +\end{description}
 36.2036 +
 36.2037 +\noindent{\bf Examples}
 36.2038 +
 36.2039 +\begin{verbatim}
 36.2040 +param units{raw, prd} >= 0;
 36.2041 +param profit{prd, 1..T+1};
 36.2042 +param N := 20, integer, >= 0, <= 100;
 36.2043 +param comb 'n choose k' {n in 0..N, k in 0..n} :=
 36.2044 +   if k = 0 or k = n then 1 else comb[n-1,k-1] + comb[n-1,k];
 36.2045 +param p{i in I, j in J}, integer, >= 0, <= i+j,
 36.2046 +   in A[i] symdiff B[j], in C[i,j], default 0.5 * (i + j);
 36.2047 +param month symbolic default 'May' in {'Mar', 'Apr', 'May'};
 36.2048 +\end{verbatim}
 36.2049 +
 36.2050 +The parameter statement declares a parameter. If a subscript domain is
 36.2051 +not specified, the parameter is a simple (scalar) parameter, otherwise
 36.2052 +it is a $n$-dimensional array.
 36.2053 +
 36.2054 +The type attributes {\tt integer}, {\tt binary}, and {\tt symbolic}
 36.2055 +qualify the type of values that can be assigned to the parameter as
 36.2056 +shown below:
 36.2057 +
 36.2058 +\medskip
 36.2059 +
 36.2060 +\noindent\hfil
 36.2061 +\begin{tabular}{@{}ll@{}}
 36.2062 +Type attribute&Assigned values\\
 36.2063 +\hline
 36.2064 +(not specified)&Any numeric values\\
 36.2065 +{\tt integer}&Only integer numeric values\\
 36.2066 +{\tt binary}&Either 0 or 1\\
 36.2067 +{\tt symbolic}&Any numeric and symbolic values\\
 36.2068 +\end{tabular}
 36.2069 +
 36.2070 +\newpage
 36.2071 +
 36.2072 +The {\tt symbolic} attribute cannot be specified along with other type
 36.2073 +attributes. Being specified it must precede all other attributes.
 36.2074 +
 36.2075 +The condition attribute specifies an optional condition that restricts
 36.2076 +values assigned to the parameter to satisfy that condition. This
 36.2077 +attribute has the following syntactic forms:
 36.2078 +
 36.2079 +\medskip
 36.2080 +
 36.2081 +\begin{tabular}{@{}ll@{}}
 36.2082 +{\tt<} $v$&check for $x<v$\\
 36.2083 +{\tt<=} $v$&check for $x\leq v$\\
 36.2084 +{\tt=} $v$, {\tt==} $v$&check for $x=v$\\
 36.2085 +{\tt>=} $v$&check for $x\geq v$\\
 36.2086 +{\tt>} $v$&check for $x\geq v$\\
 36.2087 +{\tt<>} $v$, {\tt!=} $v$&check for $x\neq v$\\
 36.2088 +\end{tabular}
 36.2089 +
 36.2090 +\medskip
 36.2091 +
 36.2092 +\noindent where $x$ is a value assigned to the parameter, $v$ is the
 36.2093 +resultant value of a numeric or symbolic expression specified in the
 36.2094 +condition attribute. Arbitrary number of condition attributes can be
 36.2095 +specified for the same parameter. If a value being assigned to the
 36.2096 +parameter during model evaluation violates at least one of specified
 36.2097 +conditions, an error is raised. (Note that symbolic values are ordered
 36.2098 +lexicographically, and any numeric value precedes any symbolic value.)
 36.2099 +
 36.2100 +The {\tt in} attribute is similar to the condition attribute and
 36.2101 +specifies a set expression whose resultant value is a superset used to
 36.2102 +restrict numeric or symbolic values assigned to the parameter to be in
 36.2103 +that superset. Arbitrary number of the {\tt in} attributes can be
 36.2104 +specified for the same parameter. If a value being assigned to the
 36.2105 +parameter during model evaluation is not in at least one of specified
 36.2106 +supersets, an error is raised.
 36.2107 +
 36.2108 +The assign ({\tt:=}) attribute specifies a numeric or symbolic
 36.2109 +expression used to compute a value assigned to the parameter (if it is
 36.2110 +a simple parameter) or its member (if the parameter is an array). If
 36.2111 +the assign attribute is specified, the parameter is {\it computable}
 36.2112 +and therefore needs no data to be provided in the data section. If the
 36.2113 +assign attribute is not specified, the parameter must be provided with
 36.2114 +data in the data section. At most one assign or {\tt default} attribute
 36.2115 +can be specified for the same parameter.
 36.2116 +
 36.2117 +The {\tt default} attribute specifies a numeric or symbolic expression
 36.2118 +used to compute a value assigned to the parameter or its member
 36.2119 +whenever no appropriate data are available in the data section. If
 36.2120 +neither assign nor {\tt default} attribute is specified, missing data
 36.2121 +will cause an error.
 36.2122 +
 36.2123 +\subsection{Variable statement}
 36.2124 +
 36.2125 +\medskip
 36.2126 +
 36.2127 +\framebox[345pt][l]{
 36.2128 +\parbox[c][24pt]{345pt}{
 36.2129 +\hspace{6pt} {\tt var} {\it name} {\it alias} {\it domain} {\tt,}
 36.2130 +{\it attrib} {\tt,} \dots {\tt,} {\it attrib} {\tt;}
 36.2131 +}}
 36.2132 +
 36.2133 +\setlength{\leftmargini}{60pt}
 36.2134 +
 36.2135 +\begin{description}
 36.2136 +\item[{\rm Where:}\hspace*{23pt}] {\it name} is a symbolic name of the
 36.2137 +variable;
 36.2138 +\item[\hspace*{54pt}] {\it alias} is an optional string literal, which
 36.2139 +specifies an alias of the variable;
 36.2140 +\item[\hspace*{54pt}] {\it domain} is an optional indexing expression,
 36.2141 +which specifies a subscript domain of the variable;
 36.2142 +\item[\hspace*{54pt}] {\it attrib}, \dots, {\it attrib} are optional
 36.2143 +attributes of the variable. (Commae preceding attributes may be
 36.2144 +omitted.)
 36.2145 +\end{description}
 36.2146 +
 36.2147 +\noindent Optional attributes:
 36.2148 +
 36.2149 +\begin{description}
 36.2150 +\item[{\tt integer}\hspace*{18.5pt}] restricts the variable to be
 36.2151 +integer;
 36.2152 +\item[{\tt binary}\hspace*{24pt}] restricts the variable to be binary;
 36.2153 +\item[{\tt>=} {\it expression}]\hspace*{0pt}\\
 36.2154 +specifies an lower bound of the variable;
 36.2155 +\item[{\tt<=} {\it expression}]\hspace*{0pt}\\
 36.2156 +specifies an upper bound of the variable;
 36.2157 +\item[{\tt=} {\it expression}]\hspace*{0pt}\\
 36.2158 +specifies a fixed value of the variable;
 36.2159 +\end{description}
 36.2160 +
 36.2161 +\noindent{\bf Examples}
 36.2162 +
 36.2163 +\begin{verbatim}
 36.2164 +var x >= 0;
 36.2165 +var y{I,J};
 36.2166 +var make{p in prd}, integer, >= commit[p], <= market[p];
 36.2167 +var store{raw, 1..T+1} >= 0;
 36.2168 +var z{i in I, j in J} >= i+j;
 36.2169 +\end{verbatim}
 36.2170 +
 36.2171 +The variable statement declares a variable. If a subscript domain is
 36.2172 +not specified, the variable is a simple (scalar) variable, otherwise it
 36.2173 +is a $n$-dimensional array of elemental variables.
 36.2174 +
 36.2175 +Elemental variable(s) associated with the model variable (if it is a
 36.2176 +simple variable) or its members (if it is an array) correspond to the
 36.2177 +variables in the LP/MIP problem formulation (see Subsection
 36.2178 +\ref{problem}, page \pageref{problem}). Note that only elemental
 36.2179 +variables actually referenced in some constraints and/or objectives are
 36.2180 +included in the LP/MIP problem instance to be generated.
 36.2181 +
 36.2182 +The type attributes {\tt integer} and {\tt binary} restrict the
 36.2183 +variable to be integer or binary, respectively. If no type attribute is
 36.2184 +specified, the variable is continuous. If all variables in the model
 36.2185 +are continuous, the corresponding problem is of LP class. If there is
 36.2186 +at least one integer or binary variable, the problem is of MIP class.
 36.2187 +
 36.2188 +The lower bound ({\tt>=}) attribute specifies a numeric expression for
 36.2189 +computing an lower bound of the variable. At most one lower bound can
 36.2190 +be specified. By default all variables (except binary ones) have no
 36.2191 +lower bound, so if a variable is required to be non-negative, its zero
 36.2192 +lower bound should be explicitly specified.
 36.2193 +
 36.2194 +The upper bound ({\tt<=}) attribute specifies a numeric expression for
 36.2195 +computing an upper bound of the variable. At most one upper bound
 36.2196 +attribute can be specified.
 36.2197 +
 36.2198 +The fixed value ({\tt=}) attribute specifies a numeric expression for
 36.2199 +computing a value, at which the variable is fixed. This attribute
 36.2200 +cannot be specified along with the bound attributes.
 36.2201 +
 36.2202 +\subsection{Constraint statement}
 36.2203 +
 36.2204 +\medskip
 36.2205 +
 36.2206 +\framebox[345pt][l]{
 36.2207 +\parbox[c][96pt]{345pt}{
 36.2208 +\hspace{6pt} {\tt s.t.} {\it name} {\it alias} {\it domain} {\tt:}
 36.2209 +{\it expression} {\tt,} {\tt=} {\it expression} {\tt;}
 36.2210 +
 36.2211 +\medskip
 36.2212 +
 36.2213 +\hspace{6pt} {\tt s.t.} {\it name} {\it alias} {\it domain} {\tt:}
 36.2214 +{\it expression} {\tt,} {\tt<=} {\it expression} {\tt;}
 36.2215 +
 36.2216 +\medskip
 36.2217 +
 36.2218 +\hspace{6pt} {\tt s.t.} {\it name} {\it alias} {\it domain} {\tt:}
 36.2219 +{\it expression} {\tt,} {\tt>=} {\it expression} {\tt;}
 36.2220 +
 36.2221 +\medskip
 36.2222 +
 36.2223 +\hspace{6pt} {\tt s.t.} {\it name} {\it alias} {\it domain} {\tt:}
 36.2224 +{\it expression} {\tt,} {\tt<=} {\it expression} {\tt,} {\tt<=}
 36.2225 +{\it expression} {\tt;}
 36.2226 +
 36.2227 +\medskip
 36.2228 +
 36.2229 +\hspace{6pt} {\tt s.t.} {\it name} {\it alias} {\it domain} {\tt:}
 36.2230 +{\it expression} {\tt,} {\tt>=} {\it expression} {\tt,} {\tt>=}
 36.2231 +{\it expression} {\tt;}
 36.2232 +}}
 36.2233 +
 36.2234 +\setlength{\leftmargini}{60pt}
 36.2235 +
 36.2236 +\begin{description}
 36.2237 +\item[{\rm Where:}\hspace*{23pt}] {\it name} is a symbolic name of the
 36.2238 +constraint;
 36.2239 +\item[\hspace*{54pt}] {\it alias} is an optional string literal, which
 36.2240 +specifies an alias of the constraint;
 36.2241 +\item[\hspace*{54pt}] {\it domain} is an optional indexing expression,
 36.2242 +which specifies a subscript domain of the constraint;
 36.2243 +\item[\hspace*{54pt}] {\it expression} is a linear expression used to
 36.2244 +compute a component of the constraint. (Commae following expressions
 36.2245 +may be omitted.)
 36.2246 +\end{description}
 36.2247 +
 36.2248 +\begin{description}
 36.2249 +\item[{\rm Note:}\hspace*{31pt}] The keyword {\tt s.t.} may be written
 36.2250 +as {\tt subject to} or as {\tt subj to}, or may be omitted at all.
 36.2251 +\end{description}
 36.2252 +
 36.2253 +\noindent{\bf Examples}
 36.2254 +
 36.2255 +\begin{verbatim}
 36.2256 +s.t. r: x + y + z, >= 0, <= 1;
 36.2257 +limit{t in 1..T}: sum{j in prd} make[j,t] <= max_prd;
 36.2258 +subject to balance{i in raw, t in 1..T}: store[i,t+1] -
 36.2259 +   store[i,t] - sum{j in prd} units[i,j] * make[j,t];
 36.2260 +subject to rlim 'regular-time limit' {t in time}:
 36.2261 +sum{p in prd} pt[p] * rprd[p,t] <= 1.3 * dpp[t] * crews[t];
 36.2262 +\end{verbatim}
 36.2263 +
 36.2264 +The constraint statement declares a constraint. If a subscript domain
 36.2265 +is not specified, the constraint is a simple (scalar) constraint,
 36.2266 +otherwise it is a $n$-dimensional array of elemental constraints.
 36.2267 +
 36.2268 +Elemental constraint(s) associated with the model constraint (if it is
 36.2269 +a simple constraint) or its members (if it is an array) correspond to
 36.2270 +the linear constraints in the LP/MIP problem formulation (see
 36.2271 +Subsection \ref{problem}, page \pageref{problem}).
 36.2272 +
 36.2273 +If the constraint has the form of equality or single inequality, i.e.
 36.2274 +includes two expressions, one of which follows the colon and other
 36.2275 +follows the relation sign {\tt=}, {\tt<=}, or {\tt>=}, both expressions
 36.2276 +in the statement can be linear expressions. If the constraint has the
 36.2277 +form of double inequality, i.e. includes three expressions, the middle
 36.2278 +expression can be a linear expression while the leftmost and rightmost
 36.2279 +ones can be only numeric expressions.
 36.2280 +
 36.2281 +Generating the model is, roughly speaking, generating its constraints,
 36.2282 +which are always evaluated for the entire subscript domain. Evaluation
 36.2283 +of the constraints leads, in turn, to evaluation of other model objects
 36.2284 +such as sets, parameters, and variables.
 36.2285 +
 36.2286 +Constructing an actual linear constraint included in the problem
 36.2287 +instance, which (constraint) corresponds to a particular elemental
 36.2288 +constraint, is performed as follows.
 36.2289 +
 36.2290 +If the constraint has the form of equality or single inequality,
 36.2291 +evaluation of both linear expressions gives two resultant linear forms:
 36.2292 +$$\begin{array}{r@{\ }c@{\ }r@{\ }c@{\ }r@{\ }c@{\ }r@{\ }c@{\ }r}
 36.2293 +f&=&a_1x_1&+&a_2x_2&+\dots+&a_nx_n&+&a_0,\\
 36.2294 +g&=&b_1x_1&+&a_2x_2&+\dots+&a_nx_n&+&b_0,\\
 36.2295 +\end{array}$$
 36.2296 +where $x_1$, $x_2$, \dots, $x_n$ are elemental variables; $a_1$, $a_2$,
 36.2297 +\dots, $a_n$, $b_1$, $b_2$, \dots, $b_n$ are numeric coefficients;
 36.2298 +$a_0$ and $b_0$ are constant terms. Then all linear terms of $f$ and
 36.2299 +$g$ are carried to the left-hand side, and the constant terms are
 36.2300 +carried to the right-hand side, that gives the final elemental
 36.2301 +constraint in the standard form:
 36.2302 +$$(a_1-b_1)x_1+(a_2-b_2)x_2+\dots+(a_n-b_n)x_n\left\{
 36.2303 +\begin{array}{@{}c@{}}=\\\leq\\\geq\\\end{array}\right\}b_0-a_0.$$
 36.2304 +
 36.2305 +If the constraint has the form of double inequality, evaluation of the
 36.2306 +middle linear expression gives the resultant linear form:
 36.2307 +$$f=a_1x_1+a_2x_2+\dots+a_nx_n+a_0,$$
 36.2308 +and evaluation of the leftmost and rightmost numeric expressions gives
 36.2309 +two numeric values $l$ and $u$, respectively. Then the constant term of
 36.2310 +the linear form is carried to both left-hand and right-handsides that
 36.2311 +gives the final elemental constraint in the standard form:
 36.2312 +$$l-a_0\leq a_1x_1+a_2x_2+\dots+a_nx_n\leq u-a_0.$$
 36.2313 +
 36.2314 +\subsection{Objective statement}
 36.2315 +
 36.2316 +\medskip
 36.2317 +
 36.2318 +\framebox[345pt][l]{
 36.2319 +\parbox[c][44pt]{345pt}{
 36.2320 +\hspace{6pt} {\tt minimize} {\it name} {\it alias} {\it domain} {\tt:}
 36.2321 +{\it expression} {\tt;}
 36.2322 +
 36.2323 +\medskip
 36.2324 +
 36.2325 +\hspace{6pt} {\tt maximize} {\it name} {\it alias} {\it domain} {\tt:}
 36.2326 +{\it expression} {\tt;}
 36.2327 +}}
 36.2328 +
 36.2329 +\setlength{\leftmargini}{60pt}
 36.2330 +
 36.2331 +\begin{description}
 36.2332 +\item[{\rm Where:}\hspace*{23pt}] {\it name} is a symbolic name of the
 36.2333 +objective;
 36.2334 +\item[\hspace*{54pt}] {\it alias} is an optional string literal, which
 36.2335 +specifies an alias of the objective;
 36.2336 +\item[\hspace*{54pt}] {\it domain} is an optional indexing expression,
 36.2337 +which specifies a subscript domain of the objective;
 36.2338 +\item[\hspace*{54pt}] {\it expression} is a linear expression used to
 36.2339 +compute the linear form of the objective.
 36.2340 +\end{description}
 36.2341 +
 36.2342 +\noindent{\bf Examples}
 36.2343 +
 36.2344 +\begin{verbatim}
 36.2345 +minimize obj: x + 1.5 * (y + z);
 36.2346 +maximize total_profit: sum{p in prd} profit[p] * make[p];
 36.2347 +\end{verbatim}
 36.2348 +
 36.2349 +The objective statement declares an objective. If a subscript domain is
 36.2350 +not specified, the objective is a simple (scalar) objective. Otherwise
 36.2351 +it is a $n$-dimensional array of elemental objectives.
 36.2352 +
 36.2353 +Elemental objective(s) associated with the model objective (if it is a
 36.2354 +simple objective) or its members (if it is an array) correspond to
 36.2355 +general linear constraints in the LP/MIP problem formulation (see
 36.2356 +Subsection \ref{problem}, page \pageref{problem}). However, unlike
 36.2357 +constraints the corresponding linear forms are free (unbounded).
 36.2358 +
 36.2359 +Constructing an actual linear constraint included in the problem
 36.2360 +instance, which (constraint) corresponds to a particular elemental
 36.2361 +constraint, is performed as follows. The linear expression specified in
 36.2362 +the objective statement is evaluated that, gives the resultant linear
 36.2363 +form:
 36.2364 +$$f=a_1x_1+a_2x_2+\dots+a_nx_n+a_0,$$
 36.2365 +where $x_1$, $x_2$, \dots, $x_n$ are elemental variables; $a_1$, $a_2$,
 36.2366 +\dots, $a_n$ are numeric coefficients; $a_0$ is the constant term. Then
 36.2367 +the linear form is used to construct the final elemental constraint in
 36.2368 +the standard form:
 36.2369 +$$-\infty<a_1x_1+a_2x_2+\dots+a_nx_n+a_0<+\infty.$$
 36.2370 +
 36.2371 +As a rule the model description contains only one objective statement
 36.2372 +that defines the objective function used in the problem instance.
 36.2373 +However, it is allowed to declare arbitrary number of objectives, in
 36.2374 +which case the actual objective function is the first objective
 36.2375 +encountered in the model description. Other objectives are also
 36.2376 +included in the problem instance, but they do not affect the objective
 36.2377 +function.
 36.2378 +
 36.2379 +\subsection{Solve statement}
 36.2380 +
 36.2381 +\medskip
 36.2382 +
 36.2383 +\framebox[345pt][l]{
 36.2384 +\parbox[c][24pt]{345pt}{
 36.2385 +\hspace{6pt} {\tt solve} {\tt;}
 36.2386 +}}
 36.2387 +
 36.2388 +\setlength{\leftmargini}{60pt}
 36.2389 +
 36.2390 +\begin{description}
 36.2391 +\item[{\rm Note:}\hspace*{31pt}] The solve statement is optional and
 36.2392 +can be used only once. If no solve statement is used, one is assumed at
 36.2393 +the end of the model section.
 36.2394 +\end{description}
 36.2395 +
 36.2396 +The solve statement causes the model to be solved, that means computing
 36.2397 +numeric values of all model variables. This allows using variables in
 36.2398 +statements below the solve statement in the same way as if they were
 36.2399 +numeric parameters.
 36.2400 +
 36.2401 +Note that the variable, constraint, and objective statements cannot be
 36.2402 +used below the solve statement, i.e. all principal components of the
 36.2403 +model must be declared above the solve statement.
 36.2404 +
 36.2405 +\subsection{Check statement}
 36.2406 +
 36.2407 +\medskip
 36.2408 +
 36.2409 +\framebox[345pt][l]{
 36.2410 +\parbox[c][24pt]{345pt}{
 36.2411 +\hspace{6pt} {\tt check} {\it domain} {\tt:} {\it expression} {\tt;}
 36.2412 +}}
 36.2413 +
 36.2414 +\setlength{\leftmargini}{60pt}
 36.2415 +
 36.2416 +\begin{description}
 36.2417 +\item[{\rm Where:}\hspace*{23pt}] {\it domain} is an optional indexing
 36.2418 +expression, which specifies a subscript domain of the check statement;
 36.2419 +\item[\hspace*{54pt}] {\it expression} is an logical expression which
 36.2420 +specifies the logical condition to be checked. (The colon preceding
 36.2421 +{\it expression} may be omitted.)
 36.2422 +\end{description}
 36.2423 +
 36.2424 +\noindent{\bf Examples}
 36.2425 +
 36.2426 +\begin{verbatim}
 36.2427 +check: x + y <= 1 and x >= 0 and y >= 0;
 36.2428 +check sum{i in ORIG} supply[i] = sum{j in DEST} demand[j];
 36.2429 +check{i in I, j in 1..10}: S[i,j] in U[i] union V[j];
 36.2430 +\end{verbatim}
 36.2431 +
 36.2432 +The check statement allows checking the resultant value of an logical
 36.2433 +expression specified in the statement. If the value is {\it false}, an
 36.2434 +error is reported.
 36.2435 +
 36.2436 +If the subscript domain is not specified, the check is performed only
 36.2437 +once. Specifying the subscript domain allows performing multiple checks
 36.2438 +for every\linebreak $n$-tuple in the domain set. In the latter case the
 36.2439 +logical expression may include dummy indices introduced in
 36.2440 +corresponding indexing expression.
 36.2441 +
 36.2442 +\subsection{Display statement}
 36.2443 +
 36.2444 +\medskip
 36.2445 +
 36.2446 +\framebox[345pt][l]{
 36.2447 +\parbox[c][24pt]{345pt}{
 36.2448 +\hspace{6pt} {\tt display} {\it domain} {\tt:} {\it item} {\tt,}
 36.2449 +\dots {\tt,} {\it item} {\tt;}
 36.2450 +}}
 36.2451 +
 36.2452 +\setlength{\leftmargini}{60pt}
 36.2453 +
 36.2454 +\begin{description}
 36.2455 +\item[{\rm Where:}\hspace*{23pt}] {\it domain} is an optional indexing
 36.2456 +expression, which specifies a subscript domain of the check statement;
 36.2457 +\item[\hspace*{54pt}] {\it item}, \dots, {\it item} are items to be
 36.2458 +displayed. (The colon preceding the first item may be omitted.)
 36.2459 +\end{description}
 36.2460 +
 36.2461 +\noindent{\bf Examples}
 36.2462 +
 36.2463 +\begin{verbatim}
 36.2464 +display: 'x =', x, 'y =', y, 'z =', z;
 36.2465 +display sqrt(x ** 2 + y ** 2 + z ** 2);
 36.2466 +display{i in I, j in J}: i, j, a[i,j], b[i,j];
 36.2467 +\end{verbatim}
 36.2468 +
 36.2469 +\newpage
 36.2470 +
 36.2471 +The display statement evaluates all items specified in the statement
 36.2472 +and writes their values to the terminal in plain text format.
 36.2473 +
 36.2474 +If a subscript domain is not specified, items are evaluated and then
 36.2475 +displayed only once. Specifying the subscript domain causes items to be
 36.2476 +evaluated and displayed for every $n$-tuple in the domain set. In the
 36.2477 +latter case items may include dummy indices introduced in corresponding
 36.2478 +indexing expression.
 36.2479 +
 36.2480 +An item to be displayed can be a model object (set, parameter, variable,
 36.2481 +constraint, objective) or an expression.
 36.2482 +
 36.2483 +If the item is a computable object (i.e. a set or parameter provided
 36.2484 +with the assign attribute), the object is evaluated over the entire
 36.2485 +domain and then its content (i.e. the content of the object array) is
 36.2486 +displayed. Otherwise, if the item is not a computable object, only its
 36.2487 +current content (i.e. members actually generated during the model
 36.2488 +evaluation) is displayed.
 36.2489 +
 36.2490 +If the item is an expression, the expression is evaluated and its
 36.2491 +resultant value is displayed.
 36.2492 +
 36.2493 +\subsection{Printf statement}
 36.2494 +
 36.2495 +\medskip
 36.2496 +
 36.2497 +\framebox[345pt][l]{
 36.2498 +\parbox[c][60pt]{345pt}{
 36.2499 +\hspace{6pt} {\tt printf} {\it domain} {\tt:} {\it format} {\tt,}
 36.2500 +{\it expression} {\tt,} \dots {\tt,} {\it expression} {\tt;}
 36.2501 +
 36.2502 +\medskip
 36.2503 +
 36.2504 +\hspace{6pt} {\tt printf} {\it domain} {\tt:} {\it format} {\tt,}
 36.2505 +{\it expression} {\tt,} \dots {\tt,} {\it expression} {\tt>}
 36.2506 +{\it filename} {\tt;}
 36.2507 +
 36.2508 +\medskip
 36.2509 +
 36.2510 +\hspace{6pt} {\tt printf} {\it domain} {\tt:} {\it format} {\tt,}
 36.2511 +{\it expression} {\tt,} \dots {\tt,} {\it expression} {\tt>>}
 36.2512 +{\it filename} {\tt;}
 36.2513 +}}
 36.2514 +
 36.2515 +\setlength{\leftmargini}{60pt}
 36.2516 +
 36.2517 +\begin{description}
 36.2518 +\item[{\rm Where:}\hspace*{23pt}] {\it domain} is an optional indexing
 36.2519 +expression, which specifies a subscript domain of the printf statement;
 36.2520 +\item[\hspace*{54pt}] {\it format} is a symbolic expression whose value
 36.2521 +specifies a format control string. (The colon preceding the format
 36.2522 +expression may be omitted.)
 36.2523 +\item[\hspace*{54pt}] {\it expression}, \dots, {\it expression} are
 36.2524 +zero or more expressions whose values have to be formatted and printed.
 36.2525 +Each expression must be of numeric, symbolic, or logical type.
 36.2526 +\item[\hspace*{54pt}] {\it filename} is a symbolic expression whose
 36.2527 +value specifies a name of a text file, to which the output is
 36.2528 +redirected. The flag {\tt>} means creating a new empty file while the
 36.2529 +flag {\tt>>} means appending the output to an existing file. If no file
 36.2530 +name is specified, the output is written to the terminal.
 36.2531 +\end{description}
 36.2532 +
 36.2533 +\noindent{\bf Examples}
 36.2534 +
 36.2535 +\begin{verbatim}
 36.2536 +printf 'Hello, world!\n';
 36.2537 +printf: "x = %.3f; y = %.3f; z = %.3f\n",
 36.2538 +   x, y, z > "result.txt";
 36.2539 +printf{i in I, j in J}: "flow from %s to %s is %d\n",
 36.2540 +   i, j, x[i,j] >> result_file & ".txt";
 36.2541 +\end{verbatim}
 36.2542 +
 36.2543 +\newpage
 36.2544 +
 36.2545 +\begin{verbatim}
 36.2546 +printf{i in I} 'total flow from %s is %g\n',
 36.2547 +   i, sum{j in J} x[i,j];
 36.2548 +printf{k in K} "x[%s] = " & (if x[k] < 0 then "?" else "%g"),
 36.2549 +   k, x[k];
 36.2550 +\end{verbatim}
 36.2551 +
 36.2552 +The printf statement is similar to the display statement, however, it
 36.2553 +allows formatting data to be written.
 36.2554 +
 36.2555 +If a subscript domain is not specified, the printf statement is
 36.2556 +executed only once. Specifying a subscript domain causes executing the
 36.2557 +printf statement for every $n$-tuple in the domain set. In the latter
 36.2558 +case the format and expression may include dummy indices introduced in
 36.2559 +corresponding indexing expression.
 36.2560 +
 36.2561 +The format control string is a value of the symbolic expression
 36.2562 +{\it format} specified in the printf statement. It is composed of zero
 36.2563 +or more directives as follows: ordinary characters (not {\tt\%}), which
 36.2564 +are copied unchanged to the output stream, and conversion
 36.2565 +specifications, each of which causes evaluating corresponding
 36.2566 +expression specified in the printf statement, formatting it, and
 36.2567 +writing its resultant value to the output stream.
 36.2568 +
 36.2569 +Conversion specifications that may be used in the format control string
 36.2570 +are the following: {\tt d}, {\tt i}, {\tt f}, {\tt F}, {\tt e}, {\tt E},
 36.2571 +{\tt g}, {\tt G}, and {\tt s}. These specifications have the same
 36.2572 +syntax and semantics as in the C programming language.
 36.2573 +
 36.2574 +\subsection{For statement}
 36.2575 +
 36.2576 +\medskip
 36.2577 +
 36.2578 +\framebox[345pt][l]{
 36.2579 +\parbox[c][44pt]{345pt}{
 36.2580 +\hspace{6pt} {\tt for} {\it domain} {\tt:} {\it statement} {\tt;}
 36.2581 +
 36.2582 +\medskip
 36.2583 +
 36.2584 +\hspace{6pt} {\tt for} {\it domain} {\tt:} {\tt\{} {\it statement}
 36.2585 +\dots {\it statement} {\tt\}} {\tt;}
 36.2586 +}}
 36.2587 +
 36.2588 +\setlength{\leftmargini}{60pt}
 36.2589 +
 36.2590 +\begin{description}
 36.2591 +\item[{\rm Where:}\hspace*{23pt}] {\it domain} is an indexing
 36.2592 +expression which specifies a subscript domain of the for statement.
 36.2593 +(The colon following the indexing expression may be omitted.)
 36.2594 +\item[\hspace*{54pt}] {\it statement} is a statement, which should be
 36.2595 +executed under control of the for statement;
 36.2596 +\item[\hspace*{54pt}] {\it statement}, \dots, {\it statement} is a
 36.2597 +sequence of statements (enclosed in curly braces), which should be
 36.2598 +executed under control of the for statement.
 36.2599 +\end{description}
 36.2600 +
 36.2601 +\begin{description}
 36.2602 +\item[{\rm Note:}\hspace*{31pt}] Only the following statements can be
 36.2603 +used within the for statement: check, display, printf, and another for.
 36.2604 +\end{description}
 36.2605 +
 36.2606 +\noindent{\bf Examples}
 36.2607 +
 36.2608 +\begin{verbatim}
 36.2609 +for {(i,j) in E: i != j}
 36.2610 +{  printf "flow from %s to %s is %g\n", i, j, x[i,j];
 36.2611 +   check x[i,j] >= 0;
 36.2612 +}
 36.2613 +\end{verbatim}
 36.2614 +
 36.2615 +\newpage
 36.2616 +
 36.2617 +\begin{verbatim}
 36.2618 +for {i in 1..n}
 36.2619 +{  for {j in 1..n} printf " %s", if x[i,j] then "Q" else ".";
 36.2620 +   printf("\n");
 36.2621 +}
 36.2622 +for {1..72} printf("*");
 36.2623 +\end{verbatim}
 36.2624 +
 36.2625 +The for statement causes a statement or a sequence of statements
 36.2626 +specified as part of the for statement to be executed for every
 36.2627 +$n$-tuple in the domain set. Thus, statements within the for statement
 36.2628 +may include dummy indices introduced in corresponding indexing
 36.2629 +expression.
 36.2630 +
 36.2631 +\subsection{Table statement}
 36.2632 +
 36.2633 +\medskip
 36.2634 +
 36.2635 +\framebox[345pt][l]{
 36.2636 +\parbox[c][68pt]{345pt}{
 36.2637 +\hspace{6pt} {\tt table} {\it name} {\it alias} {\tt IN} {\it driver}
 36.2638 +{\it arg} \dots {\it arg} {\tt:}
 36.2639 +
 36.2640 +\hspace{6pt} {\tt\ \ \ \ \ } {\it set} {\tt<-} {\tt[} {\it fld} {\tt,}
 36.2641 +\dots {\tt,} {\it fld} {\tt]} {\tt,} {\it par} {\tt\textasciitilde}
 36.2642 +{\it fld} {\tt,} \dots {\tt,} {\it par} {\tt\textasciitilde} {\it fld}
 36.2643 +{\tt;}
 36.2644 +
 36.2645 +\medskip
 36.2646 +
 36.2647 +\hspace{6pt} {\tt table} {\it name} {\it alias} {\it domain} {\tt OUT}
 36.2648 +{\it driver} {\it arg} \dots {\it arg} {\tt:}
 36.2649 +
 36.2650 +\hspace{6pt} {\tt\ \ \ \ \ } {\it expr} {\tt\textasciitilde} {\it fld}
 36.2651 +{\tt,} \dots {\tt,} {\it expr} {\tt\textasciitilde} {\it fld} {\tt;}
 36.2652 +}}
 36.2653 +
 36.2654 +\setlength{\leftmargini}{60pt}
 36.2655 +
 36.2656 +\begin{description}
 36.2657 +\item[{\rm Where:}\hspace*{23pt}] {\it name} is a symbolic name of the
 36.2658 +table;
 36.2659 +\item[\hspace*{54pt}] {\it alias} is an optional string literal, which
 36.2660 +specifies an alias of the table;
 36.2661 +\item[\hspace*{54pt}] {\it domain} is an indexing expression, which
 36.2662 +specifies a subscript domain of the (output) table;
 36.2663 +\item[\hspace*{54pt}] {\tt IN} means reading data from the input table;
 36.2664 +\item[\hspace*{54pt}] {\tt OUT} means writing data to the output table;
 36.2665 +\item[\hspace*{54pt}] {\it driver} is a symbolic expression, which
 36.2666 +specifies the driver used to access the table (for details see Section
 36.2667 +\ref{drivers}, page \pageref{drivers});
 36.2668 +\item[\hspace*{54pt}] {\it arg} is an optional symbolic expression,
 36.2669 +which is an argument pass\-ed to the table driver. This symbolic
 36.2670 +expression must not include dummy indices specified in the domain;
 36.2671 +\item[\hspace*{54pt}] {\it set} is the name of an optional simple set
 36.2672 +called {\it control set}. It can be omitted along with the delimiter
 36.2673 +{\tt<-};
 36.2674 +\item[\hspace*{54pt}] {\it fld} is a field name. Within square brackets
 36.2675 +at least one field should be specified. The field name following
 36.2676 +a parameter name or expression is optional and can be omitted along
 36.2677 +with the delimiter {\tt\textasciitilde}, in which case the name of
 36.2678 +corresponding model object is used as the field name;
 36.2679 +\item[\hspace*{54pt}] {\it par} is a symbolic name of a model parameter;
 36.2680 +\item[\hspace*{54pt}] {\it expr} is a numeric or symbolic expression.
 36.2681 +\end{description}
 36.2682 +
 36.2683 +\newpage
 36.2684 +
 36.2685 +\noindent{\bf Examples}
 36.2686 +
 36.2687 +\begin{verbatim}
 36.2688 +table data IN "CSV" "data.csv":
 36.2689 +   S <- [FROM,TO], d~DISTANCE, c~COST;
 36.2690 +table result{(f,t) in S} OUT "CSV" "result.csv":
 36.2691 +   f~FROM, t~TO, x[f,t]~FLOW;
 36.2692 +\end{verbatim}
 36.2693 +
 36.2694 +The table statement allows reading data from a table into model
 36.2695 +objects such as sets and (non-scalar) parameters as well as writing
 36.2696 +data from the model to a table.
 36.2697 +
 36.2698 +\subsubsection{Table structure}
 36.2699 +
 36.2700 +A {\it data table} is an (unordered) set of {\it records}, where each
 36.2701 +record consists of the same number of {\it fields}, and each field is
 36.2702 +provided with a unique symbolic name called the {\it field name}. For
 36.2703 +example:
 36.2704 +
 36.2705 +\bigskip
 36.2706 +
 36.2707 +\begin{tabular}{@{\hspace*{38mm}}c@{\hspace*{11mm}}c@{\hspace*{10mm}}c
 36.2708 +@{\hspace*{9mm}}c}
 36.2709 +First&Second&&Last\\
 36.2710 +field&field&.\ \ .\ \ .&field\\
 36.2711 +$\downarrow$&$\downarrow$&&$\downarrow$\\
 36.2712 +\end{tabular}
 36.2713 +
 36.2714 +\begin{tabular}{ll@{}}
 36.2715 +Table header&$\rightarrow$\\
 36.2716 +First record&$\rightarrow$\\
 36.2717 +Second record&$\rightarrow$\\
 36.2718 +\\
 36.2719 +\hfil .\ \ .\ \ .\\
 36.2720 +\\
 36.2721 +Last record&$\rightarrow$\\
 36.2722 +\end{tabular}
 36.2723 +\begin{tabular}{|l|l|c|c|}
 36.2724 +\hline
 36.2725 +{\tt FROM}&{\tt TO}&{\tt DISTANCE}&{\tt COST}\\
 36.2726 +\hline
 36.2727 +{\tt Seattle}  &{\tt New-York}&{\tt 2.5}&{\tt 0.12}\\
 36.2728 +{\tt Seattle}  &{\tt Chicago} &{\tt 1.7}&{\tt 0.08}\\
 36.2729 +{\tt Seattle}  &{\tt Topeka}  &{\tt 1.8}&{\tt 0.09}\\
 36.2730 +{\tt San-Diego}&{\tt New-York}&{\tt 2.5}&{\tt 0.15}\\
 36.2731 +{\tt San-Diego}&{\tt Chicago} &{\tt 1.8}&{\tt 0.10}\\
 36.2732 +{\tt San-Diego}&{\tt Topeka}  &{\tt 1.4}&{\tt 0.07}\\
 36.2733 +\hline
 36.2734 +\end{tabular}
 36.2735 +
 36.2736 +\subsubsection{Reading data from input table}
 36.2737 +
 36.2738 +The input table statement causes reading data from the specified table
 36.2739 +record by record.
 36.2740 +
 36.2741 +Once a next record has been read, numeric or symbolic values of fields,
 36.2742 +whose names are enclosed in square brackets in the table statement, are
 36.2743 +gathered into $n$-tuple, and if the control set is specified in the
 36.2744 +table statement, this $n$-tuple is added to it. Besides, a numeric or
 36.2745 +symbolic value of each field associated with a model parameter is
 36.2746 +assigned to the parameter member identified by subscripts, which are
 36.2747 +components of the $n$-tuple just read.
 36.2748 +
 36.2749 +For example, the following input table statement:
 36.2750 +
 36.2751 +\medskip
 36.2752 +
 36.2753 +\noindent\hfil
 36.2754 +\verb|table data IN "...": S <- [FROM,TO], d~DISTANCE, c~COST;|
 36.2755 +
 36.2756 +\medskip
 36.2757 +
 36.2758 +\noindent
 36.2759 +causes reading values of four fields named {\tt FROM}, {\tt TO},
 36.2760 +{\tt DISTANCE}, and {\tt COST} from each record of the specified table.
 36.2761 +Values of fields {\tt FROM} and {\tt TO} give a pair $(f,t)$, which is
 36.2762 +added to the control set {\tt S}. The value of field {\tt DISTANCE} is
 36.2763 +assigned to parameter member ${\tt d}[f,t]$, and the value of field
 36.2764 +{\tt COST} is assigned to parameter member ${\tt c}[f,t]$.
 36.2765 +
 36.2766 +Note that the input table may contain extra fields whose names are not
 36.2767 +specified in the table statement, in which case values of these fields
 36.2768 +on reading the table are ignored.
 36.2769 +
 36.2770 +\subsubsection{Writing data to output table}
 36.2771 +
 36.2772 +The output table statement causes writing data to the specified table.
 36.2773 +Note that some drivers (namely, CSV and xBASE) destroy the output table
 36.2774 +before writing data, i.e. delete all its existing records.
 36.2775 +
 36.2776 +Each $n$-tuple in the specified domain set generates one record written
 36.2777 +to the output table. Values of fields are numeric or symbolic values of
 36.2778 +corresponding expressions specified in the table statement. These
 36.2779 +expressions are evaluated for each $n$-tuple in the domain set and,
 36.2780 +thus, may include dummy indices introduced in the corresponding indexing
 36.2781 +expression.
 36.2782 +
 36.2783 +For example, the following output table statement:
 36.2784 +
 36.2785 +\medskip
 36.2786 +
 36.2787 +\noindent
 36.2788 +\verb|   table result{(f,t) in S} OUT "...": f~FROM, t~TO, x[f,t]~FLOW;|
 36.2789 +
 36.2790 +\medskip
 36.2791 +
 36.2792 +\noindent
 36.2793 +causes writing records, by one record for each pair $(f,t)$ in set
 36.2794 +{\tt S}, to the output table, where each record consists of three
 36.2795 +fields named {\tt FROM}, {\tt TO}, and {\tt FLOW}. The values written
 36.2796 +to fields {\tt FROM} and {\tt TO} are current values of dummy indices
 36.2797 +{\tt f} and {\tt t}, and the value written to field {\tt FLOW} is
 36.2798 +a value of member ${\tt x}[f,t]$ of corresponding subscripted parameter
 36.2799 +or variable.
 36.2800 +
 36.2801 +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 36.2802 +
 36.2803 +\newpage
 36.2804 +
 36.2805 +\section{Model data}
 36.2806 +
 36.2807 +{\it Model data} include elemental sets, which are ``values'' of model
 36.2808 +sets, and numeric and symbolic values of model parameters.
 36.2809 +
 36.2810 +In MathProg there are two different ways to saturate model sets and
 36.2811 +parameters with data. One way is simply providing necessary data using
 36.2812 +the assign attribute. However, in many cases it is more practical to
 36.2813 +separate the model itself and particular data needed for the model. For
 36.2814 +the latter reason in MathProg there is another way, when the model
 36.2815 +description is divided into two parts: model section and data section.
 36.2816 +
 36.2817 +A {\it model section} is a main part of the model description that
 36.2818 +contains declarations of all model objects and is common for all
 36.2819 +problems based on that model.
 36.2820 +
 36.2821 +A {\it data section} is an optional part of the model description that
 36.2822 +contains model data specific for a particular problem.
 36.2823 +
 36.2824 +In MathProg model and data sections can be placed either in one text
 36.2825 +file or in two separate text files.
 36.2826 +
 36.2827 +1. If both model and data sections are placed in one file, the file is
 36.2828 +composed as follows:
 36.2829 +
 36.2830 +\bigskip
 36.2831 +
 36.2832 +\noindent\hfil
 36.2833 +\framebox{\begin{tabular}{l}
 36.2834 +{\it statement}{\tt;}\\
 36.2835 +{\it statement}{\tt;}\\
 36.2836 +\hfil.\ \ .\ \ .\\
 36.2837 +{\it statement}{\tt;}\\
 36.2838 +{\tt data;}\\
 36.2839 +{\it data block}{\tt;}\\
 36.2840 +{\it data block}{\tt;}\\
 36.2841 +\hfil.\ \ .\ \ .\\
 36.2842 +{\it data block}{\tt;}\\
 36.2843 +{\tt end;}
 36.2844 +\end{tabular}}
 36.2845 +
 36.2846 +\bigskip
 36.2847 +
 36.2848 +2. If the model and data sections are placed in two separate files, the
 36.2849 +files are composed as follows:
 36.2850 +
 36.2851 +\bigskip
 36.2852 +
 36.2853 +\noindent\hfil
 36.2854 +\begin{tabular}{@{}c@{}}
 36.2855 +\framebox{\begin{tabular}{l}
 36.2856 +{\it statement}{\tt;}\\
 36.2857 +{\it statement}{\tt;}\\
 36.2858 +\hfil.\ \ .\ \ .\\
 36.2859 +{\it statement}{\tt;}\\
 36.2860 +{\tt end;}\\
 36.2861 +\end{tabular}}\\
 36.2862 +\\\\Model file\\
 36.2863 +\end{tabular}
 36.2864 +\hspace{32pt}
 36.2865 +\begin{tabular}{@{}c@{}}
 36.2866 +\framebox{\begin{tabular}{l}
 36.2867 +{\tt data;}\\
 36.2868 +{\it data block}{\tt;}\\
 36.2869 +{\it data block}{\tt;}\\
 36.2870 +\hfil.\ \ .\ \ .\\
 36.2871 +{\it data block}{\tt;}\\
 36.2872 +{\tt end;}\\
 36.2873 +\end{tabular}}\\
 36.2874 +\\Data file\\
 36.2875 +\end{tabular}
 36.2876 +
 36.2877 +\bigskip
 36.2878 +
 36.2879 +\begin{description}
 36.2880 +\item[{\rm Note:}\hspace*{31pt}] If the data section is placed in a
 36.2881 +separate file, the keyword {\tt data} is optional and may be omitted
 36.2882 +along with the semicolon that follows it.
 36.2883 +\end{description}
 36.2884 +
 36.2885 +\subsection{Coding data section}
 36.2886 +
 36.2887 +The {\it data section} is a sequence of data blocks in various formats,
 36.2888 +which are discussed in following subsections. The order, in which data
 36.2889 +blocks follow in the data section, may be arbitrary, not necessarily
 36.2890 +the same, in which corresponding model objects follow in the model
 36.2891 +section.
 36.2892 +
 36.2893 +The rules of coding the data section are commonly the same as the rules
 36.2894 +of coding the model description (see Subsection \ref{coding}, page
 36.2895 +\pageref{coding}), i.e. data blocks are composed from basic lexical
 36.2896 +units such as symbolic names, numeric and string literals, keywords,
 36.2897 +delimiters, and comments. However, for the sake of convenience and
 36.2898 +improving readability there is one deviation from the common rule: if
 36.2899 +a string literal consists of only alphanumeric characters (including
 36.2900 +the underscore character), the signs {\tt+} and {\tt-}, and/or the
 36.2901 +decimal point, it may be coded without bordering by (single or double)
 36.2902 +quotes.
 36.2903 +
 36.2904 +All numeric and symbolic material provided in the data section is coded
 36.2905 +in the form of numbers and symbols, i.e. unlike the model section
 36.2906 +no expressions are allowed in the data section. Nevertheless, the signs
 36.2907 +{\tt+} and {\tt-} can precede numeric literals to allow coding signed
 36.2908 +numeric quantities, in which case there must be no white-space
 36.2909 +characters between the sign and following numeric literal (if there is
 36.2910 +at least one white-space, the sign and following numeric literal are
 36.2911 +recognized as two different lexical units).
 36.2912 +
 36.2913 +\subsection{Set data block}
 36.2914 +
 36.2915 +\medskip
 36.2916 +
 36.2917 +\framebox[345pt][l]{
 36.2918 +\parbox[c][44pt]{345pt}{
 36.2919 +\hspace{6pt} {\tt set} {\it name} {\tt,} {\it record} {\tt,} \dots
 36.2920 +{\tt,} {\it record} {\tt;}
 36.2921 +
 36.2922 +\medskip
 36.2923 +
 36.2924 +\hspace{6pt} {\tt set} {\it name} {\tt[} {\it symbol} {\tt,} \dots
 36.2925 +{\tt,} {\it symbol} {\tt]} {\tt,} {\it record} {\tt,} \dots {\tt,}
 36.2926 +{\it record} {\tt;}
 36.2927 +}}
 36.2928 +
 36.2929 +\setlength{\leftmargini}{60pt}
 36.2930 +
 36.2931 +\begin{description}
 36.2932 +\item[{\rm Where:}\hspace*{23pt}] {\it name} is a symbolic name of the
 36.2933 +set;
 36.2934 +\item[\hspace*{54pt}] {\it symbol}, \dots, {\it symbol} are subscripts,
 36.2935 +which specify a particular member of the set (if the set is an array,
 36.2936 +i.e. a set of sets);
 36.2937 +\item[\hspace*{54pt}] {\it record}, \dots, {\it record} are data
 36.2938 +records.
 36.2939 +\end{description}
 36.2940 +
 36.2941 +\begin{description}
 36.2942 +\item[{\rm Note:}\hspace*{31pt}] Commae preceding data records may be
 36.2943 +omitted.
 36.2944 +\end{description}
 36.2945 +
 36.2946 +\noindent Data records:
 36.2947 +
 36.2948 +\begin{description}
 36.2949 +\item[{\tt :=}\hspace*{45pt}] is a non-significant data record, which
 36.2950 +may be used freely to improve readability;
 36.2951 +\item[{\tt(} {\it slice} {\tt)}\hspace*{18.5pt}] specifies a slice;
 36.2952 +\item[{\it simple-data}\hspace*{5.5pt}] specifies set data in the
 36.2953 +simple format;
 36.2954 +\item[{\tt:} {\it matrix-data}]\hspace*{0pt}\\
 36.2955 +specifies set data in the matrix format;
 36.2956 +\item[{\tt(tr)} {\tt:} {\it matrix-data}]\hspace*{0pt}\\
 36.2957 +specifies set data in the transposed matrix format. (In this case the
 36.2958 +colon following the keyword {\tt(tr)} may be omitted.)
 36.2959 +\end{description}
 36.2960 +
 36.2961 +\noindent{\bf Examples}
 36.2962 +
 36.2963 +\begin{verbatim}
 36.2964 +set month := Jan Feb Mar Apr May Jun;
 36.2965 +set month "Jan", "Feb", "Mar", "Apr", "May", "Jun";
 36.2966 +set A[3,Mar] := (1,2) (2,3) (4,2) (3,1) (2,2) (4,4) (3,4);
 36.2967 +set A[3,'Mar'] := 1 2 2 3 4 2 3 1 2 2 4 4 2 4;
 36.2968 +set A[3,'Mar'] : 1 2 3 4 :=
 36.2969 +               1 - + - -
 36.2970 +               2 - + + -
 36.2971 +               3 + - - +
 36.2972 +               4 - + - + ;
 36.2973 +set B := (1,2,3) (1,3,2) (2,3,1) (2,1,3) (1,2,2) (1,1,1) (2,1,1);
 36.2974 +set B := (*,*,*) 1 2 3, 1 3 2, 2 3 1, 2 1 3, 1 2 2, 1 1 1, 2 1 1;
 36.2975 +set B := (1,*,2) 3 2 (2,*,1) 3 1 (1,2,3) (2,1,3) (1,1,1);
 36.2976 +set B := (1,*,*) : 1 2 3 :=
 36.2977 +                 1 + - -
 36.2978 +                 2 - + +
 36.2979 +                 3 - + -
 36.2980 +         (2,*,*) : 1 2 3 :=
 36.2981 +                 1 + - +
 36.2982 +                 2 - - -
 36.2983 +                 3 + - - ;
 36.2984 +\end{verbatim}
 36.2985 +
 36.2986 +\noindent(In these examples {\tt month} is a simple set of singlets,
 36.2987 +{\tt A} is a 2-dimensional array of doublets, and {\tt B} is a simple
 36.2988 +set of triplets. Data blocks for the same set are equivalent in the
 36.2989 +sense that they specify the same data in different formats.)
 36.2990 +
 36.2991 +\medskip
 36.2992 +
 36.2993 +The {\it set data block} is used to specify a complete elemental set,
 36.2994 +which is assigned to a set (if it is a simple set) or one of its
 36.2995 +members (if the set is an array of sets).\footnote{There is another way
 36.2996 +to specify data for a simple set along with data for parameters. This
 36.2997 +feature is discussed in the next subsection.}
 36.2998 +
 36.2999 +Data blocks can be specified only for non-computable sets, i.e. for
 36.3000 +sets, which have no assign ({\tt:=}) attribute in the corresponding set
 36.3001 +statements.
 36.3002 +
 36.3003 +If the set is a simple set, only its symbolic name should be specified
 36.3004 +in the header of the data block. Otherwise, if the set is a
 36.3005 +$n$-dimensional array, its symbolic name should be provided with a
 36.3006 +complete list of subscripts separated by commae and enclosed in square
 36.3007 +brackets to specify a particular member of the set array. The number of
 36.3008 +subscripts must be the same as the dimension of the set array, where
 36.3009 +each subscript must be a number or symbol.
 36.3010 +
 36.3011 +An elemental set defined in the set data block is coded as a sequence
 36.3012 +of data records described below.\footnote{{\it Data record} is simply a
 36.3013 +technical term. It does not mean that data records have any special
 36.3014 +formatting.}
 36.3015 +
 36.3016 +\newpage
 36.3017 +
 36.3018 +\subsubsection{Assign data record}
 36.3019 +
 36.3020 +The {\it assign} ({\tt:=}) {\it data record} is a non-signficant
 36.3021 +element. It may be used for improving readability of data blocks.
 36.3022 +
 36.3023 +\subsubsection{Slice data record}
 36.3024 +
 36.3025 +The {\it slice data record} is a control record, which specifies a
 36.3026 +{\it slice} of the elemental set defined in the data block. It has the
 36.3027 +following syntactic form:
 36.3028 +
 36.3029 +\medskip
 36.3030 +
 36.3031 +\noindent\hfil
 36.3032 +{\tt(} $s_1$ {\tt,} $s_2$ {\tt,} \dots {\tt,} $s_n$ {\tt)}
 36.3033 +
 36.3034 +\medskip
 36.3035 +
 36.3036 +\noindent where $s_1$, $s_2$, \dots, $s_n$ are components of the slice.
 36.3037 +
 36.3038 +Each component of the slice can be a number or symbol or the asterisk
 36.3039 +({\tt*}). The number of components in the slice must be the same as the
 36.3040 +dimension of $n$-tuples in the elemental set to be defined. For
 36.3041 +instance, if the elemental set contains 4-tuples (quadruplets), the
 36.3042 +slice must have four components. The number of asterisks in the slice
 36.3043 +is called the {\it slice dimension}.
 36.3044 +
 36.3045 +The effect of using slices is the following. If a $m$-dimensional slice
 36.3046 +(i.e. a slice having $m$ asterisks) is specified in the data block, all
 36.3047 +subsequent data records must specify tuples of the dimension $m$.
 36.3048 +Whenever a $m$-tuple is encountered, each asterisk in the slice is
 36.3049 +replaced by corresponding components of the $m$-tuple that gives the
 36.3050 +resultant $n$-tuple, which is included in the elemental set to be
 36.3051 +defined. For example, if the slice $(a,*,1,2,*)$ is in effect, and
 36.3052 +2-tuple $(3,b)$ is encountered in a subsequent data record, the
 36.3053 +resultant 5-tuple included in the elemental set is $(a,3,1,2,b)$.
 36.3054 +
 36.3055 +The slice having no asterisks itself defines a complete $n$-tuple,
 36.3056 +which is included in the elemental set.
 36.3057 +
 36.3058 +Being once specified the slice effects until either a new slice or the
 36.3059 +end of data block is encountered. Note that if no slice is specified in
 36.3060 +the data block, one, components of which are all asterisks, is assumed.
 36.3061 +
 36.3062 +\subsubsection{Simple data record}
 36.3063 +
 36.3064 +The {\it simple data record} defines one $n$-tuple in a simple format
 36.3065 +and has the following syntactic form:
 36.3066 +
 36.3067 +\medskip
 36.3068 +
 36.3069 +\noindent\hfil
 36.3070 +$t_1$ {\tt,} $t_2$ {\tt,} \dots {\tt,} $t_n$
 36.3071 +
 36.3072 +\medskip
 36.3073 +
 36.3074 +\noindent where $t_1$, $t_2$, \dots, $t_n$ are components of the
 36.3075 +$n$-tuple. Each component can be a number or symbol. Commae between
 36.3076 +components are optional and may be omitted.
 36.3077 +
 36.3078 +\subsubsection{Matrix data record}
 36.3079 +
 36.3080 +The {\it matrix data record} defines several 2-tuples (doublets) in
 36.3081 +a matrix format and has the following syntactic form:
 36.3082 +
 36.3083 +\newpage
 36.3084 +
 36.3085 +$$\begin{array}{cccccc}
 36.3086 +\mbox{{\tt:}}&c_1&c_2&\dots&c_n&\mbox{{\tt:=}}\\
 36.3087 +r_1&a_{11}&a_{12}&\dots&a_{1n}&\\
 36.3088 +r_2&a_{21}&a_{22}&\dots&a_{2n}&\\
 36.3089 +\multicolumn{5}{c}{.\ \ .\ \ .\ \ .\ \ .\ \ .\ \ .\ \ .\ \ .}&\\
 36.3090 +r_m&a_{m1}&a_{m2}&\dots&a_{mn}&\\
 36.3091 +\end{array}$$
 36.3092 +where $r_1$, $r_2$, \dots, $r_m$ are numbers and/or symbols
 36.3093 +corresponding to rows of the matrix; $c_1$, $c_2$, \dots, $c_n$ are
 36.3094 +numbers and/or symbols corresponding to columns of the matrix, $a_{11}$,
 36.3095 +$a_{12}$, \dots, $a_{mn}$ are matrix elements, which can be either
 36.3096 +{\tt+} or {\tt-}. (In this data record the delimiter {\tt:} preceding
 36.3097 +the column list and the delimiter {\tt:=} following the column list
 36.3098 +cannot be omitted.)
 36.3099 +
 36.3100 +Each element $a_{ij}$ of the matrix data block (where $1\leq i\leq m$,
 36.3101 +$1\leq j\leq n$) corresponds to 2-tuple $(r_i,c_j)$. If $a_{ij}$ is the
 36.3102 +plus sign ({\tt+}), that 2-tuple (or a longer $n$-tuple, if a slice is
 36.3103 +used) is included in the elemental set. Otherwise, if $a_{ij}$ is the
 36.3104 +minus sign ({\tt-}), that 2-tuple is not included in the elemental set.
 36.3105 +
 36.3106 +Since the matrix data record defines 2-tuples, either the elemental set
 36.3107 +must consist of 2-tuples or the slice currently used must be
 36.3108 +2-dimensional.
 36.3109 +
 36.3110 +\subsubsection{Transposed matrix data record}
 36.3111 +
 36.3112 +The {\it transposed matrix data record} has the following syntactic
 36.3113 +form:
 36.3114 +$$\begin{array}{cccccc}
 36.3115 +\mbox{{\tt(tr) :}}&c_1&c_2&\dots&c_n&\mbox{{\tt:=}}\\
 36.3116 +r_1&a_{11}&a_{12}&\dots&a_{1n}&\\
 36.3117 +r_2&a_{21}&a_{22}&\dots&a_{2n}&\\
 36.3118 +\multicolumn{5}{c}{.\ \ .\ \ .\ \ .\ \ .\ \ .\ \ .\ \ .\ \ .}&\\
 36.3119 +r_m&a_{m1}&a_{m2}&\dots&a_{mn}&\\
 36.3120 +\end{array}$$
 36.3121 +(In this case the delimiter {\tt:} following the keyword {\tt(tr)} is
 36.3122 +optional and may be omitted.)
 36.3123 +
 36.3124 +This data record is completely analogous to the matrix data record (see
 36.3125 +above) with only exception that in this case each element $a_{ij}$ of
 36.3126 +the matrix corresponds to 2-tuple $(c_j,r_i)$ rather than $(r_i,c_j)$.
 36.3127 +
 36.3128 +Being once specified the {\tt(tr)} indicator affects all subsequent
 36.3129 +data records until either a slice or the end of data block is
 36.3130 +encountered.
 36.3131 +
 36.3132 +\subsection{Parameter data block}
 36.3133 +
 36.3134 +\medskip
 36.3135 +
 36.3136 +\framebox[345pt][l]{
 36.3137 +\parbox[c][80pt]{345pt}{
 36.3138 +\hspace{6pt} {\tt param} {\it name} {\tt,} {\it record} {\tt,} \dots
 36.3139 +{\tt,} {\it record} {\tt;}
 36.3140 +
 36.3141 +\medskip
 36.3142 +
 36.3143 +\hspace{6pt} {\tt param} {\it name} {\tt default} {\it value} {\tt,}
 36.3144 +{\it record} {\tt,} \dots {\tt,} {\it record} {\tt;}
 36.3145 +
 36.3146 +\medskip
 36.3147 +
 36.3148 +\hspace{6pt} {\tt param} {\tt:} {\it tabbing-data} {\tt;}
 36.3149 +
 36.3150 +\medskip
 36.3151 +
 36.3152 +\hspace{6pt} {\tt param} {\tt default} {\it value} {\tt:}
 36.3153 +{\it tabbing-data} {\tt;}
 36.3154 +}}
 36.3155 +
 36.3156 +\newpage
 36.3157 +
 36.3158 +\setlength{\leftmargini}{60pt}
 36.3159 +
 36.3160 +\begin{description}
 36.3161 +\item[{\rm Where:}\hspace*{23pt}] {\it name} is a symbolic name of the
 36.3162 +parameter;
 36.3163 +\item[\hspace*{54pt}] {\it value} is an optional default value of the
 36.3164 +parameter;
 36.3165 +\item[\hspace*{54pt}] {\it record}, \dots, {\it record} are data
 36.3166 +records;
 36.3167 +\item[\hspace*{54pt}] {\it tabbing-data} specifies parameter data in
 36.3168 +the tabbing format.
 36.3169 +\end{description}
 36.3170 +
 36.3171 +\begin{description}
 36.3172 +\item[{\rm Note:}\hspace*{31pt}] Commae preceding data records may be
 36.3173 +omitted.
 36.3174 +\end{description}
 36.3175 +
 36.3176 +\noindent Data records:
 36.3177 +
 36.3178 +\begin{description}
 36.3179 +\item[{\tt :=}\hspace*{45pt}] is a non-significant data record, which
 36.3180 +may be used freely to improve readability;
 36.3181 +\item[{\tt[} {\it slice} {\tt]}\hspace*{18.5pt}] specifies a slice;
 36.3182 +\item[{\it plain-data}\hspace*{11pt}] specifies parameter data in the
 36.3183 +plain format;
 36.3184 +\item[{\tt:} {\it tabular-data}]\hspace*{0pt}\\
 36.3185 +specifies parameter data in the tabular format;
 36.3186 +\item[{\tt(tr)} {\tt:} {\it tabular-data}]\hspace*{0pt}\\
 36.3187 +specifies set data in the transposed tabular format. (In this case the
 36.3188 +colon following the keyword {\tt(tr)} may be omitted.)
 36.3189 +\end{description}
 36.3190 +
 36.3191 +\noindent{\bf Examples}
 36.3192 +
 36.3193 +\begin{verbatim}
 36.3194 +param T := 4;
 36.3195 +param month := 1 'Jan' 2 'Feb' 3 'Mar' 4 'Apr' 5 'May';
 36.3196 +param month := [1] Jan, [2] Feb, [3] Mar, [4] Apr, [5] May;
 36.3197 +param day := [Sun] 0, [Mon] 1, [Tue] 2, [Wed] 3, [Thu] 4,
 36.3198 +             [Fri] 5, [Sat] 6;
 36.3199 +param init_stock := iron 7.32 nickel 35.8;
 36.3200 +param init_stock [*] iron 7.32, nickel 35.8;
 36.3201 +param cost [iron] .025 [nickel] .03;
 36.3202 +param value := iron -.1, nickel .02;
 36.3203 +param       : init_stock cost value :=
 36.3204 +      iron       7.32    .025  -.1
 36.3205 +      nickel    35.8     .03    .02 ;
 36.3206 +param : raw : init_stock cost value :=
 36.3207 +      iron       7.32    .025  -.1
 36.3208 +      nickel    35.8     .03    .02 ;
 36.3209 +param demand default 0 (tr)
 36.3210 +       :  FRA  DET  LAN  WIN  STL  FRE  LAF :=
 36.3211 +   bands  300   .   100   75   .   225  250
 36.3212 +   coils  500  750  400  250   .   850  500
 36.3213 +   plate  100   .    .    50  200   .   250 ;
 36.3214 +\end{verbatim}
 36.3215 +
 36.3216 +\newpage
 36.3217 +
 36.3218 +\begin{verbatim}
 36.3219 +param trans_cost :=
 36.3220 +   [*,*,bands]:  FRA  DET  LAN  WIN  STL  FRE  LAF :=
 36.3221 +         GARY     30   10    8   10   11   71    6
 36.3222 +         CLEV     22    7   10    7   21   82   13
 36.3223 +         PITT     19   11   12   10   25   83   15
 36.3224 +   [*,*,coils]:  FRA  DET  LAN  WIN  STL  FRE  LAF :=
 36.3225 +         GARY     39   14   11   14   16   82    8
 36.3226 +         CLEV     27    9   12    9   26   95   17
 36.3227 +         PITT     24   14   17   13   28   99   20
 36.3228 +   [*,*,plate]:  FRA  DET  LAN  WIN  STL  FRE  LAF :=
 36.3229 +         GARY     41   15   12   16   17   86    8
 36.3230 +         CLEV     29    9   13    9   28   99   18
 36.3231 +         PITT     26   14   17   13   31  104   20 ;
 36.3232 +\end{verbatim}
 36.3233 +
 36.3234 +The {\it parameter data block} is used to specify complete data for a
 36.3235 +parameter (or parameters, if data are specified in the tabbing format).
 36.3236 +
 36.3237 +Data blocks can be specified only for non-computable parameters, i.e.
 36.3238 +for parameters, which have no assign ({\tt:=}) attribute in the
 36.3239 +corresponding parameter statements.
 36.3240 +
 36.3241 +Data defined in the parameter data block are coded as a sequence of
 36.3242 +data records described below. Additionally the data block can be
 36.3243 +provided with the optional {\tt default} attribute, which specifies a
 36.3244 +default numeric or symbolic value of the parameter (parameters). This
 36.3245 +default value is assigned to the parameter or its members, if
 36.3246 +no appropriate value is defined in the parameter data block. The
 36.3247 +{\tt default} attribute cannot be used, if it is already specified in
 36.3248 +the corresponding parameter statement.
 36.3249 +
 36.3250 +\subsubsection{Assign data record}
 36.3251 +
 36.3252 +The {\it assign} ({\tt:=}) {\it data record} is a non-signficant
 36.3253 +element. It may be used for improving readability of data blocks.
 36.3254 +
 36.3255 +\subsubsection{Slice data record}
 36.3256 +
 36.3257 +The {\it slice data record} is a control record, which specifies a
 36.3258 +{\it slice} of the parameter array. It has the following syntactic form:
 36.3259 +
 36.3260 +\medskip
 36.3261 +
 36.3262 +\noindent\hfil
 36.3263 +{\tt[} $s_1$ {\tt,} $s_2$ {\tt,} \dots {\tt,} $s_n$ {\tt]}
 36.3264 +
 36.3265 +\medskip
 36.3266 +
 36.3267 +\noindent where $s_1$, $s_2$, \dots, $s_n$ are components of the slice.
 36.3268 +
 36.3269 +Each component of the slice can be a number or symbol or the asterisk
 36.3270 +({\tt*}). The number of components in the slice must be the same as the
 36.3271 +dimension of the parameter. For instance, if the parameter is a
 36.3272 +4-dimensional array, the slice must have four components. The number of
 36.3273 +asterisks in the slice is called the {\it slice dimension}.
 36.3274 +
 36.3275 +The effect of using slices is the following. If a $m$-dimensional slice
 36.3276 +(i.e. a slice having $m$ asterisks) is specified in the data block, all
 36.3277 +subsequent data records must specify subscripts of the parameter
 36.3278 +members as if the parameter were $m$-dimensional, not $n$-dimensional.
 36.3279 +
 36.3280 +Whenever $m$ subscripts are encountered, each asterisk in the slice is
 36.3281 +replaced by corresponding subscript that gives $n$ subscripts, which
 36.3282 +define the actual parameter member. For example, if the slice
 36.3283 +$[a,*,1,2,*]$ is in effect, and subscripts 3 and $b$ are encountered in
 36.3284 +a subsequent data record, the complete subscript list used to choose a
 36.3285 +parameter member is $[a,3,1,2,b]$.
 36.3286 +
 36.3287 +It is allowed to specify a slice having no asterisks. Such slice itself
 36.3288 +defines a complete subscript list, in which case the next data record
 36.3289 +should define only a single value of corresponding parameter member.
 36.3290 +
 36.3291 +Being once specified the slice effects until either a new slice or the
 36.3292 +end of data block is encountered. Note that if no slice is specified in
 36.3293 +the data block, one, components of which are all asterisks, is assumed.
 36.3294 +
 36.3295 +\subsubsection{Plain data record}
 36.3296 +
 36.3297 +The {\it plain data record} defines a subscript list and a single value
 36.3298 +in the plain format. This record has the following syntactic form:
 36.3299 +
 36.3300 +\medskip
 36.3301 +
 36.3302 +\noindent\hfil
 36.3303 +$t_1$ {\tt,} $t_2$ {\tt,} \dots {\tt,} $t_n$ {\tt,} $v$
 36.3304 +
 36.3305 +\medskip
 36.3306 +
 36.3307 +\noindent where $t_1$, $t_2$, \dots, $t_n$ are subscripts, and $v$ is a
 36.3308 +value. Each subscript as well as the value can be a number or symbol.
 36.3309 +Commae following subscripts are optional and may be omitted.
 36.3310 +
 36.3311 +In case of 0-dimensional parameter or slice the plain data record has
 36.3312 +no subscripts and consists of a single value only.
 36.3313 +
 36.3314 +\subsubsection{Tabular data record}
 36.3315 +
 36.3316 +The {\it tabular data record} defines several values, where each value
 36.3317 +is provided with two subscripts. This record has the following
 36.3318 +syntactic form:
 36.3319 +$$\begin{array}{cccccc}
 36.3320 +\mbox{{\tt:}}&c_1&c_2&\dots&c_n&\mbox{{\tt:=}}\\
 36.3321 +r_1&a_{11}&a_{12}&\dots&a_{1n}&\\
 36.3322 +r_2&a_{21}&a_{22}&\dots&a_{2n}&\\
 36.3323 +\multicolumn{5}{c}{.\ \ .\ \ .\ \ .\ \ .\ \ .\ \ .\ \ .\ \ .}&\\
 36.3324 +r_m&a_{m1}&a_{m2}&\dots&a_{mn}&\\
 36.3325 +\end{array}$$
 36.3326 +where $r_1$, $r_2$, \dots, $r_m$ are numbers and/or symbols
 36.3327 +corresponding to rows of the table; $c_1$, $c_2$, \dots, $c_n$ are
 36.3328 +numbers and/or symbols corresponding to columns of the table, $a_{11}$,
 36.3329 +$a_{12}$, \dots, $a_{mn}$ are table elements. Each element can be a
 36.3330 +number or symbol or the single decimal point ({\tt.}). (In this data
 36.3331 +record the delimiter {\tt:} preceding the column list and the delimiter
 36.3332 +{\tt:=} following the column list cannot be omitted.)
 36.3333 +
 36.3334 +Each element $a_{ij}$ of the tabular data block ($1\leq i\leq m$,
 36.3335 +$1\leq j\leq n$) defines two subscripts, where the first subscript is
 36.3336 +$r_i$, and the second one is $c_j$. These subscripts are used in
 36.3337 +conjunction with the current slice to form the complete subscript list
 36.3338 +that identifies a particular member of the parameter array. If $a_{ij}$
 36.3339 +is a number or symbol, this value is assigned to the parameter member.
 36.3340 +However, if $a_{ij}$ is the single decimal point, the member is
 36.3341 +assigned a default value specified either in the parameter data block
 36.3342 +or in the parameter statement, or, if no default value is specified,
 36.3343 +the member remains undefined.
 36.3344 +
 36.3345 +Since the tabular data record provides two subscripts for each value,
 36.3346 +either the parameter or the slice currently used must be 2-dimensional.
 36.3347 +
 36.3348 +\subsubsection{Transposed tabular data record}
 36.3349 +
 36.3350 +The {\it transposed tabular data record} has the following syntactic
 36.3351 +form:
 36.3352 +$$\begin{array}{cccccc}
 36.3353 +\mbox{{\tt(tr) :}}&c_1&c_2&\dots&c_n&\mbox{{\tt:=}}\\
 36.3354 +r_1&a_{11}&a_{12}&\dots&a_{1n}&\\
 36.3355 +r_2&a_{21}&a_{22}&\dots&a_{2n}&\\
 36.3356 +\multicolumn{5}{c}{.\ \ .\ \ .\ \ .\ \ .\ \ .\ \ .\ \ .\ \ .}&\\
 36.3357 +r_m&a_{m1}&a_{m2}&\dots&a_{mn}&\\
 36.3358 +\end{array}$$
 36.3359 +(In this case the delimiter {\tt:} following the keyword {\tt(tr)} is
 36.3360 +optional and may be omitted.)
 36.3361 +
 36.3362 +This data record is completely analogous to the tabular data record
 36.3363 +(see above) with only exception that the first subscript defined by
 36.3364 +element $a_{ij}$ is $c_j$ while the second one is $r_i$.
 36.3365 +
 36.3366 +Being once specified the {\tt(tr)} indicator affects all subsequent
 36.3367 +data records until either a slice or the end of data block is
 36.3368 +encountered.
 36.3369 +
 36.3370 +\subsubsection{Tabbing data format}
 36.3371 +
 36.3372 +The parameter data block in the {\it tabbing format} has the following
 36.3373 +syntactic form:
 36.3374 +$$\begin{array}{p{12pt}@{\ }l@{\ }c@{\ }l@{\ }c@{\ }l@{\ }r@{\ }l@{\ }c
 36.3375 +@{\ }l@{\ }c@{\ }l@{\ }l}
 36.3376 +\multicolumn{7}{@{}c@{}}{\mbox{\tt param}\ \mbox{\tt default}\ \mbox
 36.3377 +{\it value}\ \mbox{\tt:}\ \mbox{\it s}\ \mbox{\tt:}}&
 36.3378 +p_1&\mbox{\tt,}&p_2&\mbox{\tt,} \dots \mbox{\tt,}&p_k&\mbox{\tt:=}\\
 36.3379 +&t_{11}&\mbox{\tt,}&t_{12}&\mbox{\tt,} \dots \mbox{\tt,}&t_{1n}&
 36.3380 +\mbox{\tt,}&a_{11}&\mbox{\tt,}&a_{12}&\mbox{\tt,} \dots \mbox{\tt,}&
 36.3381 +a_{1k}\\
 36.3382 +&t_{21}&\mbox{\tt,}&t_{22}&\mbox{\tt,} \dots \mbox{\tt,}&t_{2n}&
 36.3383 +\mbox{\tt,}&a_{21}&\mbox{\tt,}&a_{22}&\mbox{\tt,} \dots \mbox{\tt,}&
 36.3384 +a_{2k}\\
 36.3385 +\multicolumn{13}{c}
 36.3386 +{.\ \ .\ \ .\ \ .\ \ .\ \ .\ \ .\ \ .\ \ .\ \ .\ \ .\ \ .\ \ .\ \ .}\\
 36.3387 +&t_{m1}&\mbox{\tt,}&t_{m2}&\mbox{\tt,} \dots \mbox{\tt,}&t_{mn}&
 36.3388 +\mbox{\tt,}&a_{m1}&\mbox{\tt,}&a_{m2}&\mbox{\tt,} \dots \mbox{\tt,}&
 36.3389 +a_{mk}&\mbox{\tt;}\\
 36.3390 +\end{array}$$
 36.3391 +
 36.3392 +{\it Notes:}
 36.3393 +
 36.3394 +1. The keyword {\tt default} may be omitted along with a value
 36.3395 +following it.
 36.3396 +
 36.3397 +2. Symbolic name {\tt s} may be omitted along with the colon following
 36.3398 +it.
 36.3399 +
 36.3400 +3. All comae are optional and may be omitted.
 36.3401 +
 36.3402 +\medskip
 36.3403 +
 36.3404 +The data block in the tabbing format shown above is exactly equivalent
 36.3405 +to the following data blocks for $j=1,2,\dots,k$:
 36.3406 +
 36.3407 +\medskip
 36.3408 +
 36.3409 +{\tt set} {\it s} {\tt:=}
 36.3410 +{\tt(}$t_{11}${\tt,}$t_{12}${\tt,}\dots{\tt,}$t_{1n}${\tt)}
 36.3411 +{\tt(}$t_{21}${\tt,}$t_{22}${\tt,}\dots{\tt,}$t_{2n}${\tt)} \dots
 36.3412 +{\tt(}$t_{m1}${\tt,}$t_{m2}${\tt,}\dots{\tt,}$t_{mn}${\tt)} {\tt;}
 36.3413 +
 36.3414 +{\tt param} $p_j$ {\tt default} {\it value} {\tt:=}
 36.3415 +
 36.3416 +$\!${\tt[}$t_{11}${\tt,}$t_{12}${\tt,}\dots{\tt,}$t_{1n}${\tt]}
 36.3417 +$a_{1j}$
 36.3418 +{\tt[}$t_{21}${\tt,}$t_{22}${\tt,}\dots{\tt,}$t_{2n}${\tt]} $a_{2j}$
 36.3419 +\dots
 36.3420 +{\tt[}$t_{m1}${\tt,}$t_{m2}${\tt,}\dots{\tt,}$t_{mn}${\tt]} $a_{mj}$
 36.3421 +{\tt;}
 36.3422 +
 36.3423 +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 36.3424 +
 36.3425 +\appendix
 36.3426 +
 36.3427 +\newpage
 36.3428 +
 36.3429 +\section{Using suffixes}
 36.3430 +
 36.3431 +Suffixes can be used to retrieve additional values associated with
 36.3432 +model variables, constraints, and objectives.
 36.3433 +
 36.3434 +A {\it suffix} consists of a period ({\tt.}) followed by a non-reserved
 36.3435 +keyword. For example, if {\tt x} is a two-dimensional variable,
 36.3436 +{\tt x[i,j].lb} is a numeric value equal to the lower bound of
 36.3437 +elemental variable {\tt x[i,j]}, which (value) can be used everywhere
 36.3438 +in expressions like a numeric parameter.
 36.3439 +
 36.3440 +For model variables suffixes have the following meaning:
 36.3441 +
 36.3442 +\medskip
 36.3443 +
 36.3444 +\begin{tabular}{@{}p{96pt}p{222pt}@{}}
 36.3445 +{\tt.lb}&lower bound\\
 36.3446 +{\tt.ub}&upper bound\\
 36.3447 +{\tt.status}&status in the solution:\\
 36.3448 +&0 --- undefined\\
 36.3449 +&1 --- basic\\
 36.3450 +&2 --- non-basic on lower bound\\
 36.3451 +&3 --- non-basic on upper bound\\
 36.3452 +&4 --- non-basic free (unbounded) variable\\
 36.3453 +&5 --- non-basic fixed variable\\
 36.3454 +{\tt.val}&primal value in the solution\\
 36.3455 +{\tt.dual}&dual value (reduced cost) in the solution\\
 36.3456 +\end{tabular}
 36.3457 +
 36.3458 +\medskip
 36.3459 +
 36.3460 +For model constraints and objectives suffixes have the following
 36.3461 +meaning:
 36.3462 +
 36.3463 +\medskip
 36.3464 +
 36.3465 +\begin{tabular}{@{}p{96pt}p{222pt}@{}}
 36.3466 +{\tt.lb}&lower bound of the linear form\\
 36.3467 +{\tt.ub}&upper bound of the linear form\\
 36.3468 +{\tt.status}&status in the solution:\\
 36.3469 +&0 --- undefined\\
 36.3470 +&1 --- non-active\\
 36.3471 +&2 --- active on lower bound\\
 36.3472 +&3 --- active on upper bound\\
 36.3473 +&4 --- active free (unbounded) row\\
 36.3474 +&5 --- active equality constraint\\
 36.3475 +{\tt.val}&primal value of the linear form in the solution\\
 36.3476 +{\tt.dual}&dual value (reduced cost) of the linear form in the
 36.3477 +solution\\
 36.3478 +\end{tabular}
 36.3479 +
 36.3480 +\medskip
 36.3481 +
 36.3482 +Note that suffixes {\tt.status}, {\tt.val}, and {\tt.dual} can be used
 36.3483 +only below the solve statement.
 36.3484 +
 36.3485 +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 36.3486 +
 36.3487 +\newpage
 36.3488 +
 36.3489 +\section{Date and time functions}
 36.3490 +
 36.3491 +\noindent\hfil
 36.3492 +by Andrew Makhorin \verb|<mao@gnu.org>|
 36.3493 +
 36.3494 +\noindent\hfil
 36.3495 +and Heinrich Schuchardt \verb|<heinrich.schuchardt@gmx.de>|
 36.3496 +
 36.3497 +\subsection{Obtaining current calendar time}
 36.3498 +\label{gmtime}
 36.3499 +
 36.3500 +To obtain the current calendar time in MathProg there exists the
 36.3501 +function {\tt gmtime}. It has no arguments and returns the number of
 36.3502 +seconds elapsed since 00:00:00 on January 1, 1970, Coordinated
 36.3503 +Universal Time (UTC). For example:
 36.3504 +
 36.3505 +\medskip
 36.3506 +
 36.3507 +\verb|   param utc := gmtime();|
 36.3508 +
 36.3509 +\medskip
 36.3510 +
 36.3511 +MathProg has no function to convert UTC time returned by the function
 36.3512 +{\tt gmtime} to {\it local} calendar times. Thus, if you need to
 36.3513 +determine the current local calendar time, you have to add to the UTC
 36.3514 +time returned the time offset from UTC expressed in seconds. For
 36.3515 +example, the time in Berlin during the winter is one hour ahead of UTC
 36.3516 +that corresponds to the time offset +1 hour = +3600 secs, so the
 36.3517 +current winter calendar time in Berlin may be determined as follows:
 36.3518 +
 36.3519 +\medskip
 36.3520 +
 36.3521 +\verb|   param now := gmtime() + 3600;|
 36.3522 +
 36.3523 +\medskip
 36.3524 +
 36.3525 +\noindent Similarly, the summer time in Chicago (Central Daylight Time)
 36.3526 +is five hours behind UTC, so the corresponding current local calendar
 36.3527 +time may be determined as follows:
 36.3528 +
 36.3529 +\medskip
 36.3530 +
 36.3531 +\verb|   param now := gmtime() - 5 * 3600;|
 36.3532 +
 36.3533 +\medskip
 36.3534 +
 36.3535 +Note that the value returned by {\tt gmtime} is volatile, i.e. being
 36.3536 +called several times this function may return different values.
 36.3537 +
 36.3538 +\subsection{Converting character string to calendar time}
 36.3539 +\label{str2time}
 36.3540 +
 36.3541 +The function {\tt str2time(}{\it s}{\tt,} {\it f}{\tt)} converts a
 36.3542 +character string (timestamp) specified by its first argument {\it s},
 36.3543 +which must be a symbolic expression, to the calendar time suitable for
 36.3544 +arithmetic calculations. The conversion is controlled by the specified
 36.3545 +format string {\it f} (the second argument), which also must be a
 36.3546 +symbolic expression.
 36.3547 +
 36.3548 +The result of conversion returned by {\tt str2time} has the same
 36.3549 +meaning as values returned by the function {\tt gmtime} (see Subsection
 36.3550 +\ref{gmtime}, page \pageref{gmtime}). Note that {\tt str2time} does
 36.3551 +{\tt not} correct the calendar time returned for the local timezone,
 36.3552 +i.e. being applied to 00:00:00 on January 1, 1970 it always returns 0.
 36.3553 +
 36.3554 +For example, the model statements:
 36.3555 +
 36.3556 +\medskip
 36.3557 +
 36.3558 +\verb|   param s, symbolic, := "07/14/98 13:47";|
 36.3559 +
 36.3560 +\verb|   param t := str2time(s, "%m/%d/%y %H:%M");|
 36.3561 +
 36.3562 +\verb|   display t;|
 36.3563 +
 36.3564 +\medskip
 36.3565 +
 36.3566 +\noindent produce the following printout:
 36.3567 +
 36.3568 +\medskip
 36.3569 +
 36.3570 +\verb|   t = 900424020|
 36.3571 +
 36.3572 +\medskip
 36.3573 +
 36.3574 +\noindent where the calendar time printed corresponds to 13:47:00 on
 36.3575 +July 14, 1998.
 36.3576 +
 36.3577 +\newpage
 36.3578 +
 36.3579 +The format string passed to the function {\tt str2time} consists of
 36.3580 +conversion specifiers and ordinary characters. Each conversion
 36.3581 +specifier begins with a percent ({\tt\%}) character followed by a
 36.3582 +letter.
 36.3583 +
 36.3584 +The following conversion specifiers may be used in the format string:
 36.3585 +
 36.3586 +\medskip
 36.3587 +
 36.3588 +\begin{tabular}{@{}p{20pt}p{298pt}@{}}
 36.3589 +{\tt\%b}&The abbreviated month name (case insensitive). At least three
 36.3590 +first letters of the month name must appear in the input string.\\
 36.3591 +\end{tabular}
 36.3592 +
 36.3593 +\medskip
 36.3594 +
 36.3595 +\begin{tabular}{@{}p{20pt}p{298pt}@{}}
 36.3596 +{\tt\%d}&The day of the month as a decimal number (range 1 to 31).
 36.3597 +Leading zero is permitted, but not required.\\
 36.3598 +\end{tabular}
 36.3599 +
 36.3600 +\medskip
 36.3601 +
 36.3602 +\begin{tabular}{@{}p{20pt}p{298pt}@{}}
 36.3603 +{\tt\%h}&The same as {\tt\%b}.\\
 36.3604 +\end{tabular}
 36.3605 +
 36.3606 +\medskip
 36.3607 +
 36.3608 +\begin{tabular}{@{}p{20pt}p{298pt}@{}}
 36.3609 +{\tt\%H}&The hour as a decimal number, using a 24-hour clock (range 0
 36.3610 +to 23). Leading zero is permitted, but not required.\\
 36.3611 +\end{tabular}
 36.3612 +
 36.3613 +\medskip
 36.3614 +
 36.3615 +\begin{tabular}{@{}p{20pt}p{298pt}@{}}
 36.3616 +{\tt\%m}&The month as a decimal number (range 1 to 12). Leading zero is
 36.3617 +permitted, but not required.\\
 36.3618 +\end{tabular}
 36.3619 +
 36.3620 +\medskip
 36.3621 +
 36.3622 +\begin{tabular}{@{}p{20pt}p{298pt}@{}}
 36.3623 +{\tt\%M}&The minute as a decimal number (range 0 to 59). Leading zero
 36.3624 +is permitted, but not required.\\
 36.3625 +\end{tabular}
 36.3626 +
 36.3627 +\medskip
 36.3628 +
 36.3629 +\begin{tabular}{@{}p{20pt}p{298pt}@{}}
 36.3630 +{\tt\%S}&The second as a decimal number (range 0 to 60). Leading zero
 36.3631 +is permitted, but not required.\\
 36.3632 +\end{tabular}
 36.3633 +
 36.3634 +\medskip
 36.3635 +
 36.3636 +\begin{tabular}{@{}p{20pt}p{298pt}@{}}
 36.3637 +{\tt\%y}&The year without a century as a decimal number (range 0 to 99).
 36.3638 +Leading zero is permitted, but not required. Input values in the range
 36.3639 +0 to 68 are considered as the years 2000 to 2068 while the values 69 to
 36.3640 +99 as the years 1969 to 1999.\\
 36.3641 +\end{tabular}
 36.3642 +
 36.3643 +\medskip
 36.3644 +
 36.3645 +\begin{tabular}{@{}p{20pt}p{298pt}@{}}
 36.3646 +{\tt\%z}&The offset from GMT in ISO 8601 format.\\
 36.3647 +\end{tabular}
 36.3648 +
 36.3649 +\medskip
 36.3650 +
 36.3651 +\begin{tabular}{@{}p{20pt}p{298pt}@{}}
 36.3652 +{\tt\%\%}&A literal {\tt\%} character.\\
 36.3653 +\end{tabular}
 36.3654 +
 36.3655 +\medskip
 36.3656 +
 36.3657 +All other (ordinary) characters in the format string must have a
 36.3658 +matching character in the input string to be converted. Exceptions are
 36.3659 +spaces in the input string which can match zero or more space
 36.3660 +characters in the format string.
 36.3661 +
 36.3662 +If some date and/or time component(s) are missing in the format and,
 36.3663 +therefore, in the input string, the function {\tt str2time} uses their
 36.3664 +default values corresponding to 00:00:00 on January 1, 1970, that is,
 36.3665 +the default value of the year is 1970, the default value of the month
 36.3666 +is January, etc.
 36.3667 +
 36.3668 +The function {\tt str2time} is applicable to all calendar times in the
 36.3669 +range 00:00:00 on January 1, 0001 to 23:59:59 on December 31, 4000 of
 36.3670 +the Gregorian calendar.
 36.3671 +
 36.3672 +\subsection{Converting calendar time to character string}
 36.3673 +\label{time2str}
 36.3674 +
 36.3675 +The function {\tt time2str(}{\it t}{\tt,} {\it f}{\tt)} converts the
 36.3676 +calendar time specified by its first argument {\it t}, which must be a
 36.3677 +numeric expression, to a character string (symbolic value). The
 36.3678 +conversion is controlled by the specified format string {\it f} (the
 36.3679 +second argument), which must be a symbolic expression.
 36.3680 +
 36.3681 +The calendar time passed to {\tt time2str} has the same meaning as
 36.3682 +values returned by the function {\tt gmtime} (see Subsection
 36.3683 +\ref{gmtime}, page \pageref{gmtime}). Note that {\tt time2str} does
 36.3684 +{\it not} correct the specified calendar time for the local timezone,
 36.3685 +i.e. the calendar time 0 always corresponds to 00:00:00 on January 1,
 36.3686 +1970.
 36.3687 +
 36.3688 +For example, the model statements:
 36.3689 +
 36.3690 +\medskip
 36.3691 +
 36.3692 +\verb|   param s, symbolic, := time2str(gmtime(), "%FT%TZ");|
 36.3693 +
 36.3694 +\verb|   display s;|
 36.3695 +
 36.3696 +\medskip
 36.3697 +
 36.3698 +\noindent may produce the following printout:
 36.3699 +
 36.3700 +\medskip
 36.3701 +
 36.3702 +\verb|   s = '2008-12-04T00:23:45Z'|
 36.3703 +
 36.3704 +\medskip
 36.3705 +
 36.3706 +\noindent which is a timestamp in the ISO format.
 36.3707 +
 36.3708 +The format string passed to the function {\tt time2str} consists of
 36.3709 +conversion specifiers and ordinary characters. Each conversion
 36.3710 +specifier begins with a percent ({\tt\%}) character followed by a
 36.3711 +letter.
 36.3712 +
 36.3713 +The following conversion specifiers may be used in the format string:
 36.3714 +
 36.3715 +\medskip
 36.3716 +
 36.3717 +\begin{tabular}{@{}p{20pt}p{298pt}@{}}
 36.3718 +{\tt\%a}&The abbreviated (2-character) weekday name.\\
 36.3719 +\end{tabular}
 36.3720 +
 36.3721 +\medskip
 36.3722 +
 36.3723 +\begin{tabular}{@{}p{20pt}p{298pt}@{}}
 36.3724 +{\tt\%A}&The full weekday name.\\
 36.3725 +\end{tabular}
 36.3726 +
 36.3727 +\medskip
 36.3728 +
 36.3729 +\begin{tabular}{@{}p{20pt}p{298pt}@{}}
 36.3730 +{\tt\%b}&The abbreviated (3-character) month name.\\
 36.3731 +\end{tabular}
 36.3732 +
 36.3733 +\medskip
 36.3734 +
 36.3735 +\begin{tabular}{@{}p{20pt}p{298pt}@{}}
 36.3736 +{\tt\%B}&The full month name.\\
 36.3737 +\end{tabular}
 36.3738 +
 36.3739 +\medskip
 36.3740 +
 36.3741 +\begin{tabular}{@{}p{20pt}p{298pt}@{}}
 36.3742 +{\tt\%C}&The century of the year, that is the greatest integer not
 36.3743 +greater than the year divided by 100.\\
 36.3744 +\end{tabular}
 36.3745 +
 36.3746 +\medskip
 36.3747 +
 36.3748 +\begin{tabular}{@{}p{20pt}p{298pt}@{}}
 36.3749 +{\tt\%d}&The day of the month as a decimal number (range 01 to 31).\\
 36.3750 +\end{tabular}
 36.3751 +
 36.3752 +\medskip
 36.3753 +
 36.3754 +\begin{tabular}{@{}p{20pt}p{298pt}@{}}
 36.3755 +{\tt\%D}&The date using the format \verb|%m/%d/%y|.\\
 36.3756 +\end{tabular}
 36.3757 +
 36.3758 +\medskip
 36.3759 +
 36.3760 +\begin{tabular}{@{}p{20pt}p{298pt}@{}}
 36.3761 +{\tt\%e}&The day of the month like with \verb|%d|, but padded with
 36.3762 +blank rather than zero.\\
 36.3763 +\end{tabular}
 36.3764 +
 36.3765 +\medskip
 36.3766 +
 36.3767 +\begin{tabular}{@{}p{20pt}p{298pt}@{}}
 36.3768 +{\tt\%F}&The date using the format \verb|%Y-%m-%d|.\\
 36.3769 +\end{tabular}
 36.3770 +
 36.3771 +\medskip
 36.3772 +
 36.3773 +\begin{tabular}{@{}p{20pt}p{298pt}@{}}
 36.3774 +{\tt\%g}&The year corresponding to the ISO week number, but without the
 36.3775 +century (range 00 to 99). This has the same format and value as
 36.3776 +\verb|%y|, except that if the ISO week number (see \verb|%V|) belongs
 36.3777 +to the previous or next year, that year is used instead.\\
 36.3778 +\end{tabular}
 36.3779 +
 36.3780 +\medskip
 36.3781 +
 36.3782 +\begin{tabular}{@{}p{20pt}p{298pt}@{}}
 36.3783 +{\tt\%G}&The year corresponding to the ISO week number. This has the
 36.3784 +same format and value as \verb|%Y|, except that if the ISO week number
 36.3785 +(see \verb|%V|) belongs to the previous or next year, that year is used
 36.3786 +instead.
 36.3787 +\end{tabular}
 36.3788 +
 36.3789 +\medskip
 36.3790 +
 36.3791 +\begin{tabular}{@{}p{20pt}p{298pt}@{}}
 36.3792 +{\tt\%h}&The same as \verb|%b|.\\
 36.3793 +\end{tabular}
 36.3794 +
 36.3795 +\medskip
 36.3796 +
 36.3797 +\begin{tabular}{@{}p{20pt}p{298pt}@{}}
 36.3798 +{\tt\%H}&The hour as a decimal number, using a 24-hour clock (range 00
 36.3799 +to 23).\\
 36.3800 +\end{tabular}
 36.3801 +
 36.3802 +\medskip
 36.3803 +
 36.3804 +\begin{tabular}{@{}p{20pt}p{298pt}@{}}
 36.3805 +{\tt\%I}&The hour as a decimal number, using a 12-hour clock (range 01
 36.3806 +to 12).\\
 36.3807 +\end{tabular}
 36.3808 +
 36.3809 +\medskip
 36.3810 +
 36.3811 +\begin{tabular}{@{}p{20pt}p{298pt}@{}}
 36.3812 +{\tt\%j}&The day of the year as a decimal number (range 001 to 366).\\
 36.3813 +\end{tabular}
 36.3814 +
 36.3815 +\medskip
 36.3816 +
 36.3817 +\begin{tabular}{@{}p{20pt}p{298pt}@{}}
 36.3818 +{\tt\%k}&The hour as a decimal number, using a 24-hour clock like
 36.3819 +\verb|%H|, but padded with blank rather than zero.\\
 36.3820 +\end{tabular}
 36.3821 +
 36.3822 +\medskip
 36.3823 +
 36.3824 +\begin{tabular}{@{}p{20pt}p{298pt}@{}}
 36.3825 +{\tt\%l}&The hour as a decimal number, using a 12-hour clock like
 36.3826 +\verb|%I|, but padded with blank rather than zero.
 36.3827 +\end{tabular}
 36.3828 +
 36.3829 +\medskip
 36.3830 +
 36.3831 +\begin{tabular}{@{}p{20pt}p{298pt}@{}}
 36.3832 +{\tt\%m}&The month as a decimal number (range 01 to 12).\\
 36.3833 +\end{tabular}
 36.3834 +
 36.3835 +\medskip
 36.3836 +
 36.3837 +\begin{tabular}{@{}p{20pt}p{298pt}@{}}
 36.3838 +{\tt\%M}&The minute as a decimal number (range 00 to 59).\\
 36.3839 +\end{tabular}
 36.3840 +
 36.3841 +\medskip
 36.3842 +
 36.3843 +\begin{tabular}{@{}p{20pt}p{298pt}@{}}
 36.3844 +{\tt\%p}&Either {\tt AM} or {\tt PM}, according to the given time value.
 36.3845 +Midnight is treated as {\tt AM} and noon as {\tt PM}.\\
 36.3846 +\end{tabular}
 36.3847 +
 36.3848 +\medskip
 36.3849 +
 36.3850 +\begin{tabular}{@{}p{20pt}p{298pt}@{}}
 36.3851 +{\tt\%P}&Either {\tt am} or {\tt pm}, according to the given time value.
 36.3852 +Midnight is treated as {\tt am} and noon as {\tt pm}.\\
 36.3853 +\end{tabular}
 36.3854 +
 36.3855 +\medskip
 36.3856 +
 36.3857 +\begin{tabular}{@{}p{20pt}p{298pt}@{}}
 36.3858 +{\tt\%R}&The hour and minute in decimal numbers using the format
 36.3859 +\verb|%H:%M|.\\
 36.3860 +\end{tabular}
 36.3861 +
 36.3862 +\medskip
 36.3863 +
 36.3864 +\begin{tabular}{@{}p{20pt}p{298pt}@{}}
 36.3865 +{\tt\%S}&The second as a decimal number (range 00 to 59).\\
 36.3866 +\end{tabular}
 36.3867 +
 36.3868 +\medskip
 36.3869 +
 36.3870 +\begin{tabular}{@{}p{20pt}p{298pt}@{}}
 36.3871 +{\tt\%T}&The time of day in decimal numbers using the format
 36.3872 +\verb|%H:%M:%S|.\\
 36.3873 +\end{tabular}
 36.3874 +
 36.3875 +\medskip
 36.3876 +
 36.3877 +\begin{tabular}{@{}p{20pt}p{298pt}@{}}
 36.3878 +{\tt\%u}&The day of the week as a decimal number (range 1 to 7), Monday
 36.3879 +being 1.\\
 36.3880 +\end{tabular}
 36.3881 +
 36.3882 +\medskip
 36.3883 +
 36.3884 +\begin{tabular}{@{}p{20pt}p{298pt}@{}}
 36.3885 +{\tt\%U}&The week number of the current year as a decimal number (range
 36.3886 +00 to 53), starting with the first Sunday as the first day of the first
 36.3887 +week. Days preceding the first Sunday in the year are considered to be
 36.3888 +in week 00.
 36.3889 +\end{tabular}
 36.3890 +
 36.3891 +\medskip
 36.3892 +
 36.3893 +\begin{tabular}{@{}p{20pt}p{298pt}@{}}
 36.3894 +{\tt\%V}&The ISO week number as a decimal number (range 01 to 53). ISO
 36.3895 +weeks start with Monday and end with Sunday. Week 01 of a year is the
 36.3896 +first week which has the majority of its days in that year; this is
 36.3897 +equivalent to the week containing January 4. Week 01 of a year can
 36.3898 +contain days from the previous year. The week before week 01 of a year
 36.3899 +is the last week (52 or 53) of the previous year even if it contains
 36.3900 +days from the new year. In other word, if 1 January is Monday, Tuesday,
 36.3901 +Wednesday or Thursday, it is in week 01; if 1 January is Friday,
 36.3902 +Saturday or Sunday, it is in week 52 or 53 of the previous year.\\
 36.3903 +\end{tabular}
 36.3904 +
 36.3905 +\medskip
 36.3906 +
 36.3907 +\begin{tabular}{@{}p{20pt}p{298pt}@{}}
 36.3908 +{\tt\%w}&The day of the week as a decimal number (range 0 to 6), Sunday
 36.3909 +being 0.\\
 36.3910 +\end{tabular}
 36.3911 +
 36.3912 +\medskip
 36.3913 +
 36.3914 +\begin{tabular}{@{}p{20pt}p{298pt}@{}}
 36.3915 +{\tt\%W}&The week number of the current year as a decimal number (range
 36.3916 +00 to 53), starting with the first Monday as the first day of the first
 36.3917 +week. Days preceding the first Monday in the year are considered to be
 36.3918 +in week 00.\\
 36.3919 +\end{tabular}
 36.3920 +
 36.3921 +\medskip
 36.3922 +
 36.3923 +\begin{tabular}{@{}p{20pt}p{298pt}@{}}
 36.3924 +{\tt\%y}&The year without a century as a decimal number (range 00 to
 36.3925 +99), that is the year modulo 100.\\
 36.3926 +\end{tabular}
 36.3927 +
 36.3928 +\medskip
 36.3929 +
 36.3930 +\begin{tabular}{@{}p{20pt}p{298pt}@{}}
 36.3931 +{\tt\%Y}&The year as a decimal number, using the Gregorian calendar.\\
 36.3932 +\end{tabular}
 36.3933 +
 36.3934 +\medskip
 36.3935 +
 36.3936 +\begin{tabular}{@{}p{20pt}p{298pt}@{}}
 36.3937 +{\tt\%\%}&A literal \verb|%| character.\\
 36.3938 +\end{tabular}
 36.3939 +
 36.3940 +\medskip
 36.3941 +
 36.3942 +All other (ordinary) characters in the format string are simply copied
 36.3943 +to the resultant string.
 36.3944 +
 36.3945 +The first argument (calendar time) passed to the function {\tt time2str}
 36.3946 +must be in the range from $-62135596800$ to $+64092211199$ that
 36.3947 +corresponds to the period from 00:00:00 on January 1, 0001 to 23:59:59
 36.3948 +on December 31, 4000 of the Gregorian calendar.
 36.3949 +
 36.3950 +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 36.3951 +
 36.3952 +\newpage
 36.3953 +
 36.3954 +\section{Table drivers}
 36.3955 +\label{drivers}
 36.3956 +
 36.3957 +\noindent\hfil
 36.3958 +by Andrew Makhorin \verb|<mao@gnu.org>|
 36.3959 +
 36.3960 +\noindent\hfil
 36.3961 +and Heinrich Schuchardt \verb|<heinrich.schuchardt@gmx.de>|
 36.3962 +
 36.3963 +\bigskip\bigskip
 36.3964 +
 36.3965 +The {\it table driver} is a program module which provides transmitting
 36.3966 +data between MathProg model objects and data tables.
 36.3967 +
 36.3968 +Currently the GLPK package has four table drivers:
 36.3969 +
 36.3970 +\setlength{\leftmargini}{2.5em}
 36.3971 +
 36.3972 +\begin{itemize}
 36.3973 +\item built-in CSV table driver;
 36.3974 +\item built-in xBASE table driver;
 36.3975 +\item ODBC table driver;
 36.3976 +\item MySQL table driver.
 36.3977 +\end{itemize}
 36.3978 +
 36.3979 +\subsection{CSV table driver}
 36.3980 +
 36.3981 +The CSV table driver assumes that the data table is represented in the
 36.3982 +form of a plain text file in the CSV (comma-separated values) file
 36.3983 +format as described below.
 36.3984 +
 36.3985 +To choose the CSV table driver its name in the table statement should
 36.3986 +be specified as \verb|"CSV"|, and the only argument should specify the
 36.3987 +name of a plain text file containing the table. For example:
 36.3988 +
 36.3989 +\medskip
 36.3990 +
 36.3991 +\verb|   table data IN "CSV" "data.csv": ... ;|
 36.3992 +
 36.3993 +\medskip
 36.3994 +
 36.3995 +The filename suffix may be arbitrary, however, it is recommended to use
 36.3996 +the suffix `\verb|.csv|'.
 36.3997 +
 36.3998 +On reading input tables the CSV table driver provides an implicit field
 36.3999 +named \verb|RECNO|, which contains the current record number. This
 36.4000 +field can be specified in the input table statement as if there were
 36.4001 +the actual field having the name \verb|RECNO| in the CSV file. For
 36.4002 +example:
 36.4003 +
 36.4004 +\medskip
 36.4005 +
 36.4006 +\verb|   table list IN "CSV" "list.csv": num <- [RECNO], ... ;|
 36.4007 +
 36.4008 +\subsubsection*{CSV format\footnote{This material is based on the RFC
 36.4009 +document 4180.}}
 36.4010 +
 36.4011 +The CSV (comma-separated values) format is a plain text file format
 36.4012 +defined as follows.
 36.4013 +
 36.4014 +1. Each record is located on a separate line, delimited by a line
 36.4015 +break. For example:
 36.4016 +
 36.4017 +\medskip
 36.4018 +
 36.4019 +\verb|   aaa,bbb,ccc\n|
 36.4020 +
 36.4021 +\verb|   xxx,yyy,zzz\n|
 36.4022 +
 36.4023 +\medskip
 36.4024 +
 36.4025 +\noindent
 36.4026 +where \verb|\n| means the control character \verb|LF| ({\tt 0x0A}).
 36.4027 +
 36.4028 +\newpage
 36.4029 +
 36.4030 +2. The last record in the file may or may not have an ending line
 36.4031 +break. For example:
 36.4032 +
 36.4033 +\medskip
 36.4034 +
 36.4035 +\verb|   aaa,bbb,ccc\n|
 36.4036 +
 36.4037 +\verb|   xxx,yyy,zzz|
 36.4038 +
 36.4039 +\medskip
 36.4040 +
 36.4041 +3. There should be a header line appearing as the first line of the
 36.4042 +file in the same format as normal record lines. This header should
 36.4043 +contain names corresponding to the fields in the file. The number of
 36.4044 +field names in the header line should be the same as the number of
 36.4045 +fields in the records of the file. For example:
 36.4046 +
 36.4047 +\medskip
 36.4048 +
 36.4049 +\verb|   name1,name2,name3\n|
 36.4050 +
 36.4051 +\verb|   aaa,bbb,ccc\n|
 36.4052 +
 36.4053 +\verb|   xxx,yyy,zzz\n|
 36.4054 +
 36.4055 +\medskip
 36.4056 +
 36.4057 +4. Within the header and each record there may be one or more fields
 36.4058 +separated by commas. Each line should contain the same number of fields
 36.4059 +throughout the file. Spaces are considered as part of a field and
 36.4060 +therefore not ignored. The last field in the record should not be
 36.4061 +followed by a comma. For example:
 36.4062 +
 36.4063 +\medskip
 36.4064 +
 36.4065 +\verb|   aaa,bbb,ccc\n|
 36.4066 +
 36.4067 +\medskip
 36.4068 +
 36.4069 +5. Fields may or may not be enclosed in double quotes. For example:
 36.4070 +
 36.4071 +\medskip
 36.4072 +
 36.4073 +\verb|   "aaa","bbb","ccc"\n|
 36.4074 +
 36.4075 +\verb|   zzz,yyy,xxx\n|
 36.4076 +
 36.4077 +\medskip
 36.4078 +
 36.4079 +6. If a field is enclosed in double quotes, each double quote which is
 36.4080 +part of the field should be coded twice. For example:
 36.4081 +
 36.4082 +\medskip
 36.4083 +
 36.4084 +\verb|   "aaa","b""bb","ccc"\n|
 36.4085 +
 36.4086 +\medskip
 36.4087 +
 36.4088 +\noindent{\bf Example}
 36.4089 +
 36.4090 +\begin{verbatim}
 36.4091 +FROM,TO,DISTANCE,COST
 36.4092 +Seattle,New-York,2.5,0.12
 36.4093 +Seattle,Chicago,1.7,0.08
 36.4094 +Seattle,Topeka,1.8,0.09
 36.4095 +San-Diego,New-York,2.5,0.15
 36.4096 +San-Diego,Chicago,1.8,0.10
 36.4097 +San-Diego,Topeka,1.4,0.07
 36.4098 +\end{verbatim}
 36.4099 +
 36.4100 +\subsection{xBASE table driver}
 36.4101 +
 36.4102 +The xBASE table driver assumes that the data table is stored in the
 36.4103 +.dbf file format.
 36.4104 +
 36.4105 +To choose the xBASE table driver its name in the table statement should
 36.4106 +be specified as \verb|"xBASE"|, and the first argument should specify
 36.4107 +the name of a .dbf file containing the table. For the output table there
 36.4108 +should be the second argument defining the table format in the form
 36.4109 +\verb|"FF...F"|, where \verb|F| is either {\tt C({\it n})},
 36.4110 +which specifies a character field of length $n$, or
 36.4111 +{\tt N({\it n}{\rm [},{\it p}{\rm ]})}, which specifies a numeric field
 36.4112 +of length $n$ and precision $p$ (by default $p$ is 0).
 36.4113 +
 36.4114 +The following is a simple example which illustrates creating and
 36.4115 +reading a .dbf file:
 36.4116 +
 36.4117 +\begin{verbatim}
 36.4118 +table tab1{i in 1..10} OUT "xBASE" "foo.dbf"
 36.4119 +   "N(5)N(10,4)C(1)C(10)": 2*i+1 ~ B, Uniform(-20,+20) ~ A,
 36.4120 +   "?" ~ FOO, "[" & i & "]" ~ C;
 36.4121 +set S, dimen 4;
 36.4122 +table tab2 IN "xBASE" "foo.dbf": S <- [B, C, RECNO, A];
 36.4123 +display S;
 36.4124 +end;
 36.4125 +\end{verbatim}
 36.4126 +
 36.4127 +\subsection{ODBC table driver}
 36.4128 +
 36.4129 +The ODBC table driver allows connecting to SQL databases using an
 36.4130 +implementation of the ODBC interface based on the Call Level Interface
 36.4131 +(CLI).\footnote{The corresponding software standard is defined in
 36.4132 +ISO/IEC 9075-3:2003.}
 36.4133 +
 36.4134 +\paragraph{Debian GNU/Linux.}
 36.4135 +Under Debian GNU/Linux the ODBC table driver uses the iODBC
 36.4136 +package,\footnote{See {\tt<http://www.iodbc.org/>}.} which should be
 36.4137 +installed before building the GLPK package. The installation can be
 36.4138 +effected with the following command:
 36.4139 +
 36.4140 +\begin{verbatim}
 36.4141 +sudo apt-get install libiodbc2-dev
 36.4142 +\end{verbatim}
 36.4143 +
 36.4144 +Note that on configuring the GLPK package to enable using the iODBC
 36.4145 +library the option `\verb|--enable-odbc|' should be passed to the
 36.4146 +configure script.
 36.4147 +
 36.4148 +The individual databases must be entered for systemwide usage in
 36.4149 +\linebreak \verb|/etc/odbc.ini| and \verb|/etc/odbcinst.ini|. Database
 36.4150 +connections to be used by a single user are specified by files in the
 36.4151 +home directory (\verb|.odbc.ini| and \verb|.odbcinst.ini|).
 36.4152 +
 36.4153 +\paragraph{Microsoft Windows.}
 36.4154 +Under Microsoft Windows the ODBC table driver uses the Microsoft ODBC
 36.4155 +library. To enable this feature the symbol:
 36.4156 +
 36.4157 +\begin{verbatim}
 36.4158 +#define ODBC_DLNAME "odbc32.dll"
 36.4159 +\end{verbatim}
 36.4160 +
 36.4161 +\noindent
 36.4162 +should be defined in the GLPK configuration file `\verb|config.h|'.
 36.4163 +
 36.4164 +Data sources can be created via the Administrative Tools from the
 36.4165 +Control Panel.
 36.4166 +
 36.4167 +\bigskip
 36.4168 +
 36.4169 +To choose the ODBC table driver its name in the table statement should
 36.4170 +be specified as \verb|'ODBC'| or \verb|'iODBC'|.
 36.4171 +
 36.4172 +The argument list is specified as follows.
 36.4173 +
 36.4174 +The first argument is the connection string passed to the ODBC library,
 36.4175 +for example:
 36.4176 +
 36.4177 +\verb|'DSN=glpk;UID=user;PWD=password'|, or
 36.4178 +
 36.4179 +\verb|'DRIVER=MySQL;DATABASE=glpkdb;UID=user;PWD=password'|.
 36.4180 +
 36.4181 +Different parts of the string are separated by semicolons. Each part
 36.4182 +consists of a pair {\it fieldname} and {\it value} separated by the
 36.4183 +equal sign. Allowable fieldnames depend on the ODBC library. Typically
 36.4184 +the following fieldnames are allowed:
 36.4185 +
 36.4186 +\verb|DATABASE | database;
 36.4187 +
 36.4188 +\verb|DRIVER   | ODBC driver;
 36.4189 +
 36.4190 +\verb|DSN      | name of a data source;
 36.4191 +
 36.4192 +\verb|FILEDSN  | name of a file data source;
 36.4193 +
 36.4194 +\verb|PWD      | user password;
 36.4195 +
 36.4196 +\verb|SERVER   | database;
 36.4197 +
 36.4198 +\verb|UID      | user name.
 36.4199 +
 36.4200 +The second argument and all following are considered to be SQL
 36.4201 +statements
 36.4202 +
 36.4203 +SQL statements may be spread over multiple arguments.  If the last
 36.4204 +character of an argument is a semicolon this indicates the end of
 36.4205 +a SQL statement.
 36.4206 +
 36.4207 +The arguments of a SQL statement are concatenated separated by space.
 36.4208 +The eventual trailing semicolon will be removed.
 36.4209 +
 36.4210 +All but the last SQL statement will be executed directly.
 36.4211 +
 36.4212 +For IN-table the last SQL statement can be a SELECT command starting
 36.4213 +with the capitalized letters \verb|'SELECT '|. If the string does not
 36.4214 +start with \verb|'SELECT '| it is considered to be a table name and a
 36.4215 +SELECT statement is automatically generated.
 36.4216 +
 36.4217 +For OUT-table the last SQL statement can contain one or multiple
 36.4218 +question marks. If it contains a question mark it is considered a
 36.4219 +template for the write routine. Otherwise the string is considered a
 36.4220 +table name and an INSERT template is automatically generated.
 36.4221 +
 36.4222 +The writing routine uses the template with the question marks and
 36.4223 +replaces the first question mark by the first output parameter, the
 36.4224 +second question mark by the second output parameter and so forth. Then
 36.4225 +the SQL command is issued.
 36.4226 +
 36.4227 +The following is an example of the output table statement:
 36.4228 +
 36.4229 +\begin{small}
 36.4230 +\begin{verbatim}
 36.4231 +table ta { l in LOCATIONS } OUT
 36.4232 +   'ODBC'
 36.4233 +   'DSN=glpkdb;UID=glpkuser;PWD=glpkpassword'
 36.4234 +   'DROP TABLE IF EXISTS result;'
 36.4235 +   'CREATE TABLE result ( ID INT, LOC VARCHAR(255), QUAN DOUBLE );'
 36.4236 +   'INSERT INTO result 'VALUES ( 4, ?, ? )' :
 36.4237 +   l ~ LOC, quantity[l] ~ QUAN;
 36.4238 +\end{verbatim}
 36.4239 +\end{small}
 36.4240 +
 36.4241 +\noindent
 36.4242 +Alternatively it could be written as follows:
 36.4243 +
 36.4244 +\begin{small}
 36.4245 +\begin{verbatim}
 36.4246 +table ta { l in LOCATIONS } OUT
 36.4247 +   'ODBC'
 36.4248 +   'DSN=glpkdb;UID=glpkuser;PWD=glpkpassword'
 36.4249 +   'DROP TABLE IF EXISTS result;'
 36.4250 +   'CREATE TABLE result ( ID INT, LOC VARCHAR(255), QUAN DOUBLE );'
 36.4251 +   'result' :
 36.4252 +   l ~ LOC, quantity[l] ~ QUAN, 4 ~ ID;
 36.4253 +\end{verbatim}
 36.4254 +\end{small}
 36.4255 +
 36.4256 +Using templates with `\verb|?|' supports not only INSERT, but also
 36.4257 +UPDATE, DELETE, etc. For example:
 36.4258 +
 36.4259 +\begin{small}
 36.4260 +\begin{verbatim}
 36.4261 +table ta { l in LOCATIONS } OUT
 36.4262 +   'ODBC'
 36.4263 +   'DSN=glpkdb;UID=glpkuser;PWD=glpkpassword'
 36.4264 +   'UPDATE result SET DATE = ' & date & ' WHERE ID = 4;'
 36.4265 +   'UPDATE result SET QUAN = ? WHERE LOC = ? AND ID = 4' :
 36.4266 +   quantity[l], l;
 36.4267 +\end{verbatim}
 36.4268 +\end{small}
 36.4269 +
 36.4270 +\subsection{MySQL table driver}
 36.4271 +
 36.4272 +The MySQL table driver allows connecting to MySQL databases.
 36.4273 +
 36.4274 +\paragraph{Debian GNU/Linux.}
 36.4275 +Under Debian GNU/Linux the MySQL table\linebreak driver uses the MySQL
 36.4276 +package,\footnote{For download development files see
 36.4277 +{\tt<http://dev.mysql.com/downloads/mysql/>}.} which should be installed
 36.4278 +before building the GLPK package. The installation can be effected with
 36.4279 +the following command:
 36.4280 +
 36.4281 +\begin{verbatim}
 36.4282 +sudo apt-get install libmysqlclient15-dev
 36.4283 +\end{verbatim}
 36.4284 +
 36.4285 +Note that on configuring the GLPK package to enable using the MySQL
 36.4286 +library the option `\verb|--enable-mysql|' should be passed to the
 36.4287 +configure script.
 36.4288 +
 36.4289 +\paragraph{Microsoft Windows.}
 36.4290 +Under Microsoft Windows the MySQL table driver also uses the MySQL
 36.4291 +library. To enable this feature the symbol:
 36.4292 +
 36.4293 +\begin{verbatim}
 36.4294 +#define MYSQL_DLNAME "libmysql.dll"
 36.4295 +\end{verbatim}
 36.4296 +
 36.4297 +\noindent
 36.4298 +should be defined in the GLPK configuration file `\verb|config.h|'.
 36.4299 +
 36.4300 +\bigskip
 36.4301 +
 36.4302 +To choose the MySQL table driver its name in the table statement should
 36.4303 +be specified as \verb|'MySQL'|.
 36.4304 +
 36.4305 +The argument list is specified as follows.
 36.4306 +
 36.4307 +The first argument specifies how to connect the data base in the DSN
 36.4308 +style, for example:
 36.4309 +
 36.4310 +\verb|'Database=glpk;UID=glpk;PWD=gnu'|.
 36.4311 +
 36.4312 +Different parts of the string are separated by semicolons. Each part
 36.4313 +consists of a pair {\it fieldname} and {\it value} separated by the
 36.4314 +equal sign. The following fieldnames are allowed:
 36.4315 +
 36.4316 +\verb|Server   | server running the database (defaulting to localhost);
 36.4317 +
 36.4318 +\verb|Database | name of the database;
 36.4319 +
 36.4320 +\verb|UID      | user name;
 36.4321 +
 36.4322 +\verb|PWD      | user password;
 36.4323 +
 36.4324 +\verb|Port     | port used by the server (defaulting to 3306).
 36.4325 +
 36.4326 +The second argument and all following are considered to be SQL
 36.4327 +statements
 36.4328 +
 36.4329 +SQL statements may be spread over multiple arguments.  If the last
 36.4330 +character of an argument is a semicolon this indicates the end of
 36.4331 +a SQL statement.
 36.4332 +
 36.4333 +The arguments of a SQL statement are concatenated separated by space.
 36.4334 +The eventual trailing semicolon will be removed.
 36.4335 +
 36.4336 +All but the last SQL statement will be executed directly.
 36.4337 +
 36.4338 +For IN-table the last SQL statement can be a SELECT command starting
 36.4339 +with the capitalized letters \verb|'SELECT '|. If the string does not
 36.4340 +start with \verb|'SELECT '| it is considered to be a table name and a
 36.4341 +SELECT statement is automatically generated.
 36.4342 +
 36.4343 +For OUT-table the last SQL statement can contain one or multiple
 36.4344 +question marks. If it contains a question mark it is considered a
 36.4345 +template for the write routine. Otherwise the string is considered a
 36.4346 +table name and an INSERT template is automatically generated.
 36.4347 +
 36.4348 +The writing routine uses the template with the question marks and
 36.4349 +replaces the first question mark by the first output parameter, the
 36.4350 +second question mark by the second output parameter and so forth. Then
 36.4351 +the SQL command is issued.
 36.4352 +
 36.4353 +The following is an example of the output table statement:
 36.4354 +
 36.4355 +\begin{small}
 36.4356 +\begin{verbatim}
 36.4357 +table ta { l in LOCATIONS } OUT
 36.4358 +   'MySQL'
 36.4359 +   'Database=glpkdb;UID=glpkuser;PWD=glpkpassword'
 36.4360 +   'DROP TABLE IF EXISTS result;'
 36.4361 +   'CREATE TABLE result ( ID INT, LOC VARCHAR(255), QUAN DOUBLE );'
 36.4362 +   'INSERT INTO result VALUES ( 4, ?, ? )' :
 36.4363 +   l ~ LOC, quantity[l] ~ QUAN;
 36.4364 +\end{verbatim}
 36.4365 +\end{small}
 36.4366 +
 36.4367 +\noindent
 36.4368 +Alternatively it could be written as follows:
 36.4369 +
 36.4370 +\begin{small}
 36.4371 +\begin{verbatim}
 36.4372 +table ta { l in LOCATIONS } OUT
 36.4373 +   'MySQL'
 36.4374 +   'Database=glpkdb;UID=glpkuser;PWD=glpkpassword'
 36.4375 +   'DROP TABLE IF EXISTS result;'
 36.4376 +   'CREATE TABLE result ( ID INT, LOC VARCHAR(255), QUAN DOUBLE );'
 36.4377 +   'result' :
 36.4378 +   l ~ LOC, quantity[l] ~ QUAN, 4 ~ ID;
 36.4379 +\end{verbatim}
 36.4380 +\end{small}
 36.4381 +
 36.4382 +Using templates with `\verb|?|' supports not only INSERT, but also
 36.4383 +UPDATE, DELETE, etc. For example:
 36.4384 +
 36.4385 +\begin{small}
 36.4386 +\begin{verbatim}
 36.4387 +table ta { l in LOCATIONS } OUT
 36.4388 +   'MySQL'
 36.4389 +   'Database=glpkdb;UID=glpkuser;PWD=glpkpassword'
 36.4390 +   'UPDATE result SET DATE = ' & date & ' WHERE ID = 4;'
 36.4391 +   'UPDATE result SET QUAN = ? WHERE LOC = ? AND ID = 4' :
 36.4392 +   quantity[l], l;
 36.4393 +\end{verbatim}
 36.4394 +\end{small}
 36.4395 +
 36.4396 +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 36.4397 +
 36.4398 +\newpage
 36.4399 +
 36.4400 +\section{Solving models with glpsol}
 36.4401 +
 36.4402 +The GLPK package\footnote{{\tt http://www.gnu.org/software/glpk/}}
 36.4403 +includes the program {\tt glpsol}, which is a stand-alone LP/MIP solver.
 36.4404 +This program can be launched from the command line or from the shell to
 36.4405 +solve models written in the GNU MathProg modeling language.
 36.4406 +
 36.4407 +In order to tell the solver that the input file contains a model
 36.4408 +description, you need to specify the option \verb|--model| in the
 36.4409 +command line. For example:
 36.4410 +
 36.4411 +\medskip
 36.4412 +
 36.4413 +\verb|   glpsol --model foo.mod|
 36.4414 +
 36.4415 +\medskip
 36.4416 +
 36.4417 +Sometimes it is necessary to use the data section placed in a separate
 36.4418 +file, in which case you may use the following command:
 36.4419 +
 36.4420 +\medskip
 36.4421 +
 36.4422 +\verb|   glpsol --model foo.mod --data foo.dat|
 36.4423 +
 36.4424 +\medskip
 36.4425 +
 36.4426 +\noindent Note that if the model file also contains the data section,
 36.4427 +that section is ignored.
 36.4428 +
 36.4429 +If the model description contains some display and/or printf statements,
 36.4430 +by default the output is sent to the terminal. In order to redirect the
 36.4431 +output to a file you may use the following command:
 36.4432 +
 36.4433 +\medskip
 36.4434 +
 36.4435 +\verb|   glpsol --model foo.mod --display foo.out|
 36.4436 +
 36.4437 +\medskip
 36.4438 +
 36.4439 +If you need to look at the problem, which has been generated by the
 36.4440 +model translator, you may use the option \verb|--wlp| as follows:
 36.4441 +
 36.4442 +\medskip
 36.4443 +
 36.4444 +\verb|   glpsol --model foo.mod --wlp foo.lp|
 36.4445 +
 36.4446 +\medskip
 36.4447 +
 36.4448 +\noindent in which case the problem data is written to file
 36.4449 +\verb|foo.lp| in CPLEX LP format suitable for visual analysis.
 36.4450 +
 36.4451 +Sometimes it is needed merely to check the model description not
 36.4452 +solving the generated problem instance. In this case you may specify
 36.4453 +the option \verb|--check|, for example:
 36.4454 +
 36.4455 +\medskip
 36.4456 +
 36.4457 +\verb|   glpsol --check --model foo.mod --wlp foo.lp|
 36.4458 +
 36.4459 +\medskip
 36.4460 +
 36.4461 +In order to write a numeric solution obtained by the solver you may use
 36.4462 +the following command:
 36.4463 +
 36.4464 +\medskip
 36.4465 +
 36.4466 +\verb|   glpsol --model foo.mod --output foo.sol|
 36.4467 +
 36.4468 +\medskip
 36.4469 +
 36.4470 +\noindent in which case the solution is written to file \verb|foo.sol|
 36.4471 +in a plain text format.
 36.4472 +
 36.4473 +The complete list of the \verb|glpsol| options can be found in the
 36.4474 +reference manual included in the GLPK distribution.
 36.4475 +
 36.4476 +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 36.4477 +
 36.4478 +\newpage
 36.4479 +
 36.4480 +\section{Example model description}
 36.4481 +
 36.4482 +\subsection{Model description written in MathProg}
 36.4483 +
 36.4484 +Below here is a complete example of the model description written in
 36.4485 +the GNU MathProg modeling language.
 36.4486 +
 36.4487 +\begin{small}
 36.4488 +\begin{verbatim}
 36.4489 +# A TRANSPORTATION PROBLEM
 36.4490 +#
 36.4491 +# This problem finds a least cost shipping schedule that meets
 36.4492 +# requirements at markets and supplies at factories.
 36.4493 +#
 36.4494 +#  References:
 36.4495 +#              Dantzig G B, "Linear Programming and Extensions."
 36.4496 +#              Princeton University Press, Princeton, New Jersey, 1963,
 36.4497 +#              Chapter 3-3.
 36.4498 +
 36.4499 +set I;
 36.4500 +/* canning plants */
 36.4501 +
 36.4502 +set J;
 36.4503 +/* markets */
 36.4504 +
 36.4505 +param a{i in I};
 36.4506 +/* capacity of plant i in cases */
 36.4507 +
 36.4508 +param b{j in J};
 36.4509 +/* demand at market j in cases */
 36.4510 +
 36.4511 +param d{i in I, j in J};
 36.4512 +/* distance in thousands of miles */
 36.4513 +
 36.4514 +param f;
 36.4515 +/* freight in dollars per case per thousand miles */
 36.4516 +
 36.4517 +param c{i in I, j in J} := f * d[i,j] / 1000;
 36.4518 +/* transport cost in thousands of dollars per case */
 36.4519 +
 36.4520 +var x{i in I, j in J} >= 0;
 36.4521 +/* shipment quantities in cases */
 36.4522 +
 36.4523 +minimize cost: sum{i in I, j in J} c[i,j] * x[i,j];
 36.4524 +/* total transportation costs in thousands of dollars */
 36.4525 +
 36.4526 +s.t. supply{i in I}: sum{j in J} x[i,j] <= a[i];
 36.4527 +/* observe supply limit at plant i */
 36.4528 +
 36.4529 +s.t. demand{j in J}: sum{i in I} x[i,j] >= b[j];
 36.4530 +/* satisfy demand at market j */
 36.4531 +
 36.4532 +data;
 36.4533 +
 36.4534 +set I := Seattle San-Diego;
 36.4535 +
 36.4536 +set J := New-York Chicago Topeka;
 36.4537 +
 36.4538 +param a := Seattle     350
 36.4539 +           San-Diego   600;
 36.4540 +
 36.4541 +param b := New-York    325
 36.4542 +           Chicago     300
 36.4543 +           Topeka      275;
 36.4544 +
 36.4545 +param d :              New-York   Chicago   Topeka :=
 36.4546 +           Seattle     2.5        1.7       1.8
 36.4547 +           San-Diego   2.5        1.8       1.4  ;
 36.4548 +
 36.4549 +param f := 90;
 36.4550 +
 36.4551 +end;
 36.4552 +\end{verbatim}
 36.4553 +\end{small}
 36.4554 +
 36.4555 +\subsection{Generated LP problem instance}
 36.4556 +
 36.4557 +Below here is the result of the translation of the example model
 36.4558 +produced by the solver \verb|glpsol| and written in CPLEX LP format
 36.4559 +with the option \verb|--wlp|.
 36.4560 +
 36.4561 +\begin{small}
 36.4562 +\begin{verbatim}
 36.4563 +\* Problem: transp *\
 36.4564 +
 36.4565 +Minimize
 36.4566 + cost: + 0.225 x(Seattle,New~York) + 0.153 x(Seattle,Chicago)
 36.4567 + + 0.162 x(Seattle,Topeka) + 0.225 x(San~Diego,New~York)
 36.4568 + + 0.162 x(San~Diego,Chicago) + 0.126 x(San~Diego,Topeka)
 36.4569 +
 36.4570 +Subject To
 36.4571 + supply(Seattle): + x(Seattle,New~York) + x(Seattle,Chicago)
 36.4572 + + x(Seattle,Topeka) <= 350
 36.4573 + supply(San~Diego): + x(San~Diego,New~York) + x(San~Diego,Chicago)
 36.4574 + + x(San~Diego,Topeka) <= 600
 36.4575 + demand(New~York): + x(Seattle,New~York) + x(San~Diego,New~York) >= 325
 36.4576 + demand(Chicago): + x(Seattle,Chicago) + x(San~Diego,Chicago) >= 300
 36.4577 + demand(Topeka): + x(Seattle,Topeka) + x(San~Diego,Topeka) >= 275
 36.4578 +
 36.4579 +End
 36.4580 +\end{verbatim}
 36.4581 +\end{small}
 36.4582 +
 36.4583 +\subsection{Optimal LP solution}
 36.4584 +
 36.4585 +Below here is the optimal solution of the generated LP problem instance
 36.4586 +found by the solver \verb|glpsol| and written in plain text format
 36.4587 +with the option \verb|--output|.
 36.4588 +
 36.4589 +\newpage
 36.4590 +
 36.4591 +\begin{small}
 36.4592 +\begin{verbatim}
 36.4593 +Problem:    transp
 36.4594 +Rows:       6
 36.4595 +Columns:    6
 36.4596 +Non-zeros:  18
 36.4597 +Status:     OPTIMAL
 36.4598 +Objective:  cost = 153.675 (MINimum)
 36.4599 +
 36.4600 +No.   Row name   St   Activity    Lower bound  Upper bound   Marginal
 36.4601 +--- ------------ -- ------------ ------------ ------------ ------------
 36.4602 +  1 cost         B       153.675
 36.4603 +  2 supply[Seattle]
 36.4604 +                 B           300                       350
 36.4605 +  3 supply[San-Diego]
 36.4606 +                 NU          600                       600        < eps
 36.4607 +  4 demand[New-York]
 36.4608 +                 NL          325          325                     0.225
 36.4609 +  5 demand[Chicago]
 36.4610 +                 NL          300          300                     0.153
 36.4611 +  6 demand[Topeka]
 36.4612 +                 NL          275          275                     0.126
 36.4613 +
 36.4614 +No. Column name  St   Activity    Lower bound  Upper bound   Marginal
 36.4615 +--- ------------ -- ------------ ------------ ------------ ------------
 36.4616 +  1 x[Seattle,New-York]
 36.4617 +                 B             0            0
 36.4618 +  2 x[Seattle,Chicago]
 36.4619 +                 B           300            0
 36.4620 +  3 x[Seattle,Topeka]
 36.4621 +                 NL            0            0                     0.036
 36.4622 +  4 x[San-Diego,New-York]
 36.4623 +                 B           325            0
 36.4624 +  5 x[San-Diego,Chicago]
 36.4625 +                 NL            0            0                     0.009
 36.4626 +  6 x[San-Diego,Topeka]
 36.4627 +                 B           275            0
 36.4628 +
 36.4629 +End of output
 36.4630 +\end{verbatim}
 36.4631 +\end{small}
 36.4632 +
 36.4633 +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 36.4634 +
 36.4635 +\newpage
 36.4636 +
 36.4637 +\setcounter{secnumdepth}{-1}
 36.4638 +
 36.4639 +\section{Acknowledgment}
 36.4640 +
 36.4641 +The authors would like to thank the following people, who kindly read,
 36.4642 +commented, and corrected the draft of this document:
 36.4643 +
 36.4644 +\medskip
 36.4645 +
 36.4646 +\noindent Juan Carlos Borras \verb|<borras@cs.helsinki.fi>|
 36.4647 +
 36.4648 +\medskip
 36.4649 +
 36.4650 +\noindent Harley Mackenzie \verb|<hjm@bigpond.com>|
 36.4651 +
 36.4652 +\medskip
 36.4653 +
 36.4654 +\noindent Robbie Morrison \verb|<robbie@actrix.co.nz>|
 36.4655 +
 36.4656 +\end{document}
    37.1 Binary file deps/glpk/doc/graphs.pdf has changed
    38.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    38.2 +++ b/deps/glpk/doc/graphs.tex	Sun Nov 06 20:59:10 2011 +0100
    38.3 @@ -0,0 +1,3935 @@
    38.4 +%* graphs.tex *%
    38.5 +
    38.6 +%***********************************************************************
    38.7 +%  This code is part of GLPK (GNU Linear Programming Kit).
    38.8 +%
    38.9 +%  Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008,
   38.10 +%  2009, 2010 Andrew Makhorin, Department for Applied Informatics,
   38.11 +%  Moscow Aviation Institute, Moscow, Russia. All rights reserved.
   38.12 +%  E-mail: <mao@gnu.org>.
   38.13 +%
   38.14 +%  GLPK is free software: you can redistribute it and/or modify it
   38.15 +%  under the terms of the GNU General Public License as published by
   38.16 +%  the Free Software Foundation, either version 3 of the License, or
   38.17 +%  (at your option) any later version.
   38.18 +%
   38.19 +%  GLPK is distributed in the hope that it will be useful, but WITHOUT
   38.20 +%  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
   38.21 +%  or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
   38.22 +%  License for more details.
   38.23 +%
   38.24 +%  You should have received a copy of the GNU General Public License
   38.25 +%  along with GLPK. If not, see <http://www.gnu.org/licenses/>.
   38.26 +%***********************************************************************
   38.27 +
   38.28 +\documentclass[11pt]{report}
   38.29 +\usepackage{amssymb}
   38.30 +\usepackage[dvipdfm,linktocpage,colorlinks,linkcolor=blue,
   38.31 +urlcolor=blue]{hyperref}
   38.32 +\usepackage[all]{xy}
   38.33 +
   38.34 +\renewcommand\contentsname{\sf\bfseries Contents}
   38.35 +\renewcommand\chaptername{\sf\bfseries Chapter}
   38.36 +\renewcommand\appendixname{\sf\bfseries Appendix}
   38.37 +
   38.38 +\begin{document}
   38.39 +
   38.40 +\thispagestyle{empty}
   38.41 +
   38.42 +\begin{center}
   38.43 +
   38.44 +\vspace*{1in}
   38.45 +
   38.46 +\begin{huge}
   38.47 +\sf\bfseries GNU Linear Programming Kit
   38.48 +\end{huge}
   38.49 +
   38.50 +\vspace{0.5in}
   38.51 +
   38.52 +\begin{LARGE}
   38.53 +\sf Graph and Network Routines
   38.54 +\end{LARGE}
   38.55 +
   38.56 +\vspace{0.5in}
   38.57 +
   38.58 +\begin{LARGE}
   38.59 +\sf for GLPK Version 4.45
   38.60 +\end{LARGE}
   38.61 +
   38.62 +\vspace{0.5in}
   38.63 +\begin{Large}
   38.64 +\sf (DRAFT, December 2010)
   38.65 +\end{Large}
   38.66 +\end{center}
   38.67 +
   38.68 +\newpage
   38.69 +
   38.70 +\vspace*{1in}
   38.71 +
   38.72 +\vfill
   38.73 +
   38.74 +\noindent
   38.75 +The GLPK package is part of the GNU Project released under the aegis of
   38.76 +GNU.
   38.77 +
   38.78 +\medskip \noindent
   38.79 +Copyright \copyright{} 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007,
   38.80 +2008, 2009, 2010 Andrew Makhorin, Department for Applied Informatics,
   38.81 +Moscow Aviation Institute, Moscow, Russia. All rights reserved.
   38.82 +
   38.83 +\medskip \noindent
   38.84 +Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
   38.85 +02110-1301, USA.
   38.86 +
   38.87 +\medskip \noindent
   38.88 +Permission is granted to make and distribute verbatim copies of this
   38.89 +manual provided the copyright notice and this permission notice are
   38.90 +preserved on all copies.
   38.91 +
   38.92 +\medskip \noindent
   38.93 +Permission is granted to copy and distribute modified versions of this
   38.94 +manual under the conditions for verbatim copying, provided also that the
   38.95 +entire resulting derived work is distributed under the terms of
   38.96 +a permission notice identical to this one.
   38.97 +
   38.98 +\medskip \noindent
   38.99 +Permission is granted to copy and distribute translations of this manual
  38.100 +into another language, under the above conditions for modified versions.
  38.101 +
  38.102 +\tableofcontents
  38.103 +
  38.104 +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  38.105 +
  38.106 +\chapter{Basic Graph API Routines}
  38.107 +
  38.108 +\section{Graph program object}
  38.109 +
  38.110 +In GLPK the base program object used to represent graphs and networks
  38.111 +is a directed graph (digraph).
  38.112 +
  38.113 +Formally, {\it digraph} (or simply, {\it graph}) is a pair $G=(V,A)$,
  38.114 +where $V$ is a set of {\it vertices}, and $A$ is a set
  38.115 +{\it arcs}.\footnote{$A$ may be a multiset.} Each arc $a\in A$ is an
  38.116 +ordered pair of vertices $a=(x,y)$, where $x\in V$ is called {\it tail
  38.117 +vertex} of arc $a$, and $y\in V$ is called its {\it head vertex}.
  38.118 +
  38.119 +Representation of a graph in the program includes three structs defined
  38.120 +by typedef in the header \verb|glpk.h|:
  38.121 +
  38.122 +\medskip
  38.123 +
  38.124 +$\bullet$ \verb|glp_graph|, which represents the graph in a whole,
  38.125 +
  38.126 +$\bullet$ \verb|glp_vertex|, which represents a vertex of the graph, and
  38.127 +
  38.128 +$\bullet$ \verb|glp_arc|, which represents an arc of the graph.
  38.129 +
  38.130 +\medskip
  38.131 +
  38.132 +All these three structs are ``semi-opaque'', i.e. the application
  38.133 +program can directly access their fields through pointers, however,
  38.134 +changing the fields directly is not allowed---all changes should be
  38.135 +performed only with appropriate GLPK API routines.
  38.136 +
  38.137 +\newpage
  38.138 +
  38.139 +\newenvironment{comment}
  38.140 +{\addtolength{\leftskip}{17pt}\noindent}
  38.141 +{\par\addtolength{\leftskip}{-17pt}}
  38.142 +
  38.143 +\noindent
  38.144 +{\bf glp\_graph.} The struct \verb|glp_graph| has the following
  38.145 +fields available to the application program:
  38.146 +
  38.147 +\medskip
  38.148 +
  38.149 +\noindent
  38.150 +\verb|char *name;|
  38.151 +
  38.152 +\begin{comment}Symbolic name assigned to the graph. It is a pointer to
  38.153 +a null terminated character string of length from 1 to 255 characters.
  38.154 +If no name is assigned to the graph, this field contains \verb|NULL|.
  38.155 +\end{comment}
  38.156 +
  38.157 +\medskip
  38.158 +
  38.159 +\noindent
  38.160 +\verb|int nv;|
  38.161 +
  38.162 +\begin{comment}The number of vertices in the graph, $nv\geq 0$.
  38.163 +\end{comment}
  38.164 +
  38.165 +\medskip
  38.166 +
  38.167 +\noindent
  38.168 +\verb|int na;|
  38.169 +
  38.170 +\begin{comment}The number of arcs in the graph, $na\geq 0$.
  38.171 +\end{comment}
  38.172 +
  38.173 +\medskip
  38.174 +
  38.175 +\noindent
  38.176 +\verb|glp_vertex **v;|
  38.177 +
  38.178 +\begin{comment}Pointer to an array containing the list of vertices.
  38.179 +Element $v[0]$ is not used. Element $v[i]$, $1\leq i\leq nv$, is a
  38.180 +pointer to $i$-th vertex of the graph. Note that on adding new vertices
  38.181 +to the graph the field $v$ may be altered due to reallocation. However,
  38.182 +pointers $v[i]$ are not changed while corresponding vertices exist in
  38.183 +the graph.
  38.184 +\end{comment}
  38.185 +
  38.186 +\medskip
  38.187 +
  38.188 +\noindent
  38.189 +\verb|int v_size;|
  38.190 +
  38.191 +\begin{comment}Size of vertex data blocks, in bytes,
  38.192 +$0\leq v\_size\leq 256$. (See also the field \verb|data| in the struct
  38.193 +\verb|glp_vertex|.)
  38.194 +\end{comment}
  38.195 +
  38.196 +\medskip
  38.197 +
  38.198 +\noindent
  38.199 +\verb|int a_size;|
  38.200 +
  38.201 +\begin{comment}Size of arc data blocks, in bytes,
  38.202 +$0\leq v\_size\leq 256$. (See also the field \verb|data| in the struct
  38.203 +\verb|glp_arc|.)
  38.204 +\end{comment}
  38.205 +
  38.206 +\bigskip
  38.207 +
  38.208 +\noindent
  38.209 +{\bf glp\_vertex.} The struct \verb|glp_vertex| has the following
  38.210 +fields available to the application program:
  38.211 +
  38.212 +\medskip
  38.213 +
  38.214 +\noindent
  38.215 +\verb|int i;|
  38.216 +
  38.217 +\begin{comment}Ordinal number of the vertex, $1\leq i\leq nv$. Note
  38.218 +that element $v[i]$ in the struct \verb|glp_graph| points to the vertex,
  38.219 +whose ordinal number is $i$.
  38.220 +\end{comment}
  38.221 +
  38.222 +\medskip
  38.223 +
  38.224 +\noindent
  38.225 +\verb|char *name;|
  38.226 +
  38.227 +\begin{comment}Symbolic name assigned to the vertex. It is a pointer to
  38.228 +a null terminated character string of length from 1 to 255 characters.
  38.229 +If no name is assigned to the vertex, this field contains \verb|NULL|.
  38.230 +\end{comment}
  38.231 +
  38.232 +\medskip
  38.233 +
  38.234 +\noindent
  38.235 +\verb|void *data;|
  38.236 +
  38.237 +\begin{comment}Pointer to a data block associated with the vertex. This
  38.238 +data block is automatically allocated on creating a new vertex and freed
  38.239 +on deleting the vertex. If $v\_size=0$, the block is not allocated, and
  38.240 +this field contains \verb|NULL|.
  38.241 +\end{comment}
  38.242 +
  38.243 +\medskip
  38.244 +
  38.245 +\noindent
  38.246 +\verb|void *temp;|
  38.247 +
  38.248 +\begin{comment}Working pointer, which may be used freely for any
  38.249 +purposes. The application program can change this field directly.
  38.250 +\end{comment}
  38.251 +
  38.252 +\medskip
  38.253 +
  38.254 +\noindent
  38.255 +\verb|glp_arc *in;|
  38.256 +
  38.257 +\begin{comment}Pointer to the (unordered) list of incoming arcs. If the
  38.258 +vertex has no incoming arcs, this field contains \verb|NULL|.
  38.259 +\end{comment}
  38.260 +
  38.261 +\medskip
  38.262 +
  38.263 +\noindent
  38.264 +\verb|glp_arc *out;|
  38.265 +
  38.266 +\begin{comment}Pointer to the (unordered) list of outgoing arcs. If the
  38.267 +vertex has no outgoing arcs, this field contains \verb|NULL|.
  38.268 +\end{comment}
  38.269 +
  38.270 +\bigskip
  38.271 +
  38.272 +\noindent
  38.273 +{\bf glp\_arc.} The struct \verb|glp_arc| has the following fields
  38.274 +available to the application program:
  38.275 +
  38.276 +\medskip
  38.277 +
  38.278 +\noindent
  38.279 +\verb|glp_vertex *tail;|
  38.280 +
  38.281 +\begin{comment}Pointer to a vertex, which is tail endpoint of the arc.
  38.282 +\end{comment}
  38.283 +
  38.284 +\medskip
  38.285 +
  38.286 +\noindent
  38.287 +\verb|glp_vertex *head;|
  38.288 +
  38.289 +\begin{comment}Pointer to a vertex, which is head endpoint of the arc.
  38.290 +\end{comment}
  38.291 +
  38.292 +\medskip
  38.293 +
  38.294 +\noindent
  38.295 +\verb|void *data;|
  38.296 +
  38.297 +\begin{comment}Pointer to a data block associated with the arc. This
  38.298 +data block is automatically allocated on creating a new arc and freed on
  38.299 +deleting the arc. If $v\_size=0$, the block is not allocated, and this
  38.300 +field contains \verb|NULL|.
  38.301 +\end{comment}
  38.302 +
  38.303 +\medskip
  38.304 +
  38.305 +\noindent
  38.306 +\verb|void *temp;|
  38.307 +
  38.308 +\begin{comment}Working pointer, which may be used freely for any
  38.309 +purposes. The application program can change this field directly.
  38.310 +\end{comment}
  38.311 +
  38.312 +\medskip
  38.313 +
  38.314 +\noindent
  38.315 +\verb|glp_arc *t_next;|
  38.316 +
  38.317 +\begin{comment}Pointer to another arc, which has the same tail endpoint
  38.318 +as this one. \verb|NULL| in this field indicates the end of the list of
  38.319 +outgoing arcs.
  38.320 +\end{comment}
  38.321 +
  38.322 +\medskip
  38.323 +
  38.324 +\noindent
  38.325 +\verb|glp_arc *h_next;|
  38.326 +
  38.327 +\begin{comment}Pointer to another arc, which has the same head endpoint
  38.328 +as this one. \verb|NULL| in this field indicates the end of the list of
  38.329 +incoming arcs.
  38.330 +\end{comment}
  38.331 +
  38.332 +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  38.333 +
  38.334 +\newpage
  38.335 +
  38.336 +\section{Graph creating and modifying routines}
  38.337 +
  38.338 +\subsection{glp\_create\_graph---create graph}
  38.339 +
  38.340 +\subsubsection*{Synopsis}
  38.341 +
  38.342 +\begin{verbatim}
  38.343 +glp_graph *glp_create_graph(int v_size, int a_size);
  38.344 +\end{verbatim}
  38.345 +
  38.346 +\subsubsection*{Description}
  38.347 +
  38.348 +The routine \verb|glp_create_graph| creates a new graph, which
  38.349 +initially is\linebreak empty, i.e. has no vertices and arcs.
  38.350 +
  38.351 +The parameter \verb|v_size| specifies the size of vertex data blocks,
  38.352 +in bytes, $0\leq v\_size\leq 256$.
  38.353 +
  38.354 +The parameter \verb|a_size| specifies the size of arc data blocks, in
  38.355 +bytes, $0\leq a\_size\leq 256$.
  38.356 +
  38.357 +\subsubsection*{Returns}
  38.358 +
  38.359 +The routine returns a pointer to the graph created.
  38.360 +
  38.361 +\subsection{glp\_set\_graph\_name---assign (change) graph name}
  38.362 +
  38.363 +\subsubsection*{Synopsis}
  38.364 +
  38.365 +\begin{verbatim}
  38.366 +void glp_set_graph_name(glp_graph *G, const char *name);
  38.367 +\end{verbatim}
  38.368 +
  38.369 +\subsubsection*{Description}
  38.370 +
  38.371 +The routine \verb|glp_set_graph_name| assigns a symbolic name specified
  38.372 +by the character string \verb|name| (1 to 255 chars) to the graph.
  38.373 +
  38.374 +If the parameter \verb|name| is \verb|NULL| or an empty string, the
  38.375 +routine erases the existing symbolic name of the graph.
  38.376 +
  38.377 +\newpage
  38.378 +
  38.379 +\subsection{glp\_add\_vertices---add new vertices to graph}
  38.380 +
  38.381 +\subsubsection*{Synopsis}
  38.382 +
  38.383 +\begin{verbatim}
  38.384 +int glp_add_vertices(glp_graph *G, int nadd);
  38.385 +\end{verbatim}
  38.386 +
  38.387 +\subsubsection*{Description}
  38.388 +
  38.389 +The routine \verb|glp_add_vertices| adds \verb|nadd| vertices to the
  38.390 +specified graph. New vertices are always added to the end of the vertex
  38.391 +list, so ordinal numbers of existing vertices remain unchanged. Note
  38.392 +that this operation may change the field \verb|v| in the struct
  38.393 +\verb|glp_graph| (pointer to the vertex array) due to reallocation.
  38.394 +
  38.395 +Being added each new vertex is isolated, i.e. has no incident arcs.
  38.396 +
  38.397 +If the size of vertex data blocks specified on creating the graph is
  38.398 +non-zero, the routine also allocates a memory block of that size for
  38.399 +each new vertex added, fills it by binary zeros, and stores a pointer to
  38.400 +it in the field \verb|data| of the struct \verb|glp_vertex|. Otherwise,
  38.401 +if the block size is zero, the field \verb|data| is set to \verb|NULL|.
  38.402 +
  38.403 +\subsubsection*{Returns}
  38.404 +
  38.405 +The routine \verb|glp_add_vertices| returns the ordinal number of the
  38.406 +first new vertex added to the graph.
  38.407 +
  38.408 +\subsection{glp\_set\_vertex\_name---assign (change) vertex name}
  38.409 +
  38.410 +\subsubsection*{Synopsis}
  38.411 +
  38.412 +\begin{verbatim}
  38.413 +void glp_set_vertex_name(glp_graph *G, int i, const char *name);
  38.414 +\end{verbatim}
  38.415 +
  38.416 +\subsubsection*{Description}
  38.417 +
  38.418 +The routine \verb|glp_set_vertex_name| assigns a given symbolic name
  38.419 +(1 up to 255 characters) to \verb|i|-th vertex of the specified graph.
  38.420 +
  38.421 +If the parameter \verb|name| is \verb|NULL| or empty string, the
  38.422 +routine erases an existing name of \verb|i|-th vertex.
  38.423 +
  38.424 +\newpage
  38.425 +
  38.426 +\subsection{glp\_add\_arc---add new arc to graph}
  38.427 +
  38.428 +\subsubsection*{Synopsis}
  38.429 +
  38.430 +\begin{verbatim}
  38.431 +glp_arc *glp_add_arc(glp_graph *G, int i, int j);
  38.432 +\end{verbatim}
  38.433 +
  38.434 +\subsubsection*{Description}
  38.435 +
  38.436 +The routine \verb|glp_add_arc| adds one new arc to the specified graph.
  38.437 +
  38.438 +The parameters \verb|i| and \verb|j| specify the ordinal numbers of,
  38.439 +resp., tail and head endpoints (vertices) of the arc. Note that
  38.440 +self-loops and multiple arcs are allowed.
  38.441 +
  38.442 +If the size of arc data blocks specified on creating the graph is
  38.443 +non-zero, the routine also allocates a memory block of that size, fills
  38.444 +it by binary zeros, and stores a pointer to it in the field \verb|data|
  38.445 +of the struct \verb|glp_arc|. Otherwise, if the block size is zero, the
  38.446 +field \verb|data| is set to \verb|NULL|.
  38.447 +
  38.448 +\subsection{glp\_del\_vertices---delete vertices from graph}
  38.449 +
  38.450 +\subsubsection*{Synopsis}
  38.451 +
  38.452 +\begin{verbatim}
  38.453 +void glp_del_vertices(glp_graph *G, int ndel, const int num[]);
  38.454 +\end{verbatim}
  38.455 +
  38.456 +\subsubsection*{Description}
  38.457 +
  38.458 +The routine \verb|glp_del_vertices| deletes vertices along with all
  38.459 +incident arcs from the specified graph. Ordinal numbers of vertices to
  38.460 +be deleted should be placed in locations \verb|num[1]|, \dots,
  38.461 +\verb|num[ndel]|, \verb|ndel| $>0$.
  38.462 +
  38.463 +Note that deleting vertices involves changing ordinal numbers of other
  38.464 +vertices remaining in the graph. New ordinal numbers of the remaining
  38.465 +vertices are assigned under the assumption that the original order of
  38.466 +vertices is not changed.
  38.467 +
  38.468 +\subsection{glp\_del\_arc---delete arc from graph}
  38.469 +
  38.470 +\subsubsection*{Synopsis}
  38.471 +
  38.472 +\begin{verbatim}
  38.473 +void glp_del_arc(glp_graph *G, glp_arc *a);
  38.474 +\end{verbatim}
  38.475 +
  38.476 +\subsubsection*{Description}
  38.477 +
  38.478 +The routine \verb|glp_del_arc| deletes an arc from the specified graph.
  38.479 +The arc to be deleted must exist.
  38.480 +
  38.481 +\subsection{glp\_erase\_graph---erase graph content}
  38.482 +
  38.483 +\subsubsection*{Synopsis}
  38.484 +
  38.485 +\begin{verbatim}
  38.486 +void glp_erase_graph(glp_graph *G, int v_size, int a_size);
  38.487 +\end{verbatim}
  38.488 +
  38.489 +\subsubsection*{Description}
  38.490 +
  38.491 +The routine \verb|glp_erase_graph| erases the content of the specified
  38.492 +graph. The effect of this operation is the same as if the graph would be
  38.493 +deleted with the routine \verb|glp_delete_graph| and then created anew
  38.494 +with the routine \verb|glp_create_graph|, with exception that the handle
  38.495 +(pointer) to the graph remains valid.
  38.496 +
  38.497 +The parameters \verb|v_size| and \verb|a_size| have the same meaning as
  38.498 +for the routine \verb|glp_create_graph|.
  38.499 +
  38.500 +\subsection{glp\_delete\_graph---delete graph}
  38.501 +
  38.502 +\subsubsection*{Synopsis}
  38.503 +
  38.504 +\begin{verbatim}
  38.505 +void glp_delete_graph(glp_graph *G);
  38.506 +\end{verbatim}
  38.507 +
  38.508 +\subsubsection*{Description}
  38.509 +
  38.510 +The routine \verb|glp_delete_graph| deletes the specified graph and
  38.511 +frees all the memory allocated to this program object.
  38.512 +
  38.513 +\newpage
  38.514 +
  38.515 +\section{Graph searching routines}
  38.516 +
  38.517 +\subsection{glp\_create\_v\_index---create vertex name index}
  38.518 +
  38.519 +\subsubsection*{Synopsis}
  38.520 +
  38.521 +\begin{verbatim}
  38.522 +void glp_create_v_index(glp_graph *G);
  38.523 +\end{verbatim}
  38.524 +
  38.525 +\subsubsection*{Description}
  38.526 +
  38.527 +The routine \verb|glp_create_v_index| creates the name index for the
  38.528 +specified graph. The name index is an auxiliary data structure, which
  38.529 +is intended to quickly (i.e. for logarithmic time) find vertices by
  38.530 +their names.
  38.531 +
  38.532 +This routine can be called at any time. If the name index already
  38.533 +exists, the routine does nothing.
  38.534 +
  38.535 +\subsection{glp\_find\_vertex---find vertex by its name}
  38.536 +
  38.537 +\subsubsection*{Synopsis}
  38.538 +
  38.539 +\begin{verbatim}
  38.540 +int glp_find_vertex(glp_graph *G, const char *name);
  38.541 +\end{verbatim}
  38.542 +
  38.543 +\subsubsection*{Returns}
  38.544 +
  38.545 +The routine \verb|glp_find_vertex| returns the ordinal number of
  38.546 +a vertex, which is assigned (by the routine \verb|glp_set_vertex_name|)
  38.547 +the specified symbolic \verb|name|. If no such vertex exists, the
  38.548 +routine returns 0.
  38.549 +
  38.550 +\subsection{glp\_delete\_v\_index---delete vertex name index}
  38.551 +
  38.552 +\subsubsection*{Synopsis}
  38.553 +
  38.554 +\begin{verbatim}
  38.555 +void glp_delete_v_index(glp_graph *G);
  38.556 +\end{verbatim}
  38.557 +
  38.558 +\subsubsection*{Description}
  38.559 +
  38.560 +The routine \verb|glp_delete_v_index| deletes the name index previously
  38.561 +created by the routine \verb|glp_create_v_index| and frees the memory
  38.562 +allocated to this auxiliary data structure.
  38.563 +
  38.564 +This routine can be called at any time. If the name index does not
  38.565 +exist, the routine does nothing.
  38.566 +
  38.567 +\newpage
  38.568 +
  38.569 +\section{Graph reading/writing routines}
  38.570 +
  38.571 +\subsection{glp\_read\_graph---read graph from plain text file}
  38.572 +
  38.573 +\subsubsection*{Synopsis}
  38.574 +
  38.575 +\begin{verbatim}
  38.576 +int glp_read_graph(glp_graph *G, const char *fname);
  38.577 +\end{verbatim}
  38.578 +
  38.579 +\subsubsection*{Description}
  38.580 +
  38.581 +The routine \verb|glp_read_graph| reads a graph from a plain text file,
  38.582 +whose name is specified by the parameter \verb|fname|. Note that before
  38.583 +reading data the current content of the graph object is completely
  38.584 +erased with the routine \verb|glp_erase_graph|.
  38.585 +
  38.586 +For the file format see description of the routine
  38.587 +\verb|glp_write_graph|.
  38.588 +
  38.589 +\subsubsection*{Returns}
  38.590 +
  38.591 +If the operation was successful, the routine returns zero. Otherwise
  38.592 +it prints an error message and returns non-zero.
  38.593 +
  38.594 +\subsection{glp\_write\_graph---write graph to plain text file}
  38.595 +
  38.596 +\subsubsection*{Synopsis}
  38.597 +
  38.598 +\begin{verbatim}
  38.599 +int glp_write_graph(glp_graph *G, const char *fname);
  38.600 +\end{verbatim}
  38.601 +
  38.602 +\subsubsection*{Description}
  38.603 +
  38.604 +The routine \verb|glp_write_graph| writes the graph to a plain text
  38.605 +file, whose name is specified by the parameter \verb|fname|.
  38.606 +
  38.607 +\subsubsection*{Returns}
  38.608 +
  38.609 +If the operation was successful, the routine returns zero. Otherwise
  38.610 +it prints an error message and returns non-zero.
  38.611 +
  38.612 +\subsubsection*{File format}
  38.613 +
  38.614 +The file created by the routine \verb|glp_write_graph| is a plain text
  38.615 +file, which contains the following information:
  38.616 +
  38.617 +\begin{verbatim}
  38.618 +   nv na
  38.619 +   i[1] j[1]
  38.620 +   i[2] j[2]
  38.621 +   . . .
  38.622 +   i[na] j[na]
  38.623 +\end{verbatim}
  38.624 +
  38.625 +\noindent
  38.626 +where:
  38.627 +
  38.628 +\noindent
  38.629 +\verb|nv| is the number of vertices (nodes);
  38.630 +
  38.631 +\noindent
  38.632 +\verb|na| is the number of arcs;
  38.633 +
  38.634 +\noindent
  38.635 +\verb|i[k]|, $k=1,\dots,na$, is the index of tail vertex of arc $k$;
  38.636 +
  38.637 +\noindent
  38.638 +\verb|j[k]|, $k=1,\dots,na$, is the index of head vertex of arc $k$.
  38.639 +
  38.640 +\subsection{glp\_read\_ccdata---read graph from text file in DIMACS
  38.641 +clique/coloring format}
  38.642 +
  38.643 +\subsubsection*{Synopsis}
  38.644 +
  38.645 +\begin{verbatim}
  38.646 +int glp_read_ccdata(glp_graph *G, int v_wgt,
  38.647 +      const char *fname);
  38.648 +\end{verbatim}
  38.649 +
  38.650 +\subsubsection*{Description}
  38.651 +
  38.652 +The routine {\it glp\_read\_ccdata} reads a graph from a text file in
  38.653 +DIMACS clique/coloring format. (Though this format is originally
  38.654 +designed to represent data for the minimal vertex coloring and maximal
  38.655 +clique problems, it may be used to represent general undirected and
  38.656 +directed graphs, because the routine allows reading self-loops and
  38.657 +multiple edges/arcs keeping the order of vertices specified for each
  38.658 +edge/arc of the graph.)
  38.659 +
  38.660 +The parameter $G$ specifies the graph object to be read in. Note that
  38.661 +before reading data the current content of the graph object is
  38.662 +completely erased with the routine {\it glp\_erase\_graph}.
  38.663 +
  38.664 +The parameter {\it v\_wgt} specifies an offset of the field of type
  38.665 +{\bf double} in the vertex data block, to which the routine stores the
  38.666 +vertex weight. If {\it v\_wgt} $<0$, the vertex weights are not stored.
  38.667 +
  38.668 +The character string {\it fname} specifies the name of a text file to
  38.669 +be read in. (If the file name ends with the suffix `\verb|.gz|', the
  38.670 +file is assumed to be compressed, in which case the routine decompresses
  38.671 +it ``on the fly''.)
  38.672 +
  38.673 +\subsubsection*{Returns}
  38.674 +
  38.675 +If the operation was successful, the routine returns zero. Otherwise,
  38.676 +it prints an error message and returns non-zero.
  38.677 +
  38.678 +\subsubsection*{DIMACS clique/coloring format\footnote{This material is
  38.679 +based on the paper ``Clique and Coloring Problems Graph Format'', which
  38.680 +is publically available at
  38.681 +{\tt http://dimacs.rutgers.edu/Challenges/}.}}
  38.682 +
  38.683 +The DIMACS input file is a plain ASCII text file. It contains
  38.684 +{\it lines} of several types described below. A line is terminated with
  38.685 +an end-of-line character. Fields in each line are separated by at least
  38.686 +one blank space. Each line begins with a one-character designator to
  38.687 +identify the line type.
  38.688 +
  38.689 +Note that DIMACS requires all numerical quantities to be integers in
  38.690 +the range $[-2^{31},2^{31}-1]$ while GLPK allows the quantities to be
  38.691 +floating-point numbers.
  38.692 +
  38.693 +\paragraph{Comment lines.} Comment lines give human-readable information
  38.694 +about the file and are ignored by programs. Comment lines can appear
  38.695 +anywhere in the file. Each comment line begins with a lower-case
  38.696 +character \verb|c|.
  38.697 +
  38.698 +\begin{verbatim}
  38.699 +   c This is a comment line
  38.700 +\end{verbatim}
  38.701 +
  38.702 +\paragraph{Problem line.} There is one problem line per data file. The
  38.703 +problem line must appear before any node or edge descriptor lines. It
  38.704 +has the following format:
  38.705 +
  38.706 +\begin{verbatim}
  38.707 +   p edge NODES EDGES
  38.708 +\end{verbatim}
  38.709 +
  38.710 +\noindent
  38.711 +The lower-case letter \verb|p| signifies that this is a problem line.
  38.712 +The four-character problem designator \verb|edge| identifies the file
  38.713 +as containing data for the minimal vertex coloring or maximal clique
  38.714 +problem. The \verb|NODES| field contains an integer value specifying
  38.715 +the number of vertices in the graph. The \verb|EDGES| field contains an
  38.716 +integer value specifying the number of edges (arcs) in the graph.
  38.717 +
  38.718 +\paragraph{Vertex descriptors.} These lines give the weight assigned to
  38.719 +a vertex of the graph. There is one vertex descriptor line for each
  38.720 +vertex, with the following format. Vertices without a descriptor take on
  38.721 +a default value of 1.
  38.722 +
  38.723 +\begin{verbatim}
  38.724 +   n ID VALUE
  38.725 +\end{verbatim}
  38.726 +
  38.727 +\noindent
  38.728 +The lower-case character \verb|n| signifies that this is a vertex
  38.729 +descriptor line. The \verb|ID| field gives a vertex identification
  38.730 +number, an integer between 1 and $n$, where $n$ is the number of
  38.731 +vertices in the graph. The \verb|VALUE| field gives a vertex weight,
  38.732 +which can either positive or negative (or zero).
  38.733 +
  38.734 +\paragraph{Edge descriptors.} There is one edge descriptor line for
  38.735 +each edge (arc) of the graph, each with the following format:
  38.736 +
  38.737 +\begin{verbatim}
  38.738 +   e I J
  38.739 +\end{verbatim}
  38.740 +
  38.741 +\noindent
  38.742 +The lower-case character \verb|e| signifies that this is an edge
  38.743 +descriptor line. For an edge (arc) $(i,j)$ the fields \verb|I| and
  38.744 +\verb|J| specify its endpoints.
  38.745 +
  38.746 +\paragraph{Example.} The following example of an undirected graph:
  38.747 +
  38.748 +\bigskip
  38.749 +
  38.750 +\noindent\hfil
  38.751 +\xymatrix %@C=32pt
  38.752 +{&{v_1}\ar@{-}[ldd]\ar@{-}[dd]\ar@{-}[rd]\ar@{-}[rr]&&{v_2}\ar@{-}[ld]
  38.753 +\ar@{-}[dd]\ar@{-}[rdd]&\\
  38.754 +&&{v_7}\ar@{-}[ld]\ar@{-}[rd]&&\\
  38.755 +{v_6}\ar@{-}[r]\ar@{-}[rdd]&{v_{10}}\ar@{-}[rr]\ar@{-}[rd]\ar@{-}[dd]&&
  38.756 +{v_8}\ar@{-}[ld]\ar@{-}[dd]\ar@{-}[r]&{v_3}\ar@{-}[ldd]\\
  38.757 +&&{v_9}\ar@{-}[ld]\ar@{-}[rd]&&\\
  38.758 +&{v_5}\ar@{-}[rr]&&{v_4}&\\
  38.759 +}
  38.760 +
  38.761 +\bigskip
  38.762 +
  38.763 +\noindent
  38.764 +might be coded in DIMACS clique/coloring format as follows:
  38.765 +
  38.766 +\begin{footnotesize}
  38.767 +\begin{verbatim}
  38.768 +c sample.col
  38.769 +c
  38.770 +c This is an example of the vertex coloring problem data
  38.771 +c in DIMACS format.
  38.772 +c
  38.773 +p edge 10 21
  38.774 +c
  38.775 +e 1 2
  38.776 +e 1 6
  38.777 +e 1 7
  38.778 +e 1 10
  38.779 +e 2 3
  38.780 +e 2 7
  38.781 +e 2 8
  38.782 +e 3 4
  38.783 +e 3 8
  38.784 +e 4 5
  38.785 +e 4 8
  38.786 +e 4 9
  38.787 +e 5 6
  38.788 +e 5 9
  38.789 +e 5 10
  38.790 +e 6 10
  38.791 +e 7 8
  38.792 +e 7 10
  38.793 +e 8 9
  38.794 +e 8 10
  38.795 +e 9 10
  38.796 +c
  38.797 +c eof
  38.798 +\end{verbatim}
  38.799 +\end{footnotesize}
  38.800 +
  38.801 +\subsection{glp\_write\_ccdata---write graph to text file in DIMACS
  38.802 +clique/coloring format}
  38.803 +
  38.804 +\subsubsection*{Synopsis}
  38.805 +
  38.806 +\begin{verbatim}
  38.807 +int glp_write_ccdata(glp_graph *G, int v_wgt,
  38.808 +      const char *fname);
  38.809 +\end{verbatim}
  38.810 +
  38.811 +\subsection*{Description}
  38.812 +
  38.813 +The routine {\it glp\_write\_ccdata} writes the graph object specified
  38.814 +by the parameter $G$ to a text file in DIMACS clique/coloring format.
  38.815 +(Though this format is originally designed to represent data for the
  38.816 +minimal vertex coloring and maximal clique problems, it may be used to
  38.817 +represent general undirected and directed graphs, because the routine
  38.818 +allows writing self-loops and multiple edges/arcs keeping the order of
  38.819 +vertices specified for each edge/arc of the graph.)
  38.820 +
  38.821 +The parameter {\it v\_wgt} specifies an offset of the field of type
  38.822 +{\bf double} in the vertex data block, which contains the vertex weight.
  38.823 +If {\it v\_wgt} $<0$, it is assumed that the weight of each vertex is 1.
  38.824 +
  38.825 +The character string {\it fname} specifies a name of the text file to be
  38.826 +written out. (If the file name ends with suffix `\verb|.gz|', the file
  38.827 +is assumed to be compressed, in which case the routine performs
  38.828 +automatic compression on writing it.)
  38.829 +
  38.830 +\subsubsection*{Returns}
  38.831 +
  38.832 +If the operation was successful, the routine returns zero. Otherwise,
  38.833 +it prints an error message and returns non-zero.
  38.834 +
  38.835 +\newpage
  38.836 +
  38.837 +\section{Graph analysis routines}
  38.838 +
  38.839 +\subsection{glp\_weak\_comp---find all weakly connected components of
  38.840 +graph}
  38.841 +
  38.842 +\subsubsection*{Synopsis}
  38.843 +
  38.844 +\begin{verbatim}
  38.845 +int glp_weak_comp(glp_graph *G, int v_num);
  38.846 +\end{verbatim}
  38.847 +
  38.848 +\subsubsection*{Description}
  38.849 +
  38.850 +The routine \verb|glp_weak_comp| finds all weakly connected components
  38.851 +of the specified graph.
  38.852 +
  38.853 +The parameter \verb|v_num| specifies an offset of the field of type
  38.854 +\verb|int| in the vertex data block, to which the routine stores the
  38.855 +number of a weakly connected component containing that vertex. If
  38.856 +\verb|v_num| $<0$, no component numbers are stored.
  38.857 +
  38.858 +The components are numbered in arbitrary order from 1 to \verb|nc|,
  38.859 +where \verb|nc| is the total number of components found,
  38.860 +$0\leq$ \verb|nc| $\leq|V|$.
  38.861 +
  38.862 +\subsubsection*{Returns}
  38.863 +
  38.864 +The routine returns \verb|nc|, the total number of components found.
  38.865 +
  38.866 +\subsection{glp\_strong\_comp---find all strongly connected components
  38.867 +of graph}
  38.868 +
  38.869 +\subsubsection*{Synopsis}
  38.870 +
  38.871 +\begin{verbatim}
  38.872 +int glp_strong_comp(glp_graph *G, int v_num);
  38.873 +\end{verbatim}
  38.874 +
  38.875 +\subsubsection*{Description}
  38.876 +
  38.877 +The routine \verb|glp_strong_comp| finds all strongly connected
  38.878 +components of the specified graph.
  38.879 +
  38.880 +The parameter \verb|v_num| specifies an offset of the field of type
  38.881 +\verb|int| in the vertex data block, to which the routine stores the
  38.882 +number of a strongly connected component containing that vertex. If
  38.883 +\verb|v_num| $<0$, no component numbers are stored.
  38.884 +
  38.885 +The components are numbered in arbitrary order from 1 to \verb|nc|,
  38.886 +where \verb|nc| is the total number of components found,
  38.887 +$0\leq$ \verb|nc| $\leq|V|$. However, the component numbering has the
  38.888 +property that for every arc $(i\rightarrow j)$ in the graph the
  38.889 +condition $num(i)\geq num(j)$ holds.
  38.890 +
  38.891 +\subsubsection*{Returns}
  38.892 +
  38.893 +The routine returns \verb|nc|, the total number of components found.
  38.894 +
  38.895 +\subsubsection*{References}
  38.896 +
  38.897 +I.~S.~Duff, J.~K.~Reid, Algorithm 529: Permutations to block triangular
  38.898 +form, ACM Trans. on Math. Softw. 4 (1978), 189-92.
  38.899 +
  38.900 +\subsubsection*{Example}
  38.901 +
  38.902 +The following program reads a graph from a plain text file
  38.903 +`\verb|graph.txt|' and finds all its strongly connected components.
  38.904 +
  38.905 +\begin{footnotesize}
  38.906 +\begin{verbatim}
  38.907 +#include <stddef.h>
  38.908 +#include <stdio.h>
  38.909 +#include <stdlib.h>
  38.910 +#include <glpk.h>
  38.911 +
  38.912 +typedef struct { int num; } v_data;
  38.913 +
  38.914 +#define vertex(v) ((v_data *)((v)->data))
  38.915 +
  38.916 +int main(void)
  38.917 +{     glp_graph *G;
  38.918 +      int i, nc;
  38.919 +      G = glp_create_graph(sizeof(v_data), 0);
  38.920 +      glp_read_graph(G, "graph.txt");
  38.921 +      nc = glp_strong_comp(G, offsetof(v_data, num));
  38.922 +      printf("nc = %d\n", nc);
  38.923 +      for (i = 1; i <= G->nv; i++)
  38.924 +         printf("num[%d] = %d\n", i, vertex(G->v[i])->num);
  38.925 +      glp_delete_graph(G);
  38.926 +      return 0;
  38.927 +}
  38.928 +\end{verbatim}
  38.929 +\end{footnotesize}
  38.930 +
  38.931 +\noindent
  38.932 +If the file `\verb|graph.txt|' contains the graph shown below:
  38.933 +
  38.934 +\bigskip
  38.935 +
  38.936 +\noindent\hfil
  38.937 +\xymatrix
  38.938 +{1\ar[r]&2\ar[r]&3\ar[r]\ar[dd]&4\ar[dd]\\
  38.939 +5\ar[u]&6\ar[l]\\
  38.940 +7\ar[u]&&8\ar[lu]\ar[ll]\ar[r]&9\ar[r]&10\ar[r]\ar[d]&11\ar[d]\\
  38.941 +12\ar[u]\ar[rru]\ar@/_/[rr]&&13\ar[ll]\ar[u]\ar[rr]&&14\ar[lu]&15\ar[l]
  38.942 +\\
  38.943 +}
  38.944 +
  38.945 +\bigskip\bigskip
  38.946 +
  38.947 +\noindent
  38.948 +the program output may look like follows:
  38.949 +
  38.950 +\begin{footnotesize}
  38.951 +\begin{verbatim}
  38.952 +Reading graph from `graph.txt'...
  38.953 +Graph has 15 vertices and 30 arcs
  38.954 +31 lines were read
  38.955 +nc = 4
  38.956 +num[1] = 3
  38.957 +num[2] = 3
  38.958 +num[3] = 3
  38.959 +num[4] = 2
  38.960 +num[5] = 3
  38.961 +num[6] = 3
  38.962 +num[7] = 3
  38.963 +num[8] = 3
  38.964 +num[9] = 1
  38.965 +num[10] = 1
  38.966 +num[11] = 1
  38.967 +num[12] = 4
  38.968 +num[13] = 4
  38.969 +num[14] = 1
  38.970 +num[15] = 1
  38.971 +\end{verbatim}
  38.972 +\end{footnotesize}
  38.973 +
  38.974 +\subsection{glp\_top\_sort---topological sorting of acyclic digraph}
  38.975 +
  38.976 +\subsubsection*{Synopsis}
  38.977 +
  38.978 +\begin{verbatim}
  38.979 +int glp_top_sort(glp_graph *G, int v_num);
  38.980 +\end{verbatim}
  38.981 +
  38.982 +\subsubsection*{Description}
  38.983 +
  38.984 +The routine \verb|glp_top_sort| performs topological sorting of
  38.985 +vertices of the specified acyclic digraph.
  38.986 +
  38.987 +The parameter \verb|v_num| specifies an offset of the field of type
  38.988 +\verb|int| in the vertex data block, to which the routine stores the
  38.989 +vertex number assigned. If \verb|v_num| $<0$, vertex numbers are not
  38.990 +stored.
  38.991 +
  38.992 +The vertices are numbered from 1 to $n$, where $n$ is the total number
  38.993 +of vertices in the graph. The vertex numbering has the property that
  38.994 +for every arc $(i\rightarrow j)$ in the graph the condition
  38.995 +$num(i)<num(j)$ holds. Special case $num(i)=0$ means that vertex $i$ is
  38.996 +not assigned a number, because the graph is {\it not} acyclic.
  38.997 +
  38.998 +\subsubsection*{Returns}
  38.999 +
 38.1000 +If the graph is acyclic and therefore all the vertices have been
 38.1001 +assigned numbers, the routine \verb|glp_top_sort| returns zero.
 38.1002 +Otherwise, if the graph is not acyclic, the routine returns the number
 38.1003 +of vertices which have not been numbered, i.e. for which $num(i)=0$.
 38.1004 +
 38.1005 +\subsubsection*{Example}
 38.1006 +
 38.1007 +The following program reads a digraph from a plain text file
 38.1008 +`\verb|graph.txt|' and performs topological sorting of its vertices.
 38.1009 +
 38.1010 +\begin{footnotesize}
 38.1011 +\begin{verbatim}
 38.1012 +#include <stddef.h>
 38.1013 +#include <stdio.h>
 38.1014 +#include <stdlib.h>
 38.1015 +#include <glpk.h>
 38.1016 +
 38.1017 +typedef struct { int num; } v_data;
 38.1018 +
 38.1019 +#define vertex(v) ((v_data *)((v)->data))
 38.1020 +
 38.1021 +int main(void)
 38.1022 +{     glp_graph *G;
 38.1023 +      int i, cnt;
 38.1024 +      G = glp_create_graph(sizeof(v_data), 0);
 38.1025 +      glp_read_graph(G, "graph.txt");
 38.1026 +      cnt = glp_top_sort(G, offsetof(v_data, num));
 38.1027 +      printf("cnt = %d\n", cnt);
 38.1028 +      for (i = 1; i <= G->nv; i++)
 38.1029 +         printf("num[%d] = %d\n", i, vertex(G->v[i])->num);
 38.1030 +      glp_delete_graph(G);
 38.1031 +      return 0;
 38.1032 +}
 38.1033 +\end{verbatim}
 38.1034 +\end{footnotesize}
 38.1035 +
 38.1036 +\noindent
 38.1037 +If the file `\verb|graph.txt|' contains the graph shown below:
 38.1038 +
 38.1039 +\bigskip
 38.1040 +
 38.1041 +\noindent\hfil
 38.1042 +\xymatrix @=20pt
 38.1043 +{
 38.1044 +1\ar[rrr]&&&2\ar[r]\ar[rddd]&3\ar[rd]&&&&\\
 38.1045 +&&&4\ar[ru]&&5\ar[r]&6\ar[rd]\ar[dd]&&\\
 38.1046 +7\ar[r]&8\ar[r]&9\ar[ruu]\ar[ru]\ar[r]\ar[rd]&10\ar[rr]\ar[rru]&&
 38.1047 +11\ar[ru]&&12\ar[r]&13\\
 38.1048 +&&&14\ar[r]&15\ar[rrru]\ar[rr]&&16\ar[rru]\ar[rr]&&17\\
 38.1049 +}
 38.1050 +
 38.1051 +\bigskip\bigskip
 38.1052 +
 38.1053 +\noindent
 38.1054 +the program output may look like follows:
 38.1055 +
 38.1056 +\begin{footnotesize}
 38.1057 +\begin{verbatim}
 38.1058 +Reading graph from `graph.txt'...
 38.1059 +Graph has 17 vertices and 23 arcs
 38.1060 +24 lines were read
 38.1061 +cnt = 0
 38.1062 +num[1] = 8
 38.1063 +num[2] = 9
 38.1064 +num[3] = 10
 38.1065 +num[4] = 4
 38.1066 +num[5] = 11
 38.1067 +num[6] = 12
 38.1068 +num[7] = 1
 38.1069 +num[8] = 2
 38.1070 +num[9] = 3
 38.1071 +num[10] = 5
 38.1072 +num[11] = 6
 38.1073 +num[12] = 14
 38.1074 +num[13] = 16
 38.1075 +num[14] = 7
 38.1076 +num[15] = 13
 38.1077 +num[16] = 15
 38.1078 +num[17] = 17
 38.1079 +\end{verbatim}
 38.1080 +\end{footnotesize}
 38.1081 +
 38.1082 +\noindent
 38.1083 +The output corresponds to the following vertex numbering:
 38.1084 +
 38.1085 +\bigskip
 38.1086 +
 38.1087 +\noindent\hfil
 38.1088 +\xymatrix @=20pt
 38.1089 +{
 38.1090 +8\ar[rrr]&&&9\ar[r]\ar[rddd]&10\ar[rd]&&&&\\
 38.1091 +&&&4\ar[ru]&&11\ar[r]&12\ar[rd]\ar[dd]&&\\
 38.1092 +1\ar[r]&2\ar[r]&3\ar[ruu]\ar[ru]\ar[r]\ar[rd]&5\ar[rr]\ar[rru]&&
 38.1093 +6\ar[ru]&&14\ar[r]&16\\
 38.1094 +&&&7\ar[r]&13\ar[rrru]\ar[rr]&&15\ar[rru]\ar[rr]&&17\\
 38.1095 +}
 38.1096 +
 38.1097 +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 38.1098 +
 38.1099 +\chapter{Network optimization API routines}
 38.1100 +
 38.1101 +\section{Minimum cost flow problem}
 38.1102 +
 38.1103 +\subsection{Background}
 38.1104 +
 38.1105 +The {\it minimum cost flow problem} (MCFP) is stated as follows. Let
 38.1106 +there be given a directed graph (flow network) $G=(V,A)$, where $V$ is
 38.1107 +a set of vertices (nodes), and $A\subseteq V\times V$ is a set of arcs.
 38.1108 +Let for each node $i\in V$ there be given a quantity $b_i$ having the
 38.1109 +following meaning:
 38.1110 +
 38.1111 +if $b_i>0$, then $|b_i|$ is a {\it supply} at node $i$, which shows
 38.1112 +how many flow units are {\it generated} at node $i$ (or, equivalently,
 38.1113 +entering the network through node $i$ from the outside);
 38.1114 +
 38.1115 +if $b_i<0$, then $|b_i|$ is a {\it demand} at node $i$, which shows how
 38.1116 +many flow units are {\it lost} at node $i$ (or, equivalently, leaving
 38.1117 +the network through node $i$ to the outside);
 38.1118 +
 38.1119 +if $b_i=0$, then $i$ is a {\it transshipment} node, at which the flow
 38.1120 +is conserved, i.e. neither generated nor lost.
 38.1121 +
 38.1122 +Let also for each arc $a=(i,j)\in A$ there be given the following three
 38.1123 +quantities:
 38.1124 +
 38.1125 +$l_{ij}$, a (non-negative) lower bound to the flow through arc $(i,j)$;
 38.1126 +
 38.1127 +$u_{ij}$, an upper bound to the flow through arc $(i,j)$, which is the
 38.1128 +{\it arc capacity};
 38.1129 +
 38.1130 +$c_{ij}$, a per-unit cost of the flow through arc $(i,j)$.
 38.1131 +
 38.1132 +The problem is to find flows $x_{ij}$ through every arc of the network,
 38.1133 +which satisfy the specified bounds and the conservation constraints at
 38.1134 +all nodes, and minimize the total flow cost. Here the conservation
 38.1135 +constraint at a node means that the total flow entering this node
 38.1136 +through its incoming arcs plus the supply at this node must be equal to
 38.1137 +the total flow leaving this node through its outgoing arcs plus the
 38.1138 +demand at this node.
 38.1139 +
 38.1140 +An example of the minimum cost flow problem is shown on Fig.~1.
 38.1141 +
 38.1142 +\bigskip
 38.1143 +
 38.1144 +\noindent\hfil
 38.1145 +\xymatrix @C=48pt
 38.1146 +{_{20}\ar@{~>}[d]&
 38.1147 +v_2\ar[r]|{_{0,10,\$2}}\ar[dd]|{_{0,9,\$3}}&
 38.1148 +v_3\ar[dd]|{_{2,12,\$1}}\ar[r]|{_{0,18,\$0}}&
 38.1149 +v_8\ar[rd]|{_{0,20,\$9}}&\\
 38.1150 +v_1\ar[ru]|{_{0,14,\$0}}\ar[rd]|{_{0,23,\$0}}&&&
 38.1151 +v_6\ar[d]|{_{0,7,\$0}}\ar[u]|{_{4,8,\$0}}&
 38.1152 +v_9\ar@{~>}[d]\\
 38.1153 +&v_4\ar[r]|{_{0,26,\$0}}&
 38.1154 +v_5\ar[luu]|{_{0,11,\$1}}\ar[ru]|{_{0,25,\$5}}\ar[r]|{_{0,4,\$7}}&
 38.1155 +v_7\ar[ru]|{_{0,15,\$3}}&_{20}\\
 38.1156 +}
 38.1157 +
 38.1158 +\medskip
 38.1159 +
 38.1160 +\noindent\hfil
 38.1161 +\begin{tabular}{ccc}
 38.1162 +\xymatrix @C=48pt{v_i\ar[r]|{\ l,u,\$c\ }&v_j\\}&
 38.1163 +\xymatrix{\hbox{\footnotesize supply}\ar@{~>}[r]&v_i\\}&
 38.1164 +\xymatrix{v_i\ar@{~>}[r]&\hbox{\footnotesize demand}\\}\\
 38.1165 +\end{tabular}
 38.1166 +
 38.1167 +\bigskip
 38.1168 +
 38.1169 +\noindent\hfil
 38.1170 +Fig.~1. An example of the minimum cost flow problem.
 38.1171 +
 38.1172 +\bigskip
 38.1173 +
 38.1174 +The minimum cost flow problem can be naturally formulated as the
 38.1175 +following LP problem:
 38.1176 +
 38.1177 +\medskip
 38.1178 +
 38.1179 +\noindent
 38.1180 +\hspace{.5in}minimize
 38.1181 +$$z=\sum_{(i,j)\in A}c_{ij}x_{ij}\eqno(1)$$
 38.1182 +\hspace{.5in}subject to
 38.1183 +$$\sum_{(i,j)\in A}x_{ij}-\sum_{(j,i)\in A}x_{ji}=b_i\ \ \ \hbox
 38.1184 +{for all}\ i\in V\eqno(2)$$
 38.1185 +$$l_{ij}\leq x_{ij}\leq u_{ij}\ \ \ \hbox{for all}\ (i,j)\in A
 38.1186 +\eqno(3)$$
 38.1187 +
 38.1188 +\newpage
 38.1189 +
 38.1190 +\subsection{glp\_read\_mincost---read minimum cost flow problem\\data
 38.1191 +in DIMACS format}
 38.1192 +
 38.1193 +\subsubsection*{Synopsis}
 38.1194 +
 38.1195 +\begin{verbatim}
 38.1196 +int glp_read_mincost(glp_graph *G, int v_rhs, int a_low,
 38.1197 +      int a_cap, int a_cost, const char *fname);
 38.1198 +\end{verbatim}
 38.1199 +
 38.1200 +\subsubsection*{Description}
 38.1201 +
 38.1202 +The routine \verb|glp_read_mincost| reads the minimum cost flow problem
 38.1203 +data from a text file in DIMACS format.
 38.1204 +
 38.1205 +The parameter \verb|G| specifies the graph object, to which the problem
 38.1206 +data have to be stored. Note that before reading data the current
 38.1207 +content of the graph object is completely erased with the routine
 38.1208 +\verb|glp_erase_graph|.
 38.1209 +
 38.1210 +The parameter \verb|v_rhs| specifies an offset of the field of type
 38.1211 +\verb|double| in the vertex data block, to which the routine stores
 38.1212 +$b_i$, the supply/demand value. If \verb|v_rhs| $<0$, the value is not
 38.1213 +stored.
 38.1214 +
 38.1215 +The parameter \verb|a_low| specifies an offset of the field of type
 38.1216 +\verb|double| in the arc data block, to which the routine stores
 38.1217 +$l_{ij}$, the lower bound to the arc flow. If \verb|a_low| $<0$, the
 38.1218 +lower bound is not stored.
 38.1219 +
 38.1220 +The parameter \verb|a_cap| specifies an offset of the field of type
 38.1221 +\verb|double| in the arc data block, to which the routine stores
 38.1222 +$u_{ij}$, the upper bound to the arc flow (the arc capacity). If
 38.1223 +\verb|a_cap| $<0$, the upper bound is not stored.
 38.1224 +
 38.1225 +The parameter \verb|a_cost| specifies an offset of the field of type
 38.1226 +\verb|double| in the arc data block, to which the routine stores
 38.1227 +$c_{ij}$, the per-unit cost of the arc flow. If \verb|a_cost| $<0$, the
 38.1228 +cost is not stored.
 38.1229 +
 38.1230 +The character string \verb|fname| specifies the name of a text file to
 38.1231 +be read in. (If the file name name ends with the suffix `\verb|.gz|',
 38.1232 +the file is assumed to be compressed, in which case the routine
 38.1233 +decompresses it ``on the fly''.)
 38.1234 +
 38.1235 +\subsubsection*{Returns}
 38.1236 +
 38.1237 +If the operation was successful, the routine returns zero. Otherwise,
 38.1238 +it prints an error message and returns non-zero.
 38.1239 +
 38.1240 +\newpage
 38.1241 +
 38.1242 +\subsubsection*{Example}
 38.1243 +
 38.1244 +\begin{footnotesize}
 38.1245 +\begin{verbatim}
 38.1246 +typedef struct
 38.1247 +{     /* vertex data block */
 38.1248 +      ...
 38.1249 +      double rhs;
 38.1250 +      ...
 38.1251 +} v_data;
 38.1252 +
 38.1253 +typedef struct
 38.1254 +{     /* arc data block */
 38.1255 +      ...
 38.1256 +      double low, cap, cost;
 38.1257 +      ...
 38.1258 +} a_data;
 38.1259 +
 38.1260 +int main(void)
 38.1261 +{     glp_graph *G;
 38.1262 +      int ret;
 38.1263 +      G = glp_create_graph(sizeof(v_data), sizeof(a_data));
 38.1264 +      ret = glp_read_mincost(G, offsetof(v_data, rhs),
 38.1265 +         offsetof(a_data, low), offsetof(a_data, cap),
 38.1266 +         offsetof(a_data, cost), "sample.min");
 38.1267 +      if (ret != 0) goto ...
 38.1268 +      ...
 38.1269 +}
 38.1270 +\end{verbatim}
 38.1271 +\end{footnotesize}
 38.1272 +
 38.1273 +\subsubsection*{DIMACS minimum cost flow problem format\footnote{This
 38.1274 +material is based on the paper ``The First DIMACS International
 38.1275 +Algorithm Implementation Challenge: Problem Definitions and
 38.1276 +Specifications'', which is publically available at
 38.1277 +{\tt http://dimacs.rutgers.edu/Challenges/}.}}
 38.1278 +\label{subsecmincost}
 38.1279 +
 38.1280 +The DIMACS input file is a plain ASCII text file. It contains
 38.1281 +{\it lines} of several types described below. A line is terminated with
 38.1282 +an end-of-line character. Fields in each line are separated by at least
 38.1283 +one blank space. Each line begins with a one-character designator to
 38.1284 +identify the line type.
 38.1285 +
 38.1286 +Note that DIMACS requires all numerical quantities to be integers in
 38.1287 +the range $[-2^{31},\ 2^{31}-1]$ while GLPK allows the quantities to be
 38.1288 +floating-point numbers.
 38.1289 +
 38.1290 +\newpage
 38.1291 +
 38.1292 +\paragraph{Comment lines.} Comment lines give human-readable information
 38.1293 +about the file and are ignored by programs. Comment lines can appear
 38.1294 +anywhere in the file. Each comment line begins with a lower-case
 38.1295 +character \verb|c|.
 38.1296 +
 38.1297 +\begin{verbatim}
 38.1298 +   c This is a comment line
 38.1299 +\end{verbatim}
 38.1300 +
 38.1301 +\paragraph{Problem line.} There is one problem line per data file. The
 38.1302 +problem line must appear before any node or arc descriptor lines. It has
 38.1303 +the following format:
 38.1304 +
 38.1305 +\begin{verbatim}
 38.1306 +   p min NODES ARCS
 38.1307 +\end{verbatim}
 38.1308 +
 38.1309 +\noindent
 38.1310 +The lower-case character \verb|p| signifies that this is a problem line.
 38.1311 +The three-character problem designator \verb|min| identifies the file as
 38.1312 +containing specification information for the minimum cost flow problem.
 38.1313 +The \verb|NODES| field contains an integer value specifying the number
 38.1314 +of nodes in the network. The \verb|ARCS| field contains an integer value
 38.1315 +specifying the number of arcs in the network.
 38.1316 +
 38.1317 +\paragraph{Node descriptors.} All node descriptor lines must appear
 38.1318 +before all arc descriptor lines. The node descriptor lines describe
 38.1319 +supply and demand nodes, but not transshipment nodes. That is, only
 38.1320 +nodes with non-zero node supply/demand values appear. There is one node
 38.1321 +descriptor line for each such node, with the following format:
 38.1322 +
 38.1323 +\begin{verbatim}
 38.1324 +   n ID FLOW
 38.1325 +\end{verbatim}
 38.1326 +
 38.1327 +\noindent
 38.1328 +The lower-case character \verb|n| signifies that this is a node
 38.1329 +descriptor line. The \verb|ID| field gives a node identification number,
 38.1330 +an integer between 1 and \verb|NODES|. The \verb|FLOW| field gives the
 38.1331 +amount of supply (if positive) or demand (if negative) at node
 38.1332 +\verb|ID|.
 38.1333 +
 38.1334 +\paragraph{Arc descriptors.} There is one arc descriptor line for each
 38.1335 +arc in the network. Arc descriptor lines are of the following format:
 38.1336 +
 38.1337 +\begin{verbatim}
 38.1338 +   a SRC DST LOW CAP COST
 38.1339 +\end{verbatim}
 38.1340 +
 38.1341 +\noindent
 38.1342 +The lower-case character \verb|a| signifies that this is an arc
 38.1343 +descriptor line. For a directed arc $(i,j)$ the \verb|SRC| field gives
 38.1344 +the identification number $i$ for the tail endpoint, and the \verb|DST|
 38.1345 +field gives the identification number $j$ for the head endpoint.
 38.1346 +Identification numbers are integers between 1 and \verb|NODES|. The
 38.1347 +\verb|LOW| field specifies the minimum amount of flow that can be sent
 38.1348 +along arc $(i,j)$, and the \verb|CAP| field gives the maximum amount of
 38.1349 +flow that can be sent along arc $(i,j)$ in a feasible flow. The
 38.1350 +\verb|COST| field contains the per-unit cost of flow sent along arc
 38.1351 +$(i,j)$.
 38.1352 +
 38.1353 +\paragraph{Example.} Below here is an example of the data file in
 38.1354 +DIMACS format corresponding to the minimum cost flow problem shown on
 38.1355 +Fig~1.
 38.1356 +
 38.1357 +\begin{footnotesize}
 38.1358 +\begin{verbatim}
 38.1359 +c sample.min
 38.1360 +c
 38.1361 +c This is an example of the minimum cost flow problem data
 38.1362 +c in DIMACS format.
 38.1363 +c
 38.1364 +p min 9 14
 38.1365 +c
 38.1366 +n 1 20
 38.1367 +n 9 -20
 38.1368 +c
 38.1369 +a 1 2 0 14 0
 38.1370 +a 1 4 0 23 0
 38.1371 +a 2 3 0 10 2
 38.1372 +a 2 4 0  9 3
 38.1373 +a 3 5 2 12 1
 38.1374 +a 3 8 0 18 0
 38.1375 +a 4 5 0 26 0
 38.1376 +a 5 2 0 11 1
 38.1377 +a 5 6 0 25 5
 38.1378 +a 5 7 0  4 7
 38.1379 +a 6 7 0  7 0
 38.1380 +a 6 8 4  8 0
 38.1381 +a 7 9 0 15 3
 38.1382 +a 8 9 0 20 9
 38.1383 +c
 38.1384 +c eof
 38.1385 +\end{verbatim}
 38.1386 +\end{footnotesize}
 38.1387 +
 38.1388 +\newpage
 38.1389 +
 38.1390 +\subsection{glp\_write\_mincost---write minimum cost flow problem\\data
 38.1391 +in DIMACS format}
 38.1392 +
 38.1393 +\subsubsection*{Synopsis}
 38.1394 +
 38.1395 +\begin{verbatim}
 38.1396 +int glp_write_mincost(glp_graph *G, int v_rhs, int a_low,
 38.1397 +      int a_cap, int a_cost, const char *fname);
 38.1398 +\end{verbatim}
 38.1399 +
 38.1400 +\subsubsection*{Description}
 38.1401 +
 38.1402 +The routine \verb|glp_write_mincost| writes the minimum cost flow
 38.1403 +problem data to a text file in DIMACS format.
 38.1404 +
 38.1405 +The parameter \verb|G| is the graph (network) program object, which
 38.1406 +specifies the minimum cost flow problem instance.
 38.1407 +
 38.1408 +The parameter \verb|v_rhs| specifies an offset of the field of type
 38.1409 +\verb|double| in the vertex data block, which contains $b_i$, the
 38.1410 +supply/demand value. If \verb|v_rhs| $<0$, it is assumed that $b_i=0$
 38.1411 +for all nodes.
 38.1412 +
 38.1413 +The parameter \verb|a_low| specifies an offset of the field of type
 38.1414 +\verb|double| in the arc data block, which contains $l_{ij}$, the lower
 38.1415 +bound to the arc flow. If \verb|a_low| $<0$, it is assumed that
 38.1416 +$l_{ij}=0$ for all arcs.
 38.1417 +
 38.1418 +The parameter \verb|a_cap| specifies an offset of the field of type
 38.1419 +\verb|double| in the arc data block, which contains $u_{ij}$, the upper
 38.1420 +bound to the arc flow (the arc capacity). If the upper bound is
 38.1421 +specified as \verb|DBL_MAX|, it is assumed that $u_{ij}=\infty$, i.e.
 38.1422 +the arc is uncapacitated. If \verb|a_cap| $<0$, it is assumed that
 38.1423 +$u_{ij}=1$ for all arcs.
 38.1424 +
 38.1425 +The parameter \verb|a_cost| specifies an offset of the field of type
 38.1426 +\verb|double| in the arc data block, which contains $c_{ij}$, the
 38.1427 +per-unit cost of the arc flow. If \verb|a_cost| $<0$, it is assumed that
 38.1428 +$c_{ij}=0$ for all arcs.
 38.1429 +
 38.1430 +The character string \verb|fname| specifies a name of the text file to
 38.1431 +be written out. (If the file name ends with suffix `\verb|.gz|', the
 38.1432 +file is assumed to be compressed, in which case the routine performs
 38.1433 +automatic compression on writing it.)
 38.1434 +
 38.1435 +\subsubsection*{Returns}
 38.1436 +
 38.1437 +If the operation was successful, the routine returns zero. Otherwise,
 38.1438 +it prints an error message and returns non-zero.
 38.1439 +
 38.1440 +\newpage
 38.1441 +
 38.1442 +\subsection{glp\_mincost\_lp---convert minimum cost flow problem\\to LP}
 38.1443 +
 38.1444 +\subsubsection*{Synopsis}
 38.1445 +
 38.1446 +\begin{verbatim}
 38.1447 +void glp_mincost_lp(glp_prob *lp, glp_graph *G, int names,
 38.1448 +      int v_rhs, int a_low, int a_cap, int a_cost);
 38.1449 +\end{verbatim}
 38.1450 +
 38.1451 +\subsubsection*{Description}
 38.1452 +
 38.1453 +The routine \verb|glp_mincost_lp| builds LP problem (1)---(3), which
 38.1454 +corresponds to the specified minimum cost flow problem.
 38.1455 +
 38.1456 +The parameter \verb|lp| is the resultant LP problem object to be built.
 38.1457 +Note that on entry its current content is erased with the routine
 38.1458 +\verb|glp_erase_prob|.
 38.1459 +
 38.1460 +The parameter \verb|G| is the graph (network) program object, which
 38.1461 +specifies the minimum cost flow problem instance.
 38.1462 +
 38.1463 +The parameter \verb|names| is a flag. If it is \verb|GLP_ON|, the
 38.1464 +routine uses symbolic names of the graph object components to assign
 38.1465 +symbolic names to the LP problem object components. If the flag is
 38.1466 +\verb|GLP_OFF|, no symbolic names are assigned.
 38.1467 +
 38.1468 +The parameter \verb|v_rhs| specifies an offset of the field of type
 38.1469 +\verb|double| in the vertex data block, which contains $b_i$, the
 38.1470 +supply/demand value. If \verb|v_rhs| $<0$, it is assumed that $b_i=0$
 38.1471 +for all nodes.
 38.1472 +
 38.1473 +The parameter \verb|a_low| specifies an offset of the field of type
 38.1474 +\verb|double| in the arc data block, which contains $l_{ij}$, the lower
 38.1475 +bound to the arc flow. If \verb|a_low| $<0$, it is assumed that
 38.1476 +$l_{ij}=0$ for all arcs.
 38.1477 +
 38.1478 +The parameter \verb|a_cap| specifies an offset of the field of type
 38.1479 +\verb|double| in the arc data block, which contains $u_{ij}$, the upper
 38.1480 +bound to the arc flow (the arc capacity). If the upper bound is
 38.1481 +specified as \verb|DBL_MAX|, it is assumed that $u_{ij}=\infty$, i.e.
 38.1482 +the arc is uncapacitated. If \verb|a_cap| $<0$, it is assumed that
 38.1483 +$u_{ij}=1$ for all arcs.
 38.1484 +
 38.1485 +The parameter \verb|a_cost| specifies an offset of the field of type
 38.1486 +\verb|double| in the arc data block, which contains $c_{ij}$, the
 38.1487 +per-unit cost of the arc flow. If \verb|a_cost| $<0$, it is assumed that
 38.1488 +$c_{ij}=0$ for all arcs.
 38.1489 +
 38.1490 +\subsubsection*{Example}
 38.1491 +
 38.1492 +The example program below reads the minimum cost problem instance in
 38.1493 +DIMACS format from file `\verb|sample.min|', converts the instance to
 38.1494 +LP, and then writes the resultant LP in CPLEX format to file
 38.1495 +`\verb|mincost.lp|'.
 38.1496 +
 38.1497 +\newpage
 38.1498 +
 38.1499 +\begin{footnotesize}
 38.1500 +\begin{verbatim}
 38.1501 +#include <stddef.h>
 38.1502 +#include <glpk.h>
 38.1503 +
 38.1504 +typedef struct { double rhs; } v_data;
 38.1505 +typedef struct { double low, cap, cost; } a_data;
 38.1506 +
 38.1507 +int main(void)
 38.1508 +{     glp_graph *G;
 38.1509 +      glp_prob *lp;
 38.1510 +      G = glp_create_graph(sizeof(v_data), sizeof(a_data));
 38.1511 +      glp_read_mincost(G, offsetof(v_data, rhs),
 38.1512 +         offsetof(a_data, low), offsetof(a_data, cap),
 38.1513 +         offsetof(a_data, cost), "sample.min");
 38.1514 +      lp = glp_create_prob();
 38.1515 +      glp_mincost_lp(lp, G, GLP_ON, offsetof(v_data, rhs),
 38.1516 +         offsetof(a_data, low), offsetof(a_data, cap),
 38.1517 +         offsetof(a_data, cost));
 38.1518 +      glp_delete_graph(G);
 38.1519 +      glp_write_lp(lp, NULL, "mincost.lp");
 38.1520 +      glp_delete_prob(lp);
 38.1521 +      return 0;
 38.1522 +}
 38.1523 +\end{verbatim}
 38.1524 +\end{footnotesize}
 38.1525 +
 38.1526 +If `\verb|sample.min|' is the example data file from the subsection
 38.1527 +describing the routine \verb|glp_read_mincost|, file `\verb|mincost.lp|'
 38.1528 +may look like follows:
 38.1529 +
 38.1530 +\begin{footnotesize}
 38.1531 +\begin{verbatim}
 38.1532 +Minimize
 38.1533 + obj: + 3 x(2,4) + 2 x(2,3) + x(3,5) + 7 x(5,7) + 5 x(5,6)
 38.1534 + + x(5,2) + 3 x(7,9) + 9 x(8,9)
 38.1535 +
 38.1536 +Subject To
 38.1537 + r_1: + x(1,2) + x(1,4) = 20
 38.1538 + r_2: - x(5,2) + x(2,3) + x(2,4) - x(1,2) = 0
 38.1539 + r_3: + x(3,5) + x(3,8) - x(2,3) = 0
 38.1540 + r_4: + x(4,5) - x(2,4) - x(1,4) = 0
 38.1541 + r_5: + x(5,2) + x(5,6) + x(5,7) - x(4,5) - x(3,5) = 0
 38.1542 + r_6: + x(6,7) + x(6,8) - x(5,6) = 0
 38.1543 + r_7: + x(7,9) - x(6,7) - x(5,7) = 0
 38.1544 + r_8: + x(8,9) - x(6,8) - x(3,8) = 0
 38.1545 + r_9: - x(8,9) - x(7,9) = -20
 38.1546 +
 38.1547 +Bounds
 38.1548 + 0 <= x(1,4) <= 23
 38.1549 + 0 <= x(1,2) <= 14
 38.1550 + 0 <= x(2,4) <= 9
 38.1551 + 0 <= x(2,3) <= 10
 38.1552 + 0 <= x(3,8) <= 18
 38.1553 + 2 <= x(3,5) <= 12
 38.1554 + 0 <= x(4,5) <= 26
 38.1555 + 0 <= x(5,7) <= 4
 38.1556 + 0 <= x(5,6) <= 25
 38.1557 + 0 <= x(5,2) <= 11
 38.1558 + 4 <= x(6,8) <= 8
 38.1559 + 0 <= x(6,7) <= 7
 38.1560 + 0 <= x(7,9) <= 15
 38.1561 + 0 <= x(8,9) <= 20
 38.1562 +
 38.1563 +End
 38.1564 +\end{verbatim}
 38.1565 +\end{footnotesize}
 38.1566 +
 38.1567 +\subsection{glp\_mincost\_okalg---solve minimum cost flow problem with
 38.1568 +out-of-kilter algorithm}
 38.1569 +
 38.1570 +\subsubsection*{Synopsis}
 38.1571 +
 38.1572 +\begin{verbatim}
 38.1573 +int glp_mincost_okalg(glp_graph *G, int v_rhs, int a_low,
 38.1574 +      int a_cap, int a_cost, double *sol, int a_x, int v_pi);
 38.1575 +\end{verbatim}
 38.1576 +
 38.1577 +\subsubsection*{Description}
 38.1578 +
 38.1579 +The routine \verb|glp_mincost_okalg| finds optimal solution to the
 38.1580 +minimum cost flow problem with the out-of-kilter
 38.1581 +algorithm.\footnote{GLPK implementation of the out-of-kilter algorithm
 38.1582 +is based on the following book: L.~R.~Ford,~Jr., and D.~R.~Fulkerson,
 38.1583 +``Flows in Networks,'' The RAND Corp., Report R-375-PR (August 1962),
 38.1584 +Chap. III ``Minimal Cost Flow Problems,'' pp.~113-26.} Note that this
 38.1585 +routine requires all the problem data to be integer-valued.
 38.1586 +
 38.1587 +The parameter \verb|G| is a graph (network) program object which
 38.1588 +specifies the minimum cost flow problem instance to be solved.
 38.1589 +
 38.1590 +The parameter \verb|v_rhs| specifies an offset of the field of type
 38.1591 +\verb|double| in the vertex data block, which contains $b_i$, the
 38.1592 +supply/demand value. This value must be integer in the range
 38.1593 +[$-$\verb|INT_MAX|, $+$\verb|INT_MAX|]. If \verb|v_rhs| $<0$, it is
 38.1594 +assumed that $b_i=0$ for all nodes.
 38.1595 +
 38.1596 +The parameter \verb|a_low| specifies an offset of the field of type
 38.1597 +\verb|double| in the arc data block, which contains $l_{ij}$, the lower
 38.1598 +bound to the arc flow. This bound must be integer in the range
 38.1599 +[$0$, \verb|INT_MAX|]. If \verb|a_low| $<0$, it is assumed that
 38.1600 +$l_{ij}=0$ for all arcs.
 38.1601 +
 38.1602 +The parameter \verb|a_cap| specifies an offset of the field of type
 38.1603 +\verb|double| in the arc data block, which contains $u_{ij}$, the upper
 38.1604 +bound to the arc flow (the arc capacity). This bound must be integer in
 38.1605 +the range [$l_{ij}$, \verb|INT_MAX|]. If \verb|a_cap| $<0$, it is
 38.1606 +assumed that $u_{ij}=1$ for all arcs.
 38.1607 +
 38.1608 +The parameter \verb|a_cost| specifies an offset of the field of type
 38.1609 +\verb|double| in the arc data block, which contains $c_{ij}$, the
 38.1610 +per-unit cost of the arc flow. This value must be integer in the range
 38.1611 +[$-$\verb|INT_MAX|, $+$\verb|INT_MAX|]. If \verb|a_cost| $<0$, it is
 38.1612 +assumed that $c_{ij}=0$ for all arcs.
 38.1613 +
 38.1614 +The parameter \verb|sol| specifies a location, to which the routine
 38.1615 +stores the objective value (that is, the total cost) found. If
 38.1616 +\verb|sol| is NULL, the objective value is not stored.
 38.1617 +
 38.1618 +The parameter \verb|a_x| specifies an offset of the field of type
 38.1619 +\verb|double| in the arc data block, to which the routine stores
 38.1620 +$x_{ij}$, the arc flow found. If \verb|a_x| $<0$, the arc flow value is
 38.1621 +not stored.
 38.1622 +
 38.1623 +The parameter \verb|v_pi| specifies an offset of the field of type
 38.1624 +\verb|double| in the vertex data block, to which the routine stores
 38.1625 +$\pi_i$, the node potential, which is the Lagrange multiplier for the
 38.1626 +corresponding flow conservation equality constraint (see (2) in
 38.1627 +Subsection ``Background''). If necessary, the application program may
 38.1628 +use the node potentials to compute $\lambda_{ij}$, reduced costs of the
 38.1629 +arc flows $x_{ij}$, which are the Lagrange multipliers for the arc flow
 38.1630 +bound constraints (see (3) ibid.), using the following formula:
 38.1631 +$$\lambda_{ij}=c_{ij}-(\pi_i-\pi_j),$$
 38.1632 +where $c_{ij}$ is the per-unit cost for arc $(i,j)$.
 38.1633 +
 38.1634 +Note that all solution components (the objective value, arc flows, and
 38.1635 +node potentials) computed by the routine are always integer-valued.
 38.1636 +
 38.1637 +\subsubsection*{Returns}
 38.1638 +
 38.1639 +\def\arraystretch{1}
 38.1640 +
 38.1641 +\begin{tabular}{@{}p{25mm}p{97.3mm}@{}}
 38.1642 +0 & Optimal solution found.\\
 38.1643 +\verb|GLP_ENOPFS| & No (primal) feasible solution exists.\\
 38.1644 +\verb|GLP_EDATA| & Unable to start the search, because some problem
 38.1645 +data are either not integer-valued or out of range. This code is also
 38.1646 +returned if the total supply, which is the sum of $b_i$ over all source
 38.1647 +nodes (nodes with $b_i>0$), exceeds \verb|INT_MAX|.\\
 38.1648 +\end{tabular}
 38.1649 +
 38.1650 +\noindent
 38.1651 +\begin{tabular}{@{}p{25mm}p{97.3mm}@{}}
 38.1652 +\verb|GLP_ERANGE| & The search was prematurely terminated because of
 38.1653 +integer overflow.\\
 38.1654 +\verb|GLP_EFAIL| & An error has been detected in the program logic.
 38.1655 +(If this code is returned for your problem instance, please report to
 38.1656 +\verb|<bug-glpk@gnu.org>|.)\\
 38.1657 +\end{tabular}
 38.1658 +
 38.1659 +\subsubsection*{Comments}
 38.1660 +
 38.1661 +By design the out-of-kilter algorithm is applicable only to networks,
 38.1662 +where $b_i=0$ for {\it all} nodes, i.e. actually this algorithm finds a
 38.1663 +minimal cost {\it circulation}. Due to this requirement the routine
 38.1664 +\verb|glp_mincost_okalg| converts the original network to a network
 38.1665 +suitable for the out-of-kilter algorithm in the following
 38.1666 +way:\footnote{The conversion is performed internally and does not change
 38.1667 +the original network program object passed to the routine.}
 38.1668 +
 38.1669 +1) it adds two auxiliary nodes $s$ and $t$;
 38.1670 +
 38.1671 +2) for each original node $i$ with $b_i>0$ the routine adds auxiliary
 38.1672 +supply arc $(s\rightarrow i)$, flow $x_{si}$ through which is costless
 38.1673 +($c_{si}=0$) and fixed to $+b_i$ ($l_{si}=u_{si}=+b_i$);
 38.1674 +
 38.1675 +3) for each original node $i$ with $b_i<0$ the routine adds auxiliary
 38.1676 +demand arc $(i\rightarrow t)$, flow $x_{it}$ through which is costless
 38.1677 +($c_{it}=0$) and fixed to $-b_i$ ($l_{it}=u_{it}=-b_i$);
 38.1678 +
 38.1679 +4) finally, the routine adds auxiliary feedback arc $(t\rightarrow s)$,
 38.1680 +flow $x_{ts}$ through which is also costless ($c_{ts}=0$) and fixed to
 38.1681 +$F$ ($l_{ts}=u_{ts}=F$), where $\displaystyle F=\sum_{b_i>0}b_i$ is the
 38.1682 +total supply.
 38.1683 +
 38.1684 +\subsubsection*{Example}
 38.1685 +
 38.1686 +The example program below reads the minimum cost problem instance in
 38.1687 +DIMACS format from file `\verb|sample.min|', solves it by using the
 38.1688 +routine \verb|glp_mincost_okalg|, and writes the solution found to the
 38.1689 +standard output.
 38.1690 +
 38.1691 +\begin{footnotesize}
 38.1692 +\begin{verbatim}
 38.1693 +#include <stddef.h>
 38.1694 +#include <stdio.h>
 38.1695 +#include <stdlib.h>
 38.1696 +#include <glpk.h>
 38.1697 +
 38.1698 +typedef struct { double rhs, pi; } v_data;
 38.1699 +typedef struct { double low, cap, cost, x; } a_data;
 38.1700 +
 38.1701 +#define node(v) ((v_data *)((v)->data))
 38.1702 +#define arc(a)  ((a_data *)((a)->data))
 38.1703 +
 38.1704 +int main(void)
 38.1705 +{     glp_graph *G;
 38.1706 +      glp_vertex *v, *w;
 38.1707 +      glp_arc *a;
 38.1708 +      int i, ret;
 38.1709 +      double sol;
 38.1710 +      G = glp_create_graph(sizeof(v_data), sizeof(a_data));
 38.1711 +      glp_read_mincost(G, offsetof(v_data, rhs),
 38.1712 +         offsetof(a_data, low), offsetof(a_data, cap),
 38.1713 +         offsetof(a_data, cost), "sample.min");
 38.1714 +      ret = glp_mincost_okalg(G, offsetof(v_data, rhs),
 38.1715 +         offsetof(a_data, low), offsetof(a_data, cap),
 38.1716 +         offsetof(a_data, cost), &sol, offsetof(a_data, x),
 38.1717 +         offsetof(v_data, pi));
 38.1718 +      printf("ret = %d; sol = %5g\n", ret, sol);
 38.1719 +      for (i = 1; i <= G->nv; i++)
 38.1720 +      {  v = G->v[i];
 38.1721 +         printf("node %d:    pi = %5g\n", i, node(v)->pi);
 38.1722 +         for (a = v->out; a != NULL; a = a->t_next)
 38.1723 +         {  w = a->head;
 38.1724 +            printf("arc  %d->%d: x  = %5g; lambda = %5g\n",
 38.1725 +               v->i, w->i, arc(a)->x,
 38.1726 +               arc(a)->cost - (node(v)->pi - node(w)->pi));
 38.1727 +         }
 38.1728 +      }
 38.1729 +      glp_delete_graph(G);
 38.1730 +      return 0;
 38.1731 +}
 38.1732 +\end{verbatim}
 38.1733 +\end{footnotesize}
 38.1734 +
 38.1735 +If `\verb|sample.min|' is the example data file from the subsection
 38.1736 +describing the routine \verb|glp_read_mincost|, the output may look like
 38.1737 +follows:
 38.1738 +
 38.1739 +\begin{footnotesize}
 38.1740 +\begin{verbatim}
 38.1741 +Reading min-cost flow problem data from `sample.min'...
 38.1742 +Flow network has 9 nodes and 14 arcs
 38.1743 +24 lines were read
 38.1744 +ret = 0; sol =   213
 38.1745 +node 1:    pi =   -12
 38.1746 +arc  1->4: x  =    13; lambda =     0
 38.1747 +arc  1->2: x  =     7; lambda =     0
 38.1748 +node 2:    pi =   -12
 38.1749 +arc  2->4: x  =     0; lambda =     3
 38.1750 +arc  2->3: x  =     7; lambda =     0
 38.1751 +node 3:    pi =   -14
 38.1752 +arc  3->8: x  =     5; lambda =     0
 38.1753 +arc  3->5: x  =     2; lambda =     3
 38.1754 +node 4:    pi =   -12
 38.1755 +arc  4->5: x  =    13; lambda =     0
 38.1756 +node 5:    pi =   -12
 38.1757 +arc  5->7: x  =     4; lambda =    -1
 38.1758 +arc  5->6: x  =    11; lambda =     0
 38.1759 +arc  5->2: x  =     0; lambda =     1
 38.1760 +node 6:    pi =   -17
 38.1761 +arc  6->8: x  =     4; lambda =     3
 38.1762 +arc  6->7: x  =     7; lambda =    -3
 38.1763 +node 7:    pi =   -20
 38.1764 +arc  7->9: x  =    11; lambda =     0
 38.1765 +node 8:    pi =   -14
 38.1766 +arc  8->9: x  =     9; lambda =     0
 38.1767 +node 9:    pi =   -23
 38.1768 +\end{verbatim}
 38.1769 +\end{footnotesize}
 38.1770 +
 38.1771 +\subsection{glp\_netgen---Klingman's network problem generator}
 38.1772 +
 38.1773 +\subsubsection*{Synopsis}
 38.1774 +
 38.1775 +\begin{verbatim}
 38.1776 +int glp_netgen(glp_graph *G, int v_rhs, int a_cap, int a_cost,
 38.1777 +      const int parm[1+15]);
 38.1778 +\end{verbatim}
 38.1779 +
 38.1780 +\subsubsection*{Description}
 38.1781 +
 38.1782 +The routine \verb|glp_netgen| is a GLPK version of the network problem
 38.1783 +generator developed by Dr.~Darwin~Klingman.\footnote{D.~Klingman,
 38.1784 +A.~Napier, and J.~Stutz. NETGEN: A program for generating large scale
 38.1785 +capacitated assignment, transportation, and minimum cost flow networks.
 38.1786 +Management Science 20 (1974), 814-20.} It can create capacitated and
 38.1787 +uncapacitated minimum cost flow (or transshipment), transportation, and
 38.1788 +assignment problems.
 38.1789 +
 38.1790 +The parameter \verb|G| specifies the graph object, to which the
 38.1791 +generated  problem data have to be stored. Note that on entry the graph
 38.1792 +object  is erased with the routine \verb|glp_erase_graph|.
 38.1793 +
 38.1794 +The parameter \verb|v_rhs| specifies an offset of the field of type
 38.1795 +\verb|double| in the vertex data block, to which the routine stores the
 38.1796 +supply or  demand value. If \verb|v_rhs| $<0$, the value is not stored.
 38.1797 +
 38.1798 +The parameter \verb|a_cap| specifies an offset of the field of type
 38.1799 +\verb|double| in the arc data block, to which the routine stores the
 38.1800 +arc capacity. If \verb|a_cap| $<0$, the capacity is not stored.
 38.1801 +
 38.1802 +The parameter \verb|a_cost| specifies an offset of the field of type
 38.1803 +\verb|double| in the arc data block, to which the routine stores the
 38.1804 +per-unit cost if the arc flow. If \verb|a_cost| $<0$, the cost is not
 38.1805 +stored.
 38.1806 +
 38.1807 +The array \verb|parm| contains description of the network to be
 38.1808 +generated:
 38.1809 +
 38.1810 +\begin{tabular}{@{}lll@{}}
 38.1811 +\verb|parm[0] |&             &not used\\
 38.1812 +\verb|parm[1] |&\verb|iseed |&8-digit positive random number seed\\
 38.1813 +\verb|parm[2] |&\verb|nprob |&8-digit problem id number\\
 38.1814 +\verb|parm[3] |&\verb|nodes |&total number of nodes\\
 38.1815 +\verb|parm[4] |&\verb|nsorc |&total number of source nodes\\
 38.1816 +&&(including transshipment nodes)\\
 38.1817 +\verb|parm[5] |&\verb|nsink |&total number of sink nodes\\
 38.1818 +&&(including transshipment nodes)\\
 38.1819 +\verb|parm[6] |&\verb|iarcs |&number of arc\\
 38.1820 +\verb|parm[7] |&\verb|mincst|&minimum cost for arcs\\
 38.1821 +\verb|parm[8] |&\verb|maxcst|&maximum cost for arcs\\
 38.1822 +\verb|parm[9] |&\verb|itsup |&total supply\\
 38.1823 +\end{tabular}
 38.1824 +
 38.1825 +\begin{tabular}{@{}lll@{}}
 38.1826 +\verb|parm[10]|&\verb|ntsorc|&number of transshipment source nodes\\
 38.1827 +\verb|parm[11]|&\verb|ntsink|&number of transshipment sink nodes\\
 38.1828 +\verb|parm[12]|&\verb|iphic |&percentage of skeleton arcs to be given
 38.1829 +the maxi-\\&&mum cost\\
 38.1830 +\verb|parm[13]|&\verb|ipcap |&percentage of arcs to be capacitated\\
 38.1831 +\verb|parm[14]|&\verb|mincap|&minimum upper bound for capacitated arcs\\
 38.1832 +\verb|parm[15]|&\verb|maxcap|&maximum upper bound for capacitated arcs\\
 38.1833 +\end{tabular}
 38.1834 +
 38.1835 +\subsubsection*{Notes}
 38.1836 +
 38.1837 +\noindent\indent
 38.1838 +1. The routine generates a transportation problem if:
 38.1839 +$${\tt nsorc}+{\tt nsink}={\tt nodes},
 38.1840 +\  {\tt ntsorc}=0,\ \mbox{and}\ {\tt ntsink}=0.$$
 38.1841 +
 38.1842 +2. The routine generates an assignment problem if the requirements for
 38.1843 +a transportation problem are met and:
 38.1844 +$${\tt nsorc}={\tt nsink}\ \mbox{and}\ {\tt itsup}={\tt nsorc}.$$
 38.1845 +
 38.1846 +3. The routine always generates connected graphs. So, if the number of
 38.1847 +requested arcs has been reached and the generated instance is not fully
 38.1848 +connected, the routine generates a few remaining arcs to ensure
 38.1849 +connectedness. Thus, the actual number of arcs generated by the routine
 38.1850 +may be greater than the requested number of arcs.
 38.1851 +
 38.1852 +\subsubsection*{Returns}
 38.1853 +
 38.1854 +If the instance was successfully generated, the routine
 38.1855 +\verb|glp_netgen| returns zero; otherwise, if specified parameters are
 38.1856 +inconsistent, the routine returns a non-zero error code.
 38.1857 +
 38.1858 +\subsection{glp\_gridgen---grid-like network problem generator}
 38.1859 +
 38.1860 +\subsubsection*{Synopsis}
 38.1861 +
 38.1862 +\begin{verbatim}
 38.1863 +int glp_gridgen(glp_graph *G, int v_rhs, int a_cap, int a_cost,
 38.1864 +      const int parm[1+14]);
 38.1865 +\end{verbatim}
 38.1866 +
 38.1867 +\subsubsection*{Description}
 38.1868 +
 38.1869 +The routine \verb|glp_gridgen| is a GLPK version of the grid-like
 38.1870 +network problem generator developed by Yusin Lee and Jim
 38.1871 +Orlin.\footnote{Y.~Lee and J.~Orlin. GRIDGEN generator., 1991. The
 38.1872 +original code is publically available from
 38.1873 +{\tt<ftp://dimacs.rutgers.edu/pub/netflow/generators/network/gridgen>}.}
 38.1874 +
 38.1875 +The parameter \verb|G| specifies the graph object, to which the
 38.1876 +generated  problem data have to be stored. Note that on entry the graph
 38.1877 +object  is erased with the routine \verb|glp_erase_graph|.
 38.1878 +
 38.1879 +The parameter \verb|v_rhs| specifies an offset of the field of type
 38.1880 +\verb|double| in the vertex data block, to which the routine stores the
 38.1881 +supply or  demand value. If \verb|v_rhs| $<0$, the value is not stored.
 38.1882 +
 38.1883 +The parameter \verb|a_cap| specifies an offset of the field of type
 38.1884 +\verb|double| in the arc data block, to which the routine stores the
 38.1885 +arc capacity. If \verb|a_cap| $<0$, the capacity is not stored.
 38.1886 +
 38.1887 +The parameter \verb|a_cost| specifies an offset of the field of type
 38.1888 +\verb|double| in the arc data block, to which the routine stores the
 38.1889 +per-unit cost if the arc flow. If \verb|a_cost| $<0$, the cost is not
 38.1890 +stored.
 38.1891 +
 38.1892 +The array \verb|parm| contains parameters of the network to be
 38.1893 +generated:
 38.1894 +
 38.1895 +\begin{tabular}{@{}ll@{}}
 38.1896 +\verb|parm[0] |&not used\\
 38.1897 +\verb|parm[1] |&two-ways arcs indicator:\\
 38.1898 +               &1 --- if links in both direction should be generated\\
 38.1899 +               &0 --- otherwise\\
 38.1900 +\verb|parm[2] |&random number seed (a positive integer)\\
 38.1901 +\verb|parm[3] |&number of nodes (the number of nodes generated might
 38.1902 +be\\&slightly different to make the network a grid)\\
 38.1903 +\verb|parm[4] |&grid width\\
 38.1904 +\verb|parm[5] |&number of sources\\
 38.1905 +\verb|parm[6] |&number of sinks\\
 38.1906 +\verb|parm[7] |&average degree\\
 38.1907 +\verb|parm[8] |&total flow\\
 38.1908 +\verb|parm[9] |&distribution of arc costs:\\
 38.1909 +               &1 --- uniform\\
 38.1910 +               &2 --- exponential\\
 38.1911 +\verb|parm[10]|&lower bound for arc cost (uniform)\\
 38.1912 +               &$100\lambda$ (exponential)\\
 38.1913 +\verb|parm[11]|&upper bound for arc cost (uniform)\\
 38.1914 +               &not used (exponential)\\
 38.1915 +\verb|parm[12]|&distribution of arc capacities:\\
 38.1916 +               &1 --- uniform\\
 38.1917 +               &2 --- exponential\\
 38.1918 +\verb|parm[13]|&lower bound for arc capacity (uniform)\\
 38.1919 +               &$100\lambda$ (exponential)\\
 38.1920 +\verb|parm[14]|&upper bound for arc capacity (uniform)\\
 38.1921 +               &not used (exponential)\\
 38.1922 +\end{tabular}
 38.1923 +
 38.1924 +\subsubsection*{Returns}
 38.1925 +
 38.1926 +If the instance was successfully generated, the routine
 38.1927 +\verb|glp_gridgen| returns zero; otherwise, if specified parameters are
 38.1928 +inconsistent, the routine returns a non-zero error code.
 38.1929 +
 38.1930 +\subsubsection*{Comments\footnote{This material is based on comments
 38.1931 +to the original version of GRIDGEN.}}
 38.1932 +
 38.1933 +This network generator generates a grid-like network plus a super node.
 38.1934 +In additional to the arcs connecting the nodes in the grid, there is an
 38.1935 +arc from each supply node to the super node and from the super node to
 38.1936 +each demand node to guarantee feasiblity. These arcs have very high
 38.1937 +costs and very big capacities.
 38.1938 +
 38.1939 +The idea of this network generator is as follows: First, a grid of
 38.1940 +$n_1\times n_2$ is generated. For example, $5\times 3$. The nodes are
 38.1941 +numbered as 1 to 15, and the supernode is numbered as $n_1\times n_2+1$.
 38.1942 +Then arcs between adjacent nodes are generated. For these arcs, the user
 38.1943 +is allowed to specify either to generate two-way arcs or one-way arcs.
 38.1944 +If two-way arcs are to be generated, two arcs, one in each direction,
 38.1945 +will be generated between each adjacent node pairs. Otherwise, only one
 38.1946 +arc will be generated. If this is the case, the arcs will be generated
 38.1947 +in alterntive directions as shown below.
 38.1948 +
 38.1949 +\bigskip
 38.1950 +
 38.1951 +\noindent\hfil
 38.1952 +\xymatrix
 38.1953 +{1\ar[r]\ar[d]&2\ar[r]&3\ar[r]\ar[d]&4\ar[r]&5\ar[d]\\
 38.1954 +6\ar[d]&7\ar[l]\ar[u]&8\ar[l]\ar[d]&9\ar[l]\ar[u]&10\ar[l]\ar[d]\\
 38.1955 +11\ar[r]&12\ar[r]\ar[u]&13\ar[r]&14\ar[r]\ar[u]&15\\
 38.1956 +}
 38.1957 +
 38.1958 +\bigskip
 38.1959 +
 38.1960 +Then the arcs between the super node and the source/sink nodes are added
 38.1961 +as mentioned before. If the number of arcs still doesn't reach the
 38.1962 +requirement, additional arcs will be added by uniformly picking random
 38.1963 +node pairs. There is no checking to prevent multiple arcs between any
 38.1964 +pair of nodes. However, there will be no self-arcs (arcs that poins back
 38.1965 +to its tail node) in the network.
 38.1966 +
 38.1967 +The source and sink nodes are selected uniformly in the network, and
 38.1968 +the imbalances of each source/sink node are also assigned by uniform
 38.1969 +distribution.
 38.1970 +
 38.1971 +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 38.1972 +
 38.1973 +\newpage
 38.1974 +
 38.1975 +\section{Maximum flow problem}
 38.1976 +
 38.1977 +\subsection{Background}
 38.1978 +
 38.1979 +The {\it maximum flow problem} (MAXFLOW) is stated as follows. Let
 38.1980 +there be given a directed graph (flow network) $G=(V,A)$, where $V$ is
 38.1981 +a set of vertices (nodes), and $A\subseteq V\times V$ is a set of arcs.
 38.1982 +Let also for each arc $a=(i,j)\in A$ there be given its capacity
 38.1983 +$u_{ij}$. The problem is, for given {\it source} node $s\in V$ and
 38.1984 +{\it sink} node $t\in V$, to find flows $x_{ij}$ through every arc of
 38.1985 +the network, which satisfy the specified arc capacities and the
 38.1986 +conservation constraints at all nodes, and maximize the total flow $F$
 38.1987 +through the network from $s$ to $t$. Here the conservation constraint
 38.1988 +at a node means that the total flow entering this node through its
 38.1989 +incoming arcs (plus $F$, if it is the source node) must be equal to the
 38.1990 +total flow leaving this node through its outgoing arcs (plus $F$, if it
 38.1991 +is the sink node).
 38.1992 +
 38.1993 +An example of the maximum flow problem, where $s=v_1$ and $t=v_9$, is
 38.1994 +shown on Fig.~2.
 38.1995 +
 38.1996 +\bigskip
 38.1997 +
 38.1998 +\noindent\hfil
 38.1999 +\xymatrix @C=48pt
 38.2000 +{_{F}\ar@{~>}[d]&
 38.2001 +v_2\ar[r]|{_{10}}\ar[dd]|{_{9}}&
 38.2002 +v_3\ar[dd]|{_{12}}\ar[r]|{_{18}}&
 38.2003 +v_8\ar[rd]|{_{20}}&\\
 38.2004 +v_1\ar[ru]|{_{14}}\ar[rd]|{_{23}}&&&
 38.2005 +v_6\ar[d]|{_{7}}\ar[u]|{_{8}}&
 38.2006 +v_9\ar@{~>}[d]\\
 38.2007 +&v_4\ar[r]|{_{26}}&
 38.2008 +v_5\ar[luu]|{_{11}}\ar[ru]|{_{25}}\ar[r]|{_{4}}&
 38.2009 +v_7\ar[ru]|{_{15}}&_{F}\\
 38.2010 +}
 38.2011 +
 38.2012 +\bigskip
 38.2013 +
 38.2014 +\noindent\hfil
 38.2015 +Fig.~2. An example of the maximum flow problem.
 38.2016 +
 38.2017 +\bigskip
 38.2018 +
 38.2019 +The maximum flow problem can be naturally formulated as the following
 38.2020 +LP problem:
 38.2021 +
 38.2022 +\medskip
 38.2023 +
 38.2024 +\noindent
 38.2025 +\hspace{.5in}maximize
 38.2026 +$$F\eqno(4)$$
 38.2027 +\hspace{.5in}subject to
 38.2028 +$$\sum_{(i,j)\in A}x_{ij}-\sum_{(j,i)\in A}x_{ji}=\left\{
 38.2029 +\begin{array}{@{\ }rl}
 38.2030 ++F,&\hbox{for}\ i=s\\
 38.2031 + 0,&\hbox{for all}\ i\in V\backslash\{s,t\}\\
 38.2032 +-F,&\hbox{for}\ i=t\\
 38.2033 +\end{array}
 38.2034 +\right.\eqno(5)
 38.2035 +$$
 38.2036 +$$0\leq x_{ij}\leq u_{ij}\ \ \ \hbox{for all}\ (i,j)\in A
 38.2037 +\eqno(6)$$
 38.2038 +
 38.2039 +\medskip
 38.2040 +
 38.2041 +\noindent
 38.2042 +where $F\geq 0$ is an additional variable playing the role of the
 38.2043 +objective.
 38.2044 +
 38.2045 +\newpage
 38.2046 +
 38.2047 +Another LP formulation of the maximum flow problem, which does not
 38.2048 +include the variable $F$, is the following:
 38.2049 +
 38.2050 +\medskip
 38.2051 +
 38.2052 +\noindent
 38.2053 +\hspace{.5in}maximize
 38.2054 +$$z=\sum_{(s,j)\in A}x_{sj}-\sum_{(j,s)\in A}x_{js}\ (=F)\eqno(7)$$
 38.2055 +\hspace{.5in}subject to
 38.2056 +$$\sum_{(i,j)\in A}x_{ij}-\sum_{(j,i)\in A}x_{ji}\left\{
 38.2057 +\begin{array}{@{\ }rl}
 38.2058 +\geq 0,&\hbox{for}\ i=s\\
 38.2059 +=0,&\hbox{for all}\ i\in V\backslash\{s,t\}\\
 38.2060 +\leq 0,&\hbox{for}\ i=t\\
 38.2061 +\end{array}
 38.2062 +\right.\eqno(8)
 38.2063 +$$
 38.2064 +$$0\leq x_{ij}\leq u_{ij}\ \ \ \hbox{for all}\ (i,j)\in A
 38.2065 +\eqno(9)$$
 38.2066 +
 38.2067 +\subsection{glp\_read\_maxflow---read maximum flow problem data\\in
 38.2068 +DIMACS format}
 38.2069 +
 38.2070 +\subsubsection*{Synopsis}
 38.2071 +
 38.2072 +\begin{verbatim}
 38.2073 +int glp_read_maxflow(glp_graph *G, int *s, int *t, int a_cap,
 38.2074 +      const char *fname);
 38.2075 +\end{verbatim}
 38.2076 +
 38.2077 +\subsubsection*{Description}
 38.2078 +
 38.2079 +The routine \verb|glp_read_maxflow| reads the maximum flow problem
 38.2080 +data from a text file in DIMACS format.
 38.2081 +
 38.2082 +The parameter \verb|G| specifies the graph object, to which the problem
 38.2083 +data have to be stored. Note that before reading data the current
 38.2084 +content of the graph object is completely erased with the routine
 38.2085 +\verb|glp_erase_graph|.
 38.2086 +
 38.2087 +The pointer \verb|s| specifies a location, to which the routine stores
 38.2088 +the ordinal number of the source node. If \verb|s| is \verb|NULL|, the
 38.2089 +source node number is not stored.
 38.2090 +
 38.2091 +The pointer \verb|t| specifies a location, to which the routine stores
 38.2092 +the ordinal number of the sink node. If \verb|t| is \verb|NULL|, the
 38.2093 +sink node number is not stored.
 38.2094 +
 38.2095 +The parameter \verb|a_cap| specifies an offset of the field of type
 38.2096 +\verb|double| in the arc data block, to which the routine stores
 38.2097 +$u_{ij}$, the arc capacity. If \verb|a_cap| $<0$, the arc capacity is
 38.2098 +not stored.
 38.2099 +
 38.2100 +The character string \verb|fname| specifies the name of a text file to
 38.2101 +be read in. (If the file name name ends with the suffix `\verb|.gz|',
 38.2102 +the file is assumed to be compressed, in which case the routine
 38.2103 +decompresses it ``on the fly''.)
 38.2104 +
 38.2105 +\subsubsection*{Returns}
 38.2106 +
 38.2107 +If the operation was successful, the routine returns zero. Otherwise,
 38.2108 +it prints an error message and returns non-zero.
 38.2109 +
 38.2110 +\subsubsection*{Example}
 38.2111 +
 38.2112 +\begin{footnotesize}
 38.2113 +\begin{verbatim}
 38.2114 +typedef struct
 38.2115 +{     /* arc data block */
 38.2116 +      ...
 38.2117 +      double cap;
 38.2118 +      ...
 38.2119 +} a_data;
 38.2120 +
 38.2121 +int main(void)
 38.2122 +{     glp_graph *G;
 38.2123 +      int s, t, ret;
 38.2124 +      G = glp_create_graph(..., sizeof(a_data));
 38.2125 +      ret = glp_read_maxflow(G, &s, &t, offsetof(a_data, cap),
 38.2126 +         "sample.max");
 38.2127 +      if (ret != 0) goto ...
 38.2128 +      ...
 38.2129 +}
 38.2130 +\end{verbatim}
 38.2131 +\end{footnotesize}
 38.2132 +
 38.2133 +\subsubsection*{DIMACS maximum flow problem format\footnote{This
 38.2134 +material is based on the paper ``The First DIMACS International
 38.2135 +Algorithm Implementation Challenge: Problem Definitions and
 38.2136 +Specifications'', which is publically available at
 38.2137 +{\tt http://dimacs.rutgers.edu/Challenges/}.}}
 38.2138 +\label{subsecmaxflow}
 38.2139 +
 38.2140 +The DIMACS input file is a plain ASCII text file. It contains
 38.2141 +{\it lines} of several types described below. A line is terminated with
 38.2142 +an end-of-line character. Fields in each line are separated by at least
 38.2143 +one blank space. Each line begins with a one-character designator to
 38.2144 +identify the line type.
 38.2145 +
 38.2146 +Note that DIMACS requires all numerical quantities to be integers in
 38.2147 +the range $[-2^{31},\ 2^{31}-1]$ while GLPK allows the quantities to be
 38.2148 +floating-point numbers.
 38.2149 +
 38.2150 +\paragraph{Comment lines.} Comment lines give human-readable information
 38.2151 +about the file and are ignored by programs. Comment lines can appear
 38.2152 +anywhere in the file. Each comment line begins with a lower-case
 38.2153 +character \verb|c|.
 38.2154 +
 38.2155 +\begin{verbatim}
 38.2156 +   c This is a comment line
 38.2157 +\end{verbatim}
 38.2158 +
 38.2159 +\newpage
 38.2160 +
 38.2161 +\paragraph{Problem line.} There is one problem line per data file. The
 38.2162 +problem line must appear before any node or arc descriptor lines. It has
 38.2163 +the following format:
 38.2164 +
 38.2165 +\begin{verbatim}
 38.2166 +   p max NODES ARCS
 38.2167 +\end{verbatim}
 38.2168 +
 38.2169 +\noindent
 38.2170 +The lower-case character \verb|p| signifies that this is a problem line.
 38.2171 +The three-character problem designator \verb|max| identifies the file as
 38.2172 +containing specification information for the maximum flow problem. The
 38.2173 +\verb|NODES| field contains an integer value specifying the number of
 38.2174 +nodes in the network. The \verb|ARCS| field contains an integer value
 38.2175 +specifying the number of arcs in the network.
 38.2176 +
 38.2177 +\paragraph{Node descriptors.} Two node descriptor lines for the source
 38.2178 +and sink nodes must appear before all arc descriptor lines. They may
 38.2179 +appear in either order, each with the following format:
 38.2180 +
 38.2181 +\begin{verbatim}
 38.2182 +   n ID WHICH
 38.2183 +\end{verbatim}
 38.2184 +
 38.2185 +\noindent
 38.2186 +The lower-case character \verb|n| signifies that this a node descriptor
 38.2187 +line. The \verb|ID| field gives a node identification number, an integer
 38.2188 +between 1 and \verb|NODES|. The \verb|WHICH| field gives either a
 38.2189 +lower-case \verb|s| or \verb|t|, designating the source and sink,
 38.2190 +respectively.
 38.2191 +
 38.2192 +\paragraph{Arc descriptors.} There is one arc descriptor line for each
 38.2193 +arc in the network. Arc descriptor lines are of the following format:
 38.2194 +
 38.2195 +\begin{verbatim}
 38.2196 +   a SRC DST CAP
 38.2197 +\end{verbatim}
 38.2198 +
 38.2199 +\noindent
 38.2200 +The lower-case character \verb|a| signifies that this is an arc
 38.2201 +descriptor line. For a directed arc $(i,j)$ the \verb|SRC| field gives
 38.2202 +the identification number $i$ for the tail endpoint, and the \verb|DST|
 38.2203 +field gives the identification number $j$ for the head endpoint.
 38.2204 +Identification numbers are integers between 1 and \verb|NODES|. The
 38.2205 +\verb|CAP| field gives the arc capacity, i.e. maximum amount of flow
 38.2206 +that can be sent along arc $(i,j)$ in a feasible flow.
 38.2207 +
 38.2208 +\paragraph{Example.} Below here is an example of the data file in
 38.2209 +DIMACS format corresponding to the maximum flow problem shown on Fig~2.
 38.2210 +
 38.2211 +\newpage
 38.2212 +
 38.2213 +\begin{footnotesize}
 38.2214 +\begin{verbatim}
 38.2215 +c sample.max
 38.2216 +c
 38.2217 +c This is an example of the maximum flow problem data
 38.2218 +c in DIMACS format.
 38.2219 +c
 38.2220 +p max 9 14
 38.2221 +c
 38.2222 +n 1 s
 38.2223 +n 9 t
 38.2224 +c
 38.2225 +a 1 2 14
 38.2226 +a 1 4 23
 38.2227 +a 2 3 10
 38.2228 +a 2 4  9
 38.2229 +a 3 5 12
 38.2230 +a 3 8 18
 38.2231 +a 4 5 26
 38.2232 +a 5 2 11
 38.2233 +a 5 6 25
 38.2234 +a 5 7  4
 38.2235 +a 6 7  7
 38.2236 +a 6 8  8
 38.2237 +a 7 9 15
 38.2238 +a 8 9 20
 38.2239 +c
 38.2240 +c eof
 38.2241 +\end{verbatim}
 38.2242 +\end{footnotesize}
 38.2243 +
 38.2244 +\subsection{glp\_write\_maxflow---write maximum flow problem data\\
 38.2245 +in DIMACS format}
 38.2246 +
 38.2247 +\subsubsection*{Synopsis}
 38.2248 +
 38.2249 +\begin{verbatim}
 38.2250 +int glp_write_maxflow(glp_graph *G, int s, int t, int a_cap,
 38.2251 +      const char *fname);
 38.2252 +\end{verbatim}
 38.2253 +
 38.2254 +\subsubsection*{Description}
 38.2255 +
 38.2256 +The routine \verb|glp_write_maxflow| writes the maximum flow problem
 38.2257 +data to a text file in DIMACS format.
 38.2258 +
 38.2259 +The parameter \verb|G| is the graph (network) program object, which
 38.2260 +specifies the maximum flow problem instance.
 38.2261 +
 38.2262 +The parameter \verb|s| specifies the ordinal number of the source node.
 38.2263 +
 38.2264 +The parameter \verb|t| specifies the ordinal number of the sink node.
 38.2265 +
 38.2266 +The parameter \verb|a_cap| specifies an offset of the field of type
 38.2267 +\verb|double| in the arc data block, which contains $u_{ij}$, the upper
 38.2268 +bound to the arc flow (the arc capacity). If the upper bound is
 38.2269 +specified as \verb|DBL_MAX|, it is assumed that $u_{ij}=\infty$, i.e.
 38.2270 +the arc is uncapacitated. If \verb|a_cap| $<0$, it is assumed that
 38.2271 +$u_{ij}=1$ for all arcs.
 38.2272 +
 38.2273 +The character string \verb|fname| specifies a name of the text file to
 38.2274 +be written out. (If the file name ends with suffix `\verb|.gz|', the
 38.2275 +file is assumed to be compressed, in which case the routine performs
 38.2276 +automatic compression on writing it.)
 38.2277 +
 38.2278 +\subsubsection*{Returns}
 38.2279 +
 38.2280 +If the operation was successful, the routine returns zero. Otherwise,
 38.2281 +it prints an error message and returns non-zero.
 38.2282 +
 38.2283 +\subsection{glp\_maxflow\_lp---convert maximum flow problem to LP}
 38.2284 +
 38.2285 +\subsubsection*{Synopsis}
 38.2286 +
 38.2287 +\begin{verbatim}
 38.2288 +void glp_maxflow_lp(glp_prob *lp, glp_graph *G, int names,
 38.2289 +      int s, int t, int a_cap);
 38.2290 +\end{verbatim}
 38.2291 +
 38.2292 +\subsubsection*{Description}
 38.2293 +
 38.2294 +The routine \verb|glp_maxflow_lp| builds LP problem (7)---(9), which
 38.2295 +corresponds to the specified maximum flow problem.
 38.2296 +
 38.2297 +The parameter \verb|lp| is the resultant LP problem object to be built.
 38.2298 +Note that on entry its current content is erased with the routine
 38.2299 +\verb|glp_erase_prob|.
 38.2300 +
 38.2301 +The parameter \verb|G| is the graph (network) program object, which
 38.2302 +specifies the maximum flow problem instance.
 38.2303 +
 38.2304 +The parameter \verb|names| is a flag. If it is \verb|GLP_ON|, the
 38.2305 +routine uses symbolic names of the graph object components to assign
 38.2306 +symbolic names to the LP problem object components. If the flag is
 38.2307 +\verb|GLP_OFF|, no symbolic names are assigned.
 38.2308 +
 38.2309 +The parameter \verb|s| specifies the ordinal number of the source node.
 38.2310 +
 38.2311 +The parameter \verb|t| specifies the ordinal number of the sink node.
 38.2312 +
 38.2313 +The parameter \verb|a_cap| specifies an offset of the field of type
 38.2314 +\verb|double| in the arc data block, which contains $u_{ij}$, the upper
 38.2315 +bound to the arc flow (the arc capacity). If the upper bound is
 38.2316 +specified as \verb|DBL_MAX|, it is assumed that $u_{ij}=\infty$, i.e.
 38.2317 +the arc is uncapacitated. If \verb|a_cap| $<0$, it is assumed that
 38.2318 +$u_{ij}=1$ for all arcs.
 38.2319 +
 38.2320 +\subsubsection*{Example}
 38.2321 +
 38.2322 +The example program below reads the maximum flow problem in DIMACS
 38.2323 +format from file `\verb|sample.max|', converts the instance to LP, and
 38.2324 +then writes the resultant LP in CPLEX format to file
 38.2325 +`\verb|maxflow.lp|'.
 38.2326 +
 38.2327 +\begin{footnotesize}
 38.2328 +\begin{verbatim}
 38.2329 +#include <stddef.h>
 38.2330 +#include <glpk.h>
 38.2331 +
 38.2332 +int main(void)
 38.2333 +{     glp_graph *G;
 38.2334 +      glp_prob *lp;
 38.2335 +      int s, t;
 38.2336 +      G = glp_create_graph(0, sizeof(double));
 38.2337 +      glp_read_maxflow(G, &s, &t, 0, "sample.max");
 38.2338 +      lp = glp_create_prob();
 38.2339 +      glp_maxflow_lp(lp, G, GLP_ON, s, t, 0);
 38.2340 +      glp_delete_graph(G);
 38.2341 +      glp_write_lp(lp, NULL, "maxflow.lp");
 38.2342 +      glp_delete_prob(lp);
 38.2343 +      return 0;
 38.2344 +}
 38.2345 +\end{verbatim}
 38.2346 +\end{footnotesize}
 38.2347 +
 38.2348 +If `\verb|sample.max|' is the example data file from the previous
 38.2349 +subsection, the output `\verb|maxflow.lp|' may look like follows:
 38.2350 +
 38.2351 +\begin{footnotesize}
 38.2352 +\begin{verbatim}
 38.2353 +Maximize
 38.2354 + obj: + x(1,4) + x(1,2)
 38.2355 +
 38.2356 +Subject To
 38.2357 + r_1: + x(1,2) + x(1,4) >= 0
 38.2358 + r_2: - x(5,2) + x(2,3) + x(2,4) - x(1,2) = 0
 38.2359 + r_3: + x(3,5) + x(3,8) - x(2,3) = 0
 38.2360 + r_4: + x(4,5) - x(2,4) - x(1,4) = 0
 38.2361 + r_5: + x(5,2) + x(5,6) + x(5,7) - x(4,5) - x(3,5) = 0
 38.2362 + r_6: + x(6,7) + x(6,8) - x(5,6) = 0
 38.2363 + r_7: + x(7,9) - x(6,7) - x(5,7) = 0
 38.2364 + r_8: + x(8,9) - x(6,8) - x(3,8) = 0
 38.2365 + r_9: - x(8,9) - x(7,9) <= 0
 38.2366 +
 38.2367 +Bounds
 38.2368 + 0 <= x(1,4) <= 23
 38.2369 + 0 <= x(1,2) <= 14
 38.2370 + 0 <= x(2,4) <= 9
 38.2371 + 0 <= x(2,3) <= 10
 38.2372 + 0 <= x(3,8) <= 18
 38.2373 + 0 <= x(3,5) <= 12
 38.2374 + 0 <= x(4,5) <= 26
 38.2375 + 0 <= x(5,7) <= 4
 38.2376 + 0 <= x(5,6) <= 25
 38.2377 + 0 <= x(5,2) <= 11
 38.2378 + 0 <= x(6,8) <= 8
 38.2379 + 0 <= x(6,7) <= 7
 38.2380 + 0 <= x(7,9) <= 15
 38.2381 + 0 <= x(8,9) <= 20
 38.2382 +
 38.2383 +End
 38.2384 +\end{verbatim}
 38.2385 +\end{footnotesize}
 38.2386 +
 38.2387 +\subsection{glp\_maxflow\_ffalg---solve maximum flow problem with
 38.2388 +Ford-Fulkerson algorithm}
 38.2389 +
 38.2390 +\subsubsection*{Synopsis}
 38.2391 +
 38.2392 +\begin{verbatim}
 38.2393 +int glp_maxflow_ffalg(glp_graph *G, int s, int t, int a_cap,
 38.2394 +      double *sol, int a_x, int v_cut);
 38.2395 +\end{verbatim}
 38.2396 +
 38.2397 +\subsubsection*{Description}
 38.2398 +
 38.2399 +The routine \verb|glp_mincost_ffalg| finds optimal solution to the
 38.2400 +maximum flow problem with the Ford-Fulkerson algorithm.\footnote{GLPK
 38.2401 +implementation of the Ford-Fulkerson algorithm is based on the following
 38.2402 +book: L.~R.~Ford,~Jr., and D.~R.~Fulkerson, ``Flows in Networks,'' The
 38.2403 +RAND Corp., Report\linebreak R-375-PR (August 1962), Chap. I
 38.2404 +``Static Maximal Flow,'' pp.~30-33.} Note that this routine requires all
 38.2405 +the problem data to be integer-valued.
 38.2406 +
 38.2407 +The parameter \verb|G| is a graph (network) program object which
 38.2408 +specifies the maximum flow problem instance to be solved.
 38.2409 +
 38.2410 +The parameter $s$ specifies the ordinal number of the source node.
 38.2411 +
 38.2412 +The parameter $t$ specifies the ordinal number of the sink node.
 38.2413 +
 38.2414 +The parameter \verb|a_cap| specifies an offset of the field of type
 38.2415 +\verb|double| in the arc data block, which contains $u_{ij}$, the upper
 38.2416 +bound to the arc flow (the arc capacity). This bound must be integer in
 38.2417 +the range [0, \verb|INT_MAX|]. If \verb|a_cap| $<0$, it is assumed that
 38.2418 +$u_{ij}=1$ for all arcs.
 38.2419 +
 38.2420 +The parameter \verb|sol| specifies a location, to which the routine
 38.2421 +stores the objective value (that is, the total flow from $s$ to $t$)
 38.2422 +found. If \verb|sol| is NULL, the objective value is not stored.
 38.2423 +
 38.2424 +The parameter \verb|a_x| specifies an offset of the field of type
 38.2425 +\verb|double| in the arc data block, to which the routine stores
 38.2426 +$x_{ij}$, the arc flow found. If \verb|a_x| $<0$, the arc flow values
 38.2427 +are not stored.
 38.2428 +
 38.2429 +The parameter \verb|v_cut| specifies an offset of the field of type
 38.2430 +\verb|int| in the vertex data block, to which the routine stores node
 38.2431 +flags corresponding to the optimal solution found: if the node flag is
 38.2432 +1, the node is labelled, and if the node flag is 0, the node is
 38.2433 +unlabelled. The calling program may use these node flags to determine
 38.2434 +the {\it minimal cut}, which is a subset of arcs whose one endpoint is
 38.2435 +labelled and other is not. If \verb|v_cut| $<0$, the node flags are not
 38.2436 +stored.
 38.2437 +
 38.2438 +Note that all solution components (the objective value and arc flows)
 38.2439 +computed by the routine are always integer-valued.
 38.2440 +
 38.2441 +\subsubsection*{Returns}
 38.2442 +
 38.2443 +\def\arraystretch{1}
 38.2444 +
 38.2445 +\begin{tabular}{@{}p{25mm}p{97.3mm}@{}}
 38.2446 +0 & Optimal solution found.\\
 38.2447 +\verb|GLP_EDATA| & Unable to start the search, because some problem
 38.2448 +data are either not integer-valued or out of range.\\
 38.2449 +\end{tabular}
 38.2450 +
 38.2451 +\subsubsection*{Example}
 38.2452 +
 38.2453 +The example program shown below reads the maximum flow problem instance
 38.2454 +in DIMACS format from file `\verb|sample.max|', solves it using the
 38.2455 +routine \verb|glp_maxflow_ffalg|, and write the solution found to the
 38.2456 +standard output.
 38.2457 +
 38.2458 +\begin{footnotesize}
 38.2459 +\begin{verbatim}
 38.2460 +#include <stddef.h>
 38.2461 +#include <stdio.h>
 38.2462 +#include <stdlib.h>
 38.2463 +#include <glpk.h>
 38.2464 +
 38.2465 +typedef struct { int cut; } v_data;
 38.2466 +typedef struct { double cap, x; } a_data;
 38.2467 +
 38.2468 +#define node(v) ((v_data *)((v)->data))
 38.2469 +#define arc(a)  ((a_data *)((a)->data))
 38.2470 +
 38.2471 +int main(void)
 38.2472 +{     glp_graph *G;
 38.2473 +      glp_vertex *v, *w;
 38.2474 +      glp_arc *a;
 38.2475 +      int i, s, t, ret;
 38.2476 +      double sol;
 38.2477 +      G = glp_create_graph(sizeof(v_data), sizeof(a_data));
 38.2478 +      glp_read_maxflow(G, &s, &t, offsetof(a_data, cap),
 38.2479 +         "sample.max");
 38.2480 +      ret = glp_maxflow_ffalg(G, s, t, offsetof(a_data, cap),
 38.2481 +         &sol, offsetof(a_data, x), offsetof(v_data, cut));
 38.2482 +      printf("ret = %d; sol = %5g\n", ret, sol);
 38.2483 +      for (i = 1; i <= G->nv; i++)
 38.2484 +      {  v = G->v[i];
 38.2485 +         for (a = v->out; a != NULL; a = a->t_next)
 38.2486 +         {  w = a->head;
 38.2487 +            printf("x[%d->%d] = %5g (%d)\n", v->i, w->i,
 38.2488 +               arc(a)->x, node(v)->cut ^ node(w)->cut);
 38.2489 +         }
 38.2490 +      }
 38.2491 +      glp_delete_graph(G);
 38.2492 +      return 0;
 38.2493 +}
 38.2494 +\end{verbatim}
 38.2495 +\end{footnotesize}
 38.2496 +
 38.2497 +If `\verb|sample.max|' is the example data file from the subsection
 38.2498 +describing the routine \verb|glp_read_maxflow|, the output may look like
 38.2499 +follows:
 38.2500 +
 38.2501 +\begin{footnotesize}
 38.2502 +\begin{verbatim}
 38.2503 +Reading maximum flow problem data from `sample.max'...
 38.2504 +Flow network has 9 nodes and 14 arcs
 38.2505 +24 lines were read
 38.2506 +ret = 0; sol =    29
 38.2507 +x[1->4] =    19 (0)
 38.2508 +x[1->2] =    10 (0)
 38.2509 +x[2->4] =     0 (0)
 38.2510 +x[2->3] =    10 (1)
 38.2511 +x[3->8] =    10 (0)
 38.2512 +x[3->5] =     0 (1)
 38.2513 +x[4->5] =    19 (0)
 38.2514 +x[5->7] =     4 (1)
 38.2515 +x[5->6] =    15 (0)
 38.2516 +x[5->2] =     0 (0)
 38.2517 +x[6->8] =     8 (1)
 38.2518 +x[6->7] =     7 (1)
 38.2519 +x[7->9] =    11 (0)
 38.2520 +x[8->9] =    18 (0)
 38.2521 +\end{verbatim}
 38.2522 +\end{footnotesize}
 38.2523 +
 38.2524 +\newpage
 38.2525 +
 38.2526 +\subsection{glp\_rmfgen---Goldfarb's maximum flow problem generator}
 38.2527 +
 38.2528 +\subsubsection*{Synopsis}
 38.2529 +
 38.2530 +\begin{verbatim}
 38.2531 +int glp_rmfgen(glp_graph *G, int *s, int *t, int a_cap,
 38.2532 +      const int parm[1+5]);
 38.2533 +\end{verbatim}
 38.2534 +
 38.2535 +\subsubsection*{Description}
 38.2536 +
 38.2537 +The routine \verb|glp_rmfgen| is a GLPK version of the maximum flow
 38.2538 +problem generator developed by D.~Goldfarb and
 38.2539 +M.~Grigoriadis.\footnote{D.~Goldfarb and M.~D.~Grigoriadis,
 38.2540 +``A computational comparison of the Dinic and network simplex methods
 38.2541 +for maximum flow.'' Annals of Op. Res. 13 (1988),
 38.2542 +pp.~83-123.}$^{,}$\footnote{U.~Derigs and W.~Meier, ``Implementing
 38.2543 +Goldberg's max-flow algorithm: A computational investigation.''
 38.2544 +Zeitschrift f\"ur Operations Research 33 (1989),
 38.2545 +pp.~383-403.}$^{,}$\footnote{The original code of RMFGEN implemented by
 38.2546 +Tamas Badics is publically available from
 38.2547 +{\tt <ftp://dimacs.rutgers.edu/pub/netflow/generators/network/genrmf>}.}
 38.2548 +
 38.2549 +The parameter \verb|G| specifies the graph object, to which the
 38.2550 +generated problem data have to be stored. Note that on entry the graph
 38.2551 +object is erased with the routine \verb|glp_erase_graph|.
 38.2552 +
 38.2553 +The pointers \verb|s| and \verb|t| specify locations, to which the
 38.2554 +routine stores the source and sink node numbers, respectively. If
 38.2555 +\verb|s| or \verb|t| is \verb|NULL|, corresponding node number is not
 38.2556 +stored.
 38.2557 +
 38.2558 +The parameter \verb|a_cap| specifies an offset of the field of type
 38.2559 +\verb|double| in the arc data block, to which the routine stores the arc
 38.2560 +capacity. If \verb|a_cap| $<0$, the capacity is not stored.
 38.2561 +
 38.2562 +The array \verb|parm| contains description of the network to be
 38.2563 +generated:
 38.2564 +
 38.2565 +\begin{tabular}{@{}lll@{}}
 38.2566 +\verb|parm[0]|&           &not used\\
 38.2567 +\verb|parm[1]|&\verb|seed|&random number seed (a positive integer)\\
 38.2568 +\verb|parm[2]|&\verb|a   |&frame size\\
 38.2569 +\verb|parm[3]|&\verb|b   |&depth\\
 38.2570 +\verb|parm[4]|&\verb|c1  |&minimal arc capacity\\
 38.2571 +\verb|parm[5]|&\verb|c2  |&maximal arc capacity\\
 38.2572 +\end{tabular}
 38.2573 +
 38.2574 +\subsubsection*{Returns}
 38.2575 +
 38.2576 +If the instance was successfully generated, the routine
 38.2577 +\verb|glp_netgen| returns zero; otherwise, if specified parameters are
 38.2578 +inconsistent, the routine returns a non-zero error code.
 38.2579 +
 38.2580 +\newpage
 38.2581 +
 38.2582 +\subsubsection*{Comments\footnote{This material is based on comments
 38.2583 +to the original version of RMFGEN.}}
 38.2584 +
 38.2585 +The generated network is as follows. It has $b$ pieces of frames of
 38.2586 +size $a\times a$. (So alltogether the number of vertices is
 38.2587 +$a\times a\times b$.)
 38.2588 +
 38.2589 +In each frame all the vertices are connected with their neighbours
 38.2590 +(forth and back). In addition the vertices of a frame are connected
 38.2591 +one to one with the vertices of next frame using a random permutation
 38.2592 +of those vertices.
 38.2593 +
 38.2594 +The source is the lower left vertex of the first frame, the sink is
 38.2595 +the upper right vertex of the $b$-th frame.
 38.2596 +
 38.2597 +\begin{verbatim}
 38.2598 +                              t
 38.2599 +                     +-------+
 38.2600 +                     |      .|
 38.2601 +                     |     . |
 38.2602 +                  /  |    /  |
 38.2603 +                 +-------+/ -+ b
 38.2604 +                 |    |  |/.
 38.2605 +               a |   -v- |/
 38.2606 +                 |    |  |/
 38.2607 +                 +-------+ 1
 38.2608 +                s    a
 38.2609 +\end{verbatim}
 38.2610 +
 38.2611 +The capacities are randomly chosen integers from the range of
 38.2612 +$[c_1,c_2]$  in the case of interconnecting edges, and $c_2\cdot a^2$
 38.2613 +for the in-frame edges.
 38.2614 +
 38.2615 +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 38.2616 +
 38.2617 +\newpage
 38.2618 +
 38.2619 +\section{Assignment problem}
 38.2620 +
 38.2621 +\subsection{Background}
 38.2622 +
 38.2623 +Let there be given an undirected bipartite graph $G=(R\cup S,E)$, where
 38.2624 +$R$ and $S$ are disjoint sets of vertices (nodes), and
 38.2625 +$E\subseteq R\times S$ is a set of edges. Let also for each edge
 38.2626 +$e=(i,j)\in E$ there be given its cost $c_{ij}$. A {\it matching}
 38.2627 +(which in case of bipartite graph is also called {\it assignment})
 38.2628 +$M\subseteq E$ in $G$ is a set of pairwise non-adjacent edges, that is,
 38.2629 +no two edges in $M$ share a common vertex. A matching, which matches
 38.2630 +all vertices of the graph, is called a {\it perfect matching}.
 38.2631 +Obviously, a perfect matching in bipartite graph $G=(R\cup S,E)$
 38.2632 +defines some bijection $R\leftrightarrow S$.
 38.2633 +
 38.2634 +The {\it assignment problem} has two different variants. In the first
 38.2635 +variant the problem is to find matching (assignment) $M$, which
 38.2636 +maximizes the sum:
 38.2637 +$$\sum_{(i,j)\in M}c_{ij}\eqno(10)$$
 38.2638 +(so this variant is also called the {\it maximum weighted bipartite
 38.2639 +matching problem} or, if all $c_{ij}=1$, the {\it maximum cardinality
 38.2640 +bipartite matching problem}). In the second, classic variant the
 38.2641 +problem is to find {\it perfect} matching (assignment) $M$, which
 38.2642 +minimizes or maximizes the sum (10).
 38.2643 +
 38.2644 +An example of the assignment problem, which is the maximum weighted
 38.2645 +bipartite matching problem, is shown on Fig. 3.
 38.2646 +
 38.2647 +The maximum weighted bipartite matching problem can be naturally
 38.2648 +formulated as the following LP problem:
 38.2649 +
 38.2650 +\medskip
 38.2651 +
 38.2652 +\noindent
 38.2653 +\hspace{.5in}maximize
 38.2654 +$$z=\sum_{(i,j)\in E}c_{ij}x_{ij}\eqno(11)$$
 38.2655 +\hspace{.5in}subject to
 38.2656 +$$\sum_{(i,j)\in E}x_{ij}\leq 1\ \ \ \hbox{for all}\ i\in R\eqno(12)$$
 38.2657 +$$\sum_{(i,j)\in E}x_{ij}\leq 1\ \ \ \hbox{for all}\ j\in S\eqno(13)$$
 38.2658 +$$\ \ \ \ \ \ \ \ 0\leq x_{ij}\leq 1\ \ \ \hbox{for all}\ (i,j)\in E
 38.2659 +\eqno(14)$$
 38.2660 +
 38.2661 +\medskip
 38.2662 +
 38.2663 +\noindent
 38.2664 +where $x_{ij}=1$ means that $(i,j)\in M$, and $x_{ij}=0$ means that
 38.2665 +$(i,j)\notin M$.\footnote{The constraint matrix of LP formulation
 38.2666 +(11)---(14) is totally unimodular, due to which $x_{ij}\in\{0,1\}$ for
 38.2667 +any basic solution.}
 38.2668 +
 38.2669 +\newpage
 38.2670 +
 38.2671 +\bigskip
 38.2672 +
 38.2673 +\noindent\hfil
 38.2674 +\xymatrix @C=48pt
 38.2675 +{v_1\ar@{-}[rr]|{_{13}}\ar@{-}[rrd]|{_{21}}\ar@{-}[rrddd]|(.2){_{20}}&&
 38.2676 +v_9\\
 38.2677 +v_2\ar@{-}[rr]|{_{12}}\ar@{-}[rrdd]|(.3){_{8}}
 38.2678 +\ar@{-}[rrddd]|(.4){_{26}}&&v_{10}\\
 38.2679 +v_3\ar@{-}[rr]|(.2){_{22}}\ar@{-}[rrdd]|(.3){_{11}}&&v_{11}\\
 38.2680 +v_4\ar@{-}[rruuu]|(.6){_{12}}\ar@{-}[rr]|(.2){_{36}}
 38.2681 +\ar@{-}[rrdd]|(.7){_{25}}&&v_{12}\\
 38.2682 +v_5\ar@{-}[rruu]|(.42){_{41}}\ar@{-}[rru]|(.4){_{40}}
 38.2683 +\ar@{-}[rr]|(.75){_{11}}\ar@{-}[rrd]|(.6){_{4}}\ar@{-}[rrdd]|{_{8}}
 38.2684 +\ar@{-}[rrddd]|{_{35}}\ar@{-}[rrdddd]|{_{32}}&&v_{13}\\
 38.2685 +v_6\ar@{-}[rruuuuu]|(.7){_{13}}&&v_{14}\\
 38.2686 +v_7\ar@{-}[rruuuuu]|(.15){_{19}}&&v_{15}\\
 38.2687 +v_8\ar@{-}[rruuuuuu]|(.25){_{39}}\ar@{-}[rruuuuu]|(.65){_{15}}&&
 38.2688 +v_{16}\\
 38.2689 +&&v_{17}\\
 38.2690 +}
 38.2691 +
 38.2692 +\bigskip
 38.2693 +
 38.2694 +\noindent\hfil
 38.2695 +Fig.~3. An example of the assignment problem.
 38.2696 +
 38.2697 +\bigskip
 38.2698 +
 38.2699 +Similarly, the perfect assignment problem can be naturally formulated
 38.2700 +as the following LP problem:
 38.2701 +
 38.2702 +\medskip
 38.2703 +
 38.2704 +\noindent
 38.2705 +\hspace{.5in}minimize (or maximize)
 38.2706 +$$z=\sum_{(i,j)\in E}c_{ij}x_{ij}\eqno(15)$$
 38.2707 +\hspace{.5in}subject to
 38.2708 +$$\sum_{(i,j)\in E}x_{ij}=1\ \ \ \hbox{for all}\ i\in R\eqno(16)$$
 38.2709 +$$\sum_{(i,j)\in E}x_{ij}=1\ \ \ \hbox{for all}\ j\in S\eqno(17)$$
 38.2710 +$$\ \ \ \ \ \ \ \ 0\leq x_{ij}\leq 1\ \ \ \hbox{for all}\ (i,j)\in E
 38.2711 +\eqno(18)$$
 38.2712 +
 38.2713 +\medskip
 38.2714 +
 38.2715 +\noindent
 38.2716 +where variables $x_{ij}$ have the same meaning as for (11)---(14)
 38.2717 +above.
 38.2718 +
 38.2719 +\newpage
 38.2720 +
 38.2721 +In GLPK an undirected bipartite graph $G=(R\cup S,E)$ is represented as
 38.2722 +directed graph $\overline{G}=(V,A)$, where $V=R\cup S$ and
 38.2723 +$A=\{(i,j):(i,j)\in E\}$, i.e. every edge $(i,j)\in E$ in $G$
 38.2724 +corresponds to arc $(i\rightarrow j)\in A$ in $\overline{G}$.
 38.2725 +
 38.2726 +\subsection{glp\_read\_asnprob---read assignment problem data in\\DIMACS
 38.2727 +format}
 38.2728 +
 38.2729 +\subsubsection*{Synopsis}
 38.2730 +
 38.2731 +\begin{verbatim}
 38.2732 +int glp_read_asnprob(glp_graph *G, int v_set, int a_cost,
 38.2733 +      const char *fname);
 38.2734 +\end{verbatim}
 38.2735 +
 38.2736 +\subsubsection*{Description}
 38.2737 +
 38.2738 +The routine \verb|glp_read_asnprob| reads the assignment problem data
 38.2739 +from a text file in DIMACS format.
 38.2740 +
 38.2741 +The parameter \verb|G| specifies the graph object, to which the problem
 38.2742 +data have to be stored. Note that before reading data the current
 38.2743 +content of the graph object is completely erased with the routine
 38.2744 +\verb|glp_erase_graph|.
 38.2745 +
 38.2746 +The parameter \verb|v_set| specifies an offset of the field of type
 38.2747 +\verb|int| in the vertex data block, to which the routine stores the
 38.2748 +node set indicator:
 38.2749 +
 38.2750 +0 --- the node is in set $R$;
 38.2751 +
 38.2752 +1 --- the node is in set $S$.
 38.2753 +
 38.2754 +\noindent
 38.2755 +If \verb|v_set| $<0$, the node set indicator is not stored.
 38.2756 +
 38.2757 +The parameter \verb|a_cost| specifies an offset of the field of type
 38.2758 +\verb|double| in the arc data block, to which the routine stores the
 38.2759 +edge cost $c_{ij}$. If \verb|a_cost| $<0$, the edge cost is not stored.
 38.2760 +
 38.2761 +The character string \verb|fname| specifies the name of a text file to
 38.2762 +be read in. (If the file name name ends with the suffix `\verb|.gz|',
 38.2763 +the file is assumed to be compressed, in which case the routine
 38.2764 +decompresses it ``on the fly''.)
 38.2765 +
 38.2766 +\subsubsection*{Returns}
 38.2767 +
 38.2768 +If the operation was successful, the routine returns zero. Otherwise,
 38.2769 +it prints an error message and returns non-zero.
 38.2770 +
 38.2771 +\newpage
 38.2772 +
 38.2773 +\subsubsection*{Example}
 38.2774 +
 38.2775 +\begin{footnotesize}
 38.2776 +\begin{verbatim}
 38.2777 +typedef struct
 38.2778 +{     /* vertex data block */
 38.2779 +      ...
 38.2780 +      int set;
 38.2781 +      ...
 38.2782 +} v_data;
 38.2783 +
 38.2784 +typedef struct
 38.2785 +{     /* arc data block */
 38.2786 +      ...
 38.2787 +      double cost;
 38.2788 +      ...
 38.2789 +} a_data;
 38.2790 +
 38.2791 +int main(void)
 38.2792 +{     glp_graph *G;
 38.2793 +      int ret;
 38.2794 +      G = glp_create_graph(sizeof(v_data), sizeof(a_data));
 38.2795 +      ret = glp_read_asnprob(G, offsetof(v_data, set),
 38.2796 +         offsetof(a_data, cost), "sample.asn");
 38.2797 +      if (ret != 0) goto ...
 38.2798 +      ...
 38.2799 +}
 38.2800 +\end{verbatim}
 38.2801 +\end{footnotesize}
 38.2802 +
 38.2803 +\subsubsection*{DIMACS assignment problem format\footnote{This
 38.2804 +material is based on the paper ``The First DIMACS International
 38.2805 +Algorithm Implementation Challenge: Problem Definitions and
 38.2806 +Specifications'', which is publically available at
 38.2807 +{\tt http://dimacs.rutgers.edu/Challenges/}.}}
 38.2808 +\label{subsecasnprob}
 38.2809 +
 38.2810 +The DIMACS input file is a plain ASCII text file. It contains
 38.2811 +{\it lines} of several types described below. A line is terminated with
 38.2812 +an end-of-line character. Fields in each line are separated by at least
 38.2813 +one blank space. Each line begins with a one-character designator to
 38.2814 +identify the line type.
 38.2815 +
 38.2816 +Note that DIMACS requires all numerical quantities to be integers in
 38.2817 +the range $[-2^{31},\ 2^{31}-1]$ while GLPK allows the quantities to be
 38.2818 +floating-point numbers.
 38.2819 +
 38.2820 +\paragraph{Comment lines.} Comment lines give human-readable information
 38.2821 +about the file and are ignored by programs. Comment lines can appear
 38.2822 +anywhere in the file. Each comment line begins with a lower-case
 38.2823 +character \verb|c|.
 38.2824 +
 38.2825 +\begin{verbatim}
 38.2826 +   c This is a comment line
 38.2827 +\end{verbatim}
 38.2828 +
 38.2829 +\newpage
 38.2830 +
 38.2831 +\paragraph{Problem line.} There is one problem line per data file. The
 38.2832 +problem line must appear before any node or arc descriptor lines. It has
 38.2833 +the following format:
 38.2834 +
 38.2835 +\begin{verbatim}
 38.2836 +   p asn NODES EDGES
 38.2837 +\end{verbatim}
 38.2838 +
 38.2839 +\noindent
 38.2840 +The lower-case character \verb|p| signifies that this is a problem line.
 38.2841 +The three-character problem designator \verb|asn| identifies the file as
 38.2842 +containing specification information for the assignment problem.
 38.2843 +The \verb|NODES| field contains an integer value specifying the total
 38.2844 +number of nodes in the graph (i.e. in both sets $R$ and $S$). The
 38.2845 +\verb|EDGES| field contains an integer value specifying the number of
 38.2846 +edges in the graph.
 38.2847 +
 38.2848 +\paragraph{Node descriptors.} All node descriptor lines must appear
 38.2849 +before all edge descriptor lines. The node descriptor lines lists the
 38.2850 +nodes in set $R$ only, and all other nodes are assumed to be in set
 38.2851 +$S$. There is one node descriptor line for each such node, with the
 38.2852 +following format:
 38.2853 +
 38.2854 +\begin{verbatim}
 38.2855 +   n ID
 38.2856 +\end{verbatim}
 38.2857 +
 38.2858 +\noindent
 38.2859 +The lower-case character \verb|n| signifies that this is a node
 38.2860 +descriptor line. The \verb|ID| field gives a node identification number,
 38.2861 +an integer between 1 and \verb|NODES|.
 38.2862 +
 38.2863 +\paragraph{Edge descriptors.} There is one edge descriptor line for
 38.2864 +each edge in the graph. Edge descriptor lines are of the following
 38.2865 +format:
 38.2866 +
 38.2867 +\begin{verbatim}
 38.2868 +   a SRC DST COST
 38.2869 +\end{verbatim}
 38.2870 +
 38.2871 +\noindent
 38.2872 +The lower-case character \verb|a| signifies that this is an edge
 38.2873 +descriptor line. For each edge $(i,j)$, where $i\in R$ and $j\in S$,
 38.2874 +the \verb|SRC| field gives the identification number of vertex $i$, and
 38.2875 +the \verb|DST| field gives the identification number of vertex $j$.
 38.2876 +Identification numbers are integers between 1 and \verb|NODES|. The
 38.2877 +\verb|COST| field contains the cost of edge $(i,j)$.
 38.2878 +
 38.2879 +\paragraph{Example.} Below here is an example of the data file in
 38.2880 +DIMACS format corresponding to the assignment problem shown on Fig~3.
 38.2881 +
 38.2882 +\newpage
 38.2883 +
 38.2884 +\begin{footnotesize}
 38.2885 +\begin{verbatim}
 38.2886 +c sample.asn
 38.2887 +c
 38.2888 +c This is an example of the assignment problem data
 38.2889 +c in DIMACS format.
 38.2890 +c
 38.2891 +p asn 17 22
 38.2892 +c
 38.2893 +n 1
 38.2894 +n 2
 38.2895 +n 3
 38.2896 +n 4
 38.2897 +n 5
 38.2898 +n 6
 38.2899 +n 7
 38.2900 +n 8
 38.2901 +c
 38.2902 +a 1  9 13
 38.2903 +a 1 10 21
 38.2904 +a 1 12 20
 38.2905 +a 2 10 12
 38.2906 +a 2 12  8
 38.2907 +a 2 13 26
 38.2908 +a 3 11 22
 38.2909 +a 3 13 11
 38.2910 +a 4  9 12
 38.2911 +a 4 12 36
 38.2912 +a 4 14 25
 38.2913 +a 5 11 41
 38.2914 +a 5 12 40
 38.2915 +a 5 13 11
 38.2916 +a 5 14  4
 38.2917 +a 5 15  8
 38.2918 +a 5 16 35
 38.2919 +a 5 17 32
 38.2920 +a 6  9 13
 38.2921 +a 7 10 19
 38.2922 +a 8 10 39
 38.2923 +a 8 11 15
 38.2924 +c
 38.2925 +c eof
 38.2926 +\end{verbatim}
 38.2927 +\end{footnotesize}
 38.2928 +
 38.2929 +\newpage
 38.2930 +
 38.2931 +\subsection{glp\_write\_asnprob---write assignment problem data in\\
 38.2932 +DIMACS format}
 38.2933 +
 38.2934 +\subsubsection*{Synopsis}
 38.2935 +
 38.2936 +\begin{verbatim}
 38.2937 +int glp_write_asnprob(glp_graph *G, int v_set, int a_cost,
 38.2938 +      const char *fname);
 38.2939 +\end{verbatim}
 38.2940 +
 38.2941 +\subsubsection*{Description}
 38.2942 +
 38.2943 +The routine \verb|glp_write_asnprob| writes the assignment problem data
 38.2944 +to a text file in DIMACS format.
 38.2945 +
 38.2946 +The parameter \verb|G| is the graph program object, which specifies the
 38.2947 +assignment problem instance.
 38.2948 +
 38.2949 +The parameter \verb|v_set| specifies an offset of the field of type
 38.2950 +\verb|int| in the vertex data block, which contains the node set
 38.2951 +indicator:
 38.2952 +
 38.2953 +0 --- the node is in set $R$;
 38.2954 +
 38.2955 +1 --- the node is in set $S$.
 38.2956 +
 38.2957 +\noindent
 38.2958 +If \verb|v_set| $<0$, it is assumed that a node having no incoming arcs
 38.2959 +is in set $R$, and a node having no outgoing arcs is in set $S$.
 38.2960 +
 38.2961 +The parameter \verb|a_cost| specifies an offset of the field of type
 38.2962 +\verb|double| in the arc data block, which contains $c_{ij}$, the edge
 38.2963 +cost. If \verb|a_cost| $<0$, it is assumed that $c_{ij}=1$ for all
 38.2964 +edges.
 38.2965 +
 38.2966 +The character string \verb|fname| specifies a name of the text file to
 38.2967 +be written out. (If the file name ends with suffix `\verb|.gz|', the
 38.2968 +file is assumed to be compressed, in which case the routine performs
 38.2969 +automatic compression on writing it.)
 38.2970 +
 38.2971 +\subsubsection*{Note}
 38.2972 +
 38.2973 +The routine \verb|glp_write_asnprob| does not check that the specified
 38.2974 +graph object correctly represents a bipartite graph. To make sure that
 38.2975 +the problem data are correct, use the routine \verb|glp_check_asnprob|.
 38.2976 +
 38.2977 +\subsubsection*{Returns}
 38.2978 +
 38.2979 +If the operation was successful, the routine returns zero. Otherwise,
 38.2980 +it prints an error message and returns non-zero.
 38.2981 +
 38.2982 +\newpage
 38.2983 +
 38.2984 +\subsection{glp\_check\_asnprob---check correctness of assignment
 38.2985 +problem data}
 38.2986 +
 38.2987 +\subsubsection*{Synopsis}
 38.2988 +
 38.2989 +\begin{verbatim}
 38.2990 +int glp_check_asnprob(glp_graph *G, int v_set);
 38.2991 +\end{verbatim}
 38.2992 +
 38.2993 +\subsubsection*{Description}
 38.2994 +
 38.2995 +The routine \verb|glp_check_asnprob| checks that the specified graph
 38.2996 +object \verb|G| correctly represents a bipartite graph.
 38.2997 +
 38.2998 +The parameter \verb|v_set| specifies an offset of the field of type
 38.2999 +\verb|int| in the vertex data block, which contains the node set
 38.3000 +indicator:
 38.3001 +
 38.3002 +0 --- the node is in set $R$;
 38.3003 +
 38.3004 +1 --- the node is in set $S$.
 38.3005 +
 38.3006 +\noindent
 38.3007 +If \verb|v_set| $<0$, it is assumed that a node having no incoming arcs
 38.3008 +is in set $R$, and a node having no outgoing arcs is in set $S$.
 38.3009 +
 38.3010 +\subsubsection*{Returns}
 38.3011 +
 38.3012 +The routine \verb|glp_check_asnprob| may return the following codes:
 38.3013 +
 38.3014 +0 --- the data are correct;
 38.3015 +
 38.3016 +1 --- the set indicator of some node is 0, however, that node has one
 38.3017 +or more incoming arcs;
 38.3018 +
 38.3019 +2 --- the set indicator of some node is 1, however, that node has one
 38.3020 +or more outgoing arcs;
 38.3021 +
 38.3022 +3 --- the set indicator of some node is invalid (neither 0 nor 1);
 38.3023 +
 38.3024 +4 --- some node has both incoming and outgoing arcs.
 38.3025 +
 38.3026 +\subsection{glp\_asnprob\_lp---convert assignment problem to LP}
 38.3027 +
 38.3028 +\subsubsection*{Synopsis}
 38.3029 +
 38.3030 +\begin{verbatim}
 38.3031 +int glp_asnprob_lp(glp_prob *P, int form, glp_graph *G,
 38.3032 +      int names, int v_set, int a_cost);
 38.3033 +\end{verbatim}
 38.3034 +
 38.3035 +\subsubsection*{Description}
 38.3036 +
 38.3037 +The routine \verb|glp_asnprob_lp| builds LP problem, which corresponds
 38.3038 +to the specified assignment problem.
 38.3039 +
 38.3040 +The parameter \verb|lp| is the resultant LP problem object to be built.
 38.3041 +Note that on entry its current content is erased with the routine
 38.3042 +\verb|glp_erase_prob|.
 38.3043 +
 38.3044 +The parameter \verb|form| defines which LP formulation should be used:
 38.3045 +
 38.3046 +\verb|GLP_ASN_MIN| --- perfect matching (15)---(18), minimization;
 38.3047 +
 38.3048 +\verb|GLP_ASN_MAX| --- perfect matching (15)---(18), maximization;
 38.3049 +
 38.3050 +\verb|GLP_ASN_MMP| --- maximum weighted matching (11)---(14).
 38.3051 +
 38.3052 +The parameter \verb|G| is the graph program object, which specifies the
 38.3053 +assignment problem instance.
 38.3054 +
 38.3055 +The parameter \verb|names| is a flag. If it is \verb|GLP_ON|, the
 38.3056 +routine uses symbolic names of the graph object components to assign
 38.3057 +symbolic names to the LP problem object components. If the \verb|flag|
 38.3058 +is \verb|GLP_OFF|, no symbolic names are assigned.
 38.3059 +
 38.3060 +The parameter \verb|v_set| specifies an offset of the field of type
 38.3061 +\verb|int| in the vertex data block, which contains the node set
 38.3062 +indicator:
 38.3063 +
 38.3064 +0 --- the node is in set $R$;
 38.3065 +
 38.3066 +1 --- the node is in set $S$.
 38.3067 +
 38.3068 +\noindent
 38.3069 +If \verb|v_set| $<0$, it is assumed that a node having no incoming arcs
 38.3070 +is in set $R$, and a node having no outgoing arcs is in set $S$.
 38.3071 +
 38.3072 +The parameter \verb|a_cost| specifies an offset of the field of type
 38.3073 +\verb|double| in the arc data block, which contains $c_{ij}$, the edge
 38.3074 +cost. If \verb|a_cost| $<0$, it is assumed that $c_{ij}=1$ for all
 38.3075 +edges.
 38.3076 +
 38.3077 +\subsubsection*{Returns}
 38.3078 +
 38.3079 +If the LP problem has been successfully built, the routine
 38.3080 +\verb|glp_asnprob_lp| returns zero, otherwise, non-zero (see the
 38.3081 +routine \verb|glp_check_asnprob|).
 38.3082 +
 38.3083 +\subsubsection*{Example}
 38.3084 +
 38.3085 +The example program below reads the assignment problem instance in
 38.3086 +DIMACS format from file `\verb|sample.asn|', converts the instance to
 38.3087 +LP (11)---(14), and writes the resultant LP in CPLEX format to file
 38.3088 +`\verb|matching.lp|'.
 38.3089 +
 38.3090 +\begin{footnotesize}
 38.3091 +\begin{verbatim}
 38.3092 +#include <stddef.h>
 38.3093 +#include <glpk.h>
 38.3094 +
 38.3095 +typedef struct { int set; } v_data;
 38.3096 +typedef struct { double cost; } a_data;
 38.3097 +
 38.3098 +int main(void)
 38.3099 +{     glp_graph *G;
 38.3100 +      glp_prob *P;
 38.3101 +      G = glp_create_graph(sizeof(v_data), sizeof(a_data));
 38.3102 +      glp_read_asnprob(G, offsetof(v_data, set),
 38.3103 +         offsetof(a_data, cost), "sample.asn");
 38.3104 +      P = glp_create_prob();
 38.3105 +      glp_asnprob_lp(P, GLP_ASN_MMP, G, GLP_ON,
 38.3106 +         offsetof(v_data, set), offsetof(a_data, cost));
 38.3107 +      glp_delete_graph(G);
 38.3108 +      glp_write_lp(P, NULL, "matching.lp");
 38.3109 +      glp_delete_prob(P);
 38.3110 +      return 0;
 38.3111 +}
 38.3112 +\end{verbatim}
 38.3113 +\end{footnotesize}
 38.3114 +
 38.3115 +If `\verb|sample.asn|' is the example data file from the subsection
 38.3116 +describing the routine \verb|glp_read_asnprob|, file
 38.3117 +`\verb|matching.lp|' may look like follows:
 38.3118 +
 38.3119 +\begin{footnotesize}
 38.3120 +\begin{verbatim}
 38.3121 +Maximize
 38.3122 + obj: + 20 x(1,12) + 21 x(1,10) + 13 x(1,9) + 26 x(2,13) + 8 x(2,12)
 38.3123 + + 12 x(2,10) + 11 x(3,13) + 22 x(3,11) + 25 x(4,14) + 36 x(4,12)
 38.3124 + + 12 x(4,9) + 32 x(5,17) + 35 x(5,16) + 8 x(5,15) + 4 x(5,14)
 38.3125 + + 11 x(5,13) + 40 x(5,12) + 41 x(5,11) + 13 x(6,9) + 19 x(7,10)
 38.3126 + + 15 x(8,11) + 39 x(8,10)
 38.3127 +
 38.3128 +Subject To
 38.3129 + r_1: + x(1,9) + x(1,10) + x(1,12) <= 1
 38.3130 + r_2: + x(2,10) + x(2,12) + x(2,13) <= 1
 38.3131 + r_3: + x(3,11) + x(3,13) <= 1
 38.3132 + r_4: + x(4,9) + x(4,12) + x(4,14) <= 1
 38.3133 + r_5: + x(5,11) + x(5,12) + x(5,13) + x(5,14) + x(5,15) + x(5,16)
 38.3134 + + x(5,17) <= 1
 38.3135 + r_6: + x(6,9) <= 1
 38.3136 + r_7: + x(7,10) <= 1
 38.3137 + r_8: + x(8,10) + x(8,11) <= 1
 38.3138 + r_9: + x(6,9) + x(4,9) + x(1,9) <= 1
 38.3139 + r_10: + x(8,10) + x(7,10) + x(2,10) + x(1,10) <= 1
 38.3140 + r_11: + x(8,11) + x(5,11) + x(3,11) <= 1
 38.3141 + r_12: + x(5,12) + x(4,12) + x(2,12) + x(1,12) <= 1
 38.3142 + r_13: + x(5,13) + x(3,13) + x(2,13) <= 1
 38.3143 + r_14: + x(5,14) + x(4,14) <= 1
 38.3144 + r_15: + x(5,15) <= 1
 38.3145 + r_16: + x(5,16) <= 1
 38.3146 + r_17: + x(5,17) <= 1
 38.3147 +
 38.3148 +Bounds
 38.3149 + 0 <= x(1,12) <= 1
 38.3150 + 0 <= x(1,10) <= 1
 38.3151 + 0 <= x(1,9) <= 1
 38.3152 + 0 <= x(2,13) <= 1
 38.3153 + 0 <= x(2,12) <= 1
 38.3154 + 0 <= x(2,10) <= 1
 38.3155 + 0 <= x(3,13) <= 1
 38.3156 + 0 <= x(3,11) <= 1
 38.3157 + 0 <= x(4,14) <= 1
 38.3158 + 0 <= x(4,12) <= 1
 38.3159 + 0 <= x(4,9) <= 1
 38.3160 + 0 <= x(5,17) <= 1
 38.3161 + 0 <= x(5,16) <= 1
 38.3162 + 0 <= x(5,15) <= 1
 38.3163 + 0 <= x(5,14) <= 1
 38.3164 + 0 <= x(5,13) <= 1
 38.3165 + 0 <= x(5,12) <= 1
 38.3166 + 0 <= x(5,11) <= 1
 38.3167 + 0 <= x(6,9) <= 1
 38.3168 + 0 <= x(7,10) <= 1
 38.3169 + 0 <= x(8,11) <= 1
 38.3170 + 0 <= x(8,10) <= 1
 38.3171 +
 38.3172 +End
 38.3173 +\end{verbatim}
 38.3174 +\end{footnotesize}
 38.3175 +
 38.3176 +\subsection{glp\_asnprob\_okalg---solve assignment problem with
 38.3177 +out-of-kilter algorithm}
 38.3178 +
 38.3179 +\subsubsection*{Synopsis}
 38.3180 +
 38.3181 +\begin{verbatim}
 38.3182 +int glp_asnprob_okalg(int form, glp_graph *G, int v_set,
 38.3183 +      int a_cost, double *sol, int a_x);
 38.3184 +\end{verbatim}
 38.3185 +
 38.3186 +\subsubsection*{Description}
 38.3187 +
 38.3188 +The routine \verb|glp_mincost_okalg| finds optimal solution to the
 38.3189 +assignment problem with the out-of-kilter
 38.3190 +algorithm.\footnote{GLPK implementation of the out-of-kilter algorithm
 38.3191 +is based on the following book: L.~R.~Ford,~Jr., and D.~R.~Fulkerson,
 38.3192 +``Flows in Networks,'' The RAND Corp., Report R-375-PR (August 1962),
 38.3193 +Chap. III ``Minimal Cost Flow Problems,'' pp.~113-26.} Note that this
 38.3194 +routine requires all the problem data to be integer-valued.
 38.3195 +
 38.3196 +The parameter \verb|form| defines which LP formulation should be used:
 38.3197 +
 38.3198 +\verb|GLP_ASN_MIN| --- perfect matching (15)---(18), minimization;
 38.3199 +
 38.3200 +\verb|GLP_ASN_MAX| --- perfect matching (15)---(18), maximization;
 38.3201 +
 38.3202 +\verb|GLP_ASN_MMP| --- maximum weighted matching (11)---(14).
 38.3203 +
 38.3204 +The parameter \verb|G| is the graph program object, which specifies the
 38.3205 +assignment problem instance.
 38.3206 +
 38.3207 +The parameter \verb|v_set| specifies an offset of the field of type
 38.3208 +\verb|int| in the vertex data block, which contains the node set
 38.3209 +indicator:
 38.3210 +
 38.3211 +0 --- the node is in set $R$;
 38.3212 +
 38.3213 +1 --- the node is in set $S$.
 38.3214 +
 38.3215 +\newpage
 38.3216 +
 38.3217 +\noindent
 38.3218 +If \verb|v_set| $<0$, it is assumed that a node having no incoming arcs
 38.3219 +is in set $R$, and a node having no outgoing arcs is in set $S$.
 38.3220 +
 38.3221 +The parameter \verb|a_cost| specifies an offset of the field of type
 38.3222 +\verb|double| in the arc data block, which contains $c_{ij}$, the edge
 38.3223 +cost. This value must be integer in the range [\verb|-INT_MAX|,
 38.3224 +\verb|+INT_MAX|]. If \verb|a_cost| $<0$, it is assumed that $c_{ij}=1$
 38.3225 +for all edges.
 38.3226 +
 38.3227 +The parameter \verb|sol| specifies a location, to which the routine
 38.3228 +stores the objective value (that is, the total cost) found.
 38.3229 +If \verb|sol| is \verb|NULL|, the objective value is not stored.
 38.3230 +
 38.3231 +The parameter \verb|a_x| specifies an offset of the field of type
 38.3232 +\verb|int| in the arc data block, to which the routine stores $x_{ij}$.
 38.3233 +If \verb|a_x| $<0$, this value is not stored.
 38.3234 +
 38.3235 +\subsubsection*{Returns}
 38.3236 +
 38.3237 +\def\arraystretch{1}
 38.3238 +
 38.3239 +\begin{tabular}{@{}p{25mm}p{97.3mm}@{}}
 38.3240 +0 & Optimal solution found.\\
 38.3241 +\verb|GLP_ENOPFS| & No (primal) feasible solution exists.\\
 38.3242 +\verb|GLP_EDATA| & Unable to start the search, because the assignment
 38.3243 +problem data are either incorrect (this error is detected by the
 38.3244 +routine \verb|glp_check_asnprob|), not integer-valued or out of range.\\
 38.3245 +\verb|GLP_ERANGE| & The search was prematurely terminated because of
 38.3246 +integer overflow.\\
 38.3247 +\verb|GLP_EFAIL| & An error has been detected in the program logic.
 38.3248 +(If this code is returned for your problem instance, please report to
 38.3249 +\verb|<bug-glpk@gnu.org>|.)\\
 38.3250 +\end{tabular}
 38.3251 +
 38.3252 +\subsubsection*{Comments}
 38.3253 +
 38.3254 +Since the out-of-kilter algorithm is designed to find a minimal cost
 38.3255 +circulation, the routine \verb|glp_asnprob_okalg| converts the original
 38.3256 +graph to a network suitable for this algorithm in the following
 38.3257 +way:\footnote{The conversion is performed internally and does not change
 38.3258 +the original graph program object passed to the routine.}
 38.3259 +
 38.3260 +1) it replaces each edge $(i,j)$ by arc $(i\rightarrow j)$,
 38.3261 +flow $x_{ij}$ through which has zero lower bound ($l_{ij}=0$), unity
 38.3262 +upper bound ($u_{ij}=1$), and per-unit cost $+c_{ij}$ (in case of
 38.3263 +\verb|GLP_ASN_MIN|), or $-c_{ij}$ (in case of \verb|GLP_ASN_MAX| and
 38.3264 +\verb|GLP_ASN_MMP|);
 38.3265 +
 38.3266 +2) then it adds one auxiliary feedback node $k$;
 38.3267 +
 38.3268 +\newpage
 38.3269 +
 38.3270 +3) for each original node $i\in R$ the routine adds auxiliary supply
 38.3271 +arc $(k\rightarrow i)$, flow $x_{ki}$ through which is costless
 38.3272 +($c_{ki}=0$) and either fixed at 1 ($l_{ki}=u_{ki}=1$, in case of
 38.3273 +\verb|GLP_ASN_MIN| and \verb|GLP_ASN_MAX|) or has zero lower bound and
 38.3274 +unity upper bound ($l_{ij}=0$, $u_{ij}=1$, in case of
 38.3275 +\verb|GLP_ASN_MMP|);
 38.3276 +
 38.3277 +4) similarly, for each original node $j\in S$ the routine adds
 38.3278 +auxiliary demand arc $(j\rightarrow k)$, flow $x_{jk}$ through which is
 38.3279 +costless ($c_{jk}=0$) and either fixed at 1 ($l_{jk}=u_{jk}=1$, in case
 38.3280 +of \verb|GLP_ASN_MIN| and \verb|GLP_ASN_MAX|) or has zero lower bound
 38.3281 +and unity upper bound ($l_{jk}=0$, $u_{jk}=1$, in case of
 38.3282 +\verb|GLP_ASN_MMP|).
 38.3283 +
 38.3284 +\subsubsection*{Example}
 38.3285 +
 38.3286 +The example program shown below reads the assignment problem instance
 38.3287 +in DIMACS format from file `\verb|sample.asn|', solves it by using the
 38.3288 +routine \verb|glp_asnprob_okalg|, and writes the solution found to the
 38.3289 +standard output.
 38.3290 +
 38.3291 +\begin{footnotesize}
 38.3292 +\begin{verbatim}
 38.3293 +#include <stddef.h>
 38.3294 +#include <stdio.h>
 38.3295 +#include <stdlib.h>
 38.3296 +#include <glpk.h>
 38.3297 +
 38.3298 +typedef struct { int set; } v_data;
 38.3299 +typedef struct { double cost; int x; } e_data;
 38.3300 +
 38.3301 +#define node(v) ((v_data *)((v)->data))
 38.3302 +#define edge(e) ((e_data *)((e)->data))
 38.3303 +
 38.3304 +int main(void)
 38.3305 +{     glp_graph *G;
 38.3306 +      glp_vertex *v;
 38.3307 +      glp_arc *e;
 38.3308 +      int i, ret;
 38.3309 +      double sol;
 38.3310 +      G = glp_create_graph(sizeof(v_data), sizeof(e_data));
 38.3311 +      glp_read_asnprob(G, offsetof(v_data, set),
 38.3312 +         offsetof(e_data, cost), "sample.asn");
 38.3313 +      ret = glp_asnprob_okalg(GLP_ASN_MMP, G,
 38.3314 +         offsetof(v_data, set), offsetof(e_data, cost), &sol,
 38.3315 +         offsetof(e_data, x));
 38.3316 +      printf("ret = %d; sol = %5g\n", ret, sol);
 38.3317 +      for (i = 1; i <= G->nv; i++)
 38.3318 +      {  v = G->v[i];
 38.3319 +         for (e = v->out; e != NULL; e = e->t_next)
 38.3320 +            printf("edge %2d %2d: x = %d; c = %g\n",
 38.3321 +               e->tail->i, e->head->i, edge(e)->x, edge(e)->cost);
 38.3322 +      }
 38.3323 +      glp_delete_graph(G);
 38.3324 +      return 0;
 38.3325 +}
 38.3326 +\end{verbatim}
 38.3327 +\end{footnotesize}
 38.3328 +
 38.3329 +If `\verb|sample.asn|' is the example data file from the subsection
 38.3330 +describing the routine \verb|glp_read_asnprob|, the output may look
 38.3331 +like follows:
 38.3332 +
 38.3333 +\begin{footnotesize}
 38.3334 +\begin{verbatim}
 38.3335 +Reading assignment problem data from `sample.asn'...
 38.3336 +Assignment problem has 8 + 9 = 17 nodes and 22 arcs
 38.3337 +38 lines were read
 38.3338 +ret = 0; sol =   180
 38.3339 +edge  1 12: x = 1; c = 20
 38.3340 +edge  1 10: x = 0; c = 21
 38.3341 +edge  1  9: x = 0; c = 13
 38.3342 +edge  2 13: x = 1; c = 26
 38.3343 +edge  2 12: x = 0; c = 8
 38.3344 +edge  2 10: x = 0; c = 12
 38.3345 +edge  3 13: x = 0; c = 11
 38.3346 +edge  3 11: x = 1; c = 22
 38.3347 +edge  4 14: x = 1; c = 25
 38.3348 +edge  4 12: x = 0; c = 36
 38.3349 +edge  4  9: x = 0; c = 12
 38.3350 +edge  5 17: x = 0; c = 32
 38.3351 +edge  5 16: x = 1; c = 35
 38.3352 +edge  5 15: x = 0; c = 8
 38.3353 +edge  5 14: x = 0; c = 4
 38.3354 +edge  5 13: x = 0; c = 11
 38.3355 +edge  5 12: x = 0; c = 40
 38.3356 +edge  5 11: x = 0; c = 41
 38.3357 +edge  6  9: x = 1; c = 13
 38.3358 +edge  7 10: x = 0; c = 19
 38.3359 +edge  8 11: x = 0; c = 15
 38.3360 +edge  8 10: x = 1; c = 39
 38.3361 +\end{verbatim}
 38.3362 +\end{footnotesize}
 38.3363 +
 38.3364 +\newpage
 38.3365 +
 38.3366 +\subsection{glp\_asnprob\_hall---find bipartite matching of maximum
 38.3367 +cardinality}
 38.3368 +
 38.3369 +\subsubsection*{Synopsis}
 38.3370 +
 38.3371 +\begin{verbatim}
 38.3372 +int glp_asnprob_hall(glp_graph *G, int v_set, int a_x);
 38.3373 +\end{verbatim}
 38.3374 +
 38.3375 +\subsubsection*{Description}
 38.3376 +
 38.3377 +The routine \verb|glp_asnprob_hall| finds a matching of maximal
 38.3378 +cardinality in the specified bipartite graph. It uses a version of the
 38.3379 +Fortran routine \verb|MC21A| developed by
 38.3380 +I.~S.~Duff\footnote{I.~S.~Duff, Algorithm 575: Permutations for
 38.3381 +zero-free diagonal, ACM Trans. on Math. Softw. 7 (1981), pp.~387-390.},
 38.3382 +which implements Hall's algorithm.\footnote{M.~Hall, ``An Algorithm for
 38.3383 +Distinct Representatives,'' Am. Math. Monthly 63 (1956), pp.~716-717.}
 38.3384 +
 38.3385 +The parameter \verb|G| is a pointer to the graph program object.
 38.3386 +
 38.3387 +The parameter \verb|v_set| specifies an offset of the field of type
 38.3388 +\verb|int| in the vertex data block, which contains the node set
 38.3389 +indicator:
 38.3390 +
 38.3391 +0 --- the node is in set $R$;
 38.3392 +
 38.3393 +1 --- the node is in set $S$.
 38.3394 +
 38.3395 +\noindent
 38.3396 +If \verb|v_set| $<0$, it is assumed that a node having no incoming arcs
 38.3397 +is in set $R$, and a node having no outgoing arcs is in set $S$.
 38.3398 +
 38.3399 +The parameter \verb|a_x| specifies an offset of the field of type
 38.3400 +\verb|int| in the arc data block, to which the routine stores $x_{ij}$.
 38.3401 +If \verb|a_x| $<0$, this value is not stored.
 38.3402 +
 38.3403 +\subsubsection*{Returns}
 38.3404 +
 38.3405 +The routine \verb|glp_asnprob_hall| returns the cardinality of the
 38.3406 +matching found. However, if the specified graph is incorrect (as
 38.3407 +detected by the routine \verb|glp_check_asnprob|), this routine returns
 38.3408 +a negative value.
 38.3409 +
 38.3410 +\subsubsection*{Comments}
 38.3411 +
 38.3412 +The same solution may be obtained with the routine
 38.3413 +\verb|glp_asnprob_okalg| (for LP formulation \verb|GLP_ASN_MMP| and
 38.3414 +all edge costs equal to 1). However, the routine \verb|glp_asnprob_hall|
 38.3415 +is much faster.
 38.3416 +
 38.3417 +\newpage
 38.3418 +
 38.3419 +\subsubsection*{Example}
 38.3420 +
 38.3421 +The example program shown below reads the assignment problem instance
 38.3422 +in DIMACS format from file `\verb|sample.asn|', finds a bipartite
 38.3423 +matching of maximal cardinality by using the routine
 38.3424 +\verb|glp_asnprob_hall|, and writes the solution found to the standard
 38.3425 +output.
 38.3426 +
 38.3427 +\begin{footnotesize}
 38.3428 +\begin{verbatim}
 38.3429 +#include <stddef.h>
 38.3430 +#include <stdio.h>
 38.3431 +#include <stdlib.h>
 38.3432 +#include <glpk.h>
 38.3433 +
 38.3434 +typedef struct { int set; } v_data;
 38.3435 +typedef struct { int x;   } e_data;
 38.3436 +
 38.3437 +#define node(v) ((v_data *)((v)->data))
 38.3438 +#define edge(e) ((e_data *)((e)->data))
 38.3439 +
 38.3440 +int main(void)
 38.3441 +{     glp_graph *G;
 38.3442 +      glp_vertex *v;
 38.3443 +      glp_arc *e;
 38.3444 +      int i, card;
 38.3445 +      G = glp_create_graph(sizeof(v_data), sizeof(e_data));
 38.3446 +      glp_read_asnprob(G, offsetof(v_data, set), -1,
 38.3447 +         "sample.asn");
 38.3448 +      card = glp_asnprob_hall(G, offsetof(v_data, set),
 38.3449 +         offsetof(e_data, x));
 38.3450 +      printf("card = %d\n", card);
 38.3451 +      for (i = 1; i <= G->nv; i++)
 38.3452 +      {  v = G->v[i];
 38.3453 +         for (e = v->out; e != NULL; e = e->t_next)
 38.3454 +            printf("edge %2d %2d: x = %d\n",
 38.3455 +               e->tail->i, e->head->i, edge(e)->x);
 38.3456 +      }
 38.3457 +      glp_delete_graph(G);
 38.3458 +      return 0;
 38.3459 +}
 38.3460 +\end{verbatim}
 38.3461 +\end{footnotesize}
 38.3462 +
 38.3463 +If `\verb|sample.asn|' is the example data file from the subsection
 38.3464 +describing the routine \verb|glp_read_asnprob|, the output may look
 38.3465 +like follows:
 38.3466 +
 38.3467 +\begin{footnotesize}
 38.3468 +\begin{verbatim}
 38.3469 +Reading assignment problem data from `sample.asn'...
 38.3470 +Assignment problem has 8 + 9 = 17 nodes and 22 arcs
 38.3471 +38 lines were read
 38.3472 +card = 7
 38.3473 +edge  1 12: x = 1
 38.3474 +edge  1 10: x = 0
 38.3475 +edge  1  9: x = 0
 38.3476 +edge  2 13: x = 1
 38.3477 +edge  2 12: x = 0
 38.3478 +edge  2 10: x = 0
 38.3479 +edge  3 13: x = 0
 38.3480 +edge  3 11: x = 1
 38.3481 +edge  4 14: x = 1
 38.3482 +edge  4 12: x = 0
 38.3483 +edge  4  9: x = 0
 38.3484 +edge  5 17: x = 1
 38.3485 +edge  5 16: x = 0
 38.3486 +edge  5 15: x = 0
 38.3487 +edge  5 14: x = 0
 38.3488 +edge  5 13: x = 0
 38.3489 +edge  5 12: x = 0
 38.3490 +edge  5 11: x = 0
 38.3491 +edge  6  9: x = 1
 38.3492 +edge  7 10: x = 1
 38.3493 +edge  8 11: x = 0
 38.3494 +edge  8 10: x = 0
 38.3495 +\end{verbatim}
 38.3496 +\end{footnotesize}
 38.3497 +
 38.3498 +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 38.3499 +
 38.3500 +\newpage
 38.3501 +
 38.3502 +\section{Critical path problem}
 38.3503 +
 38.3504 +\subsection{Background}
 38.3505 +
 38.3506 +The {\it critical path problem} (CPP) is stated as follows. Let there
 38.3507 +be given a project $J$, which a set of jobs (tasks, activities, etc.).
 38.3508 +Performing each job $i\in J$ requires time $t_i\geq 0$. Besides, over
 38.3509 +the set $J$ there is given a precedence relation $R\subseteq J\times J$,
 38.3510 +where $(i,j)\in R$ means that job $i$ immediately precedes job $j$, i.e.
 38.3511 +performing job $j$ cannot start until job $i$ has been completely
 38.3512 +performed. The problem is to find starting times $x_i$ for each job
 38.3513 +$i\in J$, which satisfy to the precedence relation and minimize the
 38.3514 +total duration (makespan) of the project.
 38.3515 +
 38.3516 +The following is an example of the critical path problem:
 38.3517 +
 38.3518 +\begin{center}
 38.3519 +\begin{tabular}{|c|l|c|c|}
 38.3520 +\hline
 38.3521 +Job&Desription&Time&Predecessors\\
 38.3522 +\hline
 38.3523 +A&Excavate&3&---\\
 38.3524 +B&Lay foundation&4&A\\
 38.3525 +C&Rough plumbing&3&B\\
 38.3526 +D&Frame&10&B\\
 38.3527 +E&Finish exterior&8&D\\
 38.3528 +F&Install HVAC&4&D\\
 38.3529 +G&Rough electric&6&D\\
 38.3530 +H&Sheet rock&8&C, E, F, G\\
 38.3531 +I&Install cabinets&5&H\\
 38.3532 +J&Paint&5&H\\
 38.3533 +K&Final plumbing&4&I\\
 38.3534 +L&Final electric&2&J\\
 38.3535 +M&Install flooring&4&K, L\\
 38.3536 +\hline
 38.3537 +\end{tabular}
 38.3538 +\end{center}
 38.3539 +
 38.3540 +Obviously, the project along with the precedence relation can be
 38.3541 +represented as a directed graph $G=(J,R)$ called {\it project network},
 38.3542 +where each node $i\in J$ corresponds to a job, and arc
 38.3543 +$(i\rightarrow j)\in R$ means that job $i$ immediately precedes job
 38.3544 +$j$.\footnote{There exists another network representation of the
 38.3545 +critical path problem, where jobs correspond to arcs while nodes
 38.3546 +correspond to events introduced to express the precedence relation.
 38.3547 +That representation, however, is much less convenient than the one,
 38.3548 +where jobs are represented as nodes of the network.} The project network
 38.3549 +for the example above is shown on Fig.~4.
 38.3550 +
 38.3551 +May note that the project network must be acyclic; otherwise, it would
 38.3552 +be impossible to satisfy to the precedence relation for any job that
 38.3553 +belongs to a cycle.
 38.3554 +
 38.3555 +\newpage
 38.3556 +
 38.3557 +\xymatrix
 38.3558 +{&&&C|3\ar[rd]&&I|5\ar[r]&K|4\ar[rd]&\\
 38.3559 +A|3\ar[r]&B|4\ar[rru]\ar[rd]&&E|8\ar[r]&H|8\ar[ru]\ar[rd]&&&M|4\\
 38.3560 +&&D|10\ar[ru]\ar[r]\ar[rd]&F|4\ar[ru]&&J|5\ar[r]&L|2\ar[ru]&\\
 38.3561 +&&&G|6\ar[ruu]&&&&\\
 38.3562 +}
 38.3563 +
 38.3564 +\bigskip
 38.3565 +
 38.3566 +\noindent\hfil
 38.3567 +Fig.~4. An example of the project network.
 38.3568 +
 38.3569 +\bigskip
 38.3570 +
 38.3571 +The critical path problem can be naturally formulated as the following
 38.3572 +LP problem:
 38.3573 +
 38.3574 +\medskip
 38.3575 +
 38.3576 +\noindent
 38.3577 +\hspace{.5in}minimize
 38.3578 +$$z\eqno(19)$$
 38.3579 +\hspace{.5in}subject to
 38.3580 +$$x_i+t_i\leq z\ \ \ \hbox{for all}\ i\in J\ \ \ \ \eqno(20)$$
 38.3581 +$$x_i+t_i\leq x_j\ \ \ \hbox{for all}\ (i,j)\in R\eqno(21)$$
 38.3582 +$$x_i\geq 0\ \ \ \ \ \ \ \hbox{for all}\ i\in J\ \ \eqno(22)$$
 38.3583 +
 38.3584 +The inequality constraints (21), which are active in the optimal
 38.3585 +solution, define so called {\it critical path} having the following
 38.3586 +property: the minimal project duration $z$ can be decreased only by
 38.3587 +decreasing the times $t_j$ for jobs on the critical path, and delaying
 38.3588 +any critical job delays the entire project.
 38.3589 +
 38.3590 +\subsection{glp\_cpp---solve critical path problem}
 38.3591 +
 38.3592 +\subsubsection{Synopsis}
 38.3593 +
 38.3594 +\begin{verbatim}
 38.3595 +double glp_cpp(glp_graph *G, int v_t, int v_es, int v_ls);
 38.3596 +\end{verbatim}
 38.3597 +
 38.3598 +\subsubsection{Description}
 38.3599 +
 38.3600 +The routine \verb|glp_cpp| solves the critical path problem represented
 38.3601 +in the form of the project network.
 38.3602 +
 38.3603 +The parameter \verb|G| is a pointer to the graph object, which
 38.3604 +specifies the project network. This graph must be acyclic. Multiple
 38.3605 +arcs are allowed being considered as single arcs.
 38.3606 +
 38.3607 +The parameter \verb|v_t| specifies an offset of the field of type
 38.3608 +\verb|double| in the vertex data block, which contains time $t_i\geq 0$
 38.3609 +needed to perform corresponding job $j\in J$. If \verb|v_t| $<0$, it is
 38.3610 +assumed that $t_i=1$ for all jobs.
 38.3611 +
 38.3612 +The parameter \verb|v_es| specifies an offset of the field of type
 38.3613 +\verb|double| in the vertex data block, to which the routine stores
 38.3614 +the {\it earliest start time} for corresponding job. If \verb|v_es|
 38.3615 +$<0$, this time is not stored.
 38.3616 +
 38.3617 +The parameter \verb|v_ls| specifies an offset of the field of type
 38.3618 +\verb|double| in the vertex data block, to which the routine stores
 38.3619 +the {\it latest start time} for corresponding job. If \verb|v_ls|
 38.3620 +$<0$, this time is not stored.
 38.3621 +
 38.3622 +The difference between the latest and earliest start times of some job
 38.3623 +is called its {\it time reserve}. Delaying a job within its time reserve
 38.3624 +does not affect the project duration, so if the time reserve is zero,
 38.3625 +the corresponding job is critical.
 38.3626 +
 38.3627 +\subsubsection{Returns}
 38.3628 +
 38.3629 +The routine \verb|glp_cpp| returns the minimal project duration, i.e.
 38.3630 +minimal time needed to perform all jobs in the project.
 38.3631 +
 38.3632 +\subsubsection{Example}
 38.3633 +
 38.3634 +The example program below solves the critical path problem shown on
 38.3635 +Fig.~4 by using the routine \verb|glp_cpp| and writes the solution found
 38.3636 +to the standard output.
 38.3637 +
 38.3638 +\begin{footnotesize}
 38.3639 +\begin{verbatim}
 38.3640 +#include <stddef.h>
 38.3641 +#include <stdio.h>
 38.3642 +#include <stdlib.h>
 38.3643 +#include <glpk.h>
 38.3644 +
 38.3645 +typedef struct { double t, es, ls; } v_data;
 38.3646 +
 38.3647 +#define node(v) ((v_data *)((v)->data))
 38.3648 +
 38.3649 +int main(void)
 38.3650 +{     glp_graph *G;
 38.3651 +      int i;
 38.3652 +      double t, es, ef, ls, lf, total;
 38.3653 +      G = glp_create_graph(sizeof(v_data), 0);
 38.3654 +      glp_add_vertices(G, 13);
 38.3655 +      node(G->v[1])->t = 3;   /* A: Excavate */
 38.3656 +      node(G->v[2])->t = 4;   /* B: Lay foundation */
 38.3657 +      node(G->v[3])->t = 3;   /* C: Rough plumbing */
 38.3658 +      node(G->v[4])->t = 10;  /* D: Frame */
 38.3659 +      node(G->v[5])->t = 8;   /* E: Finish exterior */
 38.3660 +      node(G->v[6])->t = 4;   /* F: Install HVAC */
 38.3661 +      node(G->v[7])->t = 6;   /* G: Rough elecrtic */
 38.3662 +      node(G->v[8])->t = 8;   /* H: Sheet rock */
 38.3663 +      node(G->v[9])->t = 5;   /* I: Install cabinets */
 38.3664 +      node(G->v[10])->t = 5;  /* J: Paint */
 38.3665 +      node(G->v[11])->t = 4;  /* K: Final plumbing */
 38.3666 +      node(G->v[12])->t = 2;  /* L: Final electric */
 38.3667 +      node(G->v[13])->t = 4;  /* M: Install flooring */
 38.3668 +      glp_add_arc(G, 1, 2);   /* A precedes B */
 38.3669 +      glp_add_arc(G, 2, 3);   /* B precedes C */
 38.3670 +      glp_add_arc(G, 2, 4);   /* B precedes D */
 38.3671 +      glp_add_arc(G, 4, 5);   /* D precedes E */
 38.3672 +      glp_add_arc(G, 4, 6);   /* D precedes F */
 38.3673 +      glp_add_arc(G, 4, 7);   /* D precedes G */
 38.3674 +      glp_add_arc(G, 3, 8);   /* C precedes H */
 38.3675 +      glp_add_arc(G, 5, 8);   /* E precedes H */
 38.3676 +      glp_add_arc(G, 6, 8);   /* F precedes H */
 38.3677 +      glp_add_arc(G, 7, 8);   /* G precedes H */
 38.3678 +      glp_add_arc(G, 8, 9);   /* H precedes I */
 38.3679 +      glp_add_arc(G, 8, 10);  /* H precedes J */
 38.3680 +      glp_add_arc(G, 9, 11);  /* I precedes K */
 38.3681 +      glp_add_arc(G, 10, 12); /* J precedes L */
 38.3682 +      glp_add_arc(G, 11, 13); /* K precedes M */
 38.3683 +      glp_add_arc(G, 12, 13); /* L precedes M */
 38.3684 +      total = glp_cpp(G, offsetof(v_data, t), offsetof(v_data, es),
 38.3685 +         offsetof(v_data, ls));
 38.3686 +      printf("Minimal project duration is %.2f\n\n", total);
 38.3687 +      printf("Job  Time      ES     EF     LS     LF\n");
 38.3688 +      printf("--- ------   ------ ------ ------ ------\n");
 38.3689 +      for (i = 1; i <= G->nv; i++)
 38.3690 +      {  t = node(G->v[i])->t;
 38.3691 +         es = node(G->v[i])->es;
 38.3692 +         ef = es + node(G->v[i])->t;
 38.3693 +         ls = node(G->v[i])->ls;
 38.3694 +         lf = ls + node(G->v[i])->t;
 38.3695 +         printf("%3d %6.2f %s %6.2f %6.2f %6.2f %6.2f\n",
 38.3696 +            i, t, ls - es < 0.001 ? "*" : " ", es, ef, ls, lf);
 38.3697 +      }
 38.3698 +      glp_delete_graph(G);
 38.3699 +      return 0;
 38.3700 +}
 38.3701 +\end{verbatim}
 38.3702 +\end{footnotesize}
 38.3703 +
 38.3704 +The output from the example program shown below includes job number,
 38.3705 +the time needed to perform a job, earliest start time (\verb|ES|),
 38.3706 +earliest finish time (\verb|EF|), latest start time (\verb|LS|), and
 38.3707 +latest finish time (\verb|LF|) for each job in the project. Critical
 38.3708 +jobs are marked by asterisks.
 38.3709 +
 38.3710 +\newpage
 38.3711 +
 38.3712 +\begin{footnotesize}
 38.3713 +\begin{verbatim}
 38.3714 +Minimal project duration is 46.00
 38.3715 +
 38.3716 +Job  Time      ES     EF     LS     LF
 38.3717 +--- ------   ------ ------ ------ ------
 38.3718 +  1   3.00 *   0.00   3.00   0.00   3.00
 38.3719 +  2   4.00 *   3.00   7.00   3.00   7.00
 38.3720 +  3   3.00     7.00  10.00  22.00  25.00
 38.3721 +  4  10.00 *   7.00  17.00   7.00  17.00
 38.3722 +  5   8.00 *  17.00  25.00  17.00  25.00
 38.3723 +  6   4.00    17.00  21.00  21.00  25.00
 38.3724 +  7   6.00    17.00  23.00  19.00  25.00
 38.3725 +  8   8.00 *  25.00  33.00  25.00  33.00
 38.3726 +  9   5.00 *  33.00  38.00  33.00  38.00
 38.3727 + 10   5.00    33.00  38.00  35.00  40.00
 38.3728 + 11   4.00 *  38.00  42.00  38.00  42.00
 38.3729 + 12   2.00    38.00  40.00  40.00  42.00
 38.3730 + 13   4.00 *  42.00  46.00  42.00  46.00
 38.3731 +\end{verbatim}
 38.3732 +\end{footnotesize}
 38.3733 +
 38.3734 +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 38.3735 +
 38.3736 +\chapter{Graph Optimization API Routines}
 38.3737 +
 38.3738 +\section{Maximum clique problem}
 38.3739 +
 38.3740 +\subsection{Background}
 38.3741 +
 38.3742 +The {\it maximum clique problem (MCP)} is a classic combinatorial
 38.3743 +optimization problem. Given an undirected graph $G=(V,E)$, where $V$ is
 38.3744 +a set of vertices, and $E$ is a set of edges, this problem is to find
 38.3745 +the largest {\it clique} $C\subseteq G$, i.e. the largest induced
 38.3746 +complete subgraph. A generalization of this problem is the {\it maximum
 38.3747 +weight clique problem (MWCP)}, which is to find a clique $C\subseteq G$
 38.3748 +of the largest weight $\displaystyle\sum_{v\in C}w(v)\rightarrow\max$,
 38.3749 +where $w(v)$ is a weight of vertex $v\in V$.
 38.3750 +
 38.3751 +An example of the maximum weight clique problem is shown on Fig.~5.
 38.3752 +
 38.3753 +\begin{figure}
 38.3754 +\noindent\hfil
 38.3755 +\begin{tabular}{c}
 38.3756 +{\xymatrix %@C=16pt
 38.3757 +{&&&{v_1}\ar@{-}[lllddd]\ar@{-}[llddddd]\ar@{-}[dddddd]
 38.3758 +\ar@{-}[rrrddd]&&&\\
 38.3759 +&{v_2}\ar@{-}[rrrr]\ar@{-}[rrrrdddd]\ar@{-}[rrddddd]\ar@{-}[dddd]&&&&
 38.3760 +{v_3}\ar@{-}[llllldd]\ar@{-}[lllldddd]\ar@{-}[dddd]&\\
 38.3761 +&&&&&&\\
 38.3762 +{v_4}\ar@{-}[rrrrrr]\ar@{-}[rrrddd]&&&&&&{v_5}\ar@{-}[lllddd]
 38.3763 +\ar@{-}[ldd]\\
 38.3764 +&&&&&&\\
 38.3765 +&{v_6}\ar@{-}[rrrr]&&&&{v_7}&\\
 38.3766 +&&&{v_8}&&&\\
 38.3767 +}}
 38.3768 +\end{tabular}
 38.3769 +\begin{tabular}{r@{\ }c@{\ }l}
 38.3770 +$w(v_1)$&=&3\\$w(v_2)$&=&4\\$w(v_3)$&=&8\\$w(v_4)$&=&1\\
 38.3771 +$w(v_5)$&=&5\\$w(v_6)$&=&2\\$w(v_7)$&=&1\\$w(v_8)$&=&3\\
 38.3772 +\end{tabular}
 38.3773 +
 38.3774 +\begin{center}
 38.3775 +Fig.~5. An example of the maximum weight clique problem.
 38.3776 +\end{center}
 38.3777 +\end{figure}
 38.3778 +
 38.3779 +\subsection{glp\_wclique\_exact---find maximum weight clique with exact
 38.3780 +algorithm}
 38.3781 +
 38.3782 +\subsubsection*{Synopsis}
 38.3783 +
 38.3784 +\begin{verbatim}
 38.3785 +int glp_wclique_exact(glp_graph *G, int v_wgt, double *sol,
 38.3786 +      int v_set);
 38.3787 +\end{verbatim}
 38.3788 +
 38.3789 +\subsection*{Description}
 38.3790 +
 38.3791 +The routine {\it glp\_wclique\_exact} finds a maximum weight clique in
 38.3792 +the specified undirected graph with the exact algorithm developed by
 38.3793 +Patric \"Osterg{\aa}rd.\footnote{P.~R.~J.~\"Osterg{\aa}rd, A new
 38.3794 +algorithm for the maximum-weight clique problem, Nordic J. of Computing,
 38.3795 +Vol.~8, No.~4, 2001, pp.~424--36.}
 38.3796 +
 38.3797 +The parameter $G$ is the program object, which specifies an undirected
 38.3798 +graph. Each arc $(x\rightarrow y)$ in $G$ is considered as edge
 38.3799 +$(x,y)$, self-loops are ignored, and multiple edges, if present, are
 38.3800 +replaced (internally) by simple edges.
 38.3801 +
 38.3802 +The parameter {\it v\_wgt} specifies an offset of the field of type
 38.3803 +{\bf double} in the vertex data block, which contains a weight of
 38.3804 +corresponding vertex. Vertex weights must be integer-valued in the
 38.3805 +range $[0,$ {\it INT\_MAX}$]$. If {\it v\_wgt} $<0$, it is assumed that
 38.3806 +all vertices of the graph have the weight 1.
 38.3807 +
 38.3808 +The parameter {\it sol} specifies a location, to which the routine
 38.3809 +stores the weight of the clique found (the clique weight is the sum
 38.3810 +of weights of all vertices included in the clique.) If {\it sol} is
 38.3811 +{\it NULL}, the solution is not stored.
 38.3812 +
 38.3813 +The parameter {\it v\_set} specifies an offset of the field of type
 38.3814 +{\bf int} in the vertex data block, to which the routines stores a
 38.3815 +vertex flag: 1 means that the corresponding vertex is included in the
 38.3816 +clique found, and 0 otherwise. If {\it v\_set} $<0$, vertex flags are
 38.3817 +not stored.
 38.3818 +
 38.3819 +\subsubsection*{Returns}
 38.3820 +
 38.3821 +\def\arraystretch{1}
 38.3822 +
 38.3823 +\begin{tabular}{@{}p{25mm}p{97.3mm}@{}}
 38.3824 +0 & Optimal solution found.\\
 38.3825 +\verb|GLP_EDATA| & Unable to start the search, because some vertex
 38.3826 +weights are either not integer-valued or out of range. This code is
 38.3827 +also returned if the sum of weights of all vertices exceeds
 38.3828 +{\it INT\_MAX}. \\
 38.3829 +\end{tabular}
 38.3830 +
 38.3831 +\subsubsection*{Notes}
 38.3832 +
 38.3833 +\noindent\indent
 38.3834 +1. The routine {\it glp\_wclique\_exact} finds exact solution. Since
 38.3835 +both MCP and MWCP problems are NP-complete, the algorithm may require
 38.3836 +exponential time in worst cases.
 38.3837 +
 38.3838 +2. Internally the specified graph is converted to an adjacency matrix
 38.3839 +in {\it dense} format. This requires about $|V|^2/16$ bytes of memory,
 38.3840 +where $|V|$ is the number of vertices in the graph.
 38.3841 +
 38.3842 +\subsubsection*{Example}
 38.3843 +
 38.3844 +The example program shown below reads a MWCP instance in DIMACS
 38.3845 +clique/coloring format from file `\verb|sample.clq|', finds the clique
 38.3846 +of largest weight, and writes the solution found to the standard output.
 38.3847 +
 38.3848 +\begin{footnotesize}
 38.3849 +\begin{verbatim}
 38.3850 +#include <stddef.h>
 38.3851 +#include <stdio.h>
 38.3852 +#include <stdlib.h>
 38.3853 +#include <glpk.h>
 38.3854 +
 38.3855 +typedef struct { double wgt; int set; } v_data;
 38.3856 +
 38.3857 +#define vertex(v) ((v_data *)((v)->data))
 38.3858 +
 38.3859 +int main(void)
 38.3860 +{     glp_graph *G;
 38.3861 +      glp_vertex *v;
 38.3862 +      int i, ret;
 38.3863 +      double sol;
 38.3864 +      G = glp_create_graph(sizeof(v_data), 0);
 38.3865 +      glp_read_ccdata(G, offsetof(v_data, wgt), "sample.clq");
 38.3866 +      ret = glp_wclique_exact(G, offsetof(v_data, wgt), &sol,
 38.3867 +         offsetof(v_data, set));
 38.3868 +      printf("ret = %d; sol = %g\n", ret, sol);
 38.3869 +      for (i = 1; i <= G->nv; i++)
 38.3870 +      {  v = G->v[i];
 38.3871 +         printf("vertex %d: weight = %g, flag = %d\n",
 38.3872 +            i, vertex(v)->wgt, vertex(v)->set);
 38.3873 +      }
 38.3874 +      glp_delete_graph(G);
 38.3875 +      return 0;
 38.3876 +}
 38.3877 +\end{verbatim}
 38.3878 +\end{footnotesize}
 38.3879 +
 38.3880 +\noindent
 38.3881 +For the example shown on Fig.~5 the data file may look like follows:
 38.3882 +
 38.3883 +\begin{footnotesize}
 38.3884 +\begin{verbatim}
 38.3885 +c sample.clq
 38.3886 +c
 38.3887 +c This is an example of the maximum weight clique
 38.3888 +c problem in DIMACS clique/coloring format.
 38.3889 +c
 38.3890 +p edge 8 16
 38.3891 +n 1 3
 38.3892 +n 2 4
 38.3893 +n 3 8
 38.3894 +n 5 5
 38.3895 +n 6 2
 38.3896 +n 8 3
 38.3897 +e 1 4
 38.3898 +e 1 5
 38.3899 +e 1 6
 38.3900 +e 1 8
 38.3901 +e 2 3
 38.3902 +e 2 6
 38.3903 +e 2 7
 38.3904 +e 2 8
 38.3905 +e 3 4
 38.3906 +e 3 6
 38.3907 +e 3 7
 38.3908 +e 4 5
 38.3909 +e 4 8
 38.3910 +e 5 7
 38.3911 +e 5 8
 38.3912 +e 6 7
 38.3913 +c
 38.3914 +c eof
 38.3915 +\end{verbatim}
 38.3916 +\end{footnotesize}
 38.3917 +
 38.3918 +\noindent
 38.3919 +The corresponding output from the example program is the following:
 38.3920 +
 38.3921 +\begin{footnotesize}
 38.3922 +\begin{verbatim}
 38.3923 +Reading graph from `sample.clq'...
 38.3924 +Graph has 8 vertices and 16 edges
 38.3925 +28 lines were read
 38.3926 +ret = 0; sol = 15
 38.3927 +vertex 1: weight = 3, flag = 0
 38.3928 +vertex 2: weight = 4, flag = 1
 38.3929 +vertex 3: weight = 8, flag = 1
 38.3930 +vertex 4: weight = 1, flag = 0
 38.3931 +vertex 5: weight = 5, flag = 0
 38.3932 +vertex 6: weight = 2, flag = 1
 38.3933 +vertex 7: weight = 1, flag = 1
 38.3934 +vertex 8: weight = 3, flag = 0
 38.3935 +\end{verbatim}
 38.3936 +\end{footnotesize}
 38.3937 +
 38.3938 +\end{document}
    39.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    39.2 +++ b/deps/glpk/doc/miplib2.txt	Sun Nov 06 20:59:10 2011 +0100
    39.3 @@ -0,0 +1,135 @@
    39.4 +Solver:   GLPSOL 4.40 (options used: --pcost)
    39.5 +Computer: Intel Pentium 4, 3.0 GHz
    39.6 +Platform: Cygwin 1.5.25
    39.7 +Compiler: GCC 3.4.4 (options used: -O3)
    39.8 +Test set: MIPLIB 2.0 <http://miplib.zib.de/miplib3/miplib/>
    39.9 +
   39.10 +Problem  Optimal Solution Cuts Used    Nodes  Iters Time,s Mem,MB
   39.11 +-------- ---------------- --------- -------- ------ ------ ------
   39.12 +air01    +6.796000000e+03                  3     41    < 1    1.2
   39.13 +air02    +7.810000000e+03                 43    201      6   13.8
   39.14 +air03    +3.401600000e+05                 33    414     12   21.0
   39.15 +air04    +5.613700000e+04               1901 109800    396   32.4
   39.16 +air05    +2.637400000e+04               6445 201649    452   45.0
   39.17 +air06    +4.964900000e+04                 11   6868     31   18.1
   39.18 +bell3a   +8.784303160e+05 --gomory      7965  42363     17    6.1
   39.19 +bell3b   +1.178616062e+07 --gomory      6031  30467     19    3.2
   39.20 +bell4    +1.854148420e+07 --gomory      7203  25019     16    2.9
   39.21 +bell5    +8.966406492e+06 --gomory      5605  18555      8    1.5
   39.22 +bm23     +3.400000000e+01                373    878    < 1    0.2
   39.23 +cracpb1  +2.219900000e+04                 47   5258      2    1.3
   39.24 +dcmulti  +1.881820000e+05                743   3366      2    1.1
   39.25 +diamond        infeasible                  3      4    < 1    0.1
   39.26 +dsbmip   -3.051981750e+02 --mir          217  46088     24    4.5
   39.27 +egout    +5.681007000e+02                 91    137    < 1    0.3
   39.28 +enigma   +0.000000000e+00              16419  55071      6    3.2
   39.29 +fixnet3  +5.197300000e+04                 81    380    < 1    1.4
   39.30 +fixnet4  +8.936000000e+03                211   1095      1    1.4
   39.31 +fixnet6  +3.983000000e+03               1031   3136      2    1.7
   39.32 +flugpl   +1.201500000e+06                397    231    < 1    0.1
   39.33 +gen      +1.123133627e+05                195   3991      1    1.7
   39.34 +khb05250 +1.069402260e+08               2163  14498      5    2.8
   39.35 +l152lav  +4.722000000e+03               7419  95299     68   12.0
   39.36 +lp4l     +2.967000000e+03                173   1331      2    1.7
   39.37 +lseu     +1.120000000e+03              10821  31954      5    2.5
   39.38 +misc01   +5.635000000e+02                769   4593      1    0.5
   39.39 +misc02   +1.690000000e+03                 29    282    < 1    0.2
   39.40 +misc03   +3.360000000e+03                957   6742      2    1.1
   39.41 +misc04   +2.666699247e+03                 17   2052      1    7.0
   39.42 +misc05   +2.984500000e+03                293   2520      1    1.1
   39.43 +misc06   +1.285086074e+04                 57    941    < 1    2.7
   39.44 +misc07   +2.810000000e+03 --mir        66075 579129    424   33.4
   39.45 +mod008   +3.070000000e+02               8185  24245      8    2.3
   39.46 +mod010   +6.548000000e+03                315   6283      7    5.3
   39.47 +mod011
   39.48 +mod013   +2.809500000e+02                545   1155    < 1    0.3
   39.49 +modglob  +2.074050809e+07 --mir         5197  31985     20    2.8
   39.50 +noswot
   39.51 +p0033    +3.089000000e+03                305    955    < 1    0.2
   39.52 +p0040    +6.202700000e+04                 17     66    < 1    0.1
   39.53 +p0201    +7.615000000e+03                521   3660      1    0.9
   39.54 +p0282    +2.584110000e+05                623   1204      1    0.8
   39.55 +p0291    +5.223749000e+03                 71    154    < 1    0.7
   39.56 +p0548    +8.691000000e+03               7617  23556      9    2.9
   39.57 +p2756    +3.124000000e+03 --mir         3911  15157     57   10.9
   39.58 +p6000    -2.451377000e+06              19209  40906    570   15.8
   39.59 +pipex    +7.882630000e+02               1569   2469    < 1    0.4
   39.60 +qiu      -1.328731369e+02              80473 1918742  1174   69.2
   39.61 +rentacar +3.035676098e+07                 43   1649      3   12.1
   39.62 +rgn      +8.219999924e+01               3325  18700      2    1.2
   39.63 +sample2  +3.750000000e+02                163    347    < 1    0.2
   39.64 +sentoy   -7.772000000e+03                335    723    < 1    0.4
   39.65 +set1al   +1.586975000e+04 --mir           17    532    < 1    1.5
   39.66 +set1ch
   39.67 +set1cl   +6.484250000e+03 --mir            1    502    < 1    1.1
   39.68 +stein15  +9.000000000e+00                 87    375    < 1    0.2
   39.69 +stein27  +1.800000000e+01               3255  15327      2    1.0
   39.70 +stein45  +3.000000000e+01              52301 389140    139   19.2
   39.71 +stein9   +5.000000000e+00                 17     45    < 1    0.1
   39.72 +vpm1     +2.000000000e+01 --mir            9    836    < 1    0.9
   39.73 +
   39.74 +PROBLEM CHARACTERISTICS
   39.75 +
   39.76 +Problem    Rows   Cols (   Int    0/1)   Nonz    Best Solution
   39.77 +-------- ------ ---------------------- ------ --------------------------
   39.78 +air01        24    771 (   all    all)   4986             6796 (opt)
   39.79 +air02        51   6774 (   all    all)  68329             7810 (opt)
   39.80 +air03       125  10757 (   all    all) 101785           340160 (opt)
   39.81 +air04       824   8904 (   all    all)  81869            56138 (opt)
   39.82 +air05       427   7195 (   all    all)  59316            26402 (not opt)
   39.83 +air06       826   8627 (   all    all)  79433            49649 (opt)
   39.84 +bell3a      124    133 (    71     39)    441        878430.32 (opt)
   39.85 +bell3b      124    133 (    71     39)    441      11786160.62 (opt)
   39.86 +bell4       106    117 (    64     34)    385      18541484.20 (opt)
   39.87 +bell5        92    104 (    58     30)    340       8966406.49 (opt)
   39.88 +bm23         21     27 (   all    all)    505               34 (opt)
   39.89 +cracpb1     144    572 (   all    all)   4730            22199 (opt)
   39.90 +dcmulti     291    548 (    75    all)   1833      188182.0000 (opt)
   39.91 +diamond       5      2 (   all    all)      9     integer infeasible
   39.92 +dsbmip     1855   1886 (   192    160)   9768         -305.198 (opt)
   39.93 +egout        99    141 (    55    all)    392          568.101 (opt)
   39.94 +enigma       22    100 (   all    all)    298              0.0 (opt)
   39.95 +fixnet3     479    878 (   378    all)   2631            51973 (opt)
   39.96 +fixnet4     479    878 (   378    all)   2621             8936 (opt)
   39.97 +fixnet6     479    878 (   378    all)   2550             3983 (opt)
   39.98 +flugpl       19     18 (    11   none)     64          1201500 (opt)
   39.99 +gen         781    870 (   150    144)   3174           112313 (opt)
  39.100 +khb05250    102   1350 (    24    all)   3973        106940226 (opt)
  39.101 +l152lav      98   1989 (   all    all)  11911             4750 (not opt)
  39.102 +lp4l         86   1086 (   all    all)   5763             2967 (opt)
  39.103 +lseu         29     89 (   all    all)    394             1120 (opt)
  39.104 +misc01       55     83 (    82    all)    746            563.5 (opt)
  39.105 +misc02       40     59 (    58    all)    414             1690 (opt)
  39.106 +misc03       97    160 (   159    all)   2054             3360 (opt)
  39.107 +misc04     1726   4897 (    30    all)  17253         2666.699 (opt)
  39.108 +misc05      301    136 (    74    all)   2946           2984.5 (opt)
  39.109 +misc06      821   1808 (   112    all)   5860       12850.8607 (opt)
  39.110 +misc07      213    260 (   259    all)   8620             2810 (not opt)
  39.111 +mod008        7    319 (   all    all)   1562              307 (opt)
  39.112 +mod010      147   2655 (   all    all)  13858             6548 (opt)
  39.113 +mod011     4482  10958 (    96    all)  37425        -54558535 (opt)
  39.114 +mod013       63     96 (    48    all)    288           280.95 (opt)
  39.115 +modglob     292    422 (    98    all)   1390         20740508 (opt)
  39.116 +noswot      183    128 (   100     75)    760              -43 (opt)
  39.117 +p0033        17     33 (   all    all)    131             3089 (opt)
  39.118 +p0040        24     40 (   all    all)    150            62027 (opt)
  39.119 +p0201       134    201 (   all    all)   2124             7615 (opt)
  39.120 +p0282       242    282 (   all    all)   2248           258411 (opt)
  39.121 +p0291       253    291 (   all    all)    349        5223.7490 (opt)
  39.122 +p0548       177    548 (   all    all)   2127             8691 (opt)
  39.123 +p2756       756   2756 (   all    all)  11103             3124 (opt)
  39.124 +p6000      2177   6000 (   all    all)  54238         -2451377 (opt)
  39.125 +pipex        26     48 (   all    all)    240          788.263 (opt)
  39.126 +qiu        1193    840 (    48    all)   3432      -132.873137 (opt)
  39.127 +rentacar   6804   9557 (    55    all)  42019         30356761 (opt)
  39.128 +rgn          25    180 (   100    all)    540          82.1999 (opt)
  39.129 +sample2      46     67 (    21    all)    179              375 (opt)
  39.130 +sentoy       31     60 (   all    all)   1860            -7772 (opt)
  39.131 +set1al      493    712 (   240    all)   1884          15869.7 (opt)
  39.132 +set1ch      493    712 (   240    all)   1884          54537.7 (opt)
  39.133 +set1cl      493    712 (   240    all)   1884          6484.25 (opt)
  39.134 +stein15      37     15 (   all    all)    135                9 (opt)
  39.135 +stein27     119     27 (   all    all)    405               18 (opt)
  39.136 +stein45     332     45 (   all    all)   1079               30 (opt)
  39.137 +stein9       14      9 (   all    all)     54                5 (opt)
  39.138 +vpm1        235    378 (   168    all)    917               20 (opt)
    40.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    40.2 +++ b/deps/glpk/doc/miplib3.txt	Sun Nov 06 20:59:10 2011 +0100
    40.3 @@ -0,0 +1,143 @@
    40.4 +Solver:   GLPSOL 4.40 
    40.5 +Computer: Intel Pentium 4, 3.0 GHz
    40.6 +Platform: Cygwin 1.5.25
    40.7 +Compiler: GCC 3.4.4 (options used: -O3)
    40.8 +Test set: MIPLIB 3.0 <http://miplib.zib.de/miplib3/miplib.html>
    40.9 +
   40.10 +Problem  Optimal Solution Options Used        Nodes  Iters Time,s Mem,MB
   40.11 +-------- ---------------- ---------------- -------- ------ ------ ------
   40.12 +10teams  +9.240000000e+02 --pcost --gomory     6013 349276    207   12.7
   40.13 +air03    +3.401600000e+05 --pcost                33    414     12   21.0
   40.14 +air04    +5.613700000e+04 --pcost              1901 109800    396   32.4
   40.15 +air05    +2.637400000e+04 --pcost              6445 201649    452   45.0
   40.16 +arki001
   40.17 +bell3a   +8.784303160e+05 --pcost --gomory     7965  42363     17    6.1
   40.18 +bell5    +8.966406492e+06 --pcost --gomory     5605  18555      8    1.5
   40.19 +blend2   +7.598985000e+00 --pcost              7185  24256      7    2.1
   40.20 +cap6000  -2.451377000e+06 --pcost             19209  40906    569   15.8
   40.21 +dano3mip 
   40.22 +danoint
   40.23 +dcmulti  +1.881820000e+05 --pcost               743   3366      2    1.1
   40.24 +dsbmip   -3.051981750e+02 --pcost --mir         217  46088     24    4.5
   40.25 +egout    +5.681007000e+02 --pcost                91    137    < 1    0.3
   40.26 +enigma   +0.000000000e+00 --pcost             16419  55071      6    3.2
   40.27 +fast0507
   40.28 +fiber    +4.059351800e+05 --pcost --mir         407   3108      4    2.4
   40.29 +fixnet6  +3.983000000e+03 --pcost              1031   3136      2    1.7
   40.30 +flugpl   +1.201500000e+06 --pcost               397    231    < 1    0.1
   40.31 +gen      +1.123133627e+05 --pcost               195   3991      1    1.7
   40.32 +gesa2    +2.577985637e+07 --pcost --mir          59   2723      4    4.1
   40.33 +gesa2_o  +2.577985637e+07 --pcost --mir          69   2588      5    3.7
   40.34 +gesa3    +2.799104265e+07 --pcost --mir          93   2774      5    3.7
   40.35 +gesa3_o  +2.799104265e+07 --pcost --mir         117   3271      6    3.6
   40.36 +gt2      +2.116600000e+04 --pcost              5613  26115      2    1.2
   40.37 +harp2
   40.38 +khb05250 +1.069402260e+08 --pcost              2163  14498      5    2.8
   40.39 +l152lav  +4.722000000e+03 --pcost              7419  95299     68   12.0
   40.40 +lseu     +1.120000000e+03 --pcost             10821  31954      5    2.5
   40.41 +marksh1
   40.42 +marksh2
   40.43 +mas74
   40.44 +mas76
   40.45 +misc03   +3.360000000e+03 --pcost               957   6742      2    1.1
   40.46 +misc06   +1.285086074e+04 --pcost                57    941    < 1    2.7
   40.47 +misc07   +2.810000000e+03 --pcost --mir       66075 579129    424   33.4
   40.48 +mitre
   40.49 +mkc
   40.50 +mod008   +3.070000000e+02 --pcost              8185  24245      8    2.3
   40.51 +mod010   +6.548000000e+03 --pcost               315   6283      7    5.3
   40.52 +mod011
   40.53 +modglob  +2.074050809e+07 --pcost --mir        5197  31985     20    2.8
   40.54 +noswot
   40.55 +nw04     +1.686200000e+04 (none)                361   5544    345  138.3
   40.56 +p0033    +3.089000000e+03 --pcost               305    955    < 1    0.2
   40.57 +p0201    +7.615000000e+03 --pcost               521   3660      1    0.9
   40.58 +p0282    +2.584110000e+05 --pcost               623   1204      1    0.8
   40.59 +p0548    +8.691000000e+03 --pcost              7617  23556      9    2.9
   40.60 +p2756    +3.124000000e+03 --pcost --mir        3911  15157     57   10.9
   40.61 +pk1
   40.62 +pp08a    +7.350000000e+03 --pcost --mir         663   9196      4    1.3
   40.63 +pp08acut +7.350000000e+03 --pcost --mir       17233 260160    154   21.1
   40.64 +qiu      -1.328731369e+02 --pcost             80473 1918742  1174   69.2
   40.65 +qnet1    +1.602969268e+04 --pcost --mir         183  20352     16    3.6
   40.66 +qnet1_o  +1.602969268e+04 --pcost --mir          75   7645      9    3.3
   40.67 +rentacar +3.035676098e+07 --pcost                43   1649      3   12.1
   40.68 +rgn      +8.219999924e+01 --pcost              3325  18700      2    1.2
   40.69 +rout
   40.70 +set1ch
   40.71 +seymour
   40.72 +stein27  +1.800000000e+01 --pcost              3255  15327      2    1.0
   40.73 +stein45  +3.000000000e+01 --pcost             52301 389140    139   19.2
   40.74 +swath
   40.75 +vpm1     +2.000000000e+01 --pcost --mir           9    836    < 1    0.9
   40.76 +vpm2     +1.375000000e+01 --pcost --mir       11729 164856     91    9.2
   40.77 +
   40.78 +PROBLEM CHARACTERISTICS
   40.79 +
   40.80 +Problem    Rows   Cols (   Int    0/1)   Nonz    Best Solution
   40.81 +-------- ------ ---------------------- ------ --------------------------
   40.82 +10teams     230   2025 (  1800    all)  12150              924 (opt)
   40.83 +air03       125  10757 (   all    all) 101785           340160 (opt)
   40.84 +air04       824   8904 (   all    all)  81869            56138 (opt)
   40.85 +air05       427   7195 (   all    all)  59316            26402 (not opt)
   40.86 +arki001    1048   1388 (   538    415)  20439     7580813.0459 (not opt)
   40.87 +bell3a      124    133 (    71     39)    441        878430.32 (opt)
   40.88 +bell5        92    104 (    58     30)    340       8966406.49 (opt)
   40.89 +blend2      274    353 (   264    231)   1409         7.598985 (opt)
   40.90 +cap6000    2176   6000 (   all    all)  48249         -2451377 (opt)
   40.91 +dano3mip   3202  13873 (   552    all)  79655         728.1111 (not opt)
   40.92 +danoint     664    521 (    56    all)   3232            65.67 (opt)
   40.93 +dcmulti     291    548 (    75    all)   1833      188182.0000 (opt)
   40.94 +dsbmip     1855   1886 (   192    160)   9768         -305.198 (opt)
   40.95 +egout        99    141 (    55    all)    392          568.101 (opt)
   40.96 +enigma       22    100 (   all    all)    298              0.0 (opt)
   40.97 +fast0507    507  63009 (   all    all) 409439              174 (opt)
   40.98 +fiber       363   1298 (  1254    all)   2944     405935.18000 (opt)
   40.99 +fixnet6     479    878 (   378    all)   2550             3983 (opt)
  40.100 +flugpl       19     18 (    11   none)     64          1201500 (opt)
  40.101 +gen         781    870 (   150    144)   3174           112313 (opt)
  40.102 +gesa2      1392   1224 (   408    240)   5064     25779856.372 (opt)
  40.103 +gesa2_o    1248   1224 (   720    384)   3672     25779856.372 (opt)
  40.104 +gesa3      1368   1152 (   384    216)   4944     27991042.648 (opt)
  40.105 +gesa3_o    1224   1152 (   672    336)   3624     27991042.648 (opt)
  40.106 +gt2          29    188 (   all     24)    376        21166.000 (opt)
  40.107 +harp2       112   2993 (   all    all)   5840     -73899798.00 (opt)
  40.108 +khb05250    102   1350 (    24    all)   3973        106940226 (opt)
  40.109 +l152lav      98   1989 (   all    all)  11911             4750 (not opt)
  40.110 +lseu         29     89 (   all    all)    394             1120 (opt)
  40.111 +marksh1       7     62 (    50    all)    324
  40.112 +marksh2       8     74 (    60    all)    448
  40.113 +mas74        13    151 (   150    all)   1705       11801.1857 (opt)
  40.114 +mas76        12    151 (   150    all)   1639       40005.0541 (opt)
  40.115 +misc03       97    160 (   159    all)   2054             3360 (opt)
  40.116 +misc06      821   1808 (   112    all)   5860       12850.8607 (opt)
  40.117 +misc07      213    260 (   259    all)   8620             2810 (not opt)
  40.118 +mitre      2054  10724 (   all    all)  39704           115155 (opt)
  40.119 +mkc        3412   5325 (  5323    all)  20621
  40.120 +mod008        7    319 (   all    all)   1562              307 (opt)
  40.121 +mod010      147   2655 (   all    all)  13858             6548 (opt)
  40.122 +mod011     4482  10958 (    96    all)  37425        -54558535 (opt)
  40.123 +modglob     292    422 (    98    all)   1390         20740508 (opt)
  40.124 +noswot      183    128 (   100     75)    760              -43 (opt)
  40.125 +nw04         36  87482 (   all    all) 636666            16862 (opt)
  40.126 +p0033        17     33 (   all    all)    131             3089 (opt)
  40.127 +p0201       134    201 (   all    all)   2124             7615 (opt)
  40.128 +p0282       242    282 (   all    all)   2248           258411 (opt)
  40.129 +p0548       177    548 (   all    all)   2127             8691 (opt)
  40.130 +p2756       756   2756 (   all    all)  11103             3124 (opt)
  40.131 +pk1          45     86 (    55    all)    915               11 (opt)
  40.132 +pp08a       136    240 (    64    all)    480             7350 (opt)
  40.133 +pp08acut    246    240 (    64    all)    839             7350 (opt)
  40.134 +qiu        1193    840 (    48    all)   3432      -132.873137 (opt)
  40.135 +qnet1       503   1541 (  1417   1288)   4622     16029.692681 (opt)
  40.136 +qnet1_o     456   1541 (  1417   1288)   4214     16029.692681 (opt)
  40.137 +rentacar   6804   9557 (    55    all)  42019         30356761 (opt)
  40.138 +rgn          25    180 (   100    all)    540          82.1999 (opt)
  40.139 +rout        291    556 (   315    300)   2431          1077.56 (opt)
  40.140 +set1ch      493    712 (   240    all)   1884          54537.7 (opt)
  40.141 +seymour    4944   1372 (   all    all)  33549          423 (not opt)
  40.142 +stein27     119     27 (   all    all)    405               18 (opt)
  40.143 +stein45     332     45 (   all    all)   1079               30 (opt)
  40.144 +swath       885   6805 (  6724    all)  34966
  40.145 +vpm1        235    378 (   168    all)    917               20 (opt)
  40.146 +vpm2        234    378 (   168    all)    917            13.75 (opt)
    41.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    41.2 +++ b/deps/glpk/doc/netlib.txt	Sun Nov 06 20:59:10 2011 +0100
    41.3 @@ -0,0 +1,103 @@
    41.4 +Solver:   GLPSOL 4.40 (default options used)
    41.5 +Computer: Intel Pentium 4, 3.0 GHz
    41.6 +Platform: Cygwin 1.5.25
    41.7 +Compiler: GCC 3.4.4 (options used: -O3)
    41.8 +Test set: Netlib LP collection <ftp://ftp.netlib.org/lp/data/>
    41.9 +
   41.10 +Problem    Rows   Cols   Nonz       Optimum        Iters  Time,s  Mem,MB
   41.11 +--------  -----  -----  ------  ----------------  ------  ------  ------
   41.12 +25fv47      822   1571   11127  +5.501845888e+03    1651     < 1     2.1
   41.13 +80bau3b    2263   9799   29063  +9.872241924e+05    5358       3     6.4
   41.14 +adlittle     57     97     465  +2.254949632e+05      71     < 1     0.1   
   41.15 +afiro        28     32      88  -4.647531429e+02      10     < 1     0.1
   41.16 +agg         489    163    2541  -3.599176729e+07     100     < 1     0.5
   41.17 +agg2        517    302    4515  -2.023925236e+07     178     < 1     0.8
   41.18 +agg3        517    302    4531  +1.031211594e+07     182     < 1     0.8
   41.19 +bandm       306    472    2659  -1.586280185e+02     252     < 1     0.6
   41.20 +beaconfd    174    262    3476  +3.359248581e+04      61     < 1     0.4
   41.21 +blend        75     83     521  -3.081214985e+01      41     < 1     0.1
   41.22 +bnl1        644   1175    6129  +1.977629562e+03     581     < 1     1.4
   41.23 +bnl2       2325   3489   16124  +1.811236540e+03    1730       1     3.7
   41.24 +boeing1     351    384    3865  -3.352135675e+02     419     < 1     0.7
   41.25 +boeing2     167    143    1339  -3.150187280e+02     161     < 1     0.3
   41.26 +bore3d      234    315    1525  +1.373080394e+03      38     < 1     0.3
   41.27 +brandy      221    249    2150  +1.518509896e+03     191     < 1     0.5
   41.28 +capri       272    353    1786  +2.690012914e+03     203     < 1     0.4
   41.29 +cycle      1904   2857   21322  -5.226393025e+00     953     < 1     3.5
   41.30 +czprob      930   3523   14173  +2.185196699e+06     754     < 1     2.6
   41.31 +d2q06c     2172   5167   35674  +1.227842108e+05    5368       7     6.2
   41.32 +d6cube      416   6184   43888  +3.154916667e+02    6596       6     6.0
   41.33 +degen2      445    534    4449  -1.435178000e+03     506     < 1     1.0
   41.34 +degen3     1504   1818   26230  -9.872940000e+02    2205       2     4.1
   41.35 +dfl001     6072  12230   41873  +1.126639605e+07   39863     117    11.0
   41.36 +e226        224    282    2767  -2.586492907e+01     206     < 1     0.5
   41.37 +etamacro    401    688    2489  -7.557152333e+02     444     < 1     0.7
   41.38 +fffff800    525    854    6235  +5.556795648e+05     167     < 1     1.0
   41.39 +finnis      498    614    2714  +1.727910656e+05     338     < 1     0.6
   41.40 +fit1d        25   1026   14430  -9.146378092e+03     488     < 1     1.7
   41.41 +fit1p       628   1677   10894  +9.146378092e+03    1379     < 1     1.9
   41.42 +fit2d        26  10500  138018  -6.846429329e+04    5751      16    15.8
   41.43 +fit2p      3001  13525   60784  +6.846429329e+04   11960      17    11.3
   41.44 +forplan     162    421    4916  -6.642189613e+02     170     < 1     0.7
   41.45 +ganges     1310   1681    7021  -1.095857361e+05     724     < 1     1.9
   41.46 +gfrd-pnc    617   1092    3467  +6.902236000e+06     416     < 1     1.0
   41.47 +greenbea   2393   5405   31499  -7.255524813e+07    3012       3     5.8
   41.48 +greenbeb   2393   5405   31499  -4.302260261e+06    2153       2     5.8
   41.49 +grow15      301    645    5665  -1.068709413e+08     358     < 1     1.1
   41.50 +grow22      441    946    8318  -1.608343365e+08     606     < 1     1.6
   41.51 +grow7       141    301    2633  -4.778781181e+07     159     < 1     0.5
   41.52 +israel      175    142    2358  -8.966448219e+05     123     < 1     0.4
   41.53 +kb2          44     41     291  -1.749900130e+03      38     < 1     0.1
   41.54 +lotfi       154    308    1086  -2.526470606e+01     104     < 1     0.3
   41.55 +maros       847   1443   10006  -5.806374370e+04     703     < 1     1.8
   41.56 +maros-r7   3137   9408  151120  +1.497185166e+06    2340       5    16.7
   41.57 +modszk1     688   1620    4158  +3.206197291e+02     705     < 1     1.4
   41.58 +nesm        663   2923   13988  +1.407603649e+07    2240       1     2.4
   41.59 +perold      626   1376    6026  -9.380755278e+03    1103     < 1     1.5
   41.60 +pilot      1442   3652   43220  -5.574831533e+02    5726      11     7.8
   41.61 +pilot-ja    941   1988   14706  -6.113136466e+03    1697       1     2.5
   41.62 +pilot-we    723   2789    9218  -2.720107533e+06    1382       1     2.3
   41.63 +pilot4      411   1000    5145  -2.581139259e+03     532     < 1     1.3
   41.64 +pilot87    2031   4883   73804  +3.017103744e+02    7573      28    12.2
   41.65 +pilotnov    976   2172   13129  -4.497276188e+03     988       1     2.5
   41.66 +recipe       92    180     752  -2.666160000e+02      17     < 1     0.2
   41.67 +sc105       106    103     281  -5.220206121e+01      51     < 1     0.2
   41.68 +sc205       206    203     552  -5.220206121e+01     124     < 1     0.3
   41.69 +sc50a        51     48     131  -6.457507706e+01      25     < 1     0.1
   41.70 +sc50b        51     48     119  -7.000000000e+01      30     < 1     0.1
   41.71 +scagr25     472    500    2029  -1.475343306e+07     352     < 1     0.7
   41.72 +scagr7      130    140     553  -2.331389824e+06      94     < 1     0.2
   41.73 +scfxm1      331    457    2612  +1.841675903e+04     281     < 1     0.6
   41.74 +scfxm2      661    914    5229  +3.666026156e+04     587     < 1     1.1
   41.75 +scfxm3      991   1371    7846  +5.490125455e+04     881     < 1     1.7
   41.76 +scorpion    389    358    1708  +1.878124823e+03     146     < 1     0.4
   41.77 +scrs8       491   1169    4029  +9.042969538e+02     545     < 1     1.1
   41.78 +scsd1        78    760    3148  +8.666666674e+00      91     < 1     0.6
   41.79 +scsd6       148   1350    5666  +5.050000008e+01     182     < 1     1.0
   41.80 +scsd8       398   2750   11334  +9.049999999e+02     397     < 1     2.1
   41.81 +sctap1      301    480    2052  +1.412250000e+03     196     < 1     0.5
   41.82 +sctap2     1091   1880    8124  +1.724807143e+03     425     < 1     1.7
   41.83 +sctap3     1481   2480   10734  +1.424000000e+03     729     < 1     2.4
   41.84 +seba        516   1028    4874  +1.571160000e+04     883     < 1     1.0
   41.85 +share1b     118    225    1182  -7.658931858e+04     167     < 1     0.3
   41.86 +share2b      97     79     730  -4.157322407e+02      87     < 1     0.2
   41.87 +shell       537   1775    4900  +1.208825346e+09     467     < 1     1.2
   41.88 +ship04l     403   2118    8450  +1.793324538e+06     373     < 1     1.5
   41.89 +ship04s     403   1458    5810  +1.798714700e+06     262     < 1     1.0
   41.90 +ship08l     779   4283   17085  +1.909055211e+06     516     < 1     2.9
   41.91 +ship08s     779   2387    9501  +1.920098211e+06     274     < 1     1.7
   41.92 +ship12l    1152   5427   21597  +1.470187919e+06     686     < 1     3.7
   41.93 +ship12s    1152   2763   10941  +1.489236134e+06     383     < 1     2.0
   41.94 +sierra     1228   2036    9252  +1.539436218e+07     857     < 1     2.1
   41.95 +stair       357    467    3857  -2.512669512e+02     399     < 1     1.0
   41.96 +standata    360   1075    3038  +1.257699500e+03     140     < 1     0.7
   41.97 +standgub    362   1184    3147  +1.257699500e+03     140     < 1     0.8
   41.98 +standmps    468   1075    3686  +1.406017500e+03     299     < 1     0.9
   41.99 +stocfor1    118    111     474  -4.113197622e+04      24     < 1     0.2
  41.100 +stocfor2   2158   2031    9492  -3.902440854e+04     499     < 1     2.6
  41.101 +stocfor3  16676  15695   74004  -3.997678394e+04    4456      11    19.7
  41.102 +truss      1001   8806   36642  +4.588158472e+05    4744       4     6.5
  41.103 +tuff        334    587    4523  +2.921477651e-01      61     < 1     0.8
  41.104 +vtp-base    199    203     914  +1.298314625e+05      69     < 1     0.2
  41.105 +wood1p      245   2594   70216  +1.442902412e+00     326     < 1     7.1
  41.106 +woodw      1099   8405   37478  +1.304476333e+00    1093     < 1     6.0
    42.1 Binary file deps/glpk/doc/notes/dfeas.pdf has changed
    43.1 Binary file deps/glpk/doc/notes/gomory.pdf has changed
    44.1 Binary file deps/glpk/doc/notes/keller.pdf has changed
    45.1 Binary file deps/glpk/doc/notes/scaling.pdf has changed
    46.1 Binary file deps/glpk/doc/notes/updating.pdf has changed
    47.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    47.2 +++ b/deps/glpk/examples/INDEX	Sun Nov 06 20:59:10 2011 +0100
    47.3 @@ -0,0 +1,52 @@
    47.4 +assign.mod     Assignment problem
    47.5 +bpp.mod        Bin packing problem
    47.6 +cal.mod        Print an ASCII calendar of the given year
    47.7 +cf12a.mod      Curve fitting problem
    47.8 +cf12b.mod      Curve fitting problem
    47.9 +cflsq.mod      Curve fitting problem by least squares
   47.10 +color.mod      Graph coloring problem
   47.11 +cpp.mod        Critical path problem
   47.12 +crypto.mod     A crypto-arithmetic puzzle
   47.13 +dea.mod        Data envelopment analysis (DEA)
   47.14 +diet.mod       Stigler's nutrition model
   47.15 +dist.mod       A product distribution model
   47.16 +egypt.mod      A static model for fertilizer production
   47.17 +fctp.mod       Fixed-charge transportation problem
   47.18 +food.mod       Food manufacture model
   47.19 +food2.mod      Food manufacture model
   47.20 +gap.mod        Generalized assignment problem
   47.21 +graph.mod      Graph visualization
   47.22 +hashi.mod      A solver for the Japanese number-puzzle Hashiwokakero
   47.23 +huge.mod       Arithmetic mean of a large number of integers
   47.24 +jssp.mod       Job-shop scheduling problem
   47.25 +magic.mod      Magic square
   47.26 +maxcut.mod     Maximum cut problem
   47.27 +maxflow.mod    Maximum flow problem
   47.28 +mfasp.mod      Minimum feedback arc set problem
   47.29 +mfvsp.mod      Minimum feedback vertex set problem
   47.30 +min01ks.mod    Finding minimal equivalent 0-1 knapsack inequality
   47.31 +misp.mod       Maximum independent set problem
   47.32 +money.mod      A crypto-arithmetic puzzle
   47.33 +mvcp.mod       Minimum vertex cover problem
   47.34 +numbrix.mod    Number placement puzzle
   47.35 +pbn/*.*        Paint-by-numbers puzzle
   47.36 +plan.mod       A simple LP problem
   47.37 +prod.mod       A multiperiod production model
   47.38 +qfit.mod       Quadratic curve fitting solution
   47.39 +queens.mod     A classic combinatorial optimization problem
   47.40 +sat.mod        Satisfiability problem
   47.41 +shiftcover.mod Workforce shift coverage assignment problem
   47.42 +shikaku.mod    A solver for the logic puzzle Shikaku
   47.43 +sorting.mod    How to sort arrays in MathProg
   47.44 +spp.mod        Shortest path problem
   47.45 +stigler.mod    Original Stigler's 1939 diet problem
   47.46 +sudoku.mod     Number placement puzzle
   47.47 +tas.mod        Tail assignment problem
   47.48 +todd.mod       A class of hard instances of 0-1 knapsack problems
   47.49 +train.mod      A model of railroad passenger car allocation
   47.50 +transp.mod     A transportation problem
   47.51 +trick.mod      A transportation design problem
   47.52 +tsp.mod        Traveling salesman problem
   47.53 +xyacfs.mod     Extended yet another curve fitting solution
   47.54 +yacfs.mod      Yet another curve fitting solution
   47.55 +zebra.mod      Who owns the zebra?
    48.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    48.2 +++ b/deps/glpk/examples/Makefile.am	Sun Nov 06 20:59:10 2011 +0100
    48.3 @@ -0,0 +1,15 @@
    48.4 +## Process this file with automake to produce Makefile.in ##
    48.5 +
    48.6 +INCLUDES = -I$(srcdir)/../src
    48.7 +
    48.8 +LDADD = ../src/libglpk.la
    48.9 +
   48.10 +bin_PROGRAMS = glpsol
   48.11 +
   48.12 +glpsol_SOURCES = glpsol.c
   48.13 +
   48.14 +check: glpsol$(EXEEXT)
   48.15 +	./glpsol$(EXEEXT) --version
   48.16 +	./glpsol$(EXEEXT) --mps $(srcdir)/plan.mps
   48.17 +
   48.18 +## eof ##
    49.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    49.2 +++ b/deps/glpk/examples/Makefile.in	Sun Nov 06 20:59:10 2011 +0100
    49.3 @@ -0,0 +1,513 @@
    49.4 +# Makefile.in generated by automake 1.11.1 from Makefile.am.
    49.5 +# @configure_input@
    49.6 +
    49.7 +# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
    49.8 +# 2003, 2004, 2005, 2006, 2007, 2008, 2009  Free Software Foundation,
    49.9 +# Inc.
   49.10 +# This Makefile.in is free software; the Free Software Foundation
   49.11 +# gives unlimited permission to copy and/or distribute it,
   49.12 +# with or without modifications, as long as this notice is preserved.
   49.13 +
   49.14 +# This program is distributed in the hope that it will be useful,
   49.15 +# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
   49.16 +# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
   49.17 +# PARTICULAR PURPOSE.
   49.18 +
   49.19 +@SET_MAKE@
   49.20 +
   49.21 +VPATH = @srcdir@
   49.22 +pkgdatadir = $(datadir)/@PACKAGE@
   49.23 +pkgincludedir = $(includedir)/@PACKAGE@
   49.24 +pkglibdir = $(libdir)/@PACKAGE@
   49.25 +pkglibexecdir = $(libexecdir)/@PACKAGE@
   49.26 +am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
   49.27 +install_sh_DATA = $(install_sh) -c -m 644
   49.28 +install_sh_PROGRAM = $(install_sh) -c
   49.29 +install_sh_SCRIPT = $(install_sh) -c
   49.30 +INSTALL_HEADER = $(INSTALL_DATA)
   49.31 +transform = $(program_transform_name)
   49.32 +NORMAL_INSTALL = :
   49.33 +PRE_INSTALL = :
   49.34 +POST_INSTALL = :
   49.35 +NORMAL_UNINSTALL = :
   49.36 +PRE_UNINSTALL = :
   49.37 +POST_UNINSTALL = :
   49.38 +build_triplet = @build@
   49.39 +host_triplet = @host@
   49.40 +bin_PROGRAMS = glpsol$(EXEEXT)
   49.41 +subdir = examples
   49.42 +DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in
   49.43 +ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
   49.44 +am__aclocal_m4_deps = $(top_srcdir)/m4/libtool.m4 \
   49.45 +	$(top_srcdir)/m4/ltoptions.m4 $(top_srcdir)/m4/ltsugar.m4 \
   49.46 +	$(top_srcdir)/m4/ltversion.m4 $(top_srcdir)/m4/lt~obsolete.m4 \
   49.47 +	$(top_srcdir)/configure.ac
   49.48 +am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
   49.49 +	$(ACLOCAL_M4)
   49.50 +mkinstalldirs = $(install_sh) -d
   49.51 +CONFIG_HEADER = $(top_builddir)/config.h
   49.52 +CONFIG_CLEAN_FILES =
   49.53 +CONFIG_CLEAN_VPATH_FILES =
   49.54 +am__installdirs = "$(DESTDIR)$(bindir)"
   49.55 +PROGRAMS = $(bin_PROGRAMS)
   49.56 +am_glpsol_OBJECTS = glpsol.$(OBJEXT)
   49.57 +glpsol_OBJECTS = $(am_glpsol_OBJECTS)
   49.58 +glpsol_LDADD = $(LDADD)
   49.59 +glpsol_DEPENDENCIES = ../src/libglpk.la
   49.60 +DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir)
   49.61 +depcomp = $(SHELL) $(top_srcdir)/depcomp
   49.62 +am__depfiles_maybe = depfiles
   49.63 +am__mv = mv -f
   49.64 +COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
   49.65 +	$(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
   49.66 +LTCOMPILE = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
   49.67 +	--mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \
   49.68 +	$(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
   49.69 +CCLD = $(CC)
   49.70 +LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
   49.71 +	--mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) \
   49.72 +	$(LDFLAGS) -o $@
   49.73 +SOURCES = $(glpsol_SOURCES)
   49.74 +DIST_SOURCES = $(glpsol_SOURCES)
   49.75 +ETAGS = etags
   49.76 +CTAGS = ctags
   49.77 +DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
   49.78 +ACLOCAL = @ACLOCAL@
   49.79 +AMTAR = @AMTAR@
   49.80 +AR = @AR@
   49.81 +AUTOCONF = @AUTOCONF@
   49.82 +AUTOHEADER = @AUTOHEADER@
   49.83 +AUTOMAKE = @AUTOMAKE@
   49.84 +AWK = @AWK@
   49.85 +CC = @CC@
   49.86 +CCDEPMODE = @CCDEPMODE@
   49.87 +CFLAGS = @CFLAGS@
   49.88 +CPP = @CPP@
   49.89 +CPPFLAGS = @CPPFLAGS@
   49.90 +CYGPATH_W = @CYGPATH_W@
   49.91 +DEFS = @DEFS@
   49.92 +DEPDIR = @DEPDIR@
   49.93 +DLLTOOL = @DLLTOOL@
   49.94 +DSYMUTIL = @DSYMUTIL@
   49.95 +DUMPBIN = @DUMPBIN@
   49.96 +ECHO_C = @ECHO_C@
   49.97 +ECHO_N = @ECHO_N@
   49.98 +ECHO_T = @ECHO_T@
   49.99 +EGREP = @EGREP@
  49.100 +EXEEXT = @EXEEXT@
  49.101 +FGREP = @FGREP@
  49.102 +GREP = @GREP@
  49.103 +INSTALL = @INSTALL@
  49.104 +INSTALL_DATA = @INSTALL_DATA@
  49.105 +INSTALL_PROGRAM = @INSTALL_PROGRAM@
  49.106 +INSTALL_SCRIPT = @INSTALL_SCRIPT@
  49.107 +INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
  49.108 +LD = @LD@
  49.109 +LDFLAGS = @LDFLAGS@
  49.110 +LIBOBJS = @LIBOBJS@
  49.111 +LIBS = @LIBS@
  49.112 +LIBTOOL = @LIBTOOL@
  49.113 +LIPO = @LIPO@
  49.114 +LN_S = @LN_S@
  49.115 +LTLIBOBJS = @LTLIBOBJS@
  49.116 +MAKEINFO = @MAKEINFO@
  49.117 +MKDIR_P = @MKDIR_P@
  49.118 +NM = @NM@
  49.119 +NMEDIT = @NMEDIT@
  49.120 +OBJDUMP = @OBJDUMP@
  49.121 +OBJEXT = @OBJEXT@
  49.122 +OTOOL = @OTOOL@
  49.123 +OTOOL64 = @OTOOL64@
  49.124 +PACKAGE = @PACKAGE@
  49.125 +PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
  49.126 +PACKAGE_NAME = @PACKAGE_NAME@
  49.127 +PACKAGE_STRING = @PACKAGE_STRING@
  49.128 +PACKAGE_TARNAME = @PACKAGE_TARNAME@
  49.129 +PACKAGE_URL = @PACKAGE_URL@
  49.130 +PACKAGE_VERSION = @PACKAGE_VERSION@
  49.131 +PATH_SEPARATOR = @PATH_SEPARATOR@
  49.132 +RANLIB = @RANLIB@
  49.133 +SED = @SED@
  49.134 +SET_MAKE = @SET_MAKE@
  49.135 +SHELL = @SHELL@
  49.136 +STRIP = @STRIP@
  49.137 +VERSION = @VERSION@
  49.138 +abs_builddir = @abs_builddir@
  49.139 +abs_srcdir = @abs_srcdir@
  49.140 +abs_top_builddir = @abs_top_builddir@
  49.141 +abs_top_srcdir = @abs_top_srcdir@
  49.142 +ac_ct_CC = @ac_ct_CC@
  49.143 +ac_ct_DUMPBIN = @ac_ct_DUMPBIN@
  49.144 +am__include = @am__include@
  49.145 +am__leading_dot = @am__leading_dot@
  49.146 +am__quote = @am__quote@
  49.147 +am__tar = @am__tar@
  49.148 +am__untar = @am__untar@
  49.149 +bindir = @bindir@
  49.150 +build = @build@
  49.151 +build_alias = @build_alias@
  49.152 +build_cpu = @build_cpu@
  49.153 +build_os = @build_os@
  49.154 +build_vendor = @build_vendor@
  49.155 +builddir = @builddir@
  49.156 +datadir = @datadir@
  49.157 +datarootdir = @datarootdir@
  49.158 +docdir = @docdir@
  49.159 +dvidir = @dvidir@
  49.160 +exec_prefix = @exec_prefix@
  49.161 +host = @host@
  49.162 +host_alias = @host_alias@
  49.163 +host_cpu = @host_cpu@
  49.164 +host_os = @host_os@
  49.165 +host_vendor = @host_vendor@
  49.166 +htmldir = @htmldir@
  49.167 +includedir = @includedir@
  49.168 +infodir = @infodir@
  49.169 +install_sh = @install_sh@
  49.170 +libdir = @libdir@
  49.171 +libexecdir = @libexecdir@
  49.172 +localedir = @localedir@
  49.173 +localstatedir = @localstatedir@
  49.174 +mandir = @mandir@
  49.175 +mkdir_p = @mkdir_p@
  49.176 +oldincludedir = @oldincludedir@
  49.177 +pdfdir = @pdfdir@
  49.178 +prefix = @prefix@
  49.179 +program_transform_name = @program_transform_name@
  49.180 +psdir = @psdir@
  49.181 +sbindir = @sbindir@
  49.182 +sharedstatedir = @sharedstatedir@
  49.183 +srcdir = @srcdir@
  49.184 +sysconfdir = @sysconfdir@
  49.185 +target_alias = @target_alias@
  49.186 +to_host_path_cmd = @to_host_path_cmd@
  49.187 +top_build_prefix = @top_build_prefix@
  49.188 +top_builddir = @top_builddir@
  49.189 +top_srcdir = @top_srcdir@
  49.190 +INCLUDES = -I$(srcdir)/../src
  49.191 +LDADD = ../src/libglpk.la
  49.192 +glpsol_SOURCES = glpsol.c
  49.193 +all: all-am
  49.194 +
  49.195 +.SUFFIXES:
  49.196 +.SUFFIXES: .c .lo .o .obj
  49.197 +$(srcdir)/Makefile.in:  $(srcdir)/Makefile.am  $(am__configure_deps)
  49.198 +	@for dep in $?; do \
  49.199 +	  case '$(am__configure_deps)' in \
  49.200 +	    *$$dep*) \
  49.201 +	      ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \
  49.202 +	        && { if test -f $@; then exit 0; else break; fi; }; \
  49.203 +	      exit 1;; \
  49.204 +	  esac; \
  49.205 +	done; \
  49.206 +	echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu examples/Makefile'; \
  49.207 +	$(am__cd) $(top_srcdir) && \
  49.208 +	  $(AUTOMAKE) --gnu examples/Makefile
  49.209 +.PRECIOUS: Makefile
  49.210 +Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
  49.211 +	@case '$?' in \
  49.212 +	  *config.status*) \
  49.213 +	    cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
  49.214 +	  *) \
  49.215 +	    echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
  49.216 +	    cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
  49.217 +	esac;
  49.218 +
  49.219 +$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
  49.220 +	cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
  49.221 +
  49.222 +$(top_srcdir)/configure:  $(am__configure_deps)
  49.223 +	cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
  49.224 +$(ACLOCAL_M4):  $(am__aclocal_m4_deps)
  49.225 +	cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
  49.226 +$(am__aclocal_m4_deps):
  49.227 +install-binPROGRAMS: $(bin_PROGRAMS)
  49.228 +	@$(NORMAL_INSTALL)
  49.229 +	test -z "$(bindir)" || $(MKDIR_P) "$(DESTDIR)$(bindir)"
  49.230 +	@list='$(bin_PROGRAMS)'; test -n "$(bindir)" || list=; \
  49.231 +	for p in $$list; do echo "$$p $$p"; done | \
  49.232 +	sed 's/$(EXEEXT)$$//' | \
  49.233 +	while read p p1; do if test -f $$p || test -f $$p1; \
  49.234 +	  then echo "$$p"; echo "$$p"; else :; fi; \
  49.235 +	done | \
  49.236 +	sed -e 'p;s,.*/,,;n;h' -e 's|.*|.|' \
  49.237 +	    -e 'p;x;s,.*/,,;s/$(EXEEXT)$$//;$(transform);s/$$/$(EXEEXT)/' | \
  49.238 +	sed 'N;N;N;s,\n, ,g' | \
  49.239 +	$(AWK) 'BEGIN { files["."] = ""; dirs["."] = 1 } \
  49.240 +	  { d=$$3; if (dirs[d] != 1) { print "d", d; dirs[d] = 1 } \
  49.241 +	    if ($$2 == $$4) files[d] = files[d] " " $$1; \
  49.242 +	    else { print "f", $$3 "/" $$4, $$1; } } \
  49.243 +	  END { for (d in files) print "f", d, files[d] }' | \
  49.244 +	while read type dir files; do \
  49.245 +	    if test "$$dir" = .; then dir=; else dir=/$$dir; fi; \
  49.246 +	    test -z "$$files" || { \
  49.247 +	    echo " $(INSTALL_PROGRAM_ENV) $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL_PROGRAM) $$files '$(DESTDIR)$(bindir)$$dir'"; \
  49.248 +	    $(INSTALL_PROGRAM_ENV) $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL_PROGRAM) $$files "$(DESTDIR)$(bindir)$$dir" || exit $$?; \
  49.249 +	    } \
  49.250 +	; done
  49.251 +
  49.252 +uninstall-binPROGRAMS:
  49.253 +	@$(NORMAL_UNINSTALL)
  49.254 +	@list='$(bin_PROGRAMS)'; test -n "$(bindir)" || list=; \
  49.255 +	files=`for p in $$list; do echo "$$p"; done | \
  49.256 +	  sed -e 'h;s,^.*/,,;s/$(EXEEXT)$$//;$(transform)' \
  49.257 +	      -e 's/$$/$(EXEEXT)/' `; \
  49.258 +	test -n "$$list" || exit 0; \
  49.259 +	echo " ( cd '$(DESTDIR)$(bindir)' && rm -f" $$files ")"; \
  49.260 +	cd "$(DESTDIR)$(bindir)" && rm -f $$files
  49.261 +
  49.262 +clean-binPROGRAMS:
  49.263 +	@list='$(bin_PROGRAMS)'; test -n "$$list" || exit 0; \
  49.264 +	echo " rm -f" $$list; \
  49.265 +	rm -f $$list || exit $$?; \
  49.266 +	test -n "$(EXEEXT)" || exit 0; \
  49.267 +	list=`for p in $$list; do echo "$$p"; done | sed 's/$(EXEEXT)$$//'`; \
  49.268 +	echo " rm -f" $$list; \
  49.269 +	rm -f $$list
  49.270 +glpsol$(EXEEXT): $(glpsol_OBJECTS) $(glpsol_DEPENDENCIES) 
  49.271 +	@rm -f glpsol$(EXEEXT)
  49.272 +	$(LINK) $(glpsol_OBJECTS) $(glpsol_LDADD) $(LIBS)
  49.273 +
  49.274 +mostlyclean-compile:
  49.275 +	-rm -f *.$(OBJEXT)
  49.276 +
  49.277 +distclean-compile:
  49.278 +	-rm -f *.tab.c
  49.279 +
  49.280 +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/glpsol.Po@am__quote@
  49.281 +
  49.282 +.c.o:
  49.283 +@am__fastdepCC_TRUE@	$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
  49.284 +@am__fastdepCC_TRUE@	$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
  49.285 +@AMDEP_TRUE@@am__fastdepCC_FALSE@	source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
  49.286 +@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
  49.287 +@am__fastdepCC_FALSE@	$(COMPILE) -c $<
  49.288 +
  49.289 +.c.obj:
  49.290 +@am__fastdepCC_TRUE@	$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'`
  49.291 +@am__fastdepCC_TRUE@	$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
  49.292 +@AMDEP_TRUE@@am__fastdepCC_FALSE@	source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
  49.293 +@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
  49.294 +@am__fastdepCC_FALSE@	$(COMPILE) -c `$(CYGPATH_W) '$<'`
  49.295 +
  49.296 +.c.lo:
  49.297 +@am__fastdepCC_TRUE@	$(LTCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
  49.298 +@am__fastdepCC_TRUE@	$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo
  49.299 +@AMDEP_TRUE@@am__fastdepCC_FALSE@	source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@
  49.300 +@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
  49.301 +@am__fastdepCC_FALSE@	$(LTCOMPILE) -c -o $@ $<
  49.302 +
  49.303 +mostlyclean-libtool:
  49.304 +	-rm -f *.lo
  49.305 +
  49.306 +clean-libtool:
  49.307 +	-rm -rf .libs _libs
  49.308 +
  49.309 +ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
  49.310 +	list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
  49.311 +	unique=`for i in $$list; do \
  49.312 +	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
  49.313 +	  done | \
  49.314 +	  $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
  49.315 +	      END { if (nonempty) { for (i in files) print i; }; }'`; \
  49.316 +	mkid -fID $$unique
  49.317 +tags: TAGS
  49.318 +
  49.319 +TAGS:  $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
  49.320 +		$(TAGS_FILES) $(LISP)
  49.321 +	set x; \
  49.322 +	here=`pwd`; \
  49.323 +	list='$(SOURCES) $(HEADERS)  $(LISP) $(TAGS_FILES)'; \
  49.324 +	unique=`for i in $$list; do \
  49.325 +	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
  49.326 +	  done | \
  49.327 +	  $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
  49.328 +	      END { if (nonempty) { for (i in files) print i; }; }'`; \
  49.329 +	shift; \
  49.330 +	if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \
  49.331 +	  test -n "$$unique" || unique=$$empty_fix; \
  49.332 +	  if test $$# -gt 0; then \
  49.333 +	    $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
  49.334 +	      "$$@" $$unique; \
  49.335 +	  else \
  49.336 +	    $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
  49.337 +	      $$unique; \
  49.338 +	  fi; \
  49.339 +	fi
  49.340 +ctags: CTAGS
  49.341 +CTAGS:  $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
  49.342 +		$(TAGS_FILES) $(LISP)
  49.343 +	list='$(SOURCES) $(HEADERS)  $(LISP) $(TAGS_FILES)'; \
  49.344 +	unique=`for i in $$list; do \
  49.345 +	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
  49.346 +	  done | \
  49.347 +	  $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
  49.348 +	      END { if (nonempty) { for (i in files) print i; }; }'`; \
  49.349 +	test -z "$(CTAGS_ARGS)$$unique" \
  49.350 +	  || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
  49.351 +	     $$unique
  49.352 +
  49.353 +GTAGS:
  49.354 +	here=`$(am__cd) $(top_builddir) && pwd` \
  49.355 +	  && $(am__cd) $(top_srcdir) \
  49.356 +	  && gtags -i $(GTAGS_ARGS) "$$here"
  49.357 +
  49.358 +distclean-tags:
  49.359 +	-rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
  49.360 +
  49.361 +distdir: $(DISTFILES)
  49.362 +	@srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
  49.363 +	topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
  49.364 +	list='$(DISTFILES)'; \
  49.365 +	  dist_files=`for file in $$list; do echo $$file; done | \
  49.366 +	  sed -e "s|^$$srcdirstrip/||;t" \
  49.367 +	      -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \
  49.368 +	case $$dist_files in \
  49.369 +	  */*) $(MKDIR_P) `echo "$$dist_files" | \
  49.370 +			   sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \
  49.371 +			   sort -u` ;; \
  49.372 +	esac; \
  49.373 +	for file in $$dist_files; do \
  49.374 +	  if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
  49.375 +	  if test -d $$d/$$file; then \
  49.376 +	    dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \
  49.377 +	    if test -d "$(distdir)/$$file"; then \
  49.378 +	      find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
  49.379 +	    fi; \
  49.380 +	    if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
  49.381 +	      cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \
  49.382 +	      find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
  49.383 +	    fi; \
  49.384 +	    cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \
  49.385 +	  else \
  49.386 +	    test -f "$(distdir)/$$file" \
  49.387 +	    || cp -p $$d/$$file "$(distdir)/$$file" \
  49.388 +	    || exit 1; \
  49.389 +	  fi; \
  49.390 +	done
  49.391 +check-am: all-am
  49.392 +check: check-am
  49.393 +all-am: Makefile $(PROGRAMS)
  49.394 +installdirs:
  49.395 +	for dir in "$(DESTDIR)$(bindir)"; do \
  49.396 +	  test -z "$$dir" || $(MKDIR_P) "$$dir"; \
  49.397 +	done
  49.398 +install: install-am
  49.399 +install-exec: install-exec-am
  49.400 +install-data: install-data-am
  49.401 +uninstall: uninstall-am
  49.402 +
  49.403 +install-am: all-am
  49.404 +	@$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
  49.405 +
  49.406 +installcheck: installcheck-am
  49.407 +install-strip:
  49.408 +	$(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
  49.409 +	  install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
  49.410 +	  `test -z '$(STRIP)' || \
  49.411 +	    echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install
  49.412 +mostlyclean-generic:
  49.413 +
  49.414 +clean-generic:
  49.415 +
  49.416 +distclean-generic:
  49.417 +	-test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
  49.418 +	-test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES)
  49.419 +
  49.420 +maintainer-clean-generic:
  49.421 +	@echo "This command is intended for maintainers to use"
  49.422 +	@echo "it deletes files that may require special tools to rebuild."
  49.423 +clean: clean-am
  49.424 +
  49.425 +clean-am: clean-binPROGRAMS clean-generic clean-libtool mostlyclean-am
  49.426 +
  49.427 +distclean: distclean-am
  49.428 +	-rm -rf ./$(DEPDIR)
  49.429 +	-rm -f Makefile
  49.430 +distclean-am: clean-am distclean-compile distclean-generic \
  49.431 +	distclean-tags
  49.432 +
  49.433 +dvi: dvi-am
  49.434 +
  49.435 +dvi-am:
  49.436 +
  49.437 +html: html-am
  49.438 +
  49.439 +html-am:
  49.440 +
  49.441 +info: info-am
  49.442 +
  49.443 +info-am:
  49.444 +
  49.445 +install-data-am:
  49.446 +
  49.447 +install-dvi: install-dvi-am
  49.448 +
  49.449 +install-dvi-am:
  49.450 +
  49.451 +install-exec-am: install-binPROGRAMS
  49.452 +
  49.453 +install-html: install-html-am
  49.454 +
  49.455 +install-html-am:
  49.456 +
  49.457 +install-info: install-info-am
  49.458 +
  49.459 +install-info-am:
  49.460 +
  49.461 +install-man:
  49.462 +
  49.463 +install-pdf: install-pdf-am
  49.464 +
  49.465 +install-pdf-am:
  49.466 +
  49.467 +install-ps: install-ps-am
  49.468 +
  49.469 +install-ps-am:
  49.470 +
  49.471 +installcheck-am:
  49.472 +
  49.473 +maintainer-clean: maintainer-clean-am
  49.474 +	-rm -rf ./$(DEPDIR)
  49.475 +	-rm -f Makefile
  49.476 +maintainer-clean-am: distclean-am maintainer-clean-generic
  49.477 +
  49.478 +mostlyclean: mostlyclean-am
  49.479 +
  49.480 +mostlyclean-am: mostlyclean-compile mostlyclean-generic \
  49.481 +	mostlyclean-libtool
  49.482 +
  49.483 +pdf: pdf-am
  49.484 +
  49.485 +pdf-am:
  49.486 +
  49.487 +ps: ps-am
  49.488 +
  49.489 +ps-am:
  49.490 +
  49.491 +uninstall-am: uninstall-binPROGRAMS
  49.492 +
  49.493 +.MAKE: install-am install-strip
  49.494 +
  49.495 +.PHONY: CTAGS GTAGS all all-am check check-am clean clean-binPROGRAMS \
  49.496 +	clean-generic clean-libtool ctags distclean distclean-compile \
  49.497 +	distclean-generic distclean-libtool distclean-tags distdir dvi \
  49.498 +	dvi-am html html-am info info-am install install-am \
  49.499 +	install-binPROGRAMS install-data install-data-am install-dvi \
  49.500 +	install-dvi-am install-exec install-exec-am install-html \
  49.501 +	install-html-am install-info install-info-am install-man \
  49.502 +	install-pdf install-pdf-am install-ps install-ps-am \
  49.503 +	install-strip installcheck installcheck-am installdirs \
  49.504 +	maintainer-clean maintainer-clean-generic mostlyclean \
  49.505 +	mostlyclean-compile mostlyclean-generic mostlyclean-libtool \
  49.506 +	pdf pdf-am ps ps-am tags uninstall uninstall-am \
  49.507 +	uninstall-binPROGRAMS
  49.508 +
  49.509 +
  49.510 +check: glpsol$(EXEEXT)
  49.511 +	./glpsol$(EXEEXT) --version
  49.512 +	./glpsol$(EXEEXT) --mps $(srcdir)/plan.mps
  49.513 +
  49.514 +# Tell versions [3.59,3.63) of GNU make to not export all variables.
  49.515 +# Otherwise a system limit (for SysV at least) may be exceeded.
  49.516 +.NOEXPORT:
    50.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    50.2 +++ b/deps/glpk/examples/assign.mod	Sun Nov 06 20:59:10 2011 +0100
    50.3 @@ -0,0 +1,77 @@
    50.4 +/* ASSIGN, Assignment Problem */
    50.5 +
    50.6 +/* Written in GNU MathProg by Andrew Makhorin <mao@gnu.org> */
    50.7 +
    50.8 +/* The assignment problem is one of the fundamental combinatorial
    50.9 +   optimization problems.
   50.10 +
   50.11 +   In its most general form, the problem is as follows:
   50.12 +
   50.13 +   There are a number of agents and a number of tasks. Any agent can be
   50.14 +   assigned to perform any task, incurring some cost that may vary
   50.15 +   depending on the agent-task assignment. It is required to perform all
   50.16 +   tasks by assigning exactly one agent to each task in such a way that
   50.17 +   the total cost of the assignment is minimized.
   50.18 +
   50.19 +   (From Wikipedia, the free encyclopedia.) */
   50.20 +
   50.21 +param m, integer, > 0;
   50.22 +/* number of agents */
   50.23 +
   50.24 +param n, integer, > 0;
   50.25 +/* number of tasks */
   50.26 +
   50.27 +set I := 1..m;
   50.28 +/* set of agents */
   50.29 +
   50.30 +set J := 1..n;
   50.31 +/* set of tasks */
   50.32 +
   50.33 +param c{i in I, j in J}, >= 0;
   50.34 +/* cost of allocating task j to agent i */
   50.35 +
   50.36 +var x{i in I, j in J}, >= 0;
   50.37 +/* x[i,j] = 1 means task j is assigned to agent i
   50.38 +   note that variables x[i,j] are binary, however, there is no need to
   50.39 +   declare them so due to the totally unimodular constraint matrix */
   50.40 +
   50.41 +s.t. phi{i in I}: sum{j in J} x[i,j] <= 1;
   50.42 +/* each agent can perform at most one task */
   50.43 +
   50.44 +s.t. psi{j in J}: sum{i in I} x[i,j] = 1;
   50.45 +/* each task must be assigned exactly to one agent */
   50.46 +
   50.47 +minimize obj: sum{i in I, j in J} c[i,j] * x[i,j];
   50.48 +/* the objective is to find a cheapest assignment */
   50.49 +
   50.50 +solve;
   50.51 +
   50.52 +printf "\n";
   50.53 +printf "Agent  Task       Cost\n";
   50.54 +printf{i in I} "%5d %5d %10g\n", i, sum{j in J} j * x[i,j],
   50.55 +   sum{j in J} c[i,j] * x[i,j];
   50.56 +printf "----------------------\n";
   50.57 +printf "     Total: %10g\n", sum{i in I, j in J} c[i,j] * x[i,j];
   50.58 +printf "\n";
   50.59 +
   50.60 +data;
   50.61 +
   50.62 +/* These data correspond to an example from [Christofides]. */
   50.63 +
   50.64 +/* Optimal solution is 76 */
   50.65 +
   50.66 +param m := 8;
   50.67 +
   50.68 +param n := 8;
   50.69 +
   50.70 +param c : 1  2  3  4  5  6  7  8 :=
   50.71 +      1  13 21 20 12  8 26 22 11
   50.72 +      2  12 36 25 41 40 11  4  8
   50.73 +      3  35 32 13 36 26 21 13 37
   50.74 +      4  34 54  7  8 12 22 11 40
   50.75 +      5  21  6 45 18 24 34 12 48
   50.76 +      6  42 19 39 15 14 16 28 46
   50.77 +      7  16 34 38  3 34 40 22 24
   50.78 +      8  26 20  5 17 45 31 37 43 ;
   50.79 +
   50.80 +end;
    51.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    51.2 +++ b/deps/glpk/examples/bpp.mod	Sun Nov 06 20:59:10 2011 +0100
    51.3 @@ -0,0 +1,83 @@
    51.4 +/* BPP, Bin Packing Problem */
    51.5 +
    51.6 +/* Written in GNU MathProg by Andrew Makhorin <mao@gnu.org> */
    51.7 +
    51.8 +/* Given a set of items I = {1,...,m} with weight w[i] > 0, the Bin
    51.9 +   Packing Problem (BPP) is to pack the items into bins of capacity c
   51.10 +   in such a way that the number of bins used is minimal. */
   51.11 +
   51.12 +param m, integer, > 0;
   51.13 +/* number of items */
   51.14 +
   51.15 +set I := 1..m;
   51.16 +/* set of items */
   51.17 +
   51.18 +param w{i in 1..m}, > 0;
   51.19 +/* w[i] is weight of item i */
   51.20 +
   51.21 +param c, > 0;
   51.22 +/* bin capacity */
   51.23 +
   51.24 +/* We need to estimate an upper bound of the number of bins sufficient
   51.25 +   to contain all items. The number of items m can be used, however, it
   51.26 +   is not a good idea. To obtain a more suitable estimation an easy
   51.27 +   heuristic is used: we put items into a bin while it is possible, and
   51.28 +   if the bin is full, we use another bin. The number of bins used in
   51.29 +   this way gives us a more appropriate estimation. */
   51.30 +
   51.31 +param z{i in I, j in 1..m} :=
   51.32 +/* z[i,j] = 1 if item i is in bin j, otherwise z[i,j] = 0 */
   51.33 +
   51.34 +   if i = 1 and j = 1 then 1
   51.35 +   /* put item 1 into bin 1 */
   51.36 +
   51.37 +   else if exists{jj in 1..j-1} z[i,jj] then 0
   51.38 +   /* if item i is already in some bin, do not put it into bin j */
   51.39 +
   51.40 +   else if sum{ii in 1..i-1} w[ii] * z[ii,j] + w[i] > c then 0
   51.41 +   /* if item i does not fit into bin j, do not put it into bin j */
   51.42 +
   51.43 +   else 1;
   51.44 +   /* otherwise put item i into bin j */
   51.45 +
   51.46 +check{i in I}: sum{j in 1..m} z[i,j] = 1;
   51.47 +/* each item must be exactly in one bin */
   51.48 +
   51.49 +check{j in 1..m}: sum{i in I} w[i] * z[i,j] <= c;
   51.50 +/* no bin must be overflowed */
   51.51 +
   51.52 +param n := sum{j in 1..m} if exists{i in I} z[i,j] then 1;
   51.53 +/* determine the number of bins used by the heuristic; obviously it is
   51.54 +   an upper bound of the optimal solution */
   51.55 +
   51.56 +display n;
   51.57 +
   51.58 +set J := 1..n;
   51.59 +/* set of bins */
   51.60 +
   51.61 +var x{i in I, j in J}, binary;
   51.62 +/* x[i,j] = 1 means item i is in bin j */
   51.63 +
   51.64 +var used{j in J}, binary;
   51.65 +/* used[j] = 1 means bin j contains at least one item */
   51.66 +
   51.67 +s.t. one{i in I}: sum{j in J} x[i,j] = 1;
   51.68 +/* each item must be exactly in one bin */
   51.69 +
   51.70 +s.t. lim{j in J}: sum{i in I} w[i] * x[i,j] <= c * used[j];
   51.71 +/* if bin j is used, it must not be overflowed */
   51.72 +
   51.73 +minimize obj: sum{j in J} used[j];
   51.74 +/* objective is to minimize the number of bins used */
   51.75 +
   51.76 +data;
   51.77 +
   51.78 +/* The optimal solution is 3 bins */
   51.79 +
   51.80 +param m := 6;
   51.81 +
   51.82 +param w := 1 50, 2 60, 3 30, 4 70, 5 50, 6 40;
   51.83 +
   51.84 +param c := 100;
   51.85 +
   51.86 +end;
    52.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    52.2 +++ b/deps/glpk/examples/cal.mod	Sun Nov 06 20:59:10 2011 +0100
    52.3 @@ -0,0 +1,49 @@
    52.4 +/* cal.mod - print an ASCII calendar of the given year */
    52.5 +
    52.6 +/* Written in GNU MathProg by Andrew Makhorin <mao@gnu.org> */
    52.7 +
    52.8 +param year, integer, >= 0001, <= 3999, default 2010;
    52.9 +
   52.10 +param first_day{m in 1..12}, integer, >= 0, <= 6, :=
   52.11 +      time2str(str2time(year & "-" & m & "-01", "%Y-%m-%d"), "%w");
   52.12 +
   52.13 +param days_in_month{m in 1..12}, integer, >= 28, <= 31, :=
   52.14 +      (str2time(year + (if m < 12 then 0 else 1) & "-" &
   52.15 +         (if m < 12 then m+1 else 1) & "-01", "%Y-%m-%d") -
   52.16 +      str2time(year & "-" & m & "-01", "%Y-%m-%d")) / 86400;
   52.17 +
   52.18 +param foo{m in 1..12, k in 0..5, d in 0..6}, integer, :=
   52.19 +      7 * k + d + 1 - first_day[m];
   52.20 +
   52.21 +param cal{m in 1..12, k in 0..5, d in 0..6}, integer, :=
   52.22 +      if 1 <= foo[m,k,d] and foo[m,k,d] <= days_in_month[m] then
   52.23 +         foo[m,k,d];
   52.24 +
   52.25 +printf "\n";
   52.26 +printf "%33s%04d\n", "", year;
   52.27 +printf "\n";
   52.28 +for {t in 1..12 by 3}
   52.29 +{     for {m in t..t+2}
   52.30 +      {  printf "%7s%-14s", "", time2str(str2time(m, "%m"), "%B");
   52.31 +         printf{0..0: m < t+2} "   ";
   52.32 +      }
   52.33 +      printf "\n";
   52.34 +      for {m in t..t+2}
   52.35 +      {  printf "  S  M Tu  W Th  F  S";
   52.36 +         printf{0..0: m < t+2} "   ";
   52.37 +      }
   52.38 +      printf "\n";
   52.39 +      for {k in 0..5}
   52.40 +      {  for {m in t..t+2}
   52.41 +         {  for {d in 0..6}
   52.42 +            {  printf{0..0: cal[m,k,d]  = 0} "   ";
   52.43 +               printf{0..0: cal[m,k,d] != 0} " %2d", cal[m,k,d];
   52.44 +            }
   52.45 +            printf{0..0: m < t+2} "   ";
   52.46 +         }
   52.47 +         printf "\n";
   52.48 +      }
   52.49 +}
   52.50 +printf "\n";
   52.51 +
   52.52 +end;
    53.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    53.2 +++ b/deps/glpk/examples/cf12a.mod	Sun Nov 06 20:59:10 2011 +0100
    53.3 @@ -0,0 +1,81 @@
    53.4 +/*
    53.5 +
    53.6 +  Curve fitting problem 12.11(a) H P Williams "Model Building in Mathematical Programming"
    53.7 +
    53.8 +  Dr. H J Mackenzie
    53.9 +  HARD software
   53.10 +  hjm@hardsoftware.com
   53.11 +
   53.12 +  2006-01-05
   53.13 +
   53.14 + */
   53.15 +
   53.16 +# set of points
   53.17 +
   53.18 +set I;
   53.19 +
   53.20 +# independent variable
   53.21 +
   53.22 +param x {i in I};
   53.23 +
   53.24 +# dependent variable
   53.25 +
   53.26 +param y {i in I};
   53.27 +
   53.28 +# output input values
   53.29 +
   53.30 +printf {i in I} "x = %.1f; y = %.1f\n", x[i], y[i];
   53.31 +
   53.32 +# define equation variables
   53.33 +
   53.34 +var a;
   53.35 +
   53.36 +var b;
   53.37 +
   53.38 +var u {i in I}, >= 0;
   53.39 +
   53.40 +var v {i in I}, >= 0;
   53.41 +
   53.42 +# define objective function
   53.43 +
   53.44 +minimize error: sum {i in I} u[i] + sum {i in I} v[i];
   53.45 +
   53.46 +# define equation constraint
   53.47 +
   53.48 +s.t. equation {i in I} : b * x[i] + a + u[i] - v[i] = y[i];
   53.49 +
   53.50 +solve;
   53.51 +
   53.52 +printf "y = %.4fx + %.4f\n", b, a;
   53.53 +
   53.54 +/*
   53.55 + *
   53.56 + * DATA section
   53.57 + *
   53.58 + */
   53.59 +
   53.60 +data;
   53.61 +
   53.62 +param : I :   x    y :=
   53.63 +        1     0    1
   53.64 +        2   0.5  0.9
   53.65 +        3     1  0.7
   53.66 +        4   1.5  1.5
   53.67 +        5   1.9    2
   53.68 +        6   2.5  2.4
   53.69 +        7     3  3.2
   53.70 +        8   3.5    2
   53.71 +        9     4  2.7
   53.72 +       10   4.5  3.5
   53.73 +       11     5    1
   53.74 +       12   5.5    4
   53.75 +       13     6  3.6
   53.76 +       14   6.6  2.7
   53.77 +       15     7  5.7
   53.78 +       16   7.6  4.6
   53.79 +       17   8.5    6
   53.80 +       18     9  6.8
   53.81 +       19    10  7.3
   53.82 +;
   53.83 +
   53.84 +end;
    54.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    54.2 +++ b/deps/glpk/examples/cf12b.mod	Sun Nov 06 20:59:10 2011 +0100
    54.3 @@ -0,0 +1,88 @@
    54.4 +/*
    54.5 +
    54.6 +  Curve fitting problem 12.11(b) H P Williams "Model Building in Mathematical Programming"
    54.7 +
    54.8 +  Dr. H J Mackenzie
    54.9 +  HARD software
   54.10 +  hjm@hardsoftware.com
   54.11 +
   54.12 +  2006-01-23
   54.13 +
   54.14 + */
   54.15 +
   54.16 +# set of points
   54.17 +
   54.18 +set I;
   54.19 +
   54.20 +# independent variable
   54.21 +
   54.22 +param x {i in I};
   54.23 +
   54.24 +# dependent variable
   54.25 +
   54.26 +param y {i in I};
   54.27 +
   54.28 +# output input values
   54.29 +
   54.30 +printf {i in I} "x = %.1f; y = %.1f\n", x[i], y[i];
   54.31 +
   54.32 +# define equation variables
   54.33 +
   54.34 +var a;
   54.35 +
   54.36 +var b;
   54.37 +
   54.38 +var u {i in I}, >= 0;
   54.39 +
   54.40 +var v {i in I}, >= 0;
   54.41 +
   54.42 +var z;
   54.43 +
   54.44 +# define objective function
   54.45 +
   54.46 +minimize deviation: z;
   54.47 +
   54.48 +# define equation constraint
   54.49 +
   54.50 +s.t. equation {i in I} : b * x[i] + a + u[i] - v[i] = y[i];
   54.51 +
   54.52 +# define deviation constrains
   54.53 +
   54.54 +s.t. u_deviation {i in I} : z - u[i] >= 0;
   54.55 +s.t. v_deviation {i in I} : z - v[i] >= 0;
   54.56 +
   54.57 +solve;
   54.58 +
   54.59 +printf "y = %.4fx + %.4f Max deviation = %.4f\n", b, a, z;
   54.60 +
   54.61 +/*
   54.62 + *
   54.63 + * DATA section
   54.64 + *
   54.65 + */
   54.66 +
   54.67 +data;
   54.68 +
   54.69 +param : I :   x    y :=
   54.70 +        1     0    1
   54.71 +        2   0.5  0.9
   54.72 +        3     1  0.7
   54.73 +        4   1.5  1.5
   54.74 +        5   1.9    2
   54.75 +        6   2.5  2.4
   54.76 +        7     3  3.2
   54.77 +        8   3.5    2
   54.78 +        9     4  2.7
   54.79 +       10   4.5  3.5
   54.80 +       11     5    1
   54.81 +       12   5.5    4
   54.82 +       13     6  3.6
   54.83 +       14   6.6  2.7
   54.84 +       15     7  5.7
   54.85 +       16   7.6  4.6
   54.86 +       17   8.5    6
   54.87 +       18     9  6.8
   54.88 +       19    10  7.3
   54.89 +;
   54.90 +
   54.91 +end;
    55.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    55.2 +++ b/deps/glpk/examples/cflsq.mod	Sun Nov 06 20:59:10 2011 +0100
    55.3 @@ -0,0 +1,51 @@
    55.4 +/*Curve fitting problem by Least Squares
    55.5 +  Nigel_Galloway@operamail.com
    55.6 +  October 1st., 2007
    55.7 +*/
    55.8 +set Sample;
    55.9 +param Sx {z in Sample};
   55.10 +param Sy {z in Sample};
   55.11 +
   55.12 +var X;
   55.13 +var Y;
   55.14 +var Ex{z in Sample};
   55.15 +var Ey{z in Sample};
   55.16 +
   55.17 +/* sum of variances is zero for Sx*/
   55.18 +variencesX{z in Sample}: X + Ex[z] = Sx[z];
   55.19 +zumVariancesX: sum{z in Sample} Ex[z] = 0;
   55.20 +/* sum of variances is zero for Sy*/
   55.21 +variencesY{z in Sample}: Y + Ey[z] = Sy[z];
   55.22 +zumVariancesY: sum{z in Sample} Ey[z] = 0;
   55.23 +
   55.24 +solve;
   55.25 +
   55.26 +param b1 := (sum{z in Sample} Ex[z]*Ey[z])/(sum{z in Sample} Ex[z]*Ex[z]);
   55.27 +printf "\nbest linear fit is:\n\ty = %f %s %fx\n\n", Y-b1*X, if b1 < 0 then "-" else "+", abs(b1);
   55.28 +
   55.29 +data;
   55.30 +
   55.31 +param:
   55.32 +Sample:   Sx    Sy :=
   55.33 +  1         0    1
   55.34 +  2       0.5  0.9
   55.35 +  3         1  0.7
   55.36 +  4       1.5  1.5
   55.37 +  5       1.9    2
   55.38 +  6       2.5  2.4
   55.39 +  7         3  3.2
   55.40 +  8       3.5    2
   55.41 +  9         4  2.7
   55.42 + 10       4.5  3.5
   55.43 + 11         5    1
   55.44 + 12       5.5    4
   55.45 + 13         6  3.6
   55.46 + 14       6.6  2.7
   55.47 + 15         7  5.7
   55.48 + 16       7.6  4.6
   55.49 + 17       8.5    6
   55.50 + 18         9  6.8
   55.51 + 19        10  7.3
   55.52 +;
   55.53 +
   55.54 +end;
    56.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    56.2 +++ b/deps/glpk/examples/color.mod	Sun Nov 06 20:59:10 2011 +0100
    56.3 @@ -0,0 +1,113 @@
    56.4 +/* COLOR, Graph Coloring Problem */
    56.5 +
    56.6 +/* Written in GNU MathProg by Andrew Makhorin <mao@gnu.org> */
    56.7 +
    56.8 +/* Given an undirected loopless graph G = (V, E), where V is a set of
    56.9 +   nodes, E <= V x V is a set of arcs, the Graph Coloring Problem is to
   56.10 +   find a mapping (coloring) F: V -> C, where C = {1, 2, ... } is a set
   56.11 +   of colors whose cardinality is as small as possible, such that
   56.12 +   F(i) != F(j) for every arc (i,j) in E, that is adjacent nodes must
   56.13 +   be assigned different colors. */
   56.14 +
   56.15 +param n, integer, >= 2;
   56.16 +/* number of nodes */
   56.17 +
   56.18 +set V := {1..n};
   56.19 +/* set of nodes */
   56.20 +
   56.21 +set E, within V cross V;
   56.22 +/* set of arcs */
   56.23 +
   56.24 +check{(i,j) in E}: i != j;
   56.25 +/* there must be no loops */
   56.26 +
   56.27 +/* We need to estimate an upper bound of the number of colors |C|.
   56.28 +   The number of nodes |V| can be used, however, for sparse graphs such
   56.29 +   bound is not very good. To obtain a more suitable estimation we use
   56.30 +   an easy "greedy" heuristic. Let nodes 1, ..., i-1 are already
   56.31 +   assigned some colors. To assign a color to node i we see if there is
   56.32 +   an existing color not used for coloring nodes adjacent to node i. If
   56.33 +   so, we use this color, otherwise we introduce a new color. */
   56.34 +
   56.35 +set EE := setof{(i,j) in E} (i,j) union setof{(i,j) in E} (j,i);
   56.36 +/* symmetrisized set of arcs */
   56.37 +
   56.38 +param z{i in V, case in 0..1} :=
   56.39 +/* z[i,0] = color index assigned to node i
   56.40 +   z[i,1] = maximal color index used for nodes 1, 2, ..., i-1 which are
   56.41 +            adjacent to node i */
   56.42 +(  if case = 0 then
   56.43 +   (  /* compute z[i,0] */
   56.44 +      min{c in 1..z[i,1]}
   56.45 +      (  if not exists{j in V: j < i and (i,j) in EE} z[j,0] = c then
   56.46 +            c
   56.47 +         else
   56.48 +            z[i,1] + 1
   56.49 +      )
   56.50 +   )
   56.51 +   else
   56.52 +   (  /* compute z[i,1] */
   56.53 +      if not exists{j in V: j < i} (i,j) in EE then
   56.54 +         1
   56.55 +      else
   56.56 +         max{j in V: j < i and (i,j) in EE} z[j,0]
   56.57 +   )
   56.58 +);
   56.59 +
   56.60 +check{(i,j) in E}: z[i,0] != z[j,0];
   56.61 +/* check that all adjacent nodes are assigned distinct colors */
   56.62 +
   56.63 +param nc := max{i in V} z[i,0];
   56.64 +/* number of colors used by the heuristic; obviously, it is an upper
   56.65 +   bound of the optimal solution */
   56.66 +
   56.67 +display nc;
   56.68 +
   56.69 +var x{i in V, c in 1..nc}, binary;
   56.70 +/* x[i,c] = 1 means that node i is assigned color c */
   56.71 +
   56.72 +var u{c in 1..nc}, binary;
   56.73 +/* u[c] = 1 means that color c is used, i.e. assigned to some node */
   56.74 +
   56.75 +s.t. map{i in V}: sum{c in 1..nc} x[i,c] = 1;
   56.76 +/* each node must be assigned exactly one color */
   56.77 +
   56.78 +s.t. arc{(i,j) in E, c in 1..nc}: x[i,c] + x[j,c] <= u[c];
   56.79 +/* adjacent nodes cannot be assigned the same color */
   56.80 +
   56.81 +minimize obj: sum{c in 1..nc} u[c];
   56.82 +/* objective is to minimize the number of colors used */
   56.83 +
   56.84 +data;
   56.85 +
   56.86 +/* These data correspond to the instance myciel3.col from:
   56.87 +   http://mat.gsia.cmu.edu/COLOR/instances.html */
   56.88 +
   56.89 +/* The optimal solution is 4 */
   56.90 +
   56.91 +param n := 11;
   56.92 +
   56.93 +set E :=
   56.94 + 1 2
   56.95 + 1 4
   56.96 + 1 7
   56.97 + 1 9
   56.98 + 2 3
   56.99 + 2 6
  56.100 + 2 8
  56.101 + 3 5
  56.102 + 3 7
  56.103 + 3 10
  56.104 + 4 5
  56.105 + 4 6
  56.106 + 4 10
  56.107 + 5 8
  56.108 + 5 9
  56.109 + 6 11
  56.110 + 7 11
  56.111 + 8 11
  56.112 + 9 11
  56.113 + 10 11
  56.114 +;
  56.115 +
  56.116 +end;
    57.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    57.2 +++ b/deps/glpk/examples/cplex/README	Sun Nov 06 20:59:10 2011 +0100
    57.3 @@ -0,0 +1,44 @@
    57.4 +The program module in this subdirectory is a crude implementation of
    57.5 +CPLEX-like interface to GLPK API. It consists of two files: cplex.c and
    57.6 +cplex.h.
    57.7 +
    57.8 +NOTE that this module is NOT a clean room implementation of the CPLEX
    57.9 +callable library. It only implements a CPLEX-like interface to the GLPK
   57.10 +API routines, and its main purpose is to provide possibility to build
   57.11 +and run applications which normally use the CPLEX callable library.
   57.12 +
   57.13 +This module approximately corresponds to CPLEX 9.0.
   57.14 +
   57.15 +Currently this module can be used as a linear programming solver for
   57.16 +Concorde, the state-of-the-art computer code for solving the symmetric
   57.17 +traveling salesman problem (TSP) developed by David Applegate, Robert
   57.18 +Bixby, Vasek Chvatal, and William Cook. For details about Concorde see
   57.19 +its web page at http://www.tsp.gatech.edu/concorde.html.
   57.20 +
   57.21 +To build Concorde along with GLPK you need to do the following:
   57.22 +
   57.23 +1. Configure, build, and install GLPK.
   57.24 +
   57.25 +2. Download the Concorde tarball co031219.tgz (version Dec 19, 2003),
   57.26 +   unpack and unarchive it.
   57.27 +
   57.28 +3. Copy files cplex.h and cplex.c to subdirectory concorde/LP/.
   57.29 +
   57.30 +4. Create file named lpglpk.c in subdirectory concorde/LP/. This file
   57.31 +   must contain the following two lines:
   57.32 +
   57.33 +      #include "cplex.c"
   57.34 +      #include "lpcplex8.c"
   57.35 +
   57.36 +5. Configure Concorde in usual way (./configure) and then build it with
   57.37 +   the following command:
   57.38 +
   57.39 +      make CPPFLAGS=-I. LPSOLVER_INTERFACE=lpglpk.c LPSOLVER_LIB=-lglpk
   57.40 +
   57.41 +   The Concorde executable can be found in subdirectory concorde/TSP/.
   57.42 +
   57.43 +Please note that currently this GLPK interface module does not support
   57.44 +some important features (namely, CPXgetijdiv, CPXmdleave, CPXpivotin,
   57.45 +CPXpivotout, and CPXstrongbranch), so large (more than 1000 nodes) TSP
   57.46 +instances cannot be solved in a reasonable time, and some instances may
   57.47 +cause abnormal termination of Concorde (if CPXgetijdiv is called).
    58.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    58.2 +++ b/deps/glpk/examples/cplex/concorde.txt	Sun Nov 06 20:59:10 2011 +0100
    58.3 @@ -0,0 +1,121 @@
    58.4 +Solver:     Concorde-03.12.19 (options used: -s 99)
    58.5 +            http://www.tsp.gatech.edu/concorde.html
    58.6 +LP Solver:  GLPK 4.34 (CPLEX-like interface module examples/cplex)
    58.7 +Computer:   Intel Pentium 4 CPU 3GHz, 2GB of RAM
    58.8 +Platform:   Cygwin 1.5.24 (Windows XP 5.1 Build 2600 Service Pack 4)
    58.9 +Compiler:   GCC 3.4.4 (options used: -O2)
   58.10 +Test set:   http://www.iwr.uni-heidelberg.de/groups/comopt/software/
   58.11 +            TSPLIB95/
   58.12 +
   58.13 +Problem     Solution   B&B   Time, s
   58.14 +---------   --------   ---   -------
   58.15 +a280            2579     1      3.09
   58.16 +ali535        202339     1     21.88
   58.17 +att48          10628     1      0.20
   58.18 +att532         27686     7     74.31
   58.19 +bayg29          1610     1      0.08
   58.20 +bays29          2020     1      0.08
   58.21 +berlin52        7542     1      0.11
   58.22 +bier127       118282     1      0.62
   58.23 +brazil58       25395     1      0.23
   58.24 +brd14051
   58.25 +brg180          1950     1      0.34
   58.26 +burma14         3323     1      0.06
   58.27 +ch130           6110     1      0.92
   58.28 +ch150           6528     1      1.69
   58.29 +d1291
   58.30 +d15112
   58.31 +d1655
   58.32 +d18512
   58.33 +d198           15780     3      4.92
   58.34 +d2103
   58.35 +d493           35002     5    123.89
   58.36 +d657           48913    11    148.17
   58.37 +dantzig42        699     1      0.08
   58.38 +dsj1000     18660188    13    251.00
   58.39 +eil101                                 (failed due to CPXgetijdiv)
   58.40 +eil51            426     1      0.17
   58.41 +eil76            538     1      0.11
   58.42 +fl1400
   58.43 +fl1577
   58.44 +fl3795
   58.45 +fl417          11861     1     47.20
   58.46 +fnl4461
   58.47 +fri26            937     1      0.05
   58.48 +gil262          2378     3     10.39
   58.49 +gr120           6942     1      0.66
   58.50 +gr137          69853     1      2.09
   58.51 +gr17            2085     1      0.03
   58.52 +gr202          40160     1      3.97
   58.53 +gr21            2707     1      0.03
   58.54 +gr229         134602     7     19.45
   58.55 +gr24            1272     1      0.03
   58.56 +gr431         171414     9     40.67
   58.57 +gr48            5046     1      0.22
   58.58 +gr666         294358     3     40.23
   58.59 +gr96           55209     1      1.22
   58.60 +hk48           11461     1      0.08
   58.61 +kroA100        21282     1      0.41
   58.62 +kroA150        26524     1      2.09
   58.63 +kroA200        29368     1      2.44
   58.64 +kroB100        22141     1      1.20
   58.65 +kroB150        26130     1      1.66
   58.66 +kroB200        29437     1      1.41
   58.67 +kroC100        20749     1      0.42
   58.68 +kroD100        21294     1      0.50
   58.69 +kroE100        22068     1      0.94
   58.70 +lin105         14379     1      0.23
   58.71 +lin318         42029     1      4.28
   58.72 +nrw1379
   58.73 +p654           34643     1     17.08
   58.74 +pa561           2763    15    370.70
   58.75 +pcb1173        56892    11    370.30
   58.76 +pcb3038
   58.77 +pcb442         59778    13     35.86
   58.78 +pla33810
   58.79 +pla7397
   58.80 +pla85900
   58.81 +pr1002        259045     1     23.08
   58.82 +pr107          44303     1      0.38
   58.83 +pr124          59030     1      1.23
   58.84 +pr136          96772     1      2.19
   58.85 +pr144          58537     1      0.89
   58.86 +pr152          73682     1      2.73
   58.87 +pr226          80369     1      2.72
   58.88 +pr2392
   58.89 +pr264          49135     1      1.61
   58.90 +pr299          48191     3     14.52
   58.91 +pr439         107217    15    117.75
   58.92 +pr76          108159     1      0.95
   58.93 +rat195          2323     5     12.91
   58.94 +rat575          6773    19    202.52
   58.95 +rat783          8806     1     37.92
   58.96 +rat99           1211     1      0.50
   58.97 +rd100           7910     1      0.28
   58.98 +rd400          15281    11     74.41
   58.99 +rl11849
  58.100 +rl1304
  58.101 +rl1323
  58.102 +rl1889
  58.103 +rl5915
  58.104 +rl5934
  58.105 +si1032         92650     1     82.09
  58.106 +si175          21407     3      8.97
  58.107 +si535          48450     1     71.28
  58.108 +st70             675     1      0.20
  58.109 +swiss42         1273     1      0.06
  58.110 +ts225         126643     1     21.25
  58.111 +tsp225          3916     1     10.14
  58.112 +u1060         224094    13    507.44
  58.113 +u1432
  58.114 +u159           42080     1      0.41
  58.115 +u1817
  58.116 +u2152
  58.117 +u2319
  58.118 +u574           36905     1     32.84
  58.119 +u724           41910    19    238.42
  58.120 +ulysses16       6859     1      0.19
  58.121 +ulysses22       7013     1      0.47
  58.122 +usa13509
  58.123 +vm1084        239297     9    543.38
  58.124 +vm1748
    59.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    59.2 +++ b/deps/glpk/examples/cplex/cplex.c	Sun Nov 06 20:59:10 2011 +0100
    59.3 @@ -0,0 +1,2130 @@
    59.4 +/* cplex.c (CPLEX-like interface to GLPK API) */
    59.5 +
    59.6 +/***********************************************************************
    59.7 +*  This code is part of GLPK (GNU Linear Programming Kit).
    59.8 +*
    59.9 +*  Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008,
   59.10 +*  2009, 2010, 2011 Andrew Makhorin, Department for Applied Informatics,
   59.11 +*  Moscow Aviation Institute, Moscow, Russia. All rights reserved.
   59.12 +*  E-mail: <mao@gnu.org>.
   59.13 +*
   59.14 +*  GLPK is free software: you can redistribute it and/or modify it
   59.15 +*  under the terms of the GNU General Public License as published by
   59.16 +*  the Free Software Foundation, either version 3 of the License, or
   59.17 +*  (at your option) any later version.
   59.18 +*
   59.19 +*  GLPK is distributed in the hope that it will be useful, but WITHOUT
   59.20 +*  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
   59.21 +*  or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
   59.22 +*  License for more details.
   59.23 +*
   59.24 +*  You should have received a copy of the GNU General Public License
   59.25 +*  along with GLPK. If not, see <http://www.gnu.org/licenses/>.
   59.26 +***********************************************************************/
   59.27 +
   59.28 +#include <ctype.h>
   59.29 +#include <stdarg.h>
   59.30 +#include <stdio.h>
   59.31 +#include <stdlib.h>
   59.32 +#include <string.h>
   59.33 +#include <glpk.h>
   59.34 +#include "cplex.h"
   59.35 +
   59.36 +struct CPXENV
   59.37 +{     /* environment block */
   59.38 +      CPXLP *list;
   59.39 +      /* linked list of problem objects */
   59.40 +      int *intparam; /* int intparam[]; */
   59.41 +      /* integer control parameters */
   59.42 +      double *dblparam; /* double dblparam[]; */
   59.43 +      /* floating-point control parameters */
   59.44 +};
   59.45 +
   59.46 +struct CPXLP
   59.47 +{     /* problem object */
   59.48 +      CPXENV *env;
   59.49 +      /* pointer to environment block */
   59.50 +      glp_prob *prob;
   59.51 +      /* pointer to underlying GLPK problem object */
   59.52 +      int rflen;
   59.53 +      /* length of the array rflag */
   59.54 +      char *rflag; /* char rflag[rflen]; */
   59.55 +      /* rflag[i], i = 0,...,nrows-1, is a flag of i-th row: */
   59.56 +#define RF_NOT_RANGED   0  /* not ranged */
   59.57 +#define RF_RANGED_POS   1  /* ranged, RHS = lower bound */
   59.58 +#define RF_RANGED_NEG   2  /* ranged, RHS = upper bound */
   59.59 +      int stat;
   59.60 +      /* solution status reported by CPXgetstat; zero means no solution
   59.61 +         exists */
   59.62 +      int meth;
   59.63 +      /* method indicator reported by CPXgetmethod */
   59.64 +      int iwlen;
   59.65 +      /* length of the working array */
   59.66 +      int *iwork; /* int iwork[iwlen] */
   59.67 +      /* working array initialized by binary zeros */
   59.68 +      CPXLP *link;
   59.69 +      /* pointer to another problem object */
   59.70 +};
   59.71 +
   59.72 +struct intparam
   59.73 +{     int which;
   59.74 +      int defv;
   59.75 +      int minv;
   59.76 +      int maxv;
   59.77 +};
   59.78 +
   59.79 +struct dblparam
   59.80 +{     int which;
   59.81 +      double defv;
   59.82 +      double minv;
   59.83 +      double maxv;
   59.84 +};
   59.85 +
   59.86 +struct errstring
   59.87 +{     int code;
   59.88 +      const char *string;
   59.89 +};
   59.90 +
   59.91 +#define BIGINT 2100000000
   59.92 +#define BIGDBL 1e75
   59.93 +
   59.94 +static const struct intparam intparam[] =
   59.95 +{     {CPX_PARAM_ADVIND, 0, 0, 2},
   59.96 +      {CPX_PARAM_AGGIND, -1, -1, BIGINT},
   59.97 +      {CPX_PARAM_DATACHECK, CPX_OFF, CPX_OFF, CPX_ON},
   59.98 +      {CPX_PARAM_DPRIIND, CPX_DPRIIND_AUTO, CPX_DPRIIND_AUTO,
   59.99 +         CPX_DPRIIND_DEVEX},
  59.100 +      {CPX_PARAM_FASTMIP, CPX_OFF, CPX_OFF, CPX_ON}, /* ??? */
  59.101 +      {CPX_PARAM_ITLIM, BIGINT, 0, BIGINT},
  59.102 +      {CPX_PARAM_PERIND, CPX_OFF, CPX_OFF, CPX_ON},
  59.103 +      {CPX_PARAM_PPRIIND, CPX_PPRIIND_AUTO, CPX_PPRIIND_PARTIAL,
  59.104 +         CPX_PPRIIND_FULL},
  59.105 +      {CPX_PARAM_PREIND, CPX_ON, CPX_OFF, CPX_ON},
  59.106 +      {CPX_PARAM_REINV, 0, 0, 10000},
  59.107 +      {CPX_PARAM_SCRIND, CPX_OFF, CPX_OFF, CPX_ON},
  59.108 +      {CPX_PARAM_SIMDISPLAY, 1, 0, 2},
  59.109 +};
  59.110 +
  59.111 +static const struct dblparam dblparam[] =
  59.112 +{     {CPX_PARAM_EPOPT, 1e-6, 1e-9, 1e-1},
  59.113 +      {CPX_PARAM_EPPER, 1e-6, 1e-8, BIGDBL},
  59.114 +      {CPX_PARAM_EPRHS, 1e-6, 1e-9, 1e-1},
  59.115 +      {CPX_PARAM_OBJLLIM, -BIGDBL, -BIGDBL, +BIGDBL},
  59.116 +      {CPX_PARAM_OBJULIM, +BIGDBL, -BIGDBL, +BIGDBL},
  59.117 +};
  59.118 +
  59.119 +static const struct errstring errstring[] =
  59.120 +{     {CPXERR_ARRAY_NOT_ASCENDING, "Array entry %d not ascending"},
  59.121 +      {CPXERR_BAD_ARGUMENT, "Invalid argument"},
  59.122 +      {CPXERR_BAD_CTYPE, "Invalid ctype entry %d"},
  59.123 +      {CPXERR_BAD_FILETYPE, "Invalid filetype"},
  59.124 +      {CPXERR_BAD_LUB, "Invalid bound change indicator entry %d"},
  59.125 +      {CPXERR_BAD_PARAM_NUM, "Invalid parameter number"},
  59.126 +      {CPXERR_BAD_SENSE, "Invalid sense entry %d"},
  59.127 +      {CPXERR_BAD_STATUS, "Invalid status entry %d for basis specificat"
  59.128 +         "ion"},
  59.129 +      {CPXERR_COL_INDEX_RANGE, "Column index %d out of range"},
  59.130 +      {CPXERR_COUNT_RANGE, "Count entry %d negative or larger than allo"
  59.131 +         "wed"},
  59.132 +      {CPXERR_DUP_ENTRY, "Duplicate entry"},
  59.133 +      {CPXERR_FAIL_OPEN_WRITE, "Could not open file '%s' for writing"},
  59.134 +      {CPXERR_INDEX_RANGE, "Index is outside range of valid values"},
  59.135 +      {CPXERR_NEGATIVE_SURPLUS, "Insufficient array length"},
  59.136 +      {CPXERR_NO_BASIC_SOLN, "No basic solution exists"},
  59.137 +      {CPXERR_NO_ENVIRONMENT, "No environment exists"},
  59.138 +      {CPXERR_NO_FILENAME, "File name not specified"},
  59.139 +      {CPXERR_NO_MEMORY, "Out of memory"},
  59.140 +      {CPXERR_NO_PROBLEM, "No problem exists"},
  59.141 +      {CPXERR_NO_SOLN, "No solution exists"},
  59.142 +      {CPXERR_NOT_FIXED, "Only fixed variables are pivoted out"},
  59.143 +      {CPXERR_NULL_NAME, "Null pointer %d in name array"},
  59.144 +      {CPXERR_NULL_POINTER, "Null pointer for required data"},
  59.145 +      {CPXERR_PARAM_TOO_BIG, "Parameter value too big"},
  59.146 +      {CPXERR_PARAM_TOO_SMALL, "Parameter value too small"},
  59.147 +      {CPXERR_ROW_INDEX_RANGE, "Row index %d out of range"},
  59.148 +};
  59.149 +
  59.150 +/**********************************************************************/
  59.151 +
  59.152 +#define xassert glp_assert
  59.153 +#define xprintf glp_printf
  59.154 +#define xmalloc glp_malloc
  59.155 +#define xcalloc glp_calloc
  59.156 +#define xfree   glp_free
  59.157 +
  59.158 +/**********************************************************************/
  59.159 +
  59.160 +static int findintparam(int whichparam)
  59.161 +{     int k, card;
  59.162 +      card = sizeof(intparam) / sizeof(struct intparam);
  59.163 +      for (k = 0; k < card; k++)
  59.164 +         if (intparam[k].which == whichparam) return k;
  59.165 +      return -1;
  59.166 +}
  59.167 +
  59.168 +static int getintparam(CPXENV *env, int whichparam)
  59.169 +{     int k;
  59.170 +      xassert(env != NULL);
  59.171 +      k = findintparam(whichparam);
  59.172 +      xassert(k >= 0);
  59.173 +      return env->intparam[k];
  59.174 +}
  59.175 +
  59.176 +static int finddblparam(int whichparam)
  59.177 +{     int k, card;
  59.178 +      card = sizeof(dblparam) / sizeof(struct dblparam);
  59.179 +      for (k = 0; k < card; k++)
  59.180 +         if (dblparam[k].which == whichparam) return k;
  59.181 +      return -1;
  59.182 +}
  59.183 +
  59.184 +static double getdblparam(CPXENV *env, int whichparam)
  59.185 +{     int k;
  59.186 +      xassert(env != NULL);
  59.187 +      k = finddblparam(whichparam);
  59.188 +      xassert(k >= 0);
  59.189 +      return env->dblparam[k];
  59.190 +}
  59.191 +
  59.192 +static const char *finderrstring(int errcode)
  59.193 +{     int k, card;
  59.194 +      card = sizeof(errstring) / sizeof(struct errstring);
  59.195 +      for (k = 0; k < card; k++)
  59.196 +      {  if (errstring[k].code == errcode)
  59.197 +            return errstring[k].string;
  59.198 +      }
  59.199 +      return NULL;
  59.200 +}
  59.201 +
  59.202 +static int error(CPXENV *env, int errcode, ...)
  59.203 +{     va_list arg;
  59.204 +      char buffer[510];
  59.205 +      xassert(env != NULL);
  59.206 +      if (getintparam(env, CPX_PARAM_SCRIND) == CPX_ON)
  59.207 +      {  xassert(CPXgeterrorstring(env, errcode, buffer) == buffer);
  59.208 +         va_start(arg, errcode);
  59.209 +         vprintf(buffer, arg);
  59.210 +         va_end(arg);
  59.211 +      }
  59.212 +      return errcode;
  59.213 +}
  59.214 +
  59.215 +static int checkenv(CPXENV *env)
  59.216 +{     int errcode;
  59.217 +      if (env == NULL)
  59.218 +         errcode = CPXERR_NO_ENVIRONMENT;
  59.219 +      else
  59.220 +         errcode = 0;
  59.221 +      return errcode;
  59.222 +}
  59.223 +
  59.224 +static checklp(CPXENV *env, CPXLP *lp)
  59.225 +{     int errcode;
  59.226 +      errcode = checkenv(env);
  59.227 +      if (errcode) goto done;
  59.228 +      if (lp == NULL)
  59.229 +         errcode = error(env, CPXERR_NO_PROBLEM);
  59.230 +done: return errcode;
  59.231 +}
  59.232 +
  59.233 +static void invalidate(CPXLP *lp)
  59.234 +{     lp->stat = 0;
  59.235 +      lp->meth = CPX_ALG_NONE;
  59.236 +      return;
  59.237 +}
  59.238 +
  59.239 +static void enlargerflag(CPXLP *lp)
  59.240 +{     int m;
  59.241 +      xassert(lp != NULL);
  59.242 +      m = glp_get_num_rows(lp->prob);
  59.243 +      if (lp->rflen < m)
  59.244 +      {  int rflen = lp->rflen;
  59.245 +         char *rflag = lp->rflag;
  59.246 +         while (lp->rflen < m)
  59.247 +         {  lp->rflen += lp->rflen;
  59.248 +            xassert(lp->rflen > 0);
  59.249 +         }
  59.250 +         lp->rflag = xcalloc(lp->rflen, sizeof(char));
  59.251 +         memcpy(lp->rflag, rflag, rflen);
  59.252 +         xfree(rflag);
  59.253 +      }
  59.254 +      return;
  59.255 +}
  59.256 +
  59.257 +static void enlargeiwork(CPXLP *lp, int len)
  59.258 +{     xassert(len >= 0);
  59.259 +      if (lp->iwlen < len)
  59.260 +      {  xfree(lp->iwork);
  59.261 +         while (lp->iwlen < len)
  59.262 +         {  lp->iwlen += lp->iwlen;
  59.263 +            xassert(lp->iwlen > 0);
  59.264 +         }
  59.265 +         lp->iwork = xcalloc(lp->iwlen, sizeof(int));
  59.266 +         memset(lp->iwork, 0, lp->iwlen * sizeof(int));
  59.267 +      }
  59.268 +      return;
  59.269 +}
  59.270 +
  59.271 +/**********************************************************************/
  59.272 +
  59.273 +int CPXaddcols(CPXENV *env, CPXLP *lp, int ccnt, int nzcnt,
  59.274 +      const double obj[], const int cmatbeg[], const int cmatind[],
  59.275 +      const double cmatval[], const double lb[], const double ub[],
  59.276 +      char *colname[])
  59.277 +{     int j, k, m, n, beg, end, type, errcode;
  59.278 +      double lbnd, ubnd;
  59.279 +      errcode = checklp(env, lp);
  59.280 +      if (errcode) goto done;
  59.281 +      if (ccnt < 0 || nzcnt < 0)
  59.282 +      {  errcode = error(env, CPXERR_BAD_ARGUMENT);
  59.283 +         goto done;
  59.284 +      }
  59.285 +      if (ccnt > 0)
  59.286 +      {  if (cmatbeg == NULL || cmatind == NULL || cmatval == NULL)
  59.287 +         {  errcode = error(env, CPXERR_NULL_POINTER);
  59.288 +            goto done;
  59.289 +         }
  59.290 +      }
  59.291 +      m = glp_get_num_rows(lp->prob);
  59.292 +      n = glp_get_num_cols(lp->prob);
  59.293 +      enlargeiwork(lp, m);
  59.294 +      for (j = 0; j < ccnt; j++)
  59.295 +      {  beg = cmatbeg[j];
  59.296 +         if (j > 0 && !(cmatbeg[j-1] <= beg))
  59.297 +         {  errcode = error(env, CPXERR_ARRAY_NOT_ASCENDING, j);
  59.298 +            goto done;
  59.299 +         }
  59.300 +         if (!(0 <= beg && beg <= nzcnt))
  59.301 +         {  errcode = error(env, CPXERR_INDEX_RANGE);
  59.302 +            goto done;
  59.303 +         }
  59.304 +         end = (j < ccnt-1 ? cmatbeg[j+1] : nzcnt);
  59.305 +         for (k = beg; k < end; k++)
  59.306 +         {  if (!(0 <= cmatind[k] && cmatind[k] < m))
  59.307 +            {  errcode = error(env, CPXERR_ROW_INDEX_RANGE, k);
  59.308 +               goto done;
  59.309 +            }
  59.310 +         }
  59.311 +         errcode = 0;
  59.312 +         for (k = beg; k < end; k++)
  59.313 +         {  if (lp->iwork[cmatind[k]])
  59.314 +            {  errcode = error(env, CPXERR_DUP_ENTRY);
  59.315 +               break;
  59.316 +            }
  59.317 +            lp->iwork[cmatind[k]] = 1;
  59.318 +         }
  59.319 +         for (k = beg; k < end; k++)
  59.320 +            lp->iwork[cmatind[k]] = 0;
  59.321 +         if (errcode) goto done;
  59.322 +         if (colname != NULL)
  59.323 +         {  if (colname[j] == NULL)
  59.324 +            {  errcode = error(env, CPXERR_NULL_NAME, j);
  59.325 +               goto done;
  59.326 +            }
  59.327 +         }
  59.328 +      }
  59.329 +      errcode = 0;
  59.330 +      invalidate(lp);
  59.331 +      if (ccnt > 0)
  59.332 +         glp_add_cols(lp->prob, ccnt);
  59.333 +      for (j = 0; j < ccnt; j++)
  59.334 +      {  if (colname != NULL)
  59.335 +            glp_set_col_name(lp->prob, n+j+1, colname[j]);
  59.336 +         lbnd = (lb == NULL ? 0.0 : lb[j]);
  59.337 +         ubnd = (ub == NULL ? +CPX_INFBOUND : ub[j]);
  59.338 +         if (lbnd <= -CPX_INFBOUND && ubnd >= +CPX_INFBOUND)
  59.339 +            type = GLP_FR;
  59.340 +         else if (ubnd >= +CPX_INFBOUND)
  59.341 +            type = GLP_LO;
  59.342 +         else if (lbnd <= -CPX_INFBOUND)
  59.343 +            type = GLP_UP;
  59.344 +         else if (lbnd != ubnd)
  59.345 +            type = GLP_DB;
  59.346 +         else
  59.347 +            type = GLP_FX;
  59.348 +         glp_set_col_bnds(lp->prob, n+j+1, type, lbnd, ubnd);
  59.349 +         if (obj != NULL)
  59.350 +            glp_set_obj_coef(lp->prob, n+j+1, obj[j]);
  59.351 +         beg = cmatbeg[j];
  59.352 +         end = (j < ccnt-1 ? cmatbeg[j+1] : nzcnt);
  59.353 +         for (k = beg; k < end; k++)
  59.354 +            lp->iwork[k-beg] = cmatind[k]+1;
  59.355 +         glp_set_mat_col(lp->prob, n+j+1, end-beg, lp->iwork-1,
  59.356 +            cmatval+beg-1);
  59.357 +         for (k = beg; k < end; k++)
  59.358 +            lp->iwork[k-beg] = 0;
  59.359 +      }
  59.360 +done: return errcode;
  59.361 +}
  59.362 +
  59.363 +int CPXaddrows(CPXENV *env, CPXLP *lp, int ccnt, int rcnt, int nzcnt,
  59.364 +      const double rhs[], const char sense[], const int rmatbeg[],
  59.365 +      const int rmatind[], const double rmatval[], char *colname[],
  59.366 +      char *rowname[])
  59.367 +{     int i, j, k, m, n, beg, end, type, errcode;
  59.368 +      double temp;
  59.369 +      errcode = checklp(env, lp);
  59.370 +      if (errcode) goto done;
  59.371 +      if (ccnt < 0 || rcnt < 0 || nzcnt < 0)
  59.372 +      {  errcode = error(env, CPXERR_BAD_ARGUMENT);
  59.373 +         goto done;
  59.374 +      }
  59.375 +      if (rcnt > 0)
  59.376 +      {  if (rmatbeg == NULL || rmatind == NULL || rmatval == NULL)
  59.377 +         {  errcode = error(env, CPXERR_NULL_POINTER);
  59.378 +            goto done;
  59.379 +         }
  59.380 +      }
  59.381 +      m = glp_get_num_rows(lp->prob);
  59.382 +      n = glp_get_num_cols(lp->prob);
  59.383 +      enlargeiwork(lp, n+ccnt);
  59.384 +      for (i = 0; i < rcnt; i++)
  59.385 +      {  if (sense != NULL)
  59.386 +         {  if (!(sense[i] == 'L' || sense[i] == 'E' ||
  59.387 +                  sense[i] == 'G' || sense[i] == 'R'))
  59.388 +            {  errcode = error(env, CPXERR_BAD_SENSE, i);
  59.389 +               goto done;
  59.390 +            }
  59.391 +         }
  59.392 +         beg = rmatbeg[i];
  59.393 +         if (i > 0 && !(rmatbeg[i-1] <= beg))
  59.394 +         {  errcode = error(env, CPXERR_ARRAY_NOT_ASCENDING, i);
  59.395 +            goto done;
  59.396 +         }
  59.397 +         if (!(0 <= beg && beg <= nzcnt))
  59.398 +         {  errcode = error(env, CPXERR_INDEX_RANGE);
  59.399 +            goto done;
  59.400 +         }
  59.401 +         end = (i < rcnt-1 ? rmatbeg[i+1] : nzcnt);
  59.402 +         for (k = beg; k < end; k++)
  59.403 +         {  if (!(0 <= rmatind[k] && rmatind[k] < n+ccnt))
  59.404 +            {  errcode = error(env, CPXERR_COL_INDEX_RANGE, k);
  59.405 +               goto done;
  59.406 +            }
  59.407 +         }
  59.408 +         errcode = 0;
  59.409 +         for (k = beg; k < end; k++)
  59.410 +         {  if (lp->iwork[rmatind[k]])
  59.411 +            {  errcode = error(env, CPXERR_DUP_ENTRY);
  59.412 +               break;
  59.413 +            }
  59.414 +            lp->iwork[rmatind[k]] = 1;
  59.415 +         }
  59.416 +         for (k = beg; k < end; k++)
  59.417 +            lp->iwork[rmatind[k]] = 0;
  59.418 +         if (errcode) goto done;
  59.419 +         if (rowname != NULL)
  59.420 +         {  if (rowname[i] == NULL)
  59.421 +            {  errcode = error(env, CPXERR_NULL_NAME, i);
  59.422 +               goto done;
  59.423 +            }
  59.424 +         }
  59.425 +      }
  59.426 +      for (j = 0; j < ccnt; j++)
  59.427 +      {  if (colname != NULL)
  59.428 +         {  if (colname[j] == NULL)
  59.429 +            {  errcode = error(env, CPXERR_NULL_NAME, j);
  59.430 +               goto done;
  59.431 +            }
  59.432 +         }
  59.433 +      }
  59.434 +      errcode = 0;
  59.435 +      invalidate(lp);
  59.436 +      if (rcnt > 0)
  59.437 +         glp_add_rows(lp->prob, rcnt);
  59.438 +      if (ccnt > 0)
  59.439 +         glp_add_cols(lp->prob, ccnt);
  59.440 +      enlargerflag(lp);
  59.441 +      for (i = 0; i < rcnt; i++)
  59.442 +      {  if (rowname != NULL)
  59.443 +            glp_set_row_name(lp->prob, m+i+1, rowname[i]);
  59.444 +         temp = (rhs == NULL ? 0.0 : rhs[i]);
  59.445 +         if (sense == NULL || sense[i] == 'E')
  59.446 +         {  lp->rflag[m+i] = RF_NOT_RANGED;
  59.447 +            type = GLP_FX;
  59.448 +         }
  59.449 +         else if (sense[i] == 'L')
  59.450 +         {  lp->rflag[m+i] = RF_NOT_RANGED;
  59.451 +            type = GLP_UP;
  59.452 +         }
  59.453 +         else if (sense[i] == 'G')
  59.454 +         {  lp->rflag[m+i] = RF_NOT_RANGED;
  59.455 +            type = GLP_LO;
  59.456 +         }
  59.457 +         else if (sense[i] == 'R')
  59.458 +         {  lp->rflag[m+i] = RF_RANGED_POS;
  59.459 +            type = GLP_FX;
  59.460 +         }
  59.461 +         else
  59.462 +            xassert(sense != sense);
  59.463 +         glp_set_row_bnds(lp->prob, m+i+1, type, temp, temp);
  59.464 +         beg = rmatbeg[i];
  59.465 +         end = (i < rcnt-1 ? rmatbeg[i+1] : nzcnt);
  59.466 +         for (k = beg; k < end; k++)
  59.467 +            lp->iwork[k-beg] = rmatind[k]+1;
  59.468 +         glp_set_mat_row(lp->prob, m+i+1, end-beg, lp->iwork-1,
  59.469 +            rmatval+beg-1);
  59.470 +         for (k = beg; k < end; k++)
  59.471 +            lp->iwork[k-beg] = 0;
  59.472 +      }
  59.473 +      for (j = 0; j < ccnt; j++)
  59.474 +      {  if (colname != NULL)
  59.475 +            glp_set_col_name(lp->prob, n+j+1, colname[j]);
  59.476 +         glp_set_col_bnds(lp->prob, n+j+1, GLP_LO, 0.0, 0.0);
  59.477 +      }
  59.478 +done: return errcode;
  59.479 +}
  59.480 +
  59.481 +int CPXbaropt(CPXENV *env, CPXLP *lp)
  59.482 +{     xassert(env == env);
  59.483 +      xassert(lp == lp);
  59.484 +      xprintf("CPXbaropt: not implemented yet\n");
  59.485 +      exit(EXIT_FAILURE);
  59.486 +      return -1;
  59.487 +}
  59.488 +
  59.489 +int CPXbinvrow(CPXENV *env, CPXLP *lp, int i, double y[])
  59.490 +{     xassert(env == env);
  59.491 +      xassert(lp == lp);
  59.492 +      xassert(i == i);
  59.493 +      xassert(y == y);
  59.494 +      xprintf("CPXbinvrow: not implemented yet\n");
  59.495 +      exit(EXIT_FAILURE);
  59.496 +      return -1;
  59.497 +}
  59.498 +
  59.499 +int CPXchgbds(CPXENV *env, CPXLP *lp, int cnt, const int indices[],
  59.500 +      const char lu[], const double bd[])
  59.501 +{     int j, n, type, errcode;
  59.502 +      double lbnd, ubnd;
  59.503 +      errcode = checklp(env, lp);
  59.504 +      if (errcode) goto done;
  59.505 +      if (cnt < 0)
  59.506 +      {  errcode = error(env, CPXERR_BAD_ARGUMENT);
  59.507 +         goto done;
  59.508 +      }
  59.509 +      if (cnt > 0)
  59.510 +      {  if (indices == NULL || lu == NULL || bd == NULL)
  59.511 +         {  errcode = error(env, CPXERR_NULL_POINTER);
  59.512 +            goto done;
  59.513 +         }
  59.514 +      }
  59.515 +      n = glp_get_num_cols(lp->prob);
  59.516 +      for (j = 0; j < cnt; j++)
  59.517 +      {  if (!(0 <= indices[j] && indices[j] < n))
  59.518 +         {  errcode = error(env, CPXERR_COL_INDEX_RANGE, j);
  59.519 +            goto done;
  59.520 +         }
  59.521 +         if (!(lu[j] == 'L' || lu[j] == 'U' || lu[j] == 'B'))
  59.522 +         {  errcode = error(env, CPXERR_BAD_LUB, j);
  59.523 +            goto done;
  59.524 +         }
  59.525 +      }
  59.526 +      errcode = 0;
  59.527 +      invalidate(lp);
  59.528 +      for (j = 0; j < cnt; j++)
  59.529 +      {  type = glp_get_col_type(lp->prob, indices[j]+1);
  59.530 +         lbnd = glp_get_col_lb(lp->prob, indices[j]+1);
  59.531 +         ubnd = glp_get_col_ub(lp->prob, indices[j]+1);
  59.532 +         if (type == GLP_FR || type == GLP_UP)
  59.533 +            lbnd = -CPX_INFBOUND;
  59.534 +         if (type == GLP_FR || type == GLP_LO)
  59.535 +            ubnd = +CPX_INFBOUND;
  59.536 +         if (lu[j] == 'L')
  59.537 +            lbnd = bd[j];
  59.538 +         else if (lu[j] == 'U')
  59.539 +            ubnd = bd[j];
  59.540 +         else if (lu[j] == 'B')
  59.541 +            lbnd = ubnd = bd[j];
  59.542 +         else
  59.543 +            xassert(lu != lu);
  59.544 +         if (lbnd <= -CPX_INFBOUND && ubnd >= +CPX_INFBOUND)
  59.545 +            type = GLP_FR;
  59.546 +         else if (ubnd >= +CPX_INFBOUND)
  59.547 +            type = GLP_LO;
  59.548 +         else if (lbnd <= -CPX_INFBOUND)
  59.549 +            type = GLP_UP;
  59.550 +         else if (lbnd != ubnd)
  59.551 +            type = GLP_DB;
  59.552 +         else
  59.553 +            type = GLP_FX;
  59.554 +         glp_set_col_bnds(lp->prob, indices[j]+1, type, lbnd, ubnd);
  59.555 +      }
  59.556 +done: return errcode;
  59.557 +}
  59.558 +
  59.559 +int CPXchgcoeflist(CPXENV *env, CPXLP *lp, int numcoefs,
  59.560 +      const int rowlist[], const int collist[], const double vallist[])
  59.561 +{     int i, j, k, m, n, rcnt, ccnt, len, ptr, errcode;
  59.562 +      int *head, *next, *ind;
  59.563 +      double *val;
  59.564 +      errcode = checklp(env, lp);
  59.565 +      if (errcode) goto done;
  59.566 +      if (numcoefs < 0)
  59.567 +      {  errcode = error(env, CPXERR_BAD_ARGUMENT);
  59.568 +         goto done;
  59.569 +      }
  59.570 +      if (numcoefs == 0)
  59.571 +      {  errcode = 0;
  59.572 +         goto done;
  59.573 +      }
  59.574 +      if (rowlist == NULL || collist == NULL || vallist == NULL)
  59.575 +      {  errcode = error(env, CPXERR_NULL_POINTER);
  59.576 +         goto done;
  59.577 +      }
  59.578 +      /* check triplets and determine the number of rows and columns
  59.579 +         to be changed */
  59.580 +      m = glp_get_num_rows(lp->prob);
  59.581 +      n = glp_get_num_cols(lp->prob);
  59.582 +      enlargeiwork(lp, m);
  59.583 +      enlargeiwork(lp, n);
  59.584 +      rcnt = ccnt = 0;
  59.585 +      for (k = 0; k < numcoefs; k++)
  59.586 +      {  i = rowlist[k];
  59.587 +         if (!(0 <= i && i < m))
  59.588 +         {  errcode = error(env, CPXERR_ROW_INDEX_RANGE, i);
  59.589 +            goto done;
  59.590 +         }
  59.591 +         if (!(lp->iwork[i] & 0x01))
  59.592 +            rcnt++, lp->iwork[i] |= 0x01;
  59.593 +         j = collist[k];
  59.594 +         if (!(0 <= j && j < n))
  59.595 +         {  errcode = error(env, CPXERR_COL_INDEX_RANGE, j);
  59.596 +            goto done;
  59.597 +         }
  59.598 +         if (!(lp->iwork[j] & 0x02))
  59.599 +            ccnt++, lp->iwork[j] |= 0x02;
  59.600 +      }
  59.601 +      memset(lp->iwork, 0, m * sizeof(int));
  59.602 +      memset(lp->iwork, 0, n * sizeof(int));
  59.603 +      errcode = 0;
  59.604 +      invalidate(lp);
  59.605 +      if (rcnt <= ccnt)
  59.606 +      {  /* change the matrix by rows */
  59.607 +         /* build the linked list of triplets:
  59.608 +            head[i] is a pointer to first triplet for row i
  59.609 +            next[k] is a pointer to next triplet for the same row */
  59.610 +         head = xcalloc(m, sizeof(int));
  59.611 +         for (i = 0; i < m; i++)
  59.612 +            head[i] = -1;
  59.613 +         next = xcalloc(numcoefs, sizeof(int));
  59.614 +         for (k = 0; k < numcoefs; k++)
  59.615 +         {  i = rowlist[k];
  59.616 +            next[k] = head[i];
  59.617 +            head[i] = k;
  59.618 +         }
  59.619 +         /* check duplicate columns */
  59.620 +         for (i = 0; i < m; i++)
  59.621 +         {  for (k = head[i]; k >= 0; k = next[k])
  59.622 +            {  j = collist[k];
  59.623 +               if (lp->iwork[j])
  59.624 +               {  xfree(head);
  59.625 +                  xfree(next);
  59.626 +                  errcode = error(env, CPXERR_DUP_ENTRY);
  59.627 +                  goto done;
  59.628 +               }
  59.629 +               lp->iwork[j] = 1;
  59.630 +            }
  59.631 +            for (k = head[i]; k >= 0; k = next[k])
  59.632 +               lp->iwork[collist[k]] = 0;
  59.633 +         }
  59.634 +         /* perform operation */
  59.635 +         ind = xcalloc(1+n, sizeof(int));
  59.636 +         val = xcalloc(1+n, sizeof(double));
  59.637 +         for (i = 0; i < m; i++)
  59.638 +         {  if (head[i] < 0) continue;
  59.639 +            len = glp_get_mat_row(lp->prob, i+1, ind, val);
  59.640 +            for (ptr = 1; ptr <= len; ptr++)
  59.641 +            {  j = ind[ptr]-1;
  59.642 +               xassert(lp->iwork[j] == 0);
  59.643 +               lp->iwork[j] = ptr;
  59.644 +            }
  59.645 +            for (k = head[i]; k >= 0; k = next[k])
  59.646 +            {  j = collist[k];
  59.647 +               if (lp->iwork[j] == 0)
  59.648 +                  lp->iwork[j] = ++len;
  59.649 +               ptr = lp->iwork[j];
  59.650 +               ind[ptr] = j+1, val[ptr] = vallist[k];
  59.651 +            }
  59.652 +            glp_set_mat_row(lp->prob, i+1, len, ind, val);
  59.653 +            for (ptr = 1; ptr <= len; ptr++)
  59.654 +               lp->iwork[ind[ptr]-1] = 0;
  59.655 +         }
  59.656 +      }
  59.657 +      else
  59.658 +      {  /* change the matrix by columns */
  59.659 +         /* build the linked lists of triplets:
  59.660 +            head[j] is a pointer to first triplet for column j
  59.661 +            next[k] is a pointer to next triplet for the same column */
  59.662 +         head = xcalloc(n, sizeof(int));
  59.663 +         for (j = 0; j < n; j++)
  59.664 +            head[j] = -1;
  59.665 +         next = xcalloc(numcoefs, sizeof(int));
  59.666 +         for (k = 0; k < numcoefs; k++)
  59.667 +         {  j = collist[k];
  59.668 +            next[k] = head[j];
  59.669 +            head[j] = k;
  59.670 +         }
  59.671 +         /* check duplicate rows */
  59.672 +         for (j = 0; j < n; j++)
  59.673 +         {  for (k = head[j]; k >= 0; k = next[k])
  59.674 +            {  i = rowlist[k];
  59.675 +               if (lp->iwork[i])
  59.676 +               {  xfree(head);
  59.677 +                  xfree(next);
  59.678 +                  errcode = error(env, CPXERR_DUP_ENTRY);
  59.679 +                  goto done;
  59.680 +               }
  59.681 +               lp->iwork[i] = 1;
  59.682 +            }
  59.683 +            for (k = head[j]; k >= 0; k = next[k])
  59.684 +               lp->iwork[rowlist[k]] = 0;
  59.685 +         }
  59.686 +         /* perform operation */
  59.687 +         ind = xcalloc(1+m, sizeof(int));
  59.688 +         val = xcalloc(1+m, sizeof(double));
  59.689 +         for (j = 0; j < n; j++)
  59.690 +         {  if (head[j] < 0) continue;
  59.691 +            len = glp_get_mat_col(lp->prob, j+1, ind, val);
  59.692 +            for (ptr = 1; ptr <= len; ptr++)
  59.693 +            {  i = ind[ptr]-1;
  59.694 +               xassert(lp->iwork[i] == 0);
  59.695 +               lp->iwork[i] = ptr;
  59.696 +            }
  59.697 +            for (k = head[j]; k >= 0; k = next[k])
  59.698 +            {  i = rowlist[k];
  59.699 +               if (lp->iwork[i] == 0)
  59.700 +                  lp->iwork[i] = ++len;
  59.701 +               ptr = lp->iwork[i];
  59.702 +               ind[ptr] = i+1, val[ptr] = vallist[k];
  59.703 +            }
  59.704 +            glp_set_mat_col(lp->prob, j+1, len, ind, val);
  59.705 +            for (ptr = 1; ptr <= len; ptr++)
  59.706 +               lp->iwork[ind[ptr]-1] = 0;
  59.707 +         }
  59.708 +      }
  59.709 +      xfree(head);
  59.710 +      xfree(next);
  59.711 +      xfree(ind);
  59.712 +      xfree(val);
  59.713 +done: return errcode;
  59.714 +}
  59.715 +
  59.716 +void CPXchgobjsen(CPXENV *env, CPXLP *lp, int maxormin)
  59.717 +{     int errcode;
  59.718 +      errcode = checklp(env, lp);
  59.719 +      if (errcode) goto done;
  59.720 +      if (!(maxormin == CPX_MIN || maxormin == CPX_MAX))
  59.721 +      {  errcode = error(env, CPXERR_BAD_ARGUMENT);
  59.722 +         goto done;
  59.723 +      }
  59.724 +      errcode = 0;
  59.725 +      invalidate(lp);
  59.726 +      if (maxormin == CPX_MIN)
  59.727 +         glp_set_obj_dir(lp->prob, GLP_MIN);
  59.728 +      else
  59.729 +         glp_set_obj_dir(lp->prob, GLP_MAX);
  59.730 +done: xassert(errcode == errcode);
  59.731 +      return;
  59.732 +}
  59.733 +
  59.734 +int CPXchgsense(CPXENV *env, CPXLP *lp, int cnt, const int indices[],
  59.735 +      const char sense[])
  59.736 +{     int i, m, type, errcode;
  59.737 +      double rhs;
  59.738 +      errcode = checklp(env, lp);
  59.739 +      if (errcode) goto done;
  59.740 +      if (cnt < 0)
  59.741 +      {  errcode = error(env, CPXERR_BAD_ARGUMENT);
  59.742 +         goto done;
  59.743 +      }
  59.744 +      if (cnt > 0 && (indices == NULL || sense == NULL))
  59.745 +      {  errcode = error(env, CPXERR_NULL_POINTER);
  59.746 +         goto done;
  59.747 +      }
  59.748 +      m = glp_get_num_rows(lp->prob);
  59.749 +      for (i = 0; i < cnt; i++)
  59.750 +      {  if (!(0 <= indices[i] && indices[i] < m))
  59.751 +         {  errcode = error(env, CPXERR_ROW_INDEX_RANGE, i);
  59.752 +            goto done;
  59.753 +         }
  59.754 +         if (!(sense[i] == 'L' || sense[i] == 'E' || sense[i] == 'G' ||
  59.755 +               sense[i] == 'R'))
  59.756 +         {  errcode = error(env, CPXERR_BAD_SENSE, i);
  59.757 +            goto done;
  59.758 +         }
  59.759 +      }
  59.760 +      errcode = 0;
  59.761 +      invalidate(lp);
  59.762 +      for (i = 0; i < cnt; i++)
  59.763 +      {  type = glp_get_row_type(lp->prob, indices[i]+1);
  59.764 +         if (lp->rflag[indices[i]] == RF_NOT_RANGED)
  59.765 +         {  if (type == GLP_LO || type == GLP_FX)
  59.766 +               rhs = glp_get_row_lb(lp->prob, indices[i]+1);
  59.767 +            else if (type == GLP_UP)
  59.768 +               rhs = glp_get_row_ub(lp->prob, indices[i]+1);
  59.769 +            else
  59.770 +               xassert(type != type);
  59.771 +         }
  59.772 +         else if (lp->rflag[indices[i]] == RF_RANGED_POS)
  59.773 +         {  xassert(type == GLP_DB || type == GLP_FX);
  59.774 +            rhs = glp_get_row_lb(lp->prob, indices[i]+1);
  59.775 +         }
  59.776 +         else if (lp->rflag[indices[i]] == RF_RANGED_NEG)
  59.777 +         {  xassert(type == GLP_DB);
  59.778 +            rhs = glp_get_row_ub(lp->prob, indices[i]+1);
  59.779 +         }
  59.780 +         else
  59.781 +            xassert(lp != lp);
  59.782 +         if (sense[i] == 'L')
  59.783 +         {  lp->rflag[indices[i]] = RF_NOT_RANGED;
  59.784 +            type = GLP_UP;
  59.785 +         }
  59.786 +         else if (sense[i] == 'E')
  59.787 +         {  lp->rflag[indices[i]] = RF_NOT_RANGED;
  59.788 +            type = GLP_FX;
  59.789 +         }
  59.790 +         else if (sense[i] == 'G')
  59.791 +         {  lp->rflag[indices[i]] = RF_NOT_RANGED;
  59.792 +            type = GLP_LO;
  59.793 +         }
  59.794 +         else if (sense[i] == 'R')
  59.795 +         {  lp->rflag[indices[i]] = RF_RANGED_POS;
  59.796 +            type = GLP_FX;
  59.797 +         }
  59.798 +         else
  59.799 +            xassert(sense != sense);
  59.800 +         glp_set_row_bnds(lp->prob, indices[i]+1, type, rhs, rhs);
  59.801 +      }
  59.802 +done: return errcode;
  59.803 +}
  59.804 +
  59.805 +int CPXcloseCPLEX(CPXENV **_env)
  59.806 +{     CPXENV *env;
  59.807 +      CPXLP *lp;
  59.808 +      int errcode;
  59.809 +      if (_env == NULL)
  59.810 +      {  errcode = CPXERR_NULL_POINTER;
  59.811 +         goto done;
  59.812 +      }
  59.813 +      env = *_env;
  59.814 +      errcode = checkenv(env);
  59.815 +      if (errcode) goto done;
  59.816 +      while (env->list != NULL)
  59.817 +      {  lp = env->list;
  59.818 +         errcode = CPXfreeprob(env, &lp);
  59.819 +         xassert(!errcode);
  59.820 +      }
  59.821 +      xfree(env->intparam);
  59.822 +      xfree(env->dblparam);
  59.823 +      xfree(env);
  59.824 +      *_env = NULL;
  59.825 +      errcode = 0;
  59.826 +done: return errcode;
  59.827 +}
  59.828 +
  59.829 +int CPXcopybase(CPXENV *env, CPXLP *lp, const int cstat[],
  59.830 +      const int rstat[])
  59.831 +{     int i, j, m, n, stat, errcode;
  59.832 +      errcode = checklp(env, lp);
  59.833 +      if (errcode) goto done;
  59.834 +      m = glp_get_num_rows(lp->prob);
  59.835 +      n = glp_get_num_cols(lp->prob);
  59.836 +      if (m > 0 && rstat == NULL || n > 0 && cstat == NULL)
  59.837 +      {  errcode = error(env, CPXERR_NULL_POINTER);
  59.838 +         goto done;
  59.839 +      }
  59.840 +      for (i = 0; i < m; i++)
  59.841 +      {  if (!(rstat[i] == CPX_AT_LOWER || rstat[i] == CPX_BASIC ||
  59.842 +               rstat[i] == CPX_AT_UPPER))
  59.843 +         {  errcode = error(env, CPXERR_BAD_STATUS, i);
  59.844 +            goto done;
  59.845 +         }
  59.846 +      }
  59.847 +      for (j = 0; j < n; j++)
  59.848 +      {  if (!(cstat[j] == CPX_AT_LOWER || cstat[j] == CPX_BASIC ||
  59.849 +               cstat[j] == CPX_AT_UPPER || cstat[j] == CPX_FREE_SUPER))
  59.850 +         {  errcode = error(env, CPXERR_BAD_STATUS, j);
  59.851 +            goto done;
  59.852 +         }
  59.853 +      }
  59.854 +      errcode = 0;
  59.855 +      invalidate(lp);
  59.856 +      for (i = 0; i < m; i++)
  59.857 +      {  if (rstat[i] == CPX_AT_LOWER)
  59.858 +            stat = GLP_NL;
  59.859 +         else if (rstat[i] == CPX_BASIC)
  59.860 +            stat = GLP_BS;
  59.861 +         else if (rstat[i] == CPX_AT_UPPER)
  59.862 +            stat = GLP_NU;
  59.863 +         else
  59.864 +            xassert(rstat != rstat);
  59.865 +         glp_set_row_stat(lp->prob, i+1, stat);
  59.866 +      }
  59.867 +      for (j = 0; j < n; j++)
  59.868 +      {  if (cstat[j] == CPX_AT_LOWER)
  59.869 +            stat = GLP_NL;
  59.870 +         else if (cstat[j] == CPX_BASIC)
  59.871 +            stat = GLP_BS;
  59.872 +         else if (cstat[j] == CPX_AT_UPPER)
  59.873 +            stat = GLP_NU;
  59.874 +         else if (cstat[j] == CPX_FREE_SUPER)
  59.875 +            stat = GLP_NF;
  59.876 +         else
  59.877 +            xassert(cstat != cstat);
  59.878 +         glp_set_col_stat(lp->prob, j+1, stat);
  59.879 +      }
  59.880 +done: return errcode;
  59.881 +}
  59.882 +
  59.883 +int CPXcopybasednorms(CPXENV *env, CPXLP *lp, const int cstat[],
  59.884 +      const int rstat[], const double dnorm[])
  59.885 +{     int errcode;
  59.886 +      errcode = CPXcopybase(env, lp, cstat, rstat);
  59.887 +      xassert(dnorm == dnorm);
  59.888 +      return errcode;
  59.889 +}
  59.890 +
  59.891 +int CPXcopylp(CPXENV *env, CPXLP *lp, int numcols, int numrows,
  59.892 +      int objsen, const double obj[], const double rhs[],
  59.893 +      const char sense[], const int matbeg[], const int matcnt[],
  59.894 +      const int matind[], const double matval[], const double lb[],
  59.895 +      const double ub[], const double rngval[])
  59.896 +{     int errcode;
  59.897 +      errcode = CPXcopylpwnames(env, lp, numcols, numrows, objsen, obj,
  59.898 +         rhs, sense, matbeg, matcnt, matind, matval, lb, ub, rngval,
  59.899 +         NULL, NULL);
  59.900 +      return errcode;
  59.901 +}
  59.902 +
  59.903 +int CPXcopylpwnames(CPXENV *env, CPXLP *lp, int numcols, int numrows,
  59.904 +      int objsen, const double obj[], const double rhs[],
  59.905 +      const char sense[], const int matbeg[], const int matcnt[],
  59.906 +      const int matind[], const double matval[], const double lb[],
  59.907 +      const double ub[], const double rngval[], char *colname[],
  59.908 +      char *rowname[])
  59.909 +{     int i, j, k, beg, end, type, errcode;
  59.910 +      double lbnd, ubnd;
  59.911 +      char name[255+1];
  59.912 +      errcode = checklp(env, lp);
  59.913 +      if (errcode) goto done;
  59.914 +      if (numcols < 0 || numrows < 0)
  59.915 +      {  errcode = error(env, CPXERR_BAD_ARGUMENT);
  59.916 +         goto done;
  59.917 +      }
  59.918 +      if (!(objsen == CPX_MIN || objsen == CPX_MAX))
  59.919 +      {  errcode = error(env, CPXERR_BAD_ARGUMENT);
  59.920 +         goto done;
  59.921 +      }
  59.922 +      if (numcols > 0)
  59.923 +      {  if (matbeg == NULL || matcnt == NULL || matind == NULL ||
  59.924 +               matval == NULL)
  59.925 +         {  errcode = error(env, CPXERR_NULL_POINTER);
  59.926 +            goto done;
  59.927 +         }
  59.928 +      }
  59.929 +      for (i = 0; i < numrows; i++)
  59.930 +      {  if (sense != NULL)
  59.931 +         {  if (!(sense[i] == 'L' || sense[i] == 'E' ||
  59.932 +                  sense[i] == 'G' || sense[i] == 'R'))
  59.933 +            {  errcode = error(env, CPXERR_BAD_SENSE, i);
  59.934 +               goto done;
  59.935 +            }
  59.936 +         }
  59.937 +         if (rowname != NULL)
  59.938 +         {  if (rowname[i] == NULL)
  59.939 +            {  errcode = error(env, CPXERR_NULL_NAME, i);
  59.940 +               goto done;
  59.941 +            }
  59.942 +         }
  59.943 +      }
  59.944 +      enlargeiwork(lp, numrows);
  59.945 +      for (j = 0; j < numcols; j++)
  59.946 +      {  beg = matbeg[j];
  59.947 +         if (j > 0 && !(matbeg[j-1] <= beg))
  59.948 +         {  errcode = error(env, CPXERR_ARRAY_NOT_ASCENDING, j);
  59.949 +            goto done;
  59.950 +         }
  59.951 +         if (beg < 0)
  59.952 +         {  errcode = error(env, CPXERR_INDEX_RANGE);
  59.953 +            goto done;
  59.954 +         }
  59.955 +         end = beg + matcnt[j];
  59.956 +         if (!(beg <= end) || j < numcols-1 && !(end <= matbeg[j+1]))
  59.957 +         {  errcode = error(env, CPXERR_COUNT_RANGE, j);
  59.958 +            goto done;
  59.959 +         }
  59.960 +         for (k = beg; k < end; k++)
  59.961 +         {  if (!(0 <= matind[k] && matind[k] < numrows))
  59.962 +            {  errcode = error(env, CPXERR_ROW_INDEX_RANGE, k);
  59.963 +               goto done;
  59.964 +            }
  59.965 +         }
  59.966 +         errcode = 0;
  59.967 +         for (k = beg; k < end; k++)
  59.968 +         {  if (lp->iwork[matind[k]])
  59.969 +            {  errcode = error(env, CPXERR_DUP_ENTRY);
  59.970 +               break;
  59.971 +            }
  59.972 +            lp->iwork[matind[k]] = 1;
  59.973 +         }
  59.974 +         for (k = beg; k < end; k++)
  59.975 +            lp->iwork[matind[k]] = 0;
  59.976 +         if (errcode) goto done;
  59.977 +         if (colname != NULL)
  59.978 +         {  if (colname[j] != NULL)
  59.979 +            {  errcode = error(env, CPXERR_NULL_NAME, j);
  59.980 +               goto done;
  59.981 +            }
  59.982 +         }
  59.983 +      }
  59.984 +      errcode = 0;
  59.985 +      invalidate(lp);
  59.986 +      if (glp_get_prob_name(lp->prob) == NULL)
  59.987 +         name[0] = '\0';
  59.988 +      else
  59.989 +         strcpy(name, glp_get_prob_name(lp->prob));
  59.990 +      glp_erase_prob(lp->prob);
  59.991 +      glp_set_prob_name(lp->prob, name);
  59.992 +      if (objsen == CPX_MIN)
  59.993 +         glp_set_obj_dir(lp->prob, GLP_MIN);
  59.994 +      else if (objsen == CPX_MAX)
  59.995 +         glp_set_obj_dir(lp->prob, GLP_MAX);
  59.996 +      else
  59.997 +         xassert(objsen != objsen);
  59.998 +      if (numrows > 0)
  59.999 +         glp_add_rows(lp->prob, numrows);
 59.1000 +      enlargerflag(lp);
 59.1001 +      for (i = 0; i < numrows; i++)
 59.1002 +      {  if (rowname != NULL)
 59.1003 +            glp_set_row_name(lp->prob, i+1, rowname[i]);
 59.1004 +         lbnd = ubnd = (rhs == NULL ? 0.0 : rhs[i]);
 59.1005 +         if (sense == NULL || sense[i] == 'E')
 59.1006 +         {  lp->rflag[i] = RF_NOT_RANGED;
 59.1007 +            type = GLP_FX;
 59.1008 +         }
 59.1009 +         else if (sense[i] == 'L')
 59.1010 +         {  lp->rflag[i] = RF_NOT_RANGED;
 59.1011 +            type = GLP_UP;
 59.1012 +         }
 59.1013 +         else if (sense[i] == 'G')
 59.1014 +         {  lp->rflag[i] = RF_NOT_RANGED;
 59.1015 +            type = GLP_LO;
 59.1016 +         }
 59.1017 +         else if (sense[i] == 'R')
 59.1018 +         {  if (rngval == NULL || rngval[i] == 0.0)
 59.1019 +            {  lp->rflag[i] = RF_RANGED_POS;
 59.1020 +               type = GLP_FX;
 59.1021 +            }
 59.1022 +            else if (rngval[i] > 0.0)
 59.1023 +            {  lp->rflag[i] = RF_RANGED_POS;
 59.1024 +               type = GLP_DB;
 59.1025 +               ubnd += rngval[i];
 59.1026 +            }
 59.1027 +            else /* rngval[i] < 0.0 */
 59.1028 +            {  lp->rflag[i] = RF_RANGED_NEG;
 59.1029 +               type = GLP_DB;
 59.1030 +               lbnd += rngval[i];
 59.1031 +            }
 59.1032 +         }
 59.1033 +         else
 59.1034 +            xassert(sense != sense);
 59.1035 +         glp_set_row_bnds(lp->prob, i+1, type, lbnd, ubnd);
 59.1036 +      }
 59.1037 +      if (numcols > 0)
 59.1038 +         glp_add_cols(lp->prob, numcols);
 59.1039 +      for (j = 0; j < numcols; j++)
 59.1040 +      {  if (colname != NULL)
 59.1041 +            glp_set_col_name(lp->prob, j+1, colname[j]);
 59.1042 +         lbnd = (lb == NULL ? 0.0 : lb[j]);
 59.1043 +         ubnd = (ub == NULL ? +CPX_INFBOUND : ub[j]);
 59.1044 +         if (lbnd <= -CPX_INFBOUND && ubnd >= +CPX_INFBOUND)
 59.1045 +            type = GLP_FR;
 59.1046 +         else if (ubnd >= +CPX_INFBOUND)
 59.1047 +            type = GLP_LO;
 59.1048 +         else if (lbnd <= -CPX_INFBOUND)
 59.1049 +            type = GLP_UP;
 59.1050 +         else if (lbnd != ubnd)
 59.1051 +            type = GLP_DB;
 59.1052 +         else
 59.1053 +            type = GLP_FX;
 59.1054 +         glp_set_col_bnds(lp->prob, j+1, type, lbnd, ubnd);
 59.1055 +         if (obj != NULL)
 59.1056 +            glp_set_obj_coef(lp->prob, j+1, obj[j]);
 59.1057 +         beg = matbeg[j];
 59.1058 +         end = beg + matcnt[j];
 59.1059 +         for (k = beg; k < end; k++)
 59.1060 +            lp->iwork[k-beg] = matind[k]+1;
 59.1061 +         glp_set_mat_col(lp->prob, j+1, end-beg, lp->iwork-1,
 59.1062 +            matval+beg-1);
 59.1063 +         for (k = beg; k < end; k++)
 59.1064 +            lp->iwork[k-beg] = 0;
 59.1065 +      }
 59.1066 +done: return errcode;
 59.1067 +}
 59.1068 +
 59.1069 +CPXLP *CPXcreateprob(CPXENV *env, int *status, const char *probname)
 59.1070 +{     CPXLP *lp = NULL;
 59.1071 +      int errcode;
 59.1072 +      errcode = checkenv(env);
 59.1073 +      if (errcode) goto done;
 59.1074 +      lp = xmalloc(sizeof(struct CPXLP));
 59.1075 +      lp->env = env;
 59.1076 +      lp->prob = glp_create_prob();
 59.1077 +      glp_set_prob_name(lp->prob, probname);
 59.1078 +      lp->rflen = 100;
 59.1079 +      lp->rflag = xcalloc(lp->rflen, sizeof(char));
 59.1080 +      lp->iwlen = 100;
 59.1081 +      lp->iwork = xcalloc(lp->iwlen, sizeof(int));
 59.1082 +      memset(lp->iwork, 0, lp->iwlen * sizeof(int));
 59.1083 +      lp->link = env->list;
 59.1084 +      env->list = lp;
 59.1085 +      invalidate(lp);
 59.1086 +done: if (status != NULL) *status = errcode;
 59.1087 +      return lp;
 59.1088 +}
 59.1089 +
 59.1090 +int CPXdelcols(CPXENV *env, CPXLP *lp, int begin, int end)
 59.1091 +{     int j, n, errcode;
 59.1092 +      errcode = checklp(env, lp);
 59.1093 +      if (errcode) goto done;
 59.1094 +      n = glp_get_num_cols(lp->prob);
 59.1095 +      if (!(0 <= begin && begin <= end && end < n))
 59.1096 +      {  errcode = error(env, CPXERR_INDEX_RANGE);
 59.1097 +         goto done;
 59.1098 +      }
 59.1099 +      errcode = 0;
 59.1100 +      invalidate(lp);
 59.1101 +      enlargeiwork(lp, end-begin+1);
 59.1102 +      for (j = begin; j <= end; j++)
 59.1103 +         lp->iwork[j-begin] = j+1;
 59.1104 +      glp_del_cols(lp->prob, end-begin+1, lp->iwork-1);
 59.1105 +      for (j = begin; j <= end; j++)
 59.1106 +         lp->iwork[j-begin] = 0;
 59.1107 +done: return errcode;
 59.1108 +}
 59.1109 +
 59.1110 +int CPXdelrows(CPXENV *env, CPXLP *lp, int begin, int end)
 59.1111 +{     int i, m, errcode;
 59.1112 +      errcode = checklp(env, lp);
 59.1113 +      if (errcode) goto done;
 59.1114 +      m = glp_get_num_rows(lp->prob);
 59.1115 +      if (!(0 <= begin && begin <= end && end < m))
 59.1116 +      {  errcode = error(env, CPXERR_INDEX_RANGE);
 59.1117 +         goto done;
 59.1118 +      }
 59.1119 +      errcode = 0;
 59.1120 +      invalidate(lp);
 59.1121 +      enlargeiwork(lp, end-begin+1);
 59.1122 +      for (i = begin; i <= end; i++)
 59.1123 +         lp->iwork[i-begin] = i+1;
 59.1124 +      glp_del_rows(lp->prob, end-begin+1, lp->iwork-1);
 59.1125 +      for (i = begin; i <= end; i++)
 59.1126 +         lp->iwork[i-begin] = 0;
 59.1127 +      for (i = end+1; i < m; i++)
 59.1128 +         lp->rflag[i-(end-begin+1)] = lp->rflag[i];
 59.1129 +done: return errcode;
 59.1130 +}
 59.1131 +
 59.1132 +int CPXdelsetcols(CPXENV *env, CPXLP *lp, int delstat[])
 59.1133 +{     xassert(env == env);
 59.1134 +      xassert(lp == lp);
 59.1135 +      xassert(delstat == delstat);
 59.1136 +      xprintf("CPXdelsetcols: not implemented yet\n");
 59.1137 +      exit(EXIT_FAILURE);
 59.1138 +      return -1;
 59.1139 +}
 59.1140 +
 59.1141 +int CPXdelsetrows(CPXENV *env, CPXLP *lp, int delstat[])
 59.1142 +{     int i, m, cnt, ind, errcode;
 59.1143 +      errcode = checklp(env, lp);
 59.1144 +      if (errcode) goto done;
 59.1145 +      m = glp_get_num_rows(lp->prob);
 59.1146 +      if (m > 0 && delstat == NULL)
 59.1147 +      {  errcode = error(env, CPXERR_NULL_POINTER);
 59.1148 +         goto done;
 59.1149 +      }
 59.1150 +      errcode = 0;
 59.1151 +      invalidate(lp);
 59.1152 +      enlargeiwork(lp, m);
 59.1153 +      cnt = ind = 0;
 59.1154 +      for (i = 0; i < m; i++)
 59.1155 +      {  if (delstat[i] == 1)
 59.1156 +         {  delstat[i] = -1;
 59.1157 +            lp->iwork[cnt++] = i+1;
 59.1158 +         }
 59.1159 +         else
 59.1160 +         {  delstat[i] = ind;
 59.1161 +            lp->rflag[ind++] = lp->rflag[i];
 59.1162 +         }
 59.1163 +      }
 59.1164 +      if (cnt > 0)
 59.1165 +         glp_del_rows(lp->prob, cnt, lp->iwork-1);
 59.1166 +      for (i = 0; i < cnt; i++)
 59.1167 +         lp->iwork[i] = 0;
 59.1168 +done: return errcode;
 59.1169 +}
 59.1170 +
 59.1171 +int CPXdualopt(CPXENV *env, CPXLP *lp);
 59.1172 +
 59.1173 +int CPXfreeprob(CPXENV *env, CPXLP **_lp)
 59.1174 +{     CPXLP *lp;
 59.1175 +      int errcode;
 59.1176 +      errcode = checkenv(env);
 59.1177 +      if (errcode) goto done;
 59.1178 +      if (_lp == NULL)
 59.1179 +      {  errcode = error(env, CPXERR_NULL_POINTER);
 59.1180 +         goto done;
 59.1181 +      }
 59.1182 +      lp = *_lp;
 59.1183 +      errcode = checklp(env, lp);
 59.1184 +      if (errcode) goto done;
 59.1185 +      errcode = 0;
 59.1186 +      env = lp->env;
 59.1187 +      if (env->list == lp)
 59.1188 +         env->list = lp->link;
 59.1189 +      else
 59.1190 +      {  CPXLP *pp;
 59.1191 +         for (pp = env->list; pp != NULL; pp = pp->link)
 59.1192 +            if (pp->link == lp) break;
 59.1193 +         xassert(pp != NULL);
 59.1194 +         pp->link = lp->link;
 59.1195 +      }
 59.1196 +      glp_delete_prob(lp->prob);
 59.1197 +      xfree(lp->rflag);
 59.1198 +      xfree(lp->iwork);
 59.1199 +      xfree(lp);
 59.1200 +      *_lp = NULL;
 59.1201 +done: return errcode;
 59.1202 +}
 59.1203 +
 59.1204 +int CPXgetbase(CPXENV *env, CPXLP *lp, int cstat[], int rstat[])
 59.1205 +{     int i, j, m, n, stat, errcode;
 59.1206 +      errcode = checklp(env, lp);
 59.1207 +      if (errcode) goto done;
 59.1208 +      if (!lp->stat)
 59.1209 +      {  errcode = error(env, CPXERR_NO_SOLN);
 59.1210 +         goto done;
 59.1211 +      }
 59.1212 +      if (lp->meth == CPX_ALG_PRIMAL || lp->meth == CPX_ALG_DUAL)
 59.1213 +         ;
 59.1214 +      else
 59.1215 +      {  errcode = error(env, CPXERR_NO_BASIC_SOLN);
 59.1216 +         goto done;
 59.1217 +      }
 59.1218 +      errcode = 0;
 59.1219 +      if (rstat != NULL)
 59.1220 +      {  m = glp_get_num_rows(lp->prob);
 59.1221 +         for (i = 0; i < m; i++)
 59.1222 +         {  stat = glp_get_row_stat(lp->prob, i+1);
 59.1223 +            if (stat == GLP_BS)
 59.1224 +               rstat[i] = CPX_BASIC;
 59.1225 +            else if (lp->rflag[i] == RF_NOT_RANGED || stat != GLP_NU)
 59.1226 +               rstat[i] = CPX_AT_LOWER;
 59.1227 +            else
 59.1228 +               rstat[i] = CPX_AT_UPPER;
 59.1229 +         }
 59.1230 +      }
 59.1231 +      if (cstat != NULL)
 59.1232 +      {  n = glp_get_num_cols(lp->prob);
 59.1233 +         for (j = 0; j < n; j++)
 59.1234 +         {  stat = glp_get_col_stat(lp->prob, j+1);
 59.1235 +            if (stat == GLP_BS)
 59.1236 +               cstat[j] = CPX_BASIC;
 59.1237 +            else if (stat == GLP_NU)
 59.1238 +               cstat[j] = CPX_AT_UPPER;
 59.1239 +            else if (stat == GLP_NF)
 59.1240 +               cstat[j] = CPX_FREE_SUPER;
 59.1241 +            else
 59.1242 +               cstat[j] = CPX_AT_LOWER;
 59.1243 +         }
 59.1244 +      }
 59.1245 +done: return errcode;
 59.1246 +}
 59.1247 +
 59.1248 +int CPXgetbasednorms(CPXENV *env, CPXLP *lp, int cstat[], int rstat[],
 59.1249 +      double dnorm[])
 59.1250 +{     int i, m, errcode;
 59.1251 +      errcode = CPXgetbase(env, lp, cstat, rstat);
 59.1252 +      if (errcode) goto done;
 59.1253 +      if (dnorm != NULL)
 59.1254 +      {  m = glp_get_num_rows(lp->prob);
 59.1255 +         for (i = 0; i < m; i++) dnorm[i] = 1.0;
 59.1256 +      }
 59.1257 +done: return errcode;
 59.1258 +}
 59.1259 +
 59.1260 +int CPXgetbhead(CPXENV *env, CPXLP *lp, int head[], double x[])
 59.1261 +{     xassert(env == env);
 59.1262 +      xassert(lp == lp);
 59.1263 +      xassert(head == head);
 59.1264 +      xassert(x == x);
 59.1265 +      xprintf("CPXgetbhead: not implemented yet\n");
 59.1266 +      exit(EXIT_FAILURE);
 59.1267 +      return -1;
 59.1268 +}
 59.1269 +
 59.1270 +int CPXgetdblparam(CPXENV *env, int whichparam, double *value)
 59.1271 +{     int k, errcode;
 59.1272 +      errcode = checkenv(env);
 59.1273 +      if (errcode) goto done;
 59.1274 +      k = finddblparam(whichparam);
 59.1275 +      if (k < 0)
 59.1276 +      {  errcode = error(env, CPXERR_BAD_PARAM_NUM);
 59.1277 +         goto done;
 59.1278 +      }
 59.1279 +      errcode = 0;
 59.1280 +      if (value != NULL)
 59.1281 +         *value = env->dblparam[k];
 59.1282 +done: return errcode;
 59.1283 +}
 59.1284 +
 59.1285 +int CPXgetdj(CPXENV *env, CPXLP *lp, double dj[], int begin, int end)
 59.1286 +{     int j, n, errcode;
 59.1287 +      errcode = checklp(env, lp);
 59.1288 +      if (errcode) goto done;
 59.1289 +      n = glp_get_num_cols(lp->prob);
 59.1290 +      if (!(0 <= begin && begin <= end && end < n))
 59.1291 +      {  errcode = error(env, CPXERR_INDEX_RANGE);
 59.1292 +         goto done;
 59.1293 +      }
 59.1294 +      if (!lp->stat)
 59.1295 +      {  errcode = error(env, CPXERR_NO_SOLN);
 59.1296 +         goto done;
 59.1297 +      }
 59.1298 +      errcode = 0;
 59.1299 +      if (lp->meth == CPX_ALG_PRIMAL || lp->meth == CPX_ALG_DUAL)
 59.1300 +      {  if (dj != NULL)
 59.1301 +         {  for (j = begin; j <= end; j++)
 59.1302 +               dj[j-begin] = glp_get_col_dual(lp->prob, j+1);
 59.1303 +         }
 59.1304 +      }
 59.1305 +      else
 59.1306 +         xassert(lp != lp);
 59.1307 +done: return errcode;
 59.1308 +}
 59.1309 +
 59.1310 +char *CPXgeterrorstring(CPXENV *env, int errcode, char *buffer)
 59.1311 +{     const char *string;
 59.1312 +      xassert(env == env);
 59.1313 +      string = finderrstring(errcode);
 59.1314 +      if (string == NULL)
 59.1315 +         buffer = NULL;
 59.1316 +      else
 59.1317 +         sprintf(buffer, "CPLEX Error %5d:  %s.\n", errcode, string);
 59.1318 +      return buffer;
 59.1319 +}
 59.1320 +
 59.1321 +int CPXgetijdiv(CPXENV *env, CPXLP *lp, int *idiv, int *jdiv)
 59.1322 +{     xassert(env == env);
 59.1323 +      xassert(lp == lp);
 59.1324 +      xassert(idiv == idiv);
 59.1325 +      xassert(jdiv == jdiv);
 59.1326 +      xprintf("CPXgetijdiv: not implemented yet\n");
 59.1327 +      exit(EXIT_FAILURE);
 59.1328 +      return -1;
 59.1329 +}
 59.1330 +
 59.1331 +int CPXgetintparam(CPXENV *env, int whichparam, int *value)
 59.1332 +{     int k, errcode;
 59.1333 +      errcode = checkenv(env);
 59.1334 +      if (errcode) goto done;
 59.1335 +      k = findintparam(whichparam);
 59.1336 +      if (k < 0)
 59.1337 +      {  errcode = error(env, CPXERR_BAD_PARAM_NUM);
 59.1338 +         goto done;
 59.1339 +      }
 59.1340 +      errcode = 0;
 59.1341 +      if (value != NULL)
 59.1342 +         *value = env->intparam[k];
 59.1343 +done: return errcode;
 59.1344 +}
 59.1345 +
 59.1346 +int CPXgetlb(CPXENV *env, CPXLP *lp, double lb[], int begin, int end)
 59.1347 +{     xassert(env == env);
 59.1348 +      xassert(lp == lp);
 59.1349 +      xassert(lb == lb);
 59.1350 +      xassert(begin == begin);
 59.1351 +      xassert(end == end);
 59.1352 +      xprintf("CPXgetlb: not implemented yet\n");
 59.1353 +      exit(EXIT_FAILURE);
 59.1354 +      return -1;
 59.1355 +}
 59.1356 +
 59.1357 +int CPXgetmethod(CPXENV *env, CPXLP *lp)
 59.1358 +{     int method;
 59.1359 +      if (checklp(env, lp))
 59.1360 +         method = CPX_ALG_NONE;
 59.1361 +      else
 59.1362 +         method = lp->meth;
 59.1363 +      return method;
 59.1364 +}
 59.1365 +
 59.1366 +int CPXgetnumcols(CPXENV *env, CPXLP *lp)
 59.1367 +{     int numcols;
 59.1368 +      if (checklp(env, lp))
 59.1369 +         numcols = 0;
 59.1370 +      else
 59.1371 +         numcols = glp_get_num_cols(lp->prob);
 59.1372 +      return numcols;
 59.1373 +}
 59.1374 +
 59.1375 +int CPXgetnumnz(CPXENV *env, CPXLP *lp)
 59.1376 +{     int numnz;
 59.1377 +      if (checklp(env, lp))
 59.1378 +         numnz = 0;
 59.1379 +      else
 59.1380 +         numnz = glp_get_num_nz(lp->prob);
 59.1381 +      return numnz;
 59.1382 +}
 59.1383 +
 59.1384 +int CPXgetnumrows(CPXENV *env, CPXLP *lp)
 59.1385 +{     int numrows;
 59.1386 +      if (checklp(env, lp))
 59.1387 +         numrows = 0;
 59.1388 +      else
 59.1389 +         numrows = glp_get_num_rows(lp->prob);
 59.1390 +      return numrows;
 59.1391 +}
 59.1392 +
 59.1393 +int CPXgetobjval(CPXENV *env, CPXLP *lp, double *objval)
 59.1394 +{     int errcode;
 59.1395 +      errcode = checklp(env, lp);
 59.1396 +      if (errcode) goto done;
 59.1397 +      if (!lp->stat)
 59.1398 +      {  errcode = error(env, CPXERR_NO_SOLN);
 59.1399 +         goto done;
 59.1400 +      }
 59.1401 +      errcode = 0;
 59.1402 +      if (lp->meth == CPX_ALG_PRIMAL || lp->meth == CPX_ALG_DUAL)
 59.1403 +      {  if (objval != NULL)
 59.1404 +            *objval = glp_get_obj_val(lp->prob);
 59.1405 +      }
 59.1406 +      else
 59.1407 +         xassert(lp != lp);
 59.1408 +done: return errcode;
 59.1409 +}
 59.1410 +
 59.1411 +int CPXgetpi(CPXENV *env, CPXLP *lp, double pi[], int begin, int end)
 59.1412 +{     int i, m, errcode;
 59.1413 +      errcode = checklp(env, lp);
 59.1414 +      if (errcode) goto done;
 59.1415 +      m = glp_get_num_rows(lp->prob);
 59.1416 +      if (!(0 <= begin && begin <= end && end < m))
 59.1417 +      {  errcode = error(env, CPXERR_INDEX_RANGE);
 59.1418 +         goto done;
 59.1419 +      }
 59.1420 +      if (!lp->stat)
 59.1421 +      {  errcode = error(env, CPXERR_NO_SOLN);
 59.1422 +         goto done;
 59.1423 +      }
 59.1424 +      errcode = 0;
 59.1425 +      if (lp->meth == CPX_ALG_PRIMAL || lp->meth == CPX_ALG_DUAL)
 59.1426 +      {  if (pi != NULL)
 59.1427 +         {  for (i = begin; i <= end; i++)
 59.1428 +               pi[i-begin] = glp_get_row_dual(lp->prob, i+1);
 59.1429 +         }
 59.1430 +      }
 59.1431 +      else
 59.1432 +         xassert(lp != lp);
 59.1433 +done: return errcode;
 59.1434 +}
 59.1435 +
 59.1436 +int CPXgetsense(CPXENV *env, CPXLP *lp, char sense[], int begin,
 59.1437 +      int end)
 59.1438 +{     xassert(env == env);
 59.1439 +      xassert(lp == lp);
 59.1440 +      xassert(sense == sense);
 59.1441 +      xassert(begin == begin);
 59.1442 +      xassert(end == end);
 59.1443 +      xprintf("CPXgetsense: not implemented yet\n");
 59.1444 +      exit(EXIT_FAILURE);
 59.1445 +      return -1;
 59.1446 +}
 59.1447 +
 59.1448 +int CPXgetslack(CPXENV *env, CPXLP *lp, double slack[], int begin,
 59.1449 +      int end)
 59.1450 +{     int i, m, type, errcode;
 59.1451 +      double temp;
 59.1452 +      errcode = checklp(env, lp);
 59.1453 +      if (errcode) goto done;
 59.1454 +      m = glp_get_num_rows(lp->prob);
 59.1455 +      if (!(0 <= begin && begin <= end && end < m))
 59.1456 +      {  errcode = error(env, CPXERR_INDEX_RANGE);
 59.1457 +         goto done;
 59.1458 +      }
 59.1459 +      if (!lp->stat)
 59.1460 +      {  errcode = error(env, CPXERR_NO_SOLN);
 59.1461 +         goto done;
 59.1462 +      }
 59.1463 +      errcode = 0;
 59.1464 +      if (lp->meth == CPX_ALG_PRIMAL || lp->meth == CPX_ALG_DUAL)
 59.1465 +      {  if (slack != NULL)
 59.1466 +         {  for (i = begin; i <= end; i++)
 59.1467 +            {  type = glp_get_row_type(lp->prob, i+1);
 59.1468 +               temp = glp_get_row_prim(lp->prob, i+1);
 59.1469 +               if (lp->rflag[i] == RF_NOT_RANGED)
 59.1470 +               {  if (type == GLP_LO || type == GLP_FX)
 59.1471 +                     slack[i-begin] =
 59.1472 +                        glp_get_row_lb(lp->prob, i+1) - temp;
 59.1473 +                  else if (type == GLP_UP)
 59.1474 +                     slack[i-begin] =
 59.1475 +                        glp_get_row_ub(lp->prob, i+1) - temp;
 59.1476 +                  else
 59.1477 +                     xassert(type != type);
 59.1478 +               }
 59.1479 +               else if (lp->rflag[i] == RF_RANGED_POS)
 59.1480 +               {  xassert(type == GLP_DB || type == GLP_FX);
 59.1481 +                  slack[i-begin] =
 59.1482 +                     temp - glp_get_row_lb(lp->prob, i+1);
 59.1483 +               }
 59.1484 +               else if (lp->rflag[i] == RF_RANGED_NEG)
 59.1485 +               {  xassert(type == GLP_DB);
 59.1486 +                  slack[i-begin] =
 59.1487 +                     temp - glp_get_row_ub(lp->prob, i+1);
 59.1488 +               }
 59.1489 +               else
 59.1490 +                  xassert(lp != lp);
 59.1491 +            }
 59.1492 +         }
 59.1493 +      }
 59.1494 +      else
 59.1495 +         xassert(lp != lp);
 59.1496 +done: return errcode;
 59.1497 +}
 59.1498 +
 59.1499 +int CPXgetstat(CPXENV *env, CPXLP *lp)
 59.1500 +{     int stat;
 59.1501 +      if (checklp(env, lp))
 59.1502 +         stat = 0;
 59.1503 +      else
 59.1504 +         stat = lp->stat;
 59.1505 +      return stat;
 59.1506 +}
 59.1507 +
 59.1508 +int CPXgetub(CPXENV *env, CPXLP *lp, double ub[], int begin, int end)
 59.1509 +{     xassert(env == env);
 59.1510 +      xassert(lp == lp);
 59.1511 +      xassert(ub == ub);
 59.1512 +      xassert(begin == begin);
 59.1513 +      xassert(end == end);
 59.1514 +      xprintf("CPXgetub: not implemented yet\n");
 59.1515 +      exit(EXIT_FAILURE);
 59.1516 +      return -1;
 59.1517 +}
 59.1518 +
 59.1519 +int CPXgetweight(CPXENV *env, CPXLP *lp, int rcnt, const int rmatbeg[],
 59.1520 +      const int rmatind[], const double rmatval[], double weight[],
 59.1521 +      int dpriind)
 59.1522 +{     xassert(env == env);
 59.1523 +      xassert(lp == lp);
 59.1524 +      xassert(rcnt == rcnt);
 59.1525 +      xassert(rmatbeg == rmatbeg);
 59.1526 +      xassert(rmatind == rmatind);
 59.1527 +      xassert(rmatval == rmatval);
 59.1528 +      xassert(weight == weight);
 59.1529 +      xassert(dpriind == dpriind);
 59.1530 +      xprintf("CPXgetweight: not implemented yet\n");
 59.1531 +      exit(EXIT_FAILURE);
 59.1532 +      return -1;
 59.1533 +}
 59.1534 +
 59.1535 +int CPXgetx(CPXENV *env, CPXLP *lp, double x[], int begin, int end)
 59.1536 +{     int j, n, errcode;
 59.1537 +      errcode = checklp(env, lp);
 59.1538 +      if (errcode) goto done;
 59.1539 +      n = glp_get_num_cols(lp->prob);
 59.1540 +      if (!(0 <= begin && begin <= end && end < n))
 59.1541 +      {  errcode = error(env, CPXERR_INDEX_RANGE);
 59.1542 +         goto done;
 59.1543 +      }
 59.1544 +      if (!lp->stat)
 59.1545 +      {  errcode = error(env, CPXERR_NO_SOLN);
 59.1546 +         goto done;
 59.1547 +      }
 59.1548 +      errcode = 0;
 59.1549 +      if (lp->meth == CPX_ALG_PRIMAL || lp->meth == CPX_ALG_DUAL)
 59.1550 +      {  if (x != NULL)
 59.1551 +         {  for (j = begin; j <= end; j++)
 59.1552 +               x[j-begin] = glp_get_col_prim(lp->prob, j+1);
 59.1553 +         }
 59.1554 +      }
 59.1555 +      else
 59.1556 +         xassert(lp != lp);
 59.1557 +done: return errcode;
 59.1558 +}
 59.1559 +
 59.1560 +int CPXinfodblparam(CPXENV *env, int whichparam, double *defvalue,
 59.1561 +      double *minvalue, double *maxvalue)
 59.1562 +{     int k, errcode;
 59.1563 +      errcode = checkenv(env);
 59.1564 +      if (errcode) goto done;
 59.1565 +      k = finddblparam(whichparam);
 59.1566 +      if (k < 0)
 59.1567 +      {  errcode = error(env, CPXERR_BAD_PARAM_NUM);
 59.1568 +         goto done;
 59.1569 +      }
 59.1570 +      errcode = 0;
 59.1571 +      if (defvalue != NULL)
 59.1572 +         *defvalue = dblparam[k].defv;
 59.1573 +      if (minvalue != NULL)
 59.1574 +         *minvalue = dblparam[k].minv;
 59.1575 +      if (maxvalue != NULL)
 59.1576 +         *maxvalue = dblparam[k].maxv;
 59.1577 +done: return errcode;
 59.1578 +}
 59.1579 +
 59.1580 +int CPXinfointparam(CPXENV *env, int whichparam, int *defvalue,
 59.1581 +      int *minvalue, int *maxvalue)
 59.1582 +{     int k, errcode;
 59.1583 +      errcode = checkenv(env);
 59.1584 +      if (errcode) goto done;
 59.1585 +      k = findintparam(whichparam);
 59.1586 +      if (k < 0)
 59.1587 +      {  errcode = error(env, CPXERR_BAD_PARAM_NUM);
 59.1588 +         goto done;
 59.1589 +      }
 59.1590 +      errcode = 0;
 59.1591 +      if (defvalue != NULL)
 59.1592 +         *defvalue = intparam[k].defv;
 59.1593 +      if (minvalue != NULL)
 59.1594 +         *minvalue = intparam[k].minv;
 59.1595 +      if (maxvalue != NULL)
 59.1596 +         *maxvalue = intparam[k].maxv;
 59.1597 +done: return errcode;
 59.1598 +}
 59.1599 +
 59.1600 +int CPXmdleave(const CPXENV *env, CPXLP *lp, const int goodlist[],
 59.1601 +      int goodlen, double downratio[], double upratio[])
 59.1602 +{     int k;
 59.1603 +      xassert(env == env);
 59.1604 +      xassert(lp == lp);
 59.1605 +      xassert(goodlist == goodlist);
 59.1606 +      xassert(goodlen >= 0);
 59.1607 +      xassert(downratio != NULL);
 59.1608 +      xassert(upratio != NULL);
 59.1609 +      /* not implemented yet */
 59.1610 +      for (k = 0; k < goodlen; k++)
 59.1611 +         downratio[k] = upratio[k] = 0.0;
 59.1612 +      return 0;
 59.1613 +}
 59.1614 +
 59.1615 +int CPXnewcols(CPXENV *env, CPXLP *lp, int ccnt, const double obj[],
 59.1616 +      const double lb[], const double ub[], const char ctype[],
 59.1617 +      char *colname[])
 59.1618 +{     int j, n, kind, type, errcode;
 59.1619 +      double lbnd, ubnd;
 59.1620 +      errcode = checklp(env, lp);
 59.1621 +      if (errcode) goto done;
 59.1622 +      if (ccnt < 0)
 59.1623 +      {  errcode = error(env, CPXERR_BAD_ARGUMENT);
 59.1624 +         goto done;
 59.1625 +      }
 59.1626 +      for (j = 0; j < ccnt; j++)
 59.1627 +      {  if (ctype != NULL)
 59.1628 +         {  if (!(ctype[j] == 'C' || ctype[j] == 'B' ||
 59.1629 +                  ctype[j] == 'I'))
 59.1630 +            {  errcode = error(env, CPXERR_BAD_CTYPE, j);
 59.1631 +               goto done;
 59.1632 +            }
 59.1633 +         }
 59.1634 +         if (colname != NULL)
 59.1635 +         {  if (colname[j] == NULL)
 59.1636 +            {  errcode = error(env, CPXERR_NULL_NAME, j);
 59.1637 +               goto done;
 59.1638 +            }
 59.1639 +         }
 59.1640 +      }
 59.1641 +      errcode = 0;
 59.1642 +      invalidate(lp);
 59.1643 +      n = glp_get_num_cols(lp->prob);
 59.1644 +      if (ccnt > 0)
 59.1645 +         glp_add_cols(lp->prob, ccnt);
 59.1646 +      for (j = 0; j < ccnt; j++)
 59.1647 +      {  if (colname != NULL)
 59.1648 +            glp_set_col_name(lp->prob, n+j+1, colname[j]);
 59.1649 +         if (obj != NULL)
 59.1650 +            glp_set_obj_coef(lp->prob, n+j+1, obj[j]);
 59.1651 +         lbnd = (lb == NULL ? 0.0 : lb[j]);
 59.1652 +         ubnd = (ub == NULL ? 0.0 : ub[j]);
 59.1653 +         if (lbnd <= -CPX_INFBOUND && ubnd >= +CPX_INFBOUND)
 59.1654 +            type = GLP_FR;
 59.1655 +         else if (ubnd >= +CPX_INFBOUND)
 59.1656 +            type = GLP_LO;
 59.1657 +         else if (lbnd <= -CPX_INFBOUND)
 59.1658 +            type = GLP_UP;
 59.1659 +         else if (lbnd != ubnd)
 59.1660 +            type = GLP_DB;
 59.1661 +         else
 59.1662 +            type = GLP_FX;
 59.1663 +         glp_set_col_bnds(lp->prob, n+j+1, type, lbnd, ubnd);
 59.1664 +         if (ctype != NULL)
 59.1665 +         {  if (ctype[j] == 'C')
 59.1666 +               kind = GLP_CV;
 59.1667 +            else if (ctype[j] == 'B')
 59.1668 +               kind = GLP_BV;
 59.1669 +            else if (ctype[j] == 'I')
 59.1670 +               kind = GLP_IV;
 59.1671 +            else
 59.1672 +               xassert(ctype != ctype);
 59.1673 +            glp_set_col_kind(lp->prob, n+j+1, kind);
 59.1674 +         }
 59.1675 +      }
 59.1676 +done: return errcode;
 59.1677 +}
 59.1678 +
 59.1679 +int CPXnewrows(CPXENV *env, CPXLP *lp, int rcnt, const double rhs[],
 59.1680 +      const char sense[], const double rngval[], char *rowname[])
 59.1681 +{     int i, m, type, errcode;
 59.1682 +      double lbnd, ubnd;
 59.1683 +      errcode = checklp(env, lp);
 59.1684 +      if (errcode) goto done;
 59.1685 +      if (rcnt < 0)
 59.1686 +      {  errcode = error(env, CPXERR_BAD_ARGUMENT);
 59.1687 +         goto done;
 59.1688 +      }
 59.1689 +      for (i = 0; i < rcnt; i++)
 59.1690 +      {  if (sense != NULL)
 59.1691 +         {  if (!(sense[i] == 'L' || sense[i] == 'E' ||
 59.1692 +                  sense[i] == 'G' || sense[i] == 'R'))
 59.1693 +            {  errcode = error(env, CPXERR_BAD_SENSE, i);
 59.1694 +               goto done;
 59.1695 +            }
 59.1696 +         }
 59.1697 +         if (rowname != NULL)
 59.1698 +         {  if (rowname[i] == NULL)
 59.1699 +            {  errcode = error(env, CPXERR_NULL_NAME, i);
 59.1700 +               goto done;
 59.1701 +            }
 59.1702 +         }
 59.1703 +      }
 59.1704 +      errcode = 0;
 59.1705 +      invalidate(lp);
 59.1706 +      m = glp_get_num_rows(lp->prob);
 59.1707 +      if (rcnt > 0)
 59.1708 +         glp_add_rows(lp->prob, rcnt);
 59.1709 +      enlargerflag(lp);
 59.1710 +      for (i = 0; i < rcnt; i++)
 59.1711 +      {  if (rowname != NULL)
 59.1712 +            glp_set_row_name(lp->prob, m+i+1, rowname[i]);
 59.1713 +         lbnd = ubnd = (rhs == NULL ? 0.0 : rhs[i]);
 59.1714 +         if (sense == NULL || sense[i] == 'E')
 59.1715 +         {  lp->rflag[m+i] = RF_NOT_RANGED;
 59.1716 +            type = GLP_FX;
 59.1717 +         }
 59.1718 +         else if (sense[i] == 'L')
 59.1719 +         {  lp->rflag[m+i] = RF_NOT_RANGED;
 59.1720 +            type = GLP_UP;
 59.1721 +         }
 59.1722 +         else if (sense[i] == 'G')
 59.1723 +         {  lp->rflag[m+i] = RF_NOT_RANGED;
 59.1724 +            type = GLP_LO;
 59.1725 +         }
 59.1726 +         else if (sense[i] == 'R')
 59.1727 +         {  if (rngval == NULL || rngval[i] == 0.0)
 59.1728 +            {  lp->rflag[m+i] = RF_RANGED_POS;
 59.1729 +               type = GLP_FX;
 59.1730 +            }
 59.1731 +            else if (rngval[i] > 0.0)
 59.1732 +            {  lp->rflag[m+i] = RF_RANGED_POS;
 59.1733 +               type = GLP_DB;
 59.1734 +               ubnd += rngval[i];
 59.1735 +            }
 59.1736 +            else /* rngval[i] < 0.0 */
 59.1737 +            {  lp->rflag[m+i] = RF_RANGED_NEG;
 59.1738 +               type = GLP_DB;
 59.1739 +               lbnd += rngval[i];
 59.1740 +            }
 59.1741 +         }
 59.1742 +         else
 59.1743 +            xassert(sense != sense);
 59.1744 +         glp_set_row_bnds(lp->prob, m+i+1, type, lbnd, ubnd);
 59.1745 +      }
 59.1746 +done: return errcode;
 59.1747 +}
 59.1748 +
 59.1749 +CPXENV *CPXopenCPLEX(int *status)
 59.1750 +{     CPXENV *env;
 59.1751 +      int k, card;
 59.1752 +      env = xmalloc(sizeof(CPXENV));
 59.1753 +      env->list = NULL;
 59.1754 +      card = sizeof(intparam) / sizeof(struct intparam);
 59.1755 +      env->intparam = xcalloc(card, sizeof(int));
 59.1756 +      for (k = 0; k < card; k++)
 59.1757 +         env->intparam[k] = intparam[k].defv;
 59.1758 +      card = sizeof(dblparam) / sizeof(struct dblparam);
 59.1759 +      env->dblparam = xcalloc(card, sizeof(double));
 59.1760 +      for (k = 0; k < card; k++)
 59.1761 +         env->dblparam[k] = dblparam[k].defv;
 59.1762 +      if (status != NULL) *status = 0;
 59.1763 +      return env;
 59.1764 +}
 59.1765 +
 59.1766 +int CPXpivotin(CPXENV *env, CPXLP *lp, const int rlist[], int rlen)
 59.1767 +{     int i, m, errcode;
 59.1768 +      errcode = checklp(env, lp);
 59.1769 +      if (errcode) goto done;
 59.1770 +      if (rlen < 0)
 59.1771 +      {  errcode = error(env, CPXERR_BAD_ARGUMENT);
 59.1772 +         goto done;
 59.1773 +      }
 59.1774 +      if (rlen > 0 && rlist == NULL)
 59.1775 +      {  errcode = error(env, CPXERR_NULL_POINTER);
 59.1776 +         goto done;
 59.1777 +      }
 59.1778 +      m = glp_get_num_rows(lp->prob);
 59.1779 +      for (i = 0; i < rlen; i++)
 59.1780 +      {  if (!(0 <= rlist[i] && rlist[i] < m))
 59.1781 +         {  errcode = error(env, CPXERR_ROW_INDEX_RANGE, i);
 59.1782 +            goto done;
 59.1783 +         }
 59.1784 +      }
 59.1785 +      errcode = 0;
 59.1786 +      for (i = 0; i < rlen; i++)
 59.1787 +      {  if (glp_get_row_type(lp->prob, rlist[i]+1) != GLP_FX)
 59.1788 +         {  if (glp_get_row_stat(lp->prob, rlist[i]+1) != GLP_BS)
 59.1789 +            {  /* not implemented yet */
 59.1790 +               break;
 59.1791 +            }
 59.1792 +         }
 59.1793 +      }
 59.1794 +done: return errcode;
 59.1795 +}
 59.1796 +
 59.1797 +int CPXpivotout(CPXENV *env, CPXLP *lp, const int clist[], int clen)
 59.1798 +{     int j, n, errcode;
 59.1799 +      errcode = checklp(env, lp);
 59.1800 +      if (errcode) goto done;
 59.1801 +      if (clen < 0)
 59.1802 +      {  errcode = error(env, CPXERR_BAD_ARGUMENT);
 59.1803 +         goto done;
 59.1804 +      }
 59.1805 +      if (clen > 0 && clist == NULL)
 59.1806 +      {  errcode = error(env, CPXERR_NULL_POINTER);
 59.1807 +         goto done;
 59.1808 +      }
 59.1809 +      n = glp_get_num_cols(lp->prob);
 59.1810 +      for (j = 0; j < clen; j++)
 59.1811 +      {  if (!(0 <= clist[j] && clist[j] < n))
 59.1812 +         {  errcode = error(env, CPXERR_COL_INDEX_RANGE, j);
 59.1813 +            goto done;
 59.1814 +         }
 59.1815 +         if (glp_get_col_type(lp->prob, clist[j]+1) != GLP_FX)
 59.1816 +         {  errcode = error(env, CPXERR_NOT_FIXED);
 59.1817 +            goto done;
 59.1818 +         }
 59.1819 +      }
 59.1820 +      errcode = 0;
 59.1821 +      for (j = 0; j < clen; j++)
 59.1822 +      {  if (glp_get_col_stat(lp->prob, clist[j]+1) == GLP_BS)
 59.1823 +         {  /* not implemented yet */
 59.1824 +            break;
 59.1825 +         }
 59.1826 +      }
 59.1827 +done: return errcode;
 59.1828 +}
 59.1829 +
 59.1830 +int CPXprimopt(CPXENV *env, CPXLP *lp);
 59.1831 +
 59.1832 +int CPXsavwrite(CPXENV *env, CPXLP *lp, const char *filename)
 59.1833 +{     xassert(env == env);
 59.1834 +      xassert(lp == lp);
 59.1835 +      xassert(filename == filename);
 59.1836 +      xprintf("CPXsavwrite: not implemented yet\n");
 59.1837 +      exit(EXIT_FAILURE);
 59.1838 +      return -1;
 59.1839 +}
 59.1840 +
 59.1841 +int CPXsetdblparam(CPXENV *env, int whichparam, double newvalue)
 59.1842 +{     int k, errcode;
 59.1843 +      errcode = checkenv(env);
 59.1844 +      if (errcode) goto done;
 59.1845 +      k = finddblparam(whichparam);
 59.1846 +      if (k < 0)
 59.1847 +      {  errcode = error(env, CPXERR_BAD_PARAM_NUM);
 59.1848 +         goto done;
 59.1849 +      }
 59.1850 +      if (newvalue < dblparam[k].minv)
 59.1851 +      {  errcode = error(env, CPXERR_PARAM_TOO_SMALL);
 59.1852 +         goto done;
 59.1853 +      }
 59.1854 +      if (newvalue > dblparam[k].maxv)
 59.1855 +      {  errcode = error(env, CPXERR_PARAM_TOO_BIG);
 59.1856 +         goto done;
 59.1857 +      }
 59.1858 +      errcode = 0;
 59.1859 +      env->dblparam[k] = newvalue;
 59.1860 +done: return errcode;
 59.1861 +}
 59.1862 +
 59.1863 +int CPXsetintparam(CPXENV *env, int whichparam, int newvalue)
 59.1864 +{     int k, errcode;
 59.1865 +      errcode = checkenv(env);
 59.1866 +      if (errcode) goto done;
 59.1867 +      k = findintparam(whichparam);
 59.1868 +      if (k < 0)
 59.1869 +      {  errcode = error(env, CPXERR_BAD_PARAM_NUM);
 59.1870 +         goto done;
 59.1871 +      }
 59.1872 +      if (newvalue < intparam[k].minv)
 59.1873 +      {  errcode = error(env, CPXERR_PARAM_TOO_SMALL);
 59.1874 +         goto done;
 59.1875 +      }
 59.1876 +      if (newvalue > intparam[k].maxv)
 59.1877 +      {  errcode = error(env, CPXERR_PARAM_TOO_BIG);
 59.1878 +         goto done;
 59.1879 +      }
 59.1880 +      errcode = 0;
 59.1881 +      env->intparam[k] = newvalue;
 59.1882 +done: return errcode;
 59.1883 +}
 59.1884 +
 59.1885 +int CPXsolninfo(CPXENV *env, CPXLP *lp, int *solnmethod, int *solntype,
 59.1886 +      int *pfeasind, int *dfeasind)
 59.1887 +{     int type, pfeas, dfeas, errcode;
 59.1888 +      errcode = checklp(env, lp);
 59.1889 +      if (errcode) goto done;
 59.1890 +      errcode = 0;
 59.1891 +      if (!lp->stat)
 59.1892 +         type = CPX_NO_SOLN, pfeas = dfeas = 0;
 59.1893 +      else if (lp->meth == CPX_ALG_PRIMAL || lp->meth == CPX_ALG_DUAL)
 59.1894 +      {  type = CPX_BASIC_SOLN;
 59.1895 +         pfeas = (glp_get_prim_stat(lp->prob) == GLP_FEAS);
 59.1896 +         dfeas = (glp_get_dual_stat(lp->prob) == GLP_FEAS);
 59.1897 +      }
 59.1898 +      else
 59.1899 +         xassert(lp != lp);
 59.1900 +      if (solnmethod != NULL)
 59.1901 +         *solnmethod = lp->meth;
 59.1902 +      if (solntype != NULL)
 59.1903 +         *solntype = type;
 59.1904 +      if (pfeasind != NULL)
 59.1905 +         *pfeasind = pfeas;
 59.1906 +      if (dfeasind != NULL)
 59.1907 +         *dfeasind = dfeas;
 59.1908 +done: return errcode;
 59.1909 +}
 59.1910 +
 59.1911 +int CPXsolution(CPXENV *env, CPXLP *lp, int *lpstat, double *objval,
 59.1912 +      double x[], double pi[], double slack[], double dj[])
 59.1913 +{     int m, n, errcode;
 59.1914 +      errcode = checklp(env, lp);
 59.1915 +      if (errcode) goto done;
 59.1916 +      if (!lp->stat)
 59.1917 +      {  errcode = error(env, CPXERR_NO_SOLN);
 59.1918 +         goto done;
 59.1919 +      }
 59.1920 +      errcode = 0;
 59.1921 +      m = glp_get_num_rows(lp->prob);
 59.1922 +      n = glp_get_num_cols(lp->prob);
 59.1923 +      if (lp->meth == CPX_ALG_PRIMAL || lp->meth == CPX_ALG_DUAL)
 59.1924 +      {  if (lpstat != NULL)
 59.1925 +            *lpstat = CPXgetstat(env, lp);
 59.1926 +         if (objval != NULL)
 59.1927 +            xassert(CPXgetobjval(env, lp, objval) == 0);
 59.1928 +         if (x != NULL)
 59.1929 +            xassert(CPXgetx(env, lp, x, 0, n-1) == 0);
 59.1930 +         if (pi != NULL)
 59.1931 +            xassert(CPXgetpi(env, lp, pi, 0, m-1) == 0);
 59.1932 +         if (slack != NULL)
 59.1933 +            xassert(CPXgetslack(env, lp, slack, 0, m-1) == 0);
 59.1934 +         if (dj != NULL)
 59.1935 +            xassert(CPXgetdj(env, lp, dj, 0, n-1) == 0);
 59.1936 +      }
 59.1937 +      else
 59.1938 +         xassert(lp != lp);
 59.1939 +done: return errcode;
 59.1940 +}
 59.1941 +
 59.1942 +int CPXstrongbranch(CPXENV *env, CPXLP *lp, const int goodlist[],
 59.1943 +      int goodlen, double downpen[], double uppen[], int itlim)
 59.1944 +{     int k;
 59.1945 +      xassert(env == env);
 59.1946 +      xassert(lp == lp);
 59.1947 +      xassert(goodlist == goodlist);
 59.1948 +      xassert(goodlen >= 0);
 59.1949 +      xassert(downpen != NULL);
 59.1950 +      xassert(uppen != NULL);
 59.1951 +      xassert(itlim == itlim);
 59.1952 +      /* not implemented yet */
 59.1953 +      for (k = 0; k < goodlen; k++)
 59.1954 +         downpen[k] = uppen[k] = 0.0;
 59.1955 +      return 0;
 59.1956 +}
 59.1957 +
 59.1958 +static int xstrcasecmp(const char *s1, const char *s2)
 59.1959 +{     int c1, c2;
 59.1960 +      for (;;)
 59.1961 +      {  c1 = toupper((unsigned char)*s1++);
 59.1962 +         c2 = toupper((unsigned char)*s2++);
 59.1963 +         if (c1 == '\0' || c1 != c2) break;
 59.1964 +      }
 59.1965 +      return c1 - c2;
 59.1966 +}
 59.1967 +
 59.1968 +static void getfiletype(const char *filename, char type[3+1])
 59.1969 +{     /* determine filetype from filename */
 59.1970 +      int beg, end;
 59.1971 +      beg = end = strlen(filename);
 59.1972 +      while (beg > 0 && filename[beg-1] != '.' && end - beg < 3)
 59.1973 +         beg--;
 59.1974 +      if (beg > 0 && filename[beg-1] == '.' &&
 59.1975 +          xstrcasecmp(&filename[beg], "gz") == 0)
 59.1976 +      {  end = --beg;
 59.1977 +         while (beg > 0 && filename[beg-1] != '.' && end - beg < 3)
 59.1978 +            beg--;
 59.1979 +      }
 59.1980 +      if (beg > 0 && filename[beg-1] == '.')
 59.1981 +      {  memcpy(type, &filename[beg], end - beg);
 59.1982 +         type[end - beg] = '\0';
 59.1983 +      }
 59.1984 +      else
 59.1985 +         type[0] = '\0';
 59.1986 +      return;
 59.1987 +}
 59.1988 +
 59.1989 +int CPXwriteprob(CPXENV *env, CPXLP *lp, const char *filename,
 59.1990 +      const char *filetype)
 59.1991 +{     glp_prob *copy;
 59.1992 +      int errcode;
 59.1993 +      char type[3+1];
 59.1994 +      errcode = checklp(env, lp);
 59.1995 +      if (errcode) goto done;
 59.1996 +      if (filename == NULL)
 59.1997 +      {  errcode = error(env, CPXERR_NO_FILENAME);
 59.1998 +         goto done;
 59.1999 +      }
 59.2000 +      if (filetype == NULL)
 59.2001 +         getfiletype(filename, type), filetype = type;
 59.2002 +      if (xstrcasecmp(filetype, "MPS") == 0)
 59.2003 +      {  glp_term_out(GLP_OFF);
 59.2004 +         errcode = glp_write_mps(lp->prob, GLP_MPS_FILE, NULL, filename)
 59.2005 +            ;
 59.2006 +         glp_term_out(GLP_ON);
 59.2007 +      }
 59.2008 +      else if (xstrcasecmp(filetype, "LP") == 0)
 59.2009 +      {  glp_term_out(GLP_OFF);
 59.2010 +         errcode = glp_write_lp(lp->prob, NULL, filename);
 59.2011 +         glp_term_out(GLP_ON);
 59.2012 +      }
 59.2013 +      else if (xstrcasecmp(filetype, "RMP") == 0 ||
 59.2014 +               xstrcasecmp(filetype, "REW") == 0)
 59.2015 +      {  copy = glp_create_prob();
 59.2016 +         glp_copy_prob(copy, lp->prob, GLP_OFF);
 59.2017 +         glp_term_out(GLP_OFF);
 59.2018 +         errcode = glp_write_mps(copy, GLP_MPS_DECK, NULL, filename);
 59.2019 +         glp_term_out(GLP_ON);
 59.2020 +         glp_delete_prob(copy);
 59.2021 +      }
 59.2022 +      else if (xstrcasecmp(filetype, "RLP") == 0)
 59.2023 +      {  copy = glp_create_prob();
 59.2024 +         glp_copy_prob(copy, lp->prob, GLP_OFF);
 59.2025 +         glp_term_out(GLP_OFF);
 59.2026 +         errcode = glp_write_lp(copy, NULL, filename);
 59.2027 +         glp_term_out(GLP_ON);
 59.2028 +         glp_delete_prob(copy);
 59.2029 +      }
 59.2030 +      else
 59.2031 +      {  errcode = error(env, CPXERR_BAD_FILETYPE);
 59.2032 +         goto done;
 59.2033 +      }
 59.2034 +      if (errcode)
 59.2035 +         errcode = error(env, CPXERR_FAIL_OPEN_WRITE, filename);
 59.2036 +done: return errcode;
 59.2037 +}
 59.2038 +
 59.2039 +/**********************************************************************/
 59.2040 +
 59.2041 +static int solvelp(CPXENV *env, CPXLP *lp, int meth)
 59.2042 +{     glp_smcp parm;
 59.2043 +      int errcode;
 59.2044 +      errcode = checklp(env, lp);
 59.2045 +      if (errcode) goto done;
 59.2046 +      errcode = 0;
 59.2047 +      invalidate(lp);
 59.2048 +      glp_init_smcp(&parm);
 59.2049 +      switch (meth)
 59.2050 +      {  case CPX_ALG_PRIMAL:
 59.2051 +            parm.meth = GLP_PRIMAL;
 59.2052 +            break;
 59.2053 +         case CPX_ALG_DUAL:
 59.2054 +            parm.meth = GLP_DUAL;
 59.2055 +            break;
 59.2056 +         default:
 59.2057 +            xassert(meth != meth);
 59.2058 +      }
 59.2059 +      switch (getintparam(env, CPX_PARAM_SIMDISPLAY))
 59.2060 +      {  case 0:
 59.2061 +            parm.msg_lev = GLP_MSG_OFF;
 59.2062 +            break;
 59.2063 +         case 1:
 59.2064 +            parm.msg_lev = GLP_MSG_ALL;
 59.2065 +            break;
 59.2066 +         case 2:
 59.2067 +            parm.msg_lev = GLP_MSG_ALL;
 59.2068 +            parm.out_frq = 1;
 59.2069 +            break;
 59.2070 +         default:
 59.2071 +            xassert(env != env);
 59.2072 +      }
 59.2073 +      xassert(getdblparam == getdblparam);
 59.2074 +      switch (getintparam(env, CPX_PARAM_ADVIND))
 59.2075 +      {  case 0:
 59.2076 +            glp_term_out(GLP_OFF);
 59.2077 +            glp_adv_basis(lp->prob, 0);
 59.2078 +            glp_term_out(GLP_ON);
 59.2079 +            break;
 59.2080 +         case 1:
 59.2081 +         case 2:
 59.2082 +            break;
 59.2083 +         default:
 59.2084 +            xassert(env != env);
 59.2085 +      }
 59.2086 +      if (!glp_bf_exists(lp->prob))
 59.2087 +      {  if (glp_factorize(lp->prob) != 0)
 59.2088 +         {  glp_term_out(GLP_OFF);
 59.2089 +            glp_adv_basis(lp->prob, 0);
 59.2090 +            glp_term_out(GLP_ON);
 59.2091 +            if (glp_factorize(lp->prob) != 0)
 59.2092 +               glp_std_basis(lp->prob);
 59.2093 +         }
 59.2094 +      }
 59.2095 +      xassert(glp_simplex(lp->prob, &parm) == 0);
 59.2096 +      switch (glp_get_status(lp->prob))
 59.2097 +      {  case GLP_OPT:
 59.2098 +            lp->stat = CPX_STAT_OPTIMAL;
 59.2099 +            lp->meth = meth;
 59.2100 +            break;
 59.2101 +         case GLP_NOFEAS:
 59.2102 +            lp->stat = CPX_STAT_INFEASIBLE;
 59.2103 +            lp->meth = meth;
 59.2104 +            break;
 59.2105 +         case GLP_UNBND:
 59.2106 +            lp->stat = CPX_STAT_UNBOUNDED;
 59.2107 +            lp->meth = meth;
 59.2108 +            break;
 59.2109 +         default:
 59.2110 +            xassert(lp != lp);
 59.2111 +      }
 59.2112 +done: return errcode;
 59.2113 +}
 59.2114 +
 59.2115 +int CPXprimopt(CPXENV *env, CPXLP *lp)
 59.2116 +{     int errcode;
 59.2117 +      errcode = solvelp(env, lp, CPX_ALG_PRIMAL);
 59.2118 +      return errcode;
 59.2119 +}
 59.2120 +
 59.2121 +int CPXdualopt(CPXENV *env, CPXLP *lp)
 59.2122 +{     int errcode;
 59.2123 +      errcode = solvelp(env, lp, CPX_ALG_DUAL);
 59.2124 +      return errcode;
 59.2125 +}
 59.2126 +
 59.2127 +int CPXlpopt(CPXENV *env, CPXLP *lp)
 59.2128 +{     int errcode;
 59.2129 +      errcode = solvelp(env, lp, CPX_ALG_PRIMAL);
 59.2130 +      return errcode;
 59.2131 +}
 59.2132 +
 59.2133 +/* eof */
    60.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    60.2 +++ b/deps/glpk/examples/cplex/cplex.h	Sun Nov 06 20:59:10 2011 +0100
    60.3 @@ -0,0 +1,301 @@
    60.4 +/* cplex.h (CPLEX-like interface to GLPK API) */
    60.5 +
    60.6 +/***********************************************************************
    60.7 +*  This code is part of GLPK (GNU Linear Programming Kit).
    60.8 +*
    60.9 +*  Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008,
   60.10 +*  2009, 2010, 2011 Andrew Makhorin, Department for Applied Informatics,
   60.11 +*  Moscow Aviation Institute, Moscow, Russia. All rights reserved.
   60.12 +*  E-mail: <mao@gnu.org>.
   60.13 +*
   60.14 +*  GLPK is free software: you can redistribute it and/or modify it
   60.15 +*  under the terms of the GNU General Public License as published by
   60.16 +*  the Free Software Foundation, either version 3 of the License, or
   60.17 +*  (at your option) any later version.
   60.18 +*
   60.19 +*  GLPK is distributed in the hope that it will be useful, but WITHOUT
   60.20 +*  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
   60.21 +*  or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
   60.22 +*  License for more details.
   60.23 +*
   60.24 +*  You should have received a copy of the GNU General Public License
   60.25 +*  along with GLPK. If not, see <http://www.gnu.org/licenses/>.
   60.26 +***********************************************************************/
   60.27 +
   60.28 +#ifndef _CPLEX_H
   60.29 +#define _CPLEX_H
   60.30 +
   60.31 +#ifdef __cplusplus
   60.32 +extern "C" {
   60.33 +#endif
   60.34 +
   60.35 +typedef struct CPXENV CPXENV, *CPXENVptr;
   60.36 +typedef struct CPXLP CPXLP, *CPXLPptr;
   60.37 +
   60.38 +#define CPX_VERSION                 900
   60.39 +
   60.40 +#define CPX_OFF                     0
   60.41 +#define CPX_ON                      1
   60.42 +
   60.43 +#define CPX_INFBOUND                1e20
   60.44 +
   60.45 +/* error codes: */
   60.46 +#define CPXERR_NO_MEMORY            1001
   60.47 +#define CPXERR_NO_ENVIRONMENT       1002
   60.48 +#define CPXERR_BAD_ARGUMENT         1003
   60.49 +#define CPXERR_NULL_POINTER         1004
   60.50 +#define CPXERR_NO_PROBLEM           1009
   60.51 +#define CPXERR_BAD_PARAM_NUM        1013
   60.52 +#define CPXERR_PARAM_TOO_SMALL      1014
   60.53 +#define CPXERR_PARAM_TOO_BIG        1015
   60.54 +#define CPXERR_INDEX_RANGE          1200
   60.55 +#define CPXERR_COL_INDEX_RANGE      1201
   60.56 +#define CPXERR_ROW_INDEX_RANGE      1203
   60.57 +#define CPXERR_NEGATIVE_SURPLUS     1207
   60.58 +#define CPXERR_BAD_SENSE            1215
   60.59 +#define CPXERR_NO_SOLN              1217
   60.60 +#define CPXERR_NOT_FIXED            1221
   60.61 +#define CPXERR_DUP_ENTRY            1222
   60.62 +#define CPXERR_NULL_NAME            1224
   60.63 +#define CPXERR_ARRAY_NOT_ASCENDING  1226
   60.64 +#define CPXERR_COUNT_RANGE          1227
   60.65 +#define CPXERR_BAD_LUB              1229
   60.66 +#define CPXERR_BAD_STATUS           1253
   60.67 +#define CPXERR_NO_BASIC_SOLN        1261
   60.68 +#define CPXERR_NO_FILENAME          1421
   60.69 +#define CPXERR_FAIL_OPEN_WRITE      1422
   60.70 +#define CPXERR_BAD_FILETYPE         1424
   60.71 +#define CPXERR_BAD_CTYPE            3021
   60.72 +
   60.73 +/* control parameters: */
   60.74 +#define CPX_PARAM_ADVIND            1001
   60.75 +#define CPX_PARAM_AGGIND            1003
   60.76 +#define CPX_PARAM_DPRIIND           1009
   60.77 +#define CPX_PARAM_EPOPT             1014
   60.78 +#define CPX_PARAM_EPPER             1015
   60.79 +#define CPX_PARAM_EPRHS             1016
   60.80 +#define CPX_PARAM_FASTMIP           1017 /* ??? */
   60.81 +#define CPX_PARAM_SIMDISPLAY        1019
   60.82 +#define CPX_PARAM_ITLIM             1020
   60.83 +#define CPX_PARAM_OBJLLIM           1025
   60.84 +#define CPX_PARAM_OBJULIM           1026
   60.85 +#define CPX_PARAM_PERIND            1027
   60.86 +#define CPX_PARAM_PPRIIND           1029
   60.87 +#define CPX_PARAM_PREIND            1030
   60.88 +#define CPX_PARAM_REINV             1031
   60.89 +#define CPX_PARAM_SCRIND            1035
   60.90 +#define CPX_PARAM_DATACHECK         1056
   60.91 +
   60.92 +/* CPX_PARAM_DPRIIND: */
   60.93 +#define CPX_DPRIIND_AUTO            0
   60.94 +#define CPX_DPRIIND_FULL            1
   60.95 +#define CPX_DPRIIND_STEEP           2
   60.96 +#define CPX_DPRIIND_FULL_STEEP      3
   60.97 +#define CPX_DPRIIND_STEEPQSTART     4
   60.98 +#define CPX_DPRIIND_DEVEX           5
   60.99 +
  60.100 +/* CPX_PARAM_PPRIIND: */
  60.101 +#define CPX_PPRIIND_PARTIAL         (-1)
  60.102 +#define CPX_PPRIIND_AUTO            0
  60.103 +#define CPX_PPRIIND_DEVEX           1
  60.104 +#define CPX_PPRIIND_STEEP           2
  60.105 +#define CPX_PPRIIND_STEEPQSTART     3
  60.106 +#define CPX_PPRIIND_FULL            4
  60.107 +
  60.108 +/* CPXgetprobtype: */
  60.109 +#define CPXPROB_LP                  0
  60.110 +#define CPXPROB_MIP                 1
  60.111 +#define CPXPROB_RELAXED             2
  60.112 +#define CPXPROB_FIXED               3
  60.113 +#define CPXPROB_QP                  5
  60.114 +#define CPXPROB_ZEROEDQP            6
  60.115 +
  60.116 +/* CPXgetobjsen: */
  60.117 +#define CPX_MIN                     1
  60.118 +#define CPX_MAX                     (-1)
  60.119 +
  60.120 +/* CPXgetbase: */
  60.121 +#define CPX_AT_LOWER                0
  60.122 +#define CPX_BASIC                   1
  60.123 +#define CPX_AT_UPPER                2
  60.124 +#define CPX_FREE_SUPER              3
  60.125 +
  60.126 +/* CPXgetstat: */
  60.127 +#define CPX_STAT_OPTIMAL            1
  60.128 +#define CPX_STAT_UNBOUNDED          2
  60.129 +#define CPX_STAT_INFEASIBLE         3
  60.130 +#define CPX_STAT_INForUNBD          4
  60.131 +#define CPX_STAT_OPTIMAL_INFEAS     5
  60.132 +#define CPX_STAT_ABORT_IT_LIM       10
  60.133 +#define CPX_STAT_ABORT_OBJ_LIM      12
  60.134 +
  60.135 +/* CPXgetmethod: */
  60.136 +#define CPX_ALG_NONE                0
  60.137 +#define CPX_ALG_PRIMAL              1
  60.138 +#define CPX_ALG_DUAL                2
  60.139 +#define CPX_ALG_BARRIER             4
  60.140 +
  60.141 +/* CPXsolninfo: */
  60.142 +#define CPX_NO_SOLN                 0
  60.143 +#define CPX_BASIC_SOLN              1
  60.144 +#define CPX_NONBASIC_SOLN           2
  60.145 +#define CPX_PRIMAL_SOLN             3
  60.146 +
  60.147 +int CPXaddcols(CPXENV *env, CPXLP *lp, int ccnt, int nzcnt,
  60.148 +      const double obj[], const int cmatbeg[], const int cmatind[],
  60.149 +      const double cmatval[], const double lb[], const double ub[],
  60.150 +      char *colname[]);
  60.151 +
  60.152 +int CPXaddrows(CPXENV *env, CPXLP *lp, int ccnt, int rcnt, int nzcnt,
  60.153 +      const double rhs[], const char sense[], const int rmatbeg[],
  60.154 +      const int rmatind[], const double rmatval[], char *colname[],
  60.155 +      char *rowname[]);
  60.156 +
  60.157 +int CPXbaropt(CPXENV *env, CPXLP *lp);
  60.158 +
  60.159 +int CPXbinvrow(CPXENV *env, CPXLP *lp, int i, double y[]);
  60.160 +
  60.161 +int CPXchgbds(CPXENV *env, CPXLP *lp, int cnt, const int indices[],
  60.162 +      const char lu[], const double bd[]);
  60.163 +
  60.164 +int CPXchgcoeflist(CPXENV *env, CPXLP *lp, int numcoefs,
  60.165 +      const int rowlist[], const int collist[], const double vallist[]);
  60.166 +
  60.167 +void CPXchgobjsen(CPXENV *env, CPXLP *lp, int maxormin);
  60.168 +
  60.169 +int CPXchgsense(CPXENV *env, CPXLP *lp, int cnt, const int indices[],
  60.170 +      const char sense[]);
  60.171 +
  60.172 +int CPXcloseCPLEX(CPXENV **env);
  60.173 +
  60.174 +int CPXcopybase(CPXENV *env, CPXLP *lp, const int cstat[],
  60.175 +      const int rstat[]);
  60.176 +
  60.177 +int CPXcopybasednorms(CPXENV *env, CPXLP *lp, const int cstat[],
  60.178 +      const int rstat[], const double dnorm[]);
  60.179 +
  60.180 +int CPXcopylp(CPXENV *env, CPXLP *lp, int numcols, int numrows,
  60.181 +      int objsen, const double obj[], const double rhs[],
  60.182 +      const char sense[], const int matbeg[], const int matcnt[],
  60.183 +      const int matind[], const double matval[], const double lb[],
  60.184 +      const double ub[], const double rngval[]);
  60.185 +
  60.186 +int CPXcopylpwnames(CPXENV *env, CPXLP *lp, int numcols, int numrows,
  60.187 +      int objsen, const double obj[], const double rhs[],
  60.188 +      const char sense[], const int matbeg[], const int matcnt[],
  60.189 +      const int matind[], const double matval[], const double lb[],
  60.190 +      const double ub[], const double rngval[], char *colname[],
  60.191 +      char *rowname[]);
  60.192 +
  60.193 +CPXLP *CPXcreateprob(CPXENV *env, int *status, const char *probname);
  60.194 +
  60.195 +int CPXdelcols(CPXENV *env, CPXLP *lp, int begin, int end);
  60.196 +
  60.197 +int CPXdelrows(CPXENV *env, CPXLP *lp, int begin, int end);
  60.198 +
  60.199 +int CPXdelsetcols(CPXENV *env, CPXLP *lp, int delstat[]);
  60.200 +
  60.201 +int CPXdelsetrows(CPXENV *env, CPXLP *lp, int delstat[]);
  60.202 +
  60.203 +int CPXdualopt(CPXENV *env, CPXLP *lp);
  60.204 +
  60.205 +int CPXfreeprob(CPXENV *env, CPXLP **lp);
  60.206 +
  60.207 +int CPXgetbase(CPXENV *env, CPXLP *lp, int cstat[], int rstat[]);
  60.208 +
  60.209 +int CPXgetbasednorms(CPXENV *env, CPXLP *lp, int cstat[], int rstat[],
  60.210 +      double dnorm[]);
  60.211 +
  60.212 +int CPXgetbhead(CPXENV *env, CPXLP *lp, int head[], double x[]);
  60.213 +
  60.214 +int CPXgetdblparam(CPXENV *env, int whichparam, double *value);
  60.215 +
  60.216 +int CPXgetdj(CPXENV *env, CPXLP *lp, double dj[], int begin, int end);
  60.217 +
  60.218 +char *CPXgeterrorstring(CPXENV *env, int errcode, char *buffer);
  60.219 +
  60.220 +int CPXgetijdiv(CPXENV *env, CPXLP *lp, int *idiv, int *jdiv);
  60.221 +
  60.222 +int CPXgetintparam(CPXENV *env, int whichparam, int *value);
  60.223 +
  60.224 +int CPXgetlb(CPXENV *env, CPXLP *lp, double lb[], int begin, int end);
  60.225 +
  60.226 +int CPXgetmethod(CPXENV *env, CPXLP *lp);
  60.227 +
  60.228 +int CPXgetnumcols(CPXENV *env, CPXLP *lp);
  60.229 +
  60.230 +int CPXgetnumnz(CPXENV *env, CPXLP *lp);
  60.231 +
  60.232 +int CPXgetnumrows(CPXENV *env, CPXLP *lp);
  60.233 +
  60.234 +int CPXgetobjval(CPXENV *env, CPXLP *lp, double *objval);
  60.235 +
  60.236 +int CPXgetpi(CPXENV *env, CPXLP *lp, double pi[], int begin, int end);
  60.237 +
  60.238 +int CPXgetsense(CPXENV *env, CPXLP *lp, char sense[], int begin,
  60.239 +      int end);
  60.240 +
  60.241 +int CPXgetslack(CPXENV *env, CPXLP *lp, double slack[], int begin,
  60.242 +      int end);
  60.243 +
  60.244 +int CPXgetstat(CPXENV *env, CPXLP *lp);
  60.245 +
  60.246 +int CPXgetub(CPXENV *env, CPXLP *lp, double ub[], int begin, int end);
  60.247 +
  60.248 +int CPXgetweight(CPXENV *env, CPXLP *lp, int rcnt, const int rmatbeg[],
  60.249 +      const int rmatind[], const double rmatval[], double weight[],
  60.250 +      int dpriind);
  60.251 +
  60.252 +int CPXgetx(CPXENV *env, CPXLP *lp, double x[], int begin, int end);
  60.253 +
  60.254 +int CPXinfodblparam(CPXENV *env, int whichparam, double *defvalue,
  60.255 +      double *minvalue, double *maxvalue);
  60.256 +
  60.257 +int CPXinfointparam(CPXENV *env, int whichparam, int *defvalue,
  60.258 +      int *minvalue, int *maxvalue);
  60.259 +
  60.260 +int CPXlpopt(CPXENV *env, CPXLP *lp);
  60.261 +
  60.262 +int CPXmdleave(const CPXENV *env, CPXLP *lp, const int goodlist[],
  60.263 +      int goodlen, double downratio[], double upratio[]);
  60.264 +
  60.265 +int CPXnewcols(CPXENV *env, CPXLP *lp, int ccnt, const double obj[],
  60.266 +      const double lb[], const double ub[], const char ctype[],
  60.267 +      char *colname[]);
  60.268 +
  60.269 +int CPXnewrows(CPXENV *env, CPXLP *lp, int rcnt, const double rhs[],
  60.270 +      const char sense[], const double rngval[], char *rowname[]);
  60.271 +
  60.272 +CPXENV *CPXopenCPLEX(int *status);
  60.273 +
  60.274 +int CPXpivotin(CPXENV *env, CPXLP *lp, const int rlist[], int rlen);
  60.275 +
  60.276 +int CPXpivotout(CPXENV *env, CPXLP *lp, const int clist[], int clen);
  60.277 +
  60.278 +int CPXprimopt(CPXENV *env, CPXLP *lp);
  60.279 +
  60.280 +int CPXsavwrite(CPXENV *env, CPXLP *lp, const char *filename);
  60.281 +
  60.282 +int CPXsetdblparam(CPXENV *env, int whichparam, double newvalue);
  60.283 +
  60.284 +int CPXsetintparam(CPXENV *env, int whichparam, int newvalue);
  60.285 +
  60.286 +int CPXsolninfo(CPXENV *env, CPXLP *lp, int *solnmethod, int *solntype,
  60.287 +      int *pfeasind, int *dfeasind);
  60.288 +
  60.289 +int CPXsolution(CPXENV *env, CPXLP *lp, int *lpstat, double *objval,
  60.290 +      double x[], double pi[], double slack[], double dj[]);
  60.291 +
  60.292 +int CPXstrongbranch(CPXENV *env, CPXLP *lp, const int goodlist[],
  60.293 +      int goodlen, double downpen[], double uppen[], int itlim);
  60.294 +
  60.295 +int CPXwriteprob(CPXENV *env, CPXLP *lp, const char *filename,
  60.296 +      const char *filetype);
  60.297 +
  60.298 +#ifdef __cplusplus
  60.299 +}
  60.300 +#endif
  60.301 +
  60.302 +#endif
  60.303 +
  60.304 +/* eof */
    61.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    61.2 +++ b/deps/glpk/examples/cpp.mod	Sun Nov 06 20:59:10 2011 +0100
    61.3 @@ -0,0 +1,67 @@
    61.4 +/* CPP, Critical Path Problem */
    61.5 +
    61.6 +/* Written in GNU MathProg by Andrew Makhorin <mao@gnu.org> */
    61.7 +
    61.8 +/* Note: Reduced costs of auxiliary variables phi[j,k] (see below)
    61.9 +         can be only zero or one. The critical path is defined by the
   61.10 +         constraints, whose reduced cost is one. */
   61.11 +
   61.12 +set J;
   61.13 +/* set of jobs (activities) */
   61.14 +
   61.15 +set P{j in J}, in J, default {};
   61.16 +/* P[j] is a subset of jobs that immediately precede job j */
   61.17 +
   61.18 +param t{j in J}, >= 0;
   61.19 +/* duration required to perform job j */
   61.20 +
   61.21 +var x{j in J}, >= 0;
   61.22 +/* starting time of job j */
   61.23 +
   61.24 +s.t. phi{j in J, k in P[j]}: x[j] >= x[k] + t[k];
   61.25 +/* job j can start only after all immediately preceding jobs have been
   61.26 +   completely performed */
   61.27 +
   61.28 +var z;
   61.29 +/* project makespan */
   61.30 +
   61.31 +s.t. fin{j in J}: z >= x[j] + t[j];
   61.32 +/* which is the maximum of the completion times of all the jobs */
   61.33 +
   61.34 +minimize obj: z;
   61.35 +/* the objective is make z as small as possible */
   61.36 +
   61.37 +data;
   61.38 +
   61.39 +/* The optimal solution is 46 */
   61.40 +
   61.41 +param : J :  t :=
   61.42 +        A    3    /* Excavate */
   61.43 +        B    4    /* Lay foundation */
   61.44 +        C    3    /* Rough plumbing */
   61.45 +        D   10    /* Frame */
   61.46 +        E    8    /* Finish exterior */
   61.47 +        F    4    /* Install HVAC */
   61.48 +        G    6    /* Rough electric */
   61.49 +        H    8    /* Sheet rock */
   61.50 +        I    5    /* Install cabinets */
   61.51 +        J    5    /* Paint */
   61.52 +        K    4    /* Final plumbing */
   61.53 +        L    2    /* Final electric */
   61.54 +        M    4    /* Install flooring */
   61.55 +;
   61.56 +
   61.57 +set P[B] := A;
   61.58 +set P[C] := B;
   61.59 +set P[D] := B;
   61.60 +set P[E] := D;
   61.61 +set P[F] := D;
   61.62 +set P[G] := D;
   61.63 +set P[H] := C E F G;
   61.64 +set P[I] := H;
   61.65 +set P[J] := H;
   61.66 +set P[K] := I;
   61.67 +set P[L] := J;
   61.68 +set P[M] := K L;
   61.69 +
   61.70 +end;
    62.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    62.2 +++ b/deps/glpk/examples/crypto.mod	Sun Nov 06 20:59:10 2011 +0100
    62.3 @@ -0,0 +1,84 @@
    62.4 +/* CRYPTO, a crypto-arithmetic puzzle */
    62.5 +
    62.6 +/* Written in GNU MathProg by Andrew Makhorin <mao@gnu.org> */
    62.7 +
    62.8 +/* This problem comes from the newsgroup rec.puzzle.
    62.9 +   The numbers from 1 to 26 are assigned to the letters of the alphabet.
   62.10 +   The numbers beside each word are the total of the values assigned to
   62.11 +   the letters in the word (e.g. for LYRE: L, Y, R, E might be to equal
   62.12 +   5, 9, 20 and 13, or any other combination that add up to 47).
   62.13 +   Find the value of each letter under the equations:
   62.14 +
   62.15 +   BALLET  45     GLEE  66     POLKA      59     SONG     61
   62.16 +   CELLO   43     JAZZ  58     QUARTET    50     SOPRANO  82
   62.17 +   CONCERT 74     LYRE  47     SAXOPHONE 134     THEME    72
   62.18 +   FLUTE   30     OBOE  53     SCALE      51     VIOLIN  100
   62.19 +   FUGUE   50     OPERA 65     SOLO       37     WALTZ    34
   62.20 +
   62.21 +   Solution:
   62.22 +   A, B,C, D, E,F, G, H, I, J, K,L,M, N, O, P,Q, R, S,T,U, V,W, X, Y, Z
   62.23 +   5,13,9,16,20,4,24,21,25,17,23,2,8,12,10,19,7,11,15,3,1,26,6,22,14,18
   62.24 +
   62.25 +   Reference:
   62.26 +   Koalog Constraint Solver <http://www.koalog.com/php/jcs.php>,
   62.27 +   Simple problems, the crypto-arithmetic puzzle ALPHACIPHER. */
   62.28 +
   62.29 +set LETTERS :=
   62.30 +{     'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M',
   62.31 +      'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z'
   62.32 +};
   62.33 +/* set of letters */
   62.34 +
   62.35 +set VALUES := 1..card(LETTERS);
   62.36 +/* set of values assigned to the letters */
   62.37 +
   62.38 +set WORDS;
   62.39 +/* set of words */
   62.40 +
   62.41 +param total{word in WORDS};
   62.42 +/* total[word] is the total of the values assigned to the letters in
   62.43 +   the word */
   62.44 +
   62.45 +var x{i in LETTERS, j in VALUES}, binary;
   62.46 +/* x[i,j] = 1 means that letter i is assigned value j */
   62.47 +
   62.48 +s.t. phi{i in LETTERS}: sum{j in VALUES} x[i,j] = 1;
   62.49 +
   62.50 +s.t. psi{j in VALUES}: sum{i in LETTERS} x[i,j] = 1;
   62.51 +
   62.52 +s.t. eqn{word in WORDS}: sum{k in 1..length(word), j in VALUES}
   62.53 +      j * x[substr(word,k,1), j] = total[word];
   62.54 +
   62.55 +solve;
   62.56 +
   62.57 +printf{i in LETTERS} "  %s", i;
   62.58 +printf "\n";
   62.59 +
   62.60 +printf{i in LETTERS} " %2d", sum{j in VALUES} j * x[i,j];
   62.61 +printf "\n";
   62.62 +
   62.63 +data;
   62.64 +
   62.65 +param :  WORDS :   total :=
   62.66 +         BALLET       45
   62.67 +         CELLO        43
   62.68 +         CONCERT      74
   62.69 +         FLUTE        30
   62.70 +         FUGUE        50
   62.71 +         GLEE         66
   62.72 +         JAZZ         58
   62.73 +         LYRE         47
   62.74 +         OBOE         53
   62.75 +         OPERA        65
   62.76 +         POLKA        59
   62.77 +         QUARTET      50
   62.78 +         SAXOPHONE   134
   62.79 +         SCALE        51
   62.80 +         SOLO         37
   62.81 +         SONG         61
   62.82 +         SOPRANO      82
   62.83 +         THEME        72
   62.84 +         VIOLIN      100
   62.85 +         WALTZ        34 ;
   62.86 +
   62.87 +end;
    63.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    63.2 +++ b/deps/glpk/examples/csv/distances.csv	Sun Nov 06 20:59:10 2011 +0100
    63.3 @@ -0,0 +1,7 @@
    63.4 +plant,market,distance
    63.5 +"Seattle","New York",2.5
    63.6 +"Seattle","Chicago",1.7
    63.7 +"Seattle","Topeka",1.8
    63.8 +"San Diego","New York",2.5
    63.9 +"San Diego","Chicago",1.8
   63.10 +"San Diego","Topeka",1.4
    64.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    64.2 +++ b/deps/glpk/examples/csv/markets.csv	Sun Nov 06 20:59:10 2011 +0100
    64.3 @@ -0,0 +1,4 @@
    64.4 +market,demand
    64.5 +"New York",325.
    64.6 +"Chicago",300.
    64.7 +"Topeka",275.
    65.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    65.2 +++ b/deps/glpk/examples/csv/parameters.csv	Sun Nov 06 20:59:10 2011 +0100
    65.3 @@ -0,0 +1,2 @@
    65.4 +parameter,value
    65.5 +"transport cost",90.
    66.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    66.2 +++ b/deps/glpk/examples/csv/plants.csv	Sun Nov 06 20:59:10 2011 +0100
    66.3 @@ -0,0 +1,3 @@
    66.4 +plant,capacity
    66.5 +"Seattle",350.
    66.6 +"San Diego",600.
    67.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    67.2 +++ b/deps/glpk/examples/csv/transp_csv.mod	Sun Nov 06 20:59:10 2011 +0100
    67.3 @@ -0,0 +1,70 @@
    67.4 +# A TRANSPORTATION PROBLEM
    67.5 +#
    67.6 +# This problem finds a least cost shipping schedule that meets
    67.7 +# requirements at markets and supplies at factories.
    67.8 +#
    67.9 +#  References:
   67.10 +#              Dantzig G B, "Linear Programming and Extensions."
   67.11 +#              Princeton University Press, Princeton, New Jersey, 1963,
   67.12 +#              Chapter 3-3.
   67.13 +
   67.14 +set I;
   67.15 +/* canning plants */
   67.16 +
   67.17 +set J;
   67.18 +/* markets */
   67.19 +
   67.20 +set K dimen 2;
   67.21 +/* transportation lane */
   67.22 +
   67.23 +set L;
   67.24 +/* parameters */
   67.25 +
   67.26 +param a{i in I};
   67.27 +/* capacity of plant i in cases */
   67.28 +
   67.29 +param b{j in J};
   67.30 +/* demand at market j in cases */
   67.31 +
   67.32 +param d{i in I, j in J};
   67.33 +/* distance in thousands of miles */
   67.34 +
   67.35 +param e{l in L};
   67.36 +/* parameters */
   67.37 +
   67.38 +param f;
   67.39 +/* freight in dollars per case per thousand miles */
   67.40 +
   67.41 +table tab_plant IN "CSV" "plants.csv" :
   67.42 +  I <- [plant], a ~ capacity;
   67.43 +
   67.44 +table tab_market IN "CSV" "markets.csv" :
   67.45 +  J <- [market], b ~ demand;
   67.46 +
   67.47 +table tab_distance IN "CSV" "distances.csv" :
   67.48 +  K <- [plant, market], d ~ distance;
   67.49 +
   67.50 +table tab_parameter IN "CSV" "parameters.csv" :
   67.51 +  L <- [parameter], e ~ value ;
   67.52 +
   67.53 +param c{i in I, j in J} := e['transport cost'] * d[i,j] / 1000;
   67.54 +/* transport cost in thousands of dollars per case */
   67.55 +
   67.56 +var x{(i,j) in K} >= 0;
   67.57 +/* shipment quantities in cases */
   67.58 +
   67.59 +minimize cost: sum{(i,j) in K} c[i,j] * x[i,j];
   67.60 +/* total transportation costs in thousands of dollars */
   67.61 +
   67.62 +s.t. supply{i in I}: sum{(i,j) in K} x[i,j] <= a[i];
   67.63 +/* observe supply limit at plant i */
   67.64 +
   67.65 +s.t. demand{j in J}: sum{(i,j) in K} x[i,j] >= b[j];
   67.66 +/* satisfy demand at market j */
   67.67 +
   67.68 +solve;
   67.69 +
   67.70 +table tab_result{(i,j) in K} OUT "CSV" "result.csv" :
   67.71 +  i ~ plant, j ~ market, x[i,j] ~ shipment;
   67.72 +
   67.73 +end;
    68.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    68.2 +++ b/deps/glpk/examples/dbf/ForestMgt_Model_I_GIS_dbf.mod	Sun Nov 06 20:59:10 2011 +0100
    68.3 @@ -0,0 +1,226 @@
    68.4 +#  Model I Forest Estate Modelling using GLPK/MathProg
    68.5 +#  Reading and writing dbf files
    68.6 +
    68.7 +#  by Noli Sicad --- nsicad@gmail.com
    68.8 +# 18 December 2009
    68.9 +
   68.10 +#  Forest Management 4th Edition 
   68.11 +#  by Lawrence Davis, K. Norman Johnson, Pete Bettinger, Theodore Howard
   68.12 +#  Chapter 11 - Daniel Pickett 
   68.13 +#  http://warnell.forestry.uga.edu/Warnell/Bettinger/mgtbook/index.htm
   68.14 +
   68.15 +#  Model I Formulation
   68.16 +
   68.17 +/*  Note: This is not the full LP model mentioned in the book.
   68.18 +Some of the constraints are deliberately omitted in this model for the purpose of clarity.
   68.19 +
   68.20 +The features of MathProg in this example are:
   68.21 +* reading and writing dbf from regular dbf files,
   68.22 +* reading dbf file (database of shapefile (stands.shp)) (e.g. area parameter),
   68.23 +* using the area data in the constraints and
   68.24 +* writing dbf file from result of LP model.
   68.25 +
   68.26 +Model I - Harvest Scheduling formulation for Sustainable Forest Management (SFM)
   68.27 +
   68.28 +Features are:
   68.29 +* Net Present Value for the objective function (Revenue - Cost)
   68.30 +* Harvest Constraints by period - Sustainable Yield per Period
   68.31 +* Even-Flow Constraint / Volume - Harvest Flow Constraint -  Alpha (1-Apha)
   68.32 +* Even-Flow Constraint / Volume - Harvest Flow Constraint - Beta  (1 +Beta)
   68.33 +* Forest / Land Constraint -- Total Area of the forest
   68.34 +* Forest Stand Constraint  -- Individual stands
   68.35 +
   68.36 +What is next? -- Forest Mgt Carbon Accounting for Climate Change
   68.37 +
   68.38 +Note: The model file that the data containing in
   68.39 +the dbf files is public domain material (so it is compatible with the
   68.40 +GNU GPL) and data can be found in 
   68.41 +http://warnell.forestry.uga.edu/Warnell/Bettinger/mgtbook/index.htm
   68.42 +
   68.43 +# Noli Sicad --- nsicad@gmail.com
   68.44 +
   68.45 +*/
   68.46 +
   68.47 +set G_STAND_TYPE; # A, B, C
   68.48 +
   68.49 +set I_CULTURAL_PRES; 
   68.50 +set J_MGT_YEAR; 
   68.51 +
   68.52 +param K_PERIOD;
   68.53 +param Forest_Cost{G_STAND_TYPE,I_CULTURAL_PRES, J_MGT_YEAR}; # cost
   68.54 +
   68.55 +param Yield_Table_Vol{G_STAND_TYPE, I_CULTURAL_PRES, J_MGT_YEAR, 1..K_PERIOD} >= 0;
   68.56 +
   68.57 +
   68.58 +param Alpha >= 0;
   68.59 +param Beta >= 0;
   68.60 +
   68.61 +param TCost_Table{G_STAND_TYPE, I_CULTURAL_PRES, J_MGT_YEAR, 1..K_PERIOD} >= 0;
   68.62 +
   68.63 +param NetRev_Table{G_STAND_TYPE, I_CULTURAL_PRES, J_MGT_YEAR, 1..K_PERIOD};
   68.64 +
   68.65 +
   68.66 +var XForestLand{g in G_STAND_TYPE, i in I_CULTURAL_PRES, j in J_MGT_YEAR} >= 0;
   68.67 +
   68.68 +
   68.69 +#reading dbf tables
   68.70 +table tab IN "xBASE" "standtype.dbf": G_STAND_TYPE <- [STAND];
   68.71 +display G_STAND_TYPE;
   68.72 +
   68.73 +
   68.74 +table tab2 IN "xBASE" "cultural_pres.dbf": I_CULTURAL_PRES <- [CUL_PRES];
   68.75 +display I_CULTURAL_PRES;
   68.76 +
   68.77 +table tab3 IN "xBASE" "mgt_year.dbf": J_MGT_YEAR <- [MGT_YEAR];
   68.78 +display J_MGT_YEAR;
   68.79 +
   68.80 +/*
   68.81 +param Forest_Cost{G_STAND_TYPE,I_CULTURAL_PRES, J_MGT_YEAR} default 0; # cost
   68.82 +*/
   68.83 +
   68.84 +set S1, dimen 3;
   68.85 +table tab4 IN "xBASE" "Forest_Cost.dbf": S1 <- [STAND, CUL_PRES, MGT_YEAR],Forest_Cost ~FCOST;
   68.86 +display Forest_Cost;
   68.87 +
   68.88 +set S2, dimen 4;
   68.89 +table tab5 IN "xBASE" "Yield_Table_Vol.dbf": S2 <- [STAND, CUL_PRES, MGT_YEAR, PERIOD],Yield_Table_Vol ~YIELD;
   68.90 +display Yield_Table_Vol;
   68.91 +
   68.92 +set S3, dimen 4;
   68.93 +table tab5 IN "xBASE" "TCost_Table.dbf": S3 <- [STAND, CUL_PRES, MGT_YEAR, PERIOD],TCost_Table ~TCOST;
   68.94 +display TCost_Table;
   68.95 +
   68.96 +
   68.97 +set S4, dimen 4;
   68.98 +table tab5 IN "xBASE" "NetRev_Table.dbf": S4 <- [STAND, CUL_PRES, MGT_YEAR, PERIOD],NetRev_Table ~NETREV;
   68.99 +display NetRev_Table;
  68.100 +
  68.101 +
  68.102 +param MGT;
  68.103 +
  68.104 +param Area_Stand_Indi{g in G_STAND_TYPE, m in 1..MGT} default 0; 
  68.105 +
  68.106 +set ST, dimen 2;
  68.107 +table tab5 IN "xBASE" "stands.dbf": ST <- [VEG_TYPE, MGT], Area_Stand_Indi ~ACRES;
  68.108 +display Area_Stand_Indi;
  68.109 +
  68.110 +param Area_Stand_Type{g in G_STAND_TYPE}:= sum {m in 1..MGT } Area_Stand_Indi[g,m];
  68.111 +display Area_Stand_Type;
  68.112 +
  68.113 +
  68.114 +param Total_Area := sum {g in G_STAND_TYPE, m in 1..MGT } Area_Stand_Indi[g,m];
  68.115 +display Total_Area;
  68.116 +
  68.117 +param Harvest_Min_Vol_Period;
  68.118 +
  68.119 +
  68.120 +var NetPresentValue;
  68.121 +
  68.122 +# Objective function
  68.123 +maximize Net_Present_Value: NetPresentValue;
  68.124 +
  68.125 +subject to NPV:
  68.126 +   NetPresentValue = sum {g in G_STAND_TYPE, i in I_CULTURAL_PRES, j in J_MGT_YEAR} Forest_Cost[g,i,j] * XForestLand[g,i,j];
  68.127 +
  68.128 +# Harvest Constraint by Period
  68.129 +subject to Harvest_Period_H {k in 1..K_PERIOD}:
  68.130 +   sum {g in G_STAND_TYPE, i in I_CULTURAL_PRES, j in J_MGT_YEAR} Yield_Table_Vol[g,i,j,k] * XForestLand[g,i,j] >= Harvest_Min_Vol_Period;
  68.131 +   
  68.132 +
  68.133 +#Even-Flow Constraint / Volume - Harvest Flow Constraint - Alpha
  68.134 +subject to Even_Flow_Constaints_Alpha {k in 6..K_PERIOD-1}:
  68.135 +    (1 - Alpha) * sum {g in G_STAND_TYPE, i in I_CULTURAL_PRES, j in J_MGT_YEAR} Yield_Table_Vol[g,i,j,k] * XForestLand[g,i,j] -
  68.136 +    sum {g in G_STAND_TYPE,i in I_CULTURAL_PRES, j in J_MGT_YEAR} Yield_Table_Vol[g,i,j,k+1] * XForestLand[g,i,j] <= 0;
  68.137 +
  68.138 +# Even-Flow Constraint / Volume - Harvest Flow Constraint - Beta
  68.139 +subject to Even_Flow_Constaints_Beta {k in 6..K_PERIOD-1}:
  68.140 +    (1 + Beta) * sum {g in G_STAND_TYPE, i in I_CULTURAL_PRES, j in J_MGT_YEAR} Yield_Table_Vol[g,i,j,k] * XForestLand[g,i,j] -
  68.141 +    sum {g in G_STAND_TYPE,i in I_CULTURAL_PRES, j in J_MGT_YEAR} Yield_Table_Vol[g,i,j,k+1] * XForestLand[g,i,j] >= 0;
  68.142 +   
  68.143 +# Forest / Land Constraints
  68.144 +subject to Total_Area_Constraint: 
  68.145 +  sum {g in G_STAND_TYPE, i in I_CULTURAL_PRES, j in J_MGT_YEAR} XForestLand[g,i,j] <= Total_Area;
  68.146 +display Total_Area;   
  68.147 +
  68.148 +# Forest / Land Constraints for A B C
  68.149 +subject to Area {g in G_STAND_TYPE}:
  68.150 +   sum {i in I_CULTURAL_PRES,j in J_MGT_YEAR} XForestLand[g,i,j] = Area_Stand_Type[g];
  68.151 +
  68.152 +
  68.153 +
  68.154 +solve;
  68.155 +#RESULT SECTION
  68.156 +printf '#################################\n';
  68.157 +printf 'Forest Management Model I - Noli Sicad\n';
  68.158 +printf '\n';
  68.159 +printf 'Net Present Value = %.2f\n', NetPresentValue;
  68.160 +printf '\n';
  68.161 +
  68.162 +printf '\n';
  68.163 +printf 'Variables\n';
  68.164 +printf 'Stand_Type  Age_Class  Mgt_Presc  Sign Value \n';
  68.165 +printf{g in G_STAND_TYPE, i in I_CULTURAL_PRES, j in J_MGT_YEAR}:'%5s %10s %11s = %10.2f\n', g,i,j, XForestLand[g,i,j]; 
  68.166 +printf '\n';
  68.167 +
  68.168 +printf 'Constraints\n';
  68.169 +printf 'Period Harvest Sign \n';
  68.170 +for {k in 1..K_PERIOD} {
  68.171 + printf '%5s %10.2f >= %.3f\n', k, sum {g in G_STAND_TYPE, i in I_CULTURAL_PRES, j in J_MGT_YEAR} Yield_Table_Vol[g,i,j,k] * XForestLand[g,i,j], Harvest_Min_Vol_Period;
  68.172 +   }
  68.173 +
  68.174 +# xbase (dbf) output
  68.175 +table Harvest{k in 1..K_PERIOD} OUT "xBASE" "HarvestArea1.dbf" "N(5)N(15,2)" :  k ~ Period, (sum {g in G_STAND_TYPE, i in I_CULTURAL_PRES, j in J_MGT_YEAR} Yield_Table_Vol[g,i,j,k] * XForestLand[g,i,j]) ~ H_Area;
  68.176 +
  68.177 +# xbase (dbf) read
  68.178 +set S, dimen 2;
  68.179 +table tab2 IN "xBASE" "HarvestArea1.dbf": S <- [Period, H_Area];
  68.180 +display S;
  68.181 +
  68.182 +
  68.183 +
  68.184 +
  68.185 +printf '\n';
  68.186 +printf 'Constraint\n';
  68.187 +printf 'Harvest Period\n';
  68.188 +printf 'Type AgeClass  PrescMgt Period    Value\n';
  68.189 +printf{g in G_STAND_TYPE, i in I_CULTURAL_PRES, j in J_MGT_YEAR, k in 1..K_PERIOD}:'%5s %11s %11s %5s %10.2f\n', g,i,j, k, (Yield_Table_Vol[g,i,j,k] * XForestLand[g,i,j]); 
  68.190 +
  68.191 +
  68.192 +printf 'Even_Flow_Constaint_Alpha (1-Alpha)\n';
  68.193 +printf 'Period Sign \n';
  68.194 +for {k in 6..K_PERIOD-1} {
  68.195 +   printf "%s %10.2f <= %s\n", k, ((1 - Alpha) * sum {g in G_STAND_TYPE, i in I_CULTURAL_PRES, j in J_MGT_YEAR} Yield_Table_Vol[g,i,j,k] * XForestLand[g,i,j] - sum {g in G_STAND_TYPE,i in I_CULTURAL_PRES, j in J_MGT_YEAR} Yield_Table_Vol[g,i,j,k+1] * XForestLand[g,i,j]),0;
  68.196 +  }
  68.197 +printf '\n';
  68.198 +
  68.199 +
  68.200 +# Forest / Land Constraints
  68.201 +printf '\n';  
  68.202 +printf 'Total Area Constraint\n';
  68.203 +printf 'Type AgeClass  PrescMgt  Value Sign Total_Area \n';
  68.204 +printf '%5s <= %.3f\n',sum {g in G_STAND_TYPE, i in I_CULTURAL_PRES, j in J_MGT_YEAR} XForestLand[g,i,j], Total_Area;
  68.205 +
  68.206 +printf 'Area\n';
  68.207 +printf 'Area Value Sign Areas_Stand\n';
  68.208 +for {g in G_STAND_TYPE} {
  68.209 +  printf '%5s %10.2f <= %.3f\n', g, sum {i in I_CULTURAL_PRES,j in J_MGT_YEAR} XForestLand[g,i,j],  Area_Stand_Type[g];
  68.210 +   }
  68.211 +
  68.212 +
  68.213 +#DATA SECTION 
  68.214 +      
  68.215 +data;
  68.216 +
  68.217 +# Most of the data has been moved to dbf format
  68.218 +
  68.219 +param MGT:=31;
  68.220 +
  68.221 +param K_PERIOD:= 7;
  68.222 +
  68.223 +param Alpha:= 0.20;
  68.224 +param Beta:= 0.20;
  68.225 +
  68.226 +param Harvest_Min_Vol_Period:= 12000;
  68.227 +
  68.228 +end;
  68.229 +
    69.1 Binary file deps/glpk/examples/dbf/Forest_Cost.dbf has changed
    70.1 Binary file deps/glpk/examples/dbf/NetRev_Table.dbf has changed
    71.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    71.2 +++ b/deps/glpk/examples/dbf/README	Sun Nov 06 20:59:10 2011 +0100
    71.3 @@ -0,0 +1,2 @@
    71.4 +This subdirectory contains an example MathProg model that demonstrates
    71.5 +using data tables in DBF format.
    72.1 Binary file deps/glpk/examples/dbf/TCost_Table.dbf has changed
    73.1 Binary file deps/glpk/examples/dbf/Yield_Table_Vol.dbf has changed
    74.1 Binary file deps/glpk/examples/dbf/cultural_pres.dbf has changed
    75.1 Binary file deps/glpk/examples/dbf/mgt_year.dbf has changed
    76.1 Binary file deps/glpk/examples/dbf/stands.dbf has changed
    77.1 Binary file deps/glpk/examples/dbf/standtype.dbf has changed
    78.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    78.2 +++ b/deps/glpk/examples/dea.mod	Sun Nov 06 20:59:10 2011 +0100
    78.3 @@ -0,0 +1,222 @@
    78.4 +/* Data Envelopment Analysis (DEA)
    78.5 + *
    78.6 + * DEA quantifies the relative efficiency of decision making units (DMUs) by
    78.7 + * finding the efficient frontier in multiple input multiple output data.  The
    78.8 + * inputs are resources (eg. number of employees, available machines, ...),
    78.9 + * the outputs are productive outputs (eg. contracts made, total sales, ...).
   78.10 + * The method is non-parametric.  More details are available in the paper
   78.11 + * below.
   78.12 + *
   78.13 + * Models according to: Seiford, Threall, "Recent developments in DEA", 1990.
   78.14 + *
   78.15 + * Implementation: Sebastian Nowozin <nowozin@gmail.com>
   78.16 + */
   78.17 +
   78.18 +### SETS ###
   78.19 +
   78.20 +set dmus;       # Decision Making Units (DMU)
   78.21 +set inputs;     # Input parameters
   78.22 +set outputs;    # Output parameters
   78.23 +
   78.24 +
   78.25 +### PARAMETERS ###
   78.26 +
   78.27 +param input_data{dmus,inputs} >= 0;
   78.28 +param output_data{dmus,outputs} >= 0;
   78.29 +
   78.30 +
   78.31 +### PROGRAM ###
   78.32 +
   78.33 +var theta{dmus} >= 0;
   78.34 +var lambda{dmus,dmus} >= 0;
   78.35 +
   78.36 +minimize inefficiency: sum{td in dmus} theta[td];
   78.37 +
   78.38 +s.t. output_lower_limit{o in outputs, td in dmus}:
   78.39 +    sum{d in dmus} lambda[d,td]*output_data[d,o] >= output_data[td,o];
   78.40 +s.t. input_upper_limit{i in inputs, td in dmus}:
   78.41 +    sum{d in dmus} lambda[d,td]*input_data[d,i] <= theta[td]*input_data[td,i];
   78.42 +
   78.43 +    s.t. PI1{td in dmus}:
   78.44 +        sum{d in dmus} lambda[d,td] = 1;
   78.45 +/*
   78.46 +possibilities:
   78.47 +      i) (no constraint)
   78.48 +     ii) s.t. PI1{td in dmus}:
   78.49 +        sum{d in dmus} lambda[d,td] <= 1;
   78.50 +    iii) s.t. PI1{td in dmus}:
   78.51 +        sum{d in dmus} lambda[d,td] >= 1;
   78.52 +*/
   78.53 +
   78.54 +
   78.55 +### SOLVE AND PRINT SOLUTION ###
   78.56 +
   78.57 +solve;
   78.58 +
   78.59 +printf "DMU\tEfficiency\n";
   78.60 +for {td in dmus} {
   78.61 +    printf "%s\t%1.4f\n", td, theta[td];
   78.62 +}
   78.63 +
   78.64 +### DATA ###
   78.65 +
   78.66 +data;
   78.67 +
   78.68 +set dmus := 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
   78.69 +    21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40
   78.70 +    41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60
   78.71 +    61 62 63 64 65 66 67 68 69 ;
   78.72 +set inputs := AvgInventory LaborCost OperatingCost Population ;
   78.73 +set outputs := PrescrVol kDollarValue ;
   78.74 +
   78.75 +param input_data default 0.0 :
   78.76 +
   78.77 +        AvgInventory LaborCost OperatingCost Population :=
   78.78 +
   78.79 +1 8000 17030 1280 1410
   78.80 +2 9000 25890 2779 1523
   78.81 +3 13694 29076 2372 1354
   78.82 +4 4250 17506 1385 822
   78.83 +5 6500 23208 639 746
   78.84 +6 7000 12946 802 1281
   78.85 +7 4500 18001 1130 1016
   78.86 +8 5000 14473 1097 1070
   78.87 +9 27000 31760 5559 1694
   78.88 +10 21560 50972 15010 1910
   78.89 +11 15000 39523 4799 1745
   78.90 +12 8500 13076 3489 1353
   78.91 +13 35000 35427 1704 500
   78.92 +14 18000 27554 2882 1016
   78.93 +15 59750 53848 14208 2500
   78.94 +16 19200 38253 1480 2293
   78.95 +17 40000 109404 83016 2718
   78.96 +18 8466 18198 1278 2877
   78.97 +19 16000 40891 7599 4150
   78.98 +20 10000 45444 5556 4421
   78.99 +21 25000 35623 2121 3883
  78.100 +22 14000 20192 5515 3519
  78.101 +23 12500 34973 10475 32366
  78.102 +24 17260 32284 14498 3393
  78.103 +25 7000 17920 7585 4489
  78.104 +26 14000 42094 3742 2217
  78.105 +27 16400 35422 14236 4641
  78.106 +28 13000 19100 3529 5968
  78.107 +29 30000 72167 8656 8715
  78.108 +30 12530 19970 1714 5968
  78.109 +31 31500 39183 4919 5607
  78.110 +32 10000 32048 3483 7324
  78.111 +33 22000 68877 12279 8685
  78.112 +34 10000 29812 3332 8685
  78.113 +35 16000 47686 2507 5420
  78.114 +36 10000 33415 4738 7703
  78.115 +37 9000 12359 4603 4665
  78.116 +38 16439 23614 2989 6317
  78.117 +39 14500 36069 1793 31839
  78.118 +40 39000 76307 9539 15619
  78.119 +41 24927 40706 12661 30213
  78.120 +42 13858 39267 4609 34719
  78.121 +43 33375 29509 11323 31839
  78.122 +44 29044 44482 5542 34719
  78.123 +45 32257 61365 20550 32366
  78.124 +46 8800 49671 3306 43561
  78.125 +47 47000 40425 10396 31263
  78.126 +48 12000 33034 4915 31263
  78.127 +49 28000 69163 4688 15173
  78.128 +50 13300 28931 16735 73064
  78.129 +51 13500 29758 4260 62309
  78.130 +52 24000 40927 8285 23166
  78.131 +53 16000 40403 2131 99836
  78.132 +54 17000 38730 2539 60348
  78.133 +55 25000 35978 2502 99836
  78.134 +56 16000 37509 6278 99836
  78.135 +57 20000 46950 10715 85925
  78.136 +58 14000 35966 3144 85925
  78.137 +59 22000 68318 8015 108987
  78.138 +60 21879 69537 7778 108987
  78.139 +61 15000 25425 2812 201404
  78.140 +62 10000 19508 2454 201404
  78.141 +63 20000 28191 3367 201404
  78.142 +64 18000 37073 8624 108987
  78.143 +65 19051 23763 3496 201404
  78.144 +66 15000 28642 3366 201404
  78.145 +67 10000 35919 3868 201404
  78.146 +68 24000 54653 26494 108987
  78.147 +69 1800 6276 3413 60348
  78.148 +        ;
  78.149 +
  78.150 +param output_data default 0.0 :
  78.151 +
  78.152 +        PrescrVol kDollarValue :=
  78.153 +
  78.154 +1 12293 61.00
  78.155 +2 18400 92.00
  78.156 +3 16789 92.65
  78.157 +4 10700 45.00
  78.158 +5 9800 50.00
  78.159 +6 6500 29.00
  78.160 +7 8200 56.00
  78.161 +8 8680 45.00
  78.162 +9 33800 183.00
  78.163 +10 23710 156.00
  78.164 +11 24000 120.00
  78.165 +12 17500 75.00
  78.166 +13 25000 130.00
  78.167 +14 26000 122.00
  78.168 +15 26830 178.513
  78.169 +16 16600 106.00
  78.170 +17 90000 450.00
  78.171 +18 11140 73.624
  78.172 +19 25868 136.00
  78.173 +20 32700 191.295
  78.174 +21 29117 152.864
  78.175 +22 18000 100.00
  78.176 +23 11100 60.00
  78.177 +24 23030 137.778
  78.178 +25 10656 58.00
  78.179 +26 24682 152.095
  78.180 +27 26908 120.00
  78.181 +28 16464 80.00
  78.182 +29 57000 321.00
  78.183 +30 17532 94.747
  78.184 +31 30035 168.00
  78.185 +32 16000 100.00
  78.186 +33 63700 277.00
  78.187 +34 18000 90.00
  78.188 +35 27339 139.134
  78.189 +36 19500 116.00
  78.190 +37 13000 80.00
  78.191 +38 15370 102.00
  78.192 +39 18446 90.00
  78.193 +40 56000 260.00
  78.194 +41 73845 364.951
  78.195 +42 28600 145.00
  78.196 +43 27000 243.00
  78.197 +44 52423 279.816
  78.198 +45 73759 363.388
  78.199 +46 20500 80.00
  78.200 +47 27100 115.00
  78.201 +48 15000 110.00
  78.202 +49 50895 277.852
  78.203 +50 19707 128.00
  78.204 +51 17994 78.80
  78.205 +52 36135 167.222
  78.206 +53 30000 153.00
  78.207 +54 26195 125.00
  78.208 +55 28000 216.00
  78.209 +56 24658 152.551
  78.210 +57 36850 190.00
  78.211 +58 29250 183.69
  78.212 +59 50000 250.00
  78.213 +60 40078 265.443
  78.214 +61 20200 110.00
  78.215 +62 12500 75.00
  78.216 +63 30890 195.00
  78.217 +64 31000 175.00
  78.218 +65 31277 192.992
  78.219 +66 11500 75.00
  78.220 +67 30000 175.668
  78.221 +68 38383 190.00
  78.222 +69 2075 8.650
  78.223 +        ;
  78.224 +
  78.225 +end;
    79.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    79.2 +++ b/deps/glpk/examples/diet.mod	Sun Nov 06 20:59:10 2011 +0100
    79.3 @@ -0,0 +1,99 @@
    79.4 +# STIGLER'S NUTRITION MODEL
    79.5 +#
    79.6 +# This model determines a least cost diet which meets the daily
    79.7 +# allowances of nutrients for a moderately active man weighing 154 lbs.
    79.8 +#
    79.9 +#  References:
   79.10 +#              Dantzig G B, "Linear Programming and Extensions."
   79.11 +#              Princeton University Press, Princeton, New Jersey, 1963,
   79.12 +#              Chapter 27-1.
   79.13 +
   79.14 +set N;
   79.15 +/* nutrients */
   79.16 +
   79.17 +set F;
   79.18 +/* foods */
   79.19 +
   79.20 +param b{N};
   79.21 +/* required daily allowances of nutrients */
   79.22 +
   79.23 +param a{F,N};
   79.24 +/* nutritive value of foods (per dollar spent) */
   79.25 +
   79.26 +var x{f in F} >= 0;
   79.27 +/* dollars of food f to be purchased daily */
   79.28 +
   79.29 +s.t. nb{n in N}: sum{f in F} a[f,n] * x[f] = b[n];
   79.30 +/* nutrient balance (units) */
   79.31 +
   79.32 +minimize cost: sum{f in F} x[f];
   79.33 +/* total food bill (dollars) */
   79.34 +
   79.35 +data;
   79.36 +
   79.37 +param : N : b :=
   79.38 +         Calorie       3 /* thousands */
   79.39 +         Protein      70 /* grams */
   79.40 +         Calcium     0.8 /* grams */
   79.41 +         Iron         12 /* milligrams */
   79.42 +         Vitamin-A     5 /* thousands IUs */
   79.43 +         Vitamin-B1  1.8 /* milligrams */
   79.44 +         Vitamin-B2  2.7 /* milligrams */
   79.45 +         Niacin       18 /* milligrams */
   79.46 +         Vitamin-C    75 /* milligrams */  ;
   79.47 +
   79.48 +set F := Wheat Cornmeal Cannedmilk Margarine Cheese Peanut-B Lard
   79.49 +         Liver Porkroast Salmon Greenbeans Cabbage Onions Potatoes
   79.50 +         Spinach Sweet-Pot Peaches Prunes Limabeans Navybeans;
   79.51 +
   79.52 +param a default 0
   79.53 +
   79.54 +:           Calorie  Protein  Calcium  Iron  Vitamin-A  Vitamin-B1 :=
   79.55 +#            (1000)    (g)      (g)    (mg)   (1000IU)     (mg)
   79.56 +
   79.57 +Wheat         44.7     1411      2.0    365        .       55.4
   79.58 +Cornmeal      36        897      1.7     99      30.9      17.4
   79.59 +Cannedmilk     8.4      422     15.1      9      26         3
   79.60 +Margarine     20.6       17       .6      6      55.8        .2
   79.61 +Cheese         7.4      448     16.4     19      28.1        .8
   79.62 +Peanut-B      15.7      661      1       48        .        9.6
   79.63 +Lard          41.7        .       .       .        .2        .
   79.64 +Liver          2.2      333       .2    139     169.2       6.4
   79.65 +Porkroast      4.4      249       .3     37        .       18.2
   79.66 +Salmon         5.8      705      6.8     45       3.5       1
   79.67 +Greenbeans     2.4      138      3.7     80      69         4.3
   79.68 +Cabbage        2.6      125      4       36       7.2       9
   79.69 +Onions         5.8      166      3.8     59      16.6       4.7
   79.70 +Potatoes      14.3      336      1.8    118       6.7      29.4
   79.71 +Spinach        1.1      106       .     138     918.4       5.7
   79.72 +Sweet-Pot      9.6      138      2.7     54     290.7       8.4
   79.73 +Peaches        8.5       87      1.7    173      86.8       1.2
   79.74 +Prunes        12.8       99      2.5    154      85.7       3.9
   79.75 +Limabeans     17.4     1055      3.7    459       5.1      26.9
   79.76 +Navybeans     26.9     1691     11.4    792        .       38.4
   79.77 +
   79.78 +:          Vitamin-B2  Niacin  Vitamin-C :=
   79.79 +#             (mg)      (mg)     (mg)
   79.80 +
   79.81 +Wheat         33.3       441         .
   79.82 +Cornmeal       7.9       106         .
   79.83 +Cannedmilk    23.5        11        60
   79.84 +Margarine       .          .         .
   79.85 +Cheese        10.3         4         .
   79.86 +Peanut-B       8.1       471         .
   79.87 +Lard            .5         5         .
   79.88 +Liver         50.8       316       525
   79.89 +Porkroast      3.6        79         .
   79.90 +Salmon         4.9       209         .
   79.91 +Greenbeans     5.8        37       862
   79.92 +Cabbage        4.5        26      5369
   79.93 +Onions         5.9        21      1184
   79.94 +Potatoes       7.1       198      2522
   79.95 +Spinach       13.8        33      2755
   79.96 +Sweet-Pot      5.4        83      1912
   79.97 +Peaches        4.3        55        57
   79.98 +Prunes         4.3        65       257
   79.99 +Limabeans     38.2        93         .
  79.100 +Navybeans     24.6       217         .   ;
  79.101 +
  79.102 +end;
    80.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    80.2 +++ b/deps/glpk/examples/dist.mod	Sun Nov 06 20:59:10 2011 +0100
    80.3 @@ -0,0 +1,565 @@
    80.4 +# DIST, a product distribution model
    80.5 +#
    80.6 +# References:
    80.7 +# Robert Fourer, David M. Gay and Brian W. Kernighan, "A Modeling Language
    80.8 +# for Mathematical Programming." Management Science 36 (1990) 519-554.
    80.9 +
   80.10 +###  SHIPPING SETS AND PARAMETERS  ###
   80.11 +
   80.12 +set whse 'warehouses';  # Locations from which demand is satisfied
   80.13 +
   80.14 +set dctr 'distribution centers' within whse;
   80.15 +
   80.16 +                        # Locations from which product may be shipped
   80.17 +
   80.18 +param sc 'shipping cost' {dctr,whse} >= 0;
   80.19 +
   80.20 +                        # Shipping costs, to whse from dctr, in $ / 100 lb
   80.21 +
   80.22 +param huge 'largest shipping cost' > 0;
   80.23 +
   80.24 +                        # Largest cost allowed for a usable shipping route
   80.25 +
   80.26 +param msr 'minimum size restriction' {dctr,whse} logical;
   80.27 +
   80.28 +                        # True indicates a minimum-size restriction on
   80.29 +                        # direct shipments using this dctr --> whse route
   80.30 +
   80.31 +param dsr 'direct shipment requirement' {dctr} >= 0;
   80.32 +
   80.33 +                        # Minimum total demand, in pallets, needed to
   80.34 +                        # allow shipment on routes subject to the
   80.35 +                        # minimum size restriction
   80.36 +
   80.37 +###  PLANT SETS AND PARAMETERS  ###
   80.38 +
   80.39 +set fact 'factories' within dctr;
   80.40 +
   80.41 +                        # Locations where product is manufactured
   80.42 +
   80.43 +param rtmin 'regular-time total minimum' >= 0;
   80.44 +
   80.45 +                        # Lower limit on (average) total regular-time
   80.46 +                        # crews employed at all factories
   80.47 +
   80.48 +param rtmax 'regular-time total maximum' >= rtmin;
   80.49 +
   80.50 +                        # Upper limit on (average) total regular-time
   80.51 +                        # crews employed at all factories
   80.52 +
   80.53 +param otmin 'overtime total minimum' >= 0;
   80.54 +
   80.55 +                        # Lower limit on total overtime hours at all factories
   80.56 +
   80.57 +param otmax 'overtime total maximum' >= otmin;
   80.58 +
   80.59 +                        # Upper limit on total overtime hours at all factories
   80.60 +
   80.61 +param rmin 'regular-time minimums' {fact} >= 0;
   80.62 +
   80.63 +                        # Lower limits on (average) regular-time crews
   80.64 +
   80.65 +param rmax 'regular-time maximums' {f in fact} >= rmin[f];
   80.66 +
   80.67 +                        # Upper limits on (average) regular-time crews
   80.68 +
   80.69 +param omin 'overtime minimums' {fact} >= 0;
   80.70 +
   80.71 +                        # Lower limits on overtime hours
   80.72 +
   80.73 +param omax 'overtime maximums' {f in fact} >= omin[f];
   80.74 +
   80.75 +                        # Upper limits on overtime hours
   80.76 +
   80.77 +param hd 'hours per day' {fact} >= 0;
   80.78 +
   80.79 +                        # Regular-time hours per working day
   80.80 +
   80.81 +param dp 'days in period' {fact} > 0;
   80.82 +
   80.83 +                        # Working days in the current planning period
   80.84 +
   80.85 +###  PRODUCT SETS AND PARAMETERS  ###
   80.86 +
   80.87 +set prd 'products';     # Elements of the product group
   80.88 +
   80.89 +param wt 'weight' {prd} > 0;
   80.90 +
   80.91 +                        # Weight in 100 lb / 1000 cases
   80.92 +
   80.93 +param cpp 'cases per pallet' {prd} > 0;
   80.94 +
   80.95 +                        # Cases of product per shipping pallet
   80.96 +
   80.97 +param tc 'transshipment cost' {prd} >= 0;
   80.98 +
   80.99 +                        # Transshipment cost in $ / 1000 cases
  80.100 +
  80.101 +param pt 'production time' {prd,fact} >= 0;
  80.102 +
  80.103 +                        # Crew-hours to produce 1000 cases
  80.104 +
  80.105 +param rpc 'regular-time production cost' {prd,fact} >= 0;
  80.106 +
  80.107 +                        # Cost of production on regular time,
  80.108 +                        # in $ / 1000 cases
  80.109 +
  80.110 +param opc 'overtime production cost' {prd,fact} >= 0;
  80.111 +
  80.112 +                        # Cost of production on overtime, in $ / 1000 cases
  80.113 +
  80.114 +###  DEMAND SETS AND PARAMETERS  ###
  80.115 +
  80.116 +param dt 'total demand' {prd} >= 0;
  80.117 +
  80.118 +                        # Total demands for products, in 1000s
  80.119 +
  80.120 +param ds 'demand shares' {prd,whse} >= 0.0, <= 1.0;
  80.121 +
  80.122 +                        # Historical demand data, from which each
  80.123 +                        # warehouse's share of total demand is deduced
  80.124 +
  80.125 +param dstot {p in prd} := sum {w in whse} ds[p,w];
  80.126 +
  80.127 +                        # Total of demand shares; should be 1, but often isn't
  80.128 +
  80.129 +param dem 'demand' {p in prd, w in whse} := dt[p] * ds[p,w] / dstot[p];
  80.130 +
  80.131 +                        # Projected demands to be satisfied, in 1000s
  80.132 +
  80.133 +set rt 'shipping routes available' :=
  80.134 +
  80.135 + {d in dctr, w in whse:
  80.136 +         d <> w  and  sc[d,w] < huge  and
  80.137 +         (w in dctr or sum {p in prd} dem[p,w] > 0)  and
  80.138 +         not (msr[d,w] and sum {p in prd} 1000*dem[p,w]/cpp[p] < dsr[d]) };
  80.139 +
  80.140 +                        # List of ordered pairs that represent routes
  80.141 +                        # on which shipments are allowed
  80.142 +
  80.143 +###  VARIABLES  ###
  80.144 +
  80.145 +var Rprd 'regular-time production' {prd,fact} >= 0;
  80.146 +
  80.147 +                        # Regular-time production of each product
  80.148 +                        # at each factory, in 1000s of cases
  80.149 +
  80.150 +var Oprd 'overtime production' {prd,fact} >= 0;
  80.151 +
  80.152 +                        # Overtime production of each product
  80.153 +                        # at each factory, in 1000s of cases
  80.154 +
  80.155 +var Ship 'shipments' {prd,rt} >= 0;
  80.156 +
  80.157 +                        # Shipments of each product on each allowed route,
  80.158 +                        # in 1000s of cases
  80.159 +
  80.160 +var Trans 'transshipments' {prd,dctr} >= 0;
  80.161 +
  80.162 +                        # Transshipments of each product at each
  80.163 +                        # distribution center, in 1000s of cases
  80.164 +
  80.165 +###  OBJECTIVE  ###
  80.166 +
  80.167 +minimize cost:  sum {p in prd, f in fact} rpc[p,f] * Rprd[p,f] +
  80.168 +                sum {p in prd, f in fact} opc[p,f] * Oprd[p,f] +
  80.169 +                sum {p in prd, (d,w) in rt} sc[d,w] * wt[p] * Ship[p,d,w] +
  80.170 +                sum {p in prd, d in dctr} tc[p] * Trans[p,d];
  80.171 +
  80.172 +                        # Total cost:  regular production, overtime
  80.173 +                        # production, shipping, and transshipment
  80.174 +
  80.175 +###  CONSTRAINTS  ###
  80.176 +
  80.177 +rtlim 'regular-time total limits':
  80.178 +
  80.179 +    rtmin <= sum {p in prd, f in fact}
  80.180 +                        (pt[p,f] * Rprd[p,f]) / (dp[f] * hd[f]) <= rtmax;
  80.181 +
  80.182 +                        # Total crews must lie between limits
  80.183 +
  80.184 +otlim 'overtime total limits':
  80.185 +
  80.186 +    otmin <= sum {p in prd, f in fact} pt[p,f] * Oprd[p,f] <= otmax;
  80.187 +
  80.188 +                        # Total overtime must lie between limits
  80.189 +
  80.190 +rlim 'regular-time limits' {f in fact}:
  80.191 +
  80.192 +    rmin[f] <= sum {p in prd}
  80.193 +                        (pt[p,f] * Rprd[p,f]) / (dp[f] * hd[f]) <= rmax[f];
  80.194 +
  80.195 +                        # Crews at each factory must lie between limits
  80.196 +
  80.197 +olim 'overtime limits' {f in fact}:
  80.198 +
  80.199 +    omin[f] <= sum {p in prd} pt[p,f] * Oprd[p,f] <= omax[f];
  80.200 +
  80.201 +                        # Overtime at each factory must lie between limits
  80.202 +
  80.203 +noRprd 'no regular production' {p in prd, f in fact: rpc[p,f] = 0}:
  80.204 +
  80.205 +    Rprd[p,f] = 0;
  80.206 +
  80.207 +noOprd 'no overtime production' {p in prd, f in fact: opc[p,f] = 0}:
  80.208 +
  80.209 +    Oprd[p,f] = 0;      # Do not produce where specified cost is zero
  80.210 +
  80.211 +bal 'material balance' {p in prd, w in whse}:
  80.212 +
  80.213 +    sum {(v,w) in rt}
  80.214 +       Ship [p,v,w] + (if w in fact then Rprd[p,w] + Oprd[p,w]) =
  80.215 +
  80.216 +    dem[p,w] + (if w in dctr then sum {(w,v) in rt} Ship[p,w,v]);
  80.217 +
  80.218 +                        # Demand is satisfied by shipment into warehouse
  80.219 +                        # plus production (if it is a factory)
  80.220 +                        # minus shipment out (if it is a distn. center)
  80.221 +
  80.222 +trdef 'transshipment definition' {p in prd, d in dctr}:
  80.223 +
  80.224 +    Trans[p,d] >= sum {(d,w) in rt} Ship [p,d,w] -
  80.225 +                  (if d in fact then Rprd[p,d] + Oprd[p,d]);
  80.226 +
  80.227 +                        # Transshipment at a distribution center is
  80.228 +                        # shipments out less production (if any)
  80.229 +
  80.230 +###  DATA -- 3 PRODUCTS  ###
  80.231 +
  80.232 +data;
  80.233 +
  80.234 +set prd := 18REG 24REG 24PRO ;
  80.235 +
  80.236 +set whse := w01 w02 w03 w04 w05 w06 w08 w09 w12 w14 w15 w17
  80.237 +            w18 w19 w20 w21 w24 w25 w26 w27 w28 w29 w30 w31
  80.238 +            w32 w33 w34 w35 w36 w37 w38 w39 w40 w41 w42 w43
  80.239 +            w44 w45 w46 w47 w48 w49 w50 w51 w53 w54 w55 w56
  80.240 +            w57 w59 w60 w61 w62 w63 w64 w65 w66 w68 w69 w71
  80.241 +            w72 w73 w74 w75 w76 w77 w78 w79 w80 w81 w82 w83
  80.242 +            w84 w85 w86 w87 w89 w90 w91 w92 w93 w94 w95 w96
  80.243 +            w98 x22 x23 ;
  80.244 +
  80.245 +set dctr := w01 w02 w03 w04 w05 w62 w76 w96 ;
  80.246 +
  80.247 +set fact := w01 w05 w96 ;
  80.248 +
  80.249 +param huge := 99. ;
  80.250 +
  80.251 +param rtmin := 0.0 ;
  80.252 +param rtmax := 8.0 ;
  80.253 +
  80.254 +param otmin :=  0.0 ;
  80.255 +param otmax := 96.0 ;
  80.256 +
  80.257 +param rmin  :=  w01 0.00   w05 0.00   w96 0.00 ;
  80.258 +param rmax  :=  w01 3.00   w05 2.00   w96 3.00 ;
  80.259 +
  80.260 +param omin  :=  w01  0.0   w05  0.0   w96  0.0 ;
  80.261 +param omax  :=  w01 48.0   w05  0.0   w96 48.0 ;
  80.262 +
  80.263 +param hd    :=  w01  8.0   w05  8.0   w96  8.0 ;
  80.264 +
  80.265 +param dp    :=  w01 19.0   w05 19.0   w96 19.0 ;
  80.266 +
  80.267 +param wt  :=  18REG  47.3    24REG  63.0    24PRO  63.0 ;
  80.268 +
  80.269 +param tc  :=  18REG  40.00   24REG  45.00   24PRO  45.00 ;
  80.270 +
  80.271 +param dt  :=  18REG 376.0    24REG 172.4    24PRO 316.3 ;
  80.272 +
  80.273 +param cpp :=  18REG 102.     24REG  91.     24PRO  91. ;
  80.274 +
  80.275 +param dsr := w01 96.  w02 96.  w03 96.  w04 96.  w05 96.
  80.276 +             w62 96.  w76 96.  w96 96. ;
  80.277 +
  80.278 +param pt (tr) :
  80.279 +
  80.280 +       18REG     24REG     24PRO    :=
  80.281 +
  80.282 +w01    1.194     1.429     1.429
  80.283 +w05    1.194     1.509     1.509
  80.284 +w96    0.000     1.600     1.600    ;
  80.285 +
  80.286 +param rpc (tr) :
  80.287 +
  80.288 +       18REG     24REG     24PRO    :=
  80.289 +
  80.290 +w01    2119.       2653.    2617.
  80.291 +w05    2489.       3182.    3176.
  80.292 +w96       0.       2925.    2918.   ;
  80.293 +
  80.294 +param opc (tr) :
  80.295 +
  80.296 +       18REG     24REG     24PRO    :=
  80.297 +
  80.298 +w01    2903.     3585.     3579.
  80.299 +w05       0.        0.        0.
  80.300 +w96       0.     3629.     3622.    ;
  80.301 +
  80.302 +param sc  default 99.99 (tr) :
  80.303 +
  80.304 +         w01     w02     w03     w04     w05     w62     w76     w96  :=
  80.305 +
  80.306 +w01      .      2.97    1.14    2.08    2.37    1.26    2.42    1.43
  80.307 +w02     4.74     .      4.17    6.12    7.41    3.78    7.04    5.21
  80.308 +w03     2.45    4.74     .      3.67    2.84    0.90    2.41    2.55
  80.309 +w04     1.74    5.03    2.43     .      3.19    2.45    2.69    0.58
  80.310 +w05     2.70    5.16    2.84    2.85     .      3.26    3.34    2.71
  80.311 +w06     1.99    4.17    2.13    2.19    2.52    2.06    2.00    1.51
  80.312 +w08     0.21    2.92    1.24    2.07    2.29    1.25    2.32    1.55
  80.313 +w09     0.66    3.76    1.41    2.47    1.82    1.66     .      1.87
  80.314 +w12     1.38    3.83    1.68    2.53    2.39     .      1.96    1.94
  80.315 +w14     2.47    1.58    2.40    3.59    3.85    2.25     .      3.05
  80.316 +w15     1.06    4.95    2.48    1.39    3.41    1.96     .      1.02
  80.317 +w17     0.88    3.39    1.46    2.00    2.67    1.45     .      1.46
  80.318 +w18     7.90    6.57    7.79    9.59    10.81    .       .      6.70
  80.319 +w19     1.42    4.12    1.96    1.99    3.52    1.88     .      1.26
  80.320 +w20     3.03    1.59    2.34    4.76    3.98    1.88     .      3.73
  80.321 +w24     1.58    2.80    2.27    2.87    3.19    1.31     .      2.05
  80.322 +w25     1.51    5.05    2.74    0.57    2.98     .      2.95    0.27
  80.323 +w26     1.75    3.61    2.70    1.54    4.07    3.52     .      1.03
  80.324 +w27     2.48    6.87    3.17    1.59    2.08    3.45     .      0.99
  80.325 +w28     2.05    6.83    2.97    1.13    2.91     .       .      1.26
  80.326 +w29     4.03    3.68    4.46    3.20    5.50     .       .      3.20
  80.327 +w30     2.48    5.78    2.99    2.24    1.79    3.10     .      1.39
  80.328 +w31     2.34    5.41    2.87    1.67    1.66     .       .      1.39
  80.329 +w32     14.36    .       .       .       .       .       .       .
  80.330 +w33     3.87    4.27    5.11    3.48    5.66    4.03     .      3.05
  80.331 +w34     3.26    4.80    3.21    2.70    4.14     .       .      1.77
  80.332 +w35     2.34    2.84    2.89    3.35    3.78    2.68     .      2.52
  80.333 +w36     2.43    5.69    2.96    2.95    1.02    2.61    1.07    2.54
  80.334 +w37     2.23    4.64    2.41    1.99    4.30    2.61     .      1.44
  80.335 +w38     4.66    4.36    5.23    3.04    4.46     .       .      3.82
  80.336 +w39     1.11    3.51    1.10    2.53    3.07    1.12     .      2.23
  80.337 +w40     2.99    4.78    4.23    1.57    3.92     .       .      1.80
  80.338 +w41     4.93    4.00    5.43    4.45    6.31     .       .      3.81
  80.339 +w42     3.86    6.55    5.03    2.11    4.41     .       .      2.63
  80.340 +w43     4.61    4.45    3.77    1.22    4.31     .       .      2.35
  80.341 +w44     2.05    4.48    1.06    3.70    3.46    1.10     .      3.21
  80.342 +w45     0.92    3.42    1.58    3.04    1.82    1.94     .      2.52
  80.343 +w46     1.36    2.44    0.95    3.08    2.78    0.39    2.16    2.37
  80.344 +w47     1.30    3.39    1.60    2.49    4.29    2.04     .      1.68
  80.345 +w48     1.65    3.78    1.03    2.97    2.21    1.31     .      2.74
  80.346 +w49     1.96    3.00    1.50    3.24    3.68    1.00     .      2.99
  80.347 +w50     0.90    4.14    1.60    1.95    3.61    1.61     .      1.52
  80.348 +w51     1.59    3.95    0.25    2.96    2.58    1.00    2.41    2.71
  80.349 +w53     1.59    3.79    1.28    3.12    3.10    0.89     .      2.98
  80.350 +w54     1.72    4.36    1.61    2.92    2.34    1.91    1.97    3.05
  80.351 +w55     2.45    2.73    2.21    4.47    4.30    2.57     .      4.48
  80.352 +w56     1.10    3.73    1.59    2.74    2.33    1.45     .      2.44
  80.353 +w57     0.95    3.39    1.37    2.30    2.47    1.15     .      1.95
  80.354 +w59     3.29    5.35    3.32    3.81    1.52    3.38    1.34    4.08
  80.355 +w60     2.41    6.12    2.46    3.65    2.35     .      1.37    4.06
  80.356 +w61     3.32    5.50    3.41    3.38    1.23     .      0.99    4.28
  80.357 +w62     1.12    3.00    0.82    3.22    2.95     .      3.33    2.53
  80.358 +w63     3.59    6.36    3.25    4.12    1.84    3.59    1.46    4.03
  80.359 +w64     1.85    4.45    2.17    3.43    2.13    2.03     .      4.02
  80.360 +w65     2.78    4.79    2.81    2.94    1.54    2.90    1.07    2.94
  80.361 +w66     3.90    5.79    3.05    3.65    1.36    3.39    1.22    3.57
  80.362 +w68     2.61    5.20    2.90    2.34    1.68    3.19    1.48    2.31
  80.363 +w69     2.94    5.21    2.78    3.43    0.21    3.26    0.68    2.54
  80.364 +w71     2.06    4.98    2.38    2.44    1.59    2.97    1.05    2.55
  80.365 +w72     2.61    5.50    2.83    3.12    1.35    3.23    0.88    2.99
  80.366 +w73     8.52    6.16    8.03    8.83    10.44   7.38    10.26    .
  80.367 +w74     6.11    5.46    9.07    9.38    10.80    .       .      8.25
  80.368 +w75     2.66    4.94    2.87    3.69    1.52    3.15    1.24    4.00
  80.369 +w76     1.99    5.26    2.23    3.36    0.58    3.17     .      2.50
  80.370 +w77     4.32    3.07    5.05    3.88    6.04     .       .      4.15
  80.371 +w78     5.60    2.59    5.78    5.56    7.10     .       .      5.60
  80.372 +w79     4.25    2.32    4.93    4.57    6.04     .       .      4.58
  80.373 +w80     5.94    4.00    5.60    7.02    9.46     .       .      7.51
  80.374 +w81     5.39    2.21    5.10    6.22    6.46     .       .      6.58
  80.375 +w82     8.80    5.69    9.29    9.88    11.69   8.63    11.52    .
  80.376 +w83     4.40     .      5.24    5.21    5.81    3.91    7.04    5.33
  80.377 +w84     5.87    5.43    6.17    5.70    7.63     .       .      5.70
  80.378 +w85     3.90    3.65    3.38    4.57    5.64    3.05     .      5.04
  80.379 +w86     5.48    2.10    5.70    6.37    7.33     .       .      6.19
  80.380 +w87     8.88    5.54    9.50    9.71    11.64   8.85    11.68    .
  80.381 +w89     4.62    4.01    4.03    6.30    6.30    3.81     .      7.77
  80.382 +w90     4.35    2.72    4.61    4.01    5.60     .       .      3.20
  80.383 +w91     7.61    4.42    7.83    6.85    8.79     .       .      7.66
  80.384 +w92     7.15    2.69    6.91    7.20     .       .       .      7.06
  80.385 +w93     3.17    3.95    4.37    3.74    5.05     .       .      2.40
  80.386 +w94     1.21    3.07    0.90    2.74    3.17     .      2.63    2.39
  80.387 +w95     5.82    3.29    6.55    7.06    11.47    .       .      7.83
  80.388 +w96     1.77    5.20    2.72    0.59    3.47    2.48     .       .
  80.389 +w98     3.04    1.92    3.64    3.70    4.90    3.05     .      3.88
  80.390 +x22     4.08    6.25    4.15    4.30    1.77     .      1.77     .
  80.391 +x23     3.39    5.74    3.55    4.08    1.69     .      1.47     .      ;
  80.392 +
  80.393 +param msr (tr) :
  80.394 +
  80.395 +         w01     w02     w03     w04     w05     w62     w76     w96    :=
  80.396 +
  80.397 +w01        0       0       0       0       0       0       1       0
  80.398 +w02        0       0       0       0       0       0       1       0
  80.399 +w03        0       0       0       0       0       0       1       0
  80.400 +w04        0       0       0       0       0       0       1       0
  80.401 +w05        0       0       0       0       0       0       0       0
  80.402 +w06        0       1       1       1       1       1       1       1
  80.403 +w08        0       1       1       1       1       1       1       1
  80.404 +w09        0       1       1       1       1       1       0       1
  80.405 +w12        0       1       1       1       1       0       1       1
  80.406 +w14        1       1       1       1       1       0       0       1
  80.407 +w15        0       1       1       1       1       1       0       1
  80.408 +w17        0       1       1       1       1       1       0       1
  80.409 +w18        0       1       1       1       1       0       0       1
  80.410 +w19        0       1       1       1       1       0       0       1
  80.411 +w20        1       1       1       1       1       0       0       1
  80.412 +w24        0       1       1       1       1       0       0       1
  80.413 +w25        0       1       1       1       1       0       1       0
  80.414 +w26        1       1       1       0       1       1       0       1
  80.415 +w27        1       1       1       0       1       1       0       1
  80.416 +w28        1       1       1       0       1       0       0       1
  80.417 +w29        0       1       1       1       1       0       0       1
  80.418 +w30        1       1       1       0       1       1       0       1
  80.419 +w31        1       1       1       0       1       0       0       1
  80.420 +w32        0       0       0       0       0       0       0       0
  80.421 +w33        1       0       1       1       1       1       0       1
  80.422 +w34        1       1       1       0       1       0       0       1
  80.423 +w35        1       1       1       1       1       0       0       1
  80.424 +w36        0       1       1       1       0       1       1       1
  80.425 +w37        1       1       1       0       1       1       0       1
  80.426 +w38        1       1       1       0       1       0       0       1
  80.427 +w39        0       1       1       1       1       1       0       1
  80.428 +w40        1       1       1       0       1       0       0       1
  80.429 +w41        1       0       1       1       1       0       0       1
  80.430 +w42        1       1       1       0       1       0       0       1
  80.431 +w43        1       1       1       0       1       0       0       1
  80.432 +w44        1       1       1       1       1       0       0       1
  80.433 +w45        0       1       1       1       1       1       0       1
  80.434 +w46        0       1       1       1       1       0       1       1
  80.435 +w47        0       1       1       1       1       1       0       1
  80.436 +w48        0       1       1       1       1       0       0       1
  80.437 +w49        1       1       1       1       1       0       0       1
  80.438 +w50        0       1       1       1       1       1       0       1
  80.439 +w51        0       1       1       1       1       0       1       1
  80.440 +w53        1       1       1       1       1       0       0       1
  80.441 +w54        0       1       1       1       1       1       1       1
  80.442 +w55        0       1       1       1       1       0       0       1
  80.443 +w56        0       1       1       1       1       1       0       1
  80.444 +w57        0       1       1       1       1       1       0       1
  80.445 +w59        0       1       1       1       0       1       1       1
  80.446 +w60        0       1       1       1       1       0       1       1
  80.447 +w61        0       1       1       1       0       0       1       1
  80.448 +w62        0       0       0       0       0       0       1       0
  80.449 +w63        0       1       1       1       0       1       1       1
  80.450 +w64        0       1       1       1       1       1       0       1
  80.451 +w65        0       1       1       1       0       1       1       1
  80.452 +w66        0       1       1       1       0       1       1       1
  80.453 +w68        0       1       1       1       0       1       1       1
  80.454 +w69        0       1       1       1       0       1       1       1
  80.455 +w71        0       1       1       1       0       1       1       1
  80.456 +w72        0       1       1       1       0       1       1       1
  80.457 +w73        0       1       1       1       0       1       1       0
  80.458 +w74        0       1       1       1       0       0       0       1
  80.459 +w75        0       1       1       1       0       1       1       1
  80.460 +w76        0       0       0       0       0       0       0       0
  80.461 +w77        1       0       1       1       1       0       0       1
  80.462 +w78        1       0       1       1       1       0       0       1
  80.463 +w79        1       0       1       1       1       0       0       1
  80.464 +w80        1       0       1       1       1       0       0       1
  80.465 +w81        1       0       1       1       1       0       0       1
  80.466 +w82        1       0       1       1       1       1       1       0
  80.467 +w83        1       0       1       1       1       0       1       1
  80.468 +w84        1       0       1       1       1       0       0       1
  80.469 +w85        1       1       1       1       1       0       0       1
  80.470 +w86        1       0       1       1       1       0       0       1
  80.471 +w87        1       0       1       1       1       1       1       0
  80.472 +w89        1       0       1       1       1       1       0       1
  80.473 +w90        0       1       1       1       1       0       0       1
  80.474 +w91        1       0       1       1       1       0       0       1
  80.475 +w92        1       0       1       1       1       0       0       1
  80.476 +w93        1       1       1       0       1       0       0       1
  80.477 +w94        0       0       1       1       1       0       1       1
  80.478 +w95        1       0       1       1       1       0       0       1
  80.479 +w96        0       0       0       0       0       0       0       0
  80.480 +w98        1       0       1       1       1       1       0       1
  80.481 +x22        1       1       1       1       0       0       1       0
  80.482 +x23        1       1       1       1       0       0       1       0    ;
  80.483 +
  80.484 +param ds default 0.000 (tr) :
  80.485 +
  80.486 +         18REG     24REG     24PRO    :=
  80.487 +
  80.488 +w01      0.000     0.000     0.008
  80.489 +w02      0.004     0.000     0.000
  80.490 +w03      0.000     0.000     0.000
  80.491 +w04      0.010     0.002     0.000
  80.492 +w05      0.000     0.000     0.000
  80.493 +w06      0.010     0.008     0.008
  80.494 +w08      0.030     0.024     0.024
  80.495 +w09      0.014     0.018     0.020
  80.496 +w12      0.014     0.012     0.010
  80.497 +w14      0.007     0.007     0.012
  80.498 +w15      0.010     0.019     0.018
  80.499 +w17      0.013     0.010     0.011
  80.500 +w19      0.015     0.012     0.009
  80.501 +w20      0.012     0.021     0.022
  80.502 +w21      0.000     0.000     0.000
  80.503 +w24      0.012     0.022     0.018
  80.504 +w25      0.019     0.025     0.020
  80.505 +w26      0.006     0.015     0.021
  80.506 +w27      0.008     0.010     0.015
  80.507 +w28      0.011     0.016     0.019
  80.508 +w29      0.008     0.020     0.013
  80.509 +w30      0.011     0.013     0.015
  80.510 +w31      0.011     0.013     0.017
  80.511 +w32      0.006     0.000     0.000
  80.512 +w33      0.000     0.015     0.014
  80.513 +w34      0.008     0.007     0.005
  80.514 +w35      0.002     0.006     0.014
  80.515 +w36      0.015     0.013     0.005
  80.516 +w37      0.017     0.016     0.015
  80.517 +w38      0.015     0.009     0.012
  80.518 +w39      0.007     0.017     0.022
  80.519 +w40      0.009     0.014     0.020
  80.520 +w41      0.003     0.014     0.011
  80.521 +w42      0.017     0.011     0.012
  80.522 +w43      0.009     0.013     0.011
  80.523 +w44      0.002     0.012     0.012
  80.524 +w45      0.016     0.025     0.028
  80.525 +w46      0.038     0.062     0.040
  80.526 +w47      0.007     0.010     0.010
  80.527 +w48      0.003     0.015     0.016
  80.528 +w49      0.005     0.016     0.017
  80.529 +w50      0.011     0.008     0.007
  80.530 +w51      0.010     0.022     0.021
  80.531 +w53      0.004     0.026     0.020
  80.532 +w54      0.020     0.017     0.025
  80.533 +w55      0.004     0.019     0.028
  80.534 +w56      0.004     0.010     0.008
  80.535 +w57      0.014     0.020     0.018
  80.536 +w59      0.012     0.006     0.007
  80.537 +w60      0.019     0.010     0.009
  80.538 +w61      0.028     0.010     0.012
  80.539 +w62      0.000     0.000     0.000
  80.540 +w63      0.070     0.027     0.037
  80.541 +w64      0.009     0.004     0.005
  80.542 +w65      0.022     0.015     0.016
  80.543 +w66      0.046     0.017     0.020
  80.544 +w68      0.005     0.012     0.016
  80.545 +w69      0.085     0.036     0.039
  80.546 +w71      0.011     0.013     0.010
  80.547 +w72      0.089     0.031     0.034
  80.548 +w75      0.026     0.012     0.010
  80.549 +w77      0.001     0.004     0.002
  80.550 +w78      0.002     0.004     0.002
  80.551 +w79      0.001     0.004     0.002
  80.552 +w80      0.001     0.001     0.002
  80.553 +w81      0.001     0.003     0.002
  80.554 +w83      0.009     0.010     0.008
  80.555 +w84      0.001     0.002     0.002
  80.556 +w85      0.001     0.004     0.005
  80.557 +w86      0.001     0.002     0.002
  80.558 +w87      0.002     0.003     0.000
  80.559 +w89      0.001     0.001     0.002
  80.560 +w90      0.006     0.017     0.013
  80.561 +w91      0.002     0.010     0.013
  80.562 +w92      0.000     0.003     0.002
  80.563 +w93      0.002     0.006     0.007
  80.564 +w95      0.001     0.007     0.007
  80.565 +w96      0.000     0.000     0.000
  80.566 +w98      0.006     0.005     0.002    ;
  80.567 +
  80.568 +end;
    81.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    81.2 +++ b/deps/glpk/examples/egypt.mod	Sun Nov 06 20:59:10 2011 +0100
    81.3 @@ -0,0 +1,519 @@
    81.4 +# EGYPT, a static model of fertilizer production
    81.5 +#
    81.6 +# References:
    81.7 +# Robert Fourer, David M. Gay and Brian W. Kernighan, "A Modeling Language
    81.8 +# for Mathematical Programming." Management Science 36 (1990) 519-554.
    81.9 +
   81.10 +###  SETS  ###
   81.11 +
   81.12 +set center;                # Locations from which final product may be shipped
   81.13 +set port within center;    # Locations at which imports can be received
   81.14 +set plant within center;   # Locations of plants
   81.15 +
   81.16 +set region;                # Demand regions
   81.17 +
   81.18 +set unit;                  # Productive units
   81.19 +set proc;                  # Processes
   81.20 +
   81.21 +set nutr;                  # Nutrients
   81.22 +
   81.23 +set c_final;               # Final products (fertilizers)
   81.24 +set c_inter;               # Intermediate products
   81.25 +set c_ship within c_inter; # Intermediates for shipment
   81.26 +set c_raw;                 # Domestic raw materials and miscellaneous inputs
   81.27 +
   81.28 +set commod := c_final union c_inter union c_raw;
   81.29 +
   81.30 +                           # All commodities
   81.31 +
   81.32 +###  PARAMETERS  ###
   81.33 +
   81.34 +param cf75 {region,c_final} >= 0;
   81.35 +
   81.36 +                           # Consumption of fertilizer 1974-75 (1000 tpy)
   81.37 +
   81.38 +param fn {c_final,nutr} >= 0;
   81.39 +
   81.40 +                           # Nutrient content of fertilizers
   81.41 +
   81.42 +param cn75 {r in region, n in nutr} := sum {c in c_final} cf75[r,c] * fn[c,n];
   81.43 +
   81.44 +                           # Consumption of nutrients 1974-75 (1000 tpy)
   81.45 +
   81.46 +param road {region,center} >= 0;
   81.47 +
   81.48 +                           # Road distances
   81.49 +
   81.50 +param rail_half {plant,plant} >= 0;
   81.51 +param rail {p1 in plant, p2 in plant} :=
   81.52 +    if rail_half[p1,p2] > 0 then rail_half[p1,p2] else rail_half[p2,p1];
   81.53 +
   81.54 +                           # Interplant rail distances (kms)
   81.55 +
   81.56 +param impd_barg {plant} >= 0;
   81.57 +param impd_road {plant} >= 0;
   81.58 +
   81.59 +                           # Import distances (kms) by barge and road
   81.60 +
   81.61 +param tran_final {pl in plant, r in region} :=
   81.62 +              if road[r,pl] > 0 then .5 + .0144 * road[r,pl] else 0;
   81.63 +
   81.64 +param tran_import {r in region, po in port} :=
   81.65 +              if road[r,po] > 0 then .5 + .0144 * road[r,po] else 0;
   81.66 +
   81.67 +param tran_inter {p1 in plant, p2 in plant} :=
   81.68 +              if rail[p1,p2] > 0 then 3.5 + .03 * rail[p1,p2] else 0;
   81.69 +
   81.70 +param tran_raw {pl in plant} :=
   81.71 +            (if impd_barg[pl] > 0 then 1.0 + .0030 * impd_barg[pl] else 0)
   81.72 +          + (if impd_road[pl] > 0 then 0.5 + .0144 * impd_road[pl] else 0);
   81.73 +
   81.74 +                           # Transport cost (le per ton) for:
   81.75 +                           #   final products, imported final products,
   81.76 +                           #   interplant shipment, imported raw materials
   81.77 +
   81.78 +param io {commod,proc};    # Input-output coefficients
   81.79 +
   81.80 +param util {unit,proc} >= 0;
   81.81 +
   81.82 +                           # Capacity utilization coefficients
   81.83 +
   81.84 +param p_imp {commod} >= 0; # Import Price (cif US$ per ton 1975)
   81.85 +
   81.86 +param p_r {c_raw} >= 0;
   81.87 +param p_pr {plant,c_raw} >= 0;
   81.88 +
   81.89 +param p_dom {pl in plant, c in c_raw} :=
   81.90 +              if p_r[c] > 0 then p_r[c] else p_pr[pl,c];
   81.91 +
   81.92 +                           # Domestic raw material prices
   81.93 +
   81.94 +param dcap {plant,unit} >= 0;
   81.95 +
   81.96 +                           # Design capacity of plants (t/day)
   81.97 +
   81.98 +param icap {u in unit, pl in plant} := 0.33 * dcap[pl,u];
   81.99 +
  81.100 +                           # Initial capacity of plants (t/day)
  81.101 +
  81.102 +param exch := 0.4;         # Exchange rate
  81.103 +
  81.104 +param util_pct := 0.85;    # Utilization percent for initial capacity
  81.105 +
  81.106 +###  DERIVED SETS OF "POSSIBILITIES"  ###
  81.107 +
  81.108 +set m_pos {pl in plant} := {u in unit: icap[u,pl] > 0};
  81.109 +
  81.110 +                           # At each plant, set of units for which there is
  81.111 +                           # initial capacity
  81.112 +
  81.113 +set p_cap {pl in plant} :=
  81.114 +             {pr in proc: forall {u in unit: util[u,pr] > 0} u in m_pos[pl] };
  81.115 +
  81.116 +                           # At each plant, set of processes for which
  81.117 +                           # all necessary units have some initial capacity
  81.118 +
  81.119 +set p_except {plant} within proc;
  81.120 +
  81.121 +                           # At each plant, list of processes that are
  81.122 +                           # arbitrarily ruled out
  81.123 +
  81.124 +set p_pos {pl in plant} := p_cap[pl] diff p_except[pl];
  81.125 +
  81.126 +                           # At each plant, set of possible processes
  81.127 +
  81.128 +set cp_pos {c in commod} := {pl in plant: sum {pr in p_pos[pl]} io[c,pr] > 0};
  81.129 +
  81.130 +set cc_pos {c in commod} := {pl in plant: sum {pr in p_pos[pl]} io[c,pr] < 0};
  81.131 +
  81.132 +set c_pos {c in commod} := cp_pos[c] union cc_pos[c];
  81.133 +
  81.134 +                           # For each commodity, set of plants that can
  81.135 +                           # produce it (cp_pos) or consume it (cc_pos),
  81.136 +                           # and their union (c_pos)
  81.137 +
  81.138 +###  VARIABLES  ###
  81.139 +
  81.140 +var Z {pl in plant, p_pos[pl]} >= 0;
  81.141 +
  81.142 +                           # Z[pl,pr] is level of process pr at plant pl
  81.143 +
  81.144 +var Xf {c in c_final, cp_pos[c], region} >= 0;
  81.145 +
  81.146 +                           # Xf[c,pl,r] is amount of final product c
  81.147 +                           # shipped from plant pl to region r
  81.148 +
  81.149 +var Xi {c in c_ship, cp_pos[c], cc_pos[c]} >= 0;
  81.150 +
  81.151 +                           # Xi[c,p1,p2] is amount of intermediate c
  81.152 +                           # shipped from plant p1 to plant p2
  81.153 +
  81.154 +var Vf {c_final,region,port} >= 0;
  81.155 +
  81.156 +                           # Vf[c,r,po] is amount of final product c
  81.157 +                           # imported by region r from port po
  81.158 +
  81.159 +var Vr {c in c_raw, cc_pos[c]} >= 0;
  81.160 +
  81.161 +                           # Vr[c,pl] is amount of raw material c
  81.162 +                           # imported for use at plant pl
  81.163 +
  81.164 +var U {c in c_raw, cc_pos[c]} >= 0;
  81.165 +
  81.166 +                           # U[c,pl] is amount of raw material c
  81.167 +                           # purchased domestically for use at plant pl
  81.168 +
  81.169 +var Psip;                  # Domestic recurrent cost
  81.170 +var Psil;                  # Transport cost
  81.171 +var Psii;                  # Import cost
  81.172 +
  81.173 +###  OBJECTIVE  ###
  81.174 +
  81.175 +minimize Psi:  Psip + Psil + Psii;
  81.176 +
  81.177 +###  CONSTRAINTS  ###
  81.178 +
  81.179 +subject to mbd {n in nutr, r in region}:
  81.180 +
  81.181 +    sum {c in c_final} fn[c,n] *
  81.182 +                (sum {po in port} Vf[c,r,po] +
  81.183 +                 sum {pl in cp_pos[c]} Xf[c,pl,r])  >=  cn75[r,n];
  81.184 +
  81.185 +                           # Total nutrients supplied to a region by all
  81.186 +                           # final products (sum of imports plus internal
  81.187 +                           # shipments from plants) must meet requirements
  81.188 +
  81.189 +subject to mbdb {c in c_final, r in region: cf75[r,c] > 0}:
  81.190 +
  81.191 +    sum {po in port} Vf[c,r,po] +
  81.192 +    sum {pl in cp_pos[c]} Xf[c,pl,r]  >=  cf75[r,c];
  81.193 +
  81.194 +                           # Total of each final product supplied to each
  81.195 +                           # region (as in previous constraint) must meet
  81.196 +                           # requirements
  81.197 +
  81.198 +subject to mb {c in commod, pl in plant}:
  81.199 +
  81.200 +    sum {pr in p_pos[pl]} io[c,pr] * Z[pl,pr]
  81.201 +
  81.202 +   + ( if c in c_ship then
  81.203 +                ( if pl in cp_pos[c] then sum {p2 in cc_pos[c]} Xi[c,pl,p2] )
  81.204 +              - ( if pl in cc_pos[c] then sum {p2 in cp_pos[c]} Xi[c,p2,pl] ))
  81.205 +
  81.206 +   + ( if (c in c_raw and pl in cc_pos[c]) then
  81.207 +                 (( if p_imp[c] > 0 then Vr[c,pl] )
  81.208 +                + ( if p_dom[pl,c] > 0 then U[c,pl] )))
  81.209 +
  81.210 +  >= if (c in c_final and pl in cp_pos[c]) then sum {r in region} Xf[c,pl,r];
  81.211 +
  81.212 +                           # For each commodity at each plant:  sum of
  81.213 +                           #   (1) production or consumption at plant,
  81.214 +                           #   (2) inter-plant shipments in or out,
  81.215 +                           #   (3) import and domestic purchases (raw only)
  81.216 +                           # is >= 0 for raw materials and intermediates;
  81.217 +                           # is >= the total shipped for final products
  81.218 +
  81.219 +subject to cc {pl in plant, u in m_pos[pl]}:
  81.220 +
  81.221 +    sum {pr in p_pos[pl]} util[u,pr] * Z[pl,pr]  <=  util_pct * icap[u,pl];
  81.222 +
  81.223 +                           # For each productive unit at each plant,
  81.224 +                           # total utilization by all processes
  81.225 +                           # may not exceed the unit's capacity
  81.226 +
  81.227 +subject to ap:
  81.228 +
  81.229 +    Psip  =  sum {c in c_raw, pl in cc_pos[c]} p_dom[pl,c] * U[c,pl];
  81.230 +
  81.231 +                           # Psip is the cost of domestic raw materials,
  81.232 +                           # summed over all plants that consume them
  81.233 +
  81.234 +subject to al:
  81.235 +
  81.236 +    Psil  =  sum {c in c_final} (
  81.237 +
  81.238 +               sum {pl in cp_pos[c], r in region}
  81.239 +                                              tran_final[pl,r] * Xf[c,pl,r]
  81.240 +
  81.241 +             + sum {po in port, r in region} tran_import[r,po] * Vf[c,r,po] )
  81.242 +
  81.243 +           + sum {c in c_ship, p1 in cp_pos[c], p2 in cc_pos[c]}
  81.244 +                                               tran_inter[p1,p2] * Xi[c,p1,p2]
  81.245 +
  81.246 +           + sum {c in c_raw, pl in cc_pos[c]: p_imp[c] > 0}
  81.247 +                                                    tran_raw[pl] * Vr[c,pl];
  81.248 +
  81.249 +                           # Total transport cost is sum of shipping costs for
  81.250 +                           #   (1) all final products from all plants,
  81.251 +                           #   (2) all imports of final products,
  81.252 +                           #   (3) all intermediates shipped between plants,
  81.253 +                           #   (4) all imports of raw materials
  81.254 +
  81.255 +subject to ai:
  81.256 +
  81.257 +    Psii / exch  =  sum {c in c_final, r in region, po in port}
  81.258 +                                                      p_imp[c] * Vf[c,r,po]
  81.259 +
  81.260 +                  + sum {c in c_raw, pl in cc_pos[c]} p_imp[c] * Vr[c,pl];
  81.261 +
  81.262 +                           # Total import cost -- at exchange rate --
  81.263 +                           # is sum of import costs for final products
  81.264 +                           # in each region and raw materials at each plant
  81.265 +
  81.266 +###  DATA  ###
  81.267 +
  81.268 +data;
  81.269 +
  81.270 +set center := ASWAN HELWAN ASSIOUT KAFR_EL_ZT ABU_ZAABAL ABU_KIR TALKHA SUEZ ;
  81.271 +
  81.272 +set port := ABU_KIR ;
  81.273 +
  81.274 +set plant := ASWAN HELWAN ASSIOUT KAFR_EL_ZT ABU_ZAABAL ;
  81.275 +
  81.276 +set region := ALEXANDRIA BEHERA GHARBIA KAFR_EL_SH DAKAHLIA DAMIETTA
  81.277 +              SHARKIA ISMAILIA SUEZ MENOUFIA KALUBIA GIZA BENI_SUEF FAYOUM
  81.278 +              MINIA ASSIOUT NEW_VALLEY SOHAG QUENA ASWAN ;
  81.279 +
  81.280 +set unit := SULF_A_S SULF_A_P NITR_ACID AMM_ELEC AMM_C_GAS C_AMM_NITR
  81.281 +            AMM_SULF SSP ;
  81.282 +
  81.283 +set proc := SULF_A_S SULF_A_P NITR_ACID AMM_ELEC AMM_C_GAS CAN_310 CAN_335
  81.284 +            AMM_SULF SSP_155 ;
  81.285 +
  81.286 +set nutr := N P205 ;
  81.287 +
  81.288 +set c_final := UREA CAN_260 CAN_310 CAN_335 AMM_SULF DAP SSP_155 C_250_55
  81.289 +               C_300_100 ;
  81.290 +
  81.291 +set c_inter := AMMONIA NITR_ACID SULF_ACID ;
  81.292 +
  81.293 +set c_ship := AMMONIA SULF_ACID ;
  81.294 +
  81.295 +set c_raw := EL_ASWAN COKE_GAS PHOS_ROCK LIMESTONE EL_SULFUR PYRITES
  81.296 +             ELECTRIC BF_GAS WATER STEAM BAGS ;
  81.297 +
  81.298 +set p_except[ASWAN] := CAN_335 ;
  81.299 +set p_except[HELWAN] := CAN_310 ;
  81.300 +set p_except[ASSIOUT] := ;
  81.301 +set p_except[KAFR_EL_ZT] := ;
  81.302 +set p_except[ABU_ZAABAL] := ;
  81.303 +
  81.304 +param cf75  default 0.0  :
  81.305 +
  81.306 +               CAN_260    CAN_310    CAN_335    AMM_SULF     UREA   :=
  81.307 +
  81.308 +ALEXANDRIA        .           .         5.0        3.0        1.0
  81.309 +ASSIOUT          1.0        20.0       26.0        1.0       27.0
  81.310 +ASWAN             .         40.0         .          .          .
  81.311 +BEHERA           1.0          .        25.0       90.0       35.0
  81.312 +BENI_SUEF        1.0          .        15.0        1.0       20.0
  81.313 +DAKAHLIA         1.0          .        26.0       60.0       20.0
  81.314 +DAMIETTA          .           .         2.0       15.0        8.0
  81.315 +FAYOUM           1.0          .        20.0        6.0       20.0
  81.316 +GHARBIA           .           .        17.0       60.0       28.0
  81.317 +GIZA              .           .        40.0        6.0        2.0
  81.318 +ISMAILIA          .           .         4.0        6.0        2.0
  81.319 +KAFR_EL_SH       1.0          .        10.0       45.0       22.0
  81.320 +KALUBIA           .           .        25.0       16.0        7.0
  81.321 +MENOUFIA         1.0          .        24.0       21.0       30.0
  81.322 +MINIA            2.0        15.0       35.0        1.0       41.0
  81.323 +NEW_VALLEY        .           .          .          .         1.0
  81.324 +QUENA             .         95.0        2.0         .         3.0
  81.325 +SHARKIA          1.0          .        31.0       50.0       28.0
  81.326 +SOHAG             .         65.0        3.0         .         7.0
  81.327 +SUEZ              .           .         1.0         .          .
  81.328 +
  81.329 +   :          SSP_155    C_250_55   C_300_100    DAP   :=
  81.330 +
  81.331 +ALEXANDRIA       8.0         .          .         .
  81.332 +ASSIOUT         35.0        5.0         .1        .
  81.333 +ASWAN            8.0         .          .         .
  81.334 +BEHERA          64.0        1.0         .1        .1
  81.335 +BENI_SUEF       13.0        3.0         .         .
  81.336 +DAKAHLIA        52.0        1.0         .         .
  81.337 +DAMIETTA         5.0         .          .         .
  81.338 +FAYOUM          17.0        1.0         .         .
  81.339 +GHARBIA         57.0        1.0         .2        .1
  81.340 +GIZA            14.0        1.0         .1        .
  81.341 +ISMAILIA         4.0         .          .         .
  81.342 +KAFR_EL_SH      25.0        2.0         .1        .
  81.343 +KALUBIA         22.0        1.0         .         .1
  81.344 +MENOUFIA        33.0        2.0         .1        .1
  81.345 +MINIA           50.0        3.0         .2        .1
  81.346 +NEW_VALLEY       1.0         .          .         .
  81.347 +QUENA            8.0         .          .         .
  81.348 +SHARKIA         43.0        1.0         .1        .
  81.349 +SOHAG           20.0        1.0         .         .
  81.350 +SUEZ             1.0         .          .         .        ;
  81.351 +
  81.352 +param fn  default 0.0 :      N     P205    :=
  81.353 +
  81.354 +            AMM_SULF       .206     .
  81.355 +            CAN_260        .26      .
  81.356 +            CAN_310        .31      .
  81.357 +            CAN_335        .335     .
  81.358 +            C_250_55       .25      .055
  81.359 +            C_300_100      .30      .10
  81.360 +            DAP            .18      .46
  81.361 +            SSP_155        .        .15
  81.362 +            UREA           .46      .      ;
  81.363 +
  81.364 +param road  default 0.0  :
  81.365 +
  81.366 +            ABU_KIR ABU_ZAABAL ASSIOUT ASWAN HELWAN KAFR_EL_ZT SUEZ TALKHA :=
  81.367 +
  81.368 +ALEXANDRIA      16     210       607    1135   244      119     362   187
  81.369 +ASSIOUT        616     420         .     518   362      504     527   518
  81.370 +ASWAN         1134     938       518       .   880     1022    1045  1036
  81.371 +BEHERA          76      50       547    1065   184       42     288   120
  81.372 +BENI_SUEF      359     163       257     775   105      248     270   261
  81.373 +DAKAHLIA       208     138       515    1033   152       58     219     3
  81.374 +DAMIETTA       267     216       596    1114   233      131     286    66
  81.375 +FAYOUM         341     145       308     826    88      230     252   243
  81.376 +GHARBIA        150      65       485    1003   122       20     226    55
  81.377 +GIZA           287      48       372     890    .9      133     169   146
  81.378 +ISMAILIA       365     142       536    1054   173      241      89   146
  81.379 +KAFR_EL_SH     145     105       525    1043   162       20     266    35
  81.380 +KALUBIA        190      97       439     957    76       66     180    81
  81.381 +MENOUFIA       157     154       472     990   109       33     213    90
  81.382 +MINIA          384     288       132     650   230      372     394   386
  81.383 +NEW_VALLEY     815     619       199     519   561      703     726   717
  81.384 +QUENA          858     662       242     276   604      746     769   760
  81.385 +SHARKIA        240      60       473     991   110       78     214    58
  81.386 +SOHAG          715     519        99     419   461      603     626   617
  81.387 +SUEZ           370     224       541    1059   178      246       .   298  ;
  81.388 +
  81.389 +param rail_half  default 0  :
  81.390 +
  81.391 +              KAFR_EL_ZT   ABU_ZAABAL    HELWAN     ASSIOUT   :=
  81.392 +
  81.393 +ABU_ZAABAL         85            .           .          .
  81.394 +HELWAN            142           57           .          .
  81.395 +ASSIOUT           504          420         362          .
  81.396 +ASWAN            1022          938         880        518     ;
  81.397 +
  81.398 +param :            impd_barg   impd_road :=
  81.399 +
  81.400 +ABU_ZAABAL            210          .1
  81.401 +ASSIOUT               583         0
  81.402 +ASWAN                1087        10
  81.403 +HELWAN                183         0
  81.404 +KAFR_EL_ZT            104         6 ;
  81.405 +
  81.406 +param io  default 0.0  :=
  81.407 +
  81.408 +   [*,AMM_C_GAS]  AMMONIA        1.0
  81.409 +                  BF_GAS      -609.
  81.410 +                  COKE_GAS      -2.0
  81.411 +                  ELECTRIC   -1960.
  81.412 +                  STEAM         -4.
  81.413 +                  WATER       -700.
  81.414 +
  81.415 +   [*,AMM_ELEC]   AMMONIA        1.0
  81.416 +                  EL_ASWAN     -12.0
  81.417 +
  81.418 +   [*,AMM_SULF]   AMMONIA        -.26
  81.419 +                  AMM_SULF       1.0
  81.420 +                  BAGS         -22.
  81.421 +                  ELECTRIC     -19.
  81.422 +                  SULF_ACID      -.76
  81.423 +                  WATER        -17.
  81.424 +
  81.425 +   [*,CAN_310]    AMMONIA        -.20
  81.426 +                  BAGS         -23.
  81.427 +                  CAN_310        1.0
  81.428 +                  LIMESTONE      -.12
  81.429 +                  NITR_ACID      -.71
  81.430 +                  STEAM          -.4
  81.431 +                  WATER        -49.
  81.432 +
  81.433 +   [*,CAN_335]    AMMONIA        -.21
  81.434 +                  BAGS         -23.
  81.435 +                  CAN_335        1.0
  81.436 +                  LIMESTONE      -.04
  81.437 +                  NITR_ACID      -.76
  81.438 +                  STEAM          -.4
  81.439 +                  WATER        -49.
  81.440 +
  81.441 +   [*,NITR_ACID]  AMMONIA        -.292
  81.442 +                  ELECTRIC    -231.
  81.443 +                  NITR_ACID      1.0
  81.444 +                  WATER          -.6
  81.445 +
  81.446 +   [*,SSP_155]    BAGS         -22.
  81.447 +                  ELECTRIC     -14.
  81.448 +                  PHOS_ROCK      -.62
  81.449 +                  SSP_155        1.0
  81.450 +                  SULF_ACID      -.41
  81.451 +                  WATER         -6.
  81.452 +
  81.453 +   [*,SULF_A_P]   ELECTRIC     -75.
  81.454 +                  PYRITES        -.826
  81.455 +                  SULF_ACID      1.0
  81.456 +                  WATER        -60.
  81.457 +
  81.458 +   [*,SULF_A_S]   ELECTRIC     -50.
  81.459 +                  EL_SULFUR      -.334
  81.460 +                  SULF_ACID      1.0
  81.461 +                  WATER        -20. ;
  81.462 +
  81.463 +param util  default 0  :=
  81.464 +
  81.465 +   [*,*]   SULF_A_S SULF_A_S    1      SULF_A_P SULF_A_P   1
  81.466 +           NITR_ACID NITR_ACID  1      AMM_ELEC AMM_ELEC   1
  81.467 +           AMM_C_GAS AMM_C_GAS  1      SSP SSP_155         1
  81.468 +           C_AMM_NITR CAN_310   1      C_AMM_NITR CAN_335  1
  81.469 +           AMM_SULF AMM_SULF    1 ;
  81.470 +
  81.471 +param p_imp  default 0.0  :=
  81.472 +
  81.473 +     PYRITES       17.5           AMM_SULF      75.
  81.474 +     EL_SULFUR     55.            DAP          175.
  81.475 +     UREA         150.            SSP_155       80.
  81.476 +     CAN_260       75.            C_250_55     100.
  81.477 +     CAN_310       90.            C_300_100    130.
  81.478 +     CAN_335      100.   ;
  81.479 +
  81.480 +param p_r  default 0.0  :=
  81.481 +
  81.482 +     ELECTRIC     .007
  81.483 +     BF_GAS       .007
  81.484 +     WATER        .031
  81.485 +     STEAM       1.25
  81.486 +     BAGS         .28   ;
  81.487 +
  81.488 +param p_pr  default 0.0  :=
  81.489 +
  81.490 + [HELWAN,COKE_GAS]              16.0
  81.491 + [ASWAN,EL_ASWAN]                1.0
  81.492 +
  81.493 + [*,LIMESTONE]      ASWAN        1.2
  81.494 +                    HELWAN       1.2
  81.495 +
  81.496 + [*,PHOS_ROCK]      ABU_ZAABAL   4.0
  81.497 +                    ASSIOUT      3.5
  81.498 +                    KAFR_EL_ZT   5.0   ;
  81.499 +
  81.500 +param dcap  default 0.0  :=
  81.501 +
  81.502 +   [ABU_ZAABAL,*]   SSP          600
  81.503 +                    SULF_A_P     227
  81.504 +                    SULF_A_S     242
  81.505 +
  81.506 +   [ASSIOUT,*]      SSP          600
  81.507 +                    SULF_A_S     250
  81.508 +
  81.509 +   [ASWAN,*]        AMM_ELEC     450
  81.510 +                    C_AMM_NITR  1100
  81.511 +                    NITR_ACID    800
  81.512 +
  81.513 +   [HELWAN,*]       AMM_C_GAS    172
  81.514 +                    AMM_SULF      24
  81.515 +                    C_AMM_NITR   364
  81.516 +                    NITR_ACID    282
  81.517 +
  81.518 +   [KAFR_EL_ZT,*]   SSP          600
  81.519 +                    SULF_A_P      50
  81.520 +                    SULF_A_S     200  ;
  81.521 +
  81.522 +end;
    82.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    82.2 +++ b/deps/glpk/examples/fctp.mod	Sun Nov 06 20:59:10 2011 +0100
    82.3 @@ -0,0 +1,93 @@
    82.4 +/* FCTP, Fixed-Charge Transportation Problem */
    82.5 +
    82.6 +/* Written in GNU MathProg by Andrew Makhorin <mao@gnu.org> */
    82.7 +
    82.8 +/* The Fixed-Charge Transportation Problem (FCTP) is obtained from
    82.9 +   classical transportation problem by imposing a fixed cost on each
   82.10 +   transportation link if there is a positive flow on that link. */
   82.11 +
   82.12 +param m, integer, > 0;
   82.13 +/* number of sources */
   82.14 +
   82.15 +param n, integer, > 0;
   82.16 +/* number of customers */
   82.17 +
   82.18 +set I := 1..m;
   82.19 +/* set of sources */
   82.20 +
   82.21 +set J := 1..n;
   82.22 +/* set of customers */
   82.23 +
   82.24 +param supply{i in I}, >= 0;
   82.25 +/* supply at source i */
   82.26 +
   82.27 +param demand{j in J}, >= 0;
   82.28 +/* demand at customer j */
   82.29 +
   82.30 +param varcost{i in I, j in J}, >= 0;
   82.31 +/* variable cost (a cost per one unit shipped from i to j) */
   82.32 +
   82.33 +param fixcost{i in I, j in J}, >= 0;
   82.34 +/* fixed cost (a cost for shipping any amount from i to j) */
   82.35 +
   82.36 +var x{i in I, j in J}, >= 0;
   82.37 +/* amount shipped from source i to customer j */
   82.38 +
   82.39 +s.t. f{i in I}: sum{j in J} x[i,j] = supply[i];
   82.40 +/* observe supply at source i */
   82.41 +
   82.42 +s.t. g{j in J}: sum{i in I} x[i,j] = demand[j];
   82.43 +/* satisfy demand at customer j */
   82.44 +
   82.45 +var y{i in I, j in J}, binary;
   82.46 +/* y[i,j] = 1 means some amount is shipped from i to j */
   82.47 +
   82.48 +s.t. h{i in I, j in J}: x[i,j] <= min(supply[i], demand[j]) * y[i,j];
   82.49 +/* if y[i,j] is 0, force x[i,j] to be 0 (may note that supply[i] and
   82.50 +   demand[j] are implicit upper bounds for x[i,j] as follows from the
   82.51 +   constraints f[i] and g[j]) */
   82.52 +
   82.53 +minimize cost: sum{i in I, j in J} varcost[i,j] * x[i,j] +
   82.54 +               sum{i in I, j in J} fixcost[i,j] * y[i,j];
   82.55 +/* total transportation costs */
   82.56 +
   82.57 +data;
   82.58 +
   82.59 +/* These data correspond to the instance bal8x12 from [Balinski]. */
   82.60 +
   82.61 +/* The optimal solution is 471.55 */
   82.62 +
   82.63 +param m := 8;
   82.64 +
   82.65 +param n := 12;
   82.66 +
   82.67 +param supply := 1 15.00,  2 20.00,  3 45.00,  4 35.00,
   82.68 +                5 25.00,  6 35.00,  7 10.00,  8 25.00;
   82.69 +
   82.70 +param demand := 1 20.00,  2 15.00,  3 20.00,  4 15.00,
   82.71 +                5  5.00,  6 20.00,  7 30.00,  8 10.00,
   82.72 +                9 35.00, 10 25.00, 11 10.00, 12  5.00;
   82.73 +
   82.74 +param varcost
   82.75 +      :   1    2    3    4    5    6    7    8    9    10   11   12  :=
   82.76 +      1  0.69 0.64 0.71 0.79 1.70 2.83 2.02 5.64 5.94 5.94 5.94 7.68
   82.77 +      2  1.01 0.75 0.88 0.59 1.50 2.63 2.26 5.64 5.85 5.62 5.85 4.94
   82.78 +      3  1.05 1.06 1.08 0.64 1.22 2.37 1.66 5.64 5.91 5.62 5.91 4.94
   82.79 +      4  1.94 1.50 1.56 1.22 1.98 1.98 1.36 6.99 6.99 6.99 6.99 3.68
   82.80 +      5  1.61 1.40 1.61 1.33 1.68 2.83 1.54 4.26 4.26 4.26 4.26 2.99
   82.81 +      6  5.29 5.94 6.08 5.29 5.96 6.77 5.08 0.31 0.21 0.17 0.31 1.53
   82.82 +      7  5.29 5.94 6.08 5.29 5.96 6.77 5.08 0.55 0.35 0.40 0.19 1.53
   82.83 +      8  5.29 6.08 6.08 5.29 5.96 6.45 5.08 2.43 2.30 2.33 1.81 2.50 ;
   82.84 +
   82.85 +param fixcost
   82.86 +      :   1    2    3    4    5    6    7    8    9    10   11   12  :=
   82.87 +      1  11.0 16.0 18.0 17.0 10.0 20.0 17.0 13.0 15.0 12.0 14.0 14.0
   82.88 +      2  14.0 17.0 17.0 13.0 15.0 13.0 16.0 11.0 20.0 11.0 15.0 10.0
   82.89 +      3  12.0 13.0 20.0 17.0 13.0 15.0 16.0 13.0 12.0 13.0 10.0 18.0
   82.90 +      4  16.0 19.0 16.0 11.0 15.0 12.0 18.0 12.0 18.0 13.0 13.0 14.0
   82.91 +      5  19.0 18.0 15.0 16.0 12.0 14.0 20.0 19.0 11.0 17.0 16.0 18.0
   82.92 +      6  13.0 20.0 20.0 17.0 15.0 12.0 14.0 11.0 12.0 19.0 15.0 16.0
   82.93 +      7  11.0 12.0 15.0 10.0 17.0 11.0 11.0 16.0 10.0 18.0 17.0 12.0
   82.94 +      8  17.0 10.0 20.0 12.0 17.0 20.0 16.0 15.0 10.0 12.0 16.0 18.0 ;
   82.95 +
   82.96 +end;
    83.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    83.2 +++ b/deps/glpk/examples/food.mod	Sun Nov 06 20:59:10 2011 +0100
    83.3 @@ -0,0 +1,127 @@
    83.4 +/* Food Manufacture 1, section 12.1 in
    83.5 + * Williams, "Model Building in Mathematical Programming"
    83.6 + *
    83.7 + * Sebastian Nowozin <nowozin@gmail.com>
    83.8 + */
    83.9 +
   83.10 +set oils;
   83.11 +set month;
   83.12 +
   83.13 +/* Buying prices of the raw oils in the next six month. */
   83.14 +param buyingprices{month,oils};
   83.15 +
   83.16 +/* Actual amount bought in each month. */
   83.17 +var buys{month,oils} >= 0;
   83.18 +
   83.19 +/* Stock for each oil. */
   83.20 +var stock{month,oils} >= 0;
   83.21 +
   83.22 +/* Price of the produced product */
   83.23 +param productprice >= 0;
   83.24 +param storagecost;
   83.25 +
   83.26 +param oilhardness{oils} >= 0;
   83.27 +
   83.28 +/* Actual amount of output oil produced in each month */
   83.29 +var production{m in month} >= 0;
   83.30 +var useoil{m in month, o in oils} >= 0;
   83.31 +
   83.32 +maximize totalprofit:
   83.33 +    sum{m in month} productprice*production[m]
   83.34 +    - sum{m in month, o in oils} buyingprices[m,o]*buys[m,o]
   83.35 +    - sum{m in month, o in oils} storagecost*stock[m,o];
   83.36 +
   83.37 +/* Constraints */
   83.38 +
   83.39 +/* 1. Starting stock */
   83.40 +s.t. startstock{o in oils}:
   83.41 +    stock[1,o] = 500;
   83.42 +s.t. endstock{o in oils}:
   83.43 +    stock[6,o] + buys[6,o] - useoil[6,o] >= 500;
   83.44 +
   83.45 +/* 2. Stock constraints */
   83.46 +s.t. stocklimit{m in month, o in oils}:
   83.47 +    stock[m,o] <= 1000;
   83.48 +
   83.49 +s.t. production1{m in month, o in oils}:
   83.50 +    useoil[m,o] <= stock[m,o] + buys[m,o];
   83.51 +s.t. production2{m1 in month, m2 in month, o in oils : m2 = m1+1}:
   83.52 +    stock[m2,o] = stock[m1,o] + buys[m1,o] - useoil[m1,o];
   83.53 +
   83.54 +s.t. production3a{m in month}:
   83.55 +    sum{o in oils} oilhardness[o]*useoil[m,o] >= 3*production[m];
   83.56 +s.t. production3b{m in month}:
   83.57 +    sum{o in oils} oilhardness[o]*useoil[m,o] <= 6*production[m];
   83.58 +
   83.59 +s.t. production4{m in month}:
   83.60 +    production[m] = sum{o in oils} useoil[m,o];
   83.61 +
   83.62 +/* 3. Refining constraints */
   83.63 +s.t. refine1{m in month}:
   83.64 +    useoil[m,"VEG1"]+useoil[m,"VEG2"] <= 200;
   83.65 +s.t. refine2{m in month}:
   83.66 +    useoil[m,"OIL1"]+useoil[m,"OIL2"]+useoil[m,"OIL3"] <= 250;
   83.67 +
   83.68 +solve;
   83.69 +
   83.70 +for {m in month} {
   83.71 +    printf "Month %d\n", m;
   83.72 +    printf "PRODUCE %4.2f tons, hardness %4.2f\n", production[m],
   83.73 +        (sum{o in oils} oilhardness[o]*useoil[m,o]) / (sum{o in oils} useoil[m,o]);
   83.74 +
   83.75 +    printf "\tVEG1\tVEG2\tOIL1\tOIL2\tOIL3\n";
   83.76 +    printf "STOCK";
   83.77 +    printf "%d", m;
   83.78 +    for {o in oils} {
   83.79 +        printf "\t%4.2f", stock[m,o];
   83.80 +    }
   83.81 +    printf "\nBUY";
   83.82 +    for {o in oils} {
   83.83 +        printf "\t%4.2f", buys[m,o];
   83.84 +    }
   83.85 +    printf "\nUSE";
   83.86 +    printf "%d", m;
   83.87 +    for {o in oils} {
   83.88 +        printf "\t%4.2f", useoil[m,o];
   83.89 +    }
   83.90 +    printf "\n";
   83.91 +    printf "\n";
   83.92 +}
   83.93 +printf "Total profit: %4.2f\n",
   83.94 +    (sum{m in month} productprice*production[m]
   83.95 +    - sum{m in month, o in oils} buyingprices[m,o]*buys[m,o]
   83.96 +    - sum{m in month, o in oils} storagecost*stock[m,o]);
   83.97 +printf "      turnover: %4.2f\n",
   83.98 +    sum{m in month} productprice*production[m];
   83.99 +printf "      buying costs: %4.2f\n",
  83.100 +    sum{m in month, o in oils} buyingprices[m,o]*buys[m,o];
  83.101 +printf "      storage costs: %4.2f\n",
  83.102 +    sum{m in month, o in oils} storagecost*stock[m,o];
  83.103 +
  83.104 +
  83.105 +data;
  83.106 +
  83.107 +param : oils : oilhardness :=
  83.108 +    VEG1    8.8
  83.109 +    VEG2    6.1
  83.110 +    OIL1    2.0
  83.111 +    OIL2    4.2
  83.112 +    OIL3    5.0 ;
  83.113 +
  83.114 +set month := 1 2 3 4 5 6;
  83.115 +
  83.116 +param buyingprices
  83.117 +
  83.118 +:           VEG1    VEG2    OIL1    OIL2    OIL3    :=
  83.119 +
  83.120 +1           110     120     130     110     115
  83.121 +2           130     130     110     90      115
  83.122 +3           110     140     130     100     95
  83.123 +4           120     110     120     120     125
  83.124 +5           100     120     150     110     105
  83.125 +6           90      100     140     80      135 ;
  83.126 +
  83.127 +param productprice := 150;
  83.128 +param storagecost := 5;
  83.129 +
  83.130 +end;
    84.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    84.2 +++ b/deps/glpk/examples/food2.mod	Sun Nov 06 20:59:10 2011 +0100
    84.3 @@ -0,0 +1,150 @@
    84.4 +/* Food Manufacture 2, section 12.2 in
    84.5 + * Williams, "Model Building in Mathematical Programming"
    84.6 + *
    84.7 + * Sebastian Nowozin <nowozin@gmail.com>
    84.8 + */
    84.9 +
   84.10 +set oils;
   84.11 +set month;
   84.12 +
   84.13 +/* Buying prices of the raw oils in the next six month. */
   84.14 +param buyingprices{month,oils};
   84.15 +
   84.16 +/* Actual amount bought in each month. */
   84.17 +var buys{month,oils} >= 0;
   84.18 +
   84.19 +/* Stock for each oil. */
   84.20 +var stock{month,oils} >= 0;
   84.21 +
   84.22 +/* Price of the produced product */
   84.23 +param productprice >= 0;
   84.24 +param storagecost;
   84.25 +
   84.26 +param oilhardness{oils} >= 0;
   84.27 +param M >= 0;
   84.28 +
   84.29 +/* Actual amount of output oil produced in each month */
   84.30 +var production{m in month} >= 0;
   84.31 +var useoil{m in month, o in oils} >= 0, <= M;
   84.32 +var useoilb{m in month, o in oils}, binary;
   84.33 +
   84.34 +maximize totalprofit:
   84.35 +    sum{m in month} productprice*production[m]
   84.36 +    - sum{m in month, o in oils} buyingprices[m,o]*buys[m,o]
   84.37 +    - sum{m in month, o in oils} storagecost*stock[m,o];
   84.38 +
   84.39 +/* Constraints */
   84.40 +
   84.41 +/* 1. Starting stock */
   84.42 +s.t. startstock{o in oils}:
   84.43 +    stock[1,o] = 500;
   84.44 +s.t. endstock{o in oils}:
   84.45 +    stock[6,o] + buys[6,o] - useoil[6,o] >= 500;
   84.46 +
   84.47 +/* 2. Stock constraints */
   84.48 +s.t. stocklimit{m in month, o in oils}:
   84.49 +    stock[m,o] <= 1000;
   84.50 +
   84.51 +s.t. production1{m in month, o in oils}:
   84.52 +    useoil[m,o] <= stock[m,o] + buys[m,o];
   84.53 +s.t. production2{m1 in month, m2 in month, o in oils : m2 = m1+1}:
   84.54 +    stock[m2,o] = stock[m1,o] + buys[m1,o] - useoil[m1,o];
   84.55 +
   84.56 +s.t. production3a{m in month}:
   84.57 +    sum{o in oils} oilhardness[o]*useoil[m,o] >= 3*production[m];
   84.58 +s.t. production3b{m in month}:
   84.59 +    sum{o in oils} oilhardness[o]*useoil[m,o] <= 6*production[m];
   84.60 +
   84.61 +s.t. production4{m in month}:
   84.62 +    production[m] = sum{o in oils} useoil[m,o];
   84.63 +
   84.64 +/* 3. Refining constraints */
   84.65 +s.t. refine1{m in month}:
   84.66 +    useoil[m,"VEG1"]+useoil[m,"VEG2"] <= 200;
   84.67 +s.t. refine2{m in month}:
   84.68 +    useoil[m,"OIL1"]+useoil[m,"OIL2"]+useoil[m,"OIL3"] <= 250;
   84.69 +
   84.70 +/* 4. Additional conditions:
   84.71 + *    i) The food may never be made up of more than three oils every month
   84.72 + */
   84.73 +s.t. useoilb_calc{m in month, o in oils}:
   84.74 +    M*useoilb[m,o] >= useoil[m,o];
   84.75 +s.t. useoilb_limit{m in month}:
   84.76 +    sum{o in oils} useoilb[m,o] <= 3;
   84.77 +
   84.78 +/* ii) If an oil is used in a month, at least 20 tons must be used.
   84.79 + */
   84.80 +s.t. useminimum{m in month, o in oils}:
   84.81 +    20*useoilb[m,o] <= useoil[m,o];
   84.82 +
   84.83 +/* iii) If either of VEG1 or VEG2 is used in a month, OIL2 must also be used
   84.84 + */
   84.85 +s.t. use_oil2a{m in month}:
   84.86 +    useoilb[m,"VEG1"] <= useoilb[m,"OIL3"];
   84.87 +s.t. use_oil2b{m in month}:
   84.88 +    useoilb[m,"VEG2"] <= useoilb[m,"OIL3"];
   84.89 +
   84.90 +solve;
   84.91 +
   84.92 +for {m in month} {
   84.93 +    printf "Month %d\n", m;
   84.94 +    printf "PRODUCE %4.2f tons, hardness %4.2f\n", production[m],
   84.95 +        (sum{o in oils} oilhardness[o]*useoil[m,o]) / (sum{o in oils} useoil[m,o]);
   84.96 +
   84.97 +    printf "\tVEG1\tVEG2\tOIL1\tOIL2\tOIL3\n";
   84.98 +    printf "STOCK";
   84.99 +    printf "%d", m;
  84.100 +    for {o in oils} {
  84.101 +        printf "\t%4.2f", stock[m,o];
  84.102 +    }
  84.103 +    printf "\nBUY";
  84.104 +    for {o in oils} {
  84.105 +        printf "\t%4.2f", buys[m,o];
  84.106 +    }
  84.107 +    printf "\nUSE";
  84.108 +    printf "%d", m;
  84.109 +    for {o in oils} {
  84.110 +        printf "\t%4.2f", useoil[m,o];
  84.111 +    }
  84.112 +    printf "\n";
  84.113 +    printf "\n";
  84.114 +}
  84.115 +printf "Total profit: %4.2f\n",
  84.116 +    (sum{m in month} productprice*production[m]
  84.117 +    - sum{m in month, o in oils} buyingprices[m,o]*buys[m,o]
  84.118 +    - sum{m in month, o in oils} storagecost*stock[m,o]);
  84.119 +printf "      turnover: %4.2f\n",
  84.120 +    sum{m in month} productprice*production[m];
  84.121 +printf "      buying costs: %4.2f\n",
  84.122 +    sum{m in month, o in oils} buyingprices[m,o]*buys[m,o];
  84.123 +printf "      storage costs: %4.2f\n",
  84.124 +    sum{m in month, o in oils} storagecost*stock[m,o];
  84.125 +
  84.126 +
  84.127 +data;
  84.128 +
  84.129 +param : oils : oilhardness :=
  84.130 +    VEG1    8.8
  84.131 +    VEG2    6.1
  84.132 +    OIL1    2.0
  84.133 +    OIL2    4.2
  84.134 +    OIL3    5.0 ;
  84.135 +
  84.136 +set month := 1 2 3 4 5 6;
  84.137 +
  84.138 +param buyingprices
  84.139 +
  84.140 +:           VEG1    VEG2    OIL1    OIL2    OIL3    :=
  84.141 +
  84.142 +1           110     120     130     110     115
  84.143 +2           130     130     110     90      115
  84.144 +3           110     140     130     100     95
  84.145 +4           120     110     120     120     125
  84.146 +5           100     120     150     110     105
  84.147 +6           90      100     140     80      135 ;
  84.148 +
  84.149 +param productprice := 150;
  84.150 +param storagecost := 5;
  84.151 +param M := 1000;
  84.152 +
  84.153 +end;
    85.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    85.2 +++ b/deps/glpk/examples/gap.mod	Sun Nov 06 20:59:10 2011 +0100
    85.3 @@ -0,0 +1,79 @@
    85.4 +/* GAP, Generalized Assignment Problem */
    85.5 +
    85.6 +/* Written in GNU MathProg by Andrew Makhorin <mao@gnu.org> */
    85.7 +
    85.8 +/* The Generalized Assignment Problem (GAP) is to assign a set of jobs
    85.9 +   to a set of agents subject to the constraints that each job must be
   85.10 +   assigned exactly to one agent and the total resources consumed by all
   85.11 +   jobs assigned to an agent must not exceed the agent's capacity. */
   85.12 +
   85.13 +param m, integer, > 0;
   85.14 +/* number of agents */
   85.15 +
   85.16 +param n, integer, > 0;
   85.17 +/* number of jobs */
   85.18 +
   85.19 +set I := 1..m;
   85.20 +/* set of agents */
   85.21 +
   85.22 +set J := 1..n;
   85.23 +/* set of jobs */
   85.24 +
   85.25 +param a{i in I, j in J}, >= 0;
   85.26 +/* resource consumed in allocating job j to agent i */
   85.27 +
   85.28 +param b{i in I}, >= 0;
   85.29 +/* resource capacity of agent i */
   85.30 +
   85.31 +param c{i in I, j in J}, >= 0;
   85.32 +/* cost of allocating job j to agent i */
   85.33 +
   85.34 +var x{i in I, j in J}, binary;
   85.35 +/* x[i,j] = 1 means job j is assigned to agent i */
   85.36 +
   85.37 +s.t. one{j in J}: sum{i in I} x[i,j] = 1;
   85.38 +/* job j must be assigned exactly to one agent */
   85.39 +
   85.40 +s.t. lim{i in I}: sum{j in J} a[i,j] * x[i,j] <= b[i];
   85.41 +/* total amount of resources consumed by all jobs assigned to agent i
   85.42 +   must not exceed the agent's capacity */
   85.43 +
   85.44 +minimize obj: sum{i in I, j in J} c[i,j] * x[i,j];
   85.45 +/* the objective is to find cheapest assignment (note that gap can also
   85.46 +   be formulated as maximization problem) */
   85.47 +
   85.48 +data;
   85.49 +
   85.50 +/* These data correspond to the instance c515-1 (gap1) from:
   85.51 +
   85.52 +   I.H. Osman, "Heuristics for the Generalised Assignment Problem:
   85.53 +   Simulated Annealing and Tabu Search Approaches", OR Spektrum, Volume
   85.54 +   17, 211-225, 1995
   85.55 +
   85.56 +   D. Cattrysse, M. Salomon and L.N. Van Wassenhove, "A set partitioning
   85.57 +   heuristic for the generalized assignment problem", European Journal
   85.58 +   of Operational Research, Volume 72, 167-174, 1994 */
   85.59 +
   85.60 +/* The optimal solution is 261 (minimization) or 336 (maximization) */
   85.61 +
   85.62 +param m := 5;
   85.63 +
   85.64 +param n := 15;
   85.65 +
   85.66 +param a :  1  2  3  4  5  6  7  8  9 10 11 12 13 14 15 :=
   85.67 +      1    8 15 14 23  8 16  8 25  9 17 25 15 10  8 24
   85.68 +      2   15  7 23 22 11 11 12 10 17 16  7 16 10 18 22
   85.69 +      3   21 20  6 22 24 10 24  9 21 14 11 14 11 19 16
   85.70 +      4   20 11  8 14  9  5  6 19 19  7  6  6 13  9 18
   85.71 +      5    8 13 13 13 10 20 25 16 16 17 10 10  5 12 23 ;
   85.72 +
   85.73 +param b := 1 36, 2 34, 3 38, 4 27, 5 33;
   85.74 +
   85.75 +param c :  1  2  3  4  5  6  7  8  9 10 11 12 13 14 15 :=
   85.76 +      1   17 21 22 18 24 15 20 18 19 18 16 22 24 24 16
   85.77 +      2   23 16 21 16 17 16 19 25 18 21 17 15 25 17 24
   85.78 +      3   16 20 16 25 24 16 17 19 19 18 20 16 17 21 24
   85.79 +      4   19 19 22 22 20 16 19 17 21 19 25 23 25 25 25
   85.80 +      5   18 19 15 15 21 25 16 16 23 15 22 17 19 22 24 ;
   85.81 +
   85.82 +end;
    86.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    86.2 +++ b/deps/glpk/examples/glpsol.c	Sun Nov 06 20:59:10 2011 +0100
    86.3 @@ -0,0 +1,10 @@
    86.4 +/* glpsol.c */
    86.5 +
    86.6 +#include <glpk.h>
    86.7 +
    86.8 +int main(int argc, const char *argv[])
    86.9 +{     /* stand-alone LP/MIP solver */
   86.10 +      return glp_main(argc, argv);
   86.11 +}
   86.12 +
   86.13 +/* eof */
    87.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    87.2 +++ b/deps/glpk/examples/graph.mod	Sun Nov 06 20:59:10 2011 +0100
    87.3 @@ -0,0 +1,98 @@
    87.4 +/* graph.mod - graph visualization */
    87.5 +
    87.6 +/* Written in GNU MathProg by Andrew Makhorin <mao@gnu.org> */
    87.7 +
    87.8 +/* This model creates a picture in EPS format to visualize a graph. */
    87.9 +
   87.10 +param file, symbolic, default "graph.eps";
   87.11 +/* output file to write the picture */
   87.12 +
   87.13 +param R, default 2;
   87.14 +/* radius to draw vertices, in mm */
   87.15 +
   87.16 +param n, integer, > 0;
   87.17 +/* number of vertices */
   87.18 +
   87.19 +set V, default 1..n;
   87.20 +/* set of vertices */
   87.21 +
   87.22 +set E, within V cross V;
   87.23 +/* set of edges */
   87.24 +
   87.25 +param x{i in V}, default 50 * cos((i - 1) / card(V) * 8 * atan(1));
   87.26 +param y{i in V}, default 50 * sin((i - 1) / card(V) * 8 * atan(1));
   87.27 +/* x[i] and y[i] are coordinates of node i, in mm */
   87.28 +
   87.29 +param x0 := (min{i in V} x[i]) - R - 3.0;
   87.30 +param y0 := (min{i in V} y[i]) - R - 3.0;
   87.31 +param x1 := (max{i in V} x[i]) + R + 3.0;
   87.32 +param y1 := (max{i in V} y[i]) + R + 3.0;
   87.33 +
   87.34 +printf "%%!PS-Adobe-3.0 EPSF-3.0\n" > file;
   87.35 +printf "%%%%BoundingBox: 0 0 %d %d\n",
   87.36 +      (72 / 25.4) * (x1 - x0), (72 / 25.4) * (y1 - y0) >> file;
   87.37 +printf "/Helvetica findfont 6 scalefont setfont\n" >> file;
   87.38 +printf "/mm { 72 mul 25.4 div } def\n" >> file;
   87.39 +
   87.40 +for {(i,j) in E}
   87.41 +{     printf "newpath\n" >> file;
   87.42 +      printf "%g mm %g mm moveto\n", x[i] - x0, y[i] - y0 >> file;
   87.43 +      printf "%g mm %g mm lineto\n", x[j] - x0, y[j] - y0 >> file;
   87.44 +      printf "closepath\n" >> file;
   87.45 +      printf "stroke\n" >> file;
   87.46 +}
   87.47 +
   87.48 +for {i in V}
   87.49 +{     printf "newpath\n" >> file;
   87.50 +      printf "%g mm %g mm %g mm 0 360 arc\n",
   87.51 +         x[i] - x0, y[i] - y0, R >> file;
   87.52 +      printf "closepath\n" >> file;
   87.53 +      printf "gsave 1 1 1 setrgbcolor fill grestore\n" >> file;
   87.54 +      printf "stroke\n" >> file;
   87.55 +      printf "%g mm %g mm moveto\n",
   87.56 +         x[i] - (if i <= 9 then 1.2 else 1.8) - x0,
   87.57 +         y[i] - 0.8 - y0 >> file;
   87.58 +      printf "( %d ) show\n", i >> file;
   87.59 +}
   87.60 +
   87.61 +printf "showpage\n" >> file;
   87.62 +printf "%%%%EOF\n" >> file;
   87.63 +
   87.64 +data;
   87.65 +
   87.66 +param
   87.67 +:  V  :  x     y :=
   87.68 +   1     0    40
   87.69 +   2    38    12
   87.70 +   3    24   -32
   87.71 +   4   -24   -32
   87.72 +   5   -38    12
   87.73 +   6   -19    26
   87.74 +   7    19    26
   87.75 +   8    31   -10
   87.76 +   9     0   -32
   87.77 +  10   -31   -10
   87.78 +  11    -9    12
   87.79 +  12     9    12
   87.80 +  13    14    -5
   87.81 +  14     0   -15
   87.82 +  15   -14    -5
   87.83 +  16     0     0 ;
   87.84 +
   87.85 +set E :=
   87.86 +   (1,*)  6 10 16 12  7
   87.87 +   (2,*)  7  6 16 13  8
   87.88 +   (3,*)  8  7 16 14  9
   87.89 +   (4,*)  9  8 16 15 10
   87.90 +   (5,*) 10  9 16 11  6
   87.91 +   (6,*) 14
   87.92 +   (7,*) 15
   87.93 +   (8,*) 11
   87.94 +   (9,*) 12
   87.95 +  (10,*) 13
   87.96 +  (11,*) 12 15
   87.97 +  (12,*) 13
   87.98 +  (13,*) 14
   87.99 +  (14,*) 15 ;
  87.100 +
  87.101 +end;
    88.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    88.2 +++ b/deps/glpk/examples/hashi.mod	Sun Nov 06 20:59:10 2011 +0100
    88.3 @@ -0,0 +1,168 @@
    88.4 +/* A solver for the Japanese number-puzzle Hashiwokakero
    88.5 + * (http://en.wikipedia.org/wiki/Hashiwokakero)
    88.6 + *
    88.7 + * Sebastian Nowozin <nowozin@gmail.com>, 13th January 2009
    88.8 + */
    88.9 +
   88.10 +param n := 25;
   88.11 +set rows := 1..n;
   88.12 +set cols := 1..n;
   88.13 +param givens{rows, cols}, integer, >= 0, <= 8, default 0;
   88.14 +
   88.15 +/* Set of vertices as (row,col) coordinates */
   88.16 +set V := { (i,j) in { rows, cols }: givens[i,j] != 0 };
   88.17 +
   88.18 +/* Set of feasible horizontal edges from (i,j) to (k,l) rightwards */
   88.19 +set Eh := { (i,j,k,l) in { V, V }:
   88.20 +        i = k and j < l and             # Same row and left to right
   88.21 +        card({ (s,t) in V: s = i and t > j and t < l }) = 0             # No vertex inbetween
   88.22 +        };
   88.23 +
   88.24 +/* Set of feasible vertical edges from (i,j) to (k,l) downwards */
   88.25 +set Ev := { (i,j,k,l) in { V, V }:
   88.26 +        j = l and i < k and             # Same column and top to bottom
   88.27 +        card({ (s,t) in V: t = j and s > i and s < k }) = 0             # No vertex inbetween
   88.28 +        };
   88.29 +
   88.30 +set E := Eh union Ev;
   88.31 +
   88.32 +/* Indicators: use edge once/twice */
   88.33 +var xe1{E}, binary;
   88.34 +var xe2{E}, binary;
   88.35 +
   88.36 +/* Constraint: Do not use edge or do use once or do use twice */
   88.37 +s.t. edge_sel{(i,j,k,l) in E}:
   88.38 +        xe1[i,j,k,l] + xe2[i,j,k,l] <= 1;
   88.39 +
   88.40 +/* Constraint: There must be as many edges used as the node value */
   88.41 +s.t. satisfy_vertex_demand{(s,t) in V}:
   88.42 +        sum{(i,j,k,l) in E: (i = s and j = t) or (k = s and l = t)}
   88.43 +                (xe1[i,j,k,l] + 2.0*xe2[i,j,k,l]) = givens[s,t];
   88.44 +
   88.45 +/* Constraint: No crossings */
   88.46 +s.t. no_crossing1{(i,j,k,l) in Eh, (s,t,u,v) in Ev:
   88.47 +        s < i and u > i and j < t and l > t}:
   88.48 +        xe1[i,j,k,l] + xe1[s,t,u,v] <= 1;
   88.49 +s.t. no_crossing2{(i,j,k,l) in Eh, (s,t,u,v) in Ev:
   88.50 +        s < i and u > i and j < t and l > t}:
   88.51 +        xe1[i,j,k,l] + xe2[s,t,u,v] <= 1;
   88.52 +s.t. no_crossing3{(i,j,k,l) in Eh, (s,t,u,v) in Ev:
   88.53 +        s < i and u > i and j < t and l > t}:
   88.54 +        xe2[i,j,k,l] + xe1[s,t,u,v] <= 1;
   88.55 +s.t. no_crossing4{(i,j,k,l) in Eh, (s,t,u,v) in Ev:
   88.56 +        s < i and u > i and j < t and l > t}:
   88.57 +        xe2[i,j,k,l] + xe2[s,t,u,v] <= 1;
   88.58 +
   88.59 +
   88.60 +/* Model connectivity by auxiliary network flow problem:
   88.61 + * One vertex becomes a target node and all other vertices send a unit flow
   88.62 + * to it.  The edge selection variables xe1/xe2 are VUB constraints and
   88.63 + * therefore xe1/xe2 select the feasible graph for the max-flow problems.
   88.64 + */
   88.65 +set node_target := { (s,t) in V:
   88.66 +        card({ (i,j) in V: i < s or (i = s and j < t) }) = 0};
   88.67 +set node_sources := { (s,t) in V: (s,t) not in node_target };
   88.68 +
   88.69 +var flow_forward{ E }, >= 0;
   88.70 +var flow_backward{ E }, >= 0;
   88.71 +s.t. flow_conservation{ (s,t) in node_target, (p,q) in V }:
   88.72 +        /* All incoming flows */
   88.73 +        - sum{(i,j,k,l) in E: k = p and l = q} flow_forward[i,j,k,l]
   88.74 +        - sum{(i,j,k,l) in E: i = p and j = q} flow_backward[i,j,k,l]
   88.75 +        /* All outgoing flows */
   88.76 +        + sum{(i,j,k,l) in E: k = p and l = q} flow_backward[i,j,k,l]
   88.77 +        + sum{(i,j,k,l) in E: i = p and j = q} flow_forward[i,j,k,l]
   88.78 +        = 0 + (if (p = s and q = t) then card(node_sources) else -1);
   88.79 +
   88.80 +/* Variable-Upper-Bound (VUB) constraints: xe1/xe2 bound the flows.
   88.81 + */
   88.82 +s.t. connectivity_vub1{(i,j,k,l) in E}:
   88.83 +        flow_forward[i,j,k,l] <= card(node_sources)*(xe1[i,j,k,l] + xe2[i,j,k,l]);
   88.84 +s.t. connectivity_vub2{(i,j,k,l) in E}:
   88.85 +        flow_backward[i,j,k,l] <= card(node_sources)*(xe1[i,j,k,l] + xe2[i,j,k,l]);
   88.86 +
   88.87 +/* A feasible solution is enough
   88.88 + */
   88.89 +minimize cost: 0;
   88.90 +
   88.91 +solve;
   88.92 +
   88.93 +/* Output solution graphically */
   88.94 +printf "\nSolution:\n";
   88.95 +for { row in rows } {
   88.96 +        for { col in cols } {
   88.97 +                /* First print this cell information: givens or space */
   88.98 +                printf{0..0: givens[row,col] != 0} "%d", givens[row,col];
   88.99 +                printf{0..0: givens[row,col] = 0 and
  88.100 +                        card({(i,j,k,l) in Eh: i = row and col >= j and col < l and
  88.101 +                                xe1[i,j,k,l] = 1}) = 1} "-";
  88.102 +                printf{0..0: givens[row,col] = 0 and
  88.103 +                        card({(i,j,k,l) in Eh: i = row and col >= j and col < l and
  88.104 +                                xe2[i,j,k,l] = 1}) = 1} "=";
  88.105 +                printf{0..0: givens[row,col] = 0
  88.106 +                        and card({(i,j,k,l) in Ev: j = col and row >= i and row < k and
  88.107 +                                xe1[i,j,k,l] = 1}) = 1} "|";
  88.108 +                printf{0..0: givens[row,col] = 0
  88.109 +                        and card({(i,j,k,l) in Ev: j = col and row >= i and row < k and
  88.110 +                                xe2[i,j,k,l] = 1}) = 1} '"';
  88.111 +                printf{0..0: givens[row,col] = 0
  88.112 +                        and card({(i,j,k,l) in Eh: i = row and col >= j and col < l and
  88.113 +                                (xe1[i,j,k,l] = 1 or xe2[i,j,k,l] = 1)}) = 0
  88.114 +                        and card({(i,j,k,l) in Ev: j = col and row >= i and row < k and
  88.115 +                                (xe1[i,j,k,l] = 1 or xe2[i,j,k,l] = 1)}) = 0} " ";
  88.116 +
  88.117 +                /* Now print any edges */
  88.118 +                printf{(i,j,k,l) in Eh: i = row and col >= j and col < l and xe1[i,j,k,l] = 1} "-";
  88.119 +                printf{(i,j,k,l) in Eh: i = row and col >= j and col < l and xe2[i,j,k,l] = 1} "=";
  88.120 +
  88.121 +                printf{(i,j,k,l) in Eh: i = row and col >= j and col < l and
  88.122 +                        xe1[i,j,k,l] = 0 and xe2[i,j,k,l] = 0} " ";
  88.123 +                printf{0..0: card({(i,j,k,l) in Eh: i = row and col >= j and col < l}) = 0} " ";
  88.124 +        }
  88.125 +        printf "\n";
  88.126 +        for { col in cols } {
  88.127 +                printf{(i,j,k,l) in Ev: j = col and row >= i and row < k and xe1[i,j,k,l] = 1} "|";
  88.128 +                printf{(i,j,k,l) in Ev: j = col and row >= i and row < k and xe2[i,j,k,l] = 1} '"';
  88.129 +                printf{(i,j,k,l) in Ev: j = col and row >= i and row < k and
  88.130 +                        xe1[i,j,k,l] = 0 and xe2[i,j,k,l] = 0} " ";
  88.131 +                /* No vertical edges: skip also a field */
  88.132 +                printf{0..0: card({(i,j,k,l) in Ev: j = col and row >= i and row < k}) = 0} " ";
  88.133 +                printf " ";
  88.134 +        }
  88.135 +        printf "\n";
  88.136 +}
  88.137 +
  88.138 +data;
  88.139 +
  88.140 +/* This is a difficult 25x25 Hashiwokakero.
  88.141 + */
  88.142 +param givens : 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
  88.143 +25 :=
  88.144 +           1   2 . 2 . 2 . . 2 . 2 . . 2 . . . . 2 . 2 . 2 . 2 .
  88.145 +           2   . 1 . . . . 2 . . . 4 . . 5 . 2 . . 1 . 2 . 2 . 1
  88.146 +           3   2 . . 5 . 4 . . 3 . . . . . 1 . . 4 . 5 . 1 . 1 .
  88.147 +           4   . . . . . . . . . . . 1 . 3 . . 1 . . . . . . . .
  88.148 +           5   2 . . 6 . 6 . . 8 . 5 . 2 . . 3 . 5 . 7 . . 2 . .
  88.149 +           6   . 1 . . . . . . . . . 1 . . 2 . . . . . 1 . . . 3
  88.150 +           7   2 . . . . 5 . . 6 . 4 . . 2 . . . 2 . 5 . 4 . 2 .
  88.151 +           8   . 2 . 2 . . . . . . . . . . . 3 . . 3 . . . 1 . 2
  88.152 +           9   . . . . . . . . . . 4 . 2 . 2 . . 1 . . . 3 . 1 .
  88.153 +          10   2 . 3 . . 6 . . 2 . . . . . . . . . . 3 . . . . .
  88.154 +          11   . . . . 1 . . 2 . . 5 . . 1 . 4 . 3 . . . . 2 . 4
  88.155 +          12   . . 2 . . 1 . . . . . . 5 . 4 . . . . 4 . 3 . . .
  88.156 +          13   2 . . . 3 . 1 . . . . . . . . 3 . . 5 . 5 . . 2 .
  88.157 +          14   . . . . . 2 . 5 . . 7 . 5 . 3 . 1 . . 1 . . 1 . 4
  88.158 +          15   2 . 5 . 3 . . . . 1 . 2 . 1 . . . . 2 . 4 . . 2 .
  88.159 +          16   . . . . . 1 . . . . . . . . . . 2 . . 2 . 1 . . 3
  88.160 +          17   2 . 6 . 6 . . 2 . . 2 . 2 . 5 . . . . . 2 . . . .
  88.161 +          18   . . . . . 1 . . . 3 . . . . . 1 . . 1 . . 4 . 3 .
  88.162 +          19   . . 4 . 5 . . 2 . . . 2 . . 6 . 6 . . 3 . . . . 3
  88.163 +          20   2 . . . . . . . . . 2 . . 1 . . . . . . 1 . . 1 .
  88.164 +          21   . . 3 . . 3 . 5 . 5 . . 4 . 6 . 7 . . 4 . 6 . . 4
  88.165 +          22   2 . . . 3 . 5 . 2 . 1 . . . . . . . . . . . . . .
  88.166 +          23   . . . . . . . . . 1 . . . . . . 3 . 2 . . 5 . . 5
  88.167 +          24   2 . 3 . 3 . 5 . 4 . 3 . 3 . 4 . . 2 . 2 . . . 1 .
  88.168 +          25   . 1 . 2 . 2 . . . 2 . 2 . . . 2 . . . . 2 . 2 . 2
  88.169 +           ;
  88.170 +
  88.171 +end;
    89.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    89.2 +++ b/deps/glpk/examples/huge.mod	Sun Nov 06 20:59:10 2011 +0100
    89.3 @@ -0,0 +1,25 @@
    89.4 +/*Arithmetic Mean of a large number of Integers
    89.5 +  - or - solve a very large constraint matrix
    89.6 +         over 1 million rows and columns
    89.7 +  Nigel_Galloway@operamail.com
    89.8 +  March 18th., 2008.
    89.9 +*/
   89.10 +
   89.11 +param e := 20;
   89.12 +/* set Sample := {-2**e..2**e-1}; */
   89.13 +set Sample := {1..2**e-1};
   89.14 +
   89.15 +var Mean;
   89.16 +var E{z in Sample};
   89.17 +
   89.18 +/* sum of variances is zero */
   89.19 +zumVariance: sum{z in Sample} E[z] = 0;
   89.20 +
   89.21 +/* Mean + variance[n] = Sample[n] */
   89.22 +variances{z in Sample}: Mean + E[z] = z;
   89.23 +
   89.24 +solve;
   89.25 +
   89.26 +printf "The arithmetic mean of the integers from 1 to %d is %f\n", 2**e-1, Mean;
   89.27 +
   89.28 +end;
    90.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    90.2 +++ b/deps/glpk/examples/iptsamp.c	Sun Nov 06 20:59:10 2011 +0100
    90.3 @@ -0,0 +1,17 @@
    90.4 +/* iptsamp.c */
    90.5 +
    90.6 +#include <stdio.h>
    90.7 +#include <stdlib.h>
    90.8 +#include <glpk.h>
    90.9 +
   90.10 +int main(void)
   90.11 +{     glp_prob *P;
   90.12 +      P = glp_create_prob();
   90.13 +      glp_read_mps(P, GLP_MPS_DECK, NULL, "25fv47.mps");
   90.14 +      glp_interior(P, NULL);
   90.15 +      glp_print_ipt(P, "25fv47.txt");
   90.16 +      glp_delete_prob(P);
   90.17 +      return 0;
   90.18 +}
   90.19 +
   90.20 +/* eof */
    91.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    91.2 +++ b/deps/glpk/examples/jssp.mod	Sun Nov 06 20:59:10 2011 +0100
    91.3 @@ -0,0 +1,114 @@
    91.4 +/* JSSP, Job-Shop Scheduling Problem */
    91.5 +
    91.6 +/* Written in GNU MathProg by Andrew Makhorin <mao@gnu.org> */
    91.7 +
    91.8 +/* The Job-Shop Scheduling Problem (JSSP) is to schedule a set of jobs
    91.9 +   on a set of machines, subject to the constraint that each machine can
   91.10 +   handle at most one job at a time and the fact that each job has a
   91.11 +   specified processing order through the machines. The objective is to
   91.12 +   schedule the jobs so as to minimize the maximum of their completion
   91.13 +   times.
   91.14 +
   91.15 +   Reference:
   91.16 +   D. Applegate and W. Cook, "A Computational Study of the Job-Shop
   91.17 +   Scheduling Problem", ORSA J. On Comput., Vol. 3, No. 2, Spring 1991,
   91.18 +   pp. 149-156. */
   91.19 +
   91.20 +param n, integer, > 0;
   91.21 +/* number of jobs */
   91.22 +
   91.23 +param m, integer, > 0;
   91.24 +/* number of machines */
   91.25 +
   91.26 +set J := 1..n;
   91.27 +/* set of jobs */
   91.28 +
   91.29 +set M := 1..m;
   91.30 +/* set of machines */
   91.31 +
   91.32 +param sigma{j in J, t in 1..m}, in M;
   91.33 +/* permutation of the machines, which represents the processing order
   91.34 +   of j through the machines: j must be processed first on sigma[j,1],
   91.35 +   then on sigma[j,2], etc. */
   91.36 +
   91.37 +check{j in J, t1 in 1..m, t2 in 1..m: t1 <> t2}:
   91.38 +      sigma[j,t1] != sigma[j,t2];
   91.39 +/* sigma must be permutation */
   91.40 +
   91.41 +param p{j in J, a in M}, >= 0;
   91.42 +/* processing time of j on a */
   91.43 +
   91.44 +var x{j in J, a in M}, >= 0;
   91.45 +/* starting time of j on a */
   91.46 +
   91.47 +s.t. ord{j in J, t in 2..m}:
   91.48 +      x[j, sigma[j,t]] >= x[j, sigma[j,t-1]] + p[j, sigma[j,t-1]];
   91.49 +/* j can be processed on sigma[j,t] only after it has been completely
   91.50 +   processed on sigma[j,t-1] */
   91.51 +
   91.52 +/* The disjunctive condition that each machine can handle at most one
   91.53 +   job at a time is the following:
   91.54 +
   91.55 +      x[i,a] >= x[j,a] + p[j,a]  or  x[j,a] >= x[i,a] + p[i,a]
   91.56 +
   91.57 +   for all i, j in J, a in M. This condition is modeled through binary
   91.58 +   variables Y as shown below. */
   91.59 +
   91.60 +var Y{i in J, j in J, a in M}, binary;
   91.61 +/* Y[i,j,a] is 1 if i scheduled before j on machine a, and 0 if j is
   91.62 +   scheduled before i */
   91.63 +
   91.64 +param K := sum{j in J, a in M} p[j,a];
   91.65 +/* some large constant */
   91.66 +
   91.67 +display K;
   91.68 +
   91.69 +s.t. phi{i in J, j in J, a in M: i <> j}:
   91.70 +      x[i,a] >= x[j,a] + p[j,a] - K * Y[i,j,a];
   91.71 +/* x[i,a] >= x[j,a] + p[j,a] iff Y[i,j,a] is 0 */
   91.72 +
   91.73 +s.t. psi{i in J, j in J, a in M: i <> j}:
   91.74 +      x[j,a] >= x[i,a] + p[i,a] - K * (1 - Y[i,j,a]);
   91.75 +/* x[j,a] >= x[i,a] + p[i,a] iff Y[i,j,a] is 1 */
   91.76 +
   91.77 +var z;
   91.78 +/* so-called makespan */
   91.79 +
   91.80 +s.t. fin{j in J}: z >= x[j, sigma[j,m]] + p[j, sigma[j,m]];
   91.81 +/* which is the maximum of the completion times of all the jobs */
   91.82 +
   91.83 +minimize obj: z;
   91.84 +/* the objective is to make z as small as possible */
   91.85 +
   91.86 +data;
   91.87 +
   91.88 +/* These data correspond to the instance ft06 (mt06) from:
   91.89 +
   91.90 +   H. Fisher, G.L. Thompson (1963), Probabilistic learning combinations
   91.91 +   of local job-shop scheduling rules, J.F. Muth, G.L. Thompson (eds.),
   91.92 +   Industrial Scheduling, Prentice Hall, Englewood Cliffs, New Jersey,
   91.93 +   225-251 */
   91.94 +
   91.95 +/* The optimal solution is 55 */
   91.96 +
   91.97 +param n := 6;
   91.98 +
   91.99 +param m := 6;
  91.100 +
  91.101 +param sigma :  1  2  3  4  5  6 :=
  91.102 +          1    3  1  2  4  6  5
  91.103 +          2    2  3  5  6  1  4
  91.104 +          3    3  4  6  1  2  5
  91.105 +          4    2  1  3  4  5  6
  91.106 +          5    3  2  5  6  1  4
  91.107 +          6    2  4  6  1  5  3 ;
  91.108 +
  91.109 +param p     :  1  2  3  4  5  6 :=
  91.110 +          1    3  6  1  7  6  3
  91.111 +          2   10  8  5  4 10 10
  91.112 +          3    9  1  5  4  7  8
  91.113 +          4    5  5  5  3  8  9
  91.114 +          5    3  3  9  1  5  4
  91.115 +          6   10  3  1  3  4  9 ;
  91.116 +
  91.117 +end;
    92.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    92.2 +++ b/deps/glpk/examples/magic.mod	Sun Nov 06 20:59:10 2011 +0100
    92.3 @@ -0,0 +1,54 @@
    92.4 +/* MAGIC, Magic Square */
    92.5 +
    92.6 +/* Written in GNU MathProg by Andrew Makhorin <mao@gnu.org> */
    92.7 +
    92.8 +/* In recreational mathematics, a magic square of order n is an
    92.9 +   arrangement of n^2 numbers, usually distinct integers, in a square,
   92.10 +   such that n numbers in all rows, all columns, and both diagonals sum
   92.11 +   to the same constant. A normal magic square contains the integers
   92.12 +   from 1 to n^2.
   92.13 +
   92.14 +   (From Wikipedia, the free encyclopedia.) */
   92.15 +
   92.16 +param n, integer, > 0, default 4;
   92.17 +/* square order */
   92.18 +
   92.19 +set N := 1..n^2;
   92.20 +/* integers to be placed */
   92.21 +
   92.22 +var x{i in 1..n, j in 1..n, k in N}, binary;
   92.23 +/* x[i,j,k] = 1 means that cell (i,j) contains integer k */
   92.24 +
   92.25 +s.t. a{i in 1..n, j in 1..n}: sum{k in N} x[i,j,k] = 1;
   92.26 +/* each cell must be assigned exactly one integer */
   92.27 +
   92.28 +s.t. b{k in N}: sum{i in 1..n, j in 1..n} x[i,j,k] = 1;
   92.29 +/* each integer must be assigned exactly to one cell */
   92.30 +
   92.31 +var s;
   92.32 +/* the magic sum */
   92.33 +
   92.34 +s.t. r{i in 1..n}: sum{j in 1..n, k in N} k * x[i,j,k] = s;
   92.35 +/* the sum in each row must be the magic sum */
   92.36 +
   92.37 +s.t. c{j in 1..n}: sum{i in 1..n, k in N} k * x[i,j,k] = s;
   92.38 +/* the sum in each column must be the magic sum */
   92.39 +
   92.40 +s.t. d: sum{i in 1..n, k in N} k * x[i,i,k] = s;
   92.41 +/* the sum in the diagonal must be the magic sum */
   92.42 +
   92.43 +s.t. e: sum{i in 1..n, k in N} k * x[i,n-i+1,k] = s;
   92.44 +/* the sum in the co-diagonal must be the magic sum */
   92.45 +
   92.46 +solve;
   92.47 +
   92.48 +printf "\n";
   92.49 +printf "Magic sum is %d\n", s;
   92.50 +printf "\n";
   92.51 +for{i in 1..n}
   92.52 +{  printf{j in 1..n} "%3d", sum{k in N} k * x[i,j,k];
   92.53 +   printf "\n";
   92.54 +}
   92.55 +printf "\n";
   92.56 +
   92.57 +end;
    93.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    93.2 +++ b/deps/glpk/examples/maxcut.mod	Sun Nov 06 20:59:10 2011 +0100
    93.3 @@ -0,0 +1,85 @@
    93.4 +/* MAXCUT, Maximum Cut Problem */
    93.5 +
    93.6 +/* Written in GNU MathProg by Andrew Makhorin <mao@gnu.org> */
    93.7 +
    93.8 +/* The Maximum Cut Problem in a network G = (V, E), where V is a set
    93.9 +   of nodes, E is a set of edges, is to find the partition of V into
   93.10 +   disjoint sets V1 and V2, which maximizes the sum of edge weights
   93.11 +   w(e), where edge e has one endpoint in V1 and other endpoint in V2.
   93.12 +
   93.13 +   Reference:
   93.14 +   Garey, M.R., and Johnson, D.S. (1979), Computers and Intractability:
   93.15 +   A guide to the theory of NP-completeness [Network design, Cuts and
   93.16 +   Connectivity, Maximum Cut, ND16]. */
   93.17 +
   93.18 +set E, dimen 2;
   93.19 +/* set of edges */
   93.20 +
   93.21 +param w{(i,j) in E}, >= 0, default 1;
   93.22 +/* w[i,j] is weight of edge (i,j) */
   93.23 +
   93.24 +set V := (setof{(i,j) in E} i) union (setof{(i,j) in E} j);
   93.25 +/* set of nodes */
   93.26 +
   93.27 +var x{i in V}, binary;
   93.28 +/* x[i] = 0 means that node i is in set V1
   93.29 +   x[i] = 1 means that node i is in set V2 */
   93.30 +
   93.31 +/* We need to include in the objective function only that edges (i,j)
   93.32 +   from E, for which x[i] != x[j]. This can be modeled through binary
   93.33 +   variables s[i,j] as follows:
   93.34 +
   93.35 +      s[i,j] = x[i] xor x[j] = (x[i] + x[j]) mod 2,                  (1)
   93.36 +
   93.37 +   where s[i,j] = 1 iff x[i] != x[j], that leads to the following
   93.38 +   objective function:
   93.39 +
   93.40 +      z = sum{(i,j) in E} w[i,j] * s[i,j].                           (2)
   93.41 +
   93.42 +   To describe "exclusive or" (1) we could think that s[i,j] is a minor
   93.43 +   bit of the sum x[i] + x[j]. Then introducing binary variables t[i,j],
   93.44 +   which represent a major bit of the sum x[i] + x[j], we can write:
   93.45 +
   93.46 +      x[i] + x[j] = s[i,j] + 2 * t[i,j].                             (3)
   93.47 +
   93.48 +   An easy check shows that conditions (1) and (3) are equivalent.
   93.49 +
   93.50 +   Note that condition (3) can be simplified by eliminating variables
   93.51 +   s[i,j]. Indeed, from (3) it follows that:
   93.52 +
   93.53 +      s[i,j] = x[i] + x[j] - 2 * t[i,j].                             (4)
   93.54 +
   93.55 +   Since the expression in the right-hand side of (4) is integral, this
   93.56 +   condition can be rewritten in the equivalent form:
   93.57 +
   93.58 +      0 <= x[i] + x[j] - 2 * t[i,j] <= 1.                            (5)
   93.59 +
   93.60 +   (One might note that (5) means t[i,j] = x[i] and x[j].)
   93.61 +
   93.62 +   Substituting s[i,j] from (4) to (2) leads to the following objective
   93.63 +   function:
   93.64 +
   93.65 +      z = sum{(i,j) in E} w[i,j] * (x[i] + x[j] - 2 * t[i,j]),       (6)
   93.66 +
   93.67 +   which does not include variables s[i,j]. */
   93.68 +
   93.69 +var t{(i,j) in E}, binary;
   93.70 +/* t[i,j] = x[i] and x[j] = (x[i] + x[j]) div 2 */
   93.71 +
   93.72 +s.t. xor{(i,j) in E}: 0 <= x[i] + x[j] - 2 * t[i,j] <= 1;
   93.73 +/* see (4) */
   93.74 +
   93.75 +maximize z: sum{(i,j) in E} w[i,j] * (x[i] + x[j] - 2 * t[i,j]);
   93.76 +/* see (6) */
   93.77 +
   93.78 +data;
   93.79 +
   93.80 +/* In this example the network has 15 nodes and 22 edges. */
   93.81 +
   93.82 +/* Optimal solution is 20 */
   93.83 +
   93.84 +set E :=
   93.85 +   1 2, 1 5, 2 3, 2 6, 3 4, 3 8, 4 9, 5 6, 5 7, 6 8, 7 8, 7 12, 8 9,
   93.86 +   8 12, 9 10, 9 14, 10 11, 10 14, 11 15, 12 13, 13 14, 14 15;
   93.87 +
   93.88 +end;
    94.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    94.2 +++ b/deps/glpk/examples/maxflow.mod	Sun Nov 06 20:59:10 2011 +0100
    94.3 @@ -0,0 +1,83 @@
    94.4 +/* MAXFLOW, Maximum Flow Problem */
    94.5 +
    94.6 +/* Written in GNU MathProg by Andrew Makhorin <mao@gnu.org> */
    94.7 +
    94.8 +/* The Maximum Flow Problem in a network G = (V, E), where V is a set
    94.9 +   of nodes, E within V x V is a set of arcs, is to maximize the flow
   94.10 +   from one given node s (source) to another given node t (sink) subject
   94.11 +   to conservation of flow constraints at each node and flow capacities
   94.12 +   on each arc. */
   94.13 +
   94.14 +param n, integer, >= 2;
   94.15 +/* number of nodes */
   94.16 +
   94.17 +set V, default {1..n};
   94.18 +/* set of nodes */
   94.19 +
   94.20 +set E, within V cross V;
   94.21 +/* set of arcs */
   94.22 +
   94.23 +param a{(i,j) in E}, > 0;
   94.24 +/* a[i,j] is capacity of arc (i,j) */
   94.25 +
   94.26 +param s, symbolic, in V, default 1;
   94.27 +/* source node */
   94.28 +
   94.29 +param t, symbolic, in V, != s, default n;
   94.30 +/* sink node */
   94.31 +
   94.32 +var x{(i,j) in E}, >= 0, <= a[i,j];
   94.33 +/* x[i,j] is elementary flow through arc (i,j) to be found */
   94.34 +
   94.35 +var flow, >= 0;
   94.36 +/* total flow from s to t */
   94.37 +
   94.38 +s.t. node{i in V}:
   94.39 +/* node[i] is conservation constraint for node i */
   94.40 +
   94.41 +   sum{(j,i) in E} x[j,i] + (if i = s then flow)
   94.42 +   /* summary flow into node i through all ingoing arcs */
   94.43 +
   94.44 +   = /* must be equal to */
   94.45 +
   94.46 +   sum{(i,j) in E} x[i,j] + (if i = t then flow);
   94.47 +   /* summary flow from node i through all outgoing arcs */
   94.48 +
   94.49 +maximize obj: flow;
   94.50 +/* objective is to maximize the total flow through the network */
   94.51 +
   94.52 +solve;
   94.53 +
   94.54 +printf{1..56} "="; printf "\n";
   94.55 +printf "Maximum flow from node %s to node %s is %g\n\n", s, t, flow;
   94.56 +printf "Starting node   Ending node   Arc capacity   Flow in arc\n";
   94.57 +printf "-------------   -----------   ------------   -----------\n";
   94.58 +printf{(i,j) in E: x[i,j] != 0}: "%13s   %11s   %12g   %11g\n", i, j,
   94.59 +   a[i,j], x[i,j];
   94.60 +printf{1..56} "="; printf "\n";
   94.61 +
   94.62 +data;
   94.63 +
   94.64 +/* These data correspond to an example from [Christofides]. */
   94.65 +
   94.66 +/* Optimal solution is 29 */
   94.67 +
   94.68 +param n := 9;
   94.69 +
   94.70 +param : E :   a :=
   94.71 +       1 2   14
   94.72 +       1 4   23
   94.73 +       2 3   10
   94.74 +       2 4    9
   94.75 +       3 5   12
   94.76 +       3 8   18
   94.77 +       4 5   26
   94.78 +       5 2   11
   94.79 +       5 6   25
   94.80 +       5 7    4
   94.81 +       6 7    7
   94.82 +       6 8    8
   94.83 +       7 9   15
   94.84 +       8 9   20;
   94.85 +
   94.86 +end;
    95.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    95.2 +++ b/deps/glpk/examples/mfasp.mod	Sun Nov 06 20:59:10 2011 +0100
    95.3 @@ -0,0 +1,62 @@
    95.4 +/* MFASP, Minimum Feedback Arc Set Problem */
    95.5 +
    95.6 +/* Written in GNU MathProg by Andrew Makhorin <mao@gnu.org> */
    95.7 +
    95.8 +/* The Minimum Feedback Arc Set Problem for a given directed graph
    95.9 +   G = (V, E), where V is a set of vertices and E is a set of arcs, is
   95.10 +   to find a minimal subset of arcs, which being removed from the graph
   95.11 +   make it acyclic.
   95.12 +
   95.13 +   Reference:
   95.14 +   Garey, M.R., and Johnson, D.S. (1979), Computers and Intractability:
   95.15 +   A guide to the theory of NP-completeness [Graph Theory, Covering and
   95.16 +   Partitioning, Minimum Feedback Arc Set, GT9]. */
   95.17 +
   95.18 +param n, integer, >= 0;
   95.19 +/* number of vertices */
   95.20 +
   95.21 +set V, default 1..n;
   95.22 +/* set of vertices */
   95.23 +
   95.24 +set E, within V cross V,
   95.25 +default setof{i in V, j in V: i <> j and Uniform(0,1) <= 0.15} (i,j);
   95.26 +/* set of arcs */
   95.27 +
   95.28 +printf "Graph has %d vertices and %d arcs\n", card(V), card(E);
   95.29 +
   95.30 +var x{(i,j) in E}, binary;
   95.31 +/* x[i,j] = 1 means that (i->j) is a feedback arc */
   95.32 +
   95.33 +/* It is known that a digraph G = (V, E) is acyclic if and only if its
   95.34 +   vertices can be assigned numbers from 1 to |V| in such a way that
   95.35 +   k[i] + 1 <= k[j] for every arc (i->j) in E, where k[i] is a number
   95.36 +   assigned to vertex i. We may use this condition to require that the
   95.37 +   digraph G = (V, E \ E'), where E' is a subset of feedback arcs, is
   95.38 +   acyclic. */
   95.39 +
   95.40 +var k{i in V}, >= 1, <= card(V);
   95.41 +/* k[i] is a number assigned to vertex i */
   95.42 +
   95.43 +s.t. r{(i,j) in E}: k[j] - k[i] >= 1 - card(V) * x[i,j];
   95.44 +/* note that x[i,j] = 1 leads to a redundant constraint */
   95.45 +
   95.46 +minimize obj: sum{(i,j) in E} x[i,j];
   95.47 +/* the objective is to minimize the cardinality of a subset of feedback
   95.48 +   arcs */
   95.49 +
   95.50 +solve;
   95.51 +
   95.52 +printf "Minimum feedback arc set:\n";
   95.53 +printf{(i,j) in E: x[i,j]} "%d %d\n", i, j;
   95.54 +
   95.55 +data;
   95.56 +
   95.57 +/* The optimal solution is 3 */
   95.58 +
   95.59 +param n := 15;
   95.60 +
   95.61 +set E := 1 2, 2 3, 3 4, 3 8, 4 9, 5 1, 6 5, 7 5, 8 6, 8 7, 8 9, 9 10,
   95.62 +         10 11, 10 14, 11 15, 12 7, 12 8, 12 13, 13 8, 13 12, 13 14,
   95.63 +         14 9, 15 14;
   95.64 +
   95.65 +end;
    96.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    96.2 +++ b/deps/glpk/examples/mfvsp.mod	Sun Nov 06 20:59:10 2011 +0100
    96.3 @@ -0,0 +1,62 @@
    96.4 +/* MFVSP, Minimum Feedback Vertex Set Problem */
    96.5 +
    96.6 +/* Written in GNU MathProg by Andrew Makhorin <mao@gnu.org> */
    96.7 +
    96.8 +/* The Minimum Feedback Vertex Set Problem for a given directed graph
    96.9 +   G = (V, E), where V is a set of vertices and E is a set of arcs, is
   96.10 +   to find a minimal subset of vertices, which being removed from the
   96.11 +   graph make it acyclic.
   96.12 +
   96.13 +   Reference:
   96.14 +   Garey, M.R., and Johnson, D.S. (1979), Computers and Intractability:
   96.15 +   A guide to the theory of NP-completeness [Graph Theory, Covering and
   96.16 +   Partitioning, Minimum Feedback Vertex Set, GT8]. */
   96.17 +
   96.18 +param n, integer, >= 0;
   96.19 +/* number of vertices */
   96.20 +
   96.21 +set V, default 1..n;
   96.22 +/* set of vertices */
   96.23 +
   96.24 +set E, within V cross V,
   96.25 +default setof{i in V, j in V: i <> j and Uniform(0,1) <= 0.15} (i,j);
   96.26 +/* set of arcs */
   96.27 +
   96.28 +printf "Graph has %d vertices and %d arcs\n", card(V), card(E);
   96.29 +
   96.30 +var x{i in V}, binary;
   96.31 +/* x[i] = 1 means that i is a feedback vertex */
   96.32 +
   96.33 +/* It is known that a digraph G = (V, E) is acyclic if and only if its
   96.34 +   vertices can be assigned numbers from 1 to |V| in such a way that
   96.35 +   k[i] + 1 <= k[j] for every arc (i->j) in E, where k[i] is a number
   96.36 +   assigned to vertex i. We may use this condition to require that the
   96.37 +   digraph G = (V, E \ E'), where E' is a subset of feedback arcs, is
   96.38 +   acyclic. */
   96.39 +
   96.40 +var k{i in V}, >= 1, <= card(V);
   96.41 +/* k[i] is a number assigned to vertex i */
   96.42 +
   96.43 +s.t. r{(i,j) in E}: k[j] - k[i] >= 1 - card(V) * (x[i] + x[j]);
   96.44 +/* note that x[i] = 1 or x[j] = 1 leads to a redundant constraint */
   96.45 +
   96.46 +minimize obj: sum{i in V} x[i];
   96.47 +/* the objective is to minimize the cardinality of a subset of feedback
   96.48 +   vertices */
   96.49 +
   96.50 +solve;
   96.51 +
   96.52 +printf "Minimum feedback vertex set:\n";
   96.53 +printf{i in V: x[i]} "%d\n", i;
   96.54 +
   96.55 +data;
   96.56 +
   96.57 +/* The optimal solution is 3 */
   96.58 +
   96.59 +param n := 15;
   96.60 +
   96.61 +set E := 1 2, 2 3, 3 4, 3 8, 4 9, 5 1, 6 5, 7 5, 8 6, 8 7, 8 9, 9 10,
   96.62 +         10 11, 10 14, 11 15, 12 7, 12 8, 12 13, 13 8, 13 12, 13 14,
   96.63 +         14 9, 15 14;
   96.64 +
   96.65 +end;
    97.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    97.2 +++ b/deps/glpk/examples/min01ks.mod	Sun Nov 06 20:59:10 2011 +0100
    97.3 @@ -0,0 +1,111 @@
    97.4 +/* min01ks.mod - finding minimal equivalent 0-1 knapsack inequality */
    97.5 +
    97.6 +/* Written in GNU MathProg by Andrew Makhorin <mao@gnu.org> */
    97.7 +
    97.8 +/* It is obvious that for a given 0-1 knapsack inequality
    97.9 +
   97.10 +      a[1] x[1] + ... + a[n] x[n] <= b,  x[j] in {0, 1}              (1)
   97.11 +
   97.12 +   there exist infinitely many equivalent inequalities with exactly the
   97.13 +   same feasible solutions.
   97.14 +
   97.15 +   Given a[j]'s and b this model allows to find an inequality
   97.16 +
   97.17 +      alfa[1] x[1] + ... + alfa[n] x[n] <= beta,  x[j] in {0, 1},    (2)
   97.18 +
   97.19 +   which is equivalent to (1) and where alfa[j]'s and beta are smallest
   97.20 +   non-negative integers.
   97.21 +
   97.22 +   This model has the following formulation:
   97.23 +
   97.24 +      minimize
   97.25 +
   97.26 +         z = |alfa[1]| + ... + |alfa[n]| + |beta| =                  (3)
   97.27 +
   97.28 +           = alfa[1] + ... + alfa[n] + beta
   97.29 +
   97.30 +      subject to
   97.31 +
   97.32 +         alfa[1] x[1] + ... + alfa[n] x[n] <= beta                   (4)
   97.33 +
   97.34 +                              for all x satisfying to (1)
   97.35 +
   97.36 +         alfa[1] x[1] + ... + alfa[n] x[n] >= beta + 1               (5)
   97.37 +
   97.38 +                              for all x not satisfying to (1)
   97.39 +
   97.40 +         alfa[1], ..., alfa[n], beta are non-negative integers.
   97.41 +
   97.42 +   Note that this model has n+1 variables and 2^n constraints.
   97.43 +
   97.44 +   It is interesting, as noticed in [1] and explained in [2], that
   97.45 +   in most cases LP relaxation of the MIP formulation above has integer
   97.46 +   optimal solution.
   97.47 +
   97.48 +   References
   97.49 +
   97.50 +   1. G.H.Bradley, P.L.Hammer, L.Wolsey, "Coefficient Reduction for
   97.51 +      Inequalities in 0-1 Variables", Math.Prog.7 (1974), 263-282.
   97.52 +
   97.53 +   2. G.J.Koehler, "A Study on Coefficient Reduction of Binary Knapsack
   97.54 +      Inequalities", University of Florida, 2001. */
   97.55 +
   97.56 +param n, integer, > 0;
   97.57 +/* number of variables in the knapsack inequality */
   97.58 +
   97.59 +set N := 1..n;
   97.60 +/* set of knapsack items */
   97.61 +
   97.62 +/* all binary n-vectors are numbered by 0, 1, ..., 2^n-1, where vector
   97.63 +   0 is 00...00, vector 1 is 00...01, etc. */
   97.64 +
   97.65 +set U := 0..2^n-1;
   97.66 +/* set of numbers of all binary n-vectors */
   97.67 +
   97.68 +param x{i in U, j in N}, binary, := (i div 2^(j-1)) mod 2;
   97.69 +/* x[i,j] is j-th component of i-th binary n-vector */
   97.70 +
   97.71 +param a{j in N}, >= 0;
   97.72 +/* original coefficients */
   97.73 +
   97.74 +param b, >= 0;
   97.75 +/* original right-hand side */
   97.76 +
   97.77 +set D := setof{i in U: sum{j in N} a[j] * x[i,j] <= b} i;
   97.78 +/* set of numbers of binary n-vectors, which (vectors) are feasible,
   97.79 +   i.e. satisfy to the original knapsack inequality (1) */
   97.80 +
   97.81 +var alfa{j in N}, integer, >= 0;
   97.82 +/* coefficients to be found */
   97.83 +
   97.84 +var beta, integer, >= 0;
   97.85 +/* right-hand side to be found */
   97.86 +
   97.87 +minimize z: sum{j in N} alfa[j] + beta; /* (3) */
   97.88 +
   97.89 +phi{i in D}: sum{j in N} alfa[j] * x[i,j] <= beta; /* (4) */
   97.90 +
   97.91 +psi{i in U diff D}: sum{j in N} alfa[j] * x[i,j] >= beta + 1; /* (5) */
   97.92 +
   97.93 +solve;
   97.94 +
   97.95 +printf "\nOriginal 0-1 knapsack inequality:\n";
   97.96 +for {j in 1..n} printf (if j = 1 then "" else " + ") & "%g x%d",
   97.97 +   a[j], j;
   97.98 +printf " <= %g\n", b;
   97.99 +printf "\nMinimized equivalent inequality:\n";
  97.100 +for {j in 1..n} printf (if j = 1 then "" else " + ") & "%g x%d",
  97.101 +   alfa[j], j;
  97.102 +printf " <= %g\n\n", beta;
  97.103 +
  97.104 +data;
  97.105 +
  97.106 +/* These data correspond to the very first example from [1]. */
  97.107 +
  97.108 +param n := 8;
  97.109 +
  97.110 +param a := [1]65, [2]64, [3]41, [4]22, [5]13, [6]12, [7]8, [8]2;
  97.111 +
  97.112 +param b := 80;
  97.113 +
  97.114 +end;
    98.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    98.2 +++ b/deps/glpk/examples/misp.mod	Sun Nov 06 20:59:10 2011 +0100
    98.3 @@ -0,0 +1,665 @@
    98.4 +/* MISP, Maximum Independent Set Problem */
    98.5 +
    98.6 +/* Written in GNU MathProg by Andrew Makhorin <mao@gnu.org> */
    98.7 +
    98.8 +/* Let G = (V,E) be an undirected graph with vertex set V and edge set
    98.9 +   E. Vertices u, v in V are non-adjacent if (u,v) not in E. A subset
   98.10 +   of the vertices S within V is independent if all vertices in S are
   98.11 +   pairwise non-adjacent. The Maximum Independent Set Problem (MISP) is
   98.12 +   to find an independent set having the largest cardinality. */
   98.13 +
   98.14 +param n, integer, > 0;
   98.15 +/* number of vertices */
   98.16 +
   98.17 +set V := 1..n;
   98.18 +/* set of vertices */
   98.19 +
   98.20 +set E within V cross V;
   98.21 +/* set of edges */
   98.22 +
   98.23 +var x{i in V}, binary;
   98.24 +/* x[i] = 1 means vertex i belongs to independent set */
   98.25 +
   98.26 +s.t. edge{(i,j) in E}: x[i] + x[j] <= 1;
   98.27 +/* if there is edge (i,j), vertices i and j cannot belong to the same
   98.28 +   independent set */
   98.29 +
   98.30 +maximize obj: sum{i in V} x[i];
   98.31 +/* the objective is to maximize the cardinality of independent set */
   98.32 +
   98.33 +data;
   98.34 +
   98.35 +/* These data corresponds to the test instance from:
   98.36 +
   98.37 +   M.G.C. Resende, T.A.Feo, S.H.Smith, "Algorithm 787 -- FORTRAN
   98.38 +   subroutines for approximate solution of the maximum independent set
   98.39 +   problem using GRASP," Trans. on Math. Softw., Vol. 24, No. 4,
   98.40 +   December 1998, pp. 386-394. */
   98.41 +
   98.42 +/* The optimal solution is 7 */
   98.43 +
   98.44 +param n := 50;
   98.45 +
   98.46 +set E :=
   98.47 + 1 2
   98.48 + 1 3
   98.49 + 1 5
   98.50 + 1 7
   98.51 + 1 8
   98.52 + 1 12
   98.53 + 1 15
   98.54 + 1 16
   98.55 + 1 19
   98.56 + 1 20
   98.57 + 1 21
   98.58 + 1 22
   98.59 + 1 28
   98.60 + 1 30
   98.61 + 1 34
   98.62 + 1 35
   98.63 + 1 37
   98.64 + 1 41
   98.65 + 1 42
   98.66 + 1 47
   98.67 + 1 50
   98.68 + 2 3
   98.69 + 2 5
   98.70 + 2 6
   98.71 + 2 7
   98.72 + 2 8
   98.73 + 2 9
   98.74 + 2 10
   98.75 + 2 13
   98.76 + 2 17
   98.77 + 2 19
   98.78 + 2 20
   98.79 + 2 21
   98.80 + 2 23
   98.81 + 2 25
   98.82 + 2 26
   98.83 + 2 29
   98.84 + 2 31
   98.85 + 2 35
   98.86 + 2 36
   98.87 + 2 44
   98.88 + 2 45
   98.89 + 2 46
   98.90 + 2 50
   98.91 + 3 5
   98.92 + 3 6
   98.93 + 3 8
   98.94 + 3 9
   98.95 + 3 10
   98.96 + 3 11
   98.97 + 3 14
   98.98 + 3 16
   98.99 + 3 23
  98.100 + 3 24
  98.101 + 3 26
  98.102 + 3 27
  98.103 + 3 28
  98.104 + 3 29
  98.105 + 3 30
  98.106 + 3 31
  98.107 + 3 34
  98.108 + 3 35
  98.109 + 3 36
  98.110 + 3 39
  98.111 + 3 41
  98.112 + 3 42
  98.113 + 3 43
  98.114 + 3 44
  98.115 + 3 50
  98.116 + 4 6
  98.117 + 4 7
  98.118 + 4 9
  98.119 + 4 10
  98.120 + 4 11
  98.121 + 4 13
  98.122 + 4 14
  98.123 + 4 15
  98.124 + 4 17
  98.125 + 4 21
  98.126 + 4 22
  98.127 + 4 23
  98.128 + 4 24
  98.129 + 4 25
  98.130 + 4 27
  98.131 + 4 28
  98.132 + 4 30
  98.133 + 4 31
  98.134 + 4 33
  98.135 + 4 34
  98.136 + 4 35
  98.137 + 4 36
  98.138 + 4 37
  98.139 + 4 38
  98.140 + 4 40
  98.141 + 4 41
  98.142 + 4 42
  98.143 + 4 46
  98.144 + 4 49
  98.145 + 5 6
  98.146 + 5 11
  98.147 + 5 14
  98.148 + 5 21
  98.149 + 5 24
  98.150 + 5 25
  98.151 + 5 28
  98.152 + 5 35
  98.153 + 5 38
  98.154 + 5 39
  98.155 + 5 41
  98.156 + 5 44
  98.157 + 5 49
  98.158 + 5 50
  98.159 + 6 8
  98.160 + 6 9
  98.161 + 6 10
  98.162 + 6 13
  98.163 + 6 14
  98.164 + 6 16
  98.165 + 6 17
  98.166 + 6 19
  98.167 + 6 22
  98.168 + 6 23
  98.169 + 6 26
  98.170 + 6 27
  98.171 + 6 30
  98.172 + 6 34
  98.173 + 6 35
  98.174 + 6 38
  98.175 + 6 39
  98.176 + 6 40
  98.177 + 6 41
  98.178 + 6 44
  98.179 + 6 45
  98.180 + 6 47
  98.181 + 6 50
  98.182 + 7 8
  98.183 + 7 9
  98.184 + 7 10
  98.185 + 7 11
  98.186 + 7 13
  98.187 + 7 15
  98.188 + 7 16
  98.189 + 7 18
  98.190 + 7 20
  98.191 + 7 22
  98.192 + 7 23
  98.193 + 7 24
  98.194 + 7 25
  98.195 + 7 33
  98.196 + 7 35
  98.197 + 7 36
  98.198 + 7 38
  98.199 + 7 43
  98.200 + 7 45
  98.201 + 7 46
  98.202 + 7 47
  98.203 + 8 10
  98.204 + 8 11
  98.205 + 8 13
  98.206 + 8 16
  98.207 + 8 17
  98.208 + 8 18
  98.209 + 8 19
  98.210 + 8 20
  98.211 + 8 21
  98.212 + 8 22
  98.213 + 8 23
  98.214 + 8 24
  98.215 + 8 25
  98.216 + 8 26
  98.217 + 8 33
  98.218 + 8 35
  98.219 + 8 36
  98.220 + 8 39
  98.221 + 8 42
  98.222 + 8 44
  98.223 + 8 48
  98.224 + 8 49
  98.225 + 9 12
  98.226 + 9 14
  98.227 + 9 17
  98.228 + 9 19
  98.229 + 9 20
  98.230 + 9 23
  98.231 + 9 28
  98.232 + 9 30
  98.233 + 9 31
  98.234 + 9 32
  98.235 + 9 33
  98.236 + 9 34
  98.237 + 9 38
  98.238 + 9 39
  98.239 + 9 42
  98.240 + 9 44
  98.241 + 9 45
  98.242 + 9 46
  98.243 + 10 11
  98.244 + 10 13
  98.245 + 10 15
  98.246 + 10 16
  98.247 + 10 17
  98.248 + 10 20
  98.249 + 10 21
  98.250 + 10 22
  98.251 + 10 23
  98.252 + 10 25
  98.253 + 10 26
  98.254 + 10 27
  98.255 + 10 28
  98.256 + 10 30
  98.257 + 10 31
  98.258 + 10 32
  98.259 + 10 37
  98.260 + 10 38
  98.261 + 10 41
  98.262 + 10 43
  98.263 + 10 44
  98.264 + 10 45
  98.265 + 10 50
  98.266 + 11 12
  98.267 + 11 14
  98.268 + 11 15
  98.269 + 11 18
  98.270 + 11 21
  98.271 + 11 24
  98.272 + 11 25
  98.273 + 11 26
  98.274 + 11 29
  98.275 + 11 32
  98.276 + 11 33
  98.277 + 11 35
  98.278 + 11 36
  98.279 + 11 37
  98.280 + 11 39
  98.281 + 11 40
  98.282 + 11 42
  98.283 + 11 43
  98.284 + 11 45
  98.285 + 11 47
  98.286 + 11 49
  98.287 + 11 50
  98.288 + 12 13
  98.289 + 12 16
  98.290 + 12 17
  98.291 + 12 19
  98.292 + 12 24
  98.293 + 12 25
  98.294 + 12 26
  98.295 + 12 30
  98.296 + 12 31
  98.297 + 12 32
  98.298 + 12 34
  98.299 + 12 36
  98.300 + 12 37
  98.301 + 12 39
  98.302 + 12 41
  98.303 + 12 44
  98.304 + 12 47
  98.305 + 12 48
  98.306 + 12 49
  98.307 + 13 15
  98.308 + 13 16
  98.309 + 13 18
  98.310 + 13 19
  98.311 + 13 20
  98.312 + 13 22
  98.313 + 13 23
  98.314 + 13 24
  98.315 + 13 27
  98.316 + 13 28
  98.317 + 13 29
  98.318 + 13 31
  98.319 + 13 33
  98.320 + 13 35
  98.321 + 13 36
  98.322 + 13 37
  98.323 + 13 44
  98.324 + 13 47
  98.325 + 13 49
  98.326 + 13 50
  98.327 + 14 15
  98.328 + 14 16
  98.329 + 14 17
  98.330 + 14 18
  98.331 + 14 19
  98.332 + 14 20
  98.333 + 14 21
  98.334 + 14 26
  98.335 + 14 28
  98.336 + 14 29
  98.337 + 14 30
  98.338 + 14 31
  98.339 + 14 32
  98.340 + 14 34
  98.341 + 14 35
  98.342 + 14 36
  98.343 + 14 38
  98.344 + 14 39
  98.345 + 14 41
  98.346 + 14 44
  98.347 + 14 46
  98.348 + 14 47
  98.349 + 14 48
  98.350 + 15 18
  98.351 + 15 21
  98.352 + 15 22
  98.353 + 15 23
  98.354 + 15 25
  98.355 + 15 28
  98.356 + 15 29
  98.357 + 15 30
  98.358 + 15 33
  98.359 + 15 34
  98.360 + 15 36
  98.361 + 15 37
  98.362 + 15 38
  98.363 + 15 39
  98.364 + 15 40
  98.365 + 15 43
  98.366 + 15 44
  98.367 + 15 46
  98.368 + 15 50
  98.369 + 16 17
  98.370 + 16 19
  98.371 + 16 20
  98.372 + 16 25
  98.373 + 16 26
  98.374 + 16 29
  98.375 + 16 35
  98.376 + 16 38
  98.377 + 16 39
  98.378 + 16 40
  98.379 + 16 41
  98.380 + 16 42
  98.381 + 16 44
  98.382 + 17 18
  98.383 + 17 19
  98.384 + 17 21
  98.385 + 17 22
  98.386 + 17 23
  98.387 + 17 25
  98.388 + 17 26
  98.389 + 17 28
  98.390 + 17 29
  98.391 + 17 33
  98.392 + 17 37
  98.393 + 17 44
  98.394 + 17 45
  98.395 + 17 48
  98.396 + 18 20
  98.397 + 18 24
  98.398 + 18 27
  98.399 + 18 28
  98.400 + 18 31
  98.401 + 18 32
  98.402 + 18 34
  98.403 + 18 35
  98.404 + 18 36
  98.405 + 18 37
  98.406 + 18 38
  98.407 + 18 45
  98.408 + 18 48
  98.409 + 18 49
  98.410 + 18 50
  98.411 + 19 22
  98.412 + 19 24
  98.413 + 19 28
  98.414 + 19 29
  98.415 + 19 36
  98.416 + 19 37
  98.417 + 19 39
  98.418 + 19 41
  98.419 + 19 43
  98.420 + 19 45
  98.421 + 19 48
  98.422 + 19 49
  98.423 + 20 21
  98.424 + 20 22
  98.425 + 20 24
  98.426 + 20 25
  98.427 + 20 26
  98.428 + 20 27
  98.429 + 20 29
  98.430 + 20 30
  98.431 + 20 31
  98.432 + 20 33
  98.433 + 20 34
  98.434 + 20 35
  98.435 + 20 38
  98.436 + 20 39
  98.437 + 20 41
  98.438 + 20 42
  98.439 + 20 43
  98.440 + 20 44
  98.441 + 20 45
  98.442 + 20 46
  98.443 + 20 48
  98.444 + 20 49
  98.445 + 21 22
  98.446 + 21 23
  98.447 + 21 29
  98.448 + 21 31
  98.449 + 21 35
  98.450 + 21 38
  98.451 + 21 42
  98.452 + 21 46
  98.453 + 21 47
  98.454 + 22 23
  98.455 + 22 26
  98.456 + 22 27
  98.457 + 22 28
  98.458 + 22 29
  98.459 + 22 30
  98.460 + 22 39
  98.461 + 22 40
  98.462 + 22 41
  98.463 + 22 42
  98.464 + 22 44
  98.465 + 22 45
  98.466 + 22 46
  98.467 + 22 47
  98.468 + 22 49
  98.469 + 22 50
  98.470 + 23 28
  98.471 + 23 31
  98.472 + 23 32
  98.473 + 23 33
  98.474 + 23 34
  98.475 + 23 35
  98.476 + 23 36
  98.477 + 23 39
  98.478 + 23 40
  98.479 + 23 41
  98.480 + 23 42
  98.481 + 23 44
  98.482 + 23 45
  98.483 + 23 48
  98.484 + 23 49
  98.485 + 23 50
  98.486 + 24 25
  98.487 + 24 27
  98.488 + 24 29
  98.489 + 24 30
  98.490 + 24 31
  98.491 + 24 33
  98.492 + 24 34
  98.493 + 24 38
  98.494 + 24 42
  98.495 + 24 43
  98.496 + 24 44
  98.497 + 24 49
  98.498 + 24 50
  98.499 + 25 26
  98.500 + 25 27
  98.501 + 25 29
  98.502 + 25 30
  98.503 + 25 33
  98.504 + 25 34
  98.505 + 25 36
  98.506 + 25 38
  98.507 + 25 40
  98.508 + 25 41
  98.509 + 25 42
  98.510 + 25 44
  98.511 + 25 46
  98.512 + 25 47
  98.513 + 25 48
  98.514 + 25 49
  98.515 + 26 28
  98.516 + 26 31
  98.517 + 26 32
  98.518 + 26 33
  98.519 + 26 37
  98.520 + 26 38
  98.521 + 26 39
  98.522 + 26 40
  98.523 + 26 41
  98.524 + 26 42
  98.525 + 26 45
  98.526 + 26 47
  98.527 + 26 48
  98.528 + 26 49
  98.529 + 27 29
  98.530 + 27 30
  98.531 + 27 33
  98.532 + 27 34
  98.533 + 27 35
  98.534 + 27 39
  98.535 + 27 40
  98.536 + 27 46
  98.537 + 27 48
  98.538 + 28 29
  98.539 + 28 37
  98.540 + 28 40
  98.541 + 28 42
  98.542 + 28 44
  98.543 + 28 46
  98.544 + 28 47
  98.545 + 28 50
  98.546 + 29 35
  98.547 + 29 38
  98.548 + 29 39
  98.549 + 29 41
  98.550 + 29 42
  98.551 + 29 48
  98.552 + 30 31
  98.553 + 30 32
  98.554 + 30 35
  98.555 + 30 37
  98.556 + 30 38
  98.557 + 30 40
  98.558 + 30 43
  98.559 + 30 45
  98.560 + 30 46
  98.561 + 30 47
  98.562 + 30 48
  98.563 + 31 33
  98.564 + 31 35
  98.565 + 31 38
  98.566 + 31 40
  98.567 + 31 41
  98.568 + 31 42
  98.569 + 31 44
  98.570 + 31 46
  98.571 + 31 47
  98.572 + 31 50
  98.573 + 32 33
  98.574 + 32 35
  98.575 + 32 39
  98.576 + 32 40
  98.577 + 32 46
  98.578 + 32 49
  98.579 + 32 50
  98.580 + 33 34
  98.581 + 33 36
  98.582 + 33 37
  98.583 + 33 40
  98.584 + 33 42
  98.585 + 33 43
  98.586 + 33 44
  98.587 + 33 45
  98.588 + 33 50
  98.589 + 34 35
  98.590 + 34 36
  98.591 + 34 37
  98.592 + 34 38
  98.593 + 34 40
  98.594 + 34 43
  98.595 + 34 44
  98.596 + 34 49
  98.597 + 34 50
  98.598 + 35 36
  98.599 + 35 38
  98.600 + 35 41
  98.601 + 35 42
  98.602 + 35 43
  98.603 + 35 45
  98.604 + 35 46
  98.605 + 35 47
  98.606 + 35 49
  98.607 + 35 50
  98.608 + 36 37
  98.609 + 36 39
  98.610 + 36 40
  98.611 + 36 41
  98.612 + 36 42
  98.613 + 36 43
  98.614 + 36 48
  98.615 + 36 50
  98.616 + 37 38
  98.617 + 37 41
  98.618 + 37 43
  98.619 + 37 46
  98.620 + 37 47
  98.621 + 37 48
  98.622 + 37 49
  98.623 + 37 50
  98.624 + 38 41
  98.625 + 38 45
  98.626 + 38 46
  98.627 + 38 48
  98.628 + 38 49
  98.629 + 38 50
  98.630 + 39 43
  98.631 + 39 46
  98.632 + 39 47
  98.633 + 39 48
  98.634 + 39 49
  98.635 + 40 43
  98.636 + 40 45
  98.637 + 40 48
  98.638 + 40 50
  98.639 + 41 42
  98.640 + 41 43
  98.641 + 41 44
  98.642 + 41 45
  98.643 + 41 46
  98.644 + 41 48
  98.645 + 41 49
  98.646 + 42 43
  98.647 + 42 44
  98.648 + 42 46
  98.649 + 42 48
  98.650 + 42 49
  98.651 + 43 45
  98.652 + 43 46
  98.653 + 43 48
  98.654 + 43 50
  98.655 + 44 45
  98.656 + 44 48
  98.657 + 45 46
  98.658 + 45 47
  98.659 + 45 48
  98.660 + 46 49
  98.661 + 47 49
  98.662 + 47 50
  98.663 + 48 49
  98.664 + 48 50
  98.665 + 49 50
  98.666 +;
  98.667 +
  98.668 +end;
    99.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    99.2 +++ b/deps/glpk/examples/money.mod	Sun Nov 06 20:59:10 2011 +0100
    99.3 @@ -0,0 +1,62 @@
    99.4 +/* MONEY, a crypto-arithmetic puzzle */
    99.5 +
    99.6 +/* Written in GNU MathProg by Andrew Makhorin <mao@gnu.org> */
    99.7 +
    99.8 +/* This is the classic example of a crypto-arithmetic puzzle published
    99.9 +   in the Strand Magazine by Henry Dudeney:
   99.10 +
   99.11 +        S E N D
   99.12 +      +
   99.13 +        M O R E
   99.14 +      ---------
   99.15 +      M O N E Y
   99.16 +
   99.17 +   In this puzzle the same letters mean the same digits. The question
   99.18 +   is: how to replace all the letters with the respective digits that
   99.19 +   makes the calculation correct?
   99.20 +
   99.21 +   The solution to this puzzle is:
   99.22 +   O = 0, M = 1, Y = 2, E = 5, N = 6, D = 7, R = 8, and S = 9.
   99.23 +
   99.24 +   References:
   99.25 +   H. E. Dudeney, in Strand Magazine vol. 68 (July 1924), pp. 97, 214.
   99.26 +
   99.27 +   (From Wikipedia, the free encyclopedia.) */
   99.28 +
   99.29 +set LETTERS := { 'D', 'E', 'M', 'N', 'O', 'R', 'S', 'Y' };
   99.30 +/* set of letters */
   99.31 +
   99.32 +set DIGITS := 0..9;
   99.33 +/* set of digits */
   99.34 +
   99.35 +var x{i in LETTERS, d in DIGITS}, binary;
   99.36 +/* x[i,d] = 1 means that letter i is digit d */
   99.37 +
   99.38 +s.t. one{i in LETTERS}: sum{d in DIGITS} x[i,d] = 1;
   99.39 +/* each letter must correspond exactly to one digit */
   99.40 +
   99.41 +s.t. alldiff{d in DIGITS}: sum{i in LETTERS} x[i,d] <= 1;
   99.42 +/* different letters must correspond to different digits; note that
   99.43 +   some digits may not correspond to any letters at all */
   99.44 +
   99.45 +var dig{i in LETTERS};
   99.46 +/* dig[i] is a digit corresponding to letter i */
   99.47 +
   99.48 +s.t. map{i in LETTERS}: dig[i] = sum{d in DIGITS} d * x[i,d];
   99.49 +
   99.50 +var carry{1..3}, binary;
   99.51 +/* carry bits */
   99.52 +
   99.53 +s.t. sum1: dig['D'] + dig['E']            = dig['Y'] + 10 * carry[1];
   99.54 +s.t. sum2: dig['N'] + dig['R'] + carry[1] = dig['E'] + 10 * carry[2];
   99.55 +s.t. sum3: dig['E'] + dig['O'] + carry[2] = dig['N'] + 10 * carry[3];
   99.56 +s.t. sum4: dig['S'] + dig['M'] + carry[3] = dig['O'] + 10 * dig['M'];
   99.57 +s.t. note: dig['M'] >= 1; /* M must not be 0 */
   99.58 +
   99.59 +solve;
   99.60 +/* solve the puzzle */
   99.61 +
   99.62 +display dig;
   99.63 +/* and display its solution */
   99.64 +
   99.65 +end;
   100.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
   100.2 +++ b/deps/glpk/examples/mplsamp1.c	Sun Nov 06 20:59:10 2011 +0100
   100.3 @@ -0,0 +1,32 @@
   100.4 +/* mplsamp1.c */
   100.5 +
   100.6 +#include <stdio.h>
   100.7 +#include <stdlib.h>
   100.8 +#include <glpk.h>
   100.9 +
  100.10 +int main(void)
  100.11 +{     glp_prob *lp;
  100.12 +      glp_tran *tran;
  100.13 +      int ret;
  100.14 +      lp = glp_create_prob();
  100.15 +      tran = glp_mpl_alloc_wksp();
  100.16 +      ret = glp_mpl_read_model(tran, "egypt.mod", 0);
  100.17 +      if (ret != 0)
  100.18 +      {  fprintf(stderr, "Error on translating model\n");
  100.19 +         goto skip;
  100.20 +      }
  100.21 +      ret = glp_mpl_generate(tran, NULL);
  100.22 +      if (ret != 0)
  100.23 +      {  fprintf(stderr, "Error on generating model\n");
  100.24 +         goto skip;
  100.25 +      }
  100.26 +      glp_mpl_build_prob(tran, lp);
  100.27 +      ret = glp_write_mps(lp, GLP_MPS_FILE, NULL, "egypt.mps");
  100.28 +      if (ret != 0)
  100.29 +         fprintf(stderr, "Error on writing MPS file\n");
  100.30 +skip: glp_mpl_free_wksp(tran);
  100.31 +      glp_delete_prob(lp);
  100.32 +      return 0;
  100.33 +}
  100.34 +
  100.35 +/* eof */
   101.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
   101.2 +++ b/deps/glpk/examples/mplsamp2.c	Sun Nov 06 20:59:10 2011 +0100
   101.3 @@ -0,0 +1,39 @@
   101.4 +/* mplsamp2.c */
   101.5 +
   101.6 +#include <stdio.h>
   101.7 +#include <stdlib.h>
   101.8 +#include <glpk.h>
   101.9 +
  101.10 +int main(void)
  101.11 +{     glp_prob *mip;
  101.12 +      glp_tran *tran;
  101.13 +      int ret;
  101.14 +      mip = glp_create_prob();
  101.15 +      tran = glp_mpl_alloc_wksp();
  101.16 +      ret = glp_mpl_read_model(tran, "sudoku.mod", 1);
  101.17 +      if (ret != 0)
  101.18 +      {  fprintf(stderr, "Error on translating model\n");
  101.19 +         goto skip;
  101.20 +      }
  101.21 +      ret = glp_mpl_read_data(tran, "sudoku.dat");
  101.22 +      if (ret != 0)
  101.23 +      {  fprintf(stderr, "Error on translating data\n");
  101.24 +         goto skip;
  101.25 +      }
  101.26 +      ret = glp_mpl_generate(tran, NULL);
  101.27 +      if (ret != 0)
  101.28 +      {  fprintf(stderr, "Error on generating model\n");
  101.29 +         goto skip;
  101.30 +      }
  101.31 +      glp_mpl_build_prob(tran, mip);
  101.32 +      glp_simplex(mip, NULL);
  101.33 +      glp_intopt(mip, NULL);
  101.34 +      ret = glp_mpl_postsolve(tran, mip, GLP_MIP);
  101.35 +      if (ret != 0)
  101.36 +         fprintf(stderr, "Error on postsolving model\n");
  101.37 +skip: glp_mpl_free_wksp(tran);
  101.38 +      glp_delete_prob(mip);
  101.39 +      return 0;
  101.40 +}
  101.41 +
  101.42 +/* eof */
   102.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
   102.2 +++ b/deps/glpk/examples/murtagh.mps	Sun Nov 06 20:59:10 2011 +0100
   102.3 @@ -0,0 +1,600 @@
   102.4 +*NAME:         OIL
   102.5 +*ROWS:         74
   102.6 +*COLUMNS:      81
   102.7 +*NONZERO:      504
   102.8 +*OPT SOLN:     126.057
   102.9 +*SOURCE:       Bruce Murtagh, "Advanced Linear Programming"
  102.10 +*APPLICATION:  oil refinery model
  102.11 +*COMMENTS:     problem is maximization
  102.12 +*
  102.13 +NAME          OIL REFINERY  EXAMPLE
  102.14 +ROWS
  102.15 + N  PROFIT
  102.16 + L  MVOLBOL
  102.17 + L  MVOLCOL
  102.18 + E  MVOLLNC
  102.19 + E  MVOLLNB
  102.20 + E  MVOLSRK
  102.21 + E  MVOLSRD
  102.22 + E  MVOLVBB
  102.23 + E  MVOLVBC
  102.24 + E  MVOLRCR
  102.25 + E  MVOLHVO
  102.26 + E  UBALKWH
  102.27 + E  UBALH2O
  102.28 + E  UBALSTM
  102.29 + E  UBALFUL
  102.30 + E  MVOLB95
  102.31 + E  MVOLB90
  102.32 + E  MVOLLHG
  102.33 + E  MVOLC3S
  102.34 + E  MVOLNC4
  102.35 + E  MVOLLSR
  102.36 + E  MVOLHSR
  102.37 + E  MVOLIC4
  102.38 + L  VCAPSGP
  102.39 + E  MVOLRFG
  102.40 + E  MSCFHYL
  102.41 + E  MVOLR90
  102.42 + E  MVOLR95
  102.43 + E  MVOLF90
  102.44 + E  MVOLF95
  102.45 + L  VCAPRFG
  102.46 + E  MVOLLCO
  102.47 + E  MVOLHHG
  102.48 + E  MVOLHCD
  102.49 + L  VCAPHVO
  102.50 + L  VCAPHOL
  102.51 + E  MVOLC3U
  102.52 + E  MVOLC4U
  102.53 + E  MVOLFCG
  102.54 + E  MVOLSLR
  102.55 + L  VCAPCCU
  102.56 + E  MVOLLA3
  102.57 + E  MVOLLA4
  102.58 + L  VCAPALK
  102.59 + L  XLPRPRE
  102.60 + L  XHPRPRE
  102.61 + L  XTELPRE
  102.62 + L  XRVPPRE
  102.63 + L  X200PRE
  102.64 + L  X230PRE
  102.65 + E  EVOLPRE
  102.66 + L  XPSCPRE
  102.67 + L  XRSCREG
  102.68 + L  XLPRINT
  102.69 + L  XHPRINT
  102.70 + L  XTELINT
  102.71 + L  XRVPINT
  102.72 + L  X200INT
  102.73 + L  X230INT
  102.74 + E  EVOLINT
  102.75 + L  XLPRREG
  102.76 + L  XHPRREG
  102.77 + L  XTELREG
  102.78 + L  XRVPREG
  102.79 + L  X200REG
  102.80 + L  X230REG
  102.81 + E  EVOLREG
  102.82 + E  EVOLLPG
  102.83 + E  EVOLJP4
  102.84 + L  XRVXJP4
  102.85 + L  XRVNJP4
  102.86 + E  EVOLDSL
  102.87 + E  EVOLRSD
  102.88 + L  XVISRSD
  102.89 +COLUMNS
  102.90 +    VCRDBOL   MVOLBOL   1.0
  102.91 +    VCRDBOL   MVOLLNB   -.537
  102.92 +    VCRDBOL   MVOLSRK   -.131
  102.93 +    VCRDBOL   MVOLSRD   -.1155
  102.94 +    VCRDBOL   MVOLVBB   -.037
  102.95 +    VCRDBOL   MVOLRCR   -.0365
  102.96 +    VCRDBOL   MVOLHVO   -.143
  102.97 +    VCRDBOL   UBALKWH   .302
  102.98 +    VCRDBOL   UBALH2O   .150
  102.99 +    VCRDBOL   UBALSTM   .003
 102.100 +    VCRDBOL   UBALFUL   .0587
 102.101 +    VCRDBOL   PROFIT    -12.8
 102.102 +    VCRDCOL   MVOLCOL   1.
 102.103 +    VCRDCOL   MVOLLNC   -.2931
 102.104 +    VCRDCOL   MVOLSRK   -.1170
 102.105 +    VCRDCOL   MVOLSRD   -.0649
 102.106 +    VCRDCOL   MVOLVBC   -.18
 102.107 +    VCRDCOL   MVOLRCR   -.1233
 102.108 +    VCRDCOL   MVOLHVO   -.2217
 102.109 +    VCRDCOL   UBALKWH   .384
 102.110 +    VCRDCOL   UBALH2O   .185
 102.111 +    VCRDCOL   UBALSTM   .003
 102.112 +    VCRDCOL   UBALFUL   .1053
 102.113 +    VCRDCOL   PROFIT    -11.48
 102.114 +    VSGPLNC   MVOLLNC   1.
 102.115 +    VSGPLNC   MVOLC3S   -.0112
 102.116 +    VSGPLNC   MVOLNC4   -.0378
 102.117 +    VSGPLNC   MVOLLSR   -.1502
 102.118 +    VSGPLNC   MVOLHSR   -.7953
 102.119 +    VSGPLNC   MVOLIC4   -.0099
 102.120 +    VSGPLNC   UBALKWH   .721
 102.121 +    VSGPLNC   UBALH2O   .185
 102.122 +    VSGPLNC   UBALSTM   .013
 102.123 +    VSGPLNC   UBALFUL   .0488
 102.124 +    VSGPLNC   VCAPSGP   1.
 102.125 +    VSGPLNB   MVOLLNB   1.
 102.126 +    VSGPLNB   MVOLC3S   -.0277
 102.127 +    VSGPLNB   MVOLNC4   -.0563
 102.128 +    VSGPLNB   MVOLLSR   -.199
 102.129 +    VSGPLNB   MVOLHSR   -.6873
 102.130 +    VSGPLNB   MVOLIC4   -.017
 102.131 +    VSGPLNB   UBALKWH   .495
 102.132 +    VSGPLNB   UBALH2O   .209
 102.133 +    VSGPLNB   UBALSTM   .013
 102.134 +    VSGPLNB   UBALFUL   .0506
 102.135 +    VSGPLNB   VCAPSGP   1.
 102.136 +    VSGPLHG   MVOLLHG   1.0
 102.137 +    VSGPLHG   MVOLC3S   -.175
 102.138 +    VSGPLHG   MVOLNC4   -.27
 102.139 +    VSGPLHG   MVOLLSR   -.028
 102.140 +    VSGPLHG   MVOLIC4   -.455
 102.141 +    VSGPLHG   UBALKWH   .495
 102.142 +    VSGPLHG   UBALH2O   .209
 102.143 +    VSGPLHG   UBALSTM   .013
 102.144 +    VSGPLHG   UBALFUL   .0448
 102.145 +    VSGPB95   MVOLB95   1.
 102.146 +    VSGPB95   MVOLC3S   -.2836
 102.147 +    VSGPB95   MVOLNC4   -.3285
 102.148 +    VSGPB95   MVOLLSR   -.0241
 102.149 +    VSGPB95   MVOLIC4   -.2502
 102.150 +    VSGPB95   UBALKWH   .495
 102.151 +    VSGPB95   UBALH2O   .209
 102.152 +    VSGPB95   UBALSTM   .013
 102.153 +    VSGPB95   UBALFUL   .0506
 102.154 +    VSGPB90   MVOLB90   1.
 102.155 +    VSGPB90   MVOLC3S   -.271
 102.156 +    VSGPB90   MVOLNC4   -.3289
 102.157 +    VSGPB90   MVOLLSR   -.0255
 102.158 +    VSGPB90   MVOLIC4   -.2656
 102.159 +    VSGPB90   UBALKWH   .495
 102.160 +    VSGPB90   UBALH2O   .209
 102.161 +    VSGPB90   UBALSTM   .013
 102.162 +    VSGPB90   UBALFUL   .0506
 102.163 +    VH2RHSR   MVOLHSR   1.
 102.164 +    VH2RHSR   MVOLRFG   -1.
 102.165 +    VH2RHSR   MSCFHYL   .0327
 102.166 +    VH2RHSR   UBALKWH   .793
 102.167 +    VH2RHSR   UBALH2O   .045
 102.168 +    VH2RHSR   UBALFUL   .094
 102.169 +    VH2RHSR   PROFIT    -.0176
 102.170 +    VRFFRF1   MVOLRFG   1.0
 102.171 +    VRFFRF1   MVOLR90   -1.0
 102.172 +    VRFFRF2   MVOLRFG   1.0
 102.173 +    VRFFRF2   MVOLR95   -1.0
 102.174 +    VRFFHH1   MVOLR90   -1.0
 102.175 +    VRFFHH1   MVOLHHG   1.0
 102.176 +    VRFFHH2   MVOLR95   -1.0
 102.177 +    VRFFHH2   MVOLHHG   1.0
 102.178 +    VRFGR90   MVOLR90   1.0
 102.179 +    VRFGR90   MVOLB90   -.0404
 102.180 +    VRFGR90   MVOLF90   -0.8564
 102.181 +    VRFGR90   MSCFHYL   -0.8239
 102.182 +    VRFGR90   UBALKWH   .792
 102.183 +    VRFGR90   UBALH2O   .297
 102.184 +    VRFGR90   UBALSTM   0.0063
 102.185 +    VRFGR90   UBALFUL   -0.156
 102.186 +    VRFGR90   VCAPRFG   1.0
 102.187 +    VRFGR90   PROFIT    -0.1512
 102.188 +    VRFGR95   MVOLR95   1.0
 102.189 +    VRFGR95   MVOLB95   -0.0588
 102.190 +    VRFGR95   MVOLF95   -0.8145
 102.191 +    VRFGR95   MSCFHYL   -.7689
 102.192 +    VRFGR95   UBALKWH   1.03
 102.193 +    VRFGR95   UBALH2O   .387
 102.194 +    VRFGR95   UBALSTM   0.008
 102.195 +    VRFGR95   UBALFUL   -.2112
 102.196 +    VRFGR95   VCAPRFG   1.3
 102.197 +    VRFGR95   PROFIT    -0.304
 102.198 +    VHOLLCO   MVOLLCO   1.0
 102.199 +    VHOLLCO   MVOLHHG   -.6627
 102.200 +    VHOLLCO   MVOLLHG   -0.2414
 102.201 +    VHOLLCO   MVOLHCD   -.2930
 102.202 +    VHOLLCO   MSCFHYL   2.3
 102.203 +    VHOLLCO   UBALFUL   -.2054
 102.204 +    VHOLLCO   UBALH2O   0.826
 102.205 +    VHOLLCO   UBALKWH   14.61
 102.206 +    VHOLLCO   VCAPHOL   1.0
 102.207 +    VHOLLCO   PROFIT    -0.2112
 102.208 +    VHOLSRD   MVOLSRD   1.0
 102.209 +    VHOLSRD   MVOLHHG   -.6627
 102.210 +    VHOLSRD   MVOLLHG   -0.2414
 102.211 +    VHOLSRD   MVOLHCD   -.2930
 102.212 +    VHOLSRD   MSCFHYL   2.3
 102.213 +    VHOLSRD   UBALFUL   -.2054
 102.214 +    VHOLSRD   UBALH2O   0.826
 102.215 +    VHOLSRD   UBALKWH   14.61
 102.216 +    VHOLSRD   VCAPHOL   1.0
 102.217 +    VHOLSRD   PROFIT    -0.2112
 102.218 +    VHOLRCR   MVOLRCR   1.0
 102.219 +    VHOLRCR   MVOLHHG   -.5875
 102.220 +    VHOLRCR   MVOLLHG   -0.3321
 102.221 +    VHOLRCR   MVOLHCD   -.3620
 102.222 +    VHOLRCR   MSCFHYL   2.3
 102.223 +    VHOLRCR   UBALFUL   -.2054
 102.224 +    VHOLRCR   UBALH2O   0.826
 102.225 +    VHOLRCR   UBALKWH   14.61
 102.226 +    VHOLRCR   VCAPHOL   1.0
 102.227 +    VHOLRCR   PROFIT    -0.2112
 102.228 +    VHOLHVO   MVOLHVO   1.0
 102.229 +    VHOLHVO   MVOLHHG   -.5875
 102.230 +    VHOLHVO   MVOLLHG   -0.3321
 102.231 +    VHOLHVO   MVOLHCD   -.3620
 102.232 +    VHOLHVO   MSCFHYL   2.3
 102.233 +    VHOLHVO   UBALFUL   -.2054
 102.234 +    VHOLHVO   UBALH2O   0.826
 102.235 +    VHOLHVO   UBALKWH   14.61
 102.236 +    VHOLHVO   VCAPHVO   1.0
 102.237 +    VHOLHVO   VCAPHOL   1.0
 102.238 +    VHOLHVO   PROFIT    -0.2112
 102.239 +    VCCUSRK   MVOLSRK   1.0
 102.240 +    VCCUSRK   MVOLNC4   -0.0184
 102.241 +    VCCUSRK   MVOLC3S   -0.0303
 102.242 +    VCCUSRK   MVOLIC4   -0.0564
 102.243 +    VCCUSRK   MVOLC3U   -0.0655
 102.244 +    VCCUSRK   MVOLC4U   -0.0780
 102.245 +    VCCUSRK   MVOLFCG   -0.4750
 102.246 +    VCCUSRK   MVOLLCO   -0.3050
 102.247 +    VCCUSRK   UBALSTM   -.0654
 102.248 +    VCCUSRK   UBALFUL   -.2703
 102.249 +    VCCUSRK   UBALH2O   .632
 102.250 +    VCCUSRK   UBALKWH   .6807
 102.251 +    VCCUSRK   VCAPCCU   1.
 102.252 +    VCCUSRK   PROFIT    -.2112
 102.253 +    VCCUSRD   MVOLSRD   1.
 102.254 +    VCCUSRD   MVOLNC4   -.0184
 102.255 +    VCCUSRD   MVOLC3S   -.0303
 102.256 +    VCCUSRD   MVOLIC4   -.0564
 102.257 +    VCCUSRD   MVOLC3U   -.0655
 102.258 +    VCCUSRD   MVOLC4U   -.0780
 102.259 +    VCCUSRD   MVOLFCG   -.4750
 102.260 +    VCCUSRD   MVOLLCO   -.3050
 102.261 +    VCCUSRD   UBALSTM   -.0654
 102.262 +    VCCUSRD   UBALFUL   -.2703
 102.263 +    VCCUSRD   UBALH2O   0.632
 102.264 +    VCCUSRD   UBALKWH   .6807
 102.265 +    VCCUSRD   VCAPCCU   1.
 102.266 +    VCCUSRD   PROFIT    -.2112
 102.267 +    VCCURCR   MVOLRCR   1.0
 102.268 +    VCCURCR   MVOLNC4   -.0185
 102.269 +    VCCURCR   MVOLC3S   -.0328
 102.270 +    VCCURCR   MVOLIC4   -.0568
 102.271 +    VCCURCR   MVOLC3U   -.0658
 102.272 +    VCCURCR   MVOLC4U   -.0806
 102.273 +    VCCURCR   MVOLFCG   -.4934
 102.274 +    VCCURCR   MVOLLCO   -.2922
 102.275 +    VCCURCR   MVOLSLR   -.0096
 102.276 +    VCCURCR   UBALSTM   -.0654
 102.277 +    VCCURCR   UBALFUL   -.2703
 102.278 +    VCCURCR   UBALH2O   0.632
 102.279 +    VCCURCR   UBALKWH   .6807
 102.280 +    VCCURCR   VCAPCCU   1.
 102.281 +    VCCURCR   PROFIT    -.2112
 102.282 +    VCCUHVO   MVOLHVO   1.0
 102.283 +    VCCUHVO   MVOLNC4   -.0185
 102.284 +    VCCUHVO   MVOLC3S   -.0328
 102.285 +    VCCUHVO   MVOLIC4   -.0568
 102.286 +    VCCUHVO   MVOLC3U   -.0658
 102.287 +    VCCUHVO   MVOLC4U   -.0806
 102.288 +    VCCUHVO   MVOLFCG   -.4934
 102.289 +    VCCUHVO   MVOLLCO   -.2922
 102.290 +    VCCUHVO   MVOLSLR   -.0096
 102.291 +    VCCUHVO   UBALSTM   -.0654
 102.292 +    VCCUHVO   UBALFUL   -.2703
 102.293 +    VCCUHVO   UBALH2O   0.632
 102.294 +    VCCUHVO   UBALKWH   .6807
 102.295 +    VCCUHVO   VCAPHVO   1.
 102.296 +    VCCUHVO   VCAPCCU   1.
 102.297 +    VCCUHVO   PROFIT    -.2112
 102.298 +    VALKLA3   MVOLIC4   .7600
 102.299 +    VALKLA3   MVOLC3U   .5714
 102.300 +    VALKLA3   MVOLLA3   -1.0
 102.301 +    VALKLA3   UBALSTM   .1869
 102.302 +    VALKLA3   UBALFUL   .2796
 102.303 +    VALKLA3   UBALH2O   2.241
 102.304 +    VALKLA3   UBALKWH   2.766
 102.305 +    VALKLA3   VCAPALK   1.0
 102.306 +    VALKLA3   PROFIT    -.512
 102.307 +    VALKLA4   MVOLIC4   .6571
 102.308 +    VALKLA4   MVOLC4U   .5714
 102.309 +    VALKLA4   MVOLC3S   -.0571
 102.310 +    VALKLA4   MVOLNC4   -.0114
 102.311 +    VALKLA4   MVOLLA4   -1.0
 102.312 +    VALKLA4   UBALSTM   .1724
 102.313 +    VALKLA4   UBALFUL   .2579
 102.314 +    VALKLA4   UBALH2O   2.067
 102.315 +    VALKLA4   UBALKWH   2.552
 102.316 +    VALKLA4   VCAPALK   1.0
 102.317 +    VALKLA4   PROFIT    -.472
 102.318 +    VALKIC4   MVOLIC4   1.0
 102.319 +    VALKIC4   MVOLNC4   -1.0
 102.320 +    VALKC3U   MVOLC3U   1.0
 102.321 +    VALKC3U   MVOLC3S   -1.0
 102.322 +    VALKC4U   MVOLC4U   1.0
 102.323 +    VALKC4U   MVOLNC4   -1.0
 102.324 +    UTILC3S   MVOLC3S   1.
 102.325 +    UTILC3S   UBALFUL   -3.814
 102.326 +    UTILNC4   MVOLNC4   1.
 102.327 +    UTILNC4   UBALFUL   -4.316
 102.328 +    UTILIC4   MVOLIC4   1.
 102.329 +    UTILIC4   UBALFUL   -4.153
 102.330 +    UTILC3U   MVOLC3U   1.
 102.331 +    UTILC3U   UBALFUL   -3.808
 102.332 +    UTILC4U   MVOLC4U   1.
 102.333 +    UTILC4U   UBALFUL   -4.44
 102.334 +    UTILHYL   MSCFHYL   1.
 102.335 +    UTILHYL   UBALFUL   -.305
 102.336 +    UTILSTM   UBALSTM   -1.
 102.337 +    UTILSTM   UBALFUL   1.42
 102.338 +    UTILSTM   PROFIT    -.16
 102.339 +    PURCPC4   MVOLIC4   -.5
 102.340 +    PURCPC4   MVOLNC4   -.5
 102.341 +    PURCPC4   PROFIT    -12.
 102.342 +    PURCH2O   UBALH2O   -1.
 102.343 +    PURCH2O   PROFIT    -.0528
 102.344 +    PURCKWH   UBALKWH   -1.
 102.345 +    PURCKWH   PROFIT    -.04
 102.346 +    PURCFUL   UBALFUL   -1.
 102.347 +    PURCFUL   PROFIT    -1.6
 102.348 +    PURCFLR   UBALFUL   1.
 102.349 +    BLPGC3S   MVOLC3S   1.0
 102.350 +    BLPGC3S   EVOLLPG   -1.0
 102.351 +    BLPGNC4   MVOLNC4   1.0
 102.352 +    BLPGNC4   EVOLLPG   -1.0
 102.353 +    SELLLPG   EVOLLPG   1.0
 102.354 +    SELLLPG   PROFIT    11.0
 102.355 +    BUP4LSR   MVOLLSR   1.0
 102.356 +    BUP4LSR   EVOLJP4   -1.0
 102.357 +    BUP4LSR   XRVXJP4   14.0
 102.358 +    BUP4LSR   XRVNJP4   -14.0
 102.359 +    BUP4HSR   MVOLHSR   1.0
 102.360 +    BUP4HSR   EVOLJP4   -1.0
 102.361 +    BUP4HSR   XRVXJP4   0.8
 102.362 +    BUP4HSR   XRVNJP4   -0.8
 102.363 +    SELLJP4   EVOLJP4   1.0
 102.364 +    SELLJP4   XRVXJP4   -3.0
 102.365 +    SELLJP4   XRVNJP4   2.0
 102.366 +    SELLJP4   PROFIT    16.8
 102.367 +    BDSLSRK   MVOLSRK   1.0
 102.368 +    BDSLSRK   EVOLDSL   -1.0
 102.369 +    BDSLSRD   MVOLSRD   1.0
 102.370 +    BDSLSRD   EVOLDSL   -1.0
 102.371 +    SELLDSL   EVOLDSL   1.0
 102.372 +    SELLDSL   PROFIT    14.4
 102.373 +    BPRELSR   MVOLLSR   1.
 102.374 +    BPRELSR   XLPRPRE   -7.95
 102.375 +    BPRELSR   XHPRPRE   -8.70
 102.376 +    BPRELSR   XTELPRE   -3.00
 102.377 +    BPRELSR   XRVPPRE   14.00
 102.378 +    BPRELSR   X200PRE   1.
 102.379 +    BPRELSR   X230PRE   -1.
 102.380 +    BPRELSR   EVOLPRE   -1.
 102.381 +    BPREHCD   MVOLHCD   1.0
 102.382 +    BPREHCD   XLPRPRE   -8.84
 102.383 +    BPREHCD   XHPRPRE   -9.45
 102.384 +    BPREHCD   XTELPRE   -3.00
 102.385 +    BPREHCD   XRVPPRE   12.00
 102.386 +    BPREHCD   X200PRE   1.
 102.387 +    BPREHCD   X230PRE   -1.
 102.388 +    BPREHCD   EVOLPRE   -1.
 102.389 +    BPREF95   MVOLF95   1.0
 102.390 +    BPREF95   XLPRPRE   -9.43
 102.391 +    BPREF95   XHPRPRE   -9.57
 102.392 +    BPREF95   XTELPRE   -3.
 102.393 +    BPREF95   XRVPPRE   3.5
 102.394 +    BPREF95   X200PRE   .233
 102.395 +    BPREF95   X230PRE   -.358
 102.396 +    BPREF95   EVOLPRE   -1.
 102.397 +    BPREF90   MVOLF90   1.0
 102.398 +    BPREF90   XLPRPRE   -9.03
 102.399 +    BPREF90   XHPRPRE   -9.32
 102.400 +    BPREF90   XTELPRE   -3.0
 102.401 +    BPREF90   XRVPPRE   3.5
 102.402 +    BPREF90   X200PRE   .205
 102.403 +    BPREF90   X230PRE   -.333
 102.404 +    BPREF90   EVOLPRE   -1.
 102.405 +    BPREFCG   MVOLFCG   1.0
 102.406 +    BPREFCG   XLPRPRE   -9.23
 102.407 +    BPREFCG   XHPRPRE   -9.22
 102.408 +    BPREFCG   XTELPRE   -3.
 102.409 +    BPREFCG   XRVPPRE   6.
 102.410 +    BPREFCG   X200PRE   .381
 102.411 +    BPREFCG   X230PRE   -.509
 102.412 +    BPREFCG   EVOLPRE   -1.
 102.413 +    BPRELA3   MVOLLA3   1.0
 102.414 +    BPRELA3   XLPRPRE   -9.4
 102.415 +    BPRELA3   XHPRPRE   -9.85
 102.416 +    BPRELA3   XTELPRE   -3.0
 102.417 +    BPRELA3   XRVPPRE   2.5
 102.418 +    BPRELA3   X200PRE   0.39
 102.419 +    BPRELA3   X230PRE   -0.77
 102.420 +    BPRELA3   EVOLPRE   -1.0
 102.421 +    BPRELA4   MVOLLA4   1.0
 102.422 +    BPRELA4   XLPRPRE   -9.74
 102.423 +    BPRELA4   XHPRPRE   -10.1
 102.424 +    BPRELA4   XTELPRE   -3.0
 102.425 +    BPRELA4   XRVPPRE   3.3
 102.426 +    BPRELA4   X200PRE   0.233
 102.427 +    BPRELA4   X230PRE   -0.58
 102.428 +    BPRELA4   EVOLPRE   -1.0
 102.429 +    BPRENC4   MVOLNC4   1.0
 102.430 +    BPRENC4   XLPRPRE   -9.74
 102.431 +    BPRENC4   XHPRPRE   -9.9
 102.432 +    BPRENC4   XTELPRE   -3.0
 102.433 +    BPRENC4   XRVPPRE   66.0
 102.434 +    BPRENC4   X200PRE   1.0
 102.435 +    BPRENC4   X230PRE   -1.0
 102.436 +    BPRENC4   EVOLPRE   -1.0
 102.437 +    BPRETEL   XLPRPRE   -0.493
 102.438 +    BPRETEL   XHPRPRE   -0.165
 102.439 +    BPRETEL   XTELPRE   1.0
 102.440 +    BPRETEL   PROFIT    -0.3696
 102.441 +    SELLPRE   XLPRPRE   10.03
 102.442 +    SELLPRE   XHPRPRE   10.03
 102.443 +    SELLPRE   XRVPPRE   -9.5
 102.444 +    SELLPRE   X200PRE   -0.5
 102.445 +    SELLPRE   X230PRE   0.5
 102.446 +    SELLPRE   XPSCPRE   0.64
 102.447 +    SELLPRE   XRSCREG   0.35
 102.448 +    SELLPRE   EVOLPRE   1.0
 102.449 +    SELLPRE   PROFIT    21.44
 102.450 +    BINTLSR   MVOLLSR   1.0
 102.451 +    BINTLSR   XLPRINT   -7.98
 102.452 +    BINTLSR   XHPRINT   -8.58
 102.453 +    BINTLSR   XTELINT   -3.0
 102.454 +    BINTLSR   XRVPINT   14.0
 102.455 +    BINTLSR   X200INT   1.0
 102.456 +    BINTLSR   X230INT   -1.0
 102.457 +    BINTLSR   EVOLINT   -1.0
 102.458 +    BINTHCD   MVOLHCD   1.
 102.459 +    BINTHCD   XLPRINT   -8.87
 102.460 +    BINTHCD   XHPRINT   -9.33
 102.461 +    BINTHCD   XTELINT   -3.0
 102.462 +    BINTHCD   XRVPINT   12.0
 102.463 +    BINTHCD   X200INT   1.0
 102.464 +    BINTHCD   X230INT   -1.
 102.465 +    BINTHCD   EVOLINT   -1.0
 102.466 +    BINTF95   MVOLF95   1.
 102.467 +    BINTF95   XLPRINT   -9.46
 102.468 +    BINTF95   XHPRINT   -9.45
 102.469 +    BINTF95   XTELINT   -3.0
 102.470 +    BINTF95   XRVPINT   3.5
 102.471 +    BINTF95   X200INT   .233
 102.472 +    BINTF95   X230INT   -.358
 102.473 +    BINTF95   EVOLINT   -1.0
 102.474 +    BINTF90   MVOLF90   1.
 102.475 +    BINTF90   XLPRINT   -9.06
 102.476 +    BINTF90   XHPRINT   -9.20
 102.477 +    BINTF90   XTELINT   -3.0
 102.478 +    BINTF90   XRVPINT   3.5
 102.479 +    BINTF90   X200INT   .205
 102.480 +    BINTF90   X230INT   -.333
 102.481 +    BINTF90   EVOLINT   -1.0
 102.482 +    BINTFCG   MVOLFCG   1.
 102.483 +    BINTFCG   XLPRINT   -9.26
 102.484 +    BINTFCG   XHPRINT   -9.13
 102.485 +    BINTFCG   XTELINT   -3.0
 102.486 +    BINTFCG   XRVPINT   6.
 102.487 +    BINTFCG   X200INT   .318
 102.488 +    BINTFCG   X230INT   -.509
 102.489 +    BINTFCG   EVOLINT   -1.0
 102.490 +    BINTNC4   MVOLNC4   1.
 102.491 +    BINTNC4   XLPRINT   -9.77
 102.492 +    BINTNC4   XHPRINT   -9.78
 102.493 +    BINTNC4   XTELINT   -3.0
 102.494 +    BINTNC4   XRVPINT   66.
 102.495 +    BINTNC4   X200INT   1.0
 102.496 +    BINTNC4   X230INT   -1.
 102.497 +    BINTNC4   EVOLINT   -1.0
 102.498 +    BINTTEL   XLPRINT   -.435
 102.499 +    BINTTEL   XHPRINT   -.208
 102.500 +    BINTTEL   XTELINT   1.
 102.501 +    BINTTEL   PROFIT    -.3696
 102.502 +    SELLINT   XLPRINT   9.65
 102.503 +    SELLINT   XHPRINT   9.65
 102.504 +    SELLINT   XRVPINT   -9.5
 102.505 +    SELLINT   X200INT   -0.5
 102.506 +    SELLINT   X230INT   0.5
 102.507 +    SELLINT   XPSCPRE   -.36
 102.508 +    SELLINT   XRSCREG   0.35
 102.509 +    SELLINT   EVOLINT   1.0
 102.510 +    SELLINT   PROFIT    20.32
 102.511 +    BREGLSR   MVOLLSR   1.0
 102.512 +    BREGLSR   XLPRREG   -7.99
 102.513 +    BREGLSR   XHPRREG   -8.59
 102.514 +    BREGLSR   XTELREG   -3.0
 102.515 +    BREGLSR   XRVPREG   14.0
 102.516 +    BREGLSR   X200REG   1.0
 102.517 +    BREGLSR   X230REG   -1.0
 102.518 +    BREGLSR   EVOLREG   -1.0
 102.519 +    BREGHCD   MVOLHCD   1.0
 102.520 +    BREGHCD   XLPRREG   -8.88
 102.521 +    BREGHCD   XHPRREG   -9.34
 102.522 +    BREGHCD   XTELREG   -3.0
 102.523 +    BREGHCD   XRVPREG   12.0
 102.524 +    BREGHCD   X200REG   1.0
 102.525 +    BREGHCD   X230REG   -1.0
 102.526 +    BREGHCD   EVOLREG   -1.0
 102.527 +    BREGF95   MVOLF95   1.0
 102.528 +    BREGF95   XLPRREG   -9.47
 102.529 +    BREGF95   XHPRREG   -9.46
 102.530 +    BREGF95   XTELREG   -3.0
 102.531 +    BREGF95   XRVPREG   3.5
 102.532 +    BREGF95   X200REG   .233
 102.533 +    BREGF95   X230REG   -0.358
 102.534 +    BREGF95   EVOLREG   -1.0
 102.535 +    BREGF90   MVOLF90   1.0
 102.536 +    BREGF90   XLPRREG   -9.07
 102.537 +    BREGF90   XHPRREG   -9.21
 102.538 +    BREGF90   XTELREG   -3.0
 102.539 +    BREGF90   XRVPREG   3.5
 102.540 +    BREGF90   X200REG   .205
 102.541 +    BREGF90   X230REG   -0.333
 102.542 +    BREGF90   EVOLREG   -1.0
 102.543 +    BREGFCG   MVOLFCG   1.0
 102.544 +    BREGFCG   XLPRREG   -9.27
 102.545 +    BREGFCG   XHPRREG   -9.14
 102.546 +    BREGFCG   XTELREG   -3.0
 102.547 +    BREGFCG   XRVPREG   6.0
 102.548 +    BREGFCG   X200REG   0.318
 102.549 +    BREGFCG   X230REG   -0.509
 102.550 +    BREGFCG   EVOLREG   -1.0
 102.551 +    BREGNC4   MVOLNC4   1.0
 102.552 +    BREGNC4   XLPRREG   -9.78
 102.553 +    BREGNC4   XHPRREG   -9.79
 102.554 +    BREGNC4   XTELREG   -3.0
 102.555 +    BREGNC4   XRVPREG   66.0
 102.556 +    BREGNC4   X200REG   1.0
 102.557 +    BREGNC4   X230REG   -1.0
 102.558 +    BREGNC4   EVOLREG   -1.0
 102.559 +    BREGTEL   XLPRREG   -0.426
 102.560 +    BREGTEL   XHPRREG   -.204
 102.561 +    BREGTEL   XTELREG   1.0
 102.562 +    BREGTEL   PROFIT    -0.3696
 102.563 +    SELLREG   XLPRREG   9.05
 102.564 +    SELLREG   XHPRREG   9.05
 102.565 +    SELLREG   XRVPREG   -9.5
 102.566 +    SELLREG   X200REG   -0.5
 102.567 +    SELLREG   X230REG   0.5
 102.568 +    SELLREG   XPSCPRE   -0.36
 102.569 +    SELLREG   XRSCREG   -0.65
 102.570 +    SELLREG   EVOLREG   1.0
 102.571 +    SELLREG   PROFIT    18.04
 102.572 +    BRSDVBB   MVOLVBB   1.0
 102.573 +    BRSDVBB   EVOLRSD   -1.0
 102.574 +    BRSDVBB   XVISRSD   10.1
 102.575 +    BRSDVBC   MVOLVBC   1.0
 102.576 +    BRSDVBC   EVOLRSD   -1.0
 102.577 +    BRSDVBC   XVISRSD   12.63
 102.578 +    BRSDRCR   MVOLRCR   1.0
 102.579 +    BRSDRCR   EVOLRSD   -1.0
 102.580 +    BRSDRCR   XVISRSD   6.9
 102.581 +    BRSDHVO   MVOLHVO   1.0
 102.582 +    BRSDHVO   EVOLRSD   -1.0
 102.583 +    BRSDHVO   XVISRSD   8.05
 102.584 +    BRSDHVO   VCAPHVO   1.0
 102.585 +    BRSDSLR   MVOLSLR   1.0
 102.586 +    BRSDSLR   EVOLRSD   -1.0
 102.587 +    BRSDSLR   XVISRSD   8.05
 102.588 +    BRSDLCO   MVOLLCO   1.0
 102.589 +    BRSDLCO   EVOLRSD   -1.0
 102.590 +    BRSDLCO   XVISRSD   4.4
 102.591 +    SELLRSD   EVOLRSD   1.0
 102.592 +    SELLRSD   XVISRSD   -10.1
 102.593 +    SELLRSD   PROFIT    8.00
 102.594 +RHS
 102.595 +    LIMITMAX  MVOLBOL   26.316
 102.596 +    LIMITMAX  MVOLCOL   21.052
 102.597 +    LIMITMAX  VCAPSGP   23.25
 102.598 +    LIMITMAX  VCAPHVO   5.25
 102.599 +    LIMITMAX  VCAPRFG   13.455
 102.600 +    LIMITMAX  VCAPHOL   3.87
 102.601 +    LIMITMAX  VCAPCCU   7.26
 102.602 +    LIMITMAX  VCAPALK   10.
 102.603 +ENDATA
   103.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
   103.2 +++ b/deps/glpk/examples/mvcp.mod	Sun Nov 06 20:59:10 2011 +0100
   103.3 @@ -0,0 +1,43 @@
   103.4 +/* MVCP, Minimum Vertex Cover Problem */
   103.5 +
   103.6 +/* Written in GNU MathProg by Andrew Makhorin <mao@gnu.org> */
   103.7 +
   103.8 +/* The Minimum Vertex Cover Problem in a network G = (V, E), where V
   103.9 +   is a set of nodes, E is a set of arcs, is to find a subset V' within
  103.10 +   V such that each edge (i,j) in E has at least one its endpoint in V'
  103.11 +   and which minimizes the sum of node weights w(i) over V'.
  103.12 +
  103.13 +   Reference:
  103.14 +   Garey, M.R., and Johnson, D.S. (1979), Computers and Intractability:
  103.15 +   A guide to the theory of NP-completeness [Graph Theory, Covering and
  103.16 +   Partitioning, Minimum Vertex Cover, GT1]. */
  103.17 +
  103.18 +set E, dimen 2;
  103.19 +/* set of edges */
  103.20 +
  103.21 +set V := (setof{(i,j) in E} i) union (setof{(i,j) in E} j);
  103.22 +/* set of nodes */
  103.23 +
  103.24 +param w{i in V}, >= 0, default 1;
  103.25 +/* w[i] is weight of vertex i */
  103.26 +
  103.27 +var x{i in V}, binary;
  103.28 +/* x[i] = 1 means that node i is included into V' */
  103.29 +
  103.30 +s.t. cov{(i,j) in E}: x[i] + x[j] >= 1;
  103.31 +/* each edge (i,j) must have node i or j (or both) in V' */
  103.32 +
  103.33 +minimize z: sum{i in V} w[i] * x[i];
  103.34 +/* we need to minimize the sum of node weights over V' */
  103.35 +
  103.36 +data;
  103.37 +
  103.38 +/* These data correspond to an example from [Papadimitriou]. */
  103.39 +
  103.40 +/* Optimal solution is 6 (greedy heuristic gives 13) */
  103.41 +
  103.42 +set E := a1 b1, b1 c1, a1 b2, b2 c2, a2 b3, b3 c3, a2 b4, b4 c4, a3 b5,
  103.43 +         b5 c5, a3 b6, b6 c6, a4 b1, a4 b2, a4 b3, a5 b4, a5 b5, a5 b6,
  103.44 +         a6 b1, a6 b2, a6 b3, a6 b4, a7 b2, a7 b3, a7 b4, a7 b5, a7 b6;
  103.45 +
  103.46 +end;
   104.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
   104.2 +++ b/deps/glpk/examples/netgen.c	Sun Nov 06 20:59:10 2011 +0100
   104.3 @@ -0,0 +1,141 @@
   104.4 +/* netgen.c */
   104.5 +
   104.6 +/* This main program generates 50 original NETGEN instances of the
   104.7 +   minimum cost flow problem and writes them in DIMACS format to the
   104.8 +   current directory. */
   104.9 +
  104.10 +#include <stddef.h>
  104.11 +#include <stdio.h>
  104.12 +#include <stdlib.h>
  104.13 +#include <glpk.h>
  104.14 +
  104.15 +static int parm[50][15] =
  104.16 +{    {13502460, 101,
  104.17 +      5000, 2500, 2500, 25000, 1, 100, 250000, 0, 0, 0, 100, 1, 1000,
  104.18 +   },{4281922, 102,
  104.19 +      5000, 2500, 2500, 25000, 1, 100, 2500000, 0, 0, 0, 100, 1, 1000,
  104.20 +   },{44820113, 103,
  104.21 +      5000, 2500, 2500, 25000, 1, 100, 6250000, 0, 0, 0, 100, 1, 1000,
  104.22 +   },{13450451, 104,
  104.23 +      5000, 2500, 2500, 25000, -100, -1, 250000, 0, 0, 0, 100, 1, 1000,
  104.24 +   },{14719436, 105,
  104.25 +      5000, 2500, 2500, 25000, 101, 200, 250000, 0, 0, 0, 100, 1, 1000,
  104.26 +   },{17365786, 106,
  104.27 +      5000, 2500, 2500, 12500, 1, 100, 125000, 0, 0, 0, 100, 1, 1000,
  104.28 +   },{19540113, 107,
  104.29 +      5000, 2500, 2500, 37500, 1, 100, 375000, 0, 0, 0, 100, 1, 1000,
  104.30 +   },{19560313, 108,
  104.31 +      5000, 2500, 2500, 50000, 1, 100, 500000, 0, 0, 0, 100, 1, 1000,
  104.32 +   },{2403509, 109,
  104.33 +      5000, 2500, 2500, 75000, 1, 100, 750000, 0, 0, 0, 100, 1, 1000,
  104.34 +   },{92480414, 110,
  104.35 +      5000, 2500, 2500, 12500, 1, 100, 250000, 0, 0, 0, 100, 1, 1000,
  104.36 +   },{4230140, 111,
  104.37 +      5000, 2500, 2500, 37500, 1, 100, 250000, 0, 0, 0, 100, 1, 1000,
  104.38 +   },{10032490, 112,
  104.39 +      5000, 2500, 2500, 50000, 1, 100, 250000, 0, 0, 0, 100, 1, 1000,
  104.40 +   },{17307474, 113,
  104.41 +      5000, 2500, 2500, 75000, 1, 100, 250000, 0, 0, 0, 100, 1, 1000,
  104.42 +   },{4925114, 114,
  104.43 +      5000, 500, 4500, 25000, 1, 100, 250000, 0, 0, 0, 100, 1, 1000,
  104.44 +   },{19842704, 115,
  104.45 +      5000, 1500, 3500, 25000, 1, 100, 250000, 0, 0, 0, 100, 1, 1000,
  104.46 +   },{88392060, 116,
  104.47 +      5000, 2500, 2500, 25000, 1, 100, 250000, 0, 0, 0, 0, 1, 1000,
  104.48 +   },{12904407, 117,
  104.49 +      5000, 2500, 2500, 12500, 1, 100, 125000, 0, 0, 0, 0, 1, 1000,
  104.50 +   },{11811811, 118,
  104.51 +      5000, 2500, 2500, 37500, 1, 100, 375000, 0, 0, 0, 0, 1, 1000,
  104.52 +   },{90023593, 119,
  104.53 +      5000, 2500, 2500, 50000, 1, 100, 500000, 0, 0, 0, 0, 1, 1000,
  104.54 +   },{93028922, 120,
  104.55 +      5000, 2500, 2500, 75000, 1, 100, 750000, 0, 0, 0, 0, 1, 1000,
  104.56 +   },{72707401, 121,
  104.57 +      5000, 50, 50, 25000, 1, 100, 250000, 50, 50, 0, 100, 1, 1000,
  104.58 +   },{93040771, 122,
  104.59 +      5000, 250, 250, 25000, 1, 100, 250000, 250, 250, 0, 100, 1, 1000,
  104.60 +   },{70220611, 123,
  104.61 +      5000, 500, 500, 25000, 1, 100, 250000, 500, 500, 0, 100, 1, 1000,
  104.62 +   },{52774811, 124,
  104.63 +      5000, 1000, 1000, 25000, 1, 100, 250000, 1000, 1000, 0, 100, 1,
  104.64 +      1000,
  104.65 +   },{22492311, 125,
  104.66 +      5000, 1500, 1500, 25000, 1, 100, 250000, 1500, 1500, 0, 100, 1,
  104.67 +      1000,
  104.68 +   },{35269337, 126,
  104.69 +      5000, 500, 500, 12500, 1, 100, 125000, 500, 500, 0, 100, 1, 1000,
  104.70 +   },{30140502, 127,
  104.71 +      5000, 500, 500, 37500, 1, 100, 375000, 500, 500, 0, 100, 1, 1000,
  104.72 +   },{49205455, 128,
  104.73 +      5000, 500, 500, 50000, 1, 100, 500000, 500, 500, 0, 100, 1, 1000,
  104.74 +   },{42958341, 129,
  104.75 +      5000, 500, 500, 75000, 1, 100, 750000, 500, 500, 0, 100, 1, 1000,
  104.76 +   },{25440925, 130,
  104.77 +      5000, 500, 500, 12500, 1, 100, 250000, 500, 500, 0, 100, 1, 1000,
  104.78 +   },{75294924, 131,
  104.79 +      5000, 500, 500, 37500, 1, 100, 250000, 500, 500, 0, 100, 1, 1000,
  104.80 +   },{4463965, 132,
  104.81 +      5000, 500, 500, 50000, 1, 100, 250000, 500, 500, 0, 100, 1, 1000,
  104.82 +   },{13390427, 133,
  104.83 +      5000, 500, 500, 75000, 1, 100, 250000, 500, 500, 0, 100, 1, 1000,
  104.84 +   },{95250971, 134,
  104.85 +      1000, 500, 500, 25000, 1, 100, 250000, 500, 500, 0, 100, 1, 1000,
  104.86 +   },{54830522, 135,
  104.87 +      2500, 500, 500, 25000, 1, 100, 250000, 500, 500, 0, 100, 1, 1000,
  104.88 +   },{520593, 136,
  104.89 +      7500, 500, 500, 25000, 1, 100, 250000, 500, 500, 0, 100, 1, 1000,
  104.90 +   },{52900925, 137,
  104.91 +      10000, 500, 500, 25000, 1, 100, 250000, 500, 500, 0, 100, 1, 1000,
  104.92 +   },{22603395, 138,
  104.93 +      5000, 500, 500, 25000, 1, 100, 250000, 500, 500, 0, 100, 1, 50,
  104.94 +   },{55253099, 139,
  104.95 +      5000, 500, 500, 25000, 1, 100, 250000, 500, 500, 0, 100, 1, 250,
  104.96 +   },{75357001, 140,
  104.97 +      5000, 500, 500, 25000, 1, 100, 250000, 500, 500, 0, 100, 1, 500,
  104.98 +   },{10072459, 141,
  104.99 +      5000, 500, 500, 25000, 1, 100, 250000, 500, 500, 0, 100, 1, 2500,
 104.100 +   },{55728492, 142,
 104.101 +      5000, 500, 500, 25000, 1, 100, 250000, 500, 500, 0, 100, 1, 5000,
 104.102 +   },{593043, 143,
 104.103 +      5000, 500, 500, 25000, 1, 100, 250000, 500, 500, 0, 0, 1, 1000,
 104.104 +   },{94236572, 144,
 104.105 +      5000, 500, 500, 25000, 1, 10, 250000, 500, 500, 0, 100, 1, 1000,
 104.106 +   },{94882955, 145,
 104.107 +      5000, 500, 500, 25000, 1, 1000, 250000, 500, 500, 0, 100, 1, 1000,
 104.108 +   },{48489922, 146,
 104.109 +      5000, 500, 500, 25000, 1, 10000, 250000, 500, 500, 0, 100, 1,
 104.110 +      1000,
 104.111 +   },{75578374, 147,
 104.112 +      5000, 500, 500, 25000, -100, -1, 250000, 500, 500, 0, 100, 1,
 104.113 +      1000,
 104.114 +   },{44821152, 148,
 104.115 +      5000, 500, 500, 25000, -50, 49, 250000, 500, 500, 0, 100, 1, 1000,
 104.116 +   },{45224103, 149,
 104.117 +      5000, 500, 500, 25000, 101, 200, 250000, 500, 500, 0, 100, 1,
 104.118 +      1000,
 104.119 +   },{63491741, 150,
 104.120 +      5000, 500, 500, 25000, 1001, 1100, 250000, 500, 500, 0, 100, 1,
 104.121 +      1000,
 104.122 +   }
 104.123 +};
 104.124 +
 104.125 +typedef struct { double rhs; } v_data;
 104.126 +typedef struct { double cap, cost; } a_data;
 104.127 +
 104.128 +int main(void)
 104.129 +{     glp_graph *G;
 104.130 +      int k;
 104.131 +      char fname[100+1];
 104.132 +      G = glp_create_graph(sizeof(v_data), sizeof(a_data));
 104.133 +      for (k = 1; k <= 50; k++)
 104.134 +      {  sprintf(fname, "netgn%03d.min", parm[k-1][1]);
 104.135 +         glp_netgen(G, offsetof(v_data, rhs), offsetof(a_data, cap),
 104.136 +            offsetof(a_data, cost), &parm[k-1][-1]);
 104.137 +         glp_write_mincost(G, offsetof(v_data, rhs), -1,
 104.138 +            offsetof(a_data, cap), offsetof(a_data, cost), fname);
 104.139 +      }
 104.140 +      glp_delete_graph(G);
 104.141 +      return 0;
 104.142 +}
 104.143 +
 104.144 +/* eof */
   105.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
   105.2 +++ b/deps/glpk/examples/numbrix.mod	Sun Nov 06 20:59:10 2011 +0100
   105.3 @@ -0,0 +1,84 @@
   105.4 +/* Numbrix, Number Placement Puzzle */
   105.5 +
   105.6 +/* Written in GNU MathProg by Robert Wood <rwood@targus.com>  */
   105.7 +
   105.8 +/* Numbrix is a logic-based number-placement puzzle.[1]
   105.9 + * The objective is to fill the grid so that each cell contains
  105.10 + * digits in sequential order taking a horizontal or vertical
  105.11 + * path; diagonal paths are not allowed. The puzzle setter
  105.12 + * provides a grid often with the outer most cells completed.
  105.13 + *
  105.14 + * Completed Numbrix puzzles are usually a square of numbers
  105.15 + * in order from 1 to 64 (8x8 grid) or from 1 to 81 (9x9 grid),
  105.16 + * following a continuous path in sequence.
  105.17 + *
  105.18 + * The modern puzzle was invented by Marilyn vos Savant in 2008
  105.19 + * and published by Parade Magazine under the name "Numbrix",
  105.20 + * near her weekly Ask Marilyn article.
  105.21 + *
  105.22 + *    http://en.wikipedia.org/wiki/Numbrix  */
  105.23 +
  105.24 +set I := {1..9};
  105.25 +set J := {1..9};
  105.26 +set VALS := {1..81};
  105.27 +
  105.28 +param givens{I, J}, integer, >= 0, <= 81, default 0;
  105.29 +/* the "givens" */
  105.30 +
  105.31 +param neighbors{i in I,j in J, i2 in I, j2 in J} , binary :=
  105.32 +(if abs(i - i2) + abs(j -j2) == 1 then
  105.33 +     1
  105.34 + else
  105.35 +     0
  105.36 +);
  105.37 +/*  defines which spots are the boards are neighbors */
  105.38 +
  105.39 +var x{i in I, j in J, k in VALS}, binary;
  105.40 +/* x[i,j,k] = 1 means cell [i,j] is assigned number k */
  105.41 +
  105.42 +s.t. fa{i in I, j in J, k in VALS: givens[i,j] != 0}:
  105.43 +     x[i,j,k] = (if givens[i,j] = k then 1 else 0);
  105.44 +/* assign pre-defined numbers using the "givens" */
  105.45 +
  105.46 +s.t. fb{i in I, j in J}: sum{k in VALS} x[i,j,k] = 1;
  105.47 +/* each cell must be assigned exactly one number */
  105.48 +
  105.49 +s.t. singleNum {k in VALS}:  sum{i in I, j in J} x[i,j,k] = 1;
  105.50 +/*  a value can only occur once */
  105.51 +
  105.52 +s.t. neighborContraint {i in I, j in J, k in 1..80}:
  105.53 +        x[i,j,k] <= sum{i2 in I, j2 in J} x[i2,j2,k+1] * neighbors[i,j,i2,j2];
  105.54 +/* each cell must have a neighbor with the next higher value */
  105.55 +
  105.56 +
  105.57 +/* there is no need for an objective function here */
  105.58 +
  105.59 +
  105.60 +solve;
  105.61 +
  105.62 +for {i in I}
  105.63 +{  for {0..0: i = 1 or i = 4 or i = 7}
  105.64 +      printf " +----------+----------+----------+\n";
  105.65 +   for {j in J}
  105.66 +   {  for {0..0: j = 1 or j = 4 or j = 7} printf(" |");
  105.67 +      printf " %2d", sum{k in VALS} x[i,j,k] * k;
  105.68 +      for {0..0: j = 9} printf(" |\n");
  105.69 +   }
  105.70 +   for {0..0: i = 9}
  105.71 +      printf " +----------+----------+----------+\n";
  105.72 +}
  105.73 +
  105.74 +data;
  105.75 +
  105.76 +param givens : 1 2 3 4 5 6 7 8 9 :=
  105.77 +           1   . . . . . . . . .
  105.78 +           2   . 11 12 15 18 21 62 61 .
  105.79 +           3   .  6 . . . . . 60 .
  105.80 +           4   . 33 . . . . . 57 .
  105.81 +           5   . 32 . . . . . 56 .
  105.82 +           6   . 37 . . . . . 73 .
  105.83 +           7   . 38 . . . . . 72 .
  105.84 +           8   . 43 44 47 48 51 76 77 .
  105.85 +           9   . . . . . . . . . ;
  105.86 +
  105.87 +end;
   106.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
   106.2 +++ b/deps/glpk/examples/pbn/9dom.dat	Sun Nov 06 20:59:10 2011 +0100
   106.3 @@ -0,0 +1,65 @@
   106.4 +/* 9dom.dat */
   106.5 +
   106.6 +/***********************************************************************
   106.7 +*  Web Paint-by-Number Puzzle #8098 from <www.webpbn.com>.
   106.8 +*  Copyright (C) 2010 by Josh Greifer. Used by permission.
   106.9 +*
  106.10 +*  Domino Logic III (Abstract pattern)
  106.11 +*
  106.12 +*  created by Josh Greifer
  106.13 +*  Apr 5, 2010
  106.14 +*
  106.15 +*  Encoded in GNU MathProg by Andrew Makhorin <mao@gnu.org>.
  106.16 +***********************************************************************/
  106.17 +
  106.18 +data;
  106.19 +
  106.20 +param m := 19;
  106.21 +
  106.22 +param n := 19;
  106.23 +
  106.24 +param row : 1  2  :=
  106.25 +      1     3  .
  106.26 +      2     1  .
  106.27 +      3     3  1
  106.28 +      4     1  .
  106.29 +      5     3  1
  106.30 +      6     1  .
  106.31 +      7     3  1
  106.32 +      8     1  .
  106.33 +      9     3  1
  106.34 +      10    1  .
  106.35 +      11    3  1
  106.36 +      12    1  .
  106.37 +      13    3  1
  106.38 +      14    1  .
  106.39 +      15    3  1
  106.40 +      16    1  .
  106.41 +      17    3  1
  106.42 +      18    1  .
  106.43 +      19    1  .
  106.44 +;
  106.45 +
  106.46 +param col : 1  2  :=
  106.47 +      1     1  .
  106.48 +      2     1  .
  106.49 +      3     1  3
  106.50 +      4     1  .
  106.51 +      5     1  3
  106.52 +      6     1  .
  106.53 +      7     1  3
  106.54 +      8     1  .
  106.55 +      9     1  3
  106.56 +      10    1  .
  106.57 +      11    1  3
  106.58 +      12    1  .
  106.59 +      13    1  3
  106.60 +      14    1  .
  106.61 +      15    1  3
  106.62 +      16    1  .
  106.63 +      17    1  3
  106.64 +      18    1  .
  106.65 +      19    3  .
  106.66 +;
  106.67 +
  106.68 +end;
   107.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
   107.2 +++ b/deps/glpk/examples/pbn/README	Sun Nov 06 20:59:10 2011 +0100
   107.3 @@ -0,0 +1,6 @@
   107.4 +This subdirectory contains examples, which illustrate how to use
   107.5 +GLPK and the GNU MathProg modeling language for practical solving the
   107.6 +paint-by-numbers puzzle.
   107.7 +
   107.8 +For details please see the document "Solving Paint-By-Numbers Puzzles
   107.9 +with GLPK" included in this subdirectory (file pbn.pdf).
   108.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
   108.2 +++ b/deps/glpk/examples/pbn/bucks.dat	Sun Nov 06 20:59:10 2011 +0100
   108.3 @@ -0,0 +1,77 @@
   108.4 +/* bucks.dat */
   108.5 +
   108.6 +/***********************************************************************
   108.7 +*  Web Paint-by-Number Puzzle #27 from <www.webpbn.com>.
   108.8 +*  Copyright (C) 2004 by Jan Wolter. Used by permission.
   108.9 +*
  108.10 +*  Party at the Right [Political]
  108.11 +*
  108.12 +*  created by Jan Wolter
  108.13 +*  Apr 6, 2004
  108.14 +*
  108.15 +*  Encoded in GNU MathProg by Andrew Makhorin <mao@gnu.org>.
  108.16 +***********************************************************************/
  108.17 +
  108.18 +data;
  108.19 +
  108.20 +param m := 23;
  108.21 +
  108.22 +param n := 27;
  108.23 +
  108.24 +param row : 1  2  3  4  5  6  7  8  :=
  108.25 +      1     11 .  .  .  .  .  .  .
  108.26 +      2     17 .  .  .  .  .  .  .
  108.27 +      3     3  5  5  3  .  .  .  .
  108.28 +      4     2  2  2  1  .  .  .  .
  108.29 +      5     2  1  3  1  3  1  4  .
  108.30 +      6     3  3  3  3  .  .  .  .
  108.31 +      7     5  1  3  1  3  1  3  .
  108.32 +      8     3  2  2  4  .  .  .  .
  108.33 +      9     5  5  5  5  .  .  .  .
  108.34 +      10    23 .  .  .  .  .  .  .
  108.35 +      11    .  .  .  .  .  .  .  .
  108.36 +      12    23 .  .  .  .  .  .  .
  108.37 +      13    1  1  .  .  .  .  .  .
  108.38 +      14    1  1  .  .  .  .  .  .
  108.39 +      15    1  2  1  .  .  .  .  .
  108.40 +      16    1  1  1  1  .  .  .  .
  108.41 +      17    1  1  1  1  .  .  .  .
  108.42 +      18    1  10 1  2  1  .  .  .
  108.43 +      19    1  1  1  1  1  1  3  .
  108.44 +      20    1  1  1  1  1  1  1  1
  108.45 +      21    1  1  1  1  1  1  1  .
  108.46 +      22    1  1  1  1  2  2  .  .
  108.47 +      23    5  5  3  .  .  .  .  .
  108.48 +;
  108.49 +
  108.50 +param col : 1  2  3  4  5  6  :=
  108.51 +      1     4  12 .  .  .  .
  108.52 +      2     6  1  1  .  .  .
  108.53 +      3     8  1  1  .  .  .
  108.54 +      4     3  2  2  1  1  .
  108.55 +      5     2  1  1  2  1  6
  108.56 +      6     1  1  1  1  .  .
  108.57 +      7     3  1  1  2  1  1
  108.58 +      8     3  2  3  1  1  .
  108.59 +      9     10 1  1  .  .  .
  108.60 +      10    4  2  2  1  1  .
  108.61 +      11    3  1  1  2  1  1
  108.62 +      12    2  1  1  1  .  .
  108.63 +      13    3  1  1  2  1  1
  108.64 +      14    3  2  3  1  6  .
  108.65 +      15    10 1  1  .  .  .
  108.66 +      16    4  2  2  1  1  .
  108.67 +      17    3  1  1  2  1  1
  108.68 +      18    1  1  1  9  .  .
  108.69 +      19    2  1  1  2  1  1
  108.70 +      20    2  2  3  1  3  .
  108.71 +      21    8  1  5  .  .  .
  108.72 +      22    6  1  1  .  .  .
  108.73 +      23    4  9  1  .  .  .
  108.74 +      24    1  1  .  .  .  .
  108.75 +      25    2  1  .  .  .  .
  108.76 +      26    1  1  .  .  .  .
  108.77 +      27    4  .  .  .  .  .
  108.78 +;
  108.79 +
  108.80 +end;
   109.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
   109.2 +++ b/deps/glpk/examples/pbn/cat.dat	Sun Nov 06 20:59:10 2011 +0100
   109.3 @@ -0,0 +1,67 @@
   109.4 +/* cat.dat */
   109.5 +
   109.6 +/***********************************************************************
   109.7 +*  Web Paint-by-Number Puzzle #6 from <www.webpbn.com>.
   109.8 +*  Copyright (C) 2004 by Jan Wolter. Used by permission.
   109.9 +*
  109.10 +*  Scardy Cat
  109.11 +*
  109.12 +*  created by Jan Wolter
  109.13 +*  Mar 24, 2004
  109.14 +*
  109.15 +*  Encoded in GNU MathProg by Andrew Makhorin <mao@gnu.org>.
  109.16 +***********************************************************************/
  109.17 +
  109.18 +data;
  109.19 +
  109.20 +param m := 20;
  109.21 +
  109.22 +param n := 20;
  109.23 +
  109.24 +param row : 1  2  3  4  :=
  109.25 +      1     2  .  .  .
  109.26 +      2     2  .  .  .
  109.27 +      3     1  .  .  .
  109.28 +      4     1  .  .  .
  109.29 +      5     1  3  .  .
  109.30 +      6     2  5  .  .
  109.31 +      7     1  7  1  1
  109.32 +      8     1  8  2  2
  109.33 +      9     1  9  5  .
  109.34 +      10    2  16 .  .
  109.35 +      11    1  17 .  .
  109.36 +      12    7  11 .  .
  109.37 +      13    5  5  3  .
  109.38 +      14    5  4  .  .
  109.39 +      15    3  3  .  .
  109.40 +      16    2  2  .  .
  109.41 +      17    2  1  .  .
  109.42 +      18    1  1  .  .
  109.43 +      19    2  2  .  .
  109.44 +      20    2  2  .  .
  109.45 +;
  109.46 +
  109.47 +param col : 1  2  3  :=
  109.48 +      1     5  .  .
  109.49 +      2     5  3  .
  109.50 +      3     2  3  4
  109.51 +      4     1  7  2
  109.52 +      5     8  .  .
  109.53 +      6     9  .  .
  109.54 +      7     9  .  .
  109.55 +      8     8  .  .
  109.56 +      9     7  .  .
  109.57 +      10    8  .  .
  109.58 +      11    9  .  .
  109.59 +      12    10 .  .
  109.60 +      13    13 .  .
  109.61 +      14    6  2  .
  109.62 +      15    4  .  .
  109.63 +      16    6  .  .
  109.64 +      17    6  .  .
  109.65 +      18    5  .  .
  109.66 +      19    6  .  .
  109.67 +      20    6  .  .
  109.68 +;
  109.69 +
  109.70 +end;
   110.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
   110.2 +++ b/deps/glpk/examples/pbn/dancer.dat	Sun Nov 06 20:59:10 2011 +0100
   110.3 @@ -0,0 +1,42 @@
   110.4 +/* dancer.dat */
   110.5 +
   110.6 +/***********************************************************************
   110.7 +*  Web Paint-by-Number Puzzle #1 from <www.webpbn.com>.
   110.8 +*  Copyright (C) 2004 by Jan Wolter. Used by permission.
   110.9 +*
  110.10 +*  Demo Puzzle from Front Page
  110.11 +*
  110.12 +*  created by Jan Wolter
  110.13 +*  Mar 24, 2004
  110.14 +*
  110.15 +*  Encoded in GNU MathProg by Andrew Makhorin <mao@gnu.org>.
  110.16 +***********************************************************************/
  110.17 +
  110.18 +data;
  110.19 +
  110.20 +param m := 10;
  110.21 +
  110.22 +param n := 5;
  110.23 +
  110.24 +param row : 1  2  3  :=
  110.25 +      1     2  .  .
  110.26 +      2     2  1  .
  110.27 +      3     1  1  .
  110.28 +      4     3  .  .
  110.29 +      5     1  1  .
  110.30 +      6     1  1  .
  110.31 +      7     2  .  .
  110.32 +      8     1  1  .
  110.33 +      9     1  2  .
  110.34 +      10    2  .  .
  110.35 +;
  110.36 +
  110.37 +param col : 1  2  3  :=
  110.38 +      1     2  1  .
  110.39 +      2     2  1  3
  110.40 +      3     7  .  .
  110.41 +      4     1  3  .
  110.42 +      5     2  1  .
  110.43 +;
  110.44 +
  110.45 +end;
   111.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
   111.2 +++ b/deps/glpk/examples/pbn/dragon.dat	Sun Nov 06 20:59:10 2011 +0100
   111.3 @@ -0,0 +1,61 @@
   111.4 +/* dragon.dat */
   111.5 +
   111.6 +/***********************************************************************
   111.7 +*  Hard 20x20 paint-by-numbers puzzle designed by Won Yoon Jo
   111.8 +*  from the article "Painting by Numbers" by Robert A. Bosch (2000),
   111.9 +*  <http://www.oberlin.edu/~math/faculty/bosch/pbn-page.html>.
  111.10 +*
  111.11 +*  Encoded in GNU MathProg by Andrew Makhorin <mao@gnu.org>.
  111.12 +***********************************************************************/
  111.13 +
  111.14 +data;
  111.15 +
  111.16 +param m := 20;
  111.17 +
  111.18 +param n := 20;
  111.19 +
  111.20 +param row :    1  2  3  4  5 :=
  111.21 +          1    7  1  .  .  .
  111.22 +          2    1  1  2  .  .
  111.23 +          3    2  1  2  .  .
  111.24 +          4    1  2  2  .  .
  111.25 +          5    4  2  3  .  .
  111.26 +          6    3  1  4  .  .
  111.27 +          7    3  1  3  .  .
  111.28 +          8    2  1  4  .  .
  111.29 +          9    2  9  .  .  .
  111.30 +          10   2  1  5  .  .
  111.31 +          11   2  7  .  .  .
  111.32 +          12   14 .  .  .  .
  111.33 +          13   8  2  .  .  .
  111.34 +          14   6  2  2  .  .
  111.35 +          15   2  8  1  3  .
  111.36 +          16   1  5  5  2  .
  111.37 +          17   1  3  2  4  1
  111.38 +          18   3  1  2  4  1
  111.39 +          19   1  1  3  1  3
  111.40 +          20   2  1  1  2  . ;
  111.41 +
  111.42 +param col :    1  2  3  4  5 :=
  111.43 +          1    1  1  1  2  .
  111.44 +          2    3  1  2  1  1
  111.45 +          3    1  4  2  1  1
  111.46 +          4    1  3  2  4  .
  111.47 +          5    1  4  6  1  .
  111.48 +          6    1  11 1  .  .
  111.49 +          7    5  1  6  2  .
  111.50 +          8    14 .  .  .  .
  111.51 +          9    7  2  .  .  .
  111.52 +          10   7  2  .  .  .
  111.53 +          11   6  1  1  .  .
  111.54 +          12   9  2  .  .  .
  111.55 +          13   3  1  1  1  .
  111.56 +          14   3  1  3  .  .
  111.57 +          15   2  1  3  .  .
  111.58 +          16   2  1  5  .  .
  111.59 +          17   3  2  2  .  .
  111.60 +          18   3  3  2  .  .
  111.61 +          19   2  3  2  .  .
  111.62 +          20   2  6  .  .  . ;
  111.63 +
  111.64 +end;
   112.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
   112.2 +++ b/deps/glpk/examples/pbn/edge.dat	Sun Nov 06 20:59:10 2011 +0100
   112.3 @@ -0,0 +1,48 @@
   112.4 +/* edge.dat */
   112.5 +
   112.6 +/***********************************************************************
   112.7 +*  Web Paint-by-Number Puzzle #23 from <www.webpbn.com>.
   112.8 +*  Copyright (C) 2004 by Jan Wolter. Used by permission.
   112.9 +*
  112.10 +*  Nonrepresentational Test Pattern
  112.11 +*
  112.12 +*  created by Jan Wolter
  112.13 +*  Apr 5, 2004
  112.14 +*
  112.15 +*  Encoded in GNU MathProg by Andrew Makhorin <mao@gnu.org>.
  112.16 +***********************************************************************/
  112.17 +
  112.18 +data;
  112.19 +
  112.20 +param m := 11;
  112.21 +
  112.22 +param n := 10;
  112.23 +
  112.24 +param row : 1  :=
  112.25 +      1     1
  112.26 +      2     3
  112.27 +      3     1
  112.28 +      4     2
  112.29 +      5     1
  112.30 +      6     3
  112.31 +      7     3
  112.32 +      8     1
  112.33 +      9     2
  112.34 +      10    2
  112.35 +      11    4
  112.36 +;
  112.37 +
  112.38 +param col : 1  2  :=
  112.39 +      1     1  .
  112.40 +      2     3  .
  112.41 +      3     1  .
  112.42 +      4     2  2
  112.43 +      5     2  .
  112.44 +      6     4  .
  112.45 +      7     1  .
  112.46 +      8     3  .
  112.47 +      9     3  .
  112.48 +      10    1  .
  112.49 +;
  112.50 +
  112.51 +end;
   113.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
   113.2 +++ b/deps/glpk/examples/pbn/forever.dat	Sun Nov 06 20:59:10 2011 +0100
   113.3 @@ -0,0 +1,77 @@
   113.4 +/* forever.dat */
   113.5 +
   113.6 +/***********************************************************************
   113.7 +*  Web Paint-by-Number Puzzle #6574 from <www.webpbn.com>.
   113.8 +*  Copyright (C) 2009 by Gator. Used by permission.
   113.9 +*
  113.10 +*  Lasts Forever
  113.11 +*
  113.12 +*  created by Gator
  113.13 +*  Aug 24, 2009
  113.14 +*
  113.15 +*  Encoded in GNU MathProg by Andrew Makhorin <mao@gnu.org>.
  113.16 +***********************************************************************/
  113.17 +
  113.18 +data;
  113.19 +
  113.20 +param m := 25;
  113.21 +
  113.22 +param n := 25;
  113.23 +
  113.24 +param row : 1  2  3  4  5  6  7  8  :=
  113.25 +      1     1  2  2  2  2  2  1  .
  113.26 +      2     1  2  2  2  2  2  1  1
  113.27 +      3     1  1  .  .  .  .  .  .
  113.28 +      4     1  1  .  .  .  .  .  .
  113.29 +      5     1  3  1  .  .  .  .  .
  113.30 +      6     1  13 1  .  .  .  .  .
  113.31 +      7     1  13 1  .  .  .  .  .
  113.32 +      8     1  13 1  .  .  .  .  .
  113.33 +      9     1  4  4  1  .  .  .  .
  113.34 +      10    1  4  3  4  1  .  .  .
  113.35 +      11    1  4  5  4  1  .  .  .
  113.36 +      12    1  7  1  .  .  .  .  .
  113.37 +      13    1  7  1  .  .  .  .  .
  113.38 +      14    1  7  1  .  .  .  .  .
  113.39 +      15    1  7  1  .  .  .  .  .
  113.40 +      16    1  1  5  1  .  .  .  .
  113.41 +      17    1  2  6  1  .  .  .  .
  113.42 +      18    1  4  6  1  .  .  .  .
  113.43 +      19    1  6  6  1  .  .  .  .
  113.44 +      20    1  3  1  .  .  .  .  .
  113.45 +      21    1  1  1  .  .  .  .  .
  113.46 +      22    1  1  .  .  .  .  .  .
  113.47 +      23    1  1  .  .  .  .  .  .
  113.48 +      24    1  1  2  2  2  2  2  1
  113.49 +      25    1  2  2  2  2  2  1  .
  113.50 +;
  113.51 +
  113.52 +param col : 1  2  3  4  5  6  7  8  :=
  113.53 +      1     1  2  2  2  2  2  1  .
  113.54 +      2     1  1  2  2  2  2  2  1
  113.55 +      3     1  1  .  .  .  .  .  .
  113.56 +      4     1  1  .  .  .  .  .  .
  113.57 +      5     1  1  .  .  .  .  .  .
  113.58 +      6     1  2  1  .  .  .  .  .
  113.59 +      7     1  6  1  1  .  .  .  .
  113.60 +      8     1  6  2  1  .  .  .  .
  113.61 +      9     1  6  3  1  .  .  .  .
  113.62 +      10    1  4  8  1  .  .  .  .
  113.63 +      11    1  3  5  2  1  .  .  .
  113.64 +      12    1  4  8  2  1  .  .  .
  113.65 +      13    1  4  9  2  1  .  .  .
  113.66 +      14    1  4  11 1  .  .  .  .
  113.67 +      15    1  3  9  1  .  .  .  .
  113.68 +      16    1  4  8  1  .  .  .  .
  113.69 +      17    1  6  3  1  .  .  .  .
  113.70 +      18    1  6  2  1  .  .  .  .
  113.71 +      19    1  6  1  1  .  .  .  .
  113.72 +      20    1  2  1  .  .  .  .  .
  113.73 +      21    1  1  .  .  .  .  .  .
  113.74 +      22    1  1  .  .  .  .  .  .
  113.75 +      23    1  1  .  .  .  .  .  .
  113.76 +      24    1  2  2  2  2  2  1  1
  113.77 +      25    1  2  2  2  2  2  1  .
  113.78 +;
  113.79 +
  113.80 +end;
   114.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
   114.2 +++ b/deps/glpk/examples/pbn/knot.dat	Sun Nov 06 20:59:10 2011 +0100
   114.3 @@ -0,0 +1,95 @@
   114.4 +/* knot.dat */
   114.5 +
   114.6 +/***********************************************************************
   114.7 +*  Web Paint-by-Number Puzzle #16 from <www.webpbn.com>.
   114.8 +*  Copyright (C) 2004 by Jan Wolter. Used by permission.
   114.9 +*
  114.10 +*  Probably Not
  114.11 +*
  114.12 +*  created by Jan Wolter
  114.13 +*  Mar 27, 2004
  114.14 +*
  114.15 +*  Encoded in GNU MathProg by Andrew Makhorin <mao@gnu.org>.
  114.16 +***********************************************************************/
  114.17 +
  114.18 +data;
  114.19 +
  114.20 +param m := 34;
  114.21 +
  114.22 +param n := 34;
  114.23 +
  114.24 +param row : 1  2  3  4  5  6  7  8 :=
  114.25 +      1     1  1  .  .  .  .  .  .
  114.26 +      2     2  2  .  .  .  .  .  .
  114.27 +      3     3  3  .  .  .  .  .  .
  114.28 +      4     2  1  1  2  .  .  .  .
  114.29 +      5     2  1  1  2  .  .  .  .
  114.30 +      6     1  1  1  1  .  .  .  .
  114.31 +      7     1  1  1  1  .  .  .  .
  114.32 +      8     18 .  .  .  .  .  .  .
  114.33 +      9     2  1  1  1  1  2  .  .
  114.34 +      10    1  1  1  1  1  1  .  .
  114.35 +      11    1  1  1  1  1  1  .  .
  114.36 +      12    26 .  .  .  .  .  .  .
  114.37 +      13    2  1  1  1  1  1  1  2
  114.38 +      14    2  1  1  2  2  1  1  2
  114.39 +      15    2  1  1  2  2  1  1  2
  114.40 +      16    14 14 .  .  .  .  .  .
  114.41 +      17    1  1  1  1  .  .  .  .
  114.42 +      18    1  1  1  1  .  .  .  .
  114.43 +      19    14 14 .  .  .  .  .  .
  114.44 +      20    2  1  1  2  2  1  1  2
  114.45 +      21    2  1  1  2  2  1  1  2
  114.46 +      22    2  1  1  1  1  1  1  2
  114.47 +      23    26 .  .  .  .  .  .  .
  114.48 +      24    1  1  1  1  1  1  .  .
  114.49 +      25    1  1  1  1  1  1  .  .
  114.50 +      26    2  1  1  1  1  2  .  .
  114.51 +      27    18 .  .  .  .  .  .  .
  114.52 +      28    1  1  1  1  .  .  .  .
  114.53 +      29    1  1  1  1  .  .  .  .
  114.54 +      30    2  1  1  2  .  .  .  .
  114.55 +      31    2  1  1  2  .  .  .  .
  114.56 +      32    3  3  .  .  .  .  .  .
  114.57 +      33    2  2  .  .  .  .  .  .
  114.58 +      34    1  1  .  .  .  .  .  .
  114.59 +;
  114.60 +
  114.61 +param col : 1  2  3  4  5  6  7  8 :=
  114.62 +      1     1  1  .  .  .  .  .  .
  114.63 +      2     2  2  .  .  .  .  .  .
  114.64 +      3     3  3  .  .  .  .  .  .
  114.65 +      4     2  1  1  2  .  .  .  .
  114.66 +      5     2  1  1  2  .  .  .  .
  114.67 +      6     1  1  1  1  .  .  .  .
  114.68 +      7     1  1  1  1  .  .  .  .
  114.69 +      8     18 .  .  .  .  .  .  .
  114.70 +      9     2  1  1  1  1  2  .  .
  114.71 +      10    1  1  1  1  1  1  .  .
  114.72 +      11    1  1  1  1  1  1  .  .
  114.73 +      12    26 .  .  .  .  .  .  .
  114.74 +      13    2  1  1  1  1  1  1  2
  114.75 +      14    2  1  1  2  2  1  1  2
  114.76 +      15    2  1  1  2  2  1  1  2
  114.77 +      16    14 14 .  .  .  .  .  .
  114.78 +      17    1  1  1  1  .  .  .  .
  114.79 +      18    1  1  1  1  .  .  .  .
  114.80 +      19    14 14 .  .  .  .  .  .
  114.81 +      20    2  1  1  2  2  1  1  2
  114.82 +      21    2  1  1  2  2  1  1  2
  114.83 +      22    2  1  1  1  1  1  1  2
  114.84 +      23    26 .  .  .  .  .  .  .
  114.85 +      24    1  1  1  1  1  1  .  .
  114.86 +      25    1  1  1  1  1  1  .  .
  114.87 +      26    2  1  1  1  1  2  .  .
  114.88 +      27    18 .  .  .  .  .  .  .
  114.89 +      28    1  1  1  1  .  .  .  .
  114.90 +      29    1  1  1  1  .  .  .  .
  114.91 +      30    2  1  1  2  .  .  .  .
  114.92 +      31    2  1  1  2  .  .  .  .
  114.93 +      32    3  3  .  .  .  .  .  .
  114.94 +      33    2  2  .  .  .  .  .  .
  114.95 +      34    1  1  .  .  .  .  .  .
  114.96 +;
  114.97 +
  114.98 +end;
   115.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
   115.2 +++ b/deps/glpk/examples/pbn/light.dat	Sun Nov 06 20:59:10 2011 +0100
   115.3 @@ -0,0 +1,122 @@
   115.4 +/* light.dat */
   115.5 +
   115.6 +/***********************************************************************
   115.7 +*  Web Paint-by-Number Puzzle #803 from <www.webpbn.com>.
   115.8 +*  Copyright (C) 2007 by Robert Kummerfeldt. Used by permission.
   115.9 +*
  115.10 +*  You light up my life
  115.11 +*
  115.12 +*  created by Robert Kummerfeldt
  115.13 +*  Mar 15, 2007
  115.14 +*
  115.15 +*  Encoded in GNU MathProg by Andrew Makhorin <mao@gnu.org>.
  115.16 +***********************************************************************/
  115.17 +
  115.18 +data;
  115.19 +
  115.20 +param m := 45;
  115.21 +
  115.22 +param n := 50;
  115.23 +
  115.24 +param row : 1  2  3  4  :=
  115.25 +      1     .  .  .  .
  115.26 +      2     1  .  .  .
  115.27 +      3     1  .  .  .
  115.28 +      4     3  .  .  .
  115.29 +      5     2  2  .  .
  115.30 +      6     1  1  .  .
  115.31 +      7     7  .  .  .
  115.32 +      8     1  1  .  .
  115.33 +      9     1  3  1  .
  115.34 +      10    1  3  1  .
  115.35 +      11    1  1  .  .
  115.36 +      12    11 .  .  .
  115.37 +      13    1  1  .  .
  115.38 +      14    1  1  .  .
  115.39 +      15    2  2  .  .
  115.40 +      16    1  1  .  .
  115.41 +      17    1  1  .  .
  115.42 +      18    1  1  .  .
  115.43 +      19    1  1  .  .
  115.44 +      20    2  2  .  .
  115.45 +      21    1  1  .  .
  115.46 +      22    1  1  .  .
  115.47 +      23    1  1  .  .
  115.48 +      24    1  1  .  .
  115.49 +      25    1  1  .  .
  115.50 +      26    1  1  .  .
  115.51 +      27    1  1  .  .
  115.52 +      28    1  1  .  .
  115.53 +      29    1  1  .  .
  115.54 +      30    1  1  .  .
  115.55 +      31    2  2  .  .
  115.56 +      32    1  1  .  .
  115.57 +      33    1  1  .  .
  115.58 +      34    1  1  .  .
  115.59 +      35    1  1  .  .
  115.60 +      36    1  1  .  .
  115.61 +      37    1  4  1  .
  115.62 +      38    1  1  1  1
  115.63 +      39    1  1  1  1
  115.64 +      40    1  1  1  1
  115.65 +      41    1  1  1  1
  115.66 +      42    25 .  .  .
  115.67 +      43    6  5  .  .
  115.68 +      44    5  6  .  .
  115.69 +      45    4  5  .  .
  115.70 +;
  115.71 +
  115.72 +param col : 1  2  3  4  5  :=
  115.73 +      1     1  .  .  .  .
  115.74 +      2     1  .  .  .  .
  115.75 +      3     1  .  .  .  .
  115.76 +      4     2  .  .  .  .
  115.77 +      5     1  .  .  .  .
  115.78 +      6     1  .  .  .  .
  115.79 +      7     1  .  .  .  .
  115.80 +      8     2  .  .  .  .
  115.81 +      9     1  .  .  .  .
  115.82 +      10    1  .  .  .  .
  115.83 +      11    1  .  .  .  .
  115.84 +      12    1  .  .  .  .
  115.85 +      13    2  .  .  .  .
  115.86 +      14    1  .  .  .  .
  115.87 +      15    1  .  .  .  .
  115.88 +      16    1  .  .  .  .
  115.89 +      17    5  .  .  .  .
  115.90 +      18    7  1  .  .  .
  115.91 +      19    6  1  .  .  .
  115.92 +      20    6  1  .  .  .
  115.93 +      21    1  6  1  .  .
  115.94 +      22    4  1  .  .  .
  115.95 +      23    7  1  .  .  .
  115.96 +      24    1  1  1  1  .
  115.97 +      25    2  1  2  1  1
  115.98 +      26    3  1  2  1  1
  115.99 +      27    2  1  2  1  1
 115.100 +      28    1  1  1  1  .
 115.101 +      29    7  6  .  .  .
 115.102 +      30    4  1  1  .  .
 115.103 +      31    1  6  1  1  .
 115.104 +      32    6  6  .  .  .
 115.105 +      33    6  1  .  .  .
 115.106 +      34    5  1  .  .  .
 115.107 +      35    7  .  .  .  .
 115.108 +      36    1  .  .  .  .
 115.109 +      37    2  .  .  .  .
 115.110 +      38    1  .  .  .  .
 115.111 +      39    1  .  .  .  .
 115.112 +      40    1  .  .  .  .
 115.113 +      41    2  .  .  .  .
 115.114 +      42    1  .  .  .  .
 115.115 +      43    1  .  .  .  .
 115.116 +      44    1  .  .  .  .
 115.117 +      45    1  .  .  .  .
 115.118 +      46    2  .  .  .  .
 115.119 +      47    1  .  .  .  .
 115.120 +      48    1  .  .  .  .
 115.121 +      49    1  .  .  .  .
 115.122 +      50    1  .  .  .  .
 115.123 +;
 115.124 +
 115.125 +end;
   116.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
   116.2 +++ b/deps/glpk/examples/pbn/mum.dat	Sun Nov 06 20:59:10 2011 +0100
   116.3 @@ -0,0 +1,101 @@
   116.4 +/* mum.dat */
   116.5 +
   116.6 +/***********************************************************************
   116.7 +*  Web Paint-by-Number Puzzle #65 from <www.webpbn.com>.
   116.8 +*  Copyright (C) 2004 by Jan Wolter. Used by permission.
   116.9 +*
  116.10 +*  Mum's the Word [has only one solution]
  116.11 +*
  116.12 +*  created by Jan Wolter
  116.13 +*  Jul 10, 2004
  116.14 +*
  116.15 +*  Encoded in GNU MathProg by Andrew Makhorin <mao@gnu.org>.
  116.16 +***********************************************************************/
  116.17 +
  116.18 +data;
  116.19 +
  116.20 +param m := 40;
  116.21 +
  116.22 +param n := 34;
  116.23 +
  116.24 +param row : 1  2  3  4  5  6  7  8  9  :=
  116.25 +      1     12 .  .  .  .  .  .  .  .
  116.26 +      2     5  2  5  .  .  .  .  .  .
  116.27 +      3     5  2  2  5  .  .  .  .  .
  116.28 +      4     1  2  2  2  2  2  1  .  .
  116.29 +      5     4  2  2  4  2  2  4  .  .
  116.30 +      6     4  2  2  4  2  2  4  .  .
  116.31 +      7     1  2  2  2  2  2  1  .  .
  116.32 +      8     6  2  2  2  2  2  6  .  .
  116.33 +      9     6  2  2  2  2  2  6  .  .
  116.34 +      10    1  14 1  .  .  .  .  .  .
  116.35 +      11    10 10 .  .  .  .  .  .  .
  116.36 +      12    8  3  3  8  .  .  .  .  .
  116.37 +      13    1  1  2  1  1  2  1  1  .
  116.38 +      14    9  2  2  2  2  9  .  .  .
  116.39 +      15    9  9  .  .  .  .  .  .  .
  116.40 +      16    1  1  1  1  1  1  .  .  .
  116.41 +      17    12 2  12 .  .  .  .  .  .
  116.42 +      18    12 12 .  .  .  .  .  .  .
  116.43 +      19    1  1  4  1  1  .  .  .  .
  116.44 +      20    14 14 .  .  .  .  .  .  .
  116.45 +      21    12 12 .  .  .  .  .  .  .
  116.46 +      22    2  1  4  1  2  .  .  .  .
  116.47 +      23    9  4  9  .  .  .  .  .  .
  116.48 +      24    1  7  4  7  1  .  .  .  .
  116.49 +      25    1  1  1  4  1  1  1  .  .
  116.50 +      26    1  7  4  7  1  .  .  .  .
  116.51 +      27    1  7  4  7  1  .  .  .  .
  116.52 +      28    1  2  1  2  1  2  1  .  .
  116.53 +      29    1  7  2  7  1  .  .  .  .
  116.54 +      30    1  1  6  2  6  1  1  .  .
  116.55 +      31    1  1  1  1  2  1  1  1  1
  116.56 +      32    1  1  6  2  6  1  1  .  .
  116.57 +      33    1  1  5  5  1  1  .  .  .
  116.58 +      34    1  1  1  8  1  1  1  .  .
  116.59 +      35    1  1  4  4  1  1  .  .  .
  116.60 +      36    1  2  6  2  1  .  .  .  .
  116.61 +      37    2  4  4  2  .  .  .  .  .
  116.62 +      38    2  6  2  .  .  .  .  .  .
  116.63 +      39    4  4  .  .  .  .  .  .  .
  116.64 +      40    6  .  .  .  .  .  .  .  .
  116.65 +;
  116.66 +
  116.67 +param col : 1  2  3  4  5  6  7  8  9  10 11 12 :=
  116.68 +      1     5  .  .  .  .  .  .  .  .  .  .  .
  116.69 +      2     3  2  1  .  .  .  .  .  .  .  .  .
  116.70 +      3     3  2  2  1  .  .  .  .  .  .  .  .
  116.71 +      4     3  2  2  2  2  .  .  .  .  .  .  .
  116.72 +      5     3  2  2  2  2  3  .  .  .  .  .  .
  116.73 +      6     1  2  2  2  2  2  16 .  .  .  .  .
  116.74 +      7     1  2  2  2  2  2  2  1  2  .  .  .
  116.75 +      8     1  2  2  2  2  2  2  13 1  .  .  .
  116.76 +      9     3  2  2  2  2  2  2  4  1  1  .  .
  116.77 +      10    6  5  2  2  2  2  6  1  1  .  .  .
  116.78 +      11    1  7  3  2  2  2  2  2  1  1  1  .
  116.79 +      12    3  4  1  2  2  2  2  2  2  1  1  1
  116.80 +      13    6  1  2  3  2  2  2  2  1  1  1  .
  116.81 +      14    1  7  2  16 1  1  .  .  .  .  .  .
  116.82 +      15    1  4  1  1  1  1  1  1  1  1  1  .
  116.83 +      16    1  2  1  3  1  1  6  1  1  1  1  .
  116.84 +      17    2  7  1  1  11 1  1  1  1  .  .  .
  116.85 +      18    2  7  1  1  11 1  1  1  1  .  .  .
  116.86 +      19    1  2  1  3  1  1  6  1  1  1  1  .
  116.87 +      20    1  4  1  1  1  1  1  1  1  1  1  .
  116.88 +      21    1  7  2  16 1  1  .  .  .  .  .  .
  116.89 +      22    6  1  2  3  2  2  2  2  1  1  1  .
  116.90 +      23    3  4  1  2  2  2  2  2  2  1  1  1
  116.91 +      24    1  7  3  2  2  2  2  2  1  1  1  .
  116.92 +      25    6  5  2  2  2  2  6  1  1  .  .  .
  116.93 +      26    3  2  2  2  2  2  2  4  1  1  .  .
  116.94 +      27    1  2  2  2  2  2  2  13 1  .  .  .
  116.95 +      28    1  2  2  2  2  2  2  1  2  .  .  .
  116.96 +      29    1  2  2  2  2  2  16 .  .  .  .  .
  116.97 +      30    3  2  2  2  2  3  .  .  .  .  .  .
  116.98 +      31    3  2  2  2  2  .  .  .  .  .  .  .
  116.99 +      32    3  2  2  1  .  .  .  .  .  .  .  .
 116.100 +      33    3  2  1  .  .  .  .  .  .  .  .  .
 116.101 +      34    5  .  .  .  .  .  .  .  .  .  .  .
 116.102 +;
 116.103 +
 116.104 +end;
   117.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
   117.2 +++ b/deps/glpk/examples/pbn/pbn.mod	Sun Nov 06 20:59:10 2011 +0100
   117.3 @@ -0,0 +1,268 @@
   117.4 +/* PBN, Paint-By-Numbers Puzzle */
   117.5 +
   117.6 +/* Written in GNU MathProg by Andrew Makhorin <mao@gnu.org> */
   117.7 +
   117.8 +/* NOTE: See also the document "Solving Paint-By-Numbers Puzzles with
   117.9 +         GLPK", which is included in the GLPK distribution. */
  117.10 +
  117.11 +/* A paint-by-numbers puzzle consists of an m*n grid of pixels (the
  117.12 +   canvas) together with m+n cluster-size sequences, one for each row
  117.13 +   and column. The goal is to paint the canvas with a picture that
  117.14 +   satisfies the following constraints:
  117.15 +
  117.16 +   1. Each pixel must be blank or white.
  117.17 +
  117.18 +   2. If a row or column has cluster-size sequence s1, s2, ..., sk,
  117.19 +      then it must contain k clusters of black pixels - the first with
  117.20 +      s1 black pixels, the second with s2 black pixels, and so on.
  117.21 +
  117.22 +   It should be noted that "first" means "leftmost" for rows and
  117.23 +   "topmost" for columns, and that rows and columns need not begin or
  117.24 +   end with black pixels.
  117.25 +
  117.26 +   Example:
  117.27 +                  1   1
  117.28 +                  1   1
  117.29 +              2 1 1 1 1 1 2 3
  117.30 +              3 2 1 2 1 2 3 4 8 9
  117.31 +
  117.32 +        3 6   # # # . # # # # # #
  117.33 +        1 4   # . . . . . # # # #
  117.34 +      1 1 3   . . # . # . . # # #
  117.35 +          2   . . . . . . . . # #
  117.36 +        3 3   . . # # # . . # # #
  117.37 +        1 4   # . . . . . # # # #
  117.38 +        2 5   # # . . . # # # # #
  117.39 +        2 5   # # . . . # # # # #
  117.40 +        1 1   . . . # . . . . . #
  117.41 +          3   . . # # # . . . . .
  117.42 +
  117.43 +   (In Russia such puzzles are known as "Japanese crosswords".)
  117.44 +
  117.45 +   References:
  117.46 +   Robert A. Bosch, "Painting by Numbers", 2000.
  117.47 +   <http://www.oberlin.edu/~math/faculty/bosch/pbn-page.html> */
  117.48 +
  117.49 +/*--------------------------------------------------------------------*/
  117.50 +/* Main part based on the formulation proposed by Robert Bosch. */
  117.51 +
  117.52 +param m, integer, >= 1;
  117.53 +/* the number of rows */
  117.54 +
  117.55 +param n, integer, >= 1;
  117.56 +/* the number of columns */
  117.57 +
  117.58 +param row{i in 1..m, 1..n div 2}, integer, >= 0, default 0;
  117.59 +/* the cluster-size sequence for row i (raw data) */
  117.60 +
  117.61 +param col{j in 1..n, 1..m div 2}, integer, >= 0, default 0;
  117.62 +/* the cluster-size sequence for column j (raw data) */
  117.63 +
  117.64 +param kr{i in 1..m} := sum{t in 1..n div 2: row[i,t] > 0} 1;
  117.65 +/* the number of clusters in row i */
  117.66 +
  117.67 +param kc{j in 1..n} := sum{t in 1..m div 2: col[j,t] > 0} 1;
  117.68 +/* the number of clusters in column j */
  117.69 +
  117.70 +param sr{i in 1..m, t in 1..kr[i]} := row[i,t], integer, >= 1;
  117.71 +/* the cluster-size sequence for row i */
  117.72 +
  117.73 +param sc{j in 1..n, t in 1..kc[j]} := col[j,t], integer, >= 1;
  117.74 +/* the cluster-size sequence for column j */
  117.75 +
  117.76 +check{i in 1..m}: sum{t in 1..kr[i]} sr[i,t] <= n - (kr[i] - 1);
  117.77 +/* check that the sum of the cluster sizes in each row is valid */
  117.78 +
  117.79 +check{j in 1..n}: sum{t in 1..kc[j]} sc[j,t] <= m - (kc[j] - 1);
  117.80 +/* check that the sum of the cluster sizes in each column is valid */
  117.81 +
  117.82 +check: sum{i in 1..m, t in 1..kr[i]} sr[i,t] =
  117.83 +       sum{j in 1..n, t in 1..kc[j]} sc[j,t];
  117.84 +/* check that the sum of the cluster sizes in all rows is equal to the
  117.85 +   sum of the cluster sizes in all columns */
  117.86 +
  117.87 +param er{i in 1..m, t in 1..kr[i]} :=
  117.88 +   if t = 1 then 1 else er[i,t-1] + sr[i,t-1] + 1;
  117.89 +/* the smallest value of j such that row i's t-th cluster can be
  117.90 +   placed in row i with its leftmost pixel occupying pixel j */
  117.91 +
  117.92 +param lr{i in 1..m, t in 1..kr[i]} :=
  117.93 +   if t = kr[i] then n + 1 - sr[i,t] else lr[i,t+1] - sr[i,t] - 1;
  117.94 +/* the largest value of j such that row i's t-th cluster can be
  117.95 +   placed in row i with its leftmost pixel occupying pixel j */
  117.96 +
  117.97 +param ec{j in 1..n, t in 1..kc[j]} :=
  117.98 +   if t = 1 then 1 else ec[j,t-1] + sc[j,t-1] + 1;
  117.99 +/* the smallest value of i such that column j's t-th cluster can be
 117.100 +   placed in column j with its topmost pixel occupying pixel i */
 117.101 +
 117.102 +param lc{j in 1..n, t in 1..kc[j]} :=
 117.103 +   if t = kc[j] then m + 1 - sc[j,t] else lc[j,t+1] - sc[j,t] - 1;
 117.104 +/* the largest value of i such that column j's t-th cluster can be
 117.105 +   placed in column j with its topmost pixel occupying pixel i */
 117.106 +
 117.107 +var z{i in 1..m, j in 1..n}, binary;
 117.108 +/* z[i,j] = 1, if row i's j-th pixel is painted black
 117.109 +   z[i,j] = 0, if row i's j-th pixel is painted white */
 117.110 +
 117.111 +var y{i in 1..m, t in 1..kr[i], j in er[i,t]..lr[i,t]}, binary;
 117.112 +/* y[i,t,j] = 1, if row i's t-th cluster is placed in row i with its
 117.113 +                 leftmost pixel occupying pixel j
 117.114 +   y[i,t,j] = 0, if not */
 117.115 +
 117.116 +var x{j in 1..n, t in 1..kc[j], i in ec[j,t]..lc[j,t]}, binary;
 117.117 +/* x[j,t,i] = 1, if column j's t-th cluster is placed in column j with
 117.118 +                 its topmost pixel occupying pixel i
 117.119 +   x[j,t,i] = 0, if not */
 117.120 +
 117.121 +s.t. fa{i in 1..m, t in 1..kr[i]}:
 117.122 +     sum{j in er[i,t]..lr[i,t]} y[i,t,j] = 1;
 117.123 +/* row i's t-th cluster must appear in row i exactly once */
 117.124 +
 117.125 +s.t. fb{i in 1..m, t in 1..kr[i]-1, j in er[i,t]..lr[i,t]}:
 117.126 +     y[i,t,j] <= sum{jp in j+sr[i,t]+1..lr[i,t+1]} y[i,t+1,jp];
 117.127 +/* row i's (t+1)-th cluster must be placed to the right of its t-th
 117.128 +   cluster */
 117.129 +
 117.130 +s.t. fc{j in 1..n, t in 1..kc[j]}:
 117.131 +     sum{i in ec[j,t]..lc[j,t]} x[j,t,i] = 1;
 117.132 +/* column j's t-th cluster must appear in column j exactly once */
 117.133 +
 117.134 +s.t. fd{j in 1..n, t in 1..kc[j]-1, i in ec[j,t]..lc[j,t]}:
 117.135 +     x[j,t,i] <= sum{ip in i+sc[j,t]+1..lc[j,t+1]} x[j,t+1,ip];
 117.136 +/* column j's (t+1)-th cluster must be placed below its t-th cluster */
 117.137 +
 117.138 +s.t. fe{i in 1..m, j in 1..n}:
 117.139 +     z[i,j] <= sum{t in 1..kr[i], jp in er[i,t]..lr[i,t]:
 117.140 +                   j-sr[i,t]+1 <= jp and jp <= j} y[i,t,jp];
 117.141 +/* the double coverage constraint stating that if row i's j-th pixel
 117.142 +   is painted black, then at least one of row i's clusters must be
 117.143 +   placed in such a way that it covers row i's j-th pixel */
 117.144 +
 117.145 +s.t. ff{i in 1..m, j in 1..n}:
 117.146 +     z[i,j] <= sum{t in 1..kc[j], ip in ec[j,t]..lc[j,t]:
 117.147 +                   i-sc[j,t]+1 <= ip and ip <= i} x[j,t,ip];
 117.148 +/* the double coverage constraint making sure that if row i's j-th
 117.149 +   pixel is painted black, then at least one of column j's clusters
 117.150 +   covers it */
 117.151 +
 117.152 +s.t. fg{i in 1..m, j in 1..n, t in 1..kr[i], jp in er[i,t]..lr[i,t]:
 117.153 +     j-sr[i,t]+1 <= jp and jp <= j}: z[i,j] >= y[i,t,jp];
 117.154 +/* the constraint to prevent white pixels from being covered by the
 117.155 +   row clusters */
 117.156 +
 117.157 +s.t. fh{i in 1..m, j in 1..n, t in 1..kc[j], ip in ec[j,t]..lc[j,t]:
 117.158 +     i-sc[j,t]+1 <= ip and ip <= i}: z[i,j] >= x[j,t,ip];
 117.159 +/* the constraint to prevent white pixels from being covered by the
 117.160 +   column clusters */
 117.161 +
 117.162 +/* this is a feasibility problem, so no objective is needed */
 117.163 +
 117.164 +/*--------------------------------------------------------------------*/
 117.165 +/* The following part is used only to check for multiple solutions. */
 117.166 +
 117.167 +param zz{i in 1..m, j in 1..n}, binary, default 0;
 117.168 +/* zz[i,j] is z[i,j] for a previously found solution */
 117.169 +
 117.170 +s.t. fz{1..1 : sum{i in 1..m, j in 1..n} zz[i,j] > 0}:
 117.171 +     sum{i in 1..m, j in 1..n}
 117.172 +         (if zz[i,j] then (1 - z[i,j]) else z[i,j]) >= 1;
 117.173 +/* the constraint to forbid finding a solution, which is identical to
 117.174 +   the previously found one; this constraint is included in the model
 117.175 +   only if the previously found solution specified by the parameter zz
 117.176 +   is provided in the data section */
 117.177 +
 117.178 +solve;
 117.179 +
 117.180 +/*--------------------------------------------------------------------*/
 117.181 +/* Print solution to the standard output. */
 117.182 +
 117.183 +for {i in 1..m}
 117.184 +{  printf{j in 1..n} " %s", if z[i,j] then "#" else ".";
 117.185 +   printf "\n";
 117.186 +}
 117.187 +
 117.188 +/*--------------------------------------------------------------------*/
 117.189 +/* Write solution to a text file in PostScript format. */
 117.190 +
 117.191 +param ps, symbolic, default "solution.ps";
 117.192 +
 117.193 +printf "%%!PS-Adobe-3.0\n" > ps;
 117.194 +printf "%%%%Creator: GLPK (pbn.mod)\n" >> ps;
 117.195 +printf "%%%%BoundingBox: 0 0 %d %d\n",
 117.196 +       6 * (n + 2), 6 * (m + 2) >> ps;
 117.197 +printf "%%%%EndComments\n" >> ps;
 117.198 +printf "<</PageSize [%d %d]>> setpagedevice\n",
 117.199 +       6 * (n + 2), 6 * (m + 2) >> ps;
 117.200 +printf "0.1 setlinewidth\n" >> ps;
 117.201 +printf "/A { 2 copy 2 copy 2 copy newpath moveto exch 6 add exch line" &
 117.202 +       "to\n" >> ps;
 117.203 +printf "exch 6 add exch 6 add lineto 6 add lineto closepath } bind de" &
 117.204 +       "f\n" >> ps;
 117.205 +printf "/W { A stroke } def\n" >> ps;
 117.206 +printf "/B { A fill } def\n" >> ps;
 117.207 +printf {i in 1..m, j in 1..n} "%d %d %s\n",
 117.208 +       (j - 1) * 6 + 6, (m - i) * 6 + 6,
 117.209 +       if z[i,j] then "B" else "W" >> ps;
 117.210 +printf "%%%%EOF\n" >> ps;
 117.211 +
 117.212 +printf "Solution has been written to file %s\n", ps;
 117.213 +
 117.214 +/*--------------------------------------------------------------------*/
 117.215 +/* Write solution to a text file in the form of MathProg data section,
 117.216 +   which can be used later to check for multiple solutions. */
 117.217 +
 117.218 +param dat, symbolic, default "solution.dat";
 117.219 +
 117.220 +printf "data;\n" > dat;
 117.221 +printf "\n" >> dat;
 117.222 +printf "param zz :" >> dat;
 117.223 +printf {j in 1..n} " %d", j >> dat;
 117.224 +printf " :=\n" >> dat;
 117.225 +for {i in 1..m}
 117.226 +{  printf " %2d", i >> dat;
 117.227 +   printf {j in 1..n} " %s", if z[i,j] then "1" else "." >> dat;
 117.228 +   printf "\n" >> dat;
 117.229 +}
 117.230 +printf ";\n" >> dat;
 117.231 +printf "\n" >> dat;
 117.232 +printf "end;\n" >> dat;
 117.233 +
 117.234 +printf "Solution has also been written to file %s\n", dat;
 117.235 +
 117.236 +/*--------------------------------------------------------------------*/
 117.237 +/* The following data correspond to the example above. */
 117.238 +
 117.239 +data;
 117.240 +
 117.241 +param m := 10;
 117.242 +
 117.243 +param n := 10;
 117.244 +
 117.245 +param row : 1  2  3  :=
 117.246 +      1     3  6  .
 117.247 +      2     1  4  .
 117.248 +      3     1  1  3
 117.249 +      4     2  .  .
 117.250 +      5     3  3  .
 117.251 +      6     1  4  .
 117.252 +      7     2  5  .
 117.253 +      8     2  5  .
 117.254 +      9     1  1  .
 117.255 +      10    3  .  .
 117.256 +;
 117.257 +
 117.258 +param col : 1  2  3  4  :=
 117.259 +      1     2  3  .  .
 117.260 +      2     1  2  .  .
 117.261 +      3     1  1  1  1
 117.262 +      4     1  2  .  .
 117.263 +      5     1  1  1  1
 117.264 +      6     1  2  .  .
 117.265 +      7     2  3  .  .
 117.266 +      8     3  4  .  .
 117.267 +      9     8  .  .  .
 117.268 +      10    9  .  .  .
 117.269 +;
 117.270 +
 117.271 +end;
   118.1 Binary file deps/glpk/examples/pbn/pbn.pdf has changed
   119.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
   119.2 +++ b/deps/glpk/examples/pbn/pbn.tex	Sun Nov 06 20:59:10 2011 +0100
   119.3 @@ -0,0 +1,279 @@
   119.4 +%* pbn.tex *%
   119.5 +
   119.6 +\documentclass[11pt,draft]{article}
   119.7 +\usepackage{amssymb}
   119.8 +
   119.9 +\begin{document}
  119.10 +
  119.11 +\title{Solving Paint-By-Numbers Puzzles with GLPK}
  119.12 +
  119.13 +\author{Andrew Makhorin {\tt<mao@gnu.org>}}
  119.14 +
  119.15 +\date{August 2011}
  119.16 +
  119.17 +\maketitle
  119.18 +
  119.19 +\section{Introduction$^1$}
  119.20 +
  119.21 +\footnotetext[1]{This section is based on the material from [1].}
  119.22 +
  119.23 +A {\it paint-by-numbers} puzzle consists of an $m\times n$ grid of
  119.24 +pixels (the {\it canvas}) together with $m+n$ {\it cluster-size
  119.25 +sequences}, one for each row and column. The goal is to paint the canvas
  119.26 +with a picture that satisfies the following constraints:
  119.27 +
  119.28 +1. Each pixel must be blank or white.
  119.29 +
  119.30 +2. If a row or column has cluster-size sequence $s_1$, $s_2$, \dots,
  119.31 +$s_k$, then it must contain $k$ clusters of black pixels---the first
  119.32 +with $s_1$ black pixels, the second with $s_2$ black pixels, and so on.
  119.33 +
  119.34 +It should be noted that ``first'' means ``leftmost'' for rows and
  119.35 +``topmost'' for columns, and that rows and columns need not begin or end
  119.36 +with black pixels.
  119.37 +
  119.38 +\subsubsection*{Example}
  119.39 +
  119.40 +\def\arraystretch{.8}
  119.41 +
  119.42 +\begin{center}
  119.43 +\begin{tabular}{*{3}{@{$\;\;$}c}c*{10}{@{\ }c}@{}}
  119.44 + & & && & &1& &1& & & & & \\
  119.45 + & & && & &1& &1& & & & & \\
  119.46 + & & &&2&1&1&1&1&1&2&3& & \\
  119.47 + & & &&3&2&1&2&1&2&3&4&8&9\\
  119.48 +\\
  119.49 + &3&6&&$\blacksquare$&$\blacksquare$&$\blacksquare$&$\square$&
  119.50 +$\blacksquare$&$\blacksquare$&$\blacksquare$&$\blacksquare$&
  119.51 +$\blacksquare$&$\blacksquare$\\
  119.52 + &1&4&&$\blacksquare$&$\square$&$\square$&$\square$&$\square$&
  119.53 +$\square$&$\blacksquare$&$\blacksquare$&$\blacksquare$&$\blacksquare$\\
  119.54 +1&1&3&&$\square$&$\square$&$\blacksquare$&$\square$&$\blacksquare$&
  119.55 +$\square$&$\square$&$\blacksquare$&$\blacksquare$&$\blacksquare$\\
  119.56 + & &2&&$\square$&$\square$&$\square$&$\square$&$\square$&$\square$&
  119.57 +$\square$&$\square$&$\blacksquare$&$\blacksquare$\\
  119.58 + &3&3&&$\square$&$\square$&$\blacksquare$&$\blacksquare$&$\blacksquare$&
  119.59 +$\square$&$\square$&$\blacksquare$&$\blacksquare$&$\blacksquare$\\
  119.60 + &1&4&&$\blacksquare$&$\square$&$\square$&$\square$&$\square$&$\square$&
  119.61 +$\blacksquare$&$\blacksquare$&$\blacksquare$&$\blacksquare$\\
  119.62 + &2&5&&$\blacksquare$&$\blacksquare$&$\square$&$\square$&$\square$&
  119.63 +$\blacksquare$&$\blacksquare$&$\blacksquare$&$\blacksquare$&
  119.64 +$\blacksquare$\\
  119.65 + &2&5&&$\blacksquare$&$\blacksquare$&$\square$&$\square$&$\square$&
  119.66 +$\blacksquare$&$\blacksquare$&$\blacksquare$&$\blacksquare$&
  119.67 +$\blacksquare$\\
  119.68 + &1&1&&$\square$&$\square$&$\square$&$\blacksquare$&$\square$&$\square$&
  119.69 +$\square$&$\square$&$\square$&$\blacksquare$\\
  119.70 + & &3&&$\square$&$\square$&$\blacksquare$&$\blacksquare$&$\blacksquare$&
  119.71 +$\square$&$\square$&$\square$&$\square$&$\square$\\
  119.72 +\end{tabular}
  119.73 +\end{center}
  119.74 +
  119.75 +\def\arraystretch{1}
  119.76 +
  119.77 +\section{Solving a puzzle}
  119.78 +
  119.79 +The Paint-By-Numbers puzzle can be formulated as a 0-1 integer
  119.80 +feasibility problem. The formulation used in GLPK was proposed in [1].
  119.81 +
  119.82 +For solving puzzles there are used two components, which both are
  119.83 +coded in the GNU MathProg modeling language [2]: the model section and
  119.84 +the data section. The model section is common for all puzzles and
  119.85 +placed in file \verb|pbn.mod|. This file is included in the GLPK
  119.86 +distribution and can be found in subdirectory \verb|examples/pbn|.
  119.87 +
  119.88 +To solve a particular puzzle the user only needs to prepare the data
  119.89 +section, which defines input data to the puzzle. The data section for
  119.90 +the example puzzle from the previous section may look like follows
  119.91 +(here \verb|m| is the number of rows, and \verb|n| is the number of
  119.92 +columns):
  119.93 +
  119.94 +\begin{footnotesize}
  119.95 +\begin{verbatim}
  119.96 +data;
  119.97 +
  119.98 +param m := 10;
  119.99 +
 119.100 +param n := 10;
 119.101 +
 119.102 +param row : 1  2  3  :=
 119.103 +      1     3  6  .
 119.104 +      2     1  4  .
 119.105 +      3     1  1  3
 119.106 +      4     2  .  .
 119.107 +      5     3  3  .
 119.108 +      6     1  4  .
 119.109 +      7     2  5  .
 119.110 +      8     2  5  .
 119.111 +      9     1  1  .
 119.112 +      10    3  .  .
 119.113 +;
 119.114 +
 119.115 +param col : 1  2  3  4  :=
 119.116 +      1     2  3  .  .
 119.117 +      2     1  2  .  .
 119.118 +      3     1  1  1  1
 119.119 +      4     1  2  .  .
 119.120 +      5     1  1  1  1
 119.121 +      6     1  2  .  .
 119.122 +      7     2  3  .  .
 119.123 +      8     3  4  .  .
 119.124 +      9     8  .  .  .
 119.125 +      10    9  .  .  .
 119.126 +;
 119.127 +
 119.128 +end;
 119.129 +\end{verbatim}
 119.130 +\end{footnotesize}
 119.131 +
 119.132 +\newpage
 119.133 +
 119.134 +Let the data section for a puzzle be placed in file \verb|foo.dat|.
 119.135 +Then to solve the puzzle the user should enter the following command:
 119.136 +
 119.137 +\begin{verbatim}
 119.138 +   glpsol --minisat -m pbn.mod -d foo.dat
 119.139 +\end{verbatim}
 119.140 +
 119.141 +\noindent
 119.142 +This command invokes \verb|glpsol|, the GLPK LP/MIP stand-alone solver,
 119.143 +which reads the model section from file \verb|pbn.mod|, the data section
 119.144 +from file \verb|foo.dat|, translates them to an internal representation,
 119.145 +and solves the resulting 0-1 integer feasibility problem. The option
 119.146 +\verb|--minisat| tells \verb|glpsol| to translate the feasibility
 119.147 +problem to a CNF satisfiability problem and then use the MiniSat solver
 119.148 +[3] to solve it.
 119.149 +
 119.150 +If a solution to the puzzle has been found, that is indicated by the
 119.151 +message \verb|SATISFIABLE|, \verb|glpsol| prints the solution to the
 119.152 +standard output (terminal), writes it to file \verb|solution.ps| in the
 119.153 +PostScript format, and also writes it to file \verb|solution.dat| in the
 119.154 +form of MathProg data section, which can be used later to check for
 119.155 +multiple solutions, if necessary (for details see the next section).
 119.156 +The message \verb|UNSATISFIABLE| means that the puzzle has no solution.
 119.157 +
 119.158 +Usually the time taken to solve a puzzle of moderate size (up to 50 rows
 119.159 +and columns) varies from several seconds to several minutes. However,
 119.160 +hard or large puzzles may require much more time.
 119.161 +
 119.162 +Data sections for some example puzzles included in the GLPK distribution
 119.163 +can be found in subdirectory \verb|examples/pbn|.
 119.164 +
 119.165 +\section{Checking for multiple solutions}
 119.166 +
 119.167 +Sometimes the user may be interested to know if the puzzle has exactly
 119.168 +one (unique) solution or it has multiple solutions. To check that the
 119.169 +user should solve the puzzle as explained above in the previous section
 119.170 +and then enter the following command:
 119.171 +
 119.172 +\begin{verbatim}
 119.173 +   glpsol --minisat -m pbn.mod -d foo.dat -d solution.dat
 119.174 +\end{verbatim}
 119.175 +
 119.176 +\noindent
 119.177 +In this case \verb|glpsol| reads an additional data section from file
 119.178 +\verb|solution.dat|, which contains the previously found solution,
 119.179 +activates an additional constraint in the model section to forbid
 119.180 +finding the solution specified in the additional data section, and
 119.181 +attempts to find another solution. The message \verb|UNSATISFIABLE|
 119.182 +reported by \verb|glpsol| will mean that the puzzle has a unique
 119.183 +solution, while the message \verb|SATISFIABLE| will mean that the puzzle
 119.184 +has at least two different solutions.
 119.185 +
 119.186 +\newpage
 119.187 +
 119.188 +\section{Solution times}
 119.189 +
 119.190 +The table on the next page shows solution times on a sample set of
 119.191 +the paint-by-numbers puzzles from the \verb|<webpbn.com>| website.
 119.192 +This sample set was used in the survey [4] to compare efficiency of
 119.193 +existing PBN solvers.
 119.194 +
 119.195 +The authors of some puzzles from the sample set have given permission
 119.196 +for their puzzles to be freely redistributed as long as the original
 119.197 +attribution and copyright statement are retained. In the table these
 119.198 +puzzles are marked by an asterisk (*). The files containing the
 119.199 +MathProg data sections for these puzzles are included in the GLPK
 119.200 +distribution and can be found in subdirectory \verb|examples/pbn|.
 119.201 +
 119.202 +All runs were performed on Intel Pentium 4 (CPU 3GHz, 2GB of RAM).
 119.203 +The C compiler used was GCC 3.4.4 with default optimization options.
 119.204 +
 119.205 +The column `Sol.Time' shows the time, in seconds, taken by the
 119.206 +\verb|glpsol| solver to find a solution to corresponding puzzle. The
 119.207 +column `Chk.Time' shows the time, in seconds, taken by \verb|glpsol| to
 119.208 +check for multiple solutions, i.e. either to prove that the puzzle has
 119.209 +a unique solution or find another solution to the puzzle. Both these
 119.210 +times do not include the time used to translate the MathProg model and
 119.211 +data sections into an internal MIP representation, but include the time
 119.212 +used to translate the 0-1 feasibility problem to a CNF satisfiability
 119.213 +problem.
 119.214 +
 119.215 +\begin{thebibliography}{10}
 119.216 +
 119.217 +\bibitem{1}
 119.218 +Robert A. Bosch, ``Painting by Numbers'', 2000.\\
 119.219 +\verb|<http://www.oberlin.edu/~math/faculty/bosch/pbn-page.html>|.
 119.220 +
 119.221 +\bibitem{2}
 119.222 +GLPK: Modeling Language GNU MathProg. Language Reference. (This
 119.223 +document is included in the GLPK distribution and can be found in
 119.224 +subdirectory \verb|doc|.)
 119.225 +
 119.226 +\bibitem{3}
 119.227 +Niklas E\'en, Niklas S\"orensson, ``An Extensible SAT-solver'',
 119.228 +Chalmers University of Technology, Sweden. \verb|<http://minisat.se/>|.
 119.229 +
 119.230 +\bibitem{4}
 119.231 +Jan Wolter, ``Survey of Paint-by-Number Puzzle Solvers''.\\
 119.232 +\verb|<http://webpbn.com/survey/>|.
 119.233 +
 119.234 +\end{thebibliography}
 119.235 +
 119.236 +\newpage
 119.237 +
 119.238 +\begin{table}
 119.239 +\caption{Solution times on the sample set of puzzles from [4]}
 119.240 +\begin{center}
 119.241 +\begin{tabular}{@{}lllcrr@{}}
 119.242 +\hline
 119.243 +\multicolumn{2}{c}{Puzzle}&Size&Notes&Sol.Time, s&Chk.Time, s\\
 119.244 +\hline
 119.245 +\#1&Dancer*    &$10\times 5$&L&$<1$&$<1$\\
 119.246 +\#6&Cat*       &$20\times 20$&L&$<1$&$<1$\\
 119.247 +\#21&Skid*     &$25\times 14$&L, B&$<1$&$<1$\\
 119.248 +\#27&Bucks*    &$23\times 27$&B&$<1$&$<1$\\
 119.249 +\#23&Edge*     &$11\times 10$&&$<1$&$<1$\\
 119.250 +\#2413&Smoke   &$20\times 20$&&$<1$&$<1$\\
 119.251 +\#16&Knot*     &$34\times 34$&L&1&1\\
 119.252 +\#529&Swing*   &$45\times 45$&L&1&1\\
 119.253 +\#65&Mum*      &$40\times 34$&&1&1\\
 119.254 +\#7604&DiCap   &$55\times 55$&&10&10\\
 119.255 +\#1694&Tragic  &$50\times 45$&&3&3\\
 119.256 +\#1611&Merka   &$60\times 55$&B&4&4\\
 119.257 +\#436&Petro*   &$35\times 40$&&1&1\\
 119.258 +\#4645&M\&M    &$70\times 50$&B&5&6\\
 119.259 +\#3541&Signed  &$50\times 60$&&7&7\\
 119.260 +\#803&Light*   &$45\times 50$&B&1&1\\
 119.261 +\#6574&Forever*&$25\times 25$&&1&1\\
 119.262 +\#2040&Hot     &$60\times 55$&&6&6\\
 119.263 +\#6739&Karate  &$40\times 40$&M&2&2\\
 119.264 +\#8098&9-Dom*  &$19\times 19$&&1&2\\
 119.265 +\#2556&Flag    &$45\times 65$&M, B&2&2\\
 119.266 +\#2712&Lion    &$47\times 47$&M&11&12\\
 119.267 +\#10088&Marley &$63\times 52$&M&135&226\\
 119.268 +\#9892&Nature  &$40\times 50$&M&850&1053\\
 119.269 +\hline
 119.270 +\end{tabular}
 119.271 +
 119.272 +\begin{tabular}{@{}lp{102mm}@{}}
 119.273 +*&Puzzle designer has given permission to redistribute the puzzle.\\
 119.274 +L&Puzzle is line solvable. That is, it can be solved one line at a
 119.275 +time.\\
 119.276 +B&Puzzle contains blank rows or columns.\\
 119.277 +M&Puzzle has multiple solutions.\\
 119.278 +\end{tabular}
 119.279 +\end{center}
 119.280 +\end{table}
 119.281 +
 119.282 +\end{document}
   120.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
   120.2 +++ b/deps/glpk/examples/pbn/petro.dat	Sun Nov 06 20:59:10 2011 +0100
   120.3 @@ -0,0 +1,102 @@
   120.4 +/* petro.dat */
   120.5 +
   120.6 +/***********************************************************************
   120.7 +*  Web Paint-by-Number Puzzle #436 from <www.webpbn.com>.
   120.8 +*  Copyright (C) 2006 by Jan Wolter. Used by permission.
   120.9 +*
  120.10 +*  Old Stone Face
  120.11 +*
  120.12 +*  created by Jan Wolter
  120.13 +*  Jun 17, 2006
  120.14 +*
  120.15 +*  Encoded in GNU MathProg by Andrew Makhorin <mao@gnu.org>.
  120.16 +***********************************************************************/
  120.17 +
  120.18 +data;
  120.19 +
  120.20 +param m := 35;
  120.21 +
  120.22 +param n := 40;
  120.23 +
  120.24 +param row : 1  2  3  4  5  6  7  8  9  :=
  120.25 +      1     2  2  .  .  .  .  .  .  .
  120.26 +      2     2  3  2  .  .  .  .  .  .
  120.27 +      3     3  3  3  2  .  .  .  .  .
  120.28 +      4     3  3  3  3  .  .  .  .  .
  120.29 +      5     2  3  3  3  3  2  .  .  .
  120.30 +      6     3  3  3  3  3  3  .  .  .
  120.31 +      7     4  2  3  2  2  4  .  .  .
  120.32 +      8     4  2  2  2  2  3  1  .  .
  120.33 +      9     3  1  2  2  2  3  3  .  .
  120.34 +      10    3  2  2  2  2  2  4  .  .
  120.35 +      11    3  2  15 2  4  .  .  .  .
  120.36 +      12    5  19 4  .  .  .  .  .  .
  120.37 +      13    6  4  3  3  .  .  .  .  .
  120.38 +      14    6  4  4  .  .  .  .  .  .
  120.39 +      15    2  4  6  2  .  .  .  .  .
  120.40 +      16    2  2  3  3  3  2  .  .  .
  120.41 +      17    9  2  2  2  3  9  .  .  .
  120.42 +      18    10 2  2  2  2  2  10 .  .
  120.43 +      19    4  2  3  3  2  2  3  2  5
  120.44 +      20    2  5  2  4  2  .  .  .  .
  120.45 +      21    5  3  2  2  5  .  .  .  .
  120.46 +      22    6  3  2  3  7  .  .  .  .
  120.47 +      23    6  8  9  7  .  .  .  .  .
  120.48 +      24    4  8  7  5  .  .  .  .  .
  120.49 +      25    4  .  .  .  .  .  .  .  .
  120.50 +      26    2  .  .  .  .  .  .  .  .
  120.51 +      27    2  .  .  .  .  .  .  .  .
  120.52 +      28    14 .  .  .  .  .  .  .  .
  120.53 +      29    16 .  .  .  .  .  .  .  .
  120.54 +      30    3  3  .  .  .  .  .  .  .
  120.55 +      31    2  2  .  .  .  .  .  .  .
  120.56 +      32    2  2  .  .  .  .  .  .  .
  120.57 +      33    4  4  .  .  .  .  .  .  .
  120.58 +      34    16 .  .  .  .  .  .  .  .
  120.59 +      35    12 .  .  .  .  .  .  .  .
  120.60 +;
  120.61 +
  120.62 +param col : 1  2  3  4  5  6  7  :=
  120.63 +      1     1  .  .  .  .  .  .
  120.64 +      2     3  2  .  .  .  .  .
  120.65 +      3     2  3  3  .  .  .  .
  120.66 +      4     3  3  3  .  .  .  .
  120.67 +      5     3  3  3  3  .  .  .
  120.68 +      6     4  2  2  2  .  .  .
  120.69 +      7     3  3  2  3  .  .  .
  120.70 +      8     3  2  2  2  .  .  .
  120.71 +      9     3  2  6  .  .  .  .
  120.72 +      10    2  9  .  .  .  .  .
  120.73 +      11    2  3  3  .  .  .  .
  120.74 +      12    4  4  3  2  4  .  .
  120.75 +      13    7  2  5  2  6  .  .
  120.76 +      14    12 2  3  2  3  2  .
  120.77 +      15    3  1  2  2  2  3  .
  120.78 +      16    2  2  3  2  2  2  .
  120.79 +      17    6  2  6  2  2  2  .
  120.80 +      18    12 4  3  2  2  .  .
  120.81 +      19    12 2  2  2  .  .  .
  120.82 +      20    2  6  2  .  .  .  .
  120.83 +      21    2  6  5  2  .  .  .
  120.84 +      22    10 9  2  2  .  .  .
  120.85 +      23    12 3  3  2  2  .  .
  120.86 +      24    6  2  2  2  2  2  2
  120.87 +      25    2  2  3  2  2  2  .
  120.88 +      26    4  3  2  2  2  3  .
  120.89 +      27    7  3  3  2  3  2  .
  120.90 +      28    5  3  5  2  6  .  .
  120.91 +      29    4  3  3  3  4  .  .
  120.92 +      30    3  5  3  .  .  .  .
  120.93 +      31    3  9  .  .  .  .  .
  120.94 +      32    4  2  6  .  .  .  .
  120.95 +      33    4  2  2  2  .  .  .
  120.96 +      34    4  2  2  3  .  .  .
  120.97 +      35    3  2  2  3  .  .  .
  120.98 +      36    3  3  3  .  .  .  .
  120.99 +      37    3  3  3  .  .  .  .
 120.100 +      38    4  3  3  .  .  .  .
 120.101 +      39    2  3  3  .  .  .  .
 120.102 +      40    2  1  .  .  .  .  .
 120.103 +;
 120.104 +
 120.105 +end;
   121.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
   121.2 +++ b/deps/glpk/examples/pbn/skid.dat	Sun Nov 06 20:59:10 2011 +0100
   121.3 @@ -0,0 +1,66 @@
   121.4 +/* skid.dat */
   121.5 +
   121.6 +/***********************************************************************
   121.7 +*  Web Paint-by-Number Puzzle #21 from <www.webpbn.com>.
   121.8 +*  Copyright (C) 2004 by Jan Wolter. Used by permission.
   121.9 +*
  121.10 +*  Slippery Conditions
  121.11 +*
  121.12 +*  created by Jan Wolter
  121.13 +*  Apr 4, 2004
  121.14 +*
  121.15 +*  Encoded in GNU MathProg by Andrew Makhorin <mao@gnu.org>.
  121.16 +***********************************************************************/
  121.17 +
  121.18 +data;
  121.19 +
  121.20 +param m := 25;
  121.21 +
  121.22 +param n := 14;
  121.23 +
  121.24 +param row : 1  2  3  :=
  121.25 +      1     9  .  .
  121.26 +      2     1  1  .
  121.27 +      3     1  1  1
  121.28 +      4     1  3  1
  121.29 +      5     13 .  .
  121.30 +      6     13 .  .
  121.31 +      7     13 .  .
  121.32 +      8     13 .  .
  121.33 +      9     2  2  .
  121.34 +      10    2  2  .
  121.35 +      11    .  .  .
  121.36 +      12    2  2  .
  121.37 +      13    2  2  .
  121.38 +      14    2  2  .
  121.39 +      15    2  2  .
  121.40 +      16    2  2  .
  121.41 +      17    2  2  .
  121.42 +      18    2  2  .
  121.43 +      19    2  2  .
  121.44 +      20    2  2  .
  121.45 +      21    2  2  .
  121.46 +      22    2  2  .
  121.47 +      23    2  2  .
  121.48 +      24    2  2  .
  121.49 +      25    2  2  .
  121.50 +;
  121.51 +
  121.52 +param col : 1  2  3  4  5  :=
  121.53 +      1     2  .  .  .  .
  121.54 +      2     4  6  .  .  .
  121.55 +      3     9  4  4  2  .
  121.56 +      4     1  6  2  6  .
  121.57 +      5     1  5  2  .  .
  121.58 +      6     1  6  .  .  .
  121.59 +      7     1  5  .  .  .
  121.60 +      8     1  4  .  .  .
  121.61 +      9     1  4  .  .  .
  121.62 +      10    1  4  2  .  .
  121.63 +      11    1  4  6  .  .
  121.64 +      12    1  6  4  4  2
  121.65 +      13    9  2  6  .  .
  121.66 +      14    4  2  .  .  .
  121.67 +;
  121.68 +
  121.69 +end;
   122.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
   122.2 +++ b/deps/glpk/examples/pbn/swing.dat	Sun Nov 06 20:59:10 2011 +0100
   122.3 @@ -0,0 +1,117 @@
   122.4 +/* swing.dat */
   122.5 +
   122.6 +/***********************************************************************
   122.7 +*  Web Paint-by-Number Puzzle #529 from <www.webpbn.com>.
   122.8 +*  Copyright (C) 2006 by Jan Wolter. Used by permission.
   122.9 +*
  122.10 +*  Swing
  122.11 +*
  122.12 +*  created by Jan Wolter
  122.13 +*  Sep 28, 2006
  122.14 +*
  122.15 +*  Encoded in GNU MathProg by Andrew Makhorin <mao@gnu.org>.
  122.16 +***********************************************************************/
  122.17 +
  122.18 +data;
  122.19 +
  122.20 +param m := 45;
  122.21 +
  122.22 +param n := 45;
  122.23 +
  122.24 +param row : 1  2  3  4  5  6  7  8  9  10 11 12 13 14 :=
  122.25 +      1     7  1  1  1  1  1  .  .  .  .  .  .  .  .
  122.26 +      2     3  1  3  1  4  1  4  1  5  1  5  1  2  .
  122.27 +      3     1  1  1  3  1  4  1  4  1  5  1  5  1  2
  122.28 +      4     2  1  2  1  1  1  1  6  2  .  .  .  .  .
  122.29 +      5     3  30 1  5  .  .  .  .  .  .  .  .  .  .
  122.30 +      6     1  5  8  1  1  7  1  1  3  .  .  .  .  .
  122.31 +      7     3  4  8  1  5  1  2  .  .  .  .  .  .  .
  122.32 +      8     3  20 6  6  .  .  .  .  .  .  .  .  .  .
  122.33 +      9     3  3  7  2  5  1  .  .  .  .  .  .  .  .
  122.34 +      10    3  3  1  1  9  1  1  5  6  .  .  .  .  .
  122.35 +      11    2  3  8  1  3  4  2  .  .  .  .  .  .  .
  122.36 +      12    5  3  1  10 4  5  2  .  .  .  .  .  .  .
  122.37 +      13    1  2  3  8  4  6  .  .  .  .  .  .  .  .
  122.38 +      14    2  2  3  11 10 .  .  .  .  .  .  .  .  .
  122.39 +      15    2  2  3  10 7  .  .  .  .  .  .  .  .  .
  122.40 +      16    2  3  1  7  12 2  .  .  .  .  .  .  .  .
  122.41 +      17    2  3  1  4  11 2  .  .  .  .  .  .  .  .
  122.42 +      18    4  1  2  1  11 2  .  .  .  .  .  .  .  .
  122.43 +      19    9  1  2  9  .  .  .  .  .  .  .  .  .  .
  122.44 +      20    6  2  1  4  11 .  .  .  .  .  .  .  .  .
  122.45 +      21    2  5  1  2  6  6  .  .  .  .  .  .  .  .
  122.46 +      22    6  2  4  8  4  .  .  .  .  .  .  .  .  .
  122.47 +      23    4  2  16 1  .  .  .  .  .  .  .  .  .  .
  122.48 +      24    2  2  15 2  .  .  .  .  .  .  .  .  .  .
  122.49 +      25    3  2  15 4  .  .  .  .  .  .  .  .  .  .
  122.50 +      26    3  3  13 4  .  .  .  .  .  .  .  .  .  .
  122.51 +      27    4  12 9  .  .  .  .  .  .  .  .  .  .  .
  122.52 +      28    1  9  10 .  .  .  .  .  .  .  .  .  .  .
  122.53 +      29    2  1  17 7  2  .  .  .  .  .  .  .  .  .
  122.54 +      30    2  2  8  3  8  2  .  .  .  .  .  .  .  .
  122.55 +      31    2  3  6  3  8  2  .  .  .  .  .  .  .  .
  122.56 +      32    2  4  5  4  7  2  .  .  .  .  .  .  .  .
  122.57 +      33    2  5  5  4  6  .  .  .  .  .  .  .  .  .
  122.58 +      34    4  4  5  4  9  .  .  .  .  .  .  .  .  .
  122.59 +      35    1  4  6  4  4  .  .  .  .  .  .  .  .  .
  122.60 +      36    4  3  6  4  3  2  .  .  .  .  .  .  .  .
  122.61 +      37    2  1  2  7  4  4  2  .  .  .  .  .  .  .
  122.62 +      38    2  2  2  9  5  5  2  .  .  .  .  .  .  .
  122.63 +      39    2  2  2  10 6  6  .  .  .  .  .  .  .  .
  122.64 +      40    3  2  1  9  18 .  .  .  .  .  .  .  .  .
  122.65 +      41    8  4  23 .  .  .  .  .  .  .  .  .  .  .
  122.66 +      42    1  2  1  2  2  1  1  1  2  .  .  .  .  .
  122.67 +      43    2  1  4  2  1  4  1  5  1  3  1  2  .  .
  122.68 +      44    2  1  5  4  4  1  5  1  3  1  2  .  .  .
  122.69 +      45    1  10 1  1  1  .  .  .  .  .  .  .  .  .
  122.70 +;
  122.71 +
  122.72 +param col : 1  2  3  4  5  6  7  8  9  10 11 12 13 14 :=
  122.73 +      1     7  1  1  1  1  1  .  .  .  .  .  .  .  .
  122.74 +      2     2  2  4  1  4  1  5  1  4  1  4  1  2  .
  122.75 +      3     3  1  4  1  4  1  14 4  1  2  .  .  .  .
  122.76 +      4     1  1  5  1  2  3  4  1  .  .  .  .  .  .
  122.77 +      5     3  13 1  10 .  .  .  .  .  .  .  .  .  .
  122.78 +      6     1  9  4  .  .  .  .  .  .  .  .  .  .  .
  122.79 +      7     6  7  2  2  .  .  .  .  .  .  .  .  .  .
  122.80 +      8     8  4  1  4  .  .  .  .  .  .  .  .  .  .
  122.81 +      9     2  8  3  2  5  3  .  .  .  .  .  .  .  .
  122.82 +      10    10 1  3  7  2  .  .  .  .  .  .  .  .  .
  122.83 +      11    8  6  2  8  1  2  .  .  .  .  .  .  .  .
  122.84 +      12    1  1  2  2  8  1  1  .  .  .  .  .  .  .
  122.85 +      13    2  1  1  1  2  1  3  1  3  3  1  .  .  .
  122.86 +      14    2  1  1  1  5  4  2  1  .  .  .  .  .  .
  122.87 +      15    2  1  1  1  1  7  2  1  .  .  .  .  .  .
  122.88 +      16    2  1  1  2  9  1  2  1  .  .  .  .  .  .
  122.89 +      17    4  6  12 1  3  .  .  .  .  .  .  .  .  .
  122.90 +      18    16 13 3  2  .  .  .  .  .  .  .  .  .  .
  122.91 +      19    12 21 2  .  .  .  .  .  .  .  .  .  .  .
  122.92 +      20    2  13 23 .  .  .  .  .  .  .  .  .  .  .
  122.93 +      21    2  14 19 .  .  .  .  .  .  .  .  .  .  .
  122.94 +      22    2  14 20 2  .  .  .  .  .  .  .  .  .  .
  122.95 +      23    2  13 7  2  8  2  .  .  .  .  .  .  .  .
  122.96 +      24    12 8  1  7  2  .  .  .  .  .  .  .  .  .
  122.97 +      25    5  1  1  1  2  8  1  5  2  .  .  .  .  .
  122.98 +      26    2  1  1  1  9  1  1  4  .  .  .  .  .  .
  122.99 +      27    2  1  1  1  6  1  3  5  .  .  .  .  .  .
 122.100 +      28    2  2  1  5  6  2  .  .  .  .  .  .  .  .
 122.101 +      29    2  1  3  1  3  7  3  2  .  .  .  .  .  .
 122.102 +      30    2  3  2  1  1  2  4  4  2  .  .  .  .  .
 122.103 +      31    2  2  1  1  2  3  1  8  2  .  .  .  .  .
 122.104 +      32    9  3  1  7  2  .  .  .  .  .  .  .  .  .
 122.105 +      33    12 4  1  6  2  .  .  .  .  .  .  .  .  .
 122.106 +      34    7  4  1  2  5  .  .  .  .  .  .  .  .  .
 122.107 +      35    2  6  6  5  6  .  .  .  .  .  .  .  .  .
 122.108 +      36    8  8  6  3  .  .  .  .  .  .  .  .  .  .
 122.109 +      37    3  10 8  4  2  .  .  .  .  .  .  .  .  .
 122.110 +      38    5  11 9  5  2  .  .  .  .  .  .  .  .  .
 122.111 +      39    3  1  12 16 2  .  .  .  .  .  .  .  .  .
 122.112 +      40    3  1  12 16 .  .  .  .  .  .  .  .  .  .
 122.113 +      41    5  2  13 21 .  .  .  .  .  .  .  .  .  .
 122.114 +      42    6  1  3  3  1  1  .  .  .  .  .  .  .  .
 122.115 +      43    5  1  3  1  3  1  1  2  1  4  1  3  1  3
 122.116 +      44    5  1  3  1  3  1  4  1  4  1  3  1  3  .
 122.117 +      45    1  1  1  1  1  1  .  .  .  .  .  .  .  .
 122.118 +;
 122.119 +
 122.120 +end;
   123.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
   123.2 +++ b/deps/glpk/examples/plan.lp	Sun Nov 06 20:59:10 2011 +0100
   123.3 @@ -0,0 +1,39 @@
   123.4 +\* plan.lp *\
   123.5 +
   123.6 +Minimize
   123.7 +   value: .03 bin1 + .08 bin2 + .17 bin3 + .12 bin4 + .15 bin5 +
   123.8 +          .21 alum + .38 silicon
   123.9 +
  123.10 +Subject To
  123.11 +   yield:     bin1 +     bin2 +     bin3 +     bin4 +     bin5 +
  123.12 +              alum +     silicon                                 =  2000
  123.13 +
  123.14 +   fe:    .15 bin1 + .04 bin2 + .02 bin3 + .04 bin4 + .02 bin5 +
  123.15 +          .01 alum + .03 silicon                                 <=   60
  123.16 +
  123.17 +   cu:    .03 bin1 + .05 bin2 + .08 bin3 + .02 bin4 + .06 bin5 +
  123.18 +          .01 alum                                               <=  100
  123.19 +
  123.20 +   mn:    .02 bin1 + .04 bin2 + .01 bin3 + .02 bin4 + .02 bin5   <=   40
  123.21 +
  123.22 +   mg:    .02 bin1 + .03 bin2                       + .01 bin5   <=   30
  123.23 +
  123.24 +   al:    .70 bin1 + .75 bin2 + .80 bin3 + .75 bin4 + .80 bin5 +
  123.25 +          .97 alum                                               >= 1500
  123.26 +
  123.27 +   si1:   .02 bin1 + .06 bin2 + .08 bin3 + .12 bin4 + .02 bin5 +
  123.28 +          .01 alum + .97 silicon                                 >=  250
  123.29 +
  123.30 +   si2:   .02 bin1 + .06 bin2 + .08 bin3 + .12 bin4 + .02 bin5 +
  123.31 +          .01 alum + .97 silicon                                 <=  300
  123.32 +
  123.33 +Bounds
  123.34 +          bin1 <=  200
  123.35 +          bin2 <= 2500
  123.36 +   400 <= bin3 <=  800
  123.37 +   100 <= bin4 <=  700
  123.38 +          bin5 <= 1500
  123.39 +
  123.40 +End
  123.41 +
  123.42 +\* eof *\
   124.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
   124.2 +++ b/deps/glpk/examples/plan.mod	Sun Nov 06 20:59:10 2011 +0100
   124.3 @@ -0,0 +1,39 @@
   124.4 +/* plan.mod */
   124.5 +
   124.6 +var bin1, >= 0, <= 200;
   124.7 +var bin2, >= 0, <= 2500;
   124.8 +var bin3, >= 400, <= 800;
   124.9 +var bin4, >= 100, <= 700;
  124.10 +var bin5, >= 0, <= 1500;
  124.11 +var alum, >= 0;
  124.12 +var silicon, >= 0;
  124.13 +
  124.14 +minimize
  124.15 +
  124.16 +value: .03 * bin1 + .08 * bin2 + .17 * bin3 + .12 * bin4 + .15 * bin5 +
  124.17 +       .21 * alum + .38 * silicon;
  124.18 +
  124.19 +subject to
  124.20 +
  124.21 +yield: bin1 + bin2 + bin3 + bin4 + bin5 + alum + silicon = 2000;
  124.22 +
  124.23 +fe: .15 * bin1 + .04 * bin2 + .02 * bin3 + .04 * bin4 + .02 * bin5 +
  124.24 +    .01 * alum + .03 * silicon <= 60;
  124.25 +
  124.26 +cu: .03 * bin1 + .05 * bin2 + .08 * bin3 + .02 * bin4 + .06 * bin5 +
  124.27 +    .01 * alum <= 100;
  124.28 +
  124.29 +mn: .02 * bin1 + .04 * bin2 + .01 * bin3 + .02 * bin4 + .02 * bin5
  124.30 +    <= 40;
  124.31 +
  124.32 +mg: .02 * bin1 + .03 * bin2 + .01 * bin5 <= 30;
  124.33 +
  124.34 +al: .70 * bin1 + .75 * bin2 + .80 * bin3 + .75 * bin4 + .80 * bin5 +
  124.35 +    .97 * alum >= 1500;
  124.36 +
  124.37 +si: 250 <= .02 * bin1 + .06 * bin2 + .08 * bin3 + .12 * bin4 +
  124.38 +    .02 * bin5 + .01 * alum + .97 * silicon <= 300;
  124.39 +
  124.40 +end;
  124.41 +
  124.42 +/* eof */
   125.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
   125.2 +++ b/deps/glpk/examples/plan.mps	Sun Nov 06 20:59:10 2011 +0100
   125.3 @@ -0,0 +1,54 @@
   125.4 +*000000001111111111222222222233333333334444444444555555555566
   125.5 +*234567890123456789012345678901234567890123456789012345678901
   125.6 +NAME          PLAN
   125.7 +ROWS
   125.8 + N  VALUE
   125.9 + E  YIELD
  125.10 + L  FE
  125.11 + L  CU
  125.12 + L  MN
  125.13 + L  MG
  125.14 + G  AL
  125.15 + L  SI
  125.16 +COLUMNS
  125.17 +    BIN1      VALUE           .03000   YIELD          1.00000
  125.18 +              FE              .15000   CU              .03000
  125.19 +              MN              .02000   MG              .02000
  125.20 +              AL              .70000   SI              .02000
  125.21 +    BIN2      VALUE           .08000   YIELD          1.00000
  125.22 +              FE              .04000   CU              .05000
  125.23 +              MN              .04000   MG              .03000
  125.24 +              AL              .75000   SI              .06000
  125.25 +    BIN3      VALUE           .17000   YIELD          1.00000
  125.26 +              FE              .02000   CU              .08000
  125.27 +              MN              .01000   AL              .80000
  125.28 +              SI              .08000
  125.29 +    BIN4      VALUE           .12000   YIELD          1.00000
  125.30 +              FE              .04000   CU              .02000
  125.31 +              MN              .02000   AL              .75000
  125.32 +              SI              .12000
  125.33 +    BIN5      VALUE           .15000   YIELD          1.00000
  125.34 +              FE              .02000   CU              .06000
  125.35 +              MN              .02000   MG              .01000
  125.36 +              AL              .80000   SI              .02000
  125.37 +    ALUM      VALUE           .21000   YIELD          1.00000
  125.38 +              FE              .01000   CU              .01000
  125.39 +              AL              .97000   SI              .01000
  125.40 +    SILICON   VALUE           .38000   YIELD          1.00000
  125.41 +              FE              .03000   SI              .97000
  125.42 +RHS
  125.43 +    RHS1      YIELD       2000.00000   FE            60.00000
  125.44 +              CU           100.00000   MN            40.00000
  125.45 +              SI           300.00000
  125.46 +              MG            30.00000   AL          1500.00000
  125.47 +RANGES
  125.48 +    RNG1      SI            50.00000
  125.49 +BOUNDS
  125.50 + UP BND1      BIN1         200.00000
  125.51 + UP           BIN2        2500.00000
  125.52 + LO           BIN3         400.00000
  125.53 + UP           BIN3         800.00000
  125.54 + LO           BIN4         100.00000
  125.55 + UP           BIN4         700.00000
  125.56 + UP           BIN5        1500.00000
  125.57 +ENDATA
   126.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
   126.2 +++ b/deps/glpk/examples/prod.mod	Sun Nov 06 20:59:10 2011 +0100
   126.3 @@ -0,0 +1,331 @@
   126.4 +# PROD, a multiperiod production model
   126.5 +#
   126.6 +# References:
   126.7 +# Robert Fourer, David M. Gay and Brian W. Kernighan, "A Modeling Language
   126.8 +# for Mathematical Programming." Management Science 36 (1990) 519-554.
   126.9 +
  126.10 +###  PRODUCTION SETS AND PARAMETERS  ###
  126.11 +
  126.12 +set prd 'products';    # Members of the product group
  126.13 +
  126.14 +param pt 'production time' {prd} > 0;
  126.15 +
  126.16 +                        # Crew-hours to produce 1000 units
  126.17 +
  126.18 +param pc 'production cost' {prd} > 0;
  126.19 +
  126.20 +                        # Nominal production cost per 1000, used
  126.21 +                        # to compute inventory and shortage costs
  126.22 +
  126.23 +###  TIME PERIOD SETS AND PARAMETERS  ###
  126.24 +
  126.25 +param first > 0 integer;
  126.26 +                        # Index of first production period to be modeled
  126.27 +
  126.28 +param last > first integer;
  126.29 +
  126.30 +                        # Index of last production period to be modeled
  126.31 +
  126.32 +set time 'planning horizon' := first..last;
  126.33 +
  126.34 +###  EMPLOYMENT PARAMETERS  ###
  126.35 +
  126.36 +param cs 'crew size' > 0 integer;
  126.37 +
  126.38 +                        # Workers per crew
  126.39 +
  126.40 +param sl 'shift length' > 0;
  126.41 +
  126.42 +                        # Regular-time hours per shift
  126.43 +
  126.44 +param rtr 'regular time rate' > 0;
  126.45 +
  126.46 +                        # Wage per hour for regular-time labor
  126.47 +
  126.48 +param otr 'overtime rate' > rtr;
  126.49 +
  126.50 +                        # Wage per hour for overtime labor
  126.51 +
  126.52 +param iw 'initial workforce' >= 0 integer;
  126.53 +
  126.54 +                        # Crews employed at start of first period
  126.55 +
  126.56 +param dpp 'days per period' {time} > 0;
  126.57 +
  126.58 +                        # Regular working days in a production period
  126.59 +
  126.60 +param ol 'overtime limit' {time} >= 0;
  126.61 +
  126.62 +                        # Maximum crew-hours of overtime in a period
  126.63 +
  126.64 +param cmin 'crew minimum' {time} >= 0;
  126.65 +
  126.66 +                        # Lower limit on average employment in a period
  126.67 +
  126.68 +param cmax 'crew maximum' {t in time} >= cmin[t];
  126.69 +
  126.70 +                        # Upper limit on average employment in a period
  126.71 +
  126.72 +param hc 'hiring cost' {time} >= 0;
  126.73 +
  126.74 +                        # Penalty cost of hiring a crew
  126.75 +
  126.76 +param lc 'layoff cost' {time} >= 0;
  126.77 +
  126.78 +                        # Penalty cost of laying off a crew
  126.79 +
  126.80 +###  DEMAND PARAMETERS  ###
  126.81 +
  126.82 +param dem 'demand' {prd,first..last+1} >= 0;
  126.83 +
  126.84 +                        # Requirements (in 1000s)
  126.85 +                        # to be met from current production and inventory
  126.86 +
  126.87 +param pro 'promoted' {prd,first..last+1} logical;
  126.88 +
  126.89 +                        # true if product will be the subject
  126.90 +                        # of a special promotion in the period
  126.91 +
  126.92 +###  INVENTORY AND SHORTAGE PARAMETERS  ###
  126.93 +
  126.94 +param rir 'regular inventory ratio' >= 0;
  126.95 +
  126.96 +                        # Proportion of non-promoted demand
  126.97 +                        # that must be in inventory the previous period
  126.98 +
  126.99 +param pir 'promotional inventory ratio' >= 0;
 126.100 +
 126.101 +                        # Proportion of promoted demand
 126.102 +                        # that must be in inventory the previous period
 126.103 +
 126.104 +param life 'inventory lifetime' > 0 integer;
 126.105 +
 126.106 +                        # Upper limit on number of periods that
 126.107 +                        # any product may sit in inventory
 126.108 +
 126.109 +param cri 'inventory cost ratio' {prd} > 0;
 126.110 +
 126.111 +                        # Inventory cost per 1000 units is
 126.112 +                        # cri times nominal production cost
 126.113 +
 126.114 +param crs 'shortage cost ratio' {prd} > 0;
 126.115 +
 126.116 +                        # Shortage cost per 1000 units is
 126.117 +                        # crs times nominal production cost
 126.118 +
 126.119 +param iinv 'initial inventory' {prd} >= 0;
 126.120 +
 126.121 +                        # Inventory at start of first period; age unknown
 126.122 +
 126.123 +param iil 'initial inventory left' {p in prd, t in time}
 126.124 +              := iinv[p] less sum {v in first..t} dem[p,v];
 126.125 +
 126.126 +                        # Initial inventory still available for allocation
 126.127 +                        # at end of period t
 126.128 +
 126.129 +param minv 'minimum inventory' {p in prd, t in time}
 126.130 +              := dem[p,t+1] * (if pro[p,t+1] then pir else rir);
 126.131 +
 126.132 +                        # Lower limit on inventory at end of period t
 126.133 +
 126.134 +###  VARIABLES  ###
 126.135 +
 126.136 +var Crews{first-1..last} >= 0;
 126.137 +
 126.138 +                        # Average number of crews employed in each period
 126.139 +
 126.140 +var Hire{time} >= 0;    # Crews hired from previous to current period
 126.141 +
 126.142 +var Layoff{time} >= 0;  # Crews laid off from previous to current period
 126.143 +
 126.144 +var Rprd 'regular production' {prd,time} >= 0;
 126.145 +
 126.146 +                        # Production using regular-time labor, in 1000s
 126.147 +
 126.148 +var Oprd 'overtime production' {prd,time} >= 0;
 126.149 +
 126.150 +                        # Production using overtime labor, in 1000s
 126.151 +
 126.152 +var Inv 'inventory' {prd,time,1..life} >= 0;
 126.153 +
 126.154 +                        # Inv[p,t,a] is the amount of product p that is
 126.155 +                        # a periods old -- produced in period (t+1)-a --
 126.156 +                        # and still in storage at the end of period t
 126.157 +
 126.158 +var Short 'shortage' {prd,time} >= 0;
 126.159 +
 126.160 +                        # Accumulated unsatisfied demand at the end of period t
 126.161 +
 126.162 +###  OBJECTIVE  ###
 126.163 +
 126.164 +minimize cost:
 126.165 +
 126.166 +    sum {t in time} rtr * sl * dpp[t] * cs * Crews[t] +
 126.167 +    sum {t in time} hc[t] * Hire[t] +
 126.168 +    sum {t in time} lc[t] * Layoff[t] +
 126.169 +    sum {t in time, p in prd} otr * cs * pt[p] * Oprd[p,t] +
 126.170 +    sum {t in time, p in prd, a in 1..life} cri[p] * pc[p] * Inv[p,t,a] +
 126.171 +    sum {t in time, p in prd} crs[p] * pc[p] * Short[p,t];
 126.172 +
 126.173 +                        # Full regular wages for all crews employed, plus
 126.174 +                        # penalties for hiring and layoffs, plus
 126.175 +                        # wages for any overtime worked, plus
 126.176 +                        # inventory and shortage costs
 126.177 +
 126.178 +                        # (All other production costs are assumed
 126.179 +                        # to depend on initial inventory and on demands,
 126.180 +                        # and so are not included explicitly.)
 126.181 +
 126.182 +###  CONSTRAINTS  ###
 126.183 +
 126.184 +rlim 'regular-time limit' {t in time}:
 126.185 +
 126.186 +    sum {p in prd} pt[p] * Rprd[p,t] <= sl * dpp[t] * Crews[t];
 126.187 +
 126.188 +                        # Hours needed to accomplish all regular-time
 126.189 +                        # production in a period must not exceed
 126.190 +                        # hours available on all shifts
 126.191 +
 126.192 +olim 'overtime limit' {t in time}:
 126.193 +
 126.194 +    sum {p in prd} pt[p] * Oprd[p,t] <= ol[t];
 126.195 +
 126.196 +                        # Hours needed to accomplish all overtime
 126.197 +                        # production in a period must not exceed
 126.198 +                        # the specified overtime limit
 126.199 +
 126.200 +empl0 'initial crew level':  Crews[first-1] = iw;
 126.201 +
 126.202 +                        # Use given initial workforce
 126.203 +
 126.204 +empl 'crew levels' {t in time}:  Crews[t] = Crews[t-1] + Hire[t] - Layoff[t];
 126.205 +
 126.206 +                        # Workforce changes by hiring or layoffs
 126.207 +
 126.208 +emplbnd 'crew limits' {t in time}:  cmin[t] <= Crews[t] <= cmax[t];
 126.209 +
 126.210 +                        # Workforce must remain within specified bounds
 126.211 +
 126.212 +dreq1 'first demand requirement' {p in prd}:
 126.213 +
 126.214 +    Rprd[p,first] + Oprd[p,first] + Short[p,first]
 126.215 +                             - Inv[p,first,1] = dem[p,first] less iinv[p];
 126.216 +
 126.217 +dreq 'demand requirements' {p in prd, t in first+1..last}:
 126.218 +
 126.219 +    Rprd[p,t] + Oprd[p,t] + Short[p,t] - Short[p,t-1]
 126.220 +                          + sum {a in 1..life} (Inv[p,t-1,a] - Inv[p,t,a])
 126.221 +                                                  = dem[p,t] less iil[p,t-1];
 126.222 +
 126.223 +                        # Production plus increase in shortage plus
 126.224 +                        # decrease in inventory must equal demand
 126.225 +
 126.226 +ireq 'inventory requirements' {p in prd, t in time}:
 126.227 +
 126.228 +    sum {a in 1..life} Inv[p,t,a] + iil[p,t] >= minv[p,t];
 126.229 +
 126.230 +                        # Inventory in storage at end of period t
 126.231 +                        # must meet specified minimum
 126.232 +
 126.233 +izero 'impossible inventories' {p in prd, v in 1..life-1, a in v+1..life}:
 126.234 +
 126.235 +    Inv[p,first+v-1,a] = 0;
 126.236 +
 126.237 +                        # In the vth period (starting from first)
 126.238 +                        # no inventory may be more than v periods old
 126.239 +                        # (initial inventories are handled separately)
 126.240 +
 126.241 +ilim1 'new-inventory limits' {p in prd, t in time}:
 126.242 +
 126.243 +    Inv[p,t,1] <= Rprd[p,t] + Oprd[p,t];
 126.244 +
 126.245 +                        # New inventory cannot exceed
 126.246 +                        # production in the most recent period
 126.247 +
 126.248 +ilim 'inventory limits' {p in prd, t in first+1..last, a in 2..life}:
 126.249 +
 126.250 +    Inv[p,t,a] <= Inv[p,t-1,a-1];
 126.251 +
 126.252 +                        # Inventory left from period (t+1)-p
 126.253 +                        # can only decrease as time goes on
 126.254 +
 126.255 +###  DATA  ###
 126.256 +
 126.257 +data;
 126.258 +
 126.259 +set prd := 18REG 24REG 24PRO ;
 126.260 +
 126.261 +param first :=  1 ;
 126.262 +param last  := 13 ;
 126.263 +param life  :=  2 ;
 126.264 +
 126.265 +param cs := 18 ;
 126.266 +param sl :=  8 ;
 126.267 +param iw :=  8 ;
 126.268 +
 126.269 +param rtr := 16.00 ;
 126.270 +param otr := 43.85 ;
 126.271 +param rir :=  0.75 ;
 126.272 +param pir :=  0.80 ;
 126.273 +
 126.274 +param :         pt       pc        cri       crs      iinv   :=
 126.275 +
 126.276 +  18REG      1.194     2304.     0.015     1.100      82.0
 126.277 +  24REG      1.509     2920.     0.015     1.100     792.2
 126.278 +  24PRO      1.509     2910.     0.015     1.100       0.0   ;
 126.279 +
 126.280 +param :     dpp        ol      cmin      cmax        hc        lc   :=
 126.281 +
 126.282 +  1        19.5      96.0       0.0       8.0      7500      7500
 126.283 +  2        19.0      96.0       0.0       8.0      7500      7500
 126.284 +  3        20.0      96.0       0.0       8.0      7500      7500
 126.285 +  4        19.0      96.0       0.0       8.0      7500      7500
 126.286 +  5        19.5      96.0       0.0       8.0     15000     15000
 126.287 +  6        19.0      96.0       0.0       8.0     15000     15000
 126.288 +  7        19.0      96.0       0.0       8.0     15000     15000
 126.289 +  8        20.0      96.0       0.0       8.0     15000     15000
 126.290 +  9        19.0      96.0       0.0       8.0     15000     15000
 126.291 + 10        20.0      96.0       0.0       8.0     15000     15000
 126.292 + 11        20.0      96.0       0.0       8.0      7500      7500
 126.293 + 12        18.0      96.0       0.0       8.0      7500      7500
 126.294 + 13        18.0      96.0       0.0       8.0      7500      7500   ;
 126.295 +
 126.296 +param dem (tr) :
 126.297 +
 126.298 +          18REG     24REG     24PRO   :=
 126.299 +
 126.300 +  1        63.8    1212.0       0.0
 126.301 +  2        76.0     306.2       0.0
 126.302 +  3        88.4     319.0       0.0
 126.303 +  4       913.8     208.4       0.0
 126.304 +  5       115.0     298.0       0.0
 126.305 +  6       133.8     328.2       0.0
 126.306 +  7        79.6     959.6       0.0
 126.307 +  8       111.0     257.6       0.0
 126.308 +  9       121.6     335.6       0.0
 126.309 + 10       470.0     118.0    1102.0
 126.310 + 11        78.4     284.8       0.0
 126.311 + 12        99.4     970.0       0.0
 126.312 + 13       140.4     343.8       0.0
 126.313 + 14        63.8    1212.0       0.0   ;
 126.314 +
 126.315 +param pro (tr) :
 126.316 +
 126.317 +          18REG     24REG     24PRO   :=
 126.318 +
 126.319 +  1           0         1         0
 126.320 +  2           0         0         0
 126.321 +  3           0         0         0
 126.322 +  4           1         0         0
 126.323 +  5           0         0         0
 126.324 +  6           0         0         0
 126.325 +  7           0         1         0
 126.326 +  8           0         0         0
 126.327 +  9           0         0         0
 126.328 + 10           1         0         1
 126.329 + 11           0         0         0
 126.330 + 12           0         0         0
 126.331 + 13           0         1         0
 126.332 + 14           0         1         0   ;
 126.333 +
 126.334 +end;
   127.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
   127.2 +++ b/deps/glpk/examples/qfit.mod	Sun Nov 06 20:59:10 2011 +0100
   127.3 @@ -0,0 +1,49 @@
   127.4 +/*Quadratic Curve Fitting Solution
   127.5 +
   127.6 +  Find a plausable quadratic fit to a sample of points
   127.7 +
   127.8 +  Nigel_Galloway@operamail.com
   127.9 +  February 1st., 2009
  127.10 +*/
  127.11 +set Sample;
  127.12 +param Sx {z in Sample};
  127.13 +param Sy {z in Sample};
  127.14 +
  127.15 +var a;
  127.16 +var b;
  127.17 +var c;
  127.18 +
  127.19 +equalz1 :sum{z in Sample} a*Sx[z]*Sx[z]*Sx[z]*Sx[z] + sum{z in Sample} b*Sx[z]*Sx[z]*Sx[z] + sum{z in Sample} c*Sx[z]*Sx[z] = sum{z in Sample} Sy[z]*Sx[z]*Sx[z];
  127.20 +equalz2 :sum{z in Sample} a*Sx[z]*Sx[z]*Sx[z] + sum{z in Sample} b*Sx[z]*Sx[z] + sum{z in Sample} c*Sx[z] = sum{z in Sample} Sy[z]*Sx[z];
  127.21 +equalz3 :sum{z in Sample} a*Sx[z]*Sx[z] + sum{z in Sample} b*Sx[z] + sum{z in Sample} c = sum{z in Sample} Sy[z];
  127.22 +
  127.23 +solve;
  127.24 +
  127.25 +printf "\nbest quadratic fit is:\n\ty = %f %s %fx %s %fx^2\n\n", c, if b < 0 then "-" else "+", abs(b), if a < 0 then "-" else "+", abs(a);
  127.26 +
  127.27 +data;
  127.28 +
  127.29 +param:
  127.30 +Sample:   Sx    Sy :=
  127.31 +  1         0    1
  127.32 +  2       0.5  0.9
  127.33 +  3         1  0.7
  127.34 +  4       1.5  1.5
  127.35 +  5       1.9    2
  127.36 +  6       2.5  2.4
  127.37 +  7         3  3.2
  127.38 +  8       3.5    2
  127.39 +  9         4  2.7
  127.40 + 10       4.5  3.5
  127.41 + 11         5    1
  127.42 + 12       5.5    4
  127.43 + 13         6  3.6
  127.44 + 14       6.6  2.7
  127.45 + 15         7  5.7
  127.46 + 16       7.6  4.6
  127.47 + 17       8.5    6
  127.48 + 18         9  6.8
  127.49 + 19        10  7.3
  127.50 +;
  127.51 +
  127.52 +end;
   128.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
   128.2 +++ b/deps/glpk/examples/queens.mod	Sun Nov 06 20:59:10 2011 +0100
   128.3 @@ -0,0 +1,41 @@
   128.4 +/* QUEENS, a classic combinatorial optimization problem */
   128.5 +
   128.6 +/* Written in GNU MathProg by Andrew Makhorin <mao@gnu.org> */
   128.7 +
   128.8 +/* The Queens Problem is to place as many queens as possible on the 8x8
   128.9 +   (or more generally, nxn) chess board in a way that they do not fight
  128.10 +   each other. This problem is probably as old as the chess game itself,
  128.11 +   and thus its origin is not known, but it is known that Gauss studied
  128.12 +   this problem. */
  128.13 +
  128.14 +param n, integer, > 0, default 8;
  128.15 +/* size of the chess board */
  128.16 +
  128.17 +var x{1..n, 1..n}, binary;
  128.18 +/* x[i,j] = 1 means that a queen is placed in square [i,j] */
  128.19 +
  128.20 +s.t. a{i in 1..n}: sum{j in 1..n} x[i,j] <= 1;
  128.21 +/* at most one queen can be placed in each row */
  128.22 +
  128.23 +s.t. b{j in 1..n}: sum{i in 1..n} x[i,j] <= 1;
  128.24 +/* at most one queen can be placed in each column */
  128.25 +
  128.26 +s.t. c{k in 2-n..n-2}: sum{i in 1..n, j in 1..n: i-j == k} x[i,j] <= 1;
  128.27 +/* at most one queen can be placed in each "\"-diagonal */
  128.28 +
  128.29 +s.t. d{k in 3..n+n-1}: sum{i in 1..n, j in 1..n: i+j == k} x[i,j] <= 1;
  128.30 +/* at most one queen can be placed in each "/"-diagonal */
  128.31 +
  128.32 +maximize obj: sum{i in 1..n, j in 1..n} x[i,j];
  128.33 +/* objective is to place as many queens as possible */
  128.34 +
  128.35 +/* solve the problem */
  128.36 +solve;
  128.37 +
  128.38 +/* and print its optimal solution */
  128.39 +for {i in 1..n}
  128.40 +{  for {j in 1..n} printf " %s", if x[i,j] then "Q" else ".";
  128.41 +   printf("\n");
  128.42 +}
  128.43 +
  128.44 +end;
   129.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
   129.2 +++ b/deps/glpk/examples/samp1.mps	Sun Nov 06 20:59:10 2011 +0100
   129.3 @@ -0,0 +1,29 @@
   129.4 +NAME          SAMP1
   129.5 +ROWS
   129.6 + N  Z
   129.7 + G  R1
   129.8 + G  R2
   129.9 + G  R3
  129.10 +COLUMNS
  129.11 +    X1        R1                2.0    R2                 1.0
  129.12 +    X1        R3                5.0    Z                  3.0
  129.13 +    MARK0001  'MARKER'                 'INTORG'
  129.14 +    X2        R1               -1.0    R2                -1.0
  129.15 +    X2        R3                3.0    Z                  7.0
  129.16 +    X3        R1                1.0    R2                -6.0
  129.17 +    X3        Z                -1.0
  129.18 +    MARK0002  'MARKER'                 'INTEND'
  129.19 +    X4        R1               -1.0    R2                 4.0
  129.20 +    X4        R3                1.0    Z                  1.0
  129.21 +RHS
  129.22 +    RHS1      R1                1.0
  129.23 +    RHS1      R2                8.0
  129.24 +    RHS1      R3                5.0
  129.25 +BOUNDS
  129.26 + UP BND1      X1                4.0
  129.27 + LO BND1      X2                2.0
  129.28 + UP BND1      X2                5.0
  129.29 + UP BND1      X3                1.0
  129.30 + LO BND1      X4                3.0
  129.31 + UP BND1      X4                8.0
  129.32 +ENDATA
   130.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
   130.2 +++ b/deps/glpk/examples/samp2.mps	Sun Nov 06 20:59:10 2011 +0100
   130.3 @@ -0,0 +1,27 @@
   130.4 +NAME          SAMP2
   130.5 +ROWS
   130.6 + N  Z
   130.7 + G  R1
   130.8 + G  R2
   130.9 + G  R3
  130.10 +COLUMNS
  130.11 +    X1        R1                2.0    R2                 1.0
  130.12 +    X1        R3                5.0    Z                  3.0
  130.13 +    X2        R1               -1.0    R2                -1.0
  130.14 +    X2        R3                3.0    Z                  7.0
  130.15 +    X3        R1                1.0    R2                -6.0
  130.16 +    X3        Z                -1.0
  130.17 +    X4        R1               -1.0    R2                 4.0
  130.18 +    X4        R3                1.0    Z                  1.0
  130.19 +RHS
  130.20 +    RHS1      R1                1.0
  130.21 +    RHS1      R2                8.0
  130.22 +    RHS1      R3                5.0
  130.23 +BOUNDS
  130.24 + UP BND1      X1                4.0
  130.25 + LO BND1      X2                2.0
  130.26 + UI BND1      X2                5.0
  130.27 + BV BND1      X3
  130.28 + LO BND1      X4                3.0
  130.29 + UP BND1      X4                8.0
  130.30 +ENDATA
   131.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
   131.2 +++ b/deps/glpk/examples/sample.asn	Sun Nov 06 20:59:10 2011 +0100
   131.3 @@ -0,0 +1,40 @@
   131.4 +c sample.asn
   131.5 +c
   131.6 +c This is an example of the assignment problem data
   131.7 +c in DIMACS format.
   131.8 +c
   131.9 +p asn 17 22
  131.10 +c
  131.11 +n 1
  131.12 +n 2
  131.13 +n 3
  131.14 +n 4
  131.15 +n 5
  131.16 +n 6
  131.17 +n 7
  131.18 +n 8
  131.19 +c
  131.20 +a 1  9 13
  131.21 +a 1 10 21
  131.22 +a 1 12 20
  131.23 +a 2 10 12
  131.24 +a 2 12  8
  131.25 +a 2 13 26
  131.26 +a 3 11 22
  131.27 +a 3 13 11
  131.28 +a 4  9 12
  131.29 +a 4 12 36
  131.30 +a 4 14 25
  131.31 +a 5 11 41
  131.32 +a 5 12 40
  131.33 +a 5 13 11
  131.34 +a 5 14  4
  131.35 +a 5 15  8
  131.36 +a 5 16 35
  131.37 +a 5 17 32
  131.38 +a 6  9 13
  131.39 +a 7 10 19
  131.40 +a 8 10 39
  131.41 +a 8 11 15
  131.42 +c
  131.43 +c eof
   132.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
   132.2 +++ b/deps/glpk/examples/sample.c	Sun Nov 06 20:59:10 2011 +0100
   132.3 @@ -0,0 +1,52 @@
   132.4 +/* sample.c */
   132.5 +
   132.6 +#include <stdio.h>
   132.7 +#include <stdlib.h>
   132.8 +#include <glpk.h>
   132.9 +
  132.10 +int main(void)
  132.11 +{     glp_prob *lp;
  132.12 +      int ia[1+1000], ja[1+1000];
  132.13 +      double ar[1+1000], z, x1, x2, x3;
  132.14 +s1:   lp = glp_create_prob();
  132.15 +s2:   glp_set_prob_name(lp, "sample");
  132.16 +s3:   glp_set_obj_dir(lp, GLP_MAX);
  132.17 +s4:   glp_add_rows(lp, 3);
  132.18 +s5:   glp_set_row_name(lp, 1, "p");
  132.19 +s6:   glp_set_row_bnds(lp, 1, GLP_UP, 0.0, 100.0);
  132.20 +s7:   glp_set_row_name(lp, 2, "q");
  132.21 +s8:   glp_set_row_bnds(lp, 2, GLP_UP, 0.0, 600.0);
  132.22 +s9:   glp_set_row_name(lp, 3, "r");
  132.23 +s10:  glp_set_row_bnds(lp, 3, GLP_UP, 0.0, 300.0);
  132.24 +s11:  glp_add_cols(lp, 3);
  132.25 +s12:  glp_set_col_name(lp, 1, "x1");
  132.26 +s13:  glp_set_col_bnds(lp, 1, GLP_LO, 0.0, 0.0);
  132.27 +s14:  glp_set_obj_coef(lp, 1, 10.0);
  132.28 +s15:  glp_set_col_name(lp, 2, "x2");
  132.29 +s16:  glp_set_col_bnds(lp, 2, GLP_LO, 0.0, 0.0);
  132.30 +s17:  glp_set_obj_coef(lp, 2, 6.0);
  132.31 +s18:  glp_set_col_name(lp, 3, "x3");
  132.32 +s19:  glp_set_col_bnds(lp, 3, GLP_LO, 0.0, 0.0);
  132.33 +s20:  glp_set_obj_coef(lp, 3, 4.0);
  132.34 +s21:  ia[1] = 1, ja[1] = 1, ar[1] =  1.0; /* a[1,1] =  1 */
  132.35 +s22:  ia[2] = 1, ja[2] = 2, ar[2] =  1.0; /* a[1,2] =  1 */
  132.36 +s23:  ia[3] = 1, ja[3] = 3, ar[3] =  1.0; /* a[1,3] =  1 */
  132.37 +s24:  ia[4] = 2, ja[4] = 1, ar[4] = 10.0; /* a[2,1] = 10 */
  132.38 +s25:  ia[5] = 3, ja[5] = 1, ar[5] =  2.0; /* a[3,1] =  2 */
  132.39 +s26:  ia[6] = 2, ja[6] = 2, ar[6] =  4.0; /* a[2,2] =  4 */
  132.40 +s27:  ia[7] = 3, ja[7] = 2, ar[7] =  2.0; /* a[3,2] =  2 */
  132.41 +s28:  ia[8] = 2, ja[8] = 3, ar[8] =  5.0; /* a[2,3] =  5 */
  132.42 +s29:  ia[9] = 3, ja[9] = 3, ar[9] =  6.0; /* a[3,3] =  6 */
  132.43 +s30:  glp_load_matrix(lp, 9, ia, ja, ar);
  132.44 +s31:  glp_simplex(lp, NULL);
  132.45 +s32:  z = glp_get_obj_val(lp);
  132.46 +s33:  x1 = glp_get_col_prim(lp, 1);
  132.47 +s34:  x2 = glp_get_col_prim(lp, 2);
  132.48 +s35:  x3 = glp_get_col_prim(lp, 3);
  132.49 +s36:  printf("\nz = %g; x1 = %g; x2 = %g; x3 = %g\n",
  132.50 +         z, x1, x2, x3);
  132.51 +s37:  glp_delete_prob(lp);
  132.52 +      return 0;
  132.53 +}
  132.54 +
  132.55 +/* eof */
   133.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
   133.2 +++ b/deps/glpk/examples/sample.clq	Sun Nov 06 20:59:10 2011 +0100
   133.3 @@ -0,0 +1,30 @@
   133.4 +c sample.clq
   133.5 +c
   133.6 +c This is an example of the Maximum Weight Clique
   133.7 +c Problem in DIMACS clique/coloring format.
   133.8 +c
   133.9 +p edge 8 16
  133.10 +n 1 3
  133.11 +n 2 4
  133.12 +n 3 8
  133.13 +n 5 5
  133.14 +n 6 2
  133.15 +n 8 3
  133.16 +e 1 4
  133.17 +e 1 5
  133.18 +e 1 6
  133.19 +e 1 8
  133.20 +e 2 3
  133.21 +e 2 6
  133.22 +e 2 7
  133.23 +e 2 8
  133.24 +e 3 4
  133.25 +e 3 6
  133.26 +e 3 7
  133.27 +e 4 5
  133.28 +e 4 8
  133.29 +e 5 7
  133.30 +e 5 8
  133.31 +e 6 7
  133.32 +c
  133.33 +c eof
   134.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
   134.2 +++ b/deps/glpk/examples/sample.cnf	Sun Nov 06 20:59:10 2011 +0100
   134.3 @@ -0,0 +1,12 @@
   134.4 +c sample.cnf
   134.5 +c
   134.6 +c This is an example of the CNF-SAT problem data
   134.7 +c in DIMACS format.
   134.8 +c
   134.9 +p cnf 4 3
  134.10 +1 2 0
  134.11 +-4 3
  134.12 +-2 0
  134.13 +-1 4 0
  134.14 +c
  134.15 +c eof
   135.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
   135.2 +++ b/deps/glpk/examples/sample.col	Sun Nov 06 20:59:10 2011 +0100
   135.3 @@ -0,0 +1,30 @@
   135.4 +c sample.col
   135.5 +c
   135.6 +c This is an example of the vertex coloring problem data
   135.7 +c in DIMACS format.
   135.8 +c
   135.9 +p edge 10 21
  135.10 +c
  135.11 +e 1 2
  135.12 +e 1 6
  135.13 +e 1 7
  135.14 +e 1 10
  135.15 +e 2 3
  135.16 +e 2 7
  135.17 +e 2 8
  135.18 +e 3 4
  135.19 +e 3 8
  135.20 +e 4 5
  135.21 +e 4 8
  135.22 +e 4 9
  135.23 +e 5 6
  135.24 +e 5 9
  135.25 +e 5 10
  135.26 +e 6 10
  135.27 +e 7 8
  135.28 +e 7 10
  135.29 +e 8 9
  135.30 +e 8 10
  135.31 +e 9 10
  135.32 +c
  135.33 +c eof
   136.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
   136.2 +++ b/deps/glpk/examples/sample.max	Sun Nov 06 20:59:10 2011 +0100
   136.3 @@ -0,0 +1,26 @@
   136.4 +c sample.max
   136.5 +c
   136.6 +c This is an example of the maximum flow problem data
   136.7 +c in DIMACS format.
   136.8 +c
   136.9 +p max 9 14
  136.10 +c
  136.11 +n 1 s
  136.12 +n 9 t
  136.13 +c
  136.14 +a 1 2 14
  136.15 +a 1 4 23
  136.16 +a 2 3 10
  136.17 +a 2 4  9
  136.18 +a 3 5 12
  136.19 +a 3 8 18
  136.20 +a 4 5 26
  136.21 +a 5 2 11
  136.22 +a 5 6 25
  136.23 +a 5 7  4
  136.24 +a 6 7  7
  136.25 +a 6 8  8
  136.26 +a 7 9 15
  136.27 +a 8 9 20
  136.28 +c
  136.29 +c eof
   137.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
   137.2 +++ b/deps/glpk/examples/sample.min	Sun Nov 06 20:59:10 2011 +0100
   137.3 @@ -0,0 +1,26 @@
   137.4 +c sample.min
   137.5 +c
   137.6 +c This is an example of the minimum cost flow problem data
   137.7 +c in DIMACS format.
   137.8 +c
   137.9 +p min 9 14
  137.10 +c
  137.11 +n 1 20
  137.12 +n 9 -20
  137.13 +c
  137.14 +a 1 2 0 14 0
  137.15 +a 1 4 0 23 0
  137.16 +a 2 3 0 10 2
  137.17 +a 2 4 0  9 3
  137.18 +a 3 5 2 12 1
  137.19 +a 3 8 0 18 0
  137.20 +a 4 5 0 26 0
  137.21 +a 5 2 0 11 1
  137.22 +a 5 6 0 25 5
  137.23 +a 5 7 0  4 7
  137.24 +a 6 7 0  7 0
  137.25 +a 6 8 4  8 0
  137.26 +a 7 9 0 15 3
  137.27 +a 8 9 0 20 9
  137.28 +c
  137.29 +c eof
   138.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
   138.2 +++ b/deps/glpk/examples/sat.mod	Sun Nov 06 20:59:10 2011 +0100
   138.3 @@ -0,0 +1,201 @@
   138.4 +/* SAT, Satisfiability Problem */
   138.5 +
   138.6 +/* Written in GNU MathProg by Andrew Makhorin <mao@gnu.org> */
   138.7 +
   138.8 +param m, integer, > 0;
   138.9 +/* number of clauses */
  138.10 +
  138.11 +param n, integer, > 0;
  138.12 +/* number of variables */
  138.13 +
  138.14 +set C{1..m};
  138.15 +/* clauses; each clause C[i], i = 1, ..., m, is disjunction of some
  138.16 +   variables or their negations; in the data section each clause is
  138.17 +   coded as a set of indices of corresponding variables, where negative
  138.18 +   indices mean negation; for example, the clause (x3 or not x7 or x11)
  138.19 +   is coded as the set { 3, -7, 11 } */
  138.20 +
  138.21 +var x{1..n}, binary;
  138.22 +/* main variables */
  138.23 +
  138.24 +/* To solve the satisfiability problem means to determine all variables
  138.25 +   x[j] such that conjunction of all clauses C[1] and ... and C[m] takes
  138.26 +   on the value true, i.e. all clauses are satisfied.
  138.27 +
  138.28 +   Let the clause C[i] be (t or t' or ... or t''), where t, t', ..., t''
  138.29 +   are either variables or their negations. The condition of satisfying
  138.30 +   C[i] can be most naturally written as:
  138.31 +
  138.32 +      t + t' + ... + t'' >= 1,                                       (1)
  138.33 +
  138.34 +   where t, t', t'' have to be replaced by either x[j] or (1 - x[j]).
  138.35 +   The formulation (1) leads to the mip problem with no objective, i.e.
  138.36 +   to a feasibility problem.
  138.37 +
  138.38 +   Another, more practical way is to write the condition for C[i] as:
  138.39 +
  138.40 +      t + t' + ... + t'' + y[i] >= 1,                                (2)
  138.41 +
  138.42 +   where y[i] is an auxiliary binary variable, and minimize the sum of
  138.43 +   y[i]. If the sum is zero, all y[i] are also zero, and therefore all
  138.44 +   clauses are satisfied. If the sum is minimal but non-zero, its value
  138.45 +   shows the number of clauses which cannot be satisfied. */
  138.46 +
  138.47 +var y{1..m}, binary, >= 0;
  138.48 +/* auxiliary variables */
  138.49 +
  138.50 +s.t. c{i in 1..m}:
  138.51 +      sum{j in C[i]} (if j > 0 then x[j] else (1 - x[-j])) + y[i] >= 1;
  138.52 +/* the condition (2) */
  138.53 +
  138.54 +minimize unsat: sum{i in 1..m} y[i];
  138.55 +/* number of unsatisfied clauses */
  138.56 +
  138.57 +data;
  138.58 +
  138.59 +/* These data correspond to the instance hole6 (pigeon hole problem for
  138.60 +   6 holes) from SATLIB, the Satisfiability Library, which is part of
  138.61 +   the collection at the Forschungsinstitut fuer anwendungsorientierte
  138.62 +   Wissensverarbeitung in Ulm Germany */
  138.63 +
  138.64 +/* The optimal solution is 1 (one clause cannot be satisfied) */
  138.65 +
  138.66 +param m := 133;
  138.67 +
  138.68 +param n := 42;
  138.69 +
  138.70 +set C[1] := -1 -7;
  138.71 +set C[2] := -1 -13;
  138.72 +set C[3] := -1 -19;
  138.73 +set C[4] := -1 -25;
  138.74 +set C[5] := -1 -31;
  138.75 +set C[6] := -1 -37;
  138.76 +set C[7] := -7 -13;
  138.77 +set C[8] := -7 -19;
  138.78 +set C[9] := -7 -25;
  138.79 +set C[10] := -7 -31;
  138.80 +set C[11] := -7 -37;
  138.81 +set C[12] := -13 -19;
  138.82 +set C[13] := -13 -25;
  138.83 +set C[14] := -13 -31;
  138.84 +set C[15] := -13 -37;
  138.85 +set C[16] := -19 -25;
  138.86 +set C[17] := -19 -31;
  138.87 +set C[18] := -19 -37;
  138.88 +set C[19] := -25 -31;
  138.89 +set C[20] := -25 -37;
  138.90 +set C[21] := -31 -37;
  138.91 +set C[22] := -2 -8;
  138.92 +set C[23] := -2 -14;
  138.93 +set C[24] := -2 -20;
  138.94 +set C[25] := -2 -26;
  138.95 +set C[26] := -2 -32;
  138.96 +set C[27] := -2 -38;
  138.97 +set C[28] := -8 -14;
  138.98 +set C[29] := -8 -20;
  138.99 +set C[30] := -8 -26;
 138.100 +set C[31] := -8 -32;
 138.101 +set C[32] := -8 -38;
 138.102 +set C[33] := -14 -20;
 138.103 +set C[34] := -14 -26;
 138.104 +set C[35] := -14 -32;
 138.105 +set C[36] := -14 -38;
 138.106 +set C[37] := -20 -26;
 138.107 +set C[38] := -20 -32;
 138.108 +set C[39] := -20 -38;
 138.109 +set C[40] := -26 -32;
 138.110 +set C[41] := -26 -38;
 138.111 +set C[42] := -32 -38;
 138.112 +set C[43] := -3 -9;
 138.113 +set C[44] := -3 -15;
 138.114 +set C[45] := -3 -21;
 138.115 +set C[46] := -3 -27;
 138.116 +set C[47] := -3 -33;
 138.117 +set C[48] := -3 -39;
 138.118 +set C[49] := -9 -15;
 138.119 +set C[50] := -9 -21;
 138.120 +set C[51] := -9 -27;
 138.121 +set C[52] := -9 -33;
 138.122 +set C[53] := -9 -39;
 138.123 +set C[54] := -15 -21;
 138.124 +set C[55] := -15 -27;
 138.125 +set C[56] := -15 -33;
 138.126 +set C[57] := -15 -39;
 138.127 +set C[58] := -21 -27;
 138.128 +set C[59] := -21 -33;
 138.129 +set C[60] := -21 -39;
 138.130 +set C[61] := -27 -33;
 138.131 +set C[62] := -27 -39;
 138.132 +set C[63] := -33 -39;
 138.133 +set C[64] := -4 -10;
 138.134 +set C[65] := -4 -16;
 138.135 +set C[66] := -4 -22;
 138.136 +set C[67] := -4 -28;
 138.137 +set C[68] := -4 -34;
 138.138 +set C[69] := -4 -40;
 138.139 +set C[70] := -10 -16;
 138.140 +set C[71] := -10 -22;
 138.141 +set C[72] := -10 -28;
 138.142 +set C[73] := -10 -34;
 138.143 +set C[74] := -10 -40;
 138.144 +set C[75] := -16 -22;
 138.145 +set C[76] := -16 -28;
 138.146 +set C[77] := -16 -34;
 138.147 +set C[78] := -16 -40;
 138.148 +set C[79] := -22 -28;
 138.149 +set C[80] := -22 -34;
 138.150 +set C[81] := -22 -40;
 138.151 +set C[82] := -28 -34;
 138.152 +set C[83] := -28 -40;
 138.153 +set C[84] := -34 -40;
 138.154 +set C[85] := -5 -11;
 138.155 +set C[86] := -5 -17;
 138.156 +set C[87] := -5 -23;
 138.157 +set C[88] := -5 -29;
 138.158 +set C[89] := -5 -35;
 138.159 +set C[90] := -5 -41;
 138.160 +set C[91] := -11 -17;
 138.161 +set C[92] := -11 -23;
 138.162 +set C[93] := -11 -29;
 138.163 +set C[94] := -11 -35;
 138.164 +set C[95] := -11 -41;
 138.165 +set C[96] := -17 -23;
 138.166 +set C[97] := -17 -29;
 138.167 +set C[98] := -17 -35;
 138.168 +set C[99] := -17 -41;
 138.169 +set C[100] := -23 -29;
 138.170 +set C[101] := -23 -35;
 138.171 +set C[102] := -23 -41;
 138.172 +set C[103] := -29 -35;
 138.173 +set C[104] := -29 -41;
 138.174 +set C[105] := -35 -41;
 138.175 +set C[106] := -6 -12;
 138.176 +set C[107] := -6 -18;
 138.177 +set C[108] := -6 -24;
 138.178 +set C[109] := -6 -30;
 138.179 +set C[110] := -6 -36;
 138.180 +set C[111] := -6 -42;
 138.181 +set C[112] := -12 -18;
 138.182 +set C[113] := -12 -24;
 138.183 +set C[114] := -12 -30;
 138.184 +set C[115] := -12 -36;
 138.185 +set C[116] := -12 -42;
 138.186 +set C[117] := -18 -24;
 138.187 +set C[118] := -18 -30;
 138.188 +set C[119] := -18 -36;
 138.189 +set C[120] := -18 -42;
 138.190 +set C[121] := -24 -30;
 138.191 +set C[122] := -24 -36;
 138.192 +set C[123] := -24 -42;
 138.193 +set C[124] := -30 -36;
 138.194 +set C[125] := -30 -42;
 138.195 +set C[126] := -36 -42;
 138.196 +set C[127] := 6 5 4 3 2 1;
 138.197 +set C[128] := 12 11 10 9 8 7;
 138.198 +set C[129] := 18 17 16 15 14 13;
 138.199 +set C[130] := 24 23 22 21 20 19;
 138.200 +set C[131] := 30 29 28 27 26 25;
 138.201 +set C[132] := 36 35 34 33 32 31;
 138.202 +set C[133] := 42 41 40 39 38 37;
 138.203 +
 138.204 +end;
   139.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
   139.2 +++ b/deps/glpk/examples/shiftcover.mod	Sun Nov 06 20:59:10 2011 +0100
   139.3 @@ -0,0 +1,244 @@
   139.4 +/* File: shiftcover.mod */
   139.5 +
   139.6 +/* WORKFORCE SHIFT COVERAGE assignment problem */
   139.7 +
   139.8 +/* Written by Larry D'Agostino <larrydag -at- sbcglobal -dot- com>
   139.9 +     
  139.10 +     Maximize Productivity with Industrial Engineer and Operations Research Tools
  139.11 +     http://industrialengineertools.blogspot.com
  139.12 +
  139.13 +
  139.14 +/* The WORKFORCE SHIFT COVERAGE is an assigment problem that determines
  139.15 +   the schedule of crew given available time and shifts.  
  139.16 +   
  139.17 +   The objective is to cover the available time given hourly demand with the minimum 
  139.18 +    number of crew members.
  139.19 +   
  139.20 +    This is a set covering problem that is very common among finding crew
  139.21 +     and shift allocations.  Notice in the data section the workforce shift allocation
  139.22 +     per day of the week.*/
  139.23 +
  139.24 +
  139.25 +/* ----- Model PARAMTERS and SETS -----*/
  139.26 +
  139.27 +param numhrs;
  139.28 +/* number of hours of operations in a given day */
  139.29 +
  139.30 +param dys;
  139.31 +/* number of days in a week */
  139.32 +
  139.33 +set S;
  139.34 +/* set of crew shifts */
  139.35 +
  139.36 +set H := 1..numhrs;
  139.37 +/* set of hours of a day*/
  139.38 +
  139.39 +set D;
  139.40 +/* set of days of a week*/
  139.41 +
  139.42 +param dmnd{h in H, d in D};
  139.43 +/* demand for crew members given h hour and d day */
  139.44 +
  139.45 +param shifts{d in D, h in H, s in S};
  139.46 +/* shifts to assign to crew members given d day, h hour, and s shift schedule
  139.47 +
  139.48 +/*----- Model VARIABLES -----*/
  139.49 +
  139.50 +var crew{s in S}, integer, >=0;
  139.51 +/*  number of crew assigned to shift S */
  139.52 +
  139.53 +
  139.54 +/*----- Model CONSTRAINTS -----*/
  139.55 +
  139.56 +s.t. Coverage{h in H, d in D}: sum{s in S} crew[s]*shifts[d,h,s] >= dmnd[h,d];
  139.57 +/* number of crew to cover with a shift  given hourly demand and day */
  139.58 +
  139.59 +
  139.60 +/*----- Model OBJECTIVE -----*/
  139.61 +
  139.62 +minimize obj: sum{s in S} crew[s];
  139.63 +/* minimize number of crew to cover demand*/
  139.64 +
  139.65 +solve;
  139.66 +display crew;
  139.67 +
  139.68 +printf "\n";
  139.69 +printf "Total Crew: %3d\n\n", sum{s in S} crew[s];
  139.70 +
  139.71 +
  139.72 +
  139.73 +printf "\n\n";
  139.74 +printf "Weekly Crew Schedule\n\n";
  139.75 +printf "Hour ";
  139.76 +printf{d in D} "  %s  ", d;
  139.77 +printf "\n";
  139.78 +for {h in H} {
  139.79 +  printf " %2s  ",h;
  139.80 +  printf{d in D} " %3d   ", sum{s in S} crew[s]*shifts[d,h,s];
  139.81 +  printf "\n";
  139.82 +}
  139.83 +printf"\n";
  139.84 +
  139.85 +
  139.86 +
  139.87 +data;
  139.88 +
  139.89 +param numhrs := 16;
  139.90 +
  139.91 +set D := SUN, MON, TUE, WED, THU, FRI, SAT;
  139.92 +
  139.93 +set S := Sh1, Sh2, Sh3, Sh4, Sh5, Sh6, Sh7, Sh8, Sh9;
  139.94 +
  139.95 +param dmnd :   SUN  MON     TUE     WED     THU     FRI     SAT :=
  139.96 +1               0   3       3       4       3       2       0
  139.97 +2               0   14      14      16      14      12      12
  139.98 +3               0   24      24      27      24      20      15
  139.99 +4               0   28      28      32      28      23      15
 139.100 +5               0   33      33      37      33      24      16
 139.101 +6               0   34      34      38      34      24      15
 139.102 +7               0   35      35      39      35      25      11
 139.103 +8               0   35      35      40      35      27      0
 139.104 +9               0   34      34      39      34      25      0
 139.105 +10              0   31      31      35      31      24      0
 139.106 +11              2   24      24      27      24      25      0
 139.107 +12              3   19      19      21      19      21      0
 139.108 +13              2   24      24      27      24      13      0
 139.109 +14              2   16      16      18      16      0       0
 139.110 +15              0   7       7       7       7       0       0
 139.111 +16              0   5       5       5       5       0       0;
 139.112 +
 139.113 +
 139.114 +param shifts := 
 139.115 +['SUN',*,*]:
 139.116 +                   Sh1  Sh2  Sh3  Sh4  Sh5  Sh6  Sh7  Sh8  Sh9 :=
 139.117 +1                   0    0    0    0    0    0    0    0    0
 139.118 +2                   0    0    0    0    0    0    0    0    0
 139.119 +3                   0    0    0    0    0    0    0    0    0
 139.120 +4                   0    0    0    0    0    0    0    0    0
 139.121 +5                   0    0    0    0    0    0    0    0    0
 139.122 +6                   0    0    0    0    0    0    0    0    0
 139.123 +7                   0    0    0    0    0    0    0    0    0
 139.124 +8                   0    0    0    0    0    0    0    0    0
 139.125 +9                   0    0    0    0    0    0    0    0    0
 139.126 +10                  0    0    0    0    0    0    0    0    0
 139.127 +11                  0    0    0    0    0    0    0    0    1
 139.128 +12                  0    0    0    0    0    0    0    0    1
 139.129 +13                  0    0    0    0    0    0    0    0    1
 139.130 +14                  0    0    0    0    0    0    0    0    1
 139.131 +15                  0    0    0    0    0    0    0    0    0
 139.132 +16                  0    0    0    0    0    0    0    0    0
 139.133 +
 139.134 +
 139.135 +['MON',*,*]:
 139.136 +                   Sh1  Sh2  Sh3  Sh4  Sh5  Sh6  Sh7  Sh8  Sh9 :=
 139.137 +1                   1    0    0    0    0    0    0    0    0
 139.138 +2                   1    1    0    0    0    0    0    0    0
 139.139 +3                   1    1    1    0    0    0    0    0    0
 139.140 +4                   1    1    1    1    0    0    0    0    0
 139.141 +5                   0    1    1    1    1    0    0    0    0
 139.142 +6                   1    0    1    1    1    1    0    0    1
 139.143 +7                   1    1    0    1    1    1    1    0    1
 139.144 +8                   1    1    1    0    1    1    1    1    1
 139.145 +9                   1    1    1    1    0    1    1    1    1
 139.146 +10                  0    1    1    1    1    0    1    1    1
 139.147 +11                  0    0    1    1    1    1    0    1    0
 139.148 +12                  0    0    0    1    1    1    1    0    1
 139.149 +13                  0    0    0    0    1    1    1    1    1
 139.150 +14                  0    0    0    0    0    1    1    1    1
 139.151 +15                  0    0    0    0    0    0    1    1    1
 139.152 +16                  0    0    0    0    0    0    0    1    1
 139.153 +
 139.154 +['TUE',*,*]:
 139.155 +                   Sh1  Sh2  Sh3  Sh4  Sh5  Sh6  Sh7  Sh8  Sh9 :=
 139.156 +1                   1    0    0    0    0    0    0    0    0
 139.157 +2                   1    1    0    0    0    0    0    0    0
 139.158 +3                   1    1    1    0    0    0    0    0    0
 139.159 +4                   1    1    1    1    0    0    0    0    0
 139.160 +5                   0    1    1    1    1    0    0    0    0
 139.161 +6                   1    0    1    1    1    1    0    0    1
 139.162 +7                   1    1    0    1    1    1    1    0    1
 139.163 +8                   1    1    1    0    1    1    1    1    1
 139.164 +9                   1    1    1    1    0    1    1    1    1
 139.165 +10                  0    1    1    1    1    0    1    1    1
 139.166 +11                  0    0    1    1    1    1    0    1    0
 139.167 +12                  0    0    0    1    1    1    1    0    1
 139.168 +13                  0    0    0    0    1    1    1    1    1
 139.169 +14                  0    0    0    0    0    1    1    1    1
 139.170 +15                  0    0    0    0    0    0    1    1    1
 139.171 +16                  0    0    0    0    0    0    0    1    1
 139.172 +
 139.173 +['WED',*,*]:
 139.174 +                   Sh1  Sh2  Sh3  Sh4  Sh5  Sh6  Sh7  Sh8  Sh9 :=
 139.175 +1                   1    0    0    0    0    0    0    0    0
 139.176 +2                   1    1    0    0    0    0    0    0    0
 139.177 +3                   1    1    1    0    0    0    0    0    0
 139.178 +4                   1    1    1    1    0    0    0    0    0
 139.179 +5                   0    1    1    1    1    0    0    0    0
 139.180 +6                   1    0    1    1    1    1    0    0    1
 139.181 +7                   1    1    0    1    1    1    1    0    1
 139.182 +8                   1    1    1    0    1    1    1    1    1
 139.183 +9                   1    1    1    1    0    1    1    1    1
 139.184 +10                  0    1    1    1    1    0    1    1    1
 139.185 +11                  0    0    1    1    1    1    0    1    0
 139.186 +12                  0    0    0    1    1    1    1    0    1
 139.187 +13                  0    0    0    0    1    1    1    1    1
 139.188 +14                  0    0    0    0    0    1    1    1    1
 139.189 +15                  0    0    0    0    0    0    1    1    1
 139.190 +16                  0    0    0    0    0    0    0    1    1
 139.191 +
 139.192 +['THU',*,*]:
 139.193 +                   Sh1  Sh2  Sh3  Sh4  Sh5  Sh6  Sh7  Sh8  Sh9 :=
 139.194 +1                   1    0    0    0    0    0    0    0    0
 139.195 +2                   1    1    0    0    0    0    0    0    0
 139.196 +3                   1    1    1    0    0    0    0    0    0
 139.197 +4                   1    1    1    1    0    0    0    0    0
 139.198 +5                   0    1    1    1    1    0    0    0    0
 139.199 +6                   1    0    1    1    1    1    0    0    0
 139.200 +7                   1    1    0    1    1    1    1    0    0
 139.201 +8                   1    1    1    0    1    1    1    1    0
 139.202 +9                   1    1    1    1    0    1    1    1    0
 139.203 +10                  0    1    1    1    1    0    1    1    0
 139.204 +11                  0    0    1    1    1    1    0    1    0
 139.205 +12                  0    0    0    1    1    1    1    0    0
 139.206 +13                  0    0    0    0    1    1    1    1    0
 139.207 +14                  0    0    0    0    0    1    1    1    0
 139.208 +15                  0    0    0    0    0    0    1    1    0
 139.209 +16                  0    0    0    0    0    0    0    1    0
 139.210 +
 139.211 +['FRI',*,*]:
 139.212 +                   Sh1  Sh2  Sh3  Sh4  Sh5  Sh6  Sh7  Sh8  Sh9 :=
 139.213 +1                   1    0    0    0    0    0    0    0    0
 139.214 +2                   1    1    0    0    0    0    0    0    0
 139.215 +3                   1    1    1    0    0    0    0    0    0
 139.216 +4                   1    1    1    1    0    0    0    0    0
 139.217 +5                   0    1    1    1    1    0    0    0    0
 139.218 +6                   1    0    1    1    1    1    0    0    0
 139.219 +7                   1    1    0    1    1    1    1    0    0
 139.220 +8                   1    1    1    0    1    1    1    1    0
 139.221 +9                   1    1    1    1    0    1    1    1    0
 139.222 +10                  0    1    1    1    1    0    1    1    0
 139.223 +11                  0    0    1    1    1    1    0    1    0
 139.224 +12                  0    0    0    1    1    1    1    0    0
 139.225 +13                  0    0    0    0    1    1    1    1    0
 139.226 +14                  0    0    0    0    0    1    1    1    0
 139.227 +15                  0    0    0    0    0    0    1    1    0
 139.228 +16                  0    0    0    0    0    0    0    1    0
 139.229 +
 139.230 +['SAT',*,*]:
 139.231 +                   Sh1  Sh2  Sh3  Sh4  Sh5  Sh6  Sh7  Sh8  Sh9 :=
 139.232 +1                   0    0    0    0    0    0    0    0    0
 139.233 +2                   0    0    0    0    0    0    0    0    1
 139.234 +3                   0    0    0    0    0    0    0    0    1
 139.235 +4                   0    0    0    0    0    0    0    0    1
 139.236 +5                   0    0    0    0    0    0    0    0    1
 139.237 +6                   0    0    0    0    0    0    0    0    1
 139.238 +7                   0    0    0    0    0    0    0    0    1
 139.239 +8                   0    0    0    0    0    0    0    0    0
 139.240 +9                   0    0    0    0    0    0    0    0    0
 139.241 +10                  0    0    0    0    0    0    0    0    0
 139.242 +11                  0    0    0    0    0    0    0    0    0
 139.243 +12                  0    0    0    0    0    0    0    0    0
 139.244 +13                  0    0    0    0    0    0    0    0    0
 139.245 +14                  0    0    0    0    0    0    0    0    0
 139.246 +15                  0    0    0    0    0    0    0    0    0
 139.247 +16                  0    0    0    0    0    0    0    0    0;
   140.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
   140.2 +++ b/deps/glpk/examples/shikaku.mod	Sun Nov 06 20:59:10 2011 +0100
   140.3 @@ -0,0 +1,107 @@
   140.4 +/* A solver for the Japanese number-puzzle Shikaku
   140.5 + * http://en.wikipedia.org/wiki/Shikaku
   140.6 + *
   140.7 + * Sebastian Nowozin <nowozin@gmail.com>, 27th January 2009
   140.8 + */
   140.9 +
  140.10 +param ndim := 10;
  140.11 +set rows := 1..ndim;
  140.12 +set rows1 := 1..(ndim+1);
  140.13 +set cols := 1..ndim;
  140.14 +set cols1 := 1..(ndim+1);
  140.15 +param givens{rows, cols}, integer, >= 0, default 0;
  140.16 +
  140.17 +/* Set of vertices as (row,col) coordinates */
  140.18 +set V := { (i,j) in { rows, cols }: givens[i,j] != 0 };
  140.19 +
  140.20 +/* Set of all feasible boxes of the right size: only this boxes are possible.
  140.21 + * The box contains (i,j) and ranges from (k,l) to (m,n)
  140.22 + */
  140.23 +set B := { (i,j,k,l,m,n) in { V, rows, cols, rows1, cols1 }:
  140.24 +    i >= k and i < m and j >= l and j < n and   /* Contains (i,j) */
  140.25 +    ((m-k)*(n-l)) = givens[i,j] and /* Right size */
  140.26 +    card({ (s,t) in V: s >= k and s < m and t >= l and t < n }) = 1
  140.27 +        /* Contains only (i,j), no other number */
  140.28 +};
  140.29 +
  140.30 +var x{B}, binary;
  140.31 +
  140.32 +/* Cover each square exactly once */
  140.33 +s.t. cover_once{ (s,t) in { rows, cols } }:
  140.34 +    sum{(i,j,k,l,m,n) in B: s >= k and s < m and t >= l and t < n}
  140.35 +        x[i,j,k,l,m,n] = 1;
  140.36 +
  140.37 +minimize cost: 0;
  140.38 +
  140.39 +solve;
  140.40 +
  140.41 +/* Output solution graphically */
  140.42 +printf "\nSolution:\n";
  140.43 +for { row in rows1 } {
  140.44 +    for { col in cols1 } {
  140.45 +        printf{0..0: card({(i,j,k,l,m,n) in B:
  140.46 +                col >= l and col <= n and (row = k or row = m) and
  140.47 +                x[i,j,k,l,m,n] = 1}) > 0 and
  140.48 +            card({(i,j,k,l,m,n) in B:
  140.49 +                row >= k and row <= m and (col = l or col = n) and
  140.50 +                x[i,j,k,l,m,n] = 1}) > 0} "+";
  140.51 +        printf{0..0: card({(i,j,k,l,m,n) in B:
  140.52 +                col >= l and col <= n and (row = k or row = m) and
  140.53 +                x[i,j,k,l,m,n] = 1}) = 0 and
  140.54 +            card({(i,j,k,l,m,n) in B:
  140.55 +                row >= k and row <= m and (col = l or col = n) and
  140.56 +                x[i,j,k,l,m,n] = 1}) > 0} "|";
  140.57 +        printf{0..0: card({(i,j,k,l,m,n) in B:
  140.58 +                row >= k and row <= m and (col = l or col = n) and
  140.59 +                x[i,j,k,l,m,n] = 1}) = 0 and
  140.60 +            card({(i,j,k,l,m,n) in B:
  140.61 +                col >= l and col <= n and (row = k or row = m) and
  140.62 +                x[i,j,k,l,m,n] = 1}) > 0} "-";
  140.63 +        printf{0..0: card({(i,j,k,l,m,n) in B:
  140.64 +                row >= k and row <= m and (col = l or col = n) and
  140.65 +                x[i,j,k,l,m,n] = 1}) = 0 and
  140.66 +            card({(i,j,k,l,m,n) in B:
  140.67 +                col >= l and col <= n and (row = k or row = m) and
  140.68 +                x[i,j,k,l,m,n] = 1}) = 0} " ";
  140.69 +
  140.70 +        printf{0..0: card({(i,j,k,l,m,n) in B:
  140.71 +            col >= l and col < n and (row = k or row = m) and
  140.72 +            x[i,j,k,l,m,n] = 1}) > 0} "---";
  140.73 +        printf{0..0: card({(i,j,k,l,m,n) in B:
  140.74 +            col >= l and col < n and (row = k or row = m) and
  140.75 +            x[i,j,k,l,m,n] = 1}) = 0} "   ";
  140.76 +    }
  140.77 +    printf "\n";
  140.78 +
  140.79 +    for { (col,p) in { cols, 1 }: card({ s in rows: s = row }) = 1 } {
  140.80 +        printf{0..0: card({(i,j,k,l,m,n) in B:
  140.81 +            row >= k and row < m and (col = l or col = n) and
  140.82 +            x[i,j,k,l,m,n] = 1}) > 0} "|";
  140.83 +        printf{0..0: card({(i,j,k,l,m,n) in B:
  140.84 +            row >= k and row < m and (col = l or col = n) and
  140.85 +            x[i,j,k,l,m,n] = 1}) = 0} " ";
  140.86 +        printf{0..0: card({ (i,j) in V: i = row and j = col}) > 0} " %2d", givens[row,col];
  140.87 +        printf{0..0: card({ (i,j) in V: i = row and j = col}) = 0} "  .";
  140.88 +    }
  140.89 +    printf{0..0: card({ r in rows: r = row }) = 1} "|\n";
  140.90 +}
  140.91 +
  140.92 +data;
  140.93 +
  140.94 +/* This Shikaku is from
  140.95 + * http://www.emn.fr/x-info/sdemasse/gccat/KShikaku.html#uid5449
  140.96 + */
  140.97 +param givens : 1 2 3 4 5 6 7 8 9 10 :=
  140.98 +           1   9 . . . 12 . . 5 . .
  140.99 +           2   . . . . . . . . . .
 140.100 +           3   . . . . . . . . . 6
 140.101 +           4   8 . 6 . 8 . . . . .
 140.102 +           5   . . . . . . . . . .
 140.103 +           6   . . . . . . . . . .
 140.104 +           7   . . . . . 6 . 8 . 12
 140.105 +           8   4 . . . . . . . . .
 140.106 +           9   . . . . . . . . . .
 140.107 +          10   . . 3 . . 9 . . . 4
 140.108 +           ;
 140.109 +
 140.110 +end;
   141.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
   141.2 +++ b/deps/glpk/examples/sorting.mod	Sun Nov 06 20:59:10 2011 +0100
   141.3 @@ -0,0 +1,67 @@
   141.4 +/* sorting.mod - how to sort arrays in MathProg */
   141.5 +
   141.6 +/* Written in GNU MathProg by Andrew Makhorin <mao@gnu.org> */
   141.7 +
   141.8 +#  Sometimes it is necessary to print parameters or variables in the
   141.9 +#  order of ascending or descending their values. Suppose, for example,
  141.10 +#  that we have the following subscripted parameter:
  141.11 +
  141.12 +set I := 1..12;
  141.13 +
  141.14 +param a{i in I} := Uniform(2, 7);
  141.15 +
  141.16 +#  If we print all its members:
  141.17 +
  141.18 +printf{i in I} "a[%d] = %g\n", i, a[i];
  141.19 +
  141.20 +#  the output may look like follows:
  141.21 +#
  141.22 +#  a[1]  = 2.64156
  141.23 +#  a[2]  = 2.04798
  141.24 +#  a[3]  = 2.14843
  141.25 +#  a[4]  = 4.76896
  141.26 +#  a[5]  = 6.09132
  141.27 +#  a[6]  = 3.27780
  141.28 +#  a[7]  = 4.06113
  141.29 +#  a[8]  = 4.05898
  141.30 +#  a[9]  = 6.63120
  141.31 +#  a[10] = 6.50318
  141.32 +#  a[11] = 3.46065
  141.33 +#  a[12] = 4.69845
  141.34 +#
  141.35 +#  However, we would like the parameter members to appear in the order
  141.36 +#  of ascending their values.
  141.37 +#
  141.38 +#  Introduce the following auxiliary parameter:
  141.39 +
  141.40 +param pos{i in I} :=
  141.41 +      1 + card({j in I: a[j] < a[i] or a[j] = a[i] and j < i});
  141.42 +
  141.43 +#  where pos[i] = k means that in the sorted list member a[i] would
  141.44 +#  have k-th position, 1 <= k <= |I|. Then introduce another auxiliary
  141.45 +#  parameter:
  141.46 +
  141.47 +param ind{k in 1..card(I)} := sum{i in I: pos[i] = k} i;
  141.48 +
  141.49 +#  where ind[k] = i iff pos[k] = i.
  141.50 +#
  141.51 +#  Now, the following statement:
  141.52 +
  141.53 +printf{k in 1..card(I)} "a[%d] = %g\n", ind[k], a[ind[k]];
  141.54 +
  141.55 +#  prints the parameter members in the desired order:
  141.56 +#
  141.57 +#  a[2]  = 2.04798
  141.58 +#  a[3]  = 2.14843
  141.59 +#  a[1]  = 2.64156
  141.60 +#  a[6]  = 3.27780
  141.61 +#  a[11] = 3.46065
  141.62 +#  a[8]  = 4.05898
  141.63 +#  a[7]  = 4.06113
  141.64 +#  a[12] = 4.69845
  141.65 +#  a[4]  = 4.76896
  141.66 +#  a[5]  = 6.09132
  141.67 +#  a[10] = 6.50318
  141.68 +#  a[9]  = 6.63120
  141.69 +
  141.70 +end;
   142.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
   142.2 +++ b/deps/glpk/examples/spp.mod	Sun Nov 06 20:59:10 2011 +0100
   142.3 @@ -0,0 +1,67 @@
   142.4 +/* SPP, Shortest Path Problem */
   142.5 +
   142.6 +/* Written in GNU MathProg by Andrew Makhorin <mao@gnu.org> */
   142.7 +
   142.8 +/* Given a directed graph G = (V,E), its edge lengths c(i,j) for all
   142.9 +   (i,j) in E, and two nodes s, t in V, the Shortest Path Problem (SPP)
  142.10 +   is to find a directed path from s to t whose length is minimal. */
  142.11 +
  142.12 +param n, integer, > 0;
  142.13 +/* number of nodes */
  142.14 +
  142.15 +set E, within {i in 1..n, j in 1..n};
  142.16 +/* set of edges */
  142.17 +
  142.18 +param c{(i,j) in E};
  142.19 +/* c[i,j] is length of edge (i,j); note that edge lengths are allowed
  142.20 +   to be of any sign (positive, negative, or zero) */
  142.21 +
  142.22 +param s, in {1..n};
  142.23 +/* source node */
  142.24 +
  142.25 +param t, in {1..n};
  142.26 +/* target node */
  142.27 +
  142.28 +var x{(i,j) in E}, >= 0;
  142.29 +/* x[i,j] = 1 means that edge (i,j) belong to shortest path;
  142.30 +   x[i,j] = 0 means that edge (i,j) does not belong to shortest path;
  142.31 +   note that variables x[i,j] are binary, however, there is no need to
  142.32 +   declare them so due to the totally unimodular constraint matrix */
  142.33 +
  142.34 +s.t. r{i in 1..n}: sum{(j,i) in E} x[j,i] + (if i = s then 1) =
  142.35 +                   sum{(i,j) in E} x[i,j] + (if i = t then 1);
  142.36 +/* conservation conditions for unity flow from s to t; every feasible
  142.37 +   solution is a path from s to t */
  142.38 +
  142.39 +minimize Z: sum{(i,j) in E} c[i,j] * x[i,j];
  142.40 +/* objective function is the path length to be minimized */
  142.41 +
  142.42 +data;
  142.43 +
  142.44 +/* Optimal solution is 20 that corresponds to the following shortest
  142.45 +   path: s = 1 -> 2 -> 4 -> 8 -> 6 = t */
  142.46 +
  142.47 +param n := 8;
  142.48 +
  142.49 +param s := 1;
  142.50 +
  142.51 +param t := 6;
  142.52 +
  142.53 +param : E :   c :=
  142.54 +       1 2    1
  142.55 +       1 4    8
  142.56 +       1 7    6
  142.57 +       2 4    2
  142.58 +       3 2   14
  142.59 +       3 4   10
  142.60 +       3 5    6
  142.61 +       3 6   19
  142.62 +       4 5    8
  142.63 +       4 8   13
  142.64 +       5 8   12
  142.65 +       6 5    7
  142.66 +       7 4    5
  142.67 +       8 6    4
  142.68 +       8 7   10;
  142.69 +
  142.70 +end;
   143.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
   143.2 +++ b/deps/glpk/examples/spxsamp1.c	Sun Nov 06 20:59:10 2011 +0100
   143.3 @@ -0,0 +1,18 @@
   143.4 +/* spxsamp1.c */
   143.5 +
   143.6 +#include <stdio.h>
   143.7 +#include <stdlib.h>
   143.8 +#include <glpk.h>
   143.9 +
  143.10 +int main(void)
  143.11 +{     glp_prob *P;
  143.12 +      P = glp_create_prob();
  143.13 +      glp_read_mps(P, GLP_MPS_DECK, NULL, "25fv47.mps");
  143.14 +      glp_adv_basis(P, 0);
  143.15 +      glp_simplex(P, NULL);
  143.16 +      glp_print_sol(P, "25fv47.txt");
  143.17 +      glp_delete_prob(P);
  143.18 +      return 0;
  143.19 +}
  143.20 +
  143.21 +/* eof */
   144.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
   144.2 +++ b/deps/glpk/examples/spxsamp2.c	Sun Nov 06 20:59:10 2011 +0100
   144.3 @@ -0,0 +1,20 @@
   144.4 +/* spxsamp2.c */
   144.5 +
   144.6 +#include <stdio.h>
   144.7 +#include <stdlib.h>
   144.8 +#include <glpk.h>
   144.9 +
  144.10 +int main(void)
  144.11 +{     glp_prob *P;
  144.12 +      glp_smcp parm;
  144.13 +      P = glp_create_prob();
  144.14 +      glp_read_mps(P, GLP_MPS_DECK, NULL, "25fv47.mps");
  144.15 +      glp_init_smcp(&parm);
  144.16 +      parm.meth = GLP_DUAL;
  144.17 +      glp_simplex(P, &parm);
  144.18 +      glp_print_sol(P, "25fv47.txt");
  144.19 +      glp_delete_prob(P);
  144.20 +      return 0;
  144.21 +}
  144.22 +
  144.23 +/* eof */
   145.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
   145.2 +++ b/deps/glpk/examples/sql/README	Sun Nov 06 20:59:10 2011 +0100
   145.3 @@ -0,0 +1,5 @@
   145.4 +This subdirectory contains files which demonstrate using data tables
   145.5 +in MathProg models for MySQL and iODBC.
   145.6 +
   145.7 +Script mysql_setup.sh is used to load the data from the *.sql files to
   145.8 +a MySQL database. Change the username, if necessary.
   146.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
   146.2 +++ b/deps/glpk/examples/sql/mysql_setup.sh	Sun Nov 06 20:59:10 2011 +0100
   146.3 @@ -0,0 +1,6 @@
   146.4 +#!/bin/sh
   146.5 +# This file can be used to create database glpk in MySQL.
   146.6 +echo MySQL is called for user root. 
   146.7 +mysql -f -u root -p < sudoku.sql
   146.8 +echo MySQL is called for user root.
   146.9 +mysql -f -u root -p < transp.sql
   147.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
   147.2 +++ b/deps/glpk/examples/sql/sudoku.sql	Sun Nov 06 20:59:10 2011 +0100
   147.3 @@ -0,0 +1,101 @@
   147.4 +CREATE DATABASE glpk;
   147.5 +CREATE USER glpk@localhost IDENTIFIED BY 'gnu';
   147.6 +GRANT ALL PRIVILEGES ON glpk.* TO glpk@localhost;
   147.7 +USE glpk;
   147.8 +DROP TABLE sudoku;
   147.9 +CREATE TABLE sudoku (
  147.10 +  ID   INT ,
  147.11 +  COL  INT ,
  147.12 +  LIN  INT ,
  147.13 +  VAL  INT ,
  147.14 +  PRIMARY KEY ( ID, COL, LIN )
  147.15 +  );
  147.16 +DROP TABLE sudoku_solution;
  147.17 +CREATE TABLE sudoku_solution (
  147.18 +  ID   INT ,
  147.19 +  COL  INT ,
  147.20 +  LIN  INT ,
  147.21 +  VAL  INT ,
  147.22 +  PRIMARY KEY ( ID, COL, LIN )
  147.23 +  );
  147.24 +INSERT INTO sudoku (ID, COL, LIN, VAL) VALUES (1, 1, 1, 5);
  147.25 +INSERT INTO sudoku (ID, COL, LIN, VAL) VALUES (1, 1, 2, 0);
  147.26 +INSERT INTO sudoku (ID, COL, LIN, VAL) VALUES (1, 1, 3, 0);
  147.27 +INSERT INTO sudoku (ID, COL, LIN, VAL) VALUES (1, 1, 4, 0);
  147.28 +INSERT INTO sudoku (ID, COL, LIN, VAL) VALUES (1, 1, 5, 4);
  147.29 +INSERT INTO sudoku (ID, COL, LIN, VAL) VALUES (1, 1, 6, 0);
  147.30 +INSERT INTO sudoku (ID, COL, LIN, VAL) VALUES (1, 1, 7, 0);
  147.31 +INSERT INTO sudoku (ID, COL, LIN, VAL) VALUES (1, 1, 8, 0);
  147.32 +INSERT INTO sudoku (ID, COL, LIN, VAL) VALUES (1, 1, 9, 0);
  147.33 +INSERT INTO sudoku (ID, COL, LIN, VAL) VALUES (1, 2, 1, 0);
  147.34 +INSERT INTO sudoku (ID, COL, LIN, VAL) VALUES (1, 2, 2, 0);
  147.35 +INSERT INTO sudoku (ID, COL, LIN, VAL) VALUES (1, 2, 3, 3);
  147.36 +INSERT INTO sudoku (ID, COL, LIN, VAL) VALUES (1, 2, 4, 0);
  147.37 +INSERT INTO sudoku (ID, COL, LIN, VAL) VALUES (1, 2, 5, 0);
  147.38 +INSERT INTO sudoku (ID, COL, LIN, VAL) VALUES (1, 2, 6, 0);
  147.39 +INSERT INTO sudoku (ID, COL, LIN, VAL) VALUES (1, 2, 7, 6);
  147.40 +INSERT INTO sudoku (ID, COL, LIN, VAL) VALUES (1, 2, 8, 2);
  147.41 +INSERT INTO sudoku (ID, COL, LIN, VAL) VALUES (1, 2, 9, 0);
  147.42 +INSERT INTO sudoku (ID, COL, LIN, VAL) VALUES (1, 3, 1, 0);
  147.43 +INSERT INTO sudoku (ID, COL, LIN, VAL) VALUES (1, 3, 2, 0);
  147.44 +INSERT INTO sudoku (ID, COL, LIN, VAL) VALUES (1, 3, 3, 0);
  147.45 +INSERT INTO sudoku (ID, COL, LIN, VAL) VALUES (1, 3, 4, 0);
  147.46 +INSERT INTO sudoku (ID, COL, LIN, VAL) VALUES (1, 3, 5, 0);
  147.47 +INSERT INTO sudoku (ID, COL, LIN, VAL) VALUES (1, 3, 6, 9);
  147.48 +INSERT INTO sudoku (ID, COL, LIN, VAL) VALUES (1, 3, 7, 0);
  147.49 +INSERT INTO sudoku (ID, COL, LIN, VAL) VALUES (1, 3, 8, 0);
  147.50 +INSERT INTO sudoku (ID, COL, LIN, VAL) VALUES (1, 3, 9, 4);
  147.51 +INSERT INTO sudoku (ID, COL, LIN, VAL) VALUES (1, 4, 1, 0);
  147.52 +INSERT INTO sudoku (ID, COL, LIN, VAL) VALUES (1, 4, 2, 0);
  147.53 +INSERT INTO sudoku (ID, COL, LIN, VAL) VALUES (1, 4, 3, 6);
  147.54 +INSERT INTO sudoku (ID, COL, LIN, VAL) VALUES (1, 4, 4, 0);
  147.55 +INSERT INTO sudoku (ID, COL, LIN, VAL) VALUES (1, 4, 5, 0);
  147.56 +INSERT INTO sudoku (ID, COL, LIN, VAL) VALUES (1, 4, 6, 7);
  147.57 +INSERT INTO sudoku (ID, COL, LIN, VAL) VALUES (1, 4, 7, 2);
  147.58 +INSERT INTO sudoku (ID, COL, LIN, VAL) VALUES (1, 4, 8, 0);
  147.59 +INSERT INTO sudoku (ID, COL, LIN, VAL) VALUES (1, 4, 9, 0);
  147.60 +INSERT INTO sudoku (ID, COL, LIN, VAL) VALUES (1, 5, 1, 8);
  147.61 +INSERT INTO sudoku (ID, COL, LIN, VAL) VALUES (1, 5, 2, 1);
  147.62 +INSERT INTO sudoku (ID, COL, LIN, VAL) VALUES (1, 5, 3, 0);
  147.63 +INSERT INTO sudoku (ID, COL, LIN, VAL) VALUES (1, 5, 4, 0);
  147.64 +INSERT INTO sudoku (ID, COL, LIN, VAL) VALUES (1, 5, 5, 0);
  147.65 +INSERT INTO sudoku (ID, COL, LIN, VAL) VALUES (1, 5, 6, 0);
  147.66 +INSERT INTO sudoku (ID, COL, LIN, VAL) VALUES (1, 5, 7, 0);
  147.67 +INSERT INTO sudoku (ID, COL, LIN, VAL) VALUES (1, 5, 8, 4);
  147.68 +INSERT INTO sudoku (ID, COL, LIN, VAL) VALUES (1, 5, 9, 3);
  147.69 +INSERT INTO sudoku (ID, COL, LIN, VAL) VALUES (1, 6, 1, 0);
  147.70 +INSERT INTO sudoku (ID, COL, LIN, VAL) VALUES (1, 6, 2, 0);
  147.71 +INSERT INTO sudoku (ID, COL, LIN, VAL) VALUES (1, 6, 3, 9);
  147.72 +INSERT INTO sudoku (ID, COL, LIN, VAL) VALUES (1, 6, 4, 1);
  147.73 +INSERT INTO sudoku (ID, COL, LIN, VAL) VALUES (1, 6, 5, 0);
  147.74 +INSERT INTO sudoku (ID, COL, LIN, VAL) VALUES (1, 6, 6, 0);
  147.75 +INSERT INTO sudoku (ID, COL, LIN, VAL) VALUES (1, 6, 7, 0);
  147.76 +INSERT INTO sudoku (ID, COL, LIN, VAL) VALUES (1, 6, 8, 0);
  147.77 +INSERT INTO sudoku (ID, COL, LIN, VAL) VALUES (1, 6, 9, 0);
  147.78 +INSERT INTO sudoku (ID, COL, LIN, VAL) VALUES (1, 7, 1, 7);
  147.79 +INSERT INTO sudoku (ID, COL, LIN, VAL) VALUES (1, 7, 2, 0);
  147.80 +INSERT INTO sudoku (ID, COL, LIN, VAL) VALUES (1, 7, 3, 0);
  147.81 +INSERT INTO sudoku (ID, COL, LIN, VAL) VALUES (1, 7, 4, 5);
  147.82 +INSERT INTO sudoku (ID, COL, LIN, VAL) VALUES (1, 7, 5, 0);
  147.83 +INSERT INTO sudoku (ID, COL, LIN, VAL) VALUES (1, 7, 6, 0);
  147.84 +INSERT INTO sudoku (ID, COL, LIN, VAL) VALUES (1, 7, 7, 0);
  147.85 +INSERT INTO sudoku (ID, COL, LIN, VAL) VALUES (1, 7, 8, 0);
  147.86 +INSERT INTO sudoku (ID, COL, LIN, VAL) VALUES (1, 7, 9, 0);
  147.87 +INSERT INTO sudoku (ID, COL, LIN, VAL) VALUES (1, 8, 1, 0);
  147.88 +INSERT INTO sudoku (ID, COL, LIN, VAL) VALUES (1, 8, 2, 9);
  147.89 +INSERT INTO sudoku (ID, COL, LIN, VAL) VALUES (1, 8, 3, 2);
  147.90 +INSERT INTO sudoku (ID, COL, LIN, VAL) VALUES (1, 8, 4, 0);
  147.91 +INSERT INTO sudoku (ID, COL, LIN, VAL) VALUES (1, 8, 5, 0);
  147.92 +INSERT INTO sudoku (ID, COL, LIN, VAL) VALUES (1, 8, 6, 0);
  147.93 +INSERT INTO sudoku (ID, COL, LIN, VAL) VALUES (1, 8, 7, 8);
  147.94 +INSERT INTO sudoku (ID, COL, LIN, VAL) VALUES (1, 8, 8, 0);
  147.95 +INSERT INTO sudoku (ID, COL, LIN, VAL) VALUES (1, 8, 9, 0);
  147.96 +INSERT INTO sudoku (ID, COL, LIN, VAL) VALUES (1, 9, 1, 0);
  147.97 +INSERT INTO sudoku (ID, COL, LIN, VAL) VALUES (1, 9, 2, 0);
  147.98 +INSERT INTO sudoku (ID, COL, LIN, VAL) VALUES (1, 9, 3, 0);
  147.99 +INSERT INTO sudoku (ID, COL, LIN, VAL) VALUES (1, 9, 4, 0);
 147.100 +INSERT INTO sudoku (ID, COL, LIN, VAL) VALUES (1, 9, 5, 3);
 147.101 +INSERT INTO sudoku (ID, COL, LIN, VAL) VALUES (1, 9, 6, 0);
 147.102 +INSERT INTO sudoku (ID, COL, LIN, VAL) VALUES (1, 9, 7, 0);
 147.103 +INSERT INTO sudoku (ID, COL, LIN, VAL) VALUES (1, 9, 8, 0);
 147.104 +INSERT INTO sudoku (ID, COL, LIN, VAL) VALUES (1, 9, 9, 6);
   148.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
   148.2 +++ b/deps/glpk/examples/sql/sudoku_mysql.mod	Sun Nov 06 20:59:10 2011 +0100
   148.3 @@ -0,0 +1,113 @@
   148.4 +/* SUDOKU, Number Placement Puzzle */
   148.5 +
   148.6 +/* Written in GNU MathProg by Andrew Makhorin <mao@mai2.rcnet.ru> */
   148.7 +
   148.8 +/* This example shows how to use the table statement.
   148.9 +   The sudoku to be solves is read from file sudoku_in.csv.
  148.10 +   The solution is written to sudoku_out.csv.
  148.11 +   The file format is CSV as defined in
  148.12 +     RFC 4180 - Common Format and MIME Type for
  148.13 +     Comma-Separated Values (CSV) Files */
  148.14 +
  148.15 +/* Sudoku, also known as Number Place, is a logic-based placement
  148.16 +   puzzle. The aim of the canonical puzzle is to enter a numerical
  148.17 +   digit from 1 through 9 in each cell of a 9x9 grid made up of 3x3
  148.18 +   subgrids (called "regions"), starting with various digits given in
  148.19 +   some cells (the "givens"). Each row, column, and region must contain
  148.20 +   only one instance of each numeral.
  148.21 +
  148.22 +   Example:
  148.23 +
  148.24 +   +-------+-------+-------+
  148.25 +   | 5 3 . | . 7 . | . . . |
  148.26 +   | 6 . . | 1 9 5 | . . . |
  148.27 +   | . 9 8 | . . . | . 6 . |
  148.28 +   +-------+-------+-------+
  148.29 +   | 8 . . | . 6 . | . . 3 |
  148.30 +   | 4 . . | 8 . 3 | . . 1 |
  148.31 +   | 7 . . | . 2 . | . . 6 |
  148.32 +   +-------+-------+-------+
  148.33 +   | . 6 . | . . . | 2 8 . |
  148.34 +   | . . . | 4 1 9 | . . 5 |
  148.35 +   | . . . | . 8 . | . 7 9 |
  148.36 +   +-------+-------+-------+
  148.37 +
  148.38 +   (From Wikipedia, the free encyclopedia.) */
  148.39 +set fields dimen 2;
  148.40 +
  148.41 +param id;
  148.42 +
  148.43 +param givens{1..9, 1..9}, integer, >= 0, <= 9, default 0;
  148.44 +/* the "givens" */
  148.45 +
  148.46 +/*
  148.47 +table ti IN 'MySQL' 'Database=glpk;UID=glpk;PWD=gnu'
  148.48 +  'sudoku' :
  148.49 +  fields <- [COL, LIN], givens ~ VAL;
  148.50 +*/
  148.51 +table ti IN 'MySQL' 'Database=glpk;UID=glpk;PWD=gnu'
  148.52 +  'SELECT * FROM sudoku WHERE ID = ' & id :
  148.53 +  fields <- [COL, LIN], givens ~ VAL;
  148.54 +
  148.55 +var x{i in 1..9, j in 1..9, k in 1..9}, binary;
  148.56 +/* x[i,j,k] = 1 means cell [i,j] is assigned number k */
  148.57 +
  148.58 +s.t. fa{i in 1..9, j in 1..9, k in 1..9: givens[i,j] != 0}:
  148.59 +     x[i,j,k] = (if givens[i,j] = k then 1 else 0);
  148.60 +/* assign pre-defined numbers using the "givens" */
  148.61 +
  148.62 +s.t. fb{i in 1..9, j in 1..9}: sum{k in 1..9} x[i,j,k] = 1;
  148.63 +/* each cell must be assigned exactly one number */
  148.64 +
  148.65 +s.t. fc{i in 1..9, k in 1..9}: sum{j in 1..9} x[i,j,k] = 1;
  148.66 +/* cells in the same row must be assigned distinct numbers */
  148.67 +
  148.68 +s.t. fd{j in 1..9, k in 1..9}: sum{i in 1..9} x[i,j,k] = 1;
  148.69 +/* cells in the same column must be assigned distinct numbers */
  148.70 +
  148.71 +s.t. fe{I in 1..9 by 3, J in 1..9 by 3, k in 1..9}:
  148.72 +     sum{i in I..I+2, j in J..J+2} x[i,j,k] = 1;
  148.73 +/* cells in the same region must be assigned distinct numbers */
  148.74 +
  148.75 +/* there is no need for an objective function here */
  148.76 +
  148.77 +solve;
  148.78 +
  148.79 +table ta{(i,j) in fields} OUT
  148.80 +  'MySQL' 'Database=glpk;UID=glpk;PWD=gnu'
  148.81 +  'DELETE FROM sudoku_solution'
  148.82 +  'WHERE ID = ' & id & ';'
  148.83 +  'INSERT INTO sudoku_solution'
  148.84 +  '(ID, COL, LIN, VAL)'
  148.85 +  'VALUES(?, ?, ?, ?);' :
  148.86 +  id ~ ID, i ~ COL, j ~ LIN, (sum{k in 1..9} x[i,j,k] * k) ~ VAL;
  148.87 +
  148.88 +printf "\nSudoku to be solved\n";
  148.89 +for {i in 1..9}
  148.90 +{  for {0..0: i = 1 or i = 4 or i = 7}
  148.91 +     printf " +-------+-------+-------+\n";
  148.92 +   for {j in 1..9}
  148.93 +   {  for {0..0: j = 1 or j = 4 or j = 7} printf(" |");
  148.94 +      printf " %d", givens[i,j];
  148.95 +      for {0..0: j = 9} printf(" |\n");
  148.96 +   }
  148.97 +   for {0..0: i = 9}
  148.98 +   printf " +-------+-------+-------+\n";
  148.99 +   }
 148.100 +printf "\nSolution\n";
 148.101 +for {i in 1..9}
 148.102 +{  for {0..0: i = 1 or i = 4 or i = 7}
 148.103 +      printf " +-------+-------+-------+\n";
 148.104 +   for {j in 1..9}
 148.105 +   {  for {0..0: j = 1 or j = 4 or j = 7} printf(" |");
 148.106 +      printf " %d", sum{k in 1..9} x[i,j,k] * k;
 148.107 +      for {0..0: j = 9} printf(" |\n");
 148.108 +   }
 148.109 +   for {0..0: i = 9}
 148.110 +      printf " +-------+-------+-------+\n";
 148.111 +}
 148.112 +
 148.113 +data;
 148.114 +
 148.115 +param id := 1;
 148.116 +end;
   149.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
   149.2 +++ b/deps/glpk/examples/sql/sudoku_odbc.mod	Sun Nov 06 20:59:10 2011 +0100
   149.3 @@ -0,0 +1,111 @@
   149.4 +/* SUDOKU, Number Placement Puzzle */
   149.5 +
   149.6 +/* Written in GNU MathProg by Andrew Makhorin <mao@mai2.rcnet.ru> */
   149.7 +
   149.8 +/* This example shows how to use the table statement.
   149.9 +   The sudoku to be solves is read from file sudoku_in.csv.
  149.10 +   The solution is written to sudoku_out.csv.
  149.11 +   The file format is CSV as defined in
  149.12 +     RFC 4180 - Common Format and MIME Type for
  149.13 +     Comma-Separated Values (CSV) Files */
  149.14 +
  149.15 +/* Sudoku, also known as Number Place, is a logic-based placement
  149.16 +   puzzle. The aim of the canonical puzzle is to enter a numerical
  149.17 +   digit from 1 through 9 in each cell of a 9x9 grid made up of 3x3
  149.18 +   subgrids (called "regions"), starting with various digits given in
  149.19 +   some cells (the "givens"). Each row, column, and region must contain
  149.20 +   only one instance of each numeral.
  149.21 +
  149.22 +   Example:
  149.23 +
  149.24 +   +-------+-------+-------+
  149.25 +   | 5 3 . | . 7 . | . . . |
  149.26 +   | 6 . . | 1 9 5 | . . . |
  149.27 +   | . 9 8 | . . . | . 6 . |
  149.28 +   +-------+-------+-------+
  149.29 +   | 8 . . | . 6 . | . . 3 |
  149.30 +   | 4 . . | 8 . 3 | . . 1 |
  149.31 +   | 7 . . | . 2 . | . . 6 |
  149.32 +   +-------+-------+-------+
  149.33 +   | . 6 . | . . . | 2 8 . |
  149.34 +   | . . . | 4 1 9 | . . 5 |
  149.35 +   | . . . | . 8 . | . 7 9 |
  149.36 +   +-------+-------+-------+
  149.37 +
  149.38 +   (From Wikipedia, the free encyclopedia.) */
  149.39 +set fields dimen 2;
  149.40 +
  149.41 +param id;
  149.42 +
  149.43 +param givens{1..9, 1..9}, integer, >= 0, <= 9, default 0;
  149.44 +/* the "givens" */
  149.45 +
  149.46 +table ti IN 'iODBC'
  149.47 +  'DSN=glpk;UID=glpk;PWD=gnu'
  149.48 +  'SELECT * FROM sudoku'
  149.49 +  'WHERE ID = ' & id :
  149.50 +  fields <- [COL, LIN], givens ~ VAL;
  149.51 +
  149.52 +var x{i in 1..9, j in 1..9, k in 1..9}, binary;
  149.53 +/* x[i,j,k] = 1 means cell [i,j] is assigned number k */
  149.54 +
  149.55 +s.t. fa{i in 1..9, j in 1..9, k in 1..9: givens[i,j] != 0}:
  149.56 +     x[i,j,k] = (if givens[i,j] = k then 1 else 0);
  149.57 +/* assign pre-defined numbers using the "givens" */
  149.58 +
  149.59 +s.t. fb{i in 1..9, j in 1..9}: sum{k in 1..9} x[i,j,k] = 1;
  149.60 +/* each cell must be assigned exactly one number */
  149.61 +
  149.62 +s.t. fc{i in 1..9, k in 1..9}: sum{j in 1..9} x[i,j,k] = 1;
  149.63 +/* cells in the same row must be assigned distinct numbers */
  149.64 +
  149.65 +s.t. fd{j in 1..9, k in 1..9}: sum{i in 1..9} x[i,j,k] = 1;
  149.66 +/* cells in the same column must be assigned distinct numbers */
  149.67 +
  149.68 +s.t. fe{I in 1..9 by 3, J in 1..9 by 3, k in 1..9}:
  149.69 +     sum{i in I..I+2, j in J..J+2} x[i,j,k] = 1;
  149.70 +/* cells in the same region must be assigned distinct numbers */
  149.71 +
  149.72 +/* there is no need for an objective function here */
  149.73 +
  149.74 +
  149.75 +solve;
  149.76 +
  149.77 +table ta {(i, j) in {i1 in 1..9} cross {i2 in 1..9}} OUT
  149.78 +  'iODBC' 'DSN=glpk;UID=glpk;PWD=gnu'
  149.79 +  'DELETE FROM sudoku_solution'
  149.80 +  'WHERE ID = ' & id & ';'
  149.81 +  'INSERT INTO sudoku_solution'
  149.82 +  '(ID, COL, LIN, VAL)'
  149.83 +  'VALUES(?, ?, ?, ?);' :
  149.84 +  id ~ ID, i ~ COL, j ~ LIN, (sum{k in 1..9} x[i,j,k] * k) ~ VAL;
  149.85 +
  149.86 +printf "\nSudoku to be solved\n";
  149.87 +for {i in 1..9}
  149.88 +{  for {0..0: i = 1 or i = 4 or i = 7}
  149.89 +     printf " +-------+-------+-------+\n";
  149.90 +   for {j in 1..9}
  149.91 +   {  for {0..0: j = 1 or j = 4 or j = 7} printf(" |");
  149.92 +      printf " %d", givens[i,j];
  149.93 +      for {0..0: j = 9} printf(" |\n");
  149.94 +   }
  149.95 +   for {0..0: i = 9}
  149.96 +   printf " +-------+-------+-------+\n";
  149.97 +   }
  149.98 +printf "\nSolution\n";
  149.99 +for {i in 1..9}
 149.100 +{  for {0..0: i = 1 or i = 4 or i = 7}
 149.101 +      printf " +-------+-------+-------+\n";
 149.102 +   for {j in 1..9}
 149.103 +   {  for {0..0: j = 1 or j = 4 or j = 7} printf(" |");
 149.104 +      printf " %d", sum{k in 1..9} x[i,j,k] * k;
 149.105 +      for {0..0: j = 9} printf(" |\n");
 149.106 +   }
 149.107 +   for {0..0: i = 9}
 149.108 +      printf " +-------+-------+-------+\n";
 149.109 +}
 149.110 +
 149.111 +data;
 149.112 +
 149.113 +param id := 1;
 149.114 +end;
   150.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
   150.2 +++ b/deps/glpk/examples/sql/transp.sql	Sun Nov 06 20:59:10 2011 +0100
   150.3 @@ -0,0 +1,45 @@
   150.4 +CREATE DATABASE glpk;
   150.5 +CREATE USER glpk@localhost IDENTIFIED BY 'gnu';
   150.6 +GRANT ALL PRIVILEGES ON glpk.* TO glpk@localhost;
   150.7 +USE glpk;
   150.8 +# production capacity
   150.9 +DROP TABLE transp_capa;
  150.10 +CREATE TABLE transp_capa (
  150.11 +  PLANT TEXT(127),
  150.12 +  CAPA  REAL,
  150.13 +  PRIMARY KEY ( PLANT(127) )
  150.14 +  );
  150.15 +INSERT INTO transp_capa ( PLANT, CAPA ) VALUES ( 'Seattle',   350 );
  150.16 +INSERT INTO transp_capa ( PLANT, CAPA ) VALUES ( 'San Diego', 600 );
  150.17 +# demand
  150.18 +DROP TABLE transp_demand;
  150.19 +CREATE TABLE transp_demand (
  150.20 +  MARKET TEXT(127),
  150.21 +  DEMAND REAL,
  150.22 +  PRIMARY KEY ( MARKET(127) )
  150.23 +  );
  150.24 +INSERT INTO transp_demand ( MARKET, DEMAND ) VALUES ( 'New York', 325 );
  150.25 +INSERT INTO transp_demand ( MARKET, DEMAND ) VALUES ( 'Chicago', 300 );
  150.26 +INSERT INTO transp_demand ( MARKET, DEMAND ) VALUES ( 'Topeka', 275 );
  150.27 +# distance
  150.28 +DROP TABLE transp_dist;
  150.29 +CREATE TABLE transp_dist (
  150.30 +  LOC1 TEXT(127),
  150.31 +  LOC2 TEXT(127),
  150.32 +  DIST REAL,
  150.33 +  PRIMARY KEY ( LOC1(127), LOC2(127) )
  150.34 +  );
  150.35 +INSERT INTO transp_dist ( LOC1, LOC2, DIST ) VALUES ( 'Seattle',   'New York', 2.5 );
  150.36 +INSERT INTO transp_dist ( LOC1, LOC2, DIST ) VALUES ( 'Seattle',   'Chicago', 1.7 );
  150.37 +INSERT INTO transp_dist ( LOC1, LOC2, DIST ) VALUES ( 'Seattle',   'Topeka', 1.8 );
  150.38 +INSERT INTO transp_dist ( LOC1, LOC2, DIST ) VALUES ( 'San Diego', 'New York', 2.5 );
  150.39 +INSERT INTO transp_dist ( LOC1, LOC2, DIST ) VALUES ( 'San Diego', 'Chicago', 1.8 );
  150.40 +INSERT INTO transp_dist ( LOC1, LOC2, DIST ) VALUES ( 'San Diego', 'Topeka', 1.4 );
  150.41 +# result
  150.42 +DROP TABLE transp_result;
  150.43 +CREATE TABLE transp_result (
  150.44 +  LOC1     TEXT(127),
  150.45 +  LOC2     TEXT(127),
  150.46 +  QUANTITY REAL,
  150.47 +  PRIMARY KEY ( LOC1(127), LOC2(127) )
  150.48 +  );
   151.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
   151.2 +++ b/deps/glpk/examples/sql/transp_mysql.mod	Sun Nov 06 20:59:10 2011 +0100
   151.3 @@ -0,0 +1,71 @@
   151.4 +# A TRANSPORTATION PROBLEM
   151.5 +#
   151.6 +# This problem finds a least cost shipping schedule that meets
   151.7 +# requirements at markets and supplies at factories.
   151.8 +#
   151.9 +#  References:
  151.10 +#              Dantzig G B, "Linear Programming and Extensions."
  151.11 +#              Princeton University Press, Princeton, New Jersey, 1963,
  151.12 +#              Chapter 3-3.
  151.13 +
  151.14 +set I;
  151.15 +/* canning plants */
  151.16 +
  151.17 +param a{i in I};
  151.18 +/* capacity of plant i in cases */
  151.19 +
  151.20 +table plants IN "MySQL"
  151.21 +  'Database=glpk;UID=glpk;PWD=gnu'
  151.22 +  'SELECT PLANT, CAPA AS CAPACITY FROM transp_capa' :
  151.23 +   I <- [ PLANT ], a ~ CAPACITY;
  151.24 +
  151.25 +set J;
  151.26 +/* markets */
  151.27 +
  151.28 +param b{j in J};
  151.29 +/* demand at market j in cases */
  151.30 +
  151.31 +table markets IN "MySQL"
  151.32 +  'Database=glpk;UID=glpk;PWD=gnu'
  151.33 +  'transp_demand' :
  151.34 +  J <- [ MARKET ], b ~ DEMAND;
  151.35 +
  151.36 +param d{i in I, j in J};
  151.37 +/* distance in thousands of miles */
  151.38 +
  151.39 +table dist IN "MySQL"
  151.40 +  'Database=glpk;UID=glpk;PWD=gnu'
  151.41 +  'transp_dist' :
  151.42 +  [ LOC1, LOC2 ], d ~ DIST;
  151.43 +
  151.44 +param f;
  151.45 +/* freight in dollars per case per thousand miles */
  151.46 +
  151.47 +param c{i in I, j in J} := f * d[i,j] / 1000;
  151.48 +/* transport cost in thousands of dollars per case */
  151.49 +
  151.50 +var x{i in I, j in J} >= 0;
  151.51 +/* shipment quantities in cases */
  151.52 +
  151.53 +minimize cost: sum{i in I, j in J} c[i,j] * x[i,j];
  151.54 +/* total transportation costs in thousands of dollars */
  151.55 +
  151.56 +s.t. supply{i in I}: sum{j in J} x[i,j] <= a[i];
  151.57 +/* observe supply limit at plant i */
  151.58 +
  151.59 +s.t. demand{j in J}: sum{i in I} x[i,j] >= b[j];
  151.60 +/* satisfy demand at market j */
  151.61 +
  151.62 +solve;
  151.63 +
  151.64 +table result{i in I, j in J: x[i,j]} OUT "MySQL"
  151.65 +  'Database=glpk;UID=glpk;PWD=gnu'
  151.66 +  'DELETE FROM transp_result;'
  151.67 +  'INSERT INTO transp_result VALUES (?,?,?)' :
  151.68 +  i ~ LOC1, j ~ LOC2, x[i,j] ~ QUANTITY;
  151.69 +
  151.70 +data;
  151.71 +
  151.72 +param f := 90;
  151.73 +
  151.74 +end;
   152.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
   152.2 +++ b/deps/glpk/examples/sql/transp_odbc.mod	Sun Nov 06 20:59:10 2011 +0100
   152.3 @@ -0,0 +1,72 @@
   152.4 +# A TRANSPORTATION PROBLEM
   152.5 +#
   152.6 +# This problem finds a least cost shipping schedule that meets
   152.7 +# requirements at markets and supplies at factories.
   152.8 +#
   152.9 +#  References:
  152.10 +#              Dantzig G B, "Linear Programming and Extensions."
  152.11 +#              Princeton University Press, Princeton, New Jersey, 1963,
  152.12 +#              Chapter 3-3.
  152.13 +
  152.14 +set I;
  152.15 +/* canning plants */
  152.16 +
  152.17 +param a{i in I};
  152.18 +/* capacity of plant i in cases */
  152.19 +
  152.20 +table plants IN "iODBC"
  152.21 +  'DSN=glpk;UID=glpk;PWD=gnu'
  152.22 +  'SELECT PLANT, CAPA AS CAPACITY'
  152.23 +  'FROM transp_capa' :
  152.24 +   I <- [ PLANT ], a ~ CAPACITY;
  152.25 +
  152.26 +set J;
  152.27 +/* markets */
  152.28 +
  152.29 +param b{j in J};
  152.30 +/* demand at market j in cases */
  152.31 +
  152.32 +table markets IN "iODBC"
  152.33 +  'DSN=glpk;UID=glpk;PWD=gnu'
  152.34 +  'transp_demand' :
  152.35 +  J <- [ MARKET ], b ~ DEMAND;
  152.36 +
  152.37 +param d{i in I, j in J};
  152.38 +/* distance in thousands of miles */
  152.39 +
  152.40 +table dist IN "iODBC"
  152.41 +  'DSN=glpk;UID=glpk;PWD=gnu'
  152.42 +  'transp_dist' :
  152.43 +  [ LOC1, LOC2 ], d ~ DIST;
  152.44 +
  152.45 +param f;
  152.46 +/* freight in dollars per case per thousand miles */
  152.47 +
  152.48 +param c{i in I, j in J} := f * d[i,j] / 1000;
  152.49 +/* transport cost in thousands of dollars per case */
  152.50 +
  152.51 +var x{i in I, j in J} >= 0;
  152.52 +/* shipment quantities in cases */
  152.53 +
  152.54 +minimize cost: sum{i in I, j in J} c[i,j] * x[i,j];
  152.55 +/* total transportation costs in thousands of dollars */
  152.56 +
  152.57 +s.t. supply{i in I}: sum{j in J} x[i,j] <= a[i];
  152.58 +/* observe supply limit at plant i */
  152.59 +
  152.60 +s.t. demand{j in J}: sum{i in I} x[i,j] >= b[j];
  152.61 +/* satisfy demand at market j */
  152.62 +
  152.63 +solve;
  152.64 +
  152.65 +table result{i in I, j in J: x[i,j]} OUT "iODBC"
  152.66 +  'DSN=glpk;UID=glpk;PWD=gnu'
  152.67 +  'DELETE FROM transp_result;'
  152.68 +  'INSERT INTO transp_result VALUES (?,?,?)' :
  152.69 +  i ~ LOC1, j ~ LOC2, x[i,j] ~ QUANTITY;
  152.70 +
  152.71 +data;
  152.72 +
  152.73 +param f := 90;
  152.74 +
  152.75 +end;
   153.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
   153.2 +++ b/deps/glpk/examples/stigler.mod	Sun Nov 06 20:59:10 2011 +0100
   153.3 @@ -0,0 +1,411 @@
   153.4 +/* STIGLER, original Stigler's 1939 diet problem */
   153.5 +
   153.6 +/* The Stigler Diet is an optimization problem named for George Stigler,
   153.7 +   a 1982 Nobel Laureate in economics, who posed the following problem:
   153.8 +   For a moderately active man weighing 154 pounds, how much of each of
   153.9 +   77 foods should be eaten on a daily basis so that the man's intake of
  153.10 +   nine nutrients will be at least equal to the recommended dietary
  153.11 +   allowances (RDSs) suggested by the National Research Council in 1943,
  153.12 +   with the cost of the diet being minimal?
  153.13 +
  153.14 +   The nutrient RDAs required to be met in Stigler's experiment were
  153.15 +   calories, protein, calcium, iron, vitamin A, thiamine, riboflavin,
  153.16 +   niacin, and ascorbic acid. The result was an annual budget allocated
  153.17 +   to foods such as evaporated milk, cabbage, dried navy beans, and beef
  153.18 +   liver at a cost of approximately $0.11 a day in 1939 U.S. dollars.
  153.19 +
  153.20 +   While the name "Stigler Diet" was applied after the experiment by
  153.21 +   outsiders, according to Stigler, "No one recommends these diets for
  153.22 +   anyone, let alone everyone." The Stigler diet has been much ridiculed
  153.23 +   for its lack of variety and palatability, however his methodology has
  153.24 +   received praise and is considered to be some of the earliest work in
  153.25 +   linear programming.
  153.26 +
  153.27 +   The Stigler diet question is a linear programming problem. Lacking
  153.28 +   any sophisticated method of solving such a problem, Stigler was
  153.29 +   forced to utilize heuristic methods in order to find a solution. The
  153.30 +   diet question originally asked in which quantities a 154 pound male
  153.31 +   would have to consume 77 different foods in order to fulfill the
  153.32 +   recommended intake of 9 different nutrients while keeping expense at
  153.33 +   a minimum. Through "trial and error, mathematical insight and
  153.34 +   agility," Stigler was able to eliminate 62 of the foods from the
  153.35 +   original 77 (these foods were removed based because they lacked
  153.36 +   nutrients in comparison to the remaining 15). From the reduced list,
  153.37 +   Stigler calculated the required amounts of each of the remaining 15
  153.38 +   foods to arrive at a cost-minimizing solution to his question.
  153.39 +   According to Stigler's calculations, the annual cost of his solution
  153.40 +   was $39.93 in 1939 dollars. When corrected for inflation using the
  153.41 +   consumer price index, the cost of the diet in 2005 dollars is
  153.42 +   $561.43. The specific combination of foods and quantities is as
  153.43 +   follows:
  153.44 +
  153.45 +   Stigler's 1939 Diet
  153.46 +
  153.47 +   Food             Annual Quantities Annual Cost
  153.48 +   ---------------- ----------------- -----------
  153.49 +   Wheat Flour           370 lb.         $13.33
  153.50 +   Evaporated Milk        57 cans          3.84
  153.51 +   Cabbage               111 lb.           4.11
  153.52 +   Spinach                23 lb.           1.85
  153.53 +   Dried Navy Beans      285 lb.          16.80
  153.54 +   ----------------------------------------------
  153.55 +   Total Annual Cost                     $39.93
  153.56 +
  153.57 +   The 9 nutrients that Stigler's diet took into consideration and their
  153.58 +   respective recommended daily amounts were:
  153.59 +
  153.60 +   Table of nutrients considered in Stigler's diet
  153.61 +
  153.62 +   Nutrient                  Daily Recommended Intake
  153.63 +   ------------------------- ------------------------
  153.64 +   Calories                       3,000 Calories
  153.65 +   Protein                           70 grams
  153.66 +   Calcium                           .8 grams
  153.67 +   Iron                              12 milligrams
  153.68 +   Vitamin A                      5,000 IU
  153.69 +   Thiamine (Vitamin B1)            1.8 milligrams
  153.70 +   Riboflavin (Vitamin B2)          2.7 milligrams
  153.71 +   Niacin                            18 milligrams
  153.72 +   Ascorbic Acid (Vitamin C)         75 milligrams
  153.73 +
  153.74 +   Seven years after Stigler made his initial estimates, the development
  153.75 +   of George Dantzig's Simplex algorithm made it possible to solve the
  153.76 +   problem without relying on heuristic methods. The exact value was
  153.77 +   determined to be $39.69 (using the original 1939 data). Dantzig's
  153.78 +   algorithm describes a method of traversing the vertices of a polytope
  153.79 +   of N+1 dimensions in order to find the optimal solution to a specific
  153.80 +   situation.
  153.81 +
  153.82 +   (From Wikipedia, the free encyclopedia.) */
  153.83 +
  153.84 +/* Translated from GAMS by Andrew Makhorin <mao@gnu.org>.
  153.85 +
  153.86 +   For the original GAMS model stigler1939.gms see [3].
  153.87 +
  153.88 +   References:
  153.89 +
  153.90 +   1. George J. Stigler, "The Cost of Subsistence," J. Farm Econ. 27,
  153.91 +      1945, pp. 303-14.
  153.92 +
  153.93 +   2. National Research Council, "Recommended Daily Allowances," Reprint
  153.94 +      and Circular Series No. 115, January, 1943.
  153.95 +
  153.96 +   3. Erwin Kalvelagen, "Model building with GAMS," Chapter 2, "Building
  153.97 +      linear programming models," pp. 128-34. */
  153.98 +
  153.99 +set C;
 153.100 +/* commodities */
 153.101 +
 153.102 +check card(C) = 77;
 153.103 +/* there must be 77 commodities */
 153.104 +
 153.105 +set N;
 153.106 +/* nutrients */
 153.107 +
 153.108 +param data{c in C, {"price", "weight"} union N};
 153.109 +/* nutritive values per dollar of expenditure */
 153.110 +
 153.111 +param allowance{n in N};
 153.112 +/* recommended daily allowance for a moderately active man */
 153.113 +
 153.114 +var x{c in C}, >= 0;
 153.115 +/* dollars of food to be purchased daily */
 153.116 +
 153.117 +s.t. nb{n in N}: sum{c in C} data[c,n] * x[c] >= allowance[n];
 153.118 +/* nutrient balance */
 153.119 +
 153.120 +minimize cost: sum{c in C} x[c];
 153.121 +/* total food bill */
 153.122 +
 153.123 +solve;
 153.124 +
 153.125 +param days := 365.25;
 153.126 +/* days in a year */
 153.127 +
 153.128 +param commodity{c in C}, symbolic;
 153.129 +
 153.130 +param unit{c in C}, symbolic;
 153.131 +
 153.132 +printf "\n";
 153.133 +printf "MINIMUM COST ANNUAL DIET\n";
 153.134 +printf "\n";
 153.135 +printf "        Commodity            Unit     Quantity     Cost   \n";
 153.136 +printf "------------------------- ---------- ---------- ----------\n";
 153.137 +printf{c in C: x[c] != 0} "%-25s %10s %10.2f   $%7.2f\n", commodity[c],
 153.138 +   unit[c], 100 * days * x[c] / data[c,"price"], days * x[c];
 153.139 +printf "                                         -----------------\n";
 153.140 +printf "                                         Total:   $%7.2f\n",
 153.141 +   days * sum{c in C} x[c];
 153.142 +printf "\n";
 153.143 +
 153.144 +data;
 153.145 +
 153.146 +param : C :    commodity                   unit :=
 153.147 +flour          "Wheat Flour (Enriched)"    "10 lb."
 153.148 +macaroni       "Macaroni"                  "1 lb."
 153.149 +cereal         "Wheat Cereal (Enriched)"   "28 oz."
 153.150 +cornflakes     "Corn Flakes"               "8 oz."
 153.151 +cornmeal       "Corn Meal"                 "1 lb."
 153.152 +grits          "Hominy Grits"              "24 oz."
 153.153 +rice           "Rice"                      "1 lb."
 153.154 +oats           "Rolled Oats"               "1 lb."
 153.155 +whitebread     "White Bread (Enriched)"    "1 lb."
 153.156 +wheatbread     "Whole Wheat Bread"         "1 lb."
 153.157 +ryebread       "Rye Bread"                 "1 lb."
 153.158 +poundcake      "Pound Cake"                "1 lb."
 153.159 +crackers       "Soda Crackers"             "1 lb."
 153.160 +milk           "Milk"                      "1 qt."
 153.161 +evapmild       "Evaporated Milk (can)"     "14.5 oz."
 153.162 +butter         "Butter"                    "1 lb."
 153.163 +margarine      "Oleomargarine"             "1 lb."
 153.164 +eggs           "Eggs"                      "1 doz."
 153.165 +cheese         "Cheese (Cheddar)"          "1 lb."
 153.166 +cream          "Cream"                     "1/2 pt."
 153.167 +peanutbutter   "Peanut Butter"             "1 lb."
 153.168 +mayonnaise     "Mayonnaise"                "1/2 pt."
 153.169 +crisco         "Crisco"                    "1 lb."
 153.170 +lard           "Lard"                      "1 lb."
 153.171 +sirloinsteak   "Sirloin Steak"             "1 lb."
 153.172 +roundsteak     "Round Steak"               "1 lb."
 153.173 +ribroast       "Rib Roast"                 "1 lb."
 153.174 +chuckroast     "Chuck Roast"               "1 lb."
 153.175 +plate          "Plate"                     "1 lb."
 153.176 +liver          "Liver (Beef)"              "1 lb."
 153.177 +lambleg        "Leg of Lamb"               "1 lb."
 153.178 +lambchops      "Lamb Chops (Rib)"          "1 lb."
 153.179 +porkchops      "Pork Chops"                "1 lb."
 153.180 +porkroast      "Pork Loin Roast"           "1 lb."
 153.181 +bacon          "Bacon"                     "1 lb."
 153.182 +ham            "Ham - smoked"              "1 lb."
 153.183 +saltpork       "Salt Pork"                 "1 lb."
 153.184 +chicken        "Roasting Chicken"          "1 lb."
 153.185 +veal           "Veal Cutlets"              "1 lb."
 153.186 +salmon         "Salmon, Pink (can)"        "16 oz."
 153.187 +apples         "Apples"                    "1 lb."
 153.188 +bananas        "Bananas"                   "1 lb."
 153.189 +lemons         "Lemons"                    "1 doz."
 153.190 +oranges        "Oranges"                   "1 doz."
 153.191 +greenbeans     "Green Beans"               "1 lb."
 153.192 +cabbage        "Cabbage"                   "1 lb."
 153.193 +carrots        "Carrots"                   "1 bunch"
 153.194 +celery         "Celery"                    "1 stalk"
 153.195 +lettuce        "Lettuce"                   "1 head"
 153.196 +onions         "Onions"                    "1 lb."
 153.197 +potatoes       "Potatoes"                  "15 lb."
 153.198 +spinach        "Spinach"                   "1 lb."
 153.199 +sweetpotato    "Sweet Potatoes"            "1 lb."
 153.200 +peaches        "Peaches (can)"             "No. 2 1/2"
 153.201 +pears          "Pears (can)"               "No. 2 1/2"
 153.202 +pineapple      "Pineapple (can)"           "No. 2 1/2"
 153.203 +asparagus      "Asparagus (can)"           "No. 2"
 153.204 +cannedgrbn     "Grean Beans (can)"         "No. 2"
 153.205 +porkbeans      "Pork and Beans (can)"      "16 oz."
 153.206 +corn           "Corn (can)"                "No. 2"
 153.207 +peas           "Peas (can)"                "No. 2"
 153.208 +tomatoes       "Tomatoes (can)"            "No. 2"
 153.209 +tomatosoup     "Tomato Soup (can)"         "10 1/2 oz."
 153.210 +driedpeach     "Peaches, Dried"            "1 lb."
 153.211 +prunes         "Prunes, Dried"             "1 lb."
 153.212 +raisins        "Raisins, Dried"            "15 oz."
 153.213 +driedpeas      "Peas, Dried"               "1 lb."
 153.214 +limabeans      "Lima Beans, Dried"         "1 lb."
 153.215 +navybeans      "Navy Beans, Dried"         "1 lb."
 153.216 +coffee         "Coffee"                    "1 lb."
 153.217 +tea            "Tea"                       "1/4 lb."
 153.218 +cocoa          "Cocoa"                     "8 oz."
 153.219 +chocolate      "Chocolate"                 "8 oz."
 153.220 +sugar          "Sugar"                     "10 lb."
 153.221 +cornsirup      "Corn Sirup"                "24 oz."
 153.222 +molasses       "Molasses"                  "18 oz."
 153.223 +stawberry      "Strawberry Preserve"       "1 lb."
 153.224 +;
 153.225 +
 153.226 +set N :=
 153.227 +calories       /* Calories, unit = 1000 */
 153.228 +protein        /* Protein, unit = grams */
 153.229 +calcium        /* Calcium, unit = grams */
 153.230 +iron           /* Iron, unit = milligrams */
 153.231 +vitaminA       /* Vitamin A, unit = 1000 International Units */
 153.232 +thiamine       /* Thiamine, Vit. B1, unit = milligrams */
 153.233 +riboflavin     /* Riboflavin, Vit. B2, unit = milligrams */
 153.234 +niacin         /* Niacin (Nicotinic Acid), unit = milligrams */
 153.235 +ascorbicAcid   /* Ascorbic Acid, Vit. C, unit = milligrams */
 153.236 +;
 153.237 +
 153.238 +param data
 153.239 +:             price   weight calories protein  calcium   iron :=
 153.240 +#            aug. 15  edible
 153.241 +#             1939    per $1
 153.242 +#           (cents)   (grams) (1000)  (grams)  (grams)   (mg.)
 153.243 +flour         36.0    12600    44.7     1411     2.0      365
 153.244 +macaroni      14.1     3217    11.6      418      .7       54
 153.245 +cereal        24.2     3280    11.8      377    14.4      175
 153.246 +cornflakes     7.1     3194    11.4      252      .1       56
 153.247 +cornmeal       4.6     9861    36.0      897     1.7       99
 153.248 +grits          8.5     8005    28.6      680      .8       80
 153.249 +rice           7.5     6048    21.2      460      .6       41
 153.250 +oats           7.1     6389    25.3      907     5.1      341
 153.251 +whitebread     7.9     5742    15.6      488     2.5      115
 153.252 +wheatbread     9.1     4985    12.2      484     2.7      125
 153.253 +ryebread       9.2     4930    12.4      439     1.1       82
 153.254 +poundcake     24.8     1829     8.0      130      .4       31
 153.255 +crackers      15.1     3004    12.5      288      .5       50
 153.256 +milk          11.0     8867     6.1      310    10.5       18
 153.257 +evapmild       6.7     6035     8.4      422    15.1        9
 153.258 +butter        20.8     1473    10.8        9      .2        3
 153.259 +margarine     16.1     2817    20.6       17      .6        6
 153.260 +eggs          32.6     1857     2.9      238     1.0       52
 153.261 +cheese        24.2     1874     7.4      448    16.4       19
 153.262 +cream         14.1     1689     3.5       49     1.7        3
 153.263 +peanutbutter  17.9     2534    15.7      661     1.0       48
 153.264 +mayonnaise    16.7     1198     8.6       18      .2        8
 153.265 +crisco        20.3     2234    20.1        0      .0        0
 153.266 +lard           9.8     4628    41.7        0      .0        0
 153.267 +sirloinsteak  39.6     1145     2.9      166      .1       34
 153.268 +roundsteak    36.4     1246     2.2      214      .1       32
 153.269 +ribroast      29.2     1553     3.4      213      .1       33
 153.270 +chuckroast    22.6     2007     3.6      309      .2       46
 153.271 +plate         14.6     3107     8.5      404      .2       62
 153.272 +liver         26.8     1692     2.2      333      .2      139
 153.273 +lambleg       27.6     1643     3.1      245      .1       20
 153.274 +lambchops     36.6     1239     3.3      140      .1       15
 153.275 +porkchops     30.7     1477     3.5      196      .2       80
 153.276 +porkroast     24.2     1874     4.4      249      .3       37
 153.277 +bacon         25.6     1772    10.4      152      .2       23
 153.278 +ham           27.4     1655     6.7      212      .2       31
 153.279 +saltpork      16.0     2835    18.8      164      .1       26
 153.280 +chicken       30.3     1497     1.8      184      .1       30
 153.281 +veal          42.3     1072     1.7      156      .1       24
 153.282 +salmon        13.0     3489     5.8      705     6.8       45
 153.283 +apples         4.4     9072     5.8       27      .5       36
 153.284 +bananas        6.1     4982     4.9       60      .4       30
 153.285 +lemons        26.0     2380     1.0       21      .5       14
 153.286 +oranges       30.9     4439     2.2       40     1.1       18
 153.287 +greenbeans     7.1     5750     2.4      138     3.7       80
 153.288 +cabbage        3.7     8949     2.6      125     4.0       36
 153.289 +carrots        4.7     6080     2.7       73     2.8       43
 153.290 +celery         7.3     3915      .9       51     3.0       23
 153.291 +lettuce        8.2     2247      .4       27     1.1       22
 153.292 +onions         3.6    11844     5.8      166     3.8       59
 153.293 +potatoes      34.0    16810    14.3      336     1.8      118
 153.294 +spinach        8.1     4592     1.1      106      .0      138
 153.295 +sweetpotato    5.1     7649     9.6      138     2.7       54
 153.296 +peaches       16.8     4894     3.7       20      .4       10
 153.297 +pears         20.4     4030     3.0        8      .3        8
 153.298 +pineapple     21.3     3993     2.4       16      .4        8
 153.299 +asparagus     27.7     1945      .4       33      .3       12
 153.300 +cannedgrbn    10.0     5386     1.0       54     2.0       65
 153.301 +porkbeans      7.1     6389     7.5      364     4.0      134
 153.302 +corn          10.4     5452     5.2      136      .2       16
 153.303 +peas          13.8     4109     2.3      136      .6       45
 153.304 +tomatoes       8.6     6263     1.3       63      .7       38
 153.305 +tomatosoup     7.6     3917     1.6       71      .6       43
 153.306 +driedpeach    15.7     2889     8.5       87     1.7      173
 153.307 +prunes         9.0     4284    12.8       99     2.5      154
 153.308 +raisins        9.4     4524    13.5      104     2.5      136
 153.309 +driedpeas      7.9     5742    20.0     1367     4.2      345
 153.310 +limabeans      8.9     5097    17.4     1055     3.7      459
 153.311 +navybeans      5.9     7688    26.9     1691    11.4      792
 153.312 +coffee        22.4     2025      .0        0      .0        0
 153.313 +tea           17.4      652      .0        0      .0        0
 153.314 +cocoa          8.6     2637     8.7      237     3.0       72
 153.315 +chocolate     16.2     1400     8.0       77     1.3       39
 153.316 +sugar         51.7     8773    34.9        0      .0        0
 153.317 +cornsirup     13.7     4996    14.7        0      .5       74
 153.318 +molasses      13.6     3752     9.0        0    10.3      244
 153.319 +stawberry     20.5     2213     6.4       11      .4        7
 153.320 +
 153.321 +:           vitaminA thiamine riboflavin  niacin  ascorbicAcid :=
 153.322 +#          (1000 IU)  (mg.)      (mg.)     (mg.)     (mg.)
 153.323 +flour           .0    55.4       33.3       441         0
 153.324 +macaroni        .0     3.2        1.9        68         0
 153.325 +cereal          .0    14.4        8.8       114         0
 153.326 +cornflakes      .0    13.5        2.3        68         0
 153.327 +cornmeal      30.9    17.4        7.9       106         0
 153.328 +grits           .0    10.6        1.6       110         0
 153.329 +rice            .0     2.0        4.8        60         0
 153.330 +oats            .0    37.1        8.9        64         0
 153.331 +whitebread      .0    13.8        8.5       126         0
 153.332 +wheatbread      .0    13.9        6.4       160         0
 153.333 +ryebread        .0     9.9        3.0        66         0
 153.334 +poundcake     18.9     2.8        3.0        17         0
 153.335 +crackers        .0      .0         .0         0         0
 153.336 +milk          16.8     4.0       16.0         7       177
 153.337 +evapmild      26.0     3.0       23.5        11        60
 153.338 +butter        44.2      .0         .2         2         0
 153.339 +margarine     55.8      .2         .0         0         0
 153.340 +eggs          18.6     2.8        6.5         1         0
 153.341 +cheese        28.1      .8       10.3         4         0
 153.342 +cream         16.9      .6        2.5         0        17
 153.343 +peanutbutter    .0     9.6        8.1       471         0
 153.344 +mayonnaise     2.7      .4         .5         0         0
 153.345 +crisco          .0      .0         .0         0         0
 153.346 +lard            .2      .0         .5         5         0
 153.347 +sirloinsteak    .2     2.1        2.9        69         0
 153.348 +roundsteak      .4     2.5        2.4        87         0
 153.349 +ribroast        .0      .0        2.0         0         0
 153.350 +chuckroast      .4     1.0        4.0       120         0
 153.351 +plate           .0      .9         .0         0         0
 153.352 +liver        169.2     6.4       50.8       316       525
 153.353 +lambleg         .0     2.8        3.0        86         0
 153.354 +lambchops       .0     1.7        2.7        54         0
 153.355 +porkchops       .0    17.4        2.7        60         0
 153.356 +porkroast       .0    18.2        3.6        79         0
 153.357 +bacon           .0     1.8        1.8        71         0
 153.358 +ham             .0     9.9        3.3        50         0
 153.359 +saltpork        .0     1.4        1.8         0         0
 153.360 +chicken         .1      .9        1.8        68        46
 153.361 +veal            .0     1.4        2.4        57         0
 153.362 +salmon         3.5     1.0        4.9       209         0
 153.363 +apples         7.3     3.6        2.7         5       544
 153.364 +bananas       17.4     2.5        3.5        28       498
 153.365 +lemons          .0      .5         .0         4       952
 153.366 +oranges       11.1     3.6        1.3        10      1993
 153.367 +greenbeans    69.0     4.3        5.8        37       862
 153.368 +cabbage        7.2     9.0        4.5        26      5369
 153.369 +carrots      188.5     6.1        4.3        89       608
 153.370 +celery          .9     1.4        1.4         9       313
 153.371 +lettuce      112.4     1.8        3.4        11       449
 153.372 +onions        16.6     4.7        5.9        21      1184
 153.373 +potatoes       6.7    29.4        7.1       198      2522
 153.374 +spinach      918.4     5.7       13.8        33      2755
 153.375 +sweetpotato  290.7     8.4        5.4        83      1912
 153.376 +peaches       21.5      .5        1.0        31       196
 153.377 +pears           .8      .8         .8         5        81
 153.378 +pineapple      2.0     2.8         .8         7       399
 153.379 +asparagus     16.3     1.4        2.1        17       272
 153.380 +cannedgrbn    53.9     1.6        4.3        32       431
 153.381 +porkbeans      3.5     8.3        7.7        56         0
 153.382 +corn          12.0     1.6        2.7        42       218
 153.383 +peas          34.9     4.9        2.5        37       370
 153.384 +tomatoes      53.2     3.4        2.5        36      1253
 153.385 +tomatosoup    57.9     3.5        2.4        67       862
 153.386 +driedpeach    86.8     1.2        4.3        55        57
 153.387 +prunes        85.7     3.9        4.3        65       257
 153.388 +raisins        4.5     6.3        1.4        24       136
 153.389 +driedpeas      2.9    28.7       18.4       162         0
 153.390 +limabeans      5.1    26.9       38.2        93         0
 153.391 +navybeans       .0    38.4       24.6       217         0
 153.392 +coffee          .0     4.0        5.1        50         0
 153.393 +tea             .0      .0        2.3        42         0
 153.394 +cocoa           .0     2.0       11.9        40         0
 153.395 +chocolate       .0      .9        3.4        14         0
 153.396 +sugar           .0      .0         .0         0         0
 153.397 +cornsirup       .0      .0         .0         5         0
 153.398 +molasses        .0     1.9        7.5       146         0
 153.399 +stawberry       .2      .2         .4         3         0
 153.400 +;
 153.401 +
 153.402 +param allowance :=
 153.403 +calories       3
 153.404 +protein       70
 153.405 +calcium         .8
 153.406 +iron          12
 153.407 +vitaminA       5
 153.408 +thiamine       1.8
 153.409 +riboflavin     2.7
 153.410 +niacin        18
 153.411 +ascorbicAcid  75
 153.412 +;
 153.413 +
 153.414 +end;
   154.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
   154.2 +++ b/deps/glpk/examples/sudoku.dat	Sun Nov 06 20:59:10 2011 +0100
   154.3 @@ -0,0 +1,16 @@
   154.4 +/* sudoku.dat, a hard Sudoku puzzle which causes branching */
   154.5 +
   154.6 +data;
   154.7 +
   154.8 +param givens : 1 2 3 4 5 6 7 8 9 :=
   154.9 +           1   1 . . . . . 7 . .
  154.10 +           2   . 2 . . . . 5 . .
  154.11 +           3   6 . . 3 8 . . . .
  154.12 +           4   . 7 8 . . . . . .
  154.13 +           5   . . . 6 . 9 . . .
  154.14 +           6   . . . . . . 1 4 .
  154.15 +           7   . . . . 2 5 . . 9
  154.16 +           8   . . 3 . . . . 6 .
  154.17 +           9   . . 4 . . . . . 2 ;
  154.18 +
  154.19 +end;
   155.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
   155.2 +++ b/deps/glpk/examples/sudoku.mod	Sun Nov 06 20:59:10 2011 +0100
   155.3 @@ -0,0 +1,84 @@
   155.4 +/* SUDOKU, Number Placement Puzzle */
   155.5 +
   155.6 +/* Written in GNU MathProg by Andrew Makhorin <mao@gnu.org> */
   155.7 +
   155.8 +/* Sudoku, also known as Number Place, is a logic-based placement
   155.9 +   puzzle. The aim of the canonical puzzle is to enter a numerical
  155.10 +   digit from 1 through 9 in each cell of a 9x9 grid made up of 3x3
  155.11 +   subgrids (called "regions"), starting with various digits given in
  155.12 +   some cells (the "givens"). Each row, column, and region must contain
  155.13 +   only one instance of each numeral.
  155.14 +
  155.15 +   Example:
  155.16 +
  155.17 +   +-------+-------+-------+
  155.18 +   | 5 3 . | . 7 . | . . . |
  155.19 +   | 6 . . | 1 9 5 | . . . |
  155.20 +   | . 9 8 | . . . | . 6 . |
  155.21 +   +-------+-------+-------+
  155.22 +   | 8 . . | . 6 . | . . 3 |
  155.23 +   | 4 . . | 8 . 3 | . . 1 |
  155.24 +   | 7 . . | . 2 . | . . 6 |
  155.25 +   +-------+-------+-------+
  155.26 +   | . 6 . | . . . | 2 8 . |
  155.27 +   | . . . | 4 1 9 | . . 5 |
  155.28 +   | . . . | . 8 . | . 7 9 |
  155.29 +   +-------+-------+-------+
  155.30 +
  155.31 +   (From Wikipedia, the free encyclopedia.) */
  155.32 +
  155.33 +param givens{1..9, 1..9}, integer, >= 0, <= 9, default 0;
  155.34 +/* the "givens" */
  155.35 +
  155.36 +var x{i in 1..9, j in 1..9, k in 1..9}, binary;
  155.37 +/* x[i,j,k] = 1 means cell [i,j] is assigned number k */
  155.38 +
  155.39 +s.t. fa{i in 1..9, j in 1..9, k in 1..9: givens[i,j] != 0}:
  155.40 +     x[i,j,k] = (if givens[i,j] = k then 1 else 0);
  155.41 +/* assign pre-defined numbers using the "givens" */
  155.42 +
  155.43 +s.t. fb{i in 1..9, j in 1..9}: sum{k in 1..9} x[i,j,k] = 1;
  155.44 +/* each cell must be assigned exactly one number */
  155.45 +
  155.46 +s.t. fc{i in 1..9, k in 1..9}: sum{j in 1..9} x[i,j,k] = 1;
  155.47 +/* cells in the same row must be assigned distinct numbers */
  155.48 +
  155.49 +s.t. fd{j in 1..9, k in 1..9}: sum{i in 1..9} x[i,j,k] = 1;
  155.50 +/* cells in the same column must be assigned distinct numbers */
  155.51 +
  155.52 +s.t. fe{I in 1..9 by 3, J in 1..9 by 3, k in 1..9}:
  155.53 +     sum{i in I..I+2, j in J..J+2} x[i,j,k] = 1;
  155.54 +/* cells in the same region must be assigned distinct numbers */
  155.55 +
  155.56 +/* there is no need for an objective function here */
  155.57 +
  155.58 +solve;
  155.59 +
  155.60 +for {i in 1..9}
  155.61 +{  for {0..0: i = 1 or i = 4 or i = 7}
  155.62 +      printf " +-------+-------+-------+\n";
  155.63 +   for {j in 1..9}
  155.64 +   {  for {0..0: j = 1 or j = 4 or j = 7} printf(" |");
  155.65 +      printf " %d", sum{k in 1..9} x[i,j,k] * k;
  155.66 +      for {0..0: j = 9} printf(" |\n");
  155.67 +   }
  155.68 +   for {0..0: i = 9}
  155.69 +      printf " +-------+-------+-------+\n";
  155.70 +}
  155.71 +
  155.72 +data;
  155.73 +
  155.74 +/* These data correspond to the example above. */
  155.75 +
  155.76 +param givens : 1 2 3 4 5 6 7 8 9 :=
  155.77 +           1   5 3 . . 7 . . . .
  155.78 +           2   6 . . 1 9 5 . . .
  155.79 +           3   . 9 8 . . . . 6 .
  155.80 +           4   8 . . . 6 . . . 3
  155.81 +           5   4 . . 8 . 3 . . 1
  155.82 +           6   7 . . . 2 . . . 6
  155.83 +           7   . 6 . . . . 2 8 .
  155.84 +           8   . . . 4 1 9 . . 5
  155.85 +           9   . . . . 8 . . 7 9 ;
  155.86 +
  155.87 +end;
   156.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
   156.2 +++ b/deps/glpk/examples/t1.cs	Sun Nov 06 20:59:10 2011 +0100
   156.3 @@ -0,0 +1,99 @@
   156.4 +/*Find the minimum value which satisfies the linear inequality:
   156.5 +    a*x + b*y >= 1 {a,b,x,y Integers} {a,b > 0} {a,b entered on command line}
   156.6 +
   156.7 +  Nigel_Galloway@operamail.com
   156.8 +  February 2008
   156.9 +*/
  156.10 +using System;
  156.11 +using System.Runtime.InteropServices;
  156.12 +
  156.13 +unsafe class GLPK{
  156.14 +  double *lp;
  156.15 +  public int a;
  156.16 +  public int b;
  156.17 +
  156.18 +  const string glpkLibrary = "libglpk.so";
  156.19 +  readonly int GLP_FR = 1;
  156.20 +  readonly int GLP_IV = 2;
  156.21 +  readonly int GLP_DB = 4;
  156.22 +  struct ConstraintMatrix{
  156.23 +    public fixed int ia[3];
  156.24 +    public fixed int ja[3];
  156.25 +    public fixed double ar[3];
  156.26 +  }
  156.27 +  [DllImport(glpkLibrary, SetLastError=true)]
  156.28 +  static extern double* glp_create_prob();
  156.29 +  [DllImport(glpkLibrary, SetLastError=true)]
  156.30 +  static extern void glp_add_rows(double* lp, int rows);
  156.31 +  [DllImport(glpkLibrary, SetLastError=true)]
  156.32 +  static extern void glp_add_cols(double* lp, int cols);
  156.33 +  [DllImport(glpkLibrary, SetLastError=true)]
  156.34 +  static extern void glp_set_col_bnds(double* lp, int col, int bound_type, double lower_bound, double upper_bound);
  156.35 +  [DllImport(glpkLibrary, SetLastError=true)]
  156.36 +  static extern void glp_set_col_kind(double* lp, int col, int kind);
  156.37 +  [DllImport(glpkLibrary, SetLastError=true)]
  156.38 +  static extern void glp_load_matrix(double* lp, int elements, int* ia, int* ja, double* ar);
  156.39 +  public GLPK(int a, int b){
  156.40 +    this.a = a;
  156.41 +    this.b = b;
  156.42 +    lp = glp_create_prob();
  156.43 +    //Col 1 is x, Col 2 is y
  156.44 +    glp_add_rows(lp, 1);
  156.45 +    glp_add_cols(lp, 2);
  156.46 +    glp_set_col_bnds(lp, 1, GLP_FR, 0.0, 0.0);
  156.47 +    glp_set_col_bnds(lp, 2, GLP_FR, 0.0, 0.0);
  156.48 +    glp_set_col_kind(lp, 1, GLP_IV);
  156.49 +    glp_set_col_kind(lp, 2, GLP_IV);
  156.50 +    //Row 1 is a*x + b*y
  156.51 +    ConstraintMatrix CM = new ConstraintMatrix();
  156.52 +    CM.ia[1]=1; CM.ja[1]=1; CM.ar[1]=a;
  156.53 +    CM.ia[2]=1; CM.ja[2]=2; CM.ar[2]=b;
  156.54 +    glp_load_matrix(lp, 2, CM.ia, CM.ja, CM.ar);
  156.55 +    Console.WriteLine("Hello Nigel");
  156.56 +  }
  156.57 +
  156.58 +  [DllImport(glpkLibrary, SetLastError=true)]
  156.59 +  static extern void glp_set_row_bnds(double* lp, int row, int bound_type, double lower_bound, double upper_bound);
  156.60 +  [DllImport(glpkLibrary, SetLastError=true)]
  156.61 +  static extern void glp_simplex(double* lp, void* options);
  156.62 +  [DllImport(glpkLibrary, SetLastError=true)]
  156.63 +  static extern void glp_intopt(double* lp, void* options);
  156.64 +  [DllImport(glpkLibrary, SetLastError=true)]
  156.65 +  static extern double glp_mip_col_val(double* lp, int col);
  156.66 +  public int betterGuess(int upper_bound){
  156.67 +    //Find a new guess less than the old guess: 1 <= (a*x + b*y) <= (old guess - 1)
  156.68 +    glp_set_row_bnds(lp, 1, GLP_DB, 1.0, ((double)upper_bound)-0.5);
  156.69 +    glp_simplex(lp, null);
  156.70 +    glp_intopt(lp, null);
  156.71 +    int x = (int)glp_mip_col_val(lp, 1);
  156.72 +    int y = (int)glp_mip_col_val(lp, 2);
  156.73 +    int nextGuess = a*x + b*y;
  156.74 +    Console.WriteLine("x = {0}, y = {1}, a*x + b*y = {2}",x,y,nextGuess);
  156.75 +    return nextGuess;
  156.76 +  }
  156.77 +
  156.78 +  [DllImport(glpkLibrary, SetLastError=true)]
  156.79 +  static extern void glp_delete_prob(double* lp);
  156.80 +  ~GLPK(){
  156.81 +    glp_delete_prob(lp);
  156.82 +    Console.WriteLine("Goodbye Nigel");
  156.83 +  }
  156.84 +
  156.85 +}
  156.86 +
  156.87 +class test{
  156.88 +  static bool isMinimum(int a, int b, int guess){
  156.89 +    Console.WriteLine("Trying {0}",guess);
  156.90 +    if (a%guess > 0) return false;
  156.91 +    if (b%guess > 0) return false;
  156.92 +    Console.WriteLine("Solution is {0}",guess);
  156.93 +    return true;
  156.94 +  }
  156.95 +
  156.96 +  public static void Main(string[] args){
  156.97 +    Console.WriteLine("a = {0}, b = {1}",args[0], args[1]);
  156.98 +    GLPK lp = new GLPK(Int32.Parse(args[0]),Int32.Parse(args[1]));
  156.99 +    int guess = (lp.a > lp.b) ? lp.b : lp.a;
 156.100 +    while (!isMinimum(lp.a,lp.b,guess)) guess = lp.betterGuess(guess);
 156.101 +  }
 156.102 +}
   157.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
   157.2 +++ b/deps/glpk/examples/tas.mod	Sun Nov 06 20:59:10 2011 +0100
   157.3 @@ -0,0 +1,486 @@
   157.4 +/* TAS, Tail Assignment Problem */
   157.5 +
   157.6 +/* Written in GNU MathProg by Andrew Makhorin <mao@gnu.org> */
   157.7 +
   157.8 +/* The Tail Assignment Problem (TAS) is to construct rosters for a set
   157.9 +   of aircrafts (tails), which cover all flights for a given scheduling
  157.10 +   period.
  157.11 +
  157.12 +   This model includes only flight connection constraints while other
  157.13 +   constraints (for example, maintenance constraints) are ignored. Such
  157.14 +   simplification allows using a single commodity network to model the
  157.15 +   problem, where commodity corresponds to the set of aircrafts.
  157.16 +
  157.17 +   Nodes of the network are activities. They include all flights plus
  157.18 +   two dummy nodes (activities): source node, s, corresponding to
  157.19 +   initial activity of each aircraft, and sink node t, corresponding to
  157.20 +   final activity of each aircraft. Arc v->v' exists in the network if
  157.21 +   and only if the same aircraft is able to operate activity v and then
  157.22 +   immediately activity v'. In partucular, arcs s->f and f->t exist for
  157.23 +   all flights f. Arcs f->f', where f and f' are some flights, exist
  157.24 +   only if the connection time (which is the difference between the
  157.25 +   departure time of f' and the arrival time of f) is not less than a
  157.26 +   given minimal connection time.
  157.27 +
  157.28 +   Reference:
  157.29 +   M. Groenkvist, "The Tail Assignment Problem," Dept. of Comp. Sci.
  157.30 +   and Eng., Chalmers University of Technology and Goeteborg University,
  157.31 +   Goeteborg, Sweden, August 2005. */
  157.32 +
  157.33 +########################################################################
  157.34 +
  157.35 +param nf, integer, > 0;
  157.36 +/* number of flights */
  157.37 +
  157.38 +set F := 1..nf;
  157.39 +/* set of flights (for a given period from timetable) */
  157.40 +
  157.41 +param hub{f in F}, in {1, 2};
  157.42 +/* hub[f] = 1: Sheremetyevo-1
  157.43 +   hub[f] = 2: Sheremetyevo-2 */
  157.44 +
  157.45 +param dest{f in F}, symbolic;
  157.46 +/* destination airport (IATA code) */
  157.47 +
  157.48 +param fno1{f in F}, integer;
  157.49 +/* first leg flight number */
  157.50 +
  157.51 +param dep1{f in F}, integer, >= 0;
  157.52 +/* departure time from Sheremetyevo airport, in minutes */
  157.53 +
  157.54 +check{f in F: f < nf}: dep1[f] <= dep1[f+1];
  157.55 +/* all flights must be ordered by ascending of the departure time */
  157.56 +
  157.57 +param arr1{f in F}, integer, >= 0;
  157.58 +/* arrival time to destination airport, in minutes */
  157.59 +
  157.60 +param fno2{f in F}, integer;
  157.61 +/* second leg flight number */
  157.62 +
  157.63 +param dep2{f in F}, integer, >= 0;
  157.64 +/* departure time from destination airport, in minutes */
  157.65 +
  157.66 +param arr2{f in F}, integer, >= 0;
  157.67 +/* arrival time to Sheremetyevo airport, in minutes */
  157.68 +
  157.69 +param mct1, integer, >= 0, default 80;
  157.70 +/* minimal connection time (within SVO1 or SVO2), in minutes */
  157.71 +
  157.72 +param mct2, integer, >= 0, default 150;
  157.73 +/* minimal connection time (between SVO1 and SVO2), in minutes */
  157.74 +
  157.75 +set E := setof{f in F, ff in F: arr2[f] + (if hub[f] = hub[ff] then
  157.76 +   mct1 else mct2) <= dep1[ff]} (f, ff);
  157.77 +/* connection network; arc f->ff is in E, iff the same aircraft can be
  157.78 +   assigned to flight f and then immediately to flight ff */
  157.79 +
  157.80 +var s{f in F}, >= 0;
  157.81 +/* s[f] is a flow from source node to node f */
  157.82 +
  157.83 +var x{(f,ff) in E}, >= 0;
  157.84 +/* x[f,ff] is a flow from node f to node ff */
  157.85 +
  157.86 +var t{f in F}, >= 0;
  157.87 +/* t[f] is a flow from node f to sink node */
  157.88 +
  157.89 +s.t. into{f in F}: s[f] + sum{(ff,f) in E} x[ff,f] = 1;
  157.90 +/* exactly one aircraft must come into each node f */
  157.91 +
  157.92 +s.t. from{f in F}: t[f] + sum{(f,ff) in E} x[f,ff] = 1;
  157.93 +/* exactly one aircraft must come from each node f */
  157.94 +
  157.95 +minimize obj: sum{f in F} s[f];
  157.96 +/* minimize the number aircrafts sufficient to cover all flights */
  157.97 +
  157.98 +solve;
  157.99 +
 157.100 +########################################################################
 157.101 +
 157.102 +param na := floor(sum{f in F} s[f] + .5);
 157.103 +/* minimal number of aircrafts found */
 157.104 +
 157.105 +printf "At least %d aircrafts needed\n", na;
 157.106 +
 157.107 +set A := 1..na;
 157.108 +/* set of aircrafts */
 157.109 +
 157.110 +printf "Building rosters...\n";
 157.111 +
 157.112 +param tail{f in F}, in A, :=
 157.113 +/* tail[f] is the number of an aircraft assigned to flight f */
 157.114 +
 157.115 +   if f = 1 then 1
 157.116 +   /* assign aircraft 1 to the earliest flight */
 157.117 +
 157.118 +   else if s[f] >= 0.9 then (max{ff in 1..f-1} tail[ff]) + 1
 157.119 +   /* if f is the first flight in a roster, assign to it a next
 157.120 +      aircraft */
 157.121 +
 157.122 +   else sum{(ff,f) in E} tail[ff] * (if x[ff,f] >= 0.9 then 1);
 157.123 +   /* otherwise, assign to flight f the same aircraft, which is
 157.124 +      assigned to a preceding flight in the roster */
 157.125 +
 157.126 +########################################################################
 157.127 +
 157.128 +param file, symbolic, default "tas.ps";
 157.129 +/* file to output the assignment chart in postscript format */
 157.130 +
 157.131 +param title, symbolic, default "(no title)";
 157.132 +/* chart title */
 157.133 +
 157.134 +param left, default 25;
 157.135 +/* left margin, in mm */
 157.136 +
 157.137 +param top, default 25;
 157.138 +/* top margin, in mm */
 157.139 +
 157.140 +param right, default 20;
 157.141 +/* right margin, in mm */
 157.142 +
 157.143 +param bottom, default 15;
 157.144 +/* bottom margin, in mm */
 157.145 +
 157.146 +param sx := 297 - left - right;
 157.147 +/* chart area horizontal size, in mm */
 157.148 +
 157.149 +param sy := 210 - top - bottom;
 157.150 +/* chart area vertical size, in mm */
 157.151 +
 157.152 +param gap, default sy / (na - 1);
 157.153 +/* gap between rosters, in mm */
 157.154 +
 157.155 +printf "Writing assignment chart to %s...\n", file;
 157.156 +
 157.157 +printf "%%!PS-Adobe-3.0\n" > file;
 157.158 +printf "%%%%Title: Tail Assignment Chart\n" >> file;
 157.159 +printf "%%%%Creator: GLPK MathProg\n" >> file;
 157.160 +printf "%%%%BoundingBox: 0 0 595 842\n" >> file;
 157.161 +printf "%%%%EndComments\n" >> file;
 157.162 +printf "<</PageSize [595 842]>> setpagedevice\n" >> file;
 157.163 +printf "72 25.4 div dup scale\n" >> file;
 157.164 +printf "210 %.3f sub %.3f translate\n", bottom, left >> file;
 157.165 +printf "90 rotate\n" >> file;
 157.166 +
 157.167 +printf "/HelveticaBold findfont 5 scalefont setfont\n" >> file;
 157.168 +printf "%.3f %.3f moveto (%s) dup show\n", 0, sy + 5, title >> file;
 157.169 +
 157.170 +param period := floor((max{f in F} arr2[f]) / 60. + .5);
 157.171 +/* period duration, in hours */
 157.172 +
 157.173 +/* vertical bars */
 157.174 +printf ".8 .8 .8 setrgbcolor\n" >> file;
 157.175 +for {tt in 0..period}
 157.176 +{  printf "%s setlinewidth\n",
 157.177 +      if tt mod 24 = 0 then ".5" else "0" >> file;
 157.178 +   printf "newpath %.3f %.3f moveto %.3f %.3f lineto stroke\n",
 157.179 +      tt * (sx / period), 0, tt * (sx / period),
 157.180 +      sy + (if tt mod 24 = 0 then 2) >> file;
 157.181 +}
 157.182 +
 157.183 +/* rosters */
 157.184 +for {a in A}
 157.185 +{  printf "0 0 0 setrgbcolor\n" >> file;
 157.186 +   printf "0 setlinewidth\n" >> file;
 157.187 +   printf "newpath %.3f %.3f moveto %.3f %.3f lineto stroke\n",
 157.188 +      0, sy - gap * (a - 1), sx, sy - gap * (a - 1) >> file;
 157.189 +   printf "/Dingbats findfont 4 scalefont setfont\n" >> file;
 157.190 +   printf "%.3f %.3f moveto <28> dup show\n",
 157.191 +      -4, sy - gap * (a - 1) - 1.4, a >> file;
 157.192 +   printf "/Helvetica findfont 3 scalefont setfont\n" >> file;
 157.193 +   printf "%.3f %.3f moveto (%2d) dup show\n",
 157.194 +      -9, sy - gap * (a - 1) - 1.2, a >> file;
 157.195 +   for {f in F: tail[f] == a}
 157.196 +   {  printf "0 0 %s setrgbcolor\n",
 157.197 +         if hub[f] = 1 then "0" else ".8" >> file;
 157.198 +      printf "1 setlinewidth\n" >> file;
 157.199 +      printf "newpath %.3f %.3f moveto %.3f %.3f lineto stroke\n",
 157.200 +         dep1[f] / 60 * (sx / period), sy - gap * (a - 1),
 157.201 +         arr2[f] / 60 * (sx / period), sy - gap * (a - 1) >> file;
 157.202 +      printf "/Helvetica findfont 1.8 scalefont setfont\n" >> file;
 157.203 +      printf "%.3f %.3f moveto (%02d:%02d %s) dup show\n",
 157.204 +         dep1[f] / 60 * (sx / period), sy - gap * (a - 1) + .8,
 157.205 +         (dep1[f] mod 1440) div 60, (dep1[f] mod 1440) mod 60,
 157.206 +         dest[f] >> file;
 157.207 +      printf "%.3f %.3f moveto (%d %02d:%02d) dup show\n",
 157.208 +         dep1[f] / 60 * (sx / period), sy - gap * (a - 1) - 2.1,
 157.209 +         fno1[f],
 157.210 +         (arr2[f] mod 1440) div 60, (arr2[f] mod 1440) mod 60 >> file;
 157.211 +   }
 157.212 +}
 157.213 +
 157.214 +printf "showpage\n" >> file;
 157.215 +printf "%%%%EOF\n" >> file;
 157.216 +
 157.217 +########################################################################
 157.218 +
 157.219 +data;
 157.220 +
 157.221 +param title := "Tu-154 [from 2008-08-18 to 2008-08-24]";
 157.222 +
 157.223 +param nf := 261;
 157.224 +
 157.225 +param : hub dest fno1 dep1  arr1  fno2 dep2  arr2 :=
 157.226 +      1  1  IKT  743   195   520  744   610   970
 157.227 +      2  1  OMS  815   205   405  816   485   700
 157.228 +      3  1  CEK  897   205   360  898   430   595
 157.229 +      4  1  KRR  763   260   400  764   480   610
 157.230 +      5  2  SIP  133   280   420  134   500   620
 157.231 +      6  2  BUD  131   290   450  132   520   675
 157.232 +      7  1  AAQ  701   305   440  702   510   640
 157.233 +      8  1  MRV  785   310   440  786   520   650
 157.234 +      9  2  WAW  101   355   475  102   540   660
 157.235 +     10  2  GYD  147   370   550  148   675   860
 157.236 +     11  1  AER  869   385   530  870   655   795
 157.237 +     12  1  KRR  765   430   560  766   630   760
 157.238 +     13  1  AAQ  703   520   660  704   740   850
 157.239 +     14  1  LED  845   530   620  846   690   775
 157.240 +     15  1  KRR  767   540   675  768   765   895
 157.241 +     16  2  KBP  183   665   760  184   850   940
 157.242 +     17  1  MRV  787   755   905  788   985  1135
 157.243 +     18  1  KRR  771   810   940  772  1030  1165
 157.244 +     19  1  LED  849   825   900  850   960  1095
 157.245 +     20  2  IST  209   880  1050  210  1120  1280
 157.246 +     21  1  AER  873   885  1030  874  1760  1900
 157.247 +     22  1  ASF  711   995  1145  712  1640  1795
 157.248 +     23  2  ULN  563   995  1335  564  1415  1815
 157.249 +     24  2  OTP  151  1020  1175  152  1800  1940
 157.250 +     25  2  BEY  509  1025  1265  510  1350  1580
 157.251 +     26  2  OSL  211  1060  1220  212  1860  2015
 157.252 +     27  1  IKT  739  1085  1420  740  1510  1870
 157.253 +     28  1  KRR  773  1095  1240  774  1620  1765
 157.254 +     29  1  SGC  877  1120  1315  878  1395  1625
 157.255 +     30  1  LED  857  1150  1230  858  1610  1690
 157.256 +     31  1  CEK  899  1230  1385  900  1455  1620
 157.257 +     32  1  PEE  821  1235  1390  822  1450  1600
 157.258 +     33  2  TBS  197  1240  1405  198  1560  1715
 157.259 +     34  1  UFA  891  1275  1405  892  1475  1610
 157.260 +     35  1  KJA  781  1300  1570  782  1680  1990
 157.261 +     36  1  IKT  743  1635  1960  744  2050  2410
 157.262 +     37  1  OMS  815  1645  1845  816  1925  2140
 157.263 +     38  1  CEK  897  1645  1800  898  1870  2035
 157.264 +     39  1  KRR  763  1700  1840  764  1920  2050
 157.265 +     40  2  SIP  133  1720  1860  134  1940  2060
 157.266 +     41  2  BUD  131  1730  1890  132  1960  2115
 157.267 +     42  1  AAQ  701  1745  1880  702  1950  2080
 157.268 +     43  1  MRV  785  1750  1880  786  1960  2090
 157.269 +     44  2  WAW  101  1795  1915  102  1980  2100
 157.270 +     45  2  GYD  147  1810  1990  148  2115  2300
 157.271 +     46  1  AER  869  1825  1970  870  2095  2235
 157.272 +     47  2  EVN  193  1850  2030  194  2105  2275
 157.273 +     48  1  KRR  765  1870  2000  766  2070  2200
 157.274 +     49  1  AAQ  703  1960  2100  704  2180  2290
 157.275 +     50  1  LED  845  1970  2060  846  2130  2215
 157.276 +     51  1  KRR  767  1980  2115  768  2205  2335
 157.277 +     52  2  KBP  183  2105  2200  184  2290  2380
 157.278 +     53  1  MRV  787  2195  2345  788  2425  2575
 157.279 +     54  1  KRR  771  2250  2380  772  2470  2605
 157.280 +     55  1  LED  849  2265  2340  850  2400  2535
 157.281 +     56  2  IST  209  2320  2490  210  2560  2720
 157.282 +     57  1  AER  873  2325  2470  874  3200  3340
 157.283 +     58  2  ULN  563  2435  2775  564  2855  3255
 157.284 +     59  1  ASF  711  2435  2585  712  3080  3235
 157.285 +     60  2  DAM  517  2465  2705  518  2790  3020
 157.286 +     61  2  OSL  211  2500  2660  212  3300  3455
 157.287 +     62  2  KBP  185  2510  2610  186  3160  3250
 157.288 +     63  1  IKT  739  2525  2860  740  2950  3310
 157.289 +     64  1  KRR  773  2535  2680  774  3060  3205
 157.290 +     65  1  SGC  877  2560  2755  878  2835  3065
 157.291 +     66  1  LED  857  2590  2670  858  3050  3130
 157.292 +     67  1  CEK  899  2670  2825  900  2895  3060
 157.293 +     68  1  PEE  821  2675  2830  822  2890  3040
 157.294 +     69  2  TBS  197  2680  2845  198  3000  3155
 157.295 +     70  1  UFA  891  2715  2845  892  2915  3050
 157.296 +     71  1  KJA  781  2740  3010  782  3120  3430
 157.297 +     72  1  IKT  743  3075  3400  744  3490  3850
 157.298 +     73  1  CEK  897  3085  3240  898  3310  3475
 157.299 +     74  1  OMS  815  3085  3285  816  3365  3580
 157.300 +     75  1  KRR  763  3140  3280  764  3360  3490
 157.301 +     76  2  SIP  133  3160  3300  134  3380  3500
 157.302 +     77  2  BUD  131  3170  3330  132  3400  3555
 157.303 +     78  1  AAQ  701  3185  3320  702  3390  3520
 157.304 +     79  1  MRV  785  3190  3320  786  3400  3530
 157.305 +     80  2  WAW  101  3235  3355  102  3420  3540
 157.306 +     81  2  FRU  181  3245  3495  182  3590  3860
 157.307 +     82  2  GYD  147  3250  3430  148  3555  3740
 157.308 +     83  1  AER  869  3265  3410  870  3535  3675
 157.309 +     84  1  KRR  765  3310  3440  766  3510  3640
 157.310 +     85  1  AAQ  703  3400  3540  704  3620  3730
 157.311 +     86  1  LED  845  3410  3500  846  3570  3655
 157.312 +     87  1  KRR  767  3420  3555  768  3645  3775
 157.313 +     88  2  KBP  183  3545  3640  184  3730  3820
 157.314 +     89  1  MRV  787  3635  3785  788  3865  4015
 157.315 +     90  1  KRR  771  3690  3820  772  3910  4045
 157.316 +     91  1  LED  849  3705  3780  850  3840  3975
 157.317 +     92  2  IST  209  3760  3930  210  4000  4160
 157.318 +     93  1  AER  873  3765  3910  874  4640  4780
 157.319 +     94  2  ULN  563  3875  4215  564  4295  4695
 157.320 +     95  1  ASF  711  3875  4025  712  4520  4675
 157.321 +     96  2  OTP  151  3900  4055  152  4680  4820
 157.322 +     97  2  BEY  509  3905  4145  510  4230  4460
 157.323 +     98  2  OSL  211  3940  4100  212  4740  4895
 157.324 +     99  2  KBP  185  3950  4050  186  4600  4690
 157.325 +    100  1  IKT  739  3965  4300  740  4390  4750
 157.326 +    101  1  KRR  773  3975  4120  774  4500  4645
 157.327 +    102  1  SGC  877  4000  4195  878  4275  4505
 157.328 +    103  1  LED  857  4030  4110  858  4490  4570
 157.329 +    104  1  CEK  899  4110  4265  900  4335  4500
 157.330 +    105  1  PEE  821  4115  4270  822  4330  4480
 157.331 +    106  2  TBS  197  4120  4285  198  4440  4595
 157.332 +    107  1  UFA  891  4155  4285  892  4355  4490
 157.333 +    108  1  KJA  781  4180  4450  782  4560  4870
 157.334 +    109  1  IKT  743  4515  4840  744  4930  5290
 157.335 +    110  1  OMS  815  4525  4725  816  4805  5020
 157.336 +    111  1  CEK  897  4525  4680  898  4750  4915
 157.337 +    112  1  KRR  763  4580  4720  764  4800  4930
 157.338 +    113  2  SIP  133  4600  4740  134  4820  4940
 157.339 +    114  2  BUD  131  4610  4770  132  4840  4995
 157.340 +    115  1  AAQ  701  4625  4760  702  4830  4960
 157.341 +    116  1  MRV  785  4630  4760  786  4840  4970
 157.342 +    117  2  WAW  101  4675  4795  102  4860  4980
 157.343 +    118  2  GYD  147  4690  4870  148  4995  5180
 157.344 +    119  1  AER  869  4705  4850  870  4975  5115
 157.345 +    120  2  EVN  193  4730  4910  194  4985  5155
 157.346 +    121  1  KRR  765  4750  4880  766  4950  5080
 157.347 +    122  1  AAQ  703  4840  4980  704  5060  5170
 157.348 +    123  1  LED  845  4850  4940  846  5010  5095
 157.349 +    124  1  KRR  767  4860  4995  768  5085  5215
 157.350 +    125  2  KBP  183  4985  5080  184  5170  5260
 157.351 +    126  1  MRV  787  5075  5225  788  5305  5455
 157.352 +    127  1  KRR  771  5130  5260  772  5350  5485
 157.353 +    128  1  LED  849  5145  5220  850  5280  5415
 157.354 +    129  2  IST  209  5200  5370  210  5440  5600
 157.355 +    130  1  AER  873  5205  5350  874  6080  6220
 157.356 +    131  1  ASF  711  5315  5465  712  5960  6115
 157.357 +    132  2  ULN  563  5315  5655  564  5735  6135
 157.358 +    133  2  DAM  517  5345  5585  518  5670  5900
 157.359 +    134  2  OSL  211  5380  5540  212  6180  6335
 157.360 +    135  2  KBP  185  5390  5490  186  6040  6130
 157.361 +    136  1  IKT  739  5405  5740  740  5830  6190
 157.362 +    137  1  KRR  773  5415  5560  774  5940  6085
 157.363 +    138  1  SGC  877  5440  5635  878  5715  5945
 157.364 +    139  1  LED  857  5470  5550  858  5930  6010
 157.365 +    140  1  CEK  899  5550  5705  900  5775  5940
 157.366 +    141  1  PEE  821  5555  5710  822  5770  5920
 157.367 +    142  2  TBS  197  5560  5725  198  5880  6035
 157.368 +    143  1  UFA  891  5595  5725  892  5795  5930
 157.369 +    144  1  KJA  781  5620  5890  782  6000  6310
 157.370 +    145  1  IKT  743  5955  6280  744  6370  6730
 157.371 +    146  1  OMS  815  5965  6165  816  6245  6460
 157.372 +    147  1  CEK  897  5965  6120  898  6190  6355
 157.373 +    148  1  KRR  763  6020  6160  764  6240  6370
 157.374 +    149  2  SIP  133  6040  6180  134  6260  6380
 157.375 +    150  2  BUD  131  6050  6210  132  6280  6435
 157.376 +    151  1  AAQ  701  6065  6200  702  6270  6400
 157.377 +    152  1  MRV  785  6070  6200  786  6280  6410
 157.378 +    153  2  WAW  101  6115  6235  102  6300  6420
 157.379 +    154  2  FRU  181  6125  6375  182  6470  6740
 157.380 +    155  2  GYD  147  6130  6310  148  6435  6620
 157.381 +    156  1  AER  869  6145  6290  870  6415  6555
 157.382 +    157  2  EVN  193  6170  6350  194  6425  6595
 157.383 +    158  1  KRR  765  6190  6320  766  6390  6520
 157.384 +    159  1  AAQ  703  6280  6420  704  6500  6610
 157.385 +    160  1  LED  845  6290  6380  846  6450  6535
 157.386 +    161  1  KRR  767  6300  6435  768  6525  6655
 157.387 +    162  2  KBP  183  6425  6520  184  6610  6700
 157.388 +    163  2  AYT  223  6500  6690  224  6750  6940
 157.389 +    164  1  AER  867  6510  6660  868  6730  6880
 157.390 +    165  1  MRV  787  6515  6665  788  6745  6895
 157.391 +    166  1  KRR  771  6570  6700  772  6790  6925
 157.392 +    167  1  LED  849  6585  6660  850  6720  6855
 157.393 +    168  2  IST  209  6640  6810  210  6880  7040
 157.394 +    169  1  AER  873  6645  6790  874  7520  7660
 157.395 +    170  1  ASF  711  6755  6905  712  7400  7555
 157.396 +    171  2  ULN  563  6755  7095  564  7175  7575
 157.397 +    172  2  OTP  151  6780  6935  152  7560  7700
 157.398 +    173  2  BEY  509  6785  7025  510  7110  7340
 157.399 +    174  2  OSL  211  6820  6980  212  7620  7775
 157.400 +    175  2  KBP  185  6830  6930  186  7480  7570
 157.401 +    176  1  IKT  739  6845  7180  740  7270  7630
 157.402 +    177  1  KRR  773  6855  7000  774  7380  7525
 157.403 +    178  1  SGC  877  6880  7075  878  7155  7385
 157.404 +    179  1  LED  857  6910  6990  858  7370  7450
 157.405 +    180  1  CEK  899  6990  7145  900  7215  7380
 157.406 +    181  1  PEE  821  6995  7150  822  7210  7360
 157.407 +    182  2  TBS  197  7000  7165  198  7320  7475
 157.408 +    183  1  UFA  891  7035  7165  892  7235  7370
 157.409 +    184  1  KJA  781  7060  7330  782  7440  7750
 157.410 +    185  1  IKT  743  7395  7720  744  7810  8170
 157.411 +    186  1  CEK  897  7405  7560  898  7630  7795
 157.412 +    187  1  KRR  763  7460  7600  764  7680  7810
 157.413 +    188  2  SIP  133  7480  7620  134  7700  7820
 157.414 +    189  2  BUD  131  7490  7650  132  7720  7875
 157.415 +    190  1  AAQ  701  7505  7640  702  7710  7840
 157.416 +    191  1  MRV  785  7510  7640  786  7720  7850
 157.417 +    192  2  IST  207  7545  7720  208  7795  7985
 157.418 +    193  2  WAW  101  7555  7675  102  7740  7860
 157.419 +    194  2  GYD  147  7570  7750  148  7875  8060
 157.420 +    195  1  AER  869  7585  7730  870  7855  7995
 157.421 +    196  2  AYT  221  7610  7800  222  7895  8085
 157.422 +    197  2  EVN  193  7610  7790  194  7865  8035
 157.423 +    198  1  KRR  765  7630  7760  766  7830  7960
 157.424 +    199  1  AAQ  703  7720  7860  704  7940  8050
 157.425 +    200  1  LED  845  7730  7820  846  7890  7975
 157.426 +    201  1  KRR  767  7740  7875  768  7965  8095
 157.427 +    202  2  KBP  183  7865  7960  184  8050  8140
 157.428 +    203  2  AYT  223  7940  8130  224  8190  8380
 157.429 +    204  1  MRV  787  7955  8105  788  8185  8335
 157.430 +    205  1  KRR  771  8010  8140  772  8230  8365
 157.431 +    206  1  LED  849  8025  8100  850  8160  8295
 157.432 +    207  2  IST  209  8080  8250  210  8320  8480
 157.433 +    208  1  AER  873  8085  8230  874  8960  9100
 157.434 +    209  1  ASF  711  8195  8345  712  8840  8995
 157.435 +    210  2  ULN  563  8195  8535  564  8615  9015
 157.436 +    211  1  KJA  779  8230  8500  780  8575  8870
 157.437 +    212  2  OSL  211  8260  8420  212  9060  9215
 157.438 +    213  2  KBP  185  8270  8370  186  8920  9010
 157.439 +    214  1  IKT  739  8285  8620  740  8710  9070
 157.440 +    215  1  KRR  773  8295  8440  774  8820  8965
 157.441 +    216  1  SGC  877  8320  8515  878  8595  8825
 157.442 +    217  1  LED  857  8350  8430  858  8810  8890
 157.443 +    218  1  CEK  899  8430  8585  900  8655  8820
 157.444 +    219  1  PEE  821  8435  8590  822  8650  8800
 157.445 +    220  2  TBS  197  8440  8605  198  8760  8915
 157.446 +    221  1  UFA  891  8475  8605  892  8675  8810
 157.447 +    222  1  KJA  781  8500  8770  782  8880  9190
 157.448 +    223  1  IKT  743  8835  9160  744  9250  9610
 157.449 +    224  1  OMS  815  8845  9045  816  9125  9340
 157.450 +    225  1  CEK  897  8845  9000  898  9070  9235
 157.451 +    226  1  KRR  763  8900  9040  764  9120  9250
 157.452 +    227  2  SIP  133  8920  9060  134  9140  9260
 157.453 +    228  2  BUD  131  8930  9090  132  9160  9315
 157.454 +    229  1  AAQ  701  8945  9080  702  9150  9280
 157.455 +    230  1  MRV  785  8950  9080  786  9160  9290
 157.456 +    231  2  IST  207  8985  9160  208  9235  9425
 157.457 +    232  2  WAW  101  8995  9115  102  9180  9300
 157.458 +    233  2  FRU  181  9005  9255  182  9350  9620
 157.459 +    234  2  GYD  147  9010  9190  148  9315  9500
 157.460 +    235  1  AER  869  9025  9170  870  9295  9435
 157.461 +    236  2  EVN  193  9050  9230  194  9305  9475
 157.462 +    237  1  KRR  765  9070  9200  766  9270  9400
 157.463 +    238  1  AAQ  703  9160  9300  704  9380  9490
 157.464 +    239  1  LED  845  9170  9260  846  9330  9415
 157.465 +    240  1  KRR  767  9180  9315  768  9405  9535
 157.466 +    241  2  KBP  183  9305  9400  184  9490  9580
 157.467 +    242  2  AYT  223  9380  9570  224  9630  9820
 157.468 +    243  1  MRV  787  9395  9545  788  9625  9775
 157.469 +    244  1  KRR  771  9450  9580  772  9670  9805
 157.470 +    245  1  LED  849  9465  9540  850  9600  9735
 157.471 +    246  2  IST  209  9520  9690  210  9760  9920
 157.472 +    247  1  AER  873  9525  9670  874 10400 10540
 157.473 +    248  1  ASF  711  9635  9785  712 10280 10435
 157.474 +    249  2  ULN  563  9635  9975  564 10055 10455
 157.475 +    250  2  OTP  151  9660  9815  152 10440 10580
 157.476 +    251  2  DAM  517  9665  9905  518  9990 10220
 157.477 +    252  2  OSL  211  9700  9860  212 10500 10655
 157.478 +    253  2  KBP  185  9710  9810  186 10360 10450
 157.479 +    254  1  IKT  739  9725 10060  740 10150 10510
 157.480 +    255  1  KRR  773  9735  9880  774 10260 10405
 157.481 +    256  1  SGC  877  9760  9955  878 10035 10265
 157.482 +    257  1  LED  857  9790  9870  858 10250 10330
 157.483 +    258  1  CEK  899  9870 10025  900 10095 10260
 157.484 +    259  1  PEE  821  9875 10030  822 10090 10240
 157.485 +    260  1  UFA  891  9915 10045  892 10115 10250
 157.486 +    261  1  KJA  781  9940 10210  782 10320 10630
 157.487 +;
 157.488 +
 157.489 +end;
   158.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
   158.2 +++ b/deps/glpk/examples/todd.mod	Sun Nov 06 20:59:10 2011 +0100
   158.3 @@ -0,0 +1,36 @@
   158.4 +/* TODD, a class of hard instances of zero-one knapsack problems */
   158.5 +
   158.6 +/* Written in GNU MathProg by Andrew Makhorin <mao@gnu.org> */
   158.7 +
   158.8 +/* Chvatal describes a class of instances of zero-one knapsack problems
   158.9 +   due to Todd. He shows that a wide class of algorithms - including all
  158.10 +   based on branch and bound or dynamic programming - find it difficult
  158.11 +   to solve problems in the Todd class. More exactly, the time required
  158.12 +   by these algorithms to solve instances of problems that belong to the
  158.13 +   Todd class grows as an exponential function of the problem size.
  158.14 +
  158.15 +   Reference:
  158.16 +   Chvatal V. (1980), Hard knapsack problems, Op. Res. 28, 1402-1411. */
  158.17 +
  158.18 +param n > 0 integer;
  158.19 +
  158.20 +param log2_n := log(n) / log(2);
  158.21 +
  158.22 +param k := floor(log2_n);
  158.23 +
  158.24 +param a{j in 1..n} := 2 ** (k + n + 1) + 2 ** (k + n + 1 - j) + 1;
  158.25 +
  158.26 +param b := 0.5 * floor(sum{j in 1..n} a[j]);
  158.27 +
  158.28 +var x{1..n} binary;
  158.29 +
  158.30 +maximize obj: sum{j in 1..n} a[j] * x[j];
  158.31 +
  158.32 +s.t. cap: sum{j in 1..n} a[j] * x[j] <= b;
  158.33 +
  158.34 +data;
  158.35 +
  158.36 +param n := 15;
  158.37 +/* change this parameter to choose a particular instance */
  158.38 +
  158.39 +end;
   159.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
   159.2 +++ b/deps/glpk/examples/train.mod	Sun Nov 06 20:59:10 2011 +0100
   159.3 @@ -0,0 +1,281 @@
   159.4 +# TRAIN, a model of railroad passenger car allocation
   159.5 +#
   159.6 +# References:
   159.7 +# Robert Fourer, David M. Gay and Brian W. Kernighan, "A Modeling Language
   159.8 +# for Mathematical Programming." Management Science 36 (1990) 519-554.
   159.9 +
  159.10 +###  SCHEDULE SETS AND PARAMETERS  ###
  159.11 +
  159.12 +set cities;
  159.13 +
  159.14 +set links within {c1 in cities, c2 in cities: c1 <> c2};
  159.15 +
  159.16 +                        # Set of cities, and set of intercity links
  159.17 +
  159.18 +param last > 0 integer; # Number of time intervals in a day
  159.19 +
  159.20 +set times := 1..last;   # Set of time intervals in a day
  159.21 +
  159.22 +set schedule within
  159.23 +      {c1 in cities, t1 in times,
  159.24 +       c2 in cities, t2 in times: (c1,c2) in links};
  159.25 +
  159.26 +                        # Member (c1,t1,c2,t2) of this set represents
  159.27 +                        # a train that leaves city c1 at time t1
  159.28 +                        # and arrives in city c2 at time t2
  159.29 +
  159.30 +###  DEMAND PARAMETERS  ###
  159.31 +
  159.32 +param section > 0 integer;
  159.33 +
  159.34 +                        # Maximum number of cars in one section of a train
  159.35 +
  159.36 +param demand {schedule} > 0;
  159.37 +
  159.38 +                        # For each scheduled train:
  159.39 +                        # the smallest number of cars that
  159.40 +                        # can meet demand for the train
  159.41 +
  159.42 +param low {(c1,t1,c2,t2) in schedule} := ceil(demand[c1,t1,c2,t2]);
  159.43 +
  159.44 +                        # Minimum number of cars needed to meet demand
  159.45 +
  159.46 +param high {(c1,t1,c2,t2) in schedule}
  159.47 +
  159.48 +   := max (2, min (ceil(2*demand[c1,t1,c2,t2]),
  159.49 +                   section*ceil(demand[c1,t1,c2,t2]/section) ));
  159.50 +
  159.51 +                        # Maximum number of cars allowed on a train:
  159.52 +                        # 2 if demand is for less than one car;
  159.53 +                        # otherwise, lesser of
  159.54 +                        # number of cars needed to hold twice the demand, and
  159.55 +                        # number of cars in minimum number of sections needed
  159.56 +
  159.57 +###  DISTANCE PARAMETERS  ###
  159.58 +
  159.59 +param dist_table {links} >= 0 default 0.0;
  159.60 +
  159.61 +param distance {(c1,c2) in links} > 0
  159.62 +   := if dist_table[c1,c2] > 0 then dist_table[c1,c2] else dist_table[c2,c1];
  159.63 +
  159.64 +                        # Inter-city distances: distance[c1,c2] is miles
  159.65 +                        # between city c1 and city c2
  159.66 +
  159.67 +###  VARIABLES  ###
  159.68 +
  159.69 +var U 'cars stored' {cities,times} >= 0;
  159.70 +
  159.71 +                        # u[c,t] is the number of unused cars stored
  159.72 +                        # at city c in the interval beginning at time t
  159.73 +
  159.74 +var X 'cars in train' {schedule} >= 0;
  159.75 +
  159.76 +                        # x[c1,t1,c2,t2] is the number of cars assigned to
  159.77 +                        # the scheduled train that leaves c1 at t1 and
  159.78 +                        # arrives in c2 at t2
  159.79 +
  159.80 +###  OBJECTIVES  ###
  159.81 +
  159.82 +minimize cars:
  159.83 +       sum {c in cities} U[c,last] +
  159.84 +       sum {(c1,t1,c2,t2) in schedule: t2 < t1} X[c1,t1,c2,t2];
  159.85 +
  159.86 +                        # Number of cars in the system:
  159.87 +                        # sum of unused cars and cars in trains during
  159.88 +                        # the last time interval of the day
  159.89 +
  159.90 +minimize miles:
  159.91 +       sum {(c1,t1,c2,t2) in schedule} distance[c1,c2] * X[c1,t1,c2,t2];
  159.92 +
  159.93 +                        # Total car-miles run by all scheduled trains in a day
  159.94 +
  159.95 +###  CONSTRAINTS  ###
  159.96 +
  159.97 +account {c in cities, t in times}:
  159.98 +
  159.99 +  U[c,t] = U[c, if t > 1 then t-1 else last] +
 159.100 +
 159.101 +      sum {(c1,t1,c,t) in schedule} X[c1,t1,c,t] -
 159.102 +      sum {(c,t,c2,t2) in schedule} X[c,t,c2,t2];
 159.103 +
 159.104 +                        # For every city and time:
 159.105 +                        # unused cars in the present interval must equal
 159.106 +                        # unused cars in the previous interval,
 159.107 +                        # plus cars just arriving in trains,
 159.108 +                        # minus cars just leaving in trains
 159.109 +
 159.110 +satisfy {(c1,t1,c2,t2) in schedule}:
 159.111 +
 159.112 +       low[c1,t1,c2,t2] <= X[c1,t1,c2,t2] <= high[c1,t1,c2,t2];
 159.113 +
 159.114 +                        # For each scheduled train:
 159.115 +                        # number of cars must meet demand,
 159.116 +                        # but must not be so great that unnecessary
 159.117 +                        # sections are run
 159.118 +
 159.119 +###  DATA  ###
 159.120 +
 159.121 +data;
 159.122 +
 159.123 +set cities := BO NY PH WA ;
 159.124 +
 159.125 +set links := (BO,NY) (NY,PH) (PH,WA)
 159.126 +             (NY,BO) (PH,NY) (WA,PH) ;
 159.127 +
 159.128 +param dist_table := [*,*]  BO NY  232
 159.129 +                           NY PH   90
 159.130 +                           PH WA  135 ;
 159.131 +
 159.132 +param last := 48 ;
 159.133 +
 159.134 +param section := 14 ;
 159.135 +
 159.136 +set schedule :=
 159.137 +
 159.138 +   (WA,*,PH,*)   2  5     6  9     8 11    10 13
 159.139 +                12 15    13 16    14 17    15 18
 159.140 +                16 19    17 20    18 21    19 22
 159.141 +                20 23    21 24    22 25    23 26
 159.142 +                24 27    25 28    26 29    27 30
 159.143 +                28 31    29 32    30 33    31 34
 159.144 +                32 35    33 36    34 37    35 38
 159.145 +                36 39    37 40    38 41    39 42
 159.146 +                40 43    41 44    42 45    44 47
 159.147 +                46  1
 159.148 +
 159.149 +   (PH,*,NY,*)   1  3     5  7     9 11    11 13
 159.150 +                13 15    14 16    15 17    16 18
 159.151 +                17 19    18 20    19 21    20 22
 159.152 +                21 23    22 24    23 25    24 26
 159.153 +                25 27    26 28    27 29    28 30
 159.154 +                29 31    30 32    31 33    32 34
 159.155 +                33 35    34 36    35 37    36 38
 159.156 +                37 39    38 40    39 41    40 42
 159.157 +                41 43    42 44    43 45    44 46
 159.158 +                45 47    47  1
 159.159 +
 159.160 +   (NY,*,BO,*)  10 16    12 18    14 20    15 21
 159.161 +                16 22    17 23    18 24    19 25
 159.162 +                20 26    21 27    22 28    23 29
 159.163 +                24 30    25 31    26 32    27 33
 159.164 +                28 34    29 35    30 36    31 37
 159.165 +                32 38    33 39    34 40    35 41
 159.166 +                36 42    37 43    38 44    39 45
 159.167 +                40 46    41 47    42 48    43  1
 159.168 +                44  2    45  3    46  4    48  6
 159.169 +
 159.170 +   (BO,*,NY,*)   7 13     9 15    11 17    12 18
 159.171 +                13 19    14 20    15 21    16 22
 159.172 +                17 23    18 24    19 25    20 26
 159.173 +                21 27    22 28    23 29    24 30
 159.174 +                25 31    26 32    27 33    28 34
 159.175 +                29 35    30 36    31 37    32 38
 159.176 +                33 39    34 40    35 41    36 42
 159.177 +                37 43    38 44    39 45    40 46
 159.178 +                41 47    43  1    45  3    47  5
 159.179 +
 159.180 +   (NY,*,PH,*)   1  3    12 14    13 15    14 16
 159.181 +                15 17    16 18    17 19    18 20
 159.182 +                19 21    20 22    21 23    22 24
 159.183 +                23 25    24 26    25 27    26 28
 159.184 +                27 29    28 30    29 31    30 32
 159.185 +                31 33    32 34    33 35    34 36
 159.186 +                35 37    36 38    37 39    38 40
 159.187 +                39 41    40 42    41 43    42 44
 159.188 +                43 45    44 46    45 47    46 48
 159.189 +                47  1
 159.190 +
 159.191 +   (PH,*,WA,*)   1  4    14 17    15 18    16 19
 159.192 +                17 20    18 21    19 22    20 23
 159.193 +                21 24    22 25    23 26    24 27
 159.194 +                25 28    26 29    27 30    28 31
 159.195 +                29 32    30 33    31 34    32 35
 159.196 +                33 36    34 37    35 38    36 39
 159.197 +                37 40    38 41    39 42    40 43
 159.198 +                41 44    42 45    43 46    44 47
 159.199 +                45 48    46  1    47  2    ;
 159.200 +
 159.201 +param demand :=
 159.202 +
 159.203 + [WA,*,PH,*]   2  5    .55      6  9    .01      8 11    .01
 159.204 +              10 13    .13     12 15   1.59     13 16   1.69
 159.205 +              14 17   5.19     15 18   3.55     16 19   6.29
 159.206 +              17 20   4.00     18 21   5.80     19 22   3.40
 159.207 +              20 23   4.88     21 24   2.92     22 25   4.37
 159.208 +              23 26   2.80     24 27   4.23     25 28   2.88
 159.209 +              26 29   4.33     27 30   3.11     28 31   4.64
 159.210 +              29 32   3.44     30 33   4.95     31 34   3.73
 159.211 +              32 35   5.27     33 36   3.77     34 37   4.80
 159.212 +              35 38   3.31     36 39   3.89     37 40   2.65
 159.213 +              38 41   3.01     39 42   2.04     40 43   2.31
 159.214 +              41 44   1.52     42 45   1.75     44 47   1.88
 159.215 +              46  1   1.05
 159.216 +
 159.217 + [PH,*,NY,*]   1  3   1.05      5  7    .43      9 11    .20
 159.218 +              11 13    .21     13 15    .40     14 16   6.49
 159.219 +              15 17  16.40     16 18   9.48     17 19  17.15
 159.220 +              18 20   9.31     19 21  15.20     20 22   8.21
 159.221 +              21 23  13.32     22 24   7.35     23 25  11.83
 159.222 +              24 26   6.61     25 27  10.61     26 28   6.05
 159.223 +              27 29   9.65     28 30   5.61     29 31   9.25
 159.224 +              30 32   5.40     31 33   8.24     32 34   4.84
 159.225 +              33 35   7.44     34 36   4.44     35 37   6.80
 159.226 +              36 38   4.11     37 39   6.25     38 40   3.69
 159.227 +              39 41   5.55     40 42   3.29     41 43   4.77
 159.228 +              42 44   2.91     43 45   4.19     44 46   2.53
 159.229 +              45 47   4.00     47 1    1.65
 159.230 +
 159.231 + [NY,*,BO,*]  10 16   1.23     12 18   3.84     14 20   4.08
 159.232 +              15 21   1.47     16 22   2.96     17 23   1.60
 159.233 +              18 24   2.95     19 25   1.71     20 26   2.81
 159.234 +              21 27   1.77     22 28   2.87     23 29   1.84
 159.235 +              24 30   2.95     25 31   1.91     26 32   3.12
 159.236 +              27 33   1.93     28 34   3.31     29 35   2.00
 159.237 +              30 36   3.40     31 37   2.08     32 38   3.41
 159.238 +              33 39   2.69     34 40   4.45     35 41   2.32
 159.239 +              36 42   3.40     37 43   1.80     38 44   2.63
 159.240 +              39 45   1.52     40 46   2.23     41 47   1.25
 159.241 +              42 48   1.79     43  1    .97     44  2   1.28
 159.242 +              45  3    .48     46  4    .68     48  6    .08
 159.243 +
 159.244 + [BO,*,NY,*]   7 13    .03      9 15   1.29     11 17   4.59
 159.245 +              12 18   2.56     13 19   3.92     14 20   2.37
 159.246 +              15 21   3.81     16 22   2.24     17 23   3.51
 159.247 +              18 24   2.13     19 25   3.28     20 26   2.05
 159.248 +              21 27   3.15     22 28   1.99     23 29   3.09
 159.249 +              24 30   1.93     25 31   3.19     26 32   1.91
 159.250 +              27 33   3.21     28 34   1.85     29 35   3.21
 159.251 +              30 36   1.71     31 37   3.04     32 38   2.08
 159.252 +              33 39   3.13     34 40   1.96     35 41   2.53
 159.253 +              36 42   1.43     37 43   2.04     38 44   1.12
 159.254 +              39 45   1.71     40 46    .91     41 47   1.32
 159.255 +              43  1   1.80     45  3   1.13     47  5    .23
 159.256 +
 159.257 + [NY,*,PH,*]   1  3    .04     12 14   4.68     13 15   5.61
 159.258 +              14 16   3.56     15 17   5.81     16 18   3.81
 159.259 +              17 19   6.31     18 20   4.07     19 21   7.33
 159.260 +              20 22   4.55     21 23   7.37     22 24   4.73
 159.261 +              23 25   7.61     24 26   4.92     25 27   7.91
 159.262 +              26 28   5.19     27 29   8.40     28 30   5.53
 159.263 +              29 31   9.32     30 32   5.51     31 33  10.33
 159.264 +              32 34   9.21     33 35  18.95     34 36  11.23
 159.265 +              35 37  16.85     36 38   7.29     37 39  10.89
 159.266 +              38 40   5.41     39 41   8.21     40 42   4.52
 159.267 +              41 43   6.99     42 44   3.92     43 45   6.21
 159.268 +              44 46   3.44     45 47   5.17     46 48   2.55
 159.269 +              47  1   1.24
 159.270 +
 159.271 + [PH,*,WA,*]   1  4    .20     14 17   4.49     15 18   3.53
 159.272 +              16 19   2.67     17 20   3.83     18 21   3.01
 159.273 +              19 22   4.12     20 23   3.15     21 24   4.67
 159.274 +              22 25   3.20     23 26   4.23     24 27   2.87
 159.275 +              25 28   3.84     26 29   2.60     27 30   3.80
 159.276 +              28 31   2.77     29 32   4.31     30 33   3.16
 159.277 +              31 34   4.88     32 35   3.45     33 36   5.55
 159.278 +              34 37   3.52     35 38   6.11     36 39   3.32
 159.279 +              37 40   5.53     38 41   3.03     39 42   4.51
 159.280 +              40 43   2.53     41 44   3.39     42 45   1.93
 159.281 +              43 46   2.52     44 47   1.20     45 48   1.75
 159.282 +              46  1    .88     47  2    .87     ;
 159.283 +
 159.284 +end;
   160.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
   160.2 +++ b/deps/glpk/examples/transp.mod	Sun Nov 06 20:59:10 2011 +0100
   160.3 @@ -0,0 +1,63 @@
   160.4 +# A TRANSPORTATION PROBLEM
   160.5 +#
   160.6 +# This problem finds a least cost shipping schedule that meets
   160.7 +# requirements at markets and supplies at factories.
   160.8 +#
   160.9 +#  References:
  160.10 +#              Dantzig G B, "Linear Programming and Extensions."
  160.11 +#              Princeton University Press, Princeton, New Jersey, 1963,
  160.12 +#              Chapter 3-3.
  160.13 +
  160.14 +set I;
  160.15 +/* canning plants */
  160.16 +
  160.17 +set J;
  160.18 +/* markets */
  160.19 +
  160.20 +param a{i in I};
  160.21 +/* capacity of plant i in cases */
  160.22 +
  160.23 +param b{j in J};
  160.24 +/* demand at market j in cases */
  160.25 +
  160.26 +param d{i in I, j in J};
  160.27 +/* distance in thousands of miles */
  160.28 +
  160.29 +param f;
  160.30 +/* freight in dollars per case per thousand miles */
  160.31 +
  160.32 +param c{i in I, j in J} := f * d[i,j] / 1000;
  160.33 +/* transport cost in thousands of dollars per case */
  160.34 +
  160.35 +var x{i in I, j in J} >= 0;
  160.36 +/* shipment quantities in cases */
  160.37 +
  160.38 +minimize cost: sum{i in I, j in J} c[i,j] * x[i,j];
  160.39 +/* total transportation costs in thousands of dollars */
  160.40 +
  160.41 +s.t. supply{i in I}: sum{j in J} x[i,j] <= a[i];
  160.42 +/* observe supply limit at plant i */
  160.43 +
  160.44 +s.t. demand{j in J}: sum{i in I} x[i,j] >= b[j];
  160.45 +/* satisfy demand at market j */
  160.46 +
  160.47 +data;
  160.48 +
  160.49 +set I := Seattle San-Diego;
  160.50 +
  160.51 +set J := New-York Chicago Topeka;
  160.52 +
  160.53 +param a := Seattle     350
  160.54 +           San-Diego   600;
  160.55 +
  160.56 +param b := New-York    325
  160.57 +           Chicago     300
  160.58 +           Topeka      275;
  160.59 +
  160.60 +param d :              New-York   Chicago   Topeka :=
  160.61 +           Seattle     2.5        1.7       1.8
  160.62 +           San-Diego   2.5        1.8       1.4  ;
  160.63 +
  160.64 +param f := 90;
  160.65 +
  160.66 +end;
   161.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
   161.2 +++ b/deps/glpk/examples/trick.mod	Sun Nov 06 20:59:10 2011 +0100
   161.3 @@ -0,0 +1,72 @@
   161.4 +/* TRICK, A Transportation Design Problem */
   161.5 +
   161.6 +/* Translated from the Mosel modeling language to GNU MathProg by
   161.7 +   Andrew Makhorin <mao@gnu.org> */
   161.8 +
   161.9 +/* This example model is described in the article "Formulations and
  161.10 +   Reformulations in Integer Programming" by Michael Trick (it is
  161.11 +   publicly available at http://mat.gsia.cmu.edu/trick/formul04.pdf).
  161.12 +
  161.13 +   This model demonstrates an amazing effect when including in the
  161.14 +   formulation an additional constraint, which is redundant even for
  161.15 +   LP relaxation, makes the model easy for solving with the B&B. */
  161.16 +
  161.17 +set TRUCKS := 1..10;
  161.18 +
  161.19 +set PACKAGES := 1..20;
  161.20 +
  161.21 +param capacity{TRUCKS};
  161.22 +
  161.23 +param size{PACKAGES};
  161.24 +
  161.25 +param cost{TRUCKS};
  161.26 +
  161.27 +param can_use{PACKAGES, TRUCKS};
  161.28 +
  161.29 +var x{PACKAGES, TRUCKS}, binary;
  161.30 +
  161.31 +var y{TRUCKS}, binary;
  161.32 +
  161.33 +minimize total: sum{i in TRUCKS} cost[i] * y[i];
  161.34 +
  161.35 +f1{i in TRUCKS}:
  161.36 +      sum{j in PACKAGES} size[j] * x[j,i] <= capacity[i] * y[i];
  161.37 +
  161.38 +f2{i in TRUCKS, j in PACKAGES}:
  161.39 +      x[j,i] <= y[i];
  161.40 +
  161.41 +f3{j in PACKAGES}:
  161.42 +      sum{i in TRUCKS} can_use[j,i] * x[j,i] = 1;
  161.43 +
  161.44 +redundant_constraint:
  161.45 +      sum{i in TRUCKS} capacity[i] * y[i] >= sum{j in PACKAGES} size[j];
  161.46 +
  161.47 +data;
  161.48 +
  161.49 +param capacity :=
  161.50 +      [1] 100 [2] 200 [3] 100 [4] 200 [5] 100 [6] 200 [7] 100 [8] 200
  161.51 +      [9] 100 [10] 200;
  161.52 +
  161.53 +param size :=
  161.54 +      [1] 17 [2] 21 [3] 54 [4] 45 [5] 87 [6] 34 [7] 23 [8] 45 [9] 12
  161.55 +      [10] 43 [11] 54 [12] 39 [13] 31 [14] 26 [15] 75 [16] 48 [17] 16
  161.56 +      [18] 32 [19] 45 [20] 55;
  161.57 +
  161.58 +param cost :=
  161.59 +      [1] 1 [2] 1.8 [3] 1 [4] 1.8 [5] 1 [6] 1.8 [7] 1 [8] 1.8 [9] 1
  161.60 +      [10] 1.8;
  161.61 +
  161.62 +param can_use (tr):
  161.63 +      1  2  3  4  5  6  7  8  9 10 11 12 13 14 15 16 17 18 19 20 :=
  161.64 +   1  1  1  1  1  1  1  0  0  0  0  1  1  1  1  0  0  0  0  0  0
  161.65 +   2  1  1  1  1  1  1  1  1  0  0  1  1  1  1  1  1  1  0  0  0
  161.66 +   3  0  1  1  1  1  0  0  0  0  0  0  1  1  1  1  1  1  0  0  0
  161.67 +   4  0  0  1  1  1  1  1  1  1  1  0  0  1  1  1  1  1  1  0  0
  161.68 +   5  0  0  1  1  1  1  0  0  0  0  0  0  0  1  1  1  1  1  1  0
  161.69 +   6  0  0  0  1  1  1  1  0  0  0  0  0  0  1  1  1  0  0  0  0
  161.70 +   7  0  0  0  0  1  1  1  1  1  0  0  0  0  0  1  1  1  1  0  0
  161.71 +   8  0  0  0  0  1  1  1  1  1  1  0  0  0  0  0  1  1  1  1  1
  161.72 +   9  0  0  0  0  0  1  1  1  1  0  0  0  0  0  0  0  1  1  1  1
  161.73 +  10  0  0  0  0  0  0  0  1  1  1  0  0  0  0  0  0  0  0  1  1;
  161.74 +
  161.75 +end;
   162.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
   162.2 +++ b/deps/glpk/examples/tsp.mod	Sun Nov 06 20:59:10 2011 +0100
   162.3 @@ -0,0 +1,335 @@
   162.4 +/* TSP, Traveling Salesman Problem */
   162.5 +
   162.6 +/* Written in GNU MathProg by Andrew Makhorin <mao@gnu.org> */
   162.7 +
   162.8 +/* The Traveling Salesman Problem (TSP) is stated as follows.
   162.9 +   Let a directed graph G = (V, E) be given, where V = {1, ..., n} is
  162.10 +   a set of nodes, E <= V x V is a set of arcs. Let also each arc
  162.11 +   e = (i,j) be assigned a number c[i,j], which is the length of the
  162.12 +   arc e. The problem is to find a closed path of minimal length going
  162.13 +   through each node of G exactly once. */
  162.14 +
  162.15 +param n, integer, >= 3;
  162.16 +/* number of nodes */
  162.17 +
  162.18 +set V := 1..n;
  162.19 +/* set of nodes */
  162.20 +
  162.21 +set E, within V cross V;
  162.22 +/* set of arcs */
  162.23 +
  162.24 +param c{(i,j) in E};
  162.25 +/* distance from node i to node j */
  162.26 +
  162.27 +var x{(i,j) in E}, binary;
  162.28 +/* x[i,j] = 1 means that the salesman goes from node i to node j */
  162.29 +
  162.30 +minimize total: sum{(i,j) in E} c[i,j] * x[i,j];
  162.31 +/* the objective is to make the path length as small as possible */
  162.32 +
  162.33 +s.t. leave{i in V}: sum{(i,j) in E} x[i,j] = 1;
  162.34 +/* the salesman leaves each node i exactly once */
  162.35 +
  162.36 +s.t. enter{j in V}: sum{(i,j) in E} x[i,j] = 1;
  162.37 +/* the salesman enters each node j exactly once */
  162.38 +
  162.39 +/* Constraints above are not sufficient to describe valid tours, so we
  162.40 +   need to add constraints to eliminate subtours, i.e. tours which have
  162.41 +   disconnected components. Although there are many known ways to do
  162.42 +   that, I invented yet another way. The general idea is the following.
  162.43 +   Let the salesman sells, say, cars, starting the travel from node 1,
  162.44 +   where he has n cars. If we require the salesman to sell exactly one
  162.45 +   car in each node, he will need to go through all nodes to satisfy
  162.46 +   this requirement, thus, all subtours will be eliminated. */
  162.47 +
  162.48 +var y{(i,j) in E}, >= 0;
  162.49 +/* y[i,j] is the number of cars, which the salesman has after leaving
  162.50 +   node i and before entering node j; in terms of the network analysis,
  162.51 +   y[i,j] is a flow through arc (i,j) */
  162.52 +
  162.53 +s.t. cap{(i,j) in E}: y[i,j] <= (n-1) * x[i,j];
  162.54 +/* if arc (i,j) does not belong to the salesman's tour, its capacity
  162.55 +   must be zero; it is obvious that on leaving a node, it is sufficient
  162.56 +   to have not more than n-1 cars */
  162.57 +
  162.58 +s.t. node{i in V}:
  162.59 +/* node[i] is a conservation constraint for node i */
  162.60 +
  162.61 +      sum{(j,i) in E} y[j,i]
  162.62 +      /* summary flow into node i through all ingoing arcs */
  162.63 +
  162.64 +      + (if i = 1 then n)
  162.65 +      /* plus n cars which the salesman has at starting node */
  162.66 +
  162.67 +      = /* must be equal to */
  162.68 +
  162.69 +      sum{(i,j) in E} y[i,j]
  162.70 +      /* summary flow from node i through all outgoing arcs */
  162.71 +
  162.72 +      + 1;
  162.73 +      /* plus one car which the salesman sells at node i */
  162.74 +
  162.75 +solve;
  162.76 +
  162.77 +printf "Optimal tour has length %d\n",
  162.78 +   sum{(i,j) in E} c[i,j] * x[i,j];
  162.79 +printf("From node   To node   Distance\n");
  162.80 +printf{(i,j) in E: x[i,j]} "      %3d       %3d   %8g\n",
  162.81 +   i, j, c[i,j];
  162.82 +
  162.83 +data;
  162.84 +
  162.85 +/* These data correspond to the symmetric instance ulysses16 from:
  162.86 +
  162.87 +   Reinelt, G.: TSPLIB - A travelling salesman problem library.
  162.88 +   ORSA-Journal of the Computing 3 (1991) 376-84;
  162.89 +   http://elib.zib.de/pub/Packages/mp-testdata/tsp/tsplib */
  162.90 +
  162.91 +/* The optimal solution is 6859 */
  162.92 +
  162.93 +param n := 16;
  162.94 +
  162.95 +param : E : c :=
  162.96 +    1  2   509
  162.97 +    1  3   501
  162.98 +    1  4   312
  162.99 +    1  5  1019
 162.100 +    1  6   736
 162.101 +    1  7   656
 162.102 +    1  8    60
 162.103 +    1  9  1039
 162.104 +    1 10   726
 162.105 +    1 11  2314
 162.106 +    1 12   479
 162.107 +    1 13   448
 162.108 +    1 14   479
 162.109 +    1 15   619
 162.110 +    1 16   150
 162.111 +    2  1   509
 162.112 +    2  3   126
 162.113 +    2  4   474
 162.114 +    2  5  1526
 162.115 +    2  6  1226
 162.116 +    2  7  1133
 162.117 +    2  8   532
 162.118 +    2  9  1449
 162.119 +    2 10  1122
 162.120 +    2 11  2789
 162.121 +    2 12   958
 162.122 +    2 13   941
 162.123 +    2 14   978
 162.124 +    2 15  1127
 162.125 +    2 16   542
 162.126 +    3  1   501
 162.127 +    3  2   126
 162.128 +    3  4   541
 162.129 +    3  5  1516
 162.130 +    3  6  1184
 162.131 +    3  7  1084
 162.132 +    3  8   536
 162.133 +    3  9  1371
 162.134 +    3 10  1045
 162.135 +    3 11  2728
 162.136 +    3 12   913
 162.137 +    3 13   904
 162.138 +    3 14   946
 162.139 +    3 15  1115
 162.140 +    3 16   499
 162.141 +    4  1   312
 162.142 +    4  2   474
 162.143 +    4  3   541
 162.144 +    4  5  1157
 162.145 +    4  6   980
 162.146 +    4  7   919
 162.147 +    4  8   271
 162.148 +    4  9  1333
 162.149 +    4 10  1029
 162.150 +    4 11  2553
 162.151 +    4 12   751
 162.152 +    4 13   704
 162.153 +    4 14   720
 162.154 +    4 15   783
 162.155 +    4 16   455
 162.156 +    5  1  1019
 162.157 +    5  2  1526
 162.158 +    5  3  1516
 162.159 +    5  4  1157
 162.160 +    5  6   478
 162.161 +    5  7   583
 162.162 +    5  8   996
 162.163 +    5  9   858
 162.164 +    5 10   855
 162.165 +    5 11  1504
 162.166 +    5 12   677
 162.167 +    5 13   651
 162.168 +    5 14   600
 162.169 +    5 15   401
 162.170 +    5 16  1033
 162.171 +    6  1   736
 162.172 +    6  2  1226
 162.173 +    6  3  1184
 162.174 +    6  4   980
 162.175 +    6  5   478
 162.176 +    6  7   115
 162.177 +    6  8   740
 162.178 +    6  9   470
 162.179 +    6 10   379
 162.180 +    6 11  1581
 162.181 +    6 12   271
 162.182 +    6 13   289
 162.183 +    6 14   261
 162.184 +    6 15   308
 162.185 +    6 16   687
 162.186 +    7  1   656
 162.187 +    7  2  1133
 162.188 +    7  3  1084
 162.189 +    7  4   919
 162.190 +    7  5   583
 162.191 +    7  6   115
 162.192 +    7  8   667
 162.193 +    7  9   455
 162.194 +    7 10   288
 162.195 +    7 11  1661
 162.196 +    7 12   177
 162.197 +    7 13   216
 162.198 +    7 14   207
 162.199 +    7 15   343
 162.200 +    7 16   592
 162.201 +    8  1    60
 162.202 +    8  2   532
 162.203 +    8  3   536
 162.204 +    8  4   271
 162.205 +    8  5   996
 162.206 +    8  6   740
 162.207 +    8  7   667
 162.208 +    8  9  1066
 162.209 +    8 10   759
 162.210 +    8 11  2320
 162.211 +    8 12   493
 162.212 +    8 13   454
 162.213 +    8 14   479
 162.214 +    8 15   598
 162.215 +    8 16   206
 162.216 +    9  1  1039
 162.217 +    9  2  1449
 162.218 +    9  3  1371
 162.219 +    9  4  1333
 162.220 +    9  5   858
 162.221 +    9  6   470
 162.222 +    9  7   455
 162.223 +    9  8  1066
 162.224 +    9 10   328
 162.225 +    9 11  1387
 162.226 +    9 12   591
 162.227 +    9 13   650
 162.228 +    9 14   656
 162.229 +    9 15   776
 162.230 +    9 16   933
 162.231 +   10  1   726
 162.232 +   10  2  1122
 162.233 +   10  3  1045
 162.234 +   10  4  1029
 162.235 +   10  5   855
 162.236 +   10  6   379
 162.237 +   10  7   288
 162.238 +   10  8   759
 162.239 +   10  9   328
 162.240 +   10 11  1697
 162.241 +   10 12   333
 162.242 +   10 13   400
 162.243 +   10 14   427
 162.244 +   10 15   622
 162.245 +   10 16   610
 162.246 +   11  1  2314
 162.247 +   11  2  2789
 162.248 +   11  3  2728
 162.249 +   11  4  2553
 162.250 +   11  5  1504
 162.251 +   11  6  1581
 162.252 +   11  7  1661
 162.253 +   11  8  2320
 162.254 +   11  9  1387
 162.255 +   11 10  1697
 162.256 +   11 12  1838
 162.257 +   11 13  1868
 162.258 +   11 14  1841
 162.259 +   11 15  1789
 162.260 +   11 16  2248
 162.261 +   12  1   479
 162.262 +   12  2   958
 162.263 +   12  3   913
 162.264 +   12  4   751
 162.265 +   12  5   677
 162.266 +   12  6   271
 162.267 +   12  7   177
 162.268 +   12  8   493
 162.269 +   12  9   591
 162.270 +   12 10   333
 162.271 +   12 11  1838
 162.272 +   12 13    68
 162.273 +   12 14   105
 162.274 +   12 15   336
 162.275 +   12 16   417
 162.276 +   13  1   448
 162.277 +   13  2   941
 162.278 +   13  3   904
 162.279 +   13  4   704
 162.280 +   13  5   651
 162.281 +   13  6   289
 162.282 +   13  7   216
 162.283 +   13  8   454
 162.284 +   13  9   650
 162.285 +   13 10   400
 162.286 +   13 11  1868
 162.287 +   13 12    68
 162.288 +   13 14    52
 162.289 +   13 15   287
 162.290 +   13 16   406
 162.291 +   14  1   479
 162.292 +   14  2   978
 162.293 +   14  3   946
 162.294 +   14  4   720
 162.295 +   14  5   600
 162.296 +   14  6   261
 162.297 +   14  7   207
 162.298 +   14  8   479
 162.299 +   14  9   656
 162.300 +   14 10   427
 162.301 +   14 11  1841
 162.302 +   14 12   105
 162.303 +   14 13    52
 162.304 +   14 15   237
 162.305 +   14 16   449
 162.306 +   15  1   619
 162.307 +   15  2  1127
 162.308 +   15  3  1115
 162.309 +   15  4   783
 162.310 +   15  5   401
 162.311 +   15  6   308
 162.312 +   15  7   343
 162.313 +   15  8   598
 162.314 +   15  9   776
 162.315 +   15 10   622
 162.316 +   15 11  1789
 162.317 +   15 12   336
 162.318 +   15 13   287
 162.319 +   15 14   237
 162.320 +   15 16   636
 162.321 +   16  1   150
 162.322 +   16  2   542
 162.323 +   16  3   499
 162.324 +   16  4   455
 162.325 +   16  5  1033
 162.326 +   16  6   687
 162.327 +   16  7   592
 162.328 +   16  8   206
 162.329 +   16  9   933
 162.330 +   16 10   610
 162.331 +   16 11  2248
 162.332 +   16 12   417
 162.333 +   16 13   406
 162.334 +   16 14   449
 162.335 +   16 15   636
 162.336 +;
 162.337 +
 162.338 +end;
   163.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
   163.2 +++ b/deps/glpk/examples/xyacfs.mod	Sun Nov 06 20:59:10 2011 +0100
   163.3 @@ -0,0 +1,56 @@
   163.4 +/*Extended Yet Another Curve Fitting Solution (The poor man's RMA)
   163.5 +
   163.6 +  An extension of yacfs.mod adding a Weight parameter:
   163.7 +    When set to 1 the model produces best fit by least squares with all error in y and none in x (YonX);
   163.8 +    When set to zero the model produces best fit by least squares with all error in x and none in y (XonY);
   163.9 +    When set to 0.5 the model assumes equal error in x and y producing results similar to fitting by Reduced Major Axis Analysis.
  163.10 +
  163.11 +  Nigel_Galloway@operamail.com
  163.12 +  November 5th., 2009
  163.13 +*/
  163.14 +set Sample;
  163.15 +param Sx {z in Sample};
  163.16 +param Sy {z in Sample};
  163.17 +param Weight := 0.5;
  163.18 +
  163.19 +var a;
  163.20 +var b;
  163.21 +var p;
  163.22 +var q;
  163.23 +
  163.24 +XonY1 :sum{z in Sample} q*Sy[z]*Sy[z] + sum{z in Sample} p*Sy[z] = sum{z in Sample} Sy[z]*Sx[z];
  163.25 +XonY2 :sum{z in Sample} q*Sy[z] + sum{z in Sample} p = sum{z in Sample} Sx[z];
  163.26 +YonX1 :sum{z in Sample} a*Sx[z]*Sx[z] + sum{z in Sample} b*Sx[z] = sum{z in Sample} Sy[z]*Sx[z];
  163.27 +YonX2 :sum{z in Sample} a*Sx[z] + sum{z in Sample} b = sum{z in Sample} Sy[z];
  163.28 +
  163.29 +solve;
  163.30 +
  163.31 +param W := Weight*a + (1-Weight)*(1/q);
  163.32 +printf "\nbest linear fit is:\n\ty = %f %s %fx\n\n", b*Weight - (1-Weight)*(p/q), if W < 0 then "-" else "+", abs(W);
  163.33 +
  163.34 +data;
  163.35 +
  163.36 +param:
  163.37 +Sample:   Sx    Sy :=
  163.38 +  1         0    1
  163.39 +  2       0.5  0.9
  163.40 +  3         1  0.7
  163.41 +  4       1.5  1.5
  163.42 +  5       1.9    2
  163.43 +  6       2.5  2.4
  163.44 +  7         3  3.2
  163.45 +  8       3.5    2
  163.46 +  9         4  2.7
  163.47 + 10       4.5  3.5
  163.48 + 11         5    1
  163.49 + 12       5.5    4
  163.50 + 13         6  3.6
  163.51 + 14       6.6  2.7
  163.52 + 15         7  5.7
  163.53 + 16       7.6  4.6
  163.54 + 17       8.5    6
  163.55 + 18         9  6.8
  163.56 + 19        10  7.3
  163.57 +;
  163.58 +
  163.59 +end;
   164.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
   164.2 +++ b/deps/glpk/examples/yacfs.mod	Sun Nov 06 20:59:10 2011 +0100
   164.3 @@ -0,0 +1,48 @@
   164.4 +/*Yet Another Curve Fitting Solution
   164.5 +
   164.6 +  Obviously this solution produces the same answer
   164.7 +  as examples/cflsq.mod
   164.8 +
   164.9 +  Nigel_Galloway@operamail.com
  164.10 +  February 1st., 2009
  164.11 +*/
  164.12 +set Sample;
  164.13 +param Sx {z in Sample};
  164.14 +param Sy {z in Sample};
  164.15 +
  164.16 +var a;
  164.17 +var b;
  164.18 +
  164.19 +equalz1 :sum{z in Sample} a*Sx[z]*Sx[z] + sum{z in Sample} b*Sx[z] = sum{z in Sample} Sy[z]*Sx[z];
  164.20 +equalz2 :sum{z in Sample} a*Sx[z] + sum{z in Sample} b = sum{z in Sample} Sy[z];
  164.21 +
  164.22 +solve;
  164.23 +
  164.24 +printf "\nbest linear fit is:\n\ty = %f %s %fx\n\n", b, if a < 0 then "-" else "+", abs(a);
  164.25 +
  164.26 +data;
  164.27 +
  164.28 +param:
  164.29 +Sample:   Sx    Sy :=
  164.30 +  1         0    1
  164.31 +  2       0.5  0.9
  164.32 +  3         1  0.7
  164.33 +  4       1.5  1.5
  164.34 +  5       1.9    2
  164.35 +  6       2.5  2.4
  164.36 +  7         3  3.2
  164.37 +  8       3.5    2
  164.38 +  9         4  2.7
  164.39 + 10       4.5  3.5
  164.40 + 11         5    1
  164.41 + 12       5.5    4
  164.42 + 13         6  3.6
  164.43 + 14       6.6  2.7
  164.44 + 15         7  5.7
  164.45 + 16       7.6  4.6
  164.46 + 17       8.5    6
  164.47 + 18         9  6.8
  164.48 + 19        10  7.3
  164.49 +;
  164.50 +
  164.51 +end;
   165.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
   165.2 +++ b/deps/glpk/examples/zebra.mod	Sun Nov 06 20:59:10 2011 +0100
   165.3 @@ -0,0 +1,151 @@
   165.4 +/* ZEBRA, Who Owns the Zebra? */
   165.5 +
   165.6 +/* Written in GNU MathProg by Andrew Makhorin <mao@gnu.org> */
   165.7 +
   165.8 +########################################################################
   165.9 +#  The Zebra Puzzle is a well-known logic puzzle.
  165.10 +#
  165.11 +#  It is often called "Einstein's Puzzle" or "Einstein's Riddle"
  165.12 +#  because it is said to have been invented by Albert Einstein as a boy,
  165.13 +#  with the common claim that Einstein said "only 2 percent of the
  165.14 +#  world's population can solve". It is also sometimes attributed to
  165.15 +#  Lewis Carroll. However, there is no known evidence for Einstein's or
  165.16 +#  Carroll's authorship.
  165.17 +#
  165.18 +#  There are several versions of this puzzle. The version below is
  165.19 +#  quoted from the first known publication in Life International
  165.20 +#  magazine on December 17, 1962.
  165.21 +#
  165.22 +#   1. There are five houses.
  165.23 +#   2. The Englishman lives in the red house.
  165.24 +#   3. The Spaniard owns the dog.
  165.25 +#   4. Coffee is drunk in the green house.
  165.26 +#   5. The Ukrainian drinks tea.
  165.27 +#   6. The green house is immediately to the right of the ivory house.
  165.28 +#   7. The Old Gold smoker owns snails.
  165.29 +#   8. Kools are smoked in the yellow house.
  165.30 +#   9. Milk is drunk in the middle house.
  165.31 +#  10. The Norwegian lives in the first house.
  165.32 +#  11. The man who smokes Chesterfields lives in the house next to the
  165.33 +#      man with the fox.
  165.34 +#  12. Kools are smoked in the house next to the house where the horse
  165.35 +#      is kept.
  165.36 +#  13. The Lucky Strike smoker drinks orange juice.
  165.37 +#  14. The Japanese smokes Parliaments.
  165.38 +#  15. The Norwegian lives next to the blue house.
  165.39 +#
  165.40 +#  Now, who drinks water? Who owns the zebra?
  165.41 +#
  165.42 +#  In the interest of clarity, it must be added that each of the five
  165.43 +#  houses is painted a different color, and their inhabitants are of
  165.44 +#  different national extractions, own different pets, drink different
  165.45 +#  beverages and smoke different brands of American cigarettes. One
  165.46 +#  other thing: In statement 6, right means your right.
  165.47 +#
  165.48 +#  (From Wikipedia, the free encyclopedia.)
  165.49 +########################################################################
  165.50 +
  165.51 +set HOUSE := { 1..5 };
  165.52 +
  165.53 +set COLOR := { "blue", "green", "ivory", "red", "yellow" };
  165.54 +
  165.55 +set NATIONALITY := { "Englishman", "Japanese", "Norwegian", "Spaniard",
  165.56 +      "Ukranian" };
  165.57 +
  165.58 +set DRINK := { "coffee", "milk", "orange_juice", "tea", "water" };
  165.59 +
  165.60 +set SMOKE := { "Chesterfield", "Kools", "Lucky_Strike", "Old_Gold",
  165.61 +      "Parliament" };
  165.62 +
  165.63 +set PET := { "dog", "fox", "horse", "snails", "zebra" };
  165.64 +
  165.65 +var color{HOUSE, COLOR}, binary;
  165.66 +c1{h in HOUSE}: sum{c in COLOR} color[h,c] = 1;
  165.67 +c2{c in COLOR}: sum{h in HOUSE} color[h,c] = 1;
  165.68 +
  165.69 +var nationality{HOUSE, NATIONALITY}, binary;
  165.70 +n1{h in HOUSE}: sum{n in NATIONALITY} nationality[h,n] = 1;
  165.71 +n2{n in NATIONALITY}: sum{h in HOUSE} nationality[h,n] = 1;
  165.72 +
  165.73 +var drink{HOUSE, DRINK}, binary;
  165.74 +d1{h in HOUSE}: sum{d in DRINK} drink[h,d] = 1;
  165.75 +d2{d in DRINK}: sum{h in HOUSE} drink[h,d] = 1;
  165.76 +
  165.77 +var smoke{HOUSE, SMOKE}, binary;
  165.78 +s1{h in HOUSE}: sum{s in SMOKE} smoke[h,s] = 1;
  165.79 +s2{s in SMOKE}: sum{h in HOUSE} smoke[h,s] = 1;
  165.80 +
  165.81 +var pet{HOUSE, PET}, binary;
  165.82 +p1{h in HOUSE}: sum{p in PET} pet[h,p] = 1;
  165.83 +p2{p in PET}: sum{h in HOUSE} pet[h,p] = 1;
  165.84 +
  165.85 +/* the Englishman lives in the red house */
  165.86 +f2{h in HOUSE}: nationality[h,"Englishman"] = color[h,"red"];
  165.87 +
  165.88 +/* the Spaniard owns the dog */
  165.89 +f3{h in HOUSE}: nationality[h,"Spaniard"] = pet[h,"dog"];
  165.90 +
  165.91 +/* coffee is drunk in the green house */
  165.92 +f4{h in HOUSE}: drink[h,"coffee"] = color[h,"green"];
  165.93 +
  165.94 +/* the Ukrainian drinks tea */
  165.95 +f5{h in HOUSE}: nationality[h,"Ukranian"] = drink[h,"tea"];
  165.96 +
  165.97 +/* the green house is immediately to the right of the ivory house */
  165.98 +f6{h in HOUSE}:
  165.99 +   color[h,"green"] = if h = 1 then 0 else color[h-1,"ivory"];
 165.100 +
 165.101 +/* the Old Gold smoker owns snails */
 165.102 +f7{h in HOUSE}: smoke[h,"Old_Gold"] = pet[h,"snails"];
 165.103 +
 165.104 +/* Kools are smoked in the yellow house */
 165.105 +f8{h in HOUSE}: smoke[h,"Kools"] = color[h,"yellow"];
 165.106 +
 165.107 +/* milk is drunk in the middle house */
 165.108 +f9: drink[3,"milk"] = 1;
 165.109 +
 165.110 +/* the Norwegian lives in the first house */
 165.111 +f10: nationality[1,"Norwegian"] = 1;
 165.112 +
 165.113 +/* the man who smokes Chesterfields lives in the house next to the man
 165.114 +   with the fox */
 165.115 +f11{h in HOUSE}:
 165.116 +   (1 - smoke[h,"Chesterfield"]) +
 165.117 +   (if h = 1 then 0 else pet[h-1,"fox"]) +
 165.118 +   (if h = 5 then 0 else pet[h+1,"fox"]) >= 1;
 165.119 +
 165.120 +/* Kools are smoked in the house next to the house where the horse is
 165.121 +   kept */
 165.122 +f12{h in HOUSE}:
 165.123 +   (1 - smoke[h,"Kools"]) +
 165.124 +   (if h = 1 then 0 else pet[h-1,"horse"]) +
 165.125 +   (if h = 5 then 0 else pet[h+1,"horse"]) >= 1;
 165.126 +
 165.127 +/* the Lucky Strike smoker drinks orange juice */
 165.128 +f13{h in HOUSE}: smoke[h,"Lucky_Strike"] = drink[h,"orange_juice"];
 165.129 +
 165.130 +/* the Japanese smokes Parliaments */
 165.131 +f14{h in HOUSE}: nationality[h,"Japanese"] = smoke[h,"Parliament"];
 165.132 +
 165.133 +/* the Norwegian lives next to the blue house */
 165.134 +f15{h in HOUSE}:
 165.135 +   (1 - nationality[h,"Norwegian"]) +
 165.136 +   (if h = 1 then 0 else color[h-1,"blue"]) +
 165.137 +   (if h = 5 then 0 else color[h+1,"blue"]) >= 1;
 165.138 +
 165.139 +solve;
 165.140 +
 165.141 +printf "\n";
 165.142 +printf "HOUSE  COLOR   NATIONALITY  DRINK         SMOKE         PET\n";
 165.143 +for {h in HOUSE}
 165.144 +{  printf "%5d", h;
 165.145 +   printf{c in COLOR: color[h,c]} "  %-6s", c;
 165.146 +   printf{n in NATIONALITY: nationality[h,n]} "  %-11s", n;
 165.147 +   printf{d in DRINK: drink[h,d]} "  %-12s", d;
 165.148 +   printf{s in SMOKE: smoke[h,s]} "  %-12s", s;
 165.149 +   printf{p in PET: pet[h,p]} "  %-6s", p;
 165.150 +   printf "\n";
 165.151 +}
 165.152 +printf "\n";
 165.153 +
 165.154 +end;
   166.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
   166.2 +++ b/deps/glpk/install-sh	Sun Nov 06 20:59:10 2011 +0100
   166.3 @@ -0,0 +1,520 @@
   166.4 +#!/bin/sh
   166.5 +# install - install a program, script, or datafile
   166.6 +
   166.7 +scriptversion=2009-04-28.21; # UTC
   166.8 +
   166.9 +# This originates from X11R5 (mit/util/scripts/install.sh), which was
  166.10 +# later released in X11R6 (xc/config/util/install.sh) with the
  166.11 +# following copyright and license.
  166.12 +#
  166.13 +# Copyright (C) 1994 X Consortium
  166.14 +#
  166.15 +# Permission is hereby granted, free of charge, to any person obtaining a copy
  166.16 +# of this software and associated documentation files (the "Software"), to
  166.17 +# deal in the Software without restriction, including without limitation the
  166.18 +# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
  166.19 +# sell copies of the Software, and to permit persons to whom the Software is
  166.20 +# furnished to do so, subject to the following conditions:
  166.21 +#
  166.22 +# The above copyright notice and this permission notice shall be included in
  166.23 +# all copies or substantial portions of the Software.
  166.24 +#
  166.25 +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  166.26 +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  166.27 +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL THE
  166.28 +# X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
  166.29 +# AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNEC-
  166.30 +# TION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  166.31 +#
  166.32 +# Except as contained in this notice, the name of the X Consortium shall not
  166.33 +# be used in advertising or otherwise to promote the sale, use or other deal-
  166.34 +# ings in this Software without prior written authorization from the X Consor-
  166.35 +# tium.
  166.36 +#
  166.37 +#
  166.38 +# FSF changes to this file are in the public domain.
  166.39 +#
  166.40 +# Calling this script install-sh is preferred over install.sh, to prevent
  166.41 +# `make' implicit rules from creating a file called install from it
  166.42 +# when there is no Makefile.
  166.43 +#
  166.44 +# This script is compatible with the BSD install script, but was written
  166.45 +# from scratch.
  166.46 +
  166.47 +nl='
  166.48 +'
  166.49 +IFS=" ""	$nl"
  166.50 +
  166.51 +# set DOITPROG to echo to test this script
  166.52 +
  166.53 +# Don't use :- since 4.3BSD and earlier shells don't like it.
  166.54 +doit=${DOITPROG-}
  166.55 +if test -z "$doit"; then
  166.56 +  doit_exec=exec
  166.57 +else
  166.58 +  doit_exec=$doit
  166.59 +fi
  166.60 +
  166.61 +# Put in absolute file names if you don't have them in your path;
  166.62 +# or use environment vars.
  166.63 +
  166.64 +chgrpprog=${CHGRPPROG-chgrp}
  166.65 +chmodprog=${CHMODPROG-chmod}
  166.66 +chownprog=${CHOWNPROG-chown}
  166.67 +cmpprog=${CMPPROG-cmp}
  166.68 +cpprog=${CPPROG-cp}
  166.69 +mkdirprog=${MKDIRPROG-mkdir}
  166.70 +mvprog=${MVPROG-mv}
  166.71 +rmprog=${RMPROG-rm}
  166.72 +stripprog=${STRIPPROG-strip}
  166.73 +
  166.74 +posix_glob='?'
  166.75 +initialize_posix_glob='
  166.76 +  test "$posix_glob" != "?" || {
  166.77 +    if (set -f) 2>/dev/null; then
  166.78 +      posix_glob=
  166.79 +    else
  166.80 +      posix_glob=:
  166.81 +    fi
  166.82 +  }
  166.83 +'
  166.84 +
  166.85 +posix_mkdir=
  166.86 +
  166.87 +# Desired mode of installed file.
  166.88 +mode=0755
  166.89 +
  166.90 +chgrpcmd=
  166.91 +chmodcmd=$chmodprog
  166.92 +chowncmd=
  166.93 +mvcmd=$mvprog
  166.94 +rmcmd="$rmprog -f"
  166.95 +stripcmd=
  166.96 +
  166.97 +src=
  166.98 +dst=
  166.99 +dir_arg=
 166.100 +dst_arg=
 166.101 +
 166.102 +copy_on_change=false
 166.103 +no_target_directory=
 166.104 +
 166.105 +usage="\
 166.106 +Usage: $0 [OPTION]... [-T] SRCFILE DSTFILE
 166.107 +   or: $0 [OPTION]... SRCFILES... DIRECTORY
 166.108 +   or: $0 [OPTION]... -t DIRECTORY SRCFILES...
 166.109 +   or: $0 [OPTION]... -d DIRECTORIES...
 166.110 +
 166.111 +In the 1st form, copy SRCFILE to DSTFILE.
 166.112 +In the 2nd and 3rd, copy all SRCFILES to DIRECTORY.
 166.113 +In the 4th, create DIRECTORIES.
 166.114 +
 166.115 +Options:
 166.116 +     --help     display this help and exit.
 166.117 +     --version  display version info and exit.
 166.118 +
 166.119 +  -c            (ignored)
 166.120 +  -C            install only if different (preserve the last data modification time)
 166.121 +  -d            create directories instead of installing files.
 166.122 +  -g GROUP      $chgrpprog installed files to GROUP.
 166.123 +  -m MODE       $chmodprog installed files to MODE.
 166.124 +  -o USER       $chownprog installed files to USER.
 166.125 +  -s            $stripprog installed files.
 166.126 +  -t DIRECTORY  install into DIRECTORY.
 166.127 +  -T            report an error if DSTFILE is a directory.
 166.128 +
 166.129 +Environment variables override the default commands:
 166.130 +  CHGRPPROG CHMODPROG CHOWNPROG CMPPROG CPPROG MKDIRPROG MVPROG
 166.131 +  RMPROG STRIPPROG
 166.132 +"
 166.133 +
 166.134 +while test $# -ne 0; do
 166.135 +  case $1 in
 166.136 +    -c) ;;
 166.137 +
 166.138 +    -C) copy_on_change=true;;
 166.139 +
 166.140 +    -d) dir_arg=true;;
 166.141 +
 166.142 +    -g) chgrpcmd="$chgrpprog $2"
 166.143 +	shift;;
 166.144 +
 166.145 +    --help) echo "$usage"; exit $?;;
 166.146 +
 166.147 +    -m) mode=$2
 166.148 +	case $mode in
 166.149 +	  *' '* | *'	'* | *'
 166.150 +'*	  | *'*'* | *'?'* | *'['*)
 166.151 +	    echo "$0: invalid mode: $mode" >&2
 166.152 +	    exit 1;;
 166.153 +	esac
 166.154 +	shift;;
 166.155 +
 166.156 +    -o) chowncmd="$chownprog $2"
 166.157 +	shift;;
 166.158 +
 166.159 +    -s) stripcmd=$stripprog;;
 166.160 +
 166.161 +    -t) dst_arg=$2
 166.162 +	shift;;
 166.163 +
 166.164 +    -T) no_target_directory=true;;
 166.165 +
 166.166 +    --version) echo "$0 $scriptversion"; exit $?;;
 166.167 +
 166.168 +    --)	shift
 166.169 +	break;;
 166.170 +
 166.171 +    -*)	echo "$0: invalid option: $1" >&2
 166.172 +	exit 1;;
 166.173 +
 166.174 +    *)  break;;
 166.175 +  esac
 166.176 +  shift
 166.177 +done
 166.178 +
 166.179 +if test $# -ne 0 && test -z "$dir_arg$dst_arg"; then
 166.180 +  # When -d is used, all remaining arguments are directories to create.
 166.181 +  # When -t is used, the destination is already specified.
 166.182 +  # Otherwise, the last argument is the destination.  Remove it from $@.
 166.183 +  for arg
 166.184 +  do
 166.185 +    if test -n "$dst_arg"; then
 166.186 +      # $@ is not empty: it contains at least $arg.
 166.187 +      set fnord "$@" "$dst_arg"
 166.188 +      shift # fnord
 166.189 +    fi
 166.190 +    shift # arg
 166.191 +    dst_arg=$arg
 166.192 +  done
 166.193 +fi
 166.194 +
 166.195 +if test $# -eq 0; then
 166.196 +  if test -z "$dir_arg"; then
 166.197 +    echo "$0: no input file specified." >&2
 166.198 +    exit 1
 166.199 +  fi
 166.200 +  # It's OK to call `install-sh -d' without argument.
 166.201 +  # This can happen when creating conditional directories.
 166.202 +  exit 0
 166.203 +fi
 166.204 +
 166.205 +if test -z "$dir_arg"; then
 166.206 +  trap '(exit $?); exit' 1 2 13 15
 166.207 +
 166.208 +  # Set umask so as not to create temps with too-generous modes.
 166.209 +  # However, 'strip' requires both read and write access to temps.
 166.210 +  case $mode in
 166.211 +    # Optimize common cases.
 166.212 +    *644) cp_umask=133;;
 166.213 +    *755) cp_umask=22;;
 166.214 +
 166.215 +    *[0-7])
 166.216 +      if test -z "$stripcmd"; then
 166.217 +	u_plus_rw=
 166.218 +      else
 166.219 +	u_plus_rw='% 200'
 166.220 +      fi
 166.221 +      cp_umask=`expr '(' 777 - $mode % 1000 ')' $u_plus_rw`;;
 166.222 +    *)
 166.223 +      if test -z "$stripcmd"; then
 166.224 +	u_plus_rw=
 166.225 +      else
 166.226 +	u_plus_rw=,u+rw
 166.227 +      fi
 166.228 +      cp_umask=$mode$u_plus_rw;;
 166.229 +  esac
 166.230 +fi
 166.231 +
 166.232 +for src
 166.233 +do
 166.234 +  # Protect names starting with `-'.
 166.235 +  case $src in
 166.236 +    -*) src=./$src;;
 166.237 +  esac
 166.238 +
 166.239 +  if test -n "$dir_arg"; then
 166.240 +    dst=$src
 166.241 +    dstdir=$dst
 166.242 +    test -d "$dstdir"
 166.243 +    dstdir_status=$?
 166.244 +  else
 166.245 +
 166.246 +    # Waiting for this to be detected by the "$cpprog $src $dsttmp" command
 166.247 +    # might cause directories to be created, which would be especially bad
 166.248 +    # if $src (and thus $dsttmp) contains '*'.
 166.249 +    if test ! -f "$src" && test ! -d "$src"; then
 166.250 +      echo "$0: $src does not exist." >&2
 166.251 +      exit 1
 166.252 +    fi
 166.253 +
 166.254 +    if test -z "$dst_arg"; then
 166.255 +      echo "$0: no destination specified." >&2
 166.256 +      exit 1
 166.257 +    fi
 166.258 +
 166.259 +    dst=$dst_arg
 166.260 +    # Protect names starting with `-'.
 166.261 +    case $dst in
 166.262 +      -*) dst=./$dst;;
 166.263 +    esac
 166.264 +
 166.265 +    # If destination is a directory, append the input filename; won't work
 166.266 +    # if double slashes aren't ignored.
 166.267 +    if test -d "$dst"; then
 166.268 +      if test -n "$no_target_directory"; then
 166.269 +	echo "$0: $dst_arg: Is a directory" >&2
 166.270 +	exit 1
 166.271 +      fi
 166.272 +      dstdir=$dst
 166.273 +      dst=$dstdir/`basename "$src"`
 166.274 +      dstdir_status=0
 166.275 +    else
 166.276 +      # Prefer dirname, but fall back on a substitute if dirname fails.
 166.277 +      dstdir=`
 166.278 +	(dirname "$dst") 2>/dev/null ||
 166.279 +	expr X"$dst" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
 166.280 +	     X"$dst" : 'X\(//\)[^/]' \| \
 166.281 +	     X"$dst" : 'X\(//\)$' \| \
 166.282 +	     X"$dst" : 'X\(/\)' \| . 2>/dev/null ||
 166.283 +	echo X"$dst" |
 166.284 +	    sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{
 166.285 +		   s//\1/
 166.286 +		   q
 166.287 +		 }
 166.288 +		 /^X\(\/\/\)[^/].*/{
 166.289 +		   s//\1/
 166.290 +		   q
 166.291 +		 }
 166.292 +		 /^X\(\/\/\)$/{
 166.293 +		   s//\1/
 166.294 +		   q
 166.295 +		 }
 166.296 +		 /^X\(\/\).*/{
 166.297 +		   s//\1/
 166.298 +		   q
 166.299 +		 }
 166.300 +		 s/.*/./; q'
 166.301 +      `
 166.302 +
 166.303 +      test -d "$dstdir"
 166.304 +      dstdir_status=$?
 166.305 +    fi
 166.306 +  fi
 166.307 +
 166.308 +  obsolete_mkdir_used=false
 166.309 +
 166.310 +  if test $dstdir_status != 0; then
 166.311 +    case $posix_mkdir in
 166.312 +      '')
 166.313 +	# Create intermediate dirs using mode 755 as modified by the umask.
 166.314 +	# This is like FreeBSD 'install' as of 1997-10-28.
 166.315 +	umask=`umask`
 166.316 +	case $stripcmd.$umask in
 166.317 +	  # Optimize common cases.
 166.318 +	  *[2367][2367]) mkdir_umask=$umask;;
 166.319 +	  .*0[02][02] | .[02][02] | .[02]) mkdir_umask=22;;
 166.320 +
 166.321 +	  *[0-7])
 166.322 +	    mkdir_umask=`expr $umask + 22 \
 166.323 +	      - $umask % 100 % 40 + $umask % 20 \
 166.324 +	      - $umask % 10 % 4 + $umask % 2
 166.325 +	    `;;
 166.326 +	  *) mkdir_umask=$umask,go-w;;
 166.327 +	esac
 166.328 +
 166.329 +	# With -d, create the new directory with the user-specified mode.
 166.330 +	# Otherwise, rely on $mkdir_umask.
 166.331 +	if test -n "$dir_arg"; then
 166.332 +	  mkdir_mode=-m$mode
 166.333 +	else
 166.334 +	  mkdir_mode=
 166.335 +	fi
 166.336 +
 166.337 +	posix_mkdir=false
 166.338 +	case $umask in
 166.339 +	  *[123567][0-7][0-7])
 166.340 +	    # POSIX mkdir -p sets u+wx bits regardless of umask, which
 166.341 +	    # is incompatible with FreeBSD 'install' when (umask & 300) != 0.
 166.342 +	    ;;
 166.343 +	  *)
 166.344 +	    tmpdir=${TMPDIR-/tmp}/ins$RANDOM-$$
 166.345 +	    trap 'ret=$?; rmdir "$tmpdir/d" "$tmpdir" 2>/dev/null; exit $ret' 0
 166.346 +
 166.347 +	    if (umask $mkdir_umask &&
 166.348 +		exec $mkdirprog $mkdir_mode -p -- "$tmpdir/d") >/dev/null 2>&1
 166.349 +	    then
 166.350 +	      if test -z "$dir_arg" || {
 166.351 +		   # Check for POSIX incompatibilities with -m.
 166.352 +		   # HP-UX 11.23 and IRIX 6.5 mkdir -m -p sets group- or
 166.353 +		   # other-writeable bit of parent directory when it shouldn't.
 166.354 +		   # FreeBSD 6.1 mkdir -m -p sets mode of existing directory.
 166.355 +		   ls_ld_tmpdir=`ls -ld "$tmpdir"`
 166.356 +		   case $ls_ld_tmpdir in
 166.357 +		     d????-?r-*) different_mode=700;;
 166.358 +		     d????-?--*) different_mode=755;;
 166.359 +		     *) false;;
 166.360 +		   esac &&
 166.361 +		   $mkdirprog -m$different_mode -p -- "$tmpdir" && {
 166.362 +		     ls_ld_tmpdir_1=`ls -ld "$tmpdir"`
 166.363 +		     test "$ls_ld_tmpdir" = "$ls_ld_tmpdir_1"
 166.364 +		   }
 166.365 +		 }
 166.366 +	      then posix_mkdir=:
 166.367 +	      fi
 166.368 +	      rmdir "$tmpdir/d" "$tmpdir"
 166.369 +	    else
 166.370 +	      # Remove any dirs left behind by ancient mkdir implementations.
 166.371 +	      rmdir ./$mkdir_mode ./-p ./-- 2>/dev/null
 166.372 +	    fi
 166.373 +	    trap '' 0;;
 166.374 +	esac;;
 166.375 +    esac
 166.376 +
 166.377 +    if
 166.378 +      $posix_mkdir && (
 166.379 +	umask $mkdir_umask &&
 166.380 +	$doit_exec $mkdirprog $mkdir_mode -p -- "$dstdir"
 166.381 +      )
 166.382 +    then :
 166.383 +    else
 166.384 +
 166.385 +      # The umask is ridiculous, or mkdir does not conform to POSIX,
 166.386 +      # or it failed possibly due to a race condition.  Create the
 166.387 +      # directory the slow way, step by step, checking for races as we go.
 166.388 +
 166.389 +      case $dstdir in
 166.390 +	/*) prefix='/';;
 166.391 +	-*) prefix='./';;
 166.392 +	*)  prefix='';;
 166.393 +      esac
 166.394 +
 166.395 +      eval "$initialize_posix_glob"
 166.396 +
 166.397 +      oIFS=$IFS
 166.398 +      IFS=/
 166.399 +      $posix_glob set -f
 166.400 +      set fnord $dstdir
 166.401 +      shift
 166.402 +      $posix_glob set +f
 166.403 +      IFS=$oIFS
 166.404 +
 166.405 +      prefixes=
 166.406 +
 166.407 +      for d
 166.408 +      do
 166.409 +	test -z "$d" && continue
 166.410 +
 166.411 +	prefix=$prefix$d
 166.412 +	if test -d "$prefix"; then
 166.413 +	  prefixes=
 166.414 +	else
 166.415 +	  if $posix_mkdir; then
 166.416 +	    (umask=$mkdir_umask &&
 166.417 +	     $doit_exec $mkdirprog $mkdir_mode -p -- "$dstdir") && break
 166.418 +	    # Don't fail if two instances are running concurrently.
 166.419 +	    test -d "$prefix" || exit 1
 166.420 +	  else
 166.421 +	    case $prefix in
 166.422 +	      *\'*) qprefix=`echo "$prefix" | sed "s/'/'\\\\\\\\''/g"`;;
 166.423 +	      *) qprefix=$prefix;;
 166.424 +	    esac
 166.425 +	    prefixes="$prefixes '$qprefix'"
 166.426 +	  fi
 166.427 +	fi
 166.428 +	prefix=$prefix/
 166.429 +      done
 166.430 +
 166.431 +      if test -n "$prefixes"; then
 166.432 +	# Don't fail if two instances are running concurrently.
 166.433 +	(umask $mkdir_umask &&
 166.434 +	 eval "\$doit_exec \$mkdirprog $prefixes") ||
 166.435 +	  test -d "$dstdir" || exit 1
 166.436 +	obsolete_mkdir_used=true
 166.437 +      fi
 166.438 +    fi
 166.439 +  fi
 166.440 +
 166.441 +  if test -n "$dir_arg"; then
 166.442 +    { test -z "$chowncmd" || $doit $chowncmd "$dst"; } &&
 166.443 +    { test -z "$chgrpcmd" || $doit $chgrpcmd "$dst"; } &&
 166.444 +    { test "$obsolete_mkdir_used$chowncmd$chgrpcmd" = false ||
 166.445 +      test -z "$chmodcmd" || $doit $chmodcmd $mode "$dst"; } || exit 1
 166.446 +  else
 166.447 +
 166.448 +    # Make a couple of temp file names in the proper directory.
 166.449 +    dsttmp=$dstdir/_inst.$$_
 166.450 +    rmtmp=$dstdir/_rm.$$_
 166.451 +
 166.452 +    # Trap to clean up those temp files at exit.
 166.453 +    trap 'ret=$?; rm -f "$dsttmp" "$rmtmp" && exit $ret' 0
 166.454 +
 166.455 +    # Copy the file name to the temp name.
 166.456 +    (umask $cp_umask && $doit_exec $cpprog "$src" "$dsttmp") &&
 166.457 +
 166.458 +    # and set any options; do chmod last to preserve setuid bits.
 166.459 +    #
 166.460 +    # If any of these fail, we abort the whole thing.  If we want to
 166.461 +    # ignore errors from any of these, just make sure not to ignore
 166.462 +    # errors from the above "$doit $cpprog $src $dsttmp" command.
 166.463 +    #
 166.464 +    { test -z "$chowncmd" || $doit $chowncmd "$dsttmp"; } &&
 166.465 +    { test -z "$chgrpcmd" || $doit $chgrpcmd "$dsttmp"; } &&
 166.466 +    { test -z "$stripcmd" || $doit $stripcmd "$dsttmp"; } &&
 166.467 +    { test -z "$chmodcmd" || $doit $chmodcmd $mode "$dsttmp"; } &&
 166.468 +
 166.469 +    # If -C, don't bother to copy if it wouldn't change the file.
 166.470 +    if $copy_on_change &&
 166.471 +       old=`LC_ALL=C ls -dlL "$dst"	2>/dev/null` &&
 166.472 +       new=`LC_ALL=C ls -dlL "$dsttmp"	2>/dev/null` &&
 166.473 +
 166.474 +       eval "$initialize_posix_glob" &&
 166.475 +       $posix_glob set -f &&
 166.476 +       set X $old && old=:$2:$4:$5:$6 &&
 166.477 +       set X $new && new=:$2:$4:$5:$6 &&
 166.478 +       $posix_glob set +f &&
 166.479 +
 166.480 +       test "$old" = "$new" &&
 166.481 +       $cmpprog "$dst" "$dsttmp" >/dev/null 2>&1
 166.482 +    then
 166.483 +      rm -f "$dsttmp"
 166.484 +    else
 166.485 +      # Rename the file to the real destination.
 166.486 +      $doit $mvcmd -f "$dsttmp" "$dst" 2>/dev/null ||
 166.487 +
 166.488 +      # The rename failed, perhaps because mv can't rename something else
 166.489 +      # to itself, or perhaps because mv is so ancient that it does not
 166.490 +      # support -f.
 166.491 +      {
 166.492 +	# Now remove or move aside any old file at destination location.
 166.493 +	# We try this two ways since rm can't unlink itself on some
 166.494 +	# systems and the destination file might be busy for other
 166.495 +	# reasons.  In this case, the final cleanup might fail but the new
 166.496 +	# file should still install successfully.
 166.497 +	{
 166.498 +	  test ! -f "$dst" ||
 166.499 +	  $doit $rmcmd -f "$dst" 2>/dev/null ||
 166.500 +	  { $doit $mvcmd -f "$dst" "$rmtmp" 2>/dev/null &&
 166.501 +	    { $doit $rmcmd -f "$rmtmp" 2>/dev/null; :; }
 166.502 +	  } ||
 166.503 +	  { echo "$0: cannot unlink or rename $dst" >&2
 166.504 +	    (exit 1); exit 1
 166.505 +	  }
 166.506 +	} &&
 166.507 +
 166.508 +	# Now rename the file to the real destination.
 166.509 +	$doit $mvcmd "$dsttmp" "$dst"
 166.510 +      }
 166.511 +    fi || exit 1
 166.512 +
 166.513 +    trap '' 0
 166.514 +  fi
 166.515 +done
 166.516 +
 166.517 +# Local variables:
 166.518 +# eval: (add-hook 'write-file-hooks 'time-stamp)
 166.519 +# time-stamp-start: "scriptversion="
 166.520 +# time-stamp-format: "%:y-%02m-%02d.%02H"
 166.521 +# time-stamp-time-zone: "UTC"
 166.522 +# time-stamp-end: "; # UTC"
 166.523 +# End:
   167.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
   167.2 +++ b/deps/glpk/ltmain.sh	Sun Nov 06 20:59:10 2011 +0100
   167.3 @@ -0,0 +1,9436 @@
   167.4 +# Generated from ltmain.m4sh.
   167.5 +
   167.6 +# libtool (GNU libtool 1.3140 2009-12-30) 2.2.7a
   167.7 +# Written by Gordon Matzigkeit <gord@gnu.ai.mit.edu>, 1996
   167.8 +
   167.9 +# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2003, 2004, 2005, 2006,
  167.10 +# 2007, 2008, 2009 Free Software Foundation, Inc.
  167.11 +# This is free software; see the source for copying conditions.  There is NO
  167.12 +# warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  167.13 +
  167.14 +# GNU Libtool is free software; you can redistribute it and/or modify
  167.15 +# it under the terms of the GNU General Public License as published by
  167.16 +# the Free Software Foundation; either version 2 of the License, or
  167.17 +# (at your option) any later version.
  167.18 +#
  167.19 +# As a special exception to the GNU General Public License,
  167.20 +# if you distribute this file as part of a program or library that
  167.21 +# is built using GNU Libtool, you may include this file under the
  167.22 +# same distribution terms that you use for the rest of that program.
  167.23 +#
  167.24 +# GNU Libtool is distributed in the hope that it will be useful, but
  167.25 +# WITHOUT ANY WARRANTY; without even the implied warranty of
  167.26 +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  167.27 +# General Public License for more details.
  167.28 +#
  167.29 +# You should have received a copy of the GNU General Public License
  167.30 +# along with GNU Libtool; see the file COPYING.  If not, a copy
  167.31 +# can be downloaded from http://www.gnu.org/licenses/gpl.html,
  167.32 +# or obtained by writing to the Free Software Foundation, Inc.,
  167.33 +# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
  167.34 +
  167.35 +# Usage: $progname [OPTION]... [MODE-ARG]...
  167.36 +#
  167.37 +# Provide generalized library-building support services.
  167.38 +#
  167.39 +#       --config             show all configuration variables
  167.40 +#       --debug              enable verbose shell tracing
  167.41 +#   -n, --dry-run            display commands without modifying any files
  167.42 +#       --features           display basic configuration information and exit
  167.43 +#       --mode=MODE          use operation mode MODE
  167.44 +#       --preserve-dup-deps  don't remove duplicate dependency libraries
  167.45 +#       --quiet, --silent    don't print informational messages
  167.46 +#       --no-quiet, --no-silent
  167.47 +#                            print informational messages (default)
  167.48 +#       --tag=TAG            use configuration variables from tag TAG
  167.49 +#   -v, --verbose            print more informational messages than default
  167.50 +#       --no-verbose         don't print the extra informational messages
  167.51 +#       --version            print version information
  167.52 +#   -h, --help, --help-all   print short, long, or detailed help message
  167.53 +#
  167.54 +# MODE must be one of the following:
  167.55 +#
  167.56 +#         clean              remove files from the build directory
  167.57 +#         compile            compile a source file into a libtool object
  167.58 +#         execute            automatically set library path, then run a program
  167.59 +#         finish             complete the installation of libtool libraries
  167.60 +#         install            install libraries or executables
  167.61 +#         link               create a library or an executable
  167.62 +#         uninstall          remove libraries from an installed directory
  167.63 +#
  167.64 +# MODE-ARGS vary depending on the MODE.  When passed as first option,
  167.65 +# `--mode=MODE' may be abbreviated as `MODE' or a unique abbreviation of that.
  167.66 +# Try `$progname --help --mode=MODE' for a more detailed description of MODE.
  167.67 +#
  167.68 +# When reporting a bug, please describe a test case to reproduce it and
  167.69 +# include the following information:
  167.70 +#
  167.71 +#         host-triplet:	$host
  167.72 +#         shell:		$SHELL
  167.73 +#         compiler:		$LTCC
  167.74 +#         compiler flags:		$LTCFLAGS
  167.75 +#         linker:		$LD (gnu? $with_gnu_ld)
  167.76 +#         $progname:	(GNU libtool 1.3140 2009-12-30) 2.2.7a
  167.77 +#         automake:	$automake_version
  167.78 +#         autoconf:	$autoconf_version
  167.79 +#
  167.80 +# Report bugs to <bug-libtool@gnu.org>.
  167.81 +
  167.82 +PROGRAM=libtool
  167.83 +PACKAGE=libtool
  167.84 +VERSION=2.2.7a
  167.85 +TIMESTAMP=" 1.3140 2009-12-30"
  167.86 +package_revision=1.3140
  167.87 +
  167.88 +# Be Bourne compatible
  167.89 +if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then
  167.90 +  emulate sh
  167.91 +  NULLCMD=:
  167.92 +  # Zsh 3.x and 4.x performs word splitting on ${1+"$@"}, which
  167.93 +  # is contrary to our usage.  Disable this feature.
  167.94 +  alias -g '${1+"$@"}'='"$@"'
  167.95 +  setopt NO_GLOB_SUBST
  167.96 +else
  167.97 +  case `(set -o) 2>/dev/null` in *posix*) set -o posix;; esac
  167.98 +fi
  167.99 +BIN_SH=xpg4; export BIN_SH # for Tru64
 167.100 +DUALCASE=1; export DUALCASE # for MKS sh
 167.101 +
 167.102 +# A function that is used when there is no print builtin or printf.
 167.103 +func_fallback_echo ()
 167.104 +{
 167.105 +  eval 'cat <<_LTECHO_EOF
 167.106 +$1
 167.107 +_LTECHO_EOF'
 167.108 +}
 167.109 +
 167.110 +# NLS nuisances: We save the old values to restore during execute mode.
 167.111 +# Only set LANG and LC_ALL to C if already set.
 167.112 +# These must not be set unconditionally because not all systems understand
 167.113 +# e.g. LANG=C (notably SCO).
 167.114 +lt_user_locale=
 167.115 +lt_safe_locale=
 167.116 +for lt_var in LANG LANGUAGE LC_ALL LC_CTYPE LC_COLLATE LC_MESSAGES
 167.117 +do
 167.118 +  eval "if test \"\${$lt_var+set}\" = set; then
 167.119 +          save_$lt_var=\$$lt_var
 167.120 +          $lt_var=C
 167.121 +	  export $lt_var
 167.122 +	  lt_user_locale=\"$lt_var=\\\$save_\$lt_var; \$lt_user_locale\"
 167.123 +	  lt_safe_locale=\"$lt_var=C; \$lt_safe_locale\"
 167.124 +	fi"
 167.125 +done
 167.126 +
 167.127 +$lt_unset CDPATH
 167.128 +
 167.129 +
 167.130 +
 167.131 +
 167.132 +
 167.133 +
 167.134 +
 167.135 +# Work around backward compatibility issue on IRIX 6.5. On IRIX 6.4+, sh
 167.136 +# is ksh but when the shell is invoked as "sh" and the current value of
 167.137 +# the _XPG environment variable is not equal to 1 (one), the special
 167.138 +# positional parameter $0, within a function call, is the name of the
 167.139 +# function.
 167.140 +progpath="$0"
 167.141 +
 167.142 +
 167.143 +
 167.144 +: ${CP="cp -f"}
 167.145 +test "${ECHO+set}" = set || ECHO=${as_echo-'printf %s\n'}
 167.146 +: ${EGREP="/usr/bin/grep -E"}
 167.147 +: ${FGREP="/usr/bin/grep -F"}
 167.148 +: ${GREP="/usr/bin/grep"}
 167.149 +: ${LN_S="ln -s"}
 167.150 +: ${MAKE="make"}
 167.151 +: ${MKDIR="mkdir"}
 167.152 +: ${MV="mv -f"}
 167.153 +: ${RM="rm -f"}
 167.154 +: ${SED="/usr/bin/sed"}
 167.155 +: ${SHELL="${CONFIG_SHELL-/bin/sh}"}
 167.156 +: ${Xsed="$SED -e 1s/^X//"}
 167.157 +
 167.158 +# Global variables:
 167.159 +EXIT_SUCCESS=0
 167.160 +EXIT_FAILURE=1
 167.161 +EXIT_MISMATCH=63  # $? = 63 is used to indicate version mismatch to missing.
 167.162 +EXIT_SKIP=77	  # $? = 77 is used to indicate a skipped test to automake.
 167.163 +
 167.164 +exit_status=$EXIT_SUCCESS
 167.165 +
 167.166 +# Make sure IFS has a sensible default
 167.167 +lt_nl='
 167.168 +'
 167.169 +IFS=" 	$lt_nl"
 167.170 +
 167.171 +dirname="s,/[^/]*$,,"
 167.172 +basename="s,^.*/,,"
 167.173 +
 167.174 +# func_dirname_and_basename file append nondir_replacement
 167.175 +# perform func_basename and func_dirname in a single function
 167.176 +# call:
 167.177 +#   dirname:  Compute the dirname of FILE.  If nonempty,
 167.178 +#             add APPEND to the result, otherwise set result
 167.179 +#             to NONDIR_REPLACEMENT.
 167.180 +#             value returned in "$func_dirname_result"
 167.181 +#   basename: Compute filename of FILE.
 167.182 +#             value retuned in "$func_basename_result"
 167.183 +# Implementation must be kept synchronized with func_dirname
 167.184 +# and func_basename. For efficiency, we do not delegate to
 167.185 +# those functions but instead duplicate the functionality here.
 167.186 +func_dirname_and_basename ()
 167.187 +{
 167.188 +  # Extract subdirectory from the argument.
 167.189 +  func_dirname_result=`$ECHO "${1}" | $SED -e "$dirname"`
 167.190 +  if test "X$func_dirname_result" = "X${1}"; then
 167.191 +    func_dirname_result="${3}"
 167.192 +  else
 167.193 +    func_dirname_result="$func_dirname_result${2}"
 167.194 +  fi
 167.195 +  func_basename_result=`$ECHO "${1}" | $SED -e "$basename"`
 167.196 +}
 167.197 +
 167.198 +# Generated shell functions inserted here.
 167.199 +
 167.200 +# These SED scripts presuppose an absolute path with a trailing slash.
 167.201 +pathcar='s,^/\([^/]*\).*$,\1,'
 167.202 +pathcdr='s,^/[^/]*,,'
 167.203 +removedotparts=':dotsl
 167.204 +		s@/\./@/@g
 167.205 +		t dotsl
 167.206 +		s,/\.$,/,'
 167.207 +collapseslashes='s@/\{1,\}@/@g'
 167.208 +finalslash='s,/*$,/,'
 167.209 +
 167.210 +# func_normal_abspath PATH
 167.211 +# Remove doubled-up and trailing slashes, "." path components,
 167.212 +# and cancel out any ".." path components in PATH after making
 167.213 +# it an absolute path.
 167.214 +#             value returned in "$func_normal_abspath_result"
 167.215 +func_normal_abspath ()
 167.216 +{
 167.217 +  # Start from root dir and reassemble the path.
 167.218 +  func_normal_abspath_result=
 167.219 +  func_normal_abspath_tpath=$1
 167.220 +  func_normal_abspath_altnamespace=
 167.221 +  case $func_normal_abspath_tpath in
 167.222 +    "")
 167.223 +      # Empty path, that just means $cwd.
 167.224 +      func_stripname '' '/' "`pwd`"
 167.225 +      func_normal_abspath_result=$func_stripname_result
 167.226 +      return
 167.227 +    ;;
 167.228 +    # The next three entries are used to spot a run of precisely
 167.229 +    # two leading slashes without using negated character classes;
 167.230 +    # we take advantage of case's first-match behaviour.
 167.231 +    ///*)
 167.232 +      # Unusual form of absolute path, do nothing.
 167.233 +    ;;
 167.234 +    //*)
 167.235 +      # Not necessarily an ordinary path; POSIX reserves leading '//'
 167.236 +      # and for example Cygwin uses it to access remote file shares
 167.237 +      # over CIFS/SMB, so we conserve a leading double slash if found.
 167.238 +      func_normal_abspath_altnamespace=/
 167.239 +    ;;
 167.240 +    /*)
 167.241 +      # Absolute path, do nothing.
 167.242 +    ;;
 167.243 +    *)
 167.244 +      # Relative path, prepend $cwd.
 167.245 +      func_normal_abspath_tpath=`pwd`/$func_normal_abspath_tpath
 167.246 +    ;;
 167.247 +  esac
 167.248 +  # Cancel out all the simple stuff to save iterations.  We also want
 167.249 +  # the path to end with a slash for ease of parsing, so make sure
 167.250 +  # there is one (and only one) here.
 167.251 +  func_normal_abspath_tpath=`$ECHO "$func_normal_abspath_tpath" | $SED \
 167.252 +        -e "$removedotparts" -e "$collapseslashes" -e "$finalslash"`
 167.253 +  while :; do
 167.254 +    # Processed it all yet?
 167.255 +    if test "$func_normal_abspath_tpath" = / ; then
 167.256 +      # If we ascended to the root using ".." the result may be empty now.
 167.257 +      if test -z "$func_normal_abspath_result" ; then
 167.258 +        func_normal_abspath_result=/
 167.259 +      fi
 167.260 +      break
 167.261 +    fi
 167.262 +    func_normal_abspath_tcomponent=`$ECHO "$func_normal_abspath_tpath" | $SED \
 167.263 +        -e "$pathcar"`
 167.264 +    func_normal_abspath_tpath=`$ECHO "$func_normal_abspath_tpath" | $SED \
 167.265 +        -e "$pathcdr"`
 167.266 +    # Figure out what to do with it
 167.267 +    case $func_normal_abspath_tcomponent in
 167.268 +      "")
 167.269 +        # Trailing empty path component, ignore it.
 167.270 +      ;;
 167.271 +      ..)
 167.272 +        # Parent dir; strip last assembled component from result.
 167.273 +        func_dirname "$func_normal_abspath_result"
 167.274 +        func_normal_abspath_result=$func_dirname_result
 167.275 +      ;;
 167.276 +      *)
 167.277 +        # Actual path component, append it.
 167.278 +        func_normal_abspath_result=$func_normal_abspath_result/$func_normal_abspath_tcomponent
 167.279 +      ;;
 167.280 +    esac
 167.281 +  done
 167.282 +  # Restore leading double-slash if one was found on entry.
 167.283 +  func_normal_abspath_result=$func_normal_abspath_altnamespace$func_normal_abspath_result
 167.284 +}
 167.285 +
 167.286 +# func_relative_path SRCDIR DSTDIR
 167.287 +# generates a relative path from SRCDIR to DSTDIR, with a trailing
 167.288 +# slash if non-empty, suitable for immediately appending a filename
 167.289 +# without needing to append a separator.
 167.290 +#             value returned in "$func_relative_path_result"
 167.291 +func_relative_path ()
 167.292 +{
 167.293 +  func_relative_path_result=
 167.294 +  func_normal_abspath "$1"
 167.295 +  func_relative_path_tlibdir=$func_normal_abspath_result
 167.296 +  func_normal_abspath "$2"
 167.297 +  func_relative_path_tbindir=$func_normal_abspath_result
 167.298 +
 167.299 +  # Ascend the tree starting from libdir
 167.300 +  while :; do
 167.301 +    # check if we have found a prefix of bindir
 167.302 +    case $func_relative_path_tbindir in
 167.303 +      $func_relative_path_tlibdir)
 167.304 +        # found an exact match
 167.305 +        func_relative_path_tcancelled=
 167.306 +        break
 167.307 +        ;;
 167.308 +      $func_relative_path_tlibdir*)
 167.309 +        # found a matching prefix
 167.310 +        func_stripname "$func_relative_path_tlibdir" '' "$func_relative_path_tbindir"
 167.311 +        func_relative_path_tcancelled=$func_stripname_result
 167.312 +        if test -z "$func_relative_path_result"; then
 167.313 +          func_relative_path_result=.
 167.314 +        fi
 167.315 +        break
 167.316 +        ;;
 167.317 +      *)
 167.318 +        func_dirname $func_relative_path_tlibdir
 167.319 +        func_relative_path_tlibdir=${func_dirname_result}
 167.320 +        if test "x$func_relative_path_tlibdir" = x ; then
 167.321 +          # Have to descend all the way to the root!
 167.322 +          func_relative_path_result=../$func_relative_path_result
 167.323 +          func_relative_path_tcancelled=$func_relative_path_tbindir
 167.324 +          break
 167.325 +        fi
 167.326 +        func_relative_path_result=../$func_relative_path_result
 167.327 +        ;;
 167.328 +    esac
 167.329 +  done
 167.330 +
 167.331 +  # Now calculate path; take care to avoid doubling-up slashes.
 167.332 +  func_stripname '' '/' "$func_relative_path_result"
 167.333 +  func_relative_path_result=$func_stripname_result
 167.334 +  func_stripname '/' '/' "$func_relative_path_tcancelled"
 167.335 +  if test "x$func_stripname_result" != x ; then
 167.336 +    func_relative_path_result=${func_relative_path_result}/${func_stripname_result}
 167.337 +  fi
 167.338 +
 167.339 +  # Normalisation. If bindir is libdir, return empty string,
 167.340 +  # else relative path ending with a slash; either way, target
 167.341 +  # file name can be directly appended.
 167.342 +  if test ! -z "$func_relative_path_result"; then
 167.343 +    func_stripname './' '' "$func_relative_path_result/"
 167.344 +    func_relative_path_result=$func_stripname_result
 167.345 +  fi
 167.346 +}
 167.347 +
 167.348 +# The name of this program:
 167.349 +func_dirname_and_basename "$progpath"
 167.350 +progname=$func_basename_result
 167.351 +
 167.352 +# Make sure we have an absolute path for reexecution:
 167.353 +case $progpath in
 167.354 +  [\\/]*|[A-Za-z]:\\*) ;;
 167.355 +  *[\\/]*)
 167.356 +     progdir=$func_dirname_result
 167.357 +     progdir=`cd "$progdir" && pwd`
 167.358 +     progpath="$progdir/$progname"
 167.359 +     ;;
 167.360 +  *)
 167.361 +     save_IFS="$IFS"
 167.362 +     IFS=:
 167.363 +     for progdir in $PATH; do
 167.364 +       IFS="$save_IFS"
 167.365 +       test -x "$progdir/$progname" && break
 167.366 +     done
 167.367 +     IFS="$save_IFS"
 167.368 +     test -n "$progdir" || progdir=`pwd`
 167.369 +     progpath="$progdir/$progname"
 167.370 +     ;;
 167.371 +esac
 167.372 +
 167.373 +# Sed substitution that helps us do robust quoting.  It backslashifies
 167.374 +# metacharacters that are still active within double-quoted strings.
 167.375 +Xsed="${SED}"' -e 1s/^X//'
 167.376 +sed_quote_subst='s/\([`"$\\]\)/\\\1/g'
 167.377 +
 167.378 +# Same as above, but do not quote variable references.
 167.379 +double_quote_subst='s/\(["`\\]\)/\\\1/g'
 167.380 +
 167.381 +# Re-`\' parameter expansions in output of double_quote_subst that were
 167.382 +# `\'-ed in input to the same.  If an odd number of `\' preceded a '$'
 167.383 +# in input to double_quote_subst, that '$' was protected from expansion.
 167.384 +# Since each input `\' is now two `\'s, look for any number of runs of
 167.385 +# four `\'s followed by two `\'s and then a '$'.  `\' that '$'.
 167.386 +bs='\\'
 167.387 +bs2='\\\\'
 167.388 +bs4='\\\\\\\\'
 167.389 +dollar='\$'
 167.390 +sed_double_backslash="\
 167.391 +  s/$bs4/&\\
 167.392 +/g
 167.393 +  s/^$bs2$dollar/$bs&/
 167.394 +  s/\\([^$bs]\\)$bs2$dollar/\\1$bs2$bs$dollar/g
 167.395 +  s/\n//g"
 167.396 +
 167.397 +# Standard options:
 167.398 +opt_dry_run=false
 167.399 +opt_help=false
 167.400 +opt_quiet=false
 167.401 +opt_verbose=false
 167.402 +opt_warning=:
 167.403 +
 167.404 +# func_echo arg...
 167.405 +# Echo program name prefixed message, along with the current mode
 167.406 +# name if it has been set yet.
 167.407 +func_echo ()
 167.408 +{
 167.409 +    $ECHO "$progname${mode+: }$mode: $*"
 167.410 +}
 167.411 +
 167.412 +# func_verbose arg...
 167.413 +# Echo program name prefixed message in verbose mode only.
 167.414 +func_verbose ()
 167.415 +{
 167.416 +    $opt_verbose && func_echo ${1+"$@"}
 167.417 +
 167.418 +    # A bug in bash halts the script if the last line of a function
 167.419 +    # fails when set -e is in force, so we need another command to
 167.420 +    # work around that:
 167.421 +    :
 167.422 +}
 167.423 +
 167.424 +# func_echo_all arg...
 167.425 +# Invoke $ECHO with all args, space-separated.
 167.426 +func_echo_all ()
 167.427 +{
 167.428 +    $ECHO "$*"
 167.429 +}
 167.430 +
 167.431 +# func_error arg...
 167.432 +# Echo program name prefixed message to standard error.
 167.433 +func_error ()
 167.434 +{
 167.435 +    $ECHO "$progname${mode+: }$mode: "${1+"$@"} 1>&2
 167.436 +}
 167.437 +
 167.438 +# func_warning arg...
 167.439 +# Echo program name prefixed warning message to standard error.
 167.440 +func_warning ()
 167.441 +{
 167.442 +    $opt_warning && $ECHO "$progname${mode+: }$mode: warning: "${1+"$@"} 1>&2
 167.443 +
 167.444 +    # bash bug again:
 167.445 +    :
 167.446 +}
 167.447 +
 167.448 +# func_fatal_error arg...
 167.449 +# Echo program name prefixed message to standard error, and exit.
 167.450 +func_fatal_error ()
 167.451 +{
 167.452 +    func_error ${1+"$@"}
 167.453 +    exit $EXIT_FAILURE
 167.454 +}
 167.455 +
 167.456 +# func_fatal_help arg...
 167.457 +# Echo program name prefixed message to standard error, followed by
 167.458 +# a help hint, and exit.
 167.459 +func_fatal_help ()
 167.460 +{
 167.461 +    func_error ${1+"$@"}
 167.462 +    func_fatal_error "$help"
 167.463 +}
 167.464 +help="Try \`$progname --help' for more information."  ## default
 167.465 +
 167.466 +
 167.467 +# func_grep expression filename
 167.468 +# Check whether EXPRESSION matches any line of FILENAME, without output.
 167.469 +func_grep ()
 167.470 +{
 167.471 +    $GREP "$1" "$2" >/dev/null 2>&1
 167.472 +}
 167.473 +
 167.474 +
 167.475 +# func_mkdir_p directory-path
 167.476 +# Make sure the entire path to DIRECTORY-PATH is available.
 167.477 +func_mkdir_p ()
 167.478 +{
 167.479 +    my_directory_path="$1"
 167.480 +    my_dir_list=
 167.481 +
 167.482 +    if test -n "$my_directory_path" && test "$opt_dry_run" != ":"; then
 167.483 +
 167.484 +      # Protect directory names starting with `-'
 167.485 +      case $my_directory_path in
 167.486 +        -*) my_directory_path="./$my_directory_path" ;;
 167.487 +      esac
 167.488 +
 167.489 +      # While some portion of DIR does not yet exist...
 167.490 +      while test ! -d "$my_directory_path"; do
 167.491 +        # ...make a list in topmost first order.  Use a colon delimited
 167.492 +	# list incase some portion of path contains whitespace.
 167.493 +        my_dir_list="$my_directory_path:$my_dir_list"
 167.494 +
 167.495 +        # If the last portion added has no slash in it, the list is done
 167.496 +        case $my_directory_path in */*) ;; *) break ;; esac
 167.497 +
 167.498 +        # ...otherwise throw away the child directory and loop
 167.499 +        my_directory_path=`$ECHO "$my_directory_path" | $SED -e "$dirname"`
 167.500 +      done
 167.501 +      my_dir_list=`$ECHO "$my_dir_list" | $SED 's,:*$,,'`
 167.502 +
 167.503 +      save_mkdir_p_IFS="$IFS"; IFS=':'
 167.504 +      for my_dir in $my_dir_list; do
 167.505 +	IFS="$save_mkdir_p_IFS"
 167.506 +        # mkdir can fail with a `File exist' error if two processes
 167.507 +        # try to create one of the directories concurrently.  Don't
 167.508 +        # stop in that case!
 167.509 +        $MKDIR "$my_dir" 2>/dev/null || :
 167.510 +      done
 167.511 +      IFS="$save_mkdir_p_IFS"
 167.512 +
 167.513 +      # Bail out if we (or some other process) failed to create a directory.
 167.514 +      test -d "$my_directory_path" || \
 167.515 +        func_fatal_error "Failed to create \`$1'"
 167.516 +    fi
 167.517 +}
 167.518 +
 167.519 +
 167.520 +# func_mktempdir [string]
 167.521 +# Make a temporary directory that won't clash with other running
 167.522 +# libtool processes, and avoids race conditions if possible.  If
 167.523 +# given, STRING is the basename for that directory.
 167.524 +func_mktempdir ()
 167.525 +{
 167.526 +    my_template="${TMPDIR-/tmp}/${1-$progname}"
 167.527 +
 167.528 +    if test "$opt_dry_run" = ":"; then
 167.529 +      # Return a directory name, but don't create it in dry-run mode
 167.530 +      my_tmpdir="${my_template}-$$"
 167.531 +    else
 167.532 +
 167.533 +      # If mktemp works, use that first and foremost
 167.534 +      my_tmpdir=`mktemp -d "${my_template}-XXXXXXXX" 2>/dev/null`
 167.535 +
 167.536 +      if test ! -d "$my_tmpdir"; then
 167.537 +        # Failing that, at least try and use $RANDOM to avoid a race
 167.538 +        my_tmpdir="${my_template}-${RANDOM-0}$$"
 167.539 +
 167.540 +        save_mktempdir_umask=`umask`
 167.541 +        umask 0077
 167.542 +        $MKDIR "$my_tmpdir"
 167.543 +        umask $save_mktempdir_umask
 167.544 +      fi
 167.545 +
 167.546 +      # If we're not in dry-run mode, bomb out on failure
 167.547 +      test -d "$my_tmpdir" || \
 167.548 +        func_fatal_error "cannot create temporary directory \`$my_tmpdir'"
 167.549 +    fi
 167.550 +
 167.551 +    $ECHO "$my_tmpdir"
 167.552 +}
 167.553 +
 167.554 +
 167.555 +# func_quote_for_eval arg
 167.556 +# Aesthetically quote ARG to be evaled later.
 167.557 +# This function returns two values: FUNC_QUOTE_FOR_EVAL_RESULT
 167.558 +# is double-quoted, suitable for a subsequent eval, whereas
 167.559 +# FUNC_QUOTE_FOR_EVAL_UNQUOTED_RESULT has merely all characters
 167.560 +# which are still active within double quotes backslashified.
 167.561 +func_quote_for_eval ()
 167.562 +{
 167.563 +    case $1 in
 167.564 +      *[\\\`\"\$]*)
 167.565 +	func_quote_for_eval_unquoted_result=`$ECHO "$1" | $SED "$sed_quote_subst"` ;;
 167.566 +      *)
 167.567 +        func_quote_for_eval_unquoted_result="$1" ;;
 167.568 +    esac
 167.569 +
 167.570 +    case $func_quote_for_eval_unquoted_result in
 167.571 +      # Double-quote args containing shell metacharacters to delay
 167.572 +      # word splitting, command substitution and and variable
 167.573 +      # expansion for a subsequent eval.
 167.574 +      # Many Bourne shells cannot handle close brackets correctly
 167.575 +      # in scan sets, so we specify it separately.
 167.576 +      *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \	]*|*]*|"")
 167.577 +        func_quote_for_eval_result="\"$func_quote_for_eval_unquoted_result\""
 167.578 +        ;;
 167.579 +      *)
 167.580 +        func_quote_for_eval_result="$func_quote_for_eval_unquoted_result"
 167.581 +    esac
 167.582 +}
 167.583 +
 167.584 +
 167.585 +# func_quote_for_expand arg
 167.586 +# Aesthetically quote ARG to be evaled later; same as above,
 167.587 +# but do not quote variable references.
 167.588 +func_quote_for_expand ()
 167.589 +{
 167.590 +    case $1 in
 167.591 +      *[\\\`\"]*)
 167.592 +	my_arg=`$ECHO "$1" | $SED \
 167.593 +	    -e "$double_quote_subst" -e "$sed_double_backslash"` ;;
 167.594 +      *)
 167.595 +        my_arg="$1" ;;
 167.596 +    esac
 167.597 +
 167.598 +    case $my_arg in
 167.599 +      # Double-quote args containing shell metacharacters to delay
 167.600 +      # word splitting and command substitution for a subsequent eval.
 167.601 +      # Many Bourne shells cannot handle close brackets correctly
 167.602 +      # in scan sets, so we specify it separately.
 167.603 +      *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \	]*|*]*|"")
 167.604 +        my_arg="\"$my_arg\""
 167.605 +        ;;
 167.606 +    esac
 167.607 +
 167.608 +    func_quote_for_expand_result="$my_arg"
 167.609 +}
 167.610 +
 167.611 +
 167.612 +# func_show_eval cmd [fail_exp]
 167.613 +# Unless opt_silent is true, then output CMD.  Then, if opt_dryrun is
 167.614 +# not true, evaluate CMD.  If the evaluation of CMD fails, and FAIL_EXP
 167.615 +# is given, then evaluate it.
 167.616 +func_show_eval ()
 167.617 +{
 167.618 +    my_cmd="$1"
 167.619 +    my_fail_exp="${2-:}"
 167.620 +
 167.621 +    ${opt_silent-false} || {
 167.622 +      func_quote_for_expand "$my_cmd"
 167.623 +      eval "func_echo $func_quote_for_expand_result"
 167.624 +    }
 167.625 +
 167.626 +    if ${opt_dry_run-false}; then :; else
 167.627 +      eval "$my_cmd"
 167.628 +      my_status=$?
 167.629 +      if test "$my_status" -eq 0; then :; else
 167.630 +	eval "(exit $my_status); $my_fail_exp"
 167.631 +      fi
 167.632 +    fi
 167.633 +}
 167.634 +
 167.635 +
 167.636 +# func_show_eval_locale cmd [fail_exp]
 167.637 +# Unless opt_silent is true, then output CMD.  Then, if opt_dryrun is
 167.638 +# not true, evaluate CMD.  If the evaluation of CMD fails, and FAIL_EXP
 167.639 +# is given, then evaluate it.  Use the saved locale for evaluation.
 167.640 +func_show_eval_locale ()
 167.641 +{
 167.642 +    my_cmd="$1"
 167.643 +    my_fail_exp="${2-:}"
 167.644 +
 167.645 +    ${opt_silent-false} || {
 167.646 +      func_quote_for_expand "$my_cmd"
 167.647 +      eval "func_echo $func_quote_for_expand_result"
 167.648 +    }
 167.649 +
 167.650 +    if ${opt_dry_run-false}; then :; else
 167.651 +      eval "$lt_user_locale
 167.652 +	    $my_cmd"
 167.653 +      my_status=$?
 167.654 +      eval "$lt_safe_locale"
 167.655 +      if test "$my_status" -eq 0; then :; else
 167.656 +	eval "(exit $my_status); $my_fail_exp"
 167.657 +      fi
 167.658 +    fi
 167.659 +}
 167.660 +
 167.661 +# func_tr_sh
 167.662 +# Turn $1 into a string suitable for a shell variable name.
 167.663 +# Result is stored in $func_tr_sh_result.  All characters
 167.664 +# not in the set a-zA-Z0-9_ are replaced with '_'. Further,
 167.665 +# if $1 begins with a digit, a '_' is prepended as well.
 167.666 +func_tr_sh ()
 167.667 +{
 167.668 +  case "$1" in
 167.669 +  [0-9]* | *[!a-zA-Z0-9_]*)
 167.670 +    func_tr_sh_result=`$ECHO "$1" | $SED 's/^\([0-9]\)/_\1/; s/[^a-zA-Z0-9_]/_/g'`
 167.671 +    ;;
 167.672 +  * )
 167.673 +    func_tr_sh_result=$1
 167.674 +    ;;
 167.675 +  esac
 167.676 +}
 167.677 +
 167.678 +
 167.679 +
 167.680 +
 167.681 +
 167.682 +# func_version
 167.683 +# Echo version message to standard output and exit.
 167.684 +func_version ()
 167.685 +{
 167.686 +    $SED -n '/(C)/!b go
 167.687 +	:more
 167.688 +	/\./!{
 167.689 +	  N
 167.690 +	  s/\n# //
 167.691 +	  b more
 167.692 +	}
 167.693 +	:go
 167.694 +	/^# '$PROGRAM' (GNU /,/# warranty; / {
 167.695 +        s/^# //
 167.696 +	s/^# *$//
 167.697 +        s/\((C)\)[ 0-9,-]*\( [1-9][0-9]*\)/\1\2/
 167.698 +        p
 167.699 +     }' < "$progpath"
 167.700 +     exit $?
 167.701 +}
 167.702 +
 167.703 +# func_usage
 167.704 +# Echo short help message to standard output and exit.
 167.705 +func_usage ()
 167.706 +{
 167.707 +    $SED -n '/^# Usage:/,/^#  *-h/ {
 167.708 +        s/^# //
 167.709 +	s/^# *$//
 167.710 +	s/\$progname/'$progname'/
 167.711 +	p
 167.712 +    }' < "$progpath"
 167.713 +    echo
 167.714 +    $ECHO "run \`$progname --help | more' for full usage"
 167.715 +    exit $?
 167.716 +}
 167.717 +
 167.718 +# func_help [NOEXIT]
 167.719 +# Echo long help message to standard output and exit,
 167.720 +# unless 'noexit' is passed as argument.
 167.721 +func_help ()
 167.722 +{
 167.723 +    $SED -n '/^# Usage:/,/# Report bugs to/ {
 167.724 +        s/^# //
 167.725 +	s/^# *$//
 167.726 +	s*\$progname*'$progname'*
 167.727 +	s*\$host*'"$host"'*
 167.728 +	s*\$SHELL*'"$SHELL"'*
 167.729 +	s*\$LTCC*'"$LTCC"'*
 167.730 +	s*\$LTCFLAGS*'"$LTCFLAGS"'*
 167.731 +	s*\$LD*'"$LD"'*
 167.732 +	s/\$with_gnu_ld/'"$with_gnu_ld"'/
 167.733 +	s/\$automake_version/'"`(automake --version) 2>/dev/null |$SED 1q`"'/
 167.734 +	s/\$autoconf_version/'"`(autoconf --version) 2>/dev/null |$SED 1q`"'/
 167.735 +	p
 167.736 +     }' < "$progpath"
 167.737 +    ret=$?
 167.738 +    if test -z "$1"; then
 167.739 +      exit $ret
 167.740 +    fi
 167.741 +}
 167.742 +
 167.743 +# func_missing_arg argname
 167.744 +# Echo program name prefixed message to standard error and set global
 167.745 +# exit_cmd.
 167.746 +func_missing_arg ()
 167.747 +{
 167.748 +    func_error "missing argument for $1"
 167.749 +    exit_cmd=exit
 167.750 +}
 167.751 +
 167.752 +exit_cmd=:
 167.753 +
 167.754 +
 167.755 +
 167.756 +
 167.757 +
 167.758 +
 167.759 +magic="%%%MAGIC variable%%%"
 167.760 +magic_exe="%%%MAGIC EXE variable%%%"
 167.761 +
 167.762 +# Global variables.
 167.763 +# $mode is unset
 167.764 +nonopt=
 167.765 +execute_dlfiles=
 167.766 +preserve_args=
 167.767 +lo2o="s/\\.lo\$/.${objext}/"
 167.768 +o2lo="s/\\.${objext}\$/.lo/"
 167.769 +extracted_archives=
 167.770 +extracted_serial=0
 167.771 +
 167.772 +opt_dry_run=false
 167.773 +opt_duplicate_deps=false
 167.774 +opt_silent=false
 167.775 +opt_debug=:
 167.776 +
 167.777 +# If this variable is set in any of the actions, the command in it
 167.778 +# will be execed at the end.  This prevents here-documents from being
 167.779 +# left over by shells.
 167.780 +exec_cmd=
 167.781 +
 167.782 +# func_fatal_configuration arg...
 167.783 +# Echo program name prefixed message to standard error, followed by
 167.784 +# a configuration failure hint, and exit.
 167.785 +func_fatal_configuration ()
 167.786 +{
 167.787 +    func_error ${1+"$@"}
 167.788 +    func_error "See the $PACKAGE documentation for more information."
 167.789 +    func_fatal_error "Fatal configuration error."
 167.790 +}
 167.791 +
 167.792 +
 167.793 +# func_config
 167.794 +# Display the configuration for all the tags in this script.
 167.795 +func_config ()
 167.796 +{
 167.797 +    re_begincf='^# ### BEGIN LIBTOOL'
 167.798 +    re_endcf='^# ### END LIBTOOL'
 167.799 +
 167.800 +    # Default configuration.
 167.801 +    $SED "1,/$re_begincf CONFIG/d;/$re_endcf CONFIG/,\$d" < "$progpath"
 167.802 +
 167.803 +    # Now print the configurations for the tags.
 167.804 +    for tagname in $taglist; do
 167.805 +      $SED -n "/$re_begincf TAG CONFIG: $tagname\$/,/$re_endcf TAG CONFIG: $tagname\$/p" < "$progpath"
 167.806 +    done
 167.807 +
 167.808 +    exit $?
 167.809 +}
 167.810 +
 167.811 +# func_features
 167.812 +# Display the features supported by this script.
 167.813 +func_features ()
 167.814 +{
 167.815 +    echo "host: $host"
 167.816 +    if test "$build_libtool_libs" = yes; then
 167.817 +      echo "enable shared libraries"
 167.818 +    else
 167.819 +      echo "disable shared libraries"
 167.820 +    fi
 167.821 +    if test "$build_old_libs" = yes; then
 167.822 +      echo "enable static libraries"
 167.823 +    else
 167.824 +      echo "disable static libraries"
 167.825 +    fi
 167.826 +
 167.827 +    exit $?
 167.828 +}
 167.829 +
 167.830 +# func_enable_tag tagname
 167.831 +# Verify that TAGNAME is valid, and either flag an error and exit, or
 167.832 +# enable the TAGNAME tag.  We also add TAGNAME to the global $taglist
 167.833 +# variable here.
 167.834 +func_enable_tag ()
 167.835 +{
 167.836 +  # Global variable:
 167.837 +  tagname="$1"
 167.838 +
 167.839 +  re_begincf="^# ### BEGIN LIBTOOL TAG CONFIG: $tagname\$"
 167.840 +  re_endcf="^# ### END LIBTOOL TAG CONFIG: $tagname\$"
 167.841 +  sed_extractcf="/$re_begincf/,/$re_endcf/p"
 167.842 +
 167.843 +  # Validate tagname.
 167.844 +  case $tagname in
 167.845 +    *[!-_A-Za-z0-9,/]*)
 167.846 +      func_fatal_error "invalid tag name: $tagname"
 167.847 +      ;;
 167.848 +  esac
 167.849 +
 167.850 +  # Don't test for the "default" C tag, as we know it's
 167.851 +  # there but not specially marked.
 167.852 +  case $tagname in
 167.853 +    CC) ;;
 167.854 +    *)
 167.855 +      if $GREP "$re_begincf" "$progpath" >/dev/null 2>&1; then
 167.856 +	taglist="$taglist $tagname"
 167.857 +
 167.858 +	# Evaluate the configuration.  Be careful to quote the path
 167.859 +	# and the sed script, to avoid splitting on whitespace, but
 167.860 +	# also don't use non-portable quotes within backquotes within
 167.861 +	# quotes we have to do it in 2 steps:
 167.862 +	extractedcf=`$SED -n -e "$sed_extractcf" < "$progpath"`
 167.863 +	eval "$extractedcf"
 167.864 +      else
 167.865 +	func_error "ignoring unknown tag $tagname"
 167.866 +      fi
 167.867 +      ;;
 167.868 +  esac
 167.869 +}
 167.870 +
 167.871 +# Parse options once, thoroughly.  This comes as soon as possible in
 167.872 +# the script to make things like `libtool --version' happen quickly.
 167.873 +{
 167.874 +
 167.875 +  # Shorthand for --mode=foo, only valid as the first argument
 167.876 +  case $1 in
 167.877 +  clean|clea|cle|cl)
 167.878 +    shift; set dummy --mode clean ${1+"$@"}; shift
 167.879 +    ;;
 167.880 +  compile|compil|compi|comp|com|co|c)
 167.881 +    shift; set dummy --mode compile ${1+"$@"}; shift
 167.882 +    ;;
 167.883 +  execute|execut|execu|exec|exe|ex|e)
 167.884 +    shift; set dummy --mode execute ${1+"$@"}; shift
 167.885 +    ;;
 167.886 +  finish|finis|fini|fin|fi|f)
 167.887 +    shift; set dummy --mode finish ${1+"$@"}; shift
 167.888 +    ;;
 167.889 +  install|instal|insta|inst|ins|in|i)
 167.890 +    shift; set dummy --mode install ${1+"$@"}; shift
 167.891 +    ;;
 167.892 +  link|lin|li|l)
 167.893 +    shift; set dummy --mode link ${1+"$@"}; shift
 167.894 +    ;;
 167.895 +  uninstall|uninstal|uninsta|uninst|unins|unin|uni|un|u)
 167.896 +    shift; set dummy --mode uninstall ${1+"$@"}; shift
 167.897 +    ;;
 167.898 +  esac
 167.899 +
 167.900 +  # Parse non-mode specific arguments:
 167.901 +  while test "$#" -gt 0; do
 167.902 +    opt="$1"
 167.903 +    shift
 167.904 +
 167.905 +    case $opt in
 167.906 +      --config)		func_config					;;
 167.907 +
 167.908 +      --debug)		preserve_args="$preserve_args $opt"
 167.909 +			func_echo "enabling shell trace mode"
 167.910 +			opt_debug='set -x'
 167.911 +			$opt_debug
 167.912 +			;;
 167.913 +
 167.914 +      -dlopen)		test "$#" -eq 0 && func_missing_arg "$opt" && break
 167.915 +			execute_dlfiles="$execute_dlfiles $1"
 167.916 +			shift
 167.917 +			;;
 167.918 +
 167.919 +      --dry-run | -n)	opt_dry_run=:					;;
 167.920 +      --features)       func_features					;;
 167.921 +      --finish)		mode="finish"					;;
 167.922 +
 167.923 +      --mode)		test "$#" -eq 0 && func_missing_arg "$opt" && break
 167.924 +			case $1 in
 167.925 +			  # Valid mode arguments:
 167.926 +			  clean)	;;
 167.927 +			  compile)	;;
 167.928 +			  execute)	;;
 167.929 +			  finish)	;;
 167.930 +			  install)	;;
 167.931 +			  link)		;;
 167.932 +			  relink)	;;
 167.933 +			  uninstall)	;;
 167.934 +
 167.935 +			  # Catch anything else as an error
 167.936 +			  *) func_error "invalid argument for $opt"
 167.937 +			     exit_cmd=exit
 167.938 +			     break
 167.939 +			     ;;
 167.940 +		        esac
 167.941 +
 167.942 +			mode="$1"
 167.943 +			shift
 167.944 +			;;
 167.945 +
 167.946 +      --preserve-dup-deps)
 167.947 +			opt_duplicate_deps=:				;;
 167.948 +
 167.949 +      --quiet|--silent)	preserve_args="$preserve_args $opt"
 167.950 +			opt_silent=:
 167.951 +			opt_verbose=false
 167.952 +			;;
 167.953 +
 167.954 +      --no-quiet|--no-silent)
 167.955 +			preserve_args="$preserve_args $opt"
 167.956 +			opt_silent=false
 167.957 +			;;
 167.958 +
 167.959 +      --verbose| -v)	preserve_args="$preserve_args $opt"
 167.960 +			opt_silent=false
 167.961 +			opt_verbose=:
 167.962 +			;;
 167.963 +
 167.964 +      --no-verbose)	preserve_args="$preserve_args $opt"
 167.965 +			opt_verbose=false
 167.966 +			;;
 167.967 +
 167.968 +      --tag)		test "$#" -eq 0 && func_missing_arg "$opt" && break
 167.969 +			preserve_args="$preserve_args $opt $1"
 167.970 +			func_enable_tag "$1"	# tagname is set here
 167.971 +			shift
 167.972 +			;;
 167.973 +
 167.974 +      # Separate optargs to long options:
 167.975 +      -dlopen=*|--mode=*|--tag=*)
 167.976 +			func_opt_split "$opt"
 167.977 +			set dummy "$func_opt_split_opt" "$func_opt_split_arg" ${1+"$@"}
 167.978 +			shift
 167.979 +			;;
 167.980 +
 167.981 +      -\?|-h)		func_usage					;;
 167.982 +      --help)		opt_help=:					;;
 167.983 +      --help-all)	opt_help=': help-all'				;;
 167.984 +      --version)	func_version					;;
 167.985 +
 167.986 +      -*)		func_fatal_help "unrecognized option \`$opt'"	;;
 167.987 +
 167.988 +      *)		nonopt="$opt"
 167.989 +			break
 167.990 +			;;
 167.991 +    esac
 167.992 +  done
 167.993 +
 167.994 +
 167.995 +  case $host in
 167.996 +    *cygwin* | *mingw* | *pw32* | *cegcc*)
 167.997 +      # don't eliminate duplications in $postdeps and $predeps
 167.998 +      opt_duplicate_compiler_generated_deps=:
 167.999 +      ;;
167.1000 +    *)
167.1001 +      opt_duplicate_compiler_generated_deps=$opt_duplicate_deps
167.1002 +      ;;
167.1003 +  esac
167.1004 +
167.1005 +  # Having warned about all mis-specified options, bail out if
167.1006 +  # anything was wrong.
167.1007 +  $exit_cmd $EXIT_FAILURE
167.1008 +}
167.1009 +
167.1010 +# func_check_version_match
167.1011 +# Ensure that we are using m4 macros, and libtool script from the same
167.1012 +# release of libtool.
167.1013 +func_check_version_match ()
167.1014 +{
167.1015 +  if test "$package_revision" != "$macro_revision"; then
167.1016 +    if test "$VERSION" != "$macro_version"; then
167.1017 +      if test -z "$macro_version"; then
167.1018 +        cat >&2 <<_LT_EOF
167.1019 +$progname: Version mismatch error.  This is $PACKAGE $VERSION, but the
167.1020 +$progname: definition of this LT_INIT comes from an older release.
167.1021 +$progname: You should recreate aclocal.m4 with macros from $PACKAGE $VERSION
167.1022 +$progname: and run autoconf again.
167.1023 +_LT_EOF
167.1024 +      else
167.1025 +        cat >&2 <<_LT_EOF
167.1026 +$progname: Version mismatch error.  This is $PACKAGE $VERSION, but the
167.1027 +$progname: definition of this LT_INIT comes from $PACKAGE $macro_version.
167.1028 +$progname: You should recreate aclocal.m4 with macros from $PACKAGE $VERSION
167.1029 +$progname: and run autoconf again.
167.1030 +_LT_EOF
167.1031 +      fi
167.1032 +    else
167.1033 +      cat >&2 <<_LT_EOF
167.1034 +$progname: Version mismatch error.  This is $PACKAGE $VERSION, revision $package_revision,
167.1035 +$progname: but the definition of this LT_INIT comes from revision $macro_revision.
167.1036 +$progname: You should recreate aclocal.m4 with macros from revision $package_revision
167.1037 +$progname: of $PACKAGE $VERSION and run autoconf again.
167.1038 +_LT_EOF
167.1039 +    fi
167.1040 +
167.1041 +    exit $EXIT_MISMATCH
167.1042 +  fi
167.1043 +}
167.1044 +
167.1045 +
167.1046 +## ----------- ##
167.1047 +##    Main.    ##
167.1048 +## ----------- ##
167.1049 +
167.1050 +$opt_help || {
167.1051 +  # Sanity checks first:
167.1052 +  func_check_version_match
167.1053 +
167.1054 +  if test "$build_libtool_libs" != yes && test "$build_old_libs" != yes; then
167.1055 +    func_fatal_configuration "not configured to build any kind of library"
167.1056 +  fi
167.1057 +
167.1058 +  test -z "$mode" && func_fatal_error "error: you must specify a MODE."
167.1059 +
167.1060 +
167.1061 +  # Darwin sucks
167.1062 +  eval std_shrext=\"$shrext_cmds\"
167.1063 +
167.1064 +
167.1065 +  # Only execute mode is allowed to have -dlopen flags.
167.1066 +  if test -n "$execute_dlfiles" && test "$mode" != execute; then
167.1067 +    func_error "unrecognized option \`-dlopen'"
167.1068 +    $ECHO "$help" 1>&2
167.1069 +    exit $EXIT_FAILURE
167.1070 +  fi
167.1071 +
167.1072 +  # Change the help message to a mode-specific one.
167.1073 +  generic_help="$help"
167.1074 +  help="Try \`$progname --help --mode=$mode' for more information."
167.1075 +}
167.1076 +
167.1077 +
167.1078 +# func_lalib_p file
167.1079 +# True iff FILE is a libtool `.la' library or `.lo' object file.
167.1080 +# This function is only a basic sanity check; it will hardly flush out
167.1081 +# determined imposters.
167.1082 +func_lalib_p ()
167.1083 +{
167.1084 +    test -f "$1" &&
167.1085 +      $SED -e 4q "$1" 2>/dev/null \
167.1086 +        | $GREP "^# Generated by .*$PACKAGE" > /dev/null 2>&1
167.1087 +}
167.1088 +
167.1089 +# func_lalib_unsafe_p file
167.1090 +# True iff FILE is a libtool `.la' library or `.lo' object file.
167.1091 +# This function implements the same check as func_lalib_p without
167.1092 +# resorting to external programs.  To this end, it redirects stdin and
167.1093 +# closes it afterwards, without saving the original file descriptor.
167.1094 +# As a safety measure, use it only where a negative result would be
167.1095 +# fatal anyway.  Works if `file' does not exist.
167.1096 +func_lalib_unsafe_p ()
167.1097 +{
167.1098 +    lalib_p=no
167.1099 +    if test -f "$1" && test -r "$1" && exec 5<&0 <"$1"; then
167.1100 +	for lalib_p_l in 1 2 3 4
167.1101 +	do
167.1102 +	    read lalib_p_line
167.1103 +	    case "$lalib_p_line" in
167.1104 +		\#\ Generated\ by\ *$PACKAGE* ) lalib_p=yes; break;;
167.1105 +	    esac
167.1106 +	done
167.1107 +	exec 0<&5 5<&-
167.1108 +    fi
167.1109 +    test "$lalib_p" = yes
167.1110 +}
167.1111 +
167.1112 +# func_ltwrapper_script_p file
167.1113 +# True iff FILE is a libtool wrapper script
167.1114 +# This function is only a basic sanity check; it will hardly flush out
167.1115 +# determined imposters.
167.1116 +func_ltwrapper_script_p ()
167.1117 +{
167.1118 +    func_lalib_p "$1"
167.1119 +}
167.1120 +
167.1121 +# func_ltwrapper_executable_p file
167.1122 +# True iff FILE is a libtool wrapper executable
167.1123 +# This function is only a basic sanity check; it will hardly flush out
167.1124 +# determined imposters.
167.1125 +func_ltwrapper_executable_p ()
167.1126 +{
167.1127 +    func_ltwrapper_exec_suffix=
167.1128 +    case $1 in
167.1129 +    *.exe) ;;
167.1130 +    *) func_ltwrapper_exec_suffix=.exe ;;
167.1131 +    esac
167.1132 +    $GREP "$magic_exe" "$1$func_ltwrapper_exec_suffix" >/dev/null 2>&1
167.1133 +}
167.1134 +
167.1135 +# func_ltwrapper_scriptname file
167.1136 +# Assumes file is an ltwrapper_executable
167.1137 +# uses $file to determine the appropriate filename for a
167.1138 +# temporary ltwrapper_script.
167.1139 +func_ltwrapper_scriptname ()
167.1140 +{
167.1141 +    func_ltwrapper_scriptname_result=""
167.1142 +    if func_ltwrapper_executable_p "$1"; then
167.1143 +	func_dirname_and_basename "$1" "" "."
167.1144 +	func_stripname '' '.exe' "$func_basename_result"
167.1145 +	func_ltwrapper_scriptname_result="$func_dirname_result/$objdir/${func_stripname_result}_ltshwrapper"
167.1146 +    fi
167.1147 +}
167.1148 +
167.1149 +# func_ltwrapper_p file
167.1150 +# True iff FILE is a libtool wrapper script or wrapper executable
167.1151 +# This function is only a basic sanity check; it will hardly flush out
167.1152 +# determined imposters.
167.1153 +func_ltwrapper_p ()
167.1154 +{
167.1155 +    func_ltwrapper_script_p "$1" || func_ltwrapper_executable_p "$1"
167.1156 +}
167.1157 +
167.1158 +
167.1159 +# func_execute_cmds commands fail_cmd
167.1160 +# Execute tilde-delimited COMMANDS.
167.1161 +# If FAIL_CMD is given, eval that upon failure.
167.1162 +# FAIL_CMD may read-access the current command in variable CMD!
167.1163 +func_execute_cmds ()
167.1164 +{
167.1165 +    $opt_debug
167.1166 +    save_ifs=$IFS; IFS='~'
167.1167 +    for cmd in $1; do
167.1168 +      IFS=$save_ifs
167.1169 +      eval cmd=\"$cmd\"
167.1170 +      func_show_eval "$cmd" "${2-:}"
167.1171 +    done
167.1172 +    IFS=$save_ifs
167.1173 +}
167.1174 +
167.1175 +
167.1176 +# func_source file
167.1177 +# Source FILE, adding directory component if necessary.
167.1178 +# Note that it is not necessary on cygwin/mingw to append a dot to
167.1179 +# FILE even if both FILE and FILE.exe exist: automatic-append-.exe
167.1180 +# behavior happens only for exec(3), not for open(2)!  Also, sourcing
167.1181 +# `FILE.' does not work on cygwin managed mounts.
167.1182 +func_source ()
167.1183 +{
167.1184 +    $opt_debug
167.1185 +    case $1 in
167.1186 +    */* | *\\*)	. "$1" ;;
167.1187 +    *)		. "./$1" ;;
167.1188 +    esac
167.1189 +}
167.1190 +
167.1191 +
167.1192 +# func_infer_tag arg
167.1193 +# Infer tagged configuration to use if any are available and
167.1194 +# if one wasn't chosen via the "--tag" command line option.
167.1195 +# Only attempt this if the compiler in the base compile
167.1196 +# command doesn't match the default compiler.
167.1197 +# arg is usually of the form 'gcc ...'
167.1198 +func_infer_tag ()
167.1199 +{
167.1200 +    $opt_debug
167.1201 +    if test -n "$available_tags" && test -z "$tagname"; then
167.1202 +      CC_quoted=
167.1203 +      for arg in $CC; do
167.1204 +        func_quote_for_eval "$arg"
167.1205 +	CC_quoted="$CC_quoted $func_quote_for_eval_result"
167.1206 +      done
167.1207 +      CC_expanded=`func_echo_all $CC`
167.1208 +      CC_quoted_expanded=`func_echo_all $CC_quoted`
167.1209 +      case $@ in
167.1210 +      # Blanks in the command may have been stripped by the calling shell,
167.1211 +      # but not from the CC environment variable when configure was run.
167.1212 +      " $CC "* | "$CC "* | " $CC_expanded "* | "$CC_expanded "* | \
167.1213 +      " $CC_quoted"* | "$CC_quoted "* | " $CC_quoted_expanded "* | "$CC_quoted_expanded "*) ;;
167.1214 +      # Blanks at the start of $base_compile will cause this to fail
167.1215 +      # if we don't check for them as well.
167.1216 +      *)
167.1217 +	for z in $available_tags; do
167.1218 +	  if $GREP "^# ### BEGIN LIBTOOL TAG CONFIG: $z$" < "$progpath" > /dev/null; then
167.1219 +	    # Evaluate the configuration.
167.1220 +	    eval "`${SED} -n -e '/^# ### BEGIN LIBTOOL TAG CONFIG: '$z'$/,/^# ### END LIBTOOL TAG CONFIG: '$z'$/p' < $progpath`"
167.1221 +	    CC_quoted=
167.1222 +	    for arg in $CC; do
167.1223 +	      # Double-quote args containing other shell metacharacters.
167.1224 +	      func_quote_for_eval "$arg"
167.1225 +	      CC_quoted="$CC_quoted $func_quote_for_eval_result"
167.1226 +	    done
167.1227 +	    CC_expanded=`func_echo_all $CC`
167.1228 +	    CC_quoted_expanded=`func_echo_all $CC_quoted`
167.1229 +	    case "$@ " in
167.1230 +	    " $CC "* | "$CC "* | " $CC_expanded "* | "$CC_expanded "* | \
167.1231 +	    " $CC_quoted"* | "$CC_quoted "* | " $CC_quoted_expanded "* | "$CC_quoted_expanded "*)
167.1232 +	      # The compiler in the base compile command matches
167.1233 +	      # the one in the tagged configuration.
167.1234 +	      # Assume this is the tagged configuration we want.
167.1235 +	      tagname=$z
167.1236 +	      break
167.1237 +	      ;;
167.1238 +	    esac
167.1239 +	  fi
167.1240 +	done
167.1241 +	# If $tagname still isn't set, then no tagged configuration
167.1242 +	# was found and let the user know that the "--tag" command
167.1243 +	# line option must be used.
167.1244 +	if test -z "$tagname"; then
167.1245 +	  func_echo "unable to infer tagged configuration"
167.1246 +	  func_fatal_error "specify a tag with \`--tag'"
167.1247 +#	else
167.1248 +#	  func_verbose "using $tagname tagged configuration"
167.1249 +	fi
167.1250 +	;;
167.1251 +      esac
167.1252 +    fi
167.1253 +}
167.1254 +
167.1255 +
167.1256 +
167.1257 +# func_write_libtool_object output_name pic_name nonpic_name
167.1258 +# Create a libtool object file (analogous to a ".la" file),
167.1259 +# but don't create it if we're doing a dry run.
167.1260 +func_write_libtool_object ()
167.1261 +{
167.1262 +    write_libobj=${1}
167.1263 +    if test "$build_libtool_libs" = yes; then
167.1264 +      write_lobj=\'${2}\'
167.1265 +    else
167.1266 +      write_lobj=none
167.1267 +    fi
167.1268 +
167.1269 +    if test "$build_old_libs" = yes; then
167.1270 +      write_oldobj=\'${3}\'
167.1271 +    else
167.1272 +      write_oldobj=none
167.1273 +    fi
167.1274 +
167.1275 +    $opt_dry_run || {
167.1276 +      cat >${write_libobj}T <<EOF
167.1277 +# $write_libobj - a libtool object file
167.1278 +# Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION
167.1279 +#
167.1280 +# Please DO NOT delete this file!
167.1281 +# It is necessary for linking the library.
167.1282 +
167.1283 +# Name of the PIC object.
167.1284 +pic_object=$write_lobj
167.1285 +
167.1286 +# Name of the non-PIC object
167.1287 +non_pic_object=$write_oldobj
167.1288 +
167.1289 +EOF
167.1290 +      $MV "${write_libobj}T" "${write_libobj}"
167.1291 +    }
167.1292 +}
167.1293 +
167.1294 +# func_mode_compile arg...
167.1295 +func_mode_compile ()
167.1296 +{
167.1297 +    $opt_debug
167.1298 +    # Get the compilation command and the source file.
167.1299 +    base_compile=
167.1300 +    srcfile="$nonopt"  #  always keep a non-empty value in "srcfile"
167.1301 +    suppress_opt=yes
167.1302 +    suppress_output=
167.1303 +    arg_mode=normal
167.1304 +    libobj=
167.1305 +    later=
167.1306 +    pie_flag=
167.1307 +
167.1308 +    for arg
167.1309 +    do
167.1310 +      case $arg_mode in
167.1311 +      arg  )
167.1312 +	# do not "continue".  Instead, add this to base_compile
167.1313 +	lastarg="$arg"
167.1314 +	arg_mode=normal
167.1315 +	;;
167.1316 +
167.1317 +      target )
167.1318 +	libobj="$arg"
167.1319 +	arg_mode=normal
167.1320 +	continue
167.1321 +	;;
167.1322 +
167.1323 +      normal )
167.1324 +	# Accept any command-line options.
167.1325 +	case $arg in
167.1326 +	-o)
167.1327 +	  test -n "$libobj" && \
167.1328 +	    func_fatal_error "you cannot specify \`-o' more than once"
167.1329 +	  arg_mode=target
167.1330 +	  continue
167.1331 +	  ;;
167.1332 +
167.1333 +	-pie | -fpie | -fPIE)
167.1334 +          pie_flag="$pie_flag $arg"
167.1335 +	  continue
167.1336 +	  ;;
167.1337 +
167.1338 +	-shared | -static | -prefer-pic | -prefer-non-pic)
167.1339 +	  later="$later $arg"
167.1340 +	  continue
167.1341 +	  ;;
167.1342 +
167.1343 +	-no-suppress)
167.1344 +	  suppress_opt=no
167.1345 +	  continue
167.1346 +	  ;;
167.1347 +
167.1348 +	-Xcompiler)
167.1349 +	  arg_mode=arg  #  the next one goes into the "base_compile" arg list
167.1350 +	  continue      #  The current "srcfile" will either be retained or
167.1351 +	  ;;            #  replaced later.  I would guess that would be a bug.
167.1352 +
167.1353 +	-Wc,*)
167.1354 +	  func_stripname '-Wc,' '' "$arg"
167.1355 +	  args=$func_stripname_result
167.1356 +	  lastarg=
167.1357 +	  save_ifs="$IFS"; IFS=','
167.1358 +	  for arg in $args; do
167.1359 +	    IFS="$save_ifs"
167.1360 +	    func_quote_for_eval "$arg"
167.1361 +	    lastarg="$lastarg $func_quote_for_eval_result"
167.1362 +	  done
167.1363 +	  IFS="$save_ifs"
167.1364 +	  func_stripname ' ' '' "$lastarg"
167.1365 +	  lastarg=$func_stripname_result
167.1366 +
167.1367 +	  # Add the arguments to base_compile.
167.1368 +	  base_compile="$base_compile $lastarg"
167.1369 +	  continue
167.1370 +	  ;;
167.1371 +
167.1372 +	*)
167.1373 +	  # Accept the current argument as the source file.
167.1374 +	  # The previous "srcfile" becomes the current argument.
167.1375 +	  #
167.1376 +	  lastarg="$srcfile"
167.1377 +	  srcfile="$arg"
167.1378 +	  ;;
167.1379 +	esac  #  case $arg
167.1380 +	;;
167.1381 +      esac    #  case $arg_mode
167.1382 +
167.1383 +      # Aesthetically quote the previous argument.
167.1384 +      func_quote_for_eval "$lastarg"
167.1385 +      base_compile="$base_compile $func_quote_for_eval_result"
167.1386 +    done # for arg
167.1387 +
167.1388 +    case $arg_mode in
167.1389 +    arg)
167.1390 +      func_fatal_error "you must specify an argument for -Xcompile"
167.1391 +      ;;
167.1392 +    target)
167.1393 +      func_fatal_error "you must specify a target with \`-o'"
167.1394 +      ;;
167.1395 +    *)
167.1396 +      # Get the name of the library object.
167.1397 +      test -z "$libobj" && {
167.1398 +	func_basename "$srcfile"
167.1399 +	libobj="$func_basename_result"
167.1400 +      }
167.1401 +      ;;
167.1402 +    esac
167.1403 +
167.1404 +    # Recognize several different file suffixes.
167.1405 +    # If the user specifies -o file.o, it is replaced with file.lo
167.1406 +    case $libobj in
167.1407 +    *.[cCFSifmso] | \
167.1408 +    *.ada | *.adb | *.ads | *.asm | \
167.1409 +    *.c++ | *.cc | *.ii | *.class | *.cpp | *.cxx | \
167.1410 +    *.[fF][09]? | *.for | *.java | *.obj | *.sx | *.cu | *.cup)
167.1411 +      func_xform "$libobj"
167.1412 +      libobj=$func_xform_result
167.1413 +      ;;
167.1414 +    esac
167.1415 +
167.1416 +    case $libobj in
167.1417 +    *.lo) func_lo2o "$libobj"; obj=$func_lo2o_result ;;
167.1418 +    *)
167.1419 +      func_fatal_error "cannot determine name of library object from \`$libobj'"
167.1420 +      ;;
167.1421 +    esac
167.1422 +
167.1423 +    func_infer_tag $base_compile
167.1424 +
167.1425 +    for arg in $later; do
167.1426 +      case $arg in
167.1427 +      -shared)
167.1428 +	test "$build_libtool_libs" != yes && \
167.1429 +	  func_fatal_configuration "can not build a shared library"
167.1430 +	build_old_libs=no
167.1431 +	continue
167.1432 +	;;
167.1433 +
167.1434 +      -static)
167.1435 +	build_libtool_libs=no
167.1436 +	build_old_libs=yes
167.1437 +	continue
167.1438 +	;;
167.1439 +
167.1440 +      -prefer-pic)
167.1441 +	pic_mode=yes
167.1442 +	continue
167.1443 +	;;
167.1444 +
167.1445 +      -prefer-non-pic)
167.1446 +	pic_mode=no
167.1447 +	continue
167.1448 +	;;
167.1449 +      esac
167.1450 +    done
167.1451 +
167.1452 +    func_quote_for_eval "$libobj"
167.1453 +    test "X$libobj" != "X$func_quote_for_eval_result" \
167.1454 +      && $ECHO "X$libobj" | $GREP '[]~#^*{};<>?"'"'"'	 &()|`$[]' \
167.1455 +      && func_warning "libobj name \`$libobj' may not contain shell special characters."
167.1456 +    func_dirname_and_basename "$obj" "/" ""
167.1457 +    objname="$func_basename_result"
167.1458 +    xdir="$func_dirname_result"
167.1459 +    lobj=${xdir}$objdir/$objname
167.1460 +
167.1461 +    test -z "$base_compile" && \
167.1462 +      func_fatal_help "you must specify a compilation command"
167.1463 +
167.1464 +    # Delete any leftover library objects.
167.1465 +    if test "$build_old_libs" = yes; then
167.1466 +      removelist="$obj $lobj $libobj ${libobj}T"
167.1467 +    else
167.1468 +      removelist="$lobj $libobj ${libobj}T"
167.1469 +    fi
167.1470 +
167.1471 +    # On Cygwin there's no "real" PIC flag so we must build both object types
167.1472 +    case $host_os in
167.1473 +    cygwin* | mingw* | pw32* | os2* | cegcc*)
167.1474 +      pic_mode=default
167.1475 +      ;;
167.1476 +    esac
167.1477 +    if test "$pic_mode" = no && test "$deplibs_check_method" != pass_all; then
167.1478 +      # non-PIC code in shared libraries is not supported
167.1479 +      pic_mode=default
167.1480 +    fi
167.1481 +
167.1482 +    # Calculate the filename of the output object if compiler does
167.1483 +    # not support -o with -c
167.1484 +    if test "$compiler_c_o" = no; then
167.1485 +      output_obj=`$ECHO "$srcfile" | $SED 's%^.*/%%; s%\.[^.]*$%%'`.${objext}
167.1486 +      lockfile="$output_obj.lock"
167.1487 +    else
167.1488 +      output_obj=
167.1489 +      need_locks=no
167.1490 +      lockfile=
167.1491 +    fi
167.1492 +
167.1493 +    # Lock this critical section if it is needed
167.1494 +    # We use this script file to make the link, it avoids creating a new file
167.1495 +    if test "$need_locks" = yes; then
167.1496 +      until $opt_dry_run || ln "$progpath" "$lockfile" 2>/dev/null; do
167.1497 +	func_echo "Waiting for $lockfile to be removed"
167.1498 +	sleep 2
167.1499 +      done
167.1500 +    elif test "$need_locks" = warn; then
167.1501 +      if test -f "$lockfile"; then
167.1502 +	$ECHO "\
167.1503 +*** ERROR, $lockfile exists and contains:
167.1504 +`cat $lockfile 2>/dev/null`
167.1505 +
167.1506 +This indicates that another process is trying to use the same
167.1507 +temporary object file, and libtool could not work around it because
167.1508 +your compiler does not support \`-c' and \`-o' together.  If you
167.1509 +repeat this compilation, it may succeed, by chance, but you had better
167.1510 +avoid parallel builds (make -j) in this platform, or get a better
167.1511 +compiler."
167.1512 +
167.1513 +	$opt_dry_run || $RM $removelist
167.1514 +	exit $EXIT_FAILURE
167.1515 +      fi
167.1516 +      removelist="$removelist $output_obj"
167.1517 +      $ECHO "$srcfile" > "$lockfile"
167.1518 +    fi
167.1519 +
167.1520 +    $opt_dry_run || $RM $removelist
167.1521 +    removelist="$removelist $lockfile"
167.1522 +    trap '$opt_dry_run || $RM $removelist; exit $EXIT_FAILURE' 1 2 15
167.1523 +
167.1524 +    if test -n "$fix_srcfile_path"; then
167.1525 +      eval srcfile=\"$fix_srcfile_path\"
167.1526 +    fi
167.1527 +    func_quote_for_eval "$srcfile"
167.1528 +    qsrcfile=$func_quote_for_eval_result
167.1529 +
167.1530 +    # Only build a PIC object if we are building libtool libraries.
167.1531 +    if test "$build_libtool_libs" = yes; then
167.1532 +      # Without this assignment, base_compile gets emptied.
167.1533 +      fbsd_hideous_sh_bug=$base_compile
167.1534 +
167.1535 +      if test "$pic_mode" != no; then
167.1536 +	command="$base_compile $qsrcfile $pic_flag"
167.1537 +      else
167.1538 +	# Don't build PIC code
167.1539 +	command="$base_compile $qsrcfile"
167.1540 +      fi
167.1541 +
167.1542 +      func_mkdir_p "$xdir$objdir"
167.1543 +
167.1544 +      if test -z "$output_obj"; then
167.1545 +	# Place PIC objects in $objdir
167.1546 +	command="$command -o $lobj"
167.1547 +      fi
167.1548 +
167.1549 +      func_show_eval_locale "$command"	\
167.1550 +          'test -n "$output_obj" && $RM $removelist; exit $EXIT_FAILURE'
167.1551 +
167.1552 +      if test "$need_locks" = warn &&
167.1553 +	 test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then
167.1554 +	$ECHO "\
167.1555 +*** ERROR, $lockfile contains:
167.1556 +`cat $lockfile 2>/dev/null`
167.1557 +
167.1558 +but it should contain:
167.1559 +$srcfile
167.1560 +
167.1561 +This indicates that another process is trying to use the same
167.1562 +temporary object file, and libtool could not work around it because
167.1563 +your compiler does not support \`-c' and \`-o' together.  If you
167.1564 +repeat this compilation, it may succeed, by chance, but you had better
167.1565 +avoid parallel builds (make -j) in this platform, or get a better
167.1566 +compiler."
167.1567 +
167.1568 +	$opt_dry_run || $RM $removelist
167.1569 +	exit $EXIT_FAILURE
167.1570 +      fi
167.1571 +
167.1572 +      # Just move the object if needed, then go on to compile the next one
167.1573 +      if test -n "$output_obj" && test "X$output_obj" != "X$lobj"; then
167.1574 +	func_show_eval '$MV "$output_obj" "$lobj"' \
167.1575 +	  'error=$?; $opt_dry_run || $RM $removelist; exit $error'
167.1576 +      fi
167.1577 +
167.1578 +      # Allow error messages only from the first compilation.
167.1579 +      if test "$suppress_opt" = yes; then
167.1580 +	suppress_output=' >/dev/null 2>&1'
167.1581 +      fi
167.1582 +    fi
167.1583 +
167.1584 +    # Only build a position-dependent object if we build old libraries.
167.1585 +    if test "$build_old_libs" = yes; then
167.1586 +      if test "$pic_mode" != yes; then
167.1587 +	# Don't build PIC code
167.1588 +	command="$base_compile $qsrcfile$pie_flag"
167.1589 +      else
167.1590 +	command="$base_compile $qsrcfile $pic_flag"
167.1591 +      fi
167.1592 +      if test "$compiler_c_o" = yes; then
167.1593 +	command="$command -o $obj"
167.1594 +      fi
167.1595 +
167.1596 +      # Suppress compiler output if we already did a PIC compilation.
167.1597 +      command="$command$suppress_output"
167.1598 +      func_show_eval_locale "$command" \
167.1599 +        '$opt_dry_run || $RM $removelist; exit $EXIT_FAILURE'
167.1600 +
167.1601 +      if test "$need_locks" = warn &&
167.1602 +	 test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then
167.1603 +	$ECHO "\
167.1604 +*** ERROR, $lockfile contains:
167.1605 +`cat $lockfile 2>/dev/null`
167.1606 +
167.1607 +but it should contain:
167.1608 +$srcfile
167.1609 +
167.1610 +This indicates that another process is trying to use the same
167.1611 +temporary object file, and libtool could not work around it because
167.1612 +your compiler does not support \`-c' and \`-o' together.  If you
167.1613 +repeat this compilation, it may succeed, by chance, but you had better
167.1614 +avoid parallel builds (make -j) in this platform, or get a better
167.1615 +compiler."
167.1616 +
167.1617 +	$opt_dry_run || $RM $removelist
167.1618 +	exit $EXIT_FAILURE
167.1619 +      fi
167.1620 +
167.1621 +      # Just move the object if needed
167.1622 +      if test -n "$output_obj" && test "X$output_obj" != "X$obj"; then
167.1623 +	func_show_eval '$MV "$output_obj" "$obj"' \
167.1624 +	  'error=$?; $opt_dry_run || $RM $removelist; exit $error'
167.1625 +      fi
167.1626 +    fi
167.1627 +
167.1628 +    $opt_dry_run || {
167.1629 +      func_write_libtool_object "$libobj" "$objdir/$objname" "$objname"
167.1630 +
167.1631 +      # Unlock the critical section if it was locked
167.1632 +      if test "$need_locks" != no; then
167.1633 +	removelist=$lockfile
167.1634 +        $RM "$lockfile"
167.1635 +      fi
167.1636 +    }
167.1637 +
167.1638 +    exit $EXIT_SUCCESS
167.1639 +}
167.1640 +
167.1641 +$opt_help || {
167.1642 +  test "$mode" = compile && func_mode_compile ${1+"$@"}
167.1643 +}
167.1644 +
167.1645 +func_mode_help ()
167.1646 +{
167.1647 +    # We need to display help for each of the modes.
167.1648 +    case $mode in
167.1649 +      "")
167.1650 +        # Generic help is extracted from the usage comments
167.1651 +        # at the start of this file.
167.1652 +        func_help
167.1653 +        ;;
167.1654 +
167.1655 +      clean)
167.1656 +        $ECHO \
167.1657 +"Usage: $progname [OPTION]... --mode=clean RM [RM-OPTION]... FILE...
167.1658 +
167.1659 +Remove files from the build directory.
167.1660 +
167.1661 +RM is the name of the program to use to delete files associated with each FILE
167.1662 +(typically \`/bin/rm').  RM-OPTIONS are options (such as \`-f') to be passed
167.1663 +to RM.
167.1664 +
167.1665 +If FILE is a libtool library, object or program, all the files associated
167.1666 +with it are deleted. Otherwise, only FILE itself is deleted using RM."
167.1667 +        ;;
167.1668 +
167.1669 +      compile)
167.1670 +      $ECHO \
167.1671 +"Usage: $progname [OPTION]... --mode=compile COMPILE-COMMAND... SOURCEFILE
167.1672 +
167.1673 +Compile a source file into a libtool library object.
167.1674 +
167.1675 +This mode accepts the following additional options:
167.1676 +
167.1677 +  -o OUTPUT-FILE    set the output file name to OUTPUT-FILE
167.1678 +  -no-suppress      do not suppress compiler output for multiple passes
167.1679 +  -prefer-pic       try to building PIC objects only
167.1680 +  -prefer-non-pic   try to building non-PIC objects only
167.1681 +  -shared           do not build a \`.o' file suitable for static linking
167.1682 +  -static           only build a \`.o' file suitable for static linking
167.1683 +  -Wc,FLAG          pass FLAG directly to the compiler
167.1684 +
167.1685 +COMPILE-COMMAND is a command to be used in creating a \`standard' object file
167.1686 +from the given SOURCEFILE.
167.1687 +
167.1688 +The output file name is determined by removing the directory component from
167.1689 +SOURCEFILE, then substituting the C source code suffix \`.c' with the
167.1690 +library object suffix, \`.lo'."
167.1691 +        ;;
167.1692 +
167.1693 +      execute)
167.1694 +        $ECHO \
167.1695 +"Usage: $progname [OPTION]... --mode=execute COMMAND [ARGS]...
167.1696 +
167.1697 +Automatically set library path, then run a program.
167.1698 +
167.1699 +This mode accepts the following additional options:
167.1700 +
167.1701 +  -dlopen FILE      add the directory containing FILE to the library path
167.1702 +
167.1703 +This mode sets the library path environment variable according to \`-dlopen'
167.1704 +flags.
167.1705 +
167.1706 +If any of the ARGS are libtool executable wrappers, then they are translated
167.1707 +into their corresponding uninstalled binary, and any of their required library
167.1708 +directories are added to the library path.
167.1709 +
167.1710 +Then, COMMAND is executed, with ARGS as arguments."
167.1711 +        ;;
167.1712 +
167.1713 +      finish)
167.1714 +        $ECHO \
167.1715 +"Usage: $progname [OPTION]... --mode=finish [LIBDIR]...
167.1716 +
167.1717 +Complete the installation of libtool libraries.
167.1718 +
167.1719 +Each LIBDIR is a directory that contains libtool libraries.
167.1720 +
167.1721 +The commands that this mode executes may require superuser privileges.  Use
167.1722 +the \`--dry-run' option if you just want to see what would be executed."
167.1723 +        ;;
167.1724 +
167.1725 +      install)
167.1726 +        $ECHO \
167.1727 +"Usage: $progname [OPTION]... --mode=install INSTALL-COMMAND...
167.1728 +
167.1729 +Install executables or libraries.
167.1730 +
167.1731 +INSTALL-COMMAND is the installation command.  The first component should be
167.1732 +either the \`install' or \`cp' program.
167.1733 +
167.1734 +The following components of INSTALL-COMMAND are treated specially:
167.1735 +
167.1736 +  -inst-prefix-dir PREFIX-DIR  Use PREFIX-DIR as a staging area for installation
167.1737 +
167.1738 +The rest of the components are interpreted as arguments to that command (only
167.1739 +BSD-compatible install options are recognized)."
167.1740 +        ;;
167.1741 +
167.1742 +      link)
167.1743 +        $ECHO \
167.1744 +"Usage: $progname [OPTION]... --mode=link LINK-COMMAND...
167.1745 +
167.1746 +Link object files or libraries together to form another library, or to
167.1747 +create an executable program.
167.1748 +
167.1749 +LINK-COMMAND is a command using the C compiler that you would use to create
167.1750 +a program from several object files.
167.1751 +
167.1752 +The following components of LINK-COMMAND are treated specially:
167.1753 +
167.1754 +  -all-static       do not do any dynamic linking at all
167.1755 +  -avoid-version    do not add a version suffix if possible
167.1756 +  -bindir BINDIR    specify path to binaries directory (for systems where
167.1757 +                    libraries must be found in the PATH setting at runtime)
167.1758 +  -dlopen FILE      \`-dlpreopen' FILE if it cannot be dlopened at runtime
167.1759 +  -dlpreopen FILE   link in FILE and add its symbols to lt_preloaded_symbols
167.1760 +  -export-dynamic   allow symbols from OUTPUT-FILE to be resolved with dlsym(3)
167.1761 +  -export-symbols SYMFILE
167.1762 +                    try to export only the symbols listed in SYMFILE
167.1763 +  -export-symbols-regex REGEX
167.1764 +                    try to export only the symbols matching REGEX
167.1765 +  -LLIBDIR          search LIBDIR for required installed libraries
167.1766 +  -lNAME            OUTPUT-FILE requires the installed library libNAME
167.1767 +  -module           build a library that can dlopened
167.1768 +  -no-fast-install  disable the fast-install mode
167.1769 +  -no-install       link a not-installable executable
167.1770 +  -no-undefined     declare that a library does not refer to external symbols
167.1771 +  -o OUTPUT-FILE    create OUTPUT-FILE from the specified objects
167.1772 +  -objectlist FILE  Use a list of object files found in FILE to specify objects
167.1773 +  -precious-files-regex REGEX
167.1774 +                    don't remove output files matching REGEX
167.1775 +  -release RELEASE  specify package release information
167.1776 +  -rpath LIBDIR     the created library will eventually be installed in LIBDIR
167.1777 +  -R[ ]LIBDIR       add LIBDIR to the runtime path of programs and libraries
167.1778 +  -shared           only do dynamic linking of libtool libraries
167.1779 +  -shrext SUFFIX    override the standard shared library file extension
167.1780 +  -static           do not do any dynamic linking of uninstalled libtool libraries
167.1781 +  -static-libtool-libs
167.1782 +                    do not do any dynamic linking of libtool libraries
167.1783 +  -version-info CURRENT[:REVISION[:AGE]]
167.1784 +                    specify library version info [each variable defaults to 0]
167.1785 +  -weak LIBNAME     declare that the target provides the LIBNAME interface
167.1786 +  -Wc,FLAG
167.1787 +  -Xcompiler FLAG   pass linker-specific FLAG directly to the compiler
167.1788 +  -Wl,FLAG
167.1789 +  -Xlinker FLAG     pass linker-specific FLAG directly to the linker
167.1790 +  -XCClinker FLAG   pass link-specific FLAG to the compiler driver (CC)
167.1791 +
167.1792 +All other options (arguments beginning with \`-') are ignored.
167.1793 +
167.1794 +Every other argument is treated as a filename.  Files ending in \`.la' are
167.1795 +treated as uninstalled libtool libraries, other files are standard or library
167.1796 +object files.
167.1797 +
167.1798 +If the OUTPUT-FILE ends in \`.la', then a libtool library is created,
167.1799 +only library objects (\`.lo' files) may be specified, and \`-rpath' is
167.1800 +required, except when creating a convenience library.
167.1801 +
167.1802 +If OUTPUT-FILE ends in \`.a' or \`.lib', then a standard library is created
167.1803 +using \`ar' and \`ranlib', or on Windows using \`lib'.
167.1804 +
167.1805 +If OUTPUT-FILE ends in \`.lo' or \`.${objext}', then a reloadable object file
167.1806 +is created, otherwise an executable program is created."
167.1807 +        ;;
167.1808 +
167.1809 +      uninstall)
167.1810 +        $ECHO \
167.1811 +"Usage: $progname [OPTION]... --mode=uninstall RM [RM-OPTION]... FILE...
167.1812 +
167.1813 +Remove libraries from an installation directory.
167.1814 +
167.1815 +RM is the name of the program to use to delete files associated with each FILE
167.1816 +(typically \`/bin/rm').  RM-OPTIONS are options (such as \`-f') to be passed
167.1817 +to RM.
167.1818 +
167.1819 +If FILE is a libtool library, all the files associated with it are deleted.
167.1820 +Otherwise, only FILE itself is deleted using RM."
167.1821 +        ;;
167.1822 +
167.1823 +      *)
167.1824 +        func_fatal_help "invalid operation mode \`$mode'"
167.1825 +        ;;
167.1826 +    esac
167.1827 +
167.1828 +    echo
167.1829 +    $ECHO "Try \`$progname --help' for more information about other modes."
167.1830 +}
167.1831 +
167.1832 +# Now that we've collected a possible --mode arg, show help if necessary
167.1833 +if $opt_help; then
167.1834 +  if test "$opt_help" = :; then
167.1835 +    func_mode_help
167.1836 +  else
167.1837 +    {
167.1838 +      func_help noexit
167.1839 +      for mode in compile link execute install finish uninstall clean; do
167.1840 +	func_mode_help
167.1841 +      done
167.1842 +    } | sed -n '1p; 2,$s/^Usage:/  or: /p'
167.1843 +    {
167.1844 +      func_help noexit
167.1845 +      for mode in compile link execute install finish uninstall clean; do
167.1846 +	echo
167.1847 +	func_mode_help
167.1848 +      done
167.1849 +    } |
167.1850 +    sed '1d
167.1851 +      /^When reporting/,/^Report/{
167.1852 +	H
167.1853 +	d
167.1854 +      }
167.1855 +      $x
167.1856 +      /information about other modes/d
167.1857 +      /more detailed .*MODE/d
167.1858 +      s/^Usage:.*--mode=\([^ ]*\) .*/Description of \1 mode:/'
167.1859 +  fi
167.1860 +  exit $?
167.1861 +fi
167.1862 +
167.1863 +
167.1864 +# func_mode_execute arg...
167.1865 +func_mode_execute ()
167.1866 +{
167.1867 +    $opt_debug
167.1868 +    # The first argument is the command name.
167.1869 +    cmd="$nonopt"
167.1870 +    test -z "$cmd" && \
167.1871 +      func_fatal_help "you must specify a COMMAND"
167.1872 +
167.1873 +    # Handle -dlopen flags immediately.
167.1874 +    for file in $execute_dlfiles; do
167.1875 +      test -f "$file" \
167.1876 +	|| func_fatal_help "\`$file' is not a file"
167.1877 +
167.1878 +      dir=
167.1879 +      case $file in
167.1880 +      *.la)
167.1881 +	# Check to see that this really is a libtool archive.
167.1882 +	func_lalib_unsafe_p "$file" \
167.1883 +	  || func_fatal_help "\`$lib' is not a valid libtool archive"
167.1884 +
167.1885 +	# Read the libtool library.
167.1886 +	dlname=
167.1887 +	library_names=
167.1888 +	func_source "$file"
167.1889 +
167.1890 +	# Skip this library if it cannot be dlopened.
167.1891 +	if test -z "$dlname"; then
167.1892 +	  # Warn if it was a shared library.
167.1893 +	  test -n "$library_names" && \
167.1894 +	    func_warning "\`$file' was not linked with \`-export-dynamic'"
167.1895 +	  continue
167.1896 +	fi
167.1897 +
167.1898 +	func_dirname "$file" "" "."
167.1899 +	dir="$func_dirname_result"
167.1900 +
167.1901 +	if test -f "$dir/$objdir/$dlname"; then
167.1902 +	  dir="$dir/$objdir"
167.1903 +	else
167.1904 +	  if test ! -f "$dir/$dlname"; then
167.1905 +	    func_fatal_error "cannot find \`$dlname' in \`$dir' or \`$dir/$objdir'"
167.1906 +	  fi
167.1907 +	fi
167.1908 +	;;
167.1909 +
167.1910 +      *.lo)
167.1911 +	# Just add the directory containing the .lo file.
167.1912 +	func_dirname "$file" "" "."
167.1913 +	dir="$func_dirname_result"
167.1914 +	;;
167.1915 +
167.1916 +      *)
167.1917 +	func_warning "\`-dlopen' is ignored for non-libtool libraries and objects"
167.1918 +	continue
167.1919 +	;;
167.1920 +      esac
167.1921 +
167.1922 +      # Get the absolute pathname.
167.1923 +      absdir=`cd "$dir" && pwd`
167.1924 +      test -n "$absdir" && dir="$absdir"
167.1925 +
167.1926 +      # Now add the directory to shlibpath_var.
167.1927 +      if eval "test -z \"\$$shlibpath_var\""; then
167.1928 +	eval "$shlibpath_var=\"\$dir\""
167.1929 +      else
167.1930 +	eval "$shlibpath_var=\"\$dir:\$$shlibpath_var\""
167.1931 +      fi
167.1932 +    done
167.1933 +
167.1934 +    # This variable tells wrapper scripts just to set shlibpath_var
167.1935 +    # rather than running their programs.
167.1936 +    libtool_execute_magic="$magic"
167.1937 +
167.1938 +    # Check if any of the arguments is a wrapper script.
167.1939 +    args=
167.1940 +    for file
167.1941 +    do
167.1942 +      case $file in
167.1943 +      -* | *.la | *.lo ) ;;
167.1944 +      *)
167.1945 +	# Do a test to see if this is really a libtool program.
167.1946 +	if func_ltwrapper_script_p "$file"; then
167.1947 +	  func_source "$file"
167.1948 +	  # Transform arg to wrapped name.
167.1949 +	  file="$progdir/$program"
167.1950 +	elif func_ltwrapper_executable_p "$file"; then
167.1951 +	  func_ltwrapper_scriptname "$file"
167.1952 +	  func_source "$func_ltwrapper_scriptname_result"
167.1953 +	  # Transform arg to wrapped name.
167.1954 +	  file="$progdir/$program"
167.1955 +	fi
167.1956 +	;;
167.1957 +      esac
167.1958 +      # Quote arguments (to preserve shell metacharacters).
167.1959 +      func_quote_for_eval "$file"
167.1960 +      args="$args $func_quote_for_eval_result"
167.1961 +    done
167.1962 +
167.1963 +    if test "X$opt_dry_run" = Xfalse; then
167.1964 +      if test -n "$shlibpath_var"; then
167.1965 +	# Export the shlibpath_var.
167.1966 +	eval "export $shlibpath_var"
167.1967 +      fi
167.1968 +
167.1969 +      # Restore saved environment variables
167.1970 +      for lt_var in LANG LANGUAGE LC_ALL LC_CTYPE LC_COLLATE LC_MESSAGES
167.1971 +      do
167.1972 +	eval "if test \"\${save_$lt_var+set}\" = set; then
167.1973 +                $lt_var=\$save_$lt_var; export $lt_var
167.1974 +	      else
167.1975 +		$lt_unset $lt_var
167.1976 +	      fi"
167.1977 +      done
167.1978 +
167.1979 +      # Now prepare to actually exec the command.
167.1980 +      exec_cmd="\$cmd$args"
167.1981 +    else
167.1982 +      # Display what would be done.
167.1983 +      if test -n "$shlibpath_var"; then
167.1984 +	eval "\$ECHO \"\$shlibpath_var=\$$shlibpath_var\""
167.1985 +	echo "export $shlibpath_var"
167.1986 +      fi
167.1987 +      $ECHO "$cmd$args"
167.1988 +      exit $EXIT_SUCCESS
167.1989 +    fi
167.1990 +}
167.1991 +
167.1992 +test "$mode" = execute && func_mode_execute ${1+"$@"}
167.1993 +
167.1994 +
167.1995 +# func_mode_finish arg...
167.1996 +func_mode_finish ()
167.1997 +{
167.1998 +    $opt_debug
167.1999 +    libdirs="$nonopt"
167.2000 +    admincmds=
167.2001 +
167.2002 +    if test -n "$finish_cmds$finish_eval" && test -n "$libdirs"; then
167.2003 +      for dir
167.2004 +      do
167.2005 +	libdirs="$libdirs $dir"
167.2006 +      done
167.2007 +
167.2008 +      for libdir in $libdirs; do
167.2009 +	if test -n "$finish_cmds"; then
167.2010 +	  # Do each command in the finish commands.
167.2011 +	  func_execute_cmds "$finish_cmds" 'admincmds="$admincmds
167.2012 +'"$cmd"'"'
167.2013 +	fi
167.2014 +	if test -n "$finish_eval"; then
167.2015 +	  # Do the single finish_eval.
167.2016 +	  eval cmds=\"$finish_eval\"
167.2017 +	  $opt_dry_run || eval "$cmds" || admincmds="$admincmds
167.2018 +       $cmds"
167.2019 +	fi
167.2020 +      done
167.2021 +    fi
167.2022 +
167.2023 +    # Exit here if they wanted silent mode.
167.2024 +    $opt_silent && exit $EXIT_SUCCESS
167.2025 +
167.2026 +    echo "----------------------------------------------------------------------"
167.2027 +    echo "Libraries have been installed in:"
167.2028 +    for libdir in $libdirs; do
167.2029 +      $ECHO "   $libdir"
167.2030 +    done
167.2031 +    echo
167.2032 +    echo "If you ever happen to want to link against installed libraries"
167.2033 +    echo "in a given directory, LIBDIR, you must either use libtool, and"
167.2034 +    echo "specify the full pathname of the library, or use the \`-LLIBDIR'"
167.2035 +    echo "flag during linking and do at least one of the following:"
167.2036 +    if test -n "$shlibpath_var"; then
167.2037 +      echo "   - add LIBDIR to the \`$shlibpath_var' environment variable"
167.2038 +      echo "     during execution"
167.2039 +    fi
167.2040 +    if test -n "$runpath_var"; then
167.2041 +      echo "   - add LIBDIR to the \`$runpath_var' environment variable"
167.2042 +      echo "     during linking"
167.2043 +    fi
167.2044 +    if test -n "$hardcode_libdir_flag_spec"; then
167.2045 +      libdir=LIBDIR
167.2046 +      eval flag=\"$hardcode_libdir_flag_spec\"
167.2047 +
167.2048 +      $ECHO "   - use the \`$flag' linker flag"
167.2049 +    fi
167.2050 +    if test -n "$admincmds"; then
167.2051 +      $ECHO "   - have your system administrator run these commands:$admincmds"
167.2052 +    fi
167.2053 +    if test -f /etc/ld.so.conf; then
167.2054 +      echo "   - have your system administrator add LIBDIR to \`/etc/ld.so.conf'"
167.2055 +    fi
167.2056 +    echo
167.2057 +
167.2058 +    echo "See any operating system documentation about shared libraries for"
167.2059 +    case $host in
167.2060 +      solaris2.[6789]|solaris2.1[0-9])
167.2061 +        echo "more information, such as the ld(1), crle(1) and ld.so(8) manual"
167.2062 +	echo "pages."
167.2063 +	;;
167.2064 +      *)
167.2065 +        echo "more information, such as the ld(1) and ld.so(8) manual pages."
167.2066 +        ;;
167.2067 +    esac
167.2068 +    echo "----------------------------------------------------------------------"
167.2069 +    exit $EXIT_SUCCESS
167.2070 +}
167.2071 +
167.2072 +test "$mode" = finish && func_mode_finish ${1+"$@"}
167.2073 +
167.2074 +
167.2075 +# func_mode_install arg...
167.2076 +func_mode_install ()
167.2077 +{
167.2078 +    $opt_debug
167.2079 +    # There may be an optional sh(1) argument at the beginning of
167.2080 +    # install_prog (especially on Windows NT).
167.2081 +    if test "$nonopt" = "$SHELL" || test "$nonopt" = /bin/sh ||
167.2082 +       # Allow the use of GNU shtool's install command.
167.2083 +       case $nonopt in *shtool*) :;; *) false;; esac; then
167.2084 +      # Aesthetically quote it.
167.2085 +      func_quote_for_eval "$nonopt"
167.2086 +      install_prog="$func_quote_for_eval_result "
167.2087 +      arg=$1
167.2088 +      shift
167.2089 +    else
167.2090 +      install_prog=
167.2091 +      arg=$nonopt
167.2092 +    fi
167.2093 +
167.2094 +    # The real first argument should be the name of the installation program.
167.2095 +    # Aesthetically quote it.
167.2096 +    func_quote_for_eval "$arg"
167.2097 +    install_prog="$install_prog$func_quote_for_eval_result"
167.2098 +    install_shared_prog=$install_prog
167.2099 +    case " $install_prog " in
167.2100 +      *[\\\ /]cp\ *) install_cp=: ;;
167.2101 +      *) install_cp=false ;;
167.2102 +    esac
167.2103 +
167.2104 +    # We need to accept at least all the BSD install flags.
167.2105 +    dest=
167.2106 +    files=
167.2107 +    opts=
167.2108 +    prev=
167.2109 +    install_type=
167.2110 +    isdir=no
167.2111 +    stripme=
167.2112 +    no_mode=:
167.2113 +    for arg
167.2114 +    do
167.2115 +      arg2=
167.2116 +      if test -n "$dest"; then
167.2117 +	files="$files $dest"
167.2118 +	dest=$arg
167.2119 +	continue
167.2120 +      fi
167.2121 +
167.2122 +      case $arg in
167.2123 +      -d) isdir=yes ;;
167.2124 +      -f)
167.2125 +	if $install_cp; then :; else
167.2126 +	  prev=$arg
167.2127 +	fi
167.2128 +	;;
167.2129 +      -g | -m | -o)
167.2130 +	prev=$arg
167.2131 +	;;
167.2132 +      -s)
167.2133 +	stripme=" -s"
167.2134 +	continue
167.2135 +	;;
167.2136 +      -*)
167.2137 +	;;
167.2138 +      *)
167.2139 +	# If the previous option needed an argument, then skip it.
167.2140 +	if test -n "$prev"; then
167.2141 +	  if test "x$prev" = x-m && test -n "$install_override_mode"; then
167.2142 +	    arg2=$install_override_mode
167.2143 +	    no_mode=false
167.2144 +	  fi
167.2145 +	  prev=
167.2146 +	else
167.2147 +	  dest=$arg
167.2148 +	  continue
167.2149 +	fi
167.2150 +	;;
167.2151 +      esac
167.2152 +
167.2153 +      # Aesthetically quote the argument.
167.2154 +      func_quote_for_eval "$arg"
167.2155 +      install_prog="$install_prog $func_quote_for_eval_result"
167.2156 +      if test -n "$arg2"; then
167.2157 +	func_quote_for_eval "$arg2"
167.2158 +      fi
167.2159 +      install_shared_prog="$install_shared_prog $func_quote_for_eval_result"
167.2160 +    done
167.2161 +
167.2162 +    test -z "$install_prog" && \
167.2163 +      func_fatal_help "you must specify an install program"
167.2164 +
167.2165 +    test -n "$prev" && \
167.2166 +      func_fatal_help "the \`$prev' option requires an argument"
167.2167 +
167.2168 +    if test -n "$install_override_mode" && $no_mode; then
167.2169 +      if $install_cp; then :; else
167.2170 +	func_quote_for_eval "$install_override_mode"
167.2171 +	install_shared_prog="$install_shared_prog -m $func_quote_for_eval_result"
167.2172 +      fi
167.2173 +    fi
167.2174 +
167.2175 +    if test -z "$files"; then
167.2176 +      if test -z "$dest"; then
167.2177 +	func_fatal_help "no file or destination specified"
167.2178 +      else
167.2179 +	func_fatal_help "you must specify a destination"
167.2180 +      fi
167.2181 +    fi
167.2182 +
167.2183 +    # Strip any trailing slash from the destination.
167.2184 +    func_stripname '' '/' "$dest"
167.2185 +    dest=$func_stripname_result
167.2186 +
167.2187 +    # Check to see that the destination is a directory.
167.2188 +    test -d "$dest" && isdir=yes
167.2189 +    if test "$isdir" = yes; then
167.2190 +      destdir="$dest"
167.2191 +      destname=
167.2192 +    else
167.2193 +      func_dirname_and_basename "$dest" "" "."
167.2194 +      destdir="$func_dirname_result"
167.2195 +      destname="$func_basename_result"
167.2196 +
167.2197 +      # Not a directory, so check to see that there is only one file specified.
167.2198 +      set dummy $files; shift
167.2199 +      test "$#" -gt 1 && \
167.2200 +	func_fatal_help "\`$dest' is not a directory"
167.2201 +    fi
167.2202 +    case $destdir in
167.2203 +    [\\/]* | [A-Za-z]:[\\/]*) ;;
167.2204 +    *)
167.2205 +      for file in $files; do
167.2206 +	case $file in
167.2207 +	*.lo) ;;
167.2208 +	*)
167.2209 +	  func_fatal_help "\`$destdir' must be an absolute directory name"
167.2210 +	  ;;
167.2211 +	esac
167.2212 +      done
167.2213 +      ;;
167.2214 +    esac
167.2215 +
167.2216 +    # This variable tells wrapper scripts just to set variables rather
167.2217 +    # than running their programs.
167.2218 +    libtool_install_magic="$magic"
167.2219 +
167.2220 +    staticlibs=
167.2221 +    future_libdirs=
167.2222 +    current_libdirs=
167.2223 +    for file in $files; do
167.2224 +
167.2225 +      # Do each installation.
167.2226 +      case $file in
167.2227 +      *.$libext)
167.2228 +	# Do the static libraries later.
167.2229 +	staticlibs="$staticlibs $file"
167.2230 +	;;
167.2231 +
167.2232 +      *.la)
167.2233 +	# Check to see that this really is a libtool archive.
167.2234 +	func_lalib_unsafe_p "$file" \
167.2235 +	  || func_fatal_help "\`$file' is not a valid libtool archive"
167.2236 +
167.2237 +	library_names=
167.2238 +	old_library=
167.2239 +	relink_command=
167.2240 +	func_source "$file"
167.2241 +
167.2242 +	# Add the libdir to current_libdirs if it is the destination.
167.2243 +	if test "X$destdir" = "X$libdir"; then
167.2244 +	  case "$current_libdirs " in
167.2245 +	  *" $libdir "*) ;;
167.2246 +	  *) current_libdirs="$current_libdirs $libdir" ;;
167.2247 +	  esac
167.2248 +	else
167.2249 +	  # Note the libdir as a future libdir.
167.2250 +	  case "$future_libdirs " in
167.2251 +	  *" $libdir "*) ;;
167.2252 +	  *) future_libdirs="$future_libdirs $libdir" ;;
167.2253 +	  esac
167.2254 +	fi
167.2255 +
167.2256 +	func_dirname "$file" "/" ""
167.2257 +	dir="$func_dirname_result"
167.2258 +	dir="$dir$objdir"
167.2259 +
167.2260 +	if test -n "$relink_command"; then
167.2261 +	  # Determine the prefix the user has applied to our future dir.
167.2262 +	  inst_prefix_dir=`$ECHO "$destdir" | $SED -e "s%$libdir\$%%"`
167.2263 +
167.2264 +	  # Don't allow the user to place us outside of our expected
167.2265 +	  # location b/c this prevents finding dependent libraries that
167.2266 +	  # are installed to the same prefix.
167.2267 +	  # At present, this check doesn't affect windows .dll's that
167.2268 +	  # are installed into $libdir/../bin (currently, that works fine)
167.2269 +	  # but it's something to keep an eye on.
167.2270 +	  test "$inst_prefix_dir" = "$destdir" && \
167.2271 +	    func_fatal_error "error: cannot install \`$file' to a directory not ending in $libdir"
167.2272 +
167.2273 +	  if test -n "$inst_prefix_dir"; then
167.2274 +	    # Stick the inst_prefix_dir data into the link command.
167.2275 +	    relink_command=`$ECHO "$relink_command" | $SED "s%@inst_prefix_dir@%-inst-prefix-dir $inst_prefix_dir%"`
167.2276 +	  else
167.2277 +	    relink_command=`$ECHO "$relink_command" | $SED "s%@inst_prefix_dir@%%"`
167.2278 +	  fi
167.2279 +
167.2280 +	  func_warning "relinking \`$file'"
167.2281 +	  func_show_eval "$relink_command" \
167.2282 +	    'func_fatal_error "error: relink \`$file'\'' with the above command before installing it"'
167.2283 +	fi
167.2284 +
167.2285 +	# See the names of the shared library.
167.2286 +	set dummy $library_names; shift
167.2287 +	if test -n "$1"; then
167.2288 +	  realname="$1"
167.2289 +	  shift
167.2290 +
167.2291 +	  srcname="$realname"
167.2292 +	  test -n "$relink_command" && srcname="$realname"T
167.2293 +
167.2294 +	  # Install the shared library and build the symlinks.
167.2295 +	  func_show_eval "$install_shared_prog $dir/$srcname $destdir/$realname" \
167.2296 +	      'exit $?'
167.2297 +	  tstripme="$stripme"
167.2298 +	  case $host_os in
167.2299 +	  cygwin* | mingw* | pw32* | cegcc*)
167.2300 +	    case $realname in
167.2301 +	    *.dll.a)
167.2302 +	      tstripme=""
167.2303 +	      ;;
167.2304 +	    esac
167.2305 +	    ;;
167.2306 +	  esac
167.2307 +	  if test -n "$tstripme" && test -n "$striplib"; then
167.2308 +	    func_show_eval "$striplib $destdir/$realname" 'exit $?'
167.2309 +	  fi
167.2310 +
167.2311 +	  if test "$#" -gt 0; then
167.2312 +	    # Delete the old symlinks, and create new ones.
167.2313 +	    # Try `ln -sf' first, because the `ln' binary might depend on
167.2314 +	    # the symlink we replace!  Solaris /bin/ln does not understand -f,
167.2315 +	    # so we also need to try rm && ln -s.
167.2316 +	    for linkname
167.2317 +	    do
167.2318 +	      test "$linkname" != "$realname" \
167.2319 +		&& func_show_eval "(cd $destdir && { $LN_S -f $realname $linkname || { $RM $linkname && $LN_S $realname $linkname; }; })"
167.2320 +	    done
167.2321 +	  fi
167.2322 +
167.2323 +	  # Do each command in the postinstall commands.
167.2324 +	  lib="$destdir/$realname"
167.2325 +	  func_execute_cmds "$postinstall_cmds" 'exit $?'
167.2326 +	fi
167.2327 +
167.2328 +	# Install the pseudo-library for information purposes.
167.2329 +	func_basename "$file"
167.2330 +	name="$func_basename_result"
167.2331 +	instname="$dir/$name"i
167.2332 +	func_show_eval "$install_prog $instname $destdir/$name" 'exit $?'
167.2333 +
167.2334 +	# Maybe install the static library, too.
167.2335 +	test -n "$old_library" && staticlibs="$staticlibs $dir/$old_library"
167.2336 +	;;
167.2337 +
167.2338 +      *.lo)
167.2339 +	# Install (i.e. copy) a libtool object.
167.2340 +
167.2341 +	# Figure out destination file name, if it wasn't already specified.
167.2342 +	if test -n "$destname"; then
167.2343 +	  destfile="$destdir/$destname"
167.2344 +	else
167.2345 +	  func_basename "$file"
167.2346 +	  destfile="$func_basename_result"
167.2347 +	  destfile="$destdir/$destfile"
167.2348 +	fi
167.2349 +
167.2350 +	# Deduce the name of the destination old-style object file.
167.2351 +	case $destfile in
167.2352 +	*.lo)
167.2353 +	  func_lo2o "$destfile"
167.2354 +	  staticdest=$func_lo2o_result
167.2355 +	  ;;
167.2356 +	*.$objext)
167.2357 +	  staticdest="$destfile"
167.2358 +	  destfile=
167.2359 +	  ;;
167.2360 +	*)
167.2361 +	  func_fatal_help "cannot copy a libtool object to \`$destfile'"
167.2362 +	  ;;
167.2363 +	esac
167.2364 +
167.2365 +	# Install the libtool object if requested.
167.2366 +	test -n "$destfile" && \
167.2367 +	  func_show_eval "$install_prog $file $destfile" 'exit $?'
167.2368 +
167.2369 +	# Install the old object if enabled.
167.2370 +	if test "$build_old_libs" = yes; then
167.2371 +	  # Deduce the name of the old-style object file.
167.2372 +	  func_lo2o "$file"
167.2373 +	  staticobj=$func_lo2o_result
167.2374 +	  func_show_eval "$install_prog \$staticobj \$staticdest" 'exit $?'
167.2375 +	fi
167.2376 +	exit $EXIT_SUCCESS
167.2377 +	;;
167.2378 +
167.2379 +      *)
167.2380 +	# Figure out destination file name, if it wasn't already specified.
167.2381 +	if test -n "$destname"; then
167.2382 +	  destfile="$destdir/$destname"
167.2383 +	else
167.2384 +	  func_basename "$file"
167.2385 +	  destfile="$func_basename_result"
167.2386 +	  destfile="$destdir/$destfile"
167.2387 +	fi
167.2388 +
167.2389 +	# If the file is missing, and there is a .exe on the end, strip it
167.2390 +	# because it is most likely a libtool script we actually want to
167.2391 +	# install
167.2392 +	stripped_ext=""
167.2393 +	case $file in
167.2394 +	  *.exe)
167.2395 +	    if test ! -f "$file"; then
167.2396 +	      func_stripname '' '.exe' "$file"
167.2397 +	      file=$func_stripname_result
167.2398 +	      stripped_ext=".exe"
167.2399 +	    fi
167.2400 +	    ;;
167.2401 +	esac
167.2402 +
167.2403 +	# Do a test to see if this is really a libtool program.
167.2404 +	case $host in
167.2405 +	*cygwin* | *mingw*)
167.2406 +	    if func_ltwrapper_executable_p "$file"; then
167.2407 +	      func_ltwrapper_scriptname "$file"
167.2408 +	      wrapper=$func_ltwrapper_scriptname_result
167.2409 +	    else
167.2410 +	      func_stripname '' '.exe' "$file"
167.2411 +	      wrapper=$func_stripname_result
167.2412 +	    fi
167.2413 +	    ;;
167.2414 +	*)
167.2415 +	    wrapper=$file
167.2416 +	    ;;
167.2417 +	esac
167.2418 +	if func_ltwrapper_script_p "$wrapper"; then
167.2419 +	  notinst_deplibs=
167.2420 +	  relink_command=
167.2421 +
167.2422 +	  func_source "$wrapper"
167.2423 +
167.2424 +	  # Check the variables that should have been set.
167.2425 +	  test -z "$generated_by_libtool_version" && \
167.2426 +	    func_fatal_error "invalid libtool wrapper script \`$wrapper'"
167.2427 +
167.2428 +	  finalize=yes
167.2429 +	  for lib in $notinst_deplibs; do
167.2430 +	    # Check to see that each library is installed.
167.2431 +	    libdir=
167.2432 +	    if test -f "$lib"; then
167.2433 +	      func_source "$lib"
167.2434 +	    fi
167.2435 +	    libfile="$libdir/"`$ECHO "$lib" | $SED 's%^.*/%%g'` ### testsuite: skip nested quoting test
167.2436 +	    if test -n "$libdir" && test ! -f "$libfile"; then
167.2437 +	      func_warning "\`$lib' has not been installed in \`$libdir'"
167.2438 +	      finalize=no
167.2439 +	    fi
167.2440 +	  done
167.2441 +
167.2442 +	  relink_command=
167.2443 +	  func_source "$wrapper"
167.2444 +
167.2445 +	  outputname=
167.2446 +	  if test "$fast_install" = no && test -n "$relink_command"; then
167.2447 +	    $opt_dry_run || {
167.2448 +	      if test "$finalize" = yes; then
167.2449 +	        tmpdir=`func_mktempdir`
167.2450 +		func_basename "$file$stripped_ext"
167.2451 +		file="$func_basename_result"
167.2452 +	        outputname="$tmpdir/$file"
167.2453 +	        # Replace the output file specification.
167.2454 +	        relink_command=`$ECHO "$relink_command" | $SED 's%@OUTPUT@%'"$outputname"'%g'`
167.2455 +
167.2456 +	        $opt_silent || {
167.2457 +	          func_quote_for_expand "$relink_command"
167.2458 +		  eval "func_echo $func_quote_for_expand_result"
167.2459 +	        }
167.2460 +	        if eval "$relink_command"; then :
167.2461 +	          else
167.2462 +		  func_error "error: relink \`$file' with the above command before installing it"
167.2463 +		  $opt_dry_run || ${RM}r "$tmpdir"
167.2464 +		  continue
167.2465 +	        fi
167.2466 +	        file="$outputname"
167.2467 +	      else
167.2468 +	        func_warning "cannot relink \`$file'"
167.2469 +	      fi
167.2470 +	    }
167.2471 +	  else
167.2472 +	    # Install the binary that we compiled earlier.
167.2473 +	    file=`$ECHO "$file$stripped_ext" | $SED "s%\([^/]*\)$%$objdir/\1%"`
167.2474 +	  fi
167.2475 +	fi
167.2476 +
167.2477 +	# remove .exe since cygwin /usr/bin/install will append another
167.2478 +	# one anyway
167.2479 +	case $install_prog,$host in
167.2480 +	*/usr/bin/install*,*cygwin*)
167.2481 +	  case $file:$destfile in
167.2482 +	  *.exe:*.exe)
167.2483 +	    # this is ok
167.2484 +	    ;;
167.2485 +	  *.exe:*)
167.2486 +	    destfile=$destfile.exe
167.2487 +	    ;;
167.2488 +	  *:*.exe)
167.2489 +	    func_stripname '' '.exe' "$destfile"
167.2490 +	    destfile=$func_stripname_result
167.2491 +	    ;;
167.2492 +	  esac
167.2493 +	  ;;
167.2494 +	esac
167.2495 +	func_show_eval "$install_prog\$stripme \$file \$destfile" 'exit $?'
167.2496 +	$opt_dry_run || if test -n "$outputname"; then
167.2497 +	  ${RM}r "$tmpdir"
167.2498 +	fi
167.2499 +	;;
167.2500 +      esac
167.2501 +    done
167.2502 +
167.2503 +    for file in $staticlibs; do
167.2504 +      func_basename "$file"
167.2505 +      name="$func_basename_result"
167.2506 +
167.2507 +      # Set up the ranlib parameters.
167.2508 +      oldlib="$destdir/$name"
167.2509 +
167.2510 +      func_show_eval "$install_prog \$file \$oldlib" 'exit $?'
167.2511 +
167.2512 +      if test -n "$stripme" && test -n "$old_striplib"; then
167.2513 +	func_show_eval "$old_striplib $oldlib" 'exit $?'
167.2514 +      fi
167.2515 +
167.2516 +      # Do each command in the postinstall commands.
167.2517 +      func_execute_cmds "$old_postinstall_cmds" 'exit $?'
167.2518 +    done
167.2519 +
167.2520 +    test -n "$future_libdirs" && \
167.2521 +      func_warning "remember to run \`$progname --finish$future_libdirs'"
167.2522 +
167.2523 +    if test -n "$current_libdirs"; then
167.2524 +      # Maybe just do a dry run.
167.2525 +      $opt_dry_run && current_libdirs=" -n$current_libdirs"
167.2526 +      exec_cmd='$SHELL $progpath $preserve_args --finish$current_libdirs'
167.2527 +    else
167.2528 +      exit $EXIT_SUCCESS
167.2529 +    fi
167.2530 +}
167.2531 +
167.2532 +test "$mode" = install && func_mode_install ${1+"$@"}
167.2533 +
167.2534 +
167.2535 +# func_generate_dlsyms outputname originator pic_p
167.2536 +# Extract symbols from dlprefiles and create ${outputname}S.o with
167.2537 +# a dlpreopen symbol table.
167.2538 +func_generate_dlsyms ()
167.2539 +{
167.2540 +    $opt_debug
167.2541 +    my_outputname="$1"
167.2542 +    my_originator="$2"
167.2543 +    my_pic_p="${3-no}"
167.2544 +    my_prefix=`$ECHO "$my_originator" | sed 's%[^a-zA-Z0-9]%_%g'`
167.2545 +    my_dlsyms=
167.2546 +
167.2547 +    if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then
167.2548 +      if test -n "$NM" && test -n "$global_symbol_pipe"; then
167.2549 +	my_dlsyms="${my_outputname}S.c"
167.2550 +      else
167.2551 +	func_error "not configured to extract global symbols from dlpreopened files"
167.2552 +      fi
167.2553 +    fi
167.2554 +
167.2555 +    if test -n "$my_dlsyms"; then
167.2556 +      case $my_dlsyms in
167.2557 +      "") ;;
167.2558 +      *.c)
167.2559 +	# Discover the nlist of each of the dlfiles.
167.2560 +	nlist="$output_objdir/${my_outputname}.nm"
167.2561 +
167.2562 +	func_show_eval "$RM $nlist ${nlist}S ${nlist}T"
167.2563 +
167.2564 +	# Parse the name list into a source file.
167.2565 +	func_verbose "creating $output_objdir/$my_dlsyms"
167.2566 +
167.2567 +	$opt_dry_run || $ECHO > "$output_objdir/$my_dlsyms" "\
167.2568 +/* $my_dlsyms - symbol resolution table for \`$my_outputname' dlsym emulation. */
167.2569 +/* Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION */
167.2570 +
167.2571 +#ifdef __cplusplus
167.2572 +extern \"C\" {
167.2573 +#endif
167.2574 +
167.2575 +#if defined(__GNUC__) && (((__GNUC__ == 4) && (__GNUC_MINOR__ >= 4)) || (__GNUC__ > 4))
167.2576 +#pragma GCC diagnostic ignored \"-Wstrict-prototypes\"
167.2577 +#endif
167.2578 +
167.2579 +/* External symbol declarations for the compiler. */\
167.2580 +"
167.2581 +
167.2582 +	if test "$dlself" = yes; then
167.2583 +	  func_verbose "generating symbol list for \`$output'"
167.2584 +
167.2585 +	  $opt_dry_run || echo ': @PROGRAM@ ' > "$nlist"
167.2586 +
167.2587 +	  # Add our own program objects to the symbol list.
167.2588 +	  progfiles=`$ECHO "$objs$old_deplibs" | $SP2NL | $SED "$lo2o" | $NL2SP`
167.2589 +	  for progfile in $progfiles; do
167.2590 +	    func_verbose "extracting global C symbols from \`$progfile'"
167.2591 +	    $opt_dry_run || eval "$NM $progfile | $global_symbol_pipe >> '$nlist'"
167.2592 +	  done
167.2593 +
167.2594 +	  if test -n "$exclude_expsyms"; then
167.2595 +	    $opt_dry_run || {
167.2596 +	      eval '$EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T'
167.2597 +	      eval '$MV "$nlist"T "$nlist"'
167.2598 +	    }
167.2599 +	  fi
167.2600 +
167.2601 +	  if test -n "$export_symbols_regex"; then
167.2602 +	    $opt_dry_run || {
167.2603 +	      eval '$EGREP -e "$export_symbols_regex" "$nlist" > "$nlist"T'
167.2604 +	      eval '$MV "$nlist"T "$nlist"'
167.2605 +	    }
167.2606 +	  fi
167.2607 +
167.2608 +	  # Prepare the list of exported symbols
167.2609 +	  if test -z "$export_symbols"; then
167.2610 +	    export_symbols="$output_objdir/$outputname.exp"
167.2611 +	    $opt_dry_run || {
167.2612 +	      $RM $export_symbols
167.2613 +	      eval "${SED} -n -e '/^: @PROGRAM@ $/d' -e 's/^.* \(.*\)$/\1/p' "'< "$nlist" > "$export_symbols"'
167.2614 +	      case $host in
167.2615 +	      *cygwin* | *mingw* | *cegcc* )
167.2616 +                eval "echo EXPORTS "'> "$output_objdir/$outputname.def"'
167.2617 +                eval 'cat "$export_symbols" >> "$output_objdir/$outputname.def"'
167.2618 +	        ;;
167.2619 +	      esac
167.2620 +	    }
167.2621 +	  else
167.2622 +	    $opt_dry_run || {
167.2623 +	      eval "${SED} -e 's/\([].[*^$]\)/\\\\\1/g' -e 's/^/ /' -e 's/$/$/'"' < "$export_symbols" > "$output_objdir/$outputname.exp"'
167.2624 +	      eval '$GREP -f "$output_objdir/$outputname.exp" < "$nlist" > "$nlist"T'
167.2625 +	      eval '$MV "$nlist"T "$nlist"'
167.2626 +	      case $host in
167.2627 +	        *cygwin* | *mingw* | *cegcc* )
167.2628 +	          eval "echo EXPORTS "'> "$output_objdir/$outputname.def"'
167.2629 +	          eval 'cat "$nlist" >> "$output_objdir/$outputname.def"'
167.2630 +	          ;;
167.2631 +	      esac
167.2632 +	    }
167.2633 +	  fi
167.2634 +	fi
167.2635 +
167.2636 +	for dlprefile in $dlprefiles; do
167.2637 +	  func_verbose "extracting global C symbols from \`$dlprefile'"
167.2638 +	  func_basename "$dlprefile"
167.2639 +	  name="$func_basename_result"
167.2640 +          case $host in
167.2641 +	    *cygwin* | *mingw* | *cegcc* )
167.2642 +	      # if an import library, we need to obtain dlname
167.2643 +	      if func_win32_import_lib_p "$dlprefile"; then
167.2644 +	        func_tr_sh "$dlprefile"
167.2645 +	        eval "curr_lafile=\$libfile_$func_tr_sh_result"
167.2646 +	        dlprefile_dlbasename=""
167.2647 +	        if test -n "$curr_lafile" && func_lalib_p "$curr_lafile"; then
167.2648 +	          # Use subshell, to avoid clobbering current variable values
167.2649 +	          dlprefile_dlname=`source "$curr_lafile" && echo "$dlname"`
167.2650 +	          if test -n "$dlprefile_dlname" ; then
167.2651 +	            func_basename "$dlprefile_dlname"
167.2652 +	            dlprefile_dlbasename="$func_basename_result"
167.2653 +	          else
167.2654 +	            # no lafile. user explicitly requested -dlpreopen <import library>.
167.2655 +	            eval '$sharedlib_from_linklib "$dlprefile"'
167.2656 +	            dlprefile_dlbasename=$sharedlib_from_linklib_result
167.2657 +	          fi
167.2658 +	        fi
167.2659 +	        $opt_dry_run || {
167.2660 +	          if test -n "$dlprefile_dlbasename" ; then
167.2661 +	            eval '$ECHO ": $dlprefile_dlbasename" >> "$nlist"'
167.2662 +	          else
167.2663 +	            func_warning "Could not compute DLL name from $name"
167.2664 +	            eval '$ECHO ": $name " >> "$nlist"'
167.2665 +	          fi
167.2666 +	          eval "$NM $dlprefile 2>/dev/null | $global_symbol_pipe |
167.2667 +	            $SED -e '/I __imp/d' -e 's/I __nm_/D /;s/_nm__//' >> '$nlist'"
167.2668 +	        }
167.2669 +	      else # not an import lib
167.2670 +	        $opt_dry_run || {
167.2671 +	          eval '$ECHO ": $name " >> "$nlist"'
167.2672 +	          eval "$NM $dlprefile 2>/dev/null | $global_symbol_pipe >> '$nlist'"
167.2673 +	        }
167.2674 +	      fi
167.2675 +	    ;;
167.2676 +	    *)
167.2677 +	      $opt_dry_run || {
167.2678 +	        eval '$ECHO ": $name " >> "$nlist"'
167.2679 +	        eval "$NM $dlprefile 2>/dev/null | $global_symbol_pipe >> '$nlist'"
167.2680 +	      }
167.2681 +	    ;;
167.2682 +          esac
167.2683 +	done
167.2684 +
167.2685 +	$opt_dry_run || {
167.2686 +	  # Make sure we have at least an empty file.
167.2687 +	  test -f "$nlist" || : > "$nlist"
167.2688 +
167.2689 +	  if test -n "$exclude_expsyms"; then
167.2690 +	    $EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T
167.2691 +	    $MV "$nlist"T "$nlist"
167.2692 +	  fi
167.2693 +
167.2694 +	  # Try sorting and uniquifying the output.
167.2695 +	  if $GREP -v "^: " < "$nlist" |
167.2696 +	      if sort -k 3 </dev/null >/dev/null 2>&1; then
167.2697 +		sort -k 3
167.2698 +	      else
167.2699 +		sort +2
167.2700 +	      fi |
167.2701 +	      uniq > "$nlist"S; then
167.2702 +	    :
167.2703 +	  else
167.2704 +	    $GREP -v "^: " < "$nlist" > "$nlist"S
167.2705 +	  fi
167.2706 +
167.2707 +	  if test -f "$nlist"S; then
167.2708 +	    eval "$global_symbol_to_cdecl"' < "$nlist"S >> "$output_objdir/$my_dlsyms"'
167.2709 +	  else
167.2710 +	    echo '/* NONE */' >> "$output_objdir/$my_dlsyms"
167.2711 +	  fi
167.2712 +
167.2713 +	  echo >> "$output_objdir/$my_dlsyms" "\
167.2714 +
167.2715 +/* The mapping between symbol names and symbols.  */
167.2716 +typedef struct {
167.2717 +  const char *name;
167.2718 +  void *address;
167.2719 +} lt_dlsymlist;
167.2720 +"
167.2721 +	  case $host in
167.2722 +	  *cygwin* | *mingw* | *cegcc* )
167.2723 +	    echo >> "$output_objdir/$my_dlsyms" "\
167.2724 +/* DATA imports from DLLs on WIN32 con't be const, because
167.2725 +   runtime relocations are performed -- see ld's documentation
167.2726 +   on pseudo-relocs.  */"
167.2727 +	    lt_dlsym_const= ;;
167.2728 +	  *osf5*)
167.2729 +	    echo >> "$output_objdir/$my_dlsyms" "\
167.2730 +/* This system does not cope well with relocations in const data */"
167.2731 +	    lt_dlsym_const= ;;
167.2732 +	  *)
167.2733 +	    lt_dlsym_const=const ;;
167.2734 +	  esac
167.2735 +
167.2736 +	  echo >> "$output_objdir/$my_dlsyms" "\
167.2737 +extern $lt_dlsym_const lt_dlsymlist
167.2738 +lt_${my_prefix}_LTX_preloaded_symbols[];
167.2739 +$lt_dlsym_const lt_dlsymlist
167.2740 +lt_${my_prefix}_LTX_preloaded_symbols[] =
167.2741 +{\
167.2742 +  { \"$my_originator\", (void *) 0 },"
167.2743 +
167.2744 +	  case $need_lib_prefix in
167.2745 +	  no)
167.2746 +	    eval "$global_symbol_to_c_name_address" < "$nlist" >> "$output_objdir/$my_dlsyms"
167.2747 +	    ;;
167.2748 +	  *)
167.2749 +	    eval "$global_symbol_to_c_name_address_lib_prefix" < "$nlist" >> "$output_objdir/$my_dlsyms"
167.2750 +	    ;;
167.2751 +	  esac
167.2752 +	  echo >> "$output_objdir/$my_dlsyms" "\
167.2753 +  {0, (void *) 0}
167.2754 +};
167.2755 +
167.2756 +/* This works around a problem in FreeBSD linker */
167.2757 +#ifdef FREEBSD_WORKAROUND
167.2758 +static const void *lt_preloaded_setup() {
167.2759 +  return lt_${my_prefix}_LTX_preloaded_symbols;
167.2760 +}
167.2761 +#endif
167.2762 +
167.2763 +#ifdef __cplusplus
167.2764 +}
167.2765 +#endif\
167.2766 +"
167.2767 +	} # !$opt_dry_run
167.2768 +
167.2769 +	pic_flag_for_symtable=
167.2770 +	case "$compile_command " in
167.2771 +	*" -static "*) ;;
167.2772 +	*)
167.2773 +	  case $host in
167.2774 +	  # compiling the symbol table file with pic_flag works around
167.2775 +	  # a FreeBSD bug that causes programs to crash when -lm is
167.2776 +	  # linked before any other PIC object.  But we must not use
167.2777 +	  # pic_flag when linking with -static.  The problem exists in
167.2778 +	  # FreeBSD 2.2.6 and is fixed in FreeBSD 3.1.
167.2779 +	  *-*-freebsd2*|*-*-freebsd3.0*|*-*-freebsdelf3.0*)
167.2780 +	    pic_flag_for_symtable=" $pic_flag -DFREEBSD_WORKAROUND" ;;
167.2781 +	  *-*-hpux*)
167.2782 +	    pic_flag_for_symtable=" $pic_flag"  ;;
167.2783 +	  *)
167.2784 +	    if test "X$my_pic_p" != Xno; then
167.2785 +	      pic_flag_for_symtable=" $pic_flag"
167.2786 +	    fi
167.2787 +	    ;;
167.2788 +	  esac
167.2789 +	  ;;
167.2790 +	esac
167.2791 +	symtab_cflags=
167.2792 +	for arg in $LTCFLAGS; do
167.2793 +	  case $arg in
167.2794 +	  -pie | -fpie | -fPIE) ;;
167.2795 +	  *) symtab_cflags="$symtab_cflags $arg" ;;
167.2796 +	  esac
167.2797 +	done
167.2798 +
167.2799 +	# Now compile the dynamic symbol file.
167.2800 +	func_show_eval '(cd $output_objdir && $LTCC$symtab_cflags -c$no_builtin_flag$pic_flag_for_symtable "$my_dlsyms")' 'exit $?'
167.2801 +
167.2802 +	# Clean up the generated files.
167.2803 +	func_show_eval '$RM "$output_objdir/$my_dlsyms" "$nlist" "${nlist}S" "${nlist}T"'
167.2804 +
167.2805 +	# Transform the symbol file into the correct name.
167.2806 +	symfileobj="$output_objdir/${my_outputname}S.$objext"
167.2807 +	case $host in
167.2808 +	*cygwin* | *mingw* | *cegcc* )
167.2809 +	  if test -f "$output_objdir/$my_outputname.def"; then
167.2810 +	    compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$output_objdir/$my_outputname.def $symfileobj%"`
167.2811 +	    finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$output_objdir/$my_outputname.def $symfileobj%"`
167.2812 +	  else
167.2813 +	    compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$symfileobj%"`
167.2814 +	    finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$symfileobj%"`
167.2815 +	  fi
167.2816 +	  ;;
167.2817 +	*)
167.2818 +	  compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$symfileobj%"`
167.2819 +	  finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$symfileobj%"`
167.2820 +	  ;;
167.2821 +	esac
167.2822 +	;;
167.2823 +      *)
167.2824 +	func_fatal_error "unknown suffix for \`$my_dlsyms'"
167.2825 +	;;
167.2826 +      esac
167.2827 +    else
167.2828 +      # We keep going just in case the user didn't refer to
167.2829 +      # lt_preloaded_symbols.  The linker will fail if global_symbol_pipe
167.2830 +      # really was required.
167.2831 +
167.2832 +      # Nullify the symbol file.
167.2833 +      compile_command=`$ECHO "$compile_command" | $SED "s% @SYMFILE@%%"`
167.2834 +      finalize_command=`$ECHO "$finalize_command" | $SED "s% @SYMFILE@%%"`
167.2835 +    fi
167.2836 +}
167.2837 +
167.2838 +# func_win32_libid arg
167.2839 +# return the library type of file 'arg'
167.2840 +#
167.2841 +# Need a lot of goo to handle *both* DLLs and import libs
167.2842 +# Has to be a shell function in order to 'eat' the argument
167.2843 +# that is supplied when $file_magic_command is called.
167.2844 +# Despite the name, also deal with 64 bit binaries.
167.2845 +func_win32_libid ()
167.2846 +{
167.2847 +  $opt_debug
167.2848 +  win32_libid_type="unknown"
167.2849 +  win32_fileres=`file -L $1 2>/dev/null`
167.2850 +  case $win32_fileres in
167.2851 +  *ar\ archive\ import\ library*) # definitely import
167.2852 +    win32_libid_type="x86 archive import"
167.2853 +    ;;
167.2854 +  *ar\ archive*) # could be an import, or static
167.2855 +    if eval $OBJDUMP -f $1 | $SED -e '10q' 2>/dev/null |
167.2856 +       $EGREP 'file format (pei?-i386(.*architecture: i386)?|pe-arm-wince|pe-x86-64)' >/dev/null; then
167.2857 +      win32_nmres=`eval $NM -f posix -A $1 |
167.2858 +	$SED -n -e '
167.2859 +	    1,100{
167.2860 +		/ I /{
167.2861 +		    s,.*,import,
167.2862 +		    p
167.2863 +		    q
167.2864 +		}
167.2865 +	    }'`
167.2866 +      case $win32_nmres in
167.2867 +      import*)  win32_libid_type="x86 archive import";;
167.2868 +      *)        win32_libid_type="x86 archive static";;
167.2869 +      esac
167.2870 +    fi
167.2871 +    ;;
167.2872 +  *DLL*)
167.2873 +    win32_libid_type="x86 DLL"
167.2874 +    ;;
167.2875 +  *executable*) # but shell scripts are "executable" too...
167.2876 +    case $win32_fileres in
167.2877 +    *MS\ Windows\ PE\ Intel*)
167.2878 +      win32_libid_type="x86 DLL"
167.2879 +      ;;
167.2880 +    esac
167.2881 +    ;;
167.2882 +  esac
167.2883 +  $ECHO "$win32_libid_type"
167.2884 +}
167.2885 +
167.2886 +# func_cygming_dll_for_implib ARG
167.2887 +#
167.2888 +# Platform-specific function to extract the
167.2889 +# name of the DLL associated with the specified
167.2890 +# import library ARG.
167.2891 +# Invoked by eval'ing the libtool variable
167.2892 +#    $sharedlib_from_linklib_cmd
167.2893 +# Result is available in the variable
167.2894 +#    $sharedlib_from_linklib_result
167.2895 +func_cygming_dll_for_implib ()
167.2896 +{
167.2897 +  $opt_debug
167.2898 +  sharedlib_from_linklib_result=`$DLLTOOL --identify-strict --identify "$1"`
167.2899 +}
167.2900 +
167.2901 +# func_cygming_dll_for_implib_core SECTION_NAME LIBNAMEs
167.2902 +#
167.2903 +# The is the core of a fallback implementation of a
167.2904 +# platform-specific function to extract the name of the
167.2905 +# DLL associated with the specified import library LIBNAME.
167.2906 +#
167.2907 +# SECTION_NAME is either .idata$6 or .idata$7, depending
167.2908 +# on the platform and compiler that created the implib.
167.2909 +#
167.2910 +# Echos the name of the DLL associated with the
167.2911 +# specified import library.
167.2912 +func_cygming_dll_for_implib_fallback_core ()
167.2913 +{
167.2914 +  $opt_debug
167.2915 +  $OBJDUMP -s --section "$1" "$2" 2>/dev/null |
167.2916 +    sed '/^Contents of section '"$1"':/{
167.2917 +      # Place marker at beginning of archive member dllname section
167.2918 +      s/.*/====MARK====/
167.2919 +      p
167.2920 +      d
167.2921 +    }
167.2922 +    # These lines can sometimes be longer than 43 characters, but
167.2923 +    # are always uninteresting
167.2924 +    /:[ \t]*file format pe[i]\{,1\}-i386$/d
167.2925 +    /^In archive [^:]*:/d
167.2926 +    # Ensure marker is printed
167.2927 +    /^====MARK====/p
167.2928 +    # Remove all lines with less than 43 characters
167.2929 +    /^.\{43\}/!d
167.2930 +    # From remoaining lines, remove first 43 characters
167.2931 +    s/^.\{43\}//' |
167.2932 +    sed -n '
167.2933 +      # Join marker and all lines until next marker into a single line
167.2934 +      /^====MARK====/ b para
167.2935 +      H
167.2936 +      $ b para
167.2937 +      b
167.2938 +      :para
167.2939 +      x
167.2940 +      s/\n//g
167.2941 +      # Remove the marker
167.2942 +      s/^====MARK====//
167.2943 +      # Remove trailing dots and whitespace
167.2944 +      s/[\. \t]*$//
167.2945 +      # Print
167.2946 +      /./p
167.2947 +      ' |
167.2948 +    # we now have a list, one entry per line, of the stringified
167.2949 +    # contents of the appropriate section of all members of the
167.2950 +    # archive which possess that section. Heuristic: eliminate
167.2951 +    # all those which have a first or second character that is
167.2952 +    # a '.' (that is, objdump's representation of an unprintable
167.2953 +    # character.) This should work for all archives with less than
167.2954 +    # 0x302f exports -- but will fail for DLLs whose name actually
167.2955 +    # begins with a literal '.' or a single character followed by
167.2956 +    # a '.'.
167.2957 +    #
167.2958 +    # Of those that remain, print the first one.
167.2959 +    sed -e '/^\./d' -e '/^.\./d' | sed -n -e '1p'
167.2960 +}
167.2961 +
167.2962 +# func_cygming_gnu_implib_p ARG
167.2963 +# This predicate returns with zero status (TRUE) if
167.2964 +# ARG is a GNU/binutils-style import library. Returns
167.2965 +# with nonzero status (FALSE) otherwise.
167.2966 +func_cygming_gnu_implib_p ()
167.2967 +{
167.2968 +  $opt_debug
167.2969 +  func_cygming_gnu_implib_tmp=`eval "\$NM \$1 | \$global_symbol_pipe | \$EGREP ' (_head_[A-Za-z0-9_]+_dll|[A-Za-z0-9_]+_dll_iname)\\\$'"`
167.2970 +  test -n "$func_cygming_gnu_implib_tmp"
167.2971 +}
167.2972 +
167.2973 +# func_cygming_ms_implib_p ARG
167.2974 +# This predicate returns with zero status (TRUE) if
167.2975 +# ARG is an MS-style import library. Returns
167.2976 +# with nonzero status (FALSE) otherwise.
167.2977 +func_cygming_ms_implib_p ()
167.2978 +{
167.2979 +  $opt_debug
167.2980 +  func_cygming_ms_implib_tmp=`eval "\$NM \$1 | \$global_symbol_pipe | grep '_NULL_IMPORT_DESCRIPTOR'"`
167.2981 +  test -n "$func_cygming_ms_implib_tmp"
167.2982 +}
167.2983 +
167.2984 +# func_cygming_dll_for_implib_fallback ARG
167.2985 +# Platform-specific function to extract the
167.2986 +# name of the DLL associated with the specified
167.2987 +# import library ARG.
167.2988 +#
167.2989 +# This fallback implementation is for use when $DLLTOOL
167.2990 +# does not support the --identify-strict option.
167.2991 +# Invoked by eval'ing the libtool variable
167.2992 +#    $sharedlib_from_linklib_cmd
167.2993 +# Result is available in the variable
167.2994 +#    $sharedlib_from_linklib_result
167.2995 +func_cygming_dll_for_implib_fallback ()
167.2996 +{
167.2997 +  $opt_debug
167.2998 +  if func_cygming_gnu_implib_p "$1" ; then
167.2999 +    # binutils import library
167.3000 +    sharedlib_from_linklib_result=`func_cygming_dll_for_implib_fallback_core '.idata$7' "$1"`
167.3001 +  elif func_cygming_ms_implib_p "$1" ; then
167.3002 +    # ms-generated import library
167.3003 +    sharedlib_from_linklib_result=`func_cygming_dll_for_implib_fallback_core '.idata$6' "$1"`
167.3004 +  else
167.3005 +    # unknown
167.3006 +    sharedlib_from_linklib_result=""
167.3007 +  fi
167.3008 +}
167.3009 +
167.3010 +
167.3011 +# func_extract_an_archive dir oldlib
167.3012 +func_extract_an_archive ()
167.3013 +{
167.3014 +    $opt_debug
167.3015 +    f_ex_an_ar_dir="$1"; shift
167.3016 +    f_ex_an_ar_oldlib="$1"
167.3017 +    if test "$lock_old_archive_extraction" = yes; then
167.3018 +      lockfile=$f_ex_an_ar_oldlib.lock
167.3019 +      until $opt_dry_run || ln "$progpath" "$lockfile" 2>/dev/null; do
167.3020 +	func_echo "Waiting for $lockfile to be removed"
167.3021 +	sleep 2
167.3022 +      done
167.3023 +    fi
167.3024 +    func_show_eval "(cd \$f_ex_an_ar_dir && $AR x \"\$f_ex_an_ar_oldlib\")" \
167.3025 +		   'stat=$?; rm -f "$lockfile"; exit $stat'
167.3026 +    if test "$lock_old_archive_extraction" = yes; then
167.3027 +      $opt_dry_run || rm -f "$lockfile"
167.3028 +    fi
167.3029 +    if ($AR t "$f_ex_an_ar_oldlib" | sort | sort -uc >/dev/null 2>&1); then
167.3030 +     :
167.3031 +    else
167.3032 +      func_fatal_error "object name conflicts in archive: $f_ex_an_ar_dir/$f_ex_an_ar_oldlib"
167.3033 +    fi
167.3034 +}
167.3035 +
167.3036 +
167.3037 +# func_extract_archives gentop oldlib ...
167.3038 +func_extract_archives ()
167.3039 +{
167.3040 +    $opt_debug
167.3041 +    my_gentop="$1"; shift
167.3042 +    my_oldlibs=${1+"$@"}
167.3043 +    my_oldobjs=""
167.3044 +    my_xlib=""
167.3045 +    my_xabs=""
167.3046 +    my_xdir=""
167.3047 +
167.3048 +    for my_xlib in $my_oldlibs; do
167.3049 +      # Extract the objects.
167.3050 +      case $my_xlib in
167.3051 +	[\\/]* | [A-Za-z]:[\\/]*) my_xabs="$my_xlib" ;;
167.3052 +	*) my_xabs=`pwd`"/$my_xlib" ;;
167.3053 +      esac
167.3054 +      func_basename "$my_xlib"
167.3055 +      my_xlib="$func_basename_result"
167.3056 +      my_xlib_u=$my_xlib
167.3057 +      while :; do
167.3058 +        case " $extracted_archives " in
167.3059 +	*" $my_xlib_u "*)
167.3060 +	  func_arith $extracted_serial + 1
167.3061 +	  extracted_serial=$func_arith_result
167.3062 +	  my_xlib_u=lt$extracted_serial-$my_xlib ;;
167.3063 +	*) break ;;
167.3064 +	esac
167.3065 +      done
167.3066 +      extracted_archives="$extracted_archives $my_xlib_u"
167.3067 +      my_xdir="$my_gentop/$my_xlib_u"
167.3068 +
167.3069 +      func_mkdir_p "$my_xdir"
167.3070 +
167.3071 +      case $host in
167.3072 +      *-darwin*)
167.3073 +	func_verbose "Extracting $my_xabs"
167.3074 +	# Do not bother doing anything if just a dry run
167.3075 +	$opt_dry_run || {
167.3076 +	  darwin_orig_dir=`pwd`
167.3077 +	  cd $my_xdir || exit $?
167.3078 +	  darwin_archive=$my_xabs
167.3079 +	  darwin_curdir=`pwd`
167.3080 +	  darwin_base_archive=`basename "$darwin_archive"`
167.3081 +	  darwin_arches=`$LIPO -info "$darwin_archive" 2>/dev/null | $GREP Architectures 2>/dev/null || true`
167.3082 +	  if test -n "$darwin_arches"; then
167.3083 +	    darwin_arches=`$ECHO "$darwin_arches" | $SED -e 's/.*are://'`
167.3084 +	    darwin_arch=
167.3085 +	    func_verbose "$darwin_base_archive has multiple architectures $darwin_arches"
167.3086 +	    for darwin_arch in  $darwin_arches ; do
167.3087 +	      func_mkdir_p "unfat-$$/${darwin_base_archive}-${darwin_arch}"
167.3088 +	      $LIPO -thin $darwin_arch -output "unfat-$$/${darwin_base_archive}-${darwin_arch}/${darwin_base_archive}" "${darwin_archive}"
167.3089 +	      cd "unfat-$$/${darwin_base_archive}-${darwin_arch}"
167.3090 +	      func_extract_an_archive "`pwd`" "${darwin_base_archive}"
167.3091 +	      cd "$darwin_curdir"
167.3092 +	      $RM "unfat-$$/${darwin_base_archive}-${darwin_arch}/${darwin_base_archive}"
167.3093 +	    done # $darwin_arches
167.3094 +            ## Okay now we've a bunch of thin objects, gotta fatten them up :)
167.3095 +	    darwin_filelist=`find unfat-$$ -type f -name \*.o -print -o -name \*.lo -print | $SED -e "$basename" | sort -u`
167.3096 +	    darwin_file=
167.3097 +	    darwin_files=
167.3098 +	    for darwin_file in $darwin_filelist; do
167.3099 +	      darwin_files=`find unfat-$$ -name $darwin_file -print | $NL2SP`
167.3100 +	      $LIPO -create -output "$darwin_file" $darwin_files
167.3101 +	    done # $darwin_filelist
167.3102 +	    $RM -rf unfat-$$
167.3103 +	    cd "$darwin_orig_dir"
167.3104 +	  else
167.3105 +	    cd $darwin_orig_dir
167.3106 +	    func_extract_an_archive "$my_xdir" "$my_xabs"
167.3107 +	  fi # $darwin_arches
167.3108 +	} # !$opt_dry_run
167.3109 +	;;
167.3110 +      *)
167.3111 +        func_extract_an_archive "$my_xdir" "$my_xabs"
167.3112 +	;;
167.3113 +      esac
167.3114 +      my_oldobjs="$my_oldobjs "`find $my_xdir -name \*.$objext -print -o -name \*.lo -print | $NL2SP`
167.3115 +    done
167.3116 +
167.3117 +    func_extract_archives_result="$my_oldobjs"
167.3118 +}
167.3119 +
167.3120 +
167.3121 +# func_emit_wrapper [arg=no]
167.3122 +#
167.3123 +# Emit a libtool wrapper script on stdout.
167.3124 +# Don't directly open a file because we may want to
167.3125 +# incorporate the script contents within a cygwin/mingw
167.3126 +# wrapper executable.  Must ONLY be called from within
167.3127 +# func_mode_link because it depends on a number of variables
167.3128 +# set therein.
167.3129 +#
167.3130 +# ARG is the value that the WRAPPER_SCRIPT_BELONGS_IN_OBJDIR
167.3131 +# variable will take.  If 'yes', then the emitted script
167.3132 +# will assume that the directory in which it is stored is
167.3133 +# the $objdir directory.  This is a cygwin/mingw-specific
167.3134 +# behavior.
167.3135 +func_emit_wrapper ()
167.3136 +{
167.3137 +	func_emit_wrapper_arg1=${1-no}
167.3138 +
167.3139 +	$ECHO "\
167.3140 +#! $SHELL
167.3141 +
167.3142 +# $output - temporary wrapper script for $objdir/$outputname
167.3143 +# Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION
167.3144 +#
167.3145 +# The $output program cannot be directly executed until all the libtool
167.3146 +# libraries that it depends on are installed.
167.3147 +#
167.3148 +# This wrapper script should never be moved out of the build directory.
167.3149 +# If it is, it will not operate correctly.
167.3150 +
167.3151 +# Sed substitution that helps us do robust quoting.  It backslashifies
167.3152 +# metacharacters that are still active within double-quoted strings.
167.3153 +sed_quote_subst='$sed_quote_subst'
167.3154 +
167.3155 +# Be Bourne compatible
167.3156 +if test -n \"\${ZSH_VERSION+set}\" && (emulate sh) >/dev/null 2>&1; then
167.3157 +  emulate sh
167.3158 +  NULLCMD=:
167.3159 +  # Zsh 3.x and 4.x performs word splitting on \${1+\"\$@\"}, which
167.3160 +  # is contrary to our usage.  Disable this feature.
167.3161 +  alias -g '\${1+\"\$@\"}'='\"\$@\"'
167.3162 +  setopt NO_GLOB_SUBST
167.3163 +else
167.3164 +  case \`(set -o) 2>/dev/null\` in *posix*) set -o posix;; esac
167.3165 +fi
167.3166 +BIN_SH=xpg4; export BIN_SH # for Tru64
167.3167 +DUALCASE=1; export DUALCASE # for MKS sh
167.3168 +
167.3169 +# The HP-UX ksh and POSIX shell print the target directory to stdout
167.3170 +# if CDPATH is set.
167.3171 +(unset CDPATH) >/dev/null 2>&1 && unset CDPATH
167.3172 +
167.3173 +relink_command=\"$relink_command\"
167.3174 +
167.3175 +# This environment variable determines our operation mode.
167.3176 +if test \"\$libtool_install_magic\" = \"$magic\"; then
167.3177 +  # install mode needs the following variables:
167.3178 +  generated_by_libtool_version='$macro_version'
167.3179 +  notinst_deplibs='$notinst_deplibs'
167.3180 +else
167.3181 +  # When we are sourced in execute mode, \$file and \$ECHO are already set.
167.3182 +  if test \"\$libtool_execute_magic\" != \"$magic\"; then
167.3183 +    file=\"\$0\""
167.3184 +
167.3185 +    qECHO=`$ECHO "$ECHO" | $SED "$sed_quote_subst"`
167.3186 +    $ECHO "\
167.3187 +
167.3188 +# A function that is used when there is no print builtin or printf.
167.3189 +func_fallback_echo ()
167.3190 +{
167.3191 +  eval 'cat <<_LTECHO_EOF
167.3192 +\$1
167.3193 +_LTECHO_EOF'
167.3194 +}
167.3195 +    ECHO=\"$qECHO\"
167.3196 +  fi
167.3197 +
167.3198 +# Very basic option parsing. These options are (a) specific to
167.3199 +# the libtool wrapper, (b) are identical between the wrapper
167.3200 +# /script/ and the wrapper /executable/ which is used only on
167.3201 +# windows platforms, and (c) all exist in the "--lt-" namespace
167.3202 +# (application programs are unlikely to have options which match
167.3203 +# this pattern).
167.3204 +#
167.3205 +# There are only two supported options: --lt-debug and
167.3206 +# --lt-dump-script. There is, deliberately, no --lt-help.
167.3207 +#
167.3208 +# The first argument to this parsing function should be the
167.3209 +# script's $0 value, followed by "$@".
167.3210 +lt_option_debug=
167.3211 +func_parse_lt_options ()
167.3212 +{
167.3213 +  lt_script_arg0=\$0
167.3214 +  shift
167.3215 +  for lt_opt
167.3216 +  do
167.3217 +    case \"\$lt_opt\" in
167.3218 +    --lt-debug) lt_option_debug=1 ;;
167.3219 +    --lt-dump-script)
167.3220 +        lt_dump_D=\`\$ECHO \"X\$lt_script_arg0\" | $SED -e 's/^X//' -e 's%/[^/]*$%%'\`
167.3221 +        test \"X\$lt_dump_D\" = \"X\$lt_script_arg0\" && lt_dump_D=.
167.3222 +        lt_dump_F=\`\$ECHO \"X\$lt_script_arg0\" | $SED -e 's/^X//' -e 's%^.*/%%'\`
167.3223 +        cat \"\$lt_dump_D/\$lt_dump_F\"
167.3224 +        exit 0
167.3225 +      ;;
167.3226 +    --lt-*)
167.3227 +        \$ECHO \"Unrecognized --lt- option: '\$lt_opt'\" 1>&2
167.3228 +        exit 1
167.3229 +      ;;
167.3230 +    esac
167.3231 +  done
167.3232 +}
167.3233 +
167.3234 +# Sets opts_contain_lt_result to \"yes\" if the
167.3235 +# supplied arguments contain any elements in the
167.3236 +# --lt-* namespace. Empty otherwise.
167.3237 +opts_contain_lt_result=
167.3238 +func_opts_contain_lt ()
167.3239 +{
167.3240 +  opts_contain_lt_result=
167.3241 +  for lt_option
167.3242 +  do
167.3243 +    case \"\$lt_option\" in
167.3244 +    --lt-*) opts_contain_lt_result=yes
167.3245 +            break ;;
167.3246 +    *) ;;
167.3247 +    esac
167.3248 +  done
167.3249 +}
167.3250 +
167.3251 +# Used when --lt-debug. Prints its arguments to stdout
167.3252 +# (redirection is the responsibility of the caller)
167.3253 +func_lt_dump_args ()
167.3254 +{
167.3255 +  lt_dump_args_N=1;
167.3256 +  for lt_arg
167.3257 +  do
167.3258 +    \$ECHO \"(main) newargz[\$lt_dump_args_N]   : \$lt_arg\"
167.3259 +    lt_dump_args_N=\`expr \$lt_dump_args_N + 1\`
167.3260 +  done
167.3261 +}
167.3262 +
167.3263 +# Core function for launching the target application
167.3264 +func_exec_program_core ()
167.3265 +{
167.3266 +"
167.3267 +  case $host in
167.3268 +  # Backslashes separate directories on plain windows
167.3269 +  *-*-mingw | *-*-os2* | *-cegcc*)
167.3270 +    $ECHO "\
167.3271 +      if test -n \"\$lt_option_debug\"; then
167.3272 +        \$ECHO \"(main) lt_argv_zero : \$progdir\\\\\$program\" 1>&2
167.3273 +        func_lt_dump_args \${1+\"\$@\"} 1>&2
167.3274 +      fi
167.3275 +      exec \"\$progdir\\\\\$program\" \${1+\"\$@\"}
167.3276 +"
167.3277 +    ;;
167.3278 +
167.3279 +  *)
167.3280 +    $ECHO "\
167.3281 +      if test -n \"\$lt_option_debug\"; then
167.3282 +        \$ECHO \"(main) lt_argv_zero : \$progdir/\$program\" 1>&2
167.3283 +        func_lt_dump_args \${1+\"\$@\"} 1>&2
167.3284 +      fi
167.3285 +      exec \"\$progdir/\$program\" \${1+\"\$@\"}
167.3286 +"
167.3287 +    ;;
167.3288 +  esac
167.3289 +  $ECHO "\
167.3290 +      \$ECHO \"\$0: cannot exec \$program \$*\" 1>&2
167.3291 +      exit 1
167.3292 +}
167.3293 +
167.3294 +# A function to encapsulate launching the target application
167.3295 +# Strips options in the --lt-* namespace from \$@ and
167.3296 +# launches target application with the remaining arguments.
167.3297 +func_exec_program ()
167.3298 +{
167.3299 +  func_opts_contain_lt \${1+\"\$@\"}
167.3300 +  if test -n \"\$opts_contain_lt_result\"; then
167.3301 +    # the following is adapted from _AC_INIT_PREPARE, except
167.3302 +    # (1) we don't care about duplicates, and
167.3303 +    # (2) we strip out --lt-*, not --no-create/--no-recursion/--silent
167.3304 +    lt_wrapper_args=
167.3305 +    for lt_wr_arg
167.3306 +    do
167.3307 +      case \$lt_wr_arg in
167.3308 +      --lt-*) continue ;;
167.3309 +      *\\'*)
167.3310 +        lt_wr_arg=\`\$ECHO \"X\$lt_wr_arg\" |
167.3311 +          $SED -e \"s/^X//\" -e \"s/'/'\\\\\\\\\\\\\\\\''/g\"\`
167.3312 +        ;;
167.3313 +      esac
167.3314 +      lt_wrapper_args=\"\$lt_wrapper_args '\$lt_wr_arg'\"
167.3315 +    done
167.3316 +    eval func_exec_program_core \$lt_wrapper_args
167.3317 +  else
167.3318 +    func_exec_program_core \${1+\"\$@\"}
167.3319 +  fi
167.3320 +}
167.3321 +
167.3322 +  # Parse options
167.3323 +  func_parse_lt_options \"\$0\" \${1+\"\$@\"}
167.3324 +
167.3325 +  # Find the directory that this script lives in.
167.3326 +  thisdir=\`\$ECHO \"\$file\" | $SED 's%/[^/]*$%%'\`
167.3327 +  test \"x\$thisdir\" = \"x\$file\" && thisdir=.
167.3328 +
167.3329 +  # Follow symbolic links until we get to the real thisdir.
167.3330 +  file=\`ls -ld \"\$file\" | $SED -n 's/.*-> //p'\`
167.3331 +  while test -n \"\$file\"; do
167.3332 +    destdir=\`\$ECHO \"\$file\" | $SED 's%/[^/]*\$%%'\`
167.3333 +
167.3334 +    # If there was a directory component, then change thisdir.
167.3335 +    if test \"x\$destdir\" != \"x\$file\"; then
167.3336 +      case \"\$destdir\" in
167.3337 +      [\\\\/]* | [A-Za-z]:[\\\\/]*) thisdir=\"\$destdir\" ;;
167.3338 +      *) thisdir=\"\$thisdir/\$destdir\" ;;
167.3339 +      esac
167.3340 +    fi
167.3341 +
167.3342 +    file=\`\$ECHO \"\$file\" | $SED 's%^.*/%%'\`
167.3343 +    file=\`ls -ld \"\$thisdir/\$file\" | $SED -n 's/.*-> //p'\`
167.3344 +  done
167.3345 +
167.3346 +  # Usually 'no', except on cygwin/mingw when embedded into
167.3347 +  # the cwrapper.
167.3348 +  WRAPPER_SCRIPT_BELONGS_IN_OBJDIR=$func_emit_wrapper_arg1
167.3349 +  if test \"\$WRAPPER_SCRIPT_BELONGS_IN_OBJDIR\" = \"yes\"; then
167.3350 +    # special case for '.'
167.3351 +    if test \"\$thisdir\" = \".\"; then
167.3352 +      thisdir=\`pwd\`
167.3353 +    fi
167.3354 +    # remove .libs from thisdir
167.3355 +    case \"\$thisdir\" in
167.3356 +    *[\\\\/]$objdir ) thisdir=\`\$ECHO \"\$thisdir\" | $SED 's%[\\\\/][^\\\\/]*$%%'\` ;;
167.3357 +    $objdir )   thisdir=. ;;
167.3358 +    esac
167.3359 +  fi
167.3360 +
167.3361 +  # Try to get the absolute directory name.
167.3362 +  absdir=\`cd \"\$thisdir\" && pwd\`
167.3363 +  test -n \"\$absdir\" && thisdir=\"\$absdir\"
167.3364 +"
167.3365 +
167.3366 +	if test "$fast_install" = yes; then
167.3367 +	  $ECHO "\
167.3368 +  program=lt-'$outputname'$exeext
167.3369 +  progdir=\"\$thisdir/$objdir\"
167.3370 +
167.3371 +  if test ! -f \"\$progdir/\$program\" ||
167.3372 +     { file=\`ls -1dt \"\$progdir/\$program\" \"\$progdir/../\$program\" 2>/dev/null | ${SED} 1q\`; \\
167.3373 +       test \"X\$file\" != \"X\$progdir/\$program\"; }; then
167.3374 +
167.3375 +    file=\"\$\$-\$program\"
167.3376 +
167.3377 +    if test ! -d \"\$progdir\"; then
167.3378 +      $MKDIR \"\$progdir\"
167.3379 +    else
167.3380 +      $RM \"\$progdir/\$file\"
167.3381 +    fi"
167.3382 +
167.3383 +	  $ECHO "\
167.3384 +
167.3385 +    # relink executable if necessary
167.3386 +    if test -n \"\$relink_command\"; then
167.3387 +      if relink_command_output=\`eval \$relink_command 2>&1\`; then :
167.3388 +      else
167.3389 +	$ECHO \"\$relink_command_output\" >&2
167.3390 +	$RM \"\$progdir/\$file\"
167.3391 +	exit 1
167.3392 +      fi
167.3393 +    fi
167.3394 +
167.3395 +    $MV \"\$progdir/\$file\" \"\$progdir/\$program\" 2>/dev/null ||
167.3396 +    { $RM \"\$progdir/\$program\";
167.3397 +      $MV \"\$progdir/\$file\" \"\$progdir/\$program\"; }
167.3398 +    $RM \"\$progdir/\$file\"
167.3399 +  fi"
167.3400 +	else
167.3401 +	  $ECHO "\
167.3402 +  program='$outputname'
167.3403 +  progdir=\"\$thisdir/$objdir\"
167.3404 +"
167.3405 +	fi
167.3406 +
167.3407 +	$ECHO "\
167.3408 +
167.3409 +  if test -f \"\$progdir/\$program\"; then"
167.3410 +
167.3411 +	# Export our shlibpath_var if we have one.
167.3412 +	if test "$shlibpath_overrides_runpath" = yes && test -n "$shlibpath_var" && test -n "$temp_rpath"; then
167.3413 +	  $ECHO "\
167.3414 +    # Add our own library path to $shlibpath_var
167.3415 +    $shlibpath_var=\"$temp_rpath\$$shlibpath_var\"
167.3416 +
167.3417 +    # Some systems cannot cope with colon-terminated $shlibpath_var
167.3418 +    # The second colon is a workaround for a bug in BeOS R4 sed
167.3419 +    $shlibpath_var=\`\$ECHO \"\$$shlibpath_var\" | $SED 's/::*\$//'\`
167.3420 +
167.3421 +    export $shlibpath_var
167.3422 +"
167.3423 +	fi
167.3424 +
167.3425 +	# fixup the dll searchpath if we need to.
167.3426 +	if test -n "$dllsearchpath"; then
167.3427 +	  $ECHO "\
167.3428 +    # Add the dll search path components to the executable PATH
167.3429 +    PATH=$dllsearchpath:\$PATH
167.3430 +"
167.3431 +	fi
167.3432 +
167.3433 +	$ECHO "\
167.3434 +    if test \"\$libtool_execute_magic\" != \"$magic\"; then
167.3435 +      # Run the actual program with our arguments.
167.3436 +      func_exec_program \${1+\"\$@\"}
167.3437 +    fi
167.3438 +  else
167.3439 +    # The program doesn't exist.
167.3440 +    \$ECHO \"\$0: error: \\\`\$progdir/\$program' does not exist\" 1>&2
167.3441 +    \$ECHO \"This script is just a wrapper for \$program.\" 1>&2
167.3442 +    \$ECHO \"See the $PACKAGE documentation for more information.\" 1>&2
167.3443 +    exit 1
167.3444 +  fi
167.3445 +fi\
167.3446 +"
167.3447 +}
167.3448 +
167.3449 +####################################
167.3450 +# PATH CONVERSION HELPER FUNCTIONS #
167.3451 +####################################
167.3452 +
167.3453 +# func_wine_to_win32_path ARG
167.3454 +# Helper function used by path conversion functions
167.3455 +# when $build is *nix, and $host is mingw, cygwin,
167.3456 +# or some other win32 environment. Relies on a
167.3457 +# correctly configured wine environment available,
167.3458 +# with the winepath program in $build's $PATH.
167.3459 +#
167.3460 +# ARG is the $build path to be converted to win32 format.
167.3461 +# result is available in $func_wine_to_win32_path_result
167.3462 +# result is empty on error (or when arg is empty)
167.3463 +func_wine_to_win32_path ()
167.3464 +{
167.3465 +  $opt_debug
167.3466 +  lt_sed_naive_backslashify='s|\\\\*|\\|g;s|/|\\|g;s|\\|\\\\|g'
167.3467 +  func_wine_to_win32_path_result="$1"
167.3468 +  if test -n "$1"; then
167.3469 +    # Unfortunately, winepath does not exit with a non-zero
167.3470 +    # error code, so we are forced to check the contents of
167.3471 +    # stdout. On the other hand, if the command is not
167.3472 +    # found, the shell will set an exit code of 127 and print
167.3473 +    # *an error message* to stdout. So we must check for both
167.3474 +    # error code of zero AND non-empty stdout, which explains
167.3475 +    # the odd construction:
167.3476 +    func_to_host_path_tmp1=`winepath -w "$1" 2>/dev/null`
167.3477 +    if test "$?" -eq 0 && test -n "${func_wine_to_win32_path_tmp}"; then
167.3478 +      func_to_host_path_result=`$ECHO "$func_wine_to_win32_path_tmp" |
167.3479 +        $SED -e "$lt_sed_naive_backslashify"`
167.3480 +    else
167.3481 +      func_wine_to_win32_path_result=
167.3482 +    fi
167.3483 +  fi
167.3484 +}
167.3485 +# end: func_wine_to_win32_path
167.3486 +
167.3487 +
167.3488 +# func_wine_to_win32_pathlist ARG
167.3489 +# Helper function used by path conversion functions
167.3490 +# when $build is *nix, and $host is mingw, cygwin,
167.3491 +# or some other win32 environment. Relies on a
167.3492 +# correctly configured wine environment available,
167.3493 +# with the winepath program in $build's $PATH.
167.3494 +# Assumes ARG has no leading or trailing path separator
167.3495 +# characters.
167.3496 +#
167.3497 +# ARG is pathlist to be converted from $build format to win32.
167.3498 +# Result is available in $func_wine_to_win32_pathlist_result
167.3499 +# Unconvertible paths in pathlist are skipped; if no paths
167.3500 +# are convertible, result may be empty.
167.3501 +func_wine_to_win32_pathlist ()
167.3502 +{
167.3503 +  $opt_debug
167.3504 +  # unfortunately, winepath doesn't convert pathlists
167.3505 +  func_wine_to_win32_pathlist_result=""
167.3506 +  if test -n "$1"; then
167.3507 +    func_wine_to_win32_pathlist_oldIFS=$IFS
167.3508 +    IFS=:
167.3509 +    for func_wine_to_win32_pathlist_f in $1; do
167.3510 +      IFS=$func_wine_to_win32_pathlist_oldIFS
167.3511 +      if test -n "$func_wine_to_win32_pathlist_f" ; then
167.3512 +        func_wine_to_win32_path "$func_wine_to_win32_pathlist_f"
167.3513 +        if test -n "$func_wine_to_win32_path_result" ; then
167.3514 +          if test -z "$func_wine_to_win32_pathlist_result"; then
167.3515 +            func_wine_to_win32_pathlist_result="$func_wine_to_win32_path_result"
167.3516 +          else
167.3517 +            func_append func_wine_to_win32_pathlist_result ";$func_wine_to_win32_path_result"
167.3518 +          fi
167.3519 +        fi
167.3520 +      fi
167.3521 +    done
167.3522 +    IFS=$func_wine_to_win32_pathlist_oldIFS
167.3523 +  fi
167.3524 +}
167.3525 +# end: func_wine_to_win32_pathlist
167.3526 +
167.3527 +
167.3528 +# func_cygpath ARGS...
167.3529 +# a wrapper around calling the cygpath program via
167.3530 +# LT_CYGPATH, when $host is *nix and cygwin is
167.3531 +# hosted via a wine environment (or, rarely, when
167.3532 +# host is mingw -- that is, msys).
167.3533 +#
167.3534 +# Result is available in func_cygpath_result, which
167.3535 +# may be empty on error. Can accomodate both paths
167.3536 +# and pathlists (with appropriate options).
167.3537 +#
167.3538 +# ARGS are the typical arguments and options for
167.3539 +# the cygpath program. Usually, the last argument
167.3540 +# is the path or pathlist to be converted.
167.3541 +#
167.3542 +# The full *nix (or msys) path to the cygpath program must be
167.3543 +# specified in the LT_CYGPATH environment variable. This
167.3544 +# is because (a) the cygpath program shouldn't be in $PATH,
167.3545 +# because it usually lives in cygwin's bin/ directory --
167.3546 +# along with *cygwin* versions of sed, id, cp. If the *nix (or
167.3547 +# msys) host environment had those programs in its $PATH, many
167.3548 +# bad things could happen. (b) especially in cygwin-1.7, multiple
167.3549 +# installations (with separate "mount tables" in
167.3550 +# <CYGROOT-N>/etc/fstab) can coexist on the same Win32
167.3551 +# instance. The cygpath.exe for cygwin installation #N in
167.3552 +# <CYGROOT-N>/bin automatically deduces the appropriate
167.3553 +# ../etc/fstab file. Therefore, it matters which cygpath.exe
167.3554 +# is used. LT_CYGPATH may be replaced or supplemented by an
167.3555 +# LT_INIT-activated configure option in the future.
167.3556 +func_cygpath ()
167.3557 +{
167.3558 +  $opt_debug
167.3559 +  if test -n "$LT_CYGPATH" && test -f "$LT_CYGPATH"; then
167.3560 +    func_cygpath_result=`$LT_CYGPATH "$@" 2>/dev/null`
167.3561 +    if test "$?" -ne 0; then
167.3562 +      # on failure, ensure result is empty
167.3563 +      func_cygpath_result=
167.3564 +    fi
167.3565 +  else
167.3566 +    func_cygpath_result=
167.3567 +    func_error "LT_CYGPATH is empty or specifies non-existant file: \`$LT_CYGPATH'"
167.3568 +  fi
167.3569 +}
167.3570 +#end: func_cygpath
167.3571 +
167.3572 +
167.3573 +# func_msys_to_win32 ARG
167.3574 +# Converts ARG from msys (unix-ish) format to
167.3575 +# win32 format. Can accomodate both paths and pathlists.
167.3576 +# Result is available in func_msys_to_win32_result.
167.3577 +func_msys_to_win32 ()
167.3578 +{
167.3579 +  $opt_debug
167.3580 +  lt_sed_naive_backslashify='s|\\\\*|\\|g;s|/|\\|g;s|\\|\\\\|g'
167.3581 +  # awkward: cmd appends spaces to result
167.3582 +  func_msys_to_win32_result=`( cmd //c echo "$1" ) 2>/dev/null |
167.3583 +    $SED -e 's/[ ]*$//' -e "$lt_sed_naive_backslashify"`
167.3584 +}
167.3585 +#end: func_msys_to_win32
167.3586 +
167.3587 +
167.3588 +# func_path_convert_check ARG1 ARG2
167.3589 +# Verify that ARG1 (a path in $build format) was
167.3590 +# converted to $host format in ARG2. Otherwise, emit
167.3591 +# an error message, but continue (resetting
167.3592 +# func_to_host_path_result to ARG1).
167.3593 +func_path_convert_check ()
167.3594 +{
167.3595 +  $opt_debug
167.3596 +  if test -z "$2" && test -n "$1" ; then
167.3597 +    func_error "Could not determine host path corresponding to"
167.3598 +    func_error "  \`$1'"
167.3599 +    func_error "Continuing, but uninstalled executables may not work."
167.3600 +    # Fallback:
167.3601 +    func_to_host_path_result="$1"
167.3602 +  fi
167.3603 +}
167.3604 +# end func_path_convert_check
167.3605 +
167.3606 +
167.3607 +# func_pathlist_convert_check FROM_PATHSEP TO_PATHSEP FROM_PATHLIST TO_PATHLIST
167.3608 +# Verify that FROM_PATHLIST (a path in $build format) was converted
167.3609 +# $host format in TO_PATHLIST. Otherwise, emit an error message, but
167.3610 +# continue, resetting func_to_host_path_result to a simplistic
167.3611 +# fallback value (see below).
167.3612 +func_pathlist_convert_check ()
167.3613 +{
167.3614 +  $opt_debug
167.3615 +  if test -z "$4" && test -n "$3"; then
167.3616 +    func_error "Could not determine the host path(s) corresponding to"
167.3617 +    func_error "  \`$3'"
167.3618 +    func_error "Continuing, but uninstalled executables may not work."
167.3619 +    # Fallback. If even this fallback fails, the fix is not to
167.3620 +    # complicate the expression below, but for the user to provide,
167.3621 +    # in that situation, whatever elements are missing from the
167.3622 +    # environment so that the actual pathlist conversion functions
167.3623 +    # work properly (for instance, a working wine installation
167.3624 +    # with winepath so that path translation in the cross-to-mingw
167.3625 +    # case works).
167.3626 +    if test "x$1" != "x$2"; then
167.3627 +      lt_replace_pathsep_chars="s|$1|$2|g"
167.3628 +      func_to_host_pathlist_result=`echo "$3" |\
167.3629 +        $SED -e "$lt_replace_pathsep_chars"`
167.3630 +    else
167.3631 +      func_to_host_pathlist_result="$3"
167.3632 +    fi
167.3633 +  fi
167.3634 +}
167.3635 +# end func_pathlist_convert_check
167.3636 +
167.3637 +
167.3638 +# func_pathlist_front_back_pathsep FRONTPAT BACKPAT REPL ORIG
167.3639 +# Modifies func_to_host_pathlist_result by prepending REPL
167.3640 +# if ORIG matches FRONTPAT and appending REPL if ORIG matches
167.3641 +# BACKPAT.
167.3642 +func_pathlist_front_back_pathsep ()
167.3643 +{
167.3644 +  $opt_debug
167.3645 +  case "$4" in
167.3646 +  $1 ) func_to_host_pathlist_result="$3$func_to_host_pathlist_result"
167.3647 +    ;;
167.3648 +  esac
167.3649 +  case "$4" in
167.3650 +  $2 ) func_append func_to_host_pathlist_result "$3"
167.3651 +    ;;
167.3652 +  esac
167.3653 +}
167.3654 +# end func_pathlist_front_back_pathsep
167.3655 +
167.3656 +
167.3657 +#############################################
167.3658 +# $build to $host PATH CONVERSION FUNCTIONS #
167.3659 +#############################################
167.3660 +# invoked via `eval $to_host_path_cmd ARG'
167.3661 +#
167.3662 +# At present, the following path conversions are supported:
167.3663 +#    $build          $host
167.3664 +#    mingw (msys)    mingw  [e.g. native]
167.3665 +#    cygwin          mingw
167.3666 +#    *nix + wine     mingw
167.3667 +#    mingw (msys)    cygwin [*] [**]
167.3668 +#    *nix + wine     cygwin [**]
167.3669 +# where wine is equipped with the `winepath' executable.
167.3670 +# [*] available, but not officially supported. See comments with
167.3671 +#     func_msys_to_cygwin_path_convert.
167.3672 +# [**] requires environment variable $LT_CYGPATH. See comments
167.3673 +#      with func_cygpath.
167.3674 +# In each case, ARG is the path to be converted from $build
167.3675 +# to $host format. the result will be available in
167.3676 +# $func_to_host_path_result.
167.3677 +
167.3678 +
167.3679 +# func_to_host_path ARG
167.3680 +# converts the path ARG from $build format to $host
167.3681 +# format.
167.3682 +func_to_host_path ()
167.3683 +{
167.3684 +  $opt_debug
167.3685 +  eval '$to_host_path_cmd "$1"'
167.3686 +}
167.3687 +# end func_to_host_path
167.3688 +
167.3689 +
167.3690 +# func_noop_path_convert ARG
167.3691 +# A no-op path conversion function for use when $build == $host.
167.3692 +# or when there is no required (or known) conversion function
167.3693 +# between $build and $host.
167.3694 +func_noop_path_convert ()
167.3695 +{
167.3696 +  $opt_debug
167.3697 +  func_to_host_path_result="$1"
167.3698 +}
167.3699 +# end func_noop_path_convert
167.3700 +
167.3701 +
167.3702 +# func_msys_to_mingw_path_convert ARG
167.3703 +# A path conversion function for use with "native" mingw
167.3704 +# builds -- that is, when $host is *mingw*, and $build
167.3705 +# is *mingw* (which is to say, msys).  In this case, the
167.3706 +# msys shell automatically converts paths for any non-msys
167.3707 +# applications it launches, but that facility isn't available
167.3708 +# from inside the cwrapper.
167.3709 +#
167.3710 +# ARG is the path to be converted; the result is available
167.3711 +# in func_to_host_path_result.
167.3712 +func_msys_to_mingw_path_convert ()
167.3713 +{
167.3714 +  $opt_debug
167.3715 +  func_to_host_path_result="$1"
167.3716 +  if test -n "$1"; then
167.3717 +    func_msys_to_win32 "$1"
167.3718 +    func_to_host_path_result="$func_msys_to_win32_result"
167.3719 +  fi
167.3720 +  func_path_convert_check "$1" "$func_to_host_path_result"
167.3721 +}
167.3722 +# end func_msys_to_mingw_path_convert
167.3723 +
167.3724 +
167.3725 +# func_cygwin_to_mingw_path_convert ARG
167.3726 +# A path conversion function for use when $host is *mingw*
167.3727 +# but $build is *cygwin*. In this case, the cygpath program
167.3728 +# provided by the $build environment is sufficient for all
167.3729 +# conversions.
167.3730 +#
167.3731 +# ARG is the path to be converted; the result is available
167.3732 +# in func_to_host_path_result.
167.3733 +func_cygwin_to_mingw_path_convert ()
167.3734 +{
167.3735 +  $opt_debug
167.3736 +  func_to_host_path_result="$1"
167.3737 +  if test -n "$1"; then
167.3738 +    # because $build is cygwin, we call "the" cygpath
167.3739 +    # in $PATH; no need to use LT_CYGPATH in this case.
167.3740 +    func_to_host_path_result=`cygpath -m "$1"`
167.3741 +  fi
167.3742 +  func_path_convert_check "$1" "$func_to_host_path_result"
167.3743 +}
167.3744 +# end func_cygwin_to_mingw_path_convert
167.3745 +
167.3746 +
167.3747 +# func_nix_to_mingw_path_convert ARG
167.3748 +# A path conversion function for use when $host is *mingw*
167.3749 +# but $build is some *nix variant. In this case, we assume
167.3750 +# that a wine environment with a working winepath executable
167.3751 +# is available in $build's $PATH.
167.3752 +#
167.3753 +# ARG is the path to be converted; the result is available
167.3754 +# in func_to_host_path_result.
167.3755 +func_nix_to_mingw_path_convert ()
167.3756 +{
167.3757 +  $opt_debug
167.3758 +  func_to_host_path_result="$1"
167.3759 +  if test -n "$1"; then
167.3760 +    func_wine_to_win32_path "$1"
167.3761 +    func_to_host_path_result="$func_wine_to_win32_path_result"
167.3762 +  fi
167.3763 +  func_path_convert_check "$1" "$func_to_host_path_result"
167.3764 +}
167.3765 +# end func_nix_to_mingw_path_convert
167.3766 +
167.3767 +
167.3768 +# func_msys_to_cygwin_path_convert ARG
167.3769 +# A path conversion function for use when $host is *cygwin*
167.3770 +# but $build is *mingw* (that is, msys). This implies running
167.3771 +# a cross build from msys to cygwin -- but msys has notorious
167.3772 +# problems executing cygwin apps, because of conflicts between
167.3773 +# cygwin1.dll and msys-1.0.dll. However, we'll try it. First,
167.3774 +# convert from msys to win32, then use func_cygpath to convert
167.3775 +# from win32 to cygwin. Requires LT_CYGPATH.
167.3776 +#
167.3777 +# ARG is the path to be converted; the result is available
167.3778 +# in func_to_host_path_result.
167.3779 +func_msys_to_cygwin_path_convert ()
167.3780 +{
167.3781 +  $opt_debug
167.3782 +  func_to_host_path_result="$1"
167.3783 +  if test -n "$1"; then
167.3784 +    func_msys_to_win32 "$1"
167.3785 +    func_cygpath -u "$func_msys_to_win32_result"
167.3786 +    func_to_host_path_result="$func_cygpath_result"
167.3787 +  fi
167.3788 +  func_path_convert_check "$1" "$func_to_host_path_result"
167.3789 +}
167.3790 +# end func_msys_to_cygwin_path_convert
167.3791 +
167.3792 +# func_nix_to_cygwin_path_convert ARG
167.3793 +# A path conversion function for use when $host is *cygwin*
167.3794 +# but $build is some *nix variant. In this case, we assume
167.3795 +# that a wine environment with a working winepath executable
167.3796 +# is available in $build's $PATH, and that cygwin is installed
167.3797 +# within that wine environment. Requires LT_CYGPATH (see
167.3798 +# func_cygpath).
167.3799 +#
167.3800 +# ARG is the path to be converted; the result is available
167.3801 +# in func_to_host_path_result.
167.3802 +func_nix_to_cygwin_path_convert ()
167.3803 +{
167.3804 +  $opt_debug
167.3805 +  func_to_host_path_result="$1"
167.3806 +  if test -n "$1"; then
167.3807 +    # convert from *nix to win32, then use cygpath to
167.3808 +    # convert from win32 to cygwin.
167.3809 +    func_wine_to_win32_path "$1"
167.3810 +    func_cygpath -u "$func_wine_to_win32_path_result"
167.3811 +    func_to_host_path_result="$func_cygpath_result"
167.3812 +  fi
167.3813 +  func_path_convert_check "$1" "$func_to_host_path_result"
167.3814 +}
167.3815 +# end func_nix_to_cygwin_path_convert
167.3816 +
167.3817 +
167.3818 +#################################################
167.3819 +# $build to $host PATHLIST CONVERSION FUNCTIONS #
167.3820 +#################################################
167.3821 +# invoked via `eval $to_host_pathlist_cmd ARG'
167.3822 +#
167.3823 +# At present, the following pathlist conversions are supported:
167.3824 +#    $build          $host
167.3825 +#    mingw (msys)    mingw  [e.g. native]
167.3826 +#    cygwin          mingw
167.3827 +#    *nix + wine     mingw
167.3828 +#    mingw (msys)    cygwin [*] [**]
167.3829 +#    *nix + wine     cygwin [**]
167.3830 +# where wine is equipped with the `winepath' executable.
167.3831 +# [*] available, but not officially supported. See comments with
167.3832 +#     func_msys_to_cygwin_pathlist_convert.
167.3833 +# [**] requires environment variable $LT_CYGPATH. See comments
167.3834 +#      with func_cygpath.
167.3835 +# In each case, ARG is the pathlist to be converted from
167.3836 +# $build to $host format. the result will be available in
167.3837 +# $func_to_host_pathlist_result.
167.3838 +#
167.3839 +# Path separators are also converted from $build format to
167.3840 +# $host format. If ARG begins or ends with a path separator
167.3841 +# character, it is preserved (but converted to $host format)
167.3842 +# on output.
167.3843 +
167.3844 +
167.3845 +# func_init_to_host_pathlist_cmd
167.3846 +# Ensures that function "pointer" variable
167.3847 +# $to_host_pathlist_cmd is set to the appropriate
167.3848 +# value, based on the value of $to_host_path_cmd.
167.3849 +#
167.3850 +# ASSUMPTIONS: all such conversion functions are
167.3851 +# named using the following convention:
167.3852 +#   path conversion function    : xxxxxx_path_convert ()
167.3853 +#   pathlist conversion function: xxxxxx_pathlist_convert ()
167.3854 +# where, for any given $build/$host combination the 'xxxxxx'
167.3855 +# value is the same.
167.3856 +to_host_pathlist_cmd=
167.3857 +func_init_to_host_pathlist_cmd ()
167.3858 +{
167.3859 +  $opt_debug
167.3860 +  if test -z "$to_host_pathlist_cmd"; then
167.3861 +    func_stripname '' '_path_convert' "$to_host_path_cmd"
167.3862 +    to_host_pathlist_cmd="${func_stripname_result}_pathlist_convert"
167.3863 +  fi
167.3864 +}
167.3865 +
167.3866 +
167.3867 +# func_to_host_pathlist ARG
167.3868 +# converts the pathlist ARG from $build format to $host
167.3869 +# format.
167.3870 +func_to_host_pathlist ()
167.3871 +{
167.3872 +  $opt_debug
167.3873 +  func_init_to_host_pathlist_cmd
167.3874 +  eval '$to_host_pathlist_cmd "$1"'
167.3875 +}
167.3876 +# end func_to_host_pathlist
167.3877 +
167.3878 +
167.3879 +# func_noop_pathlist_convert ARG
167.3880 +# A no-op pathlist conversion function for use when $build == $host,
167.3881 +# or when there is no required (or known) conversion function
167.3882 +# between $build and $host.
167.3883 +func_noop_pathlist_convert ()
167.3884 +{
167.3885 +  $opt_debug
167.3886 +  func_to_host_pathlist_result="$1"
167.3887 +}
167.3888 +# end func_noop_pathlist_convert
167.3889 +
167.3890 +
167.3891 +# func_msys_to_mingw_pathlist_convert ARG
167.3892 +# A pathlist conversion function for use with "native" mingw
167.3893 +# builds -- that is, when $host is *mingw*, and $build
167.3894 +# is *mingw* (which is to say, msys).  In this case, the
167.3895 +# msys shell automatically converts pathlists for any non-msys
167.3896 +# applications it launches, but that facility isn't available
167.3897 +# from inside the cwrapper.
167.3898 +#
167.3899 +# ARG is the pathlist to be converted; the result is available
167.3900 +# in func_to_host_pathlist_result.
167.3901 +func_msys_to_mingw_pathlist_convert ()
167.3902 +{
167.3903 +  $opt_debug
167.3904 +  func_to_host_pathlist_result="$1"
167.3905 +  if test -n "$1"; then
167.3906 +    # Remove leading and trailing path separator characters from
167.3907 +    # ARG. msys behavior is inconsistent here, cygpath turns them
167.3908 +    # into '.;' and ';.', and winepath ignores them completely.
167.3909 +    func_stripname : : "$1"
167.3910 +    func_to_host_pathlist_tmp1=$func_stripname_result
167.3911 +    func_msys_to_win32 "$func_to_host_pathlist_tmp1"
167.3912 +    func_to_host_pathlist_result="$func_msys_to_win32_result"
167.3913 +    func_pathlist_convert_check ":" ";" \
167.3914 +      "$func_to_host_pathlist_tmp1" "$func_to_host_pathlist_result"
167.3915 +    func_pathlist_front_back_pathsep ":*" "*:" ";" "$1"
167.3916 +  fi
167.3917 +}
167.3918 +# end func_msys_to_mingw_pathlist_convert
167.3919 +
167.3920 +
167.3921 +# func_cygwin_to_mingw_pathlist_convert ARG
167.3922 +# A pathlist conversion function for use when $host is *mingw*
167.3923 +# but $build is *cygwin*. In this case, the cygpath program
167.3924 +# provided by the $build environment is sufficient for all
167.3925 +# conversions.
167.3926 +#
167.3927 +# ARG is the pathlist to be converted; the result is available
167.3928 +# in func_to_host_pathlist_result.
167.3929 +func_cygwin_to_mingw_pathlist_convert ()
167.3930 +{
167.3931 +  $opt_debug
167.3932 +  func_to_host_pathlist_result="$1"
167.3933 +  if test -n "$1"; then
167.3934 +    # Remove leading and trailing path separator characters from
167.3935 +    # ARG. msys behavior is inconsistent here, cygpath turns them
167.3936 +    # into '.;' and ';.', and winepath ignores them completely.
167.3937 +    func_stripname : : "$1"
167.3938 +    func_to_host_pathlist_tmp1=$func_stripname_result
167.3939 +    func_to_host_pathlist_result=`cygpath -m -p "$func_to_host_pathlist_tmp1"`
167.3940 +    func_pathlist_convert_check ":" ";" \
167.3941 +      "$func_to_host_pathlist_tmp1" "$func_to_host_pathlist_result"
167.3942 +    func_pathlist_front_back_pathsep ":*" "*:" ";" "$1"
167.3943 +  fi
167.3944 +}
167.3945 +# end func_cygwin_to_mingw_pathlist_convert
167.3946 +
167.3947 +
167.3948 +# func_nix_to_mingw_pathlist_convert ARG
167.3949 +# A pathlist conversion function for use when $host is *mingw*
167.3950 +# but $build is some *nix variant. In this case, we assume
167.3951 +# that a wine environment with a working winepath executable
167.3952 +# is available in $build's $PATH.
167.3953 +#
167.3954 +# ARG is the pathlist to be converted; the result is available
167.3955 +# in func_to_host_pathlist_result.
167.3956 +func_nix_to_mingw_pathlist_convert ()
167.3957 +{
167.3958 +  $opt_debug
167.3959 +  func_to_host_pathlist_result="$1"
167.3960 +  if test -n "$1"; then
167.3961 +    # Remove leading and trailing path separator characters from
167.3962 +    # ARG. msys behavior is inconsistent here, cygpath turns them
167.3963 +    # into '.;' and ';.', and winepath ignores them completely.
167.3964 +    func_stripname : : "$1"
167.3965 +    func_to_host_pathlist_tmp1=$func_stripname_result
167.3966 +    func_wine_to_win32_pathlist "$func_to_host_pathlist_tmp1"
167.3967 +    func_to_host_pathlist_result="$func_wine_to_win32_pathlist_result"
167.3968 +    func_pathlist_convert_check ":" ";" \
167.3969 +      "$func_to_host_pathlist_tmp1" "$func_to_host_pathlist_result"
167.3970 +    func_pathlist_front_back_pathsep ":*" "*:" ";" "$1"
167.3971 +  fi
167.3972 +}
167.3973 +# end func_nix_to_mingw_pathlist_convert
167.3974 +
167.3975 +
167.3976 +# func_msys_to_cygwin_pathlist_convert ARG
167.3977 +# A pathlist conversion function for use when $host is *cygwin*
167.3978 +# but $build is *mingw* (that is, msys). This implies running
167.3979 +# a cross build from msys to cygwin -- but msys has notorious
167.3980 +# problems executing cygwin apps, because of conflicts between
167.3981 +# cygwin1.dll and msys-1.0.dll. However, we'll try it. First,
167.3982 +# convert from msys to win32, then use func_cygpath to convert
167.3983 +# from win32 to cygwin. Requires LT_CYGPATH.
167.3984 +#
167.3985 +# ARG is the pathlist to be converted; the result is available
167.3986 +# in func_to_host_pathlist_result.
167.3987 +func_msys_to_cygwin_pathlist_convert ()
167.3988 +{
167.3989 +  $opt_debug
167.3990 +  func_to_host_pathlist_result="$1"
167.3991 +  if test -n "$1"; then
167.3992 +    # Remove leading and trailing path separator characters from
167.3993 +    # ARG. msys behavior is inconsistent here, cygpath turns them
167.3994 +    # into '.;' and ';.', and winepath ignores them completely.
167.3995 +    func_stripname : : "$1"
167.3996 +    func_to_host_pathlist_tmp1=$func_stripname_result
167.3997 +    func_msys_to_win32 "$func_to_host_pathlist_tmp1"
167.3998 +    func_cygpath -u -p "$func_msys_to_win32_result"
167.3999 +    func_to_host_pathlist_result="$func_cygpath_result"
167.4000 +    func_pathlist_convert_check ":" ":" \
167.4001 +      "$func_to_host_pathlist_tmp1" "$func_to_host_pathlist_result"
167.4002 +    func_pathlist_front_back_pathsep ":*" "*:" ":" "$1"
167.4003 +  fi
167.4004 +}
167.4005 +# end func_msys_to_cygwin_pathlist_convert
167.4006 +
167.4007 +
167.4008 +# func_nix_to_cygwin_pathlist_convert ARG
167.4009 +# A pathlist conversion function for use when $host is *cygwin*
167.4010 +# but $build is some *nix variant. In this case, we assume
167.4011 +# that a wine environment with a working winepath executable
167.4012 +# is available in $build's $PATH, and that cygwin is installed
167.4013 +# within that wine environment. Requires LT_CYGPATH (see
167.4014 +# func_cygpath).
167.4015 +#
167.4016 +# ARG is the pathlist to be converted; the result is available
167.4017 +# in func_to_host_pathlist_result.
167.4018 +func_nix_to_cygwin_pathlist_convert ()
167.4019 +{
167.4020 +  $opt_debug
167.4021 +  func_to_host_pathlist_result="$1"
167.4022 +  if test -n "$1"; then
167.4023 +    # Remove leading and trailing path separator characters from
167.4024 +    # ARG. msys behavior is inconsistent here, cygpath turns them
167.4025 +    # into '.;' and ';.', and winepath ignores them completely.
167.4026 +    func_stripname : : "$1"
167.4027 +    func_to_host_pathlist_tmp1=$func_stripname_result
167.4028 +    func_wine_to_win32_pathlist "$func_to_host_pathlist_tmp1"
167.4029 +    func_cygpath -u -p "$func_wine_to_win32_pathlist_result"
167.4030 +    func_to_host_pathlist_result="$func_cygpath_result"
167.4031 +    func_pathlist_convert_check ":" ":" \
167.4032 +      "$func_to_host_pathlist_tmp1" "$func_to_host_pathlist_result"
167.4033 +    func_pathlist_front_back_pathsep ":*" "*:" ":" "$1"
167.4034 +  fi
167.4035 +}
167.4036 +# end func_nix_to_cygwin_pathlist_convert
167.4037 +
167.4038 +
167.4039 +# func_emit_cwrapperexe_src
167.4040 +# emit the source code for a wrapper executable on stdout
167.4041 +# Must ONLY be called from within func_mode_link because
167.4042 +# it depends on a number of variable set therein.
167.4043 +func_emit_cwrapperexe_src ()
167.4044 +{
167.4045 +	cat <<EOF
167.4046 +
167.4047 +/* $cwrappersource - temporary wrapper executable for $objdir/$outputname
167.4048 +   Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION
167.4049 +
167.4050 +   The $output program cannot be directly executed until all the libtool
167.4051 +   libraries that it depends on are installed.
167.4052 +
167.4053 +   This wrapper executable should never be moved out of the build directory.
167.4054 +   If it is, it will not operate correctly.
167.4055 +
167.4056 +   Currently, it simply execs the wrapper *script* "$SHELL $output",
167.4057 +   but could eventually absorb all of the scripts functionality and
167.4058 +   exec $objdir/$outputname directly.
167.4059 +*/
167.4060 +EOF
167.4061 +	    cat <<"EOF"
167.4062 +#ifdef _MSC_VER
167.4063 +# define _CRT_SECURE_NO_DEPRECATE 1
167.4064 +#endif
167.4065 +#include <stdio.h>
167.4066 +#include <stdlib.h>
167.4067 +#ifdef _MSC_VER
167.4068 +# include <direct.h>
167.4069 +# include <process.h>
167.4070 +# include <io.h>
167.4071 +#else
167.4072 +# include <unistd.h>
167.4073 +# include <stdint.h>
167.4074 +# ifdef __CYGWIN__
167.4075 +#  include <io.h>
167.4076 +# endif
167.4077 +#endif
167.4078 +#include <malloc.h>
167.4079 +#include <stdarg.h>
167.4080 +#include <assert.h>
167.4081 +#include <string.h>
167.4082 +#include <ctype.h>
167.4083 +#include <errno.h>
167.4084 +#include <fcntl.h>
167.4085 +#include <sys/stat.h>
167.4086 +
167.4087 +/* declarations of non-ANSI functions */
167.4088 +#if defined(__MINGW32__)
167.4089 +# ifdef __STRICT_ANSI__
167.4090 +int _putenv (const char *);
167.4091 +# endif
167.4092 +#elif defined(__CYGWIN__)
167.4093 +# ifdef __STRICT_ANSI__
167.4094 +char *realpath (const char *, char *);
167.4095 +int putenv (char *);
167.4096 +int setenv (const char *, const char *, int);
167.4097 +# endif
167.4098 +/* #elif defined (other platforms) ... */
167.4099 +#endif
167.4100 +
167.4101 +/* portability defines, excluding path handling macros */
167.4102 +#if defined(_MSC_VER)
167.4103 +# define setmode _setmode
167.4104 +# define stat    _stat
167.4105 +# define chmod   _chmod
167.4106 +# define getcwd  _getcwd
167.4107 +# define putenv  _putenv
167.4108 +# define S_IXUSR _S_IEXEC
167.4109 +# ifndef _INTPTR_T_DEFINED
167.4110 +#  define _INTPTR_T_DEFINED
167.4111 +#  define intptr_t int
167.4112 +# endif
167.4113 +#elif defined(__MINGW32__)
167.4114 +# define setmode _setmode
167.4115 +# define stat    _stat
167.4116 +# define chmod   _chmod
167.4117 +# define getcwd  _getcwd
167.4118 +# define putenv  _putenv
167.4119 +#elif defined(__CYGWIN__)
167.4120 +# define HAVE_SETENV
167.4121 +# define FOPEN_WB "wb"
167.4122 +/* #elif defined (other platforms) ... */
167.4123 +#endif
167.4124 +
167.4125 +#if defined(PATH_MAX)
167.4126 +# define LT_PATHMAX PATH_MAX
167.4127 +#elif defined(MAXPATHLEN)
167.4128 +# define LT_PATHMAX MAXPATHLEN
167.4129 +#else
167.4130 +# define LT_PATHMAX 1024
167.4131 +#endif
167.4132 +
167.4133 +#ifndef S_IXOTH
167.4134 +# define S_IXOTH 0
167.4135 +#endif
167.4136 +#ifndef S_IXGRP
167.4137 +# define S_IXGRP 0
167.4138 +#endif
167.4139 +
167.4140 +/* path handling portability macros */
167.4141 +#ifndef DIR_SEPARATOR
167.4142 +# define DIR_SEPARATOR '/'
167.4143 +# define PATH_SEPARATOR ':'
167.4144 +#endif
167.4145 +
167.4146 +#if defined (_WIN32) || defined (__MSDOS__) || defined (__DJGPP__) || \
167.4147 +  defined (__OS2__)
167.4148 +# define HAVE_DOS_BASED_FILE_SYSTEM
167.4149 +# define FOPEN_WB "wb"
167.4150 +# ifndef DIR_SEPARATOR_2
167.4151 +#  define DIR_SEPARATOR_2 '\\'
167.4152 +# endif
167.4153 +# ifndef PATH_SEPARATOR_2
167.4154 +#  define PATH_SEPARATOR_2 ';'
167.4155 +# endif
167.4156 +#endif
167.4157 +
167.4158 +#ifndef DIR_SEPARATOR_2
167.4159 +# define IS_DIR_SEPARATOR(ch) ((ch) == DIR_SEPARATOR)
167.4160 +#else /* DIR_SEPARATOR_2 */
167.4161 +# define IS_DIR_SEPARATOR(ch) \
167.4162 +	(((ch) == DIR_SEPARATOR) || ((ch) == DIR_SEPARATOR_2))
167.4163 +#endif /* DIR_SEPARATOR_2 */
167.4164 +
167.4165 +#ifndef PATH_SEPARATOR_2
167.4166 +# define IS_PATH_SEPARATOR(ch) ((ch) == PATH_SEPARATOR)
167.4167 +#else /* PATH_SEPARATOR_2 */
167.4168 +# define IS_PATH_SEPARATOR(ch) ((ch) == PATH_SEPARATOR_2)
167.4169 +#endif /* PATH_SEPARATOR_2 */
167.4170 +
167.4171 +#ifndef FOPEN_WB
167.4172 +# define FOPEN_WB "w"
167.4173 +#endif
167.4174 +#ifndef _O_BINARY
167.4175 +# define _O_BINARY 0
167.4176 +#endif
167.4177 +
167.4178 +#define XMALLOC(type, num)      ((type *) xmalloc ((num) * sizeof(type)))
167.4179 +#define XFREE(stale) do { \
167.4180 +  if (stale) { free ((void *) stale); stale = 0; } \
167.4181 +} while (0)
167.4182 +
167.4183 +#if defined(LT_DEBUGWRAPPER)
167.4184 +static int lt_debug = 1;
167.4185 +#else
167.4186 +static int lt_debug = 0;
167.4187 +#endif
167.4188 +
167.4189 +const char *program_name = NULL;
167.4190 +
167.4191 +void *xmalloc (size_t num);
167.4192 +char *xstrdup (const char *string);
167.4193 +const char *base_name (const char *name);
167.4194 +char *find_executable (const char *wrapper);
167.4195 +char *chase_symlinks (const char *pathspec);
167.4196 +int make_executable (const char *path);
167.4197 +int check_executable (const char *path);
167.4198 +char *strendzap (char *str, const char *pat);
167.4199 +void lt_debugprintf (const char *fmt, ...);
167.4200 +void lt_fatal (const char *message, ...);
167.4201 +void lt_setenv (const char *name, const char *value);
167.4202 +char *lt_extend_str (const char *orig_value, const char *add, int to_end);
167.4203 +void lt_update_exe_path (const char *name, const char *value);
167.4204 +void lt_update_lib_path (const char *name, const char *value);
167.4205 +char **prepare_spawn (char **argv);
167.4206 +void lt_dump_script (FILE *f);
167.4207 +
167.4208 +EOF
167.4209 +
167.4210 +	    cat <<EOF
167.4211 +const char * MAGIC_EXE = "$magic_exe";
167.4212 +const char * LIB_PATH_VARNAME = "$shlibpath_var";
167.4213 +EOF
167.4214 +
167.4215 +	    if test "$shlibpath_overrides_runpath" = yes && test -n "$shlibpath_var" && test -n "$temp_rpath"; then
167.4216 +              func_to_host_pathlist "$temp_rpath"
167.4217 +	      cat <<EOF
167.4218 +const char * LIB_PATH_VALUE   = "$func_to_host_pathlist_result";
167.4219 +EOF
167.4220 +	    else
167.4221 +	      cat <<"EOF"
167.4222 +const char * LIB_PATH_VALUE   = "";
167.4223 +EOF
167.4224 +	    fi
167.4225 +
167.4226 +	    if test -n "$dllsearchpath"; then
167.4227 +              func_to_host_pathlist "$dllsearchpath:"
167.4228 +	      cat <<EOF
167.4229 +const char * EXE_PATH_VARNAME = "PATH";
167.4230 +const char * EXE_PATH_VALUE   = "$func_to_host_pathlist_result";
167.4231 +EOF
167.4232 +	    else
167.4233 +	      cat <<"EOF"
167.4234 +const char * EXE_PATH_VARNAME = "";
167.4235 +const char * EXE_PATH_VALUE   = "";
167.4236 +EOF
167.4237 +	    fi
167.4238 +
167.4239 +	    if test "$fast_install" = yes; then
167.4240 +	      cat <<EOF
167.4241 +const char * TARGET_PROGRAM_NAME = "lt-$outputname"; /* hopefully, no .exe */
167.4242 +EOF
167.4243 +	    else
167.4244 +	      cat <<EOF
167.4245 +const char * TARGET_PROGRAM_NAME = "$outputname"; /* hopefully, no .exe */
167.4246 +EOF
167.4247 +	    fi
167.4248 +
167.4249 +
167.4250 +	    cat <<"EOF"
167.4251 +
167.4252 +#define LTWRAPPER_OPTION_PREFIX         "--lt-"
167.4253 +#define LTWRAPPER_OPTION_PREFIX_LENGTH  5
167.4254 +
167.4255 +static const size_t opt_prefix_len         = LTWRAPPER_OPTION_PREFIX_LENGTH;
167.4256 +static const char *ltwrapper_option_prefix = LTWRAPPER_OPTION_PREFIX;
167.4257 +
167.4258 +static const char *dumpscript_opt       = LTWRAPPER_OPTION_PREFIX "dump-script";
167.4259 +static const size_t dumpscript_opt_len  = LTWRAPPER_OPTION_PREFIX_LENGTH + 11;
167.4260 +
167.4261 +static const char *debug_opt            = LTWRAPPER_OPTION_PREFIX "debug";
167.4262 +static const size_t debug_opt_len       = LTWRAPPER_OPTION_PREFIX_LENGTH + 5;
167.4263 +
167.4264 +int
167.4265 +main (int argc, char *argv[])
167.4266 +{
167.4267 +  char **newargz;
167.4268 +  int  newargc;
167.4269 +  char *tmp_pathspec;
167.4270 +  char *actual_cwrapper_path;
167.4271 +  char *actual_cwrapper_name;
167.4272 +  char *target_name;
167.4273 +  char *lt_argv_zero;
167.4274 +  intptr_t rval = 127;
167.4275 +
167.4276 +  int i;
167.4277 +
167.4278 +  program_name = (char *) xstrdup (base_name (argv[0]));
167.4279 +  newargz = XMALLOC (char *, argc + 1);
167.4280 +
167.4281 +  /* very simple arg parsing; don't want to rely on getopt
167.4282 +   * also, copy all non cwrapper options to newargz, except
167.4283 +   * argz[0], which is handled differently
167.4284 +   */
167.4285 +  newargc=0;
167.4286 +  for (i = 1; i < argc; i++)
167.4287 +    {
167.4288 +      if (strncmp (argv[i], dumpscript_opt, dumpscript_opt_len) == 0)
167.4289 +	{
167.4290 +EOF
167.4291 +	    case "$host" in
167.4292 +	      *mingw* | *cygwin* )
167.4293 +		# make stdout use "unix" line endings
167.4294 +		echo "          setmode(1,_O_BINARY);"
167.4295 +		;;
167.4296 +	      esac
167.4297 +
167.4298 +	    cat <<"EOF"
167.4299 +	  lt_dump_script (stdout);
167.4300 +	  return 0;
167.4301 +	}
167.4302 +      if (strncmp (argv[i], debug_opt, debug_opt_len) == 0)
167.4303 +	{
167.4304 +          lt_debug = 1;
167.4305 +          continue;
167.4306 +	}
167.4307 +      if (strncmp (argv[i], ltwrapper_option_prefix, opt_prefix_len) == 0)
167.4308 +        {
167.4309 +          /* however, if there is an option in the LTWRAPPER_OPTION_PREFIX
167.4310 +             namespace, but it is not one of the ones we know about and
167.4311 +             have already dealt with, above (inluding dump-script), then
167.4312 +             report an error. Otherwise, targets might begin to believe
167.4313 +             they are allowed to use options in the LTWRAPPER_OPTION_PREFIX
167.4314 +             namespace. The first time any user complains about this, we'll
167.4315 +             need to make LTWRAPPER_OPTION_PREFIX a configure-time option
167.4316 +             or a configure.ac-settable value.
167.4317 +           */
167.4318 +          lt_fatal ("Unrecognized %s option: '%s'",
167.4319 +                    ltwrapper_option_prefix, argv[i]);
167.4320 +        }
167.4321 +      /* otherwise ... */
167.4322 +      newargz[++newargc] = xstrdup (argv[i]);
167.4323 +    }
167.4324 +  newargz[++newargc] = NULL;
167.4325 +
167.4326 +  /* first use of lt_debugprintf AFTER parsing options */
167.4327 +  lt_debugprintf ("(main) argv[0]      : %s\n", argv[0]);
167.4328 +  lt_debugprintf ("(main) program_name : %s\n", program_name);
167.4329 +
167.4330 +  tmp_pathspec = find_executable (argv[0]);
167.4331 +  if (tmp_pathspec == NULL)
167.4332 +    lt_fatal ("Couldn't find %s", argv[0]);
167.4333 +  lt_debugprintf ("(main) found exe (before symlink chase) at : %s\n",
167.4334 +		  tmp_pathspec);
167.4335 +
167.4336 +  actual_cwrapper_path = chase_symlinks (tmp_pathspec);
167.4337 +  lt_debugprintf ("(main) found exe (after symlink chase) at : %s\n",
167.4338 +		  actual_cwrapper_path);
167.4339 +  XFREE (tmp_pathspec);
167.4340 +
167.4341 +  actual_cwrapper_name = xstrdup( base_name (actual_cwrapper_path));
167.4342 +  strendzap (actual_cwrapper_path, actual_cwrapper_name);
167.4343 +
167.4344 +  /* wrapper name transforms */
167.4345 +  strendzap (actual_cwrapper_name, ".exe");
167.4346 +  tmp_pathspec = lt_extend_str (actual_cwrapper_name, ".exe", 1);
167.4347 +  XFREE (actual_cwrapper_name);
167.4348 +  actual_cwrapper_name = tmp_pathspec;
167.4349 +  tmp_pathspec = 0;
167.4350 +
167.4351 +  /* target_name transforms -- use actual target program name; might have lt- prefix */
167.4352 +  target_name = xstrdup (base_name (TARGET_PROGRAM_NAME));
167.4353 +  strendzap (target_name, ".exe");
167.4354 +  tmp_pathspec = lt_extend_str (target_name, ".exe", 1);
167.4355 +  XFREE (target_name);
167.4356 +  target_name = tmp_pathspec;
167.4357 +  tmp_pathspec = 0;
167.4358 +
167.4359 +  lt_debugprintf ("(main) libtool target name: %s\n",
167.4360 +		  target_name);
167.4361 +EOF
167.4362 +
167.4363 +	    cat <<EOF
167.4364 +  newargz[0] =
167.4365 +    XMALLOC (char, (strlen (actual_cwrapper_path) +
167.4366 +		    strlen ("$objdir") + 1 + strlen (actual_cwrapper_name) + 1));
167.4367 +  strcpy (newargz[0], actual_cwrapper_path);
167.4368 +  strcat (newargz[0], "$objdir");
167.4369 +  strcat (newargz[0], "/");
167.4370 +EOF
167.4371 +
167.4372 +	    cat <<"EOF"
167.4373 +  /* stop here, and copy so we don't have to do this twice */
167.4374 +  tmp_pathspec = xstrdup (newargz[0]);
167.4375 +
167.4376 +  /* do NOT want the lt- prefix here, so use actual_cwrapper_name */
167.4377 +  strcat (newargz[0], actual_cwrapper_name);
167.4378 +
167.4379 +  /* DO want the lt- prefix here if it exists, so use target_name */
167.4380 +  lt_argv_zero = lt_extend_str (tmp_pathspec, target_name, 1);
167.4381 +  XFREE (tmp_pathspec);
167.4382 +  tmp_pathspec = NULL;
167.4383 +EOF
167.4384 +
167.4385 +	    case $host_os in
167.4386 +	      mingw*)
167.4387 +	    cat <<"EOF"
167.4388 +  {
167.4389 +    char* p;
167.4390 +    while ((p = strchr (newargz[0], '\\')) != NULL)
167.4391 +      {
167.4392 +	*p = '/';
167.4393 +      }
167.4394 +    while ((p = strchr (lt_argv_zero, '\\')) != NULL)
167.4395 +      {
167.4396 +	*p = '/';
167.4397 +      }
167.4398 +  }
167.4399 +EOF
167.4400 +	    ;;
167.4401 +	    esac
167.4402 +
167.4403 +	    cat <<"EOF"
167.4404 +  XFREE (target_name);
167.4405 +  XFREE (actual_cwrapper_path);
167.4406 +  XFREE (actual_cwrapper_name);
167.4407 +
167.4408 +  lt_setenv ("BIN_SH", "xpg4"); /* for Tru64 */
167.4409 +  lt_setenv ("DUALCASE", "1");  /* for MSK sh */
167.4410 +  lt_update_lib_path (LIB_PATH_VARNAME, LIB_PATH_VALUE);
167.4411 +  lt_update_exe_path (EXE_PATH_VARNAME, EXE_PATH_VALUE);
167.4412 +
167.4413 +  lt_debugprintf     ("(main) lt_argv_zero : %s\n", (lt_argv_zero ? lt_argv_zero : "<NULL>"));
167.4414 +  for (i = 0; i < newargc; i++)
167.4415 +    {
167.4416 +      lt_debugprintf ("(main) newargz[%d]   : %s\n", i, (newargz[i] ? newargz[i] : "<NULL>"));
167.4417 +    }
167.4418 +
167.4419 +EOF
167.4420 +
167.4421 +	    case $host_os in
167.4422 +	      mingw*)
167.4423 +		cat <<"EOF"
167.4424 +  /* execv doesn't actually work on mingw as expected on unix */
167.4425 +  newargz = prepare_spawn (newargz);
167.4426 +  rval = _spawnv (_P_WAIT, lt_argv_zero, (const char * const *) newargz);
167.4427 +  if (rval == -1)
167.4428 +    {
167.4429 +      /* failed to start process */
167.4430 +      lt_debugprintf ("(main) failed to launch target \"%s\": errno = %d\n", lt_argv_zero, errno);
167.4431 +      return 127;
167.4432 +    }
167.4433 +  return rval;
167.4434 +EOF
167.4435 +		;;
167.4436 +	      *)
167.4437 +		cat <<"EOF"
167.4438 +  execv (lt_argv_zero, newargz);
167.4439 +  return rval; /* =127, but avoids unused variable warning */
167.4440 +EOF
167.4441 +		;;
167.4442 +	    esac
167.4443 +
167.4444 +	    cat <<"EOF"
167.4445 +}
167.4446 +
167.4447 +void *
167.4448 +xmalloc (size_t num)
167.4449 +{
167.4450 +  void *p = (void *) malloc (num);
167.4451 +  if (!p)
167.4452 +    lt_fatal ("Memory exhausted");
167.4453 +
167.4454 +  return p;
167.4455 +}
167.4456 +
167.4457 +char *
167.4458 +xstrdup (const char *string)
167.4459 +{
167.4460 +  return string ? strcpy ((char *) xmalloc (strlen (string) + 1),
167.4461 +			  string) : NULL;
167.4462 +}
167.4463 +
167.4464 +const char *
167.4465 +base_name (const char *name)
167.4466 +{
167.4467 +  const char *base;
167.4468 +
167.4469 +#if defined (HAVE_DOS_BASED_FILE_SYSTEM)
167.4470 +  /* Skip over the disk name in MSDOS pathnames. */
167.4471 +  if (isalpha ((unsigned char) name[0]) && name[1] == ':')
167.4472 +    name += 2;
167.4473 +#endif
167.4474 +
167.4475 +  for (base = name; *name; name++)
167.4476 +    if (IS_DIR_SEPARATOR (*name))
167.4477 +      base = name + 1;
167.4478 +  return base;
167.4479 +}
167.4480 +
167.4481 +int
167.4482 +check_executable (const char *path)
167.4483 +{
167.4484 +  struct stat st;
167.4485 +
167.4486 +  lt_debugprintf ("(check_executable)  : %s\n",
167.4487 +		  path ? (*path ? path : "EMPTY!") : "NULL!");
167.4488 +  if ((!path) || (!*path))
167.4489 +    return 0;
167.4490 +
167.4491 +  if ((stat (path, &st) >= 0)
167.4492 +      && (st.st_mode & (S_IXUSR | S_IXGRP | S_IXOTH)))
167.4493 +    return 1;
167.4494 +  else
167.4495 +    return 0;
167.4496 +}
167.4497 +
167.4498 +int
167.4499 +make_executable (const char *path)
167.4500 +{
167.4501 +  int rval = 0;
167.4502 +  struct stat st;
167.4503 +
167.4504 +  lt_debugprintf ("(make_executable)   : %s\n",
167.4505 +		  path ? (*path ? path : "EMPTY!") : "NULL!");
167.4506 +  if ((!path) || (!*path))
167.4507 +    return 0;
167.4508 +
167.4509 +  if (stat (path, &st) >= 0)
167.4510 +    {
167.4511 +      rval = chmod (path, st.st_mode | S_IXOTH | S_IXGRP | S_IXUSR);
167.4512 +    }
167.4513 +  return rval;
167.4514 +}
167.4515 +
167.4516 +/* Searches for the full path of the wrapper.  Returns
167.4517 +   newly allocated full path name if found, NULL otherwise
167.4518 +   Does not chase symlinks, even on platforms that support them.
167.4519 +*/
167.4520 +char *
167.4521 +find_executable (const char *wrapper)
167.4522 +{
167.4523 +  int has_slash = 0;
167.4524 +  const char *p;
167.4525 +  const char *p_next;
167.4526 +  /* static buffer for getcwd */
167.4527 +  char tmp[LT_PATHMAX + 1];
167.4528 +  int tmp_len;
167.4529 +  char *concat_name;
167.4530 +
167.4531 +  lt_debugprintf ("(find_executable)   : %s\n",
167.4532 +		  wrapper ? (*wrapper ? wrapper : "EMPTY!") : "NULL!");
167.4533 +
167.4534 +  if ((wrapper == NULL) || (*wrapper == '\0'))
167.4535 +    return NULL;
167.4536 +
167.4537 +  /* Absolute path? */
167.4538 +#if defined (HAVE_DOS_BASED_FILE_SYSTEM)
167.4539 +  if (isalpha ((unsigned char) wrapper[0]) && wrapper[1] == ':')
167.4540 +    {
167.4541 +      concat_name = xstrdup (wrapper);
167.4542 +      if (check_executable (concat_name))
167.4543 +	return concat_name;
167.4544 +      XFREE (concat_name);
167.4545 +    }
167.4546 +  else
167.4547 +    {
167.4548 +#endif
167.4549 +      if (IS_DIR_SEPARATOR (wrapper[0]))
167.4550 +	{
167.4551 +	  concat_name = xstrdup (wrapper);
167.4552 +	  if (check_executable (concat_name))
167.4553 +	    return concat_name;
167.4554 +	  XFREE (concat_name);
167.4555 +	}
167.4556 +#if defined (HAVE_DOS_BASED_FILE_SYSTEM)
167.4557 +    }
167.4558 +#endif
167.4559 +
167.4560 +  for (p = wrapper; *p; p++)
167.4561 +    if (*p == '/')
167.4562 +      {
167.4563 +	has_slash = 1;
167.4564 +	break;
167.4565 +      }
167.4566 +  if (!has_slash)
167.4567 +    {
167.4568 +      /* no slashes; search PATH */
167.4569 +      const char *path = getenv ("PATH");
167.4570 +      if (path != NULL)
167.4571 +	{
167.4572 +	  for (p = path; *p; p = p_next)
167.4573 +	    {
167.4574 +	      const char *q;
167.4575 +	      size_t p_len;
167.4576 +	      for (q = p; *q; q++)
167.4577 +		if (IS_PATH_SEPARATOR (*q))
167.4578 +		  break;
167.4579 +	      p_len = q - p;
167.4580 +	      p_next = (*q == '\0' ? q : q + 1);
167.4581 +	      if (p_len == 0)
167.4582 +		{
167.4583 +		  /* empty path: current directory */
167.4584 +		  if (getcwd (tmp, LT_PATHMAX) == NULL)
167.4585 +		    lt_fatal ("getcwd failed");
167.4586 +		  tmp_len = strlen (tmp);
167.4587 +		  concat_name =
167.4588 +		    XMALLOC (char, tmp_len + 1 + strlen (wrapper) + 1);
167.4589 +		  memcpy (concat_name, tmp, tmp_len);
167.4590 +		  concat_name[tmp_len] = '/';
167.4591 +		  strcpy (concat_name + tmp_len + 1, wrapper);
167.4592 +		}
167.4593 +	      else
167.4594 +		{
167.4595 +		  concat_name =
167.4596 +		    XMALLOC (char, p_len + 1 + strlen (wrapper) + 1);
167.4597 +		  memcpy (concat_name, p, p_len);
167.4598 +		  concat_name[p_len] = '/';
167.4599 +		  strcpy (concat_name + p_len + 1, wrapper);
167.4600 +		}
167.4601 +	      if (check_executable (concat_name))
167.4602 +		return concat_name;
167.4603 +	      XFREE (concat_name);
167.4604 +	    }
167.4605 +	}
167.4606 +      /* not found in PATH; assume curdir */
167.4607 +    }
167.4608 +  /* Relative path | not found in path: prepend cwd */
167.4609 +  if (getcwd (tmp, LT_PATHMAX) == NULL)
167.4610 +    lt_fatal ("getcwd failed");
167.4611 +  tmp_len = strlen (tmp);
167.4612 +  concat_name = XMALLOC (char, tmp_len + 1 + strlen (wrapper) + 1);
167.4613 +  memcpy (concat_name, tmp, tmp_len);
167.4614 +  concat_name[tmp_len] = '/';
167.4615 +  strcpy (concat_name + tmp_len + 1, wrapper);
167.4616 +
167.4617 +  if (check_executable (concat_name))
167.4618 +    return concat_name;
167.4619 +  XFREE (concat_name);
167.4620 +  return NULL;
167.4621 +}
167.4622 +
167.4623 +char *
167.4624 +chase_symlinks (const char *pathspec)
167.4625 +{
167.4626 +#ifndef S_ISLNK
167.4627 +  return xstrdup (pathspec);
167.4628 +#else
167.4629 +  char buf[LT_PATHMAX];
167.4630 +  struct stat s;
167.4631 +  char *tmp_pathspec = xstrdup (pathspec);
167.4632 +  char *p;
167.4633 +  int has_symlinks = 0;
167.4634 +  while (strlen (tmp_pathspec) && !has_symlinks)
167.4635 +    {
167.4636 +      lt_debugprintf ("checking path component for symlinks: %s\n",
167.4637 +		      tmp_pathspec);
167.4638 +      if (lstat (tmp_pathspec, &s) == 0)
167.4639 +	{
167.4640 +	  if (S_ISLNK (s.st_mode) != 0)
167.4641 +	    {
167.4642 +	      has_symlinks = 1;
167.4643 +	      break;
167.4644 +	    }
167.4645 +
167.4646 +	  /* search backwards for last DIR_SEPARATOR */
167.4647 +	  p = tmp_pathspec + strlen (tmp_pathspec) - 1;
167.4648 +	  while ((p > tmp_pathspec) && (!IS_DIR_SEPARATOR (*p)))
167.4649 +	    p--;
167.4650 +	  if ((p == tmp_pathspec) && (!IS_DIR_SEPARATOR (*p)))
167.4651 +	    {
167.4652 +	      /* no more DIR_SEPARATORS left */
167.4653 +	      break;
167.4654 +	    }
167.4655 +	  *p = '\0';
167.4656 +	}
167.4657 +      else
167.4658 +	{
167.4659 +	  char *errstr = strerror (errno);
167.4660 +	  lt_fatal ("Error accessing file %s (%s)", tmp_pathspec, errstr);
167.4661 +	}
167.4662 +    }
167.4663 +  XFREE (tmp_pathspec);
167.4664 +
167.4665 +  if (!has_symlinks)
167.4666 +    {
167.4667 +      return xstrdup (pathspec);
167.4668 +    }
167.4669 +
167.4670 +  tmp_pathspec = realpath (pathspec, buf);
167.4671 +  if (tmp_pathspec == 0)
167.4672 +    {
167.4673 +      lt_fatal ("Could not follow symlinks for %s", pathspec);
167.4674 +    }
167.4675 +  return xstrdup (tmp_pathspec);
167.4676 +#endif
167.4677 +}
167.4678 +
167.4679 +char *
167.4680 +strendzap (char *str, const char *pat)
167.4681 +{
167.4682 +  size_t len, patlen;
167.4683 +
167.4684 +  assert (str != NULL);
167.4685 +  assert (pat != NULL);
167.4686 +
167.4687 +  len = strlen (str);
167.4688 +  patlen = strlen (pat);
167.4689 +
167.4690 +  if (patlen <= len)
167.4691 +    {
167.4692 +      str += len - patlen;
167.4693 +      if (strcmp (str, pat) == 0)
167.4694 +	*str = '\0';
167.4695 +    }
167.4696 +  return str;
167.4697 +}
167.4698 +
167.4699 +void
167.4700 +lt_debugprintf (const char *fmt, ...)
167.4701 +{
167.4702 +  va_list args;
167.4703 +  if (lt_debug)
167.4704 +    {
167.4705 +      va_start (args, fmt);
167.4706 +      (void) vfprintf (stderr, fmt, args);
167.4707 +      va_end (args);
167.4708 +    }
167.4709 +}
167.4710 +
167.4711 +static void
167.4712 +lt_error_core (int exit_status, const char *mode,
167.4713 +	       const char *message, va_list ap)
167.4714 +{
167.4715 +  fprintf (stderr, "%s: %s: ", program_name, mode);
167.4716 +  vfprintf (stderr, message, ap);
167.4717 +  fprintf (stderr, ".\n");
167.4718 +
167.4719 +  if (exit_status >= 0)
167.4720 +    exit (exit_status);
167.4721 +}
167.4722 +
167.4723 +void
167.4724 +lt_fatal (const char *message, ...)
167.4725 +{
167.4726 +  va_list ap;
167.4727 +  va_start (ap, message);
167.4728 +  lt_error_core (EXIT_FAILURE, "FATAL", message, ap);
167.4729 +  va_end (ap);
167.4730 +}
167.4731 +
167.4732 +void
167.4733 +lt_setenv (const char *name, const char *value)
167.4734 +{
167.4735 +  lt_debugprintf ("(lt_setenv) setting '%s' to '%s'\n",
167.4736 +                  (name ? name : "<NULL>"),
167.4737 +                  (value ? value : "<NULL>"));
167.4738 +  {
167.4739 +#ifdef HAVE_SETENV
167.4740 +    /* always make a copy, for consistency with !HAVE_SETENV */
167.4741 +    char *str = xstrdup (value);
167.4742 +    setenv (name, str, 1);
167.4743 +#else
167.4744 +    int len = strlen (name) + 1 + strlen (value) + 1;
167.4745 +    char *str = XMALLOC (char, len);
167.4746 +    sprintf (str, "%s=%s", name, value);
167.4747 +    if (putenv (str) != EXIT_SUCCESS)
167.4748 +      {
167.4749 +        XFREE (str);
167.4750 +      }
167.4751 +#endif
167.4752 +  }
167.4753 +}
167.4754 +
167.4755 +char *
167.4756 +lt_extend_str (const char *orig_value, const char *add, int to_end)
167.4757 +{
167.4758 +  char *new_value;
167.4759 +  if (orig_value && *orig_value)
167.4760 +    {
167.4761 +      int orig_value_len = strlen (orig_value);
167.4762 +      int add_len = strlen (add);
167.4763 +      new_value = XMALLOC (char, add_len + orig_value_len + 1);
167.4764 +      if (to_end)
167.4765 +        {
167.4766 +          strcpy (new_value, orig_value);
167.4767 +          strcpy (new_value + orig_value_len, add);
167.4768 +        }
167.4769 +      else
167.4770 +        {
167.4771 +          strcpy (new_value, add);
167.4772 +          strcpy (new_value + add_len, orig_value);
167.4773 +        }
167.4774 +    }
167.4775 +  else
167.4776 +    {
167.4777 +      new_value = xstrdup (add);
167.4778 +    }
167.4779 +  return new_value;
167.4780 +}
167.4781 +
167.4782 +void
167.4783 +lt_update_exe_path (const char *name, const char *value)
167.4784 +{
167.4785 +  lt_debugprintf ("(lt_update_exe_path) modifying '%s' by prepending '%s'\n",
167.4786 +                  (name ? name : "<NULL>"),
167.4787 +                  (value ? value : "<NULL>"));
167.4788 +
167.4789 +  if (name && *name && value && *value)
167.4790 +    {
167.4791 +      char *new_value = lt_extend_str (getenv (name), value, 0);
167.4792 +      /* some systems can't cope with a ':'-terminated path #' */
167.4793 +      int len = strlen (new_value);
167.4794 +      while (((len = strlen (new_value)) > 0) && IS_PATH_SEPARATOR (new_value[len-1]))
167.4795 +        {
167.4796 +          new_value[len-1] = '\0';
167.4797 +        }
167.4798 +      lt_setenv (name, new_value);
167.4799 +      XFREE (new_value);
167.4800 +    }
167.4801 +}
167.4802 +
167.4803 +void
167.4804 +lt_update_lib_path (const char *name, const char *value)
167.4805 +{
167.4806 +  lt_debugprintf ("(lt_update_lib_path) modifying '%s' by prepending '%s'\n",
167.4807 +                  (name ? name : "<NULL>"),
167.4808 +                  (value ? value : "<NULL>"));
167.4809 +
167.4810 +  if (name && *name && value && *value)
167.4811 +    {
167.4812 +      char *new_value = lt_extend_str (getenv (name), value, 0);
167.4813 +      lt_setenv (name, new_value);
167.4814 +      XFREE (new_value);
167.4815 +    }
167.4816 +}
167.4817 +
167.4818 +EOF
167.4819 +	    case $host_os in
167.4820 +	      mingw*)
167.4821 +		cat <<"EOF"
167.4822 +
167.4823 +/* Prepares an argument vector before calling spawn().
167.4824 +   Note that spawn() does not by itself call the command interpreter
167.4825 +     (getenv ("COMSPEC") != NULL ? getenv ("COMSPEC") :
167.4826 +      ({ OSVERSIONINFO v; v.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
167.4827 +         GetVersionEx(&v);
167.4828 +         v.dwPlatformId == VER_PLATFORM_WIN32_NT;
167.4829 +      }) ? "cmd.exe" : "command.com").
167.4830 +   Instead it simply concatenates the arguments, separated by ' ', and calls
167.4831 +   CreateProcess().  We must quote the arguments since Win32 CreateProcess()
167.4832 +   interprets characters like ' ', '\t', '\\', '"' (but not '<' and '>') in a
167.4833 +   special way:
167.4834 +   - Space and tab are interpreted as delimiters. They are not treated as
167.4835 +     delimiters if they are surrounded by double quotes: "...".
167.4836 +   - Unescaped double quotes are removed from the input. Their only effect is
167.4837 +     that within double quotes, space and tab are treated like normal
167.4838 +     characters.
167.4839 +   - Backslashes not followed by double quotes are not special.
167.4840 +   - But 2*n+1 backslashes followed by a double quote become
167.4841 +     n backslashes followed by a double quote (n >= 0):
167.4842 +       \" -> "
167.4843 +       \\\" -> \"
167.4844 +       \\\\\" -> \\"
167.4845 + */
167.4846 +#define SHELL_SPECIAL_CHARS "\"\\ \001\002\003\004\005\006\007\010\011\012\013\014\015\016\017\020\021\022\023\024\025\026\027\030\031\032\033\034\035\036\037"
167.4847 +#define SHELL_SPACE_CHARS " \001\002\003\004\005\006\007\010\011\012\013\014\015\016\017\020\021\022\023\024\025\026\027\030\031\032\033\034\035\036\037"
167.4848 +char **
167.4849 +prepare_spawn (char **argv)
167.4850 +{
167.4851 +  size_t argc;
167.4852 +  char **new_argv;
167.4853 +  size_t i;
167.4854 +
167.4855 +  /* Count number of arguments.  */
167.4856 +  for (argc = 0; argv[argc] != NULL; argc++)
167.4857 +    ;
167.4858 +
167.4859 +  /* Allocate new argument vector.  */
167.4860 +  new_argv = XMALLOC (char *, argc + 1);
167.4861 +
167.4862 +  /* Put quoted arguments into the new argument vector.  */
167.4863 +  for (i = 0; i < argc; i++)
167.4864 +    {
167.4865 +      const char *string = argv[i];
167.4866 +
167.4867 +      if (string[0] == '\0')
167.4868 +	new_argv[i] = xstrdup ("\"\"");
167.4869 +      else if (strpbrk (string, SHELL_SPECIAL_CHARS) != NULL)
167.4870 +	{
167.4871 +	  int quote_around = (strpbrk (string, SHELL_SPACE_CHARS) != NULL);
167.4872 +	  size_t length;
167.4873 +	  unsigned int backslashes;
167.4874 +	  const char *s;
167.4875 +	  char *quoted_string;
167.4876 +	  char *p;
167.4877 +
167.4878 +	  length = 0;
167.4879 +	  backslashes = 0;
167.4880 +	  if (quote_around)
167.4881 +	    length++;
167.4882 +	  for (s = string; *s != '\0'; s++)
167.4883 +	    {
167.4884 +	      char c = *s;
167.4885 +	      if (c == '"')
167.4886 +		length += backslashes + 1;
167.4887 +	      length++;
167.4888 +	      if (c == '\\')
167.4889 +		backslashes++;
167.4890 +	      else
167.4891 +		backslashes = 0;
167.4892 +	    }
167.4893 +	  if (quote_around)
167.4894 +	    length += backslashes + 1;
167.4895 +
167.4896 +	  quoted_string = XMALLOC (char, length + 1);
167.4897 +
167.4898 +	  p = quoted_string;
167.4899 +	  backslashes = 0;
167.4900 +	  if (quote_around)
167.4901 +	    *p++ = '"';
167.4902 +	  for (s = string; *s != '\0'; s++)
167.4903 +	    {
167.4904 +	      char c = *s;
167.4905 +	      if (c == '"')
167.4906 +		{
167.4907 +		  unsigned int j;
167.4908 +		  for (j = backslashes + 1; j > 0; j--)
167.4909 +		    *p++ = '\\';
167.4910 +		}
167.4911 +	      *p++ = c;
167.4912 +	      if (c == '\\')
167.4913 +		backslashes++;
167.4914 +	      else
167.4915 +		backslashes = 0;
167.4916 +	    }
167.4917 +	  if (quote_around)
167.4918 +	    {
167.4919 +	      unsigned int j;
167.4920 +	      for (j = backslashes; j > 0; j--)
167.4921 +		*p++ = '\\';
167.4922 +	      *p++ = '"';
167.4923 +	    }
167.4924 +	  *p = '\0';
167.4925 +
167.4926 +	  new_argv[i] = quoted_string;
167.4927 +	}
167.4928 +      else
167.4929 +	new_argv[i] = (char *) string;
167.4930 +    }
167.4931 +  new_argv[argc] = NULL;
167.4932 +
167.4933 +  return new_argv;
167.4934 +}
167.4935 +EOF
167.4936 +		;;
167.4937 +	    esac
167.4938 +
167.4939 +            cat <<"EOF"
167.4940 +void lt_dump_script (FILE* f)
167.4941 +{
167.4942 +EOF
167.4943 +	    func_emit_wrapper yes |
167.4944 +              $SED -e 's/\([\\"]\)/\\\1/g' \
167.4945 +	           -e 's/^/  fputs ("/' -e 's/$/\\n", f);/'
167.4946 +
167.4947 +            cat <<"EOF"
167.4948 +}
167.4949 +EOF
167.4950 +}
167.4951 +# end: func_emit_cwrapperexe_src
167.4952 +
167.4953 +# func_emit_exe_manifest
167.4954 +# emit a Win32 UAC manifest for executable on stdout
167.4955 +# Must ONLY be called from within func_mode_link because
167.4956 +# it depends on a number of variable set therein.
167.4957 +func_emit_exe_manifest ()
167.4958 +{
167.4959 +    cat <<EOF
167.4960 +<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
167.4961 +<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
167.4962 +  <assemblyIdentity version="1.0.0.0"
167.4963 +EOF
167.4964 +
167.4965 +  case $host in
167.4966 +  i?86-*-* )   echo '     processorArchitecture="x86"' ;;
167.4967 +  ia64-*-* )   echo '     processorArchitecture="ia64"' ;;
167.4968 +  x86_64-*-* ) echo '     processorArchitecture="amd64"' ;;
167.4969 +  *)           echo '     processorArchitecture="*"' ;;
167.4970 +  esac
167.4971 +
167.4972 +    cat <<EOF
167.4973 +     name="$host_os.$PROGRAM.$outputname"
167.4974 +     type="win32"/>
167.4975 +
167.4976 +  <!-- Identify the application security requirements. -->
167.4977 +  <trustInfo xmlns="urn:schemas-microsoft-com:asm.v3">
167.4978 +    <security>
167.4979 +      <requestedPrivileges>
167.4980 +        <requestedExecutionLevel level="asInvoker" uiAccess="false"/>
167.4981 +      </requestedPrivileges>
167.4982 +    </security>
167.4983 +  </trustInfo>
167.4984 +</assembly>
167.4985 +EOF
167.4986 +}
167.4987 +
167.4988 +# func_win32_import_lib_p ARG
167.4989 +# True if ARG is an import lib, as indicated by $file_magic_cmd
167.4990 +func_win32_import_lib_p ()
167.4991 +{
167.4992 +    $opt_debug
167.4993 +    case `eval $file_magic_cmd \"\$1\" 2>/dev/null | $SED -e 10q` in
167.4994 +    *import*) : ;;
167.4995 +    *) false ;;
167.4996 +    esac
167.4997 +}
167.4998 +
167.4999 +# func_mode_link arg...
167.5000 +func_mode_link ()
167.5001 +{
167.5002 +    $opt_debug
167.5003 +    case $host in
167.5004 +    *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*)
167.5005 +      # It is impossible to link a dll without this setting, and
167.5006 +      # we shouldn't force the makefile maintainer to figure out
167.5007 +      # which system we are compiling for in order to pass an extra
167.5008 +      # flag for every libtool invocation.
167.5009 +      # allow_undefined=no
167.5010 +
167.5011 +      # FIXME: Unfortunately, there are problems with the above when trying
167.5012 +      # to make a dll which has undefined symbols, in which case not
167.5013 +      # even a static library is built.  For now, we need to specify
167.5014 +      # -no-undefined on the libtool link line when we can be certain
167.5015 +      # that all symbols are satisfied, otherwise we get a static library.
167.5016 +      allow_undefined=yes
167.5017 +      ;;
167.5018 +    *)
167.5019 +      allow_undefined=yes
167.5020 +      ;;
167.5021 +    esac
167.5022 +    libtool_args=$nonopt
167.5023 +    base_compile="$nonopt $@"
167.5024 +    compile_command=$nonopt
167.5025 +    finalize_command=$nonopt
167.5026 +
167.5027 +    compile_rpath=
167.5028 +    finalize_rpath=
167.5029 +    compile_shlibpath=
167.5030 +    finalize_shlibpath=
167.5031 +    convenience=
167.5032 +    old_convenience=
167.5033 +    deplibs=
167.5034 +    old_deplibs=
167.5035 +    compiler_flags=
167.5036 +    linker_flags=
167.5037 +    dllsearchpath=
167.5038 +    lib_search_path=`pwd`
167.5039 +    inst_prefix_dir=
167.5040 +    new_inherited_linker_flags=
167.5041 +
167.5042 +    avoid_version=no
167.5043 +    bindir=
167.5044 +    dlfiles=
167.5045 +    dlprefiles=
167.5046 +    dlself=no
167.5047 +    export_dynamic=no
167.5048 +    export_symbols=
167.5049 +    export_symbols_regex=
167.5050 +    generated=
167.5051 +    libobjs=
167.5052 +    ltlibs=
167.5053 +    module=no
167.5054 +    no_install=no
167.5055 +    objs=
167.5056 +    non_pic_objects=
167.5057 +    precious_files_regex=
167.5058 +    prefer_static_libs=no
167.5059 +    preload=no
167.5060 +    prev=
167.5061 +    prevarg=
167.5062 +    release=
167.5063 +    rpath=
167.5064 +    xrpath=
167.5065 +    perm_rpath=
167.5066 +    temp_rpath=
167.5067 +    thread_safe=no
167.5068 +    vinfo=
167.5069 +    vinfo_number=no
167.5070 +    weak_libs=
167.5071 +    single_module="${wl}-single_module"
167.5072 +    func_infer_tag $base_compile
167.5073 +
167.5074 +    # We need to know -static, to get the right output filenames.
167.5075 +    for arg
167.5076 +    do
167.5077 +      case $arg in
167.5078 +      -shared)
167.5079 +	test "$build_libtool_libs" != yes && \
167.5080 +	  func_fatal_configuration "can not build a shared library"
167.5081 +	build_old_libs=no
167.5082 +	break
167.5083 +	;;
167.5084 +      -all-static | -static | -static-libtool-libs)
167.5085 +	case $arg in
167.5086 +	-all-static)
167.5087 +	  if test "$build_libtool_libs" = yes && test -z "$link_static_flag"; then
167.5088 +	    func_warning "complete static linking is impossible in this configuration"
167.5089 +	  fi
167.5090 +	  if test -n "$link_static_flag"; then
167.5091 +	    dlopen_self=$dlopen_self_static
167.5092 +	  fi
167.5093 +	  prefer_static_libs=yes
167.5094 +	  ;;
167.5095 +	-static)
167.5096 +	  if test -z "$pic_flag" && test -n "$link_static_flag"; then
167.5097 +	    dlopen_self=$dlopen_self_static
167.5098 +	  fi
167.5099 +	  prefer_static_libs=built
167.5100 +	  ;;
167.5101 +	-static-libtool-libs)
167.5102 +	  if test -z "$pic_flag" && test -n "$link_static_flag"; then
167.5103 +	    dlopen_self=$dlopen_self_static
167.5104 +	  fi
167.5105 +	  prefer_static_libs=yes
167.5106 +	  ;;
167.5107 +	esac
167.5108 +	build_libtool_libs=no
167.5109 +	build_old_libs=yes
167.5110 +	break
167.5111 +	;;
167.5112 +      esac
167.5113 +    done
167.5114 +
167.5115 +    # See if our shared archives depend on static archives.
167.5116 +    test -n "$old_archive_from_new_cmds" && build_old_libs=yes
167.5117 +
167.5118 +    # Go through the arguments, transforming them on the way.
167.5119 +    while test "$#" -gt 0; do
167.5120 +      arg="$1"
167.5121 +      shift
167.5122 +      func_quote_for_eval "$arg"
167.5123 +      qarg=$func_quote_for_eval_unquoted_result
167.5124 +      func_append libtool_args " $func_quote_for_eval_result"
167.5125 +
167.5126 +      # If the previous option needs an argument, assign it.
167.5127 +      if test -n "$prev"; then
167.5128 +	case $prev in
167.5129 +	output)
167.5130 +	  func_append compile_command " @OUTPUT@"
167.5131 +	  func_append finalize_command " @OUTPUT@"
167.5132 +	  ;;
167.5133 +	esac
167.5134 +
167.5135 +	case $prev in
167.5136 +	bindir)
167.5137 +	  bindir="$arg"
167.5138 +	  prev=
167.5139 +	  continue
167.5140 +	  ;;
167.5141 +	dlfiles|dlprefiles)
167.5142 +	  if test "$preload" = no; then
167.5143 +	    # Add the symbol object into the linking commands.
167.5144 +	    func_append compile_command " @SYMFILE@"
167.5145 +	    func_append finalize_command " @SYMFILE@"
167.5146 +	    preload=yes
167.5147 +	  fi
167.5148 +	  case $arg in
167.5149 +	  *.la | *.lo) ;;  # We handle these cases below.
167.5150 +	  force)
167.5151 +	    if test "$dlself" = no; then
167.5152 +	      dlself=needless
167.5153 +	      export_dynamic=yes
167.5154 +	    fi
167.5155 +	    prev=
167.5156 +	    continue
167.5157 +	    ;;
167.5158 +	  self)
167.5159 +	    if test "$prev" = dlprefiles; then
167.5160 +	      dlself=yes
167.5161 +	    elif test "$prev" = dlfiles && test "$dlopen_self" != yes; then
167.5162 +	      dlself=yes
167.5163 +	    else
167.5164 +	      dlself=needless
167.5165 +	      export_dynamic=yes
167.5166 +	    fi
167.5167 +	    prev=
167.5168 +	    continue
167.5169 +	    ;;
167.5170 +	  *)
167.5171 +	    if test "$prev" = dlfiles; then
167.5172 +	      dlfiles="$dlfiles $arg"
167.5173 +	    else
167.5174 +	      dlprefiles="$dlprefiles $arg"
167.5175 +	    fi
167.5176 +	    prev=
167.5177 +	    continue
167.5178 +	    ;;
167.5179 +	  esac
167.5180 +	  ;;
167.5181 +	expsyms)
167.5182 +	  export_symbols="$arg"
167.5183 +	  test -f "$arg" \
167.5184 +	    || func_fatal_error "symbol file \`$arg' does not exist"
167.5185 +	  prev=
167.5186 +	  continue
167.5187 +	  ;;
167.5188 +	expsyms_regex)
167.5189 +	  export_symbols_regex="$arg"
167.5190 +	  prev=
167.5191 +	  continue
167.5192 +	  ;;
167.5193 +	framework)
167.5194 +	  case $host in
167.5195 +	    *-*-darwin*)
167.5196 +	      case "$deplibs " in
167.5197 +		*" $qarg.ltframework "*) ;;
167.5198 +		*) deplibs="$deplibs $qarg.ltframework" # this is fixed later
167.5199 +		   ;;
167.5200 +	      esac
167.5201 +	      ;;
167.5202 +	  esac
167.5203 +	  prev=
167.5204 +	  continue
167.5205 +	  ;;
167.5206 +	inst_prefix)
167.5207 +	  inst_prefix_dir="$arg"
167.5208 +	  prev=
167.5209 +	  continue
167.5210 +	  ;;
167.5211 +	objectlist)
167.5212 +	  if test -f "$arg"; then
167.5213 +	    save_arg=$arg
167.5214 +	    moreargs=
167.5215 +	    for fil in `cat "$save_arg"`
167.5216 +	    do
167.5217 +#	      moreargs="$moreargs $fil"
167.5218 +	      arg=$fil
167.5219 +	      # A libtool-controlled object.
167.5220 +
167.5221 +	      # Check to see that this really is a libtool object.
167.5222 +	      if func_lalib_unsafe_p "$arg"; then
167.5223 +		pic_object=
167.5224 +		non_pic_object=
167.5225 +
167.5226 +		# Read the .lo file
167.5227 +		func_source "$arg"
167.5228 +
167.5229 +		if test -z "$pic_object" ||
167.5230 +		   test -z "$non_pic_object" ||
167.5231 +		   test "$pic_object" = none &&
167.5232 +		   test "$non_pic_object" = none; then
167.5233 +		  func_fatal_error "cannot find name of object for \`$arg'"
167.5234 +		fi
167.5235 +
167.5236 +		# Extract subdirectory from the argument.
167.5237 +		func_dirname "$arg" "/" ""
167.5238 +		xdir="$func_dirname_result"
167.5239 +
167.5240 +		if test "$pic_object" != none; then
167.5241 +		  # Prepend the subdirectory the object is found in.
167.5242 +		  pic_object="$xdir$pic_object"
167.5243 +
167.5244 +		  if test "$prev" = dlfiles; then
167.5245 +		    if test "$build_libtool_libs" = yes && test "$dlopen_support" = yes; then
167.5246 +		      dlfiles="$dlfiles $pic_object"
167.5247 +		      prev=
167.5248 +		      continue
167.5249 +		    else
167.5250 +		      # If libtool objects are unsupported, then we need to preload.
167.5251 +		      prev=dlprefiles
167.5252 +		    fi
167.5253 +		  fi
167.5254 +
167.5255 +		  # CHECK ME:  I think I busted this.  -Ossama
167.5256 +		  if test "$prev" = dlprefiles; then
167.5257 +		    # Preload the old-style object.
167.5258 +		    dlprefiles="$dlprefiles $pic_object"
167.5259 +		    prev=
167.5260 +		  fi
167.5261 +
167.5262 +		  # A PIC object.
167.5263 +		  func_append libobjs " $pic_object"
167.5264 +		  arg="$pic_object"
167.5265 +		fi
167.5266 +
167.5267 +		# Non-PIC object.
167.5268 +		if test "$non_pic_object" != none; then
167.5269 +		  # Prepend the subdirectory the object is found in.
167.5270 +		  non_pic_object="$xdir$non_pic_object"
167.5271 +
167.5272 +		  # A standard non-PIC object
167.5273 +		  func_append non_pic_objects " $non_pic_object"
167.5274 +		  if test -z "$pic_object" || test "$pic_object" = none ; then
167.5275 +		    arg="$non_pic_object"
167.5276 +		  fi
167.5277 +		else
167.5278 +		  # If the PIC object exists, use it instead.
167.5279 +		  # $xdir was prepended to $pic_object above.
167.5280 +		  non_pic_object="$pic_object"
167.5281 +		  func_append non_pic_objects " $non_pic_object"
167.5282 +		fi
167.5283 +	      else
167.5284 +		# Only an error if not doing a dry-run.
167.5285 +		if $opt_dry_run; then
167.5286 +		  # Extract subdirectory from the argument.
167.5287 +		  func_dirname "$arg" "/" ""
167.5288 +		  xdir="$func_dirname_result"
167.5289 +
167.5290 +		  func_lo2o "$arg"
167.5291 +		  pic_object=$xdir$objdir/$func_lo2o_result
167.5292 +		  non_pic_object=$xdir$func_lo2o_result
167.5293 +		  func_append libobjs " $pic_object"
167.5294 +		  func_append non_pic_objects " $non_pic_object"
167.5295 +	        else
167.5296 +		  func_fatal_error "\`$arg' is not a valid libtool object"
167.5297 +		fi
167.5298 +	      fi
167.5299 +	    done
167.5300 +	  else
167.5301 +	    func_fatal_error "link input file \`$arg' does not exist"
167.5302 +	  fi
167.5303 +	  arg=$save_arg
167.5304 +	  prev=
167.5305 +	  continue
167.5306 +	  ;;
167.5307 +	precious_regex)
167.5308 +	  precious_files_regex="$arg"
167.5309 +	  prev=
167.5310 +	  continue
167.5311 +	  ;;
167.5312 +	release)
167.5313 +	  release="-$arg"
167.5314 +	  prev=
167.5315 +	  continue
167.5316 +	  ;;
167.5317 +	rpath | xrpath)
167.5318 +	  # We need an absolute path.
167.5319 +	  case $arg in
167.5320 +	  [\\/]* | [A-Za-z]:[\\/]*) ;;
167.5321 +	  *)
167.5322 +	    func_fatal_error "only absolute run-paths are allowed"
167.5323 +	    ;;
167.5324 +	  esac
167.5325 +	  if test "$prev" = rpath; then
167.5326 +	    case "$rpath " in
167.5327 +	    *" $arg "*) ;;
167.5328 +	    *) rpath="$rpath $arg" ;;
167.5329 +	    esac
167.5330 +	  else
167.5331 +	    case "$xrpath " in
167.5332 +	    *" $arg "*) ;;
167.5333 +	    *) xrpath="$xrpath $arg" ;;
167.5334 +	    esac
167.5335 +	  fi
167.5336 +	  prev=
167.5337 +	  continue
167.5338 +	  ;;
167.5339 +	shrext)
167.5340 +	  shrext_cmds="$arg"
167.5341 +	  prev=
167.5342 +	  continue
167.5343 +	  ;;
167.5344 +	weak)
167.5345 +	  weak_libs="$weak_libs $arg"
167.5346 +	  prev=
167.5347 +	  continue
167.5348 +	  ;;
167.5349 +	xcclinker)
167.5350 +	  linker_flags="$linker_flags $qarg"
167.5351 +	  compiler_flags="$compiler_flags $qarg"
167.5352 +	  prev=
167.5353 +	  func_append compile_command " $qarg"
167.5354 +	  func_append finalize_command " $qarg"
167.5355 +	  continue
167.5356 +	  ;;
167.5357 +	xcompiler)
167.5358 +	  compiler_flags="$compiler_flags $qarg"
167.5359 +	  prev=
167.5360 +	  func_append compile_command " $qarg"
167.5361 +	  func_append finalize_command " $qarg"
167.5362 +	  continue
167.5363 +	  ;;
167.5364 +	xlinker)
167.5365 +	  linker_flags="$linker_flags $qarg"
167.5366 +	  compiler_flags="$compiler_flags $wl$qarg"
167.5367 +	  prev=
167.5368 +	  func_append compile_command " $wl$qarg"
167.5369 +	  func_append finalize_command " $wl$qarg"
167.5370 +	  continue
167.5371 +	  ;;
167.5372 +	*)
167.5373 +	  eval "$prev=\"\$arg\""
167.5374 +	  prev=
167.5375 +	  continue
167.5376 +	  ;;
167.5377 +	esac
167.5378 +      fi # test -n "$prev"
167.5379 +
167.5380 +      prevarg="$arg"
167.5381 +
167.5382 +      case $arg in
167.5383 +      -all-static)
167.5384 +	if test -n "$link_static_flag"; then
167.5385 +	  # See comment for -static flag below, for more details.
167.5386 +	  func_append compile_command " $link_static_flag"
167.5387 +	  func_append finalize_command " $link_static_flag"
167.5388 +	fi
167.5389 +	continue
167.5390 +	;;
167.5391 +
167.5392 +      -allow-undefined)
167.5393 +	# FIXME: remove this flag sometime in the future.
167.5394 +	func_fatal_error "\`-allow-undefined' must not be used because it is the default"
167.5395 +	;;
167.5396 +
167.5397 +      -avoid-version)
167.5398 +	avoid_version=yes
167.5399 +	continue
167.5400 +	;;
167.5401 +
167.5402 +      -bindir)
167.5403 +	prev=bindir
167.5404 +	continue
167.5405 +	;;
167.5406 +
167.5407 +      -dlopen)
167.5408 +	prev=dlfiles
167.5409 +	continue
167.5410 +	;;
167.5411 +
167.5412 +      -dlpreopen)
167.5413 +	prev=dlprefiles
167.5414 +	continue
167.5415 +	;;
167.5416 +
167.5417 +      -export-dynamic)
167.5418 +	export_dynamic=yes
167.5419 +	continue
167.5420 +	;;
167.5421 +
167.5422 +      -export-symbols | -export-symbols-regex)
167.5423 +	if test -n "$export_symbols" || test -n "$export_symbols_regex"; then
167.5424 +	  func_fatal_error "more than one -exported-symbols argument is not allowed"
167.5425 +	fi
167.5426 +	if test "X$arg" = "X-export-symbols"; then
167.5427 +	  prev=expsyms
167.5428 +	else
167.5429 +	  prev=expsyms_regex
167.5430 +	fi
167.5431 +	continue
167.5432 +	;;
167.5433 +
167.5434 +      -framework)
167.5435 +	prev=framework
167.5436 +	continue
167.5437 +	;;
167.5438 +
167.5439 +      -inst-prefix-dir)
167.5440 +	prev=inst_prefix
167.5441 +	continue
167.5442 +	;;
167.5443 +
167.5444 +      # The native IRIX linker understands -LANG:*, -LIST:* and -LNO:*
167.5445 +      # so, if we see these flags be careful not to treat them like -L
167.5446 +      -L[A-Z][A-Z]*:*)
167.5447 +	case $with_gcc/$host in
167.5448 +	no/*-*-irix* | /*-*-irix*)
167.5449 +	  func_append compile_command " $arg"
167.5450 +	  func_append finalize_command " $arg"
167.5451 +	  ;;
167.5452 +	esac
167.5453 +	continue
167.5454 +	;;
167.5455 +
167.5456 +      -L*)
167.5457 +	func_stripname '-L' '' "$arg"
167.5458 +	dir=$func_stripname_result
167.5459 +	if test -z "$dir"; then
167.5460 +	  if test "$#" -gt 0; then
167.5461 +	    func_fatal_error "require no space between \`-L' and \`$1'"
167.5462 +	  else
167.5463 +	    func_fatal_error "need path for \`-L' option"
167.5464 +	  fi
167.5465 +	fi
167.5466 +	# We need an absolute path.
167.5467 +	case $dir in
167.5468 +	[\\/]* | [A-Za-z]:[\\/]*) ;;
167.5469 +	*)
167.5470 +	  absdir=`cd "$dir" && pwd`
167.5471 +	  test -z "$absdir" && \
167.5472 +	    func_fatal_error "cannot determine absolute directory name of \`$dir'"
167.5473 +	  dir="$absdir"
167.5474 +	  ;;
167.5475 +	esac
167.5476 +	case "$deplibs " in
167.5477 +	*" -L$dir "*) ;;
167.5478 +	*)
167.5479 +	  deplibs="$deplibs -L$dir"
167.5480 +	  lib_search_path="$lib_search_path $dir"
167.5481 +	  ;;
167.5482 +	esac
167.5483 +	case $host in
167.5484 +	*-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*)
167.5485 +	  testbindir=`$ECHO "$dir" | $SED 's*/lib$*/bin*'`
167.5486 +	  case :$dllsearchpath: in
167.5487 +	  *":$dir:"*) ;;
167.5488 +	  ::) dllsearchpath=$dir;;
167.5489 +	  *) dllsearchpath="$dllsearchpath:$dir";;
167.5490 +	  esac
167.5491 +	  case :$dllsearchpath: in
167.5492 +	  *":$testbindir:"*) ;;
167.5493 +	  ::) dllsearchpath=$testbindir;;
167.5494 +	  *) dllsearchpath="$dllsearchpath:$testbindir";;
167.5495 +	  esac
167.5496 +	  ;;
167.5497 +	esac
167.5498 +	continue
167.5499 +	;;
167.5500 +
167.5501 +      -l*)
167.5502 +	if test "X$arg" = "X-lc" || test "X$arg" = "X-lm"; then
167.5503 +	  case $host in
167.5504 +	  *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-beos* | *-cegcc* | *-*-haiku*)
167.5505 +	    # These systems don't actually have a C or math library (as such)
167.5506 +	    continue
167.5507 +	    ;;
167.5508 +	  *-*-os2*)
167.5509 +	    # These systems don't actually have a C library (as such)
167.5510 +	    test "X$arg" = "X-lc" && continue
167.5511 +	    ;;
167.5512 +	  *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*)
167.5513 +	    # Do not include libc due to us having libc/libc_r.
167.5514 +	    test "X$arg" = "X-lc" && continue
167.5515 +	    ;;
167.5516 +	  *-*-rhapsody* | *-*-darwin1.[012])
167.5517 +	    # Rhapsody C and math libraries are in the System framework
167.5518 +	    deplibs="$deplibs System.ltframework"
167.5519 +	    continue
167.5520 +	    ;;
167.5521 +	  *-*-sco3.2v5* | *-*-sco5v6*)
167.5522 +	    # Causes problems with __ctype
167.5523 +	    test "X$arg" = "X-lc" && continue
167.5524 +	    ;;
167.5525 +	  *-*-sysv4.2uw2* | *-*-sysv5* | *-*-unixware* | *-*-OpenUNIX*)
167.5526 +	    # Compiler inserts libc in the correct place for threads to work
167.5527 +	    test "X$arg" = "X-lc" && continue
167.5528 +	    ;;
167.5529 +	  esac
167.5530 +	elif test "X$arg" = "X-lc_r"; then
167.5531 +	 case $host in
167.5532 +	 *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*)
167.5533 +	   # Do not include libc_r directly, use -pthread flag.
167.5534 +	   continue
167.5535 +	   ;;
167.5536 +	 esac
167.5537 +	fi
167.5538 +	deplibs="$deplibs $arg"
167.5539 +	continue
167.5540 +	;;
167.5541 +
167.5542 +      -module)
167.5543 +	module=yes
167.5544 +	continue
167.5545 +	;;
167.5546 +
167.5547 +      # Tru64 UNIX uses -model [arg] to determine the layout of C++
167.5548 +      # classes, name mangling, and exception handling.
167.5549 +      # Darwin uses the -arch flag to determine output architecture.
167.5550 +      -model|-arch|-isysroot)
167.5551 +	compiler_flags="$compiler_flags $arg"
167.5552 +	func_append compile_command " $arg"
167.5553 +	func_append finalize_command " $arg"
167.5554 +	prev=xcompiler
167.5555 +	continue
167.5556 +	;;
167.5557 +
167.5558 +      -mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe|-threads)
167.5559 +	compiler_flags="$compiler_flags $arg"
167.5560 +	func_append compile_command " $arg"
167.5561 +	func_append finalize_command " $arg"
167.5562 +	case "$new_inherited_linker_flags " in
167.5563 +	    *" $arg "*) ;;
167.5564 +	    * ) new_inherited_linker_flags="$new_inherited_linker_flags $arg" ;;
167.5565 +	esac
167.5566 +	continue
167.5567 +	;;
167.5568 +
167.5569 +      -multi_module)
167.5570 +	single_module="${wl}-multi_module"
167.5571 +	continue
167.5572 +	;;
167.5573 +
167.5574 +      -no-fast-install)
167.5575 +	fast_install=no
167.5576 +	continue
167.5577 +	;;
167.5578 +
167.5579 +      -no-install)
167.5580 +	case $host in
167.5581 +	*-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-darwin* | *-cegcc*)
167.5582 +	  # The PATH hackery in wrapper scripts is required on Windows
167.5583 +	  # and Darwin in order for the loader to find any dlls it needs.
167.5584 +	  func_warning "\`-no-install' is ignored for $host"
167.5585 +	  func_warning "assuming \`-no-fast-install' instead"
167.5586 +	  fast_install=no
167.5587 +	  ;;
167.5588 +	*) no_install=yes ;;
167.5589 +	esac
167.5590 +	continue
167.5591 +	;;
167.5592 +
167.5593 +      -no-undefined)
167.5594 +	allow_undefined=no
167.5595 +	continue
167.5596 +	;;
167.5597 +
167.5598 +      -objectlist)
167.5599 +	prev=objectlist
167.5600 +	continue
167.5601 +	;;
167.5602 +
167.5603 +      -o) prev=output ;;
167.5604 +
167.5605 +      -precious-files-regex)
167.5606 +	prev=precious_regex
167.5607 +	continue
167.5608 +	;;
167.5609 +
167.5610 +      -release)
167.5611 +	prev=release
167.5612 +	continue
167.5613 +	;;
167.5614 +
167.5615 +      -rpath)
167.5616 +	prev=rpath
167.5617 +	continue
167.5618 +	;;
167.5619 +
167.5620 +      -R)
167.5621 +	prev=xrpath
167.5622 +	continue
167.5623 +	;;
167.5624 +
167.5625 +      -R*)
167.5626 +	func_stripname '-R' '' "$arg"
167.5627 +	dir=$func_stripname_result
167.5628 +	# We need an absolute path.
167.5629 +	case $dir in
167.5630 +	[\\/]* | [A-Za-z]:[\\/]*) ;;
167.5631 +	*)
167.5632 +	  func_fatal_error "only absolute run-paths are allowed"
167.5633 +	  ;;
167.5634 +	esac
167.5635 +	case "$xrpath " in
167.5636 +	*" $dir "*) ;;
167.5637 +	*) xrpath="$xrpath $dir" ;;
167.5638 +	esac
167.5639 +	continue
167.5640 +	;;
167.5641 +
167.5642 +      -shared)
167.5643 +	# The effects of -shared are defined in a previous loop.
167.5644 +	continue
167.5645 +	;;
167.5646 +
167.5647 +      -shrext)
167.5648 +	prev=shrext
167.5649 +	continue
167.5650 +	;;
167.5651 +
167.5652 +      -static | -static-libtool-libs)
167.5653 +	# The effects of -static are defined in a previous loop.
167.5654 +	# We used to do the same as -all-static on platforms that
167.5655 +	# didn't have a PIC flag, but the assumption that the effects
167.5656 +	# would be equivalent was wrong.  It would break on at least
167.5657 +	# Digital Unix and AIX.
167.5658 +	continue
167.5659 +	;;
167.5660 +
167.5661 +      -thread-safe)
167.5662 +	thread_safe=yes
167.5663 +	continue
167.5664 +	;;
167.5665 +
167.5666 +      -version-info)
167.5667 +	prev=vinfo
167.5668 +	continue
167.5669 +	;;
167.5670 +
167.5671 +      -version-number)
167.5672 +	prev=vinfo
167.5673 +	vinfo_number=yes
167.5674 +	continue
167.5675 +	;;
167.5676 +
167.5677 +      -weak)
167.5678 +        prev=weak
167.5679 +	continue
167.5680 +	;;
167.5681 +
167.5682 +      -Wc,*)
167.5683 +	func_stripname '-Wc,' '' "$arg"
167.5684 +	args=$func_stripname_result
167.5685 +	arg=
167.5686 +	save_ifs="$IFS"; IFS=','
167.5687 +	for flag in $args; do
167.5688 +	  IFS="$save_ifs"
167.5689 +          func_quote_for_eval "$flag"
167.5690 +	  arg="$arg $func_quote_for_eval_result"
167.5691 +	  compiler_flags="$compiler_flags $func_quote_for_eval_result"
167.5692 +	done
167.5693 +	IFS="$save_ifs"
167.5694 +	func_stripname ' ' '' "$arg"
167.5695 +	arg=$func_stripname_result
167.5696 +	;;
167.5697 +
167.5698 +      -Wl,*)
167.5699 +	func_stripname '-Wl,' '' "$arg"
167.5700 +	args=$func_stripname_result
167.5701 +	arg=
167.5702 +	save_ifs="$IFS"; IFS=','
167.5703 +	for flag in $args; do
167.5704 +	  IFS="$save_ifs"
167.5705 +          func_quote_for_eval "$flag"
167.5706 +	  arg="$arg $wl$func_quote_for_eval_result"
167.5707 +	  compiler_flags="$compiler_flags $wl$func_quote_for_eval_result"
167.5708 +	  linker_flags="$linker_flags $func_quote_for_eval_result"
167.5709 +	done
167.5710 +	IFS="$save_ifs"
167.5711 +	func_stripname ' ' '' "$arg"
167.5712 +	arg=$func_stripname_result
167.5713 +	;;
167.5714 +
167.5715 +      -Xcompiler)
167.5716 +	prev=xcompiler
167.5717 +	continue
167.5718 +	;;
167.5719 +
167.5720 +      -Xlinker)
167.5721 +	prev=xlinker
167.5722 +	continue
167.5723 +	;;
167.5724 +
167.5725 +      -XCClinker)
167.5726 +	prev=xcclinker
167.5727 +	continue
167.5728 +	;;
167.5729 +
167.5730 +      # -msg_* for osf cc
167.5731 +      -msg_*)
167.5732 +	func_quote_for_eval "$arg"
167.5733 +	arg="$func_quote_for_eval_result"
167.5734 +	;;
167.5735 +
167.5736 +      # -64, -mips[0-9] enable 64-bit mode on the SGI compiler
167.5737 +      # -r[0-9][0-9]* specifies the processor on the SGI compiler
167.5738 +      # -xarch=*, -xtarget=* enable 64-bit mode on the Sun compiler
167.5739 +      # +DA*, +DD* enable 64-bit mode on the HP compiler
167.5740 +      # -q* pass through compiler args for the IBM compiler
167.5741 +      # -m*, -t[45]*, -txscale* pass through architecture-specific
167.5742 +      # compiler args for GCC
167.5743 +      # -F/path gives path to uninstalled frameworks, gcc on darwin
167.5744 +      # -p, -pg, --coverage, -fprofile-* pass through profiling flag for GCC
167.5745 +      # @file GCC response files
167.5746 +      # -tp=* Portland pgcc target processor selection
167.5747 +      # -{shared,static}-libgcc, -static-{libgfortran|libstdc++}: force GCC
167.5748 +      # to link against specified runtime library.
167.5749 +      -64|-mips[0-9]|-r[0-9][0-9]*|-xarch=*|-xtarget=*|+DA*|+DD*|-q*|-m*| \
167.5750 +      -t[45]*|-txscale*|-p|-pg|--coverage|-fprofile-*|-F*|@*|-tp=*| \
167.5751 +      -shared-libgcc|-static-libgcc|-static-libgfortran|-static-libstdc++)
167.5752 +        func_quote_for_eval "$arg"
167.5753 +	arg="$func_quote_for_eval_result"
167.5754 +        func_append compile_command " $arg"
167.5755 +        func_append finalize_command " $arg"
167.5756 +        compiler_flags="$compiler_flags $arg"
167.5757 +        continue
167.5758 +        ;;
167.5759 +
167.5760 +      # Some other compiler flag.
167.5761 +      -* | +*)
167.5762 +        func_quote_for_eval "$arg"
167.5763 +	arg="$func_quote_for_eval_result"
167.5764 +	;;
167.5765 +
167.5766 +      *.$objext)
167.5767 +	# A standard object.
167.5768 +	objs="$objs $arg"
167.5769 +	;;
167.5770 +
167.5771 +      *.lo)
167.5772 +	# A libtool-controlled object.
167.5773 +
167.5774 +	# Check to see that this really is a libtool object.
167.5775 +	if func_lalib_unsafe_p "$arg"; then
167.5776 +	  pic_object=
167.5777 +	  non_pic_object=
167.5778 +
167.5779 +	  # Read the .lo file
167.5780 +	  func_source "$arg"
167.5781 +
167.5782 +	  if test -z "$pic_object" ||
167.5783 +	     test -z "$non_pic_object" ||
167.5784 +	     test "$pic_object" = none &&
167.5785 +	     test "$non_pic_object" = none; then
167.5786 +	    func_fatal_error "cannot find name of object for \`$arg'"
167.5787 +	  fi
167.5788 +
167.5789 +	  # Extract subdirectory from the argument.
167.5790 +	  func_dirname "$arg" "/" ""
167.5791 +	  xdir="$func_dirname_result"
167.5792 +
167.5793 +	  if test "$pic_object" != none; then
167.5794 +	    # Prepend the subdirectory the object is found in.
167.5795 +	    pic_object="$xdir$pic_object"
167.5796 +
167.5797 +	    if test "$prev" = dlfiles; then
167.5798 +	      if test "$build_libtool_libs" = yes && test "$dlopen_support" = yes; then
167.5799 +		dlfiles="$dlfiles $pic_object"
167.5800 +		prev=
167.5801 +		continue
167.5802 +	      else
167.5803 +		# If libtool objects are unsupported, then we need to preload.
167.5804 +		prev=dlprefiles
167.5805 +	      fi
167.5806 +	    fi
167.5807 +
167.5808 +	    # CHECK ME:  I think I busted this.  -Ossama
167.5809 +	    if test "$prev" = dlprefiles; then
167.5810 +	      # Preload the old-style object.
167.5811 +	      dlprefiles="$dlprefiles $pic_object"
167.5812 +	      prev=
167.5813 +	    fi
167.5814 +
167.5815 +	    # A PIC object.
167.5816 +	    func_append libobjs " $pic_object"
167.5817 +	    arg="$pic_object"
167.5818 +	  fi
167.5819 +
167.5820 +	  # Non-PIC object.
167.5821 +	  if test "$non_pic_object" != none; then
167.5822 +	    # Prepend the subdirectory the object is found in.
167.5823 +	    non_pic_object="$xdir$non_pic_object"
167.5824 +
167.5825 +	    # A standard non-PIC object
167.5826 +	    func_append non_pic_objects " $non_pic_object"
167.5827 +	    if test -z "$pic_object" || test "$pic_object" = none ; then
167.5828 +	      arg="$non_pic_object"
167.5829 +	    fi
167.5830 +	  else
167.5831 +	    # If the PIC object exists, use it instead.
167.5832 +	    # $xdir was prepended to $pic_object above.
167.5833 +	    non_pic_object="$pic_object"
167.5834 +	    func_append non_pic_objects " $non_pic_object"
167.5835 +	  fi
167.5836 +	else
167.5837 +	  # Only an error if not doing a dry-run.
167.5838 +	  if $opt_dry_run; then
167.5839 +	    # Extract subdirectory from the argument.
167.5840 +	    func_dirname "$arg" "/" ""
167.5841 +	    xdir="$func_dirname_result"
167.5842 +
167.5843 +	    func_lo2o "$arg"
167.5844 +	    pic_object=$xdir$objdir/$func_lo2o_result
167.5845 +	    non_pic_object=$xdir$func_lo2o_result
167.5846 +	    func_append libobjs " $pic_object"
167.5847 +	    func_append non_pic_objects " $non_pic_object"
167.5848 +	  else
167.5849 +	    func_fatal_error "\`$arg' is not a valid libtool object"
167.5850 +	  fi
167.5851 +	fi
167.5852 +	;;
167.5853 +
167.5854 +      *.$libext)
167.5855 +	# An archive.
167.5856 +	deplibs="$deplibs $arg"
167.5857 +	old_deplibs="$old_deplibs $arg"
167.5858 +	continue
167.5859 +	;;
167.5860 +
167.5861 +      *.la)
167.5862 +	# A libtool-controlled library.
167.5863 +
167.5864 +	if test "$prev" = dlfiles; then
167.5865 +	  # This library was specified with -dlopen.
167.5866 +	  dlfiles="$dlfiles $arg"
167.5867 +	  prev=
167.5868 +	elif test "$prev" = dlprefiles; then
167.5869 +	  # The library was specified with -dlpreopen.
167.5870 +	  dlprefiles="$dlprefiles $arg"
167.5871 +	  prev=
167.5872 +	else
167.5873 +	  deplibs="$deplibs $arg"
167.5874 +	fi
167.5875 +	continue
167.5876 +	;;
167.5877 +
167.5878 +      # Some other compiler argument.
167.5879 +      *)
167.5880 +	# Unknown arguments in both finalize_command and compile_command need
167.5881 +	# to be aesthetically quoted because they are evaled later.
167.5882 +	func_quote_for_eval "$arg"
167.5883 +	arg="$func_quote_for_eval_result"
167.5884 +	;;
167.5885 +      esac # arg
167.5886 +
167.5887 +      # Now actually substitute the argument into the commands.
167.5888 +      if test -n "$arg"; then
167.5889 +	func_append compile_command " $arg"
167.5890 +	func_append finalize_command " $arg"
167.5891 +      fi
167.5892 +    done # argument parsing loop
167.5893 +
167.5894 +    test -n "$prev" && \
167.5895 +      func_fatal_help "the \`$prevarg' option requires an argument"
167.5896 +
167.5897 +    if test "$export_dynamic" = yes && test -n "$export_dynamic_flag_spec"; then
167.5898 +      eval arg=\"$export_dynamic_flag_spec\"
167.5899 +      func_append compile_command " $arg"
167.5900 +      func_append finalize_command " $arg"
167.5901 +    fi
167.5902 +
167.5903 +    oldlibs=
167.5904 +    # calculate the name of the file, without its directory
167.5905 +    func_basename "$output"
167.5906 +    outputname="$func_basename_result"
167.5907 +    libobjs_save="$libobjs"
167.5908 +
167.5909 +    if test -n "$shlibpath_var"; then
167.5910 +      # get the directories listed in $shlibpath_var
167.5911 +      eval shlib_search_path=\`\$ECHO \"\${$shlibpath_var}\" \| \$SED \'s/:/ /g\'\`
167.5912 +    else
167.5913 +      shlib_search_path=
167.5914 +    fi
167.5915 +    eval sys_lib_search_path=\"$sys_lib_search_path_spec\"
167.5916 +    eval sys_lib_dlsearch_path=\"$sys_lib_dlsearch_path_spec\"
167.5917 +
167.5918 +    func_dirname "$output" "/" ""
167.5919 +    output_objdir="$func_dirname_result$objdir"
167.5920 +    # Create the object directory.
167.5921 +    func_mkdir_p "$output_objdir"
167.5922 +
167.5923 +    # Determine the type of output
167.5924 +    case $output in
167.5925 +    "")
167.5926 +      func_fatal_help "you must specify an output file"
167.5927 +      ;;
167.5928 +    *.$libext) linkmode=oldlib ;;
167.5929 +    *.lo | *.$objext) linkmode=obj ;;
167.5930 +    *.la) linkmode=lib ;;
167.5931 +    *) linkmode=prog ;; # Anything else should be a program.
167.5932 +    esac
167.5933 +
167.5934 +    specialdeplibs=
167.5935 +
167.5936 +    libs=
167.5937 +    # Find all interdependent deplibs by searching for libraries
167.5938 +    # that are linked more than once (e.g. -la -lb -la)
167.5939 +    for deplib in $deplibs; do
167.5940 +      if $opt_duplicate_deps ; then
167.5941 +	case "$libs " in
167.5942 +	*" $deplib "*) specialdeplibs="$specialdeplibs $deplib" ;;
167.5943 +	esac
167.5944 +      fi
167.5945 +      libs="$libs $deplib"
167.5946 +    done
167.5947 +
167.5948 +    if test "$linkmode" = lib; then
167.5949 +      libs="$predeps $libs $compiler_lib_search_path $postdeps"
167.5950 +
167.5951 +      # Compute libraries that are listed more than once in $predeps
167.5952 +      # $postdeps and mark them as special (i.e., whose duplicates are
167.5953 +      # not to be eliminated).
167.5954 +      pre_post_deps=
167.5955 +      if $opt_duplicate_compiler_generated_deps; then
167.5956 +	for pre_post_dep in $predeps $postdeps; do
167.5957 +	  case "$pre_post_deps " in
167.5958 +	  *" $pre_post_dep "*) specialdeplibs="$specialdeplibs $pre_post_deps" ;;
167.5959 +	  esac
167.5960 +	  pre_post_deps="$pre_post_deps $pre_post_dep"
167.5961 +	done
167.5962 +      fi
167.5963 +      pre_post_deps=
167.5964 +    fi
167.5965 +
167.5966 +    deplibs=
167.5967 +    newdependency_libs=
167.5968 +    newlib_search_path=
167.5969 +    need_relink=no # whether we're linking any uninstalled libtool libraries
167.5970 +    notinst_deplibs= # not-installed libtool libraries
167.5971 +    notinst_path= # paths that contain not-installed libtool libraries
167.5972 +
167.5973 +    case $linkmode in
167.5974 +    lib)
167.5975 +	passes="conv dlpreopen link"
167.5976 +	for file in $dlfiles $dlprefiles; do
167.5977 +	  case $file in
167.5978 +	  *.la) ;;
167.5979 +	  *)
167.5980 +	    func_fatal_help "libraries can \`-dlopen' only libtool libraries: $file"
167.5981 +	    ;;
167.5982 +	  esac
167.5983 +	done
167.5984 +	;;
167.5985 +    prog)
167.5986 +	compile_deplibs=
167.5987 +	finalize_deplibs=
167.5988 +	alldeplibs=no
167.5989 +	newdlfiles=
167.5990 +	newdlprefiles=
167.5991 +	passes="conv scan dlopen dlpreopen link"
167.5992 +	;;
167.5993 +    *)  passes="conv"
167.5994 +	;;
167.5995 +    esac
167.5996 +
167.5997 +    for pass in $passes; do
167.5998 +      # The preopen pass in lib mode reverses $deplibs; put it back here
167.5999 +      # so that -L comes before libs that need it for instance...
167.6000 +      if test "$linkmode,$pass" = "lib,link"; then
167.6001 +	## FIXME: Find the place where the list is rebuilt in the wrong
167.6002 +	##        order, and fix it there properly
167.6003 +        tmp_deplibs=
167.6004 +	for deplib in $deplibs; do
167.6005 +	  tmp_deplibs="$deplib $tmp_deplibs"
167.6006 +	done
167.6007 +	deplibs="$tmp_deplibs"
167.6008 +      fi
167.6009 +
167.6010 +      if test "$linkmode,$pass" = "lib,link" ||
167.6011 +	 test "$linkmode,$pass" = "prog,scan"; then
167.6012 +	libs="$deplibs"
167.6013 +	deplibs=
167.6014 +      fi
167.6015 +      if test "$linkmode" = prog; then
167.6016 +	case $pass in
167.6017 +	dlopen) libs="$dlfiles" ;;
167.6018 +	dlpreopen) libs="$dlprefiles" ;;
167.6019 +	link) libs="$deplibs %DEPLIBS% $dependency_libs" ;;
167.6020 +	esac
167.6021 +      fi
167.6022 +      if test "$linkmode,$pass" = "lib,dlpreopen"; then
167.6023 +	# Collect and forward deplibs of preopened libtool libs
167.6024 +	for lib in $dlprefiles; do
167.6025 +	  # Ignore non-libtool-libs
167.6026 +	  dependency_libs=
167.6027 +	  case $lib in
167.6028 +	  *.la)	func_source "$lib" ;;
167.6029 +	  esac
167.6030 +
167.6031 +	  # Collect preopened libtool deplibs, except any this library
167.6032 +	  # has declared as weak libs
167.6033 +	  for deplib in $dependency_libs; do
167.6034 +	    func_basename "$deplib"
167.6035 +            deplib_base=$func_basename_result
167.6036 +	    case " $weak_libs " in
167.6037 +	    *" $deplib_base "*) ;;
167.6038 +	    *) deplibs="$deplibs $deplib" ;;
167.6039 +	    esac
167.6040 +	  done
167.6041 +	done
167.6042 +	libs="$dlprefiles"
167.6043 +      fi
167.6044 +      if test "$pass" = dlopen; then
167.6045 +	# Collect dlpreopened libraries
167.6046 +	save_deplibs="$deplibs"
167.6047 +	deplibs=
167.6048 +      fi
167.6049 +
167.6050 +      for deplib in $libs; do
167.6051 +	lib=
167.6052 +	found=no
167.6053 +	case $deplib in
167.6054 +	-mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe|-threads)
167.6055 +	  if test "$linkmode,$pass" = "prog,link"; then
167.6056 +	    compile_deplibs="$deplib $compile_deplibs"
167.6057 +	    finalize_deplibs="$deplib $finalize_deplibs"
167.6058 +	  else
167.6059 +	    compiler_flags="$compiler_flags $deplib"
167.6060 +	    if test "$linkmode" = lib ; then
167.6061 +		case "$new_inherited_linker_flags " in
167.6062 +		    *" $deplib "*) ;;
167.6063 +		    * ) new_inherited_linker_flags="$new_inherited_linker_flags $deplib" ;;
167.6064 +		esac
167.6065 +	    fi
167.6066 +	  fi
167.6067 +	  continue
167.6068 +	  ;;
167.6069 +	-l*)
167.6070 +	  if test "$linkmode" != lib && test "$linkmode" != prog; then
167.6071 +	    func_warning "\`-l' is ignored for archives/objects"
167.6072 +	    continue
167.6073 +	  fi
167.6074 +	  func_stripname '-l' '' "$deplib"
167.6075 +	  name=$func_stripname_result
167.6076 +	  if test "$linkmode" = lib; then
167.6077 +	    searchdirs="$newlib_search_path $lib_search_path $compiler_lib_search_dirs $sys_lib_search_path $shlib_search_path"
167.6078 +	  else
167.6079 +	    searchdirs="$newlib_search_path $lib_search_path $sys_lib_search_path $shlib_search_path"
167.6080 +	  fi
167.6081 +	  for searchdir in $searchdirs; do
167.6082 +	    for search_ext in .la $std_shrext .so .a; do
167.6083 +	      # Search the libtool library
167.6084 +	      lib="$searchdir/lib${name}${search_ext}"
167.6085 +	      if test -f "$lib"; then
167.6086 +		if test "$search_ext" = ".la"; then
167.6087 +		  found=yes
167.6088 +		else
167.6089 +		  found=no
167.6090 +		fi
167.6091 +		break 2
167.6092 +	      fi
167.6093 +	    done
167.6094 +	  done
167.6095 +	  if test "$found" != yes; then
167.6096 +	    # deplib doesn't seem to be a libtool library
167.6097 +	    if test "$linkmode,$pass" = "prog,link"; then
167.6098 +	      compile_deplibs="$deplib $compile_deplibs"
167.6099 +	      finalize_deplibs="$deplib $finalize_deplibs"
167.6100 +	    else
167.6101 +	      deplibs="$deplib $deplibs"
167.6102 +	      test "$linkmode" = lib && newdependency_libs="$deplib $newdependency_libs"
167.6103 +	    fi
167.6104 +	    continue
167.6105 +	  else # deplib is a libtool library
167.6106 +	    # If $allow_libtool_libs_with_static_runtimes && $deplib is a stdlib,
167.6107 +	    # We need to do some special things here, and not later.
167.6108 +	    if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
167.6109 +	      case " $predeps $postdeps " in
167.6110 +	      *" $deplib "*)
167.6111 +		if func_lalib_p "$lib"; then
167.6112 +		  library_names=
167.6113 +		  old_library=
167.6114 +		  func_source "$lib"
167.6115 +		  for l in $old_library $library_names; do
167.6116 +		    ll="$l"
167.6117 +		  done
167.6118 +		  if test "X$ll" = "X$old_library" ; then # only static version available
167.6119 +		    found=no
167.6120 +		    func_dirname "$lib" "" "."
167.6121 +		    ladir="$func_dirname_result"
167.6122 +		    lib=$ladir/$old_library
167.6123 +		    if test "$linkmode,$pass" = "prog,link"; then
167.6124 +		      compile_deplibs="$deplib $compile_deplibs"
167.6125 +		      finalize_deplibs="$deplib $finalize_deplibs"
167.6126 +		    else
167.6127 +		      deplibs="$deplib $deplibs"
167.6128 +		      test "$linkmode" = lib && newdependency_libs="$deplib $newdependency_libs"
167.6129 +		    fi
167.6130 +		    continue
167.6131 +		  fi
167.6132 +		fi
167.6133 +		;;
167.6134 +	      *) ;;
167.6135 +	      esac
167.6136 +	    fi
167.6137 +	  fi
167.6138 +	  ;; # -l
167.6139 +	*.ltframework)
167.6140 +	  if test "$linkmode,$pass" = "prog,link"; then
167.6141 +	    compile_deplibs="$deplib $compile_deplibs"
167.6142 +	    finalize_deplibs="$deplib $finalize_deplibs"
167.6143 +	  else
167.6144 +	    deplibs="$deplib $deplibs"
167.6145 +	    if test "$linkmode" = lib ; then
167.6146 +		case "$new_inherited_linker_flags " in
167.6147 +		    *" $deplib "*) ;;
167.6148 +		    * ) new_inherited_linker_flags="$new_inherited_linker_flags $deplib" ;;
167.6149 +		esac
167.6150 +	    fi
167.6151 +	  fi
167.6152 +	  continue
167.6153 +	  ;;
167.6154 +	-L*)
167.6155 +	  case $linkmode in
167.6156 +	  lib)
167.6157 +	    deplibs="$deplib $deplibs"
167.6158 +	    test "$pass" = conv && continue
167.6159 +	    newdependency_libs="$deplib $newdependency_libs"
167.6160 +	    func_stripname '-L' '' "$deplib"
167.6161 +	    newlib_search_path="$newlib_search_path $func_stripname_result"
167.6162 +	    ;;
167.6163 +	  prog)
167.6164 +	    if test "$pass" = conv; then
167.6165 +	      deplibs="$deplib $deplibs"
167.6166 +	      continue
167.6167 +	    fi
167.6168 +	    if test "$pass" = scan; then
167.6169 +	      deplibs="$deplib $deplibs"
167.6170 +	    else
167.6171 +	      compile_deplibs="$deplib $compile_deplibs"
167.6172 +	      finalize_deplibs="$deplib $finalize_deplibs"
167.6173 +	    fi
167.6174 +	    func_stripname '-L' '' "$deplib"
167.6175 +	    newlib_search_path="$newlib_search_path $func_stripname_result"
167.6176 +	    ;;
167.6177 +	  *)
167.6178 +	    func_warning "\`-L' is ignored for archives/objects"
167.6179 +	    ;;
167.6180 +	  esac # linkmode
167.6181 +	  continue
167.6182 +	  ;; # -L
167.6183 +	-R*)
167.6184 +	  if test "$pass" = link; then
167.6185 +	    func_stripname '-R' '' "$deplib"
167.6186 +	    dir=$func_stripname_result
167.6187 +	    # Make sure the xrpath contains only unique directories.
167.6188 +	    case "$xrpath " in
167.6189 +	    *" $dir "*) ;;
167.6190 +	    *) xrpath="$xrpath $dir" ;;
167.6191 +	    esac
167.6192 +	  fi
167.6193 +	  deplibs="$deplib $deplibs"
167.6194 +	  continue
167.6195 +	  ;;
167.6196 +	*.la) lib="$deplib" ;;
167.6197 +	*.$libext)
167.6198 +	  if test "$pass" = conv; then
167.6199 +	    deplibs="$deplib $deplibs"
167.6200 +	    continue
167.6201 +	  fi
167.6202 +	  case $linkmode in
167.6203 +	  lib)
167.6204 +	    # Linking convenience modules into shared libraries is allowed,
167.6205 +	    # but linking other static libraries is non-portable.
167.6206 +	    case " $dlpreconveniencelibs " in
167.6207 +	    *" $deplib "*) ;;
167.6208 +	    *)
167.6209 +	      valid_a_lib=no
167.6210 +	      case $deplibs_check_method in
167.6211 +		match_pattern*)
167.6212 +		  set dummy $deplibs_check_method; shift
167.6213 +		  match_pattern_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"`
167.6214 +		  if eval "\$ECHO \"$deplib\"" 2>/dev/null | $SED 10q \
167.6215 +		    | $EGREP "$match_pattern_regex" > /dev/null; then
167.6216 +		    valid_a_lib=yes
167.6217 +		  fi
167.6218 +		;;
167.6219 +		pass_all)
167.6220 +		  valid_a_lib=yes
167.6221 +		;;
167.6222 +	      esac
167.6223 +	      if test "$valid_a_lib" != yes; then
167.6224 +		echo
167.6225 +		$ECHO "*** Warning: Trying to link with static lib archive $deplib."
167.6226 +		echo "*** I have the capability to make that library automatically link in when"
167.6227 +		echo "*** you link to this library.  But I can only do this if you have a"
167.6228 +		echo "*** shared version of the library, which you do not appear to have"
167.6229 +		echo "*** because the file extensions .$libext of this argument makes me believe"
167.6230 +		echo "*** that it is just a static archive that I should not use here."
167.6231 +	      else
167.6232 +		echo
167.6233 +		$ECHO "*** Warning: Linking the shared library $output against the"
167.6234 +		$ECHO "*** static library $deplib is not portable!"
167.6235 +		deplibs="$deplib $deplibs"
167.6236 +	      fi
167.6237 +	      ;;
167.6238 +	    esac
167.6239 +	    continue
167.6240 +	    ;;
167.6241 +	  prog)
167.6242 +	    if test "$pass" != link; then
167.6243 +	      deplibs="$deplib $deplibs"
167.6244 +	    else
167.6245 +	      compile_deplibs="$deplib $compile_deplibs"
167.6246 +	      finalize_deplibs="$deplib $finalize_deplibs"
167.6247 +	    fi
167.6248 +	    continue
167.6249 +	    ;;
167.6250 +	  esac # linkmode
167.6251 +	  ;; # *.$libext
167.6252 +	*.lo | *.$objext)
167.6253 +	  if test "$pass" = conv; then
167.6254 +	    deplibs="$deplib $deplibs"
167.6255 +	  elif test "$linkmode" = prog; then
167.6256 +	    if test "$pass" = dlpreopen || test "$dlopen_support" != yes || test "$build_libtool_libs" = no; then
167.6257 +	      # If there is no dlopen support or we're linking statically,
167.6258 +	      # we need to preload.
167.6259 +	      newdlprefiles="$newdlprefiles $deplib"
167.6260 +	      compile_deplibs="$deplib $compile_deplibs"
167.6261 +	      finalize_deplibs="$deplib $finalize_deplibs"
167.6262 +	    else
167.6263 +	      newdlfiles="$newdlfiles $deplib"
167.6264 +	    fi
167.6265 +	  fi
167.6266 +	  continue
167.6267 +	  ;;
167.6268 +	%DEPLIBS%)
167.6269 +	  alldeplibs=yes
167.6270 +	  continue
167.6271 +	  ;;
167.6272 +	esac # case $deplib
167.6273 +
167.6274 +	if test "$found" = yes || test -f "$lib"; then :
167.6275 +	else
167.6276 +	  func_fatal_error "cannot find the library \`$lib' or unhandled argument \`$deplib'"
167.6277 +	fi
167.6278 +
167.6279 +	# Check to see that this really is a libtool archive.
167.6280 +	func_lalib_unsafe_p "$lib" \
167.6281 +	  || func_fatal_error "\`$lib' is not a valid libtool archive"
167.6282 +
167.6283 +	func_dirname "$lib" "" "."
167.6284 +	ladir="$func_dirname_result"
167.6285 +
167.6286 +	dlname=
167.6287 +	dlopen=
167.6288 +	dlpreopen=
167.6289 +	libdir=
167.6290 +	library_names=
167.6291 +	old_library=
167.6292 +	inherited_linker_flags=
167.6293 +	# If the library was installed with an old release of libtool,
167.6294 +	# it will not redefine variables installed, or shouldnotlink
167.6295 +	installed=yes
167.6296 +	shouldnotlink=no
167.6297 +	avoidtemprpath=
167.6298 +
167.6299 +
167.6300 +	# Read the .la file
167.6301 +	func_source "$lib"
167.6302 +
167.6303 +	# Convert "-framework foo" to "foo.ltframework"
167.6304 +	if test -n "$inherited_linker_flags"; then
167.6305 +	  tmp_inherited_linker_flags=`$ECHO "$inherited_linker_flags" | $SED 's/-framework \([^ $]*\)/\1.ltframework/g'`
167.6306 +	  for tmp_inherited_linker_flag in $tmp_inherited_linker_flags; do
167.6307 +	    case " $new_inherited_linker_flags " in
167.6308 +	      *" $tmp_inherited_linker_flag "*) ;;
167.6309 +	      *) new_inherited_linker_flags="$new_inherited_linker_flags $tmp_inherited_linker_flag";;
167.6310 +	    esac
167.6311 +	  done
167.6312 +	fi
167.6313 +	dependency_libs=`$ECHO " $dependency_libs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
167.6314 +	if test "$linkmode,$pass" = "lib,link" ||
167.6315 +	   test "$linkmode,$pass" = "prog,scan" ||
167.6316 +	   { test "$linkmode" != prog && test "$linkmode" != lib; }; then
167.6317 +	  test -n "$dlopen" && dlfiles="$dlfiles $dlopen"
167.6318 +	  test -n "$dlpreopen" && dlprefiles="$dlprefiles $dlpreopen"
167.6319 +	fi
167.6320 +
167.6321 +	if test "$pass" = conv; then
167.6322 +	  # Only check for convenience libraries
167.6323 +	  deplibs="$lib $deplibs"
167.6324 +	  if test -z "$libdir"; then
167.6325 +	    if test -z "$old_library"; then
167.6326 +	      func_fatal_error "cannot find name of link library for \`$lib'"
167.6327 +	    fi
167.6328 +	    # It is a libtool convenience library, so add in its objects.
167.6329 +	    convenience="$convenience $ladir/$objdir/$old_library"
167.6330 +	    old_convenience="$old_convenience $ladir/$objdir/$old_library"
167.6331 +	  elif test "$linkmode" != prog && test "$linkmode" != lib; then
167.6332 +	    func_fatal_error "\`$lib' is not a convenience library"
167.6333 +	  fi
167.6334 +	  tmp_libs=
167.6335 +	  for deplib in $dependency_libs; do
167.6336 +	    deplibs="$deplib $deplibs"
167.6337 +	    if $opt_duplicate_deps ; then
167.6338 +	      case "$tmp_libs " in
167.6339 +	      *" $deplib "*) specialdeplibs="$specialdeplibs $deplib" ;;
167.6340 +	      esac
167.6341 +	    fi
167.6342 +	    tmp_libs="$tmp_libs $deplib"
167.6343 +	  done
167.6344 +	  continue
167.6345 +	fi # $pass = conv
167.6346 +
167.6347 +
167.6348 +	# Get the name of the library we link against.
167.6349 +	linklib=
167.6350 +	for l in $old_library $library_names; do
167.6351 +	  linklib="$l"
167.6352 +	done
167.6353 +	if test -z "$linklib"; then
167.6354 +	  func_fatal_error "cannot find name of link library for \`$lib'"
167.6355 +	fi
167.6356 +
167.6357 +	# This library was specified with -dlopen.
167.6358 +	if test "$pass" = dlopen; then
167.6359 +	  if test -z "$libdir"; then
167.6360 +	    func_fatal_error "cannot -dlopen a convenience library: \`$lib'"
167.6361 +	  fi
167.6362 +	  if test -z "$dlname" ||
167.6363 +	     test "$dlopen_support" != yes ||
167.6364 +	     test "$build_libtool_libs" = no; then
167.6365 +	    # If there is no dlname, no dlopen support or we're linking
167.6366 +	    # statically, we need to preload.  We also need to preload any
167.6367 +	    # dependent libraries so libltdl's deplib preloader doesn't
167.6368 +	    # bomb out in the load deplibs phase.
167.6369 +	    dlprefiles="$dlprefiles $lib $dependency_libs"
167.6370 +	  else
167.6371 +	    newdlfiles="$newdlfiles $lib"
167.6372 +	  fi
167.6373 +	  continue
167.6374 +	fi # $pass = dlopen
167.6375 +
167.6376 +	# We need an absolute path.
167.6377 +	case $ladir in
167.6378 +	[\\/]* | [A-Za-z]:[\\/]*) abs_ladir="$ladir" ;;
167.6379 +	*)
167.6380 +	  abs_ladir=`cd "$ladir" && pwd`
167.6381 +	  if test -z "$abs_ladir"; then
167.6382 +	    func_warning "cannot determine absolute directory name of \`$ladir'"
167.6383 +	    func_warning "passing it literally to the linker, although it might fail"
167.6384 +	    abs_ladir="$ladir"
167.6385 +	  fi
167.6386 +	  ;;
167.6387 +	esac
167.6388 +	func_basename "$lib"
167.6389 +	laname="$func_basename_result"
167.6390 +
167.6391 +	# Find the relevant object directory and library name.
167.6392 +	if test "X$installed" = Xyes; then
167.6393 +	  if test ! -f "$libdir/$linklib" && test -f "$abs_ladir/$linklib"; then
167.6394 +	    func_warning "library \`$lib' was moved."
167.6395 +	    dir="$ladir"
167.6396 +	    absdir="$abs_ladir"
167.6397 +	    libdir="$abs_ladir"
167.6398 +	  else
167.6399 +	    dir="$libdir"
167.6400 +	    absdir="$libdir"
167.6401 +	  fi
167.6402 +	  test "X$hardcode_automatic" = Xyes && avoidtemprpath=yes
167.6403 +	else
167.6404 +	  if test ! -f "$ladir/$objdir/$linklib" && test -f "$abs_ladir/$linklib"; then
167.6405 +	    dir="$ladir"
167.6406 +	    absdir="$abs_ladir"
167.6407 +	    # Remove this search path later
167.6408 +	    notinst_path="$notinst_path $abs_ladir"
167.6409 +	  else
167.6410 +	    dir="$ladir/$objdir"
167.6411 +	    absdir="$abs_ladir/$objdir"
167.6412 +	    # Remove this search path later
167.6413 +	    notinst_path="$notinst_path $abs_ladir"
167.6414 +	  fi
167.6415 +	fi # $installed = yes
167.6416 +	func_stripname 'lib' '.la' "$laname"
167.6417 +	name=$func_stripname_result
167.6418 +
167.6419 +	# This library was specified with -dlpreopen.
167.6420 +	if test "$pass" = dlpreopen; then
167.6421 +	  if test -z "$libdir" && test "$linkmode" = prog; then
167.6422 +	    func_fatal_error "only libraries may -dlpreopen a convenience library: \`$lib'"
167.6423 +	  fi
167.6424 +	  case "$host" in
167.6425 +	    # special handling for platforms with PE-DLLs.
167.6426 +	    *cygwin* | *mingw* | *cegcc* )
167.6427 +	      # Linker will automatically link against shared library if both
167.6428 +	      # static and shared are present.  Therefore, ensure we extract
167.6429 +	      # symbols from the import library if a shared library is present
167.6430 +	      # (otherwise, the dlopen module name will be incorrect).  We do
167.6431 +	      # this by putting the import library name into $newdlprefiles.
167.6432 +	      # We recover the dlopen module name by 'saving' the la file
167.6433 +	      # name in a special purpose variable, and (later) extracting the
167.6434 +	      # dlname from the la file.
167.6435 +	      if test -n "$dlname"; then
167.6436 +	        func_tr_sh "$dir/$linklib"
167.6437 +	        eval "libfile_$func_tr_sh_result=\$abs_ladir/\$laname"
167.6438 +	        newdlprefiles="$newdlprefiles $dir/$linklib"
167.6439 +	      else
167.6440 +	        newdlprefiles="$newdlprefiles $dir/$old_library"
167.6441 +	        # Keep a list of preopened convenience libraries to check
167.6442 +	        # that they are being used correctly in the link pass.
167.6443 +	        test -z "$libdir" && \
167.6444 +	          dlpreconveniencelibs="$dlpreconveniencelibs $dir/$old_library"
167.6445 +	      fi
167.6446 +	    ;;
167.6447 +	    * )
167.6448 +	      # Prefer using a static library (so that no silly _DYNAMIC symbols
167.6449 +	      # are required to link).
167.6450 +	      if test -n "$old_library"; then
167.6451 +	        newdlprefiles="$newdlprefiles $dir/$old_library"
167.6452 +	        # Keep a list of preopened convenience libraries to check
167.6453 +	        # that they are being used correctly in the link pass.
167.6454 +	        test -z "$libdir" && \
167.6455 +	          dlpreconveniencelibs="$dlpreconveniencelibs $dir/$old_library"
167.6456 +	      # Otherwise, use the dlname, so that lt_dlopen finds it.
167.6457 +	      elif test -n "$dlname"; then
167.6458 +	        newdlprefiles="$newdlprefiles $dir/$dlname"
167.6459 +	      else
167.6460 +	        newdlprefiles="$newdlprefiles $dir/$linklib"
167.6461 +	      fi
167.6462 +	    ;;
167.6463 +	  esac
167.6464 +	fi # $pass = dlpreopen
167.6465 +
167.6466 +	if test -z "$libdir"; then
167.6467 +	  # Link the convenience library
167.6468 +	  if test "$linkmode" = lib; then
167.6469 +	    deplibs="$dir/$old_library $deplibs"
167.6470 +	  elif test "$linkmode,$pass" = "prog,link"; then
167.6471 +	    compile_deplibs="$dir/$old_library $compile_deplibs"
167.6472 +	    finalize_deplibs="$dir/$old_library $finalize_deplibs"
167.6473 +	  else
167.6474 +	    deplibs="$lib $deplibs" # used for prog,scan pass
167.6475 +	  fi
167.6476 +	  continue
167.6477 +	fi
167.6478 +
167.6479 +
167.6480 +	if test "$linkmode" = prog && test "$pass" != link; then
167.6481 +	  newlib_search_path="$newlib_search_path $ladir"
167.6482 +	  deplibs="$lib $deplibs"
167.6483 +
167.6484 +	  linkalldeplibs=no
167.6485 +	  if test "$link_all_deplibs" != no || test -z "$library_names" ||
167.6486 +	     test "$build_libtool_libs" = no; then
167.6487 +	    linkalldeplibs=yes
167.6488 +	  fi
167.6489 +
167.6490 +	  tmp_libs=
167.6491 +	  for deplib in $dependency_libs; do
167.6492 +	    case $deplib in
167.6493 +	    -L*) func_stripname '-L' '' "$deplib"
167.6494 +	         newlib_search_path="$newlib_search_path $func_stripname_result"
167.6495 +		 ;;
167.6496 +	    esac
167.6497 +	    # Need to link against all dependency_libs?
167.6498 +	    if test "$linkalldeplibs" = yes; then
167.6499 +	      deplibs="$deplib $deplibs"
167.6500 +	    else
167.6501 +	      # Need to hardcode shared library paths
167.6502 +	      # or/and link against static libraries
167.6503 +	      newdependency_libs="$deplib $newdependency_libs"
167.6504 +	    fi
167.6505 +	    if $opt_duplicate_deps ; then
167.6506 +	      case "$tmp_libs " in
167.6507 +	      *" $deplib "*) specialdeplibs="$specialdeplibs $deplib" ;;
167.6508 +	      esac
167.6509 +	    fi
167.6510 +	    tmp_libs="$tmp_libs $deplib"
167.6511 +	  done # for deplib
167.6512 +	  continue
167.6513 +	fi # $linkmode = prog...
167.6514 +
167.6515 +	if test "$linkmode,$pass" = "prog,link"; then
167.6516 +	  if test -n "$library_names" &&
167.6517 +	     { { test "$prefer_static_libs" = no ||
167.6518 +	         test "$prefer_static_libs,$installed" = "built,yes"; } ||
167.6519 +	       test -z "$old_library"; }; then
167.6520 +	    # We need to hardcode the library path
167.6521 +	    if test -n "$shlibpath_var" && test -z "$avoidtemprpath" ; then
167.6522 +	      # Make sure the rpath contains only unique directories.
167.6523 +	      case "$temp_rpath:" in
167.6524 +	      *"$absdir:"*) ;;
167.6525 +	      *) temp_rpath="$temp_rpath$absdir:" ;;
167.6526 +	      esac
167.6527 +	    fi
167.6528 +
167.6529 +	    # Hardcode the library path.
167.6530 +	    # Skip directories that are in the system default run-time
167.6531 +	    # search path.
167.6532 +	    case " $sys_lib_dlsearch_path " in
167.6533 +	    *" $absdir "*) ;;
167.6534 +	    *)
167.6535 +	      case "$compile_rpath " in
167.6536 +	      *" $absdir "*) ;;
167.6537 +	      *) compile_rpath="$compile_rpath $absdir"
167.6538 +	      esac
167.6539 +	      ;;
167.6540 +	    esac
167.6541 +	    case " $sys_lib_dlsearch_path " in
167.6542 +	    *" $libdir "*) ;;
167.6543 +	    *)
167.6544 +	      case "$finalize_rpath " in
167.6545 +	      *" $libdir "*) ;;
167.6546 +	      *) finalize_rpath="$finalize_rpath $libdir"
167.6547 +	      esac
167.6548 +	      ;;
167.6549 +	    esac
167.6550 +	  fi # $linkmode,$pass = prog,link...
167.6551 +
167.6552 +	  if test "$alldeplibs" = yes &&
167.6553 +	     { test "$deplibs_check_method" = pass_all ||
167.6554 +	       { test "$build_libtool_libs" = yes &&
167.6555 +		 test -n "$library_names"; }; }; then
167.6556 +	    # We only need to search for static libraries
167.6557 +	    continue
167.6558 +	  fi
167.6559 +	fi
167.6560 +
167.6561 +	link_static=no # Whether the deplib will be linked statically
167.6562 +	use_static_libs=$prefer_static_libs
167.6563 +	if test "$use_static_libs" = built && test "$installed" = yes; then
167.6564 +	  use_static_libs=no
167.6565 +	fi
167.6566 +	if test -n "$library_names" &&
167.6567 +	   { test "$use_static_libs" = no || test -z "$old_library"; }; then
167.6568 +	  case $host in
167.6569 +	  *cygwin* | *mingw* | *cegcc*)
167.6570 +	      # No point in relinking DLLs because paths are not encoded
167.6571 +	      notinst_deplibs="$notinst_deplibs $lib"
167.6572 +	      need_relink=no
167.6573 +	    ;;
167.6574 +	  *)
167.6575 +	    if test "$installed" = no; then
167.6576 +	      notinst_deplibs="$notinst_deplibs $lib"
167.6577 +	      need_relink=yes
167.6578 +	    fi
167.6579 +	    ;;
167.6580 +	  esac
167.6581 +	  # This is a shared library
167.6582 +
167.6583 +	  # Warn about portability, can't link against -module's on some
167.6584 +	  # systems (darwin).  Don't bleat about dlopened modules though!
167.6585 +	  dlopenmodule=""
167.6586 +	  for dlpremoduletest in $dlprefiles; do
167.6587 +	    if test "X$dlpremoduletest" = "X$lib"; then
167.6588 +	      dlopenmodule="$dlpremoduletest"
167.6589 +	      break
167.6590 +	    fi
167.6591 +	  done
167.6592 +	  if test -z "$dlopenmodule" && test "$shouldnotlink" = yes && test "$pass" = link; then
167.6593 +	    echo
167.6594 +	    if test "$linkmode" = prog; then
167.6595 +	      $ECHO "*** Warning: Linking the executable $output against the loadable module"
167.6596 +	    else
167.6597 +	      $ECHO "*** Warning: Linking the shared library $output against the loadable module"
167.6598 +	    fi
167.6599 +	    $ECHO "*** $linklib is not portable!"
167.6600 +	  fi
167.6601 +	  if test "$linkmode" = lib &&
167.6602 +	     test "$hardcode_into_libs" = yes; then
167.6603 +	    # Hardcode the library path.
167.6604 +	    # Skip directories that are in the system default run-time
167.6605 +	    # search path.
167.6606 +	    case " $sys_lib_dlsearch_path " in
167.6607 +	    *" $absdir "*) ;;
167.6608 +	    *)
167.6609 +	      case "$compile_rpath " in
167.6610 +	      *" $absdir "*) ;;
167.6611 +	      *) compile_rpath="$compile_rpath $absdir"
167.6612 +	      esac
167.6613 +	      ;;
167.6614 +	    esac
167.6615 +	    case " $sys_lib_dlsearch_path " in
167.6616 +	    *" $libdir "*) ;;
167.6617 +	    *)
167.6618 +	      case "$finalize_rpath " in
167.6619 +	      *" $libdir "*) ;;
167.6620 +	      *) finalize_rpath="$finalize_rpath $libdir"
167.6621 +	      esac
167.6622 +	      ;;
167.6623 +	    esac
167.6624 +	  fi
167.6625 +
167.6626 +	  if test -n "$old_archive_from_expsyms_cmds"; then
167.6627 +	    # figure out the soname
167.6628 +	    set dummy $library_names
167.6629 +	    shift
167.6630 +	    realname="$1"
167.6631 +	    shift
167.6632 +	    libname=`eval "\\$ECHO \"$libname_spec\""`
167.6633 +	    # use dlname if we got it. it's perfectly good, no?
167.6634 +	    if test -n "$dlname"; then
167.6635 +	      soname="$dlname"
167.6636 +	    elif test -n "$soname_spec"; then
167.6637 +	      # bleh windows
167.6638 +	      case $host in
167.6639 +	      *cygwin* | mingw* | *cegcc*)
167.6640 +	        func_arith $current - $age
167.6641 +		major=$func_arith_result
167.6642 +		versuffix="-$major"
167.6643 +		;;
167.6644 +	      esac
167.6645 +	      eval soname=\"$soname_spec\"
167.6646 +	    else
167.6647 +	      soname="$realname"
167.6648 +	    fi
167.6649 +
167.6650 +	    # Make a new name for the extract_expsyms_cmds to use
167.6651 +	    soroot="$soname"
167.6652 +	    func_basename "$soroot"
167.6653 +	    soname="$func_basename_result"
167.6654 +	    func_stripname 'lib' '.dll' "$soname"
167.6655 +	    newlib=libimp-$func_stripname_result.a
167.6656 +
167.6657 +	    # If the library has no export list, then create one now
167.6658 +	    if test -f "$output_objdir/$soname-def"; then :
167.6659 +	    else
167.6660 +	      func_verbose "extracting exported symbol list from \`$soname'"
167.6661 +	      func_execute_cmds "$extract_expsyms_cmds" 'exit $?'
167.6662 +	    fi
167.6663 +
167.6664 +	    # Create $newlib
167.6665 +	    if test -f "$output_objdir/$newlib"; then :; else
167.6666 +	      func_verbose "generating import library for \`$soname'"
167.6667 +	      func_execute_cmds "$old_archive_from_expsyms_cmds" 'exit $?'
167.6668 +	    fi
167.6669 +	    # make sure the library variables are pointing to the new library
167.6670 +	    dir=$output_objdir
167.6671 +	    linklib=$newlib
167.6672 +	  fi # test -n "$old_archive_from_expsyms_cmds"
167.6673 +
167.6674 +	  if test "$linkmode" = prog || test "$mode" != relink; then
167.6675 +	    add_shlibpath=
167.6676 +	    add_dir=
167.6677 +	    add=
167.6678 +	    lib_linked=yes
167.6679 +	    case $hardcode_action in
167.6680 +	    immediate | unsupported)
167.6681 +	      if test "$hardcode_direct" = no; then
167.6682 +		add="$dir/$linklib"
167.6683 +		case $host in
167.6684 +		  *-*-sco3.2v5.0.[024]*) add_dir="-L$dir" ;;
167.6685 +		  *-*-sysv4*uw2*) add_dir="-L$dir" ;;
167.6686 +		  *-*-sysv5OpenUNIX* | *-*-sysv5UnixWare7.[01].[10]* | \
167.6687 +		    *-*-unixware7*) add_dir="-L$dir" ;;
167.6688 +		  *-*-darwin* )
167.6689 +		    # if the lib is a (non-dlopened) module then we can not
167.6690 +		    # link against it, someone is ignoring the earlier warnings
167.6691 +		    if /usr/bin/file -L $add 2> /dev/null |
167.6692 +			 $GREP ": [^:]* bundle" >/dev/null ; then
167.6693 +		      if test "X$dlopenmodule" != "X$lib"; then
167.6694 +			$ECHO "*** Warning: lib $linklib is a module, not a shared library"
167.6695 +			if test -z "$old_library" ; then
167.6696 +			  echo
167.6697 +			  echo "*** And there doesn't seem to be a static archive available"
167.6698 +			  echo "*** The link will probably fail, sorry"
167.6699 +			else
167.6700 +			  add="$dir/$old_library"
167.6701 +			fi
167.6702 +		      elif test -n "$old_library"; then
167.6703 +			add="$dir/$old_library"
167.6704 +		      fi
167.6705 +		    fi
167.6706 +		esac
167.6707 +	      elif test "$hardcode_minus_L" = no; then
167.6708 +		case $host in
167.6709 +		*-*-sunos*) add_shlibpath="$dir" ;;
167.6710 +		esac
167.6711 +		add_dir="-L$dir"
167.6712 +		add="-l$name"
167.6713 +	      elif test "$hardcode_shlibpath_var" = no; then
167.6714 +		add_shlibpath="$dir"
167.6715 +		add="-l$name"
167.6716 +	      else
167.6717 +		lib_linked=no
167.6718 +	      fi
167.6719 +	      ;;
167.6720 +	    relink)
167.6721 +	      if test "$hardcode_direct" = yes &&
167.6722 +	         test "$hardcode_direct_absolute" = no; then
167.6723 +		add="$dir/$linklib"
167.6724 +	      elif test "$hardcode_minus_L" = yes; then
167.6725 +		add_dir="-L$dir"
167.6726 +		# Try looking first in the location we're being installed to.
167.6727 +		if test -n "$inst_prefix_dir"; then
167.6728 +		  case $libdir in
167.6729 +		    [\\/]*)
167.6730 +		      add_dir="$add_dir -L$inst_prefix_dir$libdir"
167.6731 +		      ;;
167.6732 +		  esac
167.6733 +		fi
167.6734 +		add="-l$name"
167.6735 +	      elif test "$hardcode_shlibpath_var" = yes; then
167.6736 +		add_shlibpath="$dir"
167.6737 +		add="-l$name"
167.6738 +	      else
167.6739 +		lib_linked=no
167.6740 +	      fi
167.6741 +	      ;;
167.6742 +	    *) lib_linked=no ;;
167.6743 +	    esac
167.6744 +
167.6745 +	    if test "$lib_linked" != yes; then
167.6746 +	      func_fatal_configuration "unsupported hardcode properties"
167.6747 +	    fi
167.6748 +
167.6749 +	    if test -n "$add_shlibpath"; then
167.6750 +	      case :$compile_shlibpath: in
167.6751 +	      *":$add_shlibpath:"*) ;;
167.6752 +	      *) compile_shlibpath="$compile_shlibpath$add_shlibpath:" ;;
167.6753 +	      esac
167.6754 +	    fi
167.6755 +	    if test "$linkmode" = prog; then
167.6756 +	      test -n "$add_dir" && compile_deplibs="$add_dir $compile_deplibs"
167.6757 +	      test -n "$add" && compile_deplibs="$add $compile_deplibs"
167.6758 +	    else
167.6759 +	      test -n "$add_dir" && deplibs="$add_dir $deplibs"
167.6760 +	      test -n "$add" && deplibs="$add $deplibs"
167.6761 +	      if test "$hardcode_direct" != yes &&
167.6762 +		 test "$hardcode_minus_L" != yes &&
167.6763 +		 test "$hardcode_shlibpath_var" = yes; then
167.6764 +		case :$finalize_shlibpath: in
167.6765 +		*":$libdir:"*) ;;
167.6766 +		*) finalize_shlibpath="$finalize_shlibpath$libdir:" ;;
167.6767 +		esac
167.6768 +	      fi
167.6769 +	    fi
167.6770 +	  fi
167.6771 +
167.6772 +	  if test "$linkmode" = prog || test "$mode" = relink; then
167.6773 +	    add_shlibpath=
167.6774 +	    add_dir=
167.6775 +	    add=
167.6776 +	    # Finalize command for both is simple: just hardcode it.
167.6777 +	    if test "$hardcode_direct" = yes &&
167.6778 +	       test "$hardcode_direct_absolute" = no; then
167.6779 +	      add="$libdir/$linklib"
167.6780 +	    elif test "$hardcode_minus_L" = yes; then
167.6781 +	      add_dir="-L$libdir"
167.6782 +	      add="-l$name"
167.6783 +	    elif test "$hardcode_shlibpath_var" = yes; then
167.6784 +	      case :$finalize_shlibpath: in
167.6785 +	      *":$libdir:"*) ;;
167.6786 +	      *) finalize_shlibpath="$finalize_shlibpath$libdir:" ;;
167.6787 +	      esac
167.6788 +	      add="-l$name"
167.6789 +	    elif test "$hardcode_automatic" = yes; then
167.6790 +	      if test -n "$inst_prefix_dir" &&
167.6791 +		 test -f "$inst_prefix_dir$libdir/$linklib" ; then
167.6792 +		add="$inst_prefix_dir$libdir/$linklib"
167.6793 +	      else
167.6794 +		add="$libdir/$linklib"
167.6795 +	      fi
167.6796 +	    else
167.6797 +	      # We cannot seem to hardcode it, guess we'll fake it.
167.6798 +	      add_dir="-L$libdir"
167.6799 +	      # Try looking first in the location we're being installed to.
167.6800 +	      if test -n "$inst_prefix_dir"; then
167.6801 +		case $libdir in
167.6802 +		  [\\/]*)
167.6803 +		    add_dir="$add_dir -L$inst_prefix_dir$libdir"
167.6804 +		    ;;
167.6805 +		esac
167.6806 +	      fi
167.6807 +	      add="-l$name"
167.6808 +	    fi
167.6809 +
167.6810 +	    if test "$linkmode" = prog; then
167.6811 +	      test -n "$add_dir" && finalize_deplibs="$add_dir $finalize_deplibs"
167.6812 +	      test -n "$add" && finalize_deplibs="$add $finalize_deplibs"
167.6813 +	    else
167.6814 +	      test -n "$add_dir" && deplibs="$add_dir $deplibs"
167.6815 +	      test -n "$add" && deplibs="$add $deplibs"
167.6816 +	    fi
167.6817 +	  fi
167.6818 +	elif test "$linkmode" = prog; then
167.6819 +	  # Here we assume that one of hardcode_direct or hardcode_minus_L
167.6820 +	  # is not unsupported.  This is valid on all known static and
167.6821 +	  # shared platforms.
167.6822 +	  if test "$hardcode_direct" != unsupported; then
167.6823 +	    test -n "$old_library" && linklib="$old_library"
167.6824 +	    compile_deplibs="$dir/$linklib $compile_deplibs"
167.6825 +	    finalize_deplibs="$dir/$linklib $finalize_deplibs"
167.6826 +	  else
167.6827 +	    compile_deplibs="-l$name -L$dir $compile_deplibs"
167.6828 +	    finalize_deplibs="-l$name -L$dir $finalize_deplibs"
167.6829 +	  fi
167.6830 +	elif test "$build_libtool_libs" = yes; then
167.6831 +	  # Not a shared library
167.6832 +	  if test "$deplibs_check_method" != pass_all; then
167.6833 +	    # We're trying link a shared library against a static one
167.6834 +	    # but the system doesn't support it.
167.6835 +
167.6836 +	    # Just print a warning and add the library to dependency_libs so
167.6837 +	    # that the program can be linked against the static library.
167.6838 +	    echo
167.6839 +	    $ECHO "*** Warning: This system can not link to static lib archive $lib."
167.6840 +	    echo "*** I have the capability to make that library automatically link in when"
167.6841 +	    echo "*** you link to this library.  But I can only do this if you have a"
167.6842 +	    echo "*** shared version of the library, which you do not appear to have."
167.6843 +	    if test "$module" = yes; then
167.6844 +	      echo "*** But as you try to build a module library, libtool will still create "
167.6845 +	      echo "*** a static module, that should work as long as the dlopening application"
167.6846 +	      echo "*** is linked with the -dlopen flag to resolve symbols at runtime."
167.6847 +	      if test -z "$global_symbol_pipe"; then
167.6848 +		echo
167.6849 +		echo "*** However, this would only work if libtool was able to extract symbol"
167.6850 +		echo "*** lists from a program, using \`nm' or equivalent, but libtool could"
167.6851 +		echo "*** not find such a program.  So, this module is probably useless."
167.6852 +		echo "*** \`nm' from GNU binutils and a full rebuild may help."
167.6853 +	      fi
167.6854 +	      if test "$build_old_libs" = no; then
167.6855 +		build_libtool_libs=module
167.6856 +		build_old_libs=yes
167.6857 +	      else
167.6858 +		build_libtool_libs=no
167.6859 +	      fi
167.6860 +	    fi
167.6861 +	  else
167.6862 +	    deplibs="$dir/$old_library $deplibs"
167.6863 +	    link_static=yes
167.6864 +	  fi
167.6865 +	fi # link shared/static library?
167.6866 +
167.6867 +	if test "$linkmode" = lib; then
167.6868 +	  if test -n "$dependency_libs" &&
167.6869 +	     { test "$hardcode_into_libs" != yes ||
167.6870 +	       test "$build_old_libs" = yes ||
167.6871 +	       test "$link_static" = yes; }; then
167.6872 +	    # Extract -R from dependency_libs
167.6873 +	    temp_deplibs=
167.6874 +	    for libdir in $dependency_libs; do
167.6875 +	      case $libdir in
167.6876 +	      -R*) func_stripname '-R' '' "$libdir"
167.6877 +	           temp_xrpath=$func_stripname_result
167.6878 +		   case " $xrpath " in
167.6879 +		   *" $temp_xrpath "*) ;;
167.6880 +		   *) xrpath="$xrpath $temp_xrpath";;
167.6881 +		   esac;;
167.6882 +	      *) temp_deplibs="$temp_deplibs $libdir";;
167.6883 +	      esac
167.6884 +	    done
167.6885 +	    dependency_libs="$temp_deplibs"
167.6886 +	  fi
167.6887 +
167.6888 +	  newlib_search_path="$newlib_search_path $absdir"
167.6889 +	  # Link against this library
167.6890 +	  test "$link_static" = no && newdependency_libs="$abs_ladir/$laname $newdependency_libs"
167.6891 +	  # ... and its dependency_libs
167.6892 +	  tmp_libs=
167.6893 +	  for deplib in $dependency_libs; do
167.6894 +	    newdependency_libs="$deplib $newdependency_libs"
167.6895 +	    if $opt_duplicate_deps ; then
167.6896 +	      case "$tmp_libs " in
167.6897 +	      *" $deplib "*) specialdeplibs="$specialdeplibs $deplib" ;;
167.6898 +	      esac
167.6899 +	    fi
167.6900 +	    tmp_libs="$tmp_libs $deplib"
167.6901 +	  done
167.6902 +
167.6903 +	  if test "$link_all_deplibs" != no; then
167.6904 +	    # Add the search paths of all dependency libraries
167.6905 +	    for deplib in $dependency_libs; do
167.6906 +	      path=
167.6907 +	      case $deplib in
167.6908 +	      -L*) path="$deplib" ;;
167.6909 +	      *.la)
167.6910 +	        func_dirname "$deplib" "" "."
167.6911 +		dir="$func_dirname_result"
167.6912 +		# We need an absolute path.
167.6913 +		case $dir in
167.6914 +		[\\/]* | [A-Za-z]:[\\/]*) absdir="$dir" ;;
167.6915 +		*)
167.6916 +		  absdir=`cd "$dir" && pwd`
167.6917 +		  if test -z "$absdir"; then
167.6918 +		    func_warning "cannot determine absolute directory name of \`$dir'"
167.6919 +		    absdir="$dir"
167.6920 +		  fi
167.6921 +		  ;;
167.6922 +		esac
167.6923 +		if $GREP "^installed=no" $deplib > /dev/null; then
167.6924 +		case $host in
167.6925 +		*-*-darwin*)
167.6926 +		  depdepl=
167.6927 +		  eval deplibrary_names=`${SED} -n -e 's/^library_names=\(.*\)$/\1/p' $deplib`
167.6928 +		  if test -n "$deplibrary_names" ; then
167.6929 +		    for tmp in $deplibrary_names ; do
167.6930 +		      depdepl=$tmp
167.6931 +		    done
167.6932 +		    if test -f "$absdir/$objdir/$depdepl" ; then
167.6933 +		      depdepl="$absdir/$objdir/$depdepl"
167.6934 +		      darwin_install_name=`${OTOOL} -L $depdepl | awk '{if (NR == 2) {print $1;exit}}'`
167.6935 +                      if test -z "$darwin_install_name"; then
167.6936 +                          darwin_install_name=`${OTOOL64} -L $depdepl  | awk '{if (NR == 2) {print $1;exit}}'`
167.6937 +                      fi
167.6938 +		      compiler_flags="$compiler_flags ${wl}-dylib_file ${wl}${darwin_install_name}:${depdepl}"
167.6939 +		      linker_flags="$linker_flags -dylib_file ${darwin_install_name}:${depdepl}"
167.6940 +		      path=
167.6941 +		    fi
167.6942 +		  fi
167.6943 +		  ;;
167.6944 +		*)
167.6945 +		  path="-L$absdir/$objdir"
167.6946 +		  ;;
167.6947 +		esac
167.6948 +		else
167.6949 +		  eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $deplib`
167.6950 +		  test -z "$libdir" && \
167.6951 +		    func_fatal_error "\`$deplib' is not a valid libtool archive"
167.6952 +		  test "$absdir" != "$libdir" && \
167.6953 +		    func_warning "\`$deplib' seems to be moved"
167.6954 +
167.6955 +		  path="-L$absdir"
167.6956 +		fi
167.6957 +		;;
167.6958 +	      esac
167.6959 +	      case " $deplibs " in
167.6960 +	      *" $path "*) ;;
167.6961 +	      *) deplibs="$path $deplibs" ;;
167.6962 +	      esac
167.6963 +	    done
167.6964 +	  fi # link_all_deplibs != no
167.6965 +	fi # linkmode = lib
167.6966 +      done # for deplib in $libs
167.6967 +      if test "$pass" = link; then
167.6968 +	if test "$linkmode" = "prog"; then
167.6969 +	  compile_deplibs="$new_inherited_linker_flags $compile_deplibs"
167.6970 +	  finalize_deplibs="$new_inherited_linker_flags $finalize_deplibs"
167.6971 +	else
167.6972 +	  compiler_flags="$compiler_flags "`$ECHO " $new_inherited_linker_flags" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
167.6973 +	fi
167.6974 +      fi
167.6975 +      dependency_libs="$newdependency_libs"
167.6976 +      if test "$pass" = dlpreopen; then
167.6977 +	# Link the dlpreopened libraries before other libraries
167.6978 +	for deplib in $save_deplibs; do
167.6979 +	  deplibs="$deplib $deplibs"
167.6980 +	done
167.6981 +      fi
167.6982 +      if test "$pass" != dlopen; then
167.6983 +	if test "$pass" != conv; then
167.6984 +	  # Make sure lib_search_path contains only unique directories.
167.6985 +	  lib_search_path=
167.6986 +	  for dir in $newlib_search_path; do
167.6987 +	    case "$lib_search_path " in
167.6988 +	    *" $dir "*) ;;
167.6989 +	    *) lib_search_path="$lib_search_path $dir" ;;
167.6990 +	    esac
167.6991 +	  done
167.6992 +	  newlib_search_path=
167.6993 +	fi
167.6994 +
167.6995 +	if test "$linkmode,$pass" != "prog,link"; then
167.6996 +	  vars="deplibs"
167.6997 +	else
167.6998 +	  vars="compile_deplibs finalize_deplibs"
167.6999 +	fi
167.7000 +	for var in $vars dependency_libs; do
167.7001 +	  # Add libraries to $var in reverse order
167.7002 +	  eval tmp_libs=\"\$$var\"
167.7003 +	  new_libs=
167.7004 +	  for deplib in $tmp_libs; do
167.7005 +	    # FIXME: Pedantically, this is the right thing to do, so
167.7006 +	    #        that some nasty dependency loop isn't accidentally
167.7007 +	    #        broken:
167.7008 +	    #new_libs="$deplib $new_libs"
167.7009 +	    # Pragmatically, this seems to cause very few problems in
167.7010 +	    # practice:
167.7011 +	    case $deplib in
167.7012 +	    -L*) new_libs="$deplib $new_libs" ;;
167.7013 +	    -R*) ;;
167.7014 +	    *)
167.7015 +	      # And here is the reason: when a library appears more
167.7016 +	      # than once as an explicit dependence of a library, or
167.7017 +	      # is implicitly linked in more than once by the
167.7018 +	      # compiler, it is considered special, and multiple
167.7019 +	      # occurrences thereof are not removed.  Compare this
167.7020 +	      # with having the same library being listed as a
167.7021 +	      # dependency of multiple other libraries: in this case,
167.7022 +	      # we know (pedantically, we assume) the library does not
167.7023 +	      # need to be listed more than once, so we keep only the
167.7024 +	      # last copy.  This is not always right, but it is rare
167.7025 +	      # enough that we require users that really mean to play
167.7026 +	      # such unportable linking tricks to link the library
167.7027 +	      # using -Wl,-lname, so that libtool does not consider it
167.7028 +	      # for duplicate removal.
167.7029 +	      case " $specialdeplibs " in
167.7030 +	      *" $deplib "*) new_libs="$deplib $new_libs" ;;
167.7031 +	      *)
167.7032 +		case " $new_libs " in
167.7033 +		*" $deplib "*) ;;
167.7034 +		*) new_libs="$deplib $new_libs" ;;
167.7035 +		esac
167.7036 +		;;
167.7037 +	      esac
167.7038 +	      ;;
167.7039 +	    esac
167.7040 +	  done
167.7041 +	  tmp_libs=
167.7042 +	  for deplib in $new_libs; do
167.7043 +	    case $deplib in
167.7044 +	    -L*)
167.7045 +	      case " $tmp_libs " in
167.7046 +	      *" $deplib "*) ;;
167.7047 +	      *) tmp_libs="$tmp_libs $deplib" ;;
167.7048 +	      esac
167.7049 +	      ;;
167.7050 +	    *) tmp_libs="$tmp_libs $deplib" ;;
167.7051 +	    esac
167.7052 +	  done
167.7053 +	  eval $var=\"$tmp_libs\"
167.7054 +	done # for var
167.7055 +      fi
167.7056 +      # Last step: remove runtime libs from dependency_libs
167.7057 +      # (they stay in deplibs)
167.7058 +      tmp_libs=
167.7059 +      for i in $dependency_libs ; do
167.7060 +	case " $predeps $postdeps $compiler_lib_search_path " in
167.7061 +	*" $i "*)
167.7062 +	  i=""
167.7063 +	  ;;
167.7064 +	esac
167.7065 +	if test -n "$i" ; then
167.7066 +	  tmp_libs="$tmp_libs $i"
167.7067 +	fi
167.7068 +      done
167.7069 +      dependency_libs=$tmp_libs
167.7070 +    done # for pass
167.7071 +    if test "$linkmode" = prog; then
167.7072 +      dlfiles="$newdlfiles"
167.7073 +    fi
167.7074 +    if test "$linkmode" = prog || test "$linkmode" = lib; then
167.7075 +      dlprefiles="$newdlprefiles"
167.7076 +    fi
167.7077 +
167.7078 +    case $linkmode in
167.7079 +    oldlib)
167.7080 +      if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then
167.7081 +	func_warning "\`-dlopen' is ignored for archives"
167.7082 +      fi
167.7083 +
167.7084 +      case " $deplibs" in
167.7085 +      *\ -l* | *\ -L*)
167.7086 +	func_warning "\`-l' and \`-L' are ignored for archives" ;;
167.7087 +      esac
167.7088 +
167.7089 +      test -n "$rpath" && \
167.7090 +	func_warning "\`-rpath' is ignored for archives"
167.7091 +
167.7092 +      test -n "$xrpath" && \
167.7093 +	func_warning "\`-R' is ignored for archives"
167.7094 +
167.7095 +      test -n "$vinfo" && \
167.7096 +	func_warning "\`-version-info/-version-number' is ignored for archives"
167.7097 +
167.7098 +      test -n "$release" && \
167.7099 +	func_warning "\`-release' is ignored for archives"
167.7100 +
167.7101 +      test -n "$export_symbols$export_symbols_regex" && \
167.7102 +	func_warning "\`-export-symbols' is ignored for archives"
167.7103 +
167.7104 +      # Now set the variables for building old libraries.
167.7105 +      build_libtool_libs=no
167.7106 +      oldlibs="$output"
167.7107 +      objs="$objs$old_deplibs"
167.7108 +      ;;
167.7109 +
167.7110 +    lib)
167.7111 +      # Make sure we only generate libraries of the form `libNAME.la'.
167.7112 +      case $outputname in
167.7113 +      lib*)
167.7114 +	func_stripname 'lib' '.la' "$outputname"
167.7115 +	name=$func_stripname_result
167.7116 +	eval shared_ext=\"$shrext_cmds\"
167.7117 +	eval libname=\"$libname_spec\"
167.7118 +	;;
167.7119 +      *)
167.7120 +	test "$module" = no && \
167.7121 +	  func_fatal_help "libtool library \`$output' must begin with \`lib'"
167.7122 +
167.7123 +	if test "$need_lib_prefix" != no; then
167.7124 +	  # Add the "lib" prefix for modules if required
167.7125 +	  func_stripname '' '.la' "$outputname"
167.7126 +	  name=$func_stripname_result
167.7127 +	  eval shared_ext=\"$shrext_cmds\"
167.7128 +	  eval libname=\"$libname_spec\"
167.7129 +	else
167.7130 +	  func_stripname '' '.la' "$outputname"
167.7131 +	  libname=$func_stripname_result
167.7132 +	fi
167.7133 +	;;
167.7134 +      esac
167.7135 +
167.7136 +      if test -n "$objs"; then
167.7137 +	if test "$deplibs_check_method" != pass_all; then
167.7138 +	  func_fatal_error "cannot build libtool library \`$output' from non-libtool objects on this host:$objs"
167.7139 +	else
167.7140 +	  echo
167.7141 +	  $ECHO "*** Warning: Linking the shared library $output against the non-libtool"
167.7142 +	  $ECHO "*** objects $objs is not portable!"
167.7143 +	  libobjs="$libobjs $objs"
167.7144 +	fi
167.7145 +      fi
167.7146 +
167.7147 +      test "$dlself" != no && \
167.7148 +	func_warning "\`-dlopen self' is ignored for libtool libraries"
167.7149 +
167.7150 +      set dummy $rpath
167.7151 +      shift
167.7152 +      test "$#" -gt 1 && \
167.7153 +	func_warning "ignoring multiple \`-rpath's for a libtool library"
167.7154 +
167.7155 +      install_libdir="$1"
167.7156 +
167.7157 +      oldlibs=
167.7158 +      if test -z "$rpath"; then
167.7159 +	if test "$build_libtool_libs" = yes; then
167.7160 +	  # Building a libtool convenience library.
167.7161 +	  # Some compilers have problems with a `.al' extension so
167.7162 +	  # convenience libraries should have the same extension an
167.7163 +	  # archive normally would.
167.7164 +	  oldlibs="$output_objdir/$libname.$libext $oldlibs"
167.7165 +	  build_libtool_libs=convenience
167.7166 +	  build_old_libs=yes
167.7167 +	fi
167.7168 +
167.7169 +	test -n "$vinfo" && \
167.7170 +	  func_warning "\`-version-info/-version-number' is ignored for convenience libraries"
167.7171 +
167.7172 +	test -n "$release" && \
167.7173 +	  func_warning "\`-release' is ignored for convenience libraries"
167.7174 +      else
167.7175 +
167.7176 +	# Parse the version information argument.
167.7177 +	save_ifs="$IFS"; IFS=':'
167.7178 +	set dummy $vinfo 0 0 0
167.7179 +	shift
167.7180 +	IFS="$save_ifs"
167.7181 +
167.7182 +	test -n "$7" && \
167.7183 +	  func_fatal_help "too many parameters to \`-version-info'"
167.7184 +
167.7185 +	# convert absolute version numbers to libtool ages
167.7186 +	# this retains compatibility with .la files and attempts
167.7187 +	# to make the code below a bit more comprehensible
167.7188 +
167.7189 +	case $vinfo_number in
167.7190 +	yes)
167.7191 +	  number_major="$1"
167.7192 +	  number_minor="$2"
167.7193 +	  number_revision="$3"
167.7194 +	  #
167.7195 +	  # There are really only two kinds -- those that
167.7196 +	  # use the current revision as the major version
167.7197 +	  # and those that subtract age and use age as
167.7198 +	  # a minor version.  But, then there is irix
167.7199 +	  # which has an extra 1 added just for fun
167.7200 +	  #
167.7201 +	  case $version_type in
167.7202 +	  darwin|linux|osf|windows|none)
167.7203 +	    func_arith $number_major + $number_minor
167.7204 +	    current=$func_arith_result
167.7205 +	    age="$number_minor"
167.7206 +	    revision="$number_revision"
167.7207 +	    ;;
167.7208 +	  freebsd-aout|freebsd-elf|qnx|sunos)
167.7209 +	    current="$number_major"
167.7210 +	    revision="$number_minor"
167.7211 +	    age="0"
167.7212 +	    ;;
167.7213 +	  irix|nonstopux)
167.7214 +	    func_arith $number_major + $number_minor
167.7215 +	    current=$func_arith_result
167.7216 +	    age="$number_minor"
167.7217 +	    revision="$number_minor"
167.7218 +	    lt_irix_increment=no
167.7219 +	    ;;
167.7220 +	  esac
167.7221 +	  ;;
167.7222 +	no)
167.7223 +	  current="$1"
167.7224 +	  revision="$2"
167.7225 +	  age="$3"
167.7226 +	  ;;
167.7227 +	esac
167.7228 +
167.7229 +	# Check that each of the things are valid numbers.
167.7230 +	case $current in
167.7231 +	0|[1-9]|[1-9][0-9]|[1-9][0-9][0-9]|[1-9][0-9][0-9][0-9]|[1-9][0-9][0-9][0-9][0-9]) ;;
167.7232 +	*)
167.7233 +	  func_error "CURRENT \`$current' must be a nonnegative integer"
167.7234 +	  func_fatal_error "\`$vinfo' is not valid version information"
167.7235 +	  ;;
167.7236 +	esac
167.7237 +
167.7238 +	case $revision in
167.7239 +	0|[1-9]|[1-9][0-9]|[1-9][0-9][0-9]|[1-9][0-9][0-9][0-9]|[1-9][0-9][0-9][0-9][0-9]) ;;
167.7240 +	*)
167.7241 +	  func_error "REVISION \`$revision' must be a nonnegative integer"
167.7242 +	  func_fatal_error "\`$vinfo' is not valid version information"
167.7243 +	  ;;
167.7244 +	esac
167.7245 +
167.7246 +	case $age in
167.7247 +	0|[1-9]|[1-9][0-9]|[1-9][0-9][0-9]|[1-9][0-9][0-9][0-9]|[1-9][0-9][0-9][0-9][0-9]) ;;
167.7248 +	*)
167.7249 +	  func_error "AGE \`$age' must be a nonnegative integer"
167.7250 +	  func_fatal_error "\`$vinfo' is not valid version information"
167.7251 +	  ;;
167.7252 +	esac
167.7253 +
167.7254 +	if test "$age" -gt "$current"; then
167.7255 +	  func_error "AGE \`$age' is greater than the current interface number \`$current'"
167.7256 +	  func_fatal_error "\`$vinfo' is not valid version information"
167.7257 +	fi
167.7258 +
167.7259 +	# Calculate the version variables.
167.7260 +	major=
167.7261 +	versuffix=
167.7262 +	verstring=
167.7263 +	case $version_type in
167.7264 +	none) ;;
167.7265 +
167.7266 +	darwin)
167.7267 +	  # Like Linux, but with the current version available in
167.7268 +	  # verstring for coding it into the library header
167.7269 +	  func_arith $current - $age
167.7270 +	  major=.$func_arith_result
167.7271 +	  versuffix="$major.$age.$revision"
167.7272 +	  # Darwin ld doesn't like 0 for these options...
167.7273 +	  func_arith $current + 1
167.7274 +	  minor_current=$func_arith_result
167.7275 +	  xlcverstring="${wl}-compatibility_version ${wl}$minor_current ${wl}-current_version ${wl}$minor_current.$revision"
167.7276 +	  verstring="-compatibility_version $minor_current -current_version $minor_current.$revision"
167.7277 +	  ;;
167.7278 +
167.7279 +	freebsd-aout)
167.7280 +	  major=".$current"
167.7281 +	  versuffix=".$current.$revision";
167.7282 +	  ;;
167.7283 +
167.7284 +	freebsd-elf)
167.7285 +	  major=".$current"
167.7286 +	  versuffix=".$current"
167.7287 +	  ;;
167.7288 +
167.7289 +	irix | nonstopux)
167.7290 +	  if test "X$lt_irix_increment" = "Xno"; then
167.7291 +	    func_arith $current - $age
167.7292 +	  else
167.7293 +	    func_arith $current - $age + 1
167.7294 +	  fi
167.7295 +	  major=$func_arith_result
167.7296 +
167.7297 +	  case $version_type in
167.7298 +	    nonstopux) verstring_prefix=nonstopux ;;
167.7299 +	    *)         verstring_prefix=sgi ;;
167.7300 +	  esac
167.7301 +	  verstring="$verstring_prefix$major.$revision"
167.7302 +
167.7303 +	  # Add in all the interfaces that we are compatible with.
167.7304 +	  loop=$revision
167.7305 +	  while test "$loop" -ne 0; do
167.7306 +	    func_arith $revision - $loop
167.7307 +	    iface=$func_arith_result
167.7308 +	    func_arith $loop - 1
167.7309 +	    loop=$func_arith_result
167.7310 +	    verstring="$verstring_prefix$major.$iface:$verstring"
167.7311 +	  done
167.7312 +
167.7313 +	  # Before this point, $major must not contain `.'.
167.7314 +	  major=.$major
167.7315 +	  versuffix="$major.$revision"
167.7316 +	  ;;
167.7317 +
167.7318 +	linux)
167.7319 +	  func_arith $current - $age
167.7320 +	  major=.$func_arith_result
167.7321 +	  versuffix="$major.$age.$revision"
167.7322 +	  ;;
167.7323 +
167.7324 +	osf)
167.7325 +	  func_arith $current - $age
167.7326 +	  major=.$func_arith_result
167.7327 +	  versuffix=".$current.$age.$revision"
167.7328 +	  verstring="$current.$age.$revision"
167.7329 +
167.7330 +	  # Add in all the interfaces that we are compatible with.
167.7331 +	  loop=$age
167.7332 +	  while test "$loop" -ne 0; do
167.7333 +	    func_arith $current - $loop
167.7334 +	    iface=$func_arith_result
167.7335 +	    func_arith $loop - 1
167.7336 +	    loop=$func_arith_result
167.7337 +	    verstring="$verstring:${iface}.0"
167.7338 +	  done
167.7339 +
167.7340 +	  # Make executables depend on our current version.
167.7341 +	  verstring="$verstring:${current}.0"
167.7342 +	  ;;
167.7343 +
167.7344 +	qnx)
167.7345 +	  major=".$current"
167.7346 +	  versuffix=".$current"
167.7347 +	  ;;
167.7348 +
167.7349 +	sunos)
167.7350 +	  major=".$current"
167.7351 +	  versuffix=".$current.$revision"
167.7352 +	  ;;
167.7353 +
167.7354 +	windows)
167.7355 +	  # Use '-' rather than '.', since we only want one
167.7356 +	  # extension on DOS 8.3 filesystems.
167.7357 +	  func_arith $current - $age
167.7358 +	  major=$func_arith_result
167.7359 +	  versuffix="-$major"
167.7360 +	  ;;
167.7361 +
167.7362 +	*)
167.7363 +	  func_fatal_configuration "unknown library version type \`$version_type'"
167.7364 +	  ;;
167.7365 +	esac
167.7366 +
167.7367 +	# Clear the version info if we defaulted, and they specified a release.
167.7368 +	if test -z "$vinfo" && test -n "$release"; then
167.7369 +	  major=
167.7370 +	  case $version_type in
167.7371 +	  darwin)
167.7372 +	    # we can't check for "0.0" in archive_cmds due to quoting
167.7373 +	    # problems, so we reset it completely
167.7374 +	    verstring=
167.7375 +	    ;;
167.7376 +	  *)
167.7377 +	    verstring="0.0"
167.7378 +	    ;;
167.7379 +	  esac
167.7380 +	  if test "$need_version" = no; then
167.7381 +	    versuffix=
167.7382 +	  else
167.7383 +	    versuffix=".0.0"
167.7384 +	  fi
167.7385 +	fi
167.7386 +
167.7387 +	# Remove version info from name if versioning should be avoided
167.7388 +	if test "$avoid_version" = yes && test "$need_version" = no; then
167.7389 +	  major=
167.7390 +	  versuffix=
167.7391 +	  verstring=""
167.7392 +	fi
167.7393 +
167.7394 +	# Check to see if the archive will have undefined symbols.
167.7395 +	if test "$allow_undefined" = yes; then
167.7396 +	  if test "$allow_undefined_flag" = unsupported; then
167.7397 +	    func_warning "undefined symbols not allowed in $host shared libraries"
167.7398 +	    build_libtool_libs=no
167.7399 +	    build_old_libs=yes
167.7400 +	  fi
167.7401 +	else
167.7402 +	  # Don't allow undefined symbols.
167.7403 +	  allow_undefined_flag="$no_undefined_flag"
167.7404 +	fi
167.7405 +
167.7406 +      fi
167.7407 +
167.7408 +      func_generate_dlsyms "$libname" "$libname" "yes"
167.7409 +      libobjs="$libobjs $symfileobj"
167.7410 +      test "X$libobjs" = "X " && libobjs=
167.7411 +
167.7412 +      if test "$mode" != relink; then
167.7413 +	# Remove our outputs, but don't remove object files since they
167.7414 +	# may have been created when compiling PIC objects.
167.7415 +	removelist=
167.7416 +	tempremovelist=`$ECHO "$output_objdir/*"`
167.7417 +	for p in $tempremovelist; do
167.7418 +	  case $p in
167.7419 +	    *.$objext | *.gcno)
167.7420 +	       ;;
167.7421 +	    $output_objdir/$outputname | $output_objdir/$libname.* | $output_objdir/${libname}${release}.*)
167.7422 +	       if test "X$precious_files_regex" != "X"; then
167.7423 +		 if $ECHO "$p" | $EGREP -e "$precious_files_regex" >/dev/null 2>&1
167.7424 +		 then
167.7425 +		   continue
167.7426 +		 fi
167.7427 +	       fi
167.7428 +	       removelist="$removelist $p"
167.7429 +	       ;;
167.7430 +	    *) ;;
167.7431 +	  esac
167.7432 +	done
167.7433 +	test -n "$removelist" && \
167.7434 +	  func_show_eval "${RM}r \$removelist"
167.7435 +      fi
167.7436 +
167.7437 +      # Now set the variables for building old libraries.
167.7438 +      if test "$build_old_libs" = yes && test "$build_libtool_libs" != convenience ; then
167.7439 +	oldlibs="$oldlibs $output_objdir/$libname.$libext"
167.7440 +
167.7441 +	# Transform .lo files to .o files.
167.7442 +	oldobjs="$objs "`$ECHO "$libobjs" | $SP2NL | $SED "/\.${libext}$/d; $lo2o" | $NL2SP`
167.7443 +      fi
167.7444 +
167.7445 +      # Eliminate all temporary directories.
167.7446 +      #for path in $notinst_path; do
167.7447 +      #	lib_search_path=`$ECHO "$lib_search_path " | $SED "s% $path % %g"`
167.7448 +      #	deplibs=`$ECHO "$deplibs " | $SED "s% -L$path % %g"`
167.7449 +      #	dependency_libs=`$ECHO "$dependency_libs " | $SED "s% -L$path % %g"`
167.7450 +      #done
167.7451 +
167.7452 +      if test -n "$xrpath"; then
167.7453 +	# If the user specified any rpath flags, then add them.
167.7454 +	temp_xrpath=
167.7455 +	for libdir in $xrpath; do
167.7456 +	  temp_xrpath="$temp_xrpath -R$libdir"
167.7457 +	  case "$finalize_rpath " in
167.7458 +	  *" $libdir "*) ;;
167.7459 +	  *) finalize_rpath="$finalize_rpath $libdir" ;;
167.7460 +	  esac
167.7461 +	done
167.7462 +	if test "$hardcode_into_libs" != yes || test "$build_old_libs" = yes; then
167.7463 +	  dependency_libs="$temp_xrpath $dependency_libs"
167.7464 +	fi
167.7465 +      fi
167.7466 +
167.7467 +      # Make sure dlfiles contains only unique files that won't be dlpreopened
167.7468 +      old_dlfiles="$dlfiles"
167.7469 +      dlfiles=
167.7470 +      for lib in $old_dlfiles; do
167.7471 +	case " $dlprefiles $dlfiles " in
167.7472 +	*" $lib "*) ;;
167.7473 +	*) dlfiles="$dlfiles $lib" ;;
167.7474 +	esac
167.7475 +      done
167.7476 +
167.7477 +      # Make sure dlprefiles contains only unique files
167.7478 +      old_dlprefiles="$dlprefiles"
167.7479 +      dlprefiles=
167.7480 +      for lib in $old_dlprefiles; do
167.7481 +	case "$dlprefiles " in
167.7482 +	*" $lib "*) ;;
167.7483 +	*) dlprefiles="$dlprefiles $lib" ;;
167.7484 +	esac
167.7485 +      done
167.7486 +
167.7487 +      if test "$build_libtool_libs" = yes; then
167.7488 +	if test -n "$rpath"; then
167.7489 +	  case $host in
167.7490 +	  *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-beos* | *-cegcc* | *-*-haiku*)
167.7491 +	    # these systems don't actually have a c library (as such)!
167.7492 +	    ;;
167.7493 +	  *-*-rhapsody* | *-*-darwin1.[012])
167.7494 +	    # Rhapsody C library is in the System framework
167.7495 +	    deplibs="$deplibs System.ltframework"
167.7496 +	    ;;
167.7497 +	  *-*-netbsd*)
167.7498 +	    # Don't link with libc until the a.out ld.so is fixed.
167.7499 +	    ;;
167.7500 +	  *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*)
167.7501 +	    # Do not include libc due to us having libc/libc_r.
167.7502 +	    ;;
167.7503 +	  *-*-sco3.2v5* | *-*-sco5v6*)
167.7504 +	    # Causes problems with __ctype
167.7505 +	    ;;
167.7506 +	  *-*-sysv4.2uw2* | *-*-sysv5* | *-*-unixware* | *-*-OpenUNIX*)
167.7507 +	    # Compiler inserts libc in the correct place for threads to work
167.7508 +	    ;;
167.7509 +	  *)
167.7510 +	    # Add libc to deplibs on all other systems if necessary.
167.7511 +	    if test "$build_libtool_need_lc" = "yes"; then
167.7512 +	      deplibs="$deplibs -lc"
167.7513 +	    fi
167.7514 +	    ;;
167.7515 +	  esac
167.7516 +	fi
167.7517 +
167.7518 +	# Transform deplibs into only deplibs that can be linked in shared.
167.7519 +	name_save=$name
167.7520 +	libname_save=$libname
167.7521 +	release_save=$release
167.7522 +	versuffix_save=$versuffix
167.7523 +	major_save=$major
167.7524 +	# I'm not sure if I'm treating the release correctly.  I think
167.7525 +	# release should show up in the -l (ie -lgmp5) so we don't want to
167.7526 +	# add it in twice.  Is that correct?
167.7527 +	release=""
167.7528 +	versuffix=""
167.7529 +	major=""
167.7530 +	newdeplibs=
167.7531 +	droppeddeps=no
167.7532 +	case $deplibs_check_method in
167.7533 +	pass_all)
167.7534 +	  # Don't check for shared/static.  Everything works.
167.7535 +	  # This might be a little naive.  We might want to check
167.7536 +	  # whether the library exists or not.  But this is on
167.7537 +	  # osf3 & osf4 and I'm not really sure... Just
167.7538 +	  # implementing what was already the behavior.
167.7539 +	  newdeplibs=$deplibs
167.7540 +	  ;;
167.7541 +	test_compile)
167.7542 +	  # This code stresses the "libraries are programs" paradigm to its
167.7543 +	  # limits. Maybe even breaks it.  We compile a program, linking it
167.7544 +	  # against the deplibs as a proxy for the library.  Then we can check
167.7545 +	  # whether they linked in statically or dynamically with ldd.
167.7546 +	  $opt_dry_run || $RM conftest.c
167.7547 +	  cat > conftest.c <<EOF
167.7548 +	  int main() { return 0; }
167.7549 +EOF
167.7550 +	  $opt_dry_run || $RM conftest
167.7551 +	  if $LTCC $LTCFLAGS -o conftest conftest.c $deplibs; then
167.7552 +	    ldd_output=`ldd conftest`
167.7553 +	    for i in $deplibs; do
167.7554 +	      case $i in
167.7555 +	      -l*)
167.7556 +		func_stripname -l '' "$i"
167.7557 +		name=$func_stripname_result
167.7558 +		if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
167.7559 +		  case " $predeps $postdeps " in
167.7560 +		  *" $i "*)
167.7561 +		    newdeplibs="$newdeplibs $i"
167.7562 +		    i=""
167.7563 +		    ;;
167.7564 +		  esac
167.7565 +		fi
167.7566 +		if test -n "$i" ; then
167.7567 +		  libname=`eval "\\$ECHO \"$libname_spec\""`
167.7568 +		  deplib_matches=`eval "\\$ECHO \"$library_names_spec\""`
167.7569 +		  set dummy $deplib_matches; shift
167.7570 +		  deplib_match=$1
167.7571 +		  if test `expr "$ldd_output" : ".*$deplib_match"` -ne 0 ; then
167.7572 +		    newdeplibs="$newdeplibs $i"
167.7573 +		  else
167.7574 +		    droppeddeps=yes
167.7575 +		    echo
167.7576 +		    $ECHO "*** Warning: dynamic linker does not accept needed library $i."
167.7577 +		    echo "*** I have the capability to make that library automatically link in when"
167.7578 +		    echo "*** you link to this library.  But I can only do this if you have a"
167.7579 +		    echo "*** shared version of the library, which I believe you do not have"
167.7580 +		    echo "*** because a test_compile did reveal that the linker did not use it for"
167.7581 +		    echo "*** its dynamic dependency list that programs get resolved with at runtime."
167.7582 +		  fi
167.7583 +		fi
167.7584 +		;;
167.7585 +	      *)
167.7586 +		newdeplibs="$newdeplibs $i"
167.7587 +		;;
167.7588 +	      esac
167.7589 +	    done
167.7590 +	  else
167.7591 +	    # Error occurred in the first compile.  Let's try to salvage
167.7592 +	    # the situation: Compile a separate program for each library.
167.7593 +	    for i in $deplibs; do
167.7594 +	      case $i in
167.7595 +	      -l*)
167.7596 +		func_stripname -l '' "$i"
167.7597 +		name=$func_stripname_result
167.7598 +		$opt_dry_run || $RM conftest
167.7599 +		if $LTCC $LTCFLAGS -o conftest conftest.c $i; then
167.7600 +		  ldd_output=`ldd conftest`
167.7601 +		  if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
167.7602 +		    case " $predeps $postdeps " in
167.7603 +		    *" $i "*)
167.7604 +		      newdeplibs="$newdeplibs $i"
167.7605 +		      i=""
167.7606 +		      ;;
167.7607 +		    esac
167.7608 +		  fi
167.7609 +		  if test -n "$i" ; then
167.7610 +		    libname=`eval "\\$ECHO \"$libname_spec\""`
167.7611 +		    deplib_matches=`eval "\\$ECHO \"$library_names_spec\""`
167.7612 +		    set dummy $deplib_matches; shift
167.7613 +		    deplib_match=$1
167.7614 +		    if test `expr "$ldd_output" : ".*$deplib_match"` -ne 0 ; then
167.7615 +		      newdeplibs="$newdeplibs $i"
167.7616 +		    else
167.7617 +		      droppeddeps=yes
167.7618 +		      echo
167.7619 +		      $ECHO "*** Warning: dynamic linker does not accept needed library $i."
167.7620 +		      echo "*** I have the capability to make that library automatically link in when"
167.7621 +		      echo "*** you link to this library.  But I can only do this if you have a"
167.7622 +		      echo "*** shared version of the library, which you do not appear to have"
167.7623 +		      echo "*** because a test_compile did reveal that the linker did not use this one"
167.7624 +		      echo "*** as a dynamic dependency that programs can get resolved with at runtime."
167.7625 +		    fi
167.7626 +		  fi
167.7627 +		else
167.7628 +		  droppeddeps=yes
167.7629 +		  echo
167.7630 +		  $ECHO "*** Warning!  Library $i is needed by this library but I was not able to"
167.7631 +		  echo "*** make it link in!  You will probably need to install it or some"
167.7632 +		  echo "*** library that it depends on before this library will be fully"
167.7633 +		  echo "*** functional.  Installing it before continuing would be even better."
167.7634 +		fi
167.7635 +		;;
167.7636 +	      *)
167.7637 +		newdeplibs="$newdeplibs $i"
167.7638 +		;;
167.7639 +	      esac
167.7640 +	    done
167.7641 +	  fi
167.7642 +	  ;;
167.7643 +	file_magic*)
167.7644 +	  set dummy $deplibs_check_method; shift
167.7645 +	  file_magic_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"`
167.7646 +	  for a_deplib in $deplibs; do
167.7647 +	    case $a_deplib in
167.7648 +	    -l*)
167.7649 +	      func_stripname -l '' "$a_deplib"
167.7650 +	      name=$func_stripname_result
167.7651 +	      if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
167.7652 +		case " $predeps $postdeps " in
167.7653 +		*" $a_deplib "*)
167.7654 +		  newdeplibs="$newdeplibs $a_deplib"
167.7655 +		  a_deplib=""
167.7656 +		  ;;
167.7657 +		esac
167.7658 +	      fi
167.7659 +	      if test -n "$a_deplib" ; then
167.7660 +		libname=`eval "\\$ECHO \"$libname_spec\""`
167.7661 +		for i in $lib_search_path $sys_lib_search_path $shlib_search_path; do
167.7662 +		  potential_libs=`ls $i/$libname[.-]* 2>/dev/null`
167.7663 +		  for potent_lib in $potential_libs; do
167.7664 +		      # Follow soft links.
167.7665 +		      if ls -lLd "$potent_lib" 2>/dev/null |
167.7666 +			 $GREP " -> " >/dev/null; then
167.7667 +			continue
167.7668 +		      fi
167.7669 +		      # The statement above tries to avoid entering an
167.7670 +		      # endless loop below, in case of cyclic links.
167.7671 +		      # We might still enter an endless loop, since a link
167.7672 +		      # loop can be closed while we follow links,
167.7673 +		      # but so what?
167.7674 +		      potlib="$potent_lib"
167.7675 +		      while test -h "$potlib" 2>/dev/null; do
167.7676 +			potliblink=`ls -ld $potlib | ${SED} 's/.* -> //'`
167.7677 +			case $potliblink in
167.7678 +			[\\/]* | [A-Za-z]:[\\/]*) potlib="$potliblink";;
167.7679 +			*) potlib=`$ECHO "$potlib" | $SED 's,[^/]*$,,'`"$potliblink";;
167.7680 +			esac
167.7681 +		      done
167.7682 +		      if eval $file_magic_cmd \"\$potlib\" 2>/dev/null |
167.7683 +			 $SED -e 10q |
167.7684 +			 $EGREP "$file_magic_regex" > /dev/null; then
167.7685 +			newdeplibs="$newdeplibs $a_deplib"
167.7686 +			a_deplib=""
167.7687 +			break 2
167.7688 +		      fi
167.7689 +		  done
167.7690 +		done
167.7691 +	      fi
167.7692 +	      if test -n "$a_deplib" ; then
167.7693 +		droppeddeps=yes
167.7694 +		echo
167.7695 +		$ECHO "*** Warning: linker path does not have real file for library $a_deplib."
167.7696 +		echo "*** I have the capability to make that library automatically link in when"
167.7697 +		echo "*** you link to this library.  But I can only do this if you have a"
167.7698 +		echo "*** shared version of the library, which you do not appear to have"
167.7699 +		echo "*** because I did check the linker path looking for a file starting"
167.7700 +		if test -z "$potlib" ; then
167.7701 +		  $ECHO "*** with $libname but no candidates were found. (...for file magic test)"
167.7702 +		else
167.7703 +		  $ECHO "*** with $libname and none of the candidates passed a file format test"
167.7704 +		  $ECHO "*** using a file magic. Last file checked: $potlib"
167.7705 +		fi
167.7706 +	      fi
167.7707 +	      ;;
167.7708 +	    *)
167.7709 +	      # Add a -L argument.
167.7710 +	      newdeplibs="$newdeplibs $a_deplib"
167.7711 +	      ;;
167.7712 +	    esac
167.7713 +	  done # Gone through all deplibs.
167.7714 +	  ;;
167.7715 +	match_pattern*)
167.7716 +	  set dummy $deplibs_check_method; shift
167.7717 +	  match_pattern_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"`
167.7718 +	  for a_deplib in $deplibs; do
167.7719 +	    case $a_deplib in
167.7720 +	    -l*)
167.7721 +	      func_stripname -l '' "$a_deplib"
167.7722 +	      name=$func_stripname_result
167.7723 +	      if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
167.7724 +		case " $predeps $postdeps " in
167.7725 +		*" $a_deplib "*)
167.7726 +		  newdeplibs="$newdeplibs $a_deplib"
167.7727 +		  a_deplib=""
167.7728 +		  ;;
167.7729 +		esac
167.7730 +	      fi
167.7731 +	      if test -n "$a_deplib" ; then
167.7732 +		libname=`eval "\\$ECHO \"$libname_spec\""`
167.7733 +		for i in $lib_search_path $sys_lib_search_path $shlib_search_path; do
167.7734 +		  potential_libs=`ls $i/$libname[.-]* 2>/dev/null`
167.7735 +		  for potent_lib in $potential_libs; do
167.7736 +		    potlib="$potent_lib" # see symlink-check above in file_magic test
167.7737 +		    if eval "\$ECHO \"$potent_lib\"" 2>/dev/null | $SED 10q | \
167.7738 +		       $EGREP "$match_pattern_regex" > /dev/null; then
167.7739 +		      newdeplibs="$newdeplibs $a_deplib"
167.7740 +		      a_deplib=""
167.7741 +		      break 2
167.7742 +		    fi
167.7743 +		  done
167.7744 +		done
167.7745 +	      fi
167.7746 +	      if test -n "$a_deplib" ; then
167.7747 +		droppeddeps=yes
167.7748 +		echo
167.7749 +		$ECHO "*** Warning: linker path does not have real file for library $a_deplib."
167.7750 +		echo "*** I have the capability to make that library automatically link in when"
167.7751 +		echo "*** you link to this library.  But I can only do this if you have a"
167.7752 +		echo "*** shared version of the library, which you do not appear to have"
167.7753 +		echo "*** because I did check the linker path looking for a file starting"
167.7754 +		if test -z "$potlib" ; then
167.7755 +		  $ECHO "*** with $libname but no candidates were found. (...for regex pattern test)"
167.7756 +		else
167.7757 +		  $ECHO "*** with $libname and none of the candidates passed a file format test"
167.7758 +		  $ECHO "*** using a regex pattern. Last file checked: $potlib"
167.7759 +		fi
167.7760 +	      fi
167.7761 +	      ;;
167.7762 +	    *)
167.7763 +	      # Add a -L argument.
167.7764 +	      newdeplibs="$newdeplibs $a_deplib"
167.7765 +	      ;;
167.7766 +	    esac
167.7767 +	  done # Gone through all deplibs.
167.7768 +	  ;;
167.7769 +	none | unknown | *)
167.7770 +	  newdeplibs=""
167.7771 +	  tmp_deplibs=`$ECHO " $deplibs" | $SED 's/ -lc$//; s/ -[LR][^ ]*//g'`
167.7772 +	  if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
167.7773 +	    for i in $predeps $postdeps ; do
167.7774 +	      # can't use Xsed below, because $i might contain '/'
167.7775 +	      tmp_deplibs=`$ECHO " $tmp_deplibs" | $SED "s,$i,,"`
167.7776 +	    done
167.7777 +	  fi
167.7778 +	  case $tmp_deplibs in
167.7779 +	  *[!\	\ ]*)
167.7780 +	    echo
167.7781 +	    if test "X$deplibs_check_method" = "Xnone"; then
167.7782 +	      echo "*** Warning: inter-library dependencies are not supported in this platform."
167.7783 +	    else
167.7784 +	      echo "*** Warning: inter-library dependencies are not known to be supported."
167.7785 +	    fi
167.7786 +	    echo "*** All declared inter-library dependencies are being dropped."
167.7787 +	    droppeddeps=yes
167.7788 +	    ;;
167.7789 +	  esac
167.7790 +	  ;;
167.7791 +	esac
167.7792 +	versuffix=$versuffix_save
167.7793 +	major=$major_save
167.7794 +	release=$release_save
167.7795 +	libname=$libname_save
167.7796 +	name=$name_save
167.7797 +
167.7798 +	case $host in
167.7799 +	*-*-rhapsody* | *-*-darwin1.[012])
167.7800 +	  # On Rhapsody replace the C library with the System framework
167.7801 +	  newdeplibs=`$ECHO " $newdeplibs" | $SED 's/ -lc / System.ltframework /'`
167.7802 +	  ;;
167.7803 +	esac
167.7804 +
167.7805 +	if test "$droppeddeps" = yes; then
167.7806 +	  if test "$module" = yes; then
167.7807 +	    echo
167.7808 +	    echo "*** Warning: libtool could not satisfy all declared inter-library"
167.7809 +	    $ECHO "*** dependencies of module $libname.  Therefore, libtool will create"
167.7810 +	    echo "*** a static module, that should work as long as the dlopening"
167.7811 +	    echo "*** application is linked with the -dlopen flag."
167.7812 +	    if test -z "$global_symbol_pipe"; then
167.7813 +	      echo
167.7814 +	      echo "*** However, this would only work if libtool was able to extract symbol"
167.7815 +	      echo "*** lists from a program, using \`nm' or equivalent, but libtool could"
167.7816 +	      echo "*** not find such a program.  So, this module is probably useless."
167.7817 +	      echo "*** \`nm' from GNU binutils and a full rebuild may help."
167.7818 +	    fi
167.7819 +	    if test "$build_old_libs" = no; then
167.7820 +	      oldlibs="$output_objdir/$libname.$libext"
167.7821 +	      build_libtool_libs=module
167.7822 +	      build_old_libs=yes
167.7823 +	    else
167.7824 +	      build_libtool_libs=no
167.7825 +	    fi
167.7826 +	  else
167.7827 +	    echo "*** The inter-library dependencies that have been dropped here will be"
167.7828 +	    echo "*** automatically added whenever a program is linked with this library"
167.7829 +	    echo "*** or is declared to -dlopen it."
167.7830 +
167.7831 +	    if test "$allow_undefined" = no; then
167.7832 +	      echo
167.7833 +	      echo "*** Since this library must not contain undefined symbols,"
167.7834 +	      echo "*** because either the platform does not support them or"
167.7835 +	      echo "*** it was explicitly requested with -no-undefined,"
167.7836 +	      echo "*** libtool will only create a static version of it."
167.7837 +	      if test "$build_old_libs" = no; then
167.7838 +		oldlibs="$output_objdir/$libname.$libext"
167.7839 +		build_libtool_libs=module
167.7840 +		build_old_libs=yes
167.7841 +	      else
167.7842 +		build_libtool_libs=no
167.7843 +	      fi
167.7844 +	    fi
167.7845 +	  fi
167.7846 +	fi
167.7847 +	# Done checking deplibs!
167.7848 +	deplibs=$newdeplibs
167.7849 +      fi
167.7850 +      # Time to change all our "foo.ltframework" stuff back to "-framework foo"
167.7851 +      case $host in
167.7852 +	*-*-darwin*)
167.7853 +	  newdeplibs=`$ECHO " $newdeplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
167.7854 +	  new_inherited_linker_flags=`$ECHO " $new_inherited_linker_flags" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
167.7855 +	  deplibs=`$ECHO " $deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
167.7856 +	  ;;
167.7857 +      esac
167.7858 +
167.7859 +      # move library search paths that coincide with paths to not yet
167.7860 +      # installed libraries to the beginning of the library search list
167.7861 +      new_libs=
167.7862 +      for path in $notinst_path; do
167.7863 +	case " $new_libs " in
167.7864 +	*" -L$path/$objdir "*) ;;
167.7865 +	*)
167.7866 +	  case " $deplibs " in
167.7867 +	  *" -L$path/$objdir "*)
167.7868 +	    new_libs="$new_libs -L$path/$objdir" ;;
167.7869 +	  esac
167.7870 +	  ;;
167.7871 +	esac
167.7872 +      done
167.7873 +      for deplib in $deplibs; do
167.7874 +	case $deplib in
167.7875 +	-L*)
167.7876 +	  case " $new_libs " in
167.7877 +	  *" $deplib "*) ;;
167.7878 +	  *) new_libs="$new_libs $deplib" ;;
167.7879 +	  esac
167.7880 +	  ;;
167.7881 +	*) new_libs="$new_libs $deplib" ;;
167.7882 +	esac
167.7883 +      done
167.7884 +      deplibs="$new_libs"
167.7885 +
167.7886 +      # All the library-specific variables (install_libdir is set above).
167.7887 +      library_names=
167.7888 +      old_library=
167.7889 +      dlname=
167.7890 +
167.7891 +      # Test again, we may have decided not to build it any more
167.7892 +      if test "$build_libtool_libs" = yes; then
167.7893 +	if test "$hardcode_into_libs" = yes; then
167.7894 +	  # Hardcode the library paths
167.7895 +	  hardcode_libdirs=
167.7896 +	  dep_rpath=
167.7897 +	  rpath="$finalize_rpath"
167.7898 +	  test "$mode" != relink && rpath="$compile_rpath$rpath"
167.7899 +	  for libdir in $rpath; do
167.7900 +	    if test -n "$hardcode_libdir_flag_spec"; then
167.7901 +	      if test -n "$hardcode_libdir_separator"; then
167.7902 +		if test -z "$hardcode_libdirs"; then
167.7903 +		  hardcode_libdirs="$libdir"
167.7904 +		else
167.7905 +		  # Just accumulate the unique libdirs.
167.7906 +		  case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in
167.7907 +		  *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*)
167.7908 +		    ;;
167.7909 +		  *)
167.7910 +		    hardcode_libdirs="$hardcode_libdirs$hardcode_libdir_separator$libdir"
167.7911 +		    ;;
167.7912 +		  esac
167.7913 +		fi
167.7914 +	      else
167.7915 +		eval flag=\"$hardcode_libdir_flag_spec\"
167.7916 +		dep_rpath="$dep_rpath $flag"
167.7917 +	      fi
167.7918 +	    elif test -n "$runpath_var"; then
167.7919 +	      case "$perm_rpath " in
167.7920 +	      *" $libdir "*) ;;
167.7921 +	      *) perm_rpath="$perm_rpath $libdir" ;;
167.7922 +	      esac
167.7923 +	    fi
167.7924 +	  done
167.7925 +	  # Substitute the hardcoded libdirs into the rpath.
167.7926 +	  if test -n "$hardcode_libdir_separator" &&
167.7927 +	     test -n "$hardcode_libdirs"; then
167.7928 +	    libdir="$hardcode_libdirs"
167.7929 +	    if test -n "$hardcode_libdir_flag_spec_ld"; then
167.7930 +	      eval dep_rpath=\"$hardcode_libdir_flag_spec_ld\"
167.7931 +	    else
167.7932 +	      eval dep_rpath=\"$hardcode_libdir_flag_spec\"
167.7933 +	    fi
167.7934 +	  fi
167.7935 +	  if test -n "$runpath_var" && test -n "$perm_rpath"; then
167.7936 +	    # We should set the runpath_var.
167.7937 +	    rpath=
167.7938 +	    for dir in $perm_rpath; do
167.7939 +	      rpath="$rpath$dir:"
167.7940 +	    done
167.7941 +	    eval "$runpath_var='$rpath\$$runpath_var'; export $runpath_var"
167.7942 +	  fi
167.7943 +	  test -n "$dep_rpath" && deplibs="$dep_rpath $deplibs"
167.7944 +	fi
167.7945 +
167.7946 +	shlibpath="$finalize_shlibpath"
167.7947 +	test "$mode" != relink && shlibpath="$compile_shlibpath$shlibpath"
167.7948 +	if test -n "$shlibpath"; then
167.7949 +	  eval "$shlibpath_var='$shlibpath\$$shlibpath_var'; export $shlibpath_var"
167.7950 +	fi
167.7951 +
167.7952 +	# Get the real and link names of the library.
167.7953 +	eval shared_ext=\"$shrext_cmds\"
167.7954 +	eval library_names=\"$library_names_spec\"
167.7955 +	set dummy $library_names
167.7956 +	shift
167.7957 +	realname="$1"
167.7958 +	shift
167.7959 +
167.7960 +	if test -n "$soname_spec"; then
167.7961 +	  eval soname=\"$soname_spec\"
167.7962 +	else
167.7963 +	  soname="$realname"
167.7964 +	fi
167.7965 +	if test -z "$dlname"; then
167.7966 +	  dlname=$soname
167.7967 +	fi
167.7968 +
167.7969 +	lib="$output_objdir/$realname"
167.7970 +	linknames=
167.7971 +	for link
167.7972 +	do
167.7973 +	  linknames="$linknames $link"
167.7974 +	done
167.7975 +
167.7976 +	# Use standard objects if they are pic
167.7977 +	test -z "$pic_flag" && libobjs=`$ECHO "$libobjs" | $SP2NL | $SED "$lo2o" | $NL2SP`
167.7978 +	test "X$libobjs" = "X " && libobjs=
167.7979 +
167.7980 +	delfiles=
167.7981 +	if test -n "$export_symbols" && test -n "$include_expsyms"; then
167.7982 +	  $opt_dry_run || cp "$export_symbols" "$output_objdir/$libname.uexp"
167.7983 +	  export_symbols="$output_objdir/$libname.uexp"
167.7984 +	  delfiles="$delfiles $export_symbols"
167.7985 +	fi
167.7986 +
167.7987 +	orig_export_symbols=
167.7988 +	case $host_os in
167.7989 +	cygwin* | mingw* | cegcc*)
167.7990 +	  if test -n "$export_symbols" && test -z "$export_symbols_regex"; then
167.7991 +	    # exporting using user supplied symfile
167.7992 +	    if test "x`$SED 1q $export_symbols`" != xEXPORTS; then
167.7993 +	      # and it's NOT already a .def file. Must figure out
167.7994 +	      # which of the given symbols are data symbols and tag
167.7995 +	      # them as such. So, trigger use of export_symbols_cmds.
167.7996 +	      # export_symbols gets reassigned inside the "prepare
167.7997 +	      # the list of exported symbols" if statement, so the
167.7998 +	      # include_expsyms logic still works.
167.7999 +	      orig_export_symbols="$export_symbols"
167.8000 +	      export_symbols=
167.8001 +	      always_export_symbols=yes
167.8002 +	    fi
167.8003 +	  fi
167.8004 +	  ;;
167.8005 +	esac
167.8006 +
167.8007 +	# Prepare the list of exported symbols
167.8008 +	if test -z "$export_symbols"; then
167.8009 +	  if test "$always_export_symbols" = yes || test -n "$export_symbols_regex"; then
167.8010 +	    func_verbose "generating symbol list for \`$libname.la'"
167.8011 +	    export_symbols="$output_objdir/$libname.exp"
167.8012 +	    $opt_dry_run || $RM $export_symbols
167.8013 +	    cmds=$export_symbols_cmds
167.8014 +	    save_ifs="$IFS"; IFS='~'
167.8015 +	    for cmd in $cmds; do
167.8016 +	      IFS="$save_ifs"
167.8017 +	      eval cmd=\"$cmd\"
167.8018 +	      func_len " $cmd"
167.8019 +	      len=$func_len_result
167.8020 +	      if test "$len" -lt "$max_cmd_len" || test "$max_cmd_len" -le -1; then
167.8021 +		func_show_eval "$cmd" 'exit $?'
167.8022 +		skipped_export=false
167.8023 +	      else
167.8024 +		# The command line is too long to execute in one step.
167.8025 +		func_verbose "using reloadable object file for export list..."
167.8026 +		skipped_export=:
167.8027 +		# Break out early, otherwise skipped_export may be
167.8028 +		# set to false by a later but shorter cmd.
167.8029 +		break
167.8030 +	      fi
167.8031 +	    done
167.8032 +	    IFS="$save_ifs"
167.8033 +	    if test -n "$export_symbols_regex" && test "X$skipped_export" != "X:"; then
167.8034 +	      func_show_eval '$EGREP -e "$export_symbols_regex" "$export_symbols" > "${export_symbols}T"'
167.8035 +	      func_show_eval '$MV "${export_symbols}T" "$export_symbols"'
167.8036 +	    fi
167.8037 +	  fi
167.8038 +	fi
167.8039 +
167.8040 +	if test -n "$export_symbols" && test -n "$include_expsyms"; then
167.8041 +	  tmp_export_symbols="$export_symbols"
167.8042 +	  test -n "$orig_export_symbols" && tmp_export_symbols="$orig_export_symbols"
167.8043 +	  $opt_dry_run || eval '$ECHO "$include_expsyms" | $SP2NL >> "$tmp_export_symbols"'
167.8044 +	fi
167.8045 +
167.8046 +	if test "X$skipped_export" != "X:" && test -n "$orig_export_symbols"; then
167.8047 +	  # The given exports_symbols file has to be filtered, so filter it.
167.8048 +	  func_verbose "filter symbol list for \`$libname.la' to tag DATA exports"
167.8049 +	  # FIXME: $output_objdir/$libname.filter potentially contains lots of
167.8050 +	  # 's' commands which not all seds can handle. GNU sed should be fine
167.8051 +	  # though. Also, the filter scales superlinearly with the number of
167.8052 +	  # global variables. join(1) would be nice here, but unfortunately
167.8053 +	  # isn't a blessed tool.
167.8054 +	  $opt_dry_run || $SED -e '/[ ,]DATA/!d;s,\(.*\)\([ \,].*\),s|^\1$|\1\2|,' < $export_symbols > $output_objdir/$libname.filter
167.8055 +	  delfiles="$delfiles $export_symbols $output_objdir/$libname.filter"
167.8056 +	  export_symbols=$output_objdir/$libname.def
167.8057 +	  $opt_dry_run || $SED -f $output_objdir/$libname.filter < $orig_export_symbols > $export_symbols
167.8058 +	fi
167.8059 +
167.8060 +	tmp_deplibs=
167.8061 +	for test_deplib in $deplibs; do
167.8062 +	  case " $convenience " in
167.8063 +	  *" $test_deplib "*) ;;
167.8064 +	  *)
167.8065 +	    tmp_deplibs="$tmp_deplibs $test_deplib"
167.8066 +	    ;;
167.8067 +	  esac
167.8068 +	done
167.8069 +	deplibs="$tmp_deplibs"
167.8070 +
167.8071 +	if test -n "$convenience"; then
167.8072 +	  if test -n "$whole_archive_flag_spec" &&
167.8073 +	    test "$compiler_needs_object" = yes &&
167.8074 +	    test -z "$libobjs"; then
167.8075 +	    # extract the archives, so we have objects to list.
167.8076 +	    # TODO: could optimize this to just extract one archive.
167.8077 +	    whole_archive_flag_spec=
167.8078 +	  fi
167.8079 +	  if test -n "$whole_archive_flag_spec"; then
167.8080 +	    save_libobjs=$libobjs
167.8081 +	    eval libobjs=\"\$libobjs $whole_archive_flag_spec\"
167.8082 +	    test "X$libobjs" = "X " && libobjs=
167.8083 +	  else
167.8084 +	    gentop="$output_objdir/${outputname}x"
167.8085 +	    generated="$generated $gentop"
167.8086 +
167.8087 +	    func_extract_archives $gentop $convenience
167.8088 +	    libobjs="$libobjs $func_extract_archives_result"
167.8089 +	    test "X$libobjs" = "X " && libobjs=
167.8090 +	  fi
167.8091 +	fi
167.8092 +
167.8093 +	if test "$thread_safe" = yes && test -n "$thread_safe_flag_spec"; then
167.8094 +	  eval flag=\"$thread_safe_flag_spec\"
167.8095 +	  linker_flags="$linker_flags $flag"
167.8096 +	fi
167.8097 +
167.8098 +	# Make a backup of the uninstalled library when relinking
167.8099 +	if test "$mode" = relink; then
167.8100 +	  $opt_dry_run || eval '(cd $output_objdir && $RM ${realname}U && $MV $realname ${realname}U)' || exit $?
167.8101 +	fi
167.8102 +
167.8103 +	# Do each of the archive commands.
167.8104 +	if test "$module" = yes && test -n "$module_cmds" ; then
167.8105 +	  if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then
167.8106 +	    eval test_cmds=\"$module_expsym_cmds\"
167.8107 +	    cmds=$module_expsym_cmds
167.8108 +	  else
167.8109 +	    eval test_cmds=\"$module_cmds\"
167.8110 +	    cmds=$module_cmds
167.8111 +	  fi
167.8112 +	else
167.8113 +	  if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then
167.8114 +	    eval test_cmds=\"$archive_expsym_cmds\"
167.8115 +	    cmds=$archive_expsym_cmds
167.8116 +	  else
167.8117 +	    eval test_cmds=\"$archive_cmds\"
167.8118 +	    cmds=$archive_cmds
167.8119 +	  fi
167.8120 +	fi
167.8121 +
167.8122 +	if test "X$skipped_export" != "X:" &&
167.8123 +	   func_len " $test_cmds" &&
167.8124 +	   len=$func_len_result &&
167.8125 +	   test "$len" -lt "$max_cmd_len" || test "$max_cmd_len" -le -1; then
167.8126 +	  :
167.8127 +	else
167.8128 +	  # The command line is too long to link in one step, link piecewise
167.8129 +	  # or, if using GNU ld and skipped_export is not :, use a linker
167.8130 +	  # script.
167.8131 +
167.8132 +	  # Save the value of $output and $libobjs because we want to
167.8133 +	  # use them later.  If we have whole_archive_flag_spec, we
167.8134 +	  # want to use save_libobjs as it was before
167.8135 +	  # whole_archive_flag_spec was expanded, because we can't
167.8136 +	  # assume the linker understands whole_archive_flag_spec.
167.8137 +	  # This may have to be revisited, in case too many
167.8138 +	  # convenience libraries get linked in and end up exceeding
167.8139 +	  # the spec.
167.8140 +	  if test -z "$convenience" || test -z "$whole_archive_flag_spec"; then
167.8141 +	    save_libobjs=$libobjs
167.8142 +	  fi
167.8143 +	  save_output=$output
167.8144 +	  func_basename "$output"
167.8145 +	  output_la=$func_basename_result
167.8146 +
167.8147 +	  # Clear the reloadable object creation command queue and
167.8148 +	  # initialize k to one.
167.8149 +	  test_cmds=
167.8150 +	  concat_cmds=
167.8151 +	  objlist=
167.8152 +	  last_robj=
167.8153 +	  k=1
167.8154 +
167.8155 +	  if test -n "$save_libobjs" && test "X$skipped_export" != "X:" && test "$with_gnu_ld" = yes; then
167.8156 +	    output=${output_objdir}/${output_la}.lnkscript
167.8157 +	    func_verbose "creating GNU ld script: $output"
167.8158 +	    echo 'INPUT (' > $output
167.8159 +	    for obj in $save_libobjs
167.8160 +	    do
167.8161 +	      $ECHO "$obj" >> $output
167.8162 +	    done
167.8163 +	    echo ')' >> $output
167.8164 +	    delfiles="$delfiles $output"
167.8165 +	  elif test -n "$save_libobjs" && test "X$skipped_export" != "X:" && test "X$file_list_spec" != X; then
167.8166 +	    output=${output_objdir}/${output_la}.lnk
167.8167 +	    func_verbose "creating linker input file list: $output"
167.8168 +	    : > $output
167.8169 +	    set x $save_libobjs
167.8170 +	    shift
167.8171 +	    firstobj=
167.8172 +	    if test "$compiler_needs_object" = yes; then
167.8173 +	      firstobj="$1 "
167.8174 +	      shift
167.8175 +	    fi
167.8176 +	    for obj
167.8177 +	    do
167.8178 +	      $ECHO "$obj" >> $output
167.8179 +	    done
167.8180 +	    delfiles="$delfiles $output"
167.8181 +	    output=$firstobj\"$file_list_spec$output\"
167.8182 +	  else
167.8183 +	    if test -n "$save_libobjs"; then
167.8184 +	      func_verbose "creating reloadable object files..."
167.8185 +	      output=$output_objdir/$output_la-${k}.$objext
167.8186 +	      eval test_cmds=\"$reload_cmds\"
167.8187 +	      func_len " $test_cmds"
167.8188 +	      len0=$func_len_result
167.8189 +	      len=$len0
167.8190 +
167.8191 +	      # Loop over the list of objects to be linked.
167.8192 +	      for obj in $save_libobjs
167.8193 +	      do
167.8194 +		func_len " $obj"
167.8195 +		func_arith $len + $func_len_result
167.8196 +		len=$func_arith_result
167.8197 +		if test "X$objlist" = X ||
167.8198 +		   test "$len" -lt "$max_cmd_len"; then
167.8199 +		  func_append objlist " $obj"
167.8200 +		else
167.8201 +		  # The command $test_cmds is almost too long, add a
167.8202 +		  # command to the queue.
167.8203 +		  if test "$k" -eq 1 ; then
167.8204 +		    # The first file doesn't have a previous command to add.
167.8205 +		    reload_objs=$objlist
167.8206 +		    eval concat_cmds=\"$reload_cmds\"
167.8207 +		  else
167.8208 +		    # All subsequent reloadable object files will link in
167.8209 +		    # the last one created.
167.8210 +		    reload_objs="$objlist $last_robj"
167.8211 +		    eval concat_cmds=\"\$concat_cmds~$reload_cmds~\$RM $last_robj\"
167.8212 +		  fi
167.8213 +		  last_robj=$output_objdir/$output_la-${k}.$objext
167.8214 +		  func_arith $k + 1
167.8215 +		  k=$func_arith_result
167.8216 +		  output=$output_objdir/$output_la-${k}.$objext
167.8217 +		  objlist=" $obj"
167.8218 +		  func_len " $last_robj"
167.8219 +		  func_arith $len0 + $func_len_result
167.8220 +		  len=$func_arith_result
167.8221 +		fi
167.8222 +	      done
167.8223 +	      # Handle the remaining objects by creating one last
167.8224 +	      # reloadable object file.  All subsequent reloadable object
167.8225 +	      # files will link in the last one created.
167.8226 +	      test -z "$concat_cmds" || concat_cmds=$concat_cmds~
167.8227 +	      reload_objs="$objlist $last_robj"
167.8228 +	      eval concat_cmds=\"\${concat_cmds}$reload_cmds\"
167.8229 +	      if test -n "$last_robj"; then
167.8230 +	        eval concat_cmds=\"\${concat_cmds}~\$RM $last_robj\"
167.8231 +	      fi
167.8232 +	      delfiles="$delfiles $output"
167.8233 +
167.8234 +	    else
167.8235 +	      output=
167.8236 +	    fi
167.8237 +
167.8238 +	    if ${skipped_export-false}; then
167.8239 +	      func_verbose "generating symbol list for \`$libname.la'"
167.8240 +	      export_symbols="$output_objdir/$libname.exp"
167.8241 +	      $opt_dry_run || $RM $export_symbols
167.8242 +	      libobjs=$output
167.8243 +	      # Append the command to create the export file.
167.8244 +	      test -z "$concat_cmds" || concat_cmds=$concat_cmds~
167.8245 +	      eval concat_cmds=\"\$concat_cmds$export_symbols_cmds\"
167.8246 +	      if test -n "$last_robj"; then
167.8247 +		eval concat_cmds=\"\$concat_cmds~\$RM $last_robj\"
167.8248 +	      fi
167.8249 +	    fi
167.8250 +
167.8251 +	    test -n "$save_libobjs" &&
167.8252 +	      func_verbose "creating a temporary reloadable object file: $output"
167.8253 +
167.8254 +	    # Loop through the commands generated above and execute them.
167.8255 +	    save_ifs="$IFS"; IFS='~'
167.8256 +	    for cmd in $concat_cmds; do
167.8257 +	      IFS="$save_ifs"
167.8258 +	      $opt_silent || {
167.8259 +		  func_quote_for_expand "$cmd"
167.8260 +		  eval "func_echo $func_quote_for_expand_result"
167.8261 +	      }
167.8262 +	      $opt_dry_run || eval "$cmd" || {
167.8263 +		lt_exit=$?
167.8264 +
167.8265 +		# Restore the uninstalled library and exit
167.8266 +		if test "$mode" = relink; then
167.8267 +		  ( cd "$output_objdir" && \
167.8268 +		    $RM "${realname}T" && \
167.8269 +		    $MV "${realname}U" "$realname" )
167.8270 +		fi
167.8271 +
167.8272 +		exit $lt_exit
167.8273 +	      }
167.8274 +	    done
167.8275 +	    IFS="$save_ifs"
167.8276 +
167.8277 +	    if test -n "$export_symbols_regex" && ${skipped_export-false}; then
167.8278 +	      func_show_eval '$EGREP -e "$export_symbols_regex" "$export_symbols" > "${export_symbols}T"'
167.8279 +	      func_show_eval '$MV "${export_symbols}T" "$export_symbols"'
167.8280 +	    fi
167.8281 +	  fi
167.8282 +
167.8283 +          if ${skipped_export-false}; then
167.8284 +	    if test -n "$export_symbols" && test -n "$include_expsyms"; then
167.8285 +	      tmp_export_symbols="$export_symbols"
167.8286 +	      test -n "$orig_export_symbols" && tmp_export_symbols="$orig_export_symbols"
167.8287 +	      $opt_dry_run || eval '$ECHO "$include_expsyms" | $SP2NL >> "$tmp_export_symbols"'
167.8288 +	    fi
167.8289 +
167.8290 +	    if test -n "$orig_export_symbols"; then
167.8291 +	      # The given exports_symbols file has to be filtered, so filter it.
167.8292 +	      func_verbose "filter symbol list for \`$libname.la' to tag DATA exports"
167.8293 +	      # FIXME: $output_objdir/$libname.filter potentially contains lots of
167.8294 +	      # 's' commands which not all seds can handle. GNU sed should be fine
167.8295 +	      # though. Also, the filter scales superlinearly with the number of
167.8296 +	      # global variables. join(1) would be nice here, but unfortunately
167.8297 +	      # isn't a blessed tool.
167.8298 +	      $opt_dry_run || $SED -e '/[ ,]DATA/!d;s,\(.*\)\([ \,].*\),s|^\1$|\1\2|,' < $export_symbols > $output_objdir/$libname.filter
167.8299 +	      delfiles="$delfiles $export_symbols $output_objdir/$libname.filter"
167.8300 +	      export_symbols=$output_objdir/$libname.def
167.8301 +	      $opt_dry_run || $SED -f $output_objdir/$libname.filter < $orig_export_symbols > $export_symbols
167.8302 +	    fi
167.8303 +	  fi
167.8304 +
167.8305 +	  libobjs=$output
167.8306 +	  # Restore the value of output.
167.8307 +	  output=$save_output
167.8308 +
167.8309 +	  if test -n "$convenience" && test -n "$whole_archive_flag_spec"; then
167.8310 +	    eval libobjs=\"\$libobjs $whole_archive_flag_spec\"
167.8311 +	    test "X$libobjs" = "X " && libobjs=
167.8312 +	  fi
167.8313 +	  # Expand the library linking commands again to reset the
167.8314 +	  # value of $libobjs for piecewise linking.
167.8315 +
167.8316 +	  # Do each of the archive commands.
167.8317 +	  if test "$module" = yes && test -n "$module_cmds" ; then
167.8318 +	    if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then
167.8319 +	      cmds=$module_expsym_cmds
167.8320 +	    else
167.8321 +	      cmds=$module_cmds
167.8322 +	    fi
167.8323 +	  else
167.8324 +	    if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then
167.8325 +	      cmds=$archive_expsym_cmds
167.8326 +	    else
167.8327 +	      cmds=$archive_cmds
167.8328 +	    fi
167.8329 +	  fi
167.8330 +	fi
167.8331 +
167.8332 +	if test -n "$delfiles"; then
167.8333 +	  # Append the command to remove temporary files to $cmds.
167.8334 +	  eval cmds=\"\$cmds~\$RM $delfiles\"
167.8335 +	fi
167.8336 +
167.8337 +	# Add any objects from preloaded convenience libraries
167.8338 +	if test -n "$dlprefiles"; then
167.8339 +	  gentop="$output_objdir/${outputname}x"
167.8340 +	  generated="$generated $gentop"
167.8341 +
167.8342 +	  func_extract_archives $gentop $dlprefiles
167.8343 +	  libobjs="$libobjs $func_extract_archives_result"
167.8344 +	  test "X$libobjs" = "X " && libobjs=
167.8345 +	fi
167.8346 +
167.8347 +	save_ifs="$IFS"; IFS='~'
167.8348 +	for cmd in $cmds; do
167.8349 +	  IFS="$save_ifs"
167.8350 +	  eval cmd=\"$cmd\"
167.8351 +	  $opt_silent || {
167.8352 +	    func_quote_for_expand "$cmd"
167.8353 +	    eval "func_echo $func_quote_for_expand_result"
167.8354 +	  }
167.8355 +	  $opt_dry_run || eval "$cmd" || {
167.8356 +	    lt_exit=$?
167.8357 +
167.8358 +	    # Restore the uninstalled library and exit
167.8359 +	    if test "$mode" = relink; then
167.8360 +	      ( cd "$output_objdir" && \
167.8361 +	        $RM "${realname}T" && \
167.8362 +		$MV "${realname}U" "$realname" )
167.8363 +	    fi
167.8364 +
167.8365 +	    exit $lt_exit
167.8366 +	  }
167.8367 +	done
167.8368 +	IFS="$save_ifs"
167.8369 +
167.8370 +	# Restore the uninstalled library and exit
167.8371 +	if test "$mode" = relink; then
167.8372 +	  $opt_dry_run || eval '(cd $output_objdir && $RM ${realname}T && $MV $realname ${realname}T && $MV ${realname}U $realname)' || exit $?
167.8373 +
167.8374 +	  if test -n "$convenience"; then
167.8375 +	    if test -z "$whole_archive_flag_spec"; then
167.8376 +	      func_show_eval '${RM}r "$gentop"'
167.8377 +	    fi
167.8378 +	  fi
167.8379 +
167.8380 +	  exit $EXIT_SUCCESS
167.8381 +	fi
167.8382 +
167.8383 +	# Create links to the real library.
167.8384 +	for linkname in $linknames; do
167.8385 +	  if test "$realname" != "$linkname"; then
167.8386 +	    func_show_eval '(cd "$output_objdir" && $RM "$linkname" && $LN_S "$realname" "$linkname")' 'exit $?'
167.8387 +	  fi
167.8388 +	done
167.8389 +
167.8390 +	# If -module or -export-dynamic was specified, set the dlname.
167.8391 +	if test "$module" = yes || test "$export_dynamic" = yes; then
167.8392 +	  # On all known operating systems, these are identical.
167.8393 +	  dlname="$soname"
167.8394 +	fi
167.8395 +      fi
167.8396 +      ;;
167.8397 +
167.8398 +    obj)
167.8399 +      if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then
167.8400 +	func_warning "\`-dlopen' is ignored for objects"
167.8401 +      fi
167.8402 +
167.8403 +      case " $deplibs" in
167.8404 +      *\ -l* | *\ -L*)
167.8405 +	func_warning "\`-l' and \`-L' are ignored for objects" ;;
167.8406 +      esac
167.8407 +
167.8408 +      test -n "$rpath" && \
167.8409 +	func_warning "\`-rpath' is ignored for objects"
167.8410 +
167.8411 +      test -n "$xrpath" && \
167.8412 +	func_warning "\`-R' is ignored for objects"
167.8413 +
167.8414 +      test -n "$vinfo" && \
167.8415 +	func_warning "\`-version-info' is ignored for objects"
167.8416 +
167.8417 +      test -n "$release" && \
167.8418 +	func_warning "\`-release' is ignored for objects"
167.8419 +
167.8420 +      case $output in
167.8421 +      *.lo)
167.8422 +	test -n "$objs$old_deplibs" && \
167.8423 +	  func_fatal_error "cannot build library object \`$output' from non-libtool objects"
167.8424 +
167.8425 +	libobj=$output
167.8426 +	func_lo2o "$libobj"
167.8427 +	obj=$func_lo2o_result
167.8428 +	;;
167.8429 +      *)
167.8430 +	libobj=
167.8431 +	obj="$output"
167.8432 +	;;
167.8433 +      esac
167.8434 +
167.8435 +      # Delete the old objects.
167.8436 +      $opt_dry_run || $RM $obj $libobj
167.8437 +
167.8438 +      # Objects from convenience libraries.  This assumes
167.8439 +      # single-version convenience libraries.  Whenever we create
167.8440 +      # different ones for PIC/non-PIC, this we'll have to duplicate
167.8441 +      # the extraction.
167.8442 +      reload_conv_objs=
167.8443 +      gentop=
167.8444 +      # reload_cmds runs $LD directly, so let us get rid of
167.8445 +      # -Wl from whole_archive_flag_spec and hope we can get by with
167.8446 +      # turning comma into space..
167.8447 +      wl=
167.8448 +
167.8449 +      if test -n "$convenience"; then
167.8450 +	if test -n "$whole_archive_flag_spec"; then
167.8451 +	  eval tmp_whole_archive_flags=\"$whole_archive_flag_spec\"
167.8452 +	  reload_conv_objs=$reload_objs\ `$ECHO "$tmp_whole_archive_flags" | $SED 's|,| |g'`
167.8453 +	else
167.8454 +	  gentop="$output_objdir/${obj}x"
167.8455 +	  generated="$generated $gentop"
167.8456 +
167.8457 +	  func_extract_archives $gentop $convenience
167.8458 +	  reload_conv_objs="$reload_objs $func_extract_archives_result"
167.8459 +	fi
167.8460 +      fi
167.8461 +
167.8462 +      # Create the old-style object.
167.8463 +      reload_objs="$objs$old_deplibs "`$ECHO "$libobjs" | $SP2NL | $SED "/\.${libext}$/d; /\.lib$/d; $lo2o" | $NL2SP`" $reload_conv_objs" ### testsuite: skip nested quoting test
167.8464 +
167.8465 +      output="$obj"
167.8466 +      func_execute_cmds "$reload_cmds" 'exit $?'
167.8467 +
167.8468 +      # Exit if we aren't doing a library object file.
167.8469 +      if test -z "$libobj"; then
167.8470 +	if test -n "$gentop"; then
167.8471 +	  func_show_eval '${RM}r "$gentop"'
167.8472 +	fi
167.8473 +
167.8474 +	exit $EXIT_SUCCESS
167.8475 +      fi
167.8476 +
167.8477 +      if test "$build_libtool_libs" != yes; then
167.8478 +	if test -n "$gentop"; then
167.8479 +	  func_show_eval '${RM}r "$gentop"'
167.8480 +	fi
167.8481 +
167.8482 +	# Create an invalid libtool object if no PIC, so that we don't
167.8483 +	# accidentally link it into a program.
167.8484 +	# $show "echo timestamp > $libobj"
167.8485 +	# $opt_dry_run || eval "echo timestamp > $libobj" || exit $?
167.8486 +	exit $EXIT_SUCCESS
167.8487 +      fi
167.8488 +
167.8489 +      if test -n "$pic_flag" || test "$pic_mode" != default; then
167.8490 +	# Only do commands if we really have different PIC objects.
167.8491 +	reload_objs="$libobjs $reload_conv_objs"
167.8492 +	output="$libobj"
167.8493 +	func_execute_cmds "$reload_cmds" 'exit $?'
167.8494 +      fi
167.8495 +
167.8496 +      if test -n "$gentop"; then
167.8497 +	func_show_eval '${RM}r "$gentop"'
167.8498 +      fi
167.8499 +
167.8500 +      exit $EXIT_SUCCESS
167.8501 +      ;;
167.8502 +
167.8503 +    prog)
167.8504 +      case $host in
167.8505 +	*cygwin*) func_stripname '' '.exe' "$output"
167.8506 +	          output=$func_stripname_result.exe;;
167.8507 +      esac
167.8508 +      test -n "$vinfo" && \
167.8509 +	func_warning "\`-version-info' is ignored for programs"
167.8510 +
167.8511 +      test -n "$release" && \
167.8512 +	func_warning "\`-release' is ignored for programs"
167.8513 +
167.8514 +      test "$preload" = yes \
167.8515 +        && test "$dlopen_support" = unknown \
167.8516 +	&& test "$dlopen_self" = unknown \
167.8517 +	&& test "$dlopen_self_static" = unknown && \
167.8518 +	  func_warning "\`LT_INIT([dlopen])' not used. Assuming no dlopen support."
167.8519 +
167.8520 +      case $host in
167.8521 +      *-*-rhapsody* | *-*-darwin1.[012])
167.8522 +	# On Rhapsody replace the C library is the System framework
167.8523 +	compile_deplibs=`$ECHO " $compile_deplibs" | $SED 's/ -lc / System.ltframework /'`
167.8524 +	finalize_deplibs=`$ECHO " $finalize_deplibs" | $SED 's/ -lc / System.ltframework /'`
167.8525 +	;;
167.8526 +      esac
167.8527 +
167.8528 +      case $host in
167.8529 +      *-*-darwin*)
167.8530 +	# Don't allow lazy linking, it breaks C++ global constructors
167.8531 +	# But is supposedly fixed on 10.4 or later (yay!).
167.8532 +	if test "$tagname" = CXX ; then
167.8533 +	  case ${MACOSX_DEPLOYMENT_TARGET-10.0} in
167.8534 +	    10.[0123])
167.8535 +	      compile_command="$compile_command ${wl}-bind_at_load"
167.8536 +	      finalize_command="$finalize_command ${wl}-bind_at_load"
167.8537 +	    ;;
167.8538 +	  esac
167.8539 +	fi
167.8540 +	# Time to change all our "foo.ltframework" stuff back to "-framework foo"
167.8541 +	compile_deplibs=`$ECHO " $compile_deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
167.8542 +	finalize_deplibs=`$ECHO " $finalize_deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
167.8543 +	;;
167.8544 +      esac
167.8545 +
167.8546 +
167.8547 +      # move library search paths that coincide with paths to not yet
167.8548 +      # installed libraries to the beginning of the library search list
167.8549 +      new_libs=
167.8550 +      for path in $notinst_path; do
167.8551 +	case " $new_libs " in
167.8552 +	*" -L$path/$objdir "*) ;;
167.8553 +	*)
167.8554 +	  case " $compile_deplibs " in
167.8555 +	  *" -L$path/$objdir "*)
167.8556 +	    new_libs="$new_libs -L$path/$objdir" ;;
167.8557 +	  esac
167.8558 +	  ;;
167.8559 +	esac
167.8560 +      done
167.8561 +      for deplib in $compile_deplibs; do
167.8562 +	case $deplib in
167.8563 +	-L*)
167.8564 +	  case " $new_libs " in
167.8565 +	  *" $deplib "*) ;;
167.8566 +	  *) new_libs="$new_libs $deplib" ;;
167.8567 +	  esac
167.8568 +	  ;;
167.8569 +	*) new_libs="$new_libs $deplib" ;;
167.8570 +	esac
167.8571 +      done
167.8572 +      compile_deplibs="$new_libs"
167.8573 +
167.8574 +
167.8575 +      compile_command="$compile_command $compile_deplibs"
167.8576 +      finalize_command="$finalize_command $finalize_deplibs"
167.8577 +
167.8578 +      if test -n "$rpath$xrpath"; then
167.8579 +	# If the user specified any rpath flags, then add them.
167.8580 +	for libdir in $rpath $xrpath; do
167.8581 +	  # This is the magic to use -rpath.
167.8582 +	  case "$finalize_rpath " in
167.8583 +	  *" $libdir "*) ;;
167.8584 +	  *) finalize_rpath="$finalize_rpath $libdir" ;;
167.8585 +	  esac
167.8586 +	done
167.8587 +      fi
167.8588 +
167.8589 +      # Now hardcode the library paths
167.8590 +      rpath=
167.8591 +      hardcode_libdirs=
167.8592 +      for libdir in $compile_rpath $finalize_rpath; do
167.8593 +	if test -n "$hardcode_libdir_flag_spec"; then
167.8594 +	  if test -n "$hardcode_libdir_separator"; then
167.8595 +	    if test -z "$hardcode_libdirs"; then
167.8596 +	      hardcode_libdirs="$libdir"
167.8597 +	    else
167.8598 +	      # Just accumulate the unique libdirs.
167.8599 +	      case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in
167.8600 +	      *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*)
167.8601 +		;;
167.8602 +	      *)
167.8603 +		hardcode_libdirs="$hardcode_libdirs$hardcode_libdir_separator$libdir"
167.8604 +		;;
167.8605 +	      esac
167.8606 +	    fi
167.8607 +	  else
167.8608 +	    eval flag=\"$hardcode_libdir_flag_spec\"
167.8609 +	    rpath="$rpath $flag"
167.8610 +	  fi
167.8611 +	elif test -n "$runpath_var"; then
167.8612 +	  case "$perm_rpath " in
167.8613 +	  *" $libdir "*) ;;
167.8614 +	  *) perm_rpath="$perm_rpath $libdir" ;;
167.8615 +	  esac
167.8616 +	fi
167.8617 +	case $host in
167.8618 +	*-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*)
167.8619 +	  testbindir=`${ECHO} "$libdir" | ${SED} -e 's*/lib$*/bin*'`
167.8620 +	  case :$dllsearchpath: in
167.8621 +	  *":$libdir:"*) ;;
167.8622 +	  ::) dllsearchpath=$libdir;;
167.8623 +	  *) dllsearchpath="$dllsearchpath:$libdir";;
167.8624 +	  esac
167.8625 +	  case :$dllsearchpath: in
167.8626 +	  *":$testbindir:"*) ;;
167.8627 +	  ::) dllsearchpath=$testbindir;;
167.8628 +	  *) dllsearchpath="$dllsearchpath:$testbindir";;
167.8629 +	  esac
167.8630 +	  ;;
167.8631 +	esac
167.8632 +      done
167.8633 +      # Substitute the hardcoded libdirs into the rpath.
167.8634 +      if test -n "$hardcode_libdir_separator" &&
167.8635 +	 test -n "$hardcode_libdirs"; then
167.8636 +	libdir="$hardcode_libdirs"
167.8637 +	eval rpath=\" $hardcode_libdir_flag_spec\"
167.8638 +      fi
167.8639 +      compile_rpath="$rpath"
167.8640 +
167.8641 +      rpath=
167.8642 +      hardcode_libdirs=
167.8643 +      for libdir in $finalize_rpath; do
167.8644 +	if test -n "$hardcode_libdir_flag_spec"; then
167.8645 +	  if test -n "$hardcode_libdir_separator"; then
167.8646 +	    if test -z "$hardcode_libdirs"; then
167.8647 +	      hardcode_libdirs="$libdir"
167.8648 +	    else
167.8649 +	      # Just accumulate the unique libdirs.
167.8650 +	      case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in
167.8651 +	      *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*)
167.8652 +		;;
167.8653 +	      *)
167.8654 +		hardcode_libdirs="$hardcode_libdirs$hardcode_libdir_separator$libdir"
167.8655 +		;;
167.8656 +	      esac
167.8657 +	    fi
167.8658 +	  else
167.8659 +	    eval flag=\"$hardcode_libdir_flag_spec\"
167.8660 +	    rpath="$rpath $flag"
167.8661 +	  fi
167.8662 +	elif test -n "$runpath_var"; then
167.8663 +	  case "$finalize_perm_rpath " in
167.8664 +	  *" $libdir "*) ;;
167.8665 +	  *) finalize_perm_rpath="$finalize_perm_rpath $libdir" ;;
167.8666 +	  esac
167.8667 +	fi
167.8668 +      done
167.8669 +      # Substitute the hardcoded libdirs into the rpath.
167.8670 +      if test -n "$hardcode_libdir_separator" &&
167.8671 +	 test -n "$hardcode_libdirs"; then
167.8672 +	libdir="$hardcode_libdirs"
167.8673 +	eval rpath=\" $hardcode_libdir_flag_spec\"
167.8674 +      fi
167.8675 +      finalize_rpath="$rpath"
167.8676 +
167.8677 +      if test -n "$libobjs" && test "$build_old_libs" = yes; then
167.8678 +	# Transform all the library objects into standard objects.
167.8679 +	compile_command=`$ECHO "$compile_command" | $SP2NL | $SED "$lo2o" | $NL2SP`
167.8680 +	finalize_command=`$ECHO "$finalize_command" | $SP2NL | $SED "$lo2o" | $NL2SP`
167.8681 +      fi
167.8682 +
167.8683 +      func_generate_dlsyms "$outputname" "@PROGRAM@" "no"
167.8684 +
167.8685 +      # template prelinking step
167.8686 +      if test -n "$prelink_cmds"; then
167.8687 +	func_execute_cmds "$prelink_cmds" 'exit $?'
167.8688 +      fi
167.8689 +
167.8690 +      wrappers_required=yes
167.8691 +      case $host in
167.8692 +      *cegcc* | *mingw32ce*)
167.8693 +        # Disable wrappers for cegcc and mingw32ce hosts, we are cross compiling anyway.
167.8694 +        wrappers_required=no
167.8695 +        ;;
167.8696 +      *cygwin* | *mingw* )
167.8697 +        if test "$build_libtool_libs" != yes; then
167.8698 +          wrappers_required=no
167.8699 +        fi
167.8700 +        ;;
167.8701 +      *)
167.8702 +        if test "$need_relink" = no || test "$build_libtool_libs" != yes; then
167.8703 +          wrappers_required=no
167.8704 +        fi
167.8705 +        ;;
167.8706 +      esac
167.8707 +      if test "$wrappers_required" = no; then
167.8708 +	# Replace the output file specification.
167.8709 +	compile_command=`$ECHO "$compile_command" | $SED 's%@OUTPUT@%'"$output"'%g'`
167.8710 +	link_command="$compile_command$compile_rpath"
167.8711 +
167.8712 +	# We have no uninstalled library dependencies, so finalize right now.
167.8713 +	exit_status=0
167.8714 +	func_show_eval "$link_command" 'exit_status=$?'
167.8715 +
167.8716 +	# Delete the generated files.
167.8717 +	if test -f "$output_objdir/${outputname}S.${objext}"; then
167.8718 +	  func_show_eval '$RM "$output_objdir/${outputname}S.${objext}"'
167.8719 +	fi
167.8720 +
167.8721 +	exit $exit_status
167.8722 +      fi
167.8723 +
167.8724 +      if test -n "$compile_shlibpath$finalize_shlibpath"; then
167.8725 +	compile_command="$shlibpath_var=\"$compile_shlibpath$finalize_shlibpath\$$shlibpath_var\" $compile_command"
167.8726 +      fi
167.8727 +      if test -n "$finalize_shlibpath"; then
167.8728 +	finalize_command="$shlibpath_var=\"$finalize_shlibpath\$$shlibpath_var\" $finalize_command"
167.8729 +      fi
167.8730 +
167.8731 +      compile_var=
167.8732 +      finalize_var=
167.8733 +      if test -n "$runpath_var"; then
167.8734 +	if test -n "$perm_rpath"; then
167.8735 +	  # We should set the runpath_var.
167.8736 +	  rpath=
167.8737 +	  for dir in $perm_rpath; do
167.8738 +	    rpath="$rpath$dir:"
167.8739 +	  done
167.8740 +	  compile_var="$runpath_var=\"$rpath\$$runpath_var\" "
167.8741 +	fi
167.8742 +	if test -n "$finalize_perm_rpath"; then
167.8743 +	  # We should set the runpath_var.
167.8744 +	  rpath=
167.8745 +	  for dir in $finalize_perm_rpath; do
167.8746 +	    rpath="$rpath$dir:"
167.8747 +	  done
167.8748 +	  finalize_var="$runpath_var=\"$rpath\$$runpath_var\" "
167.8749 +	fi
167.8750 +      fi
167.8751 +
167.8752 +      if test "$no_install" = yes; then
167.8753 +	# We don't need to create a wrapper script.
167.8754 +	link_command="$compile_var$compile_command$compile_rpath"
167.8755 +	# Replace the output file specification.
167.8756 +	link_command=`$ECHO "$link_command" | $SED 's%@OUTPUT@%'"$output"'%g'`
167.8757 +	# Delete the old output file.
167.8758 +	$opt_dry_run || $RM $output
167.8759 +	# Link the executable and exit
167.8760 +	func_show_eval "$link_command" 'exit $?'
167.8761 +	exit $EXIT_SUCCESS
167.8762 +      fi
167.8763 +
167.8764 +      if test "$hardcode_action" = relink; then
167.8765 +	# Fast installation is not supported
167.8766 +	link_command="$compile_var$compile_command$compile_rpath"
167.8767 +	relink_command="$finalize_var$finalize_command$finalize_rpath"
167.8768 +
167.8769 +	func_warning "this platform does not like uninstalled shared libraries"
167.8770 +	func_warning "\`$output' will be relinked during installation"
167.8771 +      else
167.8772 +	if test "$fast_install" != no; then
167.8773 +	  link_command="$finalize_var$compile_command$finalize_rpath"
167.8774 +	  if test "$fast_install" = yes; then
167.8775 +	    relink_command=`$ECHO "$compile_var$compile_command$compile_rpath" | $SED 's%@OUTPUT@%\$progdir/\$file%g'`
167.8776 +	  else
167.8777 +	    # fast_install is set to needless
167.8778 +	    relink_command=
167.8779 +	  fi
167.8780 +	else
167.8781 +	  link_command="$compile_var$compile_command$compile_rpath"
167.8782 +	  relink_command="$finalize_var$finalize_command$finalize_rpath"
167.8783 +	fi
167.8784 +      fi
167.8785 +
167.8786 +      # Replace the output file specification.
167.8787 +      link_command=`$ECHO "$link_command" | $SED 's%@OUTPUT@%'"$output_objdir/$outputname"'%g'`
167.8788 +
167.8789 +      # Delete the old output files.
167.8790 +      $opt_dry_run || $RM $output $output_objdir/$outputname $output_objdir/lt-$outputname
167.8791 +
167.8792 +      func_show_eval "$link_command" 'exit $?'
167.8793 +
167.8794 +      # Now create the wrapper script.
167.8795 +      func_verbose "creating $output"
167.8796 +
167.8797 +      # Quote the relink command for shipping.
167.8798 +      if test -n "$relink_command"; then
167.8799 +	# Preserve any variables that may affect compiler behavior
167.8800 +	for var in $variables_saved_for_relink; do
167.8801 +	  if eval test -z \"\${$var+set}\"; then
167.8802 +	    relink_command="{ test -z \"\${$var+set}\" || $lt_unset $var || { $var=; export $var; }; }; $relink_command"
167.8803 +	  elif eval var_value=\$$var; test -z "$var_value"; then
167.8804 +	    relink_command="$var=; export $var; $relink_command"
167.8805 +	  else
167.8806 +	    func_quote_for_eval "$var_value"
167.8807 +	    relink_command="$var=$func_quote_for_eval_result; export $var; $relink_command"
167.8808 +	  fi
167.8809 +	done
167.8810 +	relink_command="(cd `pwd`; $relink_command)"
167.8811 +	relink_command=`$ECHO "$relink_command" | $SED "$sed_quote_subst"`
167.8812 +      fi
167.8813 +
167.8814 +      # Only actually do things if not in dry run mode.
167.8815 +      $opt_dry_run || {
167.8816 +	# win32 will think the script is a binary if it has
167.8817 +	# a .exe suffix, so we strip it off here.
167.8818 +	case $output in
167.8819 +	  *.exe) func_stripname '' '.exe' "$output"
167.8820 +	         output=$func_stripname_result ;;
167.8821 +	esac
167.8822 +	# test for cygwin because mv fails w/o .exe extensions
167.8823 +	case $host in
167.8824 +	  *cygwin*)
167.8825 +	    exeext=.exe
167.8826 +	    func_stripname '' '.exe' "$outputname"
167.8827 +	    outputname=$func_stripname_result ;;
167.8828 +	  *) exeext= ;;
167.8829 +	esac
167.8830 +	case $host in
167.8831 +	  *cygwin* | *mingw* )
167.8832 +	    func_dirname_and_basename "$output" "" "."
167.8833 +	    output_name=$func_basename_result
167.8834 +	    output_path=$func_dirname_result
167.8835 +	    cwrappersource="$output_path/$objdir/lt-$output_name.c"
167.8836 +	    cwrapper="$output_path/$output_name.exe"
167.8837 +	    $RM $cwrappersource $cwrapper
167.8838 +	    trap "$RM $cwrappersource $cwrapper $cwrapper.manifest; exit $EXIT_FAILURE" 1 2 15
167.8839 +
167.8840 +	    func_emit_cwrapperexe_src > $cwrappersource
167.8841 +
167.8842 +	    # The wrapper executable is built using the $host compiler,
167.8843 +	    # because it contains $host paths and files. If cross-
167.8844 +	    # compiling, it, like the target executable, must be
167.8845 +	    # executed on the $host or under an emulation environment.
167.8846 +	    $opt_dry_run || {
167.8847 +	      $LTCC $LTCFLAGS -o $cwrapper $cwrappersource
167.8848 +	      $STRIP $cwrapper
167.8849 +	    }
167.8850 +
167.8851 +	    # Now, create the wrapper script for func_source use:
167.8852 +	    func_ltwrapper_scriptname $cwrapper
167.8853 +	    $RM $func_ltwrapper_scriptname_result
167.8854 +	    trap "$RM $func_ltwrapper_scriptname_result; exit $EXIT_FAILURE" 1 2 15
167.8855 +	    $opt_dry_run || {
167.8856 +	      # note: this script will not be executed, so do not chmod.
167.8857 +	      if test "x$build" = "x$host" ; then
167.8858 +		# Create the UAC manifests first if necessary (but the
167.8859 +		# manifest files must have executable permission regardless).
167.8860 +		case $output_name in
167.8861 +		  *instal*|*patch*|*setup*|*update*)
167.8862 +		    func_emit_exe_manifest > $cwrapper.manifest
167.8863 +		    func_emit_exe_manifest > $output_path/$objdir/$output_name.exe.manifest
167.8864 +		    chmod +x $cwrapper.manifest
167.8865 +		    chmod +x $output_path/$objdir/$output_name.exe.manifest
167.8866 +		  ;;
167.8867 +		esac
167.8868 +		$cwrapper --lt-dump-script > $func_ltwrapper_scriptname_result
167.8869 +	      else
167.8870 +		func_emit_wrapper no > $func_ltwrapper_scriptname_result
167.8871 +	      fi
167.8872 +	    }
167.8873 +	  ;;
167.8874 +	  * )
167.8875 +	    $RM $output
167.8876 +	    trap "$RM $output; exit $EXIT_FAILURE" 1 2 15
167.8877 +
167.8878 +	    func_emit_wrapper no > $output
167.8879 +	    chmod +x $output
167.8880 +	  ;;
167.8881 +	esac
167.8882 +      }
167.8883 +      exit $EXIT_SUCCESS
167.8884 +      ;;
167.8885 +    esac
167.8886 +
167.8887 +    # See if we need to build an old-fashioned archive.
167.8888 +    for oldlib in $oldlibs; do
167.8889 +
167.8890 +      if test "$build_libtool_libs" = convenience; then
167.8891 +	oldobjs="$libobjs_save $symfileobj"
167.8892 +	addlibs="$convenience"
167.8893 +	build_libtool_libs=no
167.8894 +      else
167.8895 +	if test "$build_libtool_libs" = module; then
167.8896 +	  oldobjs="$libobjs_save"
167.8897 +	  build_libtool_libs=no
167.8898 +	else
167.8899 +	  oldobjs="$old_deplibs $non_pic_objects"
167.8900 +	  if test "$preload" = yes && test -f "$symfileobj"; then
167.8901 +	    oldobjs="$oldobjs $symfileobj"
167.8902 +	  fi
167.8903 +	fi
167.8904 +	addlibs="$old_convenience"
167.8905 +      fi
167.8906 +
167.8907 +      if test -n "$addlibs"; then
167.8908 +	gentop="$output_objdir/${outputname}x"
167.8909 +	generated="$generated $gentop"
167.8910 +
167.8911 +	func_extract_archives $gentop $addlibs
167.8912 +	oldobjs="$oldobjs $func_extract_archives_result"
167.8913 +      fi
167.8914 +
167.8915 +      # Do each command in the archive commands.
167.8916 +      if test -n "$old_archive_from_new_cmds" && test "$build_libtool_libs" = yes; then
167.8917 +	cmds=$old_archive_from_new_cmds
167.8918 +      else
167.8919 +
167.8920 +	# Add any objects from preloaded convenience libraries
167.8921 +	if test -n "$dlprefiles"; then
167.8922 +	  gentop="$output_objdir/${outputname}x"
167.8923 +	  generated="$generated $gentop"
167.8924 +
167.8925 +	  func_extract_archives $gentop $dlprefiles
167.8926 +	  oldobjs="$oldobjs $func_extract_archives_result"
167.8927 +	fi
167.8928 +
167.8929 +	# POSIX demands no paths to be encoded in archives.  We have
167.8930 +	# to avoid creating archives with duplicate basenames if we
167.8931 +	# might have to extract them afterwards, e.g., when creating a
167.8932 +	# static archive out of a convenience library, or when linking
167.8933 +	# the entirety of a libtool archive into another (currently
167.8934 +	# not supported by libtool).
167.8935 +	if (for obj in $oldobjs
167.8936 +	    do
167.8937 +	      func_basename "$obj"
167.8938 +	      $ECHO "$func_basename_result"
167.8939 +	    done | sort | sort -uc >/dev/null 2>&1); then
167.8940 +	  :
167.8941 +	else
167.8942 +	  echo "copying selected object files to avoid basename conflicts..."
167.8943 +	  gentop="$output_objdir/${outputname}x"
167.8944 +	  generated="$generated $gentop"
167.8945 +	  func_mkdir_p "$gentop"
167.8946 +	  save_oldobjs=$oldobjs
167.8947 +	  oldobjs=
167.8948 +	  counter=1
167.8949 +	  for obj in $save_oldobjs
167.8950 +	  do
167.8951 +	    func_basename "$obj"
167.8952 +	    objbase="$func_basename_result"
167.8953 +	    case " $oldobjs " in
167.8954 +	    " ") oldobjs=$obj ;;
167.8955 +	    *[\ /]"$objbase "*)
167.8956 +	      while :; do
167.8957 +		# Make sure we don't pick an alternate name that also
167.8958 +		# overlaps.
167.8959 +		newobj=lt$counter-$objbase
167.8960 +		func_arith $counter + 1
167.8961 +		counter=$func_arith_result
167.8962 +		case " $oldobjs " in
167.8963 +		*[\ /]"$newobj "*) ;;
167.8964 +		*) if test ! -f "$gentop/$newobj"; then break; fi ;;
167.8965 +		esac
167.8966 +	      done
167.8967 +	      func_show_eval "ln $obj $gentop/$newobj || cp $obj $gentop/$newobj"
167.8968 +	      oldobjs="$oldobjs $gentop/$newobj"
167.8969 +	      ;;
167.8970 +	    *) oldobjs="$oldobjs $obj" ;;
167.8971 +	    esac
167.8972 +	  done
167.8973 +	fi
167.8974 +	eval cmds=\"$old_archive_cmds\"
167.8975 +
167.8976 +	func_len " $cmds"
167.8977 +	len=$func_len_result
167.8978 +	if test "$len" -lt "$max_cmd_len" || test "$max_cmd_len" -le -1; then
167.8979 +	  cmds=$old_archive_cmds
167.8980 +	else
167.8981 +	  # the command line is too long to link in one step, link in parts
167.8982 +	  func_verbose "using piecewise archive linking..."
167.8983 +	  save_RANLIB=$RANLIB
167.8984 +	  RANLIB=:
167.8985 +	  objlist=
167.8986 +	  concat_cmds=
167.8987 +	  save_oldobjs=$oldobjs
167.8988 +	  oldobjs=
167.8989 +	  # Is there a better way of finding the last object in the list?
167.8990 +	  for obj in $save_oldobjs
167.8991 +	  do
167.8992 +	    last_oldobj=$obj
167.8993 +	  done
167.8994 +	  eval test_cmds=\"$old_archive_cmds\"
167.8995 +	  func_len " $test_cmds"
167.8996 +	  len0=$func_len_result
167.8997 +	  len=$len0
167.8998 +	  for obj in $save_oldobjs
167.8999 +	  do
167.9000 +	    func_len " $obj"
167.9001 +	    func_arith $len + $func_len_result
167.9002 +	    len=$func_arith_result
167.9003 +	    func_append objlist " $obj"
167.9004 +	    if test "$len" -lt "$max_cmd_len"; then
167.9005 +	      :
167.9006 +	    else
167.9007 +	      # the above command should be used before it gets too long
167.9008 +	      oldobjs=$objlist
167.9009 +	      if test "$obj" = "$last_oldobj" ; then
167.9010 +		RANLIB=$save_RANLIB
167.9011 +	      fi
167.9012 +	      test -z "$concat_cmds" || concat_cmds=$concat_cmds~
167.9013 +	      eval concat_cmds=\"\${concat_cmds}$old_archive_cmds\"
167.9014 +	      objlist=
167.9015 +	      len=$len0
167.9016 +	    fi
167.9017 +	  done
167.9018 +	  RANLIB=$save_RANLIB
167.9019 +	  oldobjs=$objlist
167.9020 +	  if test "X$oldobjs" = "X" ; then
167.9021 +	    eval cmds=\"\$concat_cmds\"
167.9022 +	  else
167.9023 +	    eval cmds=\"\$concat_cmds~\$old_archive_cmds\"
167.9024 +	  fi
167.9025 +	fi
167.9026 +      fi
167.9027 +      func_execute_cmds "$cmds" 'exit $?'
167.9028 +    done
167.9029 +
167.9030 +    test -n "$generated" && \
167.9031 +      func_show_eval "${RM}r$generated"
167.9032 +
167.9033 +    # Now create the libtool archive.
167.9034 +    case $output in
167.9035 +    *.la)
167.9036 +      old_library=
167.9037 +      test "$build_old_libs" = yes && old_library="$libname.$libext"
167.9038 +      func_verbose "creating $output"
167.9039 +
167.9040 +      # Preserve any variables that may affect compiler behavior
167.9041 +      for var in $variables_saved_for_relink; do
167.9042 +	if eval test -z \"\${$var+set}\"; then
167.9043 +	  relink_command="{ test -z \"\${$var+set}\" || $lt_unset $var || { $var=; export $var; }; }; $relink_command"
167.9044 +	elif eval var_value=\$$var; test -z "$var_value"; then
167.9045 +	  relink_command="$var=; export $var; $relink_command"
167.9046 +	else
167.9047 +	  func_quote_for_eval "$var_value"
167.9048 +	  relink_command="$var=$func_quote_for_eval_result; export $var; $relink_command"
167.9049 +	fi
167.9050 +      done
167.9051 +      # Quote the link command for shipping.
167.9052 +      relink_command="(cd `pwd`; $SHELL $progpath $preserve_args --mode=relink $libtool_args @inst_prefix_dir@)"
167.9053 +      relink_command=`$ECHO "$relink_command" | $SED "$sed_quote_subst"`
167.9054 +      if test "$hardcode_automatic" = yes ; then
167.9055 +	relink_command=
167.9056 +      fi
167.9057 +
167.9058 +      # Only create the output if not a dry run.
167.9059 +      $opt_dry_run || {
167.9060 +	for installed in no yes; do
167.9061 +	  if test "$installed" = yes; then
167.9062 +	    if test -z "$install_libdir"; then
167.9063 +	      break
167.9064 +	    fi
167.9065 +	    output="$output_objdir/$outputname"i
167.9066 +	    # Replace all uninstalled libtool libraries with the installed ones
167.9067 +	    newdependency_libs=
167.9068 +	    for deplib in $dependency_libs; do
167.9069 +	      case $deplib in
167.9070 +	      *.la)
167.9071 +		func_basename "$deplib"
167.9072 +		name="$func_basename_result"
167.9073 +		eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $deplib`
167.9074 +		test -z "$libdir" && \
167.9075 +		  func_fatal_error "\`$deplib' is not a valid libtool archive"
167.9076 +		newdependency_libs="$newdependency_libs $libdir/$name"
167.9077 +		;;
167.9078 +	      *) newdependency_libs="$newdependency_libs $deplib" ;;
167.9079 +	      esac
167.9080 +	    done
167.9081 +	    dependency_libs="$newdependency_libs"
167.9082 +	    newdlfiles=
167.9083 +
167.9084 +	    for lib in $dlfiles; do
167.9085 +	      case $lib in
167.9086 +	      *.la)
167.9087 +	        func_basename "$lib"
167.9088 +		name="$func_basename_result"
167.9089 +		eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $lib`
167.9090 +		test -z "$libdir" && \
167.9091 +		  func_fatal_error "\`$lib' is not a valid libtool archive"
167.9092 +		newdlfiles="$newdlfiles $libdir/$name"
167.9093 +		;;
167.9094 +	      *) newdlfiles="$newdlfiles $lib" ;;
167.9095 +	      esac
167.9096 +	    done
167.9097 +	    dlfiles="$newdlfiles"
167.9098 +	    newdlprefiles=
167.9099 +	    for lib in $dlprefiles; do
167.9100 +	      case $lib in
167.9101 +	      *.la)
167.9102 +		# Only pass preopened files to the pseudo-archive (for
167.9103 +		# eventual linking with the app. that links it) if we
167.9104 +		# didn't already link the preopened objects directly into
167.9105 +		# the library:
167.9106 +		func_basename "$lib"
167.9107 +		name="$func_basename_result"
167.9108 +		eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $lib`
167.9109 +		test -z "$libdir" && \
167.9110 +		  func_fatal_error "\`$lib' is not a valid libtool archive"
167.9111 +		newdlprefiles="$newdlprefiles $libdir/$name"
167.9112 +		;;
167.9113 +	      esac
167.9114 +	    done
167.9115 +	    dlprefiles="$newdlprefiles"
167.9116 +	  else
167.9117 +	    newdlfiles=
167.9118 +	    for lib in $dlfiles; do
167.9119 +	      case $lib in
167.9120 +		[\\/]* | [A-Za-z]:[\\/]*) abs="$lib" ;;
167.9121 +		*) abs=`pwd`"/$lib" ;;
167.9122 +	      esac
167.9123 +	      newdlfiles="$newdlfiles $abs"
167.9124 +	    done
167.9125 +	    dlfiles="$newdlfiles"
167.9126 +	    newdlprefiles=
167.9127 +	    for lib in $dlprefiles; do
167.9128 +	      case $lib in
167.9129 +		[\\/]* | [A-Za-z]:[\\/]*) abs="$lib" ;;
167.9130 +		*) abs=`pwd`"/$lib" ;;
167.9131 +	      esac
167.9132 +	      newdlprefiles="$newdlprefiles $abs"
167.9133 +	    done
167.9134 +	    dlprefiles="$newdlprefiles"
167.9135 +	  fi
167.9136 +	  $RM $output
167.9137 +	  # place dlname in correct position for cygwin
167.9138 +	  # In fact, it would be nice if we could use this code for all target
167.9139 +	  # systems that can't hard-code library paths into their executables
167.9140 +	  # and that have no shared library path variable independent of PATH,
167.9141 +	  # but it turns out we can't easily determine that from inspecting
167.9142 +	  # libtool variables, so we have to hard-code the OSs to which it
167.9143 +	  # applies here; at the moment, that means platforms that use the PE
167.9144 +	  # object format with DLL files.  See the long comment at the top of
167.9145 +	  # tests/bindir.at for full details.
167.9146 +	  tdlname=$dlname
167.9147 +	  case $host,$output,$installed,$module,$dlname in
167.9148 +	    *cygwin*,*lai,yes,no,*.dll | *mingw*,*lai,yes,no,*.dll | *cegcc*,*lai,yes,no,*.dll)
167.9149 +	      # If a -bindir argument was supplied, place the dll there.
167.9150 +	      if test "x$bindir" != x ;
167.9151 +	      then
167.9152 +		func_relative_path "$install_libdir" "$bindir"
167.9153 +		tdlname=$func_relative_path_result$dlname
167.9154 +	      else
167.9155 +		# Otherwise fall back on heuristic.
167.9156 +		tdlname=../bin/$dlname
167.9157 +	      fi
167.9158 +	      ;;
167.9159 +	  esac
167.9160 +	  $ECHO > $output "\
167.9161 +# $outputname - a libtool library file
167.9162 +# Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION
167.9163 +#
167.9164 +# Please DO NOT delete this file!
167.9165 +# It is necessary for linking the library.
167.9166 +
167.9167 +# The name that we can dlopen(3).
167.9168 +dlname='$tdlname'
167.9169 +
167.9170 +# Names of this library.
167.9171 +library_names='$library_names'
167.9172 +
167.9173 +# The name of the static archive.
167.9174 +old_library='$old_library'
167.9175 +
167.9176 +# Linker flags that can not go in dependency_libs.
167.9177 +inherited_linker_flags='$new_inherited_linker_flags'
167.9178 +
167.9179 +# Libraries that this one depends upon.
167.9180 +dependency_libs='$dependency_libs'
167.9181 +
167.9182 +# Names of additional weak libraries provided by this library
167.9183 +weak_library_names='$weak_libs'
167.9184 +
167.9185 +# Version information for $libname.
167.9186 +current=$current
167.9187 +age=$age
167.9188 +revision=$revision
167.9189 +
167.9190 +# Is this an already installed library?
167.9191 +installed=$installed
167.9192 +
167.9193 +# Should we warn about portability when linking against -modules?
167.9194 +shouldnotlink=$module
167.9195 +
167.9196 +# Files to dlopen/dlpreopen
167.9197 +dlopen='$dlfiles'
167.9198 +dlpreopen='$dlprefiles'
167.9199 +
167.9200 +# Directory that this library needs to be installed in:
167.9201 +libdir='$install_libdir'"
167.9202 +	  if test "$installed" = no && test "$need_relink" = yes; then
167.9203 +	    $ECHO >> $output "\
167.9204 +relink_command=\"$relink_command\""
167.9205 +	  fi
167.9206 +	done
167.9207 +      }
167.9208 +
167.9209 +      # Do a symbolic link so that the libtool archive can be found in
167.9210 +      # LD_LIBRARY_PATH before the program is installed.
167.9211 +      func_show_eval '( cd "$output_objdir" && $RM "$outputname" && $LN_S "../$outputname" "$outputname" )' 'exit $?'
167.9212 +      ;;
167.9213 +    esac
167.9214 +    exit $EXIT_SUCCESS
167.9215 +}
167.9216 +
167.9217 +{ test "$mode" = link || test "$mode" = relink; } &&
167.9218 +    func_mode_link ${1+"$@"}
167.9219 +
167.9220 +
167.9221 +# func_mode_uninstall arg...
167.9222 +func_mode_uninstall ()
167.9223 +{
167.9224 +    $opt_debug
167.9225 +    RM="$nonopt"
167.9226 +    files=
167.9227 +    rmforce=
167.9228 +    exit_status=0
167.9229 +
167.9230 +    # This variable tells wrapper scripts just to set variables rather
167.9231 +    # than running their programs.
167.9232 +    libtool_install_magic="$magic"
167.9233 +
167.9234 +    for arg
167.9235 +    do
167.9236 +      case $arg in
167.9237 +      -f) RM="$RM $arg"; rmforce=yes ;;
167.9238 +      -*) RM="$RM $arg" ;;
167.9239 +      *) files="$files $arg" ;;
167.9240 +      esac
167.9241 +    done
167.9242 +
167.9243 +    test -z "$RM" && \
167.9244 +      func_fatal_help "you must specify an RM program"
167.9245 +
167.9246 +    rmdirs=
167.9247 +
167.9248 +    origobjdir="$objdir"
167.9249 +    for file in $files; do
167.9250 +      func_dirname "$file" "" "."
167.9251 +      dir="$func_dirname_result"
167.9252 +      if test "X$dir" = X.; then
167.9253 +	objdir="$origobjdir"
167.9254 +      else
167.9255 +	objdir="$dir/$origobjdir"
167.9256 +      fi
167.9257 +      func_basename "$file"
167.9258 +      name="$func_basename_result"
167.9259 +      test "$mode" = uninstall && objdir="$dir"
167.9260 +
167.9261 +      # Remember objdir for removal later, being careful to avoid duplicates
167.9262 +      if test "$mode" = clean; then
167.9263 +	case " $rmdirs " in
167.9264 +	  *" $objdir "*) ;;
167.9265 +	  *) rmdirs="$rmdirs $objdir" ;;
167.9266 +	esac
167.9267 +      fi
167.9268 +
167.9269 +      # Don't error if the file doesn't exist and rm -f was used.
167.9270 +      if { test -L "$file"; } >/dev/null 2>&1 ||
167.9271 +	 { test -h "$file"; } >/dev/null 2>&1 ||
167.9272 +	 test -f "$file"; then
167.9273 +	:
167.9274 +      elif test -d "$file"; then
167.9275 +	exit_status=1
167.9276 +	continue
167.9277 +      elif test "$rmforce" = yes; then
167.9278 +	continue
167.9279 +      fi
167.9280 +
167.9281 +      rmfiles="$file"
167.9282 +
167.9283 +      case $name in
167.9284 +      *.la)
167.9285 +	# Possibly a libtool archive, so verify it.
167.9286 +	if func_lalib_p "$file"; then
167.9287 +	  func_source $dir/$name
167.9288 +
167.9289 +	  # Delete the libtool libraries and symlinks.
167.9290 +	  for n in $library_names; do
167.9291 +	    rmfiles="$rmfiles $objdir/$n"
167.9292 +	  done
167.9293 +	  test -n "$old_library" && rmfiles="$rmfiles $objdir/$old_library"
167.9294 +
167.9295 +	  case "$mode" in
167.9296 +	  clean)
167.9297 +	    case "  $library_names " in
167.9298 +	    # "  " in the beginning catches empty $dlname
167.9299 +	    *" $dlname "*) ;;
167.9300 +	    *) rmfiles="$rmfiles $objdir/$dlname" ;;
167.9301 +	    esac
167.9302 +	    test -n "$libdir" && rmfiles="$rmfiles $objdir/$name $objdir/${name}i"
167.9303 +	    ;;
167.9304 +	  uninstall)
167.9305 +	    if test -n "$library_names"; then
167.9306 +	      # Do each command in the postuninstall commands.
167.9307 +	      func_execute_cmds "$postuninstall_cmds" 'test "$rmforce" = yes || exit_status=1'
167.9308 +	    fi
167.9309 +
167.9310 +	    if test -n "$old_library"; then
167.9311 +	      # Do each command in the old_postuninstall commands.
167.9312 +	      func_execute_cmds "$old_postuninstall_cmds" 'test "$rmforce" = yes || exit_status=1'
167.9313 +	    fi
167.9314 +	    # FIXME: should reinstall the best remaining shared library.
167.9315 +	    ;;
167.9316 +	  esac
167.9317 +	fi
167.9318 +	;;
167.9319 +
167.9320 +      *.lo)
167.9321 +	# Possibly a libtool object, so verify it.
167.9322 +	if func_lalib_p "$file"; then
167.9323 +
167.9324 +	  # Read the .lo file
167.9325 +	  func_source $dir/$name
167.9326 +
167.9327 +	  # Add PIC object to the list of files to remove.
167.9328 +	  if test -n "$pic_object" &&
167.9329 +	     test "$pic_object" != none; then
167.9330 +	    rmfiles="$rmfiles $dir/$pic_object"
167.9331 +	  fi
167.9332 +
167.9333 +	  # Add non-PIC object to the list of files to remove.
167.9334 +	  if test -n "$non_pic_object" &&
167.9335 +	     test "$non_pic_object" != none; then
167.9336 +	    rmfiles="$rmfiles $dir/$non_pic_object"
167.9337 +	  fi
167.9338 +	fi
167.9339 +	;;
167.9340 +
167.9341 +      *)
167.9342 +	if test "$mode" = clean ; then
167.9343 +	  noexename=$name
167.9344 +	  case $file in
167.9345 +	  *.exe)
167.9346 +	    func_stripname '' '.exe' "$file"
167.9347 +	    file=$func_stripname_result
167.9348 +	    func_stripname '' '.exe' "$name"
167.9349 +	    noexename=$func_stripname_result
167.9350 +	    # $file with .exe has already been added to rmfiles,
167.9351 +	    # add $file without .exe
167.9352 +	    rmfiles="$rmfiles $file"
167.9353 +	    ;;
167.9354 +	  esac
167.9355 +	  # Do a test to see if this is a libtool program.
167.9356 +	  if func_ltwrapper_p "$file"; then
167.9357 +	    if func_ltwrapper_executable_p "$file"; then
167.9358 +	      func_ltwrapper_scriptname "$file"
167.9359 +	      relink_command=
167.9360 +	      func_source $func_ltwrapper_scriptname_result
167.9361 +	      rmfiles="$rmfiles $func_ltwrapper_scriptname_result"
167.9362 +	    else
167.9363 +	      relink_command=
167.9364 +	      func_source $dir/$noexename
167.9365 +	    fi
167.9366 +
167.9367 +	    # note $name still contains .exe if it was in $file originally
167.9368 +	    # as does the version of $file that was added into $rmfiles
167.9369 +	    rmfiles="$rmfiles $objdir/$name $objdir/${name}S.${objext}"
167.9370 +	    rmfiles="$rmfiles ${name}.manifest $objdir/${name}.manifest"
167.9371 +	    if test "$fast_install" = yes && test -n "$relink_command"; then
167.9372 +	      rmfiles="$rmfiles $objdir/lt-$name $objdir/lt-${name}.manifest"
167.9373 +	    fi
167.9374 +	    if test "X$noexename" != "X$name" ; then
167.9375 +	      rmfiles="$rmfiles $objdir/lt-${noexename}.c"
167.9376 +	    fi
167.9377 +	  fi
167.9378 +	fi
167.9379 +	;;
167.9380 +      esac
167.9381 +      func_show_eval "$RM $rmfiles" 'exit_status=1'
167.9382 +    done
167.9383 +    objdir="$origobjdir"
167.9384 +
167.9385 +    # Try to remove the ${objdir}s in the directories where we deleted files
167.9386 +    for dir in $rmdirs; do
167.9387 +      if test -d "$dir"; then
167.9388 +	func_show_eval "rmdir $dir >/dev/null 2>&1"
167.9389 +      fi
167.9390 +    done
167.9391 +
167.9392 +    exit $exit_status
167.9393 +}
167.9394 +
167.9395 +{ test "$mode" = uninstall || test "$mode" = clean; } &&
167.9396 +    func_mode_uninstall ${1+"$@"}
167.9397 +
167.9398 +test -z "$mode" && {
167.9399 +  help="$generic_help"
167.9400 +  func_fatal_help "you must specify a MODE"
167.9401 +}
167.9402 +
167.9403 +test -z "$exec_cmd" && \
167.9404 +  func_fatal_help "invalid operation mode \`$mode'"
167.9405 +
167.9406 +if test -n "$exec_cmd"; then
167.9407 +  eval exec "$exec_cmd"
167.9408 +  exit $EXIT_FAILURE
167.9409 +fi
167.9410 +
167.9411 +exit $exit_status
167.9412 +
167.9413 +
167.9414 +# The TAGs below are defined such that we never get into a situation
167.9415 +# in which we disable both kinds of libraries.  Given conflicting
167.9416 +# choices, we go for a static library, that is the most portable,
167.9417 +# since we can't tell whether shared libraries were disabled because
167.9418 +# the user asked for that or because the platform doesn't support
167.9419 +# them.  This is particularly important on AIX, because we don't
167.9420 +# support having both static and shared libraries enabled at the same
167.9421 +# time on that platform, so we default to a shared-only configuration.
167.9422 +# If a disable-shared tag is given, we'll fallback to a static-only
167.9423 +# configuration.  But we'll never go from static-only to shared-only.
167.9424 +
167.9425 +# ### BEGIN LIBTOOL TAG CONFIG: disable-shared
167.9426 +build_libtool_libs=no
167.9427 +build_old_libs=yes
167.9428 +# ### END LIBTOOL TAG CONFIG: disable-shared
167.9429 +
167.9430 +# ### BEGIN LIBTOOL TAG CONFIG: disable-static
167.9431 +build_old_libs=`case $build_libtool_libs in yes) echo no;; *) echo yes;; esac`
167.9432 +# ### END LIBTOOL TAG CONFIG: disable-static
167.9433 +
167.9434 +# Local Variables:
167.9435 +# mode:shell-script
167.9436 +# sh-indentation:2
167.9437 +# End:
167.9438 +# vi:sw=2
167.9439 +
   168.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
   168.2 +++ b/deps/glpk/m4/libtool.m4	Sun Nov 06 20:59:10 2011 +0100
   168.3 @@ -0,0 +1,7537 @@
   168.4 +# libtool.m4 - Configure libtool for the host system. -*-Autoconf-*-
   168.5 +#
   168.6 +#   Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2003, 2004, 2005,
   168.7 +#                 2006, 2007, 2008, 2009 Free Software Foundation, Inc.
   168.8 +#   Written by Gordon Matzigkeit, 1996
   168.9 +#
  168.10 +# This file is free software; the Free Software Foundation gives
  168.11 +# unlimited permission to copy and/or distribute it, with or without
  168.12 +# modifications, as long as this notice is preserved.
  168.13 +
  168.14 +m4_define([_LT_COPYING], [dnl
  168.15 +#   Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2003, 2004, 2005,
  168.16 +#                 2006, 2007, 2008, 2009 Free Software Foundation, Inc.
  168.17 +#   Written by Gordon Matzigkeit, 1996
  168.18 +#
  168.19 +#   This file is part of GNU Libtool.
  168.20 +#
  168.21 +# GNU Libtool is free software; you can redistribute it and/or
  168.22 +# modify it under the terms of the GNU General Public License as
  168.23 +# published by the Free Software Foundation; either version 2 of
  168.24 +# the License, or (at your option) any later version.
  168.25 +#
  168.26 +# As a special exception to the GNU General Public License,
  168.27 +# if you distribute this file as part of a program or library that
  168.28 +# is built using GNU Libtool, you may include this file under the
  168.29 +# same distribution terms that you use for the rest of that program.
  168.30 +#
  168.31 +# GNU Libtool is distributed in the hope that it will be useful,
  168.32 +# but WITHOUT ANY WARRANTY; without even the implied warranty of
  168.33 +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  168.34 +# GNU General Public License for more details.
  168.35 +#
  168.36 +# You should have received a copy of the GNU General Public License
  168.37 +# along with GNU Libtool; see the file COPYING.  If not, a copy
  168.38 +# can be downloaded from http://www.gnu.org/licenses/gpl.html, or
  168.39 +# obtained by writing to the Free Software Foundation, Inc.,
  168.40 +# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
  168.41 +])
  168.42 +
  168.43 +# serial 56 LT_INIT
  168.44 +
  168.45 +
  168.46 +# LT_PREREQ(VERSION)
  168.47 +# ------------------
  168.48 +# Complain and exit if this libtool version is less that VERSION.
  168.49 +m4_defun([LT_PREREQ],
  168.50 +[m4_if(m4_version_compare(m4_defn([LT_PACKAGE_VERSION]), [$1]), -1,
  168.51 +       [m4_default([$3],
  168.52 +		   [m4_fatal([Libtool version $1 or higher is required],
  168.53 +		             63)])],
  168.54 +       [$2])])
  168.55 +
  168.56 +
  168.57 +# _LT_CHECK_BUILDDIR
  168.58 +# ------------------
  168.59 +# Complain if the absolute build directory name contains unusual characters
  168.60 +m4_defun([_LT_CHECK_BUILDDIR],
  168.61 +[case `pwd` in
  168.62 +  *\ * | *\	*)
  168.63 +    AC_MSG_WARN([Libtool does not cope well with whitespace in `pwd`]) ;;
  168.64 +esac
  168.65 +])
  168.66 +
  168.67 +
  168.68 +# LT_INIT([OPTIONS])
  168.69 +# ------------------
  168.70 +AC_DEFUN([LT_INIT],
  168.71 +[AC_PREREQ([2.58])dnl We use AC_INCLUDES_DEFAULT
  168.72 +AC_REQUIRE([AC_CONFIG_AUX_DIR_DEFAULT])dnl
  168.73 +AC_BEFORE([$0], [LT_LANG])dnl
  168.74 +AC_BEFORE([$0], [LT_OUTPUT])dnl
  168.75 +AC_BEFORE([$0], [LTDL_INIT])dnl
  168.76 +m4_require([_LT_CHECK_BUILDDIR])dnl
  168.77 +
  168.78 +dnl Autoconf doesn't catch unexpanded LT_ macros by default:
  168.79 +m4_pattern_forbid([^_?LT_[A-Z_]+$])dnl
  168.80 +m4_pattern_allow([^(_LT_EOF|LT_DLGLOBAL|LT_DLLAZY_OR_NOW|LT_MULTI_MODULE)$])dnl
  168.81 +dnl aclocal doesn't pull ltoptions.m4, ltsugar.m4, or ltversion.m4
  168.82 +dnl unless we require an AC_DEFUNed macro:
  168.83 +AC_REQUIRE([LTOPTIONS_VERSION])dnl
  168.84 +AC_REQUIRE([LTSUGAR_VERSION])dnl
  168.85 +AC_REQUIRE([LTVERSION_VERSION])dnl
  168.86 +AC_REQUIRE([LTOBSOLETE_VERSION])dnl
  168.87 +m4_require([_LT_PROG_LTMAIN])dnl
  168.88 +
  168.89 +_LT_SHELL_INIT([SHELL=${CONFIG_SHELL-/bin/sh}])
  168.90 +
  168.91 +dnl Parse OPTIONS
  168.92 +_LT_SET_OPTIONS([$0], [$1])
  168.93 +
  168.94 +# This can be used to rebuild libtool when needed
  168.95 +LIBTOOL_DEPS="$ltmain"
  168.96 +
  168.97 +# Always use our own libtool.
  168.98 +LIBTOOL='$(SHELL) $(top_builddir)/libtool'
  168.99 +AC_SUBST(LIBTOOL)dnl
 168.100 +
 168.101 +_LT_SETUP
 168.102 +
 168.103 +# Only expand once:
 168.104 +m4_define([LT_INIT])
 168.105 +])# LT_INIT
 168.106 +
 168.107 +# Old names:
 168.108 +AU_ALIAS([AC_PROG_LIBTOOL], [LT_INIT])
 168.109 +AU_ALIAS([AM_PROG_LIBTOOL], [LT_INIT])
 168.110 +dnl aclocal-1.4 backwards compatibility:
 168.111 +dnl AC_DEFUN([AC_PROG_LIBTOOL], [])
 168.112 +dnl AC_DEFUN([AM_PROG_LIBTOOL], [])
 168.113 +
 168.114 +
 168.115 +# _LT_CC_BASENAME(CC)
 168.116 +# -------------------
 168.117 +# Calculate cc_basename.  Skip known compiler wrappers and cross-prefix.
 168.118 +m4_defun([_LT_CC_BASENAME],
 168.119 +[for cc_temp in $1""; do
 168.120 +  case $cc_temp in
 168.121 +    compile | *[[\\/]]compile | ccache | *[[\\/]]ccache ) ;;
 168.122 +    distcc | *[[\\/]]distcc | purify | *[[\\/]]purify ) ;;
 168.123 +    \-*) ;;
 168.124 +    *) break;;
 168.125 +  esac
 168.126 +done
 168.127 +cc_basename=`$ECHO "$cc_temp" | $SED "s%.*/%%; s%^$host_alias-%%"`
 168.128 +])
 168.129 +
 168.130 +
 168.131 +# _LT_FILEUTILS_DEFAULTS
 168.132 +# ----------------------
 168.133 +# It is okay to use these file commands and assume they have been set
 168.134 +# sensibly after `m4_require([_LT_FILEUTILS_DEFAULTS])'.
 168.135 +m4_defun([_LT_FILEUTILS_DEFAULTS],
 168.136 +[: ${CP="cp -f"}
 168.137 +: ${MV="mv -f"}
 168.138 +: ${RM="rm -f"}
 168.139 +])# _LT_FILEUTILS_DEFAULTS
 168.140 +
 168.141 +
 168.142 +# _LT_SETUP
 168.143 +# ---------
 168.144 +m4_defun([_LT_SETUP],
 168.145 +[AC_REQUIRE([AC_CANONICAL_HOST])dnl
 168.146 +AC_REQUIRE([AC_CANONICAL_BUILD])dnl
 168.147 +AC_REQUIRE([_LT_PREPARE_SED_QUOTE_VARS])dnl
 168.148 +AC_REQUIRE([_LT_PROG_ECHO_BACKSLASH])dnl
 168.149 +
 168.150 +_LT_DECL([], [host_alias], [0], [The host system])dnl
 168.151 +_LT_DECL([], [host], [0])dnl
 168.152 +_LT_DECL([], [host_os], [0])dnl
 168.153 +dnl
 168.154 +_LT_DECL([], [build_alias], [0], [The build system])dnl
 168.155 +_LT_DECL([], [build], [0])dnl
 168.156 +_LT_DECL([], [build_os], [0])dnl
 168.157 +dnl
 168.158 +AC_REQUIRE([AC_PROG_CC])dnl
 168.159 +AC_REQUIRE([LT_PATH_LD])dnl
 168.160 +AC_REQUIRE([LT_PATH_NM])dnl
 168.161 +dnl
 168.162 +AC_REQUIRE([AC_PROG_LN_S])dnl
 168.163 +test -z "$LN_S" && LN_S="ln -s"
 168.164 +_LT_DECL([], [LN_S], [1], [Whether we need soft or hard links])dnl
 168.165 +dnl
 168.166 +AC_REQUIRE([LT_CMD_MAX_LEN])dnl
 168.167 +_LT_DECL([objext], [ac_objext], [0], [Object file suffix (normally "o")])dnl
 168.168 +_LT_DECL([], [exeext], [0], [Executable file suffix (normally "")])dnl
 168.169 +dnl
 168.170 +m4_require([_LT_FILEUTILS_DEFAULTS])dnl
 168.171 +m4_require([_LT_CHECK_SHELL_FEATURES])dnl
 168.172 +m4_require([_LT_PATH_CONVERSION_FUNCTIONS])dnl
 168.173 +m4_require([_LT_CMD_RELOAD])dnl
 168.174 +m4_require([_LT_CHECK_MAGIC_METHOD])dnl
 168.175 +m4_require([_LT_CHECK_SHAREDLIB_FROM_LINKLIB])dnl
 168.176 +m4_require([_LT_CMD_OLD_ARCHIVE])dnl
 168.177 +m4_require([_LT_CMD_GLOBAL_SYMBOLS])dnl
 168.178 +
 168.179 +_LT_CONFIG_LIBTOOL_INIT([
 168.180 +# See if we are running on zsh, and set the options which allow our
 168.181 +# commands through without removal of \ escapes INIT.
 168.182 +if test -n "\${ZSH_VERSION+set}" ; then
 168.183 +   setopt NO_GLOB_SUBST
 168.184 +fi
 168.185 +])
 168.186 +if test -n "${ZSH_VERSION+set}" ; then
 168.187 +   setopt NO_GLOB_SUBST
 168.188 +fi
 168.189 +
 168.190 +_LT_CHECK_OBJDIR
 168.191 +
 168.192 +m4_require([_LT_TAG_COMPILER])dnl
 168.193 +
 168.194 +case $host_os in
 168.195 +aix3*)
 168.196 +  # AIX sometimes has problems with the GCC collect2 program.  For some
 168.197 +  # reason, if we set the COLLECT_NAMES environment variable, the problems
 168.198 +  # vanish in a puff of smoke.
 168.199 +  if test "X${COLLECT_NAMES+set}" != Xset; then
 168.200 +    COLLECT_NAMES=
 168.201 +    export COLLECT_NAMES
 168.202 +  fi
 168.203 +  ;;
 168.204 +esac
 168.205 +
 168.206 +# Global variables:
 168.207 +ofile=libtool
 168.208 +can_build_shared=yes
 168.209 +
 168.210 +# All known linkers require a `.a' archive for static linking (except MSVC,
 168.211 +# which needs '.lib').
 168.212 +libext=a
 168.213 +
 168.214 +with_gnu_ld="$lt_cv_prog_gnu_ld"
 168.215 +
 168.216 +old_CC="$CC"
 168.217 +old_CFLAGS="$CFLAGS"
 168.218 +
 168.219 +# Set sane defaults for various variables
 168.220 +test -z "$CC" && CC=cc
 168.221 +test -z "$LTCC" && LTCC=$CC
 168.222 +test -z "$LTCFLAGS" && LTCFLAGS=$CFLAGS
 168.223 +test -z "$LD" && LD=ld
 168.224 +test -z "$ac_objext" && ac_objext=o
 168.225 +
 168.226 +_LT_CC_BASENAME([$compiler])
 168.227 +
 168.228 +# Only perform the check for file, if the check method requires it
 168.229 +test -z "$MAGIC_CMD" && MAGIC_CMD=file
 168.230 +case $deplibs_check_method in
 168.231 +file_magic*)
 168.232 +  if test "$file_magic_cmd" = '$MAGIC_CMD'; then
 168.233 +    _LT_PATH_MAGIC
 168.234 +  fi
 168.235 +  ;;
 168.236 +esac
 168.237 +
 168.238 +# Use C for the default configuration in the libtool script
 168.239 +LT_SUPPORTED_TAG([CC])
 168.240 +_LT_LANG_C_CONFIG
 168.241 +_LT_LANG_DEFAULT_CONFIG
 168.242 +_LT_CONFIG_COMMANDS
 168.243 +])# _LT_SETUP
 168.244 +
 168.245 +
 168.246 +# _LT_PREPARE_SED_QUOTE_VARS
 168.247 +# --------------------------
 168.248 +# Define a few sed substitution that help us do robust quoting.
 168.249 +m4_defun([_LT_PREPARE_SED_QUOTE_VARS],
 168.250 +[# Backslashify metacharacters that are still active within
 168.251 +# double-quoted strings.
 168.252 +sed_quote_subst='s/\([["`$\\]]\)/\\\1/g'
 168.253 +
 168.254 +# Same as above, but do not quote variable references.
 168.255 +double_quote_subst='s/\([["`\\]]\)/\\\1/g'
 168.256 +
 168.257 +# Sed substitution to delay expansion of an escaped shell variable in a
 168.258 +# double_quote_subst'ed string.
 168.259 +delay_variable_subst='s/\\\\\\\\\\\$/\\\\\\$/g'
 168.260 +
 168.261 +# Sed substitution to delay expansion of an escaped single quote.
 168.262 +delay_single_quote_subst='s/'\''/'\'\\\\\\\'\''/g'
 168.263 +
 168.264 +# Sed substitution to avoid accidental globbing in evaled expressions
 168.265 +no_glob_subst='s/\*/\\\*/g'
 168.266 +])
 168.267 +
 168.268 +# _LT_PROG_LTMAIN
 168.269 +# ---------------
 168.270 +# Note that this code is called both from `configure', and `config.status'
 168.271 +# now that we use AC_CONFIG_COMMANDS to generate libtool.  Notably,
 168.272 +# `config.status' has no value for ac_aux_dir unless we are using Automake,
 168.273 +# so we pass a copy along to make sure it has a sensible value anyway.
 168.274 +m4_defun([_LT_PROG_LTMAIN],
 168.275 +[m4_ifdef([AC_REQUIRE_AUX_FILE], [AC_REQUIRE_AUX_FILE([ltmain.sh])])dnl
 168.276 +_LT_CONFIG_LIBTOOL_INIT([ac_aux_dir='$ac_aux_dir'])
 168.277 +ltmain="$ac_aux_dir/ltmain.sh"
 168.278 +])# _LT_PROG_LTMAIN
 168.279 +
 168.280 +
 168.281 +## ------------------------------------- ##
 168.282 +## Accumulate code for creating libtool. ##
 168.283 +## ------------------------------------- ##
 168.284 +
 168.285 +# So that we can recreate a full libtool script including additional
 168.286 +# tags, we accumulate the chunks of code to send to AC_CONFIG_COMMANDS
 168.287 +# in macros and then make a single call at the end using the `libtool'
 168.288 +# label.
 168.289 +
 168.290 +
 168.291 +# _LT_CONFIG_LIBTOOL_INIT([INIT-COMMANDS])
 168.292 +# ----------------------------------------
 168.293 +# Register INIT-COMMANDS to be passed to AC_CONFIG_COMMANDS later.
 168.294 +m4_define([_LT_CONFIG_LIBTOOL_INIT],
 168.295 +[m4_ifval([$1],
 168.296 +          [m4_append([_LT_OUTPUT_LIBTOOL_INIT],
 168.297 +                     [$1
 168.298 +])])])
 168.299 +
 168.300 +# Initialize.
 168.301 +m4_define([_LT_OUTPUT_LIBTOOL_INIT])
 168.302 +
 168.303 +
 168.304 +# _LT_CONFIG_LIBTOOL([COMMANDS])
 168.305 +# ------------------------------
 168.306 +# Register COMMANDS to be passed to AC_CONFIG_COMMANDS later.
 168.307 +m4_define([_LT_CONFIG_LIBTOOL],
 168.308 +[m4_ifval([$1],
 168.309 +          [m4_append([_LT_OUTPUT_LIBTOOL_COMMANDS],
 168.310 +                     [$1
 168.311 +])])])
 168.312 +
 168.313 +# Initialize.
 168.314 +m4_define([_LT_OUTPUT_LIBTOOL_COMMANDS])
 168.315 +
 168.316 +
 168.317 +# _LT_CONFIG_SAVE_COMMANDS([COMMANDS], [INIT_COMMANDS])
 168.318 +# -----------------------------------------------------
 168.319 +m4_defun([_LT_CONFIG_SAVE_COMMANDS],
 168.320 +[_LT_CONFIG_LIBTOOL([$1])
 168.321 +_LT_CONFIG_LIBTOOL_INIT([$2])
 168.322 +])
 168.323 +
 168.324 +
 168.325 +# _LT_FORMAT_COMMENT([COMMENT])
 168.326 +# -----------------------------
 168.327 +# Add leading comment marks to the start of each line, and a trailing
 168.328 +# full-stop to the whole comment if one is not present already.
 168.329 +m4_define([_LT_FORMAT_COMMENT],
 168.330 +[m4_ifval([$1], [
 168.331 +m4_bpatsubst([m4_bpatsubst([$1], [^ *], [# ])],
 168.332 +              [['`$\]], [\\\&])]m4_bmatch([$1], [[!?.]$], [], [.])
 168.333 +)])
 168.334 +
 168.335 +
 168.336 +
 168.337 +## ------------------------ ##
 168.338 +## FIXME: Eliminate VARNAME ##
 168.339 +## ------------------------ ##
 168.340 +
 168.341 +
 168.342 +# _LT_DECL([CONFIGNAME], VARNAME, VALUE, [DESCRIPTION], [IS-TAGGED?])
 168.343 +# -------------------------------------------------------------------
 168.344 +# CONFIGNAME is the name given to the value in the libtool script.
 168.345 +# VARNAME is the (base) name used in the configure script.
 168.346 +# VALUE may be 0, 1 or 2 for a computed quote escaped value based on
 168.347 +# VARNAME.  Any other value will be used directly.
 168.348 +m4_define([_LT_DECL],
 168.349 +[lt_if_append_uniq([lt_decl_varnames], [$2], [, ],
 168.350 +    [lt_dict_add_subkey([lt_decl_dict], [$2], [libtool_name],
 168.351 +	[m4_ifval([$1], [$1], [$2])])
 168.352 +    lt_dict_add_subkey([lt_decl_dict], [$2], [value], [$3])
 168.353 +    m4_ifval([$4],
 168.354 +	[lt_dict_add_subkey([lt_decl_dict], [$2], [description], [$4])])
 168.355 +    lt_dict_add_subkey([lt_decl_dict], [$2],
 168.356 +	[tagged?], [m4_ifval([$5], [yes], [no])])])
 168.357 +])
 168.358 +
 168.359 +
 168.360 +# _LT_TAGDECL([CONFIGNAME], VARNAME, VALUE, [DESCRIPTION])
 168.361 +# --------------------------------------------------------
 168.362 +m4_define([_LT_TAGDECL], [_LT_DECL([$1], [$2], [$3], [$4], [yes])])
 168.363 +
 168.364 +
 168.365 +# lt_decl_tag_varnames([SEPARATOR], [VARNAME1...])
 168.366 +# ------------------------------------------------
 168.367 +m4_define([lt_decl_tag_varnames],
 168.368 +[_lt_decl_filter([tagged?], [yes], $@)])
 168.369 +
 168.370 +
 168.371 +# _lt_decl_filter(SUBKEY, VALUE, [SEPARATOR], [VARNAME1..])
 168.372 +# ---------------------------------------------------------
 168.373 +m4_define([_lt_decl_filter],
 168.374 +[m4_case([$#],
 168.375 +  [0], [m4_fatal([$0: too few arguments: $#])],
 168.376 +  [1], [m4_fatal([$0: too few arguments: $#: $1])],
 168.377 +  [2], [lt_dict_filter([lt_decl_dict], [$1], [$2], [], lt_decl_varnames)],
 168.378 +  [3], [lt_dict_filter([lt_decl_dict], [$1], [$2], [$3], lt_decl_varnames)],
 168.379 +  [lt_dict_filter([lt_decl_dict], $@)])[]dnl
 168.380 +])
 168.381 +
 168.382 +
 168.383 +# lt_decl_quote_varnames([SEPARATOR], [VARNAME1...])
 168.384 +# --------------------------------------------------
 168.385 +m4_define([lt_decl_quote_varnames],
 168.386 +[_lt_decl_filter([value], [1], $@)])
 168.387 +
 168.388 +
 168.389 +# lt_decl_dquote_varnames([SEPARATOR], [VARNAME1...])
 168.390 +# ---------------------------------------------------
 168.391 +m4_define([lt_decl_dquote_varnames],
 168.392 +[_lt_decl_filter([value], [2], $@)])
 168.393 +
 168.394 +
 168.395 +# lt_decl_varnames_tagged([SEPARATOR], [VARNAME1...])
 168.396 +# ---------------------------------------------------
 168.397 +m4_define([lt_decl_varnames_tagged],
 168.398 +[m4_assert([$# <= 2])dnl
 168.399 +_$0(m4_quote(m4_default([$1], [[, ]])),
 168.400 +    m4_ifval([$2], [[$2]], [m4_dquote(lt_decl_tag_varnames)]),
 168.401 +    m4_split(m4_normalize(m4_quote(_LT_TAGS)), [ ]))])
 168.402 +m4_define([_lt_decl_varnames_tagged],
 168.403 +[m4_ifval([$3], [lt_combine([$1], [$2], [_], $3)])])
 168.404 +
 168.405 +
 168.406 +# lt_decl_all_varnames([SEPARATOR], [VARNAME1...])
 168.407 +# ------------------------------------------------
 168.408 +m4_define([lt_decl_all_varnames],
 168.409 +[_$0(m4_quote(m4_default([$1], [[, ]])),
 168.410 +     m4_if([$2], [],
 168.411 +	   m4_quote(lt_decl_varnames),
 168.412 +	m4_quote(m4_shift($@))))[]dnl
 168.413 +])
 168.414 +m4_define([_lt_decl_all_varnames],
 168.415 +[lt_join($@, lt_decl_varnames_tagged([$1],
 168.416 +			lt_decl_tag_varnames([[, ]], m4_shift($@))))dnl
 168.417 +])
 168.418 +
 168.419 +
 168.420 +# _LT_CONFIG_STATUS_DECLARE([VARNAME])
 168.421 +# ------------------------------------
 168.422 +# Quote a variable value, and forward it to `config.status' so that its
 168.423 +# declaration there will have the same value as in `configure'.  VARNAME
 168.424 +# must have a single quote delimited value for this to work.
 168.425 +m4_define([_LT_CONFIG_STATUS_DECLARE],
 168.426 +[$1='`$ECHO "$][$1" | $SED "$delay_single_quote_subst"`'])
 168.427 +
 168.428 +
 168.429 +# _LT_CONFIG_STATUS_DECLARATIONS
 168.430 +# ------------------------------
 168.431 +# We delimit libtool config variables with single quotes, so when
 168.432 +# we write them to config.status, we have to be sure to quote all
 168.433 +# embedded single quotes properly.  In configure, this macro expands
 168.434 +# each variable declared with _LT_DECL (and _LT_TAGDECL) into:
 168.435 +#
 168.436 +#    <var>='`$ECHO "$<var>" | $SED "$delay_single_quote_subst"`'
 168.437 +m4_defun([_LT_CONFIG_STATUS_DECLARATIONS],
 168.438 +[m4_foreach([_lt_var], m4_quote(lt_decl_all_varnames),
 168.439 +    [m4_n([_LT_CONFIG_STATUS_DECLARE(_lt_var)])])])
 168.440 +
 168.441 +
 168.442 +# _LT_LIBTOOL_TAGS
 168.443 +# ----------------
 168.444 +# Output comment and list of tags supported by the script
 168.445 +m4_defun([_LT_LIBTOOL_TAGS],
 168.446 +[_LT_FORMAT_COMMENT([The names of the tagged configurations supported by this script])dnl
 168.447 +available_tags="_LT_TAGS"dnl
 168.448 +])
 168.449 +
 168.450 +
 168.451 +# _LT_LIBTOOL_DECLARE(VARNAME, [TAG])
 168.452 +# -----------------------------------
 168.453 +# Extract the dictionary values for VARNAME (optionally with TAG) and
 168.454 +# expand to a commented shell variable setting:
 168.455 +#
 168.456 +#    # Some comment about what VAR is for.
 168.457 +#    visible_name=$lt_internal_name
 168.458 +m4_define([_LT_LIBTOOL_DECLARE],
 168.459 +[_LT_FORMAT_COMMENT(m4_quote(lt_dict_fetch([lt_decl_dict], [$1],
 168.460 +					   [description])))[]dnl
 168.461 +m4_pushdef([_libtool_name],
 168.462 +    m4_quote(lt_dict_fetch([lt_decl_dict], [$1], [libtool_name])))[]dnl
 168.463 +m4_case(m4_quote(lt_dict_fetch([lt_decl_dict], [$1], [value])),
 168.464 +    [0], [_libtool_name=[$]$1],
 168.465 +    [1], [_libtool_name=$lt_[]$1],
 168.466 +    [2], [_libtool_name=$lt_[]$1],
 168.467 +    [_libtool_name=lt_dict_fetch([lt_decl_dict], [$1], [value])])[]dnl
 168.468 +m4_ifval([$2], [_$2])[]m4_popdef([_libtool_name])[]dnl
 168.469 +])
 168.470 +
 168.471 +
 168.472 +# _LT_LIBTOOL_CONFIG_VARS
 168.473 +# -----------------------
 168.474 +# Produce commented declarations of non-tagged libtool config variables
 168.475 +# suitable for insertion in the LIBTOOL CONFIG section of the `libtool'
 168.476 +# script.  Tagged libtool config variables (even for the LIBTOOL CONFIG
 168.477 +# section) are produced by _LT_LIBTOOL_TAG_VARS.
 168.478 +m4_defun([_LT_LIBTOOL_CONFIG_VARS],
 168.479 +[m4_foreach([_lt_var],
 168.480 +    m4_quote(_lt_decl_filter([tagged?], [no], [], lt_decl_varnames)),
 168.481 +    [m4_n([_LT_LIBTOOL_DECLARE(_lt_var)])])])
 168.482 +
 168.483 +
 168.484 +# _LT_LIBTOOL_TAG_VARS(TAG)
 168.485 +# -------------------------
 168.486 +m4_define([_LT_LIBTOOL_TAG_VARS],
 168.487 +[m4_foreach([_lt_var], m4_quote(lt_decl_tag_varnames),
 168.488 +    [m4_n([_LT_LIBTOOL_DECLARE(_lt_var, [$1])])])])
 168.489 +
 168.490 +
 168.491 +# _LT_TAGVAR(VARNAME, [TAGNAME])
 168.492 +# ------------------------------
 168.493 +m4_define([_LT_TAGVAR], [m4_ifval([$2], [$1_$2], [$1])])
 168.494 +
 168.495 +
 168.496 +# _LT_CONFIG_COMMANDS
 168.497 +# -------------------
 168.498 +# Send accumulated output to $CONFIG_STATUS.  Thanks to the lists of
 168.499 +# variables for single and double quote escaping we saved from calls
 168.500 +# to _LT_DECL, we can put quote escaped variables declarations
 168.501 +# into `config.status', and then the shell code to quote escape them in
 168.502 +# for loops in `config.status'.  Finally, any additional code accumulated
 168.503 +# from calls to _LT_CONFIG_LIBTOOL_INIT is expanded.
 168.504 +m4_defun([_LT_CONFIG_COMMANDS],
 168.505 +[AC_PROVIDE_IFELSE([LT_OUTPUT],
 168.506 +	dnl If the libtool generation code has been placed in $CONFIG_LT,
 168.507 +	dnl instead of duplicating it all over again into config.status,
 168.508 +	dnl then we will have config.status run $CONFIG_LT later, so it
 168.509 +	dnl needs to know what name is stored there:
 168.510 +        [AC_CONFIG_COMMANDS([libtool],
 168.511 +            [$SHELL $CONFIG_LT || AS_EXIT(1)], [CONFIG_LT='$CONFIG_LT'])],
 168.512 +    dnl If the libtool generation code is destined for config.status,
 168.513 +    dnl expand the accumulated commands and init code now:
 168.514 +    [AC_CONFIG_COMMANDS([libtool],
 168.515 +        [_LT_OUTPUT_LIBTOOL_COMMANDS], [_LT_OUTPUT_LIBTOOL_COMMANDS_INIT])])
 168.516 +])#_LT_CONFIG_COMMANDS
 168.517 +
 168.518 +
 168.519 +# Initialize.
 168.520 +m4_define([_LT_OUTPUT_LIBTOOL_COMMANDS_INIT],
 168.521 +[
 168.522 +
 168.523 +# The HP-UX ksh and POSIX shell print the target directory to stdout
 168.524 +# if CDPATH is set.
 168.525 +(unset CDPATH) >/dev/null 2>&1 && unset CDPATH
 168.526 +
 168.527 +sed_quote_subst='$sed_quote_subst'
 168.528 +double_quote_subst='$double_quote_subst'
 168.529 +delay_variable_subst='$delay_variable_subst'
 168.530 +_LT_CONFIG_STATUS_DECLARATIONS
 168.531 +LTCC='$LTCC'
 168.532 +LTCFLAGS='$LTCFLAGS'
 168.533 +compiler='$compiler_DEFAULT'
 168.534 +
 168.535 +# A function that is used when there is no print builtin or printf.
 168.536 +func_fallback_echo ()
 168.537 +{
 168.538 +  eval 'cat <<_LTECHO_EOF
 168.539 +\$[]1
 168.540 +_LTECHO_EOF'
 168.541 +}
 168.542 +
 168.543 +# Quote evaled strings.
 168.544 +for var in lt_decl_all_varnames([[ \
 168.545 +]], lt_decl_quote_varnames); do
 168.546 +    case \`eval \\\\\$ECHO \\\\""\\\\\$\$var"\\\\"\` in
 168.547 +    *[[\\\\\\\`\\"\\\$]]*)
 168.548 +      eval "lt_\$var=\\\\\\"\\\`\\\$ECHO \\"\\\$\$var\\" | \\\$SED \\"\\\$sed_quote_subst\\"\\\`\\\\\\""
 168.549 +      ;;
 168.550 +    *)
 168.551 +      eval "lt_\$var=\\\\\\"\\\$\$var\\\\\\""
 168.552 +      ;;
 168.553 +    esac
 168.554 +done
 168.555 +
 168.556 +# Double-quote double-evaled strings.
 168.557 +for var in lt_decl_all_varnames([[ \
 168.558 +]], lt_decl_dquote_varnames); do
 168.559 +    case \`eval \\\\\$ECHO \\\\""\\\\\$\$var"\\\\"\` in
 168.560 +    *[[\\\\\\\`\\"\\\$]]*)
 168.561 +      eval "lt_\$var=\\\\\\"\\\`\\\$ECHO \\"\\\$\$var\\" | \\\$SED -e \\"\\\$double_quote_subst\\" -e \\"\\\$sed_quote_subst\\" -e \\"\\\$delay_variable_subst\\"\\\`\\\\\\""
 168.562 +      ;;
 168.563 +    *)
 168.564 +      eval "lt_\$var=\\\\\\"\\\$\$var\\\\\\""
 168.565 +      ;;
 168.566 +    esac
 168.567 +done
 168.568 +
 168.569 +_LT_OUTPUT_LIBTOOL_INIT
 168.570 +])
 168.571 +
 168.572 +# _LT_GENERATED_FILE_INIT(FILE, [COMMENT])
 168.573 +# ------------------------------------
 168.574 +# Generate a child script FILE with all initialization necessary to
 168.575 +# reuse the environment learned by the parent script, and make the
 168.576 +# file executable.  If COMMENT is supplied, it is inserted after the
 168.577 +# `#!' sequence but before initialization text begins.  After this
 168.578 +# macro, additional text can be appended to FILE to form the body of
 168.579 +# the child script.  The macro ends with non-zero status if the
 168.580 +# file could not be fully written (such as if the disk is full).
 168.581 +m4_ifdef([AS_INIT_GENERATED],
 168.582 +[m4_defun([_LT_GENERATED_FILE_INIT],[AS_INIT_GENERATED($@)])],
 168.583 +[m4_defun([_LT_GENERATED_FILE_INIT],
 168.584 +[m4_require([AS_PREPARE])]dnl
 168.585 +[m4_pushdef([AS_MESSAGE_LOG_FD])]dnl
 168.586 +[lt_write_fail=0
 168.587 +cat >$1 <<_ASEOF || lt_write_fail=1
 168.588 +#! $SHELL
 168.589 +# Generated by $as_me.
 168.590 +$2
 168.591 +SHELL=\${CONFIG_SHELL-$SHELL}
 168.592 +export SHELL
 168.593 +_ASEOF
 168.594 +cat >>$1 <<\_ASEOF || lt_write_fail=1
 168.595 +AS_SHELL_SANITIZE
 168.596 +_AS_PREPARE
 168.597 +exec AS_MESSAGE_FD>&1
 168.598 +_ASEOF
 168.599 +test $lt_write_fail = 0 && chmod +x $1[]dnl
 168.600 +m4_popdef([AS_MESSAGE_LOG_FD])])])# _LT_GENERATED_FILE_INIT
 168.601 +
 168.602 +# LT_OUTPUT
 168.603 +# ---------
 168.604 +# This macro allows early generation of the libtool script (before
 168.605 +# AC_OUTPUT is called), incase it is used in configure for compilation
 168.606 +# tests.
 168.607 +AC_DEFUN([LT_OUTPUT],
 168.608 +[: ${CONFIG_LT=./config.lt}
 168.609 +AC_MSG_NOTICE([creating $CONFIG_LT])
 168.610 +_LT_GENERATED_FILE_INIT(["$CONFIG_LT"],
 168.611 +[# Run this file to recreate a libtool stub with the current configuration.])
 168.612 +
 168.613 +cat >>"$CONFIG_LT" <<\_LTEOF
 168.614 +lt_cl_silent=false
 168.615 +exec AS_MESSAGE_LOG_FD>>config.log
 168.616 +{
 168.617 +  echo
 168.618 +  AS_BOX([Running $as_me.])
 168.619 +} >&AS_MESSAGE_LOG_FD
 168.620 +
 168.621 +lt_cl_help="\
 168.622 +\`$as_me' creates a local libtool stub from the current configuration,
 168.623 +for use in further configure time tests before the real libtool is
 168.624 +generated.
 168.625 +
 168.626 +Usage: $[0] [[OPTIONS]]
 168.627 +
 168.628 +  -h, --help      print this help, then exit
 168.629 +  -V, --version   print version number, then exit
 168.630 +  -q, --quiet     do not print progress messages
 168.631 +  -d, --debug     don't remove temporary files
 168.632 +
 168.633 +Report bugs to <bug-libtool@gnu.org>."
 168.634 +
 168.635 +lt_cl_version="\
 168.636 +m4_ifset([AC_PACKAGE_NAME], [AC_PACKAGE_NAME ])config.lt[]dnl
 168.637 +m4_ifset([AC_PACKAGE_VERSION], [ AC_PACKAGE_VERSION])
 168.638 +configured by $[0], generated by m4_PACKAGE_STRING.
 168.639 +
 168.640 +Copyright (C) 2009 Free Software Foundation, Inc.
 168.641 +This config.lt script is free software; the Free Software Foundation
 168.642 +gives unlimited permision to copy, distribute and modify it."
 168.643 +
 168.644 +while test $[#] != 0
 168.645 +do
 168.646 +  case $[1] in
 168.647 +    --version | --v* | -V )
 168.648 +      echo "$lt_cl_version"; exit 0 ;;
 168.649 +    --help | --h* | -h )
 168.650 +      echo "$lt_cl_help"; exit 0 ;;
 168.651 +    --debug | --d* | -d )
 168.652 +      debug=: ;;
 168.653 +    --quiet | --q* | --silent | --s* | -q )
 168.654 +      lt_cl_silent=: ;;
 168.655 +
 168.656 +    -*) AC_MSG_ERROR([unrecognized option: $[1]
 168.657 +Try \`$[0] --help' for more information.]) ;;
 168.658 +
 168.659 +    *) AC_MSG_ERROR([unrecognized argument: $[1]
 168.660 +Try \`$[0] --help' for more information.]) ;;
 168.661 +  esac
 168.662 +  shift
 168.663 +done
 168.664 +
 168.665 +if $lt_cl_silent; then
 168.666 +  exec AS_MESSAGE_FD>/dev/null
 168.667 +fi
 168.668 +_LTEOF
 168.669 +
 168.670 +cat >>"$CONFIG_LT" <<_LTEOF
 168.671 +_LT_OUTPUT_LIBTOOL_COMMANDS_INIT
 168.672 +_LTEOF
 168.673 +
 168.674 +cat >>"$CONFIG_LT" <<\_LTEOF
 168.675 +AC_MSG_NOTICE([creating $ofile])
 168.676 +_LT_OUTPUT_LIBTOOL_COMMANDS
 168.677 +AS_EXIT(0)
 168.678 +_LTEOF
 168.679 +chmod +x "$CONFIG_LT"
 168.680 +
 168.681 +# configure is writing to config.log, but config.lt does its own redirection,
 168.682 +# appending to config.log, which fails on DOS, as config.log is still kept
 168.683 +# open by configure.  Here we exec the FD to /dev/null, effectively closing
 168.684 +# config.log, so it can be properly (re)opened and appended to by config.lt.
 168.685 +lt_cl_success=:
 168.686 +test "$silent" = yes &&
 168.687 +  lt_config_lt_args="$lt_config_lt_args --quiet"
 168.688 +exec AS_MESSAGE_LOG_FD>/dev/null
 168.689 +$SHELL "$CONFIG_LT" $lt_config_lt_args || lt_cl_success=false
 168.690 +exec AS_MESSAGE_LOG_FD>>config.log
 168.691 +$lt_cl_success || AS_EXIT(1)
 168.692 +])# LT_OUTPUT
 168.693 +
 168.694 +
 168.695 +# _LT_CONFIG(TAG)
 168.696 +# ---------------
 168.697 +# If TAG is the built-in tag, create an initial libtool script with a
 168.698 +# default configuration from the untagged config vars.  Otherwise add code
 168.699 +# to config.status for appending the configuration named by TAG from the
 168.700 +# matching tagged config vars.
 168.701 +m4_defun([_LT_CONFIG],
 168.702 +[m4_require([_LT_FILEUTILS_DEFAULTS])dnl
 168.703 +_LT_CONFIG_SAVE_COMMANDS([
 168.704 +  m4_define([_LT_TAG], m4_if([$1], [], [C], [$1]))dnl
 168.705 +  m4_if(_LT_TAG, [C], [
 168.706 +    # See if we are running on zsh, and set the options which allow our
 168.707 +    # commands through without removal of \ escapes.
 168.708 +    if test -n "${ZSH_VERSION+set}" ; then
 168.709 +      setopt NO_GLOB_SUBST
 168.710 +    fi
 168.711 +
 168.712 +    cfgfile="${ofile}T"
 168.713 +    trap "$RM \"$cfgfile\"; exit 1" 1 2 15
 168.714 +    $RM "$cfgfile"
 168.715 +
 168.716 +    cat <<_LT_EOF >> "$cfgfile"
 168.717 +#! $SHELL
 168.718 +
 168.719 +# `$ECHO "$ofile" | sed 's%^.*/%%'` - Provide generalized library-building support services.
 168.720 +# Generated automatically by $as_me ($PACKAGE$TIMESTAMP) $VERSION
 168.721 +# Libtool was configured on host `(hostname || uname -n) 2>/dev/null | sed 1q`:
 168.722 +# NOTE: Changes made to this file will be lost: look at ltmain.sh.
 168.723 +#
 168.724 +_LT_COPYING
 168.725 +_LT_LIBTOOL_TAGS
 168.726 +
 168.727 +# ### BEGIN LIBTOOL CONFIG
 168.728 +_LT_LIBTOOL_CONFIG_VARS
 168.729 +_LT_LIBTOOL_TAG_VARS
 168.730 +# ### END LIBTOOL CONFIG
 168.731 +
 168.732 +_LT_EOF
 168.733 +
 168.734 +  case $host_os in
 168.735 +  aix3*)
 168.736 +    cat <<\_LT_EOF >> "$cfgfile"
 168.737 +# AIX sometimes has problems with the GCC collect2 program.  For some
 168.738 +# reason, if we set the COLLECT_NAMES environment variable, the problems
 168.739 +# vanish in a puff of smoke.
 168.740 +if test "X${COLLECT_NAMES+set}" != Xset; then
 168.741 +  COLLECT_NAMES=
 168.742 +  export COLLECT_NAMES
 168.743 +fi
 168.744 +_LT_EOF
 168.745 +    ;;
 168.746 +  esac
 168.747 +
 168.748 +  _LT_PROG_LTMAIN
 168.749 +
 168.750 +  # We use sed instead of cat because bash on DJGPP gets confused if
 168.751 +  # if finds mixed CR/LF and LF-only lines.  Since sed operates in
 168.752 +  # text mode, it properly converts lines to CR/LF.  This bash problem
 168.753 +  # is reportedly fixed, but why not run on old versions too?
 168.754 +  sed '/^# Generated shell functions inserted here/q' "$ltmain" >> "$cfgfile" \
 168.755 +    || (rm -f "$cfgfile"; exit 1)
 168.756 +
 168.757 +  _LT_PROG_XSI_SHELLFNS
 168.758 +
 168.759 +  sed -n '/^# Generated shell functions inserted here/,$p' "$ltmain" >> "$cfgfile" \
 168.760 +    || (rm -f "$cfgfile"; exit 1)
 168.761 +
 168.762 +  mv -f "$cfgfile" "$ofile" ||
 168.763 +    (rm -f "$ofile" && cp "$cfgfile" "$ofile" && rm -f "$cfgfile")
 168.764 +  chmod +x "$ofile"
 168.765 +],
 168.766 +[cat <<_LT_EOF >> "$ofile"
 168.767 +
 168.768 +dnl Unfortunately we have to use $1 here, since _LT_TAG is not expanded
 168.769 +dnl in a comment (ie after a #).
 168.770 +# ### BEGIN LIBTOOL TAG CONFIG: $1
 168.771 +_LT_LIBTOOL_TAG_VARS(_LT_TAG)
 168.772 +# ### END LIBTOOL TAG CONFIG: $1
 168.773 +_LT_EOF
 168.774 +])dnl /m4_if
 168.775 +],
 168.776 +[m4_if([$1], [], [
 168.777 +    PACKAGE='$PACKAGE'
 168.778 +    VERSION='$VERSION'
 168.779 +    TIMESTAMP='$TIMESTAMP'
 168.780 +    RM='$RM'
 168.781 +    ofile='$ofile'], [])
 168.782 +])dnl /_LT_CONFIG_SAVE_COMMANDS
 168.783 +])# _LT_CONFIG
 168.784 +
 168.785 +
 168.786 +# LT_SUPPORTED_TAG(TAG)
 168.787 +# ---------------------
 168.788 +# Trace this macro to discover what tags are supported by the libtool
 168.789 +# --tag option, using:
 168.790 +#    autoconf --trace 'LT_SUPPORTED_TAG:$1'
 168.791 +AC_DEFUN([LT_SUPPORTED_TAG], [])
 168.792 +
 168.793 +
 168.794 +# C support is built-in for now
 168.795 +m4_define([_LT_LANG_C_enabled], [])
 168.796 +m4_define([_LT_TAGS], [])
 168.797 +
 168.798 +
 168.799 +# LT_LANG(LANG)
 168.800 +# -------------
 168.801 +# Enable libtool support for the given language if not already enabled.
 168.802 +AC_DEFUN([LT_LANG],
 168.803 +[AC_BEFORE([$0], [LT_OUTPUT])dnl
 168.804 +m4_case([$1],
 168.805 +  [C],			[_LT_LANG(C)],
 168.806 +  [C++],		[_LT_LANG(CXX)],
 168.807 +  [Java],		[_LT_LANG(GCJ)],
 168.808 +  [Fortran 77],		[_LT_LANG(F77)],
 168.809 +  [Fortran],		[_LT_LANG(FC)],
 168.810 +  [Windows Resource],	[_LT_LANG(RC)],
 168.811 +  [m4_ifdef([_LT_LANG_]$1[_CONFIG],
 168.812 +    [_LT_LANG($1)],
 168.813 +    [m4_fatal([$0: unsupported language: "$1"])])])dnl
 168.814 +])# LT_LANG
 168.815 +
 168.816 +
 168.817 +# _LT_LANG(LANGNAME)
 168.818 +# ------------------
 168.819 +m4_defun([_LT_LANG],
 168.820 +[m4_ifdef([_LT_LANG_]$1[_enabled], [],
 168.821 +  [LT_SUPPORTED_TAG([$1])dnl
 168.822 +  m4_append([_LT_TAGS], [$1 ])dnl
 168.823 +  m4_define([_LT_LANG_]$1[_enabled], [])dnl
 168.824 +  _LT_LANG_$1_CONFIG($1)])dnl
 168.825 +])# _LT_LANG
 168.826 +
 168.827 +
 168.828 +# _LT_LANG_DEFAULT_CONFIG
 168.829 +# -----------------------
 168.830 +m4_defun([_LT_LANG_DEFAULT_CONFIG],
 168.831 +[AC_PROVIDE_IFELSE([AC_PROG_CXX],
 168.832 +  [LT_LANG(CXX)],
 168.833 +  [m4_define([AC_PROG_CXX], defn([AC_PROG_CXX])[LT_LANG(CXX)])])
 168.834 +
 168.835 +AC_PROVIDE_IFELSE([AC_PROG_F77],
 168.836 +  [LT_LANG(F77)],
 168.837 +  [m4_define([AC_PROG_F77], defn([AC_PROG_F77])[LT_LANG(F77)])])
 168.838 +
 168.839 +AC_PROVIDE_IFELSE([AC_PROG_FC],
 168.840 +  [LT_LANG(FC)],
 168.841 +  [m4_define([AC_PROG_FC], defn([AC_PROG_FC])[LT_LANG(FC)])])
 168.842 +
 168.843 +dnl The call to [A][M_PROG_GCJ] is quoted like that to stop aclocal
 168.844 +dnl pulling things in needlessly.
 168.845 +AC_PROVIDE_IFELSE([AC_PROG_GCJ],
 168.846 +  [LT_LANG(GCJ)],
 168.847 +  [AC_PROVIDE_IFELSE([A][M_PROG_GCJ],
 168.848 +    [LT_LANG(GCJ)],
 168.849 +    [AC_PROVIDE_IFELSE([LT_PROG_GCJ],
 168.850 +      [LT_LANG(GCJ)],
 168.851 +      [m4_ifdef([AC_PROG_GCJ],
 168.852 +	[m4_define([AC_PROG_GCJ], defn([AC_PROG_GCJ])[LT_LANG(GCJ)])])
 168.853 +       m4_ifdef([A][M_PROG_GCJ],
 168.854 +	[m4_define([A][M_PROG_GCJ], defn([A][M_PROG_GCJ])[LT_LANG(GCJ)])])
 168.855 +       m4_ifdef([LT_PROG_GCJ],
 168.856 +	[m4_define([LT_PROG_GCJ], defn([LT_PROG_GCJ])[LT_LANG(GCJ)])])])])])
 168.857 +
 168.858 +AC_PROVIDE_IFELSE([LT_PROG_RC],
 168.859 +  [LT_LANG(RC)],
 168.860 +  [m4_define([LT_PROG_RC], defn([LT_PROG_RC])[LT_LANG(RC)])])
 168.861 +])# _LT_LANG_DEFAULT_CONFIG
 168.862 +
 168.863 +# Obsolete macros:
 168.864 +AU_DEFUN([AC_LIBTOOL_CXX], [LT_LANG(C++)])
 168.865 +AU_DEFUN([AC_LIBTOOL_F77], [LT_LANG(Fortran 77)])
 168.866 +AU_DEFUN([AC_LIBTOOL_FC], [LT_LANG(Fortran)])
 168.867 +AU_DEFUN([AC_LIBTOOL_GCJ], [LT_LANG(Java)])
 168.868 +AU_DEFUN([AC_LIBTOOL_RC], [LT_LANG(Windows Resource)])
 168.869 +dnl aclocal-1.4 backwards compatibility:
 168.870 +dnl AC_DEFUN([AC_LIBTOOL_CXX], [])
 168.871 +dnl AC_DEFUN([AC_LIBTOOL_F77], [])
 168.872 +dnl AC_DEFUN([AC_LIBTOOL_FC], [])
 168.873 +dnl AC_DEFUN([AC_LIBTOOL_GCJ], [])
 168.874 +dnl AC_DEFUN([AC_LIBTOOL_RC], [])
 168.875 +
 168.876 +
 168.877 +# _LT_TAG_COMPILER
 168.878 +# ----------------
 168.879 +m4_defun([_LT_TAG_COMPILER],
 168.880 +[AC_REQUIRE([AC_PROG_CC])dnl
 168.881 +
 168.882 +_LT_DECL([LTCC], [CC], [1], [A C compiler])dnl
 168.883 +_LT_DECL([LTCFLAGS], [CFLAGS], [1], [LTCC compiler flags])dnl
 168.884 +_LT_TAGDECL([CC], [compiler], [1], [A language specific compiler])dnl
 168.885 +_LT_TAGDECL([with_gcc], [GCC], [0], [Is the compiler the GNU compiler?])dnl
 168.886 +
 168.887 +# If no C compiler was specified, use CC.
 168.888 +LTCC=${LTCC-"$CC"}
 168.889 +
 168.890 +# If no C compiler flags were specified, use CFLAGS.
 168.891 +LTCFLAGS=${LTCFLAGS-"$CFLAGS"}
 168.892 +
 168.893 +# Allow CC to be a program name with arguments.
 168.894 +compiler=$CC
 168.895 +])# _LT_TAG_COMPILER
 168.896 +
 168.897 +
 168.898 +# _LT_COMPILER_BOILERPLATE
 168.899 +# ------------------------
 168.900 +# Check for compiler boilerplate output or warnings with
 168.901 +# the simple compiler test code.
 168.902 +m4_defun([_LT_COMPILER_BOILERPLATE],
 168.903 +[m4_require([_LT_DECL_SED])dnl
 168.904 +ac_outfile=conftest.$ac_objext
 168.905 +echo "$lt_simple_compile_test_code" >conftest.$ac_ext
 168.906 +eval "$ac_compile" 2>&1 >/dev/null | $SED '/^$/d; /^ *+/d' >conftest.err
 168.907 +_lt_compiler_boilerplate=`cat conftest.err`
 168.908 +$RM conftest*
 168.909 +])# _LT_COMPILER_BOILERPLATE
 168.910 +
 168.911 +
 168.912 +# _LT_LINKER_BOILERPLATE
 168.913 +# ----------------------
 168.914 +# Check for linker boilerplate output or warnings with
 168.915 +# the simple link test code.
 168.916 +m4_defun([_LT_LINKER_BOILERPLATE],
 168.917 +[m4_require([_LT_DECL_SED])dnl
 168.918 +ac_outfile=conftest.$ac_objext
 168.919 +echo "$lt_simple_link_test_code" >conftest.$ac_ext
 168.920 +eval "$ac_link" 2>&1 >/dev/null | $SED '/^$/d; /^ *+/d' >conftest.err
 168.921 +_lt_linker_boilerplate=`cat conftest.err`
 168.922 +$RM -r conftest*
 168.923 +])# _LT_LINKER_BOILERPLATE
 168.924 +
 168.925 +# _LT_REQUIRED_DARWIN_CHECKS
 168.926 +# -------------------------
 168.927 +m4_defun_once([_LT_REQUIRED_DARWIN_CHECKS],[
 168.928 +  case $host_os in
 168.929 +    rhapsody* | darwin*)
 168.930 +    AC_CHECK_TOOL([DSYMUTIL], [dsymutil], [:])
 168.931 +    AC_CHECK_TOOL([NMEDIT], [nmedit], [:])
 168.932 +    AC_CHECK_TOOL([LIPO], [lipo], [:])
 168.933 +    AC_CHECK_TOOL([OTOOL], [otool], [:])
 168.934 +    AC_CHECK_TOOL([OTOOL64], [otool64], [:])
 168.935 +    _LT_DECL([], [DSYMUTIL], [1],
 168.936 +      [Tool to manipulate archived DWARF debug symbol files on Mac OS X])
 168.937 +    _LT_DECL([], [NMEDIT], [1],
 168.938 +      [Tool to change global to local symbols on Mac OS X])
 168.939 +    _LT_DECL([], [LIPO], [1],
 168.940 +      [Tool to manipulate fat objects and archives on Mac OS X])
 168.941 +    _LT_DECL([], [OTOOL], [1],
 168.942 +      [ldd/readelf like tool for Mach-O binaries on Mac OS X])
 168.943 +    _LT_DECL([], [OTOOL64], [1],
 168.944 +      [ldd/readelf like tool for 64 bit Mach-O binaries on Mac OS X 10.4])
 168.945 +
 168.946 +    AC_CACHE_CHECK([for -single_module linker flag],[lt_cv_apple_cc_single_mod],
 168.947 +      [lt_cv_apple_cc_single_mod=no
 168.948 +      if test -z "${LT_MULTI_MODULE}"; then
 168.949 +	# By default we will add the -single_module flag. You can override
 168.950 +	# by either setting the environment variable LT_MULTI_MODULE
 168.951 +	# non-empty at configure time, or by adding -multi_module to the
 168.952 +	# link flags.
 168.953 +	rm -rf libconftest.dylib*
 168.954 +	echo "int foo(void){return 1;}" > conftest.c
 168.955 +	echo "$LTCC $LTCFLAGS $LDFLAGS -o libconftest.dylib \
 168.956 +-dynamiclib -Wl,-single_module conftest.c" >&AS_MESSAGE_LOG_FD
 168.957 +	$LTCC $LTCFLAGS $LDFLAGS -o libconftest.dylib \
 168.958 +	  -dynamiclib -Wl,-single_module conftest.c 2>conftest.err
 168.959 +        _lt_result=$?
 168.960 +	if test -f libconftest.dylib && test ! -s conftest.err && test $_lt_result = 0; then
 168.961 +	  lt_cv_apple_cc_single_mod=yes
 168.962 +	else
 168.963 +	  cat conftest.err >&AS_MESSAGE_LOG_FD
 168.964 +	fi
 168.965 +	rm -rf libconftest.dylib*
 168.966 +	rm -f conftest.*
 168.967 +      fi])
 168.968 +    AC_CACHE_CHECK([for -exported_symbols_list linker flag],
 168.969 +      [lt_cv_ld_exported_symbols_list],
 168.970 +      [lt_cv_ld_exported_symbols_list=no
 168.971 +      save_LDFLAGS=$LDFLAGS
 168.972 +      echo "_main" > conftest.sym
 168.973 +      LDFLAGS="$LDFLAGS -Wl,-exported_symbols_list,conftest.sym"
 168.974 +      AC_LINK_IFELSE([AC_LANG_PROGRAM([],[])],
 168.975 +	[lt_cv_ld_exported_symbols_list=yes],
 168.976 +	[lt_cv_ld_exported_symbols_list=no])
 168.977 +	LDFLAGS="$save_LDFLAGS"
 168.978 +    ])
 168.979 +    AC_CACHE_CHECK([for -force_load linker flag],[lt_cv_ld_force_load],
 168.980 +      [lt_cv_ld_force_load=no
 168.981 +      cat > conftest.c << _LT_EOF
 168.982 +int forced_loaded() { return 2;}
 168.983 +_LT_EOF
 168.984 +      echo "$LTCC $LTCFLAGS -c -o conftest.o conftest.c" >&AS_MESSAGE_LOG_FD
 168.985 +      $LTCC $LTCFLAGS -c -o conftest.o conftest.c 2>&AS_MESSAGE_LOG_FD
 168.986 +      echo "$AR cru libconftest.a conftest.o" >&AS_MESSAGE_LOG_FD
 168.987 +      $AR cru libconftest.a conftest.o 2>&AS_MESSAGE_LOG_FD
 168.988 +      cat > conftest.c << _LT_EOF
 168.989 +int main() { return 0;}
 168.990 +_LT_EOF
 168.991 +      echo "$LTCC $LTCFLAGS $LDFLAGS -o conftest conftest.c -Wl,-force_load,./libconftest.a" >&AS_MESSAGE_LOG_FD
 168.992 +      $LTCC $LTCFLAGS $LDFLAGS -o conftest conftest.c -Wl,-force_load,./libconftest.a 2>conftest.err
 168.993 +      _lt_result=$?
 168.994 +      if test -f conftest && test ! -s conftest.err && test $_lt_result = 0 && $GREP forced_load conftest 2>&1 >/dev/null; then
 168.995 +	lt_cv_ld_force_load=yes
 168.996 +      else
 168.997 +	cat conftest.err >&AS_MESSAGE_LOG_FD
 168.998 +      fi
 168.999 +        rm -f conftest.err libconftest.a conftest conftest.c
168.1000 +        rm -rf conftest.dSYM
168.1001 +    ])
168.1002 +    case $host_os in
168.1003 +    rhapsody* | darwin1.[[012]])
168.1004 +      _lt_dar_allow_undefined='${wl}-undefined ${wl}suppress' ;;
168.1005 +    darwin1.*)
168.1006 +      _lt_dar_allow_undefined='${wl}-flat_namespace ${wl}-undefined ${wl}suppress' ;;
168.1007 +    darwin*) # darwin 5.x on
168.1008 +      # if running on 10.5 or later, the deployment target defaults
168.1009 +      # to the OS version, if on x86, and 10.4, the deployment
168.1010 +      # target defaults to 10.4. Don't you love it?
168.1011 +      case ${MACOSX_DEPLOYMENT_TARGET-10.0},$host in
168.1012 +	10.0,*86*-darwin8*|10.0,*-darwin[[91]]*)
168.1013 +	  _lt_dar_allow_undefined='${wl}-undefined ${wl}dynamic_lookup' ;;
168.1014 +	10.[[012]]*)
168.1015 +	  _lt_dar_allow_undefined='${wl}-flat_namespace ${wl}-undefined ${wl}suppress' ;;
168.1016 +	10.*)
168.1017 +	  _lt_dar_allow_undefined='${wl}-undefined ${wl}dynamic_lookup' ;;
168.1018 +      esac
168.1019 +    ;;
168.1020 +  esac
168.1021 +    if test "$lt_cv_apple_cc_single_mod" = "yes"; then
168.1022 +      _lt_dar_single_mod='$single_module'
168.1023 +    fi
168.1024 +    if test "$lt_cv_ld_exported_symbols_list" = "yes"; then
168.1025 +      _lt_dar_export_syms=' ${wl}-exported_symbols_list,$output_objdir/${libname}-symbols.expsym'
168.1026 +    else
168.1027 +      _lt_dar_export_syms='~$NMEDIT -s $output_objdir/${libname}-symbols.expsym ${lib}'
168.1028 +    fi
168.1029 +    if test "$DSYMUTIL" != ":" && test "$lt_cv_ld_force_load" = "no"; then
168.1030 +      _lt_dsymutil='~$DSYMUTIL $lib || :'
168.1031 +    else
168.1032 +      _lt_dsymutil=
168.1033 +    fi
168.1034 +    ;;
168.1035 +  esac
168.1036 +])
168.1037 +
168.1038 +
168.1039 +# _LT_DARWIN_LINKER_FEATURES
168.1040 +# --------------------------
168.1041 +# Checks for linker and compiler features on darwin
168.1042 +m4_defun([_LT_DARWIN_LINKER_FEATURES],
168.1043 +[
168.1044 +  m4_require([_LT_REQUIRED_DARWIN_CHECKS])
168.1045 +  _LT_TAGVAR(archive_cmds_need_lc, $1)=no
168.1046 +  _LT_TAGVAR(hardcode_direct, $1)=no
168.1047 +  _LT_TAGVAR(hardcode_automatic, $1)=yes
168.1048 +  _LT_TAGVAR(hardcode_shlibpath_var, $1)=unsupported
168.1049 +  if test "$lt_cv_ld_force_load" = "yes"; then
168.1050 +    _LT_TAGVAR(whole_archive_flag_spec, $1)='`for conv in $convenience\"\"; do test  -n \"$conv\" && new_convenience=\"$new_convenience ${wl}-force_load,$conv\"; done; func_echo_all \"$new_convenience\"`'
168.1051 +  else
168.1052 +    _LT_TAGVAR(whole_archive_flag_spec, $1)=''
168.1053 +  fi
168.1054 +  _LT_TAGVAR(link_all_deplibs, $1)=yes
168.1055 +  _LT_TAGVAR(allow_undefined_flag, $1)="$_lt_dar_allow_undefined"
168.1056 +  case $cc_basename in
168.1057 +     ifort*) _lt_dar_can_shared=yes ;;
168.1058 +     *) _lt_dar_can_shared=$GCC ;;
168.1059 +  esac
168.1060 +  if test "$_lt_dar_can_shared" = "yes"; then
168.1061 +    output_verbose_link_cmd=func_echo_all
168.1062 +    _LT_TAGVAR(archive_cmds, $1)="\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring $_lt_dar_single_mod${_lt_dsymutil}"
168.1063 +    _LT_TAGVAR(module_cmds, $1)="\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dsymutil}"
168.1064 +    _LT_TAGVAR(archive_expsym_cmds, $1)="sed 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring ${_lt_dar_single_mod}${_lt_dar_export_syms}${_lt_dsymutil}"
168.1065 +    _LT_TAGVAR(module_expsym_cmds, $1)="sed -e 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dar_export_syms}${_lt_dsymutil}"
168.1066 +    m4_if([$1], [CXX],
168.1067 +[   if test "$lt_cv_apple_cc_single_mod" != "yes"; then
168.1068 +      _LT_TAGVAR(archive_cmds, $1)="\$CC -r -keep_private_externs -nostdlib -o \${lib}-master.o \$libobjs~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \${lib}-master.o \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring${_lt_dsymutil}"
168.1069 +      _LT_TAGVAR(archive_expsym_cmds, $1)="sed 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC -r -keep_private_externs -nostdlib -o \${lib}-master.o \$libobjs~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \${lib}-master.o \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring${_lt_dar_export_syms}${_lt_dsymutil}"
168.1070 +    fi
168.1071 +],[])
168.1072 +  else
168.1073 +  _LT_TAGVAR(ld_shlibs, $1)=no
168.1074 +  fi
168.1075 +])
168.1076 +
168.1077 +# _LT_SYS_MODULE_PATH_AIX
168.1078 +# -----------------------
168.1079 +# Links a minimal program and checks the executable
168.1080 +# for the system default hardcoded library path. In most cases,
168.1081 +# this is /usr/lib:/lib, but when the MPI compilers are used
168.1082 +# the location of the communication and MPI libs are included too.
168.1083 +# If we don't find anything, use the default library path according
168.1084 +# to the aix ld manual.
168.1085 +m4_defun([_LT_SYS_MODULE_PATH_AIX],
168.1086 +[m4_require([_LT_DECL_SED])dnl
168.1087 +AC_LINK_IFELSE(AC_LANG_PROGRAM,[
168.1088 +lt_aix_libpath_sed='
168.1089 +    /Import File Strings/,/^$/ {
168.1090 +	/^0/ {
168.1091 +	    s/^0  *\(.*\)$/\1/
168.1092 +	    p
168.1093 +	}
168.1094 +    }'
168.1095 +aix_libpath=`dump -H conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"`
168.1096 +# Check for a 64-bit object if we didn't find anything.
168.1097 +if test -z "$aix_libpath"; then
168.1098 +  aix_libpath=`dump -HX64 conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"`
168.1099 +fi],[])
168.1100 +if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi
168.1101 +])# _LT_SYS_MODULE_PATH_AIX
168.1102 +
168.1103 +
168.1104 +# _LT_SHELL_INIT(ARG)
168.1105 +# -------------------
168.1106 +m4_define([_LT_SHELL_INIT],
168.1107 +[m4_divert_text([M4SH-INIT], [$1
168.1108 +])])# _LT_SHELL_INIT
168.1109 +
168.1110 +
168.1111 +
168.1112 +# _LT_PROG_ECHO_BACKSLASH
168.1113 +# -----------------------
168.1114 +# Find how we can fake an echo command that does not interpret backslash.
168.1115 +# In particular, with Autoconf 2.60 or later we add some code to the start
168.1116 +# of the generated configure script which will find a shell with a builtin
168.1117 +# printf (which we can use as an echo command).
168.1118 +m4_defun([_LT_PROG_ECHO_BACKSLASH],
168.1119 +[ECHO='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\'
168.1120 +ECHO=$ECHO$ECHO$ECHO$ECHO$ECHO
168.1121 +ECHO=$ECHO$ECHO$ECHO$ECHO$ECHO$ECHO
168.1122 +
168.1123 +AC_MSG_CHECKING([how to print strings])
168.1124 +# Test print first, because it will be a builtin if present.
168.1125 +if test "X`print -r -- -n 2>/dev/null`" = X-n && \
168.1126 +   test "X`print -r -- $ECHO 2>/dev/null`" = "X$ECHO"; then
168.1127 +  ECHO='print -r --'
168.1128 +elif test "X`printf %s $ECHO 2>/dev/null`" = "X$ECHO"; then
168.1129 +  ECHO='printf %s\n'
168.1130 +else
168.1131 +  # Use this function as a fallback that always works.
168.1132 +  func_fallback_echo ()
168.1133 +  {
168.1134 +    eval 'cat <<_LTECHO_EOF
168.1135 +$[]1
168.1136 +_LTECHO_EOF'
168.1137 +  }
168.1138 +  ECHO='func_fallback_echo'
168.1139 +fi
168.1140 +
168.1141 +# func_echo_all arg...
168.1142 +# Invoke $ECHO with all args, space-separated.
168.1143 +func_echo_all ()
168.1144 +{
168.1145 +    $ECHO "$*" 
168.1146 +}
168.1147 +
168.1148 +case "$ECHO" in
168.1149 +  printf*) AC_MSG_RESULT([printf]) ;;
168.1150 +  print*) AC_MSG_RESULT([print -r]) ;;
168.1151 +  *) AC_MSG_RESULT([cat]) ;;
168.1152 +esac
168.1153 +
168.1154 +m4_ifdef([_AS_DETECT_SUGGESTED],
168.1155 +[_AS_DETECT_SUGGESTED([
168.1156 +  test -n "${ZSH_VERSION+set}${BASH_VERSION+set}" || (
168.1157 +    ECHO='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\'
168.1158 +    ECHO=$ECHO$ECHO$ECHO$ECHO$ECHO
168.1159 +    ECHO=$ECHO$ECHO$ECHO$ECHO$ECHO$ECHO
168.1160 +    PATH=/empty FPATH=/empty; export PATH FPATH
168.1161 +    test "X`printf %s $ECHO`" = "X$ECHO" \
168.1162 +      || test "X`print -r -- $ECHO`" = "X$ECHO" )])])
168.1163 +
168.1164 +_LT_DECL([], [SHELL], [1], [Shell to use when invoking shell scripts])
168.1165 +_LT_DECL([], [ECHO], [1], [An echo program that protects backslashes])
168.1166 +])# _LT_PROG_ECHO_BACKSLASH
168.1167 +
168.1168 +
168.1169 +# _LT_ENABLE_LOCK
168.1170 +# ---------------
168.1171 +m4_defun([_LT_ENABLE_LOCK],
168.1172 +[AC_ARG_ENABLE([libtool-lock],
168.1173 +  [AS_HELP_STRING([--disable-libtool-lock],
168.1174 +    [avoid locking (might break parallel builds)])])
168.1175 +test "x$enable_libtool_lock" != xno && enable_libtool_lock=yes
168.1176 +
168.1177 +# Some flags need to be propagated to the compiler or linker for good
168.1178 +# libtool support.
168.1179 +case $host in
168.1180 +ia64-*-hpux*)
168.1181 +  # Find out which ABI we are using.
168.1182 +  echo 'int i;' > conftest.$ac_ext
168.1183 +  if AC_TRY_EVAL(ac_compile); then
168.1184 +    case `/usr/bin/file conftest.$ac_objext` in
168.1185 +      *ELF-32*)
168.1186 +	HPUX_IA64_MODE="32"
168.1187 +	;;
168.1188 +      *ELF-64*)
168.1189 +	HPUX_IA64_MODE="64"
168.1190 +	;;
168.1191 +    esac
168.1192 +  fi
168.1193 +  rm -rf conftest*
168.1194 +  ;;
168.1195 +*-*-irix6*)
168.1196 +  # Find out which ABI we are using.
168.1197 +  echo '[#]line '$LINENO' "configure"' > conftest.$ac_ext
168.1198 +  if AC_TRY_EVAL(ac_compile); then
168.1199 +    if test "$lt_cv_prog_gnu_ld" = yes; then
168.1200 +      case `/usr/bin/file conftest.$ac_objext` in
168.1201 +	*32-bit*)
168.1202 +	  LD="${LD-ld} -melf32bsmip"
168.1203 +	  ;;
168.1204 +	*N32*)
168.1205 +	  LD="${LD-ld} -melf32bmipn32"
168.1206 +	  ;;
168.1207 +	*64-bit*)
168.1208 +	  LD="${LD-ld} -melf64bmip"
168.1209 +	;;
168.1210 +      esac
168.1211 +    else
168.1212 +      case `/usr/bin/file conftest.$ac_objext` in
168.1213 +	*32-bit*)
168.1214 +	  LD="${LD-ld} -32"
168.1215 +	  ;;
168.1216 +	*N32*)
168.1217 +	  LD="${LD-ld} -n32"
168.1218 +	  ;;
168.1219 +	*64-bit*)
168.1220 +	  LD="${LD-ld} -64"
168.1221 +	  ;;
168.1222 +      esac
168.1223 +    fi
168.1224 +  fi
168.1225 +  rm -rf conftest*
168.1226 +  ;;
168.1227 +
168.1228 +x86_64-*kfreebsd*-gnu|x86_64-*linux*|ppc*-*linux*|powerpc*-*linux*| \
168.1229 +s390*-*linux*|s390*-*tpf*|sparc*-*linux*)
168.1230 +  # Find out which ABI we are using.
168.1231 +  echo 'int i;' > conftest.$ac_ext
168.1232 +  if AC_TRY_EVAL(ac_compile); then
168.1233 +    case `/usr/bin/file conftest.o` in
168.1234 +      *32-bit*)
168.1235 +	case $host in
168.1236 +	  x86_64-*kfreebsd*-gnu)
168.1237 +	    LD="${LD-ld} -m elf_i386_fbsd"
168.1238 +	    ;;
168.1239 +	  x86_64-*linux*)
168.1240 +	    LD="${LD-ld} -m elf_i386"
168.1241 +	    ;;
168.1242 +	  ppc64-*linux*|powerpc64-*linux*)
168.1243 +	    LD="${LD-ld} -m elf32ppclinux"
168.1244 +	    ;;
168.1245 +	  s390x-*linux*)
168.1246 +	    LD="${LD-ld} -m elf_s390"
168.1247 +	    ;;
168.1248 +	  sparc64-*linux*)
168.1249 +	    LD="${LD-ld} -m elf32_sparc"
168.1250 +	    ;;
168.1251 +	esac
168.1252 +	;;
168.1253 +      *64-bit*)
168.1254 +	case $host in
168.1255 +	  x86_64-*kfreebsd*-gnu)
168.1256 +	    LD="${LD-ld} -m elf_x86_64_fbsd"
168.1257 +	    ;;
168.1258 +	  x86_64-*linux*)
168.1259 +	    LD="${LD-ld} -m elf_x86_64"
168.1260 +	    ;;
168.1261 +	  ppc*-*linux*|powerpc*-*linux*)
168.1262 +	    LD="${LD-ld} -m elf64ppc"
168.1263 +	    ;;
168.1264 +	  s390*-*linux*|s390*-*tpf*)
168.1265 +	    LD="${LD-ld} -m elf64_s390"
168.1266 +	    ;;
168.1267 +	  sparc*-*linux*)
168.1268 +	    LD="${LD-ld} -m elf64_sparc"
168.1269 +	    ;;
168.1270 +	esac
168.1271 +	;;
168.1272 +    esac
168.1273 +  fi
168.1274 +  rm -rf conftest*
168.1275 +  ;;
168.1276 +
168.1277 +*-*-sco3.2v5*)
168.1278 +  # On SCO OpenServer 5, we need -belf to get full-featured binaries.
168.1279 +  SAVE_CFLAGS="$CFLAGS"
168.1280 +  CFLAGS="$CFLAGS -belf"
168.1281 +  AC_CACHE_CHECK([whether the C compiler needs -belf], lt_cv_cc_needs_belf,
168.1282 +    [AC_LANG_PUSH(C)
168.1283 +     AC_LINK_IFELSE([AC_LANG_PROGRAM([[]],[[]])],[lt_cv_cc_needs_belf=yes],[lt_cv_cc_needs_belf=no])
168.1284 +     AC_LANG_POP])
168.1285 +  if test x"$lt_cv_cc_needs_belf" != x"yes"; then
168.1286 +    # this is probably gcc 2.8.0, egcs 1.0 or newer; no need for -belf
168.1287 +    CFLAGS="$SAVE_CFLAGS"
168.1288 +  fi
168.1289 +  ;;
168.1290 +sparc*-*solaris*)
168.1291 +  # Find out which ABI we are using.
168.1292 +  echo 'int i;' > conftest.$ac_ext
168.1293 +  if AC_TRY_EVAL(ac_compile); then
168.1294 +    case `/usr/bin/file conftest.o` in
168.1295 +    *64-bit*)
168.1296 +      case $lt_cv_prog_gnu_ld in
168.1297 +      yes*) LD="${LD-ld} -m elf64_sparc" ;;
168.1298 +      *)
168.1299 +	if ${LD-ld} -64 -r -o conftest2.o conftest.o >/dev/null 2>&1; then
168.1300 +	  LD="${LD-ld} -64"
168.1301 +	fi
168.1302 +	;;
168.1303 +      esac
168.1304 +      ;;
168.1305 +    esac
168.1306 +  fi
168.1307 +  rm -rf conftest*
168.1308 +  ;;
168.1309 +esac
168.1310 +
168.1311 +need_locks="$enable_libtool_lock"
168.1312 +])# _LT_ENABLE_LOCK
168.1313 +
168.1314 +
168.1315 +# _LT_CMD_OLD_ARCHIVE
168.1316 +# -------------------
168.1317 +m4_defun([_LT_CMD_OLD_ARCHIVE],
168.1318 +[AC_CHECK_TOOL(AR, ar, false)
168.1319 +test -z "$AR" && AR=ar
168.1320 +test -z "$AR_FLAGS" && AR_FLAGS=cru
168.1321 +_LT_DECL([], [AR], [1], [The archiver])
168.1322 +_LT_DECL([], [AR_FLAGS], [1])
168.1323 +
168.1324 +AC_CHECK_TOOL(STRIP, strip, :)
168.1325 +test -z "$STRIP" && STRIP=:
168.1326 +_LT_DECL([], [STRIP], [1], [A symbol stripping program])
168.1327 +
168.1328 +AC_CHECK_TOOL(RANLIB, ranlib, :)
168.1329 +test -z "$RANLIB" && RANLIB=:
168.1330 +_LT_DECL([], [RANLIB], [1],
168.1331 +    [Commands used to install an old-style archive])
168.1332 +
168.1333 +# Determine commands to create old-style static archives.
168.1334 +old_archive_cmds='$AR $AR_FLAGS $oldlib$oldobjs'
168.1335 +old_postinstall_cmds='chmod 644 $oldlib'
168.1336 +old_postuninstall_cmds=
168.1337 +
168.1338 +if test -n "$RANLIB"; then
168.1339 +  case $host_os in
168.1340 +  openbsd*)
168.1341 +    old_postinstall_cmds="$old_postinstall_cmds~\$RANLIB -t \$oldlib"
168.1342 +    ;;
168.1343 +  *)
168.1344 +    old_postinstall_cmds="$old_postinstall_cmds~\$RANLIB \$oldlib"
168.1345 +    ;;
168.1346 +  esac
168.1347 +  old_archive_cmds="$old_archive_cmds~\$RANLIB \$oldlib"
168.1348 +fi
168.1349 +
168.1350 +case $host_os in
168.1351 +  darwin*)
168.1352 +    lock_old_archive_extraction=yes ;;
168.1353 +  *)
168.1354 +    lock_old_archive_extraction=no ;;
168.1355 +esac
168.1356 +_LT_DECL([], [old_postinstall_cmds], [2])
168.1357 +_LT_DECL([], [old_postuninstall_cmds], [2])
168.1358 +_LT_TAGDECL([], [old_archive_cmds], [2],
168.1359 +    [Commands used to build an old-style archive])
168.1360 +_LT_DECL([], [lock_old_archive_extraction], [0],
168.1361 +    [Whether to use a lock for old archive extraction])
168.1362 +])# _LT_CMD_OLD_ARCHIVE
168.1363 +
168.1364 +
168.1365 +# _LT_COMPILER_OPTION(MESSAGE, VARIABLE-NAME, FLAGS,
168.1366 +#		[OUTPUT-FILE], [ACTION-SUCCESS], [ACTION-FAILURE])
168.1367 +# ----------------------------------------------------------------
168.1368 +# Check whether the given compiler option works
168.1369 +AC_DEFUN([_LT_COMPILER_OPTION],
168.1370 +[m4_require([_LT_FILEUTILS_DEFAULTS])dnl
168.1371 +m4_require([_LT_DECL_SED])dnl
168.1372 +AC_CACHE_CHECK([$1], [$2],
168.1373 +  [$2=no
168.1374 +   m4_if([$4], , [ac_outfile=conftest.$ac_objext], [ac_outfile=$4])
168.1375 +   echo "$lt_simple_compile_test_code" > conftest.$ac_ext
168.1376 +   lt_compiler_flag="$3"
168.1377 +   # Insert the option either (1) after the last *FLAGS variable, or
168.1378 +   # (2) before a word containing "conftest.", or (3) at the end.
168.1379 +   # Note that $ac_compile itself does not contain backslashes and begins
168.1380 +   # with a dollar sign (not a hyphen), so the echo should work correctly.
168.1381 +   # The option is referenced via a variable to avoid confusing sed.
168.1382 +   lt_compile=`echo "$ac_compile" | $SED \
168.1383 +   -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
168.1384 +   -e 's: [[^ ]]*conftest\.: $lt_compiler_flag&:; t' \
168.1385 +   -e 's:$: $lt_compiler_flag:'`
168.1386 +   (eval echo "\"\$as_me:$LINENO: $lt_compile\"" >&AS_MESSAGE_LOG_FD)
168.1387 +   (eval "$lt_compile" 2>conftest.err)
168.1388 +   ac_status=$?
168.1389 +   cat conftest.err >&AS_MESSAGE_LOG_FD
168.1390 +   echo "$as_me:$LINENO: \$? = $ac_status" >&AS_MESSAGE_LOG_FD
168.1391 +   if (exit $ac_status) && test -s "$ac_outfile"; then
168.1392 +     # The compiler can only warn and ignore the option if not recognized
168.1393 +     # So say no if there are warnings other than the usual output.
168.1394 +     $ECHO "$_lt_compiler_boilerplate" | $SED '/^$/d' >conftest.exp
168.1395 +     $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2
168.1396 +     if test ! -s conftest.er2 || diff conftest.exp conftest.er2 >/dev/null; then
168.1397 +       $2=yes
168.1398 +     fi
168.1399 +   fi
168.1400 +   $RM conftest*
168.1401 +])
168.1402 +
168.1403 +if test x"[$]$2" = xyes; then
168.1404 +    m4_if([$5], , :, [$5])
168.1405 +else
168.1406 +    m4_if([$6], , :, [$6])
168.1407 +fi
168.1408 +])# _LT_COMPILER_OPTION
168.1409 +
168.1410 +# Old name:
168.1411 +AU_ALIAS([AC_LIBTOOL_COMPILER_OPTION], [_LT_COMPILER_OPTION])
168.1412 +dnl aclocal-1.4 backwards compatibility:
168.1413 +dnl AC_DEFUN([AC_LIBTOOL_COMPILER_OPTION], [])
168.1414 +
168.1415 +
168.1416 +# _LT_LINKER_OPTION(MESSAGE, VARIABLE-NAME, FLAGS,
168.1417 +#                  [ACTION-SUCCESS], [ACTION-FAILURE])
168.1418 +# ----------------------------------------------------
168.1419 +# Check whether the given linker option works
168.1420 +AC_DEFUN([_LT_LINKER_OPTION],
168.1421 +[m4_require([_LT_FILEUTILS_DEFAULTS])dnl
168.1422 +m4_require([_LT_DECL_SED])dnl
168.1423 +AC_CACHE_CHECK([$1], [$2],
168.1424 +  [$2=no
168.1425 +   save_LDFLAGS="$LDFLAGS"
168.1426 +   LDFLAGS="$LDFLAGS $3"
168.1427 +   echo "$lt_simple_link_test_code" > conftest.$ac_ext
168.1428 +   if (eval $ac_link 2>conftest.err) && test -s conftest$ac_exeext; then
168.1429 +     # The linker can only warn and ignore the option if not recognized
168.1430 +     # So say no if there are warnings
168.1431 +     if test -s conftest.err; then
168.1432 +       # Append any errors to the config.log.
168.1433 +       cat conftest.err 1>&AS_MESSAGE_LOG_FD
168.1434 +       $ECHO "$_lt_linker_boilerplate" | $SED '/^$/d' > conftest.exp
168.1435 +       $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2
168.1436 +       if diff conftest.exp conftest.er2 >/dev/null; then
168.1437 +         $2=yes
168.1438 +       fi
168.1439 +     else
168.1440 +       $2=yes
168.1441 +     fi
168.1442 +   fi
168.1443 +   $RM -r conftest*
168.1444 +   LDFLAGS="$save_LDFLAGS"
168.1445 +])
168.1446 +
168.1447 +if test x"[$]$2" = xyes; then
168.1448 +    m4_if([$4], , :, [$4])
168.1449 +else
168.1450 +    m4_if([$5], , :, [$5])
168.1451 +fi
168.1452 +])# _LT_LINKER_OPTION
168.1453 +
168.1454 +# Old name:
168.1455 +AU_ALIAS([AC_LIBTOOL_LINKER_OPTION], [_LT_LINKER_OPTION])
168.1456 +dnl aclocal-1.4 backwards compatibility:
168.1457 +dnl AC_DEFUN([AC_LIBTOOL_LINKER_OPTION], [])
168.1458 +
168.1459 +
168.1460 +# LT_CMD_MAX_LEN
168.1461 +#---------------
168.1462 +AC_DEFUN([LT_CMD_MAX_LEN],
168.1463 +[AC_REQUIRE([AC_CANONICAL_HOST])dnl
168.1464 +# find the maximum length of command line arguments
168.1465 +AC_MSG_CHECKING([the maximum length of command line arguments])
168.1466 +AC_CACHE_VAL([lt_cv_sys_max_cmd_len], [dnl
168.1467 +  i=0
168.1468 +  teststring="ABCD"
168.1469 +
168.1470 +  case $build_os in
168.1471 +  msdosdjgpp*)
168.1472 +    # On DJGPP, this test can blow up pretty badly due to problems in libc
168.1473 +    # (any single argument exceeding 2000 bytes causes a buffer overrun
168.1474 +    # during glob expansion).  Even if it were fixed, the result of this
168.1475 +    # check would be larger than it should be.
168.1476 +    lt_cv_sys_max_cmd_len=12288;    # 12K is about right
168.1477 +    ;;
168.1478 +
168.1479 +  gnu*)
168.1480 +    # Under GNU Hurd, this test is not required because there is
168.1481 +    # no limit to the length of command line arguments.
168.1482 +    # Libtool will interpret -1 as no limit whatsoever
168.1483 +    lt_cv_sys_max_cmd_len=-1;
168.1484 +    ;;
168.1485 +
168.1486 +  cygwin* | mingw* | cegcc*)
168.1487 +    # On Win9x/ME, this test blows up -- it succeeds, but takes
168.1488 +    # about 5 minutes as the teststring grows exponentially.
168.1489 +    # Worse, since 9x/ME are not pre-emptively multitasking,
168.1490 +    # you end up with a "frozen" computer, even though with patience
168.1491 +    # the test eventually succeeds (with a max line length of 256k).
168.1492 +    # Instead, let's just punt: use the minimum linelength reported by
168.1493 +    # all of the supported platforms: 8192 (on NT/2K/XP).
168.1494 +    lt_cv_sys_max_cmd_len=8192;
168.1495 +    ;;
168.1496 +
168.1497 +  mint*)
168.1498 +    # On MiNT this can take a long time and run out of memory.
168.1499 +    lt_cv_sys_max_cmd_len=8192;
168.1500 +    ;;
168.1501 +
168.1502 +  amigaos*)
168.1503 +    # On AmigaOS with pdksh, this test takes hours, literally.
168.1504 +    # So we just punt and use a minimum line length of 8192.
168.1505 +    lt_cv_sys_max_cmd_len=8192;
168.1506 +    ;;
168.1507 +
168.1508 +  netbsd* | freebsd* | openbsd* | darwin* | dragonfly*)
168.1509 +    # This has been around since 386BSD, at least.  Likely further.
168.1510 +    if test -x /sbin/sysctl; then
168.1511 +      lt_cv_sys_max_cmd_len=`/sbin/sysctl -n kern.argmax`
168.1512 +    elif test -x /usr/sbin/sysctl; then
168.1513 +      lt_cv_sys_max_cmd_len=`/usr/sbin/sysctl -n kern.argmax`
168.1514 +    else
168.1515 +      lt_cv_sys_max_cmd_len=65536	# usable default for all BSDs
168.1516 +    fi
168.1517 +    # And add a safety zone
168.1518 +    lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \/ 4`
168.1519 +    lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \* 3`
168.1520 +    ;;
168.1521 +
168.1522 +  interix*)
168.1523 +    # We know the value 262144 and hardcode it with a safety zone (like BSD)
168.1524 +    lt_cv_sys_max_cmd_len=196608
168.1525 +    ;;
168.1526 +
168.1527 +  osf*)
168.1528 +    # Dr. Hans Ekkehard Plesser reports seeing a kernel panic running configure
168.1529 +    # due to this test when exec_disable_arg_limit is 1 on Tru64. It is not
168.1530 +    # nice to cause kernel panics so lets avoid the loop below.
168.1531 +    # First set a reasonable default.
168.1532 +    lt_cv_sys_max_cmd_len=16384
168.1533 +    #
168.1534 +    if test -x /sbin/sysconfig; then
168.1535 +      case `/sbin/sysconfig -q proc exec_disable_arg_limit` in
168.1536 +        *1*) lt_cv_sys_max_cmd_len=-1 ;;
168.1537 +      esac
168.1538 +    fi
168.1539 +    ;;
168.1540 +  sco3.2v5*)
168.1541 +    lt_cv_sys_max_cmd_len=102400
168.1542 +    ;;
168.1543 +  sysv5* | sco5v6* | sysv4.2uw2*)
168.1544 +    kargmax=`grep ARG_MAX /etc/conf/cf.d/stune 2>/dev/null`
168.1545 +    if test -n "$kargmax"; then
168.1546 +      lt_cv_sys_max_cmd_len=`echo $kargmax | sed 's/.*[[	 ]]//'`
168.1547 +    else
168.1548 +      lt_cv_sys_max_cmd_len=32768
168.1549 +    fi
168.1550 +    ;;
168.1551 +  *)
168.1552 +    lt_cv_sys_max_cmd_len=`(getconf ARG_MAX) 2> /dev/null`
168.1553 +    if test -n "$lt_cv_sys_max_cmd_len"; then
168.1554 +      lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \/ 4`
168.1555 +      lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \* 3`
168.1556 +    else
168.1557 +      # Make teststring a little bigger before we do anything with it.
168.1558 +      # a 1K string should be a reasonable start.
168.1559 +      for i in 1 2 3 4 5 6 7 8 ; do
168.1560 +        teststring=$teststring$teststring
168.1561 +      done
168.1562 +      SHELL=${SHELL-${CONFIG_SHELL-/bin/sh}}
168.1563 +      # If test is not a shell built-in, we'll probably end up computing a
168.1564 +      # maximum length that is only half of the actual maximum length, but
168.1565 +      # we can't tell.
168.1566 +      while { test "X"`func_fallback_echo "$teststring$teststring" 2>/dev/null` \
168.1567 +	         = "X$teststring$teststring"; } >/dev/null 2>&1 &&
168.1568 +	      test $i != 17 # 1/2 MB should be enough
168.1569 +      do
168.1570 +        i=`expr $i + 1`
168.1571 +        teststring=$teststring$teststring
168.1572 +      done
168.1573 +      # Only check the string length outside the loop.
168.1574 +      lt_cv_sys_max_cmd_len=`expr "X$teststring" : ".*" 2>&1`
168.1575 +      teststring=
168.1576 +      # Add a significant safety factor because C++ compilers can tack on
168.1577 +      # massive amounts of additional arguments before passing them to the
168.1578 +      # linker.  It appears as though 1/2 is a usable value.
168.1579 +      lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \/ 2`
168.1580 +    fi
168.1581 +    ;;
168.1582 +  esac
168.1583 +])
168.1584 +if test -n $lt_cv_sys_max_cmd_len ; then
168.1585 +  AC_MSG_RESULT($lt_cv_sys_max_cmd_len)
168.1586 +else
168.1587 +  AC_MSG_RESULT(none)
168.1588 +fi
168.1589 +max_cmd_len=$lt_cv_sys_max_cmd_len
168.1590 +_LT_DECL([], [max_cmd_len], [0],
168.1591 +    [What is the maximum length of a command?])
168.1592 +])# LT_CMD_MAX_LEN
168.1593 +
168.1594 +# Old name:
168.1595 +AU_ALIAS([AC_LIBTOOL_SYS_MAX_CMD_LEN], [LT_CMD_MAX_LEN])
168.1596 +dnl aclocal-1.4 backwards compatibility:
168.1597 +dnl AC_DEFUN([AC_LIBTOOL_SYS_MAX_CMD_LEN], [])
168.1598 +
168.1599 +
168.1600 +# _LT_HEADER_DLFCN
168.1601 +# ----------------
168.1602 +m4_defun([_LT_HEADER_DLFCN],
168.1603 +[AC_CHECK_HEADERS([dlfcn.h], [], [], [AC_INCLUDES_DEFAULT])dnl
168.1604 +])# _LT_HEADER_DLFCN
168.1605 +
168.1606 +
168.1607 +# _LT_TRY_DLOPEN_SELF (ACTION-IF-TRUE, ACTION-IF-TRUE-W-USCORE,
168.1608 +#                      ACTION-IF-FALSE, ACTION-IF-CROSS-COMPILING)
168.1609 +# ----------------------------------------------------------------
168.1610 +m4_defun([_LT_TRY_DLOPEN_SELF],
168.1611 +[m4_require([_LT_HEADER_DLFCN])dnl
168.1612 +if test "$cross_compiling" = yes; then :
168.1613 +  [$4]
168.1614 +else
168.1615 +  lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
168.1616 +  lt_status=$lt_dlunknown
168.1617 +  cat > conftest.$ac_ext <<_LT_EOF
168.1618 +[#line $LINENO "configure"
168.1619 +#include "confdefs.h"
168.1620 +
168.1621 +#if HAVE_DLFCN_H
168.1622 +#include <dlfcn.h>
168.1623 +#endif
168.1624 +
168.1625 +#include <stdio.h>
168.1626 +
168.1627 +#ifdef RTLD_GLOBAL
168.1628 +#  define LT_DLGLOBAL		RTLD_GLOBAL
168.1629 +#else
168.1630 +#  ifdef DL_GLOBAL
168.1631 +#    define LT_DLGLOBAL		DL_GLOBAL
168.1632 +#  else
168.1633 +#    define LT_DLGLOBAL		0
168.1634 +#  endif
168.1635 +#endif
168.1636 +
168.1637 +/* We may have to define LT_DLLAZY_OR_NOW in the command line if we
168.1638 +   find out it does not work in some platform. */
168.1639 +#ifndef LT_DLLAZY_OR_NOW
168.1640 +#  ifdef RTLD_LAZY
168.1641 +#    define LT_DLLAZY_OR_NOW		RTLD_LAZY
168.1642 +#  else
168.1643 +#    ifdef DL_LAZY
168.1644 +#      define LT_DLLAZY_OR_NOW		DL_LAZY
168.1645 +#    else
168.1646 +#      ifdef RTLD_NOW
168.1647 +#        define LT_DLLAZY_OR_NOW	RTLD_NOW
168.1648 +#      else
168.1649 +#        ifdef DL_NOW
168.1650 +#          define LT_DLLAZY_OR_NOW	DL_NOW
168.1651 +#        else
168.1652 +#          define LT_DLLAZY_OR_NOW	0
168.1653 +#        endif
168.1654 +#      endif
168.1655 +#    endif
168.1656 +#  endif
168.1657 +#endif
168.1658 +
168.1659 +/* When -fvisbility=hidden is used, assume the code has been annotated
168.1660 +   correspondingly for the symbols needed.  */
168.1661 +#if defined(__GNUC__) && (((__GNUC__ == 3) && (__GNUC_MINOR__ >= 3)) || (__GNUC__ > 3))
168.1662 +void fnord () __attribute__((visibility("default")));
168.1663 +#endif
168.1664 +
168.1665 +void fnord () { int i=42; }
168.1666 +int main ()
168.1667 +{
168.1668 +  void *self = dlopen (0, LT_DLGLOBAL|LT_DLLAZY_OR_NOW);
168.1669 +  int status = $lt_dlunknown;
168.1670 +
168.1671 +  if (self)
168.1672 +    {
168.1673 +      if (dlsym (self,"fnord"))       status = $lt_dlno_uscore;
168.1674 +      else
168.1675 +        {
168.1676 +	  if (dlsym( self,"_fnord"))  status = $lt_dlneed_uscore;
168.1677 +          else puts (dlerror ());
168.1678 +	}
168.1679 +      /* dlclose (self); */
168.1680 +    }
168.1681 +  else
168.1682 +    puts (dlerror ());
168.1683 +
168.1684 +  return status;
168.1685 +}]
168.1686 +_LT_EOF
168.1687 +  if AC_TRY_EVAL(ac_link) && test -s conftest${ac_exeext} 2>/dev/null; then
168.1688 +    (./conftest; exit; ) >&AS_MESSAGE_LOG_FD 2>/dev/null
168.1689 +    lt_status=$?
168.1690 +    case x$lt_status in
168.1691 +      x$lt_dlno_uscore) $1 ;;
168.1692 +      x$lt_dlneed_uscore) $2 ;;
168.1693 +      x$lt_dlunknown|x*) $3 ;;
168.1694 +    esac
168.1695 +  else :
168.1696 +    # compilation failed
168.1697 +    $3
168.1698 +  fi
168.1699 +fi
168.1700 +rm -fr conftest*
168.1701 +])# _LT_TRY_DLOPEN_SELF
168.1702 +
168.1703 +
168.1704 +# LT_SYS_DLOPEN_SELF
168.1705 +# ------------------
168.1706 +AC_DEFUN([LT_SYS_DLOPEN_SELF],
168.1707 +[m4_require([_LT_HEADER_DLFCN])dnl
168.1708 +if test "x$enable_dlopen" != xyes; then
168.1709 +  enable_dlopen=unknown
168.1710 +  enable_dlopen_self=unknown
168.1711 +  enable_dlopen_self_static=unknown
168.1712 +else
168.1713 +  lt_cv_dlopen=no
168.1714 +  lt_cv_dlopen_libs=
168.1715 +
168.1716 +  case $host_os in
168.1717 +  beos*)
168.1718 +    lt_cv_dlopen="load_add_on"
168.1719 +    lt_cv_dlopen_libs=
168.1720 +    lt_cv_dlopen_self=yes
168.1721 +    ;;
168.1722 +
168.1723 +  mingw* | pw32* | cegcc*)
168.1724 +    lt_cv_dlopen="LoadLibrary"
168.1725 +    lt_cv_dlopen_libs=
168.1726 +    ;;
168.1727 +
168.1728 +  cygwin*)
168.1729 +    lt_cv_dlopen="dlopen"
168.1730 +    lt_cv_dlopen_libs=
168.1731 +    ;;
168.1732 +
168.1733 +  darwin*)
168.1734 +  # if libdl is installed we need to link against it
168.1735 +    AC_CHECK_LIB([dl], [dlopen],
168.1736 +		[lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-ldl"],[
168.1737 +    lt_cv_dlopen="dyld"
168.1738 +    lt_cv_dlopen_libs=
168.1739 +    lt_cv_dlopen_self=yes
168.1740 +    ])
168.1741 +    ;;
168.1742 +
168.1743 +  *)
168.1744 +    AC_CHECK_FUNC([shl_load],
168.1745 +	  [lt_cv_dlopen="shl_load"],
168.1746 +      [AC_CHECK_LIB([dld], [shl_load],
168.1747 +	    [lt_cv_dlopen="shl_load" lt_cv_dlopen_libs="-ldld"],
168.1748 +	[AC_CHECK_FUNC([dlopen],
168.1749 +	      [lt_cv_dlopen="dlopen"],
168.1750 +	  [AC_CHECK_LIB([dl], [dlopen],
168.1751 +		[lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-ldl"],
168.1752 +	    [AC_CHECK_LIB([svld], [dlopen],
168.1753 +		  [lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-lsvld"],
168.1754 +	      [AC_CHECK_LIB([dld], [dld_link],
168.1755 +		    [lt_cv_dlopen="dld_link" lt_cv_dlopen_libs="-ldld"])
168.1756 +	      ])
168.1757 +	    ])
168.1758 +	  ])
168.1759 +	])
168.1760 +      ])
168.1761 +    ;;
168.1762 +  esac
168.1763 +
168.1764 +  if test "x$lt_cv_dlopen" != xno; then
168.1765 +    enable_dlopen=yes
168.1766 +  else
168.1767 +    enable_dlopen=no
168.1768 +  fi
168.1769 +
168.1770 +  case $lt_cv_dlopen in
168.1771 +  dlopen)
168.1772 +    save_CPPFLAGS="$CPPFLAGS"
168.1773 +    test "x$ac_cv_header_dlfcn_h" = xyes && CPPFLAGS="$CPPFLAGS -DHAVE_DLFCN_H"
168.1774 +
168.1775 +    save_LDFLAGS="$LDFLAGS"
168.1776 +    wl=$lt_prog_compiler_wl eval LDFLAGS=\"\$LDFLAGS $export_dynamic_flag_spec\"
168.1777 +
168.1778 +    save_LIBS="$LIBS"
168.1779 +    LIBS="$lt_cv_dlopen_libs $LIBS"
168.1780 +
168.1781 +    AC_CACHE_CHECK([whether a program can dlopen itself],
168.1782 +	  lt_cv_dlopen_self, [dnl
168.1783 +	  _LT_TRY_DLOPEN_SELF(
168.1784 +	    lt_cv_dlopen_self=yes, lt_cv_dlopen_self=yes,
168.1785 +	    lt_cv_dlopen_self=no, lt_cv_dlopen_self=cross)
168.1786 +    ])
168.1787 +
168.1788 +    if test "x$lt_cv_dlopen_self" = xyes; then
168.1789 +      wl=$lt_prog_compiler_wl eval LDFLAGS=\"\$LDFLAGS $lt_prog_compiler_static\"
168.1790 +      AC_CACHE_CHECK([whether a statically linked program can dlopen itself],
168.1791 +	  lt_cv_dlopen_self_static, [dnl
168.1792 +	  _LT_TRY_DLOPEN_SELF(
168.1793 +	    lt_cv_dlopen_self_static=yes, lt_cv_dlopen_self_static=yes,
168.1794 +	    lt_cv_dlopen_self_static=no,  lt_cv_dlopen_self_static=cross)
168.1795 +      ])
168.1796 +    fi
168.1797 +
168.1798 +    CPPFLAGS="$save_CPPFLAGS"
168.1799 +    LDFLAGS="$save_LDFLAGS"
168.1800 +    LIBS="$save_LIBS"
168.1801 +    ;;
168.1802 +  esac
168.1803 +
168.1804 +  case $lt_cv_dlopen_self in
168.1805 +  yes|no) enable_dlopen_self=$lt_cv_dlopen_self ;;
168.1806 +  *) enable_dlopen_self=unknown ;;
168.1807 +  esac
168.1808 +
168.1809 +  case $lt_cv_dlopen_self_static in
168.1810 +  yes|no) enable_dlopen_self_static=$lt_cv_dlopen_self_static ;;
168.1811 +  *) enable_dlopen_self_static=unknown ;;
168.1812 +  esac
168.1813 +fi
168.1814 +_LT_DECL([dlopen_support], [enable_dlopen], [0],
168.1815 +	 [Whether dlopen is supported])
168.1816 +_LT_DECL([dlopen_self], [enable_dlopen_self], [0],
168.1817 +	 [Whether dlopen of programs is supported])
168.1818 +_LT_DECL([dlopen_self_static], [enable_dlopen_self_static], [0],
168.1819 +	 [Whether dlopen of statically linked programs is supported])
168.1820 +])# LT_SYS_DLOPEN_SELF
168.1821 +
168.1822 +# Old name:
168.1823 +AU_ALIAS([AC_LIBTOOL_DLOPEN_SELF], [LT_SYS_DLOPEN_SELF])
168.1824 +dnl aclocal-1.4 backwards compatibility:
168.1825 +dnl AC_DEFUN([AC_LIBTOOL_DLOPEN_SELF], [])
168.1826 +
168.1827 +
168.1828 +# _LT_COMPILER_C_O([TAGNAME])
168.1829 +# ---------------------------
168.1830 +# Check to see if options -c and -o are simultaneously supported by compiler.
168.1831 +# This macro does not hard code the compiler like AC_PROG_CC_C_O.
168.1832 +m4_defun([_LT_COMPILER_C_O],
168.1833 +[m4_require([_LT_DECL_SED])dnl
168.1834 +m4_require([_LT_FILEUTILS_DEFAULTS])dnl
168.1835 +m4_require([_LT_TAG_COMPILER])dnl
168.1836 +AC_CACHE_CHECK([if $compiler supports -c -o file.$ac_objext],
168.1837 +  [_LT_TAGVAR(lt_cv_prog_compiler_c_o, $1)],
168.1838 +  [_LT_TAGVAR(lt_cv_prog_compiler_c_o, $1)=no
168.1839 +   $RM -r conftest 2>/dev/null
168.1840 +   mkdir conftest
168.1841 +   cd conftest
168.1842 +   mkdir out
168.1843 +   echo "$lt_simple_compile_test_code" > conftest.$ac_ext
168.1844 +
168.1845 +   lt_compiler_flag="-o out/conftest2.$ac_objext"
168.1846 +   # Insert the option either (1) after the last *FLAGS variable, or
168.1847 +   # (2) before a word containing "conftest.", or (3) at the end.
168.1848 +   # Note that $ac_compile itself does not contain backslashes and begins
168.1849 +   # with a dollar sign (not a hyphen), so the echo should work correctly.
168.1850 +   lt_compile=`echo "$ac_compile" | $SED \
168.1851 +   -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
168.1852 +   -e 's: [[^ ]]*conftest\.: $lt_compiler_flag&:; t' \
168.1853 +   -e 's:$: $lt_compiler_flag:'`
168.1854 +   (eval echo "\"\$as_me:$LINENO: $lt_compile\"" >&AS_MESSAGE_LOG_FD)
168.1855 +   (eval "$lt_compile" 2>out/conftest.err)
168.1856 +   ac_status=$?
168.1857 +   cat out/conftest.err >&AS_MESSAGE_LOG_FD
168.1858 +   echo "$as_me:$LINENO: \$? = $ac_status" >&AS_MESSAGE_LOG_FD
168.1859 +   if (exit $ac_status) && test -s out/conftest2.$ac_objext
168.1860 +   then
168.1861 +     # The compiler can only warn and ignore the option if not recognized
168.1862 +     # So say no if there are warnings
168.1863 +     $ECHO "$_lt_compiler_boilerplate" | $SED '/^$/d' > out/conftest.exp
168.1864 +     $SED '/^$/d; /^ *+/d' out/conftest.err >out/conftest.er2
168.1865 +     if test ! -s out/conftest.er2 || diff out/conftest.exp out/conftest.er2 >/dev/null; then
168.1866 +       _LT_TAGVAR(lt_cv_prog_compiler_c_o, $1)=yes
168.1867 +     fi
168.1868 +   fi
168.1869 +   chmod u+w . 2>&AS_MESSAGE_LOG_FD
168.1870 +   $RM conftest*
168.1871 +   # SGI C++ compiler will create directory out/ii_files/ for
168.1872 +   # template instantiation
168.1873 +   test -d out/ii_files && $RM out/ii_files/* && rmdir out/ii_files
168.1874 +   $RM out/* && rmdir out
168.1875 +   cd ..
168.1876 +   $RM -r conftest
168.1877 +   $RM conftest*
168.1878 +])
168.1879 +_LT_TAGDECL([compiler_c_o], [lt_cv_prog_compiler_c_o], [1],
168.1880 +	[Does compiler simultaneously support -c and -o options?])
168.1881 +])# _LT_COMPILER_C_O
168.1882 +
168.1883 +
168.1884 +# _LT_COMPILER_FILE_LOCKS([TAGNAME])
168.1885 +# ----------------------------------
168.1886 +# Check to see if we can do hard links to lock some files if needed
168.1887 +m4_defun([_LT_COMPILER_FILE_LOCKS],
168.1888 +[m4_require([_LT_ENABLE_LOCK])dnl
168.1889 +m4_require([_LT_FILEUTILS_DEFAULTS])dnl
168.1890 +_LT_COMPILER_C_O([$1])
168.1891 +
168.1892 +hard_links="nottested"
168.1893 +if test "$_LT_TAGVAR(lt_cv_prog_compiler_c_o, $1)" = no && test "$need_locks" != no; then
168.1894 +  # do not overwrite the value of need_locks provided by the user
168.1895 +  AC_MSG_CHECKING([if we can lock with hard links])
168.1896 +  hard_links=yes
168.1897 +  $RM conftest*
168.1898 +  ln conftest.a conftest.b 2>/dev/null && hard_links=no
168.1899 +  touch conftest.a
168.1900 +  ln conftest.a conftest.b 2>&5 || hard_links=no
168.1901 +  ln conftest.a conftest.b 2>/dev/null && hard_links=no
168.1902 +  AC_MSG_RESULT([$hard_links])
168.1903 +  if test "$hard_links" = no; then
168.1904 +    AC_MSG_WARN([`$CC' does not support `-c -o', so `make -j' may be unsafe])
168.1905 +    need_locks=warn
168.1906 +  fi
168.1907 +else
168.1908 +  need_locks=no
168.1909 +fi
168.1910 +_LT_DECL([], [need_locks], [1], [Must we lock files when doing compilation?])
168.1911 +])# _LT_COMPILER_FILE_LOCKS
168.1912 +
168.1913 +
168.1914 +# _LT_CHECK_OBJDIR
168.1915 +# ----------------
168.1916 +m4_defun([_LT_CHECK_OBJDIR],
168.1917 +[AC_CACHE_CHECK([for objdir], [lt_cv_objdir],
168.1918 +[rm -f .libs 2>/dev/null
168.1919 +mkdir .libs 2>/dev/null
168.1920 +if test -d .libs; then
168.1921 +  lt_cv_objdir=.libs
168.1922 +else
168.1923 +  # MS-DOS does not allow filenames that begin with a dot.
168.1924 +  lt_cv_objdir=_libs
168.1925 +fi
168.1926 +rmdir .libs 2>/dev/null])
168.1927 +objdir=$lt_cv_objdir
168.1928 +_LT_DECL([], [objdir], [0],
168.1929 +         [The name of the directory that contains temporary libtool files])dnl
168.1930 +m4_pattern_allow([LT_OBJDIR])dnl
168.1931 +AC_DEFINE_UNQUOTED(LT_OBJDIR, "$lt_cv_objdir/",
168.1932 +  [Define to the sub-directory in which libtool stores uninstalled libraries.])
168.1933 +])# _LT_CHECK_OBJDIR
168.1934 +
168.1935 +
168.1936 +# _LT_LINKER_HARDCODE_LIBPATH([TAGNAME])
168.1937 +# --------------------------------------
168.1938 +# Check hardcoding attributes.
168.1939 +m4_defun([_LT_LINKER_HARDCODE_LIBPATH],
168.1940 +[AC_MSG_CHECKING([how to hardcode library paths into programs])
168.1941 +_LT_TAGVAR(hardcode_action, $1)=
168.1942 +if test -n "$_LT_TAGVAR(hardcode_libdir_flag_spec, $1)" ||
168.1943 +   test -n "$_LT_TAGVAR(runpath_var, $1)" ||
168.1944 +   test "X$_LT_TAGVAR(hardcode_automatic, $1)" = "Xyes" ; then
168.1945 +
168.1946 +  # We can hardcode non-existent directories.
168.1947 +  if test "$_LT_TAGVAR(hardcode_direct, $1)" != no &&
168.1948 +     # If the only mechanism to avoid hardcoding is shlibpath_var, we
168.1949 +     # have to relink, otherwise we might link with an installed library
168.1950 +     # when we should be linking with a yet-to-be-installed one
168.1951 +     ## test "$_LT_TAGVAR(hardcode_shlibpath_var, $1)" != no &&
168.1952 +     test "$_LT_TAGVAR(hardcode_minus_L, $1)" != no; then
168.1953 +    # Linking always hardcodes the temporary library directory.
168.1954 +    _LT_TAGVAR(hardcode_action, $1)=relink
168.1955 +  else
168.1956 +    # We can link without hardcoding, and we can hardcode nonexisting dirs.
168.1957 +    _LT_TAGVAR(hardcode_action, $1)=immediate
168.1958 +  fi
168.1959 +else
168.1960 +  # We cannot hardcode anything, or else we can only hardcode existing
168.1961 +  # directories.
168.1962 +  _LT_TAGVAR(hardcode_action, $1)=unsupported
168.1963 +fi
168.1964 +AC_MSG_RESULT([$_LT_TAGVAR(hardcode_action, $1)])
168.1965 +
168.1966 +if test "$_LT_TAGVAR(hardcode_action, $1)" = relink ||
168.1967 +   test "$_LT_TAGVAR(inherit_rpath, $1)" = yes; then
168.1968 +  # Fast installation is not supported
168.1969 +  enable_fast_install=no
168.1970 +elif test "$shlibpath_overrides_runpath" = yes ||
168.1971 +     test "$enable_shared" = no; then
168.1972 +  # Fast installation is not necessary
168.1973 +  enable_fast_install=needless
168.1974 +fi
168.1975 +_LT_TAGDECL([], [hardcode_action], [0],
168.1976 +    [How to hardcode a shared library path into an executable])
168.1977 +])# _LT_LINKER_HARDCODE_LIBPATH
168.1978 +
168.1979 +
168.1980 +# _LT_CMD_STRIPLIB
168.1981 +# ----------------
168.1982 +m4_defun([_LT_CMD_STRIPLIB],
168.1983 +[m4_require([_LT_DECL_EGREP])
168.1984 +striplib=
168.1985 +old_striplib=
168.1986 +AC_MSG_CHECKING([whether stripping libraries is possible])
168.1987 +if test -n "$STRIP" && $STRIP -V 2>&1 | $GREP "GNU strip" >/dev/null; then
168.1988 +  test -z "$old_striplib" && old_striplib="$STRIP --strip-debug"
168.1989 +  test -z "$striplib" && striplib="$STRIP --strip-unneeded"
168.1990 +  AC_MSG_RESULT([yes])
168.1991 +else
168.1992 +# FIXME - insert some real tests, host_os isn't really good enough
168.1993 +  case $host_os in
168.1994 +  darwin*)
168.1995 +    if test -n "$STRIP" ; then
168.1996 +      striplib="$STRIP -x"
168.1997 +      old_striplib="$STRIP -S"
168.1998 +      AC_MSG_RESULT([yes])
168.1999 +    else
168.2000 +      AC_MSG_RESULT([no])
168.2001 +    fi
168.2002 +    ;;
168.2003 +  *)
168.2004 +    AC_MSG_RESULT([no])
168.2005 +    ;;
168.2006 +  esac
168.2007 +fi
168.2008 +_LT_DECL([], [old_striplib], [1], [Commands to strip libraries])
168.2009 +_LT_DECL([], [striplib], [1])
168.2010 +])# _LT_CMD_STRIPLIB
168.2011 +
168.2012 +
168.2013 +# _LT_SYS_DYNAMIC_LINKER([TAG])
168.2014 +# -----------------------------
168.2015 +# PORTME Fill in your ld.so characteristics
168.2016 +m4_defun([_LT_SYS_DYNAMIC_LINKER],
168.2017 +[AC_REQUIRE([AC_CANONICAL_HOST])dnl
168.2018 +m4_require([_LT_DECL_EGREP])dnl
168.2019 +m4_require([_LT_FILEUTILS_DEFAULTS])dnl
168.2020 +m4_require([_LT_DECL_OBJDUMP])dnl
168.2021 +m4_require([_LT_DECL_SED])dnl
168.2022 +m4_require([_LT_CHECK_SHELL_FEATURES])dnl
168.2023 +AC_MSG_CHECKING([dynamic linker characteristics])
168.2024 +m4_if([$1],
168.2025 +	[], [
168.2026 +if test "$GCC" = yes; then
168.2027 +  case $host_os in
168.2028 +    darwin*) lt_awk_arg="/^libraries:/,/LR/" ;;
168.2029 +    *) lt_awk_arg="/^libraries:/" ;;
168.2030 +  esac
168.2031 +  case $host_os in
168.2032 +    mingw* | cegcc*) lt_sed_strip_eq="s,=\([[A-Za-z]]:\),\1,g" ;;
168.2033 +    *) lt_sed_strip_eq="s,=/,/,g" ;;
168.2034 +  esac
168.2035 +  lt_search_path_spec=`$CC -print-search-dirs | awk $lt_awk_arg | $SED -e "s/^libraries://" -e $lt_sed_strip_eq`
168.2036 +  case $lt_search_path_spec in
168.2037 +  *\;*)
168.2038 +    # if the path contains ";" then we assume it to be the separator
168.2039 +    # otherwise default to the standard path separator (i.e. ":") - it is
168.2040 +    # assumed that no part of a normal pathname contains ";" but that should
168.2041 +    # okay in the real world where ";" in dirpaths is itself problematic.
168.2042 +    lt_search_path_spec=`$ECHO "$lt_search_path_spec" | $SED 's/;/ /g'`
168.2043 +    ;;
168.2044 +  *)
168.2045 +    lt_search_path_spec=`$ECHO "$lt_search_path_spec" | $SED "s/$PATH_SEPARATOR/ /g"`
168.2046 +    ;;
168.2047 +  esac
168.2048 +  # Ok, now we have the path, separated by spaces, we can step through it
168.2049 +  # and add multilib dir if necessary.
168.2050 +  lt_tmp_lt_search_path_spec=
168.2051 +  lt_multi_os_dir=`$CC $CPPFLAGS $CFLAGS $LDFLAGS -print-multi-os-directory 2>/dev/null`
168.2052 +  for lt_sys_path in $lt_search_path_spec; do
168.2053 +    if test -d "$lt_sys_path/$lt_multi_os_dir"; then
168.2054 +      lt_tmp_lt_search_path_spec="$lt_tmp_lt_search_path_spec $lt_sys_path/$lt_multi_os_dir"
168.2055 +    else
168.2056 +      test -d "$lt_sys_path" && \
168.2057 +	lt_tmp_lt_search_path_spec="$lt_tmp_lt_search_path_spec $lt_sys_path"
168.2058 +    fi
168.2059 +  done
168.2060 +  lt_search_path_spec=`$ECHO "$lt_tmp_lt_search_path_spec" | awk '
168.2061 +BEGIN {RS=" "; FS="/|\n";} {
168.2062 +  lt_foo="";
168.2063 +  lt_count=0;
168.2064 +  for (lt_i = NF; lt_i > 0; lt_i--) {
168.2065 +    if ($lt_i != "" && $lt_i != ".") {
168.2066 +      if ($lt_i == "..") {
168.2067 +        lt_count++;
168.2068 +      } else {
168.2069 +        if (lt_count == 0) {
168.2070 +          lt_foo="/" $lt_i lt_foo;
168.2071 +        } else {
168.2072 +          lt_count--;
168.2073 +        }
168.2074 +      }
168.2075 +    }
168.2076 +  }
168.2077 +  if (lt_foo != "") { lt_freq[[lt_foo]]++; }
168.2078 +  if (lt_freq[[lt_foo]] == 1) { print lt_foo; }
168.2079 +}'`
168.2080 +  # AWK program above erroneously prepends '/' to C:/dos/paths
168.2081 +  # for these hosts.
168.2082 +  case $host_os in
168.2083 +    mingw* | cegcc*) lt_search_path_spec=`$ECHO "$lt_search_path_spec" |\
168.2084 +      $SED 's,/\([[A-Za-z]]:\),\1,g'` ;;
168.2085 +  esac
168.2086 +  sys_lib_search_path_spec=`$ECHO "$lt_search_path_spec" | $lt_NL2SP`
168.2087 +else
168.2088 +  sys_lib_search_path_spec="/lib /usr/lib /usr/local/lib"
168.2089 +fi])
168.2090 +library_names_spec=
168.2091 +libname_spec='lib$name'
168.2092 +soname_spec=
168.2093 +shrext_cmds=".so"
168.2094 +postinstall_cmds=
168.2095 +postuninstall_cmds=
168.2096 +finish_cmds=
168.2097 +finish_eval=
168.2098 +shlibpath_var=
168.2099 +shlibpath_overrides_runpath=unknown
168.2100 +version_type=none
168.2101 +dynamic_linker="$host_os ld.so"
168.2102 +sys_lib_dlsearch_path_spec="/lib /usr/lib"
168.2103 +need_lib_prefix=unknown
168.2104 +hardcode_into_libs=no
168.2105 +
168.2106 +# when you set need_version to no, make sure it does not cause -set_version
168.2107 +# flags to be left without arguments
168.2108 +need_version=unknown
168.2109 +
168.2110 +case $host_os in
168.2111 +aix3*)
168.2112 +  version_type=linux
168.2113 +  library_names_spec='${libname}${release}${shared_ext}$versuffix $libname.a'
168.2114 +  shlibpath_var=LIBPATH
168.2115 +
168.2116 +  # AIX 3 has no versioning support, so we append a major version to the name.
168.2117 +  soname_spec='${libname}${release}${shared_ext}$major'
168.2118 +  ;;
168.2119 +
168.2120 +aix[[4-9]]*)
168.2121 +  version_type=linux
168.2122 +  need_lib_prefix=no
168.2123 +  need_version=no
168.2124 +  hardcode_into_libs=yes
168.2125 +  if test "$host_cpu" = ia64; then
168.2126 +    # AIX 5 supports IA64
168.2127 +    library_names_spec='${libname}${release}${shared_ext}$major ${libname}${release}${shared_ext}$versuffix $libname${shared_ext}'
168.2128 +    shlibpath_var=LD_LIBRARY_PATH
168.2129 +  else
168.2130 +    # With GCC up to 2.95.x, collect2 would create an import file
168.2131 +    # for dependence libraries.  The import file would start with
168.2132 +    # the line `#! .'.  This would cause the generated library to
168.2133 +    # depend on `.', always an invalid library.  This was fixed in
168.2134 +    # development snapshots of GCC prior to 3.0.
168.2135 +    case $host_os in
168.2136 +      aix4 | aix4.[[01]] | aix4.[[01]].*)
168.2137 +      if { echo '#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 97)'
168.2138 +	   echo ' yes '
168.2139 +	   echo '#endif'; } | ${CC} -E - | $GREP yes > /dev/null; then
168.2140 +	:
168.2141 +      else
168.2142 +	can_build_shared=no
168.2143 +      fi
168.2144 +      ;;
168.2145 +    esac
168.2146 +    # AIX (on Power*) has no versioning support, so currently we can not hardcode correct
168.2147 +    # soname into executable. Probably we can add versioning support to
168.2148 +    # collect2, so additional links can be useful in future.
168.2149 +    if test "$aix_use_runtimelinking" = yes; then
168.2150 +      # If using run time linking (on AIX 4.2 or later) use lib<name>.so
168.2151 +      # instead of lib<name>.a to let people know that these are not
168.2152 +      # typical AIX shared libraries.
168.2153 +      library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
168.2154 +    else
168.2155 +      # We preserve .a as extension for shared libraries through AIX4.2
168.2156 +      # and later when we are not doing run time linking.
168.2157 +      library_names_spec='${libname}${release}.a $libname.a'
168.2158 +      soname_spec='${libname}${release}${shared_ext}$major'
168.2159 +    fi
168.2160 +    shlibpath_var=LIBPATH
168.2161 +  fi
168.2162 +  ;;
168.2163 +
168.2164 +amigaos*)
168.2165 +  case $host_cpu in
168.2166 +  powerpc)
168.2167 +    # Since July 2007 AmigaOS4 officially supports .so libraries.
168.2168 +    # When compiling the executable, add -use-dynld -Lsobjs: to the compileline.
168.2169 +    library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
168.2170 +    ;;
168.2171 +  m68k)
168.2172 +    library_names_spec='$libname.ixlibrary $libname.a'
168.2173 +    # Create ${libname}_ixlibrary.a entries in /sys/libs.
168.2174 +    finish_eval='for lib in `ls $libdir/*.ixlibrary 2>/dev/null`; do libname=`func_echo_all "$lib" | $SED '\''s%^.*/\([[^/]]*\)\.ixlibrary$%\1%'\''`; test $RM /sys/libs/${libname}_ixlibrary.a; $show "cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a"; cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a || exit 1; done'
168.2175 +    ;;
168.2176 +  esac
168.2177 +  ;;
168.2178 +
168.2179 +beos*)
168.2180 +  library_names_spec='${libname}${shared_ext}'
168.2181 +  dynamic_linker="$host_os ld.so"
168.2182 +  shlibpath_var=LIBRARY_PATH
168.2183 +  ;;
168.2184 +
168.2185 +bsdi[[45]]*)
168.2186 +  version_type=linux
168.2187 +  need_version=no
168.2188 +  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
168.2189 +  soname_spec='${libname}${release}${shared_ext}$major'
168.2190 +  finish_cmds='PATH="\$PATH:/sbin" ldconfig $libdir'
168.2191 +  shlibpath_var=LD_LIBRARY_PATH
168.2192 +  sys_lib_search_path_spec="/shlib /usr/lib /usr/X11/lib /usr/contrib/lib /lib /usr/local/lib"
168.2193 +  sys_lib_dlsearch_path_spec="/shlib /usr/lib /usr/local/lib"
168.2194 +  # the default ld.so.conf also contains /usr/contrib/lib and
168.2195 +  # /usr/X11R6/lib (/usr/X11 is a link to /usr/X11R6), but let us allow
168.2196 +  # libtool to hard-code these into programs
168.2197 +  ;;
168.2198 +
168.2199 +cygwin* | mingw* | pw32* | cegcc*)
168.2200 +  version_type=windows
168.2201 +  shrext_cmds=".dll"
168.2202 +  need_version=no
168.2203 +  need_lib_prefix=no
168.2204 +
168.2205 +  case $GCC,$host_os in
168.2206 +  yes,cygwin* | yes,mingw* | yes,pw32* | yes,cegcc*)
168.2207 +    library_names_spec='$libname.dll.a'
168.2208 +    # DLL is installed to $(libdir)/../bin by postinstall_cmds
168.2209 +    postinstall_cmds='base_file=`basename \${file}`~
168.2210 +      dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\${base_file}'\''i; echo \$dlname'\''`~
168.2211 +      dldir=$destdir/`dirname \$dlpath`~
168.2212 +      test -d \$dldir || mkdir -p \$dldir~
168.2213 +      $install_prog $dir/$dlname \$dldir/$dlname~
168.2214 +      chmod a+x \$dldir/$dlname~
168.2215 +      if test -n '\''$stripme'\'' && test -n '\''$striplib'\''; then
168.2216 +        eval '\''$striplib \$dldir/$dlname'\'' || exit \$?;
168.2217 +      fi'
168.2218 +    postuninstall_cmds='dldll=`$SHELL 2>&1 -c '\''. $file; echo \$dlname'\''`~
168.2219 +      dlpath=$dir/\$dldll~
168.2220 +       $RM \$dlpath'
168.2221 +    shlibpath_overrides_runpath=yes
168.2222 +
168.2223 +    case $host_os in
168.2224 +    cygwin*)
168.2225 +      # Cygwin DLLs use 'cyg' prefix rather than 'lib'
168.2226 +      soname_spec='`echo ${libname} | sed -e 's/^lib/cyg/'``echo ${release} | $SED -e 's/[[.]]/-/g'`${versuffix}${shared_ext}'
168.2227 +m4_if([$1], [],[
168.2228 +      sys_lib_search_path_spec="$sys_lib_search_path_spec /usr/lib/w32api"])
168.2229 +      ;;
168.2230 +    mingw* | cegcc*)
168.2231 +      # MinGW DLLs use traditional 'lib' prefix
168.2232 +      soname_spec='${libname}`echo ${release} | $SED -e 's/[[.]]/-/g'`${versuffix}${shared_ext}'
168.2233 +      ;;
168.2234 +    pw32*)
168.2235 +      # pw32 DLLs use 'pw' prefix rather than 'lib'
168.2236 +      library_names_spec='`echo ${libname} | sed -e 's/^lib/pw/'``echo ${release} | $SED -e 's/[[.]]/-/g'`${versuffix}${shared_ext}'
168.2237 +      ;;
168.2238 +    esac
168.2239 +    ;;
168.2240 +
168.2241 +  *)
168.2242 +    library_names_spec='${libname}`echo ${release} | $SED -e 's/[[.]]/-/g'`${versuffix}${shared_ext} $libname.lib'
168.2243 +    ;;
168.2244 +  esac
168.2245 +  dynamic_linker='Win32 ld.exe'
168.2246 +  # FIXME: first we should search . and the directory the executable is in
168.2247 +  shlibpath_var=PATH
168.2248 +  ;;
168.2249 +
168.2250 +darwin* | rhapsody*)
168.2251 +  dynamic_linker="$host_os dyld"
168.2252 +  version_type=darwin
168.2253 +  need_lib_prefix=no
168.2254 +  need_version=no
168.2255 +  library_names_spec='${libname}${release}${major}$shared_ext ${libname}$shared_ext'
168.2256 +  soname_spec='${libname}${release}${major}$shared_ext'
168.2257 +  shlibpath_overrides_runpath=yes
168.2258 +  shlibpath_var=DYLD_LIBRARY_PATH
168.2259 +  shrext_cmds='`test .$module = .yes && echo .so || echo .dylib`'
168.2260 +m4_if([$1], [],[
168.2261 +  sys_lib_search_path_spec="$sys_lib_search_path_spec /usr/local/lib"])
168.2262 +  sys_lib_dlsearch_path_spec='/usr/local/lib /lib /usr/lib'
168.2263 +  ;;
168.2264 +
168.2265 +dgux*)
168.2266 +  version_type=linux
168.2267 +  need_lib_prefix=no
168.2268 +  need_version=no
168.2269 +  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname$shared_ext'
168.2270 +  soname_spec='${libname}${release}${shared_ext}$major'
168.2271 +  shlibpath_var=LD_LIBRARY_PATH
168.2272 +  ;;
168.2273 +
168.2274 +freebsd1*)
168.2275 +  dynamic_linker=no
168.2276 +  ;;
168.2277 +
168.2278 +freebsd* | dragonfly*)
168.2279 +  # DragonFly does not have aout.  When/if they implement a new
168.2280 +  # versioning mechanism, adjust this.
168.2281 +  if test -x /usr/bin/objformat; then
168.2282 +    objformat=`/usr/bin/objformat`
168.2283 +  else
168.2284 +    case $host_os in
168.2285 +    freebsd[[123]]*) objformat=aout ;;
168.2286 +    *) objformat=elf ;;
168.2287 +    esac
168.2288 +  fi
168.2289 +  version_type=freebsd-$objformat
168.2290 +  case $version_type in
168.2291 +    freebsd-elf*)
168.2292 +      library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext} $libname${shared_ext}'
168.2293 +      need_version=no
168.2294 +      need_lib_prefix=no
168.2295 +      ;;
168.2296 +    freebsd-*)
168.2297 +      library_names_spec='${libname}${release}${shared_ext}$versuffix $libname${shared_ext}$versuffix'
168.2298 +      need_version=yes
168.2299 +      ;;
168.2300 +  esac
168.2301 +  shlibpath_var=LD_LIBRARY_PATH
168.2302 +  case $host_os in
168.2303 +  freebsd2*)
168.2304 +    shlibpath_overrides_runpath=yes
168.2305 +    ;;
168.2306 +  freebsd3.[[01]]* | freebsdelf3.[[01]]*)
168.2307 +    shlibpath_overrides_runpath=yes
168.2308 +    hardcode_into_libs=yes
168.2309 +    ;;
168.2310 +  freebsd3.[[2-9]]* | freebsdelf3.[[2-9]]* | \
168.2311 +  freebsd4.[[0-5]] | freebsdelf4.[[0-5]] | freebsd4.1.1 | freebsdelf4.1.1)
168.2312 +    shlibpath_overrides_runpath=no
168.2313 +    hardcode_into_libs=yes
168.2314 +    ;;
168.2315 +  *) # from 4.6 on, and DragonFly
168.2316 +    shlibpath_overrides_runpath=yes
168.2317 +    hardcode_into_libs=yes
168.2318 +    ;;
168.2319 +  esac
168.2320 +  ;;
168.2321 +
168.2322 +gnu*)
168.2323 +  version_type=linux
168.2324 +  need_lib_prefix=no
168.2325 +  need_version=no
168.2326 +  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}${major} ${libname}${shared_ext}'
168.2327 +  soname_spec='${libname}${release}${shared_ext}$major'
168.2328 +  shlibpath_var=LD_LIBRARY_PATH
168.2329 +  hardcode_into_libs=yes
168.2330 +  ;;
168.2331 +
168.2332 +haiku*)
168.2333 +  version_type=linux
168.2334 +  need_lib_prefix=no
168.2335 +  need_version=no
168.2336 +  dynamic_linker="$host_os runtime_loader"
168.2337 +  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}${major} ${libname}${shared_ext}'
168.2338 +  soname_spec='${libname}${release}${shared_ext}$major'
168.2339 +  shlibpath_var=LIBRARY_PATH
168.2340 +  shlibpath_overrides_runpath=yes
168.2341 +  sys_lib_dlsearch_path_spec='/boot/home/config/lib /boot/common/lib /boot/beos/system/lib'
168.2342 +  hardcode_into_libs=yes
168.2343 +  ;;
168.2344 +
168.2345 +hpux9* | hpux10* | hpux11*)
168.2346 +  # Give a soname corresponding to the major version so that dld.sl refuses to
168.2347 +  # link against other versions.
168.2348 +  version_type=sunos
168.2349 +  need_lib_prefix=no
168.2350 +  need_version=no
168.2351 +  case $host_cpu in
168.2352 +  ia64*)
168.2353 +    shrext_cmds='.so'
168.2354 +    hardcode_into_libs=yes
168.2355 +    dynamic_linker="$host_os dld.so"
168.2356 +    shlibpath_var=LD_LIBRARY_PATH
168.2357 +    shlibpath_overrides_runpath=yes # Unless +noenvvar is specified.
168.2358 +    library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
168.2359 +    soname_spec='${libname}${release}${shared_ext}$major'
168.2360 +    if test "X$HPUX_IA64_MODE" = X32; then
168.2361 +      sys_lib_search_path_spec="/usr/lib/hpux32 /usr/local/lib/hpux32 /usr/local/lib"
168.2362 +    else
168.2363 +      sys_lib_search_path_spec="/usr/lib/hpux64 /usr/local/lib/hpux64"
168.2364 +    fi
168.2365 +    sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec
168.2366 +    ;;
168.2367 +  hppa*64*)
168.2368 +    shrext_cmds='.sl'
168.2369 +    hardcode_into_libs=yes
168.2370 +    dynamic_linker="$host_os dld.sl"
168.2371 +    shlibpath_var=LD_LIBRARY_PATH # How should we handle SHLIB_PATH
168.2372 +    shlibpath_overrides_runpath=yes # Unless +noenvvar is specified.
168.2373 +    library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
168.2374 +    soname_spec='${libname}${release}${shared_ext}$major'
168.2375 +    sys_lib_search_path_spec="/usr/lib/pa20_64 /usr/ccs/lib/pa20_64"
168.2376 +    sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec
168.2377 +    ;;
168.2378 +  *)
168.2379 +    shrext_cmds='.sl'
168.2380 +    dynamic_linker="$host_os dld.sl"
168.2381 +    shlibpath_var=SHLIB_PATH
168.2382 +    shlibpath_overrides_runpath=no # +s is required to enable SHLIB_PATH
168.2383 +    library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
168.2384 +    soname_spec='${libname}${release}${shared_ext}$major'
168.2385 +    ;;
168.2386 +  esac
168.2387 +  # HP-UX runs *really* slowly unless shared libraries are mode 555, ...
168.2388 +  postinstall_cmds='chmod 555 $lib'
168.2389 +  # or fails outright, so override atomically:
168.2390 +  install_override_mode=555
168.2391 +  ;;
168.2392 +
168.2393 +interix[[3-9]]*)
168.2394 +  version_type=linux
168.2395 +  need_lib_prefix=no
168.2396 +  need_version=no
168.2397 +  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}'
168.2398 +  soname_spec='${libname}${release}${shared_ext}$major'
168.2399 +  dynamic_linker='Interix 3.x ld.so.1 (PE, like ELF)'
168.2400 +  shlibpath_var=LD_LIBRARY_PATH
168.2401 +  shlibpath_overrides_runpath=no
168.2402 +  hardcode_into_libs=yes
168.2403 +  ;;
168.2404 +
168.2405 +irix5* | irix6* | nonstopux*)
168.2406 +  case $host_os in
168.2407 +    nonstopux*) version_type=nonstopux ;;
168.2408 +    *)
168.2409 +	if test "$lt_cv_prog_gnu_ld" = yes; then
168.2410 +		version_type=linux
168.2411 +	else
168.2412 +		version_type=irix
168.2413 +	fi ;;
168.2414 +  esac
168.2415 +  need_lib_prefix=no
168.2416 +  need_version=no
168.2417 +  soname_spec='${libname}${release}${shared_ext}$major'
168.2418 +  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${release}${shared_ext} $libname${shared_ext}'
168.2419 +  case $host_os in
168.2420 +  irix5* | nonstopux*)
168.2421 +    libsuff= shlibsuff=
168.2422 +    ;;
168.2423 +  *)
168.2424 +    case $LD in # libtool.m4 will add one of these switches to LD
168.2425 +    *-32|*"-32 "|*-melf32bsmip|*"-melf32bsmip ")
168.2426 +      libsuff= shlibsuff= libmagic=32-bit;;
168.2427 +    *-n32|*"-n32 "|*-melf32bmipn32|*"-melf32bmipn32 ")
168.2428 +      libsuff=32 shlibsuff=N32 libmagic=N32;;
168.2429 +    *-64|*"-64 "|*-melf64bmip|*"-melf64bmip ")
168.2430 +      libsuff=64 shlibsuff=64 libmagic=64-bit;;
168.2431 +    *) libsuff= shlibsuff= libmagic=never-match;;
168.2432 +    esac
168.2433 +    ;;
168.2434 +  esac
168.2435 +  shlibpath_var=LD_LIBRARY${shlibsuff}_PATH
168.2436 +  shlibpath_overrides_runpath=no
168.2437 +  sys_lib_search_path_spec="/usr/lib${libsuff} /lib${libsuff} /usr/local/lib${libsuff}"
168.2438 +  sys_lib_dlsearch_path_spec="/usr/lib${libsuff} /lib${libsuff}"
168.2439 +  hardcode_into_libs=yes
168.2440 +  ;;
168.2441 +
168.2442 +# No shared lib support for Linux oldld, aout, or coff.
168.2443 +linux*oldld* | linux*aout* | linux*coff*)
168.2444 +  dynamic_linker=no
168.2445 +  ;;
168.2446 +
168.2447 +# This must be Linux ELF.
168.2448 +linux* | k*bsd*-gnu | kopensolaris*-gnu)
168.2449 +  version_type=linux
168.2450 +  need_lib_prefix=no
168.2451 +  need_version=no
168.2452 +  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
168.2453 +  soname_spec='${libname}${release}${shared_ext}$major'
168.2454 +  finish_cmds='PATH="\$PATH:/sbin" ldconfig -n $libdir'
168.2455 +  shlibpath_var=LD_LIBRARY_PATH
168.2456 +  shlibpath_overrides_runpath=no
168.2457 +
168.2458 +  # Some binutils ld are patched to set DT_RUNPATH
168.2459 +  AC_CACHE_VAL([lt_cv_shlibpath_overrides_runpath],
168.2460 +    [lt_cv_shlibpath_overrides_runpath=no
168.2461 +    save_LDFLAGS=$LDFLAGS
168.2462 +    save_libdir=$libdir
168.2463 +    eval "libdir=/foo; wl=\"$_LT_TAGVAR(lt_prog_compiler_wl, $1)\"; \
168.2464 +	 LDFLAGS=\"\$LDFLAGS $_LT_TAGVAR(hardcode_libdir_flag_spec, $1)\""
168.2465 +    AC_LINK_IFELSE([AC_LANG_PROGRAM([],[])],
168.2466 +      [AS_IF([ ($OBJDUMP -p conftest$ac_exeext) 2>/dev/null | grep "RUNPATH.*$libdir" >/dev/null],
168.2467 +	 [lt_cv_shlibpath_overrides_runpath=yes])])
168.2468 +    LDFLAGS=$save_LDFLAGS
168.2469 +    libdir=$save_libdir
168.2470 +    ])
168.2471 +  shlibpath_overrides_runpath=$lt_cv_shlibpath_overrides_runpath
168.2472 +
168.2473 +  # This implies no fast_install, which is unacceptable.
168.2474 +  # Some rework will be needed to allow for fast_install
168.2475 +  # before this can be enabled.
168.2476 +  hardcode_into_libs=yes
168.2477 +
168.2478 +  # Append ld.so.conf contents to the search path
168.2479 +  if test -f /etc/ld.so.conf; then
168.2480 +    lt_ld_extra=`awk '/^include / { system(sprintf("cd /etc; cat %s 2>/dev/null", \[$]2)); skip = 1; } { if (!skip) print \[$]0; skip = 0; }' < /etc/ld.so.conf | $SED -e 's/#.*//;/^[	 ]*hwcap[	 ]/d;s/[:,	]/ /g;s/=[^=]*$//;s/=[^= ]* / /g;s/"//g;/^$/d' | tr '\n' ' '`
168.2481 +    sys_lib_dlsearch_path_spec="/lib /usr/lib $lt_ld_extra"
168.2482 +  fi
168.2483 +
168.2484 +  # We used to test for /lib/ld.so.1 and disable shared libraries on
168.2485 +  # powerpc, because MkLinux only supported shared libraries with the
168.2486 +  # GNU dynamic linker.  Since this was broken with cross compilers,
168.2487 +  # most powerpc-linux boxes support dynamic linking these days and
168.2488 +  # people can always --disable-shared, the test was removed, and we
168.2489 +  # assume the GNU/Linux dynamic linker is in use.
168.2490 +  dynamic_linker='GNU/Linux ld.so'
168.2491 +  ;;
168.2492 +
168.2493 +netbsd*)
168.2494 +  version_type=sunos
168.2495 +  need_lib_prefix=no
168.2496 +  need_version=no
168.2497 +  if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then
168.2498 +    library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix'
168.2499 +    finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir'
168.2500 +    dynamic_linker='NetBSD (a.out) ld.so'
168.2501 +  else
168.2502 +    library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}'
168.2503 +    soname_spec='${libname}${release}${shared_ext}$major'
168.2504 +    dynamic_linker='NetBSD ld.elf_so'
168.2505 +  fi
168.2506 +  shlibpath_var=LD_LIBRARY_PATH
168.2507 +  shlibpath_overrides_runpath=yes
168.2508 +  hardcode_into_libs=yes
168.2509 +  ;;
168.2510 +
168.2511 +newsos6)
168.2512 +  version_type=linux
168.2513 +  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
168.2514 +  shlibpath_var=LD_LIBRARY_PATH
168.2515 +  shlibpath_overrides_runpath=yes
168.2516 +  ;;
168.2517 +
168.2518 +*nto* | *qnx*)
168.2519 +  version_type=qnx
168.2520 +  need_lib_prefix=no
168.2521 +  need_version=no
168.2522 +  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
168.2523 +  soname_spec='${libname}${release}${shared_ext}$major'
168.2524 +  shlibpath_var=LD_LIBRARY_PATH
168.2525 +  shlibpath_overrides_runpath=no
168.2526 +  hardcode_into_libs=yes
168.2527 +  dynamic_linker='ldqnx.so'
168.2528 +  ;;
168.2529 +
168.2530 +openbsd*)
168.2531 +  version_type=sunos
168.2532 +  sys_lib_dlsearch_path_spec="/usr/lib"
168.2533 +  need_lib_prefix=no
168.2534 +  # Some older versions of OpenBSD (3.3 at least) *do* need versioned libs.
168.2535 +  case $host_os in
168.2536 +    openbsd3.3 | openbsd3.3.*)	need_version=yes ;;
168.2537 +    *)				need_version=no  ;;
168.2538 +  esac
168.2539 +  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix'
168.2540 +  finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir'
168.2541 +  shlibpath_var=LD_LIBRARY_PATH
168.2542 +  if test -z "`echo __ELF__ | $CC -E - | $GREP __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then
168.2543 +    case $host_os in
168.2544 +      openbsd2.[[89]] | openbsd2.[[89]].*)
168.2545 +	shlibpath_overrides_runpath=no
168.2546 +	;;
168.2547 +      *)
168.2548 +	shlibpath_overrides_runpath=yes
168.2549 +	;;
168.2550 +      esac
168.2551 +  else
168.2552 +    shlibpath_overrides_runpath=yes
168.2553 +  fi
168.2554 +  ;;
168.2555 +
168.2556 +os2*)
168.2557 +  libname_spec='$name'
168.2558 +  shrext_cmds=".dll"
168.2559 +  need_lib_prefix=no
168.2560 +  library_names_spec='$libname${shared_ext} $libname.a'
168.2561 +  dynamic_linker='OS/2 ld.exe'
168.2562 +  shlibpath_var=LIBPATH
168.2563 +  ;;
168.2564 +
168.2565 +osf3* | osf4* | osf5*)
168.2566 +  version_type=osf
168.2567 +  need_lib_prefix=no
168.2568 +  need_version=no
168.2569 +  soname_spec='${libname}${release}${shared_ext}$major'
168.2570 +  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
168.2571 +  shlibpath_var=LD_LIBRARY_PATH
168.2572 +  sys_lib_search_path_spec="/usr/shlib /usr/ccs/lib /usr/lib/cmplrs/cc /usr/lib /usr/local/lib /var/shlib"
168.2573 +  sys_lib_dlsearch_path_spec="$sys_lib_search_path_spec"
168.2574 +  ;;
168.2575 +
168.2576 +rdos*)
168.2577 +  dynamic_linker=no
168.2578 +  ;;
168.2579 +
168.2580 +solaris*)
168.2581 +  version_type=linux
168.2582 +  need_lib_prefix=no
168.2583 +  need_version=no
168.2584 +  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
168.2585 +  soname_spec='${libname}${release}${shared_ext}$major'
168.2586 +  shlibpath_var=LD_LIBRARY_PATH
168.2587 +  shlibpath_overrides_runpath=yes
168.2588 +  hardcode_into_libs=yes
168.2589 +  # ldd complains unless libraries are executable
168.2590 +  postinstall_cmds='chmod +x $lib'
168.2591 +  ;;
168.2592 +
168.2593 +sunos4*)
168.2594 +  version_type=sunos
168.2595 +  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix'
168.2596 +  finish_cmds='PATH="\$PATH:/usr/etc" ldconfig $libdir'
168.2597 +  shlibpath_var=LD_LIBRARY_PATH
168.2598 +  shlibpath_overrides_runpath=yes
168.2599 +  if test "$with_gnu_ld" = yes; then
168.2600 +    need_lib_prefix=no
168.2601 +  fi
168.2602 +  need_version=yes
168.2603 +  ;;
168.2604 +
168.2605 +sysv4 | sysv4.3*)
168.2606 +  version_type=linux
168.2607 +  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
168.2608 +  soname_spec='${libname}${release}${shared_ext}$major'
168.2609 +  shlibpath_var=LD_LIBRARY_PATH
168.2610 +  case $host_vendor in
168.2611 +    sni)
168.2612 +      shlibpath_overrides_runpath=no
168.2613 +      need_lib_prefix=no
168.2614 +      runpath_var=LD_RUN_PATH
168.2615 +      ;;
168.2616 +    siemens)
168.2617 +      need_lib_prefix=no
168.2618 +      ;;
168.2619 +    motorola)
168.2620 +      need_lib_prefix=no
168.2621 +      need_version=no
168.2622 +      shlibpath_overrides_runpath=no
168.2623 +      sys_lib_search_path_spec='/lib /usr/lib /usr/ccs/lib'
168.2624 +      ;;
168.2625 +  esac
168.2626 +  ;;
168.2627 +
168.2628 +sysv4*MP*)
168.2629 +  if test -d /usr/nec ;then
168.2630 +    version_type=linux
168.2631 +    library_names_spec='$libname${shared_ext}.$versuffix $libname${shared_ext}.$major $libname${shared_ext}'
168.2632 +    soname_spec='$libname${shared_ext}.$major'
168.2633 +    shlibpath_var=LD_LIBRARY_PATH
168.2634 +  fi
168.2635 +  ;;
168.2636 +
168.2637 +sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX* | sysv4*uw2*)
168.2638 +  version_type=freebsd-elf
168.2639 +  need_lib_prefix=no
168.2640 +  need_version=no
168.2641 +  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext} $libname${shared_ext}'
168.2642 +  soname_spec='${libname}${release}${shared_ext}$major'
168.2643 +  shlibpath_var=LD_LIBRARY_PATH
168.2644 +  shlibpath_overrides_runpath=yes
168.2645 +  hardcode_into_libs=yes
168.2646 +  if test "$with_gnu_ld" = yes; then
168.2647 +    sys_lib_search_path_spec='/usr/local/lib /usr/gnu/lib /usr/ccs/lib /usr/lib /lib'
168.2648 +  else
168.2649 +    sys_lib_search_path_spec='/usr/ccs/lib /usr/lib'
168.2650 +    case $host_os in
168.2651 +      sco3.2v5*)
168.2652 +        sys_lib_search_path_spec="$sys_lib_search_path_spec /lib"
168.2653 +	;;
168.2654 +    esac
168.2655 +  fi
168.2656 +  sys_lib_dlsearch_path_spec='/usr/lib'
168.2657 +  ;;
168.2658 +
168.2659 +tpf*)
168.2660 +  # TPF is a cross-target only.  Preferred cross-host = GNU/Linux.
168.2661 +  version_type=linux
168.2662 +  need_lib_prefix=no
168.2663 +  need_version=no
168.2664 +  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
168.2665 +  shlibpath_var=LD_LIBRARY_PATH
168.2666 +  shlibpath_overrides_runpath=no
168.2667 +  hardcode_into_libs=yes
168.2668 +  ;;
168.2669 +
168.2670 +uts4*)
168.2671 +  version_type=linux
168.2672 +  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
168.2673 +  soname_spec='${libname}${release}${shared_ext}$major'
168.2674 +  shlibpath_var=LD_LIBRARY_PATH
168.2675 +  ;;
168.2676 +
168.2677 +*)
168.2678 +  dynamic_linker=no
168.2679 +  ;;
168.2680 +esac
168.2681 +AC_MSG_RESULT([$dynamic_linker])
168.2682 +test "$dynamic_linker" = no && can_build_shared=no
168.2683 +
168.2684 +variables_saved_for_relink="PATH $shlibpath_var $runpath_var"
168.2685 +if test "$GCC" = yes; then
168.2686 +  variables_saved_for_relink="$variables_saved_for_relink GCC_EXEC_PREFIX COMPILER_PATH LIBRARY_PATH"
168.2687 +fi
168.2688 +
168.2689 +if test "${lt_cv_sys_lib_search_path_spec+set}" = set; then
168.2690 +  sys_lib_search_path_spec="$lt_cv_sys_lib_search_path_spec"
168.2691 +fi
168.2692 +if test "${lt_cv_sys_lib_dlsearch_path_spec+set}" = set; then
168.2693 +  sys_lib_dlsearch_path_spec="$lt_cv_sys_lib_dlsearch_path_spec"
168.2694 +fi
168.2695 +
168.2696 +_LT_DECL([], [variables_saved_for_relink], [1],
168.2697 +    [Variables whose values should be saved in libtool wrapper scripts and
168.2698 +    restored at link time])
168.2699 +_LT_DECL([], [need_lib_prefix], [0],
168.2700 +    [Do we need the "lib" prefix for modules?])
168.2701 +_LT_DECL([], [need_version], [0], [Do we need a version for libraries?])
168.2702 +_LT_DECL([], [version_type], [0], [Library versioning type])
168.2703 +_LT_DECL([], [runpath_var], [0],  [Shared library runtime path variable])
168.2704 +_LT_DECL([], [shlibpath_var], [0],[Shared library path variable])
168.2705 +_LT_DECL([], [shlibpath_overrides_runpath], [0],
168.2706 +    [Is shlibpath searched before the hard-coded library search path?])
168.2707 +_LT_DECL([], [libname_spec], [1], [Format of library name prefix])
168.2708 +_LT_DECL([], [library_names_spec], [1],
168.2709 +    [[List of archive names.  First name is the real one, the rest are links.
168.2710 +    The last name is the one that the linker finds with -lNAME]])
168.2711 +_LT_DECL([], [soname_spec], [1],
168.2712 +    [[The coded name of the library, if different from the real name]])
168.2713 +_LT_DECL([], [install_override_mode], [1],
168.2714 +    [Permission mode override for installation of shared libraries])
168.2715 +_LT_DECL([], [postinstall_cmds], [2],
168.2716 +    [Command to use after installation of a shared archive])
168.2717 +_LT_DECL([], [postuninstall_cmds], [2],
168.2718 +    [Command to use after uninstallation of a shared archive])
168.2719 +_LT_DECL([], [finish_cmds], [2],
168.2720 +    [Commands used to finish a libtool library installation in a directory])
168.2721 +_LT_DECL([], [finish_eval], [1],
168.2722 +    [[As "finish_cmds", except a single script fragment to be evaled but
168.2723 +    not shown]])
168.2724 +_LT_DECL([], [hardcode_into_libs], [0],
168.2725 +    [Whether we should hardcode library paths into libraries])
168.2726 +_LT_DECL([], [sys_lib_search_path_spec], [2],
168.2727 +    [Compile-time system search path for libraries])
168.2728 +_LT_DECL([], [sys_lib_dlsearch_path_spec], [2],
168.2729 +    [Run-time system search path for libraries])
168.2730 +])# _LT_SYS_DYNAMIC_LINKER
168.2731 +
168.2732 +
168.2733 +# _LT_PATH_TOOL_PREFIX(TOOL)
168.2734 +# --------------------------
168.2735 +# find a file program which can recognize shared library
168.2736 +AC_DEFUN([_LT_PATH_TOOL_PREFIX],
168.2737 +[m4_require([_LT_DECL_EGREP])dnl
168.2738 +AC_MSG_CHECKING([for $1])
168.2739 +AC_CACHE_VAL(lt_cv_path_MAGIC_CMD,
168.2740 +[case $MAGIC_CMD in
168.2741 +[[\\/*] |  ?:[\\/]*])
168.2742 +  lt_cv_path_MAGIC_CMD="$MAGIC_CMD" # Let the user override the test with a path.
168.2743 +  ;;
168.2744 +*)
168.2745 +  lt_save_MAGIC_CMD="$MAGIC_CMD"
168.2746 +  lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR
168.2747 +dnl $ac_dummy forces splitting on constant user-supplied paths.
168.2748 +dnl POSIX.2 word splitting is done only on the output of word expansions,
168.2749 +dnl not every word.  This closes a longstanding sh security hole.
168.2750 +  ac_dummy="m4_if([$2], , $PATH, [$2])"
168.2751 +  for ac_dir in $ac_dummy; do
168.2752 +    IFS="$lt_save_ifs"
168.2753 +    test -z "$ac_dir" && ac_dir=.
168.2754 +    if test -f $ac_dir/$1; then
168.2755 +      lt_cv_path_MAGIC_CMD="$ac_dir/$1"
168.2756 +      if test -n "$file_magic_test_file"; then
168.2757 +	case $deplibs_check_method in
168.2758 +	"file_magic "*)
168.2759 +	  file_magic_regex=`expr "$deplibs_check_method" : "file_magic \(.*\)"`
168.2760 +	  MAGIC_CMD="$lt_cv_path_MAGIC_CMD"
168.2761 +	  if eval $file_magic_cmd \$file_magic_test_file 2> /dev/null |
168.2762 +	    $EGREP "$file_magic_regex" > /dev/null; then
168.2763 +	    :
168.2764 +	  else
168.2765 +	    cat <<_LT_EOF 1>&2
168.2766 +
168.2767 +*** Warning: the command libtool uses to detect shared libraries,
168.2768 +*** $file_magic_cmd, produces output that libtool cannot recognize.
168.2769 +*** The result is that libtool may fail to recognize shared libraries
168.2770 +*** as such.  This will affect the creation of libtool libraries that
168.2771 +*** depend on shared libraries, but programs linked with such libtool
168.2772 +*** libraries will work regardless of this problem.  Nevertheless, you
168.2773 +*** may want to report the problem to your system manager and/or to
168.2774 +*** bug-libtool@gnu.org
168.2775 +
168.2776 +_LT_EOF
168.2777 +	  fi ;;
168.2778 +	esac
168.2779 +      fi
168.2780 +      break
168.2781 +    fi
168.2782 +  done
168.2783 +  IFS="$lt_save_ifs"
168.2784 +  MAGIC_CMD="$lt_save_MAGIC_CMD"
168.2785 +  ;;
168.2786 +esac])
168.2787 +MAGIC_CMD="$lt_cv_path_MAGIC_CMD"
168.2788 +if test -n "$MAGIC_CMD"; then
168.2789 +  AC_MSG_RESULT($MAGIC_CMD)
168.2790 +else
168.2791 +  AC_MSG_RESULT(no)
168.2792 +fi
168.2793 +_LT_DECL([], [MAGIC_CMD], [0],
168.2794 +	 [Used to examine libraries when file_magic_cmd begins with "file"])dnl
168.2795 +])# _LT_PATH_TOOL_PREFIX
168.2796 +
168.2797 +# Old name:
168.2798 +AU_ALIAS([AC_PATH_TOOL_PREFIX], [_LT_PATH_TOOL_PREFIX])
168.2799 +dnl aclocal-1.4 backwards compatibility:
168.2800 +dnl AC_DEFUN([AC_PATH_TOOL_PREFIX], [])
168.2801 +
168.2802 +
168.2803 +# _LT_PATH_MAGIC
168.2804 +# --------------
168.2805 +# find a file program which can recognize a shared library
168.2806 +m4_defun([_LT_PATH_MAGIC],
168.2807 +[_LT_PATH_TOOL_PREFIX(${ac_tool_prefix}file, /usr/bin$PATH_SEPARATOR$PATH)
168.2808 +if test -z "$lt_cv_path_MAGIC_CMD"; then
168.2809 +  if test -n "$ac_tool_prefix"; then
168.2810 +    _LT_PATH_TOOL_PREFIX(file, /usr/bin$PATH_SEPARATOR$PATH)
168.2811 +  else
168.2812 +    MAGIC_CMD=:
168.2813 +  fi
168.2814 +fi
168.2815 +])# _LT_PATH_MAGIC
168.2816 +
168.2817 +
168.2818 +# LT_PATH_LD
168.2819 +# ----------
168.2820 +# find the pathname to the GNU or non-GNU linker
168.2821 +AC_DEFUN([LT_PATH_LD],
168.2822 +[AC_REQUIRE([AC_PROG_CC])dnl
168.2823 +AC_REQUIRE([AC_CANONICAL_HOST])dnl
168.2824 +AC_REQUIRE([AC_CANONICAL_BUILD])dnl
168.2825 +m4_require([_LT_DECL_SED])dnl
168.2826 +m4_require([_LT_DECL_EGREP])dnl
168.2827 +m4_require([_LT_PROG_ECHO_BACKSLASH])dnl
168.2828 +
168.2829 +AC_ARG_WITH([gnu-ld],
168.2830 +    [AS_HELP_STRING([--with-gnu-ld],
168.2831 +	[assume the C compiler uses GNU ld @<:@default=no@:>@])],
168.2832 +    [test "$withval" = no || with_gnu_ld=yes],
168.2833 +    [with_gnu_ld=no])dnl
168.2834 +
168.2835 +ac_prog=ld
168.2836 +if test "$GCC" = yes; then
168.2837 +  # Check if gcc -print-prog-name=ld gives a path.
168.2838 +  AC_MSG_CHECKING([for ld used by $CC])
168.2839 +  case $host in
168.2840 +  *-*-mingw*)
168.2841 +    # gcc leaves a trailing carriage return which upsets mingw
168.2842 +    ac_prog=`($CC -print-prog-name=ld) 2>&5 | tr -d '\015'` ;;
168.2843 +  *)
168.2844 +    ac_prog=`($CC -print-prog-name=ld) 2>&5` ;;
168.2845 +  esac
168.2846 +  case $ac_prog in
168.2847 +    # Accept absolute paths.
168.2848 +    [[\\/]]* | ?:[[\\/]]*)
168.2849 +      re_direlt='/[[^/]][[^/]]*/\.\./'
168.2850 +      # Canonicalize the pathname of ld
168.2851 +      ac_prog=`$ECHO "$ac_prog"| $SED 's%\\\\%/%g'`
168.2852 +      while $ECHO "$ac_prog" | $GREP "$re_direlt" > /dev/null 2>&1; do
168.2853 +	ac_prog=`$ECHO $ac_prog| $SED "s%$re_direlt%/%"`
168.2854 +      done
168.2855 +      test -z "$LD" && LD="$ac_prog"
168.2856 +      ;;
168.2857 +  "")
168.2858 +    # If it fails, then pretend we aren't using GCC.
168.2859 +    ac_prog=ld
168.2860 +    ;;
168.2861 +  *)
168.2862 +    # If it is relative, then search for the first ld in PATH.
168.2863 +    with_gnu_ld=unknown
168.2864 +    ;;
168.2865 +  esac
168.2866 +elif test "$with_gnu_ld" = yes; then
168.2867 +  AC_MSG_CHECKING([for GNU ld])
168.2868 +else
168.2869 +  AC_MSG_CHECKING([for non-GNU ld])
168.2870 +fi
168.2871 +AC_CACHE_VAL(lt_cv_path_LD,
168.2872 +[if test -z "$LD"; then
168.2873 +  lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR
168.2874 +  for ac_dir in $PATH; do
168.2875 +    IFS="$lt_save_ifs"
168.2876 +    test -z "$ac_dir" && ac_dir=.
168.2877 +    if test -f "$ac_dir/$ac_prog" || test -f "$ac_dir/$ac_prog$ac_exeext"; then
168.2878 +      lt_cv_path_LD="$ac_dir/$ac_prog"
168.2879 +      # Check to see if the program is GNU ld.  I'd rather use --version,
168.2880 +      # but apparently some variants of GNU ld only accept -v.
168.2881 +      # Break only if it was the GNU/non-GNU ld that we prefer.
168.2882 +      case `"$lt_cv_path_LD" -v 2>&1 </dev/null` in
168.2883 +      *GNU* | *'with BFD'*)
168.2884 +	test "$with_gnu_ld" != no && break
168.2885 +	;;
168.2886 +      *)
168.2887 +	test "$with_gnu_ld" != yes && break
168.2888 +	;;
168.2889 +      esac
168.2890 +    fi
168.2891 +  done
168.2892 +  IFS="$lt_save_ifs"
168.2893 +else
168.2894 +  lt_cv_path_LD="$LD" # Let the user override the test with a path.
168.2895 +fi])
168.2896 +LD="$lt_cv_path_LD"
168.2897 +if test -n "$LD"; then
168.2898 +  AC_MSG_RESULT($LD)
168.2899 +else
168.2900 +  AC_MSG_RESULT(no)
168.2901 +fi
168.2902 +test -z "$LD" && AC_MSG_ERROR([no acceptable ld found in \$PATH])
168.2903 +_LT_PATH_LD_GNU
168.2904 +AC_SUBST([LD])
168.2905 +
168.2906 +_LT_TAGDECL([], [LD], [1], [The linker used to build libraries])
168.2907 +])# LT_PATH_LD
168.2908 +
168.2909 +# Old names:
168.2910 +AU_ALIAS([AM_PROG_LD], [LT_PATH_LD])
168.2911 +AU_ALIAS([AC_PROG_LD], [LT_PATH_LD])
168.2912 +dnl aclocal-1.4 backwards compatibility:
168.2913 +dnl AC_DEFUN([AM_PROG_LD], [])
168.2914 +dnl AC_DEFUN([AC_PROG_LD], [])
168.2915 +
168.2916 +
168.2917 +# _LT_PATH_LD_GNU
168.2918 +#- --------------
168.2919 +m4_defun([_LT_PATH_LD_GNU],
168.2920 +[AC_CACHE_CHECK([if the linker ($LD) is GNU ld], lt_cv_prog_gnu_ld,
168.2921 +[# I'd rather use --version here, but apparently some GNU lds only accept -v.
168.2922 +case `$LD -v 2>&1 </dev/null` in
168.2923 +*GNU* | *'with BFD'*)
168.2924 +  lt_cv_prog_gnu_ld=yes
168.2925 +  ;;
168.2926 +*)
168.2927 +  lt_cv_prog_gnu_ld=no
168.2928 +  ;;
168.2929 +esac])
168.2930 +with_gnu_ld=$lt_cv_prog_gnu_ld
168.2931 +])# _LT_PATH_LD_GNU
168.2932 +
168.2933 +
168.2934 +# _LT_CMD_RELOAD
168.2935 +# --------------
168.2936 +# find reload flag for linker
168.2937 +#   -- PORTME Some linkers may need a different reload flag.
168.2938 +m4_defun([_LT_CMD_RELOAD],
168.2939 +[AC_CACHE_CHECK([for $LD option to reload object files],
168.2940 +  lt_cv_ld_reload_flag,
168.2941 +  [lt_cv_ld_reload_flag='-r'])
168.2942 +reload_flag=$lt_cv_ld_reload_flag
168.2943 +case $reload_flag in
168.2944 +"" | " "*) ;;
168.2945 +*) reload_flag=" $reload_flag" ;;
168.2946 +esac
168.2947 +reload_cmds='$LD$reload_flag -o $output$reload_objs'
168.2948 +case $host_os in
168.2949 +  darwin*)
168.2950 +    if test "$GCC" = yes; then
168.2951 +      reload_cmds='$LTCC $LTCFLAGS -nostdlib ${wl}-r -o $output$reload_objs'
168.2952 +    else
168.2953 +      reload_cmds='$LD$reload_flag -o $output$reload_objs'
168.2954 +    fi
168.2955 +    ;;
168.2956 +esac
168.2957 +_LT_TAGDECL([], [reload_flag], [1], [How to create reloadable object files])dnl
168.2958 +_LT_TAGDECL([], [reload_cmds], [2])dnl
168.2959 +])# _LT_CMD_RELOAD
168.2960 +
168.2961 +
168.2962 +# _LT_CHECK_MAGIC_METHOD
168.2963 +# ----------------------
168.2964 +# how to check for library dependencies
168.2965 +#  -- PORTME fill in with the dynamic library characteristics
168.2966 +m4_defun([_LT_CHECK_MAGIC_METHOD],
168.2967 +[m4_require([_LT_DECL_EGREP])
168.2968 +m4_require([_LT_DECL_OBJDUMP])
168.2969 +AC_CACHE_CHECK([how to recognize dependent libraries],
168.2970 +lt_cv_deplibs_check_method,
168.2971 +[lt_cv_file_magic_cmd='$MAGIC_CMD'
168.2972 +lt_cv_file_magic_test_file=
168.2973 +lt_cv_deplibs_check_method='unknown'
168.2974 +# Need to set the preceding variable on all platforms that support
168.2975 +# interlibrary dependencies.
168.2976 +# 'none' -- dependencies not supported.
168.2977 +# `unknown' -- same as none, but documents that we really don't know.
168.2978 +# 'pass_all' -- all dependencies passed with no checks.
168.2979 +# 'test_compile' -- check by making test program.
168.2980 +# 'file_magic [[regex]]' -- check by looking for files in library path
168.2981 +# which responds to the $file_magic_cmd with a given extended regex.
168.2982 +# If you have `file' or equivalent on your system and you're not sure
168.2983 +# whether `pass_all' will *always* work, you probably want this one.
168.2984 +
168.2985 +case $host_os in
168.2986 +aix[[4-9]]*)
168.2987 +  lt_cv_deplibs_check_method=pass_all
168.2988 +  ;;
168.2989 +
168.2990 +beos*)
168.2991 +  lt_cv_deplibs_check_method=pass_all
168.2992 +  ;;
168.2993 +
168.2994 +bsdi[[45]]*)
168.2995 +  lt_cv_deplibs_check_method='file_magic ELF [[0-9]][[0-9]]*-bit [[ML]]SB (shared object|dynamic lib)'
168.2996 +  lt_cv_file_magic_cmd='/usr/bin/file -L'
168.2997 +  lt_cv_file_magic_test_file=/shlib/libc.so
168.2998 +  ;;
168.2999 +
168.3000 +cygwin*)
168.3001 +  # func_win32_libid is a shell function defined in ltmain.sh
168.3002 +  lt_cv_deplibs_check_method='file_magic ^x86 archive import|^x86 DLL'
168.3003 +  lt_cv_file_magic_cmd='func_win32_libid'
168.3004 +  ;;
168.3005 +
168.3006 +mingw* | pw32*)
168.3007 +  # Base MSYS/MinGW do not provide the 'file' command needed by
168.3008 +  # func_win32_libid shell function, so use a weaker test based on 'objdump',
168.3009 +  # unless we find 'file', for example because we are cross-compiling.
168.3010 +  # func_win32_libid assumes BSD nm, so disallow it if using MS dumpbin.
168.3011 +  if ( test "$lt_cv_nm_interface" = "BSD nm" && file / ) >/dev/null 2>&1; then
168.3012 +    lt_cv_deplibs_check_method='file_magic ^x86 archive import|^x86 DLL'
168.3013 +    lt_cv_file_magic_cmd='func_win32_libid'
168.3014 +  else
168.3015 +    lt_cv_deplibs_check_method='file_magic file format pei*-i386(.*architecture: i386)?'
168.3016 +    lt_cv_file_magic_cmd='$OBJDUMP -f'
168.3017 +  fi
168.3018 +  ;;
168.3019 +
168.3020 +cegcc*)
168.3021 +  # use the weaker test based on 'objdump'. See mingw*.
168.3022 +  lt_cv_deplibs_check_method='file_magic file format pe-arm-.*little(.*architecture: arm)?'
168.3023 +  lt_cv_file_magic_cmd='$OBJDUMP -f'
168.3024 +  ;;
168.3025 +
168.3026 +darwin* | rhapsody*)
168.3027 +  lt_cv_deplibs_check_method=pass_all
168.3028 +  ;;
168.3029 +
168.3030 +freebsd* | dragonfly*)
168.3031 +  if echo __ELF__ | $CC -E - | $GREP __ELF__ > /dev/null; then
168.3032 +    case $host_cpu in
168.3033 +    i*86 )
168.3034 +      # Not sure whether the presence of OpenBSD here was a mistake.
168.3035 +      # Let's accept both of them until this is cleared up.
168.3036 +      lt_cv_deplibs_check_method='file_magic (FreeBSD|OpenBSD|DragonFly)/i[[3-9]]86 (compact )?demand paged shared library'
168.3037 +      lt_cv_file_magic_cmd=/usr/bin/file
168.3038 +      lt_cv_file_magic_test_file=`echo /usr/lib/libc.so.*`
168.3039 +      ;;
168.3040 +    esac
168.3041 +  else
168.3042 +    lt_cv_deplibs_check_method=pass_all
168.3043 +  fi
168.3044 +  ;;
168.3045 +
168.3046 +gnu*)
168.3047 +  lt_cv_deplibs_check_method=pass_all
168.3048 +  ;;
168.3049 +
168.3050 +haiku*)
168.3051 +  lt_cv_deplibs_check_method=pass_all
168.3052 +  ;;
168.3053 +
168.3054 +hpux10.20* | hpux11*)
168.3055 +  lt_cv_file_magic_cmd=/usr/bin/file
168.3056 +  case $host_cpu in
168.3057 +  ia64*)
168.3058 +    lt_cv_deplibs_check_method='file_magic (s[[0-9]][[0-9]][[0-9]]|ELF-[[0-9]][[0-9]]) shared object file - IA64'
168.3059 +    lt_cv_file_magic_test_file=/usr/lib/hpux32/libc.so
168.3060 +    ;;
168.3061 +  hppa*64*)
168.3062 +    [lt_cv_deplibs_check_method='file_magic (s[0-9][0-9][0-9]|ELF[ -][0-9][0-9])(-bit)?( [LM]SB)? shared object( file)?[, -]* PA-RISC [0-9]\.[0-9]']
168.3063 +    lt_cv_file_magic_test_file=/usr/lib/pa20_64/libc.sl
168.3064 +    ;;
168.3065 +  *)
168.3066 +    lt_cv_deplibs_check_method='file_magic (s[[0-9]][[0-9]][[0-9]]|PA-RISC[[0-9]]\.[[0-9]]) shared library'
168.3067 +    lt_cv_file_magic_test_file=/usr/lib/libc.sl
168.3068 +    ;;
168.3069 +  esac
168.3070 +  ;;
168.3071 +
168.3072 +interix[[3-9]]*)
168.3073 +  # PIC code is broken on Interix 3.x, that's why |\.a not |_pic\.a here
168.3074 +  lt_cv_deplibs_check_method='match_pattern /lib[[^/]]+(\.so|\.a)$'
168.3075 +  ;;
168.3076 +
168.3077 +irix5* | irix6* | nonstopux*)
168.3078 +  case $LD in
168.3079 +  *-32|*"-32 ") libmagic=32-bit;;
168.3080 +  *-n32|*"-n32 ") libmagic=N32;;
168.3081 +  *-64|*"-64 ") libmagic=64-bit;;
168.3082 +  *) libmagic=never-match;;
168.3083 +  esac
168.3084 +  lt_cv_deplibs_check_method=pass_all
168.3085 +  ;;
168.3086 +
168.3087 +# This must be Linux ELF.
168.3088 +linux* | k*bsd*-gnu | kopensolaris*-gnu)
168.3089 +  lt_cv_deplibs_check_method=pass_all
168.3090 +  ;;
168.3091 +
168.3092 +netbsd*)
168.3093 +  if echo __ELF__ | $CC -E - | $GREP __ELF__ > /dev/null; then
168.3094 +    lt_cv_deplibs_check_method='match_pattern /lib[[^/]]+(\.so\.[[0-9]]+\.[[0-9]]+|_pic\.a)$'
168.3095 +  else
168.3096 +    lt_cv_deplibs_check_method='match_pattern /lib[[^/]]+(\.so|_pic\.a)$'
168.3097 +  fi
168.3098 +  ;;
168.3099 +
168.3100 +newos6*)
168.3101 +  lt_cv_deplibs_check_method='file_magic ELF [[0-9]][[0-9]]*-bit [[ML]]SB (executable|dynamic lib)'
168.3102 +  lt_cv_file_magic_cmd=/usr/bin/file
168.3103 +  lt_cv_file_magic_test_file=/usr/lib/libnls.so
168.3104 +  ;;
168.3105 +
168.3106 +*nto* | *qnx*)
168.3107 +  lt_cv_deplibs_check_method=pass_all
168.3108 +  ;;
168.3109 +
168.3110 +openbsd*)
168.3111 +  if test -z "`echo __ELF__ | $CC -E - | $GREP __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then
168.3112 +    lt_cv_deplibs_check_method='match_pattern /lib[[^/]]+(\.so\.[[0-9]]+\.[[0-9]]+|\.so|_pic\.a)$'
168.3113 +  else
168.3114 +    lt_cv_deplibs_check_method='match_pattern /lib[[^/]]+(\.so\.[[0-9]]+\.[[0-9]]+|_pic\.a)$'
168.3115 +  fi
168.3116 +  ;;
168.3117 +
168.3118 +osf3* | osf4* | osf5*)
168.3119 +  lt_cv_deplibs_check_method=pass_all
168.3120 +  ;;
168.3121 +
168.3122 +rdos*)
168.3123 +  lt_cv_deplibs_check_method=pass_all
168.3124 +  ;;
168.3125 +
168.3126 +solaris*)
168.3127 +  lt_cv_deplibs_check_method=pass_all
168.3128 +  ;;
168.3129 +
168.3130 +sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX* | sysv4*uw2*)
168.3131 +  lt_cv_deplibs_check_method=pass_all
168.3132 +  ;;
168.3133 +
168.3134 +sysv4 | sysv4.3*)
168.3135 +  case $host_vendor in
168.3136 +  motorola)
168.3137 +    lt_cv_deplibs_check_method='file_magic ELF [[0-9]][[0-9]]*-bit [[ML]]SB (shared object|dynamic lib) M[[0-9]][[0-9]]* Version [[0-9]]'
168.3138 +    lt_cv_file_magic_test_file=`echo /usr/lib/libc.so*`
168.3139 +    ;;
168.3140 +  ncr)
168.3141 +    lt_cv_deplibs_check_method=pass_all
168.3142 +    ;;
168.3143 +  sequent)
168.3144 +    lt_cv_file_magic_cmd='/bin/file'
168.3145 +    lt_cv_deplibs_check_method='file_magic ELF [[0-9]][[0-9]]*-bit [[LM]]SB (shared object|dynamic lib )'
168.3146 +    ;;
168.3147 +  sni)
168.3148 +    lt_cv_file_magic_cmd='/bin/file'
168.3149 +    lt_cv_deplibs_check_method="file_magic ELF [[0-9]][[0-9]]*-bit [[LM]]SB dynamic lib"
168.3150 +    lt_cv_file_magic_test_file=/lib/libc.so
168.3151 +    ;;
168.3152 +  siemens)
168.3153 +    lt_cv_deplibs_check_method=pass_all
168.3154 +    ;;
168.3155 +  pc)
168.3156 +    lt_cv_deplibs_check_method=pass_all
168.3157 +    ;;
168.3158 +  esac
168.3159 +  ;;
168.3160 +
168.3161 +tpf*)
168.3162 +  lt_cv_deplibs_check_method=pass_all
168.3163 +  ;;
168.3164 +esac
168.3165 +])
168.3166 +file_magic_cmd=$lt_cv_file_magic_cmd
168.3167 +deplibs_check_method=$lt_cv_deplibs_check_method
168.3168 +test -z "$deplibs_check_method" && deplibs_check_method=unknown
168.3169 +
168.3170 +_LT_DECL([], [deplibs_check_method], [1],
168.3171 +    [Method to check whether dependent libraries are shared objects])
168.3172 +_LT_DECL([], [file_magic_cmd], [1],
168.3173 +    [Command to use when deplibs_check_method == "file_magic"])
168.3174 +])# _LT_CHECK_MAGIC_METHOD
168.3175 +
168.3176 +
168.3177 +# LT_PATH_NM
168.3178 +# ----------
168.3179 +# find the pathname to a BSD- or MS-compatible name lister
168.3180 +AC_DEFUN([LT_PATH_NM],
168.3181 +[AC_REQUIRE([AC_PROG_CC])dnl
168.3182 +AC_CACHE_CHECK([for BSD- or MS-compatible name lister (nm)], lt_cv_path_NM,
168.3183 +[if test -n "$NM"; then
168.3184 +  # Let the user override the test.
168.3185 +  lt_cv_path_NM="$NM"
168.3186 +else
168.3187 +  lt_nm_to_check="${ac_tool_prefix}nm"
168.3188 +  if test -n "$ac_tool_prefix" && test "$build" = "$host"; then
168.3189 +    lt_nm_to_check="$lt_nm_to_check nm"
168.3190 +  fi
168.3191 +  for lt_tmp_nm in $lt_nm_to_check; do
168.3192 +    lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR
168.3193 +    for ac_dir in $PATH /usr/ccs/bin/elf /usr/ccs/bin /usr/ucb /bin; do
168.3194 +      IFS="$lt_save_ifs"
168.3195 +      test -z "$ac_dir" && ac_dir=.
168.3196 +      tmp_nm="$ac_dir/$lt_tmp_nm"
168.3197 +      if test -f "$tmp_nm" || test -f "$tmp_nm$ac_exeext" ; then
168.3198 +	# Check to see if the nm accepts a BSD-compat flag.
168.3199 +	# Adding the `sed 1q' prevents false positives on HP-UX, which says:
168.3200 +	#   nm: unknown option "B" ignored
168.3201 +	# Tru64's nm complains that /dev/null is an invalid object file
168.3202 +	case `"$tmp_nm" -B /dev/null 2>&1 | sed '1q'` in
168.3203 +	*/dev/null* | *'Invalid file or object type'*)
168.3204 +	  lt_cv_path_NM="$tmp_nm -B"
168.3205 +	  break
168.3206 +	  ;;
168.3207 +	*)
168.3208 +	  case `"$tmp_nm" -p /dev/null 2>&1 | sed '1q'` in
168.3209 +	  */dev/null*)
168.3210 +	    lt_cv_path_NM="$tmp_nm -p"
168.3211 +	    break
168.3212 +	    ;;
168.3213 +	  *)
168.3214 +	    lt_cv_path_NM=${lt_cv_path_NM="$tmp_nm"} # keep the first match, but
168.3215 +	    continue # so that we can try to find one that supports BSD flags
168.3216 +	    ;;
168.3217 +	  esac
168.3218 +	  ;;
168.3219 +	esac
168.3220 +      fi
168.3221 +    done
168.3222 +    IFS="$lt_save_ifs"
168.3223 +  done
168.3224 +  : ${lt_cv_path_NM=no}
168.3225 +fi])
168.3226 +if test "$lt_cv_path_NM" != "no"; then
168.3227 +  NM="$lt_cv_path_NM"
168.3228 +else
168.3229 +  # Didn't find any BSD compatible name lister, look for dumpbin.
168.3230 +  if test -n "$DUMPBIN"; then :
168.3231 +    # Let the user override the test.
168.3232 +  else
168.3233 +    AC_CHECK_TOOLS(DUMPBIN, [dumpbin "link -dump"], :)
168.3234 +    case `$DUMPBIN -symbols /dev/null 2>&1 | sed '1q'` in
168.3235 +    *COFF*)
168.3236 +      DUMPBIN="$DUMPBIN -symbols"
168.3237 +      ;;
168.3238 +    *)
168.3239 +      DUMPBIN=:
168.3240 +      ;;
168.3241 +    esac
168.3242 +  fi
168.3243 +  AC_SUBST([DUMPBIN])
168.3244 +  if test "$DUMPBIN" != ":"; then
168.3245 +    NM="$DUMPBIN"
168.3246 +  fi
168.3247 +fi
168.3248 +test -z "$NM" && NM=nm
168.3249 +AC_SUBST([NM])
168.3250 +_LT_DECL([], [NM], [1], [A BSD- or MS-compatible name lister])dnl
168.3251 +
168.3252 +AC_CACHE_CHECK([the name lister ($NM) interface], [lt_cv_nm_interface],
168.3253 +  [lt_cv_nm_interface="BSD nm"
168.3254 +  echo "int some_variable = 0;" > conftest.$ac_ext
168.3255 +  (eval echo "\"\$as_me:$LINENO: $ac_compile\"" >&AS_MESSAGE_LOG_FD)
168.3256 +  (eval "$ac_compile" 2>conftest.err)
168.3257 +  cat conftest.err >&AS_MESSAGE_LOG_FD
168.3258 +  (eval echo "\"\$as_me:$LINENO: $NM \\\"conftest.$ac_objext\\\"\"" >&AS_MESSAGE_LOG_FD)
168.3259 +  (eval "$NM \"conftest.$ac_objext\"" 2>conftest.err > conftest.out)
168.3260 +  cat conftest.err >&AS_MESSAGE_LOG_FD
168.3261 +  (eval echo "\"\$as_me:$LINENO: output\"" >&AS_MESSAGE_LOG_FD)
168.3262 +  cat conftest.out >&AS_MESSAGE_LOG_FD
168.3263 +  if $GREP 'External.*some_variable' conftest.out > /dev/null; then
168.3264 +    lt_cv_nm_interface="MS dumpbin"
168.3265 +  fi
168.3266 +  rm -f conftest*])
168.3267 +])# LT_PATH_NM
168.3268 +
168.3269 +# Old names:
168.3270 +AU_ALIAS([AM_PROG_NM], [LT_PATH_NM])
168.3271 +AU_ALIAS([AC_PROG_NM], [LT_PATH_NM])
168.3272 +dnl aclocal-1.4 backwards compatibility:
168.3273 +dnl AC_DEFUN([AM_PROG_NM], [])
168.3274 +dnl AC_DEFUN([AC_PROG_NM], [])
168.3275 +
168.3276 +# _LT_CHECK_SHAREDLIB_FROM_LINKLIB
168.3277 +# ----------------------
168.3278 +# how to determine the name of the shared library
168.3279 +# associated with a specific link library.
168.3280 +#  -- PORTME fill in with the dynamic library characteristics
168.3281 +m4_defun([_LT_CHECK_SHAREDLIB_FROM_LINKLIB],
168.3282 +[m4_require([_LT_DECL_EGREP])
168.3283 +m4_require([_LT_DECL_OBJDUMP])
168.3284 +m4_require([_LT_DECL_DLLTOOL])
168.3285 +AC_CACHE_CHECK([how to associate runtime and link libraries],
168.3286 +lt_cv_sharedlib_from_linklib_cmd,
168.3287 +[lt_cv_sharedlib_from_linklib_cmd='unknown'
168.3288 +
168.3289 +case $host_os in
168.3290 +cygwin* | mingw* | pw32* | cegcc*)
168.3291 +  # two different shell functions defined in ltmain.sh
168.3292 +  # decide which to use based on capabilities of $DLLTOOL
168.3293 +  case `$DLLTOOL --help 2>&1` in
168.3294 +  *--identify-strict*)
168.3295 +    lt_cv_sharedlib_from_linklib_cmd=func_cygming_dll_for_implib
168.3296 +    ;;
168.3297 +  *)
168.3298 +    lt_cv_sharedlib_from_linklib_cmd=func_cygming_dll_for_implib_fallback
168.3299 +    ;;
168.3300 +  esac
168.3301 +  ;;
168.3302 +*)
168.3303 +  # fallback: assume linklib IS sharedlib
168.3304 +  lt_cv_sharedlib_from_linklib_cmd="$ECHO"
168.3305 +  ;;
168.3306 +esac
168.3307 +])
168.3308 +sharedlib_from_linklib_cmd=$lt_cv_sharedlib_from_linklib_cmd
168.3309 +test -z "$sharedlib_from_linklib_cmd" && sharedlib_from_linklib_cmd=$ECHO
168.3310 +
168.3311 +_LT_DECL([], [sharedlib_from_linklib_cmd], [1],
168.3312 +    [Command to associate shared and link libraries])
168.3313 +])# _LT_CHECK_SHAREDLIB_FROM_LINKLIB
168.3314 +
168.3315 +
168.3316 +# LT_LIB_M
168.3317 +# --------
168.3318 +# check for math library
168.3319 +AC_DEFUN([LT_LIB_M],
168.3320 +[AC_REQUIRE([AC_CANONICAL_HOST])dnl
168.3321 +LIBM=
168.3322 +case $host in
168.3323 +*-*-beos* | *-*-cegcc* | *-*-cygwin* | *-*-haiku* | *-*-pw32* | *-*-darwin*)
168.3324 +  # These system don't have libm, or don't need it
168.3325 +  ;;
168.3326 +*-ncr-sysv4.3*)
168.3327 +  AC_CHECK_LIB(mw, _mwvalidcheckl, LIBM="-lmw")
168.3328 +  AC_CHECK_LIB(m, cos, LIBM="$LIBM -lm")
168.3329 +  ;;
168.3330 +*)
168.3331 +  AC_CHECK_LIB(m, cos, LIBM="-lm")
168.3332 +  ;;
168.3333 +esac
168.3334 +AC_SUBST([LIBM])
168.3335 +])# LT_LIB_M
168.3336 +
168.3337 +# Old name:
168.3338 +AU_ALIAS([AC_CHECK_LIBM], [LT_LIB_M])
168.3339 +dnl aclocal-1.4 backwards compatibility:
168.3340 +dnl AC_DEFUN([AC_CHECK_LIBM], [])
168.3341 +
168.3342 +
168.3343 +# _LT_COMPILER_NO_RTTI([TAGNAME])
168.3344 +# -------------------------------
168.3345 +m4_defun([_LT_COMPILER_NO_RTTI],
168.3346 +[m4_require([_LT_TAG_COMPILER])dnl
168.3347 +
168.3348 +_LT_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)=
168.3349 +
168.3350 +if test "$GCC" = yes; then
168.3351 +  case $cc_basename in
168.3352 +  nvcc*)
168.3353 +    _LT_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)=' -Xcompiler -fno-builtin' ;;
168.3354 +  *)
168.3355 +    _LT_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)=' -fno-builtin' ;;
168.3356 +  esac
168.3357 +
168.3358 +  _LT_COMPILER_OPTION([if $compiler supports -fno-rtti -fno-exceptions],
168.3359 +    lt_cv_prog_compiler_rtti_exceptions,
168.3360 +    [-fno-rtti -fno-exceptions], [],
168.3361 +    [_LT_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)="$_LT_TAGVAR(lt_prog_compiler_no_builtin_flag, $1) -fno-rtti -fno-exceptions"])
168.3362 +fi
168.3363 +_LT_TAGDECL([no_builtin_flag], [lt_prog_compiler_no_builtin_flag], [1],
168.3364 +	[Compiler flag to turn off builtin functions])
168.3365 +])# _LT_COMPILER_NO_RTTI
168.3366 +
168.3367 +
168.3368 +# _LT_CMD_GLOBAL_SYMBOLS
168.3369 +# ----------------------
168.3370 +m4_defun([_LT_CMD_GLOBAL_SYMBOLS],
168.3371 +[AC_REQUIRE([AC_CANONICAL_HOST])dnl
168.3372 +AC_REQUIRE([AC_PROG_CC])dnl
168.3373 +AC_REQUIRE([AC_PROG_AWK])dnl
168.3374 +AC_REQUIRE([LT_PATH_NM])dnl
168.3375 +AC_REQUIRE([LT_PATH_LD])dnl
168.3376 +m4_require([_LT_DECL_SED])dnl
168.3377 +m4_require([_LT_DECL_EGREP])dnl
168.3378 +m4_require([_LT_TAG_COMPILER])dnl
168.3379 +
168.3380 +# Check for command to grab the raw symbol name followed by C symbol from nm.
168.3381 +AC_MSG_CHECKING([command to parse $NM output from $compiler object])
168.3382 +AC_CACHE_VAL([lt_cv_sys_global_symbol_pipe],
168.3383 +[
168.3384 +# These are sane defaults that work on at least a few old systems.
168.3385 +# [They come from Ultrix.  What could be older than Ultrix?!! ;)]
168.3386 +
168.3387 +# Character class describing NM global symbol codes.
168.3388 +symcode='[[BCDEGRST]]'
168.3389 +
168.3390 +# Regexp to match symbols that can be accessed directly from C.
168.3391 +sympat='\([[_A-Za-z]][[_A-Za-z0-9]]*\)'
168.3392 +
168.3393 +# Define system-specific variables.
168.3394 +case $host_os in
168.3395 +aix*)
168.3396 +  symcode='[[BCDT]]'
168.3397 +  ;;
168.3398 +cygwin* | mingw* | pw32* | cegcc*)
168.3399 +  symcode='[[ABCDGISTW]]'
168.3400 +  ;;
168.3401 +hpux*)
168.3402 +  if test "$host_cpu" = ia64; then
168.3403 +    symcode='[[ABCDEGRST]]'
168.3404 +  fi
168.3405 +  ;;
168.3406 +irix* | nonstopux*)
168.3407 +  symcode='[[BCDEGRST]]'
168.3408 +  ;;
168.3409 +osf*)
168.3410 +  symcode='[[BCDEGQRST]]'
168.3411 +  ;;
168.3412 +solaris*)
168.3413 +  symcode='[[BDRT]]'
168.3414 +  ;;
168.3415 +sco3.2v5*)
168.3416 +  symcode='[[DT]]'
168.3417 +  ;;
168.3418 +sysv4.2uw2*)
168.3419 +  symcode='[[DT]]'
168.3420 +  ;;
168.3421 +sysv5* | sco5v6* | unixware* | OpenUNIX*)
168.3422 +  symcode='[[ABDT]]'
168.3423 +  ;;
168.3424 +sysv4)
168.3425 +  symcode='[[DFNSTU]]'
168.3426 +  ;;
168.3427 +esac
168.3428 +
168.3429 +# If we're using GNU nm, then use its standard symbol codes.
168.3430 +case `$NM -V 2>&1` in
168.3431 +*GNU* | *'with BFD'*)
168.3432 +  symcode='[[ABCDGIRSTW]]' ;;
168.3433 +esac
168.3434 +
168.3435 +# Transform an extracted symbol line into a proper C declaration.
168.3436 +# Some systems (esp. on ia64) link data and code symbols differently,
168.3437 +# so use this general approach.
168.3438 +lt_cv_sys_global_symbol_to_cdecl="sed -n -e 's/^T .* \(.*\)$/extern int \1();/p' -e 's/^$symcode* .* \(.*\)$/extern char \1;/p'"
168.3439 +
168.3440 +# Transform an extracted symbol line into symbol name and symbol address
168.3441 +lt_cv_sys_global_symbol_to_c_name_address="sed -n -e 's/^: \([[^ ]]*\)[[ ]]*$/  {\\\"\1\\\", (void *) 0},/p' -e 's/^$symcode* \([[^ ]]*\) \([[^ ]]*\)$/  {\"\2\", (void *) \&\2},/p'"
168.3442 +lt_cv_sys_global_symbol_to_c_name_address_lib_prefix="sed -n -e 's/^: \([[^ ]]*\)[[ ]]*$/  {\\\"\1\\\", (void *) 0},/p' -e 's/^$symcode* \([[^ ]]*\) \(lib[[^ ]]*\)$/  {\"\2\", (void *) \&\2},/p' -e 's/^$symcode* \([[^ ]]*\) \([[^ ]]*\)$/  {\"lib\2\", (void *) \&\2},/p'"
168.3443 +
168.3444 +# Handle CRLF in mingw tool chain
168.3445 +opt_cr=
168.3446 +case $build_os in
168.3447 +mingw*)
168.3448 +  opt_cr=`$ECHO 'x\{0,1\}' | tr x '\015'` # option cr in regexp
168.3449 +  ;;
168.3450 +esac
168.3451 +
168.3452 +# Try without a prefix underscore, then with it.
168.3453 +for ac_symprfx in "" "_"; do
168.3454 +
168.3455 +  # Transform symcode, sympat, and symprfx into a raw symbol and a C symbol.
168.3456 +  symxfrm="\\1 $ac_symprfx\\2 \\2"
168.3457 +
168.3458 +  # Write the raw and C identifiers.
168.3459 +  if test "$lt_cv_nm_interface" = "MS dumpbin"; then
168.3460 +    # Fake it for dumpbin and say T for any non-static function
168.3461 +    # and D for any global variable.
168.3462 +    # Also find C++ and __fastcall symbols from MSVC++,
168.3463 +    # which start with @ or ?.
168.3464 +    lt_cv_sys_global_symbol_pipe="$AWK ['"\
168.3465 +"     {last_section=section; section=\$ 3};"\
168.3466 +"     /Section length .*#relocs.*(pick any)/{hide[last_section]=1};"\
168.3467 +"     \$ 0!~/External *\|/{next};"\
168.3468 +"     / 0+ UNDEF /{next}; / UNDEF \([^|]\)*()/{next};"\
168.3469 +"     {if(hide[section]) next};"\
168.3470 +"     {f=0}; \$ 0~/\(\).*\|/{f=1}; {printf f ? \"T \" : \"D \"};"\
168.3471 +"     {split(\$ 0, a, /\||\r/); split(a[2], s)};"\
168.3472 +"     s[1]~/^[@?]/{print s[1], s[1]; next};"\
168.3473 +"     s[1]~prfx {split(s[1],t,\"@\"); print t[1], substr(t[1],length(prfx))}"\
168.3474 +"     ' prfx=^$ac_symprfx]"
168.3475 +  else
168.3476 +    lt_cv_sys_global_symbol_pipe="sed -n -e 's/^.*[[	 ]]\($symcode$symcode*\)[[	 ]][[	 ]]*$ac_symprfx$sympat$opt_cr$/$symxfrm/p'"
168.3477 +  fi
168.3478 +
168.3479 +  # Check to see that the pipe works correctly.
168.3480 +  pipe_works=no
168.3481 +
168.3482 +  rm -f conftest*
168.3483 +  cat > conftest.$ac_ext <<_LT_EOF
168.3484 +#ifdef __cplusplus
168.3485 +extern "C" {
168.3486 +#endif
168.3487 +char nm_test_var;
168.3488 +void nm_test_func(void);
168.3489 +void nm_test_func(void){}
168.3490 +#ifdef __cplusplus
168.3491 +}
168.3492 +#endif
168.3493 +int main(){nm_test_var='a';nm_test_func();return(0);}
168.3494 +_LT_EOF
168.3495 +
168.3496 +  if AC_TRY_EVAL(ac_compile); then
168.3497 +    # Now try to grab the symbols.
168.3498 +    nlist=conftest.nm
168.3499 +    if AC_TRY_EVAL(NM conftest.$ac_objext \| "$lt_cv_sys_global_symbol_pipe" \> $nlist) && test -s "$nlist"; then
168.3500 +      # Try sorting and uniquifying the output.
168.3501 +      if sort "$nlist" | uniq > "$nlist"T; then
168.3502 +	mv -f "$nlist"T "$nlist"
168.3503 +      else
168.3504 +	rm -f "$nlist"T
168.3505 +      fi
168.3506 +
168.3507 +      # Make sure that we snagged all the symbols we need.
168.3508 +      if $GREP ' nm_test_var$' "$nlist" >/dev/null; then
168.3509 +	if $GREP ' nm_test_func$' "$nlist" >/dev/null; then
168.3510 +	  cat <<_LT_EOF > conftest.$ac_ext
168.3511 +#ifdef __cplusplus
168.3512 +extern "C" {
168.3513 +#endif
168.3514 +
168.3515 +_LT_EOF
168.3516 +	  # Now generate the symbol file.
168.3517 +	  eval "$lt_cv_sys_global_symbol_to_cdecl"' < "$nlist" | $GREP -v main >> conftest.$ac_ext'
168.3518 +
168.3519 +	  cat <<_LT_EOF >> conftest.$ac_ext
168.3520 +
168.3521 +/* The mapping between symbol names and symbols.  */
168.3522 +const struct {
168.3523 +  const char *name;
168.3524 +  void       *address;
168.3525 +}
168.3526 +lt__PROGRAM__LTX_preloaded_symbols[[]] =
168.3527 +{
168.3528 +  { "@PROGRAM@", (void *) 0 },
168.3529 +_LT_EOF
168.3530 +	  $SED "s/^$symcode$symcode* \(.*\) \(.*\)$/  {\"\2\", (void *) \&\2},/" < "$nlist" | $GREP -v main >> conftest.$ac_ext
168.3531 +	  cat <<\_LT_EOF >> conftest.$ac_ext
168.3532 +  {0, (void *) 0}
168.3533 +};
168.3534 +
168.3535 +/* This works around a problem in FreeBSD linker */
168.3536 +#ifdef FREEBSD_WORKAROUND
168.3537 +static const void *lt_preloaded_setup() {
168.3538 +  return lt__PROGRAM__LTX_preloaded_symbols;
168.3539 +}
168.3540 +#endif
168.3541 +
168.3542 +#ifdef __cplusplus
168.3543 +}
168.3544 +#endif
168.3545 +_LT_EOF
168.3546 +	  # Now try linking the two files.
168.3547 +	  mv conftest.$ac_objext conftstm.$ac_objext
168.3548 +	  lt_save_LIBS="$LIBS"
168.3549 +	  lt_save_CFLAGS="$CFLAGS"
168.3550 +	  LIBS="conftstm.$ac_objext"
168.3551 +	  CFLAGS="$CFLAGS$_LT_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)"
168.3552 +	  if AC_TRY_EVAL(ac_link) && test -s conftest${ac_exeext}; then
168.3553 +	    pipe_works=yes
168.3554 +	  fi
168.3555 +	  LIBS="$lt_save_LIBS"
168.3556 +	  CFLAGS="$lt_save_CFLAGS"
168.3557 +	else
168.3558 +	  echo "cannot find nm_test_func in $nlist" >&AS_MESSAGE_LOG_FD
168.3559 +	fi
168.3560 +      else
168.3561 +	echo "cannot find nm_test_var in $nlist" >&AS_MESSAGE_LOG_FD
168.3562 +      fi
168.3563 +    else
168.3564 +      echo "cannot run $lt_cv_sys_global_symbol_pipe" >&AS_MESSAGE_LOG_FD
168.3565 +    fi
168.3566 +  else
168.3567 +    echo "$progname: failed program was:" >&AS_MESSAGE_LOG_FD
168.3568 +    cat conftest.$ac_ext >&5
168.3569 +  fi
168.3570 +  rm -rf conftest* conftst*
168.3571 +
168.3572 +  # Do not use the global_symbol_pipe unless it works.
168.3573 +  if test "$pipe_works" = yes; then
168.3574 +    break
168.3575 +  else
168.3576 +    lt_cv_sys_global_symbol_pipe=
168.3577 +  fi
168.3578 +done
168.3579 +])
168.3580 +if test -z "$lt_cv_sys_global_symbol_pipe"; then
168.3581 +  lt_cv_sys_global_symbol_to_cdecl=
168.3582 +fi
168.3583 +if test -z "$lt_cv_sys_global_symbol_pipe$lt_cv_sys_global_symbol_to_cdecl"; then
168.3584 +  AC_MSG_RESULT(failed)
168.3585 +else
168.3586 +  AC_MSG_RESULT(ok)
168.3587 +fi
168.3588 +
168.3589 +_LT_DECL([global_symbol_pipe], [lt_cv_sys_global_symbol_pipe], [1],
168.3590 +    [Take the output of nm and produce a listing of raw symbols and C names])
168.3591 +_LT_DECL([global_symbol_to_cdecl], [lt_cv_sys_global_symbol_to_cdecl], [1],
168.3592 +    [Transform the output of nm in a proper C declaration])
168.3593 +_LT_DECL([global_symbol_to_c_name_address],
168.3594 +    [lt_cv_sys_global_symbol_to_c_name_address], [1],
168.3595 +    [Transform the output of nm in a C name address pair])
168.3596 +_LT_DECL([global_symbol_to_c_name_address_lib_prefix],
168.3597 +    [lt_cv_sys_global_symbol_to_c_name_address_lib_prefix], [1],
168.3598 +    [Transform the output of nm in a C name address pair when lib prefix is needed])
168.3599 +]) # _LT_CMD_GLOBAL_SYMBOLS
168.3600 +
168.3601 +
168.3602 +# _LT_COMPILER_PIC([TAGNAME])
168.3603 +# ---------------------------
168.3604 +m4_defun([_LT_COMPILER_PIC],
168.3605 +[m4_require([_LT_TAG_COMPILER])dnl
168.3606 +_LT_TAGVAR(lt_prog_compiler_wl, $1)=
168.3607 +_LT_TAGVAR(lt_prog_compiler_pic, $1)=
168.3608 +_LT_TAGVAR(lt_prog_compiler_static, $1)=
168.3609 +
168.3610 +AC_MSG_CHECKING([for $compiler option to produce PIC])
168.3611 +m4_if([$1], [CXX], [
168.3612 +  # C++ specific cases for pic, static, wl, etc.
168.3613 +  if test "$GXX" = yes; then
168.3614 +    _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
168.3615 +    _LT_TAGVAR(lt_prog_compiler_static, $1)='-static'
168.3616 +
168.3617 +    case $host_os in
168.3618 +    aix*)
168.3619 +      # All AIX code is PIC.
168.3620 +      if test "$host_cpu" = ia64; then
168.3621 +	# AIX 5 now supports IA64 processor
168.3622 +	_LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
168.3623 +      fi
168.3624 +      ;;
168.3625 +
168.3626 +    amigaos*)
168.3627 +      case $host_cpu in
168.3628 +      powerpc)
168.3629 +            # see comment about AmigaOS4 .so support
168.3630 +            _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC'
168.3631 +        ;;
168.3632 +      m68k)
168.3633 +            # FIXME: we need at least 68020 code to build shared libraries, but
168.3634 +            # adding the `-m68020' flag to GCC prevents building anything better,
168.3635 +            # like `-m68040'.
168.3636 +            _LT_TAGVAR(lt_prog_compiler_pic, $1)='-m68020 -resident32 -malways-restore-a4'
168.3637 +        ;;
168.3638 +      esac
168.3639 +      ;;
168.3640 +
168.3641 +    beos* | irix5* | irix6* | nonstopux* | osf3* | osf4* | osf5*)
168.3642 +      # PIC is the default for these OSes.
168.3643 +      ;;
168.3644 +    mingw* | cygwin* | os2* | pw32* | cegcc*)
168.3645 +      # This hack is so that the source file can tell whether it is being
168.3646 +      # built for inclusion in a dll (and should export symbols for example).
168.3647 +      # Although the cygwin gcc ignores -fPIC, still need this for old-style
168.3648 +      # (--disable-auto-import) libraries
168.3649 +      m4_if([$1], [GCJ], [],
168.3650 +	[_LT_TAGVAR(lt_prog_compiler_pic, $1)='-DDLL_EXPORT'])
168.3651 +      ;;
168.3652 +    darwin* | rhapsody*)
168.3653 +      # PIC is the default on this platform
168.3654 +      # Common symbols not allowed in MH_DYLIB files
168.3655 +      _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fno-common'
168.3656 +      ;;
168.3657 +    *djgpp*)
168.3658 +      # DJGPP does not support shared libraries at all
168.3659 +      _LT_TAGVAR(lt_prog_compiler_pic, $1)=
168.3660 +      ;;
168.3661 +    haiku*)
168.3662 +      # PIC is the default for Haiku.
168.3663 +      # The "-static" flag exists, but is broken.
168.3664 +      _LT_TAGVAR(lt_prog_compiler_static, $1)=
168.3665 +      ;;
168.3666 +    interix[[3-9]]*)
168.3667 +      # Interix 3.x gcc -fpic/-fPIC options generate broken code.
168.3668 +      # Instead, we relocate shared libraries at runtime.
168.3669 +      ;;
168.3670 +    sysv4*MP*)
168.3671 +      if test -d /usr/nec; then
168.3672 +	_LT_TAGVAR(lt_prog_compiler_pic, $1)=-Kconform_pic
168.3673 +      fi
168.3674 +      ;;
168.3675 +    hpux*)
168.3676 +      # PIC is the default for 64-bit PA HP-UX, but not for 32-bit
168.3677 +      # PA HP-UX.  On IA64 HP-UX, PIC is the default but the pic flag
168.3678 +      # sets the default TLS model and affects inlining.
168.3679 +      case $host_cpu in
168.3680 +      hppa*64*)
168.3681 +	;;
168.3682 +      *)
168.3683 +	_LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC'
168.3684 +	;;
168.3685 +      esac
168.3686 +      ;;
168.3687 +    *qnx* | *nto*)
168.3688 +      # QNX uses GNU C++, but need to define -shared option too, otherwise
168.3689 +      # it will coredump.
168.3690 +      _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC -shared'
168.3691 +      ;;
168.3692 +    *)
168.3693 +      _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC'
168.3694 +      ;;
168.3695 +    esac
168.3696 +  else
168.3697 +    case $host_os in
168.3698 +      aix[[4-9]]*)
168.3699 +	# All AIX code is PIC.
168.3700 +	if test "$host_cpu" = ia64; then
168.3701 +	  # AIX 5 now supports IA64 processor
168.3702 +	  _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
168.3703 +	else
168.3704 +	  _LT_TAGVAR(lt_prog_compiler_static, $1)='-bnso -bI:/lib/syscalls.exp'
168.3705 +	fi
168.3706 +	;;
168.3707 +      chorus*)
168.3708 +	case $cc_basename in
168.3709 +	cxch68*)
168.3710 +	  # Green Hills C++ Compiler
168.3711 +	  # _LT_TAGVAR(lt_prog_compiler_static, $1)="--no_auto_instantiation -u __main -u __premain -u _abort -r $COOL_DIR/lib/libOrb.a $MVME_DIR/lib/CC/libC.a $MVME_DIR/lib/classix/libcx.s.a"
168.3712 +	  ;;
168.3713 +	esac
168.3714 +	;;
168.3715 +      dgux*)
168.3716 +	case $cc_basename in
168.3717 +	  ec++*)
168.3718 +	    _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC'
168.3719 +	    ;;
168.3720 +	  ghcx*)
168.3721 +	    # Green Hills C++ Compiler
168.3722 +	    _LT_TAGVAR(lt_prog_compiler_pic, $1)='-pic'
168.3723 +	    ;;
168.3724 +	  *)
168.3725 +	    ;;
168.3726 +	esac
168.3727 +	;;
168.3728 +      freebsd* | dragonfly*)
168.3729 +	# FreeBSD uses GNU C++
168.3730 +	;;
168.3731 +      hpux9* | hpux10* | hpux11*)
168.3732 +	case $cc_basename in
168.3733 +	  CC*)
168.3734 +	    _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
168.3735 +	    _LT_TAGVAR(lt_prog_compiler_static, $1)='${wl}-a ${wl}archive'
168.3736 +	    if test "$host_cpu" != ia64; then
168.3737 +	      _LT_TAGVAR(lt_prog_compiler_pic, $1)='+Z'
168.3738 +	    fi
168.3739 +	    ;;
168.3740 +	  aCC*)
168.3741 +	    _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
168.3742 +	    _LT_TAGVAR(lt_prog_compiler_static, $1)='${wl}-a ${wl}archive'
168.3743 +	    case $host_cpu in
168.3744 +	    hppa*64*|ia64*)
168.3745 +	      # +Z the default
168.3746 +	      ;;
168.3747 +	    *)
168.3748 +	      _LT_TAGVAR(lt_prog_compiler_pic, $1)='+Z'
168.3749 +	      ;;
168.3750 +	    esac
168.3751 +	    ;;
168.3752 +	  *)
168.3753 +	    ;;
168.3754 +	esac
168.3755 +	;;
168.3756 +      interix*)
168.3757 +	# This is c89, which is MS Visual C++ (no shared libs)
168.3758 +	# Anyone wants to do a port?
168.3759 +	;;
168.3760 +      irix5* | irix6* | nonstopux*)
168.3761 +	case $cc_basename in
168.3762 +	  CC*)
168.3763 +	    _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
168.3764 +	    _LT_TAGVAR(lt_prog_compiler_static, $1)='-non_shared'
168.3765 +	    # CC pic flag -KPIC is the default.
168.3766 +	    ;;
168.3767 +	  *)
168.3768 +	    ;;
168.3769 +	esac
168.3770 +	;;
168.3771 +      linux* | k*bsd*-gnu | kopensolaris*-gnu)
168.3772 +	case $cc_basename in
168.3773 +	  KCC*)
168.3774 +	    # KAI C++ Compiler
168.3775 +	    _LT_TAGVAR(lt_prog_compiler_wl, $1)='--backend -Wl,'
168.3776 +	    _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC'
168.3777 +	    ;;
168.3778 +	  ecpc* )
168.3779 +	    # old Intel C++ for x86_64 which still supported -KPIC.
168.3780 +	    _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
168.3781 +	    _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC'
168.3782 +	    _LT_TAGVAR(lt_prog_compiler_static, $1)='-static'
168.3783 +	    ;;
168.3784 +	  icpc* )
168.3785 +	    # Intel C++, used to be incompatible with GCC.
168.3786 +	    # ICC 10 doesn't accept -KPIC any more.
168.3787 +	    _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
168.3788 +	    _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC'
168.3789 +	    _LT_TAGVAR(lt_prog_compiler_static, $1)='-static'
168.3790 +	    ;;
168.3791 +	  pgCC* | pgcpp*)
168.3792 +	    # Portland Group C++ compiler
168.3793 +	    _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
168.3794 +	    _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fpic'
168.3795 +	    _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
168.3796 +	    ;;
168.3797 +	  cxx*)
168.3798 +	    # Compaq C++
168.3799 +	    # Make sure the PIC flag is empty.  It appears that all Alpha
168.3800 +	    # Linux and Compaq Tru64 Unix objects are PIC.
168.3801 +	    _LT_TAGVAR(lt_prog_compiler_pic, $1)=
168.3802 +	    _LT_TAGVAR(lt_prog_compiler_static, $1)='-non_shared'
168.3803 +	    ;;
168.3804 +	  xlc* | xlC* | bgxl[[cC]]* | mpixl[[cC]]*)
168.3805 +	    # IBM XL 8.0, 9.0 on PPC and BlueGene
168.3806 +	    _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
168.3807 +	    _LT_TAGVAR(lt_prog_compiler_pic, $1)='-qpic'
168.3808 +	    _LT_TAGVAR(lt_prog_compiler_static, $1)='-qstaticlink'
168.3809 +	    ;;
168.3810 +	  *)
168.3811 +	    case `$CC -V 2>&1 | sed 5q` in
168.3812 +	    *Sun\ C*)
168.3813 +	      # Sun C++ 5.9
168.3814 +	      _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC'
168.3815 +	      _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
168.3816 +	      _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Qoption ld '
168.3817 +	      ;;
168.3818 +	    esac
168.3819 +	    ;;
168.3820 +	esac
168.3821 +	;;
168.3822 +      lynxos*)
168.3823 +	;;
168.3824 +      m88k*)
168.3825 +	;;
168.3826 +      mvs*)
168.3827 +	case $cc_basename in
168.3828 +	  cxx*)
168.3829 +	    _LT_TAGVAR(lt_prog_compiler_pic, $1)='-W c,exportall'
168.3830 +	    ;;
168.3831 +	  *)
168.3832 +	    ;;
168.3833 +	esac
168.3834 +	;;
168.3835 +      netbsd*)
168.3836 +	;;
168.3837 +      *qnx* | *nto*)
168.3838 +        # QNX uses GNU C++, but need to define -shared option too, otherwise
168.3839 +        # it will coredump.
168.3840 +        _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC -shared'
168.3841 +        ;;
168.3842 +      osf3* | osf4* | osf5*)
168.3843 +	case $cc_basename in
168.3844 +	  KCC*)
168.3845 +	    _LT_TAGVAR(lt_prog_compiler_wl, $1)='--backend -Wl,'
168.3846 +	    ;;
168.3847 +	  RCC*)
168.3848 +	    # Rational C++ 2.4.1
168.3849 +	    _LT_TAGVAR(lt_prog_compiler_pic, $1)='-pic'
168.3850 +	    ;;
168.3851 +	  cxx*)
168.3852 +	    # Digital/Compaq C++
168.3853 +	    _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
168.3854 +	    # Make sure the PIC flag is empty.  It appears that all Alpha
168.3855 +	    # Linux and Compaq Tru64 Unix objects are PIC.
168.3856 +	    _LT_TAGVAR(lt_prog_compiler_pic, $1)=
168.3857 +	    _LT_TAGVAR(lt_prog_compiler_static, $1)='-non_shared'
168.3858 +	    ;;
168.3859 +	  *)
168.3860 +	    ;;
168.3861 +	esac
168.3862 +	;;
168.3863 +      psos*)
168.3864 +	;;
168.3865 +      solaris*)
168.3866 +	case $cc_basename in
168.3867 +	  CC*)
168.3868 +	    # Sun C++ 4.2, 5.x and Centerline C++
168.3869 +	    _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC'
168.3870 +	    _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
168.3871 +	    _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Qoption ld '
168.3872 +	    ;;
168.3873 +	  gcx*)
168.3874 +	    # Green Hills C++ Compiler
168.3875 +	    _LT_TAGVAR(lt_prog_compiler_pic, $1)='-PIC'
168.3876 +	    ;;
168.3877 +	  *)
168.3878 +	    ;;
168.3879 +	esac
168.3880 +	;;
168.3881 +      sunos4*)
168.3882 +	case $cc_basename in
168.3883 +	  CC*)
168.3884 +	    # Sun C++ 4.x
168.3885 +	    _LT_TAGVAR(lt_prog_compiler_pic, $1)='-pic'
168.3886 +	    _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
168.3887 +	    ;;
168.3888 +	  lcc*)
168.3889 +	    # Lucid
168.3890 +	    _LT_TAGVAR(lt_prog_compiler_pic, $1)='-pic'
168.3891 +	    ;;
168.3892 +	  *)
168.3893 +	    ;;
168.3894 +	esac
168.3895 +	;;
168.3896 +      sysv5* | unixware* | sco3.2v5* | sco5v6* | OpenUNIX*)
168.3897 +	case $cc_basename in
168.3898 +	  CC*)
168.3899 +	    _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
168.3900 +	    _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC'
168.3901 +	    _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
168.3902 +	    ;;
168.3903 +	esac
168.3904 +	;;
168.3905 +      tandem*)
168.3906 +	case $cc_basename in
168.3907 +	  NCC*)
168.3908 +	    # NonStop-UX NCC 3.20
168.3909 +	    _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC'
168.3910 +	    ;;
168.3911 +	  *)
168.3912 +	    ;;
168.3913 +	esac
168.3914 +	;;
168.3915 +      vxworks*)
168.3916 +	;;
168.3917 +      *)
168.3918 +	_LT_TAGVAR(lt_prog_compiler_can_build_shared, $1)=no
168.3919 +	;;
168.3920 +    esac
168.3921 +  fi
168.3922 +],
168.3923 +[
168.3924 +  if test "$GCC" = yes; then
168.3925 +    _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
168.3926 +    _LT_TAGVAR(lt_prog_compiler_static, $1)='-static'
168.3927 +
168.3928 +    case $host_os in
168.3929 +      aix*)
168.3930 +      # All AIX code is PIC.
168.3931 +      if test "$host_cpu" = ia64; then
168.3932 +	# AIX 5 now supports IA64 processor
168.3933 +	_LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
168.3934 +      fi
168.3935 +      ;;
168.3936 +
168.3937 +    amigaos*)
168.3938 +      case $host_cpu in
168.3939 +      powerpc)
168.3940 +            # see comment about AmigaOS4 .so support
168.3941 +            _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC'
168.3942 +        ;;
168.3943 +      m68k)
168.3944 +            # FIXME: we need at least 68020 code to build shared libraries, but
168.3945 +            # adding the `-m68020' flag to GCC prevents building anything better,
168.3946 +            # like `-m68040'.
168.3947 +            _LT_TAGVAR(lt_prog_compiler_pic, $1)='-m68020 -resident32 -malways-restore-a4'
168.3948 +        ;;
168.3949 +      esac
168.3950 +      ;;
168.3951 +
168.3952 +    beos* | irix5* | irix6* | nonstopux* | osf3* | osf4* | osf5*)
168.3953 +      # PIC is the default for these OSes.
168.3954 +      ;;
168.3955 +
168.3956 +    mingw* | cygwin* | pw32* | os2* | cegcc*)
168.3957 +      # This hack is so that the source file can tell whether it is being
168.3958 +      # built for inclusion in a dll (and should export symbols for example).
168.3959 +      # Although the cygwin gcc ignores -fPIC, still need this for old-style
168.3960 +      # (--disable-auto-import) libraries
168.3961 +      m4_if([$1], [GCJ], [],
168.3962 +	[_LT_TAGVAR(lt_prog_compiler_pic, $1)='-DDLL_EXPORT'])
168.3963 +      ;;
168.3964 +
168.3965 +    darwin* | rhapsody*)
168.3966 +      # PIC is the default on this platform
168.3967 +      # Common symbols not allowed in MH_DYLIB files
168.3968 +      _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fno-common'
168.3969 +      ;;
168.3970 +
168.3971 +    haiku*)
168.3972 +      # PIC is the default for Haiku.
168.3973 +      # The "-static" flag exists, but is broken.
168.3974 +      _LT_TAGVAR(lt_prog_compiler_static, $1)=
168.3975 +      ;;
168.3976 +
168.3977 +    hpux*)
168.3978 +      # PIC is the default for 64-bit PA HP-UX, but not for 32-bit
168.3979 +      # PA HP-UX.  On IA64 HP-UX, PIC is the default but the pic flag
168.3980 +      # sets the default TLS model and affects inlining.
168.3981 +      case $host_cpu in
168.3982 +      hppa*64*)
168.3983 +	# +Z the default
168.3984 +	;;
168.3985 +      *)
168.3986 +	_LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC'
168.3987 +	;;
168.3988 +      esac
168.3989 +      ;;
168.3990 +
168.3991 +    interix[[3-9]]*)
168.3992 +      # Interix 3.x gcc -fpic/-fPIC options generate broken code.
168.3993 +      # Instead, we relocate shared libraries at runtime.
168.3994 +      ;;
168.3995 +
168.3996 +    msdosdjgpp*)
168.3997 +      # Just because we use GCC doesn't mean we suddenly get shared libraries
168.3998 +      # on systems that don't support them.
168.3999 +      _LT_TAGVAR(lt_prog_compiler_can_build_shared, $1)=no
168.4000 +      enable_shared=no
168.4001 +      ;;
168.4002 +
168.4003 +    *nto* | *qnx*)
168.4004 +      # QNX uses GNU C++, but need to define -shared option too, otherwise
168.4005 +      # it will coredump.
168.4006 +      _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC -shared'
168.4007 +      ;;
168.4008 +
168.4009 +    sysv4*MP*)
168.4010 +      if test -d /usr/nec; then
168.4011 +	_LT_TAGVAR(lt_prog_compiler_pic, $1)=-Kconform_pic
168.4012 +      fi
168.4013 +      ;;
168.4014 +
168.4015 +    *)
168.4016 +      _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC'
168.4017 +      ;;
168.4018 +    esac
168.4019 +
168.4020 +    case $cc_basename in
168.4021 +    nvcc*) # Cuda Compiler Driver 2.2
168.4022 +      _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Xlinker '
168.4023 +      _LT_TAGVAR(lt_prog_compiler_pic, $1)='-Xcompiler -fPIC'
168.4024 +      ;;
168.4025 +    esac
168.4026 +  else
168.4027 +    # PORTME Check for flag to pass linker flags through the system compiler.
168.4028 +    case $host_os in
168.4029 +    aix*)
168.4030 +      _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
168.4031 +      if test "$host_cpu" = ia64; then
168.4032 +	# AIX 5 now supports IA64 processor
168.4033 +	_LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
168.4034 +      else
168.4035 +	_LT_TAGVAR(lt_prog_compiler_static, $1)='-bnso -bI:/lib/syscalls.exp'
168.4036 +      fi
168.4037 +      ;;
168.4038 +
168.4039 +    mingw* | cygwin* | pw32* | os2* | cegcc*)
168.4040 +      # This hack is so that the source file can tell whether it is being
168.4041 +      # built for inclusion in a dll (and should export symbols for example).
168.4042 +      m4_if([$1], [GCJ], [],
168.4043 +	[_LT_TAGVAR(lt_prog_compiler_pic, $1)='-DDLL_EXPORT'])
168.4044 +      ;;
168.4045 +
168.4046 +    hpux9* | hpux10* | hpux11*)
168.4047 +      _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
168.4048 +      # PIC is the default for IA64 HP-UX and 64-bit HP-UX, but
168.4049 +      # not for PA HP-UX.
168.4050 +      case $host_cpu in
168.4051 +      hppa*64*|ia64*)
168.4052 +	# +Z the default
168.4053 +	;;
168.4054 +      *)
168.4055 +	_LT_TAGVAR(lt_prog_compiler_pic, $1)='+Z'
168.4056 +	;;
168.4057 +      esac
168.4058 +      # Is there a better lt_prog_compiler_static that works with the bundled CC?
168.4059 +      _LT_TAGVAR(lt_prog_compiler_static, $1)='${wl}-a ${wl}archive'
168.4060 +      ;;
168.4061 +
168.4062 +    irix5* | irix6* | nonstopux*)
168.4063 +      _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
168.4064 +      # PIC (with -KPIC) is the default.
168.4065 +      _LT_TAGVAR(lt_prog_compiler_static, $1)='-non_shared'
168.4066 +      ;;
168.4067 +
168.4068 +    linux* | k*bsd*-gnu | kopensolaris*-gnu)
168.4069 +      case $cc_basename in
168.4070 +      # old Intel for x86_64 which still supported -KPIC.
168.4071 +      ecc*)
168.4072 +	_LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
168.4073 +	_LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC'
168.4074 +	_LT_TAGVAR(lt_prog_compiler_static, $1)='-static'
168.4075 +        ;;
168.4076 +      # icc used to be incompatible with GCC.
168.4077 +      # ICC 10 doesn't accept -KPIC any more.
168.4078 +      icc* | ifort*)
168.4079 +	_LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
168.4080 +	_LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC'
168.4081 +	_LT_TAGVAR(lt_prog_compiler_static, $1)='-static'
168.4082 +        ;;
168.4083 +      # Lahey Fortran 8.1.
168.4084 +      lf95*)
168.4085 +	_LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
168.4086 +	_LT_TAGVAR(lt_prog_compiler_pic, $1)='--shared'
168.4087 +	_LT_TAGVAR(lt_prog_compiler_static, $1)='--static'
168.4088 +	;;
168.4089 +      pgcc* | pgf77* | pgf90* | pgf95* | pgfortran*)
168.4090 +        # Portland Group compilers (*not* the Pentium gcc compiler,
168.4091 +	# which looks to be a dead project)
168.4092 +	_LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
168.4093 +	_LT_TAGVAR(lt_prog_compiler_pic, $1)='-fpic'
168.4094 +	_LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
168.4095 +        ;;
168.4096 +      ccc*)
168.4097 +        _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
168.4098 +        # All Alpha code is PIC.
168.4099 +        _LT_TAGVAR(lt_prog_compiler_static, $1)='-non_shared'
168.4100 +        ;;
168.4101 +      xl* | bgxl* | bgf* | mpixl*)
168.4102 +	# IBM XL C 8.0/Fortran 10.1, 11.1 on PPC and BlueGene
168.4103 +	_LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
168.4104 +	_LT_TAGVAR(lt_prog_compiler_pic, $1)='-qpic'
168.4105 +	_LT_TAGVAR(lt_prog_compiler_static, $1)='-qstaticlink'
168.4106 +	;;
168.4107 +      *)
168.4108 +	case `$CC -V 2>&1 | sed 5q` in
168.4109 +	*Sun\ F* | *Sun*Fortran*)
168.4110 +	  # Sun Fortran 8.3 passes all unrecognized flags to the linker
168.4111 +	  _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC'
168.4112 +	  _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
168.4113 +	  _LT_TAGVAR(lt_prog_compiler_wl, $1)=''
168.4114 +	  ;;
168.4115 +	*Sun\ C*)
168.4116 +	  # Sun C 5.9
168.4117 +	  _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC'
168.4118 +	  _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
168.4119 +	  _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
168.4120 +	  ;;
168.4121 +	esac
168.4122 +	;;
168.4123 +      esac
168.4124 +      ;;
168.4125 +
168.4126 +    newsos6)
168.4127 +      _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC'
168.4128 +      _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
168.4129 +      ;;
168.4130 +
168.4131 +    *nto* | *qnx*)
168.4132 +      # QNX uses GNU C++, but need to define -shared option too, otherwise
168.4133 +      # it will coredump.
168.4134 +      _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC -shared'
168.4135 +      ;;
168.4136 +
168.4137 +    osf3* | osf4* | osf5*)
168.4138 +      _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
168.4139 +      # All OSF/1 code is PIC.
168.4140 +      _LT_TAGVAR(lt_prog_compiler_static, $1)='-non_shared'
168.4141 +      ;;
168.4142 +
168.4143 +    rdos*)
168.4144 +      _LT_TAGVAR(lt_prog_compiler_static, $1)='-non_shared'
168.4145 +      ;;
168.4146 +
168.4147 +    solaris*)
168.4148 +      _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC'
168.4149 +      _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
168.4150 +      case $cc_basename in
168.4151 +      f77* | f90* | f95*)
168.4152 +	_LT_TAGVAR(lt_prog_compiler_wl, $1)='-Qoption ld ';;
168.4153 +      *)
168.4154 +	_LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,';;
168.4155 +      esac
168.4156 +      ;;
168.4157 +
168.4158 +    sunos4*)
168.4159 +      _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Qoption ld '
168.4160 +      _LT_TAGVAR(lt_prog_compiler_pic, $1)='-PIC'
168.4161 +      _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
168.4162 +      ;;
168.4163 +
168.4164 +    sysv4 | sysv4.2uw2* | sysv4.3*)
168.4165 +      _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
168.4166 +      _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC'
168.4167 +      _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
168.4168 +      ;;
168.4169 +
168.4170 +    sysv4*MP*)
168.4171 +      if test -d /usr/nec ;then
168.4172 +	_LT_TAGVAR(lt_prog_compiler_pic, $1)='-Kconform_pic'
168.4173 +	_LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
168.4174 +      fi
168.4175 +      ;;
168.4176 +
168.4177 +    sysv5* | unixware* | sco3.2v5* | sco5v6* | OpenUNIX*)
168.4178 +      _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
168.4179 +      _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC'
168.4180 +      _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
168.4181 +      ;;
168.4182 +
168.4183 +    unicos*)
168.4184 +      _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
168.4185 +      _LT_TAGVAR(lt_prog_compiler_can_build_shared, $1)=no
168.4186 +      ;;
168.4187 +
168.4188 +    uts4*)
168.4189 +      _LT_TAGVAR(lt_prog_compiler_pic, $1)='-pic'
168.4190 +      _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
168.4191 +      ;;
168.4192 +
168.4193 +    *)
168.4194 +      _LT_TAGVAR(lt_prog_compiler_can_build_shared, $1)=no
168.4195 +      ;;
168.4196 +    esac
168.4197 +  fi
168.4198 +])
168.4199 +case $host_os in
168.4200 +  # For platforms which do not support PIC, -DPIC is meaningless:
168.4201 +  *djgpp*)
168.4202 +    _LT_TAGVAR(lt_prog_compiler_pic, $1)=
168.4203 +    ;;
168.4204 +  *)
168.4205 +    _LT_TAGVAR(lt_prog_compiler_pic, $1)="$_LT_TAGVAR(lt_prog_compiler_pic, $1)@&t@m4_if([$1],[],[ -DPIC],[m4_if([$1],[CXX],[ -DPIC],[])])"
168.4206 +    ;;
168.4207 +esac
168.4208 +AC_MSG_RESULT([$_LT_TAGVAR(lt_prog_compiler_pic, $1)])
168.4209 +_LT_TAGDECL([wl], [lt_prog_compiler_wl], [1],
168.4210 +	[How to pass a linker flag through the compiler])
168.4211 +
168.4212 +#
168.4213 +# Check to make sure the PIC flag actually works.
168.4214 +#
168.4215 +if test -n "$_LT_TAGVAR(lt_prog_compiler_pic, $1)"; then
168.4216 +  _LT_COMPILER_OPTION([if $compiler PIC flag $_LT_TAGVAR(lt_prog_compiler_pic, $1) works],
168.4217 +    [_LT_TAGVAR(lt_cv_prog_compiler_pic_works, $1)],
168.4218 +    [$_LT_TAGVAR(lt_prog_compiler_pic, $1)@&t@m4_if([$1],[],[ -DPIC],[m4_if([$1],[CXX],[ -DPIC],[])])], [],
168.4219 +    [case $_LT_TAGVAR(lt_prog_compiler_pic, $1) in
168.4220 +     "" | " "*) ;;
168.4221 +     *) _LT_TAGVAR(lt_prog_compiler_pic, $1)=" $_LT_TAGVAR(lt_prog_compiler_pic, $1)" ;;
168.4222 +     esac],
168.4223 +    [_LT_TAGVAR(lt_prog_compiler_pic, $1)=
168.4224 +     _LT_TAGVAR(lt_prog_compiler_can_build_shared, $1)=no])
168.4225 +fi
168.4226 +_LT_TAGDECL([pic_flag], [lt_prog_compiler_pic], [1],
168.4227 +	[Additional compiler flags for building library objects])
168.4228 +
168.4229 +#
168.4230 +# Check to make sure the static flag actually works.
168.4231 +#
168.4232 +wl=$_LT_TAGVAR(lt_prog_compiler_wl, $1) eval lt_tmp_static_flag=\"$_LT_TAGVAR(lt_prog_compiler_static, $1)\"
168.4233 +_LT_LINKER_OPTION([if $compiler static flag $lt_tmp_static_flag works],
168.4234 +  _LT_TAGVAR(lt_cv_prog_compiler_static_works, $1),
168.4235 +  $lt_tmp_static_flag,
168.4236 +  [],
168.4237 +  [_LT_TAGVAR(lt_prog_compiler_static, $1)=])
168.4238 +_LT_TAGDECL([link_static_flag], [lt_prog_compiler_static], [1],
168.4239 +	[Compiler flag to prevent dynamic linking])
168.4240 +])# _LT_COMPILER_PIC
168.4241 +
168.4242 +
168.4243 +# _LT_LINKER_SHLIBS([TAGNAME])
168.4244 +# ----------------------------
168.4245 +# See if the linker supports building shared libraries.
168.4246 +m4_defun([_LT_LINKER_SHLIBS],
168.4247 +[AC_REQUIRE([LT_PATH_LD])dnl
168.4248 +AC_REQUIRE([LT_PATH_NM])dnl
168.4249 +m4_require([_LT_FILEUTILS_DEFAULTS])dnl
168.4250 +m4_require([_LT_DECL_EGREP])dnl
168.4251 +m4_require([_LT_DECL_SED])dnl
168.4252 +m4_require([_LT_CMD_GLOBAL_SYMBOLS])dnl
168.4253 +m4_require([_LT_TAG_COMPILER])dnl
168.4254 +AC_MSG_CHECKING([whether the $compiler linker ($LD) supports shared libraries])
168.4255 +m4_if([$1], [CXX], [
168.4256 +  _LT_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED '\''s/.* //'\'' | sort | uniq > $export_symbols'
168.4257 +  _LT_TAGVAR(exclude_expsyms, $1)=['_GLOBAL_OFFSET_TABLE_|_GLOBAL__F[ID]_.*']
168.4258 +  case $host_os in
168.4259 +  aix[[4-9]]*)
168.4260 +    # If we're using GNU nm, then we don't want the "-C" option.
168.4261 +    # -C means demangle to AIX nm, but means don't demangle with GNU nm
168.4262 +    # Also, AIX nm treats weak defined symbols like other global defined
168.4263 +    # symbols, whereas GNU nm marks them as "W".
168.4264 +    if $NM -V 2>&1 | $GREP 'GNU' > /dev/null; then
168.4265 +      _LT_TAGVAR(export_symbols_cmds, $1)='$NM -Bpg $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B") || (\$ 2 == "W")) && ([substr](\$ 3,1,1) != ".")) { print \$ 3 } }'\'' | sort -u > $export_symbols'
168.4266 +    else
168.4267 +      _LT_TAGVAR(export_symbols_cmds, $1)='$NM -BCpg $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B")) && ([substr](\$ 3,1,1) != ".")) { print \$ 3 } }'\'' | sort -u > $export_symbols'
168.4268 +    fi
168.4269 +    ;;
168.4270 +  pw32*)
168.4271 +    _LT_TAGVAR(export_symbols_cmds, $1)="$ltdll_cmds"
168.4272 +  ;;
168.4273 +  cygwin* | mingw* | cegcc*)
168.4274 +    _LT_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED -e '\''/^[[BCDGRS]][[ ]]/s/.*[[ ]]\([[^ ]]*\)/\1 DATA/;s/^.*[[ ]]__nm__\([[^ ]]*\)[[ ]][[^ ]]*/\1 DATA/;/^I[[ ]]/d;/^[[AITW]][[ ]]/s/.* //'\'' | sort | uniq > $export_symbols'
168.4275 +    _LT_TAGVAR(exclude_expsyms, $1)=['[_]+GLOBAL_OFFSET_TABLE_|[_]+GLOBAL__[FID]_.*|[_]+head_[A-Za-z0-9_]+_dll|[A-Za-z0-9_]+_dll_iname']
168.4276 +  ;;
168.4277 +  *)
168.4278 +    _LT_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED '\''s/.* //'\'' | sort | uniq > $export_symbols'
168.4279 +  ;;
168.4280 +  esac
168.4281 +], [
168.4282 +  runpath_var=
168.4283 +  _LT_TAGVAR(allow_undefined_flag, $1)=
168.4284 +  _LT_TAGVAR(always_export_symbols, $1)=no
168.4285 +  _LT_TAGVAR(archive_cmds, $1)=
168.4286 +  _LT_TAGVAR(archive_expsym_cmds, $1)=
168.4287 +  _LT_TAGVAR(compiler_needs_object, $1)=no
168.4288 +  _LT_TAGVAR(enable_shared_with_static_runtimes, $1)=no
168.4289 +  _LT_TAGVAR(export_dynamic_flag_spec, $1)=
168.4290 +  _LT_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED '\''s/.* //'\'' | sort | uniq > $export_symbols'
168.4291 +  _LT_TAGVAR(hardcode_automatic, $1)=no
168.4292 +  _LT_TAGVAR(hardcode_direct, $1)=no
168.4293 +  _LT_TAGVAR(hardcode_direct_absolute, $1)=no
168.4294 +  _LT_TAGVAR(hardcode_libdir_flag_spec, $1)=
168.4295 +  _LT_TAGVAR(hardcode_libdir_flag_spec_ld, $1)=
168.4296 +  _LT_TAGVAR(hardcode_libdir_separator, $1)=
168.4297 +  _LT_TAGVAR(hardcode_minus_L, $1)=no
168.4298 +  _LT_TAGVAR(hardcode_shlibpath_var, $1)=unsupported
168.4299 +  _LT_TAGVAR(inherit_rpath, $1)=no
168.4300 +  _LT_TAGVAR(link_all_deplibs, $1)=unknown
168.4301 +  _LT_TAGVAR(module_cmds, $1)=
168.4302 +  _LT_TAGVAR(module_expsym_cmds, $1)=
168.4303 +  _LT_TAGVAR(old_archive_from_new_cmds, $1)=
168.4304 +  _LT_TAGVAR(old_archive_from_expsyms_cmds, $1)=
168.4305 +  _LT_TAGVAR(thread_safe_flag_spec, $1)=
168.4306 +  _LT_TAGVAR(whole_archive_flag_spec, $1)=
168.4307 +  # include_expsyms should be a list of space-separated symbols to be *always*
168.4308 +  # included in the symbol list
168.4309 +  _LT_TAGVAR(include_expsyms, $1)=
168.4310 +  # exclude_expsyms can be an extended regexp of symbols to exclude
168.4311 +  # it will be wrapped by ` (' and `)$', so one must not match beginning or
168.4312 +  # end of line.  Example: `a|bc|.*d.*' will exclude the symbols `a' and `bc',
168.4313 +  # as well as any symbol that contains `d'.
168.4314 +  _LT_TAGVAR(exclude_expsyms, $1)=['_GLOBAL_OFFSET_TABLE_|_GLOBAL__F[ID]_.*']
168.4315 +  # Although _GLOBAL_OFFSET_TABLE_ is a valid symbol C name, most a.out
168.4316 +  # platforms (ab)use it in PIC code, but their linkers get confused if
168.4317 +  # the symbol is explicitly referenced.  Since portable code cannot
168.4318 +  # rely on this symbol name, it's probably fine to never include it in
168.4319 +  # preloaded symbol tables.
168.4320 +  # Exclude shared library initialization/finalization symbols.
168.4321 +dnl Note also adjust exclude_expsyms for C++ above.
168.4322 +  extract_expsyms_cmds=
168.4323 +
168.4324 +  case $host_os in
168.4325 +  cygwin* | mingw* | pw32* | cegcc*)
168.4326 +    # FIXME: the MSVC++ port hasn't been tested in a loooong time
168.4327 +    # When not using gcc, we currently assume that we are using
168.4328 +    # Microsoft Visual C++.
168.4329 +    if test "$GCC" != yes; then
168.4330 +      with_gnu_ld=no
168.4331 +    fi
168.4332 +    ;;
168.4333 +  interix*)
168.4334 +    # we just hope/assume this is gcc and not c89 (= MSVC++)
168.4335 +    with_gnu_ld=yes
168.4336 +    ;;
168.4337 +  openbsd*)
168.4338 +    with_gnu_ld=no
168.4339 +    ;;
168.4340 +  esac
168.4341 +
168.4342 +  _LT_TAGVAR(ld_shlibs, $1)=yes
168.4343 +
168.4344 +  # On some targets, GNU ld is compatible enough with the native linker
168.4345 +  # that we're better off using the native interface for both.
168.4346 +  lt_use_gnu_ld_interface=no
168.4347 +  if test "$with_gnu_ld" = yes; then
168.4348 +    case $host_os in
168.4349 +      aix*)
168.4350 +	# The AIX port of GNU ld has always aspired to compatibility
168.4351 +	# with the native linker.  However, as the warning in the GNU ld
168.4352 +	# block says, versions before 2.19.5* couldn't really create working
168.4353 +	# shared libraries, regardless of the interface used.
168.4354 +	case `$LD -v 2>&1` in
168.4355 +	  *\ \(GNU\ Binutils\)\ 2.19.5*) ;;
168.4356 +	  *\ \(GNU\ Binutils\)\ 2.[[2-9]]*) ;;
168.4357 +	  *\ \(GNU\ Binutils\)\ [[3-9]]*) ;;
168.4358 +	  *)
168.4359 +	    lt_use_gnu_ld_interface=yes
168.4360 +	    ;;
168.4361 +	esac
168.4362 +	;;
168.4363 +      *)
168.4364 +	lt_use_gnu_ld_interface=yes
168.4365 +	;;
168.4366 +    esac
168.4367 +  fi
168.4368 +
168.4369 +  if test "$lt_use_gnu_ld_interface" = yes; then
168.4370 +    # If archive_cmds runs LD, not CC, wlarc should be empty
168.4371 +    wlarc='${wl}'
168.4372 +
168.4373 +    # Set some defaults for GNU ld with shared library support. These
168.4374 +    # are reset later if shared libraries are not supported. Putting them
168.4375 +    # here allows them to be overridden if necessary.
168.4376 +    runpath_var=LD_RUN_PATH
168.4377 +    _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir'
168.4378 +    _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-dynamic'
168.4379 +    # ancient GNU ld didn't support --whole-archive et. al.
168.4380 +    if $LD --help 2>&1 | $GREP 'no-whole-archive' > /dev/null; then
168.4381 +      _LT_TAGVAR(whole_archive_flag_spec, $1)="$wlarc"'--whole-archive$convenience '"$wlarc"'--no-whole-archive'
168.4382 +    else
168.4383 +      _LT_TAGVAR(whole_archive_flag_spec, $1)=
168.4384 +    fi
168.4385 +    supports_anon_versioning=no
168.4386 +    case `$LD -v 2>&1` in
168.4387 +      *GNU\ gold*) supports_anon_versioning=yes ;;
168.4388 +      *\ [[01]].* | *\ 2.[[0-9]].* | *\ 2.10.*) ;; # catch versions < 2.11
168.4389 +      *\ 2.11.93.0.2\ *) supports_anon_versioning=yes ;; # RH7.3 ...
168.4390 +      *\ 2.11.92.0.12\ *) supports_anon_versioning=yes ;; # Mandrake 8.2 ...
168.4391 +      *\ 2.11.*) ;; # other 2.11 versions
168.4392 +      *) supports_anon_versioning=yes ;;
168.4393 +    esac
168.4394 +
168.4395 +    # See if GNU ld supports shared libraries.
168.4396 +    case $host_os in
168.4397 +    aix[[3-9]]*)
168.4398 +      # On AIX/PPC, the GNU linker is very broken
168.4399 +      if test "$host_cpu" != ia64; then
168.4400 +	_LT_TAGVAR(ld_shlibs, $1)=no
168.4401 +	cat <<_LT_EOF 1>&2
168.4402 +
168.4403 +*** Warning: the GNU linker, at least up to release 2.19, is reported
168.4404 +*** to be unable to reliably create shared libraries on AIX.
168.4405 +*** Therefore, libtool is disabling shared libraries support.  If you
168.4406 +*** really care for shared libraries, you may want to install binutils
168.4407 +*** 2.20 or above, or modify your PATH so that a non-GNU linker is found.
168.4408 +*** You will then need to restart the configuration process.
168.4409 +
168.4410 +_LT_EOF
168.4411 +      fi
168.4412 +      ;;
168.4413 +
168.4414 +    amigaos*)
168.4415 +      case $host_cpu in
168.4416 +      powerpc)
168.4417 +            # see comment about AmigaOS4 .so support
168.4418 +            _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
168.4419 +            _LT_TAGVAR(archive_expsym_cmds, $1)=''
168.4420 +        ;;
168.4421 +      m68k)
168.4422 +            _LT_TAGVAR(archive_cmds, $1)='$RM $output_objdir/a2ixlibrary.data~$ECHO "#define NAME $libname" > $output_objdir/a2ixlibrary.data~$ECHO "#define LIBRARY_ID 1" >> $output_objdir/a2ixlibrary.data~$ECHO "#define VERSION $major" >> $output_objdir/a2ixlibrary.data~$ECHO "#define REVISION $revision" >> $output_objdir/a2ixlibrary.data~$AR $AR_FLAGS $lib $libobjs~$RANLIB $lib~(cd $output_objdir && a2ixlibrary -32)'
168.4423 +            _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir'
168.4424 +            _LT_TAGVAR(hardcode_minus_L, $1)=yes
168.4425 +        ;;
168.4426 +      esac
168.4427 +      ;;
168.4428 +
168.4429 +    beos*)
168.4430 +      if $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then
168.4431 +	_LT_TAGVAR(allow_undefined_flag, $1)=unsupported
168.4432 +	# Joseph Beckenbach <jrb3@best.com> says some releases of gcc
168.4433 +	# support --undefined.  This deserves some investigation.  FIXME
168.4434 +	_LT_TAGVAR(archive_cmds, $1)='$CC -nostart $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
168.4435 +      else
168.4436 +	_LT_TAGVAR(ld_shlibs, $1)=no
168.4437 +      fi
168.4438 +      ;;
168.4439 +
168.4440 +    cygwin* | mingw* | pw32* | cegcc*)
168.4441 +      # _LT_TAGVAR(hardcode_libdir_flag_spec, $1) is actually meaningless,
168.4442 +      # as there is no search path for DLLs.
168.4443 +      _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir'
168.4444 +      _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-all-symbols'
168.4445 +      _LT_TAGVAR(allow_undefined_flag, $1)=unsupported
168.4446 +      _LT_TAGVAR(always_export_symbols, $1)=no
168.4447 +      _LT_TAGVAR(enable_shared_with_static_runtimes, $1)=yes
168.4448 +      _LT_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED -e '\''/^[[BCDGRS]][[ ]]/s/.*[[ ]]\([[^ ]]*\)/\1 DATA/;s/^.*[[ ]]__nm__\([[^ ]]*\)[[ ]][[^ ]]*/\1 DATA/;/^I[[ ]]/d;/^[[AITW]][[ ]]/s/.* //'\'' | sort | uniq > $export_symbols'
168.4449 +      _LT_TAGVAR(exclude_expsyms, $1)=['[_]+GLOBAL_OFFSET_TABLE_|[_]+GLOBAL__[FID]_.*|[_]+head_[A-Za-z0-9_]+_dll|[A-Za-z0-9_]+_dll_iname']
168.4450 +
168.4451 +      if $LD --help 2>&1 | $GREP 'auto-import' > /dev/null; then
168.4452 +        _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib'
168.4453 +	# If the export-symbols file already is a .def file (1st line
168.4454 +	# is EXPORTS), use it as is; otherwise, prepend...
168.4455 +	_LT_TAGVAR(archive_expsym_cmds, $1)='if test "x`$SED 1q $export_symbols`" = xEXPORTS; then
168.4456 +	  cp $export_symbols $output_objdir/$soname.def;
168.4457 +	else
168.4458 +	  echo EXPORTS > $output_objdir/$soname.def;
168.4459 +	  cat $export_symbols >> $output_objdir/$soname.def;
168.4460 +	fi~
168.4461 +	$CC -shared $output_objdir/$soname.def $libobjs $deplibs $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib'
168.4462 +      else
168.4463 +	_LT_TAGVAR(ld_shlibs, $1)=no
168.4464 +      fi
168.4465 +      ;;
168.4466 +
168.4467 +    haiku*)
168.4468 +      _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
168.4469 +      _LT_TAGVAR(link_all_deplibs, $1)=yes
168.4470 +      ;;
168.4471 +
168.4472 +    interix[[3-9]]*)
168.4473 +      _LT_TAGVAR(hardcode_direct, $1)=no
168.4474 +      _LT_TAGVAR(hardcode_shlibpath_var, $1)=no
168.4475 +      _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir'
168.4476 +      _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E'
168.4477 +      # Hack: On Interix 3.x, we cannot compile PIC because of a broken gcc.
168.4478 +      # Instead, shared libraries are loaded at an image base (0x10000000 by
168.4479 +      # default) and relocated if they conflict, which is a slow very memory
168.4480 +      # consuming and fragmenting process.  To avoid this, we pick a random,
168.4481 +      # 256 KiB-aligned image base between 0x50000000 and 0x6FFC0000 at link
168.4482 +      # time.  Moving up from 0x10000000 also allows more sbrk(2) space.
168.4483 +      _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib'
168.4484 +      _LT_TAGVAR(archive_expsym_cmds, $1)='sed "s,^,_," $export_symbols >$output_objdir/$soname.expsym~$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--retain-symbols-file,$output_objdir/$soname.expsym ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib'
168.4485 +      ;;
168.4486 +
168.4487 +    gnu* | linux* | tpf* | k*bsd*-gnu | kopensolaris*-gnu)
168.4488 +      tmp_diet=no
168.4489 +      if test "$host_os" = linux-dietlibc; then
168.4490 +	case $cc_basename in
168.4491 +	  diet\ *) tmp_diet=yes;;	# linux-dietlibc with static linking (!diet-dyn)
168.4492 +	esac
168.4493 +      fi
168.4494 +      if $LD --help 2>&1 | $EGREP ': supported targets:.* elf' > /dev/null \
168.4495 +	 && test "$tmp_diet" = no
168.4496 +      then
168.4497 +	tmp_addflag=
168.4498 +	tmp_sharedflag='-shared'
168.4499 +	case $cc_basename,$host_cpu in
168.4500 +        pgcc*)				# Portland Group C compiler
168.4501 +	  _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive`for conv in $convenience\"\"; do test  -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` ${wl}--no-whole-archive'
168.4502 +	  tmp_addflag=' $pic_flag'
168.4503 +	  ;;
168.4504 +	pgf77* | pgf90* | pgf95* | pgfortran*)
168.4505 +					# Portland Group f77 and f90 compilers
168.4506 +	  _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive`for conv in $convenience\"\"; do test  -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` ${wl}--no-whole-archive'
168.4507 +	  tmp_addflag=' $pic_flag -Mnomain' ;;
168.4508 +	ecc*,ia64* | icc*,ia64*)	# Intel C compiler on ia64
168.4509 +	  tmp_addflag=' -i_dynamic' ;;
168.4510 +	efc*,ia64* | ifort*,ia64*)	# Intel Fortran compiler on ia64
168.4511 +	  tmp_addflag=' -i_dynamic -nofor_main' ;;
168.4512 +	ifc* | ifort*)			# Intel Fortran compiler
168.4513 +	  tmp_addflag=' -nofor_main' ;;
168.4514 +	lf95*)				# Lahey Fortran 8.1
168.4515 +	  _LT_TAGVAR(whole_archive_flag_spec, $1)=
168.4516 +	  tmp_sharedflag='--shared' ;;
168.4517 +	xl[[cC]]* | bgxl[[cC]]* | mpixl[[cC]]*) # IBM XL C 8.0 on PPC (deal with xlf below)
168.4518 +	  tmp_sharedflag='-qmkshrobj'
168.4519 +	  tmp_addflag= ;;
168.4520 +	nvcc*)	# Cuda Compiler Driver 2.2
168.4521 +	  _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive`for conv in $convenience\"\"; do test  -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` ${wl}--no-whole-archive'
168.4522 +	  _LT_TAGVAR(compiler_needs_object, $1)=yes
168.4523 +	  ;;
168.4524 +	esac
168.4525 +	case `$CC -V 2>&1 | sed 5q` in
168.4526 +	*Sun\ C*)			# Sun C 5.9
168.4527 +	  _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive`new_convenience=; for conv in $convenience\"\"; do test -z \"$conv\" || new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` ${wl}--no-whole-archive'
168.4528 +	  _LT_TAGVAR(compiler_needs_object, $1)=yes
168.4529 +	  tmp_sharedflag='-G' ;;
168.4530 +	*Sun\ F*)			# Sun Fortran 8.3
168.4531 +	  tmp_sharedflag='-G' ;;
168.4532 +	esac
168.4533 +	_LT_TAGVAR(archive_cmds, $1)='$CC '"$tmp_sharedflag""$tmp_addflag"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
168.4534 +
168.4535 +        if test "x$supports_anon_versioning" = xyes; then
168.4536 +          _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $output_objdir/$libname.ver~
168.4537 +	    cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~
168.4538 +	    echo "local: *; };" >> $output_objdir/$libname.ver~
168.4539 +	    $CC '"$tmp_sharedflag""$tmp_addflag"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-version-script ${wl}$output_objdir/$libname.ver -o $lib'
168.4540 +        fi
168.4541 +
168.4542 +	case $cc_basename in
168.4543 +	xlf* | bgf* | bgxlf* | mpixlf*)
168.4544 +	  # IBM XL Fortran 10.1 on PPC cannot create shared libs itself
168.4545 +	  _LT_TAGVAR(whole_archive_flag_spec, $1)='--whole-archive$convenience --no-whole-archive'
168.4546 +	  _LT_TAGVAR(hardcode_libdir_flag_spec, $1)=
168.4547 +	  _LT_TAGVAR(hardcode_libdir_flag_spec_ld, $1)='-rpath $libdir'
168.4548 +	  _LT_TAGVAR(archive_cmds, $1)='$LD -shared $libobjs $deplibs $compiler_flags -soname $soname -o $lib'
168.4549 +	  if test "x$supports_anon_versioning" = xyes; then
168.4550 +	    _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $output_objdir/$libname.ver~
168.4551 +	      cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~
168.4552 +	      echo "local: *; };" >> $output_objdir/$libname.ver~
168.4553 +	      $LD -shared $libobjs $deplibs $compiler_flags -soname $soname -version-script $output_objdir/$libname.ver -o $lib'
168.4554 +	  fi
168.4555 +	  ;;
168.4556 +	esac
168.4557 +      else
168.4558 +        _LT_TAGVAR(ld_shlibs, $1)=no
168.4559 +      fi
168.4560 +      ;;
168.4561 +
168.4562 +    netbsd*)
168.4563 +      if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then
168.4564 +	_LT_TAGVAR(archive_cmds, $1)='$LD -Bshareable $libobjs $deplibs $linker_flags -o $lib'
168.4565 +	wlarc=
168.4566 +      else
168.4567 +	_LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
168.4568 +	_LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
168.4569 +      fi
168.4570 +      ;;
168.4571 +
168.4572 +    solaris*)
168.4573 +      if $LD -v 2>&1 | $GREP 'BFD 2\.8' > /dev/null; then
168.4574 +	_LT_TAGVAR(ld_shlibs, $1)=no
168.4575 +	cat <<_LT_EOF 1>&2
168.4576 +
168.4577 +*** Warning: The releases 2.8.* of the GNU linker cannot reliably
168.4578 +*** create shared libraries on Solaris systems.  Therefore, libtool
168.4579 +*** is disabling shared libraries support.  We urge you to upgrade GNU
168.4580 +*** binutils to release 2.9.1 or newer.  Another option is to modify
168.4581 +*** your PATH or compiler configuration so that the native linker is
168.4582 +*** used, and then restart.
168.4583 +
168.4584 +_LT_EOF
168.4585 +      elif $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then
168.4586 +	_LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
168.4587 +	_LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
168.4588 +      else
168.4589 +	_LT_TAGVAR(ld_shlibs, $1)=no
168.4590 +      fi
168.4591 +      ;;
168.4592 +
168.4593 +    sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX*)
168.4594 +      case `$LD -v 2>&1` in
168.4595 +        *\ [[01]].* | *\ 2.[[0-9]].* | *\ 2.1[[0-5]].*)
168.4596 +	_LT_TAGVAR(ld_shlibs, $1)=no
168.4597 +	cat <<_LT_EOF 1>&2
168.4598 +
168.4599 +*** Warning: Releases of the GNU linker prior to 2.16.91.0.3 can not
168.4600 +*** reliably create shared libraries on SCO systems.  Therefore, libtool
168.4601 +*** is disabling shared libraries support.  We urge you to upgrade GNU
168.4602 +*** binutils to release 2.16.91.0.3 or newer.  Another option is to modify
168.4603 +*** your PATH or compiler configuration so that the native linker is
168.4604 +*** used, and then restart.
168.4605 +
168.4606 +_LT_EOF
168.4607 +	;;
168.4608 +	*)
168.4609 +	  # For security reasons, it is highly recommended that you always
168.4610 +	  # use absolute paths for naming shared libraries, and exclude the
168.4611 +	  # DT_RUNPATH tag from executables and libraries.  But doing so
168.4612 +	  # requires that you compile everything twice, which is a pain.
168.4613 +	  if $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then
168.4614 +	    _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir'
168.4615 +	    _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
168.4616 +	    _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
168.4617 +	  else
168.4618 +	    _LT_TAGVAR(ld_shlibs, $1)=no
168.4619 +	  fi
168.4620 +	;;
168.4621 +      esac
168.4622 +      ;;
168.4623 +
168.4624 +    sunos4*)
168.4625 +      _LT_TAGVAR(archive_cmds, $1)='$LD -assert pure-text -Bshareable -o $lib $libobjs $deplibs $linker_flags'
168.4626 +      wlarc=
168.4627 +      _LT_TAGVAR(hardcode_direct, $1)=yes
168.4628 +      _LT_TAGVAR(hardcode_shlibpath_var, $1)=no
168.4629 +      ;;
168.4630 +
168.4631 +    *)
168.4632 +      if $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then
168.4633 +	_LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
168.4634 +	_LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
168.4635 +      else
168.4636 +	_LT_TAGVAR(ld_shlibs, $1)=no
168.4637 +      fi
168.4638 +      ;;
168.4639 +    esac
168.4640 +
168.4641 +    if test "$_LT_TAGVAR(ld_shlibs, $1)" = no; then
168.4642 +      runpath_var=
168.4643 +      _LT_TAGVAR(hardcode_libdir_flag_spec, $1)=
168.4644 +      _LT_TAGVAR(export_dynamic_flag_spec, $1)=
168.4645 +      _LT_TAGVAR(whole_archive_flag_spec, $1)=
168.4646 +    fi
168.4647 +  else
168.4648 +    # PORTME fill in a description of your system's linker (not GNU ld)
168.4649 +    case $host_os in
168.4650 +    aix3*)
168.4651 +      _LT_TAGVAR(allow_undefined_flag, $1)=unsupported
168.4652 +      _LT_TAGVAR(always_export_symbols, $1)=yes
168.4653 +      _LT_TAGVAR(archive_expsym_cmds, $1)='$LD -o $output_objdir/$soname $libobjs $deplibs $linker_flags -bE:$export_symbols -T512 -H512 -bM:SRE~$AR $AR_FLAGS $lib $output_objdir/$soname'
168.4654 +      # Note: this linker hardcodes the directories in LIBPATH if there
168.4655 +      # are no directories specified by -L.
168.4656 +      _LT_TAGVAR(hardcode_minus_L, $1)=yes
168.4657 +      if test "$GCC" = yes && test -z "$lt_prog_compiler_static"; then
168.4658 +	# Neither direct hardcoding nor static linking is supported with a
168.4659 +	# broken collect2.
168.4660 +	_LT_TAGVAR(hardcode_direct, $1)=unsupported
168.4661 +      fi
168.4662 +      ;;
168.4663 +
168.4664 +    aix[[4-9]]*)
168.4665 +      if test "$host_cpu" = ia64; then
168.4666 +	# On IA64, the linker does run time linking by default, so we don't
168.4667 +	# have to do anything special.
168.4668 +	aix_use_runtimelinking=no
168.4669 +	exp_sym_flag='-Bexport'
168.4670 +	no_entry_flag=""
168.4671 +      else
168.4672 +	# If we're using GNU nm, then we don't want the "-C" option.
168.4673 +	# -C means demangle to AIX nm, but means don't demangle with GNU nm
168.4674 +	# Also, AIX nm treats weak defined symbols like other global
168.4675 +	# defined symbols, whereas GNU nm marks them as "W".
168.4676 +	if $NM -V 2>&1 | $GREP 'GNU' > /dev/null; then
168.4677 +	  _LT_TAGVAR(export_symbols_cmds, $1)='$NM -Bpg $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B") || (\$ 2 == "W")) && ([substr](\$ 3,1,1) != ".")) { print \$ 3 } }'\'' | sort -u > $export_symbols'
168.4678 +	else
168.4679 +	  _LT_TAGVAR(export_symbols_cmds, $1)='$NM -BCpg $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B")) && ([substr](\$ 3,1,1) != ".")) { print \$ 3 } }'\'' | sort -u > $export_symbols'
168.4680 +	fi
168.4681 +	aix_use_runtimelinking=no
168.4682 +
168.4683 +	# Test if we are trying to use run time linking or normal
168.4684 +	# AIX style linking. If -brtl is somewhere in LDFLAGS, we
168.4685 +	# need to do runtime linking.
168.4686 +	case $host_os in aix4.[[23]]|aix4.[[23]].*|aix[[5-9]]*)
168.4687 +	  for ld_flag in $LDFLAGS; do
168.4688 +	  if (test $ld_flag = "-brtl" || test $ld_flag = "-Wl,-brtl"); then
168.4689 +	    aix_use_runtimelinking=yes
168.4690 +	    break
168.4691 +	  fi
168.4692 +	  done
168.4693 +	  ;;
168.4694 +	esac
168.4695 +
168.4696 +	exp_sym_flag='-bexport'
168.4697 +	no_entry_flag='-bnoentry'
168.4698 +      fi
168.4699 +
168.4700 +      # When large executables or shared objects are built, AIX ld can
168.4701 +      # have problems creating the table of contents.  If linking a library
168.4702 +      # or program results in "error TOC overflow" add -mminimal-toc to
168.4703 +      # CXXFLAGS/CFLAGS for g++/gcc.  In the cases where that is not
168.4704 +      # enough to fix the problem, add -Wl,-bbigtoc to LDFLAGS.
168.4705 +
168.4706 +      _LT_TAGVAR(archive_cmds, $1)=''
168.4707 +      _LT_TAGVAR(hardcode_direct, $1)=yes
168.4708 +      _LT_TAGVAR(hardcode_direct_absolute, $1)=yes
168.4709 +      _LT_TAGVAR(hardcode_libdir_separator, $1)=':'
168.4710 +      _LT_TAGVAR(link_all_deplibs, $1)=yes
168.4711 +      _LT_TAGVAR(file_list_spec, $1)='${wl}-f,'
168.4712 +
168.4713 +      if test "$GCC" = yes; then
168.4714 +	case $host_os in aix4.[[012]]|aix4.[[012]].*)
168.4715 +	# We only want to do this on AIX 4.2 and lower, the check
168.4716 +	# below for broken collect2 doesn't work under 4.3+
168.4717 +	  collect2name=`${CC} -print-prog-name=collect2`
168.4718 +	  if test -f "$collect2name" &&
168.4719 +	   strings "$collect2name" | $GREP resolve_lib_name >/dev/null
168.4720 +	  then
168.4721 +	  # We have reworked collect2
168.4722 +	  :
168.4723 +	  else
168.4724 +	  # We have old collect2
168.4725 +	  _LT_TAGVAR(hardcode_direct, $1)=unsupported
168.4726 +	  # It fails to find uninstalled libraries when the uninstalled
168.4727 +	  # path is not listed in the libpath.  Setting hardcode_minus_L
168.4728 +	  # to unsupported forces relinking
168.4729 +	  _LT_TAGVAR(hardcode_minus_L, $1)=yes
168.4730 +	  _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir'
168.4731 +	  _LT_TAGVAR(hardcode_libdir_separator, $1)=
168.4732 +	  fi
168.4733 +	  ;;
168.4734 +	esac
168.4735 +	shared_flag='-shared'
168.4736 +	if test "$aix_use_runtimelinking" = yes; then
168.4737 +	  shared_flag="$shared_flag "'${wl}-G'
168.4738 +	fi
168.4739 +      else
168.4740 +	# not using gcc
168.4741 +	if test "$host_cpu" = ia64; then
168.4742 +	# VisualAge C++, Version 5.5 for AIX 5L for IA-64, Beta 3 Release
168.4743 +	# chokes on -Wl,-G. The following line is correct:
168.4744 +	  shared_flag='-G'
168.4745 +	else
168.4746 +	  if test "$aix_use_runtimelinking" = yes; then
168.4747 +	    shared_flag='${wl}-G'
168.4748 +	  else
168.4749 +	    shared_flag='${wl}-bM:SRE'
168.4750 +	  fi
168.4751 +	fi
168.4752 +      fi
168.4753 +
168.4754 +      _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-bexpall'
168.4755 +      # It seems that -bexpall does not export symbols beginning with
168.4756 +      # underscore (_), so it is better to generate a list of symbols to export.
168.4757 +      _LT_TAGVAR(always_export_symbols, $1)=yes
168.4758 +      if test "$aix_use_runtimelinking" = yes; then
168.4759 +	# Warning - without using the other runtime loading flags (-brtl),
168.4760 +	# -berok will link without error, but may produce a broken library.
168.4761 +	_LT_TAGVAR(allow_undefined_flag, $1)='-berok'
168.4762 +        # Determine the default libpath from the value encoded in an
168.4763 +        # empty executable.
168.4764 +        _LT_SYS_MODULE_PATH_AIX
168.4765 +        _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-blibpath:$libdir:'"$aix_libpath"
168.4766 +        _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags `if test "x${allow_undefined_flag}" != "x"; then func_echo_all "${wl}${allow_undefined_flag}"; else :; fi` '"\${wl}$exp_sym_flag:\$export_symbols $shared_flag"
168.4767 +      else
168.4768 +	if test "$host_cpu" = ia64; then
168.4769 +	  _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-R $libdir:/usr/lib:/lib'
168.4770 +	  _LT_TAGVAR(allow_undefined_flag, $1)="-z nodefs"
168.4771 +	  _LT_TAGVAR(archive_expsym_cmds, $1)="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags ${wl}${allow_undefined_flag} '"\${wl}$exp_sym_flag:\$export_symbols"
168.4772 +	else
168.4773 +	 # Determine the default libpath from the value encoded in an
168.4774 +	 # empty executable.
168.4775 +	 _LT_SYS_MODULE_PATH_AIX
168.4776 +	 _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-blibpath:$libdir:'"$aix_libpath"
168.4777 +	  # Warning - without using the other run time loading flags,
168.4778 +	  # -berok will link without error, but may produce a broken library.
168.4779 +	  _LT_TAGVAR(no_undefined_flag, $1)=' ${wl}-bernotok'
168.4780 +	  _LT_TAGVAR(allow_undefined_flag, $1)=' ${wl}-berok'
168.4781 +	  if test "$with_gnu_ld" = yes; then
168.4782 +	    # We only use this code for GNU lds that support --whole-archive.
168.4783 +	    _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive$convenience ${wl}--no-whole-archive'
168.4784 +	  else
168.4785 +	    # Exported symbols can be pulled into shared objects from archives
168.4786 +	    _LT_TAGVAR(whole_archive_flag_spec, $1)='$convenience'
168.4787 +	  fi
168.4788 +	  _LT_TAGVAR(archive_cmds_need_lc, $1)=yes
168.4789 +	  # This is similar to how AIX traditionally builds its shared libraries.
168.4790 +	  _LT_TAGVAR(archive_expsym_cmds, $1)="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs ${wl}-bnoentry $compiler_flags ${wl}-bE:$export_symbols${allow_undefined_flag}~$AR $AR_FLAGS $output_objdir/$libname$release.a $output_objdir/$soname'
168.4791 +	fi
168.4792 +      fi
168.4793 +      ;;
168.4794 +
168.4795 +    amigaos*)
168.4796 +      case $host_cpu in
168.4797 +      powerpc)
168.4798 +            # see comment about AmigaOS4 .so support
168.4799 +            _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
168.4800 +            _LT_TAGVAR(archive_expsym_cmds, $1)=''
168.4801 +        ;;
168.4802 +      m68k)
168.4803 +            _LT_TAGVAR(archive_cmds, $1)='$RM $output_objdir/a2ixlibrary.data~$ECHO "#define NAME $libname" > $output_objdir/a2ixlibrary.data~$ECHO "#define LIBRARY_ID 1" >> $output_objdir/a2ixlibrary.data~$ECHO "#define VERSION $major" >> $output_objdir/a2ixlibrary.data~$ECHO "#define REVISION $revision" >> $output_objdir/a2ixlibrary.data~$AR $AR_FLAGS $lib $libobjs~$RANLIB $lib~(cd $output_objdir && a2ixlibrary -32)'
168.4804 +            _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir'
168.4805 +            _LT_TAGVAR(hardcode_minus_L, $1)=yes
168.4806 +        ;;
168.4807 +      esac
168.4808 +      ;;
168.4809 +
168.4810 +    bsdi[[45]]*)
168.4811 +      _LT_TAGVAR(export_dynamic_flag_spec, $1)=-rdynamic
168.4812 +      ;;
168.4813 +
168.4814 +    cygwin* | mingw* | pw32* | cegcc*)
168.4815 +      # When not using gcc, we currently assume that we are using
168.4816 +      # Microsoft Visual C++.
168.4817 +      # hardcode_libdir_flag_spec is actually meaningless, as there is
168.4818 +      # no search path for DLLs.
168.4819 +      _LT_TAGVAR(hardcode_libdir_flag_spec, $1)=' '
168.4820 +      _LT_TAGVAR(allow_undefined_flag, $1)=unsupported
168.4821 +      # Tell ltmain to make .lib files, not .a files.
168.4822 +      libext=lib
168.4823 +      # Tell ltmain to make .dll files, not .so files.
168.4824 +      shrext_cmds=".dll"
168.4825 +      # FIXME: Setting linknames here is a bad hack.
168.4826 +      _LT_TAGVAR(archive_cmds, $1)='$CC -o $lib $libobjs $compiler_flags `func_echo_all "$deplibs" | $SED '\''s/ -lc$//'\''` -link -dll~linknames='
168.4827 +      # The linker will automatically build a .lib file if we build a DLL.
168.4828 +      _LT_TAGVAR(old_archive_from_new_cmds, $1)='true'
168.4829 +      # FIXME: Should let the user specify the lib program.
168.4830 +      _LT_TAGVAR(old_archive_cmds, $1)='lib -OUT:$oldlib$oldobjs$old_deplibs'
168.4831 +      _LT_TAGVAR(fix_srcfile_path, $1)='`cygpath -w "$srcfile"`'
168.4832 +      _LT_TAGVAR(enable_shared_with_static_runtimes, $1)=yes
168.4833 +      ;;
168.4834 +
168.4835 +    darwin* | rhapsody*)
168.4836 +      _LT_DARWIN_LINKER_FEATURES($1)
168.4837 +      ;;
168.4838 +
168.4839 +    dgux*)
168.4840 +      _LT_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
168.4841 +      _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir'
168.4842 +      _LT_TAGVAR(hardcode_shlibpath_var, $1)=no
168.4843 +      ;;
168.4844 +
168.4845 +    freebsd1*)
168.4846 +      _LT_TAGVAR(ld_shlibs, $1)=no
168.4847 +      ;;
168.4848 +
168.4849 +    # FreeBSD 2.2.[012] allows us to include c++rt0.o to get C++ constructor
168.4850 +    # support.  Future versions do this automatically, but an explicit c++rt0.o
168.4851 +    # does not break anything, and helps significantly (at the cost of a little
168.4852 +    # extra space).
168.4853 +    freebsd2.2*)
168.4854 +      _LT_TAGVAR(archive_cmds, $1)='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags /usr/lib/c++rt0.o'
168.4855 +      _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir'
168.4856 +      _LT_TAGVAR(hardcode_direct, $1)=yes
168.4857 +      _LT_TAGVAR(hardcode_shlibpath_var, $1)=no
168.4858 +      ;;
168.4859 +
168.4860 +    # Unfortunately, older versions of FreeBSD 2 do not have this feature.
168.4861 +    freebsd2*)
168.4862 +      _LT_TAGVAR(archive_cmds, $1)='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags'
168.4863 +      _LT_TAGVAR(hardcode_direct, $1)=yes
168.4864 +      _LT_TAGVAR(hardcode_minus_L, $1)=yes
168.4865 +      _LT_TAGVAR(hardcode_shlibpath_var, $1)=no
168.4866 +      ;;
168.4867 +
168.4868 +    # FreeBSD 3 and greater uses gcc -shared to do shared libraries.
168.4869 +    freebsd* | dragonfly*)
168.4870 +      _LT_TAGVAR(archive_cmds, $1)='$CC -shared -o $lib $libobjs $deplibs $compiler_flags'
168.4871 +      _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir'
168.4872 +      _LT_TAGVAR(hardcode_direct, $1)=yes
168.4873 +      _LT_TAGVAR(hardcode_shlibpath_var, $1)=no
168.4874 +      ;;
168.4875 +
168.4876 +    hpux9*)
168.4877 +      if test "$GCC" = yes; then
168.4878 +	_LT_TAGVAR(archive_cmds, $1)='$RM $output_objdir/$soname~$CC -shared -fPIC ${wl}+b ${wl}$install_libdir -o $output_objdir/$soname $libobjs $deplibs $compiler_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib'
168.4879 +      else
168.4880 +	_LT_TAGVAR(archive_cmds, $1)='$RM $output_objdir/$soname~$LD -b +b $install_libdir -o $output_objdir/$soname $libobjs $deplibs $linker_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib'
168.4881 +      fi
168.4882 +      _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}+b ${wl}$libdir'
168.4883 +      _LT_TAGVAR(hardcode_libdir_separator, $1)=:
168.4884 +      _LT_TAGVAR(hardcode_direct, $1)=yes
168.4885 +
168.4886 +      # hardcode_minus_L: Not really in the search PATH,
168.4887 +      # but as the default location of the library.
168.4888 +      _LT_TAGVAR(hardcode_minus_L, $1)=yes
168.4889 +      _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E'
168.4890 +      ;;
168.4891 +
168.4892 +    hpux10*)
168.4893 +      if test "$GCC" = yes && test "$with_gnu_ld" = no; then
168.4894 +	_LT_TAGVAR(archive_cmds, $1)='$CC -shared -fPIC ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags'
168.4895 +      else
168.4896 +	_LT_TAGVAR(archive_cmds, $1)='$LD -b +h $soname +b $install_libdir -o $lib $libobjs $deplibs $linker_flags'
168.4897 +      fi
168.4898 +      if test "$with_gnu_ld" = no; then
168.4899 +	_LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}+b ${wl}$libdir'
168.4900 +	_LT_TAGVAR(hardcode_libdir_flag_spec_ld, $1)='+b $libdir'
168.4901 +	_LT_TAGVAR(hardcode_libdir_separator, $1)=:
168.4902 +	_LT_TAGVAR(hardcode_direct, $1)=yes
168.4903 +	_LT_TAGVAR(hardcode_direct_absolute, $1)=yes
168.4904 +	_LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E'
168.4905 +	# hardcode_minus_L: Not really in the search PATH,
168.4906 +	# but as the default location of the library.
168.4907 +	_LT_TAGVAR(hardcode_minus_L, $1)=yes
168.4908 +      fi
168.4909 +      ;;
168.4910 +
168.4911 +    hpux11*)
168.4912 +      if test "$GCC" = yes && test "$with_gnu_ld" = no; then
168.4913 +	case $host_cpu in
168.4914 +	hppa*64*)
168.4915 +	  _LT_TAGVAR(archive_cmds, $1)='$CC -shared ${wl}+h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags'
168.4916 +	  ;;
168.4917 +	ia64*)
168.4918 +	  _LT_TAGVAR(archive_cmds, $1)='$CC -shared -fPIC ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $libobjs $deplibs $compiler_flags'
168.4919 +	  ;;
168.4920 +	*)
168.4921 +	  _LT_TAGVAR(archive_cmds, $1)='$CC -shared -fPIC ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags'
168.4922 +	  ;;
168.4923 +	esac
168.4924 +      else
168.4925 +	case $host_cpu in
168.4926 +	hppa*64*)
168.4927 +	  _LT_TAGVAR(archive_cmds, $1)='$CC -b ${wl}+h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags'
168.4928 +	  ;;
168.4929 +	ia64*)
168.4930 +	  _LT_TAGVAR(archive_cmds, $1)='$CC -b ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $libobjs $deplibs $compiler_flags'
168.4931 +	  ;;
168.4932 +	*)
168.4933 +	m4_if($1, [], [
168.4934 +	  # Older versions of the 11.00 compiler do not understand -b yet
168.4935 +	  # (HP92453-01 A.11.01.20 doesn't, HP92453-01 B.11.X.35175-35176.GP does)
168.4936 +	  _LT_LINKER_OPTION([if $CC understands -b],
168.4937 +	    _LT_TAGVAR(lt_cv_prog_compiler__b, $1), [-b],
168.4938 +	    [_LT_TAGVAR(archive_cmds, $1)='$CC -b ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags'],
168.4939 +	    [_LT_TAGVAR(archive_cmds, $1)='$LD -b +h $soname +b $install_libdir -o $lib $libobjs $deplibs $linker_flags'])],
168.4940 +	  [_LT_TAGVAR(archive_cmds, $1)='$CC -b ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags'])
168.4941 +	  ;;
168.4942 +	esac
168.4943 +      fi
168.4944 +      if test "$with_gnu_ld" = no; then
168.4945 +	_LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}+b ${wl}$libdir'
168.4946 +	_LT_TAGVAR(hardcode_libdir_separator, $1)=:
168.4947 +
168.4948 +	case $host_cpu in
168.4949 +	hppa*64*|ia64*)
168.4950 +	  _LT_TAGVAR(hardcode_direct, $1)=no
168.4951 +	  _LT_TAGVAR(hardcode_shlibpath_var, $1)=no
168.4952 +	  ;;
168.4953 +	*)
168.4954 +	  _LT_TAGVAR(hardcode_direct, $1)=yes
168.4955 +	  _LT_TAGVAR(hardcode_direct_absolute, $1)=yes
168.4956 +	  _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E'
168.4957 +
168.4958 +	  # hardcode_minus_L: Not really in the search PATH,
168.4959 +	  # but as the default location of the library.
168.4960 +	  _LT_TAGVAR(hardcode_minus_L, $1)=yes
168.4961 +	  ;;
168.4962 +	esac
168.4963 +      fi
168.4964 +      ;;
168.4965 +
168.4966 +    irix5* | irix6* | nonstopux*)
168.4967 +      if test "$GCC" = yes; then
168.4968 +	_LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version ${wl}$verstring"` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib'
168.4969 +	# Try to use the -exported_symbol ld option, if it does not
168.4970 +	# work, assume that -exports_file does not work either and
168.4971 +	# implicitly export all symbols.
168.4972 +        save_LDFLAGS="$LDFLAGS"
168.4973 +        LDFLAGS="$LDFLAGS -shared ${wl}-exported_symbol ${wl}foo ${wl}-update_registry ${wl}/dev/null"
168.4974 +        AC_LINK_IFELSE(int foo(void) {},
168.4975 +          _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version ${wl}$verstring"` ${wl}-update_registry ${wl}${output_objdir}/so_locations ${wl}-exports_file ${wl}$export_symbols -o $lib'
168.4976 +        )
168.4977 +        LDFLAGS="$save_LDFLAGS"
168.4978 +      else
168.4979 +	_LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry ${output_objdir}/so_locations -o $lib'
168.4980 +	_LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry ${output_objdir}/so_locations -exports_file $export_symbols -o $lib'
168.4981 +      fi
168.4982 +      _LT_TAGVAR(archive_cmds_need_lc, $1)='no'
168.4983 +      _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir'
168.4984 +      _LT_TAGVAR(hardcode_libdir_separator, $1)=:
168.4985 +      _LT_TAGVAR(inherit_rpath, $1)=yes
168.4986 +      _LT_TAGVAR(link_all_deplibs, $1)=yes
168.4987 +      ;;
168.4988 +
168.4989 +    netbsd*)
168.4990 +      if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then
168.4991 +	_LT_TAGVAR(archive_cmds, $1)='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags'  # a.out
168.4992 +      else
168.4993 +	_LT_TAGVAR(archive_cmds, $1)='$LD -shared -o $lib $libobjs $deplibs $linker_flags'      # ELF
168.4994 +      fi
168.4995 +      _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir'
168.4996 +      _LT_TAGVAR(hardcode_direct, $1)=yes
168.4997 +      _LT_TAGVAR(hardcode_shlibpath_var, $1)=no
168.4998 +      ;;
168.4999 +
168.5000 +    newsos6)
168.5001 +      _LT_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
168.5002 +      _LT_TAGVAR(hardcode_direct, $1)=yes
168.5003 +      _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir'
168.5004 +      _LT_TAGVAR(hardcode_libdir_separator, $1)=:
168.5005 +      _LT_TAGVAR(hardcode_shlibpath_var, $1)=no
168.5006 +      ;;
168.5007 +
168.5008 +    *nto* | *qnx*)
168.5009 +      ;;
168.5010 +
168.5011 +    openbsd*)
168.5012 +      if test -f /usr/libexec/ld.so; then
168.5013 +	_LT_TAGVAR(hardcode_direct, $1)=yes
168.5014 +	_LT_TAGVAR(hardcode_shlibpath_var, $1)=no
168.5015 +	_LT_TAGVAR(hardcode_direct_absolute, $1)=yes
168.5016 +	if test -z "`echo __ELF__ | $CC -E - | $GREP __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then
168.5017 +	  _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags'
168.5018 +	  _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags ${wl}-retain-symbols-file,$export_symbols'
168.5019 +	  _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir'
168.5020 +	  _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E'
168.5021 +	else
168.5022 +	  case $host_os in
168.5023 +	   openbsd[[01]].* | openbsd2.[[0-7]] | openbsd2.[[0-7]].*)
168.5024 +	     _LT_TAGVAR(archive_cmds, $1)='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags'
168.5025 +	     _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir'
168.5026 +	     ;;
168.5027 +	   *)
168.5028 +	     _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags'
168.5029 +	     _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir'
168.5030 +	     ;;
168.5031 +	  esac
168.5032 +	fi
168.5033 +      else
168.5034 +	_LT_TAGVAR(ld_shlibs, $1)=no
168.5035 +      fi
168.5036 +      ;;
168.5037 +
168.5038 +    os2*)
168.5039 +      _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir'
168.5040 +      _LT_TAGVAR(hardcode_minus_L, $1)=yes
168.5041 +      _LT_TAGVAR(allow_undefined_flag, $1)=unsupported
168.5042 +      _LT_TAGVAR(archive_cmds, $1)='$ECHO "LIBRARY $libname INITINSTANCE" > $output_objdir/$libname.def~$ECHO "DESCRIPTION \"$libname\"" >> $output_objdir/$libname.def~echo DATA >> $output_objdir/$libname.def~echo " SINGLE NONSHARED" >> $output_objdir/$libname.def~echo EXPORTS >> $output_objdir/$libname.def~emxexp $libobjs >> $output_objdir/$libname.def~$CC -Zdll -Zcrtdll -o $lib $libobjs $deplibs $compiler_flags $output_objdir/$libname.def'
168.5043 +      _LT_TAGVAR(old_archive_from_new_cmds, $1)='emximp -o $output_objdir/$libname.a $output_objdir/$libname.def'
168.5044 +      ;;
168.5045 +
168.5046 +    osf3*)
168.5047 +      if test "$GCC" = yes; then
168.5048 +	_LT_TAGVAR(allow_undefined_flag, $1)=' ${wl}-expect_unresolved ${wl}\*'
168.5049 +	_LT_TAGVAR(archive_cmds, $1)='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version ${wl}$verstring"` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib'
168.5050 +      else
168.5051 +	_LT_TAGVAR(allow_undefined_flag, $1)=' -expect_unresolved \*'
168.5052 +	_LT_TAGVAR(archive_cmds, $1)='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry ${output_objdir}/so_locations -o $lib'
168.5053 +      fi
168.5054 +      _LT_TAGVAR(archive_cmds_need_lc, $1)='no'
168.5055 +      _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir'
168.5056 +      _LT_TAGVAR(hardcode_libdir_separator, $1)=:
168.5057 +      ;;
168.5058 +
168.5059 +    osf4* | osf5*)	# as osf3* with the addition of -msym flag
168.5060 +      if test "$GCC" = yes; then
168.5061 +	_LT_TAGVAR(allow_undefined_flag, $1)=' ${wl}-expect_unresolved ${wl}\*'
168.5062 +	_LT_TAGVAR(archive_cmds, $1)='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags ${wl}-msym ${wl}-soname ${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version ${wl}$verstring"` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib'
168.5063 +	_LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir'
168.5064 +      else
168.5065 +	_LT_TAGVAR(allow_undefined_flag, $1)=' -expect_unresolved \*'
168.5066 +	_LT_TAGVAR(archive_cmds, $1)='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags -msym -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry ${output_objdir}/so_locations -o $lib'
168.5067 +	_LT_TAGVAR(archive_expsym_cmds, $1)='for i in `cat $export_symbols`; do printf "%s %s\\n" -exported_symbol "\$i" >> $lib.exp; done; printf "%s\\n" "-hidden">> $lib.exp~
168.5068 +	$CC -shared${allow_undefined_flag} ${wl}-input ${wl}$lib.exp $compiler_flags $libobjs $deplibs -soname $soname `test -n "$verstring" && $ECHO "-set_version $verstring"` -update_registry ${output_objdir}/so_locations -o $lib~$RM $lib.exp'
168.5069 +
168.5070 +	# Both c and cxx compiler support -rpath directly
168.5071 +	_LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-rpath $libdir'
168.5072 +      fi
168.5073 +      _LT_TAGVAR(archive_cmds_need_lc, $1)='no'
168.5074 +      _LT_TAGVAR(hardcode_libdir_separator, $1)=:
168.5075 +      ;;
168.5076 +
168.5077 +    solaris*)
168.5078 +      _LT_TAGVAR(no_undefined_flag, $1)=' -z defs'
168.5079 +      if test "$GCC" = yes; then
168.5080 +	wlarc='${wl}'
168.5081 +	_LT_TAGVAR(archive_cmds, $1)='$CC -shared ${wl}-z ${wl}text ${wl}-h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags'
168.5082 +	_LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~
168.5083 +	  $CC -shared ${wl}-z ${wl}text ${wl}-M ${wl}$lib.exp ${wl}-h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags~$RM $lib.exp'
168.5084 +      else
168.5085 +	case `$CC -V 2>&1` in
168.5086 +	*"Compilers 5.0"*)
168.5087 +	  wlarc=''
168.5088 +	  _LT_TAGVAR(archive_cmds, $1)='$LD -G${allow_undefined_flag} -h $soname -o $lib $libobjs $deplibs $linker_flags'
168.5089 +	  _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~
168.5090 +	  $LD -G${allow_undefined_flag} -M $lib.exp -h $soname -o $lib $libobjs $deplibs $linker_flags~$RM $lib.exp'
168.5091 +	  ;;
168.5092 +	*)
168.5093 +	  wlarc='${wl}'
168.5094 +	  _LT_TAGVAR(archive_cmds, $1)='$CC -G${allow_undefined_flag} -h $soname -o $lib $libobjs $deplibs $compiler_flags'
168.5095 +	  _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~
168.5096 +	  $CC -G${allow_undefined_flag} -M $lib.exp -h $soname -o $lib $libobjs $deplibs $compiler_flags~$RM $lib.exp'
168.5097 +	  ;;
168.5098 +	esac
168.5099 +      fi
168.5100 +      _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir'
168.5101 +      _LT_TAGVAR(hardcode_shlibpath_var, $1)=no
168.5102 +      case $host_os in
168.5103 +      solaris2.[[0-5]] | solaris2.[[0-5]].*) ;;
168.5104 +      *)
168.5105 +	# The compiler driver will combine and reorder linker options,
168.5106 +	# but understands `-z linker_flag'.  GCC discards it without `$wl',
168.5107 +	# but is careful enough not to reorder.
168.5108 +	# Supported since Solaris 2.6 (maybe 2.5.1?)
168.5109 +	if test "$GCC" = yes; then
168.5110 +	  _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}-z ${wl}allextract$convenience ${wl}-z ${wl}defaultextract'
168.5111 +	else
168.5112 +	  _LT_TAGVAR(whole_archive_flag_spec, $1)='-z allextract$convenience -z defaultextract'
168.5113 +	fi
168.5114 +	;;
168.5115 +      esac
168.5116 +      _LT_TAGVAR(link_all_deplibs, $1)=yes
168.5117 +      ;;
168.5118 +
168.5119 +    sunos4*)
168.5120 +      if test "x$host_vendor" = xsequent; then
168.5121 +	# Use $CC to link under sequent, because it throws in some extra .o
168.5122 +	# files that make .init and .fini sections work.
168.5123 +	_LT_TAGVAR(archive_cmds, $1)='$CC -G ${wl}-h $soname -o $lib $libobjs $deplibs $compiler_flags'
168.5124 +      else
168.5125 +	_LT_TAGVAR(archive_cmds, $1)='$LD -assert pure-text -Bstatic -o $lib $libobjs $deplibs $linker_flags'
168.5126 +      fi
168.5127 +      _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir'
168.5128 +      _LT_TAGVAR(hardcode_direct, $1)=yes
168.5129 +      _LT_TAGVAR(hardcode_minus_L, $1)=yes
168.5130 +      _LT_TAGVAR(hardcode_shlibpath_var, $1)=no
168.5131 +      ;;
168.5132 +
168.5133 +    sysv4)
168.5134 +      case $host_vendor in
168.5135 +	sni)
168.5136 +	  _LT_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
168.5137 +	  _LT_TAGVAR(hardcode_direct, $1)=yes # is this really true???
168.5138 +	;;
168.5139 +	siemens)
168.5140 +	  ## LD is ld it makes a PLAMLIB
168.5141 +	  ## CC just makes a GrossModule.
168.5142 +	  _LT_TAGVAR(archive_cmds, $1)='$LD -G -o $lib $libobjs $deplibs $linker_flags'
168.5143 +	  _LT_TAGVAR(reload_cmds, $1)='$CC -r -o $output$reload_objs'
168.5144 +	  _LT_TAGVAR(hardcode_direct, $1)=no
168.5145 +        ;;
168.5146 +	motorola)
168.5147 +	  _LT_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
168.5148 +	  _LT_TAGVAR(hardcode_direct, $1)=no #Motorola manual says yes, but my tests say they lie
168.5149 +	;;
168.5150 +      esac
168.5151 +      runpath_var='LD_RUN_PATH'
168.5152 +      _LT_TAGVAR(hardcode_shlibpath_var, $1)=no
168.5153 +      ;;
168.5154 +
168.5155 +    sysv4.3*)
168.5156 +      _LT_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
168.5157 +      _LT_TAGVAR(hardcode_shlibpath_var, $1)=no
168.5158 +      _LT_TAGVAR(export_dynamic_flag_spec, $1)='-Bexport'
168.5159 +      ;;
168.5160 +
168.5161 +    sysv4*MP*)
168.5162 +      if test -d /usr/nec; then
168.5163 +	_LT_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
168.5164 +	_LT_TAGVAR(hardcode_shlibpath_var, $1)=no
168.5165 +	runpath_var=LD_RUN_PATH
168.5166 +	hardcode_runpath_var=yes
168.5167 +	_LT_TAGVAR(ld_shlibs, $1)=yes
168.5168 +      fi
168.5169 +      ;;
168.5170 +
168.5171 +    sysv4*uw2* | sysv5OpenUNIX* | sysv5UnixWare7.[[01]].[[10]]* | unixware7* | sco3.2v5.0.[[024]]*)
168.5172 +      _LT_TAGVAR(no_undefined_flag, $1)='${wl}-z,text'
168.5173 +      _LT_TAGVAR(archive_cmds_need_lc, $1)=no
168.5174 +      _LT_TAGVAR(hardcode_shlibpath_var, $1)=no
168.5175 +      runpath_var='LD_RUN_PATH'
168.5176 +
168.5177 +      if test "$GCC" = yes; then
168.5178 +	_LT_TAGVAR(archive_cmds, $1)='$CC -shared ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
168.5179 +	_LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
168.5180 +      else
168.5181 +	_LT_TAGVAR(archive_cmds, $1)='$CC -G ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
168.5182 +	_LT_TAGVAR(archive_expsym_cmds, $1)='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
168.5183 +      fi
168.5184 +      ;;
168.5185 +
168.5186 +    sysv5* | sco3.2v5* | sco5v6*)
168.5187 +      # Note: We can NOT use -z defs as we might desire, because we do not
168.5188 +      # link with -lc, and that would cause any symbols used from libc to
168.5189 +      # always be unresolved, which means just about no library would
168.5190 +      # ever link correctly.  If we're not using GNU ld we use -z text
168.5191 +      # though, which does catch some bad symbols but isn't as heavy-handed
168.5192 +      # as -z defs.
168.5193 +      _LT_TAGVAR(no_undefined_flag, $1)='${wl}-z,text'
168.5194 +      _LT_TAGVAR(allow_undefined_flag, $1)='${wl}-z,nodefs'
168.5195 +      _LT_TAGVAR(archive_cmds_need_lc, $1)=no
168.5196 +      _LT_TAGVAR(hardcode_shlibpath_var, $1)=no
168.5197 +      _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-R,$libdir'
168.5198 +      _LT_TAGVAR(hardcode_libdir_separator, $1)=':'
168.5199 +      _LT_TAGVAR(link_all_deplibs, $1)=yes
168.5200 +      _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-Bexport'
168.5201 +      runpath_var='LD_RUN_PATH'
168.5202 +
168.5203 +      if test "$GCC" = yes; then
168.5204 +	_LT_TAGVAR(archive_cmds, $1)='$CC -shared ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
168.5205 +	_LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
168.5206 +      else
168.5207 +	_LT_TAGVAR(archive_cmds, $1)='$CC -G ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
168.5208 +	_LT_TAGVAR(archive_expsym_cmds, $1)='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
168.5209 +      fi
168.5210 +      ;;
168.5211 +
168.5212 +    uts4*)
168.5213 +      _LT_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
168.5214 +      _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir'
168.5215 +      _LT_TAGVAR(hardcode_shlibpath_var, $1)=no
168.5216 +      ;;
168.5217 +
168.5218 +    *)
168.5219 +      _LT_TAGVAR(ld_shlibs, $1)=no
168.5220 +      ;;
168.5221 +    esac
168.5222 +
168.5223 +    if test x$host_vendor = xsni; then
168.5224 +      case $host in
168.5225 +      sysv4 | sysv4.2uw2* | sysv4.3* | sysv5*)
168.5226 +	_LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-Blargedynsym'
168.5227 +	;;
168.5228 +      esac
168.5229 +    fi
168.5230 +  fi
168.5231 +])
168.5232 +AC_MSG_RESULT([$_LT_TAGVAR(ld_shlibs, $1)])
168.5233 +test "$_LT_TAGVAR(ld_shlibs, $1)" = no && can_build_shared=no
168.5234 +
168.5235 +_LT_TAGVAR(with_gnu_ld, $1)=$with_gnu_ld
168.5236 +
168.5237 +_LT_DECL([], [libext], [0], [Old archive suffix (normally "a")])dnl
168.5238 +_LT_DECL([], [shrext_cmds], [1], [Shared library suffix (normally ".so")])dnl
168.5239 +_LT_DECL([], [extract_expsyms_cmds], [2],
168.5240 +    [The commands to extract the exported symbol list from a shared archive])
168.5241 +
168.5242 +#
168.5243 +# Do we need to explicitly link libc?
168.5244 +#
168.5245 +case "x$_LT_TAGVAR(archive_cmds_need_lc, $1)" in
168.5246 +x|xyes)
168.5247 +  # Assume -lc should be added
168.5248 +  _LT_TAGVAR(archive_cmds_need_lc, $1)=yes
168.5249 +
168.5250 +  if test "$enable_shared" = yes && test "$GCC" = yes; then
168.5251 +    case $_LT_TAGVAR(archive_cmds, $1) in
168.5252 +    *'~'*)
168.5253 +      # FIXME: we may have to deal with multi-command sequences.
168.5254 +      ;;
168.5255 +    '$CC '*)
168.5256 +      # Test whether the compiler implicitly links with -lc since on some
168.5257 +      # systems, -lgcc has to come before -lc. If gcc already passes -lc
168.5258 +      # to ld, don't add -lc before -lgcc.
168.5259 +      AC_CACHE_CHECK([whether -lc should be explicitly linked in],
168.5260 +	[lt_cv_]_LT_TAGVAR(archive_cmds_need_lc, $1),
168.5261 +	[$RM conftest*
168.5262 +	echo "$lt_simple_compile_test_code" > conftest.$ac_ext
168.5263 +
168.5264 +	if AC_TRY_EVAL(ac_compile) 2>conftest.err; then
168.5265 +	  soname=conftest
168.5266 +	  lib=conftest
168.5267 +	  libobjs=conftest.$ac_objext
168.5268 +	  deplibs=
168.5269 +	  wl=$_LT_TAGVAR(lt_prog_compiler_wl, $1)
168.5270 +	  pic_flag=$_LT_TAGVAR(lt_prog_compiler_pic, $1)
168.5271 +	  compiler_flags=-v
168.5272 +	  linker_flags=-v
168.5273 +	  verstring=
168.5274 +	  output_objdir=.
168.5275 +	  libname=conftest
168.5276 +	  lt_save_allow_undefined_flag=$_LT_TAGVAR(allow_undefined_flag, $1)
168.5277 +	  _LT_TAGVAR(allow_undefined_flag, $1)=
168.5278 +	  if AC_TRY_EVAL(_LT_TAGVAR(archive_cmds, $1) 2\>\&1 \| $GREP \" -lc \" \>/dev/null 2\>\&1)
168.5279 +	  then
168.5280 +	    lt_cv_[]_LT_TAGVAR(archive_cmds_need_lc, $1)=no
168.5281 +	  else
168.5282 +	    lt_cv_[]_LT_TAGVAR(archive_cmds_need_lc, $1)=yes
168.5283 +	  fi
168.5284 +	  _LT_TAGVAR(allow_undefined_flag, $1)=$lt_save_allow_undefined_flag
168.5285 +	else
168.5286 +	  cat conftest.err 1>&5
168.5287 +	fi
168.5288 +	$RM conftest*
168.5289 +	])
168.5290 +      _LT_TAGVAR(archive_cmds_need_lc, $1)=$lt_cv_[]_LT_TAGVAR(archive_cmds_need_lc, $1)
168.5291 +      ;;
168.5292 +    esac
168.5293 +  fi
168.5294 +  ;;
168.5295 +esac
168.5296 +
168.5297 +_LT_TAGDECL([build_libtool_need_lc], [archive_cmds_need_lc], [0],
168.5298 +    [Whether or not to add -lc for building shared libraries])
168.5299 +_LT_TAGDECL([allow_libtool_libs_with_static_runtimes],
168.5300 +    [enable_shared_with_static_runtimes], [0],
168.5301 +    [Whether or not to disallow shared libs when runtime libs are static])
168.5302 +_LT_TAGDECL([], [export_dynamic_flag_spec], [1],
168.5303 +    [Compiler flag to allow reflexive dlopens])
168.5304 +_LT_TAGDECL([], [whole_archive_flag_spec], [1],
168.5305 +    [Compiler flag to generate shared objects directly from archives])
168.5306 +_LT_TAGDECL([], [compiler_needs_object], [1],
168.5307 +    [Whether the compiler copes with passing no objects directly])
168.5308 +_LT_TAGDECL([], [old_archive_from_new_cmds], [2],
168.5309 +    [Create an old-style archive from a shared archive])
168.5310 +_LT_TAGDECL([], [old_archive_from_expsyms_cmds], [2],
168.5311 +    [Create a temporary old-style archive to link instead of a shared archive])
168.5312 +_LT_TAGDECL([], [archive_cmds], [2], [Commands used to build a shared archive])
168.5313 +_LT_TAGDECL([], [archive_expsym_cmds], [2])
168.5314 +_LT_TAGDECL([], [module_cmds], [2],
168.5315 +    [Commands used to build a loadable module if different from building
168.5316 +    a shared archive.])
168.5317 +_LT_TAGDECL([], [module_expsym_cmds], [2])
168.5318 +_LT_TAGDECL([], [with_gnu_ld], [1],
168.5319 +    [Whether we are building with GNU ld or not])
168.5320 +_LT_TAGDECL([], [allow_undefined_flag], [1],
168.5321 +    [Flag that allows shared libraries with undefined symbols to be built])
168.5322 +_LT_TAGDECL([], [no_undefined_flag], [1],
168.5323 +    [Flag that enforces no undefined symbols])
168.5324 +_LT_TAGDECL([], [hardcode_libdir_flag_spec], [1],
168.5325 +    [Flag to hardcode $libdir into a binary during linking.
168.5326 +    This must work even if $libdir does not exist])
168.5327 +_LT_TAGDECL([], [hardcode_libdir_flag_spec_ld], [1],
168.5328 +    [[If ld is used when linking, flag to hardcode $libdir into a binary
168.5329 +    during linking.  This must work even if $libdir does not exist]])
168.5330 +_LT_TAGDECL([], [hardcode_libdir_separator], [1],
168.5331 +    [Whether we need a single "-rpath" flag with a separated argument])
168.5332 +_LT_TAGDECL([], [hardcode_direct], [0],
168.5333 +    [Set to "yes" if using DIR/libNAME${shared_ext} during linking hardcodes
168.5334 +    DIR into the resulting binary])
168.5335 +_LT_TAGDECL([], [hardcode_direct_absolute], [0],
168.5336 +    [Set to "yes" if using DIR/libNAME${shared_ext} during linking hardcodes
168.5337 +    DIR into the resulting binary and the resulting library dependency is
168.5338 +    "absolute", i.e impossible to change by setting ${shlibpath_var} if the
168.5339 +    library is relocated])
168.5340 +_LT_TAGDECL([], [hardcode_minus_L], [0],
168.5341 +    [Set to "yes" if using the -LDIR flag during linking hardcodes DIR
168.5342 +    into the resulting binary])
168.5343 +_LT_TAGDECL([], [hardcode_shlibpath_var], [0],
168.5344 +    [Set to "yes" if using SHLIBPATH_VAR=DIR during linking hardcodes DIR
168.5345 +    into the resulting binary])
168.5346 +_LT_TAGDECL([], [hardcode_automatic], [0],
168.5347 +    [Set to "yes" if building a shared library automatically hardcodes DIR
168.5348 +    into the library and all subsequent libraries and executables linked
168.5349 +    against it])
168.5350 +_LT_TAGDECL([], [inherit_rpath], [0],
168.5351 +    [Set to yes if linker adds runtime paths of dependent libraries
168.5352 +    to runtime path list])
168.5353 +_LT_TAGDECL([], [link_all_deplibs], [0],
168.5354 +    [Whether libtool must link a program against all its dependency libraries])
168.5355 +_LT_TAGDECL([], [fix_srcfile_path], [1],
168.5356 +    [Fix the shell variable $srcfile for the compiler])
168.5357 +_LT_TAGDECL([], [always_export_symbols], [0],
168.5358 +    [Set to "yes" if exported symbols are required])
168.5359 +_LT_TAGDECL([], [export_symbols_cmds], [2],
168.5360 +    [The commands to list exported symbols])
168.5361 +_LT_TAGDECL([], [exclude_expsyms], [1],
168.5362 +    [Symbols that should not be listed in the preloaded symbols])
168.5363 +_LT_TAGDECL([], [include_expsyms], [1],
168.5364 +    [Symbols that must always be exported])
168.5365 +_LT_TAGDECL([], [prelink_cmds], [2],
168.5366 +    [Commands necessary for linking programs (against libraries) with templates])
168.5367 +_LT_TAGDECL([], [file_list_spec], [1],
168.5368 +    [Specify filename containing input files])
168.5369 +dnl FIXME: Not yet implemented
168.5370 +dnl _LT_TAGDECL([], [thread_safe_flag_spec], [1],
168.5371 +dnl    [Compiler flag to generate thread safe objects])
168.5372 +])# _LT_LINKER_SHLIBS
168.5373 +
168.5374 +
168.5375 +# _LT_LANG_C_CONFIG([TAG])
168.5376 +# ------------------------
168.5377 +# Ensure that the configuration variables for a C compiler are suitably
168.5378 +# defined.  These variables are subsequently used by _LT_CONFIG to write
168.5379 +# the compiler configuration to `libtool'.
168.5380 +m4_defun([_LT_LANG_C_CONFIG],
168.5381 +[m4_require([_LT_DECL_EGREP])dnl
168.5382 +lt_save_CC="$CC"
168.5383 +AC_LANG_PUSH(C)
168.5384 +
168.5385 +# Source file extension for C test sources.
168.5386 +ac_ext=c
168.5387 +
168.5388 +# Object file extension for compiled C test sources.
168.5389 +objext=o
168.5390 +_LT_TAGVAR(objext, $1)=$objext
168.5391 +
168.5392 +# Code to be used in simple compile tests
168.5393 +lt_simple_compile_test_code="int some_variable = 0;"
168.5394 +
168.5395 +# Code to be used in simple link tests
168.5396 +lt_simple_link_test_code='int main(){return(0);}'
168.5397 +
168.5398 +_LT_TAG_COMPILER
168.5399 +# Save the default compiler, since it gets overwritten when the other
168.5400 +# tags are being tested, and _LT_TAGVAR(compiler, []) is a NOP.
168.5401 +compiler_DEFAULT=$CC
168.5402 +
168.5403 +# save warnings/boilerplate of simple test code
168.5404 +_LT_COMPILER_BOILERPLATE
168.5405 +_LT_LINKER_BOILERPLATE
168.5406 +
168.5407 +## CAVEAT EMPTOR:
168.5408 +## There is no encapsulation within the following macros, do not change
168.5409 +## the running order or otherwise move them around unless you know exactly
168.5410 +## what you are doing...
168.5411 +if test -n "$compiler"; then
168.5412 +  _LT_COMPILER_NO_RTTI($1)
168.5413 +  _LT_COMPILER_PIC($1)
168.5414 +  _LT_COMPILER_C_O($1)
168.5415 +  _LT_COMPILER_FILE_LOCKS($1)
168.5416 +  _LT_LINKER_SHLIBS($1)
168.5417 +  _LT_SYS_DYNAMIC_LINKER($1)
168.5418 +  _LT_LINKER_HARDCODE_LIBPATH($1)
168.5419 +  LT_SYS_DLOPEN_SELF
168.5420 +  _LT_CMD_STRIPLIB
168.5421 +
168.5422 +  # Report which library types will actually be built
168.5423 +  AC_MSG_CHECKING([if libtool supports shared libraries])
168.5424 +  AC_MSG_RESULT([$can_build_shared])
168.5425 +
168.5426 +  AC_MSG_CHECKING([whether to build shared libraries])
168.5427 +  test "$can_build_shared" = "no" && enable_shared=no
168.5428 +
168.5429 +  # On AIX, shared libraries and static libraries use the same namespace, and
168.5430 +  # are all built from PIC.
168.5431 +  case $host_os in
168.5432 +  aix3*)
168.5433 +    test "$enable_shared" = yes && enable_static=no
168.5434 +    if test -n "$RANLIB"; then
168.5435 +      archive_cmds="$archive_cmds~\$RANLIB \$lib"
168.5436 +      postinstall_cmds='$RANLIB $lib'
168.5437 +    fi
168.5438 +    ;;
168.5439 +
168.5440 +  aix[[4-9]]*)
168.5441 +    if test "$host_cpu" != ia64 && test "$aix_use_runtimelinking" = no ; then
168.5442 +      test "$enable_shared" = yes && enable_static=no
168.5443 +    fi
168.5444 +    ;;
168.5445 +  esac
168.5446 +  AC_MSG_RESULT([$enable_shared])
168.5447 +
168.5448 +  AC_MSG_CHECKING([whether to build static libraries])
168.5449 +  # Make sure either enable_shared or enable_static is yes.
168.5450 +  test "$enable_shared" = yes || enable_static=yes
168.5451 +  AC_MSG_RESULT([$enable_static])
168.5452 +
168.5453 +  _LT_CONFIG($1)
168.5454 +fi
168.5455 +AC_LANG_POP
168.5456 +CC="$lt_save_CC"
168.5457 +])# _LT_LANG_C_CONFIG
168.5458 +
168.5459 +
168.5460 +# _LT_LANG_CXX_CONFIG([TAG])
168.5461 +# --------------------------
168.5462 +# Ensure that the configuration variables for a C++ compiler are suitably
168.5463 +# defined.  These variables are subsequently used by _LT_CONFIG to write
168.5464 +# the compiler configuration to `libtool'.
168.5465 +m4_defun([_LT_LANG_CXX_CONFIG],
168.5466 +[m4_require([_LT_FILEUTILS_DEFAULTS])dnl
168.5467 +m4_require([_LT_DECL_EGREP])dnl
168.5468 +if test -n "$CXX" && ( test "X$CXX" != "Xno" &&
168.5469 +    ( (test "X$CXX" = "Xg++" && `g++ -v >/dev/null 2>&1` ) ||
168.5470 +    (test "X$CXX" != "Xg++"))) ; then
168.5471 +  AC_PROG_CXXCPP
168.5472 +else
168.5473 +  _lt_caught_CXX_error=yes
168.5474 +fi
168.5475 +
168.5476 +AC_LANG_PUSH(C++)
168.5477 +_LT_TAGVAR(archive_cmds_need_lc, $1)=no
168.5478 +_LT_TAGVAR(allow_undefined_flag, $1)=
168.5479 +_LT_TAGVAR(always_export_symbols, $1)=no
168.5480 +_LT_TAGVAR(archive_expsym_cmds, $1)=
168.5481 +_LT_TAGVAR(compiler_needs_object, $1)=no
168.5482 +_LT_TAGVAR(export_dynamic_flag_spec, $1)=
168.5483 +_LT_TAGVAR(hardcode_direct, $1)=no
168.5484 +_LT_TAGVAR(hardcode_direct_absolute, $1)=no
168.5485 +_LT_TAGVAR(hardcode_libdir_flag_spec, $1)=
168.5486 +_LT_TAGVAR(hardcode_libdir_flag_spec_ld, $1)=
168.5487 +_LT_TAGVAR(hardcode_libdir_separator, $1)=
168.5488 +_LT_TAGVAR(hardcode_minus_L, $1)=no
168.5489 +_LT_TAGVAR(hardcode_shlibpath_var, $1)=unsupported
168.5490 +_LT_TAGVAR(hardcode_automatic, $1)=no
168.5491 +_LT_TAGVAR(inherit_rpath, $1)=no
168.5492 +_LT_TAGVAR(module_cmds, $1)=
168.5493 +_LT_TAGVAR(module_expsym_cmds, $1)=
168.5494 +_LT_TAGVAR(link_all_deplibs, $1)=unknown
168.5495 +_LT_TAGVAR(old_archive_cmds, $1)=$old_archive_cmds
168.5496 +_LT_TAGVAR(reload_flag, $1)=$reload_flag
168.5497 +_LT_TAGVAR(reload_cmds, $1)=$reload_cmds
168.5498 +_LT_TAGVAR(no_undefined_flag, $1)=
168.5499 +_LT_TAGVAR(whole_archive_flag_spec, $1)=
168.5500 +_LT_TAGVAR(enable_shared_with_static_runtimes, $1)=no
168.5501 +
168.5502 +# Source file extension for C++ test sources.
168.5503 +ac_ext=cpp
168.5504 +
168.5505 +# Object file extension for compiled C++ test sources.
168.5506 +objext=o
168.5507 +_LT_TAGVAR(objext, $1)=$objext
168.5508 +
168.5509 +# No sense in running all these tests if we already determined that
168.5510 +# the CXX compiler isn't working.  Some variables (like enable_shared)
168.5511 +# are currently assumed to apply to all compilers on this platform,
168.5512 +# and will be corrupted by setting them based on a non-working compiler.
168.5513 +if test "$_lt_caught_CXX_error" != yes; then
168.5514 +  # Code to be used in simple compile tests
168.5515 +  lt_simple_compile_test_code="int some_variable = 0;"
168.5516 +
168.5517 +  # Code to be used in simple link tests
168.5518 +  lt_simple_link_test_code='int main(int, char *[[]]) { return(0); }'
168.5519 +
168.5520 +  # ltmain only uses $CC for tagged configurations so make sure $CC is set.
168.5521 +  _LT_TAG_COMPILER
168.5522 +
168.5523 +  # save warnings/boilerplate of simple test code
168.5524 +  _LT_COMPILER_BOILERPLATE
168.5525 +  _LT_LINKER_BOILERPLATE
168.5526 +
168.5527 +  # Allow CC to be a program name with arguments.
168.5528 +  lt_save_CC=$CC
168.5529 +  lt_save_LD=$LD
168.5530 +  lt_save_GCC=$GCC
168.5531 +  GCC=$GXX
168.5532 +  lt_save_with_gnu_ld=$with_gnu_ld
168.5533 +  lt_save_path_LD=$lt_cv_path_LD
168.5534 +  if test -n "${lt_cv_prog_gnu_ldcxx+set}"; then
168.5535 +    lt_cv_prog_gnu_ld=$lt_cv_prog_gnu_ldcxx
168.5536 +  else
168.5537 +    $as_unset lt_cv_prog_gnu_ld
168.5538 +  fi
168.5539 +  if test -n "${lt_cv_path_LDCXX+set}"; then
168.5540 +    lt_cv_path_LD=$lt_cv_path_LDCXX
168.5541 +  else
168.5542 +    $as_unset lt_cv_path_LD
168.5543 +  fi
168.5544 +  test -z "${LDCXX+set}" || LD=$LDCXX
168.5545 +  CC=${CXX-"c++"}
168.5546 +  compiler=$CC
168.5547 +  _LT_TAGVAR(compiler, $1)=$CC
168.5548 +  _LT_CC_BASENAME([$compiler])
168.5549 +
168.5550 +  if test -n "$compiler"; then
168.5551 +    # We don't want -fno-exception when compiling C++ code, so set the
168.5552 +    # no_builtin_flag separately
168.5553 +    if test "$GXX" = yes; then
168.5554 +      _LT_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)=' -fno-builtin'
168.5555 +    else
168.5556 +      _LT_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)=
168.5557 +    fi
168.5558 +
168.5559 +    if test "$GXX" = yes; then
168.5560 +      # Set up default GNU C++ configuration
168.5561 +
168.5562 +      LT_PATH_LD
168.5563 +
168.5564 +      # Check if GNU C++ uses GNU ld as the underlying linker, since the
168.5565 +      # archiving commands below assume that GNU ld is being used.
168.5566 +      if test "$with_gnu_ld" = yes; then
168.5567 +        _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname -o $lib'
168.5568 +        _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
168.5569 +
168.5570 +        _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir'
168.5571 +        _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-dynamic'
168.5572 +
168.5573 +        # If archive_cmds runs LD, not CC, wlarc should be empty
168.5574 +        # XXX I think wlarc can be eliminated in ltcf-cxx, but I need to
168.5575 +        #     investigate it a little bit more. (MM)
168.5576 +        wlarc='${wl}'
168.5577 +
168.5578 +        # ancient GNU ld didn't support --whole-archive et. al.
168.5579 +        if eval "`$CC -print-prog-name=ld` --help 2>&1" |
168.5580 +	  $GREP 'no-whole-archive' > /dev/null; then
168.5581 +          _LT_TAGVAR(whole_archive_flag_spec, $1)="$wlarc"'--whole-archive$convenience '"$wlarc"'--no-whole-archive'
168.5582 +        else
168.5583 +          _LT_TAGVAR(whole_archive_flag_spec, $1)=
168.5584 +        fi
168.5585 +      else
168.5586 +        with_gnu_ld=no
168.5587 +        wlarc=
168.5588 +
168.5589 +        # A generic and very simple default shared library creation
168.5590 +        # command for GNU C++ for the case where it uses the native
168.5591 +        # linker, instead of GNU ld.  If possible, this setting should
168.5592 +        # overridden to take advantage of the native linker features on
168.5593 +        # the platform it is being used on.
168.5594 +        _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $lib'
168.5595 +      fi
168.5596 +
168.5597 +      # Commands to make compiler produce verbose output that lists
168.5598 +      # what "hidden" libraries, object files and flags are used when
168.5599 +      # linking a shared library.
168.5600 +      output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP -v "^Configured with:" | $GREP "\-L"'
168.5601 +
168.5602 +    else
168.5603 +      GXX=no
168.5604 +      with_gnu_ld=no
168.5605 +      wlarc=
168.5606 +    fi
168.5607 +
168.5608 +    # PORTME: fill in a description of your system's C++ link characteristics
168.5609 +    AC_MSG_CHECKING([whether the $compiler linker ($LD) supports shared libraries])
168.5610 +    _LT_TAGVAR(ld_shlibs, $1)=yes
168.5611 +    case $host_os in
168.5612 +      aix3*)
168.5613 +        # FIXME: insert proper C++ library support
168.5614 +        _LT_TAGVAR(ld_shlibs, $1)=no
168.5615 +        ;;
168.5616 +      aix[[4-9]]*)
168.5617 +        if test "$host_cpu" = ia64; then
168.5618 +          # On IA64, the linker does run time linking by default, so we don't
168.5619 +          # have to do anything special.
168.5620 +          aix_use_runtimelinking=no
168.5621 +          exp_sym_flag='-Bexport'
168.5622 +          no_entry_flag=""
168.5623 +        else
168.5624 +          aix_use_runtimelinking=no
168.5625 +
168.5626 +          # Test if we are trying to use run time linking or normal
168.5627 +          # AIX style linking. If -brtl is somewhere in LDFLAGS, we
168.5628 +          # need to do runtime linking.
168.5629 +          case $host_os in aix4.[[23]]|aix4.[[23]].*|aix[[5-9]]*)
168.5630 +	    for ld_flag in $LDFLAGS; do
168.5631 +	      case $ld_flag in
168.5632 +	      *-brtl*)
168.5633 +	        aix_use_runtimelinking=yes
168.5634 +	        break
168.5635 +	        ;;
168.5636 +	      esac
168.5637 +	    done
168.5638 +	    ;;
168.5639 +          esac
168.5640 +
168.5641 +          exp_sym_flag='-bexport'
168.5642 +          no_entry_flag='-bnoentry'
168.5643 +        fi
168.5644 +
168.5645 +        # When large executables or shared objects are built, AIX ld can
168.5646 +        # have problems creating the table of contents.  If linking a library
168.5647 +        # or program results in "error TOC overflow" add -mminimal-toc to
168.5648 +        # CXXFLAGS/CFLAGS for g++/gcc.  In the cases where that is not
168.5649 +        # enough to fix the problem, add -Wl,-bbigtoc to LDFLAGS.
168.5650 +
168.5651 +        _LT_TAGVAR(archive_cmds, $1)=''
168.5652 +        _LT_TAGVAR(hardcode_direct, $1)=yes
168.5653 +        _LT_TAGVAR(hardcode_direct_absolute, $1)=yes
168.5654 +        _LT_TAGVAR(hardcode_libdir_separator, $1)=':'
168.5655 +        _LT_TAGVAR(link_all_deplibs, $1)=yes
168.5656 +        _LT_TAGVAR(file_list_spec, $1)='${wl}-f,'
168.5657 +
168.5658 +        if test "$GXX" = yes; then
168.5659 +          case $host_os in aix4.[[012]]|aix4.[[012]].*)
168.5660 +          # We only want to do this on AIX 4.2 and lower, the check
168.5661 +          # below for broken collect2 doesn't work under 4.3+
168.5662 +	  collect2name=`${CC} -print-prog-name=collect2`
168.5663 +	  if test -f "$collect2name" &&
168.5664 +	     strings "$collect2name" | $GREP resolve_lib_name >/dev/null
168.5665 +	  then
168.5666 +	    # We have reworked collect2
168.5667 +	    :
168.5668 +	  else
168.5669 +	    # We have old collect2
168.5670 +	    _LT_TAGVAR(hardcode_direct, $1)=unsupported
168.5671 +	    # It fails to find uninstalled libraries when the uninstalled
168.5672 +	    # path is not listed in the libpath.  Setting hardcode_minus_L
168.5673 +	    # to unsupported forces relinking
168.5674 +	    _LT_TAGVAR(hardcode_minus_L, $1)=yes
168.5675 +	    _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir'
168.5676 +	    _LT_TAGVAR(hardcode_libdir_separator, $1)=
168.5677 +	  fi
168.5678 +          esac
168.5679 +          shared_flag='-shared'
168.5680 +	  if test "$aix_use_runtimelinking" = yes; then
168.5681 +	    shared_flag="$shared_flag "'${wl}-G'
168.5682 +	  fi
168.5683 +        else
168.5684 +          # not using gcc
168.5685 +          if test "$host_cpu" = ia64; then
168.5686 +	  # VisualAge C++, Version 5.5 for AIX 5L for IA-64, Beta 3 Release
168.5687 +	  # chokes on -Wl,-G. The following line is correct:
168.5688 +	  shared_flag='-G'
168.5689 +          else
168.5690 +	    if test "$aix_use_runtimelinking" = yes; then
168.5691 +	      shared_flag='${wl}-G'
168.5692 +	    else
168.5693 +	      shared_flag='${wl}-bM:SRE'
168.5694 +	    fi
168.5695 +          fi
168.5696 +        fi
168.5697 +
168.5698 +        _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-bexpall'
168.5699 +        # It seems that -bexpall does not export symbols beginning with
168.5700 +        # underscore (_), so it is better to generate a list of symbols to
168.5701 +	# export.
168.5702 +        _LT_TAGVAR(always_export_symbols, $1)=yes
168.5703 +        if test "$aix_use_runtimelinking" = yes; then
168.5704 +          # Warning - without using the other runtime loading flags (-brtl),
168.5705 +          # -berok will link without error, but may produce a broken library.
168.5706 +          _LT_TAGVAR(allow_undefined_flag, $1)='-berok'
168.5707 +          # Determine the default libpath from the value encoded in an empty
168.5708 +          # executable.
168.5709 +          _LT_SYS_MODULE_PATH_AIX
168.5710 +          _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-blibpath:$libdir:'"$aix_libpath"
168.5711 +
168.5712 +          _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags `if test "x${allow_undefined_flag}" != "x"; then func_echo_all "${wl}${allow_undefined_flag}"; else :; fi` '"\${wl}$exp_sym_flag:\$export_symbols $shared_flag"
168.5713 +        else
168.5714 +          if test "$host_cpu" = ia64; then
168.5715 +	    _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-R $libdir:/usr/lib:/lib'
168.5716 +	    _LT_TAGVAR(allow_undefined_flag, $1)="-z nodefs"
168.5717 +	    _LT_TAGVAR(archive_expsym_cmds, $1)="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags ${wl}${allow_undefined_flag} '"\${wl}$exp_sym_flag:\$export_symbols"
168.5718 +          else
168.5719 +	    # Determine the default libpath from the value encoded in an
168.5720 +	    # empty executable.
168.5721 +	    _LT_SYS_MODULE_PATH_AIX
168.5722 +	    _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-blibpath:$libdir:'"$aix_libpath"
168.5723 +	    # Warning - without using the other run time loading flags,
168.5724 +	    # -berok will link without error, but may produce a broken library.
168.5725 +	    _LT_TAGVAR(no_undefined_flag, $1)=' ${wl}-bernotok'
168.5726 +	    _LT_TAGVAR(allow_undefined_flag, $1)=' ${wl}-berok'
168.5727 +	    if test "$with_gnu_ld" = yes; then
168.5728 +	      # We only use this code for GNU lds that support --whole-archive.
168.5729 +	      _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive$convenience ${wl}--no-whole-archive'
168.5730 +	    else
168.5731 +	      # Exported symbols can be pulled into shared objects from archives
168.5732 +	      _LT_TAGVAR(whole_archive_flag_spec, $1)='$convenience'
168.5733 +	    fi
168.5734 +	    _LT_TAGVAR(archive_cmds_need_lc, $1)=yes
168.5735 +	    # This is similar to how AIX traditionally builds its shared
168.5736 +	    # libraries.
168.5737 +	    _LT_TAGVAR(archive_expsym_cmds, $1)="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs ${wl}-bnoentry $compiler_flags ${wl}-bE:$export_symbols${allow_undefined_flag}~$AR $AR_FLAGS $output_objdir/$libname$release.a $output_objdir/$soname'
168.5738 +          fi
168.5739 +        fi
168.5740 +        ;;
168.5741 +
168.5742 +      beos*)
168.5743 +	if $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then
168.5744 +	  _LT_TAGVAR(allow_undefined_flag, $1)=unsupported
168.5745 +	  # Joseph Beckenbach <jrb3@best.com> says some releases of gcc
168.5746 +	  # support --undefined.  This deserves some investigation.  FIXME
168.5747 +	  _LT_TAGVAR(archive_cmds, $1)='$CC -nostart $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
168.5748 +	else
168.5749 +	  _LT_TAGVAR(ld_shlibs, $1)=no
168.5750 +	fi
168.5751 +	;;
168.5752 +
168.5753 +      chorus*)
168.5754 +        case $cc_basename in
168.5755 +          *)
168.5756 +	  # FIXME: insert proper C++ library support
168.5757 +	  _LT_TAGVAR(ld_shlibs, $1)=no
168.5758 +	  ;;
168.5759 +        esac
168.5760 +        ;;
168.5761 +
168.5762 +      cygwin* | mingw* | pw32* | cegcc*)
168.5763 +        # _LT_TAGVAR(hardcode_libdir_flag_spec, $1) is actually meaningless,
168.5764 +        # as there is no search path for DLLs.
168.5765 +        _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir'
168.5766 +        _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-all-symbols'
168.5767 +        _LT_TAGVAR(allow_undefined_flag, $1)=unsupported
168.5768 +        _LT_TAGVAR(always_export_symbols, $1)=no
168.5769 +        _LT_TAGVAR(enable_shared_with_static_runtimes, $1)=yes
168.5770 +
168.5771 +        if $LD --help 2>&1 | $GREP 'auto-import' > /dev/null; then
168.5772 +          _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib'
168.5773 +          # If the export-symbols file already is a .def file (1st line
168.5774 +          # is EXPORTS), use it as is; otherwise, prepend...
168.5775 +          _LT_TAGVAR(archive_expsym_cmds, $1)='if test "x`$SED 1q $export_symbols`" = xEXPORTS; then
168.5776 +	    cp $export_symbols $output_objdir/$soname.def;
168.5777 +          else
168.5778 +	    echo EXPORTS > $output_objdir/$soname.def;
168.5779 +	    cat $export_symbols >> $output_objdir/$soname.def;
168.5780 +          fi~
168.5781 +          $CC -shared -nostdlib $output_objdir/$soname.def $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib'
168.5782 +        else
168.5783 +          _LT_TAGVAR(ld_shlibs, $1)=no
168.5784 +        fi
168.5785 +        ;;
168.5786 +      darwin* | rhapsody*)
168.5787 +        _LT_DARWIN_LINKER_FEATURES($1)
168.5788 +	;;
168.5789 +
168.5790 +      dgux*)
168.5791 +        case $cc_basename in
168.5792 +          ec++*)
168.5793 +	    # FIXME: insert proper C++ library support
168.5794 +	    _LT_TAGVAR(ld_shlibs, $1)=no
168.5795 +	    ;;
168.5796 +          ghcx*)
168.5797 +	    # Green Hills C++ Compiler
168.5798 +	    # FIXME: insert proper C++ library support
168.5799 +	    _LT_TAGVAR(ld_shlibs, $1)=no
168.5800 +	    ;;
168.5801 +          *)
168.5802 +	    # FIXME: insert proper C++ library support
168.5803 +	    _LT_TAGVAR(ld_shlibs, $1)=no
168.5804 +	    ;;
168.5805 +        esac
168.5806 +        ;;
168.5807 +
168.5808 +      freebsd[[12]]*)
168.5809 +        # C++ shared libraries reported to be fairly broken before
168.5810 +	# switch to ELF
168.5811 +        _LT_TAGVAR(ld_shlibs, $1)=no
168.5812 +        ;;
168.5813 +
168.5814 +      freebsd-elf*)
168.5815 +        _LT_TAGVAR(archive_cmds_need_lc, $1)=no
168.5816 +        ;;
168.5817 +
168.5818 +      freebsd* | dragonfly*)
168.5819 +        # FreeBSD 3 and later use GNU C++ and GNU ld with standard ELF
168.5820 +        # conventions
168.5821 +        _LT_TAGVAR(ld_shlibs, $1)=yes
168.5822 +        ;;
168.5823 +
168.5824 +      gnu*)
168.5825 +        ;;
168.5826 +
168.5827 +      haiku*)
168.5828 +        _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
168.5829 +        _LT_TAGVAR(link_all_deplibs, $1)=yes
168.5830 +        ;;
168.5831 +
168.5832 +      hpux9*)
168.5833 +        _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}+b ${wl}$libdir'
168.5834 +        _LT_TAGVAR(hardcode_libdir_separator, $1)=:
168.5835 +        _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E'
168.5836 +        _LT_TAGVAR(hardcode_direct, $1)=yes
168.5837 +        _LT_TAGVAR(hardcode_minus_L, $1)=yes # Not in the search PATH,
168.5838 +				             # but as the default
168.5839 +				             # location of the library.
168.5840 +
168.5841 +        case $cc_basename in
168.5842 +          CC*)
168.5843 +            # FIXME: insert proper C++ library support
168.5844 +            _LT_TAGVAR(ld_shlibs, $1)=no
168.5845 +            ;;
168.5846 +          aCC*)
168.5847 +            _LT_TAGVAR(archive_cmds, $1)='$RM $output_objdir/$soname~$CC -b ${wl}+b ${wl}$install_libdir -o $output_objdir/$soname $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib'
168.5848 +            # Commands to make compiler produce verbose output that lists
168.5849 +            # what "hidden" libraries, object files and flags are used when
168.5850 +            # linking a shared library.
168.5851 +            #
168.5852 +            # There doesn't appear to be a way to prevent this compiler from
168.5853 +            # explicitly linking system object files so we need to strip them
168.5854 +            # from the output so that they don't get included in the library
168.5855 +            # dependencies.
168.5856 +            output_verbose_link_cmd='templist=`($CC -b $CFLAGS -v conftest.$objext 2>&1) | $EGREP "\-L"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; func_echo_all "$list"'
168.5857 +            ;;
168.5858 +          *)
168.5859 +            if test "$GXX" = yes; then
168.5860 +              _LT_TAGVAR(archive_cmds, $1)='$RM $output_objdir/$soname~$CC -shared -nostdlib -fPIC ${wl}+b ${wl}$install_libdir -o $output_objdir/$soname $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib'
168.5861 +            else
168.5862 +              # FIXME: insert proper C++ library support
168.5863 +              _LT_TAGVAR(ld_shlibs, $1)=no
168.5864 +            fi
168.5865 +            ;;
168.5866 +        esac
168.5867 +        ;;
168.5868 +
168.5869 +      hpux10*|hpux11*)
168.5870 +        if test $with_gnu_ld = no; then
168.5871 +	  _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}+b ${wl}$libdir'
168.5872 +	  _LT_TAGVAR(hardcode_libdir_separator, $1)=:
168.5873 +
168.5874 +          case $host_cpu in
168.5875 +            hppa*64*|ia64*)
168.5876 +              ;;
168.5877 +            *)
168.5878 +	      _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E'
168.5879 +              ;;
168.5880 +          esac
168.5881 +        fi
168.5882 +        case $host_cpu in
168.5883 +          hppa*64*|ia64*)
168.5884 +            _LT_TAGVAR(hardcode_direct, $1)=no
168.5885 +            _LT_TAGVAR(hardcode_shlibpath_var, $1)=no
168.5886 +            ;;
168.5887 +          *)
168.5888 +            _LT_TAGVAR(hardcode_direct, $1)=yes
168.5889 +            _LT_TAGVAR(hardcode_direct_absolute, $1)=yes
168.5890 +            _LT_TAGVAR(hardcode_minus_L, $1)=yes # Not in the search PATH,
168.5891 +					         # but as the default
168.5892 +					         # location of the library.
168.5893 +            ;;
168.5894 +        esac
168.5895 +
168.5896 +        case $cc_basename in
168.5897 +          CC*)
168.5898 +	    # FIXME: insert proper C++ library support
168.5899 +	    _LT_TAGVAR(ld_shlibs, $1)=no
168.5900 +	    ;;
168.5901 +          aCC*)
168.5902 +	    case $host_cpu in
168.5903 +	      hppa*64*)
168.5904 +	        _LT_TAGVAR(archive_cmds, $1)='$CC -b ${wl}+h ${wl}$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
168.5905 +	        ;;
168.5906 +	      ia64*)
168.5907 +	        _LT_TAGVAR(archive_cmds, $1)='$CC -b ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
168.5908 +	        ;;
168.5909 +	      *)
168.5910 +	        _LT_TAGVAR(archive_cmds, $1)='$CC -b ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
168.5911 +	        ;;
168.5912 +	    esac
168.5913 +	    # Commands to make compiler produce verbose output that lists
168.5914 +	    # what "hidden" libraries, object files and flags are used when
168.5915 +	    # linking a shared library.
168.5916 +	    #
168.5917 +	    # There doesn't appear to be a way to prevent this compiler from
168.5918 +	    # explicitly linking system object files so we need to strip them
168.5919 +	    # from the output so that they don't get included in the library
168.5920 +	    # dependencies.
168.5921 +	    output_verbose_link_cmd='templist=`($CC -b $CFLAGS -v conftest.$objext 2>&1) | $GREP "\-L"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; func_echo_all "$list"'
168.5922 +	    ;;
168.5923 +          *)
168.5924 +	    if test "$GXX" = yes; then
168.5925 +	      if test $with_gnu_ld = no; then
168.5926 +	        case $host_cpu in
168.5927 +	          hppa*64*)
168.5928 +	            _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib -fPIC ${wl}+h ${wl}$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
168.5929 +	            ;;
168.5930 +	          ia64*)
168.5931 +	            _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib -fPIC ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
168.5932 +	            ;;
168.5933 +	          *)
168.5934 +	            _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib -fPIC ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
168.5935 +	            ;;
168.5936 +	        esac
168.5937 +	      fi
168.5938 +	    else
168.5939 +	      # FIXME: insert proper C++ library support
168.5940 +	      _LT_TAGVAR(ld_shlibs, $1)=no
168.5941 +	    fi
168.5942 +	    ;;
168.5943 +        esac
168.5944 +        ;;
168.5945 +
168.5946 +      interix[[3-9]]*)
168.5947 +	_LT_TAGVAR(hardcode_direct, $1)=no
168.5948 +	_LT_TAGVAR(hardcode_shlibpath_var, $1)=no
168.5949 +	_LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir'
168.5950 +	_LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E'
168.5951 +	# Hack: On Interix 3.x, we cannot compile PIC because of a broken gcc.
168.5952 +	# Instead, shared libraries are loaded at an image base (0x10000000 by
168.5953 +	# default) and relocated if they conflict, which is a slow very memory
168.5954 +	# consuming and fragmenting process.  To avoid this, we pick a random,
168.5955 +	# 256 KiB-aligned image base between 0x50000000 and 0x6FFC0000 at link
168.5956 +	# time.  Moving up from 0x10000000 also allows more sbrk(2) space.
168.5957 +	_LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib'
168.5958 +	_LT_TAGVAR(archive_expsym_cmds, $1)='sed "s,^,_," $export_symbols >$output_objdir/$soname.expsym~$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--retain-symbols-file,$output_objdir/$soname.expsym ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib'
168.5959 +	;;
168.5960 +      irix5* | irix6*)
168.5961 +        case $cc_basename in
168.5962 +          CC*)
168.5963 +	    # SGI C++
168.5964 +	    _LT_TAGVAR(archive_cmds, $1)='$CC -shared -all -multigot $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry ${output_objdir}/so_locations -o $lib'
168.5965 +
168.5966 +	    # Archives containing C++ object files must be created using
168.5967 +	    # "CC -ar", where "CC" is the IRIX C++ compiler.  This is
168.5968 +	    # necessary to make sure instantiated templates are included
168.5969 +	    # in the archive.
168.5970 +	    _LT_TAGVAR(old_archive_cmds, $1)='$CC -ar -WR,-u -o $oldlib $oldobjs'
168.5971 +	    ;;
168.5972 +          *)
168.5973 +	    if test "$GXX" = yes; then
168.5974 +	      if test "$with_gnu_ld" = no; then
168.5975 +	        _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version ${wl}$verstring"` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib'
168.5976 +	      else
168.5977 +	        _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version ${wl}$verstring"` -o $lib'
168.5978 +	      fi
168.5979 +	    fi
168.5980 +	    _LT_TAGVAR(link_all_deplibs, $1)=yes
168.5981 +	    ;;
168.5982 +        esac
168.5983 +        _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir'
168.5984 +        _LT_TAGVAR(hardcode_libdir_separator, $1)=:
168.5985 +        _LT_TAGVAR(inherit_rpath, $1)=yes
168.5986 +        ;;
168.5987 +
168.5988 +      linux* | k*bsd*-gnu | kopensolaris*-gnu)
168.5989 +        case $cc_basename in
168.5990 +          KCC*)
168.5991 +	    # Kuck and Associates, Inc. (KAI) C++ Compiler
168.5992 +
168.5993 +	    # KCC will only create a shared library if the output file
168.5994 +	    # ends with ".so" (or ".sl" for HP-UX), so rename the library
168.5995 +	    # to its proper name (with version) after linking.
168.5996 +	    _LT_TAGVAR(archive_cmds, $1)='tempext=`echo $shared_ext | $SED -e '\''s/\([[^()0-9A-Za-z{}]]\)/\\\\\1/g'\''`; templib=`echo $lib | $SED -e "s/\${tempext}\..*/.so/"`; $CC $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags --soname $soname -o \$templib; mv \$templib $lib'
168.5997 +	    _LT_TAGVAR(archive_expsym_cmds, $1)='tempext=`echo $shared_ext | $SED -e '\''s/\([[^()0-9A-Za-z{}]]\)/\\\\\1/g'\''`; templib=`echo $lib | $SED -e "s/\${tempext}\..*/.so/"`; $CC $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags --soname $soname -o \$templib ${wl}-retain-symbols-file,$export_symbols; mv \$templib $lib'
168.5998 +	    # Commands to make compiler produce verbose output that lists
168.5999 +	    # what "hidden" libraries, object files and flags are used when
168.6000 +	    # linking a shared library.
168.6001 +	    #
168.6002 +	    # There doesn't appear to be a way to prevent this compiler from
168.6003 +	    # explicitly linking system object files so we need to strip them
168.6004 +	    # from the output so that they don't get included in the library
168.6005 +	    # dependencies.
168.6006 +	    output_verbose_link_cmd='templist=`$CC $CFLAGS -v conftest.$objext -o libconftest$shared_ext 2>&1 | $GREP "ld"`; rm -f libconftest$shared_ext; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; func_echo_all "$list"'
168.6007 +
168.6008 +	    _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir'
168.6009 +	    _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-dynamic'
168.6010 +
168.6011 +	    # Archives containing C++ object files must be created using
168.6012 +	    # "CC -Bstatic", where "CC" is the KAI C++ compiler.
168.6013 +	    _LT_TAGVAR(old_archive_cmds, $1)='$CC -Bstatic -o $oldlib $oldobjs'
168.6014 +	    ;;
168.6015 +	  icpc* | ecpc* )
168.6016 +	    # Intel C++
168.6017 +	    with_gnu_ld=yes
168.6018 +	    # version 8.0 and above of icpc choke on multiply defined symbols
168.6019 +	    # if we add $predep_objects and $postdep_objects, however 7.1 and
168.6020 +	    # earlier do not add the objects themselves.
168.6021 +	    case `$CC -V 2>&1` in
168.6022 +	      *"Version 7."*)
168.6023 +	        _LT_TAGVAR(archive_cmds, $1)='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname -o $lib'
168.6024 +		_LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
168.6025 +		;;
168.6026 +	      *)  # Version 8.0 or newer
168.6027 +	        tmp_idyn=
168.6028 +	        case $host_cpu in
168.6029 +		  ia64*) tmp_idyn=' -i_dynamic';;
168.6030 +		esac
168.6031 +	        _LT_TAGVAR(archive_cmds, $1)='$CC -shared'"$tmp_idyn"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
168.6032 +		_LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared'"$tmp_idyn"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
168.6033 +		;;
168.6034 +	    esac
168.6035 +	    _LT_TAGVAR(archive_cmds_need_lc, $1)=no
168.6036 +	    _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir'
168.6037 +	    _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-dynamic'
168.6038 +	    _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive$convenience ${wl}--no-whole-archive'
168.6039 +	    ;;
168.6040 +          pgCC* | pgcpp*)
168.6041 +            # Portland Group C++ compiler
168.6042 +	    case `$CC -V` in
168.6043 +	    *pgCC\ [[1-5]].* | *pgcpp\ [[1-5]].*)
168.6044 +	      _LT_TAGVAR(prelink_cmds, $1)='tpldir=Template.dir~
168.6045 +		rm -rf $tpldir~
168.6046 +		$CC --prelink_objects --instantiation_dir $tpldir $objs $libobjs $compile_deplibs~
168.6047 +		compile_command="$compile_command `find $tpldir -name \*.o | $NL2SP`"'
168.6048 +	      _LT_TAGVAR(old_archive_cmds, $1)='tpldir=Template.dir~
168.6049 +		rm -rf $tpldir~
168.6050 +		$CC --prelink_objects --instantiation_dir $tpldir $oldobjs$old_deplibs~
168.6051 +		$AR $AR_FLAGS $oldlib$oldobjs$old_deplibs `find $tpldir -name \*.o | $NL2SP`~
168.6052 +		$RANLIB $oldlib'
168.6053 +	      _LT_TAGVAR(archive_cmds, $1)='tpldir=Template.dir~
168.6054 +		rm -rf $tpldir~
168.6055 +		$CC --prelink_objects --instantiation_dir $tpldir $predep_objects $libobjs $deplibs $convenience $postdep_objects~
168.6056 +		$CC -shared $pic_flag $predep_objects $libobjs $deplibs `find $tpldir -name \*.o | $NL2SP` $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname -o $lib'
168.6057 +	      _LT_TAGVAR(archive_expsym_cmds, $1)='tpldir=Template.dir~
168.6058 +		rm -rf $tpldir~
168.6059 +		$CC --prelink_objects --instantiation_dir $tpldir $predep_objects $libobjs $deplibs $convenience $postdep_objects~
168.6060 +		$CC -shared $pic_flag $predep_objects $libobjs $deplibs `find $tpldir -name \*.o | $NL2SP` $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname ${wl}-retain-symbols-file ${wl}$export_symbols -o $lib'
168.6061 +	      ;;
168.6062 +	    *) # Version 6 and above use weak symbols
168.6063 +	      _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname -o $lib'
168.6064 +	      _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname ${wl}-retain-symbols-file ${wl}$export_symbols -o $lib'
168.6065 +	      ;;
168.6066 +	    esac
168.6067 +
168.6068 +	    _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}--rpath ${wl}$libdir'
168.6069 +	    _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-dynamic'
168.6070 +	    _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive`for conv in $convenience\"\"; do test  -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` ${wl}--no-whole-archive'
168.6071 +            ;;
168.6072 +	  cxx*)
168.6073 +	    # Compaq C++
168.6074 +	    _LT_TAGVAR(archive_cmds, $1)='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname -o $lib'
168.6075 +	    _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname  -o $lib ${wl}-retain-symbols-file $wl$export_symbols'
168.6076 +
168.6077 +	    runpath_var=LD_RUN_PATH
168.6078 +	    _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-rpath $libdir'
168.6079 +	    _LT_TAGVAR(hardcode_libdir_separator, $1)=:
168.6080 +
168.6081 +	    # Commands to make compiler produce verbose output that lists
168.6082 +	    # what "hidden" libraries, object files and flags are used when
168.6083 +	    # linking a shared library.
168.6084 +	    #
168.6085 +	    # There doesn't appear to be a way to prevent this compiler from
168.6086 +	    # explicitly linking system object files so we need to strip them
168.6087 +	    # from the output so that they don't get included in the library
168.6088 +	    # dependencies.
168.6089 +	    output_verbose_link_cmd='templist=`$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP "ld"`; templist=`func_echo_all "$templist" | $SED "s/\(^.*ld.*\)\( .*ld .*$\)/\1/"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; func_echo_all "X$list" | $Xsed'
168.6090 +	    ;;
168.6091 +	  xl* | mpixl* | bgxl*)
168.6092 +	    # IBM XL 8.0 on PPC, with GNU ld
168.6093 +	    _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir'
168.6094 +	    _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-dynamic'
168.6095 +	    _LT_TAGVAR(archive_cmds, $1)='$CC -qmkshrobj $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
168.6096 +	    if test "x$supports_anon_versioning" = xyes; then
168.6097 +	      _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $output_objdir/$libname.ver~
168.6098 +		cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~
168.6099 +		echo "local: *; };" >> $output_objdir/$libname.ver~
168.6100 +		$CC -qmkshrobj $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-version-script ${wl}$output_objdir/$libname.ver -o $lib'
168.6101 +	    fi
168.6102 +	    ;;
168.6103 +	  *)
168.6104 +	    case `$CC -V 2>&1 | sed 5q` in
168.6105 +	    *Sun\ C*)
168.6106 +	      # Sun C++ 5.9
168.6107 +	      _LT_TAGVAR(no_undefined_flag, $1)=' -zdefs'
168.6108 +	      _LT_TAGVAR(archive_cmds, $1)='$CC -G${allow_undefined_flag} -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
168.6109 +	      _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -G${allow_undefined_flag} -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-retain-symbols-file ${wl}$export_symbols'
168.6110 +	      _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir'
168.6111 +	      _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive`new_convenience=; for conv in $convenience\"\"; do test -z \"$conv\" || new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` ${wl}--no-whole-archive'
168.6112 +	      _LT_TAGVAR(compiler_needs_object, $1)=yes
168.6113 +
168.6114 +	      # Not sure whether something based on
168.6115 +	      # $CC $CFLAGS -v conftest.$objext -o libconftest$shared_ext 2>&1
168.6116 +	      # would be better.
168.6117 +	      output_verbose_link_cmd='func_echo_all'
168.6118 +
168.6119 +	      # Archives containing C++ object files must be created using
168.6120 +	      # "CC -xar", where "CC" is the Sun C++ compiler.  This is
168.6121 +	      # necessary to make sure instantiated templates are included
168.6122 +	      # in the archive.
168.6123 +	      _LT_TAGVAR(old_archive_cmds, $1)='$CC -xar -o $oldlib $oldobjs'
168.6124 +	      ;;
168.6125 +	    esac
168.6126 +	    ;;
168.6127 +	esac
168.6128 +	;;
168.6129 +
168.6130 +      lynxos*)
168.6131 +        # FIXME: insert proper C++ library support
168.6132 +	_LT_TAGVAR(ld_shlibs, $1)=no
168.6133 +	;;
168.6134 +
168.6135 +      m88k*)
168.6136 +        # FIXME: insert proper C++ library support
168.6137 +        _LT_TAGVAR(ld_shlibs, $1)=no
168.6138 +	;;
168.6139 +
168.6140 +      mvs*)
168.6141 +        case $cc_basename in
168.6142 +          cxx*)
168.6143 +	    # FIXME: insert proper C++ library support
168.6144 +	    _LT_TAGVAR(ld_shlibs, $1)=no
168.6145 +	    ;;
168.6146 +	  *)
168.6147 +	    # FIXME: insert proper C++ library support
168.6148 +	    _LT_TAGVAR(ld_shlibs, $1)=no
168.6149 +	    ;;
168.6150 +	esac
168.6151 +	;;
168.6152 +
168.6153 +      netbsd*)
168.6154 +        if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then
168.6155 +	  _LT_TAGVAR(archive_cmds, $1)='$LD -Bshareable  -o $lib $predep_objects $libobjs $deplibs $postdep_objects $linker_flags'
168.6156 +	  wlarc=
168.6157 +	  _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir'
168.6158 +	  _LT_TAGVAR(hardcode_direct, $1)=yes
168.6159 +	  _LT_TAGVAR(hardcode_shlibpath_var, $1)=no
168.6160 +	fi
168.6161 +	# Workaround some broken pre-1.5 toolchains
168.6162 +	output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP conftest.$objext | $SED -e "s:-lgcc -lc -lgcc::"'
168.6163 +	;;
168.6164 +
168.6165 +      *nto* | *qnx*)
168.6166 +        _LT_TAGVAR(ld_shlibs, $1)=yes
168.6167 +	;;
168.6168 +
168.6169 +      openbsd2*)
168.6170 +        # C++ shared libraries are fairly broken
168.6171 +	_LT_TAGVAR(ld_shlibs, $1)=no
168.6172 +	;;
168.6173 +
168.6174 +      openbsd*)
168.6175 +	if test -f /usr/libexec/ld.so; then
168.6176 +	  _LT_TAGVAR(hardcode_direct, $1)=yes
168.6177 +	  _LT_TAGVAR(hardcode_shlibpath_var, $1)=no
168.6178 +	  _LT_TAGVAR(hardcode_direct_absolute, $1)=yes
168.6179 +	  _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $lib'
168.6180 +	  _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir'
168.6181 +	  if test -z "`echo __ELF__ | $CC -E - | grep __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then
168.6182 +	    _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-retain-symbols-file,$export_symbols -o $lib'
168.6183 +	    _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E'
168.6184 +	    _LT_TAGVAR(whole_archive_flag_spec, $1)="$wlarc"'--whole-archive$convenience '"$wlarc"'--no-whole-archive'
168.6185 +	  fi
168.6186 +	  output_verbose_link_cmd=func_echo_all
168.6187 +	else
168.6188 +	  _LT_TAGVAR(ld_shlibs, $1)=no
168.6189 +	fi
168.6190 +	;;
168.6191 +
168.6192 +      osf3* | osf4* | osf5*)
168.6193 +        case $cc_basename in
168.6194 +          KCC*)
168.6195 +	    # Kuck and Associates, Inc. (KAI) C++ Compiler
168.6196 +
168.6197 +	    # KCC will only create a shared library if the output file
168.6198 +	    # ends with ".so" (or ".sl" for HP-UX), so rename the library
168.6199 +	    # to its proper name (with version) after linking.
168.6200 +	    _LT_TAGVAR(archive_cmds, $1)='tempext=`echo $shared_ext | $SED -e '\''s/\([[^()0-9A-Za-z{}]]\)/\\\\\1/g'\''`; templib=`echo "$lib" | $SED -e "s/\${tempext}\..*/.so/"`; $CC $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags --soname $soname -o \$templib; mv \$templib $lib'
168.6201 +
168.6202 +	    _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir'
168.6203 +	    _LT_TAGVAR(hardcode_libdir_separator, $1)=:
168.6204 +
168.6205 +	    # Archives containing C++ object files must be created using
168.6206 +	    # the KAI C++ compiler.
168.6207 +	    case $host in
168.6208 +	      osf3*) _LT_TAGVAR(old_archive_cmds, $1)='$CC -Bstatic -o $oldlib $oldobjs' ;;
168.6209 +	      *) _LT_TAGVAR(old_archive_cmds, $1)='$CC -o $oldlib $oldobjs' ;;
168.6210 +	    esac
168.6211 +	    ;;
168.6212 +          RCC*)
168.6213 +	    # Rational C++ 2.4.1
168.6214 +	    # FIXME: insert proper C++ library support
168.6215 +	    _LT_TAGVAR(ld_shlibs, $1)=no
168.6216 +	    ;;
168.6217 +          cxx*)
168.6218 +	    case $host in
168.6219 +	      osf3*)
168.6220 +	        _LT_TAGVAR(allow_undefined_flag, $1)=' ${wl}-expect_unresolved ${wl}\*'
168.6221 +	        _LT_TAGVAR(archive_cmds, $1)='$CC -shared${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $soname `test -n "$verstring" && func_echo_all "${wl}-set_version $verstring"` -update_registry ${output_objdir}/so_locations -o $lib'
168.6222 +	        _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir'
168.6223 +		;;
168.6224 +	      *)
168.6225 +	        _LT_TAGVAR(allow_undefined_flag, $1)=' -expect_unresolved \*'
168.6226 +	        _LT_TAGVAR(archive_cmds, $1)='$CC -shared${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -msym -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry ${output_objdir}/so_locations -o $lib'
168.6227 +	        _LT_TAGVAR(archive_expsym_cmds, $1)='for i in `cat $export_symbols`; do printf "%s %s\\n" -exported_symbol "\$i" >> $lib.exp; done~
168.6228 +	          echo "-hidden">> $lib.exp~
168.6229 +	          $CC -shared$allow_undefined_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -msym -soname $soname ${wl}-input ${wl}$lib.exp  `test -n "$verstring" && $ECHO "-set_version $verstring"` -update_registry ${output_objdir}/so_locations -o $lib~
168.6230 +	          $RM $lib.exp'
168.6231 +	        _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-rpath $libdir'
168.6232 +		;;
168.6233 +	    esac
168.6234 +
168.6235 +	    _LT_TAGVAR(hardcode_libdir_separator, $1)=:
168.6236 +
168.6237 +	    # Commands to make compiler produce verbose output that lists
168.6238 +	    # what "hidden" libraries, object files and flags are used when
168.6239 +	    # linking a shared library.
168.6240 +	    #
168.6241 +	    # There doesn't appear to be a way to prevent this compiler from
168.6242 +	    # explicitly linking system object files so we need to strip them
168.6243 +	    # from the output so that they don't get included in the library
168.6244 +	    # dependencies.
168.6245 +	    output_verbose_link_cmd='templist=`$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP "ld" | $GREP -v "ld:"`; templist=`func_echo_all "$templist" | $SED "s/\(^.*ld.*\)\( .*ld.*$\)/\1/"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; func_echo_all "$list"'
168.6246 +	    ;;
168.6247 +	  *)
168.6248 +	    if test "$GXX" = yes && test "$with_gnu_ld" = no; then
168.6249 +	      _LT_TAGVAR(allow_undefined_flag, $1)=' ${wl}-expect_unresolved ${wl}\*'
168.6250 +	      case $host in
168.6251 +	        osf3*)
168.6252 +	          _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib ${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version ${wl}$verstring"` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib'
168.6253 +		  ;;
168.6254 +	        *)
168.6255 +	          _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib ${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-msym ${wl}-soname ${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version ${wl}$verstring"` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib'
168.6256 +		  ;;
168.6257 +	      esac
168.6258 +
168.6259 +	      _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir'
168.6260 +	      _LT_TAGVAR(hardcode_libdir_separator, $1)=:
168.6261 +
168.6262 +	      # Commands to make compiler produce verbose output that lists
168.6263 +	      # what "hidden" libraries, object files and flags are used when
168.6264 +	      # linking a shared library.
168.6265 +	      output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP -v "^Configured with:" | $GREP "\-L"'
168.6266 +
168.6267 +	    else
168.6268 +	      # FIXME: insert proper C++ library support
168.6269 +	      _LT_TAGVAR(ld_shlibs, $1)=no
168.6270 +	    fi
168.6271 +	    ;;
168.6272 +        esac
168.6273 +        ;;
168.6274 +
168.6275 +      psos*)
168.6276 +        # FIXME: insert proper C++ library support
168.6277 +        _LT_TAGVAR(ld_shlibs, $1)=no
168.6278 +        ;;
168.6279 +
168.6280 +      sunos4*)
168.6281 +        case $cc_basename in
168.6282 +          CC*)
168.6283 +	    # Sun C++ 4.x
168.6284 +	    # FIXME: insert proper C++ library support
168.6285 +	    _LT_TAGVAR(ld_shlibs, $1)=no
168.6286 +	    ;;
168.6287 +          lcc*)
168.6288 +	    # Lucid
168.6289 +	    # FIXME: insert proper C++ library support
168.6290 +	    _LT_TAGVAR(ld_shlibs, $1)=no
168.6291 +	    ;;
168.6292 +          *)
168.6293 +	    # FIXME: insert proper C++ library support
168.6294 +	    _LT_TAGVAR(ld_shlibs, $1)=no
168.6295 +	    ;;
168.6296 +        esac
168.6297 +        ;;
168.6298 +
168.6299 +      solaris*)
168.6300 +        case $cc_basename in
168.6301 +          CC*)
168.6302 +	    # Sun C++ 4.2, 5.x and Centerline C++
168.6303 +            _LT_TAGVAR(archive_cmds_need_lc,$1)=yes
168.6304 +	    _LT_TAGVAR(no_undefined_flag, $1)=' -zdefs'
168.6305 +	    _LT_TAGVAR(archive_cmds, $1)='$CC -G${allow_undefined_flag}  -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
168.6306 +	    _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~
168.6307 +	      $CC -G${allow_undefined_flag} ${wl}-M ${wl}$lib.exp -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~$RM $lib.exp'
168.6308 +
168.6309 +	    _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir'
168.6310 +	    _LT_TAGVAR(hardcode_shlibpath_var, $1)=no
168.6311 +	    case $host_os in
168.6312 +	      solaris2.[[0-5]] | solaris2.[[0-5]].*) ;;
168.6313 +	      *)
168.6314 +		# The compiler driver will combine and reorder linker options,
168.6315 +		# but understands `-z linker_flag'.
168.6316 +	        # Supported since Solaris 2.6 (maybe 2.5.1?)
168.6317 +		_LT_TAGVAR(whole_archive_flag_spec, $1)='-z allextract$convenience -z defaultextract'
168.6318 +	        ;;
168.6319 +	    esac
168.6320 +	    _LT_TAGVAR(link_all_deplibs, $1)=yes
168.6321 +
168.6322 +	    output_verbose_link_cmd='func_echo_all'
168.6323 +
168.6324 +	    # Archives containing C++ object files must be created using
168.6325 +	    # "CC -xar", where "CC" is the Sun C++ compiler.  This is
168.6326 +	    # necessary to make sure instantiated templates are included
168.6327 +	    # in the archive.
168.6328 +	    _LT_TAGVAR(old_archive_cmds, $1)='$CC -xar -o $oldlib $oldobjs'
168.6329 +	    ;;
168.6330 +          gcx*)
168.6331 +	    # Green Hills C++ Compiler
168.6332 +	    _LT_TAGVAR(archive_cmds, $1)='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-h $wl$soname -o $lib'
168.6333 +
168.6334 +	    # The C++ compiler must be used to create the archive.
168.6335 +	    _LT_TAGVAR(old_archive_cmds, $1)='$CC $LDFLAGS -archive -o $oldlib $oldobjs'
168.6336 +	    ;;
168.6337 +          *)
168.6338 +	    # GNU C++ compiler with Solaris linker
168.6339 +	    if test "$GXX" = yes && test "$with_gnu_ld" = no; then
168.6340 +	      _LT_TAGVAR(no_undefined_flag, $1)=' ${wl}-z ${wl}defs'
168.6341 +	      if $CC --version | $GREP -v '^2\.7' > /dev/null; then
168.6342 +	        _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $LDFLAGS $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-h $wl$soname -o $lib'
168.6343 +	        _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~
168.6344 +		  $CC -shared -nostdlib ${wl}-M $wl$lib.exp -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~$RM $lib.exp'
168.6345 +
168.6346 +	        # Commands to make compiler produce verbose output that lists
168.6347 +	        # what "hidden" libraries, object files and flags are used when
168.6348 +	        # linking a shared library.
168.6349 +	        output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP -v "^Configured with:" | $GREP "\-L"'
168.6350 +	      else
168.6351 +	        # g++ 2.7 appears to require `-G' NOT `-shared' on this
168.6352 +	        # platform.
168.6353 +	        _LT_TAGVAR(archive_cmds, $1)='$CC -G -nostdlib $LDFLAGS $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-h $wl$soname -o $lib'
168.6354 +	        _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~
168.6355 +		  $CC -G -nostdlib ${wl}-M $wl$lib.exp -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~$RM $lib.exp'
168.6356 +
168.6357 +	        # Commands to make compiler produce verbose output that lists
168.6358 +	        # what "hidden" libraries, object files and flags are used when
168.6359 +	        # linking a shared library.
168.6360 +	        output_verbose_link_cmd='$CC -G $CFLAGS -v conftest.$objext 2>&1 | $GREP -v "^Configured with:" | $GREP "\-L"'
168.6361 +	      fi
168.6362 +
168.6363 +	      _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-R $wl$libdir'
168.6364 +	      case $host_os in
168.6365 +		solaris2.[[0-5]] | solaris2.[[0-5]].*) ;;
168.6366 +		*)
168.6367 +		  _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}-z ${wl}allextract$convenience ${wl}-z ${wl}defaultextract'
168.6368 +		  ;;
168.6369 +	      esac
168.6370 +	    fi
168.6371 +	    ;;
168.6372 +        esac
168.6373 +        ;;
168.6374 +
168.6375 +    sysv4*uw2* | sysv5OpenUNIX* | sysv5UnixWare7.[[01]].[[10]]* | unixware7* | sco3.2v5.0.[[024]]*)
168.6376 +      _LT_TAGVAR(no_undefined_flag, $1)='${wl}-z,text'
168.6377 +      _LT_TAGVAR(archive_cmds_need_lc, $1)=no
168.6378 +      _LT_TAGVAR(hardcode_shlibpath_var, $1)=no
168.6379 +      runpath_var='LD_RUN_PATH'
168.6380 +
168.6381 +      case $cc_basename in
168.6382 +        CC*)
168.6383 +	  _LT_TAGVAR(archive_cmds, $1)='$CC -G ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
168.6384 +	  _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
168.6385 +	  ;;
168.6386 +	*)
168.6387 +	  _LT_TAGVAR(archive_cmds, $1)='$CC -shared ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
168.6388 +	  _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
168.6389 +	  ;;
168.6390 +      esac
168.6391 +      ;;
168.6392 +
168.6393 +      sysv5* | sco3.2v5* | sco5v6*)
168.6394 +	# Note: We can NOT use -z defs as we might desire, because we do not
168.6395 +	# link with -lc, and that would cause any symbols used from libc to
168.6396 +	# always be unresolved, which means just about no library would
168.6397 +	# ever link correctly.  If we're not using GNU ld we use -z text
168.6398 +	# though, which does catch some bad symbols but isn't as heavy-handed
168.6399 +	# as -z defs.
168.6400 +	_LT_TAGVAR(no_undefined_flag, $1)='${wl}-z,text'
168.6401 +	_LT_TAGVAR(allow_undefined_flag, $1)='${wl}-z,nodefs'
168.6402 +	_LT_TAGVAR(archive_cmds_need_lc, $1)=no
168.6403 +	_LT_TAGVAR(hardcode_shlibpath_var, $1)=no
168.6404 +	_LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-R,$libdir'
168.6405 +	_LT_TAGVAR(hardcode_libdir_separator, $1)=':'
168.6406 +	_LT_TAGVAR(link_all_deplibs, $1)=yes
168.6407 +	_LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-Bexport'
168.6408 +	runpath_var='LD_RUN_PATH'
168.6409 +
168.6410 +	case $cc_basename in
168.6411 +          CC*)
168.6412 +	    _LT_TAGVAR(archive_cmds, $1)='$CC -G ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
168.6413 +	    _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
168.6414 +	    _LT_TAGVAR(old_archive_cmds, $1)='$CC -Tprelink_objects $oldobjs~
168.6415 +	      '"$_LT_TAGVAR(old_archive_cmds, $1)"
168.6416 +	    _LT_TAGVAR(reload_cmds, $1)='$CC -Tprelink_objects $reload_objs~
168.6417 +	      '"$_LT_TAGVAR(reload_cmds, $1)"
168.6418 +	    ;;
168.6419 +	  *)
168.6420 +	    _LT_TAGVAR(archive_cmds, $1)='$CC -shared ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
168.6421 +	    _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
168.6422 +	    ;;
168.6423 +	esac
168.6424 +      ;;
168.6425 +
168.6426 +      tandem*)
168.6427 +        case $cc_basename in
168.6428 +          NCC*)
168.6429 +	    # NonStop-UX NCC 3.20
168.6430 +	    # FIXME: insert proper C++ library support
168.6431 +	    _LT_TAGVAR(ld_shlibs, $1)=no
168.6432 +	    ;;
168.6433 +          *)
168.6434 +	    # FIXME: insert proper C++ library support
168.6435 +	    _LT_TAGVAR(ld_shlibs, $1)=no
168.6436 +	    ;;
168.6437 +        esac
168.6438 +        ;;
168.6439 +
168.6440 +      vxworks*)
168.6441 +        # FIXME: insert proper C++ library support
168.6442 +        _LT_TAGVAR(ld_shlibs, $1)=no
168.6443 +        ;;
168.6444 +
168.6445 +      *)
168.6446 +        # FIXME: insert proper C++ library support
168.6447 +        _LT_TAGVAR(ld_shlibs, $1)=no
168.6448 +        ;;
168.6449 +    esac
168.6450 +
168.6451 +    AC_MSG_RESULT([$_LT_TAGVAR(ld_shlibs, $1)])
168.6452 +    test "$_LT_TAGVAR(ld_shlibs, $1)" = no && can_build_shared=no
168.6453 +
168.6454 +    _LT_TAGVAR(GCC, $1)="$GXX"
168.6455 +    _LT_TAGVAR(LD, $1)="$LD"
168.6456 +
168.6457 +    ## CAVEAT EMPTOR:
168.6458 +    ## There is no encapsulation within the following macros, do not change
168.6459 +    ## the running order or otherwise move them around unless you know exactly
168.6460 +    ## what you are doing...
168.6461 +    _LT_SYS_HIDDEN_LIBDEPS($1)
168.6462 +    _LT_COMPILER_PIC($1)
168.6463 +    _LT_COMPILER_C_O($1)
168.6464 +    _LT_COMPILER_FILE_LOCKS($1)
168.6465 +    _LT_LINKER_SHLIBS($1)
168.6466 +    _LT_SYS_DYNAMIC_LINKER($1)
168.6467 +    _LT_LINKER_HARDCODE_LIBPATH($1)
168.6468 +
168.6469 +    _LT_CONFIG($1)
168.6470 +  fi # test -n "$compiler"
168.6471 +
168.6472 +  CC=$lt_save_CC
168.6473 +  LDCXX=$LD
168.6474 +  LD=$lt_save_LD
168.6475 +  GCC=$lt_save_GCC
168.6476 +  with_gnu_ld=$lt_save_with_gnu_ld
168.6477 +  lt_cv_path_LDCXX=$lt_cv_path_LD
168.6478 +  lt_cv_path_LD=$lt_save_path_LD
168.6479 +  lt_cv_prog_gnu_ldcxx=$lt_cv_prog_gnu_ld
168.6480 +  lt_cv_prog_gnu_ld=$lt_save_with_gnu_ld
168.6481 +fi # test "$_lt_caught_CXX_error" != yes
168.6482 +
168.6483 +AC_LANG_POP
168.6484 +])# _LT_LANG_CXX_CONFIG
168.6485 +
168.6486 +
168.6487 +# _LT_SYS_HIDDEN_LIBDEPS([TAGNAME])
168.6488 +# ---------------------------------
168.6489 +# Figure out "hidden" library dependencies from verbose
168.6490 +# compiler output when linking a shared library.
168.6491 +# Parse the compiler output and extract the necessary
168.6492 +# objects, libraries and library flags.
168.6493 +m4_defun([_LT_SYS_HIDDEN_LIBDEPS],
168.6494 +[m4_require([_LT_FILEUTILS_DEFAULTS])dnl
168.6495 +# Dependencies to place before and after the object being linked:
168.6496 +_LT_TAGVAR(predep_objects, $1)=
168.6497 +_LT_TAGVAR(postdep_objects, $1)=
168.6498 +_LT_TAGVAR(predeps, $1)=
168.6499 +_LT_TAGVAR(postdeps, $1)=
168.6500 +_LT_TAGVAR(compiler_lib_search_path, $1)=
168.6501 +
168.6502 +dnl we can't use the lt_simple_compile_test_code here,
168.6503 +dnl because it contains code intended for an executable,
168.6504 +dnl not a library.  It's possible we should let each
168.6505 +dnl tag define a new lt_????_link_test_code variable,
168.6506 +dnl but it's only used here...
168.6507 +m4_if([$1], [], [cat > conftest.$ac_ext <<_LT_EOF
168.6508 +int a;
168.6509 +void foo (void) { a = 0; }
168.6510 +_LT_EOF
168.6511 +], [$1], [CXX], [cat > conftest.$ac_ext <<_LT_EOF
168.6512 +class Foo
168.6513 +{
168.6514 +public:
168.6515 +  Foo (void) { a = 0; }
168.6516 +private:
168.6517 +  int a;
168.6518 +};
168.6519 +_LT_EOF
168.6520 +], [$1], [F77], [cat > conftest.$ac_ext <<_LT_EOF
168.6521 +      subroutine foo
168.6522 +      implicit none
168.6523 +      integer*4 a
168.6524 +      a=0
168.6525 +      return
168.6526 +      end
168.6527 +_LT_EOF
168.6528 +], [$1], [FC], [cat > conftest.$ac_ext <<_LT_EOF
168.6529 +      subroutine foo
168.6530 +      implicit none
168.6531 +      integer a
168.6532 +      a=0
168.6533 +      return
168.6534 +      end
168.6535 +_LT_EOF
168.6536 +], [$1], [GCJ], [cat > conftest.$ac_ext <<_LT_EOF
168.6537 +public class foo {
168.6538 +  private int a;
168.6539 +  public void bar (void) {
168.6540 +    a = 0;
168.6541 +  }
168.6542 +};
168.6543 +_LT_EOF
168.6544 +])
168.6545 +dnl Parse the compiler output and extract the necessary
168.6546 +dnl objects, libraries and library flags.
168.6547 +if AC_TRY_EVAL(ac_compile); then
168.6548 +  # Parse the compiler output and extract the necessary
168.6549 +  # objects, libraries and library flags.
168.6550 +
168.6551 +  # Sentinel used to keep track of whether or not we are before
168.6552 +  # the conftest object file.
168.6553 +  pre_test_object_deps_done=no
168.6554 +
168.6555 +  for p in `eval "$output_verbose_link_cmd"`; do
168.6556 +    case $p in
168.6557 +
168.6558 +    -L* | -R* | -l*)
168.6559 +       # Some compilers place space between "-{L,R}" and the path.
168.6560 +       # Remove the space.
168.6561 +       if test $p = "-L" ||
168.6562 +          test $p = "-R"; then
168.6563 +	 prev=$p
168.6564 +	 continue
168.6565 +       else
168.6566 +	 prev=
168.6567 +       fi
168.6568 +
168.6569 +       if test "$pre_test_object_deps_done" = no; then
168.6570 +	 case $p in
168.6571 +	 -L* | -R*)
168.6572 +	   # Internal compiler library paths should come after those
168.6573 +	   # provided the user.  The postdeps already come after the
168.6574 +	   # user supplied libs so there is no need to process them.
168.6575 +	   if test -z "$_LT_TAGVAR(compiler_lib_search_path, $1)"; then
168.6576 +	     _LT_TAGVAR(compiler_lib_search_path, $1)="${prev}${p}"
168.6577 +	   else
168.6578 +	     _LT_TAGVAR(compiler_lib_search_path, $1)="${_LT_TAGVAR(compiler_lib_search_path, $1)} ${prev}${p}"
168.6579 +	   fi
168.6580 +	   ;;
168.6581 +	 # The "-l" case would never come before the object being
168.6582 +	 # linked, so don't bother handling this case.
168.6583 +	 esac
168.6584 +       else
168.6585 +	 if test -z "$_LT_TAGVAR(postdeps, $1)"; then
168.6586 +	   _LT_TAGVAR(postdeps, $1)="${prev}${p}"
168.6587 +	 else
168.6588 +	   _LT_TAGVAR(postdeps, $1)="${_LT_TAGVAR(postdeps, $1)} ${prev}${p}"
168.6589 +	 fi
168.6590 +       fi
168.6591 +       ;;
168.6592 +
168.6593 +    *.$objext)
168.6594 +       # This assumes that the test object file only shows up
168.6595 +       # once in the compiler output.
168.6596 +       if test "$p" = "conftest.$objext"; then
168.6597 +	 pre_test_object_deps_done=yes
168.6598 +	 continue
168.6599 +       fi
168.6600 +
168.6601 +       if test "$pre_test_object_deps_done" = no; then
168.6602 +	 if test -z "$_LT_TAGVAR(predep_objects, $1)"; then
168.6603 +	   _LT_TAGVAR(predep_objects, $1)="$p"
168.6604 +	 else
168.6605 +	   _LT_TAGVAR(predep_objects, $1)="$_LT_TAGVAR(predep_objects, $1) $p"
168.6606 +	 fi
168.6607 +       else
168.6608 +	 if test -z "$_LT_TAGVAR(postdep_objects, $1)"; then
168.6609 +	   _LT_TAGVAR(postdep_objects, $1)="$p"
168.6610 +	 else
168.6611 +	   _LT_TAGVAR(postdep_objects, $1)="$_LT_TAGVAR(postdep_objects, $1) $p"
168.6612 +	 fi
168.6613 +       fi
168.6614 +       ;;
168.6615 +
168.6616 +    *) ;; # Ignore the rest.
168.6617 +
168.6618 +    esac
168.6619 +  done
168.6620 +
168.6621 +  # Clean up.
168.6622 +  rm -f a.out a.exe
168.6623 +else
168.6624 +  echo "libtool.m4: error: problem compiling $1 test program"
168.6625 +fi
168.6626 +
168.6627 +$RM -f confest.$objext
168.6628 +
168.6629 +# PORTME: override above test on systems where it is broken
168.6630 +m4_if([$1], [CXX],
168.6631 +[case $host_os in
168.6632 +interix[[3-9]]*)
168.6633 +  # Interix 3.5 installs completely hosed .la files for C++, so rather than
168.6634 +  # hack all around it, let's just trust "g++" to DTRT.
168.6635 +  _LT_TAGVAR(predep_objects,$1)=
168.6636 +  _LT_TAGVAR(postdep_objects,$1)=
168.6637 +  _LT_TAGVAR(postdeps,$1)=
168.6638 +  ;;
168.6639 +
168.6640 +linux*)
168.6641 +  case `$CC -V 2>&1 | sed 5q` in
168.6642 +  *Sun\ C*)
168.6643 +    # Sun C++ 5.9
168.6644 +
168.6645 +    # The more standards-conforming stlport4 library is
168.6646 +    # incompatible with the Cstd library. Avoid specifying
168.6647 +    # it if it's in CXXFLAGS. Ignore libCrun as
168.6648 +    # -library=stlport4 depends on it.
168.6649 +    case " $CXX $CXXFLAGS " in
168.6650 +    *" -library=stlport4 "*)
168.6651 +      solaris_use_stlport4=yes
168.6652 +      ;;
168.6653 +    esac
168.6654 +
168.6655 +    if test "$solaris_use_stlport4" != yes; then
168.6656 +      _LT_TAGVAR(postdeps,$1)='-library=Cstd -library=Crun'
168.6657 +    fi
168.6658 +    ;;
168.6659 +  esac
168.6660 +  ;;
168.6661 +
168.6662 +solaris*)
168.6663 +  case $cc_basename in
168.6664 +  CC*)
168.6665 +    # The more standards-conforming stlport4 library is
168.6666 +    # incompatible with the Cstd library. Avoid specifying
168.6667 +    # it if it's in CXXFLAGS. Ignore libCrun as
168.6668 +    # -library=stlport4 depends on it.
168.6669 +    case " $CXX $CXXFLAGS " in
168.6670 +    *" -library=stlport4 "*)
168.6671 +      solaris_use_stlport4=yes
168.6672 +      ;;
168.6673 +    esac
168.6674 +
168.6675 +    # Adding this requires a known-good setup of shared libraries for
168.6676 +    # Sun compiler versions before 5.6, else PIC objects from an old
168.6677 +    # archive will be linked into the output, leading to subtle bugs.
168.6678 +    if test "$solaris_use_stlport4" != yes; then
168.6679 +      _LT_TAGVAR(postdeps,$1)='-library=Cstd -library=Crun'
168.6680 +    fi
168.6681 +    ;;
168.6682 +  esac
168.6683 +  ;;
168.6684 +esac
168.6685 +])
168.6686 +
168.6687 +case " $_LT_TAGVAR(postdeps, $1) " in
168.6688 +*" -lc "*) _LT_TAGVAR(archive_cmds_need_lc, $1)=no ;;
168.6689 +esac
168.6690 + _LT_TAGVAR(compiler_lib_search_dirs, $1)=
168.6691 +if test -n "${_LT_TAGVAR(compiler_lib_search_path, $1)}"; then
168.6692 + _LT_TAGVAR(compiler_lib_search_dirs, $1)=`echo " ${_LT_TAGVAR(compiler_lib_search_path, $1)}" | ${SED} -e 's! -L! !g' -e 's!^ !!'`
168.6693 +fi
168.6694 +_LT_TAGDECL([], [compiler_lib_search_dirs], [1],
168.6695 +    [The directories searched by this compiler when creating a shared library])
168.6696 +_LT_TAGDECL([], [predep_objects], [1],
168.6697 +    [Dependencies to place before and after the objects being linked to
168.6698 +    create a shared library])
168.6699 +_LT_TAGDECL([], [postdep_objects], [1])
168.6700 +_LT_TAGDECL([], [predeps], [1])
168.6701 +_LT_TAGDECL([], [postdeps], [1])
168.6702 +_LT_TAGDECL([], [compiler_lib_search_path], [1],
168.6703 +    [The library search path used internally by the compiler when linking
168.6704 +    a shared library])
168.6705 +])# _LT_SYS_HIDDEN_LIBDEPS
168.6706 +
168.6707 +
168.6708 +# _LT_LANG_F77_CONFIG([TAG])
168.6709 +# --------------------------
168.6710 +# Ensure that the configuration variables for a Fortran 77 compiler are
168.6711 +# suitably defined.  These variables are subsequently used by _LT_CONFIG
168.6712 +# to write the compiler configuration to `libtool'.
168.6713 +m4_defun([_LT_LANG_F77_CONFIG],
168.6714 +[AC_LANG_PUSH(Fortran 77)
168.6715 +if test -z "$F77" || test "X$F77" = "Xno"; then
168.6716 +  _lt_disable_F77=yes
168.6717 +fi
168.6718 +
168.6719 +_LT_TAGVAR(archive_cmds_need_lc, $1)=no
168.6720 +_LT_TAGVAR(allow_undefined_flag, $1)=
168.6721 +_LT_TAGVAR(always_export_symbols, $1)=no
168.6722 +_LT_TAGVAR(archive_expsym_cmds, $1)=
168.6723 +_LT_TAGVAR(export_dynamic_flag_spec, $1)=
168.6724 +_LT_TAGVAR(hardcode_direct, $1)=no
168.6725 +_LT_TAGVAR(hardcode_direct_absolute, $1)=no
168.6726 +_LT_TAGVAR(hardcode_libdir_flag_spec, $1)=
168.6727 +_LT_TAGVAR(hardcode_libdir_flag_spec_ld, $1)=
168.6728 +_LT_TAGVAR(hardcode_libdir_separator, $1)=
168.6729 +_LT_TAGVAR(hardcode_minus_L, $1)=no
168.6730 +_LT_TAGVAR(hardcode_automatic, $1)=no
168.6731 +_LT_TAGVAR(inherit_rpath, $1)=no
168.6732 +_LT_TAGVAR(module_cmds, $1)=
168.6733 +_LT_TAGVAR(module_expsym_cmds, $1)=
168.6734 +_LT_TAGVAR(link_all_deplibs, $1)=unknown
168.6735 +_LT_TAGVAR(old_archive_cmds, $1)=$old_archive_cmds
168.6736 +_LT_TAGVAR(reload_flag, $1)=$reload_flag
168.6737 +_LT_TAGVAR(reload_cmds, $1)=$reload_cmds
168.6738 +_LT_TAGVAR(no_undefined_flag, $1)=
168.6739 +_LT_TAGVAR(whole_archive_flag_spec, $1)=
168.6740 +_LT_TAGVAR(enable_shared_with_static_runtimes, $1)=no
168.6741 +
168.6742 +# Source file extension for f77 test sources.
168.6743 +ac_ext=f
168.6744 +
168.6745 +# Object file extension for compiled f77 test sources.
168.6746 +objext=o
168.6747 +_LT_TAGVAR(objext, $1)=$objext
168.6748 +
168.6749 +# No sense in running all these tests if we already determined that
168.6750 +# the F77 compiler isn't working.  Some variables (like enable_shared)
168.6751 +# are currently assumed to apply to all compilers on this platform,
168.6752 +# and will be corrupted by setting them based on a non-working compiler.
168.6753 +if test "$_lt_disable_F77" != yes; then
168.6754 +  # Code to be used in simple compile tests
168.6755 +  lt_simple_compile_test_code="\
168.6756 +      subroutine t
168.6757 +      return
168.6758 +      end
168.6759 +"
168.6760 +
168.6761 +  # Code to be used in simple link tests
168.6762 +  lt_simple_link_test_code="\
168.6763 +      program t
168.6764 +      end
168.6765 +"
168.6766 +
168.6767 +  # ltmain only uses $CC for tagged configurations so make sure $CC is set.
168.6768 +  _LT_TAG_COMPILER
168.6769 +
168.6770 +  # save warnings/boilerplate of simple test code
168.6771 +  _LT_COMPILER_BOILERPLATE
168.6772 +  _LT_LINKER_BOILERPLATE
168.6773 +
168.6774 +  # Allow CC to be a program name with arguments.
168.6775 +  lt_save_CC="$CC"
168.6776 +  lt_save_GCC=$GCC
168.6777 +  CC=${F77-"f77"}
168.6778 +  compiler=$CC
168.6779 +  _LT_TAGVAR(compiler, $1)=$CC
168.6780 +  _LT_CC_BASENAME([$compiler])
168.6781 +  GCC=$G77
168.6782 +  if test -n "$compiler"; then
168.6783 +    AC_MSG_CHECKING([if libtool supports shared libraries])
168.6784 +    AC_MSG_RESULT([$can_build_shared])
168.6785 +
168.6786 +    AC_MSG_CHECKING([whether to build shared libraries])
168.6787 +    test "$can_build_shared" = "no" && enable_shared=no
168.6788 +
168.6789 +    # On AIX, shared libraries and static libraries use the same namespace, and
168.6790 +    # are all built from PIC.
168.6791 +    case $host_os in
168.6792 +      aix3*)
168.6793 +        test "$enable_shared" = yes && enable_static=no
168.6794 +        if test -n "$RANLIB"; then
168.6795 +          archive_cmds="$archive_cmds~\$RANLIB \$lib"
168.6796 +          postinstall_cmds='$RANLIB $lib'
168.6797 +        fi
168.6798 +        ;;
168.6799 +      aix[[4-9]]*)
168.6800 +	if test "$host_cpu" != ia64 && test "$aix_use_runtimelinking" = no ; then
168.6801 +	  test "$enable_shared" = yes && enable_static=no
168.6802 +	fi
168.6803 +        ;;
168.6804 +    esac
168.6805 +    AC_MSG_RESULT([$enable_shared])
168.6806 +
168.6807 +    AC_MSG_CHECKING([whether to build static libraries])
168.6808 +    # Make sure either enable_shared or enable_static is yes.
168.6809 +    test "$enable_shared" = yes || enable_static=yes
168.6810 +    AC_MSG_RESULT([$enable_static])
168.6811 +
168.6812 +    _LT_TAGVAR(GCC, $1)="$G77"
168.6813 +    _LT_TAGVAR(LD, $1)="$LD"
168.6814 +
168.6815 +    ## CAVEAT EMPTOR:
168.6816 +    ## There is no encapsulation within the following macros, do not change
168.6817 +    ## the running order or otherwise move them around unless you know exactly
168.6818 +    ## what you are doing...
168.6819 +    _LT_COMPILER_PIC($1)
168.6820 +    _LT_COMPILER_C_O($1)
168.6821 +    _LT_COMPILER_FILE_LOCKS($1)
168.6822 +    _LT_LINKER_SHLIBS($1)
168.6823 +    _LT_SYS_DYNAMIC_LINKER($1)
168.6824 +    _LT_LINKER_HARDCODE_LIBPATH($1)
168.6825 +
168.6826 +    _LT_CONFIG($1)
168.6827 +  fi # test -n "$compiler"
168.6828 +
168.6829 +  GCC=$lt_save_GCC
168.6830 +  CC="$lt_save_CC"
168.6831 +fi # test "$_lt_disable_F77" != yes
168.6832 +
168.6833 +AC_LANG_POP
168.6834 +])# _LT_LANG_F77_CONFIG
168.6835 +
168.6836 +
168.6837 +# _LT_LANG_FC_CONFIG([TAG])
168.6838 +# -------------------------
168.6839 +# Ensure that the configuration variables for a Fortran compiler are
168.6840 +# suitably defined.  These variables are subsequently used by _LT_CONFIG
168.6841 +# to write the compiler configuration to `libtool'.
168.6842 +m4_defun([_LT_LANG_FC_CONFIG],
168.6843 +[AC_LANG_PUSH(Fortran)
168.6844 +
168.6845 +if test -z "$FC" || test "X$FC" = "Xno"; then
168.6846 +  _lt_disable_FC=yes
168.6847 +fi
168.6848 +
168.6849 +_LT_TAGVAR(archive_cmds_need_lc, $1)=no
168.6850 +_LT_TAGVAR(allow_undefined_flag, $1)=
168.6851 +_LT_TAGVAR(always_export_symbols, $1)=no
168.6852 +_LT_TAGVAR(archive_expsym_cmds, $1)=
168.6853 +_LT_TAGVAR(export_dynamic_flag_spec, $1)=
168.6854 +_LT_TAGVAR(hardcode_direct, $1)=no
168.6855 +_LT_TAGVAR(hardcode_direct_absolute, $1)=no
168.6856 +_LT_TAGVAR(hardcode_libdir_flag_spec, $1)=
168.6857 +_LT_TAGVAR(hardcode_libdir_flag_spec_ld, $1)=
168.6858 +_LT_TAGVAR(hardcode_libdir_separator, $1)=
168.6859 +_LT_TAGVAR(hardcode_minus_L, $1)=no
168.6860 +_LT_TAGVAR(hardcode_automatic, $1)=no
168.6861 +_LT_TAGVAR(inherit_rpath, $1)=no
168.6862 +_LT_TAGVAR(module_cmds, $1)=
168.6863 +_LT_TAGVAR(module_expsym_cmds, $1)=
168.6864 +_LT_TAGVAR(link_all_deplibs, $1)=unknown
168.6865 +_LT_TAGVAR(old_archive_cmds, $1)=$old_archive_cmds
168.6866 +_LT_TAGVAR(reload_flag, $1)=$reload_flag
168.6867 +_LT_TAGVAR(reload_cmds, $1)=$reload_cmds
168.6868 +_LT_TAGVAR(no_undefined_flag, $1)=
168.6869 +_LT_TAGVAR(whole_archive_flag_spec, $1)=
168.6870 +_LT_TAGVAR(enable_shared_with_static_runtimes, $1)=no
168.6871 +
168.6872 +# Source file extension for fc test sources.
168.6873 +ac_ext=${ac_fc_srcext-f}
168.6874 +
168.6875 +# Object file extension for compiled fc test sources.
168.6876 +objext=o
168.6877 +_LT_TAGVAR(objext, $1)=$objext
168.6878 +
168.6879 +# No sense in running all these tests if we already determined that
168.6880 +# the FC compiler isn't working.  Some variables (like enable_shared)
168.6881 +# are currently assumed to apply to all compilers on this platform,
168.6882 +# and will be corrupted by setting them based on a non-working compiler.
168.6883 +if test "$_lt_disable_FC" != yes; then
168.6884 +  # Code to be used in simple compile tests
168.6885 +  lt_simple_compile_test_code="\
168.6886 +      subroutine t
168.6887 +      return
168.6888 +      end
168.6889 +"
168.6890 +
168.6891 +  # Code to be used in simple link tests
168.6892 +  lt_simple_link_test_code="\
168.6893 +      program t
168.6894 +      end
168.6895 +"
168.6896 +
168.6897 +  # ltmain only uses $CC for tagged configurations so make sure $CC is set.
168.6898 +  _LT_TAG_COMPILER
168.6899 +
168.6900 +  # save warnings/boilerplate of simple test code
168.6901 +  _LT_COMPILER_BOILERPLATE
168.6902 +  _LT_LINKER_BOILERPLATE
168.6903 +
168.6904 +  # Allow CC to be a program name with arguments.
168.6905 +  lt_save_CC="$CC"
168.6906 +  lt_save_GCC=$GCC
168.6907 +  CC=${FC-"f95"}
168.6908 +  compiler=$CC
168.6909 +  GCC=$ac_cv_fc_compiler_gnu
168.6910 +
168.6911 +  _LT_TAGVAR(compiler, $1)=$CC
168.6912 +  _LT_CC_BASENAME([$compiler])
168.6913 +
168.6914 +  if test -n "$compiler"; then
168.6915 +    AC_MSG_CHECKING([if libtool supports shared libraries])
168.6916 +    AC_MSG_RESULT([$can_build_shared])
168.6917 +
168.6918 +    AC_MSG_CHECKING([whether to build shared libraries])
168.6919 +    test "$can_build_shared" = "no" && enable_shared=no
168.6920 +
168.6921 +    # On AIX, shared libraries and static libraries use the same namespace, and
168.6922 +    # are all built from PIC.
168.6923 +    case $host_os in
168.6924 +      aix3*)
168.6925 +        test "$enable_shared" = yes && enable_static=no
168.6926 +        if test -n "$RANLIB"; then
168.6927 +          archive_cmds="$archive_cmds~\$RANLIB \$lib"
168.6928 +          postinstall_cmds='$RANLIB $lib'
168.6929 +        fi
168.6930 +        ;;
168.6931 +      aix[[4-9]]*)
168.6932 +	if test "$host_cpu" != ia64 && test "$aix_use_runtimelinking" = no ; then
168.6933 +	  test "$enable_shared" = yes && enable_static=no
168.6934 +	fi
168.6935 +        ;;
168.6936 +    esac
168.6937 +    AC_MSG_RESULT([$enable_shared])
168.6938 +
168.6939 +    AC_MSG_CHECKING([whether to build static libraries])
168.6940 +    # Make sure either enable_shared or enable_static is yes.
168.6941 +    test "$enable_shared" = yes || enable_static=yes
168.6942 +    AC_MSG_RESULT([$enable_static])
168.6943 +
168.6944 +    _LT_TAGVAR(GCC, $1)="$ac_cv_fc_compiler_gnu"
168.6945 +    _LT_TAGVAR(LD, $1)="$LD"
168.6946 +
168.6947 +    ## CAVEAT EMPTOR:
168.6948 +    ## There is no encapsulation within the following macros, do not change
168.6949 +    ## the running order or otherwise move them around unless you know exactly
168.6950 +    ## what you are doing...
168.6951 +    _LT_SYS_HIDDEN_LIBDEPS($1)
168.6952 +    _LT_COMPILER_PIC($1)
168.6953 +    _LT_COMPILER_C_O($1)
168.6954 +    _LT_COMPILER_FILE_LOCKS($1)
168.6955 +    _LT_LINKER_SHLIBS($1)
168.6956 +    _LT_SYS_DYNAMIC_LINKER($1)
168.6957 +    _LT_LINKER_HARDCODE_LIBPATH($1)
168.6958 +
168.6959 +    _LT_CONFIG($1)
168.6960 +  fi # test -n "$compiler"
168.6961 +
168.6962 +  GCC=$lt_save_GCC
168.6963 +  CC="$lt_save_CC"
168.6964 +fi # test "$_lt_disable_FC" != yes
168.6965 +
168.6966 +AC_LANG_POP
168.6967 +])# _LT_LANG_FC_CONFIG
168.6968 +
168.6969 +
168.6970 +# _LT_LANG_GCJ_CONFIG([TAG])
168.6971 +# --------------------------
168.6972 +# Ensure that the configuration variables for the GNU Java Compiler compiler
168.6973 +# are suitably defined.  These variables are subsequently used by _LT_CONFIG
168.6974 +# to write the compiler configuration to `libtool'.
168.6975 +m4_defun([_LT_LANG_GCJ_CONFIG],
168.6976 +[AC_REQUIRE([LT_PROG_GCJ])dnl
168.6977 +AC_LANG_SAVE
168.6978 +
168.6979 +# Source file extension for Java test sources.
168.6980 +ac_ext=java
168.6981 +
168.6982 +# Object file extension for compiled Java test sources.
168.6983 +objext=o
168.6984 +_LT_TAGVAR(objext, $1)=$objext
168.6985 +
168.6986 +# Code to be used in simple compile tests
168.6987 +lt_simple_compile_test_code="class foo {}"
168.6988 +
168.6989 +# Code to be used in simple link tests
168.6990 +lt_simple_link_test_code='public class conftest { public static void main(String[[]] argv) {}; }'
168.6991 +
168.6992 +# ltmain only uses $CC for tagged configurations so make sure $CC is set.
168.6993 +_LT_TAG_COMPILER
168.6994 +
168.6995 +# save warnings/boilerplate of simple test code
168.6996 +_LT_COMPILER_BOILERPLATE
168.6997 +_LT_LINKER_BOILERPLATE
168.6998 +
168.6999 +# Allow CC to be a program name with arguments.
168.7000 +lt_save_CC="$CC"
168.7001 +lt_save_GCC=$GCC
168.7002 +GCC=yes
168.7003 +CC=${GCJ-"gcj"}
168.7004 +compiler=$CC
168.7005 +_LT_TAGVAR(compiler, $1)=$CC
168.7006 +_LT_TAGVAR(LD, $1)="$LD"
168.7007 +_LT_CC_BASENAME([$compiler])
168.7008 +
168.7009 +# GCJ did not exist at the time GCC didn't implicitly link libc in.
168.7010 +_LT_TAGVAR(archive_cmds_need_lc, $1)=no
168.7011 +
168.7012 +_LT_TAGVAR(old_archive_cmds, $1)=$old_archive_cmds
168.7013 +_LT_TAGVAR(reload_flag, $1)=$reload_flag
168.7014 +_LT_TAGVAR(reload_cmds, $1)=$reload_cmds
168.7015 +
168.7016 +## CAVEAT EMPTOR:
168.7017 +## There is no encapsulation within the following macros, do not change
168.7018 +## the running order or otherwise move them around unless you know exactly
168.7019 +## what you are doing...
168.7020 +if test -n "$compiler"; then
168.7021 +  _LT_COMPILER_NO_RTTI($1)
168.7022 +  _LT_COMPILER_PIC($1)
168.7023 +  _LT_COMPILER_C_O($1)
168.7024 +  _LT_COMPILER_FILE_LOCKS($1)
168.7025 +  _LT_LINKER_SHLIBS($1)
168.7026 +  _LT_LINKER_HARDCODE_LIBPATH($1)
168.7027 +
168.7028 +  _LT_CONFIG($1)
168.7029 +fi
168.7030 +
168.7031 +AC_LANG_RESTORE
168.7032 +
168.7033 +GCC=$lt_save_GCC
168.7034 +CC="$lt_save_CC"
168.7035 +])# _LT_LANG_GCJ_CONFIG
168.7036 +
168.7037 +
168.7038 +# _LT_LANG_RC_CONFIG([TAG])
168.7039 +# -------------------------
168.7040 +# Ensure that the configuration variables for the Windows resource compiler
168.7041 +# are suitably defined.  These variables are subsequently used by _LT_CONFIG
168.7042 +# to write the compiler configuration to `libtool'.
168.7043 +m4_defun([_LT_LANG_RC_CONFIG],
168.7044 +[AC_REQUIRE([LT_PROG_RC])dnl
168.7045 +AC_LANG_SAVE
168.7046 +
168.7047 +# Source file extension for RC test sources.
168.7048 +ac_ext=rc
168.7049 +
168.7050 +# Object file extension for compiled RC test sources.
168.7051 +objext=o
168.7052 +_LT_TAGVAR(objext, $1)=$objext
168.7053 +
168.7054 +# Code to be used in simple compile tests
168.7055 +lt_simple_compile_test_code='sample MENU { MENUITEM "&Soup", 100, CHECKED }'
168.7056 +
168.7057 +# Code to be used in simple link tests
168.7058 +lt_simple_link_test_code="$lt_simple_compile_test_code"
168.7059 +
168.7060 +# ltmain only uses $CC for tagged configurations so make sure $CC is set.
168.7061 +_LT_TAG_COMPILER
168.7062 +
168.7063 +# save warnings/boilerplate of simple test code
168.7064 +_LT_COMPILER_BOILERPLATE
168.7065 +_LT_LINKER_BOILERPLATE
168.7066 +
168.7067 +# Allow CC to be a program name with arguments.
168.7068 +lt_save_CC="$CC"
168.7069 +lt_save_GCC=$GCC
168.7070 +GCC=
168.7071 +CC=${RC-"windres"}
168.7072 +compiler=$CC
168.7073 +_LT_TAGVAR(compiler, $1)=$CC
168.7074 +_LT_CC_BASENAME([$compiler])
168.7075 +_LT_TAGVAR(lt_cv_prog_compiler_c_o, $1)=yes
168.7076 +
168.7077 +if test -n "$compiler"; then
168.7078 +  :
168.7079 +  _LT_CONFIG($1)
168.7080 +fi
168.7081 +
168.7082 +GCC=$lt_save_GCC
168.7083 +AC_LANG_RESTORE
168.7084 +CC="$lt_save_CC"
168.7085 +])# _LT_LANG_RC_CONFIG
168.7086 +
168.7087 +
168.7088 +# LT_PROG_GCJ
168.7089 +# -----------
168.7090 +AC_DEFUN([LT_PROG_GCJ],
168.7091 +[m4_ifdef([AC_PROG_GCJ], [AC_PROG_GCJ],
168.7092 +  [m4_ifdef([A][M_PROG_GCJ], [A][M_PROG_GCJ],
168.7093 +    [AC_CHECK_TOOL(GCJ, gcj,)
168.7094 +      test "x${GCJFLAGS+set}" = xset || GCJFLAGS="-g -O2"
168.7095 +      AC_SUBST(GCJFLAGS)])])[]dnl
168.7096 +])
168.7097 +
168.7098 +# Old name:
168.7099 +AU_ALIAS([LT_AC_PROG_GCJ], [LT_PROG_GCJ])
168.7100 +dnl aclocal-1.4 backwards compatibility:
168.7101 +dnl AC_DEFUN([LT_AC_PROG_GCJ], [])
168.7102 +
168.7103 +
168.7104 +# LT_PROG_RC
168.7105 +# ----------
168.7106 +AC_DEFUN([LT_PROG_RC],
168.7107 +[AC_CHECK_TOOL(RC, windres,)
168.7108 +])
168.7109 +
168.7110 +# Old name:
168.7111 +AU_ALIAS([LT_AC_PROG_RC], [LT_PROG_RC])
168.7112 +dnl aclocal-1.4 backwards compatibility:
168.7113 +dnl AC_DEFUN([LT_AC_PROG_RC], [])
168.7114 +
168.7115 +
168.7116 +# _LT_DECL_EGREP
168.7117 +# --------------
168.7118 +# If we don't have a new enough Autoconf to choose the best grep
168.7119 +# available, choose the one first in the user's PATH.
168.7120 +m4_defun([_LT_DECL_EGREP],
168.7121 +[AC_REQUIRE([AC_PROG_EGREP])dnl
168.7122 +AC_REQUIRE([AC_PROG_FGREP])dnl
168.7123 +test -z "$GREP" && GREP=grep
168.7124 +_LT_DECL([], [GREP], [1], [A grep program that handles long lines])
168.7125 +_LT_DECL([], [EGREP], [1], [An ERE matcher])
168.7126 +_LT_DECL([], [FGREP], [1], [A literal string matcher])
168.7127 +dnl Non-bleeding-edge autoconf doesn't subst GREP, so do it here too
168.7128 +AC_SUBST([GREP])
168.7129 +])
168.7130 +
168.7131 +
168.7132 +# _LT_DECL_OBJDUMP
168.7133 +# --------------
168.7134 +# If we don't have a new enough Autoconf to choose the best objdump
168.7135 +# available, choose the one first in the user's PATH.
168.7136 +m4_defun([_LT_DECL_OBJDUMP],
168.7137 +[AC_CHECK_TOOL(OBJDUMP, objdump, false)
168.7138 +test -z "$OBJDUMP" && OBJDUMP=objdump
168.7139 +_LT_DECL([], [OBJDUMP], [1], [An object symbol dumper])
168.7140 +AC_SUBST([OBJDUMP])
168.7141 +])
168.7142 +
168.7143 +# _LT_DECL_DLLTOOL
168.7144 +# --------------
168.7145 +# If we don't have a new enough Autoconf to choose the best dlltool
168.7146 +# available, choose the one first in the user's PATH.
168.7147 +m4_defun([_LT_DECL_DLLTOOL],
168.7148 +[AC_CHECK_TOOL(DLLTOOL, dlltool, false)
168.7149 +test -z "$DLLTOOL" && DLLTOOL=dlltool
168.7150 +_LT_DECL([], [DLLTOOL], [1], [DLL creation program])
168.7151 +AC_SUBST([DLLTOOL])
168.7152 +])
168.7153 +
168.7154 +# _LT_DECL_SED
168.7155 +# ------------
168.7156 +# Check for a fully-functional sed program, that truncates
168.7157 +# as few characters as possible.  Prefer GNU sed if found.
168.7158 +m4_defun([_LT_DECL_SED],
168.7159 +[AC_PROG_SED
168.7160 +test -z "$SED" && SED=sed
168.7161 +Xsed="$SED -e 1s/^X//"
168.7162 +_LT_DECL([], [SED], [1], [A sed program that does not truncate output])
168.7163 +_LT_DECL([], [Xsed], ["\$SED -e 1s/^X//"],
168.7164 +    [Sed that helps us avoid accidentally triggering echo(1) options like -n])
168.7165 +])# _LT_DECL_SED
168.7166 +
168.7167 +m4_ifndef([AC_PROG_SED], [
168.7168 +############################################################
168.7169 +# NOTE: This macro has been submitted for inclusion into   #
168.7170 +#  GNU Autoconf as AC_PROG_SED.  When it is available in   #
168.7171 +#  a released version of Autoconf we should remove this    #
168.7172 +#  macro and use it instead.                               #
168.7173 +############################################################
168.7174 +
168.7175 +m4_defun([AC_PROG_SED],
168.7176 +[AC_MSG_CHECKING([for a sed that does not truncate output])
168.7177 +AC_CACHE_VAL(lt_cv_path_SED,
168.7178 +[# Loop through the user's path and test for sed and gsed.
168.7179 +# Then use that list of sed's as ones to test for truncation.
168.7180 +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
168.7181 +for as_dir in $PATH
168.7182 +do
168.7183 +  IFS=$as_save_IFS
168.7184 +  test -z "$as_dir" && as_dir=.
168.7185 +  for lt_ac_prog in sed gsed; do
168.7186 +    for ac_exec_ext in '' $ac_executable_extensions; do
168.7187 +      if $as_executable_p "$as_dir/$lt_ac_prog$ac_exec_ext"; then
168.7188 +        lt_ac_sed_list="$lt_ac_sed_list $as_dir/$lt_ac_prog$ac_exec_ext"
168.7189 +      fi
168.7190 +    done
168.7191 +  done
168.7192 +done
168.7193 +IFS=$as_save_IFS
168.7194 +lt_ac_max=0
168.7195 +lt_ac_count=0
168.7196 +# Add /usr/xpg4/bin/sed as it is typically found on Solaris
168.7197 +# along with /bin/sed that truncates output.
168.7198 +for lt_ac_sed in $lt_ac_sed_list /usr/xpg4/bin/sed; do
168.7199 +  test ! -f $lt_ac_sed && continue
168.7200 +  cat /dev/null > conftest.in
168.7201 +  lt_ac_count=0
168.7202 +  echo $ECHO_N "0123456789$ECHO_C" >conftest.in
168.7203 +  # Check for GNU sed and select it if it is found.
168.7204 +  if "$lt_ac_sed" --version 2>&1 < /dev/null | grep 'GNU' > /dev/null; then
168.7205 +    lt_cv_path_SED=$lt_ac_sed
168.7206 +    break
168.7207 +  fi
168.7208 +  while true; do
168.7209 +    cat conftest.in conftest.in >conftest.tmp
168.7210 +    mv conftest.tmp conftest.in
168.7211 +    cp conftest.in conftest.nl
168.7212 +    echo >>conftest.nl
168.7213 +    $lt_ac_sed -e 's/a$//' < conftest.nl >conftest.out || break
168.7214 +    cmp -s conftest.out conftest.nl || break
168.7215 +    # 10000 chars as input seems more than enough
168.7216 +    test $lt_ac_count -gt 10 && break
168.7217 +    lt_ac_count=`expr $lt_ac_count + 1`
168.7218 +    if test $lt_ac_count -gt $lt_ac_max; then
168.7219 +      lt_ac_max=$lt_ac_count
168.7220 +      lt_cv_path_SED=$lt_ac_sed
168.7221 +    fi
168.7222 +  done
168.7223 +done
168.7224 +])
168.7225 +SED=$lt_cv_path_SED
168.7226 +AC_SUBST([SED])
168.7227 +AC_MSG_RESULT([$SED])
168.7228 +])#AC_PROG_SED
168.7229 +])#m4_ifndef
168.7230 +
168.7231 +# Old name:
168.7232 +AU_ALIAS([LT_AC_PROG_SED], [AC_PROG_SED])
168.7233 +dnl aclocal-1.4 backwards compatibility:
168.7234 +dnl AC_DEFUN([LT_AC_PROG_SED], [])
168.7235 +
168.7236 +
168.7237 +# _LT_CHECK_SHELL_FEATURES
168.7238 +# ------------------------
168.7239 +# Find out whether the shell is Bourne or XSI compatible,
168.7240 +# or has some other useful features.
168.7241 +m4_defun([_LT_CHECK_SHELL_FEATURES],
168.7242 +[AC_MSG_CHECKING([whether the shell understands some XSI constructs])
168.7243 +# Try some XSI features
168.7244 +xsi_shell=no
168.7245 +( _lt_dummy="a/b/c"
168.7246 +  test "${_lt_dummy##*/},${_lt_dummy%/*},"${_lt_dummy%"$_lt_dummy"}, \
168.7247 +      = c,a/b,, \
168.7248 +    && eval 'test $(( 1 + 1 )) -eq 2 \
168.7249 +    && test "${#_lt_dummy}" -eq 5' ) >/dev/null 2>&1 \
168.7250 +  && xsi_shell=yes
168.7251 +AC_MSG_RESULT([$xsi_shell])
168.7252 +_LT_CONFIG_LIBTOOL_INIT([xsi_shell='$xsi_shell'])
168.7253 +
168.7254 +AC_MSG_CHECKING([whether the shell understands "+="])
168.7255 +lt_shell_append=no
168.7256 +( foo=bar; set foo baz; eval "$[1]+=\$[2]" && test "$foo" = barbaz ) \
168.7257 +    >/dev/null 2>&1 \
168.7258 +  && lt_shell_append=yes
168.7259 +AC_MSG_RESULT([$lt_shell_append])
168.7260 +_LT_CONFIG_LIBTOOL_INIT([lt_shell_append='$lt_shell_append'])
168.7261 +
168.7262 +if ( (MAIL=60; unset MAIL) || exit) >/dev/null 2>&1; then
168.7263 +  lt_unset=unset
168.7264 +else
168.7265 +  lt_unset=false
168.7266 +fi
168.7267 +_LT_DECL([], [lt_unset], [0], [whether the shell understands "unset"])dnl
168.7268 +
168.7269 +# test EBCDIC or ASCII
168.7270 +case `echo X|tr X '\101'` in
168.7271 + A) # ASCII based system
168.7272 +    # \n is not interpreted correctly by Solaris 8 /usr/ucb/tr
168.7273 +  lt_SP2NL='tr \040 \012'
168.7274 +  lt_NL2SP='tr \015\012 \040\040'
168.7275 +  ;;
168.7276 + *) # EBCDIC based system
168.7277 +  lt_SP2NL='tr \100 \n'
168.7278 +  lt_NL2SP='tr \r\n \100\100'
168.7279 +  ;;
168.7280 +esac
168.7281 +_LT_DECL([SP2NL], [lt_SP2NL], [1], [turn spaces into newlines])dnl
168.7282 +_LT_DECL([NL2SP], [lt_NL2SP], [1], [turn newlines into spaces])dnl
168.7283 +])# _LT_CHECK_SHELL_FEATURES
168.7284 +
168.7285 +
168.7286 +# _LT_PROG_XSI_SHELLFNS
168.7287 +# ---------------------
168.7288 +# Bourne and XSI compatible variants of some useful shell functions.
168.7289 +m4_defun([_LT_PROG_XSI_SHELLFNS],
168.7290 +[case $xsi_shell in
168.7291 +  yes)
168.7292 +    cat << \_LT_EOF >> "$cfgfile"
168.7293 +
168.7294 +# func_dirname file append nondir_replacement
168.7295 +# Compute the dirname of FILE.  If nonempty, add APPEND to the result,
168.7296 +# otherwise set result to NONDIR_REPLACEMENT.
168.7297 +func_dirname ()
168.7298 +{
168.7299 +  case ${1} in
168.7300 +    */*) func_dirname_result="${1%/*}${2}" ;;
168.7301 +    *  ) func_dirname_result="${3}" ;;
168.7302 +  esac
168.7303 +}
168.7304 +
168.7305 +# func_basename file
168.7306 +func_basename ()
168.7307 +{
168.7308 +  func_basename_result="${1##*/}"
168.7309 +}
168.7310 +
168.7311 +# func_dirname_and_basename file append nondir_replacement
168.7312 +# perform func_basename and func_dirname in a single function
168.7313 +# call:
168.7314 +#   dirname:  Compute the dirname of FILE.  If nonempty,
168.7315 +#             add APPEND to the result, otherwise set result
168.7316 +#             to NONDIR_REPLACEMENT.
168.7317 +#             value returned in "$func_dirname_result"
168.7318 +#   basename: Compute filename of FILE.
168.7319 +#             value retuned in "$func_basename_result"
168.7320 +# Implementation must be kept synchronized with func_dirname
168.7321 +# and func_basename. For efficiency, we do not delegate to
168.7322 +# those functions but instead duplicate the functionality here.
168.7323 +func_dirname_and_basename ()
168.7324 +{
168.7325 +  case ${1} in
168.7326 +    */*) func_dirname_result="${1%/*}${2}" ;;
168.7327 +    *  ) func_dirname_result="${3}" ;;
168.7328 +  esac
168.7329 +  func_basename_result="${1##*/}"
168.7330 +}
168.7331 +
168.7332 +# func_stripname prefix suffix name
168.7333 +# strip PREFIX and SUFFIX off of NAME.
168.7334 +# PREFIX and SUFFIX must not contain globbing or regex special
168.7335 +# characters, hashes, percent signs, but SUFFIX may contain a leading
168.7336 +# dot (in which case that matches only a dot).
168.7337 +func_stripname ()
168.7338 +{
168.7339 +  # pdksh 5.2.14 does not do ${X%$Y} correctly if both X and Y are
168.7340 +  # positional parameters, so assign one to ordinary parameter first.
168.7341 +  func_stripname_result=${3}
168.7342 +  func_stripname_result=${func_stripname_result#"${1}"}
168.7343 +  func_stripname_result=${func_stripname_result%"${2}"}
168.7344 +}
168.7345 +
168.7346 +# func_opt_split
168.7347 +func_opt_split ()
168.7348 +{
168.7349 +  func_opt_split_opt=${1%%=*}
168.7350 +  func_opt_split_arg=${1#*=}
168.7351 +}
168.7352 +
168.7353 +# func_lo2o object
168.7354 +func_lo2o ()
168.7355 +{
168.7356 +  case ${1} in
168.7357 +    *.lo) func_lo2o_result=${1%.lo}.${objext} ;;
168.7358 +    *)    func_lo2o_result=${1} ;;
168.7359 +  esac
168.7360 +}
168.7361 +
168.7362 +# func_xform libobj-or-source
168.7363 +func_xform ()
168.7364 +{
168.7365 +  func_xform_result=${1%.*}.lo
168.7366 +}
168.7367 +
168.7368 +# func_arith arithmetic-term...
168.7369 +func_arith ()
168.7370 +{
168.7371 +  func_arith_result=$(( $[*] ))
168.7372 +}
168.7373 +
168.7374 +# func_len string
168.7375 +# STRING may not start with a hyphen.
168.7376 +func_len ()
168.7377 +{
168.7378 +  func_len_result=${#1}
168.7379 +}
168.7380 +
168.7381 +_LT_EOF
168.7382 +    ;;
168.7383 +  *) # Bourne compatible functions.
168.7384 +    cat << \_LT_EOF >> "$cfgfile"
168.7385 +
168.7386 +# func_dirname file append nondir_replacement
168.7387 +# Compute the dirname of FILE.  If nonempty, add APPEND to the result,
168.7388 +# otherwise set result to NONDIR_REPLACEMENT.
168.7389 +func_dirname ()
168.7390 +{
168.7391 +  # Extract subdirectory from the argument.
168.7392 +  func_dirname_result=`$ECHO "${1}" | $SED "$dirname"`
168.7393 +  if test "X$func_dirname_result" = "X${1}"; then
168.7394 +    func_dirname_result="${3}"
168.7395 +  else
168.7396 +    func_dirname_result="$func_dirname_result${2}"
168.7397 +  fi
168.7398 +}
168.7399 +
168.7400 +# func_basename file
168.7401 +func_basename ()
168.7402 +{
168.7403 +  func_basename_result=`$ECHO "${1}" | $SED "$basename"`
168.7404 +}
168.7405 +
168.7406 +dnl func_dirname_and_basename
168.7407 +dnl A portable version of this function is already defined in general.m4sh
168.7408 +dnl so there is no need for it here.
168.7409 +
168.7410 +# func_stripname prefix suffix name
168.7411 +# strip PREFIX and SUFFIX off of NAME.
168.7412 +# PREFIX and SUFFIX must not contain globbing or regex special
168.7413 +# characters, hashes, percent signs, but SUFFIX may contain a leading
168.7414 +# dot (in which case that matches only a dot).
168.7415 +# func_strip_suffix prefix name
168.7416 +func_stripname ()
168.7417 +{
168.7418 +  case ${2} in
168.7419 +    .*) func_stripname_result=`$ECHO "${3}" | $SED "s%^${1}%%; s%\\\\${2}\$%%"`;;
168.7420 +    *)  func_stripname_result=`$ECHO "${3}" | $SED "s%^${1}%%; s%${2}\$%%"`;;
168.7421 +  esac
168.7422 +}
168.7423 +
168.7424 +# sed scripts:
168.7425 +my_sed_long_opt='1s/^\(-[[^=]]*\)=.*/\1/;q'
168.7426 +my_sed_long_arg='1s/^-[[^=]]*=//'
168.7427 +
168.7428 +# func_opt_split
168.7429 +func_opt_split ()
168.7430 +{
168.7431 +  func_opt_split_opt=`$ECHO "${1}" | $SED "$my_sed_long_opt"`
168.7432 +  func_opt_split_arg=`$ECHO "${1}" | $SED "$my_sed_long_arg"`
168.7433 +}
168.7434 +
168.7435 +# func_lo2o object
168.7436 +func_lo2o ()
168.7437 +{
168.7438 +  func_lo2o_result=`$ECHO "${1}" | $SED "$lo2o"`
168.7439 +}
168.7440 +
168.7441 +# func_xform libobj-or-source
168.7442 +func_xform ()
168.7443 +{
168.7444 +  func_xform_result=`$ECHO "${1}" | $SED 's/\.[[^.]]*$/.lo/'`
168.7445 +}
168.7446 +
168.7447 +# func_arith arithmetic-term...
168.7448 +func_arith ()
168.7449 +{
168.7450 +  func_arith_result=`expr "$[@]"`
168.7451 +}
168.7452 +
168.7453 +# func_len string
168.7454 +# STRING may not start with a hyphen.
168.7455 +func_len ()
168.7456 +{
168.7457 +  func_len_result=`expr "$[1]" : ".*" 2>/dev/null || echo $max_cmd_len`
168.7458 +}
168.7459 +
168.7460 +_LT_EOF
168.7461 +esac
168.7462 +
168.7463 +case $lt_shell_append in
168.7464 +  yes)
168.7465 +    cat << \_LT_EOF >> "$cfgfile"
168.7466 +
168.7467 +# func_append var value
168.7468 +# Append VALUE to the end of shell variable VAR.
168.7469 +func_append ()
168.7470 +{
168.7471 +  eval "$[1]+=\$[2]"
168.7472 +}
168.7473 +_LT_EOF
168.7474 +    ;;
168.7475 +  *)
168.7476 +    cat << \_LT_EOF >> "$cfgfile"
168.7477 +
168.7478 +# func_append var value
168.7479 +# Append VALUE to the end of shell variable VAR.
168.7480 +func_append ()
168.7481 +{
168.7482 +  eval "$[1]=\$$[1]\$[2]"
168.7483 +}
168.7484 +
168.7485 +_LT_EOF
168.7486 +    ;;
168.7487 +  esac
168.7488 +])
168.7489 +
168.7490 +# _LT_PATH_CONVERSION_FUNCTIONS
168.7491 +# -----------------------------
168.7492 +# Determine which path conversion functions should be
168.7493 +# used by func_to_host_path (and, implicitly, by
168.7494 +# func_to_host_pathlist).  These are needed for certain
168.7495 +# cross-compile configurations and "native" mingw (which
168.7496 +# is actually an msys->mingw cross).
168.7497 +m4_defun([_LT_PATH_CONVERSION_FUNCTIONS],
168.7498 +[AC_REQUIRE([AC_CANONICAL_HOST])dnl
168.7499 +AC_REQUIRE([AC_CANONICAL_BUILD])dnl
168.7500 +AC_MSG_CHECKING([how to convert $build paths to $host format])
168.7501 +AC_CACHE_VAL(lt_cv_to_host_path_cmd,
168.7502 +[case $host in
168.7503 +  *mingw* )
168.7504 +    case $build in
168.7505 +      *mingw* ) # actually msys
168.7506 +        lt_cv_to_host_path_cmd=func_msys_to_mingw_path_convert
168.7507 +        ;;
168.7508 +      *cygwin* )
168.7509 +        lt_cv_to_host_path_cmd=func_cygwin_to_mingw_path_convert
168.7510 +        ;;
168.7511 +      * ) # otherwise, assume *nix
168.7512 +        lt_cv_to_host_path_cmd=func_nix_to_mingw_path_convert
168.7513 +        ;;
168.7514 +    esac
168.7515 +    ;;
168.7516 +  *cygwin* )
168.7517 +    case $build in
168.7518 +      *mingw* ) # actually msys
168.7519 +        lt_cv_to_host_path_cmd=func_msys_to_cygwin_path_convert
168.7520 +        ;;
168.7521 +      *cygwin* )
168.7522 +        lt_cv_to_host_path_cmd=func_noop_path_convert
168.7523 +        ;;
168.7524 +      * ) # otherwise, assume *nix
168.7525 +        lt_cv_to_host_path_cmd=func_nix_to_cygwin_path_convert
168.7526 +        ;;
168.7527 +    esac
168.7528 +    ;;
168.7529 +  * ) # unhandled hosts (and "normal" native builds)
168.7530 +    lt_cv_to_host_path_cmd=func_noop_path_convert
168.7531 +    ;;
168.7532 +esac
168.7533 +])
168.7534 +to_host_path_cmd=$lt_cv_to_host_path_cmd
168.7535 +AC_MSG_RESULT([$lt_cv_to_host_path_cmd])
168.7536 +_LT_DECL([to_host_path_cmd], [lt_cv_to_host_path_cmd],
168.7537 +         [0], [convert $build paths to $host format])dnl
168.7538 +AC_SUBST([to_host_path_cmd])dnl
168.7539 +])# _LT_PATH_CONVERSION_FUNCTIONS
168.7540 +
   169.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
   169.2 +++ b/deps/glpk/m4/ltoptions.m4	Sun Nov 06 20:59:10 2011 +0100
   169.3 @@ -0,0 +1,369 @@
   169.4 +# Helper functions for option handling.                    -*- Autoconf -*-
   169.5 +#
   169.6 +#   Copyright (C) 2004, 2005, 2007, 2008, 2009 Free Software Foundation,
   169.7 +#   Inc.
   169.8 +#   Written by Gary V. Vaughan, 2004
   169.9 +#
  169.10 +# This file is free software; the Free Software Foundation gives
  169.11 +# unlimited permission to copy and/or distribute it, with or without
  169.12 +# modifications, as long as this notice is preserved.
  169.13 +
  169.14 +# serial 6 ltoptions.m4
  169.15 +
  169.16 +# This is to help aclocal find these macros, as it can't see m4_define.
  169.17 +AC_DEFUN([LTOPTIONS_VERSION], [m4_if([1])])
  169.18 +
  169.19 +
  169.20 +# _LT_MANGLE_OPTION(MACRO-NAME, OPTION-NAME)
  169.21 +# ------------------------------------------
  169.22 +m4_define([_LT_MANGLE_OPTION],
  169.23 +[[_LT_OPTION_]m4_bpatsubst($1__$2, [[^a-zA-Z0-9_]], [_])])
  169.24 +
  169.25 +
  169.26 +# _LT_SET_OPTION(MACRO-NAME, OPTION-NAME)
  169.27 +# ---------------------------------------
  169.28 +# Set option OPTION-NAME for macro MACRO-NAME, and if there is a
  169.29 +# matching handler defined, dispatch to it.  Other OPTION-NAMEs are
  169.30 +# saved as a flag.
  169.31 +m4_define([_LT_SET_OPTION],
  169.32 +[m4_define(_LT_MANGLE_OPTION([$1], [$2]))dnl
  169.33 +m4_ifdef(_LT_MANGLE_DEFUN([$1], [$2]),
  169.34 +        _LT_MANGLE_DEFUN([$1], [$2]),
  169.35 +    [m4_warning([Unknown $1 option `$2'])])[]dnl
  169.36 +])
  169.37 +
  169.38 +
  169.39 +# _LT_IF_OPTION(MACRO-NAME, OPTION-NAME, IF-SET, [IF-NOT-SET])
  169.40 +# ------------------------------------------------------------
  169.41 +# Execute IF-SET if OPTION is set, IF-NOT-SET otherwise.
  169.42 +m4_define([_LT_IF_OPTION],
  169.43 +[m4_ifdef(_LT_MANGLE_OPTION([$1], [$2]), [$3], [$4])])
  169.44 +
  169.45 +
  169.46 +# _LT_UNLESS_OPTIONS(MACRO-NAME, OPTION-LIST, IF-NOT-SET)
  169.47 +# -------------------------------------------------------
  169.48 +# Execute IF-NOT-SET unless all options in OPTION-LIST for MACRO-NAME
  169.49 +# are set.
  169.50 +m4_define([_LT_UNLESS_OPTIONS],
  169.51 +[m4_foreach([_LT_Option], m4_split(m4_normalize([$2])),
  169.52 +	    [m4_ifdef(_LT_MANGLE_OPTION([$1], _LT_Option),
  169.53 +		      [m4_define([$0_found])])])[]dnl
  169.54 +m4_ifdef([$0_found], [m4_undefine([$0_found])], [$3
  169.55 +])[]dnl
  169.56 +])
  169.57 +
  169.58 +
  169.59 +# _LT_SET_OPTIONS(MACRO-NAME, OPTION-LIST)
  169.60 +# ----------------------------------------
  169.61 +# OPTION-LIST is a space-separated list of Libtool options associated
  169.62 +# with MACRO-NAME.  If any OPTION has a matching handler declared with
  169.63 +# LT_OPTION_DEFINE, dispatch to that macro; otherwise complain about
  169.64 +# the unknown option and exit.
  169.65 +m4_defun([_LT_SET_OPTIONS],
  169.66 +[# Set options
  169.67 +m4_foreach([_LT_Option], m4_split(m4_normalize([$2])),
  169.68 +    [_LT_SET_OPTION([$1], _LT_Option)])
  169.69 +
  169.70 +m4_if([$1],[LT_INIT],[
  169.71 +  dnl
  169.72 +  dnl Simply set some default values (i.e off) if boolean options were not
  169.73 +  dnl specified:
  169.74 +  _LT_UNLESS_OPTIONS([LT_INIT], [dlopen], [enable_dlopen=no
  169.75 +  ])
  169.76 +  _LT_UNLESS_OPTIONS([LT_INIT], [win32-dll], [enable_win32_dll=no
  169.77 +  ])
  169.78 +  dnl
  169.79 +  dnl If no reference was made to various pairs of opposing options, then
  169.80 +  dnl we run the default mode handler for the pair.  For example, if neither
  169.81 +  dnl `shared' nor `disable-shared' was passed, we enable building of shared
  169.82 +  dnl archives by default:
  169.83 +  _LT_UNLESS_OPTIONS([LT_INIT], [shared disable-shared], [_LT_ENABLE_SHARED])
  169.84 +  _LT_UNLESS_OPTIONS([LT_INIT], [static disable-static], [_LT_ENABLE_STATIC])
  169.85 +  _LT_UNLESS_OPTIONS([LT_INIT], [pic-only no-pic], [_LT_WITH_PIC])
  169.86 +  _LT_UNLESS_OPTIONS([LT_INIT], [fast-install disable-fast-install],
  169.87 +  		   [_LT_ENABLE_FAST_INSTALL])
  169.88 +  ])
  169.89 +])# _LT_SET_OPTIONS
  169.90 +
  169.91 +
  169.92 +## --------------------------------- ##
  169.93 +## Macros to handle LT_INIT options. ##
  169.94 +## --------------------------------- ##
  169.95 +
  169.96 +# _LT_MANGLE_DEFUN(MACRO-NAME, OPTION-NAME)
  169.97 +# -----------------------------------------
  169.98 +m4_define([_LT_MANGLE_DEFUN],
  169.99 +[[_LT_OPTION_DEFUN_]m4_bpatsubst(m4_toupper([$1__$2]), [[^A-Z0-9_]], [_])])
 169.100 +
 169.101 +
 169.102 +# LT_OPTION_DEFINE(MACRO-NAME, OPTION-NAME, CODE)
 169.103 +# -----------------------------------------------
 169.104 +m4_define([LT_OPTION_DEFINE],
 169.105 +[m4_define(_LT_MANGLE_DEFUN([$1], [$2]), [$3])[]dnl
 169.106 +])# LT_OPTION_DEFINE
 169.107 +
 169.108 +
 169.109 +# dlopen
 169.110 +# ------
 169.111 +LT_OPTION_DEFINE([LT_INIT], [dlopen], [enable_dlopen=yes
 169.112 +])
 169.113 +
 169.114 +AU_DEFUN([AC_LIBTOOL_DLOPEN],
 169.115 +[_LT_SET_OPTION([LT_INIT], [dlopen])
 169.116 +AC_DIAGNOSE([obsolete],
 169.117 +[$0: Remove this warning and the call to _LT_SET_OPTION when you
 169.118 +put the `dlopen' option into LT_INIT's first parameter.])
 169.119 +])
 169.120 +
 169.121 +dnl aclocal-1.4 backwards compatibility:
 169.122 +dnl AC_DEFUN([AC_LIBTOOL_DLOPEN], [])
 169.123 +
 169.124 +
 169.125 +# win32-dll
 169.126 +# ---------
 169.127 +# Declare package support for building win32 dll's.
 169.128 +LT_OPTION_DEFINE([LT_INIT], [win32-dll],
 169.129 +[enable_win32_dll=yes
 169.130 +
 169.131 +case $host in
 169.132 +*-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-cegcc*)
 169.133 +  AC_CHECK_TOOL(AS, as, false)
 169.134 +  AC_CHECK_TOOL(DLLTOOL, dlltool, false)
 169.135 +  AC_CHECK_TOOL(OBJDUMP, objdump, false)
 169.136 +  ;;
 169.137 +esac
 169.138 +
 169.139 +test -z "$AS" && AS=as
 169.140 +_LT_DECL([], [AS],      [1], [Assembler program])dnl
 169.141 +
 169.142 +test -z "$DLLTOOL" && DLLTOOL=dlltool
 169.143 +_LT_DECL([], [DLLTOOL], [1], [DLL creation program])dnl
 169.144 +
 169.145 +test -z "$OBJDUMP" && OBJDUMP=objdump
 169.146 +_LT_DECL([], [OBJDUMP], [1], [Object dumper program])dnl
 169.147 +])# win32-dll
 169.148 +
 169.149 +AU_DEFUN([AC_LIBTOOL_WIN32_DLL],
 169.150 +[AC_REQUIRE([AC_CANONICAL_HOST])dnl
 169.151 +_LT_SET_OPTION([LT_INIT], [win32-dll])
 169.152 +AC_DIAGNOSE([obsolete],
 169.153 +[$0: Remove this warning and the call to _LT_SET_OPTION when you
 169.154 +put the `win32-dll' option into LT_INIT's first parameter.])
 169.155 +])
 169.156 +
 169.157 +dnl aclocal-1.4 backwards compatibility:
 169.158 +dnl AC_DEFUN([AC_LIBTOOL_WIN32_DLL], [])
 169.159 +
 169.160 +
 169.161 +# _LT_ENABLE_SHARED([DEFAULT])
 169.162 +# ----------------------------
 169.163 +# implement the --enable-shared flag, and supports the `shared' and
 169.164 +# `disable-shared' LT_INIT options.
 169.165 +# DEFAULT is either `yes' or `no'.  If omitted, it defaults to `yes'.
 169.166 +m4_define([_LT_ENABLE_SHARED],
 169.167 +[m4_define([_LT_ENABLE_SHARED_DEFAULT], [m4_if($1, no, no, yes)])dnl
 169.168 +AC_ARG_ENABLE([shared],
 169.169 +    [AS_HELP_STRING([--enable-shared@<:@=PKGS@:>@],
 169.170 +	[build shared libraries @<:@default=]_LT_ENABLE_SHARED_DEFAULT[@:>@])],
 169.171 +    [p=${PACKAGE-default}
 169.172 +    case $enableval in
 169.173 +    yes) enable_shared=yes ;;
 169.174 +    no) enable_shared=no ;;
 169.175 +    *)
 169.176 +      enable_shared=no
 169.177 +      # Look at the argument we got.  We use all the common list separators.
 169.178 +      lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR,"
 169.179 +      for pkg in $enableval; do
 169.180 +	IFS="$lt_save_ifs"
 169.181 +	if test "X$pkg" = "X$p"; then
 169.182 +	  enable_shared=yes
 169.183 +	fi
 169.184 +      done
 169.185 +      IFS="$lt_save_ifs"
 169.186 +      ;;
 169.187 +    esac],
 169.188 +    [enable_shared=]_LT_ENABLE_SHARED_DEFAULT)
 169.189 +
 169.190 +    _LT_DECL([build_libtool_libs], [enable_shared], [0],
 169.191 +	[Whether or not to build shared libraries])
 169.192 +])# _LT_ENABLE_SHARED
 169.193 +
 169.194 +LT_OPTION_DEFINE([LT_INIT], [shared], [_LT_ENABLE_SHARED([yes])])
 169.195 +LT_OPTION_DEFINE([LT_INIT], [disable-shared], [_LT_ENABLE_SHARED([no])])
 169.196 +
 169.197 +# Old names:
 169.198 +AC_DEFUN([AC_ENABLE_SHARED],
 169.199 +[_LT_SET_OPTION([LT_INIT], m4_if([$1], [no], [disable-])[shared])
 169.200 +])
 169.201 +
 169.202 +AC_DEFUN([AC_DISABLE_SHARED],
 169.203 +[_LT_SET_OPTION([LT_INIT], [disable-shared])
 169.204 +])
 169.205 +
 169.206 +AU_DEFUN([AM_ENABLE_SHARED], [AC_ENABLE_SHARED($@)])
 169.207 +AU_DEFUN([AM_DISABLE_SHARED], [AC_DISABLE_SHARED($@)])
 169.208 +
 169.209 +dnl aclocal-1.4 backwards compatibility:
 169.210 +dnl AC_DEFUN([AM_ENABLE_SHARED], [])
 169.211 +dnl AC_DEFUN([AM_DISABLE_SHARED], [])
 169.212 +
 169.213 +
 169.214 +
 169.215 +# _LT_ENABLE_STATIC([DEFAULT])
 169.216 +# ----------------------------
 169.217 +# implement the --enable-static flag, and support the `static' and
 169.218 +# `disable-static' LT_INIT options.
 169.219 +# DEFAULT is either `yes' or `no'.  If omitted, it defaults to `yes'.
 169.220 +m4_define([_LT_ENABLE_STATIC],
 169.221 +[m4_define([_LT_ENABLE_STATIC_DEFAULT], [m4_if($1, no, no, yes)])dnl
 169.222 +AC_ARG_ENABLE([static],
 169.223 +    [AS_HELP_STRING([--enable-static@<:@=PKGS@:>@],
 169.224 +	[build static libraries @<:@default=]_LT_ENABLE_STATIC_DEFAULT[@:>@])],
 169.225 +    [p=${PACKAGE-default}
 169.226 +    case $enableval in
 169.227 +    yes) enable_static=yes ;;
 169.228 +    no) enable_static=no ;;
 169.229 +    *)
 169.230 +     enable_static=no
 169.231 +      # Look at the argument we got.  We use all the common list separators.
 169.232 +      lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR,"
 169.233 +      for pkg in $enableval; do
 169.234 +	IFS="$lt_save_ifs"
 169.235 +	if test "X$pkg" = "X$p"; then
 169.236 +	  enable_static=yes
 169.237 +	fi
 169.238 +      done
 169.239 +      IFS="$lt_save_ifs"
 169.240 +      ;;
 169.241 +    esac],
 169.242 +    [enable_static=]_LT_ENABLE_STATIC_DEFAULT)
 169.243 +
 169.244 +    _LT_DECL([build_old_libs], [enable_static], [0],
 169.245 +	[Whether or not to build static libraries])
 169.246 +])# _LT_ENABLE_STATIC
 169.247 +
 169.248 +LT_OPTION_DEFINE([LT_INIT], [static], [_LT_ENABLE_STATIC([yes])])
 169.249 +LT_OPTION_DEFINE([LT_INIT], [disable-static], [_LT_ENABLE_STATIC([no])])
 169.250 +
 169.251 +# Old names:
 169.252 +AC_DEFUN([AC_ENABLE_STATIC],
 169.253 +[_LT_SET_OPTION([LT_INIT], m4_if([$1], [no], [disable-])[static])
 169.254 +])
 169.255 +
 169.256 +AC_DEFUN([AC_DISABLE_STATIC],
 169.257 +[_LT_SET_OPTION([LT_INIT], [disable-static])
 169.258 +])
 169.259 +
 169.260 +AU_DEFUN([AM_ENABLE_STATIC], [AC_ENABLE_STATIC($@)])
 169.261 +AU_DEFUN([AM_DISABLE_STATIC], [AC_DISABLE_STATIC($@)])
 169.262 +
 169.263 +dnl aclocal-1.4 backwards compatibility:
 169.264 +dnl AC_DEFUN([AM_ENABLE_STATIC], [])
 169.265 +dnl AC_DEFUN([AM_DISABLE_STATIC], [])
 169.266 +
 169.267 +
 169.268 +
 169.269 +# _LT_ENABLE_FAST_INSTALL([DEFAULT])
 169.270 +# ----------------------------------
 169.271 +# implement the --enable-fast-install flag, and support the `fast-install'
 169.272 +# and `disable-fast-install' LT_INIT options.
 169.273 +# DEFAULT is either `yes' or `no'.  If omitted, it defaults to `yes'.
 169.274 +m4_define([_LT_ENABLE_FAST_INSTALL],
 169.275 +[m4_define([_LT_ENABLE_FAST_INSTALL_DEFAULT], [m4_if($1, no, no, yes)])dnl
 169.276 +AC_ARG_ENABLE([fast-install],
 169.277 +    [AS_HELP_STRING([--enable-fast-install@<:@=PKGS@:>@],
 169.278 +    [optimize for fast installation @<:@default=]_LT_ENABLE_FAST_INSTALL_DEFAULT[@:>@])],
 169.279 +    [p=${PACKAGE-default}
 169.280 +    case $enableval in
 169.281 +    yes) enable_fast_install=yes ;;
 169.282 +    no) enable_fast_install=no ;;
 169.283 +    *)
 169.284 +      enable_fast_install=no
 169.285 +      # Look at the argument we got.  We use all the common list separators.
 169.286 +      lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR,"
 169.287 +      for pkg in $enableval; do
 169.288 +	IFS="$lt_save_ifs"
 169.289 +	if test "X$pkg" = "X$p"; then
 169.290 +	  enable_fast_install=yes
 169.291 +	fi
 169.292 +      done
 169.293 +      IFS="$lt_save_ifs"
 169.294 +      ;;
 169.295 +    esac],
 169.296 +    [enable_fast_install=]_LT_ENABLE_FAST_INSTALL_DEFAULT)
 169.297 +
 169.298 +_LT_DECL([fast_install], [enable_fast_install], [0],
 169.299 +	 [Whether or not to optimize for fast installation])dnl
 169.300 +])# _LT_ENABLE_FAST_INSTALL
 169.301 +
 169.302 +LT_OPTION_DEFINE([LT_INIT], [fast-install], [_LT_ENABLE_FAST_INSTALL([yes])])
 169.303 +LT_OPTION_DEFINE([LT_INIT], [disable-fast-install], [_LT_ENABLE_FAST_INSTALL([no])])
 169.304 +
 169.305 +# Old names:
 169.306 +AU_DEFUN([AC_ENABLE_FAST_INSTALL],
 169.307 +[_LT_SET_OPTION([LT_INIT], m4_if([$1], [no], [disable-])[fast-install])
 169.308 +AC_DIAGNOSE([obsolete],
 169.309 +[$0: Remove this warning and the call to _LT_SET_OPTION when you put
 169.310 +the `fast-install' option into LT_INIT's first parameter.])
 169.311 +])
 169.312 +
 169.313 +AU_DEFUN([AC_DISABLE_FAST_INSTALL],
 169.314 +[_LT_SET_OPTION([LT_INIT], [disable-fast-install])
 169.315 +AC_DIAGNOSE([obsolete],
 169.316 +[$0: Remove this warning and the call to _LT_SET_OPTION when you put
 169.317 +the `disable-fast-install' option into LT_INIT's first parameter.])
 169.318 +])
 169.319 +
 169.320 +dnl aclocal-1.4 backwards compatibility:
 169.321 +dnl AC_DEFUN([AC_ENABLE_FAST_INSTALL], [])
 169.322 +dnl AC_DEFUN([AM_DISABLE_FAST_INSTALL], [])
 169.323 +
 169.324 +
 169.325 +# _LT_WITH_PIC([MODE])
 169.326 +# --------------------
 169.327 +# implement the --with-pic flag, and support the `pic-only' and `no-pic'
 169.328 +# LT_INIT options.
 169.329 +# MODE is either `yes' or `no'.  If omitted, it defaults to `both'.
 169.330 +m4_define([_LT_WITH_PIC],
 169.331 +[AC_ARG_WITH([pic],
 169.332 +    [AS_HELP_STRING([--with-pic],
 169.333 +	[try to use only PIC/non-PIC objects @<:@default=use both@:>@])],
 169.334 +    [pic_mode="$withval"],
 169.335 +    [pic_mode=default])
 169.336 +
 169.337 +test -z "$pic_mode" && pic_mode=m4_default([$1], [default])
 169.338 +
 169.339 +_LT_DECL([], [pic_mode], [0], [What type of objects to build])dnl
 169.340 +])# _LT_WITH_PIC
 169.341 +
 169.342 +LT_OPTION_DEFINE([LT_INIT], [pic-only], [_LT_WITH_PIC([yes])])
 169.343 +LT_OPTION_DEFINE([LT_INIT], [no-pic], [_LT_WITH_PIC([no])])
 169.344 +
 169.345 +# Old name:
 169.346 +AU_DEFUN([AC_LIBTOOL_PICMODE],
 169.347 +[_LT_SET_OPTION([LT_INIT], [pic-only])
 169.348 +AC_DIAGNOSE([obsolete],
 169.349 +[$0: Remove this warning and the call to _LT_SET_OPTION when you
 169.350 +put the `pic-only' option into LT_INIT's first parameter.])
 169.351 +])
 169.352 +
 169.353 +dnl aclocal-1.4 backwards compatibility:
 169.354 +dnl AC_DEFUN([AC_LIBTOOL_PICMODE], [])
 169.355 +
 169.356 +## ----------------- ##
 169.357 +## LTDL_INIT Options ##
 169.358 +## ----------------- ##
 169.359 +
 169.360 +m4_define([_LTDL_MODE], [])
 169.361 +LT_OPTION_DEFINE([LTDL_INIT], [nonrecursive],
 169.362 +		 [m4_define([_LTDL_MODE], [nonrecursive])])
 169.363 +LT_OPTION_DEFINE([LTDL_INIT], [recursive],
 169.364 +		 [m4_define([_LTDL_MODE], [recursive])])
 169.365 +LT_OPTION_DEFINE([LTDL_INIT], [subproject],
 169.366 +		 [m4_define([_LTDL_MODE], [subproject])])
 169.367 +
 169.368 +m4_define([_LTDL_TYPE], [])
 169.369 +LT_OPTION_DEFINE([LTDL_INIT], [installable],
 169.370 +		 [m4_define([_LTDL_TYPE], [installable])])
 169.371 +LT_OPTION_DEFINE([LTDL_INIT], [convenience],
 169.372 +		 [m4_define([_LTDL_TYPE], [convenience])])
   170.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
   170.2 +++ b/deps/glpk/m4/ltsugar.m4	Sun Nov 06 20:59:10 2011 +0100
   170.3 @@ -0,0 +1,123 @@
   170.4 +# ltsugar.m4 -- libtool m4 base layer.                         -*-Autoconf-*-
   170.5 +#
   170.6 +# Copyright (C) 2004, 2005, 2007, 2008 Free Software Foundation, Inc.
   170.7 +# Written by Gary V. Vaughan, 2004
   170.8 +#
   170.9 +# This file is free software; the Free Software Foundation gives
  170.10 +# unlimited permission to copy and/or distribute it, with or without
  170.11 +# modifications, as long as this notice is preserved.
  170.12 +
  170.13 +# serial 6 ltsugar.m4
  170.14 +
  170.15 +# This is to help aclocal find these macros, as it can't see m4_define.
  170.16 +AC_DEFUN([LTSUGAR_VERSION], [m4_if([0.1])])
  170.17 +
  170.18 +
  170.19 +# lt_join(SEP, ARG1, [ARG2...])
  170.20 +# -----------------------------
  170.21 +# Produce ARG1SEPARG2...SEPARGn, omitting [] arguments and their
  170.22 +# associated separator.
  170.23 +# Needed until we can rely on m4_join from Autoconf 2.62, since all earlier
  170.24 +# versions in m4sugar had bugs.
  170.25 +m4_define([lt_join],
  170.26 +[m4_if([$#], [1], [],
  170.27 +       [$#], [2], [[$2]],
  170.28 +       [m4_if([$2], [], [], [[$2]_])$0([$1], m4_shift(m4_shift($@)))])])
  170.29 +m4_define([_lt_join],
  170.30 +[m4_if([$#$2], [2], [],
  170.31 +       [m4_if([$2], [], [], [[$1$2]])$0([$1], m4_shift(m4_shift($@)))])])
  170.32 +
  170.33 +
  170.34 +# lt_car(LIST)
  170.35 +# lt_cdr(LIST)
  170.36 +# ------------
  170.37 +# Manipulate m4 lists.
  170.38 +# These macros are necessary as long as will still need to support
  170.39 +# Autoconf-2.59 which quotes differently.
  170.40 +m4_define([lt_car], [[$1]])
  170.41 +m4_define([lt_cdr],
  170.42 +[m4_if([$#], 0, [m4_fatal([$0: cannot be called without arguments])],
  170.43 +       [$#], 1, [],
  170.44 +       [m4_dquote(m4_shift($@))])])
  170.45 +m4_define([lt_unquote], $1)
  170.46 +
  170.47 +
  170.48 +# lt_append(MACRO-NAME, STRING, [SEPARATOR])
  170.49 +# ------------------------------------------
  170.50 +# Redefine MACRO-NAME to hold its former content plus `SEPARATOR'`STRING'.
  170.51 +# Note that neither SEPARATOR nor STRING are expanded; they are appended
  170.52 +# to MACRO-NAME as is (leaving the expansion for when MACRO-NAME is invoked).
  170.53 +# No SEPARATOR is output if MACRO-NAME was previously undefined (different
  170.54 +# than defined and empty).
  170.55 +#
  170.56 +# This macro is needed until we can rely on Autoconf 2.62, since earlier
  170.57 +# versions of m4sugar mistakenly expanded SEPARATOR but not STRING.
  170.58 +m4_define([lt_append],
  170.59 +[m4_define([$1],
  170.60 +	   m4_ifdef([$1], [m4_defn([$1])[$3]])[$2])])
  170.61 +
  170.62 +
  170.63 +
  170.64 +# lt_combine(SEP, PREFIX-LIST, INFIX, SUFFIX1, [SUFFIX2...])
  170.65 +# ----------------------------------------------------------
  170.66 +# Produce a SEP delimited list of all paired combinations of elements of
  170.67 +# PREFIX-LIST with SUFFIX1 through SUFFIXn.  Each element of the list
  170.68 +# has the form PREFIXmINFIXSUFFIXn.
  170.69 +# Needed until we can rely on m4_combine added in Autoconf 2.62.
  170.70 +m4_define([lt_combine],
  170.71 +[m4_if(m4_eval([$# > 3]), [1],
  170.72 +       [m4_pushdef([_Lt_sep], [m4_define([_Lt_sep], m4_defn([lt_car]))])]]dnl
  170.73 +[[m4_foreach([_Lt_prefix], [$2],
  170.74 +	     [m4_foreach([_Lt_suffix],
  170.75 +		]m4_dquote(m4_dquote(m4_shift(m4_shift(m4_shift($@)))))[,
  170.76 +	[_Lt_sep([$1])[]m4_defn([_Lt_prefix])[$3]m4_defn([_Lt_suffix])])])])])
  170.77 +
  170.78 +
  170.79 +# lt_if_append_uniq(MACRO-NAME, VARNAME, [SEPARATOR], [UNIQ], [NOT-UNIQ])
  170.80 +# -----------------------------------------------------------------------
  170.81 +# Iff MACRO-NAME does not yet contain VARNAME, then append it (delimited
  170.82 +# by SEPARATOR if supplied) and expand UNIQ, else NOT-UNIQ.
  170.83 +m4_define([lt_if_append_uniq],
  170.84 +[m4_ifdef([$1],
  170.85 +	  [m4_if(m4_index([$3]m4_defn([$1])[$3], [$3$2$3]), [-1],
  170.86 +		 [lt_append([$1], [$2], [$3])$4],
  170.87 +		 [$5])],
  170.88 +	  [lt_append([$1], [$2], [$3])$4])])
  170.89 +
  170.90 +
  170.91 +# lt_dict_add(DICT, KEY, VALUE)
  170.92 +# -----------------------------
  170.93 +m4_define([lt_dict_add],
  170.94 +[m4_define([$1($2)], [$3])])
  170.95 +
  170.96 +
  170.97 +# lt_dict_add_subkey(DICT, KEY, SUBKEY, VALUE)
  170.98 +# --------------------------------------------
  170.99 +m4_define([lt_dict_add_subkey],
 170.100 +[m4_define([$1($2:$3)], [$4])])
 170.101 +
 170.102 +
 170.103 +# lt_dict_fetch(DICT, KEY, [SUBKEY])
 170.104 +# ----------------------------------
 170.105 +m4_define([lt_dict_fetch],
 170.106 +[m4_ifval([$3],
 170.107 +	m4_ifdef([$1($2:$3)], [m4_defn([$1($2:$3)])]),
 170.108 +    m4_ifdef([$1($2)], [m4_defn([$1($2)])]))])
 170.109 +
 170.110 +
 170.111 +# lt_if_dict_fetch(DICT, KEY, [SUBKEY], VALUE, IF-TRUE, [IF-FALSE])
 170.112 +# -----------------------------------------------------------------
 170.113 +m4_define([lt_if_dict_fetch],
 170.114 +[m4_if(lt_dict_fetch([$1], [$2], [$3]), [$4],
 170.115 +	[$5],
 170.116 +    [$6])])
 170.117 +
 170.118 +
 170.119 +# lt_dict_filter(DICT, [SUBKEY], VALUE, [SEPARATOR], KEY, [...])
 170.120 +# --------------------------------------------------------------
 170.121 +m4_define([lt_dict_filter],
 170.122 +[m4_if([$5], [], [],
 170.123 +  [lt_join(m4_quote(m4_default([$4], [[, ]])),
 170.124 +           lt_unquote(m4_split(m4_normalize(m4_foreach(_Lt_key, lt_car([m4_shiftn(4, $@)]),
 170.125 +		      [lt_if_dict_fetch([$1], _Lt_key, [$2], [$3], [_Lt_key ])])))))])[]dnl
 170.126 +])
   171.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
   171.2 +++ b/deps/glpk/m4/ltversion.m4	Sun Nov 06 20:59:10 2011 +0100
   171.3 @@ -0,0 +1,23 @@
   171.4 +# ltversion.m4 -- version numbers			-*- Autoconf -*-
   171.5 +#
   171.6 +#   Copyright (C) 2004 Free Software Foundation, Inc.
   171.7 +#   Written by Scott James Remnant, 2004
   171.8 +#
   171.9 +# This file is free software; the Free Software Foundation gives
  171.10 +# unlimited permission to copy and/or distribute it, with or without
  171.11 +# modifications, as long as this notice is preserved.
  171.12 +
  171.13 +# Generated from ltversion.in.
  171.14 +
  171.15 +# serial 3140 ltversion.m4
  171.16 +# This file is part of GNU Libtool
  171.17 +
  171.18 +m4_define([LT_PACKAGE_VERSION], [2.2.7a])
  171.19 +m4_define([LT_PACKAGE_REVISION], [1.3140])
  171.20 +
  171.21 +AC_DEFUN([LTVERSION_VERSION],
  171.22 +[macro_version='2.2.7a'
  171.23 +macro_revision='1.3140'
  171.24 +_LT_DECL(, macro_version, 0, [Which release of libtool.m4 was used?])
  171.25 +_LT_DECL(, macro_revision, 0)
  171.26 +])
   172.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
   172.2 +++ b/deps/glpk/m4/lt~obsolete.m4	Sun Nov 06 20:59:10 2011 +0100
   172.3 @@ -0,0 +1,98 @@
   172.4 +# lt~obsolete.m4 -- aclocal satisfying obsolete definitions.    -*-Autoconf-*-
   172.5 +#
   172.6 +#   Copyright (C) 2004, 2005, 2007, 2009 Free Software Foundation, Inc.
   172.7 +#   Written by Scott James Remnant, 2004.
   172.8 +#
   172.9 +# This file is free software; the Free Software Foundation gives
  172.10 +# unlimited permission to copy and/or distribute it, with or without
  172.11 +# modifications, as long as this notice is preserved.
  172.12 +
  172.13 +# serial 4 lt~obsolete.m4
  172.14 +
  172.15 +# These exist entirely to fool aclocal when bootstrapping libtool.
  172.16 +#
  172.17 +# In the past libtool.m4 has provided macros via AC_DEFUN (or AU_DEFUN)
  172.18 +# which have later been changed to m4_define as they aren't part of the
  172.19 +# exported API, or moved to Autoconf or Automake where they belong.
  172.20 +#
  172.21 +# The trouble is, aclocal is a bit thick.  It'll see the old AC_DEFUN
  172.22 +# in /usr/share/aclocal/libtool.m4 and remember it, then when it sees us
  172.23 +# using a macro with the same name in our local m4/libtool.m4 it'll
  172.24 +# pull the old libtool.m4 in (it doesn't see our shiny new m4_define
  172.25 +# and doesn't know about Autoconf macros at all.)
  172.26 +#
  172.27 +# So we provide this file, which has a silly filename so it's always
  172.28 +# included after everything else.  This provides aclocal with the
  172.29 +# AC_DEFUNs it wants, but when m4 processes it, it doesn't do anything
  172.30 +# because those macros already exist, or will be overwritten later.
  172.31 +# We use AC_DEFUN over AU_DEFUN for compatibility with aclocal-1.6. 
  172.32 +#
  172.33 +# Anytime we withdraw an AC_DEFUN or AU_DEFUN, remember to add it here.
  172.34 +# Yes, that means every name once taken will need to remain here until
  172.35 +# we give up compatibility with versions before 1.7, at which point
  172.36 +# we need to keep only those names which we still refer to.
  172.37 +
  172.38 +# This is to help aclocal find these macros, as it can't see m4_define.
  172.39 +AC_DEFUN([LTOBSOLETE_VERSION], [m4_if([1])])
  172.40 +
  172.41 +m4_ifndef([AC_LIBTOOL_LINKER_OPTION],	[AC_DEFUN([AC_LIBTOOL_LINKER_OPTION])])
  172.42 +m4_ifndef([AC_PROG_EGREP],		[AC_DEFUN([AC_PROG_EGREP])])
  172.43 +m4_ifndef([_LT_AC_PROG_ECHO_BACKSLASH],	[AC_DEFUN([_LT_AC_PROG_ECHO_BACKSLASH])])
  172.44 +m4_ifndef([_LT_AC_SHELL_INIT],		[AC_DEFUN([_LT_AC_SHELL_INIT])])
  172.45 +m4_ifndef([_LT_AC_SYS_LIBPATH_AIX],	[AC_DEFUN([_LT_AC_SYS_LIBPATH_AIX])])
  172.46 +m4_ifndef([_LT_PROG_LTMAIN],		[AC_DEFUN([_LT_PROG_LTMAIN])])
  172.47 +m4_ifndef([_LT_AC_TAGVAR],		[AC_DEFUN([_LT_AC_TAGVAR])])
  172.48 +m4_ifndef([AC_LTDL_ENABLE_INSTALL],	[AC_DEFUN([AC_LTDL_ENABLE_INSTALL])])
  172.49 +m4_ifndef([AC_LTDL_PREOPEN],		[AC_DEFUN([AC_LTDL_PREOPEN])])
  172.50 +m4_ifndef([_LT_AC_SYS_COMPILER],	[AC_DEFUN([_LT_AC_SYS_COMPILER])])
  172.51 +m4_ifndef([_LT_AC_LOCK],		[AC_DEFUN([_LT_AC_LOCK])])
  172.52 +m4_ifndef([AC_LIBTOOL_SYS_OLD_ARCHIVE],	[AC_DEFUN([AC_LIBTOOL_SYS_OLD_ARCHIVE])])
  172.53 +m4_ifndef([_LT_AC_TRY_DLOPEN_SELF],	[AC_DEFUN([_LT_AC_TRY_DLOPEN_SELF])])
  172.54 +m4_ifndef([AC_LIBTOOL_PROG_CC_C_O],	[AC_DEFUN([AC_LIBTOOL_PROG_CC_C_O])])
  172.55 +m4_ifndef([AC_LIBTOOL_SYS_HARD_LINK_LOCKS], [AC_DEFUN([AC_LIBTOOL_SYS_HARD_LINK_LOCKS])])
  172.56 +m4_ifndef([AC_LIBTOOL_OBJDIR],		[AC_DEFUN([AC_LIBTOOL_OBJDIR])])
  172.57 +m4_ifndef([AC_LTDL_OBJDIR],		[AC_DEFUN([AC_LTDL_OBJDIR])])
  172.58 +m4_ifndef([AC_LIBTOOL_PROG_LD_HARDCODE_LIBPATH], [AC_DEFUN([AC_LIBTOOL_PROG_LD_HARDCODE_LIBPATH])])
  172.59 +m4_ifndef([AC_LIBTOOL_SYS_LIB_STRIP],	[AC_DEFUN([AC_LIBTOOL_SYS_LIB_STRIP])])
  172.60 +m4_ifndef([AC_PATH_MAGIC],		[AC_DEFUN([AC_PATH_MAGIC])])
  172.61 +m4_ifndef([AC_PROG_LD_GNU],		[AC_DEFUN([AC_PROG_LD_GNU])])
  172.62 +m4_ifndef([AC_PROG_LD_RELOAD_FLAG],	[AC_DEFUN([AC_PROG_LD_RELOAD_FLAG])])
  172.63 +m4_ifndef([AC_DEPLIBS_CHECK_METHOD],	[AC_DEFUN([AC_DEPLIBS_CHECK_METHOD])])
  172.64 +m4_ifndef([AC_LIBTOOL_PROG_COMPILER_NO_RTTI], [AC_DEFUN([AC_LIBTOOL_PROG_COMPILER_NO_RTTI])])
  172.65 +m4_ifndef([AC_LIBTOOL_SYS_GLOBAL_SYMBOL_PIPE], [AC_DEFUN([AC_LIBTOOL_SYS_GLOBAL_SYMBOL_PIPE])])
  172.66 +m4_ifndef([AC_LIBTOOL_PROG_COMPILER_PIC], [AC_DEFUN([AC_LIBTOOL_PROG_COMPILER_PIC])])
  172.67 +m4_ifndef([AC_LIBTOOL_PROG_LD_SHLIBS],	[AC_DEFUN([AC_LIBTOOL_PROG_LD_SHLIBS])])
  172.68 +m4_ifndef([AC_LIBTOOL_POSTDEP_PREDEP],	[AC_DEFUN([AC_LIBTOOL_POSTDEP_PREDEP])])
  172.69 +m4_ifndef([LT_AC_PROG_EGREP],		[AC_DEFUN([LT_AC_PROG_EGREP])])
  172.70 +m4_ifndef([LT_AC_PROG_SED],		[AC_DEFUN([LT_AC_PROG_SED])])
  172.71 +m4_ifndef([_LT_CC_BASENAME],		[AC_DEFUN([_LT_CC_BASENAME])])
  172.72 +m4_ifndef([_LT_COMPILER_BOILERPLATE],	[AC_DEFUN([_LT_COMPILER_BOILERPLATE])])
  172.73 +m4_ifndef([_LT_LINKER_BOILERPLATE],	[AC_DEFUN([_LT_LINKER_BOILERPLATE])])
  172.74 +m4_ifndef([_AC_PROG_LIBTOOL],		[AC_DEFUN([_AC_PROG_LIBTOOL])])
  172.75 +m4_ifndef([AC_LIBTOOL_SETUP],		[AC_DEFUN([AC_LIBTOOL_SETUP])])
  172.76 +m4_ifndef([_LT_AC_CHECK_DLFCN],		[AC_DEFUN([_LT_AC_CHECK_DLFCN])])
  172.77 +m4_ifndef([AC_LIBTOOL_SYS_DYNAMIC_LINKER],	[AC_DEFUN([AC_LIBTOOL_SYS_DYNAMIC_LINKER])])
  172.78 +m4_ifndef([_LT_AC_TAGCONFIG],		[AC_DEFUN([_LT_AC_TAGCONFIG])])
  172.79 +m4_ifndef([AC_DISABLE_FAST_INSTALL],	[AC_DEFUN([AC_DISABLE_FAST_INSTALL])])
  172.80 +m4_ifndef([_LT_AC_LANG_CXX],		[AC_DEFUN([_LT_AC_LANG_CXX])])
  172.81 +m4_ifndef([_LT_AC_LANG_F77],		[AC_DEFUN([_LT_AC_LANG_F77])])
  172.82 +m4_ifndef([_LT_AC_LANG_GCJ],		[AC_DEFUN([_LT_AC_LANG_GCJ])])
  172.83 +m4_ifndef([AC_LIBTOOL_LANG_C_CONFIG],	[AC_DEFUN([AC_LIBTOOL_LANG_C_CONFIG])])
  172.84 +m4_ifndef([_LT_AC_LANG_C_CONFIG],	[AC_DEFUN([_LT_AC_LANG_C_CONFIG])])
  172.85 +m4_ifndef([AC_LIBTOOL_LANG_CXX_CONFIG],	[AC_DEFUN([AC_LIBTOOL_LANG_CXX_CONFIG])])
  172.86 +m4_ifndef([_LT_AC_LANG_CXX_CONFIG],	[AC_DEFUN([_LT_AC_LANG_CXX_CONFIG])])
  172.87 +m4_ifndef([AC_LIBTOOL_LANG_F77_CONFIG],	[AC_DEFUN([AC_LIBTOOL_LANG_F77_CONFIG])])
  172.88 +m4_ifndef([_LT_AC_LANG_F77_CONFIG],	[AC_DEFUN([_LT_AC_LANG_F77_CONFIG])])
  172.89 +m4_ifndef([AC_LIBTOOL_LANG_GCJ_CONFIG],	[AC_DEFUN([AC_LIBTOOL_LANG_GCJ_CONFIG])])
  172.90 +m4_ifndef([_LT_AC_LANG_GCJ_CONFIG],	[AC_DEFUN([_LT_AC_LANG_GCJ_CONFIG])])
  172.91 +m4_ifndef([AC_LIBTOOL_LANG_RC_CONFIG],	[AC_DEFUN([AC_LIBTOOL_LANG_RC_CONFIG])])
  172.92 +m4_ifndef([_LT_AC_LANG_RC_CONFIG],	[AC_DEFUN([_LT_AC_LANG_RC_CONFIG])])
  172.93 +m4_ifndef([AC_LIBTOOL_CONFIG],		[AC_DEFUN([AC_LIBTOOL_CONFIG])])
  172.94 +m4_ifndef([_LT_AC_FILE_LTDLL_C],	[AC_DEFUN([_LT_AC_FILE_LTDLL_C])])
  172.95 +m4_ifndef([_LT_REQUIRED_DARWIN_CHECKS],	[AC_DEFUN([_LT_REQUIRED_DARWIN_CHECKS])])
  172.96 +m4_ifndef([_LT_AC_PROG_CXXCPP],		[AC_DEFUN([_LT_AC_PROG_CXXCPP])])
  172.97 +m4_ifndef([_LT_PREPARE_SED_QUOTE_VARS],	[AC_DEFUN([_LT_PREPARE_SED_QUOTE_VARS])])
  172.98 +m4_ifndef([_LT_PROG_ECHO_BACKSLASH],	[AC_DEFUN([_LT_PROG_ECHO_BACKSLASH])])
  172.99 +m4_ifndef([_LT_PROG_F77],		[AC_DEFUN([_LT_PROG_F77])])
 172.100 +m4_ifndef([_LT_PROG_FC],		[AC_DEFUN([_LT_PROG_FC])])
 172.101 +m4_ifndef([_LT_PROG_CXX],		[AC_DEFUN([_LT_PROG_CXX])])
   173.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
   173.2 +++ b/deps/glpk/missing	Sun Nov 06 20:59:10 2011 +0100
   173.3 @@ -0,0 +1,376 @@
   173.4 +#! /bin/sh
   173.5 +# Common stub for a few missing GNU programs while installing.
   173.6 +
   173.7 +scriptversion=2009-04-28.21; # UTC
   173.8 +
   173.9 +# Copyright (C) 1996, 1997, 1999, 2000, 2002, 2003, 2004, 2005, 2006,
  173.10 +# 2008, 2009 Free Software Foundation, Inc.
  173.11 +# Originally by Fran,cois Pinard <pinard@iro.umontreal.ca>, 1996.
  173.12 +
  173.13 +# This program is free software; you can redistribute it and/or modify
  173.14 +# it under the terms of the GNU General Public License as published by
  173.15 +# the Free Software Foundation; either version 2, or (at your option)
  173.16 +# any later version.
  173.17 +
  173.18 +# This program is distributed in the hope that it will be useful,
  173.19 +# but WITHOUT ANY WARRANTY; without even the implied warranty of
  173.20 +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  173.21 +# GNU General Public License for more details.
  173.22 +
  173.23 +# You should have received a copy of the GNU General Public License
  173.24 +# along with this program.  If not, see <http://www.gnu.org/licenses/>.
  173.25 +
  173.26 +# As a special exception to the GNU General Public License, if you
  173.27 +# distribute this file as part of a program that contains a
  173.28 +# configuration script generated by Autoconf, you may include it under
  173.29 +# the same distribution terms that you use for the rest of that program.
  173.30 +
  173.31 +if test $# -eq 0; then
  173.32 +  echo 1>&2 "Try \`$0 --help' for more information"
  173.33 +  exit 1
  173.34 +fi
  173.35 +
  173.36 +run=:
  173.37 +sed_output='s/.* --output[ =]\([^ ]*\).*/\1/p'
  173.38 +sed_minuso='s/.* -o \([^ ]*\).*/\1/p'
  173.39 +
  173.40 +# In the cases where this matters, `missing' is being run in the
  173.41 +# srcdir already.
  173.42 +if test -f configure.ac; then
  173.43 +  configure_ac=configure.ac
  173.44 +else
  173.45 +  configure_ac=configure.in
  173.46 +fi
  173.47 +
  173.48 +msg="missing on your system"
  173.49 +
  173.50 +case $1 in
  173.51 +--run)
  173.52 +  # Try to run requested program, and just exit if it succeeds.
  173.53 +  run=
  173.54 +  shift
  173.55 +  "$@" && exit 0
  173.56 +  # Exit code 63 means version mismatch.  This often happens
  173.57 +  # when the user try to use an ancient version of a tool on
  173.58 +  # a file that requires a minimum version.  In this case we
  173.59 +  # we should proceed has if the program had been absent, or
  173.60 +  # if --run hadn't been passed.
  173.61 +  if test $? = 63; then
  173.62 +    run=:
  173.63 +    msg="probably too old"
  173.64 +  fi
  173.65 +  ;;
  173.66 +
  173.67 +  -h|--h|--he|--hel|--help)
  173.68 +    echo "\
  173.69 +$0 [OPTION]... PROGRAM [ARGUMENT]...
  173.70 +
  173.71 +Handle \`PROGRAM [ARGUMENT]...' for when PROGRAM is missing, or return an
  173.72 +error status if there is no known handling for PROGRAM.
  173.73 +
  173.74 +Options:
  173.75 +  -h, --help      display this help and exit
  173.76 +  -v, --version   output version information and exit
  173.77 +  --run           try to run the given command, and emulate it if it fails
  173.78 +
  173.79 +Supported PROGRAM values:
  173.80 +  aclocal      touch file \`aclocal.m4'
  173.81 +  autoconf     touch file \`configure'
  173.82 +  autoheader   touch file \`config.h.in'
  173.83 +  autom4te     touch the output file, or create a stub one
  173.84 +  automake     touch all \`Makefile.in' files
  173.85 +  bison        create \`y.tab.[ch]', if possible, from existing .[ch]
  173.86 +  flex         create \`lex.yy.c', if possible, from existing .c
  173.87 +  help2man     touch the output file
  173.88 +  lex          create \`lex.yy.c', if possible, from existing .c
  173.89 +  makeinfo     touch the output file
  173.90 +  tar          try tar, gnutar, gtar, then tar without non-portable flags
  173.91 +  yacc         create \`y.tab.[ch]', if possible, from existing .[ch]
  173.92 +
  173.93 +Version suffixes to PROGRAM as well as the prefixes \`gnu-', \`gnu', and
  173.94 +\`g' are ignored when checking the name.
  173.95 +
  173.96 +Send bug reports to <bug-automake@gnu.org>."
  173.97 +    exit $?
  173.98 +    ;;
  173.99 +
 173.100 +  -v|--v|--ve|--ver|--vers|--versi|--versio|--version)
 173.101 +    echo "missing $scriptversion (GNU Automake)"
 173.102 +    exit $?
 173.103 +    ;;
 173.104 +
 173.105 +  -*)
 173.106 +    echo 1>&2 "$0: Unknown \`$1' option"
 173.107 +    echo 1>&2 "Try \`$0 --help' for more information"
 173.108 +    exit 1
 173.109 +    ;;
 173.110 +
 173.111 +esac
 173.112 +
 173.113 +# normalize program name to check for.
 173.114 +program=`echo "$1" | sed '
 173.115 +  s/^gnu-//; t
 173.116 +  s/^gnu//; t
 173.117 +  s/^g//; t'`
 173.118 +
 173.119 +# Now exit if we have it, but it failed.  Also exit now if we
 173.120 +# don't have it and --version was passed (most likely to detect
 173.121 +# the program).  This is about non-GNU programs, so use $1 not
 173.122 +# $program.
 173.123 +case $1 in
 173.124 +  lex*|yacc*)
 173.125 +    # Not GNU programs, they don't have --version.
 173.126 +    ;;
 173.127 +
 173.128 +  tar*)
 173.129 +    if test -n "$run"; then
 173.130 +       echo 1>&2 "ERROR: \`tar' requires --run"
 173.131 +       exit 1
 173.132 +    elif test "x$2" = "x--version" || test "x$2" = "x--help"; then
 173.133 +       exit 1
 173.134 +    fi
 173.135 +    ;;
 173.136 +
 173.137 +  *)
 173.138 +    if test -z "$run" && ($1 --version) > /dev/null 2>&1; then
 173.139 +       # We have it, but it failed.
 173.140 +       exit 1
 173.141 +    elif test "x$2" = "x--version" || test "x$2" = "x--help"; then
 173.142 +       # Could not run --version or --help.  This is probably someone
 173.143 +       # running `$TOOL --version' or `$TOOL --help' to check whether
 173.144 +       # $TOOL exists and not knowing $TOOL uses missing.
 173.145 +       exit 1
 173.146 +    fi
 173.147 +    ;;
 173.148 +esac
 173.149 +
 173.150 +# If it does not exist, or fails to run (possibly an outdated version),
 173.151 +# try to emulate it.
 173.152 +case $program in
 173.153 +  aclocal*)
 173.154 +    echo 1>&2 "\
 173.155 +WARNING: \`$1' is $msg.  You should only need it if
 173.156 +         you modified \`acinclude.m4' or \`${configure_ac}'.  You might want
 173.157 +         to install the \`Automake' and \`Perl' packages.  Grab them from
 173.158 +         any GNU archive site."
 173.159 +    touch aclocal.m4
 173.160 +    ;;
 173.161 +
 173.162 +  autoconf*)
 173.163 +    echo 1>&2 "\
 173.164 +WARNING: \`$1' is $msg.  You should only need it if
 173.165 +         you modified \`${configure_ac}'.  You might want to install the
 173.166 +         \`Autoconf' and \`GNU m4' packages.  Grab them from any GNU
 173.167 +         archive site."
 173.168 +    touch configure
 173.169 +    ;;
 173.170 +
 173.171 +  autoheader*)
 173.172 +    echo 1>&2 "\
 173.173 +WARNING: \`$1' is $msg.  You should only need it if
 173.174 +         you modified \`acconfig.h' or \`${configure_ac}'.  You might want
 173.175 +         to install the \`Autoconf' and \`GNU m4' packages.  Grab them
 173.176 +         from any GNU archive site."
 173.177 +    files=`sed -n 's/^[ ]*A[CM]_CONFIG_HEADER(\([^)]*\)).*/\1/p' ${configure_ac}`
 173.178 +    test -z "$files" && files="config.h"
 173.179 +    touch_files=
 173.180 +    for f in $files; do
 173.181 +      case $f in
 173.182 +      *:*) touch_files="$touch_files "`echo "$f" |
 173.183 +				       sed -e 's/^[^:]*://' -e 's/:.*//'`;;
 173.184 +      *) touch_files="$touch_files $f.in";;
 173.185 +      esac
 173.186 +    done
 173.187 +    touch $touch_files
 173.188 +    ;;
 173.189 +
 173.190 +  automake*)
 173.191 +    echo 1>&2 "\
 173.192 +WARNING: \`$1' is $msg.  You should only need it if
 173.193 +         you modified \`Makefile.am', \`acinclude.m4' or \`${configure_ac}'.
 173.194 +         You might want to install the \`Automake' and \`Perl' packages.
 173.195 +         Grab them from any GNU archive site."
 173.196 +    find . -type f -name Makefile.am -print |
 173.197 +	   sed 's/\.am$/.in/' |
 173.198 +	   while read f; do touch "$f"; done
 173.199 +    ;;
 173.200 +
 173.201 +  autom4te*)
 173.202 +    echo 1>&2 "\
 173.203 +WARNING: \`$1' is needed, but is $msg.
 173.204 +         You might have modified some files without having the
 173.205 +         proper tools for further handling them.
 173.206 +         You can get \`$1' as part of \`Autoconf' from any GNU
 173.207 +         archive site."
 173.208 +
 173.209 +    file=`echo "$*" | sed -n "$sed_output"`
 173.210 +    test -z "$file" && file=`echo "$*" | sed -n "$sed_minuso"`
 173.211 +    if test -f "$file"; then
 173.212 +	touch $file
 173.213 +    else
 173.214 +	test -z "$file" || exec >$file
 173.215 +	echo "#! /bin/sh"
 173.216 +	echo "# Created by GNU Automake missing as a replacement of"
 173.217 +	echo "#  $ $@"
 173.218 +	echo "exit 0"
 173.219 +	chmod +x $file
 173.220 +	exit 1
 173.221 +    fi
 173.222 +    ;;
 173.223 +
 173.224 +  bison*|yacc*)
 173.225 +    echo 1>&2 "\
 173.226 +WARNING: \`$1' $msg.  You should only need it if
 173.227 +         you modified a \`.y' file.  You may need the \`Bison' package
 173.228 +         in order for those modifications to take effect.  You can get
 173.229 +         \`Bison' from any GNU archive site."
 173.230 +    rm -f y.tab.c y.tab.h
 173.231 +    if test $# -ne 1; then
 173.232 +        eval LASTARG="\${$#}"
 173.233 +	case $LASTARG in
 173.234 +	*.y)
 173.235 +	    SRCFILE=`echo "$LASTARG" | sed 's/y$/c/'`
 173.236 +	    if test -f "$SRCFILE"; then
 173.237 +	         cp "$SRCFILE" y.tab.c
 173.238 +	    fi
 173.239 +	    SRCFILE=`echo "$LASTARG" | sed 's/y$/h/'`
 173.240 +	    if test -f "$SRCFILE"; then
 173.241 +	         cp "$SRCFILE" y.tab.h
 173.242 +	    fi
 173.243 +	  ;;
 173.244 +	esac
 173.245 +    fi
 173.246 +    if test ! -f y.tab.h; then
 173.247 +	echo >y.tab.h
 173.248 +    fi
 173.249 +    if test ! -f y.tab.c; then
 173.250 +	echo 'main() { return 0; }' >y.tab.c
 173.251 +    fi
 173.252 +    ;;
 173.253 +
 173.254 +  lex*|flex*)
 173.255 +    echo 1>&2 "\
 173.256 +WARNING: \`$1' is $msg.  You should only need it if
 173.257 +         you modified a \`.l' file.  You may need the \`Flex' package
 173.258 +         in order for those modifications to take effect.  You can get
 173.259 +         \`Flex' from any GNU archive site."
 173.260 +    rm -f lex.yy.c
 173.261 +    if test $# -ne 1; then
 173.262 +        eval LASTARG="\${$#}"
 173.263 +	case $LASTARG in
 173.264 +	*.l)
 173.265 +	    SRCFILE=`echo "$LASTARG" | sed 's/l$/c/'`
 173.266 +	    if test -f "$SRCFILE"; then
 173.267 +	         cp "$SRCFILE" lex.yy.c
 173.268 +	    fi
 173.269 +	  ;;
 173.270 +	esac
 173.271 +    fi
 173.272 +    if test ! -f lex.yy.c; then
 173.273 +	echo 'main() { return 0; }' >lex.yy.c
 173.274 +    fi
 173.275 +    ;;
 173.276 +
 173.277 +  help2man*)
 173.278 +    echo 1>&2 "\
 173.279 +WARNING: \`$1' is $msg.  You should only need it if
 173.280 +	 you modified a dependency of a manual page.  You may need the
 173.281 +	 \`Help2man' package in order for those modifications to take
 173.282 +	 effect.  You can get \`Help2man' from any GNU archive site."
 173.283 +
 173.284 +    file=`echo "$*" | sed -n "$sed_output"`
 173.285 +    test -z "$file" && file=`echo "$*" | sed -n "$sed_minuso"`
 173.286 +    if test -f "$file"; then
 173.287 +	touch $file
 173.288 +    else
 173.289 +	test -z "$file" || exec >$file
 173.290 +	echo ".ab help2man is required to generate this page"
 173.291 +	exit $?
 173.292 +    fi
 173.293 +    ;;
 173.294 +
 173.295 +  makeinfo*)
 173.296 +    echo 1>&2 "\
 173.297 +WARNING: \`$1' is $msg.  You should only need it if
 173.298 +         you modified a \`.texi' or \`.texinfo' file, or any other file
 173.299 +         indirectly affecting the aspect of the manual.  The spurious
 173.300 +         call might also be the consequence of using a buggy \`make' (AIX,
 173.301 +         DU, IRIX).  You might want to install the \`Texinfo' package or
 173.302 +         the \`GNU make' package.  Grab either from any GNU archive site."
 173.303 +    # The file to touch is that specified with -o ...
 173.304 +    file=`echo "$*" | sed -n "$sed_output"`
 173.305 +    test -z "$file" && file=`echo "$*" | sed -n "$sed_minuso"`
 173.306 +    if test -z "$file"; then
 173.307 +      # ... or it is the one specified with @setfilename ...
 173.308 +      infile=`echo "$*" | sed 's/.* \([^ ]*\) *$/\1/'`
 173.309 +      file=`sed -n '
 173.310 +	/^@setfilename/{
 173.311 +	  s/.* \([^ ]*\) *$/\1/
 173.312 +	  p
 173.313 +	  q
 173.314 +	}' $infile`
 173.315 +      # ... or it is derived from the source name (dir/f.texi becomes f.info)
 173.316 +      test -z "$file" && file=`echo "$infile" | sed 's,.*/,,;s,.[^.]*$,,'`.info
 173.317 +    fi
 173.318 +    # If the file does not exist, the user really needs makeinfo;
 173.319 +    # let's fail without touching anything.
 173.320 +    test -f $file || exit 1
 173.321 +    touch $file
 173.322 +    ;;
 173.323 +
 173.324 +  tar*)
 173.325 +    shift
 173.326 +
 173.327 +    # We have already tried tar in the generic part.
 173.328 +    # Look for gnutar/gtar before invocation to avoid ugly error
 173.329 +    # messages.
 173.330 +    if (gnutar --version > /dev/null 2>&1); then
 173.331 +       gnutar "$@" && exit 0
 173.332 +    fi
 173.333 +    if (gtar --version > /dev/null 2>&1); then
 173.334 +       gtar "$@" && exit 0
 173.335 +    fi
 173.336 +    firstarg="$1"
 173.337 +    if shift; then
 173.338 +	case $firstarg in
 173.339 +	*o*)
 173.340 +	    firstarg=`echo "$firstarg" | sed s/o//`
 173.341 +	    tar "$firstarg" "$@" && exit 0
 173.342 +	    ;;
 173.343 +	esac
 173.344 +	case $firstarg in
 173.345 +	*h*)
 173.346 +	    firstarg=`echo "$firstarg" | sed s/h//`
 173.347 +	    tar "$firstarg" "$@" && exit 0
 173.348 +	    ;;
 173.349 +	esac
 173.350 +    fi
 173.351 +
 173.352 +    echo 1>&2 "\
 173.353 +WARNING: I can't seem to be able to run \`tar' with the given arguments.
 173.354 +         You may want to install GNU tar or Free paxutils, or check the
 173.355 +         command line arguments."
 173.356 +    exit 1
 173.357 +    ;;
 173.358 +
 173.359 +  *)
 173.360 +    echo 1>&2 "\
 173.361 +WARNING: \`$1' is needed, and is $msg.
 173.362 +         You might have modified some files without having the
 173.363 +         proper tools for further handling them.  Check the \`README' file,
 173.364 +         it often tells you about the needed prerequisites for installing
 173.365 +         this package.  You may also peek at any GNU archive site, in case
 173.366 +         some other package would contain this missing \`$1' program."
 173.367 +    exit 1
 173.368 +    ;;
 173.369 +esac
 173.370 +
 173.371 +exit 0
 173.372 +
 173.373 +# Local variables:
 173.374 +# eval: (add-hook 'write-file-hooks 'time-stamp)
 173.375 +# time-stamp-start: "scriptversion="
 173.376 +# time-stamp-format: "%:y-%02m-%02d.%02H"
 173.377 +# time-stamp-time-zone: "UTC"
 173.378 +# time-stamp-end: "; # UTC"
 173.379 +# End:
   174.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
   174.2 +++ b/deps/glpk/src/Makefile.am	Sun Nov 06 20:59:10 2011 +0100
   174.3 @@ -0,0 +1,141 @@
   174.4 +## Process this file with automake to produce Makefile.in ##
   174.5 +
   174.6 +include_HEADERS = glpk.h
   174.7 +
   174.8 +lib_LTLIBRARIES = libglpk.la
   174.9 +
  174.10 +libglpk_la_LDFLAGS = -version-info 32:0:32 \
  174.11 +-export-symbols-regex '^(glp_|_glp_lpx_).*'
  174.12 +
  174.13 +libglpk_la_SOURCES = \
  174.14 +glpapi01.c \
  174.15 +glpapi02.c \
  174.16 +glpapi03.c \
  174.17 +glpapi04.c \
  174.18 +glpapi05.c \
  174.19 +glpapi06.c \
  174.20 +glpapi07.c \
  174.21 +glpapi08.c \
  174.22 +glpapi09.c \
  174.23 +glpapi10.c \
  174.24 +glpapi11.c \
  174.25 +glpapi12.c \
  174.26 +glpapi13.c \
  174.27 +glpapi14.c \
  174.28 +glpapi15.c \
  174.29 +glpapi16.c \
  174.30 +glpapi17.c \
  174.31 +glpapi18.c \
  174.32 +glpapi19.c \
  174.33 +glpapi20.c \
  174.34 +glpapi21.c \
  174.35 +glpavl.c \
  174.36 +glpbfd.c \
  174.37 +glpbfx.c \
  174.38 +glpcpx.c \
  174.39 +glpdmp.c \
  174.40 +glpdmx.c \
  174.41 +glpenv01.c \
  174.42 +glpenv02.c \
  174.43 +glpenv03.c \
  174.44 +glpenv04.c \
  174.45 +glpenv05.c \
  174.46 +glpenv06.c \
  174.47 +glpenv07.c \
  174.48 +glpenv08.c \
  174.49 +glpfhv.c \
  174.50 +glpgmp.c \
  174.51 +glphbm.c \
  174.52 +glpini01.c \
  174.53 +glpini02.c \
  174.54 +glpios01.c \
  174.55 +glpios02.c \
  174.56 +glpios03.c \
  174.57 +glpios04.c \
  174.58 +glpios05.c \
  174.59 +glpios06.c \
  174.60 +glpios07.c \
  174.61 +glpios08.c \
  174.62 +glpios09.c \
  174.63 +glpios10.c \
  174.64 +glpios11.c \
  174.65 +glpios12.c \
  174.66 +glpipm.c \
  174.67 +glplib01.c \
  174.68 +glplib02.c \
  174.69 +glplib03.c \
  174.70 +glplpf.c \
  174.71 +glplpx01.c \
  174.72 +glplpx02.c \
  174.73 +glplpx03.c \
  174.74 +glpluf.c \
  174.75 +glplux.c \
  174.76 +glpmat.c \
  174.77 +glpmpl01.c \
  174.78 +glpmpl02.c \
  174.79 +glpmpl03.c \
  174.80 +glpmpl04.c \
  174.81 +glpmpl05.c \
  174.82 +glpmpl06.c \
  174.83 +glpmps.c \
  174.84 +glpnet01.c \
  174.85 +glpnet02.c \
  174.86 +glpnet03.c \
  174.87 +glpnet04.c \
  174.88 +glpnet05.c \
  174.89 +glpnet06.c \
  174.90 +glpnet07.c \
  174.91 +glpnet08.c \
  174.92 +glpnet09.c \
  174.93 +glpnpp01.c \
  174.94 +glpnpp02.c \
  174.95 +glpnpp03.c \
  174.96 +glpnpp04.c \
  174.97 +glpnpp05.c \
  174.98 +glpnpp06.c \
  174.99 +glpqmd.c \
 174.100 +glprgr.c \
 174.101 +glprng01.c \
 174.102 +glprng02.c \
 174.103 +glpscf.c \
 174.104 +glpscl.c \
 174.105 +glpsdf.c \
 174.106 +glpspm.c \
 174.107 +glpspx01.c \
 174.108 +glpspx02.c \
 174.109 +glpsql.c \
 174.110 +glpssx01.c \
 174.111 +glpssx02.c \
 174.112 +glptsp.c \
 174.113 +amd/amd_1.c \
 174.114 +amd/amd_2.c \
 174.115 +amd/amd_aat.c \
 174.116 +amd/amd_control.c \
 174.117 +amd/amd_defaults.c \
 174.118 +amd/amd_dump.c \
 174.119 +amd/amd_info.c \
 174.120 +amd/amd_order.c \
 174.121 +amd/amd_post_tree.c \
 174.122 +amd/amd_postorder.c \
 174.123 +amd/amd_preprocess.c \
 174.124 +amd/amd_valid.c \
 174.125 +colamd/colamd.c \
 174.126 +minisat/minisat.c \
 174.127 +zlib/adler32.c \
 174.128 +zlib/compress.c \
 174.129 +zlib/crc32.c \
 174.130 +zlib/deflate.c \
 174.131 +zlib/gzclose.c \
 174.132 +zlib/gzlib.c \
 174.133 +zlib/gzread.c \
 174.134 +zlib/gzwrite.c \
 174.135 +zlib/infback.c \
 174.136 +zlib/inffast.c \
 174.137 +zlib/inflate.c \
 174.138 +zlib/inftrees.c \
 174.139 +zlib/trees.c \
 174.140 +zlib/uncompr.c \
 174.141 +zlib/zio.c \
 174.142 +zlib/zutil.c
 174.143 +
 174.144 +## eof ##
   175.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
   175.2 +++ b/deps/glpk/src/Makefile.in	Sun Nov 06 20:59:10 2011 +0100
   175.3 @@ -0,0 +1,1040 @@
   175.4 +# Makefile.in generated by automake 1.11.1 from Makefile.am.
   175.5 +# @configure_input@
   175.6 +
   175.7 +# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
   175.8 +# 2003, 2004, 2005, 2006, 2007, 2008, 2009  Free Software Foundation,
   175.9 +# Inc.
  175.10 +# This Makefile.in is free software; the Free Software Foundation
  175.11 +# gives unlimited permission to copy and/or distribute it,
  175.12 +# with or without modifications, as long as this notice is preserved.
  175.13 +
  175.14 +# This program is distributed in the hope that it will be useful,
  175.15 +# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
  175.16 +# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
  175.17 +# PARTICULAR PURPOSE.
  175.18 +
  175.19 +@SET_MAKE@
  175.20 +
  175.21 +
  175.22 +VPATH = @srcdir@
  175.23 +pkgdatadir = $(datadir)/@PACKAGE@
  175.24 +pkgincludedir = $(includedir)/@PACKAGE@
  175.25 +pkglibdir = $(libdir)/@PACKAGE@
  175.26 +pkglibexecdir = $(libexecdir)/@PACKAGE@
  175.27 +am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
  175.28 +install_sh_DATA = $(install_sh) -c -m 644
  175.29 +install_sh_PROGRAM = $(install_sh) -c
  175.30 +install_sh_SCRIPT = $(install_sh) -c
  175.31 +INSTALL_HEADER = $(INSTALL_DATA)
  175.32 +transform = $(program_transform_name)
  175.33 +NORMAL_INSTALL = :
  175.34 +PRE_INSTALL = :
  175.35 +POST_INSTALL = :
  175.36 +NORMAL_UNINSTALL = :
  175.37 +PRE_UNINSTALL = :
  175.38 +POST_UNINSTALL = :
  175.39 +build_triplet = @build@
  175.40 +host_triplet = @host@
  175.41 +subdir = src
  175.42 +DIST_COMMON = $(include_HEADERS) $(srcdir)/Makefile.am \
  175.43 +	$(srcdir)/Makefile.in
  175.44 +ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
  175.45 +am__aclocal_m4_deps = $(top_srcdir)/m4/libtool.m4 \
  175.46 +	$(top_srcdir)/m4/ltoptions.m4 $(top_srcdir)/m4/ltsugar.m4 \
  175.47 +	$(top_srcdir)/m4/ltversion.m4 $(top_srcdir)/m4/lt~obsolete.m4 \
  175.48 +	$(top_srcdir)/configure.ac
  175.49 +am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
  175.50 +	$(ACLOCAL_M4)
  175.51 +mkinstalldirs = $(install_sh) -d
  175.52 +CONFIG_HEADER = $(top_builddir)/config.h
  175.53 +CONFIG_CLEAN_FILES =
  175.54 +CONFIG_CLEAN_VPATH_FILES =
  175.55 +am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`;
  175.56 +am__vpath_adj = case $$p in \
  175.57 +    $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \
  175.58 +    *) f=$$p;; \
  175.59 +  esac;
  175.60 +am__strip_dir = f=`echo $$p | sed -e 's|^.*/||'`;
  175.61 +am__install_max = 40
  175.62 +am__nobase_strip_setup = \
  175.63 +  srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*|]/\\\\&/g'`
  175.64 +am__nobase_strip = \
  175.65 +  for p in $$list; do echo "$$p"; done | sed -e "s|$$srcdirstrip/||"
  175.66 +am__nobase_list = $(am__nobase_strip_setup); \
  175.67 +  for p in $$list; do echo "$$p $$p"; done | \
  175.68 +  sed "s| $$srcdirstrip/| |;"' / .*\//!s/ .*/ ./; s,\( .*\)/[^/]*$$,\1,' | \
  175.69 +  $(AWK) 'BEGIN { files["."] = "" } { files[$$2] = files[$$2] " " $$1; \
  175.70 +    if (++n[$$2] == $(am__install_max)) \
  175.71 +      { print $$2, files[$$2]; n[$$2] = 0; files[$$2] = "" } } \
  175.72 +    END { for (dir in files) print dir, files[dir] }'
  175.73 +am__base_list = \
  175.74 +  sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | \
  175.75 +  sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g'
  175.76 +am__installdirs = "$(DESTDIR)$(libdir)" "$(DESTDIR)$(includedir)"
  175.77 +LTLIBRARIES = $(lib_LTLIBRARIES)
  175.78 +libglpk_la_LIBADD =
  175.79 +am_libglpk_la_OBJECTS = glpapi01.lo glpapi02.lo glpapi03.lo \
  175.80 +	glpapi04.lo glpapi05.lo glpapi06.lo glpapi07.lo glpapi08.lo \
  175.81 +	glpapi09.lo glpapi10.lo glpapi11.lo glpapi12.lo glpapi13.lo \
  175.82 +	glpapi14.lo glpapi15.lo glpapi16.lo glpapi17.lo glpapi18.lo \
  175.83 +	glpapi19.lo glpapi20.lo glpapi21.lo glpavl.lo glpbfd.lo \
  175.84 +	glpbfx.lo glpcpx.lo glpdmp.lo glpdmx.lo glpenv01.lo \
  175.85 +	glpenv02.lo glpenv03.lo glpenv04.lo glpenv05.lo glpenv06.lo \
  175.86 +	glpenv07.lo glpenv08.lo glpfhv.lo glpgmp.lo glphbm.lo \
  175.87 +	glpini01.lo glpini02.lo glpios01.lo glpios02.lo glpios03.lo \
  175.88 +	glpios04.lo glpios05.lo glpios06.lo glpios07.lo glpios08.lo \
  175.89 +	glpios09.lo glpios10.lo glpios11.lo glpios12.lo glpipm.lo \
  175.90 +	glplib01.lo glplib02.lo glplib03.lo glplpf.lo glplpx01.lo \
  175.91 +	glplpx02.lo glplpx03.lo glpluf.lo glplux.lo glpmat.lo \
  175.92 +	glpmpl01.lo glpmpl02.lo glpmpl03.lo glpmpl04.lo glpmpl05.lo \
  175.93 +	glpmpl06.lo glpmps.lo glpnet01.lo glpnet02.lo glpnet03.lo \
  175.94 +	glpnet04.lo glpnet05.lo glpnet06.lo glpnet07.lo glpnet08.lo \
  175.95 +	glpnet09.lo glpnpp01.lo glpnpp02.lo glpnpp03.lo glpnpp04.lo \
  175.96 +	glpnpp05.lo glpnpp06.lo glpqmd.lo glprgr.lo glprng01.lo \
  175.97 +	glprng02.lo glpscf.lo glpscl.lo glpsdf.lo glpspm.lo \
  175.98 +	glpspx01.lo glpspx02.lo glpsql.lo glpssx01.lo glpssx02.lo \
  175.99 +	glptsp.lo amd_1.lo amd_2.lo amd_aat.lo amd_control.lo \
 175.100 +	amd_defaults.lo amd_dump.lo amd_info.lo amd_order.lo \
 175.101 +	amd_post_tree.lo amd_postorder.lo amd_preprocess.lo \
 175.102 +	amd_valid.lo colamd.lo minisat.lo adler32.lo compress.lo \
 175.103 +	crc32.lo deflate.lo gzclose.lo gzlib.lo gzread.lo gzwrite.lo \
 175.104 +	infback.lo inffast.lo inflate.lo inftrees.lo trees.lo \
 175.105 +	uncompr.lo zio.lo zutil.lo
 175.106 +libglpk_la_OBJECTS = $(am_libglpk_la_OBJECTS)
 175.107 +libglpk_la_LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) \
 175.108 +	$(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
 175.109 +	$(libglpk_la_LDFLAGS) $(LDFLAGS) -o $@
 175.110 +DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir)
 175.111 +depcomp = $(SHELL) $(top_srcdir)/depcomp
 175.112 +am__depfiles_maybe = depfiles
 175.113 +am__mv = mv -f
 175.114 +COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
 175.115 +	$(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
 175.116 +LTCOMPILE = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
 175.117 +	--mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \
 175.118 +	$(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
 175.119 +CCLD = $(CC)
 175.120 +LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
 175.121 +	--mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) \
 175.122 +	$(LDFLAGS) -o $@
 175.123 +SOURCES = $(libglpk_la_SOURCES)
 175.124 +DIST_SOURCES = $(libglpk_la_SOURCES)
 175.125 +HEADERS = $(include_HEADERS)
 175.126 +ETAGS = etags
 175.127 +CTAGS = ctags
 175.128 +DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
 175.129 +ACLOCAL = @ACLOCAL@
 175.130 +AMTAR = @AMTAR@
 175.131 +AR = @AR@
 175.132 +AUTOCONF = @AUTOCONF@
 175.133 +AUTOHEADER = @AUTOHEADER@
 175.134 +AUTOMAKE = @AUTOMAKE@
 175.135 +AWK = @AWK@
 175.136 +CC = @CC@
 175.137 +CCDEPMODE = @CCDEPMODE@
 175.138 +CFLAGS = @CFLAGS@
 175.139 +CPP = @CPP@
 175.140 +CPPFLAGS = @CPPFLAGS@
 175.141 +CYGPATH_W = @CYGPATH_W@
 175.142 +DEFS = @DEFS@
 175.143 +DEPDIR = @DEPDIR@
 175.144 +DLLTOOL = @DLLTOOL@
 175.145 +DSYMUTIL = @DSYMUTIL@
 175.146 +DUMPBIN = @DUMPBIN@
 175.147 +ECHO_C = @ECHO_C@
 175.148 +ECHO_N = @ECHO_N@
 175.149 +ECHO_T = @ECHO_T@
 175.150 +EGREP = @EGREP@
 175.151 +EXEEXT = @EXEEXT@
 175.152 +FGREP = @FGREP@
 175.153 +GREP = @GREP@
 175.154 +INSTALL = @INSTALL@
 175.155 +INSTALL_DATA = @INSTALL_DATA@
 175.156 +INSTALL_PROGRAM = @INSTALL_PROGRAM@
 175.157 +INSTALL_SCRIPT = @INSTALL_SCRIPT@
 175.158 +INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
 175.159 +LD = @LD@
 175.160 +LDFLAGS = @LDFLAGS@
 175.161 +LIBOBJS = @LIBOBJS@
 175.162 +LIBS = @LIBS@
 175.163 +LIBTOOL = @LIBTOOL@
 175.164 +LIPO = @LIPO@
 175.165 +LN_S = @LN_S@
 175.166 +LTLIBOBJS = @LTLIBOBJS@
 175.167 +MAKEINFO = @MAKEINFO@
 175.168 +MKDIR_P = @MKDIR_P@
 175.169 +NM = @NM@
 175.170 +NMEDIT = @NMEDIT@
 175.171 +OBJDUMP = @OBJDUMP@
 175.172 +OBJEXT = @OBJEXT@
 175.173 +OTOOL = @OTOOL@
 175.174 +OTOOL64 = @OTOOL64@
 175.175 +PACKAGE = @PACKAGE@
 175.176 +PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
 175.177 +PACKAGE_NAME = @PACKAGE_NAME@
 175.178 +PACKAGE_STRING = @PACKAGE_STRING@
 175.179 +PACKAGE_TARNAME = @PACKAGE_TARNAME@
 175.180 +PACKAGE_URL = @PACKAGE_URL@
 175.181 +PACKAGE_VERSION = @PACKAGE_VERSION@
 175.182 +PATH_SEPARATOR = @PATH_SEPARATOR@
 175.183 +RANLIB = @RANLIB@
 175.184 +SED = @SED@
 175.185 +SET_MAKE = @SET_MAKE@
 175.186 +SHELL = @SHELL@
 175.187 +STRIP = @STRIP@
 175.188 +VERSION = @VERSION@
 175.189 +abs_builddir = @abs_builddir@
 175.190 +abs_srcdir = @abs_srcdir@
 175.191 +abs_top_builddir = @abs_top_builddir@
 175.192 +abs_top_srcdir = @abs_top_srcdir@
 175.193 +ac_ct_CC = @ac_ct_CC@
 175.194 +ac_ct_DUMPBIN = @ac_ct_DUMPBIN@
 175.195 +am__include = @am__include@
 175.196 +am__leading_dot = @am__leading_dot@
 175.197 +am__quote = @am__quote@
 175.198 +am__tar = @am__tar@
 175.199 +am__untar = @am__untar@
 175.200 +bindir = @bindir@
 175.201 +build = @build@
 175.202 +build_alias = @build_alias@
 175.203 +build_cpu = @build_cpu@
 175.204 +build_os = @build_os@
 175.205 +build_vendor = @build_vendor@
 175.206 +builddir = @builddir@
 175.207 +datadir = @datadir@
 175.208 +datarootdir = @datarootdir@
 175.209 +docdir = @docdir@
 175.210 +dvidir = @dvidir@
 175.211 +exec_prefix = @exec_prefix@
 175.212 +host = @host@
 175.213 +host_alias = @host_alias@
 175.214 +host_cpu = @host_cpu@
 175.215 +host_os = @host_os@
 175.216 +host_vendor = @host_vendor@
 175.217 +htmldir = @htmldir@
 175.218 +includedir = @includedir@
 175.219 +infodir = @infodir@
 175.220 +install_sh = @install_sh@
 175.221 +libdir = @libdir@
 175.222 +libexecdir = @libexecdir@
 175.223 +localedir = @localedir@
 175.224 +localstatedir = @localstatedir@
 175.225 +mandir = @mandir@
 175.226 +mkdir_p = @mkdir_p@
 175.227 +oldincludedir = @oldincludedir@
 175.228 +pdfdir = @pdfdir@
 175.229 +prefix = @prefix@
 175.230 +program_transform_name = @program_transform_name@
 175.231 +psdir = @psdir@
 175.232 +sbindir = @sbindir@
 175.233 +sharedstatedir = @sharedstatedir@
 175.234 +srcdir = @srcdir@
 175.235 +sysconfdir = @sysconfdir@
 175.236 +target_alias = @target_alias@
 175.237 +to_host_path_cmd = @to_host_path_cmd@
 175.238 +top_build_prefix = @top_build_prefix@
 175.239 +top_builddir = @top_builddir@
 175.240 +top_srcdir = @top_srcdir@
 175.241 +include_HEADERS = glpk.h
 175.242 +lib_LTLIBRARIES = libglpk.la
 175.243 +libglpk_la_LDFLAGS = -version-info 32:0:32 \
 175.244 +-export-symbols-regex '^(glp_|_glp_lpx_).*'
 175.245 +
 175.246 +libglpk_la_SOURCES = \
 175.247 +glpapi01.c \
 175.248 +glpapi02.c \
 175.249 +glpapi03.c \
 175.250 +glpapi04.c \
 175.251 +glpapi05.c \
 175.252 +glpapi06.c \
 175.253 +glpapi07.c \
 175.254 +glpapi08.c \
 175.255 +glpapi09.c \
 175.256 +glpapi10.c \
 175.257 +glpapi11.c \
 175.258 +glpapi12.c \
 175.259 +glpapi13.c \
 175.260 +glpapi14.c \
 175.261 +glpapi15.c \
 175.262 +glpapi16.c \
 175.263 +glpapi17.c \
 175.264 +glpapi18.c \
 175.265 +glpapi19.c \
 175.266 +glpapi20.c \
 175.267 +glpapi21.c \
 175.268 +glpavl.c \
 175.269 +glpbfd.c \
 175.270 +glpbfx.c \
 175.271 +glpcpx.c \
 175.272 +glpdmp.c \
 175.273 +glpdmx.c \
 175.274 +glpenv01.c \
 175.275 +glpenv02.c \
 175.276 +glpenv03.c \
 175.277 +glpenv04.c \
 175.278 +glpenv05.c \
 175.279 +glpenv06.c \
 175.280 +glpenv07.c \
 175.281 +glpenv08.c \
 175.282 +glpfhv.c \
 175.283 +glpgmp.c \
 175.284 +glphbm.c \
 175.285 +glpini01.c \
 175.286 +glpini02.c \
 175.287 +glpios01.c \
 175.288 +glpios02.c \
 175.289 +glpios03.c \
 175.290 +glpios04.c \
 175.291 +glpios05.c \
 175.292 +glpios06.c \
 175.293 +glpios07.c \
 175.294 +glpios08.c \
 175.295 +glpios09.c \
 175.296 +glpios10.c \
 175.297 +glpios11.c \
 175.298 +glpios12.c \
 175.299 +glpipm.c \
 175.300 +glplib01.c \
 175.301 +glplib02.c \
 175.302 +glplib03.c \
 175.303 +glplpf.c \
 175.304 +glplpx01.c \
 175.305 +glplpx02.c \
 175.306 +glplpx03.c \
 175.307 +glpluf.c \
 175.308 +glplux.c \
 175.309 +glpmat.c \
 175.310 +glpmpl01.c \
 175.311 +glpmpl02.c \
 175.312 +glpmpl03.c \
 175.313 +glpmpl04.c \
 175.314 +glpmpl05.c \
 175.315 +glpmpl06.c \
 175.316 +glpmps.c \
 175.317 +glpnet01.c \
 175.318 +glpnet02.c \
 175.319 +glpnet03.c \
 175.320 +glpnet04.c \
 175.321 +glpnet05.c \
 175.322 +glpnet06.c \
 175.323 +glpnet07.c \
 175.324 +glpnet08.c \
 175.325 +glpnet09.c \
 175.326 +glpnpp01.c \
 175.327 +glpnpp02.c \
 175.328 +glpnpp03.c \
 175.329 +glpnpp04.c \
 175.330 +glpnpp05.c \
 175.331 +glpnpp06.c \
 175.332 +glpqmd.c \
 175.333 +glprgr.c \
 175.334 +glprng01.c \
 175.335 +glprng02.c \
 175.336 +glpscf.c \
 175.337 +glpscl.c \
 175.338 +glpsdf.c \
 175.339 +glpspm.c \
 175.340 +glpspx01.c \
 175.341 +glpspx02.c \
 175.342 +glpsql.c \
 175.343 +glpssx01.c \
 175.344 +glpssx02.c \
 175.345 +glptsp.c \
 175.346 +amd/amd_1.c \
 175.347 +amd/amd_2.c \
 175.348 +amd/amd_aat.c \
 175.349 +amd/amd_control.c \
 175.350 +amd/amd_defaults.c \
 175.351 +amd/amd_dump.c \
 175.352 +amd/amd_info.c \
 175.353 +amd/amd_order.c \
 175.354 +amd/amd_post_tree.c \
 175.355 +amd/amd_postorder.c \
 175.356 +amd/amd_preprocess.c \
 175.357 +amd/amd_valid.c \
 175.358 +colamd/colamd.c \
 175.359 +minisat/minisat.c \
 175.360 +zlib/adler32.c \
 175.361 +zlib/compress.c \
 175.362 +zlib/crc32.c \
 175.363 +zlib/deflate.c \
 175.364 +zlib/gzclose.c \
 175.365 +zlib/gzlib.c \
 175.366 +zlib/gzread.c \
 175.367 +zlib/gzwrite.c \
 175.368 +zlib/infback.c \
 175.369 +zlib/inffast.c \
 175.370 +zlib/inflate.c \
 175.371 +zlib/inftrees.c \
 175.372 +zlib/trees.c \
 175.373 +zlib/uncompr.c \
 175.374 +zlib/zio.c \
 175.375 +zlib/zutil.c
 175.376 +
 175.377 +all: all-am
 175.378 +
 175.379 +.SUFFIXES:
 175.380 +.SUFFIXES: .c .lo .o .obj
 175.381 +$(srcdir)/Makefile.in:  $(srcdir)/Makefile.am  $(am__configure_deps)
 175.382 +	@for dep in $?; do \
 175.383 +	  case '$(am__configure_deps)' in \
 175.384 +	    *$$dep*) \
 175.385 +	      ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \
 175.386 +	        && { if test -f $@; then exit 0; else break; fi; }; \
 175.387 +	      exit 1;; \
 175.388 +	  esac; \
 175.389 +	done; \
 175.390 +	echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu src/Makefile'; \
 175.391 +	$(am__cd) $(top_srcdir) && \
 175.392 +	  $(AUTOMAKE) --gnu src/Makefile
 175.393 +.PRECIOUS: Makefile
 175.394 +Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
 175.395 +	@case '$?' in \
 175.396 +	  *config.status*) \
 175.397 +	    cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
 175.398 +	  *) \
 175.399 +	    echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
 175.400 +	    cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
 175.401 +	esac;
 175.402 +
 175.403 +$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
 175.404 +	cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
 175.405 +
 175.406 +$(top_srcdir)/configure:  $(am__configure_deps)
 175.407 +	cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
 175.408 +$(ACLOCAL_M4):  $(am__aclocal_m4_deps)
 175.409 +	cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
 175.410 +$(am__aclocal_m4_deps):
 175.411 +install-libLTLIBRARIES: $(lib_LTLIBRARIES)
 175.412 +	@$(NORMAL_INSTALL)
 175.413 +	test -z "$(libdir)" || $(MKDIR_P) "$(DESTDIR)$(libdir)"
 175.414 +	@list='$(lib_LTLIBRARIES)'; test -n "$(libdir)" || list=; \
 175.415 +	list2=; for p in $$list; do \
 175.416 +	  if test -f $$p; then \
 175.417 +	    list2="$$list2 $$p"; \
 175.418 +	  else :; fi; \
 175.419 +	done; \
 175.420 +	test -z "$$list2" || { \
 175.421 +	  echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG) $$list2 '$(DESTDIR)$(libdir)'"; \
 175.422 +	  $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG) $$list2 "$(DESTDIR)$(libdir)"; \
 175.423 +	}
 175.424 +
 175.425 +uninstall-libLTLIBRARIES:
 175.426 +	@$(NORMAL_UNINSTALL)
 175.427 +	@list='$(lib_LTLIBRARIES)'; test -n "$(libdir)" || list=; \
 175.428 +	for p in $$list; do \
 175.429 +	  $(am__strip_dir) \
 175.430 +	  echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f '$(DESTDIR)$(libdir)/$$f'"; \
 175.431 +	  $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f "$(DESTDIR)$(libdir)/$$f"; \
 175.432 +	done
 175.433 +
 175.434 +clean-libLTLIBRARIES:
 175.435 +	-test -z "$(lib_LTLIBRARIES)" || rm -f $(lib_LTLIBRARIES)
 175.436 +	@list='$(lib_LTLIBRARIES)'; for p in $$list; do \
 175.437 +	  dir="`echo $$p | sed -e 's|/[^/]*$$||'`"; \
 175.438 +	  test "$$dir" != "$$p" || dir=.; \
 175.439 +	  echo "rm -f \"$${dir}/so_locations\""; \
 175.440 +	  rm -f "$${dir}/so_locations"; \
 175.441 +	done
 175.442 +libglpk.la: $(libglpk_la_OBJECTS) $(libglpk_la_DEPENDENCIES) 
 175.443 +	$(libglpk_la_LINK) -rpath $(libdir) $(libglpk_la_OBJECTS) $(libglpk_la_LIBADD) $(LIBS)
 175.444 +
 175.445 +mostlyclean-compile:
 175.446 +	-rm -f *.$(OBJEXT)
 175.447 +
 175.448 +distclean-compile:
 175.449 +	-rm -f *.tab.c
 175.450 +
 175.451 +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/adler32.Plo@am__quote@
 175.452 +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/amd_1.Plo@am__quote@
 175.453 +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/amd_2.Plo@am__quote@
 175.454 +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/amd_aat.Plo@am__quote@
 175.455 +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/amd_control.Plo@am__quote@
 175.456 +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/amd_defaults.Plo@am__quote@
 175.457 +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/amd_dump.Plo@am__quote@
 175.458 +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/amd_info.Plo@am__quote@
 175.459 +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/amd_order.Plo@am__quote@
 175.460 +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/amd_post_tree.Plo@am__quote@
 175.461 +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/amd_postorder.Plo@am__quote@
 175.462 +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/amd_preprocess.Plo@am__quote@
 175.463 +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/amd_valid.Plo@am__quote@
 175.464 +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/colamd.Plo@am__quote@
 175.465 +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/compress.Plo@am__quote@
 175.466 +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/crc32.Plo@am__quote@
 175.467 +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/deflate.Plo@am__quote@
 175.468 +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/glpapi01.Plo@am__quote@
 175.469 +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/glpapi02.Plo@am__quote@
 175.470 +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/glpapi03.Plo@am__quote@
 175.471 +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/glpapi04.Plo@am__quote@
 175.472 +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/glpapi05.Plo@am__quote@
 175.473 +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/glpapi06.Plo@am__quote@
 175.474 +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/glpapi07.Plo@am__quote@
 175.475 +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/glpapi08.Plo@am__quote@
 175.476 +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/glpapi09.Plo@am__quote@
 175.477 +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/glpapi10.Plo@am__quote@
 175.478 +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/glpapi11.Plo@am__quote@
 175.479 +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/glpapi12.Plo@am__quote@
 175.480 +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/glpapi13.Plo@am__quote@
 175.481 +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/glpapi14.Plo@am__quote@
 175.482 +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/glpapi15.Plo@am__quote@
 175.483 +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/glpapi16.Plo@am__quote@
 175.484 +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/glpapi17.Plo@am__quote@
 175.485 +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/glpapi18.Plo@am__quote@
 175.486 +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/glpapi19.Plo@am__quote@
 175.487 +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/glpapi20.Plo@am__quote@
 175.488 +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/glpapi21.Plo@am__quote@
 175.489 +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/glpavl.Plo@am__quote@
 175.490 +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/glpbfd.Plo@am__quote@
 175.491 +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/glpbfx.Plo@am__quote@
 175.492 +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/glpcpx.Plo@am__quote@
 175.493 +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/glpdmp.Plo@am__quote@
 175.494 +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/glpdmx.Plo@am__quote@
 175.495 +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/glpenv01.Plo@am__quote@
 175.496 +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/glpenv02.Plo@am__quote@
 175.497 +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/glpenv03.Plo@am__quote@
 175.498 +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/glpenv04.Plo@am__quote@
 175.499 +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/glpenv05.Plo@am__quote@
 175.500 +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/glpenv06.Plo@am__quote@
 175.501 +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/glpenv07.Plo@am__quote@
 175.502 +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/glpenv08.Plo@am__quote@
 175.503 +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/glpfhv.Plo@am__quote@
 175.504 +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/glpgmp.Plo@am__quote@
 175.505 +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/glphbm.Plo@am__quote@
 175.506 +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/glpini01.Plo@am__quote@
 175.507 +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/glpini02.Plo@am__quote@
 175.508 +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/glpios01.Plo@am__quote@
 175.509 +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/glpios02.Plo@am__quote@
 175.510 +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/glpios03.Plo@am__quote@
 175.511 +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/glpios04.Plo@am__quote@
 175.512 +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/glpios05.Plo@am__quote@
 175.513 +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/glpios06.Plo@am__quote@
 175.514 +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/glpios07.Plo@am__quote@
 175.515 +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/glpios08.Plo@am__quote@
 175.516 +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/glpios09.Plo@am__quote@
 175.517 +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/glpios10.Plo@am__quote@
 175.518 +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/glpios11.Plo@am__quote@
 175.519 +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/glpios12.Plo@am__quote@
 175.520 +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/glpipm.Plo@am__quote@
 175.521 +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/glplib01.Plo@am__quote@
 175.522 +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/glplib02.Plo@am__quote@
 175.523 +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/glplib03.Plo@am__quote@
 175.524 +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/glplpf.Plo@am__quote@
 175.525 +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/glplpx01.Plo@am__quote@
 175.526 +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/glplpx02.Plo@am__quote@
 175.527 +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/glplpx03.Plo@am__quote@
 175.528 +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/glpluf.Plo@am__quote@
 175.529 +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/glplux.Plo@am__quote@
 175.530 +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/glpmat.Plo@am__quote@
 175.531 +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/glpmpl01.Plo@am__quote@
 175.532 +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/glpmpl02.Plo@am__quote@
 175.533 +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/glpmpl03.Plo@am__quote@
 175.534 +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/glpmpl04.Plo@am__quote@
 175.535 +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/glpmpl05.Plo@am__quote@
 175.536 +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/glpmpl06.Plo@am__quote@
 175.537 +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/glpmps.Plo@am__quote@
 175.538 +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/glpnet01.Plo@am__quote@
 175.539 +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/glpnet02.Plo@am__quote@
 175.540 +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/glpnet03.Plo@am__quote@
 175.541 +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/glpnet04.Plo@am__quote@
 175.542 +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/glpnet05.Plo@am__quote@
 175.543 +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/glpnet06.Plo@am__quote@
 175.544 +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/glpnet07.Plo@am__quote@
 175.545 +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/glpnet08.Plo@am__quote@
 175.546 +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/glpnet09.Plo@am__quote@
 175.547 +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/glpnpp01.Plo@am__quote@
 175.548 +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/glpnpp02.Plo@am__quote@
 175.549 +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/glpnpp03.Plo@am__quote@
 175.550 +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/glpnpp04.Plo@am__quote@
 175.551 +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/glpnpp05.Plo@am__quote@
 175.552 +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/glpnpp06.Plo@am__quote@
 175.553 +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/glpqmd.Plo@am__quote@
 175.554 +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/glprgr.Plo@am__quote@
 175.555 +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/glprng01.Plo@am__quote@
 175.556 +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/glprng02.Plo@am__quote@
 175.557 +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/glpscf.Plo@am__quote@
 175.558 +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/glpscl.Plo@am__quote@
 175.559 +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/glpsdf.Plo@am__quote@
 175.560 +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/glpspm.Plo@am__quote@
 175.561 +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/glpspx01.Plo@am__quote@
 175.562 +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/glpspx02.Plo@am__quote@
 175.563 +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/glpsql.Plo@am__quote@
 175.564 +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/glpssx01.Plo@am__quote@
 175.565 +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/glpssx02.Plo@am__quote@
 175.566 +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/glptsp.Plo@am__quote@
 175.567 +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/gzclose.Plo@am__quote@
 175.568 +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/gzlib.Plo@am__quote@
 175.569 +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/gzread.Plo@am__quote@
 175.570 +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/gzwrite.Plo@am__quote@
 175.571 +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/infback.Plo@am__quote@
 175.572 +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/inffast.Plo@am__quote@
 175.573 +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/inflate.Plo@am__quote@
 175.574 +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/inftrees.Plo@am__quote@
 175.575 +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/minisat.Plo@am__quote@
 175.576 +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/trees.Plo@am__quote@
 175.577 +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/uncompr.Plo@am__quote@
 175.578 +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/zio.Plo@am__quote@
 175.579 +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/zutil.Plo@am__quote@
 175.580 +
 175.581 +.c.o:
 175.582 +@am__fastdepCC_TRUE@	$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
 175.583 +@am__fastdepCC_TRUE@	$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
 175.584 +@AMDEP_TRUE@@am__fastdepCC_FALSE@	source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
 175.585 +@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
 175.586 +@am__fastdepCC_FALSE@	$(COMPILE) -c $<
 175.587 +
 175.588 +.c.obj:
 175.589 +@am__fastdepCC_TRUE@	$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'`
 175.590 +@am__fastdepCC_TRUE@	$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
 175.591 +@AMDEP_TRUE@@am__fastdepCC_FALSE@	source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
 175.592 +@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
 175.593 +@am__fastdepCC_FALSE@	$(COMPILE) -c `$(CYGPATH_W) '$<'`
 175.594 +
 175.595 +.c.lo:
 175.596 +@am__fastdepCC_TRUE@	$(LTCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
 175.597 +@am__fastdepCC_TRUE@	$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo
 175.598 +@AMDEP_TRUE@@am__fastdepCC_FALSE@	source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@
 175.599 +@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
 175.600 +@am__fastdepCC_FALSE@	$(LTCOMPILE) -c -o $@ $<
 175.601 +
 175.602 +amd_1.lo: amd/amd_1.c
 175.603 +@am__fastdepCC_TRUE@	$(LIBTOOL)  --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT amd_1.lo -MD -MP -MF $(DEPDIR)/amd_1.Tpo -c -o amd_1.lo `test -f 'amd/amd_1.c' || echo '$(srcdir)/'`amd/amd_1.c
 175.604 +@am__fastdepCC_TRUE@	$(am__mv) $(DEPDIR)/amd_1.Tpo $(DEPDIR)/amd_1.Plo
 175.605 +@AMDEP_TRUE@@am__fastdepCC_FALSE@	source='amd/amd_1.c' object='amd_1.lo' libtool=yes @AMDEPBACKSLASH@
 175.606 +@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
 175.607 +@am__fastdepCC_FALSE@	$(LIBTOOL)  --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o amd_1.lo `test -f 'amd/amd_1.c' || echo '$(srcdir)/'`amd/amd_1.c
 175.608 +
 175.609 +amd_2.lo: amd/amd_2.c
 175.610 +@am__fastdepCC_TRUE@	$(LIBTOOL)  --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT amd_2.lo -MD -MP -MF $(DEPDIR)/amd_2.Tpo -c -o amd_2.lo `test -f 'amd/amd_2.c' || echo '$(srcdir)/'`amd/amd_2.c
 175.611 +@am__fastdepCC_TRUE@	$(am__mv) $(DEPDIR)/amd_2.Tpo $(DEPDIR)/amd_2.Plo
 175.612 +@AMDEP_TRUE@@am__fastdepCC_FALSE@	source='amd/amd_2.c' object='amd_2.lo' libtool=yes @AMDEPBACKSLASH@
 175.613 +@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
 175.614 +@am__fastdepCC_FALSE@	$(LIBTOOL)  --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o amd_2.lo `test -f 'amd/amd_2.c' || echo '$(srcdir)/'`amd/amd_2.c
 175.615 +
 175.616 +amd_aat.lo: amd/amd_aat.c
 175.617 +@am__fastdepCC_TRUE@	$(LIBTOOL)  --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT amd_aat.lo -MD -MP -MF $(DEPDIR)/amd_aat.Tpo -c -o amd_aat.lo `test -f 'amd/amd_aat.c' || echo '$(srcdir)/'`amd/amd_aat.c
 175.618 +@am__fastdepCC_TRUE@	$(am__mv) $(DEPDIR)/amd_aat.Tpo $(DEPDIR)/amd_aat.Plo
 175.619 +@AMDEP_TRUE@@am__fastdepCC_FALSE@	source='amd/amd_aat.c' object='amd_aat.lo' libtool=yes @AMDEPBACKSLASH@
 175.620 +@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
 175.621 +@am__fastdepCC_FALSE@	$(LIBTOOL)  --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o amd_aat.lo `test -f 'amd/amd_aat.c' || echo '$(srcdir)/'`amd/amd_aat.c
 175.622 +
 175.623 +amd_control.lo: amd/amd_control.c
 175.624 +@am__fastdepCC_TRUE@	$(LIBTOOL)  --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT amd_control.lo -MD -MP -MF $(DEPDIR)/amd_control.Tpo -c -o amd_control.lo `test -f 'amd/amd_control.c' || echo '$(srcdir)/'`amd/amd_control.c
 175.625 +@am__fastdepCC_TRUE@	$(am__mv) $(DEPDIR)/amd_control.Tpo $(DEPDIR)/amd_control.Plo
 175.626 +@AMDEP_TRUE@@am__fastdepCC_FALSE@	source='amd/amd_control.c' object='amd_control.lo' libtool=yes @AMDEPBACKSLASH@
 175.627 +@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
 175.628 +@am__fastdepCC_FALSE@	$(LIBTOOL)  --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o amd_control.lo `test -f 'amd/amd_control.c' || echo '$(srcdir)/'`amd/amd_control.c
 175.629 +
 175.630 +amd_defaults.lo: amd/amd_defaults.c
 175.631 +@am__fastdepCC_TRUE@	$(LIBTOOL)  --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT amd_defaults.lo -MD -MP -MF $(DEPDIR)/amd_defaults.Tpo -c -o amd_defaults.lo `test -f 'amd/amd_defaults.c' || echo '$(srcdir)/'`amd/amd_defaults.c
 175.632 +@am__fastdepCC_TRUE@	$(am__mv) $(DEPDIR)/amd_defaults.Tpo $(DEPDIR)/amd_defaults.Plo
 175.633 +@AMDEP_TRUE@@am__fastdepCC_FALSE@	source='amd/amd_defaults.c' object='amd_defaults.lo' libtool=yes @AMDEPBACKSLASH@
 175.634 +@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
 175.635 +@am__fastdepCC_FALSE@	$(LIBTOOL)  --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o amd_defaults.lo `test -f 'amd/amd_defaults.c' || echo '$(srcdir)/'`amd/amd_defaults.c
 175.636 +
 175.637 +amd_dump.lo: amd/amd_dump.c
 175.638 +@am__fastdepCC_TRUE@	$(LIBTOOL)  --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT amd_dump.lo -MD -MP -MF $(DEPDIR)/amd_dump.Tpo -c -o amd_dump.lo `test -f 'amd/amd_dump.c' || echo '$(srcdir)/'`amd/amd_dump.c
 175.639 +@am__fastdepCC_TRUE@	$(am__mv) $(DEPDIR)/amd_dump.Tpo $(DEPDIR)/amd_dump.Plo
 175.640 +@AMDEP_TRUE@@am__fastdepCC_FALSE@	source='amd/amd_dump.c' object='amd_dump.lo' libtool=yes @AMDEPBACKSLASH@
 175.641 +@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
 175.642 +@am__fastdepCC_FALSE@	$(LIBTOOL)  --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o amd_dump.lo `test -f 'amd/amd_dump.c' || echo '$(srcdir)/'`amd/amd_dump.c
 175.643 +
 175.644 +amd_info.lo: amd/amd_info.c
 175.645 +@am__fastdepCC_TRUE@	$(LIBTOOL)  --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT amd_info.lo -MD -MP -MF $(DEPDIR)/amd_info.Tpo -c -o amd_info.lo `test -f 'amd/amd_info.c' || echo '$(srcdir)/'`amd/amd_info.c
 175.646 +@am__fastdepCC_TRUE@	$(am__mv) $(DEPDIR)/amd_info.Tpo $(DEPDIR)/amd_info.Plo
 175.647 +@AMDEP_TRUE@@am__fastdepCC_FALSE@	source='amd/amd_info.c' object='amd_info.lo' libtool=yes @AMDEPBACKSLASH@
 175.648 +@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
 175.649 +@am__fastdepCC_FALSE@	$(LIBTOOL)  --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o amd_info.lo `test -f 'amd/amd_info.c' || echo '$(srcdir)/'`amd/amd_info.c
 175.650 +
 175.651 +amd_order.lo: amd/amd_order.c
 175.652 +@am__fastdepCC_TRUE@	$(LIBTOOL)  --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT amd_order.lo -MD -MP -MF $(DEPDIR)/amd_order.Tpo -c -o amd_order.lo `test -f 'amd/amd_order.c' || echo '$(srcdir)/'`amd/amd_order.c
 175.653 +@am__fastdepCC_TRUE@	$(am__mv) $(DEPDIR)/amd_order.Tpo $(DEPDIR)/amd_order.Plo
 175.654 +@AMDEP_TRUE@@am__fastdepCC_FALSE@	source='amd/amd_order.c' object='amd_order.lo' libtool=yes @AMDEPBACKSLASH@
 175.655 +@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
 175.656 +@am__fastdepCC_FALSE@	$(LIBTOOL)  --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o amd_order.lo `test -f 'amd/amd_order.c' || echo '$(srcdir)/'`amd/amd_order.c
 175.657 +
 175.658 +amd_post_tree.lo: amd/amd_post_tree.c
 175.659 +@am__fastdepCC_TRUE@	$(LIBTOOL)  --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT amd_post_tree.lo -MD -MP -MF $(DEPDIR)/amd_post_tree.Tpo -c -o amd_post_tree.lo `test -f 'amd/amd_post_tree.c' || echo '$(srcdir)/'`amd/amd_post_tree.c
 175.660 +@am__fastdepCC_TRUE@	$(am__mv) $(DEPDIR)/amd_post_tree.Tpo $(DEPDIR)/amd_post_tree.Plo
 175.661 +@AMDEP_TRUE@@am__fastdepCC_FALSE@	source='amd/amd_post_tree.c' object='amd_post_tree.lo' libtool=yes @AMDEPBACKSLASH@
 175.662 +@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
 175.663 +@am__fastdepCC_FALSE@	$(LIBTOOL)  --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o amd_post_tree.lo `test -f 'amd/amd_post_tree.c' || echo '$(srcdir)/'`amd/amd_post_tree.c
 175.664 +
 175.665 +amd_postorder.lo: amd/amd_postorder.c
 175.666 +@am__fastdepCC_TRUE@	$(LIBTOOL)  --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT amd_postorder.lo -MD -MP -MF $(DEPDIR)/amd_postorder.Tpo -c -o amd_postorder.lo `test -f 'amd/amd_postorder.c' || echo '$(srcdir)/'`amd/amd_postorder.c
 175.667 +@am__fastdepCC_TRUE@	$(am__mv) $(DEPDIR)/amd_postorder.Tpo $(DEPDIR)/amd_postorder.Plo
 175.668 +@AMDEP_TRUE@@am__fastdepCC_FALSE@	source='amd/amd_postorder.c' object='amd_postorder.lo' libtool=yes @AMDEPBACKSLASH@
 175.669 +@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
 175.670 +@am__fastdepCC_FALSE@	$(LIBTOOL)  --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o amd_postorder.lo `test -f 'amd/amd_postorder.c' || echo '$(srcdir)/'`amd/amd_postorder.c
 175.671 +
 175.672 +amd_preprocess.lo: amd/amd_preprocess.c
 175.673 +@am__fastdepCC_TRUE@	$(LIBTOOL)  --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT amd_preprocess.lo -MD -MP -MF $(DEPDIR)/amd_preprocess.Tpo -c -o amd_preprocess.lo `test -f 'amd/amd_preprocess.c' || echo '$(srcdir)/'`amd/amd_preprocess.c
 175.674 +@am__fastdepCC_TRUE@	$(am__mv) $(DEPDIR)/amd_preprocess.Tpo $(DEPDIR)/amd_preprocess.Plo
 175.675 +@AMDEP_TRUE@@am__fastdepCC_FALSE@	source='amd/amd_preprocess.c' object='amd_preprocess.lo' libtool=yes @AMDEPBACKSLASH@
 175.676 +@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
 175.677 +@am__fastdepCC_FALSE@	$(LIBTOOL)  --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o amd_preprocess.lo `test -f 'amd/amd_preprocess.c' || echo '$(srcdir)/'`amd/amd_preprocess.c
 175.678 +
 175.679 +amd_valid.lo: amd/amd_valid.c
 175.680 +@am__fastdepCC_TRUE@	$(LIBTOOL)  --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT amd_valid.lo -MD -MP -MF $(DEPDIR)/amd_valid.Tpo -c -o amd_valid.lo `test -f 'amd/amd_valid.c' || echo '$(srcdir)/'`amd/amd_valid.c
 175.681 +@am__fastdepCC_TRUE@	$(am__mv) $(DEPDIR)/amd_valid.Tpo $(DEPDIR)/amd_valid.Plo
 175.682 +@AMDEP_TRUE@@am__fastdepCC_FALSE@	source='amd/amd_valid.c' object='amd_valid.lo' libtool=yes @AMDEPBACKSLASH@
 175.683 +@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
 175.684 +@am__fastdepCC_FALSE@	$(LIBTOOL)  --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o amd_valid.lo `test -f 'amd/amd_valid.c' || echo '$(srcdir)/'`amd/amd_valid.c
 175.685 +
 175.686 +colamd.lo: colamd/colamd.c
 175.687 +@am__fastdepCC_TRUE@	$(LIBTOOL)  --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT colamd.lo -MD -MP -MF $(DEPDIR)/colamd.Tpo -c -o colamd.lo `test -f 'colamd/colamd.c' || echo '$(srcdir)/'`colamd/colamd.c
 175.688 +@am__fastdepCC_TRUE@	$(am__mv) $(DEPDIR)/colamd.Tpo $(DEPDIR)/colamd.Plo
 175.689 +@AMDEP_TRUE@@am__fastdepCC_FALSE@	source='colamd/colamd.c' object='colamd.lo' libtool=yes @AMDEPBACKSLASH@
 175.690 +@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
 175.691 +@am__fastdepCC_FALSE@	$(LIBTOOL)  --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o colamd.lo `test -f 'colamd/colamd.c' || echo '$(srcdir)/'`colamd/colamd.c
 175.692 +
 175.693 +minisat.lo: minisat/minisat.c
 175.694 +@am__fastdepCC_TRUE@	$(LIBTOOL)  --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT minisat.lo -MD -MP -MF $(DEPDIR)/minisat.Tpo -c -o minisat.lo `test -f 'minisat/minisat.c' || echo '$(srcdir)/'`minisat/minisat.c
 175.695 +@am__fastdepCC_TRUE@	$(am__mv) $(DEPDIR)/minisat.Tpo $(DEPDIR)/minisat.Plo
 175.696 +@AMDEP_TRUE@@am__fastdepCC_FALSE@	source='minisat/minisat.c' object='minisat.lo' libtool=yes @AMDEPBACKSLASH@
 175.697 +@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
 175.698 +@am__fastdepCC_FALSE@	$(LIBTOOL)  --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o minisat.lo `test -f 'minisat/minisat.c' || echo '$(srcdir)/'`minisat/minisat.c
 175.699 +
 175.700 +adler32.lo: zlib/adler32.c
 175.701 +@am__fastdepCC_TRUE@	$(LIBTOOL)  --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT adler32.lo -MD -MP -MF $(DEPDIR)/adler32.Tpo -c -o adler32.lo `test -f 'zlib/adler32.c' || echo '$(srcdir)/'`zlib/adler32.c
 175.702 +@am__fastdepCC_TRUE@	$(am__mv) $(DEPDIR)/adler32.Tpo $(DEPDIR)/adler32.Plo
 175.703 +@AMDEP_TRUE@@am__fastdepCC_FALSE@	source='zlib/adler32.c' object='adler32.lo' libtool=yes @AMDEPBACKSLASH@
 175.704 +@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
 175.705 +@am__fastdepCC_FALSE@	$(LIBTOOL)  --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o adler32.lo `test -f 'zlib/adler32.c' || echo '$(srcdir)/'`zlib/adler32.c
 175.706 +
 175.707 +compress.lo: zlib/compress.c
 175.708 +@am__fastdepCC_TRUE@	$(LIBTOOL)  --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT compress.lo -MD -MP -MF $(DEPDIR)/compress.Tpo -c -o compress.lo `test -f 'zlib/compress.c' || echo '$(srcdir)/'`zlib/compress.c
 175.709 +@am__fastdepCC_TRUE@	$(am__mv) $(DEPDIR)/compress.Tpo $(DEPDIR)/compress.Plo
 175.710 +@AMDEP_TRUE@@am__fastdepCC_FALSE@	source='zlib/compress.c' object='compress.lo' libtool=yes @AMDEPBACKSLASH@
 175.711 +@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
 175.712 +@am__fastdepCC_FALSE@	$(LIBTOOL)  --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o compress.lo `test -f 'zlib/compress.c' || echo '$(srcdir)/'`zlib/compress.c
 175.713 +
 175.714 +crc32.lo: zlib/crc32.c
 175.715 +@am__fastdepCC_TRUE@	$(LIBTOOL)  --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT crc32.lo -MD -MP -MF $(DEPDIR)/crc32.Tpo -c -o crc32.lo `test -f 'zlib/crc32.c' || echo '$(srcdir)/'`zlib/crc32.c
 175.716 +@am__fastdepCC_TRUE@	$(am__mv) $(DEPDIR)/crc32.Tpo $(DEPDIR)/crc32.Plo
 175.717 +@AMDEP_TRUE@@am__fastdepCC_FALSE@	source='zlib/crc32.c' object='crc32.lo' libtool=yes @AMDEPBACKSLASH@
 175.718 +@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
 175.719 +@am__fastdepCC_FALSE@	$(LIBTOOL)  --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o crc32.lo `test -f 'zlib/crc32.c' || echo '$(srcdir)/'`zlib/crc32.c
 175.720 +
 175.721 +deflate.lo: zlib/deflate.c
 175.722 +@am__fastdepCC_TRUE@	$(LIBTOOL)  --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT deflate.lo -MD -MP -MF $(DEPDIR)/deflate.Tpo -c -o deflate.lo `test -f 'zlib/deflate.c' || echo '$(srcdir)/'`zlib/deflate.c
 175.723 +@am__fastdepCC_TRUE@	$(am__mv) $(DEPDIR)/deflate.Tpo $(DEPDIR)/deflate.Plo
 175.724 +@AMDEP_TRUE@@am__fastdepCC_FALSE@	source='zlib/deflate.c' object='deflate.lo' libtool=yes @AMDEPBACKSLASH@
 175.725 +@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
 175.726 +@am__fastdepCC_FALSE@	$(LIBTOOL)  --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o deflate.lo `test -f 'zlib/deflate.c' || echo '$(srcdir)/'`zlib/deflate.c
 175.727 +
 175.728 +gzclose.lo: zlib/gzclose.c
 175.729 +@am__fastdepCC_TRUE@	$(LIBTOOL)  --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT gzclose.lo -MD -MP -MF $(DEPDIR)/gzclose.Tpo -c -o gzclose.lo `test -f 'zlib/gzclose.c' || echo '$(srcdir)/'`zlib/gzclose.c
 175.730 +@am__fastdepCC_TRUE@	$(am__mv) $(DEPDIR)/gzclose.Tpo $(DEPDIR)/gzclose.Plo
 175.731 +@AMDEP_TRUE@@am__fastdepCC_FALSE@	source='zlib/gzclose.c' object='gzclose.lo' libtool=yes @AMDEPBACKSLASH@
 175.732 +@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
 175.733 +@am__fastdepCC_FALSE@	$(LIBTOOL)  --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o gzclose.lo `test -f 'zlib/gzclose.c' || echo '$(srcdir)/'`zlib/gzclose.c
 175.734 +
 175.735 +gzlib.lo: zlib/gzlib.c
 175.736 +@am__fastdepCC_TRUE@	$(LIBTOOL)  --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT gzlib.lo -MD -MP -MF $(DEPDIR)/gzlib.Tpo -c -o gzlib.lo `test -f 'zlib/gzlib.c' || echo '$(srcdir)/'`zlib/gzlib.c
 175.737 +@am__fastdepCC_TRUE@	$(am__mv) $(DEPDIR)/gzlib.Tpo $(DEPDIR)/gzlib.Plo
 175.738 +@AMDEP_TRUE@@am__fastdepCC_FALSE@	source='zlib/gzlib.c' object='gzlib.lo' libtool=yes @AMDEPBACKSLASH@
 175.739 +@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
 175.740 +@am__fastdepCC_FALSE@	$(LIBTOOL)  --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o gzlib.lo `test -f 'zlib/gzlib.c' || echo '$(srcdir)/'`zlib/gzlib.c
 175.741 +
 175.742 +gzread.lo: zlib/gzread.c
 175.743 +@am__fastdepCC_TRUE@	$(LIBTOOL)  --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT gzread.lo -MD -MP -MF $(DEPDIR)/gzread.Tpo -c -o gzread.lo `test -f 'zlib/gzread.c' || echo '$(srcdir)/'`zlib/gzread.c
 175.744 +@am__fastdepCC_TRUE@	$(am__mv) $(DEPDIR)/gzread.Tpo $(DEPDIR)/gzread.Plo
 175.745 +@AMDEP_TRUE@@am__fastdepCC_FALSE@	source='zlib/gzread.c' object='gzread.lo' libtool=yes @AMDEPBACKSLASH@
 175.746 +@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
 175.747 +@am__fastdepCC_FALSE@	$(LIBTOOL)  --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o gzread.lo `test -f 'zlib/gzread.c' || echo '$(srcdir)/'`zlib/gzread.c
 175.748 +
 175.749 +gzwrite.lo: zlib/gzwrite.c
 175.750 +@am__fastdepCC_TRUE@	$(LIBTOOL)  --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT gzwrite.lo -MD -MP -MF $(DEPDIR)/gzwrite.Tpo -c -o gzwrite.lo `test -f 'zlib/gzwrite.c' || echo '$(srcdir)/'`zlib/gzwrite.c
 175.751 +@am__fastdepCC_TRUE@	$(am__mv) $(DEPDIR)/gzwrite.Tpo $(DEPDIR)/gzwrite.Plo
 175.752 +@AMDEP_TRUE@@am__fastdepCC_FALSE@	source='zlib/gzwrite.c' object='gzwrite.lo' libtool=yes @AMDEPBACKSLASH@
 175.753 +@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
 175.754 +@am__fastdepCC_FALSE@	$(LIBTOOL)  --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o gzwrite.lo `test -f 'zlib/gzwrite.c' || echo '$(srcdir)/'`zlib/gzwrite.c
 175.755 +
 175.756 +infback.lo: zlib/infback.c
 175.757 +@am__fastdepCC_TRUE@	$(LIBTOOL)  --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT infback.lo -MD -MP -MF $(DEPDIR)/infback.Tpo -c -o infback.lo `test -f 'zlib/infback.c' || echo '$(srcdir)/'`zlib/infback.c
 175.758 +@am__fastdepCC_TRUE@	$(am__mv) $(DEPDIR)/infback.Tpo $(DEPDIR)/infback.Plo
 175.759 +@AMDEP_TRUE@@am__fastdepCC_FALSE@	source='zlib/infback.c' object='infback.lo' libtool=yes @AMDEPBACKSLASH@
 175.760 +@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
 175.761 +@am__fastdepCC_FALSE@	$(LIBTOOL)  --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o infback.lo `test -f 'zlib/infback.c' || echo '$(srcdir)/'`zlib/infback.c
 175.762 +
 175.763 +inffast.lo: zlib/inffast.c
 175.764 +@am__fastdepCC_TRUE@	$(LIBTOOL)  --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT inffast.lo -MD -MP -MF $(DEPDIR)/inffast.Tpo -c -o inffast.lo `test -f 'zlib/inffast.c' || echo '$(srcdir)/'`zlib/inffast.c
 175.765 +@am__fastdepCC_TRUE@	$(am__mv) $(DEPDIR)/inffast.Tpo $(DEPDIR)/inffast.Plo
 175.766 +@AMDEP_TRUE@@am__fastdepCC_FALSE@	source='zlib/inffast.c' object='inffast.lo' libtool=yes @AMDEPBACKSLASH@
 175.767 +@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
 175.768 +@am__fastdepCC_FALSE@	$(LIBTOOL)  --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o inffast.lo `test -f 'zlib/inffast.c' || echo '$(srcdir)/'`zlib/inffast.c
 175.769 +
 175.770 +inflate.lo: zlib/inflate.c
 175.771 +@am__fastdepCC_TRUE@	$(LIBTOOL)  --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT inflate.lo -MD -MP -MF $(DEPDIR)/inflate.Tpo -c -o inflate.lo `test -f 'zlib/inflate.c' || echo '$(srcdir)/'`zlib/inflate.c
 175.772 +@am__fastdepCC_TRUE@	$(am__mv) $(DEPDIR)/inflate.Tpo $(DEPDIR)/inflate.Plo
 175.773 +@AMDEP_TRUE@@am__fastdepCC_FALSE@	source='zlib/inflate.c' object='inflate.lo' libtool=yes @AMDEPBACKSLASH@
 175.774 +@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
 175.775 +@am__fastdepCC_FALSE@	$(LIBTOOL)  --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o inflate.lo `test -f 'zlib/inflate.c' || echo '$(srcdir)/'`zlib/inflate.c
 175.776 +
 175.777 +inftrees.lo: zlib/inftrees.c
 175.778 +@am__fastdepCC_TRUE@	$(LIBTOOL)  --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT inftrees.lo -MD -MP -MF $(DEPDIR)/inftrees.Tpo -c -o inftrees.lo `test -f 'zlib/inftrees.c' || echo '$(srcdir)/'`zlib/inftrees.c
 175.779 +@am__fastdepCC_TRUE@	$(am__mv) $(DEPDIR)/inftrees.Tpo $(DEPDIR)/inftrees.Plo
 175.780 +@AMDEP_TRUE@@am__fastdepCC_FALSE@	source='zlib/inftrees.c' object='inftrees.lo' libtool=yes @AMDEPBACKSLASH@
 175.781 +@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
 175.782 +@am__fastdepCC_FALSE@	$(LIBTOOL)  --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o inftrees.lo `test -f 'zlib/inftrees.c' || echo '$(srcdir)/'`zlib/inftrees.c
 175.783 +
 175.784 +trees.lo: zlib/trees.c
 175.785 +@am__fastdepCC_TRUE@	$(LIBTOOL)  --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT trees.lo -MD -MP -MF $(DEPDIR)/trees.Tpo -c -o trees.lo `test -f 'zlib/trees.c' || echo '$(srcdir)/'`zlib/trees.c
 175.786 +@am__fastdepCC_TRUE@	$(am__mv) $(DEPDIR)/trees.Tpo $(DEPDIR)/trees.Plo
 175.787 +@AMDEP_TRUE@@am__fastdepCC_FALSE@	source='zlib/trees.c' object='trees.lo' libtool=yes @AMDEPBACKSLASH@
 175.788 +@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
 175.789 +@am__fastdepCC_FALSE@	$(LIBTOOL)  --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o trees.lo `test -f 'zlib/trees.c' || echo '$(srcdir)/'`zlib/trees.c
 175.790 +
 175.791 +uncompr.lo: zlib/uncompr.c
 175.792 +@am__fastdepCC_TRUE@	$(LIBTOOL)  --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT uncompr.lo -MD -MP -MF $(DEPDIR)/uncompr.Tpo -c -o uncompr.lo `test -f 'zlib/uncompr.c' || echo '$(srcdir)/'`zlib/uncompr.c
 175.793 +@am__fastdepCC_TRUE@	$(am__mv) $(DEPDIR)/uncompr.Tpo $(DEPDIR)/uncompr.Plo
 175.794 +@AMDEP_TRUE@@am__fastdepCC_FALSE@	source='zlib/uncompr.c' object='uncompr.lo' libtool=yes @AMDEPBACKSLASH@
 175.795 +@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
 175.796 +@am__fastdepCC_FALSE@	$(LIBTOOL)  --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o uncompr.lo `test -f 'zlib/uncompr.c' || echo '$(srcdir)/'`zlib/uncompr.c
 175.797 +
 175.798 +zio.lo: zlib/zio.c
 175.799 +@am__fastdepCC_TRUE@	$(LIBTOOL)  --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT zio.lo -MD -MP -MF $(DEPDIR)/zio.Tpo -c -o zio.lo `test -f 'zlib/zio.c' || echo '$(srcdir)/'`zlib/zio.c
 175.800 +@am__fastdepCC_TRUE@	$(am__mv) $(DEPDIR)/zio.Tpo $(DEPDIR)/zio.Plo
 175.801 +@AMDEP_TRUE@@am__fastdepCC_FALSE@	source='zlib/zio.c' object='zio.lo' libtool=yes @AMDEPBACKSLASH@
 175.802 +@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
 175.803 +@am__fastdepCC_FALSE@	$(LIBTOOL)  --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o zio.lo `test -f 'zlib/zio.c' || echo '$(srcdir)/'`zlib/zio.c
 175.804 +
 175.805 +zutil.lo: zlib/zutil.c
 175.806 +@am__fastdepCC_TRUE@	$(LIBTOOL)  --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT zutil.lo -MD -MP -MF $(DEPDIR)/zutil.Tpo -c -o zutil.lo `test -f 'zlib/zutil.c' || echo '$(srcdir)/'`zlib/zutil.c
 175.807 +@am__fastdepCC_TRUE@	$(am__mv) $(DEPDIR)/zutil.Tpo $(DEPDIR)/zutil.Plo
 175.808 +@AMDEP_TRUE@@am__fastdepCC_FALSE@	source='zlib/zutil.c' object='zutil.lo' libtool=yes @AMDEPBACKSLASH@
 175.809 +@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
 175.810 +@am__fastdepCC_FALSE@	$(LIBTOOL)  --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o zutil.lo `test -f 'zlib/zutil.c' || echo '$(srcdir)/'`zlib/zutil.c
 175.811 +
 175.812 +mostlyclean-libtool:
 175.813 +	-rm -f *.lo
 175.814 +
 175.815 +clean-libtool:
 175.816 +	-rm -rf .libs _libs
 175.817 +install-includeHEADERS: $(include_HEADERS)
 175.818 +	@$(NORMAL_INSTALL)
 175.819 +	test -z "$(includedir)" || $(MKDIR_P) "$(DESTDIR)$(includedir)"
 175.820 +	@list='$(include_HEADERS)'; test -n "$(includedir)" || list=; \
 175.821 +	for p in $$list; do \
 175.822 +	  if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \
 175.823 +	  echo "$$d$$p"; \
 175.824 +	done | $(am__base_list) | \
 175.825 +	while read files; do \
 175.826 +	  echo " $(INSTALL_HEADER) $$files '$(DESTDIR)$(includedir)'"; \
 175.827 +	  $(INSTALL_HEADER) $$files "$(DESTDIR)$(includedir)" || exit $$?; \
 175.828 +	done
 175.829 +
 175.830 +uninstall-includeHEADERS:
 175.831 +	@$(NORMAL_UNINSTALL)
 175.832 +	@list='$(include_HEADERS)'; test -n "$(includedir)" || list=; \
 175.833 +	files=`for p in $$list; do echo $$p; done | sed -e 's|^.*/||'`; \
 175.834 +	test -n "$$files" || exit 0; \
 175.835 +	echo " ( cd '$(DESTDIR)$(includedir)' && rm -f" $$files ")"; \
 175.836 +	cd "$(DESTDIR)$(includedir)" && rm -f $$files
 175.837 +
 175.838 +ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
 175.839 +	list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
 175.840 +	unique=`for i in $$list; do \
 175.841 +	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
 175.842 +	  done | \
 175.843 +	  $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
 175.844 +	      END { if (nonempty) { for (i in files) print i; }; }'`; \
 175.845 +	mkid -fID $$unique
 175.846 +tags: TAGS
 175.847 +
 175.848 +TAGS:  $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
 175.849 +		$(TAGS_FILES) $(LISP)
 175.850 +	set x; \
 175.851 +	here=`pwd`; \
 175.852 +	list='$(SOURCES) $(HEADERS)  $(LISP) $(TAGS_FILES)'; \
 175.853 +	unique=`for i in $$list; do \
 175.854 +	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
 175.855 +	  done | \
 175.856 +	  $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
 175.857 +	      END { if (nonempty) { for (i in files) print i; }; }'`; \
 175.858 +	shift; \
 175.859 +	if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \
 175.860 +	  test -n "$$unique" || unique=$$empty_fix; \
 175.861 +	  if test $$# -gt 0; then \
 175.862 +	    $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
 175.863 +	      "$$@" $$unique; \
 175.864 +	  else \
 175.865 +	    $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
 175.866 +	      $$unique; \
 175.867 +	  fi; \
 175.868 +	fi
 175.869 +ctags: CTAGS
 175.870 +CTAGS:  $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
 175.871 +		$(TAGS_FILES) $(LISP)
 175.872 +	list='$(SOURCES) $(HEADERS)  $(LISP) $(TAGS_FILES)'; \
 175.873 +	unique=`for i in $$list; do \
 175.874 +	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
 175.875 +	  done | \
 175.876 +	  $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
 175.877 +	      END { if (nonempty) { for (i in files) print i; }; }'`; \
 175.878 +	test -z "$(CTAGS_ARGS)$$unique" \
 175.879 +	  || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
 175.880 +	     $$unique
 175.881 +
 175.882 +GTAGS:
 175.883 +	here=`$(am__cd) $(top_builddir) && pwd` \
 175.884 +	  && $(am__cd) $(top_srcdir) \
 175.885 +	  && gtags -i $(GTAGS_ARGS) "$$here"
 175.886 +
 175.887 +distclean-tags:
 175.888 +	-rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
 175.889 +
 175.890 +distdir: $(DISTFILES)
 175.891 +	@srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
 175.892 +	topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
 175.893 +	list='$(DISTFILES)'; \
 175.894 +	  dist_files=`for file in $$list; do echo $$file; done | \
 175.895 +	  sed -e "s|^$$srcdirstrip/||;t" \
 175.896 +	      -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \
 175.897 +	case $$dist_files in \
 175.898 +	  */*) $(MKDIR_P) `echo "$$dist_files" | \
 175.899 +			   sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \
 175.900 +			   sort -u` ;; \
 175.901 +	esac; \
 175.902 +	for file in $$dist_files; do \
 175.903 +	  if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
 175.904 +	  if test -d $$d/$$file; then \
 175.905 +	    dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \
 175.906 +	    if test -d "$(distdir)/$$file"; then \
 175.907 +	      find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
 175.908 +	    fi; \
 175.909 +	    if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
 175.910 +	      cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \
 175.911 +	      find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
 175.912 +	    fi; \
 175.913 +	    cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \
 175.914 +	  else \
 175.915 +	    test -f "$(distdir)/$$file" \
 175.916 +	    || cp -p $$d/$$file "$(distdir)/$$file" \
 175.917 +	    || exit 1; \
 175.918 +	  fi; \
 175.919 +	done
 175.920 +check-am: all-am
 175.921 +check: check-am
 175.922 +all-am: Makefile $(LTLIBRARIES) $(HEADERS)
 175.923 +installdirs:
 175.924 +	for dir in "$(DESTDIR)$(libdir)" "$(DESTDIR)$(includedir)"; do \
 175.925 +	  test -z "$$dir" || $(MKDIR_P) "$$dir"; \
 175.926 +	done
 175.927 +install: install-am
 175.928 +install-exec: install-exec-am
 175.929 +install-data: install-data-am
 175.930 +uninstall: uninstall-am
 175.931 +
 175.932 +install-am: all-am
 175.933 +	@$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
 175.934 +
 175.935 +installcheck: installcheck-am
 175.936 +install-strip:
 175.937 +	$(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
 175.938 +	  install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
 175.939 +	  `test -z '$(STRIP)' || \
 175.940 +	    echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install
 175.941 +mostlyclean-generic:
 175.942 +
 175.943 +clean-generic:
 175.944 +
 175.945 +distclean-generic:
 175.946 +	-test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
 175.947 +	-test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES)
 175.948 +
 175.949 +maintainer-clean-generic:
 175.950 +	@echo "This command is intended for maintainers to use"
 175.951 +	@echo "it deletes files that may require special tools to rebuild."
 175.952 +clean: clean-am
 175.953 +
 175.954 +clean-am: clean-generic clean-libLTLIBRARIES clean-libtool \
 175.955 +	mostlyclean-am
 175.956 +
 175.957 +distclean: distclean-am
 175.958 +	-rm -rf ./$(DEPDIR)
 175.959 +	-rm -f Makefile
 175.960 +distclean-am: clean-am distclean-compile distclean-generic \
 175.961 +	distclean-tags
 175.962 +
 175.963 +dvi: dvi-am
 175.964 +
 175.965 +dvi-am:
 175.966 +
 175.967 +html: html-am
 175.968 +
 175.969 +html-am:
 175.970 +
 175.971 +info: info-am
 175.972 +
 175.973 +info-am:
 175.974 +
 175.975 +install-data-am: install-includeHEADERS
 175.976 +
 175.977 +install-dvi: install-dvi-am
 175.978 +
 175.979 +install-dvi-am:
 175.980 +
 175.981 +install-exec-am: install-libLTLIBRARIES
 175.982 +
 175.983 +install-html: install-html-am
 175.984 +
 175.985 +install-html-am:
 175.986 +
 175.987 +install-info: install-info-am
 175.988 +
 175.989 +install-info-am:
 175.990 +
 175.991 +install-man:
 175.992 +
 175.993 +install-pdf: install-pdf-am
 175.994 +
 175.995 +install-pdf-am:
 175.996 +
 175.997 +install-ps: install-ps-am
 175.998 +
 175.999 +install-ps-am:
175.1000 +
175.1001 +installcheck-am:
175.1002 +
175.1003 +maintainer-clean: maintainer-clean-am
175.1004 +	-rm -rf ./$(DEPDIR)
175.1005 +	-rm -f Makefile
175.1006 +maintainer-clean-am: distclean-am maintainer-clean-generic
175.1007 +
175.1008 +mostlyclean: mostlyclean-am
175.1009 +
175.1010 +mostlyclean-am: mostlyclean-compile mostlyclean-generic \
175.1011 +	mostlyclean-libtool
175.1012 +
175.1013 +pdf: pdf-am
175.1014 +
175.1015 +pdf-am:
175.1016 +
175.1017 +ps: ps-am
175.1018 +
175.1019 +ps-am:
175.1020 +
175.1021 +uninstall-am: uninstall-includeHEADERS uninstall-libLTLIBRARIES
175.1022 +
175.1023 +.MAKE: install-am install-strip
175.1024 +
175.1025 +.PHONY: CTAGS GTAGS all all-am check check-am clean clean-generic \
175.1026 +	clean-libLTLIBRARIES clean-libtool ctags distclean \
175.1027 +	distclean-compile distclean-generic distclean-libtool \
175.1028 +	distclean-tags distdir dvi dvi-am html html-am info info-am \
175.1029 +	install install-am install-data install-data-am install-dvi \
175.1030 +	install-dvi-am install-exec install-exec-am install-html \
175.1031 +	install-html-am install-includeHEADERS install-info \
175.1032 +	install-info-am install-libLTLIBRARIES install-man install-pdf \
175.1033 +	install-pdf-am install-ps install-ps-am install-strip \
175.1034 +	installcheck installcheck-am installdirs maintainer-clean \
175.1035 +	maintainer-clean-generic mostlyclean mostlyclean-compile \
175.1036 +	mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \
175.1037 +	tags uninstall uninstall-am uninstall-includeHEADERS \
175.1038 +	uninstall-libLTLIBRARIES
175.1039 +
175.1040 +
175.1041 +# Tell versions [3.59,3.63) of GNU make to not export all variables.
175.1042 +# Otherwise a system limit (for SysV at least) may be exceeded.
175.1043 +.NOEXPORT:
   176.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
   176.2 +++ b/deps/glpk/src/amd/COPYING	Sun Nov 06 20:59:10 2011 +0100
   176.3 @@ -0,0 +1,502 @@
   176.4 +                  GNU LESSER GENERAL PUBLIC LICENSE
   176.5 +                       Version 2.1, February 1999
   176.6 +
   176.7 + Copyright (C) 1991, 1999 Free Software Foundation, Inc.
   176.8 +     51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
   176.9 + Everyone is permitted to copy and distribute verbatim copies
  176.10 + of this license document, but changing it is not allowed.
  176.11 +
  176.12 +[This is the first released version of the Lesser GPL.  It also counts
  176.13 + as the successor of the GNU Library Public License, version 2, hence
  176.14 + the version number 2.1.]
  176.15 +
  176.16 +                            Preamble
  176.17 +
  176.18 +  The licenses for most software are designed to take away your
  176.19 +freedom to share and change it.  By contrast, the GNU General Public
  176.20 +Licenses are intended to guarantee your freedom to share and change
  176.21 +free software--to make sure the software is free for all its users.
  176.22 +
  176.23 +  This license, the Lesser General Public License, applies to some
  176.24 +specially designated software packages--typically libraries--of the
  176.25 +Free Software Foundation and other authors who decide to use it.  You
  176.26 +can use it too, but we suggest you first think carefully about whether
  176.27 +this license or the ordinary General Public License is the better
  176.28 +strategy to use in any particular case, based on the explanations below.
  176.29 +
  176.30 +  When we speak of free software, we are referring to freedom of use,
  176.31 +not price.  Our General Public Licenses are designed to make sure that
  176.32 +you have the freedom to distribute copies of free software (and charge
  176.33 +for this service if you wish); that you receive source code or can get
  176.34 +it if you want it; that you can change the software and use pieces of
  176.35 +it in new free programs; and that you are informed that you can do
  176.36 +these things.
  176.37 +
  176.38 +  To protect your rights, we need to make restrictions that forbid
  176.39 +distributors to deny you these rights or to ask you to surrender these
  176.40 +rights.  These restrictions translate to certain responsibilities for
  176.41 +you if you distribute copies of the library or if you modify it.
  176.42 +
  176.43 +  For example, if you distribute copies of the library, whether gratis
  176.44 +or for a fee, you must give the recipients all the rights that we gave
  176.45 +you.  You must make sure that they, too, receive or can get the source
  176.46 +code.  If you link other code with the library, you must provide
  176.47 +complete object files to the recipients, so that they can relink them
  176.48 +with the library after making changes to the library and recompiling
  176.49 +it.  And you must show them these terms so they know their rights.
  176.50 +
  176.51 +  We protect your rights with a two-step method: (1) we copyright the
  176.52 +library, and (2) we offer you this license, which gives you legal
  176.53 +permission to copy, distribute and/or modify the library.
  176.54 +
  176.55 +  To protect each distributor, we want to make it very clear that
  176.56 +there is no warranty for the free library.  Also, if the library is
  176.57 +modified by someone else and passed on, the recipients should know
  176.58 +that what they have is not the original version, so that the original
  176.59 +author's reputation will not be affected by problems that might be
  176.60 +introduced by others.
  176.61 +
  176.62 +  Finally, software patents pose a constant threat to the existence of
  176.63 +any free program.  We wish to make sure that a company cannot
  176.64 +effectively restrict the users of a free program by obtaining a
  176.65 +restrictive license from a patent holder.  Therefore, we insist that
  176.66 +any patent license obtained for a version of the library must be
  176.67 +consistent with the full freedom of use specified in this license.
  176.68 +
  176.69 +  Most GNU software, including some libraries, is covered by the
  176.70 +ordinary GNU General Public License.  This license, the GNU Lesser
  176.71 +General Public License, applies to certain designated libraries, and
  176.72 +is quite different from the ordinary General Public License.  We use
  176.73 +this license for certain libraries in order to permit linking those
  176.74 +libraries into non-free programs.
  176.75 +
  176.76 +  When a program is linked with a library, whether statically or using
  176.77 +a shared library, the combination of the two is legally speaking a
  176.78 +combined work, a derivative of the original library.  The ordinary
  176.79 +General Public License therefore permits such linking only if the
  176.80 +entire combination fits its criteria of freedom.  The Lesser General
  176.81 +Public License permits more lax criteria for linking other code with
  176.82 +the library.
  176.83 +
  176.84 +  We call this license the "Lesser" General Public License because it
  176.85 +does Less to protect the user's freedom than the ordinary General
  176.86 +Public License.  It also provides other free software developers Less
  176.87 +of an advantage over competing non-free programs.  These disadvantages
  176.88 +are the reason we use the ordinary General Public License for many
  176.89 +libraries.  However, the Lesser license provides advantages in certain
  176.90 +special circumstances.
  176.91 +
  176.92 +  For example, on rare occasions, there may be a special need to
  176.93 +encourage the widest possible use of a certain library, so that it becomes
  176.94 +a de-facto standard.  To achieve this, non-free programs must be
  176.95 +allowed to use the library.  A more frequent case is that a free
  176.96 +library does the same job as widely used non-free libraries.  In this
  176.97 +case, there is little to gain by limiting the free library to free
  176.98 +software only, so we use the Lesser General Public License.
  176.99 +
 176.100 +  In other cases, permission to use a particular library in non-free
 176.101 +programs enables a greater number of people to use a large body of
 176.102 +free software.  For example, permission to use the GNU C Library in
 176.103 +non-free programs enables many more people to use the whole GNU
 176.104 +operating system, as well as its variant, the GNU/Linux operating
 176.105 +system.
 176.106 +
 176.107 +  Although the Lesser General Public License is Less protective of the
 176.108 +users' freedom, it does ensure that the user of a program that is
 176.109 +linked with the Library has the freedom and the wherewithal to run
 176.110 +that program using a modified version of the Library.
 176.111 +
 176.112 +  The precise terms and conditions for copying, distribution and
 176.113 +modification follow.  Pay close attention to the difference between a
 176.114 +"work based on the library" and a "work that uses the library".  The
 176.115 +former contains code derived from the library, whereas the latter must
 176.116 +be combined with the library in order to run.
 176.117 +
 176.118 +                  GNU LESSER GENERAL PUBLIC LICENSE
 176.119 +   TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
 176.120 +
 176.121 +  0. This License Agreement applies to any software library or other
 176.122 +program which contains a notice placed by the copyright holder or
 176.123 +other authorized party saying it may be distributed under the terms of
 176.124 +this Lesser General Public License (also called "this License").
 176.125 +Each licensee is addressed as "you".
 176.126 +
 176.127 +  A "library" means a collection of software functions and/or data
 176.128 +prepared so as to be conveniently linked with application programs
 176.129 +(which use some of those functions and data) to form executables.
 176.130 +
 176.131 +  The "Library", below, refers to any such software library or work
 176.132 +which has been distributed under these terms.  A "work based on the
 176.133 +Library" means either the Library or any derivative work under
 176.134 +copyright law: that is to say, a work containing the Library or a
 176.135 +portion of it, either verbatim or with modifications and/or translated
 176.136 +straightforwardly into another language.  (Hereinafter, translation is
 176.137 +included without limitation in the term "modification".)
 176.138 +
 176.139 +  "Source code" for a work means the preferred form of the work for
 176.140 +making modifications to it.  For a library, complete source code means
 176.141 +all the source code for all modules it contains, plus any associated
 176.142 +interface definition files, plus the scripts used to control compilation
 176.143 +and installation of the library.
 176.144 +
 176.145 +  Activities other than copying, distribution and modification are not
 176.146 +covered by this License; they are outside its scope.  The act of
 176.147 +running a program using the Library is not restricted, and output from
 176.148 +such a program is covered only if its contents constitute a work based
 176.149 +on the Library (independent of the use of the Library in a tool for
 176.150 +writing it).  Whether that is true depends on what the Library does
 176.151 +and what the program that uses the Library does.
 176.152 +
 176.153 +  1. You may copy and distribute verbatim copies of the Library's
 176.154 +complete source code as you receive it, in any medium, provided that
 176.155 +you conspicuously and appropriately publish on each copy an
 176.156 +appropriate copyright notice and disclaimer of warranty; keep intact
 176.157 +all the notices that refer to this License and to the absence of any
 176.158 +warranty; and distribute a copy of this License along with the
 176.159 +Library.
 176.160 +
 176.161 +  You may charge a fee for the physical act of transferring a copy,
 176.162 +and you may at your option offer warranty protection in exchange for a
 176.163 +fee.
 176.164 +
 176.165 +  2. You may modify your copy or copies of the Library or any portion
 176.166 +of it, thus forming a work based on the Library, and copy and
 176.167 +distribute such modifications or work under the terms of Section 1
 176.168 +above, provided that you also meet all of these conditions:
 176.169 +
 176.170 +    a) The modified work must itself be a software library.
 176.171 +
 176.172 +    b) You must cause the files modified to carry prominent notices
 176.173 +    stating that you changed the files and the date of any change.
 176.174 +
 176.175 +    c) You must cause the whole of the work to be licensed at no
 176.176 +    charge to all third parties under the terms of this License.
 176.177 +
 176.178 +    d) If a facility in the modified Library refers to a function or a
 176.179 +    table of data to be supplied by an application program that uses
 176.180 +    the facility, other than as an argument passed when the facility
 176.181 +    is invoked, then you must make a good faith effort to ensure that,
 176.182 +    in the event an application does not supply such function or
 176.183 +    table, the facility still operates, and performs whatever part of
 176.184 +    its purpose remains meaningful.
 176.185 +
 176.186 +    (For example, a function in a library to compute square roots has
 176.187 +    a purpose that is entirely well-defined independent of the
 176.188 +    application.  Therefore, Subsection 2d requires that any
 176.189 +    application-supplied function or table used by this function must
 176.190 +    be optional: if the application does not supply it, the square
 176.191 +    root function must still compute square roots.)
 176.192 +
 176.193 +These requirements apply to the modified work as a whole.  If
 176.194 +identifiable sections of that work are not derived from the Library,
 176.195 +and can be reasonably considered independent and separate works in
 176.196 +themselves, then this License, and its terms, do not apply to those
 176.197 +sections when you distribute them as separate works.  But when you
 176.198 +distribute the same sections as part of a whole which is a work based
 176.199 +on the Library, the distribution of the whole must be on the terms of
 176.200 +this License, whose permissions for other licensees extend to the
 176.201 +entire whole, and thus to each and every part regardless of who wrote
 176.202 +it.
 176.203 +
 176.204 +Thus, it is not the intent of this section to claim rights or contest
 176.205 +your rights to work written entirely by you; rather, the intent is to
 176.206 +exercise the right to control the distribution of derivative or
 176.207 +collective works based on the Library.
 176.208 +
 176.209 +In addition, mere aggregation of another work not based on the Library
 176.210 +with the Library (or with a work based on the Library) on a volume of
 176.211 +a storage or distribution medium does not bring the other work under
 176.212 +the scope of this License.
 176.213 +
 176.214 +  3. You may opt to apply the terms of the ordinary GNU General Public
 176.215 +License instead of this License to a given copy of the Library.  To do
 176.216 +this, you must alter all the notices that refer to this License, so
 176.217 +that they refer to the ordinary GNU General Public License, version 2,
 176.218 +instead of to this License.  (If a newer version than version 2 of the
 176.219 +ordinary GNU General Public License has appeared, then you can specify
 176.220 +that version instead if you wish.)  Do not make any other change in
 176.221 +these notices.
 176.222 +
 176.223 +  Once this change is made in a given copy, it is irreversible for
 176.224 +that copy, so the ordinary GNU General Public License applies to all
 176.225 +subsequent copies and derivative works made from that copy.
 176.226 +
 176.227 +  This option is useful when you wish to copy part of the code of
 176.228 +the Library into a program that is not a library.
 176.229 +
 176.230 +  4. You may copy and distribute the Library (or a portion or
 176.231 +derivative of it, under Section 2) in object code or executable form
 176.232 +under the terms of Sections 1 and 2 above provided that you accompany
 176.233 +it with the complete corresponding machine-readable source code, which
 176.234 +must be distributed under the terms of Sections 1 and 2 above on a
 176.235 +medium customarily used for software interchange.
 176.236 +
 176.237 +  If distribution of object code is made by offering access to copy
 176.238 +from a designated place, then offering equivalent access to copy the
 176.239 +source code from the same place satisfies the requirement to
 176.240 +distribute the source code, even though third parties are not
 176.241 +compelled to copy the source along with the object code.
 176.242 +
 176.243 +  5. A program that contains no derivative of any portion of the
 176.244 +Library, but is designed to work with the Library by being compiled or
 176.245 +linked with it, is called a "work that uses the Library".  Such a
 176.246 +work, in isolation, is not a derivative work of the Library, and
 176.247 +therefore falls outside the scope of this License.
 176.248 +
 176.249 +  However, linking a "work that uses the Library" with the Library
 176.250 +creates an executable that is a derivative of the Library (because it
 176.251 +contains portions of the Library), rather than a "work that uses the
 176.252 +library".  The executable is therefore covered by this License.
 176.253 +Section 6 states terms for distribution of such executables.
 176.254 +
 176.255 +  When a "work that uses the Library" uses material from a header file
 176.256 +that is part of the Library, the object code for the work may be a
 176.257 +derivative work of the Library even though the source code is not.
 176.258 +Whether this is true is especially significant if the work can be
 176.259 +linked without the Library, or if the work is itself a library.  The
 176.260 +threshold for this to be true is not precisely defined by law.
 176.261 +
 176.262 +  If such an object file uses only numerical parameters, data
 176.263 +structure layouts and accessors, and small macros and small inline
 176.264 +functions (ten lines or less in length), then the use of the object
 176.265 +file is unrestricted, regardless of whether it is legally a derivative
 176.266 +work.  (Executables containing this object code plus portions of the
 176.267 +Library will still fall under Section 6.)
 176.268 +
 176.269 +  Otherwise, if the work is a derivative of the Library, you may
 176.270 +distribute the object code for the work under the terms of Section 6.
 176.271 +Any executables containing that work also fall under Section 6,
 176.272 +whether or not they are linked directly with the Library itself.
 176.273 +
 176.274 +  6. As an exception to the Sections above, you may also combine or
 176.275 +link a "work that uses the Library" with the Library to produce a
 176.276 +work containing portions of the Library, and distribute that work
 176.277 +under terms of your choice, provided that the terms permit
 176.278 +modification of the work for the customer's own use and reverse
 176.279 +engineering for debugging such modifications.
 176.280 +
 176.281 +  You must give prominent notice with each copy of the work that the
 176.282 +Library is used in it and that the Library and its use are covered by
 176.283 +this License.  You must supply a copy of this License.  If the work
 176.284 +during execution displays copyright notices, you must include the
 176.285 +copyright notice for the Library among them, as well as a reference
 176.286 +directing the user to the copy of this License.  Also, you must do one
 176.287 +of these things:
 176.288 +
 176.289 +    a) Accompany the work with the complete corresponding
 176.290 +    machine-readable source code for the Library including whatever
 176.291 +    changes were used in the work (which must be distributed under
 176.292 +    Sections 1 and 2 above); and, if the work is an executable linked
 176.293 +    with the Library, with the complete machine-readable "work that
 176.294 +    uses the Library", as object code and/or source code, so that the
 176.295 +    user can modify the Library and then relink to produce a modified
 176.296 +    executable containing the modified Library.  (It is understood
 176.297 +    that the user who changes the contents of definitions files in the
 176.298 +    Library will not necessarily be able to recompile the application
 176.299 +    to use the modified definitions.)
 176.300 +
 176.301 +    b) Use a suitable shared library mechanism for linking with the
 176.302 +    Library.  A suitable mechanism is one that (1) uses at run time a
 176.303 +    copy of the library already present on the user's computer system,
 176.304 +    rather than copying library functions into the executable, and (2)
 176.305 +    will operate properly with a modified version of the library, if
 176.306 +    the user installs one, as long as the modified version is
 176.307 +    interface-compatible with the version that the work was made with.
 176.308 +
 176.309 +    c) Accompany the work with a written offer, valid for at
 176.310 +    least three years, to give the same user the materials
 176.311 +    specified in Subsection 6a, above, for a charge no more
 176.312 +    than the cost of performing this distribution.
 176.313 +
 176.314 +    d) If distribution of the work is made by offering access to copy
 176.315 +    from a designated place, offer equivalent access to copy the above
 176.316 +    specified materials from the same place.
 176.317 +
 176.318 +    e) Verify that the user has already received a copy of these
 176.319 +    materials or that you have already sent this user a copy.
 176.320 +
 176.321 +  For an executable, the required form of the "work that uses the
 176.322 +Library" must include any data and utility programs needed for
 176.323 +reproducing the executable from it.  However, as a special exception,
 176.324 +the materials to be distributed need not include anything that is
 176.325 +normally distributed (in either source or binary form) with the major
 176.326 +components (compiler, kernel, and so on) of the operating system on
 176.327 +which the executable runs, unless that component itself accompanies
 176.328 +the executable.
 176.329 +
 176.330 +  It may happen that this requirement contradicts the license
 176.331 +restrictions of other proprietary libraries that do not normally
 176.332 +accompany the operating system.  Such a contradiction means you cannot
 176.333 +use both them and the Library together in an executable that you
 176.334 +distribute.
 176.335 +
 176.336 +  7. You may place library facilities that are a work based on the
 176.337 +Library side-by-side in a single library together with other library
 176.338 +facilities not covered by this License, and distribute such a combined
 176.339 +library, provided that the separate distribution of the work based on
 176.340 +the Library and of the other library facilities is otherwise
 176.341 +permitted, and provided that you do these two things:
 176.342 +
 176.343 +    a) Accompany the combined library with a copy of the same work
 176.344 +    based on the Library, uncombined with any other library
 176.345 +    facilities.  This must be distributed under the terms of the
 176.346 +    Sections above.
 176.347 +
 176.348 +    b) Give prominent notice with the combined library of the fact
 176.349 +    that part of it is a work based on the Library, and explaining
 176.350 +    where to find the accompanying uncombined form of the same work.
 176.351 +
 176.352 +  8. You may not copy, modify, sublicense, link with, or distribute
 176.353 +the Library except as expressly provided under this License.  Any
 176.354 +attempt otherwise to copy, modify, sublicense, link with, or
 176.355 +distribute the Library is void, and will automatically terminate your
 176.356 +rights under this License.  However, parties who have received copies,
 176.357 +or rights, from you under this License will not have their licenses
 176.358 +terminated so long as such parties remain in full compliance.
 176.359 +
 176.360 +  9. You are not required to accept this License, since you have not
 176.361 +signed it.  However, nothing else grants you permission to modify or
 176.362 +distribute the Library or its derivative works.  These actions are
 176.363 +prohibited by law if you do not accept this License.  Therefore, by
 176.364 +modifying or distributing the Library (or any work based on the
 176.365 +Library), you indicate your acceptance of this License to do so, and
 176.366 +all its terms and conditions for copying, distributing or modifying
 176.367 +the Library or works based on it.
 176.368 +
 176.369 +  10. Each time you redistribute the Library (or any work based on the
 176.370 +Library), the recipient automatically receives a license from the
 176.371 +original licensor to copy, distribute, link with or modify the Library
 176.372 +subject to these terms and conditions.  You may not impose any further
 176.373 +restrictions on the recipients' exercise of the rights granted herein.
 176.374 +You are not responsible for enforcing compliance by third parties with
 176.375 +this License.
 176.376 +
 176.377 +  11. If, as a consequence of a court judgment or allegation of patent
 176.378 +infringement or for any other reason (not limited to patent issues),
 176.379 +conditions are imposed on you (whether by court order, agreement or
 176.380 +otherwise) that contradict the conditions of this License, they do not
 176.381 +excuse you from the conditions of this License.  If you cannot
 176.382 +distribute so as to satisfy simultaneously your obligations under this
 176.383 +License and any other pertinent obligations, then as a consequence you
 176.384 +may not distribute the Library at all.  For example, if a patent
 176.385 +license would not permit royalty-free redistribution of the Library by
 176.386 +all those who receive copies directly or indirectly through you, then
 176.387 +the only way you could satisfy both it and this License would be to
 176.388 +refrain entirely from distribution of the Library.
 176.389 +
 176.390 +If any portion of this section is held invalid or unenforceable under any
 176.391 +particular circumstance, the balance of the section is intended to apply,
 176.392 +and the section as a whole is intended to apply in other circumstances.
 176.393 +
 176.394 +It is not the purpose of this section to induce you to infringe any
 176.395 +patents or other property right claims or to contest validity of any
 176.396 +such claims; this section has the sole purpose of protecting the
 176.397 +integrity of the free software distribution system which is
 176.398 +implemented by public license practices.  Many people have made
 176.399 +generous contributions to the wide range of software distributed
 176.400 +through that system in reliance on consistent application of that
 176.401 +system; it is up to the author/donor to decide if he or she is willing
 176.402 +to distribute software through any other system and a licensee cannot
 176.403 +impose that choice.
 176.404 +
 176.405 +This section is intended to make thoroughly clear what is believed to
 176.406 +be a consequence of the rest of this License.
 176.407 +
 176.408 +  12. If the distribution and/or use of the Library is restricted in
 176.409 +certain countries either by patents or by copyrighted interfaces, the
 176.410 +original copyright holder who places the Library under this License may add
 176.411 +an explicit geographical distribution limitation excluding those countries,
 176.412 +so that distribution is permitted only in or among countries not thus
 176.413 +excluded.  In such case, this License incorporates the limitation as if
 176.414 +written in the body of this License.
 176.415 +
 176.416 +  13. The Free Software Foundation may publish revised and/or new
 176.417 +versions of the Lesser General Public License from time to time.
 176.418 +Such new versions will be similar in spirit to the present version,
 176.419 +but may differ in detail to address new problems or concerns.
 176.420 +
 176.421 +Each version is given a distinguishing version number.  If the Library
 176.422 +specifies a version number of this License which applies to it and
 176.423 +"any later version", you have the option of following the terms and
 176.424 +conditions either of that version or of any later version published by
 176.425 +the Free Software Foundation.  If the Library does not specify a
 176.426 +license version number, you may choose any version ever published by
 176.427 +the Free Software Foundation.
 176.428 +
 176.429 +  14. If you wish to incorporate parts of the Library into other free
 176.430 +programs whose distribution conditions are incompatible with these,
 176.431 +write to the author to ask for permission.  For software which is
 176.432 +copyrighted by the Free Software Foundation, write to the Free
 176.433 +Software Foundation; we sometimes make exceptions for this.  Our
 176.434 +decision will be guided by the two goals of preserving the free status
 176.435 +of all derivatives of our free software and of promoting the sharing
 176.436 +and reuse of software generally.
 176.437 +
 176.438 +                            NO WARRANTY
 176.439 +
 176.440 +  15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO
 176.441 +WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW.
 176.442 +EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR
 176.443 +OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY
 176.444 +KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE
 176.445 +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
 176.446 +PURPOSE.  THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE
 176.447 +LIBRARY IS WITH YOU.  SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME
 176.448 +THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
 176.449 +
 176.450 +  16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN
 176.451 +WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY
 176.452 +AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU
 176.453 +FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR
 176.454 +CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE
 176.455 +LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING
 176.456 +RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A
 176.457 +FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF
 176.458 +SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
 176.459 +DAMAGES.
 176.460 +
 176.461 +                     END OF TERMS AND CONDITIONS
 176.462 +
 176.463 +           How to Apply These Terms to Your New Libraries
 176.464 +
 176.465 +  If you develop a new library, and you want it to be of the greatest
 176.466 +possible use to the public, we recommend making it free software that
 176.467 +everyone can redistribute and change.  You can do so by permitting
 176.468 +redistribution under these terms (or, alternatively, under the terms of the
 176.469 +ordinary General Public License).
 176.470 +
 176.471 +  To apply these terms, attach the following notices to the library.  It is
 176.472 +safest to attach them to the start of each source file to most effectively
 176.473 +convey the exclusion of warranty; and each file should have at least the
 176.474 +"copyright" line and a pointer to where the full notice is found.
 176.475 +
 176.476 +    <one line to give the library's name and a brief idea of what it does.>
 176.477 +    Copyright (C) <year>  <name of author>
 176.478 +
 176.479 +    This library is free software; you can redistribute it and/or
 176.480 +    modify it under the terms of the GNU Lesser General Public
 176.481 +    License as published by the Free Software Foundation; either
 176.482 +    version 2.1 of the License, or (at your option) any later version.
 176.483 +
 176.484 +    This library is distributed in the hope that it will be useful,
 176.485 +    but WITHOUT ANY WARRANTY; without even the implied warranty of
 176.486 +    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 176.487 +    Lesser General Public License for more details.
 176.488 +
 176.489 +    You should have received a copy of the GNU Lesser General Public
 176.490 +    License along with this library; if not, write to the Free Software
 176.491 +    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 176.492 +
 176.493 +Also add information on how to contact you by electronic and paper mail.
 176.494 +
 176.495 +You should also get your employer (if you work as a programmer) or your
 176.496 +school, if any, to sign a "copyright disclaimer" for the library, if
 176.497 +necessary.  Here is a sample; alter the names:
 176.498 +
 176.499 +  Yoyodyne, Inc., hereby disclaims all copyright interest in the
 176.500 +  library `Frob' (a library for tweaking knobs) written by James Random Hacker.
 176.501 +
 176.502 +  <signature of Ty Coon>, 1 April 1990
 176.503 +  Ty Coon, President of Vice
 176.504 +
 176.505 +That's all there is to it!
   177.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
   177.2 +++ b/deps/glpk/src/amd/README	Sun Nov 06 20:59:10 2011 +0100
   177.3 @@ -0,0 +1,58 @@
   177.4 +NOTE: Files in this subdirectory are NOT part of the GLPK package, but
   177.5 +      are used with GLPK.
   177.6 +
   177.7 +      The original code was modified according to GLPK requirements by
   177.8 +      Andrew Makhorin <mao@gnu.org>.
   177.9 +************************************************************************
  177.10 +AMD Version 2.2, Copyright (C) 2007 by Timothy A. Davis,
  177.11 +Patrick R. Amestoy, and Iain S. Duff.  All Rights Reserved.
  177.12 +
  177.13 +Description:
  177.14 +
  177.15 +   AMD is a set of routines for pre-ordering sparse matrices prior to
  177.16 +   Cholesky or LU factorization, using the approximate minimum degree
  177.17 +   ordering algorithm.  Written in ANSI/ISO C with a MATLAB interface,
  177.18 +   and in Fortran 77.
  177.19 +
  177.20 +Authors:
  177.21 +
  177.22 +   Timothy A. Davis (davis at cise.ufl.edu), University of Florida.
  177.23 +   Patrick R. Amestoy, ENSEEIHT, Toulouse, France.
  177.24 +   Iain S. Duff, Rutherford Appleton Laboratory, UK.
  177.25 +
  177.26 +AMD License:
  177.27 +
  177.28 +   Your use or distribution of AMD or any modified version of AMD
  177.29 +   implies that you agree to this License.
  177.30 +
  177.31 +   This library is free software; you can redistribute it and/or
  177.32 +   modify it under the terms of the GNU Lesser General Public License
  177.33 +   as published by the Free Software Foundation; either version 2.1 of
  177.34 +   the License, or (at your option) any later version.
  177.35 +
  177.36 +   This library is distributed in the hope that it will be useful,
  177.37 +   but WITHOUT ANY WARRANTY; without even the implied warranty of
  177.38 +   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  177.39 +   Lesser General Public License for more details.
  177.40 +
  177.41 +   You should have received a copy of the GNU Lesser General Public
  177.42 +   License along with this library; if not, write to the Free Software
  177.43 +   Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301
  177.44 +   USA.
  177.45 +
  177.46 +   Permission is hereby granted to use or copy this program under the
  177.47 +   terms of the GNU LGPL, provided that the Copyright, this License,
  177.48 +   and the Availability of the original version is retained on all
  177.49 +   copies.  User documentation of any code that uses this code or any
  177.50 +   modified version of this code must cite the Copyright, this License,
  177.51 +   the Availability note, and "Used by permission."  Permission to
  177.52 +   modify the code and to distribute modified code is granted, provided
  177.53 +   the Copyright, this License, and the Availability note are retained,
  177.54 +   and a notice that the code was modified is included.
  177.55 +
  177.56 +   AMD is available under alternate licences; contact T. Davis for
  177.57 +   details.
  177.58 +
  177.59 +Availability:
  177.60 +
  177.61 +    http://www.cise.ufl.edu/research/sparse/amd
   178.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
   178.2 +++ b/deps/glpk/src/amd/amd.h	Sun Nov 06 20:59:10 2011 +0100
   178.3 @@ -0,0 +1,67 @@
   178.4 +/* amd.h */
   178.5 +
   178.6 +/* Written by Andrew Makhorin <mao@gnu.org>. */
   178.7 +
   178.8 +#ifndef GLPAMD_H
   178.9 +#define GLPAMD_H
  178.10 +
  178.11 +#define AMD_DATE "May 31, 2007"
  178.12 +#define AMD_VERSION_CODE(main, sub) ((main) * 1000 + (sub))
  178.13 +#define AMD_MAIN_VERSION 2
  178.14 +#define AMD_SUB_VERSION 2
  178.15 +#define AMD_SUBSUB_VERSION 0
  178.16 +#define AMD_VERSION AMD_VERSION_CODE(AMD_MAIN_VERSION, AMD_SUB_VERSION)
  178.17 +
  178.18 +#define AMD_CONTROL 5
  178.19 +#define AMD_INFO 20
  178.20 +
  178.21 +#define AMD_DENSE 0
  178.22 +#define AMD_AGGRESSIVE 1
  178.23 +
  178.24 +#define AMD_DEFAULT_DENSE 10.0
  178.25 +#define AMD_DEFAULT_AGGRESSIVE 1
  178.26 +
  178.27 +#define AMD_STATUS         0
  178.28 +#define AMD_N              1
  178.29 +#define AMD_NZ             2
  178.30 +#define AMD_SYMMETRY       3
  178.31 +#define AMD_NZDIAG         4
  178.32 +#define AMD_NZ_A_PLUS_AT   5
  178.33 +#define AMD_NDENSE         6
  178.34 +#define AMD_MEMORY         7
  178.35 +#define AMD_NCMPA          8
  178.36 +#define AMD_LNZ            9
  178.37 +#define AMD_NDIV           10
  178.38 +#define AMD_NMULTSUBS_LDL  11
  178.39 +#define AMD_NMULTSUBS_LU   12
  178.40 +#define AMD_DMAX           13
  178.41 +
  178.42 +#define AMD_OK             0
  178.43 +#define AMD_OUT_OF_MEMORY  (-1)
  178.44 +#define AMD_INVALID        (-2)
  178.45 +#define AMD_OK_BUT_JUMBLED 1
  178.46 +
  178.47 +#define amd_order _glp_amd_order
  178.48 +int amd_order(int n, const int Ap[], const int Ai[], int P[],
  178.49 +      double Control[], double Info[]);
  178.50 +
  178.51 +#define amd_2 _glp_amd_2
  178.52 +void amd_2(int n, int Pe[], int Iw[], int Len[], int iwlen, int pfree,
  178.53 +      int Nv[], int Next[], int Last[], int Head[], int Elen[],
  178.54 +      int Degree[], int W[], double Control[], double Info[]);
  178.55 +
  178.56 +#define amd_valid _glp_amd_valid
  178.57 +int amd_valid(int n_row, int n_col, const int Ap[], const int Ai[]);
  178.58 +
  178.59 +#define amd_defaults _glp_amd_defaults
  178.60 +void amd_defaults(double Control[]);
  178.61 +
  178.62 +#define amd_control _glp_amd_control
  178.63 +void amd_control(double Control[]);
  178.64 +
  178.65 +#define amd_info _glp_amd_info
  178.66 +void amd_info(double Info[]);
  178.67 +
  178.68 +#endif
  178.69 +
  178.70 +/* eof */
   179.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
   179.2 +++ b/deps/glpk/src/amd/amd_1.c	Sun Nov 06 20:59:10 2011 +0100
   179.3 @@ -0,0 +1,181 @@
   179.4 +/* ========================================================================= */
   179.5 +/* === AMD_1 =============================================================== */
   179.6 +/* ========================================================================= */
   179.7 +
   179.8 +/* ------------------------------------------------------------------------- */
   179.9 +/* AMD, Copyright (c) Timothy A. Davis,                                      */
  179.10 +/* Patrick R. Amestoy, and Iain S. Duff.  See ../README.txt for License.     */
  179.11 +/* email: davis at cise.ufl.edu    CISE Department, Univ. of Florida.        */
  179.12 +/* web: http://www.cise.ufl.edu/research/sparse/amd                          */
  179.13 +/* ------------------------------------------------------------------------- */
  179.14 +
  179.15 +/* AMD_1: Construct A+A' for a sparse matrix A and perform the AMD ordering.
  179.16 + *
  179.17 + * The n-by-n sparse matrix A can be unsymmetric.  It is stored in MATLAB-style
  179.18 + * compressed-column form, with sorted row indices in each column, and no
  179.19 + * duplicate entries.  Diagonal entries may be present, but they are ignored.
  179.20 + * Row indices of column j of A are stored in Ai [Ap [j] ... Ap [j+1]-1].
  179.21 + * Ap [0] must be zero, and nz = Ap [n] is the number of entries in A.  The
  179.22 + * size of the matrix, n, must be greater than or equal to zero.
  179.23 + *
  179.24 + * This routine must be preceded by a call to AMD_aat, which computes the
  179.25 + * number of entries in each row/column in A+A', excluding the diagonal.
  179.26 + * Len [j], on input, is the number of entries in row/column j of A+A'.  This
  179.27 + * routine constructs the matrix A+A' and then calls AMD_2.  No error checking
  179.28 + * is performed (this was done in AMD_valid).
  179.29 + */
  179.30 +
  179.31 +#include "amd_internal.h"
  179.32 +
  179.33 +GLOBAL void AMD_1
  179.34 +(
  179.35 +    Int n,              /* n > 0 */
  179.36 +    const Int Ap [ ],   /* input of size n+1, not modified */
  179.37 +    const Int Ai [ ],   /* input of size nz = Ap [n], not modified */
  179.38 +    Int P [ ],          /* size n output permutation */
  179.39 +    Int Pinv [ ],       /* size n output inverse permutation */
  179.40 +    Int Len [ ],        /* size n input, undefined on output */
  179.41 +    Int slen,           /* slen >= sum (Len [0..n-1]) + 7n,
  179.42 +                         * ideally slen = 1.2 * sum (Len) + 8n */
  179.43 +    Int S [ ],          /* size slen workspace */
  179.44 +    double Control [ ], /* input array of size AMD_CONTROL */
  179.45 +    double Info [ ]     /* output array of size AMD_INFO */
  179.46 +)
  179.47 +{
  179.48 +    Int i, j, k, p, pfree, iwlen, pj, p1, p2, pj2, *Iw, *Pe, *Nv, *Head,
  179.49 +        *Elen, *Degree, *s, *W, *Sp, *Tp ;
  179.50 +
  179.51 +    /* --------------------------------------------------------------------- */
  179.52 +    /* construct the matrix for AMD_2 */
  179.53 +    /* --------------------------------------------------------------------- */
  179.54 +
  179.55 +    ASSERT (n > 0) ;
  179.56 +
  179.57 +    iwlen = slen - 6*n ;
  179.58 +    s = S ;
  179.59 +    Pe = s ;        s += n ;
  179.60 +    Nv = s ;        s += n ;
  179.61 +    Head = s ;      s += n ;
  179.62 +    Elen = s ;      s += n ;
  179.63 +    Degree = s ;    s += n ;
  179.64 +    W = s ;         s += n ;
  179.65 +    Iw = s ;        s += iwlen ;
  179.66 +
  179.67 +    ASSERT (AMD_valid (n, n, Ap, Ai) == AMD_OK) ;
  179.68 +
  179.69 +    /* construct the pointers for A+A' */
  179.70 +    Sp = Nv ;                   /* use Nv and W as workspace for Sp and Tp [ */
  179.71 +    Tp = W ;
  179.72 +    pfree = 0 ;
  179.73 +    for (j = 0 ; j < n ; j++)
  179.74 +    {
  179.75 +        Pe [j] = pfree ;
  179.76 +        Sp [j] = pfree ;
  179.77 +        pfree += Len [j] ;
  179.78 +    }
  179.79 +
  179.80 +    /* Note that this restriction on iwlen is slightly more restrictive than
  179.81 +     * what is strictly required in AMD_2.  AMD_2 can operate with no elbow
  179.82 +     * room at all, but it will be very slow.  For better performance, at
  179.83 +     * least size-n elbow room is enforced. */
  179.84 +    ASSERT (iwlen >= pfree + n) ;
  179.85 +
  179.86 +#ifndef NDEBUG
  179.87 +    for (p = 0 ; p < iwlen ; p++) Iw [p] = EMPTY ;
  179.88 +#endif
  179.89 +
  179.90 +    for (k = 0 ; k < n ; k++)
  179.91 +    {
  179.92 +        AMD_DEBUG1 (("Construct row/column k= "ID" of A+A'\n", k))  ;
  179.93 +        p1 = Ap [k] ;
  179.94 +        p2 = Ap [k+1] ;
  179.95 +
  179.96 +        /* construct A+A' */
  179.97 +        for (p = p1 ; p < p2 ; )
  179.98 +        {
  179.99 +            /* scan the upper triangular part of A */
 179.100 +            j = Ai [p] ;
 179.101 +            ASSERT (j >= 0 && j < n) ;
 179.102 +            if (j < k)
 179.103 +            {
 179.104 +                /* entry A (j,k) in the strictly upper triangular part */
 179.105 +                ASSERT (Sp [j] < (j == n-1 ? pfree : Pe [j+1])) ;
 179.106 +                ASSERT (Sp [k] < (k == n-1 ? pfree : Pe [k+1])) ;
 179.107 +                Iw [Sp [j]++] = k ;
 179.108 +                Iw [Sp [k]++] = j ;
 179.109 +                p++ ;
 179.110 +            }
 179.111 +            else if (j == k)
 179.112 +            {
 179.113 +                /* skip the diagonal */
 179.114 +                p++ ;
 179.115 +                break ;
 179.116 +            }
 179.117 +            else /* j > k */
 179.118 +            {
 179.119 +                /* first entry below the diagonal */
 179.120 +                break ;
 179.121 +            }
 179.122 +            /* scan lower triangular part of A, in column j until reaching
 179.123 +             * row k.  Start where last scan left off. */
 179.124 +            ASSERT (Ap [j] <= Tp [j] && Tp [j] <= Ap [j+1]) ;
 179.125 +            pj2 = Ap [j+1] ;
 179.126 +            for (pj = Tp [j] ; pj < pj2 ; )
 179.127 +            {
 179.128 +                i = Ai [pj] ;
 179.129 +                ASSERT (i >= 0 && i < n) ;
 179.130 +                if (i < k)
 179.131 +                {
 179.132 +                    /* A (i,j) is only in the lower part, not in upper */
 179.133 +                    ASSERT (Sp [i] < (i == n-1 ? pfree : Pe [i+1])) ;
 179.134 +                    ASSERT (Sp [j] < (j == n-1 ? pfree : Pe [j+1])) ;
 179.135 +                    Iw [Sp [i]++] = j ;
 179.136 +                    Iw [Sp [j]++] = i ;
 179.137 +                    pj++ ;
 179.138 +                }
 179.139 +                else if (i == k)
 179.140 +                {
 179.141 +                    /* entry A (k,j) in lower part and A (j,k) in upper */
 179.142 +                    pj++ ;
 179.143 +                    break ;
 179.144 +                }
 179.145 +                else /* i > k */
 179.146 +                {
 179.147 +                    /* consider this entry later, when k advances to i */
 179.148 +                    break ;
 179.149 +                }
 179.150 +            }
 179.151 +            Tp [j] = pj ;
 179.152 +        }
 179.153 +        Tp [k] = p ;
 179.154 +    }
 179.155 +
 179.156 +    /* clean up, for remaining mismatched entries */
 179.157 +    for (j = 0 ; j < n ; j++)
 179.158 +    {
 179.159 +        for (pj = Tp [j] ; pj < Ap [j+1] ; pj++)
 179.160 +        {
 179.161 +            i = Ai [pj] ;
 179.162 +            ASSERT (i >= 0 && i < n) ;
 179.163 +            /* A (i,j) is only in the lower part, not in upper */
 179.164 +            ASSERT (Sp [i] < (i == n-1 ? pfree : Pe [i+1])) ;
 179.165 +            ASSERT (Sp [j] < (j == n-1 ? pfree : Pe [j+1])) ;
 179.166 +            Iw [Sp [i]++] = j ;
 179.167 +            Iw [Sp [j]++] = i ;
 179.168 +        }
 179.169 +    }
 179.170 +
 179.171 +#ifndef NDEBUG
 179.172 +    for (j = 0 ; j < n-1 ; j++) ASSERT (Sp [j] == Pe [j+1]) ;
 179.173 +    ASSERT (Sp [n-1] == pfree) ;
 179.174 +#endif
 179.175 +
 179.176 +    /* Tp and Sp no longer needed ] */
 179.177 +
 179.178 +    /* --------------------------------------------------------------------- */
 179.179 +    /* order the matrix */
 179.180 +    /* --------------------------------------------------------------------- */
 179.181 +
 179.182 +    AMD_2 (n, Pe, Iw, Len, iwlen, pfree,
 179.183 +        Nv, Pinv, P, Head, Elen, Degree, W, Control, Info) ;
 179.184 +}
   180.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
   180.2 +++ b/deps/glpk/src/amd/amd_2.c	Sun Nov 06 20:59:10 2011 +0100
   180.3 @@ -0,0 +1,1842 @@
   180.4 +/* ========================================================================= */
   180.5 +/* === AMD_2 =============================================================== */
   180.6 +/* ========================================================================= */
   180.7 +
   180.8 +/* ------------------------------------------------------------------------- */
   180.9 +/* AMD, Copyright (c) Timothy A. Davis,                                      */
  180.10 +/* Patrick R. Amestoy, and Iain S. Duff.  See ../README.txt for License.     */
  180.11 +/* email: davis at cise.ufl.edu    CISE Department, Univ. of Florida.        */
  180.12 +/* web: http://www.cise.ufl.edu/research/sparse/amd                          */
  180.13 +/* ------------------------------------------------------------------------- */
  180.14 +
  180.15 +/* AMD_2:  performs the AMD ordering on a symmetric sparse matrix A, followed
  180.16 + * by a postordering (via depth-first search) of the assembly tree using the
  180.17 + * AMD_postorder routine.
  180.18 + */
  180.19 +
  180.20 +#include "amd_internal.h"
  180.21 +
  180.22 +/* ========================================================================= */
  180.23 +/* === clear_flag ========================================================== */
  180.24 +/* ========================================================================= */
  180.25 +
  180.26 +static Int clear_flag (Int wflg, Int wbig, Int W [ ], Int n)
  180.27 +{
  180.28 +    Int x ;
  180.29 +    if (wflg < 2 || wflg >= wbig)
  180.30 +    {
  180.31 +        for (x = 0 ; x < n ; x++)
  180.32 +        {
  180.33 +            if (W [x] != 0) W [x] = 1 ;
  180.34 +        }
  180.35 +        wflg = 2 ;
  180.36 +    }
  180.37 +    /*  at this point, W [0..n-1] < wflg holds */
  180.38 +    return (wflg) ;
  180.39 +}
  180.40 +
  180.41 +
  180.42 +/* ========================================================================= */
  180.43 +/* === AMD_2 =============================================================== */
  180.44 +/* ========================================================================= */
  180.45 +
  180.46 +GLOBAL void AMD_2
  180.47 +(
  180.48 +    Int n,              /* A is n-by-n, where n > 0 */
  180.49 +    Int Pe [ ],         /* Pe [0..n-1]: index in Iw of row i on input */
  180.50 +    Int Iw [ ],         /* workspace of size iwlen. Iw [0..pfree-1]
  180.51 +                         * holds the matrix on input */
  180.52 +    Int Len [ ],        /* Len [0..n-1]: length for row/column i on input */
  180.53 +    Int iwlen,          /* length of Iw. iwlen >= pfree + n */
  180.54 +    Int pfree,          /* Iw [pfree ... iwlen-1] is empty on input */
  180.55 +
  180.56 +    /* 7 size-n workspaces, not defined on input: */
  180.57 +    Int Nv [ ],         /* the size of each supernode on output */
  180.58 +    Int Next [ ],       /* the output inverse permutation */
  180.59 +    Int Last [ ],       /* the output permutation */
  180.60 +    Int Head [ ],
  180.61 +    Int Elen [ ],       /* the size columns of L for each supernode */
  180.62 +    Int Degree [ ],
  180.63 +    Int W [ ],
  180.64 +
  180.65 +    /* control parameters and output statistics */
  180.66 +    double Control [ ], /* array of size AMD_CONTROL */
  180.67 +    double Info [ ]     /* array of size AMD_INFO */
  180.68 +)
  180.69 +{
  180.70 +
  180.71 +/*
  180.72 + * Given a representation of the nonzero pattern of a symmetric matrix, A,
  180.73 + * (excluding the diagonal) perform an approximate minimum (UMFPACK/MA38-style)
  180.74 + * degree ordering to compute a pivot order such that the introduction of
  180.75 + * nonzeros (fill-in) in the Cholesky factors A = LL' is kept low.  At each
  180.76 + * step, the pivot selected is the one with the minimum UMFAPACK/MA38-style
  180.77 + * upper-bound on the external degree.  This routine can optionally perform
  180.78 + * aggresive absorption (as done by MC47B in the Harwell Subroutine
  180.79 + * Library).
  180.80 + *
  180.81 + * The approximate degree algorithm implemented here is the symmetric analog of
  180.82 + * the degree update algorithm in MA38 and UMFPACK (the Unsymmetric-pattern
  180.83 + * MultiFrontal PACKage, both by Davis and Duff).  The routine is based on the
  180.84 + * MA27 minimum degree ordering algorithm by Iain Duff and John Reid.
  180.85 + *
  180.86 + * This routine is a translation of the original AMDBAR and MC47B routines,
  180.87 + * in Fortran, with the following modifications:
  180.88 + *
  180.89 + * (1) dense rows/columns are removed prior to ordering the matrix, and placed
  180.90 + *      last in the output order.  The presence of a dense row/column can
  180.91 + *      increase the ordering time by up to O(n^2), unless they are removed
  180.92 + *      prior to ordering.
  180.93 + *
  180.94 + * (2) the minimum degree ordering is followed by a postordering (depth-first
  180.95 + *      search) of the assembly tree.  Note that mass elimination (discussed
  180.96 + *      below) combined with the approximate degree update can lead to the mass
  180.97 + *      elimination of nodes with lower exact degree than the current pivot
  180.98 + *      element.  No additional fill-in is caused in the representation of the
  180.99 + *      Schur complement.  The mass-eliminated nodes merge with the current
 180.100 + *      pivot element.  They are ordered prior to the current pivot element.
 180.101 + *      Because they can have lower exact degree than the current element, the
 180.102 + *      merger of two or more of these nodes in the current pivot element can
 180.103 + *      lead to a single element that is not a "fundamental supernode".  The
 180.104 + *      diagonal block can have zeros in it.  Thus, the assembly tree used here
 180.105 + *      is not guaranteed to be the precise supernodal elemination tree (with
 180.106 + *      "funadmental" supernodes), and the postordering performed by this
 180.107 + *      routine is not guaranteed to be a precise postordering of the
 180.108 + *      elimination tree.
 180.109 + *
 180.110 + * (3) input parameters are added, to control aggressive absorption and the
 180.111 + *      detection of "dense" rows/columns of A.
 180.112 + *
 180.113 + * (4) additional statistical information is returned, such as the number of
 180.114 + *      nonzeros in L, and the flop counts for subsequent LDL' and LU
 180.115 + *      factorizations.  These are slight upper bounds, because of the mass
 180.116 + *      elimination issue discussed above.
 180.117 + *
 180.118 + * (5) additional routines are added to interface this routine to MATLAB
 180.119 + *      to provide a simple C-callable user-interface, to check inputs for
 180.120 + *      errors, compute the symmetry of the pattern of A and the number of
 180.121 + *      nonzeros in each row/column of A+A', to compute the pattern of A+A',
 180.122 + *      to perform the assembly tree postordering, and to provide debugging
 180.123 + *      ouput.  Many of these functions are also provided by the Fortran
 180.124 + *      Harwell Subroutine Library routine MC47A.
 180.125 + *
 180.126 + * (6) both int and UF_long versions are provided.  In the descriptions below
 180.127 + *      and integer is and int or UF_long depending on which version is
 180.128 + *      being used.
 180.129 +
 180.130 + **********************************************************************
 180.131 + ***** CAUTION:  ARGUMENTS ARE NOT CHECKED FOR ERRORS ON INPUT.  ******
 180.132 + **********************************************************************
 180.133 + ** If you want error checking, a more versatile input format, and a **
 180.134 + ** simpler user interface, use amd_order or amd_l_order instead.    **
 180.135 + ** This routine is not meant to be user-callable.                   **
 180.136 + **********************************************************************
 180.137 +
 180.138 + * ----------------------------------------------------------------------------
 180.139 + * References:
 180.140 + * ----------------------------------------------------------------------------
 180.141 + *
 180.142 + *  [1] Timothy A. Davis and Iain Duff, "An unsymmetric-pattern multifrontal
 180.143 + *      method for sparse LU factorization", SIAM J. Matrix Analysis and
 180.144 + *      Applications, vol. 18, no. 1, pp. 140-158.  Discusses UMFPACK / MA38,
 180.145 + *      which first introduced the approximate minimum degree used by this
 180.146 + *      routine.
 180.147 + *
 180.148 + *  [2] Patrick Amestoy, Timothy A. Davis, and Iain S. Duff, "An approximate
 180.149 + *      minimum degree ordering algorithm," SIAM J. Matrix Analysis and
 180.150 + *      Applications, vol. 17, no. 4, pp. 886-905, 1996.  Discusses AMDBAR and
 180.151 + *      MC47B, which are the Fortran versions of this routine.
 180.152 + *
 180.153 + *  [3] Alan George and Joseph Liu, "The evolution of the minimum degree
 180.154 + *      ordering algorithm," SIAM Review, vol. 31, no. 1, pp. 1-19, 1989.
 180.155 + *      We list below the features mentioned in that paper that this code
 180.156 + *      includes:
 180.157 + *
 180.158 + *      mass elimination:
 180.159 + *          Yes.  MA27 relied on supervariable detection for mass elimination.
 180.160 + *
 180.161 + *      indistinguishable nodes:
 180.162 + *          Yes (we call these "supervariables").  This was also in the MA27
 180.163 + *          code - although we modified the method of detecting them (the
 180.164 + *          previous hash was the true degree, which we no longer keep track
 180.165 + *          of).  A supervariable is a set of rows with identical nonzero
 180.166 + *          pattern.  All variables in a supervariable are eliminated together.
 180.167 + *          Each supervariable has as its numerical name that of one of its
 180.168 + *          variables (its principal variable).
 180.169 + *
 180.170 + *      quotient graph representation:
 180.171 + *          Yes.  We use the term "element" for the cliques formed during
 180.172 + *          elimination.  This was also in the MA27 code.  The algorithm can
 180.173 + *          operate in place, but it will work more efficiently if given some
 180.174 + *          "elbow room."
 180.175 + *
 180.176 + *      element absorption:
 180.177 + *          Yes.  This was also in the MA27 code.
 180.178 + *
 180.179 + *      external degree:
 180.180 + *          Yes.  The MA27 code was based on the true degree.
 180.181 + *
 180.182 + *      incomplete degree update and multiple elimination:
 180.183 + *          No.  This was not in MA27, either.  Our method of degree update
 180.184 + *          within MC47B is element-based, not variable-based.  It is thus
 180.185 + *          not well-suited for use with incomplete degree update or multiple
 180.186 + *          elimination.
 180.187 + *
 180.188 + * Authors, and Copyright (C) 2004 by:
 180.189 + * Timothy A. Davis, Patrick Amestoy, Iain S. Duff, John K. Reid.
 180.190 + *
 180.191 + * Acknowledgements: This work (and the UMFPACK package) was supported by the
 180.192 + * National Science Foundation (ASC-9111263, DMS-9223088, and CCR-0203270).
 180.193 + * The UMFPACK/MA38 approximate degree update algorithm, the unsymmetric analog
 180.194 + * which forms the basis of AMD, was developed while Tim Davis was supported by
 180.195 + * CERFACS (Toulouse, France) in a post-doctoral position.  This C version, and
 180.196 + * the etree postorder, were written while Tim Davis was on sabbatical at
 180.197 + * Stanford University and Lawrence Berkeley National Laboratory.
 180.198 +
 180.199 + * ----------------------------------------------------------------------------
 180.200 + * INPUT ARGUMENTS (unaltered):
 180.201 + * ----------------------------------------------------------------------------
 180.202 +
 180.203 + * n:  The matrix order.  Restriction:  n >= 1.
 180.204 + *
 180.205 + * iwlen:  The size of the Iw array.  On input, the matrix is stored in
 180.206 + *      Iw [0..pfree-1].  However, Iw [0..iwlen-1] should be slightly larger
 180.207 + *      than what is required to hold the matrix, at least iwlen >= pfree + n.
 180.208 + *      Otherwise, excessive compressions will take place.  The recommended
 180.209 + *      value of iwlen is 1.2 * pfree + n, which is the value used in the
 180.210 + *      user-callable interface to this routine (amd_order.c).  The algorithm
 180.211 + *      will not run at all if iwlen < pfree.  Restriction: iwlen >= pfree + n.
 180.212 + *      Note that this is slightly more restrictive than the actual minimum
 180.213 + *      (iwlen >= pfree), but AMD_2 will be very slow with no elbow room.
 180.214 + *      Thus, this routine enforces a bare minimum elbow room of size n.
 180.215 + *
 180.216 + * pfree: On input the tail end of the array, Iw [pfree..iwlen-1], is empty,
 180.217 + *      and the matrix is stored in Iw [0..pfree-1].  During execution,
 180.218 + *      additional data is placed in Iw, and pfree is modified so that
 180.219 + *      Iw [pfree..iwlen-1] is always the unused part of Iw.
 180.220 + *
 180.221 + * Control:  A double array of size AMD_CONTROL containing input parameters
 180.222 + *      that affect how the ordering is computed.  If NULL, then default
 180.223 + *      settings are used.
 180.224 + *
 180.225 + *      Control [AMD_DENSE] is used to determine whether or not a given input
 180.226 + *      row is "dense".  A row is "dense" if the number of entries in the row
 180.227 + *      exceeds Control [AMD_DENSE] times sqrt (n), except that rows with 16 or
 180.228 + *      fewer entries are never considered "dense".  To turn off the detection
 180.229 + *      of dense rows, set Control [AMD_DENSE] to a negative number, or to a
 180.230 + *      number larger than sqrt (n).  The default value of Control [AMD_DENSE]
 180.231 + *      is AMD_DEFAULT_DENSE, which is defined in amd.h as 10.
 180.232 + *
 180.233 + *      Control [AMD_AGGRESSIVE] is used to determine whether or not aggressive
 180.234 + *      absorption is to be performed.  If nonzero, then aggressive absorption
 180.235 + *      is performed (this is the default).
 180.236 +
 180.237 + * ----------------------------------------------------------------------------
 180.238 + * INPUT/OUPUT ARGUMENTS:
 180.239 + * ----------------------------------------------------------------------------
 180.240 + *
 180.241 + * Pe:  An integer array of size n.  On input, Pe [i] is the index in Iw of
 180.242 + *      the start of row i.  Pe [i] is ignored if row i has no off-diagonal
 180.243 + *      entries.  Thus Pe [i] must be in the range 0 to pfree-1 for non-empty
 180.244 + *      rows.
 180.245 + *
 180.246 + *      During execution, it is used for both supervariables and elements:
 180.247 + *
 180.248 + *      Principal supervariable i:  index into Iw of the description of
 180.249 + *          supervariable i.  A supervariable represents one or more rows of
 180.250 + *          the matrix with identical nonzero pattern.  In this case,
 180.251 + *          Pe [i] >= 0.
 180.252 + *
 180.253 + *      Non-principal supervariable i:  if i has been absorbed into another
 180.254 + *          supervariable j, then Pe [i] = FLIP (j), where FLIP (j) is defined
 180.255 + *          as (-(j)-2).  Row j has the same pattern as row i.  Note that j
 180.256 + *          might later be absorbed into another supervariable j2, in which
 180.257 + *          case Pe [i] is still FLIP (j), and Pe [j] = FLIP (j2) which is
 180.258 + *          < EMPTY, where EMPTY is defined as (-1) in amd_internal.h.
 180.259 + *
 180.260 + *      Unabsorbed element e:  the index into Iw of the description of element
 180.261 + *          e, if e has not yet been absorbed by a subsequent element.  Element
 180.262 + *          e is created when the supervariable of the same name is selected as
 180.263 + *          the pivot.  In this case, Pe [i] >= 0.
 180.264 + *
 180.265 + *      Absorbed element e:  if element e is absorbed into element e2, then
 180.266 + *          Pe [e] = FLIP (e2).  This occurs when the pattern of e (which we
 180.267 + *          refer to as Le) is found to be a subset of the pattern of e2 (that
 180.268 + *          is, Le2).  In this case, Pe [i] < EMPTY.  If element e is "null"
 180.269 + *          (it has no nonzeros outside its pivot block), then Pe [e] = EMPTY,
 180.270 + *          and e is the root of an assembly subtree (or the whole tree if
 180.271 + *          there is just one such root).
 180.272 + *
 180.273 + *      Dense variable i:  if i is "dense", then Pe [i] = EMPTY.
 180.274 + *
 180.275 + *      On output, Pe holds the assembly tree/forest, which implicitly
 180.276 + *      represents a pivot order with identical fill-in as the actual order
 180.277 + *      (via a depth-first search of the tree), as follows.  If Nv [i] > 0,
 180.278 + *      then i represents a node in the assembly tree, and the parent of i is
 180.279 + *      Pe [i], or EMPTY if i is a root.  If Nv [i] = 0, then (i, Pe [i])
 180.280 + *      represents an edge in a subtree, the root of which is a node in the
 180.281 + *      assembly tree.  Note that i refers to a row/column in the original
 180.282 + *      matrix, not the permuted matrix.
 180.283 + *
 180.284 + * Info:  A double array of size AMD_INFO.  If present, (that is, not NULL),
 180.285 + *      then statistics about the ordering are returned in the Info array.
 180.286 + *      See amd.h for a description.
 180.287 +
 180.288 + * ----------------------------------------------------------------------------
 180.289 + * INPUT/MODIFIED (undefined on output):
 180.290 + * ----------------------------------------------------------------------------
 180.291 + *
 180.292 + * Len:  An integer array of size n.  On input, Len [i] holds the number of
 180.293 + *      entries in row i of the matrix, excluding the diagonal.  The contents
 180.294 + *      of Len are undefined on output.
 180.295 + *
 180.296 + * Iw:  An integer array of size iwlen.  On input, Iw [0..pfree-1] holds the
 180.297 + *      description of each row i in the matrix.  The matrix must be symmetric,
 180.298 + *      and both upper and lower triangular parts must be present.  The
 180.299 + *      diagonal must not be present.  Row i is held as follows:
 180.300 + *
 180.301 + *          Len [i]:  the length of the row i data structure in the Iw array.
 180.302 + *          Iw [Pe [i] ... Pe [i] + Len [i] - 1]:
 180.303 + *              the list of column indices for nonzeros in row i (simple
 180.304 + *              supervariables), excluding the diagonal.  All supervariables
 180.305 + *              start with one row/column each (supervariable i is just row i).
 180.306 + *              If Len [i] is zero on input, then Pe [i] is ignored on input.
 180.307 + *
 180.308 + *          Note that the rows need not be in any particular order, and there
 180.309 + *          may be empty space between the rows.
 180.310 + *
 180.311 + *      During execution, the supervariable i experiences fill-in.  This is
 180.312 + *      represented by placing in i a list of the elements that cause fill-in
 180.313 + *      in supervariable i:
 180.314 + *
 180.315 + *          Len [i]:  the length of supervariable i in the Iw array.
 180.316 + *          Iw [Pe [i] ... Pe [i] + Elen [i] - 1]:
 180.317 + *              the list of elements that contain i.  This list is kept short
 180.318 + *              by removing absorbed elements.
 180.319 + *          Iw [Pe [i] + Elen [i] ... Pe [i] + Len [i] - 1]:
 180.320 + *              the list of supervariables in i.  This list is kept short by
 180.321 + *              removing nonprincipal variables, and any entry j that is also
 180.322 + *              contained in at least one of the elements (j in Le) in the list
 180.323 + *              for i (e in row i).
 180.324 + *
 180.325 + *      When supervariable i is selected as pivot, we create an element e of
 180.326 + *      the same name (e=i):
 180.327 + *
 180.328 + *          Len [e]:  the length of element e in the Iw array.
 180.329 + *          Iw [Pe [e] ... Pe [e] + Len [e] - 1]:
 180.330 + *              the list of supervariables in element e.
 180.331 + *
 180.332 + *      An element represents the fill-in that occurs when supervariable i is
 180.333 + *      selected as pivot (which represents the selection of row i and all
 180.334 + *      non-principal variables whose principal variable is i).  We use the
 180.335 + *      term Le to denote the set of all supervariables in element e.  Absorbed
 180.336 + *      supervariables and elements are pruned from these lists when
 180.337 + *      computationally convenient.
 180.338 + *
 180.339 + *  CAUTION:  THE INPUT MATRIX IS OVERWRITTEN DURING COMPUTATION.
 180.340 + *  The contents of Iw are undefined on output.
 180.341 +
 180.342 + * ----------------------------------------------------------------------------
 180.343 + * OUTPUT (need not be set on input):
 180.344 + * ----------------------------------------------------------------------------
 180.345 + *
 180.346 + * Nv:  An integer array of size n.  During execution, ABS (Nv [i]) is equal to
 180.347 + *      the number of rows that are represented by the principal supervariable
 180.348 + *      i.  If i is a nonprincipal or dense variable, then Nv [i] = 0.
 180.349 + *      Initially, Nv [i] = 1 for all i.  Nv [i] < 0 signifies that i is a
 180.350 + *      principal variable in the pattern Lme of the current pivot element me.
 180.351 + *      After element me is constructed, Nv [i] is set back to a positive
 180.352 + *      value.
 180.353 + *
 180.354 + *      On output, Nv [i] holds the number of pivots represented by super
 180.355 + *      row/column i of the original matrix, or Nv [i] = 0 for non-principal
 180.356 + *      rows/columns.  Note that i refers to a row/column in the original
 180.357 + *      matrix, not the permuted matrix.
 180.358 + *
 180.359 + * Elen:  An integer array of size n.  See the description of Iw above.  At the
 180.360 + *      start of execution, Elen [i] is set to zero for all rows i.  During
 180.361 + *      execution, Elen [i] is the number of elements in the list for
 180.362 + *      supervariable i.  When e becomes an element, Elen [e] = FLIP (esize) is
 180.363 + *      set, where esize is the size of the element (the number of pivots, plus
 180.364 + *      the number of nonpivotal entries).  Thus Elen [e] < EMPTY.
 180.365 + *      Elen (i) = EMPTY set when variable i becomes nonprincipal.
 180.366 + *
 180.367 + *      For variables, Elen (i) >= EMPTY holds until just before the
 180.368 + *      postordering and permutation vectors are computed.  For elements,
 180.369 + *      Elen [e] < EMPTY holds.
 180.370 + *
 180.371 + *      On output, Elen [i] is the degree of the row/column in the Cholesky
 180.372 + *      factorization of the permuted matrix, corresponding to the original row
 180.373 + *      i, if i is a super row/column.  It is equal to EMPTY if i is
 180.374 + *      non-principal.  Note that i refers to a row/column in the original
 180.375 + *      matrix, not the permuted matrix.
 180.376 + *
 180.377 + *      Note that the contents of Elen on output differ from the Fortran
 180.378 + *      version (Elen holds the inverse permutation in the Fortran version,
 180.379 + *      which is instead returned in the Next array in this C version,
 180.380 + *      described below).
 180.381 + *
 180.382 + * Last: In a degree list, Last [i] is the supervariable preceding i, or EMPTY
 180.383 + *      if i is the head of the list.  In a hash bucket, Last [i] is the hash
 180.384 + *      key for i.
 180.385 + *
 180.386 + *      Last [Head [hash]] is also used as the head of a hash bucket if
 180.387 + *      Head [hash] contains a degree list (see the description of Head,
 180.388 + *      below).
 180.389 + *
 180.390 + *      On output, Last [0..n-1] holds the permutation.  That is, if
 180.391 + *      i = Last [k], then row i is the kth pivot row (where k ranges from 0 to
 180.392 + *      n-1).  Row Last [k] of A is the kth row in the permuted matrix, PAP'.
 180.393 + *
 180.394 + * Next: Next [i] is the supervariable following i in a link list, or EMPTY if
 180.395 + *      i is the last in the list.  Used for two kinds of lists:  degree lists
 180.396 + *      and hash buckets (a supervariable can be in only one kind of list at a
 180.397 + *      time).
 180.398 + *
 180.399 + *      On output Next [0..n-1] holds the inverse permutation.  That is, if
 180.400 + *      k = Next [i], then row i is the kth pivot row. Row i of A appears as
 180.401 + *      the (Next[i])-th row in the permuted matrix, PAP'.
 180.402 + *
 180.403 + *      Note that the contents of Next on output differ from the Fortran
 180.404 + *      version (Next is undefined on output in the Fortran version).
 180.405 +
 180.406 + * ----------------------------------------------------------------------------
 180.407 + * LOCAL WORKSPACE (not input or output - used only during execution):
 180.408 + * ----------------------------------------------------------------------------
 180.409 + *
 180.410 + * Degree:  An integer array of size n.  If i is a supervariable, then
 180.411 + *      Degree [i] holds the current approximation of the external degree of
 180.412 + *      row i (an upper bound).  The external degree is the number of nonzeros
 180.413 + *      in row i, minus ABS (Nv [i]), the diagonal part.  The bound is equal to
 180.414 + *      the exact external degree if Elen [i] is less than or equal to two.
 180.415 + *
 180.416 + *      We also use the term "external degree" for elements e to refer to
 180.417 + *      |Le \ Lme|.  If e is an element, then Degree [e] is |Le|, which is the
 180.418 + *      degree of the off-diagonal part of the element e (not including the
 180.419 + *      diagonal part).
 180.420 + *
 180.421 + * Head:   An integer array of size n.  Head is used for degree lists.
 180.422 + *      Head [deg] is the first supervariable in a degree list.  All
 180.423 + *      supervariables i in a degree list Head [deg] have the same approximate
 180.424 + *      degree, namely, deg = Degree [i].  If the list Head [deg] is empty then
 180.425 + *      Head [deg] = EMPTY.
 180.426 + *
 180.427 + *      During supervariable detection Head [hash] also serves as a pointer to
 180.428 + *      a hash bucket.  If Head [hash] >= 0, there is a degree list of degree
 180.429 + *      hash.  The hash bucket head pointer is Last [Head [hash]].  If
 180.430 + *      Head [hash] = EMPTY, then the degree list and hash bucket are both
 180.431 + *      empty.  If Head [hash] < EMPTY, then the degree list is empty, and
 180.432 + *      FLIP (Head [hash]) is the head of the hash bucket.  After supervariable
 180.433 + *      detection is complete, all hash buckets are empty, and the
 180.434 + *      (Last [Head [hash]] = EMPTY) condition is restored for the non-empty
 180.435 + *      degree lists.
 180.436 + *
 180.437 + * W:  An integer array of size n.  The flag array W determines the status of
 180.438 + *      elements and variables, and the external degree of elements.
 180.439 + *
 180.440 + *      for elements:
 180.441 + *          if W [e] = 0, then the element e is absorbed.
 180.442 + *          if W [e] >= wflg, then W [e] - wflg is the size of the set
 180.443 + *              |Le \ Lme|, in terms of nonzeros (the sum of ABS (Nv [i]) for
 180.444 + *              each principal variable i that is both in the pattern of
 180.445 + *              element e and NOT in the pattern of the current pivot element,
 180.446 + *              me).
 180.447 + *          if wflg > W [e] > 0, then e is not absorbed and has not yet been
 180.448 + *              seen in the scan of the element lists in the computation of
 180.449 + *              |Le\Lme| in Scan 1 below.
 180.450 + *
 180.451 + *      for variables:
 180.452 + *          during supervariable detection, if W [j] != wflg then j is
 180.453 + *          not in the pattern of variable i.
 180.454 + *
 180.455 + *      The W array is initialized by setting W [i] = 1 for all i, and by
 180.456 + *      setting wflg = 2.  It is reinitialized if wflg becomes too large (to
 180.457 + *      ensure that wflg+n does not cause integer overflow).
 180.458 +
 180.459 + * ----------------------------------------------------------------------------
 180.460 + * LOCAL INTEGERS:
 180.461 + * ----------------------------------------------------------------------------
 180.462 + */
 180.463 +
 180.464 +    Int deg, degme, dext, lemax, e, elenme, eln, i, ilast, inext, j,
 180.465 +        jlast, jnext, k, knt1, knt2, knt3, lenj, ln, me, mindeg, nel, nleft,
 180.466 +        nvi, nvj, nvpiv, slenme, wbig, we, wflg, wnvi, ok, ndense, ncmpa,
 180.467 +        dense, aggressive ;
 180.468 +
 180.469 +    unsigned Int hash ;     /* unsigned, so that hash % n is well defined.*/
 180.470 +
 180.471 +/*
 180.472 + * deg:         the degree of a variable or element
 180.473 + * degme:       size, |Lme|, of the current element, me (= Degree [me])
 180.474 + * dext:        external degree, |Le \ Lme|, of some element e
 180.475 + * lemax:       largest |Le| seen so far (called dmax in Fortran version)
 180.476 + * e:           an element
 180.477 + * elenme:      the length, Elen [me], of element list of pivotal variable
 180.478 + * eln:         the length, Elen [...], of an element list
 180.479 + * hash:        the computed value of the hash function
 180.480 + * i:           a supervariable
 180.481 + * ilast:       the entry in a link list preceding i
 180.482 + * inext:       the entry in a link list following i
 180.483 + * j:           a supervariable
 180.484 + * jlast:       the entry in a link list preceding j
 180.485 + * jnext:       the entry in a link list, or path, following j
 180.486 + * k:           the pivot order of an element or variable
 180.487 + * knt1:        loop counter used during element construction
 180.488 + * knt2:        loop counter used during element construction
 180.489 + * knt3:        loop counter used during compression
 180.490 + * lenj:        Len [j]
 180.491 + * ln:          length of a supervariable list
 180.492 + * me:          current supervariable being eliminated, and the current
 180.493 + *                  element created by eliminating that supervariable
 180.494 + * mindeg:      current minimum degree
 180.495 + * nel:         number of pivots selected so far
 180.496 + * nleft:       n - nel, the number of nonpivotal rows/columns remaining
 180.497 + * nvi:         the number of variables in a supervariable i (= Nv [i])
 180.498 + * nvj:         the number of variables in a supervariable j (= Nv [j])
 180.499 + * nvpiv:       number of pivots in current element
 180.500 + * slenme:      number of variables in variable list of pivotal variable
 180.501 + * wbig:        = INT_MAX - n for the int version, UF_long_max - n for the
 180.502 + *                  UF_long version.  wflg is not allowed to be >= wbig.
 180.503 + * we:          W [e]
 180.504 + * wflg:        used for flagging the W array.  See description of Iw.
 180.505 + * wnvi:        wflg - Nv [i]
 180.506 + * x:           either a supervariable or an element
 180.507 + *
 180.508 + * ok:          true if supervariable j can be absorbed into i
 180.509 + * ndense:      number of "dense" rows/columns
 180.510 + * dense:       rows/columns with initial degree > dense are considered "dense"
 180.511 + * aggressive:  true if aggressive absorption is being performed
 180.512 + * ncmpa:       number of garbage collections
 180.513 +
 180.514 + * ----------------------------------------------------------------------------
 180.515 + * LOCAL DOUBLES, used for statistical output only (except for alpha):
 180.516 + * ----------------------------------------------------------------------------
 180.517 + */
 180.518 +
 180.519 +    double f, r, ndiv, s, nms_lu, nms_ldl, dmax, alpha, lnz, lnzme ;
 180.520 +
 180.521 +/*
 180.522 + * f:           nvpiv
 180.523 + * r:           degme + nvpiv
 180.524 + * ndiv:        number of divisions for LU or LDL' factorizations
 180.525 + * s:           number of multiply-subtract pairs for LU factorization, for the
 180.526 + *                  current element me
 180.527 + * nms_lu       number of multiply-subtract pairs for LU factorization
 180.528 + * nms_ldl      number of multiply-subtract pairs for LDL' factorization
 180.529 + * dmax:        the largest number of entries in any column of L, including the
 180.530 + *                  diagonal
 180.531 + * alpha:       "dense" degree ratio
 180.532 + * lnz:         the number of nonzeros in L (excluding the diagonal)
 180.533 + * lnzme:       the number of nonzeros in L (excl. the diagonal) for the
 180.534 + *                  current element me
 180.535 +
 180.536 + * ----------------------------------------------------------------------------
 180.537 + * LOCAL "POINTERS" (indices into the Iw array)
 180.538 + * ----------------------------------------------------------------------------
 180.539 +*/
 180.540 +
 180.541 +    Int p, p1, p2, p3, p4, pdst, pend, pj, pme, pme1, pme2, pn, psrc ;
 180.542 +
 180.543 +/*
 180.544 + * Any parameter (Pe [...] or pfree) or local variable starting with "p" (for
 180.545 + * Pointer) is an index into Iw, and all indices into Iw use variables starting
 180.546 + * with "p."  The only exception to this rule is the iwlen input argument.
 180.547 + *
 180.548 + * p:           pointer into lots of things
 180.549 + * p1:          Pe [i] for some variable i (start of element list)
 180.550 + * p2:          Pe [i] + Elen [i] -  1 for some variable i
 180.551 + * p3:          index of first supervariable in clean list
 180.552 + * p4:          
 180.553 + * pdst:        destination pointer, for compression
 180.554 + * pend:        end of memory to compress
 180.555 + * pj:          pointer into an element or variable
 180.556 + * pme:         pointer into the current element (pme1...pme2)
 180.557 + * pme1:        the current element, me, is stored in Iw [pme1...pme2]
 180.558 + * pme2:        the end of the current element
 180.559 + * pn:          pointer into a "clean" variable, also used to compress
 180.560 + * psrc:        source pointer, for compression
 180.561 +*/
 180.562 +
 180.563 +/* ========================================================================= */
 180.564 +/*  INITIALIZATIONS */
 180.565 +/* ========================================================================= */
 180.566 +
 180.567 +    /* Note that this restriction on iwlen is slightly more restrictive than
 180.568 +     * what is actually required in AMD_2.  AMD_2 can operate with no elbow
 180.569 +     * room at all, but it will be slow.  For better performance, at least
 180.570 +     * size-n elbow room is enforced. */
 180.571 +    ASSERT (iwlen >= pfree + n) ;
 180.572 +    ASSERT (n > 0) ;
 180.573 +
 180.574 +    /* initialize output statistics */
 180.575 +    lnz = 0 ;
 180.576 +    ndiv = 0 ;
 180.577 +    nms_lu = 0 ;
 180.578 +    nms_ldl = 0 ;
 180.579 +    dmax = 1 ;
 180.580 +    me = EMPTY ;
 180.581 +
 180.582 +    mindeg = 0 ;
 180.583 +    ncmpa = 0 ;
 180.584 +    nel = 0 ;
 180.585 +    lemax = 0 ;
 180.586 +
 180.587 +    /* get control parameters */
 180.588 +    if (Control != (double *) NULL)
 180.589 +    {
 180.590 +        alpha = Control [AMD_DENSE] ;
 180.591 +        aggressive = (Control [AMD_AGGRESSIVE] != 0) ;
 180.592 +    }
 180.593 +    else
 180.594 +    {
 180.595 +        alpha = AMD_DEFAULT_DENSE ;
 180.596 +        aggressive = AMD_DEFAULT_AGGRESSIVE ;
 180.597 +    }
 180.598 +    /* Note: if alpha is NaN, this is undefined: */
 180.599 +    if (alpha < 0)
 180.600 +    {
 180.601 +        /* only remove completely dense rows/columns */
 180.602 +        dense = n-2 ;
 180.603 +    }
 180.604 +    else
 180.605 +    {
 180.606 +        dense = alpha * sqrt ((double) n) ;
 180.607 +    }
 180.608 +    dense = MAX (16, dense) ;
 180.609 +    dense = MIN (n,  dense) ;
 180.610 +    AMD_DEBUG1 (("\n\nAMD (debug), alpha %g, aggr. "ID"\n",
 180.611 +        alpha, aggressive)) ;
 180.612 +
 180.613 +    for (i = 0 ; i < n ; i++)
 180.614 +    {
 180.615 +        Last [i] = EMPTY ;
 180.616 +        Head [i] = EMPTY ;
 180.617 +        Next [i] = EMPTY ;
 180.618 +        /* if separate Hhead array is used for hash buckets: *
 180.619 +        Hhead [i] = EMPTY ;
 180.620 +        */
 180.621 +        Nv [i] = 1 ;
 180.622 +        W [i] = 1 ;
 180.623 +        Elen [i] = 0 ;
 180.624 +        Degree [i] = Len [i] ;
 180.625 +    }
 180.626 +
 180.627 +#ifndef NDEBUG
 180.628 +    AMD_DEBUG1 (("\n======Nel "ID" initial\n", nel)) ;
 180.629 +    AMD_dump (n, Pe, Iw, Len, iwlen, pfree, Nv, Next, Last,
 180.630 +                Head, Elen, Degree, W, -1) ;
 180.631 +#endif
 180.632 +
 180.633 +    /* initialize wflg */
 180.634 +    wbig = Int_MAX - n ;
 180.635 +    wflg = clear_flag (0, wbig, W, n) ;
 180.636 +
 180.637 +    /* --------------------------------------------------------------------- */
 180.638 +    /* initialize degree lists and eliminate dense and empty rows */
 180.639 +    /* --------------------------------------------------------------------- */
 180.640 +
 180.641 +    ndense = 0 ;
 180.642 +
 180.643 +    for (i = 0 ; i < n ; i++)
 180.644 +    {
 180.645 +        deg = Degree [i] ;
 180.646 +        ASSERT (deg >= 0 && deg < n) ;
 180.647 +        if (deg == 0)
 180.648 +        {
 180.649 +
 180.650 +            /* -------------------------------------------------------------
 180.651 +             * we have a variable that can be eliminated at once because
 180.652 +             * there is no off-diagonal non-zero in its row.  Note that
 180.653 +             * Nv [i] = 1 for an empty variable i.  It is treated just
 180.654 +             * the same as an eliminated element i.
 180.655 +             * ------------------------------------------------------------- */
 180.656 +
 180.657 +            Elen [i] = FLIP (1) ;
 180.658 +            nel++ ;
 180.659 +            Pe [i] = EMPTY ;
 180.660 +            W [i] = 0 ;
 180.661 +
 180.662 +        }
 180.663 +        else if (deg > dense)
 180.664 +        {
 180.665 +
 180.666 +            /* -------------------------------------------------------------
 180.667 +             * Dense variables are not treated as elements, but as unordered,
 180.668 +             * non-principal variables that have no parent.  They do not take
 180.669 +             * part in the postorder, since Nv [i] = 0.  Note that the Fortran
 180.670 +             * version does not have this option.
 180.671 +             * ------------------------------------------------------------- */
 180.672 +
 180.673 +            AMD_DEBUG1 (("Dense node "ID" degree "ID"\n", i, deg)) ;
 180.674 +            ndense++ ;
 180.675 +            Nv [i] = 0 ;                /* do not postorder this node */
 180.676 +            Elen [i] = EMPTY ;
 180.677 +            nel++ ;
 180.678 +            Pe [i] = EMPTY ;
 180.679 +
 180.680 +        }
 180.681 +        else
 180.682 +        {
 180.683 +
 180.684 +            /* -------------------------------------------------------------
 180.685 +             * place i in the degree list corresponding to its degree
 180.686 +             * ------------------------------------------------------------- */
 180.687 +
 180.688 +            inext = Head [deg] ;
 180.689 +            ASSERT (inext >= EMPTY && inext < n) ;
 180.690 +            if (inext != EMPTY) Last [inext] = i ;
 180.691 +            Next [i] = inext ;
 180.692 +            Head [deg] = i ;
 180.693 +
 180.694 +        }
 180.695 +    }
 180.696 +
 180.697 +/* ========================================================================= */
 180.698 +/* WHILE (selecting pivots) DO */
 180.699 +/* ========================================================================= */
 180.700 +
 180.701 +    while (nel < n)
 180.702 +    {
 180.703 +
 180.704 +#ifndef NDEBUG
 180.705 +        AMD_DEBUG1 (("\n======Nel "ID"\n", nel)) ;
 180.706 +        if (AMD_debug >= 2)
 180.707 +        {
 180.708 +            AMD_dump (n, Pe, Iw, Len, iwlen, pfree, Nv, Next,
 180.709 +                    Last, Head, Elen, Degree, W, nel) ;
 180.710 +        }
 180.711 +#endif
 180.712 +
 180.713 +/* ========================================================================= */
 180.714 +/* GET PIVOT OF MINIMUM DEGREE */
 180.715 +/* ========================================================================= */
 180.716 +
 180.717 +        /* ----------------------------------------------------------------- */
 180.718 +        /* find next supervariable for elimination */
 180.719 +        /* ----------------------------------------------------------------- */
 180.720 +
 180.721 +        ASSERT (mindeg >= 0 && mindeg < n) ;
 180.722 +        for (deg = mindeg ; deg < n ; deg++)
 180.723 +        {
 180.724 +            me = Head [deg] ;
 180.725 +            if (me != EMPTY) break ;
 180.726 +        }
 180.727 +        mindeg = deg ;
 180.728 +        ASSERT (me >= 0 && me < n) ;
 180.729 +        AMD_DEBUG1 (("=================me: "ID"\n", me)) ;
 180.730 +
 180.731 +        /* ----------------------------------------------------------------- */
 180.732 +        /* remove chosen variable from link list */
 180.733 +        /* ----------------------------------------------------------------- */
 180.734 +
 180.735 +        inext = Next [me] ;
 180.736 +        ASSERT (inext >= EMPTY && inext < n) ;
 180.737 +        if (inext != EMPTY) Last [inext] = EMPTY ;
 180.738 +        Head [deg] = inext ;
 180.739 +
 180.740 +        /* ----------------------------------------------------------------- */
 180.741 +        /* me represents the elimination of pivots nel to nel+Nv[me]-1. */
 180.742 +        /* place me itself as the first in this set. */
 180.743 +        /* ----------------------------------------------------------------- */
 180.744 +
 180.745 +        elenme = Elen [me] ;
 180.746 +        nvpiv = Nv [me] ;
 180.747 +        ASSERT (nvpiv > 0) ;
 180.748 +        nel += nvpiv ;
 180.749 +
 180.750 +/* ========================================================================= */
 180.751 +/* CONSTRUCT NEW ELEMENT */
 180.752 +/* ========================================================================= */
 180.753 +
 180.754 +        /* -----------------------------------------------------------------
 180.755 +         * At this point, me is the pivotal supervariable.  It will be
 180.756 +         * converted into the current element.  Scan list of the pivotal
 180.757 +         * supervariable, me, setting tree pointers and constructing new list
 180.758 +         * of supervariables for the new element, me.  p is a pointer to the
 180.759 +         * current position in the old list.
 180.760 +         * ----------------------------------------------------------------- */
 180.761 +
 180.762 +        /* flag the variable "me" as being in Lme by negating Nv [me] */
 180.763 +        Nv [me] = -nvpiv ;
 180.764 +        degme = 0 ;
 180.765 +        ASSERT (Pe [me] >= 0 && Pe [me] < iwlen) ;
 180.766 +
 180.767 +        if (elenme == 0)
 180.768 +        {
 180.769 +
 180.770 +            /* ------------------------------------------------------------- */
 180.771 +            /* construct the new element in place */
 180.772 +            /* ------------------------------------------------------------- */
 180.773 +
 180.774 +            pme1 = Pe [me] ;
 180.775 +            pme2 = pme1 - 1 ;
 180.776 +
 180.777 +            for (p = pme1 ; p <= pme1 + Len [me] - 1 ; p++)
 180.778 +            {
 180.779 +                i = Iw [p] ;
 180.780 +                ASSERT (i >= 0 && i < n && Nv [i] >= 0) ;
 180.781 +                nvi = Nv [i] ;
 180.782 +                if (nvi > 0)
 180.783 +                {
 180.784 +
 180.785 +                    /* ----------------------------------------------------- */
 180.786 +                    /* i is a principal variable not yet placed in Lme. */
 180.787 +                    /* store i in new list */
 180.788 +                    /* ----------------------------------------------------- */
 180.789 +
 180.790 +                    /* flag i as being in Lme by negating Nv [i] */
 180.791 +                    degme += nvi ;
 180.792 +                    Nv [i] = -nvi ;
 180.793 +                    Iw [++pme2] = i ;
 180.794 +
 180.795 +                    /* ----------------------------------------------------- */
 180.796 +                    /* remove variable i from degree list. */
 180.797 +                    /* ----------------------------------------------------- */
 180.798 +
 180.799 +                    ilast = Last [i] ;
 180.800 +                    inext = Next [i] ;
 180.801 +                    ASSERT (ilast >= EMPTY && ilast < n) ;
 180.802 +                    ASSERT (inext >= EMPTY && inext < n) ;
 180.803 +                    if (inext != EMPTY) Last [inext] = ilast ;
 180.804 +                    if (ilast != EMPTY)
 180.805 +                    {
 180.806 +                        Next [ilast] = inext ;
 180.807 +                    }
 180.808 +                    else
 180.809 +                    {
 180.810 +                        /* i is at the head of the degree list */
 180.811 +                        ASSERT (Degree [i] >= 0 && Degree [i] < n) ;
 180.812 +                        Head [Degree [i]] = inext ;
 180.813 +                    }
 180.814 +                }
 180.815 +            }
 180.816 +        }
 180.817 +        else
 180.818 +        {
 180.819 +
 180.820 +            /* ------------------------------------------------------------- */
 180.821 +            /* construct the new element in empty space, Iw [pfree ...] */
 180.822 +            /* ------------------------------------------------------------- */
 180.823 +
 180.824 +            p = Pe [me] ;
 180.825 +            pme1 = pfree ;
 180.826 +            slenme = Len [me] - elenme ;
 180.827 +
 180.828 +            for (knt1 = 1 ; knt1 <= elenme + 1 ; knt1++)
 180.829 +            {
 180.830 +
 180.831 +                if (knt1 > elenme)
 180.832 +                {
 180.833 +                    /* search the supervariables in me. */
 180.834 +                    e = me ;
 180.835 +                    pj = p ;
 180.836 +                    ln = slenme ;
 180.837 +                    AMD_DEBUG2 (("Search sv: "ID" "ID" "ID"\n", me,pj,ln)) ;
 180.838 +                }
 180.839 +                else
 180.840 +                {
 180.841 +                    /* search the elements in me. */
 180.842 +                    e = Iw [p++] ;
 180.843 +                    ASSERT (e >= 0 && e < n) ;
 180.844 +                    pj = Pe [e] ;
 180.845 +                    ln = Len [e] ;
 180.846 +                    AMD_DEBUG2 (("Search element e "ID" in me "ID"\n", e,me)) ;
 180.847 +                    ASSERT (Elen [e] < EMPTY && W [e] > 0 && pj >= 0) ;
 180.848 +                }
 180.849 +                ASSERT (ln >= 0 && (ln == 0 || (pj >= 0 && pj < iwlen))) ;
 180.850 +
 180.851 +                /* ---------------------------------------------------------
 180.852 +                 * search for different supervariables and add them to the
 180.853 +                 * new list, compressing when necessary. this loop is
 180.854 +                 * executed once for each element in the list and once for
 180.855 +                 * all the supervariables in the list.
 180.856 +                 * --------------------------------------------------------- */
 180.857 +
 180.858 +                for (knt2 = 1 ; knt2 <= ln ; knt2++)
 180.859 +                {
 180.860 +                    i = Iw [pj++] ;
 180.861 +                    ASSERT (i >= 0 && i < n && (i == me || Elen [i] >= EMPTY));
 180.862 +                    nvi = Nv [i] ;
 180.863 +                    AMD_DEBUG2 ((": "ID" "ID" "ID" "ID"\n",
 180.864 +                                i, Elen [i], Nv [i], wflg)) ;
 180.865 +
 180.866 +                    if (nvi > 0)
 180.867 +                    {
 180.868 +
 180.869 +                        /* ------------------------------------------------- */
 180.870 +                        /* compress Iw, if necessary */
 180.871 +                        /* ------------------------------------------------- */
 180.872 +
 180.873 +                        if (pfree >= iwlen)
 180.874 +                        {
 180.875 +
 180.876 +                            AMD_DEBUG1 (("GARBAGE COLLECTION\n")) ;
 180.877 +
 180.878 +                            /* prepare for compressing Iw by adjusting pointers
 180.879 +                             * and lengths so that the lists being searched in
 180.880 +                             * the inner and outer loops contain only the
 180.881 +                             * remaining entries. */
 180.882 +
 180.883 +                            Pe [me] = p ;
 180.884 +                            Len [me] -= knt1 ;
 180.885 +                            /* check if nothing left of supervariable me */
 180.886 +                            if (Len [me] == 0) Pe [me] = EMPTY ;
 180.887 +                            Pe [e] = pj ;
 180.888 +                            Len [e] = ln - knt2 ;
 180.889 +                            /* nothing left of element e */
 180.890 +                            if (Len [e] == 0) Pe [e] = EMPTY ;
 180.891 +
 180.892 +                            ncmpa++ ;   /* one more garbage collection */
 180.893 +
 180.894 +                            /* store first entry of each object in Pe */
 180.895 +                            /* FLIP the first entry in each object */
 180.896 +                            for (j = 0 ; j < n ; j++)
 180.897 +                            {
 180.898 +                                pn = Pe [j] ;
 180.899 +                                if (pn >= 0)
 180.900 +                                {
 180.901 +                                    ASSERT (pn >= 0 && pn < iwlen) ;
 180.902 +                                    Pe [j] = Iw [pn] ;
 180.903 +                                    Iw [pn] = FLIP (j) ;
 180.904 +                                }
 180.905 +                            }
 180.906 +
 180.907 +                            /* psrc/pdst point to source/destination */
 180.908 +                            psrc = 0 ;
 180.909 +                            pdst = 0 ;
 180.910 +                            pend = pme1 - 1 ;
 180.911 +
 180.912 +                            while (psrc <= pend)
 180.913 +                            {
 180.914 +                                /* search for next FLIP'd entry */
 180.915 +                                j = FLIP (Iw [psrc++]) ;
 180.916 +                                if (j >= 0)
 180.917 +                                {
 180.918 +                                    AMD_DEBUG2 (("Got object j: "ID"\n", j)) ;
 180.919 +                                    Iw [pdst] = Pe [j] ;
 180.920 +                                    Pe [j] = pdst++ ;
 180.921 +                                    lenj = Len [j] ;
 180.922 +                                    /* copy from source to destination */
 180.923 +                                    for (knt3 = 0 ; knt3 <= lenj - 2 ; knt3++)
 180.924 +                                    {
 180.925 +                                        Iw [pdst++] = Iw [psrc++] ;
 180.926 +                                    }
 180.927 +                                }
 180.928 +                            }
 180.929 +
 180.930 +                            /* move the new partially-constructed element */
 180.931 +                            p1 = pdst ;
 180.932 +                            for (psrc = pme1 ; psrc <= pfree-1 ; psrc++)
 180.933 +                            {
 180.934 +                                Iw [pdst++] = Iw [psrc] ;
 180.935 +                            }
 180.936 +                            pme1 = p1 ;
 180.937 +                            pfree = pdst ;
 180.938 +                            pj = Pe [e] ;
 180.939 +                            p = Pe [me] ;
 180.940 +
 180.941 +                        }
 180.942 +
 180.943 +                        /* ------------------------------------------------- */
 180.944 +                        /* i is a principal variable not yet placed in Lme */
 180.945 +                        /* store i in new list */
 180.946 +                        /* ------------------------------------------------- */
 180.947 +
 180.948 +                        /* flag i as being in Lme by negating Nv [i] */
 180.949 +                        degme += nvi ;
 180.950 +                        Nv [i] = -nvi ;
 180.951 +                        Iw [pfree++] = i ;
 180.952 +                        AMD_DEBUG2 (("     s: "ID"     nv "ID"\n", i, Nv [i]));
 180.953 +
 180.954 +                        /* ------------------------------------------------- */
 180.955 +                        /* remove variable i from degree link list */
 180.956 +                        /* ------------------------------------------------- */
 180.957 +
 180.958 +                        ilast = Last [i] ;
 180.959 +                        inext = Next [i] ;
 180.960 +                        ASSERT (ilast >= EMPTY && ilast < n) ;
 180.961 +                        ASSERT (inext >= EMPTY && inext < n) ;
 180.962 +                        if (inext != EMPTY) Last [inext] = ilast ;
 180.963 +                        if (ilast != EMPTY)
 180.964 +                        {
 180.965 +                            Next [ilast] = inext ;
 180.966 +                        }
 180.967 +                        else
 180.968 +                        {
 180.969 +                            /* i is at the head of the degree list */
 180.970 +                            ASSERT (Degree [i] >= 0 && Degree [i] < n) ;
 180.971 +                            Head [Degree [i]] = inext ;
 180.972 +                        }
 180.973 +                    }
 180.974 +                }
 180.975 +
 180.976 +                if (e != me)
 180.977 +                {
 180.978 +                    /* set tree pointer and flag to indicate element e is
 180.979 +                     * absorbed into new element me (the parent of e is me) */
 180.980 +                    AMD_DEBUG1 ((" Element "ID" => "ID"\n", e, me)) ;
 180.981 +                    Pe [e] = FLIP (me) ;
 180.982 +                    W [e] = 0 ;
 180.983 +                }
 180.984 +            }
 180.985 +
 180.986 +            pme2 = pfree - 1 ;
 180.987 +        }
 180.988 +
 180.989 +        /* ----------------------------------------------------------------- */
 180.990 +        /* me has now been converted into an element in Iw [pme1..pme2] */
 180.991 +        /* ----------------------------------------------------------------- */
 180.992 +
 180.993 +        /* degme holds the external degree of new element */
 180.994 +        Degree [me] = degme ;
 180.995 +        Pe [me] = pme1 ;
 180.996 +        Len [me] = pme2 - pme1 + 1 ;
 180.997 +        ASSERT (Pe [me] >= 0 && Pe [me] < iwlen) ;
 180.998 +
 180.999 +        Elen [me] = FLIP (nvpiv + degme) ;
180.1000 +        /* FLIP (Elen (me)) is now the degree of pivot (including
180.1001 +         * diagonal part). */
180.1002 +
180.1003 +#ifndef NDEBUG
180.1004 +        AMD_DEBUG2 (("New element structure: length= "ID"\n", pme2-pme1+1)) ;
180.1005 +        for (pme = pme1 ; pme <= pme2 ; pme++) AMD_DEBUG3 ((" "ID"", Iw[pme]));
180.1006 +        AMD_DEBUG3 (("\n")) ;
180.1007 +#endif
180.1008 +
180.1009 +        /* ----------------------------------------------------------------- */
180.1010 +        /* make sure that wflg is not too large. */
180.1011 +        /* ----------------------------------------------------------------- */
180.1012 +
180.1013 +        /* With the current value of wflg, wflg+n must not cause integer
180.1014 +         * overflow */
180.1015 +
180.1016 +        wflg = clear_flag (wflg, wbig, W, n) ;
180.1017 +
180.1018 +/* ========================================================================= */
180.1019 +/* COMPUTE (W [e] - wflg) = |Le\Lme| FOR ALL ELEMENTS */
180.1020 +/* ========================================================================= */
180.1021 +
180.1022 +        /* -----------------------------------------------------------------
180.1023 +         * Scan 1:  compute the external degrees of previous elements with
180.1024 +         * respect to the current element.  That is:
180.1025 +         *       (W [e] - wflg) = |Le \ Lme|
180.1026 +         * for each element e that appears in any supervariable in Lme.  The
180.1027 +         * notation Le refers to the pattern (list of supervariables) of a
180.1028 +         * previous element e, where e is not yet absorbed, stored in
180.1029 +         * Iw [Pe [e] + 1 ... Pe [e] + Len [e]].  The notation Lme
180.1030 +         * refers to the pattern of the current element (stored in
180.1031 +         * Iw [pme1..pme2]).   If aggressive absorption is enabled, and
180.1032 +         * (W [e] - wflg) becomes zero, then the element e will be absorbed
180.1033 +         * in Scan 2.
180.1034 +         * ----------------------------------------------------------------- */
180.1035 +
180.1036 +        AMD_DEBUG2 (("me: ")) ;
180.1037 +        for (pme = pme1 ; pme <= pme2 ; pme++)
180.1038 +        {
180.1039 +            i = Iw [pme] ;
180.1040 +            ASSERT (i >= 0 && i < n) ;
180.1041 +            eln = Elen [i] ;
180.1042 +            AMD_DEBUG3 ((""ID" Elen "ID": \n", i, eln)) ;
180.1043 +            if (eln > 0)
180.1044 +            {
180.1045 +                /* note that Nv [i] has been negated to denote i in Lme: */
180.1046 +                nvi = -Nv [i] ;
180.1047 +                ASSERT (nvi > 0 && Pe [i] >= 0 && Pe [i] < iwlen) ;
180.1048 +                wnvi = wflg - nvi ;
180.1049 +                for (p = Pe [i] ; p <= Pe [i] + eln - 1 ; p++)
180.1050 +                {
180.1051 +                    e = Iw [p] ;
180.1052 +                    ASSERT (e >= 0 && e < n) ;
180.1053 +                    we = W [e] ;
180.1054 +                    AMD_DEBUG4 (("    e "ID" we "ID" ", e, we)) ;
180.1055 +                    if (we >= wflg)
180.1056 +                    {
180.1057 +                        /* unabsorbed element e has been seen in this loop */
180.1058 +                        AMD_DEBUG4 (("    unabsorbed, first time seen")) ;
180.1059 +                        we -= nvi ;
180.1060 +                    }
180.1061 +                    else if (we != 0)
180.1062 +                    {
180.1063 +                        /* e is an unabsorbed element */
180.1064 +                        /* this is the first we have seen e in all of Scan 1 */
180.1065 +                        AMD_DEBUG4 (("    unabsorbed")) ;
180.1066 +                        we = Degree [e] + wnvi ;
180.1067 +                    }
180.1068 +                    AMD_DEBUG4 (("\n")) ;
180.1069 +                    W [e] = we ;
180.1070 +                }
180.1071 +            }
180.1072 +        }
180.1073 +        AMD_DEBUG2 (("\n")) ;
180.1074 +
180.1075 +/* ========================================================================= */
180.1076 +/* DEGREE UPDATE AND ELEMENT ABSORPTION */
180.1077 +/* ========================================================================= */
180.1078 +
180.1079 +        /* -----------------------------------------------------------------
180.1080 +         * Scan 2:  for each i in Lme, sum up the degree of Lme (which is
180.1081 +         * degme), plus the sum of the external degrees of each Le for the
180.1082 +         * elements e appearing within i, plus the supervariables in i.
180.1083 +         * Place i in hash list.
180.1084 +         * ----------------------------------------------------------------- */
180.1085 +
180.1086 +        for (pme = pme1 ; pme <= pme2 ; pme++)
180.1087 +        {
180.1088 +            i = Iw [pme] ;
180.1089 +            ASSERT (i >= 0 && i < n && Nv [i] < 0 && Elen [i] >= 0) ;
180.1090 +            AMD_DEBUG2 (("Updating: i "ID" "ID" "ID"\n", i, Elen[i], Len [i]));
180.1091 +            p1 = Pe [i] ;
180.1092 +            p2 = p1 + Elen [i] - 1 ;
180.1093 +            pn = p1 ;
180.1094 +            hash = 0 ;
180.1095 +            deg = 0 ;
180.1096 +            ASSERT (p1 >= 0 && p1 < iwlen && p2 >= -1 && p2 < iwlen) ;
180.1097 +
180.1098 +            /* ------------------------------------------------------------- */
180.1099 +            /* scan the element list associated with supervariable i */
180.1100 +            /* ------------------------------------------------------------- */
180.1101 +
180.1102 +            /* UMFPACK/MA38-style approximate degree: */
180.1103 +            if (aggressive)
180.1104 +            {
180.1105 +                for (p = p1 ; p <= p2 ; p++)
180.1106 +                {
180.1107 +                    e = Iw [p] ;
180.1108 +                    ASSERT (e >= 0 && e < n) ;
180.1109 +                    we = W [e] ;
180.1110 +                    if (we != 0)
180.1111 +                    {
180.1112 +                        /* e is an unabsorbed element */
180.1113 +                        /* dext = | Le \ Lme | */
180.1114 +                        dext = we - wflg ;
180.1115 +                        if (dext > 0)
180.1116 +                        {
180.1117 +                            deg += dext ;
180.1118 +                            Iw [pn++] = e ;
180.1119 +                            hash += e ;
180.1120 +                            AMD_DEBUG4 ((" e: "ID" hash = "ID"\n",e,hash)) ;
180.1121 +                        }
180.1122 +                        else
180.1123 +                        {
180.1124 +                            /* external degree of e is zero, absorb e into me*/
180.1125 +                            AMD_DEBUG1 ((" Element "ID" =>"ID" (aggressive)\n",
180.1126 +                                e, me)) ;
180.1127 +                            ASSERT (dext == 0) ;
180.1128 +                            Pe [e] = FLIP (me) ;
180.1129 +                            W [e] = 0 ;
180.1130 +                        }
180.1131 +                    }
180.1132 +                }
180.1133 +            }
180.1134 +            else
180.1135 +            {
180.1136 +                for (p = p1 ; p <= p2 ; p++)
180.1137 +                {
180.1138 +                    e = Iw [p] ;
180.1139 +                    ASSERT (e >= 0 && e < n) ;
180.1140 +                    we = W [e] ;
180.1141 +                    if (we != 0)
180.1142 +                    {
180.1143 +                        /* e is an unabsorbed element */
180.1144 +                        dext = we - wflg ;
180.1145 +                        ASSERT (dext >= 0) ;
180.1146 +                        deg += dext ;
180.1147 +                        Iw [pn++] = e ;
180.1148 +                        hash += e ;
180.1149 +                        AMD_DEBUG4 (("  e: "ID" hash = "ID"\n",e,hash)) ;
180.1150 +                    }
180.1151 +                }
180.1152 +            }
180.1153 +
180.1154 +            /* count the number of elements in i (including me): */
180.1155 +            Elen [i] = pn - p1 + 1 ;
180.1156 +
180.1157 +            /* ------------------------------------------------------------- */
180.1158 +            /* scan the supervariables in the list associated with i */
180.1159 +            /* ------------------------------------------------------------- */
180.1160 +
180.1161 +            /* The bulk of the AMD run time is typically spent in this loop,
180.1162 +             * particularly if the matrix has many dense rows that are not
180.1163 +             * removed prior to ordering. */
180.1164 +            p3 = pn ;
180.1165 +            p4 = p1 + Len [i] ;
180.1166 +            for (p = p2 + 1 ; p < p4 ; p++)
180.1167 +            {
180.1168 +                j = Iw [p] ;
180.1169 +                ASSERT (j >= 0 && j < n) ;
180.1170 +                nvj = Nv [j] ;
180.1171 +                if (nvj > 0)
180.1172 +                {
180.1173 +                    /* j is unabsorbed, and not in Lme. */
180.1174 +                    /* add to degree and add to new list */
180.1175 +                    deg += nvj ;
180.1176 +                    Iw [pn++] = j ;
180.1177 +                    hash += j ;
180.1178 +                    AMD_DEBUG4 (("  s: "ID" hash "ID" Nv[j]= "ID"\n",
180.1179 +                                j, hash, nvj)) ;
180.1180 +                }
180.1181 +            }
180.1182 +
180.1183 +            /* ------------------------------------------------------------- */
180.1184 +            /* update the degree and check for mass elimination */
180.1185 +            /* ------------------------------------------------------------- */
180.1186 +
180.1187 +            /* with aggressive absorption, deg==0 is identical to the
180.1188 +             * Elen [i] == 1 && p3 == pn test, below. */
180.1189 +            ASSERT (IMPLIES (aggressive, (deg==0) == (Elen[i]==1 && p3==pn))) ;
180.1190 +
180.1191 +            if (Elen [i] == 1 && p3 == pn)
180.1192 +            {
180.1193 +
180.1194 +                /* --------------------------------------------------------- */
180.1195 +                /* mass elimination */
180.1196 +                /* --------------------------------------------------------- */
180.1197 +
180.1198 +                /* There is nothing left of this node except for an edge to
180.1199 +                 * the current pivot element.  Elen [i] is 1, and there are
180.1200 +                 * no variables adjacent to node i.  Absorb i into the
180.1201 +                 * current pivot element, me.  Note that if there are two or
180.1202 +                 * more mass eliminations, fillin due to mass elimination is
180.1203 +                 * possible within the nvpiv-by-nvpiv pivot block.  It is this
180.1204 +                 * step that causes AMD's analysis to be an upper bound.
180.1205 +                 *
180.1206 +                 * The reason is that the selected pivot has a lower
180.1207 +                 * approximate degree than the true degree of the two mass
180.1208 +                 * eliminated nodes.  There is no edge between the two mass
180.1209 +                 * eliminated nodes.  They are merged with the current pivot
180.1210 +                 * anyway.
180.1211 +                 *
180.1212 +                 * No fillin occurs in the Schur complement, in any case,
180.1213 +                 * and this effect does not decrease the quality of the
180.1214 +                 * ordering itself, just the quality of the nonzero and
180.1215 +                 * flop count analysis.  It also means that the post-ordering
180.1216 +                 * is not an exact elimination tree post-ordering. */
180.1217 +
180.1218 +                AMD_DEBUG1 (("  MASS i "ID" => parent e "ID"\n", i, me)) ;
180.1219 +                Pe [i] = FLIP (me) ;
180.1220 +                nvi = -Nv [i] ;
180.1221 +                degme -= nvi ;
180.1222 +                nvpiv += nvi ;
180.1223 +                nel += nvi ;
180.1224 +                Nv [i] = 0 ;
180.1225 +                Elen [i] = EMPTY ;
180.1226 +
180.1227 +            }
180.1228 +            else
180.1229 +            {
180.1230 +
180.1231 +                /* --------------------------------------------------------- */
180.1232 +                /* update the upper-bound degree of i */
180.1233 +                /* --------------------------------------------------------- */
180.1234 +
180.1235 +                /* the following degree does not yet include the size
180.1236 +                 * of the current element, which is added later: */
180.1237 +
180.1238 +                Degree [i] = MIN (Degree [i], deg) ;
180.1239 +
180.1240 +                /* --------------------------------------------------------- */
180.1241 +                /* add me to the list for i */
180.1242 +                /* --------------------------------------------------------- */
180.1243 +
180.1244 +                /* move first supervariable to end of list */
180.1245 +                Iw [pn] = Iw [p3] ;
180.1246 +                /* move first element to end of element part of list */
180.1247 +                Iw [p3] = Iw [p1] ;
180.1248 +                /* add new element, me, to front of list. */
180.1249 +                Iw [p1] = me ;
180.1250 +                /* store the new length of the list in Len [i] */
180.1251 +                Len [i] = pn - p1 + 1 ;
180.1252 +
180.1253 +                /* --------------------------------------------------------- */
180.1254 +                /* place in hash bucket.  Save hash key of i in Last [i]. */
180.1255 +                /* --------------------------------------------------------- */
180.1256 +
180.1257 +                /* NOTE: this can fail if hash is negative, because the ANSI C
180.1258 +                 * standard does not define a % b when a and/or b are negative.
180.1259 +                 * That's why hash is defined as an unsigned Int, to avoid this
180.1260 +                 * problem. */
180.1261 +                hash = hash % n ;
180.1262 +                ASSERT (((Int) hash) >= 0 && ((Int) hash) < n) ;
180.1263 +
180.1264 +                /* if the Hhead array is not used: */
180.1265 +                j = Head [hash] ;
180.1266 +                if (j <= EMPTY)
180.1267 +                {
180.1268 +                    /* degree list is empty, hash head is FLIP (j) */
180.1269 +                    Next [i] = FLIP (j) ;
180.1270 +                    Head [hash] = FLIP (i) ;
180.1271 +                }
180.1272 +                else
180.1273 +                {
180.1274 +                    /* degree list is not empty, use Last [Head [hash]] as
180.1275 +                     * hash head. */
180.1276 +                    Next [i] = Last [j] ;
180.1277 +                    Last [j] = i ;
180.1278 +                }
180.1279 +
180.1280 +                /* if a separate Hhead array is used: *
180.1281 +                Next [i] = Hhead [hash] ;
180.1282 +                Hhead [hash] = i ;
180.1283 +                */
180.1284 +
180.1285 +                Last [i] = hash ;
180.1286 +            }
180.1287 +        }
180.1288 +
180.1289 +        Degree [me] = degme ;
180.1290 +
180.1291 +        /* ----------------------------------------------------------------- */
180.1292 +        /* Clear the counter array, W [...], by incrementing wflg. */
180.1293 +        /* ----------------------------------------------------------------- */
180.1294 +
180.1295 +        /* make sure that wflg+n does not cause integer overflow */
180.1296 +        lemax =  MAX (lemax, degme) ;
180.1297 +        wflg += lemax ;
180.1298 +        wflg = clear_flag (wflg, wbig, W, n) ;
180.1299 +        /*  at this point, W [0..n-1] < wflg holds */
180.1300 +
180.1301 +/* ========================================================================= */
180.1302 +/* SUPERVARIABLE DETECTION */
180.1303 +/* ========================================================================= */
180.1304 +
180.1305 +        AMD_DEBUG1 (("Detecting supervariables:\n")) ;
180.1306 +        for (pme = pme1 ; pme <= pme2 ; pme++)
180.1307 +        {
180.1308 +            i = Iw [pme] ;
180.1309 +            ASSERT (i >= 0 && i < n) ;
180.1310 +            AMD_DEBUG2 (("Consider i "ID" nv "ID"\n", i, Nv [i])) ;
180.1311 +            if (Nv [i] < 0)
180.1312 +            {
180.1313 +                /* i is a principal variable in Lme */
180.1314 +
180.1315 +                /* ---------------------------------------------------------
180.1316 +                 * examine all hash buckets with 2 or more variables.  We do
180.1317 +                 * this by examing all unique hash keys for supervariables in
180.1318 +                 * the pattern Lme of the current element, me
180.1319 +                 * --------------------------------------------------------- */
180.1320 +
180.1321 +                /* let i = head of hash bucket, and empty the hash bucket */
180.1322 +                ASSERT (Last [i] >= 0 && Last [i] < n) ;
180.1323 +                hash = Last [i] ;
180.1324 +
180.1325 +                /* if Hhead array is not used: */
180.1326 +                j = Head [hash] ;
180.1327 +                if (j == EMPTY)
180.1328 +                {
180.1329 +                    /* hash bucket and degree list are both empty */
180.1330 +                    i = EMPTY ;
180.1331 +                }
180.1332 +                else if (j < EMPTY)
180.1333 +                {
180.1334 +                    /* degree list is empty */
180.1335 +                    i = FLIP (j) ;
180.1336 +                    Head [hash] = EMPTY ;
180.1337 +                }
180.1338 +                else
180.1339 +                {
180.1340 +                    /* degree list is not empty, restore Last [j] of head j */
180.1341 +                    i = Last [j] ;
180.1342 +                    Last [j] = EMPTY ;
180.1343 +                }
180.1344 +
180.1345 +                /* if separate Hhead array is used: *
180.1346 +                i = Hhead [hash] ;
180.1347 +                Hhead [hash] = EMPTY ;
180.1348 +                */
180.1349 +
180.1350 +                ASSERT (i >= EMPTY && i < n) ;
180.1351 +                AMD_DEBUG2 (("----i "ID" hash "ID"\n", i, hash)) ;
180.1352 +
180.1353 +                while (i != EMPTY && Next [i] != EMPTY)
180.1354 +                {
180.1355 +
180.1356 +                    /* -----------------------------------------------------
180.1357 +                     * this bucket has one or more variables following i.
180.1358 +                     * scan all of them to see if i can absorb any entries
180.1359 +                     * that follow i in hash bucket.  Scatter i into w.
180.1360 +                     * ----------------------------------------------------- */
180.1361 +
180.1362 +                    ln = Len [i] ;
180.1363 +                    eln = Elen [i] ;
180.1364 +                    ASSERT (ln >= 0 && eln >= 0) ;
180.1365 +                    ASSERT (Pe [i] >= 0 && Pe [i] < iwlen) ;
180.1366 +                    /* do not flag the first element in the list (me) */
180.1367 +                    for (p = Pe [i] + 1 ; p <= Pe [i] + ln - 1 ; p++)
180.1368 +                    {
180.1369 +                        ASSERT (Iw [p] >= 0 && Iw [p] < n) ;
180.1370 +                        W [Iw [p]] = wflg ;
180.1371 +                    }
180.1372 +
180.1373 +                    /* ----------------------------------------------------- */
180.1374 +                    /* scan every other entry j following i in bucket */
180.1375 +                    /* ----------------------------------------------------- */
180.1376 +
180.1377 +                    jlast = i ;
180.1378 +                    j = Next [i] ;
180.1379 +                    ASSERT (j >= EMPTY && j < n) ;
180.1380 +
180.1381 +                    while (j != EMPTY)
180.1382 +                    {
180.1383 +                        /* ------------------------------------------------- */
180.1384 +                        /* check if j and i have identical nonzero pattern */
180.1385 +                        /* ------------------------------------------------- */
180.1386 +
180.1387 +                        AMD_DEBUG3 (("compare i "ID" and j "ID"\n", i,j)) ;
180.1388 +
180.1389 +                        /* check if i and j have the same Len and Elen */
180.1390 +                        ASSERT (Len [j] >= 0 && Elen [j] >= 0) ;
180.1391 +                        ASSERT (Pe [j] >= 0 && Pe [j] < iwlen) ;
180.1392 +                        ok = (Len [j] == ln) && (Elen [j] == eln) ;
180.1393 +                        /* skip the first element in the list (me) */
180.1394 +                        for (p = Pe [j] + 1 ; ok && p <= Pe [j] + ln - 1 ; p++)
180.1395 +                        {
180.1396 +                            ASSERT (Iw [p] >= 0 && Iw [p] < n) ;
180.1397 +                            if (W [Iw [p]] != wflg) ok = 0 ;
180.1398 +                        }
180.1399 +                        if (ok)
180.1400 +                        {
180.1401 +                            /* --------------------------------------------- */
180.1402 +                            /* found it!  j can be absorbed into i */
180.1403 +                            /* --------------------------------------------- */
180.1404 +
180.1405 +                            AMD_DEBUG1 (("found it! j "ID" => i "ID"\n", j,i));
180.1406 +                            Pe [j] = FLIP (i) ;
180.1407 +                            /* both Nv [i] and Nv [j] are negated since they */
180.1408 +                            /* are in Lme, and the absolute values of each */
180.1409 +                            /* are the number of variables in i and j: */
180.1410 +                            Nv [i] += Nv [j] ;
180.1411 +                            Nv [j] = 0 ;
180.1412 +                            Elen [j] = EMPTY ;
180.1413 +                            /* delete j from hash bucket */
180.1414 +                            ASSERT (j != Next [j]) ;
180.1415 +                            j = Next [j] ;
180.1416 +                            Next [jlast] = j ;
180.1417 +
180.1418 +                        }
180.1419 +                        else
180.1420 +                        {
180.1421 +                            /* j cannot be absorbed into i */
180.1422 +                            jlast = j ;
180.1423 +                            ASSERT (j != Next [j]) ;
180.1424 +                            j = Next [j] ;
180.1425 +                        }
180.1426 +                        ASSERT (j >= EMPTY && j < n) ;
180.1427 +                    }
180.1428 +
180.1429 +                    /* -----------------------------------------------------
180.1430 +                     * no more variables can be absorbed into i
180.1431 +                     * go to next i in bucket and clear flag array
180.1432 +                     * ----------------------------------------------------- */
180.1433 +
180.1434 +                    wflg++ ;
180.1435 +                    i = Next [i] ;
180.1436 +                    ASSERT (i >= EMPTY && i < n) ;
180.1437 +
180.1438 +                }
180.1439 +            }
180.1440 +        }
180.1441 +        AMD_DEBUG2 (("detect done\n")) ;
180.1442 +
180.1443 +/* ========================================================================= */
180.1444 +/* RESTORE DEGREE LISTS AND REMOVE NONPRINCIPAL SUPERVARIABLES FROM ELEMENT */
180.1445 +/* ========================================================================= */
180.1446 +
180.1447 +        p = pme1 ;
180.1448 +        nleft = n - nel ;
180.1449 +        for (pme = pme1 ; pme <= pme2 ; pme++)
180.1450 +        {
180.1451 +            i = Iw [pme] ;
180.1452 +            ASSERT (i >= 0 && i < n) ;
180.1453 +            nvi = -Nv [i] ;
180.1454 +            AMD_DEBUG3 (("Restore i "ID" "ID"\n", i, nvi)) ;
180.1455 +            if (nvi > 0)
180.1456 +            {
180.1457 +                /* i is a principal variable in Lme */
180.1458 +                /* restore Nv [i] to signify that i is principal */
180.1459 +                Nv [i] = nvi ;
180.1460 +
180.1461 +                /* --------------------------------------------------------- */
180.1462 +                /* compute the external degree (add size of current element) */
180.1463 +                /* --------------------------------------------------------- */
180.1464 +
180.1465 +                deg = Degree [i] + degme - nvi ;
180.1466 +                deg = MIN (deg, nleft - nvi) ;
180.1467 +                ASSERT (IMPLIES (aggressive, deg > 0) && deg >= 0 && deg < n) ;
180.1468 +
180.1469 +                /* --------------------------------------------------------- */
180.1470 +                /* place the supervariable at the head of the degree list */
180.1471 +                /* --------------------------------------------------------- */
180.1472 +
180.1473 +                inext = Head [deg] ;
180.1474 +                ASSERT (inext >= EMPTY && inext < n) ;
180.1475 +                if (inext != EMPTY) Last [inext] = i ;
180.1476 +                Next [i] = inext ;
180.1477 +                Last [i] = EMPTY ;
180.1478 +                Head [deg] = i ;
180.1479 +
180.1480 +                /* --------------------------------------------------------- */
180.1481 +                /* save the new degree, and find the minimum degree */
180.1482 +                /* --------------------------------------------------------- */
180.1483 +
180.1484 +                mindeg = MIN (mindeg, deg) ;
180.1485 +                Degree [i] = deg ;
180.1486 +
180.1487 +                /* --------------------------------------------------------- */
180.1488 +                /* place the supervariable in the element pattern */
180.1489 +                /* --------------------------------------------------------- */
180.1490 +
180.1491 +                Iw [p++] = i ;
180.1492 +
180.1493 +            }
180.1494 +        }
180.1495 +        AMD_DEBUG2 (("restore done\n")) ;
180.1496 +
180.1497 +/* ========================================================================= */
180.1498 +/* FINALIZE THE NEW ELEMENT */
180.1499 +/* ========================================================================= */
180.1500 +
180.1501 +        AMD_DEBUG2 (("ME = "ID" DONE\n", me)) ;
180.1502 +        Nv [me] = nvpiv ;
180.1503 +        /* save the length of the list for the new element me */
180.1504 +        Len [me] = p - pme1 ;
180.1505 +        if (Len [me] == 0)
180.1506 +        {
180.1507 +            /* there is nothing left of the current pivot element */
180.1508 +            /* it is a root of the assembly tree */
180.1509 +            Pe [me] = EMPTY ;
180.1510 +            W [me] = 0 ;
180.1511 +        }
180.1512 +        if (elenme != 0)
180.1513 +        {
180.1514 +            /* element was not constructed in place: deallocate part of */
180.1515 +            /* it since newly nonprincipal variables may have been removed */
180.1516 +            pfree = p ;
180.1517 +        }
180.1518 +
180.1519 +        /* The new element has nvpiv pivots and the size of the contribution
180.1520 +         * block for a multifrontal method is degme-by-degme, not including
180.1521 +         * the "dense" rows/columns.  If the "dense" rows/columns are included,
180.1522 +         * the frontal matrix is no larger than
180.1523 +         * (degme+ndense)-by-(degme+ndense).
180.1524 +         */
180.1525 +
180.1526 +        if (Info != (double *) NULL)
180.1527 +        {
180.1528 +            f = nvpiv ;
180.1529 +            r = degme + ndense ;
180.1530 +            dmax = MAX (dmax, f + r) ;
180.1531 +
180.1532 +            /* number of nonzeros in L (excluding the diagonal) */
180.1533 +            lnzme = f*r + (f-1)*f/2 ;
180.1534 +            lnz += lnzme ;
180.1535 +
180.1536 +            /* number of divide operations for LDL' and for LU */
180.1537 +            ndiv += lnzme ;
180.1538 +
180.1539 +            /* number of multiply-subtract pairs for LU */
180.1540 +            s = f*r*r + r*(f-1)*f + (f-1)*f*(2*f-1)/6 ;
180.1541 +            nms_lu += s ;
180.1542 +
180.1543 +            /* number of multiply-subtract pairs for LDL' */
180.1544 +            nms_ldl += (s + lnzme)/2 ;
180.1545 +        }
180.1546 +
180.1547 +#ifndef NDEBUG
180.1548 +        AMD_DEBUG2 (("finalize done nel "ID" n "ID"\n   ::::\n", nel, n)) ;
180.1549 +        for (pme = Pe [me] ; pme <= Pe [me] + Len [me] - 1 ; pme++)
180.1550 +        {
180.1551 +              AMD_DEBUG3 ((" "ID"", Iw [pme])) ;
180.1552 +        }
180.1553 +        AMD_DEBUG3 (("\n")) ;
180.1554 +#endif
180.1555 +
180.1556 +    }
180.1557 +
180.1558 +/* ========================================================================= */
180.1559 +/* DONE SELECTING PIVOTS */
180.1560 +/* ========================================================================= */
180.1561 +
180.1562 +    if (Info != (double *) NULL)
180.1563 +    {
180.1564 +
180.1565 +        /* count the work to factorize the ndense-by-ndense submatrix */
180.1566 +        f = ndense ;
180.1567 +        dmax = MAX (dmax, (double) ndense) ;
180.1568 +
180.1569 +        /* number of nonzeros in L (excluding the diagonal) */
180.1570 +        lnzme = (f-1)*f/2 ;
180.1571 +        lnz += lnzme ;
180.1572 +
180.1573 +        /* number of divide operations for LDL' and for LU */
180.1574 +        ndiv += lnzme ;
180.1575 +
180.1576 +        /* number of multiply-subtract pairs for LU */
180.1577 +        s = (f-1)*f*(2*f-1)/6 ;
180.1578 +        nms_lu += s ;
180.1579 +
180.1580 +        /* number of multiply-subtract pairs for LDL' */
180.1581 +        nms_ldl += (s + lnzme)/2 ;
180.1582 +
180.1583 +        /* number of nz's in L (excl. diagonal) */
180.1584 +        Info [AMD_LNZ] = lnz ;
180.1585 +
180.1586 +        /* number of divide ops for LU and LDL' */
180.1587 +        Info [AMD_NDIV] = ndiv ;
180.1588 +
180.1589 +        /* number of multiply-subtract pairs for LDL' */
180.1590 +        Info [AMD_NMULTSUBS_LDL] = nms_ldl ;
180.1591 +
180.1592 +        /* number of multiply-subtract pairs for LU */
180.1593 +        Info [AMD_NMULTSUBS_LU] = nms_lu ;
180.1594 +
180.1595 +        /* number of "dense" rows/columns */
180.1596 +        Info [AMD_NDENSE] = ndense ;
180.1597 +
180.1598 +        /* largest front is dmax-by-dmax */
180.1599 +        Info [AMD_DMAX] = dmax ;
180.1600 +
180.1601 +        /* number of garbage collections in AMD */
180.1602 +        Info [AMD_NCMPA] = ncmpa ;
180.1603 +
180.1604 +        /* successful ordering */
180.1605 +        Info [AMD_STATUS] = AMD_OK ;
180.1606 +    }
180.1607 +
180.1608 +/* ========================================================================= */
180.1609 +/* POST-ORDERING */
180.1610 +/* ========================================================================= */
180.1611 +
180.1612 +/* -------------------------------------------------------------------------
180.1613 + * Variables at this point:
180.1614 + *
180.1615 + * Pe: holds the elimination tree.  The parent of j is FLIP (Pe [j]),
180.1616 + *      or EMPTY if j is a root.  The tree holds both elements and
180.1617 + *      non-principal (unordered) variables absorbed into them.
180.1618 + *      Dense variables are non-principal and unordered.
180.1619 + *
180.1620 + * Elen: holds the size of each element, including the diagonal part.
180.1621 + *      FLIP (Elen [e]) > 0 if e is an element.  For unordered
180.1622 + *      variables i, Elen [i] is EMPTY.
180.1623 + *
180.1624 + * Nv: Nv [e] > 0 is the number of pivots represented by the element e.
180.1625 + *      For unordered variables i, Nv [i] is zero.
180.1626 + *
180.1627 + * Contents no longer needed:
180.1628 + *      W, Iw, Len, Degree, Head, Next, Last.
180.1629 + *
180.1630 + * The matrix itself has been destroyed.
180.1631 + *
180.1632 + * n: the size of the matrix.
180.1633 + * No other scalars needed (pfree, iwlen, etc.)
180.1634 + * ------------------------------------------------------------------------- */
180.1635 +
180.1636 +    /* restore Pe */
180.1637 +    for (i = 0 ; i < n ; i++)
180.1638 +    {
180.1639 +        Pe [i] = FLIP (Pe [i]) ;
180.1640 +    }
180.1641 +
180.1642 +    /* restore Elen, for output information, and for postordering */
180.1643 +    for (i = 0 ; i < n ; i++)
180.1644 +    {
180.1645 +        Elen [i] = FLIP (Elen [i]) ;
180.1646 +    }
180.1647 +
180.1648 +/* Now the parent of j is Pe [j], or EMPTY if j is a root.  Elen [e] > 0
180.1649 + * is the size of element e.  Elen [i] is EMPTY for unordered variable i. */
180.1650 +
180.1651 +#ifndef NDEBUG
180.1652 +    AMD_DEBUG2 (("\nTree:\n")) ;
180.1653 +    for (i = 0 ; i < n ; i++)
180.1654 +    {
180.1655 +        AMD_DEBUG2 ((" "ID" parent: "ID"   ", i, Pe [i])) ;
180.1656 +        ASSERT (Pe [i] >= EMPTY && Pe [i] < n) ;
180.1657 +        if (Nv [i] > 0)
180.1658 +        {
180.1659 +            /* this is an element */
180.1660 +            e = i ;
180.1661 +            AMD_DEBUG2 ((" element, size is "ID"\n", Elen [i])) ;
180.1662 +            ASSERT (Elen [e] > 0) ;
180.1663 +        }
180.1664 +        AMD_DEBUG2 (("\n")) ;
180.1665 +    }
180.1666 +    AMD_DEBUG2 (("\nelements:\n")) ;
180.1667 +    for (e = 0 ; e < n ; e++)
180.1668 +    {
180.1669 +        if (Nv [e] > 0)
180.1670 +        {
180.1671 +            AMD_DEBUG3 (("Element e= "ID" size "ID" nv "ID" \n", e,
180.1672 +                Elen [e], Nv [e])) ;
180.1673 +        }
180.1674 +    }
180.1675 +    AMD_DEBUG2 (("\nvariables:\n")) ;
180.1676 +    for (i = 0 ; i < n ; i++)
180.1677 +    {
180.1678 +        Int cnt ;
180.1679 +        if (Nv [i] == 0)
180.1680 +        {
180.1681 +            AMD_DEBUG3 (("i unordered: "ID"\n", i)) ;
180.1682 +            j = Pe [i] ;
180.1683 +            cnt = 0 ;
180.1684 +            AMD_DEBUG3 (("  j: "ID"\n", j)) ;
180.1685 +            if (j == EMPTY)
180.1686 +            {
180.1687 +                AMD_DEBUG3 (("  i is a dense variable\n")) ;
180.1688 +            }
180.1689 +            else
180.1690 +            {
180.1691 +                ASSERT (j >= 0 && j < n) ;
180.1692 +                while (Nv [j] == 0)
180.1693 +                {
180.1694 +                    AMD_DEBUG3 (("      j : "ID"\n", j)) ;
180.1695 +                    j = Pe [j] ;
180.1696 +                    AMD_DEBUG3 (("      j:: "ID"\n", j)) ;
180.1697 +                    cnt++ ;
180.1698 +                    if (cnt > n) break ;
180.1699 +                }
180.1700 +                e = j ;
180.1701 +                AMD_DEBUG3 (("  got to e: "ID"\n", e)) ;
180.1702 +            }
180.1703 +        }
180.1704 +    }
180.1705 +#endif
180.1706 +
180.1707 +/* ========================================================================= */
180.1708 +/* compress the paths of the variables */
180.1709 +/* ========================================================================= */
180.1710 +
180.1711 +    for (i = 0 ; i < n ; i++)
180.1712 +    {
180.1713 +        if (Nv [i] == 0)
180.1714 +        {
180.1715 +
180.1716 +            /* -------------------------------------------------------------
180.1717 +             * i is an un-ordered row.  Traverse the tree from i until
180.1718 +             * reaching an element, e.  The element, e, was the principal
180.1719 +             * supervariable of i and all nodes in the path from i to when e
180.1720 +             * was selected as pivot.
180.1721 +             * ------------------------------------------------------------- */
180.1722 +
180.1723 +            AMD_DEBUG1 (("Path compression, i unordered: "ID"\n", i)) ;
180.1724 +            j = Pe [i] ;
180.1725 +            ASSERT (j >= EMPTY && j < n) ;
180.1726 +            AMD_DEBUG3 (("      j: "ID"\n", j)) ;
180.1727 +            if (j == EMPTY)
180.1728 +            {
180.1729 +                /* Skip a dense variable.  It has no parent. */
180.1730 +                AMD_DEBUG3 (("      i is a dense variable\n")) ;
180.1731 +                continue ;
180.1732 +            }
180.1733 +
180.1734 +            /* while (j is a variable) */
180.1735 +            while (Nv [j] == 0)
180.1736 +            {
180.1737 +                AMD_DEBUG3 (("          j : "ID"\n", j)) ;
180.1738 +                j = Pe [j] ;
180.1739 +                AMD_DEBUG3 (("          j:: "ID"\n", j)) ;
180.1740 +                ASSERT (j >= 0 && j < n) ;
180.1741 +            }
180.1742 +            /* got to an element e */
180.1743 +            e = j ;
180.1744 +            AMD_DEBUG3 (("got to e: "ID"\n", e)) ;
180.1745 +
180.1746 +            /* -------------------------------------------------------------
180.1747 +             * traverse the path again from i to e, and compress the path
180.1748 +             * (all nodes point to e).  Path compression allows this code to
180.1749 +             * compute in O(n) time.
180.1750 +             * ------------------------------------------------------------- */
180.1751 +
180.1752 +            j = i ;
180.1753 +            /* while (j is a variable) */
180.1754 +            while (Nv [j] == 0)
180.1755 +            {
180.1756 +                jnext = Pe [j] ;
180.1757 +                AMD_DEBUG3 (("j "ID" jnext "ID"\n", j, jnext)) ;
180.1758 +                Pe [j] = e ;
180.1759 +                j = jnext ;
180.1760 +                ASSERT (j >= 0 && j < n) ;
180.1761 +            }
180.1762 +        }
180.1763 +    }
180.1764 +
180.1765 +/* ========================================================================= */
180.1766 +/* postorder the assembly tree */
180.1767 +/* ========================================================================= */
180.1768 +
180.1769 +    AMD_postorder (n, Pe, Nv, Elen,
180.1770 +        W,                      /* output order */
180.1771 +        Head, Next, Last) ;     /* workspace */
180.1772 +
180.1773 +/* ========================================================================= */
180.1774 +/* compute output permutation and inverse permutation */
180.1775 +/* ========================================================================= */
180.1776 +
180.1777 +    /* W [e] = k means that element e is the kth element in the new
180.1778 +     * order.  e is in the range 0 to n-1, and k is in the range 0 to
180.1779 +     * the number of elements.  Use Head for inverse order. */
180.1780 +
180.1781 +    for (k = 0 ; k < n ; k++)
180.1782 +    {
180.1783 +        Head [k] = EMPTY ;
180.1784 +        Next [k] = EMPTY ;
180.1785 +    }
180.1786 +    for (e = 0 ; e < n ; e++)
180.1787 +    {
180.1788 +        k = W [e] ;
180.1789 +        ASSERT ((k == EMPTY) == (Nv [e] == 0)) ;
180.1790 +        if (k != EMPTY)
180.1791 +        {
180.1792 +            ASSERT (k >= 0 && k < n) ;
180.1793 +            Head [k] = e ;
180.1794 +        }
180.1795 +    }
180.1796 +
180.1797 +    /* construct output inverse permutation in Next,
180.1798 +     * and permutation in Last */
180.1799 +    nel = 0 ;
180.1800 +    for (k = 0 ; k < n ; k++)
180.1801 +    {
180.1802 +        e = Head [k] ;
180.1803 +        if (e == EMPTY) break ;
180.1804 +        ASSERT (e >= 0 && e < n && Nv [e] > 0) ;
180.1805 +        Next [e] = nel ;
180.1806 +        nel += Nv [e] ;
180.1807 +    }
180.1808 +    ASSERT (nel == n - ndense) ;
180.1809 +
180.1810 +    /* order non-principal variables (dense, & those merged into supervar's) */
180.1811 +    for (i = 0 ; i < n ; i++)
180.1812 +    {
180.1813 +        if (Nv [i] == 0)
180.1814 +        {
180.1815 +            e = Pe [i] ;
180.1816 +            ASSERT (e >= EMPTY && e < n) ;
180.1817 +            if (e != EMPTY)
180.1818 +            {
180.1819 +                /* This is an unordered variable that was merged
180.1820 +                 * into element e via supernode detection or mass
180.1821 +                 * elimination of i when e became the pivot element.
180.1822 +                 * Place i in order just before e. */
180.1823 +                ASSERT (Next [i] == EMPTY && Nv [e] > 0) ;
180.1824 +                Next [i] = Next [e] ;
180.1825 +                Next [e]++ ;
180.1826 +            }
180.1827 +            else
180.1828 +            {
180.1829 +                /* This is a dense unordered variable, with no parent.
180.1830 +                 * Place it last in the output order. */
180.1831 +                Next [i] = nel++ ;
180.1832 +            }
180.1833 +        }
180.1834 +    }
180.1835 +    ASSERT (nel == n) ;
180.1836 +
180.1837 +    AMD_DEBUG2 (("\n\nPerm:\n")) ;
180.1838 +    for (i = 0 ; i < n ; i++)
180.1839 +    {
180.1840 +        k = Next [i] ;
180.1841 +        ASSERT (k >= 0 && k < n) ;
180.1842 +        Last [k] = i ;
180.1843 +        AMD_DEBUG2 (("   perm ["ID"] = "ID"\n", k, i)) ;
180.1844 +    }
180.1845 +}
   181.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
   181.2 +++ b/deps/glpk/src/amd/amd_aat.c	Sun Nov 06 20:59:10 2011 +0100
   181.3 @@ -0,0 +1,185 @@
   181.4 +/* ========================================================================= */
   181.5 +/* === AMD_aat ============================================================= */
   181.6 +/* ========================================================================= */
   181.7 +
   181.8 +/* ------------------------------------------------------------------------- */
   181.9 +/* AMD, Copyright (c) Timothy A. Davis,                                      */
  181.10 +/* Patrick R. Amestoy, and Iain S. Duff.  See ../README.txt for License.     */
  181.11 +/* email: davis at cise.ufl.edu    CISE Department, Univ. of Florida.        */
  181.12 +/* web: http://www.cise.ufl.edu/research/sparse/amd                          */
  181.13 +/* ------------------------------------------------------------------------- */
  181.14 +
  181.15 +/* AMD_aat:  compute the symmetry of the pattern of A, and count the number of
  181.16 + * nonzeros each column of A+A' (excluding the diagonal).  Assumes the input
  181.17 + * matrix has no errors, with sorted columns and no duplicates
  181.18 + * (AMD_valid (n, n, Ap, Ai) must be AMD_OK, but this condition is not
  181.19 + * checked).
  181.20 + */
  181.21 +
  181.22 +#include "amd_internal.h"
  181.23 +
  181.24 +GLOBAL size_t AMD_aat   /* returns nz in A+A' */
  181.25 +(
  181.26 +    Int n,
  181.27 +    const Int Ap [ ],
  181.28 +    const Int Ai [ ],
  181.29 +    Int Len [ ],        /* Len [j]: length of column j of A+A', excl diagonal*/
  181.30 +    Int Tp [ ],         /* workspace of size n */
  181.31 +    double Info [ ]
  181.32 +)
  181.33 +{
  181.34 +    Int p1, p2, p, i, j, pj, pj2, k, nzdiag, nzboth, nz ;
  181.35 +    double sym ;
  181.36 +    size_t nzaat ;
  181.37 +
  181.38 +#ifndef NDEBUG
  181.39 +    AMD_debug_init ("AMD AAT") ;
  181.40 +    for (k = 0 ; k < n ; k++) Tp [k] = EMPTY ;
  181.41 +    ASSERT (AMD_valid (n, n, Ap, Ai) == AMD_OK) ;
  181.42 +#endif
  181.43 +
  181.44 +    if (Info != (double *) NULL)
  181.45 +    {
  181.46 +        /* clear the Info array, if it exists */
  181.47 +        for (i = 0 ; i < AMD_INFO ; i++)
  181.48 +        {
  181.49 +            Info [i] = EMPTY ;
  181.50 +        }
  181.51 +        Info [AMD_STATUS] = AMD_OK ;
  181.52 +    }
  181.53 +
  181.54 +    for (k = 0 ; k < n ; k++)
  181.55 +    {
  181.56 +        Len [k] = 0 ;
  181.57 +    }
  181.58 +
  181.59 +    nzdiag = 0 ;
  181.60 +    nzboth = 0 ;
  181.61 +    nz = Ap [n] ;
  181.62 +
  181.63 +    for (k = 0 ; k < n ; k++)
  181.64 +    {
  181.65 +        p1 = Ap [k] ;
  181.66 +        p2 = Ap [k+1] ;
  181.67 +        AMD_DEBUG2 (("\nAAT Column: "ID" p1: "ID" p2: "ID"\n", k, p1, p2)) ;
  181.68 +
  181.69 +        /* construct A+A' */
  181.70 +        for (p = p1 ; p < p2 ; )
  181.71 +        {
  181.72 +            /* scan the upper triangular part of A */
  181.73 +            j = Ai [p] ;
  181.74 +            if (j < k)
  181.75 +            {
  181.76 +                /* entry A (j,k) is in the strictly upper triangular part,
  181.77 +                 * add both A (j,k) and A (k,j) to the matrix A+A' */
  181.78 +                Len [j]++ ;
  181.79 +                Len [k]++ ;
  181.80 +                AMD_DEBUG3 (("    upper ("ID","ID") ("ID","ID")\n", j,k, k,j));
  181.81 +                p++ ;
  181.82 +            }
  181.83 +            else if (j == k)
  181.84 +            {
  181.85 +                /* skip the diagonal */
  181.86 +                p++ ;
  181.87 +                nzdiag++ ;
  181.88 +                break ;
  181.89 +            }
  181.90 +            else /* j > k */
  181.91 +            {
  181.92 +                /* first entry below the diagonal */
  181.93 +                break ;
  181.94 +            }
  181.95 +            /* scan lower triangular part of A, in column j until reaching
  181.96 +             * row k.  Start where last scan left off. */
  181.97 +            ASSERT (Tp [j] != EMPTY) ;
  181.98 +            ASSERT (Ap [j] <= Tp [j] && Tp [j] <= Ap [j+1]) ;
  181.99 +            pj2 = Ap [j+1] ;
 181.100 +            for (pj = Tp [j] ; pj < pj2 ; )
 181.101 +            {
 181.102 +                i = Ai [pj] ;
 181.103 +                if (i < k)
 181.104 +                {
 181.105 +                    /* A (i,j) is only in the lower part, not in upper.
 181.106 +                     * add both A (i,j) and A (j,i) to the matrix A+A' */
 181.107 +                    Len [i]++ ;
 181.108 +                    Len [j]++ ;
 181.109 +                    AMD_DEBUG3 (("    lower ("ID","ID") ("ID","ID")\n",
 181.110 +                        i,j, j,i)) ;
 181.111 +                    pj++ ;
 181.112 +                }
 181.113 +                else if (i == k)
 181.114 +                {
 181.115 +                    /* entry A (k,j) in lower part and A (j,k) in upper */
 181.116 +                    pj++ ;
 181.117 +                    nzboth++ ;
 181.118 +                    break ;
 181.119 +                }
 181.120 +                else /* i > k */
 181.121 +                {
 181.122 +                    /* consider this entry later, when k advances to i */
 181.123 +                    break ;
 181.124 +                }
 181.125 +            }
 181.126 +            Tp [j] = pj ;
 181.127 +        }
 181.128 +        /* Tp [k] points to the entry just below the diagonal in column k */
 181.129 +        Tp [k] = p ;
 181.130 +    }
 181.131 +
 181.132 +    /* clean up, for remaining mismatched entries */
 181.133 +    for (j = 0 ; j < n ; j++)
 181.134 +    {
 181.135 +        for (pj = Tp [j] ; pj < Ap [j+1] ; pj++)
 181.136 +        {
 181.137 +            i = Ai [pj] ;
 181.138 +            /* A (i,j) is only in the lower part, not in upper.
 181.139 +             * add both A (i,j) and A (j,i) to the matrix A+A' */
 181.140 +            Len [i]++ ;
 181.141 +            Len [j]++ ;
 181.142 +            AMD_DEBUG3 (("    lower cleanup ("ID","ID") ("ID","ID")\n",
 181.143 +                i,j, j,i)) ;
 181.144 +        }
 181.145 +    }
 181.146 +
 181.147 +    /* --------------------------------------------------------------------- */
 181.148 +    /* compute the symmetry of the nonzero pattern of A */
 181.149 +    /* --------------------------------------------------------------------- */
 181.150 +
 181.151 +    /* Given a matrix A, the symmetry of A is:
 181.152 +     *  B = tril (spones (A), -1) + triu (spones (A), 1) ;
 181.153 +     *  sym = nnz (B & B') / nnz (B) ;
 181.154 +     *  or 1 if nnz (B) is zero.
 181.155 +     */
 181.156 +
 181.157 +    if (nz == nzdiag)
 181.158 +    {
 181.159 +        sym = 1 ;
 181.160 +    }
 181.161 +    else
 181.162 +    {
 181.163 +        sym = (2 * (double) nzboth) / ((double) (nz - nzdiag)) ;
 181.164 +    }
 181.165 +
 181.166 +    nzaat = 0 ;
 181.167 +    for (k = 0 ; k < n ; k++)
 181.168 +    {
 181.169 +        nzaat += Len [k] ;
 181.170 +    }
 181.171 +
 181.172 +    AMD_DEBUG1 (("AMD nz in A+A', excluding diagonal (nzaat) = %g\n",
 181.173 +        (double) nzaat)) ;
 181.174 +    AMD_DEBUG1 (("   nzboth: "ID" nz: "ID" nzdiag: "ID" symmetry: %g\n",
 181.175 +                nzboth, nz, nzdiag, sym)) ;
 181.176 +
 181.177 +    if (Info != (double *) NULL)
 181.178 +    {
 181.179 +        Info [AMD_STATUS] = AMD_OK ;
 181.180 +        Info [AMD_N] = n ;
 181.181 +        Info [AMD_NZ] = nz ;
 181.182 +        Info [AMD_SYMMETRY] = sym ;         /* symmetry of pattern of A */
 181.183 +        Info [AMD_NZDIAG] = nzdiag ;        /* nonzeros on diagonal of A */
 181.184 +        Info [AMD_NZ_A_PLUS_AT] = nzaat ;   /* nonzeros in A+A' */
 181.185 +    }
 181.186 +
 181.187 +    return (nzaat) ;
 181.188 +}
   182.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
   182.2 +++ b/deps/glpk/src/amd/amd_control.c	Sun Nov 06 20:59:10 2011 +0100
   182.3 @@ -0,0 +1,64 @@
   182.4 +/* ========================================================================= */
   182.5 +/* === AMD_control ========================================================= */
   182.6 +/* ========================================================================= */
   182.7 +
   182.8 +/* ------------------------------------------------------------------------- */
   182.9 +/* AMD, Copyright (c) Timothy A. Davis,                                      */
  182.10 +/* Patrick R. Amestoy, and Iain S. Duff.  See ../README.txt for License.     */
  182.11 +/* email: davis at cise.ufl.edu    CISE Department, Univ. of Florida.        */
  182.12 +/* web: http://www.cise.ufl.edu/research/sparse/amd                          */
  182.13 +/* ------------------------------------------------------------------------- */
  182.14 +
  182.15 +/* User-callable.  Prints the control parameters for AMD.  See amd.h
  182.16 + * for details.  If the Control array is not present, the defaults are
  182.17 + * printed instead.
  182.18 + */
  182.19 +
  182.20 +#include "amd_internal.h"
  182.21 +
  182.22 +GLOBAL void AMD_control
  182.23 +(
  182.24 +    double Control [ ]
  182.25 +)
  182.26 +{
  182.27 +    double alpha ;
  182.28 +    Int aggressive ;
  182.29 +
  182.30 +    if (Control != (double *) NULL)
  182.31 +    {
  182.32 +        alpha = Control [AMD_DENSE] ;
  182.33 +        aggressive = Control [AMD_AGGRESSIVE] != 0 ;
  182.34 +    }
  182.35 +    else
  182.36 +    {
  182.37 +        alpha = AMD_DEFAULT_DENSE ;
  182.38 +        aggressive = AMD_DEFAULT_AGGRESSIVE ;
  182.39 +    }
  182.40 +
  182.41 +    PRINTF (("\nAMD version %d.%d.%d, %s: approximate minimum degree ordering\n"
  182.42 +        "    dense row parameter: %g\n", AMD_MAIN_VERSION, AMD_SUB_VERSION,
  182.43 +        AMD_SUBSUB_VERSION, AMD_DATE, alpha)) ;
  182.44 +
  182.45 +    if (alpha < 0)
  182.46 +    {
  182.47 +        PRINTF (("    no rows treated as dense\n")) ;
  182.48 +    }
  182.49 +    else
  182.50 +    {
  182.51 +        PRINTF ((
  182.52 +        "    (rows with more than max (%g * sqrt (n), 16) entries are\n"
  182.53 +        "    considered \"dense\", and placed last in output permutation)\n",
  182.54 +        alpha)) ;
  182.55 +    }
  182.56 +
  182.57 +    if (aggressive)
  182.58 +    {
  182.59 +        PRINTF (("    aggressive absorption:  yes\n")) ;
  182.60 +    }
  182.61 +    else
  182.62 +    {
  182.63 +        PRINTF (("    aggressive absorption:  no\n")) ;
  182.64 +    }
  182.65 +
  182.66 +    PRINTF (("    size of AMD integer: %d\n\n", sizeof (Int))) ;
  182.67 +}
   183.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
   183.2 +++ b/deps/glpk/src/amd/amd_defaults.c	Sun Nov 06 20:59:10 2011 +0100
   183.3 @@ -0,0 +1,38 @@
   183.4 +/* ========================================================================= */
   183.5 +/* === AMD_defaults ======================================================== */
   183.6 +/* ========================================================================= */
   183.7 +
   183.8 +/* ------------------------------------------------------------------------- */
   183.9 +/* AMD, Copyright (c) Timothy A. Davis,                                      */
  183.10 +/* Patrick R. Amestoy, and Iain S. Duff.  See ../README.txt for License.     */
  183.11 +/* email: davis at cise.ufl.edu    CISE Department, Univ. of Florida.        */
  183.12 +/* web: http://www.cise.ufl.edu/research/sparse/amd                          */
  183.13 +/* ------------------------------------------------------------------------- */
  183.14 +
  183.15 +/* User-callable.  Sets default control parameters for AMD.  See amd.h
  183.16 + * for details.
  183.17 + */
  183.18 +
  183.19 +#include "amd_internal.h"
  183.20 +
  183.21 +/* ========================================================================= */
  183.22 +/* === AMD defaults ======================================================== */
  183.23 +/* ========================================================================= */
  183.24 +
  183.25 +GLOBAL void AMD_defaults
  183.26 +(
  183.27 +    double Control [ ]
  183.28 +)
  183.29 +{
  183.30 +    Int i ;
  183.31 +
  183.32 +    if (Control != (double *) NULL)
  183.33 +    {
  183.34 +        for (i = 0 ; i < AMD_CONTROL ; i++)
  183.35 +        {
  183.36 +            Control [i] = 0 ;
  183.37 +        }
  183.38 +        Control [AMD_DENSE] = AMD_DEFAULT_DENSE ;
  183.39 +        Control [AMD_AGGRESSIVE] = AMD_DEFAULT_AGGRESSIVE ;
  183.40 +    }
  183.41 +}
   184.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
   184.2 +++ b/deps/glpk/src/amd/amd_dump.c	Sun Nov 06 20:59:10 2011 +0100
   184.3 @@ -0,0 +1,180 @@
   184.4 +/* ========================================================================= */
   184.5 +/* === AMD_dump ============================================================ */
   184.6 +/* ========================================================================= */
   184.7 +
   184.8 +/* ------------------------------------------------------------------------- */
   184.9 +/* AMD, Copyright (c) Timothy A. Davis,                                      */
  184.10 +/* Patrick R. Amestoy, and Iain S. Duff.  See ../README.txt for License.     */
  184.11 +/* email: davis at cise.ufl.edu    CISE Department, Univ. of Florida.        */
  184.12 +/* web: http://www.cise.ufl.edu/research/sparse/amd                          */
  184.13 +/* ------------------------------------------------------------------------- */
  184.14 +
  184.15 +/* Debugging routines for AMD.  Not used if NDEBUG is not defined at compile-
  184.16 + * time (the default).  See comments in amd_internal.h on how to enable
  184.17 + * debugging.  Not user-callable.
  184.18 + */
  184.19 +
  184.20 +#include "amd_internal.h"
  184.21 +
  184.22 +#ifndef NDEBUG
  184.23 +
  184.24 +/* This global variable is present only when debugging */
  184.25 +GLOBAL Int AMD_debug = -999 ;           /* default is no debug printing */
  184.26 +
  184.27 +/* ========================================================================= */
  184.28 +/* === AMD_debug_init ====================================================== */
  184.29 +/* ========================================================================= */
  184.30 +
  184.31 +/* Sets the debug print level, by reading the file debug.amd (if it exists) */
  184.32 +
  184.33 +GLOBAL void AMD_debug_init ( char *s )
  184.34 +{
  184.35 +    FILE *f ;
  184.36 +    f = fopen ("debug.amd", "r") ;
  184.37 +    if (f == (FILE *) NULL)
  184.38 +    {
  184.39 +        AMD_debug = -999 ;
  184.40 +    }
  184.41 +    else
  184.42 +    {
  184.43 +        fscanf (f, ID, &AMD_debug) ;
  184.44 +        fclose (f) ;
  184.45 +    }
  184.46 +    if (AMD_debug >= 0)
  184.47 +    {
  184.48 +        printf ("%s: AMD_debug_init, D= "ID"\n", s, AMD_debug) ;
  184.49 +    }
  184.50 +}
  184.51 +
  184.52 +/* ========================================================================= */
  184.53 +/* === AMD_dump ============================================================ */
  184.54 +/* ========================================================================= */
  184.55 +
  184.56 +/* Dump AMD's data structure, except for the hash buckets.  This routine
  184.57 + * cannot be called when the hash buckets are non-empty.
  184.58 + */
  184.59 +
  184.60 +GLOBAL void AMD_dump (
  184.61 +    Int n,          /* A is n-by-n */
  184.62 +    Int Pe [ ],     /* pe [0..n-1]: index in iw of start of row i */
  184.63 +    Int Iw [ ],     /* workspace of size iwlen, iwlen [0..pfree-1]
  184.64 +                     * holds the matrix on input */
  184.65 +    Int Len [ ],    /* len [0..n-1]: length for row i */
  184.66 +    Int iwlen,      /* length of iw */
  184.67 +    Int pfree,      /* iw [pfree ... iwlen-1] is empty on input */
  184.68 +    Int Nv [ ],     /* nv [0..n-1] */
  184.69 +    Int Next [ ],   /* next [0..n-1] */
  184.70 +    Int Last [ ],   /* last [0..n-1] */
  184.71 +    Int Head [ ],   /* head [0..n-1] */
  184.72 +    Int Elen [ ],   /* size n */
  184.73 +    Int Degree [ ], /* size n */
  184.74 +    Int W [ ],      /* size n */
  184.75 +    Int nel
  184.76 +)
  184.77 +{
  184.78 +    Int i, pe, elen, nv, len, e, p, k, j, deg, w, cnt, ilast ;
  184.79 +
  184.80 +    if (AMD_debug < 0) return ;
  184.81 +    ASSERT (pfree <= iwlen) ;
  184.82 +    AMD_DEBUG3 (("\nAMD dump, pfree: "ID"\n", pfree)) ;
  184.83 +    for (i = 0 ; i < n ; i++)
  184.84 +    {
  184.85 +        pe = Pe [i] ;
  184.86 +        elen = Elen [i] ;
  184.87 +        nv = Nv [i] ;
  184.88 +        len = Len [i] ;
  184.89 +        w = W [i] ;
  184.90 +
  184.91 +        if (elen >= EMPTY)
  184.92 +        {
  184.93 +            if (nv == 0)
  184.94 +            {
  184.95 +                AMD_DEBUG3 (("\nI "ID": nonprincipal:    ", i)) ;
  184.96 +                ASSERT (elen == EMPTY) ;
  184.97 +                if (pe == EMPTY)
  184.98 +                {
  184.99 +                    AMD_DEBUG3 ((" dense node\n")) ;
 184.100 +                    ASSERT (w == 1) ;
 184.101 +                }
 184.102 +                else
 184.103 +                {
 184.104 +                    ASSERT (pe < EMPTY) ;
 184.105 +                    AMD_DEBUG3 ((" i "ID" -> parent "ID"\n", i, FLIP (Pe[i])));
 184.106 +                }
 184.107 +            }
 184.108 +            else
 184.109 +            {
 184.110 +                AMD_DEBUG3 (("\nI "ID": active principal supervariable:\n",i));
 184.111 +                AMD_DEBUG3 (("   nv(i): "ID"  Flag: %d\n", nv, (nv < 0))) ;
 184.112 +                ASSERT (elen >= 0) ;
 184.113 +                ASSERT (nv > 0 && pe >= 0) ;
 184.114 +                p = pe ;
 184.115 +                AMD_DEBUG3 (("   e/s: ")) ;
 184.116 +                if (elen == 0) AMD_DEBUG3 ((" : ")) ;
 184.117 +                ASSERT (pe + len <= pfree) ;
 184.118 +                for (k = 0 ; k < len ; k++)
 184.119 +                {
 184.120 +                    j = Iw [p] ;
 184.121 +                    AMD_DEBUG3 (("  "ID"", j)) ;
 184.122 +                    ASSERT (j >= 0 && j < n) ;
 184.123 +                    if (k == elen-1) AMD_DEBUG3 ((" : ")) ;
 184.124 +                    p++ ;
 184.125 +                }
 184.126 +                AMD_DEBUG3 (("\n")) ;
 184.127 +            }
 184.128 +        }
 184.129 +        else
 184.130 +        {
 184.131 +            e = i ;
 184.132 +            if (w == 0)
 184.133 +            {
 184.134 +                AMD_DEBUG3 (("\nE "ID": absorbed element: w "ID"\n", e, w)) ;
 184.135 +                ASSERT (nv > 0 && pe < 0) ;
 184.136 +                AMD_DEBUG3 ((" e "ID" -> parent "ID"\n", e, FLIP (Pe [e]))) ;
 184.137 +            }
 184.138 +            else
 184.139 +            {
 184.140 +                AMD_DEBUG3 (("\nE "ID": unabsorbed element: w "ID"\n", e, w)) ;
 184.141 +                ASSERT (nv > 0 && pe >= 0) ;
 184.142 +                p = pe ;
 184.143 +                AMD_DEBUG3 ((" : ")) ;
 184.144 +                ASSERT (pe + len <= pfree) ;
 184.145 +                for (k = 0 ; k < len ; k++)
 184.146 +                {
 184.147 +                    j = Iw [p] ;
 184.148 +                    AMD_DEBUG3 (("  "ID"", j)) ;
 184.149 +                    ASSERT (j >= 0 && j < n) ;
 184.150 +                    p++ ;
 184.151 +                }
 184.152 +                AMD_DEBUG3 (("\n")) ;
 184.153 +            }
 184.154 +        }
 184.155 +    }
 184.156 +
 184.157 +    /* this routine cannot be called when the hash buckets are non-empty */
 184.158 +    AMD_DEBUG3 (("\nDegree lists:\n")) ;
 184.159 +    if (nel >= 0)
 184.160 +    {
 184.161 +        cnt = 0 ;
 184.162 +        for (deg = 0 ; deg < n ; deg++)
 184.163 +        {
 184.164 +            if (Head [deg] == EMPTY) continue ;
 184.165 +            ilast = EMPTY ;
 184.166 +            AMD_DEBUG3 ((ID": \n", deg)) ;
 184.167 +            for (i = Head [deg] ; i != EMPTY ; i = Next [i])
 184.168 +            {
 184.169 +                AMD_DEBUG3 (("   "ID" : next "ID" last "ID" deg "ID"\n",
 184.170 +                    i, Next [i], Last [i], Degree [i])) ;
 184.171 +                ASSERT (i >= 0 && i < n && ilast == Last [i] &&
 184.172 +                    deg == Degree [i]) ;
 184.173 +                cnt += Nv [i] ;
 184.174 +                ilast = i ;
 184.175 +            }
 184.176 +            AMD_DEBUG3 (("\n")) ;
 184.177 +        }
 184.178 +        ASSERT (cnt == n - nel) ;
 184.179 +    }
 184.180 +
 184.181 +}
 184.182 +
 184.183 +#endif
   185.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
   185.2 +++ b/deps/glpk/src/amd/amd_info.c	Sun Nov 06 20:59:10 2011 +0100
   185.3 @@ -0,0 +1,120 @@
   185.4 +/* ========================================================================= */
   185.5 +/* === AMD_info ============================================================ */
   185.6 +/* ========================================================================= */
   185.7 +
   185.8 +/* ------------------------------------------------------------------------- */
   185.9 +/* AMD, Copyright (c) Timothy A. Davis,                                      */
  185.10 +/* Patrick R. Amestoy, and Iain S. Duff.  See ../README.txt for License.     */
  185.11 +/* email: davis at cise.ufl.edu    CISE Department, Univ. of Florida.        */
  185.12 +/* web: http://www.cise.ufl.edu/research/sparse/amd                          */
  185.13 +/* ------------------------------------------------------------------------- */
  185.14 +
  185.15 +/* User-callable.  Prints the output statistics for AMD.  See amd.h
  185.16 + * for details.  If the Info array is not present, nothing is printed.
  185.17 + */
  185.18 +
  185.19 +#include "amd_internal.h"
  185.20 +
  185.21 +#define PRI(format,x) { if (x >= 0) { PRINTF ((format, x)) ; }}
  185.22 +
  185.23 +GLOBAL void AMD_info
  185.24 +(
  185.25 +    double Info [ ]
  185.26 +)
  185.27 +{
  185.28 +    double n, ndiv, nmultsubs_ldl, nmultsubs_lu, lnz, lnzd ;
  185.29 +
  185.30 +    PRINTF (("\nAMD version %d.%d.%d, %s, results:\n",
  185.31 +        AMD_MAIN_VERSION, AMD_SUB_VERSION, AMD_SUBSUB_VERSION, AMD_DATE)) ;
  185.32 +
  185.33 +    if (!Info)
  185.34 +    {
  185.35 +        return ;
  185.36 +    }
  185.37 +
  185.38 +    n = Info [AMD_N] ;
  185.39 +    ndiv = Info [AMD_NDIV] ;
  185.40 +    nmultsubs_ldl = Info [AMD_NMULTSUBS_LDL] ;
  185.41 +    nmultsubs_lu = Info [AMD_NMULTSUBS_LU] ;
  185.42 +    lnz = Info [AMD_LNZ] ;
  185.43 +    lnzd = (n >= 0 && lnz >= 0) ? (n + lnz) : (-1) ;
  185.44 +
  185.45 +    /* AMD return status */
  185.46 +    PRINTF (("    status: ")) ;
  185.47 +    if (Info [AMD_STATUS] == AMD_OK)
  185.48 +    {
  185.49 +        PRINTF (("OK\n")) ;
  185.50 +    }
  185.51 +    else if (Info [AMD_STATUS] == AMD_OUT_OF_MEMORY)
  185.52 +    {
  185.53 +        PRINTF (("out of memory\n")) ;
  185.54 +    }
  185.55 +    else if (Info [AMD_STATUS] == AMD_INVALID)
  185.56 +    {
  185.57 +        PRINTF (("invalid matrix\n")) ;
  185.58 +    }
  185.59 +    else if (Info [AMD_STATUS] == AMD_OK_BUT_JUMBLED)
  185.60 +    {
  185.61 +        PRINTF (("OK, but jumbled\n")) ;
  185.62 +    }
  185.63 +    else
  185.64 +    {
  185.65 +        PRINTF (("unknown\n")) ;
  185.66 +    }
  185.67 +
  185.68 +    /* statistics about the input matrix */
  185.69 +    PRI ("    n, dimension of A:                                  %.20g\n", n);
  185.70 +    PRI ("    nz, number of nonzeros in A:                        %.20g\n",
  185.71 +        Info [AMD_NZ]) ;
  185.72 +    PRI ("    symmetry of A:                                      %.4f\n",
  185.73 +        Info [AMD_SYMMETRY]) ;
  185.74 +    PRI ("    number of nonzeros on diagonal:                     %.20g\n",
  185.75 +        Info [AMD_NZDIAG]) ;
  185.76 +    PRI ("    nonzeros in pattern of A+A' (excl. diagonal):       %.20g\n",
  185.77 +        Info [AMD_NZ_A_PLUS_AT]) ;
  185.78 +    PRI ("    # dense rows/columns of A+A':                       %.20g\n",
  185.79 +        Info [AMD_NDENSE]) ;
  185.80 +
  185.81 +    /* statistics about AMD's behavior  */
  185.82 +    PRI ("    memory used, in bytes:                              %.20g\n",
  185.83 +        Info [AMD_MEMORY]) ;
  185.84 +    PRI ("    # of memory compactions:                            %.20g\n",
  185.85 +        Info [AMD_NCMPA]) ;
  185.86 +
  185.87 +    /* statistics about the ordering quality */
  185.88 +    PRINTF (("\n"
  185.89 +        "    The following approximate statistics are for a subsequent\n"
  185.90 +        "    factorization of A(P,P) + A(P,P)'.  They are slight upper\n"
  185.91 +        "    bounds if there are no dense rows/columns in A+A', and become\n"
  185.92 +        "    looser if dense rows/columns exist.\n\n")) ;
  185.93 +
  185.94 +    PRI ("    nonzeros in L (excluding diagonal):                 %.20g\n",
  185.95 +        lnz) ;
  185.96 +    PRI ("    nonzeros in L (including diagonal):                 %.20g\n",
  185.97 +        lnzd) ;
  185.98 +    PRI ("    # divide operations for LDL' or LU:                 %.20g\n",
  185.99 +        ndiv) ;
 185.100 +    PRI ("    # multiply-subtract operations for LDL':            %.20g\n",
 185.101 +        nmultsubs_ldl) ;
 185.102 +    PRI ("    # multiply-subtract operations for LU:              %.20g\n",
 185.103 +        nmultsubs_lu) ;
 185.104 +    PRI ("    max nz. in any column of L (incl. diagonal):        %.20g\n",
 185.105 +        Info [AMD_DMAX]) ;
 185.106 +
 185.107 +    /* total flop counts for various factorizations */
 185.108 +
 185.109 +    if (n >= 0 && ndiv >= 0 && nmultsubs_ldl >= 0 && nmultsubs_lu >= 0)
 185.110 +    {
 185.111 +        PRINTF (("\n"
 185.112 +        "    chol flop count for real A, sqrt counted as 1 flop: %.20g\n"
 185.113 +        "    LDL' flop count for real A:                         %.20g\n"
 185.114 +        "    LDL' flop count for complex A:                      %.20g\n"
 185.115 +        "    LU flop count for real A (with no pivoting):        %.20g\n"
 185.116 +        "    LU flop count for complex A (with no pivoting):     %.20g\n\n",
 185.117 +        n + ndiv + 2*nmultsubs_ldl,
 185.118 +            ndiv + 2*nmultsubs_ldl,
 185.119 +          9*ndiv + 8*nmultsubs_ldl,
 185.120 +            ndiv + 2*nmultsubs_lu,
 185.121 +          9*ndiv + 8*nmultsubs_lu)) ;
 185.122 +    }
 185.123 +}
   186.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
   186.2 +++ b/deps/glpk/src/amd/amd_internal.h	Sun Nov 06 20:59:10 2011 +0100
   186.3 @@ -0,0 +1,113 @@
   186.4 +/* amd_internal.h */
   186.5 +
   186.6 +/* Written by Andrew Makhorin <mao@gnu.org>. */
   186.7 +
   186.8 +#ifndef AMD_INTERNAL_H
   186.9 +#define AMD_INTERNAL_H
  186.10 +
  186.11 +/* AMD will be exceedingly slow when running in debug mode. */
  186.12 +#if 1
  186.13 +#define NDEBUG
  186.14 +#endif
  186.15 +
  186.16 +#include "amd.h"
  186.17 +#define _GLPSTD_STDIO
  186.18 +#include "glpenv.h"
  186.19 +
  186.20 +#define Int int
  186.21 +#define ID "%d"
  186.22 +#define Int_MAX INT_MAX
  186.23 +
  186.24 +#define SIZE_T_MAX ((size_t)(-1))
  186.25 +
  186.26 +#define EMPTY (-1)
  186.27 +#define FLIP(i) (-(i)-2)
  186.28 +#define UNFLIP(i) ((i < EMPTY) ? FLIP (i) : (i))
  186.29 +
  186.30 +#define MAX(a,b) (((a) > (b)) ? (a) : (b))
  186.31 +#define MIN(a,b) (((a) < (b)) ? (a) : (b))
  186.32 +
  186.33 +#define IMPLIES(p, q) (!(p) || (q))
  186.34 +
  186.35 +#define GLOBAL
  186.36 +
  186.37 +#define AMD_order amd_order
  186.38 +#define AMD_defaults amd_defaults
  186.39 +#define AMD_control amd_control
  186.40 +#define AMD_info amd_info
  186.41 +#define AMD_1 amd_1
  186.42 +#define AMD_2 amd_2
  186.43 +#define AMD_valid amd_valid
  186.44 +#define AMD_aat amd_aat
  186.45 +#define AMD_postorder amd_postorder
  186.46 +#define AMD_post_tree amd_post_tree
  186.47 +#define AMD_dump amd_dump
  186.48 +#define AMD_debug amd_debug
  186.49 +#define AMD_debug_init amd_debug_init
  186.50 +#define AMD_preprocess amd_preprocess
  186.51 +
  186.52 +#define amd_malloc xmalloc
  186.53 +#if 0 /* 24/V-2009 */
  186.54 +#define amd_free xfree
  186.55 +#else
  186.56 +#define amd_free(ptr) { if ((ptr) != NULL) xfree(ptr); } 
  186.57 +#endif
  186.58 +#define amd_printf xprintf
  186.59 +
  186.60 +#define PRINTF(params) { amd_printf params; }
  186.61 +
  186.62 +#ifndef NDEBUG
  186.63 +#define ASSERT(expr) xassert(expr)
  186.64 +#define AMD_DEBUG0(params) { PRINTF(params); }
  186.65 +#define AMD_DEBUG1(params) { if (AMD_debug >= 1) PRINTF(params); }
  186.66 +#define AMD_DEBUG2(params) { if (AMD_debug >= 2) PRINTF(params); }
  186.67 +#define AMD_DEBUG3(params) { if (AMD_debug >= 3) PRINTF(params); }
  186.68 +#define AMD_DEBUG4(params) { if (AMD_debug >= 4) PRINTF(params); }
  186.69 +#else
  186.70 +#define ASSERT(expression)
  186.71 +#define AMD_DEBUG0(params)
  186.72 +#define AMD_DEBUG1(params)
  186.73 +#define AMD_DEBUG2(params)
  186.74 +#define AMD_DEBUG3(params)
  186.75 +#define AMD_DEBUG4(params)
  186.76 +#endif
  186.77 +
  186.78 +#define amd_aat _glp_amd_aat
  186.79 +size_t AMD_aat(Int n, const Int Ap[], const Int Ai[], Int Len[],
  186.80 +      Int Tp[], double Info[]);
  186.81 +
  186.82 +#define amd_1 _glp_amd_1
  186.83 +void AMD_1(Int n, const Int Ap[], const Int Ai[], Int P[], Int Pinv[],
  186.84 +      Int Len[], Int slen, Int S[], double Control[], double Info[]);
  186.85 +
  186.86 +#define amd_postorder _glp_amd_postorder
  186.87 +void AMD_postorder(Int nn, Int Parent[], Int Npiv[], Int Fsize[],
  186.88 +      Int Order[], Int Child[], Int Sibling[], Int Stack[]);
  186.89 +
  186.90 +#define amd_post_tree _glp_amd_post_tree
  186.91 +#ifndef NDEBUG
  186.92 +Int AMD_post_tree(Int root, Int k, Int Child[], const Int Sibling[],
  186.93 +      Int Order[], Int Stack[], Int nn);
  186.94 +#else
  186.95 +Int AMD_post_tree(Int root, Int k, Int Child[], const Int Sibling[],
  186.96 +      Int Order[], Int Stack[]);
  186.97 +#endif
  186.98 +
  186.99 +#define amd_preprocess _glp_amd_preprocess
 186.100 +void AMD_preprocess(Int n, const Int Ap[], const Int Ai[], Int Rp[],
 186.101 +      Int Ri[], Int W[], Int Flag[]);
 186.102 +
 186.103 +#define amd_debug _glp_amd_debug
 186.104 +extern Int AMD_debug;
 186.105 +
 186.106 +#define amd_debug_init _glp_amd_debug_init
 186.107 +void AMD_debug_init(char *s);
 186.108 +
 186.109 +#define amd_dump _glp_amd_dump
 186.110 +void AMD_dump(Int n, Int Pe[], Int Iw[], Int Len[], Int iwlen,
 186.111 +      Int pfree, Int Nv[], Int Next[], Int Last[], Int Head[],
 186.112 +      Int Elen[], Int Degree[], Int W[], Int nel);
 186.113 +
 186.114 +#endif
 186.115 +
 186.116 +/* eof */
   187.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
   187.2 +++ b/deps/glpk/src/amd/amd_order.c	Sun Nov 06 20:59:10 2011 +0100
   187.3 @@ -0,0 +1,200 @@
   187.4 +/* ========================================================================= */
   187.5 +/* === AMD_order =========================================================== */
   187.6 +/* ========================================================================= */
   187.7 +
   187.8 +/* ------------------------------------------------------------------------- */
   187.9 +/* AMD, Copyright (c) Timothy A. Davis,                                      */
  187.10 +/* Patrick R. Amestoy, and Iain S. Duff.  See ../README.txt for License.     */
  187.11 +/* email: davis at cise.ufl.edu    CISE Department, Univ. of Florida.        */
  187.12 +/* web: http://www.cise.ufl.edu/research/sparse/amd                          */
  187.13 +/* ------------------------------------------------------------------------- */
  187.14 +
  187.15 +/* User-callable AMD minimum degree ordering routine.  See amd.h for
  187.16 + * documentation.
  187.17 + */
  187.18 +
  187.19 +#include "amd_internal.h"
  187.20 +
  187.21 +/* ========================================================================= */
  187.22 +/* === AMD_order =========================================================== */
  187.23 +/* ========================================================================= */
  187.24 +
  187.25 +GLOBAL Int AMD_order
  187.26 +(
  187.27 +    Int n,
  187.28 +    const Int Ap [ ],
  187.29 +    const Int Ai [ ],
  187.30 +    Int P [ ],
  187.31 +    double Control [ ],
  187.32 +    double Info [ ]
  187.33 +)
  187.34 +{
  187.35 +    Int *Len, *S, nz, i, *Pinv, info, status, *Rp, *Ri, *Cp, *Ci, ok ;
  187.36 +    size_t nzaat, slen ;
  187.37 +    double mem = 0 ;
  187.38 +
  187.39 +#ifndef NDEBUG
  187.40 +    AMD_debug_init ("amd") ;
  187.41 +#endif
  187.42 +
  187.43 +    /* clear the Info array, if it exists */
  187.44 +    info = Info != (double *) NULL ;
  187.45 +    if (info)
  187.46 +    {
  187.47 +        for (i = 0 ; i < AMD_INFO ; i++)
  187.48 +        {
  187.49 +            Info [i] = EMPTY ;
  187.50 +        }
  187.51 +        Info [AMD_N] = n ;
  187.52 +        Info [AMD_STATUS] = AMD_OK ;
  187.53 +    }
  187.54 +
  187.55 +    /* make sure inputs exist and n is >= 0 */
  187.56 +    if (Ai == (Int *) NULL || Ap == (Int *) NULL || P == (Int *) NULL || n < 0)
  187.57 +    {
  187.58 +        if (info) Info [AMD_STATUS] = AMD_INVALID ;
  187.59 +        return (AMD_INVALID) ;      /* arguments are invalid */
  187.60 +    }
  187.61 +
  187.62 +    if (n == 0)
  187.63 +    {
  187.64 +        return (AMD_OK) ;           /* n is 0 so there's nothing to do */
  187.65 +    }
  187.66 +
  187.67 +    nz = Ap [n] ;
  187.68 +    if (info)
  187.69 +    {
  187.70 +        Info [AMD_NZ] = nz ;
  187.71 +    }
  187.72 +    if (nz < 0)
  187.73 +    {
  187.74 +        if (info) Info [AMD_STATUS] = AMD_INVALID ;
  187.75 +        return (AMD_INVALID) ;
  187.76 +    }
  187.77 +
  187.78 +    /* check if n or nz will cause size_t overflow */
  187.79 +    if (((size_t) n) >= SIZE_T_MAX / sizeof (Int)
  187.80 +     || ((size_t) nz) >= SIZE_T_MAX / sizeof (Int))
  187.81 +    {
  187.82 +        if (info) Info [AMD_STATUS] = AMD_OUT_OF_MEMORY ;
  187.83 +        return (AMD_OUT_OF_MEMORY) ;        /* problem too large */
  187.84 +    }
  187.85 +
  187.86 +    /* check the input matrix:  AMD_OK, AMD_INVALID, or AMD_OK_BUT_JUMBLED */
  187.87 +    status = AMD_valid (n, n, Ap, Ai) ;
  187.88 +
  187.89 +    if (status == AMD_INVALID)
  187.90 +    {
  187.91 +        if (info) Info [AMD_STATUS] = AMD_INVALID ;
  187.92 +        return (AMD_INVALID) ;      /* matrix is invalid */
  187.93 +    }
  187.94 +
  187.95 +    /* allocate two size-n integer workspaces */
  187.96 +    Len = amd_malloc (n * sizeof (Int)) ;
  187.97 +    Pinv = amd_malloc (n * sizeof (Int)) ;
  187.98 +    mem += n ;
  187.99 +    mem += n ;
 187.100 +    if (!Len || !Pinv)
 187.101 +    {
 187.102 +        /* :: out of memory :: */
 187.103 +        amd_free (Len) ;
 187.104 +        amd_free (Pinv) ;
 187.105 +        if (info) Info [AMD_STATUS] = AMD_OUT_OF_MEMORY ;
 187.106 +        return (AMD_OUT_OF_MEMORY) ;
 187.107 +    }
 187.108 +
 187.109 +    if (status == AMD_OK_BUT_JUMBLED)
 187.110 +    {
 187.111 +        /* sort the input matrix and remove duplicate entries */
 187.112 +        AMD_DEBUG1 (("Matrix is jumbled\n")) ;
 187.113 +        Rp = amd_malloc ((n+1) * sizeof (Int)) ;
 187.114 +        Ri = amd_malloc (MAX (nz,1) * sizeof (Int)) ;
 187.115 +        mem += (n+1) ;
 187.116 +        mem += MAX (nz,1) ;
 187.117 +        if (!Rp || !Ri)
 187.118 +        {
 187.119 +            /* :: out of memory :: */
 187.120 +            amd_free (Rp) ;
 187.121 +            amd_free (Ri) ;
 187.122 +            amd_free (Len) ;
 187.123 +            amd_free (Pinv) ;
 187.124 +            if (info) Info [AMD_STATUS] = AMD_OUT_OF_MEMORY ;
 187.125 +            return (AMD_OUT_OF_MEMORY) ;
 187.126 +        }
 187.127 +        /* use Len and Pinv as workspace to create R = A' */
 187.128 +        AMD_preprocess (n, Ap, Ai, Rp, Ri, Len, Pinv) ;
 187.129 +        Cp = Rp ;
 187.130 +        Ci = Ri ;
 187.131 +    }
 187.132 +    else
 187.133 +    {
 187.134 +        /* order the input matrix as-is.  No need to compute R = A' first */
 187.135 +        Rp = NULL ;
 187.136 +        Ri = NULL ;
 187.137 +        Cp = (Int *) Ap ;
 187.138 +        Ci = (Int *) Ai ;
 187.139 +    }
 187.140 +
 187.141 +    /* --------------------------------------------------------------------- */
 187.142 +    /* determine the symmetry and count off-diagonal nonzeros in A+A' */
 187.143 +    /* --------------------------------------------------------------------- */
 187.144 +
 187.145 +    nzaat = AMD_aat (n, Cp, Ci, Len, P, Info) ;
 187.146 +    AMD_DEBUG1 (("nzaat: %g\n", (double) nzaat)) ;
 187.147 +    ASSERT ((MAX (nz-n, 0) <= nzaat) && (nzaat <= 2 * (size_t) nz)) ;
 187.148 +
 187.149 +    /* --------------------------------------------------------------------- */
 187.150 +    /* allocate workspace for matrix, elbow room, and 6 size-n vectors */
 187.151 +    /* --------------------------------------------------------------------- */
 187.152 +
 187.153 +    S = NULL ;
 187.154 +    slen = nzaat ;                      /* space for matrix */
 187.155 +    ok = ((slen + nzaat/5) >= slen) ;   /* check for size_t overflow */
 187.156 +    slen += nzaat/5 ;                   /* add elbow room */
 187.157 +    for (i = 0 ; ok && i < 7 ; i++)
 187.158 +    {
 187.159 +        ok = ((slen + n) > slen) ;      /* check for size_t overflow */
 187.160 +        slen += n ;                     /* size-n elbow room, 6 size-n work */
 187.161 +    }
 187.162 +    mem += slen ;
 187.163 +    ok = ok && (slen < SIZE_T_MAX / sizeof (Int)) ; /* check for overflow */
 187.164 +    ok = ok && (slen < Int_MAX) ;       /* S[i] for Int i must be OK */
 187.165 +    if (ok)
 187.166 +    {
 187.167 +        S = amd_malloc (slen * sizeof (Int)) ;
 187.168 +    }
 187.169 +    AMD_DEBUG1 (("slen %g\n", (double) slen)) ;
 187.170 +    if (!S)
 187.171 +    {
 187.172 +        /* :: out of memory :: (or problem too large) */
 187.173 +        amd_free (Rp) ;
 187.174 +        amd_free (Ri) ;
 187.175 +        amd_free (Len) ;
 187.176 +        amd_free (Pinv) ;
 187.177 +        if (info) Info [AMD_STATUS] = AMD_OUT_OF_MEMORY ;
 187.178 +        return (AMD_OUT_OF_MEMORY) ;
 187.179 +    }
 187.180 +    if (info)
 187.181 +    {
 187.182 +        /* memory usage, in bytes. */
 187.183 +        Info [AMD_MEMORY] = mem * sizeof (Int) ;
 187.184 +    }
 187.185 +
 187.186 +    /* --------------------------------------------------------------------- */
 187.187 +    /* order the matrix */
 187.188 +    /* --------------------------------------------------------------------- */
 187.189 +
 187.190 +    AMD_1 (n, Cp, Ci, P, Pinv, Len, slen, S, Control, Info) ;
 187.191 +
 187.192 +    /* --------------------------------------------------------------------- */
 187.193 +    /* free the workspace */
 187.194 +    /* --------------------------------------------------------------------- */
 187.195 +
 187.196 +    amd_free (Rp) ;
 187.197 +    amd_free (Ri) ;
 187.198 +    amd_free (Len) ;
 187.199 +    amd_free (Pinv) ;
 187.200 +    amd_free (S) ;
 187.201 +    if (info) Info [AMD_STATUS] = status ;
 187.202 +    return (status) ;       /* successful ordering */
 187.203 +}
   188.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
   188.2 +++ b/deps/glpk/src/amd/amd_post_tree.c	Sun Nov 06 20:59:10 2011 +0100
   188.3 @@ -0,0 +1,121 @@
   188.4 +/* ========================================================================= */
   188.5 +/* === AMD_post_tree ======================================================= */
   188.6 +/* ========================================================================= */
   188.7 +
   188.8 +/* ------------------------------------------------------------------------- */
   188.9 +/* AMD, Copyright (c) Timothy A. Davis,                                      */
  188.10 +/* Patrick R. Amestoy, and Iain S. Duff.  See ../README.txt for License.     */
  188.11 +/* email: davis at cise.ufl.edu    CISE Department, Univ. of Florida.        */
  188.12 +/* web: http://www.cise.ufl.edu/research/sparse/amd                          */
  188.13 +/* ------------------------------------------------------------------------- */
  188.14 +
  188.15 +/* Post-ordering of a supernodal elimination tree.  */
  188.16 +
  188.17 +#include "amd_internal.h"
  188.18 +
  188.19 +GLOBAL Int AMD_post_tree
  188.20 +(
  188.21 +    Int root,                   /* root of the tree */
  188.22 +    Int k,                      /* start numbering at k */
  188.23 +    Int Child [ ],              /* input argument of size nn, undefined on
  188.24 +                                 * output.  Child [i] is the head of a link
  188.25 +                                 * list of all nodes that are children of node
  188.26 +                                 * i in the tree. */
  188.27 +    const Int Sibling [ ],      /* input argument of size nn, not modified.
  188.28 +                                 * If f is a node in the link list of the
  188.29 +                                 * children of node i, then Sibling [f] is the
  188.30 +                                 * next child of node i.
  188.31 +                                 */
  188.32 +    Int Order [ ],              /* output order, of size nn.  Order [i] = k
  188.33 +                                 * if node i is the kth node of the reordered
  188.34 +                                 * tree. */
  188.35 +    Int Stack [ ]               /* workspace of size nn */
  188.36 +#ifndef NDEBUG
  188.37 +    , Int nn                    /* nodes are in the range 0..nn-1. */
  188.38 +#endif
  188.39 +)
  188.40 +{
  188.41 +    Int f, head, h, i ;
  188.42 +
  188.43 +#if 0
  188.44 +    /* --------------------------------------------------------------------- */
  188.45 +    /* recursive version (Stack [ ] is not used): */
  188.46 +    /* --------------------------------------------------------------------- */
  188.47 +
  188.48 +    /* this is simple, but can caouse stack overflow if nn is large */
  188.49 +    i = root ;
  188.50 +    for (f = Child [i] ; f != EMPTY ; f = Sibling [f])
  188.51 +    {
  188.52 +        k = AMD_post_tree (f, k, Child, Sibling, Order, Stack, nn) ;
  188.53 +    }
  188.54 +    Order [i] = k++ ;
  188.55 +    return (k) ;
  188.56 +#endif
  188.57 +
  188.58 +    /* --------------------------------------------------------------------- */
  188.59 +    /* non-recursive version, using an explicit stack */
  188.60 +    /* --------------------------------------------------------------------- */
  188.61 +
  188.62 +    /* push root on the stack */
  188.63 +    head = 0 ;
  188.64 +    Stack [0] = root ;
  188.65 +
  188.66 +    while (head >= 0)
  188.67 +    {
  188.68 +        /* get head of stack */
  188.69 +        ASSERT (head < nn) ;
  188.70 +        i = Stack [head] ;
  188.71 +        AMD_DEBUG1 (("head of stack "ID" \n", i)) ;
  188.72 +        ASSERT (i >= 0 && i < nn) ;
  188.73 +
  188.74 +        if (Child [i] != EMPTY)
  188.75 +        {
  188.76 +            /* the children of i are not yet ordered */
  188.77 +            /* push each child onto the stack in reverse order */
  188.78 +            /* so that small ones at the head of the list get popped first */
  188.79 +            /* and the biggest one at the end of the list gets popped last */
  188.80 +            for (f = Child [i] ; f != EMPTY ; f = Sibling [f])
  188.81 +            {
  188.82 +                head++ ;
  188.83 +                ASSERT (head < nn) ;
  188.84 +                ASSERT (f >= 0 && f < nn) ;
  188.85 +            }
  188.86 +            h = head ;
  188.87 +            ASSERT (head < nn) ;
  188.88 +            for (f = Child [i] ; f != EMPTY ; f = Sibling [f])
  188.89 +            {
  188.90 +                ASSERT (h > 0) ;
  188.91 +                Stack [h--] = f ;
  188.92 +                AMD_DEBUG1 (("push "ID" on stack\n", f)) ;
  188.93 +                ASSERT (f >= 0 && f < nn) ;
  188.94 +            }
  188.95 +            ASSERT (Stack [h] == i) ;
  188.96 +
  188.97 +            /* delete child list so that i gets ordered next time we see it */
  188.98 +            Child [i] = EMPTY ;
  188.99 +        }
 188.100 +        else
 188.101 +        {
 188.102 +            /* the children of i (if there were any) are already ordered */
 188.103 +            /* remove i from the stack and order it.  Front i is kth front */
 188.104 +            head-- ;
 188.105 +            AMD_DEBUG1 (("pop "ID" order "ID"\n", i, k)) ;
 188.106 +            Order [i] = k++ ;
 188.107 +            ASSERT (k <= nn) ;
 188.108 +        }
 188.109 +
 188.110 +#ifndef NDEBUG
 188.111 +        AMD_DEBUG1 (("\nStack:")) ;
 188.112 +        for (h = head ; h >= 0 ; h--)
 188.113 +        {
 188.114 +            Int j = Stack [h] ;
 188.115 +            AMD_DEBUG1 ((" "ID, j)) ;
 188.116 +            ASSERT (j >= 0 && j < nn) ;
 188.117 +        }
 188.118 +        AMD_DEBUG1 (("\n\n")) ;
 188.119 +        ASSERT (head < nn) ;
 188.120 +#endif
 188.121 +
 188.122 +    }
 188.123 +    return (k) ;
 188.124 +}
   189.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
   189.2 +++ b/deps/glpk/src/amd/amd_postorder.c	Sun Nov 06 20:59:10 2011 +0100
   189.3 @@ -0,0 +1,207 @@
   189.4 +/* ========================================================================= */
   189.5 +/* === AMD_postorder ======================================================= */
   189.6 +/* ========================================================================= */
   189.7 +
   189.8 +/* ------------------------------------------------------------------------- */
   189.9 +/* AMD, Copyright (c) Timothy A. Davis,                                      */
  189.10 +/* Patrick R. Amestoy, and Iain S. Duff.  See ../README.txt for License.     */
  189.11 +/* email: davis at cise.ufl.edu    CISE Department, Univ. of Florida.        */
  189.12 +/* web: http://www.cise.ufl.edu/research/sparse/amd                          */
  189.13 +/* ------------------------------------------------------------------------- */
  189.14 +
  189.15 +/* Perform a postordering (via depth-first search) of an assembly tree. */
  189.16 +
  189.17 +#include "amd_internal.h"
  189.18 +
  189.19 +GLOBAL void AMD_postorder
  189.20 +(
  189.21 +    /* inputs, not modified on output: */
  189.22 +    Int nn,             /* nodes are in the range 0..nn-1 */
  189.23 +    Int Parent [ ],     /* Parent [j] is the parent of j, or EMPTY if root */
  189.24 +    Int Nv [ ],         /* Nv [j] > 0 number of pivots represented by node j,
  189.25 +                         * or zero if j is not a node. */
  189.26 +    Int Fsize [ ],      /* Fsize [j]: size of node j */
  189.27 +
  189.28 +    /* output, not defined on input: */
  189.29 +    Int Order [ ],      /* output post-order */
  189.30 +
  189.31 +    /* workspaces of size nn: */
  189.32 +    Int Child [ ],
  189.33 +    Int Sibling [ ],
  189.34 +    Int Stack [ ]
  189.35 +)
  189.36 +{
  189.37 +    Int i, j, k, parent, frsize, f, fprev, maxfrsize, bigfprev, bigf, fnext ;
  189.38 +
  189.39 +    for (j = 0 ; j < nn ; j++)
  189.40 +    {
  189.41 +        Child [j] = EMPTY ;
  189.42 +        Sibling [j] = EMPTY ;
  189.43 +    }
  189.44 +
  189.45 +    /* --------------------------------------------------------------------- */
  189.46 +    /* place the children in link lists - bigger elements tend to be last */
  189.47 +    /* --------------------------------------------------------------------- */
  189.48 +
  189.49 +    for (j = nn-1 ; j >= 0 ; j--)
  189.50 +    {
  189.51 +        if (Nv [j] > 0)
  189.52 +        {
  189.53 +            /* this is an element */
  189.54 +            parent = Parent [j] ;
  189.55 +            if (parent != EMPTY)
  189.56 +            {
  189.57 +                /* place the element in link list of the children its parent */
  189.58 +                /* bigger elements will tend to be at the end of the list */
  189.59 +                Sibling [j] = Child [parent] ;
  189.60 +                Child [parent] = j ;
  189.61 +            }
  189.62 +        }
  189.63 +    }
  189.64 +
  189.65 +#ifndef NDEBUG
  189.66 +    {
  189.67 +        Int nels, ff, nchild ;
  189.68 +        AMD_DEBUG1 (("\n\n================================ AMD_postorder:\n"));
  189.69 +        nels = 0 ;
  189.70 +        for (j = 0 ; j < nn ; j++)
  189.71 +        {
  189.72 +            if (Nv [j] > 0)
  189.73 +            {
  189.74 +                AMD_DEBUG1 (( ""ID" :  nels "ID" npiv "ID" size "ID
  189.75 +                    " parent "ID" maxfr "ID"\n", j, nels,
  189.76 +                    Nv [j], Fsize [j], Parent [j], Fsize [j])) ;
  189.77 +                /* this is an element */
  189.78 +                /* dump the link list of children */
  189.79 +                nchild = 0 ;
  189.80 +                AMD_DEBUG1 (("    Children: ")) ;
  189.81 +                for (ff = Child [j] ; ff != EMPTY ; ff = Sibling [ff])
  189.82 +                {
  189.83 +                    AMD_DEBUG1 ((ID" ", ff)) ;
  189.84 +                    ASSERT (Parent [ff] == j) ;
  189.85 +                    nchild++ ;
  189.86 +                    ASSERT (nchild < nn) ;
  189.87 +                }
  189.88 +                AMD_DEBUG1 (("\n")) ;
  189.89 +                parent = Parent [j] ;
  189.90 +                if (parent != EMPTY)
  189.91 +                {
  189.92 +                    ASSERT (Nv [parent] > 0) ;
  189.93 +                }
  189.94 +                nels++ ;
  189.95 +            }
  189.96 +        }
  189.97 +    }
  189.98 +    AMD_DEBUG1 (("\n\nGo through the children of each node, and put\n"
  189.99 +                 "the biggest child last in each list:\n")) ;
 189.100 +#endif
 189.101 +
 189.102 +    /* --------------------------------------------------------------------- */
 189.103 +    /* place the largest child last in the list of children for each node */
 189.104 +    /* --------------------------------------------------------------------- */
 189.105 +
 189.106 +    for (i = 0 ; i < nn ; i++)
 189.107 +    {
 189.108 +        if (Nv [i] > 0 && Child [i] != EMPTY)
 189.109 +        {
 189.110 +
 189.111 +#ifndef NDEBUG
 189.112 +            Int nchild ;
 189.113 +            AMD_DEBUG1 (("Before partial sort, element "ID"\n", i)) ;
 189.114 +            nchild = 0 ;
 189.115 +            for (f = Child [i] ; f != EMPTY ; f = Sibling [f])
 189.116 +            {
 189.117 +                ASSERT (f >= 0 && f < nn) ;
 189.118 +                AMD_DEBUG1 (("      f: "ID"  size: "ID"\n", f, Fsize [f])) ;
 189.119 +                nchild++ ;
 189.120 +                ASSERT (nchild <= nn) ;
 189.121 +            }
 189.122 +#endif
 189.123 +
 189.124 +            /* find the biggest element in the child list */
 189.125 +            fprev = EMPTY ;
 189.126 +            maxfrsize = EMPTY ;
 189.127 +            bigfprev = EMPTY ;
 189.128 +            bigf = EMPTY ;
 189.129 +            for (f = Child [i] ; f != EMPTY ; f = Sibling [f])
 189.130 +            {
 189.131 +                ASSERT (f >= 0 && f < nn) ;
 189.132 +                frsize = Fsize [f] ;
 189.133 +                if (frsize >= maxfrsize)
 189.134 +                {
 189.135 +                    /* this is the biggest seen so far */
 189.136 +                    maxfrsize = frsize ;
 189.137 +                    bigfprev = fprev ;
 189.138 +                    bigf = f ;
 189.139 +                }
 189.140 +                fprev = f ;
 189.141 +            }
 189.142 +            ASSERT (bigf != EMPTY) ;
 189.143 +
 189.144 +            fnext = Sibling [bigf] ;
 189.145 +
 189.146 +            AMD_DEBUG1 (("bigf "ID" maxfrsize "ID" bigfprev "ID" fnext "ID
 189.147 +                " fprev " ID"\n", bigf, maxfrsize, bigfprev, fnext, fprev)) ;
 189.148 +
 189.149 +            if (fnext != EMPTY)
 189.150 +            {
 189.151 +                /* if fnext is EMPTY then bigf is already at the end of list */
 189.152 +
 189.153 +                if (bigfprev == EMPTY)
 189.154 +                {
 189.155 +                    /* delete bigf from the element of the list */
 189.156 +                    Child [i] = fnext ;
 189.157 +                }
 189.158 +                else
 189.159 +                {
 189.160 +                    /* delete bigf from the middle of the list */
 189.161 +                    Sibling [bigfprev] = fnext ;
 189.162 +                }
 189.163 +
 189.164 +                /* put bigf at the end of the list */
 189.165 +                Sibling [bigf] = EMPTY ;
 189.166 +                ASSERT (Child [i] != EMPTY) ;
 189.167 +                ASSERT (fprev != bigf) ;
 189.168 +                ASSERT (fprev != EMPTY) ;
 189.169 +                Sibling [fprev] = bigf ;
 189.170 +            }
 189.171 +
 189.172 +#ifndef NDEBUG
 189.173 +            AMD_DEBUG1 (("After partial sort, element "ID"\n", i)) ;
 189.174 +            for (f = Child [i] ; f != EMPTY ; f = Sibling [f])
 189.175 +            {
 189.176 +                ASSERT (f >= 0 && f < nn) ;
 189.177 +                AMD_DEBUG1 (("        "ID"  "ID"\n", f, Fsize [f])) ;
 189.178 +                ASSERT (Nv [f] > 0) ;
 189.179 +                nchild-- ;
 189.180 +            }
 189.181 +            ASSERT (nchild == 0) ;
 189.182 +#endif
 189.183 +
 189.184 +        }
 189.185 +    }
 189.186 +
 189.187 +    /* --------------------------------------------------------------------- */
 189.188 +    /* postorder the assembly tree */
 189.189 +    /* --------------------------------------------------------------------- */
 189.190 +
 189.191 +    for (i = 0 ; i < nn ; i++)
 189.192 +    {
 189.193 +        Order [i] = EMPTY ;
 189.194 +    }
 189.195 +
 189.196 +    k = 0 ;
 189.197 +
 189.198 +    for (i = 0 ; i < nn ; i++)
 189.199 +    {
 189.200 +        if (Parent [i] == EMPTY && Nv [i] > 0)
 189.201 +        {
 189.202 +            AMD_DEBUG1 (("Root of assembly tree "ID"\n", i)) ;
 189.203 +            k = AMD_post_tree (i, k, Child, Sibling, Order, Stack
 189.204 +#ifndef NDEBUG
 189.205 +                , nn
 189.206 +#endif
 189.207 +                ) ;
 189.208 +        }
 189.209 +    }
 189.210 +}
   190.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
   190.2 +++ b/deps/glpk/src/amd/amd_preprocess.c	Sun Nov 06 20:59:10 2011 +0100
   190.3 @@ -0,0 +1,119 @@
   190.4 +/* ========================================================================= */
   190.5 +/* === AMD_preprocess ====================================================== */
   190.6 +/* ========================================================================= */
   190.7 +
   190.8 +/* ------------------------------------------------------------------------- */
   190.9 +/* AMD, Copyright (c) Timothy A. Davis,                                      */
  190.10 +/* Patrick R. Amestoy, and Iain S. Duff.  See ../README.txt for License.     */
  190.11 +/* email: davis at cise.ufl.edu    CISE Department, Univ. of Florida.        */
  190.12 +/* web: http://www.cise.ufl.edu/research/sparse/amd                          */
  190.13 +/* ------------------------------------------------------------------------- */
  190.14 +
  190.15 +/* Sorts, removes duplicate entries, and transposes from the nonzero pattern of
  190.16 + * a column-form matrix A, to obtain the matrix R.  The input matrix can have
  190.17 + * duplicate entries and/or unsorted columns (AMD_valid (n,Ap,Ai) must not be
  190.18 + * AMD_INVALID).
  190.19 + *
  190.20 + * This input condition is NOT checked.  This routine is not user-callable.
  190.21 + */
  190.22 +
  190.23 +#include "amd_internal.h"
  190.24 +
  190.25 +/* ========================================================================= */
  190.26 +/* === AMD_preprocess ====================================================== */
  190.27 +/* ========================================================================= */
  190.28 +
  190.29 +/* AMD_preprocess does not check its input for errors or allocate workspace.
  190.30 + * On input, the condition (AMD_valid (n,n,Ap,Ai) != AMD_INVALID) must hold.
  190.31 + */
  190.32 +
  190.33 +GLOBAL void AMD_preprocess
  190.34 +(
  190.35 +    Int n,              /* input matrix: A is n-by-n */
  190.36 +    const Int Ap [ ],   /* size n+1 */
  190.37 +    const Int Ai [ ],   /* size nz = Ap [n] */
  190.38 +
  190.39 +    /* output matrix R: */
  190.40 +    Int Rp [ ],         /* size n+1 */
  190.41 +    Int Ri [ ],         /* size nz (or less, if duplicates present) */
  190.42 +
  190.43 +    Int W [ ],          /* workspace of size n */
  190.44 +    Int Flag [ ]        /* workspace of size n */
  190.45 +)
  190.46 +{
  190.47 +
  190.48 +    /* --------------------------------------------------------------------- */
  190.49 +    /* local variables */
  190.50 +    /* --------------------------------------------------------------------- */
  190.51 +
  190.52 +    Int i, j, p, p2 ;
  190.53 +
  190.54 +    ASSERT (AMD_valid (n, n, Ap, Ai) != AMD_INVALID) ;
  190.55 +
  190.56 +    /* --------------------------------------------------------------------- */
  190.57 +    /* count the entries in each row of A (excluding duplicates) */
  190.58 +    /* --------------------------------------------------------------------- */
  190.59 +
  190.60 +    for (i = 0 ; i < n ; i++)
  190.61 +    {
  190.62 +        W [i] = 0 ;             /* # of nonzeros in row i (excl duplicates) */
  190.63 +        Flag [i] = EMPTY ;      /* Flag [i] = j if i appears in column j */
  190.64 +    }
  190.65 +    for (j = 0 ; j < n ; j++)
  190.66 +    {
  190.67 +        p2 = Ap [j+1] ;
  190.68 +        for (p = Ap [j] ; p < p2 ; p++)
  190.69 +        {
  190.70 +            i = Ai [p] ;
  190.71 +            if (Flag [i] != j)
  190.72 +            {
  190.73 +                /* row index i has not yet appeared in column j */
  190.74 +                W [i]++ ;           /* one more entry in row i */
  190.75 +                Flag [i] = j ;      /* flag row index i as appearing in col j*/
  190.76 +            }
  190.77 +        }
  190.78 +    }
  190.79 +
  190.80 +    /* --------------------------------------------------------------------- */
  190.81 +    /* compute the row pointers for R */
  190.82 +    /* --------------------------------------------------------------------- */
  190.83 +
  190.84 +    Rp [0] = 0 ;
  190.85 +    for (i = 0 ; i < n ; i++)
  190.86 +    {
  190.87 +        Rp [i+1] = Rp [i] + W [i] ;
  190.88 +    }
  190.89 +    for (i = 0 ; i < n ; i++)
  190.90 +    {
  190.91 +        W [i] = Rp [i] ;
  190.92 +        Flag [i] = EMPTY ;
  190.93 +    }
  190.94 +
  190.95 +    /* --------------------------------------------------------------------- */
  190.96 +    /* construct the row form matrix R */
  190.97 +    /* --------------------------------------------------------------------- */
  190.98 +
  190.99 +    /* R = row form of pattern of A */
 190.100 +    for (j = 0 ; j < n ; j++)
 190.101 +    {
 190.102 +        p2 = Ap [j+1] ;
 190.103 +        for (p = Ap [j] ; p < p2 ; p++)
 190.104 +        {
 190.105 +            i = Ai [p] ;
 190.106 +            if (Flag [i] != j)
 190.107 +            {
 190.108 +                /* row index i has not yet appeared in column j */
 190.109 +                Ri [W [i]++] = j ;  /* put col j in row i */
 190.110 +                Flag [i] = j ;      /* flag row index i as appearing in col j*/
 190.111 +            }
 190.112 +        }
 190.113 +    }
 190.114 +
 190.115 +#ifndef NDEBUG
 190.116 +    ASSERT (AMD_valid (n, n, Rp, Ri) == AMD_OK) ;
 190.117 +    for (j = 0 ; j < n ; j++)
 190.118 +    {
 190.119 +        ASSERT (W [j] == Rp [j+1]) ;
 190.120 +    }
 190.121 +#endif
 190.122 +}
   191.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
   191.2 +++ b/deps/glpk/src/amd/amd_valid.c	Sun Nov 06 20:59:10 2011 +0100
   191.3 @@ -0,0 +1,93 @@
   191.4 +/* ========================================================================= */
   191.5 +/* === AMD_valid =========================================================== */
   191.6 +/* ========================================================================= */
   191.7 +
   191.8 +/* ------------------------------------------------------------------------- */
   191.9 +/* AMD, Copyright (c) Timothy A. Davis,                                      */
  191.10 +/* Patrick R. Amestoy, and Iain S. Duff.  See ../README.txt for License.     */
  191.11 +/* email: davis at cise.ufl.edu    CISE Department, Univ. of Florida.        */
  191.12 +/* web: http://www.cise.ufl.edu/research/sparse/amd                          */
  191.13 +/* ------------------------------------------------------------------------- */
  191.14 +
  191.15 +/* Check if a column-form matrix is valid or not.  The matrix A is
  191.16 + * n_row-by-n_col.  The row indices of entries in column j are in
  191.17 + * Ai [Ap [j] ... Ap [j+1]-1].  Required conditions are:
  191.18 + *
  191.19 + *      n_row >= 0
  191.20 + *      n_col >= 0
  191.21 + *      nz = Ap [n_col] >= 0        number of entries in the matrix
  191.22 + *      Ap [0] == 0
  191.23 + *      Ap [j] <= Ap [j+1] for all j in the range 0 to n_col.
  191.24 + *      Ai [0 ... nz-1] must be in the range 0 to n_row-1.
  191.25 + *
  191.26 + * If any of the above conditions hold, AMD_INVALID is returned.  If the
  191.27 + * following condition holds, AMD_OK_BUT_JUMBLED is returned (a warning,
  191.28 + * not an error):
  191.29 + *
  191.30 + *      row indices in Ai [Ap [j] ... Ap [j+1]-1] are not sorted in ascending
  191.31 + *          order, and/or duplicate entries exist.
  191.32 + *
  191.33 + * Otherwise, AMD_OK is returned.
  191.34 + *
  191.35 + * In v1.2 and earlier, this function returned TRUE if the matrix was valid
  191.36 + * (now returns AMD_OK), or FALSE otherwise (now returns AMD_INVALID or
  191.37 + * AMD_OK_BUT_JUMBLED).
  191.38 + */
  191.39 +
  191.40 +#include "amd_internal.h"
  191.41 +
  191.42 +GLOBAL Int AMD_valid
  191.43 +(
  191.44 +    /* inputs, not modified on output: */
  191.45 +    Int n_row,          /* A is n_row-by-n_col */
  191.46 +    Int n_col,
  191.47 +    const Int Ap [ ],   /* column pointers of A, of size n_col+1 */
  191.48 +    const Int Ai [ ]    /* row indices of A, of size nz = Ap [n_col] */
  191.49 +)
  191.50 +{
  191.51 +    Int nz, j, p1, p2, ilast, i, p, result = AMD_OK ;
  191.52 +
  191.53 +    if (n_row < 0 || n_col < 0 || Ap == NULL || Ai == NULL)
  191.54 +    {
  191.55 +        return (AMD_INVALID) ;
  191.56 +    }
  191.57 +    nz = Ap [n_col] ;
  191.58 +    if (Ap [0] != 0 || nz < 0)
  191.59 +    {
  191.60 +        /* column pointers must start at Ap [0] = 0, and Ap [n] must be >= 0 */
  191.61 +        AMD_DEBUG0 (("column 0 pointer bad or nz < 0\n")) ;
  191.62 +        return (AMD_INVALID) ;
  191.63 +    }
  191.64 +    for (j = 0 ; j < n_col ; j++)
  191.65 +    {
  191.66 +        p1 = Ap [j] ;
  191.67 +        p2 = Ap [j+1] ;
  191.68 +        AMD_DEBUG2 (("\nColumn: "ID" p1: "ID" p2: "ID"\n", j, p1, p2)) ;
  191.69 +        if (p1 > p2)
  191.70 +        {
  191.71 +            /* column pointers must be ascending */
  191.72 +            AMD_DEBUG0 (("column "ID" pointer bad\n", j)) ;
  191.73 +            return (AMD_INVALID) ;
  191.74 +        }
  191.75 +        ilast = EMPTY ;
  191.76 +        for (p = p1 ; p < p2 ; p++)
  191.77 +        {
  191.78 +            i = Ai [p] ;
  191.79 +            AMD_DEBUG3 (("row: "ID"\n", i)) ;
  191.80 +            if (i < 0 || i >= n_row)
  191.81 +            {
  191.82 +                /* row index out of range */
  191.83 +                AMD_DEBUG0 (("index out of range, col "ID" row "ID"\n", j, i));
  191.84 +                return (AMD_INVALID) ;
  191.85 +            }
  191.86 +            if (i <= ilast)
  191.87 +            {
  191.88 +                /* row index unsorted, or duplicate entry present */
  191.89 +                AMD_DEBUG1 (("index unsorted/dupl col "ID" row "ID"\n", j, i));
  191.90 +                result = AMD_OK_BUT_JUMBLED ;
  191.91 +            }
  191.92 +            ilast = i ;
  191.93 +        }
  191.94 +    }
  191.95 +    return (result) ;
  191.96 +}
   192.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
   192.2 +++ b/deps/glpk/src/colamd/COPYING	Sun Nov 06 20:59:10 2011 +0100
   192.3 @@ -0,0 +1,502 @@
   192.4 +                  GNU LESSER GENERAL PUBLIC LICENSE
   192.5 +                       Version 2.1, February 1999
   192.6 +
   192.7 + Copyright (C) 1991, 1999 Free Software Foundation, Inc.
   192.8 +     51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
   192.9 + Everyone is permitted to copy and distribute verbatim copies
  192.10 + of this license document, but changing it is not allowed.
  192.11 +
  192.12 +[This is the first released version of the Lesser GPL.  It also counts
  192.13 + as the successor of the GNU Library Public License, version 2, hence
  192.14 + the version number 2.1.]
  192.15 +
  192.16 +                            Preamble
  192.17 +
  192.18 +  The licenses for most software are designed to take away your
  192.19 +freedom to share and change it.  By contrast, the GNU General Public
  192.20 +Licenses are intended to guarantee your freedom to share and change
  192.21 +free software--to make sure the software is free for all its users.
  192.22 +
  192.23 +  This license, the Lesser General Public License, applies to some
  192.24 +specially designated software packages--typically libraries--of the
  192.25 +Free Software Foundation and other authors who decide to use it.  You
  192.26 +can use it too, but we suggest you first think carefully about whether
  192.27 +this license or the ordinary General Public License is the better
  192.28 +strategy to use in any particular case, based on the explanations below.
  192.29 +
  192.30 +  When we speak of free software, we are referring to freedom of use,
  192.31 +not price.  Our General Public Licenses are designed to make sure that
  192.32 +you have the freedom to distribute copies of free software (and charge
  192.33 +for this service if you wish); that you receive source code or can get
  192.34 +it if you want it; that you can change the software and use pieces of
  192.35 +it in new free programs; and that you are informed that you can do
  192.36 +these things.
  192.37 +
  192.38 +  To protect your rights, we need to make restrictions that forbid
  192.39 +distributors to deny you these rights or to ask you to surrender these
  192.40 +rights.  These restrictions translate to certain responsibilities for
  192.41 +you if you distribute copies of the library or if you modify it.
  192.42 +
  192.43 +  For example, if you distribute copies of the library, whether gratis
  192.44 +or for a fee, you must give the recipients all the rights that we gave
  192.45 +you.  You must make sure that they, too, receive or can get the source
  192.46 +code.  If you link other code with the library, you must provide
  192.47 +complete object files to the recipients, so that they can relink them
  192.48 +with the library after making changes to the library and recompiling
  192.49 +it.  And you must show them these terms so they know their rights.
  192.50 +
  192.51 +  We protect your rights with a two-step method: (1) we copyright the
  192.52 +library, and (2) we offer you this license, which gives you legal
  192.53 +permission to copy, distribute and/or modify the library.
  192.54 +
  192.55 +  To protect each distributor, we want to make it very clear that
  192.56 +there is no warranty for the free library.  Also, if the library is
  192.57 +modified by someone else and passed on, the recipients should know
  192.58 +that what they have is not the original version, so that the original
  192.59 +author's reputation will not be affected by problems that might be
  192.60 +introduced by others.
  192.61 +
  192.62 +  Finally, software patents pose a constant threat to the existence of
  192.63 +any free program.  We wish to make sure that a company cannot
  192.64 +effectively restrict the users of a free program by obtaining a
  192.65 +restrictive license from a patent holder.  Therefore, we insist that
  192.66 +any patent license obtained for a version of the library must be
  192.67 +consistent with the full freedom of use specified in this license.
  192.68 +
  192.69 +  Most GNU software, including some libraries, is covered by the
  192.70 +ordinary GNU General Public License.  This license, the GNU Lesser
  192.71 +General Public License, applies to certain designated libraries, and
  192.72 +is quite different from the ordinary General Public License.  We use
  192.73 +this license for certain libraries in order to permit linking those
  192.74 +libraries into non-free programs.
  192.75 +
  192.76 +  When a program is linked with a library, whether statically or using
  192.77 +a shared library, the combination of the two is legally speaking a
  192.78 +combined work, a derivative of the original library.  The ordinary
  192.79 +General Public License therefore permits such linking only if the
  192.80 +entire combination fits its criteria of freedom.  The Lesser General
  192.81 +Public License permits more lax criteria for linking other code with
  192.82 +the library.
  192.83 +
  192.84 +  We call this license the "Lesser" General Public License because it
  192.85 +does Less to protect the user's freedom than the ordinary General
  192.86 +Public License.  It also provides other free software developers Less
  192.87 +of an advantage over competing non-free programs.  These disadvantages
  192.88 +are the reason we use the ordinary General Public License for many
  192.89 +libraries.  However, the Lesser license provides advantages in certain
  192.90 +special circumstances.
  192.91 +
  192.92 +  For example, on rare occasions, there may be a special need to
  192.93 +encourage the widest possible use of a certain library, so that it becomes
  192.94 +a de-facto standard.  To achieve this, non-free programs must be
  192.95 +allowed to use the library.  A more frequent case is that a free
  192.96 +library does the same job as widely used non-free libraries.  In this
  192.97 +case, there is little to gain by limiting the free library to free
  192.98 +software only, so we use the Lesser General Public License.
  192.99 +
 192.100 +  In other cases, permission to use a particular library in non-free
 192.101 +programs enables a greater number of people to use a large body of
 192.102 +free software.  For example, permission to use the GNU C Library in
 192.103 +non-free programs enables many more people to use the whole GNU
 192.104 +operating system, as well as its variant, the GNU/Linux operating
 192.105 +system.
 192.106 +
 192.107 +  Although the Lesser General Public License is Less protective of the
 192.108 +users' freedom, it does ensure that the user of a program that is
 192.109 +linked with the Library has the freedom and the wherewithal to run
 192.110 +that program using a modified version of the Library.
 192.111 +
 192.112 +  The precise terms and conditions for copying, distribution and
 192.113 +modification follow.  Pay close attention to the difference between a
 192.114 +"work based on the library" and a "work that uses the library".  The
 192.115 +former contains code derived from the library, whereas the latter must
 192.116 +be combined with the library in order to run.
 192.117 +
 192.118 +                  GNU LESSER GENERAL PUBLIC LICENSE
 192.119 +   TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
 192.120 +
 192.121 +  0. This License Agreement applies to any software library or other
 192.122 +program which contains a notice placed by the copyright holder or
 192.123 +other authorized party saying it may be distributed under the terms of
 192.124 +this Lesser General Public License (also called "this License").
 192.125 +Each licensee is addressed as "you".
 192.126 +
 192.127 +  A "library" means a collection of software functions and/or data
 192.128 +prepared so as to be conveniently linked with application programs
 192.129 +(which use some of those functions and data) to form executables.
 192.130 +
 192.131 +  The "Library", below, refers to any such software library or work
 192.132 +which has been distributed under these terms.  A "work based on the
 192.133 +Library" means either the Library or any derivative work under
 192.134 +copyright law: that is to say, a work containing the Library or a
 192.135 +portion of it, either verbatim or with modifications and/or translated
 192.136 +straightforwardly into another language.  (Hereinafter, translation is
 192.137 +included without limitation in the term "modification".)
 192.138 +
 192.139 +  "Source code" for a work means the preferred form of the work for
 192.140 +making modifications to it.  For a library, complete source code means
 192.141 +all the source code for all modules it contains, plus any associated
 192.142 +interface definition files, plus the scripts used to control compilation
 192.143 +and installation of the library.
 192.144 +
 192.145 +  Activities other than copying, distribution and modification are not
 192.146 +covered by this License; they are outside its scope.  The act of
 192.147 +running a program using the Library is not restricted, and output from
 192.148 +such a program is covered only if its contents constitute a work based
 192.149 +on the Library (independent of the use of the Library in a tool for
 192.150 +writing it).  Whether that is true depends on what the Library does
 192.151 +and what the program that uses the Library does.
 192.152 +
 192.153 +  1. You may copy and distribute verbatim copies of the Library's
 192.154 +complete source code as you receive it, in any medium, provided that
 192.155 +you conspicuously and appropriately publish on each copy an
 192.156 +appropriate copyright notice and disclaimer of warranty; keep intact
 192.157 +all the notices that refer to this License and to the absence of any
 192.158 +warranty; and distribute a copy of this License along with the
 192.159 +Library.
 192.160 +
 192.161 +  You may charge a fee for the physical act of transferring a copy,
 192.162 +and you may at your option offer warranty protection in exchange for a
 192.163 +fee.
 192.164 +
 192.165 +  2. You may modify your copy or copies of the Library or any portion
 192.166 +of it, thus forming a work based on the Library, and copy and
 192.167 +distribute such modifications or work under the terms of Section 1
 192.168 +above, provided that you also meet all of these conditions:
 192.169 +
 192.170 +    a) The modified work must itself be a software library.
 192.171 +
 192.172 +    b) You must cause the files modified to carry prominent notices
 192.173 +    stating that you changed the files and the date of any change.
 192.174 +
 192.175 +    c) You must cause the whole of the work to be licensed at no
 192.176 +    charge to all third parties under the terms of this License.
 192.177 +
 192.178 +    d) If a facility in the modified Library refers to a function or a
 192.179 +    table of data to be supplied by an application program that uses
 192.180 +    the facility, other than as an argument passed when the facility
 192.181 +    is invoked, then you must make a good faith effort to ensure that,
 192.182 +    in the event an application does not supply such function or
 192.183 +    table, the facility still operates, and performs whatever part of
 192.184 +    its purpose remains meaningful.
 192.185 +
 192.186 +    (For example, a function in a library to compute square roots has
 192.187 +    a purpose that is entirely well-defined independent of the
 192.188 +    application.  Therefore, Subsection 2d requires that any
 192.189 +    application-supplied function or table used by this function must
 192.190 +    be optional: if the application does not supply it, the square
 192.191 +    root function must still compute square roots.)
 192.192 +
 192.193 +These requirements apply to the modified work as a whole.  If
 192.194 +identifiable sections of that work are not derived from the Library,
 192.195 +and can be reasonably considered independent and separate works in
 192.196 +themselves, then this License, and its terms, do not apply to those
 192.197 +sections when you distribute them as separate works.  But when you
 192.198 +distribute the same sections as part of a whole which is a work based
 192.199 +on the Library, the distribution of the whole must be on the terms of
 192.200 +this License, whose permissions for other licensees extend to the
 192.201 +entire whole, and thus to each and every part regardless of who wrote
 192.202 +it.
 192.203 +
 192.204 +Thus, it is not the intent of this section to claim rights or contest
 192.205 +your rights to work written entirely by you; rather, the intent is to
 192.206 +exercise the right to control the distribution of derivative or
 192.207 +collective works based on the Library.
 192.208 +
 192.209 +In addition, mere aggregation of another work not based on the Library
 192.210 +with the Library (or with a work based on the Library) on a volume of
 192.211 +a storage or distribution medium does not bring the other work under
 192.212 +the scope of this License.
 192.213 +
 192.214 +  3. You may opt to apply the terms of the ordinary GNU General Public
 192.215 +License instead of this License to a given copy of the Library.  To do
 192.216 +this, you must alter all the notices that refer to this License, so
 192.217 +that they refer to the ordinary GNU General Public License, version 2,
 192.218 +instead of to this License.  (If a newer version than version 2 of the
 192.219 +ordinary GNU General Public License has appeared, then you can specify
 192.220 +that version instead if you wish.)  Do not make any other change in
 192.221 +these notices.
 192.222 +
 192.223 +  Once this change is made in a given copy, it is irreversible for
 192.224 +that copy, so the ordinary GNU General Public License applies to all
 192.225 +subsequent copies and derivative works made from that copy.
 192.226 +
 192.227 +  This option is useful when you wish to copy part of the code of
 192.228 +the Library into a program that is not a library.
 192.229 +
 192.230 +  4. You may copy and distribute the Library (or a portion or
 192.231 +derivative of it, under Section 2) in object code or executable form
 192.232 +under the terms of Sections 1 and 2 above provided that you accompany
 192.233 +it with the complete corresponding machine-readable source code, which
 192.234 +must be distributed under the terms of Sections 1 and 2 above on a
 192.235 +medium customarily used for software interchange.
 192.236 +
 192.237 +  If distribution of object code is made by offering access to copy
 192.238 +from a designated place, then offering equivalent access to copy the
 192.239 +source code from the same place satisfies the requirement to
 192.240 +distribute the source code, even though third parties are not
 192.241 +compelled to copy the source along with the object code.
 192.242 +
 192.243 +  5. A program that contains no derivative of any portion of the
 192.244 +Library, but is designed to work with the Library by being compiled or
 192.245 +linked with it, is called a "work that uses the Library".  Such a
 192.246 +work, in isolation, is not a derivative work of the Library, and
 192.247 +therefore falls outside the scope of this License.
 192.248 +
 192.249 +  However, linking a "work that uses the Library" with the Library
 192.250 +creates an executable that is a derivative of the Library (because it
 192.251 +contains portions of the Library), rather than a "work that uses the
 192.252 +library".  The executable is therefore covered by this License.
 192.253 +Section 6 states terms for distribution of such executables.
 192.254 +
 192.255 +  When a "work that uses the Library" uses material from a header file
 192.256 +that is part of the Library, the object code for the work may be a
 192.257 +derivative work of the Library even though the source code is not.
 192.258 +Whether this is true is especially significant if the work can be
 192.259 +linked without the Library, or if the work is itself a library.  The
 192.260 +threshold for this to be true is not precisely defined by law.
 192.261 +
 192.262 +  If such an object file uses only numerical parameters, data
 192.263 +structure layouts and accessors, and small macros and small inline
 192.264 +functions (ten lines or less in length), then the use of the object
 192.265 +file is unrestricted, regardless of whether it is legally a derivative
 192.266 +work.  (Executables containing this object code plus portions of the
 192.267 +Library will still fall under Section 6.)
 192.268 +
 192.269 +  Otherwise, if the work is a derivative of the Library, you may
 192.270 +distribute the object code for the work under the terms of Section 6.
 192.271 +Any executables containing that work also fall under Section 6,
 192.272 +whether or not they are linked directly with the Library itself.
 192.273 +
 192.274 +  6. As an exception to the Sections above, you may also combine or
 192.275 +link a "work that uses the Library" with the Library to produce a
 192.276 +work containing portions of the Library, and distribute that work
 192.277 +under terms of your choice, provided that the terms permit
 192.278 +modification of the work for the customer's own use and reverse
 192.279 +engineering for debugging such modifications.
 192.280 +
 192.281 +  You must give prominent notice with each copy of the work that the
 192.282 +Library is used in it and that the Library and its use are covered by
 192.283 +this License.  You must supply a copy of this License.  If the work
 192.284 +during execution displays copyright notices, you must include the
 192.285 +copyright notice for the Library among them, as well as a reference
 192.286 +directing the user to the copy of this License.  Also, you must do one
 192.287 +of these things:
 192.288 +
 192.289 +    a) Accompany the work with the complete corresponding
 192.290 +    machine-readable source code for the Library including whatever
 192.291 +    changes were used in the work (which must be distributed under
 192.292 +    Sections 1 and 2 above); and, if the work is an executable linked
 192.293 +    with the Library, with the complete machine-readable "work that
 192.294 +    uses the Library", as object code and/or source code, so that the
 192.295 +    user can modify the Library and then relink to produce a modified
 192.296 +    executable containing the modified Library.  (It is understood
 192.297 +    that the user who changes the contents of definitions files in the
 192.298 +    Library will not necessarily be able to recompile the application
 192.299 +    to use the modified definitions.)
 192.300 +
 192.301 +    b) Use a suitable shared library mechanism for linking with the
 192.302 +    Library.  A suitable mechanism is one that (1) uses at run time a
 192.303 +    copy of the library already present on the user's computer system,
 192.304 +    rather than copying library functions into the executable, and (2)
 192.305 +    will operate properly with a modified version of the library, if
 192.306 +    the user installs one, as long as the modified version is
 192.307 +    interface-compatible with the version that the work was made with.
 192.308 +
 192.309 +    c) Accompany the work with a written offer, valid for at
 192.310 +    least three years, to give the same user the materials
 192.311 +    specified in Subsection 6a, above, for a charge no more
 192.312 +    than the cost of performing this distribution.
 192.313 +
 192.314 +    d) If distribution of the work is made by offering access to copy
 192.315 +    from a designated place, offer equivalent access to copy the above
 192.316 +    specified materials from the same place.
 192.317 +
 192.318 +    e) Verify that the user has already received a copy of these
 192.319 +    materials or that you have already sent this user a copy.
 192.320 +
 192.321 +  For an executable, the required form of the "work that uses the
 192.322 +Library" must include any data and utility programs needed for
 192.323 +reproducing the executable from it.  However, as a special exception,
 192.324 +the materials to be distributed need not include anything that is
 192.325 +normally distributed (in either source or binary form) with the major
 192.326 +components (compiler, kernel, and so on) of the operating system on
 192.327 +which the executable runs, unless that component itself accompanies
 192.328 +the executable.
 192.329 +
 192.330 +  It may happen that this requirement contradicts the license
 192.331 +restrictions of other proprietary libraries that do not normally
 192.332 +accompany the operating system.  Such a contradiction means you cannot
 192.333 +use both them and the Library together in an executable that you
 192.334 +distribute.
 192.335 +
 192.336 +  7. You may place library facilities that are a work based on the
 192.337 +Library side-by-side in a single library together with other library
 192.338 +facilities not covered by this License, and distribute such a combined
 192.339 +library, provided that the separate distribution of the work based on
 192.340 +the Library and of the other library facilities is otherwise
 192.341 +permitted, and provided that you do these two things:
 192.342 +
 192.343 +    a) Accompany the combined library with a copy of the same work
 192.344 +    based on the Library, uncombined with any other library
 192.345 +    facilities.  This must be distributed under the terms of the
 192.346 +    Sections above.
 192.347 +
 192.348 +    b) Give prominent notice with the combined library of the fact
 192.349 +    that part of it is a work based on the Library, and explaining
 192.350 +    where to find the accompanying uncombined form of the same work.
 192.351 +
 192.352 +  8. You may not copy, modify, sublicense, link with, or distribute
 192.353 +the Library except as expressly provided under this License.  Any
 192.354 +attempt otherwise to copy, modify, sublicense, link with, or
 192.355 +distribute the Library is void, and will automatically terminate your
 192.356 +rights under this License.  However, parties who have received copies,
 192.357 +or rights, from you under this License will not have their licenses
 192.358 +terminated so long as such parties remain in full compliance.
 192.359 +
 192.360 +  9. You are not required to accept this License, since you have not
 192.361 +signed it.  However, nothing else grants you permission to modify or
 192.362 +distribute the Library or its derivative works.  These actions are
 192.363 +prohibited by law if you do not accept this License.  Therefore, by
 192.364 +modifying or distributing the Library (or any work based on the
 192.365 +Library), you indicate your acceptance of this License to do so, and
 192.366 +all its terms and conditions for copying, distributing or modifying
 192.367 +the Library or works based on it.
 192.368 +
 192.369 +  10. Each time you redistribute the Library (or any work based on the
 192.370 +Library), the recipient automatically receives a license from the
 192.371 +original licensor to copy, distribute, link with or modify the Library
 192.372 +subject to these terms and conditions.  You may not impose any further
 192.373 +restrictions on the recipients' exercise of the rights granted herein.
 192.374 +You are not responsible for enforcing compliance by third parties with
 192.375 +this License.
 192.376 +
 192.377 +  11. If, as a consequence of a court judgment or allegation of patent
 192.378 +infringement or for any other reason (not limited to patent issues),
 192.379 +conditions are imposed on you (whether by court order, agreement or
 192.380 +otherwise) that contradict the conditions of this License, they do not
 192.381 +excuse you from the conditions of this License.  If you cannot
 192.382 +distribute so as to satisfy simultaneously your obligations under this
 192.383 +License and any other pertinent obligations, then as a consequence you
 192.384 +may not distribute the Library at all.  For example, if a patent
 192.385 +license would not permit royalty-free redistribution of the Library by
 192.386 +all those who receive copies directly or indirectly through you, then
 192.387 +the only way you could satisfy both it and this License would be to
 192.388 +refrain entirely from distribution of the Library.
 192.389 +
 192.390 +If any portion of this section is held invalid or unenforceable under any
 192.391 +particular circumstance, the balance of the section is intended to apply,
 192.392 +and the section as a whole is intended to apply in other circumstances.
 192.393 +
 192.394 +It is not the purpose of this section to induce you to infringe any
 192.395 +patents or other property right claims or to contest validity of any
 192.396 +such claims; this section has the sole purpose of protecting the
 192.397 +integrity of the free software distribution system which is
 192.398 +implemented by public license practices.  Many people have made
 192.399 +generous contributions to the wide range of software distributed
 192.400 +through that system in reliance on consistent application of that
 192.401 +system; it is up to the author/donor to decide if he or she is willing
 192.402 +to distribute software through any other system and a licensee cannot
 192.403 +impose that choice.
 192.404 +
 192.405 +This section is intended to make thoroughly clear what is believed to
 192.406 +be a consequence of the rest of this License.
 192.407 +
 192.408 +  12. If the distribution and/or use of the Library is restricted in
 192.409 +certain countries either by patents or by copyrighted interfaces, the
 192.410 +original copyright holder who places the Library under this License may add
 192.411 +an explicit geographical distribution limitation excluding those countries,
 192.412 +so that distribution is permitted only in or among countries not thus
 192.413 +excluded.  In such case, this License incorporates the limitation as if
 192.414 +written in the body of this License.
 192.415 +
 192.416 +  13. The Free Software Foundation may publish revised and/or new
 192.417 +versions of the Lesser General Public License from time to time.
 192.418 +Such new versions will be similar in spirit to the present version,
 192.419 +but may differ in detail to address new problems or concerns.
 192.420 +
 192.421 +Each version is given a distinguishing version number.  If the Library
 192.422 +specifies a version number of this License which applies to it and
 192.423 +"any later version", you have the option of following the terms and
 192.424 +conditions either of that version or of any later version published by
 192.425 +the Free Software Foundation.  If the Library does not specify a
 192.426 +license version number, you may choose any version ever published by
 192.427 +the Free Software Foundation.
 192.428 +
 192.429 +  14. If you wish to incorporate parts of the Library into other free
 192.430 +programs whose distribution conditions are incompatible with these,
 192.431 +write to the author to ask for permission.  For software which is
 192.432 +copyrighted by the Free Software Foundation, write to the Free
 192.433 +Software Foundation; we sometimes make exceptions for this.  Our
 192.434 +decision will be guided by the two goals of preserving the free status
 192.435 +of all derivatives of our free software and of promoting the sharing
 192.436 +and reuse of software generally.
 192.437 +
 192.438 +                            NO WARRANTY
 192.439 +
 192.440 +  15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO
 192.441 +WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW.
 192.442 +EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR
 192.443 +OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY
 192.444 +KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE
 192.445 +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
 192.446 +PURPOSE.  THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE
 192.447 +LIBRARY IS WITH YOU.  SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME
 192.448 +THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
 192.449 +
 192.450 +  16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN
 192.451 +WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY
 192.452 +AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU
 192.453 +FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR
 192.454 +CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE
 192.455 +LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING
 192.456 +RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A
 192.457 +FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF
 192.458 +SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
 192.459 +DAMAGES.
 192.460 +
 192.461 +                     END OF TERMS AND CONDITIONS
 192.462 +
 192.463 +           How to Apply These Terms to Your New Libraries
 192.464 +
 192.465 +  If you develop a new library, and you want it to be of the greatest
 192.466 +possible use to the public, we recommend making it free software that
 192.467 +everyone can redistribute and change.  You can do so by permitting
 192.468 +redistribution under these terms (or, alternatively, under the terms of the
 192.469 +ordinary General Public License).
 192.470 +
 192.471 +  To apply these terms, attach the following notices to the library.  It is
 192.472 +safest to attach them to the start of each source file to most effectively
 192.473 +convey the exclusion of warranty; and each file should have at least the
 192.474 +"copyright" line and a pointer to where the full notice is found.
 192.475 +
 192.476 +    <one line to give the library's name and a brief idea of what it does.>
 192.477 +    Copyright (C) <year>  <name of author>
 192.478 +
 192.479 +    This library is free software; you can redistribute it and/or
 192.480 +    modify it under the terms of the GNU Lesser General Public
 192.481 +    License as published by the Free Software Foundation; either
 192.482 +    version 2.1 of the License, or (at your option) any later version.
 192.483 +
 192.484 +    This library is distributed in the hope that it will be useful,
 192.485 +    but WITHOUT ANY WARRANTY; without even the implied warranty of
 192.486 +    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 192.487 +    Lesser General Public License for more details.
 192.488 +
 192.489 +    You should have received a copy of the GNU Lesser General Public
 192.490 +    License along with this library; if not, write to the Free Software
 192.491 +    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 192.492 +
 192.493 +Also add information on how to contact you by electronic and paper mail.
 192.494 +
 192.495 +You should also get your employer (if you work as a programmer) or your
 192.496 +school, if any, to sign a "copyright disclaimer" for the library, if
 192.497 +necessary.  Here is a sample; alter the names:
 192.498 +
 192.499 +  Yoyodyne, Inc., hereby disclaims all copyright interest in the
 192.500 +  library `Frob' (a library for tweaking knobs) written by James Random Hacker.
 192.501 +
 192.502 +  <signature of Ty Coon>, 1 April 1990
 192.503 +  Ty Coon, President of Vice
 192.504 +
 192.505 +That's all there is to it!
   193.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
   193.2 +++ b/deps/glpk/src/colamd/README	Sun Nov 06 20:59:10 2011 +0100
   193.3 @@ -0,0 +1,98 @@
   193.4 +NOTE: Files in this subdirectory are NOT part of the GLPK package, but
   193.5 +      are used with GLPK.
   193.6 +
   193.7 +      The original code was modified according to GLPK requirements by
   193.8 +      Andrew Makhorin <mao@gnu.org>.
   193.9 +************************************************************************
  193.10 +COLAMD/SYMAMD Version 2.7, Copyright (C) 1998-2007, Timothy A. Davis,
  193.11 +All Rights Reserved.
  193.12 +
  193.13 +Description:
  193.14 +
  193.15 +   colamd:  an approximate minimum degree column ordering algorithm,
  193.16 +            for LU factorization of symmetric or unsymmetric matrices,
  193.17 +            QR factorization, least squares, interior point methods for
  193.18 +            linear programming problems, and other related problems.
  193.19 +
  193.20 +   symamd:  an approximate minimum degree ordering algorithm for
  193.21 +            Cholesky factorization of symmetric matrices.
  193.22 +
  193.23 +Purpose:
  193.24 +
  193.25 +   Colamd computes a permutation Q such that the Cholesky factorization
  193.26 +   of (AQ)'(AQ) has less fill-in and requires fewer floating point
  193.27 +   operations than A'A.  This also provides a good ordering for sparse
  193.28 +   partial pivoting methods, P(AQ) = LU, where Q is computed prior to
  193.29 +   numerical factorization, and P is computed during numerical
  193.30 +   factorization via conventional partial pivoting with row
  193.31 +   interchanges.  Colamd is the column ordering method used in SuperLU,
  193.32 +   part of the ScaLAPACK library.  It is also available as built-in
  193.33 +   function in MATLAB Version 6, available from MathWorks, Inc.
  193.34 +   (http://www.mathworks.com).  This routine can be used in place of
  193.35 +   colmmd in MATLAB.
  193.36 +
  193.37 +   Symamd computes a permutation P of a symmetric matrix A such that
  193.38 +   the Cholesky factorization of PAP' has less fill-in and requires
  193.39 +   fewer floating point operations than A.  Symamd constructs a matrix
  193.40 +   M such that M'M has the same nonzero pattern of A, and then orders
  193.41 +   the columns of M using colmmd.  The column ordering of M is then
  193.42 +   returned as the row and column ordering P of A.
  193.43 +
  193.44 +Authors:
  193.45 +
  193.46 +   The authors of the code itself are Stefan I. Larimore and Timothy A.
  193.47 +   Davis (davis at cise.ufl.edu), University of Florida.  The algorithm
  193.48 +   was developed in collaboration with John Gilbert, Xerox PARC, and
  193.49 +   Esmond Ng, Oak Ridge National Laboratory.
  193.50 +
  193.51 +Acknowledgements:
  193.52 +
  193.53 +   This work was supported by the National Science Foundation, under
  193.54 +   grants DMS-9504974 and DMS-9803599.
  193.55 +
  193.56 +License:
  193.57 +
  193.58 +   This library is free software; you can redistribute it and/or
  193.59 +   modify it under the terms of the GNU Lesser General Public License
  193.60 +   as published by the Free Software Foundation; either version 2.1 of
  193.61 +   the License, or (at your option) any later version.
  193.62 +
  193.63 +   This library is distributed in the hope that it will be useful,
  193.64 +   but WITHOUT ANY WARRANTY; without even the implied warranty of
  193.65 +   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  193.66 +   Lesser General Public License for more details.
  193.67 +
  193.68 +   You should have received a copy of the GNU Lesser General Public
  193.69 +   License along with this library; if not, write to the Free Software
  193.70 +   Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301
  193.71 +   USA.
  193.72 +
  193.73 +   Permission is hereby granted to use or copy this program under the
  193.74 +   terms of the GNU LGPL, provided that the Copyright, this License,
  193.75 +   and the Availability of the original version is retained on all
  193.76 +   copies.  User documentation of any code that uses this code or any
  193.77 +   modified version of this code must cite the Copyright, this License,
  193.78 +   the Availability note, and "Used by permission."  Permission to
  193.79 +   modify the code and to distribute modified code is granted, provided
  193.80 +   the Copyright, this License, and the Availability note are retained,
  193.81 +   and a notice that the code was modified is included.
  193.82 +
  193.83 +   COLAMD is also available under alternate licenses, contact T. Davis
  193.84 +   for details.
  193.85 +
  193.86 +Availability:
  193.87 +
  193.88 +   The colamd/symamd library is available at:
  193.89 +
  193.90 +   http://www.cise.ufl.edu/research/sparse/colamd/
  193.91 +
  193.92 +References:
  193.93 +
  193.94 +   T. A. Davis, J. R. Gilbert, S. Larimore, E. Ng, An approximate
  193.95 +   column minimum degree ordering algorithm, ACM Transactions on
  193.96 +   Mathematical Software, vol. 30, no. 3., pp. 353-376, 2004.
  193.97 +
  193.98 +   T. A. Davis, J. R. Gilbert, S. Larimore, E. Ng, Algorithm 836:
  193.99 +   COLAMD, an approximate column minimum degree ordering algorithm, ACM
 193.100 +   Transactions on Mathematical Software, vol. 30, no. 3., pp. 377-380,
 193.101 +   2004.
   194.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
   194.2 +++ b/deps/glpk/src/colamd/colamd.c	Sun Nov 06 20:59:10 2011 +0100
   194.3 @@ -0,0 +1,3622 @@
   194.4 +/* ========================================================================== */
   194.5 +/* === colamd/symamd - a sparse matrix column ordering algorithm ============ */
   194.6 +/* ========================================================================== */
   194.7 +
   194.8 +/* COLAMD / SYMAMD
   194.9 +
  194.10 +    colamd:  an approximate minimum degree column ordering algorithm,
  194.11 +        for LU factorization of symmetric or unsymmetric matrices,
  194.12 +        QR factorization, least squares, interior point methods for
  194.13 +        linear programming problems, and other related problems.
  194.14 +
  194.15 +    symamd:  an approximate minimum degree ordering algorithm for Cholesky
  194.16 +        factorization of symmetric matrices.
  194.17 +
  194.18 +    Purpose:
  194.19 +
  194.20 +        Colamd computes a permutation Q such that the Cholesky factorization of
  194.21 +        (AQ)'(AQ) has less fill-in and requires fewer floating point operations
  194.22 +        than A'A.  This also provides a good ordering for sparse partial
  194.23 +        pivoting methods, P(AQ) = LU, where Q is computed prior to numerical
  194.24 +        factorization, and P is computed during numerical factorization via
  194.25 +        conventional partial pivoting with row interchanges.  Colamd is the
  194.26 +        column ordering method used in SuperLU, part of the ScaLAPACK library.
  194.27 +        It is also available as built-in function in MATLAB Version 6,
  194.28 +        available from MathWorks, Inc. (http://www.mathworks.com).  This
  194.29 +        routine can be used in place of colmmd in MATLAB.
  194.30 +
  194.31 +        Symamd computes a permutation P of a symmetric matrix A such that the
  194.32 +        Cholesky factorization of PAP' has less fill-in and requires fewer
  194.33 +        floating point operations than A.  Symamd constructs a matrix M such
  194.34 +        that M'M has the same nonzero pattern of A, and then orders the columns
  194.35 +        of M using colmmd.  The column ordering of M is then returned as the
  194.36 +        row and column ordering P of A. 
  194.37 +
  194.38 +    Authors:
  194.39 +
  194.40 +        The authors of the code itself are Stefan I. Larimore and Timothy A.
  194.41 +        Davis (davis at cise.ufl.edu), University of Florida.  The algorithm was
  194.42 +        developed in collaboration with John Gilbert, Xerox PARC, and Esmond
  194.43 +        Ng, Oak Ridge National Laboratory.
  194.44 +
  194.45 +    Acknowledgements:
  194.46 +
  194.47 +        This work was supported by the National Science Foundation, under
  194.48 +        grants DMS-9504974 and DMS-9803599.
  194.49 +
  194.50 +    Copyright and License:
  194.51 +
  194.52 +        Copyright (c) 1998-2007, Timothy A. Davis, All Rights Reserved.
  194.53 +        COLAMD is also available under alternate licenses, contact T. Davis
  194.54 +        for details.
  194.55 +
  194.56 +        This library is free software; you can redistribute it and/or
  194.57 +        modify it under the terms of the GNU Lesser General Public
  194.58 +        License as published by the Free Software Foundation; either
  194.59 +        version 2.1 of the License, or (at your option) any later version.
  194.60 +
  194.61 +        This library is distributed in the hope that it will be useful,
  194.62 +        but WITHOUT ANY WARRANTY; without even the implied warranty of
  194.63 +        MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  194.64 +        Lesser General Public License for more details.
  194.65 +
  194.66 +        You should have received a copy of the GNU Lesser General Public
  194.67 +        License along with this library; if not, write to the Free Software
  194.68 +        Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301
  194.69 +        USA
  194.70 +
  194.71 +        Permission is hereby granted to use or copy this program under the
  194.72 +        terms of the GNU LGPL, provided that the Copyright, this License,
  194.73 +        and the Availability of the original version is retained on all copies.
  194.74 +        User documentation of any code that uses this code or any modified
  194.75 +        version of this code must cite the Copyright, this License, the
  194.76 +        Availability note, and "Used by permission." Permission to modify
  194.77 +        the code and to distribute modified code is granted, provided the
  194.78 +        Copyright, this License, and the Availability note are retained,
  194.79 +        and a notice that the code was modified is included.
  194.80 +
  194.81 +    Availability:
  194.82 +
  194.83 +        The colamd/symamd library is available at
  194.84 +
  194.85 +            http://www.cise.ufl.edu/research/sparse/colamd/
  194.86 +
  194.87 +        This is the http://www.cise.ufl.edu/research/sparse/colamd/colamd.c
  194.88 +        file.  It requires the colamd.h file.  It is required by the colamdmex.c
  194.89 +        and symamdmex.c files, for the MATLAB interface to colamd and symamd.
  194.90 +        Appears as ACM Algorithm 836.
  194.91 +
  194.92 +    See the ChangeLog file for changes since Version 1.0.
  194.93 +
  194.94 +    References:
  194.95 +
  194.96 +        T. A. Davis, J. R. Gilbert, S. Larimore, E. Ng, An approximate column
  194.97 +        minimum degree ordering algorithm, ACM Transactions on Mathematical
  194.98 +        Software, vol. 30, no. 3., pp. 353-376, 2004.
  194.99 +
 194.100 +        T. A. Davis, J. R. Gilbert, S. Larimore, E. Ng, Algorithm 836: COLAMD,
 194.101 +        an approximate column minimum degree ordering algorithm, ACM
 194.102 +        Transactions on Mathematical Software, vol. 30, no. 3., pp. 377-380,
 194.103 +        2004.
 194.104 +
 194.105 +*/
 194.106 +
 194.107 +/* ========================================================================== */
 194.108 +/* === Description of user-callable routines ================================ */
 194.109 +/* ========================================================================== */
 194.110 +
 194.111 +/* COLAMD includes both int and UF_long versions of all its routines.  The
 194.112 + * description below is for the int version.  For UF_long, all int arguments
 194.113 + * become UF_long.  UF_long is normally defined as long, except for WIN64.
 194.114 +
 194.115 +    ----------------------------------------------------------------------------
 194.116 +    colamd_recommended:
 194.117 +    ----------------------------------------------------------------------------
 194.118 +
 194.119 +        C syntax:
 194.120 +
 194.121 +            #include "colamd.h"
 194.122 +            size_t colamd_recommended (int nnz, int n_row, int n_col) ;
 194.123 +            size_t colamd_l_recommended (UF_long nnz, UF_long n_row,
 194.124 +                UF_long n_col) ;
 194.125 +
 194.126 +        Purpose:
 194.127 +
 194.128 +            Returns recommended value of Alen for use by colamd.  Returns 0
 194.129 +            if any input argument is negative.  The use of this routine
 194.130 +            is optional.  Not needed for symamd, which dynamically allocates
 194.131 +            its own memory.
 194.132 +
 194.133 +            Note that in v2.4 and earlier, these routines returned int or long.
 194.134 +            They now return a value of type size_t.
 194.135 +
 194.136 +        Arguments (all input arguments):
 194.137 +
 194.138 +            int nnz ;           Number of nonzeros in the matrix A.  This must
 194.139 +                                be the same value as p [n_col] in the call to
 194.140 +                                colamd - otherwise you will get a wrong value
 194.141 +                                of the recommended memory to use.
 194.142 +
 194.143 +            int n_row ;         Number of rows in the matrix A.
 194.144 +
 194.145 +            int n_col ;         Number of columns in the matrix A.
 194.146 +
 194.147 +    ----------------------------------------------------------------------------
 194.148 +    colamd_set_defaults:
 194.149 +    ----------------------------------------------------------------------------
 194.150 +
 194.151 +        C syntax:
 194.152 +
 194.153 +            #include "colamd.h"
 194.154 +            colamd_set_defaults (double knobs [COLAMD_KNOBS]) ;
 194.155 +            colamd_l_set_defaults (double knobs [COLAMD_KNOBS]) ;
 194.156 +
 194.157 +        Purpose:
 194.158 +
 194.159 +            Sets the default parameters.  The use of this routine is optional.
 194.160 +
 194.161 +        Arguments:
 194.162 +
 194.163 +            double knobs [COLAMD_KNOBS] ;       Output only.
 194.164 +
 194.165 +                NOTE: the meaning of the dense row/col knobs has changed in v2.4
 194.166 +
 194.167 +                knobs [0] and knobs [1] control dense row and col detection:
 194.168 +
 194.169 +                Colamd: rows with more than
 194.170 +                max (16, knobs [COLAMD_DENSE_ROW] * sqrt (n_col))
 194.171 +                entries are removed prior to ordering.  Columns with more than
 194.172 +                max (16, knobs [COLAMD_DENSE_COL] * sqrt (MIN (n_row,n_col)))
 194.173 +                entries are removed prior to
 194.174 +                ordering, and placed last in the output column ordering. 
 194.175 +
 194.176 +                Symamd: uses only knobs [COLAMD_DENSE_ROW], which is knobs [0].
 194.177 +                Rows and columns with more than
 194.178 +                max (16, knobs [COLAMD_DENSE_ROW] * sqrt (n))
 194.179 +                entries are removed prior to ordering, and placed last in the
 194.180 +                output ordering.
 194.181 +
 194.182 +                COLAMD_DENSE_ROW and COLAMD_DENSE_COL are defined as 0 and 1,
 194.183 +                respectively, in colamd.h.  Default values of these two knobs
 194.184 +                are both 10.  Currently, only knobs [0] and knobs [1] are
 194.185 +                used, but future versions may use more knobs.  If so, they will
 194.186 +                be properly set to their defaults by the future version of
 194.187 +                colamd_set_defaults, so that the code that calls colamd will
 194.188 +                not need to change, assuming that you either use
 194.189 +                colamd_set_defaults, or pass a (double *) NULL pointer as the
 194.190 +                knobs array to colamd or symamd.
 194.191 +
 194.192 +            knobs [2]: aggressive absorption
 194.193 +
 194.194 +                knobs [COLAMD_AGGRESSIVE] controls whether or not to do
 194.195 +                aggressive absorption during the ordering.  Default is TRUE.
 194.196 +
 194.197 +
 194.198 +    ----------------------------------------------------------------------------
 194.199 +    colamd:
 194.200 +    ----------------------------------------------------------------------------
 194.201 +
 194.202 +        C syntax:
 194.203 +
 194.204 +            #include "colamd.h"
 194.205 +            int colamd (int n_row, int n_col, int Alen, int *A, int *p,
 194.206 +                double knobs [COLAMD_KNOBS], int stats [COLAMD_STATS]) ;
 194.207 +            UF_long colamd_l (UF_long n_row, UF_long n_col, UF_long Alen,
 194.208 +                UF_long *A, UF_long *p, double knobs [COLAMD_KNOBS],
 194.209 +                UF_long stats [COLAMD_STATS]) ;
 194.210 +
 194.211 +        Purpose:
 194.212 +
 194.213 +            Computes a column ordering (Q) of A such that P(AQ)=LU or
 194.214 +            (AQ)'AQ=LL' have less fill-in and require fewer floating point
 194.215 +            operations than factorizing the unpermuted matrix A or A'A,
 194.216 +            respectively.
 194.217 +            
 194.218 +        Returns:
 194.219 +
 194.220 +            TRUE (1) if successful, FALSE (0) otherwise.
 194.221 +
 194.222 +        Arguments:
 194.223 +
 194.224 +            int n_row ;         Input argument.
 194.225 +
 194.226 +                Number of rows in the matrix A.
 194.227 +                Restriction:  n_row >= 0.
 194.228 +                Colamd returns FALSE if n_row is negative.
 194.229 +
 194.230 +            int n_col ;         Input argument.
 194.231 +
 194.232 +                Number of columns in the matrix A.
 194.233 +                Restriction:  n_col >= 0.
 194.234 +                Colamd returns FALSE if n_col is negative.
 194.235 +
 194.236 +            int Alen ;          Input argument.
 194.237 +
 194.238 +                Restriction (see note):
 194.239 +                Alen >= 2*nnz + 6*(n_col+1) + 4*(n_row+1) + n_col
 194.240 +                Colamd returns FALSE if these conditions are not met.
 194.241 +
 194.242 +                Note:  this restriction makes an modest assumption regarding
 194.243 +                the size of the two typedef's structures in colamd.h.
 194.244 +                We do, however, guarantee that
 194.245 +
 194.246 +                        Alen >= colamd_recommended (nnz, n_row, n_col)
 194.247 +
 194.248 +                will be sufficient.  Note: the macro version does not check
 194.249 +                for integer overflow, and thus is not recommended.  Use
 194.250 +                the colamd_recommended routine instead.
 194.251 +
 194.252 +            int A [Alen] ;      Input argument, undefined on output.
 194.253 +
 194.254 +                A is an integer array of size Alen.  Alen must be at least as
 194.255 +                large as the bare minimum value given above, but this is very
 194.256 +                low, and can result in excessive run time.  For best
 194.257 +                performance, we recommend that Alen be greater than or equal to
 194.258 +                colamd_recommended (nnz, n_row, n_col), which adds
 194.259 +                nnz/5 to the bare minimum value given above.
 194.260 +
 194.261 +                On input, the row indices of the entries in column c of the
 194.262 +                matrix are held in A [(p [c]) ... (p [c+1]-1)].  The row indices
 194.263 +                in a given column c need not be in ascending order, and
 194.264 +                duplicate row indices may be be present.  However, colamd will
 194.265 +                work a little faster if both of these conditions are met
 194.266 +                (Colamd puts the matrix into this format, if it finds that the
 194.267 +                the conditions are not met).
 194.268 +
 194.269 +                The matrix is 0-based.  That is, rows are in the range 0 to
 194.270 +                n_row-1, and columns are in the range 0 to n_col-1.  Colamd
 194.271 +                returns FALSE if any row index is out of range.
 194.272 +
 194.273 +                The contents of A are modified during ordering, and are
 194.274 +                undefined on output.
 194.275 +
 194.276 +            int p [n_col+1] ;   Both input and output argument.
 194.277 +
 194.278 +                p is an integer array of size n_col+1.  On input, it holds the
 194.279 +                "pointers" for the column form of the matrix A.  Column c of
 194.280 +                the matrix A is held in A [(p [c]) ... (p [c+1]-1)].  The first
 194.281 +                entry, p [0], must be zero, and p [c] <= p [c+1] must hold
 194.282 +                for all c in the range 0 to n_col-1.  The value p [n_col] is
 194.283 +                thus the total number of entries in the pattern of the matrix A.
 194.284 +                Colamd returns FALSE if these conditions are not met.
 194.285 +
 194.286 +                On output, if colamd returns TRUE, the array p holds the column
 194.287 +                permutation (Q, for P(AQ)=LU or (AQ)'(AQ)=LL'), where p [0] is
 194.288 +                the first column index in the new ordering, and p [n_col-1] is
 194.289 +                the last.  That is, p [k] = j means that column j of A is the
 194.290 +                kth pivot column, in AQ, where k is in the range 0 to n_col-1
 194.291 +                (p [0] = j means that column j of A is the first column in AQ).
 194.292 +
 194.293 +                If colamd returns FALSE, then no permutation is returned, and
 194.294 +                p is undefined on output.
 194.295 +
 194.296 +            double knobs [COLAMD_KNOBS] ;       Input argument.
 194.297 +
 194.298 +                See colamd_set_defaults for a description.
 194.299 +
 194.300 +            int stats [COLAMD_STATS] ;          Output argument.
 194.301 +
 194.302 +                Statistics on the ordering, and error status.
 194.303 +                See colamd.h for related definitions.
 194.304 +                Colamd returns FALSE if stats is not present.
 194.305 +
 194.306 +                stats [0]:  number of dense or empty rows ignored.
 194.307 +
 194.308 +                stats [1]:  number of dense or empty columns ignored (and
 194.309 +                                ordered last in the output permutation p)
 194.310 +                                Note that a row can become "empty" if it
 194.311 +                                contains only "dense" and/or "empty" columns,
 194.312 +                                and similarly a column can become "empty" if it
 194.313 +                                only contains "dense" and/or "empty" rows.
 194.314 +
 194.315 +                stats [2]:  number of garbage collections performed.
 194.316 +                                This can be excessively high if Alen is close
 194.317 +                                to the minimum required value.
 194.318 +
 194.319 +                stats [3]:  status code.  < 0 is an error code.
 194.320 +                            > 1 is a warning or notice.
 194.321 +
 194.322 +                        0       OK.  Each column of the input matrix contained
 194.323 +                                row indices in increasing order, with no
 194.324 +                                duplicates.
 194.325 +
 194.326 +                        1       OK, but columns of input matrix were jumbled
 194.327 +                                (unsorted columns or duplicate entries).  Colamd
 194.328 +                                had to do some extra work to sort the matrix
 194.329 +                                first and remove duplicate entries, but it
 194.330 +                                still was able to return a valid permutation
 194.331 +                                (return value of colamd was TRUE).
 194.332 +
 194.333 +                                        stats [4]: highest numbered column that
 194.334 +                                                is unsorted or has duplicate
 194.335 +                                                entries.
 194.336 +                                        stats [5]: last seen duplicate or
 194.337 +                                                unsorted row index.
 194.338 +                                        stats [6]: number of duplicate or
 194.339 +                                                unsorted row indices.
 194.340 +
 194.341 +                        -1      A is a null pointer
 194.342 +
 194.343 +                        -2      p is a null pointer
 194.344 +
 194.345 +                        -3      n_row is negative
 194.346 +
 194.347 +                                        stats [4]: n_row
 194.348 +
 194.349 +                        -4      n_col is negative
 194.350 +
 194.351 +                                        stats [4]: n_col
 194.352 +
 194.353 +                        -5      number of nonzeros in matrix is negative
 194.354 +
 194.355 +                                        stats [4]: number of nonzeros, p [n_col]
 194.356 +
 194.357 +                        -6      p [0] is nonzero
 194.358 +
 194.359 +                                        stats [4]: p [0]
 194.360 +
 194.361 +                        -7      A is too small
 194.362 +
 194.363 +                                        stats [4]: required size
 194.364 +                                        stats [5]: actual size (Alen)
 194.365 +
 194.366 +                        -8      a column has a negative number of entries
 194.367 +
 194.368 +                                        stats [4]: column with < 0 entries
 194.369 +                                        stats [5]: number of entries in col
 194.370 +
 194.371 +                        -9      a row index is out of bounds
 194.372 +
 194.373 +                                        stats [4]: column with bad row index
 194.374 +                                        stats [5]: bad row index
 194.375 +                                        stats [6]: n_row, # of rows of matrx
 194.376 +
 194.377 +                        -10     (unused; see symamd.c)
 194.378 +
 194.379 +                        -999    (unused; see symamd.c)
 194.380 +
 194.381 +                Future versions may return more statistics in the stats array.
 194.382 +
 194.383 +        Example:
 194.384 +        
 194.385 +            See http://www.cise.ufl.edu/research/sparse/colamd/example.c
 194.386 +            for a complete example.
 194.387 +
 194.388 +            To order the columns of a 5-by-4 matrix with 11 nonzero entries in
 194.389 +            the following nonzero pattern
 194.390 +
 194.391 +                x 0 x 0
 194.392 +                x 0 x x
 194.393 +                0 x x 0
 194.394 +                0 0 x x
 194.395 +                x x 0 0
 194.396 +
 194.397 +            with default knobs and no output statistics, do the following:
 194.398 +
 194.399 +                #include "colamd.h"
 194.400 +                #define ALEN 100
 194.401 +                int A [ALEN] = {0, 1, 4, 2, 4, 0, 1, 2, 3, 1, 3} ;
 194.402 +                int p [ ] = {0, 3, 5, 9, 11} ;
 194.403 +                int stats [COLAMD_STATS] ;
 194.404 +                colamd (5, 4, ALEN, A, p, (double *) NULL, stats) ;
 194.405 +
 194.406 +            The permutation is returned in the array p, and A is destroyed.
 194.407 +
 194.408 +    ----------------------------------------------------------------------------
 194.409 +    symamd:
 194.410 +    ----------------------------------------------------------------------------
 194.411 +
 194.412 +        C syntax:
 194.413 +
 194.414 +            #include "colamd.h"
 194.415 +            int symamd (int n, int *A, int *p, int *perm,
 194.416 +                double knobs [COLAMD_KNOBS], int stats [COLAMD_STATS],
 194.417 +                void (*allocate) (size_t, size_t), void (*release) (void *)) ;
 194.418 +            UF_long symamd_l (UF_long n, UF_long *A, UF_long *p, UF_long *perm,
 194.419 +                double knobs [COLAMD_KNOBS], UF_long stats [COLAMD_STATS],
 194.420 +                void (*allocate) (size_t, size_t), void (*release) (void *)) ;
 194.421 +
 194.422 +        Purpose:
 194.423 +
 194.424 +            The symamd routine computes an ordering P of a symmetric sparse
 194.425 +            matrix A such that the Cholesky factorization PAP' = LL' remains
 194.426 +            sparse.  It is based on a column ordering of a matrix M constructed
 194.427 +            so that the nonzero pattern of M'M is the same as A.  The matrix A
 194.428 +            is assumed to be symmetric; only the strictly lower triangular part
 194.429 +            is accessed.  You must pass your selected memory allocator (usually
 194.430 +            calloc/free or mxCalloc/mxFree) to symamd, for it to allocate
 194.431 +            memory for the temporary matrix M.
 194.432 +
 194.433 +        Returns:
 194.434 +
 194.435 +            TRUE (1) if successful, FALSE (0) otherwise.
 194.436 +
 194.437 +        Arguments:
 194.438 +
 194.439 +            int n ;             Input argument.
 194.440 +
 194.441 +                Number of rows and columns in the symmetrix matrix A.
 194.442 +                Restriction:  n >= 0.
 194.443 +                Symamd returns FALSE if n is negative.
 194.444 +
 194.445 +            int A [nnz] ;       Input argument.
 194.446 +
 194.447 +                A is an integer array of size nnz, where nnz = p [n].
 194.448 +                
 194.449 +                The row indices of the entries in column c of the matrix are
 194.450 +                held in A [(p [c]) ... (p [c+1]-1)].  The row indices in a
 194.451 +                given column c need not be in ascending order, and duplicate
 194.452 +                row indices may be present.  However, symamd will run faster
 194.453 +                if the columns are in sorted order with no duplicate entries. 
 194.454 +
 194.455 +                The matrix is 0-based.  That is, rows are in the range 0 to
 194.456 +                n-1, and columns are in the range 0 to n-1.  Symamd
 194.457 +                returns FALSE if any row index is out of range.
 194.458 +
 194.459 +                The contents of A are not modified.
 194.460 +
 194.461 +            int p [n+1] ;       Input argument.
 194.462 +
 194.463 +                p is an integer array of size n+1.  On input, it holds the
 194.464 +                "pointers" for the column form of the matrix A.  Column c of
 194.465 +                the matrix A is held in A [(p [c]) ... (p [c+1]-1)].  The first
 194.466 +                entry, p [0], must be zero, and p [c] <= p [c+1] must hold
 194.467 +                for all c in the range 0 to n-1.  The value p [n] is
 194.468 +                thus the total number of entries in the pattern of the matrix A.
 194.469 +                Symamd returns FALSE if these conditions are not met.
 194.470 +
 194.471 +                The contents of p are not modified.
 194.472 +
 194.473 +            int perm [n+1] ;    Output argument.
 194.474 +
 194.475 +                On output, if symamd returns TRUE, the array perm holds the
 194.476 +                permutation P, where perm [0] is the first index in the new
 194.477 +                ordering, and perm [n-1] is the last.  That is, perm [k] = j
 194.478 +                means that row and column j of A is the kth column in PAP',
 194.479 +                where k is in the range 0 to n-1 (perm [0] = j means
 194.480 +                that row and column j of A are the first row and column in
 194.481 +                PAP').  The array is used as a workspace during the ordering,
 194.482 +                which is why it must be of length n+1, not just n.
 194.483 +
 194.484 +            double knobs [COLAMD_KNOBS] ;       Input argument.
 194.485 +
 194.486 +                See colamd_set_defaults for a description.
 194.487 +
 194.488 +            int stats [COLAMD_STATS] ;          Output argument.
 194.489 +
 194.490 +                Statistics on the ordering, and error status.
 194.491 +                See colamd.h for related definitions.
 194.492 +                Symamd returns FALSE if stats is not present.
 194.493 +
 194.494 +                stats [0]:  number of dense or empty row and columns ignored
 194.495 +                                (and ordered last in the output permutation 
 194.496 +                                perm).  Note that a row/column can become
 194.497 +                                "empty" if it contains only "dense" and/or
 194.498 +                                "empty" columns/rows.
 194.499 +
 194.500 +                stats [1]:  (same as stats [0])
 194.501 +
 194.502 +                stats [2]:  number of garbage collections performed.
 194.503 +
 194.504 +                stats [3]:  status code.  < 0 is an error code.
 194.505 +                            > 1 is a warning or notice.
 194.506 +
 194.507 +                        0       OK.  Each column of the input matrix contained
 194.508 +                                row indices in increasing order, with no
 194.509 +                                duplicates.
 194.510 +
 194.511 +                        1       OK, but columns of input matrix were jumbled
 194.512 +                                (unsorted columns or duplicate entries).  Symamd
 194.513 +                                had to do some extra work to sort the matrix
 194.514 +                                first and remove duplicate entries, but it
 194.515 +                                still was able to return a valid permutation
 194.516 +                                (return value of symamd was TRUE).
 194.517 +
 194.518 +                                        stats [4]: highest numbered column that
 194.519 +                                                is unsorted or has duplicate
 194.520 +                                                entries.
 194.521 +                                        stats [5]: last seen duplicate or
 194.522 +                                                unsorted row index.
 194.523 +                                        stats [6]: number of duplicate or
 194.524 +                                                unsorted row indices.
 194.525 +
 194.526 +                        -1      A is a null pointer
 194.527 +
 194.528 +                        -2      p is a null pointer
 194.529 +
 194.530 +                        -3      (unused, see colamd.c)
 194.531 +
 194.532 +                        -4      n is negative
 194.533 +
 194.534 +                                        stats [4]: n
 194.535 +
 194.536 +                        -5      number of nonzeros in matrix is negative
 194.537 +
 194.538 +                                        stats [4]: # of nonzeros (p [n]).
 194.539 +
 194.540 +                        -6      p [0] is nonzero
 194.541 +
 194.542 +                                        stats [4]: p [0]
 194.543 +
 194.544 +                        -7      (unused)
 194.545 +
 194.546 +                        -8      a column has a negative number of entries
 194.547 +
 194.548 +                                        stats [4]: column with < 0 entries
 194.549 +                                        stats [5]: number of entries in col
 194.550 +
 194.551 +                        -9      a row index is out of bounds
 194.552 +
 194.553 +                                        stats [4]: column with bad row index
 194.554 +                                        stats [5]: bad row index
 194.555 +                                        stats [6]: n_row, # of rows of matrx
 194.556 +
 194.557 +                        -10     out of memory (unable to allocate temporary
 194.558 +                                workspace for M or count arrays using the
 194.559 +                                "allocate" routine passed into symamd).
 194.560 +
 194.561 +                Future versions may return more statistics in the stats array.
 194.562 +
 194.563 +            void * (*allocate) (size_t, size_t)
 194.564 +
 194.565 +                A pointer to a function providing memory allocation.  The
 194.566 +                allocated memory must be returned initialized to zero.  For a
 194.567 +                C application, this argument should normally be a pointer to
 194.568 +                calloc.  For a MATLAB mexFunction, the routine mxCalloc is
 194.569 +                passed instead.
 194.570 +
 194.571 +            void (*release) (size_t, size_t)
 194.572 +
 194.573 +                A pointer to a function that frees memory allocated by the
 194.574 +                memory allocation routine above.  For a C application, this
 194.575 +                argument should normally be a pointer to free.  For a MATLAB
 194.576 +                mexFunction, the routine mxFree is passed instead.
 194.577 +
 194.578 +
 194.579 +    ----------------------------------------------------------------------------
 194.580 +    colamd_report:
 194.581 +    ----------------------------------------------------------------------------
 194.582 +
 194.583 +        C syntax:
 194.584 +
 194.585 +            #include "colamd.h"
 194.586 +            colamd_report (int stats [COLAMD_STATS]) ;
 194.587 +            colamd_l_report (UF_long stats [COLAMD_STATS]) ;
 194.588 +
 194.589 +        Purpose:
 194.590 +
 194.591 +            Prints the error status and statistics recorded in the stats
 194.592 +            array on the standard error output (for a standard C routine)
 194.593 +            or on the MATLAB output (for a mexFunction).
 194.594 +
 194.595 +        Arguments:
 194.596 +
 194.597 +            int stats [COLAMD_STATS] ;  Input only.  Statistics from colamd.
 194.598 +
 194.599 +
 194.600 +    ----------------------------------------------------------------------------
 194.601 +    symamd_report:
 194.602 +    ----------------------------------------------------------------------------
 194.603 +
 194.604 +        C syntax:
 194.605 +
 194.606 +            #include "colamd.h"
 194.607 +            symamd_report (int stats [COLAMD_STATS]) ;
 194.608 +            symamd_l_report (UF_long stats [COLAMD_STATS]) ;
 194.609 +
 194.610 +        Purpose:
 194.611 +
 194.612 +            Prints the error status and statistics recorded in the stats
 194.613 +            array on the standard error output (for a standard C routine)
 194.614 +            or on the MATLAB output (for a mexFunction).
 194.615 +
 194.616 +        Arguments:
 194.617 +
 194.618 +            int stats [COLAMD_STATS] ;  Input only.  Statistics from symamd.
 194.619 +
 194.620 +
 194.621 +*/
 194.622 +
 194.623 +/* ========================================================================== */
 194.624 +/* === Scaffolding code definitions  ======================================== */
 194.625 +/* ========================================================================== */
 194.626 +
 194.627 +/* Ensure that debugging is turned off: */
 194.628 +#ifndef NDEBUG
 194.629 +#define NDEBUG
 194.630 +#endif
 194.631 +
 194.632 +/* turn on debugging by uncommenting the following line
 194.633 + #undef NDEBUG
 194.634 +*/
 194.635 +
 194.636 +/*
 194.637 +   Our "scaffolding code" philosophy:  In our opinion, well-written library
 194.638 +   code should keep its "debugging" code, and just normally have it turned off
 194.639 +   by the compiler so as not to interfere with performance.  This serves
 194.640 +   several purposes:
 194.641 +
 194.642 +   (1) assertions act as comments to the reader, telling you what the code
 194.643 +        expects at that point.  All assertions will always be true (unless
 194.644 +        there really is a bug, of course).
 194.645 +
 194.646 +   (2) leaving in the scaffolding code assists anyone who would like to modify
 194.647 +        the code, or understand the algorithm (by reading the debugging output,
 194.648 +        one can get a glimpse into what the code is doing).
 194.649 +
 194.650 +   (3) (gasp!) for actually finding bugs.  This code has been heavily tested
 194.651 +        and "should" be fully functional and bug-free ... but you never know...
 194.652 +
 194.653 +    The code will become outrageously slow when debugging is
 194.654 +    enabled.  To control the level of debugging output, set an environment
 194.655 +    variable D to 0 (little), 1 (some), 2, 3, or 4 (lots).  When debugging,
 194.656 +    you should see the following message on the standard output:
 194.657 +
 194.658 +        colamd: debug version, D = 1 (THIS WILL BE SLOW!)
 194.659 +
 194.660 +    or a similar message for symamd.  If you don't, then debugging has not
 194.661 +    been enabled.
 194.662 +
 194.663 +*/
 194.664 +
 194.665 +/* ========================================================================== */
 194.666 +/* === Include files ======================================================== */
 194.667 +/* ========================================================================== */
 194.668 +
 194.669 +#include "colamd.h"
 194.670 +
 194.671 +#if 0 /* by mao */
 194.672 +#include <limits.h>
 194.673 +#include <math.h>
 194.674 +
 194.675 +#ifdef MATLAB_MEX_FILE
 194.676 +#include "mex.h"
 194.677 +#include "matrix.h"
 194.678 +#endif /* MATLAB_MEX_FILE */
 194.679 +
 194.680 +#if !defined (NPRINT) || !defined (NDEBUG)
 194.681 +#include <stdio.h>
 194.682 +#endif
 194.683 +
 194.684 +#ifndef NULL
 194.685 +#define NULL ((void *) 0)
 194.686 +#endif
 194.687 +#endif
 194.688 +
 194.689 +/* ========================================================================== */
 194.690 +/* === int or UF_long ======================================================= */
 194.691 +/* ========================================================================== */
 194.692 +
 194.693 +#if 0 /* by mao */
 194.694 +/* define UF_long */
 194.695 +#include "UFconfig.h"
 194.696 +#endif
 194.697 +
 194.698 +#ifdef DLONG
 194.699 +
 194.700 +#define Int UF_long
 194.701 +#define ID  UF_long_id
 194.702 +#define Int_MAX UF_long_max
 194.703 +
 194.704 +#define COLAMD_recommended colamd_l_recommended
 194.705 +#define COLAMD_set_defaults colamd_l_set_defaults
 194.706 +#define COLAMD_MAIN colamd_l
 194.707 +#define SYMAMD_MAIN symamd_l
 194.708 +#define COLAMD_report colamd_l_report
 194.709 +#define SYMAMD_report symamd_l_report
 194.710 +
 194.711 +#else
 194.712 +
 194.713 +#define Int int
 194.714 +#define ID "%d"
 194.715 +#define Int_MAX INT_MAX
 194.716 +
 194.717 +#define COLAMD_recommended colamd_recommended
 194.718 +#define COLAMD_set_defaults colamd_set_defaults
 194.719 +#define COLAMD_MAIN colamd
 194.720 +#define SYMAMD_MAIN symamd
 194.721 +#define COLAMD_report colamd_report
 194.722 +#define SYMAMD_report symamd_report
 194.723 +
 194.724 +#endif
 194.725 +
 194.726 +/* ========================================================================== */
 194.727 +/* === Row and Column structures ============================================ */
 194.728 +/* ========================================================================== */
 194.729 +
 194.730 +/* User code that makes use of the colamd/symamd routines need not directly */
 194.731 +/* reference these structures.  They are used only for colamd_recommended. */
 194.732 +
 194.733 +typedef struct Colamd_Col_struct
 194.734 +{
 194.735 +    Int start ;         /* index for A of first row in this column, or DEAD */
 194.736 +                        /* if column is dead */
 194.737 +    Int length ;        /* number of rows in this column */
 194.738 +    union
 194.739 +    {
 194.740 +        Int thickness ; /* number of original columns represented by this */
 194.741 +                        /* col, if the column is alive */
 194.742 +        Int parent ;    /* parent in parent tree super-column structure, if */
 194.743 +                        /* the column is dead */
 194.744 +    } shared1 ;
 194.745 +    union
 194.746 +    {
 194.747 +        Int score ;     /* the score used to maintain heap, if col is alive */
 194.748 +        Int order ;     /* pivot ordering of this column, if col is dead */
 194.749 +    } shared2 ;
 194.750 +    union
 194.751 +    {
 194.752 +        Int headhash ;  /* head of a hash bucket, if col is at the head of */
 194.753 +                        /* a degree list */
 194.754 +        Int hash ;      /* hash value, if col is not in a degree list */
 194.755 +        Int prev ;      /* previous column in degree list, if col is in a */
 194.756 +                        /* degree list (but not at the head of a degree list) */
 194.757 +    } shared3 ;
 194.758 +    union
 194.759 +    {
 194.760 +        Int degree_next ;       /* next column, if col is in a degree list */
 194.761 +        Int hash_next ;         /* next column, if col is in a hash list */
 194.762 +    } shared4 ;
 194.763 +
 194.764 +} Colamd_Col ;
 194.765 +
 194.766 +typedef struct Colamd_Row_struct
 194.767 +{
 194.768 +    Int start ;         /* index for A of first col in this row */
 194.769 +    Int length ;        /* number of principal columns in this row */
 194.770 +    union
 194.771 +    {
 194.772 +        Int degree ;    /* number of principal & non-principal columns in row */
 194.773 +        Int p ;         /* used as a row pointer in init_rows_cols () */
 194.774 +    } shared1 ;
 194.775 +    union
 194.776 +    {
 194.777 +        Int mark ;      /* for computing set differences and marking dead rows*/
 194.778 +        Int first_column ;/* first column in row (used in garbage collection) */
 194.779 +    } shared2 ;
 194.780 +
 194.781 +} Colamd_Row ;
 194.782 +
 194.783 +/* ========================================================================== */
 194.784 +/* === Definitions ========================================================== */
 194.785 +/* ========================================================================== */
 194.786 +
 194.787 +/* Routines are either PUBLIC (user-callable) or PRIVATE (not user-callable) */
 194.788 +#define PUBLIC
 194.789 +#define PRIVATE static
 194.790 +
 194.791 +#define DENSE_DEGREE(alpha,n) \
 194.792 +    ((Int) MAX (16.0, (alpha) * sqrt ((double) (n))))
 194.793 +
 194.794 +#define MAX(a,b) (((a) > (b)) ? (a) : (b))
 194.795 +#define MIN(a,b) (((a) < (b)) ? (a) : (b))
 194.796 +
 194.797 +#define ONES_COMPLEMENT(r) (-(r)-1)
 194.798 +
 194.799 +/* -------------------------------------------------------------------------- */
 194.800 +/* Change for version 2.1:  define TRUE and FALSE only if not yet defined */  
 194.801 +/* -------------------------------------------------------------------------- */
 194.802 +
 194.803 +#ifndef TRUE
 194.804 +#define TRUE (1)
 194.805 +#endif
 194.806 +
 194.807 +#ifndef FALSE
 194.808 +#define FALSE (0)
 194.809 +#endif
 194.810 +
 194.811 +/* -------------------------------------------------------------------------- */
 194.812 +
 194.813 +#define EMPTY   (-1)
 194.814 +
 194.815 +/* Row and column status */
 194.816 +#define ALIVE   (0)
 194.817 +#define DEAD    (-1)
 194.818 +
 194.819 +/* Column status */
 194.820 +#define DEAD_PRINCIPAL          (-1)
 194.821 +#define DEAD_NON_PRINCIPAL      (-2)
 194.822 +
 194.823 +/* Macros for row and column status update and checking. */
 194.824 +#define ROW_IS_DEAD(r)                  ROW_IS_MARKED_DEAD (Row[r].shared2.mark)
 194.825 +#define ROW_IS_MARKED_DEAD(row_mark)    (row_mark < ALIVE)
 194.826 +#define ROW_IS_ALIVE(r)                 (Row [r].shared2.mark >= ALIVE)
 194.827 +#define COL_IS_DEAD(c)                  (Col [c].start < ALIVE)
 194.828 +#define COL_IS_ALIVE(c)                 (Col [c].start >= ALIVE)
 194.829 +#define COL_IS_DEAD_PRINCIPAL(c)        (Col [c].start == DEAD_PRINCIPAL)
 194.830 +#define KILL_ROW(r)                     { Row [r].shared2.mark = DEAD ; }
 194.831 +#define KILL_PRINCIPAL_COL(c)           { Col [c].start = DEAD_PRINCIPAL ; }
 194.832 +#define KILL_NON_PRINCIPAL_COL(c)       { Col [c].start = DEAD_NON_PRINCIPAL ; }
 194.833 +
 194.834 +/* ========================================================================== */
 194.835 +/* === Colamd reporting mechanism =========================================== */
 194.836 +/* ========================================================================== */
 194.837 +
 194.838 +#if defined (MATLAB_MEX_FILE) || defined (MATHWORKS)
 194.839 +/* In MATLAB, matrices are 1-based to the user, but 0-based internally */
 194.840 +#define INDEX(i) ((i)+1)
 194.841 +#else
 194.842 +/* In C, matrices are 0-based and indices are reported as such in *_report */
 194.843 +#define INDEX(i) (i)
 194.844 +#endif
 194.845 +
 194.846 +/* All output goes through the PRINTF macro.  */
 194.847 +#define PRINTF(params) { if (colamd_printf != NULL) (void) colamd_printf params ; }
 194.848 +
 194.849 +/* ========================================================================== */
 194.850 +/* === Prototypes of PRIVATE routines ======================================= */
 194.851 +/* ========================================================================== */
 194.852 +
 194.853 +PRIVATE Int init_rows_cols
 194.854 +(
 194.855 +    Int n_row,
 194.856 +    Int n_col,
 194.857 +    Colamd_Row Row [],
 194.858 +    Colamd_Col Col [],
 194.859 +    Int A [],
 194.860 +    Int p [],
 194.861 +    Int stats [COLAMD_STATS]
 194.862 +) ;
 194.863 +
 194.864 +PRIVATE void init_scoring
 194.865 +(
 194.866 +    Int n_row,
 194.867 +    Int n_col,
 194.868 +    Colamd_Row Row [],
 194.869 +    Colamd_Col Col [],
 194.870 +    Int A [],
 194.871 +    Int head [],
 194.872 +    double knobs [COLAMD_KNOBS],
 194.873 +    Int *p_n_row2,
 194.874 +    Int *p_n_col2,
 194.875 +    Int *p_max_deg
 194.876 +) ;
 194.877 +
 194.878 +PRIVATE Int find_ordering
 194.879 +(
 194.880 +    Int n_row,
 194.881 +    Int n_col,
 194.882 +    Int Alen,
 194.883 +    Colamd_Row Row [],
 194.884 +    Colamd_Col Col [],
 194.885 +    Int A [],
 194.886 +    Int head [],
 194.887 +    Int n_col2,
 194.888 +    Int max_deg,
 194.889 +    Int pfree,
 194.890 +    Int aggressive
 194.891 +) ;
 194.892 +
 194.893 +PRIVATE void order_children
 194.894 +(
 194.895 +    Int n_col,
 194.896 +    Colamd_Col Col [],
 194.897 +    Int p []
 194.898 +) ;
 194.899 +
 194.900 +PRIVATE void detect_super_cols
 194.901 +(
 194.902 +
 194.903 +#ifndef NDEBUG
 194.904 +    Int n_col,
 194.905 +    Colamd_Row Row [],
 194.906 +#endif /* NDEBUG */
 194.907 +
 194.908 +    Colamd_Col Col [],
 194.909 +    Int A [],
 194.910 +    Int head [],
 194.911 +    Int row_start,
 194.912 +    Int row_length
 194.913 +) ;
 194.914 +
 194.915 +PRIVATE Int garbage_collection
 194.916 +(
 194.917 +    Int n_row,
 194.918 +    Int n_col,
 194.919 +    Colamd_Row Row [],
 194.920 +    Colamd_Col Col [],
 194.921 +    Int A [],
 194.922 +    Int *pfree
 194.923 +) ;
 194.924 +
 194.925 +PRIVATE Int clear_mark
 194.926 +(
 194.927 +    Int tag_mark,
 194.928 +    Int max_mark,
 194.929 +    Int n_row,
 194.930 +    Colamd_Row Row []
 194.931 +) ;
 194.932 +
 194.933 +PRIVATE void print_report
 194.934 +(
 194.935 +    char *method,
 194.936 +    Int stats [COLAMD_STATS]
 194.937 +) ;
 194.938 +
 194.939 +/* ========================================================================== */
 194.940 +/* === Debugging prototypes and definitions ================================= */
 194.941 +/* ========================================================================== */
 194.942 +
 194.943 +#ifndef NDEBUG
 194.944 +
 194.945 +#if 0 /* by mao */
 194.946 +#include <assert.h>
 194.947 +#endif
 194.948 +
 194.949 +/* colamd_debug is the *ONLY* global variable, and is only */
 194.950 +/* present when debugging */
 194.951 +
 194.952 +PRIVATE Int colamd_debug = 0 ;  /* debug print level */
 194.953 +
 194.954 +#define DEBUG0(params) { PRINTF (params) ; }
 194.955 +#define DEBUG1(params) { if (colamd_debug >= 1) PRINTF (params) ; }
 194.956 +#define DEBUG2(params) { if (colamd_debug >= 2) PRINTF (params) ; }
 194.957 +#define DEBUG3(params) { if (colamd_debug >= 3) PRINTF (params) ; }
 194.958 +#define DEBUG4(params) { if (colamd_debug >= 4) PRINTF (params) ; }
 194.959 +
 194.960 +#if 0 /* by mao */
 194.961 +#ifdef MATLAB_MEX_FILE
 194.962 +#define ASSERT(expression) (mxAssert ((expression), ""))
 194.963 +#else
 194.964 +#define ASSERT(expression) (assert (expression))
 194.965 +#endif /* MATLAB_MEX_FILE */
 194.966 +#else
 194.967 +#define ASSERT xassert
 194.968 +#endif
 194.969 +
 194.970 +PRIVATE void colamd_get_debug   /* gets the debug print level from getenv */
 194.971 +(
 194.972 +    char *method
 194.973 +) ;
 194.974 +
 194.975 +PRIVATE void debug_deg_lists
 194.976 +(
 194.977 +    Int n_row,
 194.978 +    Int n_col,
 194.979 +    Colamd_Row Row [],
 194.980 +    Colamd_Col Col [],
 194.981 +    Int head [],
 194.982 +    Int min_score,
 194.983 +    Int should,
 194.984 +    Int max_deg
 194.985 +) ;
 194.986 +
 194.987 +PRIVATE void debug_mark
 194.988 +(
 194.989 +    Int n_row,
 194.990 +    Colamd_Row Row [],
 194.991 +    Int tag_mark,
 194.992 +    Int max_mark
 194.993 +) ;
 194.994 +
 194.995 +PRIVATE void debug_matrix
 194.996 +(
 194.997 +    Int n_row,
 194.998 +    Int n_col,
 194.999 +    Colamd_Row Row [],
194.1000 +    Colamd_Col Col [],
194.1001 +    Int A []
194.1002 +) ;
194.1003 +
194.1004 +PRIVATE void debug_structures
194.1005 +(
194.1006 +    Int n_row,
194.1007 +    Int n_col,
194.1008 +    Colamd_Row Row [],
194.1009 +    Colamd_Col Col [],
194.1010 +    Int A [],
194.1011 +    Int n_col2
194.1012 +) ;
194.1013 +
194.1014 +#else /* NDEBUG */
194.1015 +
194.1016 +/* === No debugging ========================================================= */
194.1017 +
194.1018 +#define DEBUG0(params) ;
194.1019 +#define DEBUG1(params) ;
194.1020 +#define DEBUG2(params) ;
194.1021 +#define DEBUG3(params) ;
194.1022 +#define DEBUG4(params) ;
194.1023 +
194.1024 +#define ASSERT(expression)
194.1025 +
194.1026 +#endif /* NDEBUG */
194.1027 +
194.1028 +/* ========================================================================== */
194.1029 +/* === USER-CALLABLE ROUTINES: ============================================== */
194.1030 +/* ========================================================================== */
194.1031 +
194.1032 +/* ========================================================================== */
194.1033 +/* === colamd_recommended =================================================== */
194.1034 +/* ========================================================================== */
194.1035 +
194.1036 +/*
194.1037 +    The colamd_recommended routine returns the suggested size for Alen.  This
194.1038 +    value has been determined to provide good balance between the number of
194.1039 +    garbage collections and the memory requirements for colamd.  If any
194.1040 +    argument is negative, or if integer overflow occurs, a 0 is returned as an
194.1041 +    error condition.  2*nnz space is required for the row and column
194.1042 +    indices of the matrix. COLAMD_C (n_col) + COLAMD_R (n_row) space is
194.1043 +    required for the Col and Row arrays, respectively, which are internal to
194.1044 +    colamd (roughly 6*n_col + 4*n_row).  An additional n_col space is the
194.1045 +    minimal amount of "elbow room", and nnz/5 more space is recommended for
194.1046 +    run time efficiency.
194.1047 +
194.1048 +    Alen is approximately 2.2*nnz + 7*n_col + 4*n_row + 10.
194.1049 +
194.1050 +    This function is not needed when using symamd.
194.1051 +*/
194.1052 +
194.1053 +/* add two values of type size_t, and check for integer overflow */
194.1054 +static size_t t_add (size_t a, size_t b, int *ok)
194.1055 +{
194.1056 +    (*ok) = (*ok) && ((a + b) >= MAX (a,b)) ;
194.1057 +    return ((*ok) ? (a + b) : 0) ;
194.1058 +}
194.1059 +
194.1060 +/* compute a*k where k is a small integer, and check for integer overflow */
194.1061 +static size_t t_mult (size_t a, size_t k, int *ok)
194.1062 +{
194.1063 +    size_t i, s = 0 ;
194.1064 +    for (i = 0 ; i < k ; i++)
194.1065 +    {
194.1066 +        s = t_add (s, a, ok) ;
194.1067 +    }
194.1068 +    return (s) ;
194.1069 +}
194.1070 +
194.1071 +/* size of the Col and Row structures */
194.1072 +#define COLAMD_C(n_col,ok) \
194.1073 +    ((t_mult (t_add (n_col, 1, ok), sizeof (Colamd_Col), ok) / sizeof (Int)))
194.1074 +
194.1075 +#define COLAMD_R(n_row,ok) \
194.1076 +    ((t_mult (t_add (n_row, 1, ok), sizeof (Colamd_Row), ok) / sizeof (Int)))
194.1077 +
194.1078 +
194.1079 +PUBLIC size_t COLAMD_recommended        /* returns recommended value of Alen. */
194.1080 +(
194.1081 +    /* === Parameters ======================================================= */
194.1082 +
194.1083 +    Int nnz,                    /* number of nonzeros in A */
194.1084 +    Int n_row,                  /* number of rows in A */
194.1085 +    Int n_col                   /* number of columns in A */
194.1086 +)
194.1087 +{
194.1088 +    size_t s, c, r ;
194.1089 +    int ok = TRUE ;
194.1090 +    if (nnz < 0 || n_row < 0 || n_col < 0)
194.1091 +    {
194.1092 +        return (0) ;
194.1093 +    }
194.1094 +    s = t_mult (nnz, 2, &ok) ;      /* 2*nnz */
194.1095 +    c = COLAMD_C (n_col, &ok) ;     /* size of column structures */
194.1096 +    r = COLAMD_R (n_row, &ok) ;     /* size of row structures */
194.1097 +    s = t_add (s, c, &ok) ;
194.1098 +    s = t_add (s, r, &ok) ;
194.1099 +    s = t_add (s, n_col, &ok) ;     /* elbow room */
194.1100 +    s = t_add (s, nnz/5, &ok) ;     /* elbow room */
194.1101 +    ok = ok && (s < Int_MAX) ;
194.1102 +    return (ok ? s : 0) ;
194.1103 +}
194.1104 +
194.1105 +
194.1106 +/* ========================================================================== */
194.1107 +/* === colamd_set_defaults ================================================== */
194.1108 +/* ========================================================================== */
194.1109 +
194.1110 +/*
194.1111 +    The colamd_set_defaults routine sets the default values of the user-
194.1112 +    controllable parameters for colamd and symamd:
194.1113 +
194.1114 +        Colamd: rows with more than max (16, knobs [0] * sqrt (n_col))
194.1115 +        entries are removed prior to ordering.  Columns with more than
194.1116 +        max (16, knobs [1] * sqrt (MIN (n_row,n_col))) entries are removed
194.1117 +        prior to ordering, and placed last in the output column ordering. 
194.1118 +
194.1119 +        Symamd: Rows and columns with more than max (16, knobs [0] * sqrt (n))
194.1120 +        entries are removed prior to ordering, and placed last in the
194.1121 +        output ordering.
194.1122 +
194.1123 +        knobs [0]       dense row control
194.1124 +
194.1125 +        knobs [1]       dense column control
194.1126 +
194.1127 +        knobs [2]       if nonzero, do aggresive absorption
194.1128 +
194.1129 +        knobs [3..19]   unused, but future versions might use this
194.1130 +
194.1131 +*/
194.1132 +
194.1133 +PUBLIC void COLAMD_set_defaults
194.1134 +(
194.1135 +    /* === Parameters ======================================================= */
194.1136 +
194.1137 +    double knobs [COLAMD_KNOBS]         /* knob array */
194.1138 +)
194.1139 +{
194.1140 +    /* === Local variables ================================================== */
194.1141 +
194.1142 +    Int i ;
194.1143 +
194.1144 +    if (!knobs)
194.1145 +    {
194.1146 +        return ;                        /* no knobs to initialize */
194.1147 +    }
194.1148 +    for (i = 0 ; i < COLAMD_KNOBS ; i++)
194.1149 +    {
194.1150 +        knobs [i] = 0 ;
194.1151 +    }
194.1152 +    knobs [COLAMD_DENSE_ROW] = 10 ;
194.1153 +    knobs [COLAMD_DENSE_COL] = 10 ;
194.1154 +    knobs [COLAMD_AGGRESSIVE] = TRUE ;  /* default: do aggressive absorption*/
194.1155 +}
194.1156 +
194.1157 +
194.1158 +/* ========================================================================== */
194.1159 +/* === symamd =============================================================== */
194.1160 +/* ========================================================================== */
194.1161 +
194.1162 +PUBLIC Int SYMAMD_MAIN                  /* return TRUE if OK, FALSE otherwise */
194.1163 +(
194.1164 +    /* === Parameters ======================================================= */
194.1165 +
194.1166 +    Int n,                              /* number of rows and columns of A */
194.1167 +    Int A [],                           /* row indices of A */
194.1168 +    Int p [],                           /* column pointers of A */
194.1169 +    Int perm [],                        /* output permutation, size n+1 */
194.1170 +    double knobs [COLAMD_KNOBS],        /* parameters (uses defaults if NULL) */
194.1171 +    Int stats [COLAMD_STATS],           /* output statistics and error codes */
194.1172 +    void * (*allocate) (size_t, size_t),
194.1173 +                                        /* pointer to calloc (ANSI C) or */
194.1174 +                                        /* mxCalloc (for MATLAB mexFunction) */
194.1175 +    void (*release) (void *)
194.1176 +                                        /* pointer to free (ANSI C) or */
194.1177 +                                        /* mxFree (for MATLAB mexFunction) */
194.1178 +)
194.1179 +{
194.1180 +    /* === Local variables ================================================== */
194.1181 +
194.1182 +    Int *count ;                /* length of each column of M, and col pointer*/
194.1183 +    Int *mark ;                 /* mark array for finding duplicate entries */
194.1184 +    Int *M ;                    /* row indices of matrix M */
194.1185 +    size_t Mlen ;               /* length of M */
194.1186 +    Int n_row ;                 /* number of rows in M */
194.1187 +    Int nnz ;                   /* number of entries in A */
194.1188 +    Int i ;                     /* row index of A */
194.1189 +    Int j ;                     /* column index of A */
194.1190 +    Int k ;                     /* row index of M */ 
194.1191 +    Int mnz ;                   /* number of nonzeros in M */
194.1192 +    Int pp ;                    /* index into a column of A */
194.1193 +    Int last_row ;              /* last row seen in the current column */
194.1194 +    Int length ;                /* number of nonzeros in a column */
194.1195 +
194.1196 +    double cknobs [COLAMD_KNOBS] ;              /* knobs for colamd */
194.1197 +    double default_knobs [COLAMD_KNOBS] ;       /* default knobs for colamd */
194.1198 +
194.1199 +#ifndef NDEBUG
194.1200 +    colamd_get_debug ("symamd") ;
194.1201 +#endif /* NDEBUG */
194.1202 +
194.1203 +    /* === Check the input arguments ======================================== */
194.1204 +
194.1205 +    if (!stats)
194.1206 +    {
194.1207 +        DEBUG0 (("symamd: stats not present\n")) ;
194.1208 +        return (FALSE) ;
194.1209 +    }
194.1210 +    for (i = 0 ; i < COLAMD_STATS ; i++)
194.1211 +    {
194.1212 +        stats [i] = 0 ;
194.1213 +    }
194.1214 +    stats [COLAMD_STATUS] = COLAMD_OK ;
194.1215 +    stats [COLAMD_INFO1] = -1 ;
194.1216 +    stats [COLAMD_INFO2] = -1 ;
194.1217 +
194.1218 +    if (!A)
194.1219 +    {
194.1220 +        stats [COLAMD_STATUS] = COLAMD_ERROR_A_not_present ;
194.1221 +        DEBUG0 (("symamd: A not present\n")) ;
194.1222 +        return (FALSE) ;
194.1223 +    }
194.1224 +
194.1225 +    if (!p)             /* p is not present */
194.1226 +    {
194.1227 +        stats [COLAMD_STATUS] = COLAMD_ERROR_p_not_present ;
194.1228 +        DEBUG0 (("symamd: p not present\n")) ;
194.1229 +        return (FALSE) ;
194.1230 +    }
194.1231 +
194.1232 +    if (n < 0)          /* n must be >= 0 */
194.1233 +    {
194.1234 +        stats [COLAMD_STATUS] = COLAMD_ERROR_ncol_negative ;
194.1235 +        stats [COLAMD_INFO1] = n ;
194.1236 +        DEBUG0 (("symamd: n negative %d\n", n)) ;
194.1237 +        return (FALSE) ;
194.1238 +    }
194.1239 +
194.1240 +    nnz = p [n] ;
194.1241 +    if (nnz < 0)        /* nnz must be >= 0 */
194.1242 +    {
194.1243 +        stats [COLAMD_STATUS] = COLAMD_ERROR_nnz_negative ;
194.1244 +        stats [COLAMD_INFO1] = nnz ;
194.1245 +        DEBUG0 (("symamd: number of entries negative %d\n", nnz)) ;
194.1246 +        return (FALSE) ;
194.1247 +    }
194.1248 +
194.1249 +    if (p [0] != 0)
194.1250 +    {
194.1251 +        stats [COLAMD_STATUS] = COLAMD_ERROR_p0_nonzero ;
194.1252 +        stats [COLAMD_INFO1] = p [0] ;
194.1253 +        DEBUG0 (("symamd: p[0] not zero %d\n", p [0])) ;
194.1254 +        return (FALSE) ;
194.1255 +    }
194.1256 +
194.1257 +    /* === If no knobs, set default knobs =================================== */
194.1258 +
194.1259 +    if (!knobs)
194.1260 +    {
194.1261 +        COLAMD_set_defaults (default_knobs) ;
194.1262 +        knobs = default_knobs ;
194.1263 +    }
194.1264 +
194.1265 +    /* === Allocate count and mark ========================================== */
194.1266 +
194.1267 +    count = (Int *) ((*allocate) (n+1, sizeof (Int))) ;
194.1268 +    if (!count)
194.1269 +    {
194.1270 +        stats [COLAMD_STATUS] = COLAMD_ERROR_out_of_memory ;
194.1271 +        DEBUG0 (("symamd: allocate count (size %d) failed\n", n+1)) ;
194.1272 +        return (FALSE) ;
194.1273 +    }
194.1274 +
194.1275 +    mark = (Int *) ((*allocate) (n+1, sizeof (Int))) ;
194.1276 +    if (!mark)
194.1277 +    {
194.1278 +        stats [COLAMD_STATUS] = COLAMD_ERROR_out_of_memory ;
194.1279 +        (*release) ((void *) count) ;
194.1280 +        DEBUG0 (("symamd: allocate mark (size %d) failed\n", n+1)) ;
194.1281 +        return (FALSE) ;
194.1282 +    }
194.1283 +
194.1284 +    /* === Compute column counts of M, check if A is valid ================== */
194.1285 +
194.1286 +    stats [COLAMD_INFO3] = 0 ;  /* number of duplicate or unsorted row indices*/
194.1287 +
194.1288 +    for (i = 0 ; i < n ; i++)
194.1289 +    {
194.1290 +        mark [i] = -1 ;
194.1291 +    }
194.1292 +
194.1293 +    for (j = 0 ; j < n ; j++)
194.1294 +    {
194.1295 +        last_row = -1 ;
194.1296 +
194.1297 +        length = p [j+1] - p [j] ;
194.1298 +        if (length < 0)
194.1299 +        {
194.1300 +            /* column pointers must be non-decreasing */
194.1301 +            stats [COLAMD_STATUS] = COLAMD_ERROR_col_length_negative ;
194.1302 +            stats [COLAMD_INFO1] = j ;
194.1303 +            stats [COLAMD_INFO2] = length ;
194.1304 +            (*release) ((void *) count) ;
194.1305 +            (*release) ((void *) mark) ;
194.1306 +            DEBUG0 (("symamd: col %d negative length %d\n", j, length)) ;
194.1307 +            return (FALSE) ;
194.1308 +        }
194.1309 +
194.1310 +        for (pp = p [j] ; pp < p [j+1] ; pp++)
194.1311 +        {
194.1312 +            i = A [pp] ;
194.1313 +            if (i < 0 || i >= n)
194.1314 +            {
194.1315 +                /* row index i, in column j, is out of bounds */
194.1316 +                stats [COLAMD_STATUS] = COLAMD_ERROR_row_index_out_of_bounds ;
194.1317 +                stats [COLAMD_INFO1] = j ;
194.1318 +                stats [COLAMD_INFO2] = i ;
194.1319 +                stats [COLAMD_INFO3] = n ;
194.1320 +                (*release) ((void *) count) ;
194.1321 +                (*release) ((void *) mark) ;
194.1322 +                DEBUG0 (("symamd: row %d col %d out of bounds\n", i, j)) ;
194.1323 +                return (FALSE) ;
194.1324 +            }
194.1325 +
194.1326 +            if (i <= last_row || mark [i] == j)
194.1327 +            {
194.1328 +                /* row index is unsorted or repeated (or both), thus col */
194.1329 +                /* is jumbled.  This is a notice, not an error condition. */
194.1330 +                stats [COLAMD_STATUS] = COLAMD_OK_BUT_JUMBLED ;
194.1331 +                stats [COLAMD_INFO1] = j ;
194.1332 +                stats [COLAMD_INFO2] = i ;
194.1333 +                (stats [COLAMD_INFO3]) ++ ;
194.1334 +                DEBUG1 (("symamd: row %d col %d unsorted/duplicate\n", i, j)) ;
194.1335 +            }
194.1336 +
194.1337 +            if (i > j && mark [i] != j)
194.1338 +            {
194.1339 +                /* row k of M will contain column indices i and j */
194.1340 +                count [i]++ ;
194.1341 +                count [j]++ ;
194.1342 +            }
194.1343 +
194.1344 +            /* mark the row as having been seen in this column */
194.1345 +            mark [i] = j ;
194.1346 +
194.1347 +            last_row = i ;
194.1348 +        }
194.1349 +    }
194.1350 +
194.1351 +    /* v2.4: removed free(mark) */
194.1352 +
194.1353 +    /* === Compute column pointers of M ===================================== */
194.1354 +
194.1355 +    /* use output permutation, perm, for column pointers of M */
194.1356 +    perm [0] = 0 ;
194.1357 +    for (j = 1 ; j <= n ; j++)
194.1358 +    {
194.1359 +        perm [j] = perm [j-1] + count [j-1] ;
194.1360 +    }
194.1361 +    for (j = 0 ; j < n ; j++)
194.1362 +    {
194.1363 +        count [j] = perm [j] ;
194.1364 +    }
194.1365 +
194.1366 +    /* === Construct M ====================================================== */
194.1367 +
194.1368 +    mnz = perm [n] ;
194.1369 +    n_row = mnz / 2 ;
194.1370 +    Mlen = COLAMD_recommended (mnz, n_row, n) ;
194.1371 +    M = (Int *) ((*allocate) (Mlen, sizeof (Int))) ;
194.1372 +    DEBUG0 (("symamd: M is %d-by-%d with %d entries, Mlen = %g\n",
194.1373 +        n_row, n, mnz, (double) Mlen)) ;
194.1374 +
194.1375 +    if (!M)
194.1376 +    {
194.1377 +        stats [COLAMD_STATUS] = COLAMD_ERROR_out_of_memory ;
194.1378 +        (*release) ((void *) count) ;
194.1379 +        (*release) ((void *) mark) ;
194.1380 +        DEBUG0 (("symamd: allocate M (size %g) failed\n", (double) Mlen)) ;
194.1381 +        return (FALSE) ;
194.1382 +    }
194.1383 +
194.1384 +    k = 0 ;
194.1385 +
194.1386 +    if (stats [COLAMD_STATUS] == COLAMD_OK)
194.1387 +    {
194.1388 +        /* Matrix is OK */
194.1389 +        for (j = 0 ; j < n ; j++)
194.1390 +        {
194.1391 +            ASSERT (p [j+1] - p [j] >= 0) ;
194.1392 +            for (pp = p [j] ; pp < p [j+1] ; pp++)
194.1393 +            {
194.1394 +                i = A [pp] ;
194.1395 +                ASSERT (i >= 0 && i < n) ;
194.1396 +                if (i > j)
194.1397 +                {
194.1398 +                    /* row k of M contains column indices i and j */
194.1399 +                    M [count [i]++] = k ;
194.1400 +                    M [count [j]++] = k ;
194.1401 +                    k++ ;
194.1402 +                }
194.1403 +            }
194.1404 +        }
194.1405 +    }
194.1406 +    else
194.1407 +    {
194.1408 +        /* Matrix is jumbled.  Do not add duplicates to M.  Unsorted cols OK. */
194.1409 +        DEBUG0 (("symamd: Duplicates in A.\n")) ;
194.1410 +        for (i = 0 ; i < n ; i++)
194.1411 +        {
194.1412 +            mark [i] = -1 ;
194.1413 +        }
194.1414 +        for (j = 0 ; j < n ; j++)
194.1415 +        {
194.1416 +            ASSERT (p [j+1] - p [j] >= 0) ;
194.1417 +            for (pp = p [j] ; pp < p [j+1] ; pp++)
194.1418 +            {
194.1419 +                i = A [pp] ;
194.1420 +                ASSERT (i >= 0 && i < n) ;
194.1421 +                if (i > j && mark [i] != j)
194.1422 +                {
194.1423 +                    /* row k of M contains column indices i and j */
194.1424 +                    M [count [i]++] = k ;
194.1425 +                    M [count [j]++] = k ;
194.1426 +                    k++ ;
194.1427 +                    mark [i] = j ;
194.1428 +                }
194.1429 +            }
194.1430 +        }
194.1431 +        /* v2.4: free(mark) moved below */
194.1432 +    }
194.1433 +
194.1434 +    /* count and mark no longer needed */
194.1435 +    (*release) ((void *) count) ;
194.1436 +    (*release) ((void *) mark) ;        /* v2.4: free (mark) moved here */
194.1437 +    ASSERT (k == n_row) ;
194.1438 +
194.1439 +    /* === Adjust the knobs for M =========================================== */
194.1440 +
194.1441 +    for (i = 0 ; i < COLAMD_KNOBS ; i++)
194.1442 +    {
194.1443 +        cknobs [i] = knobs [i] ;
194.1444 +    }
194.1445 +
194.1446 +    /* there are no dense rows in M */
194.1447 +    cknobs [COLAMD_DENSE_ROW] = -1 ;
194.1448 +    cknobs [COLAMD_DENSE_COL] = knobs [COLAMD_DENSE_ROW] ;
194.1449 +
194.1450 +    /* === Order the columns of M =========================================== */
194.1451 +
194.1452 +    /* v2.4: colamd cannot fail here, so the error check is removed */
194.1453 +    (void) COLAMD_MAIN (n_row, n, (Int) Mlen, M, perm, cknobs, stats) ;
194.1454 +
194.1455 +    /* Note that the output permutation is now in perm */
194.1456 +
194.1457 +    /* === get the statistics for symamd from colamd ======================== */
194.1458 +
194.1459 +    /* a dense column in colamd means a dense row and col in symamd */
194.1460 +    stats [COLAMD_DENSE_ROW] = stats [COLAMD_DENSE_COL] ;
194.1461 +
194.1462 +    /* === Free M =========================================================== */
194.1463 +
194.1464 +    (*release) ((void *) M) ;
194.1465 +    DEBUG0 (("symamd: done.\n")) ;
194.1466 +    return (TRUE) ;
194.1467 +
194.1468 +}
194.1469 +
194.1470 +/* ========================================================================== */
194.1471 +/* === colamd =============================================================== */
194.1472 +/* ========================================================================== */
194.1473 +
194.1474 +/*
194.1475 +    The colamd routine computes a column ordering Q of a sparse matrix
194.1476 +    A such that the LU factorization P(AQ) = LU remains sparse, where P is
194.1477 +    selected via partial pivoting.   The routine can also be viewed as
194.1478 +    providing a permutation Q such that the Cholesky factorization
194.1479 +    (AQ)'(AQ) = LL' remains sparse.
194.1480 +*/
194.1481 +
194.1482 +PUBLIC Int COLAMD_MAIN          /* returns TRUE if successful, FALSE otherwise*/
194.1483 +(
194.1484 +    /* === Parameters ======================================================= */
194.1485 +
194.1486 +    Int n_row,                  /* number of rows in A */
194.1487 +    Int n_col,                  /* number of columns in A */
194.1488 +    Int Alen,                   /* length of A */
194.1489 +    Int A [],                   /* row indices of A */
194.1490 +    Int p [],                   /* pointers to columns in A */
194.1491 +    double knobs [COLAMD_KNOBS],/* parameters (uses defaults if NULL) */
194.1492 +    Int stats [COLAMD_STATS]    /* output statistics and error codes */
194.1493 +)
194.1494 +{
194.1495 +    /* === Local variables ================================================== */
194.1496 +
194.1497 +    Int i ;                     /* loop index */
194.1498 +    Int nnz ;                   /* nonzeros in A */
194.1499 +    size_t Row_size ;           /* size of Row [], in integers */
194.1500 +    size_t Col_size ;           /* size of Col [], in integers */
194.1501 +    size_t need ;               /* minimum required length of A */
194.1502 +    Colamd_Row *Row ;           /* pointer into A of Row [0..n_row] array */
194.1503 +    Colamd_Col *Col ;           /* pointer into A of Col [0..n_col] array */
194.1504 +    Int n_col2 ;                /* number of non-dense, non-empty columns */
194.1505 +    Int n_row2 ;                /* number of non-dense, non-empty rows */
194.1506 +    Int ngarbage ;              /* number of garbage collections performed */
194.1507 +    Int max_deg ;               /* maximum row degree */
194.1508 +    double default_knobs [COLAMD_KNOBS] ;       /* default knobs array */
194.1509 +    Int aggressive ;            /* do aggressive absorption */
194.1510 +    int ok ;
194.1511 +
194.1512 +#ifndef NDEBUG
194.1513 +    colamd_get_debug ("colamd") ;
194.1514 +#endif /* NDEBUG */
194.1515 +
194.1516 +    /* === Check the input arguments ======================================== */
194.1517 +
194.1518 +    if (!stats)
194.1519 +    {
194.1520 +        DEBUG0 (("colamd: stats not present\n")) ;
194.1521 +        return (FALSE) ;
194.1522 +    }
194.1523 +    for (i = 0 ; i < COLAMD_STATS ; i++)
194.1524 +    {
194.1525 +        stats [i] = 0 ;
194.1526 +    }
194.1527 +    stats [COLAMD_STATUS] = COLAMD_OK ;
194.1528 +    stats [COLAMD_INFO1] = -1 ;
194.1529 +    stats [COLAMD_INFO2] = -1 ;
194.1530 +
194.1531 +    if (!A)             /* A is not present */
194.1532 +    {
194.1533 +        stats [COLAMD_STATUS] = COLAMD_ERROR_A_not_present ;
194.1534 +        DEBUG0 (("colamd: A not present\n")) ;
194.1535 +        return (FALSE) ;
194.1536 +    }
194.1537 +
194.1538 +    if (!p)             /* p is not present */
194.1539 +    {
194.1540 +        stats [COLAMD_STATUS] = COLAMD_ERROR_p_not_present ;
194.1541 +        DEBUG0 (("colamd: p not present\n")) ;
194.1542 +        return (FALSE) ;
194.1543 +    }
194.1544 +
194.1545 +    if (n_row < 0)      /* n_row must be >= 0 */
194.1546 +    {
194.1547 +        stats [COLAMD_STATUS] = COLAMD_ERROR_nrow_negative ;
194.1548 +        stats [COLAMD_INFO1] = n_row ;
194.1549 +        DEBUG0 (("colamd: nrow negative %d\n", n_row)) ;
194.1550 +        return (FALSE) ;
194.1551 +    }
194.1552 +
194.1553 +    if (n_col < 0)      /* n_col must be >= 0 */
194.1554 +    {
194.1555 +        stats [COLAMD_STATUS] = COLAMD_ERROR_ncol_negative ;
194.1556 +        stats [COLAMD_INFO1] = n_col ;
194.1557 +        DEBUG0 (("colamd: ncol negative %d\n", n_col)) ;
194.1558 +        return (FALSE) ;
194.1559 +    }
194.1560 +
194.1561 +    nnz = p [n_col] ;
194.1562 +    if (nnz < 0)        /* nnz must be >= 0 */
194.1563 +    {
194.1564 +        stats [COLAMD_STATUS] = COLAMD_ERROR_nnz_negative ;
194.1565 +        stats [COLAMD_INFO1] = nnz ;
194.1566 +        DEBUG0 (("colamd: number of entries negative %d\n", nnz)) ;
194.1567 +        return (FALSE) ;
194.1568 +    }
194.1569 +
194.1570 +    if (p [0] != 0)
194.1571 +    {
194.1572 +        stats [COLAMD_STATUS] = COLAMD_ERROR_p0_nonzero ;
194.1573 +        stats [COLAMD_INFO1] = p [0] ;
194.1574 +        DEBUG0 (("colamd: p[0] not zero %d\n", p [0])) ;
194.1575 +        return (FALSE) ;
194.1576 +    }
194.1577 +
194.1578 +    /* === If no knobs, set default knobs =================================== */
194.1579 +
194.1580 +    if (!knobs)
194.1581 +    {
194.1582 +        COLAMD_set_defaults (default_knobs) ;
194.1583 +        knobs = default_knobs ;
194.1584 +    }
194.1585 +
194.1586 +    aggressive = (knobs [COLAMD_AGGRESSIVE] != FALSE) ;
194.1587 +
194.1588 +    /* === Allocate the Row and Col arrays from array A ===================== */
194.1589 +
194.1590 +    ok = TRUE ;
194.1591 +    Col_size = COLAMD_C (n_col, &ok) ;      /* size of Col array of structs */
194.1592 +    Row_size = COLAMD_R (n_row, &ok) ;      /* size of Row array of structs */
194.1593 +
194.1594 +    /* need = 2*nnz + n_col + Col_size + Row_size ; */
194.1595 +    need = t_mult (nnz, 2, &ok) ;
194.1596 +    need = t_add (need, n_col, &ok) ;
194.1597 +    need = t_add (need, Col_size, &ok) ;
194.1598 +    need = t_add (need, Row_size, &ok) ;
194.1599 +
194.1600 +    if (!ok || need > (size_t) Alen || need > Int_MAX)
194.1601 +    {
194.1602 +        /* not enough space in array A to perform the ordering */
194.1603 +        stats [COLAMD_STATUS] = COLAMD_ERROR_A_too_small ;
194.1604 +        stats [COLAMD_INFO1] = need ;
194.1605 +        stats [COLAMD_INFO2] = Alen ;
194.1606 +        DEBUG0 (("colamd: Need Alen >= %d, given only Alen = %d\n", need,Alen));
194.1607 +        return (FALSE) ;
194.1608 +    }
194.1609 +
194.1610 +    Alen -= Col_size + Row_size ;
194.1611 +    Col = (Colamd_Col *) &A [Alen] ;
194.1612 +    Row = (Colamd_Row *) &A [Alen + Col_size] ;
194.1613 +
194.1614 +    /* === Construct the row and column data structures ===================== */
194.1615 +
194.1616 +    if (!init_rows_cols (n_row, n_col, Row, Col, A, p, stats))
194.1617 +    {
194.1618 +        /* input matrix is invalid */
194.1619 +        DEBUG0 (("colamd: Matrix invalid\n")) ;
194.1620 +        return (FALSE) ;
194.1621 +    }
194.1622 +
194.1623 +    /* === Initialize scores, kill dense rows/columns ======================= */
194.1624 +
194.1625 +    init_scoring (n_row, n_col, Row, Col, A, p, knobs,
194.1626 +        &n_row2, &n_col2, &max_deg) ;
194.1627 +
194.1628 +    /* === Order the supercolumns =========================================== */
194.1629 +
194.1630 +    ngarbage = find_ordering (n_row, n_col, Alen, Row, Col, A, p,
194.1631 +        n_col2, max_deg, 2*nnz, aggressive) ;
194.1632 +
194.1633 +    /* === Order the non-principal columns ================================== */
194.1634 +
194.1635 +    order_children (n_col, Col, p) ;
194.1636 +
194.1637 +    /* === Return statistics in stats ======================================= */
194.1638 +
194.1639 +    stats [COLAMD_DENSE_ROW] = n_row - n_row2 ;
194.1640 +    stats [COLAMD_DENSE_COL] = n_col - n_col2 ;
194.1641 +    stats [COLAMD_DEFRAG_COUNT] = ngarbage ;
194.1642 +    DEBUG0 (("colamd: done.\n")) ; 
194.1643 +    return (TRUE) ;
194.1644 +}
194.1645 +
194.1646 +
194.1647 +/* ========================================================================== */
194.1648 +/* === colamd_report ======================================================== */
194.1649 +/* ========================================================================== */
194.1650 +
194.1651 +PUBLIC void COLAMD_report
194.1652 +(
194.1653 +    Int stats [COLAMD_STATS]
194.1654 +)
194.1655 +{
194.1656 +    print_report ("colamd", stats) ;
194.1657 +}
194.1658 +
194.1659 +
194.1660 +/* ========================================================================== */
194.1661 +/* === symamd_report ======================================================== */
194.1662 +/* ========================================================================== */
194.1663 +
194.1664 +PUBLIC void SYMAMD_report
194.1665 +(
194.1666 +    Int stats [COLAMD_STATS]
194.1667 +)
194.1668 +{
194.1669 +    print_report ("symamd", stats) ;
194.1670 +}
194.1671 +
194.1672 +
194.1673 +
194.1674 +/* ========================================================================== */
194.1675 +/* === NON-USER-CALLABLE ROUTINES: ========================================== */
194.1676 +/* ========================================================================== */
194.1677 +
194.1678 +/* There are no user-callable routines beyond this point in the file */
194.1679 +
194.1680 +
194.1681 +/* ========================================================================== */
194.1682 +/* === init_rows_cols ======================================================= */
194.1683 +/* ========================================================================== */
194.1684 +
194.1685 +/*
194.1686 +    Takes the column form of the matrix in A and creates the row form of the
194.1687 +    matrix.  Also, row and column attributes are stored in the Col and Row
194.1688 +    structs.  If the columns are un-sorted or contain duplicate row indices,
194.1689 +    this routine will also sort and remove duplicate row indices from the
194.1690 +    column form of the matrix.  Returns FALSE if the matrix is invalid,
194.1691 +    TRUE otherwise.  Not user-callable.
194.1692 +*/
194.1693 +
194.1694 +PRIVATE Int init_rows_cols      /* returns TRUE if OK, or FALSE otherwise */
194.1695 +(
194.1696 +    /* === Parameters ======================================================= */
194.1697 +
194.1698 +    Int n_row,                  /* number of rows of A */
194.1699 +    Int n_col,                  /* number of columns of A */
194.1700 +    Colamd_Row Row [],          /* of size n_row+1 */
194.1701 +    Colamd_Col Col [],          /* of size n_col+1 */
194.1702 +    Int A [],                   /* row indices of A, of size Alen */
194.1703 +    Int p [],                   /* pointers to columns in A, of size n_col+1 */
194.1704 +    Int stats [COLAMD_STATS]    /* colamd statistics */ 
194.1705 +)
194.1706 +{
194.1707 +    /* === Local variables ================================================== */
194.1708 +
194.1709 +    Int col ;                   /* a column index */
194.1710 +    Int row ;                   /* a row index */
194.1711 +    Int *cp ;                   /* a column pointer */
194.1712 +    Int *cp_end ;               /* a pointer to the end of a column */
194.1713 +    Int *rp ;                   /* a row pointer */
194.1714 +    Int *rp_end ;               /* a pointer to the end of a row */
194.1715 +    Int last_row ;              /* previous row */
194.1716 +
194.1717 +    /* === Initialize columns, and check column pointers ==================== */
194.1718 +
194.1719 +    for (col = 0 ; col < n_col ; col++)
194.1720 +    {
194.1721 +        Col [col].start = p [col] ;
194.1722 +        Col [col].length = p [col+1] - p [col] ;
194.1723 +
194.1724 +        if (Col [col].length < 0)
194.1725 +        {
194.1726 +            /* column pointers must be non-decreasing */
194.1727 +            stats [COLAMD_STATUS] = COLAMD_ERROR_col_length_negative ;
194.1728 +            stats [COLAMD_INFO1] = col ;
194.1729 +            stats [COLAMD_INFO2] = Col [col].length ;
194.1730 +            DEBUG0 (("colamd: col %d length %d < 0\n", col, Col [col].length)) ;
194.1731 +            return (FALSE) ;
194.1732 +        }
194.1733 +
194.1734 +        Col [col].shared1.thickness = 1 ;
194.1735 +        Col [col].shared2.score = 0 ;
194.1736 +        Col [col].shared3.prev = EMPTY ;
194.1737 +        Col [col].shared4.degree_next = EMPTY ;
194.1738 +    }
194.1739 +
194.1740 +    /* p [0..n_col] no longer needed, used as "head" in subsequent routines */
194.1741 +
194.1742 +    /* === Scan columns, compute row degrees, and check row indices ========= */
194.1743 +
194.1744 +    stats [COLAMD_INFO3] = 0 ;  /* number of duplicate or unsorted row indices*/
194.1745 +
194.1746 +    for (row = 0 ; row < n_row ; row++)
194.1747 +    {
194.1748 +        Row [row].length = 0 ;
194.1749 +        Row [row].shared2.mark = -1 ;
194.1750 +    }
194.1751 +
194.1752 +    for (col = 0 ; col < n_col ; col++)
194.1753 +    {
194.1754 +        last_row = -1 ;
194.1755 +
194.1756 +        cp = &A [p [col]] ;
194.1757 +        cp_end = &A [p [col+1]] ;
194.1758 +
194.1759 +        while (cp < cp_end)
194.1760 +        {
194.1761 +            row = *cp++ ;
194.1762 +
194.1763 +            /* make sure row indices within range */
194.1764 +            if (row < 0 || row >= n_row)
194.1765 +            {
194.1766 +                stats [COLAMD_STATUS] = COLAMD_ERROR_row_index_out_of_bounds ;
194.1767 +                stats [COLAMD_INFO1] = col ;
194.1768 +                stats [COLAMD_INFO2] = row ;
194.1769 +                stats [COLAMD_INFO3] = n_row ;
194.1770 +                DEBUG0 (("colamd: row %d col %d out of bounds\n", row, col)) ;
194.1771 +                return (FALSE) ;
194.1772 +            }
194.1773 +
194.1774 +            if (row <= last_row || Row [row].shared2.mark == col)
194.1775 +            {
194.1776 +                /* row index are unsorted or repeated (or both), thus col */
194.1777 +                /* is jumbled.  This is a notice, not an error condition. */
194.1778 +                stats [COLAMD_STATUS] = COLAMD_OK_BUT_JUMBLED ;
194.1779 +                stats [COLAMD_INFO1] = col ;
194.1780 +                stats [COLAMD_INFO2] = row ;
194.1781 +                (stats [COLAMD_INFO3]) ++ ;
194.1782 +                DEBUG1 (("colamd: row %d col %d unsorted/duplicate\n",row,col));
194.1783 +            }
194.1784 +
194.1785 +            if (Row [row].shared2.mark != col)
194.1786 +            {
194.1787 +                Row [row].length++ ;
194.1788 +            }
194.1789 +            else
194.1790 +            {
194.1791 +                /* this is a repeated entry in the column, */
194.1792 +                /* it will be removed */
194.1793 +                Col [col].length-- ;
194.1794 +            }
194.1795 +
194.1796 +            /* mark the row as having been seen in this column */
194.1797 +            Row [row].shared2.mark = col ;
194.1798 +
194.1799 +            last_row = row ;
194.1800 +        }
194.1801 +    }
194.1802 +
194.1803 +    /* === Compute row pointers ============================================= */
194.1804 +
194.1805 +    /* row form of the matrix starts directly after the column */
194.1806 +    /* form of matrix in A */
194.1807 +    Row [0].start = p [n_col] ;
194.1808 +    Row [0].shared1.p = Row [0].start ;
194.1809 +    Row [0].shared2.mark = -1 ;
194.1810 +    for (row = 1 ; row < n_row ; row++)
194.1811 +    {
194.1812 +        Row [row].start = Row [row-1].start + Row [row-1].length ;
194.1813 +        Row [row].shared1.p = Row [row].start ;
194.1814 +        Row [row].shared2.mark = -1 ;
194.1815 +    }
194.1816 +
194.1817 +    /* === Create row form ================================================== */
194.1818 +
194.1819 +    if (stats [COLAMD_STATUS] == COLAMD_OK_BUT_JUMBLED)
194.1820 +    {
194.1821 +        /* if cols jumbled, watch for repeated row indices */
194.1822 +        for (col = 0 ; col < n_col ; col++)
194.1823 +        {
194.1824 +            cp = &A [p [col]] ;
194.1825 +            cp_end = &A [p [col+1]] ;
194.1826 +            while (cp < cp_end)
194.1827 +            {
194.1828 +                row = *cp++ ;
194.1829 +                if (Row [row].shared2.mark != col)
194.1830 +                {
194.1831 +                    A [(Row [row].shared1.p)++] = col ;
194.1832 +                    Row [row].shared2.mark = col ;
194.1833 +                }
194.1834 +            }
194.1835 +        }
194.1836 +    }
194.1837 +    else
194.1838 +    {
194.1839 +        /* if cols not jumbled, we don't need the mark (this is faster) */
194.1840 +        for (col = 0 ; col < n_col ; col++)
194.1841 +        {
194.1842 +            cp = &A [p [col]] ;
194.1843 +            cp_end = &A [p [col+1]] ;
194.1844 +            while (cp < cp_end)
194.1845 +            {
194.1846 +                A [(Row [*cp++].shared1.p)++] = col ;
194.1847 +            }
194.1848 +        }
194.1849 +    }
194.1850 +
194.1851 +    /* === Clear the row marks and set row degrees ========================== */
194.1852 +
194.1853 +    for (row = 0 ; row < n_row ; row++)
194.1854 +    {
194.1855 +        Row [row].shared2.mark = 0 ;
194.1856 +        Row [row].shared1.degree = Row [row].length ;
194.1857 +    }
194.1858 +
194.1859 +    /* === See if we need to re-create columns ============================== */
194.1860 +
194.1861 +    if (stats [COLAMD_STATUS] == COLAMD_OK_BUT_JUMBLED)
194.1862 +    {
194.1863 +        DEBUG0 (("colamd: reconstructing column form, matrix jumbled\n")) ;
194.1864 +
194.1865 +#ifndef NDEBUG
194.1866 +        /* make sure column lengths are correct */
194.1867 +        for (col = 0 ; col < n_col ; col++)
194.1868 +        {
194.1869 +            p [col] = Col [col].length ;
194.1870 +        }
194.1871 +        for (row = 0 ; row < n_row ; row++)
194.1872 +        {
194.1873 +            rp = &A [Row [row].start] ;
194.1874 +            rp_end = rp + Row [row].length ;
194.1875 +            while (rp < rp_end)
194.1876 +            {
194.1877 +                p [*rp++]-- ;
194.1878 +            }
194.1879 +        }
194.1880 +        for (col = 0 ; col < n_col ; col++)
194.1881 +        {
194.1882 +            ASSERT (p [col] == 0) ;
194.1883 +        }
194.1884 +        /* now p is all zero (different than when debugging is turned off) */
194.1885 +#endif /* NDEBUG */
194.1886 +
194.1887 +        /* === Compute col pointers ========================================= */
194.1888 +
194.1889 +        /* col form of the matrix starts at A [0]. */
194.1890 +        /* Note, we may have a gap between the col form and the row */
194.1891 +        /* form if there were duplicate entries, if so, it will be */
194.1892 +        /* removed upon the first garbage collection */
194.1893 +        Col [0].start = 0 ;
194.1894 +        p [0] = Col [0].start ;
194.1895 +        for (col = 1 ; col < n_col ; col++)
194.1896 +        {
194.1897 +            /* note that the lengths here are for pruned columns, i.e. */
194.1898 +            /* no duplicate row indices will exist for these columns */
194.1899 +            Col [col].start = Col [col-1].start + Col [col-1].length ;
194.1900 +            p [col] = Col [col].start ;
194.1901 +        }
194.1902 +
194.1903 +        /* === Re-create col form =========================================== */
194.1904 +
194.1905 +        for (row = 0 ; row < n_row ; row++)
194.1906 +        {
194.1907 +            rp = &A [Row [row].start] ;
194.1908 +            rp_end = rp + Row [row].length ;
194.1909 +            while (rp < rp_end)
194.1910 +            {
194.1911 +                A [(p [*rp++])++] = row ;
194.1912 +            }
194.1913 +        }
194.1914 +    }
194.1915 +
194.1916 +    /* === Done.  Matrix is not (or no longer) jumbled ====================== */
194.1917 +
194.1918 +    return (TRUE) ;
194.1919 +}
194.1920 +
194.1921 +
194.1922 +/* ========================================================================== */
194.1923 +/* === init_scoring ========================================================= */
194.1924 +/* ========================================================================== */
194.1925 +
194.1926 +/*
194.1927 +    Kills dense or empty columns and rows, calculates an initial score for
194.1928 +    each column, and places all columns in the degree lists.  Not user-callable.
194.1929 +*/
194.1930 +
194.1931 +PRIVATE void init_scoring
194.1932 +(
194.1933 +    /* === Parameters ======================================================= */
194.1934 +
194.1935 +    Int n_row,                  /* number of rows of A */
194.1936 +    Int n_col,                  /* number of columns of A */
194.1937 +    Colamd_Row Row [],          /* of size n_row+1 */
194.1938 +    Colamd_Col Col [],          /* of size n_col+1 */
194.1939 +    Int A [],                   /* column form and row form of A */
194.1940 +    Int head [],                /* of size n_col+1 */
194.1941 +    double knobs [COLAMD_KNOBS],/* parameters */
194.1942 +    Int *p_n_row2,              /* number of non-dense, non-empty rows */
194.1943 +    Int *p_n_col2,              /* number of non-dense, non-empty columns */
194.1944 +    Int *p_max_deg              /* maximum row degree */
194.1945 +)
194.1946 +{
194.1947 +    /* === Local variables ================================================== */
194.1948 +
194.1949 +    Int c ;                     /* a column index */
194.1950 +    Int r, row ;                /* a row index */
194.1951 +    Int *cp ;                   /* a column pointer */
194.1952 +    Int deg ;                   /* degree of a row or column */
194.1953 +    Int *cp_end ;               /* a pointer to the end of a column */
194.1954 +    Int *new_cp ;               /* new column pointer */
194.1955 +    Int col_length ;            /* length of pruned column */
194.1956 +    Int score ;                 /* current column score */
194.1957 +    Int n_col2 ;                /* number of non-dense, non-empty columns */
194.1958 +    Int n_row2 ;                /* number of non-dense, non-empty rows */
194.1959 +    Int dense_row_count ;       /* remove rows with more entries than this */
194.1960 +    Int dense_col_count ;       /* remove cols with more entries than this */
194.1961 +    Int min_score ;             /* smallest column score */
194.1962 +    Int max_deg ;               /* maximum row degree */
194.1963 +    Int next_col ;              /* Used to add to degree list.*/
194.1964 +
194.1965 +#ifndef NDEBUG
194.1966 +    Int debug_count ;           /* debug only. */
194.1967 +#endif /* NDEBUG */
194.1968 +
194.1969 +    /* === Extract knobs ==================================================== */
194.1970 +
194.1971 +    /* Note: if knobs contains a NaN, this is undefined: */
194.1972 +    if (knobs [COLAMD_DENSE_ROW] < 0)
194.1973 +    {
194.1974 +        /* only remove completely dense rows */
194.1975 +        dense_row_count = n_col-1 ;
194.1976 +    }
194.1977 +    else
194.1978 +    {
194.1979 +        dense_row_count = DENSE_DEGREE (knobs [COLAMD_DENSE_ROW], n_col) ;
194.1980 +    }
194.1981 +    if (knobs [COLAMD_DENSE_COL] < 0)
194.1982 +    {
194.1983 +        /* only remove completely dense columns */
194.1984 +        dense_col_count = n_row-1 ;
194.1985 +    }
194.1986 +    else
194.1987 +    {
194.1988 +        dense_col_count =
194.1989 +            DENSE_DEGREE (knobs [COLAMD_DENSE_COL], MIN (n_row, n_col)) ;
194.1990 +    }
194.1991 +
194.1992 +    DEBUG1 (("colamd: densecount: %d %d\n", dense_row_count, dense_col_count)) ;
194.1993 +    max_deg = 0 ;
194.1994 +    n_col2 = n_col ;
194.1995 +    n_row2 = n_row ;
194.1996 +
194.1997 +    /* === Kill empty columns =============================================== */
194.1998 +
194.1999 +    /* Put the empty columns at the end in their natural order, so that LU */
194.2000 +    /* factorization can proceed as far as possible. */
194.2001 +    for (c = n_col-1 ; c >= 0 ; c--)
194.2002 +    {
194.2003 +        deg = Col [c].length ;
194.2004 +        if (deg == 0)
194.2005 +        {
194.2006 +            /* this is a empty column, kill and order it last */
194.2007 +            Col [c].shared2.order = --n_col2 ;
194.2008 +            KILL_PRINCIPAL_COL (c) ;
194.2009 +        }
194.2010 +    }
194.2011 +    DEBUG1 (("colamd: null columns killed: %d\n", n_col - n_col2)) ;
194.2012 +
194.2013 +    /* === Kill dense columns =============================================== */
194.2014 +
194.2015 +    /* Put the dense columns at the end, in their natural order */
194.2016 +    for (c = n_col-1 ; c >= 0 ; c--)
194.2017 +    {
194.2018 +        /* skip any dead columns */
194.2019 +        if (COL_IS_DEAD (c))
194.2020 +        {
194.2021 +            continue ;
194.2022 +        }
194.2023 +        deg = Col [c].length ;
194.2024 +        if (deg > dense_col_count)
194.2025 +        {
194.2026 +            /* this is a dense column, kill and order it last */
194.2027 +            Col [c].shared2.order = --n_col2 ;
194.2028 +            /* decrement the row degrees */
194.2029 +            cp = &A [Col [c].start] ;
194.2030 +            cp_end = cp + Col [c].length ;
194.2031 +            while (cp < cp_end)
194.2032 +            {
194.2033 +                Row [*cp++].shared1.degree-- ;
194.2034 +            }
194.2035 +            KILL_PRINCIPAL_COL (c) ;
194.2036 +        }
194.2037 +    }
194.2038 +    DEBUG1 (("colamd: Dense and null columns killed: %d\n", n_col - n_col2)) ;
194.2039 +
194.2040 +    /* === Kill dense and empty rows ======================================== */
194.2041 +
194.2042 +    for (r = 0 ; r < n_row ; r++)
194.2043 +    {
194.2044 +        deg = Row [r].shared1.degree ;
194.2045 +        ASSERT (deg >= 0 && deg <= n_col) ;
194.2046 +        if (deg > dense_row_count || deg == 0)
194.2047 +        {
194.2048 +            /* kill a dense or empty row */
194.2049 +            KILL_ROW (r) ;
194.2050 +            --n_row2 ;
194.2051 +        }
194.2052 +        else
194.2053 +        {
194.2054 +            /* keep track of max degree of remaining rows */
194.2055 +            max_deg = MAX (max_deg, deg) ;
194.2056 +        }
194.2057 +    }
194.2058 +    DEBUG1 (("colamd: Dense and null rows killed: %d\n", n_row - n_row2)) ;
194.2059 +
194.2060 +    /* === Compute initial column scores ==================================== */
194.2061 +
194.2062 +    /* At this point the row degrees are accurate.  They reflect the number */
194.2063 +    /* of "live" (non-dense) columns in each row.  No empty rows exist. */
194.2064 +    /* Some "live" columns may contain only dead rows, however.  These are */
194.2065 +    /* pruned in the code below. */
194.2066 +
194.2067 +    /* now find the initial matlab score for each column */
194.2068 +    for (c = n_col-1 ; c >= 0 ; c--)
194.2069 +    {
194.2070 +        /* skip dead column */
194.2071 +        if (COL_IS_DEAD (c))
194.2072 +        {
194.2073 +            continue ;
194.2074 +        }
194.2075 +        score = 0 ;
194.2076 +        cp = &A [Col [c].start] ;
194.2077 +        new_cp = cp ;
194.2078 +        cp_end = cp + Col [c].length ;
194.2079 +        while (cp < cp_end)
194.2080 +        {
194.2081 +            /* get a row */
194.2082 +            row = *cp++ ;
194.2083 +            /* skip if dead */
194.2084 +            if (ROW_IS_DEAD (row))
194.2085 +            {
194.2086 +                continue ;
194.2087 +            }
194.2088 +            /* compact the column */
194.2089 +            *new_cp++ = row ;
194.2090 +            /* add row's external degree */
194.2091 +            score += Row [row].shared1.degree - 1 ;
194.2092 +            /* guard against integer overflow */
194.2093 +            score = MIN (score, n_col) ;
194.2094 +        }
194.2095 +        /* determine pruned column length */
194.2096 +        col_length = (Int) (new_cp - &A [Col [c].start]) ;
194.2097 +        if (col_length == 0)
194.2098 +        {
194.2099 +            /* a newly-made null column (all rows in this col are "dense" */
194.2100 +            /* and have already been killed) */
194.2101 +            DEBUG2 (("Newly null killed: %d\n", c)) ;
194.2102 +            Col [c].shared2.order = --n_col2 ;
194.2103 +            KILL_PRINCIPAL_COL (c) ;
194.2104 +        }
194.2105 +        else
194.2106 +        {
194.2107 +            /* set column length and set score */
194.2108 +            ASSERT (score >= 0) ;
194.2109 +            ASSERT (score <= n_col) ;
194.2110 +            Col [c].length = col_length ;
194.2111 +            Col [c].shared2.score = score ;
194.2112 +        }
194.2113 +    }
194.2114 +    DEBUG1 (("colamd: Dense, null, and newly-null columns killed: %d\n",
194.2115 +        n_col-n_col2)) ;
194.2116 +
194.2117 +    /* At this point, all empty rows and columns are dead.  All live columns */
194.2118 +    /* are "clean" (containing no dead rows) and simplicial (no supercolumns */
194.2119 +    /* yet).  Rows may contain dead columns, but all live rows contain at */
194.2120 +    /* least one live column. */
194.2121 +
194.2122 +#ifndef NDEBUG
194.2123 +    debug_structures (n_row, n_col, Row, Col, A, n_col2) ;
194.2124 +#endif /* NDEBUG */
194.2125 +
194.2126 +    /* === Initialize degree lists ========================================== */
194.2127 +
194.2128 +#ifndef NDEBUG
194.2129 +    debug_count = 0 ;
194.2130 +#endif /* NDEBUG */
194.2131 +
194.2132 +    /* clear the hash buckets */
194.2133 +    for (c = 0 ; c <= n_col ; c++)
194.2134 +    {
194.2135 +        head [c] = EMPTY ;
194.2136 +    }
194.2137 +    min_score = n_col ;
194.2138 +    /* place in reverse order, so low column indices are at the front */
194.2139 +    /* of the lists.  This is to encourage natural tie-breaking */
194.2140 +    for (c = n_col-1 ; c >= 0 ; c--)
194.2141 +    {
194.2142 +        /* only add principal columns to degree lists */
194.2143 +        if (COL_IS_ALIVE (c))
194.2144 +        {
194.2145 +            DEBUG4 (("place %d score %d minscore %d ncol %d\n",
194.2146 +                c, Col [c].shared2.score, min_score, n_col)) ;
194.2147 +
194.2148 +            /* === Add columns score to DList =============================== */
194.2149 +
194.2150 +            score = Col [c].shared2.score ;
194.2151 +
194.2152 +            ASSERT (min_score >= 0) ;
194.2153 +            ASSERT (min_score <= n_col) ;
194.2154 +            ASSERT (score >= 0) ;
194.2155 +            ASSERT (score <= n_col) ;
194.2156 +            ASSERT (head [score] >= EMPTY) ;
194.2157 +
194.2158 +            /* now add this column to dList at proper score location */
194.2159 +            next_col = head [score] ;
194.2160 +            Col [c].shared3.prev = EMPTY ;
194.2161 +            Col [c].shared4.degree_next = next_col ;
194.2162 +
194.2163 +            /* if there already was a column with the same score, set its */
194.2164 +            /* previous pointer to this new column */
194.2165 +            if (next_col != EMPTY)
194.2166 +            {
194.2167 +                Col [next_col].shared3.prev = c ;
194.2168 +            }
194.2169 +            head [score] = c ;
194.2170 +
194.2171 +            /* see if this score is less than current min */
194.2172 +            min_score = MIN (min_score, score) ;
194.2173 +
194.2174 +#ifndef NDEBUG
194.2175 +            debug_count++ ;
194.2176 +#endif /* NDEBUG */
194.2177 +
194.2178 +        }
194.2179 +    }
194.2180 +
194.2181 +#ifndef NDEBUG
194.2182 +    DEBUG1 (("colamd: Live cols %d out of %d, non-princ: %d\n",
194.2183 +        debug_count, n_col, n_col-debug_count)) ;
194.2184 +    ASSERT (debug_count == n_col2) ;
194.2185 +    debug_deg_lists (n_row, n_col, Row, Col, head, min_score, n_col2, max_deg) ;
194.2186 +#endif /* NDEBUG */
194.2187 +
194.2188 +    /* === Return number of remaining columns, and max row degree =========== */
194.2189 +
194.2190 +    *p_n_col2 = n_col2 ;
194.2191 +    *p_n_row2 = n_row2 ;
194.2192 +    *p_max_deg = max_deg ;
194.2193 +}
194.2194 +
194.2195 +
194.2196 +/* ========================================================================== */
194.2197 +/* === find_ordering ======================================================== */
194.2198 +/* ========================================================================== */
194.2199 +
194.2200 +/*
194.2201 +    Order the principal columns of the supercolumn form of the matrix
194.2202 +    (no supercolumns on input).  Uses a minimum approximate column minimum
194.2203 +    degree ordering method.  Not user-callable.
194.2204 +*/
194.2205 +
194.2206 +PRIVATE Int find_ordering       /* return the number of garbage collections */
194.2207 +(
194.2208 +    /* === Parameters ======================================================= */
194.2209 +
194.2210 +    Int n_row,                  /* number of rows of A */
194.2211 +    Int n_col,                  /* number of columns of A */
194.2212 +    Int Alen,                   /* size of A, 2*nnz + n_col or larger */
194.2213 +    Colamd_Row Row [],          /* of size n_row+1 */
194.2214 +    Colamd_Col Col [],          /* of size n_col+1 */
194.2215 +    Int A [],                   /* column form and row form of A */
194.2216 +    Int head [],                /* of size n_col+1 */
194.2217 +    Int n_col2,                 /* Remaining columns to order */
194.2218 +    Int max_deg,                /* Maximum row degree */
194.2219 +    Int pfree,                  /* index of first free slot (2*nnz on entry) */
194.2220 +    Int aggressive
194.2221 +)
194.2222 +{
194.2223 +    /* === Local variables ================================================== */
194.2224 +
194.2225 +    Int k ;                     /* current pivot ordering step */
194.2226 +    Int pivot_col ;             /* current pivot column */
194.2227 +    Int *cp ;                   /* a column pointer */
194.2228 +    Int *rp ;                   /* a row pointer */
194.2229 +    Int pivot_row ;             /* current pivot row */
194.2230 +    Int *new_cp ;               /* modified column pointer */
194.2231 +    Int *new_rp ;               /* modified row pointer */
194.2232 +    Int pivot_row_start ;       /* pointer to start of pivot row */
194.2233 +    Int pivot_row_degree ;      /* number of columns in pivot row */
194.2234 +    Int pivot_row_length ;      /* number of supercolumns in pivot row */
194.2235 +    Int pivot_col_score ;       /* score of pivot column */
194.2236 +    Int needed_memory ;         /* free space needed for pivot row */
194.2237 +    Int *cp_end ;               /* pointer to the end of a column */
194.2238 +    Int *rp_end ;               /* pointer to the end of a row */
194.2239 +    Int row ;                   /* a row index */
194.2240 +    Int col ;                   /* a column index */
194.2241 +    Int max_score ;             /* maximum possible score */
194.2242 +    Int cur_score ;             /* score of current column */
194.2243 +    unsigned Int hash ;         /* hash value for supernode detection */
194.2244 +    Int head_column ;           /* head of hash bucket */
194.2245 +    Int first_col ;             /* first column in hash bucket */
194.2246 +    Int tag_mark ;              /* marker value for mark array */
194.2247 +    Int row_mark ;              /* Row [row].shared2.mark */
194.2248 +    Int set_difference ;        /* set difference size of row with pivot row */
194.2249 +    Int min_score ;             /* smallest column score */
194.2250 +    Int col_thickness ;         /* "thickness" (no. of columns in a supercol) */
194.2251 +    Int max_mark ;              /* maximum value of tag_mark */
194.2252 +    Int pivot_col_thickness ;   /* number of columns represented by pivot col */
194.2253 +    Int prev_col ;              /* Used by Dlist operations. */
194.2254 +    Int next_col ;              /* Used by Dlist operations. */
194.2255 +    Int ngarbage ;              /* number of garbage collections performed */
194.2256 +
194.2257 +#ifndef NDEBUG
194.2258 +    Int debug_d ;               /* debug loop counter */
194.2259 +    Int debug_step = 0 ;        /* debug loop counter */
194.2260 +#endif /* NDEBUG */
194.2261 +
194.2262 +    /* === Initialization and clear mark ==================================== */
194.2263 +
194.2264 +    max_mark = INT_MAX - n_col ;        /* INT_MAX defined in <limits.h> */
194.2265 +    tag_mark = clear_mark (0, max_mark, n_row, Row) ;
194.2266 +    min_score = 0 ;
194.2267 +    ngarbage = 0 ;
194.2268 +    DEBUG1 (("colamd: Ordering, n_col2=%d\n", n_col2)) ;
194.2269 +
194.2270 +    /* === Order the columns ================================================ */
194.2271 +
194.2272 +    for (k = 0 ; k < n_col2 ; /* 'k' is incremented below */)
194.2273 +    {
194.2274 +
194.2275 +#ifndef NDEBUG
194.2276 +        if (debug_step % 100 == 0)
194.2277 +        {
194.2278 +            DEBUG2 (("\n...       Step k: %d out of n_col2: %d\n", k, n_col2)) ;
194.2279 +        }
194.2280 +        else
194.2281 +        {
194.2282 +            DEBUG3 (("\n----------Step k: %d out of n_col2: %d\n", k, n_col2)) ;
194.2283 +        }
194.2284 +        debug_step++ ;
194.2285 +        debug_deg_lists (n_row, n_col, Row, Col, head,
194.2286 +                min_score, n_col2-k, max_deg) ;
194.2287 +        debug_matrix (n_row, n_col, Row, Col, A) ;
194.2288 +#endif /* NDEBUG */
194.2289 +
194.2290 +        /* === Select pivot column, and order it ============================ */
194.2291 +
194.2292 +        /* make sure degree list isn't empty */
194.2293 +        ASSERT (min_score >= 0) ;
194.2294 +        ASSERT (min_score <= n_col) ;
194.2295 +        ASSERT (head [min_score] >= EMPTY) ;
194.2296 +
194.2297 +#ifndef NDEBUG
194.2298 +        for (debug_d = 0 ; debug_d < min_score ; debug_d++)
194.2299 +        {
194.2300 +            ASSERT (head [debug_d] == EMPTY) ;
194.2301 +        }
194.2302 +#endif /* NDEBUG */
194.2303 +
194.2304 +        /* get pivot column from head of minimum degree list */
194.2305 +        while (head [min_score] == EMPTY && min_score < n_col)
194.2306 +        {
194.2307 +            min_score++ ;
194.2308 +        }
194.2309 +        pivot_col = head [min_score] ;
194.2310 +        ASSERT (pivot_col >= 0 && pivot_col <= n_col) ;
194.2311 +        next_col = Col [pivot_col].shared4.degree_next ;
194.2312 +        head [min_score] = next_col ;
194.2313 +        if (next_col != EMPTY)
194.2314 +        {
194.2315 +            Col [next_col].shared3.prev = EMPTY ;
194.2316 +        }
194.2317 +
194.2318 +        ASSERT (COL_IS_ALIVE (pivot_col)) ;
194.2319 +
194.2320 +        /* remember score for defrag check */
194.2321 +        pivot_col_score = Col [pivot_col].shared2.score ;
194.2322 +
194.2323 +        /* the pivot column is the kth column in the pivot order */
194.2324 +        Col [pivot_col].shared2.order = k ;
194.2325 +
194.2326 +        /* increment order count by column thickness */
194.2327 +        pivot_col_thickness = Col [pivot_col].shared1.thickness ;
194.2328 +        k += pivot_col_thickness ;
194.2329 +        ASSERT (pivot_col_thickness > 0) ;
194.2330 +        DEBUG3 (("Pivot col: %d thick %d\n", pivot_col, pivot_col_thickness)) ;
194.2331 +
194.2332 +        /* === Garbage_collection, if necessary ============================= */
194.2333 +
194.2334 +        needed_memory = MIN (pivot_col_score, n_col - k) ;
194.2335 +        if (pfree + needed_memory >= Alen)
194.2336 +        {
194.2337 +            pfree = garbage_collection (n_row, n_col, Row, Col, A, &A [pfree]) ;
194.2338 +            ngarbage++ ;
194.2339 +            /* after garbage collection we will have enough */
194.2340 +            ASSERT (pfree + needed_memory < Alen) ;
194.2341 +            /* garbage collection has wiped out the Row[].shared2.mark array */
194.2342 +            tag_mark = clear_mark (0, max_mark, n_row, Row) ;
194.2343 +
194.2344 +#ifndef NDEBUG
194.2345 +            debug_matrix (n_row, n_col, Row, Col, A) ;
194.2346 +#endif /* NDEBUG */
194.2347 +        }
194.2348 +
194.2349 +        /* === Compute pivot row pattern ==================================== */
194.2350 +
194.2351 +        /* get starting location for this new merged row */
194.2352 +        pivot_row_start = pfree ;
194.2353 +
194.2354 +        /* initialize new row counts to zero */
194.2355 +        pivot_row_degree = 0 ;
194.2356 +
194.2357 +        /* tag pivot column as having been visited so it isn't included */
194.2358 +        /* in merged pivot row */
194.2359 +        Col [pivot_col].shared1.thickness = -pivot_col_thickness ;
194.2360 +
194.2361 +        /* pivot row is the union of all rows in the pivot column pattern */
194.2362 +        cp = &A [Col [pivot_col].start] ;
194.2363 +        cp_end = cp + Col [pivot_col].length ;
194.2364 +        while (cp < cp_end)
194.2365 +        {
194.2366 +            /* get a row */
194.2367 +            row = *cp++ ;
194.2368 +            DEBUG4 (("Pivot col pattern %d %d\n", ROW_IS_ALIVE (row), row)) ;
194.2369 +            /* skip if row is dead */
194.2370 +            if (ROW_IS_ALIVE (row))
194.2371 +            {
194.2372 +                rp = &A [Row [row].start] ;
194.2373 +                rp_end = rp + Row [row].length ;
194.2374 +                while (rp < rp_end)
194.2375 +                {
194.2376 +                    /* get a column */
194.2377 +                    col = *rp++ ;
194.2378 +                    /* add the column, if alive and untagged */
194.2379 +                    col_thickness = Col [col].shared1.thickness ;
194.2380 +                    if (col_thickness > 0 && COL_IS_ALIVE (col))
194.2381 +                    {
194.2382 +                        /* tag column in pivot row */
194.2383 +                        Col [col].shared1.thickness = -col_thickness ;
194.2384 +                        ASSERT (pfree < Alen) ;
194.2385 +                        /* place column in pivot row */
194.2386 +                        A [pfree++] = col ;
194.2387 +                        pivot_row_degree += col_thickness ;
194.2388 +                    }
194.2389 +                }
194.2390 +            }
194.2391 +        }
194.2392 +
194.2393 +        /* clear tag on pivot column */
194.2394 +        Col [pivot_col].shared1.thickness = pivot_col_thickness ;
194.2395 +        max_deg = MAX (max_deg, pivot_row_degree) ;
194.2396 +
194.2397 +#ifndef NDEBUG
194.2398 +        DEBUG3 (("check2\n")) ;
194.2399 +        debug_mark (n_row, Row, tag_mark, max_mark) ;
194.2400 +#endif /* NDEBUG */
194.2401 +
194.2402 +        /* === Kill all rows used to construct pivot row ==================== */
194.2403 +
194.2404 +        /* also kill pivot row, temporarily */
194.2405 +        cp = &A [Col [pivot_col].start] ;
194.2406 +        cp_end = cp + Col [pivot_col].length ;
194.2407 +        while (cp < cp_end)
194.2408 +        {
194.2409 +            /* may be killing an already dead row */
194.2410 +            row = *cp++ ;
194.2411 +            DEBUG3 (("Kill row in pivot col: %d\n", row)) ;
194.2412 +            KILL_ROW (row) ;
194.2413 +        }
194.2414 +
194.2415 +        /* === Select a row index to use as the new pivot row =============== */
194.2416 +
194.2417 +        pivot_row_length = pfree - pivot_row_start ;
194.2418 +        if (pivot_row_length > 0)
194.2419 +        {
194.2420 +            /* pick the "pivot" row arbitrarily (first row in col) */
194.2421 +            pivot_row = A [Col [pivot_col].start] ;
194.2422 +            DEBUG3 (("Pivotal row is %d\n", pivot_row)) ;
194.2423 +        }
194.2424 +        else
194.2425 +        {
194.2426 +            /* there is no pivot row, since it is of zero length */
194.2427 +            pivot_row = EMPTY ;
194.2428 +            ASSERT (pivot_row_length == 0) ;
194.2429 +        }
194.2430 +        ASSERT (Col [pivot_col].length > 0 || pivot_row_length == 0) ;
194.2431 +
194.2432 +        /* === Approximate degree computation =============================== */
194.2433 +
194.2434 +        /* Here begins the computation of the approximate degree.  The column */
194.2435 +        /* score is the sum of the pivot row "length", plus the size of the */
194.2436 +        /* set differences of each row in the column minus the pattern of the */
194.2437 +        /* pivot row itself.  The column ("thickness") itself is also */
194.2438 +        /* excluded from the column score (we thus use an approximate */
194.2439 +        /* external degree). */
194.2440 +
194.2441 +        /* The time taken by the following code (compute set differences, and */
194.2442 +        /* add them up) is proportional to the size of the data structure */
194.2443 +        /* being scanned - that is, the sum of the sizes of each column in */
194.2444 +        /* the pivot row.  Thus, the amortized time to compute a column score */
194.2445 +        /* is proportional to the size of that column (where size, in this */
194.2446 +        /* context, is the column "length", or the number of row indices */
194.2447 +        /* in that column).  The number of row indices in a column is */
194.2448 +        /* monotonically non-decreasing, from the length of the original */
194.2449 +        /* column on input to colamd. */
194.2450 +
194.2451 +        /* === Compute set differences ====================================== */
194.2452 +
194.2453 +        DEBUG3 (("** Computing set differences phase. **\n")) ;
194.2454 +
194.2455 +        /* pivot row is currently dead - it will be revived later. */
194.2456 +
194.2457 +        DEBUG3 (("Pivot row: ")) ;
194.2458 +        /* for each column in pivot row */
194.2459 +        rp = &A [pivot_row_start] ;
194.2460 +        rp_end = rp + pivot_row_length ;
194.2461 +        while (rp < rp_end)
194.2462 +        {
194.2463 +            col = *rp++ ;
194.2464 +            ASSERT (COL_IS_ALIVE (col) && col != pivot_col) ;
194.2465 +            DEBUG3 (("Col: %d\n", col)) ;
194.2466 +
194.2467 +            /* clear tags used to construct pivot row pattern */
194.2468 +            col_thickness = -Col [col].shared1.thickness ;
194.2469 +            ASSERT (col_thickness > 0) ;
194.2470 +            Col [col].shared1.thickness = col_thickness ;
194.2471 +
194.2472 +            /* === Remove column from degree list =========================== */
194.2473 +
194.2474 +            cur_score = Col [col].shared2.score ;
194.2475 +            prev_col = Col [col].shared3.prev ;
194.2476 +            next_col = Col [col].shared4.degree_next ;
194.2477 +            ASSERT (cur_score >= 0) ;
194.2478 +            ASSERT (cur_score <= n_col) ;
194.2479 +            ASSERT (cur_score >= EMPTY) ;
194.2480 +            if (prev_col == EMPTY)
194.2481 +            {
194.2482 +                head [cur_score] = next_col ;
194.2483 +            }
194.2484 +            else
194.2485 +            {
194.2486 +                Col [prev_col].shared4.degree_next = next_col ;
194.2487 +            }
194.2488 +            if (next_col != EMPTY)
194.2489 +            {
194.2490 +                Col [next_col].shared3.prev = prev_col ;
194.2491 +            }
194.2492 +
194.2493 +            /* === Scan the column ========================================== */
194.2494 +
194.2495 +            cp = &A [Col [col].start] ;
194.2496 +            cp_end = cp + Col [col].length ;
194.2497 +            while (cp < cp_end)
194.2498 +            {
194.2499 +                /* get a row */
194.2500 +                row = *cp++ ;
194.2501 +                row_mark = Row [row].shared2.mark ;
194.2502 +                /* skip if dead */
194.2503 +                if (ROW_IS_MARKED_DEAD (row_mark))
194.2504 +                {
194.2505 +                    continue ;
194.2506 +                }
194.2507 +                ASSERT (row != pivot_row) ;
194.2508 +                set_difference = row_mark - tag_mark ;
194.2509 +                /* check if the row has been seen yet */
194.2510 +                if (set_difference < 0)
194.2511 +                {
194.2512 +                    ASSERT (Row [row].shared1.degree <= max_deg) ;
194.2513 +                    set_difference = Row [row].shared1.degree ;
194.2514 +                }
194.2515 +                /* subtract column thickness from this row's set difference */
194.2516 +                set_difference -= col_thickness ;
194.2517 +                ASSERT (set_difference >= 0) ;
194.2518 +                /* absorb this row if the set difference becomes zero */
194.2519 +                if (set_difference == 0 && aggressive)
194.2520 +                {
194.2521 +                    DEBUG3 (("aggressive absorption. Row: %d\n", row)) ;
194.2522 +                    KILL_ROW (row) ;
194.2523 +                }
194.2524 +                else
194.2525 +                {
194.2526 +                    /* save the new mark */
194.2527 +                    Row [row].shared2.mark = set_difference + tag_mark ;
194.2528 +                }
194.2529 +            }
194.2530 +        }
194.2531 +
194.2532 +#ifndef NDEBUG
194.2533 +        debug_deg_lists (n_row, n_col, Row, Col, head,
194.2534 +                min_score, n_col2-k-pivot_row_degree, max_deg) ;
194.2535 +#endif /* NDEBUG */
194.2536 +
194.2537 +        /* === Add up set differences for each column ======================= */
194.2538 +
194.2539 +        DEBUG3 (("** Adding set differences phase. **\n")) ;
194.2540 +
194.2541 +        /* for each column in pivot row */
194.2542 +        rp = &A [pivot_row_start] ;
194.2543 +        rp_end = rp + pivot_row_length ;
194.2544 +        while (rp < rp_end)
194.2545 +        {
194.2546 +            /* get a column */
194.2547 +            col = *rp++ ;
194.2548 +            ASSERT (COL_IS_ALIVE (col) && col != pivot_col) ;
194.2549 +            hash = 0 ;
194.2550 +            cur_score = 0 ;
194.2551 +            cp = &A [Col [col].start] ;
194.2552 +            /* compact the column */
194.2553 +            new_cp = cp ;
194.2554 +            cp_end = cp + Col [col].length ;
194.2555 +
194.2556 +            DEBUG4 (("Adding set diffs for Col: %d.\n", col)) ;
194.2557 +
194.2558 +            while (cp < cp_end)
194.2559 +            {
194.2560 +                /* get a row */
194.2561 +                row = *cp++ ;
194.2562 +                ASSERT(row >= 0 && row < n_row) ;
194.2563 +                row_mark = Row [row].shared2.mark ;
194.2564 +                /* skip if dead */
194.2565 +                if (ROW_IS_MARKED_DEAD (row_mark))
194.2566 +                {
194.2567 +                    DEBUG4 ((" Row %d, dead\n", row)) ;
194.2568 +                    continue ;
194.2569 +                }
194.2570 +                DEBUG4 ((" Row %d, set diff %d\n", row, row_mark-tag_mark));
194.2571 +                ASSERT (row_mark >= tag_mark) ;
194.2572 +                /* compact the column */
194.2573 +                *new_cp++ = row ;
194.2574 +                /* compute hash function */
194.2575 +                hash += row ;
194.2576 +                /* add set difference */
194.2577 +                cur_score += row_mark - tag_mark ;
194.2578 +                /* integer overflow... */
194.2579 +                cur_score = MIN (cur_score, n_col) ;
194.2580 +            }
194.2581 +
194.2582 +            /* recompute the column's length */
194.2583 +            Col [col].length = (Int) (new_cp - &A [Col [col].start]) ;
194.2584 +
194.2585 +            /* === Further mass elimination ================================= */
194.2586 +
194.2587 +            if (Col [col].length == 0)
194.2588 +            {
194.2589 +                DEBUG4 (("further mass elimination. Col: %d\n", col)) ;
194.2590 +                /* nothing left but the pivot row in this column */
194.2591 +                KILL_PRINCIPAL_COL (col) ;
194.2592 +                pivot_row_degree -= Col [col].shared1.thickness ;
194.2593 +                ASSERT (pivot_row_degree >= 0) ;
194.2594 +                /* order it */
194.2595 +                Col [col].shared2.order = k ;
194.2596 +                /* increment order count by column thickness */
194.2597 +                k += Col [col].shared1.thickness ;
194.2598 +            }
194.2599 +            else
194.2600 +            {
194.2601 +                /* === Prepare for supercolumn detection ==================== */
194.2602 +
194.2603 +                DEBUG4 (("Preparing supercol detection for Col: %d.\n", col)) ;
194.2604 +
194.2605 +                /* save score so far */
194.2606 +                Col [col].shared2.score = cur_score ;
194.2607 +
194.2608 +                /* add column to hash table, for supercolumn detection */
194.2609 +                hash %= n_col + 1 ;
194.2610 +
194.2611 +                DEBUG4 ((" Hash = %d, n_col = %d.\n", hash, n_col)) ;
194.2612 +                ASSERT (((Int) hash) <= n_col) ;
194.2613 +
194.2614 +                head_column = head [hash] ;
194.2615 +                if (head_column > EMPTY)
194.2616 +                {
194.2617 +                    /* degree list "hash" is non-empty, use prev (shared3) of */
194.2618 +                    /* first column in degree list as head of hash bucket */
194.2619 +                    first_col = Col [head_column].shared3.headhash ;
194.2620 +                    Col [head_column].shared3.headhash = col ;
194.2621 +                }
194.2622 +                else
194.2623 +                {
194.2624 +                    /* degree list "hash" is empty, use head as hash bucket */
194.2625 +                    first_col = - (head_column + 2) ;
194.2626 +                    head [hash] = - (col + 2) ;
194.2627 +                }
194.2628 +                Col [col].shared4.hash_next = first_col ;
194.2629 +
194.2630 +                /* save hash function in Col [col].shared3.hash */
194.2631 +                Col [col].shared3.hash = (Int) hash ;
194.2632 +                ASSERT (COL_IS_ALIVE (col)) ;
194.2633 +            }
194.2634 +        }
194.2635 +
194.2636 +        /* The approximate external column degree is now computed.  */
194.2637 +
194.2638 +        /* === Supercolumn detection ======================================== */
194.2639 +
194.2640 +        DEBUG3 (("** Supercolumn detection phase. **\n")) ;
194.2641 +
194.2642 +        detect_super_cols (
194.2643 +
194.2644 +#ifndef NDEBUG
194.2645 +                n_col, Row,
194.2646 +#endif /* NDEBUG */
194.2647 +
194.2648 +                Col, A, head, pivot_row_start, pivot_row_length) ;
194.2649 +
194.2650 +        /* === Kill the pivotal column ====================================== */
194.2651 +
194.2652 +        KILL_PRINCIPAL_COL (pivot_col) ;
194.2653 +
194.2654 +        /* === Clear mark =================================================== */
194.2655 +
194.2656 +        tag_mark = clear_mark (tag_mark+max_deg+1, max_mark, n_row, Row) ;
194.2657 +
194.2658 +#ifndef NDEBUG
194.2659 +        DEBUG3 (("check3\n")) ;
194.2660 +        debug_mark (n_row, Row, tag_mark, max_mark) ;
194.2661 +#endif /* NDEBUG */
194.2662 +
194.2663 +        /* === Finalize the new pivot row, and column scores ================ */
194.2664 +
194.2665 +        DEBUG3 (("** Finalize scores phase. **\n")) ;
194.2666 +
194.2667 +        /* for each column in pivot row */
194.2668 +        rp = &A [pivot_row_start] ;
194.2669 +        /* compact the pivot row */
194.2670 +        new_rp = rp ;
194.2671 +        rp_end = rp + pivot_row_length ;
194.2672 +        while (rp < rp_end)
194.2673 +        {
194.2674 +            col = *rp++ ;
194.2675 +            /* skip dead columns */
194.2676 +            if (COL_IS_DEAD (col))
194.2677 +            {
194.2678 +                continue ;
194.2679 +            }
194.2680 +            *new_rp++ = col ;
194.2681 +            /* add new pivot row to column */
194.2682 +            A [Col [col].start + (Col [col].length++)] = pivot_row ;
194.2683 +
194.2684 +            /* retrieve score so far and add on pivot row's degree. */
194.2685 +            /* (we wait until here for this in case the pivot */
194.2686 +            /* row's degree was reduced due to mass elimination). */
194.2687 +            cur_score = Col [col].shared2.score + pivot_row_degree ;
194.2688 +
194.2689 +            /* calculate the max possible score as the number of */
194.2690 +            /* external columns minus the 'k' value minus the */
194.2691 +            /* columns thickness */
194.2692 +            max_score = n_col - k - Col [col].shared1.thickness ;
194.2693 +
194.2694 +            /* make the score the external degree of the union-of-rows */
194.2695 +            cur_score -= Col [col].shared1.thickness ;
194.2696 +
194.2697 +            /* make sure score is less or equal than the max score */
194.2698 +            cur_score = MIN (cur_score, max_score) ;
194.2699 +            ASSERT (cur_score >= 0) ;
194.2700 +
194.2701 +            /* store updated score */
194.2702 +            Col [col].shared2.score = cur_score ;
194.2703 +
194.2704 +            /* === Place column back in degree list ========================= */
194.2705 +
194.2706 +            ASSERT (min_score >= 0) ;
194.2707 +            ASSERT (min_score <= n_col) ;
194.2708 +            ASSERT (cur_score >= 0) ;
194.2709 +            ASSERT (cur_score <= n_col) ;
194.2710 +            ASSERT (head [cur_score] >= EMPTY) ;
194.2711 +            next_col = head [cur_score] ;
194.2712 +            Col [col].shared4.degree_next = next_col ;
194.2713 +            Col [col].shared3.prev = EMPTY ;
194.2714 +            if (next_col != EMPTY)
194.2715 +            {
194.2716 +                Col [next_col].shared3.prev = col ;
194.2717 +            }
194.2718 +            head [cur_score] = col ;
194.2719 +
194.2720 +            /* see if this score is less than current min */
194.2721 +            min_score = MIN (min_score, cur_score) ;
194.2722 +
194.2723 +        }
194.2724 +
194.2725 +#ifndef NDEBUG
194.2726 +        debug_deg_lists (n_row, n_col, Row, Col, head,
194.2727 +                min_score, n_col2-k, max_deg) ;
194.2728 +#endif /* NDEBUG */
194.2729 +
194.2730 +        /* === Resurrect the new pivot row ================================== */
194.2731 +
194.2732 +        if (pivot_row_degree > 0)
194.2733 +        {
194.2734 +            /* update pivot row length to reflect any cols that were killed */
194.2735 +            /* during super-col detection and mass elimination */
194.2736 +            Row [pivot_row].start  = pivot_row_start ;
194.2737 +            Row [pivot_row].length = (Int) (new_rp - &A[pivot_row_start]) ;
194.2738 +            ASSERT (Row [pivot_row].length > 0) ;
194.2739 +            Row [pivot_row].shared1.degree = pivot_row_degree ;
194.2740 +            Row [pivot_row].shared2.mark = 0 ;
194.2741 +            /* pivot row is no longer dead */
194.2742 +
194.2743 +            DEBUG1 (("Resurrect Pivot_row %d deg: %d\n",
194.2744 +                        pivot_row, pivot_row_degree)) ;
194.2745 +        }
194.2746 +    }
194.2747 +
194.2748 +    /* === All principal columns have now been ordered ====================== */
194.2749 +
194.2750 +    return (ngarbage) ;
194.2751 +}
194.2752 +
194.2753 +
194.2754 +/* ========================================================================== */
194.2755 +/* === order_children ======================================================= */
194.2756 +/* ========================================================================== */
194.2757 +
194.2758 +/*
194.2759 +    The find_ordering routine has ordered all of the principal columns (the
194.2760 +    representatives of the supercolumns).  The non-principal columns have not
194.2761 +    yet been ordered.  This routine orders those columns by walking up the
194.2762 +    parent tree (a column is a child of the column which absorbed it).  The
194.2763 +    final permutation vector is then placed in p [0 ... n_col-1], with p [0]
194.2764 +    being the first column, and p [n_col-1] being the last.  It doesn't look
194.2765 +    like it at first glance, but be assured that this routine takes time linear
194.2766 +    in the number of columns.  Although not immediately obvious, the time
194.2767 +    taken by this routine is O (n_col), that is, linear in the number of
194.2768 +    columns.  Not user-callable.
194.2769 +*/
194.2770 +
194.2771 +PRIVATE void order_children
194.2772 +(
194.2773 +    /* === Parameters ======================================================= */
194.2774 +
194.2775 +    Int n_col,                  /* number of columns of A */
194.2776 +    Colamd_Col Col [],          /* of size n_col+1 */
194.2777 +    Int p []                    /* p [0 ... n_col-1] is the column permutation*/
194.2778 +)
194.2779 +{
194.2780 +    /* === Local variables ================================================== */
194.2781 +
194.2782 +    Int i ;                     /* loop counter for all columns */
194.2783 +    Int c ;                     /* column index */
194.2784 +    Int parent ;                /* index of column's parent */
194.2785 +    Int order ;                 /* column's order */
194.2786 +
194.2787 +    /* === Order each non-principal column ================================== */
194.2788 +
194.2789 +    for (i = 0 ; i < n_col ; i++)
194.2790 +    {
194.2791 +        /* find an un-ordered non-principal column */
194.2792 +        ASSERT (COL_IS_DEAD (i)) ;
194.2793 +        if (!COL_IS_DEAD_PRINCIPAL (i) && Col [i].shared2.order == EMPTY)
194.2794 +        {
194.2795 +            parent = i ;
194.2796 +            /* once found, find its principal parent */
194.2797 +            do
194.2798 +            {
194.2799 +                parent = Col [parent].shared1.parent ;
194.2800 +            } while (!COL_IS_DEAD_PRINCIPAL (parent)) ;
194.2801 +
194.2802 +            /* now, order all un-ordered non-principal columns along path */
194.2803 +            /* to this parent.  collapse tree at the same time */
194.2804 +            c = i ;
194.2805 +            /* get order of parent */
194.2806 +            order = Col [parent].shared2.order ;
194.2807 +
194.2808 +            do
194.2809 +            {
194.2810 +                ASSERT (Col [c].shared2.order == EMPTY) ;
194.2811 +
194.2812 +                /* order this column */
194.2813 +                Col [c].shared2.order = order++ ;
194.2814 +                /* collaps tree */
194.2815 +                Col [c].shared1.parent = parent ;
194.2816 +
194.2817 +                /* get immediate parent of this column */
194.2818 +                c = Col [c].shared1.parent ;
194.2819 +
194.2820 +                /* continue until we hit an ordered column.  There are */
194.2821 +                /* guarranteed not to be anymore unordered columns */
194.2822 +                /* above an ordered column */
194.2823 +            } while (Col [c].shared2.order == EMPTY) ;
194.2824 +
194.2825 +            /* re-order the super_col parent to largest order for this group */
194.2826 +            Col [parent].shared2.order = order ;
194.2827 +        }
194.2828 +    }
194.2829 +
194.2830 +    /* === Generate the permutation ========================================= */
194.2831 +
194.2832 +    for (c = 0 ; c < n_col ; c++)
194.2833 +    {
194.2834 +        p [Col [c].shared2.order] = c ;
194.2835 +    }
194.2836 +}
194.2837 +
194.2838 +
194.2839 +/* ========================================================================== */
194.2840 +/* === detect_super_cols ==================================================== */
194.2841 +/* ========================================================================== */
194.2842 +
194.2843 +/*
194.2844 +    Detects supercolumns by finding matches between columns in the hash buckets.
194.2845 +    Check amongst columns in the set A [row_start ... row_start + row_length-1].
194.2846 +    The columns under consideration are currently *not* in the degree lists,
194.2847 +    and have already been placed in the hash buckets.
194.2848 +
194.2849 +    The hash bucket for columns whose hash function is equal to h is stored
194.2850 +    as follows:
194.2851 +
194.2852 +        if head [h] is >= 0, then head [h] contains a degree list, so:
194.2853 +
194.2854 +                head [h] is the first column in degree bucket h.
194.2855 +                Col [head [h]].headhash gives the first column in hash bucket h.
194.2856 +
194.2857 +        otherwise, the degree list is empty, and:
194.2858 +
194.2859 +                -(head [h] + 2) is the first column in hash bucket h.
194.2860 +
194.2861 +    For a column c in a hash bucket, Col [c].shared3.prev is NOT a "previous
194.2862 +    column" pointer.  Col [c].shared3.hash is used instead as the hash number
194.2863 +    for that column.  The value of Col [c].shared4.hash_next is the next column
194.2864 +    in the same hash bucket.
194.2865 +
194.2866 +    Assuming no, or "few" hash collisions, the time taken by this routine is
194.2867 +    linear in the sum of the sizes (lengths) of each column whose score has
194.2868 +    just been computed in the approximate degree computation.
194.2869 +    Not user-callable.
194.2870 +*/
194.2871 +
194.2872 +PRIVATE void detect_super_cols
194.2873 +(
194.2874 +    /* === Parameters ======================================================= */
194.2875 +
194.2876 +#ifndef NDEBUG
194.2877 +    /* these two parameters are only needed when debugging is enabled: */
194.2878 +    Int n_col,                  /* number of columns of A */
194.2879 +    Colamd_Row Row [],          /* of size n_row+1 */
194.2880 +#endif /* NDEBUG */
194.2881 +
194.2882 +    Colamd_Col Col [],          /* of size n_col+1 */
194.2883 +    Int A [],                   /* row indices of A */
194.2884 +    Int head [],                /* head of degree lists and hash buckets */
194.2885 +    Int row_start,              /* pointer to set of columns to check */
194.2886 +    Int row_length              /* number of columns to check */
194.2887 +)
194.2888 +{
194.2889 +    /* === Local variables ================================================== */
194.2890 +
194.2891 +    Int hash ;                  /* hash value for a column */
194.2892 +    Int *rp ;                   /* pointer to a row */
194.2893 +    Int c ;                     /* a column index */
194.2894 +    Int super_c ;               /* column index of the column to absorb into */
194.2895 +    Int *cp1 ;                  /* column pointer for column super_c */
194.2896 +    Int *cp2 ;                  /* column pointer for column c */
194.2897 +    Int length ;                /* length of column super_c */
194.2898 +    Int prev_c ;                /* column preceding c in hash bucket */
194.2899 +    Int i ;                     /* loop counter */
194.2900 +    Int *rp_end ;               /* pointer to the end of the row */
194.2901 +    Int col ;                   /* a column index in the row to check */
194.2902 +    Int head_column ;           /* first column in hash bucket or degree list */
194.2903 +    Int first_col ;             /* first column in hash bucket */
194.2904 +
194.2905 +    /* === Consider each column in the row ================================== */
194.2906 +
194.2907 +    rp = &A [row_start] ;
194.2908 +    rp_end = rp + row_length ;
194.2909 +    while (rp < rp_end)
194.2910 +    {
194.2911 +        col = *rp++ ;
194.2912 +        if (COL_IS_DEAD (col))
194.2913 +        {
194.2914 +            continue ;
194.2915 +        }
194.2916 +
194.2917 +        /* get hash number for this column */
194.2918 +        hash = Col [col].shared3.hash ;
194.2919 +        ASSERT (hash <= n_col) ;
194.2920 +
194.2921 +        /* === Get the first column in this hash bucket ===================== */
194.2922 +
194.2923 +        head_column = head [hash] ;
194.2924 +        if (head_column > EMPTY)
194.2925 +        {
194.2926 +            first_col = Col [head_column].shared3.headhash ;
194.2927 +        }
194.2928 +        else
194.2929 +        {
194.2930 +            first_col = - (head_column + 2) ;
194.2931 +        }
194.2932 +
194.2933 +        /* === Consider each column in the hash bucket ====================== */
194.2934 +
194.2935 +        for (super_c = first_col ; super_c != EMPTY ;
194.2936 +            super_c = Col [super_c].shared4.hash_next)
194.2937 +        {
194.2938 +            ASSERT (COL_IS_ALIVE (super_c)) ;
194.2939 +            ASSERT (Col [super_c].shared3.hash == hash) ;
194.2940 +            length = Col [super_c].length ;
194.2941 +
194.2942 +            /* prev_c is the column preceding column c in the hash bucket */
194.2943 +            prev_c = super_c ;
194.2944 +
194.2945 +            /* === Compare super_c with all columns after it ================ */
194.2946 +
194.2947 +            for (c = Col [super_c].shared4.hash_next ;
194.2948 +                 c != EMPTY ; c = Col [c].shared4.hash_next)
194.2949 +            {
194.2950 +                ASSERT (c != super_c) ;
194.2951 +                ASSERT (COL_IS_ALIVE (c)) ;
194.2952 +                ASSERT (Col [c].shared3.hash == hash) ;
194.2953 +
194.2954 +                /* not identical if lengths or scores are different */
194.2955 +                if (Col [c].length != length ||
194.2956 +                    Col [c].shared2.score != Col [super_c].shared2.score)
194.2957 +                {
194.2958 +                    prev_c = c ;
194.2959 +                    continue ;
194.2960 +                }
194.2961 +
194.2962 +                /* compare the two columns */
194.2963 +                cp1 = &A [Col [super_c].start] ;
194.2964 +                cp2 = &A [Col [c].start] ;
194.2965 +
194.2966 +                for (i = 0 ; i < length ; i++)
194.2967 +                {
194.2968 +                    /* the columns are "clean" (no dead rows) */
194.2969 +                    ASSERT (ROW_IS_ALIVE (*cp1))  ;
194.2970 +                    ASSERT (ROW_IS_ALIVE (*cp2))  ;
194.2971 +                    /* row indices will same order for both supercols, */
194.2972 +                    /* no gather scatter nessasary */
194.2973 +                    if (*cp1++ != *cp2++)
194.2974 +                    {
194.2975 +                        break ;
194.2976 +                    }
194.2977 +                }
194.2978 +
194.2979 +                /* the two columns are different if the for-loop "broke" */
194.2980 +                if (i != length)
194.2981 +                {
194.2982 +                    prev_c = c ;
194.2983 +                    continue ;
194.2984 +                }
194.2985 +
194.2986 +                /* === Got it!  two columns are identical =================== */
194.2987 +
194.2988 +                ASSERT (Col [c].shared2.score == Col [super_c].shared2.score) ;
194.2989 +
194.2990 +                Col [super_c].shared1.thickness += Col [c].shared1.thickness ;
194.2991 +                Col [c].shared1.parent = super_c ;
194.2992 +                KILL_NON_PRINCIPAL_COL (c) ;
194.2993 +                /* order c later, in order_children() */
194.2994 +                Col [c].shared2.order = EMPTY ;
194.2995 +                /* remove c from hash bucket */
194.2996 +                Col [prev_c].shared4.hash_next = Col [c].shared4.hash_next ;
194.2997 +            }
194.2998 +        }
194.2999 +
194.3000 +        /* === Empty this hash bucket ======================================= */
194.3001 +
194.3002 +        if (head_column > EMPTY)
194.3003 +        {
194.3004 +            /* corresponding degree list "hash" is not empty */
194.3005 +            Col [head_column].shared3.headhash = EMPTY ;
194.3006 +        }
194.3007 +        else
194.3008 +        {
194.3009 +            /* corresponding degree list "hash" is empty */
194.3010 +            head [hash] = EMPTY ;
194.3011 +        }
194.3012 +    }
194.3013 +}
194.3014 +
194.3015 +
194.3016 +/* ========================================================================== */
194.3017 +/* === garbage_collection =================================================== */
194.3018 +/* ========================================================================== */
194.3019 +
194.3020 +/*
194.3021 +    Defragments and compacts columns and rows in the workspace A.  Used when
194.3022 +    all avaliable memory has been used while performing row merging.  Returns
194.3023 +    the index of the first free position in A, after garbage collection.  The
194.3024 +    time taken by this routine is linear is the size of the array A, which is
194.3025 +    itself linear in the number of nonzeros in the input matrix.
194.3026 +    Not user-callable.
194.3027 +*/
194.3028 +
194.3029 +PRIVATE Int garbage_collection  /* returns the new value of pfree */
194.3030 +(
194.3031 +    /* === Parameters ======================================================= */
194.3032 +
194.3033 +    Int n_row,                  /* number of rows */
194.3034 +    Int n_col,                  /* number of columns */
194.3035 +    Colamd_Row Row [],          /* row info */
194.3036 +    Colamd_Col Col [],          /* column info */
194.3037 +    Int A [],                   /* A [0 ... Alen-1] holds the matrix */
194.3038 +    Int *pfree                  /* &A [0] ... pfree is in use */
194.3039 +)
194.3040 +{
194.3041 +    /* === Local variables ================================================== */
194.3042 +
194.3043 +    Int *psrc ;                 /* source pointer */
194.3044 +    Int *pdest ;                /* destination pointer */
194.3045 +    Int j ;                     /* counter */
194.3046 +    Int r ;                     /* a row index */
194.3047 +    Int c ;                     /* a column index */
194.3048 +    Int length ;                /* length of a row or column */
194.3049 +
194.3050 +#ifndef NDEBUG
194.3051 +    Int debug_rows ;
194.3052 +    DEBUG2 (("Defrag..\n")) ;
194.3053 +    for (psrc = &A[0] ; psrc < pfree ; psrc++) ASSERT (*psrc >= 0) ;
194.3054 +    debug_rows = 0 ;
194.3055 +#endif /* NDEBUG */
194.3056 +
194.3057 +    /* === Defragment the columns =========================================== */
194.3058 +
194.3059 +    pdest = &A[0] ;
194.3060 +    for (c = 0 ; c < n_col ; c++)
194.3061 +    {
194.3062 +        if (COL_IS_ALIVE (c))
194.3063 +        {
194.3064 +            psrc = &A [Col [c].start] ;
194.3065 +
194.3066 +            /* move and compact the column */
194.3067 +            ASSERT (pdest <= psrc) ;
194.3068 +            Col [c].start = (Int) (pdest - &A [0]) ;
194.3069 +            length = Col [c].length ;
194.3070 +            for (j = 0 ; j < length ; j++)
194.3071 +            {
194.3072 +                r = *psrc++ ;
194.3073 +                if (ROW_IS_ALIVE (r))
194.3074 +                {
194.3075 +                    *pdest++ = r ;
194.3076 +                }
194.3077 +            }
194.3078 +            Col [c].length = (Int) (pdest - &A [Col [c].start]) ;
194.3079 +        }
194.3080 +    }
194.3081 +
194.3082 +    /* === Prepare to defragment the rows =================================== */
194.3083 +
194.3084 +    for (r = 0 ; r < n_row ; r++)
194.3085 +    {
194.3086 +        if (ROW_IS_DEAD (r) || (Row [r].length == 0))
194.3087 +        {
194.3088 +            /* This row is already dead, or is of zero length.  Cannot compact
194.3089 +             * a row of zero length, so kill it.  NOTE: in the current version,
194.3090 +             * there are no zero-length live rows.  Kill the row (for the first
194.3091 +             * time, or again) just to be safe. */
194.3092 +            KILL_ROW (r) ;
194.3093 +        }
194.3094 +        else
194.3095 +        {
194.3096 +            /* save first column index in Row [r].shared2.first_column */
194.3097 +            psrc = &A [Row [r].start] ;
194.3098 +            Row [r].shared2.first_column = *psrc ;
194.3099 +            ASSERT (ROW_IS_ALIVE (r)) ;
194.3100 +            /* flag the start of the row with the one's complement of row */
194.3101 +            *psrc = ONES_COMPLEMENT (r) ;
194.3102 +#ifndef NDEBUG
194.3103 +            debug_rows++ ;
194.3104 +#endif /* NDEBUG */
194.3105 +        }
194.3106 +    }
194.3107 +
194.3108 +    /* === Defragment the rows ============================================== */
194.3109 +
194.3110 +    psrc = pdest ;
194.3111 +    while (psrc < pfree)
194.3112 +    {
194.3113 +        /* find a negative number ... the start of a row */
194.3114 +        if (*psrc++ < 0)
194.3115 +        {
194.3116 +            psrc-- ;
194.3117 +            /* get the row index */
194.3118 +            r = ONES_COMPLEMENT (*psrc) ;
194.3119 +            ASSERT (r >= 0 && r < n_row) ;
194.3120 +            /* restore first column index */
194.3121 +            *psrc = Row [r].shared2.first_column ;
194.3122 +            ASSERT (ROW_IS_ALIVE (r)) ;
194.3123 +            ASSERT (Row [r].length > 0) ;
194.3124 +            /* move and compact the row */
194.3125 +            ASSERT (pdest <= psrc) ;
194.3126 +            Row [r].start = (Int) (pdest - &A [0]) ;
194.3127 +            length = Row [r].length ;
194.3128 +            for (j = 0 ; j < length ; j++)
194.3129 +            {
194.3130 +                c = *psrc++ ;
194.3131 +                if (COL_IS_ALIVE (c))
194.3132 +                {
194.3133 +                    *pdest++ = c ;
194.3134 +                }
194.3135 +            }
194.3136 +            Row [r].length = (Int) (pdest - &A [Row [r].start]) ;
194.3137 +            ASSERT (Row [r].length > 0) ;
194.3138 +#ifndef NDEBUG
194.3139 +            debug_rows-- ;
194.3140 +#endif /* NDEBUG */
194.3141 +        }
194.3142 +    }
194.3143 +    /* ensure we found all the rows */
194.3144 +    ASSERT (debug_rows == 0) ;
194.3145 +
194.3146 +    /* === Return the new value of pfree ==================================== */
194.3147 +
194.3148 +    return ((Int) (pdest - &A [0])) ;
194.3149 +}
194.3150 +
194.3151 +
194.3152 +/* ========================================================================== */
194.3153 +/* === clear_mark =========================================================== */
194.3154 +/* ========================================================================== */
194.3155 +
194.3156 +/*
194.3157 +    Clears the Row [].shared2.mark array, and returns the new tag_mark.
194.3158 +    Return value is the new tag_mark.  Not user-callable.
194.3159 +*/
194.3160 +
194.3161 +PRIVATE Int clear_mark  /* return the new value for tag_mark */
194.3162 +(
194.3163 +    /* === Parameters ======================================================= */
194.3164 +
194.3165 +    Int tag_mark,       /* new value of tag_mark */
194.3166 +    Int max_mark,       /* max allowed value of tag_mark */
194.3167 +
194.3168 +    Int n_row,          /* number of rows in A */
194.3169 +    Colamd_Row Row []   /* Row [0 ... n_row-1].shared2.mark is set to zero */
194.3170 +)
194.3171 +{
194.3172 +    /* === Local variables ================================================== */
194.3173 +
194.3174 +    Int r ;
194.3175 +
194.3176 +    if (tag_mark <= 0 || tag_mark >= max_mark)
194.3177 +    {
194.3178 +        for (r = 0 ; r < n_row ; r++)
194.3179 +        {
194.3180 +            if (ROW_IS_ALIVE (r))
194.3181 +            {
194.3182 +                Row [r].shared2.mark = 0 ;
194.3183 +            }
194.3184 +        }
194.3185 +        tag_mark = 1 ;
194.3186 +    }
194.3187 +
194.3188 +    return (tag_mark) ;
194.3189 +}
194.3190 +
194.3191 +
194.3192 +/* ========================================================================== */
194.3193 +/* === print_report ========================================================= */
194.3194 +/* ========================================================================== */
194.3195 +
194.3196 +PRIVATE void print_report
194.3197 +(
194.3198 +    char *method,
194.3199 +    Int stats [COLAMD_STATS]
194.3200 +)
194.3201 +{
194.3202 +
194.3203 +    Int i1, i2, i3 ;
194.3204 +
194.3205 +    PRINTF (("\n%s version %d.%d, %s: ", method,
194.3206 +            COLAMD_MAIN_VERSION, COLAMD_SUB_VERSION, COLAMD_DATE)) ;
194.3207 +
194.3208 +    if (!stats)
194.3209 +    {
194.3210 +        PRINTF (("No statistics available.\n")) ;
194.3211 +        return ;
194.3212 +    }
194.3213 +
194.3214 +    i1 = stats [COLAMD_INFO1] ;
194.3215 +    i2 = stats [COLAMD_INFO2] ;
194.3216 +    i3 = stats [COLAMD_INFO3] ;
194.3217 +
194.3218 +    if (stats [COLAMD_STATUS] >= 0)
194.3219 +    {
194.3220 +        PRINTF (("OK.  ")) ;
194.3221 +    }
194.3222 +    else
194.3223 +    {
194.3224 +        PRINTF (("ERROR.  ")) ;
194.3225 +    }
194.3226 +
194.3227 +    switch (stats [COLAMD_STATUS])
194.3228 +    {
194.3229 +
194.3230 +        case COLAMD_OK_BUT_JUMBLED:
194.3231 +
194.3232 +            PRINTF(("Matrix has unsorted or duplicate row indices.\n")) ;
194.3233 +
194.3234 +            PRINTF(("%s: number of duplicate or out-of-order row indices: %d\n",
194.3235 +            method, i3)) ;
194.3236 +
194.3237 +            PRINTF(("%s: last seen duplicate or out-of-order row index:   %d\n",
194.3238 +            method, INDEX (i2))) ;
194.3239 +
194.3240 +            PRINTF(("%s: last seen in column:                             %d",
194.3241 +            method, INDEX (i1))) ;
194.3242 +
194.3243 +            /* no break - fall through to next case instead */
194.3244 +
194.3245 +        case COLAMD_OK:
194.3246 +
194.3247 +            PRINTF(("\n")) ;
194.3248 +
194.3249 +            PRINTF(("%s: number of dense or empty rows ignored:           %d\n",
194.3250 +            method, stats [COLAMD_DENSE_ROW])) ;
194.3251 +
194.3252 +            PRINTF(("%s: number of dense or empty columns ignored:        %d\n",
194.3253 +            method, stats [COLAMD_DENSE_COL])) ;
194.3254 +
194.3255 +            PRINTF(("%s: number of garbage collections performed:         %d\n",
194.3256 +            method, stats [COLAMD_DEFRAG_COUNT])) ;
194.3257 +            break ;
194.3258 +
194.3259 +        case COLAMD_ERROR_A_not_present:
194.3260 +
194.3261 +            PRINTF(("Array A (row indices of matrix) not present.\n")) ;
194.3262 +            break ;
194.3263 +
194.3264 +        case COLAMD_ERROR_p_not_present:
194.3265 +
194.3266 +            PRINTF(("Array p (column pointers for matrix) not present.\n")) ;
194.3267 +            break ;
194.3268 +
194.3269 +        case COLAMD_ERROR_nrow_negative:
194.3270 +
194.3271 +            PRINTF(("Invalid number of rows (%d).\n", i1)) ;
194.3272 +            break ;
194.3273 +
194.3274 +        case COLAMD_ERROR_ncol_negative:
194.3275 +
194.3276 +            PRINTF(("Invalid number of columns (%d).\n", i1)) ;
194.3277 +            break ;
194.3278 +
194.3279 +        case COLAMD_ERROR_nnz_negative:
194.3280 +
194.3281 +            PRINTF(("Invalid number of nonzero entries (%d).\n", i1)) ;
194.3282 +            break ;
194.3283 +
194.3284 +        case COLAMD_ERROR_p0_nonzero:
194.3285 +
194.3286 +            PRINTF(("Invalid column pointer, p [0] = %d, must be zero.\n", i1));
194.3287 +            break ;
194.3288 +
194.3289 +        case COLAMD_ERROR_A_too_small:
194.3290 +
194.3291 +            PRINTF(("Array A too small.\n")) ;
194.3292 +            PRINTF(("        Need Alen >= %d, but given only Alen = %d.\n",
194.3293 +            i1, i2)) ;
194.3294 +            break ;
194.3295 +
194.3296 +        case COLAMD_ERROR_col_length_negative:
194.3297 +
194.3298 +            PRINTF
194.3299 +            (("Column %d has a negative number of nonzero entries (%d).\n",
194.3300 +            INDEX (i1), i2)) ;
194.3301 +            break ;
194.3302 +
194.3303 +        case COLAMD_ERROR_row_index_out_of_bounds:
194.3304 +
194.3305 +            PRINTF
194.3306 +            (("Row index (row %d) out of bounds (%d to %d) in column %d.\n",
194.3307 +            INDEX (i2), INDEX (0), INDEX (i3-1), INDEX (i1))) ;
194.3308 +            break ;
194.3309 +
194.3310 +        case COLAMD_ERROR_out_of_memory:
194.3311 +
194.3312 +            PRINTF(("Out of memory.\n")) ;
194.3313 +            break ;
194.3314 +
194.3315 +        /* v2.4: internal-error case deleted */
194.3316 +    }
194.3317 +}
194.3318 +
194.3319 +
194.3320 +
194.3321 +
194.3322 +/* ========================================================================== */
194.3323 +/* === colamd debugging routines ============================================ */
194.3324 +/* ========================================================================== */
194.3325 +
194.3326 +/* When debugging is disabled, the remainder of this file is ignored. */
194.3327 +
194.3328 +#ifndef NDEBUG
194.3329 +
194.3330 +
194.3331 +/* ========================================================================== */
194.3332 +/* === debug_structures ===================================================== */
194.3333 +/* ========================================================================== */
194.3334 +
194.3335 +/*
194.3336 +    At this point, all empty rows and columns are dead.  All live columns
194.3337 +    are "clean" (containing no dead rows) and simplicial (no supercolumns
194.3338 +    yet).  Rows may contain dead columns, but all live rows contain at
194.3339 +    least one live column.
194.3340 +*/
194.3341 +
194.3342 +PRIVATE void debug_structures
194.3343 +(
194.3344 +    /* === Parameters ======================================================= */
194.3345 +
194.3346 +    Int n_row,
194.3347 +    Int n_col,
194.3348 +    Colamd_Row Row [],
194.3349 +    Colamd_Col Col [],
194.3350 +    Int A [],
194.3351 +    Int n_col2
194.3352 +)
194.3353 +{
194.3354 +    /* === Local variables ================================================== */
194.3355 +
194.3356 +    Int i ;
194.3357 +    Int c ;
194.3358 +    Int *cp ;
194.3359 +    Int *cp_end ;
194.3360 +    Int len ;
194.3361 +    Int score ;
194.3362 +    Int r ;
194.3363 +    Int *rp ;
194.3364 +    Int *rp_end ;
194.3365 +    Int deg ;
194.3366 +
194.3367 +    /* === Check A, Row, and Col ============================================ */
194.3368 +
194.3369 +    for (c = 0 ; c < n_col ; c++)
194.3370 +    {
194.3371 +        if (COL_IS_ALIVE (c))
194.3372 +        {
194.3373 +            len = Col [c].length ;
194.3374 +            score = Col [c].shared2.score ;
194.3375 +            DEBUG4 (("initial live col %5d %5d %5d\n", c, len, score)) ;
194.3376 +            ASSERT (len > 0) ;
194.3377 +            ASSERT (score >= 0) ;
194.3378 +            ASSERT (Col [c].shared1.thickness == 1) ;
194.3379 +            cp = &A [Col [c].start] ;
194.3380 +            cp_end = cp + len ;
194.3381 +            while (cp < cp_end)
194.3382 +            {
194.3383 +                r = *cp++ ;
194.3384 +                ASSERT (ROW_IS_ALIVE (r)) ;
194.3385 +            }
194.3386 +        }
194.3387 +        else
194.3388 +        {
194.3389 +            i = Col [c].shared2.order ;
194.3390 +            ASSERT (i >= n_col2 && i < n_col) ;
194.3391 +        }
194.3392 +    }
194.3393 +
194.3394 +    for (r = 0 ; r < n_row ; r++)
194.3395 +    {
194.3396 +        if (ROW_IS_ALIVE (r))
194.3397 +        {
194.3398 +            i = 0 ;
194.3399 +            len = Row [r].length ;
194.3400 +            deg = Row [r].shared1.degree ;
194.3401 +            ASSERT (len > 0) ;
194.3402 +            ASSERT (deg > 0) ;
194.3403 +            rp = &A [Row [r].start] ;
194.3404 +            rp_end = rp + len ;
194.3405 +            while (rp < rp_end)
194.3406 +            {
194.3407 +                c = *rp++ ;
194.3408 +                if (COL_IS_ALIVE (c))
194.3409 +                {
194.3410 +                    i++ ;
194.3411 +                }
194.3412 +            }
194.3413 +            ASSERT (i > 0) ;
194.3414 +        }
194.3415 +    }
194.3416 +}
194.3417 +
194.3418 +
194.3419 +/* ========================================================================== */
194.3420 +/* === debug_deg_lists ====================================================== */
194.3421 +/* ========================================================================== */
194.3422 +
194.3423 +/*
194.3424 +    Prints the contents of the degree lists.  Counts the number of columns
194.3425 +    in the degree list and compares it to the total it should have.  Also
194.3426 +    checks the row degrees.
194.3427 +*/
194.3428 +
194.3429 +PRIVATE void debug_deg_lists
194.3430 +(
194.3431 +    /* === Parameters ======================================================= */
194.3432 +
194.3433 +    Int n_row,
194.3434 +    Int n_col,
194.3435 +    Colamd_Row Row [],
194.3436 +    Colamd_Col Col [],
194.3437 +    Int head [],
194.3438 +    Int min_score,
194.3439 +    Int should,
194.3440 +    Int max_deg
194.3441 +)
194.3442 +{
194.3443 +    /* === Local variables ================================================== */
194.3444 +
194.3445 +    Int deg ;
194.3446 +    Int col ;
194.3447 +    Int have ;
194.3448 +    Int row ;
194.3449 +
194.3450 +    /* === Check the degree lists =========================================== */
194.3451 +
194.3452 +    if (n_col > 10000 && colamd_debug <= 0)
194.3453 +    {
194.3454 +        return ;
194.3455 +    }
194.3456 +    have = 0 ;
194.3457 +    DEBUG4 (("Degree lists: %d\n", min_score)) ;
194.3458 +    for (deg = 0 ; deg <= n_col ; deg++)
194.3459 +    {
194.3460 +        col = head [deg] ;
194.3461 +        if (col == EMPTY)
194.3462 +        {
194.3463 +            continue ;
194.3464 +        }
194.3465 +        DEBUG4 (("%d:", deg)) ;
194.3466 +        while (col != EMPTY)
194.3467 +        {
194.3468 +            DEBUG4 ((" %d", col)) ;
194.3469 +            have += Col [col].shared1.thickness ;
194.3470 +            ASSERT (COL_IS_ALIVE (col)) ;
194.3471 +            col = Col [col].shared4.degree_next ;
194.3472 +        }
194.3473 +        DEBUG4 (("\n")) ;
194.3474 +    }
194.3475 +    DEBUG4 (("should %d have %d\n", should, have)) ;
194.3476 +    ASSERT (should == have) ;
194.3477 +
194.3478 +    /* === Check the row degrees ============================================ */
194.3479 +
194.3480 +    if (n_row > 10000 && colamd_debug <= 0)
194.3481 +    {
194.3482 +        return ;
194.3483 +    }
194.3484 +    for (row = 0 ; row < n_row ; row++)
194.3485 +    {
194.3486 +        if (ROW_IS_ALIVE (row))
194.3487 +        {
194.3488 +            ASSERT (Row [row].shared1.degree <= max_deg) ;
194.3489 +        }
194.3490 +    }
194.3491 +}
194.3492 +
194.3493 +
194.3494 +/* ========================================================================== */
194.3495 +/* === debug_mark =========================================================== */
194.3496 +/* ========================================================================== */
194.3497 +
194.3498 +/*
194.3499 +    Ensures that the tag_mark is less that the maximum and also ensures that
194.3500 +    each entry in the mark array is less than the tag mark.
194.3501 +*/
194.3502 +
194.3503 +PRIVATE void debug_mark
194.3504 +(
194.3505 +    /* === Parameters ======================================================= */
194.3506 +
194.3507 +    Int n_row,
194.3508 +    Colamd_Row Row [],
194.3509 +    Int tag_mark,
194.3510 +    Int max_mark
194.3511 +)
194.3512 +{
194.3513 +    /* === Local variables ================================================== */
194.3514 +
194.3515 +    Int r ;
194.3516 +
194.3517 +    /* === Check the Row marks ============================================== */
194.3518 +
194.3519 +    ASSERT (tag_mark > 0 && tag_mark <= max_mark) ;
194.3520 +    if (n_row > 10000 && colamd_debug <= 0)
194.3521 +    {
194.3522 +        return ;
194.3523 +    }
194.3524 +    for (r = 0 ; r < n_row ; r++)
194.3525 +    {
194.3526 +        ASSERT (Row [r].shared2.mark < tag_mark) ;
194.3527 +    }
194.3528 +}
194.3529 +
194.3530 +
194.3531 +/* ========================================================================== */
194.3532 +/* === debug_matrix ========================================================= */
194.3533 +/* ========================================================================== */
194.3534 +
194.3535 +/*
194.3536 +    Prints out the contents of the columns and the rows.
194.3537 +*/
194.3538 +
194.3539 +PRIVATE void debug_matrix
194.3540 +(
194.3541 +    /* === Parameters ======================================================= */
194.3542 +
194.3543 +    Int n_row,
194.3544 +    Int n_col,
194.3545 +    Colamd_Row Row [],
194.3546 +    Colamd_Col Col [],
194.3547 +    Int A []
194.3548 +)
194.3549 +{
194.3550 +    /* === Local variables ================================================== */
194.3551 +
194.3552 +    Int r ;
194.3553 +    Int c ;
194.3554 +    Int *rp ;
194.3555 +    Int *rp_end ;
194.3556 +    Int *cp ;
194.3557 +    Int *cp_end ;
194.3558 +
194.3559 +    /* === Dump the rows and columns of the matrix ========================== */
194.3560 +
194.3561 +    if (colamd_debug < 3)
194.3562 +    {
194.3563 +        return ;
194.3564 +    }
194.3565 +    DEBUG3 (("DUMP MATRIX:\n")) ;
194.3566 +    for (r = 0 ; r < n_row ; r++)
194.3567 +    {
194.3568 +        DEBUG3 (("Row %d alive? %d\n", r, ROW_IS_ALIVE (r))) ;
194.3569 +        if (ROW_IS_DEAD (r))
194.3570 +        {
194.3571 +            continue ;
194.3572 +        }
194.3573 +        DEBUG3 (("start %d length %d degree %d\n",
194.3574 +                Row [r].start, Row [r].length, Row [r].shared1.degree)) ;
194.3575 +        rp = &A [Row [r].start] ;
194.3576 +        rp_end = rp + Row [r].length ;
194.3577 +        while (rp < rp_end)
194.3578 +        {
194.3579 +            c = *rp++ ;
194.3580 +            DEBUG4 (("  %d col %d\n", COL_IS_ALIVE (c), c)) ;
194.3581 +        }
194.3582 +    }
194.3583 +
194.3584 +    for (c = 0 ; c < n_col ; c++)
194.3585 +    {
194.3586 +        DEBUG3 (("Col %d alive? %d\n", c, COL_IS_ALIVE (c))) ;
194.3587 +        if (COL_IS_DEAD (c))
194.3588 +        {
194.3589 +            continue ;
194.3590 +        }
194.3591 +        DEBUG3 (("start %d length %d shared1 %d shared2 %d\n",
194.3592 +                Col [c].start, Col [c].length,
194.3593 +                Col [c].shared1.thickness, Col [c].shared2.score)) ;
194.3594 +        cp = &A [Col [c].start] ;
194.3595 +        cp_end = cp + Col [c].length ;
194.3596 +        while (cp < cp_end)
194.3597 +        {
194.3598 +            r = *cp++ ;
194.3599 +            DEBUG4 (("  %d row %d\n", ROW_IS_ALIVE (r), r)) ;
194.3600 +        }
194.3601 +    }
194.3602 +}
194.3603 +
194.3604 +PRIVATE void colamd_get_debug
194.3605 +(
194.3606 +    char *method
194.3607 +)
194.3608 +{
194.3609 +    FILE *f ;
194.3610 +    colamd_debug = 0 ;          /* no debug printing */
194.3611 +    f = fopen ("debug", "r") ;
194.3612 +    if (f == (FILE *) NULL)
194.3613 +    {
194.3614 +        colamd_debug = 0 ;
194.3615 +    }
194.3616 +    else
194.3617 +    {
194.3618 +        fscanf (f, "%d", &colamd_debug) ;
194.3619 +        fclose (f) ;
194.3620 +    }
194.3621 +    DEBUG0 (("%s: debug version, D = %d (THIS WILL BE SLOW!)\n",
194.3622 +        method, colamd_debug)) ;
194.3623 +}
194.3624 +
194.3625 +#endif /* NDEBUG */
   195.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
   195.2 +++ b/deps/glpk/src/colamd/colamd.h	Sun Nov 06 20:59:10 2011 +0100
   195.3 @@ -0,0 +1,69 @@
   195.4 +/* colamd.h */
   195.5 +
   195.6 +/* Written by Andrew Makhorin <mao@gnu.org>. */
   195.7 +
   195.8 +#ifndef COLAMD_H
   195.9 +#define COLAMD_H
  195.10 +
  195.11 +#define _GLPSTD_STDIO
  195.12 +#include "glpenv.h"
  195.13 +
  195.14 +#define COLAMD_DATE "Nov 1, 2007"
  195.15 +#define COLAMD_VERSION_CODE(main, sub) ((main) * 1000 + (sub))
  195.16 +#define COLAMD_MAIN_VERSION 2
  195.17 +#define COLAMD_SUB_VERSION 7
  195.18 +#define COLAMD_SUBSUB_VERSION 1
  195.19 +#define COLAMD_VERSION \
  195.20 +        COLAMD_VERSION_CODE(COLAMD_MAIN_VERSION, COLAMD_SUB_VERSION)
  195.21 +
  195.22 +#define COLAMD_KNOBS 20
  195.23 +#define COLAMD_STATS 20
  195.24 +#define COLAMD_DENSE_ROW 0
  195.25 +#define COLAMD_DENSE_COL 1
  195.26 +#define COLAMD_AGGRESSIVE 2
  195.27 +#define COLAMD_DEFRAG_COUNT 2
  195.28 +#define COLAMD_STATUS 3
  195.29 +#define COLAMD_INFO1 4
  195.30 +#define COLAMD_INFO2 5
  195.31 +#define COLAMD_INFO3 6
  195.32 +
  195.33 +#define COLAMD_OK                            (0)
  195.34 +#define COLAMD_OK_BUT_JUMBLED                (1)
  195.35 +#define COLAMD_ERROR_A_not_present           (-1)
  195.36 +#define COLAMD_ERROR_p_not_present           (-2)
  195.37 +#define COLAMD_ERROR_nrow_negative           (-3)
  195.38 +#define COLAMD_ERROR_ncol_negative           (-4)
  195.39 +#define COLAMD_ERROR_nnz_negative            (-5)
  195.40 +#define COLAMD_ERROR_p0_nonzero              (-6)
  195.41 +#define COLAMD_ERROR_A_too_small             (-7)
  195.42 +#define COLAMD_ERROR_col_length_negative     (-8)
  195.43 +#define COLAMD_ERROR_row_index_out_of_bounds (-9)
  195.44 +#define COLAMD_ERROR_out_of_memory           (-10)
  195.45 +#define COLAMD_ERROR_internal_error          (-999)
  195.46 +
  195.47 +#define colamd_recommended _glp_colamd_recommended
  195.48 +size_t colamd_recommended(int nnz, int n_row, int n_col);
  195.49 +
  195.50 +#define colamd_set_defaults _glp_colamd_set_defaults
  195.51 +void colamd_set_defaults(double knobs [COLAMD_KNOBS]);
  195.52 +
  195.53 +#define colamd _glp_colamd
  195.54 +int colamd(int n_row, int n_col, int Alen, int A[], int p[],
  195.55 +      double knobs[COLAMD_KNOBS], int stats[COLAMD_STATS]);
  195.56 +
  195.57 +#define symamd _glp_symamd
  195.58 +int symamd(int n, int A[], int p[], int perm[],
  195.59 +      double knobs[COLAMD_KNOBS], int stats[COLAMD_STATS],
  195.60 +      void *(*allocate)(size_t, size_t), void(*release)(void *));
  195.61 +
  195.62 +#define colamd_report _glp_colamd_report
  195.63 +void colamd_report(int stats[COLAMD_STATS]);
  195.64 +
  195.65 +#define symamd_report _glp_symamd_report
  195.66 +void symamd_report(int stats[COLAMD_STATS]);
  195.67 +
  195.68 +#define colamd_printf xprintf
  195.69 +
  195.70 +#endif
  195.71 +
  195.72 +/* eof */
   196.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
   196.2 +++ b/deps/glpk/src/glpapi.h	Sun Nov 06 20:59:10 2011 +0100
   196.3 @@ -0,0 +1,314 @@
   196.4 +/* glpapi.h (application program interface) */
   196.5 +
   196.6 +/***********************************************************************
   196.7 +*  This code is part of GLPK (GNU Linear Programming Kit).
   196.8 +*
   196.9 +*  Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008,
  196.10 +*  2009, 2010, 2011 Andrew Makhorin, Department for Applied Informatics,
  196.11 +*  Moscow Aviation Institute, Moscow, Russia. All rights reserved.
  196.12 +*  E-mail: <mao@gnu.org>.
  196.13 +*
  196.14 +*  GLPK is free software: you can redistribute it and/or modify it
  196.15 +*  under the terms of the GNU General Public License as published by
  196.16 +*  the Free Software Foundation, either version 3 of the License, or
  196.17 +*  (at your option) any later version.
  196.18 +*
  196.19 +*  GLPK is distributed in the hope that it will be useful, but WITHOUT
  196.20 +*  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
  196.21 +*  or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
  196.22 +*  License for more details.
  196.23 +*
  196.24 +*  You should have received a copy of the GNU General Public License
  196.25 +*  along with GLPK. If not, see <http://www.gnu.org/licenses/>.
  196.26 +***********************************************************************/
  196.27 +
  196.28 +#ifndef GLPAPI_H
  196.29 +#define GLPAPI_H
  196.30 +
  196.31 +#define GLP_PROB_DEFINED
  196.32 +typedef struct glp_prob glp_prob;
  196.33 +
  196.34 +#include "glpk.h"
  196.35 +#include "glpavl.h"
  196.36 +#include "glpbfd.h"
  196.37 +
  196.38 +typedef struct GLPROW GLPROW;
  196.39 +typedef struct GLPCOL GLPCOL;
  196.40 +typedef struct GLPAIJ GLPAIJ;
  196.41 +
  196.42 +#define GLP_PROB_MAGIC 0xD7D9D6C2
  196.43 +
  196.44 +struct glp_prob
  196.45 +{     /* LP/MIP problem object */
  196.46 +      unsigned magic;
  196.47 +      /* magic value used for debugging */
  196.48 +      DMP *pool;
  196.49 +      /* memory pool to store problem object components */
  196.50 +      glp_tree *tree;
  196.51 +      /* pointer to the search tree; set by the MIP solver when this
  196.52 +         object is used in the tree as a core MIP object */
  196.53 +      void *parms;
  196.54 +      /* reserved for backward compatibility */
  196.55 +      /*--------------------------------------------------------------*/
  196.56 +      /* LP/MIP data */
  196.57 +      char *name;
  196.58 +      /* problem name (1 to 255 chars); NULL means no name is assigned
  196.59 +         to the problem */
  196.60 +      char *obj;
  196.61 +      /* objective function name (1 to 255 chars); NULL means no name
  196.62 +         is assigned to the objective function */
  196.63 +      int dir;
  196.64 +      /* optimization direction flag (objective "sense"):
  196.65 +         GLP_MIN - minimization
  196.66 +         GLP_MAX - maximization */
  196.67 +      double c0;
  196.68 +      /* constant term of the objective function ("shift") */
  196.69 +      int m_max;
  196.70 +      /* length of the array of rows (enlarged automatically) */
  196.71 +      int n_max;
  196.72 +      /* length of the array of columns (enlarged automatically) */
  196.73 +      int m;
  196.74 +      /* number of rows, 0 <= m <= m_max */
  196.75 +      int n;
  196.76 +      /* number of columns, 0 <= n <= n_max */
  196.77 +      int nnz;
  196.78 +      /* number of non-zero constraint coefficients, nnz >= 0 */
  196.79 +      GLPROW **row; /* GLPROW *row[1+m_max]; */
  196.80 +      /* row[i], 1 <= i <= m, is a pointer to i-th row */
  196.81 +      GLPCOL **col; /* GLPCOL *col[1+n_max]; */
  196.82 +      /* col[j], 1 <= j <= n, is a pointer to j-th column */
  196.83 +      AVL *r_tree;
  196.84 +      /* row index to find rows by their names; NULL means this index
  196.85 +         does not exist */
  196.86 +      AVL *c_tree;
  196.87 +      /* column index to find columns by their names; NULL means this
  196.88 +         index does not exist */
  196.89 +      /*--------------------------------------------------------------*/
  196.90 +      /* basis factorization (LP) */
  196.91 +      int valid;
  196.92 +      /* the factorization is valid only if this flag is set */
  196.93 +      int *head; /* int head[1+m_max]; */
  196.94 +      /* basis header (valid only if the factorization is valid);
  196.95 +         head[i] = k is the ordinal number of auxiliary (1 <= k <= m)
  196.96 +         or structural (m+1 <= k <= m+n) variable which corresponds to
  196.97 +         i-th basic variable xB[i], 1 <= i <= m */
  196.98 +      glp_bfcp *bfcp;
  196.99 +      /* basis factorization control parameters; may be NULL */
 196.100 +      BFD *bfd; /* BFD bfd[1:m,1:m]; */
 196.101 +      /* basis factorization driver; may be NULL */
 196.102 +      /*--------------------------------------------------------------*/
 196.103 +      /* basic solution (LP) */
 196.104 +      int pbs_stat;
 196.105 +      /* primal basic solution status:
 196.106 +         GLP_UNDEF  - primal solution is undefined
 196.107 +         GLP_FEAS   - primal solution is feasible
 196.108 +         GLP_INFEAS - primal solution is infeasible
 196.109 +         GLP_NOFEAS - no primal feasible solution exists */
 196.110 +      int dbs_stat;
 196.111 +      /* dual basic solution status:
 196.112 +         GLP_UNDEF  - dual solution is undefined
 196.113 +         GLP_FEAS   - dual solution is feasible
 196.114 +         GLP_INFEAS - dual solution is infeasible
 196.115 +         GLP_NOFEAS - no dual feasible solution exists */
 196.116 +      double obj_val;
 196.117 +      /* objective function value */
 196.118 +      int it_cnt;
 196.119 +      /* simplex method iteration count; increased by one on performing
 196.120 +         one simplex iteration */
 196.121 +      int some;
 196.122 +      /* ordinal number of some auxiliary or structural variable having
 196.123 +         certain property, 0 <= some <= m+n */
 196.124 +      /*--------------------------------------------------------------*/
 196.125 +      /* interior-point solution (LP) */
 196.126 +      int ipt_stat;
 196.127 +      /* interior-point solution status:
 196.128 +         GLP_UNDEF  - interior solution is undefined
 196.129 +         GLP_OPT    - interior solution is optimal
 196.130 +         GLP_INFEAS - interior solution is infeasible
 196.131 +         GLP_NOFEAS - no feasible solution exists */
 196.132 +      double ipt_obj;
 196.133 +      /* objective function value */
 196.134 +      /*--------------------------------------------------------------*/
 196.135 +      /* integer solution (MIP) */
 196.136 +      int mip_stat;
 196.137 +      /* integer solution status:
 196.138 +         GLP_UNDEF  - integer solution is undefined
 196.139 +         GLP_OPT    - integer solution is optimal
 196.140 +         GLP_FEAS   - integer solution is feasible
 196.141 +         GLP_NOFEAS - no integer solution exists */
 196.142 +      double mip_obj;
 196.143 +      /* objective function value */
 196.144 +};
 196.145 +
 196.146 +struct GLPROW
 196.147 +{     /* LP/MIP row (auxiliary variable) */
 196.148 +      int i;
 196.149 +      /* ordinal number (1 to m) assigned to this row */
 196.150 +      char *name;
 196.151 +      /* row name (1 to 255 chars); NULL means no name is assigned to
 196.152 +         this row */
 196.153 +      AVLNODE *node;
 196.154 +      /* pointer to corresponding node in the row index; NULL means
 196.155 +         that either the row index does not exist or this row has no
 196.156 +         name assigned */
 196.157 +#if 1 /* 20/IX-2008 */
 196.158 +      int level;
 196.159 +      unsigned char origin;
 196.160 +      unsigned char klass;
 196.161 +#endif
 196.162 +      int type;
 196.163 +      /* type of the auxiliary variable:
 196.164 +         GLP_FR - free variable
 196.165 +         GLP_LO - variable with lower bound
 196.166 +         GLP_UP - variable with upper bound
 196.167 +         GLP_DB - double-bounded variable
 196.168 +         GLP_FX - fixed variable */
 196.169 +      double lb; /* non-scaled */
 196.170 +      /* lower bound; if the row has no lower bound, lb is zero */
 196.171 +      double ub; /* non-scaled */
 196.172 +      /* upper bound; if the row has no upper bound, ub is zero */
 196.173 +      /* if the row type is GLP_FX, ub is equal to lb */
 196.174 +      GLPAIJ *ptr; /* non-scaled */
 196.175 +      /* pointer to doubly linked list of constraint coefficients which
 196.176 +         are placed in this row */
 196.177 +      double rii;
 196.178 +      /* diagonal element r[i,i] of scaling matrix R for this row;
 196.179 +         if the scaling is not used, r[i,i] is 1 */
 196.180 +      int stat;
 196.181 +      /* status of the auxiliary variable:
 196.182 +         GLP_BS - basic variable
 196.183 +         GLP_NL - non-basic variable on lower bound
 196.184 +         GLP_NU - non-basic variable on upper bound
 196.185 +         GLP_NF - non-basic free variable
 196.186 +         GLP_NS - non-basic fixed variable */
 196.187 +      int bind;
 196.188 +      /* if the auxiliary variable is basic, head[bind] refers to this
 196.189 +         row, otherwise, bind is 0; this attribute is valid only if the
 196.190 +         basis factorization is valid */
 196.191 +      double prim; /* non-scaled */
 196.192 +      /* primal value of the auxiliary variable in basic solution */
 196.193 +      double dual; /* non-scaled */
 196.194 +      /* dual value of the auxiliary variable in basic solution */
 196.195 +      double pval; /* non-scaled */
 196.196 +      /* primal value of the auxiliary variable in interior solution */
 196.197 +      double dval; /* non-scaled */
 196.198 +      /* dual value of the auxiliary variable in interior solution */
 196.199 +      double mipx; /* non-scaled */
 196.200 +      /* primal value of the auxiliary variable in integer solution */
 196.201 +};
 196.202 +
 196.203 +struct GLPCOL
 196.204 +{     /* LP/MIP column (structural variable) */
 196.205 +      int j;
 196.206 +      /* ordinal number (1 to n) assigned to this column */
 196.207 +      char *name;
 196.208 +      /* column name (1 to 255 chars); NULL means no name is assigned
 196.209 +         to this column */
 196.210 +      AVLNODE *node;
 196.211 +      /* pointer to corresponding node in the column index; NULL means
 196.212 +         that either the column index does not exist or the column has
 196.213 +         no name assigned */
 196.214 +      int kind;
 196.215 +      /* kind of the structural variable:
 196.216 +         GLP_CV - continuous variable
 196.217 +         GLP_IV - integer or binary variable */
 196.218 +      int type;
 196.219 +      /* type of the structural variable:
 196.220 +         GLP_FR - free variable
 196.221 +         GLP_LO - variable with lower bound
 196.222 +         GLP_UP - variable with upper bound
 196.223 +         GLP_DB - double-bounded variable
 196.224 +         GLP_FX - fixed variable */
 196.225 +      double lb; /* non-scaled */
 196.226 +      /* lower bound; if the column has no lower bound, lb is zero */
 196.227 +      double ub; /* non-scaled */
 196.228 +      /* upper bound; if the column has no upper bound, ub is zero */
 196.229 +      /* if the column type is GLP_FX, ub is equal to lb */
 196.230 +      double coef; /* non-scaled */
 196.231 +      /* objective coefficient at the structural variable */
 196.232 +      GLPAIJ *ptr; /* non-scaled */
 196.233 +      /* pointer to doubly linked list of constraint coefficients which
 196.234 +         are placed in this column */
 196.235 +      double sjj;
 196.236 +      /* diagonal element s[j,j] of scaling matrix S for this column;
 196.237 +         if the scaling is not used, s[j,j] is 1 */
 196.238 +      int stat;
 196.239 +      /* status of the structural variable:
 196.240 +         GLP_BS - basic variable
 196.241 +         GLP_NL - non-basic variable on lower bound
 196.242 +         GLP_NU - non-basic variable on upper bound
 196.243 +         GLP_NF - non-basic free variable
 196.244 +         GLP_NS - non-basic fixed variable */
 196.245 +      int bind;
 196.246 +      /* if the structural variable is basic, head[bind] refers to
 196.247 +         this column; otherwise, bind is 0; this attribute is valid only
 196.248 +         if the basis factorization is valid */
 196.249 +      double prim; /* non-scaled */
 196.250 +      /* primal value of the structural variable in basic solution */
 196.251 +      double dual; /* non-scaled */
 196.252 +      /* dual value of the structural variable in basic solution */
 196.253 +      double pval; /* non-scaled */
 196.254 +      /* primal value of the structural variable in interior solution */
 196.255 +      double dval; /* non-scaled */
 196.256 +      /* dual value of the structural variable in interior solution */
 196.257 +      double mipx; /* non-scaled */
 196.258 +      /* primal value of the structural variable in integer solution */
 196.259 +};
 196.260 +
 196.261 +struct GLPAIJ
 196.262 +{     /* constraint coefficient a[i,j] */
 196.263 +      GLPROW *row;
 196.264 +      /* pointer to row, where this coefficient is placed */
 196.265 +      GLPCOL *col;
 196.266 +      /* pointer to column, where this coefficient is placed */
 196.267 +      double val;
 196.268 +      /* numeric (non-zero) value of this coefficient */
 196.269 +      GLPAIJ *r_prev;
 196.270 +      /* pointer to previous coefficient in the same row */
 196.271 +      GLPAIJ *r_next;
 196.272 +      /* pointer to next coefficient in the same row */
 196.273 +      GLPAIJ *c_prev;
 196.274 +      /* pointer to previous coefficient in the same column */
 196.275 +      GLPAIJ *c_next;
 196.276 +      /* pointer to next coefficient in the same column */
 196.277 +};
 196.278 +
 196.279 +void _glp_check_kkt(glp_prob *P, int sol, int cond, double *ae_max,
 196.280 +      int *ae_ind, double *re_max, int *re_ind);
 196.281 +/* check feasibility and optimality conditions */
 196.282 +
 196.283 +#define lpx_put_solution _glp_put_solution
 196.284 +void lpx_put_solution(glp_prob *lp, int inval, const int *p_stat,
 196.285 +      const int *d_stat, const double *obj_val, const int r_stat[],
 196.286 +      const double r_prim[], const double r_dual[], const int c_stat[],
 196.287 +      const double c_prim[], const double c_dual[]);
 196.288 +/* store basic solution components */
 196.289 +
 196.290 +#define lpx_put_mip_soln _glp_put_mip_soln
 196.291 +void lpx_put_mip_soln(LPX *lp, int i_stat, double row_mipx[],
 196.292 +      double col_mipx[]);
 196.293 +/* store mixed integer solution components */
 196.294 +
 196.295 +#if 1 /* 28/XI-2009 */
 196.296 +int _glp_analyze_row(glp_prob *P, int len, const int ind[],
 196.297 +      const double val[], int type, double rhs, double eps, int *_piv,
 196.298 +      double *_x, double *_dx, double *_y, double *_dy, double *_dz);
 196.299 +/* simulate one iteration of dual simplex method */
 196.300 +#endif
 196.301 +
 196.302 +#if 1 /* 08/XII-2009 */
 196.303 +void _glp_mpl_init_rand(glp_tran *tran, int seed);
 196.304 +#endif
 196.305 +
 196.306 +#define glp_skpgen _glp_skpgen
 196.307 +void glp_skpgen(int n, int r, int type, int v, int s, int a[],
 196.308 +   int *b, int c[]);
 196.309 +/* Pisinger's 0-1 single knapsack problem generator */
 196.310 +
 196.311 +#if 1 /* 28/V-2010 */
 196.312 +int _glp_intopt1(glp_prob *P, const glp_iocp *parm);
 196.313 +#endif
 196.314 +
 196.315 +#endif
 196.316 +
 196.317 +/* eof */
   197.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
   197.2 +++ b/deps/glpk/src/glpapi01.c	Sun Nov 06 20:59:10 2011 +0100
   197.3 @@ -0,0 +1,1570 @@
   197.4 +/* glpapi01.c (problem creating and modifying routines) */
   197.5 +
   197.6 +/***********************************************************************
   197.7 +*  This code is part of GLPK (GNU Linear Programming Kit).
   197.8 +*
   197.9 +*  Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008,
  197.10 +*  2009, 2010, 2011 Andrew Makhorin, Department for Applied Informatics,
  197.11 +*  Moscow Aviation Institute, Moscow, Russia. All rights reserved.
  197.12 +*  E-mail: <mao@gnu.org>.
  197.13 +*
  197.14 +*  GLPK is free software: you can redistribute it and/or modify it
  197.15 +*  under the terms of the GNU General Public License as published by
  197.16 +*  the Free Software Foundation, either version 3 of the License, or
  197.17 +*  (at your option) any later version.
  197.18 +*
  197.19 +*  GLPK is distributed in the hope that it will be useful, but WITHOUT
  197.20 +*  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
  197.21 +*  or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
  197.22 +*  License for more details.
  197.23 +*
  197.24 +*  You should have received a copy of the GNU General Public License
  197.25 +*  along with GLPK. If not, see <http://www.gnu.org/licenses/>.
  197.26 +***********************************************************************/
  197.27 +
  197.28 +#include "glpios.h"
  197.29 +
  197.30 +/* CAUTION: DO NOT CHANGE THE LIMITS BELOW */
  197.31 +
  197.32 +#define M_MAX 100000000 /* = 100*10^6 */
  197.33 +/* maximal number of rows in the problem object */
  197.34 +
  197.35 +#define N_MAX 100000000 /* = 100*10^6 */
  197.36 +/* maximal number of columns in the problem object */
  197.37 +
  197.38 +#define NNZ_MAX 500000000 /* = 500*10^6 */
  197.39 +/* maximal number of constraint coefficients in the problem object */
  197.40 +
  197.41 +/***********************************************************************
  197.42 +*  NAME
  197.43 +*
  197.44 +*  glp_create_prob - create problem object
  197.45 +*
  197.46 +*  SYNOPSIS
  197.47 +*
  197.48 +*  glp_prob *glp_create_prob(void);
  197.49 +*
  197.50 +*  DESCRIPTION
  197.51 +*
  197.52 +*  The routine glp_create_prob creates a new problem object, which is
  197.53 +*  initially "empty", i.e. has no rows and columns.
  197.54 +*
  197.55 +*  RETURNS
  197.56 +*
  197.57 +*  The routine returns a pointer to the object created, which should be
  197.58 +*  used in any subsequent operations on this object. */
  197.59 +
  197.60 +static void create_prob(glp_prob *lp)
  197.61 +{     lp->magic = GLP_PROB_MAGIC;
  197.62 +      lp->pool = dmp_create_pool();
  197.63 +#if 0 /* 17/XI-2009 */
  197.64 +      lp->cps = xmalloc(sizeof(struct LPXCPS));
  197.65 +      lpx_reset_parms(lp);
  197.66 +#else
  197.67 +      lp->parms = NULL;
  197.68 +#endif
  197.69 +      lp->tree = NULL;
  197.70 +#if 0
  197.71 +      lp->lwa = 0;
  197.72 +      lp->cwa = NULL;
  197.73 +#endif
  197.74 +      /* LP/MIP data */
  197.75 +      lp->name = NULL;
  197.76 +      lp->obj = NULL;
  197.77 +      lp->dir = GLP_MIN;
  197.78 +      lp->c0 = 0.0;
  197.79 +      lp->m_max = 100;
  197.80 +      lp->n_max = 200;
  197.81 +      lp->m = lp->n = 0;
  197.82 +      lp->nnz = 0;
  197.83 +      lp->row = xcalloc(1+lp->m_max, sizeof(GLPROW *));
  197.84 +      lp->col = xcalloc(1+lp->n_max, sizeof(GLPCOL *));
  197.85 +      lp->r_tree = lp->c_tree = NULL;
  197.86 +      /* basis factorization */
  197.87 +      lp->valid = 0;
  197.88 +      lp->head = xcalloc(1+lp->m_max, sizeof(int));
  197.89 +      lp->bfcp = NULL;
  197.90 +      lp->bfd = NULL;
  197.91 +      /* basic solution (LP) */
  197.92 +      lp->pbs_stat = lp->dbs_stat = GLP_UNDEF;
  197.93 +      lp->obj_val = 0.0;
  197.94 +      lp->it_cnt = 0;
  197.95 +      lp->some = 0;
  197.96 +      /* interior-point solution (LP) */
  197.97 +      lp->ipt_stat = GLP_UNDEF;
  197.98 +      lp->ipt_obj = 0.0;
  197.99 +      /* integer solution (MIP) */
 197.100 +      lp->mip_stat = GLP_UNDEF;
 197.101 +      lp->mip_obj = 0.0;
 197.102 +      return;
 197.103 +}
 197.104 +
 197.105 +glp_prob *glp_create_prob(void)
 197.106 +{     glp_prob *lp;
 197.107 +      lp = xmalloc(sizeof(glp_prob));
 197.108 +      create_prob(lp);
 197.109 +      return lp;
 197.110 +}
 197.111 +
 197.112 +/***********************************************************************
 197.113 +*  NAME
 197.114 +*
 197.115 +*  glp_set_prob_name - assign (change) problem name
 197.116 +*
 197.117 +*  SYNOPSIS
 197.118 +*
 197.119 +*  void glp_set_prob_name(glp_prob *lp, const char *name);
 197.120 +*
 197.121 +*  DESCRIPTION
 197.122 +*
 197.123 +*  The routine glp_set_prob_name assigns a given symbolic name (1 up to
 197.124 +*  255 characters) to the specified problem object.
 197.125 +*
 197.126 +*  If the parameter name is NULL or empty string, the routine erases an
 197.127 +*  existing symbolic name of the problem object. */
 197.128 +
 197.129 +void glp_set_prob_name(glp_prob *lp, const char *name)
 197.130 +{     glp_tree *tree = lp->tree;
 197.131 +      if (tree != NULL && tree->reason != 0)
 197.132 +         xerror("glp_set_prob_name: operation not allowed\n");
 197.133 +      if (lp->name != NULL)
 197.134 +      {  dmp_free_atom(lp->pool, lp->name, strlen(lp->name)+1);
 197.135 +         lp->name = NULL;
 197.136 +      }
 197.137 +      if (!(name == NULL || name[0] == '\0'))
 197.138 +      {  int k;
 197.139 +         for (k = 0; name[k] != '\0'; k++)
 197.140 +         {  if (k == 256)
 197.141 +               xerror("glp_set_prob_name: problem name too long\n");
 197.142 +            if (iscntrl((unsigned char)name[k]))
 197.143 +               xerror("glp_set_prob_name: problem name contains invalid"
 197.144 +                  " character(s)\n");
 197.145 +         }
 197.146 +         lp->name = dmp_get_atom(lp->pool, strlen(name)+1);
 197.147 +         strcpy(lp->name, name);
 197.148 +      }
 197.149 +      return;
 197.150 +}
 197.151 +
 197.152 +/***********************************************************************
 197.153 +*  NAME
 197.154 +*
 197.155 +*  glp_set_obj_name - assign (change) objective function name
 197.156 +*
 197.157 +*  SYNOPSIS
 197.158 +*
 197.159 +*  void glp_set_obj_name(glp_prob *lp, const char *name);
 197.160 +*
 197.161 +*  DESCRIPTION
 197.162 +*
 197.163 +*  The routine glp_set_obj_name assigns a given symbolic name (1 up to
 197.164 +*  255 characters) to the objective function of the specified problem
 197.165 +*  object.
 197.166 +*
 197.167 +*  If the parameter name is NULL or empty string, the routine erases an
 197.168 +*  existing name of the objective function. */
 197.169 +
 197.170 +void glp_set_obj_name(glp_prob *lp, const char *name)
 197.171 +{     glp_tree *tree = lp->tree;
 197.172 +      if (tree != NULL && tree->reason != 0)
 197.173 +         xerror("glp_set_obj_name: operation not allowed\n");
 197.174 +     if (lp->obj != NULL)
 197.175 +      {  dmp_free_atom(lp->pool, lp->obj, strlen(lp->obj)+1);
 197.176 +         lp->obj = NULL;
 197.177 +      }
 197.178 +      if (!(name == NULL || name[0] == '\0'))
 197.179 +      {  int k;
 197.180 +         for (k = 0; name[k] != '\0'; k++)
 197.181 +         {  if (k == 256)
 197.182 +               xerror("glp_set_obj_name: objective name too long\n");
 197.183 +            if (iscntrl((unsigned char)name[k]))
 197.184 +               xerror("glp_set_obj_name: objective name contains invali"
 197.185 +                  "d character(s)\n");
 197.186 +         }
 197.187 +         lp->obj = dmp_get_atom(lp->pool, strlen(name)+1);
 197.188 +         strcpy(lp->obj, name);
 197.189 +      }
 197.190 +      return;
 197.191 +}
 197.192 +
 197.193 +/***********************************************************************
 197.194 +*  NAME
 197.195 +*
 197.196 +*  glp_set_obj_dir - set (change) optimization direction flag
 197.197 +*
 197.198 +*  SYNOPSIS
 197.199 +*
 197.200 +*  void glp_set_obj_dir(glp_prob *lp, int dir);
 197.201 +*
 197.202 +*  DESCRIPTION
 197.203 +*
 197.204 +*  The routine glp_set_obj_dir sets (changes) optimization direction
 197.205 +*  flag (i.e. "sense" of the objective function) as specified by the
 197.206 +*  parameter dir:
 197.207 +*
 197.208 +*  GLP_MIN - minimization;
 197.209 +*  GLP_MAX - maximization. */
 197.210 +
 197.211 +void glp_set_obj_dir(glp_prob *lp, int dir)
 197.212 +{     glp_tree *tree = lp->tree;
 197.213 +      if (tree != NULL && tree->reason != 0)
 197.214 +         xerror("glp_set_obj_dir: operation not allowed\n");
 197.215 +     if (!(dir == GLP_MIN || dir == GLP_MAX))
 197.216 +         xerror("glp_set_obj_dir: dir = %d; invalid direction flag\n",
 197.217 +            dir);
 197.218 +      lp->dir = dir;
 197.219 +      return;
 197.220 +}
 197.221 +
 197.222 +/***********************************************************************
 197.223 +*  NAME
 197.224 +*
 197.225 +*  glp_add_rows - add new rows to problem object
 197.226 +*
 197.227 +*  SYNOPSIS
 197.228 +*
 197.229 +*  int glp_add_rows(glp_prob *lp, int nrs);
 197.230 +*
 197.231 +*  DESCRIPTION
 197.232 +*
 197.233 +*  The routine glp_add_rows adds nrs rows (constraints) to the specified
 197.234 +*  problem object. New rows are always added to the end of the row list,
 197.235 +*  so the ordinal numbers of existing rows remain unchanged.
 197.236 +*
 197.237 +*  Being added each new row is initially free (unbounded) and has empty
 197.238 +*  list of the constraint coefficients.
 197.239 +*
 197.240 +*  RETURNS
 197.241 +*
 197.242 +*  The routine glp_add_rows returns the ordinal number of the first new
 197.243 +*  row added to the problem object. */
 197.244 +
 197.245 +int glp_add_rows(glp_prob *lp, int nrs)
 197.246 +{     glp_tree *tree = lp->tree;
 197.247 +      GLPROW *row;
 197.248 +      int m_new, i;
 197.249 +      /* determine new number of rows */
 197.250 +      if (nrs < 1)
 197.251 +         xerror("glp_add_rows: nrs = %d; invalid number of rows\n",
 197.252 +            nrs);
 197.253 +      if (nrs > M_MAX - lp->m)
 197.254 +         xerror("glp_add_rows: nrs = %d; too many rows\n", nrs);
 197.255 +      m_new = lp->m + nrs;
 197.256 +      /* increase the room, if necessary */
 197.257 +      if (lp->m_max < m_new)
 197.258 +      {  GLPROW **save = lp->row;
 197.259 +         while (lp->m_max < m_new)
 197.260 +         {  lp->m_max += lp->m_max;
 197.261 +            xassert(lp->m_max > 0);
 197.262 +         }
 197.263 +         lp->row = xcalloc(1+lp->m_max, sizeof(GLPROW *));
 197.264 +         memcpy(&lp->row[1], &save[1], lp->m * sizeof(GLPROW *));
 197.265 +         xfree(save);
 197.266 +         /* do not forget about the basis header */
 197.267 +         xfree(lp->head);
 197.268 +         lp->head = xcalloc(1+lp->m_max, sizeof(int));
 197.269 +      }
 197.270 +      /* add new rows to the end of the row list */
 197.271 +      for (i = lp->m+1; i <= m_new; i++)
 197.272 +      {  /* create row descriptor */
 197.273 +         lp->row[i] = row = dmp_get_atom(lp->pool, sizeof(GLPROW));
 197.274 +         row->i = i;
 197.275 +         row->name = NULL;
 197.276 +         row->node = NULL;
 197.277 +#if 1 /* 20/IX-2008 */
 197.278 +         row->level = 0;
 197.279 +         row->origin = 0;
 197.280 +         row->klass = 0;
 197.281 +         if (tree != NULL)
 197.282 +         {  switch (tree->reason)
 197.283 +            {  case 0:
 197.284 +                  break;
 197.285 +               case GLP_IROWGEN:
 197.286 +                  xassert(tree->curr != NULL);
 197.287 +                  row->level = tree->curr->level;
 197.288 +                  row->origin = GLP_RF_LAZY;
 197.289 +                  break;
 197.290 +               case GLP_ICUTGEN:
 197.291 +                  xassert(tree->curr != NULL);
 197.292 +                  row->level = tree->curr->level;
 197.293 +                  row->origin = GLP_RF_CUT;
 197.294 +                  break;
 197.295 +               default:
 197.296 +                  xassert(tree != tree);
 197.297 +            }
 197.298 +         }
 197.299 +#endif
 197.300 +         row->type = GLP_FR;
 197.301 +         row->lb = row->ub = 0.0;
 197.302 +         row->ptr = NULL;
 197.303 +         row->rii = 1.0;
 197.304 +         row->stat = GLP_BS;
 197.305 +#if 0
 197.306 +         row->bind = -1;
 197.307 +#else
 197.308 +         row->bind = 0;
 197.309 +#endif
 197.310 +         row->prim = row->dual = 0.0;
 197.311 +         row->pval = row->dval = 0.0;
 197.312 +         row->mipx = 0.0;
 197.313 +      }
 197.314 +      /* set new number of rows */
 197.315 +      lp->m = m_new;
 197.316 +      /* invalidate the basis factorization */
 197.317 +      lp->valid = 0;
 197.318 +#if 1
 197.319 +      if (tree != NULL && tree->reason != 0) tree->reopt = 1;
 197.320 +#endif
 197.321 +      /* return the ordinal number of the first row added */
 197.322 +      return m_new - nrs + 1;
 197.323 +}
 197.324 +
 197.325 +/***********************************************************************
 197.326 +*  NAME
 197.327 +*
 197.328 +*  glp_add_cols - add new columns to problem object
 197.329 +*
 197.330 +*  SYNOPSIS
 197.331 +*
 197.332 +*  int glp_add_cols(glp_prob *lp, int ncs);
 197.333 +*
 197.334 +*  DESCRIPTION
 197.335 +*
 197.336 +*  The routine glp_add_cols adds ncs columns (structural variables) to
 197.337 +*  the specified problem object. New columns are always added to the end
 197.338 +*  of the column list, so the ordinal numbers of existing columns remain
 197.339 +*  unchanged.
 197.340 +*
 197.341 +*  Being added each new column is initially fixed at zero and has empty
 197.342 +*  list of the constraint coefficients.
 197.343 +*
 197.344 +*  RETURNS
 197.345 +*
 197.346 +*  The routine glp_add_cols returns the ordinal number of the first new
 197.347 +*  column added to the problem object. */
 197.348 +
 197.349 +int glp_add_cols(glp_prob *lp, int ncs)
 197.350 +{     glp_tree *tree = lp->tree;
 197.351 +      GLPCOL *col;
 197.352 +      int n_new, j;
 197.353 +      if (tree != NULL && tree->reason != 0)
 197.354 +         xerror("glp_add_cols: operation not allowed\n");
 197.355 +      /* determine new number of columns */
 197.356 +      if (ncs < 1)
 197.357 +         xerror("glp_add_cols: ncs = %d; invalid number of columns\n",
 197.358 +            ncs);
 197.359 +      if (ncs > N_MAX - lp->n)
 197.360 +         xerror("glp_add_cols: ncs = %d; too many columns\n", ncs);
 197.361 +      n_new = lp->n + ncs;
 197.362 +      /* increase the room, if necessary */
 197.363 +      if (lp->n_max < n_new)
 197.364 +      {  GLPCOL **save = lp->col;
 197.365 +         while (lp->n_max < n_new)
 197.366 +         {  lp->n_max += lp->n_max;
 197.367 +            xassert(lp->n_max > 0);
 197.368 +         }
 197.369 +         lp->col = xcalloc(1+lp->n_max, sizeof(GLPCOL *));
 197.370 +         memcpy(&lp->col[1], &save[1], lp->n * sizeof(GLPCOL *));
 197.371 +         xfree(save);
 197.372 +      }
 197.373 +      /* add new columns to the end of the column list */
 197.374 +      for (j = lp->n+1; j <= n_new; j++)
 197.375 +      {  /* create column descriptor */
 197.376 +         lp->col[j] = col = dmp_get_atom(lp->pool, sizeof(GLPCOL));
 197.377 +         col->j = j;
 197.378 +         col->name = NULL;
 197.379 +         col->node = NULL;
 197.380 +         col->kind = GLP_CV;
 197.381 +         col->type = GLP_FX;
 197.382 +         col->lb = col->ub = 0.0;
 197.383 +         col->coef = 0.0;
 197.384 +         col->ptr = NULL;
 197.385 +         col->sjj = 1.0;
 197.386 +         col->stat = GLP_NS;
 197.387 +#if 0
 197.388 +         col->bind = -1;
 197.389 +#else
 197.390 +         col->bind = 0; /* the basis may remain valid */
 197.391 +#endif
 197.392 +         col->prim = col->dual = 0.0;
 197.393 +         col->pval = col->dval = 0.0;
 197.394 +         col->mipx = 0.0;
 197.395 +      }
 197.396 +      /* set new number of columns */
 197.397 +      lp->n = n_new;
 197.398 +      /* return the ordinal number of the first column added */
 197.399 +      return n_new - ncs + 1;
 197.400 +}
 197.401 +
 197.402 +/***********************************************************************
 197.403 +*  NAME
 197.404 +*
 197.405 +*  glp_set_row_name - assign (change) row name
 197.406 +*
 197.407 +*  SYNOPSIS
 197.408 +*
 197.409 +*  void glp_set_row_name(glp_prob *lp, int i, const char *name);
 197.410 +*
 197.411 +*  DESCRIPTION
 197.412 +*
 197.413 +*  The routine glp_set_row_name assigns a given symbolic name (1 up to
 197.414 +*  255 characters) to i-th row (auxiliary variable) of the specified
 197.415 +*  problem object.
 197.416 +*
 197.417 +*  If the parameter name is NULL or empty string, the routine erases an
 197.418 +*  existing name of i-th row. */
 197.419 +
 197.420 +void glp_set_row_name(glp_prob *lp, int i, const char *name)
 197.421 +{     glp_tree *tree = lp->tree;
 197.422 +      GLPROW *row;
 197.423 +      if (!(1 <= i && i <= lp->m))
 197.424 +         xerror("glp_set_row_name: i = %d; row number out of range\n",
 197.425 +            i);
 197.426 +      row = lp->row[i];
 197.427 +      if (tree != NULL && tree->reason != 0)
 197.428 +      {  xassert(tree->curr != NULL);
 197.429 +         xassert(row->level == tree->curr->level);
 197.430 +      }
 197.431 +      if (row->name != NULL)
 197.432 +      {  if (row->node != NULL)
 197.433 +         {  xassert(lp->r_tree != NULL);
 197.434 +            avl_delete_node(lp->r_tree, row->node);
 197.435 +            row->node = NULL;
 197.436 +         }
 197.437 +         dmp_free_atom(lp->pool, row->name, strlen(row->name)+1);
 197.438 +         row->name = NULL;
 197.439 +      }
 197.440 +      if (!(name == NULL || name[0] == '\0'))
 197.441 +      {  int k;
 197.442 +         for (k = 0; name[k] != '\0'; k++)
 197.443 +         {  if (k == 256)
 197.444 +               xerror("glp_set_row_name: i = %d; row name too long\n",
 197.445 +                  i);
 197.446 +            if (iscntrl((unsigned char)name[k]))
 197.447 +               xerror("glp_set_row_name: i = %d: row name contains inva"
 197.448 +                  "lid character(s)\n", i);
 197.449 +         }
 197.450 +         row->name = dmp_get_atom(lp->pool, strlen(name)+1);
 197.451 +         strcpy(row->name, name);
 197.452 +         if (lp->r_tree != NULL)
 197.453 +         {  xassert(row->node == NULL);
 197.454 +            row->node = avl_insert_node(lp->r_tree, row->name);
 197.455 +            avl_set_node_link(row->node, row);
 197.456 +         }
 197.457 +      }
 197.458 +      return;
 197.459 +}
 197.460 +
 197.461 +/***********************************************************************
 197.462 +*  NAME
 197.463 +*
 197.464 +*  glp_set_col_name - assign (change) column name
 197.465 +*
 197.466 +*  SYNOPSIS
 197.467 +*
 197.468 +*  void glp_set_col_name(glp_prob *lp, int j, const char *name);
 197.469 +*
 197.470 +*  DESCRIPTION
 197.471 +*
 197.472 +*  The routine glp_set_col_name assigns a given symbolic name (1 up to
 197.473 +*  255 characters) to j-th column (structural variable) of the specified
 197.474 +*  problem object.
 197.475 +*
 197.476 +*  If the parameter name is NULL or empty string, the routine erases an
 197.477 +*  existing name of j-th column. */
 197.478 +
 197.479 +void glp_set_col_name(glp_prob *lp, int j, const char *name)
 197.480 +{     glp_tree *tree = lp->tree;
 197.481 +      GLPCOL *col;
 197.482 +      if (tree != NULL && tree->reason != 0)
 197.483 +         xerror("glp_set_col_name: operation not allowed\n");
 197.484 +      if (!(1 <= j && j <= lp->n))
 197.485 +         xerror("glp_set_col_name: j = %d; column number out of range\n"
 197.486 +            , j);
 197.487 +      col = lp->col[j];
 197.488 +      if (col->name != NULL)
 197.489 +      {  if (col->node != NULL)
 197.490 +         {  xassert(lp->c_tree != NULL);
 197.491 +            avl_delete_node(lp->c_tree, col->node);
 197.492 +            col->node = NULL;
 197.493 +         }
 197.494 +         dmp_free_atom(lp->pool, col->name, strlen(col->name)+1);
 197.495 +         col->name = NULL;
 197.496 +      }
 197.497 +      if (!(name == NULL || name[0] == '\0'))
 197.498 +      {  int k;
 197.499 +         for (k = 0; name[k] != '\0'; k++)
 197.500 +         {  if (k == 256)
 197.501 +               xerror("glp_set_col_name: j = %d; column name too long\n"
 197.502 +                  , j);
 197.503 +            if (iscntrl((unsigned char)name[k]))
 197.504 +               xerror("glp_set_col_name: j = %d: column name contains i"
 197.505 +                  "nvalid character(s)\n", j);
 197.506 +         }
 197.507 +         col->name = dmp_get_atom(lp->pool, strlen(name)+1);
 197.508 +         strcpy(col->name, name);
 197.509 +         if (lp->c_tree != NULL && col->name != NULL)
 197.510 +         {  xassert(col->node == NULL);
 197.511 +            col->node = avl_insert_node(lp->c_tree, col->name);
 197.512 +            avl_set_node_link(col->node, col);
 197.513 +         }
 197.514 +      }
 197.515 +      return;
 197.516 +}
 197.517 +
 197.518 +/***********************************************************************
 197.519 +*  NAME
 197.520 +*
 197.521 +*  glp_set_row_bnds - set (change) row bounds
 197.522 +*
 197.523 +*  SYNOPSIS
 197.524 +*
 197.525 +*  void glp_set_row_bnds(glp_prob *lp, int i, int type, double lb,
 197.526 +*     double ub);
 197.527 +*
 197.528 +*  DESCRIPTION
 197.529 +*
 197.530 +*  The routine glp_set_row_bnds sets (changes) the type and bounds of
 197.531 +*  i-th row (auxiliary variable) of the specified problem object.
 197.532 +*
 197.533 +*  Parameters type, lb, and ub specify the type, lower bound, and upper
 197.534 +*  bound, respectively, as follows:
 197.535 +*
 197.536 +*     Type           Bounds        Comments
 197.537 +*     ------------------------------------------------------
 197.538 +*     GLP_FR   -inf <  x <  +inf   Free variable
 197.539 +*     GLP_LO     lb <= x <  +inf   Variable with lower bound
 197.540 +*     GLP_UP   -inf <  x <=  ub    Variable with upper bound
 197.541 +*     GLP_DB     lb <= x <=  ub    Double-bounded variable
 197.542 +*     GLP_FX           x  =  lb    Fixed variable
 197.543 +*
 197.544 +*  where x is the auxiliary variable associated with i-th row.
 197.545 +*
 197.546 +*  If the row has no lower bound, the parameter lb is ignored. If the
 197.547 +*  row has no upper bound, the parameter ub is ignored. If the row is
 197.548 +*  an equality constraint (i.e. the corresponding auxiliary variable is
 197.549 +*  of fixed type), only the parameter lb is used while the parameter ub
 197.550 +*  is ignored. */
 197.551 +
 197.552 +void glp_set_row_bnds(glp_prob *lp, int i, int type, double lb,
 197.553 +      double ub)
 197.554 +{     GLPROW *row;
 197.555 +      if (!(1 <= i && i <= lp->m))
 197.556 +         xerror("glp_set_row_bnds: i = %d; row number out of range\n",
 197.557 +            i);
 197.558 +      row = lp->row[i];
 197.559 +      row->type = type;
 197.560 +      switch (type)
 197.561 +      {  case GLP_FR:
 197.562 +            row->lb = row->ub = 0.0;
 197.563 +            if (row->stat != GLP_BS) row->stat = GLP_NF;
 197.564 +            break;
 197.565 +         case GLP_LO:
 197.566 +            row->lb = lb, row->ub = 0.0;
 197.567 +            if (row->stat != GLP_BS) row->stat = GLP_NL;
 197.568 +            break;
 197.569 +         case GLP_UP:
 197.570 +            row->lb = 0.0, row->ub = ub;
 197.571 +            if (row->stat != GLP_BS) row->stat = GLP_NU;
 197.572 +            break;
 197.573 +         case GLP_DB:
 197.574 +            row->lb = lb, row->ub = ub;
 197.575 +            if (!(row->stat == GLP_BS ||
 197.576 +                  row->stat == GLP_NL || row->stat == GLP_NU))
 197.577 +               row->stat = (fabs(lb) <= fabs(ub) ? GLP_NL : GLP_NU);
 197.578 +            break;
 197.579 +         case GLP_FX:
 197.580 +            row->lb = row->ub = lb;
 197.581 +            if (row->stat != GLP_BS) row->stat = GLP_NS;
 197.582 +            break;
 197.583 +         default:
 197.584 +            xerror("glp_set_row_bnds: i = %d; type = %d; invalid row ty"
 197.585 +               "pe\n", i, type);
 197.586 +      }
 197.587 +      return;
 197.588 +}
 197.589 +
 197.590 +/***********************************************************************
 197.591 +*  NAME
 197.592 +*
 197.593 +*  glp_set_col_bnds - set (change) column bounds
 197.594 +*
 197.595 +*  SYNOPSIS
 197.596 +*
 197.597 +*  void glp_set_col_bnds(glp_prob *lp, int j, int type, double lb,
 197.598 +*     double ub);
 197.599 +*
 197.600 +*  DESCRIPTION
 197.601 +*
 197.602 +*  The routine glp_set_col_bnds sets (changes) the type and bounds of
 197.603 +*  j-th column (structural variable) of the specified problem object.
 197.604 +*
 197.605 +*  Parameters type, lb, and ub specify the type, lower bound, and upper
 197.606 +*  bound, respectively, as follows:
 197.607 +*
 197.608 +*     Type           Bounds        Comments
 197.609 +*     ------------------------------------------------------
 197.610 +*     GLP_FR   -inf <  x <  +inf   Free variable
 197.611 +*     GLP_LO     lb <= x <  +inf   Variable with lower bound
 197.612 +*     GLP_UP   -inf <  x <=  ub    Variable with upper bound
 197.613 +*     GLP_DB     lb <= x <=  ub    Double-bounded variable
 197.614 +*     GLP_FX           x  =  lb    Fixed variable
 197.615 +*
 197.616 +*  where x is the structural variable associated with j-th column.
 197.617 +*
 197.618 +*  If the column has no lower bound, the parameter lb is ignored. If the
 197.619 +*  column has no upper bound, the parameter ub is ignored. If the column
 197.620 +*  is of fixed type, only the parameter lb is used while the parameter
 197.621 +*  ub is ignored. */
 197.622 +
 197.623 +void glp_set_col_bnds(glp_prob *lp, int j, int type, double lb,
 197.624 +      double ub)
 197.625 +{     GLPCOL *col;
 197.626 +      if (!(1 <= j && j <= lp->n))
 197.627 +         xerror("glp_set_col_bnds: j = %d; column number out of range\n"
 197.628 +            , j);
 197.629 +      col = lp->col[j];
 197.630 +      col->type = type;
 197.631 +      switch (type)
 197.632 +      {  case GLP_FR:
 197.633 +            col->lb = col->ub = 0.0;
 197.634 +            if (col->stat != GLP_BS) col->stat = GLP_NF;
 197.635 +            break;
 197.636 +         case GLP_LO:
 197.637 +            col->lb = lb, col->ub = 0.0;
 197.638 +            if (col->stat != GLP_BS) col->stat = GLP_NL;
 197.639 +            break;
 197.640 +         case GLP_UP:
 197.641 +            col->lb = 0.0, col->ub = ub;
 197.642 +            if (col->stat != GLP_BS) col->stat = GLP_NU;
 197.643 +            break;
 197.644 +         case GLP_DB:
 197.645 +            col->lb = lb, col->ub = ub;
 197.646 +            if (!(col->stat == GLP_BS ||
 197.647 +                  col->stat == GLP_NL || col->stat == GLP_NU))
 197.648 +               col->stat = (fabs(lb) <= fabs(ub) ? GLP_NL : GLP_NU);
 197.649 +            break;
 197.650 +         case GLP_FX:
 197.651 +            col->lb = col->ub = lb;
 197.652 +            if (col->stat != GLP_BS) col->stat = GLP_NS;
 197.653 +            break;
 197.654 +         default:
 197.655 +            xerror("glp_set_col_bnds: j = %d; type = %d; invalid column"
 197.656 +               " type\n", j, type);
 197.657 +      }
 197.658 +      return;
 197.659 +}
 197.660 +
 197.661 +/***********************************************************************
 197.662 +*  NAME
 197.663 +*
 197.664 +*  glp_set_obj_coef - set (change) obj. coefficient or constant term
 197.665 +*
 197.666 +*  SYNOPSIS
 197.667 +*
 197.668 +*  void glp_set_obj_coef(glp_prob *lp, int j, double coef);
 197.669 +*
 197.670 +*  DESCRIPTION
 197.671 +*
 197.672 +*  The routine glp_set_obj_coef sets (changes) objective coefficient at
 197.673 +*  j-th column (structural variable) of the specified problem object.
 197.674 +*
 197.675 +*  If the parameter j is 0, the routine sets (changes) the constant term
 197.676 +*  ("shift") of the objective function. */
 197.677 +
 197.678 +void glp_set_obj_coef(glp_prob *lp, int j, double coef)
 197.679 +{     glp_tree *tree = lp->tree;
 197.680 +      if (tree != NULL && tree->reason != 0)
 197.681 +         xerror("glp_set_obj_coef: operation not allowed\n");
 197.682 +      if (!(0 <= j && j <= lp->n))
 197.683 +         xerror("glp_set_obj_coef: j = %d; column number out of range\n"
 197.684 +            , j);
 197.685 +      if (j == 0)
 197.686 +         lp->c0 = coef;
 197.687 +      else
 197.688 +         lp->col[j]->coef = coef;
 197.689 +      return;
 197.690 +}
 197.691 +
 197.692 +/***********************************************************************
 197.693 +*  NAME
 197.694 +*
 197.695 +*  glp_set_mat_row - set (replace) row of the constraint matrix
 197.696 +*
 197.697 +*  SYNOPSIS
 197.698 +*
 197.699 +*  void glp_set_mat_row(glp_prob *lp, int i, int len, const int ind[],
 197.700 +*     const double val[]);
 197.701 +*
 197.702 +*  DESCRIPTION
 197.703 +*
 197.704 +*  The routine glp_set_mat_row stores (replaces) the contents of i-th
 197.705 +*  row of the constraint matrix of the specified problem object.
 197.706 +*
 197.707 +*  Column indices and numeric values of new row elements must be placed
 197.708 +*  in locations ind[1], ..., ind[len] and val[1], ..., val[len], where
 197.709 +*  0 <= len <= n is the new length of i-th row, n is the current number
 197.710 +*  of columns in the problem object. Elements with identical column
 197.711 +*  indices are not allowed. Zero elements are allowed, but they are not
 197.712 +*  stored in the constraint matrix.
 197.713 +*
 197.714 +*  If the parameter len is zero, the parameters ind and/or val can be
 197.715 +*  specified as NULL. */
 197.716 +
 197.717 +void glp_set_mat_row(glp_prob *lp, int i, int len, const int ind[],
 197.718 +      const double val[])
 197.719 +{     glp_tree *tree = lp->tree;
 197.720 +      GLPROW *row;
 197.721 +      GLPCOL *col;
 197.722 +      GLPAIJ *aij, *next;
 197.723 +      int j, k;
 197.724 +      /* obtain pointer to i-th row */
 197.725 +      if (!(1 <= i && i <= lp->m))
 197.726 +         xerror("glp_set_mat_row: i = %d; row number out of range\n",
 197.727 +            i);
 197.728 +      row = lp->row[i];
 197.729 +      if (tree != NULL && tree->reason != 0)
 197.730 +      {  xassert(tree->curr != NULL);
 197.731 +         xassert(row->level == tree->curr->level);
 197.732 +      }
 197.733 +      /* remove all existing elements from i-th row */
 197.734 +      while (row->ptr != NULL)
 197.735 +      {  /* take next element in the row */
 197.736 +         aij = row->ptr;
 197.737 +         /* remove the element from the row list */
 197.738 +         row->ptr = aij->r_next;
 197.739 +         /* obtain pointer to corresponding column */
 197.740 +         col = aij->col;
 197.741 +         /* remove the element from the column list */
 197.742 +         if (aij->c_prev == NULL)
 197.743 +            col->ptr = aij->c_next;
 197.744 +         else
 197.745 +            aij->c_prev->c_next = aij->c_next;
 197.746 +         if (aij->c_next == NULL)
 197.747 +            ;
 197.748 +         else
 197.749 +            aij->c_next->c_prev = aij->c_prev;
 197.750 +         /* return the element to the memory pool */
 197.751 +         dmp_free_atom(lp->pool, aij, sizeof(GLPAIJ)), lp->nnz--;
 197.752 +         /* if the corresponding column is basic, invalidate the basis
 197.753 +            factorization */
 197.754 +         if (col->stat == GLP_BS) lp->valid = 0;
 197.755 +      }
 197.756 +      /* store new contents of i-th row */
 197.757 +      if (!(0 <= len && len <= lp->n))
 197.758 +         xerror("glp_set_mat_row: i = %d; len = %d; invalid row length "
 197.759 +            "\n", i, len);
 197.760 +      if (len > NNZ_MAX - lp->nnz)
 197.761 +         xerror("glp_set_mat_row: i = %d; len = %d; too many constraint"
 197.762 +            " coefficients\n", i, len);
 197.763 +      for (k = 1; k <= len; k++)
 197.764 +      {  /* take number j of corresponding column */
 197.765 +         j = ind[k];
 197.766 +         /* obtain pointer to j-th column */
 197.767 +         if (!(1 <= j && j <= lp->n))
 197.768 +            xerror("glp_set_mat_row: i = %d; ind[%d] = %d; column index"
 197.769 +               " out of range\n", i, k, j);
 197.770 +         col = lp->col[j];
 197.771 +         /* if there is element with the same column index, it can only
 197.772 +            be found in the beginning of j-th column list */
 197.773 +         if (col->ptr != NULL && col->ptr->row->i == i)
 197.774 +            xerror("glp_set_mat_row: i = %d; ind[%d] = %d; duplicate co"
 197.775 +               "lumn indices not allowed\n", i, k, j);
 197.776 +         /* create new element */
 197.777 +         aij = dmp_get_atom(lp->pool, sizeof(GLPAIJ)), lp->nnz++;
 197.778 +         aij->row = row;
 197.779 +         aij->col = col;
 197.780 +         aij->val = val[k];
 197.781 +         /* add the new element to the beginning of i-th row and j-th
 197.782 +            column lists */
 197.783 +         aij->r_prev = NULL;
 197.784 +         aij->r_next = row->ptr;
 197.785 +         aij->c_prev = NULL;
 197.786 +         aij->c_next = col->ptr;
 197.787 +         if (aij->r_next != NULL) aij->r_next->r_prev = aij;
 197.788 +         if (aij->c_next != NULL) aij->c_next->c_prev = aij;
 197.789 +         row->ptr = col->ptr = aij;
 197.790 +         /* if the corresponding column is basic, invalidate the basis
 197.791 +            factorization */
 197.792 +         if (col->stat == GLP_BS && aij->val != 0.0) lp->valid = 0;
 197.793 +      }
 197.794 +      /* remove zero elements from i-th row */
 197.795 +      for (aij = row->ptr; aij != NULL; aij = next)
 197.796 +      {  next = aij->r_next;
 197.797 +         if (aij->val == 0.0)
 197.798 +         {  /* remove the element from the row list */
 197.799 +            if (aij->r_prev == NULL)
 197.800 +               row->ptr = next;
 197.801 +            else
 197.802 +               aij->r_prev->r_next = next;
 197.803 +            if (next == NULL)
 197.804 +               ;
 197.805 +            else
 197.806 +               next->r_prev = aij->r_prev;
 197.807 +            /* remove the element from the column list */
 197.808 +            xassert(aij->c_prev == NULL);
 197.809 +            aij->col->ptr = aij->c_next;
 197.810 +            if (aij->c_next != NULL) aij->c_next->c_prev = NULL;
 197.811 +            /* return the element to the memory pool */
 197.812 +            dmp_free_atom(lp->pool, aij, sizeof(GLPAIJ)), lp->nnz--;
 197.813 +         }
 197.814 +      }
 197.815 +      return;
 197.816 +}
 197.817 +
 197.818 +/***********************************************************************
 197.819 +*  NAME
 197.820 +*
 197.821 +*  glp_set_mat_col - set (replace) column of the constraint matrix
 197.822 +*
 197.823 +*  SYNOPSIS
 197.824 +*
 197.825 +*  void glp_set_mat_col(glp_prob *lp, int j, int len, const int ind[],
 197.826 +*     const double val[]);
 197.827 +*
 197.828 +*  DESCRIPTION
 197.829 +*
 197.830 +*  The routine glp_set_mat_col stores (replaces) the contents of j-th
 197.831 +*  column of the constraint matrix of the specified problem object.
 197.832 +*
 197.833 +*  Row indices and numeric values of new column elements must be placed
 197.834 +*  in locations ind[1], ..., ind[len] and val[1], ..., val[len], where
 197.835 +*  0 <= len <= m is the new length of j-th column, m is the current
 197.836 +*  number of rows in the problem object. Elements with identical column
 197.837 +*  indices are not allowed. Zero elements are allowed, but they are not
 197.838 +*  stored in the constraint matrix.
 197.839 +*
 197.840 +*  If the parameter len is zero, the parameters ind and/or val can be
 197.841 +*  specified as NULL. */
 197.842 +
 197.843 +void glp_set_mat_col(glp_prob *lp, int j, int len, const int ind[],
 197.844 +      const double val[])
 197.845 +{     glp_tree *tree = lp->tree;
 197.846 +      GLPROW *row;
 197.847 +      GLPCOL *col;
 197.848 +      GLPAIJ *aij, *next;
 197.849 +      int i, k;
 197.850 +      if (tree != NULL && tree->reason != 0)
 197.851 +         xerror("glp_set_mat_col: operation not allowed\n");
 197.852 +      /* obtain pointer to j-th column */
 197.853 +      if (!(1 <= j && j <= lp->n))
 197.854 +         xerror("glp_set_mat_col: j = %d; column number out of range\n",
 197.855 +            j);
 197.856 +      col = lp->col[j];
 197.857 +      /* remove all existing elements from j-th column */
 197.858 +      while (col->ptr != NULL)
 197.859 +      {  /* take next element in the column */
 197.860 +         aij = col->ptr;
 197.861 +         /* remove the element from the column list */
 197.862 +         col->ptr = aij->c_next;
 197.863 +         /* obtain pointer to corresponding row */
 197.864 +         row = aij->row;
 197.865 +         /* remove the element from the row list */
 197.866 +         if (aij->r_prev == NULL)
 197.867 +            row->ptr = aij->r_next;
 197.868 +         else
 197.869 +            aij->r_prev->r_next = aij->r_next;
 197.870 +         if (aij->r_next == NULL)
 197.871 +            ;
 197.872 +         else
 197.873 +            aij->r_next->r_prev = aij->r_prev;
 197.874 +         /* return the element to the memory pool */
 197.875 +         dmp_free_atom(lp->pool, aij, sizeof(GLPAIJ)), lp->nnz--;
 197.876 +      }
 197.877 +      /* store new contents of j-th column */
 197.878 +      if (!(0 <= len && len <= lp->m))
 197.879 +         xerror("glp_set_mat_col: j = %d; len = %d; invalid column leng"
 197.880 +            "th\n", j, len);
 197.881 +      if (len > NNZ_MAX - lp->nnz)
 197.882 +         xerror("glp_set_mat_col: j = %d; len = %d; too many constraint"
 197.883 +            " coefficients\n", j, len);
 197.884 +      for (k = 1; k <= len; k++)
 197.885 +      {  /* take number i of corresponding row */
 197.886 +         i = ind[k];
 197.887 +         /* obtain pointer to i-th row */
 197.888 +         if (!(1 <= i && i <= lp->m))
 197.889 +            xerror("glp_set_mat_col: j = %d; ind[%d] = %d; row index ou"
 197.890 +               "t of range\n", j, k, i);
 197.891 +         row = lp->row[i];
 197.892 +         /* if there is element with the same row index, it can only be
 197.893 +            found in the beginning of i-th row list */
 197.894 +         if (row->ptr != NULL && row->ptr->col->j == j)
 197.895 +            xerror("glp_set_mat_col: j = %d; ind[%d] = %d; duplicate ro"
 197.896 +               "w indices not allowed\n", j, k, i);
 197.897 +         /* create new element */
 197.898 +         aij = dmp_get_atom(lp->pool, sizeof(GLPAIJ)), lp->nnz++;
 197.899 +         aij->row = row;
 197.900 +         aij->col = col;
 197.901 +         aij->val = val[k];
 197.902 +         /* add the new element to the beginning of i-th row and j-th
 197.903 +            column lists */
 197.904 +         aij->r_prev = NULL;
 197.905 +         aij->r_next = row->ptr;
 197.906 +         aij->c_prev = NULL;
 197.907 +         aij->c_next = col->ptr;
 197.908 +         if (aij->r_next != NULL) aij->r_next->r_prev = aij;
 197.909 +         if (aij->c_next != NULL) aij->c_next->c_prev = aij;
 197.910 +         row->ptr = col->ptr = aij;
 197.911 +      }
 197.912 +      /* remove zero elements from j-th column */
 197.913 +      for (aij = col->ptr; aij != NULL; aij = next)
 197.914 +      {  next = aij->c_next;
 197.915 +         if (aij->val == 0.0)
 197.916 +         {  /* remove the element from the row list */
 197.917 +            xassert(aij->r_prev == NULL);
 197.918 +            aij->row->ptr = aij->r_next;
 197.919 +            if (aij->r_next != NULL) aij->r_next->r_prev = NULL;
 197.920 +            /* remove the element from the column list */
 197.921 +            if (aij->c_prev == NULL)
 197.922 +               col->ptr = next;
 197.923 +            else
 197.924 +               aij->c_prev->c_next = next;
 197.925 +            if (next == NULL)
 197.926 +               ;
 197.927 +            else
 197.928 +               next->c_prev = aij->c_prev;
 197.929 +            /* return the element to the memory pool */
 197.930 +            dmp_free_atom(lp->pool, aij, sizeof(GLPAIJ)), lp->nnz--;
 197.931 +         }
 197.932 +      }
 197.933 +      /* if j-th column is basic, invalidate the basis factorization */
 197.934 +      if (col->stat == GLP_BS) lp->valid = 0;
 197.935 +      return;
 197.936 +}
 197.937 +
 197.938 +/***********************************************************************
 197.939 +*  NAME
 197.940 +*
 197.941 +*  glp_load_matrix - load (replace) the whole constraint matrix
 197.942 +*
 197.943 +*  SYNOPSIS
 197.944 +*
 197.945 +*  void glp_load_matrix(glp_prob *lp, int ne, const int ia[],
 197.946 +*     const int ja[], const double ar[]);
 197.947 +*
 197.948 +*  DESCRIPTION
 197.949 +*
 197.950 +*  The routine glp_load_matrix loads the constraint matrix passed in
 197.951 +*  the arrays ia, ja, and ar into the specified problem object. Before
 197.952 +*  loading the current contents of the constraint matrix is destroyed.
 197.953 +*
 197.954 +*  Constraint coefficients (elements of the constraint matrix) must be
 197.955 +*  specified as triplets (ia[k], ja[k], ar[k]) for k = 1, ..., ne,
 197.956 +*  where ia[k] is the row index, ja[k] is the column index, ar[k] is a
 197.957 +*  numeric value of corresponding constraint coefficient. The parameter
 197.958 +*  ne specifies the total number of (non-zero) elements in the matrix
 197.959 +*  to be loaded. Coefficients with identical indices are not allowed.
 197.960 +*  Zero coefficients are allowed, however, they are not stored in the
 197.961 +*  constraint matrix.
 197.962 +*
 197.963 +*  If the parameter ne is zero, the parameters ia, ja, and ar can be
 197.964 +*  specified as NULL. */
 197.965 +
 197.966 +void glp_load_matrix(glp_prob *lp, int ne, const int ia[],
 197.967 +      const int ja[], const double ar[])
 197.968 +{     glp_tree *tree = lp->tree;
 197.969 +      GLPROW *row;
 197.970 +      GLPCOL *col;
 197.971 +      GLPAIJ *aij, *next;
 197.972 +      int i, j, k;
 197.973 +      if (tree != NULL && tree->reason != 0)
 197.974 +         xerror("glp_load_matrix: operation not allowed\n");
 197.975 +      /* clear the constraint matrix */
 197.976 +      for (i = 1; i <= lp->m; i++)
 197.977 +      {  row = lp->row[i];
 197.978 +         while (row->ptr != NULL)
 197.979 +         {  aij = row->ptr;
 197.980 +            row->ptr = aij->r_next;
 197.981 +            dmp_free_atom(lp->pool, aij, sizeof(GLPAIJ)), lp->nnz--;
 197.982 +         }
 197.983 +      }
 197.984 +      xassert(lp->nnz == 0);
 197.985 +      for (j = 1; j <= lp->n; j++) lp->col[j]->ptr = NULL;
 197.986 +      /* load the new contents of the constraint matrix and build its
 197.987 +         row lists */
 197.988 +      if (ne < 0)
 197.989 +         xerror("glp_load_matrix: ne = %d; invalid number of constraint"
 197.990 +            " coefficients\n", ne);
 197.991 +      if (ne > NNZ_MAX)
 197.992 +         xerror("glp_load_matrix: ne = %d; too many constraint coeffici"
 197.993 +            "ents\n", ne);
 197.994 +      for (k = 1; k <= ne; k++)
 197.995 +      {  /* take indices of new element */
 197.996 +         i = ia[k], j = ja[k];
 197.997 +         /* obtain pointer to i-th row */
 197.998 +         if (!(1 <= i && i <= lp->m))
 197.999 +            xerror("glp_load_matrix: ia[%d] = %d; row index out of rang"
197.1000 +               "e\n", k, i);
197.1001 +         row = lp->row[i];
197.1002 +         /* obtain pointer to j-th column */
197.1003 +         if (!(1 <= j && j <= lp->n))
197.1004 +            xerror("glp_load_matrix: ja[%d] = %d; column index out of r"
197.1005 +               "ange\n", k, j);
197.1006 +         col = lp->col[j];
197.1007 +         /* create new element */
197.1008 +         aij = dmp_get_atom(lp->pool, sizeof(GLPAIJ)), lp->nnz++;
197.1009 +         aij->row = row;
197.1010 +         aij->col = col;
197.1011 +         aij->val = ar[k];
197.1012 +         /* add the new element to the beginning of i-th row list */
197.1013 +         aij->r_prev = NULL;
197.1014 +         aij->r_next = row->ptr;
197.1015 +         if (aij->r_next != NULL) aij->r_next->r_prev = aij;
197.1016 +         row->ptr = aij;
197.1017 +      }
197.1018 +      xassert(lp->nnz == ne);
197.1019 +      /* build column lists of the constraint matrix and check elements
197.1020 +         with identical indices */
197.1021 +      for (i = 1; i <= lp->m; i++)
197.1022 +      {  for (aij = lp->row[i]->ptr; aij != NULL; aij = aij->r_next)
197.1023 +         {  /* obtain pointer to corresponding column */
197.1024 +            col = aij->col;
197.1025 +            /* if there is element with identical indices, it can only
197.1026 +               be found in the beginning of j-th column list */
197.1027 +            if (col->ptr != NULL && col->ptr->row->i == i)
197.1028 +            {  for (k = 1; k <= ne; k++)
197.1029 +                  if (ia[k] == i && ja[k] == col->j) break;
197.1030 +               xerror("glp_load_mat: ia[%d] = %d; ja[%d] = %d; duplicat"
197.1031 +                  "e indices not allowed\n", k, i, k, col->j);
197.1032 +            }
197.1033 +            /* add the element to the beginning of j-th column list */
197.1034 +            aij->c_prev = NULL;
197.1035 +            aij->c_next = col->ptr;
197.1036 +            if (aij->c_next != NULL) aij->c_next->c_prev = aij;
197.1037 +            col->ptr = aij;
197.1038 +         }
197.1039 +      }
197.1040 +      /* remove zero elements from the constraint matrix */
197.1041 +      for (i = 1; i <= lp->m; i++)
197.1042 +      {  row = lp->row[i];
197.1043 +         for (aij = row->ptr; aij != NULL; aij = next)
197.1044 +         {  next = aij->r_next;
197.1045 +            if (aij->val == 0.0)
197.1046 +            {  /* remove the element from the row list */
197.1047 +               if (aij->r_prev == NULL)
197.1048 +                  row->ptr = next;
197.1049 +               else
197.1050 +                  aij->r_prev->r_next = next;
197.1051 +               if (next == NULL)
197.1052 +                  ;
197.1053 +               else
197.1054 +                  next->r_prev = aij->r_prev;
197.1055 +               /* remove the element from the column list */
197.1056 +               if (aij->c_prev == NULL)
197.1057 +                  aij->col->ptr = aij->c_next;
197.1058 +               else
197.1059 +                  aij->c_prev->c_next = aij->c_next;
197.1060 +               if (aij->c_next == NULL)
197.1061 +                  ;
197.1062 +               else
197.1063 +                  aij->c_next->c_prev = aij->c_prev;
197.1064 +               /* return the element to the memory pool */
197.1065 +               dmp_free_atom(lp->pool, aij, sizeof(GLPAIJ)), lp->nnz--;
197.1066 +            }
197.1067 +         }
197.1068 +      }
197.1069 +      /* invalidate the basis factorization */
197.1070 +      lp->valid = 0;
197.1071 +      return;
197.1072 +}
197.1073 +
197.1074 +/***********************************************************************
197.1075 +*  NAME
197.1076 +*
197.1077 +*  glp_check_dup - check for duplicate elements in sparse matrix
197.1078 +*
197.1079 +*  SYNOPSIS
197.1080 +*
197.1081 +*  int glp_check_dup(int m, int n, int ne, const int ia[],
197.1082 +*     const int ja[]);
197.1083 +*
197.1084 +*  DESCRIPTION
197.1085 +*
197.1086 +*  The routine glp_check_dup checks for duplicate elements (that is,
197.1087 +*  elements with identical indices) in a sparse matrix specified in the
197.1088 +*  coordinate format.
197.1089 +*
197.1090 +*  The parameters m and n specifies, respectively, the number of rows
197.1091 +*  and columns in the matrix, m >= 0, n >= 0.
197.1092 +*
197.1093 +*  The parameter ne specifies the number of (structurally) non-zero
197.1094 +*  elements in the matrix, ne >= 0.
197.1095 +*
197.1096 +*  Elements of the matrix are specified as doublets (ia[k],ja[k]) for
197.1097 +*  k = 1,...,ne, where ia[k] is a row index, ja[k] is a column index.
197.1098 +*
197.1099 +*  The routine glp_check_dup can be used prior to a call to the routine
197.1100 +*  glp_load_matrix to check that the constraint matrix to be loaded has
197.1101 +*  no duplicate elements.
197.1102 +*
197.1103 +*  RETURNS
197.1104 +*
197.1105 +*  The routine glp_check_dup returns one of the following values:
197.1106 +*
197.1107 +*   0 - the matrix has no duplicate elements;
197.1108 +*
197.1109 +*  -k - indices ia[k] or/and ja[k] are out of range;
197.1110 +*
197.1111 +*  +k - element (ia[k],ja[k]) is duplicate. */
197.1112 +
197.1113 +int glp_check_dup(int m, int n, int ne, const int ia[], const int ja[])
197.1114 +{     int i, j, k, *ptr, *next, ret;
197.1115 +      char *flag;
197.1116 +      if (m < 0)
197.1117 +         xerror("glp_check_dup: m = %d; invalid parameter\n");
197.1118 +      if (n < 0)
197.1119 +         xerror("glp_check_dup: n = %d; invalid parameter\n");
197.1120 +      if (ne < 0)
197.1121 +         xerror("glp_check_dup: ne = %d; invalid parameter\n");
197.1122 +      if (ne > 0 && ia == NULL)
197.1123 +         xerror("glp_check_dup: ia = %p; invalid parameter\n", ia);
197.1124 +      if (ne > 0 && ja == NULL)
197.1125 +         xerror("glp_check_dup: ja = %p; invalid parameter\n", ja);
197.1126 +      for (k = 1; k <= ne; k++)
197.1127 +      {  i = ia[k], j = ja[k];
197.1128 +         if (!(1 <= i && i <= m && 1 <= j && j <= n))
197.1129 +         {  ret = -k;
197.1130 +            goto done;
197.1131 +         }
197.1132 +      }
197.1133 +      if (m == 0 || n == 0)
197.1134 +      {  ret = 0;
197.1135 +         goto done;
197.1136 +      }
197.1137 +      /* allocate working arrays */
197.1138 +      ptr = xcalloc(1+m, sizeof(int));
197.1139 +      next = xcalloc(1+ne, sizeof(int));
197.1140 +      flag = xcalloc(1+n, sizeof(char));
197.1141 +      /* build row lists */
197.1142 +      for (i = 1; i <= m; i++)
197.1143 +         ptr[i] = 0;
197.1144 +      for (k = 1; k <= ne; k++)
197.1145 +      {  i = ia[k];
197.1146 +         next[k] = ptr[i];
197.1147 +         ptr[i] = k;
197.1148 +      }
197.1149 +      /* clear column flags */
197.1150 +      for (j = 1; j <= n; j++)
197.1151 +         flag[j] = 0;
197.1152 +      /* check for duplicate elements */
197.1153 +      for (i = 1; i <= m; i++)
197.1154 +      {  for (k = ptr[i]; k != 0; k = next[k])
197.1155 +         {  j = ja[k];
197.1156 +            if (flag[j])
197.1157 +            {  /* find first element (i,j) */
197.1158 +               for (k = 1; k <= ne; k++)
197.1159 +                  if (ia[k] == i && ja[k] == j) break;
197.1160 +               xassert(k <= ne);
197.1161 +               /* find next (duplicate) element (i,j) */
197.1162 +               for (k++; k <= ne; k++)
197.1163 +                  if (ia[k] == i && ja[k] == j) break;
197.1164 +               xassert(k <= ne);
197.1165 +               ret = +k;
197.1166 +               goto skip;
197.1167 +            }
197.1168 +            flag[j] = 1;
197.1169 +         }
197.1170 +         /* clear column flags */
197.1171 +         for (k = ptr[i]; k != 0; k = next[k])
197.1172 +            flag[ja[k]] = 0;
197.1173 +      }
197.1174 +      /* no duplicate element found */
197.1175 +      ret = 0;
197.1176 +skip: /* free working arrays */
197.1177 +      xfree(ptr);
197.1178 +      xfree(next);
197.1179 +      xfree(flag);
197.1180 +done: return ret;
197.1181 +}
197.1182 +
197.1183 +/***********************************************************************
197.1184 +*  NAME
197.1185 +*
197.1186 +*  glp_sort_matrix - sort elements of the constraint matrix
197.1187 +*
197.1188 +*  SYNOPSIS
197.1189 +*
197.1190 +*  void glp_sort_matrix(glp_prob *P);
197.1191 +*
197.1192 +*  DESCRIPTION
197.1193 +*
197.1194 +*  The routine glp_sort_matrix sorts elements of the constraint matrix
197.1195 +*  rebuilding its row and column linked lists. On exit from the routine
197.1196 +*  the constraint matrix is not changed, however, elements in the row
197.1197 +*  linked lists become ordered by ascending column indices, and the
197.1198 +*  elements in the column linked lists become ordered by ascending row
197.1199 +*  indices. */
197.1200 +
197.1201 +void glp_sort_matrix(glp_prob *P)
197.1202 +{     GLPAIJ *aij;
197.1203 +      int i, j;
197.1204 +      if (P == NULL || P->magic != GLP_PROB_MAGIC)
197.1205 +         xerror("glp_sort_matrix: P = %p; invalid problem object\n",
197.1206 +            P);
197.1207 +      /* rebuild row linked lists */
197.1208 +      for (i = P->m; i >= 1; i--)
197.1209 +         P->row[i]->ptr = NULL;
197.1210 +      for (j = P->n; j >= 1; j--)
197.1211 +      {  for (aij = P->col[j]->ptr; aij != NULL; aij = aij->c_next)
197.1212 +         {  i = aij->row->i;
197.1213 +            aij->r_prev = NULL;
197.1214 +            aij->r_next = P->row[i]->ptr;
197.1215 +            if (aij->r_next != NULL) aij->r_next->r_prev = aij;
197.1216 +            P->row[i]->ptr = aij;
197.1217 +         }
197.1218 +      }
197.1219 +      /* rebuild column linked lists */
197.1220 +      for (j = P->n; j >= 1; j--)
197.1221 +         P->col[j]->ptr = NULL;
197.1222 +      for (i = P->m; i >= 1; i--)
197.1223 +      {  for (aij = P->row[i]->ptr; aij != NULL; aij = aij->r_next)
197.1224 +         {  j = aij->col->j;
197.1225 +            aij->c_prev = NULL;
197.1226 +            aij->c_next = P->col[j]->ptr;
197.1227 +            if (aij->c_next != NULL) aij->c_next->c_prev = aij;
197.1228 +            P->col[j]->ptr = aij;
197.1229 +         }
197.1230 +      }
197.1231 +      return;
197.1232 +}
197.1233 +
197.1234 +/***********************************************************************
197.1235 +*  NAME
197.1236 +*
197.1237 +*  glp_del_rows - delete rows from problem object
197.1238 +*
197.1239 +*  SYNOPSIS
197.1240 +*
197.1241 +*  void glp_del_rows(glp_prob *lp, int nrs, const int num[]);
197.1242 +*
197.1243 +*  DESCRIPTION
197.1244 +*
197.1245 +*  The routine glp_del_rows deletes rows from the specified problem
197.1246 +*  object. Ordinal numbers of rows to be deleted should be placed in
197.1247 +*  locations num[1], ..., num[nrs], where nrs > 0.
197.1248 +*
197.1249 +*  Note that deleting rows involves changing ordinal numbers of other
197.1250 +*  rows remaining in the problem object. New ordinal numbers of the
197.1251 +*  remaining rows are assigned under the assumption that the original
197.1252 +*  order of rows is not changed. */
197.1253 +
197.1254 +void glp_del_rows(glp_prob *lp, int nrs, const int num[])
197.1255 +{     glp_tree *tree = lp->tree;
197.1256 +      GLPROW *row;
197.1257 +      int i, k, m_new;
197.1258 +      /* mark rows to be deleted */
197.1259 +      if (!(1 <= nrs && nrs <= lp->m))
197.1260 +         xerror("glp_del_rows: nrs = %d; invalid number of rows\n",
197.1261 +            nrs);
197.1262 +      for (k = 1; k <= nrs; k++)
197.1263 +      {  /* take the number of row to be deleted */
197.1264 +         i = num[k];
197.1265 +         /* obtain pointer to i-th row */
197.1266 +         if (!(1 <= i && i <= lp->m))
197.1267 +            xerror("glp_del_rows: num[%d] = %d; row number out of range"
197.1268 +               "\n", k, i);
197.1269 +         row = lp->row[i];
197.1270 +         if (tree != NULL && tree->reason != 0)
197.1271 +         {  if (!(tree->reason == GLP_IROWGEN ||
197.1272 +                  tree->reason == GLP_ICUTGEN))
197.1273 +               xerror("glp_del_rows: operation not allowed\n");
197.1274 +            xassert(tree->curr != NULL);
197.1275 +            if (row->level != tree->curr->level)
197.1276 +               xerror("glp_del_rows: num[%d] = %d; invalid attempt to d"
197.1277 +                  "elete row created not in current subproblem\n", k,i);
197.1278 +            if (row->stat != GLP_BS)
197.1279 +               xerror("glp_del_rows: num[%d] = %d; invalid attempt to d"
197.1280 +                  "elete active row (constraint)\n", k, i);
197.1281 +            tree->reinv = 1;
197.1282 +         }
197.1283 +         /* check that the row is not marked yet */
197.1284 +         if (row->i == 0)
197.1285 +            xerror("glp_del_rows: num[%d] = %d; duplicate row numbers n"
197.1286 +               "ot allowed\n", k, i);
197.1287 +         /* erase symbolic name assigned to the row */
197.1288 +         glp_set_row_name(lp, i, NULL);
197.1289 +         xassert(row->node == NULL);
197.1290 +         /* erase corresponding row of the constraint matrix */
197.1291 +         glp_set_mat_row(lp, i, 0, NULL, NULL);
197.1292 +         xassert(row->ptr == NULL);
197.1293 +         /* mark the row to be deleted */
197.1294 +         row->i = 0;
197.1295 +      }
197.1296 +      /* delete all marked rows from the row list */
197.1297 +      m_new = 0;
197.1298 +      for (i = 1; i <= lp->m; i++)
197.1299 +      {  /* obtain pointer to i-th row */
197.1300 +         row = lp->row[i];
197.1301 +         /* check if the row is marked */
197.1302 +         if (row->i == 0)
197.1303 +         {  /* it is marked, delete it */
197.1304 +            dmp_free_atom(lp->pool, row, sizeof(GLPROW));
197.1305 +         }
197.1306 +         else
197.1307 +         {  /* it is not marked; keep it */
197.1308 +            row->i = ++m_new;
197.1309 +            lp->row[row->i] = row;
197.1310 +         }
197.1311 +      }
197.1312 +      /* set new number of rows */
197.1313 +      lp->m = m_new;
197.1314 +      /* invalidate the basis factorization */
197.1315 +      lp->valid = 0;
197.1316 +      return;
197.1317 +}
197.1318 +
197.1319 +/***********************************************************************
197.1320 +*  NAME
197.1321 +*
197.1322 +*  glp_del_cols - delete columns from problem object
197.1323 +*
197.1324 +*  SYNOPSIS
197.1325 +*
197.1326 +*  void glp_del_cols(glp_prob *lp, int ncs, const int num[]);
197.1327 +*
197.1328 +*  DESCRIPTION
197.1329 +*
197.1330 +*  The routine glp_del_cols deletes columns from the specified problem
197.1331 +*  object. Ordinal numbers of columns to be deleted should be placed in
197.1332 +*  locations num[1], ..., num[ncs], where ncs > 0.
197.1333 +*
197.1334 +*  Note that deleting columns involves changing ordinal numbers of
197.1335 +*  other columns remaining in the problem object. New ordinal numbers
197.1336 +*  of the remaining columns are assigned under the assumption that the
197.1337 +*  original order of columns is not changed. */
197.1338 +
197.1339 +void glp_del_cols(glp_prob *lp, int ncs, const int num[])
197.1340 +{     glp_tree *tree = lp->tree;
197.1341 +      GLPCOL *col;
197.1342 +      int j, k, n_new;
197.1343 +      if (tree != NULL && tree->reason != 0)
197.1344 +         xerror("glp_del_cols: operation not allowed\n");
197.1345 +      /* mark columns to be deleted */
197.1346 +      if (!(1 <= ncs && ncs <= lp->n))
197.1347 +         xerror("glp_del_cols: ncs = %d; invalid number of columns\n",
197.1348 +            ncs);
197.1349 +      for (k = 1; k <= ncs; k++)
197.1350 +      {  /* take the number of column to be deleted */
197.1351 +         j = num[k];
197.1352 +         /* obtain pointer to j-th column */
197.1353 +         if (!(1 <= j && j <= lp->n))
197.1354 +            xerror("glp_del_cols: num[%d] = %d; column number out of ra"
197.1355 +               "nge", k, j);
197.1356 +         col = lp->col[j];
197.1357 +         /* check that the column is not marked yet */
197.1358 +         if (col->j == 0)
197.1359 +            xerror("glp_del_cols: num[%d] = %d; duplicate column number"
197.1360 +               "s not allowed\n", k, j);
197.1361 +         /* erase symbolic name assigned to the column */
197.1362 +         glp_set_col_name(lp, j, NULL);
197.1363 +         xassert(col->node == NULL);
197.1364 +         /* erase corresponding column of the constraint matrix */
197.1365 +         glp_set_mat_col(lp, j, 0, NULL, NULL);
197.1366 +         xassert(col->ptr == NULL);
197.1367 +         /* mark the column to be deleted */
197.1368 +         col->j = 0;
197.1369 +         /* if it is basic, invalidate the basis factorization */
197.1370 +         if (col->stat == GLP_BS) lp->valid = 0;
197.1371 +      }
197.1372 +      /* delete all marked columns from the column list */
197.1373 +      n_new = 0;
197.1374 +      for (j = 1; j <= lp->n; j++)
197.1375 +      {  /* obtain pointer to j-th column */
197.1376 +         col = lp->col[j];
197.1377 +         /* check if the column is marked */
197.1378 +         if (col->j == 0)
197.1379 +         {  /* it is marked; delete it */
197.1380 +            dmp_free_atom(lp->pool, col, sizeof(GLPCOL));
197.1381 +         }
197.1382 +         else
197.1383 +         {  /* it is not marked; keep it */
197.1384 +            col->j = ++n_new;
197.1385 +            lp->col[col->j] = col;
197.1386 +         }
197.1387 +      }
197.1388 +      /* set new number of columns */
197.1389 +      lp->n = n_new;
197.1390 +      /* if the basis header is still valid, adjust it */
197.1391 +      if (lp->valid)
197.1392 +      {  int m = lp->m;
197.1393 +         int *head = lp->head;
197.1394 +         for (j = 1; j <= n_new; j++)
197.1395 +         {  k = lp->col[j]->bind;
197.1396 +            if (k != 0)
197.1397 +            {  xassert(1 <= k && k <= m);
197.1398 +               head[k] = m + j;
197.1399 +            }
197.1400 +         }
197.1401 +      }
197.1402 +      return;
197.1403 +}
197.1404 +
197.1405 +/***********************************************************************
197.1406 +*  NAME
197.1407 +*
197.1408 +*  glp_copy_prob - copy problem object content
197.1409 +*
197.1410 +*  SYNOPSIS
197.1411 +*
197.1412 +*  void glp_copy_prob(glp_prob *dest, glp_prob *prob, int names);
197.1413 +*
197.1414 +*  DESCRIPTION
197.1415 +*
197.1416 +*  The routine glp_copy_prob copies the content of the problem object
197.1417 +*  prob to the problem object dest.
197.1418 +*
197.1419 +*  The parameter names is a flag. If it is non-zero, the routine also
197.1420 +*  copies all symbolic names; otherwise, if it is zero, symbolic names
197.1421 +*  are not copied. */
197.1422 +
197.1423 +void glp_copy_prob(glp_prob *dest, glp_prob *prob, int names)
197.1424 +{     glp_tree *tree = dest->tree;
197.1425 +      glp_bfcp bfcp;
197.1426 +      int i, j, len, *ind;
197.1427 +      double *val;
197.1428 +      if (tree != NULL && tree->reason != 0)
197.1429 +         xerror("glp_copy_prob: operation not allowed\n");
197.1430 +      if (dest == prob)
197.1431 +         xerror("glp_copy_prob: copying problem object to itself not al"
197.1432 +            "lowed\n");
197.1433 +      if (!(names == GLP_ON || names == GLP_OFF))
197.1434 +         xerror("glp_copy_prob: names = %d; invalid parameter\n",
197.1435 +            names);
197.1436 +      glp_erase_prob(dest);
197.1437 +      if (names && prob->name != NULL)
197.1438 +         glp_set_prob_name(dest, prob->name);
197.1439 +      if (names && prob->obj != NULL)
197.1440 +         glp_set_obj_name(dest, prob->obj);
197.1441 +      dest->dir = prob->dir;
197.1442 +      dest->c0 = prob->c0;
197.1443 +      if (prob->m > 0)
197.1444 +         glp_add_rows(dest, prob->m);
197.1445 +      if (prob->n > 0)
197.1446 +         glp_add_cols(dest, prob->n);
197.1447 +      glp_get_bfcp(prob, &bfcp);
197.1448 +      glp_set_bfcp(dest, &bfcp);
197.1449 +      dest->pbs_stat = prob->pbs_stat;
197.1450 +      dest->dbs_stat = prob->dbs_stat;
197.1451 +      dest->obj_val = prob->obj_val;
197.1452 +      dest->some = prob->some;
197.1453 +      dest->ipt_stat = prob->ipt_stat;
197.1454 +      dest->ipt_obj = prob->ipt_obj;
197.1455 +      dest->mip_stat = prob->mip_stat;
197.1456 +      dest->mip_obj = prob->mip_obj;
197.1457 +      for (i = 1; i <= prob->m; i++)
197.1458 +      {  GLPROW *to = dest->row[i];
197.1459 +         GLPROW *from = prob->row[i];
197.1460 +         if (names && from->name != NULL)
197.1461 +            glp_set_row_name(dest, i, from->name);
197.1462 +         to->type = from->type;
197.1463 +         to->lb = from->lb;
197.1464 +         to->ub = from->ub;
197.1465 +         to->rii = from->rii;
197.1466 +         to->stat = from->stat;
197.1467 +         to->prim = from->prim;
197.1468 +         to->dual = from->dual;
197.1469 +         to->pval = from->pval;
197.1470 +         to->dval = from->dval;
197.1471 +         to->mipx = from->mipx;
197.1472 +      }
197.1473 +      ind = xcalloc(1+prob->m, sizeof(int));
197.1474 +      val = xcalloc(1+prob->m, sizeof(double));
197.1475 +      for (j = 1; j <= prob->n; j++)
197.1476 +      {  GLPCOL *to = dest->col[j];
197.1477 +         GLPCOL *from = prob->col[j];
197.1478 +         if (names && from->name != NULL)
197.1479 +            glp_set_col_name(dest, j, from->name);
197.1480 +         to->kind = from->kind;
197.1481 +         to->type = from->type;
197.1482 +         to->lb = from->lb;
197.1483 +         to->ub = from->ub;
197.1484 +         to->coef = from->coef;
197.1485 +         len = glp_get_mat_col(prob, j, ind, val);
197.1486 +         glp_set_mat_col(dest, j, len, ind, val);
197.1487 +         to->sjj = from->sjj;
197.1488 +         to->stat = from->stat;
197.1489 +         to->prim = from->prim;
197.1490 +         to->dual = from->dual;
197.1491 +         to->pval = from->pval;
197.1492 +         to->dval = from->dval;
197.1493 +         to->mipx = from->mipx;
197.1494 +      }
197.1495 +      xfree(ind);
197.1496 +      xfree(val);
197.1497 +      return;
197.1498 +}
197.1499 +
197.1500 +/***********************************************************************
197.1501 +*  NAME
197.1502 +*
197.1503 +*  glp_erase_prob - erase problem object content
197.1504 +*
197.1505 +*  SYNOPSIS
197.1506 +*
197.1507 +*  void glp_erase_prob(glp_prob *lp);
197.1508 +*
197.1509 +*  DESCRIPTION
197.1510 +*
197.1511 +*  The routine glp_erase_prob erases the content of the specified
197.1512 +*  problem object. The effect of this operation is the same as if the
197.1513 +*  problem object would be deleted with the routine glp_delete_prob and
197.1514 +*  then created anew with the routine glp_create_prob, with exception
197.1515 +*  that the handle (pointer) to the problem object remains valid. */
197.1516 +
197.1517 +static void delete_prob(glp_prob *lp);
197.1518 +
197.1519 +void glp_erase_prob(glp_prob *lp)
197.1520 +{     glp_tree *tree = lp->tree;
197.1521 +      if (tree != NULL && tree->reason != 0)
197.1522 +         xerror("glp_erase_prob: operation not allowed\n");
197.1523 +      delete_prob(lp);
197.1524 +      create_prob(lp);
197.1525 +      return;
197.1526 +}
197.1527 +
197.1528 +/***********************************************************************
197.1529 +*  NAME
197.1530 +*
197.1531 +*  glp_delete_prob - delete problem object
197.1532 +*
197.1533 +*  SYNOPSIS
197.1534 +*
197.1535 +*  void glp_delete_prob(glp_prob *lp);
197.1536 +*
197.1537 +*  DESCRIPTION
197.1538 +*
197.1539 +*  The routine glp_delete_prob deletes the specified problem object and
197.1540 +*  frees all the memory allocated to it. */
197.1541 +
197.1542 +static void delete_prob(glp_prob *lp)
197.1543 +{     lp->magic = 0x3F3F3F3F;
197.1544 +      dmp_delete_pool(lp->pool);
197.1545 +#if 0 /* 17/XI-2009 */
197.1546 +      xfree(lp->cps);
197.1547 +#else
197.1548 +      if (lp->parms != NULL) xfree(lp->parms);
197.1549 +#endif
197.1550 +      xassert(lp->tree == NULL);
197.1551 +#if 0
197.1552 +      if (lp->cwa != NULL) xfree(lp->cwa);
197.1553 +#endif
197.1554 +      xfree(lp->row);
197.1555 +      xfree(lp->col);
197.1556 +      if (lp->r_tree != NULL) avl_delete_tree(lp->r_tree);
197.1557 +      if (lp->c_tree != NULL) avl_delete_tree(lp->c_tree);
197.1558 +      xfree(lp->head);
197.1559 +      if (lp->bfcp != NULL) xfree(lp->bfcp);
197.1560 +      if (lp->bfd != NULL) bfd_delete_it(lp->bfd);
197.1561 +      return;
197.1562 +}
197.1563 +
197.1564 +void glp_delete_prob(glp_prob *lp)
197.1565 +{     glp_tree *tree = lp->tree;
197.1566 +      if (tree != NULL && tree->reason != 0)
197.1567 +         xerror("glp_delete_prob: operation not allowed\n");
197.1568 +      delete_prob(lp);
197.1569 +      xfree(lp);
197.1570 +      return;
197.1571 +}
197.1572 +
197.1573 +/* eof */
   198.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
   198.2 +++ b/deps/glpk/src/glpapi02.c	Sun Nov 06 20:59:10 2011 +0100
   198.3 @@ -0,0 +1,491 @@
   198.4 +/* glpapi02.c (problem retrieving routines) */
   198.5 +
   198.6 +/***********************************************************************
   198.7 +*  This code is part of GLPK (GNU Linear Programming Kit).
   198.8 +*
   198.9 +*  Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008,
  198.10 +*  2009, 2010, 2011 Andrew Makhorin, Department for Applied Informatics,
  198.11 +*  Moscow Aviation Institute, Moscow, Russia. All rights reserved.
  198.12 +*  E-mail: <mao@gnu.org>.
  198.13 +*
  198.14 +*  GLPK is free software: you can redistribute it and/or modify it
  198.15 +*  under the terms of the GNU General Public License as published by
  198.16 +*  the Free Software Foundation, either version 3 of the License, or
  198.17 +*  (at your option) any later version.
  198.18 +*
  198.19 +*  GLPK is distributed in the hope that it will be useful, but WITHOUT
  198.20 +*  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
  198.21 +*  or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
  198.22 +*  License for more details.
  198.23 +*
  198.24 +*  You should have received a copy of the GNU General Public License
  198.25 +*  along with GLPK. If not, see <http://www.gnu.org/licenses/>.
  198.26 +***********************************************************************/
  198.27 +
  198.28 +#include "glpapi.h"
  198.29 +
  198.30 +/***********************************************************************
  198.31 +*  NAME
  198.32 +*
  198.33 +*  glp_get_prob_name - retrieve problem name
  198.34 +*
  198.35 +*  SYNOPSIS
  198.36 +*
  198.37 +*  const char *glp_get_prob_name(glp_prob *lp);
  198.38 +*
  198.39 +*  RETURNS
  198.40 +*
  198.41 +*  The routine glp_get_prob_name returns a pointer to an internal
  198.42 +*  buffer, which contains symbolic name of the problem. However, if the
  198.43 +*  problem has no assigned name, the routine returns NULL. */
  198.44 +
  198.45 +const char *glp_get_prob_name(glp_prob *lp)
  198.46 +{     char *name;
  198.47 +      name = lp->name;
  198.48 +      return name;
  198.49 +}
  198.50 +
  198.51 +/***********************************************************************
  198.52 +*  NAME
  198.53 +*
  198.54 +*  glp_get_obj_name - retrieve objective function name
  198.55 +*
  198.56 +*  SYNOPSIS
  198.57 +*
  198.58 +*  const char *glp_get_obj_name(glp_prob *lp);
  198.59 +*
  198.60 +*  RETURNS
  198.61 +*
  198.62 +*  The routine glp_get_obj_name returns a pointer to an internal
  198.63 +*  buffer, which contains a symbolic name of the objective function.
  198.64 +*  However, if the objective function has no assigned name, the routine
  198.65 +*  returns NULL. */
  198.66 +
  198.67 +const char *glp_get_obj_name(glp_prob *lp)
  198.68 +{     char *name;
  198.69 +      name = lp->obj;
  198.70 +      return name;
  198.71 +}
  198.72 +
  198.73 +/***********************************************************************
  198.74 +*  NAME
  198.75 +*
  198.76 +*  glp_get_obj_dir - retrieve optimization direction flag
  198.77 +*
  198.78 +*  SYNOPSIS
  198.79 +*
  198.80 +*  int glp_get_obj_dir(glp_prob *lp);
  198.81 +*
  198.82 +*  RETURNS
  198.83 +*
  198.84 +*  The routine glp_get_obj_dir returns the optimization direction flag
  198.85 +*  (i.e. "sense" of the objective function):
  198.86 +*
  198.87 +*  GLP_MIN - minimization;
  198.88 +*  GLP_MAX - maximization. */
  198.89 +
  198.90 +int glp_get_obj_dir(glp_prob *lp)
  198.91 +{     int dir = lp->dir;
  198.92 +      return dir;
  198.93 +}
  198.94 +
  198.95 +/***********************************************************************
  198.96 +*  NAME
  198.97 +*
  198.98 +*  glp_get_num_rows - retrieve number of rows
  198.99 +*
 198.100 +*  SYNOPSIS
 198.101 +*
 198.102 +*  int glp_get_num_rows(glp_prob *lp);
 198.103 +*
 198.104 +*  RETURNS
 198.105 +*
 198.106 +*  The routine glp_get_num_rows returns the current number of rows in
 198.107 +*  the specified problem object. */
 198.108 +
 198.109 +int glp_get_num_rows(glp_prob *lp)
 198.110 +{     int m = lp->m;
 198.111 +      return m;
 198.112 +}
 198.113 +
 198.114 +/***********************************************************************
 198.115 +*  NAME
 198.116 +*
 198.117 +*  glp_get_num_cols - retrieve number of columns
 198.118 +*
 198.119 +*  SYNOPSIS
 198.120 +*
 198.121 +*  int glp_get_num_cols(glp_prob *lp);
 198.122 +*
 198.123 +*  RETURNS
 198.124 +*
 198.125 +*  The routine glp_get_num_cols returns the current number of columns
 198.126 +*  in the specified problem object. */
 198.127 +
 198.128 +int glp_get_num_cols(glp_prob *lp)
 198.129 +{     int n = lp->n;
 198.130 +      return n;
 198.131 +}
 198.132 +
 198.133 +/***********************************************************************
 198.134 +*  NAME
 198.135 +*
 198.136 +*  glp_get_row_name - retrieve row name
 198.137 +*
 198.138 +*  SYNOPSIS
 198.139 +*
 198.140 +*  const char *glp_get_row_name(glp_prob *lp, int i);
 198.141 +*
 198.142 +*  RETURNS
 198.143 +*
 198.144 +*  The routine glp_get_row_name returns a pointer to an internal
 198.145 +*  buffer, which contains symbolic name of i-th row. However, if i-th
 198.146 +*  row has no assigned name, the routine returns NULL. */
 198.147 +
 198.148 +const char *glp_get_row_name(glp_prob *lp, int i)
 198.149 +{     char *name;
 198.150 +      if (!(1 <= i && i <= lp->m))
 198.151 +         xerror("glp_get_row_name: i = %d; row number out of range\n",
 198.152 +            i);
 198.153 +      name = lp->row[i]->name;
 198.154 +      return name;
 198.155 +}
 198.156 +
 198.157 +/***********************************************************************
 198.158 +*  NAME
 198.159 +*
 198.160 +*  glp_get_col_name - retrieve column name
 198.161 +*
 198.162 +*  SYNOPSIS
 198.163 +*
 198.164 +*  const char *glp_get_col_name(glp_prob *lp, int j);
 198.165 +*
 198.166 +*  RETURNS
 198.167 +*
 198.168 +*  The routine glp_get_col_name returns a pointer to an internal
 198.169 +*  buffer, which contains symbolic name of j-th column. However, if j-th
 198.170 +*  column has no assigned name, the routine returns NULL. */
 198.171 +
 198.172 +const char *glp_get_col_name(glp_prob *lp, int j)
 198.173 +{     char *name;
 198.174 +      if (!(1 <= j && j <= lp->n))
 198.175 +         xerror("glp_get_col_name: j = %d; column number out of range\n"
 198.176 +            , j);
 198.177 +      name = lp->col[j]->name;
 198.178 +      return name;
 198.179 +}
 198.180 +
 198.181 +/***********************************************************************
 198.182 +*  NAME
 198.183 +*
 198.184 +*  glp_get_row_type - retrieve row type
 198.185 +*
 198.186 +*  SYNOPSIS
 198.187 +*
 198.188 +*  int glp_get_row_type(glp_prob *lp, int i);
 198.189 +*
 198.190 +*  RETURNS
 198.191 +*
 198.192 +*  The routine glp_get_row_type returns the type of i-th row, i.e. the
 198.193 +*  type of corresponding auxiliary variable, as follows:
 198.194 +*
 198.195 +*  GLP_FR - free (unbounded) variable;
 198.196 +*  GLP_LO - variable with lower bound;
 198.197 +*  GLP_UP - variable with upper bound;
 198.198 +*  GLP_DB - double-bounded variable;
 198.199 +*  GLP_FX - fixed variable. */
 198.200 +
 198.201 +int glp_get_row_type(glp_prob *lp, int i)
 198.202 +{     if (!(1 <= i && i <= lp->m))
 198.203 +         xerror("glp_get_row_type: i = %d; row number out of range\n",
 198.204 +            i);
 198.205 +      return lp->row[i]->type;
 198.206 +}
 198.207 +
 198.208 +/***********************************************************************
 198.209 +*  NAME
 198.210 +*
 198.211 +*  glp_get_row_lb - retrieve row lower bound
 198.212 +*
 198.213 +*  SYNOPSIS
 198.214 +*
 198.215 +*  double glp_get_row_lb(glp_prob *lp, int i);
 198.216 +*
 198.217 +*  RETURNS
 198.218 +*
 198.219 +*  The routine glp_get_row_lb returns the lower bound of i-th row, i.e.
 198.220 +*  the lower bound of corresponding auxiliary variable. However, if the
 198.221 +*  row has no lower bound, the routine returns -DBL_MAX. */
 198.222 +
 198.223 +double glp_get_row_lb(glp_prob *lp, int i)
 198.224 +{     double lb;
 198.225 +      if (!(1 <= i && i <= lp->m))
 198.226 +         xerror("glp_get_row_lb: i = %d; row number out of range\n", i);
 198.227 +      switch (lp->row[i]->type)
 198.228 +      {  case GLP_FR:
 198.229 +         case GLP_UP:
 198.230 +            lb = -DBL_MAX; break;
 198.231 +         case GLP_LO:
 198.232 +         case GLP_DB:
 198.233 +         case GLP_FX:
 198.234 +            lb = lp->row[i]->lb; break;
 198.235 +         default:
 198.236 +            xassert(lp != lp);
 198.237 +      }
 198.238 +      return lb;
 198.239 +}
 198.240 +
 198.241 +/***********************************************************************
 198.242 +*  NAME
 198.243 +*
 198.244 +*  glp_get_row_ub - retrieve row upper bound
 198.245 +*
 198.246 +*  SYNOPSIS
 198.247 +*
 198.248 +*  double glp_get_row_ub(glp_prob *lp, int i);
 198.249 +*
 198.250 +*  RETURNS
 198.251 +*
 198.252 +*  The routine glp_get_row_ub returns the upper bound of i-th row, i.e.
 198.253 +*  the upper bound of corresponding auxiliary variable. However, if the
 198.254 +*  row has no upper bound, the routine returns +DBL_MAX. */
 198.255 +
 198.256 +double glp_get_row_ub(glp_prob *lp, int i)
 198.257 +{     double ub;
 198.258 +      if (!(1 <= i && i <= lp->m))
 198.259 +         xerror("glp_get_row_ub: i = %d; row number out of range\n", i);
 198.260 +      switch (lp->row[i]->type)
 198.261 +      {  case GLP_FR:
 198.262 +         case GLP_LO:
 198.263 +            ub = +DBL_MAX; break;
 198.264 +         case GLP_UP:
 198.265 +         case GLP_DB:
 198.266 +         case GLP_FX:
 198.267 +            ub = lp->row[i]->ub; break;
 198.268 +         default:
 198.269 +            xassert(lp != lp);
 198.270 +      }
 198.271 +      return ub;
 198.272 +}
 198.273 +
 198.274 +/***********************************************************************
 198.275 +*  NAME
 198.276 +*
 198.277 +*  glp_get_col_type - retrieve column type
 198.278 +*
 198.279 +*  SYNOPSIS
 198.280 +*
 198.281 +*  int glp_get_col_type(glp_prob *lp, int j);
 198.282 +*
 198.283 +*  RETURNS
 198.284 +*
 198.285 +*  The routine glp_get_col_type returns the type of j-th column, i.e.
 198.286 +*  the type of corresponding structural variable, as follows:
 198.287 +*
 198.288 +*  GLP_FR - free (unbounded) variable;
 198.289 +*  GLP_LO - variable with lower bound;
 198.290 +*  GLP_UP - variable with upper bound;
 198.291 +*  GLP_DB - double-bounded variable;
 198.292 +*  GLP_FX - fixed variable. */
 198.293 +
 198.294 +int glp_get_col_type(glp_prob *lp, int j)
 198.295 +{     if (!(1 <= j && j <= lp->n))
 198.296 +         xerror("glp_get_col_type: j = %d; column number out of range\n"
 198.297 +            , j);
 198.298 +      return lp->col[j]->type;
 198.299 +}
 198.300 +
 198.301 +/***********************************************************************
 198.302 +*  NAME
 198.303 +*
 198.304 +*  glp_get_col_lb - retrieve column lower bound
 198.305 +*
 198.306 +*  SYNOPSIS
 198.307 +*
 198.308 +*  double glp_get_col_lb(glp_prob *lp, int j);
 198.309 +*
 198.310 +*  RETURNS
 198.311 +*
 198.312 +*  The routine glp_get_col_lb returns the lower bound of j-th column,
 198.313 +*  i.e. the lower bound of corresponding structural variable. However,
 198.314 +*  if the column has no lower bound, the routine returns -DBL_MAX. */
 198.315 +
 198.316 +double glp_get_col_lb(glp_prob *lp, int j)
 198.317 +{     double lb;
 198.318 +      if (!(1 <= j && j <= lp->n))
 198.319 +         xerror("glp_get_col_lb: j = %d; column number out of range\n",
 198.320 +            j);
 198.321 +      switch (lp->col[j]->type)
 198.322 +      {  case GLP_FR:
 198.323 +         case GLP_UP:
 198.324 +            lb = -DBL_MAX; break;
 198.325 +         case GLP_LO:
 198.326 +         case GLP_DB:
 198.327 +         case GLP_FX:
 198.328 +            lb = lp->col[j]->lb; break;
 198.329 +         default:
 198.330 +            xassert(lp != lp);
 198.331 +      }
 198.332 +      return lb;
 198.333 +}
 198.334 +
 198.335 +/***********************************************************************
 198.336 +*  NAME
 198.337 +*
 198.338 +*  glp_get_col_ub - retrieve column upper bound
 198.339 +*
 198.340 +*  SYNOPSIS
 198.341 +*
 198.342 +*  double glp_get_col_ub(glp_prob *lp, int j);
 198.343 +*
 198.344 +*  RETURNS
 198.345 +*
 198.346 +*  The routine glp_get_col_ub returns the upper bound of j-th column,
 198.347 +*  i.e. the upper bound of corresponding structural variable. However,
 198.348 +*  if the column has no upper bound, the routine returns +DBL_MAX. */
 198.349 +
 198.350 +double glp_get_col_ub(glp_prob *lp, int j)
 198.351 +{     double ub;
 198.352 +      if (!(1 <= j && j <= lp->n))
 198.353 +         xerror("glp_get_col_ub: j = %d; column number out of range\n",
 198.354 +            j);
 198.355 +      switch (lp->col[j]->type)
 198.356 +      {  case GLP_FR:
 198.357 +         case GLP_LO:
 198.358 +            ub = +DBL_MAX; break;
 198.359 +         case GLP_UP:
 198.360 +         case GLP_DB:
 198.361 +         case GLP_FX:
 198.362 +            ub = lp->col[j]->ub; break;
 198.363 +         default:
 198.364 +            xassert(lp != lp);
 198.365 +      }
 198.366 +      return ub;
 198.367 +}
 198.368 +
 198.369 +/***********************************************************************
 198.370 +*  NAME
 198.371 +*
 198.372 +*  glp_get_obj_coef - retrieve obj. coefficient or constant term
 198.373 +*
 198.374 +*  SYNOPSIS
 198.375 +*
 198.376 +*  double glp_get_obj_coef(glp_prob *lp, int j);
 198.377 +*
 198.378 +*  RETURNS
 198.379 +*
 198.380 +*  The routine glp_get_obj_coef returns the objective coefficient at
 198.381 +*  j-th structural variable (column) of the specified problem object.
 198.382 +*
 198.383 +*  If the parameter j is zero, the routine returns the constant term
 198.384 +*  ("shift") of the objective function. */
 198.385 +
 198.386 +double glp_get_obj_coef(glp_prob *lp, int j)
 198.387 +{     if (!(0 <= j && j <= lp->n))
 198.388 +         xerror("glp_get_obj_coef: j = %d; column number out of range\n"
 198.389 +            , j);
 198.390 +      return j == 0 ? lp->c0 : lp->col[j]->coef;
 198.391 +}
 198.392 +
 198.393 +/***********************************************************************
 198.394 +*  NAME
 198.395 +*
 198.396 +*  glp_get_num_nz - retrieve number of constraint coefficients
 198.397 +*
 198.398 +*  SYNOPSIS
 198.399 +*
 198.400 +*  int glp_get_num_nz(glp_prob *lp);
 198.401 +*
 198.402 +*  RETURNS
 198.403 +*
 198.404 +*  The routine glp_get_num_nz returns the number of (non-zero) elements
 198.405 +*  in the constraint matrix of the specified problem object. */
 198.406 +
 198.407 +int glp_get_num_nz(glp_prob *lp)
 198.408 +{     int nnz = lp->nnz;
 198.409 +      return nnz;
 198.410 +}
 198.411 +
 198.412 +/***********************************************************************
 198.413 +*  NAME
 198.414 +*
 198.415 +*  glp_get_mat_row - retrieve row of the constraint matrix
 198.416 +*
 198.417 +*  SYNOPSIS
 198.418 +*
 198.419 +*  int glp_get_mat_row(glp_prob *lp, int i, int ind[], double val[]);
 198.420 +*
 198.421 +*  DESCRIPTION
 198.422 +*
 198.423 +*  The routine glp_get_mat_row scans (non-zero) elements of i-th row
 198.424 +*  of the constraint matrix of the specified problem object and stores
 198.425 +*  their column indices and numeric values to locations ind[1], ...,
 198.426 +*  ind[len] and val[1], ..., val[len], respectively, where 0 <= len <= n
 198.427 +*  is the number of elements in i-th row, n is the number of columns.
 198.428 +*
 198.429 +*  The parameter ind and/or val can be specified as NULL, in which case
 198.430 +*  corresponding information is not stored.
 198.431 +*
 198.432 +*  RETURNS
 198.433 +*
 198.434 +*  The routine glp_get_mat_row returns the length len, i.e. the number
 198.435 +*  of (non-zero) elements in i-th row. */
 198.436 +
 198.437 +int glp_get_mat_row(glp_prob *lp, int i, int ind[], double val[])
 198.438 +{     GLPAIJ *aij;
 198.439 +      int len;
 198.440 +      if (!(1 <= i && i <= lp->m))
 198.441 +         xerror("glp_get_mat_row: i = %d; row number out of range\n",
 198.442 +            i);
 198.443 +      len = 0;
 198.444 +      for (aij = lp->row[i]->ptr; aij != NULL; aij = aij->r_next)
 198.445 +      {  len++;
 198.446 +         if (ind != NULL) ind[len] = aij->col->j;
 198.447 +         if (val != NULL) val[len] = aij->val;
 198.448 +      }
 198.449 +      xassert(len <= lp->n);
 198.450 +      return len;
 198.451 +}
 198.452 +
 198.453 +/***********************************************************************
 198.454 +*  NAME
 198.455 +*
 198.456 +*  glp_get_mat_col - retrieve column of the constraint matrix
 198.457 +*
 198.458 +*  SYNOPSIS
 198.459 +*
 198.460 +*  int glp_get_mat_col(glp_prob *lp, int j, int ind[], double val[]);
 198.461 +*
 198.462 +*  DESCRIPTION
 198.463 +*
 198.464 +*  The routine glp_get_mat_col scans (non-zero) elements of j-th column
 198.465 +*  of the constraint matrix of the specified problem object and stores
 198.466 +*  their row indices and numeric values to locations ind[1], ...,
 198.467 +*  ind[len] and val[1], ..., val[len], respectively, where 0 <= len <= m
 198.468 +*  is the number of elements in j-th column, m is the number of rows.
 198.469 +*
 198.470 +*  The parameter ind or/and val can be specified as NULL, in which case
 198.471 +*  corresponding information is not stored.
 198.472 +*
 198.473 +*  RETURNS
 198.474 +*
 198.475 +*  The routine glp_get_mat_col returns the length len, i.e. the number
 198.476 +*  of (non-zero) elements in j-th column. */
 198.477 +
 198.478 +int glp_get_mat_col(glp_prob *lp, int j, int ind[], double val[])
 198.479 +{     GLPAIJ *aij;
 198.480 +      int len;
 198.481 +      if (!(1 <= j && j <= lp->n))
 198.482 +         xerror("glp_get_mat_col: j = %d; column number out of range\n",
 198.483 +            j);
 198.484 +      len = 0;
 198.485 +      for (aij = lp->col[j]->ptr; aij != NULL; aij = aij->c_next)
 198.486 +      {  len++;
 198.487 +         if (ind != NULL) ind[len] = aij->row->i;
 198.488 +         if (val != NULL) val[len] = aij->val;
 198.489 +      }
 198.490 +      xassert(len <= lp->m);
 198.491 +      return len;
 198.492 +}
 198.493 +
 198.494 +/* eof */
   199.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
   199.2 +++ b/deps/glpk/src/glpapi03.c	Sun Nov 06 20:59:10 2011 +0100
   199.3 @@ -0,0 +1,166 @@
   199.4 +/* glpapi03.c (row and column searching routines) */
   199.5 +
   199.6 +/***********************************************************************
   199.7 +*  This code is part of GLPK (GNU Linear Programming Kit).
   199.8 +*
   199.9 +*  Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008,
  199.10 +*  2009, 2010, 2011 Andrew Makhorin, Department for Applied Informatics,
  199.11 +*  Moscow Aviation Institute, Moscow, Russia. All rights reserved.
  199.12 +*  E-mail: <mao@gnu.org>.
  199.13 +*
  199.14 +*  GLPK is free software: you can redistribute it and/or modify it
  199.15 +*  under the terms of the GNU General Public License as published by
  199.16 +*  the Free Software Foundation, either version 3 of the License, or
  199.17 +*  (at your option) any later version.
  199.18 +*
  199.19 +*  GLPK is distributed in the hope that it will be useful, but WITHOUT
  199.20 +*  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
  199.21 +*  or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
  199.22 +*  License for more details.
  199.23 +*
  199.24 +*  You should have received a copy of the GNU General Public License
  199.25 +*  along with GLPK. If not, see <http://www.gnu.org/licenses/>.
  199.26 +***********************************************************************/
  199.27 +
  199.28 +#include "glpapi.h"
  199.29 +
  199.30 +/***********************************************************************
  199.31 +*  NAME
  199.32 +*
  199.33 +*  glp_create_index - create the name index
  199.34 +*
  199.35 +*  SYNOPSIS
  199.36 +*
  199.37 +*  void glp_create_index(glp_prob *lp);
  199.38 +*
  199.39 +*  DESCRIPTION
  199.40 +*
  199.41 +*  The routine glp_create_index creates the name index for the
  199.42 +*  specified problem object. The name index is an auxiliary data
  199.43 +*  structure, which is intended to quickly (i.e. for logarithmic time)
  199.44 +*  find rows and columns by their names.
  199.45 +*
  199.46 +*  This routine can be called at any time. If the name index already
  199.47 +*  exists, the routine does nothing. */
  199.48 +
  199.49 +void glp_create_index(glp_prob *lp)
  199.50 +{     GLPROW *row;
  199.51 +      GLPCOL *col;
  199.52 +      int i, j;
  199.53 +      /* create row name index */
  199.54 +      if (lp->r_tree == NULL)
  199.55 +      {  lp->r_tree = avl_create_tree(avl_strcmp, NULL);
  199.56 +         for (i = 1; i <= lp->m; i++)
  199.57 +         {  row = lp->row[i];
  199.58 +            xassert(row->node == NULL);
  199.59 +            if (row->name != NULL)
  199.60 +            {  row->node = avl_insert_node(lp->r_tree, row->name);
  199.61 +               avl_set_node_link(row->node, row);
  199.62 +            }
  199.63 +         }
  199.64 +      }
  199.65 +      /* create column name index */
  199.66 +      if (lp->c_tree == NULL)
  199.67 +      {  lp->c_tree = avl_create_tree(avl_strcmp, NULL);
  199.68 +         for (j = 1; j <= lp->n; j++)
  199.69 +         {  col = lp->col[j];
  199.70 +            xassert(col->node == NULL);
  199.71 +            if (col->name != NULL)
  199.72 +            {  col->node = avl_insert_node(lp->c_tree, col->name);
  199.73 +               avl_set_node_link(col->node, col);
  199.74 +            }
  199.75 +         }
  199.76 +      }
  199.77 +      return;
  199.78 +}
  199.79 +
  199.80 +/***********************************************************************
  199.81 +*  NAME
  199.82 +*
  199.83 +*  glp_find_row - find row by its name
  199.84 +*
  199.85 +*  SYNOPSIS
  199.86 +*
  199.87 +*  int glp_find_row(glp_prob *lp, const char *name);
  199.88 +*
  199.89 +*  RETURNS
  199.90 +*
  199.91 +*  The routine glp_find_row returns the ordinal number of a row,
  199.92 +*  which is assigned (by the routine glp_set_row_name) the specified
  199.93 +*  symbolic name. If no such row exists, the routine returns 0. */
  199.94 +
  199.95 +int glp_find_row(glp_prob *lp, const char *name)
  199.96 +{     AVLNODE *node;
  199.97 +      int i = 0;
  199.98 +      if (lp->r_tree == NULL)
  199.99 +         xerror("glp_find_row: row name index does not exist\n");
 199.100 +      if (!(name == NULL || name[0] == '\0' || strlen(name) > 255))
 199.101 +      {  node = avl_find_node(lp->r_tree, name);
 199.102 +         if (node != NULL)
 199.103 +            i = ((GLPROW *)avl_get_node_link(node))->i;
 199.104 +      }
 199.105 +      return i;
 199.106 +}
 199.107 +
 199.108 +/***********************************************************************
 199.109 +*  NAME
 199.110 +*
 199.111 +*  glp_find_col - find column by its name
 199.112 +*
 199.113 +*  SYNOPSIS
 199.114 +*
 199.115 +*  int glp_find_col(glp_prob *lp, const char *name);
 199.116 +*
 199.117 +*  RETURNS
 199.118 +*
 199.119 +*  The routine glp_find_col returns the ordinal number of a column,
 199.120 +*  which is assigned (by the routine glp_set_col_name) the specified
 199.121 +*  symbolic name. If no such column exists, the routine returns 0. */
 199.122 +
 199.123 +int glp_find_col(glp_prob *lp, const char *name)
 199.124 +{     AVLNODE *node;
 199.125 +      int j = 0;
 199.126 +      if (lp->c_tree == NULL)
 199.127 +         xerror("glp_find_col: column name index does not exist\n");
 199.128 +      if (!(name == NULL || name[0] == '\0' || strlen(name) > 255))
 199.129 +      {  node = avl_find_node(lp->c_tree, name);
 199.130 +         if (node != NULL)
 199.131 +            j = ((GLPCOL *)avl_get_node_link(node))->j;
 199.132 +      }
 199.133 +      return j;
 199.134 +}
 199.135 +
 199.136 +/***********************************************************************
 199.137 +*  NAME
 199.138 +*
 199.139 +*  glp_delete_index - delete the name index
 199.140 +*
 199.141 +*  SYNOPSIS
 199.142 +*
 199.143 +*  void glp_delete_index(glp_prob *lp);
 199.144 +*
 199.145 +*  DESCRIPTION
 199.146 +*
 199.147 +*  The routine glp_delete_index deletes the name index previously
 199.148 +*  created by the routine glp_create_index and frees the memory
 199.149 +*  allocated to this auxiliary data structure.
 199.150 +*
 199.151 +*  This routine can be called at any time. If the name index does not
 199.152 +*  exist, the routine does nothing. */
 199.153 +
 199.154 +void glp_delete_index(glp_prob *lp)
 199.155 +{     int i, j;
 199.156 +      /* delete row name index */
 199.157 +      if (lp->r_tree != NULL)
 199.158 +      {  for (i = 1; i <= lp->m; i++) lp->row[i]->node = NULL;
 199.159 +         avl_delete_tree(lp->r_tree), lp->r_tree = NULL;
 199.160 +      }
 199.161 +      /* delete column name index */
 199.162 +      if (lp->c_tree != NULL)
 199.163 +      {  for (j = 1; j <= lp->n; j++) lp->col[j]->node = NULL;
 199.164 +         avl_delete_tree(lp->c_tree), lp->c_tree = NULL;
 199.165 +      }
 199.166 +      return;
 199.167 +}
 199.168 +
 199.169 +/* eof */
   200.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
   200.2 +++ b/deps/glpk/src/glpapi04.c	Sun Nov 06 20:59:10 2011 +0100
   200.3 @@ -0,0 +1,156 @@
   200.4 +/* glpapi04.c (problem scaling routines) */
   200.5 +
   200.6 +/***********************************************************************
   200.7 +*  This code is part of GLPK (GNU Linear Programming Kit).
   200.8 +*
   200.9 +*  Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008,
  200.10 +*  2009, 2010, 2011 Andrew Makhorin, Department for Applied Informatics,
  200.11 +*  Moscow Aviation Institute, Moscow, Russia. All rights reserved.
  200.12 +*  E-mail: <mao@gnu.org>.
  200.13 +*
  200.14 +*  GLPK is free software: you can redistribute it and/or modify it
  200.15 +*  under the terms of the GNU General Public License as published by
  200.16 +*  the Free Software Foundation, either version 3 of the License, or
  200.17 +*  (at your option) any later version.
  200.18 +*
  200.19 +*  GLPK is distributed in the hope that it will be useful, but WITHOUT
  200.20 +*  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
  200.21 +*  or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
  200.22 +*  License for more details.
  200.23 +*
  200.24 +*  You should have received a copy of the GNU General Public License
  200.25 +*  along with GLPK. If not, see <http://www.gnu.org/licenses/>.
  200.26 +***********************************************************************/
  200.27 +
  200.28 +#include "glpapi.h"
  200.29 +
  200.30 +/***********************************************************************
  200.31 +*  NAME
  200.32 +*
  200.33 +*  glp_set_rii - set (change) row scale factor
  200.34 +*
  200.35 +*  SYNOPSIS
  200.36 +*
  200.37 +*  void glp_set_rii(glp_prob *lp, int i, double rii);
  200.38 +*
  200.39 +*  DESCRIPTION
  200.40 +*
  200.41 +*  The routine glp_set_rii sets (changes) the scale factor r[i,i] for
  200.42 +*  i-th row of the specified problem object. */
  200.43 +
  200.44 +void glp_set_rii(glp_prob *lp, int i, double rii)
  200.45 +{     if (!(1 <= i && i <= lp->m))
  200.46 +         xerror("glp_set_rii: i = %d; row number out of range\n", i);
  200.47 +      if (rii <= 0.0)
  200.48 +         xerror("glp_set_rii: i = %d; rii = %g; invalid scale factor\n",
  200.49 +            i, rii);
  200.50 +      if (lp->valid && lp->row[i]->rii != rii)
  200.51 +      {  GLPAIJ *aij;
  200.52 +         for (aij = lp->row[i]->ptr; aij != NULL; aij = aij->r_next)
  200.53 +         {  if (aij->col->stat == GLP_BS)
  200.54 +            {  /* invalidate the basis factorization */
  200.55 +               lp->valid = 0;
  200.56 +               break;
  200.57 +            }
  200.58 +         }
  200.59 +      }
  200.60 +      lp->row[i]->rii = rii;
  200.61 +      return;
  200.62 +}
  200.63 +
  200.64 +/***********************************************************************
  200.65 +*  NAME
  200.66 +*
  200.67 +*  glp_set sjj - set (change) column scale factor
  200.68 +*
  200.69 +*  SYNOPSIS
  200.70 +*
  200.71 +*  void glp_set_sjj(glp_prob *lp, int j, double sjj);
  200.72 +*
  200.73 +*  DESCRIPTION
  200.74 +*
  200.75 +*  The routine glp_set_sjj sets (changes) the scale factor s[j,j] for
  200.76 +*  j-th column of the specified problem object. */
  200.77 +
  200.78 +void glp_set_sjj(glp_prob *lp, int j, double sjj)
  200.79 +{     if (!(1 <= j && j <= lp->n))
  200.80 +         xerror("glp_set_sjj: j = %d; column number out of range\n", j);
  200.81 +      if (sjj <= 0.0)
  200.82 +         xerror("glp_set_sjj: j = %d; sjj = %g; invalid scale factor\n",
  200.83 +            j, sjj);
  200.84 +      if (lp->valid && lp->col[j]->sjj != sjj && lp->col[j]->stat ==
  200.85 +         GLP_BS)
  200.86 +      {  /* invalidate the basis factorization */
  200.87 +         lp->valid = 0;
  200.88 +      }
  200.89 +      lp->col[j]->sjj = sjj;
  200.90 +      return;
  200.91 +}
  200.92 +
  200.93 +/***********************************************************************
  200.94 +*  NAME
  200.95 +*
  200.96 +*  glp_get_rii - retrieve row scale factor
  200.97 +*
  200.98 +*  SYNOPSIS
  200.99 +*
 200.100 +*  double glp_get_rii(glp_prob *lp, int i);
 200.101 +*
 200.102 +*  RETURNS
 200.103 +*
 200.104 +*  The routine glp_get_rii returns current scale factor r[i,i] for i-th
 200.105 +*  row of the specified problem object. */
 200.106 +
 200.107 +double glp_get_rii(glp_prob *lp, int i)
 200.108 +{     if (!(1 <= i && i <= lp->m))
 200.109 +         xerror("glp_get_rii: i = %d; row number out of range\n", i);
 200.110 +      return lp->row[i]->rii;
 200.111 +}
 200.112 +
 200.113 +/***********************************************************************
 200.114 +*  NAME
 200.115 +*
 200.116 +*  glp_get_sjj - retrieve column scale factor
 200.117 +*
 200.118 +*  SYNOPSIS
 200.119 +*
 200.120 +*  double glp_get_sjj(glp_prob *lp, int j);
 200.121 +*
 200.122 +*  RETURNS
 200.123 +*
 200.124 +*  The routine glp_get_sjj returns current scale factor s[j,j] for j-th
 200.125 +*  column of the specified problem object. */
 200.126 +
 200.127 +double glp_get_sjj(glp_prob *lp, int j)
 200.128 +{     if (!(1 <= j && j <= lp->n))
 200.129 +         xerror("glp_get_sjj: j = %d; column number out of range\n", j);
 200.130 +      return lp->col[j]->sjj;
 200.131 +}
 200.132 +
 200.133 +/***********************************************************************
 200.134 +*  NAME
 200.135 +*
 200.136 +*  glp_unscale_prob - unscale problem data
 200.137 +*
 200.138 +*  SYNOPSIS
 200.139 +*
 200.140 +*  void glp_unscale_prob(glp_prob *lp);
 200.141 +*
 200.142 +*  DESCRIPTION
 200.143 +*
 200.144 +*  The routine glp_unscale_prob performs unscaling of problem data for
 200.145 +*  the specified problem object.
 200.146 +*
 200.147 +*  "Unscaling" means replacing the current scaling matrices R and S by
 200.148 +*  unity matrices that cancels the scaling effect. */
 200.149 +
 200.150 +void glp_unscale_prob(glp_prob *lp)
 200.151 +{     int m = glp_get_num_rows(lp);
 200.152 +      int n = glp_get_num_cols(lp);
 200.153 +      int i, j;
 200.154 +      for (i = 1; i <= m; i++) glp_set_rii(lp, i, 1.0);
 200.155 +      for (j = 1; j <= n; j++) glp_set_sjj(lp, j, 1.0);
 200.156 +      return;
 200.157 +}
 200.158 +
 200.159 +/* eof */
   201.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
   201.2 +++ b/deps/glpk/src/glpapi05.c	Sun Nov 06 20:59:10 2011 +0100
   201.3 @@ -0,0 +1,168 @@
   201.4 +/* glpapi05.c (LP basis constructing routines) */
   201.5 +
   201.6 +/***********************************************************************
   201.7 +*  This code is part of GLPK (GNU Linear Programming Kit).
   201.8 +*
   201.9 +*  Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008,
  201.10 +*  2009, 2010, 2011 Andrew Makhorin, Department for Applied Informatics,
  201.11 +*  Moscow Aviation Institute, Moscow, Russia. All rights reserved.
  201.12 +*  E-mail: <mao@gnu.org>.
  201.13 +*
  201.14 +*  GLPK is free software: you can redistribute it and/or modify it
  201.15 +*  under the terms of the GNU General Public License as published by
  201.16 +*  the Free Software Foundation, either version 3 of the License, or
  201.17 +*  (at your option) any later version.
  201.18 +*
  201.19 +*  GLPK is distributed in the hope that it will be useful, but WITHOUT
  201.20 +*  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
  201.21 +*  or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
  201.22 +*  License for more details.
  201.23 +*
  201.24 +*  You should have received a copy of the GNU General Public License
  201.25 +*  along with GLPK. If not, see <http://www.gnu.org/licenses/>.
  201.26 +***********************************************************************/
  201.27 +
  201.28 +#include "glpapi.h"
  201.29 +
  201.30 +/***********************************************************************
  201.31 +*  NAME
  201.32 +*
  201.33 +*  glp_set_row_stat - set (change) row status
  201.34 +*
  201.35 +*  SYNOPSIS
  201.36 +*
  201.37 +*  void glp_set_row_stat(glp_prob *lp, int i, int stat);
  201.38 +*
  201.39 +*  DESCRIPTION
  201.40 +*
  201.41 +*  The routine glp_set_row_stat sets (changes) status of the auxiliary
  201.42 +*  variable associated with i-th row.
  201.43 +*
  201.44 +*  The new status of the auxiliary variable should be specified by the
  201.45 +*  parameter stat as follows:
  201.46 +*
  201.47 +*  GLP_BS - basic variable;
  201.48 +*  GLP_NL - non-basic variable;
  201.49 +*  GLP_NU - non-basic variable on its upper bound; if the variable is
  201.50 +*           not double-bounded, this means the same as GLP_NL (only in
  201.51 +*           case of this routine);
  201.52 +*  GLP_NF - the same as GLP_NL (only in case of this routine);
  201.53 +*  GLP_NS - the same as GLP_NL (only in case of this routine). */
  201.54 +
  201.55 +void glp_set_row_stat(glp_prob *lp, int i, int stat)
  201.56 +{     GLPROW *row;
  201.57 +      if (!(1 <= i && i <= lp->m))
  201.58 +         xerror("glp_set_row_stat: i = %d; row number out of range\n",
  201.59 +            i);
  201.60 +      if (!(stat == GLP_BS || stat == GLP_NL || stat == GLP_NU ||
  201.61 +            stat == GLP_NF || stat == GLP_NS))
  201.62 +         xerror("glp_set_row_stat: i = %d; stat = %d; invalid status\n",
  201.63 +            i, stat);
  201.64 +      row = lp->row[i];
  201.65 +      if (stat != GLP_BS)
  201.66 +      {  switch (row->type)
  201.67 +         {  case GLP_FR: stat = GLP_NF; break;
  201.68 +            case GLP_LO: stat = GLP_NL; break;
  201.69 +            case GLP_UP: stat = GLP_NU; break;
  201.70 +            case GLP_DB: if (stat != GLP_NU) stat = GLP_NL; break;
  201.71 +            case GLP_FX: stat = GLP_NS; break;
  201.72 +            default: xassert(row != row);
  201.73 +         }
  201.74 +      }
  201.75 +      if (row->stat == GLP_BS && stat != GLP_BS ||
  201.76 +          row->stat != GLP_BS && stat == GLP_BS)
  201.77 +      {  /* invalidate the basis factorization */
  201.78 +         lp->valid = 0;
  201.79 +      }
  201.80 +      row->stat = stat;
  201.81 +      return;
  201.82 +}
  201.83 +
  201.84 +/***********************************************************************
  201.85 +*  NAME
  201.86 +*
  201.87 +*  glp_set_col_stat - set (change) column status
  201.88 +*
  201.89 +*  SYNOPSIS
  201.90 +*
  201.91 +*  void glp_set_col_stat(glp_prob *lp, int j, int stat);
  201.92 +*
  201.93 +*  DESCRIPTION
  201.94 +*
  201.95 +*  The routine glp_set_col_stat sets (changes) status of the structural
  201.96 +*  variable associated with j-th column.
  201.97 +*
  201.98 +*  The new status of the structural variable should be specified by the
  201.99 +*  parameter stat as follows:
 201.100 +*
 201.101 +*  GLP_BS - basic variable;
 201.102 +*  GLP_NL - non-basic variable;
 201.103 +*  GLP_NU - non-basic variable on its upper bound; if the variable is
 201.104 +*           not double-bounded, this means the same as GLP_NL (only in
 201.105 +*           case of this routine);
 201.106 +*  GLP_NF - the same as GLP_NL (only in case of this routine);
 201.107 +*  GLP_NS - the same as GLP_NL (only in case of this routine). */
 201.108 +
 201.109 +void glp_set_col_stat(glp_prob *lp, int j, int stat)
 201.110 +{     GLPCOL *col;
 201.111 +      if (!(1 <= j && j <= lp->n))
 201.112 +         xerror("glp_set_col_stat: j = %d; column number out of range\n"
 201.113 +            , j);
 201.114 +      if (!(stat == GLP_BS || stat == GLP_NL || stat == GLP_NU ||
 201.115 +            stat == GLP_NF || stat == GLP_NS))
 201.116 +         xerror("glp_set_col_stat: j = %d; stat = %d; invalid status\n",
 201.117 +            j, stat);
 201.118 +      col = lp->col[j];
 201.119 +      if (stat != GLP_BS)
 201.120 +      {  switch (col->type)
 201.121 +         {  case GLP_FR: stat = GLP_NF; break;
 201.122 +            case GLP_LO: stat = GLP_NL; break;
 201.123 +            case GLP_UP: stat = GLP_NU; break;
 201.124 +            case GLP_DB: if (stat != GLP_NU) stat = GLP_NL; break;
 201.125 +            case GLP_FX: stat = GLP_NS; break;
 201.126 +            default: xassert(col != col);
 201.127 +         }
 201.128 +      }
 201.129 +      if (col->stat == GLP_BS && stat != GLP_BS ||
 201.130 +          col->stat != GLP_BS && stat == GLP_BS)
 201.131 +      {  /* invalidate the basis factorization */
 201.132 +         lp->valid = 0;
 201.133 +      }
 201.134 +      col->stat = stat;
 201.135 +      return;
 201.136 +}
 201.137 +
 201.138 +/***********************************************************************
 201.139 +*  NAME
 201.140 +*
 201.141 +*  glp_std_basis - construct standard initial LP basis
 201.142 +*
 201.143 +*  SYNOPSIS
 201.144 +*
 201.145 +*  void glp_std_basis(glp_prob *lp);
 201.146 +*
 201.147 +*  DESCRIPTION
 201.148 +*
 201.149 +*  The routine glp_std_basis builds the "standard" (trivial) initial
 201.150 +*  basis for the specified problem object.
 201.151 +*
 201.152 +*  In the "standard" basis all auxiliary variables are basic, and all
 201.153 +*  structural variables are non-basic. */
 201.154 +
 201.155 +void glp_std_basis(glp_prob *lp)
 201.156 +{     int i, j;
 201.157 +      /* make all auxiliary variables basic */
 201.158 +      for (i = 1; i <= lp->m; i++)
 201.159 +         glp_set_row_stat(lp, i, GLP_BS);
 201.160 +      /* make all structural variables non-basic */
 201.161 +      for (j = 1; j <= lp->n; j++)
 201.162 +      {  GLPCOL *col = lp->col[j];
 201.163 +         if (col->type == GLP_DB && fabs(col->lb) > fabs(col->ub))
 201.164 +            glp_set_col_stat(lp, j, GLP_NU);
 201.165 +         else
 201.166 +            glp_set_col_stat(lp, j, GLP_NL);
 201.167 +      }
 201.168 +      return;
 201.169 +}
 201.170 +
 201.171 +/* eof */
   202.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
   202.2 +++ b/deps/glpk/src/glpapi06.c	Sun Nov 06 20:59:10 2011 +0100
   202.3 @@ -0,0 +1,806 @@
   202.4 +/* glpapi06.c (simplex method routines) */
   202.5 +
   202.6 +/***********************************************************************
   202.7 +*  This code is part of GLPK (GNU Linear Programming Kit).
   202.8 +*
   202.9 +*  Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008,
  202.10 +*  2009, 2010, 2011 Andrew Makhorin, Department for Applied Informatics,
  202.11 +*  Moscow Aviation Institute, Moscow, Russia. All rights reserved.
  202.12 +*  E-mail: <mao@gnu.org>.
  202.13 +*
  202.14 +*  GLPK is free software: you can redistribute it and/or modify it
  202.15 +*  under the terms of the GNU General Public License as published by
  202.16 +*  the Free Software Foundation, either version 3 of the License, or
  202.17 +*  (at your option) any later version.
  202.18 +*
  202.19 +*  GLPK is distributed in the hope that it will be useful, but WITHOUT
  202.20 +*  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
  202.21 +*  or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
  202.22 +*  License for more details.
  202.23 +*
  202.24 +*  You should have received a copy of the GNU General Public License
  202.25 +*  along with GLPK. If not, see <http://www.gnu.org/licenses/>.
  202.26 +***********************************************************************/
  202.27 +
  202.28 +#include "glpios.h"
  202.29 +#include "glpnpp.h"
  202.30 +#include "glpspx.h"
  202.31 +
  202.32 +/***********************************************************************
  202.33 +*  NAME
  202.34 +*
  202.35 +*  glp_simplex - solve LP problem with the simplex method
  202.36 +*
  202.37 +*  SYNOPSIS
  202.38 +*
  202.39 +*  int glp_simplex(glp_prob *P, const glp_smcp *parm);
  202.40 +*
  202.41 +*  DESCRIPTION
  202.42 +*
  202.43 +*  The routine glp_simplex is a driver to the LP solver based on the
  202.44 +*  simplex method. This routine retrieves problem data from the
  202.45 +*  specified problem object, calls the solver to solve the problem
  202.46 +*  instance, and stores results of computations back into the problem
  202.47 +*  object.
  202.48 +*
  202.49 +*  The simplex solver has a set of control parameters. Values of the
  202.50 +*  control parameters can be passed in a structure glp_smcp, which the
  202.51 +*  parameter parm points to.
  202.52 +*
  202.53 +*  The parameter parm can be specified as NULL, in which case the LP
  202.54 +*  solver uses default settings.
  202.55 +*
  202.56 +*  RETURNS
  202.57 +*
  202.58 +*  0  The LP problem instance has been successfully solved. This code
  202.59 +*     does not necessarily mean that the solver has found optimal
  202.60 +*     solution. It only means that the solution process was successful.
  202.61 +*
  202.62 +*  GLP_EBADB
  202.63 +*     Unable to start the search, because the initial basis specified
  202.64 +*     in the problem object is invalid--the number of basic (auxiliary
  202.65 +*     and structural) variables is not the same as the number of rows in
  202.66 +*     the problem object.
  202.67 +*
  202.68 +*  GLP_ESING
  202.69 +*     Unable to start the search, because the basis matrix correspodning
  202.70 +*     to the initial basis is singular within the working precision.
  202.71 +*
  202.72 +*  GLP_ECOND
  202.73 +*     Unable to start the search, because the basis matrix correspodning
  202.74 +*     to the initial basis is ill-conditioned, i.e. its condition number
  202.75 +*     is too large.
  202.76 +*
  202.77 +*  GLP_EBOUND
  202.78 +*     Unable to start the search, because some double-bounded variables
  202.79 +*     have incorrect bounds.
  202.80 +*
  202.81 +*  GLP_EFAIL
  202.82 +*     The search was prematurely terminated due to the solver failure.
  202.83 +*
  202.84 +*  GLP_EOBJLL
  202.85 +*     The search was prematurely terminated, because the objective
  202.86 +*     function being maximized has reached its lower limit and continues
  202.87 +*     decreasing (dual simplex only).
  202.88 +*
  202.89 +*  GLP_EOBJUL
  202.90 +*     The search was prematurely terminated, because the objective
  202.91 +*     function being minimized has reached its upper limit and continues
  202.92 +*     increasing (dual simplex only).
  202.93 +*
  202.94 +*  GLP_EITLIM
  202.95 +*     The search was prematurely terminated, because the simplex
  202.96 +*     iteration limit has been exceeded.
  202.97 +*
  202.98 +*  GLP_ETMLIM
  202.99 +*     The search was prematurely terminated, because the time limit has
 202.100 +*     been exceeded.
 202.101 +*
 202.102 +*  GLP_ENOPFS
 202.103 +*     The LP problem instance has no primal feasible solution (only if
 202.104 +*     the LP presolver is used).
 202.105 +*
 202.106 +*  GLP_ENODFS
 202.107 +*     The LP problem instance has no dual feasible solution (only if the
 202.108 +*     LP presolver is used). */
 202.109 +
 202.110 +static void trivial_lp(glp_prob *P, const glp_smcp *parm)
 202.111 +{     /* solve trivial LP which has empty constraint matrix */
 202.112 +      GLPROW *row;
 202.113 +      GLPCOL *col;
 202.114 +      int i, j;
 202.115 +      double p_infeas, d_infeas, zeta;
 202.116 +      P->valid = 0;
 202.117 +      P->pbs_stat = P->dbs_stat = GLP_FEAS;
 202.118 +      P->obj_val = P->c0;
 202.119 +      P->some = 0;
 202.120 +      p_infeas = d_infeas = 0.0;
 202.121 +      /* make all auxiliary variables basic */
 202.122 +      for (i = 1; i <= P->m; i++)
 202.123 +      {  row = P->row[i];
 202.124 +         row->stat = GLP_BS;
 202.125 +         row->prim = row->dual = 0.0;
 202.126 +         /* check primal feasibility */
 202.127 +         if (row->type == GLP_LO || row->type == GLP_DB ||
 202.128 +             row->type == GLP_FX)
 202.129 +         {  /* row has lower bound */
 202.130 +            if (row->lb > + parm->tol_bnd)
 202.131 +            {  P->pbs_stat = GLP_NOFEAS;
 202.132 +               if (P->some == 0 && parm->meth != GLP_PRIMAL)
 202.133 +                  P->some = i;
 202.134 +            }
 202.135 +            if (p_infeas < + row->lb)
 202.136 +               p_infeas = + row->lb;
 202.137 +         }
 202.138 +         if (row->type == GLP_UP || row->type == GLP_DB ||
 202.139 +             row->type == GLP_FX)
 202.140 +         {  /* row has upper bound */
 202.141 +            if (row->ub < - parm->tol_bnd)
 202.142 +            {  P->pbs_stat = GLP_NOFEAS;
 202.143 +               if (P->some == 0 && parm->meth != GLP_PRIMAL)
 202.144 +                  P->some = i;
 202.145 +            }
 202.146 +            if (p_infeas < - row->ub)
 202.147 +               p_infeas = - row->ub;
 202.148 +         }
 202.149 +      }
 202.150 +      /* determine scale factor for the objective row */
 202.151 +      zeta = 1.0;
 202.152 +      for (j = 1; j <= P->n; j++)
 202.153 +      {  col = P->col[j];
 202.154 +         if (zeta < fabs(col->coef)) zeta = fabs(col->coef);
 202.155 +      }
 202.156 +      zeta = (P->dir == GLP_MIN ? +1.0 : -1.0) / zeta;
 202.157 +      /* make all structural variables non-basic */
 202.158 +      for (j = 1; j <= P->n; j++)
 202.159 +      {  col = P->col[j];
 202.160 +         if (col->type == GLP_FR)
 202.161 +            col->stat = GLP_NF, col->prim = 0.0;
 202.162 +         else if (col->type == GLP_LO)
 202.163 +lo:         col->stat = GLP_NL, col->prim = col->lb;
 202.164 +         else if (col->type == GLP_UP)
 202.165 +up:         col->stat = GLP_NU, col->prim = col->ub;
 202.166 +         else if (col->type == GLP_DB)
 202.167 +         {  if (zeta * col->coef > 0.0)
 202.168 +               goto lo;
 202.169 +            else if (zeta * col->coef < 0.0)
 202.170 +               goto up;
 202.171 +            else if (fabs(col->lb) <= fabs(col->ub))
 202.172 +               goto lo;
 202.173 +            else
 202.174 +               goto up;
 202.175 +         }
 202.176 +         else if (col->type == GLP_FX)
 202.177 +            col->stat = GLP_NS, col->prim = col->lb;
 202.178 +         col->dual = col->coef;
 202.179 +         P->obj_val += col->coef * col->prim;
 202.180 +         /* check dual feasibility */
 202.181 +         if (col->type == GLP_FR || col->type == GLP_LO)
 202.182 +         {  /* column has no upper bound */
 202.183 +            if (zeta * col->dual < - parm->tol_dj)
 202.184 +            {  P->dbs_stat = GLP_NOFEAS;
 202.185 +               if (P->some == 0 && parm->meth == GLP_PRIMAL)
 202.186 +                  P->some = P->m + j;
 202.187 +            }
 202.188 +            if (d_infeas < - zeta * col->dual)
 202.189 +               d_infeas = - zeta * col->dual;
 202.190 +         }
 202.191 +         if (col->type == GLP_FR || col->type == GLP_UP)
 202.192 +         {  /* column has no lower bound */
 202.193 +            if (zeta * col->dual > + parm->tol_dj)
 202.194 +            {  P->dbs_stat = GLP_NOFEAS;
 202.195 +               if (P->some == 0 && parm->meth == GLP_PRIMAL)
 202.196 +                  P->some = P->m + j;
 202.197 +            }
 202.198 +            if (d_infeas < + zeta * col->dual)
 202.199 +               d_infeas = + zeta * col->dual;
 202.200 +         }
 202.201 +      }
 202.202 +      /* simulate the simplex solver output */
 202.203 +      if (parm->msg_lev >= GLP_MSG_ON && parm->out_dly == 0)
 202.204 +      {  xprintf("~%6d: obj = %17.9e  infeas = %10.3e\n", P->it_cnt,
 202.205 +            P->obj_val, parm->meth == GLP_PRIMAL ? p_infeas : d_infeas);
 202.206 +      }
 202.207 +      if (parm->msg_lev >= GLP_MSG_ALL && parm->out_dly == 0)
 202.208 +      {  if (P->pbs_stat == GLP_FEAS && P->dbs_stat == GLP_FEAS)
 202.209 +            xprintf("OPTIMAL SOLUTION FOUND\n");
 202.210 +         else if (P->pbs_stat == GLP_NOFEAS)
 202.211 +            xprintf("PROBLEM HAS NO FEASIBLE SOLUTION\n");
 202.212 +         else if (parm->meth == GLP_PRIMAL)
 202.213 +            xprintf("PROBLEM HAS UNBOUNDED SOLUTION\n");
 202.214 +         else
 202.215 +            xprintf("PROBLEM HAS NO DUAL FEASIBLE SOLUTION\n");
 202.216 +      }
 202.217 +      return;
 202.218 +}
 202.219 +
 202.220 +static int solve_lp(glp_prob *P, const glp_smcp *parm)
 202.221 +{     /* solve LP directly without using the preprocessor */
 202.222 +      int ret;
 202.223 +      if (!glp_bf_exists(P))
 202.224 +      {  ret = glp_factorize(P);
 202.225 +         if (ret == 0)
 202.226 +            ;
 202.227 +         else if (ret == GLP_EBADB)
 202.228 +         {  if (parm->msg_lev >= GLP_MSG_ERR)
 202.229 +               xprintf("glp_simplex: initial basis is invalid\n");
 202.230 +         }
 202.231 +         else if (ret == GLP_ESING)
 202.232 +         {  if (parm->msg_lev >= GLP_MSG_ERR)
 202.233 +               xprintf("glp_simplex: initial basis is singular\n");
 202.234 +         }
 202.235 +         else if (ret == GLP_ECOND)
 202.236 +         {  if (parm->msg_lev >= GLP_MSG_ERR)
 202.237 +               xprintf(
 202.238 +                  "glp_simplex: initial basis is ill-conditioned\n");
 202.239 +         }
 202.240 +         else
 202.241 +            xassert(ret != ret);
 202.242 +         if (ret != 0) goto done;
 202.243 +      }
 202.244 +      if (parm->meth == GLP_PRIMAL)
 202.245 +         ret = spx_primal(P, parm);
 202.246 +      else if (parm->meth == GLP_DUALP)
 202.247 +      {  ret = spx_dual(P, parm);
 202.248 +         if (ret == GLP_EFAIL && P->valid)
 202.249 +            ret = spx_primal(P, parm);
 202.250 +      }
 202.251 +      else if (parm->meth == GLP_DUAL)
 202.252 +         ret = spx_dual(P, parm);
 202.253 +      else
 202.254 +         xassert(parm != parm);
 202.255 +done: return ret;
 202.256 +}
 202.257 +
 202.258 +static int preprocess_and_solve_lp(glp_prob *P, const glp_smcp *parm)
 202.259 +{     /* solve LP using the preprocessor */
 202.260 +      NPP *npp;
 202.261 +      glp_prob *lp = NULL;
 202.262 +      glp_bfcp bfcp;
 202.263 +      int ret;
 202.264 +      if (parm->msg_lev >= GLP_MSG_ALL)
 202.265 +         xprintf("Preprocessing...\n");
 202.266 +      /* create preprocessor workspace */
 202.267 +      npp = npp_create_wksp();
 202.268 +      /* load original problem into the preprocessor workspace */
 202.269 +      npp_load_prob(npp, P, GLP_OFF, GLP_SOL, GLP_OFF);
 202.270 +      /* process LP prior to applying primal/dual simplex method */
 202.271 +      ret = npp_simplex(npp, parm);
 202.272 +      if (ret == 0)
 202.273 +         ;
 202.274 +      else if (ret == GLP_ENOPFS)
 202.275 +      {  if (parm->msg_lev >= GLP_MSG_ALL)
 202.276 +            xprintf("PROBLEM HAS NO PRIMAL FEASIBLE SOLUTION\n");
 202.277 +      }
 202.278 +      else if (ret == GLP_ENODFS)
 202.279 +      {  if (parm->msg_lev >= GLP_MSG_ALL)
 202.280 +            xprintf("PROBLEM HAS NO DUAL FEASIBLE SOLUTION\n");
 202.281 +      }
 202.282 +      else
 202.283 +         xassert(ret != ret);
 202.284 +      if (ret != 0) goto done;
 202.285 +      /* build transformed LP */
 202.286 +      lp = glp_create_prob();
 202.287 +      npp_build_prob(npp, lp);
 202.288 +      /* if the transformed LP is empty, it has empty solution, which
 202.289 +         is optimal */
 202.290 +      if (lp->m == 0 && lp->n == 0)
 202.291 +      {  lp->pbs_stat = lp->dbs_stat = GLP_FEAS;
 202.292 +         lp->obj_val = lp->c0;
 202.293 +         if (parm->msg_lev >= GLP_MSG_ON && parm->out_dly == 0)
 202.294 +         {  xprintf("~%6d: obj = %17.9e  infeas = %10.3e\n", P->it_cnt,
 202.295 +               lp->obj_val, 0.0);
 202.296 +         }
 202.297 +         if (parm->msg_lev >= GLP_MSG_ALL)
 202.298 +            xprintf("OPTIMAL SOLUTION FOUND BY LP PREPROCESSOR\n");
 202.299 +         goto post;
 202.300 +      }
 202.301 +      if (parm->msg_lev >= GLP_MSG_ALL)
 202.302 +      {  xprintf("%d row%s, %d column%s, %d non-zero%s\n",
 202.303 +            lp->m, lp->m == 1 ? "" : "s", lp->n, lp->n == 1 ? "" : "s",
 202.304 +            lp->nnz, lp->nnz == 1 ? "" : "s");
 202.305 +      }
 202.306 +      /* inherit basis factorization control parameters */
 202.307 +      glp_get_bfcp(P, &bfcp);
 202.308 +      glp_set_bfcp(lp, &bfcp);
 202.309 +      /* scale the transformed problem */
 202.310 +      {  ENV *env = get_env_ptr();
 202.311 +         int term_out = env->term_out;
 202.312 +         if (!term_out || parm->msg_lev < GLP_MSG_ALL)
 202.313 +            env->term_out = GLP_OFF;
 202.314 +         else
 202.315 +            env->term_out = GLP_ON;
 202.316 +         glp_scale_prob(lp, GLP_SF_AUTO);
 202.317 +         env->term_out = term_out;
 202.318 +      }
 202.319 +      /* build advanced initial basis */
 202.320 +      {  ENV *env = get_env_ptr();
 202.321 +         int term_out = env->term_out;
 202.322 +         if (!term_out || parm->msg_lev < GLP_MSG_ALL)
 202.323 +            env->term_out = GLP_OFF;
 202.324 +         else
 202.325 +            env->term_out = GLP_ON;
 202.326 +         glp_adv_basis(lp, 0);
 202.327 +         env->term_out = term_out;
 202.328 +      }
 202.329 +      /* solve the transformed LP */
 202.330 +      lp->it_cnt = P->it_cnt;
 202.331 +      ret = solve_lp(lp, parm);
 202.332 +      P->it_cnt = lp->it_cnt;
 202.333 +      /* only optimal solution can be postprocessed */
 202.334 +      if (!(ret == 0 && lp->pbs_stat == GLP_FEAS && lp->dbs_stat ==
 202.335 +            GLP_FEAS))
 202.336 +      {  if (parm->msg_lev >= GLP_MSG_ERR)
 202.337 +            xprintf("glp_simplex: unable to recover undefined or non-op"
 202.338 +               "timal solution\n");
 202.339 +         if (ret == 0)
 202.340 +         {  if (lp->pbs_stat == GLP_NOFEAS)
 202.341 +               ret = GLP_ENOPFS;
 202.342 +            else if (lp->dbs_stat == GLP_NOFEAS)
 202.343 +               ret = GLP_ENODFS;
 202.344 +            else
 202.345 +               xassert(lp != lp);
 202.346 +         }
 202.347 +         goto done;
 202.348 +      }
 202.349 +post: /* postprocess solution from the transformed LP */
 202.350 +      npp_postprocess(npp, lp);
 202.351 +      /* the transformed LP is no longer needed */
 202.352 +      glp_delete_prob(lp), lp = NULL;
 202.353 +      /* store solution to the original problem */
 202.354 +      npp_unload_sol(npp, P);
 202.355 +      /* the original LP has been successfully solved */
 202.356 +      ret = 0;
 202.357 +done: /* delete the transformed LP, if it exists */
 202.358 +      if (lp != NULL) glp_delete_prob(lp);
 202.359 +      /* delete preprocessor workspace */
 202.360 +      npp_delete_wksp(npp);
 202.361 +      return ret;
 202.362 +}
 202.363 +
 202.364 +int glp_simplex(glp_prob *P, const glp_smcp *parm)
 202.365 +{     /* solve LP problem with the simplex method */
 202.366 +      glp_smcp _parm;
 202.367 +      int i, j, ret;
 202.368 +      /* check problem object */
 202.369 +      if (P == NULL || P->magic != GLP_PROB_MAGIC)
 202.370 +         xerror("glp_simplex: P = %p; invalid problem object\n", P);
 202.371 +      if (P->tree != NULL && P->tree->reason != 0)
 202.372 +         xerror("glp_simplex: operation not allowed\n");
 202.373 +      /* check control parameters */
 202.374 +      if (parm == NULL)
 202.375 +         parm = &_parm, glp_init_smcp((glp_smcp *)parm);
 202.376 +      if (!(parm->msg_lev == GLP_MSG_OFF ||
 202.377 +            parm->msg_lev == GLP_MSG_ERR ||
 202.378 +            parm->msg_lev == GLP_MSG_ON  ||
 202.379 +            parm->msg_lev == GLP_MSG_ALL ||
 202.380 +            parm->msg_lev == GLP_MSG_DBG))
 202.381 +         xerror("glp_simplex: msg_lev = %d; invalid parameter\n",
 202.382 +            parm->msg_lev);
 202.383 +      if (!(parm->meth == GLP_PRIMAL ||
 202.384 +            parm->meth == GLP_DUALP  ||
 202.385 +            parm->meth == GLP_DUAL))
 202.386 +         xerror("glp_simplex: meth = %d; invalid parameter\n",
 202.387 +            parm->meth);
 202.388 +      if (!(parm->pricing == GLP_PT_STD ||
 202.389 +            parm->pricing == GLP_PT_PSE))
 202.390 +         xerror("glp_simplex: pricing = %d; invalid parameter\n",
 202.391 +            parm->pricing);
 202.392 +      if (!(parm->r_test == GLP_RT_STD ||
 202.393 +            parm->r_test == GLP_RT_HAR))
 202.394 +         xerror("glp_simplex: r_test = %d; invalid parameter\n",
 202.395 +            parm->r_test);
 202.396 +      if (!(0.0 < parm->tol_bnd && parm->tol_bnd < 1.0))
 202.397 +         xerror("glp_simplex: tol_bnd = %g; invalid parameter\n",
 202.398 +            parm->tol_bnd);
 202.399 +      if (!(0.0 < parm->tol_dj && parm->tol_dj < 1.0))
 202.400 +         xerror("glp_simplex: tol_dj = %g; invalid parameter\n",
 202.401 +            parm->tol_dj);
 202.402 +      if (!(0.0 < parm->tol_piv && parm->tol_piv < 1.0))
 202.403 +         xerror("glp_simplex: tol_piv = %g; invalid parameter\n",
 202.404 +            parm->tol_piv);
 202.405 +      if (parm->it_lim < 0)
 202.406 +         xerror("glp_simplex: it_lim = %d; invalid parameter\n",
 202.407 +            parm->it_lim);
 202.408 +      if (parm->tm_lim < 0)
 202.409 +         xerror("glp_simplex: tm_lim = %d; invalid parameter\n",
 202.410 +            parm->tm_lim);
 202.411 +      if (parm->out_frq < 1)
 202.412 +         xerror("glp_simplex: out_frq = %d; invalid parameter\n",
 202.413 +            parm->out_frq);
 202.414 +      if (parm->out_dly < 0)
 202.415 +         xerror("glp_simplex: out_dly = %d; invalid parameter\n",
 202.416 +            parm->out_dly);
 202.417 +      if (!(parm->presolve == GLP_ON || parm->presolve == GLP_OFF))
 202.418 +         xerror("glp_simplex: presolve = %d; invalid parameter\n",
 202.419 +            parm->presolve);
 202.420 +      /* basic solution is currently undefined */
 202.421 +      P->pbs_stat = P->dbs_stat = GLP_UNDEF;
 202.422 +      P->obj_val = 0.0;
 202.423 +      P->some = 0;
 202.424 +      /* check bounds of double-bounded variables */
 202.425 +      for (i = 1; i <= P->m; i++)
 202.426 +      {  GLPROW *row = P->row[i];
 202.427 +         if (row->type == GLP_DB && row->lb >= row->ub)
 202.428 +         {  if (parm->msg_lev >= GLP_MSG_ERR)
 202.429 +               xprintf("glp_simplex: row %d: lb = %g, ub = %g; incorrec"
 202.430 +                  "t bounds\n", i, row->lb, row->ub);
 202.431 +            ret = GLP_EBOUND;
 202.432 +            goto done;
 202.433 +         }
 202.434 +      }
 202.435 +      for (j = 1; j <= P->n; j++)
 202.436 +      {  GLPCOL *col = P->col[j];
 202.437 +         if (col->type == GLP_DB && col->lb >= col->ub)
 202.438 +         {  if (parm->msg_lev >= GLP_MSG_ERR)
 202.439 +               xprintf("glp_simplex: column %d: lb = %g, ub = %g; incor"
 202.440 +                  "rect bounds\n", j, col->lb, col->ub);
 202.441 +            ret = GLP_EBOUND;
 202.442 +            goto done;
 202.443 +         }
 202.444 +      }
 202.445 +      /* solve LP problem */
 202.446 +      if (parm->msg_lev >= GLP_MSG_ALL)
 202.447 +      {  xprintf("GLPK Simplex Optimizer, v%s\n", glp_version());
 202.448 +         xprintf("%d row%s, %d column%s, %d non-zero%s\n",
 202.449 +            P->m, P->m == 1 ? "" : "s", P->n, P->n == 1 ? "" : "s",
 202.450 +            P->nnz, P->nnz == 1 ? "" : "s");
 202.451 +      }
 202.452 +      if (P->nnz == 0)
 202.453 +         trivial_lp(P, parm), ret = 0;
 202.454 +      else if (!parm->presolve)
 202.455 +         ret = solve_lp(P, parm);
 202.456 +      else
 202.457 +         ret = preprocess_and_solve_lp(P, parm);
 202.458 +done: /* return to the application program */
 202.459 +      return ret;
 202.460 +}
 202.461 +
 202.462 +/***********************************************************************
 202.463 +*  NAME
 202.464 +*
 202.465 +*  glp_init_smcp - initialize simplex method control parameters
 202.466 +*
 202.467 +*  SYNOPSIS
 202.468 +*
 202.469 +*  void glp_init_smcp(glp_smcp *parm);
 202.470 +*
 202.471 +*  DESCRIPTION
 202.472 +*
 202.473 +*  The routine glp_init_smcp initializes control parameters, which are
 202.474 +*  used by the simplex solver, with default values.
 202.475 +*
 202.476 +*  Default values of the control parameters are stored in a glp_smcp
 202.477 +*  structure, which the parameter parm points to. */
 202.478 +
 202.479 +void glp_init_smcp(glp_smcp *parm)
 202.480 +{     parm->msg_lev = GLP_MSG_ALL;
 202.481 +      parm->meth = GLP_PRIMAL;
 202.482 +      parm->pricing = GLP_PT_PSE;
 202.483 +      parm->r_test = GLP_RT_HAR;
 202.484 +      parm->tol_bnd = 1e-7;
 202.485 +      parm->tol_dj = 1e-7;
 202.486 +      parm->tol_piv = 1e-10;
 202.487 +      parm->obj_ll = -DBL_MAX;
 202.488 +      parm->obj_ul = +DBL_MAX;
 202.489 +      parm->it_lim = INT_MAX;
 202.490 +      parm->tm_lim = INT_MAX;
 202.491 +      parm->out_frq = 500;
 202.492 +      parm->out_dly = 0;
 202.493 +      parm->presolve = GLP_OFF;
 202.494 +      return;
 202.495 +}
 202.496 +
 202.497 +/***********************************************************************
 202.498 +*  NAME
 202.499 +*
 202.500 +*  glp_get_status - retrieve generic status of basic solution
 202.501 +*
 202.502 +*  SYNOPSIS
 202.503 +*
 202.504 +*  int glp_get_status(glp_prob *lp);
 202.505 +*
 202.506 +*  RETURNS
 202.507 +*
 202.508 +*  The routine glp_get_status reports the generic status of the basic
 202.509 +*  solution for the specified problem object as follows:
 202.510 +*
 202.511 +*  GLP_OPT    - solution is optimal;
 202.512 +*  GLP_FEAS   - solution is feasible;
 202.513 +*  GLP_INFEAS - solution is infeasible;
 202.514 +*  GLP_NOFEAS - problem has no feasible solution;
 202.515 +*  GLP_UNBND  - problem has unbounded solution;
 202.516 +*  GLP_UNDEF  - solution is undefined. */
 202.517 +
 202.518 +int glp_get_status(glp_prob *lp)
 202.519 +{     int status;
 202.520 +      status = glp_get_prim_stat(lp);
 202.521 +      switch (status)
 202.522 +      {  case GLP_FEAS:
 202.523 +            switch (glp_get_dual_stat(lp))
 202.524 +            {  case GLP_FEAS:
 202.525 +                  status = GLP_OPT;
 202.526 +                  break;
 202.527 +               case GLP_NOFEAS:
 202.528 +                  status = GLP_UNBND;
 202.529 +                  break;
 202.530 +               case GLP_UNDEF:
 202.531 +               case GLP_INFEAS:
 202.532 +                  status = status;
 202.533 +                  break;
 202.534 +               default:
 202.535 +                  xassert(lp != lp);
 202.536 +            }
 202.537 +            break;
 202.538 +         case GLP_UNDEF:
 202.539 +         case GLP_INFEAS:
 202.540 +         case GLP_NOFEAS:
 202.541 +            status = status;
 202.542 +            break;
 202.543 +         default:
 202.544 +            xassert(lp != lp);
 202.545 +      }
 202.546 +      return status;
 202.547 +}
 202.548 +
 202.549 +/***********************************************************************
 202.550 +*  NAME
 202.551 +*
 202.552 +*  glp_get_prim_stat - retrieve status of primal basic solution
 202.553 +*
 202.554 +*  SYNOPSIS
 202.555 +*
 202.556 +*  int glp_get_prim_stat(glp_prob *lp);
 202.557 +*
 202.558 +*  RETURNS
 202.559 +*
 202.560 +*  The routine glp_get_prim_stat reports the status of the primal basic
 202.561 +*  solution for the specified problem object as follows:
 202.562 +*
 202.563 +*  GLP_UNDEF  - primal solution is undefined;
 202.564 +*  GLP_FEAS   - primal solution is feasible;
 202.565 +*  GLP_INFEAS - primal solution is infeasible;
 202.566 +*  GLP_NOFEAS - no primal feasible solution exists. */
 202.567 +
 202.568 +int glp_get_prim_stat(glp_prob *lp)
 202.569 +{     int pbs_stat = lp->pbs_stat;
 202.570 +      return pbs_stat;
 202.571 +}
 202.572 +
 202.573 +/***********************************************************************
 202.574 +*  NAME
 202.575 +*
 202.576 +*  glp_get_dual_stat - retrieve status of dual basic solution
 202.577 +*
 202.578 +*  SYNOPSIS
 202.579 +*
 202.580 +*  int glp_get_dual_stat(glp_prob *lp);
 202.581 +*
 202.582 +*  RETURNS
 202.583 +*
 202.584 +*  The routine glp_get_dual_stat reports the status of the dual basic
 202.585 +*  solution for the specified problem object as follows:
 202.586 +*
 202.587 +*  GLP_UNDEF  - dual solution is undefined;
 202.588 +*  GLP_FEAS   - dual solution is feasible;
 202.589 +*  GLP_INFEAS - dual solution is infeasible;
 202.590 +*  GLP_NOFEAS - no dual feasible solution exists. */
 202.591 +
 202.592 +int glp_get_dual_stat(glp_prob *lp)
 202.593 +{     int dbs_stat = lp->dbs_stat;
 202.594 +      return dbs_stat;
 202.595 +}
 202.596 +
 202.597 +/***********************************************************************
 202.598 +*  NAME
 202.599 +*
 202.600 +*  glp_get_obj_val - retrieve objective value (basic solution)
 202.601 +*
 202.602 +*  SYNOPSIS
 202.603 +*
 202.604 +*  double glp_get_obj_val(glp_prob *lp);
 202.605 +*
 202.606 +*  RETURNS
 202.607 +*
 202.608 +*  The routine glp_get_obj_val returns value of the objective function
 202.609 +*  for basic solution. */
 202.610 +
 202.611 +double glp_get_obj_val(glp_prob *lp)
 202.612 +{     /*struct LPXCPS *cps = lp->cps;*/
 202.613 +      double z;
 202.614 +      z = lp->obj_val;
 202.615 +      /*if (cps->round && fabs(z) < 1e-9) z = 0.0;*/
 202.616 +      return z;
 202.617 +}
 202.618 +
 202.619 +/***********************************************************************
 202.620 +*  NAME
 202.621 +*
 202.622 +*  glp_get_row_stat - retrieve row status
 202.623 +*
 202.624 +*  SYNOPSIS
 202.625 +*
 202.626 +*  int glp_get_row_stat(glp_prob *lp, int i);
 202.627 +*
 202.628 +*  RETURNS
 202.629 +*
 202.630 +*  The routine glp_get_row_stat returns current status assigned to the
 202.631 +*  auxiliary variable associated with i-th row as follows:
 202.632 +*
 202.633 +*  GLP_BS - basic variable;
 202.634 +*  GLP_NL - non-basic variable on its lower bound;
 202.635 +*  GLP_NU - non-basic variable on its upper bound;
 202.636 +*  GLP_NF - non-basic free (unbounded) variable;
 202.637 +*  GLP_NS - non-basic fixed variable. */
 202.638 +
 202.639 +int glp_get_row_stat(glp_prob *lp, int i)
 202.640 +{     if (!(1 <= i && i <= lp->m))
 202.641 +         xerror("glp_get_row_stat: i = %d; row number out of range\n",
 202.642 +            i);
 202.643 +      return lp->row[i]->stat;
 202.644 +}
 202.645 +
 202.646 +/***********************************************************************
 202.647 +*  NAME
 202.648 +*
 202.649 +*  glp_get_row_prim - retrieve row primal value (basic solution)
 202.650 +*
 202.651 +*  SYNOPSIS
 202.652 +*
 202.653 +*  double glp_get_row_prim(glp_prob *lp, int i);
 202.654 +*
 202.655 +*  RETURNS
 202.656 +*
 202.657 +*  The routine glp_get_row_prim returns primal value of the auxiliary
 202.658 +*  variable associated with i-th row. */
 202.659 +
 202.660 +double glp_get_row_prim(glp_prob *lp, int i)
 202.661 +{     /*struct LPXCPS *cps = lp->cps;*/
 202.662 +      double prim;
 202.663 +      if (!(1 <= i && i <= lp->m))
 202.664 +         xerror("glp_get_row_prim: i = %d; row number out of range\n",
 202.665 +            i);
 202.666 +      prim = lp->row[i]->prim;
 202.667 +      /*if (cps->round && fabs(prim) < 1e-9) prim = 0.0;*/
 202.668 +      return prim;
 202.669 +}
 202.670 +
 202.671 +/***********************************************************************
 202.672 +*  NAME
 202.673 +*
 202.674 +*  glp_get_row_dual - retrieve row dual value (basic solution)
 202.675 +*
 202.676 +*  SYNOPSIS
 202.677 +*
 202.678 +*  double glp_get_row_dual(glp_prob *lp, int i);
 202.679 +*
 202.680 +*  RETURNS
 202.681 +*
 202.682 +*  The routine glp_get_row_dual returns dual value (i.e. reduced cost)
 202.683 +*  of the auxiliary variable associated with i-th row. */
 202.684 +
 202.685 +double glp_get_row_dual(glp_prob *lp, int i)
 202.686 +{     /*struct LPXCPS *cps = lp->cps;*/
 202.687 +      double dual;
 202.688 +      if (!(1 <= i && i <= lp->m))
 202.689 +         xerror("glp_get_row_dual: i = %d; row number out of range\n",
 202.690 +            i);
 202.691 +      dual = lp->row[i]->dual;
 202.692 +      /*if (cps->round && fabs(dual) < 1e-9) dual = 0.0;*/
 202.693 +      return dual;
 202.694 +}
 202.695 +
 202.696 +/***********************************************************************
 202.697 +*  NAME
 202.698 +*
 202.699 +*  glp_get_col_stat - retrieve column status
 202.700 +*
 202.701 +*  SYNOPSIS
 202.702 +*
 202.703 +*  int glp_get_col_stat(glp_prob *lp, int j);
 202.704 +*
 202.705 +*  RETURNS
 202.706 +*
 202.707 +*  The routine glp_get_col_stat returns current status assigned to the
 202.708 +*  structural variable associated with j-th column as follows:
 202.709 +*
 202.710 +*  GLP_BS - basic variable;
 202.711 +*  GLP_NL - non-basic variable on its lower bound;
 202.712 +*  GLP_NU - non-basic variable on its upper bound;
 202.713 +*  GLP_NF - non-basic free (unbounded) variable;
 202.714 +*  GLP_NS - non-basic fixed variable. */
 202.715 +
 202.716 +int glp_get_col_stat(glp_prob *lp, int j)
 202.717 +{     if (!(1 <= j && j <= lp->n))
 202.718 +         xerror("glp_get_col_stat: j = %d; column number out of range\n"
 202.719 +            , j);
 202.720 +      return lp->col[j]->stat;
 202.721 +}
 202.722 +
 202.723 +/***********************************************************************
 202.724 +*  NAME
 202.725 +*
 202.726 +*  glp_get_col_prim - retrieve column primal value (basic solution)
 202.727 +*
 202.728 +*  SYNOPSIS
 202.729 +*
 202.730 +*  double glp_get_col_prim(glp_prob *lp, int j);
 202.731 +*
 202.732 +*  RETURNS
 202.733 +*
 202.734 +*  The routine glp_get_col_prim returns primal value of the structural
 202.735 +*  variable associated with j-th column. */
 202.736 +
 202.737 +double glp_get_col_prim(glp_prob *lp, int j)
 202.738 +{     /*struct LPXCPS *cps = lp->cps;*/
 202.739 +      double prim;
 202.740 +      if (!(1 <= j && j <= lp->n))
 202.741 +         xerror("glp_get_col_prim: j = %d; column number out of range\n"
 202.742 +            , j);
 202.743 +      prim = lp->col[j]->prim;
 202.744 +      /*if (cps->round && fabs(prim) < 1e-9) prim = 0.0;*/
 202.745 +      return prim;
 202.746 +}
 202.747 +
 202.748 +/***********************************************************************
 202.749 +*  NAME
 202.750 +*
 202.751 +*  glp_get_col_dual - retrieve column dual value (basic solution)
 202.752 +*
 202.753 +*  SYNOPSIS
 202.754 +*
 202.755 +*  double glp_get_col_dual(glp_prob *lp, int j);
 202.756 +*
 202.757 +*  RETURNS
 202.758 +*
 202.759 +*  The routine glp_get_col_dual returns dual value (i.e. reduced cost)
 202.760 +*  of the structural variable associated with j-th column. */
 202.761 +
 202.762 +double glp_get_col_dual(glp_prob *lp, int j)
 202.763 +{     /*struct LPXCPS *cps = lp->cps;*/
 202.764 +      double dual;
 202.765 +      if (!(1 <= j && j <= lp->n))
 202.766 +         xerror("glp_get_col_dual: j = %d; column number out of range\n"
 202.767 +            , j);
 202.768 +      dual = lp->col[j]->dual;
 202.769 +      /*if (cps->round && fabs(dual) < 1e-9) dual = 0.0;*/
 202.770 +      return dual;
 202.771 +}
 202.772 +
 202.773 +/***********************************************************************
 202.774 +*  NAME
 202.775 +*
 202.776 +*  glp_get_unbnd_ray - determine variable causing unboundedness
 202.777 +*
 202.778 +*  SYNOPSIS
 202.779 +*
 202.780 +*  int glp_get_unbnd_ray(glp_prob *lp);
 202.781 +*
 202.782 +*  RETURNS
 202.783 +*
 202.784 +*  The routine glp_get_unbnd_ray returns the number k of a variable,
 202.785 +*  which causes primal or dual unboundedness. If 1 <= k <= m, it is
 202.786 +*  k-th auxiliary variable, and if m+1 <= k <= m+n, it is (k-m)-th
 202.787 +*  structural variable, where m is the number of rows, n is the number
 202.788 +*  of columns in the problem object. If such variable is not defined,
 202.789 +*  the routine returns 0.
 202.790 +*
 202.791 +*  COMMENTS
 202.792 +*
 202.793 +*  If it is not exactly known which version of the simplex solver
 202.794 +*  detected unboundedness, i.e. whether the unboundedness is primal or
 202.795 +*  dual, it is sufficient to check the status of the variable reported
 202.796 +*  with the routine glp_get_row_stat or glp_get_col_stat. If the
 202.797 +*  variable is non-basic, the unboundedness is primal, otherwise, if
 202.798 +*  the variable is basic, the unboundedness is dual (the latter case
 202.799 +*  means that the problem has no primal feasible dolution). */
 202.800 +
 202.801 +int glp_get_unbnd_ray(glp_prob *lp)
 202.802 +{     int k;
 202.803 +      k = lp->some;
 202.804 +      xassert(k >= 0);
 202.805 +      if (k > lp->m + lp->n) k = 0;
 202.806 +      return k;
 202.807 +}
 202.808 +
 202.809 +/* eof */
   203.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
   203.2 +++ b/deps/glpk/src/glpapi07.c	Sun Nov 06 20:59:10 2011 +0100
   203.3 @@ -0,0 +1,451 @@
   203.4 +/* glpapi07.c (exact simplex solver) */
   203.5 +
   203.6 +/***********************************************************************
   203.7 +*  This code is part of GLPK (GNU Linear Programming Kit).
   203.8 +*
   203.9 +*  Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008,
  203.10 +*  2009, 2010, 2011 Andrew Makhorin, Department for Applied Informatics,
  203.11 +*  Moscow Aviation Institute, Moscow, Russia. All rights reserved.
  203.12 +*  E-mail: <mao@gnu.org>.
  203.13 +*
  203.14 +*  GLPK is free software: you can redistribute it and/or modify it
  203.15 +*  under the terms of the GNU General Public License as published by
  203.16 +*  the Free Software Foundation, either version 3 of the License, or
  203.17 +*  (at your option) any later version.
  203.18 +*
  203.19 +*  GLPK is distributed in the hope that it will be useful, but WITHOUT
  203.20 +*  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
  203.21 +*  or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
  203.22 +*  License for more details.
  203.23 +*
  203.24 +*  You should have received a copy of the GNU General Public License
  203.25 +*  along with GLPK. If not, see <http://www.gnu.org/licenses/>.
  203.26 +***********************************************************************/
  203.27 +
  203.28 +#include "glpapi.h"
  203.29 +#include "glpssx.h"
  203.30 +
  203.31 +/***********************************************************************
  203.32 +*  NAME
  203.33 +*
  203.34 +*  glp_exact - solve LP problem in exact arithmetic
  203.35 +*
  203.36 +*  SYNOPSIS
  203.37 +*
  203.38 +*  int glp_exact(glp_prob *lp, const glp_smcp *parm);
  203.39 +*
  203.40 +*  DESCRIPTION
  203.41 +*
  203.42 +*  The routine glp_exact is a tentative implementation of the primal
  203.43 +*  two-phase simplex method based on exact (rational) arithmetic. It is
  203.44 +*  similar to the routine glp_simplex, however, for all internal
  203.45 +*  computations it uses arithmetic of rational numbers, which is exact
  203.46 +*  in mathematical sense, i.e. free of round-off errors unlike floating
  203.47 +*  point arithmetic.
  203.48 +*
  203.49 +*  Note that the routine glp_exact uses inly two control parameters
  203.50 +*  passed in the structure glp_smcp, namely, it_lim and tm_lim.
  203.51 +*
  203.52 +*  RETURNS
  203.53 +*
  203.54 +*  0  The LP problem instance has been successfully solved. This code
  203.55 +*     does not necessarily mean that the solver has found optimal
  203.56 +*     solution. It only means that the solution process was successful.
  203.57 +*
  203.58 +*  GLP_EBADB
  203.59 +*     Unable to start the search, because the initial basis specified
  203.60 +*     in the problem object is invalid--the number of basic (auxiliary
  203.61 +*     and structural) variables is not the same as the number of rows in
  203.62 +*     the problem object.
  203.63 +*
  203.64 +*  GLP_ESING
  203.65 +*     Unable to start the search, because the basis matrix correspodning
  203.66 +*     to the initial basis is exactly singular.
  203.67 +*
  203.68 +*  GLP_EBOUND
  203.69 +*     Unable to start the search, because some double-bounded variables
  203.70 +*     have incorrect bounds.
  203.71 +*
  203.72 +*  GLP_EFAIL
  203.73 +*     The problem has no rows/columns.
  203.74 +*
  203.75 +*  GLP_EITLIM
  203.76 +*     The search was prematurely terminated, because the simplex
  203.77 +*     iteration limit has been exceeded.
  203.78 +*
  203.79 +*  GLP_ETMLIM
  203.80 +*     The search was prematurely terminated, because the time limit has
  203.81 +*     been exceeded. */
  203.82 +
  203.83 +static void set_d_eps(mpq_t x, double val)
  203.84 +{     /* convert double val to rational x obtaining a more adequate
  203.85 +         fraction than provided by mpq_set_d due to allowing a small
  203.86 +         approximation error specified by a given relative tolerance;
  203.87 +         for example, mpq_set_d would give the following
  203.88 +         1/3 ~= 0.333333333333333314829616256247391... ->
  203.89 +             -> 6004799503160661/18014398509481984
  203.90 +         while this routine gives exactly 1/3 */
  203.91 +      int s, n, j;
  203.92 +      double f, p, q, eps = 1e-9;
  203.93 +      mpq_t temp;
  203.94 +      xassert(-DBL_MAX <= val && val <= +DBL_MAX);
  203.95 +#if 1 /* 30/VII-2008 */
  203.96 +      if (val == floor(val))
  203.97 +      {  /* if val is integral, do not approximate */
  203.98 +         mpq_set_d(x, val);
  203.99 +         goto done;
 203.100 +      }
 203.101 +#endif
 203.102 +      if (val > 0.0)
 203.103 +         s = +1;
 203.104 +      else if (val < 0.0)
 203.105 +         s = -1;
 203.106 +      else
 203.107 +      {  mpq_set_si(x, 0, 1);
 203.108 +         goto done;
 203.109 +      }
 203.110 +      f = frexp(fabs(val), &n);
 203.111 +      /* |val| = f * 2^n, where 0.5 <= f < 1.0 */
 203.112 +      fp2rat(f, 0.1 * eps, &p, &q);
 203.113 +      /* f ~= p / q, where p and q are integers */
 203.114 +      mpq_init(temp);
 203.115 +      mpq_set_d(x, p);
 203.116 +      mpq_set_d(temp, q);
 203.117 +      mpq_div(x, x, temp);
 203.118 +      mpq_set_si(temp, 1, 1);
 203.119 +      for (j = 1; j <= abs(n); j++)
 203.120 +         mpq_add(temp, temp, temp);
 203.121 +      if (n > 0)
 203.122 +         mpq_mul(x, x, temp);
 203.123 +      else if (n < 0)
 203.124 +         mpq_div(x, x, temp);
 203.125 +      mpq_clear(temp);
 203.126 +      if (s < 0) mpq_neg(x, x);
 203.127 +      /* check that the desired tolerance has been attained */
 203.128 +      xassert(fabs(val - mpq_get_d(x)) <= eps * (1.0 + fabs(val)));
 203.129 +done: return;
 203.130 +}
 203.131 +
 203.132 +static void load_data(SSX *ssx, LPX *lp)
 203.133 +{     /* load LP problem data into simplex solver workspace */
 203.134 +      int m = ssx->m;
 203.135 +      int n = ssx->n;
 203.136 +      int nnz = ssx->A_ptr[n+1]-1;
 203.137 +      int j, k, type, loc, len, *ind;
 203.138 +      double lb, ub, coef, *val;
 203.139 +      xassert(lpx_get_num_rows(lp) == m);
 203.140 +      xassert(lpx_get_num_cols(lp) == n);
 203.141 +      xassert(lpx_get_num_nz(lp) == nnz);
 203.142 +      /* types and bounds of rows and columns */
 203.143 +      for (k = 1; k <= m+n; k++)
 203.144 +      {  if (k <= m)
 203.145 +         {  type = lpx_get_row_type(lp, k);
 203.146 +            lb = lpx_get_row_lb(lp, k);
 203.147 +            ub = lpx_get_row_ub(lp, k);
 203.148 +         }
 203.149 +         else
 203.150 +         {  type = lpx_get_col_type(lp, k-m);
 203.151 +            lb = lpx_get_col_lb(lp, k-m);
 203.152 +            ub = lpx_get_col_ub(lp, k-m);
 203.153 +         }
 203.154 +         switch (type)
 203.155 +         {  case LPX_FR: type = SSX_FR; break;
 203.156 +            case LPX_LO: type = SSX_LO; break;
 203.157 +            case LPX_UP: type = SSX_UP; break;
 203.158 +            case LPX_DB: type = SSX_DB; break;
 203.159 +            case LPX_FX: type = SSX_FX; break;
 203.160 +            default: xassert(type != type);
 203.161 +         }
 203.162 +         ssx->type[k] = type;
 203.163 +         set_d_eps(ssx->lb[k], lb);
 203.164 +         set_d_eps(ssx->ub[k], ub);
 203.165 +      }
 203.166 +      /* optimization direction */
 203.167 +      switch (lpx_get_obj_dir(lp))
 203.168 +      {  case LPX_MIN: ssx->dir = SSX_MIN; break;
 203.169 +         case LPX_MAX: ssx->dir = SSX_MAX; break;
 203.170 +         default: xassert(lp != lp);
 203.171 +      }
 203.172 +      /* objective coefficients */
 203.173 +      for (k = 0; k <= m+n; k++)
 203.174 +      {  if (k == 0)
 203.175 +            coef = lpx_get_obj_coef(lp, 0);
 203.176 +         else if (k <= m)
 203.177 +            coef = 0.0;
 203.178 +         else
 203.179 +            coef = lpx_get_obj_coef(lp, k-m);
 203.180 +         set_d_eps(ssx->coef[k], coef);
 203.181 +      }
 203.182 +      /* constraint coefficients */
 203.183 +      ind = xcalloc(1+m, sizeof(int));
 203.184 +      val = xcalloc(1+m, sizeof(double));
 203.185 +      loc = 0;
 203.186 +      for (j = 1; j <= n; j++)
 203.187 +      {  ssx->A_ptr[j] = loc+1;
 203.188 +         len = lpx_get_mat_col(lp, j, ind, val);
 203.189 +         for (k = 1; k <= len; k++)
 203.190 +         {  loc++;
 203.191 +            ssx->A_ind[loc] = ind[k];
 203.192 +            set_d_eps(ssx->A_val[loc], val[k]);
 203.193 +         }
 203.194 +      }
 203.195 +      xassert(loc == nnz);
 203.196 +      xfree(ind);
 203.197 +      xfree(val);
 203.198 +      return;
 203.199 +}
 203.200 +
 203.201 +static int load_basis(SSX *ssx, LPX *lp)
 203.202 +{     /* load current LP basis into simplex solver workspace */
 203.203 +      int m = ssx->m;
 203.204 +      int n = ssx->n;
 203.205 +      int *type = ssx->type;
 203.206 +      int *stat = ssx->stat;
 203.207 +      int *Q_row = ssx->Q_row;
 203.208 +      int *Q_col = ssx->Q_col;
 203.209 +      int i, j, k;
 203.210 +      xassert(lpx_get_num_rows(lp) == m);
 203.211 +      xassert(lpx_get_num_cols(lp) == n);
 203.212 +      /* statuses of rows and columns */
 203.213 +      for (k = 1; k <= m+n; k++)
 203.214 +      {  if (k <= m)
 203.215 +            stat[k] = lpx_get_row_stat(lp, k);
 203.216 +         else
 203.217 +            stat[k] = lpx_get_col_stat(lp, k-m);
 203.218 +         switch (stat[k])
 203.219 +         {  case LPX_BS:
 203.220 +               stat[k] = SSX_BS;
 203.221 +               break;
 203.222 +            case LPX_NL:
 203.223 +               stat[k] = SSX_NL;
 203.224 +               xassert(type[k] == SSX_LO || type[k] == SSX_DB);
 203.225 +               break;
 203.226 +            case LPX_NU:
 203.227 +               stat[k] = SSX_NU;
 203.228 +               xassert(type[k] == SSX_UP || type[k] == SSX_DB);
 203.229 +               break;
 203.230 +            case LPX_NF:
 203.231 +               stat[k] = SSX_NF;
 203.232 +               xassert(type[k] == SSX_FR);
 203.233 +               break;
 203.234 +            case LPX_NS:
 203.235 +               stat[k] = SSX_NS;
 203.236 +               xassert(type[k] == SSX_FX);
 203.237 +               break;
 203.238 +            default:
 203.239 +               xassert(stat != stat);
 203.240 +         }
 203.241 +      }
 203.242 +      /* build permutation matix Q */
 203.243 +      i = j = 0;
 203.244 +      for (k = 1; k <= m+n; k++)
 203.245 +      {  if (stat[k] == SSX_BS)
 203.246 +         {  i++;
 203.247 +            if (i > m) return 1;
 203.248 +            Q_row[k] = i, Q_col[i] = k;
 203.249 +         }
 203.250 +         else
 203.251 +         {  j++;
 203.252 +            if (j > n) return 1;
 203.253 +            Q_row[k] = m+j, Q_col[m+j] = k;
 203.254 +         }
 203.255 +      }
 203.256 +      xassert(i == m && j == n);
 203.257 +      return 0;
 203.258 +}
 203.259 +
 203.260 +int glp_exact(glp_prob *lp, const glp_smcp *parm)
 203.261 +{     glp_smcp _parm;
 203.262 +      SSX *ssx;
 203.263 +      int m = lpx_get_num_rows(lp);
 203.264 +      int n = lpx_get_num_cols(lp);
 203.265 +      int nnz = lpx_get_num_nz(lp);
 203.266 +      int i, j, k, type, pst, dst, ret, *stat;
 203.267 +      double lb, ub, *prim, *dual, sum;
 203.268 +      if (parm == NULL)
 203.269 +         parm = &_parm, glp_init_smcp((glp_smcp *)parm);
 203.270 +      /* check control parameters */
 203.271 +      if (parm->it_lim < 0)
 203.272 +         xerror("glp_exact: it_lim = %d; invalid parameter\n",
 203.273 +            parm->it_lim);
 203.274 +      if (parm->tm_lim < 0)
 203.275 +         xerror("glp_exact: tm_lim = %d; invalid parameter\n",
 203.276 +            parm->tm_lim);
 203.277 +      /* the problem must have at least one row and one column */
 203.278 +      if (!(m > 0 && n > 0))
 203.279 +      {  xprintf("glp_exact: problem has no rows/columns\n");
 203.280 +         return GLP_EFAIL;
 203.281 +      }
 203.282 +#if 1
 203.283 +      /* basic solution is currently undefined */
 203.284 +      lp->pbs_stat = lp->dbs_stat = GLP_UNDEF;
 203.285 +      lp->obj_val = 0.0;
 203.286 +      lp->some = 0;
 203.287 +#endif
 203.288 +      /* check that all double-bounded variables have correct bounds */
 203.289 +      for (k = 1; k <= m+n; k++)
 203.290 +      {  if (k <= m)
 203.291 +         {  type = lpx_get_row_type(lp, k);
 203.292 +            lb = lpx_get_row_lb(lp, k);
 203.293 +            ub = lpx_get_row_ub(lp, k);
 203.294 +         }
 203.295 +         else
 203.296 +         {  type = lpx_get_col_type(lp, k-m);
 203.297 +            lb = lpx_get_col_lb(lp, k-m);
 203.298 +            ub = lpx_get_col_ub(lp, k-m);
 203.299 +         }
 203.300 +         if (type == LPX_DB && lb >= ub)
 203.301 +         {  xprintf("glp_exact: %s %d has invalid bounds\n",
 203.302 +               k <= m ? "row" : "column", k <= m ? k : k-m);
 203.303 +            return GLP_EBOUND;
 203.304 +         }
 203.305 +      }
 203.306 +      /* create the simplex solver workspace */
 203.307 +      xprintf("glp_exact: %d rows, %d columns, %d non-zeros\n",
 203.308 +         m, n, nnz);
 203.309 +#ifdef HAVE_GMP
 203.310 +      xprintf("GNU MP bignum library is being used\n");
 203.311 +#else
 203.312 +      xprintf("GLPK bignum module is being used\n");
 203.313 +      xprintf("(Consider installing GNU MP to attain a much better perf"
 203.314 +         "ormance.)\n");
 203.315 +#endif
 203.316 +      ssx = ssx_create(m, n, nnz);
 203.317 +      /* load LP problem data into the workspace */
 203.318 +      load_data(ssx, lp);
 203.319 +      /* load current LP basis into the workspace */
 203.320 +      if (load_basis(ssx, lp))
 203.321 +      {  xprintf("glp_exact: initial LP basis is invalid\n");
 203.322 +         ret = GLP_EBADB;
 203.323 +         goto done;
 203.324 +      }
 203.325 +      /* inherit some control parameters from the LP object */
 203.326 +#if 0
 203.327 +      ssx->it_lim = lpx_get_int_parm(lp, LPX_K_ITLIM);
 203.328 +      ssx->it_cnt = lpx_get_int_parm(lp, LPX_K_ITCNT);
 203.329 +      ssx->tm_lim = lpx_get_real_parm(lp, LPX_K_TMLIM);
 203.330 +#else
 203.331 +      ssx->it_lim = parm->it_lim;
 203.332 +      ssx->it_cnt = lp->it_cnt;
 203.333 +      ssx->tm_lim = (double)parm->tm_lim / 1000.0;
 203.334 +#endif
 203.335 +      ssx->out_frq = 5.0;
 203.336 +      ssx->tm_beg = xtime();
 203.337 +      ssx->tm_lag = xlset(0);
 203.338 +      /* solve LP */
 203.339 +      ret = ssx_driver(ssx);
 203.340 +      /* copy back some statistics to the LP object */
 203.341 +#if 0
 203.342 +      lpx_set_int_parm(lp, LPX_K_ITLIM, ssx->it_lim);
 203.343 +      lpx_set_int_parm(lp, LPX_K_ITCNT, ssx->it_cnt);
 203.344 +      lpx_set_real_parm(lp, LPX_K_TMLIM, ssx->tm_lim);
 203.345 +#else
 203.346 +      lp->it_cnt = ssx->it_cnt;
 203.347 +#endif
 203.348 +      /* analyze the return code */
 203.349 +      switch (ret)
 203.350 +      {  case 0:
 203.351 +            /* optimal solution found */
 203.352 +            ret = 0;
 203.353 +            pst = LPX_P_FEAS, dst = LPX_D_FEAS;
 203.354 +            break;
 203.355 +         case 1:
 203.356 +            /* problem has no feasible solution */
 203.357 +            ret = 0;
 203.358 +            pst = LPX_P_NOFEAS, dst = LPX_D_INFEAS;
 203.359 +            break;
 203.360 +         case 2:
 203.361 +            /* problem has unbounded solution */
 203.362 +            ret = 0;
 203.363 +            pst = LPX_P_FEAS, dst = LPX_D_NOFEAS;
 203.364 +#if 1
 203.365 +            xassert(1 <= ssx->q && ssx->q <= n);
 203.366 +            lp->some = ssx->Q_col[m + ssx->q];
 203.367 +            xassert(1 <= lp->some && lp->some <= m+n);
 203.368 +#endif
 203.369 +            break;
 203.370 +         case 3:
 203.371 +            /* iteration limit exceeded (phase I) */
 203.372 +            ret = GLP_EITLIM;
 203.373 +            pst = LPX_P_INFEAS, dst = LPX_D_INFEAS;
 203.374 +            break;
 203.375 +         case 4:
 203.376 +            /* iteration limit exceeded (phase II) */
 203.377 +            ret = GLP_EITLIM;
 203.378 +            pst = LPX_P_FEAS, dst = LPX_D_INFEAS;
 203.379 +            break;
 203.380 +         case 5:
 203.381 +            /* time limit exceeded (phase I) */
 203.382 +            ret = GLP_ETMLIM;
 203.383 +            pst = LPX_P_INFEAS, dst = LPX_D_INFEAS;
 203.384 +            break;
 203.385 +         case 6:
 203.386 +            /* time limit exceeded (phase II) */
 203.387 +            ret = GLP_ETMLIM;
 203.388 +            pst = LPX_P_FEAS, dst = LPX_D_INFEAS;
 203.389 +            break;
 203.390 +         case 7:
 203.391 +            /* initial basis matrix is singular */
 203.392 +            ret = GLP_ESING;
 203.393 +            goto done;
 203.394 +         default:
 203.395 +            xassert(ret != ret);
 203.396 +      }
 203.397 +      /* obtain final basic solution components */
 203.398 +      stat = xcalloc(1+m+n, sizeof(int));
 203.399 +      prim = xcalloc(1+m+n, sizeof(double));
 203.400 +      dual = xcalloc(1+m+n, sizeof(double));
 203.401 +      for (k = 1; k <= m+n; k++)
 203.402 +      {  if (ssx->stat[k] == SSX_BS)
 203.403 +         {  i = ssx->Q_row[k]; /* x[k] = xB[i] */
 203.404 +            xassert(1 <= i && i <= m);
 203.405 +            stat[k] = LPX_BS;
 203.406 +            prim[k] = mpq_get_d(ssx->bbar[i]);
 203.407 +            dual[k] = 0.0;
 203.408 +         }
 203.409 +         else
 203.410 +         {  j = ssx->Q_row[k] - m; /* x[k] = xN[j] */
 203.411 +            xassert(1 <= j && j <= n);
 203.412 +            switch (ssx->stat[k])
 203.413 +            {  case SSX_NF:
 203.414 +                  stat[k] = LPX_NF;
 203.415 +                  prim[k] = 0.0;
 203.416 +                  break;
 203.417 +               case SSX_NL:
 203.418 +                  stat[k] = LPX_NL;
 203.419 +                  prim[k] = mpq_get_d(ssx->lb[k]);
 203.420 +                  break;
 203.421 +               case SSX_NU:
 203.422 +                  stat[k] = LPX_NU;
 203.423 +                  prim[k] = mpq_get_d(ssx->ub[k]);
 203.424 +                  break;
 203.425 +               case SSX_NS:
 203.426 +                  stat[k] = LPX_NS;
 203.427 +                  prim[k] = mpq_get_d(ssx->lb[k]);
 203.428 +                  break;
 203.429 +               default:
 203.430 +                  xassert(ssx != ssx);
 203.431 +            }
 203.432 +            dual[k] = mpq_get_d(ssx->cbar[j]);
 203.433 +         }
 203.434 +      }
 203.435 +      /* and store them into the LP object */
 203.436 +      pst = pst - LPX_P_UNDEF + GLP_UNDEF;
 203.437 +      dst = dst - LPX_D_UNDEF + GLP_UNDEF;
 203.438 +      for (k = 1; k <= m+n; k++)
 203.439 +         stat[k] = stat[k] - LPX_BS + GLP_BS;
 203.440 +      sum = lpx_get_obj_coef(lp, 0);
 203.441 +      for (j = 1; j <= n; j++)
 203.442 +         sum += lpx_get_obj_coef(lp, j) * prim[m+j];
 203.443 +      lpx_put_solution(lp, 1, &pst, &dst, &sum,
 203.444 +         &stat[0], &prim[0], &dual[0], &stat[m], &prim[m], &dual[m]);
 203.445 +      xfree(stat);
 203.446 +      xfree(prim);
 203.447 +      xfree(dual);
 203.448 +done: /* delete the simplex solver workspace */
 203.449 +      ssx_delete(ssx);
 203.450 +      /* return to the application program */
 203.451 +      return ret;
 203.452 +}
 203.453 +
 203.454 +/* eof */
   204.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
   204.2 +++ b/deps/glpk/src/glpapi08.c	Sun Nov 06 20:59:10 2011 +0100
   204.3 @@ -0,0 +1,389 @@
   204.4 +/* glpapi08.c (interior-point method routines) */
   204.5 +
   204.6 +/***********************************************************************
   204.7 +*  This code is part of GLPK (GNU Linear Programming Kit).
   204.8 +*
   204.9 +*  Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008,
  204.10 +*  2009, 2010, 2011 Andrew Makhorin, Department for Applied Informatics,
  204.11 +*  Moscow Aviation Institute, Moscow, Russia. All rights reserved.
  204.12 +*  E-mail: <mao@gnu.org>.
  204.13 +*
  204.14 +*  GLPK is free software: you can redistribute it and/or modify it
  204.15 +*  under the terms of the GNU General Public License as published by
  204.16 +*  the Free Software Foundation, either version 3 of the License, or
  204.17 +*  (at your option) any later version.
  204.18 +*
  204.19 +*  GLPK is distributed in the hope that it will be useful, but WITHOUT
  204.20 +*  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
  204.21 +*  or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
  204.22 +*  License for more details.
  204.23 +*
  204.24 +*  You should have received a copy of the GNU General Public License
  204.25 +*  along with GLPK. If not, see <http://www.gnu.org/licenses/>.
  204.26 +***********************************************************************/
  204.27 +
  204.28 +#include "glpapi.h"
  204.29 +#include "glpipm.h"
  204.30 +#include "glpnpp.h"
  204.31 +
  204.32 +/***********************************************************************
  204.33 +*  NAME
  204.34 +*
  204.35 +*  glp_interior - solve LP problem with the interior-point method
  204.36 +*
  204.37 +*  SYNOPSIS
  204.38 +*
  204.39 +*  int glp_interior(glp_prob *P, const glp_iptcp *parm);
  204.40 +*
  204.41 +*  The routine glp_interior is a driver to the LP solver based on the
  204.42 +*  interior-point method.
  204.43 +*
  204.44 +*  The interior-point solver has a set of control parameters. Values of
  204.45 +*  the control parameters can be passed in a structure glp_iptcp, which
  204.46 +*  the parameter parm points to.
  204.47 +*
  204.48 +*  Currently this routine implements an easy variant of the primal-dual
  204.49 +*  interior-point method based on Mehrotra's technique.
  204.50 +*
  204.51 +*  This routine transforms the original LP problem to an equivalent LP
  204.52 +*  problem in the standard formulation (all constraints are equalities,
  204.53 +*  all variables are non-negative), calls the routine ipm_main to solve
  204.54 +*  the transformed problem, and then transforms an obtained solution to
  204.55 +*  the solution of the original problem.
  204.56 +*
  204.57 +*  RETURNS
  204.58 +*
  204.59 +*  0  The LP problem instance has been successfully solved. This code
  204.60 +*     does not necessarily mean that the solver has found optimal
  204.61 +*     solution. It only means that the solution process was successful.
  204.62 +*
  204.63 +*  GLP_EFAIL
  204.64 +*     The problem has no rows/columns.
  204.65 +*
  204.66 +*  GLP_ENOCVG
  204.67 +*     Very slow convergence or divergence.
  204.68 +*
  204.69 +*  GLP_EITLIM
  204.70 +*     Iteration limit exceeded.
  204.71 +*
  204.72 +*  GLP_EINSTAB
  204.73 +*     Numerical instability on solving Newtonian system. */
  204.74 +
  204.75 +static void transform(NPP *npp)
  204.76 +{     /* transform LP to the standard formulation */
  204.77 +      NPPROW *row, *prev_row;
  204.78 +      NPPCOL *col, *prev_col;
  204.79 +      for (row = npp->r_tail; row != NULL; row = prev_row)
  204.80 +      {  prev_row = row->prev;
  204.81 +         if (row->lb == -DBL_MAX && row->ub == +DBL_MAX)
  204.82 +            npp_free_row(npp, row);
  204.83 +         else if (row->lb == -DBL_MAX)
  204.84 +            npp_leq_row(npp, row);
  204.85 +         else if (row->ub == +DBL_MAX)
  204.86 +            npp_geq_row(npp, row);
  204.87 +         else if (row->lb != row->ub)
  204.88 +         {  if (fabs(row->lb) < fabs(row->ub))
  204.89 +               npp_geq_row(npp, row);
  204.90 +            else
  204.91 +               npp_leq_row(npp, row);
  204.92 +         }
  204.93 +      }
  204.94 +      for (col = npp->c_tail; col != NULL; col = prev_col)
  204.95 +      {  prev_col = col->prev;
  204.96 +         if (col->lb == -DBL_MAX && col->ub == +DBL_MAX)
  204.97 +            npp_free_col(npp, col);
  204.98 +         else if (col->lb == -DBL_MAX)
  204.99 +            npp_ubnd_col(npp, col);
 204.100 +         else if (col->ub == +DBL_MAX)
 204.101 +         {  if (col->lb != 0.0)
 204.102 +               npp_lbnd_col(npp, col);
 204.103 +         }
 204.104 +         else if (col->lb != col->ub)
 204.105 +         {  if (fabs(col->lb) < fabs(col->ub))
 204.106 +            {  if (col->lb != 0.0)
 204.107 +                  npp_lbnd_col(npp, col);
 204.108 +            }
 204.109 +            else
 204.110 +               npp_ubnd_col(npp, col);
 204.111 +            npp_dbnd_col(npp, col);
 204.112 +         }
 204.113 +         else
 204.114 +            npp_fixed_col(npp, col);
 204.115 +      }
 204.116 +      for (row = npp->r_head; row != NULL; row = row->next)
 204.117 +         xassert(row->lb == row->ub);
 204.118 +      for (col = npp->c_head; col != NULL; col = col->next)
 204.119 +         xassert(col->lb == 0.0 && col->ub == +DBL_MAX);
 204.120 +      return;
 204.121 +}
 204.122 +
 204.123 +int glp_interior(glp_prob *P, const glp_iptcp *parm)
 204.124 +{     glp_iptcp _parm;
 204.125 +      GLPROW *row;
 204.126 +      GLPCOL *col;
 204.127 +      NPP *npp = NULL;
 204.128 +      glp_prob *prob = NULL;
 204.129 +      int i, j, ret;
 204.130 +      /* check control parameters */
 204.131 +      if (parm == NULL)
 204.132 +         glp_init_iptcp(&_parm), parm = &_parm;
 204.133 +      if (!(parm->msg_lev == GLP_MSG_OFF ||
 204.134 +            parm->msg_lev == GLP_MSG_ERR ||
 204.135 +            parm->msg_lev == GLP_MSG_ON  ||
 204.136 +            parm->msg_lev == GLP_MSG_ALL))
 204.137 +         xerror("glp_interior: msg_lev = %d; invalid parameter\n",
 204.138 +            parm->msg_lev);
 204.139 +      if (!(parm->ord_alg == GLP_ORD_NONE ||
 204.140 +            parm->ord_alg == GLP_ORD_QMD ||
 204.141 +            parm->ord_alg == GLP_ORD_AMD ||
 204.142 +            parm->ord_alg == GLP_ORD_SYMAMD))
 204.143 +         xerror("glp_interior: ord_alg = %d; invalid parameter\n",
 204.144 +            parm->ord_alg);
 204.145 +      /* interior-point solution is currently undefined */
 204.146 +      P->ipt_stat = GLP_UNDEF;
 204.147 +      P->ipt_obj = 0.0;
 204.148 +      /* check bounds of double-bounded variables */
 204.149 +      for (i = 1; i <= P->m; i++)
 204.150 +      {  row = P->row[i];
 204.151 +         if (row->type == GLP_DB && row->lb >= row->ub)
 204.152 +         {  if (parm->msg_lev >= GLP_MSG_ERR)
 204.153 +               xprintf("glp_interior: row %d: lb = %g, ub = %g; incorre"
 204.154 +                  "ct bounds\n", i, row->lb, row->ub);
 204.155 +            ret = GLP_EBOUND;
 204.156 +            goto done;
 204.157 +         }
 204.158 +      }
 204.159 +      for (j = 1; j <= P->n; j++)
 204.160 +      {  col = P->col[j];
 204.161 +         if (col->type == GLP_DB && col->lb >= col->ub)
 204.162 +         {  if (parm->msg_lev >= GLP_MSG_ERR)
 204.163 +               xprintf("glp_interior: column %d: lb = %g, ub = %g; inco"
 204.164 +                  "rrect bounds\n", j, col->lb, col->ub);
 204.165 +            ret = GLP_EBOUND;
 204.166 +            goto done;
 204.167 +         }
 204.168 +      }
 204.169 +      /* transform LP to the standard formulation */
 204.170 +      if (parm->msg_lev >= GLP_MSG_ALL)
 204.171 +         xprintf("Original LP has %d row(s), %d column(s), and %d non-z"
 204.172 +            "ero(s)\n", P->m, P->n, P->nnz);
 204.173 +      npp = npp_create_wksp();
 204.174 +      npp_load_prob(npp, P, GLP_OFF, GLP_IPT, GLP_ON);
 204.175 +      transform(npp);
 204.176 +      prob = glp_create_prob();
 204.177 +      npp_build_prob(npp, prob);
 204.178 +      if (parm->msg_lev >= GLP_MSG_ALL)
 204.179 +         xprintf("Working LP has %d row(s), %d column(s), and %d non-ze"
 204.180 +            "ro(s)\n", prob->m, prob->n, prob->nnz);
 204.181 +#if 1
 204.182 +      /* currently empty problem cannot be solved */
 204.183 +      if (!(prob->m > 0 && prob->n > 0))
 204.184 +      {  if (parm->msg_lev >= GLP_MSG_ERR)
 204.185 +            xprintf("glp_interior: unable to solve empty problem\n");
 204.186 +         ret = GLP_EFAIL;
 204.187 +         goto done;
 204.188 +      }
 204.189 +#endif
 204.190 +      /* scale the resultant LP */
 204.191 +      {  ENV *env = get_env_ptr();
 204.192 +         int term_out = env->term_out;
 204.193 +         env->term_out = GLP_OFF;
 204.194 +         glp_scale_prob(prob, GLP_SF_EQ);
 204.195 +         env->term_out = term_out;
 204.196 +      }
 204.197 +      /* warn about dense columns */
 204.198 +      if (parm->msg_lev >= GLP_MSG_ON && prob->m >= 200)
 204.199 +      {  int len, cnt = 0;
 204.200 +         for (j = 1; j <= prob->n; j++)
 204.201 +         {  len = glp_get_mat_col(prob, j, NULL, NULL);
 204.202 +            if ((double)len >= 0.20 * (double)prob->m) cnt++;
 204.203 +         }
 204.204 +         if (cnt == 1)
 204.205 +            xprintf("WARNING: PROBLEM HAS ONE DENSE COLUMN\n");
 204.206 +         else if (cnt > 0)
 204.207 +            xprintf("WARNING: PROBLEM HAS %d DENSE COLUMNS\n", cnt);
 204.208 +      }
 204.209 +      /* solve the transformed LP */
 204.210 +      ret = ipm_solve(prob, parm);
 204.211 +      /* postprocess solution from the transformed LP */
 204.212 +      npp_postprocess(npp, prob);
 204.213 +      /* and store solution to the original LP */
 204.214 +      npp_unload_sol(npp, P);
 204.215 +done: /* free working program objects */
 204.216 +      if (npp != NULL) npp_delete_wksp(npp);
 204.217 +      if (prob != NULL) glp_delete_prob(prob);
 204.218 +      /* return to the application program */
 204.219 +      return ret;
 204.220 +}
 204.221 +
 204.222 +/***********************************************************************
 204.223 +*  NAME
 204.224 +*
 204.225 +*  glp_init_iptcp - initialize interior-point solver control parameters
 204.226 +*
 204.227 +*  SYNOPSIS
 204.228 +*
 204.229 +*  void glp_init_iptcp(glp_iptcp *parm);
 204.230 +*
 204.231 +*  DESCRIPTION
 204.232 +*
 204.233 +*  The routine glp_init_iptcp initializes control parameters, which are
 204.234 +*  used by the interior-point solver, with default values.
 204.235 +*
 204.236 +*  Default values of the control parameters are stored in the glp_iptcp
 204.237 +*  structure, which the parameter parm points to. */
 204.238 +
 204.239 +void glp_init_iptcp(glp_iptcp *parm)
 204.240 +{     parm->msg_lev = GLP_MSG_ALL;
 204.241 +      parm->ord_alg = GLP_ORD_AMD;
 204.242 +      return;
 204.243 +}
 204.244 +
 204.245 +/***********************************************************************
 204.246 +*  NAME
 204.247 +*
 204.248 +*  glp_ipt_status - retrieve status of interior-point solution
 204.249 +*
 204.250 +*  SYNOPSIS
 204.251 +*
 204.252 +*  int glp_ipt_status(glp_prob *lp);
 204.253 +*
 204.254 +*  RETURNS
 204.255 +*
 204.256 +*  The routine glp_ipt_status reports the status of solution found by
 204.257 +*  the interior-point solver as follows:
 204.258 +*
 204.259 +*  GLP_UNDEF  - interior-point solution is undefined;
 204.260 +*  GLP_OPT    - interior-point solution is optimal;
 204.261 +*  GLP_INFEAS - interior-point solution is infeasible;
 204.262 +*  GLP_NOFEAS - no feasible solution exists. */
 204.263 +
 204.264 +int glp_ipt_status(glp_prob *lp)
 204.265 +{     int ipt_stat = lp->ipt_stat;
 204.266 +      return ipt_stat;
 204.267 +}
 204.268 +
 204.269 +/***********************************************************************
 204.270 +*  NAME
 204.271 +*
 204.272 +*  glp_ipt_obj_val - retrieve objective value (interior point)
 204.273 +*
 204.274 +*  SYNOPSIS
 204.275 +*
 204.276 +*  double glp_ipt_obj_val(glp_prob *lp);
 204.277 +*
 204.278 +*  RETURNS
 204.279 +*
 204.280 +*  The routine glp_ipt_obj_val returns value of the objective function
 204.281 +*  for interior-point solution. */
 204.282 +
 204.283 +double glp_ipt_obj_val(glp_prob *lp)
 204.284 +{     /*struct LPXCPS *cps = lp->cps;*/
 204.285 +      double z;
 204.286 +      z = lp->ipt_obj;
 204.287 +      /*if (cps->round && fabs(z) < 1e-9) z = 0.0;*/
 204.288 +      return z;
 204.289 +}
 204.290 +
 204.291 +/***********************************************************************
 204.292 +*  NAME
 204.293 +*
 204.294 +*  glp_ipt_row_prim - retrieve row primal value (interior point)
 204.295 +*
 204.296 +*  SYNOPSIS
 204.297 +*
 204.298 +*  double glp_ipt_row_prim(glp_prob *lp, int i);
 204.299 +*
 204.300 +*  RETURNS
 204.301 +*
 204.302 +*  The routine glp_ipt_row_prim returns primal value of the auxiliary
 204.303 +*  variable associated with i-th row. */
 204.304 +
 204.305 +double glp_ipt_row_prim(glp_prob *lp, int i)
 204.306 +{     /*struct LPXCPS *cps = lp->cps;*/
 204.307 +      double pval;
 204.308 +      if (!(1 <= i && i <= lp->m))
 204.309 +         xerror("glp_ipt_row_prim: i = %d; row number out of range\n",
 204.310 +            i);
 204.311 +      pval = lp->row[i]->pval;
 204.312 +      /*if (cps->round && fabs(pval) < 1e-9) pval = 0.0;*/
 204.313 +      return pval;
 204.314 +}
 204.315 +
 204.316 +/***********************************************************************
 204.317 +*  NAME
 204.318 +*
 204.319 +*  glp_ipt_row_dual - retrieve row dual value (interior point)
 204.320 +*
 204.321 +*  SYNOPSIS
 204.322 +*
 204.323 +*  double glp_ipt_row_dual(glp_prob *lp, int i);
 204.324 +*
 204.325 +*  RETURNS
 204.326 +*
 204.327 +*  The routine glp_ipt_row_dual returns dual value (i.e. reduced cost)
 204.328 +*  of the auxiliary variable associated with i-th row. */
 204.329 +
 204.330 +double glp_ipt_row_dual(glp_prob *lp, int i)
 204.331 +{     /*struct LPXCPS *cps = lp->cps;*/
 204.332 +      double dval;
 204.333 +      if (!(1 <= i && i <= lp->m))
 204.334 +         xerror("glp_ipt_row_dual: i = %d; row number out of range\n",
 204.335 +            i);
 204.336 +      dval = lp->row[i]->dval;
 204.337 +      /*if (cps->round && fabs(dval) < 1e-9) dval = 0.0;*/
 204.338 +      return dval;
 204.339 +}
 204.340 +
 204.341 +/***********************************************************************
 204.342 +*  NAME
 204.343 +*
 204.344 +*  glp_ipt_col_prim - retrieve column primal value (interior point)
 204.345 +*
 204.346 +*  SYNOPSIS
 204.347 +*
 204.348 +*  double glp_ipt_col_prim(glp_prob *lp, int j);
 204.349 +*
 204.350 +*  RETURNS
 204.351 +*
 204.352 +*  The routine glp_ipt_col_prim returns primal value of the structural
 204.353 +*  variable associated with j-th column. */
 204.354 +
 204.355 +double glp_ipt_col_prim(glp_prob *lp, int j)
 204.356 +{     /*struct LPXCPS *cps = lp->cps;*/
 204.357 +      double pval;
 204.358 +      if (!(1 <= j && j <= lp->n))
 204.359 +         xerror("glp_ipt_col_prim: j = %d; column number out of range\n"
 204.360 +            , j);
 204.361 +      pval = lp->col[j]->pval;
 204.362 +      /*if (cps->round && fabs(pval) < 1e-9) pval = 0.0;*/
 204.363 +      return pval;
 204.364 +}
 204.365 +
 204.366 +/***********************************************************************
 204.367 +*  NAME
 204.368 +*
 204.369 +*  glp_ipt_col_dual - retrieve column dual value (interior point)
 204.370 +*
 204.371 +*  SYNOPSIS
 204.372 +*
 204.373 +*  #include "glplpx.h"
 204.374 +*  double glp_ipt_col_dual(glp_prob *lp, int j);
 204.375 +*
 204.376 +*  RETURNS
 204.377 +*
 204.378 +*  The routine glp_ipt_col_dual returns dual value (i.e. reduced cost)
 204.379 +*  of the structural variable associated with j-th column. */
 204.380 +
 204.381 +double glp_ipt_col_dual(glp_prob *lp, int j)
 204.382 +{     /*struct LPXCPS *cps = lp->cps;*/
 204.383 +      double dval;
 204.384 +      if (!(1 <= j && j <= lp->n))
 204.385 +         xerror("glp_ipt_col_dual: j = %d; column number out of range\n"
 204.386 +            , j);
 204.387 +      dval = lp->col[j]->dval;
 204.388 +      /*if (cps->round && fabs(dval) < 1e-9) dval = 0.0;*/
 204.389 +      return dval;
 204.390 +}
 204.391 +
 204.392 +/* eof */
   205.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
   205.2 +++ b/deps/glpk/src/glpapi09.c	Sun Nov 06 20:59:10 2011 +0100
   205.3 @@ -0,0 +1,741 @@
   205.4 +/* glpapi09.c (mixed integer programming routines) */
   205.5 +
   205.6 +/***********************************************************************
   205.7 +*  This code is part of GLPK (GNU Linear Programming Kit).
   205.8 +*
   205.9 +*  Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008,
  205.10 +*  2009, 2010, 2011 Andrew Makhorin, Department for Applied Informatics,
  205.11 +*  Moscow Aviation Institute, Moscow, Russia. All rights reserved.
  205.12 +*  E-mail: <mao@gnu.org>.
  205.13 +*
  205.14 +*  GLPK is free software: you can redistribute it and/or modify it
  205.15 +*  under the terms of the GNU General Public License as published by
  205.16 +*  the Free Software Foundation, either version 3 of the License, or
  205.17 +*  (at your option) any later version.
  205.18 +*
  205.19 +*  GLPK is distributed in the hope that it will be useful, but WITHOUT
  205.20 +*  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
  205.21 +*  or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
  205.22 +*  License for more details.
  205.23 +*
  205.24 +*  You should have received a copy of the GNU General Public License
  205.25 +*  along with GLPK. If not, see <http://www.gnu.org/licenses/>.
  205.26 +***********************************************************************/
  205.27 +
  205.28 +#include "glpios.h"
  205.29 +#include "glpnpp.h"
  205.30 +
  205.31 +/***********************************************************************
  205.32 +*  NAME
  205.33 +*
  205.34 +*  glp_set_col_kind - set (change) column kind
  205.35 +*
  205.36 +*  SYNOPSIS
  205.37 +*
  205.38 +*  void glp_set_col_kind(glp_prob *mip, int j, int kind);
  205.39 +*
  205.40 +*  DESCRIPTION
  205.41 +*
  205.42 +*  The routine glp_set_col_kind sets (changes) the kind of j-th column
  205.43 +*  (structural variable) as specified by the parameter kind:
  205.44 +*
  205.45 +*  GLP_CV - continuous variable;
  205.46 +*  GLP_IV - integer variable;
  205.47 +*  GLP_BV - binary variable. */
  205.48 +
  205.49 +void glp_set_col_kind(glp_prob *mip, int j, int kind)
  205.50 +{     GLPCOL *col;
  205.51 +      if (!(1 <= j && j <= mip->n))
  205.52 +         xerror("glp_set_col_kind: j = %d; column number out of range\n"
  205.53 +            , j);
  205.54 +      col = mip->col[j];
  205.55 +      switch (kind)
  205.56 +      {  case GLP_CV:
  205.57 +            col->kind = GLP_CV;
  205.58 +            break;
  205.59 +         case GLP_IV:
  205.60 +            col->kind = GLP_IV;
  205.61 +            break;
  205.62 +         case GLP_BV:
  205.63 +            col->kind = GLP_IV;
  205.64 +            if (!(col->type == GLP_DB && col->lb == 0.0 && col->ub ==
  205.65 +               1.0)) glp_set_col_bnds(mip, j, GLP_DB, 0.0, 1.0);
  205.66 +            break;
  205.67 +         default:
  205.68 +            xerror("glp_set_col_kind: j = %d; kind = %d; invalid column"
  205.69 +               " kind\n", j, kind);
  205.70 +      }
  205.71 +      return;
  205.72 +}
  205.73 +
  205.74 +/***********************************************************************
  205.75 +*  NAME
  205.76 +*
  205.77 +*  glp_get_col_kind - retrieve column kind
  205.78 +*
  205.79 +*  SYNOPSIS
  205.80 +*
  205.81 +*  int glp_get_col_kind(glp_prob *mip, int j);
  205.82 +*
  205.83 +*  RETURNS
  205.84 +*
  205.85 +*  The routine glp_get_col_kind returns the kind of j-th column, i.e.
  205.86 +*  the kind of corresponding structural variable, as follows:
  205.87 +*
  205.88 +*  GLP_CV - continuous variable;
  205.89 +*  GLP_IV - integer variable;
  205.90 +*  GLP_BV - binary variable */
  205.91 +
  205.92 +int glp_get_col_kind(glp_prob *mip, int j)
  205.93 +{     GLPCOL *col;
  205.94 +      int kind;
  205.95 +      if (!(1 <= j && j <= mip->n))
  205.96 +         xerror("glp_get_col_kind: j = %d; column number out of range\n"
  205.97 +            , j);
  205.98 +      col = mip->col[j];
  205.99 +      kind = col->kind;
 205.100 +      switch (kind)
 205.101 +      {  case GLP_CV:
 205.102 +            break;
 205.103 +         case GLP_IV:
 205.104 +            if (col->type == GLP_DB && col->lb == 0.0 && col->ub == 1.0)
 205.105 +               kind = GLP_BV;
 205.106 +            break;
 205.107 +         default:
 205.108 +            xassert(kind != kind);
 205.109 +      }
 205.110 +      return kind;
 205.111 +}
 205.112 +
 205.113 +/***********************************************************************
 205.114 +*  NAME
 205.115 +*
 205.116 +*  glp_get_num_int - retrieve number of integer columns
 205.117 +*
 205.118 +*  SYNOPSIS
 205.119 +*
 205.120 +*  int glp_get_num_int(glp_prob *mip);
 205.121 +*
 205.122 +*  RETURNS
 205.123 +*
 205.124 +*  The routine glp_get_num_int returns the current number of columns,
 205.125 +*  which are marked as integer. */
 205.126 +
 205.127 +int glp_get_num_int(glp_prob *mip)
 205.128 +{     GLPCOL *col;
 205.129 +      int j, count = 0;
 205.130 +      for (j = 1; j <= mip->n; j++)
 205.131 +      {  col = mip->col[j];
 205.132 +         if (col->kind == GLP_IV) count++;
 205.133 +      }
 205.134 +      return count;
 205.135 +}
 205.136 +
 205.137 +/***********************************************************************
 205.138 +*  NAME
 205.139 +*
 205.140 +*  glp_get_num_bin - retrieve number of binary columns
 205.141 +*
 205.142 +*  SYNOPSIS
 205.143 +*
 205.144 +*  int glp_get_num_bin(glp_prob *mip);
 205.145 +*
 205.146 +*  RETURNS
 205.147 +*
 205.148 +*  The routine glp_get_num_bin returns the current number of columns,
 205.149 +*  which are marked as binary. */
 205.150 +
 205.151 +int glp_get_num_bin(glp_prob *mip)
 205.152 +{     GLPCOL *col;
 205.153 +      int j, count = 0;
 205.154 +      for (j = 1; j <= mip->n; j++)
 205.155 +      {  col = mip->col[j];
 205.156 +         if (col->kind == GLP_IV && col->type == GLP_DB && col->lb ==
 205.157 +            0.0 && col->ub == 1.0) count++;
 205.158 +      }
 205.159 +      return count;
 205.160 +}
 205.161 +
 205.162 +/***********************************************************************
 205.163 +*  NAME
 205.164 +*
 205.165 +*  glp_intopt - solve MIP problem with the branch-and-bound method
 205.166 +*
 205.167 +*  SYNOPSIS
 205.168 +*
 205.169 +*  int glp_intopt(glp_prob *P, const glp_iocp *parm);
 205.170 +*
 205.171 +*  DESCRIPTION
 205.172 +*
 205.173 +*  The routine glp_intopt is a driver to the MIP solver based on the
 205.174 +*  branch-and-bound method.
 205.175 +*
 205.176 +*  On entry the problem object should contain optimal solution to LP
 205.177 +*  relaxation (which can be obtained with the routine glp_simplex).
 205.178 +*
 205.179 +*  The MIP solver has a set of control parameters. Values of the control
 205.180 +*  parameters can be passed in a structure glp_iocp, which the parameter
 205.181 +*  parm points to.
 205.182 +*
 205.183 +*  The parameter parm can be specified as NULL, in which case the MIP
 205.184 +*  solver uses default settings.
 205.185 +*
 205.186 +*  RETURNS
 205.187 +*
 205.188 +*  0  The MIP problem instance has been successfully solved. This code
 205.189 +*     does not necessarily mean that the solver has found optimal
 205.190 +*     solution. It only means that the solution process was successful.
 205.191 +*
 205.192 +*  GLP_EBOUND
 205.193 +*     Unable to start the search, because some double-bounded variables
 205.194 +*     have incorrect bounds or some integer variables have non-integer
 205.195 +*     (fractional) bounds.
 205.196 +*
 205.197 +*  GLP_EROOT
 205.198 +*     Unable to start the search, because optimal basis for initial LP
 205.199 +*     relaxation is not provided.
 205.200 +*
 205.201 +*  GLP_EFAIL
 205.202 +*     The search was prematurely terminated due to the solver failure.
 205.203 +*
 205.204 +*  GLP_EMIPGAP
 205.205 +*     The search was prematurely terminated, because the relative mip
 205.206 +*     gap tolerance has been reached.
 205.207 +*
 205.208 +*  GLP_ETMLIM
 205.209 +*     The search was prematurely terminated, because the time limit has
 205.210 +*     been exceeded.
 205.211 +*
 205.212 +*  GLP_ENOPFS
 205.213 +*     The MIP problem instance has no primal feasible solution (only if
 205.214 +*     the MIP presolver is used).
 205.215 +*
 205.216 +*  GLP_ENODFS
 205.217 +*     LP relaxation of the MIP problem instance has no dual feasible
 205.218 +*     solution (only if the MIP presolver is used).
 205.219 +*
 205.220 +*  GLP_ESTOP
 205.221 +*     The search was prematurely terminated by application. */
 205.222 +
 205.223 +static int solve_mip(glp_prob *P, const glp_iocp *parm)
 205.224 +{     /* solve MIP directly without using the preprocessor */
 205.225 +      glp_tree *T;
 205.226 +      int ret;
 205.227 +      /* optimal basis to LP relaxation must be provided */
 205.228 +      if (glp_get_status(P) != GLP_OPT)
 205.229 +      {  if (parm->msg_lev >= GLP_MSG_ERR)
 205.230 +            xprintf("glp_intopt: optimal basis to initial LP relaxation"
 205.231 +               " not provided\n");
 205.232 +         ret = GLP_EROOT;
 205.233 +         goto done;
 205.234 +      }
 205.235 +      /* it seems all is ok */
 205.236 +      if (parm->msg_lev >= GLP_MSG_ALL)
 205.237 +         xprintf("Integer optimization begins...\n");
 205.238 +      /* create the branch-and-bound tree */
 205.239 +      T = ios_create_tree(P, parm);
 205.240 +      /* solve the problem instance */
 205.241 +      ret = ios_driver(T);
 205.242 +      /* delete the branch-and-bound tree */
 205.243 +      ios_delete_tree(T);
 205.244 +      /* analyze exit code reported by the mip driver */
 205.245 +      if (ret == 0)
 205.246 +      {  if (P->mip_stat == GLP_FEAS)
 205.247 +         {  if (parm->msg_lev >= GLP_MSG_ALL)
 205.248 +               xprintf("INTEGER OPTIMAL SOLUTION FOUND\n");
 205.249 +            P->mip_stat = GLP_OPT;
 205.250 +         }
 205.251 +         else
 205.252 +         {  if (parm->msg_lev >= GLP_MSG_ALL)
 205.253 +               xprintf("PROBLEM HAS NO INTEGER FEASIBLE SOLUTION\n");
 205.254 +            P->mip_stat = GLP_NOFEAS;
 205.255 +         }
 205.256 +      }
 205.257 +      else if (ret == GLP_EMIPGAP)
 205.258 +      {  if (parm->msg_lev >= GLP_MSG_ALL)
 205.259 +            xprintf("RELATIVE MIP GAP TOLERANCE REACHED; SEARCH TERMINA"
 205.260 +               "TED\n");
 205.261 +      }
 205.262 +      else if (ret == GLP_ETMLIM)
 205.263 +      {  if (parm->msg_lev >= GLP_MSG_ALL)
 205.264 +            xprintf("TIME LIMIT EXCEEDED; SEARCH TERMINATED\n");
 205.265 +      }
 205.266 +      else if (ret == GLP_EFAIL)
 205.267 +      {  if (parm->msg_lev >= GLP_MSG_ERR)
 205.268 +            xprintf("glp_intopt: cannot solve current LP relaxation\n");
 205.269 +      }
 205.270 +      else if (ret == GLP_ESTOP)
 205.271 +      {  if (parm->msg_lev >= GLP_MSG_ALL)
 205.272 +            xprintf("SEARCH TERMINATED BY APPLICATION\n");
 205.273 +      }
 205.274 +      else
 205.275 +         xassert(ret != ret);
 205.276 +done: return ret;
 205.277 +}
 205.278 +
 205.279 +static int preprocess_and_solve_mip(glp_prob *P, const glp_iocp *parm)
 205.280 +{     /* solve MIP using the preprocessor */
 205.281 +      ENV *env = get_env_ptr();
 205.282 +      int term_out = env->term_out;
 205.283 +      NPP *npp;
 205.284 +      glp_prob *mip = NULL;
 205.285 +      glp_bfcp bfcp;
 205.286 +      glp_smcp smcp;
 205.287 +      int ret;
 205.288 +      if (parm->msg_lev >= GLP_MSG_ALL)
 205.289 +         xprintf("Preprocessing...\n");
 205.290 +      /* create preprocessor workspace */
 205.291 +      npp = npp_create_wksp();
 205.292 +      /* load original problem into the preprocessor workspace */
 205.293 +      npp_load_prob(npp, P, GLP_OFF, GLP_MIP, GLP_OFF);
 205.294 +      /* process MIP prior to applying the branch-and-bound method */
 205.295 +      if (!term_out || parm->msg_lev < GLP_MSG_ALL)
 205.296 +         env->term_out = GLP_OFF;
 205.297 +      else
 205.298 +         env->term_out = GLP_ON;
 205.299 +      ret = npp_integer(npp, parm);
 205.300 +      env->term_out = term_out;
 205.301 +      if (ret == 0)
 205.302 +         ;
 205.303 +      else if (ret == GLP_ENOPFS)
 205.304 +      {  if (parm->msg_lev >= GLP_MSG_ALL)
 205.305 +            xprintf("PROBLEM HAS NO PRIMAL FEASIBLE SOLUTION\n");
 205.306 +      }
 205.307 +      else if (ret == GLP_ENODFS)
 205.308 +      {  if (parm->msg_lev >= GLP_MSG_ALL)
 205.309 +            xprintf("LP RELAXATION HAS NO DUAL FEASIBLE SOLUTION\n");
 205.310 +      }
 205.311 +      else
 205.312 +         xassert(ret != ret);
 205.313 +      if (ret != 0) goto done;
 205.314 +      /* build transformed MIP */
 205.315 +      mip = glp_create_prob();
 205.316 +      npp_build_prob(npp, mip);
 205.317 +      /* if the transformed MIP is empty, it has empty solution, which
 205.318 +         is optimal */
 205.319 +      if (mip->m == 0 && mip->n == 0)
 205.320 +      {  mip->mip_stat = GLP_OPT;
 205.321 +         mip->mip_obj = mip->c0;
 205.322 +         if (parm->msg_lev >= GLP_MSG_ALL)
 205.323 +         {  xprintf("Objective value = %17.9e\n", mip->mip_obj);
 205.324 +            xprintf("INTEGER OPTIMAL SOLUTION FOUND BY MIP PREPROCESSOR"
 205.325 +               "\n");
 205.326 +         }
 205.327 +         goto post;
 205.328 +      }
 205.329 +      /* display some statistics */
 205.330 +      if (parm->msg_lev >= GLP_MSG_ALL)
 205.331 +      {  int ni = glp_get_num_int(mip);
 205.332 +         int nb = glp_get_num_bin(mip);
 205.333 +         char s[50];
 205.334 +         xprintf("%d row%s, %d column%s, %d non-zero%s\n",
 205.335 +            mip->m, mip->m == 1 ? "" : "s", mip->n, mip->n == 1 ? "" :
 205.336 +            "s", mip->nnz, mip->nnz == 1 ? "" : "s");
 205.337 +         if (nb == 0)
 205.338 +            strcpy(s, "none of");
 205.339 +         else if (ni == 1 && nb == 1)
 205.340 +            strcpy(s, "");
 205.341 +         else if (nb == 1)
 205.342 +            strcpy(s, "one of");
 205.343 +         else if (nb == ni)
 205.344 +            strcpy(s, "all of");
 205.345 +         else
 205.346 +            sprintf(s, "%d of", nb);
 205.347 +         xprintf("%d integer variable%s, %s which %s binary\n",
 205.348 +            ni, ni == 1 ? "" : "s", s, nb == 1 ? "is" : "are");
 205.349 +      }
 205.350 +      /* inherit basis factorization control parameters */
 205.351 +      glp_get_bfcp(P, &bfcp);
 205.352 +      glp_set_bfcp(mip, &bfcp);
 205.353 +      /* scale the transformed problem */
 205.354 +      if (!term_out || parm->msg_lev < GLP_MSG_ALL)
 205.355 +         env->term_out = GLP_OFF;
 205.356 +      else
 205.357 +         env->term_out = GLP_ON;
 205.358 +      glp_scale_prob(mip,
 205.359 +         GLP_SF_GM | GLP_SF_EQ | GLP_SF_2N | GLP_SF_SKIP);
 205.360 +      env->term_out = term_out;
 205.361 +      /* build advanced initial basis */
 205.362 +      if (!term_out || parm->msg_lev < GLP_MSG_ALL)
 205.363 +         env->term_out = GLP_OFF;
 205.364 +      else
 205.365 +         env->term_out = GLP_ON;
 205.366 +      glp_adv_basis(mip, 0);
 205.367 +      env->term_out = term_out;
 205.368 +      /* solve initial LP relaxation */
 205.369 +      if (parm->msg_lev >= GLP_MSG_ALL)
 205.370 +         xprintf("Solving LP relaxation...\n");
 205.371 +      glp_init_smcp(&smcp);
 205.372 +      smcp.msg_lev = parm->msg_lev;
 205.373 +      mip->it_cnt = P->it_cnt;
 205.374 +      ret = glp_simplex(mip, &smcp);
 205.375 +      P->it_cnt = mip->it_cnt;
 205.376 +      if (ret != 0)
 205.377 +      {  if (parm->msg_lev >= GLP_MSG_ERR)
 205.378 +            xprintf("glp_intopt: cannot solve LP relaxation\n");
 205.379 +         ret = GLP_EFAIL;
 205.380 +         goto done;
 205.381 +      }
 205.382 +      /* check status of the basic solution */
 205.383 +      ret = glp_get_status(mip);
 205.384 +      if (ret == GLP_OPT)
 205.385 +         ret = 0;
 205.386 +      else if (ret == GLP_NOFEAS)
 205.387 +         ret = GLP_ENOPFS;
 205.388 +      else if (ret == GLP_UNBND)
 205.389 +         ret = GLP_ENODFS;
 205.390 +      else
 205.391 +         xassert(ret != ret);
 205.392 +      if (ret != 0) goto done;
 205.393 +      /* solve the transformed MIP */
 205.394 +      mip->it_cnt = P->it_cnt;
 205.395 +      ret = solve_mip(mip, parm);
 205.396 +      P->it_cnt = mip->it_cnt;
 205.397 +      /* only integer feasible solution can be postprocessed */
 205.398 +      if (!(mip->mip_stat == GLP_OPT || mip->mip_stat == GLP_FEAS))
 205.399 +      {  P->mip_stat = mip->mip_stat;
 205.400 +         goto done;
 205.401 +      }
 205.402 +      /* postprocess solution from the transformed MIP */
 205.403 +post: npp_postprocess(npp, mip);
 205.404 +      /* the transformed MIP is no longer needed */
 205.405 +      glp_delete_prob(mip), mip = NULL;
 205.406 +      /* store solution to the original problem */
 205.407 +      npp_unload_sol(npp, P);
 205.408 +done: /* delete the transformed MIP, if it exists */
 205.409 +      if (mip != NULL) glp_delete_prob(mip);
 205.410 +      /* delete preprocessor workspace */
 205.411 +      npp_delete_wksp(npp);
 205.412 +      return ret;
 205.413 +}
 205.414 +
 205.415 +#ifndef HAVE_ALIEN_SOLVER /* 28/V-2010 */
 205.416 +int _glp_intopt1(glp_prob *P, const glp_iocp *parm)
 205.417 +{     xassert(P == P);
 205.418 +      xassert(parm == parm);
 205.419 +      xprintf("glp_intopt: no alien solver is available\n");
 205.420 +      return GLP_EFAIL;
 205.421 +}
 205.422 +#endif
 205.423 +
 205.424 +int glp_intopt(glp_prob *P, const glp_iocp *parm)
 205.425 +{     /* solve MIP problem with the branch-and-bound method */
 205.426 +      glp_iocp _parm;
 205.427 +      int i, j, ret;
 205.428 +      /* check problem object */
 205.429 +      if (P == NULL || P->magic != GLP_PROB_MAGIC)
 205.430 +         xerror("glp_intopt: P = %p; invalid problem object\n", P);
 205.431 +      if (P->tree != NULL)
 205.432 +         xerror("glp_intopt: operation not allowed\n");
 205.433 +      /* check control parameters */
 205.434 +      if (parm == NULL)
 205.435 +         parm = &_parm, glp_init_iocp((glp_iocp *)parm);
 205.436 +      if (!(parm->msg_lev == GLP_MSG_OFF ||
 205.437 +            parm->msg_lev == GLP_MSG_ERR ||
 205.438 +            parm->msg_lev == GLP_MSG_ON  ||
 205.439 +            parm->msg_lev == GLP_MSG_ALL ||
 205.440 +            parm->msg_lev == GLP_MSG_DBG))
 205.441 +         xerror("glp_intopt: msg_lev = %d; invalid parameter\n",
 205.442 +            parm->msg_lev);
 205.443 +      if (!(parm->br_tech == GLP_BR_FFV ||
 205.444 +            parm->br_tech == GLP_BR_LFV ||
 205.445 +            parm->br_tech == GLP_BR_MFV ||
 205.446 +            parm->br_tech == GLP_BR_DTH ||
 205.447 +            parm->br_tech == GLP_BR_PCH))
 205.448 +         xerror("glp_intopt: br_tech = %d; invalid parameter\n",
 205.449 +            parm->br_tech);
 205.450 +      if (!(parm->bt_tech == GLP_BT_DFS ||
 205.451 +            parm->bt_tech == GLP_BT_BFS ||
 205.452 +            parm->bt_tech == GLP_BT_BLB ||
 205.453 +            parm->bt_tech == GLP_BT_BPH))
 205.454 +         xerror("glp_intopt: bt_tech = %d; invalid parameter\n",
 205.455 +            parm->bt_tech);
 205.456 +      if (!(0.0 < parm->tol_int && parm->tol_int < 1.0))
 205.457 +         xerror("glp_intopt: tol_int = %g; invalid parameter\n",
 205.458 +            parm->tol_int);
 205.459 +      if (!(0.0 < parm->tol_obj && parm->tol_obj < 1.0))
 205.460 +         xerror("glp_intopt: tol_obj = %g; invalid parameter\n",
 205.461 +            parm->tol_obj);
 205.462 +      if (parm->tm_lim < 0)
 205.463 +         xerror("glp_intopt: tm_lim = %d; invalid parameter\n",
 205.464 +            parm->tm_lim);
 205.465 +      if (parm->out_frq < 0)
 205.466 +         xerror("glp_intopt: out_frq = %d; invalid parameter\n",
 205.467 +            parm->out_frq);
 205.468 +      if (parm->out_dly < 0)
 205.469 +         xerror("glp_intopt: out_dly = %d; invalid parameter\n",
 205.470 +            parm->out_dly);
 205.471 +      if (!(0 <= parm->cb_size && parm->cb_size <= 256))
 205.472 +         xerror("glp_intopt: cb_size = %d; invalid parameter\n",
 205.473 +            parm->cb_size);
 205.474 +      if (!(parm->pp_tech == GLP_PP_NONE ||
 205.475 +            parm->pp_tech == GLP_PP_ROOT ||
 205.476 +            parm->pp_tech == GLP_PP_ALL))
 205.477 +         xerror("glp_intopt: pp_tech = %d; invalid parameter\n",
 205.478 +            parm->pp_tech);
 205.479 +      if (parm->mip_gap < 0.0)
 205.480 +         xerror("glp_intopt: mip_gap = %g; invalid parameter\n",
 205.481 +            parm->mip_gap);
 205.482 +      if (!(parm->mir_cuts == GLP_ON || parm->mir_cuts == GLP_OFF))
 205.483 +         xerror("glp_intopt: mir_cuts = %d; invalid parameter\n",
 205.484 +            parm->mir_cuts);
 205.485 +      if (!(parm->gmi_cuts == GLP_ON || parm->gmi_cuts == GLP_OFF))
 205.486 +         xerror("glp_intopt: gmi_cuts = %d; invalid parameter\n",
 205.487 +            parm->gmi_cuts);
 205.488 +      if (!(parm->cov_cuts == GLP_ON || parm->cov_cuts == GLP_OFF))
 205.489 +         xerror("glp_intopt: cov_cuts = %d; invalid parameter\n",
 205.490 +            parm->cov_cuts);
 205.491 +      if (!(parm->clq_cuts == GLP_ON || parm->clq_cuts == GLP_OFF))
 205.492 +         xerror("glp_intopt: clq_cuts = %d; invalid parameter\n",
 205.493 +            parm->clq_cuts);
 205.494 +      if (!(parm->presolve == GLP_ON || parm->presolve == GLP_OFF))
 205.495 +         xerror("glp_intopt: presolve = %d; invalid parameter\n",
 205.496 +            parm->presolve);
 205.497 +      if (!(parm->binarize == GLP_ON || parm->binarize == GLP_OFF))
 205.498 +         xerror("glp_intopt: binarize = %d; invalid parameter\n",
 205.499 +            parm->binarize);
 205.500 +      if (!(parm->fp_heur == GLP_ON || parm->fp_heur == GLP_OFF))
 205.501 +         xerror("glp_intopt: fp_heur = %d; invalid parameter\n",
 205.502 +            parm->fp_heur);
 205.503 +#if 1 /* 28/V-2010 */
 205.504 +      if (!(parm->alien == GLP_ON || parm->alien == GLP_OFF))
 205.505 +         xerror("glp_intopt: alien = %d; invalid parameter\n",
 205.506 +            parm->alien);
 205.507 +#endif
 205.508 +      /* integer solution is currently undefined */
 205.509 +      P->mip_stat = GLP_UNDEF;
 205.510 +      P->mip_obj = 0.0;
 205.511 +      /* check bounds of double-bounded variables */
 205.512 +      for (i = 1; i <= P->m; i++)
 205.513 +      {  GLPROW *row = P->row[i];
 205.514 +         if (row->type == GLP_DB && row->lb >= row->ub)
 205.515 +         {  if (parm->msg_lev >= GLP_MSG_ERR)
 205.516 +               xprintf("glp_intopt: row %d: lb = %g, ub = %g; incorrect"
 205.517 +                  " bounds\n", i, row->lb, row->ub);
 205.518 +            ret = GLP_EBOUND;
 205.519 +            goto done;
 205.520 +         }
 205.521 +      }
 205.522 +      for (j = 1; j <= P->n; j++)
 205.523 +      {  GLPCOL *col = P->col[j];
 205.524 +         if (col->type == GLP_DB && col->lb >= col->ub)
 205.525 +         {  if (parm->msg_lev >= GLP_MSG_ERR)
 205.526 +               xprintf("glp_intopt: column %d: lb = %g, ub = %g; incorr"
 205.527 +                  "ect bounds\n", j, col->lb, col->ub);
 205.528 +            ret = GLP_EBOUND;
 205.529 +            goto done;
 205.530 +         }
 205.531 +      }
 205.532 +      /* bounds of all integer variables must be integral */
 205.533 +      for (j = 1; j <= P->n; j++)
 205.534 +      {  GLPCOL *col = P->col[j];
 205.535 +         if (col->kind != GLP_IV) continue;
 205.536 +         if (col->type == GLP_LO || col->type == GLP_DB)
 205.537 +         {  if (col->lb != floor(col->lb))
 205.538 +            {  if (parm->msg_lev >= GLP_MSG_ERR)
 205.539 +                  xprintf("glp_intopt: integer column %d has non-intege"
 205.540 +                     "r lower bound %g\n", j, col->lb);
 205.541 +               ret = GLP_EBOUND;
 205.542 +               goto done;
 205.543 +            }
 205.544 +         }
 205.545 +         if (col->type == GLP_UP || col->type == GLP_DB)
 205.546 +         {  if (col->ub != floor(col->ub))
 205.547 +            {  if (parm->msg_lev >= GLP_MSG_ERR)
 205.548 +                  xprintf("glp_intopt: integer column %d has non-intege"
 205.549 +                     "r upper bound %g\n", j, col->ub);
 205.550 +               ret = GLP_EBOUND;
 205.551 +               goto done;
 205.552 +            }
 205.553 +         }
 205.554 +         if (col->type == GLP_FX)
 205.555 +         {  if (col->lb != floor(col->lb))
 205.556 +            {  if (parm->msg_lev >= GLP_MSG_ERR)
 205.557 +                  xprintf("glp_intopt: integer column %d has non-intege"
 205.558 +                     "r fixed value %g\n", j, col->lb);
 205.559 +               ret = GLP_EBOUND;
 205.560 +               goto done;
 205.561 +            }
 205.562 +         }
 205.563 +      }
 205.564 +      /* solve MIP problem */
 205.565 +      if (parm->msg_lev >= GLP_MSG_ALL)
 205.566 +      {  int ni = glp_get_num_int(P);
 205.567 +         int nb = glp_get_num_bin(P);
 205.568 +         char s[50];
 205.569 +         xprintf("GLPK Integer Optimizer, v%s\n", glp_version());
 205.570 +         xprintf("%d row%s, %d column%s, %d non-zero%s\n",
 205.571 +            P->m, P->m == 1 ? "" : "s", P->n, P->n == 1 ? "" : "s",
 205.572 +            P->nnz, P->nnz == 1 ? "" : "s");
 205.573 +         if (nb == 0)
 205.574 +            strcpy(s, "none of");
 205.575 +         else if (ni == 1 && nb == 1)
 205.576 +            strcpy(s, "");
 205.577 +         else if (nb == 1)
 205.578 +            strcpy(s, "one of");
 205.579 +         else if (nb == ni)
 205.580 +            strcpy(s, "all of");
 205.581 +         else
 205.582 +            sprintf(s, "%d of", nb);
 205.583 +         xprintf("%d integer variable%s, %s which %s binary\n",
 205.584 +            ni, ni == 1 ? "" : "s", s, nb == 1 ? "is" : "are");
 205.585 +      }
 205.586 +#if 1 /* 28/V-2010 */
 205.587 +      if (parm->alien)
 205.588 +      {  /* use alien integer optimizer */
 205.589 +         ret = _glp_intopt1(P, parm);
 205.590 +         goto done;
 205.591 +      }
 205.592 +#endif
 205.593 +      if (!parm->presolve)
 205.594 +         ret = solve_mip(P, parm);
 205.595 +      else
 205.596 +         ret = preprocess_and_solve_mip(P, parm);
 205.597 +done: /* return to the application program */
 205.598 +      return ret;
 205.599 +}
 205.600 +
 205.601 +/***********************************************************************
 205.602 +*  NAME
 205.603 +*
 205.604 +*  glp_init_iocp - initialize integer optimizer control parameters
 205.605 +*
 205.606 +*  SYNOPSIS
 205.607 +*
 205.608 +*  void glp_init_iocp(glp_iocp *parm);
 205.609 +*
 205.610 +*  DESCRIPTION
 205.611 +*
 205.612 +*  The routine glp_init_iocp initializes control parameters, which are
 205.613 +*  used by the integer optimizer, with default values.
 205.614 +*
 205.615 +*  Default values of the control parameters are stored in a glp_iocp
 205.616 +*  structure, which the parameter parm points to. */
 205.617 +
 205.618 +void glp_init_iocp(glp_iocp *parm)
 205.619 +{     parm->msg_lev = GLP_MSG_ALL;
 205.620 +      parm->br_tech = GLP_BR_DTH;
 205.621 +      parm->bt_tech = GLP_BT_BLB;
 205.622 +      parm->tol_int = 1e-5;
 205.623 +      parm->tol_obj = 1e-7;
 205.624 +      parm->tm_lim = INT_MAX;
 205.625 +      parm->out_frq = 5000;
 205.626 +      parm->out_dly = 10000;
 205.627 +      parm->cb_func = NULL;
 205.628 +      parm->cb_info = NULL;
 205.629 +      parm->cb_size = 0;
 205.630 +      parm->pp_tech = GLP_PP_ALL;
 205.631 +      parm->mip_gap = 0.0;
 205.632 +      parm->mir_cuts = GLP_OFF;
 205.633 +      parm->gmi_cuts = GLP_OFF;
 205.634 +      parm->cov_cuts = GLP_OFF;
 205.635 +      parm->clq_cuts = GLP_OFF;
 205.636 +      parm->presolve = GLP_OFF;
 205.637 +      parm->binarize = GLP_OFF;
 205.638 +      parm->fp_heur = GLP_OFF;
 205.639 +#if 1 /* 28/V-2010 */
 205.640 +      parm->alien = GLP_OFF;
 205.641 +#endif
 205.642 +      return;
 205.643 +}
 205.644 +
 205.645 +/***********************************************************************
 205.646 +*  NAME
 205.647 +*
 205.648 +*  glp_mip_status - retrieve status of MIP solution
 205.649 +*
 205.650 +*  SYNOPSIS
 205.651 +*
 205.652 +*  int glp_mip_status(glp_prob *mip);
 205.653 +*
 205.654 +*  RETURNS
 205.655 +*
 205.656 +*  The routine lpx_mip_status reports the status of MIP solution found
 205.657 +*  by the branch-and-bound solver as follows:
 205.658 +*
 205.659 +*  GLP_UNDEF  - MIP solution is undefined;
 205.660 +*  GLP_OPT    - MIP solution is integer optimal;
 205.661 +*  GLP_FEAS   - MIP solution is integer feasible but its optimality
 205.662 +*               (or non-optimality) has not been proven, perhaps due to
 205.663 +*               premature termination of the search;
 205.664 +*  GLP_NOFEAS - problem has no integer feasible solution (proven by the
 205.665 +*               solver). */
 205.666 +
 205.667 +int glp_mip_status(glp_prob *mip)
 205.668 +{     int mip_stat = mip->mip_stat;
 205.669 +      return mip_stat;
 205.670 +}
 205.671 +
 205.672 +/***********************************************************************
 205.673 +*  NAME
 205.674 +*
 205.675 +*  glp_mip_obj_val - retrieve objective value (MIP solution)
 205.676 +*
 205.677 +*  SYNOPSIS
 205.678 +*
 205.679 +*  double glp_mip_obj_val(glp_prob *mip);
 205.680 +*
 205.681 +*  RETURNS
 205.682 +*
 205.683 +*  The routine glp_mip_obj_val returns value of the objective function
 205.684 +*  for MIP solution. */
 205.685 +
 205.686 +double glp_mip_obj_val(glp_prob *mip)
 205.687 +{     /*struct LPXCPS *cps = mip->cps;*/
 205.688 +      double z;
 205.689 +      z = mip->mip_obj;
 205.690 +      /*if (cps->round && fabs(z) < 1e-9) z = 0.0;*/
 205.691 +      return z;
 205.692 +}
 205.693 +
 205.694 +/***********************************************************************
 205.695 +*  NAME
 205.696 +*
 205.697 +*  glp_mip_row_val - retrieve row value (MIP solution)
 205.698 +*
 205.699 +*  SYNOPSIS
 205.700 +*
 205.701 +*  double glp_mip_row_val(glp_prob *mip, int i);
 205.702 +*
 205.703 +*  RETURNS
 205.704 +*
 205.705 +*  The routine glp_mip_row_val returns value of the auxiliary variable
 205.706 +*  associated with i-th row. */
 205.707 +
 205.708 +double glp_mip_row_val(glp_prob *mip, int i)
 205.709 +{     /*struct LPXCPS *cps = mip->cps;*/
 205.710 +      double mipx;
 205.711 +      if (!(1 <= i && i <= mip->m))
 205.712 +         xerror("glp_mip_row_val: i = %d; row number out of range\n", i)
 205.713 +            ;
 205.714 +      mipx = mip->row[i]->mipx;
 205.715 +      /*if (cps->round && fabs(mipx) < 1e-9) mipx = 0.0;*/
 205.716 +      return mipx;
 205.717 +}
 205.718 +
 205.719 +/***********************************************************************
 205.720 +*  NAME
 205.721 +*
 205.722 +*  glp_mip_col_val - retrieve column value (MIP solution)
 205.723 +*
 205.724 +*  SYNOPSIS
 205.725 +*
 205.726 +*  double glp_mip_col_val(glp_prob *mip, int j);
 205.727 +*
 205.728 +*  RETURNS
 205.729 +*
 205.730 +*  The routine glp_mip_col_val returns value of the structural variable
 205.731 +*  associated with j-th column. */
 205.732 +
 205.733 +double glp_mip_col_val(glp_prob *mip, int j)
 205.734 +{     /*struct LPXCPS *cps = mip->cps;*/
 205.735 +      double mipx;
 205.736 +      if (!(1 <= j && j <= mip->n))
 205.737 +         xerror("glp_mip_col_val: j = %d; column number out of range\n",
 205.738 +            j);
 205.739 +      mipx = mip->col[j]->mipx;
 205.740 +      /*if (cps->round && fabs(mipx) < 1e-9) mipx = 0.0;*/
 205.741 +      return mipx;
 205.742 +}
 205.743 +
 205.744 +/* eof */
   206.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
   206.2 +++ b/deps/glpk/src/glpapi10.c	Sun Nov 06 20:59:10 2011 +0100
   206.3 @@ -0,0 +1,282 @@
   206.4 +/* glpapi10.c (solution checking routines) */
   206.5 +
   206.6 +/***********************************************************************
   206.7 +*  This code is part of GLPK (GNU Linear Programming Kit).
   206.8 +*
   206.9 +*  Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008,
  206.10 +*  2009, 2010, 2011 Andrew Makhorin, Department for Applied Informatics,
  206.11 +*  Moscow Aviation Institute, Moscow, Russia. All rights reserved.
  206.12 +*  E-mail: <mao@gnu.org>.
  206.13 +*
  206.14 +*  GLPK is free software: you can redistribute it and/or modify it
  206.15 +*  under the terms of the GNU General Public License as published by
  206.16 +*  the Free Software Foundation, either version 3 of the License, or
  206.17 +*  (at your option) any later version.
  206.18 +*
  206.19 +*  GLPK is distributed in the hope that it will be useful, but WITHOUT
  206.20 +*  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
  206.21 +*  or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
  206.22 +*  License for more details.
  206.23 +*
  206.24 +*  You should have received a copy of the GNU General Public License
  206.25 +*  along with GLPK. If not, see <http://www.gnu.org/licenses/>.
  206.26 +***********************************************************************/
  206.27 +
  206.28 +#include "glpapi.h"
  206.29 +
  206.30 +void _glp_check_kkt(glp_prob *P, int sol, int cond, double *_ae_max,
  206.31 +      int *_ae_ind, double *_re_max, int *_re_ind)
  206.32 +{     /* check feasibility and optimality conditions */
  206.33 +      int m = P->m;
  206.34 +      int n = P->n;
  206.35 +      GLPROW *row;
  206.36 +      GLPCOL *col;
  206.37 +      GLPAIJ *aij;
  206.38 +      int i, j, ae_ind, re_ind;
  206.39 +      double e, sp, sn, t, ae_max, re_max;
  206.40 +      if (!(sol == GLP_SOL || sol == GLP_IPT || sol == GLP_MIP))
  206.41 +         xerror("glp_check_kkt: sol = %d; invalid solution indicator\n",
  206.42 +            sol);
  206.43 +      if (!(cond == GLP_KKT_PE || cond == GLP_KKT_PB ||
  206.44 +            cond == GLP_KKT_DE || cond == GLP_KKT_DB ||
  206.45 +            cond == GLP_KKT_CS))
  206.46 +         xerror("glp_check_kkt: cond = %d; invalid condition indicator "
  206.47 +            "\n", cond);
  206.48 +      ae_max = re_max = 0.0;
  206.49 +      ae_ind = re_ind = 0;
  206.50 +      if (cond == GLP_KKT_PE)
  206.51 +      {  /* xR - A * xS = 0 */
  206.52 +         for (i = 1; i <= m; i++)
  206.53 +         {  row = P->row[i];
  206.54 +            sp = sn = 0.0;
  206.55 +            /* t := xR[i] */
  206.56 +            if (sol == GLP_SOL)
  206.57 +               t = row->prim;
  206.58 +            else if (sol == GLP_IPT)
  206.59 +               t = row->pval;
  206.60 +            else if (sol == GLP_MIP)
  206.61 +               t = row->mipx;
  206.62 +            else
  206.63 +               xassert(sol != sol);
  206.64 +            if (t >= 0.0) sp += t; else sn -= t;
  206.65 +            for (aij = row->ptr; aij != NULL; aij = aij->r_next)
  206.66 +            {  col = aij->col;
  206.67 +               /* t := - a[i,j] * xS[j] */
  206.68 +               if (sol == GLP_SOL)
  206.69 +                  t = - aij->val * col->prim;
  206.70 +               else if (sol == GLP_IPT)
  206.71 +                  t = - aij->val * col->pval;
  206.72 +               else if (sol == GLP_MIP)
  206.73 +                  t = - aij->val * col->mipx;
  206.74 +               else
  206.75 +                  xassert(sol != sol);
  206.76 +               if (t >= 0.0) sp += t; else sn -= t;
  206.77 +            }
  206.78 +            /* absolute error */
  206.79 +            e = fabs(sp - sn);
  206.80 +            if (ae_max < e)
  206.81 +               ae_max = e, ae_ind = i;
  206.82 +            /* relative error */
  206.83 +            e /= (1.0 + sp + sn);
  206.84 +            if (re_max < e)
  206.85 +               re_max = e, re_ind = i;
  206.86 +         }
  206.87 +      }
  206.88 +      else if (cond == GLP_KKT_PB)
  206.89 +      {  /* lR <= xR <= uR */
  206.90 +         for (i = 1; i <= m; i++)
  206.91 +         {  row = P->row[i];
  206.92 +            /* t := xR[i] */
  206.93 +            if (sol == GLP_SOL)
  206.94 +               t = row->prim;
  206.95 +            else if (sol == GLP_IPT)
  206.96 +               t = row->pval;
  206.97 +            else if (sol == GLP_MIP)
  206.98 +               t = row->mipx;
  206.99 +            else
 206.100 +               xassert(sol != sol);
 206.101 +            /* check lower bound */
 206.102 +            if (row->type == GLP_LO || row->type == GLP_DB ||
 206.103 +                row->type == GLP_FX)
 206.104 +            {  if (t < row->lb)
 206.105 +               {  /* absolute error */
 206.106 +                  e = row->lb - t;
 206.107 +                  if (ae_max < e)
 206.108 +                     ae_max = e, ae_ind = i;
 206.109 +                  /* relative error */
 206.110 +                  e /= (1.0 + fabs(row->lb));
 206.111 +                  if (re_max < e)
 206.112 +                     re_max = e, re_ind = i;
 206.113 +               }
 206.114 +            }
 206.115 +            /* check upper bound */
 206.116 +            if (row->type == GLP_UP || row->type == GLP_DB ||
 206.117 +                row->type == GLP_FX)
 206.118 +            {  if (t > row->ub)
 206.119 +               {  /* absolute error */
 206.120 +                  e = t - row->ub;
 206.121 +                  if (ae_max < e)
 206.122 +                     ae_max = e, ae_ind = i;
 206.123 +                  /* relative error */
 206.124 +                  e /= (1.0 + fabs(row->ub));
 206.125 +                  if (re_max < e)
 206.126 +                     re_max = e, re_ind = i;
 206.127 +               }
 206.128 +            }
 206.129 +         }
 206.130 +         /* lS <= xS <= uS */
 206.131 +         for (j = 1; j <= n; j++)
 206.132 +         {  col = P->col[j];
 206.133 +            /* t := xS[j] */
 206.134 +            if (sol == GLP_SOL)
 206.135 +               t = col->prim;
 206.136 +            else if (sol == GLP_IPT)
 206.137 +               t = col->pval;
 206.138 +            else if (sol == GLP_MIP)
 206.139 +               t = col->mipx;
 206.140 +            else
 206.141 +               xassert(sol != sol);
 206.142 +            /* check lower bound */
 206.143 +            if (col->type == GLP_LO || col->type == GLP_DB ||
 206.144 +                col->type == GLP_FX)
 206.145 +            {  if (t < col->lb)
 206.146 +               {  /* absolute error */
 206.147 +                  e = col->lb - t;
 206.148 +                  if (ae_max < e)
 206.149 +                     ae_max = e, ae_ind = m+j;
 206.150 +                  /* relative error */
 206.151 +                  e /= (1.0 + fabs(col->lb));
 206.152 +                  if (re_max < e)
 206.153 +                     re_max = e, re_ind = m+j;
 206.154 +               }
 206.155 +            }
 206.156 +            /* check upper bound */
 206.157 +            if (col->type == GLP_UP || col->type == GLP_DB ||
 206.158 +                col->type == GLP_FX)
 206.159 +            {  if (t > col->ub)
 206.160 +               {  /* absolute error */
 206.161 +                  e = t - col->ub;
 206.162 +                  if (ae_max < e)
 206.163 +                     ae_max = e, ae_ind = m+j;
 206.164 +                  /* relative error */
 206.165 +                  e /= (1.0 + fabs(col->ub));
 206.166 +                  if (re_max < e)
 206.167 +                     re_max = e, re_ind = m+j;
 206.168 +               }
 206.169 +            }
 206.170 +         }
 206.171 +      }
 206.172 +      else if (cond == GLP_KKT_DE)
 206.173 +      {  /* A' * (lambdaR - cR) + (lambdaS - cS) = 0 */
 206.174 +         for (j = 1; j <= n; j++)
 206.175 +         {  col = P->col[j];
 206.176 +            sp = sn = 0.0;
 206.177 +            /* t := lambdaS[j] - cS[j] */
 206.178 +            if (sol == GLP_SOL)
 206.179 +               t = col->dual - col->coef;
 206.180 +            else if (sol == GLP_IPT)
 206.181 +               t = col->dval - col->coef;
 206.182 +            else
 206.183 +               xassert(sol != sol);
 206.184 +            if (t >= 0.0) sp += t; else sn -= t;
 206.185 +            for (aij = col->ptr; aij != NULL; aij = aij->c_next)
 206.186 +            {  row = aij->row;
 206.187 +               /* t := a[i,j] * (lambdaR[i] - cR[i]) */
 206.188 +               if (sol == GLP_SOL)
 206.189 +                  t = aij->val * row->dual;
 206.190 +               else if (sol == GLP_IPT)
 206.191 +                  t = aij->val * row->dval;
 206.192 +               else
 206.193 +                  xassert(sol != sol);
 206.194 +               if (t >= 0.0) sp += t; else sn -= t;
 206.195 +            }
 206.196 +            /* absolute error */
 206.197 +            e = fabs(sp - sn);
 206.198 +            if (ae_max < e)
 206.199 +               ae_max = e, ae_ind = m+j;
 206.200 +            /* relative error */
 206.201 +            e /= (1.0 + sp + sn);
 206.202 +            if (re_max < e)
 206.203 +               re_max = e, re_ind = m+j;
 206.204 +         }
 206.205 +      }
 206.206 +      else if (cond == GLP_KKT_DB)
 206.207 +      {  /* check lambdaR */
 206.208 +         for (i = 1; i <= m; i++)
 206.209 +         {  row = P->row[i];
 206.210 +            /* t := lambdaR[i] */
 206.211 +            if (sol == GLP_SOL)
 206.212 +               t = row->dual;
 206.213 +            else if (sol == GLP_IPT)
 206.214 +               t = row->dval;
 206.215 +            else
 206.216 +               xassert(sol != sol);
 206.217 +            /* correct sign */
 206.218 +            if (P->dir == GLP_MIN)
 206.219 +               t = + t;
 206.220 +            else if (P->dir == GLP_MAX)
 206.221 +               t = - t;
 206.222 +            else
 206.223 +               xassert(P != P);
 206.224 +            /* check for positivity */
 206.225 +            if (row->type == GLP_FR || row->type == GLP_LO)
 206.226 +            {  if (t < 0.0)
 206.227 +               {  e = - t;
 206.228 +                  if (ae_max < e)
 206.229 +                     ae_max = re_max = e, ae_ind = re_ind = i;
 206.230 +               }
 206.231 +            }
 206.232 +            /* check for negativity */
 206.233 +            if (row->type == GLP_FR || row->type == GLP_UP)
 206.234 +            {  if (t > 0.0)
 206.235 +               {  e = + t;
 206.236 +                  if (ae_max < e)
 206.237 +                     ae_max = re_max = e, ae_ind = re_ind = i;
 206.238 +               }
 206.239 +            }
 206.240 +         }
 206.241 +         /* check lambdaS */
 206.242 +         for (j = 1; j <= n; j++)
 206.243 +         {  col = P->col[j];
 206.244 +            /* t := lambdaS[j] */
 206.245 +            if (sol == GLP_SOL)
 206.246 +               t = col->dual;
 206.247 +            else if (sol == GLP_IPT)
 206.248 +               t = col->dval;
 206.249 +            else
 206.250 +               xassert(sol != sol);
 206.251 +            /* correct sign */
 206.252 +            if (P->dir == GLP_MIN)
 206.253 +               t = + t;
 206.254 +            else if (P->dir == GLP_MAX)
 206.255 +               t = - t;
 206.256 +            else
 206.257 +               xassert(P != P);
 206.258 +            /* check for positivity */
 206.259 +            if (col->type == GLP_FR || col->type == GLP_LO)
 206.260 +            {  if (t < 0.0)
 206.261 +               {  e = - t;
 206.262 +                  if (ae_max < e)
 206.263 +                     ae_max = re_max = e, ae_ind = re_ind = m+j;
 206.264 +               }
 206.265 +            }
 206.266 +            /* check for negativity */
 206.267 +            if (col->type == GLP_FR || col->type == GLP_UP)
 206.268 +            {  if (t > 0.0)
 206.269 +               {  e = + t;
 206.270 +                  if (ae_max < e)
 206.271 +                     ae_max = re_max = e, ae_ind = re_ind = m+j;
 206.272 +               }
 206.273 +            }
 206.274 +         }
 206.275 +      }
 206.276 +      else
 206.277 +         xassert(cond != cond);
 206.278 +      if (_ae_max != NULL) *_ae_max = ae_max;
 206.279 +      if (_ae_ind != NULL) *_ae_ind = ae_ind;
 206.280 +      if (_re_max != NULL) *_re_max = re_max;
 206.281 +      if (_re_ind != NULL) *_re_ind = re_ind;
 206.282 +      return;
 206.283 +}
 206.284 +
 206.285 +/* eof */
   207.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
   207.2 +++ b/deps/glpk/src/glpapi11.c	Sun Nov 06 20:59:10 2011 +0100
   207.3 @@ -0,0 +1,1217 @@
   207.4 +/* glpapi11.c (utility routines) */
   207.5 +
   207.6 +/***********************************************************************
   207.7 +*  This code is part of GLPK (GNU Linear Programming Kit).
   207.8 +*
   207.9 +*  Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008,
  207.10 +*  2009, 2010, 2011 Andrew Makhorin, Department for Applied Informatics,
  207.11 +*  Moscow Aviation Institute, Moscow, Russia. All rights reserved.
  207.12 +*  E-mail: <mao@gnu.org>.
  207.13 +*
  207.14 +*  GLPK is free software: you can redistribute it and/or modify it
  207.15 +*  under the terms of the GNU General Public License as published by
  207.16 +*  the Free Software Foundation, either version 3 of the License, or
  207.17 +*  (at your option) any later version.
  207.18 +*
  207.19 +*  GLPK is distributed in the hope that it will be useful, but WITHOUT
  207.20 +*  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
  207.21 +*  or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
  207.22 +*  License for more details.
  207.23 +*
  207.24 +*  You should have received a copy of the GNU General Public License
  207.25 +*  along with GLPK. If not, see <http://www.gnu.org/licenses/>.
  207.26 +***********************************************************************/
  207.27 +
  207.28 +#include "glpapi.h"
  207.29 +
  207.30 +int glp_print_sol(glp_prob *P, const char *fname)
  207.31 +{     /* write basic solution in printable format */
  207.32 +      XFILE *fp;
  207.33 +      GLPROW *row;
  207.34 +      GLPCOL *col;
  207.35 +      int i, j, t, ae_ind, re_ind, ret;
  207.36 +      double ae_max, re_max;
  207.37 +      xprintf("Writing basic solution to `%s'...\n", fname);
  207.38 +      fp = xfopen(fname, "w");
  207.39 +      if (fp == NULL)
  207.40 +      {  xprintf("Unable to create `%s' - %s\n", fname, xerrmsg());
  207.41 +         ret = 1;
  207.42 +         goto done;
  207.43 +      }
  207.44 +      xfprintf(fp, "%-12s%s\n", "Problem:",
  207.45 +         P->name == NULL ? "" : P->name);
  207.46 +      xfprintf(fp, "%-12s%d\n", "Rows:", P->m);
  207.47 +      xfprintf(fp, "%-12s%d\n", "Columns:", P->n);
  207.48 +      xfprintf(fp, "%-12s%d\n", "Non-zeros:", P->nnz);
  207.49 +      t = glp_get_status(P);
  207.50 +      xfprintf(fp, "%-12s%s\n", "Status:",
  207.51 +         t == GLP_OPT    ? "OPTIMAL" :
  207.52 +         t == GLP_FEAS   ? "FEASIBLE" :
  207.53 +         t == GLP_INFEAS ? "INFEASIBLE (INTERMEDIATE)" :
  207.54 +         t == GLP_NOFEAS ? "INFEASIBLE (FINAL)" :
  207.55 +         t == GLP_UNBND  ? "UNBOUNDED" :
  207.56 +         t == GLP_UNDEF  ? "UNDEFINED" : "???");
  207.57 +      xfprintf(fp, "%-12s%s%s%.10g (%s)\n", "Objective:",
  207.58 +         P->obj == NULL ? "" : P->obj,
  207.59 +         P->obj == NULL ? "" : " = ", P->obj_val,
  207.60 +         P->dir == GLP_MIN ? "MINimum" :
  207.61 +         P->dir == GLP_MAX ? "MAXimum" : "???");
  207.62 +      xfprintf(fp, "\n");
  207.63 +      xfprintf(fp, "   No.   Row name   St   Activity     Lower bound  "
  207.64 +         " Upper bound    Marginal\n");
  207.65 +      xfprintf(fp, "------ ------------ -- ------------- ------------- "
  207.66 +         "------------- -------------\n");
  207.67 +      for (i = 1; i <= P->m; i++)
  207.68 +      {  row = P->row[i];
  207.69 +         xfprintf(fp, "%6d ", i);
  207.70 +         if (row->name == NULL || strlen(row->name) <= 12)
  207.71 +            xfprintf(fp, "%-12s ", row->name == NULL ? "" : row->name);
  207.72 +         else
  207.73 +            xfprintf(fp, "%s\n%20s", row->name, "");
  207.74 +         xfprintf(fp, "%s ",
  207.75 +            row->stat == GLP_BS ? "B " :
  207.76 +            row->stat == GLP_NL ? "NL" :
  207.77 +            row->stat == GLP_NU ? "NU" :
  207.78 +            row->stat == GLP_NF ? "NF" :
  207.79 +            row->stat == GLP_NS ? "NS" : "??");
  207.80 +         xfprintf(fp, "%13.6g ",
  207.81 +            fabs(row->prim) <= 1e-9 ? 0.0 : row->prim);
  207.82 +         if (row->type == GLP_LO || row->type == GLP_DB ||
  207.83 +             row->type == GLP_FX)
  207.84 +            xfprintf(fp, "%13.6g ", row->lb);
  207.85 +         else
  207.86 +            xfprintf(fp, "%13s ", "");
  207.87 +         if (row->type == GLP_UP || row->type == GLP_DB)
  207.88 +            xfprintf(fp, "%13.6g ", row->ub);
  207.89 +         else
  207.90 +            xfprintf(fp, "%13s ", row->type == GLP_FX ? "=" : "");
  207.91 +         if (row->stat != GLP_BS)
  207.92 +         {  if (fabs(row->dual) <= 1e-9)
  207.93 +               xfprintf(fp, "%13s", "< eps");
  207.94 +            else
  207.95 +               xfprintf(fp, "%13.6g ", row->dual);
  207.96 +         }
  207.97 +         xfprintf(fp, "\n");
  207.98 +      }
  207.99 +      xfprintf(fp, "\n");
 207.100 +      xfprintf(fp, "   No. Column name  St   Activity     Lower bound  "
 207.101 +         " Upper bound    Marginal\n");
 207.102 +      xfprintf(fp, "------ ------------ -- ------------- ------------- "
 207.103 +         "------------- -------------\n");
 207.104 +      for (j = 1; j <= P->n; j++)
 207.105 +      {  col = P->col[j];
 207.106 +         xfprintf(fp, "%6d ", j);
 207.107 +         if (col->name == NULL || strlen(col->name) <= 12)
 207.108 +            xfprintf(fp, "%-12s ", col->name == NULL ? "" : col->name);
 207.109 +         else
 207.110 +            xfprintf(fp, "%s\n%20s", col->name, "");
 207.111 +         xfprintf(fp, "%s ",
 207.112 +            col->stat == GLP_BS ? "B " :
 207.113 +            col->stat == GLP_NL ? "NL" :
 207.114 +            col->stat == GLP_NU ? "NU" :
 207.115 +            col->stat == GLP_NF ? "NF" :
 207.116 +            col->stat == GLP_NS ? "NS" : "??");
 207.117 +         xfprintf(fp, "%13.6g ",
 207.118 +            fabs(col->prim) <= 1e-9 ? 0.0 : col->prim);
 207.119 +         if (col->type == GLP_LO || col->type == GLP_DB ||
 207.120 +             col->type == GLP_FX)
 207.121 +            xfprintf(fp, "%13.6g ", col->lb);
 207.122 +         else
 207.123 +            xfprintf(fp, "%13s ", "");
 207.124 +         if (col->type == GLP_UP || col->type == GLP_DB)
 207.125 +            xfprintf(fp, "%13.6g ", col->ub);
 207.126 +         else
 207.127 +            xfprintf(fp, "%13s ", col->type == GLP_FX ? "=" : "");
 207.128 +         if (col->stat != GLP_BS)
 207.129 +         {  if (fabs(col->dual) <= 1e-9)
 207.130 +               xfprintf(fp, "%13s", "< eps");
 207.131 +            else
 207.132 +               xfprintf(fp, "%13.6g ", col->dual);
 207.133 +         }
 207.134 +         xfprintf(fp, "\n");
 207.135 +      }
 207.136 +      xfprintf(fp, "\n");
 207.137 +      xfprintf(fp, "Karush-Kuhn-Tucker optimality conditions:\n");
 207.138 +      xfprintf(fp, "\n");
 207.139 +      _glp_check_kkt(P, GLP_SOL, GLP_KKT_PE, &ae_max, &ae_ind, &re_max,
 207.140 +         &re_ind);
 207.141 +      xfprintf(fp, "KKT.PE: max.abs.err = %.2e on row %d\n",
 207.142 +         ae_max, ae_ind);
 207.143 +      xfprintf(fp, "        max.rel.err = %.2e on row %d\n",
 207.144 +         re_max, re_ind);
 207.145 +      xfprintf(fp, "%8s%s\n", "",
 207.146 +         re_max <= 1e-9 ? "High quality" :
 207.147 +         re_max <= 1e-6 ? "Medium quality" :
 207.148 +         re_max <= 1e-3 ? "Low quality" : "PRIMAL SOLUTION IS WRONG");
 207.149 +      xfprintf(fp, "\n");
 207.150 +      _glp_check_kkt(P, GLP_SOL, GLP_KKT_PB, &ae_max, &ae_ind, &re_max,
 207.151 +         &re_ind);
 207.152 +      xfprintf(fp, "KKT.PB: max.abs.err = %.2e on %s %d\n",
 207.153 +            ae_max, ae_ind <= P->m ? "row" : "column",
 207.154 +            ae_ind <= P->m ? ae_ind : ae_ind - P->m);
 207.155 +      xfprintf(fp, "        max.rel.err = %.2e on %s %d\n",
 207.156 +            re_max, re_ind <= P->m ? "row" : "column",
 207.157 +            re_ind <= P->m ? re_ind : re_ind - P->m);
 207.158 +      xfprintf(fp, "%8s%s\n", "",
 207.159 +         re_max <= 1e-9 ? "High quality" :
 207.160 +         re_max <= 1e-6 ? "Medium quality" :
 207.161 +         re_max <= 1e-3 ? "Low quality" : "PRIMAL SOLUTION IS INFEASIBL"
 207.162 +            "E");
 207.163 +      xfprintf(fp, "\n");
 207.164 +      _glp_check_kkt(P, GLP_SOL, GLP_KKT_DE, &ae_max, &ae_ind, &re_max,
 207.165 +         &re_ind);
 207.166 +      xfprintf(fp, "KKT.DE: max.abs.err = %.2e on column %d\n",
 207.167 +         ae_max, ae_ind == 0 ? 0 : ae_ind - P->m);
 207.168 +      xfprintf(fp, "        max.rel.err = %.2e on column %d\n",
 207.169 +         re_max, re_ind == 0 ? 0 : re_ind - P->m);
 207.170 +      xfprintf(fp, "%8s%s\n", "",
 207.171 +         re_max <= 1e-9 ? "High quality" :
 207.172 +         re_max <= 1e-6 ? "Medium quality" :
 207.173 +         re_max <= 1e-3 ? "Low quality" : "DUAL SOLUTION IS WRONG");
 207.174 +      xfprintf(fp, "\n");
 207.175 +      _glp_check_kkt(P, GLP_SOL, GLP_KKT_DB, &ae_max, &ae_ind, &re_max,
 207.176 +         &re_ind);
 207.177 +      xfprintf(fp, "KKT.DB: max.abs.err = %.2e on %s %d\n",
 207.178 +            ae_max, ae_ind <= P->m ? "row" : "column",
 207.179 +            ae_ind <= P->m ? ae_ind : ae_ind - P->m);
 207.180 +      xfprintf(fp, "        max.rel.err = %.2e on %s %d\n",
 207.181 +            re_max, re_ind <= P->m ? "row" : "column",
 207.182 +            re_ind <= P->m ? re_ind : re_ind - P->m);
 207.183 +      xfprintf(fp, "%8s%s\n", "",
 207.184 +         re_max <= 1e-9 ? "High quality" :
 207.185 +         re_max <= 1e-6 ? "Medium quality" :
 207.186 +         re_max <= 1e-3 ? "Low quality" : "DUAL SOLUTION IS INFEASIBLE")
 207.187 +            ;
 207.188 +      xfprintf(fp, "\n");
 207.189 +      xfprintf(fp, "End of output\n");
 207.190 +      xfflush(fp);
 207.191 +      if (xferror(fp))
 207.192 +      {  xprintf("Write error on `%s' - %s\n", fname, xerrmsg());
 207.193 +         ret = 1;
 207.194 +         goto done;
 207.195 +      }
 207.196 +      ret = 0;
 207.197 +done: if (fp != NULL) xfclose(fp);
 207.198 +      return ret;
 207.199 +}
 207.200 +
 207.201 +/***********************************************************************
 207.202 +*  NAME
 207.203 +*
 207.204 +*  glp_read_sol - read basic solution from text file
 207.205 +*
 207.206 +*  SYNOPSIS
 207.207 +*
 207.208 +*  int glp_read_sol(glp_prob *lp, const char *fname);
 207.209 +*
 207.210 +*  DESCRIPTION
 207.211 +*
 207.212 +*  The routine glp_read_sol reads basic solution from a text file whose
 207.213 +*  name is specified by the parameter fname into the problem object.
 207.214 +*
 207.215 +*  For the file format see description of the routine glp_write_sol.
 207.216 +*
 207.217 +*  RETURNS
 207.218 +*
 207.219 +*  On success the routine returns zero, otherwise non-zero. */
 207.220 +
 207.221 +int glp_read_sol(glp_prob *lp, const char *fname)
 207.222 +{     glp_data *data;
 207.223 +      jmp_buf jump;
 207.224 +      int i, j, k, ret = 0;
 207.225 +      xprintf("Reading basic solution from `%s'...\n", fname);
 207.226 +      data = glp_sdf_open_file(fname);
 207.227 +      if (data == NULL)
 207.228 +      {  ret = 1;
 207.229 +         goto done;
 207.230 +      }
 207.231 +      if (setjmp(jump))
 207.232 +      {  ret = 1;
 207.233 +         goto done;
 207.234 +      }
 207.235 +      glp_sdf_set_jump(data, jump);
 207.236 +      /* number of rows, number of columns */
 207.237 +      k = glp_sdf_read_int(data);
 207.238 +      if (k != lp->m)
 207.239 +         glp_sdf_error(data, "wrong number of rows\n");
 207.240 +      k = glp_sdf_read_int(data);
 207.241 +      if (k != lp->n)
 207.242 +         glp_sdf_error(data, "wrong number of columns\n");
 207.243 +      /* primal status, dual status, objective value */
 207.244 +      k = glp_sdf_read_int(data);
 207.245 +      if (!(k == GLP_UNDEF || k == GLP_FEAS || k == GLP_INFEAS ||
 207.246 +            k == GLP_NOFEAS))
 207.247 +         glp_sdf_error(data, "invalid primal status\n");
 207.248 +      lp->pbs_stat = k;
 207.249 +      k = glp_sdf_read_int(data);
 207.250 +      if (!(k == GLP_UNDEF || k == GLP_FEAS || k == GLP_INFEAS ||
 207.251 +            k == GLP_NOFEAS))
 207.252 +         glp_sdf_error(data, "invalid dual status\n");
 207.253 +      lp->dbs_stat = k;
 207.254 +      lp->obj_val = glp_sdf_read_num(data);
 207.255 +      /* rows (auxiliary variables) */
 207.256 +      for (i = 1; i <= lp->m; i++)
 207.257 +      {  GLPROW *row = lp->row[i];
 207.258 +         /* status, primal value, dual value */
 207.259 +         k = glp_sdf_read_int(data);
 207.260 +         if (!(k == GLP_BS || k == GLP_NL || k == GLP_NU ||
 207.261 +               k == GLP_NF || k == GLP_NS))
 207.262 +            glp_sdf_error(data, "invalid row status\n");
 207.263 +         glp_set_row_stat(lp, i, k);
 207.264 +         row->prim = glp_sdf_read_num(data);
 207.265 +         row->dual = glp_sdf_read_num(data);
 207.266 +      }
 207.267 +      /* columns (structural variables) */
 207.268 +      for (j = 1; j <= lp->n; j++)
 207.269 +      {  GLPCOL *col = lp->col[j];
 207.270 +         /* status, primal value, dual value */
 207.271 +         k = glp_sdf_read_int(data);
 207.272 +         if (!(k == GLP_BS || k == GLP_NL || k == GLP_NU ||
 207.273 +               k == GLP_NF || k == GLP_NS))
 207.274 +            glp_sdf_error(data, "invalid column status\n");
 207.275 +         glp_set_col_stat(lp, j, k);
 207.276 +         col->prim = glp_sdf_read_num(data);
 207.277 +         col->dual = glp_sdf_read_num(data);
 207.278 +      }
 207.279 +      xprintf("%d lines were read\n", glp_sdf_line(data));
 207.280 +done: if (ret) lp->pbs_stat = lp->dbs_stat = GLP_UNDEF;
 207.281 +      if (data != NULL) glp_sdf_close_file(data);
 207.282 +      return ret;
 207.283 +}
 207.284 +
 207.285 +/***********************************************************************
 207.286 +*  NAME
 207.287 +*
 207.288 +*  glp_write_sol - write basic solution to text file
 207.289 +*
 207.290 +*  SYNOPSIS
 207.291 +*
 207.292 +*  int glp_write_sol(glp_prob *lp, const char *fname);
 207.293 +*
 207.294 +*  DESCRIPTION
 207.295 +*
 207.296 +*  The routine glp_write_sol writes the current basic solution to a
 207.297 +*  text file whose name is specified by the parameter fname. This file
 207.298 +*  can be read back with the routine glp_read_sol.
 207.299 +*
 207.300 +*  RETURNS
 207.301 +*
 207.302 +*  On success the routine returns zero, otherwise non-zero.
 207.303 +*
 207.304 +*  FILE FORMAT
 207.305 +*
 207.306 +*  The file created by the routine glp_write_sol is a plain text file,
 207.307 +*  which contains the following information:
 207.308 +*
 207.309 +*     m n
 207.310 +*     p_stat d_stat obj_val
 207.311 +*     r_stat[1] r_prim[1] r_dual[1]
 207.312 +*     . . .
 207.313 +*     r_stat[m] r_prim[m] r_dual[m]
 207.314 +*     c_stat[1] c_prim[1] c_dual[1]
 207.315 +*     . . .
 207.316 +*     c_stat[n] c_prim[n] c_dual[n]
 207.317 +*
 207.318 +*  where:
 207.319 +*  m is the number of rows (auxiliary variables);
 207.320 +*  n is the number of columns (structural variables);
 207.321 +*  p_stat is the primal status of the basic solution (GLP_UNDEF = 1,
 207.322 +*     GLP_FEAS = 2, GLP_INFEAS = 3, or GLP_NOFEAS = 4);
 207.323 +*  d_stat is the dual status of the basic solution (GLP_UNDEF = 1,
 207.324 +*     GLP_FEAS = 2, GLP_INFEAS = 3, or GLP_NOFEAS = 4);
 207.325 +*  obj_val is the objective value;
 207.326 +*  r_stat[i], i = 1,...,m, is the status of i-th row (GLP_BS = 1,
 207.327 +*     GLP_NL = 2, GLP_NU = 3, GLP_NF = 4, or GLP_NS = 5);
 207.328 +*  r_prim[i], i = 1,...,m, is the primal value of i-th row;
 207.329 +*  r_dual[i], i = 1,...,m, is the dual value of i-th row;
 207.330 +*  c_stat[j], j = 1,...,n, is the status of j-th column (GLP_BS = 1,
 207.331 +*     GLP_NL = 2, GLP_NU = 3, GLP_NF = 4, or GLP_NS = 5);
 207.332 +*  c_prim[j], j = 1,...,n, is the primal value of j-th column;
 207.333 +*  c_dual[j], j = 1,...,n, is the dual value of j-th column. */
 207.334 +
 207.335 +int glp_write_sol(glp_prob *lp, const char *fname)
 207.336 +{     XFILE *fp;
 207.337 +      int i, j, ret = 0;
 207.338 +      xprintf("Writing basic solution to `%s'...\n", fname);
 207.339 +      fp = xfopen(fname, "w");
 207.340 +      if (fp == NULL)
 207.341 +      {  xprintf("Unable to create `%s' - %s\n", fname, xerrmsg());
 207.342 +         ret = 1;
 207.343 +         goto done;
 207.344 +      }
 207.345 +      /* number of rows, number of columns */
 207.346 +      xfprintf(fp, "%d %d\n", lp->m, lp->n);
 207.347 +      /* primal status, dual status, objective value */
 207.348 +      xfprintf(fp, "%d %d %.*g\n", lp->pbs_stat, lp->dbs_stat, DBL_DIG,
 207.349 +         lp->obj_val);
 207.350 +      /* rows (auxiliary variables) */
 207.351 +      for (i = 1; i <= lp->m; i++)
 207.352 +      {  GLPROW *row = lp->row[i];
 207.353 +         /* status, primal value, dual value */
 207.354 +         xfprintf(fp, "%d %.*g %.*g\n", row->stat, DBL_DIG, row->prim,
 207.355 +            DBL_DIG, row->dual);
 207.356 +      }
 207.357 +      /* columns (structural variables) */
 207.358 +      for (j = 1; j <= lp->n; j++)
 207.359 +      {  GLPCOL *col = lp->col[j];
 207.360 +         /* status, primal value, dual value */
 207.361 +         xfprintf(fp, "%d %.*g %.*g\n", col->stat, DBL_DIG, col->prim,
 207.362 +            DBL_DIG, col->dual);
 207.363 +      }
 207.364 +      xfflush(fp);
 207.365 +      if (xferror(fp))
 207.366 +      {  xprintf("Write error on `%s' - %s\n", fname, xerrmsg());
 207.367 +         ret = 1;
 207.368 +         goto done;
 207.369 +      }
 207.370 +      xprintf("%d lines were written\n", 2 + lp->m + lp->n);
 207.371 +done: if (fp != NULL) xfclose(fp);
 207.372 +      return ret;
 207.373 +}
 207.374 +
 207.375 +/**********************************************************************/
 207.376 +
 207.377 +static char *format(char buf[13+1], double x)
 207.378 +{     /* format floating-point number in MPS/360-like style */
 207.379 +      if (x == -DBL_MAX)
 207.380 +         strcpy(buf, "         -Inf");
 207.381 +      else if (x == +DBL_MAX)
 207.382 +         strcpy(buf, "         +Inf");
 207.383 +      else if (fabs(x) <= 999999.99998)
 207.384 +      {  sprintf(buf, "%13.5f", x);
 207.385 +#if 1
 207.386 +         if (strcmp(buf, "      0.00000") == 0 ||
 207.387 +             strcmp(buf, "     -0.00000") == 0)
 207.388 +            strcpy(buf, "       .     ");
 207.389 +         else if (memcmp(buf, "      0.", 8) == 0)
 207.390 +            memcpy(buf, "       .", 8);
 207.391 +         else if (memcmp(buf, "     -0.", 8) == 0)
 207.392 +            memcpy(buf, "      -.", 8);
 207.393 +#endif
 207.394 +      }
 207.395 +      else
 207.396 +         sprintf(buf, "%13.6g", x);
 207.397 +      return buf;
 207.398 +}
 207.399 +
 207.400 +int glp_print_ranges(glp_prob *P, int len, const int list[],
 207.401 +      int flags, const char *fname)
 207.402 +{     /* print sensitivity analysis report */
 207.403 +      XFILE *fp = NULL;
 207.404 +      GLPROW *row;
 207.405 +      GLPCOL *col;
 207.406 +      int m, n, pass, k, t, numb, type, stat, var1, var2, count, page,
 207.407 +         ret;
 207.408 +      double lb, ub, slack, coef, prim, dual, value1, value2, coef1,
 207.409 +         coef2, obj1, obj2;
 207.410 +      const char *name, *limit;
 207.411 +      char buf[13+1];
 207.412 +      /* sanity checks */
 207.413 +      if (P == NULL || P->magic != GLP_PROB_MAGIC)
 207.414 +         xerror("glp_print_ranges: P = %p; invalid problem object\n",
 207.415 +            P);
 207.416 +      m = P->m, n = P->n;
 207.417 +      if (len < 0)
 207.418 +         xerror("glp_print_ranges: len = %d; invalid list length\n",
 207.419 +            len);
 207.420 +      if (len > 0)
 207.421 +      {  if (list == NULL)
 207.422 +            xerror("glp_print_ranges: list = %p: invalid parameter\n",
 207.423 +               list);
 207.424 +         for (t = 1; t <= len; t++)
 207.425 +         {  k = list[t];
 207.426 +            if (!(1 <= k && k <= m+n))
 207.427 +               xerror("glp_print_ranges: list[%d] = %d; row/column numb"
 207.428 +                  "er out of range\n", t, k);
 207.429 +         }
 207.430 +      }
 207.431 +      if (flags != 0)
 207.432 +         xerror("glp_print_ranges: flags = %d; invalid parameter\n",
 207.433 +            flags);
 207.434 +      if (fname == NULL)
 207.435 +         xerror("glp_print_ranges: fname = %p; invalid parameter\n",
 207.436 +            fname);
 207.437 +      if (glp_get_status(P) != GLP_OPT)
 207.438 +      {  xprintf("glp_print_ranges: optimal basic solution required\n");
 207.439 +         ret = 1;
 207.440 +         goto done;
 207.441 +      }
 207.442 +      if (!glp_bf_exists(P))
 207.443 +      {  xprintf("glp_print_ranges: basis factorization required\n");
 207.444 +         ret = 2;
 207.445 +         goto done;
 207.446 +      }
 207.447 +      /* start reporting */
 207.448 +      xprintf("Write sensitivity analysis report to `%s'...\n", fname);
 207.449 +      fp = xfopen(fname, "w");
 207.450 +      if (fp == NULL)
 207.451 +      {  xprintf("Unable to create `%s' - %s\n", fname, xerrmsg());
 207.452 +         ret = 3;
 207.453 +         goto done;
 207.454 +      }
 207.455 +      page = count = 0;
 207.456 +      for (pass = 1; pass <= 2; pass++)
 207.457 +      for (t = 1; t <= (len == 0 ? m+n : len); t++)
 207.458 +      {  if (t == 1) count = 0;
 207.459 +         k = (len == 0 ? t : list[t]);
 207.460 +         if (pass == 1 && k > m || pass == 2 && k <= m)
 207.461 +            continue;
 207.462 +         if (count == 0)
 207.463 +         {  xfprintf(fp, "GLPK %-4s - SENSITIVITY ANALYSIS REPORT%73sPa"
 207.464 +               "ge%4d\n", glp_version(), "", ++page);
 207.465 +            xfprintf(fp, "\n");
 207.466 +            xfprintf(fp, "%-12s%s\n", "Problem:",
 207.467 +               P->name == NULL ? "" : P->name);
 207.468 +            xfprintf(fp, "%-12s%s%s%.10g (%s)\n", "Objective:",
 207.469 +               P->obj == NULL ? "" : P->obj,
 207.470 +               P->obj == NULL ? "" : " = ", P->obj_val,
 207.471 +               P->dir == GLP_MIN ? "MINimum" :
 207.472 +               P->dir == GLP_MAX ? "MAXimum" : "???");
 207.473 +            xfprintf(fp, "\n");
 207.474 +            xfprintf(fp, "%6s %-12s %2s %13s %13s %13s  %13s %13s %13s "
 207.475 +               "%s\n", "No.", pass == 1 ? "Row name" : "Column name",
 207.476 +               "St", "Activity", pass == 1 ? "Slack" : "Obj coef",
 207.477 +               "Lower bound", "Activity", "Obj coef", "Obj value at",
 207.478 +               "Limiting");
 207.479 +            xfprintf(fp, "%6s %-12s %2s %13s %13s %13s  %13s %13s %13s "
 207.480 +               "%s\n", "", "", "", "", "Marginal", "Upper bound",
 207.481 +               "range", "range", "break point", "variable");
 207.482 +            xfprintf(fp, "------ ------------ -- ------------- --------"
 207.483 +               "----- -------------  ------------- ------------- ------"
 207.484 +               "------- ------------\n");
 207.485 +         }
 207.486 +         if (pass == 1)
 207.487 +         {  numb = k;
 207.488 +            xassert(1 <= numb && numb <= m);
 207.489 +            row = P->row[numb];
 207.490 +            name = row->name;
 207.491 +            type = row->type;
 207.492 +            lb = glp_get_row_lb(P, numb);
 207.493 +            ub = glp_get_row_ub(P, numb);
 207.494 +            coef = 0.0;
 207.495 +            stat = row->stat;
 207.496 +            prim = row->prim;
 207.497 +            if (type == GLP_FR)
 207.498 +               slack = - prim;
 207.499 +            else if (type == GLP_LO)
 207.500 +               slack = lb - prim;
 207.501 +            else if (type == GLP_UP || type == GLP_DB || type == GLP_FX)
 207.502 +               slack = ub - prim;
 207.503 +            dual = row->dual;
 207.504 +         }
 207.505 +         else
 207.506 +         {  numb = k - m;
 207.507 +            xassert(1 <= numb && numb <= n);
 207.508 +            col = P->col[numb];
 207.509 +            name = col->name;
 207.510 +            lb = glp_get_col_lb(P, numb);
 207.511 +            ub = glp_get_col_ub(P, numb);
 207.512 +            coef = col->coef;
 207.513 +            stat = col->stat;
 207.514 +            prim = col->prim;
 207.515 +            slack = 0.0;
 207.516 +            dual = col->dual;
 207.517 +         }
 207.518 +         if (stat != GLP_BS)
 207.519 +         {  glp_analyze_bound(P, k, &value1, &var1, &value2, &var2);
 207.520 +            if (stat == GLP_NF)
 207.521 +               coef1 = coef2 = coef;
 207.522 +            else if (stat == GLP_NS)
 207.523 +               coef1 = -DBL_MAX, coef2 = +DBL_MAX;
 207.524 +            else if (stat == GLP_NL && P->dir == GLP_MIN ||
 207.525 +                     stat == GLP_NU && P->dir == GLP_MAX)
 207.526 +               coef1 = coef - dual, coef2 = +DBL_MAX;
 207.527 +            else
 207.528 +               coef1 = -DBL_MAX, coef2 = coef - dual;
 207.529 +            if (value1 == -DBL_MAX)
 207.530 +            {  if (dual < -1e-9)
 207.531 +                  obj1 = +DBL_MAX;
 207.532 +               else if (dual > +1e-9)
 207.533 +                  obj1 = -DBL_MAX;
 207.534 +               else
 207.535 +                  obj1 = P->obj_val;
 207.536 +            }
 207.537 +            else
 207.538 +               obj1 = P->obj_val + dual * (value1 - prim);
 207.539 +            if (value2 == +DBL_MAX)
 207.540 +            {  if (dual < -1e-9)
 207.541 +                  obj2 = -DBL_MAX;
 207.542 +               else if (dual > +1e-9)
 207.543 +                  obj2 = +DBL_MAX;
 207.544 +               else
 207.545 +                  obj2 = P->obj_val;
 207.546 +            }
 207.547 +            else
 207.548 +               obj2 = P->obj_val + dual * (value2 - prim);
 207.549 +         }
 207.550 +         else
 207.551 +         {  glp_analyze_coef(P, k, &coef1, &var1, &value1, &coef2,
 207.552 +               &var2, &value2);
 207.553 +            if (coef1 == -DBL_MAX)
 207.554 +            {  if (prim < -1e-9)
 207.555 +                  obj1 = +DBL_MAX;
 207.556 +               else if (prim > +1e-9)
 207.557 +                  obj1 = -DBL_MAX;
 207.558 +               else
 207.559 +                  obj1 = P->obj_val;
 207.560 +            }
 207.561 +            else
 207.562 +               obj1 = P->obj_val + (coef1 - coef) * prim;
 207.563 +            if (coef2 == +DBL_MAX)
 207.564 +            {  if (prim < -1e-9)
 207.565 +                  obj2 = -DBL_MAX;
 207.566 +               else if (prim > +1e-9)
 207.567 +                  obj2 = +DBL_MAX;
 207.568 +               else
 207.569 +                  obj2 = P->obj_val;
 207.570 +            }
 207.571 +            else
 207.572 +               obj2 = P->obj_val + (coef2 - coef) * prim;
 207.573 +         }
 207.574 +         /*** first line ***/
 207.575 +         /* row/column number */
 207.576 +         xfprintf(fp, "%6d", numb);
 207.577 +         /* row/column name */
 207.578 +         xfprintf(fp, " %-12.12s", name == NULL ? "" : name);
 207.579 +         if (name != NULL && strlen(name) > 12)
 207.580 +            xfprintf(fp, "%s\n%6s %12s", name+12, "", "");
 207.581 +         /* row/column status */
 207.582 +         xfprintf(fp, " %2s",
 207.583 +            stat == GLP_BS ? "BS" : stat == GLP_NL ? "NL" :
 207.584 +            stat == GLP_NU ? "NU" : stat == GLP_NF ? "NF" :
 207.585 +            stat == GLP_NS ? "NS" : "??");
 207.586 +         /* row/column activity */
 207.587 +         xfprintf(fp, " %s", format(buf, prim));
 207.588 +         /* row slack, column objective coefficient */
 207.589 +         xfprintf(fp, " %s", format(buf, k <= m ? slack : coef));
 207.590 +         /* row/column lower bound */
 207.591 +         xfprintf(fp, " %s", format(buf, lb));
 207.592 +         /* row/column activity range */
 207.593 +         xfprintf(fp, "  %s", format(buf, value1));
 207.594 +         /* row/column objective coefficient range */
 207.595 +         xfprintf(fp, " %s", format(buf, coef1));
 207.596 +         /* objective value at break point */
 207.597 +         xfprintf(fp, " %s", format(buf, obj1));
 207.598 +         /* limiting variable name */
 207.599 +         if (var1 != 0)
 207.600 +         {  if (var1 <= m)
 207.601 +               limit = glp_get_row_name(P, var1);
 207.602 +            else
 207.603 +               limit = glp_get_col_name(P, var1 - m);
 207.604 +            if (limit != NULL)
 207.605 +               xfprintf(fp, " %s", limit);
 207.606 +         }
 207.607 +         xfprintf(fp, "\n");
 207.608 +         /*** second line ***/
 207.609 +         xfprintf(fp, "%6s %-12s %2s %13s", "", "", "", "");
 207.610 +         /* row/column reduced cost */
 207.611 +         xfprintf(fp, " %s", format(buf, dual));
 207.612 +         /* row/column upper bound */
 207.613 +         xfprintf(fp, " %s", format(buf, ub));
 207.614 +         /* row/column activity range */
 207.615 +         xfprintf(fp, "  %s", format(buf, value2));
 207.616 +         /* row/column objective coefficient range */
 207.617 +         xfprintf(fp, " %s", format(buf, coef2));
 207.618 +         /* objective value at break point */
 207.619 +         xfprintf(fp, " %s", format(buf, obj2));
 207.620 +         /* limiting variable name */
 207.621 +         if (var2 != 0)
 207.622 +         {  if (var2 <= m)
 207.623 +               limit = glp_get_row_name(P, var2);
 207.624 +            else
 207.625 +               limit = glp_get_col_name(P, var2 - m);
 207.626 +            if (limit != NULL)
 207.627 +               xfprintf(fp, " %s", limit);
 207.628 +         }
 207.629 +         xfprintf(fp, "\n");
 207.630 +         xfprintf(fp, "\n");
 207.631 +         /* print 10 items per page */
 207.632 +         count = (count + 1) % 10;
 207.633 +      }
 207.634 +      xfprintf(fp, "End of report\n");
 207.635 +      xfflush(fp);
 207.636 +      if (xferror(fp))
 207.637 +      {  xprintf("Write error on `%s' - %s\n", fname, xerrmsg());
 207.638 +         ret = 4;
 207.639 +         goto done;
 207.640 +      }
 207.641 +      ret = 0;
 207.642 +done: if (fp != NULL) xfclose(fp);
 207.643 +      return ret;
 207.644 +}
 207.645 +
 207.646 +/**********************************************************************/
 207.647 +
 207.648 +int glp_print_ipt(glp_prob *P, const char *fname)
 207.649 +{     /* write interior-point solution in printable format */
 207.650 +      XFILE *fp;
 207.651 +      GLPROW *row;
 207.652 +      GLPCOL *col;
 207.653 +      int i, j, t, ae_ind, re_ind, ret;
 207.654 +      double ae_max, re_max;
 207.655 +      xprintf("Writing interior-point solution to `%s'...\n", fname);
 207.656 +      fp = xfopen(fname, "w");
 207.657 +      if (fp == NULL)
 207.658 +      {  xprintf("Unable to create `%s' - %s\n", fname, xerrmsg());
 207.659 +         ret = 1;
 207.660 +         goto done;
 207.661 +      }
 207.662 +      xfprintf(fp, "%-12s%s\n", "Problem:",
 207.663 +         P->name == NULL ? "" : P->name);
 207.664 +      xfprintf(fp, "%-12s%d\n", "Rows:", P->m);
 207.665 +      xfprintf(fp, "%-12s%d\n", "Columns:", P->n);
 207.666 +      xfprintf(fp, "%-12s%d\n", "Non-zeros:", P->nnz);
 207.667 +      t = glp_ipt_status(P);
 207.668 +      xfprintf(fp, "%-12s%s\n", "Status:",
 207.669 +         t == GLP_OPT    ? "OPTIMAL" :
 207.670 +         t == GLP_UNDEF  ? "UNDEFINED" :
 207.671 +         t == GLP_INFEAS ? "INFEASIBLE (INTERMEDIATE)" :
 207.672 +         t == GLP_NOFEAS ? "INFEASIBLE (FINAL)" : "???");
 207.673 +      xfprintf(fp, "%-12s%s%s%.10g (%s)\n", "Objective:",
 207.674 +         P->obj == NULL ? "" : P->obj,
 207.675 +         P->obj == NULL ? "" : " = ", P->ipt_obj,
 207.676 +         P->dir == GLP_MIN ? "MINimum" :
 207.677 +         P->dir == GLP_MAX ? "MAXimum" : "???");
 207.678 +      xfprintf(fp, "\n");
 207.679 +      xfprintf(fp, "   No.   Row name        Activity     Lower bound  "
 207.680 +         " Upper bound    Marginal\n");
 207.681 +      xfprintf(fp, "------ ------------    ------------- ------------- "
 207.682 +         "------------- -------------\n");
 207.683 +      for (i = 1; i <= P->m; i++)
 207.684 +      {  row = P->row[i];
 207.685 +         xfprintf(fp, "%6d ", i);
 207.686 +         if (row->name == NULL || strlen(row->name) <= 12)
 207.687 +            xfprintf(fp, "%-12s ", row->name == NULL ? "" : row->name);
 207.688 +         else
 207.689 +            xfprintf(fp, "%s\n%20s", row->name, "");
 207.690 +         xfprintf(fp, "%3s", "");
 207.691 +         xfprintf(fp, "%13.6g ",
 207.692 +            fabs(row->pval) <= 1e-9 ? 0.0 : row->pval);
 207.693 +         if (row->type == GLP_LO || row->type == GLP_DB ||
 207.694 +             row->type == GLP_FX)
 207.695 +            xfprintf(fp, "%13.6g ", row->lb);
 207.696 +         else
 207.697 +            xfprintf(fp, "%13s ", "");
 207.698 +         if (row->type == GLP_UP || row->type == GLP_DB)
 207.699 +            xfprintf(fp, "%13.6g ", row->ub);
 207.700 +         else
 207.701 +            xfprintf(fp, "%13s ", row->type == GLP_FX ? "=" : "");
 207.702 +         if (fabs(row->dval) <= 1e-9)
 207.703 +            xfprintf(fp, "%13s", "< eps");
 207.704 +         else
 207.705 +            xfprintf(fp, "%13.6g ", row->dval);
 207.706 +         xfprintf(fp, "\n");
 207.707 +      }
 207.708 +      xfprintf(fp, "\n");
 207.709 +      xfprintf(fp, "   No. Column name       Activity     Lower bound  "
 207.710 +         " Upper bound    Marginal\n");
 207.711 +      xfprintf(fp, "------ ------------    ------------- ------------- "
 207.712 +         "------------- -------------\n");
 207.713 +      for (j = 1; j <= P->n; j++)
 207.714 +      {  col = P->col[j];
 207.715 +         xfprintf(fp, "%6d ", j);
 207.716 +         if (col->name == NULL || strlen(col->name) <= 12)
 207.717 +            xfprintf(fp, "%-12s ", col->name == NULL ? "" : col->name);
 207.718 +         else
 207.719 +            xfprintf(fp, "%s\n%20s", col->name, "");
 207.720 +         xfprintf(fp, "%3s", "");
 207.721 +         xfprintf(fp, "%13.6g ",
 207.722 +            fabs(col->pval) <= 1e-9 ? 0.0 : col->pval);
 207.723 +         if (col->type == GLP_LO || col->type == GLP_DB ||
 207.724 +             col->type == GLP_FX)
 207.725 +            xfprintf(fp, "%13.6g ", col->lb);
 207.726 +         else
 207.727 +            xfprintf(fp, "%13s ", "");
 207.728 +         if (col->type == GLP_UP || col->type == GLP_DB)
 207.729 +            xfprintf(fp, "%13.6g ", col->ub);
 207.730 +         else
 207.731 +            xfprintf(fp, "%13s ", col->type == GLP_FX ? "=" : "");
 207.732 +         if (fabs(col->dval) <= 1e-9)
 207.733 +            xfprintf(fp, "%13s", "< eps");
 207.734 +         else
 207.735 +            xfprintf(fp, "%13.6g ", col->dval);
 207.736 +         xfprintf(fp, "\n");
 207.737 +      }
 207.738 +      xfprintf(fp, "\n");
 207.739 +      xfprintf(fp, "Karush-Kuhn-Tucker optimality conditions:\n");
 207.740 +      xfprintf(fp, "\n");
 207.741 +      _glp_check_kkt(P, GLP_IPT, GLP_KKT_PE, &ae_max, &ae_ind, &re_max,
 207.742 +         &re_ind);
 207.743 +      xfprintf(fp, "KKT.PE: max.abs.err = %.2e on row %d\n",
 207.744 +         ae_max, ae_ind);
 207.745 +      xfprintf(fp, "        max.rel.err = %.2e on row %d\n",
 207.746 +         re_max, re_ind);
 207.747 +      xfprintf(fp, "%8s%s\n", "",
 207.748 +         re_max <= 1e-9 ? "High quality" :
 207.749 +         re_max <= 1e-6 ? "Medium quality" :
 207.750 +         re_max <= 1e-3 ? "Low quality" : "PRIMAL SOLUTION IS WRONG");
 207.751 +      xfprintf(fp, "\n");
 207.752 +      _glp_check_kkt(P, GLP_IPT, GLP_KKT_PB, &ae_max, &ae_ind, &re_max,
 207.753 +         &re_ind);
 207.754 +      xfprintf(fp, "KKT.PB: max.abs.err = %.2e on %s %d\n",
 207.755 +            ae_max, ae_ind <= P->m ? "row" : "column",
 207.756 +            ae_ind <= P->m ? ae_ind : ae_ind - P->m);
 207.757 +      xfprintf(fp, "        max.rel.err = %.2e on %s %d\n",
 207.758 +            re_max, re_ind <= P->m ? "row" : "column",
 207.759 +            re_ind <= P->m ? re_ind : re_ind - P->m);
 207.760 +      xfprintf(fp, "%8s%s\n", "",
 207.761 +         re_max <= 1e-9 ? "High quality" :
 207.762 +         re_max <= 1e-6 ? "Medium quality" :
 207.763 +         re_max <= 1e-3 ? "Low quality" : "PRIMAL SOLUTION IS INFEASIBL"
 207.764 +            "E");
 207.765 +      xfprintf(fp, "\n");
 207.766 +      _glp_check_kkt(P, GLP_IPT, GLP_KKT_DE, &ae_max, &ae_ind, &re_max,
 207.767 +         &re_ind);
 207.768 +      xfprintf(fp, "KKT.DE: max.abs.err = %.2e on column %d\n",
 207.769 +         ae_max, ae_ind == 0 ? 0 : ae_ind - P->m);
 207.770 +      xfprintf(fp, "        max.rel.err = %.2e on column %d\n",
 207.771 +         re_max, re_ind == 0 ? 0 : re_ind - P->m);
 207.772 +      xfprintf(fp, "%8s%s\n", "",
 207.773 +         re_max <= 1e-9 ? "High quality" :
 207.774 +         re_max <= 1e-6 ? "Medium quality" :
 207.775 +         re_max <= 1e-3 ? "Low quality" : "DUAL SOLUTION IS WRONG");
 207.776 +      xfprintf(fp, "\n");
 207.777 +      _glp_check_kkt(P, GLP_IPT, GLP_KKT_DB, &ae_max, &ae_ind, &re_max,
 207.778 +         &re_ind);
 207.779 +      xfprintf(fp, "KKT.DB: max.abs.err = %.2e on %s %d\n",
 207.780 +            ae_max, ae_ind <= P->m ? "row" : "column",
 207.781 +            ae_ind <= P->m ? ae_ind : ae_ind - P->m);
 207.782 +      xfprintf(fp, "        max.rel.err = %.2e on %s %d\n",
 207.783 +            re_max, re_ind <= P->m ? "row" : "column",
 207.784 +            re_ind <= P->m ? re_ind : re_ind - P->m);
 207.785 +      xfprintf(fp, "%8s%s\n", "",
 207.786 +         re_max <= 1e-9 ? "High quality" :
 207.787 +         re_max <= 1e-6 ? "Medium quality" :
 207.788 +         re_max <= 1e-3 ? "Low quality" : "DUAL SOLUTION IS INFEASIBLE")
 207.789 +            ;
 207.790 +      xfprintf(fp, "\n");
 207.791 +      xfprintf(fp, "End of output\n");
 207.792 +      xfflush(fp);
 207.793 +      if (xferror(fp))
 207.794 +      {  xprintf("Write error on `%s' - %s\n", fname, xerrmsg());
 207.795 +         ret = 1;
 207.796 +         goto done;
 207.797 +      }
 207.798 +      ret = 0;
 207.799 +done: if (fp != NULL) xfclose(fp);
 207.800 +      return ret;
 207.801 +}
 207.802 +
 207.803 +/***********************************************************************
 207.804 +*  NAME
 207.805 +*
 207.806 +*  glp_read_ipt - read interior-point solution from text file
 207.807 +*
 207.808 +*  SYNOPSIS
 207.809 +*
 207.810 +*  int glp_read_ipt(glp_prob *lp, const char *fname);
 207.811 +*
 207.812 +*  DESCRIPTION
 207.813 +*
 207.814 +*  The routine glp_read_ipt reads interior-point solution from a text
 207.815 +*  file whose name is specified by the parameter fname into the problem
 207.816 +*  object.
 207.817 +*
 207.818 +*  For the file format see description of the routine glp_write_ipt.
 207.819 +*
 207.820 +*  RETURNS
 207.821 +*
 207.822 +*  On success the routine returns zero, otherwise non-zero. */
 207.823 +
 207.824 +int glp_read_ipt(glp_prob *lp, const char *fname)
 207.825 +{     glp_data *data;
 207.826 +      jmp_buf jump;
 207.827 +      int i, j, k, ret = 0;
 207.828 +      xprintf("Reading interior-point solution from `%s'...\n", fname);
 207.829 +      data = glp_sdf_open_file(fname);
 207.830 +      if (data == NULL)
 207.831 +      {  ret = 1;
 207.832 +         goto done;
 207.833 +      }
 207.834 +      if (setjmp(jump))
 207.835 +      {  ret = 1;
 207.836 +         goto done;
 207.837 +      }
 207.838 +      glp_sdf_set_jump(data, jump);
 207.839 +      /* number of rows, number of columns */
 207.840 +      k = glp_sdf_read_int(data);
 207.841 +      if (k != lp->m)
 207.842 +         glp_sdf_error(data, "wrong number of rows\n");
 207.843 +      k = glp_sdf_read_int(data);
 207.844 +      if (k != lp->n)
 207.845 +         glp_sdf_error(data, "wrong number of columns\n");
 207.846 +      /* solution status, objective value */
 207.847 +      k = glp_sdf_read_int(data);
 207.848 +      if (!(k == GLP_UNDEF || k == GLP_OPT))
 207.849 +         glp_sdf_error(data, "invalid solution status\n");
 207.850 +      lp->ipt_stat = k;
 207.851 +      lp->ipt_obj = glp_sdf_read_num(data);
 207.852 +      /* rows (auxiliary variables) */
 207.853 +      for (i = 1; i <= lp->m; i++)
 207.854 +      {  GLPROW *row = lp->row[i];
 207.855 +         /* primal value, dual value */
 207.856 +         row->pval = glp_sdf_read_num(data);
 207.857 +         row->dval = glp_sdf_read_num(data);
 207.858 +      }
 207.859 +      /* columns (structural variables) */
 207.860 +      for (j = 1; j <= lp->n; j++)
 207.861 +      {  GLPCOL *col = lp->col[j];
 207.862 +         /* primal value, dual value */
 207.863 +         col->pval = glp_sdf_read_num(data);
 207.864 +         col->dval = glp_sdf_read_num(data);
 207.865 +      }
 207.866 +      xprintf("%d lines were read\n", glp_sdf_line(data));
 207.867 +done: if (ret) lp->ipt_stat = GLP_UNDEF;
 207.868 +      if (data != NULL) glp_sdf_close_file(data);
 207.869 +      return ret;
 207.870 +}
 207.871 +
 207.872 +/***********************************************************************
 207.873 +*  NAME
 207.874 +*
 207.875 +*  glp_write_ipt - write interior-point solution to text file
 207.876 +*
 207.877 +*  SYNOPSIS
 207.878 +*
 207.879 +*  int glp_write_ipt(glp_prob *lp, const char *fname);
 207.880 +*
 207.881 +*  DESCRIPTION
 207.882 +*
 207.883 +*  The routine glp_write_ipt writes the current interior-point solution
 207.884 +*  to a text file whose name is specified by the parameter fname. This
 207.885 +*  file can be read back with the routine glp_read_ipt.
 207.886 +*
 207.887 +*  RETURNS
 207.888 +*
 207.889 +*  On success the routine returns zero, otherwise non-zero.
 207.890 +*
 207.891 +*  FILE FORMAT
 207.892 +*
 207.893 +*  The file created by the routine glp_write_ipt is a plain text file,
 207.894 +*  which contains the following information:
 207.895 +*
 207.896 +*     m n
 207.897 +*     stat obj_val
 207.898 +*     r_prim[1] r_dual[1]
 207.899 +*     . . .
 207.900 +*     r_prim[m] r_dual[m]
 207.901 +*     c_prim[1] c_dual[1]
 207.902 +*     . . .
 207.903 +*     c_prim[n] c_dual[n]
 207.904 +*
 207.905 +*  where:
 207.906 +*  m is the number of rows (auxiliary variables);
 207.907 +*  n is the number of columns (structural variables);
 207.908 +*  stat is the solution status (GLP_UNDEF = 1 or GLP_OPT = 5);
 207.909 +*  obj_val is the objective value;
 207.910 +*  r_prim[i], i = 1,...,m, is the primal value of i-th row;
 207.911 +*  r_dual[i], i = 1,...,m, is the dual value of i-th row;
 207.912 +*  c_prim[j], j = 1,...,n, is the primal value of j-th column;
 207.913 +*  c_dual[j], j = 1,...,n, is the dual value of j-th column. */
 207.914 +
 207.915 +int glp_write_ipt(glp_prob *lp, const char *fname)
 207.916 +{     XFILE *fp;
 207.917 +      int i, j, ret = 0;
 207.918 +      xprintf("Writing interior-point solution to `%s'...\n", fname);
 207.919 +      fp = xfopen(fname, "w");
 207.920 +      if (fp == NULL)
 207.921 +      {  xprintf("Unable to create `%s' - %s\n", fname, xerrmsg());
 207.922 +         ret = 1;
 207.923 +         goto done;
 207.924 +      }
 207.925 +      /* number of rows, number of columns */
 207.926 +      xfprintf(fp, "%d %d\n", lp->m, lp->n);
 207.927 +      /* solution status, objective value */
 207.928 +      xfprintf(fp, "%d %.*g\n", lp->ipt_stat, DBL_DIG, lp->ipt_obj);
 207.929 +      /* rows (auxiliary variables) */
 207.930 +      for (i = 1; i <= lp->m; i++)
 207.931 +      {  GLPROW *row = lp->row[i];
 207.932 +         /* primal value, dual value */
 207.933 +         xfprintf(fp, "%.*g %.*g\n", DBL_DIG, row->pval, DBL_DIG,
 207.934 +            row->dval);
 207.935 +      }
 207.936 +      /* columns (structural variables) */
 207.937 +      for (j = 1; j <= lp->n; j++)
 207.938 +      {  GLPCOL *col = lp->col[j];
 207.939 +         /* primal value, dual value */
 207.940 +         xfprintf(fp, "%.*g %.*g\n", DBL_DIG, col->pval, DBL_DIG,
 207.941 +            col->dval);
 207.942 +      }
 207.943 +      xfflush(fp);
 207.944 +      if (xferror(fp))
 207.945 +      {  xprintf("Write error on `%s' - %s\n", fname, xerrmsg());
 207.946 +         ret = 1;
 207.947 +         goto done;
 207.948 +      }
 207.949 +      xprintf("%d lines were written\n", 2 + lp->m + lp->n);
 207.950 +done: if (fp != NULL) xfclose(fp);
 207.951 +      return ret;
 207.952 +}
 207.953 +
 207.954 +/**********************************************************************/
 207.955 +
 207.956 +int glp_print_mip(glp_prob *P, const char *fname)
 207.957 +{     /* write MIP solution in printable format */
 207.958 +      XFILE *fp;
 207.959 +      GLPROW *row;
 207.960 +      GLPCOL *col;
 207.961 +      int i, j, t, ae_ind, re_ind, ret;
 207.962 +      double ae_max, re_max;
 207.963 +      xprintf("Writing MIP solution to `%s'...\n", fname);
 207.964 +      fp = xfopen(fname, "w");
 207.965 +      if (fp == NULL)
 207.966 +      {  xprintf("Unable to create `%s' - %s\n", fname, xerrmsg());
 207.967 +         ret = 1;
 207.968 +         goto done;
 207.969 +      }
 207.970 +      xfprintf(fp, "%-12s%s\n", "Problem:",
 207.971 +         P->name == NULL ? "" : P->name);
 207.972 +      xfprintf(fp, "%-12s%d\n", "Rows:", P->m);
 207.973 +      xfprintf(fp, "%-12s%d (%d integer, %d binary)\n", "Columns:",
 207.974 +         P->n, glp_get_num_int(P), glp_get_num_bin(P));
 207.975 +      xfprintf(fp, "%-12s%d\n", "Non-zeros:", P->nnz);
 207.976 +      t = glp_mip_status(P);
 207.977 +      xfprintf(fp, "%-12s%s\n", "Status:",
 207.978 +         t == GLP_OPT    ? "INTEGER OPTIMAL" :
 207.979 +         t == GLP_FEAS   ? "INTEGER NON-OPTIMAL" :
 207.980 +         t == GLP_NOFEAS ? "INTEGER EMPTY" :
 207.981 +         t == GLP_UNDEF  ? "INTEGER UNDEFINED" : "???");
 207.982 +      xfprintf(fp, "%-12s%s%s%.10g (%s)\n", "Objective:",
 207.983 +         P->obj == NULL ? "" : P->obj,
 207.984 +         P->obj == NULL ? "" : " = ", P->mip_obj,
 207.985 +         P->dir == GLP_MIN ? "MINimum" :
 207.986 +         P->dir == GLP_MAX ? "MAXimum" : "???");
 207.987 +      xfprintf(fp, "\n");
 207.988 +      xfprintf(fp, "   No.   Row name        Activity     Lower bound  "
 207.989 +         " Upper bound\n");
 207.990 +      xfprintf(fp, "------ ------------    ------------- ------------- "
 207.991 +         "-------------\n");
 207.992 +      for (i = 1; i <= P->m; i++)
 207.993 +      {  row = P->row[i];
 207.994 +         xfprintf(fp, "%6d ", i);
 207.995 +         if (row->name == NULL || strlen(row->name) <= 12)
 207.996 +            xfprintf(fp, "%-12s ", row->name == NULL ? "" : row->name);
 207.997 +         else
 207.998 +            xfprintf(fp, "%s\n%20s", row->name, "");
 207.999 +         xfprintf(fp, "%3s", "");
207.1000 +         xfprintf(fp, "%13.6g ",
207.1001 +            fabs(row->mipx) <= 1e-9 ? 0.0 : row->mipx);
207.1002 +         if (row->type == GLP_LO || row->type == GLP_DB ||
207.1003 +             row->type == GLP_FX)
207.1004 +            xfprintf(fp, "%13.6g ", row->lb);
207.1005 +         else
207.1006 +            xfprintf(fp, "%13s ", "");
207.1007 +         if (row->type == GLP_UP || row->type == GLP_DB)
207.1008 +            xfprintf(fp, "%13.6g ", row->ub);
207.1009 +         else
207.1010 +            xfprintf(fp, "%13s ", row->type == GLP_FX ? "=" : "");
207.1011 +         xfprintf(fp, "\n");
207.1012 +      }
207.1013 +      xfprintf(fp, "\n");
207.1014 +      xfprintf(fp, "   No. Column name       Activity     Lower bound  "
207.1015 +         " Upper bound\n");
207.1016 +      xfprintf(fp, "------ ------------    ------------- ------------- "
207.1017 +         "-------------\n");
207.1018 +      for (j = 1; j <= P->n; j++)
207.1019 +      {  col = P->col[j];
207.1020 +         xfprintf(fp, "%6d ", j);
207.1021 +         if (col->name == NULL || strlen(col->name) <= 12)
207.1022 +            xfprintf(fp, "%-12s ", col->name == NULL ? "" : col->name);
207.1023 +         else
207.1024 +            xfprintf(fp, "%s\n%20s", col->name, "");
207.1025 +         xfprintf(fp, "%s  ",
207.1026 +            col->kind == GLP_CV ? " " :
207.1027 +            col->kind == GLP_IV ? "*" : "?");
207.1028 +         xfprintf(fp, "%13.6g ",
207.1029 +            fabs(col->mipx) <= 1e-9 ? 0.0 : col->mipx);
207.1030 +         if (col->type == GLP_LO || col->type == GLP_DB ||
207.1031 +             col->type == GLP_FX)
207.1032 +            xfprintf(fp, "%13.6g ", col->lb);
207.1033 +         else
207.1034 +            xfprintf(fp, "%13s ", "");
207.1035 +         if (col->type == GLP_UP || col->type == GLP_DB)
207.1036 +            xfprintf(fp, "%13.6g ", col->ub);
207.1037 +         else
207.1038 +            xfprintf(fp, "%13s ", col->type == GLP_FX ? "=" : "");
207.1039 +         xfprintf(fp, "\n");
207.1040 +      }
207.1041 +      xfprintf(fp, "\n");
207.1042 +      xfprintf(fp, "Integer feasibility conditions:\n");
207.1043 +      xfprintf(fp, "\n");
207.1044 +      _glp_check_kkt(P, GLP_MIP, GLP_KKT_PE, &ae_max, &ae_ind, &re_max,
207.1045 +         &re_ind);
207.1046 +      xfprintf(fp, "KKT.PE: max.abs.err = %.2e on row %d\n",
207.1047 +         ae_max, ae_ind);
207.1048 +      xfprintf(fp, "        max.rel.err = %.2e on row %d\n",
207.1049 +         re_max, re_ind);
207.1050 +      xfprintf(fp, "%8s%s\n", "",
207.1051 +         re_max <= 1e-9 ? "High quality" :
207.1052 +         re_max <= 1e-6 ? "Medium quality" :
207.1053 +         re_max <= 1e-3 ? "Low quality" : "SOLUTION IS WRONG");
207.1054 +      xfprintf(fp, "\n");
207.1055 +      _glp_check_kkt(P, GLP_MIP, GLP_KKT_PB, &ae_max, &ae_ind, &re_max,
207.1056 +         &re_ind);
207.1057 +      xfprintf(fp, "KKT.PB: max.abs.err = %.2e on %s %d\n",
207.1058 +            ae_max, ae_ind <= P->m ? "row" : "column",
207.1059 +            ae_ind <= P->m ? ae_ind : ae_ind - P->m);
207.1060 +      xfprintf(fp, "        max.rel.err = %.2e on %s %d\n",
207.1061 +            re_max, re_ind <= P->m ? "row" : "column",
207.1062 +            re_ind <= P->m ? re_ind : re_ind - P->m);
207.1063 +      xfprintf(fp, "%8s%s\n", "",
207.1064 +         re_max <= 1e-9 ? "High quality" :
207.1065 +         re_max <= 1e-6 ? "Medium quality" :
207.1066 +         re_max <= 1e-3 ? "Low quality" : "SOLUTION IS INFEASIBLE");
207.1067 +      xfprintf(fp, "\n");
207.1068 +      xfprintf(fp, "End of output\n");
207.1069 +      xfflush(fp);
207.1070 +      if (xferror(fp))
207.1071 +      {  xprintf("Write error on `%s' - %s\n", fname, xerrmsg());
207.1072 +         ret = 1;
207.1073 +         goto done;
207.1074 +      }
207.1075 +      ret = 0;
207.1076 +done: if (fp != NULL) xfclose(fp);
207.1077 +      return ret;
207.1078 +}
207.1079 +
207.1080 +/***********************************************************************
207.1081 +*  NAME
207.1082 +*
207.1083 +*  glp_read_mip - read MIP solution from text file
207.1084 +*
207.1085 +*  SYNOPSIS
207.1086 +*
207.1087 +*  int glp_read_mip(glp_prob *mip, const char *fname);
207.1088 +*
207.1089 +*  DESCRIPTION
207.1090 +*
207.1091 +*  The routine glp_read_mip reads MIP solution from a text file whose
207.1092 +*  name is specified by the parameter fname into the problem object.
207.1093 +*
207.1094 +*  For the file format see description of the routine glp_write_mip.
207.1095 +*
207.1096 +*  RETURNS
207.1097 +*
207.1098 +*  On success the routine returns zero, otherwise non-zero. */
207.1099 +
207.1100 +int glp_read_mip(glp_prob *mip, const char *fname)
207.1101 +{     glp_data *data;
207.1102 +      jmp_buf jump;
207.1103 +      int i, j, k, ret = 0;
207.1104 +      xprintf("Reading MIP solution from `%s'...\n", fname);
207.1105 +      data = glp_sdf_open_file(fname);
207.1106 +      if (data == NULL)
207.1107 +      {  ret = 1;
207.1108 +         goto done;
207.1109 +      }
207.1110 +      if (setjmp(jump))
207.1111 +      {  ret = 1;
207.1112 +         goto done;
207.1113 +      }
207.1114 +      glp_sdf_set_jump(data, jump);
207.1115 +      /* number of rows, number of columns */
207.1116 +      k = glp_sdf_read_int(data);
207.1117 +      if (k != mip->m)
207.1118 +         glp_sdf_error(data, "wrong number of rows\n");
207.1119 +      k = glp_sdf_read_int(data);
207.1120 +      if (k != mip->n)
207.1121 +         glp_sdf_error(data, "wrong number of columns\n");
207.1122 +      /* solution status, objective value */
207.1123 +      k = glp_sdf_read_int(data);
207.1124 +      if (!(k == GLP_UNDEF || k == GLP_OPT || k == GLP_FEAS ||
207.1125 +            k == GLP_NOFEAS))
207.1126 +         glp_sdf_error(data, "invalid solution status\n");
207.1127 +      mip->mip_stat = k;
207.1128 +      mip->mip_obj = glp_sdf_read_num(data);
207.1129 +      /* rows (auxiliary variables) */
207.1130 +      for (i = 1; i <= mip->m; i++)
207.1131 +      {  GLPROW *row = mip->row[i];
207.1132 +         row->mipx = glp_sdf_read_num(data);
207.1133 +      }
207.1134 +      /* columns (structural variables) */
207.1135 +      for (j = 1; j <= mip->n; j++)
207.1136 +      {  GLPCOL *col = mip->col[j];
207.1137 +         col->mipx = glp_sdf_read_num(data);
207.1138 +         if (col->kind == GLP_IV && col->mipx != floor(col->mipx))
207.1139 +            glp_sdf_error(data, "non-integer column value");
207.1140 +      }
207.1141 +      xprintf("%d lines were read\n", glp_sdf_line(data));
207.1142 +done: if (ret) mip->mip_stat = GLP_UNDEF;
207.1143 +      if (data != NULL) glp_sdf_close_file(data);
207.1144 +      return ret;
207.1145 +}
207.1146 +
207.1147 +/***********************************************************************
207.1148 +*  NAME
207.1149 +*
207.1150 +*  glp_write_mip - write MIP solution to text file
207.1151 +*
207.1152 +*  SYNOPSIS
207.1153 +*
207.1154 +*  int glp_write_mip(glp_prob *mip, const char *fname);
207.1155 +*
207.1156 +*  DESCRIPTION
207.1157 +*
207.1158 +*  The routine glp_write_mip writes the current MIP solution to a text
207.1159 +*  file whose name is specified by the parameter fname. This file can
207.1160 +*  be read back with the routine glp_read_mip.
207.1161 +*
207.1162 +*  RETURNS
207.1163 +*
207.1164 +*  On success the routine returns zero, otherwise non-zero.
207.1165 +*
207.1166 +*  FILE FORMAT
207.1167 +*
207.1168 +*  The file created by the routine glp_write_sol is a plain text file,
207.1169 +*  which contains the following information:
207.1170 +*
207.1171 +*     m n
207.1172 +*     stat obj_val
207.1173 +*     r_val[1]
207.1174 +*     . . .
207.1175 +*     r_val[m]
207.1176 +*     c_val[1]
207.1177 +*     . . .
207.1178 +*     c_val[n]
207.1179 +*
207.1180 +*  where:
207.1181 +*  m is the number of rows (auxiliary variables);
207.1182 +*  n is the number of columns (structural variables);
207.1183 +*  stat is the solution status (GLP_UNDEF = 1, GLP_FEAS = 2,
207.1184 +*     GLP_NOFEAS = 4, or GLP_OPT = 5);
207.1185 +*  obj_val is the objective value;
207.1186 +*  r_val[i], i = 1,...,m, is the value of i-th row;
207.1187 +*  c_val[j], j = 1,...,n, is the value of j-th column. */
207.1188 +
207.1189 +int glp_write_mip(glp_prob *mip, const char *fname)
207.1190 +{     XFILE *fp;
207.1191 +      int i, j, ret = 0;
207.1192 +      xprintf("Writing MIP solution to `%s'...\n", fname);
207.1193 +      fp = xfopen(fname, "w");
207.1194 +      if (fp == NULL)
207.1195 +      {  xprintf("Unable to create `%s' - %s\n", fname, xerrmsg());
207.1196 +         ret = 1;
207.1197 +         goto done;
207.1198 +      }
207.1199 +      /* number of rows, number of columns */
207.1200 +      xfprintf(fp, "%d %d\n", mip->m, mip->n);
207.1201 +      /* solution status, objective value */
207.1202 +      xfprintf(fp, "%d %.*g\n", mip->mip_stat, DBL_DIG, mip->mip_obj);
207.1203 +      /* rows (auxiliary variables) */
207.1204 +      for (i = 1; i <= mip->m; i++)
207.1205 +         xfprintf(fp, "%.*g\n", DBL_DIG, mip->row[i]->mipx);
207.1206 +      /* columns (structural variables) */
207.1207 +      for (j = 1; j <= mip->n; j++)
207.1208 +         xfprintf(fp, "%.*g\n", DBL_DIG, mip->col[j]->mipx);
207.1209 +      xfflush(fp);
207.1210 +      if (xferror(fp))
207.1211 +      {  xprintf("Write error on `%s' - %s\n", fname, xerrmsg());
207.1212 +         ret = 1;
207.1213 +         goto done;
207.1214 +      }
207.1215 +      xprintf("%d lines were written\n", 2 + mip->m + mip->n);
207.1216 +done: if (fp != NULL) xfclose(fp);
207.1217 +      return ret;
207.1218 +}
207.1219 +
207.1220 +/* eof */
   208.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
   208.2 +++ b/deps/glpk/src/glpapi12.c	Sun Nov 06 20:59:10 2011 +0100
   208.3 @@ -0,0 +1,2219 @@
   208.4 +/* glpapi12.c (basis factorization and simplex tableau routines) */
   208.5 +
   208.6 +/***********************************************************************
   208.7 +*  This code is part of GLPK (GNU Linear Programming Kit).
   208.8 +*
   208.9 +*  Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008,
  208.10 +*  2009, 2010, 2011 Andrew Makhorin, Department for Applied Informatics,
  208.11 +*  Moscow Aviation Institute, Moscow, Russia. All rights reserved.
  208.12 +*  E-mail: <mao@gnu.org>.
  208.13 +*
  208.14 +*  GLPK is free software: you can redistribute it and/or modify it
  208.15 +*  under the terms of the GNU General Public License as published by
  208.16 +*  the Free Software Foundation, either version 3 of the License, or
  208.17 +*  (at your option) any later version.
  208.18 +*
  208.19 +*  GLPK is distributed in the hope that it will be useful, but WITHOUT
  208.20 +*  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
  208.21 +*  or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
  208.22 +*  License for more details.
  208.23 +*
  208.24 +*  You should have received a copy of the GNU General Public License
  208.25 +*  along with GLPK. If not, see <http://www.gnu.org/licenses/>.
  208.26 +***********************************************************************/
  208.27 +
  208.28 +#include "glpapi.h"
  208.29 +
  208.30 +/***********************************************************************
  208.31 +*  NAME
  208.32 +*
  208.33 +*  glp_bf_exists - check if the basis factorization exists
  208.34 +*
  208.35 +*  SYNOPSIS
  208.36 +*
  208.37 +*  int glp_bf_exists(glp_prob *lp);
  208.38 +*
  208.39 +*  RETURNS
  208.40 +*
  208.41 +*  If the basis factorization for the current basis associated with
  208.42 +*  the specified problem object exists and therefore is available for
  208.43 +*  computations, the routine glp_bf_exists returns non-zero. Otherwise
  208.44 +*  the routine returns zero. */
  208.45 +
  208.46 +int glp_bf_exists(glp_prob *lp)
  208.47 +{     int ret;
  208.48 +      ret = (lp->m == 0 || lp->valid);
  208.49 +      return ret;
  208.50 +}
  208.51 +
  208.52 +/***********************************************************************
  208.53 +*  NAME
  208.54 +*
  208.55 +*  glp_factorize - compute the basis factorization
  208.56 +*
  208.57 +*  SYNOPSIS
  208.58 +*
  208.59 +*  int glp_factorize(glp_prob *lp);
  208.60 +*
  208.61 +*  DESCRIPTION
  208.62 +*
  208.63 +*  The routine glp_factorize computes the basis factorization for the
  208.64 +*  current basis associated with the specified problem object.
  208.65 +*
  208.66 +*  RETURNS
  208.67 +*
  208.68 +*  0  The basis factorization has been successfully computed.
  208.69 +*
  208.70 +*  GLP_EBADB
  208.71 +*     The basis matrix is invalid, i.e. the number of basic (auxiliary
  208.72 +*     and structural) variables differs from the number of rows in the
  208.73 +*     problem object.
  208.74 +*
  208.75 +*  GLP_ESING
  208.76 +*     The basis matrix is singular within the working precision.
  208.77 +*
  208.78 +*  GLP_ECOND
  208.79 +*     The basis matrix is ill-conditioned. */
  208.80 +
  208.81 +static int b_col(void *info, int j, int ind[], double val[])
  208.82 +{     glp_prob *lp = info;
  208.83 +      int m = lp->m;
  208.84 +      GLPAIJ *aij;
  208.85 +      int k, len;
  208.86 +      xassert(1 <= j && j <= m);
  208.87 +      /* determine the ordinal number of basic auxiliary or structural
  208.88 +         variable x[k] corresponding to basic variable xB[j] */
  208.89 +      k = lp->head[j];
  208.90 +      /* build j-th column of the basic matrix, which is k-th column of
  208.91 +         the scaled augmented matrix (I | -R*A*S) */
  208.92 +      if (k <= m)
  208.93 +      {  /* x[k] is auxiliary variable */
  208.94 +         len = 1;
  208.95 +         ind[1] = k;
  208.96 +         val[1] = 1.0;
  208.97 +      }
  208.98 +      else
  208.99 +      {  /* x[k] is structural variable */
 208.100 +         len = 0;
 208.101 +         for (aij = lp->col[k-m]->ptr; aij != NULL; aij = aij->c_next)
 208.102 +         {  len++;
 208.103 +            ind[len] = aij->row->i;
 208.104 +            val[len] = - aij->row->rii * aij->val * aij->col->sjj;
 208.105 +         }
 208.106 +      }
 208.107 +      return len;
 208.108 +}
 208.109 +
 208.110 +static void copy_bfcp(glp_prob *lp);
 208.111 +
 208.112 +int glp_factorize(glp_prob *lp)
 208.113 +{     int m = lp->m;
 208.114 +      int n = lp->n;
 208.115 +      GLPROW **row = lp->row;
 208.116 +      GLPCOL **col = lp->col;
 208.117 +      int *head = lp->head;
 208.118 +      int j, k, stat, ret;
 208.119 +      /* invalidate the basis factorization */
 208.120 +      lp->valid = 0;
 208.121 +      /* build the basis header */
 208.122 +      j = 0;
 208.123 +      for (k = 1; k <= m+n; k++)
 208.124 +      {  if (k <= m)
 208.125 +         {  stat = row[k]->stat;
 208.126 +            row[k]->bind = 0;
 208.127 +         }
 208.128 +         else
 208.129 +         {  stat = col[k-m]->stat;
 208.130 +            col[k-m]->bind = 0;
 208.131 +         }
 208.132 +         if (stat == GLP_BS)
 208.133 +         {  j++;
 208.134 +            if (j > m)
 208.135 +            {  /* too many basic variables */
 208.136 +               ret = GLP_EBADB;
 208.137 +               goto fini;
 208.138 +            }
 208.139 +            head[j] = k;
 208.140 +            if (k <= m)
 208.141 +               row[k]->bind = j;
 208.142 +            else
 208.143 +               col[k-m]->bind = j;
 208.144 +         }
 208.145 +      }
 208.146 +      if (j < m)
 208.147 +      {  /* too few basic variables */
 208.148 +         ret = GLP_EBADB;
 208.149 +         goto fini;
 208.150 +      }
 208.151 +      /* try to factorize the basis matrix */
 208.152 +      if (m > 0)
 208.153 +      {  if (lp->bfd == NULL)
 208.154 +         {  lp->bfd = bfd_create_it();
 208.155 +            copy_bfcp(lp);
 208.156 +         }
 208.157 +         switch (bfd_factorize(lp->bfd, m, lp->head, b_col, lp))
 208.158 +         {  case 0:
 208.159 +               /* ok */
 208.160 +               break;
 208.161 +            case BFD_ESING:
 208.162 +               /* singular matrix */
 208.163 +               ret = GLP_ESING;
 208.164 +               goto fini;
 208.165 +            case BFD_ECOND:
 208.166 +               /* ill-conditioned matrix */
 208.167 +               ret = GLP_ECOND;
 208.168 +               goto fini;
 208.169 +            default:
 208.170 +               xassert(lp != lp);
 208.171 +         }
 208.172 +         lp->valid = 1;
 208.173 +      }
 208.174 +      /* factorization successful */
 208.175 +      ret = 0;
 208.176 +fini: /* bring the return code to the calling program */
 208.177 +      return ret;
 208.178 +}
 208.179 +
 208.180 +/***********************************************************************
 208.181 +*  NAME
 208.182 +*
 208.183 +*  glp_bf_updated - check if the basis factorization has been updated
 208.184 +*
 208.185 +*  SYNOPSIS
 208.186 +*
 208.187 +*  int glp_bf_updated(glp_prob *lp);
 208.188 +*
 208.189 +*  RETURNS
 208.190 +*
 208.191 +*  If the basis factorization has been just computed from scratch, the
 208.192 +*  routine glp_bf_updated returns zero. Otherwise, if the factorization
 208.193 +*  has been updated one or more times, the routine returns non-zero. */
 208.194 +
 208.195 +int glp_bf_updated(glp_prob *lp)
 208.196 +{     int cnt;
 208.197 +      if (!(lp->m == 0 || lp->valid))
 208.198 +         xerror("glp_bf_update: basis factorization does not exist\n");
 208.199 +#if 0 /* 15/XI-2009 */
 208.200 +      cnt = (lp->m == 0 ? 0 : lp->bfd->upd_cnt);
 208.201 +#else
 208.202 +      cnt = (lp->m == 0 ? 0 : bfd_get_count(lp->bfd));
 208.203 +#endif
 208.204 +      return cnt;
 208.205 +}
 208.206 +
 208.207 +/***********************************************************************
 208.208 +*  NAME
 208.209 +*
 208.210 +*  glp_get_bfcp - retrieve basis factorization control parameters
 208.211 +*
 208.212 +*  SYNOPSIS
 208.213 +*
 208.214 +*  void glp_get_bfcp(glp_prob *lp, glp_bfcp *parm);
 208.215 +*
 208.216 +*  DESCRIPTION
 208.217 +*
 208.218 +*  The routine glp_get_bfcp retrieves control parameters, which are
 208.219 +*  used on computing and updating the basis factorization associated
 208.220 +*  with the specified problem object.
 208.221 +*
 208.222 +*  Current values of control parameters are stored by the routine in
 208.223 +*  a glp_bfcp structure, which the parameter parm points to. */
 208.224 +
 208.225 +void glp_get_bfcp(glp_prob *lp, glp_bfcp *parm)
 208.226 +{     glp_bfcp *bfcp = lp->bfcp;
 208.227 +      if (bfcp == NULL)
 208.228 +      {  parm->type = GLP_BF_FT;
 208.229 +         parm->lu_size = 0;
 208.230 +         parm->piv_tol = 0.10;
 208.231 +         parm->piv_lim = 4;
 208.232 +         parm->suhl = GLP_ON;
 208.233 +         parm->eps_tol = 1e-15;
 208.234 +         parm->max_gro = 1e+10;
 208.235 +         parm->nfs_max = 100;
 208.236 +         parm->upd_tol = 1e-6;
 208.237 +         parm->nrs_max = 100;
 208.238 +         parm->rs_size = 0;
 208.239 +      }
 208.240 +      else
 208.241 +         memcpy(parm, bfcp, sizeof(glp_bfcp));
 208.242 +      return;
 208.243 +}
 208.244 +
 208.245 +/***********************************************************************
 208.246 +*  NAME
 208.247 +*
 208.248 +*  glp_set_bfcp - change basis factorization control parameters
 208.249 +*
 208.250 +*  SYNOPSIS
 208.251 +*
 208.252 +*  void glp_set_bfcp(glp_prob *lp, const glp_bfcp *parm);
 208.253 +*
 208.254 +*  DESCRIPTION
 208.255 +*
 208.256 +*  The routine glp_set_bfcp changes control parameters, which are used
 208.257 +*  by internal GLPK routines in computing and updating the basis
 208.258 +*  factorization associated with the specified problem object.
 208.259 +*
 208.260 +*  New values of the control parameters should be passed in a structure
 208.261 +*  glp_bfcp, which the parameter parm points to.
 208.262 +*
 208.263 +*  The parameter parm can be specified as NULL, in which case all
 208.264 +*  control parameters are reset to their default values. */
 208.265 +
 208.266 +#if 0 /* 15/XI-2009 */
 208.267 +static void copy_bfcp(glp_prob *lp)
 208.268 +{     glp_bfcp _parm, *parm = &_parm;
 208.269 +      BFD *bfd = lp->bfd;
 208.270 +      glp_get_bfcp(lp, parm);
 208.271 +      xassert(bfd != NULL);
 208.272 +      bfd->type = parm->type;
 208.273 +      bfd->lu_size = parm->lu_size;
 208.274 +      bfd->piv_tol = parm->piv_tol;
 208.275 +      bfd->piv_lim = parm->piv_lim;
 208.276 +      bfd->suhl = parm->suhl;
 208.277 +      bfd->eps_tol = parm->eps_tol;
 208.278 +      bfd->max_gro = parm->max_gro;
 208.279 +      bfd->nfs_max = parm->nfs_max;
 208.280 +      bfd->upd_tol = parm->upd_tol;
 208.281 +      bfd->nrs_max = parm->nrs_max;
 208.282 +      bfd->rs_size = parm->rs_size;
 208.283 +      return;
 208.284 +}
 208.285 +#else
 208.286 +static void copy_bfcp(glp_prob *lp)
 208.287 +{     glp_bfcp _parm, *parm = &_parm;
 208.288 +      glp_get_bfcp(lp, parm);
 208.289 +      bfd_set_parm(lp->bfd, parm);
 208.290 +      return;
 208.291 +}
 208.292 +#endif
 208.293 +
 208.294 +void glp_set_bfcp(glp_prob *lp, const glp_bfcp *parm)
 208.295 +{     glp_bfcp *bfcp = lp->bfcp;
 208.296 +      if (parm == NULL)
 208.297 +      {  /* reset to default values */
 208.298 +         if (bfcp != NULL)
 208.299 +            xfree(bfcp), lp->bfcp = NULL;
 208.300 +      }
 208.301 +      else
 208.302 +      {  /* set to specified values */
 208.303 +         if (bfcp == NULL)
 208.304 +            bfcp = lp->bfcp = xmalloc(sizeof(glp_bfcp));
 208.305 +         memcpy(bfcp, parm, sizeof(glp_bfcp));
 208.306 +         if (!(bfcp->type == GLP_BF_FT || bfcp->type == GLP_BF_BG ||
 208.307 +               bfcp->type == GLP_BF_GR))
 208.308 +            xerror("glp_set_bfcp: type = %d; invalid parameter\n",
 208.309 +               bfcp->type);
 208.310 +         if (bfcp->lu_size < 0)
 208.311 +            xerror("glp_set_bfcp: lu_size = %d; invalid parameter\n",
 208.312 +               bfcp->lu_size);
 208.313 +         if (!(0.0 < bfcp->piv_tol && bfcp->piv_tol < 1.0))
 208.314 +            xerror("glp_set_bfcp: piv_tol = %g; invalid parameter\n",
 208.315 +               bfcp->piv_tol);
 208.316 +         if (bfcp->piv_lim < 1)
 208.317 +            xerror("glp_set_bfcp: piv_lim = %d; invalid parameter\n",
 208.318 +               bfcp->piv_lim);
 208.319 +         if (!(bfcp->suhl == GLP_ON || bfcp->suhl == GLP_OFF))
 208.320 +            xerror("glp_set_bfcp: suhl = %d; invalid parameter\n",
 208.321 +               bfcp->suhl);
 208.322 +         if (!(0.0 <= bfcp->eps_tol && bfcp->eps_tol <= 1e-6))
 208.323 +            xerror("glp_set_bfcp: eps_tol = %g; invalid parameter\n",
 208.324 +               bfcp->eps_tol);
 208.325 +         if (bfcp->max_gro < 1.0)
 208.326 +            xerror("glp_set_bfcp: max_gro = %g; invalid parameter\n",
 208.327 +               bfcp->max_gro);
 208.328 +         if (!(1 <= bfcp->nfs_max && bfcp->nfs_max <= 32767))
 208.329 +            xerror("glp_set_bfcp: nfs_max = %d; invalid parameter\n",
 208.330 +               bfcp->nfs_max);
 208.331 +         if (!(0.0 < bfcp->upd_tol && bfcp->upd_tol < 1.0))
 208.332 +            xerror("glp_set_bfcp: upd_tol = %g; invalid parameter\n",
 208.333 +               bfcp->upd_tol);
 208.334 +         if (!(1 <= bfcp->nrs_max && bfcp->nrs_max <= 32767))
 208.335 +            xerror("glp_set_bfcp: nrs_max = %d; invalid parameter\n",
 208.336 +               bfcp->nrs_max);
 208.337 +         if (bfcp->rs_size < 0)
 208.338 +            xerror("glp_set_bfcp: rs_size = %d; invalid parameter\n",
 208.339 +               bfcp->nrs_max);
 208.340 +         if (bfcp->rs_size == 0)
 208.341 +            bfcp->rs_size = 20 * bfcp->nrs_max;
 208.342 +      }
 208.343 +      if (lp->bfd != NULL) copy_bfcp(lp);
 208.344 +      return;
 208.345 +}
 208.346 +
 208.347 +/***********************************************************************
 208.348 +*  NAME
 208.349 +*
 208.350 +*  glp_get_bhead - retrieve the basis header information
 208.351 +*
 208.352 +*  SYNOPSIS
 208.353 +*
 208.354 +*  int glp_get_bhead(glp_prob *lp, int k);
 208.355 +*
 208.356 +*  DESCRIPTION
 208.357 +*
 208.358 +*  The routine glp_get_bhead returns the basis header information for
 208.359 +*  the current basis associated with the specified problem object.
 208.360 +*
 208.361 +*  RETURNS
 208.362 +*
 208.363 +*  If xB[k], 1 <= k <= m, is i-th auxiliary variable (1 <= i <= m), the
 208.364 +*  routine returns i. Otherwise, if xB[k] is j-th structural variable
 208.365 +*  (1 <= j <= n), the routine returns m+j. Here m is the number of rows
 208.366 +*  and n is the number of columns in the problem object. */
 208.367 +
 208.368 +int glp_get_bhead(glp_prob *lp, int k)
 208.369 +{     if (!(lp->m == 0 || lp->valid))
 208.370 +         xerror("glp_get_bhead: basis factorization does not exist\n");
 208.371 +      if (!(1 <= k && k <= lp->m))
 208.372 +         xerror("glp_get_bhead: k = %d; index out of range\n", k);
 208.373 +      return lp->head[k];
 208.374 +}
 208.375 +
 208.376 +/***********************************************************************
 208.377 +*  NAME
 208.378 +*
 208.379 +*  glp_get_row_bind - retrieve row index in the basis header
 208.380 +*
 208.381 +*  SYNOPSIS
 208.382 +*
 208.383 +*  int glp_get_row_bind(glp_prob *lp, int i);
 208.384 +*
 208.385 +*  RETURNS
 208.386 +*
 208.387 +*  The routine glp_get_row_bind returns the index k of basic variable
 208.388 +*  xB[k], 1 <= k <= m, which is i-th auxiliary variable, 1 <= i <= m,
 208.389 +*  in the current basis associated with the specified problem object,
 208.390 +*  where m is the number of rows. However, if i-th auxiliary variable
 208.391 +*  is non-basic, the routine returns zero. */
 208.392 +
 208.393 +int glp_get_row_bind(glp_prob *lp, int i)
 208.394 +{     if (!(lp->m == 0 || lp->valid))
 208.395 +         xerror("glp_get_row_bind: basis factorization does not exist\n"
 208.396 +            );
 208.397 +      if (!(1 <= i && i <= lp->m))
 208.398 +         xerror("glp_get_row_bind: i = %d; row number out of range\n",
 208.399 +            i);
 208.400 +      return lp->row[i]->bind;
 208.401 +}
 208.402 +
 208.403 +/***********************************************************************
 208.404 +*  NAME
 208.405 +*
 208.406 +*  glp_get_col_bind - retrieve column index in the basis header
 208.407 +*
 208.408 +*  SYNOPSIS
 208.409 +*
 208.410 +*  int glp_get_col_bind(glp_prob *lp, int j);
 208.411 +*
 208.412 +*  RETURNS
 208.413 +*
 208.414 +*  The routine glp_get_col_bind returns the index k of basic variable
 208.415 +*  xB[k], 1 <= k <= m, which is j-th structural variable, 1 <= j <= n,
 208.416 +*  in the current basis associated with the specified problem object,
 208.417 +*  where m is the number of rows, n is the number of columns. However,
 208.418 +*  if j-th structural variable is non-basic, the routine returns zero.*/
 208.419 +
 208.420 +int glp_get_col_bind(glp_prob *lp, int j)
 208.421 +{     if (!(lp->m == 0 || lp->valid))
 208.422 +         xerror("glp_get_col_bind: basis factorization does not exist\n"
 208.423 +            );
 208.424 +      if (!(1 <= j && j <= lp->n))
 208.425 +         xerror("glp_get_col_bind: j = %d; column number out of range\n"
 208.426 +            , j);
 208.427 +      return lp->col[j]->bind;
 208.428 +}
 208.429 +
 208.430 +/***********************************************************************
 208.431 +*  NAME
 208.432 +*
 208.433 +*  glp_ftran - perform forward transformation (solve system B*x = b)
 208.434 +*
 208.435 +*  SYNOPSIS
 208.436 +*
 208.437 +*  void glp_ftran(glp_prob *lp, double x[]);
 208.438 +*
 208.439 +*  DESCRIPTION
 208.440 +*
 208.441 +*  The routine glp_ftran performs forward transformation, i.e. solves
 208.442 +*  the system B*x = b, where B is the basis matrix corresponding to the
 208.443 +*  current basis for the specified problem object, x is the vector of
 208.444 +*  unknowns to be computed, b is the vector of right-hand sides.
 208.445 +*
 208.446 +*  On entry elements of the vector b should be stored in dense format
 208.447 +*  in locations x[1], ..., x[m], where m is the number of rows. On exit
 208.448 +*  the routine stores elements of the vector x in the same locations.
 208.449 +*
 208.450 +*  SCALING/UNSCALING
 208.451 +*
 208.452 +*  Let A~ = (I | -A) is the augmented constraint matrix of the original
 208.453 +*  (unscaled) problem. In the scaled LP problem instead the matrix A the
 208.454 +*  scaled matrix A" = R*A*S is actually used, so
 208.455 +*
 208.456 +*     A~" = (I | A") = (I | R*A*S) = (R*I*inv(R) | R*A*S) =
 208.457 +*                                                                    (1)
 208.458 +*         = R*(I | A)*S~ = R*A~*S~,
 208.459 +*
 208.460 +*  is the scaled augmented constraint matrix, where R and S are diagonal
 208.461 +*  scaling matrices used to scale rows and columns of the matrix A, and
 208.462 +*
 208.463 +*     S~ = diag(inv(R) | S)                                          (2)
 208.464 +*
 208.465 +*  is an augmented diagonal scaling matrix.
 208.466 +*
 208.467 +*  By definition:
 208.468 +*
 208.469 +*     A~ = (B | N),                                                  (3)
 208.470 +*
 208.471 +*  where B is the basic matrix, which consists of basic columns of the
 208.472 +*  augmented constraint matrix A~, and N is a matrix, which consists of
 208.473 +*  non-basic columns of A~. From (1) it follows that:
 208.474 +*
 208.475 +*     A~" = (B" | N") = (R*B*SB | R*N*SN),                           (4)
 208.476 +*
 208.477 +*  where SB and SN are parts of the augmented scaling matrix S~, which
 208.478 +*  correspond to basic and non-basic variables, respectively. Therefore
 208.479 +*
 208.480 +*     B" = R*B*SB,                                                   (5)
 208.481 +*
 208.482 +*  which is the scaled basis matrix. */
 208.483 +
 208.484 +void glp_ftran(glp_prob *lp, double x[])
 208.485 +{     int m = lp->m;
 208.486 +      GLPROW **row = lp->row;
 208.487 +      GLPCOL **col = lp->col;
 208.488 +      int i, k;
 208.489 +      /* B*x = b ===> (R*B*SB)*(inv(SB)*x) = R*b ===>
 208.490 +         B"*x" = b", where b" = R*b, x = SB*x" */
 208.491 +      if (!(m == 0 || lp->valid))
 208.492 +         xerror("glp_ftran: basis factorization does not exist\n");
 208.493 +      /* b" := R*b */
 208.494 +      for (i = 1; i <= m; i++)
 208.495 +         x[i] *= row[i]->rii;
 208.496 +      /* x" := inv(B")*b" */
 208.497 +      if (m > 0) bfd_ftran(lp->bfd, x);
 208.498 +      /* x := SB*x" */
 208.499 +      for (i = 1; i <= m; i++)
 208.500 +      {  k = lp->head[i];
 208.501 +         if (k <= m)
 208.502 +            x[i] /= row[k]->rii;
 208.503 +         else
 208.504 +            x[i] *= col[k-m]->sjj;
 208.505 +      }
 208.506 +      return;
 208.507 +}
 208.508 +
 208.509 +/***********************************************************************
 208.510 +*  NAME
 208.511 +*
 208.512 +*  glp_btran - perform backward transformation (solve system B'*x = b)
 208.513 +*
 208.514 +*  SYNOPSIS
 208.515 +*
 208.516 +*  void glp_btran(glp_prob *lp, double x[]);
 208.517 +*
 208.518 +*  DESCRIPTION
 208.519 +*
 208.520 +*  The routine glp_btran performs backward transformation, i.e. solves
 208.521 +*  the system B'*x = b, where B' is a matrix transposed to the basis
 208.522 +*  matrix corresponding to the current basis for the specified problem
 208.523 +*  problem object, x is the vector of unknowns to be computed, b is the
 208.524 +*  vector of right-hand sides.
 208.525 +*
 208.526 +*  On entry elements of the vector b should be stored in dense format
 208.527 +*  in locations x[1], ..., x[m], where m is the number of rows. On exit
 208.528 +*  the routine stores elements of the vector x in the same locations.
 208.529 +*
 208.530 +*  SCALING/UNSCALING
 208.531 +*
 208.532 +*  See comments to the routine glp_ftran. */
 208.533 +
 208.534 +void glp_btran(glp_prob *lp, double x[])
 208.535 +{     int m = lp->m;
 208.536 +      GLPROW **row = lp->row;
 208.537 +      GLPCOL **col = lp->col;
 208.538 +      int i, k;
 208.539 +      /* B'*x = b ===> (SB*B'*R)*(inv(R)*x) = SB*b ===>
 208.540 +         (B")'*x" = b", where b" = SB*b, x = R*x" */
 208.541 +      if (!(m == 0 || lp->valid))
 208.542 +         xerror("glp_btran: basis factorization does not exist\n");
 208.543 +      /* b" := SB*b */
 208.544 +      for (i = 1; i <= m; i++)
 208.545 +      {  k = lp->head[i];
 208.546 +         if (k <= m)
 208.547 +            x[i] /= row[k]->rii;
 208.548 +         else
 208.549 +            x[i] *= col[k-m]->sjj;
 208.550 +      }
 208.551 +      /* x" := inv[(B")']*b" */
 208.552 +      if (m > 0) bfd_btran(lp->bfd, x);
 208.553 +      /* x := R*x" */
 208.554 +      for (i = 1; i <= m; i++)
 208.555 +         x[i] *= row[i]->rii;
 208.556 +      return;
 208.557 +}
 208.558 +
 208.559 +/***********************************************************************
 208.560 +*  NAME
 208.561 +*
 208.562 +*  glp_warm_up - "warm up" LP basis
 208.563 +*
 208.564 +*  SYNOPSIS
 208.565 +*
 208.566 +*  int glp_warm_up(glp_prob *P);
 208.567 +*
 208.568 +*  DESCRIPTION
 208.569 +*
 208.570 +*  The routine glp_warm_up "warms up" the LP basis for the specified
 208.571 +*  problem object using current statuses assigned to rows and columns
 208.572 +*  (that is, to auxiliary and structural variables).
 208.573 +*
 208.574 +*  This operation includes computing factorization of the basis matrix
 208.575 +*  (if it does not exist), computing primal and dual components of basic
 208.576 +*  solution, and determining the solution status.
 208.577 +*
 208.578 +*  RETURNS
 208.579 +*
 208.580 +*  0  The operation has been successfully performed.
 208.581 +*
 208.582 +*  GLP_EBADB
 208.583 +*     The basis matrix is invalid, i.e. the number of basic (auxiliary
 208.584 +*     and structural) variables differs from the number of rows in the
 208.585 +*     problem object.
 208.586 +*
 208.587 +*  GLP_ESING
 208.588 +*     The basis matrix is singular within the working precision.
 208.589 +*
 208.590 +*  GLP_ECOND
 208.591 +*     The basis matrix is ill-conditioned. */
 208.592 +
 208.593 +int glp_warm_up(glp_prob *P)
 208.594 +{     GLPROW *row;
 208.595 +      GLPCOL *col;
 208.596 +      GLPAIJ *aij;
 208.597 +      int i, j, type, ret;
 208.598 +      double eps, temp, *work;
 208.599 +      /* invalidate basic solution */
 208.600 +      P->pbs_stat = P->dbs_stat = GLP_UNDEF;
 208.601 +      P->obj_val = 0.0;
 208.602 +      P->some = 0;
 208.603 +      for (i = 1; i <= P->m; i++)
 208.604 +      {  row = P->row[i];
 208.605 +         row->prim = row->dual = 0.0;
 208.606 +      }
 208.607 +      for (j = 1; j <= P->n; j++)
 208.608 +      {  col = P->col[j];
 208.609 +         col->prim = col->dual = 0.0;
 208.610 +      }
 208.611 +      /* compute the basis factorization, if necessary */
 208.612 +      if (!glp_bf_exists(P))
 208.613 +      {  ret = glp_factorize(P);
 208.614 +         if (ret != 0) goto done;
 208.615 +      }
 208.616 +      /* allocate working array */
 208.617 +      work = xcalloc(1+P->m, sizeof(double));
 208.618 +      /* determine and store values of non-basic variables, compute
 208.619 +         vector (- N * xN) */
 208.620 +      for (i = 1; i <= P->m; i++)
 208.621 +         work[i] = 0.0;
 208.622 +      for (i = 1; i <= P->m; i++)
 208.623 +      {  row = P->row[i];
 208.624 +         if (row->stat == GLP_BS)
 208.625 +            continue;
 208.626 +         else if (row->stat == GLP_NL)
 208.627 +            row->prim = row->lb;
 208.628 +         else if (row->stat == GLP_NU)
 208.629 +            row->prim = row->ub;
 208.630 +         else if (row->stat == GLP_NF)
 208.631 +            row->prim = 0.0;
 208.632 +         else if (row->stat == GLP_NS)
 208.633 +            row->prim = row->lb;
 208.634 +         else
 208.635 +            xassert(row != row);
 208.636 +         /* N[j] is i-th column of matrix (I|-A) */
 208.637 +         work[i] -= row->prim;
 208.638 +      }
 208.639 +      for (j = 1; j <= P->n; j++)
 208.640 +      {  col = P->col[j];
 208.641 +         if (col->stat == GLP_BS)
 208.642 +            continue;
 208.643 +         else if (col->stat == GLP_NL)
 208.644 +            col->prim = col->lb;
 208.645 +         else if (col->stat == GLP_NU)
 208.646 +            col->prim = col->ub;
 208.647 +         else if (col->stat == GLP_NF)
 208.648 +            col->prim = 0.0;
 208.649 +         else if (col->stat == GLP_NS)
 208.650 +            col->prim = col->lb;
 208.651 +         else
 208.652 +            xassert(col != col);
 208.653 +         /* N[j] is (m+j)-th column of matrix (I|-A) */
 208.654 +         if (col->prim != 0.0)
 208.655 +         {  for (aij = col->ptr; aij != NULL; aij = aij->c_next)
 208.656 +               work[aij->row->i] += aij->val * col->prim;
 208.657 +         }
 208.658 +      }
 208.659 +      /* compute vector of basic variables xB = - inv(B) * N * xN */
 208.660 +      glp_ftran(P, work);
 208.661 +      /* store values of basic variables, check primal feasibility */
 208.662 +      P->pbs_stat = GLP_FEAS;
 208.663 +      for (i = 1; i <= P->m; i++)
 208.664 +      {  row = P->row[i];
 208.665 +         if (row->stat != GLP_BS)
 208.666 +            continue;
 208.667 +         row->prim = work[row->bind];
 208.668 +         type = row->type;
 208.669 +         if (type == GLP_LO || type == GLP_DB || type == GLP_FX)
 208.670 +         {  eps = 1e-6 + 1e-9 * fabs(row->lb);
 208.671 +            if (row->prim < row->lb - eps)
 208.672 +               P->pbs_stat = GLP_INFEAS;
 208.673 +         }
 208.674 +         if (type == GLP_UP || type == GLP_DB || type == GLP_FX)
 208.675 +         {  eps = 1e-6 + 1e-9 * fabs(row->ub);
 208.676 +            if (row->prim > row->ub + eps)
 208.677 +               P->pbs_stat = GLP_INFEAS;
 208.678 +         }
 208.679 +      }
 208.680 +      for (j = 1; j <= P->n; j++)
 208.681 +      {  col = P->col[j];
 208.682 +         if (col->stat != GLP_BS)
 208.683 +            continue;
 208.684 +         col->prim = work[col->bind];
 208.685 +         type = col->type;
 208.686 +         if (type == GLP_LO || type == GLP_DB || type == GLP_FX)
 208.687 +         {  eps = 1e-6 + 1e-9 * fabs(col->lb);
 208.688 +            if (col->prim < col->lb - eps)
 208.689 +               P->pbs_stat = GLP_INFEAS;
 208.690 +         }
 208.691 +         if (type == GLP_UP || type == GLP_DB || type == GLP_FX)
 208.692 +         {  eps = 1e-6 + 1e-9 * fabs(col->ub);
 208.693 +            if (col->prim > col->ub + eps)
 208.694 +               P->pbs_stat = GLP_INFEAS;
 208.695 +         }
 208.696 +      }
 208.697 +      /* compute value of the objective function */
 208.698 +      P->obj_val = P->c0;
 208.699 +      for (j = 1; j <= P->n; j++)
 208.700 +      {  col = P->col[j];
 208.701 +         P->obj_val += col->coef * col->prim;
 208.702 +      }
 208.703 +      /* build vector cB of objective coefficients at basic variables */
 208.704 +      for (i = 1; i <= P->m; i++)
 208.705 +         work[i] = 0.0;
 208.706 +      for (j = 1; j <= P->n; j++)
 208.707 +      {  col = P->col[j];
 208.708 +         if (col->stat == GLP_BS)
 208.709 +            work[col->bind] = col->coef;
 208.710 +      }
 208.711 +      /* compute vector of simplex multipliers pi = inv(B') * cB */
 208.712 +      glp_btran(P, work);
 208.713 +      /* compute and store reduced costs of non-basic variables d[j] =
 208.714 +         c[j] - N'[j] * pi, check dual feasibility */
 208.715 +      P->dbs_stat = GLP_FEAS;
 208.716 +      for (i = 1; i <= P->m; i++)
 208.717 +      {  row = P->row[i];
 208.718 +         if (row->stat == GLP_BS)
 208.719 +         {  row->dual = 0.0;
 208.720 +            continue;
 208.721 +         }
 208.722 +         /* N[j] is i-th column of matrix (I|-A) */
 208.723 +         row->dual = - work[i];
 208.724 +         type = row->type;
 208.725 +         temp = (P->dir == GLP_MIN ? + row->dual : - row->dual);
 208.726 +         if ((type == GLP_FR || type == GLP_LO) && temp < -1e-5 ||
 208.727 +             (type == GLP_FR || type == GLP_UP) && temp > +1e-5)
 208.728 +            P->dbs_stat = GLP_INFEAS;
 208.729 +      }
 208.730 +      for (j = 1; j <= P->n; j++)
 208.731 +      {  col = P->col[j];
 208.732 +         if (col->stat == GLP_BS)
 208.733 +         {  col->dual = 0.0;
 208.734 +            continue;
 208.735 +         }
 208.736 +         /* N[j] is (m+j)-th column of matrix (I|-A) */
 208.737 +         col->dual = col->coef;
 208.738 +         for (aij = col->ptr; aij != NULL; aij = aij->c_next)
 208.739 +            col->dual += aij->val * work[aij->row->i];
 208.740 +         type = col->type;
 208.741 +         temp = (P->dir == GLP_MIN ? + col->dual : - col->dual);
 208.742 +         if ((type == GLP_FR || type == GLP_LO) && temp < -1e-5 ||
 208.743 +             (type == GLP_FR || type == GLP_UP) && temp > +1e-5)
 208.744 +            P->dbs_stat = GLP_INFEAS;
 208.745 +      }
 208.746 +      /* free working array */
 208.747 +      xfree(work);
 208.748 +      ret = 0;
 208.749 +done: return ret;
 208.750 +}
 208.751 +
 208.752 +/***********************************************************************
 208.753 +*  NAME
 208.754 +*
 208.755 +*  glp_eval_tab_row - compute row of the simplex tableau
 208.756 +*
 208.757 +*  SYNOPSIS
 208.758 +*
 208.759 +*  int glp_eval_tab_row(glp_prob *lp, int k, int ind[], double val[]);
 208.760 +*
 208.761 +*  DESCRIPTION
 208.762 +*
 208.763 +*  The routine glp_eval_tab_row computes a row of the current simplex
 208.764 +*  tableau for the basic variable, which is specified by the number k:
 208.765 +*  if 1 <= k <= m, x[k] is k-th auxiliary variable; if m+1 <= k <= m+n,
 208.766 +*  x[k] is (k-m)-th structural variable, where m is number of rows, and
 208.767 +*  n is number of columns. The current basis must be available.
 208.768 +*
 208.769 +*  The routine stores column indices and numerical values of non-zero
 208.770 +*  elements of the computed row using sparse format to the locations
 208.771 +*  ind[1], ..., ind[len] and val[1], ..., val[len], respectively, where
 208.772 +*  0 <= len <= n is number of non-zeros returned on exit.
 208.773 +*
 208.774 +*  Element indices stored in the array ind have the same sense as the
 208.775 +*  index k, i.e. indices 1 to m denote auxiliary variables and indices
 208.776 +*  m+1 to m+n denote structural ones (all these variables are obviously
 208.777 +*  non-basic by definition).
 208.778 +*
 208.779 +*  The computed row shows how the specified basic variable x[k] = xB[i]
 208.780 +*  depends on non-basic variables:
 208.781 +*
 208.782 +*     xB[i] = alfa[i,1]*xN[1] + alfa[i,2]*xN[2] + ... + alfa[i,n]*xN[n],
 208.783 +*
 208.784 +*  where alfa[i,j] are elements of the simplex table row, xN[j] are
 208.785 +*  non-basic (auxiliary and structural) variables.
 208.786 +*
 208.787 +*  RETURNS
 208.788 +*
 208.789 +*  The routine returns number of non-zero elements in the simplex table
 208.790 +*  row stored in the arrays ind and val.
 208.791 +*
 208.792 +*  BACKGROUND
 208.793 +*
 208.794 +*  The system of equality constraints of the LP problem is:
 208.795 +*
 208.796 +*     xR = A * xS,                                                   (1)
 208.797 +*
 208.798 +*  where xR is the vector of auxliary variables, xS is the vector of
 208.799 +*  structural variables, A is the matrix of constraint coefficients.
 208.800 +*
 208.801 +*  The system (1) can be written in homogenous form as follows:
 208.802 +*
 208.803 +*     A~ * x = 0,                                                    (2)
 208.804 +*
 208.805 +*  where A~ = (I | -A) is the augmented constraint matrix (has m rows
 208.806 +*  and m+n columns), x = (xR | xS) is the vector of all (auxiliary and
 208.807 +*  structural) variables.
 208.808 +*
 208.809 +*  By definition for the current basis we have:
 208.810 +*
 208.811 +*     A~ = (B | N),                                                  (3)
 208.812 +*
 208.813 +*  where B is the basis matrix. Thus, the system (2) can be written as:
 208.814 +*
 208.815 +*     B * xB + N * xN = 0.                                           (4)
 208.816 +*
 208.817 +*  From (4) it follows that:
 208.818 +*
 208.819 +*     xB = A^ * xN,                                                  (5)
 208.820 +*
 208.821 +*  where the matrix
 208.822 +*
 208.823 +*     A^ = - inv(B) * N                                              (6)
 208.824 +*
 208.825 +*  is called the simplex table.
 208.826 +*
 208.827 +*  It is understood that i-th row of the simplex table is:
 208.828 +*
 208.829 +*     e * A^ = - e * inv(B) * N,                                     (7)
 208.830 +*
 208.831 +*  where e is a unity vector with e[i] = 1.
 208.832 +*
 208.833 +*  To compute i-th row of the simplex table the routine first computes
 208.834 +*  i-th row of the inverse:
 208.835 +*
 208.836 +*     rho = inv(B') * e,                                             (8)
 208.837 +*
 208.838 +*  where B' is a matrix transposed to B, and then computes elements of
 208.839 +*  i-th row of the simplex table as scalar products:
 208.840 +*
 208.841 +*     alfa[i,j] = - rho * N[j]   for all j,                          (9)
 208.842 +*
 208.843 +*  where N[j] is a column of the augmented constraint matrix A~, which
 208.844 +*  corresponds to some non-basic auxiliary or structural variable. */
 208.845 +
 208.846 +int glp_eval_tab_row(glp_prob *lp, int k, int ind[], double val[])
 208.847 +{     int m = lp->m;
 208.848 +      int n = lp->n;
 208.849 +      int i, t, len, lll, *iii;
 208.850 +      double alfa, *rho, *vvv;
 208.851 +      if (!(m == 0 || lp->valid))
 208.852 +         xerror("glp_eval_tab_row: basis factorization does not exist\n"
 208.853 +            );
 208.854 +      if (!(1 <= k && k <= m+n))
 208.855 +         xerror("glp_eval_tab_row: k = %d; variable number out of range"
 208.856 +            , k);
 208.857 +      /* determine xB[i] which corresponds to x[k] */
 208.858 +      if (k <= m)
 208.859 +         i = glp_get_row_bind(lp, k);
 208.860 +      else
 208.861 +         i = glp_get_col_bind(lp, k-m);
 208.862 +      if (i == 0)
 208.863 +         xerror("glp_eval_tab_row: k = %d; variable must be basic", k);
 208.864 +      xassert(1 <= i && i <= m);
 208.865 +      /* allocate working arrays */
 208.866 +      rho = xcalloc(1+m, sizeof(double));
 208.867 +      iii = xcalloc(1+m, sizeof(int));
 208.868 +      vvv = xcalloc(1+m, sizeof(double));
 208.869 +      /* compute i-th row of the inverse; see (8) */
 208.870 +      for (t = 1; t <= m; t++) rho[t] = 0.0;
 208.871 +      rho[i] = 1.0;
 208.872 +      glp_btran(lp, rho);
 208.873 +      /* compute i-th row of the simplex table */
 208.874 +      len = 0;
 208.875 +      for (k = 1; k <= m+n; k++)
 208.876 +      {  if (k <= m)
 208.877 +         {  /* x[k] is auxiliary variable, so N[k] is a unity column */
 208.878 +            if (glp_get_row_stat(lp, k) == GLP_BS) continue;
 208.879 +            /* compute alfa[i,j]; see (9) */
 208.880 +            alfa = - rho[k];
 208.881 +         }
 208.882 +         else
 208.883 +         {  /* x[k] is structural variable, so N[k] is a column of the
 208.884 +               original constraint matrix A with negative sign */
 208.885 +            if (glp_get_col_stat(lp, k-m) == GLP_BS) continue;
 208.886 +            /* compute alfa[i,j]; see (9) */
 208.887 +            lll = glp_get_mat_col(lp, k-m, iii, vvv);
 208.888 +            alfa = 0.0;
 208.889 +            for (t = 1; t <= lll; t++) alfa += rho[iii[t]] * vvv[t];
 208.890 +         }
 208.891 +         /* store alfa[i,j] */
 208.892 +         if (alfa != 0.0) len++, ind[len] = k, val[len] = alfa;
 208.893 +      }
 208.894 +      xassert(len <= n);
 208.895 +      /* free working arrays */
 208.896 +      xfree(rho);
 208.897 +      xfree(iii);
 208.898 +      xfree(vvv);
 208.899 +      /* return to the calling program */
 208.900 +      return len;
 208.901 +}
 208.902 +
 208.903 +/***********************************************************************
 208.904 +*  NAME
 208.905 +*
 208.906 +*  glp_eval_tab_col - compute column of the simplex tableau
 208.907 +*
 208.908 +*  SYNOPSIS
 208.909 +*
 208.910 +*  int glp_eval_tab_col(glp_prob *lp, int k, int ind[], double val[]);
 208.911 +*
 208.912 +*  DESCRIPTION
 208.913 +*
 208.914 +*  The routine glp_eval_tab_col computes a column of the current simplex
 208.915 +*  table for the non-basic variable, which is specified by the number k:
 208.916 +*  if 1 <= k <= m, x[k] is k-th auxiliary variable; if m+1 <= k <= m+n,
 208.917 +*  x[k] is (k-m)-th structural variable, where m is number of rows, and
 208.918 +*  n is number of columns. The current basis must be available.
 208.919 +*
 208.920 +*  The routine stores row indices and numerical values of non-zero
 208.921 +*  elements of the computed column using sparse format to the locations
 208.922 +*  ind[1], ..., ind[len] and val[1], ..., val[len] respectively, where
 208.923 +*  0 <= len <= m is number of non-zeros returned on exit.
 208.924 +*
 208.925 +*  Element indices stored in the array ind have the same sense as the
 208.926 +*  index k, i.e. indices 1 to m denote auxiliary variables and indices
 208.927 +*  m+1 to m+n denote structural ones (all these variables are obviously
 208.928 +*  basic by the definition).
 208.929 +*
 208.930 +*  The computed column shows how basic variables depend on the specified
 208.931 +*  non-basic variable x[k] = xN[j]:
 208.932 +*
 208.933 +*     xB[1] = ... + alfa[1,j]*xN[j] + ...
 208.934 +*     xB[2] = ... + alfa[2,j]*xN[j] + ...
 208.935 +*              . . . . . .
 208.936 +*     xB[m] = ... + alfa[m,j]*xN[j] + ...
 208.937 +*
 208.938 +*  where alfa[i,j] are elements of the simplex table column, xB[i] are
 208.939 +*  basic (auxiliary and structural) variables.
 208.940 +*
 208.941 +*  RETURNS
 208.942 +*
 208.943 +*  The routine returns number of non-zero elements in the simplex table
 208.944 +*  column stored in the arrays ind and val.
 208.945 +*
 208.946 +*  BACKGROUND
 208.947 +*
 208.948 +*  As it was explained in comments to the routine glp_eval_tab_row (see
 208.949 +*  above) the simplex table is the following matrix:
 208.950 +*
 208.951 +*     A^ = - inv(B) * N.                                             (1)
 208.952 +*
 208.953 +*  Therefore j-th column of the simplex table is:
 208.954 +*
 208.955 +*     A^ * e = - inv(B) * N * e = - inv(B) * N[j],                   (2)
 208.956 +*
 208.957 +*  where e is a unity vector with e[j] = 1, B is the basis matrix, N[j]
 208.958 +*  is a column of the augmented constraint matrix A~, which corresponds
 208.959 +*  to the given non-basic auxiliary or structural variable. */
 208.960 +
 208.961 +int glp_eval_tab_col(glp_prob *lp, int k, int ind[], double val[])
 208.962 +{     int m = lp->m;
 208.963 +      int n = lp->n;
 208.964 +      int t, len, stat;
 208.965 +      double *col;
 208.966 +      if (!(m == 0 || lp->valid))
 208.967 +         xerror("glp_eval_tab_col: basis factorization does not exist\n"
 208.968 +            );
 208.969 +      if (!(1 <= k && k <= m+n))
 208.970 +         xerror("glp_eval_tab_col: k = %d; variable number out of range"
 208.971 +            , k);
 208.972 +      if (k <= m)
 208.973 +         stat = glp_get_row_stat(lp, k);
 208.974 +      else
 208.975 +         stat = glp_get_col_stat(lp, k-m);
 208.976 +      if (stat == GLP_BS)
 208.977 +         xerror("glp_eval_tab_col: k = %d; variable must be non-basic",
 208.978 +            k);
 208.979 +      /* obtain column N[k] with negative sign */
 208.980 +      col = xcalloc(1+m, sizeof(double));
 208.981 +      for (t = 1; t <= m; t++) col[t] = 0.0;
 208.982 +      if (k <= m)
 208.983 +      {  /* x[k] is auxiliary variable, so N[k] is a unity column */
 208.984 +         col[k] = -1.0;
 208.985 +      }
 208.986 +      else
 208.987 +      {  /* x[k] is structural variable, so N[k] is a column of the
 208.988 +            original constraint matrix A with negative sign */
 208.989 +         len = glp_get_mat_col(lp, k-m, ind, val);
 208.990 +         for (t = 1; t <= len; t++) col[ind[t]] = val[t];
 208.991 +      }
 208.992 +      /* compute column of the simplex table, which corresponds to the
 208.993 +         specified non-basic variable x[k] */
 208.994 +      glp_ftran(lp, col);
 208.995 +      len = 0;
 208.996 +      for (t = 1; t <= m; t++)
 208.997 +      {  if (col[t] != 0.0)
 208.998 +         {  len++;
 208.999 +            ind[len] = glp_get_bhead(lp, t);
208.1000 +            val[len] = col[t];
208.1001 +         }
208.1002 +      }
208.1003 +      xfree(col);
208.1004 +      /* return to the calling program */
208.1005 +      return len;
208.1006 +}
208.1007 +
208.1008 +/***********************************************************************
208.1009 +*  NAME
208.1010 +*
208.1011 +*  glp_transform_row - transform explicitly specified row
208.1012 +*
208.1013 +*  SYNOPSIS
208.1014 +*
208.1015 +*  int glp_transform_row(glp_prob *P, int len, int ind[], double val[]);
208.1016 +*
208.1017 +*  DESCRIPTION
208.1018 +*
208.1019 +*  The routine glp_transform_row performs the same operation as the
208.1020 +*  routine glp_eval_tab_row with exception that the row to be
208.1021 +*  transformed is specified explicitly as a sparse vector.
208.1022 +*
208.1023 +*  The explicitly specified row may be thought as a linear form:
208.1024 +*
208.1025 +*     x = a[1]*x[m+1] + a[2]*x[m+2] + ... + a[n]*x[m+n],             (1)
208.1026 +*
208.1027 +*  where x is an auxiliary variable for this row, a[j] are coefficients
208.1028 +*  of the linear form, x[m+j] are structural variables.
208.1029 +*
208.1030 +*  On entry column indices and numerical values of non-zero elements of
208.1031 +*  the row should be stored in locations ind[1], ..., ind[len] and
208.1032 +*  val[1], ..., val[len], where len is the number of non-zero elements.
208.1033 +*
208.1034 +*  This routine uses the system of equality constraints and the current
208.1035 +*  basis in order to express the auxiliary variable x in (1) through the
208.1036 +*  current non-basic variables (as if the transformed row were added to
208.1037 +*  the problem object and its auxiliary variable were basic), i.e. the
208.1038 +*  resultant row has the form:
208.1039 +*
208.1040 +*     x = alfa[1]*xN[1] + alfa[2]*xN[2] + ... + alfa[n]*xN[n],       (2)
208.1041 +*
208.1042 +*  where xN[j] are non-basic (auxiliary or structural) variables, n is
208.1043 +*  the number of columns in the LP problem object.
208.1044 +*
208.1045 +*  On exit the routine stores indices and numerical values of non-zero
208.1046 +*  elements of the resultant row (2) in locations ind[1], ..., ind[len']
208.1047 +*  and val[1], ..., val[len'], where 0 <= len' <= n is the number of
208.1048 +*  non-zero elements in the resultant row returned by the routine. Note
208.1049 +*  that indices (numbers) of non-basic variables stored in the array ind
208.1050 +*  correspond to original ordinal numbers of variables: indices 1 to m
208.1051 +*  mean auxiliary variables and indices m+1 to m+n mean structural ones.
208.1052 +*
208.1053 +*  RETURNS
208.1054 +*
208.1055 +*  The routine returns len', which is the number of non-zero elements in
208.1056 +*  the resultant row stored in the arrays ind and val.
208.1057 +*
208.1058 +*  BACKGROUND
208.1059 +*
208.1060 +*  The explicitly specified row (1) is transformed in the same way as it
208.1061 +*  were the objective function row.
208.1062 +*
208.1063 +*  From (1) it follows that:
208.1064 +*
208.1065 +*     x = aB * xB + aN * xN,                                         (3)
208.1066 +*
208.1067 +*  where xB is the vector of basic variables, xN is the vector of
208.1068 +*  non-basic variables.
208.1069 +*
208.1070 +*  The simplex table, which corresponds to the current basis, is:
208.1071 +*
208.1072 +*     xB = [-inv(B) * N] * xN.                                       (4)
208.1073 +*
208.1074 +*  Therefore substituting xB from (4) to (3) we have:
208.1075 +*
208.1076 +*     x = aB * [-inv(B) * N] * xN + aN * xN =
208.1077 +*                                                                    (5)
208.1078 +*       = rho * (-N) * xN + aN * xN = alfa * xN,
208.1079 +*
208.1080 +*  where:
208.1081 +*
208.1082 +*     rho = inv(B') * aB,                                            (6)
208.1083 +*
208.1084 +*  and
208.1085 +*
208.1086 +*     alfa = aN + rho * (-N)                                         (7)
208.1087 +*
208.1088 +*  is the resultant row computed by the routine. */
208.1089 +
208.1090 +int glp_transform_row(glp_prob *P, int len, int ind[], double val[])
208.1091 +{     int i, j, k, m, n, t, lll, *iii;
208.1092 +      double alfa, *a, *aB, *rho, *vvv;
208.1093 +      if (!glp_bf_exists(P))
208.1094 +         xerror("glp_transform_row: basis factorization does not exist "
208.1095 +            "\n");
208.1096 +      m = glp_get_num_rows(P);
208.1097 +      n = glp_get_num_cols(P);
208.1098 +      /* unpack the row to be transformed to the array a */
208.1099 +      a = xcalloc(1+n, sizeof(double));
208.1100 +      for (j = 1; j <= n; j++) a[j] = 0.0;
208.1101 +      if (!(0 <= len && len <= n))
208.1102 +         xerror("glp_transform_row: len = %d; invalid row length\n",
208.1103 +            len);
208.1104 +      for (t = 1; t <= len; t++)
208.1105 +      {  j = ind[t];
208.1106 +         if (!(1 <= j && j <= n))
208.1107 +            xerror("glp_transform_row: ind[%d] = %d; column index out o"
208.1108 +               "f range\n", t, j);
208.1109 +         if (val[t] == 0.0)
208.1110 +            xerror("glp_transform_row: val[%d] = 0; zero coefficient no"
208.1111 +               "t allowed\n", t);
208.1112 +         if (a[j] != 0.0)
208.1113 +            xerror("glp_transform_row: ind[%d] = %d; duplicate column i"
208.1114 +               "ndices not allowed\n", t, j);
208.1115 +         a[j] = val[t];
208.1116 +      }
208.1117 +      /* construct the vector aB */
208.1118 +      aB = xcalloc(1+m, sizeof(double));
208.1119 +      for (i = 1; i <= m; i++)
208.1120 +      {  k = glp_get_bhead(P, i);
208.1121 +         /* xB[i] is k-th original variable */
208.1122 +         xassert(1 <= k && k <= m+n);
208.1123 +         aB[i] = (k <= m ? 0.0 : a[k-m]);
208.1124 +      }
208.1125 +      /* solve the system B'*rho = aB to compute the vector rho */
208.1126 +      rho = aB, glp_btran(P, rho);
208.1127 +      /* compute coefficients at non-basic auxiliary variables */
208.1128 +      len = 0;
208.1129 +      for (i = 1; i <= m; i++)
208.1130 +      {  if (glp_get_row_stat(P, i) != GLP_BS)
208.1131 +         {  alfa = - rho[i];
208.1132 +            if (alfa != 0.0)
208.1133 +            {  len++;
208.1134 +               ind[len] = i;
208.1135 +               val[len] = alfa;
208.1136 +            }
208.1137 +         }
208.1138 +      }
208.1139 +      /* compute coefficients at non-basic structural variables */
208.1140 +      iii = xcalloc(1+m, sizeof(int));
208.1141 +      vvv = xcalloc(1+m, sizeof(double));
208.1142 +      for (j = 1; j <= n; j++)
208.1143 +      {  if (glp_get_col_stat(P, j) != GLP_BS)
208.1144 +         {  alfa = a[j];
208.1145 +            lll = glp_get_mat_col(P, j, iii, vvv);
208.1146 +            for (t = 1; t <= lll; t++) alfa += vvv[t] * rho[iii[t]];
208.1147 +            if (alfa != 0.0)
208.1148 +            {  len++;
208.1149 +               ind[len] = m+j;
208.1150 +               val[len] = alfa;
208.1151 +            }
208.1152 +         }
208.1153 +      }
208.1154 +      xassert(len <= n);
208.1155 +      xfree(iii);
208.1156 +      xfree(vvv);
208.1157 +      xfree(aB);
208.1158 +      xfree(a);
208.1159 +      return len;
208.1160 +}
208.1161 +
208.1162 +/***********************************************************************
208.1163 +*  NAME
208.1164 +*
208.1165 +*  glp_transform_col - transform explicitly specified column
208.1166 +*
208.1167 +*  SYNOPSIS
208.1168 +*
208.1169 +*  int glp_transform_col(glp_prob *P, int len, int ind[], double val[]);
208.1170 +*
208.1171 +*  DESCRIPTION
208.1172 +*
208.1173 +*  The routine glp_transform_col performs the same operation as the
208.1174 +*  routine glp_eval_tab_col with exception that the column to be
208.1175 +*  transformed is specified explicitly as a sparse vector.
208.1176 +*
208.1177 +*  The explicitly specified column may be thought as if it were added
208.1178 +*  to the original system of equality constraints:
208.1179 +*
208.1180 +*     x[1] = a[1,1]*x[m+1] + ... + a[1,n]*x[m+n] + a[1]*x
208.1181 +*     x[2] = a[2,1]*x[m+1] + ... + a[2,n]*x[m+n] + a[2]*x            (1)
208.1182 +*        .  .  .  .  .  .  .  .  .  .  .  .  .  .  .
208.1183 +*     x[m] = a[m,1]*x[m+1] + ... + a[m,n]*x[m+n] + a[m]*x
208.1184 +*
208.1185 +*  where x[i] are auxiliary variables, x[m+j] are structural variables,
208.1186 +*  x is a structural variable for the explicitly specified column, a[i]
208.1187 +*  are constraint coefficients for x.
208.1188 +*
208.1189 +*  On entry row indices and numerical values of non-zero elements of
208.1190 +*  the column should be stored in locations ind[1], ..., ind[len] and
208.1191 +*  val[1], ..., val[len], where len is the number of non-zero elements.
208.1192 +*
208.1193 +*  This routine uses the system of equality constraints and the current
208.1194 +*  basis in order to express the current basic variables through the
208.1195 +*  structural variable x in (1) (as if the transformed column were added
208.1196 +*  to the problem object and the variable x were non-basic), i.e. the
208.1197 +*  resultant column has the form:
208.1198 +*
208.1199 +*     xB[1] = ... + alfa[1]*x
208.1200 +*     xB[2] = ... + alfa[2]*x                                        (2)
208.1201 +*        .  .  .  .  .  .
208.1202 +*     xB[m] = ... + alfa[m]*x
208.1203 +*
208.1204 +*  where xB are basic (auxiliary and structural) variables, m is the
208.1205 +*  number of rows in the problem object.
208.1206 +*
208.1207 +*  On exit the routine stores indices and numerical values of non-zero
208.1208 +*  elements of the resultant column (2) in locations ind[1], ...,
208.1209 +*  ind[len'] and val[1], ..., val[len'], where 0 <= len' <= m is the
208.1210 +*  number of non-zero element in the resultant column returned by the
208.1211 +*  routine. Note that indices (numbers) of basic variables stored in
208.1212 +*  the array ind correspond to original ordinal numbers of variables:
208.1213 +*  indices 1 to m mean auxiliary variables and indices m+1 to m+n mean
208.1214 +*  structural ones.
208.1215 +*
208.1216 +*  RETURNS
208.1217 +*
208.1218 +*  The routine returns len', which is the number of non-zero elements
208.1219 +*  in the resultant column stored in the arrays ind and val.
208.1220 +*
208.1221 +*  BACKGROUND
208.1222 +*
208.1223 +*  The explicitly specified column (1) is transformed in the same way
208.1224 +*  as any other column of the constraint matrix using the formula:
208.1225 +*
208.1226 +*     alfa = inv(B) * a,                                             (3)
208.1227 +*
208.1228 +*  where alfa is the resultant column computed by the routine. */
208.1229 +
208.1230 +int glp_transform_col(glp_prob *P, int len, int ind[], double val[])
208.1231 +{     int i, m, t;
208.1232 +      double *a, *alfa;
208.1233 +      if (!glp_bf_exists(P))
208.1234 +         xerror("glp_transform_col: basis factorization does not exist "
208.1235 +            "\n");
208.1236 +      m = glp_get_num_rows(P);
208.1237 +      /* unpack the column to be transformed to the array a */
208.1238 +      a = xcalloc(1+m, sizeof(double));
208.1239 +      for (i = 1; i <= m; i++) a[i] = 0.0;
208.1240 +      if (!(0 <= len && len <= m))
208.1241 +         xerror("glp_transform_col: len = %d; invalid column length\n",
208.1242 +            len);
208.1243 +      for (t = 1; t <= len; t++)
208.1244 +      {  i = ind[t];
208.1245 +         if (!(1 <= i && i <= m))
208.1246 +            xerror("glp_transform_col: ind[%d] = %d; row index out of r"
208.1247 +               "ange\n", t, i);
208.1248 +         if (val[t] == 0.0)
208.1249 +            xerror("glp_transform_col: val[%d] = 0; zero coefficient no"
208.1250 +               "t allowed\n", t);
208.1251 +         if (a[i] != 0.0)
208.1252 +            xerror("glp_transform_col: ind[%d] = %d; duplicate row indi"
208.1253 +               "ces not allowed\n", t, i);
208.1254 +         a[i] = val[t];
208.1255 +      }
208.1256 +      /* solve the system B*a = alfa to compute the vector alfa */
208.1257 +      alfa = a, glp_ftran(P, alfa);
208.1258 +      /* store resultant coefficients */
208.1259 +      len = 0;
208.1260 +      for (i = 1; i <= m; i++)
208.1261 +      {  if (alfa[i] != 0.0)
208.1262 +         {  len++;
208.1263 +            ind[len] = glp_get_bhead(P, i);
208.1264 +            val[len] = alfa[i];
208.1265 +         }
208.1266 +      }
208.1267 +      xfree(a);
208.1268 +      return len;
208.1269 +}
208.1270 +
208.1271 +/***********************************************************************
208.1272 +*  NAME
208.1273 +*
208.1274 +*  glp_prim_rtest - perform primal ratio test
208.1275 +*
208.1276 +*  SYNOPSIS
208.1277 +*
208.1278 +*  int glp_prim_rtest(glp_prob *P, int len, const int ind[],
208.1279 +*     const double val[], int dir, double eps);
208.1280 +*
208.1281 +*  DESCRIPTION
208.1282 +*
208.1283 +*  The routine glp_prim_rtest performs the primal ratio test using an
208.1284 +*  explicitly specified column of the simplex table.
208.1285 +*
208.1286 +*  The current basic solution associated with the LP problem object
208.1287 +*  must be primal feasible.
208.1288 +*
208.1289 +*  The explicitly specified column of the simplex table shows how the
208.1290 +*  basic variables xB depend on some non-basic variable x (which is not
208.1291 +*  necessarily presented in the problem object):
208.1292 +*
208.1293 +*     xB[1] = ... + alfa[1] * x + ...
208.1294 +*     xB[2] = ... + alfa[2] * x + ...                                (*)
208.1295 +*         .  .  .  .  .  .  .  .
208.1296 +*     xB[m] = ... + alfa[m] * x + ...
208.1297 +*
208.1298 +*  The column (*) is specifed on entry to the routine using the sparse
208.1299 +*  format. Ordinal numbers of basic variables xB[i] should be placed in
208.1300 +*  locations ind[1], ..., ind[len], where ordinal number 1 to m denote
208.1301 +*  auxiliary variables, and ordinal numbers m+1 to m+n denote structural
208.1302 +*  variables. The corresponding non-zero coefficients alfa[i] should be
208.1303 +*  placed in locations val[1], ..., val[len]. The arrays ind and val are
208.1304 +*  not changed on exit.
208.1305 +*
208.1306 +*  The parameter dir specifies direction in which the variable x changes
208.1307 +*  on entering the basis: +1 means increasing, -1 means decreasing.
208.1308 +*
208.1309 +*  The parameter eps is an absolute tolerance (small positive number)
208.1310 +*  used by the routine to skip small alfa[j] of the row (*).
208.1311 +*
208.1312 +*  The routine determines which basic variable (among specified in
208.1313 +*  ind[1], ..., ind[len]) should leave the basis in order to keep primal
208.1314 +*  feasibility.
208.1315 +*
208.1316 +*  RETURNS
208.1317 +*
208.1318 +*  The routine glp_prim_rtest returns the index piv in the arrays ind
208.1319 +*  and val corresponding to the pivot element chosen, 1 <= piv <= len.
208.1320 +*  If the adjacent basic solution is primal unbounded and therefore the
208.1321 +*  choice cannot be made, the routine returns zero.
208.1322 +*
208.1323 +*  COMMENTS
208.1324 +*
208.1325 +*  If the non-basic variable x is presented in the LP problem object,
208.1326 +*  the column (*) can be computed with the routine glp_eval_tab_col;
208.1327 +*  otherwise it can be computed with the routine glp_transform_col. */
208.1328 +
208.1329 +int glp_prim_rtest(glp_prob *P, int len, const int ind[],
208.1330 +      const double val[], int dir, double eps)
208.1331 +{     int k, m, n, piv, t, type, stat;
208.1332 +      double alfa, big, beta, lb, ub, temp, teta;
208.1333 +      if (glp_get_prim_stat(P) != GLP_FEAS)
208.1334 +         xerror("glp_prim_rtest: basic solution is not primal feasible "
208.1335 +            "\n");
208.1336 +      if (!(dir == +1 || dir == -1))
208.1337 +         xerror("glp_prim_rtest: dir = %d; invalid parameter\n", dir);
208.1338 +      if (!(0.0 < eps && eps < 1.0))
208.1339 +         xerror("glp_prim_rtest: eps = %g; invalid parameter\n", eps);
208.1340 +      m = glp_get_num_rows(P);
208.1341 +      n = glp_get_num_cols(P);
208.1342 +      /* initial settings */
208.1343 +      piv = 0, teta = DBL_MAX, big = 0.0;
208.1344 +      /* walk through the entries of the specified column */
208.1345 +      for (t = 1; t <= len; t++)
208.1346 +      {  /* get the ordinal number of basic variable */
208.1347 +         k = ind[t];
208.1348 +         if (!(1 <= k && k <= m+n))
208.1349 +            xerror("glp_prim_rtest: ind[%d] = %d; variable number out o"
208.1350 +               "f range\n", t, k);
208.1351 +         /* determine type, bounds, status and primal value of basic
208.1352 +            variable xB[i] = x[k] in the current basic solution */
208.1353 +         if (k <= m)
208.1354 +         {  type = glp_get_row_type(P, k);
208.1355 +            lb = glp_get_row_lb(P, k);
208.1356 +            ub = glp_get_row_ub(P, k);
208.1357 +            stat = glp_get_row_stat(P, k);
208.1358 +            beta = glp_get_row_prim(P, k);
208.1359 +         }
208.1360 +         else
208.1361 +         {  type = glp_get_col_type(P, k-m);
208.1362 +            lb = glp_get_col_lb(P, k-m);
208.1363 +            ub = glp_get_col_ub(P, k-m);
208.1364 +            stat = glp_get_col_stat(P, k-m);
208.1365 +            beta = glp_get_col_prim(P, k-m);
208.1366 +         }
208.1367 +         if (stat != GLP_BS)
208.1368 +            xerror("glp_prim_rtest: ind[%d] = %d; non-basic variable no"
208.1369 +               "t allowed\n", t, k);
208.1370 +         /* determine influence coefficient at basic variable xB[i]
208.1371 +            in the explicitly specified column and turn to the case of
208.1372 +            increasing the variable x in order to simplify the program
208.1373 +            logic */
208.1374 +         alfa = (dir > 0 ? + val[t] : - val[t]);
208.1375 +         /* analyze main cases */
208.1376 +         if (type == GLP_FR)
208.1377 +         {  /* xB[i] is free variable */
208.1378 +            continue;
208.1379 +         }
208.1380 +         else if (type == GLP_LO)
208.1381 +lo:      {  /* xB[i] has an lower bound */
208.1382 +            if (alfa > - eps) continue;
208.1383 +            temp = (lb - beta) / alfa;
208.1384 +         }
208.1385 +         else if (type == GLP_UP)
208.1386 +up:      {  /* xB[i] has an upper bound */
208.1387 +            if (alfa < + eps) continue;
208.1388 +            temp = (ub - beta) / alfa;
208.1389 +         }
208.1390 +         else if (type == GLP_DB)
208.1391 +         {  /* xB[i] has both lower and upper bounds */
208.1392 +            if (alfa < 0.0) goto lo; else goto up;
208.1393 +         }
208.1394 +         else if (type == GLP_FX)
208.1395 +         {  /* xB[i] is fixed variable */
208.1396 +            if (- eps < alfa && alfa < + eps) continue;
208.1397 +            temp = 0.0;
208.1398 +         }
208.1399 +         else
208.1400 +            xassert(type != type);
208.1401 +         /* if the value of the variable xB[i] violates its lower or
208.1402 +            upper bound (slightly, because the current basis is assumed
208.1403 +            to be primal feasible), temp is negative; we can think this
208.1404 +            happens due to round-off errors and the value is exactly on
208.1405 +            the bound; this allows replacing temp by zero */
208.1406 +         if (temp < 0.0) temp = 0.0;
208.1407 +         /* apply the minimal ratio test */
208.1408 +         if (teta > temp || teta == temp && big < fabs(alfa))
208.1409 +            piv = t, teta = temp, big = fabs(alfa);
208.1410 +      }
208.1411 +      /* return index of the pivot element chosen */
208.1412 +      return piv;
208.1413 +}
208.1414 +
208.1415 +/***********************************************************************
208.1416 +*  NAME
208.1417 +*
208.1418 +*  glp_dual_rtest - perform dual ratio test
208.1419 +*
208.1420 +*  SYNOPSIS
208.1421 +*
208.1422 +*  int glp_dual_rtest(glp_prob *P, int len, const int ind[],
208.1423 +*     const double val[], int dir, double eps);
208.1424 +*
208.1425 +*  DESCRIPTION
208.1426 +*
208.1427 +*  The routine glp_dual_rtest performs the dual ratio test using an
208.1428 +*  explicitly specified row of the simplex table.
208.1429 +*
208.1430 +*  The current basic solution associated with the LP problem object
208.1431 +*  must be dual feasible.
208.1432 +*
208.1433 +*  The explicitly specified row of the simplex table is a linear form
208.1434 +*  that shows how some basic variable x (which is not necessarily
208.1435 +*  presented in the problem object) depends on non-basic variables xN:
208.1436 +*
208.1437 +*     x = alfa[1] * xN[1] + alfa[2] * xN[2] + ... + alfa[n] * xN[n]. (*)
208.1438 +*
208.1439 +*  The row (*) is specified on entry to the routine using the sparse
208.1440 +*  format. Ordinal numbers of non-basic variables xN[j] should be placed
208.1441 +*  in locations ind[1], ..., ind[len], where ordinal numbers 1 to m
208.1442 +*  denote auxiliary variables, and ordinal numbers m+1 to m+n denote
208.1443 +*  structural variables. The corresponding non-zero coefficients alfa[j]
208.1444 +*  should be placed in locations val[1], ..., val[len]. The arrays ind
208.1445 +*  and val are not changed on exit.
208.1446 +*
208.1447 +*  The parameter dir specifies direction in which the variable x changes
208.1448 +*  on leaving the basis: +1 means that x goes to its lower bound, and -1
208.1449 +*  means that x goes to its upper bound.
208.1450 +*
208.1451 +*  The parameter eps is an absolute tolerance (small positive number)
208.1452 +*  used by the routine to skip small alfa[j] of the row (*).
208.1453 +*
208.1454 +*  The routine determines which non-basic variable (among specified in
208.1455 +*  ind[1], ..., ind[len]) should enter the basis in order to keep dual
208.1456 +*  feasibility.
208.1457 +*
208.1458 +*  RETURNS
208.1459 +*
208.1460 +*  The routine glp_dual_rtest returns the index piv in the arrays ind
208.1461 +*  and val corresponding to the pivot element chosen, 1 <= piv <= len.
208.1462 +*  If the adjacent basic solution is dual unbounded and therefore the
208.1463 +*  choice cannot be made, the routine returns zero.
208.1464 +*
208.1465 +*  COMMENTS
208.1466 +*
208.1467 +*  If the basic variable x is presented in the LP problem object, the
208.1468 +*  row (*) can be computed with the routine glp_eval_tab_row; otherwise
208.1469 +*  it can be computed with the routine glp_transform_row. */
208.1470 +
208.1471 +int glp_dual_rtest(glp_prob *P, int len, const int ind[],
208.1472 +      const double val[], int dir, double eps)
208.1473 +{     int k, m, n, piv, t, stat;
208.1474 +      double alfa, big, cost, obj, temp, teta;
208.1475 +      if (glp_get_dual_stat(P) != GLP_FEAS)
208.1476 +         xerror("glp_dual_rtest: basic solution is not dual feasible\n")
208.1477 +            ;
208.1478 +      if (!(dir == +1 || dir == -1))
208.1479 +         xerror("glp_dual_rtest: dir = %d; invalid parameter\n", dir);
208.1480 +      if (!(0.0 < eps && eps < 1.0))
208.1481 +         xerror("glp_dual_rtest: eps = %g; invalid parameter\n", eps);
208.1482 +      m = glp_get_num_rows(P);
208.1483 +      n = glp_get_num_cols(P);
208.1484 +      /* take into account optimization direction */
208.1485 +      obj = (glp_get_obj_dir(P) == GLP_MIN ? +1.0 : -1.0);
208.1486 +      /* initial settings */
208.1487 +      piv = 0, teta = DBL_MAX, big = 0.0;
208.1488 +      /* walk through the entries of the specified row */
208.1489 +      for (t = 1; t <= len; t++)
208.1490 +      {  /* get ordinal number of non-basic variable */
208.1491 +         k = ind[t];
208.1492 +         if (!(1 <= k && k <= m+n))
208.1493 +            xerror("glp_dual_rtest: ind[%d] = %d; variable number out o"
208.1494 +               "f range\n", t, k);
208.1495 +         /* determine status and reduced cost of non-basic variable
208.1496 +            x[k] = xN[j] in the current basic solution */
208.1497 +         if (k <= m)
208.1498 +         {  stat = glp_get_row_stat(P, k);
208.1499 +            cost = glp_get_row_dual(P, k);
208.1500 +         }
208.1501 +         else
208.1502 +         {  stat = glp_get_col_stat(P, k-m);
208.1503 +            cost = glp_get_col_dual(P, k-m);
208.1504 +         }
208.1505 +         if (stat == GLP_BS)
208.1506 +            xerror("glp_dual_rtest: ind[%d] = %d; basic variable not al"
208.1507 +               "lowed\n", t, k);
208.1508 +         /* determine influence coefficient at non-basic variable xN[j]
208.1509 +            in the explicitly specified row and turn to the case of
208.1510 +            increasing the variable x in order to simplify the program
208.1511 +            logic */
208.1512 +         alfa = (dir > 0 ? + val[t] : - val[t]);
208.1513 +         /* analyze main cases */
208.1514 +         if (stat == GLP_NL)
208.1515 +         {  /* xN[j] is on its lower bound */
208.1516 +            if (alfa < + eps) continue;
208.1517 +            temp = (obj * cost) / alfa;
208.1518 +         }
208.1519 +         else if (stat == GLP_NU)
208.1520 +         {  /* xN[j] is on its upper bound */
208.1521 +            if (alfa > - eps) continue;
208.1522 +            temp = (obj * cost) / alfa;
208.1523 +         }
208.1524 +         else if (stat == GLP_NF)
208.1525 +         {  /* xN[j] is non-basic free variable */
208.1526 +            if (- eps < alfa && alfa < + eps) continue;
208.1527 +            temp = 0.0;
208.1528 +         }
208.1529 +         else if (stat == GLP_NS)
208.1530 +         {  /* xN[j] is non-basic fixed variable */
208.1531 +            continue;
208.1532 +         }
208.1533 +         else
208.1534 +            xassert(stat != stat);
208.1535 +         /* if the reduced cost of the variable xN[j] violates its zero
208.1536 +            bound (slightly, because the current basis is assumed to be
208.1537 +            dual feasible), temp is negative; we can think this happens
208.1538 +            due to round-off errors and the reduced cost is exact zero;
208.1539 +            this allows replacing temp by zero */
208.1540 +         if (temp < 0.0) temp = 0.0;
208.1541 +         /* apply the minimal ratio test */
208.1542 +         if (teta > temp || teta == temp && big < fabs(alfa))
208.1543 +            piv = t, teta = temp, big = fabs(alfa);
208.1544 +      }
208.1545 +      /* return index of the pivot element chosen */
208.1546 +      return piv;
208.1547 +}
208.1548 +
208.1549 +/***********************************************************************
208.1550 +*  NAME
208.1551 +*
208.1552 +*  glp_analyze_row - simulate one iteration of dual simplex method
208.1553 +*
208.1554 +*  SYNOPSIS
208.1555 +*
208.1556 +*  int glp_analyze_row(glp_prob *P, int len, const int ind[],
208.1557 +*     const double val[], int type, double rhs, double eps, int *piv,
208.1558 +*     double *x, double *dx, double *y, double *dy, double *dz);
208.1559 +*
208.1560 +*  DESCRIPTION
208.1561 +*
208.1562 +*  Let the current basis be optimal or dual feasible, and there be
208.1563 +*  specified a row (constraint), which is violated by the current basic
208.1564 +*  solution. The routine glp_analyze_row simulates one iteration of the
208.1565 +*  dual simplex method to determine some information on the adjacent
208.1566 +*  basis (see below), where the specified row becomes active constraint
208.1567 +*  (i.e. its auxiliary variable becomes non-basic).
208.1568 +*
208.1569 +*  The current basic solution associated with the problem object passed
208.1570 +*  to the routine must be dual feasible, and its primal components must
208.1571 +*  be defined.
208.1572 +*
208.1573 +*  The row to be analyzed must be previously transformed either with
208.1574 +*  the routine glp_eval_tab_row (if the row is in the problem object)
208.1575 +*  or with the routine glp_transform_row (if the row is external, i.e.
208.1576 +*  not in the problem object). This is needed to express the row only
208.1577 +*  through (auxiliary and structural) variables, which are non-basic in
208.1578 +*  the current basis:
208.1579 +*
208.1580 +*     y = alfa[1] * xN[1] + alfa[2] * xN[2] + ... + alfa[n] * xN[n],
208.1581 +*
208.1582 +*  where y is an auxiliary variable of the row, alfa[j] is an influence
208.1583 +*  coefficient, xN[j] is a non-basic variable.
208.1584 +*
208.1585 +*  The row is passed to the routine in sparse format. Ordinal numbers
208.1586 +*  of non-basic variables are stored in locations ind[1], ..., ind[len],
208.1587 +*  where numbers 1 to m denote auxiliary variables while numbers m+1 to
208.1588 +*  m+n denote structural variables. Corresponding non-zero coefficients
208.1589 +*  alfa[j] are stored in locations val[1], ..., val[len]. The arrays
208.1590 +*  ind and val are ot changed on exit.
208.1591 +*
208.1592 +*  The parameters type and rhs specify the row type and its right-hand
208.1593 +*  side as follows:
208.1594 +*
208.1595 +*     type = GLP_LO: y = sum alfa[j] * xN[j] >= rhs
208.1596 +*
208.1597 +*     type = GLP_UP: y = sum alfa[j] * xN[j] <= rhs
208.1598 +*
208.1599 +*  The parameter eps is an absolute tolerance (small positive number)
208.1600 +*  used by the routine to skip small coefficients alfa[j] on performing
208.1601 +*  the dual ratio test.
208.1602 +*
208.1603 +*  If the operation was successful, the routine stores the following
208.1604 +*  information to corresponding location (if some parameter is NULL,
208.1605 +*  its value is not stored):
208.1606 +*
208.1607 +*  piv   index in the array ind and val, 1 <= piv <= len, determining
208.1608 +*        the non-basic variable, which would enter the adjacent basis;
208.1609 +*
208.1610 +*  x     value of the non-basic variable in the current basis;
208.1611 +*
208.1612 +*  dx    difference between values of the non-basic variable in the
208.1613 +*        adjacent and current bases, dx = x.new - x.old;
208.1614 +*
208.1615 +*  y     value of the row (i.e. of its auxiliary variable) in the
208.1616 +*        current basis;
208.1617 +*
208.1618 +*  dy    difference between values of the row in the adjacent and
208.1619 +*        current bases, dy = y.new - y.old;
208.1620 +*
208.1621 +*  dz    difference between values of the objective function in the
208.1622 +*        adjacent and current bases, dz = z.new - z.old. Note that in
208.1623 +*        case of minimization dz >= 0, and in case of maximization
208.1624 +*        dz <= 0, i.e. in the adjacent basis the objective function
208.1625 +*        always gets worse (degrades). */
208.1626 +
208.1627 +int _glp_analyze_row(glp_prob *P, int len, const int ind[],
208.1628 +      const double val[], int type, double rhs, double eps, int *_piv,
208.1629 +      double *_x, double *_dx, double *_y, double *_dy, double *_dz)
208.1630 +{     int t, k, dir, piv, ret = 0;
208.1631 +      double x, dx, y, dy, dz;
208.1632 +      if (P->pbs_stat == GLP_UNDEF)
208.1633 +         xerror("glp_analyze_row: primal basic solution components are "
208.1634 +            "undefined\n");
208.1635 +      if (P->dbs_stat != GLP_FEAS)
208.1636 +         xerror("glp_analyze_row: basic solution is not dual feasible\n"
208.1637 +            );
208.1638 +      /* compute the row value y = sum alfa[j] * xN[j] in the current
208.1639 +         basis */
208.1640 +      if (!(0 <= len && len <= P->n))
208.1641 +         xerror("glp_analyze_row: len = %d; invalid row length\n", len);
208.1642 +      y = 0.0;
208.1643 +      for (t = 1; t <= len; t++)
208.1644 +      {  /* determine value of x[k] = xN[j] in the current basis */
208.1645 +         k = ind[t];
208.1646 +         if (!(1 <= k && k <= P->m+P->n))
208.1647 +            xerror("glp_analyze_row: ind[%d] = %d; row/column index out"
208.1648 +               " of range\n", t, k);
208.1649 +         if (k <= P->m)
208.1650 +         {  /* x[k] is auxiliary variable */
208.1651 +            if (P->row[k]->stat == GLP_BS)
208.1652 +               xerror("glp_analyze_row: ind[%d] = %d; basic auxiliary v"
208.1653 +                  "ariable is not allowed\n", t, k);
208.1654 +            x = P->row[k]->prim;
208.1655 +         }
208.1656 +         else
208.1657 +         {  /* x[k] is structural variable */
208.1658 +            if (P->col[k-P->m]->stat == GLP_BS)
208.1659 +               xerror("glp_analyze_row: ind[%d] = %d; basic structural "
208.1660 +                  "variable is not allowed\n", t, k);
208.1661 +            x = P->col[k-P->m]->prim;
208.1662 +         }
208.1663 +         y += val[t] * x;
208.1664 +      }
208.1665 +      /* check if the row is primal infeasible in the current basis,
208.1666 +         i.e. the constraint is violated at the current point */
208.1667 +      if (type == GLP_LO)
208.1668 +      {  if (y >= rhs)
208.1669 +         {  /* the constraint is not violated */
208.1670 +            ret = 1;
208.1671 +            goto done;
208.1672 +         }
208.1673 +         /* in the adjacent basis y goes to its lower bound */
208.1674 +         dir = +1;
208.1675 +      }
208.1676 +      else if (type == GLP_UP)
208.1677 +      {  if (y <= rhs)
208.1678 +         {  /* the constraint is not violated */
208.1679 +            ret = 1;
208.1680 +            goto done;
208.1681 +         }
208.1682 +         /* in the adjacent basis y goes to its upper bound */
208.1683 +         dir = -1;
208.1684 +      }
208.1685 +      else
208.1686 +         xerror("glp_analyze_row: type = %d; invalid parameter\n",
208.1687 +            type);
208.1688 +      /* compute dy = y.new - y.old */
208.1689 +      dy = rhs - y;
208.1690 +      /* perform dual ratio test to determine which non-basic variable
208.1691 +         should enter the adjacent basis to keep it dual feasible */
208.1692 +      piv = glp_dual_rtest(P, len, ind, val, dir, eps);
208.1693 +      if (piv == 0)
208.1694 +      {  /* no dual feasible adjacent basis exists */
208.1695 +         ret = 2;
208.1696 +         goto done;
208.1697 +      }
208.1698 +      /* non-basic variable x[k] = xN[j] should enter the basis */
208.1699 +      k = ind[piv];
208.1700 +      xassert(1 <= k && k <= P->m+P->n);
208.1701 +      /* determine its value in the current basis */
208.1702 +      if (k <= P->m)
208.1703 +         x = P->row[k]->prim;
208.1704 +      else
208.1705 +         x = P->col[k-P->m]->prim;
208.1706 +      /* compute dx = x.new - x.old = dy / alfa[j] */
208.1707 +      xassert(val[piv] != 0.0);
208.1708 +      dx = dy / val[piv];
208.1709 +      /* compute dz = z.new - z.old = d[j] * dx, where d[j] is reduced
208.1710 +         cost of xN[j] in the current basis */
208.1711 +      if (k <= P->m)
208.1712 +         dz = P->row[k]->dual * dx;
208.1713 +      else
208.1714 +         dz = P->col[k-P->m]->dual * dx;
208.1715 +      /* store the analysis results */
208.1716 +      if (_piv != NULL) *_piv = piv;
208.1717 +      if (_x   != NULL) *_x   = x;
208.1718 +      if (_dx  != NULL) *_dx  = dx;
208.1719 +      if (_y   != NULL) *_y   = y;
208.1720 +      if (_dy  != NULL) *_dy  = dy;
208.1721 +      if (_dz  != NULL) *_dz  = dz;
208.1722 +done: return ret;
208.1723 +}
208.1724 +
208.1725 +#if 0
208.1726 +int main(void)
208.1727 +{     /* example program for the routine glp_analyze_row */
208.1728 +      glp_prob *P;
208.1729 +      glp_smcp parm;
208.1730 +      int i, k, len, piv, ret, ind[1+100];
208.1731 +      double rhs, x, dx, y, dy, dz, val[1+100];
208.1732 +      P = glp_create_prob();
208.1733 +      /* read plan.mps (see glpk/examples) */
208.1734 +      ret = glp_read_mps(P, GLP_MPS_DECK, NULL, "plan.mps");
208.1735 +      glp_assert(ret == 0);
208.1736 +      /* and solve it to optimality */
208.1737 +      ret = glp_simplex(P, NULL);
208.1738 +      glp_assert(ret == 0);
208.1739 +      glp_assert(glp_get_status(P) == GLP_OPT);
208.1740 +      /* the optimal objective value is 296.217 */
208.1741 +      /* we would like to know what happens if we would add a new row
208.1742 +         (constraint) to plan.mps:
208.1743 +         .01 * bin1 + .01 * bin2 + .02 * bin4 + .02 * bin5 <= 12 */
208.1744 +      /* first, we specify this new row */
208.1745 +      glp_create_index(P);
208.1746 +      len = 0;
208.1747 +      ind[++len] = glp_find_col(P, "BIN1"), val[len] = .01;
208.1748 +      ind[++len] = glp_find_col(P, "BIN2"), val[len] = .01;
208.1749 +      ind[++len] = glp_find_col(P, "BIN4"), val[len] = .02;
208.1750 +      ind[++len] = glp_find_col(P, "BIN5"), val[len] = .02;
208.1751 +      rhs = 12;
208.1752 +      /* then we can compute value of the row (i.e. of its auxiliary
208.1753 +         variable) in the current basis to see if the constraint is
208.1754 +         violated */
208.1755 +      y = 0.0;
208.1756 +      for (k = 1; k <= len; k++)
208.1757 +         y += val[k] * glp_get_col_prim(P, ind[k]);
208.1758 +      glp_printf("y = %g\n", y);
208.1759 +      /* this prints y = 15.1372, so the constraint is violated, since
208.1760 +         we require that y <= rhs = 12 */
208.1761 +      /* now we transform the row to express it only through non-basic
208.1762 +         (auxiliary and artificial) variables */
208.1763 +      len = glp_transform_row(P, len, ind, val);
208.1764 +      /* finally, we simulate one step of the dual simplex method to
208.1765 +         obtain necessary information for the adjacent basis */
208.1766 +      ret = _glp_analyze_row(P, len, ind, val, GLP_UP, rhs, 1e-9, &piv,
208.1767 +         &x, &dx, &y, &dy, &dz);
208.1768 +      glp_assert(ret == 0);
208.1769 +      glp_printf("k = %d, x = %g; dx = %g; y = %g; dy = %g; dz = %g\n",
208.1770 +         ind[piv], x, dx, y, dy, dz);
208.1771 +      /* this prints dz = 5.64418 and means that in the adjacent basis
208.1772 +         the objective function would be 296.217 + 5.64418 = 301.861 */
208.1773 +      /* now we actually include the row into the problem object; note
208.1774 +         that the arrays ind and val are clobbered, so we need to build
208.1775 +         them once again */
208.1776 +      len = 0;
208.1777 +      ind[++len] = glp_find_col(P, "BIN1"), val[len] = .01;
208.1778 +      ind[++len] = glp_find_col(P, "BIN2"), val[len] = .01;
208.1779 +      ind[++len] = glp_find_col(P, "BIN4"), val[len] = .02;
208.1780 +      ind[++len] = glp_find_col(P, "BIN5"), val[len] = .02;
208.1781 +      rhs = 12;
208.1782 +      i = glp_add_rows(P, 1);
208.1783 +      glp_set_row_bnds(P, i, GLP_UP, 0, rhs);
208.1784 +      glp_set_mat_row(P, i, len, ind, val);
208.1785 +      /* and perform one dual simplex iteration */
208.1786 +      glp_init_smcp(&parm);
208.1787 +      parm.meth = GLP_DUAL;
208.1788 +      parm.it_lim = 1;
208.1789 +      glp_simplex(P, &parm);
208.1790 +      /* the current objective value is 301.861 */
208.1791 +      return 0;
208.1792 +}
208.1793 +#endif
208.1794 +
208.1795 +/***********************************************************************
208.1796 +*  NAME
208.1797 +*
208.1798 +*  glp_analyze_bound - analyze active bound of non-basic variable
208.1799 +*
208.1800 +*  SYNOPSIS
208.1801 +*
208.1802 +*  void glp_analyze_bound(glp_prob *P, int k, double *limit1, int *var1,
208.1803 +*     double *limit2, int *var2);
208.1804 +*
208.1805 +*  DESCRIPTION
208.1806 +*
208.1807 +*  The routine glp_analyze_bound analyzes the effect of varying the
208.1808 +*  active bound of specified non-basic variable.
208.1809 +*
208.1810 +*  The non-basic variable is specified by the parameter k, where
208.1811 +*  1 <= k <= m means auxiliary variable of corresponding row while
208.1812 +*  m+1 <= k <= m+n means structural variable (column).
208.1813 +*
208.1814 +*  Note that the current basic solution must be optimal, and the basis
208.1815 +*  factorization must exist.
208.1816 +*
208.1817 +*  Results of the analysis have the following meaning.
208.1818 +*
208.1819 +*  value1 is the minimal value of the active bound, at which the basis
208.1820 +*  still remains primal feasible and thus optimal. -DBL_MAX means that
208.1821 +*  the active bound has no lower limit.
208.1822 +*
208.1823 +*  var1 is the ordinal number of an auxiliary (1 to m) or structural
208.1824 +*  (m+1 to n) basic variable, which reaches its bound first and thereby
208.1825 +*  limits further decreasing the active bound being analyzed.
208.1826 +*  if value1 = -DBL_MAX, var1 is set to 0.
208.1827 +*
208.1828 +*  value2 is the maximal value of the active bound, at which the basis
208.1829 +*  still remains primal feasible and thus optimal. +DBL_MAX means that
208.1830 +*  the active bound has no upper limit.
208.1831 +*
208.1832 +*  var2 is the ordinal number of an auxiliary (1 to m) or structural
208.1833 +*  (m+1 to n) basic variable, which reaches its bound first and thereby
208.1834 +*  limits further increasing the active bound being analyzed.
208.1835 +*  if value2 = +DBL_MAX, var2 is set to 0. */
208.1836 +
208.1837 +void glp_analyze_bound(glp_prob *P, int k, double *value1, int *var1,
208.1838 +      double *value2, int *var2)
208.1839 +{     GLPROW *row;
208.1840 +      GLPCOL *col;
208.1841 +      int m, n, stat, kase, p, len, piv, *ind;
208.1842 +      double x, new_x, ll, uu, xx, delta, *val;
208.1843 +      /* sanity checks */
208.1844 +      if (P == NULL || P->magic != GLP_PROB_MAGIC)
208.1845 +         xerror("glp_analyze_bound: P = %p; invalid problem object\n",
208.1846 +            P);
208.1847 +      m = P->m, n = P->n;
208.1848 +      if (!(P->pbs_stat == GLP_FEAS && P->dbs_stat == GLP_FEAS))
208.1849 +         xerror("glp_analyze_bound: optimal basic solution required\n");
208.1850 +      if (!(m == 0 || P->valid))
208.1851 +         xerror("glp_analyze_bound: basis factorization required\n");
208.1852 +      if (!(1 <= k && k <= m+n))
208.1853 +         xerror("glp_analyze_bound: k = %d; variable number out of rang"
208.1854 +            "e\n", k);
208.1855 +      /* retrieve information about the specified non-basic variable
208.1856 +         x[k] whose active bound is to be analyzed */
208.1857 +      if (k <= m)
208.1858 +      {  row = P->row[k];
208.1859 +         stat = row->stat;
208.1860 +         x = row->prim;
208.1861 +      }
208.1862 +      else
208.1863 +      {  col = P->col[k-m];
208.1864 +         stat = col->stat;
208.1865 +         x = col->prim;
208.1866 +      }
208.1867 +      if (stat == GLP_BS)
208.1868 +         xerror("glp_analyze_bound: k = %d; basic variable not allowed "
208.1869 +            "\n", k);
208.1870 +      /* allocate working arrays */
208.1871 +      ind = xcalloc(1+m, sizeof(int));
208.1872 +      val = xcalloc(1+m, sizeof(double));
208.1873 +      /* compute column of the simplex table corresponding to the
208.1874 +         non-basic variable x[k] */
208.1875 +      len = glp_eval_tab_col(P, k, ind, val);
208.1876 +      xassert(0 <= len && len <= m);
208.1877 +      /* perform analysis */
208.1878 +      for (kase = -1; kase <= +1; kase += 2)
208.1879 +      {  /* kase < 0 means active bound of x[k] is decreasing;
208.1880 +            kase > 0 means active bound of x[k] is increasing */
208.1881 +         /* use the primal ratio test to determine some basic variable
208.1882 +            x[p] which reaches its bound first */
208.1883 +         piv = glp_prim_rtest(P, len, ind, val, kase, 1e-9);
208.1884 +         if (piv == 0)
208.1885 +         {  /* nothing limits changing the active bound of x[k] */
208.1886 +            p = 0;
208.1887 +            new_x = (kase < 0 ? -DBL_MAX : +DBL_MAX);
208.1888 +            goto store;
208.1889 +         }
208.1890 +         /* basic variable x[p] limits changing the active bound of
208.1891 +            x[k]; determine its value in the current basis */
208.1892 +         xassert(1 <= piv && piv <= len);
208.1893 +         p = ind[piv];
208.1894 +         if (p <= m)
208.1895 +         {  row = P->row[p];
208.1896 +            ll = glp_get_row_lb(P, row->i);
208.1897 +            uu = glp_get_row_ub(P, row->i);
208.1898 +            stat = row->stat;
208.1899 +            xx = row->prim;
208.1900 +         }
208.1901 +         else
208.1902 +         {  col = P->col[p-m];
208.1903 +            ll = glp_get_col_lb(P, col->j);
208.1904 +            uu = glp_get_col_ub(P, col->j);
208.1905 +            stat = col->stat;
208.1906 +            xx = col->prim;
208.1907 +         }
208.1908 +         xassert(stat == GLP_BS);
208.1909 +         /* determine delta x[p] = bound of x[p] - value of x[p] */
208.1910 +         if (kase < 0 && val[piv] > 0.0 ||
208.1911 +             kase > 0 && val[piv] < 0.0)
208.1912 +         {  /* delta x[p] < 0, so x[p] goes toward its lower bound */
208.1913 +            xassert(ll != -DBL_MAX);
208.1914 +            delta = ll - xx;
208.1915 +         }
208.1916 +         else
208.1917 +         {  /* delta x[p] > 0, so x[p] goes toward its upper bound */
208.1918 +            xassert(uu != +DBL_MAX);
208.1919 +            delta = uu - xx;
208.1920 +         }
208.1921 +         /* delta x[p] = alfa[p,k] * delta x[k], so new x[k] = x[k] +
208.1922 +            delta x[k] = x[k] + delta x[p] / alfa[p,k] is the value of
208.1923 +            x[k] in the adjacent basis */
208.1924 +         xassert(val[piv] != 0.0);
208.1925 +         new_x = x + delta / val[piv];
208.1926 +store:   /* store analysis results */
208.1927 +         if (kase < 0)
208.1928 +         {  if (value1 != NULL) *value1 = new_x;
208.1929 +            if (var1 != NULL) *var1 = p;
208.1930 +         }
208.1931 +         else
208.1932 +         {  if (value2 != NULL) *value2 = new_x;
208.1933 +            if (var2 != NULL) *var2 = p;
208.1934 +         }
208.1935 +      }
208.1936 +      /* free working arrays */
208.1937 +      xfree(ind);
208.1938 +      xfree(val);
208.1939 +      return;
208.1940 +}
208.1941 +
208.1942 +/***********************************************************************
208.1943 +*  NAME
208.1944 +*
208.1945 +*  glp_analyze_coef - analyze objective coefficient at basic variable
208.1946 +*
208.1947 +*  SYNOPSIS
208.1948 +*
208.1949 +*  void glp_analyze_coef(glp_prob *P, int k, double *coef1, int *var1,
208.1950 +*     double *value1, double *coef2, int *var2, double *value2);
208.1951 +*
208.1952 +*  DESCRIPTION
208.1953 +*
208.1954 +*  The routine glp_analyze_coef analyzes the effect of varying the
208.1955 +*  objective coefficient at specified basic variable.
208.1956 +*
208.1957 +*  The basic variable is specified by the parameter k, where
208.1958 +*  1 <= k <= m means auxiliary variable of corresponding row while
208.1959 +*  m+1 <= k <= m+n means structural variable (column).
208.1960 +*
208.1961 +*  Note that the current basic solution must be optimal, and the basis
208.1962 +*  factorization must exist.
208.1963 +*
208.1964 +*  Results of the analysis have the following meaning.
208.1965 +*
208.1966 +*  coef1 is the minimal value of the objective coefficient, at which
208.1967 +*  the basis still remains dual feasible and thus optimal. -DBL_MAX
208.1968 +*  means that the objective coefficient has no lower limit.
208.1969 +*
208.1970 +*  var1 is the ordinal number of an auxiliary (1 to m) or structural
208.1971 +*  (m+1 to n) non-basic variable, whose reduced cost reaches its zero
208.1972 +*  bound first and thereby limits further decreasing the objective
208.1973 +*  coefficient being analyzed. If coef1 = -DBL_MAX, var1 is set to 0.
208.1974 +*
208.1975 +*  value1 is value of the basic variable being analyzed in an adjacent
208.1976 +*  basis, which is defined as follows. Let the objective coefficient
208.1977 +*  reaches its minimal value (coef1) and continues decreasing. Then the
208.1978 +*  reduced cost of the limiting non-basic variable (var1) becomes dual
208.1979 +*  infeasible and the current basis becomes non-optimal that forces the
208.1980 +*  limiting non-basic variable to enter the basis replacing there some
208.1981 +*  basic variable that leaves the basis to keep primal feasibility.
208.1982 +*  Should note that on determining the adjacent basis current bounds
208.1983 +*  of the basic variable being analyzed are ignored as if it were free
208.1984 +*  (unbounded) variable, so it cannot leave the basis. It may happen
208.1985 +*  that no dual feasible adjacent basis exists, in which case value1 is
208.1986 +*  set to -DBL_MAX or +DBL_MAX.
208.1987 +*
208.1988 +*  coef2 is the maximal value of the objective coefficient, at which
208.1989 +*  the basis still remains dual feasible and thus optimal. +DBL_MAX
208.1990 +*  means that the objective coefficient has no upper limit.
208.1991 +*
208.1992 +*  var2 is the ordinal number of an auxiliary (1 to m) or structural
208.1993 +*  (m+1 to n) non-basic variable, whose reduced cost reaches its zero
208.1994 +*  bound first and thereby limits further increasing the objective
208.1995 +*  coefficient being analyzed. If coef2 = +DBL_MAX, var2 is set to 0.
208.1996 +*
208.1997 +*  value2 is value of the basic variable being analyzed in an adjacent
208.1998 +*  basis, which is defined exactly in the same way as value1 above with
208.1999 +*  exception that now the objective coefficient is increasing. */
208.2000 +
208.2001 +void glp_analyze_coef(glp_prob *P, int k, double *coef1, int *var1,
208.2002 +      double *value1, double *coef2, int *var2, double *value2)
208.2003 +{     GLPROW *row; GLPCOL *col;
208.2004 +      int m, n, type, stat, kase, p, q, dir, clen, cpiv, rlen, rpiv,
208.2005 +         *cind, *rind;
208.2006 +      double lb, ub, coef, x, lim_coef, new_x, d, delta, ll, uu, xx,
208.2007 +         *rval, *cval;
208.2008 +      /* sanity checks */
208.2009 +      if (P == NULL || P->magic != GLP_PROB_MAGIC)
208.2010 +         xerror("glp_analyze_coef: P = %p; invalid problem object\n",
208.2011 +            P);
208.2012 +      m = P->m, n = P->n;
208.2013 +      if (!(P->pbs_stat == GLP_FEAS && P->dbs_stat == GLP_FEAS))
208.2014 +         xerror("glp_analyze_coef: optimal basic solution required\n");
208.2015 +      if (!(m == 0 || P->valid))
208.2016 +         xerror("glp_analyze_coef: basis factorization required\n");
208.2017 +      if (!(1 <= k && k <= m+n))
208.2018 +         xerror("glp_analyze_coef: k = %d; variable number out of range"
208.2019 +            "\n", k);
208.2020 +      /* retrieve information about the specified basic variable x[k]
208.2021 +         whose objective coefficient c[k] is to be analyzed */
208.2022 +      if (k <= m)
208.2023 +      {  row = P->row[k];
208.2024 +         type = row->type;
208.2025 +         lb = row->lb;
208.2026 +         ub = row->ub;
208.2027 +         coef = 0.0;
208.2028 +         stat = row->stat;
208.2029 +         x = row->prim;
208.2030 +      }
208.2031 +      else
208.2032 +      {  col = P->col[k-m];
208.2033 +         type = col->type;
208.2034 +         lb = col->lb;
208.2035 +         ub = col->ub;
208.2036 +         coef = col->coef;
208.2037 +         stat = col->stat;
208.2038 +         x = col->prim;
208.2039 +      }
208.2040 +      if (stat != GLP_BS)
208.2041 +         xerror("glp_analyze_coef: k = %d; non-basic variable not allow"
208.2042 +            "ed\n", k);
208.2043 +      /* allocate working arrays */
208.2044 +      cind = xcalloc(1+m, sizeof(int));
208.2045 +      cval = xcalloc(1+m, sizeof(double));
208.2046 +      rind = xcalloc(1+n, sizeof(int));
208.2047 +      rval = xcalloc(1+n, sizeof(double));
208.2048 +      /* compute row of the simplex table corresponding to the basic
208.2049 +         variable x[k] */
208.2050 +      rlen = glp_eval_tab_row(P, k, rind, rval);
208.2051 +      xassert(0 <= rlen && rlen <= n);
208.2052 +      /* perform analysis */
208.2053 +      for (kase = -1; kase <= +1; kase += 2)
208.2054 +      {  /* kase < 0 means objective coefficient c[k] is decreasing;
208.2055 +            kase > 0 means objective coefficient c[k] is increasing */
208.2056 +         /* note that decreasing c[k] is equivalent to increasing dual
208.2057 +            variable lambda[k] and vice versa; we need to correctly set
208.2058 +            the dir flag as required by the routine glp_dual_rtest */
208.2059 +         if (P->dir == GLP_MIN)
208.2060 +            dir = - kase;
208.2061 +         else if (P->dir == GLP_MAX)
208.2062 +            dir = + kase;
208.2063 +         else
208.2064 +            xassert(P != P);
208.2065 +         /* use the dual ratio test to determine non-basic variable
208.2066 +            x[q] whose reduced cost d[q] reaches zero bound first */
208.2067 +         rpiv = glp_dual_rtest(P, rlen, rind, rval, dir, 1e-9);
208.2068 +         if (rpiv == 0)
208.2069 +         {  /* nothing limits changing c[k] */
208.2070 +            lim_coef = (kase < 0 ? -DBL_MAX : +DBL_MAX);
208.2071 +            q = 0;
208.2072 +            /* x[k] keeps its current value */
208.2073 +            new_x = x;
208.2074 +            goto store;
208.2075 +         }
208.2076 +         /* non-basic variable x[q] limits changing coefficient c[k];
208.2077 +            determine its status and reduced cost d[k] in the current
208.2078 +            basis */
208.2079 +         xassert(1 <= rpiv && rpiv <= rlen);
208.2080 +         q = rind[rpiv];
208.2081 +         xassert(1 <= q && q <= m+n);
208.2082 +         if (q <= m)
208.2083 +         {  row = P->row[q];
208.2084 +            stat = row->stat;
208.2085 +            d = row->dual;
208.2086 +         }
208.2087 +         else
208.2088 +         {  col = P->col[q-m];
208.2089 +            stat = col->stat;
208.2090 +            d = col->dual;
208.2091 +         }
208.2092 +         /* note that delta d[q] = new d[q] - d[q] = - d[q], because
208.2093 +            new d[q] = 0; delta d[q] = alfa[k,q] * delta c[k], so
208.2094 +            delta c[k] = delta d[q] / alfa[k,q] = - d[q] / alfa[k,q] */
208.2095 +         xassert(rval[rpiv] != 0.0);
208.2096 +         delta = - d / rval[rpiv];
208.2097 +         /* compute new c[k] = c[k] + delta c[k], which is the limiting
208.2098 +            value of the objective coefficient c[k] */
208.2099 +         lim_coef = coef + delta;
208.2100 +         /* let c[k] continue decreasing/increasing that makes d[q]
208.2101 +            dual infeasible and forces x[q] to enter the basis;
208.2102 +            to perform the primal ratio test we need to know in which
208.2103 +            direction x[q] changes on entering the basis; we determine
208.2104 +            that analyzing the sign of delta d[q] (see above), since
208.2105 +            d[q] may be close to zero having wrong sign */
208.2106 +         /* let, for simplicity, the problem is minimization */
208.2107 +         if (kase < 0 && rval[rpiv] > 0.0 ||
208.2108 +             kase > 0 && rval[rpiv] < 0.0)
208.2109 +         {  /* delta d[q] < 0, so d[q] being non-negative will become
208.2110 +               negative, so x[q] will increase */
208.2111 +            dir = +1;
208.2112 +         }
208.2113 +         else
208.2114 +         {  /* delta d[q] > 0, so d[q] being non-positive will become
208.2115 +               positive, so x[q] will decrease */
208.2116 +            dir = -1;
208.2117 +         }
208.2118 +         /* if the problem is maximization, correct the direction */
208.2119 +         if (P->dir == GLP_MAX) dir = - dir;
208.2120 +         /* check that we didn't make a silly mistake */
208.2121 +         if (dir > 0)
208.2122 +            xassert(stat == GLP_NL || stat == GLP_NF);
208.2123 +         else
208.2124 +            xassert(stat == GLP_NU || stat == GLP_NF);
208.2125 +         /* compute column of the simplex table corresponding to the
208.2126 +            non-basic variable x[q] */
208.2127 +         clen = glp_eval_tab_col(P, q, cind, cval);
208.2128 +         /* make x[k] temporarily free (unbounded) */
208.2129 +         if (k <= m)
208.2130 +         {  row = P->row[k];
208.2131 +            row->type = GLP_FR;
208.2132 +            row->lb = row->ub = 0.0;
208.2133 +         }
208.2134 +         else
208.2135 +         {  col = P->col[k-m];
208.2136 +            col->type = GLP_FR;
208.2137 +            col->lb = col->ub = 0.0;
208.2138 +         }
208.2139 +         /* use the primal ratio test to determine some basic variable
208.2140 +            which leaves the basis */
208.2141 +         cpiv = glp_prim_rtest(P, clen, cind, cval, dir, 1e-9);
208.2142 +         /* restore original bounds of the basic variable x[k] */
208.2143 +         if (k <= m)
208.2144 +         {  row = P->row[k];
208.2145 +            row->type = type;
208.2146 +            row->lb = lb, row->ub = ub;
208.2147 +         }
208.2148 +         else
208.2149 +         {  col = P->col[k-m];
208.2150 +            col->type = type;
208.2151 +            col->lb = lb, col->ub = ub;
208.2152 +         }
208.2153 +         if (cpiv == 0)
208.2154 +         {  /* non-basic variable x[q] can change unlimitedly */
208.2155 +            if (dir < 0 && rval[rpiv] > 0.0 ||
208.2156 +                dir > 0 && rval[rpiv] < 0.0)
208.2157 +            {  /* delta x[k] = alfa[k,q] * delta x[q] < 0 */
208.2158 +               new_x = -DBL_MAX;
208.2159 +            }
208.2160 +            else
208.2161 +            {  /* delta x[k] = alfa[k,q] * delta x[q] > 0 */
208.2162 +               new_x = +DBL_MAX;
208.2163 +            }
208.2164 +            goto store;
208.2165 +         }
208.2166 +         /* some basic variable x[p] limits changing non-basic variable
208.2167 +            x[q] in the adjacent basis */
208.2168 +         xassert(1 <= cpiv && cpiv <= clen);
208.2169 +         p = cind[cpiv];
208.2170 +         xassert(1 <= p && p <= m+n);
208.2171 +         xassert(p != k);
208.2172 +         if (p <= m)
208.2173 +         {  row = P->row[p];
208.2174 +            xassert(row->stat == GLP_BS);
208.2175 +            ll = glp_get_row_lb(P, row->i);
208.2176 +            uu = glp_get_row_ub(P, row->i);
208.2177 +            xx = row->prim;
208.2178 +         }
208.2179 +         else
208.2180 +         {  col = P->col[p-m];
208.2181 +            xassert(col->stat == GLP_BS);
208.2182 +            ll = glp_get_col_lb(P, col->j);
208.2183 +            uu = glp_get_col_ub(P, col->j);
208.2184 +            xx = col->prim;
208.2185 +         }
208.2186 +         /* determine delta x[p] = new x[p] - x[p] */
208.2187 +         if (dir < 0 && cval[cpiv] > 0.0 ||
208.2188 +             dir > 0 && cval[cpiv] < 0.0)
208.2189 +         {  /* delta x[p] < 0, so x[p] goes toward its lower bound */
208.2190 +            xassert(ll != -DBL_MAX);
208.2191 +            delta = ll - xx;
208.2192 +         }
208.2193 +         else
208.2194 +         {  /* delta x[p] > 0, so x[p] goes toward its upper bound */
208.2195 +            xassert(uu != +DBL_MAX);
208.2196 +            delta = uu - xx;
208.2197 +         }
208.2198 +         /* compute new x[k] = x[k] + alfa[k,q] * delta x[q], where
208.2199 +            delta x[q] = delta x[p] / alfa[p,q] */
208.2200 +         xassert(cval[cpiv] != 0.0);
208.2201 +         new_x = x + (rval[rpiv] / cval[cpiv]) * delta;
208.2202 +store:   /* store analysis results */
208.2203 +         if (kase < 0)
208.2204 +         {  if (coef1 != NULL) *coef1 = lim_coef;
208.2205 +            if (var1 != NULL) *var1 = q;
208.2206 +            if (value1 != NULL) *value1 = new_x;
208.2207 +         }
208.2208 +         else
208.2209 +         {  if (coef2 != NULL) *coef2 = lim_coef;
208.2210 +            if (var2 != NULL) *var2 = q;
208.2211 +            if (value2 != NULL) *value2 = new_x;
208.2212 +         }
208.2213 +      }
208.2214 +      /* free working arrays */
208.2215 +      xfree(cind);
208.2216 +      xfree(cval);
208.2217 +      xfree(rind);
208.2218 +      xfree(rval);
208.2219 +      return;
208.2220 +}
208.2221 +
208.2222 +/* eof */
   209.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
   209.2 +++ b/deps/glpk/src/glpapi13.c	Sun Nov 06 20:59:10 2011 +0100
   209.3 @@ -0,0 +1,702 @@
   209.4 +/* glpapi13.c (branch-and-bound interface routines) */
   209.5 +
   209.6 +/***********************************************************************
   209.7 +*  This code is part of GLPK (GNU Linear Programming Kit).
   209.8 +*
   209.9 +*  Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008,
  209.10 +*  2009, 2010, 2011 Andrew Makhorin, Department for Applied Informatics,
  209.11 +*  Moscow Aviation Institute, Moscow, Russia. All rights reserved.
  209.12 +*  E-mail: <mao@gnu.org>.
  209.13 +*
  209.14 +*  GLPK is free software: you can redistribute it and/or modify it
  209.15 +*  under the terms of the GNU General Public License as published by
  209.16 +*  the Free Software Foundation, either version 3 of the License, or
  209.17 +*  (at your option) any later version.
  209.18 +*
  209.19 +*  GLPK is distributed in the hope that it will be useful, but WITHOUT
  209.20 +*  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
  209.21 +*  or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
  209.22 +*  License for more details.
  209.23 +*
  209.24 +*  You should have received a copy of the GNU General Public License
  209.25 +*  along with GLPK. If not, see <http://www.gnu.org/licenses/>.
  209.26 +***********************************************************************/
  209.27 +
  209.28 +#include "glpios.h"
  209.29 +
  209.30 +/***********************************************************************
  209.31 +*  NAME
  209.32 +*
  209.33 +*  glp_ios_reason - determine reason for calling the callback routine
  209.34 +*
  209.35 +*  SYNOPSIS
  209.36 +*
  209.37 +*  glp_ios_reason(glp_tree *tree);
  209.38 +*
  209.39 +*  RETURNS
  209.40 +*
  209.41 +*  The routine glp_ios_reason returns a code, which indicates why the
  209.42 +*  user-defined callback routine is being called. */
  209.43 +
  209.44 +int glp_ios_reason(glp_tree *tree)
  209.45 +{     return
  209.46 +         tree->reason;
  209.47 +}
  209.48 +
  209.49 +/***********************************************************************
  209.50 +*  NAME
  209.51 +*
  209.52 +*  glp_ios_get_prob - access the problem object
  209.53 +*
  209.54 +*  SYNOPSIS
  209.55 +*
  209.56 +*  glp_prob *glp_ios_get_prob(glp_tree *tree);
  209.57 +*
  209.58 +*  DESCRIPTION
  209.59 +*
  209.60 +*  The routine glp_ios_get_prob can be called from the user-defined
  209.61 +*  callback routine to access the problem object, which is used by the
  209.62 +*  MIP solver. It is the original problem object passed to the routine
  209.63 +*  glp_intopt if the MIP presolver is not used; otherwise it is an
  209.64 +*  internal problem object built by the presolver. If the current
  209.65 +*  subproblem exists, LP segment of the problem object corresponds to
  209.66 +*  its LP relaxation.
  209.67 +*
  209.68 +*  RETURNS
  209.69 +*
  209.70 +*  The routine glp_ios_get_prob returns a pointer to the problem object
  209.71 +*  used by the MIP solver. */
  209.72 +
  209.73 +glp_prob *glp_ios_get_prob(glp_tree *tree)
  209.74 +{     return
  209.75 +         tree->mip;
  209.76 +}
  209.77 +
  209.78 +/***********************************************************************
  209.79 +*  NAME
  209.80 +*
  209.81 +*  glp_ios_tree_size - determine size of the branch-and-bound tree
  209.82 +*
  209.83 +*  SYNOPSIS
  209.84 +*
  209.85 +*  void glp_ios_tree_size(glp_tree *tree, int *a_cnt, int *n_cnt,
  209.86 +*     int *t_cnt);
  209.87 +*
  209.88 +*  DESCRIPTION
  209.89 +*
  209.90 +*  The routine glp_ios_tree_size stores the following three counts which
  209.91 +*  characterize the current size of the branch-and-bound tree:
  209.92 +*
  209.93 +*  a_cnt is the current number of active nodes, i.e. the current size of
  209.94 +*        the active list;
  209.95 +*
  209.96 +*  n_cnt is the current number of all (active and inactive) nodes;
  209.97 +*
  209.98 +*  t_cnt is the total number of nodes including those which have been
  209.99 +*        already removed from the tree. This count is increased whenever
 209.100 +*        a new node appears in the tree and never decreased.
 209.101 +*
 209.102 +*  If some of the parameters a_cnt, n_cnt, t_cnt is a null pointer, the
 209.103 +*  corresponding count is not stored. */
 209.104 +
 209.105 +void glp_ios_tree_size(glp_tree *tree, int *a_cnt, int *n_cnt,
 209.106 +      int *t_cnt)
 209.107 +{     if (a_cnt != NULL) *a_cnt = tree->a_cnt;
 209.108 +      if (n_cnt != NULL) *n_cnt = tree->n_cnt;
 209.109 +      if (t_cnt != NULL) *t_cnt = tree->t_cnt;
 209.110 +      return;
 209.111 +}
 209.112 +
 209.113 +/***********************************************************************
 209.114 +*  NAME
 209.115 +*
 209.116 +*  glp_ios_curr_node - determine current active subproblem
 209.117 +*
 209.118 +*  SYNOPSIS
 209.119 +*
 209.120 +*  int glp_ios_curr_node(glp_tree *tree);
 209.121 +*
 209.122 +*  RETURNS
 209.123 +*
 209.124 +*  The routine glp_ios_curr_node returns the reference number of the
 209.125 +*  current active subproblem. However, if the current subproblem does
 209.126 +*  not exist, the routine returns zero. */
 209.127 +
 209.128 +int glp_ios_curr_node(glp_tree *tree)
 209.129 +{     IOSNPD *node;
 209.130 +      /* obtain pointer to the current subproblem */
 209.131 +      node = tree->curr;
 209.132 +      /* return its reference number */
 209.133 +      return node == NULL ? 0 : node->p;
 209.134 +}
 209.135 +
 209.136 +/***********************************************************************
 209.137 +*  NAME
 209.138 +*
 209.139 +*  glp_ios_next_node - determine next active subproblem
 209.140 +*
 209.141 +*  SYNOPSIS
 209.142 +*
 209.143 +*  int glp_ios_next_node(glp_tree *tree, int p);
 209.144 +*
 209.145 +*  RETURNS
 209.146 +*
 209.147 +*  If the parameter p is zero, the routine glp_ios_next_node returns
 209.148 +*  the reference number of the first active subproblem. However, if the
 209.149 +*  tree is empty, zero is returned.
 209.150 +*
 209.151 +*  If the parameter p is not zero, it must specify the reference number
 209.152 +*  of some active subproblem, in which case the routine returns the
 209.153 +*  reference number of the next active subproblem. However, if there is
 209.154 +*  no next active subproblem in the list, zero is returned.
 209.155 +*
 209.156 +*  All subproblems in the active list are ordered chronologically, i.e.
 209.157 +*  subproblem A precedes subproblem B if A was created before B. */
 209.158 +
 209.159 +int glp_ios_next_node(glp_tree *tree, int p)
 209.160 +{     IOSNPD *node;
 209.161 +      if (p == 0)
 209.162 +      {  /* obtain pointer to the first active subproblem */
 209.163 +         node = tree->head;
 209.164 +      }
 209.165 +      else
 209.166 +      {  /* obtain pointer to the specified subproblem */
 209.167 +         if (!(1 <= p && p <= tree->nslots))
 209.168 +err:        xerror("glp_ios_next_node: p = %d; invalid subproblem refer"
 209.169 +               "ence number\n", p);
 209.170 +         node = tree->slot[p].node;
 209.171 +         if (node == NULL) goto err;
 209.172 +         /* the specified subproblem must be active */
 209.173 +         if (node->count != 0)
 209.174 +            xerror("glp_ios_next_node: p = %d; subproblem not in the ac"
 209.175 +               "tive list\n", p);
 209.176 +         /* obtain pointer to the next active subproblem */
 209.177 +         node = node->next;
 209.178 +      }
 209.179 +      /* return the reference number */
 209.180 +      return node == NULL ? 0 : node->p;
 209.181 +}
 209.182 +
 209.183 +/***********************************************************************
 209.184 +*  NAME
 209.185 +*
 209.186 +*  glp_ios_prev_node - determine previous active subproblem
 209.187 +*
 209.188 +*  SYNOPSIS
 209.189 +*
 209.190 +*  int glp_ios_prev_node(glp_tree *tree, int p);
 209.191 +*
 209.192 +*  RETURNS
 209.193 +*
 209.194 +*  If the parameter p is zero, the routine glp_ios_prev_node returns
 209.195 +*  the reference number of the last active subproblem. However, if the
 209.196 +*  tree is empty, zero is returned.
 209.197 +*
 209.198 +*  If the parameter p is not zero, it must specify the reference number
 209.199 +*  of some active subproblem, in which case the routine returns the
 209.200 +*  reference number of the previous active subproblem. However, if there
 209.201 +*  is no previous active subproblem in the list, zero is returned.
 209.202 +*
 209.203 +*  All subproblems in the active list are ordered chronologically, i.e.
 209.204 +*  subproblem A precedes subproblem B if A was created before B. */
 209.205 +
 209.206 +int glp_ios_prev_node(glp_tree *tree, int p)
 209.207 +{     IOSNPD *node;
 209.208 +      if (p == 0)
 209.209 +      {  /* obtain pointer to the last active subproblem */
 209.210 +         node = tree->tail;
 209.211 +      }
 209.212 +      else
 209.213 +      {  /* obtain pointer to the specified subproblem */
 209.214 +         if (!(1 <= p && p <= tree->nslots))
 209.215 +err:        xerror("glp_ios_prev_node: p = %d; invalid subproblem refer"
 209.216 +               "ence number\n", p);
 209.217 +         node = tree->slot[p].node;
 209.218 +         if (node == NULL) goto err;
 209.219 +         /* the specified subproblem must be active */
 209.220 +         if (node->count != 0)
 209.221 +            xerror("glp_ios_prev_node: p = %d; subproblem not in the ac"
 209.222 +               "tive list\n", p);
 209.223 +         /* obtain pointer to the previous active subproblem */
 209.224 +         node = node->prev;
 209.225 +      }
 209.226 +      /* return the reference number */
 209.227 +      return node == NULL ? 0 : node->p;
 209.228 +}
 209.229 +
 209.230 +/***********************************************************************
 209.231 +*  NAME
 209.232 +*
 209.233 +*  glp_ios_up_node - determine parent subproblem
 209.234 +*
 209.235 +*  SYNOPSIS
 209.236 +*
 209.237 +*  int glp_ios_up_node(glp_tree *tree, int p);
 209.238 +*
 209.239 +*  RETURNS
 209.240 +*
 209.241 +*  The parameter p must specify the reference number of some (active or
 209.242 +*  inactive) subproblem, in which case the routine iet_get_up_node
 209.243 +*  returns the reference number of its parent subproblem. However, if
 209.244 +*  the specified subproblem is the root of the tree and, therefore, has
 209.245 +*  no parent, the routine returns zero. */
 209.246 +
 209.247 +int glp_ios_up_node(glp_tree *tree, int p)
 209.248 +{     IOSNPD *node;
 209.249 +      /* obtain pointer to the specified subproblem */
 209.250 +      if (!(1 <= p && p <= tree->nslots))
 209.251 +err:     xerror("glp_ios_up_node: p = %d; invalid subproblem reference "
 209.252 +            "number\n", p);
 209.253 +      node = tree->slot[p].node;
 209.254 +      if (node == NULL) goto err;
 209.255 +      /* obtain pointer to the parent subproblem */
 209.256 +      node = node->up;
 209.257 +      /* return the reference number */
 209.258 +      return node == NULL ? 0 : node->p;
 209.259 +}
 209.260 +
 209.261 +/***********************************************************************
 209.262 +*  NAME
 209.263 +*
 209.264 +*  glp_ios_node_level - determine subproblem level
 209.265 +*
 209.266 +*  SYNOPSIS
 209.267 +*
 209.268 +*  int glp_ios_node_level(glp_tree *tree, int p);
 209.269 +*
 209.270 +*  RETURNS
 209.271 +*
 209.272 +*  The routine glp_ios_node_level returns the level of the subproblem,
 209.273 +*  whose reference number is p, in the branch-and-bound tree. (The root
 209.274 +*  subproblem has level 0, and the level of any other subproblem is the
 209.275 +*  level of its parent plus one.) */
 209.276 +
 209.277 +int glp_ios_node_level(glp_tree *tree, int p)
 209.278 +{     IOSNPD *node;
 209.279 +      /* obtain pointer to the specified subproblem */
 209.280 +      if (!(1 <= p && p <= tree->nslots))
 209.281 +err:     xerror("glp_ios_node_level: p = %d; invalid subproblem referen"
 209.282 +            "ce number\n", p);
 209.283 +      node = tree->slot[p].node;
 209.284 +      if (node == NULL) goto err;
 209.285 +      /* return the node level */
 209.286 +      return node->level;
 209.287 +}
 209.288 +
 209.289 +/***********************************************************************
 209.290 +*  NAME
 209.291 +*
 209.292 +*  glp_ios_node_bound - determine subproblem local bound
 209.293 +*
 209.294 +*  SYNOPSIS
 209.295 +*
 209.296 +*  double glp_ios_node_bound(glp_tree *tree, int p);
 209.297 +*
 209.298 +*  RETURNS
 209.299 +*
 209.300 +*  The routine glp_ios_node_bound returns the local bound for (active or
 209.301 +*  inactive) subproblem, whose reference number is p.
 209.302 +*
 209.303 +*  COMMENTS
 209.304 +*
 209.305 +*  The local bound for subproblem p is an lower (minimization) or upper
 209.306 +*  (maximization) bound for integer optimal solution to this subproblem
 209.307 +*  (not to the original problem). This bound is local in the sense that
 209.308 +*  only subproblems in the subtree rooted at node p cannot have better
 209.309 +*  integer feasible solutions.
 209.310 +*
 209.311 +*  On creating a subproblem (due to the branching step) its local bound
 209.312 +*  is inherited from its parent and then may get only stronger (never
 209.313 +*  weaker). For the root subproblem its local bound is initially set to
 209.314 +*  -DBL_MAX (minimization) or +DBL_MAX (maximization) and then improved
 209.315 +*  as the root LP relaxation has been solved.
 209.316 +*
 209.317 +*  Note that the local bound is not necessarily the optimal objective
 209.318 +*  value to corresponding LP relaxation; it may be stronger. */
 209.319 +
 209.320 +double glp_ios_node_bound(glp_tree *tree, int p)
 209.321 +{     IOSNPD *node;
 209.322 +      /* obtain pointer to the specified subproblem */
 209.323 +      if (!(1 <= p && p <= tree->nslots))
 209.324 +err:     xerror("glp_ios_node_bound: p = %d; invalid subproblem referen"
 209.325 +            "ce number\n", p);
 209.326 +      node = tree->slot[p].node;
 209.327 +      if (node == NULL) goto err;
 209.328 +      /* return the node local bound */
 209.329 +      return node->bound;
 209.330 +}
 209.331 +
 209.332 +/***********************************************************************
 209.333 +*  NAME
 209.334 +*
 209.335 +*  glp_ios_best_node - find active subproblem with best local bound
 209.336 +*
 209.337 +*  SYNOPSIS
 209.338 +*
 209.339 +*  int glp_ios_best_node(glp_tree *tree);
 209.340 +*
 209.341 +*  RETURNS
 209.342 +*
 209.343 +*  The routine glp_ios_best_node returns the reference number of the
 209.344 +*  active subproblem, whose local bound is best (i.e. smallest in case
 209.345 +*  of minimization or largest in case of maximization). However, if the
 209.346 +*  tree is empty, the routine returns zero.
 209.347 +*
 209.348 +*  COMMENTS
 209.349 +*
 209.350 +*  The best local bound is an lower (minimization) or upper
 209.351 +*  (maximization) bound for integer optimal solution to the original
 209.352 +*  MIP problem. */
 209.353 +
 209.354 +int glp_ios_best_node(glp_tree *tree)
 209.355 +{     return
 209.356 +         ios_best_node(tree);
 209.357 +}
 209.358 +
 209.359 +/***********************************************************************
 209.360 +*  NAME
 209.361 +*
 209.362 +*  glp_ios_mip_gap - compute relative MIP gap
 209.363 +*
 209.364 +*  SYNOPSIS
 209.365 +*
 209.366 +*  double glp_ios_mip_gap(glp_tree *tree);
 209.367 +*
 209.368 +*  DESCRIPTION
 209.369 +*
 209.370 +*  The routine glp_ios_mip_gap computes the relative MIP gap with the
 209.371 +*  following formula:
 209.372 +*
 209.373 +*     gap = |best_mip - best_bnd| / (|best_mip| + DBL_EPSILON),
 209.374 +*
 209.375 +*  where best_mip is the best integer feasible solution found so far,
 209.376 +*  best_bnd is the best (global) bound. If no integer feasible solution
 209.377 +*  has been found yet, gap is set to DBL_MAX.
 209.378 +*
 209.379 +*  RETURNS
 209.380 +*
 209.381 +*  The routine glp_ios_mip_gap returns the relative MIP gap. */
 209.382 +
 209.383 +double glp_ios_mip_gap(glp_tree *tree)
 209.384 +{     return
 209.385 +         ios_relative_gap(tree);
 209.386 +}
 209.387 +
 209.388 +/***********************************************************************
 209.389 +*  NAME
 209.390 +*
 209.391 +*  glp_ios_node_data - access subproblem application-specific data
 209.392 +*
 209.393 +*  SYNOPSIS
 209.394 +*
 209.395 +*  void *glp_ios_node_data(glp_tree *tree, int p);
 209.396 +*
 209.397 +*  DESCRIPTION
 209.398 +*
 209.399 +*  The routine glp_ios_node_data allows the application accessing a
 209.400 +*  memory block allocated for the subproblem (which may be active or
 209.401 +*  inactive), whose reference number is p.
 209.402 +*
 209.403 +*  The size of the block is defined by the control parameter cb_size
 209.404 +*  passed to the routine glp_intopt. The block is initialized by binary
 209.405 +*  zeros on creating corresponding subproblem, and its contents is kept
 209.406 +*  until the subproblem will be removed from the tree.
 209.407 +*
 209.408 +*  The application may use these memory blocks to store specific data
 209.409 +*  for each subproblem.
 209.410 +*
 209.411 +*  RETURNS
 209.412 +*
 209.413 +*  The routine glp_ios_node_data returns a pointer to the memory block
 209.414 +*  for the specified subproblem. Note that if cb_size = 0, the routine
 209.415 +*  returns a null pointer. */
 209.416 +
 209.417 +void *glp_ios_node_data(glp_tree *tree, int p)
 209.418 +{     IOSNPD *node;
 209.419 +      /* obtain pointer to the specified subproblem */
 209.420 +      if (!(1 <= p && p <= tree->nslots))
 209.421 +err:     xerror("glp_ios_node_level: p = %d; invalid subproblem referen"
 209.422 +            "ce number\n", p);
 209.423 +      node = tree->slot[p].node;
 209.424 +      if (node == NULL) goto err;
 209.425 +      /* return pointer to the application-specific data */
 209.426 +      return node->data;
 209.427 +}
 209.428 +
 209.429 +/***********************************************************************
 209.430 +*  NAME
 209.431 +*
 209.432 +*  glp_ios_row_attr - retrieve additional row attributes
 209.433 +*
 209.434 +*  SYNOPSIS
 209.435 +*
 209.436 +*  void glp_ios_row_attr(glp_tree *tree, int i, glp_attr *attr);
 209.437 +*
 209.438 +*  DESCRIPTION
 209.439 +*
 209.440 +*  The routine glp_ios_row_attr retrieves additional attributes of row
 209.441 +*  i and stores them in the structure glp_attr. */
 209.442 +
 209.443 +void glp_ios_row_attr(glp_tree *tree, int i, glp_attr *attr)
 209.444 +{     GLPROW *row;
 209.445 +      if (!(1 <= i && i <= tree->mip->m))
 209.446 +         xerror("glp_ios_row_attr: i = %d; row number out of range\n",
 209.447 +            i);
 209.448 +      row = tree->mip->row[i];
 209.449 +      attr->level = row->level;
 209.450 +      attr->origin = row->origin;
 209.451 +      attr->klass = row->klass;
 209.452 +      return;
 209.453 +}
 209.454 +
 209.455 +/**********************************************************************/
 209.456 +
 209.457 +int glp_ios_pool_size(glp_tree *tree)
 209.458 +{     /* determine current size of the cut pool */
 209.459 +      if (tree->reason != GLP_ICUTGEN)
 209.460 +         xerror("glp_ios_pool_size: operation not allowed\n");
 209.461 +      xassert(tree->local != NULL);
 209.462 +      return tree->local->size;
 209.463 +}
 209.464 +
 209.465 +/**********************************************************************/
 209.466 +
 209.467 +int glp_ios_add_row(glp_tree *tree,
 209.468 +      const char *name, int klass, int flags, int len, const int ind[],
 209.469 +      const double val[], int type, double rhs)
 209.470 +{     /* add row (constraint) to the cut pool */
 209.471 +      int num;
 209.472 +      if (tree->reason != GLP_ICUTGEN)
 209.473 +         xerror("glp_ios_add_row: operation not allowed\n");
 209.474 +      xassert(tree->local != NULL);
 209.475 +      num = ios_add_row(tree, tree->local, name, klass, flags, len,
 209.476 +         ind, val, type, rhs);
 209.477 +      return num;
 209.478 +}
 209.479 +
 209.480 +/**********************************************************************/
 209.481 +
 209.482 +void glp_ios_del_row(glp_tree *tree, int i)
 209.483 +{     /* remove row (constraint) from the cut pool */
 209.484 +      if (tree->reason != GLP_ICUTGEN)
 209.485 +         xerror("glp_ios_del_row: operation not allowed\n");
 209.486 +      ios_del_row(tree, tree->local, i);
 209.487 +      return;
 209.488 +}
 209.489 +
 209.490 +/**********************************************************************/
 209.491 +
 209.492 +void glp_ios_clear_pool(glp_tree *tree)
 209.493 +{     /* remove all rows (constraints) from the cut pool */
 209.494 +      if (tree->reason != GLP_ICUTGEN)
 209.495 +         xerror("glp_ios_clear_pool: operation not allowed\n");
 209.496 +      ios_clear_pool(tree, tree->local);
 209.497 +      return;
 209.498 +}
 209.499 +
 209.500 +/***********************************************************************
 209.501 +*  NAME
 209.502 +*
 209.503 +*  glp_ios_can_branch - check if can branch upon specified variable
 209.504 +*
 209.505 +*  SYNOPSIS
 209.506 +*
 209.507 +*  int glp_ios_can_branch(glp_tree *tree, int j);
 209.508 +*
 209.509 +*  RETURNS
 209.510 +*
 209.511 +*  If j-th variable (column) can be used to branch upon, the routine
 209.512 +*  glp_ios_can_branch returns non-zero, otherwise zero. */
 209.513 +
 209.514 +int glp_ios_can_branch(glp_tree *tree, int j)
 209.515 +{     if (!(1 <= j && j <= tree->mip->n))
 209.516 +         xerror("glp_ios_can_branch: j = %d; column number out of range"
 209.517 +            "\n", j);
 209.518 +      return tree->non_int[j];
 209.519 +}
 209.520 +
 209.521 +/***********************************************************************
 209.522 +*  NAME
 209.523 +*
 209.524 +*  glp_ios_branch_upon - choose variable to branch upon
 209.525 +*
 209.526 +*  SYNOPSIS
 209.527 +*
 209.528 +*  void glp_ios_branch_upon(glp_tree *tree, int j, int sel);
 209.529 +*
 209.530 +*  DESCRIPTION
 209.531 +*
 209.532 +*  The routine glp_ios_branch_upon can be called from the user-defined
 209.533 +*  callback routine in response to the reason GLP_IBRANCH to choose a
 209.534 +*  branching variable, whose ordinal number is j. Should note that only
 209.535 +*  variables, for which the routine glp_ios_can_branch returns non-zero,
 209.536 +*  can be used to branch upon.
 209.537 +*
 209.538 +*  The parameter sel is a flag that indicates which branch (subproblem)
 209.539 +*  should be selected next to continue the search:
 209.540 +*
 209.541 +*  GLP_DN_BRNCH - select down-branch;
 209.542 +*  GLP_UP_BRNCH - select up-branch;
 209.543 +*  GLP_NO_BRNCH - use general selection technique. */
 209.544 +
 209.545 +void glp_ios_branch_upon(glp_tree *tree, int j, int sel)
 209.546 +{     if (!(1 <= j && j <= tree->mip->n))
 209.547 +         xerror("glp_ios_branch_upon: j = %d; column number out of rang"
 209.548 +            "e\n", j);
 209.549 +      if (!(sel == GLP_DN_BRNCH || sel == GLP_UP_BRNCH ||
 209.550 +            sel == GLP_NO_BRNCH))
 209.551 +         xerror("glp_ios_branch_upon: sel = %d: invalid branch selectio"
 209.552 +            "n flag\n", sel);
 209.553 +      if (!(tree->non_int[j]))
 209.554 +         xerror("glp_ios_branch_upon: j = %d; variable cannot be used t"
 209.555 +            "o branch upon\n", j);
 209.556 +      if (tree->br_var != 0)
 209.557 +         xerror("glp_ios_branch_upon: branching variable already chosen"
 209.558 +            "\n");
 209.559 +      tree->br_var = j;
 209.560 +      tree->br_sel = sel;
 209.561 +      return;
 209.562 +}
 209.563 +
 209.564 +/***********************************************************************
 209.565 +*  NAME
 209.566 +*
 209.567 +*  glp_ios_select_node - select subproblem to continue the search
 209.568 +*
 209.569 +*  SYNOPSIS
 209.570 +*
 209.571 +*  void glp_ios_select_node(glp_tree *tree, int p);
 209.572 +*
 209.573 +*  DESCRIPTION
 209.574 +*
 209.575 +*  The routine glp_ios_select_node can be called from the user-defined
 209.576 +*  callback routine in response to the reason GLP_ISELECT to select an
 209.577 +*  active subproblem, whose reference number is p. The search will be
 209.578 +*  continued from the subproblem selected. */
 209.579 +
 209.580 +void glp_ios_select_node(glp_tree *tree, int p)
 209.581 +{     IOSNPD *node;
 209.582 +      /* obtain pointer to the specified subproblem */
 209.583 +      if (!(1 <= p && p <= tree->nslots))
 209.584 +err:     xerror("glp_ios_select_node: p = %d; invalid subproblem refere"
 209.585 +            "nce number\n", p);
 209.586 +      node = tree->slot[p].node;
 209.587 +      if (node == NULL) goto err;
 209.588 +      /* the specified subproblem must be active */
 209.589 +      if (node->count != 0)
 209.590 +         xerror("glp_ios_select_node: p = %d; subproblem not in the act"
 209.591 +            "ive list\n", p);
 209.592 +      /* no subproblem must be selected yet */
 209.593 +      if (tree->next_p != 0)
 209.594 +         xerror("glp_ios_select_node: subproblem already selected\n");
 209.595 +      /* select the specified subproblem to continue the search */
 209.596 +      tree->next_p = p;
 209.597 +      return;
 209.598 +}
 209.599 +
 209.600 +/***********************************************************************
 209.601 +*  NAME
 209.602 +*
 209.603 +*  glp_ios_heur_sol - provide solution found by heuristic
 209.604 +*
 209.605 +*  SYNOPSIS
 209.606 +*
 209.607 +*  int glp_ios_heur_sol(glp_tree *tree, const double x[]);
 209.608 +*
 209.609 +*  DESCRIPTION
 209.610 +*
 209.611 +*  The routine glp_ios_heur_sol can be called from the user-defined
 209.612 +*  callback routine in response to the reason GLP_IHEUR to provide an
 209.613 +*  integer feasible solution found by a primal heuristic.
 209.614 +*
 209.615 +*  Primal values of *all* variables (columns) found by the heuristic
 209.616 +*  should be placed in locations x[1], ..., x[n], where n is the number
 209.617 +*  of columns in the original problem object. Note that the routine
 209.618 +*  glp_ios_heur_sol *does not* check primal feasibility of the solution
 209.619 +*  provided.
 209.620 +*
 209.621 +*  Using the solution passed in the array x the routine computes value
 209.622 +*  of the objective function. If the objective value is better than the
 209.623 +*  best known integer feasible solution, the routine computes values of
 209.624 +*  auxiliary variables (rows) and stores all solution components in the
 209.625 +*  problem object.
 209.626 +*
 209.627 +*  RETURNS
 209.628 +*
 209.629 +*  If the provided solution is accepted, the routine glp_ios_heur_sol
 209.630 +*  returns zero. Otherwise, if the provided solution is rejected, the
 209.631 +*  routine returns non-zero. */
 209.632 +
 209.633 +int glp_ios_heur_sol(glp_tree *tree, const double x[])
 209.634 +{     glp_prob *mip = tree->mip;
 209.635 +      int m = tree->orig_m;
 209.636 +      int n = tree->n;
 209.637 +      int i, j;
 209.638 +      double obj;
 209.639 +      xassert(mip->m >= m);
 209.640 +      xassert(mip->n == n);
 209.641 +      /* check values of integer variables and compute value of the
 209.642 +         objective function */
 209.643 +      obj = mip->c0;
 209.644 +      for (j = 1; j <= n; j++)
 209.645 +      {  GLPCOL *col = mip->col[j];
 209.646 +         if (col->kind == GLP_IV)
 209.647 +         {  /* provided value must be integral */
 209.648 +            if (x[j] != floor(x[j])) return 1;
 209.649 +         }
 209.650 +         obj += col->coef * x[j];
 209.651 +      }
 209.652 +      /* check if the provided solution is better than the best known
 209.653 +         integer feasible solution */
 209.654 +      if (mip->mip_stat == GLP_FEAS)
 209.655 +      {  switch (mip->dir)
 209.656 +         {  case GLP_MIN:
 209.657 +               if (obj >= tree->mip->mip_obj) return 1;
 209.658 +               break;
 209.659 +            case GLP_MAX:
 209.660 +               if (obj <= tree->mip->mip_obj) return 1;
 209.661 +               break;
 209.662 +            default:
 209.663 +               xassert(mip != mip);
 209.664 +         }
 209.665 +      }
 209.666 +      /* it is better; store it in the problem object */
 209.667 +      if (tree->parm->msg_lev >= GLP_MSG_ON)
 209.668 +         xprintf("Solution found by heuristic: %.12g\n", obj);
 209.669 +      mip->mip_stat = GLP_FEAS;
 209.670 +      mip->mip_obj = obj;
 209.671 +      for (j = 1; j <= n; j++)
 209.672 +         mip->col[j]->mipx = x[j];
 209.673 +      for (i = 1; i <= m; i++)
 209.674 +      {  GLPROW *row = mip->row[i];
 209.675 +         GLPAIJ *aij;
 209.676 +         row->mipx = 0.0;
 209.677 +         for (aij = row->ptr; aij != NULL; aij = aij->r_next)
 209.678 +            row->mipx += aij->val * aij->col->mipx;
 209.679 +      }
 209.680 +      return 0;
 209.681 +}
 209.682 +
 209.683 +/***********************************************************************
 209.684 +*  NAME
 209.685 +*
 209.686 +*  glp_ios_terminate - terminate the solution process.
 209.687 +*
 209.688 +*  SYNOPSIS
 209.689 +*
 209.690 +*  void glp_ios_terminate(glp_tree *tree);
 209.691 +*
 209.692 +*  DESCRIPTION
 209.693 +*
 209.694 +*  The routine glp_ios_terminate sets a flag indicating that the MIP
 209.695 +*  solver should prematurely terminate the search. */
 209.696 +
 209.697 +void glp_ios_terminate(glp_tree *tree)
 209.698 +{     if (tree->parm->msg_lev >= GLP_MSG_DBG)
 209.699 +         xprintf("The search is prematurely terminated due to applicati"
 209.700 +            "on request\n");
 209.701 +      tree->stop = 1;
 209.702 +      return;
 209.703 +}
 209.704 +
 209.705 +/* eof */
   210.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
   210.2 +++ b/deps/glpk/src/glpapi14.c	Sun Nov 06 20:59:10 2011 +0100
   210.3 @@ -0,0 +1,274 @@
   210.4 +/* glpapi14.c (processing models in GNU MathProg language) */
   210.5 +
   210.6 +/***********************************************************************
   210.7 +*  This code is part of GLPK (GNU Linear Programming Kit).
   210.8 +*
   210.9 +*  Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008,
  210.10 +*  2009, 2010, 2011 Andrew Makhorin, Department for Applied Informatics,
  210.11 +*  Moscow Aviation Institute, Moscow, Russia. All rights reserved.
  210.12 +*  E-mail: <mao@gnu.org>.
  210.13 +*
  210.14 +*  GLPK is free software: you can redistribute it and/or modify it
  210.15 +*  under the terms of the GNU General Public License as published by
  210.16 +*  the Free Software Foundation, either version 3 of the License, or
  210.17 +*  (at your option) any later version.
  210.18 +*
  210.19 +*  GLPK is distributed in the hope that it will be useful, but WITHOUT
  210.20 +*  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
  210.21 +*  or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
  210.22 +*  License for more details.
  210.23 +*
  210.24 +*  You should have received a copy of the GNU General Public License
  210.25 +*  along with GLPK. If not, see <http://www.gnu.org/licenses/>.
  210.26 +***********************************************************************/
  210.27 +
  210.28 +#define GLP_TRAN_DEFINED
  210.29 +typedef struct MPL glp_tran;
  210.30 +
  210.31 +#include "glpmpl.h"
  210.32 +#include "glpapi.h"
  210.33 +
  210.34 +glp_tran *glp_mpl_alloc_wksp(void)
  210.35 +{     /* allocate the MathProg translator workspace */
  210.36 +      glp_tran *tran;
  210.37 +      tran = mpl_initialize();
  210.38 +      return tran;
  210.39 +}
  210.40 +
  210.41 +#if 1 /* 08/XII-2009 */
  210.42 +void _glp_mpl_init_rand(glp_tran *tran, int seed)
  210.43 +{     if (tran->phase != 0)
  210.44 +         xerror("glp_mpl_init_rand: invalid call sequence\n");
  210.45 +      rng_init_rand(tran->rand, seed);
  210.46 +      return;
  210.47 +}
  210.48 +#endif
  210.49 +
  210.50 +int glp_mpl_read_model(glp_tran *tran, const char *fname, int skip)
  210.51 +{     /* read and translate model section */
  210.52 +      int ret;
  210.53 +      if (tran->phase != 0)
  210.54 +         xerror("glp_mpl_read_model: invalid call sequence\n");
  210.55 +      ret = mpl_read_model(tran, (char *)fname, skip);
  210.56 +      if (ret == 1 || ret == 2)
  210.57 +         ret = 0;
  210.58 +      else if (ret == 4)
  210.59 +         ret = 1;
  210.60 +      else
  210.61 +         xassert(ret != ret);
  210.62 +      return ret;
  210.63 +}
  210.64 +
  210.65 +int glp_mpl_read_data(glp_tran *tran, const char *fname)
  210.66 +{     /* read and translate data section */
  210.67 +      int ret;
  210.68 +      if (!(tran->phase == 1 || tran->phase == 2))
  210.69 +         xerror("glp_mpl_read_data: invalid call sequence\n");
  210.70 +      ret = mpl_read_data(tran, (char *)fname);
  210.71 +      if (ret == 2)
  210.72 +         ret = 0;
  210.73 +      else if (ret == 4)
  210.74 +         ret = 1;
  210.75 +      else
  210.76 +         xassert(ret != ret);
  210.77 +      return ret;
  210.78 +}
  210.79 +
  210.80 +int glp_mpl_generate(glp_tran *tran, const char *fname)
  210.81 +{     /* generate the model */
  210.82 +      int ret;
  210.83 +      if (!(tran->phase == 1 || tran->phase == 2))
  210.84 +         xerror("glp_mpl_generate: invalid call sequence\n");
  210.85 +      ret = mpl_generate(tran, (char *)fname);
  210.86 +      if (ret == 3)
  210.87 +         ret = 0;
  210.88 +      else if (ret == 4)
  210.89 +         ret = 1;
  210.90 +      return ret;
  210.91 +}
  210.92 +
  210.93 +void glp_mpl_build_prob(glp_tran *tran, glp_prob *prob)
  210.94 +{     /* build LP/MIP problem instance from the model */
  210.95 +      int m, n, i, j, t, kind, type, len, *ind;
  210.96 +      double lb, ub, *val;
  210.97 +      if (tran->phase != 3)
  210.98 +         xerror("glp_mpl_build_prob: invalid call sequence\n");
  210.99 +      /* erase the problem object */
 210.100 +      glp_erase_prob(prob);
 210.101 +      /* set problem name */
 210.102 +      glp_set_prob_name(prob, mpl_get_prob_name(tran));
 210.103 +      /* build rows (constraints) */
 210.104 +      m = mpl_get_num_rows(tran);
 210.105 +      if (m > 0)
 210.106 +         glp_add_rows(prob, m);
 210.107 +      for (i = 1; i <= m; i++)
 210.108 +      {  /* set row name */
 210.109 +         glp_set_row_name(prob, i, mpl_get_row_name(tran, i));
 210.110 +         /* set row bounds */
 210.111 +         type = mpl_get_row_bnds(tran, i, &lb, &ub);
 210.112 +         switch (type)
 210.113 +         {  case MPL_FR: type = GLP_FR; break;
 210.114 +            case MPL_LO: type = GLP_LO; break;
 210.115 +            case MPL_UP: type = GLP_UP; break;
 210.116 +            case MPL_DB: type = GLP_DB; break;
 210.117 +            case MPL_FX: type = GLP_FX; break;
 210.118 +            default: xassert(type != type);
 210.119 +         }
 210.120 +         if (type == GLP_DB && fabs(lb - ub) < 1e-9 * (1.0 + fabs(lb)))
 210.121 +         {  type = GLP_FX;
 210.122 +            if (fabs(lb) <= fabs(ub)) ub = lb; else lb = ub;
 210.123 +         }
 210.124 +         glp_set_row_bnds(prob, i, type, lb, ub);
 210.125 +         /* warn about non-zero constant term */
 210.126 +         if (mpl_get_row_c0(tran, i) != 0.0)
 210.127 +            xprintf("glp_mpl_build_prob: row %s; constant term %.12g ig"
 210.128 +               "nored\n",
 210.129 +               mpl_get_row_name(tran, i), mpl_get_row_c0(tran, i));
 210.130 +      }
 210.131 +      /* build columns (variables) */
 210.132 +      n = mpl_get_num_cols(tran);
 210.133 +      if (n > 0)
 210.134 +         glp_add_cols(prob, n);
 210.135 +      for (j = 1; j <= n; j++)
 210.136 +      {  /* set column name */
 210.137 +         glp_set_col_name(prob, j, mpl_get_col_name(tran, j));
 210.138 +         /* set column kind */
 210.139 +         kind = mpl_get_col_kind(tran, j);
 210.140 +         switch (kind)
 210.141 +         {  case MPL_NUM:
 210.142 +               break;
 210.143 +            case MPL_INT:
 210.144 +            case MPL_BIN:
 210.145 +               glp_set_col_kind(prob, j, GLP_IV);
 210.146 +               break;
 210.147 +            default:
 210.148 +               xassert(kind != kind);
 210.149 +         }
 210.150 +         /* set column bounds */
 210.151 +         type = mpl_get_col_bnds(tran, j, &lb, &ub);
 210.152 +         switch (type)
 210.153 +         {  case MPL_FR: type = GLP_FR; break;
 210.154 +            case MPL_LO: type = GLP_LO; break;
 210.155 +            case MPL_UP: type = GLP_UP; break;
 210.156 +            case MPL_DB: type = GLP_DB; break;
 210.157 +            case MPL_FX: type = GLP_FX; break;
 210.158 +            default: xassert(type != type);
 210.159 +         }
 210.160 +         if (kind == MPL_BIN)
 210.161 +         {  if (type == GLP_FR || type == GLP_UP || lb < 0.0) lb = 0.0;
 210.162 +            if (type == GLP_FR || type == GLP_LO || ub > 1.0) ub = 1.0;
 210.163 +            type = GLP_DB;
 210.164 +         }
 210.165 +         if (type == GLP_DB && fabs(lb - ub) < 1e-9 * (1.0 + fabs(lb)))
 210.166 +         {  type = GLP_FX;
 210.167 +            if (fabs(lb) <= fabs(ub)) ub = lb; else lb = ub;
 210.168 +         }
 210.169 +         glp_set_col_bnds(prob, j, type, lb, ub);
 210.170 +      }
 210.171 +      /* load the constraint matrix */
 210.172 +      ind = xcalloc(1+n, sizeof(int));
 210.173 +      val = xcalloc(1+n, sizeof(double));
 210.174 +      for (i = 1; i <= m; i++)
 210.175 +      {  len = mpl_get_mat_row(tran, i, ind, val);
 210.176 +         glp_set_mat_row(prob, i, len, ind, val);
 210.177 +      }
 210.178 +      /* build objective function (the first objective is used) */
 210.179 +      for (i = 1; i <= m; i++)
 210.180 +      {  kind = mpl_get_row_kind(tran, i);
 210.181 +         if (kind == MPL_MIN || kind == MPL_MAX)
 210.182 +         {  /* set objective name */
 210.183 +            glp_set_obj_name(prob, mpl_get_row_name(tran, i));
 210.184 +            /* set optimization direction */
 210.185 +            glp_set_obj_dir(prob, kind == MPL_MIN ? GLP_MIN : GLP_MAX);
 210.186 +            /* set constant term */
 210.187 +            glp_set_obj_coef(prob, 0, mpl_get_row_c0(tran, i));
 210.188 +            /* set objective coefficients */
 210.189 +            len = mpl_get_mat_row(tran, i, ind, val);
 210.190 +            for (t = 1; t <= len; t++)
 210.191 +               glp_set_obj_coef(prob, ind[t], val[t]);
 210.192 +            break;
 210.193 +         }
 210.194 +      }
 210.195 +      /* free working arrays */
 210.196 +      xfree(ind);
 210.197 +      xfree(val);
 210.198 +      return;
 210.199 +}
 210.200 +
 210.201 +int glp_mpl_postsolve(glp_tran *tran, glp_prob *prob, int sol)
 210.202 +{     /* postsolve the model */
 210.203 +      int i, j, m, n, stat, ret;
 210.204 +      double prim, dual;
 210.205 +      if (!(tran->phase == 3 && !tran->flag_p))
 210.206 +         xerror("glp_mpl_postsolve: invalid call sequence\n");
 210.207 +      if (!(sol == GLP_SOL || sol == GLP_IPT || sol == GLP_MIP))
 210.208 +         xerror("glp_mpl_postsolve: sol = %d; invalid parameter\n",
 210.209 +            sol);
 210.210 +      m = mpl_get_num_rows(tran);
 210.211 +      n = mpl_get_num_cols(tran);
 210.212 +      if (!(m == glp_get_num_rows(prob) &&
 210.213 +            n == glp_get_num_cols(prob)))
 210.214 +         xerror("glp_mpl_postsolve: wrong problem object\n");
 210.215 +      if (!mpl_has_solve_stmt(tran))
 210.216 +      {  ret = 0;
 210.217 +         goto done;
 210.218 +      }
 210.219 +      for (i = 1; i <= m; i++)
 210.220 +      {  if (sol == GLP_SOL)
 210.221 +         {  stat = glp_get_row_stat(prob, i);
 210.222 +            prim = glp_get_row_prim(prob, i);
 210.223 +            dual = glp_get_row_dual(prob, i);
 210.224 +         }
 210.225 +         else if (sol == GLP_IPT)
 210.226 +         {  stat = 0;
 210.227 +            prim = glp_ipt_row_prim(prob, i);
 210.228 +            dual = glp_ipt_row_dual(prob, i);
 210.229 +         }
 210.230 +         else if (sol == GLP_MIP)
 210.231 +         {  stat = 0;
 210.232 +            prim = glp_mip_row_val(prob, i);
 210.233 +            dual = 0.0;
 210.234 +         }
 210.235 +         else
 210.236 +            xassert(sol != sol);
 210.237 +         if (fabs(prim) < 1e-9) prim = 0.0;
 210.238 +         if (fabs(dual) < 1e-9) dual = 0.0;
 210.239 +         mpl_put_row_soln(tran, i, stat, prim, dual);
 210.240 +      }
 210.241 +      for (j = 1; j <= n; j++)
 210.242 +      {  if (sol == GLP_SOL)
 210.243 +         {  stat = glp_get_col_stat(prob, j);
 210.244 +            prim = glp_get_col_prim(prob, j);
 210.245 +            dual = glp_get_col_dual(prob, j);
 210.246 +         }
 210.247 +         else if (sol == GLP_IPT)
 210.248 +         {  stat = 0;
 210.249 +            prim = glp_ipt_col_prim(prob, j);
 210.250 +            dual = glp_ipt_col_dual(prob, j);
 210.251 +         }
 210.252 +         else if (sol == GLP_MIP)
 210.253 +         {  stat = 0;
 210.254 +            prim = glp_mip_col_val(prob, j);
 210.255 +            dual = 0.0;
 210.256 +         }
 210.257 +         else
 210.258 +            xassert(sol != sol);
 210.259 +         if (fabs(prim) < 1e-9) prim = 0.0;
 210.260 +         if (fabs(dual) < 1e-9) dual = 0.0;
 210.261 +         mpl_put_col_soln(tran, j, stat, prim, dual);
 210.262 +      }
 210.263 +      ret = mpl_postsolve(tran);
 210.264 +      if (ret == 3)
 210.265 +         ret = 0;
 210.266 +      else if (ret == 4)
 210.267 +         ret = 1;
 210.268 +done: return ret;
 210.269 +}
 210.270 +
 210.271 +void glp_mpl_free_wksp(glp_tran *tran)
 210.272 +{     /* free the MathProg translator workspace */
 210.273 +      mpl_terminate(tran);
 210.274 +      return;
 210.275 +}
 210.276 +
 210.277 +/* eof */
   211.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
   211.2 +++ b/deps/glpk/src/glpapi15.c	Sun Nov 06 20:59:10 2011 +0100
   211.3 @@ -0,0 +1,609 @@
   211.4 +/* glpapi15.c (basic graph and network routines) */
   211.5 +
   211.6 +/***********************************************************************
   211.7 +*  This code is part of GLPK (GNU Linear Programming Kit).
   211.8 +*
   211.9 +*  Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008,
  211.10 +*  2009, 2010, 2011 Andrew Makhorin, Department for Applied Informatics,
  211.11 +*  Moscow Aviation Institute, Moscow, Russia. All rights reserved.
  211.12 +*  E-mail: <mao@gnu.org>.
  211.13 +*
  211.14 +*  GLPK is free software: you can redistribute it and/or modify it
  211.15 +*  under the terms of the GNU General Public License as published by
  211.16 +*  the Free Software Foundation, either version 3 of the License, or
  211.17 +*  (at your option) any later version.
  211.18 +*
  211.19 +*  GLPK is distributed in the hope that it will be useful, but WITHOUT
  211.20 +*  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
  211.21 +*  or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
  211.22 +*  License for more details.
  211.23 +*
  211.24 +*  You should have received a copy of the GNU General Public License
  211.25 +*  along with GLPK. If not, see <http://www.gnu.org/licenses/>.
  211.26 +***********************************************************************/
  211.27 +
  211.28 +#include "glpapi.h"
  211.29 +
  211.30 +/* CAUTION: DO NOT CHANGE THE LIMITS BELOW */
  211.31 +
  211.32 +#define NV_MAX 100000000 /* = 100*10^6 */
  211.33 +/* maximal number of vertices in the graph */
  211.34 +
  211.35 +#define NA_MAX 500000000 /* = 500*10^6 */
  211.36 +/* maximal number of arcs in the graph */
  211.37 +
  211.38 +/***********************************************************************
  211.39 +*  NAME
  211.40 +*
  211.41 +*  glp_create_graph - create graph
  211.42 +*
  211.43 +*  SYNOPSIS
  211.44 +*
  211.45 +*  glp_graph *glp_create_graph(int v_size, int a_size);
  211.46 +*
  211.47 +*  DESCRIPTION
  211.48 +*
  211.49 +*  The routine creates a new graph, which initially is empty, i.e. has
  211.50 +*  no vertices and arcs.
  211.51 +*
  211.52 +*  The parameter v_size specifies the size of data associated with each
  211.53 +*  vertex of the graph (0 to 256 bytes).
  211.54 +*
  211.55 +*  The parameter a_size specifies the size of data associated with each
  211.56 +*  arc of the graph (0 to 256 bytes).
  211.57 +*
  211.58 +*  RETURNS
  211.59 +*
  211.60 +*  The routine returns a pointer to the graph created. */
  211.61 +
  211.62 +static void create_graph(glp_graph *G, int v_size, int a_size)
  211.63 +{     G->pool = dmp_create_pool();
  211.64 +      G->name = NULL;
  211.65 +      G->nv_max = 50;
  211.66 +      G->nv = G->na = 0;
  211.67 +      G->v = xcalloc(1+G->nv_max, sizeof(glp_vertex *));
  211.68 +      G->index = NULL;
  211.69 +      G->v_size = v_size;
  211.70 +      G->a_size = a_size;
  211.71 +      return;
  211.72 +}
  211.73 +
  211.74 +glp_graph *glp_create_graph(int v_size, int a_size)
  211.75 +{     glp_graph *G;
  211.76 +      if (!(0 <= v_size && v_size <= 256))
  211.77 +         xerror("glp_create_graph: v_size = %d; invalid size of vertex "
  211.78 +            "data\n", v_size);
  211.79 +      if (!(0 <= a_size && a_size <= 256))
  211.80 +         xerror("glp_create_graph: a_size = %d; invalid size of arc dat"
  211.81 +            "a\n", a_size);
  211.82 +      G = xmalloc(sizeof(glp_graph));
  211.83 +      create_graph(G, v_size, a_size);
  211.84 +      return G;
  211.85 +}
  211.86 +
  211.87 +/***********************************************************************
  211.88 +*  NAME
  211.89 +*
  211.90 +*  glp_set_graph_name - assign (change) graph name
  211.91 +*
  211.92 +*  SYNOPSIS
  211.93 +*
  211.94 +*  void glp_set_graph_name(glp_graph *G, const char *name);
  211.95 +*
  211.96 +*  DESCRIPTION
  211.97 +*
  211.98 +*  The routine glp_set_graph_name assigns a symbolic name specified by
  211.99 +*  the character string name (1 to 255 chars) to the graph.
 211.100 +*
 211.101 +*  If the parameter name is NULL or an empty string, the routine erases
 211.102 +*  the existing symbolic name of the graph. */
 211.103 +
 211.104 +void glp_set_graph_name(glp_graph *G, const char *name)
 211.105 +{     if (G->name != NULL)
 211.106 +      {  dmp_free_atom(G->pool, G->name, strlen(G->name)+1);
 211.107 +         G->name = NULL;
 211.108 +      }
 211.109 +      if (!(name == NULL || name[0] == '\0'))
 211.110 +      {  int j;
 211.111 +         for (j = 0; name[j] != '\0'; j++)
 211.112 +         {  if (j == 256)
 211.113 +               xerror("glp_set_graph_name: graph name too long\n");
 211.114 +            if (iscntrl((unsigned char)name[j]))
 211.115 +               xerror("glp_set_graph_name: graph name contains invalid "
 211.116 +                  "character(s)\n");
 211.117 +         }
 211.118 +         G->name = dmp_get_atom(G->pool, strlen(name)+1);
 211.119 +         strcpy(G->name, name);
 211.120 +      }
 211.121 +      return;
 211.122 +}
 211.123 +
 211.124 +/***********************************************************************
 211.125 +*  NAME
 211.126 +*
 211.127 +*  glp_add_vertices - add new vertices to graph
 211.128 +*
 211.129 +*  SYNOPSIS
 211.130 +*
 211.131 +*  int glp_add_vertices(glp_graph *G, int nadd);
 211.132 +*
 211.133 +*  DESCRIPTION
 211.134 +*
 211.135 +*  The routine glp_add_vertices adds nadd vertices to the specified
 211.136 +*  graph. New vertices are always added to the end of the vertex list,
 211.137 +*  so ordinal numbers of existing vertices remain unchanged.
 211.138 +*
 211.139 +*  Being added each new vertex is isolated (has no incident arcs).
 211.140 +*
 211.141 +*  RETURNS
 211.142 +*
 211.143 +*  The routine glp_add_vertices returns an ordinal number of the first
 211.144 +*  new vertex added to the graph. */
 211.145 +
 211.146 +int glp_add_vertices(glp_graph *G, int nadd)
 211.147 +{     int i, nv_new;
 211.148 +      if (nadd < 1)
 211.149 +         xerror("glp_add_vertices: nadd = %d; invalid number of vertice"
 211.150 +            "s\n", nadd);
 211.151 +      if (nadd > NV_MAX - G->nv)
 211.152 +         xerror("glp_add_vertices: nadd = %d; too many vertices\n",
 211.153 +            nadd);
 211.154 +      /* determine new number of vertices */
 211.155 +      nv_new = G->nv + nadd;
 211.156 +      /* increase the room, if necessary */
 211.157 +      if (G->nv_max < nv_new)
 211.158 +      {  glp_vertex **save = G->v;
 211.159 +         while (G->nv_max < nv_new)
 211.160 +         {  G->nv_max += G->nv_max;
 211.161 +            xassert(G->nv_max > 0);
 211.162 +         }
 211.163 +         G->v = xcalloc(1+G->nv_max, sizeof(glp_vertex *));
 211.164 +         memcpy(&G->v[1], &save[1], G->nv * sizeof(glp_vertex *));
 211.165 +         xfree(save);
 211.166 +      }
 211.167 +      /* add new vertices to the end of the vertex list */
 211.168 +      for (i = G->nv+1; i <= nv_new; i++)
 211.169 +      {  glp_vertex *v;
 211.170 +         G->v[i] = v = dmp_get_atom(G->pool, sizeof(glp_vertex));
 211.171 +         v->i = i;
 211.172 +         v->name = NULL;
 211.173 +         v->entry = NULL;
 211.174 +         if (G->v_size == 0)
 211.175 +            v->data = NULL;
 211.176 +         else
 211.177 +         {  v->data = dmp_get_atom(G->pool, G->v_size);
 211.178 +            memset(v->data, 0, G->v_size);
 211.179 +         }
 211.180 +         v->temp = NULL;
 211.181 +         v->in = v->out = NULL;
 211.182 +      }
 211.183 +      /* set new number of vertices */
 211.184 +      G->nv = nv_new;
 211.185 +      /* return the ordinal number of the first vertex added */
 211.186 +      return nv_new - nadd + 1;
 211.187 +}
 211.188 +
 211.189 +/**********************************************************************/
 211.190 +
 211.191 +void glp_set_vertex_name(glp_graph *G, int i, const char *name)
 211.192 +{     /* assign (change) vertex name */
 211.193 +      glp_vertex *v;
 211.194 +      if (!(1 <= i && i <= G->nv))
 211.195 +         xerror("glp_set_vertex_name: i = %d; vertex number out of rang"
 211.196 +            "e\n", i);
 211.197 +      v = G->v[i];
 211.198 +      if (v->name != NULL)
 211.199 +      {  if (v->entry != NULL)
 211.200 +         {  xassert(G->index != NULL);
 211.201 +            avl_delete_node(G->index, v->entry);
 211.202 +            v->entry = NULL;
 211.203 +         }
 211.204 +         dmp_free_atom(G->pool, v->name, strlen(v->name)+1);
 211.205 +         v->name = NULL;
 211.206 +      }
 211.207 +      if (!(name == NULL || name[0] == '\0'))
 211.208 +      {  int k;
 211.209 +         for (k = 0; name[k] != '\0'; k++)
 211.210 +         {  if (k == 256)
 211.211 +               xerror("glp_set_vertex_name: i = %d; vertex name too lon"
 211.212 +                  "g\n", i);
 211.213 +            if (iscntrl((unsigned char)name[k]))
 211.214 +               xerror("glp_set_vertex_name: i = %d; vertex name contain"
 211.215 +                  "s invalid character(s)\n", i);
 211.216 +         }
 211.217 +         v->name = dmp_get_atom(G->pool, strlen(name)+1);
 211.218 +         strcpy(v->name, name);
 211.219 +         if (G->index != NULL)
 211.220 +         {  xassert(v->entry == NULL);
 211.221 +            v->entry = avl_insert_node(G->index, v->name);
 211.222 +            avl_set_node_link(v->entry, v);
 211.223 +         }
 211.224 +      }
 211.225 +      return;
 211.226 +}
 211.227 +
 211.228 +/***********************************************************************
 211.229 +*  NAME
 211.230 +*
 211.231 +*  glp_add_arc - add new arc to graph
 211.232 +*
 211.233 +*  SYNOPSIS
 211.234 +*
 211.235 +*  glp_arc *glp_add_arc(glp_graph *G, int i, int j);
 211.236 +*
 211.237 +*  DESCRIPTION
 211.238 +*
 211.239 +*  The routine glp_add_arc adds a new arc to the specified graph.
 211.240 +*
 211.241 +*  The parameters i and j specify the ordinal numbers of, resp., tail
 211.242 +*  and head vertices of the arc. Note that self-loops and multiple arcs
 211.243 +*  are allowed.
 211.244 +*
 211.245 +*  RETURNS
 211.246 +*
 211.247 +*  The routine glp_add_arc returns a pointer to the arc added. */
 211.248 +
 211.249 +glp_arc *glp_add_arc(glp_graph *G, int i, int j)
 211.250 +{     glp_arc *a;
 211.251 +      if (!(1 <= i && i <= G->nv))
 211.252 +         xerror("glp_add_arc: i = %d; tail vertex number out of range\n"
 211.253 +            , i);
 211.254 +      if (!(1 <= j && j <= G->nv))
 211.255 +         xerror("glp_add_arc: j = %d; head vertex number out of range\n"
 211.256 +            , j);
 211.257 +      if (G->na == NA_MAX)
 211.258 +         xerror("glp_add_arc: too many arcs\n");
 211.259 +      a = dmp_get_atom(G->pool, sizeof(glp_arc));
 211.260 +      a->tail = G->v[i];
 211.261 +      a->head = G->v[j];
 211.262 +      if (G->a_size == 0)
 211.263 +         a->data = NULL;
 211.264 +      else
 211.265 +      {  a->data = dmp_get_atom(G->pool, G->a_size);
 211.266 +         memset(a->data, 0, G->a_size);
 211.267 +      }
 211.268 +      a->temp = NULL;
 211.269 +      a->t_prev = NULL;
 211.270 +      a->t_next = G->v[i]->out;
 211.271 +      if (a->t_next != NULL) a->t_next->t_prev = a;
 211.272 +      a->h_prev = NULL;
 211.273 +      a->h_next = G->v[j]->in;
 211.274 +      if (a->h_next != NULL) a->h_next->h_prev = a;
 211.275 +      G->v[i]->out = G->v[j]->in = a;
 211.276 +      G->na++;
 211.277 +      return a;
 211.278 +}
 211.279 +
 211.280 +/***********************************************************************
 211.281 +*  NAME
 211.282 +*
 211.283 +*  glp_del_vertices - delete vertices from graph
 211.284 +*
 211.285 +*  SYNOPSIS
 211.286 +*
 211.287 +*  void glp_del_vertices(glp_graph *G, int ndel, const int num[]);
 211.288 +*
 211.289 +*  DESCRIPTION
 211.290 +*
 211.291 +*  The routine glp_del_vertices deletes vertices along with all
 211.292 +*  incident arcs from the specified graph. Ordinal numbers of vertices
 211.293 +*  to be deleted should be placed in locations num[1], ..., num[ndel],
 211.294 +*  ndel > 0.
 211.295 +*
 211.296 +*  Note that deleting vertices involves changing ordinal numbers of
 211.297 +*  other vertices remaining in the graph. New ordinal numbers of the
 211.298 +*  remaining vertices are assigned under the assumption that the
 211.299 +*  original order of vertices is not changed. */
 211.300 +
 211.301 +void glp_del_vertices(glp_graph *G, int ndel, const int num[])
 211.302 +{     glp_vertex *v;
 211.303 +      int i, k, nv_new;
 211.304 +      /* scan the list of vertices to be deleted */
 211.305 +      if (!(1 <= ndel && ndel <= G->nv))
 211.306 +         xerror("glp_del_vertices: ndel = %d; invalid number of vertice"
 211.307 +            "s\n", ndel);
 211.308 +      for (k = 1; k <= ndel; k++)
 211.309 +      {  /* take the number of vertex to be deleted */
 211.310 +         i = num[k];
 211.311 +         /* obtain pointer to i-th vertex */
 211.312 +         if (!(1 <= i && i <= G->nv))
 211.313 +            xerror("glp_del_vertices: num[%d] = %d; vertex number out o"
 211.314 +               "f range\n", k, i);
 211.315 +         v = G->v[i];
 211.316 +         /* check that the vertex is not marked yet */
 211.317 +         if (v->i == 0)
 211.318 +            xerror("glp_del_vertices: num[%d] = %d; duplicate vertex nu"
 211.319 +               "mbers not allowed\n", k, i);
 211.320 +         /* erase symbolic name assigned to the vertex */
 211.321 +         glp_set_vertex_name(G, i, NULL);
 211.322 +         xassert(v->name == NULL);
 211.323 +         xassert(v->entry == NULL);
 211.324 +         /* free vertex data, if allocated */
 211.325 +         if (v->data != NULL)
 211.326 +            dmp_free_atom(G->pool, v->data, G->v_size);
 211.327 +         /* delete all incoming arcs */
 211.328 +         while (v->in != NULL)
 211.329 +            glp_del_arc(G, v->in);
 211.330 +         /* delete all outgoing arcs */
 211.331 +         while (v->out != NULL)
 211.332 +            glp_del_arc(G, v->out);
 211.333 +         /* mark the vertex to be deleted */
 211.334 +         v->i = 0;
 211.335 +      }
 211.336 +      /* delete all marked vertices from the vertex list */
 211.337 +      nv_new = 0;
 211.338 +      for (i = 1; i <= G->nv; i++)
 211.339 +      {  /* obtain pointer to i-th vertex */
 211.340 +         v = G->v[i];
 211.341 +         /* check if the vertex is marked */
 211.342 +         if (v->i == 0)
 211.343 +         {  /* it is marked, delete it */
 211.344 +            dmp_free_atom(G->pool, v, sizeof(glp_vertex));
 211.345 +         }
 211.346 +         else
 211.347 +         {  /* it is not marked, keep it */
 211.348 +            v->i = ++nv_new;
 211.349 +            G->v[v->i] = v;
 211.350 +         }
 211.351 +      }
 211.352 +      /* set new number of vertices in the graph */
 211.353 +      G->nv = nv_new;
 211.354 +      return;
 211.355 +}
 211.356 +
 211.357 +/***********************************************************************
 211.358 +*  NAME
 211.359 +*
 211.360 +*  glp_del_arc - delete arc from graph
 211.361 +*
 211.362 +*  SYNOPSIS
 211.363 +*
 211.364 +*  void glp_del_arc(glp_graph *G, glp_arc *a);
 211.365 +*
 211.366 +*  DESCRIPTION
 211.367 +*
 211.368 +*  The routine glp_del_arc deletes an arc from the specified graph.
 211.369 +*  The arc to be deleted must exist. */
 211.370 +
 211.371 +void glp_del_arc(glp_graph *G, glp_arc *a)
 211.372 +{     /* some sanity checks */
 211.373 +      xassert(G->na > 0);
 211.374 +      xassert(1 <= a->tail->i && a->tail->i <= G->nv);
 211.375 +      xassert(a->tail == G->v[a->tail->i]);
 211.376 +      xassert(1 <= a->head->i && a->head->i <= G->nv);
 211.377 +      xassert(a->head == G->v[a->head->i]);
 211.378 +      /* remove the arc from the list of incoming arcs */
 211.379 +      if (a->h_prev == NULL)
 211.380 +         a->head->in = a->h_next;
 211.381 +      else
 211.382 +         a->h_prev->h_next = a->h_next;
 211.383 +      if (a->h_next == NULL)
 211.384 +         ;
 211.385 +      else
 211.386 +         a->h_next->h_prev = a->h_prev;
 211.387 +      /* remove the arc from the list of outgoing arcs */
 211.388 +      if (a->t_prev == NULL)
 211.389 +         a->tail->out = a->t_next;
 211.390 +      else
 211.391 +         a->t_prev->t_next = a->t_next;
 211.392 +      if (a->t_next == NULL)
 211.393 +         ;
 211.394 +      else
 211.395 +         a->t_next->t_prev = a->t_prev;
 211.396 +      /* free arc data, if allocated */
 211.397 +      if (a->data != NULL)
 211.398 +         dmp_free_atom(G->pool, a->data, G->a_size);
 211.399 +      /* delete the arc from the graph */
 211.400 +      dmp_free_atom(G->pool, a, sizeof(glp_arc));
 211.401 +      G->na--;
 211.402 +      return;
 211.403 +}
 211.404 +
 211.405 +/***********************************************************************
 211.406 +*  NAME
 211.407 +*
 211.408 +*  glp_erase_graph - erase graph content
 211.409 +*
 211.410 +*  SYNOPSIS
 211.411 +*
 211.412 +*  void glp_erase_graph(glp_graph *G, int v_size, int a_size);
 211.413 +*
 211.414 +*  DESCRIPTION
 211.415 +*
 211.416 +*  The routine glp_erase_graph erases the content of the specified
 211.417 +*  graph. The effect of this operation is the same as if the graph
 211.418 +*  would be deleted with the routine glp_delete_graph and then created
 211.419 +*  anew with the routine glp_create_graph, with exception that the
 211.420 +*  handle (pointer) to the graph remains valid. */
 211.421 +
 211.422 +static void delete_graph(glp_graph *G)
 211.423 +{     dmp_delete_pool(G->pool);
 211.424 +      xfree(G->v);
 211.425 +      if (G->index != NULL) avl_delete_tree(G->index);
 211.426 +      return;
 211.427 +}
 211.428 +
 211.429 +void glp_erase_graph(glp_graph *G, int v_size, int a_size)
 211.430 +{     if (!(0 <= v_size && v_size <= 256))
 211.431 +         xerror("glp_erase_graph: v_size = %d; invalid size of vertex d"
 211.432 +            "ata\n", v_size);
 211.433 +      if (!(0 <= a_size && a_size <= 256))
 211.434 +         xerror("glp_erase_graph: a_size = %d; invalid size of arc data"
 211.435 +            "\n", a_size);
 211.436 +      delete_graph(G);
 211.437 +      create_graph(G, v_size, a_size);
 211.438 +      return;
 211.439 +}
 211.440 +
 211.441 +/***********************************************************************
 211.442 +*  NAME
 211.443 +*
 211.444 +*  glp_delete_graph - delete graph
 211.445 +*
 211.446 +*  SYNOPSIS
 211.447 +*
 211.448 +*  void glp_delete_graph(glp_graph *G);
 211.449 +*
 211.450 +*  DESCRIPTION
 211.451 +*
 211.452 +*  The routine glp_delete_graph deletes the specified graph and frees
 211.453 +*  all the memory allocated to this program object. */
 211.454 +
 211.455 +void glp_delete_graph(glp_graph *G)
 211.456 +{     delete_graph(G);
 211.457 +      xfree(G);
 211.458 +      return;
 211.459 +}
 211.460 +
 211.461 +/**********************************************************************/
 211.462 +
 211.463 +void glp_create_v_index(glp_graph *G)
 211.464 +{     /* create vertex name index */
 211.465 +      glp_vertex *v;
 211.466 +      int i;
 211.467 +      if (G->index == NULL)
 211.468 +      {  G->index = avl_create_tree(avl_strcmp, NULL);
 211.469 +         for (i = 1; i <= G->nv; i++)
 211.470 +         {  v = G->v[i];
 211.471 +            xassert(v->entry == NULL);
 211.472 +            if (v->name != NULL)
 211.473 +            {  v->entry = avl_insert_node(G->index, v->name);
 211.474 +               avl_set_node_link(v->entry, v);
 211.475 +            }
 211.476 +         }
 211.477 +      }
 211.478 +      return;
 211.479 +}
 211.480 +
 211.481 +int glp_find_vertex(glp_graph *G, const char *name)
 211.482 +{     /* find vertex by its name */
 211.483 +      AVLNODE *node;
 211.484 +      int i = 0;
 211.485 +      if (G->index == NULL)
 211.486 +         xerror("glp_find_vertex: vertex name index does not exist\n");
 211.487 +      if (!(name == NULL || name[0] == '\0' || strlen(name) > 255))
 211.488 +      {  node = avl_find_node(G->index, name);
 211.489 +         if (node != NULL)
 211.490 +            i = ((glp_vertex *)avl_get_node_link(node))->i;
 211.491 +      }
 211.492 +      return i;
 211.493 +}
 211.494 +
 211.495 +void glp_delete_v_index(glp_graph *G)
 211.496 +{     /* delete vertex name index */
 211.497 +      int i;
 211.498 +      if (G->index != NULL)
 211.499 +      {  avl_delete_tree(G->index), G->index = NULL;
 211.500 +         for (i = 1; i <= G->nv; i++) G->v[i]->entry = NULL;
 211.501 +      }
 211.502 +      return;
 211.503 +}
 211.504 +
 211.505 +/***********************************************************************
 211.506 +*  NAME
 211.507 +*
 211.508 +*  glp_read_graph - read graph from plain text file
 211.509 +*
 211.510 +*  SYNOPSIS
 211.511 +*
 211.512 +*  int glp_read_graph(glp_graph *G, const char *fname);
 211.513 +*
 211.514 +*  DESCRIPTION
 211.515 +*
 211.516 +*  The routine glp_read_graph reads a graph from a plain text file.
 211.517 +*
 211.518 +*  RETURNS
 211.519 +*
 211.520 +*  If the operation was successful, the routine returns zero. Otherwise
 211.521 +*  it prints an error message and returns non-zero. */
 211.522 +
 211.523 +int glp_read_graph(glp_graph *G, const char *fname)
 211.524 +{     glp_data *data;
 211.525 +      jmp_buf jump;
 211.526 +      int nv, na, i, j, k, ret;
 211.527 +      glp_erase_graph(G, G->v_size, G->a_size);
 211.528 +      xprintf("Reading graph from `%s'...\n", fname);
 211.529 +      data = glp_sdf_open_file(fname);
 211.530 +      if (data == NULL)
 211.531 +      {  ret = 1;
 211.532 +         goto done;
 211.533 +      }
 211.534 +      if (setjmp(jump))
 211.535 +      {  ret = 1;
 211.536 +         goto done;
 211.537 +      }
 211.538 +      glp_sdf_set_jump(data, jump);
 211.539 +      nv = glp_sdf_read_int(data);
 211.540 +      if (nv < 0)
 211.541 +         glp_sdf_error(data, "invalid number of vertices\n");
 211.542 +      na = glp_sdf_read_int(data);
 211.543 +      if (na < 0)
 211.544 +         glp_sdf_error(data, "invalid number of arcs\n");
 211.545 +      xprintf("Graph has %d vert%s and %d arc%s\n",
 211.546 +         nv, nv == 1 ? "ex" : "ices", na, na == 1 ? "" : "s");
 211.547 +      if (nv > 0) glp_add_vertices(G, nv);
 211.548 +      for (k = 1; k <= na; k++)
 211.549 +      {  i = glp_sdf_read_int(data);
 211.550 +         if (!(1 <= i && i <= nv))
 211.551 +            glp_sdf_error(data, "tail vertex number out of range\n");
 211.552 +         j = glp_sdf_read_int(data);
 211.553 +         if (!(1 <= j && j <= nv))
 211.554 +            glp_sdf_error(data, "head vertex number out of range\n");
 211.555 +         glp_add_arc(G, i, j);
 211.556 +      }
 211.557 +      xprintf("%d lines were read\n", glp_sdf_line(data));
 211.558 +      ret = 0;
 211.559 +done: if (data != NULL) glp_sdf_close_file(data);
 211.560 +      return ret;
 211.561 +}
 211.562 +
 211.563 +/***********************************************************************
 211.564 +*  NAME
 211.565 +*
 211.566 +*  glp_write_graph - write graph to plain text file
 211.567 +*
 211.568 +*  SYNOPSIS
 211.569 +*
 211.570 +*  int glp_write_graph(glp_graph *G, const char *fname).
 211.571 +*
 211.572 +*  DESCRIPTION
 211.573 +*
 211.574 +*  The routine glp_write_graph writes the specified graph to a plain
 211.575 +*  text file.
 211.576 +*
 211.577 +*  RETURNS
 211.578 +*
 211.579 +*  If the operation was successful, the routine returns zero. Otherwise
 211.580 +*  it prints an error message and returns non-zero. */
 211.581 +
 211.582 +int glp_write_graph(glp_graph *G, const char *fname)
 211.583 +{     XFILE *fp;
 211.584 +      glp_vertex *v;
 211.585 +      glp_arc *a;
 211.586 +      int i, count, ret;
 211.587 +      xprintf("Writing graph to `%s'...\n", fname);
 211.588 +      fp = xfopen(fname, "w"), count = 0;
 211.589 +      if (fp == NULL)
 211.590 +      {  xprintf("Unable to create `%s' - %s\n", fname, xerrmsg());
 211.591 +         ret = 1;
 211.592 +         goto done;
 211.593 +      }
 211.594 +      xfprintf(fp, "%d %d\n", G->nv, G->na), count++;
 211.595 +      for (i = 1; i <= G->nv; i++)
 211.596 +      {  v = G->v[i];
 211.597 +         for (a = v->out; a != NULL; a = a->t_next)
 211.598 +            xfprintf(fp, "%d %d\n", a->tail->i, a->head->i), count++;
 211.599 +      }
 211.600 +      xfflush(fp);
 211.601 +      if (xferror(fp))
 211.602 +      {  xprintf("Write error on `%s' - %s\n", fname, xerrmsg());
 211.603 +         ret = 1;
 211.604 +         goto done;
 211.605 +      }
 211.606 +      xprintf("%d lines were written\n", count);
 211.607 +      ret = 0;
 211.608 +done: if (fp != NULL) xfclose(fp);
 211.609 +      return ret;
 211.610 +}
 211.611 +
 211.612 +/* eof */
   212.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
   212.2 +++ b/deps/glpk/src/glpapi16.c	Sun Nov 06 20:59:10 2011 +0100
   212.3 @@ -0,0 +1,329 @@
   212.4 +/* glpapi16.c (graph and network analysis routines) */
   212.5 +
   212.6 +/***********************************************************************
   212.7 +*  This code is part of GLPK (GNU Linear Programming Kit).
   212.8 +*
   212.9 +*  Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008,
  212.10 +*  2009, 2010, 2011 Andrew Makhorin, Department for Applied Informatics,
  212.11 +*  Moscow Aviation Institute, Moscow, Russia. All rights reserved.
  212.12 +*  E-mail: <mao@gnu.org>.
  212.13 +*
  212.14 +*  GLPK is free software: you can redistribute it and/or modify it
  212.15 +*  under the terms of the GNU General Public License as published by
  212.16 +*  the Free Software Foundation, either version 3 of the License, or
  212.17 +*  (at your option) any later version.
  212.18 +*
  212.19 +*  GLPK is distributed in the hope that it will be useful, but WITHOUT
  212.20 +*  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
  212.21 +*  or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
  212.22 +*  License for more details.
  212.23 +*
  212.24 +*  You should have received a copy of the GNU General Public License
  212.25 +*  along with GLPK. If not, see <http://www.gnu.org/licenses/>.
  212.26 +***********************************************************************/
  212.27 +
  212.28 +#include "glpapi.h"
  212.29 +#include "glpnet.h"
  212.30 +
  212.31 +/***********************************************************************
  212.32 +*  NAME
  212.33 +*
  212.34 +*  glp_weak_comp - find all weakly connected components of graph
  212.35 +*
  212.36 +*  SYNOPSIS
  212.37 +*
  212.38 +*  int glp_weak_comp(glp_graph *G, int v_num);
  212.39 +*
  212.40 +*  DESCRIPTION
  212.41 +*
  212.42 +*  The routine glp_weak_comp finds all weakly connected components of
  212.43 +*  the specified graph.
  212.44 +*
  212.45 +*  The parameter v_num specifies an offset of the field of type int
  212.46 +*  in the vertex data block, to which the routine stores the number of
  212.47 +*  a (weakly) connected component containing that vertex. If v_num < 0,
  212.48 +*  no component numbers are stored.
  212.49 +*
  212.50 +*  The components are numbered in arbitrary order from 1 to nc, where
  212.51 +*  nc is the total number of components found, 0 <= nc <= |V|.
  212.52 +*
  212.53 +*  RETURNS
  212.54 +*
  212.55 +*  The routine returns nc, the total number of components found. */
  212.56 +
  212.57 +int glp_weak_comp(glp_graph *G, int v_num)
  212.58 +{     glp_vertex *v;
  212.59 +      glp_arc *a;
  212.60 +      int f, i, j, nc, nv, pos1, pos2, *prev, *next, *list;
  212.61 +      if (v_num >= 0 && v_num > G->v_size - (int)sizeof(int))
  212.62 +         xerror("glp_weak_comp: v_num = %d; invalid offset\n", v_num);
  212.63 +      nv = G->nv;
  212.64 +      if (nv == 0)
  212.65 +      {  nc = 0;
  212.66 +         goto done;
  212.67 +      }
  212.68 +      /* allocate working arrays */
  212.69 +      prev = xcalloc(1+nv, sizeof(int));
  212.70 +      next = xcalloc(1+nv, sizeof(int));
  212.71 +      list = xcalloc(1+nv, sizeof(int));
  212.72 +      /* if vertex i is unlabelled, prev[i] is the index of previous
  212.73 +         unlabelled vertex, and next[i] is the index of next unlabelled
  212.74 +         vertex; if vertex i is labelled, then prev[i] < 0, and next[i]
  212.75 +         is the connected component number */
  212.76 +      /* initially all vertices are unlabelled */
  212.77 +      f = 1;
  212.78 +      for (i = 1; i <= nv; i++)
  212.79 +         prev[i] = i - 1, next[i] = i + 1;
  212.80 +      next[nv] = 0;
  212.81 +      /* main loop (until all vertices have been labelled) */
  212.82 +      nc = 0;
  212.83 +      while (f != 0)
  212.84 +      {  /* take an unlabelled vertex */
  212.85 +         i = f;
  212.86 +         /* and remove it from the list of unlabelled vertices */
  212.87 +         f = next[i];
  212.88 +         if (f != 0) prev[f] = 0;
  212.89 +         /* label the vertex; it begins a new component */
  212.90 +         prev[i] = -1, next[i] = ++nc;
  212.91 +         /* breadth first search */
  212.92 +         list[1] = i, pos1 = pos2 = 1;
  212.93 +         while (pos1 <= pos2)
  212.94 +         {  /* dequeue vertex i */
  212.95 +            i = list[pos1++];
  212.96 +            /* consider all arcs incoming to vertex i */
  212.97 +            for (a = G->v[i]->in; a != NULL; a = a->h_next)
  212.98 +            {  /* vertex j is adjacent to vertex i */
  212.99 +               j = a->tail->i;
 212.100 +               if (prev[j] >= 0)
 212.101 +               {  /* vertex j is unlabelled */
 212.102 +                  /* remove it from the list of unlabelled vertices */
 212.103 +                  if (prev[j] == 0)
 212.104 +                     f = next[j];
 212.105 +                  else
 212.106 +                     next[prev[j]] = next[j];
 212.107 +                  if (next[j] == 0)
 212.108 +                     ;
 212.109 +                  else
 212.110 +                     prev[next[j]] = prev[j];
 212.111 +                  /* label the vertex */
 212.112 +                  prev[j] = -1, next[j] = nc;
 212.113 +                  /* and enqueue it for further consideration */
 212.114 +                  list[++pos2] = j;
 212.115 +               }
 212.116 +            }
 212.117 +            /* consider all arcs outgoing from vertex i */
 212.118 +            for (a = G->v[i]->out; a != NULL; a = a->t_next)
 212.119 +            {  /* vertex j is adjacent to vertex i */
 212.120 +               j = a->head->i;
 212.121 +               if (prev[j] >= 0)
 212.122 +               {  /* vertex j is unlabelled */
 212.123 +                  /* remove it from the list of unlabelled vertices */
 212.124 +                  if (prev[j] == 0)
 212.125 +                     f = next[j];
 212.126 +                  else
 212.127 +                     next[prev[j]] = next[j];
 212.128 +                  if (next[j] == 0)
 212.129 +                     ;
 212.130 +                  else
 212.131 +                     prev[next[j]] = prev[j];
 212.132 +                  /* label the vertex */
 212.133 +                  prev[j] = -1, next[j] = nc;
 212.134 +                  /* and enqueue it for further consideration */
 212.135 +                  list[++pos2] = j;
 212.136 +               }
 212.137 +            }
 212.138 +         }
 212.139 +      }
 212.140 +      /* store component numbers */
 212.141 +      if (v_num >= 0)
 212.142 +      {  for (i = 1; i <= nv; i++)
 212.143 +         {  v = G->v[i];
 212.144 +            memcpy((char *)v->data + v_num, &next[i], sizeof(int));
 212.145 +         }
 212.146 +      }
 212.147 +      /* free working arrays */
 212.148 +      xfree(prev);
 212.149 +      xfree(next);
 212.150 +      xfree(list);
 212.151 +done: return nc;
 212.152 +}
 212.153 +
 212.154 +/***********************************************************************
 212.155 +*  NAME
 212.156 +*
 212.157 +*  glp_strong_comp - find all strongly connected components of graph
 212.158 +*
 212.159 +*  SYNOPSIS
 212.160 +*
 212.161 +*  int glp_strong_comp(glp_graph *G, int v_num);
 212.162 +*
 212.163 +*  DESCRIPTION
 212.164 +*
 212.165 +*  The routine glp_strong_comp finds all strongly connected components
 212.166 +*  of the specified graph.
 212.167 +*
 212.168 +*  The parameter v_num specifies an offset of the field of type int
 212.169 +*  in the vertex data block, to which the routine stores the number of
 212.170 +*  a strongly connected component containing that vertex. If v_num < 0,
 212.171 +*  no component numbers are stored.
 212.172 +*
 212.173 +*  The components are numbered in arbitrary order from 1 to nc, where
 212.174 +*  nc is the total number of components found, 0 <= nc <= |V|. However,
 212.175 +*  the component numbering has the property that for every arc (i->j)
 212.176 +*  in the graph the condition num(i) >= num(j) holds.
 212.177 +*
 212.178 +*  RETURNS
 212.179 +*
 212.180 +*  The routine returns nc, the total number of components found. */
 212.181 +
 212.182 +int glp_strong_comp(glp_graph *G, int v_num)
 212.183 +{     glp_vertex *v;
 212.184 +      glp_arc *a;
 212.185 +      int i, k, last, n, na, nc, *icn, *ip, *lenr, *ior, *ib, *lowl,
 212.186 +         *numb, *prev;
 212.187 +      if (v_num >= 0 && v_num > G->v_size - (int)sizeof(int))
 212.188 +         xerror("glp_strong_comp: v_num = %d; invalid offset\n",
 212.189 +            v_num);
 212.190 +      n = G->nv;
 212.191 +      if (n == 0)
 212.192 +      {  nc = 0;
 212.193 +         goto done;
 212.194 +      }
 212.195 +      na = G->na;
 212.196 +      icn = xcalloc(1+na, sizeof(int));
 212.197 +      ip = xcalloc(1+n, sizeof(int));
 212.198 +      lenr = xcalloc(1+n, sizeof(int));
 212.199 +      ior = xcalloc(1+n, sizeof(int));
 212.200 +      ib = xcalloc(1+n, sizeof(int));
 212.201 +      lowl = xcalloc(1+n, sizeof(int));
 212.202 +      numb = xcalloc(1+n, sizeof(int));
 212.203 +      prev = xcalloc(1+n, sizeof(int));
 212.204 +      k = 1;
 212.205 +      for (i = 1; i <= n; i++)
 212.206 +      {  v = G->v[i];
 212.207 +         ip[i] = k;
 212.208 +         for (a = v->out; a != NULL; a = a->t_next)
 212.209 +            icn[k++] = a->head->i;
 212.210 +         lenr[i] = k - ip[i];
 212.211 +      }
 212.212 +      xassert(na == k-1);
 212.213 +      nc = mc13d(n, icn, ip, lenr, ior, ib, lowl, numb, prev);
 212.214 +      if (v_num >= 0)
 212.215 +      {  xassert(ib[1] == 1);
 212.216 +         for (k = 1; k <= nc; k++)
 212.217 +         {  last = (k < nc ? ib[k+1] : n+1);
 212.218 +            xassert(ib[k] < last);
 212.219 +            for (i = ib[k]; i < last; i++)
 212.220 +            {  v = G->v[ior[i]];
 212.221 +               memcpy((char *)v->data + v_num, &k, sizeof(int));
 212.222 +            }
 212.223 +         }
 212.224 +      }
 212.225 +      xfree(icn);
 212.226 +      xfree(ip);
 212.227 +      xfree(lenr);
 212.228 +      xfree(ior);
 212.229 +      xfree(ib);
 212.230 +      xfree(lowl);
 212.231 +      xfree(numb);
 212.232 +      xfree(prev);
 212.233 +done: return nc;
 212.234 +}
 212.235 +
 212.236 +/***********************************************************************
 212.237 +*  NAME
 212.238 +*
 212.239 +*  glp_top_sort - topological sorting of acyclic digraph
 212.240 +*
 212.241 +*  SYNOPSIS
 212.242 +*
 212.243 +*  int glp_top_sort(glp_graph *G, int v_num);
 212.244 +*
 212.245 +*  DESCRIPTION
 212.246 +*
 212.247 +*  The routine glp_top_sort performs topological sorting of vertices of
 212.248 +*  the specified acyclic digraph.
 212.249 +*
 212.250 +*  The parameter v_num specifies an offset of the field of type int in
 212.251 +*  the vertex data block, to which the routine stores the vertex number
 212.252 +*  assigned. If v_num < 0, vertex numbers are not stored.
 212.253 +*
 212.254 +*  The vertices are numbered from 1 to n, where n is the total number
 212.255 +*  of vertices in the graph. The vertex numbering has the property that
 212.256 +*  for every arc (i->j) in the graph the condition num(i) < num(j)
 212.257 +*  holds. Special case num(i) = 0 means that vertex i is not assigned a
 212.258 +*  number, because the graph is *not* acyclic.
 212.259 +*
 212.260 +*  RETURNS
 212.261 +*
 212.262 +*  If the graph is acyclic and therefore all the vertices have been
 212.263 +*  assigned numbers, the routine glp_top_sort returns zero. Otherwise,
 212.264 +*  if the graph is not acyclic, the routine returns the number of
 212.265 +*  vertices which have not been numbered, i.e. for which num(i) = 0. */
 212.266 +
 212.267 +static int top_sort(glp_graph *G, int num[])
 212.268 +{     glp_arc *a;
 212.269 +      int i, j, cnt, top, *stack, *indeg;
 212.270 +      /* allocate working arrays */
 212.271 +      indeg = xcalloc(1+G->nv, sizeof(int));
 212.272 +      stack = xcalloc(1+G->nv, sizeof(int));
 212.273 +      /* determine initial indegree of each vertex; push into the stack
 212.274 +         the vertices having zero indegree */
 212.275 +      top = 0;
 212.276 +      for (i = 1; i <= G->nv; i++)
 212.277 +      {  num[i] = indeg[i] = 0;
 212.278 +         for (a = G->v[i]->in; a != NULL; a = a->h_next)
 212.279 +            indeg[i]++;
 212.280 +         if (indeg[i] == 0)
 212.281 +            stack[++top] = i;
 212.282 +      }
 212.283 +      /* assign numbers to vertices in the sorted order */
 212.284 +      cnt = 0;
 212.285 +      while (top > 0)
 212.286 +      {  /* pull vertex i from the stack */
 212.287 +         i = stack[top--];
 212.288 +         /* it has zero indegree in the current graph */
 212.289 +         xassert(indeg[i] == 0);
 212.290 +         /* so assign it a next number */
 212.291 +         xassert(num[i] == 0);
 212.292 +         num[i] = ++cnt;
 212.293 +         /* remove vertex i from the current graph, update indegree of
 212.294 +            its adjacent vertices, and push into the stack new vertices
 212.295 +            whose indegree becomes zero */
 212.296 +         for (a = G->v[i]->out; a != NULL; a = a->t_next)
 212.297 +         {  j = a->head->i;
 212.298 +            /* there exists arc (i->j) in the graph */
 212.299 +            xassert(indeg[j] > 0);
 212.300 +            indeg[j]--;
 212.301 +            if (indeg[j] == 0)
 212.302 +               stack[++top] = j;
 212.303 +         }
 212.304 +      }
 212.305 +      /* free working arrays */
 212.306 +      xfree(indeg);
 212.307 +      xfree(stack);
 212.308 +      return G->nv - cnt;
 212.309 +}
 212.310 +
 212.311 +int glp_top_sort(glp_graph *G, int v_num)
 212.312 +{     glp_vertex *v;
 212.313 +      int i, cnt, *num;
 212.314 +      if (v_num >= 0 && v_num > G->v_size - (int)sizeof(int))
 212.315 +         xerror("glp_top_sort: v_num = %d; invalid offset\n", v_num);
 212.316 +      if (G->nv == 0)
 212.317 +      {  cnt = 0;
 212.318 +         goto done;
 212.319 +      }
 212.320 +      num = xcalloc(1+G->nv, sizeof(int));
 212.321 +      cnt = top_sort(G, num);
 212.322 +      if (v_num >= 0)
 212.323 +      {  for (i = 1; i <= G->nv; i++)
 212.324 +         {  v = G->v[i];
 212.325 +            memcpy((char *)v->data + v_num, &num[i], sizeof(int));
 212.326 +         }
 212.327 +      }
 212.328 +      xfree(num);
 212.329 +done: return cnt;
 212.330 +}
 212.331 +
 212.332 +/* eof */
   213.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
   213.2 +++ b/deps/glpk/src/glpapi17.c	Sun Nov 06 20:59:10 2011 +0100
   213.3 @@ -0,0 +1,1048 @@
   213.4 +/* glpapi17.c (flow network problems) */
   213.5 +
   213.6 +/***********************************************************************
   213.7 +*  This code is part of GLPK (GNU Linear Programming Kit).
   213.8 +*
   213.9 +*  Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008,
  213.10 +*  2009, 2010, 2011 Andrew Makhorin, Department for Applied Informatics,
  213.11 +*  Moscow Aviation Institute, Moscow, Russia. All rights reserved.
  213.12 +*  E-mail: <mao@gnu.org>.
  213.13 +*
  213.14 +*  GLPK is free software: you can redistribute it and/or modify it
  213.15 +*  under the terms of the GNU General Public License as published by
  213.16 +*  the Free Software Foundation, either version 3 of the License, or
  213.17 +*  (at your option) any later version.
  213.18 +*
  213.19 +*  GLPK is distributed in the hope that it will be useful, but WITHOUT
  213.20 +*  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
  213.21 +*  or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
  213.22 +*  License for more details.
  213.23 +*
  213.24 +*  You should have received a copy of the GNU General Public License
  213.25 +*  along with GLPK. If not, see <http://www.gnu.org/licenses/>.
  213.26 +***********************************************************************/
  213.27 +
  213.28 +#include "glpapi.h"
  213.29 +#include "glpnet.h"
  213.30 +
  213.31 +/***********************************************************************
  213.32 +*  NAME
  213.33 +*
  213.34 +*  glp_mincost_lp - convert minimum cost flow problem to LP
  213.35 +*
  213.36 +*  SYNOPSIS
  213.37 +*
  213.38 +*  void glp_mincost_lp(glp_prob *lp, glp_graph *G, int names,
  213.39 +*     int v_rhs, int a_low, int a_cap, int a_cost);
  213.40 +*
  213.41 +*  DESCRIPTION
  213.42 +*
  213.43 +*  The routine glp_mincost_lp builds an LP problem, which corresponds
  213.44 +*  to the minimum cost flow problem on the specified network G. */
  213.45 +
  213.46 +void glp_mincost_lp(glp_prob *lp, glp_graph *G, int names, int v_rhs,
  213.47 +      int a_low, int a_cap, int a_cost)
  213.48 +{     glp_vertex *v;
  213.49 +      glp_arc *a;
  213.50 +      int i, j, type, ind[1+2];
  213.51 +      double rhs, low, cap, cost, val[1+2];
  213.52 +      if (!(names == GLP_ON || names == GLP_OFF))
  213.53 +         xerror("glp_mincost_lp: names = %d; invalid parameter\n",
  213.54 +            names);
  213.55 +      if (v_rhs >= 0 && v_rhs > G->v_size - (int)sizeof(double))
  213.56 +         xerror("glp_mincost_lp: v_rhs = %d; invalid offset\n", v_rhs);
  213.57 +      if (a_low >= 0 && a_low > G->a_size - (int)sizeof(double))
  213.58 +         xerror("glp_mincost_lp: a_low = %d; invalid offset\n", a_low);
  213.59 +      if (a_cap >= 0 && a_cap > G->a_size - (int)sizeof(double))
  213.60 +         xerror("glp_mincost_lp: a_cap = %d; invalid offset\n", a_cap);
  213.61 +      if (a_cost >= 0 && a_cost > G->a_size - (int)sizeof(double))
  213.62 +         xerror("glp_mincost_lp: a_cost = %d; invalid offset\n", a_cost)
  213.63 +            ;
  213.64 +      glp_erase_prob(lp);
  213.65 +      if (names) glp_set_prob_name(lp, G->name);
  213.66 +      if (G->nv > 0) glp_add_rows(lp, G->nv);
  213.67 +      for (i = 1; i <= G->nv; i++)
  213.68 +      {  v = G->v[i];
  213.69 +         if (names) glp_set_row_name(lp, i, v->name);
  213.70 +         if (v_rhs >= 0)
  213.71 +            memcpy(&rhs, (char *)v->data + v_rhs, sizeof(double));
  213.72 +         else
  213.73 +            rhs = 0.0;
  213.74 +         glp_set_row_bnds(lp, i, GLP_FX, rhs, rhs);
  213.75 +      }
  213.76 +      if (G->na > 0) glp_add_cols(lp, G->na);
  213.77 +      for (i = 1, j = 0; i <= G->nv; i++)
  213.78 +      {  v = G->v[i];
  213.79 +         for (a = v->out; a != NULL; a = a->t_next)
  213.80 +         {  j++;
  213.81 +            if (names)
  213.82 +            {  char name[50+1];
  213.83 +               sprintf(name, "x[%d,%d]", a->tail->i, a->head->i);
  213.84 +               xassert(strlen(name) < sizeof(name));
  213.85 +               glp_set_col_name(lp, j, name);
  213.86 +            }
  213.87 +            if (a->tail->i != a->head->i)
  213.88 +            {  ind[1] = a->tail->i, val[1] = +1.0;
  213.89 +               ind[2] = a->head->i, val[2] = -1.0;
  213.90 +               glp_set_mat_col(lp, j, 2, ind, val);
  213.91 +            }
  213.92 +            if (a_low >= 0)
  213.93 +               memcpy(&low, (char *)a->data + a_low, sizeof(double));
  213.94 +            else
  213.95 +               low = 0.0;
  213.96 +            if (a_cap >= 0)
  213.97 +               memcpy(&cap, (char *)a->data + a_cap, sizeof(double));
  213.98 +            else
  213.99 +               cap = 1.0;
 213.100 +            if (cap == DBL_MAX)
 213.101 +               type = GLP_LO;
 213.102 +            else if (low != cap)
 213.103 +               type = GLP_DB;
 213.104 +            else
 213.105 +               type = GLP_FX;
 213.106 +            glp_set_col_bnds(lp, j, type, low, cap);
 213.107 +            if (a_cost >= 0)
 213.108 +               memcpy(&cost, (char *)a->data + a_cost, sizeof(double));
 213.109 +            else
 213.110 +               cost = 0.0;
 213.111 +            glp_set_obj_coef(lp, j, cost);
 213.112 +         }
 213.113 +      }
 213.114 +      xassert(j == G->na);
 213.115 +      return;
 213.116 +}
 213.117 +
 213.118 +/**********************************************************************/
 213.119 +
 213.120 +int glp_mincost_okalg(glp_graph *G, int v_rhs, int a_low, int a_cap,
 213.121 +      int a_cost, double *sol, int a_x, int v_pi)
 213.122 +{     /* find minimum-cost flow with out-of-kilter algorithm */
 213.123 +      glp_vertex *v;
 213.124 +      glp_arc *a;
 213.125 +      int nv, na, i, k, s, t, *tail, *head, *low, *cap, *cost, *x, *pi,
 213.126 +         ret;
 213.127 +      double sum, temp;
 213.128 +      if (v_rhs >= 0 && v_rhs > G->v_size - (int)sizeof(double))
 213.129 +         xerror("glp_mincost_okalg: v_rhs = %d; invalid offset\n",
 213.130 +            v_rhs);
 213.131 +      if (a_low >= 0 && a_low > G->a_size - (int)sizeof(double))
 213.132 +         xerror("glp_mincost_okalg: a_low = %d; invalid offset\n",
 213.133 +            a_low);
 213.134 +      if (a_cap >= 0 && a_cap > G->a_size - (int)sizeof(double))
 213.135 +         xerror("glp_mincost_okalg: a_cap = %d; invalid offset\n",
 213.136 +            a_cap);
 213.137 +      if (a_cost >= 0 && a_cost > G->a_size - (int)sizeof(double))
 213.138 +         xerror("glp_mincost_okalg: a_cost = %d; invalid offset\n",
 213.139 +            a_cost);
 213.140 +      if (a_x >= 0 && a_x > G->a_size - (int)sizeof(double))
 213.141 +         xerror("glp_mincost_okalg: a_x = %d; invalid offset\n", a_x);
 213.142 +      if (v_pi >= 0 && v_pi > G->v_size - (int)sizeof(double))
 213.143 +         xerror("glp_mincost_okalg: v_pi = %d; invalid offset\n", v_pi);
 213.144 +      /* s is artificial source node */
 213.145 +      s = G->nv + 1;
 213.146 +      /* t is artificial sink node */
 213.147 +      t = s + 1;
 213.148 +      /* nv is the total number of nodes in the resulting network */
 213.149 +      nv = t;
 213.150 +      /* na is the total number of arcs in the resulting network */
 213.151 +      na = G->na + 1;
 213.152 +      for (i = 1; i <= G->nv; i++)
 213.153 +      {  v = G->v[i];
 213.154 +         if (v_rhs >= 0)
 213.155 +            memcpy(&temp, (char *)v->data + v_rhs, sizeof(double));
 213.156 +         else
 213.157 +            temp = 0.0;
 213.158 +         if (temp != 0.0) na++;
 213.159 +      }
 213.160 +      /* allocate working arrays */
 213.161 +      tail = xcalloc(1+na, sizeof(int));
 213.162 +      head = xcalloc(1+na, sizeof(int));
 213.163 +      low = xcalloc(1+na, sizeof(int));
 213.164 +      cap = xcalloc(1+na, sizeof(int));
 213.165 +      cost = xcalloc(1+na, sizeof(int));
 213.166 +      x = xcalloc(1+na, sizeof(int));
 213.167 +      pi = xcalloc(1+nv, sizeof(int));
 213.168 +      /* construct the resulting network */
 213.169 +      k = 0;
 213.170 +      /* (original arcs) */
 213.171 +      for (i = 1; i <= G->nv; i++)
 213.172 +      {  v = G->v[i];
 213.173 +         for (a = v->out; a != NULL; a = a->t_next)
 213.174 +         {  k++;
 213.175 +            tail[k] = a->tail->i;
 213.176 +            head[k] = a->head->i;
 213.177 +            if (tail[k] == head[k])
 213.178 +            {  ret = GLP_EDATA;
 213.179 +               goto done;
 213.180 +            }
 213.181 +            if (a_low >= 0)
 213.182 +               memcpy(&temp, (char *)a->data + a_low, sizeof(double));
 213.183 +            else
 213.184 +               temp = 0.0;
 213.185 +            if (!(0.0 <= temp && temp <= (double)INT_MAX &&
 213.186 +                  temp == floor(temp)))
 213.187 +            {  ret = GLP_EDATA;
 213.188 +               goto done;
 213.189 +            }
 213.190 +            low[k] = (int)temp;
 213.191 +            if (a_cap >= 0)
 213.192 +               memcpy(&temp, (char *)a->data + a_cap, sizeof(double));
 213.193 +            else
 213.194 +               temp = 1.0;
 213.195 +            if (!((double)low[k] <= temp && temp <= (double)INT_MAX &&
 213.196 +                  temp == floor(temp)))
 213.197 +            {  ret = GLP_EDATA;
 213.198 +               goto done;
 213.199 +            }
 213.200 +            cap[k] = (int)temp;
 213.201 +            if (a_cost >= 0)
 213.202 +               memcpy(&temp, (char *)a->data + a_cost, sizeof(double));
 213.203 +            else
 213.204 +               temp = 0.0;
 213.205 +            if (!(fabs(temp) <= (double)INT_MAX && temp == floor(temp)))
 213.206 +            {  ret = GLP_EDATA;
 213.207 +               goto done;
 213.208 +            }
 213.209 +            cost[k] = (int)temp;
 213.210 +         }
 213.211 +      }
 213.212 +      /* (artificial arcs) */
 213.213 +      sum = 0.0;
 213.214 +      for (i = 1; i <= G->nv; i++)
 213.215 +      {  v = G->v[i];
 213.216 +         if (v_rhs >= 0)
 213.217 +            memcpy(&temp, (char *)v->data + v_rhs, sizeof(double));
 213.218 +         else
 213.219 +            temp = 0.0;
 213.220 +         if (!(fabs(temp) <= (double)INT_MAX && temp == floor(temp)))
 213.221 +         {  ret = GLP_EDATA;
 213.222 +            goto done;
 213.223 +         }
 213.224 +         if (temp > 0.0)
 213.225 +         {  /* artificial arc from s to original source i */
 213.226 +            k++;
 213.227 +            tail[k] = s;
 213.228 +            head[k] = i;
 213.229 +            low[k] = cap[k] = (int)(+temp); /* supply */
 213.230 +            cost[k] = 0;
 213.231 +            sum += (double)temp;
 213.232 +         }
 213.233 +         else if (temp < 0.0)
 213.234 +         {  /* artificial arc from original sink i to t */
 213.235 +            k++;
 213.236 +            tail[k] = i;
 213.237 +            head[k] = t;
 213.238 +            low[k] = cap[k] = (int)(-temp); /* demand */
 213.239 +            cost[k] = 0;
 213.240 +         }
 213.241 +      }
 213.242 +      /* (feedback arc from t to s) */
 213.243 +      k++;
 213.244 +      xassert(k == na);
 213.245 +      tail[k] = t;
 213.246 +      head[k] = s;
 213.247 +      if (sum > (double)INT_MAX)
 213.248 +      {  ret = GLP_EDATA;
 213.249 +         goto done;
 213.250 +      }
 213.251 +      low[k] = cap[k] = (int)sum; /* total supply/demand */
 213.252 +      cost[k] = 0;
 213.253 +      /* find minimal-cost circulation in the resulting network */
 213.254 +      ret = okalg(nv, na, tail, head, low, cap, cost, x, pi);
 213.255 +      switch (ret)
 213.256 +      {  case 0:
 213.257 +            /* optimal circulation found */
 213.258 +            ret = 0;
 213.259 +            break;
 213.260 +         case 1:
 213.261 +            /* no feasible circulation exists */
 213.262 +            ret = GLP_ENOPFS;
 213.263 +            break;
 213.264 +         case 2:
 213.265 +            /* integer overflow occured */
 213.266 +            ret = GLP_ERANGE;
 213.267 +            goto done;
 213.268 +         case 3:
 213.269 +            /* optimality test failed (logic error) */
 213.270 +            ret = GLP_EFAIL;
 213.271 +            goto done;
 213.272 +         default:
 213.273 +            xassert(ret != ret);
 213.274 +      }
 213.275 +      /* store solution components */
 213.276 +      /* (objective function = the total cost) */
 213.277 +      if (sol != NULL)
 213.278 +      {  temp = 0.0;
 213.279 +         for (k = 1; k <= na; k++)
 213.280 +            temp += (double)cost[k] * (double)x[k];
 213.281 +         *sol = temp;
 213.282 +      }
 213.283 +      /* (arc flows) */
 213.284 +      if (a_x >= 0)
 213.285 +      {  k = 0;
 213.286 +         for (i = 1; i <= G->nv; i++)
 213.287 +         {  v = G->v[i];
 213.288 +            for (a = v->out; a != NULL; a = a->t_next)
 213.289 +            {  temp = (double)x[++k];
 213.290 +               memcpy((char *)a->data + a_x, &temp, sizeof(double));
 213.291 +            }
 213.292 +         }
 213.293 +      }
 213.294 +      /* (node potentials = Lagrange multipliers) */
 213.295 +      if (v_pi >= 0)
 213.296 +      {  for (i = 1; i <= G->nv; i++)
 213.297 +         {  v = G->v[i];
 213.298 +            temp = - (double)pi[i];
 213.299 +            memcpy((char *)v->data + v_pi, &temp, sizeof(double));
 213.300 +         }
 213.301 +      }
 213.302 +done: /* free working arrays */
 213.303 +      xfree(tail);
 213.304 +      xfree(head);
 213.305 +      xfree(low);
 213.306 +      xfree(cap);
 213.307 +      xfree(cost);
 213.308 +      xfree(x);
 213.309 +      xfree(pi);
 213.310 +      return ret;
 213.311 +}
 213.312 +
 213.313 +/***********************************************************************
 213.314 +*  NAME
 213.315 +*
 213.316 +*  glp_maxflow_lp - convert maximum flow problem to LP
 213.317 +*
 213.318 +*  SYNOPSIS
 213.319 +*
 213.320 +*  void glp_maxflow_lp(glp_prob *lp, glp_graph *G, int names, int s,
 213.321 +*     int t, int a_cap);
 213.322 +*
 213.323 +*  DESCRIPTION
 213.324 +*
 213.325 +*  The routine glp_maxflow_lp builds an LP problem, which corresponds
 213.326 +*  to the maximum flow problem on the specified network G. */
 213.327 +
 213.328 +void glp_maxflow_lp(glp_prob *lp, glp_graph *G, int names, int s,
 213.329 +      int t, int a_cap)
 213.330 +{     glp_vertex *v;
 213.331 +      glp_arc *a;
 213.332 +      int i, j, type, ind[1+2];
 213.333 +      double cap, val[1+2];
 213.334 +      if (!(names == GLP_ON || names == GLP_OFF))
 213.335 +         xerror("glp_maxflow_lp: names = %d; invalid parameter\n",
 213.336 +            names);
 213.337 +      if (!(1 <= s && s <= G->nv))
 213.338 +         xerror("glp_maxflow_lp: s = %d; source node number out of rang"
 213.339 +            "e\n", s);
 213.340 +      if (!(1 <= t && t <= G->nv))
 213.341 +         xerror("glp_maxflow_lp: t = %d: sink node number out of range "
 213.342 +            "\n", t);
 213.343 +      if (s == t)
 213.344 +         xerror("glp_maxflow_lp: s = t = %d; source and sink nodes must"
 213.345 +            " be distinct\n", s);
 213.346 +      if (a_cap >= 0 && a_cap > G->a_size - (int)sizeof(double))
 213.347 +         xerror("glp_maxflow_lp: a_cap = %d; invalid offset\n", a_cap);
 213.348 +      glp_erase_prob(lp);
 213.349 +      if (names) glp_set_prob_name(lp, G->name);
 213.350 +      glp_set_obj_dir(lp, GLP_MAX);
 213.351 +      glp_add_rows(lp, G->nv);
 213.352 +      for (i = 1; i <= G->nv; i++)
 213.353 +      {  v = G->v[i];
 213.354 +         if (names) glp_set_row_name(lp, i, v->name);
 213.355 +         if (i == s)
 213.356 +            type = GLP_LO;
 213.357 +         else if (i == t)
 213.358 +            type = GLP_UP;
 213.359 +         else
 213.360 +            type = GLP_FX;
 213.361 +         glp_set_row_bnds(lp, i, type, 0.0, 0.0);
 213.362 +      }
 213.363 +      if (G->na > 0) glp_add_cols(lp, G->na);
 213.364 +      for (i = 1, j = 0; i <= G->nv; i++)
 213.365 +      {  v = G->v[i];
 213.366 +         for (a = v->out; a != NULL; a = a->t_next)
 213.367 +         {  j++;
 213.368 +            if (names)
 213.369 +            {  char name[50+1];
 213.370 +               sprintf(name, "x[%d,%d]", a->tail->i, a->head->i);
 213.371 +               xassert(strlen(name) < sizeof(name));
 213.372 +               glp_set_col_name(lp, j, name);
 213.373 +            }
 213.374 +            if (a->tail->i != a->head->i)
 213.375 +            {  ind[1] = a->tail->i, val[1] = +1.0;
 213.376 +               ind[2] = a->head->i, val[2] = -1.0;
 213.377 +               glp_set_mat_col(lp, j, 2, ind, val);
 213.378 +            }
 213.379 +            if (a_cap >= 0)
 213.380 +               memcpy(&cap, (char *)a->data + a_cap, sizeof(double));
 213.381 +            else
 213.382 +               cap = 1.0;
 213.383 +            if (cap == DBL_MAX)
 213.384 +               type = GLP_LO;
 213.385 +            else if (cap != 0.0)
 213.386 +               type = GLP_DB;
 213.387 +            else
 213.388 +               type = GLP_FX;
 213.389 +            glp_set_col_bnds(lp, j, type, 0.0, cap);
 213.390 +            if (a->tail->i == s)
 213.391 +               glp_set_obj_coef(lp, j, +1.0);
 213.392 +            else if (a->head->i == s)
 213.393 +               glp_set_obj_coef(lp, j, -1.0);
 213.394 +         }
 213.395 +      }
 213.396 +      xassert(j == G->na);
 213.397 +      return;
 213.398 +}
 213.399 +
 213.400 +int glp_maxflow_ffalg(glp_graph *G, int s, int t, int a_cap,
 213.401 +      double *sol, int a_x, int v_cut)
 213.402 +{     /* find maximal flow with Ford-Fulkerson algorithm */
 213.403 +      glp_vertex *v;
 213.404 +      glp_arc *a;
 213.405 +      int nv, na, i, k, flag, *tail, *head, *cap, *x, ret;
 213.406 +      char *cut;
 213.407 +      double temp;
 213.408 +      if (!(1 <= s && s <= G->nv))
 213.409 +         xerror("glp_maxflow_ffalg: s = %d; source node number out of r"
 213.410 +            "ange\n", s);
 213.411 +      if (!(1 <= t && t <= G->nv))
 213.412 +         xerror("glp_maxflow_ffalg: t = %d: sink node number out of ran"
 213.413 +            "ge\n", t);
 213.414 +      if (s == t)
 213.415 +         xerror("glp_maxflow_ffalg: s = t = %d; source and sink nodes m"
 213.416 +            "ust be distinct\n", s);
 213.417 +      if (a_cap >= 0 && a_cap > G->a_size - (int)sizeof(double))
 213.418 +         xerror("glp_maxflow_ffalg: a_cap = %d; invalid offset\n",
 213.419 +            a_cap);
 213.420 +      if (v_cut >= 0 && v_cut > G->v_size - (int)sizeof(int))
 213.421 +         xerror("glp_maxflow_ffalg: v_cut = %d; invalid offset\n",
 213.422 +            v_cut);
 213.423 +      /* allocate working arrays */
 213.424 +      nv = G->nv;
 213.425 +      na = G->na;
 213.426 +      tail = xcalloc(1+na, sizeof(int));
 213.427 +      head = xcalloc(1+na, sizeof(int));
 213.428 +      cap = xcalloc(1+na, sizeof(int));
 213.429 +      x = xcalloc(1+na, sizeof(int));
 213.430 +      if (v_cut < 0)
 213.431 +         cut = NULL;
 213.432 +      else
 213.433 +         cut = xcalloc(1+nv, sizeof(char));
 213.434 +      /* copy the flow network */
 213.435 +      k = 0;
 213.436 +      for (i = 1; i <= G->nv; i++)
 213.437 +      {  v = G->v[i];
 213.438 +         for (a = v->out; a != NULL; a = a->t_next)
 213.439 +         {  k++;
 213.440 +            tail[k] = a->tail->i;
 213.441 +            head[k] = a->head->i;
 213.442 +            if (tail[k] == head[k])
 213.443 +            {  ret = GLP_EDATA;
 213.444 +               goto done;
 213.445 +            }
 213.446 +            if (a_cap >= 0)
 213.447 +               memcpy(&temp, (char *)a->data + a_cap, sizeof(double));
 213.448 +            else
 213.449 +               temp = 1.0;
 213.450 +            if (!(0.0 <= temp && temp <= (double)INT_MAX &&
 213.451 +                  temp == floor(temp)))
 213.452 +            {  ret = GLP_EDATA;
 213.453 +               goto done;
 213.454 +            }
 213.455 +            cap[k] = (int)temp;
 213.456 +         }
 213.457 +      }
 213.458 +      xassert(k == na);
 213.459 +      /* find maximal flow in the flow network */
 213.460 +      ffalg(nv, na, tail, head, s, t, cap, x, cut);
 213.461 +      ret = 0;
 213.462 +      /* store solution components */
 213.463 +      /* (objective function = total flow through the network) */
 213.464 +      if (sol != NULL)
 213.465 +      {  temp = 0.0;
 213.466 +         for (k = 1; k <= na; k++)
 213.467 +         {  if (tail[k] == s)
 213.468 +               temp += (double)x[k];
 213.469 +            else if (head[k] == s)
 213.470 +               temp -= (double)x[k];
 213.471 +         }
 213.472 +         *sol = temp;
 213.473 +      }
 213.474 +      /* (arc flows) */
 213.475 +      if (a_x >= 0)
 213.476 +      {  k = 0;
 213.477 +         for (i = 1; i <= G->nv; i++)
 213.478 +         {  v = G->v[i];
 213.479 +            for (a = v->out; a != NULL; a = a->t_next)
 213.480 +            {  temp = (double)x[++k];
 213.481 +               memcpy((char *)a->data + a_x, &temp, sizeof(double));
 213.482 +            }
 213.483 +         }
 213.484 +      }
 213.485 +      /* (node flags) */
 213.486 +      if (v_cut >= 0)
 213.487 +      {  for (i = 1; i <= G->nv; i++)
 213.488 +         {  v = G->v[i];
 213.489 +            flag = cut[i];
 213.490 +            memcpy((char *)v->data + v_cut, &flag, sizeof(int));
 213.491 +         }
 213.492 +      }
 213.493 +done: /* free working arrays */
 213.494 +      xfree(tail);
 213.495 +      xfree(head);
 213.496 +      xfree(cap);
 213.497 +      xfree(x);
 213.498 +      if (cut != NULL) xfree(cut);
 213.499 +      return ret;
 213.500 +}
 213.501 +
 213.502 +/***********************************************************************
 213.503 +*  NAME
 213.504 +*
 213.505 +*  glp_check_asnprob - check correctness of assignment problem data
 213.506 +*
 213.507 +*  SYNOPSIS
 213.508 +*
 213.509 +*  int glp_check_asnprob(glp_graph *G, int v_set);
 213.510 +*
 213.511 +*  RETURNS
 213.512 +*
 213.513 +*  If the specified assignment problem data are correct, the routine
 213.514 +*  glp_check_asnprob returns zero, otherwise, non-zero. */
 213.515 +
 213.516 +int glp_check_asnprob(glp_graph *G, int v_set)
 213.517 +{     glp_vertex *v;
 213.518 +      int i, k, ret = 0;
 213.519 +      if (v_set >= 0 && v_set > G->v_size - (int)sizeof(int))
 213.520 +         xerror("glp_check_asnprob: v_set = %d; invalid offset\n",
 213.521 +            v_set);
 213.522 +      for (i = 1; i <= G->nv; i++)
 213.523 +      {  v = G->v[i];
 213.524 +         if (v_set >= 0)
 213.525 +         {  memcpy(&k, (char *)v->data + v_set, sizeof(int));
 213.526 +            if (k == 0)
 213.527 +            {  if (v->in != NULL)
 213.528 +               {  ret = 1;
 213.529 +                  break;
 213.530 +               }
 213.531 +            }
 213.532 +            else if (k == 1)
 213.533 +            {  if (v->out != NULL)
 213.534 +               {  ret = 2;
 213.535 +                  break;
 213.536 +               }
 213.537 +            }
 213.538 +            else
 213.539 +            {  ret = 3;
 213.540 +               break;
 213.541 +            }
 213.542 +         }
 213.543 +         else
 213.544 +         {  if (v->in != NULL && v->out != NULL)
 213.545 +            {  ret = 4;
 213.546 +               break;
 213.547 +            }
 213.548 +         }
 213.549 +      }
 213.550 +      return ret;
 213.551 +}
 213.552 +
 213.553 +/***********************************************************************
 213.554 +*  NAME
 213.555 +*
 213.556 +*  glp_asnprob_lp - convert assignment problem to LP
 213.557 +*
 213.558 +*  SYNOPSIS
 213.559 +*
 213.560 +*  int glp_asnprob_lp(glp_prob *P, int form, glp_graph *G, int names,
 213.561 +*     int v_set, int a_cost);
 213.562 +*
 213.563 +*  DESCRIPTION
 213.564 +*
 213.565 +*  The routine glp_asnprob_lp builds an LP problem, which corresponds
 213.566 +*  to the assignment problem on the specified graph G.
 213.567 +*
 213.568 +*  RETURNS
 213.569 +*
 213.570 +*  If the LP problem has been successfully built, the routine returns
 213.571 +*  zero, otherwise, non-zero. */
 213.572 +
 213.573 +int glp_asnprob_lp(glp_prob *P, int form, glp_graph *G, int names,
 213.574 +      int v_set, int a_cost)
 213.575 +{     glp_vertex *v;
 213.576 +      glp_arc *a;
 213.577 +      int i, j, ret, ind[1+2];
 213.578 +      double cost, val[1+2];
 213.579 +      if (!(form == GLP_ASN_MIN || form == GLP_ASN_MAX ||
 213.580 +            form == GLP_ASN_MMP))
 213.581 +         xerror("glp_asnprob_lp: form = %d; invalid parameter\n",
 213.582 +            form);
 213.583 +      if (!(names == GLP_ON || names == GLP_OFF))
 213.584 +         xerror("glp_asnprob_lp: names = %d; invalid parameter\n",
 213.585 +            names);
 213.586 +      if (v_set >= 0 && v_set > G->v_size - (int)sizeof(int))
 213.587 +         xerror("glp_asnprob_lp: v_set = %d; invalid offset\n",
 213.588 +            v_set);
 213.589 +      if (a_cost >= 0 && a_cost > G->a_size - (int)sizeof(double))
 213.590 +         xerror("glp_asnprob_lp: a_cost = %d; invalid offset\n",
 213.591 +            a_cost);
 213.592 +      ret = glp_check_asnprob(G, v_set);
 213.593 +      if (ret != 0) goto done;
 213.594 +      glp_erase_prob(P);
 213.595 +      if (names) glp_set_prob_name(P, G->name);
 213.596 +      glp_set_obj_dir(P, form == GLP_ASN_MIN ? GLP_MIN : GLP_MAX);
 213.597 +      if (G->nv > 0) glp_add_rows(P, G->nv);
 213.598 +      for (i = 1; i <= G->nv; i++)
 213.599 +      {  v = G->v[i];
 213.600 +         if (names) glp_set_row_name(P, i, v->name);
 213.601 +         glp_set_row_bnds(P, i, form == GLP_ASN_MMP ? GLP_UP : GLP_FX,
 213.602 +            1.0, 1.0);
 213.603 +      }
 213.604 +      if (G->na > 0) glp_add_cols(P, G->na);
 213.605 +      for (i = 1, j = 0; i <= G->nv; i++)
 213.606 +      {  v = G->v[i];
 213.607 +         for (a = v->out; a != NULL; a = a->t_next)
 213.608 +         {  j++;
 213.609 +            if (names)
 213.610 +            {  char name[50+1];
 213.611 +               sprintf(name, "x[%d,%d]", a->tail->i, a->head->i);
 213.612 +               xassert(strlen(name) < sizeof(name));
 213.613 +               glp_set_col_name(P, j, name);
 213.614 +            }
 213.615 +            ind[1] = a->tail->i, val[1] = +1.0;
 213.616 +            ind[2] = a->head->i, val[2] = +1.0;
 213.617 +            glp_set_mat_col(P, j, 2, ind, val);
 213.618 +            glp_set_col_bnds(P, j, GLP_DB, 0.0, 1.0);
 213.619 +            if (a_cost >= 0)
 213.620 +               memcpy(&cost, (char *)a->data + a_cost, sizeof(double));
 213.621 +            else
 213.622 +               cost = 1.0;
 213.623 +            glp_set_obj_coef(P, j, cost);
 213.624 +         }
 213.625 +      }
 213.626 +      xassert(j == G->na);
 213.627 +done: return ret;
 213.628 +}
 213.629 +
 213.630 +/**********************************************************************/
 213.631 +
 213.632 +int glp_asnprob_okalg(int form, glp_graph *G, int v_set, int a_cost,
 213.633 +      double *sol, int a_x)
 213.634 +{     /* solve assignment problem with out-of-kilter algorithm */
 213.635 +      glp_vertex *v;
 213.636 +      glp_arc *a;
 213.637 +      int nv, na, i, k, *tail, *head, *low, *cap, *cost, *x, *pi, ret;
 213.638 +      double temp;
 213.639 +      if (!(form == GLP_ASN_MIN || form == GLP_ASN_MAX ||
 213.640 +            form == GLP_ASN_MMP))
 213.641 +         xerror("glp_asnprob_okalg: form = %d; invalid parameter\n",
 213.642 +            form);
 213.643 +      if (v_set >= 0 && v_set > G->v_size - (int)sizeof(int))
 213.644 +         xerror("glp_asnprob_okalg: v_set = %d; invalid offset\n",
 213.645 +            v_set);
 213.646 +      if (a_cost >= 0 && a_cost > G->a_size - (int)sizeof(double))
 213.647 +         xerror("glp_asnprob_okalg: a_cost = %d; invalid offset\n",
 213.648 +            a_cost);
 213.649 +      if (a_x >= 0 && a_x > G->a_size - (int)sizeof(int))
 213.650 +         xerror("glp_asnprob_okalg: a_x = %d; invalid offset\n", a_x);
 213.651 +      if (glp_check_asnprob(G, v_set))
 213.652 +         return GLP_EDATA;
 213.653 +      /* nv is the total number of nodes in the resulting network */
 213.654 +      nv = G->nv + 1;
 213.655 +      /* na is the total number of arcs in the resulting network */
 213.656 +      na = G->na + G->nv;
 213.657 +      /* allocate working arrays */
 213.658 +      tail = xcalloc(1+na, sizeof(int));
 213.659 +      head = xcalloc(1+na, sizeof(int));
 213.660 +      low = xcalloc(1+na, sizeof(int));
 213.661 +      cap = xcalloc(1+na, sizeof(int));
 213.662 +      cost = xcalloc(1+na, sizeof(int));
 213.663 +      x = xcalloc(1+na, sizeof(int));
 213.664 +      pi = xcalloc(1+nv, sizeof(int));
 213.665 +      /* construct the resulting network */
 213.666 +      k = 0;
 213.667 +      /* (original arcs) */
 213.668 +      for (i = 1; i <= G->nv; i++)
 213.669 +      {  v = G->v[i];
 213.670 +         for (a = v->out; a != NULL; a = a->t_next)
 213.671 +         {  k++;
 213.672 +            tail[k] = a->tail->i;
 213.673 +            head[k] = a->head->i;
 213.674 +            low[k] = 0;
 213.675 +            cap[k] = 1;
 213.676 +            if (a_cost >= 0)
 213.677 +               memcpy(&temp, (char *)a->data + a_cost, sizeof(double));
 213.678 +            else
 213.679 +               temp = 1.0;
 213.680 +            if (!(fabs(temp) <= (double)INT_MAX && temp == floor(temp)))
 213.681 +            {  ret = GLP_EDATA;
 213.682 +               goto done;
 213.683 +            }
 213.684 +            cost[k] = (int)temp;
 213.685 +            if (form != GLP_ASN_MIN) cost[k] = - cost[k];
 213.686 +         }
 213.687 +      }
 213.688 +      /* (artificial arcs) */
 213.689 +      for (i = 1; i <= G->nv; i++)
 213.690 +      {  v = G->v[i];
 213.691 +         k++;
 213.692 +         if (v->out == NULL)
 213.693 +            tail[k] = i, head[k] = nv;
 213.694 +         else if (v->in == NULL)
 213.695 +            tail[k] = nv, head[k] = i;
 213.696 +         else
 213.697 +            xassert(v != v);
 213.698 +         low[k] = (form == GLP_ASN_MMP ? 0 : 1);
 213.699 +         cap[k] = 1;
 213.700 +         cost[k] = 0;
 213.701 +      }
 213.702 +      xassert(k == na);
 213.703 +      /* find minimal-cost circulation in the resulting network */
 213.704 +      ret = okalg(nv, na, tail, head, low, cap, cost, x, pi);
 213.705 +      switch (ret)
 213.706 +      {  case 0:
 213.707 +            /* optimal circulation found */
 213.708 +            ret = 0;
 213.709 +            break;
 213.710 +         case 1:
 213.711 +            /* no feasible circulation exists */
 213.712 +            ret = GLP_ENOPFS;
 213.713 +            break;
 213.714 +         case 2:
 213.715 +            /* integer overflow occured */
 213.716 +            ret = GLP_ERANGE;
 213.717 +            goto done;
 213.718 +         case 3:
 213.719 +            /* optimality test failed (logic error) */
 213.720 +            ret = GLP_EFAIL;
 213.721 +            goto done;
 213.722 +         default:
 213.723 +            xassert(ret != ret);
 213.724 +      }
 213.725 +      /* store solution components */
 213.726 +      /* (objective function = the total cost) */
 213.727 +      if (sol != NULL)
 213.728 +      {  temp = 0.0;
 213.729 +         for (k = 1; k <= na; k++)
 213.730 +            temp += (double)cost[k] * (double)x[k];
 213.731 +         if (form != GLP_ASN_MIN) temp = - temp;
 213.732 +         *sol = temp;
 213.733 +      }
 213.734 +      /* (arc flows) */
 213.735 +      if (a_x >= 0)
 213.736 +      {  k = 0;
 213.737 +         for (i = 1; i <= G->nv; i++)
 213.738 +         {  v = G->v[i];
 213.739 +            for (a = v->out; a != NULL; a = a->t_next)
 213.740 +            {  k++;
 213.741 +               if (ret == 0)
 213.742 +                  xassert(x[k] == 0 || x[k] == 1);
 213.743 +               memcpy((char *)a->data + a_x, &x[k], sizeof(int));
 213.744 +            }
 213.745 +         }
 213.746 +      }
 213.747 +done: /* free working arrays */
 213.748 +      xfree(tail);
 213.749 +      xfree(head);
 213.750 +      xfree(low);
 213.751 +      xfree(cap);
 213.752 +      xfree(cost);
 213.753 +      xfree(x);
 213.754 +      xfree(pi);
 213.755 +      return ret;
 213.756 +}
 213.757 +
 213.758 +/***********************************************************************
 213.759 +*  NAME
 213.760 +*
 213.761 +*  glp_asnprob_hall - find bipartite matching of maximum cardinality
 213.762 +*
 213.763 +*  SYNOPSIS
 213.764 +*
 213.765 +*  int glp_asnprob_hall(glp_graph *G, int v_set, int a_x);
 213.766 +*
 213.767 +*  DESCRIPTION
 213.768 +*
 213.769 +*  The routine glp_asnprob_hall finds a matching of maximal cardinality
 213.770 +*  in the specified bipartite graph G. It uses a version of the Fortran
 213.771 +*  routine MC21A developed by I.S.Duff [1], which implements Hall's
 213.772 +*  algorithm [2].
 213.773 +*
 213.774 +*  RETURNS
 213.775 +*
 213.776 +*  The routine glp_asnprob_hall returns the cardinality of the matching
 213.777 +*  found. However, if the specified graph is incorrect (as detected by
 213.778 +*  the routine glp_check_asnprob), the routine returns negative value.
 213.779 +*
 213.780 +*  REFERENCES
 213.781 +*
 213.782 +*  1. I.S.Duff, Algorithm 575: Permutations for zero-free diagonal, ACM
 213.783 +*     Trans. on Math. Softw. 7 (1981), 387-390.
 213.784 +*
 213.785 +*  2. M.Hall, "An Algorithm for distinct representatives," Amer. Math.
 213.786 +*     Monthly 63 (1956), 716-717. */
 213.787 +
 213.788 +int glp_asnprob_hall(glp_graph *G, int v_set, int a_x)
 213.789 +{     glp_vertex *v;
 213.790 +      glp_arc *a;
 213.791 +      int card, i, k, loc, n, n1, n2, xij;
 213.792 +      int *num, *icn, *ip, *lenr, *iperm, *pr, *arp, *cv, *out;
 213.793 +      if (v_set >= 0 && v_set > G->v_size - (int)sizeof(int))
 213.794 +         xerror("glp_asnprob_hall: v_set = %d; invalid offset\n",
 213.795 +            v_set);
 213.796 +      if (a_x >= 0 && a_x > G->a_size - (int)sizeof(int))
 213.797 +         xerror("glp_asnprob_hall: a_x = %d; invalid offset\n", a_x);
 213.798 +      if (glp_check_asnprob(G, v_set))
 213.799 +         return -1;
 213.800 +      /* determine the number of vertices in sets R and S and renumber
 213.801 +         vertices in S which correspond to columns of the matrix; skip
 213.802 +         all isolated vertices */
 213.803 +      num = xcalloc(1+G->nv, sizeof(int));
 213.804 +      n1 = n2 = 0;
 213.805 +      for (i = 1; i <= G->nv; i++)
 213.806 +      {  v = G->v[i];
 213.807 +         if (v->in == NULL && v->out != NULL)
 213.808 +            n1++, num[i] = 0; /* vertex in R */
 213.809 +         else if (v->in != NULL && v->out == NULL)
 213.810 +            n2++, num[i] = n2; /* vertex in S */
 213.811 +         else
 213.812 +         {  xassert(v->in == NULL && v->out == NULL);
 213.813 +            num[i] = -1; /* isolated vertex */
 213.814 +         }
 213.815 +      }
 213.816 +      /* the matrix must be square, thus, if it has more columns than
 213.817 +         rows, extra rows will be just empty, and vice versa */
 213.818 +      n = (n1 >= n2 ? n1 : n2);
 213.819 +      /* allocate working arrays */
 213.820 +      icn = xcalloc(1+G->na, sizeof(int));
 213.821 +      ip = xcalloc(1+n, sizeof(int));
 213.822 +      lenr = xcalloc(1+n, sizeof(int));
 213.823 +      iperm = xcalloc(1+n, sizeof(int));
 213.824 +      pr = xcalloc(1+n, sizeof(int));
 213.825 +      arp = xcalloc(1+n, sizeof(int));
 213.826 +      cv = xcalloc(1+n, sizeof(int));
 213.827 +      out = xcalloc(1+n, sizeof(int));
 213.828 +      /* build the adjacency matrix of the bipartite graph in row-wise
 213.829 +         format (rows are vertices in R, columns are vertices in S) */
 213.830 +      k = 0, loc = 1;
 213.831 +      for (i = 1; i <= G->nv; i++)
 213.832 +      {  if (num[i] != 0) continue;
 213.833 +         /* vertex i in R */
 213.834 +         ip[++k] = loc;
 213.835 +         v = G->v[i];
 213.836 +         for (a = v->out; a != NULL; a = a->t_next)
 213.837 +         {  xassert(num[a->head->i] != 0);
 213.838 +            icn[loc++] = num[a->head->i];
 213.839 +         }
 213.840 +         lenr[k] = loc - ip[k];
 213.841 +      }
 213.842 +      xassert(loc-1 == G->na);
 213.843 +      /* make all extra rows empty (all extra columns are empty due to
 213.844 +         the row-wise format used) */
 213.845 +      for (k++; k <= n; k++)
 213.846 +         ip[k] = loc, lenr[k] = 0;
 213.847 +      /* find a row permutation that maximizes the number of non-zeros
 213.848 +         on the main diagonal */
 213.849 +      card = mc21a(n, icn, ip, lenr, iperm, pr, arp, cv, out);
 213.850 +#if 1 /* 18/II-2010 */
 213.851 +      /* FIXED: if card = n, arp remains clobbered on exit */
 213.852 +      for (i = 1; i <= n; i++)
 213.853 +         arp[i] = 0;
 213.854 +      for (i = 1; i <= card; i++)
 213.855 +      {  k = iperm[i];
 213.856 +         xassert(1 <= k && k <= n);
 213.857 +         xassert(arp[k] == 0);
 213.858 +         arp[k] = i;
 213.859 +      }
 213.860 +#endif
 213.861 +      /* store solution, if necessary */
 213.862 +      if (a_x < 0) goto skip;
 213.863 +      k = 0;
 213.864 +      for (i = 1; i <= G->nv; i++)
 213.865 +      {  if (num[i] != 0) continue;
 213.866 +         /* vertex i in R */
 213.867 +         k++;
 213.868 +         v = G->v[i];
 213.869 +         for (a = v->out; a != NULL; a = a->t_next)
 213.870 +         {  /* arp[k] is the number of matched column or zero */
 213.871 +            if (arp[k] == num[a->head->i])
 213.872 +            {  xassert(arp[k] != 0);
 213.873 +               xij = 1;
 213.874 +            }
 213.875 +            else
 213.876 +               xij = 0;
 213.877 +            memcpy((char *)a->data + a_x, &xij, sizeof(int));
 213.878 +         }
 213.879 +      }
 213.880 +skip: /* free working arrays */
 213.881 +      xfree(num);
 213.882 +      xfree(icn);
 213.883 +      xfree(ip);
 213.884 +      xfree(lenr);
 213.885 +      xfree(iperm);
 213.886 +      xfree(pr);
 213.887 +      xfree(arp);
 213.888 +      xfree(cv);
 213.889 +      xfree(out);
 213.890 +      return card;
 213.891 +}
 213.892 +
 213.893 +/***********************************************************************
 213.894 +*  NAME
 213.895 +*
 213.896 +*  glp_cpp - solve critical path problem
 213.897 +*
 213.898 +*  SYNOPSIS
 213.899 +*
 213.900 +*  double glp_cpp(glp_graph *G, int v_t, int v_es, int v_ls);
 213.901 +*
 213.902 +*  DESCRIPTION
 213.903 +*
 213.904 +*  The routine glp_cpp solves the critical path problem represented in
 213.905 +*  the form of the project network.
 213.906 +*
 213.907 +*  The parameter G is a pointer to the graph object, which specifies
 213.908 +*  the project network. This graph must be acyclic. Multiple arcs are
 213.909 +*  allowed being considered as single arcs.
 213.910 +*
 213.911 +*  The parameter v_t specifies an offset of the field of type double
 213.912 +*  in the vertex data block, which contains time t[i] >= 0 needed to
 213.913 +*  perform corresponding job j. If v_t < 0, it is assumed that t[i] = 1
 213.914 +*  for all jobs.
 213.915 +*
 213.916 +*  The parameter v_es specifies an offset of the field of type double
 213.917 +*  in the vertex data block, to which the routine stores earliest start
 213.918 +*  time for corresponding job. If v_es < 0, this time is not stored.
 213.919 +*
 213.920 +*  The parameter v_ls specifies an offset of the field of type double
 213.921 +*  in the vertex data block, to which the routine stores latest start
 213.922 +*  time for corresponding job. If v_ls < 0, this time is not stored.
 213.923 +*
 213.924 +*  RETURNS
 213.925 +*
 213.926 +*  The routine glp_cpp returns the minimal project duration, that is,
 213.927 +*  minimal time needed to perform all jobs in the project. */
 213.928 +
 213.929 +static void sorting(glp_graph *G, int list[]);
 213.930 +
 213.931 +double glp_cpp(glp_graph *G, int v_t, int v_es, int v_ls)
 213.932 +{     glp_vertex *v;
 213.933 +      glp_arc *a;
 213.934 +      int i, j, k, nv, *list;
 213.935 +      double temp, total, *t, *es, *ls;
 213.936 +      if (v_t >= 0 && v_t > G->v_size - (int)sizeof(double))
 213.937 +         xerror("glp_cpp: v_t = %d; invalid offset\n", v_t);
 213.938 +      if (v_es >= 0 && v_es > G->v_size - (int)sizeof(double))
 213.939 +         xerror("glp_cpp: v_es = %d; invalid offset\n", v_es);
 213.940 +      if (v_ls >= 0 && v_ls > G->v_size - (int)sizeof(double))
 213.941 +         xerror("glp_cpp: v_ls = %d; invalid offset\n", v_ls);
 213.942 +      nv = G->nv;
 213.943 +      if (nv == 0)
 213.944 +      {  total = 0.0;
 213.945 +         goto done;
 213.946 +      }
 213.947 +      /* allocate working arrays */
 213.948 +      t = xcalloc(1+nv, sizeof(double));
 213.949 +      es = xcalloc(1+nv, sizeof(double));
 213.950 +      ls = xcalloc(1+nv, sizeof(double));
 213.951 +      list = xcalloc(1+nv, sizeof(int));
 213.952 +      /* retrieve job times */
 213.953 +      for (i = 1; i <= nv; i++)
 213.954 +      {  v = G->v[i];
 213.955 +         if (v_t >= 0)
 213.956 +         {  memcpy(&t[i], (char *)v->data + v_t, sizeof(double));
 213.957 +            if (t[i] < 0.0)
 213.958 +               xerror("glp_cpp: t[%d] = %g; invalid time\n", i, t[i]);
 213.959 +         }
 213.960 +         else
 213.961 +            t[i] = 1.0;
 213.962 +      }
 213.963 +      /* perform topological sorting to determine the list of nodes
 213.964 +         (jobs) such that if list[k] = i and list[kk] = j and there
 213.965 +         exists arc (i->j), then k < kk */
 213.966 +      sorting(G, list);
 213.967 +      /* FORWARD PASS */
 213.968 +      /* determine earliest start times */
 213.969 +      for (k = 1; k <= nv; k++)
 213.970 +      {  j = list[k];
 213.971 +         es[j] = 0.0;
 213.972 +         for (a = G->v[j]->in; a != NULL; a = a->h_next)
 213.973 +         {  i = a->tail->i;
 213.974 +            /* there exists arc (i->j) in the project network */
 213.975 +            temp = es[i] + t[i];
 213.976 +            if (es[j] < temp) es[j] = temp;
 213.977 +         }
 213.978 +      }
 213.979 +      /* determine the minimal project duration */
 213.980 +      total = 0.0;
 213.981 +      for (i = 1; i <= nv; i++)
 213.982 +      {  temp = es[i] + t[i];
 213.983 +         if (total < temp) total = temp;
 213.984 +      }
 213.985 +      /* BACKWARD PASS */
 213.986 +      /* determine latest start times */
 213.987 +      for (k = nv; k >= 1; k--)
 213.988 +      {  i = list[k];
 213.989 +         ls[i] = total - t[i];
 213.990 +         for (a = G->v[i]->out; a != NULL; a = a->t_next)
 213.991 +         {  j = a->head->i;
 213.992 +            /* there exists arc (i->j) in the project network */
 213.993 +            temp = ls[j] - t[i];
 213.994 +            if (ls[i] > temp) ls[i] = temp;
 213.995 +         }
 213.996 +         /* avoid possible round-off errors */
 213.997 +         if (ls[i] < es[i]) ls[i] = es[i];
 213.998 +      }
 213.999 +      /* store results, if necessary */
213.1000 +      if (v_es >= 0)
213.1001 +      {  for (i = 1; i <= nv; i++)
213.1002 +         {  v = G->v[i];
213.1003 +            memcpy((char *)v->data + v_es, &es[i], sizeof(double));
213.1004 +         }
213.1005 +      }
213.1006 +      if (v_ls >= 0)
213.1007 +      {  for (i = 1; i <= nv; i++)
213.1008 +         {  v = G->v[i];
213.1009 +            memcpy((char *)v->data + v_ls, &ls[i], sizeof(double));
213.1010 +         }
213.1011 +      }
213.1012 +      /* free working arrays */
213.1013 +      xfree(t);
213.1014 +      xfree(es);
213.1015 +      xfree(ls);
213.1016 +      xfree(list);
213.1017 +done: return total;
213.1018 +}
213.1019 +
213.1020 +static void sorting(glp_graph *G, int list[])
213.1021 +{     /* perform topological sorting to determine the list of nodes
213.1022 +         (jobs) such that if list[k] = i and list[kk] = j and there
213.1023 +         exists arc (i->j), then k < kk */
213.1024 +      int i, k, nv, v_size, *num;
213.1025 +      void **save;
213.1026 +      nv = G->nv;
213.1027 +      v_size = G->v_size;
213.1028 +      save = xcalloc(1+nv, sizeof(void *));
213.1029 +      num = xcalloc(1+nv, sizeof(int));
213.1030 +      G->v_size = sizeof(int);
213.1031 +      for (i = 1; i <= nv; i++)
213.1032 +      {  save[i] = G->v[i]->data;
213.1033 +         G->v[i]->data = &num[i];
213.1034 +         list[i] = 0;
213.1035 +      }
213.1036 +      if (glp_top_sort(G, 0) != 0)
213.1037 +         xerror("glp_cpp: project network is not acyclic\n");
213.1038 +      G->v_size = v_size;
213.1039 +      for (i = 1; i <= nv; i++)
213.1040 +      {  G->v[i]->data = save[i];
213.1041 +         k = num[i];
213.1042 +         xassert(1 <= k && k <= nv);
213.1043 +         xassert(list[k] == 0);
213.1044 +         list[k] = i;
213.1045 +      }
213.1046 +      xfree(save);
213.1047 +      xfree(num);
213.1048 +      return;
213.1049 +}
213.1050 +
213.1051 +/* eof */
   214.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
   214.2 +++ b/deps/glpk/src/glpapi18.c	Sun Nov 06 20:59:10 2011 +0100
   214.3 @@ -0,0 +1,122 @@
   214.4 +/* glpapi18.c (maximum clique problem) */
   214.5 +
   214.6 +/***********************************************************************
   214.7 +*  This code is part of GLPK (GNU Linear Programming Kit).
   214.8 +*
   214.9 +*  Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008,
  214.10 +*  2009, 2010, 2011 Andrew Makhorin, Department for Applied Informatics,
  214.11 +*  Moscow Aviation Institute, Moscow, Russia. All rights reserved.
  214.12 +*  E-mail: <mao@gnu.org>.
  214.13 +*
  214.14 +*  GLPK is free software: you can redistribute it and/or modify it
  214.15 +*  under the terms of the GNU General Public License as published by
  214.16 +*  the Free Software Foundation, either version 3 of the License, or
  214.17 +*  (at your option) any later version.
  214.18 +*
  214.19 +*  GLPK is distributed in the hope that it will be useful, but WITHOUT
  214.20 +*  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
  214.21 +*  or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
  214.22 +*  License for more details.
  214.23 +*
  214.24 +*  You should have received a copy of the GNU General Public License
  214.25 +*  along with GLPK. If not, see <http://www.gnu.org/licenses/>.
  214.26 +***********************************************************************/
  214.27 +
  214.28 +#include "glpapi.h"
  214.29 +#include "glpnet.h"
  214.30 +
  214.31 +static void set_edge(int nv, unsigned char a[], int i, int j)
  214.32 +{     int k;
  214.33 +      xassert(1 <= j && j < i && i <= nv);
  214.34 +      k = ((i - 1) * (i - 2)) / 2 + (j - 1);
  214.35 +      a[k / CHAR_BIT] |=
  214.36 +         (unsigned char)(1 << ((CHAR_BIT - 1) - k % CHAR_BIT));
  214.37 +      return;
  214.38 +}
  214.39 +
  214.40 +int glp_wclique_exact(glp_graph *G, int v_wgt, double *sol, int v_set)
  214.41 +{     /* find maximum weight clique with exact algorithm */
  214.42 +      glp_arc *e;
  214.43 +      int i, j, k, len, x, *w, *ind, ret = 0;
  214.44 +      unsigned char *a;
  214.45 +      double s, t;
  214.46 +      if (v_wgt >= 0 && v_wgt > G->v_size - (int)sizeof(double))
  214.47 +         xerror("glp_wclique_exact: v_wgt = %d; invalid parameter\n",
  214.48 +            v_wgt);
  214.49 +      if (v_set >= 0 && v_set > G->v_size - (int)sizeof(int))
  214.50 +         xerror("glp_wclique_exact: v_set = %d; invalid parameter\n",
  214.51 +            v_set);
  214.52 +      if (G->nv == 0)
  214.53 +      {  /* empty graph has only empty clique */
  214.54 +         if (sol != NULL) *sol = 0.0;
  214.55 +         return 0;
  214.56 +      }
  214.57 +      /* allocate working arrays */
  214.58 +      w = xcalloc(1+G->nv, sizeof(int));
  214.59 +      ind = xcalloc(1+G->nv, sizeof(int));
  214.60 +      len = G->nv; /* # vertices */
  214.61 +      len = len * (len - 1) / 2; /* # entries in lower triangle */
  214.62 +      len = (len + (CHAR_BIT - 1)) / CHAR_BIT; /* # bytes needed */
  214.63 +      a = xcalloc(len, sizeof(char));
  214.64 +      memset(a, 0, len * sizeof(char));
  214.65 +      /* determine vertex weights */
  214.66 +      s = 0.0;
  214.67 +      for (i = 1; i <= G->nv; i++)
  214.68 +      {  if (v_wgt >= 0)
  214.69 +         {  memcpy(&t, (char *)G->v[i]->data + v_wgt, sizeof(double));
  214.70 +            if (!(0.0 <= t && t <= (double)INT_MAX && t == floor(t)))
  214.71 +            {  ret = GLP_EDATA;
  214.72 +               goto done;
  214.73 +            }
  214.74 +            w[i] = (int)t;
  214.75 +         }
  214.76 +         else
  214.77 +            w[i] = 1;
  214.78 +         s += (double)w[i];
  214.79 +      }
  214.80 +      if (s > (double)INT_MAX)
  214.81 +      {  ret = GLP_EDATA;
  214.82 +         goto done;
  214.83 +      }
  214.84 +      /* build the adjacency matrix */
  214.85 +      for (i = 1; i <= G->nv; i++)
  214.86 +      {  for (e = G->v[i]->in; e != NULL; e = e->h_next)
  214.87 +         {  j = e->tail->i;
  214.88 +            /* there exists edge (j,i) in the graph */
  214.89 +            if (i > j) set_edge(G->nv, a, i, j);
  214.90 +         }
  214.91 +         for (e = G->v[i]->out; e != NULL; e = e->t_next)
  214.92 +         {  j = e->head->i;
  214.93 +            /* there exists edge (i,j) in the graph */
  214.94 +            if (i > j) set_edge(G->nv, a, i, j);
  214.95 +         }
  214.96 +      }
  214.97 +      /* find maximum weight clique in the graph */
  214.98 +      len = wclique(G->nv, w, a, ind);
  214.99 +      /* compute the clique weight */
 214.100 +      s = 0.0;
 214.101 +      for (k = 1; k <= len; k++)
 214.102 +      {  i = ind[k];
 214.103 +         xassert(1 <= i && i <= G->nv);
 214.104 +         s += (double)w[i];
 214.105 +      }
 214.106 +      if (sol != NULL) *sol = s;
 214.107 +      /* mark vertices included in the clique */
 214.108 +      if (v_set >= 0)
 214.109 +      {  x = 0;
 214.110 +         for (i = 1; i <= G->nv; i++)
 214.111 +            memcpy((char *)G->v[i]->data + v_set, &x, sizeof(int));
 214.112 +         x = 1;
 214.113 +         for (k = 1; k <= len; k++)
 214.114 +         {  i = ind[k];
 214.115 +            memcpy((char *)G->v[i]->data + v_set, &x, sizeof(int));
 214.116 +         }
 214.117 +      }
 214.118 +done: /* free working arrays */
 214.119 +      xfree(w);
 214.120 +      xfree(ind);
 214.121 +      xfree(a);
 214.122 +      return ret;
 214.123 +}
 214.124 +
 214.125 +/* eof */
   215.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
   215.2 +++ b/deps/glpk/src/glpapi19.c	Sun Nov 06 20:59:10 2011 +0100
   215.3 @@ -0,0 +1,132 @@
   215.4 +/* glpapi19.c (driver to MiniSat solver) */
   215.5 +
   215.6 +/***********************************************************************
   215.7 +*  This code is part of GLPK (GNU Linear Programming Kit).
   215.8 +*
   215.9 +*  Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008,
  215.10 +*  2009, 2010, 2011 Andrew Makhorin, Department for Applied Informatics,
  215.11 +*  Moscow Aviation Institute, Moscow, Russia. All rights reserved.
  215.12 +*  E-mail: <mao@gnu.org>.
  215.13 +*
  215.14 +*  GLPK is free software: you can redistribute it and/or modify it
  215.15 +*  under the terms of the GNU General Public License as published by
  215.16 +*  the Free Software Foundation, either version 3 of the License, or
  215.17 +*  (at your option) any later version.
  215.18 +*
  215.19 +*  GLPK is distributed in the hope that it will be useful, but WITHOUT
  215.20 +*  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
  215.21 +*  or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
  215.22 +*  License for more details.
  215.23 +*
  215.24 +*  You should have received a copy of the GNU General Public License
  215.25 +*  along with GLPK. If not, see <http://www.gnu.org/licenses/>.
  215.26 +***********************************************************************/
  215.27 +
  215.28 +#include "glpapi.h"
  215.29 +#include "minisat/minisat.h"
  215.30 +
  215.31 +int glp_minisat1(glp_prob *P)
  215.32 +{     /* solve CNF-SAT problem with MiniSat solver */
  215.33 +      solver *s;
  215.34 +      GLPAIJ *aij;
  215.35 +      int i, j, len, ret, *ind;
  215.36 +      double sum;
  215.37 +      /* check problem object */
  215.38 +      if (P == NULL || P->magic != GLP_PROB_MAGIC)
  215.39 +         xerror("glp_minisat1: P = %p; invalid problem object\n",
  215.40 +            P);
  215.41 +      if (P->tree != NULL)
  215.42 +         xerror("glp_minisat1: operation not allowed\n");
  215.43 +      /* integer solution is currently undefined */
  215.44 +      P->mip_stat = GLP_UNDEF;
  215.45 +      P->mip_obj = 0.0;
  215.46 +      /* check that problem object encodes CNF-SAT instance */
  215.47 +      if (glp_check_cnfsat(P) != 0)
  215.48 +      {  xprintf("glp_minisat1: problem object does not encode CNF-SAT "
  215.49 +            "instance\n");
  215.50 +         ret = GLP_EDATA;
  215.51 +         goto done;
  215.52 +      }
  215.53 +      /* solve CNF-SAT problem */
  215.54 +      xprintf("Solving CNF-SAT problem...\n");
  215.55 +      xprintf("Instance has %d variable%s, %d clause%s, and %d literal%"
  215.56 +         "s\n", P->n, P->n == 1 ? "" : "s", P->m, P->m == 1 ? "" : "s",
  215.57 +         P->nnz, P->nnz == 1 ? "" : "s");
  215.58 +      /* if CNF-SAT has no clauses, it is satisfiable */
  215.59 +      if (P->m == 0)
  215.60 +      {  P->mip_stat = GLP_OPT;
  215.61 +         for (j = 1; j <= P->n; j++)
  215.62 +            P->col[j]->mipx = 0.0;
  215.63 +         goto fini;
  215.64 +      }
  215.65 +      /* if CNF-SAT has an empty clause, it is unsatisfiable */
  215.66 +      for (i = 1; i <= P->m; i++)
  215.67 +      {  if (P->row[i]->ptr == NULL)
  215.68 +         {  P->mip_stat = GLP_NOFEAS;
  215.69 +            goto fini;
  215.70 +         }
  215.71 +      }
  215.72 +      /* prepare input data for the solver */
  215.73 +      s = solver_new();
  215.74 +      solver_setnvars(s, P->n);
  215.75 +      ind = xcalloc(1+P->n, sizeof(int));
  215.76 +      for (i = 1; i <= P->m; i++)
  215.77 +      {  len = 0;
  215.78 +         for (aij = P->row[i]->ptr; aij != NULL; aij = aij->r_next)
  215.79 +         {  ind[++len] = toLit(aij->col->j-1);
  215.80 +            if (aij->val < 0.0)
  215.81 +               ind[len] = lit_neg(ind[len]);
  215.82 +         }
  215.83 +         xassert(len > 0);
  215.84 +         xassert(solver_addclause(s, &ind[1], &ind[1+len]));
  215.85 +      }
  215.86 +      xfree(ind);
  215.87 +      /* call the solver */
  215.88 +      s->verbosity = 1;
  215.89 +      if (solver_solve(s, 0, 0))
  215.90 +      {  /* instance is reported as satisfiable */
  215.91 +         P->mip_stat = GLP_OPT;
  215.92 +         /* copy solution to the problem object */
  215.93 +         xassert(s->model.size == P->n);
  215.94 +         for (j = 1; j <= P->n; j++)
  215.95 +         {  P->col[j]->mipx =
  215.96 +               s->model.ptr[j-1] == l_True ? 1.0 : 0.0;
  215.97 +         }
  215.98 +         /* compute row values */
  215.99 +         for (i = 1; i <= P->m; i++)
 215.100 +         {  sum = 0;
 215.101 +            for (aij = P->row[i]->ptr; aij != NULL; aij = aij->r_next)
 215.102 +               sum += aij->val * aij->col->mipx;
 215.103 +            P->row[i]->mipx = sum;
 215.104 +         }
 215.105 +         /* check integer feasibility */
 215.106 +         for (i = 1; i <= P->m; i++)
 215.107 +         {  if (P->row[i]->mipx < P->row[i]->lb)
 215.108 +            {  /* solution is wrong */
 215.109 +               P->mip_stat = GLP_UNDEF;
 215.110 +               break;
 215.111 +            }
 215.112 +         }
 215.113 +      }
 215.114 +      else
 215.115 +      {  /* instance is reported as unsatisfiable */
 215.116 +         P->mip_stat = GLP_NOFEAS;
 215.117 +      }
 215.118 +      solver_delete(s);
 215.119 +fini: /* report the instance status */
 215.120 +      if (P->mip_stat == GLP_OPT)
 215.121 +      {  xprintf("SATISFIABLE\n");
 215.122 +         ret = 0;
 215.123 +      }
 215.124 +      else if (P->mip_stat == GLP_NOFEAS)
 215.125 +      {  xprintf("UNSATISFIABLE\n");
 215.126 +         ret = 0;
 215.127 +      }
 215.128 +      else
 215.129 +      {  xprintf("glp_minisat1: solver failed\n");
 215.130 +         ret = GLP_EFAIL;
 215.131 +      }
 215.132 +done: return ret;
 215.133 +}
 215.134 +
 215.135 +/* eof */
   216.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
   216.2 +++ b/deps/glpk/src/glpapi20.c	Sun Nov 06 20:59:10 2011 +0100
   216.3 @@ -0,0 +1,256 @@
   216.4 +/* glpapi20.c */
   216.5 +
   216.6 +/***********************************************************************
   216.7 +*  This code is part of GLPK (GNU Linear Programming Kit).
   216.8 +*
   216.9 +*  Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008,
  216.10 +*  2009, 2010, 2011 Andrew Makhorin, Department for Applied Informatics,
  216.11 +*  Moscow Aviation Institute, Moscow, Russia. All rights reserved.
  216.12 +*  E-mail: <mao@gnu.org>.
  216.13 +*
  216.14 +*  GLPK is free software: you can redistribute it and/or modify it
  216.15 +*  under the terms of the GNU General Public License as published by
  216.16 +*  the Free Software Foundation, either version 3 of the License, or
  216.17 +*  (at your option) any later version.
  216.18 +*
  216.19 +*  GLPK is distributed in the hope that it will be useful, but WITHOUT
  216.20 +*  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
  216.21 +*  or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
  216.22 +*  License for more details.
  216.23 +*
  216.24 +*  You should have received a copy of the GNU General Public License
  216.25 +*  along with GLPK. If not, see <http://www.gnu.org/licenses/>.
  216.26 +***********************************************************************/
  216.27 +
  216.28 +#include "glpnpp.h"
  216.29 +
  216.30 +int glp_intfeas1(glp_prob *P, int use_bound, int obj_bound)
  216.31 +{     /* solve integer feasibility problem */
  216.32 +      NPP *npp = NULL;
  216.33 +      glp_prob *mip = NULL;
  216.34 +      int *obj_ind = NULL;
  216.35 +      double *obj_val = NULL;
  216.36 +      int obj_row = 0;
  216.37 +      int i, j, k, obj_len, temp, ret;
  216.38 +      /* check the problem object */
  216.39 +      if (P == NULL || P->magic != GLP_PROB_MAGIC)
  216.40 +         xerror("glp_intfeas1: P = %p; invalid problem object\n",
  216.41 +            P);
  216.42 +      if (P->tree != NULL)
  216.43 +         xerror("glp_intfeas1: operation not allowed\n");
  216.44 +      /* integer solution is currently undefined */
  216.45 +      P->mip_stat = GLP_UNDEF;
  216.46 +      P->mip_obj = 0.0;
  216.47 +      /* check columns (variables) */
  216.48 +      for (j = 1; j <= P->n; j++)
  216.49 +      {  GLPCOL *col = P->col[j];
  216.50 +#if 0 /* currently binarization is not yet implemented */
  216.51 +         if (!(col->kind == GLP_IV || col->type == GLP_FX))
  216.52 +         {  xprintf("glp_intfeas1: column %d: non-integer non-fixed var"
  216.53 +               "iable not allowed\n", j);
  216.54 +#else
  216.55 +         if (!((col->kind == GLP_IV && col->lb == 0.0 && col->ub == 1.0)
  216.56 +            || col->type == GLP_FX))
  216.57 +         {  xprintf("glp_intfeas1: column %d: non-binary non-fixed vari"
  216.58 +               "able not allowed\n", j);
  216.59 +#endif
  216.60 +            ret = GLP_EDATA;
  216.61 +            goto done;
  216.62 +         }
  216.63 +         temp = (int)col->lb;
  216.64 +         if ((double)temp != col->lb)
  216.65 +         {  if (col->type == GLP_FX)
  216.66 +               xprintf("glp_intfeas1: column %d: fixed value %g is non-"
  216.67 +                  "integer or out of range\n", j, col->lb);
  216.68 +            else
  216.69 +               xprintf("glp_intfeas1: column %d: lower bound %g is non-"
  216.70 +                  "integer or out of range\n", j, col->lb);
  216.71 +            ret = GLP_EDATA;
  216.72 +            goto done;
  216.73 +         }
  216.74 +         temp = (int)col->ub;
  216.75 +         if ((double)temp != col->ub)
  216.76 +         {  xprintf("glp_intfeas1: column %d: upper bound %g is non-int"
  216.77 +               "eger or out of range\n", j, col->ub);
  216.78 +            ret = GLP_EDATA;
  216.79 +            goto done;
  216.80 +         }
  216.81 +         if (col->type == GLP_DB && col->lb > col->ub)
  216.82 +         {  xprintf("glp_intfeas1: column %d: lower bound %g is greater"
  216.83 +               " than upper bound %g\n", j, col->lb, col->ub);
  216.84 +            ret = GLP_EBOUND;
  216.85 +            goto done;
  216.86 +         }
  216.87 +      }
  216.88 +      /* check rows (constraints) */
  216.89 +      for (i = 1; i <= P->m; i++)
  216.90 +      {  GLPROW *row = P->row[i];
  216.91 +         GLPAIJ *aij;
  216.92 +         for (aij = row->ptr; aij != NULL; aij = aij->r_next)
  216.93 +         {  temp = (int)aij->val;
  216.94 +            if ((double)temp != aij->val)
  216.95 +            {  xprintf("glp_intfeas1: row = %d, column %d: constraint c"
  216.96 +                  "oefficient %g is non-integer or out of range\n",
  216.97 +                  i, aij->col->j, aij->val);
  216.98 +               ret = GLP_EDATA;
  216.99 +               goto done;
 216.100 +            }
 216.101 +         }
 216.102 +         temp = (int)row->lb;
 216.103 +         if ((double)temp != row->lb)
 216.104 +         {  if (row->type == GLP_FX)
 216.105 +               xprintf("glp_intfeas1: row = %d: fixed value %g is non-i"
 216.106 +                  "nteger or out of range\n", i, row->lb);
 216.107 +            else
 216.108 +               xprintf("glp_intfeas1: row = %d: lower bound %g is non-i"
 216.109 +                  "nteger or out of range\n", i, row->lb);
 216.110 +            ret = GLP_EDATA;
 216.111 +            goto done;
 216.112 +         }
 216.113 +         temp = (int)row->ub;
 216.114 +         if ((double)temp != row->ub)
 216.115 +         {  xprintf("glp_intfeas1: row = %d: upper bound %g is non-inte"
 216.116 +               "ger or out of range\n", i, row->ub);
 216.117 +            ret = GLP_EDATA;
 216.118 +            goto done;
 216.119 +         }
 216.120 +         if (row->type == GLP_DB && row->lb > row->ub)
 216.121 +         {  xprintf("glp_intfeas1: row %d: lower bound %g is greater th"
 216.122 +               "an upper bound %g\n", i, row->lb, row->ub);
 216.123 +            ret = GLP_EBOUND;
 216.124 +            goto done;
 216.125 +         }
 216.126 +      }
 216.127 +      /* check the objective function */
 216.128 +      temp = (int)P->c0;
 216.129 +      if ((double)temp != P->c0)
 216.130 +      {  xprintf("glp_intfeas1: objective constant term %g is non-integ"
 216.131 +            "er or out of range\n", P->c0);
 216.132 +         ret = GLP_EDATA;
 216.133 +         goto done;
 216.134 +      }
 216.135 +      for (j = 1; j <= P->n; j++)
 216.136 +      {  temp = (int)P->col[j]->coef;
 216.137 +         if ((double)temp != P->col[j]->coef)
 216.138 +         {  xprintf("glp_intfeas1: column %d: objective coefficient is "
 216.139 +               "non-integer or out of range\n", j, P->col[j]->coef);
 216.140 +            ret = GLP_EDATA;
 216.141 +            goto done;
 216.142 +         }
 216.143 +      }
 216.144 +      /* save the objective function and set it to zero */
 216.145 +      obj_ind = xcalloc(1+P->n, sizeof(int));
 216.146 +      obj_val = xcalloc(1+P->n, sizeof(double));
 216.147 +      obj_len = 0;
 216.148 +      obj_ind[0] = 0;
 216.149 +      obj_val[0] = P->c0;
 216.150 +      P->c0 = 0.0;
 216.151 +      for (j = 1; j <= P->n; j++)
 216.152 +      {  if (P->col[j]->coef != 0.0)
 216.153 +         {  obj_len++;
 216.154 +            obj_ind[obj_len] = j;
 216.155 +            obj_val[obj_len] = P->col[j]->coef;
 216.156 +            P->col[j]->coef = 0.0;
 216.157 +         }
 216.158 +      }
 216.159 +      /* add inequality to bound the objective function, if required */
 216.160 +      if (!use_bound)
 216.161 +         xprintf("Will search for ANY feasible solution\n");
 216.162 +      else
 216.163 +      {  xprintf("Will search only for solution not worse than %d\n",
 216.164 +            obj_bound);
 216.165 +         obj_row = glp_add_rows(P, 1);
 216.166 +         glp_set_mat_row(P, obj_row, obj_len, obj_ind, obj_val);
 216.167 +         if (P->dir == GLP_MIN)
 216.168 +            glp_set_row_bnds(P, obj_row,
 216.169 +               GLP_UP, 0.0, (double)obj_bound - obj_val[0]);
 216.170 +         else if (P->dir == GLP_MAX)
 216.171 +            glp_set_row_bnds(P, obj_row,
 216.172 +               GLP_LO, (double)obj_bound - obj_val[0], 0.0);
 216.173 +         else
 216.174 +            xassert(P != P);
 216.175 +      }
 216.176 +      /* create preprocessor workspace */
 216.177 +      xprintf("Translating to CNF-SAT...\n");
 216.178 +      xprintf("Original problem has %d row%s, %d column%s, and %d non-z"
 216.179 +         "ero%s\n", P->m, P->m == 1 ? "" : "s", P->n, P->n == 1 ? "" :
 216.180 +         "s", P->nnz, P->nnz == 1 ? "" : "s");
 216.181 +      npp = npp_create_wksp();
 216.182 +      /* load the original problem into the preprocessor workspace */
 216.183 +      npp_load_prob(npp, P, GLP_OFF, GLP_MIP, GLP_OFF);
 216.184 +      /* perform translation to SAT-CNF problem instance */
 216.185 +      ret = npp_sat_encode_prob(npp);
 216.186 +      if (ret == 0)
 216.187 +         ;
 216.188 +      else if (ret == GLP_ENOPFS)
 216.189 +         xprintf("PROBLEM HAS NO INTEGER FEASIBLE SOLUTION\n");
 216.190 +      else if (ret == GLP_ERANGE)
 216.191 +         xprintf("glp_intfeas1: translation to SAT-CNF failed because o"
 216.192 +            "f integer overflow\n");
 216.193 +      else
 216.194 +         xassert(ret != ret);
 216.195 +      if (ret != 0)
 216.196 +         goto done;
 216.197 +      /* build SAT-CNF problem instance and try to solve it */
 216.198 +      mip = glp_create_prob();
 216.199 +      npp_build_prob(npp, mip);
 216.200 +      ret = glp_minisat1(mip);
 216.201 +      /* only integer feasible solution can be postprocessed */
 216.202 +      if (!(mip->mip_stat == GLP_OPT || mip->mip_stat == GLP_FEAS))
 216.203 +      {  P->mip_stat = mip->mip_stat;
 216.204 +         goto done;
 216.205 +      }
 216.206 +      /* postprocess the solution found */
 216.207 +      npp_postprocess(npp, mip);
 216.208 +      /* the transformed problem is no longer needed */
 216.209 +      glp_delete_prob(mip), mip = NULL;
 216.210 +      /* store solution to the original problem object */
 216.211 +      npp_unload_sol(npp, P);
 216.212 +      /* change the solution status to 'integer feasible' */
 216.213 +      P->mip_stat = GLP_FEAS;
 216.214 +      /* check integer feasibility */
 216.215 +      for (i = 1; i <= P->m; i++)
 216.216 +      {  GLPROW *row;
 216.217 +         GLPAIJ *aij;
 216.218 +         double sum;
 216.219 +         row = P->row[i];
 216.220 +         sum = 0.0;
 216.221 +         for (aij = row->ptr; aij != NULL; aij = aij->r_next)
 216.222 +            sum += aij->val * aij->col->mipx;
 216.223 +         xassert(sum == row->mipx);
 216.224 +         if (row->type == GLP_LO || row->type == GLP_DB ||
 216.225 +             row->type == GLP_FX)
 216.226 +            xassert(sum >= row->lb);
 216.227 +         if (row->type == GLP_UP || row->type == GLP_DB ||
 216.228 +             row->type == GLP_FX)
 216.229 +            xassert(sum <= row->ub);
 216.230 +      }
 216.231 +      /* compute value of the original objective function */
 216.232 +      P->mip_obj = obj_val[0];
 216.233 +      for (k = 1; k <= obj_len; k++)
 216.234 +         P->mip_obj += obj_val[k] * P->col[obj_ind[k]]->mipx;
 216.235 +      xprintf("Objective value = %17.9e\n", P->mip_obj);
 216.236 +done: /* delete the transformed problem, if it exists */
 216.237 +      if (mip != NULL)
 216.238 +         glp_delete_prob(mip);
 216.239 +      /* delete the preprocessor workspace, if it exists */
 216.240 +      if (npp != NULL)
 216.241 +         npp_delete_wksp(npp);
 216.242 +      /* remove inequality used to bound the objective function */
 216.243 +      if (obj_row > 0)
 216.244 +      {  int ind[1+1];
 216.245 +         ind[1] = obj_row;
 216.246 +         glp_del_rows(P, 1, ind);
 216.247 +      }
 216.248 +      /* restore the original objective function */
 216.249 +      if (obj_ind != NULL)
 216.250 +      {  P->c0 = obj_val[0];
 216.251 +         for (k = 1; k <= obj_len; k++)
 216.252 +            P->col[obj_ind[k]]->coef = obj_val[k];
 216.253 +         xfree(obj_ind);
 216.254 +         xfree(obj_val);
 216.255 +      }
 216.256 +      return ret;
 216.257 +}
 216.258 +
 216.259 +/* eof */
   217.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
   217.2 +++ b/deps/glpk/src/glpapi21.c	Sun Nov 06 20:59:10 2011 +0100
   217.3 @@ -0,0 +1,1324 @@
   217.4 +/* glpapi21.c (stand-alone LP/MIP solver) */
   217.5 +
   217.6 +/***********************************************************************
   217.7 +*  This code is part of GLPK (GNU Linear Programming Kit).
   217.8 +*
   217.9 +*  Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008,
  217.10 +*  2009, 2010, 2011 Andrew Makhorin, Department for Applied Informatics,
  217.11 +*  Moscow Aviation Institute, Moscow, Russia. All rights reserved.
  217.12 +*  E-mail: <mao@gnu.org>.
  217.13 +*
  217.14 +*  GLPK is free software: you can redistribute it and/or modify it
  217.15 +*  under the terms of the GNU General Public License as published by
  217.16 +*  the Free Software Foundation, either version 3 of the License, or
  217.17 +*  (at your option) any later version.
  217.18 +*
  217.19 +*  GLPK is distributed in the hope that it will be useful, but WITHOUT
  217.20 +*  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
  217.21 +*  or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
  217.22 +*  License for more details.
  217.23 +*
  217.24 +*  You should have received a copy of the GNU General Public License
  217.25 +*  along with GLPK. If not, see <http://www.gnu.org/licenses/>.
  217.26 +***********************************************************************/
  217.27 +
  217.28 +#include "glpapi.h"
  217.29 +#include "glpgmp.h"
  217.30 +
  217.31 +struct csa
  217.32 +{     /* common storage area */
  217.33 +      glp_prob *prob;
  217.34 +      /* LP/MIP problem object */
  217.35 +      glp_bfcp bfcp;
  217.36 +      /* basis factorization control parameters */
  217.37 +      glp_smcp smcp;
  217.38 +      /* simplex method control parameters */
  217.39 +      glp_iptcp iptcp;
  217.40 +      /* interior-point method control parameters */
  217.41 +      glp_iocp iocp;
  217.42 +      /* integer optimizer control parameters */
  217.43 +      glp_tran *tran;
  217.44 +      /* model translator workspace */
  217.45 +      glp_graph *graph;
  217.46 +      /* network problem object */
  217.47 +      int format;
  217.48 +      /* problem file format: */
  217.49 +#define FMT_MPS_DECK    1  /* fixed MPS */
  217.50 +#define FMT_MPS_FILE    2  /* free MPS */
  217.51 +#define FMT_LP          3  /* CPLEX LP */
  217.52 +#define FMT_GLP         4  /* GLPK LP/MIP */
  217.53 +#define FMT_MATHPROG    5  /* MathProg */
  217.54 +#define FMT_MIN_COST    6  /* DIMACS min-cost flow */
  217.55 +#define FMT_MAX_FLOW    7  /* DIMACS maximum flow */
  217.56 +#if 1 /* 06/VIII-2011 */
  217.57 +#define FMT_CNF         8  /* DIMACS CNF-SAT */
  217.58 +#endif
  217.59 +      const char *in_file;
  217.60 +      /* name of input problem file */
  217.61 +#define DATA_MAX 10
  217.62 +      /* maximal number of input data files */
  217.63 +      int ndf;
  217.64 +      /* number of input data files specified */
  217.65 +      const char *in_data[1+DATA_MAX];
  217.66 +      /* name(s) of input data file(s) */
  217.67 +      const char *out_dpy;
  217.68 +      /* name of output file to send display output; NULL means the
  217.69 +         display output is sent to the terminal */
  217.70 +      int seed;
  217.71 +      /* seed value to be passed to the MathProg translator; initially
  217.72 +         set to 1; 0x80000000 means the value is omitted */
  217.73 +      int solution;
  217.74 +      /* solution type flag: */
  217.75 +#define SOL_BASIC       1  /* basic */
  217.76 +#define SOL_INTERIOR    2  /* interior-point */
  217.77 +#define SOL_INTEGER     3  /* mixed integer */
  217.78 +      const char *in_res;
  217.79 +      /* name of input solution file in raw format */
  217.80 +      int dir;
  217.81 +      /* optimization direction flag:
  217.82 +         0       - not specified
  217.83 +         GLP_MIN - minimization
  217.84 +         GLP_MAX - maximization */
  217.85 +      int scale;
  217.86 +      /* automatic problem scaling flag */
  217.87 +      const char *out_sol;
  217.88 +      /* name of output solution file in printable format */
  217.89 +      const char *out_res;
  217.90 +      /* name of output solution file in raw format */
  217.91 +      const char *out_ranges;
  217.92 +      /* name of output file to write sensitivity analysis report */
  217.93 +      int check;
  217.94 +      /* input data checking flag; no solution is performed */
  217.95 +      const char *new_name;
  217.96 +      /* new name to be assigned to the problem */
  217.97 +      const char *out_mps;
  217.98 +      /* name of output problem file in fixed MPS format */
  217.99 +      const char *out_freemps;
 217.100 +      /* name of output problem file in free MPS format */
 217.101 +      const char *out_cpxlp;
 217.102 +      /* name of output problem file in CPLEX LP format */
 217.103 +      const char *out_glp;
 217.104 +      /* name of output problem file in GLPK format */
 217.105 +      const char *out_pb;
 217.106 +      /* name of output problem file in OPB format */
 217.107 +      const char *out_npb;
 217.108 +      /* name of output problem file in normalized OPB format */
 217.109 +#if 1 /* 06/VIII-2011 */
 217.110 +      const char *out_cnf;
 217.111 +      /* name of output problem file in DIMACS CNF-SAT format */
 217.112 +#endif
 217.113 +      const char *log_file;
 217.114 +      /* name of output file to hardcopy terminal output */
 217.115 +      int crash;
 217.116 +      /* initial basis option: */
 217.117 +#define USE_STD_BASIS   1  /* use standard basis */
 217.118 +#define USE_ADV_BASIS   2  /* use advanced basis */
 217.119 +#define USE_CPX_BASIS   3  /* use Bixby's basis */
 217.120 +#define USE_INI_BASIS   4  /* use initial basis from ini_file */
 217.121 +      const char *ini_file;
 217.122 +      /* name of input file containing initial basis */
 217.123 +      int exact;
 217.124 +      /* flag to use glp_exact rather than glp_simplex */
 217.125 +      int xcheck;
 217.126 +      /* flag to check final basis with glp_exact */
 217.127 +      int nomip;
 217.128 +      /* flag to consider MIP as pure LP */
 217.129 +#if 1 /* 15/VIII-2011 */
 217.130 +      int minisat;
 217.131 +      /* option to solve feasibility problem with MiniSat solver */
 217.132 +      int use_bnd;
 217.133 +      /* option to bound objective function */
 217.134 +      int obj_bnd;
 217.135 +      /* upper (minization) or lower (maximization) objective bound */
 217.136 +#endif
 217.137 +};
 217.138 +
 217.139 +static void print_help(const char *my_name)
 217.140 +{     /* print help information */
 217.141 +      xprintf("Usage: %s [options...] filename\n", my_name);
 217.142 +      xprintf("\n");
 217.143 +      xprintf("General options:\n");
 217.144 +      xprintf("   --mps             read LP/MIP problem in fixed MPS fo"
 217.145 +         "rmat\n");
 217.146 +      xprintf("   --freemps         read LP/MIP problem in free MPS for"
 217.147 +         "mat (default)\n");
 217.148 +      xprintf("   --lp              read LP/MIP problem in CPLEX LP for"
 217.149 +         "mat\n");
 217.150 +      xprintf("   --glp             read LP/MIP problem in GLPK format "
 217.151 +         "\n");
 217.152 +      xprintf("   --math            read LP/MIP model written in GNU Ma"
 217.153 +         "thProg modeling\n");
 217.154 +      xprintf("                     language\n");
 217.155 +      xprintf("   -m filename, --model filename\n");
 217.156 +      xprintf("                     read model section and optional dat"
 217.157 +         "a section from\n");
 217.158 +      xprintf("                     filename (same as --math)\n");
 217.159 +      xprintf("   -d filename, --data filename\n");
 217.160 +      xprintf("                     read data section from filename (fo"
 217.161 +         "r --math only);\n");
 217.162 +      xprintf("                     if model file also has data section"
 217.163 +         ", it is ignored\n");
 217.164 +      xprintf("   -y filename, --display filename\n");
 217.165 +      xprintf("                     send display output to filename (fo"
 217.166 +         "r --math only);\n");
 217.167 +      xprintf("                     by default the output is sent to te"
 217.168 +         "rminal\n");
 217.169 +      xprintf("   --seed value      initialize pseudo-random number gen"
 217.170 +         "erator used in\n");
 217.171 +      xprintf("                     MathProg model with specified seed "
 217.172 +         "(any integer);\n");
 217.173 +      xprintf("                     if seed value is ?, some random see"
 217.174 +         "d will be used\n");
 217.175 +      xprintf("   --mincost         read min-cost flow problem in DIMAC"
 217.176 +         "S format\n");
 217.177 +      xprintf("   --maxflow         read maximum flow problem in DIMACS"
 217.178 +         " format\n");
 217.179 +#if 1 /* 06/VIII-2011 */
 217.180 +      xprintf("   --cnf             read CNF-SAT problem in DIMACS form"
 217.181 +         "at\n");
 217.182 +#endif
 217.183 +      xprintf("   --simplex         use simplex method (default)\n");
 217.184 +      xprintf("   --interior        use interior point method (LP only)"
 217.185 +         "\n");
 217.186 +      xprintf("   -r filename, --read filename\n");
 217.187 +      xprintf("                     read solution from filename rather "
 217.188 +         "to find it with\n");
 217.189 +      xprintf("                     the solver\n");
 217.190 +      xprintf("   --min             minimization\n");
 217.191 +      xprintf("   --max             maximization\n");
 217.192 +      xprintf("   --scale           scale problem (default)\n");
 217.193 +      xprintf("   --noscale         do not scale problem\n");
 217.194 +      xprintf("   -o filename, --output filename\n");
 217.195 +      xprintf("                     write solution to filename in print"
 217.196 +         "able format\n");
 217.197 +      xprintf("   -w filename, --write filename\n");
 217.198 +      xprintf("                     write solution to filename in plain"
 217.199 +         " text format\n");
 217.200 +      xprintf("   --ranges filename\n");
 217.201 +      xprintf("                     write sensitivity analysis report t"
 217.202 +         "o filename in\n");
 217.203 +      xprintf("                     printable format (simplex only)\n");
 217.204 +      xprintf("   --tmlim nnn       limit solution time to nnn seconds "
 217.205 +         "\n");
 217.206 +      xprintf("   --memlim nnn      limit available memory to nnn megab"
 217.207 +         "ytes\n");
 217.208 +      xprintf("   --check           do not solve problem, check input d"
 217.209 +         "ata only\n");
 217.210 +      xprintf("   --name probname   change problem name to probname\n");
 217.211 +      xprintf("   --wmps filename   write problem to filename in fixed "
 217.212 +         "MPS format\n");
 217.213 +      xprintf("   --wfreemps filename\n");
 217.214 +      xprintf("                     write problem to filename in free M"
 217.215 +         "PS format\n");
 217.216 +      xprintf("   --wlp filename    write problem to filename in CPLEX "
 217.217 +         "LP format\n");
 217.218 +      xprintf("   --wglp filename   write problem to filename in GLPK f"
 217.219 +         "ormat\n");
 217.220 +#if 0
 217.221 +      xprintf("   --wpb filename    write problem to filename in OPB fo"
 217.222 +         "rmat\n");
 217.223 +      xprintf("   --wnpb filename   write problem to filename in normal"
 217.224 +         "ized OPB format\n");
 217.225 +#endif
 217.226 +#if 1 /* 06/VIII-2011 */
 217.227 +      xprintf("   --wcnf filename   write problem to filename in DIMACS"
 217.228 +         " CNF-SAT format\n");
 217.229 +#endif
 217.230 +      xprintf("   --log filename    write copy of terminal output to fi"
 217.231 +         "lename\n");
 217.232 +      xprintf("   -h, --help        display this help information and e"
 217.233 +         "xit\n");
 217.234 +      xprintf("   -v, --version     display program version and exit\n")
 217.235 +         ;
 217.236 +      xprintf("\n");
 217.237 +      xprintf("LP basis factorization options:\n");
 217.238 +      xprintf("   --luf             LU + Forrest-Tomlin update\n");
 217.239 +      xprintf("                     (faster, less stable; default)\n");
 217.240 +      xprintf("   --cbg             LU + Schur complement + Bartels-Gol"
 217.241 +         "ub update\n");
 217.242 +      xprintf("                     (slower, more stable)\n");
 217.243 +      xprintf("   --cgr             LU + Schur complement + Givens rota"
 217.244 +         "tion update\n");
 217.245 +      xprintf("                     (slower, more stable)\n");
 217.246 +      xprintf("\n");
 217.247 +      xprintf("Options specific to simplex solver:\n");
 217.248 +      xprintf("   --primal          use primal simplex (default)\n");
 217.249 +      xprintf("   --dual            use dual simplex\n");
 217.250 +      xprintf("   --std             use standard initial basis of all s"
 217.251 +         "lacks\n");
 217.252 +      xprintf("   --adv             use advanced initial basis (default"
 217.253 +         ")\n");
 217.254 +      xprintf("   --bib             use Bixby's initial basis\n");
 217.255 +      xprintf("   --ini filename    use as initial basis previously sav"
 217.256 +         "ed with -w\n");
 217.257 +      xprintf("                     (disables LP presolver)\n");
 217.258 +      xprintf("   --steep           use steepest edge technique (defaul"
 217.259 +         "t)\n");
 217.260 +      xprintf("   --nosteep         use standard \"textbook\" pricing\n"
 217.261 +         );
 217.262 +      xprintf("   --relax           use Harris' two-pass ratio test (de"
 217.263 +         "fault)\n");
 217.264 +      xprintf("   --norelax         use standard \"textbook\" ratio tes"
 217.265 +         "t\n");
 217.266 +      xprintf("   --presol          use presolver (default; assumes --s"
 217.267 +         "cale and --adv)\n");
 217.268 +      xprintf("   --nopresol        do not use presolver\n");
 217.269 +      xprintf("   --exact           use simplex method based on exact a"
 217.270 +         "rithmetic\n");
 217.271 +      xprintf("   --xcheck          check final basis using exact arith"
 217.272 +         "metic\n");
 217.273 +      xprintf("\n");
 217.274 +      xprintf("Options specific to interior-point solver:\n");
 217.275 +      xprintf("   --nord            use natural (original) ordering\n");
 217.276 +      xprintf("   --qmd             use quotient minimum degree orderin"
 217.277 +         "g\n");
 217.278 +      xprintf("   --amd             use approximate minimum degree orde"
 217.279 +         "ring (default)\n");
 217.280 +      xprintf("   --symamd          use approximate minimum degree orde"
 217.281 +         "ring\n");
 217.282 +      xprintf("\n");
 217.283 +      xprintf("Options specific to MIP solver:\n");
 217.284 +      xprintf("   --nomip           consider all integer variables as c"
 217.285 +         "ontinuous\n");
 217.286 +      xprintf("                     (allows solving MIP as pure LP)\n");
 217.287 +      xprintf("   --first           branch on first integer variable\n")
 217.288 +         ;
 217.289 +      xprintf("   --last            branch on last integer variable\n");
 217.290 +      xprintf("   --mostf           branch on most fractional variable "
 217.291 +         "\n");
 217.292 +      xprintf("   --drtom           branch using heuristic by Driebeck "
 217.293 +         "and Tomlin\n");
 217.294 +      xprintf("                     (default)\n");
 217.295 +      xprintf("   --pcost           branch using hybrid pseudocost heur"
 217.296 +         "istic (may be\n");
 217.297 +      xprintf("                     useful for hard instances)\n");
 217.298 +      xprintf("   --dfs             backtrack using depth first search "
 217.299 +         "\n");
 217.300 +      xprintf("   --bfs             backtrack using breadth first searc"
 217.301 +         "h\n");
 217.302 +      xprintf("   --bestp           backtrack using the best projection"
 217.303 +         " heuristic\n");
 217.304 +      xprintf("   --bestb           backtrack using node with best loca"
 217.305 +         "l bound\n");
 217.306 +      xprintf("                     (default)\n");
 217.307 +      xprintf("   --intopt          use MIP presolver (default)\n");
 217.308 +      xprintf("   --nointopt        do not use MIP presolver\n");
 217.309 +      xprintf("   --binarize        replace general integer variables b"
 217.310 +         "y binary ones\n");
 217.311 +      xprintf("                     (assumes --intopt)\n");
 217.312 +      xprintf("   --fpump           apply feasibility pump heuristic\n")
 217.313 +         ;
 217.314 +      xprintf("   --gomory          generate Gomory's mixed integer cut"
 217.315 +         "s\n");
 217.316 +      xprintf("   --mir             generate MIR (mixed integer roundin"
 217.317 +         "g) cuts\n");
 217.318 +      xprintf("   --cover           generate mixed cover cuts\n");
 217.319 +      xprintf("   --clique          generate clique cuts\n");
 217.320 +      xprintf("   --cuts            generate all cuts above\n");
 217.321 +      xprintf("   --mipgap tol      set relative mip gap tolerance to t"
 217.322 +         "ol\n");
 217.323 +#if 1 /* 15/VIII-2011 */
 217.324 +      xprintf("   --minisat         translate integer feasibility probl"
 217.325 +         "em to CNF-SAT\n");
 217.326 +      xprintf("                     and solve it with MiniSat solver\n")
 217.327 +         ;
 217.328 +      xprintf("   --objbnd bound    add inequality obj <= bound (minimi"
 217.329 +         "zation) or\n");
 217.330 +      xprintf("                     obj >= bound (maximization) to inte"
 217.331 +         "ger feasibility\n");
 217.332 +      xprintf("                     problem (assumes --minisat)\n");
 217.333 +#endif
 217.334 +      xprintf("\n");
 217.335 +      xprintf("For description of the MPS and CPLEX LP formats see Refe"
 217.336 +         "rence Manual.\n");
 217.337 +      xprintf("For description of the modeling language see \"GLPK: Mod"
 217.338 +         "eling Language\n");
 217.339 +      xprintf("GNU MathProg\". Both documents are included in the GLPK "
 217.340 +         "distribution.\n");
 217.341 +      xprintf("\n");
 217.342 +      xprintf("See GLPK web page at <http://www.gnu.org/software/glpk/g"
 217.343 +         "lpk.html>.\n");
 217.344 +      xprintf("\n");
 217.345 +      xprintf("Please report bugs to <bug-glpk@gnu.org>.\n");
 217.346 +      return;
 217.347 +}
 217.348 +
 217.349 +static void print_version(int briefly)
 217.350 +{     /* print version information */
 217.351 +      xprintf("GLPSOL: GLPK LP/MIP Solver, v%s\n", glp_version());
 217.352 +      if (briefly) goto done;
 217.353 +      xprintf("\n");
 217.354 +      xprintf("Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2006, "
 217.355 +         "2007, 2008,\n");
 217.356 +      xprintf("2009, 2010, 2011 Andrew Makhorin, Department for Applied"
 217.357 +         " Informatics,\n");
 217.358 +      xprintf("Moscow Aviation Institute, Moscow, Russia. All rights re"
 217.359 +         "served.\n");
 217.360 +      xprintf("\n");
 217.361 +      xprintf("This program has ABSOLUTELY NO WARRANTY.\n");
 217.362 +      xprintf("\n");
 217.363 +      xprintf("This program is free software; you may re-distribute it "
 217.364 +         "under the terms\n");
 217.365 +      xprintf("of the GNU General Public License version 3 or later.\n")
 217.366 +         ;
 217.367 +done: return;
 217.368 +}
 217.369 +
 217.370 +static int parse_cmdline(struct csa *csa, int argc, const char *argv[])
 217.371 +{     /* parse command-line parameters */
 217.372 +      int k;
 217.373 +#define p(str) (strcmp(argv[k], str) == 0)
 217.374 +      for (k = 1; k < argc; k++)
 217.375 +      {  if (p("--mps"))
 217.376 +            csa->format = FMT_MPS_DECK;
 217.377 +         else if (p("--freemps"))
 217.378 +            csa->format = FMT_MPS_FILE;
 217.379 +         else if (p("--lp") || p("--cpxlp"))
 217.380 +            csa->format = FMT_LP;
 217.381 +         else if (p("--glp"))
 217.382 +            csa->format = FMT_GLP;
 217.383 +         else if (p("--math") || p("-m") || p("--model"))
 217.384 +            csa->format = FMT_MATHPROG;
 217.385 +         else if (p("-d") || p("--data"))
 217.386 +         {  k++;
 217.387 +            if (k == argc || argv[k][0] == '\0' || argv[k][0] == '-')
 217.388 +            {  xprintf("No input data file specified\n");
 217.389 +               return 1;
 217.390 +            }
 217.391 +            if (csa->ndf == DATA_MAX)
 217.392 +            {  xprintf("Too many input data files\n");
 217.393 +               return 1;
 217.394 +            }
 217.395 +            csa->in_data[++(csa->ndf)] = argv[k];
 217.396 +         }
 217.397 +         else if (p("-y") || p("--display"))
 217.398 +         {  k++;
 217.399 +            if (k == argc || argv[k][0] == '\0' || argv[k][0] == '-')
 217.400 +            {  xprintf("No display output file specified\n");
 217.401 +               return 1;
 217.402 +            }
 217.403 +            if (csa->out_dpy != NULL)
 217.404 +            {  xprintf("Only one display output file allowed\n");
 217.405 +               return 1;
 217.406 +            }
 217.407 +            csa->out_dpy = argv[k];
 217.408 +         }
 217.409 +         else if (p("--seed"))
 217.410 +         {  k++;
 217.411 +            if (k == argc || argv[k][0] == '\0' ||
 217.412 +               argv[k][0] == '-' && !isdigit((unsigned char)argv[k][1]))
 217.413 +            {  xprintf("No seed value specified\n");
 217.414 +               return 1;
 217.415 +            }
 217.416 +            if (strcmp(argv[k], "?") == 0)
 217.417 +               csa->seed = 0x80000000;
 217.418 +            else if (str2int(argv[k], &csa->seed))
 217.419 +            {  xprintf("Invalid seed value `%s'\n", argv[k]);
 217.420 +               return 1;
 217.421 +            }
 217.422 +         }
 217.423 +         else if (p("--mincost"))
 217.424 +            csa->format = FMT_MIN_COST;
 217.425 +         else if (p("--maxflow"))
 217.426 +            csa->format = FMT_MAX_FLOW;
 217.427 +#if 1 /* 06/VIII-2011 */
 217.428 +         else if (p("--cnf"))
 217.429 +            csa->format = FMT_CNF;
 217.430 +#endif
 217.431 +         else if (p("--simplex"))
 217.432 +            csa->solution = SOL_BASIC;
 217.433 +         else if (p("--interior"))
 217.434 +            csa->solution = SOL_INTERIOR;
 217.435 +#if 1 /* 28/V-2010 */
 217.436 +         else if (p("--alien"))
 217.437 +            csa->iocp.alien = GLP_ON;
 217.438 +#endif
 217.439 +         else if (p("-r") || p("--read"))
 217.440 +         {  k++;
 217.441 +            if (k == argc || argv[k][0] == '\0' || argv[k][0] == '-')
 217.442 +            {  xprintf("No input solution file specified\n");
 217.443 +               return 1;
 217.444 +            }
 217.445 +            if (csa->in_res != NULL)
 217.446 +            {  xprintf("Only one input solution file allowed\n");
 217.447 +               return 1;
 217.448 +            }
 217.449 +            csa->in_res = argv[k];
 217.450 +         }
 217.451 +         else if (p("--min"))
 217.452 +            csa->dir = GLP_MIN;
 217.453 +         else if (p("--max"))
 217.454 +            csa->dir = GLP_MAX;
 217.455 +         else if (p("--scale"))
 217.456 +            csa->scale = 1;
 217.457 +         else if (p("--noscale"))
 217.458 +            csa->scale = 0;
 217.459 +         else if (p("-o") || p("--output"))
 217.460 +         {  k++;
 217.461 +            if (k == argc || argv[k][0] == '\0' || argv[k][0] == '-')
 217.462 +            {  xprintf("No output solution file specified\n");
 217.463 +               return 1;
 217.464 +            }
 217.465 +            if (csa->out_sol != NULL)
 217.466 +            {  xprintf("Only one output solution file allowed\n");
 217.467 +               return 1;
 217.468 +            }
 217.469 +            csa->out_sol = argv[k];
 217.470 +         }
 217.471 +         else if (p("-w") || p("--write"))
 217.472 +         {  k++;
 217.473 +            if (k == argc || argv[k][0] == '\0' || argv[k][0] == '-')
 217.474 +            {  xprintf("No output solution file specified\n");
 217.475 +               return 1;
 217.476 +            }
 217.477 +            if (csa->out_res != NULL)
 217.478 +            {  xprintf("Only one output solution file allowed\n");
 217.479 +               return 1;
 217.480 +            }
 217.481 +            csa->out_res = argv[k];
 217.482 +         }
 217.483 +         else if (p("--ranges") || p("--bounds"))
 217.484 +         {  k++;
 217.485 +            if (k == argc || argv[k][0] == '\0' || argv[k][0] == '-')
 217.486 +            {  xprintf("No output file specified to write sensitivity a"
 217.487 +                  "nalysis report\n");
 217.488 +               return 1;
 217.489 +            }
 217.490 +            if (csa->out_ranges != NULL)
 217.491 +            {  xprintf("Only one output file allowed to write sensitivi"
 217.492 +                  "ty analysis report\n");
 217.493 +               return 1;
 217.494 +            }
 217.495 +            csa->out_ranges = argv[k];
 217.496 +         }
 217.497 +         else if (p("--tmlim"))
 217.498 +         {  int tm_lim;
 217.499 +            k++;
 217.500 +            if (k == argc || argv[k][0] == '\0' || argv[k][0] == '-')
 217.501 +            {  xprintf("No time limit specified\n");
 217.502 +               return 1;
 217.503 +            }
 217.504 +            if (str2int(argv[k], &tm_lim) || tm_lim < 0)
 217.505 +            {  xprintf("Invalid time limit `%s'\n", argv[k]);
 217.506 +               return 1;
 217.507 +            }
 217.508 +            if (tm_lim <= INT_MAX / 1000)
 217.509 +               csa->smcp.tm_lim = csa->iocp.tm_lim = 1000 * tm_lim;
 217.510 +            else
 217.511 +               csa->smcp.tm_lim = csa->iocp.tm_lim = INT_MAX;
 217.512 +         }
 217.513 +         else if (p("--memlim"))
 217.514 +         {  int mem_lim;
 217.515 +            k++;
 217.516 +            if (k == argc || argv[k][0] == '\0' || argv[k][0] == '-')
 217.517 +            {  xprintf("No memory limit specified\n");
 217.518 +               return 1;
 217.519 +            }
 217.520 +            if (str2int(argv[k], &mem_lim) || mem_lim < 1)
 217.521 +            {  xprintf("Invalid memory limit `%s'\n", argv[k]);
 217.522 +               return 1;
 217.523 +            }
 217.524 +            glp_mem_limit(mem_lim);
 217.525 +         }
 217.526 +         else if (p("--check"))
 217.527 +            csa->check = 1;
 217.528 +         else if (p("--name"))
 217.529 +         {  k++;
 217.530 +            if (k == argc || argv[k][0] == '\0' || argv[k][0] == '-')
 217.531 +            {  xprintf("No problem name specified\n");
 217.532 +               return 1;
 217.533 +            }
 217.534 +            if (csa->new_name != NULL)
 217.535 +            {  xprintf("Only one problem name allowed\n");
 217.536 +               return 1;
 217.537 +            }
 217.538 +            csa->new_name = argv[k];
 217.539 +         }
 217.540 +         else if (p("--wmps"))
 217.541 +         {  k++;
 217.542 +            if (k == argc || argv[k][0] == '\0' || argv[k][0] == '-')
 217.543 +            {  xprintf("No fixed MPS output file specified\n");
 217.544 +               return 1;
 217.545 +            }
 217.546 +            if (csa->out_mps != NULL)
 217.547 +            {  xprintf("Only one fixed MPS output file allowed\n");
 217.548 +               return 1;
 217.549 +            }
 217.550 +            csa->out_mps = argv[k];
 217.551 +         }
 217.552 +         else if (p("--wfreemps"))
 217.553 +         {  k++;
 217.554 +            if (k == argc || argv[k][0] == '\0' || argv[k][0] == '-')
 217.555 +            {  xprintf("No free MPS output file specified\n");
 217.556 +               return 1;
 217.557 +            }
 217.558 +            if (csa->out_freemps != NULL)
 217.559 +            {  xprintf("Only one free MPS output file allowed\n");
 217.560 +               return 1;
 217.561 +            }
 217.562 +            csa->out_freemps = argv[k];
 217.563 +         }
 217.564 +         else if (p("--wlp") || p("--wcpxlp") || p("--wlpt"))
 217.565 +         {  k++;
 217.566 +            if (k == argc || argv[k][0] == '\0' || argv[k][0] == '-')
 217.567 +            {  xprintf("No CPLEX LP output file specified\n");
 217.568 +               return 1;
 217.569 +            }
 217.570 +            if (csa->out_cpxlp != NULL)
 217.571 +            {  xprintf("Only one CPLEX LP output file allowed\n");
 217.572 +               return 1;
 217.573 +            }
 217.574 +            csa->out_cpxlp = argv[k];
 217.575 +         }
 217.576 +         else if (p("--wglp"))
 217.577 +         {  k++;
 217.578 +            if (k == argc || argv[k][0] == '\0' || argv[k][0] == '-')
 217.579 +            {  xprintf("No GLPK LP/MIP output file specified\n");
 217.580 +               return 1;
 217.581 +            }
 217.582 +            if (csa->out_glp != NULL)
 217.583 +            {  xprintf("Only one GLPK LP/MIP output file allowed\n");
 217.584 +               return 1;
 217.585 +            }
 217.586 +            csa->out_glp = argv[k];
 217.587 +         }
 217.588 +         else if (p("--wpb"))
 217.589 +         {  k++;
 217.590 +            if (k == argc || argv[k][0] == '\0' || argv[k][0] == '-')
 217.591 +            {  xprintf("No problem output file specified\n");
 217.592 +               return 1;
 217.593 +            }
 217.594 +            if (csa->out_pb != NULL)
 217.595 +            {  xprintf("Only one OPB output file allowed\n");
 217.596 +               return 1;
 217.597 +            }
 217.598 +            csa->out_pb = argv[k];
 217.599 +         }
 217.600 +         else if (p("--wnpb"))
 217.601 +         {  k++;
 217.602 +            if (k == argc || argv[k][0] == '\0' || argv[k][0] == '-')
 217.603 +            {  xprintf("No problem output file specified\n");
 217.604 +               return 1;
 217.605 +            }
 217.606 +            if (csa->out_npb != NULL)
 217.607 +            {  xprintf("Only one normalized OPB output file allowed\n");
 217.608 +               return 1;
 217.609 +            }
 217.610 +            csa->out_npb = argv[k];
 217.611 +         }
 217.612 +#if 1 /* 06/VIII-2011 */
 217.613 +         else if (p("--wcnf"))
 217.614 +         {  k++;
 217.615 +            if (k == argc || argv[k][0] == '\0' || argv[k][0] == '-')
 217.616 +            {  xprintf("No problem output file specified\n");
 217.617 +               return 1;
 217.618 +            }
 217.619 +            if (csa->out_cnf != NULL)
 217.620 +            {  xprintf("Only one output DIMACS CNF-SAT file allowed\n");
 217.621 +               return 1;
 217.622 +            }
 217.623 +            csa->out_cnf = argv[k];
 217.624 +         }
 217.625 +#endif
 217.626 +         else if (p("--log"))
 217.627 +         {  k++;
 217.628 +            if (k == argc || argv[k][0] == '\0' || argv[k][0] == '-')
 217.629 +            {  xprintf("No log file specified\n");
 217.630 +               return 1;
 217.631 +            }
 217.632 +            if (csa->log_file != NULL)
 217.633 +            {  xprintf("Only one log file allowed\n");
 217.634 +               return 1;
 217.635 +            }
 217.636 +            csa->log_file = argv[k];
 217.637 +         }
 217.638 +         else if (p("-h") || p("--help"))
 217.639 +         {  print_help(argv[0]);
 217.640 +            return -1;
 217.641 +         }
 217.642 +         else if (p("-v") || p("--version"))
 217.643 +         {  print_version(0);
 217.644 +            return -1;
 217.645 +         }
 217.646 +         else if (p("--luf"))
 217.647 +            csa->bfcp.type = GLP_BF_FT;
 217.648 +         else if (p("--cbg"))
 217.649 +            csa->bfcp.type = GLP_BF_BG;
 217.650 +         else if (p("--cgr"))
 217.651 +            csa->bfcp.type = GLP_BF_GR;
 217.652 +         else if (p("--primal"))
 217.653 +            csa->smcp.meth = GLP_PRIMAL;
 217.654 +         else if (p("--dual"))
 217.655 +            csa->smcp.meth = GLP_DUAL;
 217.656 +         else if (p("--std"))
 217.657 +            csa->crash = USE_STD_BASIS;
 217.658 +         else if (p("--adv"))
 217.659 +            csa->crash = USE_ADV_BASIS;
 217.660 +         else if (p("--bib"))
 217.661 +            csa->crash = USE_CPX_BASIS;
 217.662 +         else if (p("--ini"))
 217.663 +         {  csa->crash = USE_INI_BASIS;
 217.664 +            csa->smcp.presolve = GLP_OFF;
 217.665 +            k++;
 217.666 +            if (k == argc || argv[k][0] == '\0' || argv[k][0] == '-')
 217.667 +            {  xprintf("No initial basis file specified\n");
 217.668 +               return 1;
 217.669 +            }
 217.670 +            if (csa->ini_file != NULL)
 217.671 +            {  xprintf("Only one initial basis file allowed\n");
 217.672 +               return 1;
 217.673 +            }
 217.674 +            csa->ini_file = argv[k];
 217.675 +         }
 217.676 +         else if (p("--steep"))
 217.677 +            csa->smcp.pricing = GLP_PT_PSE;
 217.678 +         else if (p("--nosteep"))
 217.679 +            csa->smcp.pricing = GLP_PT_STD;
 217.680 +         else if (p("--relax"))
 217.681 +            csa->smcp.r_test = GLP_RT_HAR;
 217.682 +         else if (p("--norelax"))
 217.683 +            csa->smcp.r_test = GLP_RT_STD;
 217.684 +         else if (p("--presol"))
 217.685 +            csa->smcp.presolve = GLP_ON;
 217.686 +         else if (p("--nopresol"))
 217.687 +            csa->smcp.presolve = GLP_OFF;
 217.688 +         else if (p("--exact"))
 217.689 +            csa->exact = 1;
 217.690 +         else if (p("--xcheck"))
 217.691 +            csa->xcheck = 1;
 217.692 +         else if (p("--nord"))
 217.693 +            csa->iptcp.ord_alg = GLP_ORD_NONE;
 217.694 +         else if (p("--qmd"))
 217.695 +            csa->iptcp.ord_alg = GLP_ORD_QMD;
 217.696 +         else if (p("--amd"))
 217.697 +            csa->iptcp.ord_alg = GLP_ORD_AMD;
 217.698 +         else if (p("--symamd"))
 217.699 +            csa->iptcp.ord_alg = GLP_ORD_SYMAMD;
 217.700 +         else if (p("--nomip"))
 217.701 +            csa->nomip = 1;
 217.702 +         else if (p("--first"))
 217.703 +            csa->iocp.br_tech = GLP_BR_FFV;
 217.704 +         else if (p("--last"))
 217.705 +            csa->iocp.br_tech = GLP_BR_LFV;
 217.706 +         else if (p("--drtom"))
 217.707 +            csa->iocp.br_tech = GLP_BR_DTH;
 217.708 +         else if (p("--mostf"))
 217.709 +            csa->iocp.br_tech = GLP_BR_MFV;
 217.710 +         else if (p("--pcost"))
 217.711 +            csa->iocp.br_tech = GLP_BR_PCH;
 217.712 +         else if (p("--dfs"))
 217.713 +            csa->iocp.bt_tech = GLP_BT_DFS;
 217.714 +         else if (p("--bfs"))
 217.715 +            csa->iocp.bt_tech = GLP_BT_BFS;
 217.716 +         else if (p("--bestp"))
 217.717 +            csa->iocp.bt_tech = GLP_BT_BPH;
 217.718 +         else if (p("--bestb"))
 217.719 +            csa->iocp.bt_tech = GLP_BT_BLB;
 217.720 +         else if (p("--intopt"))
 217.721 +            csa->iocp.presolve = GLP_ON;
 217.722 +         else if (p("--nointopt"))
 217.723 +            csa->iocp.presolve = GLP_OFF;
 217.724 +         else if (p("--binarize"))
 217.725 +            csa->iocp.presolve = csa->iocp.binarize = GLP_ON;
 217.726 +         else if (p("--fpump"))
 217.727 +            csa->iocp.fp_heur = GLP_ON;
 217.728 +         else if (p("--gomory"))
 217.729 +            csa->iocp.gmi_cuts = GLP_ON;
 217.730 +         else if (p("--mir"))
 217.731 +            csa->iocp.mir_cuts = GLP_ON;
 217.732 +         else if (p("--cover"))
 217.733 +            csa->iocp.cov_cuts = GLP_ON;
 217.734 +         else if (p("--clique"))
 217.735 +            csa->iocp.clq_cuts = GLP_ON;
 217.736 +         else if (p("--cuts"))
 217.737 +            csa->iocp.gmi_cuts = csa->iocp.mir_cuts =
 217.738 +            csa->iocp.cov_cuts = csa->iocp.clq_cuts = GLP_ON;
 217.739 +         else if (p("--mipgap"))
 217.740 +         {  double mip_gap;
 217.741 +            k++;
 217.742 +            if (k == argc || argv[k][0] == '\0' || argv[k][0] == '-')
 217.743 +            {  xprintf("No relative gap tolerance specified\n");
 217.744 +               return 1;
 217.745 +            }
 217.746 +            if (str2num(argv[k], &mip_gap) || mip_gap < 0.0)
 217.747 +            {  xprintf("Invalid relative mip gap tolerance `%s'\n",
 217.748 +                  argv[k]);
 217.749 +               return 1;
 217.750 +            }
 217.751 +            csa->iocp.mip_gap = mip_gap;
 217.752 +         }
 217.753 +#if 1 /* 15/VIII-2011 */
 217.754 +         else if (p("--minisat"))
 217.755 +            csa->minisat = 1;
 217.756 +         else if (p("--objbnd"))
 217.757 +         {  k++;
 217.758 +            if (k == argc || argv[k][0] == '\0' ||
 217.759 +               argv[k][0] == '-' && !isdigit((unsigned char)argv[k][1]))
 217.760 +            {  xprintf("No objective bound specified\n");
 217.761 +               return 1;
 217.762 +            }
 217.763 +            csa->minisat = 1;
 217.764 +            csa->use_bnd = 1;
 217.765 +            if (str2int(argv[k], &csa->obj_bnd))
 217.766 +            {  xprintf("Invalid objective bound `%s' (should be integer"
 217.767 +                  " value)\n", argv[k]);
 217.768 +               return 1;
 217.769 +            }
 217.770 +         }
 217.771 +#endif
 217.772 +         else if (argv[k][0] == '-' ||
 217.773 +                 (argv[k][0] == '-' && argv[k][1] == '-'))
 217.774 +         {  xprintf("Invalid option `%s'; try %s --help\n",
 217.775 +               argv[k], argv[0]);
 217.776 +            return 1;
 217.777 +         }
 217.778 +         else
 217.779 +         {  if (csa->in_file != NULL)
 217.780 +            {  xprintf("Only one input problem file allowed\n");
 217.781 +               return 1;
 217.782 +            }
 217.783 +            csa->in_file = argv[k];
 217.784 +         }
 217.785 +      }
 217.786 +#undef p
 217.787 +      return 0;
 217.788 +}
 217.789 +
 217.790 +typedef struct { double rhs, pi; } v_data;
 217.791 +typedef struct { double low, cap, cost, x; } a_data;
 217.792 +
 217.793 +int glp_main(int argc, const char *argv[])
 217.794 +{     /* stand-alone LP/MIP solver */
 217.795 +      struct csa _csa, *csa = &_csa;
 217.796 +      int ret;
 217.797 +      glp_long start;
 217.798 +      /* perform initialization */
 217.799 +      csa->prob = glp_create_prob();
 217.800 +      glp_get_bfcp(csa->prob, &csa->bfcp);
 217.801 +      glp_init_smcp(&csa->smcp);
 217.802 +      csa->smcp.presolve = GLP_ON;
 217.803 +      glp_init_iptcp(&csa->iptcp);
 217.804 +      glp_init_iocp(&csa->iocp);
 217.805 +      csa->iocp.presolve = GLP_ON;
 217.806 +      csa->tran = NULL;
 217.807 +      csa->graph = NULL;
 217.808 +      csa->format = FMT_MPS_FILE;
 217.809 +      csa->in_file = NULL;
 217.810 +      csa->ndf = 0;
 217.811 +      csa->out_dpy = NULL;
 217.812 +      csa->seed = 1;
 217.813 +      csa->solution = SOL_BASIC;
 217.814 +      csa->in_res = NULL;
 217.815 +      csa->dir = 0;
 217.816 +      csa->scale = 1;
 217.817 +      csa->out_sol = NULL;
 217.818 +      csa->out_res = NULL;
 217.819 +      csa->out_ranges = NULL;
 217.820 +      csa->check = 0;
 217.821 +      csa->new_name = NULL;
 217.822 +      csa->out_mps = NULL;
 217.823 +      csa->out_freemps = NULL;
 217.824 +      csa->out_cpxlp = NULL;
 217.825 +      csa->out_glp = NULL;
 217.826 +      csa->out_pb = NULL;
 217.827 +      csa->out_npb = NULL;
 217.828 +#if 1 /* 06/VIII-2011 */
 217.829 +      csa->out_cnf = NULL;
 217.830 +#endif
 217.831 +      csa->log_file = NULL;
 217.832 +      csa->crash = USE_ADV_BASIS;
 217.833 +      csa->ini_file = NULL;
 217.834 +      csa->exact = 0;
 217.835 +      csa->xcheck = 0;
 217.836 +      csa->nomip = 0;
 217.837 +#if 1 /* 15/VIII-2011 */
 217.838 +      csa->minisat = 0;
 217.839 +      csa->use_bnd = 0;
 217.840 +      csa->obj_bnd = 0;
 217.841 +#endif
 217.842 +      /* parse command-line parameters */
 217.843 +      ret = parse_cmdline(csa, argc, argv);
 217.844 +      if (ret < 0)
 217.845 +      {  ret = EXIT_SUCCESS;
 217.846 +         goto done;
 217.847 +      }
 217.848 +      if (ret > 0)
 217.849 +      {  ret = EXIT_FAILURE;
 217.850 +         goto done;
 217.851 +      }
 217.852 +      /*--------------------------------------------------------------*/
 217.853 +      /* remove all output files specified in the command line */
 217.854 +      if (csa->out_dpy != NULL) remove(csa->out_dpy);
 217.855 +      if (csa->out_sol != NULL) remove(csa->out_sol);
 217.856 +      if (csa->out_res != NULL) remove(csa->out_res);
 217.857 +      if (csa->out_ranges != NULL) remove(csa->out_ranges);
 217.858 +      if (csa->out_mps != NULL) remove(csa->out_mps);
 217.859 +      if (csa->out_freemps != NULL) remove(csa->out_freemps);
 217.860 +      if (csa->out_cpxlp != NULL) remove(csa->out_cpxlp);
 217.861 +      if (csa->out_glp != NULL) remove(csa->out_glp);
 217.862 +      if (csa->out_pb != NULL) remove(csa->out_pb);
 217.863 +      if (csa->out_npb != NULL) remove(csa->out_npb);
 217.864 +#if 1 /* 06/VIII-2011 */
 217.865 +      if (csa->out_cnf != NULL) remove(csa->out_cnf);
 217.866 +#endif
 217.867 +      if (csa->log_file != NULL) remove(csa->log_file);
 217.868 +      /*--------------------------------------------------------------*/
 217.869 +      /* open log file, if required */
 217.870 +      if (csa->log_file != NULL)
 217.871 +      {  if (glp_open_tee(csa->log_file))
 217.872 +         {  xprintf("Unable to create log file\n");
 217.873 +            ret = EXIT_FAILURE;
 217.874 +            goto done;
 217.875 +         }
 217.876 +      }
 217.877 +      /*--------------------------------------------------------------*/
 217.878 +      /* print version information */
 217.879 +      print_version(1);
 217.880 +      /*--------------------------------------------------------------*/
 217.881 +      /* print parameters specified in the command line */
 217.882 +      if (argc > 1)
 217.883 +      {  int k, len = INT_MAX;
 217.884 +         xprintf("Parameter(s) specified in the command line:");
 217.885 +         for (k = 1; k < argc; k++)
 217.886 +         {  if (len > 72)
 217.887 +               xprintf("\n"), len = 0;
 217.888 +            xprintf(" %s", argv[k]);
 217.889 +            len += 1 + strlen(argv[k]);
 217.890 +         }
 217.891 +         xprintf("\n");
 217.892 +      }
 217.893 +      /*--------------------------------------------------------------*/
 217.894 +      /* read problem data from the input file */
 217.895 +      if (csa->in_file == NULL)
 217.896 +      {  xprintf("No input problem file specified; try %s --help\n",
 217.897 +            argv[0]);
 217.898 +         ret = EXIT_FAILURE;
 217.899 +         goto done;
 217.900 +      }
 217.901 +      if (csa->format == FMT_MPS_DECK)
 217.902 +      {  ret = glp_read_mps(csa->prob, GLP_MPS_DECK, NULL,
 217.903 +            csa->in_file);
 217.904 +         if (ret != 0)
 217.905 +err1:    {  xprintf("MPS file processing error\n");
 217.906 +            ret = EXIT_FAILURE;
 217.907 +            goto done;
 217.908 +         }
 217.909 +      }
 217.910 +      else if (csa->format == FMT_MPS_FILE)
 217.911 +      {  ret = glp_read_mps(csa->prob, GLP_MPS_FILE, NULL,
 217.912 +            csa->in_file);
 217.913 +         if (ret != 0) goto err1;
 217.914 +      }
 217.915 +      else if (csa->format == FMT_LP)
 217.916 +      {  ret = glp_read_lp(csa->prob, NULL, csa->in_file);
 217.917 +         if (ret != 0)
 217.918 +         {  xprintf("CPLEX LP file processing error\n");
 217.919 +            ret = EXIT_FAILURE;
 217.920 +            goto done;
 217.921 +         }
 217.922 +      }
 217.923 +      else if (csa->format == FMT_GLP)
 217.924 +      {  ret = glp_read_prob(csa->prob, 0, csa->in_file);
 217.925 +         if (ret != 0)
 217.926 +         {  xprintf("GLPK LP/MIP file processing error\n");
 217.927 +            ret = EXIT_FAILURE;
 217.928 +            goto done;
 217.929 +         }
 217.930 +      }
 217.931 +      else if (csa->format == FMT_MATHPROG)
 217.932 +      {  int k;
 217.933 +         /* allocate the translator workspace */
 217.934 +         csa->tran = glp_mpl_alloc_wksp();
 217.935 +         /* set seed value */
 217.936 +         if (csa->seed == 0x80000000)
 217.937 +         {  csa->seed = glp_time().lo;
 217.938 +            xprintf("Seed value %d will be used\n", csa->seed);
 217.939 +         }
 217.940 +         _glp_mpl_init_rand(csa->tran, csa->seed);
 217.941 +         /* read model section and optional data section */
 217.942 +         if (glp_mpl_read_model(csa->tran, csa->in_file, csa->ndf > 0))
 217.943 +err2:    {  xprintf("MathProg model processing error\n");
 217.944 +            ret = EXIT_FAILURE;
 217.945 +            goto done;
 217.946 +         }
 217.947 +         /* read optional data section(s), if necessary */
 217.948 +         for (k = 1; k <= csa->ndf; k++)
 217.949 +         {  if (glp_mpl_read_data(csa->tran, csa->in_data[k]))
 217.950 +               goto err2;
 217.951 +         }
 217.952 +         /* generate the model */
 217.953 +         if (glp_mpl_generate(csa->tran, csa->out_dpy)) goto err2;
 217.954 +         /* build the problem instance from the model */
 217.955 +         glp_mpl_build_prob(csa->tran, csa->prob);
 217.956 +      }
 217.957 +      else if (csa->format == FMT_MIN_COST)
 217.958 +      {  csa->graph = glp_create_graph(sizeof(v_data), sizeof(a_data));
 217.959 +         ret = glp_read_mincost(csa->graph, offsetof(v_data, rhs),
 217.960 +            offsetof(a_data, low), offsetof(a_data, cap),
 217.961 +            offsetof(a_data, cost), csa->in_file);
 217.962 +         if (ret != 0)
 217.963 +         {  xprintf("DIMACS file processing error\n");
 217.964 +            ret = EXIT_FAILURE;
 217.965 +            goto done;
 217.966 +         }
 217.967 +         glp_mincost_lp(csa->prob, csa->graph, GLP_ON,
 217.968 +            offsetof(v_data, rhs), offsetof(a_data, low),
 217.969 +            offsetof(a_data, cap), offsetof(a_data, cost));
 217.970 +         glp_set_prob_name(csa->prob, csa->in_file);
 217.971 +      }
 217.972 +      else if (csa->format == FMT_MAX_FLOW)
 217.973 +      {  int s, t;
 217.974 +         csa->graph = glp_create_graph(sizeof(v_data), sizeof(a_data));
 217.975 +         ret = glp_read_maxflow(csa->graph, &s, &t,
 217.976 +            offsetof(a_data, cap), csa->in_file);
 217.977 +         if (ret != 0)
 217.978 +         {  xprintf("DIMACS file processing error\n");
 217.979 +            ret = EXIT_FAILURE;
 217.980 +            goto done;
 217.981 +         }
 217.982 +         glp_maxflow_lp(csa->prob, csa->graph, GLP_ON, s, t,
 217.983 +            offsetof(a_data, cap));
 217.984 +         glp_set_prob_name(csa->prob, csa->in_file);
 217.985 +      }
 217.986 +#if 1 /* 06/VIII-2011 */
 217.987 +      else if (csa->format == FMT_CNF)
 217.988 +      {  ret = glp_read_cnfsat(csa->prob, csa->in_file);
 217.989 +         if (ret != 0)
 217.990 +         {  xprintf("DIMACS file processing error\n");
 217.991 +            ret = EXIT_FAILURE;
 217.992 +            goto done;
 217.993 +         }
 217.994 +         glp_set_prob_name(csa->prob, csa->in_file);
 217.995 +      }
 217.996 +#endif
 217.997 +      else
 217.998 +         xassert(csa != csa);
 217.999 +      /*--------------------------------------------------------------*/
217.1000 +      /* change problem name, if required */
217.1001 +      if (csa->new_name != NULL)
217.1002 +         glp_set_prob_name(csa->prob, csa->new_name);
217.1003 +      /* change optimization direction, if required */
217.1004 +      if (csa->dir != 0)
217.1005 +         glp_set_obj_dir(csa->prob, csa->dir);
217.1006 +      /* sort elements of the constraint matrix */
217.1007 +      glp_sort_matrix(csa->prob);
217.1008 +      /*--------------------------------------------------------------*/
217.1009 +      /* write problem data in fixed MPS format, if required */
217.1010 +      if (csa->out_mps != NULL)
217.1011 +      {  ret = glp_write_mps(csa->prob, GLP_MPS_DECK, NULL,
217.1012 +            csa->out_mps);
217.1013 +         if (ret != 0)
217.1014 +         {  xprintf("Unable to write problem in fixed MPS format\n");
217.1015 +            ret = EXIT_FAILURE;
217.1016 +            goto done;
217.1017 +         }
217.1018 +      }
217.1019 +      /* write problem data in free MPS format, if required */
217.1020 +      if (csa->out_freemps != NULL)
217.1021 +      {  ret = glp_write_mps(csa->prob, GLP_MPS_FILE, NULL,
217.1022 +            csa->out_freemps);
217.1023 +         if (ret != 0)
217.1024 +         {  xprintf("Unable to write problem in free MPS format\n");
217.1025 +            ret = EXIT_FAILURE;
217.1026 +            goto done;
217.1027 +         }
217.1028 +      }
217.1029 +      /* write problem data in CPLEX LP format, if required */
217.1030 +      if (csa->out_cpxlp != NULL)
217.1031 +      {  ret = glp_write_lp(csa->prob, NULL, csa->out_cpxlp);
217.1032 +         if (ret != 0)
217.1033 +         {  xprintf("Unable to write problem in CPLEX LP format\n");
217.1034 +            ret = EXIT_FAILURE;
217.1035 +            goto done;
217.1036 +         }
217.1037 +      }
217.1038 +      /* write problem data in GLPK format, if required */
217.1039 +      if (csa->out_glp != NULL)
217.1040 +      {  ret = glp_write_prob(csa->prob, 0, csa->out_glp);
217.1041 +         if (ret != 0)
217.1042 +         {  xprintf("Unable to write problem in GLPK format\n");
217.1043 +            ret = EXIT_FAILURE;
217.1044 +            goto done;
217.1045 +         }
217.1046 +      }
217.1047 +      /* write problem data in OPB format, if required */
217.1048 +      if (csa->out_pb != NULL)
217.1049 +      {  ret = lpx_write_pb(csa->prob, csa->out_pb, 0, 0);
217.1050 +         if (ret != 0)
217.1051 +         {  xprintf("Unable to write problem in OPB format\n");
217.1052 +            ret = EXIT_FAILURE;
217.1053 +            goto done;
217.1054 +         }
217.1055 +      }
217.1056 +      /* write problem data in normalized OPB format, if required */
217.1057 +      if (csa->out_npb != NULL)
217.1058 +      {  ret = lpx_write_pb(csa->prob, csa->out_npb, 1, 1);
217.1059 +         if (ret != 0)
217.1060 +         {  xprintf(
217.1061 +               "Unable to write problem in normalized OPB format\n");
217.1062 +            ret = EXIT_FAILURE;
217.1063 +            goto done;
217.1064 +         }
217.1065 +      }
217.1066 +#if 1 /* 06/VIII-2011 */
217.1067 +      /* write problem data in DIMACS CNF-SAT format, if required */
217.1068 +      if (csa->out_cnf != NULL)
217.1069 +      {  ret = glp_write_cnfsat(csa->prob, csa->out_cnf);
217.1070 +         if (ret != 0)
217.1071 +         {  xprintf(
217.1072 +               "Unable to write problem in DIMACS CNF-SAT format\n");
217.1073 +            ret = EXIT_FAILURE;
217.1074 +            goto done;
217.1075 +         }
217.1076 +      }
217.1077 +#endif
217.1078 +      /*--------------------------------------------------------------*/
217.1079 +      /* if only problem data check is required, skip computations */
217.1080 +      if (csa->check)
217.1081 +      {  ret = EXIT_SUCCESS;
217.1082 +         goto done;
217.1083 +      }
217.1084 +      /*--------------------------------------------------------------*/
217.1085 +      /* determine the solution type */
217.1086 +      if (!csa->nomip &&
217.1087 +          glp_get_num_int(csa->prob) + glp_get_num_bin(csa->prob) > 0)
217.1088 +      {  if (csa->solution == SOL_INTERIOR)
217.1089 +         {  xprintf("Interior-point method is not able to solve MIP pro"
217.1090 +               "blem; use --simplex\n");
217.1091 +            ret = EXIT_FAILURE;
217.1092 +            goto done;
217.1093 +         }
217.1094 +         csa->solution = SOL_INTEGER;
217.1095 +      }
217.1096 +      /*--------------------------------------------------------------*/
217.1097 +      /* if solution is provided, read it and skip computations */
217.1098 +      if (csa->in_res != NULL)
217.1099 +      {  if (csa->solution == SOL_BASIC)
217.1100 +            ret = glp_read_sol(csa->prob, csa->in_res);
217.1101 +         else if (csa->solution == SOL_INTERIOR)
217.1102 +            ret = glp_read_ipt(csa->prob, csa->in_res);
217.1103 +         else if (csa->solution == SOL_INTEGER)
217.1104 +            ret = glp_read_mip(csa->prob, csa->in_res);
217.1105 +         else
217.1106 +            xassert(csa != csa);
217.1107 +         if (ret != 0)
217.1108 +         {  xprintf("Unable to read problem solution\n");
217.1109 +            ret = EXIT_FAILURE;
217.1110 +            goto done;
217.1111 +         }
217.1112 +         goto skip;
217.1113 +      }
217.1114 +      /*--------------------------------------------------------------*/
217.1115 +      /* scale the problem data, if required */
217.1116 +      if (csa->scale)
217.1117 +      {  if (csa->solution == SOL_BASIC && !csa->smcp.presolve ||
217.1118 +             csa->solution == SOL_INTERIOR ||
217.1119 +             csa->solution == SOL_INTEGER && !csa->iocp.presolve)
217.1120 +            glp_scale_prob(csa->prob, GLP_SF_AUTO);
217.1121 +      }
217.1122 +      /*--------------------------------------------------------------*/
217.1123 +      /* construct starting LP basis */
217.1124 +      if (csa->solution == SOL_BASIC && !csa->smcp.presolve ||
217.1125 +          csa->solution == SOL_INTEGER && !csa->iocp.presolve)
217.1126 +      {  if (csa->crash == USE_STD_BASIS)
217.1127 +            glp_std_basis(csa->prob);
217.1128 +         else if (csa->crash == USE_ADV_BASIS)
217.1129 +            glp_adv_basis(csa->prob, 0);
217.1130 +         else if (csa->crash == USE_CPX_BASIS)
217.1131 +            glp_cpx_basis(csa->prob);
217.1132 +         else if (csa->crash == USE_INI_BASIS)
217.1133 +         {  ret = glp_read_sol(csa->prob, csa->ini_file);
217.1134 +            if (ret != 0)
217.1135 +            {  xprintf("Unable to read initial basis\n");
217.1136 +               ret = EXIT_FAILURE;
217.1137 +               goto done;
217.1138 +            }
217.1139 +         }
217.1140 +         else
217.1141 +            xassert(csa != csa);
217.1142 +      }
217.1143 +      /*--------------------------------------------------------------*/
217.1144 +      /* solve the problem */
217.1145 +      start = xtime();
217.1146 +      if (csa->solution == SOL_BASIC)
217.1147 +      {  if (!csa->exact)
217.1148 +         {  glp_set_bfcp(csa->prob, &csa->bfcp);
217.1149 +            glp_simplex(csa->prob, &csa->smcp);
217.1150 +            if (csa->xcheck)
217.1151 +            {  if (csa->smcp.presolve &&
217.1152 +                   glp_get_status(csa->prob) != GLP_OPT)
217.1153 +                  xprintf("If you need to check final basis for non-opt"
217.1154 +                     "imal solution, use --nopresol\n");
217.1155 +               else
217.1156 +                  glp_exact(csa->prob, &csa->smcp);
217.1157 +            }
217.1158 +            if (csa->out_sol != NULL || csa->out_res != NULL)
217.1159 +            {  if (csa->smcp.presolve &&
217.1160 +                   glp_get_status(csa->prob) != GLP_OPT)
217.1161 +               xprintf("If you need actual output for non-optimal solut"
217.1162 +                  "ion, use --nopresol\n");
217.1163 +            }
217.1164 +         }
217.1165 +         else
217.1166 +            glp_exact(csa->prob, &csa->smcp);
217.1167 +      }
217.1168 +      else if (csa->solution == SOL_INTERIOR)
217.1169 +         glp_interior(csa->prob, &csa->iptcp);
217.1170 +#if 1 /* 15/VIII-2011 */
217.1171 +      else if (csa->solution == SOL_INTEGER && csa->minisat)
217.1172 +      {  if (glp_check_cnfsat(csa->prob) == 0)
217.1173 +            glp_minisat1(csa->prob);
217.1174 +         else
217.1175 +            glp_intfeas1(csa->prob, csa->use_bnd, csa->obj_bnd);
217.1176 +      }
217.1177 +#endif
217.1178 +      else if (csa->solution == SOL_INTEGER)
217.1179 +      {  if (!csa->iocp.presolve)
217.1180 +         {  glp_set_bfcp(csa->prob, &csa->bfcp);
217.1181 +            glp_simplex(csa->prob, &csa->smcp);
217.1182 +         }
217.1183 +#if 0
217.1184 +         csa->iocp.msg_lev = GLP_MSG_DBG;
217.1185 +         csa->iocp.pp_tech = GLP_PP_NONE;
217.1186 +#endif
217.1187 +         glp_intopt(csa->prob, &csa->iocp);
217.1188 +      }
217.1189 +      else
217.1190 +         xassert(csa != csa);
217.1191 +      /*--------------------------------------------------------------*/
217.1192 +      /* display statistics */
217.1193 +      xprintf("Time used:   %.1f secs\n", xdifftime(xtime(), start));
217.1194 +      {  glp_long tpeak;
217.1195 +         char buf[50];
217.1196 +         glp_mem_usage(NULL, NULL, NULL, &tpeak);
217.1197 +         xprintf("Memory used: %.1f Mb (%s bytes)\n",
217.1198 +            xltod(tpeak) / 1048576.0, xltoa(tpeak, buf));
217.1199 +      }
217.1200 +      /*--------------------------------------------------------------*/
217.1201 +skip: /* postsolve the model, if necessary */
217.1202 +      if (csa->tran != NULL)
217.1203 +      {  if (csa->solution == SOL_BASIC)
217.1204 +         {  if (!(glp_get_status(csa->prob) == GLP_OPT ||
217.1205 +                  glp_get_status(csa->prob) == GLP_FEAS))
217.1206 +               ret = -1;
217.1207 +            else
217.1208 +               ret = glp_mpl_postsolve(csa->tran, csa->prob, GLP_SOL);
217.1209 +         }
217.1210 +         else if (csa->solution == SOL_INTERIOR)
217.1211 +         {  if (!(glp_ipt_status(csa->prob) == GLP_OPT ||
217.1212 +                  glp_ipt_status(csa->prob) == GLP_FEAS))
217.1213 +               ret = -1;
217.1214 +            else
217.1215 +               ret = glp_mpl_postsolve(csa->tran, csa->prob, GLP_IPT);
217.1216 +         }
217.1217 +         else if (csa->solution == SOL_INTEGER)
217.1218 +         {  if (!(glp_mip_status(csa->prob) == GLP_OPT ||
217.1219 +                  glp_mip_status(csa->prob) == GLP_FEAS))
217.1220 +               ret = -1;
217.1221 +            else
217.1222 +               ret = glp_mpl_postsolve(csa->tran, csa->prob, GLP_MIP);
217.1223 +         }
217.1224 +         else
217.1225 +            xassert(csa != csa);
217.1226 +         if (ret > 0)
217.1227 +         {  xprintf("Model postsolving error\n");
217.1228 +            ret = EXIT_FAILURE;
217.1229 +            goto done;
217.1230 +         }
217.1231 +      }
217.1232 +      /*--------------------------------------------------------------*/
217.1233 +      /* write problem solution in printable format, if required */
217.1234 +      if (csa->out_sol != NULL)
217.1235 +      {  if (csa->solution == SOL_BASIC)
217.1236 +            ret = lpx_print_sol(csa->prob, csa->out_sol);
217.1237 +         else if (csa->solution == SOL_INTERIOR)
217.1238 +            ret = lpx_print_ips(csa->prob, csa->out_sol);
217.1239 +         else if (csa->solution == SOL_INTEGER)
217.1240 +            ret = lpx_print_mip(csa->prob, csa->out_sol);
217.1241 +         else
217.1242 +            xassert(csa != csa);
217.1243 +         if (ret != 0)
217.1244 +         {  xprintf("Unable to write problem solution\n");
217.1245 +            ret = EXIT_FAILURE;
217.1246 +            goto done;
217.1247 +         }
217.1248 +      }
217.1249 +      /* write problem solution in printable format, if required */
217.1250 +      if (csa->out_res != NULL)
217.1251 +      {  if (csa->solution == SOL_BASIC)
217.1252 +            ret = glp_write_sol(csa->prob, csa->out_res);
217.1253 +         else if (csa->solution == SOL_INTERIOR)
217.1254 +            ret = glp_write_ipt(csa->prob, csa->out_res);
217.1255 +         else if (csa->solution == SOL_INTEGER)
217.1256 +            ret = glp_write_mip(csa->prob, csa->out_res);
217.1257 +         else
217.1258 +            xassert(csa != csa);
217.1259 +         if (ret != 0)
217.1260 +         {  xprintf("Unable to write problem solution\n");
217.1261 +            ret = EXIT_FAILURE;
217.1262 +            goto done;
217.1263 +         }
217.1264 +      }
217.1265 +      /* write sensitivity analysis report, if required */
217.1266 +      if (csa->out_ranges != NULL)
217.1267 +      {  if (csa->solution == SOL_BASIC)
217.1268 +         {  if (glp_get_status(csa->prob) == GLP_OPT)
217.1269 +            {  if (glp_bf_exists(csa->prob))
217.1270 +ranges:        {  ret = glp_print_ranges(csa->prob, 0, NULL, 0,
217.1271 +                     csa->out_ranges);
217.1272 +                  if (ret != 0)
217.1273 +                  {  xprintf("Unable to write sensitivity analysis repo"
217.1274 +                        "rt\n");
217.1275 +                     ret = EXIT_FAILURE;
217.1276 +                     goto done;
217.1277 +                  }
217.1278 +               }
217.1279 +               else
217.1280 +               {  ret = glp_factorize(csa->prob);
217.1281 +                  if (ret == 0) goto ranges;
217.1282 +                  xprintf("Cannot produce sensitivity analysis report d"
217.1283 +                     "ue to error in basis factorization (glp_factorize"
217.1284 +                     " returned %d); try --nopresol\n", ret);
217.1285 +               }
217.1286 +            }
217.1287 +            else
217.1288 +               xprintf("Cannot produce sensitivity analysis report for "
217.1289 +                  "non-optimal basic solution\n");
217.1290 +         }
217.1291 +         else
217.1292 +            xprintf("Cannot produce sensitivity analysis report for int"
217.1293 +               "erior-point or MIP solution\n");
217.1294 +      }
217.1295 +      /*--------------------------------------------------------------*/
217.1296 +      /* all seems to be ok */
217.1297 +      ret = EXIT_SUCCESS;
217.1298 +      /*--------------------------------------------------------------*/
217.1299 +done: /* delete the LP/MIP problem object */
217.1300 +      if (csa->prob != NULL)
217.1301 +         glp_delete_prob(csa->prob);
217.1302 +      /* free the translator workspace, if necessary */
217.1303 +      if (csa->tran != NULL)
217.1304 +         glp_mpl_free_wksp(csa->tran);
217.1305 +      /* delete the network problem object, if necessary */
217.1306 +      if (csa->graph != NULL)
217.1307 +         glp_delete_graph(csa->graph);
217.1308 +      xassert(gmp_pool_count() == 0);
217.1309 +      gmp_free_mem();
217.1310 +      /* close log file, if necessary */
217.1311 +      if (csa->log_file != NULL) glp_close_tee();
217.1312 +      /* check that no memory blocks are still allocated */
217.1313 +      {  int count;
217.1314 +         glp_long total;
217.1315 +         glp_mem_usage(&count, NULL, &total, NULL);
217.1316 +         if (count != 0)
217.1317 +            xerror("Error: %d memory block(s) were lost\n", count);
217.1318 +         xassert(count == 0);
217.1319 +         xassert(total.lo == 0 && total.hi == 0);
217.1320 +      }
217.1321 +      /* free the GLPK environment */
217.1322 +      glp_free_env();
217.1323 +      /* return to the control program */
217.1324 +      return ret;
217.1325 +}
217.1326 +
217.1327 +/* eof */
   218.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
   218.2 +++ b/deps/glpk/src/glpavl.c	Sun Nov 06 20:59:10 2011 +0100
   218.3 @@ -0,0 +1,357 @@
   218.4 +/* glpavl.c (binary search tree) */
   218.5 +
   218.6 +/***********************************************************************
   218.7 +*  This code is part of GLPK (GNU Linear Programming Kit).
   218.8 +*
   218.9 +*  Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008,
  218.10 +*  2009, 2010, 2011 Andrew Makhorin, Department for Applied Informatics,
  218.11 +*  Moscow Aviation Institute, Moscow, Russia. All rights reserved.
  218.12 +*  E-mail: <mao@gnu.org>.
  218.13 +*
  218.14 +*  GLPK is free software: you can redistribute it and/or modify it
  218.15 +*  under the terms of the GNU General Public License as published by
  218.16 +*  the Free Software Foundation, either version 3 of the License, or
  218.17 +*  (at your option) any later version.
  218.18 +*
  218.19 +*  GLPK is distributed in the hope that it will be useful, but WITHOUT
  218.20 +*  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
  218.21 +*  or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
  218.22 +*  License for more details.
  218.23 +*
  218.24 +*  You should have received a copy of the GNU General Public License
  218.25 +*  along with GLPK. If not, see <http://www.gnu.org/licenses/>.
  218.26 +***********************************************************************/
  218.27 +
  218.28 +#include "glpavl.h"
  218.29 +
  218.30 +AVL *avl_create_tree(int (*fcmp)(void *info, const void *key1,
  218.31 +      const void *key2), void *info)
  218.32 +{     /* create AVL tree */
  218.33 +      AVL *tree;
  218.34 +      tree = xmalloc(sizeof(AVL));
  218.35 +      tree->pool = dmp_create_pool();
  218.36 +      tree->root = NULL;
  218.37 +      tree->fcmp = fcmp;
  218.38 +      tree->info = info;
  218.39 +      tree->size = 0;
  218.40 +      tree->height = 0;
  218.41 +      return tree;
  218.42 +}
  218.43 +
  218.44 +int avl_strcmp(void *info, const void *key1, const void *key2)
  218.45 +{     /* compare character string keys */
  218.46 +      xassert(info == info);
  218.47 +      return strcmp(key1, key2);
  218.48 +}
  218.49 +
  218.50 +static AVLNODE *rotate_subtree(AVL *tree, AVLNODE *node);
  218.51 +
  218.52 +AVLNODE *avl_insert_node(AVL *tree, const void *key)
  218.53 +{     /* insert new node into AVL tree */
  218.54 +      AVLNODE *p, *q, *r;
  218.55 +      short int flag;
  218.56 +      /* find an appropriate point for insertion */
  218.57 +      p = NULL; q = tree->root;
  218.58 +      while (q != NULL)
  218.59 +      {  p = q;
  218.60 +         if (tree->fcmp(tree->info, key, p->key) <= 0)
  218.61 +         {  flag = 0;
  218.62 +            q = p->left;
  218.63 +            p->rank++;
  218.64 +         }
  218.65 +         else
  218.66 +         {  flag = 1;
  218.67 +            q = p->right;
  218.68 +         }
  218.69 +      }
  218.70 +      /* create new node and insert it into the tree */
  218.71 +      r = dmp_get_atom(tree->pool, sizeof(AVLNODE));
  218.72 +      r->key = key; r->type = 0; r->link = NULL;
  218.73 +      r->rank = 1; r->up = p;
  218.74 +      r->flag = (short int)(p == NULL ? 0 : flag);
  218.75 +      r->bal = 0; r->left = NULL; r->right = NULL;
  218.76 +      tree->size++;
  218.77 +      if (p == NULL)
  218.78 +         tree->root = r;
  218.79 +      else
  218.80 +         if (flag == 0) p->left = r; else p->right = r;
  218.81 +      /* go upstairs to the root and correct all subtrees affected by
  218.82 +         insertion */
  218.83 +      while (p != NULL)
  218.84 +      {  if (flag == 0)
  218.85 +         {  /* the height of the left subtree of [p] is increased */
  218.86 +            if (p->bal > 0)
  218.87 +            {  p->bal = 0;
  218.88 +               break;
  218.89 +            }
  218.90 +            if (p->bal < 0)
  218.91 +            {  rotate_subtree(tree, p);
  218.92 +               break;
  218.93 +            }
  218.94 +            p->bal = -1; flag = p->flag; p = p->up;
  218.95 +         }
  218.96 +         else
  218.97 +         {  /* the height of the right subtree of [p] is increased */
  218.98 +            if (p->bal < 0)
  218.99 +            {  p->bal = 0;
 218.100 +               break;
 218.101 +            }
 218.102 +            if (p->bal > 0)
 218.103 +            {  rotate_subtree(tree, p);
 218.104 +               break;
 218.105 +            }
 218.106 +            p->bal = +1; flag = p->flag; p = p->up;
 218.107 +         }
 218.108 +      }
 218.109 +      /* if the root has been reached, the height of the entire tree is
 218.110 +         increased */
 218.111 +      if (p == NULL) tree->height++;
 218.112 +      return r;
 218.113 +}
 218.114 +
 218.115 +void avl_set_node_type(AVLNODE *node, int type)
 218.116 +{     /* assign the type field of specified node */
 218.117 +      node->type = type;
 218.118 +      return;
 218.119 +}
 218.120 +
 218.121 +void avl_set_node_link(AVLNODE *node, void *link)
 218.122 +{     /* assign the link field of specified node */
 218.123 +      node->link = link;
 218.124 +      return;
 218.125 +}
 218.126 +
 218.127 +AVLNODE *avl_find_node(AVL *tree, const void *key)
 218.128 +{     /* find node in AVL tree */
 218.129 +      AVLNODE *p;
 218.130 +      int c;
 218.131 +      p = tree->root;
 218.132 +      while (p != NULL)
 218.133 +      {  c = tree->fcmp(tree->info, key, p->key);
 218.134 +         if (c == 0) break;
 218.135 +         p = (c < 0 ? p->left : p->right);
 218.136 +      }
 218.137 +      return p;
 218.138 +}
 218.139 +
 218.140 +int avl_get_node_type(AVLNODE *node)
 218.141 +{     /* retrieve the type field of specified node */
 218.142 +      return node->type;
 218.143 +}
 218.144 +
 218.145 +void *avl_get_node_link(AVLNODE *node)
 218.146 +{     /* retrieve the link field of specified node */
 218.147 +      return node->link;
 218.148 +}
 218.149 +
 218.150 +static AVLNODE *find_next_node(AVL *tree, AVLNODE *node)
 218.151 +{     /* find next node in AVL tree */
 218.152 +      AVLNODE *p, *q;
 218.153 +      if (tree->root == NULL) return NULL;
 218.154 +      p = node;
 218.155 +      q = (p == NULL ? tree->root : p->right);
 218.156 +      if (q == NULL)
 218.157 +      {  /* go upstairs from the left subtree */
 218.158 +         for (;;)
 218.159 +         {  q = p->up;
 218.160 +            if (q == NULL) break;
 218.161 +            if (p->flag == 0) break;
 218.162 +            p = q;
 218.163 +         }
 218.164 +      }
 218.165 +      else
 218.166 +      {  /* go downstairs into the right subtree */
 218.167 +         for (;;)
 218.168 +         {  p = q->left;
 218.169 +            if (p == NULL) break;
 218.170 +            q = p;
 218.171 +         }
 218.172 +      }
 218.173 +      return q;
 218.174 +}
 218.175 +
 218.176 +void avl_delete_node(AVL *tree, AVLNODE *node)
 218.177 +{     /* delete specified node from AVL tree */
 218.178 +      AVLNODE *f, *p, *q, *r, *s, *x, *y;
 218.179 +      short int flag;
 218.180 +      p = node;
 218.181 +      /* if both subtrees of the specified node are non-empty, the node
 218.182 +         should be interchanged with the next one, at least one subtree
 218.183 +         of which is always empty */
 218.184 +      if (p->left == NULL || p->right == NULL) goto skip;
 218.185 +      f = p->up; q = p->left;
 218.186 +      r = find_next_node(tree, p); s = r->right;
 218.187 +      if (p->right == r)
 218.188 +      {  if (f == NULL)
 218.189 +            tree->root = r;
 218.190 +         else
 218.191 +            if (p->flag == 0) f->left = r; else f->right = r;
 218.192 +         r->rank = p->rank; r->up = f;
 218.193 +         r->flag = p->flag; r->bal = p->bal;
 218.194 +         r->left = q; r->right = p;
 218.195 +         q->up = r;
 218.196 +         p->rank = 1; p->up = r; p->flag = 1;
 218.197 +         p->bal = (short int)(s == NULL ? 0 : +1);
 218.198 +         p->left = NULL; p->right = s;
 218.199 +         if (s != NULL) s->up = p;
 218.200 +      }
 218.201 +      else
 218.202 +      {  x = p->right; y = r->up;
 218.203 +         if (f == NULL)
 218.204 +            tree->root = r;
 218.205 +         else
 218.206 +            if (p->flag == 0) f->left = r; else f->right = r;
 218.207 +         r->rank = p->rank; r->up = f;
 218.208 +         r->flag = p->flag; r->bal = p->bal;
 218.209 +         r->left = q; r->right = x;
 218.210 +         q->up = r; x->up = r; y->left = p;
 218.211 +         p->rank = 1; p->up = y; p->flag = 0;
 218.212 +         p->bal = (short int)(s == NULL ? 0 : +1);
 218.213 +         p->left = NULL; p->right = s;
 218.214 +         if (s != NULL) s->up = p;
 218.215 +      }
 218.216 +skip: /* now the specified node [p] has at least one empty subtree;
 218.217 +         go upstairs to the root and adjust the rank field of all nodes
 218.218 +         affected by deletion */
 218.219 +      q = p; f = q->up;
 218.220 +      while (f != NULL)
 218.221 +      {  if (q->flag == 0) f->rank--;
 218.222 +         q = f; f = q->up;
 218.223 +      }
 218.224 +      /* delete the specified node from the tree */
 218.225 +      f = p->up; flag = p->flag;
 218.226 +      q = p->left != NULL ? p->left : p->right;
 218.227 +      if (f == NULL)
 218.228 +         tree->root = q;
 218.229 +      else
 218.230 +         if (flag == 0) f->left = q; else f->right = q;
 218.231 +      if (q != NULL) q->up = f, q->flag = flag;
 218.232 +      tree->size--;
 218.233 +      /* go upstairs to the root and correct all subtrees affected by
 218.234 +         deletion */
 218.235 +      while (f != NULL)
 218.236 +      {  if (flag == 0)
 218.237 +         {  /* the height of the left subtree of [f] is decreased */
 218.238 +            if (f->bal == 0)
 218.239 +            {  f->bal = +1;
 218.240 +               break;
 218.241 +            }
 218.242 +            if (f->bal < 0)
 218.243 +               f->bal = 0;
 218.244 +            else
 218.245 +            {  f = rotate_subtree(tree, f);
 218.246 +               if (f->bal < 0) break;
 218.247 +            }
 218.248 +            flag = f->flag; f = f->up;
 218.249 +         }
 218.250 +         else
 218.251 +         {  /* the height of the right subtree of [f] is decreased */
 218.252 +            if (f->bal == 0)
 218.253 +            {  f->bal = -1;
 218.254 +               break;
 218.255 +            }
 218.256 +            if (f->bal > 0)
 218.257 +               f->bal = 0;
 218.258 +            else
 218.259 +            {  f = rotate_subtree(tree, f);
 218.260 +               if (f->bal > 0) break;
 218.261 +            }
 218.262 +            flag = f->flag; f = f->up;
 218.263 +         }
 218.264 +      }
 218.265 +      /* if the root has been reached, the height of the entire tree is
 218.266 +         decreased */
 218.267 +      if (f == NULL) tree->height--;
 218.268 +      /* returns the deleted node to the memory pool */
 218.269 +      dmp_free_atom(tree->pool, p, sizeof(AVLNODE));
 218.270 +      return;
 218.271 +}
 218.272 +
 218.273 +static AVLNODE *rotate_subtree(AVL *tree, AVLNODE *node)
 218.274 +{     /* restore balance of AVL subtree */
 218.275 +      AVLNODE *f, *p, *q, *r, *x, *y;
 218.276 +      xassert(node != NULL);
 218.277 +      p = node;
 218.278 +      if (p->bal < 0)
 218.279 +      {  /* perform negative (left) rotation */
 218.280 +         f = p->up; q = p->left; r = q->right;
 218.281 +         if (q->bal <= 0)
 218.282 +         {  /* perform single negative rotation */
 218.283 +            if (f == NULL)
 218.284 +               tree->root = q;
 218.285 +            else
 218.286 +               if (p->flag == 0) f->left = q; else f->right = q;
 218.287 +            p->rank -= q->rank;
 218.288 +            q->up = f; q->flag = p->flag; q->bal++; q->right = p;
 218.289 +            p->up = q; p->flag = 1;
 218.290 +            p->bal = (short int)(-q->bal); p->left = r;
 218.291 +            if (r != NULL) r->up = p, r->flag = 0;
 218.292 +            node = q;
 218.293 +         }
 218.294 +         else
 218.295 +         {  /* perform double negative rotation */
 218.296 +            x = r->left; y = r->right;
 218.297 +            if (f == NULL)
 218.298 +               tree->root = r;
 218.299 +            else
 218.300 +               if (p->flag == 0) f->left = r; else f->right = r;
 218.301 +            p->rank -= (q->rank + r->rank);
 218.302 +            r->rank += q->rank;
 218.303 +            p->bal = (short int)(r->bal >= 0 ? 0 : +1);
 218.304 +            q->bal = (short int)(r->bal <= 0 ? 0 : -1);
 218.305 +            r->up = f; r->flag = p->flag; r->bal = 0;
 218.306 +            r->left = q; r->right = p;
 218.307 +            p->up = r; p->flag = 1; p->left = y;
 218.308 +            q->up = r; q->flag = 0; q->right = x;
 218.309 +            if (x != NULL) x->up = q, x->flag = 1;
 218.310 +            if (y != NULL) y->up = p, y->flag = 0;
 218.311 +            node = r;
 218.312 +         }
 218.313 +      }
 218.314 +      else
 218.315 +      {  /* perform positive (right) rotation */
 218.316 +         f = p->up; q = p->right; r = q->left;
 218.317 +         if (q->bal >= 0)
 218.318 +         {  /* perform single positive rotation */
 218.319 +            if (f == NULL)
 218.320 +               tree->root = q;
 218.321 +            else
 218.322 +               if (p->flag == 0) f->left = q; else f->right = q;
 218.323 +            q->rank += p->rank;
 218.324 +            q->up = f; q->flag = p->flag; q->bal--; q->left = p;
 218.325 +            p->up = q; p->flag = 0;
 218.326 +            p->bal = (short int)(-q->bal); p->right = r;
 218.327 +            if (r != NULL) r->up = p, r->flag = 1;
 218.328 +            node = q;
 218.329 +         }
 218.330 +         else
 218.331 +         {  /* perform double positive rotation */
 218.332 +            x = r->left; y = r->right;
 218.333 +            if (f == NULL)
 218.334 +               tree->root = r;
 218.335 +            else
 218.336 +               if (p->flag == 0) f->left = r; else f->right = r;
 218.337 +            q->rank -= r->rank;
 218.338 +            r->rank += p->rank;
 218.339 +            p->bal = (short int)(r->bal <= 0 ? 0 : -1);
 218.340 +            q->bal = (short int)(r->bal >= 0 ? 0 : +1);
 218.341 +            r->up = f; r->flag = p->flag; r->bal = 0;
 218.342 +            r->left = p; r->right = q;
 218.343 +            p->up = r; p->flag = 0; p->right = x;
 218.344 +            q->up = r; q->flag = 1; q->left = y;
 218.345 +            if (x != NULL) x->up = p, x->flag = 1;
 218.346 +            if (y != NULL) y->up = q, y->flag = 0;
 218.347 +            node = r;
 218.348 +         }
 218.349 +      }
 218.350 +      return node;
 218.351 +}
 218.352 +
 218.353 +void avl_delete_tree(AVL *tree)
 218.354 +{     /* delete AVL tree */
 218.355 +      dmp_delete_pool(tree->pool);
 218.356 +      xfree(tree);
 218.357 +      return;
 218.358 +}
 218.359 +
 218.360 +/* eof */
   219.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
   219.2 +++ b/deps/glpk/src/glpavl.h	Sun Nov 06 20:59:10 2011 +0100
   219.3 @@ -0,0 +1,123 @@
   219.4 +/* glpavl.h (binary search tree) */
   219.5 +
   219.6 +/***********************************************************************
   219.7 +*  This code is part of GLPK (GNU Linear Programming Kit).
   219.8 +*
   219.9 +*  Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008,
  219.10 +*  2009, 2010, 2011 Andrew Makhorin, Department for Applied Informatics,
  219.11 +*  Moscow Aviation Institute, Moscow, Russia. All rights reserved.
  219.12 +*  E-mail: <mao@gnu.org>.
  219.13 +*
  219.14 +*  GLPK is free software: you can redistribute it and/or modify it
  219.15 +*  under the terms of the GNU General Public License as published by
  219.16 +*  the Free Software Foundation, either version 3 of the License, or
  219.17 +*  (at your option) any later version.
  219.18 +*
  219.19 +*  GLPK is distributed in the hope that it will be useful, but WITHOUT
  219.20 +*  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
  219.21 +*  or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
  219.22 +*  License for more details.
  219.23 +*
  219.24 +*  You should have received a copy of the GNU General Public License
  219.25 +*  along with GLPK. If not, see <http://www.gnu.org/licenses/>.
  219.26 +***********************************************************************/
  219.27 +
  219.28 +#ifndef GLPAVL_H
  219.29 +#define GLPAVL_H
  219.30 +
  219.31 +#include "glpdmp.h"
  219.32 +
  219.33 +typedef struct AVL AVL;
  219.34 +typedef struct AVLNODE AVLNODE;
  219.35 +
  219.36 +struct AVL
  219.37 +{     /* AVL tree (Adelson-Velsky & Landis binary search tree) */
  219.38 +      DMP *pool;
  219.39 +      /* memory pool for allocating nodes */
  219.40 +      AVLNODE *root;
  219.41 +      /* pointer to the root node */
  219.42 +      int (*fcmp)(void *info, const void *key1, const void *key2);
  219.43 +      /* application-defined key comparison routine */
  219.44 +      void *info;
  219.45 +      /* transit pointer passed to the routine fcmp */
  219.46 +      int size;
  219.47 +      /* the tree size (the total number of nodes) */
  219.48 +      int height;
  219.49 +      /* the tree height */
  219.50 +};
  219.51 +
  219.52 +struct AVLNODE
  219.53 +{     /* node of AVL tree */
  219.54 +      const void *key;
  219.55 +      /* pointer to the node key (data structure for representing keys
  219.56 +         is supplied by the application) */
  219.57 +      int rank;
  219.58 +      /* node rank = relative position of the node in its own subtree =
  219.59 +         the number of nodes in the left subtree plus one */
  219.60 +      int type;
  219.61 +      /* reserved for the application specific information */
  219.62 +      void *link;
  219.63 +      /* reserved for the application specific information */
  219.64 +      AVLNODE *up;
  219.65 +      /* pointer to the parent node */
  219.66 +      short int flag;
  219.67 +      /* node flag:
  219.68 +         0 - this node is the left child of its parent (or this node is
  219.69 +             the root of the tree and has no parent)
  219.70 +         1 - this node is the right child of its parent */
  219.71 +      short int bal;
  219.72 +      /* node balance = the difference between heights of the right and
  219.73 +         left subtrees:
  219.74 +         -1 - the left subtree is higher than the right one;
  219.75 +          0 - the left and right subtrees have the same height;
  219.76 +         +1 - the left subtree is lower than the right one */
  219.77 +      AVLNODE *left;
  219.78 +      /* pointer to the root of the left subtree */
  219.79 +      AVLNODE *right;
  219.80 +      /* pointer to the root of the right subtree */
  219.81 +};
  219.82 +
  219.83 +#define avl_create_tree _glp_avl_create_tree
  219.84 +AVL *avl_create_tree(int (*fcmp)(void *info, const void *key1,
  219.85 +      const void *key2), void *info);
  219.86 +/* create AVL tree */
  219.87 +
  219.88 +#define avl_strcmp _glp_avl_strcmp
  219.89 +int avl_strcmp(void *info, const void *key1, const void *key2);
  219.90 +/* compare character string keys */
  219.91 +
  219.92 +#define avl_insert_node _glp_avl_insert_node
  219.93 +AVLNODE *avl_insert_node(AVL *tree, const void *key);
  219.94 +/* insert new node into AVL tree */
  219.95 +
  219.96 +#define avl_set_node_type _glp_avl_set_node_type
  219.97 +void avl_set_node_type(AVLNODE *node, int type);
  219.98 +/* assign the type field of specified node */
  219.99 +
 219.100 +#define avl_set_node_link _glp_avl_set_node_link
 219.101 +void avl_set_node_link(AVLNODE *node, void *link);
 219.102 +/* assign the link field of specified node */
 219.103 +
 219.104 +#define avl_find_node _glp_avl_find_node
 219.105 +AVLNODE *avl_find_node(AVL *tree, const void *key);
 219.106 +/* find node in AVL tree */
 219.107 +
 219.108 +#define avl_get_node_type _glp_avl_get_node_type
 219.109 +int avl_get_node_type(AVLNODE *node);
 219.110 +/* retrieve the type field of specified node */
 219.111 +
 219.112 +#define avl_get_node_link _glp_avl_get_node_link
 219.113 +void *avl_get_node_link(AVLNODE *node);
 219.114 +/* retrieve the link field of specified node */
 219.115 +
 219.116 +#define avl_delete_node _glp_avl_delete_node
 219.117 +void avl_delete_node(AVL *tree, AVLNODE *node);
 219.118 +/* delete specified node from AVL tree */
 219.119 +
 219.120 +#define avl_delete_tree _glp_avl_delete_tree
 219.121 +void avl_delete_tree(AVL *tree);
 219.122 +/* delete AVL tree */
 219.123 +
 219.124 +#endif
 219.125 +
 219.126 +/* eof */
   220.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
   220.2 +++ b/deps/glpk/src/glpbfd.c	Sun Nov 06 20:59:10 2011 +0100
   220.3 @@ -0,0 +1,481 @@
   220.4 +/* glpbfd.c (LP basis factorization driver) */
   220.5 +
   220.6 +/***********************************************************************
   220.7 +*  This code is part of GLPK (GNU Linear Programming Kit).
   220.8 +*
   220.9 +*  Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008,
  220.10 +*  2009, 2010, 2011 Andrew Makhorin, Department for Applied Informatics,
  220.11 +*  Moscow Aviation Institute, Moscow, Russia. All rights reserved.
  220.12 +*  E-mail: <mao@gnu.org>.
  220.13 +*
  220.14 +*  GLPK is free software: you can redistribute it and/or modify it
  220.15 +*  under the terms of the GNU General Public License as published by
  220.16 +*  the Free Software Foundation, either version 3 of the License, or
  220.17 +*  (at your option) any later version.
  220.18 +*
  220.19 +*  GLPK is distributed in the hope that it will be useful, but WITHOUT
  220.20 +*  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
  220.21 +*  or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
  220.22 +*  License for more details.
  220.23 +*
  220.24 +*  You should have received a copy of the GNU General Public License
  220.25 +*  along with GLPK. If not, see <http://www.gnu.org/licenses/>.
  220.26 +***********************************************************************/
  220.27 +
  220.28 +typedef struct BFD BFD;
  220.29 +
  220.30 +#define GLPBFD_PRIVATE
  220.31 +#include "glpapi.h"
  220.32 +#include "glpfhv.h"
  220.33 +#include "glplpf.h"
  220.34 +
  220.35 +/* CAUTION: DO NOT CHANGE THE LIMIT BELOW */
  220.36 +
  220.37 +#define M_MAX 100000000 /* = 100*10^6 */
  220.38 +/* maximal order of the basis matrix */
  220.39 +
  220.40 +struct BFD
  220.41 +{     /* LP basis factorization */
  220.42 +      int valid;
  220.43 +      /* factorization is valid only if this flag is set */
  220.44 +      int type;
  220.45 +      /* factorization type:
  220.46 +         GLP_BF_FT - LUF + Forrest-Tomlin
  220.47 +         GLP_BF_BG - LUF + Schur compl. + Bartels-Golub
  220.48 +         GLP_BF_GR - LUF + Schur compl. + Givens rotation */
  220.49 +      FHV *fhv;
  220.50 +      /* LP basis factorization (GLP_BF_FT) */
  220.51 +      LPF *lpf;
  220.52 +      /* LP basis factorization (GLP_BF_BG, GLP_BF_GR) */
  220.53 +      int lu_size;      /* luf.sv_size */
  220.54 +      double piv_tol;   /* luf.piv_tol */
  220.55 +      int piv_lim;      /* luf.piv_lim */
  220.56 +      int suhl;         /* luf.suhl */
  220.57 +      double eps_tol;   /* luf.eps_tol */
  220.58 +      double max_gro;   /* luf.max_gro */
  220.59 +      int nfs_max;      /* fhv.hh_max */
  220.60 +      double upd_tol;   /* fhv.upd_tol */
  220.61 +      int nrs_max;      /* lpf.n_max */
  220.62 +      int rs_size;      /* lpf.v_size */
  220.63 +      /* internal control parameters */
  220.64 +      int upd_lim;
  220.65 +      /* the factorization update limit */
  220.66 +      int upd_cnt;
  220.67 +      /* the factorization update count */
  220.68 +};
  220.69 +
  220.70 +/***********************************************************************
  220.71 +*  NAME
  220.72 +*
  220.73 +*  bfd_create_it - create LP basis factorization
  220.74 +*
  220.75 +*  SYNOPSIS
  220.76 +*
  220.77 +*  #include "glpbfd.h"
  220.78 +*  BFD *bfd_create_it(void);
  220.79 +*
  220.80 +*  DESCRIPTION
  220.81 +*
  220.82 +*  The routine bfd_create_it creates a program object, which represents
  220.83 +*  a factorization of LP basis.
  220.84 +*
  220.85 +*  RETURNS
  220.86 +*
  220.87 +*  The routine bfd_create_it returns a pointer to the object created. */
  220.88 +
  220.89 +BFD *bfd_create_it(void)
  220.90 +{     BFD *bfd;
  220.91 +      bfd = xmalloc(sizeof(BFD));
  220.92 +      bfd->valid = 0;
  220.93 +      bfd->type = GLP_BF_FT;
  220.94 +      bfd->fhv = NULL;
  220.95 +      bfd->lpf = NULL;
  220.96 +      bfd->lu_size = 0;
  220.97 +      bfd->piv_tol = 0.10;
  220.98 +      bfd->piv_lim = 4;
  220.99 +      bfd->suhl = 1;
 220.100 +      bfd->eps_tol = 1e-15;
 220.101 +      bfd->max_gro = 1e+10;
 220.102 +      bfd->nfs_max = 100;
 220.103 +      bfd->upd_tol = 1e-6;
 220.104 +      bfd->nrs_max = 100;
 220.105 +      bfd->rs_size = 1000;
 220.106 +      bfd->upd_lim = -1;
 220.107 +      bfd->upd_cnt = 0;
 220.108 +      return bfd;
 220.109 +}
 220.110 +
 220.111 +/**********************************************************************/
 220.112 +
 220.113 +void bfd_set_parm(BFD *bfd, const void *_parm)
 220.114 +{     /* change LP basis factorization control parameters */
 220.115 +      const glp_bfcp *parm = _parm;
 220.116 +      xassert(bfd != NULL);
 220.117 +      bfd->type = parm->type;
 220.118 +      bfd->lu_size = parm->lu_size;
 220.119 +      bfd->piv_tol = parm->piv_tol;
 220.120 +      bfd->piv_lim = parm->piv_lim;
 220.121 +      bfd->suhl = parm->suhl;
 220.122 +      bfd->eps_tol = parm->eps_tol;
 220.123 +      bfd->max_gro = parm->max_gro;
 220.124 +      bfd->nfs_max = parm->nfs_max;
 220.125 +      bfd->upd_tol = parm->upd_tol;
 220.126 +      bfd->nrs_max = parm->nrs_max;
 220.127 +      bfd->rs_size = parm->rs_size;
 220.128 +      return;
 220.129 +}
 220.130 +
 220.131 +/***********************************************************************
 220.132 +*  NAME
 220.133 +*
 220.134 +*  bfd_factorize - compute LP basis factorization
 220.135 +*
 220.136 +*  SYNOPSIS
 220.137 +*
 220.138 +*  #include "glpbfd.h"
 220.139 +*  int bfd_factorize(BFD *bfd, int m, int bh[], int (*col)(void *info,
 220.140 +*     int j, int ind[], double val[]), void *info);
 220.141 +*
 220.142 +*  DESCRIPTION
 220.143 +*
 220.144 +*  The routine bfd_factorize computes the factorization of the basis
 220.145 +*  matrix B specified by the routine col.
 220.146 +*
 220.147 +*  The parameter bfd specified the basis factorization data structure
 220.148 +*  created with the routine bfd_create_it.
 220.149 +*
 220.150 +*  The parameter m specifies the order of B, m > 0.
 220.151 +*
 220.152 +*  The array bh specifies the basis header: bh[j], 1 <= j <= m, is the
 220.153 +*  number of j-th column of B in some original matrix. The array bh is
 220.154 +*  optional and can be specified as NULL.
 220.155 +*
 220.156 +*  The formal routine col specifies the matrix B to be factorized. To
 220.157 +*  obtain j-th column of A the routine bfd_factorize calls the routine
 220.158 +*  col with the parameter j (1 <= j <= n). In response the routine col
 220.159 +*  should store row indices and numerical values of non-zero elements
 220.160 +*  of j-th column of B to locations ind[1,...,len] and val[1,...,len],
 220.161 +*  respectively, where len is the number of non-zeros in j-th column
 220.162 +*  returned on exit. Neither zero nor duplicate elements are allowed.
 220.163 +*
 220.164 +*  The parameter info is a transit pointer passed to the routine col.
 220.165 +*
 220.166 +*  RETURNS
 220.167 +*
 220.168 +*  0  The factorization has been successfully computed.
 220.169 +*
 220.170 +*  BFD_ESING
 220.171 +*     The specified matrix is singular within the working precision.
 220.172 +*
 220.173 +*  BFD_ECOND
 220.174 +*     The specified matrix is ill-conditioned.
 220.175 +*
 220.176 +*  For more details see comments to the routine luf_factorize. */
 220.177 +
 220.178 +int bfd_factorize(BFD *bfd, int m, const int bh[], int (*col)
 220.179 +      (void *info, int j, int ind[], double val[]), void *info)
 220.180 +{     LUF *luf;
 220.181 +      int nov, ret;
 220.182 +      xassert(bfd != NULL);
 220.183 +      xassert(1 <= m && m <= M_MAX);
 220.184 +      /* invalidate the factorization */
 220.185 +      bfd->valid = 0;
 220.186 +      /* create the factorization, if necessary */
 220.187 +      nov = 0;
 220.188 +      switch (bfd->type)
 220.189 +      {  case GLP_BF_FT:
 220.190 +            if (bfd->lpf != NULL)
 220.191 +               lpf_delete_it(bfd->lpf), bfd->lpf = NULL;
 220.192 +            if (bfd->fhv == NULL)
 220.193 +               bfd->fhv = fhv_create_it(), nov = 1;
 220.194 +            break;
 220.195 +         case GLP_BF_BG:
 220.196 +         case GLP_BF_GR:
 220.197 +            if (bfd->fhv != NULL)
 220.198 +               fhv_delete_it(bfd->fhv), bfd->fhv = NULL;
 220.199 +            if (bfd->lpf == NULL)
 220.200 +               bfd->lpf = lpf_create_it(), nov = 1;
 220.201 +            break;
 220.202 +         default:
 220.203 +            xassert(bfd != bfd);
 220.204 +      }
 220.205 +      /* set control parameters specific to LUF */
 220.206 +      if (bfd->fhv != NULL)
 220.207 +         luf = bfd->fhv->luf;
 220.208 +      else if (bfd->lpf != NULL)
 220.209 +         luf = bfd->lpf->luf;
 220.210 +      else
 220.211 +         xassert(bfd != bfd);
 220.212 +      if (nov) luf->new_sva = bfd->lu_size;
 220.213 +      luf->piv_tol = bfd->piv_tol;
 220.214 +      luf->piv_lim = bfd->piv_lim;
 220.215 +      luf->suhl = bfd->suhl;
 220.216 +      luf->eps_tol = bfd->eps_tol;
 220.217 +      luf->max_gro = bfd->max_gro;
 220.218 +      /* set control parameters specific to FHV */
 220.219 +      if (bfd->fhv != NULL)
 220.220 +      {  if (nov) bfd->fhv->hh_max = bfd->nfs_max;
 220.221 +         bfd->fhv->upd_tol = bfd->upd_tol;
 220.222 +      }
 220.223 +      /* set control parameters specific to LPF */
 220.224 +      if (bfd->lpf != NULL)
 220.225 +      {  if (nov) bfd->lpf->n_max = bfd->nrs_max;
 220.226 +         if (nov) bfd->lpf->v_size = bfd->rs_size;
 220.227 +      }
 220.228 +      /* try to factorize the basis matrix */
 220.229 +      if (bfd->fhv != NULL)
 220.230 +      {  switch (fhv_factorize(bfd->fhv, m, col, info))
 220.231 +         {  case 0:
 220.232 +               break;
 220.233 +            case FHV_ESING:
 220.234 +               ret = BFD_ESING;
 220.235 +               goto done;
 220.236 +            case FHV_ECOND:
 220.237 +               ret = BFD_ECOND;
 220.238 +               goto done;
 220.239 +            default:
 220.240 +               xassert(bfd != bfd);
 220.241 +         }
 220.242 +      }
 220.243 +      else if (bfd->lpf != NULL)
 220.244 +      {  switch (lpf_factorize(bfd->lpf, m, bh, col, info))
 220.245 +         {  case 0:
 220.246 +               /* set the Schur complement update type */
 220.247 +               switch (bfd->type)
 220.248 +               {  case GLP_BF_BG:
 220.249 +                     /* Bartels-Golub update */
 220.250 +                     bfd->lpf->scf->t_opt = SCF_TBG;
 220.251 +                     break;
 220.252 +                  case GLP_BF_GR:
 220.253 +                     /* Givens rotation update */
 220.254 +                     bfd->lpf->scf->t_opt = SCF_TGR;
 220.255 +                     break;
 220.256 +                  default:
 220.257 +                     xassert(bfd != bfd);
 220.258 +               }
 220.259 +               break;
 220.260 +            case LPF_ESING:
 220.261 +               ret = BFD_ESING;
 220.262 +               goto done;
 220.263 +            case LPF_ECOND:
 220.264 +               ret = BFD_ECOND;
 220.265 +               goto done;
 220.266 +            default:
 220.267 +               xassert(bfd != bfd);
 220.268 +         }
 220.269 +      }
 220.270 +      else
 220.271 +         xassert(bfd != bfd);
 220.272 +      /* the basis matrix has been successfully factorized */
 220.273 +      bfd->valid = 1;
 220.274 +      bfd->upd_cnt = 0;
 220.275 +      ret = 0;
 220.276 +done: /* return to the calling program */
 220.277 +      return ret;
 220.278 +}
 220.279 +
 220.280 +/***********************************************************************
 220.281 +*  NAME
 220.282 +*
 220.283 +*  bfd_ftran - perform forward transformation (solve system B*x = b)
 220.284 +*
 220.285 +*  SYNOPSIS
 220.286 +*
 220.287 +*  #include "glpbfd.h"
 220.288 +*  void bfd_ftran(BFD *bfd, double x[]);
 220.289 +*
 220.290 +*  DESCRIPTION
 220.291 +*
 220.292 +*  The routine bfd_ftran performs forward transformation, i.e. solves
 220.293 +*  the system B*x = b, where B is the basis matrix, x is the vector of
 220.294 +*  unknowns to be computed, b is the vector of right-hand sides.
 220.295 +*
 220.296 +*  On entry elements of the vector b should be stored in dense format
 220.297 +*  in locations x[1], ..., x[m], where m is the number of rows. On exit
 220.298 +*  the routine stores elements of the vector x in the same locations. */
 220.299 +
 220.300 +void bfd_ftran(BFD *bfd, double x[])
 220.301 +{     xassert(bfd != NULL);
 220.302 +      xassert(bfd->valid);
 220.303 +      if (bfd->fhv != NULL)
 220.304 +         fhv_ftran(bfd->fhv, x);
 220.305 +      else if (bfd->lpf != NULL)
 220.306 +         lpf_ftran(bfd->lpf, x);
 220.307 +      else
 220.308 +         xassert(bfd != bfd);
 220.309 +      return;
 220.310 +}
 220.311 +
 220.312 +/***********************************************************************
 220.313 +*  NAME
 220.314 +*
 220.315 +*  bfd_btran - perform backward transformation (solve system B'*x = b)
 220.316 +*
 220.317 +*  SYNOPSIS
 220.318 +*
 220.319 +*  #include "glpbfd.h"
 220.320 +*  void bfd_btran(BFD *bfd, double x[]);
 220.321 +*
 220.322 +*  DESCRIPTION
 220.323 +*
 220.324 +*  The routine bfd_btran performs backward transformation, i.e. solves
 220.325 +*  the system B'*x = b, where B' is a matrix transposed to the basis
 220.326 +*  matrix B, x is the vector of unknowns to be computed, b is the vector
 220.327 +*  of right-hand sides.
 220.328 +*
 220.329 +*  On entry elements of the vector b should be stored in dense format
 220.330 +*  in locations x[1], ..., x[m], where m is the number of rows. On exit
 220.331 +*  the routine stores elements of the vector x in the same locations. */
 220.332 +
 220.333 +void bfd_btran(BFD *bfd, double x[])
 220.334 +{     xassert(bfd != NULL);
 220.335 +      xassert(bfd->valid);
 220.336 +      if (bfd->fhv != NULL)
 220.337 +         fhv_btran(bfd->fhv, x);
 220.338 +      else if (bfd->lpf != NULL)
 220.339 +         lpf_btran(bfd->lpf, x);
 220.340 +      else
 220.341 +         xassert(bfd != bfd);
 220.342 +      return;
 220.343 +}
 220.344 +
 220.345 +/***********************************************************************
 220.346 +*  NAME
 220.347 +*
 220.348 +*  bfd_update_it - update LP basis factorization
 220.349 +*
 220.350 +*  SYNOPSIS
 220.351 +*
 220.352 +*  #include "glpbfd.h"
 220.353 +*  int bfd_update_it(BFD *bfd, int j, int bh, int len, const int ind[],
 220.354 +*     const double val[]);
 220.355 +*
 220.356 +*  DESCRIPTION
 220.357 +*
 220.358 +*  The routine bfd_update_it updates the factorization of the basis
 220.359 +*  matrix B after replacing its j-th column by a new vector.
 220.360 +*
 220.361 +*  The parameter j specifies the number of column of B, which has been
 220.362 +*  replaced, 1 <= j <= m, where m is the order of B.
 220.363 +*
 220.364 +*  The parameter bh specifies the basis header entry for the new column
 220.365 +*  of B, which is the number of the new column in some original matrix.
 220.366 +*  This parameter is optional and can be specified as 0.
 220.367 +*
 220.368 +*  Row indices and numerical values of non-zero elements of the new
 220.369 +*  column of B should be placed in locations ind[1], ..., ind[len] and
 220.370 +*  val[1], ..., val[len], resp., where len is the number of non-zeros
 220.371 +*  in the column. Neither zero nor duplicate elements are allowed.
 220.372 +*
 220.373 +*  RETURNS
 220.374 +*
 220.375 +*  0  The factorization has been successfully updated.
 220.376 +*
 220.377 +*  BFD_ESING
 220.378 +*     New basis matrix is singular within the working precision.
 220.379 +*
 220.380 +*  BFD_ECHECK
 220.381 +*     The factorization is inaccurate.
 220.382 +*
 220.383 +*  BFD_ELIMIT
 220.384 +*     Factorization update limit has been reached.
 220.385 +*
 220.386 +*  BFD_EROOM
 220.387 +*     Overflow of the sparse vector area.
 220.388 +*
 220.389 +*  In case of non-zero return code the factorization becomes invalid.
 220.390 +*  It should not be used until it has been recomputed with the routine
 220.391 +*  bfd_factorize. */
 220.392 +
 220.393 +int bfd_update_it(BFD *bfd, int j, int bh, int len, const int ind[],
 220.394 +      const double val[])
 220.395 +{     int ret;
 220.396 +      xassert(bfd != NULL);
 220.397 +      xassert(bfd->valid);
 220.398 +      /* try to update the factorization */
 220.399 +      if (bfd->fhv != NULL)
 220.400 +      {  switch (fhv_update_it(bfd->fhv, j, len, ind, val))
 220.401 +         {  case 0:
 220.402 +               break;
 220.403 +            case FHV_ESING:
 220.404 +               bfd->valid = 0;
 220.405 +               ret = BFD_ESING;
 220.406 +               goto done;
 220.407 +            case FHV_ECHECK:
 220.408 +               bfd->valid = 0;
 220.409 +               ret = BFD_ECHECK;
 220.410 +               goto done;
 220.411 +            case FHV_ELIMIT:
 220.412 +               bfd->valid = 0;
 220.413 +               ret = BFD_ELIMIT;
 220.414 +               goto done;
 220.415 +            case FHV_EROOM:
 220.416 +               bfd->valid = 0;
 220.417 +               ret = BFD_EROOM;
 220.418 +               goto done;
 220.419 +            default:
 220.420 +               xassert(bfd != bfd);
 220.421 +         }
 220.422 +      }
 220.423 +      else if (bfd->lpf != NULL)
 220.424 +      {  switch (lpf_update_it(bfd->lpf, j, bh, len, ind, val))
 220.425 +         {  case 0:
 220.426 +               break;
 220.427 +            case LPF_ESING:
 220.428 +               bfd->valid = 0;
 220.429 +               ret = BFD_ESING;
 220.430 +               goto done;
 220.431 +            case LPF_ELIMIT:
 220.432 +               bfd->valid = 0;
 220.433 +               ret = BFD_ELIMIT;
 220.434 +               goto done;
 220.435 +            default:
 220.436 +               xassert(bfd != bfd);
 220.437 +         }
 220.438 +      }
 220.439 +      else
 220.440 +         xassert(bfd != bfd);
 220.441 +      /* the factorization has been successfully updated */
 220.442 +      /* increase the update count */
 220.443 +      bfd->upd_cnt++;
 220.444 +      ret = 0;
 220.445 +done: /* return to the calling program */
 220.446 +      return ret;
 220.447 +}
 220.448 +
 220.449 +/**********************************************************************/
 220.450 +
 220.451 +int bfd_get_count(BFD *bfd)
 220.452 +{     /* determine factorization update count */
 220.453 +      xassert(bfd != NULL);
 220.454 +      xassert(bfd->valid);
 220.455 +      return bfd->upd_cnt;
 220.456 +}
 220.457 +
 220.458 +/***********************************************************************
 220.459 +*  NAME
 220.460 +*
 220.461 +*  bfd_delete_it - delete LP basis factorization
 220.462 +*
 220.463 +*  SYNOPSIS
 220.464 +*
 220.465 +*  #include "glpbfd.h"
 220.466 +*  void bfd_delete_it(BFD *bfd);
 220.467 +*
 220.468 +*  DESCRIPTION
 220.469 +*
 220.470 +*  The routine bfd_delete_it deletes LP basis factorization specified
 220.471 +*  by the parameter fhv and frees all memory allocated to this program
 220.472 +*  object. */
 220.473 +
 220.474 +void bfd_delete_it(BFD *bfd)
 220.475 +{     xassert(bfd != NULL);
 220.476 +      if (bfd->fhv != NULL)
 220.477 +         fhv_delete_it(bfd->fhv);
 220.478 +      if (bfd->lpf != NULL)
 220.479 +         lpf_delete_it(bfd->lpf);
 220.480 +      xfree(bfd);
 220.481 +      return;
 220.482 +}
 220.483 +
 220.484 +/* eof */
   221.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
   221.2 +++ b/deps/glpk/src/glpbfd.h	Sun Nov 06 20:59:10 2011 +0100
   221.3 @@ -0,0 +1,75 @@
   221.4 +/* glpbfd.h (LP basis factorization driver) */
   221.5 +
   221.6 +/***********************************************************************
   221.7 +*  This code is part of GLPK (GNU Linear Programming Kit).
   221.8 +*
   221.9 +*  Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008,
  221.10 +*  2009, 2010, 2011 Andrew Makhorin, Department for Applied Informatics,
  221.11 +*  Moscow Aviation Institute, Moscow, Russia. All rights reserved.
  221.12 +*  E-mail: <mao@gnu.org>.
  221.13 +*
  221.14 +*  GLPK is free software: you can redistribute it and/or modify it
  221.15 +*  under the terms of the GNU General Public License as published by
  221.16 +*  the Free Software Foundation, either version 3 of the License, or
  221.17 +*  (at your option) any later version.
  221.18 +*
  221.19 +*  GLPK is distributed in the hope that it will be useful, but WITHOUT
  221.20 +*  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
  221.21 +*  or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
  221.22 +*  License for more details.
  221.23 +*
  221.24 +*  You should have received a copy of the GNU General Public License
  221.25 +*  along with GLPK. If not, see <http://www.gnu.org/licenses/>.
  221.26 +***********************************************************************/
  221.27 +
  221.28 +#ifndef GLPBFD_H
  221.29 +#define GLPBFD_H
  221.30 +
  221.31 +#ifndef GLPBFD_PRIVATE
  221.32 +typedef struct { double _opaque_bfd[100]; } BFD;
  221.33 +#endif
  221.34 +
  221.35 +/* return codes: */
  221.36 +#define BFD_ESING    1  /* singular matrix */
  221.37 +#define BFD_ECOND    2  /* ill-conditioned matrix */
  221.38 +#define BFD_ECHECK   3  /* insufficient accuracy */
  221.39 +#define BFD_ELIMIT   4  /* update limit reached */
  221.40 +#define BFD_EROOM    5  /* SVA overflow */
  221.41 +
  221.42 +#define bfd_create_it _glp_bfd_create_it
  221.43 +BFD *bfd_create_it(void);
  221.44 +/* create LP basis factorization */
  221.45 +
  221.46 +#define bfd_set_parm _glp_bfd_set_parm
  221.47 +void bfd_set_parm(BFD *bfd, const void *parm);
  221.48 +/* change LP basis factorization control parameters */
  221.49 +
  221.50 +#define bfd_factorize _glp_bfd_factorize
  221.51 +int bfd_factorize(BFD *bfd, int m, const int bh[], int (*col)
  221.52 +      (void *info, int j, int ind[], double val[]), void *info);
  221.53 +/* compute LP basis factorization */
  221.54 +
  221.55 +#define bfd_ftran _glp_bfd_ftran
  221.56 +void bfd_ftran(BFD *bfd, double x[]);
  221.57 +/* perform forward transformation (solve system B*x = b) */
  221.58 +
  221.59 +#define bfd_btran _glp_bfd_btran
  221.60 +void bfd_btran(BFD *bfd, double x[]);
  221.61 +/* perform backward transformation (solve system B'*x = b) */
  221.62 +
  221.63 +#define bfd_update_it _glp_bfd_update_it
  221.64 +int bfd_update_it(BFD *bfd, int j, int bh, int len, const int ind[],
  221.65 +      const double val[]);
  221.66 +/* update LP basis factorization */
  221.67 +
  221.68 +#define bfd_get_count _glp_bfd_get_count
  221.69 +int bfd_get_count(BFD *bfd);
  221.70 +/* determine factorization update count */
  221.71 +
  221.72 +#define bfd_delete_it _glp_bfd_delete_it
  221.73 +void bfd_delete_it(BFD *bfd);
  221.74 +/* delete LP basis factorization */
  221.75 +
  221.76 +#endif
  221.77 +
  221.78 +/* eof */
   222.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
   222.2 +++ b/deps/glpk/src/glpbfx.c	Sun Nov 06 20:59:10 2011 +0100
   222.3 @@ -0,0 +1,91 @@
   222.4 +/* glpbfx.c */
   222.5 +
   222.6 +/***********************************************************************
   222.7 +*  This code is part of GLPK (GNU Linear Programming Kit).
   222.8 +*
   222.9 +*  Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008,
  222.10 +*  2009, 2010, 2011 Andrew Makhorin, Department for Applied Informatics,
  222.11 +*  Moscow Aviation Institute, Moscow, Russia. All rights reserved.
  222.12 +*  E-mail: <mao@gnu.org>.
  222.13 +*
  222.14 +*  GLPK is free software: you can redistribute it and/or modify it
  222.15 +*  under the terms of the GNU General Public License as published by
  222.16 +*  the Free Software Foundation, either version 3 of the License, or
  222.17 +*  (at your option) any later version.
  222.18 +*
  222.19 +*  GLPK is distributed in the hope that it will be useful, but WITHOUT
  222.20 +*  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
  222.21 +*  or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
  222.22 +*  License for more details.
  222.23 +*
  222.24 +*  You should have received a copy of the GNU General Public License
  222.25 +*  along with GLPK. If not, see <http://www.gnu.org/licenses/>.
  222.26 +***********************************************************************/
  222.27 +
  222.28 +typedef struct BFX BFX;
  222.29 +#define GLPBFX_DEFINED
  222.30 +#include "glpbfx.h"
  222.31 +#include "glpenv.h"
  222.32 +#include "glplux.h"
  222.33 +
  222.34 +struct BFX
  222.35 +{     int valid;
  222.36 +      LUX *lux;
  222.37 +};
  222.38 +
  222.39 +BFX *bfx_create_binv(void)
  222.40 +{     /* create factorization of the basis matrix */
  222.41 +      BFX *bfx;
  222.42 +      bfx = xmalloc(sizeof(BFX));
  222.43 +      bfx->valid = 0;
  222.44 +      bfx->lux = NULL;
  222.45 +      return bfx;
  222.46 +}
  222.47 +
  222.48 +int bfx_factorize(BFX *binv, int m, int (*col)(void *info, int j,
  222.49 +      int ind[], mpq_t val[]), void *info)
  222.50 +{     /* compute factorization of the basis matrix */
  222.51 +      int ret;
  222.52 +      xassert(m > 0);
  222.53 +      if (binv->lux != NULL && binv->lux->n != m)
  222.54 +      {  lux_delete(binv->lux);
  222.55 +         binv->lux = NULL;
  222.56 +      }
  222.57 +      if (binv->lux == NULL)
  222.58 +         binv->lux = lux_create(m);
  222.59 +      ret = lux_decomp(binv->lux, col, info);
  222.60 +      binv->valid = (ret == 0);
  222.61 +      return ret;
  222.62 +}
  222.63 +
  222.64 +void bfx_ftran(BFX *binv, mpq_t x[], int save)
  222.65 +{     /* perform forward transformation (FTRAN) */
  222.66 +      xassert(binv->valid);
  222.67 +      lux_solve(binv->lux, 0, x);
  222.68 +      xassert(save == save);
  222.69 +      return;
  222.70 +}
  222.71 +
  222.72 +void bfx_btran(BFX *binv, mpq_t x[])
  222.73 +{     /* perform backward transformation (BTRAN) */
  222.74 +      xassert(binv->valid);
  222.75 +      lux_solve(binv->lux, 1, x);
  222.76 +      return;
  222.77 +}
  222.78 +
  222.79 +int bfx_update(BFX *binv, int j)
  222.80 +{     /* update factorization of the basis matrix */
  222.81 +      xassert(binv->valid);
  222.82 +      xassert(1 <= j && j <= binv->lux->n);
  222.83 +      return 1;
  222.84 +}
  222.85 +
  222.86 +void bfx_delete_binv(BFX *binv)
  222.87 +{     /* delete factorization of the basis matrix */
  222.88 +      if (binv->lux != NULL)
  222.89 +         lux_delete(binv->lux);
  222.90 +      xfree(binv);
  222.91 +      return;
  222.92 +}
  222.93 +
  222.94 +/* eof */
   223.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
   223.2 +++ b/deps/glpk/src/glpbfx.h	Sun Nov 06 20:59:10 2011 +0100
   223.3 @@ -0,0 +1,71 @@
   223.4 +/* glpbfx.h (basis factorization interface, bignum arithmetic) */
   223.5 +
   223.6 +/***********************************************************************
   223.7 +*  This code is part of GLPK (GNU Linear Programming Kit).
   223.8 +*
   223.9 +*  Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008,
  223.10 +*  2009, 2010, 2011 Andrew Makhorin, Department for Applied Informatics,
  223.11 +*  Moscow Aviation Institute, Moscow, Russia. All rights reserved.
  223.12 +*  E-mail: <mao@gnu.org>.
  223.13 +*
  223.14 +*  GLPK is free software: you can redistribute it and/or modify it
  223.15 +*  under the terms of the GNU General Public License as published by
  223.16 +*  the Free Software Foundation, either version 3 of the License, or
  223.17 +*  (at your option) any later version.
  223.18 +*
  223.19 +*  GLPK is distributed in the hope that it will be useful, but WITHOUT
  223.20 +*  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
  223.21 +*  or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
  223.22 +*  License for more details.
  223.23 +*
  223.24 +*  You should have received a copy of the GNU General Public License
  223.25 +*  along with GLPK. If not, see <http://www.gnu.org/licenses/>.
  223.26 +***********************************************************************/
  223.27 +
  223.28 +#ifndef GLPBFX_H
  223.29 +#define GLPBFX_H
  223.30 +
  223.31 +#include "glpgmp.h"
  223.32 +
  223.33 +#ifndef GLPBFX_DEFINED
  223.34 +#define GLPBFX_DEFINED
  223.35 +typedef struct { double _opaque_bfx; } BFX;
  223.36 +#endif
  223.37 +
  223.38 +#define bfx_create_binv       _glp_bfx_create_binv
  223.39 +#define bfx_is_valid          _glp_bfx_is_valid
  223.40 +#define bfx_invalidate        _glp_bfx_invalidate
  223.41 +#define bfx_factorize         _glp_bfx_factorize
  223.42 +#define bfx_ftran             _glp_bfx_ftran
  223.43 +#define bfx_btran             _glp_bfx_btran
  223.44 +#define bfx_update            _glp_bfx_update
  223.45 +#define bfx_delete_binv       _glp_bfx_delete_binv
  223.46 +
  223.47 +BFX *bfx_create_binv(void);
  223.48 +/* create factorization of the basis matrix */
  223.49 +
  223.50 +int bfx_is_valid(BFX *binv);
  223.51 +/* check if factorization is valid */
  223.52 +
  223.53 +void bfx_invalidate(BFX *binv);
  223.54 +/* invalidate factorization of the basis matrix */
  223.55 +
  223.56 +int bfx_factorize(BFX *binv, int m, int (*col)(void *info, int j,
  223.57 +      int ind[], mpq_t val[]), void *info);
  223.58 +/* compute factorization of the basis matrix */
  223.59 +
  223.60 +void bfx_ftran(BFX *binv, mpq_t x[], int save);
  223.61 +/* perform forward transformation (FTRAN) */
  223.62 +
  223.63 +void bfx_btran(BFX *binv, mpq_t x[]);
  223.64 +/* perform backward transformation (BTRAN) */
  223.65 +
  223.66 +int bfx_update(BFX *binv, int j);
  223.67 +/* update factorization of the basis matrix */
  223.68 +
  223.69 +void bfx_delete_binv(BFX *binv);
  223.70 +/* delete factorization of the basis matrix */
  223.71 +
  223.72 +#endif
  223.73 +
  223.74 +/* eof */
   224.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
   224.2 +++ b/deps/glpk/src/glpcpx.c	Sun Nov 06 20:59:10 2011 +0100
   224.3 @@ -0,0 +1,1239 @@
   224.4 +/* glpcpx.c (CPLEX LP format routines) */
   224.5 +
   224.6 +/***********************************************************************
   224.7 +*  This code is part of GLPK (GNU Linear Programming Kit).
   224.8 +*
   224.9 +*  Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008,
  224.10 +*  2009, 2010, 2011 Andrew Makhorin, Department for Applied Informatics,
  224.11 +*  Moscow Aviation Institute, Moscow, Russia. All rights reserved.
  224.12 +*  E-mail: <mao@gnu.org>.
  224.13 +*
  224.14 +*  GLPK is free software: you can redistribute it and/or modify it
  224.15 +*  under the terms of the GNU General Public License as published by
  224.16 +*  the Free Software Foundation, either version 3 of the License, or
  224.17 +*  (at your option) any later version.
  224.18 +*
  224.19 +*  GLPK is distributed in the hope that it will be useful, but WITHOUT
  224.20 +*  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
  224.21 +*  or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
  224.22 +*  License for more details.
  224.23 +*
  224.24 +*  You should have received a copy of the GNU General Public License
  224.25 +*  along with GLPK. If not, see <http://www.gnu.org/licenses/>.
  224.26 +***********************************************************************/
  224.27 +
  224.28 +#include "glpapi.h"
  224.29 +
  224.30 +/***********************************************************************
  224.31 +*  NAME
  224.32 +*
  224.33 +*  glp_init_cpxcp - initialize CPLEX LP format control parameters
  224.34 +*
  224.35 +*  SYNOPSIS
  224.36 +*
  224.37 +*  void glp_init_cpxcp(glp_cpxcp *parm):
  224.38 +*
  224.39 +*  The routine glp_init_cpxcp initializes control parameters used by
  224.40 +*  the CPLEX LP input/output routines glp_read_lp and glp_write_lp with
  224.41 +*  default values.
  224.42 +*
  224.43 +*  Default values of the control parameters are stored in the glp_cpxcp
  224.44 +*  structure, which the parameter parm points to. */
  224.45 +
  224.46 +void glp_init_cpxcp(glp_cpxcp *parm)
  224.47 +{     xassert(parm != NULL);
  224.48 +      return;
  224.49 +}
  224.50 +
  224.51 +static void check_parm(const char *func, const glp_cpxcp *parm)
  224.52 +{     /* check control parameters */
  224.53 +      xassert(func != NULL);
  224.54 +      xassert(parm != NULL);
  224.55 +      return;
  224.56 +}
  224.57 +
  224.58 +/***********************************************************************
  224.59 +*  NAME
  224.60 +*
  224.61 +*  glp_read_lp - read problem data in CPLEX LP format
  224.62 +*
  224.63 +*  SYNOPSIS
  224.64 +*
  224.65 +*  int glp_read_lp(glp_prob *P, const glp_cpxcp *parm, const char
  224.66 +*     *fname);
  224.67 +*
  224.68 +*  DESCRIPTION
  224.69 +*
  224.70 +*  The routine glp_read_lp reads problem data in CPLEX LP format from
  224.71 +*  a text file.
  224.72 +*
  224.73 +*  The parameter parm is a pointer to the structure glp_cpxcp, which
  224.74 +*  specifies control parameters used by the routine. If parm is NULL,
  224.75 +*  the routine uses default settings.
  224.76 +*
  224.77 +*  The character string fname specifies a name of the text file to be
  224.78 +*  read.
  224.79 +*
  224.80 +*  Note that before reading data the current content of the problem
  224.81 +*  object is completely erased with the routine glp_erase_prob.
  224.82 +*
  224.83 +*  RETURNS
  224.84 +*
  224.85 +*  If the operation was successful, the routine glp_read_lp returns
  224.86 +*  zero. Otherwise, it prints an error message and returns non-zero. */
  224.87 +
  224.88 +struct csa
  224.89 +{     /* common storage area */
  224.90 +      glp_prob *P;
  224.91 +      /* LP/MIP problem object */
  224.92 +      const glp_cpxcp *parm;
  224.93 +      /* pointer to control parameters */
  224.94 +      const char *fname;
  224.95 +      /* name of input CPLEX LP file */
  224.96 +      XFILE *fp;
  224.97 +      /* stream assigned to input CPLEX LP file */
  224.98 +      jmp_buf jump;
  224.99 +      /* label for go to in case of error */
 224.100 +      int count;
 224.101 +      /* line count */
 224.102 +      int c;
 224.103 +      /* current character or XEOF */
 224.104 +      int token;
 224.105 +      /* current token: */
 224.106 +#define T_EOF        0x00  /* end of file */
 224.107 +#define T_MINIMIZE   0x01  /* keyword 'minimize' */
 224.108 +#define T_MAXIMIZE   0x02  /* keyword 'maximize' */
 224.109 +#define T_SUBJECT_TO 0x03  /* keyword 'subject to' */
 224.110 +#define T_BOUNDS     0x04  /* keyword 'bounds' */
 224.111 +#define T_GENERAL    0x05  /* keyword 'general' */
 224.112 +#define T_INTEGER    0x06  /* keyword 'integer' */
 224.113 +#define T_BINARY     0x07  /* keyword 'binary' */
 224.114 +#define T_END        0x08  /* keyword 'end' */
 224.115 +#define T_NAME       0x09  /* symbolic name */
 224.116 +#define T_NUMBER     0x0A  /* numeric constant */
 224.117 +#define T_PLUS       0x0B  /* delimiter '+' */
 224.118 +#define T_MINUS      0x0C  /* delimiter '-' */
 224.119 +#define T_COLON      0x0D  /* delimiter ':' */
 224.120 +#define T_LE         0x0E  /* delimiter '<=' */
 224.121 +#define T_GE         0x0F  /* delimiter '>=' */
 224.122 +#define T_EQ         0x10  /* delimiter '=' */
 224.123 +      char image[255+1];
 224.124 +      /* image of current token */
 224.125 +      int imlen;
 224.126 +      /* length of token image */
 224.127 +      double value;
 224.128 +      /* value of numeric constant */
 224.129 +      int n_max;
 224.130 +      /* length of the following five arrays (enlarged automatically,
 224.131 +         if necessary) */
 224.132 +      int *ind; /* int ind[1+n_max]; */
 224.133 +      double *val; /* double val[1+n_max]; */
 224.134 +      char *flag; /* char flag[1+n_max]; */
 224.135 +      /* working arrays used to construct linear forms */
 224.136 +      double *lb; /* double lb[1+n_max]; */
 224.137 +      double *ub; /* double ub[1+n_max]; */
 224.138 +      /* lower and upper bounds of variables (columns) */
 224.139 +};
 224.140 +
 224.141 +#define CHAR_SET "!\"#$%&()/,.;?@_`'{}|~"
 224.142 +/* characters, which may appear in symbolic names */
 224.143 +
 224.144 +static void error(struct csa *csa, const char *fmt, ...)
 224.145 +{     /* print error message and terminate processing */
 224.146 +      va_list arg;
 224.147 +      xprintf("%s:%d: ", csa->fname, csa->count);
 224.148 +      va_start(arg, fmt);
 224.149 +      xvprintf(fmt, arg);
 224.150 +      va_end(arg);
 224.151 +      longjmp(csa->jump, 1);
 224.152 +      /* no return */
 224.153 +}
 224.154 +
 224.155 +static void warning(struct csa *csa, const char *fmt, ...)
 224.156 +{     /* print warning message and continue processing */
 224.157 +      va_list arg;
 224.158 +      xprintf("%s:%d: warning: ", csa->fname, csa->count);
 224.159 +      va_start(arg, fmt);
 224.160 +      xvprintf(fmt, arg);
 224.161 +      va_end(arg);
 224.162 +      return;
 224.163 +}
 224.164 +
 224.165 +static void read_char(struct csa *csa)
 224.166 +{     /* read next character from input file */
 224.167 +      int c;
 224.168 +      xassert(csa->c != XEOF);
 224.169 +      if (csa->c == '\n') csa->count++;
 224.170 +      c = xfgetc(csa->fp);
 224.171 +      if (c < 0)
 224.172 +      {  if (xferror(csa->fp))
 224.173 +            error(csa, "read error - %s\n", xerrmsg());
 224.174 +         else if (csa->c == '\n')
 224.175 +         {  csa->count--;
 224.176 +            c = XEOF;
 224.177 +         }
 224.178 +         else
 224.179 +         {  warning(csa, "missing final end of line\n");
 224.180 +            c = '\n';
 224.181 +         }
 224.182 +      }
 224.183 +      else if (c == '\n')
 224.184 +         ;
 224.185 +      else if (isspace(c))
 224.186 +         c = ' ';
 224.187 +      else if (iscntrl(c))
 224.188 +         error(csa, "invalid control character 0x%02X\n", c);
 224.189 +      csa->c = c;
 224.190 +      return;
 224.191 +}
 224.192 +
 224.193 +static void add_char(struct csa *csa)
 224.194 +{     /* append current character to current token */
 224.195 +      if (csa->imlen == sizeof(csa->image)-1)
 224.196 +         error(csa, "token `%.15s...' too long\n", csa->image);
 224.197 +      csa->image[csa->imlen++] = (char)csa->c;
 224.198 +      csa->image[csa->imlen] = '\0';
 224.199 +      read_char(csa);
 224.200 +      return;
 224.201 +}
 224.202 +
 224.203 +static int the_same(char *s1, char *s2)
 224.204 +{     /* compare two character strings ignoring case sensitivity */
 224.205 +      for (; *s1 != '\0'; s1++, s2++)
 224.206 +      {  if (tolower((unsigned char)*s1) != tolower((unsigned char)*s2))
 224.207 +            return 0;
 224.208 +      }
 224.209 +      return 1;
 224.210 +}
 224.211 +
 224.212 +static void scan_token(struct csa *csa)
 224.213 +{     /* scan next token */
 224.214 +      int flag;
 224.215 +      csa->token = -1;
 224.216 +      csa->image[0] = '\0';
 224.217 +      csa->imlen = 0;
 224.218 +      csa->value = 0.0;
 224.219 +loop: flag = 0;
 224.220 +      /* skip non-significant characters */
 224.221 +      while (csa->c == ' ') read_char(csa);
 224.222 +      /* recognize and scan current token */
 224.223 +      if (csa->c == XEOF)
 224.224 +         csa->token = T_EOF;
 224.225 +      else if (csa->c == '\n')
 224.226 +      {  read_char(csa);
 224.227 +         /* if the next character is letter, it may begin a keyword */
 224.228 +         if (isalpha(csa->c))
 224.229 +         {  flag = 1;
 224.230 +            goto name;
 224.231 +         }
 224.232 +         goto loop;
 224.233 +      }
 224.234 +      else if (csa->c == '\\')
 224.235 +      {  /* comment; ignore everything until end-of-line */
 224.236 +         while (csa->c != '\n') read_char(csa);
 224.237 +         goto loop;
 224.238 +      }
 224.239 +      else if (isalpha(csa->c) || csa->c != '.' && strchr(CHAR_SET,
 224.240 +         csa->c) != NULL)
 224.241 +name: {  /* symbolic name */
 224.242 +         csa->token = T_NAME;
 224.243 +         while (isalnum(csa->c) || strchr(CHAR_SET, csa->c) != NULL)
 224.244 +            add_char(csa);
 224.245 +         if (flag)
 224.246 +         {  /* check for keyword */
 224.247 +            if (the_same(csa->image, "minimize"))
 224.248 +               csa->token = T_MINIMIZE;
 224.249 +            else if (the_same(csa->image, "minimum"))
 224.250 +               csa->token = T_MINIMIZE;
 224.251 +            else if (the_same(csa->image, "min"))
 224.252 +               csa->token = T_MINIMIZE;
 224.253 +            else if (the_same(csa->image, "maximize"))
 224.254 +               csa->token = T_MAXIMIZE;
 224.255 +            else if (the_same(csa->image, "maximum"))
 224.256 +               csa->token = T_MAXIMIZE;
 224.257 +            else if (the_same(csa->image, "max"))
 224.258 +               csa->token = T_MAXIMIZE;
 224.259 +            else if (the_same(csa->image, "subject"))
 224.260 +            {  if (csa->c == ' ')
 224.261 +               {  read_char(csa);
 224.262 +                  if (tolower(csa->c) == 't')
 224.263 +                  {  csa->token = T_SUBJECT_TO;
 224.264 +                     csa->image[csa->imlen++] = ' ';
 224.265 +                     csa->image[csa->imlen] = '\0';
 224.266 +                     add_char(csa);
 224.267 +                     if (tolower(csa->c) != 'o')
 224.268 +                        error(csa, "keyword `subject to' incomplete\n");
 224.269 +                     add_char(csa);
 224.270 +                     if (isalpha(csa->c))
 224.271 +                        error(csa, "keyword `%s%c...' not recognized\n",
 224.272 +                           csa->image, csa->c);
 224.273 +                  }
 224.274 +               }
 224.275 +            }
 224.276 +            else if (the_same(csa->image, "such"))
 224.277 +            {  if (csa->c == ' ')
 224.278 +               {  read_char(csa);
 224.279 +                  if (tolower(csa->c) == 't')
 224.280 +                  {  csa->token = T_SUBJECT_TO;
 224.281 +                     csa->image[csa->imlen++] = ' ';
 224.282 +                     csa->image[csa->imlen] = '\0';
 224.283 +                     add_char(csa);
 224.284 +                     if (tolower(csa->c) != 'h')
 224.285 +err:                    error(csa, "keyword `such that' incomplete\n");
 224.286 +                     add_char(csa);
 224.287 +                     if (tolower(csa->c) != 'a') goto err;
 224.288 +                     add_char(csa);
 224.289 +                     if (tolower(csa->c) != 't') goto err;
 224.290 +                     add_char(csa);
 224.291 +                     if (isalpha(csa->c))
 224.292 +                        error(csa, "keyword `%s%c...' not recognized\n",
 224.293 +                           csa->image, csa->c);
 224.294 +                  }
 224.295 +               }
 224.296 +            }
 224.297 +            else if (the_same(csa->image, "st"))
 224.298 +               csa->token = T_SUBJECT_TO;
 224.299 +            else if (the_same(csa->image, "s.t."))
 224.300 +               csa->token = T_SUBJECT_TO;
 224.301 +            else if (the_same(csa->image, "st."))
 224.302 +               csa->token = T_SUBJECT_TO;
 224.303 +            else if (the_same(csa->image, "bounds"))
 224.304 +               csa->token = T_BOUNDS;
 224.305 +            else if (the_same(csa->image, "bound"))
 224.306 +               csa->token = T_BOUNDS;
 224.307 +            else if (the_same(csa->image, "general"))
 224.308 +               csa->token = T_GENERAL;
 224.309 +            else if (the_same(csa->image, "generals"))
 224.310 +               csa->token = T_GENERAL;
 224.311 +            else if (the_same(csa->image, "gen"))
 224.312 +               csa->token = T_GENERAL;
 224.313 +            else if (the_same(csa->image, "integer"))
 224.314 +               csa->token = T_INTEGER;
 224.315 +            else if (the_same(csa->image, "integers"))
 224.316 +               csa->token = T_INTEGER;
 224.317 +            else if (the_same(csa->image, "int"))
 224.318 +              csa->token = T_INTEGER;
 224.319 +            else if (the_same(csa->image, "binary"))
 224.320 +               csa->token = T_BINARY;
 224.321 +            else if (the_same(csa->image, "binaries"))
 224.322 +               csa->token = T_BINARY;
 224.323 +            else if (the_same(csa->image, "bin"))
 224.324 +               csa->token = T_BINARY;
 224.325 +            else if (the_same(csa->image, "end"))
 224.326 +               csa->token = T_END;
 224.327 +         }
 224.328 +      }
 224.329 +      else if (isdigit(csa->c) || csa->c == '.')
 224.330 +      {  /* numeric constant */
 224.331 +         csa->token = T_NUMBER;
 224.332 +         /* scan integer part */
 224.333 +         while (isdigit(csa->c)) add_char(csa);
 224.334 +         /* scan optional fractional part (it is mandatory, if there is
 224.335 +            no integer part) */
 224.336 +         if (csa->c == '.')
 224.337 +         {  add_char(csa);
 224.338 +            if (csa->imlen == 1 && !isdigit(csa->c))
 224.339 +               error(csa, "invalid use of decimal point\n");
 224.340 +            while (isdigit(csa->c)) add_char(csa);
 224.341 +         }
 224.342 +         /* scan optional decimal exponent */
 224.343 +         if (csa->c == 'e' || csa->c == 'E')
 224.344 +         {  add_char(csa);
 224.345 +            if (csa->c == '+' || csa->c == '-') add_char(csa);
 224.346 +            if (!isdigit(csa->c))
 224.347 +               error(csa, "numeric constant `%s' incomplete\n",
 224.348 +                  csa->image);
 224.349 +            while (isdigit(csa->c)) add_char(csa);
 224.350 +         }
 224.351 +         /* convert the numeric constant to floating-point */
 224.352 +         if (str2num(csa->image, &csa->value))
 224.353 +            error(csa, "numeric constant `%s' out of range\n",
 224.354 +               csa->image);
 224.355 +      }
 224.356 +      else if (csa->c == '+')
 224.357 +         csa->token = T_PLUS, add_char(csa);
 224.358 +      else if (csa->c == '-')
 224.359 +         csa->token = T_MINUS, add_char(csa);
 224.360 +      else if (csa->c == ':')
 224.361 +         csa->token = T_COLON, add_char(csa);
 224.362 +      else if (csa->c == '<')
 224.363 +      {  csa->token = T_LE, add_char(csa);
 224.364 +         if (csa->c == '=') add_char(csa);
 224.365 +      }
 224.366 +      else if (csa->c == '>')
 224.367 +      {  csa->token = T_GE, add_char(csa);
 224.368 +         if (csa->c == '=') add_char(csa);
 224.369 +      }
 224.370 +      else if (csa->c == '=')
 224.371 +      {  csa->token = T_EQ, add_char(csa);
 224.372 +         if (csa->c == '<')
 224.373 +            csa->token = T_LE, add_char(csa);
 224.374 +         else if (csa->c == '>')
 224.375 +            csa->token = T_GE, add_char(csa);
 224.376 +      }
 224.377 +      else
 224.378 +         error(csa, "character `%c' not recognized\n", csa->c);
 224.379 +      /* skip non-significant characters */
 224.380 +      while (csa->c == ' ') read_char(csa);
 224.381 +      return;
 224.382 +}
 224.383 +
 224.384 +static int find_col(struct csa *csa, char *name)
 224.385 +{     /* find column by its symbolic name */
 224.386 +      int j;
 224.387 +      j = glp_find_col(csa->P, name);
 224.388 +      if (j == 0)
 224.389 +      {  /* not found; create new column */
 224.390 +         j = glp_add_cols(csa->P, 1);
 224.391 +         glp_set_col_name(csa->P, j, name);
 224.392 +         /* enlarge working arrays, if necessary */
 224.393 +         if (csa->n_max < j)
 224.394 +         {  int n_max = csa->n_max;
 224.395 +            int *ind = csa->ind;
 224.396 +            double *val = csa->val;
 224.397 +            char *flag = csa->flag;
 224.398 +            double *lb = csa->lb;
 224.399 +            double *ub = csa->ub;
 224.400 +            csa->n_max += csa->n_max;
 224.401 +            csa->ind = xcalloc(1+csa->n_max, sizeof(int));
 224.402 +            memcpy(&csa->ind[1], &ind[1], n_max * sizeof(int));
 224.403 +            xfree(ind);
 224.404 +            csa->val = xcalloc(1+csa->n_max, sizeof(double));
 224.405 +            memcpy(&csa->val[1], &val[1], n_max * sizeof(double));
 224.406 +            xfree(val);
 224.407 +            csa->flag = xcalloc(1+csa->n_max, sizeof(char));
 224.408 +            memset(&csa->flag[1], 0, csa->n_max * sizeof(char));
 224.409 +            memcpy(&csa->flag[1], &flag[1], n_max * sizeof(char));
 224.410 +            xfree(flag);
 224.411 +            csa->lb = xcalloc(1+csa->n_max, sizeof(double));
 224.412 +            memcpy(&csa->lb[1], &lb[1], n_max * sizeof(double));
 224.413 +            xfree(lb);
 224.414 +            csa->ub = xcalloc(1+csa->n_max, sizeof(double));
 224.415 +            memcpy(&csa->ub[1], &ub[1], n_max * sizeof(double));
 224.416 +            xfree(ub);
 224.417 +         }
 224.418 +         csa->lb[j] = +DBL_MAX, csa->ub[j] = -DBL_MAX;
 224.419 +      }
 224.420 +      return j;
 224.421 +}
 224.422 +
 224.423 +/***********************************************************************
 224.424 +*  parse_linear_form - parse linear form
 224.425 +*
 224.426 +*  This routine parses the linear form using the following syntax:
 224.427 +*
 224.428 +*  <variable> ::= <symbolic name>
 224.429 +*  <coefficient> ::= <numeric constant>
 224.430 +*  <term> ::= <variable> | <numeric constant> <variable>
 224.431 +*  <linear form> ::= <term> | + <term> | - <term> |
 224.432 +*     <linear form> + <term> | <linear form> - <term>
 224.433 +*
 224.434 +*  The routine returns the number of terms in the linear form. */
 224.435 +
 224.436 +static int parse_linear_form(struct csa *csa)
 224.437 +{     int j, k, len = 0, newlen;
 224.438 +      double s, coef;
 224.439 +loop: /* parse an optional sign */
 224.440 +      if (csa->token == T_PLUS)
 224.441 +         s = +1.0, scan_token(csa);
 224.442 +      else if (csa->token == T_MINUS)
 224.443 +         s = -1.0, scan_token(csa);
 224.444 +      else
 224.445 +         s = +1.0;
 224.446 +      /* parse an optional coefficient */
 224.447 +      if (csa->token == T_NUMBER)
 224.448 +         coef = csa->value, scan_token(csa);
 224.449 +      else
 224.450 +         coef = 1.0;
 224.451 +      /* parse a variable name */
 224.452 +      if (csa->token != T_NAME)
 224.453 +         error(csa, "missing variable name\n");
 224.454 +      /* find the corresponding column */
 224.455 +      j = find_col(csa, csa->image);
 224.456 +      /* check if the variable is already used in the linear form */
 224.457 +      if (csa->flag[j])
 224.458 +         error(csa, "multiple use of variable `%s' not allowed\n",
 224.459 +            csa->image);
 224.460 +      /* add new term to the linear form */
 224.461 +      len++, csa->ind[len] = j, csa->val[len] = s * coef;
 224.462 +      /* and mark that the variable is used in the linear form */
 224.463 +      csa->flag[j] = 1;
 224.464 +      scan_token(csa);
 224.465 +      /* if the next token is a sign, there is another term */
 224.466 +      if (csa->token == T_PLUS || csa->token == T_MINUS) goto loop;
 224.467 +      /* clear marks of the variables used in the linear form */
 224.468 +      for (k = 1; k <= len; k++) csa->flag[csa->ind[k]] = 0;
 224.469 +      /* remove zero coefficients */
 224.470 +      newlen = 0;
 224.471 +      for (k = 1; k <= len; k++)
 224.472 +      {  if (csa->val[k] != 0.0)
 224.473 +         {  newlen++;
 224.474 +            csa->ind[newlen] = csa->ind[k];
 224.475 +            csa->val[newlen] = csa->val[k];
 224.476 +         }
 224.477 +      }
 224.478 +      return newlen;
 224.479 +}
 224.480 +
 224.481 +/***********************************************************************
 224.482 +*  parse_objective - parse objective function
 224.483 +*
 224.484 +*  This routine parses definition of the objective function using the
 224.485 +*  following syntax:
 224.486 +*
 224.487 +*  <obj sense> ::= minimize | minimum | min | maximize | maximum | max
 224.488 +*  <obj name> ::= <empty> | <symbolic name> :
 224.489 +*  <obj function> ::= <obj sense> <obj name> <linear form> */
 224.490 +
 224.491 +static void parse_objective(struct csa *csa)
 224.492 +{     /* parse objective sense */
 224.493 +      int k, len;
 224.494 +      /* parse the keyword 'minimize' or 'maximize' */
 224.495 +      if (csa->token == T_MINIMIZE)
 224.496 +         glp_set_obj_dir(csa->P, GLP_MIN);
 224.497 +      else if (csa->token == T_MAXIMIZE)
 224.498 +         glp_set_obj_dir(csa->P, GLP_MAX);
 224.499 +      else
 224.500 +         xassert(csa != csa);
 224.501 +      scan_token(csa);
 224.502 +      /* parse objective name */
 224.503 +      if (csa->token == T_NAME && csa->c == ':')
 224.504 +      {  /* objective name is followed by a colon */
 224.505 +         glp_set_obj_name(csa->P, csa->image);
 224.506 +         scan_token(csa);
 224.507 +         xassert(csa->token == T_COLON);
 224.508 +         scan_token(csa);
 224.509 +      }
 224.510 +      else
 224.511 +      {  /* objective name is not specified; use default */
 224.512 +         glp_set_obj_name(csa->P, "obj");
 224.513 +      }
 224.514 +      /* parse linear form */
 224.515 +      len = parse_linear_form(csa);
 224.516 +      for (k = 1; k <= len; k++)
 224.517 +         glp_set_obj_coef(csa->P, csa->ind[k], csa->val[k]);
 224.518 +      return;
 224.519 +}
 224.520 +
 224.521 +/***********************************************************************
 224.522 +*  parse_constraints - parse constraints section
 224.523 +*
 224.524 +*  This routine parses the constraints section using the following
 224.525 +*  syntax:
 224.526 +*
 224.527 +*  <row name> ::= <empty> | <symbolic name> :
 224.528 +*  <row sense> ::= < | <= | =< | > | >= | => | =
 224.529 +*  <right-hand side> ::= <numeric constant> | + <numeric constant> |
 224.530 +*     - <numeric constant>
 224.531 +*  <constraint> ::= <row name> <linear form> <row sense>
 224.532 +*     <right-hand side>
 224.533 +*  <subject to> ::= subject to | such that | st | s.t. | st.
 224.534 +*  <constraints section> ::= <subject to> <constraint> |
 224.535 +*     <constraints section> <constraint> */
 224.536 +
 224.537 +static void parse_constraints(struct csa *csa)
 224.538 +{     int i, len, type;
 224.539 +      double s;
 224.540 +      /* parse the keyword 'subject to' */
 224.541 +      xassert(csa->token == T_SUBJECT_TO);
 224.542 +      scan_token(csa);
 224.543 +loop: /* create new row (constraint) */
 224.544 +      i = glp_add_rows(csa->P, 1);
 224.545 +      /* parse row name */
 224.546 +      if (csa->token == T_NAME && csa->c == ':')
 224.547 +      {  /* row name is followed by a colon */
 224.548 +         if (glp_find_row(csa->P, csa->image) != 0)
 224.549 +            error(csa, "constraint `%s' multiply defined\n",
 224.550 +               csa->image);
 224.551 +         glp_set_row_name(csa->P, i, csa->image);
 224.552 +         scan_token(csa);
 224.553 +         xassert(csa->token == T_COLON);
 224.554 +         scan_token(csa);
 224.555 +      }
 224.556 +      else
 224.557 +      {  /* row name is not specified; use default */
 224.558 +         char name[50];
 224.559 +         sprintf(name, "r.%d", csa->count);
 224.560 +         glp_set_row_name(csa->P, i, name);
 224.561 +      }
 224.562 +      /* parse linear form */
 224.563 +      len = parse_linear_form(csa);
 224.564 +      glp_set_mat_row(csa->P, i, len, csa->ind, csa->val);
 224.565 +      /* parse constraint sense */
 224.566 +      if (csa->token == T_LE)
 224.567 +         type = GLP_UP, scan_token(csa);
 224.568 +      else if (csa->token == T_GE)
 224.569 +         type = GLP_LO, scan_token(csa);
 224.570 +      else if (csa->token == T_EQ)
 224.571 +         type = GLP_FX, scan_token(csa);
 224.572 +      else
 224.573 +         error(csa, "missing constraint sense\n");
 224.574 +      /* parse right-hand side */
 224.575 +      if (csa->token == T_PLUS)
 224.576 +         s = +1.0, scan_token(csa);
 224.577 +      else if (csa->token == T_MINUS)
 224.578 +         s = -1.0, scan_token(csa);
 224.579 +      else
 224.580 +         s = +1.0;
 224.581 +      if (csa->token != T_NUMBER)
 224.582 +         error(csa, "missing right-hand side\n");
 224.583 +      glp_set_row_bnds(csa->P, i, type, s * csa->value, s * csa->value);
 224.584 +      /* the rest of the current line must be empty */
 224.585 +      if (!(csa->c == '\n' || csa->c == XEOF))
 224.586 +         error(csa, "invalid symbol(s) beyond right-hand side\n");
 224.587 +      scan_token(csa);
 224.588 +      /* if the next token is a sign, numeric constant, or a symbolic
 224.589 +         name, here is another constraint */
 224.590 +      if (csa->token == T_PLUS || csa->token == T_MINUS ||
 224.591 +          csa->token == T_NUMBER || csa->token == T_NAME) goto loop;
 224.592 +      return;
 224.593 +}
 224.594 +
 224.595 +static void set_lower_bound(struct csa *csa, int j, double lb)
 224.596 +{     /* set lower bound of j-th variable */
 224.597 +      if (csa->lb[j] != +DBL_MAX)
 224.598 +      {  warning(csa, "lower bound of variable `%s' redefined\n",
 224.599 +            glp_get_col_name(csa->P, j));
 224.600 +      }
 224.601 +      csa->lb[j] = lb;
 224.602 +      return;
 224.603 +}
 224.604 +
 224.605 +static void set_upper_bound(struct csa *csa, int j, double ub)
 224.606 +{     /* set upper bound of j-th variable */
 224.607 +      if (csa->ub[j] != -DBL_MAX)
 224.608 +      {  warning(csa, "upper bound of variable `%s' redefined\n",
 224.609 +            glp_get_col_name(csa->P, j));
 224.610 +      }
 224.611 +      csa->ub[j] = ub;
 224.612 +      return;
 224.613 +}
 224.614 +
 224.615 +/***********************************************************************
 224.616 +*  parse_bounds - parse bounds section
 224.617 +*
 224.618 +*  This routine parses the bounds section using the following syntax:
 224.619 +*
 224.620 +*  <variable> ::= <symbolic name>
 224.621 +*  <infinity> ::= infinity | inf
 224.622 +*  <bound> ::= <numeric constant> | + <numeric constant> |
 224.623 +*     - <numeric constant> | + <infinity> | - <infinity>
 224.624 +*  <lt> ::= < | <= | =<
 224.625 +*  <gt> ::= > | >= | =>
 224.626 +*  <bound definition> ::= <bound> <lt> <variable> <lt> <bound> |
 224.627 +*     <bound> <lt> <variable> | <variable> <lt> <bound> |
 224.628 +*     <variable> <gt> <bound> | <variable> = <bound> | <variable> free
 224.629 +*  <bounds> ::= bounds | bound
 224.630 +*  <bounds section> ::= <bounds> |
 224.631 +*     <bounds section> <bound definition> */
 224.632 +
 224.633 +static void parse_bounds(struct csa *csa)
 224.634 +{     int j, lb_flag;
 224.635 +      double lb, s;
 224.636 +      /* parse the keyword 'bounds' */
 224.637 +      xassert(csa->token == T_BOUNDS);
 224.638 +      scan_token(csa);
 224.639 +loop: /* bound definition can start with a sign, numeric constant, or
 224.640 +         a symbolic name */
 224.641 +      if (!(csa->token == T_PLUS || csa->token == T_MINUS ||
 224.642 +            csa->token == T_NUMBER || csa->token == T_NAME)) goto done;
 224.643 +      /* parse bound definition */
 224.644 +      if (csa->token == T_PLUS || csa->token == T_MINUS)
 224.645 +      {  /* parse signed lower bound */
 224.646 +         lb_flag = 1;
 224.647 +         s = (csa->token == T_PLUS ? +1.0 : -1.0);
 224.648 +         scan_token(csa);
 224.649 +         if (csa->token == T_NUMBER)
 224.650 +            lb = s * csa->value, scan_token(csa);
 224.651 +         else if (the_same(csa->image, "infinity") ||
 224.652 +                  the_same(csa->image, "inf"))
 224.653 +         {  if (s > 0.0)
 224.654 +               error(csa, "invalid use of `+inf' as lower bound\n");
 224.655 +            lb = -DBL_MAX, scan_token(csa);
 224.656 +         }
 224.657 +         else
 224.658 +            error(csa, "missing lower bound\n");
 224.659 +      }
 224.660 +      else if (csa->token == T_NUMBER)
 224.661 +      {  /* parse unsigned lower bound */
 224.662 +         lb_flag = 1;
 224.663 +         lb = csa->value, scan_token(csa);
 224.664 +      }
 224.665 +      else
 224.666 +      {  /* lower bound is not specified */
 224.667 +         lb_flag = 0;
 224.668 +      }
 224.669 +      /* parse the token that should follow the lower bound */
 224.670 +      if (lb_flag)
 224.671 +      {  if (csa->token != T_LE)
 224.672 +            error(csa, "missing `<', `<=', or `=<' after lower bound\n")
 224.673 +               ;
 224.674 +         scan_token(csa);
 224.675 +      }
 224.676 +      /* parse variable name */
 224.677 +      if (csa->token != T_NAME)
 224.678 +         error(csa, "missing variable name\n");
 224.679 +      j = find_col(csa, csa->image);
 224.680 +      /* set lower bound */
 224.681 +      if (lb_flag) set_lower_bound(csa, j, lb);
 224.682 +      scan_token(csa);
 224.683 +      /* parse the context that follows the variable name */
 224.684 +      if (csa->token == T_LE)
 224.685 +      {  /* parse upper bound */
 224.686 +         scan_token(csa);
 224.687 +         if (csa->token == T_PLUS || csa->token == T_MINUS)
 224.688 +         {  /* parse signed upper bound */
 224.689 +            s = (csa->token == T_PLUS ? +1.0 : -1.0);
 224.690 +            scan_token(csa);
 224.691 +            if (csa->token == T_NUMBER)
 224.692 +            {  set_upper_bound(csa, j, s * csa->value);
 224.693 +               scan_token(csa);
 224.694 +            }
 224.695 +            else if (the_same(csa->image, "infinity") ||
 224.696 +                     the_same(csa->image, "inf"))
 224.697 +            {  if (s < 0.0)
 224.698 +                  error(csa, "invalid use of `-inf' as upper bound\n");
 224.699 +               set_upper_bound(csa, j, +DBL_MAX);
 224.700 +               scan_token(csa);
 224.701 +            }
 224.702 +            else
 224.703 +               error(csa, "missing upper bound\n");
 224.704 +         }
 224.705 +         else if (csa->token == T_NUMBER)
 224.706 +         {  /* parse unsigned upper bound */
 224.707 +            set_upper_bound(csa, j, csa->value);
 224.708 +            scan_token(csa);
 224.709 +         }
 224.710 +         else
 224.711 +            error(csa, "missing upper bound\n");
 224.712 +      }
 224.713 +      else if (csa->token == T_GE)
 224.714 +      {  /* parse lower bound */
 224.715 +         if (lb_flag)
 224.716 +         {  /* the context '... <= x >= ...' is invalid */
 224.717 +            error(csa, "invalid bound definition\n");
 224.718 +         }
 224.719 +         scan_token(csa);
 224.720 +         if (csa->token == T_PLUS || csa->token == T_MINUS)
 224.721 +         {  /* parse signed lower bound */
 224.722 +            s = (csa->token == T_PLUS ? +1.0 : -1.0);
 224.723 +            scan_token(csa);
 224.724 +            if (csa->token == T_NUMBER)
 224.725 +            {  set_lower_bound(csa, j, s * csa->value);
 224.726 +               scan_token(csa);
 224.727 +            }
 224.728 +            else if (the_same(csa->image, "infinity") ||
 224.729 +                     the_same(csa->image, "inf") == 0)
 224.730 +            {  if (s > 0.0)
 224.731 +                  error(csa, "invalid use of `+inf' as lower bound\n");
 224.732 +               set_lower_bound(csa, j, -DBL_MAX);
 224.733 +               scan_token(csa);
 224.734 +            }
 224.735 +            else
 224.736 +               error(csa, "missing lower bound\n");
 224.737 +         }
 224.738 +         else if (csa->token == T_NUMBER)
 224.739 +         {  /* parse unsigned lower bound */
 224.740 +            set_lower_bound(csa, j, csa->value);
 224.741 +            scan_token(csa);
 224.742 +         }
 224.743 +         else
 224.744 +            error(csa, "missing lower bound\n");
 224.745 +      }
 224.746 +      else if (csa->token == T_EQ)
 224.747 +      {  /* parse fixed value */
 224.748 +         if (lb_flag)
 224.749 +         {  /* the context '... <= x = ...' is invalid */
 224.750 +            error(csa, "invalid bound definition\n");
 224.751 +         }
 224.752 +         scan_token(csa);
 224.753 +         if (csa->token == T_PLUS || csa->token == T_MINUS)
 224.754 +         {  /* parse signed fixed value */
 224.755 +            s = (csa->token == T_PLUS ? +1.0 : -1.0);
 224.756 +            scan_token(csa);
 224.757 +            if (csa->token == T_NUMBER)
 224.758 +            {  set_lower_bound(csa, j, s * csa->value);
 224.759 +               set_upper_bound(csa, j, s * csa->value);
 224.760 +               scan_token(csa);
 224.761 +            }
 224.762 +            else
 224.763 +               error(csa, "missing fixed value\n");
 224.764 +         }
 224.765 +         else if (csa->token == T_NUMBER)
 224.766 +         {  /* parse unsigned fixed value */
 224.767 +            set_lower_bound(csa, j, csa->value);
 224.768 +            set_upper_bound(csa, j, csa->value);
 224.769 +            scan_token(csa);
 224.770 +         }
 224.771 +         else
 224.772 +            error(csa, "missing fixed value\n");
 224.773 +      }
 224.774 +      else if (the_same(csa->image, "free"))
 224.775 +      {  /* parse the keyword 'free' */
 224.776 +         if (lb_flag)
 224.777 +         {  /* the context '... <= x free ...' is invalid */
 224.778 +            error(csa, "invalid bound definition\n");
 224.779 +         }
 224.780 +         set_lower_bound(csa, j, -DBL_MAX);
 224.781 +         set_upper_bound(csa, j, +DBL_MAX);
 224.782 +         scan_token(csa);
 224.783 +      }
 224.784 +      else if (!lb_flag)
 224.785 +      {  /* neither lower nor upper bounds are specified */
 224.786 +         error(csa, "invalid bound definition\n");
 224.787 +      }
 224.788 +      goto loop;
 224.789 +done: return;
 224.790 +}
 224.791 +
 224.792 +/***********************************************************************
 224.793 +*  parse_integer - parse general, integer, or binary section
 224.794 +*
 224.795 +*  <variable> ::= <symbolic name>
 224.796 +*  <general> ::= general | generals | gen
 224.797 +*  <integer> ::= integer | integers | int
 224.798 +*  <binary> ::= binary | binaries | bin
 224.799 +*  <section head> ::= <general> <integer> <binary>
 224.800 +*  <additional section> ::= <section head> |
 224.801 +*     <additional section> <variable> */
 224.802 +
 224.803 +static void parse_integer(struct csa *csa)
 224.804 +{     int j, binary;
 224.805 +      /* parse the keyword 'general', 'integer', or 'binary' */
 224.806 +      if (csa->token == T_GENERAL)
 224.807 +         binary = 0, scan_token(csa);
 224.808 +      else if (csa->token == T_INTEGER)
 224.809 +         binary = 0, scan_token(csa);
 224.810 +      else if (csa->token == T_BINARY)
 224.811 +         binary = 1, scan_token(csa);
 224.812 +      else
 224.813 +         xassert(csa != csa);
 224.814 +      /* parse list of variables (may be empty) */
 224.815 +      while (csa->token == T_NAME)
 224.816 +      {  /* find the corresponding column */
 224.817 +         j = find_col(csa, csa->image);
 224.818 +         /* change kind of the variable */
 224.819 +         glp_set_col_kind(csa->P, j, GLP_IV);
 224.820 +         /* set 0-1 bounds for the binary variable */
 224.821 +         if (binary)
 224.822 +         {  set_lower_bound(csa, j, 0.0);
 224.823 +            set_upper_bound(csa, j, 1.0);
 224.824 +         }
 224.825 +         scan_token(csa);
 224.826 +      }
 224.827 +      return;
 224.828 +}
 224.829 +
 224.830 +int glp_read_lp(glp_prob *P, const glp_cpxcp *parm, const char *fname)
 224.831 +{     /* read problem data in CPLEX LP format */
 224.832 +      glp_cpxcp _parm;
 224.833 +      struct csa _csa, *csa = &_csa;
 224.834 +      int ret;
 224.835 +      xprintf("Reading problem data from `%s'...\n", fname);
 224.836 +      if (parm == NULL)
 224.837 +         glp_init_cpxcp(&_parm), parm = &_parm;
 224.838 +      /* check control parameters */
 224.839 +      check_parm("glp_read_lp", parm);
 224.840 +      /* initialize common storage area */
 224.841 +      csa->P = P;
 224.842 +      csa->parm = parm;
 224.843 +      csa->fname = fname;
 224.844 +      csa->fp = NULL;
 224.845 +      if (setjmp(csa->jump))
 224.846 +      {  ret = 1;
 224.847 +         goto done;
 224.848 +      }
 224.849 +      csa->count = 0;
 224.850 +      csa->c = '\n';
 224.851 +      csa->token = T_EOF;
 224.852 +      csa->image[0] = '\0';
 224.853 +      csa->imlen = 0;
 224.854 +      csa->value = 0.0;
 224.855 +      csa->n_max = 100;
 224.856 +      csa->ind = xcalloc(1+csa->n_max, sizeof(int));
 224.857 +      csa->val = xcalloc(1+csa->n_max, sizeof(double));
 224.858 +      csa->flag = xcalloc(1+csa->n_max, sizeof(char));
 224.859 +      memset(&csa->flag[1], 0, csa->n_max * sizeof(char));
 224.860 +      csa->lb = xcalloc(1+csa->n_max, sizeof(double));
 224.861 +      csa->ub = xcalloc(1+csa->n_max, sizeof(double));
 224.862 +      /* erase problem object */
 224.863 +      glp_erase_prob(P);
 224.864 +      glp_create_index(P);
 224.865 +      /* open input CPLEX LP file */
 224.866 +      csa->fp = xfopen(fname, "r");
 224.867 +      if (csa->fp == NULL)
 224.868 +      {  xprintf("Unable to open `%s' - %s\n", fname, xerrmsg());
 224.869 +         ret = 1;
 224.870 +         goto done;
 224.871 +      }
 224.872 +      /* scan very first token */
 224.873 +      scan_token(csa);
 224.874 +      /* parse definition of the objective function */
 224.875 +      if (!(csa->token == T_MINIMIZE || csa->token == T_MAXIMIZE))
 224.876 +         error(csa, "`minimize' or `maximize' keyword missing\n");
 224.877 +      parse_objective(csa);
 224.878 +      /* parse constraints section */
 224.879 +      if (csa->token != T_SUBJECT_TO)
 224.880 +         error(csa, "constraints section missing\n");
 224.881 +      parse_constraints(csa);
 224.882 +      /* parse optional bounds section */
 224.883 +      if (csa->token == T_BOUNDS) parse_bounds(csa);
 224.884 +      /* parse optional general, integer, and binary sections */
 224.885 +      while (csa->token == T_GENERAL ||
 224.886 +             csa->token == T_INTEGER ||
 224.887 +             csa->token == T_BINARY) parse_integer(csa);
 224.888 +      /* check for the keyword 'end' */
 224.889 +      if (csa->token == T_END)
 224.890 +         scan_token(csa);
 224.891 +      else if (csa->token == T_EOF)
 224.892 +         warning(csa, "keyword `end' missing\n");
 224.893 +      else
 224.894 +         error(csa, "symbol `%s' in wrong position\n", csa->image);
 224.895 +      /* nothing must follow the keyword 'end' (except comments) */
 224.896 +      if (csa->token != T_EOF)
 224.897 +         error(csa, "extra symbol(s) detected beyond `end'\n");
 224.898 +      /* set bounds of variables */
 224.899 +      {  int j, type;
 224.900 +         double lb, ub;
 224.901 +         for (j = 1; j <= P->n; j++)
 224.902 +         {  lb = csa->lb[j];
 224.903 +            ub = csa->ub[j];
 224.904 +            if (lb == +DBL_MAX) lb = 0.0;      /* default lb */
 224.905 +            if (ub == -DBL_MAX) ub = +DBL_MAX; /* default ub */
 224.906 +            if (lb == -DBL_MAX && ub == +DBL_MAX)
 224.907 +               type = GLP_FR;
 224.908 +            else if (ub == +DBL_MAX)
 224.909 +               type = GLP_LO;
 224.910 +            else if (lb == -DBL_MAX)
 224.911 +               type = GLP_UP;
 224.912 +            else if (lb != ub)
 224.913 +               type = GLP_DB;
 224.914 +            else
 224.915 +               type = GLP_FX;
 224.916 +            glp_set_col_bnds(csa->P, j, type, lb, ub);
 224.917 +         }
 224.918 +      }
 224.919 +      /* print some statistics */
 224.920 +      xprintf("%d row%s, %d column%s, %d non-zero%s\n",
 224.921 +         P->m, P->m == 1 ? "" : "s", P->n, P->n == 1 ? "" : "s",
 224.922 +         P->nnz, P->nnz == 1 ? "" : "s");
 224.923 +      if (glp_get_num_int(P) > 0)
 224.924 +      {  int ni = glp_get_num_int(P);
 224.925 +         int nb = glp_get_num_bin(P);
 224.926 +         if (ni == 1)
 224.927 +         {  if (nb == 0)
 224.928 +               xprintf("One variable is integer\n");
 224.929 +            else
 224.930 +               xprintf("One variable is binary\n");
 224.931 +         }
 224.932 +         else
 224.933 +         {  xprintf("%d integer variables, ", ni);
 224.934 +            if (nb == 0)
 224.935 +               xprintf("none");
 224.936 +            else if (nb == 1)
 224.937 +               xprintf("one");
 224.938 +            else if (nb == ni)
 224.939 +               xprintf("all");
 224.940 +            else
 224.941 +               xprintf("%d", nb);
 224.942 +            xprintf(" of which %s binary\n", nb == 1 ? "is" : "are");
 224.943 +         }
 224.944 +      }
 224.945 +      xprintf("%d lines were read\n", csa->count);
 224.946 +      /* problem data has been successfully read */
 224.947 +      glp_delete_index(P);
 224.948 +      glp_sort_matrix(P);
 224.949 +      ret = 0;
 224.950 +done: if (csa->fp != NULL) xfclose(csa->fp);
 224.951 +      xfree(csa->ind);
 224.952 +      xfree(csa->val);
 224.953 +      xfree(csa->flag);
 224.954 +      xfree(csa->lb);
 224.955 +      xfree(csa->ub);
 224.956 +      if (ret != 0) glp_erase_prob(P);
 224.957 +      return ret;
 224.958 +}
 224.959 +
 224.960 +/***********************************************************************
 224.961 +*  NAME
 224.962 +*
 224.963 +*  glp_write_lp - write problem data in CPLEX LP format
 224.964 +*
 224.965 +*  SYNOPSIS
 224.966 +*
 224.967 +*  int glp_write_lp(glp_prob *P, const glp_cpxcp *parm, const char
 224.968 +*     *fname);
 224.969 +*
 224.970 +*  DESCRIPTION
 224.971 +*
 224.972 +*  The routine glp_write_lp writes problem data in CPLEX LP format to
 224.973 +*  a text file.
 224.974 +*
 224.975 +*  The parameter parm is a pointer to the structure glp_cpxcp, which
 224.976 +*  specifies control parameters used by the routine. If parm is NULL,
 224.977 +*  the routine uses default settings.
 224.978 +*
 224.979 +*  The character string fname specifies a name of the text file to be
 224.980 +*  written.
 224.981 +*
 224.982 +*  RETURNS
 224.983 +*
 224.984 +*  If the operation was successful, the routine glp_write_lp returns
 224.985 +*  zero. Otherwise, it prints an error message and returns non-zero. */
 224.986 +
 224.987 +#define csa csa1
 224.988 +
 224.989 +struct csa
 224.990 +{     /* common storage area */
 224.991 +      glp_prob *P;
 224.992 +      /* pointer to problem object */
 224.993 +      const glp_cpxcp *parm;
 224.994 +      /* pointer to control parameters */
 224.995 +};
 224.996 +
 224.997 +static int check_name(char *name)
 224.998 +{     /* check if specified name is valid for CPLEX LP format */
 224.999 +      if (*name == '.') return 1;
224.1000 +      if (isdigit((unsigned char)*name)) return 1;
224.1001 +      for (; *name; name++)
224.1002 +      {  if (!isalnum((unsigned char)*name) &&
224.1003 +             strchr(CHAR_SET, (unsigned char)*name) == NULL) return 1;
224.1004 +      }
224.1005 +      return 0; /* name is ok */
224.1006 +}
224.1007 +
224.1008 +static void adjust_name(char *name)
224.1009 +{     /* attempt to adjust specified name to make it valid for CPLEX LP
224.1010 +         format */
224.1011 +      for (; *name; name++)
224.1012 +      {  if (*name == ' ')
224.1013 +            *name = '_';
224.1014 +         else if (*name == '-')
224.1015 +            *name = '~';
224.1016 +         else if (*name == '[')
224.1017 +            *name = '(';
224.1018 +         else if (*name == ']')
224.1019 +            *name = ')';
224.1020 +      }
224.1021 +      return;
224.1022 +}
224.1023 +
224.1024 +static char *row_name(struct csa *csa, int i, char rname[255+1])
224.1025 +{     /* construct symbolic name of i-th row (constraint) */
224.1026 +      const char *name;
224.1027 +      if (i == 0)
224.1028 +         name = glp_get_obj_name(csa->P);
224.1029 +      else
224.1030 +         name = glp_get_row_name(csa->P, i);
224.1031 +      if (name == NULL) goto fake;
224.1032 +      strcpy(rname, name);
224.1033 +      adjust_name(rname);
224.1034 +      if (check_name(rname)) goto fake;
224.1035 +      return rname;
224.1036 +fake: if (i == 0)
224.1037 +         strcpy(rname, "obj");
224.1038 +      else
224.1039 +         sprintf(rname, "r_%d", i);
224.1040 +      return rname;
224.1041 +}
224.1042 +
224.1043 +static char *col_name(struct csa *csa, int j, char cname[255+1])
224.1044 +{     /* construct symbolic name of j-th column (variable) */
224.1045 +      const char *name;
224.1046 +      name = glp_get_col_name(csa->P, j);
224.1047 +      if (name == NULL) goto fake;
224.1048 +      strcpy(cname, name);
224.1049 +      adjust_name(cname);
224.1050 +      if (check_name(cname)) goto fake;
224.1051 +      return cname;
224.1052 +fake: sprintf(cname, "x_%d", j);
224.1053 +      return cname;
224.1054 +}
224.1055 +
224.1056 +int glp_write_lp(glp_prob *P, const glp_cpxcp *parm, const char *fname)
224.1057 +{     /* write problem data in CPLEX LP format */
224.1058 +      glp_cpxcp _parm;
224.1059 +      struct csa _csa, *csa = &_csa;
224.1060 +      XFILE *fp;
224.1061 +      GLPROW *row;
224.1062 +      GLPCOL *col;
224.1063 +      GLPAIJ *aij;
224.1064 +      int i, j, len, flag, count, ret;
224.1065 +      char line[1000+1], term[500+1], name[255+1];
224.1066 +      xprintf("Writing problem data to `%s'...\n", fname);
224.1067 +      if (parm == NULL)
224.1068 +         glp_init_cpxcp(&_parm), parm = &_parm;
224.1069 +      /* check control parameters */
224.1070 +      check_parm("glp_write_lp", parm);
224.1071 +      /* initialize common storage area */
224.1072 +      csa->P = P;
224.1073 +      csa->parm = parm;
224.1074 +      /* create output CPLEX LP file */
224.1075 +      fp = xfopen(fname, "w"), count = 0;
224.1076 +      if (fp == NULL)
224.1077 +      {  xprintf("Unable to create `%s' - %s\n", fname, xerrmsg());
224.1078 +         ret = 1;
224.1079 +         goto done;
224.1080 +      }
224.1081 +      /* write problem name */
224.1082 +      xfprintf(fp, "\\* Problem: %s *\\\n",
224.1083 +         P->name == NULL ? "Unknown" : P->name), count++;
224.1084 +      xfprintf(fp, "\n"), count++;
224.1085 +      /* the problem should contain at least one row and one column */
224.1086 +      if (!(P->m > 0 && P->n > 0))
224.1087 +      {  xprintf("Warning: problem has no rows/columns\n");
224.1088 +         xfprintf(fp, "\\* WARNING: PROBLEM HAS NO ROWS/COLUMNS *\\\n"),
224.1089 +            count++;
224.1090 +         xfprintf(fp, "\n"), count++;
224.1091 +         goto skip;
224.1092 +      }
224.1093 +      /* write the objective function definition */
224.1094 +      if (P->dir == GLP_MIN)
224.1095 +         xfprintf(fp, "Minimize\n"), count++;
224.1096 +      else if (P->dir == GLP_MAX)
224.1097 +         xfprintf(fp, "Maximize\n"), count++;
224.1098 +      else
224.1099 +         xassert(P != P);
224.1100 +      row_name(csa, 0, name);
224.1101 +      sprintf(line, " %s:", name);
224.1102 +      len = 0;
224.1103 +      for (j = 1; j <= P->n; j++)
224.1104 +      {  col = P->col[j];
224.1105 +         if (col->coef != 0.0 || col->ptr == NULL)
224.1106 +         {  len++;
224.1107 +            col_name(csa, j, name);
224.1108 +            if (col->coef == 0.0)
224.1109 +               sprintf(term, " + 0 %s", name); /* empty column */
224.1110 +            else if (col->coef == +1.0)
224.1111 +               sprintf(term, " + %s", name);
224.1112 +            else if (col->coef == -1.0)
224.1113 +               sprintf(term, " - %s", name);
224.1114 +            else if (col->coef > 0.0)
224.1115 +               sprintf(term, " + %.*g %s", DBL_DIG, +col->coef, name);
224.1116 +            else
224.1117 +               sprintf(term, " - %.*g %s", DBL_DIG, -col->coef, name);
224.1118 +            if (strlen(line) + strlen(term) > 72)
224.1119 +               xfprintf(fp, "%s\n", line), line[0] = '\0', count++;
224.1120 +            strcat(line, term);
224.1121 +         }
224.1122 +      }
224.1123 +      if (len == 0)
224.1124 +      {  /* empty objective */
224.1125 +         sprintf(term, " 0 %s", col_name(csa, 1, name));
224.1126 +         strcat(line, term);
224.1127 +      }
224.1128 +      xfprintf(fp, "%s\n", line), count++;
224.1129 +      if (P->c0 != 0.0)
224.1130 +         xfprintf(fp, "\\* constant term = %.*g *\\\n", DBL_DIG, P->c0),
224.1131 +            count++;
224.1132 +      xfprintf(fp, "\n"), count++;
224.1133 +      /* write the constraints section */
224.1134 +      xfprintf(fp, "Subject To\n"), count++;
224.1135 +      for (i = 1; i <= P->m; i++)
224.1136 +      {  row = P->row[i];
224.1137 +         if (row->type == GLP_FR) continue; /* skip free row */
224.1138 +         row_name(csa, i, name);
224.1139 +         sprintf(line, " %s:", name);
224.1140 +         /* linear form */
224.1141 +         for (aij = row->ptr; aij != NULL; aij = aij->r_next)
224.1142 +         {  col_name(csa, aij->col->j, name);
224.1143 +            if (aij->val == +1.0)
224.1144 +               sprintf(term, " + %s", name);
224.1145 +            else if (aij->val == -1.0)
224.1146 +               sprintf(term, " - %s", name);
224.1147 +            else if (aij->val > 0.0)
224.1148 +               sprintf(term, " + %.*g %s", DBL_DIG, +aij->val, name);
224.1149 +            else
224.1150 +               sprintf(term, " - %.*g %s", DBL_DIG, -aij->val, name);
224.1151 +            if (strlen(line) + strlen(term) > 72)
224.1152 +               xfprintf(fp, "%s\n", line), line[0] = '\0', count++;
224.1153 +            strcat(line, term);
224.1154 +         }
224.1155 +         if (row->type == GLP_DB)
224.1156 +         {  /* double-bounded (ranged) constraint */
224.1157 +            sprintf(term, " - ~r_%d", i);
224.1158 +            if (strlen(line) + strlen(term) > 72)
224.1159 +               xfprintf(fp, "%s\n", line), line[0] = '\0', count++;
224.1160 +            strcat(line, term);
224.1161 +         }
224.1162 +         else if (row->ptr == NULL)
224.1163 +         {  /* empty constraint */
224.1164 +            sprintf(term, " 0 %s", col_name(csa, 1, name));
224.1165 +            strcat(line, term);
224.1166 +         }
224.1167 +         /* right hand-side */
224.1168 +         if (row->type == GLP_LO)
224.1169 +            sprintf(term, " >= %.*g", DBL_DIG, row->lb);
224.1170 +         else if (row->type == GLP_UP)
224.1171 +            sprintf(term, " <= %.*g", DBL_DIG, row->ub);
224.1172 +         else if (row->type == GLP_DB || row->type == GLP_FX)
224.1173 +            sprintf(term, " = %.*g", DBL_DIG, row->lb);
224.1174 +         else
224.1175 +            xassert(row != row);
224.1176 +         if (strlen(line) + strlen(term) > 72)
224.1177 +            xfprintf(fp, "%s\n", line), line[0] = '\0', count++;
224.1178 +         strcat(line, term);
224.1179 +         xfprintf(fp, "%s\n", line), count++;
224.1180 +      }
224.1181 +      xfprintf(fp, "\n"), count++;
224.1182 +      /* write the bounds section */
224.1183 +      flag = 0;
224.1184 +      for (i = 1; i <= P->m; i++)
224.1185 +      {  row = P->row[i];
224.1186 +         if (row->type != GLP_DB) continue;
224.1187 +         if (!flag)
224.1188 +            xfprintf(fp, "Bounds\n"), flag = 1, count++;
224.1189 +         xfprintf(fp, " 0 <= ~r_%d <= %.*g\n",
224.1190 +            i, DBL_DIG, row->ub - row->lb), count++;
224.1191 +      }
224.1192 +      for (j = 1; j <= P->n; j++)
224.1193 +      {  col = P->col[j];
224.1194 +         if (col->type == GLP_LO && col->lb == 0.0) continue;
224.1195 +         if (!flag)
224.1196 +            xfprintf(fp, "Bounds\n"), flag = 1, count++;
224.1197 +         col_name(csa, j, name);
224.1198 +         if (col->type == GLP_FR)
224.1199 +            xfprintf(fp, " %s free\n", name), count++;
224.1200 +         else if (col->type == GLP_LO)
224.1201 +            xfprintf(fp, " %s >= %.*g\n",
224.1202 +               name, DBL_DIG, col->lb), count++;
224.1203 +         else if (col->type == GLP_UP)
224.1204 +            xfprintf(fp, " -Inf <= %s <= %.*g\n",
224.1205 +               name, DBL_DIG, col->ub), count++;
224.1206 +         else if (col->type == GLP_DB)
224.1207 +            xfprintf(fp, " %.*g <= %s <= %.*g\n",
224.1208 +               DBL_DIG, col->lb, name, DBL_DIG, col->ub), count++;
224.1209 +         else if (col->type == GLP_FX)
224.1210 +            xfprintf(fp, " %s = %.*g\n",
224.1211 +               name, DBL_DIG, col->lb), count++;
224.1212 +         else
224.1213 +            xassert(col != col);
224.1214 +      }
224.1215 +      if (flag) xfprintf(fp, "\n"), count++;
224.1216 +      /* write the integer section */
224.1217 +      flag = 0;
224.1218 +      for (j = 1; j <= P->n; j++)
224.1219 +      {  col = P->col[j];
224.1220 +         if (col->kind == GLP_CV) continue;
224.1221 +         xassert(col->kind == GLP_IV);
224.1222 +         if (!flag)
224.1223 +            xfprintf(fp, "Generals\n"), flag = 1, count++;
224.1224 +         xfprintf(fp, " %s\n", col_name(csa, j, name)), count++;
224.1225 +      }
224.1226 +      if (flag) xfprintf(fp, "\n"), count++;
224.1227 +skip: /* write the end keyword */
224.1228 +      xfprintf(fp, "End\n"), count++;
224.1229 +      xfflush(fp);
224.1230 +      if (xferror(fp))
224.1231 +      {  xprintf("Write error on `%s' - %s\n", fname, xerrmsg());
224.1232 +         ret = 1;
224.1233 +         goto done;
224.1234 +      }
224.1235 +      /* problem data has been successfully written */
224.1236 +      xprintf("%d lines were written\n", count);
224.1237 +      ret = 0;
224.1238 +done: if (fp != NULL) xfclose(fp);
224.1239 +      return ret;
224.1240 +}
224.1241 +
224.1242 +/* eof */
   225.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
   225.2 +++ b/deps/glpk/src/glpdmp.c	Sun Nov 06 20:59:10 2011 +0100
   225.3 @@ -0,0 +1,259 @@
   225.4 +/* glpdmp.c (dynamic memory pool) */
   225.5 +
   225.6 +/***********************************************************************
   225.7 +*  This code is part of GLPK (GNU Linear Programming Kit).
   225.8 +*
   225.9 +*  Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008,
  225.10 +*  2009, 2010, 2011 Andrew Makhorin, Department for Applied Informatics,
  225.11 +*  Moscow Aviation Institute, Moscow, Russia. All rights reserved.
  225.12 +*  E-mail: <mao@gnu.org>.
  225.13 +*
  225.14 +*  GLPK is free software: you can redistribute it and/or modify it
  225.15 +*  under the terms of the GNU General Public License as published by
  225.16 +*  the Free Software Foundation, either version 3 of the License, or
  225.17 +*  (at your option) any later version.
  225.18 +*
  225.19 +*  GLPK is distributed in the hope that it will be useful, but WITHOUT
  225.20 +*  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
  225.21 +*  or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
  225.22 +*  License for more details.
  225.23 +*
  225.24 +*  You should have received a copy of the GNU General Public License
  225.25 +*  along with GLPK. If not, see <http://www.gnu.org/licenses/>.
  225.26 +***********************************************************************/
  225.27 +
  225.28 +#include "glpdmp.h"
  225.29 +
  225.30 +#if 1 /* 29/VIII-2008 */
  225.31 +/* some processors need data to be properly aligned; the macro
  225.32 +   align_datasize enlarges the specified size of a data item to provide
  225.33 +   a proper alignment of immediately following data */
  225.34 +
  225.35 +#define align_datasize(size) ((((size) + 7) / 8) * 8)
  225.36 +/* 8 bytes is sufficient in both 32- and 64-bit environments */
  225.37 +#endif
  225.38 +
  225.39 +#ifdef GLP_DEBUG
  225.40 +struct info
  225.41 +{     DMP *pool;
  225.42 +      int size;
  225.43 +};
  225.44 +#endif
  225.45 +
  225.46 +/***********************************************************************
  225.47 +*  NAME
  225.48 +*
  225.49 +*  dmp_create_pool - create dynamic memory pool
  225.50 +*
  225.51 +*  SYNOPSIS
  225.52 +*
  225.53 +*  #include "glpdmp.h"
  225.54 +*  DMP *dmp_create_pool(void);
  225.55 +*
  225.56 +*  DESCRIPTION
  225.57 +*
  225.58 +*  The routine dmp_create_pool creates a dynamic memory pool.
  225.59 +*
  225.60 +*  RETURNS
  225.61 +*
  225.62 +*  The routine returns a pointer to the memory pool created. */
  225.63 +
  225.64 +DMP *dmp_create_pool(void)
  225.65 +{     DMP *pool;
  225.66 +      int k;
  225.67 +#ifdef GLP_DEBUG
  225.68 +      xprintf("dmp_create_pool: warning: debug mode enabled\n");
  225.69 +#endif
  225.70 +      pool = xmalloc(sizeof(DMP));
  225.71 +#if 0
  225.72 +      pool->size = 0;
  225.73 +#endif
  225.74 +      for (k = 0; k <= 31; k++) pool->avail[k] = NULL;
  225.75 +      pool->block = NULL;
  225.76 +      pool->used = DMP_BLK_SIZE;
  225.77 +      pool->count.lo = pool->count.hi = 0;
  225.78 +      return pool;
  225.79 +}
  225.80 +
  225.81 +/***********************************************************************
  225.82 +*  NAME
  225.83 +*
  225.84 +*  dmp_get_atom - get free atom from dynamic memory pool
  225.85 +*
  225.86 +*  SYNOPSIS
  225.87 +*
  225.88 +*  #include "glpdmp.h"
  225.89 +*  void *dmp_get_atom(DMP *pool, int size);
  225.90 +*
  225.91 +*  DESCRIPTION
  225.92 +*
  225.93 +*  The routine dmp_get_atom obtains a free atom (memory block) from the
  225.94 +*  specified memory pool.
  225.95 +*
  225.96 +*  The parameter size is the atom size, in bytes, 1 <= size <= 256.
  225.97 +*
  225.98 +*  Note that the free atom contains arbitrary data, not binary zeros.
  225.99 +*
 225.100 +*  RETURNS
 225.101 +*
 225.102 +*  The routine returns a pointer to the free atom obtained. */
 225.103 +
 225.104 +void *dmp_get_atom(DMP *pool, int size)
 225.105 +{     void *atom;
 225.106 +      int k;
 225.107 +#ifdef GLP_DEBUG
 225.108 +      int orig_size = size;
 225.109 +#endif
 225.110 +      if (!(1 <= size && size <= 256))
 225.111 +         xerror("dmp_get_atom: size = %d; invalid atom size\n", size);
 225.112 +#if 0
 225.113 +      if (!(pool->size == 0 || pool->size == size))
 225.114 +         xerror("dmp_get_atom: size = %d; wrong atom size\n", size);
 225.115 +#endif
 225.116 +      /* adjust the size to provide the proper data alignment */
 225.117 +      size = align_datasize(size);
 225.118 +#ifdef GLP_DEBUG
 225.119 +      size += align_datasize(sizeof(struct info));
 225.120 +#endif
 225.121 +      /* adjust the size to make it multiple of 8 bytes, if needed */
 225.122 +      size = ((size + 7) / 8) * 8;
 225.123 +      /* determine the corresponding list of free cells */
 225.124 +      k = size / 8 - 1;
 225.125 +      xassert(0 <= k && k <= 31);
 225.126 +      /* obtain a free atom */
 225.127 +      if (pool->avail[k] == NULL)
 225.128 +      {  /* the list of free cells is empty */
 225.129 +         if (pool->used + size > DMP_BLK_SIZE)
 225.130 +         {  /* allocate a new memory block */
 225.131 +            void *block = xmalloc(DMP_BLK_SIZE);
 225.132 +            *(void **)block = pool->block;
 225.133 +            pool->block = block;
 225.134 +            pool->used = align_datasize(sizeof(void *));
 225.135 +         }
 225.136 +         /* place the atom in the current memory block */
 225.137 +         atom = (char *)pool->block + pool->used;
 225.138 +         pool->used += size;
 225.139 +      }
 225.140 +      else
 225.141 +      {  /* obtain the atom from the list of free cells */
 225.142 +         atom = pool->avail[k];
 225.143 +         pool->avail[k] = *(void **)atom;
 225.144 +      }
 225.145 +      memset(atom, '?', size);
 225.146 +      /* increase the number of atoms which are currently in use */
 225.147 +      pool->count.lo++;
 225.148 +      if (pool->count.lo == 0) pool->count.hi++;
 225.149 +#ifdef GLP_DEBUG
 225.150 +      ((struct info *)atom)->pool = pool;
 225.151 +      ((struct info *)atom)->size = orig_size;
 225.152 +      atom = (char *)atom + align_datasize(sizeof(struct info));
 225.153 +#endif
 225.154 +      return atom;
 225.155 +}
 225.156 +
 225.157 +/***********************************************************************
 225.158 +*  NAME
 225.159 +*
 225.160 +*  dmp_free_atom - return atom to dynamic memory pool
 225.161 +*
 225.162 +*  SYNOPSIS
 225.163 +*
 225.164 +*  #include "glpdmp.h"
 225.165 +*  void dmp_free_atom(DMP *pool, void *atom, int size);
 225.166 +*
 225.167 +*  DESCRIPTION
 225.168 +*
 225.169 +*  The routine dmp_free_atom returns the specified atom (memory block)
 225.170 +*  to the specified memory pool, making it free.
 225.171 +*
 225.172 +*  The parameter size is the atom size, in bytes, 1 <= size <= 256.
 225.173 +*
 225.174 +*  Note that the atom can be returned only to the pool, from which it
 225.175 +*  was obtained, and its size must be exactly the same as on obtaining
 225.176 +*  it from the pool. */
 225.177 +
 225.178 +void dmp_free_atom(DMP *pool, void *atom, int size)
 225.179 +{     int k;
 225.180 +      if (!(1 <= size && size <= 256))
 225.181 +         xerror("dmp_free_atom: size = %d; invalid atom size\n", size);
 225.182 +#if 0
 225.183 +      if (!(pool->size == 0 || pool->size == size))
 225.184 +         xerror("dmp_free_atom: size = %d; wrong atom size\n", size);
 225.185 +#endif
 225.186 +      if (pool->count.lo == 0 && pool->count.hi == 0)
 225.187 +         xerror("dmp_free_atom: pool allocation error\n");
 225.188 +#ifdef GLP_DEBUG
 225.189 +      atom = (char *)atom - align_datasize(sizeof(struct info));
 225.190 +      xassert(((struct info *)atom)->pool == pool);
 225.191 +      xassert(((struct info *)atom)->size == size);
 225.192 +#endif
 225.193 +      /* adjust the size to provide the proper data alignment */
 225.194 +      size = align_datasize(size);
 225.195 +#ifdef GLP_DEBUG
 225.196 +      size += align_datasize(sizeof(struct info));
 225.197 +#endif
 225.198 +      /* adjust the size to make it multiple of 8 bytes, if needed */
 225.199 +      size = ((size + 7) / 8) * 8;
 225.200 +      /* determine the corresponding list of free cells */
 225.201 +      k = size / 8 - 1;
 225.202 +      xassert(0 <= k && k <= 31);
 225.203 +      /* return the atom to the list of free cells */
 225.204 +      *(void **)atom = pool->avail[k];
 225.205 +      pool->avail[k] = atom;
 225.206 +      /* decrease the number of atoms which are currently in use */
 225.207 +      pool->count.lo--;
 225.208 +      if (pool->count.lo == 0xFFFFFFFF) pool->count.hi--;
 225.209 +      return;
 225.210 +}
 225.211 +
 225.212 +/***********************************************************************
 225.213 +*  NAME
 225.214 +*
 225.215 +*  dmp_in_use - determine how many atoms are still in use
 225.216 +*
 225.217 +*  SYNOPSIS
 225.218 +*
 225.219 +*  #include "glpdmp.h"
 225.220 +*  glp_long dmp_in_use(DMP *pool);
 225.221 +*
 225.222 +*  DESCRIPTION
 225.223 +*
 225.224 +*  The routine dmp_in_use determines how many atoms allocated from the
 225.225 +*  specified memory pool with the routine dmp_get_atom are still in use,
 225.226 +*  i.e. not returned to the pool with the routine dmp_free_atom.
 225.227 +*
 225.228 +*  RETURNS
 225.229 +*
 225.230 +*  The routine returns the number of atoms which are still in use. */
 225.231 +
 225.232 +glp_long dmp_in_use(DMP *pool)
 225.233 +{     return
 225.234 +         pool->count;
 225.235 +}
 225.236 +
 225.237 +/***********************************************************************
 225.238 +*  NAME
 225.239 +*
 225.240 +*  dmp_delete_pool - delete dynamic memory pool
 225.241 +*
 225.242 +*  SYNOPSIS
 225.243 +*
 225.244 +*  #include "glpdmp.h"
 225.245 +*  void dmp_delete_pool(DMP *pool);
 225.246 +*
 225.247 +*  DESCRIPTION
 225.248 +*
 225.249 +*  The routine dmp_delete_pool deletes the specified dynamic memory
 225.250 +*  pool and frees all the memory allocated to this object. */
 225.251 +
 225.252 +void dmp_delete_pool(DMP *pool)
 225.253 +{     while (pool->block != NULL)
 225.254 +      {  void *block = pool->block;
 225.255 +         pool->block = *(void **)block;
 225.256 +         xfree(block);
 225.257 +      }
 225.258 +      xfree(pool);
 225.259 +      return;
 225.260 +}
 225.261 +
 225.262 +/* eof */
   226.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
   226.2 +++ b/deps/glpk/src/glpdmp.h	Sun Nov 06 20:59:10 2011 +0100
   226.3 @@ -0,0 +1,80 @@
   226.4 +/* glpdmp.h (dynamic memory pool) */
   226.5 +
   226.6 +/***********************************************************************
   226.7 +*  This code is part of GLPK (GNU Linear Programming Kit).
   226.8 +*
   226.9 +*  Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008,
  226.10 +*  2009, 2010, 2011 Andrew Makhorin, Department for Applied Informatics,
  226.11 +*  Moscow Aviation Institute, Moscow, Russia. All rights reserved.
  226.12 +*  E-mail: <mao@gnu.org>.
  226.13 +*
  226.14 +*  GLPK is free software: you can redistribute it and/or modify it
  226.15 +*  under the terms of the GNU General Public License as published by
  226.16 +*  the Free Software Foundation, either version 3 of the License, or
  226.17 +*  (at your option) any later version.
  226.18 +*
  226.19 +*  GLPK is distributed in the hope that it will be useful, but WITHOUT
  226.20 +*  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
  226.21 +*  or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
  226.22 +*  License for more details.
  226.23 +*
  226.24 +*  You should have received a copy of the GNU General Public License
  226.25 +*  along with GLPK. If not, see <http://www.gnu.org/licenses/>.
  226.26 +***********************************************************************/
  226.27 +
  226.28 +#ifndef GLPDMP_H
  226.29 +#define GLPDMP_H
  226.30 +
  226.31 +#include "glpenv.h"
  226.32 +
  226.33 +typedef struct DMP DMP;
  226.34 +
  226.35 +#define DMP_BLK_SIZE 8000
  226.36 +/* size of memory blocks, in bytes, allocated for memory pools */
  226.37 +
  226.38 +struct DMP
  226.39 +{     /* dynamic memory pool */
  226.40 +#if 0
  226.41 +      int size;
  226.42 +      /* size of atoms, in bytes, 1 <= size <= 256; if size = 0, atoms
  226.43 +         may have different sizes */
  226.44 +#endif
  226.45 +      void *avail[32];
  226.46 +      /* avail[k], 0 <= k <= 31, is a pointer to the first available
  226.47 +         (free) cell of (k+1)*8 bytes long; in the beginning of each
  226.48 +         free cell there is a pointer to another free cell of the same
  226.49 +         length */
  226.50 +      void *block;
  226.51 +      /* pointer to the most recently allocated memory block; in the
  226.52 +         beginning of each allocated memory block there is a pointer to
  226.53 +         the previously allocated memory block */
  226.54 +      int used;
  226.55 +      /* number of bytes used in the most recently allocated memory
  226.56 +         block */
  226.57 +      glp_long count;
  226.58 +      /* number of atoms which are currently in use */
  226.59 +};
  226.60 +
  226.61 +#define dmp_create_pool _glp_dmp_create_pool
  226.62 +DMP *dmp_create_pool(void);
  226.63 +/* create dynamic memory pool */
  226.64 +
  226.65 +#define dmp_get_atom _glp_dmp_get_atom
  226.66 +void *dmp_get_atom(DMP *pool, int size);
  226.67 +/* get free atom from dynamic memory pool */
  226.68 +
  226.69 +#define dmp_free_atom _glp_dmp_free_atom
  226.70 +void dmp_free_atom(DMP *pool, void *atom, int size);
  226.71 +/* return atom to dynamic memory pool */
  226.72 +
  226.73 +#define dmp_in_use _glp_dmp_in_use
  226.74 +glp_long dmp_in_use(DMP *pool);
  226.75 +/* determine how many atoms are still in use */
  226.76 +
  226.77 +#define dmp_delete_pool _glp_dmp_delete_pool
  226.78 +void dmp_delete_pool(DMP *pool);
  226.79 +/* delete dynamic memory pool */
  226.80 +
  226.81 +#endif
  226.82 +
  226.83 +/* eof */
   227.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
   227.2 +++ b/deps/glpk/src/glpdmx.c	Sun Nov 06 20:59:10 2011 +0100
   227.3 @@ -0,0 +1,1678 @@
   227.4 +/* glpdmx.c (reading/writing data in DIMACS format) */
   227.5 +
   227.6 +/***********************************************************************
   227.7 +*  This code is part of GLPK (GNU Linear Programming Kit).
   227.8 +*
   227.9 +*  Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008,
  227.10 +*  2009, 2010, 2011 Andrew Makhorin, Department for Applied Informatics,
  227.11 +*  Moscow Aviation Institute, Moscow, Russia. All rights reserved.
  227.12 +*  E-mail: <mao@gnu.org>.
  227.13 +*
  227.14 +*  GLPK is free software: you can redistribute it and/or modify it
  227.15 +*  under the terms of the GNU General Public License as published by
  227.16 +*  the Free Software Foundation, either version 3 of the License, or
  227.17 +*  (at your option) any later version.
  227.18 +*
  227.19 +*  GLPK is distributed in the hope that it will be useful, but WITHOUT
  227.20 +*  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
  227.21 +*  or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
  227.22 +*  License for more details.
  227.23 +*
  227.24 +*  You should have received a copy of the GNU General Public License
  227.25 +*  along with GLPK. If not, see <http://www.gnu.org/licenses/>.
  227.26 +***********************************************************************/
  227.27 +
  227.28 +#define _GLPSTD_STDIO
  227.29 +#include "glpapi.h"
  227.30 +
  227.31 +struct csa
  227.32 +{     /* common storage area */
  227.33 +      jmp_buf jump;
  227.34 +      /* label for go to in case of error */
  227.35 +      const char *fname;
  227.36 +      /* name of input text file */
  227.37 +      XFILE *fp;
  227.38 +      /* stream assigned to input text file */
  227.39 +      int count;
  227.40 +      /* line count */
  227.41 +      int c;
  227.42 +      /* current character */
  227.43 +      char field[255+1];
  227.44 +      /* data field */
  227.45 +      int empty;
  227.46 +      /* warning 'empty line ignored' was printed */
  227.47 +      int nonint;
  227.48 +      /* warning 'non-integer data detected' was printed */
  227.49 +};
  227.50 +
  227.51 +static void error(struct csa *csa, const char *fmt, ...)
  227.52 +{     /* print error message and terminate processing */
  227.53 +      va_list arg;
  227.54 +      xprintf("%s:%d: error: ", csa->fname, csa->count);
  227.55 +      va_start(arg, fmt);
  227.56 +      xvprintf(fmt, arg);
  227.57 +      va_end(arg);
  227.58 +      xprintf("\n");
  227.59 +      longjmp(csa->jump, 1);
  227.60 +      /* no return */
  227.61 +}
  227.62 +
  227.63 +static void warning(struct csa *csa, const char *fmt, ...)
  227.64 +{     /* print warning message and continue processing */
  227.65 +      va_list arg;
  227.66 +      xprintf("%s:%d: warning: ", csa->fname, csa->count);
  227.67 +      va_start(arg, fmt);
  227.68 +      xvprintf(fmt, arg);
  227.69 +      va_end(arg);
  227.70 +      xprintf("\n");
  227.71 +      return;
  227.72 +}
  227.73 +
  227.74 +static void read_char(struct csa *csa)
  227.75 +{     /* read character from input text file */
  227.76 +      int c;
  227.77 +      if (csa->c == '\n') csa->count++;
  227.78 +      c = xfgetc(csa->fp);
  227.79 +      if (c < 0)
  227.80 +      {  if (xferror(csa->fp))
  227.81 +            error(csa, "read error - %s", xerrmsg());
  227.82 +         else if (csa->c == '\n')
  227.83 +            error(csa, "unexpected end of file");
  227.84 +         else
  227.85 +         {  warning(csa, "missing final end of line");
  227.86 +            c = '\n';
  227.87 +         }
  227.88 +      }
  227.89 +      else if (c == '\n')
  227.90 +         ;
  227.91 +      else if (isspace(c))
  227.92 +         c = ' ';
  227.93 +      else if (iscntrl(c))
  227.94 +         error(csa, "invalid control character 0x%02X", c);
  227.95 +      csa->c = c;
  227.96 +      return;
  227.97 +}
  227.98 +
  227.99 +static void read_designator(struct csa *csa)
 227.100 +{     /* read one-character line designator */
 227.101 +      xassert(csa->c == '\n');
 227.102 +      read_char(csa);
 227.103 +      for (;;)
 227.104 +      {  /* skip preceding white-space characters */
 227.105 +         while (csa->c == ' ')
 227.106 +            read_char(csa);
 227.107 +         if (csa->c == '\n')
 227.108 +         {  /* ignore empty line */
 227.109 +            if (!csa->empty)
 227.110 +            {  warning(csa, "empty line ignored");
 227.111 +               csa->empty = 1;
 227.112 +            }
 227.113 +            read_char(csa);
 227.114 +         }
 227.115 +         else if (csa->c == 'c')
 227.116 +         {  /* skip comment line */
 227.117 +            while (csa->c != '\n')
 227.118 +               read_char(csa);
 227.119 +            read_char(csa);
 227.120 +         }
 227.121 +         else
 227.122 +         {  /* hmm... looks like a line designator */
 227.123 +            csa->field[0] = (char)csa->c, csa->field[1] = '\0';
 227.124 +            /* check that it is followed by a white-space character */
 227.125 +            read_char(csa);
 227.126 +            if (!(csa->c == ' ' || csa->c == '\n'))
 227.127 +               error(csa, "line designator missing or invalid");
 227.128 +            break;
 227.129 +         }
 227.130 +      }
 227.131 +      return;
 227.132 +}
 227.133 +
 227.134 +static void read_field(struct csa *csa)
 227.135 +{     /* read data field */
 227.136 +      int len = 0;
 227.137 +      /* skip preceding white-space characters */
 227.138 +      while (csa->c == ' ')
 227.139 +         read_char(csa);
 227.140 +      /* scan data field */
 227.141 +      if (csa->c == '\n')
 227.142 +         error(csa, "unexpected end of line");
 227.143 +      while (!(csa->c == ' ' || csa->c == '\n'))
 227.144 +      {  if (len == sizeof(csa->field)-1)
 227.145 +            error(csa, "data field `%.15s...' too long", csa->field);
 227.146 +         csa->field[len++] = (char)csa->c;
 227.147 +         read_char(csa);
 227.148 +      }
 227.149 +      csa->field[len] = '\0';
 227.150 +      return;
 227.151 +}
 227.152 +
 227.153 +static void end_of_line(struct csa *csa)
 227.154 +{     /* skip white-space characters until end of line */
 227.155 +      while (csa->c == ' ')
 227.156 +         read_char(csa);
 227.157 +      if (csa->c != '\n')
 227.158 +         error(csa, "too many data fields specified");
 227.159 +      return;
 227.160 +}
 227.161 +
 227.162 +static void check_int(struct csa *csa, double num)
 227.163 +{     /* print a warning if non-integer data are detected */
 227.164 +      if (!csa->nonint && num != floor(num))
 227.165 +      {  warning(csa, "non-integer data detected");
 227.166 +         csa->nonint = 1;
 227.167 +      }
 227.168 +      return;
 227.169 +}
 227.170 +
 227.171 +/***********************************************************************
 227.172 +*  NAME
 227.173 +*
 227.174 +*  glp_read_mincost - read min-cost flow problem data in DIMACS format
 227.175 +*
 227.176 +*  SYNOPSIS
 227.177 +*
 227.178 +*  int glp_read_mincost(glp_graph *G, int v_rhs, int a_low, int a_cap,
 227.179 +*     int a_cost, const char *fname);
 227.180 +*
 227.181 +*  DESCRIPTION
 227.182 +*
 227.183 +*  The routine glp_read_mincost reads minimum cost flow problem data in
 227.184 +*  DIMACS format from a text file.
 227.185 +*
 227.186 +*  RETURNS
 227.187 +*
 227.188 +*  If the operation was successful, the routine returns zero. Otherwise
 227.189 +*  it prints an error message and returns non-zero. */
 227.190 +
 227.191 +int glp_read_mincost(glp_graph *G, int v_rhs, int a_low, int a_cap,
 227.192 +      int a_cost, const char *fname)
 227.193 +{     struct csa _csa, *csa = &_csa;
 227.194 +      glp_vertex *v;
 227.195 +      glp_arc *a;
 227.196 +      int i, j, k, nv, na, ret = 0;
 227.197 +      double rhs, low, cap, cost;
 227.198 +      char *flag = NULL;
 227.199 +      if (v_rhs >= 0 && v_rhs > G->v_size - (int)sizeof(double))
 227.200 +         xerror("glp_read_mincost: v_rhs = %d; invalid offset\n",
 227.201 +            v_rhs);
 227.202 +      if (a_low >= 0 && a_low > G->a_size - (int)sizeof(double))
 227.203 +         xerror("glp_read_mincost: a_low = %d; invalid offset\n",
 227.204 +            a_low);
 227.205 +      if (a_cap >= 0 && a_cap > G->a_size - (int)sizeof(double))
 227.206 +         xerror("glp_read_mincost: a_cap = %d; invalid offset\n",
 227.207 +            a_cap);
 227.208 +      if (a_cost >= 0 && a_cost > G->a_size - (int)sizeof(double))
 227.209 +         xerror("glp_read_mincost: a_cost = %d; invalid offset\n",
 227.210 +            a_cost);
 227.211 +      glp_erase_graph(G, G->v_size, G->a_size);
 227.212 +      if (setjmp(csa->jump))
 227.213 +      {  ret = 1;
 227.214 +         goto done;
 227.215 +      }
 227.216 +      csa->fname = fname;
 227.217 +      csa->fp = NULL;
 227.218 +      csa->count = 0;
 227.219 +      csa->c = '\n';
 227.220 +      csa->field[0] = '\0';
 227.221 +      csa->empty = csa->nonint = 0;
 227.222 +      xprintf("Reading min-cost flow problem data from `%s'...\n",
 227.223 +         fname);
 227.224 +      csa->fp = xfopen(fname, "r");
 227.225 +      if (csa->fp == NULL)
 227.226 +      {  xprintf("Unable to open `%s' - %s\n", fname, xerrmsg());
 227.227 +         longjmp(csa->jump, 1);
 227.228 +      }
 227.229 +      /* read problem line */
 227.230 +      read_designator(csa);
 227.231 +      if (strcmp(csa->field, "p") != 0)
 227.232 +         error(csa, "problem line missing or invalid");
 227.233 +      read_field(csa);
 227.234 +      if (strcmp(csa->field, "min") != 0)
 227.235 +         error(csa, "wrong problem designator; `min' expected");
 227.236 +      read_field(csa);
 227.237 +      if (!(str2int(csa->field, &nv) == 0 && nv >= 0))
 227.238 +         error(csa, "number of nodes missing or invalid");
 227.239 +      read_field(csa);
 227.240 +      if (!(str2int(csa->field, &na) == 0 && na >= 0))
 227.241 +         error(csa, "number of arcs missing or invalid");
 227.242 +      xprintf("Flow network has %d node%s and %d arc%s\n",
 227.243 +         nv, nv == 1 ? "" : "s", na, na == 1 ? "" : "s");
 227.244 +      if (nv > 0) glp_add_vertices(G, nv);
 227.245 +      end_of_line(csa);
 227.246 +      /* read node descriptor lines */
 227.247 +      flag = xcalloc(1+nv, sizeof(char));
 227.248 +      memset(&flag[1], 0, nv * sizeof(char));
 227.249 +      if (v_rhs >= 0)
 227.250 +      {  rhs = 0.0;
 227.251 +         for (i = 1; i <= nv; i++)
 227.252 +         {  v = G->v[i];
 227.253 +            memcpy((char *)v->data + v_rhs, &rhs, sizeof(double));
 227.254 +         }
 227.255 +      }
 227.256 +      for (;;)
 227.257 +      {  read_designator(csa);
 227.258 +         if (strcmp(csa->field, "n") != 0) break;
 227.259 +         read_field(csa);
 227.260 +         if (str2int(csa->field, &i) != 0)
 227.261 +            error(csa, "node number missing or invalid");
 227.262 +         if (!(1 <= i && i <= nv))
 227.263 +            error(csa, "node number %d out of range", i);
 227.264 +         if (flag[i])
 227.265 +            error(csa, "duplicate descriptor of node %d", i);
 227.266 +         read_field(csa);
 227.267 +         if (str2num(csa->field, &rhs) != 0)
 227.268 +            error(csa, "node supply/demand missing or invalid");
 227.269 +         check_int(csa, rhs);
 227.270 +         if (v_rhs >= 0)
 227.271 +         {  v = G->v[i];
 227.272 +            memcpy((char *)v->data + v_rhs, &rhs, sizeof(double));
 227.273 +         }
 227.274 +         flag[i] = 1;
 227.275 +         end_of_line(csa);
 227.276 +      }
 227.277 +      xfree(flag), flag = NULL;
 227.278 +      /* read arc descriptor lines */
 227.279 +      for (k = 1; k <= na; k++)
 227.280 +      {  if (k > 1) read_designator(csa);
 227.281 +         if (strcmp(csa->field, "a") != 0)
 227.282 +            error(csa, "wrong line designator; `a' expected");
 227.283 +         read_field(csa);
 227.284 +         if (str2int(csa->field, &i) != 0)
 227.285 +            error(csa, "starting node number missing or invalid");
 227.286 +         if (!(1 <= i && i <= nv))
 227.287 +            error(csa, "starting node number %d out of range", i);
 227.288 +         read_field(csa);
 227.289 +         if (str2int(csa->field, &j) != 0)
 227.290 +            error(csa, "ending node number missing or invalid");
 227.291 +         if (!(1 <= j && j <= nv))
 227.292 +            error(csa, "ending node number %d out of range", j);
 227.293 +         read_field(csa);
 227.294 +         if (!(str2num(csa->field, &low) == 0 && low >= 0.0))
 227.295 +            error(csa, "lower bound of arc flow missing or invalid");
 227.296 +         check_int(csa, low);
 227.297 +         read_field(csa);
 227.298 +         if (!(str2num(csa->field, &cap) == 0 && cap >= low))
 227.299 +            error(csa, "upper bound of arc flow missing or invalid");
 227.300 +         check_int(csa, cap);
 227.301 +         read_field(csa);
 227.302 +         if (str2num(csa->field, &cost) != 0)
 227.303 +            error(csa, "per-unit cost of arc flow missing or invalid");
 227.304 +         check_int(csa, cost);
 227.305 +         a = glp_add_arc(G, i, j);
 227.306 +         if (a_low >= 0)
 227.307 +            memcpy((char *)a->data + a_low, &low, sizeof(double));
 227.308 +         if (a_cap >= 0)
 227.309 +            memcpy((char *)a->data + a_cap, &cap, sizeof(double));
 227.310 +         if (a_cost >= 0)
 227.311 +            memcpy((char *)a->data + a_cost, &cost, sizeof(double));
 227.312 +         end_of_line(csa);
 227.313 +      }
 227.314 +      xprintf("%d lines were read\n", csa->count);
 227.315 +done: if (ret) glp_erase_graph(G, G->v_size, G->a_size);
 227.316 +      if (csa->fp != NULL) xfclose(csa->fp);
 227.317 +      if (flag != NULL) xfree(flag);
 227.318 +      return ret;
 227.319 +}
 227.320 +
 227.321 +/***********************************************************************
 227.322 +*  NAME
 227.323 +*
 227.324 +*  glp_write_mincost - write min-cost flow problem data in DIMACS format
 227.325 +*
 227.326 +*  SYNOPSIS
 227.327 +*
 227.328 +*  int glp_write_mincost(glp_graph *G, int v_rhs, int a_low, int a_cap,
 227.329 +*     int a_cost, const char *fname);
 227.330 +*
 227.331 +*  DESCRIPTION
 227.332 +*
 227.333 +*  The routine glp_write_mincost writes minimum cost flow problem data
 227.334 +*  in DIMACS format to a text file.
 227.335 +*
 227.336 +*  RETURNS
 227.337 +*
 227.338 +*  If the operation was successful, the routine returns zero. Otherwise
 227.339 +*  it prints an error message and returns non-zero. */
 227.340 +
 227.341 +int glp_write_mincost(glp_graph *G, int v_rhs, int a_low, int a_cap,
 227.342 +      int a_cost, const char *fname)
 227.343 +{     XFILE *fp;
 227.344 +      glp_vertex *v;
 227.345 +      glp_arc *a;
 227.346 +      int i, count = 0, ret;
 227.347 +      double rhs, low, cap, cost;
 227.348 +      if (v_rhs >= 0 && v_rhs > G->v_size - (int)sizeof(double))
 227.349 +         xerror("glp_write_mincost: v_rhs = %d; invalid offset\n",
 227.350 +            v_rhs);
 227.351 +      if (a_low >= 0 && a_low > G->a_size - (int)sizeof(double))
 227.352 +         xerror("glp_write_mincost: a_low = %d; invalid offset\n",
 227.353 +            a_low);
 227.354 +      if (a_cap >= 0 && a_cap > G->a_size - (int)sizeof(double))
 227.355 +         xerror("glp_write_mincost: a_cap = %d; invalid offset\n",
 227.356 +            a_cap);
 227.357 +      if (a_cost >= 0 && a_cost > G->a_size - (int)sizeof(double))
 227.358 +         xerror("glp_write_mincost: a_cost = %d; invalid offset\n",
 227.359 +            a_cost);
 227.360 +      xprintf("Writing min-cost flow problem data to `%s'...\n",
 227.361 +         fname);
 227.362 +      fp = xfopen(fname, "w");
 227.363 +      if (fp == NULL)
 227.364 +      {  xprintf("Unable to create `%s' - %s\n", fname, xerrmsg());
 227.365 +         ret = 1;
 227.366 +         goto done;
 227.367 +      }
 227.368 +      xfprintf(fp, "c %s\n",
 227.369 +         G->name == NULL ? "unknown" : G->name), count++;
 227.370 +      xfprintf(fp, "p min %d %d\n", G->nv, G->na), count++;
 227.371 +      if (v_rhs >= 0)
 227.372 +      {  for (i = 1; i <= G->nv; i++)
 227.373 +         {  v = G->v[i];
 227.374 +            memcpy(&rhs, (char *)v->data + v_rhs, sizeof(double));
 227.375 +            if (rhs != 0.0)
 227.376 +               xfprintf(fp, "n %d %.*g\n", i, DBL_DIG, rhs), count++;
 227.377 +         }
 227.378 +      }
 227.379 +      for (i = 1; i <= G->nv; i++)
 227.380 +      {  v = G->v[i];
 227.381 +         for (a = v->out; a != NULL; a = a->t_next)
 227.382 +         {  if (a_low >= 0)
 227.383 +               memcpy(&low, (char *)a->data + a_low, sizeof(double));
 227.384 +            else
 227.385 +               low = 0.0;
 227.386 +            if (a_cap >= 0)
 227.387 +               memcpy(&cap, (char *)a->data + a_cap, sizeof(double));
 227.388 +            else
 227.389 +               cap = 1.0;
 227.390 +            if (a_cost >= 0)
 227.391 +               memcpy(&cost, (char *)a->data + a_cost, sizeof(double));
 227.392 +            else
 227.393 +               cost = 0.0;
 227.394 +            xfprintf(fp, "a %d %d %.*g %.*g %.*g\n",
 227.395 +               a->tail->i, a->head->i, DBL_DIG, low, DBL_DIG, cap,
 227.396 +               DBL_DIG, cost), count++;
 227.397 +         }
 227.398 +      }
 227.399 +      xfprintf(fp, "c eof\n"), count++;
 227.400 +      xfflush(fp);
 227.401 +      if (xferror(fp))
 227.402 +      {  xprintf("Write error on `%s' - %s\n", fname, xerrmsg());
 227.403 +         ret = 1;
 227.404 +         goto done;
 227.405 +      }
 227.406 +      xprintf("%d lines were written\n", count);
 227.407 +      ret = 0;
 227.408 +done: if (fp != NULL) xfclose(fp);
 227.409 +      return ret;
 227.410 +}
 227.411 +
 227.412 +/***********************************************************************
 227.413 +*  NAME
 227.414 +*
 227.415 +*  glp_read_maxflow - read maximum flow problem data in DIMACS format
 227.416 +*
 227.417 +*  SYNOPSIS
 227.418 +*
 227.419 +*  int glp_read_maxflow(glp_graph *G, int *s, int *t, int a_cap,
 227.420 +*     const char *fname);
 227.421 +*
 227.422 +*  DESCRIPTION
 227.423 +*
 227.424 +*  The routine glp_read_maxflow reads maximum flow problem data in
 227.425 +*  DIMACS format from a text file.
 227.426 +*
 227.427 +*  RETURNS
 227.428 +*
 227.429 +*  If the operation was successful, the routine returns zero. Otherwise
 227.430 +*  it prints an error message and returns non-zero. */
 227.431 +
 227.432 +int glp_read_maxflow(glp_graph *G, int *_s, int *_t, int a_cap,
 227.433 +      const char *fname)
 227.434 +{     struct csa _csa, *csa = &_csa;
 227.435 +      glp_arc *a;
 227.436 +      int i, j, k, s, t, nv, na, ret = 0;
 227.437 +      double cap;
 227.438 +      if (a_cap >= 0 && a_cap > G->a_size - (int)sizeof(double))
 227.439 +         xerror("glp_read_maxflow: a_cap = %d; invalid offset\n",
 227.440 +            a_cap);
 227.441 +      glp_erase_graph(G, G->v_size, G->a_size);
 227.442 +      if (setjmp(csa->jump))
 227.443 +      {  ret = 1;
 227.444 +         goto done;
 227.445 +      }
 227.446 +      csa->fname = fname;
 227.447 +      csa->fp = NULL;
 227.448 +      csa->count = 0;
 227.449 +      csa->c = '\n';
 227.450 +      csa->field[0] = '\0';
 227.451 +      csa->empty = csa->nonint = 0;
 227.452 +      xprintf("Reading maximum flow problem data from `%s'...\n",
 227.453 +         fname);
 227.454 +      csa->fp = xfopen(fname, "r");
 227.455 +      if (csa->fp == NULL)
 227.456 +      {  xprintf("Unable to open `%s' - %s\n", fname, xerrmsg());
 227.457 +         longjmp(csa->jump, 1);
 227.458 +      }
 227.459 +      /* read problem line */
 227.460 +      read_designator(csa);
 227.461 +      if (strcmp(csa->field, "p") != 0)
 227.462 +         error(csa, "problem line missing or invalid");
 227.463 +      read_field(csa);
 227.464 +      if (strcmp(csa->field, "max") != 0)
 227.465 +         error(csa, "wrong problem designator; `max' expected");
 227.466 +      read_field(csa);
 227.467 +      if (!(str2int(csa->field, &nv) == 0 && nv >= 2))
 227.468 +         error(csa, "number of nodes missing or invalid");
 227.469 +      read_field(csa);
 227.470 +      if (!(str2int(csa->field, &na) == 0 && na >= 0))
 227.471 +         error(csa, "number of arcs missing or invalid");
 227.472 +      xprintf("Flow network has %d node%s and %d arc%s\n",
 227.473 +         nv, nv == 1 ? "" : "s", na, na == 1 ? "" : "s");
 227.474 +      if (nv > 0) glp_add_vertices(G, nv);
 227.475 +      end_of_line(csa);
 227.476 +      /* read node descriptor lines */
 227.477 +      s = t = 0;
 227.478 +      for (;;)
 227.479 +      {  read_designator(csa);
 227.480 +         if (strcmp(csa->field, "n") != 0) break;
 227.481 +         read_field(csa);
 227.482 +         if (str2int(csa->field, &i) != 0)
 227.483 +            error(csa, "node number missing or invalid");
 227.484 +         if (!(1 <= i && i <= nv))
 227.485 +            error(csa, "node number %d out of range", i);
 227.486 +         read_field(csa);
 227.487 +         if (strcmp(csa->field, "s") == 0)
 227.488 +         {  if (s > 0)
 227.489 +               error(csa, "only one source node allowed");
 227.490 +            s = i;
 227.491 +         }
 227.492 +         else if (strcmp(csa->field, "t") == 0)
 227.493 +         {  if (t > 0)
 227.494 +               error(csa, "only one sink node allowed");
 227.495 +            t = i;
 227.496 +         }
 227.497 +         else
 227.498 +            error(csa, "wrong node designator; `s' or `t' expected");
 227.499 +         if (s > 0 && s == t)
 227.500 +            error(csa, "source and sink nodes must be distinct");
 227.501 +         end_of_line(csa);
 227.502 +      }
 227.503 +      if (s == 0)
 227.504 +         error(csa, "source node descriptor missing\n");
 227.505 +      if (t == 0)
 227.506 +         error(csa, "sink node descriptor missing\n");
 227.507 +      if (_s != NULL) *_s = s;
 227.508 +      if (_t != NULL) *_t = t;
 227.509 +      /* read arc descriptor lines */
 227.510 +      for (k = 1; k <= na; k++)
 227.511 +      {  if (k > 1) read_designator(csa);
 227.512 +         if (strcmp(csa->field, "a") != 0)
 227.513 +            error(csa, "wrong line designator; `a' expected");
 227.514 +         read_field(csa);
 227.515 +         if (str2int(csa->field, &i) != 0)
 227.516 +            error(csa, "starting node number missing or invalid");
 227.517 +         if (!(1 <= i && i <= nv))
 227.518 +            error(csa, "starting node number %d out of range", i);
 227.519 +         read_field(csa);
 227.520 +         if (str2int(csa->field, &j) != 0)
 227.521 +            error(csa, "ending node number missing or invalid");
 227.522 +         if (!(1 <= j && j <= nv))
 227.523 +            error(csa, "ending node number %d out of range", j);
 227.524 +         read_field(csa);
 227.525 +         if (!(str2num(csa->field, &cap) == 0 && cap >= 0.0))
 227.526 +            error(csa, "arc capacity missing or invalid");
 227.527 +         check_int(csa, cap);
 227.528 +         a = glp_add_arc(G, i, j);
 227.529 +         if (a_cap >= 0)
 227.530 +            memcpy((char *)a->data + a_cap, &cap, sizeof(double));
 227.531 +         end_of_line(csa);
 227.532 +      }
 227.533 +      xprintf("%d lines were read\n", csa->count);
 227.534 +done: if (ret) glp_erase_graph(G, G->v_size, G->a_size);
 227.535 +      if (csa->fp != NULL) xfclose(csa->fp);
 227.536 +      return ret;
 227.537 +}
 227.538 +
 227.539 +/***********************************************************************
 227.540 +*  NAME
 227.541 +*
 227.542 +*  glp_write_maxflow - write maximum flow problem data in DIMACS format
 227.543 +*
 227.544 +*  SYNOPSIS
 227.545 +*
 227.546 +*  int glp_write_maxflow(glp_graph *G, int s, int t, int a_cap,
 227.547 +*     const char *fname);
 227.548 +*
 227.549 +*  DESCRIPTION
 227.550 +*
 227.551 +*  The routine glp_write_maxflow writes maximum flow problem data in
 227.552 +*  DIMACS format to a text file.
 227.553 +*
 227.554 +*  RETURNS
 227.555 +*
 227.556 +*  If the operation was successful, the routine returns zero. Otherwise
 227.557 +*  it prints an error message and returns non-zero. */
 227.558 +
 227.559 +int glp_write_maxflow(glp_graph *G, int s, int t, int a_cap,
 227.560 +      const char *fname)
 227.561 +{     XFILE *fp;
 227.562 +      glp_vertex *v;
 227.563 +      glp_arc *a;
 227.564 +      int i, count = 0, ret;
 227.565 +      double cap;
 227.566 +      if (!(1 <= s && s <= G->nv))
 227.567 +         xerror("glp_write_maxflow: s = %d; source node number out of r"
 227.568 +            "ange\n", s);
 227.569 +      if (!(1 <= t && t <= G->nv))
 227.570 +         xerror("glp_write_maxflow: t = %d: sink node number out of ran"
 227.571 +            "ge\n", t);
 227.572 +      if (a_cap >= 0 && a_cap > G->a_size - (int)sizeof(double))
 227.573 +         xerror("glp_write_mincost: a_cap = %d; invalid offset\n",
 227.574 +            a_cap);
 227.575 +      xprintf("Writing maximum flow problem data to `%s'...\n",
 227.576 +         fname);
 227.577 +      fp = xfopen(fname, "w");
 227.578 +      if (fp == NULL)
 227.579 +      {  xprintf("Unable to create `%s' - %s\n", fname, xerrmsg());
 227.580 +         ret = 1;
 227.581 +         goto done;
 227.582 +      }
 227.583 +      xfprintf(fp, "c %s\n",
 227.584 +         G->name == NULL ? "unknown" : G->name), count++;
 227.585 +      xfprintf(fp, "p max %d %d\n", G->nv, G->na), count++;
 227.586 +      xfprintf(fp, "n %d s\n", s), count++;
 227.587 +      xfprintf(fp, "n %d t\n", t), count++;
 227.588 +      for (i = 1; i <= G->nv; i++)
 227.589 +      {  v = G->v[i];
 227.590 +         for (a = v->out; a != NULL; a = a->t_next)
 227.591 +         {  if (a_cap >= 0)
 227.592 +               memcpy(&cap, (char *)a->data + a_cap, sizeof(double));
 227.593 +            else
 227.594 +               cap = 1.0;
 227.595 +            xfprintf(fp, "a %d %d %.*g\n",
 227.596 +               a->tail->i, a->head->i, DBL_DIG, cap), count++;
 227.597 +         }
 227.598 +      }
 227.599 +      xfprintf(fp, "c eof\n"), count++;
 227.600 +      xfflush(fp);
 227.601 +      if (xferror(fp))
 227.602 +      {  xprintf("Write error on `%s' - %s\n", fname, xerrmsg());
 227.603 +         ret = 1;
 227.604 +         goto done;
 227.605 +      }
 227.606 +      xprintf("%d lines were written\n", count);
 227.607 +      ret = 0;
 227.608 +done: if (fp != NULL) xfclose(fp);
 227.609 +      return ret;
 227.610 +}
 227.611 +
 227.612 +/***********************************************************************
 227.613 +*  NAME
 227.614 +*
 227.615 +*  glp_read_asnprob - read assignment problem data in DIMACS format
 227.616 +*
 227.617 +*  SYNOPSIS
 227.618 +*
 227.619 +*  int glp_read_asnprob(glp_graph *G, int v_set, int a_cost,
 227.620 +*     const char *fname);
 227.621 +*
 227.622 +*  DESCRIPTION
 227.623 +*
 227.624 +*  The routine glp_read_asnprob reads assignment problem data in DIMACS
 227.625 +*  format from a text file.
 227.626 +*
 227.627 +*  RETURNS
 227.628 +*
 227.629 +*  If the operation was successful, the routine returns zero. Otherwise
 227.630 +*  it prints an error message and returns non-zero. */
 227.631 +
 227.632 +int glp_read_asnprob(glp_graph *G, int v_set, int a_cost, const char
 227.633 +      *fname)
 227.634 +{     struct csa _csa, *csa = &_csa;
 227.635 +      glp_vertex *v;
 227.636 +      glp_arc *a;
 227.637 +      int nv, na, n1, i, j, k, ret = 0;
 227.638 +      double cost;
 227.639 +      char *flag = NULL;
 227.640 +      if (v_set >= 0 && v_set > G->v_size - (int)sizeof(int))
 227.641 +         xerror("glp_read_asnprob: v_set = %d; invalid offset\n",
 227.642 +            v_set);
 227.643 +      if (a_cost >= 0 && a_cost > G->a_size - (int)sizeof(double))
 227.644 +         xerror("glp_read_asnprob: a_cost = %d; invalid offset\n",
 227.645 +            a_cost);
 227.646 +      glp_erase_graph(G, G->v_size, G->a_size);
 227.647 +      if (setjmp(csa->jump))
 227.648 +      {  ret = 1;
 227.649 +         goto done;
 227.650 +      }
 227.651 +      csa->fname = fname;
 227.652 +      csa->fp = NULL;
 227.653 +      csa->count = 0;
 227.654 +      csa->c = '\n';
 227.655 +      csa->field[0] = '\0';
 227.656 +      csa->empty = csa->nonint = 0;
 227.657 +      xprintf("Reading assignment problem data from `%s'...\n", fname);
 227.658 +      csa->fp = xfopen(fname, "r");
 227.659 +      if (csa->fp == NULL)
 227.660 +      {  xprintf("Unable to open `%s' - %s\n", fname, xerrmsg());
 227.661 +         longjmp(csa->jump, 1);
 227.662 +      }
 227.663 +      /* read problem line */
 227.664 +      read_designator(csa);
 227.665 +      if (strcmp(csa->field, "p") != 0)
 227.666 +         error(csa, "problem line missing or invalid");
 227.667 +      read_field(csa);
 227.668 +      if (strcmp(csa->field, "asn") != 0)
 227.669 +         error(csa, "wrong problem designator; `asn' expected");
 227.670 +      read_field(csa);
 227.671 +      if (!(str2int(csa->field, &nv) == 0 && nv >= 0))
 227.672 +         error(csa, "number of nodes missing or invalid");
 227.673 +      read_field(csa);
 227.674 +      if (!(str2int(csa->field, &na) == 0 && na >= 0))
 227.675 +         error(csa, "number of arcs missing or invalid");
 227.676 +      if (nv > 0) glp_add_vertices(G, nv);
 227.677 +      end_of_line(csa);
 227.678 +      /* read node descriptor lines */
 227.679 +      flag = xcalloc(1+nv, sizeof(char));
 227.680 +      memset(&flag[1], 0, nv * sizeof(char));
 227.681 +      n1 = 0;
 227.682 +      for (;;)
 227.683 +      {  read_designator(csa);
 227.684 +         if (strcmp(csa->field, "n") != 0) break;
 227.685 +         read_field(csa);
 227.686 +         if (str2int(csa->field, &i) != 0)
 227.687 +            error(csa, "node number missing or invalid");
 227.688 +         if (!(1 <= i && i <= nv))
 227.689 +            error(csa, "node number %d out of range", i);
 227.690 +         if (flag[i])
 227.691 +            error(csa, "duplicate descriptor of node %d", i);
 227.692 +         flag[i] = 1, n1++;
 227.693 +         end_of_line(csa);
 227.694 +      }
 227.695 +      xprintf(
 227.696 +         "Assignment problem has %d + %d = %d node%s and %d arc%s\n",
 227.697 +         n1, nv - n1, nv, nv == 1 ? "" : "s", na, na == 1 ? "" : "s");
 227.698 +      if (v_set >= 0)
 227.699 +      {  for (i = 1; i <= nv; i++)
 227.700 +         {  v = G->v[i];
 227.701 +            k = (flag[i] ? 0 : 1);
 227.702 +            memcpy((char *)v->data + v_set, &k, sizeof(int));
 227.703 +         }
 227.704 +      }
 227.705 +      /* read arc descriptor lines */
 227.706 +      for (k = 1; k <= na; k++)
 227.707 +      {  if (k > 1) read_designator(csa);
 227.708 +         if (strcmp(csa->field, "a") != 0)
 227.709 +            error(csa, "wrong line designator; `a' expected");
 227.710 +         read_field(csa);
 227.711 +         if (str2int(csa->field, &i) != 0)
 227.712 +            error(csa, "starting node number missing or invalid");
 227.713 +         if (!(1 <= i && i <= nv))
 227.714 +            error(csa, "starting node number %d out of range", i);
 227.715 +         if (!flag[i])
 227.716 +            error(csa, "node %d cannot be a starting node", i);
 227.717 +         read_field(csa);
 227.718 +         if (str2int(csa->field, &j) != 0)
 227.719 +            error(csa, "ending node number missing or invalid");
 227.720 +         if (!(1 <= j && j <= nv))
 227.721 +            error(csa, "ending node number %d out of range", j);
 227.722 +         if (flag[j])
 227.723 +            error(csa, "node %d cannot be an ending node", j);
 227.724 +         read_field(csa);
 227.725 +         if (str2num(csa->field, &cost) != 0)
 227.726 +            error(csa, "arc cost missing or invalid");
 227.727 +         check_int(csa, cost);
 227.728 +         a = glp_add_arc(G, i, j);
 227.729 +         if (a_cost >= 0)
 227.730 +            memcpy((char *)a->data + a_cost, &cost, sizeof(double));
 227.731 +         end_of_line(csa);
 227.732 +      }
 227.733 +      xprintf("%d lines were read\n", csa->count);
 227.734 +done: if (ret) glp_erase_graph(G, G->v_size, G->a_size);
 227.735 +      if (csa->fp != NULL) xfclose(csa->fp);
 227.736 +      if (flag != NULL) xfree(flag);
 227.737 +      return ret;
 227.738 +}
 227.739 +
 227.740 +/***********************************************************************
 227.741 +*  NAME
 227.742 +*
 227.743 +*  glp_write_asnprob - write assignment problem data in DIMACS format
 227.744 +*
 227.745 +*  SYNOPSIS
 227.746 +*
 227.747 +*  int glp_write_asnprob(glp_graph *G, int v_set, int a_cost,
 227.748 +*     const char *fname);
 227.749 +*
 227.750 +*  DESCRIPTION
 227.751 +*
 227.752 +*  The routine glp_write_asnprob writes assignment problem data in
 227.753 +*  DIMACS format to a text file.
 227.754 +*
 227.755 +*  RETURNS
 227.756 +*
 227.757 +*  If the operation was successful, the routine returns zero. Otherwise
 227.758 +*  it prints an error message and returns non-zero. */
 227.759 +
 227.760 +int glp_write_asnprob(glp_graph *G, int v_set, int a_cost, const char
 227.761 +      *fname)
 227.762 +{     XFILE *fp;
 227.763 +      glp_vertex *v;
 227.764 +      glp_arc *a;
 227.765 +      int i, k, count = 0, ret;
 227.766 +      double cost;
 227.767 +      if (v_set >= 0 && v_set > G->v_size - (int)sizeof(int))
 227.768 +         xerror("glp_write_asnprob: v_set = %d; invalid offset\n",
 227.769 +            v_set);
 227.770 +      if (a_cost >= 0 && a_cost > G->a_size - (int)sizeof(double))
 227.771 +         xerror("glp_write_asnprob: a_cost = %d; invalid offset\n",
 227.772 +            a_cost);
 227.773 +      xprintf("Writing assignment problem data to `%s'...\n", fname);
 227.774 +      fp = xfopen(fname, "w");
 227.775 +      if (fp == NULL)
 227.776 +      {  xprintf("Unable to create `%s' - %s\n", fname, xerrmsg());
 227.777 +         ret = 1;
 227.778 +         goto done;
 227.779 +      }
 227.780 +      xfprintf(fp, "c %s\n",
 227.781 +         G->name == NULL ? "unknown" : G->name), count++;
 227.782 +      xfprintf(fp, "p asn %d %d\n", G->nv, G->na), count++;
 227.783 +      for (i = 1; i <= G->nv; i++)
 227.784 +      {  v = G->v[i];
 227.785 +         if (v_set >= 0)
 227.786 +            memcpy(&k, (char *)v->data + v_set, sizeof(int));
 227.787 +         else
 227.788 +            k = (v->out != NULL ? 0 : 1);
 227.789 +         if (k == 0)
 227.790 +            xfprintf(fp, "n %d\n", i), count++;
 227.791 +      }
 227.792 +      for (i = 1; i <= G->nv; i++)
 227.793 +      {  v = G->v[i];
 227.794 +         for (a = v->out; a != NULL; a = a->t_next)
 227.795 +         {  if (a_cost >= 0)
 227.796 +               memcpy(&cost, (char *)a->data + a_cost, sizeof(double));
 227.797 +            else
 227.798 +               cost = 1.0;
 227.799 +            xfprintf(fp, "a %d %d %.*g\n",
 227.800 +               a->tail->i, a->head->i, DBL_DIG, cost), count++;
 227.801 +         }
 227.802 +      }
 227.803 +      xfprintf(fp, "c eof\n"), count++;
 227.804 +      xfflush(fp);
 227.805 +      if (xferror(fp))
 227.806 +      {  xprintf("Write error on `%s' - %s\n", fname, xerrmsg());
 227.807 +         ret = 1;
 227.808 +         goto done;
 227.809 +      }
 227.810 +      xprintf("%d lines were written\n", count);
 227.811 +      ret = 0;
 227.812 +done: if (fp != NULL) xfclose(fp);
 227.813 +      return ret;
 227.814 +}
 227.815 +
 227.816 +/***********************************************************************
 227.817 +*  NAME
 227.818 +*
 227.819 +*  glp_read_ccdata - read graph in DIMACS clique/coloring format
 227.820 +*
 227.821 +*  SYNOPSIS
 227.822 +*
 227.823 +*  int glp_read_ccdata(glp_graph *G, int v_wgt, const char *fname);
 227.824 +*
 227.825 +*  DESCRIPTION
 227.826 +*
 227.827 +*  The routine glp_read_ccdata reads an (undirected) graph in DIMACS
 227.828 +*  clique/coloring format from a text file.
 227.829 +*
 227.830 +*  RETURNS
 227.831 +*
 227.832 +*  If the operation was successful, the routine returns zero. Otherwise
 227.833 +*  it prints an error message and returns non-zero. */
 227.834 +
 227.835 +int glp_read_ccdata(glp_graph *G, int v_wgt, const char *fname)
 227.836 +{     struct csa _csa, *csa = &_csa;
 227.837 +      glp_vertex *v;
 227.838 +      int i, j, k, nv, ne, ret = 0;
 227.839 +      double w;
 227.840 +      char *flag = NULL;
 227.841 +      if (v_wgt >= 0 && v_wgt > G->v_size - (int)sizeof(double))
 227.842 +         xerror("glp_read_ccdata: v_wgt = %d; invalid offset\n",
 227.843 +            v_wgt);
 227.844 +      glp_erase_graph(G, G->v_size, G->a_size);
 227.845 +      if (setjmp(csa->jump))
 227.846 +      {  ret = 1;
 227.847 +         goto done;
 227.848 +      }
 227.849 +      csa->fname = fname;
 227.850 +      csa->fp = NULL;
 227.851 +      csa->count = 0;
 227.852 +      csa->c = '\n';
 227.853 +      csa->field[0] = '\0';
 227.854 +      csa->empty = csa->nonint = 0;
 227.855 +      xprintf("Reading graph from `%s'...\n", fname);
 227.856 +      csa->fp = xfopen(fname, "r");
 227.857 +      if (csa->fp == NULL)
 227.858 +      {  xprintf("Unable to open `%s' - %s\n", fname, xerrmsg());
 227.859 +         longjmp(csa->jump, 1);
 227.860 +      }
 227.861 +      /* read problem line */
 227.862 +      read_designator(csa);
 227.863 +      if (strcmp(csa->field, "p") != 0)
 227.864 +         error(csa, "problem line missing or invalid");
 227.865 +      read_field(csa);
 227.866 +      if (strcmp(csa->field, "edge") != 0)
 227.867 +         error(csa, "wrong problem designator; `edge' expected");
 227.868 +      read_field(csa);
 227.869 +      if (!(str2int(csa->field, &nv) == 0 && nv >= 0))
 227.870 +         error(csa, "number of vertices missing or invalid");
 227.871 +      read_field(csa);
 227.872 +      if (!(str2int(csa->field, &ne) == 0 && ne >= 0))
 227.873 +         error(csa, "number of edges missing or invalid");
 227.874 +      xprintf("Graph has %d vert%s and %d edge%s\n",
 227.875 +         nv, nv == 1 ? "ex" : "ices", ne, ne == 1 ? "" : "s");
 227.876 +      if (nv > 0) glp_add_vertices(G, nv);
 227.877 +      end_of_line(csa);
 227.878 +      /* read node descriptor lines */
 227.879 +      flag = xcalloc(1+nv, sizeof(char));
 227.880 +      memset(&flag[1], 0, nv * sizeof(char));
 227.881 +      if (v_wgt >= 0)
 227.882 +      {  w = 1.0;
 227.883 +         for (i = 1; i <= nv; i++)
 227.884 +         {  v = G->v[i];
 227.885 +            memcpy((char *)v->data + v_wgt, &w, sizeof(double));
 227.886 +         }
 227.887 +      }
 227.888 +      for (;;)
 227.889 +      {  read_designator(csa);
 227.890 +         if (strcmp(csa->field, "n") != 0) break;
 227.891 +         read_field(csa);
 227.892 +         if (str2int(csa->field, &i) != 0)
 227.893 +            error(csa, "vertex number missing or invalid");
 227.894 +         if (!(1 <= i && i <= nv))
 227.895 +            error(csa, "vertex number %d out of range", i);
 227.896 +         if (flag[i])
 227.897 +            error(csa, "duplicate descriptor of vertex %d", i);
 227.898 +         read_field(csa);
 227.899 +         if (str2num(csa->field, &w) != 0)
 227.900 +            error(csa, "vertex weight missing or invalid");
 227.901 +         check_int(csa, w);
 227.902 +         if (v_wgt >= 0)
 227.903 +         {  v = G->v[i];
 227.904 +            memcpy((char *)v->data + v_wgt, &w, sizeof(double));
 227.905 +         }
 227.906 +         flag[i] = 1;
 227.907 +         end_of_line(csa);
 227.908 +      }
 227.909 +      xfree(flag), flag = NULL;
 227.910 +      /* read edge descriptor lines */
 227.911 +      for (k = 1; k <= ne; k++)
 227.912 +      {  if (k > 1) read_designator(csa);
 227.913 +         if (strcmp(csa->field, "e") != 0)
 227.914 +            error(csa, "wrong line designator; `e' expected");
 227.915 +         read_field(csa);
 227.916 +         if (str2int(csa->field, &i) != 0)
 227.917 +            error(csa, "first vertex number missing or invalid");
 227.918 +         if (!(1 <= i && i <= nv))
 227.919 +            error(csa, "first vertex number %d out of range", i);
 227.920 +         read_field(csa);
 227.921 +         if (str2int(csa->field, &j) != 0)
 227.922 +            error(csa, "second vertex number missing or invalid");
 227.923 +         if (!(1 <= j && j <= nv))
 227.924 +            error(csa, "second vertex number %d out of range", j);
 227.925 +         glp_add_arc(G, i, j);
 227.926 +         end_of_line(csa);
 227.927 +      }
 227.928 +      xprintf("%d lines were read\n", csa->count);
 227.929 +done: if (ret) glp_erase_graph(G, G->v_size, G->a_size);
 227.930 +      if (csa->fp != NULL) xfclose(csa->fp);
 227.931 +      if (flag != NULL) xfree(flag);
 227.932 +      return ret;
 227.933 +}
 227.934 +
 227.935 +/***********************************************************************
 227.936 +*  NAME
 227.937 +*
 227.938 +*  glp_write_ccdata - write graph in DIMACS clique/coloring format
 227.939 +*
 227.940 +*  SYNOPSIS
 227.941 +*
 227.942 +*  int glp_write_ccdata(glp_graph *G, int v_wgt, const char *fname);
 227.943 +*
 227.944 +*  DESCRIPTION
 227.945 +*
 227.946 +*  The routine glp_write_ccdata writes the specified graph in DIMACS
 227.947 +*  clique/coloring format to a text file.
 227.948 +*
 227.949 +*  RETURNS
 227.950 +*
 227.951 +*  If the operation was successful, the routine returns zero. Otherwise
 227.952 +*  it prints an error message and returns non-zero. */
 227.953 +
 227.954 +int glp_write_ccdata(glp_graph *G, int v_wgt, const char *fname)
 227.955 +{     XFILE *fp;
 227.956 +      glp_vertex *v;
 227.957 +      glp_arc *e;
 227.958 +      int i, count = 0, ret;
 227.959 +      double w;
 227.960 +      if (v_wgt >= 0 && v_wgt > G->v_size - (int)sizeof(double))
 227.961 +         xerror("glp_write_ccdata: v_wgt = %d; invalid offset\n",
 227.962 +            v_wgt);
 227.963 +      xprintf("Writing graph to `%s'\n", fname);
 227.964 +      fp = xfopen(fname, "w");
 227.965 +      if (fp == NULL)
 227.966 +      {  xprintf("Unable to create `%s' - %s\n", fname, xerrmsg());
 227.967 +         ret = 1;
 227.968 +         goto done;
 227.969 +      }
 227.970 +      xfprintf(fp, "c %s\n",
 227.971 +         G->name == NULL ? "unknown" : G->name), count++;
 227.972 +      xfprintf(fp, "p edge %d %d\n", G->nv, G->na), count++;
 227.973 +      if (v_wgt >= 0)
 227.974 +      {  for (i = 1; i <= G->nv; i++)
 227.975 +         {  v = G->v[i];
 227.976 +            memcpy(&w, (char *)v->data + v_wgt, sizeof(double));
 227.977 +            if (w != 1.0)
 227.978 +               xfprintf(fp, "n %d %.*g\n", i, DBL_DIG, w), count++;
 227.979 +         }
 227.980 +      }
 227.981 +      for (i = 1; i <= G->nv; i++)
 227.982 +      {  v = G->v[i];
 227.983 +         for (e = v->out; e != NULL; e = e->t_next)
 227.984 +            xfprintf(fp, "e %d %d\n", e->tail->i, e->head->i), count++;
 227.985 +      }
 227.986 +      xfprintf(fp, "c eof\n"), count++;
 227.987 +      xfflush(fp);
 227.988 +      if (xferror(fp))
 227.989 +      {  xprintf("Write error on `%s' - %s\n", fname, xerrmsg());
 227.990 +         ret = 1;
 227.991 +         goto done;
 227.992 +      }
 227.993 +      xprintf("%d lines were written\n", count);
 227.994 +      ret = 0;
 227.995 +done: if (fp != NULL) xfclose(fp);
 227.996 +      return ret;
 227.997 +}
 227.998 +
 227.999 +/***********************************************************************
227.1000 +*  NAME
227.1001 +*
227.1002 +*  glp_read_prob - read problem data in GLPK format
227.1003 +*
227.1004 +*  SYNOPSIS
227.1005 +*
227.1006 +*  int glp_read_prob(glp_prob *P, int flags, const char *fname);
227.1007 +*
227.1008 +*  The routine glp_read_prob reads problem data in GLPK LP/MIP format
227.1009 +*  from a text file.
227.1010 +*
227.1011 +*  RETURNS
227.1012 +*
227.1013 +*  If the operation was successful, the routine returns zero. Otherwise
227.1014 +*  it prints an error message and returns non-zero. */
227.1015 +
227.1016 +int glp_read_prob(glp_prob *P, int flags, const char *fname)
227.1017 +{     struct csa _csa, *csa = &_csa;
227.1018 +      int mip, m, n, nnz, ne, i, j, k, type, kind, ret, *ln = NULL,
227.1019 +         *ia = NULL, *ja = NULL;
227.1020 +      double lb, ub, temp, *ar = NULL;
227.1021 +      char *rf = NULL, *cf = NULL;
227.1022 +      if (P == NULL || P->magic != GLP_PROB_MAGIC)
227.1023 +         xerror("glp_read_prob: P = %p; invalid problem object\n",
227.1024 +            P);
227.1025 +      if (flags != 0)
227.1026 +         xerror("glp_read_prob: flags = %d; invalid parameter\n",
227.1027 +            flags);
227.1028 +      if (fname == NULL)
227.1029 +         xerror("glp_read_prob: fname = %d; invalid parameter\n",
227.1030 +            fname);
227.1031 +      glp_erase_prob(P);
227.1032 +      if (setjmp(csa->jump))
227.1033 +      {  ret = 1;
227.1034 +         goto done;
227.1035 +      }
227.1036 +      csa->fname = fname;
227.1037 +      csa->fp = NULL;
227.1038 +      csa->count = 0;
227.1039 +      csa->c = '\n';
227.1040 +      csa->field[0] = '\0';
227.1041 +      csa->empty = csa->nonint = 0;
227.1042 +      xprintf("Reading problem data from `%s'...\n", fname);
227.1043 +      csa->fp = xfopen(fname, "r");
227.1044 +      if (csa->fp == NULL)
227.1045 +      {  xprintf("Unable to open `%s' - %s\n", fname, xerrmsg());
227.1046 +         longjmp(csa->jump, 1);
227.1047 +      }
227.1048 +      /* read problem line */
227.1049 +      read_designator(csa);
227.1050 +      if (strcmp(csa->field, "p") != 0)
227.1051 +         error(csa, "problem line missing or invalid");
227.1052 +      read_field(csa);
227.1053 +      if (strcmp(csa->field, "lp") == 0)
227.1054 +         mip = 0;
227.1055 +      else if (strcmp(csa->field, "mip") == 0)
227.1056 +         mip = 1;
227.1057 +      else
227.1058 +         error(csa, "wrong problem designator; `lp' or `mip' expected\n"
227.1059 +            );
227.1060 +      read_field(csa);
227.1061 +      if (strcmp(csa->field, "min") == 0)
227.1062 +         glp_set_obj_dir(P, GLP_MIN);
227.1063 +      else if (strcmp(csa->field, "max") == 0)
227.1064 +         glp_set_obj_dir(P, GLP_MAX);
227.1065 +      else
227.1066 +         error(csa, "objective sense missing or invalid");
227.1067 +      read_field(csa);
227.1068 +      if (!(str2int(csa->field, &m) == 0 && m >= 0))
227.1069 +         error(csa, "number of rows missing or invalid");
227.1070 +      read_field(csa);
227.1071 +      if (!(str2int(csa->field, &n) == 0 && n >= 0))
227.1072 +         error(csa, "number of columns missing or invalid");
227.1073 +      read_field(csa);
227.1074 +      if (!(str2int(csa->field, &nnz) == 0 && nnz >= 0))
227.1075 +         error(csa, "number of constraint coefficients missing or inval"
227.1076 +            "id");
227.1077 +      if (m > 0)
227.1078 +      {  glp_add_rows(P, m);
227.1079 +         for (i = 1; i <= m; i++)
227.1080 +            glp_set_row_bnds(P, i, GLP_FX, 0.0, 0.0);
227.1081 +      }
227.1082 +      if (n > 0)
227.1083 +      {  glp_add_cols(P, n);
227.1084 +         for (j = 1; j <= n; j++)
227.1085 +         {  if (!mip)
227.1086 +               glp_set_col_bnds(P, j, GLP_LO, 0.0, 0.0);
227.1087 +            else
227.1088 +               glp_set_col_kind(P, j, GLP_BV);
227.1089 +         }
227.1090 +      }
227.1091 +      end_of_line(csa);
227.1092 +      /* allocate working arrays */
227.1093 +      rf = xcalloc(1+m, sizeof(char));
227.1094 +      memset(rf, 0, 1+m);
227.1095 +      cf = xcalloc(1+n, sizeof(char));
227.1096 +      memset(cf, 0, 1+n);
227.1097 +      ln = xcalloc(1+nnz, sizeof(int));
227.1098 +      ia = xcalloc(1+nnz, sizeof(int));
227.1099 +      ja = xcalloc(1+nnz, sizeof(int));
227.1100 +      ar = xcalloc(1+nnz, sizeof(double));
227.1101 +      /* read descriptor lines */
227.1102 +      ne = 0;
227.1103 +      for (;;)
227.1104 +      {  read_designator(csa);
227.1105 +         if (strcmp(csa->field, "i") == 0)
227.1106 +         {  /* row descriptor */
227.1107 +            read_field(csa);
227.1108 +            if (str2int(csa->field, &i) != 0)
227.1109 +               error(csa, "row number missing or invalid");
227.1110 +            if (!(1 <= i && i <= m))
227.1111 +               error(csa, "row number out of range");
227.1112 +            read_field(csa);
227.1113 +            if (strcmp(csa->field, "f") == 0)
227.1114 +               type = GLP_FR;
227.1115 +            else if (strcmp(csa->field, "l") == 0)
227.1116 +               type = GLP_LO;
227.1117 +            else if (strcmp(csa->field, "u") == 0)
227.1118 +               type = GLP_UP;
227.1119 +            else if (strcmp(csa->field, "d") == 0)
227.1120 +               type = GLP_DB;
227.1121 +            else if (strcmp(csa->field, "s") == 0)
227.1122 +               type = GLP_FX;
227.1123 +            else
227.1124 +               error(csa, "row type missing or invalid");
227.1125 +            if (type == GLP_LO || type == GLP_DB || type == GLP_FX)
227.1126 +            {  read_field(csa);
227.1127 +               if (str2num(csa->field, &lb) != 0)
227.1128 +                  error(csa, "row lower bound/fixed value missing or in"
227.1129 +                     "valid");
227.1130 +            }
227.1131 +            else
227.1132 +               lb = 0.0;
227.1133 +            if (type == GLP_UP || type == GLP_DB)
227.1134 +            {  read_field(csa);
227.1135 +               if (str2num(csa->field, &ub) != 0)
227.1136 +                  error(csa, "row upper bound missing or invalid");
227.1137 +            }
227.1138 +            else
227.1139 +               ub = 0.0;
227.1140 +            if (rf[i] & 0x01)
227.1141 +               error(csa, "duplicate row descriptor");
227.1142 +            glp_set_row_bnds(P, i, type, lb, ub), rf[i] |= 0x01;
227.1143 +         }
227.1144 +         else if (strcmp(csa->field, "j") == 0)
227.1145 +         {  /* column descriptor */
227.1146 +            read_field(csa);
227.1147 +            if (str2int(csa->field, &j) != 0)
227.1148 +               error(csa, "column number missing or invalid");
227.1149 +            if (!(1 <= j && j <= n))
227.1150 +               error(csa, "column number out of range");
227.1151 +            if (!mip)
227.1152 +               kind = GLP_CV;
227.1153 +            else
227.1154 +            {  read_field(csa);
227.1155 +               if (strcmp(csa->field, "c") == 0)
227.1156 +                  kind = GLP_CV;
227.1157 +               else if (strcmp(csa->field, "i") == 0)
227.1158 +                  kind = GLP_IV;
227.1159 +               else if (strcmp(csa->field, "b") == 0)
227.1160 +               {  kind = GLP_IV;
227.1161 +                  type = GLP_DB, lb = 0.0, ub = 1.0;
227.1162 +                  goto skip;
227.1163 +               }
227.1164 +               else
227.1165 +                  error(csa, "column kind missing or invalid");
227.1166 +            }
227.1167 +            read_field(csa);
227.1168 +            if (strcmp(csa->field, "f") == 0)
227.1169 +               type = GLP_FR;
227.1170 +            else if (strcmp(csa->field, "l") == 0)
227.1171 +               type = GLP_LO;
227.1172 +            else if (strcmp(csa->field, "u") == 0)
227.1173 +               type = GLP_UP;
227.1174 +            else if (strcmp(csa->field, "d") == 0)
227.1175 +               type = GLP_DB;
227.1176 +            else if (strcmp(csa->field, "s") == 0)
227.1177 +               type = GLP_FX;
227.1178 +            else
227.1179 +               error(csa, "column type missing or invalid");
227.1180 +            if (type == GLP_LO || type == GLP_DB || type == GLP_FX)
227.1181 +            {  read_field(csa);
227.1182 +               if (str2num(csa->field, &lb) != 0)
227.1183 +                  error(csa, "column lower bound/fixed value missing or"
227.1184 +                     " invalid");
227.1185 +            }
227.1186 +            else
227.1187 +               lb = 0.0;
227.1188 +            if (type == GLP_UP || type == GLP_DB)
227.1189 +            {  read_field(csa);
227.1190 +               if (str2num(csa->field, &ub) != 0)
227.1191 +                  error(csa, "column upper bound missing or invalid");
227.1192 +            }
227.1193 +            else
227.1194 +               ub = 0.0;
227.1195 +skip:       if (cf[j] & 0x01)
227.1196 +               error(csa, "duplicate column descriptor");
227.1197 +            glp_set_col_kind(P, j, kind);
227.1198 +            glp_set_col_bnds(P, j, type, lb, ub), cf[j] |= 0x01;
227.1199 +         }
227.1200 +         else if (strcmp(csa->field, "a") == 0)
227.1201 +         {  /* coefficient descriptor */
227.1202 +            read_field(csa);
227.1203 +            if (str2int(csa->field, &i) != 0)
227.1204 +               error(csa, "row number missing or invalid");
227.1205 +            if (!(0 <= i && i <= m))
227.1206 +               error(csa, "row number out of range");
227.1207 +            read_field(csa);
227.1208 +            if (str2int(csa->field, &j) != 0)
227.1209 +               error(csa, "column number missing or invalid");
227.1210 +            if (!((i == 0 ? 0 : 1) <= j && j <= n))
227.1211 +               error(csa, "column number out of range");
227.1212 +            read_field(csa);
227.1213 +            if (i == 0)
227.1214 +            {  if (str2num(csa->field, &temp) != 0)
227.1215 +                  error(csa, "objective %s missing or invalid",
227.1216 +                     j == 0 ? "constant term" : "coefficient");
227.1217 +               if (cf[j] & 0x10)
227.1218 +                  error(csa, "duplicate objective %s",
227.1219 +                     j == 0 ? "constant term" : "coefficient");
227.1220 +               glp_set_obj_coef(P, j, temp), cf[j] |= 0x10;
227.1221 +            }
227.1222 +            else
227.1223 +            {  if (str2num(csa->field, &temp) != 0)
227.1224 +                  error(csa, "constraint coefficient missing or invalid"
227.1225 +                     );
227.1226 +               if (ne == nnz)
227.1227 +                  error(csa, "too many constraint coefficient descripto"
227.1228 +                     "rs");
227.1229 +               ln[++ne] = csa->count;
227.1230 +               ia[ne] = i, ja[ne] = j, ar[ne] = temp;
227.1231 +            }
227.1232 +         }
227.1233 +         else if (strcmp(csa->field, "n") == 0)
227.1234 +         {  /* symbolic name descriptor */
227.1235 +            read_field(csa);
227.1236 +            if (strcmp(csa->field, "p") == 0)
227.1237 +            {  /* problem name */
227.1238 +               read_field(csa);
227.1239 +               if (P->name != NULL)
227.1240 +                  error(csa, "duplicate problem name");
227.1241 +               glp_set_prob_name(P, csa->field);
227.1242 +            }
227.1243 +            else if (strcmp(csa->field, "z") == 0)
227.1244 +            {  /* objective name */
227.1245 +               read_field(csa);
227.1246 +               if (P->obj != NULL)
227.1247 +                  error(csa, "duplicate objective name");
227.1248 +               glp_set_obj_name(P, csa->field);
227.1249 +            }
227.1250 +            else if (strcmp(csa->field, "i") == 0)
227.1251 +            {  /* row name */
227.1252 +               read_field(csa);
227.1253 +               if (str2int(csa->field, &i) != 0)
227.1254 +                  error(csa, "row number missing or invalid");
227.1255 +               if (!(1 <= i && i <= m))
227.1256 +                  error(csa, "row number out of range");
227.1257 +               read_field(csa);
227.1258 +               if (P->row[i]->name != NULL)
227.1259 +                  error(csa, "duplicate row name");
227.1260 +               glp_set_row_name(P, i, csa->field);
227.1261 +            }
227.1262 +            else if (strcmp(csa->field, "j") == 0)
227.1263 +            {  /* column name */
227.1264 +               read_field(csa);
227.1265 +               if (str2int(csa->field, &j) != 0)
227.1266 +                  error(csa, "column number missing or invalid");
227.1267 +               if (!(1 <= j && j <= n))
227.1268 +                  error(csa, "column number out of range");
227.1269 +               read_field(csa);
227.1270 +               if (P->col[j]->name != NULL)
227.1271 +                  error(csa, "duplicate column name");
227.1272 +               glp_set_col_name(P, j, csa->field);
227.1273 +            }
227.1274 +            else
227.1275 +               error(csa, "object designator missing or invalid");
227.1276 +         }
227.1277 +         else if (strcmp(csa->field, "e") == 0)
227.1278 +            break;
227.1279 +         else
227.1280 +            error(csa, "line designator missing or invalid");
227.1281 +         end_of_line(csa);
227.1282 +      }
227.1283 +      if (ne < nnz)
227.1284 +         error(csa, "too few constraint coefficient descriptors");
227.1285 +      xassert(ne == nnz);
227.1286 +      k = glp_check_dup(m, n, ne, ia, ja);
227.1287 +      xassert(0 <= k && k <= nnz);
227.1288 +      if (k > 0)
227.1289 +      {  csa->count = ln[k];
227.1290 +         error(csa, "duplicate constraint coefficient");
227.1291 +      }
227.1292 +      glp_load_matrix(P, ne, ia, ja, ar);
227.1293 +      /* print some statistics */
227.1294 +      if (P->name != NULL)
227.1295 +         xprintf("Problem: %s\n", P->name);
227.1296 +      if (P->obj != NULL)
227.1297 +         xprintf("Objective: %s\n", P->obj);
227.1298 +      xprintf("%d row%s, %d column%s, %d non-zero%s\n",
227.1299 +         m, m == 1 ? "" : "s", n, n == 1 ? "" : "s", nnz, nnz == 1 ?
227.1300 +         "" : "s");
227.1301 +      if (glp_get_num_int(P) > 0)
227.1302 +      {  int ni = glp_get_num_int(P);
227.1303 +         int nb = glp_get_num_bin(P);
227.1304 +         if (ni == 1)
227.1305 +         {  if (nb == 0)
227.1306 +               xprintf("One variable is integer\n");
227.1307 +            else
227.1308 +               xprintf("One variable is binary\n");
227.1309 +         }
227.1310 +         else
227.1311 +         {  xprintf("%d integer variables, ", ni);
227.1312 +            if (nb == 0)
227.1313 +               xprintf("none");
227.1314 +            else if (nb == 1)
227.1315 +               xprintf("one");
227.1316 +            else if (nb == ni)
227.1317 +               xprintf("all");
227.1318 +            else
227.1319 +               xprintf("%d", nb);
227.1320 +            xprintf(" of which %s binary\n", nb == 1 ? "is" : "are");
227.1321 +         }
227.1322 +      }
227.1323 +      xprintf("%d lines were read\n", csa->count);
227.1324 +      /* problem data has been successfully read */
227.1325 +      glp_sort_matrix(P);
227.1326 +      ret = 0;
227.1327 +done: if (csa->fp != NULL) xfclose(csa->fp);
227.1328 +      if (rf != NULL) xfree(rf);
227.1329 +      if (cf != NULL) xfree(cf);
227.1330 +      if (ln != NULL) xfree(ln);
227.1331 +      if (ia != NULL) xfree(ia);
227.1332 +      if (ja != NULL) xfree(ja);
227.1333 +      if (ar != NULL) xfree(ar);
227.1334 +      if (ret) glp_erase_prob(P);
227.1335 +      return ret;
227.1336 +}
227.1337 +
227.1338 +/***********************************************************************
227.1339 +*  NAME
227.1340 +*
227.1341 +*  glp_write_prob - write problem data in GLPK format
227.1342 +*
227.1343 +*  SYNOPSIS
227.1344 +*
227.1345 +*  int glp_write_prob(glp_prob *P, int flags, const char *fname);
227.1346 +*
227.1347 +*  The routine glp_write_prob writes problem data in GLPK LP/MIP format
227.1348 +*  to a text file.
227.1349 +*
227.1350 +*  RETURNS
227.1351 +*
227.1352 +*  If the operation was successful, the routine returns zero. Otherwise
227.1353 +*  it prints an error message and returns non-zero. */
227.1354 +
227.1355 +int glp_write_prob(glp_prob *P, int flags, const char *fname)
227.1356 +{     XFILE *fp;
227.1357 +      GLPROW *row;
227.1358 +      GLPCOL *col;
227.1359 +      GLPAIJ *aij;
227.1360 +      int mip, i, j, count, ret;
227.1361 +      if (P == NULL || P->magic != GLP_PROB_MAGIC)
227.1362 +         xerror("glp_write_prob: P = %p; invalid problem object\n",
227.1363 +            P);
227.1364 +      if (flags != 0)
227.1365 +         xerror("glp_write_prob: flags = %d; invalid parameter\n",
227.1366 +            flags);
227.1367 +      if (fname == NULL)
227.1368 +         xerror("glp_write_prob: fname = %d; invalid parameter\n",
227.1369 +            fname);
227.1370 +      xprintf("Writing problem data to `%s'...\n", fname);
227.1371 +      fp = xfopen(fname, "w"), count = 0;
227.1372 +      if (fp == NULL)
227.1373 +      {  xprintf("Unable to create `%s' - %s\n", fname, xerrmsg());
227.1374 +         ret = 1;
227.1375 +         goto done;
227.1376 +      }
227.1377 +      /* write problem line */
227.1378 +      mip = (glp_get_num_int(P) > 0);
227.1379 +      xfprintf(fp, "p %s %s %d %d %d\n", !mip ? "lp" : "mip",
227.1380 +         P->dir == GLP_MIN ? "min" : P->dir == GLP_MAX ? "max" : "???",
227.1381 +         P->m, P->n, P->nnz), count++;
227.1382 +      if (P->name != NULL)
227.1383 +         xfprintf(fp, "n p %s\n", P->name), count++;
227.1384 +      if (P->obj != NULL)
227.1385 +         xfprintf(fp, "n z %s\n", P->obj), count++;
227.1386 +      /* write row descriptors */
227.1387 +      for (i = 1; i <= P->m; i++)
227.1388 +      {  row = P->row[i];
227.1389 +         if (row->type == GLP_FX && row->lb == 0.0)
227.1390 +            goto skip1;
227.1391 +         xfprintf(fp, "i %d ", i), count++;
227.1392 +         if (row->type == GLP_FR)
227.1393 +            xfprintf(fp, "f\n");
227.1394 +         else if (row->type == GLP_LO)
227.1395 +            xfprintf(fp, "l %.*g\n", DBL_DIG, row->lb);
227.1396 +         else if (row->type == GLP_UP)
227.1397 +            xfprintf(fp, "u %.*g\n", DBL_DIG, row->ub);
227.1398 +         else if (row->type == GLP_DB)
227.1399 +            xfprintf(fp, "d %.*g %.*g\n", DBL_DIG, row->lb, DBL_DIG,
227.1400 +                  row->ub);
227.1401 +         else if (row->type == GLP_FX)
227.1402 +            xfprintf(fp, "s %.*g\n", DBL_DIG, row->lb);
227.1403 +         else
227.1404 +            xassert(row != row);
227.1405 +skip1:   if (row->name != NULL)
227.1406 +            xfprintf(fp, "n i %d %s\n", i, row->name), count++;
227.1407 +      }
227.1408 +      /* write column descriptors */
227.1409 +      for (j = 1; j <= P->n; j++)
227.1410 +      {  col = P->col[j];
227.1411 +         if (!mip && col->type == GLP_LO && col->lb == 0.0)
227.1412 +            goto skip2;
227.1413 +         if (mip && col->kind == GLP_IV && col->type == GLP_DB &&
227.1414 +             col->lb == 0.0 && col->ub == 1.0)
227.1415 +            goto skip2;
227.1416 +         xfprintf(fp, "j %d ", j), count++;
227.1417 +         if (mip)
227.1418 +         {  if (col->kind == GLP_CV)
227.1419 +               xfprintf(fp, "c ");
227.1420 +            else if (col->kind == GLP_IV)
227.1421 +               xfprintf(fp, "i ");
227.1422 +            else
227.1423 +               xassert(col != col);
227.1424 +         }
227.1425 +         if (col->type == GLP_FR)
227.1426 +            xfprintf(fp, "f\n");
227.1427 +         else if (col->type == GLP_LO)
227.1428 +            xfprintf(fp, "l %.*g\n", DBL_DIG, col->lb);
227.1429 +         else if (col->type == GLP_UP)
227.1430 +            xfprintf(fp, "u %.*g\n", DBL_DIG, col->ub);
227.1431 +         else if (col->type == GLP_DB)
227.1432 +            xfprintf(fp, "d %.*g %.*g\n", DBL_DIG, col->lb, DBL_DIG,
227.1433 +                  col->ub);
227.1434 +         else if (col->type == GLP_FX)
227.1435 +            xfprintf(fp, "s %.*g\n", DBL_DIG, col->lb);
227.1436 +         else
227.1437 +            xassert(col != col);
227.1438 +skip2:   if (col->name != NULL)
227.1439 +            xfprintf(fp, "n j %d %s\n", j, col->name), count++;
227.1440 +      }
227.1441 +      /* write objective coefficient descriptors */
227.1442 +      if (P->c0 != 0.0)
227.1443 +         xfprintf(fp, "a 0 0 %.*g\n", DBL_DIG, P->c0), count++;
227.1444 +      for (j = 1; j <= P->n; j++)
227.1445 +      {  col = P->col[j];
227.1446 +         if (col->coef != 0.0)
227.1447 +            xfprintf(fp, "a 0 %d %.*g\n", j, DBL_DIG, col->coef),
227.1448 +               count++;
227.1449 +      }
227.1450 +      /* write constraint coefficient descriptors */
227.1451 +      for (i = 1; i <= P->m; i++)
227.1452 +      {  row = P->row[i];
227.1453 +         for (aij = row->ptr; aij != NULL; aij = aij->r_next)
227.1454 +            xfprintf(fp, "a %d %d %.*g\n", i, aij->col->j, DBL_DIG,
227.1455 +               aij->val), count++;
227.1456 +      }
227.1457 +      /* write end line */
227.1458 +      xfprintf(fp, "e o f\n"), count++;
227.1459 +      xfflush(fp);
227.1460 +      if (xferror(fp))
227.1461 +      {  xprintf("Write error on `%s' - %s\n", fname, xerrmsg());
227.1462 +         ret = 1;
227.1463 +         goto done;
227.1464 +      }
227.1465 +      xprintf("%d lines were written\n", count);
227.1466 +      ret = 0;
227.1467 +done: if (fp != NULL) xfclose(fp);
227.1468 +      return ret;
227.1469 +}
227.1470 +
227.1471 +/**********************************************************************/
227.1472 +
227.1473 +int glp_read_cnfsat(glp_prob *P, const char *fname)
227.1474 +{     /* read CNF-SAT problem data in DIMACS format */
227.1475 +      struct csa _csa, *csa = &_csa;
227.1476 +      int m, n, i, j, len, neg, rhs, ret = 0, *ind = NULL;
227.1477 +      double *val = NULL;
227.1478 +      char *map = NULL;
227.1479 +      if (P == NULL || P->magic != GLP_PROB_MAGIC)
227.1480 +         xerror("glp_read_cnfsat: P = %p; invalid problem object\n",
227.1481 +            P);
227.1482 +      if (fname == NULL)
227.1483 +         xerror("glp_read_cnfsat: fname = %p; invalid parameter\n",
227.1484 +            fname);
227.1485 +      glp_erase_prob(P);
227.1486 +      if (setjmp(csa->jump))
227.1487 +      {  ret = 1;
227.1488 +         goto done;
227.1489 +      }
227.1490 +      csa->fname = fname;
227.1491 +      csa->fp = NULL;
227.1492 +      csa->count = 0;
227.1493 +      csa->c = '\n';
227.1494 +      csa->field[0] = '\0';
227.1495 +      csa->empty = csa->nonint = 0;
227.1496 +      xprintf("Reading CNF-SAT problem data from `%s'...\n", fname);
227.1497 +      csa->fp = xfopen(fname, "r");
227.1498 +      if (csa->fp == NULL)
227.1499 +      {  xprintf("Unable to open `%s' - %s\n", fname, xerrmsg());
227.1500 +         longjmp(csa->jump, 1);
227.1501 +      }
227.1502 +      /* read problem line */
227.1503 +      read_designator(csa);
227.1504 +      if (strcmp(csa->field, "p") != 0)
227.1505 +         error(csa, "problem line missing or invalid");
227.1506 +      read_field(csa);
227.1507 +      if (strcmp(csa->field, "cnf") != 0)
227.1508 +         error(csa, "wrong problem designator; `cnf' expected\n");
227.1509 +      read_field(csa);
227.1510 +      if (!(str2int(csa->field, &n) == 0 && n >= 0))
227.1511 +         error(csa, "number of variables missing or invalid\n");
227.1512 +      read_field(csa);
227.1513 +      if (!(str2int(csa->field, &m) == 0 && m >= 0))
227.1514 +         error(csa, "number of clauses missing or invalid\n");
227.1515 +      xprintf("Instance has %d variable%s and %d clause%s\n",
227.1516 +         n, n == 1 ? "" : "s", m, m == 1 ? "" : "s");
227.1517 +      end_of_line(csa);
227.1518 +      if (m > 0)
227.1519 +         glp_add_rows(P, m);
227.1520 +      if (n > 0)
227.1521 +      {  glp_add_cols(P, n);
227.1522 +         for (j = 1; j <= n; j++)
227.1523 +            glp_set_col_kind(P, j, GLP_BV);
227.1524 +      }
227.1525 +      /* allocate working arrays */
227.1526 +      ind = xcalloc(1+n, sizeof(int));
227.1527 +      val = xcalloc(1+n, sizeof(double));
227.1528 +      map = xcalloc(1+n, sizeof(char));
227.1529 +      for (j = 1; j <= n; j++) map[j] = 0;
227.1530 +      /* read clauses */
227.1531 +      for (i = 1; i <= m; i++)
227.1532 +      {  /* read i-th clause */
227.1533 +         len = 0, rhs = 1;
227.1534 +         for (;;)
227.1535 +         {  /* skip white-space characters */
227.1536 +            while (csa->c == ' ' || csa->c == '\n')
227.1537 +               read_char(csa);
227.1538 +            /* read term */
227.1539 +            read_field(csa);
227.1540 +            if (str2int(csa->field, &j) != 0)
227.1541 +               error(csa, "variable number missing or invalid\n");
227.1542 +            if (j > 0)
227.1543 +               neg = 0;
227.1544 +            else if (j < 0)
227.1545 +               neg = 1, j = -j, rhs--;
227.1546 +            else
227.1547 +               break;
227.1548 +            if (!(1 <= j && j <= n))
227.1549 +               error(csa, "variable number out of range\n");
227.1550 +            if (map[j])
227.1551 +               error(csa, "duplicate variable number\n");
227.1552 +            len++, ind[len] = j, val[len] = (neg ? -1.0 : +1.0);
227.1553 +            map[j] = 1;
227.1554 +         }
227.1555 +         glp_set_row_bnds(P, i, GLP_LO, (double)rhs, 0.0);
227.1556 +         glp_set_mat_row(P, i, len, ind, val);
227.1557 +         while (len > 0) map[ind[len--]] = 0;
227.1558 +      }
227.1559 +      xprintf("%d lines were read\n", csa->count);
227.1560 +      /* problem data has been successfully read */
227.1561 +      glp_sort_matrix(P);
227.1562 +done: if (csa->fp != NULL) xfclose(csa->fp);
227.1563 +      if (ind != NULL) xfree(ind);
227.1564 +      if (val != NULL) xfree(val);
227.1565 +      if (map != NULL) xfree(map);
227.1566 +      if (ret) glp_erase_prob(P);
227.1567 +      return ret;
227.1568 +}
227.1569 +
227.1570 +/**********************************************************************/
227.1571 +
227.1572 +int glp_check_cnfsat(glp_prob *P)
227.1573 +{     /* check for CNF-SAT problem instance */
227.1574 +      int m = P->m;
227.1575 +      int n = P->n;
227.1576 +      GLPROW *row;
227.1577 +      GLPCOL *col;
227.1578 +      GLPAIJ *aij;
227.1579 +      int i, j, neg;
227.1580 +      if (P == NULL || P->magic != GLP_PROB_MAGIC)
227.1581 +         xerror("glp_check_cnfsat: P = %p; invalid problem object\n",
227.1582 +            P);
227.1583 +      /* check columns */
227.1584 +      for (j = 1; j <= n; j++)
227.1585 +      {  col = P->col[j];
227.1586 +         /* the variable should be binary */
227.1587 +         if (!(col->kind == GLP_IV && col->type == GLP_DB &&
227.1588 +               col->lb == 0.0 && col->ub == 1.0))
227.1589 +            return 1;
227.1590 +      }
227.1591 +      /* objective function should be zero */
227.1592 +      if (P->c0 != 0.0)
227.1593 +         return 2;
227.1594 +      for (j = 1; j <= n; j++)
227.1595 +      {  col = P->col[j];
227.1596 +         if (col->coef != 0.0)
227.1597 +            return 3;
227.1598 +      }
227.1599 +      /* check rows */
227.1600 +      for (i = 1; i <= m; i++)
227.1601 +      {  row = P->row[i];
227.1602 +         /* the row should be of ">=" type */
227.1603 +         if (row->type != GLP_LO)
227.1604 +            return 4;
227.1605 +         /* check constraint coefficients */
227.1606 +         neg = 0;
227.1607 +         for (aij = row->ptr; aij != NULL; aij = aij->r_next)
227.1608 +         {  /* the constraint coefficient should be +1 or -1 */
227.1609 +            if (aij->val == +1.0)
227.1610 +               ;
227.1611 +            else if (aij->val == -1.0)
227.1612 +               neg++;
227.1613 +            else
227.1614 +               return 5;
227.1615 +         }
227.1616 +         /* the right-hand side should be (1 - neg), where neg is the
227.1617 +            number of negative constraint coefficients in the row */
227.1618 +         if (row->lb != (double)(1 - neg))
227.1619 +            return 6;
227.1620 +      }
227.1621 +      /* congratulations; this is CNF-SAT */
227.1622 +      return 0;
227.1623 +}
227.1624 +
227.1625 +/**********************************************************************/
227.1626 +
227.1627 +int glp_write_cnfsat(glp_prob *P, const char *fname)
227.1628 +{     /* write CNF-SAT problem data in DIMACS format */
227.1629 +      XFILE *fp = NULL;
227.1630 +      GLPAIJ *aij;
227.1631 +      int i, j, len, count = 0, ret;
227.1632 +      char s[50];
227.1633 +      if (P == NULL || P->magic != GLP_PROB_MAGIC)
227.1634 +         xerror("glp_write_cnfsat: P = %p; invalid problem object\n",
227.1635 +            P);
227.1636 +      if (glp_check_cnfsat(P) != 0)
227.1637 +      {  xprintf("glp_write_cnfsat: problem object does not encode CNF-"
227.1638 +            "SAT instance\n");
227.1639 +         ret = 1;
227.1640 +         goto done;
227.1641 +      }
227.1642 +      xprintf("Writing CNF-SAT problem data to `%s'...\n", fname);
227.1643 +      fp = xfopen(fname, "w");
227.1644 +      if (fp == NULL)
227.1645 +      {  xprintf("Unable to create `%s' - %s\n", fname, xerrmsg());
227.1646 +         ret = 1;
227.1647 +         goto done;
227.1648 +      }
227.1649 +      xfprintf(fp, "c %s\n",
227.1650 +         P->name == NULL ? "unknown" : P->name), count++;
227.1651 +      xfprintf(fp, "p cnf %d %d\n", P->n, P->m), count++;
227.1652 +      for (i = 1; i <= P->m; i++)
227.1653 +      {  len = 0;
227.1654 +         for (aij = P->row[i]->ptr; aij != NULL; aij = aij->r_next)
227.1655 +         {  j = aij->col->j;
227.1656 +            if (aij->val < 0.0) j = -j;
227.1657 +            sprintf(s, "%d", j);
227.1658 +            if (len > 0 && len + 1 + strlen(s) > 72)
227.1659 +               xfprintf(fp, "\n"), count++, len = 0;
227.1660 +            xfprintf(fp, "%s%s", len == 0 ? "" : " ", s);
227.1661 +            if (len > 0) len++;
227.1662 +            len += strlen(s);
227.1663 +         }
227.1664 +         if (len > 0 && len + 1 + 1 > 72)
227.1665 +            xfprintf(fp, "\n"), count++, len = 0;
227.1666 +         xfprintf(fp, "%s0\n", len == 0 ? "" : " "), count++;
227.1667 +      }
227.1668 +      xfprintf(fp, "c eof\n"), count++;
227.1669 +      xfflush(fp);
227.1670 +      if (xferror(fp))
227.1671 +      {  xprintf("Write error on `%s' - %s\n", fname, xerrmsg());
227.1672 +         ret = 1;
227.1673 +         goto done;
227.1674 +      }
227.1675 +      xprintf("%d lines were written\n", count);
227.1676 +      ret = 0;
227.1677 +done: if (fp != NULL) xfclose(fp);
227.1678 +      return ret;
227.1679 +}
227.1680 +
227.1681 +/* eof */
   228.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
   228.2 +++ b/deps/glpk/src/glpenv.h	Sun Nov 06 20:59:10 2011 +0100
   228.3 @@ -0,0 +1,228 @@
   228.4 +/* glpenv.h (GLPK environment) */
   228.5 +
   228.6 +/***********************************************************************
   228.7 +*  This code is part of GLPK (GNU Linear Programming Kit).
   228.8 +*
   228.9 +*  Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008,
  228.10 +*  2009, 2010, 2011 Andrew Makhorin, Department for Applied Informatics,
  228.11 +*  Moscow Aviation Institute, Moscow, Russia. All rights reserved.
  228.12 +*  E-mail: <mao@gnu.org>.
  228.13 +*
  228.14 +*  GLPK is free software: you can redistribute it and/or modify it
  228.15 +*  under the terms of the GNU General Public License as published by
  228.16 +*  the Free Software Foundation, either version 3 of the License, or
  228.17 +*  (at your option) any later version.
  228.18 +*
  228.19 +*  GLPK is distributed in the hope that it will be useful, but WITHOUT
  228.20 +*  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
  228.21 +*  or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
  228.22 +*  License for more details.
  228.23 +*
  228.24 +*  You should have received a copy of the GNU General Public License
  228.25 +*  along with GLPK. If not, see <http://www.gnu.org/licenses/>.
  228.26 +***********************************************************************/
  228.27 +
  228.28 +#ifndef GLPENV_H
  228.29 +#define GLPENV_H
  228.30 +
  228.31 +#include "glpstd.h"
  228.32 +#include "glplib.h"
  228.33 +
  228.34 +typedef struct ENV ENV;
  228.35 +typedef struct MEM MEM;
  228.36 +typedef struct XFILE XFILE;
  228.37 +
  228.38 +#define ENV_MAGIC 0x454E5631
  228.39 +/* environment block magic value */
  228.40 +
  228.41 +#define TERM_BUF_SIZE 4096
  228.42 +/* terminal output buffer size, in bytes */
  228.43 +
  228.44 +#define IOERR_MSG_SIZE 1024
  228.45 +/* i/o error message buffer size, in bytes */
  228.46 +
  228.47 +#define MEM_MAGIC 0x4D454D31
  228.48 +/* memory block descriptor magic value */
  228.49 +
  228.50 +struct ENV
  228.51 +{     /* environment block */
  228.52 +      int magic;
  228.53 +      /* magic value used for debugging */
  228.54 +      char version[7+1];
  228.55 +      /* version string returned by the routine glp_version */
  228.56 +      /*--------------------------------------------------------------*/
  228.57 +      /* terminal output */
  228.58 +      char *term_buf; /* char term_buf[TERM_BUF_SIZE]; */
  228.59 +      /* terminal output buffer */
  228.60 +      int term_out;
  228.61 +      /* flag to enable/disable terminal output */
  228.62 +      int (*term_hook)(void *info, const char *s);
  228.63 +      /* user-defined routine to intercept terminal output */
  228.64 +      void *term_info;
  228.65 +      /* transit pointer (cookie) passed to the routine term_hook */
  228.66 +      FILE *tee_file;
  228.67 +      /* output stream used to copy terminal output */
  228.68 +      /*--------------------------------------------------------------*/
  228.69 +      /* error handling */
  228.70 +      const char *err_file;
  228.71 +      /* value of the __FILE__ macro passed to glp_error */
  228.72 +      int err_line;
  228.73 +      /* value of the __LINE__ macro passed to glp_error */
  228.74 +      void (*err_hook)(void *info);
  228.75 +      /* user-defined routine to intercept abnormal termination */
  228.76 +      void *err_info;
  228.77 +      /* transit pointer (cookie) passed to the routine err_hook */
  228.78 +      /*--------------------------------------------------------------*/
  228.79 +      /* memory allocation */
  228.80 +      glp_long mem_limit;
  228.81 +      /* maximal amount of memory (in bytes) available for dynamic
  228.82 +         allocation */
  228.83 +      MEM *mem_ptr;
  228.84 +      /* pointer to the linked list of allocated memory blocks */
  228.85 +      int mem_count;
  228.86 +      /* total number of currently allocated memory blocks */
  228.87 +      int mem_cpeak;
  228.88 +      /* peak value of mem_count */
  228.89 +      glp_long mem_total;
  228.90 +      /* total amount of currently allocated memory (in bytes; is the
  228.91 +         sum of the size field over all memory block descriptors) */
  228.92 +      glp_long mem_tpeak;
  228.93 +      /* peak value of mem_total */
  228.94 +      /*--------------------------------------------------------------*/
  228.95 +      /* stream input/output */
  228.96 +      XFILE *file_ptr;
  228.97 +      /* pointer to the linked list of active stream descriptors */
  228.98 +      char *ioerr_msg; /* char ioerr_msg[IOERR_MSG_SIZE]; */
  228.99 +      /* input/output error message buffer */
 228.100 +      /*--------------------------------------------------------------*/
 228.101 +      /* shared libraries support */
 228.102 +      void *h_odbc;
 228.103 +      /* handle to ODBC shared library */
 228.104 +      void *h_mysql;
 228.105 +      /* handle to MySQL shared library */
 228.106 +};
 228.107 +
 228.108 +struct MEM
 228.109 +{     /* memory block descriptor */
 228.110 +      int flag;
 228.111 +      /* descriptor flag */
 228.112 +      int size;
 228.113 +      /* size of block (in bytes, including descriptor) */
 228.114 +      MEM *prev;
 228.115 +      /* pointer to previous memory block descriptor */
 228.116 +      MEM *next;
 228.117 +      /* pointer to next memory block descriptor */
 228.118 +};
 228.119 +
 228.120 +struct XFILE
 228.121 +{     /* input/output stream descriptor */
 228.122 +      int type;
 228.123 +      /* stream handle type: */
 228.124 +#define FH_FILE   0x11  /* FILE   */
 228.125 +#define FH_ZLIB   0x22  /* gzFile */
 228.126 +      void *fh;
 228.127 +      /* pointer to stream handle */
 228.128 +      XFILE *prev;
 228.129 +      /* pointer to previous stream descriptor */
 228.130 +      XFILE *next;
 228.131 +      /* pointer to next stream descriptor */
 228.132 +};
 228.133 +
 228.134 +#define XEOF (-1)
 228.135 +
 228.136 +#define get_env_ptr _glp_get_env_ptr
 228.137 +ENV *get_env_ptr(void);
 228.138 +/* retrieve pointer to environment block */
 228.139 +
 228.140 +#define tls_set_ptr _glp_tls_set_ptr
 228.141 +void tls_set_ptr(void *ptr);
 228.142 +/* store global pointer in TLS */
 228.143 +
 228.144 +#define tls_get_ptr _glp_tls_get_ptr
 228.145 +void *tls_get_ptr(void);
 228.146 +/* retrieve global pointer from TLS */
 228.147 +
 228.148 +#define xprintf glp_printf
 228.149 +void glp_printf(const char *fmt, ...);
 228.150 +/* write formatted output to the terminal */
 228.151 +
 228.152 +#define xvprintf glp_vprintf
 228.153 +void glp_vprintf(const char *fmt, va_list arg);
 228.154 +/* write formatted output to the terminal */
 228.155 +
 228.156 +#ifndef GLP_ERROR_DEFINED
 228.157 +#define GLP_ERROR_DEFINED
 228.158 +typedef void (*_glp_error)(const char *fmt, ...);
 228.159 +#endif
 228.160 +
 228.161 +#define xerror glp_error_(__FILE__, __LINE__)
 228.162 +_glp_error glp_error_(const char *file, int line);
 228.163 +/* display error message and terminate execution */
 228.164 +
 228.165 +#define xassert(expr) \
 228.166 +      ((void)((expr) || (glp_assert_(#expr, __FILE__, __LINE__), 1)))
 228.167 +void glp_assert_(const char *expr, const char *file, int line);
 228.168 +/* check for logical condition */
 228.169 +
 228.170 +#define xmalloc glp_malloc
 228.171 +void *glp_malloc(int size);
 228.172 +/* allocate memory block */
 228.173 +
 228.174 +#define xcalloc glp_calloc
 228.175 +void *glp_calloc(int n, int size);
 228.176 +/* allocate memory block */
 228.177 +
 228.178 +#define xfree glp_free
 228.179 +void glp_free(void *ptr);
 228.180 +/* free memory block */
 228.181 +
 228.182 +#define xtime glp_time
 228.183 +glp_long glp_time(void);
 228.184 +/* determine current universal time */
 228.185 +
 228.186 +#define xdifftime glp_difftime
 228.187 +double glp_difftime(glp_long t1, glp_long t0);
 228.188 +/* compute difference between two time values, in seconds */
 228.189 +
 228.190 +#define lib_err_msg _glp_lib_err_msg
 228.191 +void lib_err_msg(const char *msg);
 228.192 +
 228.193 +#define xerrmsg _glp_lib_xerrmsg
 228.194 +const char *xerrmsg(void);
 228.195 +
 228.196 +#define xfopen _glp_lib_xfopen
 228.197 +XFILE *xfopen(const char *fname, const char *mode);
 228.198 +
 228.199 +#define xferror _glp_lib_xferror
 228.200 +int xferror(XFILE *file);
 228.201 +
 228.202 +#define xfeof _glp_lib_xfeof
 228.203 +int xfeof(XFILE *file);
 228.204 +
 228.205 +#define xfgetc _glp_lib_xfgetc
 228.206 +int xfgetc(XFILE *file);
 228.207 +
 228.208 +#define xfputc _glp_lib_xfputc
 228.209 +int xfputc(int c, XFILE *file);
 228.210 +
 228.211 +#define xfflush _glp_lib_xfflush
 228.212 +int xfflush(XFILE *fp);
 228.213 +
 228.214 +#define xfclose _glp_lib_xfclose
 228.215 +int xfclose(XFILE *file);
 228.216 +
 228.217 +#define xfprintf _glp_lib_xfprintf
 228.218 +int xfprintf(XFILE *file, const char *fmt, ...);
 228.219 +
 228.220 +#define xdlopen _glp_xdlopen
 228.221 +void *xdlopen(const char *module);
 228.222 +
 228.223 +#define xdlsym _glp_xdlsym
 228.224 +void *xdlsym(void *h, const char *symbol);
 228.225 +
 228.226 +#define xdlclose _glp_xdlclose
 228.227 +void xdlclose(void *h);
 228.228 +
 228.229 +#endif
 228.230 +
 228.231 +/* eof */
   229.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
   229.2 +++ b/deps/glpk/src/glpenv01.c	Sun Nov 06 20:59:10 2011 +0100
   229.3 @@ -0,0 +1,233 @@
   229.4 +/* glpenv01.c (environment initialization/termination) */
   229.5 +
   229.6 +/***********************************************************************
   229.7 +*  This code is part of GLPK (GNU Linear Programming Kit).
   229.8 +*
   229.9 +*  Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008,
  229.10 +*  2009, 2010, 2011 Andrew Makhorin, Department for Applied Informatics,
  229.11 +*  Moscow Aviation Institute, Moscow, Russia. All rights reserved.
  229.12 +*  E-mail: <mao@gnu.org>.
  229.13 +*
  229.14 +*  GLPK is free software: you can redistribute it and/or modify it
  229.15 +*  under the terms of the GNU General Public License as published by
  229.16 +*  the Free Software Foundation, either version 3 of the License, or
  229.17 +*  (at your option) any later version.
  229.18 +*
  229.19 +*  GLPK is distributed in the hope that it will be useful, but WITHOUT
  229.20 +*  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
  229.21 +*  or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
  229.22 +*  License for more details.
  229.23 +*
  229.24 +*  You should have received a copy of the GNU General Public License
  229.25 +*  along with GLPK. If not, see <http://www.gnu.org/licenses/>.
  229.26 +***********************************************************************/
  229.27 +
  229.28 +#include "glpapi.h"
  229.29 +
  229.30 +/***********************************************************************
  229.31 +*  NAME
  229.32 +*
  229.33 +*  glp_init_env - initialize GLPK environment
  229.34 +*
  229.35 +*  SYNOPSIS
  229.36 +*
  229.37 +*  int glp_init_env(void);
  229.38 +*
  229.39 +*  DESCRIPTION
  229.40 +*
  229.41 +*  The routine glp_init_env initializes the GLPK environment. Normally
  229.42 +*  the application program does not need to call this routine, because
  229.43 +*  it is called automatically on the first call to any API routine.
  229.44 +*
  229.45 +*  RETURNS
  229.46 +*
  229.47 +*  The routine glp_init_env returns one of the following codes:
  229.48 +*
  229.49 +*  0 - initialization successful;
  229.50 +*  1 - environment has been already initialized;
  229.51 +*  2 - initialization failed (insufficient memory);
  229.52 +*  3 - initialization failed (unsupported programming model). */
  229.53 +
  229.54 +int glp_init_env(void)
  229.55 +{     ENV *env;
  229.56 +      int ok;
  229.57 +      /* check if the programming model is supported */
  229.58 +      ok = (CHAR_BIT == 8 && sizeof(char) == 1 &&
  229.59 +         sizeof(short) == 2 && sizeof(int) == 4 &&
  229.60 +         (sizeof(void *) == 4 || sizeof(void *) == 8));
  229.61 +      if (!ok) return 3;
  229.62 +      /* check if the environment is already initialized */
  229.63 +      if (tls_get_ptr() != NULL) return 1;
  229.64 +      /* allocate and initialize the environment block */
  229.65 +      env = malloc(sizeof(ENV));
  229.66 +      if (env == NULL) return 2;
  229.67 +      env->magic = ENV_MAGIC;
  229.68 +      sprintf(env->version, "%d.%d",
  229.69 +         GLP_MAJOR_VERSION, GLP_MINOR_VERSION);
  229.70 +      env->term_buf = malloc(TERM_BUF_SIZE);
  229.71 +      if (env->term_buf == NULL)
  229.72 +      {  free(env);
  229.73 +         return 2;
  229.74 +      }
  229.75 +      env->term_out = GLP_ON;
  229.76 +      env->term_hook = NULL;
  229.77 +      env->term_info = NULL;
  229.78 +      env->tee_file = NULL;
  229.79 +      env->err_file = "";
  229.80 +      env->err_line = 0;
  229.81 +      env->err_hook = NULL;
  229.82 +      env->err_info = NULL;
  229.83 +      env->mem_limit.hi = 0x7FFFFFFF, env->mem_limit.lo = 0xFFFFFFFF;
  229.84 +      env->mem_ptr = NULL;
  229.85 +      env->mem_count = env->mem_cpeak = 0;
  229.86 +      env->mem_total = env->mem_tpeak = xlset(0);
  229.87 +      env->file_ptr = NULL;
  229.88 +      env->ioerr_msg = malloc(IOERR_MSG_SIZE);
  229.89 +      if (env->ioerr_msg == NULL)
  229.90 +      {  free(env->term_buf);
  229.91 +         free(env);
  229.92 +         return 2;
  229.93 +      }
  229.94 +      strcpy(env->ioerr_msg, "No error");
  229.95 +      env->h_odbc = env->h_mysql = NULL;
  229.96 +      /* save pointer to the environment block */
  229.97 +      tls_set_ptr(env);
  229.98 +      /* initialization successful */
  229.99 +      return 0;
 229.100 +}
 229.101 +
 229.102 +/***********************************************************************
 229.103 +*  NAME
 229.104 +*
 229.105 +*  get_env_ptr - retrieve pointer to environment block
 229.106 +*
 229.107 +*  SYNOPSIS
 229.108 +*
 229.109 +*  #include "glpenv.h"
 229.110 +*  ENV *get_env_ptr(void);
 229.111 +*
 229.112 +*  DESCRIPTION
 229.113 +*
 229.114 +*  The routine get_env_ptr retrieves and returns a pointer to the GLPK
 229.115 +*  environment block.
 229.116 +*
 229.117 +*  If the GLPK environment has not been initialized yet, the routine
 229.118 +*  performs initialization. If initialization fails, the routine prints
 229.119 +*  an error message to stderr and terminates the program.
 229.120 +*
 229.121 +*  RETURNS
 229.122 +*
 229.123 +*  The routine returns a pointer to the environment block. */
 229.124 +
 229.125 +ENV *get_env_ptr(void)
 229.126 +{     ENV *env = tls_get_ptr();
 229.127 +      /* check if the environment has been initialized */
 229.128 +      if (env == NULL)
 229.129 +      {  /* not initialized yet; perform initialization */
 229.130 +         if (glp_init_env() != 0)
 229.131 +         {  /* initialization failed; display an error message */
 229.132 +            fprintf(stderr, "GLPK initialization failed\n");
 229.133 +            fflush(stderr);
 229.134 +            /* and abnormally terminate the program */
 229.135 +            abort();
 229.136 +         }
 229.137 +         /* initialization successful; retrieve the pointer */
 229.138 +         env = tls_get_ptr();
 229.139 +      }
 229.140 +      /* check if the environment block is valid */
 229.141 +      if (env->magic != ENV_MAGIC)
 229.142 +      {  fprintf(stderr, "Invalid GLPK environment\n");
 229.143 +         fflush(stderr);
 229.144 +         abort();
 229.145 +      }
 229.146 +      return env;
 229.147 +}
 229.148 +
 229.149 +/***********************************************************************
 229.150 +*  NAME
 229.151 +*
 229.152 +*  glp_version - determine library version
 229.153 +*
 229.154 +*  SYNOPSIS
 229.155 +*
 229.156 +*  const char *glp_version(void);
 229.157 +*
 229.158 +*  RETURNS
 229.159 +*
 229.160 +*  The routine glp_version returns a pointer to a null-terminated
 229.161 +*  character string, which specifies the version of the GLPK library in
 229.162 +*  the form "X.Y", where X is the major version number, and Y is the
 229.163 +*  minor version number, for example, "4.16". */
 229.164 +
 229.165 +const char *glp_version(void)
 229.166 +{     ENV *env = get_env_ptr();
 229.167 +      return env->version;
 229.168 +}
 229.169 +
 229.170 +/***********************************************************************
 229.171 +*  NAME
 229.172 +*
 229.173 +*  glp_free_env - free GLPK environment
 229.174 +*
 229.175 +*  SYNOPSIS
 229.176 +*
 229.177 +*  int glp_free_env(void);
 229.178 +*
 229.179 +*  DESCRIPTION
 229.180 +*
 229.181 +*  The routine glp_free_env frees all resources used by GLPK routines
 229.182 +*  (memory blocks, etc.) which are currently still in use.
 229.183 +*
 229.184 +*  Normally the application program does not need to call this routine,
 229.185 +*  because GLPK routines always free all unused resources. However, if
 229.186 +*  the application program even has deleted all problem objects, there
 229.187 +*  will be several memory blocks still allocated for the library needs.
 229.188 +*  For some reasons the application program may want GLPK to free this
 229.189 +*  memory, in which case it should call glp_free_env.
 229.190 +*
 229.191 +*  Note that a call to glp_free_env invalidates all problem objects as
 229.192 +*  if no GLPK routine were called.
 229.193 +*
 229.194 +*  RETURNS
 229.195 +*
 229.196 +*  0 - termination successful;
 229.197 +*  1 - environment is inactive (was not initialized). */
 229.198 +
 229.199 +int glp_free_env(void)
 229.200 +{     ENV *env = tls_get_ptr();
 229.201 +      MEM *desc;
 229.202 +      /* check if the environment is active */
 229.203 +      if (env == NULL) return 1;
 229.204 +      /* check if the environment block is valid */
 229.205 +      if (env->magic != ENV_MAGIC)
 229.206 +      {  fprintf(stderr, "Invalid GLPK environment\n");
 229.207 +         fflush(stderr);
 229.208 +         abort();
 229.209 +      }
 229.210 +      /* close handles to shared libraries */
 229.211 +      if (env->h_odbc != NULL)
 229.212 +         xdlclose(env->h_odbc);
 229.213 +      if (env->h_mysql != NULL)
 229.214 +         xdlclose(env->h_mysql);
 229.215 +      /* close streams which are still open */
 229.216 +      while (env->file_ptr != NULL)
 229.217 +         xfclose(env->file_ptr);
 229.218 +      /* free memory blocks which are still allocated */
 229.219 +      while (env->mem_ptr != NULL)
 229.220 +      {  desc = env->mem_ptr;
 229.221 +         env->mem_ptr = desc->next;
 229.222 +         free(desc);
 229.223 +      }
 229.224 +      /* invalidate the environment block */
 229.225 +      env->magic = -1;
 229.226 +      /* free memory allocated to the environment block */
 229.227 +      free(env->term_buf);
 229.228 +      free(env->ioerr_msg);
 229.229 +      free(env);
 229.230 +      /* reset a pointer to the environment block */
 229.231 +      tls_set_ptr(NULL);
 229.232 +      /* termination successful */
 229.233 +      return 0;
 229.234 +}
 229.235 +
 229.236 +/* eof */
   230.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
   230.2 +++ b/deps/glpk/src/glpenv02.c	Sun Nov 06 20:59:10 2011 +0100
   230.3 @@ -0,0 +1,73 @@
   230.4 +/* glpenv02.c (thread local storage) */
   230.5 +
   230.6 +/***********************************************************************
   230.7 +*  This code is part of GLPK (GNU Linear Programming Kit).
   230.8 +*
   230.9 +*  Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008,
  230.10 +*  2009, 2010, 2011 Andrew Makhorin, Department for Applied Informatics,
  230.11 +*  Moscow Aviation Institute, Moscow, Russia. All rights reserved.
  230.12 +*  E-mail: <mao@gnu.org>.
  230.13 +*
  230.14 +*  GLPK is free software: you can redistribute it and/or modify it
  230.15 +*  under the terms of the GNU General Public License as published by
  230.16 +*  the Free Software Foundation, either version 3 of the License, or
  230.17 +*  (at your option) any later version.
  230.18 +*
  230.19 +*  GLPK is distributed in the hope that it will be useful, but WITHOUT
  230.20 +*  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
  230.21 +*  or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
  230.22 +*  License for more details.
  230.23 +*
  230.24 +*  You should have received a copy of the GNU General Public License
  230.25 +*  along with GLPK. If not, see <http://www.gnu.org/licenses/>.
  230.26 +***********************************************************************/
  230.27 +
  230.28 +#include "glpenv.h"
  230.29 +
  230.30 +static void *tls = NULL;
  230.31 +/* in a re-entrant version of the package this variable must be placed
  230.32 +   in the Thread Local Storage (TLS) */
  230.33 +
  230.34 +/***********************************************************************
  230.35 +*  NAME
  230.36 +*
  230.37 +*  tls_set_ptr - store global pointer in TLS
  230.38 +*
  230.39 +*  SYNOPSIS
  230.40 +*
  230.41 +*  #include "glpenv.h"
  230.42 +*  void tls_set_ptr(void *ptr);
  230.43 +*
  230.44 +*  DESCRIPTION
  230.45 +*
  230.46 +*  The routine tls_set_ptr stores a pointer specified by the parameter
  230.47 +*  ptr in the Thread Local Storage (TLS). */
  230.48 +
  230.49 +void tls_set_ptr(void *ptr)
  230.50 +{     tls = ptr;
  230.51 +      return;
  230.52 +}
  230.53 +
  230.54 +/***********************************************************************
  230.55 +*  NAME
  230.56 +*
  230.57 +*  tls_get_ptr - retrieve global pointer from TLS
  230.58 +*
  230.59 +*  SYNOPSIS
  230.60 +*
  230.61 +*  #include "glpenv.h"
  230.62 +*  void *tls_get_ptr(void);
  230.63 +*
  230.64 +*  RETURNS
  230.65 +*
  230.66 +*  The routine tls_get_ptr returns a pointer previously stored by the
  230.67 +*  routine tls_set_ptr. If the latter has not been called yet, NULL is
  230.68 +*  returned. */
  230.69 +
  230.70 +void *tls_get_ptr(void)
  230.71 +{     void *ptr;
  230.72 +      ptr = tls;
  230.73 +      return ptr;
  230.74 +}
  230.75 +
  230.76 +/* eof */
   231.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
   231.2 +++ b/deps/glpk/src/glpenv03.c	Sun Nov 06 20:59:10 2011 +0100
   231.3 @@ -0,0 +1,228 @@
   231.4 +/* glpenv03.c (terminal output) */
   231.5 +
   231.6 +/***********************************************************************
   231.7 +*  This code is part of GLPK (GNU Linear Programming Kit).
   231.8 +*
   231.9 +*  Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008,
  231.10 +*  2009, 2010, 2011 Andrew Makhorin, Department for Applied Informatics,
  231.11 +*  Moscow Aviation Institute, Moscow, Russia. All rights reserved.
  231.12 +*  E-mail: <mao@gnu.org>.
  231.13 +*
  231.14 +*  GLPK is free software: you can redistribute it and/or modify it
  231.15 +*  under the terms of the GNU General Public License as published by
  231.16 +*  the Free Software Foundation, either version 3 of the License, or
  231.17 +*  (at your option) any later version.
  231.18 +*
  231.19 +*  GLPK is distributed in the hope that it will be useful, but WITHOUT
  231.20 +*  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
  231.21 +*  or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
  231.22 +*  License for more details.
  231.23 +*
  231.24 +*  You should have received a copy of the GNU General Public License
  231.25 +*  along with GLPK. If not, see <http://www.gnu.org/licenses/>.
  231.26 +***********************************************************************/
  231.27 +
  231.28 +#include "glpapi.h"
  231.29 +
  231.30 +/***********************************************************************
  231.31 +*  NAME
  231.32 +*
  231.33 +*  glp_printf - write formatted output to terminal
  231.34 +*
  231.35 +*  SYNOPSIS
  231.36 +*
  231.37 +*  void glp_printf(const char *fmt, ...);
  231.38 +*
  231.39 +*  DESCRIPTION
  231.40 +*
  231.41 +*  The routine glp_printf uses the format control string fmt to format
  231.42 +*  its parameters and writes the formatted output to the terminal. */
  231.43 +
  231.44 +void glp_printf(const char *fmt, ...)
  231.45 +{     va_list arg;
  231.46 +      va_start(arg, fmt);
  231.47 +      xvprintf(fmt, arg);
  231.48 +      va_end(arg);
  231.49 +      return;
  231.50 +}
  231.51 +
  231.52 +/***********************************************************************
  231.53 +*  NAME
  231.54 +*
  231.55 +*  glp_vprintf - write formatted output to terminal
  231.56 +*
  231.57 +*  SYNOPSIS
  231.58 +*
  231.59 +*  void glp_vprintf(const char *fmt, va_list arg);
  231.60 +*
  231.61 +*  DESCRIPTION
  231.62 +*
  231.63 +*  The routine glp_vprintf uses the format control string fmt to format
  231.64 +*  its parameters specified by the list arg and writes the formatted
  231.65 +*  output to the terminal. */
  231.66 +
  231.67 +void glp_vprintf(const char *fmt, va_list arg)
  231.68 +{     ENV *env = get_env_ptr();
  231.69 +      /* if terminal output is disabled, do nothing */
  231.70 +      if (!env->term_out) goto skip;
  231.71 +      /* format the output */
  231.72 +      vsprintf(env->term_buf, fmt, arg);
  231.73 +      /* pass the output to the user-defined routine */
  231.74 +      if (env->term_hook != NULL)
  231.75 +      {  if (env->term_hook(env->term_info, env->term_buf) != 0)
  231.76 +            goto skip;
  231.77 +      }
  231.78 +      /* send the output to the terminal */
  231.79 +      fputs(env->term_buf, stdout);
  231.80 +      fflush(stdout);
  231.81 +      /* copy the output to the text file */
  231.82 +      if (env->tee_file != NULL)
  231.83 +      {  fputs(env->term_buf, env->tee_file);
  231.84 +         fflush(env->tee_file);
  231.85 +      }
  231.86 +skip: return;
  231.87 +}
  231.88 +
  231.89 +/***********************************************************************
  231.90 +*  NAME
  231.91 +*
  231.92 +*  glp_term_out - enable/disable terminal output
  231.93 +*
  231.94 +*  SYNOPSIS
  231.95 +*
  231.96 +*  int glp_term_out(int flag);
  231.97 +*
  231.98 +*  DESCRIPTION
  231.99 +*
 231.100 +*  Depending on the parameter flag the routine glp_term_out enables or
 231.101 +*  disables terminal output performed by glpk routines:
 231.102 +*
 231.103 +*  GLP_ON  - enable terminal output;
 231.104 +*  GLP_OFF - disable terminal output.
 231.105 +*
 231.106 +*  RETURNS
 231.107 +*
 231.108 +*  The routine glp_term_out returns the previous value of the terminal
 231.109 +*  output flag. */
 231.110 +
 231.111 +int glp_term_out(int flag)
 231.112 +{     ENV *env = get_env_ptr();
 231.113 +      int old = env->term_out;
 231.114 +      if (!(flag == GLP_ON || flag == GLP_OFF))
 231.115 +         xerror("glp_term_out: flag = %d; invalid value\n", flag);
 231.116 +      env->term_out = flag;
 231.117 +      return old;
 231.118 +}
 231.119 +
 231.120 +/***********************************************************************
 231.121 +*  NAME
 231.122 +*
 231.123 +*  glp_term_hook - install hook to intercept terminal output
 231.124 +*
 231.125 +*  SYNOPSIS
 231.126 +*
 231.127 +*  void glp_term_hook(int (*func)(void *info, const char *s),
 231.128 +*     void *info);
 231.129 +*
 231.130 +*  DESCRIPTION
 231.131 +*
 231.132 +*  The routine glp_term_hook installs a user-defined hook routine to
 231.133 +*  intercept all terminal output performed by glpk routines.
 231.134 +*
 231.135 +*  This feature can be used to redirect the terminal output to other
 231.136 +*  destination, for example to a file or a text window.
 231.137 +*
 231.138 +*  The parameter func specifies the user-defined hook routine. It is
 231.139 +*  called from an internal printing routine, which passes to it two
 231.140 +*  parameters: info and s. The parameter info is a transit pointer,
 231.141 +*  specified in the corresponding call to the routine glp_term_hook;
 231.142 +*  it may be used to pass some information to the hook routine. The
 231.143 +*  parameter s is a pointer to the null terminated character string,
 231.144 +*  which is intended to be written to the terminal. If the hook routine
 231.145 +*  returns zero, the printing routine writes the string s to the
 231.146 +*  terminal in a usual way; otherwise, if the hook routine returns
 231.147 +*  non-zero, no terminal output is performed.
 231.148 +*
 231.149 +*  To uninstall the hook routine the parameters func and info should be
 231.150 +*  specified as NULL. */
 231.151 +
 231.152 +void glp_term_hook(int (*func)(void *info, const char *s), void *info)
 231.153 +{     ENV *env = get_env_ptr();
 231.154 +      if (func == NULL)
 231.155 +      {  env->term_hook = NULL;
 231.156 +         env->term_info = NULL;
 231.157 +      }
 231.158 +      else
 231.159 +      {  env->term_hook = func;
 231.160 +         env->term_info = info;
 231.161 +      }
 231.162 +      return;
 231.163 +}
 231.164 +
 231.165 +/***********************************************************************
 231.166 +*  NAME
 231.167 +*
 231.168 +*  glp_open_tee - start copying terminal output to text file
 231.169 +*
 231.170 +*  SYNOPSIS
 231.171 +*
 231.172 +*  int glp_open_tee(const char *fname);
 231.173 +*
 231.174 +*  DESCRIPTION
 231.175 +*
 231.176 +*  The routine glp_open_tee starts copying all the terminal output to
 231.177 +*  an output text file, whose name is specified by the character string
 231.178 +*  fname.
 231.179 +*
 231.180 +*  RETURNS
 231.181 +*
 231.182 +*  0 - operation successful
 231.183 +*  1 - copying terminal output is already active
 231.184 +*  2 - unable to create output file */
 231.185 +
 231.186 +int glp_open_tee(const char *fname)
 231.187 +{     ENV *env = get_env_ptr();
 231.188 +      if (env->tee_file != NULL)
 231.189 +      {  /* copying terminal output is already active */
 231.190 +         return 1;
 231.191 +      }
 231.192 +      env->tee_file = fopen(fname, "w");
 231.193 +      if (env->tee_file == NULL)
 231.194 +      {  /* unable to create output file */
 231.195 +         return 2;
 231.196 +      }
 231.197 +      return 0;
 231.198 +}
 231.199 +
 231.200 +/***********************************************************************
 231.201 +*  NAME
 231.202 +*
 231.203 +*  glp_close_tee - stop copying terminal output to text file
 231.204 +*
 231.205 +*  SYNOPSIS
 231.206 +*
 231.207 +*  int glp_close_tee(void);
 231.208 +*
 231.209 +*  DESCRIPTION
 231.210 +*
 231.211 +*  The routine glp_close_tee stops copying the terminal output to the
 231.212 +*  output text file previously open by the routine glp_open_tee closing
 231.213 +*  that file.
 231.214 +*
 231.215 +*  RETURNS
 231.216 +*
 231.217 +*  0 - operation successful
 231.218 +*  1 - copying terminal output was not started */
 231.219 +
 231.220 +int glp_close_tee(void)
 231.221 +{     ENV *env = get_env_ptr();
 231.222 +      if (env->tee_file == NULL)
 231.223 +      {  /* copying terminal output was not started */
 231.224 +         return 1;
 231.225 +      }
 231.226 +      fclose(env->tee_file);
 231.227 +      env->tee_file = NULL;
 231.228 +      return 0;
 231.229 +}
 231.230 +
 231.231 +/* eof */
   232.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
   232.2 +++ b/deps/glpk/src/glpenv04.c	Sun Nov 06 20:59:10 2011 +0100
   232.3 @@ -0,0 +1,124 @@
   232.4 +/* glpenv04.c (error handling) */
   232.5 +
   232.6 +/***********************************************************************
   232.7 +*  This code is part of GLPK (GNU Linear Programming Kit).
   232.8 +*
   232.9 +*  Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008,
  232.10 +*  2009, 2010, 2011 Andrew Makhorin, Department for Applied Informatics,
  232.11 +*  Moscow Aviation Institute, Moscow, Russia. All rights reserved.
  232.12 +*  E-mail: <mao@gnu.org>.
  232.13 +*
  232.14 +*  GLPK is free software: you can redistribute it and/or modify it
  232.15 +*  under the terms of the GNU General Public License as published by
  232.16 +*  the Free Software Foundation, either version 3 of the License, or
  232.17 +*  (at your option) any later version.
  232.18 +*
  232.19 +*  GLPK is distributed in the hope that it will be useful, but WITHOUT
  232.20 +*  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
  232.21 +*  or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
  232.22 +*  License for more details.
  232.23 +*
  232.24 +*  You should have received a copy of the GNU General Public License
  232.25 +*  along with GLPK. If not, see <http://www.gnu.org/licenses/>.
  232.26 +***********************************************************************/
  232.27 +
  232.28 +#include "glpapi.h"
  232.29 +
  232.30 +/***********************************************************************
  232.31 +*  NAME
  232.32 +*
  232.33 +*  glp_error - display error message and terminate execution
  232.34 +*
  232.35 +*  SYNOPSIS
  232.36 +*
  232.37 +*  void glp_error(const char *fmt, ...);
  232.38 +*
  232.39 +*  DESCRIPTION
  232.40 +*
  232.41 +*  The routine glp_error (implemented as a macro) formats its
  232.42 +*  parameters using the format control string fmt, writes the formatted
  232.43 +*  message to the terminal, and abnormally terminates the program. */
  232.44 +
  232.45 +static void error(const char *fmt, ...)
  232.46 +{     ENV *env = get_env_ptr();
  232.47 +      va_list arg;
  232.48 +      env->term_out = GLP_ON;
  232.49 +      va_start(arg, fmt);
  232.50 +      xvprintf(fmt, arg);
  232.51 +      va_end(arg);
  232.52 +      xprintf("Error detected in file %s at line %d\n", env->err_file,
  232.53 +         env->err_line);
  232.54 +      if (env->err_hook != NULL)
  232.55 +         env->err_hook(env->err_info);
  232.56 +      abort();
  232.57 +      exit(EXIT_FAILURE);
  232.58 +      /* no return */
  232.59 +}
  232.60 +
  232.61 +_glp_error glp_error_(const char *file, int line)
  232.62 +{     ENV *env = get_env_ptr();
  232.63 +      env->err_file = file;
  232.64 +      env->err_line = line;
  232.65 +      return error;
  232.66 +}
  232.67 +
  232.68 +/***********************************************************************
  232.69 +*  NAME
  232.70 +*
  232.71 +*  glp_assert - check for logical condition
  232.72 +*
  232.73 +*  SYNOPSIS
  232.74 +*
  232.75 +*  #include "glplib.h"
  232.76 +*  void glp_assert(int expr);
  232.77 +*
  232.78 +*  DESCRIPTION
  232.79 +*
  232.80 +*  The routine glp_assert (implemented as a macro) checks for a logical
  232.81 +*  condition specified by the parameter expr. If the condition is false
  232.82 +*  (i.e. the value of expr is zero), the routine writes a message to
  232.83 +*  the terminal and abnormally terminates the program. */
  232.84 +
  232.85 +void glp_assert_(const char *expr, const char *file, int line)
  232.86 +{     glp_error_(file, line)("Assertion failed: %s\n", expr);
  232.87 +      /* no return */
  232.88 +}
  232.89 +
  232.90 +/***********************************************************************
  232.91 +*  NAME
  232.92 +*
  232.93 +*  glp_error_hook - install hook to intercept abnormal termination
  232.94 +*
  232.95 +*  SYNOPSIS
  232.96 +*
  232.97 +*  void glp_error_hook(void (*func)(void *info), void *info);
  232.98 +*
  232.99 +*  DESCRIPTION
 232.100 +*
 232.101 +*  The routine glp_error_hook installs a user-defined hook routine to
 232.102 +*  intercept abnormal termination.
 232.103 +*
 232.104 +*  The parameter func specifies the user-defined hook routine. It is
 232.105 +*  called from the routine glp_error before the latter calls the abort
 232.106 +*  function to abnormally terminate the application program because of
 232.107 +*  fatal error. The parameter info is a transit pointer, specified in
 232.108 +*  the corresponding call to the routine glp_error_hook; it may be used
 232.109 +*  to pass some information to the hook routine.
 232.110 +*
 232.111 +*  To uninstall the hook routine the parameters func and info should be
 232.112 +*  specified as NULL. */
 232.113 +
 232.114 +void glp_error_hook(void (*func)(void *info), void *info)
 232.115 +{     ENV *env = get_env_ptr();
 232.116 +      if (func == NULL)
 232.117 +      {  env->err_hook = NULL;
 232.118 +         env->err_info = NULL;
 232.119 +      }
 232.120 +      else
 232.121 +      {  env->err_hook = func;
 232.122 +         env->err_info = info;
 232.123 +      }
 232.124 +      return;
 232.125 +}
 232.126 +
 232.127 +/* eof */
   233.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
   233.2 +++ b/deps/glpk/src/glpenv05.c	Sun Nov 06 20:59:10 2011 +0100
   233.3 @@ -0,0 +1,225 @@
   233.4 +/* glpenv05.c (memory allocation) */
   233.5 +
   233.6 +/***********************************************************************
   233.7 +*  This code is part of GLPK (GNU Linear Programming Kit).
   233.8 +*
   233.9 +*  Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008,
  233.10 +*  2009, 2010, 2011 Andrew Makhorin, Department for Applied Informatics,
  233.11 +*  Moscow Aviation Institute, Moscow, Russia. All rights reserved.
  233.12 +*  E-mail: <mao@gnu.org>.
  233.13 +*
  233.14 +*  GLPK is free software: you can redistribute it and/or modify it
  233.15 +*  under the terms of the GNU General Public License as published by
  233.16 +*  the Free Software Foundation, either version 3 of the License, or
  233.17 +*  (at your option) any later version.
  233.18 +*
  233.19 +*  GLPK is distributed in the hope that it will be useful, but WITHOUT
  233.20 +*  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
  233.21 +*  or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
  233.22 +*  License for more details.
  233.23 +*
  233.24 +*  You should have received a copy of the GNU General Public License
  233.25 +*  along with GLPK. If not, see <http://www.gnu.org/licenses/>.
  233.26 +***********************************************************************/
  233.27 +
  233.28 +#include "glpapi.h"
  233.29 +
  233.30 +/* some processors need data to be properly aligned; the macro
  233.31 +   align_datasize enlarges the specified size of a data item to provide
  233.32 +   a proper alignment of immediately following data */
  233.33 +
  233.34 +#define align_datasize(size) ((((size) + 15) / 16) * 16)
  233.35 +/* 16 bytes is sufficient in both 32- and 64-bit environments
  233.36 +   (8 bytes is not sufficient in 64-bit environment due to jmp_buf) */
  233.37 +
  233.38 +/***********************************************************************
  233.39 +*  NAME
  233.40 +*
  233.41 +*  glp_malloc - allocate memory block
  233.42 +*
  233.43 +*  SYNOPSIS
  233.44 +*
  233.45 +*  void *glp_malloc(int size);
  233.46 +*
  233.47 +*  DESCRIPTION
  233.48 +*
  233.49 +*  The routine glp_malloc allocates a memory block of size bytes long.
  233.50 +*
  233.51 +*  Note that being allocated the memory block contains arbitrary data
  233.52 +*  (not binary zeros).
  233.53 +*
  233.54 +*  RETURNS
  233.55 +*
  233.56 +*  The routine glp_malloc returns a pointer to the allocated block.
  233.57 +*  To free this block the routine glp_free (not free!) must be used. */
  233.58 +
  233.59 +void *glp_malloc(int size)
  233.60 +{     ENV *env = get_env_ptr();
  233.61 +      MEM *desc;
  233.62 +      int size_of_desc = align_datasize(sizeof(MEM));
  233.63 +      if (size < 1 || size > INT_MAX - size_of_desc)
  233.64 +         xerror("glp_malloc: size = %d; invalid parameter\n", size);
  233.65 +      size += size_of_desc;
  233.66 +      if (xlcmp(xlset(size),
  233.67 +          xlsub(env->mem_limit, env->mem_total)) > 0)
  233.68 +         xerror("glp_malloc: memory limit exceeded\n");
  233.69 +      if (env->mem_count == INT_MAX)
  233.70 +         xerror("glp_malloc: too many memory blocks allocated\n");
  233.71 +      desc = malloc(size);
  233.72 +      if (desc == NULL)
  233.73 +         xerror("glp_malloc: no memory available\n");
  233.74 +      memset(desc, '?', size);
  233.75 +      desc->flag = MEM_MAGIC;
  233.76 +      desc->size = size;
  233.77 +      desc->prev = NULL;
  233.78 +      desc->next = env->mem_ptr;
  233.79 +      if (desc->next != NULL) desc->next->prev = desc;
  233.80 +      env->mem_ptr = desc;
  233.81 +      env->mem_count++;
  233.82 +      if (env->mem_cpeak < env->mem_count)
  233.83 +         env->mem_cpeak = env->mem_count;
  233.84 +      env->mem_total = xladd(env->mem_total, xlset(size));
  233.85 +      if (xlcmp(env->mem_tpeak, env->mem_total) < 0)
  233.86 +         env->mem_tpeak = env->mem_total;
  233.87 +      return (void *)((char *)desc + size_of_desc);
  233.88 +}
  233.89 +
  233.90 +/***********************************************************************
  233.91 +*  NAME
  233.92 +*
  233.93 +*  glp_calloc - allocate memory block
  233.94 +*
  233.95 +*  SYNOPSIS
  233.96 +*
  233.97 +*  void *glp_calloc(int n, int size);
  233.98 +*
  233.99 +*  DESCRIPTION
 233.100 +*
 233.101 +*  The routine glp_calloc allocates a memory block of (n*size) bytes
 233.102 +*  long.
 233.103 +*
 233.104 +*  Note that being allocated the memory block contains arbitrary data
 233.105 +*  (not binary zeros).
 233.106 +*
 233.107 +*  RETURNS
 233.108 +*
 233.109 +*  The routine glp_calloc returns a pointer to the allocated block.
 233.110 +*  To free this block the routine glp_free (not free!) must be used. */
 233.111 +
 233.112 +void *glp_calloc(int n, int size)
 233.113 +{     if (n < 1)
 233.114 +         xerror("glp_calloc: n = %d; invalid parameter\n", n);
 233.115 +      if (size < 1)
 233.116 +         xerror("glp_calloc: size = %d; invalid parameter\n", size);
 233.117 +      if (n > INT_MAX / size)
 233.118 +         xerror("glp_calloc: n = %d; size = %d; array too big\n", n,
 233.119 +            size);
 233.120 +      return xmalloc(n * size);
 233.121 +}
 233.122 +
 233.123 +/***********************************************************************
 233.124 +*  NAME
 233.125 +*
 233.126 +*  glp_free - free memory block
 233.127 +*
 233.128 +*  SYNOPSIS
 233.129 +*
 233.130 +*  void glp_free(void *ptr);
 233.131 +*
 233.132 +*  DESCRIPTION
 233.133 +*
 233.134 +*  The routine glp_free frees a memory block pointed to by ptr, which
 233.135 +*  was previuosly allocated by the routine glp_malloc or glp_calloc. */
 233.136 +
 233.137 +void glp_free(void *ptr)
 233.138 +{     ENV *env = get_env_ptr();
 233.139 +      MEM *desc;
 233.140 +      int size_of_desc = align_datasize(sizeof(MEM));
 233.141 +      if (ptr == NULL)
 233.142 +         xerror("glp_free: ptr = %p; null pointer\n", ptr);
 233.143 +      desc = (void *)((char *)ptr - size_of_desc);
 233.144 +      if (desc->flag != MEM_MAGIC)
 233.145 +         xerror("glp_free: ptr = %p; invalid pointer\n", ptr);
 233.146 +      if (env->mem_count == 0 ||
 233.147 +          xlcmp(env->mem_total, xlset(desc->size)) < 0)
 233.148 +         xerror("glp_free: memory allocation error\n");
 233.149 +      if (desc->prev == NULL)
 233.150 +         env->mem_ptr = desc->next;
 233.151 +      else
 233.152 +         desc->prev->next = desc->next;
 233.153 +      if (desc->next == NULL)
 233.154 +         ;
 233.155 +      else
 233.156 +         desc->next->prev = desc->prev;
 233.157 +      env->mem_count--;
 233.158 +      env->mem_total = xlsub(env->mem_total, xlset(desc->size));
 233.159 +      memset(desc, '?', size_of_desc);
 233.160 +      free(desc);
 233.161 +      return;
 233.162 +}
 233.163 +
 233.164 +/***********************************************************************
 233.165 +*  NAME
 233.166 +*
 233.167 +*  glp_mem_limit - set memory usage limit
 233.168 +*
 233.169 +*  SYNOPSIS
 233.170 +*
 233.171 +*  void glp_mem_limit(int limit);
 233.172 +*
 233.173 +*  DESCRIPTION
 233.174 +*
 233.175 +*  The routine glp_mem_limit limits the amount of memory available for
 233.176 +*  dynamic allocation (in GLPK routines) to limit megabytes. */
 233.177 +
 233.178 +void glp_mem_limit(int limit)
 233.179 +{     ENV *env = get_env_ptr();
 233.180 +      if (limit < 0)
 233.181 +         xerror("glp_mem_limit: limit = %d; invalid parameter\n",
 233.182 +            limit);
 233.183 +      env->mem_limit = xlmul(xlset(limit), xlset(1 << 20));
 233.184 +      return;
 233.185 +}
 233.186 +
 233.187 +/***********************************************************************
 233.188 +*  NAME
 233.189 +*
 233.190 +*  glp_mem_usage - get memory usage information
 233.191 +*
 233.192 +*  SYNOPSIS
 233.193 +*
 233.194 +*  void glp_mem_usage(int *count, int *cpeak, glp_long *total,
 233.195 +*     glp_long *tpeak);
 233.196 +*
 233.197 +*  DESCRIPTION
 233.198 +*
 233.199 +*  The routine glp_mem_usage reports some information about utilization
 233.200 +*  of the memory by GLPK routines. Information is stored to locations
 233.201 +*  specified by corresponding parameters (see below). Any parameter can
 233.202 +*  be specified as NULL, in which case corresponding information is not
 233.203 +*  stored.
 233.204 +*
 233.205 +*  *count is the number of the memory blocks currently allocated by the
 233.206 +*  routines xmalloc and xcalloc (one call to xmalloc or xcalloc results
 233.207 +*  in allocating one memory block).
 233.208 +*
 233.209 +*  *cpeak is the peak value of *count reached since the initialization
 233.210 +*  of the GLPK library environment.
 233.211 +*
 233.212 +*  *total is the total amount, in bytes, of the memory blocks currently
 233.213 +*  allocated by the routines xmalloc and xcalloc.
 233.214 +*
 233.215 +*  *tpeak is the peak value of *total reached since the initialization
 233.216 +*  of the GLPK library envirionment. */
 233.217 +
 233.218 +void glp_mem_usage(int *count, int *cpeak, glp_long *total,
 233.219 +      glp_long *tpeak)
 233.220 +{     ENV *env = get_env_ptr();
 233.221 +      if (count != NULL) *count = env->mem_count;
 233.222 +      if (cpeak != NULL) *cpeak = env->mem_cpeak;
 233.223 +      if (total != NULL) *total = env->mem_total;
 233.224 +      if (tpeak != NULL) *tpeak = env->mem_tpeak;
 233.225 +      return;
 233.226 +}
 233.227 +
 233.228 +/* eof */
   234.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
   234.2 +++ b/deps/glpk/src/glpenv06.c	Sun Nov 06 20:59:10 2011 +0100
   234.3 @@ -0,0 +1,172 @@
   234.4 +/* glpenv06.c (standard time) */
   234.5 +
   234.6 +/***********************************************************************
   234.7 +*  This code is part of GLPK (GNU Linear Programming Kit).
   234.8 +*
   234.9 +*  Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008,
  234.10 +*  2009, 2010, 2011 Andrew Makhorin, Department for Applied Informatics,
  234.11 +*  Moscow Aviation Institute, Moscow, Russia. All rights reserved.
  234.12 +*  E-mail: <mao@gnu.org>.
  234.13 +*
  234.14 +*  GLPK is free software: you can redistribute it and/or modify it
  234.15 +*  under the terms of the GNU General Public License as published by
  234.16 +*  the Free Software Foundation, either version 3 of the License, or
  234.17 +*  (at your option) any later version.
  234.18 +*
  234.19 +*  GLPK is distributed in the hope that it will be useful, but WITHOUT
  234.20 +*  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
  234.21 +*  or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
  234.22 +*  License for more details.
  234.23 +*
  234.24 +*  You should have received a copy of the GNU General Public License
  234.25 +*  along with GLPK. If not, see <http://www.gnu.org/licenses/>.
  234.26 +***********************************************************************/
  234.27 +
  234.28 +#ifdef HAVE_CONFIG_H
  234.29 +#include <config.h>
  234.30 +#endif
  234.31 +
  234.32 +#include "glpapi.h"
  234.33 +
  234.34 +/***********************************************************************
  234.35 +*  NAME
  234.36 +*
  234.37 +*  glp_time - determine current universal time
  234.38 +*
  234.39 +*  SYNOPSIS
  234.40 +*
  234.41 +*  glp_long glp_time(void);
  234.42 +*
  234.43 +*  RETURNS
  234.44 +*
  234.45 +*  The routine glp_time returns the current universal time (UTC), in
  234.46 +*  milliseconds, elapsed since 00:00:00 GMT January 1, 1970. */
  234.47 +
  234.48 +static const int epoch = 2440588; /* = jday(1, 1, 1970) */
  234.49 +
  234.50 +/* POSIX version ******************************************************/
  234.51 +
  234.52 +#if defined(HAVE_SYS_TIME_H) && defined(HAVE_GETTIMEOFDAY)
  234.53 +
  234.54 +#include <sys/time.h>
  234.55 +#include <time.h>
  234.56 +
  234.57 +glp_long glp_time(void)
  234.58 +{     struct timeval tv;
  234.59 +      struct tm *tm;
  234.60 +      glp_long t;
  234.61 +      int j;
  234.62 +      gettimeofday(&tv, NULL);
  234.63 +      tm = gmtime(&tv.tv_sec);
  234.64 +      j = jday(tm->tm_mday, tm->tm_mon + 1, 1900 + tm->tm_year);
  234.65 +      xassert(j >= 0);
  234.66 +      t = xlset(j - epoch);
  234.67 +      t = xlmul(t, xlset(24));
  234.68 +      t = xladd(t, xlset(tm->tm_hour));
  234.69 +      t = xlmul(t, xlset(60));
  234.70 +      t = xladd(t, xlset(tm->tm_min));
  234.71 +      t = xlmul(t, xlset(60));
  234.72 +      t = xladd(t, xlset(tm->tm_sec));
  234.73 +      t = xlmul(t, xlset(1000));
  234.74 +      t = xladd(t, xlset(tv.tv_usec / 1000));
  234.75 +      return t;
  234.76 +}
  234.77 +
  234.78 +/* Windows version ****************************************************/
  234.79 +
  234.80 +#elif defined(__WOE__)
  234.81 +
  234.82 +#include <windows.h>
  234.83 +
  234.84 +glp_long glp_time(void)
  234.85 +{     SYSTEMTIME st;
  234.86 +      glp_long t;
  234.87 +      int j;
  234.88 +      GetSystemTime(&st);
  234.89 +      j = jday(st.wDay, st.wMonth, st.wYear);
  234.90 +      xassert(j >= 0);
  234.91 +      t = xlset(j - epoch);
  234.92 +      t = xlmul(t, xlset(24));
  234.93 +      t = xladd(t, xlset(st.wHour));
  234.94 +      t = xlmul(t, xlset(60));
  234.95 +      t = xladd(t, xlset(st.wMinute));
  234.96 +      t = xlmul(t, xlset(60));
  234.97 +      t = xladd(t, xlset(st.wSecond));
  234.98 +      t = xlmul(t, xlset(1000));
  234.99 +      t = xladd(t, xlset(st.wMilliseconds));
 234.100 +      return t;
 234.101 +}
 234.102 +
 234.103 +/* portable ISO C version *********************************************/
 234.104 +
 234.105 +#else
 234.106 +
 234.107 +#include <time.h>
 234.108 +
 234.109 +glp_long glp_time(void)
 234.110 +{     time_t timer;
 234.111 +      struct tm *tm;
 234.112 +      glp_long t;
 234.113 +      int j;
 234.114 +      timer = time(NULL);
 234.115 +      tm = gmtime(&timer);
 234.116 +      j = jday(tm->tm_mday, tm->tm_mon + 1, 1900 + tm->tm_year);
 234.117 +      xassert(j >= 0);
 234.118 +      t = xlset(j - epoch);
 234.119 +      t = xlmul(t, xlset(24));
 234.120 +      t = xladd(t, xlset(tm->tm_hour));
 234.121 +      t = xlmul(t, xlset(60));
 234.122 +      t = xladd(t, xlset(tm->tm_min));
 234.123 +      t = xlmul(t, xlset(60));
 234.124 +      t = xladd(t, xlset(tm->tm_sec));
 234.125 +      t = xlmul(t, xlset(1000));
 234.126 +      return t;
 234.127 +}
 234.128 +
 234.129 +#endif
 234.130 +
 234.131 +/***********************************************************************
 234.132 +*  NAME
 234.133 +*
 234.134 +*  glp_difftime - compute difference between two time values
 234.135 +*
 234.136 +*  SYNOPSIS
 234.137 +*
 234.138 +*  double glp_difftime(glp_long t1, glp_long t0);
 234.139 +*
 234.140 +*  RETURNS
 234.141 +*
 234.142 +*  The routine glp_difftime returns the difference between two time
 234.143 +*  values t1 and t0, expressed in seconds. */
 234.144 +
 234.145 +double glp_difftime(glp_long t1, glp_long t0)
 234.146 +{     return
 234.147 +         xltod(xlsub(t1, t0)) / 1000.0;
 234.148 +}
 234.149 +
 234.150 +/**********************************************************************/
 234.151 +
 234.152 +#if 0
 234.153 +int main(void)
 234.154 +{     glp_long t;
 234.155 +      glp_ldiv d;
 234.156 +      int ttt, ss, mm, hh, day, month, year;
 234.157 +      char s[50];
 234.158 +      t = glp_time();
 234.159 +      xprintf("t = %s\n", xltoa(t, s));
 234.160 +      d = xldiv(t, xlset(1000));
 234.161 +      ttt = d.rem.lo, t = d.quot;
 234.162 +      d = xldiv(t, xlset(60));
 234.163 +      ss = d.rem.lo, t = d.quot;
 234.164 +      d = xldiv(t, xlset(60));
 234.165 +      mm = d.rem.lo, t = d.quot;
 234.166 +      d = xldiv(t, xlset(24));
 234.167 +      hh = d.rem.lo, t = d.quot;
 234.168 +      xassert(jdate(t.lo + epoch, &day, &month, &year) == 0);
 234.169 +      xprintf("%04d-%02d-%02d %02d:%02d:%02d.%03d\n", year, month, day,
 234.170 +         hh, mm, ss, ttt);
 234.171 +      return 0;
 234.172 +}
 234.173 +#endif
 234.174 +
 234.175 +/* eof */
   235.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
   235.2 +++ b/deps/glpk/src/glpenv07.c	Sun Nov 06 20:59:10 2011 +0100
   235.3 @@ -0,0 +1,672 @@
   235.4 +/* glpenv07.c (stream input/output) */
   235.5 +
   235.6 +/***********************************************************************
   235.7 +*  This code is part of GLPK (GNU Linear Programming Kit).
   235.8 +*
   235.9 +*  Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008,
  235.10 +*  2009, 2010, 2011 Andrew Makhorin, Department for Applied Informatics,
  235.11 +*  Moscow Aviation Institute, Moscow, Russia. All rights reserved.
  235.12 +*  E-mail: <mao@gnu.org>.
  235.13 +*
  235.14 +*  GLPK is free software: you can redistribute it and/or modify it
  235.15 +*  under the terms of the GNU General Public License as published by
  235.16 +*  the Free Software Foundation, either version 3 of the License, or
  235.17 +*  (at your option) any later version.
  235.18 +*
  235.19 +*  GLPK is distributed in the hope that it will be useful, but WITHOUT
  235.20 +*  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
  235.21 +*  or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
  235.22 +*  License for more details.
  235.23 +*
  235.24 +*  You should have received a copy of the GNU General Public License
  235.25 +*  along with GLPK. If not, see <http://www.gnu.org/licenses/>.
  235.26 +***********************************************************************/
  235.27 +
  235.28 +#ifdef HAVE_CONFIG_H
  235.29 +#include <config.h>
  235.30 +#endif
  235.31 +
  235.32 +#include "glpenv.h"
  235.33 +
  235.34 +/***********************************************************************
  235.35 +*  NAME
  235.36 +*
  235.37 +*  lib_err_msg - save error message string
  235.38 +*
  235.39 +*  SYNOPSIS
  235.40 +*
  235.41 +*  #include "glpenv.h"
  235.42 +*  void lib_err_msg(const char *msg);
  235.43 +*
  235.44 +*  DESCRIPTION
  235.45 +*
  235.46 +*  The routine lib_err_msg saves an error message string specified by
  235.47 +*  the parameter msg. The message is obtained by some library routines
  235.48 +*  with a call to strerror(errno). */
  235.49 +
  235.50 +void lib_err_msg(const char *msg)
  235.51 +{     ENV *env = get_env_ptr();
  235.52 +      int len = strlen(msg);
  235.53 +      if (len >= IOERR_MSG_SIZE)
  235.54 +         len = IOERR_MSG_SIZE - 1;
  235.55 +      memcpy(env->ioerr_msg, msg, len);
  235.56 +      if (len > 0 && env->ioerr_msg[len-1] == '\n') len--;
  235.57 +      env->ioerr_msg[len] = '\0';
  235.58 +      return;
  235.59 +}
  235.60 +
  235.61 +/***********************************************************************
  235.62 +*  NAME
  235.63 +*
  235.64 +*  xerrmsg - retrieve error message string
  235.65 +*
  235.66 +*  SYNOPSIS
  235.67 +*
  235.68 +*  #include "glpenv.h"
  235.69 +*  const char *xerrmsg(void);
  235.70 +*
  235.71 +*  RETURNS
  235.72 +*
  235.73 +*  The routine xerrmsg returns a pointer to an error message string
  235.74 +*  previously set by some library routine to indicate an error. */
  235.75 +
  235.76 +const char *xerrmsg(void)
  235.77 +{     ENV *env = get_env_ptr();
  235.78 +      return env->ioerr_msg;
  235.79 +}
  235.80 +
  235.81 +/***********************************************************************
  235.82 +*  NAME
  235.83 +*
  235.84 +*  xfopen - open a stream
  235.85 +*
  235.86 +*  SYNOPSIS
  235.87 +*
  235.88 +*  #include "glpenv.h"
  235.89 +*  XFILE *xfopen(const char *fname, const char *mode);
  235.90 +*
  235.91 +*  DESCRIPTION
  235.92 +*
  235.93 +*  The routine xfopen opens the file whose name is a string pointed to
  235.94 +*  by fname and associates a stream with it.
  235.95 +*
  235.96 +*  The parameter mode points to a string, which indicates the open mode
  235.97 +*  and should be one of the following:
  235.98 +*
  235.99 +*  "r"   open text file for reading;
 235.100 +*  "w"   truncate to zero length or create text file for writing;
 235.101 +*  "rb"  open binary file for reading;
 235.102 +*  "wb"  truncate to zero length or create binary file for writing.
 235.103 +*
 235.104 +*  RETURNS
 235.105 +*
 235.106 +*  The routine xfopen returns a pointer to the object controlling the
 235.107 +*  stream. If the open operation fails, xfopen returns NULL. */
 235.108 +
 235.109 +static void *c_fopen(const char *fname, const char *mode);
 235.110 +static void *z_fopen(const char *fname, const char *mode);
 235.111 +
 235.112 +static int is_gz_file(const char *fname)
 235.113 +{     char *ext = strrchr(fname, '.');
 235.114 +      return ext != NULL && strcmp(ext, ".gz") == 0;
 235.115 +}
 235.116 +
 235.117 +XFILE *xfopen(const char *fname, const char *mode)
 235.118 +{     ENV *env = get_env_ptr();
 235.119 +      XFILE *fp;
 235.120 +      int type;
 235.121 +      void *fh;
 235.122 +      if (!is_gz_file(fname))
 235.123 +      {  type = FH_FILE;
 235.124 +         fh = c_fopen(fname, mode);
 235.125 +      }
 235.126 +      else
 235.127 +      {  type = FH_ZLIB;
 235.128 +         fh = z_fopen(fname, mode);
 235.129 +      }
 235.130 +      if (fh == NULL)
 235.131 +      {  fp = NULL;
 235.132 +         goto done;
 235.133 +      }
 235.134 +      fp = xmalloc(sizeof(XFILE));
 235.135 +      fp->type = type;
 235.136 +      fp->fh = fh;
 235.137 +      fp->prev = NULL;
 235.138 +      fp->next = env->file_ptr;
 235.139 +      if (fp->next != NULL) fp->next->prev = fp;
 235.140 +      env->file_ptr = fp;
 235.141 +done: return fp;
 235.142 +}
 235.143 +
 235.144 +/***********************************************************************
 235.145 +*  NAME
 235.146 +*
 235.147 +*  xfgetc - read character from the stream
 235.148 +*
 235.149 +*  SYNOPSIS
 235.150 +*
 235.151 +*  #include "glpenv.h"
 235.152 +*  int xfgetc(XFILE *fp);
 235.153 +*
 235.154 +*  DESCRIPTION
 235.155 +*
 235.156 +*  If the end-of-file indicator for the input stream pointed to by fp
 235.157 +*  is not set and a next character is present, the routine xfgetc
 235.158 +*  obtains that character as an unsigned char converted to an int and
 235.159 +*  advances the associated file position indicator for the stream (if
 235.160 +*  defined).
 235.161 +*
 235.162 +*  RETURNS
 235.163 +*
 235.164 +*  If the end-of-file indicator for the stream is set, or if the
 235.165 +*  stream is at end-of-file, the end-of-file indicator for the stream
 235.166 +*  is set and the routine xfgetc returns XEOF. Otherwise, the routine
 235.167 +*  xfgetc returns the next character from the input stream pointed to
 235.168 +*  by fp. If a read error occurs, the error indicator for the stream is
 235.169 +*  set and the xfgetc routine returns XEOF.
 235.170 +*
 235.171 +*  Note: An end-of-file and a read error can be distinguished by use of
 235.172 +*  the routines xfeof and xferror. */
 235.173 +
 235.174 +static int c_fgetc(void *fh);
 235.175 +static int z_fgetc(void *fh);
 235.176 +
 235.177 +int xfgetc(XFILE *fp)
 235.178 +{     int c;
 235.179 +      switch (fp->type)
 235.180 +      {  case FH_FILE:
 235.181 +            c = c_fgetc(fp->fh);
 235.182 +            break;
 235.183 +         case FH_ZLIB:
 235.184 +            c = z_fgetc(fp->fh);
 235.185 +            break;
 235.186 +         default:
 235.187 +            xassert(fp != fp);
 235.188 +      }
 235.189 +      return c;
 235.190 +}
 235.191 +
 235.192 +/***********************************************************************
 235.193 +*  NAME
 235.194 +*
 235.195 +*  xfputc - write character to the stream
 235.196 +*
 235.197 +*  SYNOPSIS
 235.198 +*
 235.199 +*  #include "glpenv.h"
 235.200 +*  int xfputc(int c, XFILE *fp);
 235.201 +*
 235.202 +*  DESCRIPTION
 235.203 +*
 235.204 +*  The routine xfputc writes the character specified by c (converted
 235.205 +*  to an unsigned char) to the output stream pointed to by fp, at the
 235.206 +*  position indicated by the associated file position indicator (if
 235.207 +*  defined), and advances the indicator appropriately.
 235.208 +*
 235.209 +*  RETURNS
 235.210 +*
 235.211 +*  The routine xfputc returns the character written. If a write error
 235.212 +*  occurs, the error indicator for the stream is set and xfputc returns
 235.213 +*  XEOF. */
 235.214 +
 235.215 +static int c_fputc(int c, void *fh);
 235.216 +static int z_fputc(int c, void *fh);
 235.217 +
 235.218 +int xfputc(int c, XFILE *fp)
 235.219 +{     switch (fp->type)
 235.220 +      {  case FH_FILE:
 235.221 +            c = c_fputc(c, fp->fh);
 235.222 +            break;
 235.223 +         case FH_ZLIB:
 235.224 +            c = z_fputc(c, fp->fh);
 235.225 +            break;
 235.226 +         default:
 235.227 +            xassert(fp != fp);
 235.228 +      }
 235.229 +      return c;
 235.230 +}
 235.231 +
 235.232 +/***********************************************************************
 235.233 +*  NAME
 235.234 +*
 235.235 +*  xferror - test error indicator for the stream
 235.236 +*
 235.237 +*  SYNOPSIS
 235.238 +*
 235.239 +*  #include "glpenv.h"
 235.240 +*  int xferror(XFILE *fp);
 235.241 +*
 235.242 +*  DESCRIPTION
 235.243 +*
 235.244 +*  The routine xferror tests the error indicator for the stream
 235.245 +*  pointed to by fp.
 235.246 +*
 235.247 +*  RETURNS
 235.248 +*
 235.249 +*  The routine xferror returns non-zero if and only if the error
 235.250 +*  indicator is set for the stream. */
 235.251 +
 235.252 +static int c_ferror(void *fh);
 235.253 +static int z_ferror(void *fh);
 235.254 +
 235.255 +int xferror(XFILE *fp)
 235.256 +{     int ret;
 235.257 +      switch (fp->type)
 235.258 +      {  case FH_FILE:
 235.259 +            ret = c_ferror(fp->fh);
 235.260 +            break;
 235.261 +         case FH_ZLIB:
 235.262 +            ret = z_ferror(fp->fh);
 235.263 +            break;
 235.264 +         default:
 235.265 +            xassert(fp != fp);
 235.266 +      }
 235.267 +      return ret;
 235.268 +}
 235.269 +
 235.270 +/***********************************************************************
 235.271 +*  NAME
 235.272 +*
 235.273 +*  xfeof - test end-of-file indicator for the stream
 235.274 +*
 235.275 +*  SYNOPSIS
 235.276 +*
 235.277 +*  #include "glpenv.h"
 235.278 +*  int xfeof(XFILE *fp);
 235.279 +*
 235.280 +*  DESCRIPTION
 235.281 +*
 235.282 +*  The routine xfeof tests the end-of-file indicator for the stream
 235.283 +*  pointed to by fp.
 235.284 +*
 235.285 +*  RETURNS
 235.286 +*
 235.287 +*  The routine xfeof returns non-zero if and only if the end-of-file
 235.288 +*  indicator is set for the stream. */
 235.289 +
 235.290 +static int c_feof(void *fh);
 235.291 +static int z_feof(void *fh);
 235.292 +
 235.293 +int xfeof(XFILE *fp)
 235.294 +{     int ret;
 235.295 +      switch (fp->type)
 235.296 +      {  case FH_FILE:
 235.297 +            ret = c_feof(fp->fh);
 235.298 +            break;
 235.299 +         case FH_ZLIB:
 235.300 +            ret = z_feof(fp->fh);
 235.301 +            break;
 235.302 +         default:
 235.303 +            xassert(fp != fp);
 235.304 +      }
 235.305 +      return ret;
 235.306 +}
 235.307 +
 235.308 +int xfprintf(XFILE *file, const char *fmt, ...)
 235.309 +{     ENV *env = get_env_ptr();
 235.310 +      int cnt, j;
 235.311 +      va_list arg;
 235.312 +      va_start(arg, fmt);
 235.313 +      cnt = vsprintf(env->term_buf, fmt, arg);
 235.314 +      va_end(arg);
 235.315 +      for (j = 0; j < cnt; j++)
 235.316 +      {  if (xfputc(env->term_buf[j], file) < 0)
 235.317 +         {  cnt = -1;
 235.318 +            break;
 235.319 +         }
 235.320 +      }
 235.321 +      return cnt;
 235.322 +}
 235.323 +
 235.324 +/***********************************************************************
 235.325 +*  NAME
 235.326 +*
 235.327 +*  xfflush - flush the stream
 235.328 +*
 235.329 +*  SYNOPSIS
 235.330 +*
 235.331 +*  #include "glpenv.h"
 235.332 +*  int xfflush(XFILE *fp);
 235.333 +*
 235.334 +*  DESCRIPTION
 235.335 +*
 235.336 +*  The routine xfflush causes any unwritten data for the output stream
 235.337 +*  pointed to by fp to be written to the associated file.
 235.338 +*
 235.339 +*  RETURNS
 235.340 +*
 235.341 +*  The routine xfflush returns zero if the stream was successfully
 235.342 +*  flushed. Otherwise, xfflush sets the error indicator for the stream
 235.343 +*  and returns XEOF. */
 235.344 +
 235.345 +static int c_fflush(void *fh);
 235.346 +static int z_fflush(void *fh);
 235.347 +
 235.348 +int xfflush(XFILE *fp)
 235.349 +{     int ret;
 235.350 +      switch (fp->type)
 235.351 +      {  case FH_FILE:
 235.352 +            ret = c_fflush(fp->fh);
 235.353 +            break;
 235.354 +         case FH_ZLIB:
 235.355 +            ret = z_fflush(fp->fh);
 235.356 +            break;
 235.357 +         default:
 235.358 +            xassert(fp != fp);
 235.359 +      }
 235.360 +      return ret;
 235.361 +}
 235.362 +
 235.363 +/***********************************************************************
 235.364 +*  NAME
 235.365 +*
 235.366 +*  xfclose - close the stream
 235.367 +*
 235.368 +*  SYNOPSIS
 235.369 +*
 235.370 +*  #include "glpenv.h"
 235.371 +*  int xfclose(XFILE *fp);
 235.372 +*
 235.373 +*  DESCRIPTION
 235.374 +*
 235.375 +*  A successful call to the routine xfclose causes the stream pointed
 235.376 +*  to by fp to be flushed and the associated file to be closed. Whether
 235.377 +*  or not the call succeeds, the stream is disassociated from the file.
 235.378 +*
 235.379 +*  RETURNS
 235.380 +*
 235.381 +*  The routine xfclose returns zero if the stream was successfully
 235.382 +*  closed, or XEOF if any errors were detected. */
 235.383 +
 235.384 +static int c_fclose(void *fh);
 235.385 +static int z_fclose(void *fh);
 235.386 +
 235.387 +int xfclose(XFILE *fp)
 235.388 +{     ENV *env = get_env_ptr();
 235.389 +      int ret;
 235.390 +      switch (fp->type)
 235.391 +      {  case FH_FILE:
 235.392 +            ret = c_fclose(fp->fh);
 235.393 +            break;
 235.394 +         case FH_ZLIB:
 235.395 +            ret = z_fclose(fp->fh);
 235.396 +            break;
 235.397 +         default:
 235.398 +            xassert(fp != fp);
 235.399 +      }
 235.400 +      fp->type = 0xF00BAD;
 235.401 +      if (fp->prev == NULL)
 235.402 +         env->file_ptr = fp->next;
 235.403 +      else
 235.404 +         fp->prev->next = fp->next;
 235.405 +      if (fp->next == NULL)
 235.406 +         ;
 235.407 +      else
 235.408 +         fp->next->prev = fp->prev;
 235.409 +      xfree(fp);
 235.410 +      return ret;
 235.411 +}
 235.412 +
 235.413 +/***********************************************************************
 235.414 +*  The following routines implement stream input/output based on the
 235.415 +*  standard C streams. */
 235.416 +
 235.417 +static void *c_fopen(const char *fname, const char *mode)
 235.418 +{     FILE *fh;
 235.419 +      if (strcmp(fname, "/dev/stdin") == 0)
 235.420 +         fh = stdin;
 235.421 +      else if (strcmp(fname, "/dev/stdout") == 0)
 235.422 +         fh = stdout;
 235.423 +      else if (strcmp(fname, "/dev/stderr") == 0)
 235.424 +         fh = stderr;
 235.425 +      else
 235.426 +         fh = fopen(fname, mode);
 235.427 +      if (fh == NULL)
 235.428 +         lib_err_msg(strerror(errno));
 235.429 +      return fh;
 235.430 +}
 235.431 +
 235.432 +static int c_fgetc(void *_fh)
 235.433 +{     FILE *fh = _fh;
 235.434 +      int c;
 235.435 +      if (ferror(fh) || feof(fh))
 235.436 +      {  c = XEOF;
 235.437 +         goto done;
 235.438 +      }
 235.439 +      c = fgetc(fh);
 235.440 +      if (ferror(fh))
 235.441 +      {  lib_err_msg(strerror(errno));
 235.442 +         c = XEOF;
 235.443 +      }
 235.444 +      else if (feof(fh))
 235.445 +         c = XEOF;
 235.446 +      else
 235.447 +         xassert(0x00 <= c && c <= 0xFF);
 235.448 +done: return c;
 235.449 +}
 235.450 +
 235.451 +static int c_fputc(int c, void *_fh)
 235.452 +{     FILE *fh = _fh;
 235.453 +      if (ferror(fh))
 235.454 +      {  c = XEOF;
 235.455 +         goto done;
 235.456 +      }
 235.457 +      c = (unsigned char)c;
 235.458 +      fputc(c, fh);
 235.459 +      if (ferror(fh))
 235.460 +      {  lib_err_msg(strerror(errno));
 235.461 +         c = XEOF;
 235.462 +      }
 235.463 +done: return c;
 235.464 +}
 235.465 +
 235.466 +static int c_ferror(void *_fh)
 235.467 +{     FILE *fh = _fh;
 235.468 +      return ferror(fh);
 235.469 +}
 235.470 +
 235.471 +static int c_feof(void *_fh)
 235.472 +{     FILE *fh = _fh;
 235.473 +      return feof(fh);
 235.474 +}
 235.475 +
 235.476 +static int c_fflush(void *_fh)
 235.477 +{     FILE *fh = _fh;
 235.478 +      int ret;
 235.479 +      ret = fflush(fh);
 235.480 +      if (ret != 0)
 235.481 +      {  lib_err_msg(strerror(errno));
 235.482 +         ret = XEOF;
 235.483 +      }
 235.484 +      return ret;
 235.485 +}
 235.486 +
 235.487 +static int c_fclose(void *_fh)
 235.488 +{     FILE *fh = _fh;
 235.489 +      int ret;
 235.490 +      if (fh == stdin)
 235.491 +         ret = 0;
 235.492 +      else if (fh == stdout || fh == stderr)
 235.493 +         fflush(fh), ret = 0;
 235.494 +      else
 235.495 +         ret = fclose(fh);
 235.496 +      if (ret != 0)
 235.497 +      {  lib_err_msg(strerror(errno));
 235.498 +         ret = XEOF;
 235.499 +      }
 235.500 +      return ret;
 235.501 +}
 235.502 +
 235.503 +/***********************************************************************
 235.504 +*  The following routines implement stream input/output based on the
 235.505 +*  zlib library, which provides processing .gz files "on the fly". */
 235.506 +
 235.507 +/*#ifndef HAVE_ZLIB*/
 235.508 +#if 0 /* 27/IV-2011 */
 235.509 +
 235.510 +static void *z_fopen(const char *fname, const char *mode)
 235.511 +{     xassert(fname == fname);
 235.512 +      xassert(mode == mode);
 235.513 +      lib_err_msg("Compressed files not supported");
 235.514 +      return NULL;
 235.515 +}
 235.516 +
 235.517 +static int z_fgetc(void *fh)
 235.518 +{     xassert(fh != fh);
 235.519 +      return 0;
 235.520 +}
 235.521 +
 235.522 +static int z_fputc(int c, void *fh)
 235.523 +{     xassert(c != c);
 235.524 +      xassert(fh != fh);
 235.525 +      return 0;
 235.526 +}
 235.527 +
 235.528 +static int z_ferror(void *fh)
 235.529 +{     xassert(fh != fh);
 235.530 +      return 0;
 235.531 +}
 235.532 +
 235.533 +static int z_feof(void *fh)
 235.534 +{     xassert(fh != fh);
 235.535 +      return 0;
 235.536 +}
 235.537 +
 235.538 +static int z_fflush(void *fh)
 235.539 +{     xassert(fh != fh);
 235.540 +      return 0;
 235.541 +}
 235.542 +
 235.543 +static int z_fclose(void *fh)
 235.544 +{     xassert(fh != fh);
 235.545 +      return 0;
 235.546 +}
 235.547 +
 235.548 +#else
 235.549 +
 235.550 +#include "zlib/zlib.h"
 235.551 +
 235.552 +struct z_file
 235.553 +{     /* .gz file handle */
 235.554 +      gzFile file;
 235.555 +      /* pointer to .gz stream */
 235.556 +      int err;
 235.557 +      /* i/o error indicator */
 235.558 +      int eof;
 235.559 +      /* end-of-file indicator */
 235.560 +};
 235.561 +
 235.562 +static void *z_fopen(const char *fname, const char *mode)
 235.563 +{     struct z_file *fh;
 235.564 +      gzFile file;
 235.565 +      if (strcmp(mode, "r") == 0 || strcmp(mode, "rb") == 0)
 235.566 +         mode = "rb";
 235.567 +      else if (strcmp(mode, "w") == 0 || strcmp(mode, "wb") == 0)
 235.568 +         mode = "wb";
 235.569 +      else
 235.570 +      {  lib_err_msg("Invalid open mode");
 235.571 +         fh = NULL;
 235.572 +         goto done;
 235.573 +      }
 235.574 +      file = gzopen(fname, mode);
 235.575 +      if (file == NULL)
 235.576 +      {  lib_err_msg(strerror(errno));
 235.577 +         fh = NULL;
 235.578 +         goto done;
 235.579 +      }
 235.580 +      fh = xmalloc(sizeof(struct z_file));
 235.581 +      fh->file = file;
 235.582 +      fh->err = fh->eof = 0;
 235.583 +done: return fh;
 235.584 +}
 235.585 +
 235.586 +static int z_fgetc(void *_fh)
 235.587 +{     struct z_file *fh = _fh;
 235.588 +      int c;
 235.589 +      if (fh->err || fh->eof)
 235.590 +      {  c = XEOF;
 235.591 +         goto done;
 235.592 +      }
 235.593 +      c = gzgetc(fh->file);
 235.594 +      if (c < 0)
 235.595 +      {  int errnum;
 235.596 +         const char *msg;
 235.597 +         msg = gzerror(fh->file, &errnum);
 235.598 +         if (errnum == Z_STREAM_END)
 235.599 +            fh->eof = 1;
 235.600 +         else if (errnum == Z_ERRNO)
 235.601 +         {  fh->err = 1;
 235.602 +            lib_err_msg(strerror(errno));
 235.603 +         }
 235.604 +         else
 235.605 +         {  fh->err = 1;
 235.606 +            lib_err_msg(msg);
 235.607 +         }
 235.608 +         c = XEOF;
 235.609 +      }
 235.610 +      else
 235.611 +         xassert(0x00 <= c && c <= 0xFF);
 235.612 +done: return c;
 235.613 +}
 235.614 +
 235.615 +static int z_fputc(int c, void *_fh)
 235.616 +{     struct z_file *fh = _fh;
 235.617 +      if (fh->err)
 235.618 +      {  c = XEOF;
 235.619 +         goto done;
 235.620 +      }
 235.621 +      c = (unsigned char)c;
 235.622 +      if (gzputc(fh->file, c) < 0)
 235.623 +      {  int errnum;
 235.624 +         const char *msg;
 235.625 +         fh->err = 1;
 235.626 +         msg = gzerror(fh->file, &errnum);
 235.627 +         if (errnum == Z_ERRNO)
 235.628 +            lib_err_msg(strerror(errno));
 235.629 +         else
 235.630 +            lib_err_msg(msg);
 235.631 +         c = XEOF;
 235.632 +      }
 235.633 +done: return c;
 235.634 +}
 235.635 +
 235.636 +static int z_ferror(void *_fh)
 235.637 +{     struct z_file *fh = _fh;
 235.638 +      return fh->err;
 235.639 +}
 235.640 +
 235.641 +static int z_feof(void *_fh)
 235.642 +{     struct z_file *fh = _fh;
 235.643 +      return fh->eof;
 235.644 +}
 235.645 +
 235.646 +static int z_fflush(void *_fh)
 235.647 +{     struct z_file *fh = _fh;
 235.648 +      int ret;
 235.649 +      ret = gzflush(fh->file, Z_FINISH);
 235.650 +      if (ret == Z_OK)
 235.651 +         ret = 0;
 235.652 +      else
 235.653 +      {  int errnum;
 235.654 +         const char *msg;
 235.655 +         fh->err = 1;
 235.656 +         msg = gzerror(fh->file, &errnum);
 235.657 +         if (errnum == Z_ERRNO)
 235.658 +            lib_err_msg(strerror(errno));
 235.659 +         else
 235.660 +            lib_err_msg(msg);
 235.661 +         ret = XEOF;
 235.662 +      }
 235.663 +      return ret;
 235.664 +}
 235.665 +
 235.666 +static int z_fclose(void *_fh)
 235.667 +{     struct z_file *fh = _fh;
 235.668 +      gzclose(fh->file);
 235.669 +      xfree(fh);
 235.670 +      return 0;
 235.671 +}
 235.672 +
 235.673 +#endif
 235.674 +
 235.675 +/* eof */
   236.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
   236.2 +++ b/deps/glpk/src/glpenv08.c	Sun Nov 06 20:59:10 2011 +0100
   236.3 @@ -0,0 +1,156 @@
   236.4 +/* glpenv08.c (shared library support) */
   236.5 +
   236.6 +/***********************************************************************
   236.7 +*  This code is part of GLPK (GNU Linear Programming Kit).
   236.8 +*
   236.9 +*  Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008,
  236.10 +*  2009, 2010, 2011 Andrew Makhorin, Department for Applied Informatics,
  236.11 +*  Moscow Aviation Institute, Moscow, Russia. All rights reserved.
  236.12 +*  E-mail: <mao@gnu.org>.
  236.13 +*
  236.14 +*  GLPK is free software: you can redistribute it and/or modify it
  236.15 +*  under the terms of the GNU General Public License as published by
  236.16 +*  the Free Software Foundation, either version 3 of the License, or
  236.17 +*  (at your option) any later version.
  236.18 +*
  236.19 +*  GLPK is distributed in the hope that it will be useful, but WITHOUT
  236.20 +*  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
  236.21 +*  or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
  236.22 +*  License for more details.
  236.23 +*
  236.24 +*  You should have received a copy of the GNU General Public License
  236.25 +*  along with GLPK. If not, see <http://www.gnu.org/licenses/>.
  236.26 +***********************************************************************/
  236.27 +
  236.28 +#ifdef HAVE_CONFIG_H
  236.29 +#include <config.h>
  236.30 +#endif
  236.31 +
  236.32 +#include "glpenv.h"
  236.33 +
  236.34 +/* GNU version ********************************************************/
  236.35 +
  236.36 +#if defined(HAVE_LTDL)
  236.37 +
  236.38 +#include <ltdl.h>
  236.39 +
  236.40 +void *xdlopen(const char *module)
  236.41 +{     void *h = NULL;
  236.42 +      if (lt_dlinit() != 0)
  236.43 +      {  lib_err_msg(lt_dlerror());
  236.44 +         goto done;
  236.45 +      }
  236.46 +      h = lt_dlopen(module);
  236.47 +      if (h == NULL)
  236.48 +      {  lib_err_msg(lt_dlerror());
  236.49 +         if (lt_dlexit() != 0)
  236.50 +            xerror("xdlopen: %s\n", lt_dlerror());
  236.51 +      }
  236.52 +done: return h;
  236.53 +}
  236.54 +
  236.55 +void *xdlsym(void *h, const char *symbol)
  236.56 +{     void *ptr;
  236.57 +      xassert(h != NULL);
  236.58 +      ptr = lt_dlsym(h, symbol);
  236.59 +      if (ptr == NULL)
  236.60 +         xerror("xdlsym: %s: %s\n", symbol, lt_dlerror());
  236.61 +      return ptr;
  236.62 +}
  236.63 +
  236.64 +void xdlclose(void *h)
  236.65 +{     xassert(h != NULL);
  236.66 +      if (lt_dlclose(h) != 0)
  236.67 +         xerror("xdlclose: %s\n", lt_dlerror());
  236.68 +      if (lt_dlexit() != 0)
  236.69 +         xerror("xdlclose: %s\n", lt_dlerror());
  236.70 +      return;
  236.71 +}
  236.72 +
  236.73 +/* POSIX version ******************************************************/
  236.74 +
  236.75 +#elif defined(HAVE_DLFCN)
  236.76 +
  236.77 +#include <dlfcn.h>
  236.78 +
  236.79 +void *xdlopen(const char *module)
  236.80 +{     void *h;
  236.81 +      h = dlopen(module, RTLD_NOW);
  236.82 +      if (h == NULL)
  236.83 +         lib_err_msg(dlerror());
  236.84 +      return h;
  236.85 +}
  236.86 +
  236.87 +void *xdlsym(void *h, const char *symbol)
  236.88 +{     void *ptr;
  236.89 +      xassert(h != NULL);
  236.90 +      ptr = dlsym(h, symbol);
  236.91 +      if (ptr == NULL)
  236.92 +         xerror("xdlsym: %s: %s\n", symbol, dlerror());
  236.93 +      return ptr;
  236.94 +}
  236.95 +
  236.96 +void xdlclose(void *h)
  236.97 +{     xassert(h != NULL);
  236.98 +      if (dlclose(h) != 0)
  236.99 +         xerror("xdlclose: %s\n", dlerror());
 236.100 +      return;
 236.101 +}
 236.102 +
 236.103 +/* Windows version ****************************************************/
 236.104 +
 236.105 +#elif defined(__WOE__)
 236.106 +
 236.107 +#include <windows.h>
 236.108 +
 236.109 +void *xdlopen(const char *module)
 236.110 +{     void *h;
 236.111 +      h = LoadLibrary(module);
 236.112 +      if (h == NULL)
 236.113 +      {  char msg[20];
 236.114 +         sprintf(msg, "Error %d", GetLastError());
 236.115 +         lib_err_msg(msg);
 236.116 +      }
 236.117 +      return h;
 236.118 +}
 236.119 +
 236.120 +void *xdlsym(void *h, const char *symbol)
 236.121 +{     void *ptr;
 236.122 +      xassert(h != NULL);
 236.123 +      ptr = GetProcAddress(h, symbol);
 236.124 +      if (ptr == NULL)
 236.125 +         xerror("xdlsym: %s: Error %d\n", symbol, GetLastError());
 236.126 +      return ptr;
 236.127 +}
 236.128 +
 236.129 +void xdlclose(void *h)
 236.130 +{     xassert(h != NULL);
 236.131 +      if (!FreeLibrary(h))
 236.132 +         xerror("xdlclose: Error %d\n", GetLastError());
 236.133 +      return;
 236.134 +}
 236.135 +
 236.136 +/* NULL version *******************************************************/
 236.137 +
 236.138 +#else
 236.139 +
 236.140 +void *xdlopen(const char *module)
 236.141 +{     xassert(module == module);
 236.142 +      lib_err_msg("Shared libraries not supported");
 236.143 +      return NULL;
 236.144 +}
 236.145 +
 236.146 +void *xdlsym(void *h, const char *symbol)
 236.147 +{     xassert(h != h);
 236.148 +      xassert(symbol != symbol);
 236.149 +      return NULL;
 236.150 +}
 236.151 +
 236.152 +void xdlclose(void *h)
 236.153 +{     xassert(h != h);
 236.154 +      return;
 236.155 +}
 236.156 +
 236.157 +#endif
 236.158 +
 236.159 +/* eof */
   237.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
   237.2 +++ b/deps/glpk/src/glpfhv.c	Sun Nov 06 20:59:10 2011 +0100
   237.3 @@ -0,0 +1,774 @@
   237.4 +/* glpfhv.c (LP basis factorization, FHV eta file version) */
   237.5 +
   237.6 +/***********************************************************************
   237.7 +*  This code is part of GLPK (GNU Linear Programming Kit).
   237.8 +*
   237.9 +*  Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008,
  237.10 +*  2009, 2010, 2011 Andrew Makhorin, Department for Applied Informatics,
  237.11 +*  Moscow Aviation Institute, Moscow, Russia. All rights reserved.
  237.12 +*  E-mail: <mao@gnu.org>.
  237.13 +*
  237.14 +*  GLPK is free software: you can redistribute it and/or modify it
  237.15 +*  under the terms of the GNU General Public License as published by
  237.16 +*  the Free Software Foundation, either version 3 of the License, or
  237.17 +*  (at your option) any later version.
  237.18 +*
  237.19 +*  GLPK is distributed in the hope that it will be useful, but WITHOUT
  237.20 +*  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
  237.21 +*  or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
  237.22 +*  License for more details.
  237.23 +*
  237.24 +*  You should have received a copy of the GNU General Public License
  237.25 +*  along with GLPK. If not, see <http://www.gnu.org/licenses/>.
  237.26 +***********************************************************************/
  237.27 +
  237.28 +#include "glpfhv.h"
  237.29 +#include "glpenv.h"
  237.30 +#define xfault xerror
  237.31 +
  237.32 +/* CAUTION: DO NOT CHANGE THE LIMIT BELOW */
  237.33 +
  237.34 +#define M_MAX 100000000 /* = 100*10^6 */
  237.35 +/* maximal order of the basis matrix */
  237.36 +
  237.37 +/***********************************************************************
  237.38 +*  NAME
  237.39 +*
  237.40 +*  fhv_create_it - create LP basis factorization
  237.41 +*
  237.42 +*  SYNOPSIS
  237.43 +*
  237.44 +*  #include "glpfhv.h"
  237.45 +*  FHV *fhv_create_it(void);
  237.46 +*
  237.47 +*  DESCRIPTION
  237.48 +*
  237.49 +*  The routine fhv_create_it creates a program object, which represents
  237.50 +*  a factorization of LP basis.
  237.51 +*
  237.52 +*  RETURNS
  237.53 +*
  237.54 +*  The routine fhv_create_it returns a pointer to the object created. */
  237.55 +
  237.56 +FHV *fhv_create_it(void)
  237.57 +{     FHV *fhv;
  237.58 +      fhv = xmalloc(sizeof(FHV));
  237.59 +      fhv->m_max = fhv->m = 0;
  237.60 +      fhv->valid = 0;
  237.61 +      fhv->luf = luf_create_it();
  237.62 +      fhv->hh_max = 50;
  237.63 +      fhv->hh_nfs = 0;
  237.64 +      fhv->hh_ind = fhv->hh_ptr = fhv->hh_len = NULL;
  237.65 +      fhv->p0_row = fhv->p0_col = NULL;
  237.66 +      fhv->cc_ind = NULL;
  237.67 +      fhv->cc_val = NULL;
  237.68 +      fhv->upd_tol = 1e-6;
  237.69 +      fhv->nnz_h = 0;
  237.70 +      return fhv;
  237.71 +}
  237.72 +
  237.73 +/***********************************************************************
  237.74 +*  NAME
  237.75 +*
  237.76 +*  fhv_factorize - compute LP basis factorization
  237.77 +*
  237.78 +*  SYNOPSIS
  237.79 +*
  237.80 +*  #include "glpfhv.h"
  237.81 +*  int fhv_factorize(FHV *fhv, int m, int (*col)(void *info, int j,
  237.82 +*     int ind[], double val[]), void *info);
  237.83 +*
  237.84 +*  DESCRIPTION
  237.85 +*
  237.86 +*  The routine fhv_factorize computes the factorization of the basis
  237.87 +*  matrix B specified by the routine col.
  237.88 +*
  237.89 +*  The parameter fhv specified the basis factorization data structure
  237.90 +*  created by the routine fhv_create_it.
  237.91 +*
  237.92 +*  The parameter m specifies the order of B, m > 0.
  237.93 +*
  237.94 +*  The formal routine col specifies the matrix B to be factorized. To
  237.95 +*  obtain j-th column of A the routine fhv_factorize calls the routine
  237.96 +*  col with the parameter j (1 <= j <= n). In response the routine col
  237.97 +*  should store row indices and numerical values of non-zero elements
  237.98 +*  of j-th column of B to locations ind[1,...,len] and val[1,...,len],
  237.99 +*  respectively, where len is the number of non-zeros in j-th column
 237.100 +*  returned on exit. Neither zero nor duplicate elements are allowed.
 237.101 +*
 237.102 +*  The parameter info is a transit pointer passed to the routine col.
 237.103 +*
 237.104 +*  RETURNS
 237.105 +*
 237.106 +*  0  The factorization has been successfully computed.
 237.107 +*
 237.108 +*  FHV_ESING
 237.109 +*     The specified matrix is singular within the working precision.
 237.110 +*
 237.111 +*  FHV_ECOND
 237.112 +*     The specified matrix is ill-conditioned.
 237.113 +*
 237.114 +*  For more details see comments to the routine luf_factorize.
 237.115 +*
 237.116 +*  ALGORITHM
 237.117 +*
 237.118 +*  The routine fhv_factorize calls the routine luf_factorize (see the
 237.119 +*  module GLPLUF), which actually computes LU-factorization of the basis
 237.120 +*  matrix B in the form
 237.121 +*
 237.122 +*     [B] = (F, V, P, Q),
 237.123 +*
 237.124 +*  where F and V are such matrices that
 237.125 +*
 237.126 +*     B = F * V,
 237.127 +*
 237.128 +*  and P and Q are such permutation matrices that the matrix
 237.129 +*
 237.130 +*     L = P * F * inv(P)
 237.131 +*
 237.132 +*  is lower triangular with unity diagonal, and the matrix
 237.133 +*
 237.134 +*     U = P * V * Q
 237.135 +*
 237.136 +*  is upper triangular.
 237.137 +*
 237.138 +*  In order to build the complete representation of the factorization
 237.139 +*  (see formula (1) in the file glpfhv.h) the routine fhv_factorize just
 237.140 +*  additionally sets H = I and P0 = P. */
 237.141 +
 237.142 +int fhv_factorize(FHV *fhv, int m, int (*col)(void *info, int j,
 237.143 +      int ind[], double val[]), void *info)
 237.144 +{     int ret;
 237.145 +      if (m < 1)
 237.146 +         xfault("fhv_factorize: m = %d; invalid parameter\n", m);
 237.147 +      if (m > M_MAX)
 237.148 +         xfault("fhv_factorize: m = %d; matrix too big\n", m);
 237.149 +      fhv->m = m;
 237.150 +      /* invalidate the factorization */
 237.151 +      fhv->valid = 0;
 237.152 +      /* allocate/reallocate arrays, if necessary */
 237.153 +      if (fhv->hh_ind == NULL)
 237.154 +         fhv->hh_ind = xcalloc(1+fhv->hh_max, sizeof(int));
 237.155 +      if (fhv->hh_ptr == NULL)
 237.156 +         fhv->hh_ptr = xcalloc(1+fhv->hh_max, sizeof(int));
 237.157 +      if (fhv->hh_len == NULL)
 237.158 +         fhv->hh_len = xcalloc(1+fhv->hh_max, sizeof(int));
 237.159 +      if (fhv->m_max < m)
 237.160 +      {  if (fhv->p0_row != NULL) xfree(fhv->p0_row);
 237.161 +         if (fhv->p0_col != NULL) xfree(fhv->p0_col);
 237.162 +         if (fhv->cc_ind != NULL) xfree(fhv->cc_ind);
 237.163 +         if (fhv->cc_val != NULL) xfree(fhv->cc_val);
 237.164 +         fhv->m_max = m + 100;
 237.165 +         fhv->p0_row = xcalloc(1+fhv->m_max, sizeof(int));
 237.166 +         fhv->p0_col = xcalloc(1+fhv->m_max, sizeof(int));
 237.167 +         fhv->cc_ind = xcalloc(1+fhv->m_max, sizeof(int));
 237.168 +         fhv->cc_val = xcalloc(1+fhv->m_max, sizeof(double));
 237.169 +      }
 237.170 +      /* try to factorize the basis matrix */
 237.171 +      switch (luf_factorize(fhv->luf, m, col, info))
 237.172 +      {  case 0:
 237.173 +            break;
 237.174 +         case LUF_ESING:
 237.175 +            ret = FHV_ESING;
 237.176 +            goto done;
 237.177 +         case LUF_ECOND:
 237.178 +            ret = FHV_ECOND;
 237.179 +            goto done;
 237.180 +         default:
 237.181 +            xassert(fhv != fhv);
 237.182 +      }
 237.183 +      /* the basis matrix has been successfully factorized */
 237.184 +      fhv->valid = 1;
 237.185 +      /* H := I */
 237.186 +      fhv->hh_nfs = 0;
 237.187 +      /* P0 := P */
 237.188 +      memcpy(&fhv->p0_row[1], &fhv->luf->pp_row[1], sizeof(int) * m);
 237.189 +      memcpy(&fhv->p0_col[1], &fhv->luf->pp_col[1], sizeof(int) * m);
 237.190 +      /* currently H has no factors */
 237.191 +      fhv->nnz_h = 0;
 237.192 +      ret = 0;
 237.193 +done: /* return to the calling program */
 237.194 +      return ret;
 237.195 +}
 237.196 +
 237.197 +/***********************************************************************
 237.198 +*  NAME
 237.199 +*
 237.200 +*  fhv_h_solve - solve system H*x = b or H'*x = b
 237.201 +*
 237.202 +*  SYNOPSIS
 237.203 +*
 237.204 +*  #include "glpfhv.h"
 237.205 +*  void fhv_h_solve(FHV *fhv, int tr, double x[]);
 237.206 +*
 237.207 +*  DESCRIPTION
 237.208 +*
 237.209 +*  The routine fhv_h_solve solves either the system H*x = b (if the
 237.210 +*  flag tr is zero) or the system H'*x = b (if the flag tr is non-zero),
 237.211 +*  where the matrix H is a component of the factorization specified by
 237.212 +*  the parameter fhv, H' is a matrix transposed to H.
 237.213 +*
 237.214 +*  On entry the array x should contain elements of the right-hand side
 237.215 +*  vector b in locations x[1], ..., x[m], where m is the order of the
 237.216 +*  matrix H. On exit this array will contain elements of the solution
 237.217 +*  vector x in the same locations. */
 237.218 +
 237.219 +void fhv_h_solve(FHV *fhv, int tr, double x[])
 237.220 +{     int nfs = fhv->hh_nfs;
 237.221 +      int *hh_ind = fhv->hh_ind;
 237.222 +      int *hh_ptr = fhv->hh_ptr;
 237.223 +      int *hh_len = fhv->hh_len;
 237.224 +      int *sv_ind = fhv->luf->sv_ind;
 237.225 +      double *sv_val = fhv->luf->sv_val;
 237.226 +      int i, k, beg, end, ptr;
 237.227 +      double temp;
 237.228 +      if (!fhv->valid)
 237.229 +         xfault("fhv_h_solve: the factorization is not valid\n");
 237.230 +      if (!tr)
 237.231 +      {  /* solve the system H*x = b */
 237.232 +         for (k = 1; k <= nfs; k++)
 237.233 +         {  i = hh_ind[k];
 237.234 +            temp = x[i];
 237.235 +            beg = hh_ptr[k];
 237.236 +            end = beg + hh_len[k] - 1;
 237.237 +            for (ptr = beg; ptr <= end; ptr++)
 237.238 +               temp -= sv_val[ptr] * x[sv_ind[ptr]];
 237.239 +            x[i] = temp;
 237.240 +         }
 237.241 +      }
 237.242 +      else
 237.243 +      {  /* solve the system H'*x = b */
 237.244 +         for (k = nfs; k >= 1; k--)
 237.245 +         {  i = hh_ind[k];
 237.246 +            temp = x[i];
 237.247 +            if (temp == 0.0) continue;
 237.248 +            beg = hh_ptr[k];
 237.249 +            end = beg + hh_len[k] - 1;
 237.250 +            for (ptr = beg; ptr <= end; ptr++)
 237.251 +               x[sv_ind[ptr]] -= sv_val[ptr] * temp;
 237.252 +         }
 237.253 +      }
 237.254 +      return;
 237.255 +}
 237.256 +
 237.257 +/***********************************************************************
 237.258 +*  NAME
 237.259 +*
 237.260 +*  fhv_ftran - perform forward transformation (solve system B*x = b)
 237.261 +*
 237.262 +*  SYNOPSIS
 237.263 +*
 237.264 +*  #include "glpfhv.h"
 237.265 +*  void fhv_ftran(FHV *fhv, double x[]);
 237.266 +*
 237.267 +*  DESCRIPTION
 237.268 +*
 237.269 +*  The routine fhv_ftran performs forward transformation, i.e. solves
 237.270 +*  the system B*x = b, where B is the basis matrix, x is the vector of
 237.271 +*  unknowns to be computed, b is the vector of right-hand sides.
 237.272 +*
 237.273 +*  On entry elements of the vector b should be stored in dense format
 237.274 +*  in locations x[1], ..., x[m], where m is the number of rows. On exit
 237.275 +*  the routine stores elements of the vector x in the same locations. */
 237.276 +
 237.277 +void fhv_ftran(FHV *fhv, double x[])
 237.278 +{     int *pp_row = fhv->luf->pp_row;
 237.279 +      int *pp_col = fhv->luf->pp_col;
 237.280 +      int *p0_row = fhv->p0_row;
 237.281 +      int *p0_col = fhv->p0_col;
 237.282 +      if (!fhv->valid)
 237.283 +         xfault("fhv_ftran: the factorization is not valid\n");
 237.284 +      /* B = F*H*V, therefore inv(B) = inv(V)*inv(H)*inv(F) */
 237.285 +      fhv->luf->pp_row = p0_row;
 237.286 +      fhv->luf->pp_col = p0_col;
 237.287 +      luf_f_solve(fhv->luf, 0, x);
 237.288 +      fhv->luf->pp_row = pp_row;
 237.289 +      fhv->luf->pp_col = pp_col;
 237.290 +      fhv_h_solve(fhv, 0, x);
 237.291 +      luf_v_solve(fhv->luf, 0, x);
 237.292 +      return;
 237.293 +}
 237.294 +
 237.295 +/***********************************************************************
 237.296 +*  NAME
 237.297 +*
 237.298 +*  fhv_btran - perform backward transformation (solve system B'*x = b)
 237.299 +*
 237.300 +*  SYNOPSIS
 237.301 +*
 237.302 +*  #include "glpfhv.h"
 237.303 +*  void fhv_btran(FHV *fhv, double x[]);
 237.304 +*
 237.305 +*  DESCRIPTION
 237.306 +*
 237.307 +*  The routine fhv_btran performs backward transformation, i.e. solves
 237.308 +*  the system B'*x = b, where B' is a matrix transposed to the basis
 237.309 +*  matrix B, x is the vector of unknowns to be computed, b is the vector
 237.310 +*  of right-hand sides.
 237.311 +*
 237.312 +*  On entry elements of the vector b should be stored in dense format
 237.313 +*  in locations x[1], ..., x[m], where m is the number of rows. On exit
 237.314 +*  the routine stores elements of the vector x in the same locations. */
 237.315 +
 237.316 +void fhv_btran(FHV *fhv, double x[])
 237.317 +{     int *pp_row = fhv->luf->pp_row;
 237.318 +      int *pp_col = fhv->luf->pp_col;
 237.319 +      int *p0_row = fhv->p0_row;
 237.320 +      int *p0_col = fhv->p0_col;
 237.321 +      if (!fhv->valid)
 237.322 +         xfault("fhv_btran: the factorization is not valid\n");
 237.323 +      /* B = F*H*V, therefore inv(B') = inv(F')*inv(H')*inv(V') */
 237.324 +      luf_v_solve(fhv->luf, 1, x);
 237.325 +      fhv_h_solve(fhv, 1, x);
 237.326 +      fhv->luf->pp_row = p0_row;
 237.327 +      fhv->luf->pp_col = p0_col;
 237.328 +      luf_f_solve(fhv->luf, 1, x);
 237.329 +      fhv->luf->pp_row = pp_row;
 237.330 +      fhv->luf->pp_col = pp_col;
 237.331 +      return;
 237.332 +}
 237.333 +
 237.334 +/***********************************************************************
 237.335 +*  NAME
 237.336 +*
 237.337 +*  fhv_update_it - update LP basis factorization
 237.338 +*
 237.339 +*  SYNOPSIS
 237.340 +*
 237.341 +*  #include "glpfhv.h"
 237.342 +*  int fhv_update_it(FHV *fhv, int j, int len, const int ind[],
 237.343 +*     const double val[]);
 237.344 +*
 237.345 +*  DESCRIPTION
 237.346 +*
 237.347 +*  The routine fhv_update_it updates the factorization of the basis
 237.348 +*  matrix B after replacing its j-th column by a new vector.
 237.349 +*
 237.350 +*  The parameter j specifies the number of column of B, which has been
 237.351 +*  replaced, 1 <= j <= m, where m is the order of B.
 237.352 +*
 237.353 +*  Row indices and numerical values of non-zero elements of the new
 237.354 +*  column of B should be placed in locations ind[1], ..., ind[len] and
 237.355 +*  val[1], ..., val[len], resp., where len is the number of non-zeros
 237.356 +*  in the column. Neither zero nor duplicate elements are allowed.
 237.357 +*
 237.358 +*  RETURNS
 237.359 +*
 237.360 +*  0  The factorization has been successfully updated.
 237.361 +*
 237.362 +*  FHV_ESING
 237.363 +*     The adjacent basis matrix is structurally singular, since after
 237.364 +*     changing j-th column of matrix V by the new column (see algorithm
 237.365 +*     below) the case k1 > k2 occured.
 237.366 +*
 237.367 +*  FHV_ECHECK
 237.368 +*     The factorization is inaccurate, since after transforming k2-th
 237.369 +*     row of matrix U = P*V*Q, its diagonal element u[k2,k2] is zero or
 237.370 +*     close to zero,
 237.371 +*
 237.372 +*  FHV_ELIMIT
 237.373 +*     Maximal number of H factors has been reached.
 237.374 +*
 237.375 +*  FHV_EROOM
 237.376 +*     Overflow of the sparse vector area.
 237.377 +*
 237.378 +*  In case of non-zero return code the factorization becomes invalid.
 237.379 +*  It should not be used until it has been recomputed with the routine
 237.380 +*  fhv_factorize.
 237.381 +*
 237.382 +*  ALGORITHM
 237.383 +*
 237.384 +*  The routine fhv_update_it is based on the transformation proposed by
 237.385 +*  Forrest and Tomlin.
 237.386 +*
 237.387 +*  Let j-th column of the basis matrix B have been replaced by new
 237.388 +*  column B[j]. In order to keep the equality B = F*H*V j-th column of
 237.389 +*  matrix V should be replaced by the column inv(F*H)*B[j].
 237.390 +*
 237.391 +*  From the standpoint of matrix U = P*V*Q, replacement of j-th column
 237.392 +*  of matrix V is equivalent to replacement of k1-th column of matrix U,
 237.393 +*  where k1 is determined by permutation matrix Q. Thus, matrix U loses
 237.394 +*  its upper triangular form and becomes the following:
 237.395 +*
 237.396 +*         1   k1       k2   m
 237.397 +*     1   x x * x x x x x x x
 237.398 +*         . x * x x x x x x x
 237.399 +*     k1  . . * x x x x x x x
 237.400 +*         . . * x x x x x x x
 237.401 +*         . . * . x x x x x x
 237.402 +*         . . * . . x x x x x
 237.403 +*         . . * . . . x x x x
 237.404 +*     k2  . . * . . . . x x x
 237.405 +*         . . . . . . . . x x
 237.406 +*     m   . . . . . . . . . x
 237.407 +*
 237.408 +*  where row index k2 corresponds to the lowest non-zero element of
 237.409 +*  k1-th column.
 237.410 +*
 237.411 +*  The routine moves rows and columns k1+1, k1+2, ..., k2 of matrix U
 237.412 +*  by one position to the left and upwards and moves k1-th row and k1-th
 237.413 +*  column to position k2. As the result of such symmetric permutations
 237.414 +*  matrix U becomes the following:
 237.415 +*
 237.416 +*         1   k1       k2   m
 237.417 +*     1   x x x x x x x * x x
 237.418 +*         . x x x x x x * x x
 237.419 +*     k1  . . x x x x x * x x
 237.420 +*         . . . x x x x * x x
 237.421 +*         . . . . x x x * x x
 237.422 +*         . . . . . x x * x x
 237.423 +*         . . . . . . x * x x
 237.424 +*     k2  . . x x x x x * x x
 237.425 +*         . . . . . . . . x x
 237.426 +*     m   . . . . . . . . . x
 237.427 +*
 237.428 +*  Then the routine performs gaussian elimination to eliminate elements
 237.429 +*  u[k2,k1], u[k2,k1+1], ..., u[k2,k2-1] using diagonal elements
 237.430 +*  u[k1,k1], u[k1+1,k1+1], ..., u[k2-1,k2-1] as pivots in the same way
 237.431 +*  as described in comments to the routine luf_factorize (see the module
 237.432 +*  GLPLUF). Note that actually all operations are performed on matrix V,
 237.433 +*  not on matrix U. During the elimination process the routine permutes
 237.434 +*  neither rows nor columns, so only k2-th row of matrix U is changed.
 237.435 +*
 237.436 +*  To keep the main equality B = F*H*V, each time when the routine
 237.437 +*  applies elementary gaussian transformation to the transformed row of
 237.438 +*  matrix V (which corresponds to k2-th row of matrix U), it also adds
 237.439 +*  a new element (gaussian multiplier) to the current row-like factor
 237.440 +*  of matrix H, which corresponds to the transformed row of matrix V. */
 237.441 +
 237.442 +int fhv_update_it(FHV *fhv, int j, int len, const int ind[],
 237.443 +      const double val[])
 237.444 +{     int m = fhv->m;
 237.445 +      LUF *luf = fhv->luf;
 237.446 +      int *vr_ptr = luf->vr_ptr;
 237.447 +      int *vr_len = luf->vr_len;
 237.448 +      int *vr_cap = luf->vr_cap;
 237.449 +      double *vr_piv = luf->vr_piv;
 237.450 +      int *vc_ptr = luf->vc_ptr;
 237.451 +      int *vc_len = luf->vc_len;
 237.452 +      int *vc_cap = luf->vc_cap;
 237.453 +      int *pp_row = luf->pp_row;
 237.454 +      int *pp_col = luf->pp_col;
 237.455 +      int *qq_row = luf->qq_row;
 237.456 +      int *qq_col = luf->qq_col;
 237.457 +      int *sv_ind = luf->sv_ind;
 237.458 +      double *sv_val = luf->sv_val;
 237.459 +      double *work = luf->work;
 237.460 +      double eps_tol = luf->eps_tol;
 237.461 +      int *hh_ind = fhv->hh_ind;
 237.462 +      int *hh_ptr = fhv->hh_ptr;
 237.463 +      int *hh_len = fhv->hh_len;
 237.464 +      int *p0_row = fhv->p0_row;
 237.465 +      int *p0_col = fhv->p0_col;
 237.466 +      int *cc_ind = fhv->cc_ind;
 237.467 +      double *cc_val = fhv->cc_val;
 237.468 +      double upd_tol = fhv->upd_tol;
 237.469 +      int i, i_beg, i_end, i_ptr, j_beg, j_end, j_ptr, k, k1, k2, p, q,
 237.470 +         p_beg, p_end, p_ptr, ptr, ret;
 237.471 +      double f, temp;
 237.472 +      if (!fhv->valid)
 237.473 +         xfault("fhv_update_it: the factorization is not valid\n");
 237.474 +      if (!(1 <= j && j <= m))
 237.475 +         xfault("fhv_update_it: j = %d; column number out of range\n",
 237.476 +            j);
 237.477 +      /* check if the new factor of matrix H can be created */
 237.478 +      if (fhv->hh_nfs == fhv->hh_max)
 237.479 +      {  /* maximal number of updates has been reached */
 237.480 +         fhv->valid = 0;
 237.481 +         ret = FHV_ELIMIT;
 237.482 +         goto done;
 237.483 +      }
 237.484 +      /* convert new j-th column of B to dense format */
 237.485 +      for (i = 1; i <= m; i++)
 237.486 +         cc_val[i] = 0.0;
 237.487 +      for (k = 1; k <= len; k++)
 237.488 +      {  i = ind[k];
 237.489 +         if (!(1 <= i && i <= m))
 237.490 +            xfault("fhv_update_it: ind[%d] = %d; row number out of rang"
 237.491 +               "e\n", k, i);
 237.492 +         if (cc_val[i] != 0.0)
 237.493 +            xfault("fhv_update_it: ind[%d] = %d; duplicate row index no"
 237.494 +               "t allowed\n", k, i);
 237.495 +         if (val[k] == 0.0)
 237.496 +            xfault("fhv_update_it: val[%d] = %g; zero element not allow"
 237.497 +               "ed\n", k, val[k]);
 237.498 +         cc_val[i] = val[k];
 237.499 +      }
 237.500 +      /* new j-th column of V := inv(F * H) * (new B[j]) */
 237.501 +      fhv->luf->pp_row = p0_row;
 237.502 +      fhv->luf->pp_col = p0_col;
 237.503 +      luf_f_solve(fhv->luf, 0, cc_val);
 237.504 +      fhv->luf->pp_row = pp_row;
 237.505 +      fhv->luf->pp_col = pp_col;
 237.506 +      fhv_h_solve(fhv, 0, cc_val);
 237.507 +      /* convert new j-th column of V to sparse format */
 237.508 +      len = 0;
 237.509 +      for (i = 1; i <= m; i++)
 237.510 +      {  temp = cc_val[i];
 237.511 +         if (temp == 0.0 || fabs(temp) < eps_tol) continue;
 237.512 +         len++, cc_ind[len] = i, cc_val[len] = temp;
 237.513 +      }
 237.514 +      /* clear old content of j-th column of matrix V */
 237.515 +      j_beg = vc_ptr[j];
 237.516 +      j_end = j_beg + vc_len[j] - 1;
 237.517 +      for (j_ptr = j_beg; j_ptr <= j_end; j_ptr++)
 237.518 +      {  /* get row index of v[i,j] */
 237.519 +         i = sv_ind[j_ptr];
 237.520 +         /* find v[i,j] in the i-th row */
 237.521 +         i_beg = vr_ptr[i];
 237.522 +         i_end = i_beg + vr_len[i] - 1;
 237.523 +         for (i_ptr = i_beg; sv_ind[i_ptr] != j; i_ptr++) /* nop */;
 237.524 +         xassert(i_ptr <= i_end);
 237.525 +         /* remove v[i,j] from the i-th row */
 237.526 +         sv_ind[i_ptr] = sv_ind[i_end];
 237.527 +         sv_val[i_ptr] = sv_val[i_end];
 237.528 +         vr_len[i]--;
 237.529 +      }
 237.530 +      /* now j-th column of matrix V is empty */
 237.531 +      luf->nnz_v -= vc_len[j];
 237.532 +      vc_len[j] = 0;
 237.533 +      /* add new elements of j-th column of matrix V to corresponding
 237.534 +         row lists; determine indices k1 and k2 */
 237.535 +      k1 = qq_row[j], k2 = 0;
 237.536 +      for (ptr = 1; ptr <= len; ptr++)
 237.537 +      {  /* get row index of v[i,j] */
 237.538 +         i = cc_ind[ptr];
 237.539 +         /* at least one unused location is needed in i-th row */
 237.540 +         if (vr_len[i] + 1 > vr_cap[i])
 237.541 +         {  if (luf_enlarge_row(luf, i, vr_len[i] + 10))
 237.542 +            {  /* overflow of the sparse vector area */
 237.543 +               fhv->valid = 0;
 237.544 +               luf->new_sva = luf->sv_size + luf->sv_size;
 237.545 +               xassert(luf->new_sva > luf->sv_size);
 237.546 +               ret = FHV_EROOM;
 237.547 +               goto done;
 237.548 +            }
 237.549 +         }
 237.550 +         /* add v[i,j] to i-th row */
 237.551 +         i_ptr = vr_ptr[i] + vr_len[i];
 237.552 +         sv_ind[i_ptr] = j;
 237.553 +         sv_val[i_ptr] = cc_val[ptr];
 237.554 +         vr_len[i]++;
 237.555 +         /* adjust index k2 */
 237.556 +         if (k2 < pp_col[i]) k2 = pp_col[i];
 237.557 +      }
 237.558 +      /* capacity of j-th column (which is currently empty) should be
 237.559 +         not less than len locations */
 237.560 +      if (vc_cap[j] < len)
 237.561 +      {  if (luf_enlarge_col(luf, j, len))
 237.562 +         {  /* overflow of the sparse vector area */
 237.563 +            fhv->valid = 0;
 237.564 +            luf->new_sva = luf->sv_size + luf->sv_size;
 237.565 +            xassert(luf->new_sva > luf->sv_size);
 237.566 +            ret = FHV_EROOM;
 237.567 +            goto done;
 237.568 +         }
 237.569 +      }
 237.570 +      /* add new elements of matrix V to j-th column list */
 237.571 +      j_ptr = vc_ptr[j];
 237.572 +      memmove(&sv_ind[j_ptr], &cc_ind[1], len * sizeof(int));
 237.573 +      memmove(&sv_val[j_ptr], &cc_val[1], len * sizeof(double));
 237.574 +      vc_len[j] = len;
 237.575 +      luf->nnz_v += len;
 237.576 +      /* if k1 > k2, diagonal element u[k2,k2] of matrix U is zero and
 237.577 +         therefore the adjacent basis matrix is structurally singular */
 237.578 +      if (k1 > k2)
 237.579 +      {  fhv->valid = 0;
 237.580 +         ret = FHV_ESING;
 237.581 +         goto done;
 237.582 +      }
 237.583 +      /* perform implicit symmetric permutations of rows and columns of
 237.584 +         matrix U */
 237.585 +      i = pp_row[k1], j = qq_col[k1];
 237.586 +      for (k = k1; k < k2; k++)
 237.587 +      {  pp_row[k] = pp_row[k+1], pp_col[pp_row[k]] = k;
 237.588 +         qq_col[k] = qq_col[k+1], qq_row[qq_col[k]] = k;
 237.589 +      }
 237.590 +      pp_row[k2] = i, pp_col[i] = k2;
 237.591 +      qq_col[k2] = j, qq_row[j] = k2;
 237.592 +      /* now i-th row of the matrix V is k2-th row of matrix U; since
 237.593 +         no pivoting is used, only this row will be transformed */
 237.594 +      /* copy elements of i-th row of matrix V to the working array and
 237.595 +         remove these elements from matrix V */
 237.596 +      for (j = 1; j <= m; j++) work[j] = 0.0;
 237.597 +      i_beg = vr_ptr[i];
 237.598 +      i_end = i_beg + vr_len[i] - 1;
 237.599 +      for (i_ptr = i_beg; i_ptr <= i_end; i_ptr++)
 237.600 +      {  /* get column index of v[i,j] */
 237.601 +         j = sv_ind[i_ptr];
 237.602 +         /* store v[i,j] to the working array */
 237.603 +         work[j] = sv_val[i_ptr];
 237.604 +         /* find v[i,j] in the j-th column */
 237.605 +         j_beg = vc_ptr[j];
 237.606 +         j_end = j_beg + vc_len[j] - 1;
 237.607 +         for (j_ptr = j_beg; sv_ind[j_ptr] != i; j_ptr++) /* nop */;
 237.608 +         xassert(j_ptr <= j_end);
 237.609 +         /* remove v[i,j] from the j-th column */
 237.610 +         sv_ind[j_ptr] = sv_ind[j_end];
 237.611 +         sv_val[j_ptr] = sv_val[j_end];
 237.612 +         vc_len[j]--;
 237.613 +      }
 237.614 +      /* now i-th row of matrix V is empty */
 237.615 +      luf->nnz_v -= vr_len[i];
 237.616 +      vr_len[i] = 0;
 237.617 +      /* create the next row-like factor of the matrix H; this factor
 237.618 +         corresponds to i-th (transformed) row */
 237.619 +      fhv->hh_nfs++;
 237.620 +      hh_ind[fhv->hh_nfs] = i;
 237.621 +      /* hh_ptr[] will be set later */
 237.622 +      hh_len[fhv->hh_nfs] = 0;
 237.623 +      /* up to (k2 - k1) free locations are needed to add new elements
 237.624 +         to the non-trivial row of the row-like factor */
 237.625 +      if (luf->sv_end - luf->sv_beg < k2 - k1)
 237.626 +      {  luf_defrag_sva(luf);
 237.627 +         if (luf->sv_end - luf->sv_beg < k2 - k1)
 237.628 +         {  /* overflow of the sparse vector area */
 237.629 +            fhv->valid = luf->valid = 0;
 237.630 +            luf->new_sva = luf->sv_size + luf->sv_size;
 237.631 +            xassert(luf->new_sva > luf->sv_size);
 237.632 +            ret = FHV_EROOM;
 237.633 +            goto done;
 237.634 +         }
 237.635 +      }
 237.636 +      /* eliminate subdiagonal elements of matrix U */
 237.637 +      for (k = k1; k < k2; k++)
 237.638 +      {  /* v[p,q] = u[k,k] */
 237.639 +         p = pp_row[k], q = qq_col[k];
 237.640 +         /* this is the crucial point, where even tiny non-zeros should
 237.641 +            not be dropped */
 237.642 +         if (work[q] == 0.0) continue;
 237.643 +         /* compute gaussian multiplier f = v[i,q] / v[p,q] */
 237.644 +         f = work[q] / vr_piv[p];
 237.645 +         /* perform gaussian transformation:
 237.646 +            (i-th row) := (i-th row) - f * (p-th row)
 237.647 +            in order to eliminate v[i,q] = u[k2,k] */
 237.648 +         p_beg = vr_ptr[p];
 237.649 +         p_end = p_beg + vr_len[p] - 1;
 237.650 +         for (p_ptr = p_beg; p_ptr <= p_end; p_ptr++)
 237.651 +            work[sv_ind[p_ptr]] -= f * sv_val[p_ptr];
 237.652 +         /* store new element (gaussian multiplier that corresponds to
 237.653 +            p-th row) in the current row-like factor */
 237.654 +         luf->sv_end--;
 237.655 +         sv_ind[luf->sv_end] = p;
 237.656 +         sv_val[luf->sv_end] = f;
 237.657 +         hh_len[fhv->hh_nfs]++;
 237.658 +      }
 237.659 +      /* set pointer to the current row-like factor of the matrix H
 237.660 +         (if no elements were added to this factor, it is unity matrix
 237.661 +         and therefore can be discarded) */
 237.662 +      if (hh_len[fhv->hh_nfs] == 0)
 237.663 +         fhv->hh_nfs--;
 237.664 +      else
 237.665 +      {  hh_ptr[fhv->hh_nfs] = luf->sv_end;
 237.666 +         fhv->nnz_h += hh_len[fhv->hh_nfs];
 237.667 +      }
 237.668 +      /* store new pivot which corresponds to u[k2,k2] */
 237.669 +      vr_piv[i] = work[qq_col[k2]];
 237.670 +      /* new elements of i-th row of matrix V (which are non-diagonal
 237.671 +         elements u[k2,k2+1], ..., u[k2,m] of matrix U = P*V*Q) now are
 237.672 +         contained in the working array; add them to matrix V */
 237.673 +      len = 0;
 237.674 +      for (k = k2+1; k <= m; k++)
 237.675 +      {  /* get column index and value of v[i,j] = u[k2,k] */
 237.676 +         j = qq_col[k];
 237.677 +         temp = work[j];
 237.678 +         /* if v[i,j] is close to zero, skip it */
 237.679 +         if (fabs(temp) < eps_tol) continue;
 237.680 +         /* at least one unused location is needed in j-th column */
 237.681 +         if (vc_len[j] + 1 > vc_cap[j])
 237.682 +         {  if (luf_enlarge_col(luf, j, vc_len[j] + 10))
 237.683 +            {  /* overflow of the sparse vector area */
 237.684 +               fhv->valid = 0;
 237.685 +               luf->new_sva = luf->sv_size + luf->sv_size;
 237.686 +               xassert(luf->new_sva > luf->sv_size);
 237.687 +               ret = FHV_EROOM;
 237.688 +               goto done;
 237.689 +            }
 237.690 +         }
 237.691 +         /* add v[i,j] to j-th column */
 237.692 +         j_ptr = vc_ptr[j] + vc_len[j];
 237.693 +         sv_ind[j_ptr] = i;
 237.694 +         sv_val[j_ptr] = temp;
 237.695 +         vc_len[j]++;
 237.696 +         /* also store v[i,j] to the auxiliary array */
 237.697 +         len++, cc_ind[len] = j, cc_val[len] = temp;
 237.698 +      }
 237.699 +      /* capacity of i-th row (which is currently empty) should be not
 237.700 +         less than len locations */
 237.701 +      if (vr_cap[i] < len)
 237.702 +      {  if (luf_enlarge_row(luf, i, len))
 237.703 +         {  /* overflow of the sparse vector area */
 237.704 +            fhv->valid = 0;
 237.705 +            luf->new_sva = luf->sv_size + luf->sv_size;
 237.706 +            xassert(luf->new_sva > luf->sv_size);
 237.707 +            ret = FHV_EROOM;
 237.708 +            goto done;
 237.709 +         }
 237.710 +      }
 237.711 +      /* add new elements to i-th row list */
 237.712 +      i_ptr = vr_ptr[i];
 237.713 +      memmove(&sv_ind[i_ptr], &cc_ind[1], len * sizeof(int));
 237.714 +      memmove(&sv_val[i_ptr], &cc_val[1], len * sizeof(double));
 237.715 +      vr_len[i] = len;
 237.716 +      luf->nnz_v += len;
 237.717 +      /* updating is finished; check that diagonal element u[k2,k2] is
 237.718 +         not very small in absolute value among other elements in k2-th
 237.719 +         row and k2-th column of matrix U = P*V*Q */
 237.720 +      /* temp = max(|u[k2,*]|, |u[*,k2]|) */
 237.721 +      temp = 0.0;
 237.722 +      /* walk through k2-th row of U which is i-th row of V */
 237.723 +      i = pp_row[k2];
 237.724 +      i_beg = vr_ptr[i];
 237.725 +      i_end = i_beg + vr_len[i] - 1;
 237.726 +      for (i_ptr = i_beg; i_ptr <= i_end; i_ptr++)
 237.727 +         if (temp < fabs(sv_val[i_ptr])) temp = fabs(sv_val[i_ptr]);
 237.728 +      /* walk through k2-th column of U which is j-th column of V */
 237.729 +      j = qq_col[k2];
 237.730 +      j_beg = vc_ptr[j];
 237.731 +      j_end = j_beg + vc_len[j] - 1;
 237.732 +      for (j_ptr = j_beg; j_ptr <= j_end; j_ptr++)
 237.733 +         if (temp < fabs(sv_val[j_ptr])) temp = fabs(sv_val[j_ptr]);
 237.734 +      /* check that u[k2,k2] is not very small */
 237.735 +      if (fabs(vr_piv[i]) < upd_tol * temp)
 237.736 +      {  /* the factorization seems to be inaccurate and therefore must
 237.737 +            be recomputed */
 237.738 +         fhv->valid = 0;
 237.739 +         ret = FHV_ECHECK;
 237.740 +         goto done;
 237.741 +      }
 237.742 +      /* the factorization has been successfully updated */
 237.743 +      ret = 0;
 237.744 +done: /* return to the calling program */
 237.745 +      return ret;
 237.746 +}
 237.747 +
 237.748 +/***********************************************************************
 237.749 +*  NAME
 237.750 +*
 237.751 +*  fhv_delete_it - delete LP basis factorization
 237.752 +*
 237.753 +*  SYNOPSIS
 237.754 +*
 237.755 +*  #include "glpfhv.h"
 237.756 +*  void fhv_delete_it(FHV *fhv);
 237.757 +*
 237.758 +*  DESCRIPTION
 237.759 +*
 237.760 +*  The routine fhv_delete_it deletes LP basis factorization specified
 237.761 +*  by the parameter fhv and frees all memory allocated to this program
 237.762 +*  object. */
 237.763 +
 237.764 +void fhv_delete_it(FHV *fhv)
 237.765 +{     luf_delete_it(fhv->luf);
 237.766 +      if (fhv->hh_ind != NULL) xfree(fhv->hh_ind);
 237.767 +      if (fhv->hh_ptr != NULL) xfree(fhv->hh_ptr);
 237.768 +      if (fhv->hh_len != NULL) xfree(fhv->hh_len);
 237.769 +      if (fhv->p0_row != NULL) xfree(fhv->p0_row);
 237.770 +      if (fhv->p0_col != NULL) xfree(fhv->p0_col);
 237.771 +      if (fhv->cc_ind != NULL) xfree(fhv->cc_ind);
 237.772 +      if (fhv->cc_val != NULL) xfree(fhv->cc_val);
 237.773 +      xfree(fhv);
 237.774 +      return;
 237.775 +}
 237.776 +
 237.777 +/* eof */
   238.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
   238.2 +++ b/deps/glpk/src/glpfhv.h	Sun Nov 06 20:59:10 2011 +0100
   238.3 @@ -0,0 +1,170 @@
   238.4 +/* glpfhv.h (LP basis factorization, FHV eta file version) */
   238.5 +
   238.6 +/***********************************************************************
   238.7 +*  This code is part of GLPK (GNU Linear Programming Kit).
   238.8 +*
   238.9 +*  Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008,
  238.10 +*  2009, 2010, 2011 Andrew Makhorin, Department for Applied Informatics,
  238.11 +*  Moscow Aviation Institute, Moscow, Russia. All rights reserved.
  238.12 +*  E-mail: <mao@gnu.org>.
  238.13 +*
  238.14 +*  GLPK is free software: you can redistribute it and/or modify it
  238.15 +*  under the terms of the GNU General Public License as published by
  238.16 +*  the Free Software Foundation, either version 3 of the License, or
  238.17 +*  (at your option) any later version.
  238.18 +*
  238.19 +*  GLPK is distributed in the hope that it will be useful, but WITHOUT
  238.20 +*  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
  238.21 +*  or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
  238.22 +*  License for more details.
  238.23 +*
  238.24 +*  You should have received a copy of the GNU General Public License
  238.25 +*  along with GLPK. If not, see <http://www.gnu.org/licenses/>.
  238.26 +***********************************************************************/
  238.27 +
  238.28 +#ifndef GLPFHV_H
  238.29 +#define GLPFHV_H
  238.30 +
  238.31 +#include "glpluf.h"
  238.32 +
  238.33 +/***********************************************************************
  238.34 +*  The structure FHV defines the factorization of the basis mxm-matrix
  238.35 +*  B, where m is the number of rows in corresponding problem instance.
  238.36 +*
  238.37 +*  This factorization is the following sextet:
  238.38 +*
  238.39 +*     [B] = (F, H, V, P0, P, Q),                                     (1)
  238.40 +*
  238.41 +*  where F, H, and V are such matrices that
  238.42 +*
  238.43 +*     B = F * H * V,                                                 (2)
  238.44 +*
  238.45 +*  and P0, P, and Q are such permutation matrices that the matrix
  238.46 +*
  238.47 +*     L = P0 * F * inv(P0)                                           (3)
  238.48 +*
  238.49 +*  is lower triangular with unity diagonal, and the matrix
  238.50 +*
  238.51 +*     U = P * V * Q                                                  (4)
  238.52 +*
  238.53 +*  is upper triangular. All the matrices have the same order m, which
  238.54 +*  is the order of the basis matrix B.
  238.55 +*
  238.56 +*  The matrices F, V, P, and Q are stored in the structure LUF (see the
  238.57 +*  module GLPLUF), which is a member of the structure FHV.
  238.58 +*
  238.59 +*  The matrix H is stored in the form of eta file using row-like format
  238.60 +*  as follows:
  238.61 +*
  238.62 +*     H = H[1] * H[2] * ... * H[nfs],                                (5)
  238.63 +*
  238.64 +*  where H[k], k = 1, 2, ..., nfs, is a row-like factor, which differs
  238.65 +*  from the unity matrix only by one row, nfs is current number of row-
  238.66 +*  like factors. After the factorization has been built for some given
  238.67 +*  basis matrix B the matrix H has no factors and thus it is the unity
  238.68 +*  matrix. Then each time when the factorization is recomputed for an
  238.69 +*  adjacent basis matrix, the next factor H[k], k = 1, 2, ... is built
  238.70 +*  and added to the end of the eta file H.
  238.71 +*
  238.72 +*  Being sparse vectors non-trivial rows of the factors H[k] are stored
  238.73 +*  in the right part of the sparse vector area (SVA) in the same manner
  238.74 +*  as rows and columns of the matrix F.
  238.75 +*
  238.76 +*  For more details see the program documentation. */
  238.77 +
  238.78 +typedef struct FHV FHV;
  238.79 +
  238.80 +struct FHV
  238.81 +{     /* LP basis factorization */
  238.82 +      int m_max;
  238.83 +      /* maximal value of m (increased automatically, if necessary) */
  238.84 +      int m;
  238.85 +      /* the order of matrices B, F, H, V, P0, P, Q */
  238.86 +      int valid;
  238.87 +      /* the factorization is valid only if this flag is set */
  238.88 +      LUF *luf;
  238.89 +      /* LU-factorization (contains the matrices F, V, P, Q) */
  238.90 +      /*--------------------------------------------------------------*/
  238.91 +      /* matrix H in the form of eta file */
  238.92 +      int hh_max;
  238.93 +      /* maximal number of row-like factors (which limits the number of
  238.94 +         updates of the factorization) */
  238.95 +      int hh_nfs;
  238.96 +      /* current number of row-like factors (0 <= hh_nfs <= hh_max) */
  238.97 +      int *hh_ind; /* int hh_ind[1+hh_max]; */
  238.98 +      /* hh_ind[k], k = 1, ..., nfs, is the number of a non-trivial row
  238.99 +         of factor H[k] */
 238.100 +      int *hh_ptr; /* int hh_ptr[1+hh_max]; */
 238.101 +      /* hh_ptr[k], k = 1, ..., nfs, is a pointer to the first element
 238.102 +         of the non-trivial row of factor H[k] in the SVA */
 238.103 +      int *hh_len; /* int hh_len[1+hh_max]; */
 238.104 +      /* hh_len[k], k = 1, ..., nfs, is the number of non-zero elements
 238.105 +         in the non-trivial row of factor H[k] */
 238.106 +      /*--------------------------------------------------------------*/
 238.107 +      /* matrix P0 */
 238.108 +      int *p0_row; /* int p0_row[1+m_max]; */
 238.109 +      /* p0_row[i] = j means that p0[i,j] = 1 */
 238.110 +      int *p0_col; /* int p0_col[1+m_max]; */
 238.111 +      /* p0_col[j] = i means that p0[i,j] = 1 */
 238.112 +      /* if i-th row or column of the matrix F corresponds to i'-th row
 238.113 +         or column of the matrix L = P0*F*inv(P0), then p0_row[i'] = i
 238.114 +         and p0_col[i] = i' */
 238.115 +      /*--------------------------------------------------------------*/
 238.116 +      /* working arrays */
 238.117 +      int *cc_ind; /* int cc_ind[1+m_max]; */
 238.118 +      /* integer working array */
 238.119 +      double *cc_val; /* double cc_val[1+m_max]; */
 238.120 +      /* floating-point working array */
 238.121 +      /*--------------------------------------------------------------*/
 238.122 +      /* control parameters */
 238.123 +      double upd_tol;
 238.124 +      /* update tolerance; if after updating the factorization absolute
 238.125 +         value of some diagonal element u[k,k] of matrix U = P*V*Q is
 238.126 +         less than upd_tol * max(|u[k,*]|, |u[*,k]|), the factorization
 238.127 +         is considered as inaccurate */
 238.128 +      /*--------------------------------------------------------------*/
 238.129 +      /* some statistics */
 238.130 +      int nnz_h;
 238.131 +      /* current number of non-zeros in all factors of matrix H */
 238.132 +};
 238.133 +
 238.134 +/* return codes: */
 238.135 +#define FHV_ESING    1  /* singular matrix */
 238.136 +#define FHV_ECOND    2  /* ill-conditioned matrix */
 238.137 +#define FHV_ECHECK   3  /* insufficient accuracy */
 238.138 +#define FHV_ELIMIT   4  /* update limit reached */
 238.139 +#define FHV_EROOM    5  /* SVA overflow */
 238.140 +
 238.141 +#define fhv_create_it _glp_fhv_create_it
 238.142 +FHV *fhv_create_it(void);
 238.143 +/* create LP basis factorization */
 238.144 +
 238.145 +#define fhv_factorize _glp_fhv_factorize
 238.146 +int fhv_factorize(FHV *fhv, int m, int (*col)(void *info, int j,
 238.147 +      int ind[], double val[]), void *info);
 238.148 +/* compute LP basis factorization */
 238.149 +
 238.150 +#define fhv_h_solve _glp_fhv_h_solve
 238.151 +void fhv_h_solve(FHV *fhv, int tr, double x[]);
 238.152 +/* solve system H*x = b or H'*x = b */
 238.153 +
 238.154 +#define fhv_ftran _glp_fhv_ftran
 238.155 +void fhv_ftran(FHV *fhv, double x[]);
 238.156 +/* perform forward transformation (solve system B*x = b) */
 238.157 +
 238.158 +#define fhv_btran _glp_fhv_btran
 238.159 +void fhv_btran(FHV *fhv, double x[]);
 238.160 +/* perform backward transformation (solve system B'*x = b) */
 238.161 +
 238.162 +#define fhv_update_it _glp_fhv_update_it
 238.163 +int fhv_update_it(FHV *fhv, int j, int len, const int ind[],
 238.164 +      const double val[]);
 238.165 +/* update LP basis factorization */
 238.166 +
 238.167 +#define fhv_delete_it _glp_fhv_delete_it
 238.168 +void fhv_delete_it(FHV *fhv);
 238.169 +/* delete LP basis factorization */
 238.170 +
 238.171 +#endif
 238.172 +
 238.173 +/* eof */
   239.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
   239.2 +++ b/deps/glpk/src/glpgmp.c	Sun Nov 06 20:59:10 2011 +0100
   239.3 @@ -0,0 +1,1108 @@
   239.4 +/* glpgmp.c */
   239.5 +
   239.6 +/***********************************************************************
   239.7 +*  This code is part of GLPK (GNU Linear Programming Kit).
   239.8 +*
   239.9 +*  Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008,
  239.10 +*  2009, 2010, 2011 Andrew Makhorin, Department for Applied Informatics,
  239.11 +*  Moscow Aviation Institute, Moscow, Russia. All rights reserved.
  239.12 +*  E-mail: <mao@gnu.org>.
  239.13 +*
  239.14 +*  GLPK is free software: you can redistribute it and/or modify it
  239.15 +*  under the terms of the GNU General Public License as published by
  239.16 +*  the Free Software Foundation, either version 3 of the License, or
  239.17 +*  (at your option) any later version.
  239.18 +*
  239.19 +*  GLPK is distributed in the hope that it will be useful, but WITHOUT
  239.20 +*  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
  239.21 +*  or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
  239.22 +*  License for more details.
  239.23 +*
  239.24 +*  You should have received a copy of the GNU General Public License
  239.25 +*  along with GLPK. If not, see <http://www.gnu.org/licenses/>.
  239.26 +***********************************************************************/
  239.27 +
  239.28 +#define _GLPSTD_STDIO
  239.29 +#include "glpdmp.h"
  239.30 +#include "glpgmp.h"
  239.31 +#define xfault xerror
  239.32 +
  239.33 +#ifdef HAVE_GMP               /* use GNU MP bignum library */
  239.34 +
  239.35 +int gmp_pool_count(void) { return 0; }
  239.36 +
  239.37 +void gmp_free_mem(void) { return; }
  239.38 +
  239.39 +#else                         /* use GLPK bignum module */
  239.40 +
  239.41 +static DMP *gmp_pool = NULL;
  239.42 +static int gmp_size = 0;
  239.43 +static unsigned short *gmp_work = NULL;
  239.44 +
  239.45 +void *gmp_get_atom(int size)
  239.46 +{     if (gmp_pool == NULL)
  239.47 +         gmp_pool = dmp_create_pool();
  239.48 +      return dmp_get_atom(gmp_pool, size);
  239.49 +}
  239.50 +
  239.51 +void gmp_free_atom(void *ptr, int size)
  239.52 +{     xassert(gmp_pool != NULL);
  239.53 +      dmp_free_atom(gmp_pool, ptr, size);
  239.54 +      return;
  239.55 +}
  239.56 +
  239.57 +int gmp_pool_count(void)
  239.58 +{     if (gmp_pool == NULL)
  239.59 +         return 0;
  239.60 +      else
  239.61 +         return dmp_in_use(gmp_pool).lo;
  239.62 +}
  239.63 +
  239.64 +unsigned short *gmp_get_work(int size)
  239.65 +{     xassert(size > 0);
  239.66 +      if (gmp_size < size)
  239.67 +      {  if (gmp_size == 0)
  239.68 +         {  xassert(gmp_work == NULL);
  239.69 +            gmp_size = 100;
  239.70 +         }
  239.71 +         else
  239.72 +         {  xassert(gmp_work != NULL);
  239.73 +            xfree(gmp_work);
  239.74 +         }
  239.75 +         while (gmp_size < size) gmp_size += gmp_size;
  239.76 +         gmp_work = xcalloc(gmp_size, sizeof(unsigned short));
  239.77 +      }
  239.78 +      return gmp_work;
  239.79 +}
  239.80 +
  239.81 +void gmp_free_mem(void)
  239.82 +{     if (gmp_pool != NULL) dmp_delete_pool(gmp_pool);
  239.83 +      if (gmp_work != NULL) xfree(gmp_work);
  239.84 +      gmp_pool = NULL;
  239.85 +      gmp_size = 0;
  239.86 +      gmp_work = NULL;
  239.87 +      return;
  239.88 +}
  239.89 +
  239.90 +/*====================================================================*/
  239.91 +
  239.92 +mpz_t _mpz_init(void)
  239.93 +{     /* initialize x, and set its value to 0 */
  239.94 +      mpz_t x;
  239.95 +      x = gmp_get_atom(sizeof(struct mpz));
  239.96 +      x->val = 0;
  239.97 +      x->ptr = NULL;
  239.98 +      return x;
  239.99 +}
 239.100 +
 239.101 +void mpz_clear(mpz_t x)
 239.102 +{     /* free the space occupied by x */
 239.103 +      mpz_set_si(x, 0);
 239.104 +      xassert(x->ptr == NULL);
 239.105 +      /* free the number descriptor */
 239.106 +      gmp_free_atom(x, sizeof(struct mpz));
 239.107 +      return;
 239.108 +}
 239.109 +
 239.110 +void mpz_set(mpz_t z, mpz_t x)
 239.111 +{     /* set the value of z from x */
 239.112 +      struct mpz_seg *e, *ee, *es;
 239.113 +      if (z != x)
 239.114 +      {  mpz_set_si(z, 0);
 239.115 +         z->val = x->val;
 239.116 +         xassert(z->ptr == NULL);
 239.117 +         for (e = x->ptr, es = NULL; e != NULL; e = e->next)
 239.118 +         {  ee = gmp_get_atom(sizeof(struct mpz_seg));
 239.119 +            memcpy(ee->d, e->d, 12);
 239.120 +            ee->next = NULL;
 239.121 +            if (z->ptr == NULL)
 239.122 +               z->ptr = ee;
 239.123 +            else
 239.124 +               es->next = ee;
 239.125 +            es = ee;
 239.126 +         }
 239.127 +      }
 239.128 +      return;
 239.129 +}
 239.130 +
 239.131 +void mpz_set_si(mpz_t x, int val)
 239.132 +{     /* set the value of x to val */
 239.133 +      struct mpz_seg *e;
 239.134 +      /* free existing segments, if any */
 239.135 +      while (x->ptr != NULL)
 239.136 +      {  e = x->ptr;
 239.137 +         x->ptr = e->next;
 239.138 +         gmp_free_atom(e, sizeof(struct mpz_seg));
 239.139 +      }
 239.140 +      /* assign new value */
 239.141 +      if (val == 0x80000000)
 239.142 +      {  /* long format is needed */
 239.143 +         x->val = -1;
 239.144 +         x->ptr = e = gmp_get_atom(sizeof(struct mpz_seg));
 239.145 +         memset(e->d, 0, 12);
 239.146 +         e->d[1] = 0x8000;
 239.147 +         e->next = NULL;
 239.148 +      }
 239.149 +      else
 239.150 +      {  /* short format is enough */
 239.151 +         x->val = val;
 239.152 +      }
 239.153 +      return;
 239.154 +}
 239.155 +
 239.156 +double mpz_get_d(mpz_t x)
 239.157 +{     /* convert x to a double, truncating if necessary */
 239.158 +      struct mpz_seg *e;
 239.159 +      int j;
 239.160 +      double val, deg;
 239.161 +      if (x->ptr == NULL)
 239.162 +         val = (double)x->val;
 239.163 +      else
 239.164 +      {  xassert(x->val != 0);
 239.165 +         val = 0.0;
 239.166 +         deg = 1.0;
 239.167 +         for (e = x->ptr; e != NULL; e = e->next)
 239.168 +         {  for (j = 0; j <= 5; j++)
 239.169 +            {  val += deg * (double)((int)e->d[j]);
 239.170 +               deg *= 65536.0;
 239.171 +            }
 239.172 +         }
 239.173 +         if (x->val < 0) val = - val;
 239.174 +      }
 239.175 +      return val;
 239.176 +}
 239.177 +
 239.178 +double mpz_get_d_2exp(int *exp, mpz_t x)
 239.179 +{     /* convert x to a double, truncating if necessary (i.e. rounding
 239.180 +         towards zero), and returning the exponent separately;
 239.181 +         the return value is in the range 0.5 <= |d| < 1 and the
 239.182 +         exponent is stored to *exp; d*2^exp is the (truncated) x value;
 239.183 +         if x is zero, the return is 0.0 and 0 is stored to *exp;
 239.184 +         this is similar to the standard C frexp function */
 239.185 +      struct mpz_seg *e;
 239.186 +      int j, n, n1;
 239.187 +      double val;
 239.188 +      if (x->ptr == NULL)
 239.189 +         val = (double)x->val, n = 0;
 239.190 +      else
 239.191 +      {  xassert(x->val != 0);
 239.192 +         val = 0.0, n = 0;
 239.193 +         for (e = x->ptr; e != NULL; e = e->next)
 239.194 +         {  for (j = 0; j <= 5; j++)
 239.195 +            {  val += (double)((int)e->d[j]);
 239.196 +               val /= 65536.0, n += 16;
 239.197 +            }
 239.198 +         }
 239.199 +         if (x->val < 0) val = - val;
 239.200 +      }
 239.201 +      val = frexp(val, &n1);
 239.202 +      *exp = n + n1;
 239.203 +      return val;
 239.204 +}
 239.205 +
 239.206 +void mpz_swap(mpz_t x, mpz_t y)
 239.207 +{     /* swap the values x and y efficiently */
 239.208 +      int val;
 239.209 +      void *ptr;
 239.210 +      val = x->val, ptr = x->ptr;
 239.211 +      x->val = y->val, x->ptr = y->ptr;
 239.212 +      y->val = val, y->ptr = ptr;
 239.213 +      return;
 239.214 +}
 239.215 +
 239.216 +static void normalize(mpz_t x)
 239.217 +{     /* normalize integer x that includes removing non-significant
 239.218 +         (leading) zeros and converting to short format, if possible */
 239.219 +      struct mpz_seg *es, *e;
 239.220 +      /* if the integer is in short format, it remains unchanged */
 239.221 +      if (x->ptr == NULL)
 239.222 +      {  xassert(x->val != 0x80000000);
 239.223 +         goto done;
 239.224 +      }
 239.225 +      xassert(x->val == +1 || x->val == -1);
 239.226 +      /* find the last (most significant) non-zero segment */
 239.227 +      es = NULL;
 239.228 +      for (e = x->ptr; e != NULL; e = e->next)
 239.229 +      {  if (e->d[0] || e->d[1] || e->d[2] ||
 239.230 +             e->d[3] || e->d[4] || e->d[5]) es = e;
 239.231 +      }
 239.232 +      /* if all segments contain zeros, the integer is zero */
 239.233 +      if (es == NULL)
 239.234 +      {  mpz_set_si(x, 0);
 239.235 +         goto done;
 239.236 +      }
 239.237 +      /* remove non-significant (leading) zero segments */
 239.238 +      while (es->next != NULL)
 239.239 +      {  e = es->next;
 239.240 +         es->next = e->next;
 239.241 +         gmp_free_atom(e, sizeof(struct mpz_seg));
 239.242 +      }
 239.243 +      /* convert the integer to short format, if possible */
 239.244 +      e = x->ptr;
 239.245 +      if (e->next == NULL && e->d[1] <= 0x7FFF &&
 239.246 +         !e->d[2] && !e->d[3] && !e->d[4] && !e->d[5])
 239.247 +      {  int val;
 239.248 +         val = (int)e->d[0] + ((int)e->d[1] << 16);
 239.249 +         if (x->val < 0) val = - val;
 239.250 +         mpz_set_si(x, val);
 239.251 +      }
 239.252 +done: return;
 239.253 +}
 239.254 +
 239.255 +void mpz_add(mpz_t z, mpz_t x, mpz_t y)
 239.256 +{     /* set z to x + y */
 239.257 +      static struct mpz_seg zero = { { 0, 0, 0, 0, 0, 0 }, NULL };
 239.258 +      struct mpz_seg dumx, dumy, *ex, *ey, *ez, *es, *ee;
 239.259 +      int k, sx, sy, sz;
 239.260 +      unsigned int t;
 239.261 +      /* if [x] = 0 then [z] = [y] */
 239.262 +      if (x->val == 0)
 239.263 +      {  xassert(x->ptr == NULL);
 239.264 +         mpz_set(z, y);
 239.265 +         goto done;
 239.266 +      }
 239.267 +      /* if [y] = 0 then [z] = [x] */
 239.268 +      if (y->val == 0)
 239.269 +      {  xassert(y->ptr == NULL);
 239.270 +         mpz_set(z, x);
 239.271 +         goto done;
 239.272 +      }
 239.273 +      /* special case when both [x] and [y] are in short format */
 239.274 +      if (x->ptr == NULL && y->ptr == NULL)
 239.275 +      {  int xval = x->val, yval = y->val, zval = x->val + y->val;
 239.276 +         xassert(xval != 0x80000000 && yval != 0x80000000);
 239.277 +         if (!(xval > 0 && yval > 0 && zval <= 0 ||
 239.278 +               xval < 0 && yval < 0 && zval >= 0))
 239.279 +         {  mpz_set_si(z, zval);
 239.280 +            goto done;
 239.281 +         }
 239.282 +      }
 239.283 +      /* convert [x] to long format, if necessary */
 239.284 +      if (x->ptr == NULL)
 239.285 +      {  xassert(x->val != 0x80000000);
 239.286 +         if (x->val >= 0)
 239.287 +         {  sx = +1;
 239.288 +            t = (unsigned int)(+ x->val);
 239.289 +         }
 239.290 +         else
 239.291 +         {  sx = -1;
 239.292 +            t = (unsigned int)(- x->val);
 239.293 +         }
 239.294 +         ex = &dumx;
 239.295 +         ex->d[0] = (unsigned short)t;
 239.296 +         ex->d[1] = (unsigned short)(t >> 16);
 239.297 +         ex->d[2] = ex->d[3] = ex->d[4] = ex->d[5] = 0;
 239.298 +         ex->next = NULL;
 239.299 +      }
 239.300 +      else
 239.301 +      {  sx = x->val;
 239.302 +         xassert(sx == +1 || sx == -1);
 239.303 +         ex = x->ptr;
 239.304 +      }
 239.305 +      /* convert [y] to long format, if necessary */
 239.306 +      if (y->ptr == NULL)
 239.307 +      {  xassert(y->val != 0x80000000);
 239.308 +         if (y->val >= 0)
 239.309 +         {  sy = +1;
 239.310 +            t = (unsigned int)(+ y->val);
 239.311 +         }
 239.312 +         else
 239.313 +         {  sy = -1;
 239.314 +            t = (unsigned int)(- y->val);
 239.315 +         }
 239.316 +         ey = &dumy;
 239.317 +         ey->d[0] = (unsigned short)t;
 239.318 +         ey->d[1] = (unsigned short)(t >> 16);
 239.319 +         ey->d[2] = ey->d[3] = ey->d[4] = ey->d[5] = 0;
 239.320 +         ey->next = NULL;
 239.321 +      }
 239.322 +      else
 239.323 +      {  sy = y->val;
 239.324 +         xassert(sy == +1 || sy == -1);
 239.325 +         ey = y->ptr;
 239.326 +      }
 239.327 +      /* main fragment */
 239.328 +      sz = sx;
 239.329 +      ez = es = NULL;
 239.330 +      if (sx > 0 && sy > 0 || sx < 0 && sy < 0)
 239.331 +      {  /* [x] and [y] have identical signs -- addition */
 239.332 +         t = 0;
 239.333 +         for (; ex || ey; ex = ex->next, ey = ey->next)
 239.334 +         {  if (ex == NULL) ex = &zero;
 239.335 +            if (ey == NULL) ey = &zero;
 239.336 +            ee = gmp_get_atom(sizeof(struct mpz_seg));
 239.337 +            for (k = 0; k <= 5; k++)
 239.338 +            {  t += (unsigned int)ex->d[k];
 239.339 +               t += (unsigned int)ey->d[k];
 239.340 +               ee->d[k] = (unsigned short)t;
 239.341 +               t >>= 16;
 239.342 +            }
 239.343 +            ee->next = NULL;
 239.344 +            if (ez == NULL)
 239.345 +               ez = ee;
 239.346 +            else
 239.347 +               es->next = ee;
 239.348 +            es = ee;
 239.349 +         }
 239.350 +         if (t)
 239.351 +         {  /* overflow -- one extra digit is needed */
 239.352 +            ee = gmp_get_atom(sizeof(struct mpz_seg));
 239.353 +            ee->d[0] = 1;
 239.354 +            ee->d[1] = ee->d[2] = ee->d[3] = ee->d[4] = ee->d[5] = 0;
 239.355 +            ee->next = NULL;
 239.356 +            xassert(es != NULL);
 239.357 +            es->next = ee;
 239.358 +         }
 239.359 +      }
 239.360 +      else
 239.361 +      {  /* [x] and [y] have different signs -- subtraction */
 239.362 +         t = 1;
 239.363 +         for (; ex || ey; ex = ex->next, ey = ey->next)
 239.364 +         {  if (ex == NULL) ex = &zero;
 239.365 +            if (ey == NULL) ey = &zero;
 239.366 +            ee = gmp_get_atom(sizeof(struct mpz_seg));
 239.367 +            for (k = 0; k <= 5; k++)
 239.368 +            {  t += (unsigned int)ex->d[k];
 239.369 +               t += (0xFFFF - (unsigned int)ey->d[k]);
 239.370 +               ee->d[k] = (unsigned short)t;
 239.371 +               t >>= 16;
 239.372 +            }
 239.373 +            ee->next = NULL;
 239.374 +            if (ez == NULL)
 239.375 +               ez = ee;
 239.376 +            else
 239.377 +               es->next = ee;
 239.378 +            es = ee;
 239.379 +         }
 239.380 +         if (!t)
 239.381 +         {  /* |[x]| < |[y]| -- result in complement coding */
 239.382 +            sz = - sz;
 239.383 +            t = 1;
 239.384 +            for (ee = ez; ee != NULL; ee = ee->next)
 239.385 +            for (k = 0; k <= 5; k++)
 239.386 +            {  t += (0xFFFF - (unsigned int)ee->d[k]);
 239.387 +               ee->d[k] = (unsigned short)t;
 239.388 +               t >>= 16;
 239.389 +            }
 239.390 +         }
 239.391 +      }
 239.392 +      /* contruct and normalize result */
 239.393 +      mpz_set_si(z, 0);
 239.394 +      z->val = sz;
 239.395 +      z->ptr = ez;
 239.396 +      normalize(z);
 239.397 +done: return;
 239.398 +}
 239.399 +
 239.400 +void mpz_sub(mpz_t z, mpz_t x, mpz_t y)
 239.401 +{     /* set z to x - y */
 239.402 +      if (x == y)
 239.403 +         mpz_set_si(z, 0);
 239.404 +      else
 239.405 +      {  y->val = - y->val;
 239.406 +         mpz_add(z, x, y);
 239.407 +         if (y != z) y->val = - y->val;
 239.408 +      }
 239.409 +      return;
 239.410 +}
 239.411 +
 239.412 +void mpz_mul(mpz_t z, mpz_t x, mpz_t y)
 239.413 +{     /* set z to x * y */
 239.414 +      struct mpz_seg dumx, dumy, *ex, *ey, *es, *e;
 239.415 +      int sx, sy, k, nx, ny, n;
 239.416 +      unsigned int t;
 239.417 +      unsigned short *work, *wx, *wy;
 239.418 +      /* if [x] = 0 then [z] = 0 */
 239.419 +      if (x->val == 0)
 239.420 +      {  xassert(x->ptr == NULL);
 239.421 +         mpz_set_si(z, 0);
 239.422 +         goto done;
 239.423 +      }
 239.424 +      /* if [y] = 0 then [z] = 0 */
 239.425 +      if (y->val == 0)
 239.426 +      {  xassert(y->ptr == NULL);
 239.427 +         mpz_set_si(z, 0);
 239.428 +         goto done;
 239.429 +      }
 239.430 +      /* special case when both [x] and [y] are in short format */
 239.431 +      if (x->ptr == NULL && y->ptr == NULL)
 239.432 +      {  int xval = x->val, yval = y->val, sz = +1;
 239.433 +         xassert(xval != 0x80000000 && yval != 0x80000000);
 239.434 +         if (xval < 0) xval = - xval, sz = - sz;
 239.435 +         if (yval < 0) yval = - yval, sz = - sz;
 239.436 +         if (xval <= 0x7FFFFFFF / yval)
 239.437 +         {  mpz_set_si(z, sz * (xval * yval));
 239.438 +            goto done;
 239.439 +         }
 239.440 +      }
 239.441 +      /* convert [x] to long format, if necessary */
 239.442 +      if (x->ptr == NULL)
 239.443 +      {  xassert(x->val != 0x80000000);
 239.444 +         if (x->val >= 0)
 239.445 +         {  sx = +1;
 239.446 +            t = (unsigned int)(+ x->val);
 239.447 +         }
 239.448 +         else
 239.449 +         {  sx = -1;
 239.450 +            t = (unsigned int)(- x->val);
 239.451 +         }
 239.452 +         ex = &dumx;
 239.453 +         ex->d[0] = (unsigned short)t;
 239.454 +         ex->d[1] = (unsigned short)(t >> 16);
 239.455 +         ex->d[2] = ex->d[3] = ex->d[4] = ex->d[5] = 0;
 239.456 +         ex->next = NULL;
 239.457 +      }
 239.458 +      else
 239.459 +      {  sx = x->val;
 239.460 +         xassert(sx == +1 || sx == -1);
 239.461 +         ex = x->ptr;
 239.462 +      }
 239.463 +      /* convert [y] to long format, if necessary */
 239.464 +      if (y->ptr == NULL)
 239.465 +      {  xassert(y->val != 0x80000000);
 239.466 +         if (y->val >= 0)
 239.467 +         {  sy = +1;
 239.468 +            t = (unsigned int)(+ y->val);
 239.469 +         }
 239.470 +         else
 239.471 +         {  sy = -1;
 239.472 +            t = (unsigned int)(- y->val);
 239.473 +         }
 239.474 +         ey = &dumy;
 239.475 +         ey->d[0] = (unsigned short)t;
 239.476 +         ey->d[1] = (unsigned short)(t >> 16);
 239.477 +         ey->d[2] = ey->d[3] = ey->d[4] = ey->d[5] = 0;
 239.478 +         ey->next = NULL;
 239.479 +      }
 239.480 +      else
 239.481 +      {  sy = y->val;
 239.482 +         xassert(sy == +1 || sy == -1);
 239.483 +         ey = y->ptr;
 239.484 +      }
 239.485 +      /* determine the number of digits of [x] */
 239.486 +      nx = n = 0;
 239.487 +      for (e = ex; e != NULL; e = e->next)
 239.488 +      for (k = 0; k <= 5; k++)
 239.489 +      {  n++;
 239.490 +         if (e->d[k]) nx = n;
 239.491 +      }
 239.492 +      xassert(nx > 0);
 239.493 +      /* determine the number of digits of [y] */
 239.494 +      ny = n = 0;
 239.495 +      for (e = ey; e != NULL; e = e->next)
 239.496 +      for (k = 0; k <= 5; k++)
 239.497 +      {  n++;
 239.498 +         if (e->d[k]) ny = n;
 239.499 +      }
 239.500 +      xassert(ny > 0);
 239.501 +      /* we need working array containing at least nx+ny+ny places */
 239.502 +      work = gmp_get_work(nx+ny+ny);
 239.503 +      /* load digits of [x] */
 239.504 +      wx = &work[0];
 239.505 +      for (n = 0; n < nx; n++) wx[ny+n] = 0;
 239.506 +      for (n = 0, e = ex; e != NULL; e = e->next)
 239.507 +         for (k = 0; k <= 5; k++, n++)
 239.508 +            if (e->d[k]) wx[ny+n] = e->d[k];
 239.509 +      /* load digits of [y] */
 239.510 +      wy = &work[nx+ny];
 239.511 +      for (n = 0; n < ny; n++) wy[n] = 0;
 239.512 +      for (n = 0, e = ey; e != NULL; e = e->next)
 239.513 +         for (k = 0; k <= 5; k++, n++)
 239.514 +            if (e->d[k]) wy[n] = e->d[k];
 239.515 +      /* compute [x] * [y] */
 239.516 +      bigmul(nx, ny, wx, wy);
 239.517 +      /* construct and normalize result */
 239.518 +      mpz_set_si(z, 0);
 239.519 +      z->val = sx * sy;
 239.520 +      es = NULL;
 239.521 +      k = 6;
 239.522 +      for (n = 0; n < nx+ny; n++)
 239.523 +      {  if (k > 5)
 239.524 +         {  e = gmp_get_atom(sizeof(struct mpz_seg));
 239.525 +            e->d[0] = e->d[1] = e->d[2] = 0;
 239.526 +            e->d[3] = e->d[4] = e->d[5] = 0;
 239.527 +            e->next = NULL;
 239.528 +            if (z->ptr == NULL)
 239.529 +               z->ptr = e;
 239.530 +            else
 239.531 +               es->next = e;
 239.532 +            es = e;
 239.533 +            k = 0;
 239.534 +         }
 239.535 +         es->d[k++] = wx[n];
 239.536 +      }
 239.537 +      normalize(z);
 239.538 +done: return;
 239.539 +}
 239.540 +
 239.541 +void mpz_neg(mpz_t z, mpz_t x)
 239.542 +{     /* set z to 0 - x */
 239.543 +      mpz_set(z, x);
 239.544 +      z->val = - z->val;
 239.545 +      return;
 239.546 +}
 239.547 +
 239.548 +void mpz_abs(mpz_t z, mpz_t x)
 239.549 +{     /* set z to the absolute value of x */
 239.550 +      mpz_set(z, x);
 239.551 +      if (z->val < 0) z->val = - z->val;
 239.552 +      return;
 239.553 +}
 239.554 +
 239.555 +void mpz_div(mpz_t q, mpz_t r, mpz_t x, mpz_t y)
 239.556 +{     /* divide x by y, forming quotient q and/or remainder r
 239.557 +         if q = NULL then quotient is not stored; if r = NULL then
 239.558 +         remainder is not stored
 239.559 +         the sign of quotient is determined as in algebra while the
 239.560 +         sign of remainder is the same as the sign of dividend:
 239.561 +         +26 : +7 = +3, remainder is +5
 239.562 +         -26 : +7 = -3, remainder is -5
 239.563 +         +26 : -7 = -3, remainder is +5
 239.564 +         -26 : -7 = +3, remainder is -5 */
 239.565 +      struct mpz_seg dumx, dumy, *ex, *ey, *es, *e;
 239.566 +      int sx, sy, k, nx, ny, n;
 239.567 +      unsigned int t;
 239.568 +      unsigned short *work, *wx, *wy;
 239.569 +      /* divide by zero is not allowed */
 239.570 +      if (y->val == 0)
 239.571 +      {  xassert(y->ptr == NULL);
 239.572 +         xfault("mpz_div: divide by zero not allowed\n");
 239.573 +      }
 239.574 +      /* if [x] = 0 then [q] = [r] = 0 */
 239.575 +      if (x->val == 0)
 239.576 +      {  xassert(x->ptr == NULL);
 239.577 +         if (q != NULL) mpz_set_si(q, 0);
 239.578 +         if (r != NULL) mpz_set_si(r, 0);
 239.579 +         goto done;
 239.580 +      }
 239.581 +      /* special case when both [x] and [y] are in short format */
 239.582 +      if (x->ptr == NULL && y->ptr == NULL)
 239.583 +      {  int xval = x->val, yval = y->val;
 239.584 +         xassert(xval != 0x80000000 && yval != 0x80000000);
 239.585 +         if (q != NULL) mpz_set_si(q, xval / yval);
 239.586 +         if (r != NULL) mpz_set_si(r, xval % yval);
 239.587 +         goto done;
 239.588 +      }
 239.589 +      /* convert [x] to long format, if necessary */
 239.590 +      if (x->ptr == NULL)
 239.591 +      {  xassert(x->val != 0x80000000);
 239.592 +         if (x->val >= 0)
 239.593 +         {  sx = +1;
 239.594 +            t = (unsigned int)(+ x->val);
 239.595 +         }
 239.596 +         else
 239.597 +         {  sx = -1;
 239.598 +            t = (unsigned int)(- x->val);
 239.599 +         }
 239.600 +         ex = &dumx;
 239.601 +         ex->d[0] = (unsigned short)t;
 239.602 +         ex->d[1] = (unsigned short)(t >> 16);
 239.603 +         ex->d[2] = ex->d[3] = ex->d[4] = ex->d[5] = 0;
 239.604 +         ex->next = NULL;
 239.605 +      }
 239.606 +      else
 239.607 +      {  sx = x->val;
 239.608 +         xassert(sx == +1 || sx == -1);
 239.609 +         ex = x->ptr;
 239.610 +      }
 239.611 +      /* convert [y] to long format, if necessary */
 239.612 +      if (y->ptr == NULL)
 239.613 +      {  xassert(y->val != 0x80000000);
 239.614 +         if (y->val >= 0)
 239.615 +         {  sy = +1;
 239.616 +            t = (unsigned int)(+ y->val);
 239.617 +         }
 239.618 +         else
 239.619 +         {  sy = -1;
 239.620 +            t = (unsigned int)(- y->val);
 239.621 +         }
 239.622 +         ey = &dumy;
 239.623 +         ey->d[0] = (unsigned short)t;
 239.624 +         ey->d[1] = (unsigned short)(t >> 16);
 239.625 +         ey->d[2] = ey->d[3] = ey->d[4] = ey->d[5] = 0;
 239.626 +         ey->next = NULL;
 239.627 +      }
 239.628 +      else
 239.629 +      {  sy = y->val;
 239.630 +         xassert(sy == +1 || sy == -1);
 239.631 +         ey = y->ptr;
 239.632 +      }
 239.633 +      /* determine the number of digits of [x] */
 239.634 +      nx = n = 0;
 239.635 +      for (e = ex; e != NULL; e = e->next)
 239.636 +      for (k = 0; k <= 5; k++)
 239.637 +      {  n++;
 239.638 +         if (e->d[k]) nx = n;
 239.639 +      }
 239.640 +      xassert(nx > 0);
 239.641 +      /* determine the number of digits of [y] */
 239.642 +      ny = n = 0;
 239.643 +      for (e = ey; e != NULL; e = e->next)
 239.644 +      for (k = 0; k <= 5; k++)
 239.645 +      {  n++;
 239.646 +         if (e->d[k]) ny = n;
 239.647 +      }
 239.648 +      xassert(ny > 0);
 239.649 +      /* if nx < ny then [q] = 0 and [r] = [x] */
 239.650 +      if (nx < ny)
 239.651 +      {  if (r != NULL) mpz_set(r, x);
 239.652 +         if (q != NULL) mpz_set_si(q, 0);
 239.653 +         goto done;
 239.654 +      }
 239.655 +      /* we need working array containing at least nx+ny+1 places */
 239.656 +      work = gmp_get_work(nx+ny+1);
 239.657 +      /* load digits of [x] */
 239.658 +      wx = &work[0];
 239.659 +      for (n = 0; n < nx; n++) wx[n] = 0;
 239.660 +      for (n = 0, e = ex; e != NULL; e = e->next)
 239.661 +         for (k = 0; k <= 5; k++, n++)
 239.662 +            if (e->d[k]) wx[n] = e->d[k];
 239.663 +      /* load digits of [y] */
 239.664 +      wy = &work[nx+1];
 239.665 +      for (n = 0; n < ny; n++) wy[n] = 0;
 239.666 +      for (n = 0, e = ey; e != NULL; e = e->next)
 239.667 +         for (k = 0; k <= 5; k++, n++)
 239.668 +            if (e->d[k]) wy[n] = e->d[k];
 239.669 +      /* compute quotient and remainder */
 239.670 +      xassert(wy[ny-1] != 0);
 239.671 +      bigdiv(nx-ny, ny, wx, wy);
 239.672 +      /* construct and normalize quotient */
 239.673 +      if (q != NULL)
 239.674 +      {  mpz_set_si(q, 0);
 239.675 +         q->val = sx * sy;
 239.676 +         es = NULL;
 239.677 +         k = 6;
 239.678 +         for (n = ny; n <= nx; n++)
 239.679 +         {  if (k > 5)
 239.680 +            {  e = gmp_get_atom(sizeof(struct mpz_seg));
 239.681 +               e->d[0] = e->d[1] = e->d[2] = 0;
 239.682 +               e->d[3] = e->d[4] = e->d[5] = 0;
 239.683 +               e->next = NULL;
 239.684 +               if (q->ptr == NULL)
 239.685 +                  q->ptr = e;
 239.686 +               else
 239.687 +                  es->next = e;
 239.688 +               es = e;
 239.689 +               k = 0;
 239.690 +            }
 239.691 +            es->d[k++] = wx[n];
 239.692 +         }
 239.693 +         normalize(q);
 239.694 +      }
 239.695 +      /* construct and normalize remainder */
 239.696 +      if (r != NULL)
 239.697 +      {  mpz_set_si(r, 0);
 239.698 +         r->val = sx;
 239.699 +         es = NULL;
 239.700 +         k = 6;
 239.701 +         for (n = 0; n < ny; n++)
 239.702 +         {  if (k > 5)
 239.703 +            {  e = gmp_get_atom(sizeof(struct mpz_seg));
 239.704 +               e->d[0] = e->d[1] = e->d[2] = 0;
 239.705 +               e->d[3] = e->d[4] = e->d[5] = 0;
 239.706 +               e->next = NULL;
 239.707 +               if (r->ptr == NULL)
 239.708 +                  r->ptr = e;
 239.709 +               else
 239.710 +                  es->next = e;
 239.711 +               es = e;
 239.712 +               k = 0;
 239.713 +            }
 239.714 +            es->d[k++] = wx[n];
 239.715 +         }
 239.716 +         normalize(r);
 239.717 +      }
 239.718 +done: return;
 239.719 +}
 239.720 +
 239.721 +void mpz_gcd(mpz_t z, mpz_t x, mpz_t y)
 239.722 +{     /* set z to the greatest common divisor of x and y */
 239.723 +      /* in case of arbitrary integers GCD(x, y) = GCD(|x|, |y|), and,
 239.724 +         in particular, GCD(0, 0) = 0 */
 239.725 +      mpz_t u, v, r;
 239.726 +      mpz_init(u);
 239.727 +      mpz_init(v);
 239.728 +      mpz_init(r);
 239.729 +      mpz_abs(u, x);
 239.730 +      mpz_abs(v, y);
 239.731 +      while (mpz_sgn(v))
 239.732 +      {  mpz_div(NULL, r, u, v);
 239.733 +         mpz_set(u, v);
 239.734 +         mpz_set(v, r);
 239.735 +      }
 239.736 +      mpz_set(z, u);
 239.737 +      mpz_clear(u);
 239.738 +      mpz_clear(v);
 239.739 +      mpz_clear(r);
 239.740 +      return;
 239.741 +}
 239.742 +
 239.743 +int mpz_cmp(mpz_t x, mpz_t y)
 239.744 +{     /* compare x and y; return a positive value if x > y, zero if
 239.745 +         x = y, or a nefative value if x < y */
 239.746 +      static struct mpz_seg zero = { { 0, 0, 0, 0, 0, 0 }, NULL };
 239.747 +      struct mpz_seg dumx, dumy, *ex, *ey;
 239.748 +      int cc, sx, sy, k;
 239.749 +      unsigned int t;
 239.750 +      if (x == y)
 239.751 +      {  cc = 0;
 239.752 +         goto done;
 239.753 +      }
 239.754 +      /* special case when both [x] and [y] are in short format */
 239.755 +      if (x->ptr == NULL && y->ptr == NULL)
 239.756 +      {  int xval = x->val, yval = y->val;
 239.757 +         xassert(xval != 0x80000000 && yval != 0x80000000);
 239.758 +         cc = (xval > yval ? +1 : xval < yval ? -1 : 0);
 239.759 +         goto done;
 239.760 +      }
 239.761 +      /* special case when [x] and [y] have different signs */
 239.762 +      if (x->val > 0 && y->val <= 0 || x->val == 0 && y->val < 0)
 239.763 +      {  cc = +1;
 239.764 +         goto done;
 239.765 +      }
 239.766 +      if (x->val < 0 && y->val >= 0 || x->val == 0 && y->val > 0)
 239.767 +      {  cc = -1;
 239.768 +         goto done;
 239.769 +      }
 239.770 +      /* convert [x] to long format, if necessary */
 239.771 +      if (x->ptr == NULL)
 239.772 +      {  xassert(x->val != 0x80000000);
 239.773 +         if (x->val >= 0)
 239.774 +         {  sx = +1;
 239.775 +            t = (unsigned int)(+ x->val);
 239.776 +         }
 239.777 +         else
 239.778 +         {  sx = -1;
 239.779 +            t = (unsigned int)(- x->val);
 239.780 +         }
 239.781 +         ex = &dumx;
 239.782 +         ex->d[0] = (unsigned short)t;
 239.783 +         ex->d[1] = (unsigned short)(t >> 16);
 239.784 +         ex->d[2] = ex->d[3] = ex->d[4] = ex->d[5] = 0;
 239.785 +         ex->next = NULL;
 239.786 +      }
 239.787 +      else
 239.788 +      {  sx = x->val;
 239.789 +         xassert(sx == +1 || sx == -1);
 239.790 +         ex = x->ptr;
 239.791 +      }
 239.792 +      /* convert [y] to long format, if necessary */
 239.793 +      if (y->ptr == NULL)
 239.794 +      {  xassert(y->val != 0x80000000);
 239.795 +         if (y->val >= 0)
 239.796 +         {  sy = +1;
 239.797 +            t = (unsigned int)(+ y->val);
 239.798 +         }
 239.799 +         else
 239.800 +         {  sy = -1;
 239.801 +            t = (unsigned int)(- y->val);
 239.802 +         }
 239.803 +         ey = &dumy;
 239.804 +         ey->d[0] = (unsigned short)t;
 239.805 +         ey->d[1] = (unsigned short)(t >> 16);
 239.806 +         ey->d[2] = ey->d[3] = ey->d[4] = ey->d[5] = 0;
 239.807 +         ey->next = NULL;
 239.808 +      }
 239.809 +      else
 239.810 +      {  sy = y->val;
 239.811 +         xassert(sy == +1 || sy == -1);
 239.812 +         ey = y->ptr;
 239.813 +      }
 239.814 +      /* main fragment */
 239.815 +      xassert(sx > 0 && sy > 0 || sx < 0 && sy < 0);
 239.816 +      cc = 0;
 239.817 +      for (; ex || ey; ex = ex->next, ey = ey->next)
 239.818 +      {  if (ex == NULL) ex = &zero;
 239.819 +         if (ey == NULL) ey = &zero;
 239.820 +         for (k = 0; k <= 5; k++)
 239.821 +         {  if (ex->d[k] > ey->d[k]) cc = +1;
 239.822 +            if (ex->d[k] < ey->d[k]) cc = -1;
 239.823 +         }
 239.824 +      }
 239.825 +      if (sx < 0) cc = - cc;
 239.826 +done: return cc;
 239.827 +}
 239.828 +
 239.829 +int mpz_sgn(mpz_t x)
 239.830 +{     /* return +1 if x > 0, 0 if x = 0, and -1 if x < 0 */
 239.831 +      int s;
 239.832 +      s = (x->val > 0 ? +1 : x->val < 0 ? -1 : 0);
 239.833 +      return s;
 239.834 +}
 239.835 +
 239.836 +int mpz_out_str(void *_fp, int base, mpz_t x)
 239.837 +{     /* output x on stream fp, as a string in given base; the base
 239.838 +         may vary from 2 to 36;
 239.839 +         return the number of bytes written, or if an error occurred,
 239.840 +         return 0 */
 239.841 +      FILE *fp = _fp;
 239.842 +      mpz_t b, y, r;
 239.843 +      int n, j, nwr = 0;
 239.844 +      unsigned char *d;
 239.845 +      static char *set = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";
 239.846 +      if (!(2 <= base && base <= 36))
 239.847 +         xfault("mpz_out_str: base = %d; invalid base\n", base);
 239.848 +      mpz_init(b);
 239.849 +      mpz_set_si(b, base);
 239.850 +      mpz_init(y);
 239.851 +      mpz_init(r);
 239.852 +      /* determine the number of digits */
 239.853 +      mpz_abs(y, x);
 239.854 +      for (n = 0; mpz_sgn(y) != 0; n++)
 239.855 +         mpz_div(y, NULL, y, b);
 239.856 +      if (n == 0) n = 1;
 239.857 +      /* compute the digits */
 239.858 +      d = xmalloc(n);
 239.859 +      mpz_abs(y, x);
 239.860 +      for (j = 0; j < n; j++)
 239.861 +      {  mpz_div(y, r, y, b);
 239.862 +         xassert(0 <= r->val && r->val < base && r->ptr == NULL);
 239.863 +         d[j] = (unsigned char)r->val;
 239.864 +      }
 239.865 +      /* output the integer to the stream */
 239.866 +      if (fp == NULL) fp = stdout;
 239.867 +      if (mpz_sgn(x) < 0)
 239.868 +         fputc('-', fp), nwr++;
 239.869 +      for (j = n-1; j >= 0; j--)
 239.870 +         fputc(set[d[j]], fp), nwr++;
 239.871 +      if (ferror(fp)) nwr = 0;
 239.872 +      mpz_clear(b);
 239.873 +      mpz_clear(y);
 239.874 +      mpz_clear(r);
 239.875 +      xfree(d);
 239.876 +      return nwr;
 239.877 +}
 239.878 +
 239.879 +/*====================================================================*/
 239.880 +
 239.881 +mpq_t _mpq_init(void)
 239.882 +{     /* initialize x, and set its value to 0/1 */
 239.883 +      mpq_t x;
 239.884 +      x = gmp_get_atom(sizeof(struct mpq));
 239.885 +      x->p.val = 0;
 239.886 +      x->p.ptr = NULL;
 239.887 +      x->q.val = 1;
 239.888 +      x->q.ptr = NULL;
 239.889 +      return x;
 239.890 +}
 239.891 +
 239.892 +void mpq_clear(mpq_t x)
 239.893 +{     /* free the space occupied by x */
 239.894 +      mpz_set_si(&x->p, 0);
 239.895 +      xassert(x->p.ptr == NULL);
 239.896 +      mpz_set_si(&x->q, 0);
 239.897 +      xassert(x->q.ptr == NULL);
 239.898 +      /* free the number descriptor */
 239.899 +      gmp_free_atom(x, sizeof(struct mpq));
 239.900 +      return;
 239.901 +}
 239.902 +
 239.903 +void mpq_canonicalize(mpq_t x)
 239.904 +{     /* remove any factors that are common to the numerator and
 239.905 +         denominator of x, and make the denominator positive */
 239.906 +      mpz_t f;
 239.907 +      xassert(x->q.val != 0);
 239.908 +      if (x->q.val < 0)
 239.909 +      {  mpz_neg(&x->p, &x->p);
 239.910 +         mpz_neg(&x->q, &x->q);
 239.911 +      }
 239.912 +      mpz_init(f);
 239.913 +      mpz_gcd(f, &x->p, &x->q);
 239.914 +      if (!(f->val == 1 && f->ptr == NULL))
 239.915 +      {  mpz_div(&x->p, NULL, &x->p, f);
 239.916 +         mpz_div(&x->q, NULL, &x->q, f);
 239.917 +      }
 239.918 +      mpz_clear(f);
 239.919 +      return;
 239.920 +}
 239.921 +
 239.922 +void mpq_set(mpq_t z, mpq_t x)
 239.923 +{     /* set the value of z from x */
 239.924 +      if (z != x)
 239.925 +      {  mpz_set(&z->p, &x->p);
 239.926 +         mpz_set(&z->q, &x->q);
 239.927 +      }
 239.928 +      return;
 239.929 +}
 239.930 +
 239.931 +void mpq_set_si(mpq_t x, int p, unsigned int q)
 239.932 +{     /* set the value of x to p/q */
 239.933 +      if (q == 0)
 239.934 +         xfault("mpq_set_si: zero denominator not allowed\n");
 239.935 +      mpz_set_si(&x->p, p);
 239.936 +      xassert(q <= 0x7FFFFFFF);
 239.937 +      mpz_set_si(&x->q, q);
 239.938 +      return;
 239.939 +}
 239.940 +
 239.941 +double mpq_get_d(mpq_t x)
 239.942 +{     /* convert x to a double, truncating if necessary */
 239.943 +      int np, nq;
 239.944 +      double p, q;
 239.945 +      p = mpz_get_d_2exp(&np, &x->p);
 239.946 +      q = mpz_get_d_2exp(&nq, &x->q);
 239.947 +      return ldexp(p / q, np - nq);
 239.948 +}
 239.949 +
 239.950 +void mpq_set_d(mpq_t x, double val)
 239.951 +{     /* set x to val; there is no rounding, the conversion is exact */
 239.952 +      int s, n, d, j;
 239.953 +      double f;
 239.954 +      mpz_t temp;
 239.955 +      xassert(-DBL_MAX <= val && val <= +DBL_MAX);
 239.956 +      mpq_set_si(x, 0, 1);
 239.957 +      if (val > 0.0)
 239.958 +         s = +1;
 239.959 +      else if (val < 0.0)
 239.960 +         s = -1;
 239.961 +      else
 239.962 +         goto done;
 239.963 +      f = frexp(fabs(val), &n);
 239.964 +      /* |val| = f * 2^n, where 0.5 <= f < 1.0 */
 239.965 +      mpz_init(temp);
 239.966 +      while (f != 0.0)
 239.967 +      {  f *= 16.0, n -= 4;
 239.968 +         d = (int)f;
 239.969 +         xassert(0 <= d && d <= 15);
 239.970 +         f -= (double)d;
 239.971 +         /* x := 16 * x + d */
 239.972 +         mpz_set_si(temp, 16);
 239.973 +         mpz_mul(&x->p, &x->p, temp);
 239.974 +         mpz_set_si(temp, d);
 239.975 +         mpz_add(&x->p, &x->p, temp);
 239.976 +      }
 239.977 +      mpz_clear(temp);
 239.978 +      /* x := x * 2^n */
 239.979 +      if (n > 0)
 239.980 +      {  for (j = 1; j <= n; j++)
 239.981 +            mpz_add(&x->p, &x->p, &x->p);
 239.982 +      }
 239.983 +      else if (n < 0)
 239.984 +      {  for (j = 1; j <= -n; j++)
 239.985 +            mpz_add(&x->q, &x->q, &x->q);
 239.986 +         mpq_canonicalize(x);
 239.987 +      }
 239.988 +      if (s < 0) mpq_neg(x, x);
 239.989 +done: return;
 239.990 +}
 239.991 +
 239.992 +void mpq_add(mpq_t z, mpq_t x, mpq_t y)
 239.993 +{     /* set z to x + y */
 239.994 +      mpz_t p, q;
 239.995 +      mpz_init(p);
 239.996 +      mpz_init(q);
 239.997 +      mpz_mul(p, &x->p, &y->q);
 239.998 +      mpz_mul(q, &x->q, &y->p);
 239.999 +      mpz_add(p, p, q);
239.1000 +      mpz_mul(q, &x->q, &y->q);
239.1001 +      mpz_set(&z->p, p);
239.1002 +      mpz_set(&z->q, q);
239.1003 +      mpz_clear(p);
239.1004 +      mpz_clear(q);
239.1005 +      mpq_canonicalize(z);
239.1006 +      return;
239.1007 +}
239.1008 +
239.1009 +void mpq_sub(mpq_t z, mpq_t x, mpq_t y)
239.1010 +{     /* set z to x - y */
239.1011 +      mpz_t p, q;
239.1012 +      mpz_init(p);
239.1013 +      mpz_init(q);
239.1014 +      mpz_mul(p, &x->p, &y->q);
239.1015 +      mpz_mul(q, &x->q, &y->p);
239.1016 +      mpz_sub(p, p, q);
239.1017 +      mpz_mul(q, &x->q, &y->q);
239.1018 +      mpz_set(&z->p, p);
239.1019 +      mpz_set(&z->q, q);
239.1020 +      mpz_clear(p);
239.1021 +      mpz_clear(q);
239.1022 +      mpq_canonicalize(z);
239.1023 +      return;
239.1024 +}
239.1025 +
239.1026 +void mpq_mul(mpq_t z, mpq_t x, mpq_t y)
239.1027 +{     /* set z to x * y */
239.1028 +      mpz_mul(&z->p, &x->p, &y->p);
239.1029 +      mpz_mul(&z->q, &x->q, &y->q);
239.1030 +      mpq_canonicalize(z);
239.1031 +      return;
239.1032 +}
239.1033 +
239.1034 +void mpq_div(mpq_t z, mpq_t x, mpq_t y)
239.1035 +{     /* set z to x / y */
239.1036 +      mpz_t p, q;
239.1037 +      if (mpq_sgn(y) == 0)
239.1038 +         xfault("mpq_div: zero divisor not allowed\n");
239.1039 +      mpz_init(p);
239.1040 +      mpz_init(q);
239.1041 +      mpz_mul(p, &x->p, &y->q);
239.1042 +      mpz_mul(q, &x->q, &y->p);
239.1043 +      mpz_set(&z->p, p);
239.1044 +      mpz_set(&z->q, q);
239.1045 +      mpz_clear(p);
239.1046 +      mpz_clear(q);
239.1047 +      mpq_canonicalize(z);
239.1048 +      return;
239.1049 +}
239.1050 +
239.1051 +void mpq_neg(mpq_t z, mpq_t x)
239.1052 +{     /* set z to 0 - x */
239.1053 +      mpq_set(z, x);
239.1054 +      mpz_neg(&z->p, &z->p);
239.1055 +      return;
239.1056 +}
239.1057 +
239.1058 +void mpq_abs(mpq_t z, mpq_t x)
239.1059 +{     /* set z to the absolute value of x */
239.1060 +      mpq_set(z, x);
239.1061 +      mpz_abs(&z->p, &z->p);
239.1062 +      xassert(mpz_sgn(&x->q) > 0);
239.1063 +      return;
239.1064 +}
239.1065 +
239.1066 +int mpq_cmp(mpq_t x, mpq_t y)
239.1067 +{     /* compare x and y; return a positive value if x > y, zero if
239.1068 +         x = y, or a nefative value if x < y */
239.1069 +      mpq_t temp;
239.1070 +      int s;
239.1071 +      mpq_init(temp);
239.1072 +      mpq_sub(temp, x, y);
239.1073 +      s = mpq_sgn(temp);
239.1074 +      mpq_clear(temp);
239.1075 +      return s;
239.1076 +}
239.1077 +
239.1078 +int mpq_sgn(mpq_t x)
239.1079 +{     /* return +1 if x > 0, 0 if x = 0, and -1 if x < 0 */
239.1080 +      int s;
239.1081 +      s = mpz_sgn(&x->p);
239.1082 +      xassert(mpz_sgn(&x->q) > 0);
239.1083 +      return s;
239.1084 +}
239.1085 +
239.1086 +int mpq_out_str(void *_fp, int base, mpq_t x)
239.1087 +{     /* output x on stream fp, as a string in given base; the base
239.1088 +         may vary from 2 to 36; output is in the form 'num/den' or if
239.1089 +         the denominator is 1 then just 'num';
239.1090 +         if the parameter fp is a null pointer, stdout is assumed;
239.1091 +         return the number of bytes written, or if an error occurred,
239.1092 +         return 0 */
239.1093 +      FILE *fp = _fp;
239.1094 +      int nwr;
239.1095 +      if (!(2 <= base && base <= 36))
239.1096 +         xfault("mpq_out_str: base = %d; invalid base\n", base);
239.1097 +      if (fp == NULL) fp = stdout;
239.1098 +      nwr = mpz_out_str(fp, base, &x->p);
239.1099 +      if (x->q.val == 1 && x->q.ptr == NULL)
239.1100 +         ;
239.1101 +      else
239.1102 +      {  fputc('/', fp), nwr++;
239.1103 +         nwr += mpz_out_str(fp, base, &x->q);
239.1104 +      }
239.1105 +      if (ferror(fp)) nwr = 0;
239.1106 +      return nwr;
239.1107 +}
239.1108 +
239.1109 +#endif
239.1110 +
239.1111 +/* eof */
   240.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
   240.2 +++ b/deps/glpk/src/glpgmp.h	Sun Nov 06 20:59:10 2011 +0100
   240.3 @@ -0,0 +1,190 @@
   240.4 +/* glpgmp.h (bignum arithmetic) */
   240.5 +
   240.6 +/***********************************************************************
   240.7 +*  This code is part of GLPK (GNU Linear Programming Kit).
   240.8 +*
   240.9 +*  Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008,
  240.10 +*  2009, 2010, 2011 Andrew Makhorin, Department for Applied Informatics,
  240.11 +*  Moscow Aviation Institute, Moscow, Russia. All rights reserved.
  240.12 +*  E-mail: <mao@gnu.org>.
  240.13 +*
  240.14 +*  GLPK is free software: you can redistribute it and/or modify it
  240.15 +*  under the terms of the GNU General Public License as published by
  240.16 +*  the Free Software Foundation, either version 3 of the License, or
  240.17 +*  (at your option) any later version.
  240.18 +*
  240.19 +*  GLPK is distributed in the hope that it will be useful, but WITHOUT
  240.20 +*  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
  240.21 +*  or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
  240.22 +*  License for more details.
  240.23 +*
  240.24 +*  You should have received a copy of the GNU General Public License
  240.25 +*  along with GLPK. If not, see <http://www.gnu.org/licenses/>.
  240.26 +***********************************************************************/
  240.27 +
  240.28 +#ifndef GLPGMP_H
  240.29 +#define GLPGMP_H
  240.30 +
  240.31 +#ifdef HAVE_CONFIG_H
  240.32 +#include <config.h>
  240.33 +#endif
  240.34 +
  240.35 +#ifdef HAVE_GMP               /* use GNU MP bignum library */
  240.36 +
  240.37 +#include <gmp.h>
  240.38 +
  240.39 +#define gmp_pool_count        _glp_gmp_pool_count
  240.40 +#define gmp_free_mem          _glp_gmp_free_mem
  240.41 +
  240.42 +int gmp_pool_count(void);
  240.43 +void gmp_free_mem(void);
  240.44 +
  240.45 +#else                         /* use GLPK bignum module */
  240.46 +
  240.47 +/*----------------------------------------------------------------------
  240.48 +// INTEGER NUMBERS
  240.49 +//
  240.50 +// Depending on its magnitude an integer number of arbitrary precision
  240.51 +// is represented either in short format or in long format.
  240.52 +//
  240.53 +// Short format corresponds to the int type and allows representing
  240.54 +// integer numbers in the range [-(2^31-1), +(2^31-1)]. Note that for
  240.55 +// the most negative number of int type the short format is not used.
  240.56 +//
  240.57 +// In long format integer numbers are represented using the positional
  240.58 +// system with the base (radix) 2^16 = 65536:
  240.59 +//
  240.60 +//    x = (-1)^s sum{j in 0..n-1} d[j] * 65536^j,
  240.61 +//
  240.62 +// where x is the integer to be represented, s is its sign (+1 or -1),
  240.63 +// d[j] are its digits (0 <= d[j] <= 65535).
  240.64 +//
  240.65 +// RATIONAL NUMBERS
  240.66 +//
  240.67 +// A rational number is represented as an irreducible fraction:
  240.68 +//
  240.69 +//    p / q,
  240.70 +//
  240.71 +// where p (numerator) and q (denominator) are integer numbers (q > 0)
  240.72 +// having no common divisors. */
  240.73 +
  240.74 +struct mpz
  240.75 +{     /* integer number */
  240.76 +      int val;
  240.77 +      /* if ptr is a null pointer, the number is in short format, and
  240.78 +         val is its value; otherwise, the number is in long format, and
  240.79 +         val is its sign (+1 or -1) */
  240.80 +      struct mpz_seg *ptr;
  240.81 +      /* pointer to the linked list of the number segments ordered in
  240.82 +         ascending of powers of the base */
  240.83 +};
  240.84 +
  240.85 +struct mpz_seg
  240.86 +{     /* integer number segment */
  240.87 +      unsigned short d[6];
  240.88 +      /* six digits of the number ordered in ascending of powers of the
  240.89 +         base */
  240.90 +      struct mpz_seg *next;
  240.91 +      /* pointer to the next number segment */
  240.92 +};
  240.93 +
  240.94 +struct mpq
  240.95 +{     /* rational number (p / q) */
  240.96 +      struct mpz p;
  240.97 +      /* numerator */
  240.98 +      struct mpz q;
  240.99 +      /* denominator */
 240.100 +};
 240.101 +
 240.102 +typedef struct mpz *mpz_t;
 240.103 +typedef struct mpq *mpq_t;
 240.104 +
 240.105 +#define gmp_get_atom          _glp_gmp_get_atom
 240.106 +#define gmp_free_atom         _glp_gmp_free_atom
 240.107 +#define gmp_pool_count        _glp_gmp_pool_count
 240.108 +#define gmp_get_work          _glp_gmp_get_work
 240.109 +#define gmp_free_mem          _glp_gmp_free_mem
 240.110 +
 240.111 +#define _mpz_init             _glp_mpz_init
 240.112 +#define mpz_clear             _glp_mpz_clear
 240.113 +#define mpz_set               _glp_mpz_set
 240.114 +#define mpz_set_si            _glp_mpz_set_si
 240.115 +#define mpz_get_d             _glp_mpz_get_d
 240.116 +#define mpz_get_d_2exp        _glp_mpz_get_d_2exp
 240.117 +#define mpz_swap              _glp_mpz_swap
 240.118 +#define mpz_add               _glp_mpz_add
 240.119 +#define mpz_sub               _glp_mpz_sub
 240.120 +#define mpz_mul               _glp_mpz_mul
 240.121 +#define mpz_neg               _glp_mpz_neg
 240.122 +#define mpz_abs               _glp_mpz_abs
 240.123 +#define mpz_div               _glp_mpz_div
 240.124 +#define mpz_gcd               _glp_mpz_gcd
 240.125 +#define mpz_cmp               _glp_mpz_cmp
 240.126 +#define mpz_sgn               _glp_mpz_sgn
 240.127 +#define mpz_out_str           _glp_mpz_out_str
 240.128 +
 240.129 +#define _mpq_init             _glp_mpq_init
 240.130 +#define mpq_clear             _glp_mpq_clear
 240.131 +#define mpq_canonicalize      _glp_mpq_canonicalize
 240.132 +#define mpq_set               _glp_mpq_set
 240.133 +#define mpq_set_si            _glp_mpq_set_si
 240.134 +#define mpq_get_d             _glp_mpq_get_d
 240.135 +#define mpq_set_d             _glp_mpq_set_d
 240.136 +#define mpq_add               _glp_mpq_add
 240.137 +#define mpq_sub               _glp_mpq_sub
 240.138 +#define mpq_mul               _glp_mpq_mul
 240.139 +#define mpq_div               _glp_mpq_div
 240.140 +#define mpq_neg               _glp_mpq_neg
 240.141 +#define mpq_abs               _glp_mpq_abs
 240.142 +#define mpq_cmp               _glp_mpq_cmp
 240.143 +#define mpq_sgn               _glp_mpq_sgn
 240.144 +#define mpq_out_str           _glp_mpq_out_str
 240.145 +
 240.146 +void *gmp_get_atom(int size);
 240.147 +void gmp_free_atom(void *ptr, int size);
 240.148 +int gmp_pool_count(void);
 240.149 +unsigned short *gmp_get_work(int size);
 240.150 +void gmp_free_mem(void);
 240.151 +
 240.152 +mpz_t _mpz_init(void);
 240.153 +#define mpz_init(x) (void)((x) = _mpz_init())
 240.154 +void mpz_clear(mpz_t x);
 240.155 +void mpz_set(mpz_t z, mpz_t x);
 240.156 +void mpz_set_si(mpz_t x, int val);
 240.157 +double mpz_get_d(mpz_t x);
 240.158 +double mpz_get_d_2exp(int *exp, mpz_t x);
 240.159 +void mpz_swap(mpz_t x, mpz_t y);
 240.160 +void mpz_add(mpz_t, mpz_t, mpz_t);
 240.161 +void mpz_sub(mpz_t, mpz_t, mpz_t);
 240.162 +void mpz_mul(mpz_t, mpz_t, mpz_t);
 240.163 +void mpz_neg(mpz_t z, mpz_t x);
 240.164 +void mpz_abs(mpz_t z, mpz_t x);
 240.165 +void mpz_div(mpz_t q, mpz_t r, mpz_t x, mpz_t y);
 240.166 +void mpz_gcd(mpz_t z, mpz_t x, mpz_t y);
 240.167 +int mpz_cmp(mpz_t x, mpz_t y);
 240.168 +int mpz_sgn(mpz_t x);
 240.169 +int mpz_out_str(void *fp, int base, mpz_t x);
 240.170 +
 240.171 +mpq_t _mpq_init(void);
 240.172 +#define mpq_init(x) (void)((x) = _mpq_init())
 240.173 +void mpq_clear(mpq_t x);
 240.174 +void mpq_canonicalize(mpq_t x);
 240.175 +void mpq_set(mpq_t z, mpq_t x);
 240.176 +void mpq_set_si(mpq_t x, int p, unsigned int q);
 240.177 +double mpq_get_d(mpq_t x);
 240.178 +void mpq_set_d(mpq_t x, double val);
 240.179 +void mpq_add(mpq_t z, mpq_t x, mpq_t y);
 240.180 +void mpq_sub(mpq_t z, mpq_t x, mpq_t y);
 240.181 +void mpq_mul(mpq_t z, mpq_t x, mpq_t y);
 240.182 +void mpq_div(mpq_t z, mpq_t x, mpq_t y);
 240.183 +void mpq_neg(mpq_t z, mpq_t x);
 240.184 +void mpq_abs(mpq_t z, mpq_t x);
 240.185 +int mpq_cmp(mpq_t x, mpq_t y);
 240.186 +int mpq_sgn(mpq_t x);
 240.187 +int mpq_out_str(void *fp, int base, mpq_t x);
 240.188 +
 240.189 +#endif
 240.190 +
 240.191 +#endif
 240.192 +
 240.193 +/* eof */
   241.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
   241.2 +++ b/deps/glpk/src/glphbm.c	Sun Nov 06 20:59:10 2011 +0100
   241.3 @@ -0,0 +1,519 @@
   241.4 +/* glphbm.c */
   241.5 +
   241.6 +/***********************************************************************
   241.7 +*  This code is part of GLPK (GNU Linear Programming Kit).
   241.8 +*
   241.9 +*  Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008,
  241.10 +*  2009, 2010, 2011 Andrew Makhorin, Department for Applied Informatics,
  241.11 +*  Moscow Aviation Institute, Moscow, Russia. All rights reserved.
  241.12 +*  E-mail: <mao@gnu.org>.
  241.13 +*
  241.14 +*  GLPK is free software: you can redistribute it and/or modify it
  241.15 +*  under the terms of the GNU General Public License as published by
  241.16 +*  the Free Software Foundation, either version 3 of the License, or
  241.17 +*  (at your option) any later version.
  241.18 +*
  241.19 +*  GLPK is distributed in the hope that it will be useful, but WITHOUT
  241.20 +*  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
  241.21 +*  or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
  241.22 +*  License for more details.
  241.23 +*
  241.24 +*  You should have received a copy of the GNU General Public License
  241.25 +*  along with GLPK. If not, see <http://www.gnu.org/licenses/>.
  241.26 +***********************************************************************/
  241.27 +
  241.28 +#define _GLPSTD_ERRNO
  241.29 +#define _GLPSTD_STDIO
  241.30 +#include "glphbm.h"
  241.31 +#include "glpenv.h"
  241.32 +
  241.33 +/***********************************************************************
  241.34 +*  NAME
  241.35 +*
  241.36 +*  hbm_read_mat - read sparse matrix in Harwell-Boeing format
  241.37 +*
  241.38 +*  SYNOPSIS
  241.39 +*
  241.40 +*  #include "glphbm.h"
  241.41 +*  HBM *hbm_read_mat(const char *fname);
  241.42 +*
  241.43 +*  DESCRIPTION
  241.44 +*
  241.45 +*  The routine hbm_read_mat reads a sparse matrix in the Harwell-Boeing
  241.46 +*  format from a text file whose name is the character string fname.
  241.47 +*
  241.48 +*  Detailed description of the Harwell-Boeing format recognised by this
  241.49 +*  routine is given in the following report:
  241.50 +*
  241.51 +*  I.S.Duff, R.G.Grimes, J.G.Lewis. User's Guide for the Harwell-Boeing
  241.52 +*  Sparse Matrix Collection (Release I), TR/PA/92/86, October 1992.
  241.53 +*
  241.54 +*  RETURNS
  241.55 +*
  241.56 +*  If no error occured, the routine hbm_read_mat returns a pointer to
  241.57 +*  a data structure containing the matrix. In case of error the routine
  241.58 +*  prints an appropriate error message and returns NULL. */
  241.59 +
  241.60 +struct dsa
  241.61 +{     /* working area used by routine hbm_read_mat */
  241.62 +      const char *fname;
  241.63 +      /* name of input text file */
  241.64 +      FILE *fp;
  241.65 +      /* stream assigned to input text file */
  241.66 +      int seqn;
  241.67 +      /* card sequential number */
  241.68 +      char card[80+1];
  241.69 +      /* card image buffer */
  241.70 +      int fmt_p;
  241.71 +      /* scale factor */
  241.72 +      int fmt_k;
  241.73 +      /* iterator */
  241.74 +      int fmt_f;
  241.75 +      /* format code */
  241.76 +      int fmt_w;
  241.77 +      /* field width */
  241.78 +      int fmt_d;
  241.79 +      /* number of decimal places after point */
  241.80 +};
  241.81 +
  241.82 +/***********************************************************************
  241.83 +*  read_card - read next data card
  241.84 +*
  241.85 +*  This routine reads the next 80-column card from the input text file
  241.86 +*  and stores its image into the character string card. If the card was
  241.87 +*  read successfully, the routine returns zero, otherwise non-zero. */
  241.88 +
  241.89 +static int read_card(struct dsa *dsa)
  241.90 +{     int k, c;
  241.91 +      dsa->seqn++;
  241.92 +      memset(dsa->card, ' ', 80), dsa->card[80] = '\0';
  241.93 +      k = 0;
  241.94 +      for (;;)
  241.95 +      {  c = fgetc(dsa->fp);
  241.96 +         if (ferror(dsa->fp))
  241.97 +         {  xprintf("%s:%d: read error - %s\n", dsa->fname, dsa->seqn,
  241.98 +               strerror(errno));
  241.99 +            return 1;
 241.100 +         }
 241.101 +         if (feof(dsa->fp))
 241.102 +         {  if (k == 0)
 241.103 +               xprintf("%s:%d: unexpected EOF\n", dsa->fname,
 241.104 +                  dsa->seqn);
 241.105 +            else
 241.106 +               xprintf("%s:%d: missing final LF\n", dsa->fname,
 241.107 +                  dsa->seqn);
 241.108 +            return 1;
 241.109 +         }
 241.110 +         if (c == '\r') continue;
 241.111 +         if (c == '\n') break;
 241.112 +         if (iscntrl(c))
 241.113 +         {  xprintf("%s:%d: invalid control character 0x%02X\n",
 241.114 +               dsa->fname, dsa->seqn, c);
 241.115 +            return 1;
 241.116 +         }
 241.117 +         if (k == 80)
 241.118 +         {  xprintf("%s:%d: card image too long\n", dsa->fname,
 241.119 +               dsa->seqn);
 241.120 +            return 1;
 241.121 +         }
 241.122 +         dsa->card[k++] = (char)c;
 241.123 +      }
 241.124 +      return 0;
 241.125 +}
 241.126 +
 241.127 +/***********************************************************************
 241.128 +*  scan_int - scan integer value from the current card
 241.129 +*
 241.130 +*  This routine scans an integer value from the current card, where fld
 241.131 +*  is the name of the field, pos is the position of the field, width is
 241.132 +*  the width of the field, val points to a location to which the scanned
 241.133 +*  value should be stored. If the value was scanned successfully, the
 241.134 +*  routine returns zero, otherwise non-zero. */
 241.135 +
 241.136 +static int scan_int(struct dsa *dsa, char *fld, int pos, int width,
 241.137 +      int *val)
 241.138 +{     char str[80+1];
 241.139 +      xassert(1 <= width && width <= 80);
 241.140 +      memcpy(str, dsa->card + pos, width), str[width] = '\0';
 241.141 +      if (str2int(strspx(str), val))
 241.142 +      {  xprintf("%s:%d: field `%s' contains invalid value `%s'\n",
 241.143 +            dsa->fname, dsa->seqn, fld, str);
 241.144 +         return 1;
 241.145 +      }
 241.146 +      return 0;
 241.147 +}
 241.148 +
 241.149 +/***********************************************************************
 241.150 +*  parse_fmt - parse Fortran format specification
 241.151 +*
 241.152 +*  This routine parses the Fortran format specification represented as
 241.153 +*  character string which fmt points to and stores format elements into
 241.154 +*  appropriate static locations. Should note that not all valid Fortran
 241.155 +*  format specifications may be recognised. If the format specification
 241.156 +*  was recognised, the routine returns zero, otherwise non-zero. */
 241.157 +
 241.158 +static int parse_fmt(struct dsa *dsa, char *fmt)
 241.159 +{     int k, s, val;
 241.160 +      char str[80+1];
 241.161 +      /* first character should be left parenthesis */
 241.162 +      if (fmt[0] != '(')
 241.163 +fail: {  xprintf("hbm_read_mat: format `%s' not recognised\n", fmt);
 241.164 +         return 1;
 241.165 +      }
 241.166 +      k = 1;
 241.167 +      /* optional scale factor */
 241.168 +      dsa->fmt_p = 0;
 241.169 +      if (isdigit((unsigned char)fmt[k]))
 241.170 +      {  s = 0;
 241.171 +         while (isdigit((unsigned char)fmt[k]))
 241.172 +         {  if (s == 80) goto fail;
 241.173 +            str[s++] = fmt[k++];
 241.174 +         }
 241.175 +         str[s] = '\0';
 241.176 +         if (str2int(str, &val)) goto fail;
 241.177 +         if (toupper((unsigned char)fmt[k]) != 'P') goto iter;
 241.178 +         dsa->fmt_p = val, k++;
 241.179 +         if (!(0 <= dsa->fmt_p && dsa->fmt_p <= 255)) goto fail;
 241.180 +         /* optional comma may follow scale factor */
 241.181 +         if (fmt[k] == ',') k++;
 241.182 +      }
 241.183 +      /* optional iterator */
 241.184 +      dsa->fmt_k = 1;
 241.185 +      if (isdigit((unsigned char)fmt[k]))
 241.186 +      {  s = 0;
 241.187 +         while (isdigit((unsigned char)fmt[k]))
 241.188 +         {  if (s == 80) goto fail;
 241.189 +            str[s++] = fmt[k++];
 241.190 +         }
 241.191 +         str[s] = '\0';
 241.192 +         if (str2int(str, &val)) goto fail;
 241.193 +iter:    dsa->fmt_k = val;
 241.194 +         if (!(1 <= dsa->fmt_k && dsa->fmt_k <= 255)) goto fail;
 241.195 +      }
 241.196 +      /* format code */
 241.197 +      dsa->fmt_f = toupper((unsigned char)fmt[k++]);
 241.198 +      if (!(dsa->fmt_f == 'D' || dsa->fmt_f == 'E' ||
 241.199 +            dsa->fmt_f == 'F' || dsa->fmt_f == 'G' ||
 241.200 +            dsa->fmt_f == 'I')) goto fail;
 241.201 +      /* field width */
 241.202 +      if (!isdigit((unsigned char)fmt[k])) goto fail;
 241.203 +      s = 0;
 241.204 +      while (isdigit((unsigned char)fmt[k]))
 241.205 +      {  if (s == 80) goto fail;
 241.206 +         str[s++] = fmt[k++];
 241.207 +      }
 241.208 +      str[s] = '\0';
 241.209 +      if (str2int(str, &dsa->fmt_w)) goto fail;
 241.210 +      if (!(1 <= dsa->fmt_w && dsa->fmt_w <= 255)) goto fail;
 241.211 +      /* optional number of decimal places after point */
 241.212 +      dsa->fmt_d = 0;
 241.213 +      if (fmt[k] == '.')
 241.214 +      {  k++;
 241.215 +         if (!isdigit((unsigned char)fmt[k])) goto fail;
 241.216 +         s = 0;
 241.217 +         while (isdigit((unsigned char)fmt[k]))
 241.218 +         {  if (s == 80) goto fail;
 241.219 +            str[s++] = fmt[k++];
 241.220 +         }
 241.221 +         str[s] = '\0';
 241.222 +         if (str2int(str, &dsa->fmt_d)) goto fail;
 241.223 +         if (!(0 <= dsa->fmt_d && dsa->fmt_d <= 255)) goto fail;
 241.224 +      }
 241.225 +      /* last character should be right parenthesis */
 241.226 +      if (!(fmt[k] == ')' && fmt[k+1] == '\0')) goto fail;
 241.227 +      return 0;
 241.228 +}
 241.229 +
 241.230 +/***********************************************************************
 241.231 +*  read_int_array - read array of integer type
 241.232 +*
 241.233 +*  This routine reads an integer array from the input text file, where
 241.234 +*  name is array name, fmt is Fortran format specification that controls
 241.235 +*  reading, n is number of array elements, val is array of integer type.
 241.236 +*  If the array was read successful, the routine returns zero, otherwise
 241.237 +*  non-zero. */
 241.238 +
 241.239 +static int read_int_array(struct dsa *dsa, char *name, char *fmt,
 241.240 +      int n, int val[])
 241.241 +{     int k, pos;
 241.242 +      char str[80+1];
 241.243 +      if (parse_fmt(dsa, fmt)) return 1;
 241.244 +      if (!(dsa->fmt_f == 'I' && dsa->fmt_w <= 80 &&
 241.245 +            dsa->fmt_k * dsa->fmt_w <= 80))
 241.246 +      {  xprintf(
 241.247 +            "%s:%d: can't read array `%s' - invalid format `%s'\n",
 241.248 +            dsa->fname, dsa->seqn, name, fmt);
 241.249 +         return 1;
 241.250 +      }
 241.251 +      for (k = 1, pos = INT_MAX; k <= n; k++, pos++)
 241.252 +      {  if (pos >= dsa->fmt_k)
 241.253 +         {  if (read_card(dsa)) return 1;
 241.254 +            pos = 0;
 241.255 +         }
 241.256 +         memcpy(str, dsa->card + dsa->fmt_w * pos, dsa->fmt_w);
 241.257 +         str[dsa->fmt_w] = '\0';
 241.258 +         strspx(str);
 241.259 +         if (str2int(str, &val[k]))
 241.260 +         {  xprintf(
 241.261 +               "%s:%d: can't read array `%s' - invalid value `%s'\n",
 241.262 +               dsa->fname, dsa->seqn, name, str);
 241.263 +            return 1;
 241.264 +         }
 241.265 +      }
 241.266 +      return 0;
 241.267 +}
 241.268 +
 241.269 +/***********************************************************************
 241.270 +*  read_real_array - read array of real type
 241.271 +*
 241.272 +*  This routine reads a real array from the input text file, where name
 241.273 +*  is array name, fmt is Fortran format specification that controls
 241.274 +*  reading, n is number of array elements, val is array of real type.
 241.275 +*  If the array was read successful, the routine returns zero, otherwise
 241.276 +*  non-zero. */
 241.277 +
 241.278 +static int read_real_array(struct dsa *dsa, char *name, char *fmt,
 241.279 +      int n, double val[])
 241.280 +{     int k, pos;
 241.281 +      char str[80+1], *ptr;
 241.282 +      if (parse_fmt(dsa, fmt)) return 1;
 241.283 +      if (!(dsa->fmt_f != 'I' && dsa->fmt_w <= 80 &&
 241.284 +            dsa->fmt_k * dsa->fmt_w <= 80))
 241.285 +      {  xprintf(
 241.286 +            "%s:%d: can't read array `%s' - invalid format `%s'\n",
 241.287 +            dsa->fname, dsa->seqn, name, fmt);
 241.288 +         return 1;
 241.289 +      }
 241.290 +      for (k = 1, pos = INT_MAX; k <= n; k++, pos++)
 241.291 +      {  if (pos >= dsa->fmt_k)
 241.292 +         {  if (read_card(dsa)) return 1;
 241.293 +            pos = 0;
 241.294 +         }
 241.295 +         memcpy(str, dsa->card + dsa->fmt_w * pos, dsa->fmt_w);
 241.296 +         str[dsa->fmt_w] = '\0';
 241.297 +         strspx(str);
 241.298 +         if (strchr(str, '.') == NULL && strcmp(str, "0"))
 241.299 +         {  xprintf("%s(%d): can't read array `%s' - value `%s' has no "
 241.300 +               "decimal point\n", dsa->fname, dsa->seqn, name, str);
 241.301 +            return 1;
 241.302 +         }
 241.303 +         /* sometimes lower case letters appear */
 241.304 +         for (ptr = str; *ptr; ptr++)
 241.305 +            *ptr = (char)toupper((unsigned char)*ptr);
 241.306 +         ptr = strchr(str, 'D');
 241.307 +         if (ptr != NULL) *ptr = 'E';
 241.308 +         /* value may appear with decimal exponent but without letters
 241.309 +            E or D (for example, -123.456-012), so missing letter should
 241.310 +            be inserted */
 241.311 +         ptr = strchr(str+1, '+');
 241.312 +         if (ptr == NULL) ptr = strchr(str+1, '-');
 241.313 +         if (ptr != NULL && *(ptr-1) != 'E')
 241.314 +         {  xassert(strlen(str) < 80);
 241.315 +            memmove(ptr+1, ptr, strlen(ptr)+1);
 241.316 +            *ptr = 'E';
 241.317 +         }
 241.318 +         if (str2num(str, &val[k]))
 241.319 +         {  xprintf(
 241.320 +               "%s:%d: can't read array `%s' - invalid value `%s'\n",
 241.321 +               dsa->fname, dsa->seqn, name, str);
 241.322 +            return 1;
 241.323 +         }
 241.324 +      }
 241.325 +      return 0;
 241.326 +}
 241.327 +
 241.328 +HBM *hbm_read_mat(const char *fname)
 241.329 +{     struct dsa _dsa, *dsa = &_dsa;
 241.330 +      HBM *hbm = NULL;
 241.331 +      dsa->fname = fname;
 241.332 +      xprintf("hbm_read_mat: reading matrix from `%s'...\n",
 241.333 +         dsa->fname);
 241.334 +      dsa->fp = fopen(dsa->fname, "r");
 241.335 +      if (dsa->fp == NULL)
 241.336 +      {  xprintf("hbm_read_mat: unable to open `%s' - %s\n",
 241.337 +            dsa->fname, strerror(errno));
 241.338 +         goto fail;
 241.339 +      }
 241.340 +      dsa->seqn = 0;
 241.341 +      hbm = xmalloc(sizeof(HBM));
 241.342 +      memset(hbm, 0, sizeof(HBM));
 241.343 +      /* read the first heading card */
 241.344 +      if (read_card(dsa)) goto fail;
 241.345 +      memcpy(hbm->title, dsa->card, 72), hbm->title[72] = '\0';
 241.346 +      strtrim(hbm->title);
 241.347 +      xprintf("%s\n", hbm->title);
 241.348 +      memcpy(hbm->key, dsa->card+72, 8), hbm->key[8] = '\0';
 241.349 +      strspx(hbm->key);
 241.350 +      xprintf("key = %s\n", hbm->key);
 241.351 +      /* read the second heading card */
 241.352 +      if (read_card(dsa)) goto fail;
 241.353 +      if (scan_int(dsa, "totcrd",  0, 14, &hbm->totcrd)) goto fail;
 241.354 +      if (scan_int(dsa, "ptrcrd", 14, 14, &hbm->ptrcrd)) goto fail;
 241.355 +      if (scan_int(dsa, "indcrd", 28, 14, &hbm->indcrd)) goto fail;
 241.356 +      if (scan_int(dsa, "valcrd", 42, 14, &hbm->valcrd)) goto fail;
 241.357 +      if (scan_int(dsa, "rhscrd", 56, 14, &hbm->rhscrd)) goto fail;
 241.358 +      xprintf("totcrd = %d; ptrcrd = %d; indcrd = %d; valcrd = %d; rhsc"
 241.359 +         "rd = %d\n", hbm->totcrd, hbm->ptrcrd, hbm->indcrd,
 241.360 +         hbm->valcrd, hbm->rhscrd);
 241.361 +      /* read the third heading card */
 241.362 +      if (read_card(dsa)) goto fail;
 241.363 +      memcpy(hbm->mxtype, dsa->card, 3), hbm->mxtype[3] = '\0';
 241.364 +      if (strchr("RCP",   hbm->mxtype[0]) == NULL ||
 241.365 +          strchr("SUHZR", hbm->mxtype[1]) == NULL ||
 241.366 +          strchr("AE",    hbm->mxtype[2]) == NULL)
 241.367 +      {  xprintf("%s:%d: matrix type `%s' not recognised\n",
 241.368 +            dsa->fname, dsa->seqn, hbm->mxtype);
 241.369 +         goto fail;
 241.370 +      }
 241.371 +      if (scan_int(dsa, "nrow", 14, 14, &hbm->nrow)) goto fail;
 241.372 +      if (scan_int(dsa, "ncol", 28, 14, &hbm->ncol)) goto fail;
 241.373 +      if (scan_int(dsa, "nnzero", 42, 14, &hbm->nnzero)) goto fail;
 241.374 +      if (scan_int(dsa, "neltvl", 56, 14, &hbm->neltvl)) goto fail;
 241.375 +      xprintf("mxtype = %s; nrow = %d; ncol = %d; nnzero = %d; neltvl ="
 241.376 +         " %d\n", hbm->mxtype, hbm->nrow, hbm->ncol, hbm->nnzero,
 241.377 +         hbm->neltvl);
 241.378 +      /* read the fourth heading card */
 241.379 +      if (read_card(dsa)) goto fail;
 241.380 +      memcpy(hbm->ptrfmt, dsa->card, 16), hbm->ptrfmt[16] = '\0';
 241.381 +      strspx(hbm->ptrfmt);
 241.382 +      memcpy(hbm->indfmt, dsa->card+16, 16), hbm->indfmt[16] = '\0';
 241.383 +      strspx(hbm->indfmt);
 241.384 +      memcpy(hbm->valfmt, dsa->card+32, 20), hbm->valfmt[20] = '\0';
 241.385 +      strspx(hbm->valfmt);
 241.386 +      memcpy(hbm->rhsfmt, dsa->card+52, 20), hbm->rhsfmt[20] = '\0';
 241.387 +      strspx(hbm->rhsfmt);
 241.388 +      xprintf("ptrfmt = %s; indfmt = %s; valfmt = %s; rhsfmt = %s\n",
 241.389 +         hbm->ptrfmt, hbm->indfmt, hbm->valfmt, hbm->rhsfmt);
 241.390 +      /* read the fifth heading card (optional) */
 241.391 +      if (hbm->rhscrd <= 0)
 241.392 +      {  strcpy(hbm->rhstyp, "???");
 241.393 +         hbm->nrhs = 0;
 241.394 +         hbm->nrhsix = 0;
 241.395 +      }
 241.396 +      else
 241.397 +      {  if (read_card(dsa)) goto fail;
 241.398 +         memcpy(hbm->rhstyp, dsa->card, 3), hbm->rhstyp[3] = '\0';
 241.399 +         if (scan_int(dsa, "nrhs", 14, 14, &hbm->nrhs)) goto fail;
 241.400 +         if (scan_int(dsa, "nrhsix", 28, 14, &hbm->nrhsix)) goto fail;
 241.401 +         xprintf("rhstyp = `%s'; nrhs = %d; nrhsix = %d\n",
 241.402 +            hbm->rhstyp, hbm->nrhs, hbm->nrhsix);
 241.403 +      }
 241.404 +      /* read matrix structure */
 241.405 +      hbm->colptr = xcalloc(1+hbm->ncol+1, sizeof(int));
 241.406 +      if (read_int_array(dsa, "colptr", hbm->ptrfmt, hbm->ncol+1,
 241.407 +         hbm->colptr)) goto fail;
 241.408 +      hbm->rowind = xcalloc(1+hbm->nnzero, sizeof(int));
 241.409 +      if (read_int_array(dsa, "rowind", hbm->indfmt, hbm->nnzero,
 241.410 +         hbm->rowind)) goto fail;
 241.411 +      /* read matrix values */
 241.412 +      if (hbm->valcrd <= 0) goto done;
 241.413 +      if (hbm->mxtype[2] == 'A')
 241.414 +      {  /* assembled matrix */
 241.415 +         hbm->values = xcalloc(1+hbm->nnzero, sizeof(double));
 241.416 +         if (read_real_array(dsa, "values", hbm->valfmt, hbm->nnzero,
 241.417 +            hbm->values)) goto fail;
 241.418 +      }
 241.419 +      else
 241.420 +      {  /* elemental (unassembled) matrix */
 241.421 +         hbm->values = xcalloc(1+hbm->neltvl, sizeof(double));
 241.422 +         if (read_real_array(dsa, "values", hbm->valfmt, hbm->neltvl,
 241.423 +            hbm->values)) goto fail;
 241.424 +      }
 241.425 +      /* read right-hand sides */
 241.426 +      if (hbm->nrhs <= 0) goto done;
 241.427 +      if (hbm->rhstyp[0] == 'F')
 241.428 +      {  /* dense format */
 241.429 +         hbm->nrhsvl = hbm->nrow * hbm->nrhs;
 241.430 +         hbm->rhsval = xcalloc(1+hbm->nrhsvl, sizeof(double));
 241.431 +         if (read_real_array(dsa, "rhsval", hbm->rhsfmt, hbm->nrhsvl,
 241.432 +            hbm->rhsval)) goto fail;
 241.433 +      }
 241.434 +      else if (hbm->rhstyp[0] == 'M' && hbm->mxtype[2] == 'A')
 241.435 +      {  /* sparse format */
 241.436 +         /* read pointers */
 241.437 +         hbm->rhsptr = xcalloc(1+hbm->nrhs+1, sizeof(int));
 241.438 +         if (read_int_array(dsa, "rhsptr", hbm->ptrfmt, hbm->nrhs+1,
 241.439 +            hbm->rhsptr)) goto fail;
 241.440 +         /* read sparsity pattern */
 241.441 +         hbm->rhsind = xcalloc(1+hbm->nrhsix, sizeof(int));
 241.442 +         if (read_int_array(dsa, "rhsind", hbm->indfmt, hbm->nrhsix,
 241.443 +            hbm->rhsind)) goto fail;
 241.444 +         /* read values */
 241.445 +         hbm->rhsval = xcalloc(1+hbm->nrhsix, sizeof(double));
 241.446 +         if (read_real_array(dsa, "rhsval", hbm->rhsfmt, hbm->nrhsix,
 241.447 +            hbm->rhsval)) goto fail;
 241.448 +      }
 241.449 +      else if (hbm->rhstyp[0] == 'M' && hbm->mxtype[2] == 'E')
 241.450 +      {  /* elemental format */
 241.451 +         hbm->rhsval = xcalloc(1+hbm->nrhsvl, sizeof(double));
 241.452 +         if (read_real_array(dsa, "rhsval", hbm->rhsfmt, hbm->nrhsvl,
 241.453 +            hbm->rhsval)) goto fail;
 241.454 +      }
 241.455 +      else
 241.456 +      {  xprintf("%s:%d: right-hand side type `%c' not recognised\n",
 241.457 +            dsa->fname, dsa->seqn, hbm->rhstyp[0]);
 241.458 +         goto fail;
 241.459 +      }
 241.460 +      /* read starting guesses */
 241.461 +      if (hbm->rhstyp[1] == 'G')
 241.462 +      {  hbm->nguess = hbm->nrow * hbm->nrhs;
 241.463 +         hbm->sguess = xcalloc(1+hbm->nguess, sizeof(double));
 241.464 +         if (read_real_array(dsa, "sguess", hbm->rhsfmt, hbm->nguess,
 241.465 +            hbm->sguess)) goto fail;
 241.466 +      }
 241.467 +      /* read solution vectors */
 241.468 +      if (hbm->rhstyp[2] == 'X')
 241.469 +      {  hbm->nexact = hbm->nrow * hbm->nrhs;
 241.470 +         hbm->xexact = xcalloc(1+hbm->nexact, sizeof(double));
 241.471 +         if (read_real_array(dsa, "xexact", hbm->rhsfmt, hbm->nexact,
 241.472 +            hbm->xexact)) goto fail;
 241.473 +      }
 241.474 +done: /* reading has been completed */
 241.475 +      xprintf("hbm_read_mat: %d cards were read\n", dsa->seqn);
 241.476 +      fclose(dsa->fp);
 241.477 +      return hbm;
 241.478 +fail: /* something wrong in Danish kingdom */
 241.479 +      if (hbm != NULL)
 241.480 +      {  if (hbm->colptr != NULL) xfree(hbm->colptr);
 241.481 +         if (hbm->rowind != NULL) xfree(hbm->rowind);
 241.482 +         if (hbm->rhsptr != NULL) xfree(hbm->rhsptr);
 241.483 +         if (hbm->rhsind != NULL) xfree(hbm->rhsind);
 241.484 +         if (hbm->values != NULL) xfree(hbm->values);
 241.485 +         if (hbm->rhsval != NULL) xfree(hbm->rhsval);
 241.486 +         if (hbm->sguess != NULL) xfree(hbm->sguess);
 241.487 +         if (hbm->xexact != NULL) xfree(hbm->xexact);
 241.488 +         xfree(hbm);
 241.489 +      }
 241.490 +      if (dsa->fp != NULL) fclose(dsa->fp);
 241.491 +      return NULL;
 241.492 +}
 241.493 +
 241.494 +/***********************************************************************
 241.495 +*  NAME
 241.496 +*
 241.497 +*  hbm_free_mat - free sparse matrix in Harwell-Boeing format
 241.498 +*
 241.499 +*  SYNOPSIS
 241.500 +*
 241.501 +*  #include "glphbm.h"
 241.502 +*  void hbm_free_mat(HBM *hbm);
 241.503 +*
 241.504 +*  DESCRIPTION
 241.505 +*
 241.506 +*  The hbm_free_mat routine frees all the memory allocated to the data
 241.507 +*  structure containing a sparse matrix in the Harwell-Boeing format. */
 241.508 +
 241.509 +void hbm_free_mat(HBM *hbm)
 241.510 +{     if (hbm->colptr != NULL) xfree(hbm->colptr);
 241.511 +      if (hbm->rowind != NULL) xfree(hbm->rowind);
 241.512 +      if (hbm->rhsptr != NULL) xfree(hbm->rhsptr);
 241.513 +      if (hbm->rhsind != NULL) xfree(hbm->rhsind);
 241.514 +      if (hbm->values != NULL) xfree(hbm->values);
 241.515 +      if (hbm->rhsval != NULL) xfree(hbm->rhsval);
 241.516 +      if (hbm->sguess != NULL) xfree(hbm->sguess);
 241.517 +      if (hbm->xexact != NULL) xfree(hbm->xexact);
 241.518 +      xfree(hbm);
 241.519 +      return;
 241.520 +}
 241.521 +
 241.522 +/* eof */
   242.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
   242.2 +++ b/deps/glpk/src/glphbm.h	Sun Nov 06 20:59:10 2011 +0100
   242.3 @@ -0,0 +1,127 @@
   242.4 +/* glphbm.h (Harwell-Boeing sparse matrix format) */
   242.5 +
   242.6 +/***********************************************************************
   242.7 +*  This code is part of GLPK (GNU Linear Programming Kit).
   242.8 +*
   242.9 +*  Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008,
  242.10 +*  2009, 2010, 2011 Andrew Makhorin, Department for Applied Informatics,
  242.11 +*  Moscow Aviation Institute, Moscow, Russia. All rights reserved.
  242.12 +*  E-mail: <mao@gnu.org>.
  242.13 +*
  242.14 +*  GLPK is free software: you can redistribute it and/or modify it
  242.15 +*  under the terms of the GNU General Public License as published by
  242.16 +*  the Free Software Foundation, either version 3 of the License, or
  242.17 +*  (at your option) any later version.
  242.18 +*
  242.19 +*  GLPK is distributed in the hope that it will be useful, but WITHOUT
  242.20 +*  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
  242.21 +*  or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
  242.22 +*  License for more details.
  242.23 +*
  242.24 +*  You should have received a copy of the GNU General Public License
  242.25 +*  along with GLPK. If not, see <http://www.gnu.org/licenses/>.
  242.26 +***********************************************************************/
  242.27 +
  242.28 +#ifndef GLPHBM_H
  242.29 +#define GLPHBM_H
  242.30 +
  242.31 +typedef struct HBM HBM;
  242.32 +
  242.33 +struct HBM
  242.34 +{     /* sparse matrix in Harwell-Boeing format; for details see the
  242.35 +         report: I.S.Duff, R.G.Grimes, J.G.Lewis. User's Guide for the
  242.36 +         Harwell-Boeing Sparse Matrix Collection (Release I), 1992 */
  242.37 +      char title[72+1];
  242.38 +      /* matrix title (informative) */
  242.39 +      char key[8+1];
  242.40 +      /* matrix key (informative) */
  242.41 +      char mxtype[3+1];
  242.42 +      /* matrix type:
  242.43 +         R.. real matrix
  242.44 +         C.. complex matrix
  242.45 +         P.. pattern only (no numerical values supplied)
  242.46 +         .S. symmetric (lower triangle + main diagonal)
  242.47 +         .U. unsymmetric
  242.48 +         .H. hermitian (lower triangle + main diagonal)
  242.49 +         .Z. skew symmetric (lower triangle only)
  242.50 +         .R. rectangular
  242.51 +         ..A assembled
  242.52 +         ..E elemental (unassembled) */
  242.53 +      char rhstyp[3+1];
  242.54 +      /* optional types:
  242.55 +         F.. right-hand sides in dense format
  242.56 +         M.. right-hand sides in same format as matrix
  242.57 +         .G. starting vector(s) (guess) is supplied
  242.58 +         ..X exact solution vector(s) is supplied */
  242.59 +      char ptrfmt[16+1];
  242.60 +      /* format for pointers */
  242.61 +      char indfmt[16+1];
  242.62 +      /* format for row (or variable) indices */
  242.63 +      char valfmt[20+1];
  242.64 +      /* format for numerical values of coefficient matrix */
  242.65 +      char rhsfmt[20+1];
  242.66 +      /* format for numerical values of right-hand sides */
  242.67 +      int totcrd;
  242.68 +      /* total number of cards excluding header */
  242.69 +      int ptrcrd;
  242.70 +      /* number of cards for ponters */
  242.71 +      int indcrd;
  242.72 +      /* number of cards for row (or variable) indices */
  242.73 +      int valcrd;
  242.74 +      /* number of cards for numerical values */
  242.75 +      int rhscrd;
  242.76 +      /* number of lines for right-hand sides;
  242.77 +         including starting guesses and solution vectors if present;
  242.78 +         zero indicates no right-hand side data is present */
  242.79 +      int nrow;
  242.80 +      /* number of rows (or variables) */
  242.81 +      int ncol;
  242.82 +      /* number of columns (or elements) */
  242.83 +      int nnzero;
  242.84 +      /* number of row (or variable) indices;
  242.85 +         equal to number of entries for assembled matrix */
  242.86 +      int neltvl;
  242.87 +      /* number of elemental matrix entries;
  242.88 +         zero in case of assembled matrix */
  242.89 +      int nrhs;
  242.90 +      /* number of right-hand sides */
  242.91 +      int nrhsix;
  242.92 +      /* number of row indices;
  242.93 +         ignored in case of unassembled matrix */
  242.94 +      int nrhsvl;
  242.95 +      /* total number of entries in all right-hand sides */
  242.96 +      int nguess;
  242.97 +      /* total number of entries in all starting guesses */
  242.98 +      int nexact;
  242.99 +      /* total number of entries in all solution vectors */
 242.100 +      int *colptr; /* alias: eltptr */
 242.101 +      /* column pointers (in case of assembled matrix);
 242.102 +         elemental matrix pointers (in case of unassembled matrix) */
 242.103 +      int *rowind; /* alias: varind */
 242.104 +      /* row indices (in case of assembled matrix);
 242.105 +         variable indices (in case of unassembled matrix) */
 242.106 +      int *rhsptr;
 242.107 +      /* right-hand side pointers */
 242.108 +      int *rhsind;
 242.109 +      /* right-hand side indices */
 242.110 +      double *values;
 242.111 +      /* matrix values */
 242.112 +      double *rhsval;
 242.113 +      /* right-hand side values */
 242.114 +      double *sguess;
 242.115 +      /* starting guess values */
 242.116 +      double *xexact;
 242.117 +      /* solution vector values */
 242.118 +};
 242.119 +
 242.120 +#define hbm_read_mat _glp_hbm_read_mat
 242.121 +HBM *hbm_read_mat(const char *fname);
 242.122 +/* read sparse matrix in Harwell-Boeing format */
 242.123 +
 242.124 +#define hbm_free_mat _glp_hbm_free_mat
 242.125 +void hbm_free_mat(HBM *hbm);
 242.126 +/* free sparse matrix in Harwell-Boeing format */
 242.127 +
 242.128 +#endif
 242.129 +
 242.130 +/* eof */
   243.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
   243.2 +++ b/deps/glpk/src/glpini01.c	Sun Nov 06 20:59:10 2011 +0100
   243.3 @@ -0,0 +1,577 @@
   243.4 +/* glpini01.c */
   243.5 +
   243.6 +/***********************************************************************
   243.7 +*  This code is part of GLPK (GNU Linear Programming Kit).
   243.8 +*
   243.9 +*  Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008,
  243.10 +*  2009, 2010, 2011 Andrew Makhorin, Department for Applied Informatics,
  243.11 +*  Moscow Aviation Institute, Moscow, Russia. All rights reserved.
  243.12 +*  E-mail: <mao@gnu.org>.
  243.13 +*
  243.14 +*  GLPK is free software: you can redistribute it and/or modify it
  243.15 +*  under the terms of the GNU General Public License as published by
  243.16 +*  the Free Software Foundation, either version 3 of the License, or
  243.17 +*  (at your option) any later version.
  243.18 +*
  243.19 +*  GLPK is distributed in the hope that it will be useful, but WITHOUT
  243.20 +*  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
  243.21 +*  or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
  243.22 +*  License for more details.
  243.23 +*
  243.24 +*  You should have received a copy of the GNU General Public License
  243.25 +*  along with GLPK. If not, see <http://www.gnu.org/licenses/>.
  243.26 +***********************************************************************/
  243.27 +
  243.28 +#include "glpapi.h"
  243.29 +
  243.30 +/*----------------------------------------------------------------------
  243.31 +-- triang - find maximal triangular part of a rectangular matrix.
  243.32 +--
  243.33 +-- *Synopsis*
  243.34 +--
  243.35 +-- int triang(int m, int n,
  243.36 +--    void *info, int (*mat)(void *info, int k, int ndx[]),
  243.37 +--    int rn[], int cn[]);
  243.38 +--
  243.39 +-- *Description*
  243.40 +--
  243.41 +-- For a given rectangular (sparse) matrix A with m rows and n columns
  243.42 +-- the routine triang tries to find such permutation matrices P and Q
  243.43 +-- that the first rows and columns of the matrix B = P*A*Q form a lower
  243.44 +-- triangular submatrix of as greatest size as possible:
  243.45 +--
  243.46 +--                   1                       n
  243.47 +--                1  * . . . . . . x x x x x x
  243.48 +--                   * * . . . . . x x x x x x
  243.49 +--                   * * * . . . . x x x x x x
  243.50 +--                   * * * * . . . x x x x x x
  243.51 +--    B = P*A*Q =    * * * * * . . x x x x x x
  243.52 +--                   * * * * * * . x x x x x x
  243.53 +--                   * * * * * * * x x x x x x
  243.54 +--                   x x x x x x x x x x x x x
  243.55 +--                   x x x x x x x x x x x x x
  243.56 +--                m  x x x x x x x x x x x x x
  243.57 +--
  243.58 +-- where: '*' - elements of the lower triangular part, '.' - structural
  243.59 +-- zeros, 'x' - other (either non-zero or zero) elements.
  243.60 +--
  243.61 +-- The parameter info is a transit pointer passed to the formal routine
  243.62 +-- mat (see below).
  243.63 +--
  243.64 +-- The formal routine mat specifies the given matrix A in both row- and
  243.65 +-- column-wise formats. In order to obtain an i-th row of the matrix A
  243.66 +-- the routine triang calls the routine mat with the parameter k = +i,
  243.67 +-- 1 <= i <= m. In response the routine mat should store column indices
  243.68 +-- of (non-zero) elements of the i-th row to the locations ndx[1], ...,
  243.69 +-- ndx[len], where len is number of non-zeros in the i-th row returned
  243.70 +-- on exit. Analogously, in order to obtain a j-th column of the matrix
  243.71 +-- A, the routine mat is called with the parameter k = -j, 1 <= j <= n,
  243.72 +-- and should return pattern of the j-th column in the same way as for
  243.73 +-- row patterns. Note that the routine mat may be called more than once
  243.74 +-- for the same rows and columns.
  243.75 +--
  243.76 +-- On exit the routine computes two resultant arrays rn and cn, which
  243.77 +-- define the permutation matrices P and Q, respectively. The array rn
  243.78 +-- should have at least 1+m locations, where rn[i] = i' (1 <= i <= m)
  243.79 +-- means that i-th row of the original matrix A corresponds to i'-th row
  243.80 +-- of the matrix B = P*A*Q. Similarly, the array cn should have at least
  243.81 +-- 1+n locations, where cn[j] = j' (1 <= j <= n) means that j-th column
  243.82 +-- of the matrix A corresponds to j'-th column of the matrix B.
  243.83 +--
  243.84 +-- *Returns*
  243.85 +--
  243.86 +-- The routine triang returns the size of the lower tringular part of
  243.87 +-- the matrix B = P*A*Q (see the figure above).
  243.88 +--
  243.89 +-- *Complexity*
  243.90 +--
  243.91 +-- The time complexity of the routine triang is O(nnz), where nnz is
  243.92 +-- number of non-zeros in the given matrix A.
  243.93 +--
  243.94 +-- *Algorithm*
  243.95 +--
  243.96 +-- The routine triang starts from the matrix B = P*Q*A, where P and Q
  243.97 +-- are unity matrices, so initially B = A.
  243.98 +--
  243.99 +-- Before the next iteration B = (B1 | B2 | B3), where B1 is partially
 243.100 +-- built a lower triangular submatrix, B2 is the active submatrix, and
 243.101 +-- B3 is a submatrix that contains rejected columns. Thus, the current
 243.102 +-- matrix B looks like follows (initially k1 = 1 and k2 = n):
 243.103 +--
 243.104 +--       1         k1         k2         n
 243.105 +--    1  x . . . . . . . . . . . . . # # #
 243.106 +--       x x . . . . . . . . . . . . # # #
 243.107 +--       x x x . . . . . . . . . . # # # #
 243.108 +--       x x x x . . . . . . . . . # # # #
 243.109 +--       x x x x x . . . . . . . # # # # #
 243.110 +--    k1 x x x x x * * * * * * * # # # # #
 243.111 +--       x x x x x * * * * * * * # # # # #
 243.112 +--       x x x x x * * * * * * * # # # # #
 243.113 +--       x x x x x * * * * * * * # # # # #
 243.114 +--    m  x x x x x * * * * * * * # # # # #
 243.115 +--       <--B1---> <----B2-----> <---B3-->
 243.116 +--
 243.117 +-- On each iteartion the routine looks for a singleton row, i.e. some
 243.118 +-- row that has the only non-zero in the active submatrix B2. If such
 243.119 +-- row exists and the corresponding non-zero is b[i,j], where (by the
 243.120 +-- definition) k1 <= i <= m and k1 <= j <= k2, the routine permutes
 243.121 +-- k1-th and i-th rows and k1-th and j-th columns of the matrix B (in
 243.122 +-- order to place the element in the position b[k1,k1]), removes the
 243.123 +-- k1-th column from the active submatrix B2, and adds this column to
 243.124 +-- the submatrix B1. If no row singletons exist, but B2 is not empty
 243.125 +-- yet, the routine chooses a j-th column, which has maximal number of
 243.126 +-- non-zeros among other columns of B2, removes this column from B2 and
 243.127 +-- adds it to the submatrix B3 in the hope that new row singletons will
 243.128 +-- appear in the active submatrix. */
 243.129 +
 243.130 +static int triang(int m, int n,
 243.131 +      void *info, int (*mat)(void *info, int k, int ndx[]),
 243.132 +      int rn[], int cn[])
 243.133 +{     int *ndx; /* int ndx[1+max(m,n)]; */
 243.134 +      /* this array is used for querying row and column patterns of the
 243.135 +         given matrix A (the third parameter to the routine mat) */
 243.136 +      int *rs_len; /* int rs_len[1+m]; */
 243.137 +      /* rs_len[0] is not used;
 243.138 +         rs_len[i], 1 <= i <= m, is number of non-zeros in the i-th row
 243.139 +         of the matrix A, which (non-zeros) belong to the current active
 243.140 +         submatrix */
 243.141 +      int *rs_head; /* int rs_head[1+n]; */
 243.142 +      /* rs_head[len], 0 <= len <= n, is the number i of the first row
 243.143 +         of the matrix A, for which rs_len[i] = len */
 243.144 +      int *rs_prev; /* int rs_prev[1+m]; */
 243.145 +      /* rs_prev[0] is not used;
 243.146 +         rs_prev[i], 1 <= i <= m, is a number i' of the previous row of
 243.147 +         the matrix A, for which rs_len[i] = rs_len[i'] (zero marks the
 243.148 +         end of this linked list) */
 243.149 +      int *rs_next; /* int rs_next[1+m]; */
 243.150 +      /* rs_next[0] is not used;
 243.151 +         rs_next[i], 1 <= i <= m, is a number i' of the next row of the
 243.152 +         matrix A, for which rs_len[i] = rs_len[i'] (zero marks the end
 243.153 +         this linked list) */
 243.154 +      int cs_head;
 243.155 +      /* is a number j of the first column of the matrix A, which has
 243.156 +         maximal number of non-zeros among other columns */
 243.157 +      int *cs_prev; /* cs_prev[1+n]; */
 243.158 +      /* cs_prev[0] is not used;
 243.159 +         cs_prev[j], 1 <= j <= n, is a number of the previous column of
 243.160 +         the matrix A with the same or greater number of non-zeros than
 243.161 +         in the j-th column (zero marks the end of this linked list) */
 243.162 +      int *cs_next; /* cs_next[1+n]; */
 243.163 +      /* cs_next[0] is not used;
 243.164 +         cs_next[j], 1 <= j <= n, is a number of the next column of
 243.165 +         the matrix A with the same or lesser number of non-zeros than
 243.166 +         in the j-th column (zero marks the end of this linked list) */
 243.167 +      int i, j, ii, jj, k1, k2, len, t, size = 0;
 243.168 +      int *head, *rn_inv, *cn_inv;
 243.169 +      if (!(m > 0 && n > 0))
 243.170 +         xerror("triang: m = %d; n = %d; invalid dimension\n", m, n);
 243.171 +      /* allocate working arrays */
 243.172 +      ndx = xcalloc(1+(m >= n ? m : n), sizeof(int));
 243.173 +      rs_len = xcalloc(1+m, sizeof(int));
 243.174 +      rs_head = xcalloc(1+n, sizeof(int));
 243.175 +      rs_prev = xcalloc(1+m, sizeof(int));
 243.176 +      rs_next = xcalloc(1+m, sizeof(int));
 243.177 +      cs_prev = xcalloc(1+n, sizeof(int));
 243.178 +      cs_next = xcalloc(1+n, sizeof(int));
 243.179 +      /* build linked lists of columns of the matrix A with the same
 243.180 +         number of non-zeros */
 243.181 +      head = rs_len; /* currently rs_len is used as working array */
 243.182 +      for (len = 0; len <= m; len ++) head[len] = 0;
 243.183 +      for (j = 1; j <= n; j++)
 243.184 +      {  /* obtain length of the j-th column */
 243.185 +         len = mat(info, -j, ndx);
 243.186 +         xassert(0 <= len && len <= m);
 243.187 +         /* include the j-th column in the corresponding linked list */
 243.188 +         cs_prev[j] = head[len];
 243.189 +         head[len] = j;
 243.190 +      }
 243.191 +      /* merge all linked lists of columns in one linked list, where
 243.192 +         columns are ordered by descending of their lengths */
 243.193 +      cs_head = 0;
 243.194 +      for (len = 0; len <= m; len++)
 243.195 +      {  for (j = head[len]; j != 0; j = cs_prev[j])
 243.196 +         {  cs_next[j] = cs_head;
 243.197 +            cs_head = j;
 243.198 +         }
 243.199 +      }
 243.200 +      jj = 0;
 243.201 +      for (j = cs_head; j != 0; j = cs_next[j])
 243.202 +      {  cs_prev[j] = jj;
 243.203 +         jj = j;
 243.204 +      }
 243.205 +      /* build initial doubly linked lists of rows of the matrix A with
 243.206 +         the same number of non-zeros */
 243.207 +      for (len = 0; len <= n; len++) rs_head[len] = 0;
 243.208 +      for (i = 1; i <= m; i++)
 243.209 +      {  /* obtain length of the i-th row */
 243.210 +         rs_len[i] = len = mat(info, +i, ndx);
 243.211 +         xassert(0 <= len && len <= n);
 243.212 +         /* include the i-th row in the correspondng linked list */
 243.213 +         rs_prev[i] = 0;
 243.214 +         rs_next[i] = rs_head[len];
 243.215 +         if (rs_next[i] != 0) rs_prev[rs_next[i]] = i;
 243.216 +         rs_head[len] = i;
 243.217 +      }
 243.218 +      /* initially all rows and columns of the matrix A are active */
 243.219 +      for (i = 1; i <= m; i++) rn[i] = 0;
 243.220 +      for (j = 1; j <= n; j++) cn[j] = 0;
 243.221 +      /* set initial bounds of the active submatrix */
 243.222 +      k1 = 1, k2 = n;
 243.223 +      /* main loop starts here */
 243.224 +      while (k1 <= k2)
 243.225 +      {  i = rs_head[1];
 243.226 +         if (i != 0)
 243.227 +         {  /* the i-th row of the matrix A is a row singleton, since
 243.228 +               it has the only non-zero in the active submatrix */
 243.229 +            xassert(rs_len[i] == 1);
 243.230 +            /* determine the number j of an active column of the matrix
 243.231 +               A, in which this non-zero is placed */
 243.232 +            j = 0;
 243.233 +            t = mat(info, +i, ndx);
 243.234 +            xassert(0 <= t && t <= n);
 243.235 +            for (t = t; t >= 1; t--)
 243.236 +            {  jj = ndx[t];
 243.237 +               xassert(1 <= jj && jj <= n);
 243.238 +               if (cn[jj] == 0)
 243.239 +               {  xassert(j == 0);
 243.240 +                  j = jj;
 243.241 +               }
 243.242 +            }
 243.243 +            xassert(j != 0);
 243.244 +            /* the singleton is a[i,j]; move a[i,j] to the position
 243.245 +               b[k1,k1] of the matrix B */
 243.246 +            rn[i] = cn[j] = k1;
 243.247 +            /* shift the left bound of the active submatrix */
 243.248 +            k1++;
 243.249 +            /* increase the size of the lower triangular part */
 243.250 +            size++;
 243.251 +         }
 243.252 +         else
 243.253 +         {  /* the current active submatrix has no row singletons */
 243.254 +            /* remove an active column with maximal number of non-zeros
 243.255 +               from the active submatrix */
 243.256 +            j = cs_head;
 243.257 +            xassert(j != 0);
 243.258 +            cn[j] = k2;
 243.259 +            /* shift the right bound of the active submatrix */
 243.260 +            k2--;
 243.261 +         }
 243.262 +         /* the j-th column of the matrix A has been removed from the
 243.263 +            active submatrix */
 243.264 +         /* remove the j-th column from the linked list */
 243.265 +         if (cs_prev[j] == 0)
 243.266 +            cs_head = cs_next[j];
 243.267 +         else
 243.268 +            cs_next[cs_prev[j]] = cs_next[j];
 243.269 +         if (cs_next[j] == 0)
 243.270 +            /* nop */;
 243.271 +         else
 243.272 +            cs_prev[cs_next[j]] = cs_prev[j];
 243.273 +         /* go through non-zeros of the j-th columns and update active
 243.274 +            lengths of the corresponding rows */
 243.275 +         t = mat(info, -j, ndx);
 243.276 +         xassert(0 <= t && t <= m);
 243.277 +         for (t = t; t >= 1; t--)
 243.278 +         {  i = ndx[t];
 243.279 +            xassert(1 <= i && i <= m);
 243.280 +            /* the non-zero a[i,j] has left the active submatrix */
 243.281 +            len = rs_len[i];
 243.282 +            xassert(len >= 1);
 243.283 +            /* remove the i-th row from the linked list of rows with
 243.284 +               active length len */
 243.285 +            if (rs_prev[i] == 0)
 243.286 +               rs_head[len] = rs_next[i];
 243.287 +            else
 243.288 +               rs_next[rs_prev[i]] = rs_next[i];
 243.289 +            if (rs_next[i] == 0)
 243.290 +               /* nop */;
 243.291 +            else
 243.292 +               rs_prev[rs_next[i]] = rs_prev[i];
 243.293 +            /* decrease the active length of the i-th row */
 243.294 +            rs_len[i] = --len;
 243.295 +            /* return the i-th row to the corresponding linked list */
 243.296 +            rs_prev[i] = 0;
 243.297 +            rs_next[i] = rs_head[len];
 243.298 +            if (rs_next[i] != 0) rs_prev[rs_next[i]] = i;
 243.299 +            rs_head[len] = i;
 243.300 +         }
 243.301 +      }
 243.302 +      /* other rows of the matrix A, which are still active, correspond
 243.303 +         to rows k1, ..., m of the matrix B (in arbitrary order) */
 243.304 +      for (i = 1; i <= m; i++) if (rn[i] == 0) rn[i] = k1++;
 243.305 +      /* but for columns this is not needed, because now the submatrix
 243.306 +         B2 has no columns */
 243.307 +      for (j = 1; j <= n; j++) xassert(cn[j] != 0);
 243.308 +      /* perform some optional checks */
 243.309 +      /* make sure that rn is a permutation of {1, ..., m} and cn is a
 243.310 +         permutation of {1, ..., n} */
 243.311 +      rn_inv = rs_len; /* used as working array */
 243.312 +      for (ii = 1; ii <= m; ii++) rn_inv[ii] = 0;
 243.313 +      for (i = 1; i <= m; i++)
 243.314 +      {  ii = rn[i];
 243.315 +         xassert(1 <= ii && ii <= m);
 243.316 +         xassert(rn_inv[ii] == 0);
 243.317 +         rn_inv[ii] = i;
 243.318 +      }
 243.319 +      cn_inv = rs_head; /* used as working array */
 243.320 +      for (jj = 1; jj <= n; jj++) cn_inv[jj] = 0;
 243.321 +      for (j = 1; j <= n; j++)
 243.322 +      {  jj = cn[j];
 243.323 +         xassert(1 <= jj && jj <= n);
 243.324 +         xassert(cn_inv[jj] == 0);
 243.325 +         cn_inv[jj] = j;
 243.326 +      }
 243.327 +      /* make sure that the matrix B = P*A*Q really has the form, which
 243.328 +         was declared */
 243.329 +      for (ii = 1; ii <= size; ii++)
 243.330 +      {  int diag = 0;
 243.331 +         i = rn_inv[ii];
 243.332 +         t = mat(info, +i, ndx);
 243.333 +         xassert(0 <= t && t <= n);
 243.334 +         for (t = t; t >= 1; t--)
 243.335 +         {  j = ndx[t];
 243.336 +            xassert(1 <= j && j <= n);
 243.337 +            jj = cn[j];
 243.338 +            if (jj <= size) xassert(jj <= ii);
 243.339 +            if (jj == ii)
 243.340 +            {  xassert(!diag);
 243.341 +               diag = 1;
 243.342 +            }
 243.343 +         }
 243.344 +         xassert(diag);
 243.345 +      }
 243.346 +      /* free working arrays */
 243.347 +      xfree(ndx);
 243.348 +      xfree(rs_len);
 243.349 +      xfree(rs_head);
 243.350 +      xfree(rs_prev);
 243.351 +      xfree(rs_next);
 243.352 +      xfree(cs_prev);
 243.353 +      xfree(cs_next);
 243.354 +      /* return to the calling program */
 243.355 +      return size;
 243.356 +}
 243.357 +
 243.358 +/*----------------------------------------------------------------------
 243.359 +-- adv_basis - construct advanced initial LP basis.
 243.360 +--
 243.361 +-- *Synopsis*
 243.362 +--
 243.363 +-- #include "glpini.h"
 243.364 +-- void adv_basis(glp_prob *lp);
 243.365 +--
 243.366 +-- *Description*
 243.367 +--
 243.368 +-- The routine adv_basis constructs an advanced initial basis for an LP
 243.369 +-- problem object, which the parameter lp points to.
 243.370 +--
 243.371 +-- In order to build the initial basis the routine does the following:
 243.372 +--
 243.373 +-- 1) includes in the basis all non-fixed auxiliary variables;
 243.374 +--
 243.375 +-- 2) includes in the basis as many as possible non-fixed structural
 243.376 +--    variables preserving triangular form of the basis matrix;
 243.377 +--
 243.378 +-- 3) includes in the basis appropriate (fixed) auxiliary variables
 243.379 +--    in order to complete the basis.
 243.380 +--
 243.381 +-- As a result the initial basis has minimum of fixed variables and the
 243.382 +-- corresponding basis matrix is triangular. */
 243.383 +
 243.384 +static int mat(void *info, int k, int ndx[])
 243.385 +{     /* this auxiliary routine returns the pattern of a given row or
 243.386 +         a given column of the augmented constraint matrix A~ = (I|-A),
 243.387 +         in which columns of fixed variables are implicitly cleared */
 243.388 +      LPX *lp = info;
 243.389 +      int m = lpx_get_num_rows(lp);
 243.390 +      int n = lpx_get_num_cols(lp);
 243.391 +      int typx, i, j, lll, len = 0;
 243.392 +      if (k > 0)
 243.393 +      {  /* the pattern of the i-th row is required */
 243.394 +         i = +k;
 243.395 +         xassert(1 <= i && i <= m);
 243.396 +#if 0 /* 22/XII-2003 */
 243.397 +         /* if the auxiliary variable x[i] is non-fixed, include its
 243.398 +            element (placed in the i-th column) in the pattern */
 243.399 +         lpx_get_row_bnds(lp, i, &typx, NULL, NULL);
 243.400 +         if (typx != LPX_FX) ndx[++len] = i;
 243.401 +         /* include in the pattern elements placed in columns, which
 243.402 +            correspond to non-fixed structural varables */
 243.403 +         i_beg = aa_ptr[i];
 243.404 +         i_end = i_beg + aa_len[i] - 1;
 243.405 +         for (i_ptr = i_beg; i_ptr <= i_end; i_ptr++)
 243.406 +         {  j = m + sv_ndx[i_ptr];
 243.407 +            lpx_get_col_bnds(lp, j-m, &typx, NULL, NULL);
 243.408 +            if (typx != LPX_FX) ndx[++len] = j;
 243.409 +         }
 243.410 +#else
 243.411 +         lll = lpx_get_mat_row(lp, i, ndx, NULL);
 243.412 +         for (k = 1; k <= lll; k++)
 243.413 +         {  lpx_get_col_bnds(lp, ndx[k], &typx, NULL, NULL);
 243.414 +            if (typx != LPX_FX) ndx[++len] = m + ndx[k];
 243.415 +         }
 243.416 +         lpx_get_row_bnds(lp, i, &typx, NULL, NULL);
 243.417 +         if (typx != LPX_FX) ndx[++len] = i;
 243.418 +#endif
 243.419 +      }
 243.420 +      else
 243.421 +      {  /* the pattern of the j-th column is required */
 243.422 +         j = -k;
 243.423 +         xassert(1 <= j && j <= m+n);
 243.424 +         /* if the (auxiliary or structural) variable x[j] is fixed,
 243.425 +            the pattern of its column is empty */
 243.426 +         if (j <= m)
 243.427 +            lpx_get_row_bnds(lp, j, &typx, NULL, NULL);
 243.428 +         else
 243.429 +            lpx_get_col_bnds(lp, j-m, &typx, NULL, NULL);
 243.430 +         if (typx != LPX_FX)
 243.431 +         {  if (j <= m)
 243.432 +            {  /* x[j] is non-fixed auxiliary variable */
 243.433 +               ndx[++len] = j;
 243.434 +            }
 243.435 +            else
 243.436 +            {  /* x[j] is non-fixed structural variables */
 243.437 +#if 0 /* 22/XII-2003 */
 243.438 +               j_beg = aa_ptr[j];
 243.439 +               j_end = j_beg + aa_len[j] - 1;
 243.440 +               for (j_ptr = j_beg; j_ptr <= j_end; j_ptr++)
 243.441 +                  ndx[++len] = sv_ndx[j_ptr];
 243.442 +#else
 243.443 +               len = lpx_get_mat_col(lp, j-m, ndx, NULL);
 243.444 +#endif
 243.445 +            }
 243.446 +         }
 243.447 +      }
 243.448 +      /* return the length of the row/column pattern */
 243.449 +      return len;
 243.450 +}
 243.451 +
 243.452 +static void adv_basis(glp_prob *lp)
 243.453 +{     int m = lpx_get_num_rows(lp);
 243.454 +      int n = lpx_get_num_cols(lp);
 243.455 +      int i, j, jj, k, size;
 243.456 +      int *rn, *cn, *rn_inv, *cn_inv;
 243.457 +      int typx, *tagx = xcalloc(1+m+n, sizeof(int));
 243.458 +      double lb, ub;
 243.459 +      xprintf("Constructing initial basis...\n");
 243.460 +#if 0 /* 13/V-2009 */
 243.461 +      if (m == 0)
 243.462 +         xerror("glp_adv_basis: problem has no rows\n");
 243.463 +      if (n == 0)
 243.464 +         xerror("glp_adv_basis: problem has no columns\n");
 243.465 +#else
 243.466 +      if (m == 0 || n == 0)
 243.467 +      {  glp_std_basis(lp);
 243.468 +         return;
 243.469 +      }
 243.470 +#endif
 243.471 +      /* use the routine triang (see above) to find maximal triangular
 243.472 +         part of the augmented constraint matrix A~ = (I|-A); in order
 243.473 +         to prevent columns of fixed variables to be included in the
 243.474 +         triangular part, such columns are implictly removed from the
 243.475 +         matrix A~ by the routine adv_mat */
 243.476 +      rn = xcalloc(1+m, sizeof(int));
 243.477 +      cn = xcalloc(1+m+n, sizeof(int));
 243.478 +      size = triang(m, m+n, lp, mat, rn, cn);
 243.479 +      if (lpx_get_int_parm(lp, LPX_K_MSGLEV) >= 3)
 243.480 +         xprintf("Size of triangular part = %d\n", size);
 243.481 +      /* the first size rows and columns of the matrix P*A~*Q (where
 243.482 +         P and Q are permutation matrices defined by the arrays rn and
 243.483 +         cn) form a lower triangular matrix; build the arrays (rn_inv
 243.484 +         and cn_inv), which define the matrices inv(P) and inv(Q) */
 243.485 +      rn_inv = xcalloc(1+m, sizeof(int));
 243.486 +      cn_inv = xcalloc(1+m+n, sizeof(int));
 243.487 +      for (i = 1; i <= m; i++) rn_inv[rn[i]] = i;
 243.488 +      for (j = 1; j <= m+n; j++) cn_inv[cn[j]] = j;
 243.489 +      /* include the columns of the matrix A~, which correspond to the
 243.490 +         first size columns of the matrix P*A~*Q, in the basis */
 243.491 +      for (k = 1; k <= m+n; k++) tagx[k] = -1;
 243.492 +      for (jj = 1; jj <= size; jj++)
 243.493 +      {  j = cn_inv[jj];
 243.494 +         /* the j-th column of A~ is the jj-th column of P*A~*Q */
 243.495 +         tagx[j] = LPX_BS;
 243.496 +      }
 243.497 +      /* if size < m, we need to add appropriate columns of auxiliary
 243.498 +         variables to the basis */
 243.499 +      for (jj = size + 1; jj <= m; jj++)
 243.500 +      {  /* the jj-th column of P*A~*Q should be replaced by the column
 243.501 +            of the auxiliary variable, for which the only unity element
 243.502 +            is placed in the position [jj,jj] */
 243.503 +         i = rn_inv[jj];
 243.504 +         /* the jj-th row of P*A~*Q is the i-th row of A~, but in the
 243.505 +            i-th row of A~ the unity element belongs to the i-th column
 243.506 +            of A~; therefore the disired column corresponds to the i-th
 243.507 +            auxiliary variable (note that this column doesn't belong to
 243.508 +            the triangular part found by the routine triang) */
 243.509 +         xassert(1 <= i && i <= m);
 243.510 +         xassert(cn[i] > size);
 243.511 +         tagx[i] = LPX_BS;
 243.512 +      }
 243.513 +      /* free working arrays */
 243.514 +      xfree(rn);
 243.515 +      xfree(cn);
 243.516 +      xfree(rn_inv);
 243.517 +      xfree(cn_inv);
 243.518 +      /* build tags of non-basic variables */
 243.519 +      for (k = 1; k <= m+n; k++)
 243.520 +      {  if (tagx[k] != LPX_BS)
 243.521 +         {  if (k <= m)
 243.522 +               lpx_get_row_bnds(lp, k, &typx, &lb, &ub);
 243.523 +            else
 243.524 +               lpx_get_col_bnds(lp, k-m, &typx, &lb, &ub);
 243.525 +            switch (typx)
 243.526 +            {  case LPX_FR:
 243.527 +                  tagx[k] = LPX_NF; break;
 243.528 +               case LPX_LO:
 243.529 +                  tagx[k] = LPX_NL; break;
 243.530 +               case LPX_UP:
 243.531 +                  tagx[k] = LPX_NU; break;
 243.532 +               case LPX_DB:
 243.533 +                  tagx[k] =
 243.534 +                     (fabs(lb) <= fabs(ub) ? LPX_NL : LPX_NU);
 243.535 +                  break;
 243.536 +               case LPX_FX:
 243.537 +                  tagx[k] = LPX_NS; break;
 243.538 +               default:
 243.539 +                  xassert(typx != typx);
 243.540 +            }
 243.541 +         }
 243.542 +      }
 243.543 +      for (k = 1; k <= m+n; k++)
 243.544 +      {  if (k <= m)
 243.545 +            lpx_set_row_stat(lp, k, tagx[k]);
 243.546 +         else
 243.547 +            lpx_set_col_stat(lp, k-m, tagx[k]);
 243.548 +      }
 243.549 +      xfree(tagx);
 243.550 +      return;
 243.551 +}
 243.552 +
 243.553 +/***********************************************************************
 243.554 +*  NAME
 243.555 +*
 243.556 +*  glp_adv_basis - construct advanced initial LP basis
 243.557 +*
 243.558 +*  SYNOPSIS
 243.559 +*
 243.560 +*  void glp_adv_basis(glp_prob *lp, int flags);
 243.561 +*
 243.562 +*  DESCRIPTION
 243.563 +*
 243.564 +*  The routine glp_adv_basis constructs an advanced initial basis for
 243.565 +*  the specified problem object.
 243.566 +*
 243.567 +*  The parameter flags is reserved for use in the future and must be
 243.568 +*  specified as zero. */
 243.569 +
 243.570 +void glp_adv_basis(glp_prob *lp, int flags)
 243.571 +{     if (flags != 0)
 243.572 +         xerror("glp_adv_basis: flags = %d; invalid flags\n", flags);
 243.573 +      if (lp->m == 0 || lp->n == 0)
 243.574 +         glp_std_basis(lp);
 243.575 +      else
 243.576 +         adv_basis(lp);
 243.577 +      return;
 243.578 +}
 243.579 +
 243.580 +/* eof */
   244.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
   244.2 +++ b/deps/glpk/src/glpini02.c	Sun Nov 06 20:59:10 2011 +0100
   244.3 @@ -0,0 +1,269 @@
   244.4 +/* glpini02.c */
   244.5 +
   244.6 +/***********************************************************************
   244.7 +*  This code is part of GLPK (GNU Linear Programming Kit).
   244.8 +*
   244.9 +*  Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008,
  244.10 +*  2009, 2010, 2011 Andrew Makhorin, Department for Applied Informatics,
  244.11 +*  Moscow Aviation Institute, Moscow, Russia. All rights reserved.
  244.12 +*  E-mail: <mao@gnu.org>.
  244.13 +*
  244.14 +*  GLPK is free software: you can redistribute it and/or modify it
  244.15 +*  under the terms of the GNU General Public License as published by
  244.16 +*  the Free Software Foundation, either version 3 of the License, or
  244.17 +*  (at your option) any later version.
  244.18 +*
  244.19 +*  GLPK is distributed in the hope that it will be useful, but WITHOUT
  244.20 +*  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
  244.21 +*  or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
  244.22 +*  License for more details.
  244.23 +*
  244.24 +*  You should have received a copy of the GNU General Public License
  244.25 +*  along with GLPK. If not, see <http://www.gnu.org/licenses/>.
  244.26 +***********************************************************************/
  244.27 +
  244.28 +#include "glpapi.h"
  244.29 +
  244.30 +struct var
  244.31 +{     /* structural variable */
  244.32 +      int j;
  244.33 +      /* ordinal number */
  244.34 +      double q;
  244.35 +      /* penalty value */
  244.36 +};
  244.37 +
  244.38 +static int fcmp(const void *ptr1, const void *ptr2)
  244.39 +{     /* this routine is passed to the qsort() function */
  244.40 +      struct var *col1 = (void *)ptr1, *col2 = (void *)ptr2;
  244.41 +      if (col1->q < col2->q) return -1;
  244.42 +      if (col1->q > col2->q) return +1;
  244.43 +      return 0;
  244.44 +}
  244.45 +
  244.46 +static int get_column(glp_prob *lp, int j, int ind[], double val[])
  244.47 +{     /* Bixby's algorithm assumes that the constraint matrix is scaled
  244.48 +         such that the maximum absolute value in every non-zero row and
  244.49 +         column is 1 */
  244.50 +      int k, len;
  244.51 +      double big;
  244.52 +      len = glp_get_mat_col(lp, j, ind, val);
  244.53 +      big = 0.0;
  244.54 +      for (k = 1; k <= len; k++)
  244.55 +         if (big < fabs(val[k])) big = fabs(val[k]);
  244.56 +      if (big == 0.0) big = 1.0;
  244.57 +      for (k = 1; k <= len; k++) val[k] /= big;
  244.58 +      return len;
  244.59 +}
  244.60 +
  244.61 +static void cpx_basis(glp_prob *lp)
  244.62 +{     /* main routine */
  244.63 +      struct var *C, *C2, *C3, *C4;
  244.64 +      int m, n, i, j, jk, k, l, ll, t, n2, n3, n4, type, len, *I, *r,
  244.65 +         *ind;
  244.66 +      double alpha, gamma, cmax, temp, *v, *val;
  244.67 +      xprintf("Constructing initial basis...\n");
  244.68 +      /* determine the number of rows and columns */
  244.69 +      m = glp_get_num_rows(lp);
  244.70 +      n = glp_get_num_cols(lp);
  244.71 +      /* allocate working arrays */
  244.72 +      C = xcalloc(1+n, sizeof(struct var));
  244.73 +      I = xcalloc(1+m, sizeof(int));
  244.74 +      r = xcalloc(1+m, sizeof(int));
  244.75 +      v = xcalloc(1+m, sizeof(double));
  244.76 +      ind = xcalloc(1+m, sizeof(int));
  244.77 +      val = xcalloc(1+m, sizeof(double));
  244.78 +      /* make all auxiliary variables non-basic */
  244.79 +      for (i = 1; i <= m; i++)
  244.80 +      {  if (glp_get_row_type(lp, i) != GLP_DB)
  244.81 +            glp_set_row_stat(lp, i, GLP_NS);
  244.82 +         else if (fabs(glp_get_row_lb(lp, i)) <=
  244.83 +                  fabs(glp_get_row_ub(lp, i)))
  244.84 +            glp_set_row_stat(lp, i, GLP_NL);
  244.85 +         else
  244.86 +            glp_set_row_stat(lp, i, GLP_NU);
  244.87 +      }
  244.88 +      /* make all structural variables non-basic */
  244.89 +      for (j = 1; j <= n; j++)
  244.90 +      {  if (glp_get_col_type(lp, j) != GLP_DB)
  244.91 +            glp_set_col_stat(lp, j, GLP_NS);
  244.92 +         else if (fabs(glp_get_col_lb(lp, j)) <=
  244.93 +                  fabs(glp_get_col_ub(lp, j)))
  244.94 +            glp_set_col_stat(lp, j, GLP_NL);
  244.95 +         else
  244.96 +            glp_set_col_stat(lp, j, GLP_NU);
  244.97 +      }
  244.98 +      /* C2 is a set of free structural variables */
  244.99 +      n2 = 0, C2 = C + 0;
 244.100 +      for (j = 1; j <= n; j++)
 244.101 +      {  type = glp_get_col_type(lp, j);
 244.102 +         if (type == GLP_FR)
 244.103 +         {  n2++;
 244.104 +            C2[n2].j = j;
 244.105 +            C2[n2].q = 0.0;
 244.106 +         }
 244.107 +      }
 244.108 +      /* C3 is a set of structural variables having excatly one (lower
 244.109 +         or upper) bound */
 244.110 +      n3 = 0, C3 = C2 + n2;
 244.111 +      for (j = 1; j <= n; j++)
 244.112 +      {  type = glp_get_col_type(lp, j);
 244.113 +         if (type == GLP_LO)
 244.114 +         {  n3++;
 244.115 +            C3[n3].j = j;
 244.116 +            C3[n3].q = + glp_get_col_lb(lp, j);
 244.117 +         }
 244.118 +         else if (type == GLP_UP)
 244.119 +         {  n3++;
 244.120 +            C3[n3].j = j;
 244.121 +            C3[n3].q = - glp_get_col_ub(lp, j);
 244.122 +         }
 244.123 +      }
 244.124 +      /* C4 is a set of structural variables having both (lower and
 244.125 +         upper) bounds */
 244.126 +      n4 = 0, C4 = C3 + n3;
 244.127 +      for (j = 1; j <= n; j++)
 244.128 +      {  type = glp_get_col_type(lp, j);
 244.129 +         if (type == GLP_DB)
 244.130 +         {  n4++;
 244.131 +            C4[n4].j = j;
 244.132 +            C4[n4].q = glp_get_col_lb(lp, j) - glp_get_col_ub(lp, j);
 244.133 +         }
 244.134 +      }
 244.135 +      /* compute gamma = max{|c[j]|: 1 <= j <= n} */
 244.136 +      gamma = 0.0;
 244.137 +      for (j = 1; j <= n; j++)
 244.138 +      {  temp = fabs(glp_get_obj_coef(lp, j));
 244.139 +         if (gamma < temp) gamma = temp;
 244.140 +      }
 244.141 +      /* compute cmax */
 244.142 +      cmax = (gamma == 0.0 ? 1.0 : 1000.0 * gamma);
 244.143 +      /* compute final penalty for all structural variables within sets
 244.144 +         C2, C3, and C4 */
 244.145 +      switch (glp_get_obj_dir(lp))
 244.146 +      {  case GLP_MIN: temp = +1.0; break;
 244.147 +         case GLP_MAX: temp = -1.0; break;
 244.148 +         default: xassert(lp != lp);
 244.149 +      }
 244.150 +      for (k = 1; k <= n2+n3+n4; k++)
 244.151 +      {  j = C[k].j;
 244.152 +         C[k].q += (temp * glp_get_obj_coef(lp, j)) / cmax;
 244.153 +      }
 244.154 +      /* sort structural variables within C2, C3, and C4 in ascending
 244.155 +         order of penalty value */
 244.156 +      qsort(C2+1, n2, sizeof(struct var), fcmp);
 244.157 +      for (k = 1; k < n2; k++) xassert(C2[k].q <= C2[k+1].q);
 244.158 +      qsort(C3+1, n3, sizeof(struct var), fcmp);
 244.159 +      for (k = 1; k < n3; k++) xassert(C3[k].q <= C3[k+1].q);
 244.160 +      qsort(C4+1, n4, sizeof(struct var), fcmp);
 244.161 +      for (k = 1; k < n4; k++) xassert(C4[k].q <= C4[k+1].q);
 244.162 +      /*** STEP 1 ***/
 244.163 +      for (i = 1; i <= m; i++)
 244.164 +      {  type = glp_get_row_type(lp, i);
 244.165 +         if (type != GLP_FX)
 244.166 +         {  /* row i is either free or inequality constraint */
 244.167 +            glp_set_row_stat(lp, i, GLP_BS);
 244.168 +            I[i] = 1;
 244.169 +            r[i] = 1;
 244.170 +         }
 244.171 +         else
 244.172 +         {  /* row i is equality constraint */
 244.173 +            I[i] = 0;
 244.174 +            r[i] = 0;
 244.175 +         }
 244.176 +         v[i] = +DBL_MAX;
 244.177 +      }
 244.178 +      /*** STEP 2 ***/
 244.179 +      for (k = 1; k <= n2+n3+n4; k++)
 244.180 +      {  jk = C[k].j;
 244.181 +         len = get_column(lp, jk, ind, val);
 244.182 +         /* let alpha = max{|A[l,jk]|: r[l] = 0} and let l' be such
 244.183 +            that alpha = |A[l',jk]| */
 244.184 +         alpha = 0.0, ll = 0;
 244.185 +         for (t = 1; t <= len; t++)
 244.186 +         {  l = ind[t];
 244.187 +            if (r[l] == 0 && alpha < fabs(val[t]))
 244.188 +               alpha = fabs(val[t]), ll = l;
 244.189 +         }
 244.190 +         if (alpha >= 0.99)
 244.191 +         {  /* B := B union {jk} */
 244.192 +            glp_set_col_stat(lp, jk, GLP_BS);
 244.193 +            I[ll] = 1;
 244.194 +            v[ll] = alpha;
 244.195 +            /* r[l] := r[l] + 1 for all l such that |A[l,jk]| != 0 */
 244.196 +            for (t = 1; t <= len; t++)
 244.197 +            {  l = ind[t];
 244.198 +               if (val[t] != 0.0) r[l]++;
 244.199 +            }
 244.200 +            /* continue to the next k */
 244.201 +            continue;
 244.202 +         }
 244.203 +         /* if |A[l,jk]| > 0.01 * v[l] for some l, continue to the
 244.204 +            next k */
 244.205 +         for (t = 1; t <= len; t++)
 244.206 +         {  l = ind[t];
 244.207 +            if (fabs(val[t]) > 0.01 * v[l]) break;
 244.208 +         }
 244.209 +         if (t <= len) continue;
 244.210 +         /* otherwise, let alpha = max{|A[l,jk]|: I[l] = 0} and let l'
 244.211 +            be such that alpha = |A[l',jk]| */
 244.212 +         alpha = 0.0, ll = 0;
 244.213 +         for (t = 1; t <= len; t++)
 244.214 +         {  l = ind[t];
 244.215 +            if (I[l] == 0 && alpha < fabs(val[t]))
 244.216 +               alpha = fabs(val[t]), ll = l;
 244.217 +         }
 244.218 +         /* if alpha = 0, continue to the next k */
 244.219 +         if (alpha == 0.0) continue;
 244.220 +         /* B := B union {jk} */
 244.221 +         glp_set_col_stat(lp, jk, GLP_BS);
 244.222 +         I[ll] = 1;
 244.223 +         v[ll] = alpha;
 244.224 +         /* r[l] := r[l] + 1 for all l such that |A[l,jk]| != 0 */
 244.225 +         for (t = 1; t <= len; t++)
 244.226 +         {  l = ind[t];
 244.227 +            if (val[t] != 0.0) r[l]++;
 244.228 +         }
 244.229 +      }
 244.230 +      /*** STEP 3 ***/
 244.231 +      /* add an artificial variable (auxiliary variable for equality
 244.232 +         constraint) to cover each remaining uncovered row */
 244.233 +      for (i = 1; i <= m; i++)
 244.234 +         if (I[i] == 0) glp_set_row_stat(lp, i, GLP_BS);
 244.235 +      /* free working arrays */
 244.236 +      xfree(C);
 244.237 +      xfree(I);
 244.238 +      xfree(r);
 244.239 +      xfree(v);
 244.240 +      xfree(ind);
 244.241 +      xfree(val);
 244.242 +      return;
 244.243 +}
 244.244 +
 244.245 +/***********************************************************************
 244.246 +*  NAME
 244.247 +*
 244.248 +*  glp_cpx_basis - construct Bixby's initial LP basis
 244.249 +*
 244.250 +*  SYNOPSIS
 244.251 +*
 244.252 +*  void glp_cpx_basis(glp_prob *lp);
 244.253 +*
 244.254 +*  DESCRIPTION
 244.255 +*
 244.256 +*  The routine glp_cpx_basis constructs an advanced initial basis for
 244.257 +*  the specified problem object.
 244.258 +*
 244.259 +*  The routine is based on Bixby's algorithm described in the paper:
 244.260 +*
 244.261 +*  Robert E. Bixby. Implementing the Simplex Method: The Initial Basis.
 244.262 +*  ORSA Journal on Computing, Vol. 4, No. 3, 1992, pp. 267-84. */
 244.263 +
 244.264 +void glp_cpx_basis(glp_prob *lp)
 244.265 +{     if (lp->m == 0 || lp->n == 0)
 244.266 +         glp_std_basis(lp);
 244.267 +      else
 244.268 +         cpx_basis(lp);
 244.269 +      return;
 244.270 +}
 244.271 +
 244.272 +/* eof */
   245.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
   245.2 +++ b/deps/glpk/src/glpios.h	Sun Nov 06 20:59:10 2011 +0100
   245.3 @@ -0,0 +1,593 @@
   245.4 +/* glpios.h (integer optimization suite) */
   245.5 +
   245.6 +/***********************************************************************
   245.7 +*  This code is part of GLPK (GNU Linear Programming Kit).
   245.8 +*
   245.9 +*  Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008,
  245.10 +*  2009, 2010, 2011 Andrew Makhorin, Department for Applied Informatics,
  245.11 +*  Moscow Aviation Institute, Moscow, Russia. All rights reserved.
  245.12 +*  E-mail: <mao@gnu.org>.
  245.13 +*
  245.14 +*  GLPK is free software: you can redistribute it and/or modify it
  245.15 +*  under the terms of the GNU General Public License as published by
  245.16 +*  the Free Software Foundation, either version 3 of the License, or
  245.17 +*  (at your option) any later version.
  245.18 +*
  245.19 +*  GLPK is distributed in the hope that it will be useful, but WITHOUT
  245.20 +*  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
  245.21 +*  or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
  245.22 +*  License for more details.
  245.23 +*
  245.24 +*  You should have received a copy of the GNU General Public License
  245.25 +*  along with GLPK. If not, see <http://www.gnu.org/licenses/>.
  245.26 +***********************************************************************/
  245.27 +
  245.28 +#ifndef GLPIOS_H
  245.29 +#define GLPIOS_H
  245.30 +
  245.31 +#define GLP_TREE_DEFINED
  245.32 +typedef struct glp_tree glp_tree;
  245.33 +
  245.34 +#include "glpapi.h"
  245.35 +
  245.36 +typedef struct IOSLOT IOSLOT;
  245.37 +typedef struct IOSNPD IOSNPD;
  245.38 +typedef struct IOSBND IOSBND;
  245.39 +typedef struct IOSTAT IOSTAT;
  245.40 +typedef struct IOSROW IOSROW;
  245.41 +typedef struct IOSAIJ IOSAIJ;
  245.42 +typedef struct IOSPOOL IOSPOOL;
  245.43 +typedef struct IOSCUT IOSCUT;
  245.44 +
  245.45 +struct glp_tree
  245.46 +{     /* branch-and-bound tree */
  245.47 +      int magic;
  245.48 +      /* magic value used for debugging */
  245.49 +      DMP *pool;
  245.50 +      /* memory pool to store all IOS components */
  245.51 +      int n;
  245.52 +      /* number of columns (variables) */
  245.53 +      /*--------------------------------------------------------------*/
  245.54 +      /* problem components corresponding to the original MIP and its
  245.55 +         LP relaxation (used to restore the original problem object on
  245.56 +         exit from the solver) */
  245.57 +      int orig_m;
  245.58 +      /* number of rows */
  245.59 +      unsigned char *orig_type; /* uchar orig_type[1+orig_m+n]; */
  245.60 +      /* types of all variables */
  245.61 +      double *orig_lb; /* double orig_lb[1+orig_m+n]; */
  245.62 +      /* lower bounds of all variables */
  245.63 +      double *orig_ub; /* double orig_ub[1+orig_m+n]; */
  245.64 +      /* upper bounds of all variables */
  245.65 +      unsigned char *orig_stat; /* uchar orig_stat[1+orig_m+n]; */
  245.66 +      /* statuses of all variables */
  245.67 +      double *orig_prim; /* double orig_prim[1+orig_m+n]; */
  245.68 +      /* primal values of all variables */
  245.69 +      double *orig_dual; /* double orig_dual[1+orig_m+n]; */
  245.70 +      /* dual values of all variables */
  245.71 +      double orig_obj;
  245.72 +      /* optimal objective value for LP relaxation */
  245.73 +      /*--------------------------------------------------------------*/
  245.74 +      /* branch-and-bound tree */
  245.75 +      int nslots;
  245.76 +      /* length of the array of slots (enlarged automatically) */
  245.77 +      int avail;
  245.78 +      /* index of the first free slot; 0 means all slots are in use */
  245.79 +      IOSLOT *slot; /* IOSLOT slot[1+nslots]; */
  245.80 +      /* array of slots:
  245.81 +         slot[0] is not used;
  245.82 +         slot[p], 1 <= p <= nslots, either contains a pointer to some
  245.83 +         node of the branch-and-bound tree, in which case p is used on
  245.84 +         API level as the reference number of corresponding subproblem,
  245.85 +         or is free; all free slots are linked into single linked list;
  245.86 +         slot[1] always contains a pointer to the root node (it is free
  245.87 +         only if the tree is empty) */
  245.88 +      IOSNPD *head;
  245.89 +      /* pointer to the head of the active list */
  245.90 +      IOSNPD *tail;
  245.91 +      /* pointer to the tail of the active list */
  245.92 +      /* the active list is a doubly linked list of active subproblems
  245.93 +         which correspond to leaves of the tree; all subproblems in the
  245.94 +         active list are ordered chronologically (each a new subproblem
  245.95 +         is always added to the tail of the list) */
  245.96 +      int a_cnt;
  245.97 +      /* current number of active nodes (including the current one) */
  245.98 +      int n_cnt;
  245.99 +      /* current number of all (active and inactive) nodes */
 245.100 +      int t_cnt;
 245.101 +      /* total number of nodes including those which have been already
 245.102 +         removed from the tree; this count is increased by one whenever
 245.103 +         a new node is created and never decreased */
 245.104 +      /*--------------------------------------------------------------*/
 245.105 +      /* problem components corresponding to the root subproblem */
 245.106 +      int root_m;
 245.107 +      /* number of rows */
 245.108 +      unsigned char *root_type; /* uchar root_type[1+root_m+n]; */
 245.109 +      /* types of all variables */
 245.110 +      double *root_lb; /* double root_lb[1+root_m+n]; */
 245.111 +      /* lower bounds of all variables */
 245.112 +      double *root_ub; /* double root_ub[1+root_m+n]; */
 245.113 +      /* upper bounds of all variables */
 245.114 +      unsigned char *root_stat; /* uchar root_stat[1+root_m+n]; */
 245.115 +      /* statuses of all variables */
 245.116 +      /*--------------------------------------------------------------*/
 245.117 +      /* current subproblem and its LP relaxation */
 245.118 +      IOSNPD *curr;
 245.119 +      /* pointer to the current subproblem (which can be only active);
 245.120 +         NULL means the current subproblem does not exist */
 245.121 +      glp_prob *mip;
 245.122 +      /* original problem object passed to the solver; if the current
 245.123 +         subproblem exists, its LP segment corresponds to LP relaxation
 245.124 +         of the current subproblem; if the current subproblem does not
 245.125 +         exist, its LP segment corresponds to LP relaxation of the root
 245.126 +         subproblem (note that the root subproblem may differ from the
 245.127 +         original MIP, because it may be preprocessed and/or may have
 245.128 +         additional rows) */
 245.129 +      unsigned char *non_int; /* uchar non_int[1+n]; */
 245.130 +      /* these column flags are set each time when LP relaxation of the
 245.131 +         current subproblem has been solved;
 245.132 +         non_int[0] is not used;
 245.133 +         non_int[j], 1 <= j <= n, is j-th column flag; if this flag is
 245.134 +         set, corresponding variable is required to be integer, but its
 245.135 +         value in basic solution is fractional */
 245.136 +      /*--------------------------------------------------------------*/
 245.137 +      /* problem components corresponding to the parent (predecessor)
 245.138 +         subproblem for the current subproblem; used to inspect changes
 245.139 +         on freezing the current subproblem */
 245.140 +      int pred_m;
 245.141 +      /* number of rows */
 245.142 +      int pred_max;
 245.143 +      /* length of the following four arrays (enlarged automatically),
 245.144 +         pred_max >= pred_m + n */
 245.145 +      unsigned char *pred_type; /* uchar pred_type[1+pred_m+n]; */
 245.146 +      /* types of all variables */
 245.147 +      double *pred_lb; /* double pred_lb[1+pred_m+n]; */
 245.148 +      /* lower bounds of all variables */
 245.149 +      double *pred_ub; /* double pred_ub[1+pred_m+n]; */
 245.150 +      /* upper bounds of all variables */
 245.151 +      unsigned char *pred_stat; /* uchar pred_stat[1+pred_m+n]; */
 245.152 +      /* statuses of all variables */
 245.153 +      /****************************************************************/
 245.154 +      /* built-in cut generators segment */
 245.155 +      IOSPOOL *local;
 245.156 +      /* local cut pool */
 245.157 +      void *mir_gen;
 245.158 +      /* pointer to working area used by the MIR cut generator */
 245.159 +      void *clq_gen;
 245.160 +      /* pointer to working area used by the clique cut generator */
 245.161 +      /*--------------------------------------------------------------*/
 245.162 +      void *pcost;
 245.163 +      /* pointer to working area used on pseudocost branching */
 245.164 +      int *iwrk; /* int iwrk[1+n]; */
 245.165 +      /* working array */
 245.166 +      double *dwrk; /* double dwrk[1+n]; */
 245.167 +      /* working array */
 245.168 +      /*--------------------------------------------------------------*/
 245.169 +      /* control parameters and statistics */
 245.170 +      const glp_iocp *parm;
 245.171 +      /* copy of control parameters passed to the solver */
 245.172 +      glp_long tm_beg;
 245.173 +      /* starting time of the search, in seconds; the total time of the
 245.174 +         search is the difference between xtime() and tm_beg */
 245.175 +      glp_long tm_lag;
 245.176 +      /* the most recent time, in seconds, at which the progress of the
 245.177 +         the search was displayed */
 245.178 +      int sol_cnt;
 245.179 +      /* number of integer feasible solutions found */
 245.180 +      /*--------------------------------------------------------------*/
 245.181 +      /* advanced solver interface */
 245.182 +      int reason;
 245.183 +      /* flag indicating the reason why the callback routine is being
 245.184 +         called (see glpk.h) */
 245.185 +      int stop;
 245.186 +      /* flag indicating that the callback routine requires premature
 245.187 +         termination of the search */
 245.188 +      int next_p;
 245.189 +      /* reference number of active subproblem selected to continue
 245.190 +         the search; 0 means no subproblem has been selected */
 245.191 +      int reopt;
 245.192 +      /* flag indicating that the current LP relaxation needs to be
 245.193 +         re-optimized */
 245.194 +      int reinv;
 245.195 +      /* flag indicating that some (non-active) rows were removed from
 245.196 +         the current LP relaxation, so if there no new rows appear, the
 245.197 +         basis must be re-factorized */
 245.198 +      int br_var;
 245.199 +      /* the number of variable chosen to branch on */
 245.200 +      int br_sel;
 245.201 +      /* flag indicating which branch (subproblem) is suggested to be
 245.202 +         selected to continue the search:
 245.203 +         GLP_DN_BRNCH - select down-branch
 245.204 +         GLP_UP_BRNCH - select up-branch
 245.205 +         GLP_NO_BRNCH - use general selection technique */
 245.206 +      int child;
 245.207 +      /* subproblem reference number corresponding to br_sel */
 245.208 +};
 245.209 +
 245.210 +struct IOSLOT
 245.211 +{     /* node subproblem slot */
 245.212 +      IOSNPD *node;
 245.213 +      /* pointer to subproblem descriptor; NULL means free slot */
 245.214 +      int next;
 245.215 +      /* index of another free slot (only if this slot is free) */
 245.216 +};
 245.217 +
 245.218 +struct IOSNPD
 245.219 +{     /* node subproblem descriptor */
 245.220 +      int p;
 245.221 +      /* subproblem reference number (it is the index to corresponding
 245.222 +         slot, i.e. slot[p] points to this descriptor) */
 245.223 +      IOSNPD *up;
 245.224 +      /* pointer to the parent subproblem; NULL means this node is the
 245.225 +         root of the tree, in which case p = 1 */
 245.226 +      int level;
 245.227 +      /* node level (the root node has level 0) */
 245.228 +      int count;
 245.229 +      /* if count = 0, this subproblem is active; if count > 0, this
 245.230 +         subproblem is inactive, in which case count is the number of
 245.231 +         its child subproblems */
 245.232 +      /* the following three linked lists are destroyed on reviving and
 245.233 +         built anew on freezing the subproblem: */
 245.234 +      IOSBND *b_ptr;
 245.235 +      /* linked list of rows and columns of the parent subproblem whose
 245.236 +         types and bounds were changed */
 245.237 +      IOSTAT *s_ptr;
 245.238 +      /* linked list of rows and columns of the parent subproblem whose
 245.239 +         statuses were changed */
 245.240 +      IOSROW *r_ptr;
 245.241 +      /* linked list of rows (cuts) added to the parent subproblem */
 245.242 +      int solved;
 245.243 +      /* how many times LP relaxation of this subproblem was solved;
 245.244 +         for inactive subproblem this count is always non-zero;
 245.245 +         for active subproblem, which is not current, this count may be
 245.246 +         non-zero, if the subproblem was temporarily suspended */
 245.247 +      double lp_obj;
 245.248 +      /* optimal objective value to LP relaxation of this subproblem;
 245.249 +         on creating a subproblem this value is inherited from its
 245.250 +         parent; for the root subproblem, which has no parent, this
 245.251 +         value is initially set to -DBL_MAX (minimization) or +DBL_MAX
 245.252 +         (maximization); each time the subproblem is re-optimized, this
 245.253 +         value is appropriately changed */
 245.254 +      double bound;
 245.255 +      /* local lower (minimization) or upper (maximization) bound for
 245.256 +         integer optimal solution to *this* subproblem; this bound is
 245.257 +         local in the sense that only subproblems in the subtree rooted
 245.258 +         at this node cannot have better integer feasible solutions;
 245.259 +         on creating a subproblem its local bound is inherited from its
 245.260 +         parent and then can be made stronger (never weaker); for the
 245.261 +         root subproblem its local bound is initially set to -DBL_MAX
 245.262 +         (minimization) or +DBL_MAX (maximization) and then improved as
 245.263 +         the root LP relaxation has been solved */
 245.264 +      /* the following two quantities are defined only if LP relaxation
 245.265 +         of this subproblem was solved at least once (solved > 0): */
 245.266 +      int ii_cnt;
 245.267 +      /* number of integer variables whose value in optimal solution to
 245.268 +         LP relaxation of this subproblem is fractional */
 245.269 +      double ii_sum;
 245.270 +      /* sum of integer infeasibilities */
 245.271 +#if 1 /* 30/XI-2009 */
 245.272 +      int changed;
 245.273 +      /* how many times this subproblem was re-formulated (by adding
 245.274 +         cutting plane constraints) */
 245.275 +#endif
 245.276 +      int br_var;
 245.277 +      /* ordinal number of branching variable, 1 <= br_var <= n, used
 245.278 +         to split this subproblem; 0 means that either this subproblem
 245.279 +         is active or branching was made on a constraint */
 245.280 +      double br_val;
 245.281 +      /* (fractional) value of branching variable in optimal solution
 245.282 +         to final LP relaxation of this subproblem */
 245.283 +      void *data; /* char data[tree->cb_size]; */
 245.284 +      /* pointer to the application-specific data */
 245.285 +      IOSNPD *temp;
 245.286 +      /* working pointer used by some routines */
 245.287 +      IOSNPD *prev;
 245.288 +      /* pointer to previous subproblem in the active list */
 245.289 +      IOSNPD *next;
 245.290 +      /* pointer to next subproblem in the active list */
 245.291 +};
 245.292 +
 245.293 +struct IOSBND
 245.294 +{     /* bounds change entry */
 245.295 +      int k;
 245.296 +      /* ordinal number of corresponding row (1 <= k <= m) or column
 245.297 +         (m+1 <= k <= m+n), where m and n are the number of rows and
 245.298 +         columns, resp., in the parent subproblem */
 245.299 +      unsigned char type;
 245.300 +      /* new type */
 245.301 +      double lb;
 245.302 +      /* new lower bound */
 245.303 +      double ub;
 245.304 +      /* new upper bound */
 245.305 +      IOSBND *next;
 245.306 +      /* pointer to next entry for the same subproblem */
 245.307 +};
 245.308 +
 245.309 +struct IOSTAT
 245.310 +{     /* status change entry */
 245.311 +      int k;
 245.312 +      /* ordinal number of corresponding row (1 <= k <= m) or column
 245.313 +         (m+1 <= k <= m+n), where m and n are the number of rows and
 245.314 +         columns, resp., in the parent subproblem */
 245.315 +      unsigned char stat;
 245.316 +      /* new status */
 245.317 +      IOSTAT *next;
 245.318 +      /* pointer to next entry for the same subproblem */
 245.319 +};
 245.320 +
 245.321 +struct IOSROW
 245.322 +{     /* row (constraint) addition entry */
 245.323 +      char *name;
 245.324 +      /* row name or NULL */
 245.325 +      unsigned char origin;
 245.326 +      /* row origin flag (see glp_attr.origin) */
 245.327 +      unsigned char klass;
 245.328 +      /* row class descriptor (see glp_attr.klass) */
 245.329 +      unsigned char type;
 245.330 +      /* row type (GLP_LO, GLP_UP, etc.) */
 245.331 +      double lb;
 245.332 +      /* row lower bound */
 245.333 +      double ub;
 245.334 +      /* row upper bound */
 245.335 +      IOSAIJ *ptr;
 245.336 +      /* pointer to the row coefficient list */
 245.337 +      double rii;
 245.338 +      /* row scale factor */
 245.339 +      unsigned char stat;
 245.340 +      /* row status (GLP_BS, GLP_NL, etc.) */
 245.341 +      IOSROW *next;
 245.342 +      /* pointer to next entry for the same subproblem */
 245.343 +};
 245.344 +
 245.345 +struct IOSAIJ
 245.346 +{     /* constraint coefficient */
 245.347 +      int j;
 245.348 +      /* variable (column) number, 1 <= j <= n */
 245.349 +      double val;
 245.350 +      /* non-zero coefficient value */
 245.351 +      IOSAIJ *next;
 245.352 +      /* pointer to next coefficient for the same row */
 245.353 +};
 245.354 +
 245.355 +struct IOSPOOL
 245.356 +{     /* cut pool */
 245.357 +      int size;
 245.358 +      /* pool size = number of cuts in the pool */
 245.359 +      IOSCUT *head;
 245.360 +      /* pointer to the first cut */
 245.361 +      IOSCUT *tail;
 245.362 +      /* pointer to the last cut */
 245.363 +      int ord;
 245.364 +      /* ordinal number of the current cut, 1 <= ord <= size */
 245.365 +      IOSCUT *curr;
 245.366 +      /* pointer to the current cut */
 245.367 +};
 245.368 +
 245.369 +struct IOSCUT
 245.370 +{     /* cut (cutting plane constraint) */
 245.371 +      char *name;
 245.372 +      /* cut name or NULL */
 245.373 +      unsigned char klass;
 245.374 +      /* cut class descriptor (see glp_attr.klass) */
 245.375 +      IOSAIJ *ptr;
 245.376 +      /* pointer to the cut coefficient list */
 245.377 +      unsigned char type;
 245.378 +      /* cut type:
 245.379 +         GLP_LO: sum a[j] * x[j] >= b
 245.380 +         GLP_UP: sum a[j] * x[j] <= b
 245.381 +         GLP_FX: sum a[j] * x[j]  = b */
 245.382 +      double rhs;
 245.383 +      /* cut right-hand side */
 245.384 +      IOSCUT *prev;
 245.385 +      /* pointer to previous cut */
 245.386 +      IOSCUT *next;
 245.387 +      /* pointer to next cut */
 245.388 +};
 245.389 +
 245.390 +#define ios_create_tree _glp_ios_create_tree
 245.391 +glp_tree *ios_create_tree(glp_prob *mip, const glp_iocp *parm);
 245.392 +/* create branch-and-bound tree */
 245.393 +
 245.394 +#define ios_revive_node _glp_ios_revive_node
 245.395 +void ios_revive_node(glp_tree *tree, int p);
 245.396 +/* revive specified subproblem */
 245.397 +
 245.398 +#define ios_freeze_node _glp_ios_freeze_node
 245.399 +void ios_freeze_node(glp_tree *tree);
 245.400 +/* freeze current subproblem */
 245.401 +
 245.402 +#define ios_clone_node _glp_ios_clone_node
 245.403 +void ios_clone_node(glp_tree *tree, int p, int nnn, int ref[]);
 245.404 +/* clone specified subproblem */
 245.405 +
 245.406 +#define ios_delete_node _glp_ios_delete_node
 245.407 +void ios_delete_node(glp_tree *tree, int p);
 245.408 +/* delete specified subproblem */
 245.409 +
 245.410 +#define ios_delete_tree _glp_ios_delete_tree
 245.411 +void ios_delete_tree(glp_tree *tree);
 245.412 +/* delete branch-and-bound tree */
 245.413 +
 245.414 +#define ios_eval_degrad _glp_ios_eval_degrad
 245.415 +void ios_eval_degrad(glp_tree *tree, int j, double *dn, double *up);
 245.416 +/* estimate obj. degrad. for down- and up-branches */
 245.417 +
 245.418 +#define ios_round_bound _glp_ios_round_bound
 245.419 +double ios_round_bound(glp_tree *tree, double bound);
 245.420 +/* improve local bound by rounding */
 245.421 +
 245.422 +#define ios_is_hopeful _glp_ios_is_hopeful
 245.423 +int ios_is_hopeful(glp_tree *tree, double bound);
 245.424 +/* check if subproblem is hopeful */
 245.425 +
 245.426 +#define ios_best_node _glp_ios_best_node
 245.427 +int ios_best_node(glp_tree *tree);
 245.428 +/* find active node with best local bound */
 245.429 +
 245.430 +#define ios_relative_gap _glp_ios_relative_gap
 245.431 +double ios_relative_gap(glp_tree *tree);
 245.432 +/* compute relative mip gap */
 245.433 +
 245.434 +#define ios_solve_node _glp_ios_solve_node
 245.435 +int ios_solve_node(glp_tree *tree);
 245.436 +/* solve LP relaxation of current subproblem */
 245.437 +
 245.438 +#define ios_create_pool _glp_ios_create_pool
 245.439 +IOSPOOL *ios_create_pool(glp_tree *tree);
 245.440 +/* create cut pool */
 245.441 +
 245.442 +#define ios_add_row _glp_ios_add_row
 245.443 +int ios_add_row(glp_tree *tree, IOSPOOL *pool,
 245.444 +      const char *name, int klass, int flags, int len, const int ind[],
 245.445 +      const double val[], int type, double rhs);
 245.446 +/* add row (constraint) to the cut pool */
 245.447 +
 245.448 +#define ios_find_row _glp_ios_find_row
 245.449 +IOSCUT *ios_find_row(IOSPOOL *pool, int i);
 245.450 +/* find row (constraint) in the cut pool */
 245.451 +
 245.452 +#define ios_del_row _glp_ios_del_row
 245.453 +void ios_del_row(glp_tree *tree, IOSPOOL *pool, int i);
 245.454 +/* remove row (constraint) from the cut pool */
 245.455 +
 245.456 +#define ios_clear_pool _glp_ios_clear_pool
 245.457 +void ios_clear_pool(glp_tree *tree, IOSPOOL *pool);
 245.458 +/* remove all rows (constraints) from the cut pool */
 245.459 +
 245.460 +#define ios_delete_pool _glp_ios_delete_pool
 245.461 +void ios_delete_pool(glp_tree *tree, IOSPOOL *pool);
 245.462 +/* delete cut pool */
 245.463 +
 245.464 +#define ios_preprocess_node _glp_ios_preprocess_node
 245.465 +int ios_preprocess_node(glp_tree *tree, int max_pass);
 245.466 +/* preprocess current subproblem */
 245.467 +
 245.468 +#define ios_driver _glp_ios_driver
 245.469 +int ios_driver(glp_tree *tree);
 245.470 +/* branch-and-bound driver */
 245.471 +
 245.472 +/**********************************************************************/
 245.473 +
 245.474 +typedef struct IOSVEC IOSVEC;
 245.475 +
 245.476 +struct IOSVEC
 245.477 +{     /* sparse vector v = (v[j]) */
 245.478 +      int n;
 245.479 +      /* dimension, n >= 0 */
 245.480 +      int nnz;
 245.481 +      /* number of non-zero components, 0 <= nnz <= n */
 245.482 +      int *pos; /* int pos[1+n]; */
 245.483 +      /* pos[j] = k, 1 <= j <= n, is position of (non-zero) v[j] in the
 245.484 +         arrays ind and val, where 1 <= k <= nnz; pos[j] = 0 means that
 245.485 +         v[j] is structural zero */
 245.486 +      int *ind; /* int ind[1+n]; */
 245.487 +      /* ind[k] = j, 1 <= k <= nnz, is index of v[j] */
 245.488 +      double *val; /* double val[1+n]; */
 245.489 +      /* val[k], 1 <= k <= nnz, is a numeric value of v[j] */
 245.490 +};
 245.491 +
 245.492 +#define ios_create_vec _glp_ios_create_vec
 245.493 +IOSVEC *ios_create_vec(int n);
 245.494 +/* create sparse vector */
 245.495 +
 245.496 +#define ios_check_vec _glp_ios_check_vec
 245.497 +void ios_check_vec(IOSVEC *v);
 245.498 +/* check that sparse vector has correct representation */
 245.499 +
 245.500 +#define ios_get_vj _glp_ios_get_vj
 245.501 +double ios_get_vj(IOSVEC *v, int j);
 245.502 +/* retrieve component of sparse vector */
 245.503 +
 245.504 +#define ios_set_vj _glp_ios_set_vj
 245.505 +void ios_set_vj(IOSVEC *v, int j, double val);
 245.506 +/* set/change component of sparse vector */
 245.507 +
 245.508 +#define ios_clear_vec _glp_ios_clear_vec
 245.509 +void ios_clear_vec(IOSVEC *v);
 245.510 +/* set all components of sparse vector to zero */
 245.511 +
 245.512 +#define ios_clean_vec _glp_ios_clean_vec
 245.513 +void ios_clean_vec(IOSVEC *v, double eps);
 245.514 +/* remove zero or small components from sparse vector */
 245.515 +
 245.516 +#define ios_copy_vec _glp_ios_copy_vec
 245.517 +void ios_copy_vec(IOSVEC *x, IOSVEC *y);
 245.518 +/* copy sparse vector (x := y) */
 245.519 +
 245.520 +#define ios_linear_comb _glp_ios_linear_comb
 245.521 +void ios_linear_comb(IOSVEC *x, double a, IOSVEC *y);
 245.522 +/* compute linear combination (x := x + a * y) */
 245.523 +
 245.524 +#define ios_delete_vec _glp_ios_delete_vec
 245.525 +void ios_delete_vec(IOSVEC *v);
 245.526 +/* delete sparse vector */
 245.527 +
 245.528 +/**********************************************************************/
 245.529 +
 245.530 +#define ios_gmi_gen _glp_ios_gmi_gen
 245.531 +void ios_gmi_gen(glp_tree *tree);
 245.532 +/* generate Gomory's mixed integer cuts */
 245.533 +
 245.534 +#define ios_mir_init _glp_ios_mir_init
 245.535 +void *ios_mir_init(glp_tree *tree);
 245.536 +/* initialize MIR cut generator */
 245.537 +
 245.538 +#define ios_mir_gen _glp_ios_mir_gen
 245.539 +void ios_mir_gen(glp_tree *tree, void *gen);
 245.540 +/* generate MIR cuts */
 245.541 +
 245.542 +#define ios_mir_term _glp_ios_mir_term
 245.543 +void ios_mir_term(void *gen);
 245.544 +/* terminate MIR cut generator */
 245.545 +
 245.546 +#define ios_cov_gen _glp_ios_cov_gen
 245.547 +void ios_cov_gen(glp_tree *tree);
 245.548 +/* generate mixed cover cuts */
 245.549 +
 245.550 +#define ios_clq_init _glp_ios_clq_init
 245.551 +void *ios_clq_init(glp_tree *tree);
 245.552 +/* initialize clique cut generator */
 245.553 +
 245.554 +#define ios_clq_gen _glp_ios_clq_gen
 245.555 +void ios_clq_gen(glp_tree *tree, void *gen);
 245.556 +/* generate clique cuts */
 245.557 +
 245.558 +#define ios_clq_term _glp_ios_clq_term
 245.559 +void ios_clq_term(void *gen);
 245.560 +/* terminate clique cut generator */
 245.561 +
 245.562 +#define ios_pcost_init _glp_ios_pcost_init
 245.563 +void *ios_pcost_init(glp_tree *tree);
 245.564 +/* initialize working data used on pseudocost branching */
 245.565 +
 245.566 +#define ios_pcost_branch _glp_ios_pcost_branch
 245.567 +int ios_pcost_branch(glp_tree *T, int *next);
 245.568 +/* choose branching variable with pseudocost branching */
 245.569 +
 245.570 +#define ios_pcost_update _glp_ios_pcost_update
 245.571 +void ios_pcost_update(glp_tree *tree);
 245.572 +/* update history information for pseudocost branching */
 245.573 +
 245.574 +#define ios_pcost_free _glp_ios_pcost_free
 245.575 +void ios_pcost_free(glp_tree *tree);
 245.576 +/* free working area used on pseudocost branching */
 245.577 +
 245.578 +#define ios_feas_pump _glp_ios_feas_pump
 245.579 +void ios_feas_pump(glp_tree *T);
 245.580 +/* feasibility pump heuristic */
 245.581 +
 245.582 +#define ios_process_cuts _glp_ios_process_cuts
 245.583 +void ios_process_cuts(glp_tree *T);
 245.584 +/* process cuts stored in the local cut pool */
 245.585 +
 245.586 +#define ios_choose_node _glp_ios_choose_node
 245.587 +int ios_choose_node(glp_tree *T);
 245.588 +/* select subproblem to continue the search */
 245.589 +
 245.590 +#define ios_choose_var _glp_ios_choose_var
 245.591 +int ios_choose_var(glp_tree *T, int *next);
 245.592 +/* select variable to branch on */
 245.593 +
 245.594 +#endif
 245.595 +
 245.596 +/* eof */
   246.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
   246.2 +++ b/deps/glpk/src/glpios01.c	Sun Nov 06 20:59:10 2011 +0100
   246.3 @@ -0,0 +1,1611 @@
   246.4 +/* glpios01.c */
   246.5 +
   246.6 +/***********************************************************************
   246.7 +*  This code is part of GLPK (GNU Linear Programming Kit).
   246.8 +*
   246.9 +*  Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008,
  246.10 +*  2009, 2010, 2011 Andrew Makhorin, Department for Applied Informatics,
  246.11 +*  Moscow Aviation Institute, Moscow, Russia. All rights reserved.
  246.12 +*  E-mail: <mao@gnu.org>.
  246.13 +*
  246.14 +*  GLPK is free software: you can redistribute it and/or modify it
  246.15 +*  under the terms of the GNU General Public License as published by
  246.16 +*  the Free Software Foundation, either version 3 of the License, or
  246.17 +*  (at your option) any later version.
  246.18 +*
  246.19 +*  GLPK is distributed in the hope that it will be useful, but WITHOUT
  246.20 +*  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
  246.21 +*  or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
  246.22 +*  License for more details.
  246.23 +*
  246.24 +*  You should have received a copy of the GNU General Public License
  246.25 +*  along with GLPK. If not, see <http://www.gnu.org/licenses/>.
  246.26 +***********************************************************************/
  246.27 +
  246.28 +#include "glpios.h"
  246.29 +
  246.30 +/***********************************************************************
  246.31 +*  NAME
  246.32 +*
  246.33 +*  ios_create_tree - create branch-and-bound tree
  246.34 +*
  246.35 +*  SYNOPSIS
  246.36 +*
  246.37 +*  #include "glpios.h"
  246.38 +*  glp_tree *ios_create_tree(glp_prob *mip, const glp_iocp *parm);
  246.39 +*
  246.40 +*  DESCRIPTION
  246.41 +*
  246.42 +*  The routine ios_create_tree creates the branch-and-bound tree.
  246.43 +*
  246.44 +*  Being created the tree consists of the only root subproblem whose
  246.45 +*  reference number is 1. Note that initially the root subproblem is in
  246.46 +*  frozen state and therefore needs to be revived.
  246.47 +*
  246.48 +*  RETURNS
  246.49 +*
  246.50 +*  The routine returns a pointer to the tree created. */
  246.51 +
  246.52 +static IOSNPD *new_node(glp_tree *tree, IOSNPD *parent);
  246.53 +
  246.54 +glp_tree *ios_create_tree(glp_prob *mip, const glp_iocp *parm)
  246.55 +{     int m = mip->m;
  246.56 +      int n = mip->n;
  246.57 +      glp_tree *tree;
  246.58 +      int i, j;
  246.59 +      xassert(mip->tree == NULL);
  246.60 +      mip->tree = tree = xmalloc(sizeof(glp_tree));
  246.61 +      tree->pool = dmp_create_pool();
  246.62 +      tree->n = n;
  246.63 +      /* save original problem components */
  246.64 +      tree->orig_m = m;
  246.65 +      tree->orig_type = xcalloc(1+m+n, sizeof(char));
  246.66 +      tree->orig_lb = xcalloc(1+m+n, sizeof(double));
  246.67 +      tree->orig_ub = xcalloc(1+m+n, sizeof(double));
  246.68 +      tree->orig_stat = xcalloc(1+m+n, sizeof(char));
  246.69 +      tree->orig_prim = xcalloc(1+m+n, sizeof(double));
  246.70 +      tree->orig_dual = xcalloc(1+m+n, sizeof(double));
  246.71 +      for (i = 1; i <= m; i++)
  246.72 +      {  GLPROW *row = mip->row[i];
  246.73 +         tree->orig_type[i] = (char)row->type;
  246.74 +         tree->orig_lb[i] = row->lb;
  246.75 +         tree->orig_ub[i] = row->ub;
  246.76 +         tree->orig_stat[i] = (char)row->stat;
  246.77 +         tree->orig_prim[i] = row->prim;
  246.78 +         tree->orig_dual[i] = row->dual;
  246.79 +      }
  246.80 +      for (j = 1; j <= n; j++)
  246.81 +      {  GLPCOL *col = mip->col[j];
  246.82 +         tree->orig_type[m+j] = (char)col->type;
  246.83 +         tree->orig_lb[m+j] = col->lb;
  246.84 +         tree->orig_ub[m+j] = col->ub;
  246.85 +         tree->orig_stat[m+j] = (char)col->stat;
  246.86 +         tree->orig_prim[m+j] = col->prim;
  246.87 +         tree->orig_dual[m+j] = col->dual;
  246.88 +      }
  246.89 +      tree->orig_obj = mip->obj_val;
  246.90 +      /* initialize the branch-and-bound tree */
  246.91 +      tree->nslots = 0;
  246.92 +      tree->avail = 0;
  246.93 +      tree->slot = NULL;
  246.94 +      tree->head = tree->tail = NULL;
  246.95 +      tree->a_cnt = tree->n_cnt = tree->t_cnt = 0;
  246.96 +      /* the root subproblem is not solved yet, so its final components
  246.97 +         are unknown so far */
  246.98 +      tree->root_m = 0;
  246.99 +      tree->root_type = NULL;
 246.100 +      tree->root_lb = tree->root_ub = NULL;
 246.101 +      tree->root_stat = NULL;
 246.102 +      /* the current subproblem does not exist yet */
 246.103 +      tree->curr = NULL;
 246.104 +      tree->mip = mip;
 246.105 +      /*tree->solved = 0;*/
 246.106 +      tree->non_int = xcalloc(1+n, sizeof(char));
 246.107 +      memset(&tree->non_int[1], 0, n);
 246.108 +      /* arrays to save parent subproblem components will be allocated
 246.109 +         later */
 246.110 +      tree->pred_m = tree->pred_max = 0;
 246.111 +      tree->pred_type = NULL;
 246.112 +      tree->pred_lb = tree->pred_ub = NULL;
 246.113 +      tree->pred_stat = NULL;
 246.114 +      /* cut generator */
 246.115 +      tree->local = ios_create_pool(tree);
 246.116 +      /*tree->first_attempt = 1;*/
 246.117 +      /*tree->max_added_cuts = 0;*/
 246.118 +      /*tree->min_eff = 0.0;*/
 246.119 +      /*tree->miss = 0;*/
 246.120 +      /*tree->just_selected = 0;*/
 246.121 +      tree->mir_gen = NULL;
 246.122 +      tree->clq_gen = NULL;
 246.123 +      /*tree->round = 0;*/
 246.124 +#if 0
 246.125 +      /* create the conflict graph */
 246.126 +      tree->n_ref = xcalloc(1+n, sizeof(int));
 246.127 +      memset(&tree->n_ref[1], 0, n * sizeof(int));
 246.128 +      tree->c_ref = xcalloc(1+n, sizeof(int));
 246.129 +      memset(&tree->c_ref[1], 0, n * sizeof(int));
 246.130 +      tree->g = scg_create_graph(0);
 246.131 +      tree->j_ref = xcalloc(1+tree->g->n_max, sizeof(int));
 246.132 +#endif
 246.133 +      /* pseudocost branching */
 246.134 +      tree->pcost = NULL;
 246.135 +      tree->iwrk = xcalloc(1+n, sizeof(int));
 246.136 +      tree->dwrk = xcalloc(1+n, sizeof(double));
 246.137 +      /* initialize control parameters */
 246.138 +      tree->parm = parm;
 246.139 +      tree->tm_beg = xtime();
 246.140 +      tree->tm_lag = xlset(0);
 246.141 +      tree->sol_cnt = 0;
 246.142 +      /* initialize advanced solver interface */
 246.143 +      tree->reason = 0;
 246.144 +      tree->reopt = 0;
 246.145 +      tree->reinv = 0;
 246.146 +      tree->br_var = 0;
 246.147 +      tree->br_sel = 0;
 246.148 +      tree->child = 0;
 246.149 +      tree->next_p = 0;
 246.150 +      /*tree->btrack = NULL;*/
 246.151 +      tree->stop = 0;
 246.152 +      /* create the root subproblem, which initially is identical to
 246.153 +         the original MIP */
 246.154 +      new_node(tree, NULL);
 246.155 +      return tree;
 246.156 +}
 246.157 +
 246.158 +/***********************************************************************
 246.159 +*  NAME
 246.160 +*
 246.161 +*  ios_revive_node - revive specified subproblem
 246.162 +*
 246.163 +*  SYNOPSIS
 246.164 +*
 246.165 +*  #include "glpios.h"
 246.166 +*  void ios_revive_node(glp_tree *tree, int p);
 246.167 +*
 246.168 +*  DESCRIPTION
 246.169 +*
 246.170 +*  The routine ios_revive_node revives the specified subproblem, whose
 246.171 +*  reference number is p, and thereby makes it the current subproblem.
 246.172 +*  Note that the specified subproblem must be active. Besides, if the
 246.173 +*  current subproblem already exists, it must be frozen before reviving
 246.174 +*  another subproblem. */
 246.175 +
 246.176 +void ios_revive_node(glp_tree *tree, int p)
 246.177 +{     glp_prob *mip = tree->mip;
 246.178 +      IOSNPD *node, *root;
 246.179 +      /* obtain pointer to the specified subproblem */
 246.180 +      xassert(1 <= p && p <= tree->nslots);
 246.181 +      node = tree->slot[p].node;
 246.182 +      xassert(node != NULL);
 246.183 +      /* the specified subproblem must be active */
 246.184 +      xassert(node->count == 0);
 246.185 +      /* the current subproblem must not exist */
 246.186 +      xassert(tree->curr == NULL);
 246.187 +      /* the specified subproblem becomes current */
 246.188 +      tree->curr = node;
 246.189 +      /*tree->solved = 0;*/
 246.190 +      /* obtain pointer to the root subproblem */
 246.191 +      root = tree->slot[1].node;
 246.192 +      xassert(root != NULL);
 246.193 +      /* at this point problem object components correspond to the root
 246.194 +         subproblem, so if the root subproblem should be revived, there
 246.195 +         is nothing more to do */
 246.196 +      if (node == root) goto done;
 246.197 +      xassert(mip->m == tree->root_m);
 246.198 +      /* build path from the root to the current node */
 246.199 +      node->temp = NULL;
 246.200 +      for (node = node; node != NULL; node = node->up)
 246.201 +      {  if (node->up == NULL)
 246.202 +            xassert(node == root);
 246.203 +         else
 246.204 +            node->up->temp = node;
 246.205 +      }
 246.206 +      /* go down from the root to the current node and make necessary
 246.207 +         changes to restore components of the current subproblem */
 246.208 +      for (node = root; node != NULL; node = node->temp)
 246.209 +      {  int m = mip->m;
 246.210 +         int n = mip->n;
 246.211 +         /* if the current node is reached, the problem object at this
 246.212 +            point corresponds to its parent, so save attributes of rows
 246.213 +            and columns for the parent subproblem */
 246.214 +         if (node->temp == NULL)
 246.215 +         {  int i, j;
 246.216 +            tree->pred_m = m;
 246.217 +            /* allocate/reallocate arrays, if necessary */
 246.218 +            if (tree->pred_max < m + n)
 246.219 +            {  int new_size = m + n + 100;
 246.220 +               if (tree->pred_type != NULL) xfree(tree->pred_type);
 246.221 +               if (tree->pred_lb != NULL) xfree(tree->pred_lb);
 246.222 +               if (tree->pred_ub != NULL) xfree(tree->pred_ub);
 246.223 +               if (tree->pred_stat != NULL) xfree(tree->pred_stat);
 246.224 +               tree->pred_max = new_size;
 246.225 +               tree->pred_type = xcalloc(1+new_size, sizeof(char));
 246.226 +               tree->pred_lb = xcalloc(1+new_size, sizeof(double));
 246.227 +               tree->pred_ub = xcalloc(1+new_size, sizeof(double));
 246.228 +               tree->pred_stat = xcalloc(1+new_size, sizeof(char));
 246.229 +            }
 246.230 +            /* save row attributes */
 246.231 +            for (i = 1; i <= m; i++)
 246.232 +            {  GLPROW *row = mip->row[i];
 246.233 +               tree->pred_type[i] = (char)row->type;
 246.234 +               tree->pred_lb[i] = row->lb;
 246.235 +               tree->pred_ub[i] = row->ub;
 246.236 +               tree->pred_stat[i] = (char)row->stat;
 246.237 +            }
 246.238 +            /* save column attributes */
 246.239 +            for (j = 1; j <= n; j++)
 246.240 +            {  GLPCOL *col = mip->col[j];
 246.241 +               tree->pred_type[mip->m+j] = (char)col->type;
 246.242 +               tree->pred_lb[mip->m+j] = col->lb;
 246.243 +               tree->pred_ub[mip->m+j] = col->ub;
 246.244 +               tree->pred_stat[mip->m+j] = (char)col->stat;
 246.245 +            }
 246.246 +         }
 246.247 +         /* change bounds of rows and columns */
 246.248 +         {  IOSBND *b;
 246.249 +            for (b = node->b_ptr; b != NULL; b = b->next)
 246.250 +            {  if (b->k <= m)
 246.251 +                  glp_set_row_bnds(mip, b->k, b->type, b->lb, b->ub);
 246.252 +               else
 246.253 +                  glp_set_col_bnds(mip, b->k-m, b->type, b->lb, b->ub);
 246.254 +            }
 246.255 +         }
 246.256 +         /* change statuses of rows and columns */
 246.257 +         {  IOSTAT *s;
 246.258 +            for (s = node->s_ptr; s != NULL; s = s->next)
 246.259 +            {  if (s->k <= m)
 246.260 +                  glp_set_row_stat(mip, s->k, s->stat);
 246.261 +               else
 246.262 +                  glp_set_col_stat(mip, s->k-m, s->stat);
 246.263 +            }
 246.264 +         }
 246.265 +         /* add new rows */
 246.266 +         if (node->r_ptr != NULL)
 246.267 +         {  IOSROW *r;
 246.268 +            IOSAIJ *a;
 246.269 +            int i, len, *ind;
 246.270 +            double *val;
 246.271 +            ind = xcalloc(1+n, sizeof(int));
 246.272 +            val = xcalloc(1+n, sizeof(double));
 246.273 +            for (r = node->r_ptr; r != NULL; r = r->next)
 246.274 +            {  i = glp_add_rows(mip, 1);
 246.275 +               glp_set_row_name(mip, i, r->name);
 246.276 +#if 1 /* 20/IX-2008 */
 246.277 +               xassert(mip->row[i]->level == 0);
 246.278 +               mip->row[i]->level = node->level;
 246.279 +               mip->row[i]->origin = r->origin;
 246.280 +               mip->row[i]->klass = r->klass;
 246.281 +#endif
 246.282 +               glp_set_row_bnds(mip, i, r->type, r->lb, r->ub);
 246.283 +               len = 0;
 246.284 +               for (a = r->ptr; a != NULL; a = a->next)
 246.285 +                  len++, ind[len] = a->j, val[len] = a->val;
 246.286 +               glp_set_mat_row(mip, i, len, ind, val);
 246.287 +               glp_set_rii(mip, i, r->rii);
 246.288 +               glp_set_row_stat(mip, i, r->stat);
 246.289 +            }
 246.290 +            xfree(ind);
 246.291 +            xfree(val);
 246.292 +         }
 246.293 +#if 0
 246.294 +         /* add new edges to the conflict graph */
 246.295 +         /* add new cliques to the conflict graph */
 246.296 +         /* (not implemented yet) */
 246.297 +         xassert(node->own_nn == 0);
 246.298 +         xassert(node->own_nc == 0);
 246.299 +         xassert(node->e_ptr == NULL);
 246.300 +#endif
 246.301 +      }
 246.302 +      /* the specified subproblem has been revived */
 246.303 +      node = tree->curr;
 246.304 +      /* delete its bound change list */
 246.305 +      while (node->b_ptr != NULL)
 246.306 +      {  IOSBND *b;
 246.307 +         b = node->b_ptr;
 246.308 +         node->b_ptr = b->next;
 246.309 +         dmp_free_atom(tree->pool, b, sizeof(IOSBND));
 246.310 +      }
 246.311 +      /* delete its status change list */
 246.312 +      while (node->s_ptr != NULL)
 246.313 +      {  IOSTAT *s;
 246.314 +         s = node->s_ptr;
 246.315 +         node->s_ptr = s->next;
 246.316 +         dmp_free_atom(tree->pool, s, sizeof(IOSTAT));
 246.317 +      }
 246.318 +#if 1 /* 20/XI-2009 */
 246.319 +      /* delete its row addition list (additional rows may appear, for
 246.320 +         example, due to branching on GUB constraints */
 246.321 +      while (node->r_ptr != NULL)
 246.322 +      {  IOSROW *r;
 246.323 +         r = node->r_ptr;
 246.324 +         node->r_ptr = r->next;
 246.325 +         xassert(r->name == NULL);
 246.326 +         while (r->ptr != NULL)
 246.327 +         {  IOSAIJ *a;
 246.328 +            a = r->ptr;
 246.329 +            r->ptr = a->next;
 246.330 +            dmp_free_atom(tree->pool, a, sizeof(IOSAIJ));
 246.331 +         }
 246.332 +         dmp_free_atom(tree->pool, r, sizeof(IOSROW));
 246.333 +      }
 246.334 +#endif
 246.335 +done: return;
 246.336 +}
 246.337 +
 246.338 +/***********************************************************************
 246.339 +*  NAME
 246.340 +*
 246.341 +*  ios_freeze_node - freeze current subproblem
 246.342 +*
 246.343 +*  SYNOPSIS
 246.344 +*
 246.345 +*  #include "glpios.h"
 246.346 +*  void ios_freeze_node(glp_tree *tree);
 246.347 +*
 246.348 +*  DESCRIPTION
 246.349 +*
 246.350 +*  The routine ios_freeze_node freezes the current subproblem. */
 246.351 +
 246.352 +void ios_freeze_node(glp_tree *tree)
 246.353 +{     glp_prob *mip = tree->mip;
 246.354 +      int m = mip->m;
 246.355 +      int n = mip->n;
 246.356 +      IOSNPD *node;
 246.357 +      /* obtain pointer to the current subproblem */
 246.358 +      node = tree->curr;
 246.359 +      xassert(node != NULL);
 246.360 +      if (node->up == NULL)
 246.361 +      {  /* freeze the root subproblem */
 246.362 +         int k;
 246.363 +         xassert(node->p == 1);
 246.364 +         xassert(tree->root_m == 0);
 246.365 +         xassert(tree->root_type == NULL);
 246.366 +         xassert(tree->root_lb == NULL);
 246.367 +         xassert(tree->root_ub == NULL);
 246.368 +         xassert(tree->root_stat == NULL);
 246.369 +         tree->root_m = m;
 246.370 +         tree->root_type = xcalloc(1+m+n, sizeof(char));
 246.371 +         tree->root_lb = xcalloc(1+m+n, sizeof(double));
 246.372 +         tree->root_ub = xcalloc(1+m+n, sizeof(double));
 246.373 +         tree->root_stat = xcalloc(1+m+n, sizeof(char));
 246.374 +         for (k = 1; k <= m+n; k++)
 246.375 +         {  if (k <= m)
 246.376 +            {  GLPROW *row = mip->row[k];
 246.377 +               tree->root_type[k] = (char)row->type;
 246.378 +               tree->root_lb[k] = row->lb;
 246.379 +               tree->root_ub[k] = row->ub;
 246.380 +               tree->root_stat[k] = (char)row->stat;
 246.381 +            }
 246.382 +            else
 246.383 +            {  GLPCOL *col = mip->col[k-m];
 246.384 +               tree->root_type[k] = (char)col->type;
 246.385 +               tree->root_lb[k] = col->lb;
 246.386 +               tree->root_ub[k] = col->ub;
 246.387 +               tree->root_stat[k] = (char)col->stat;
 246.388 +            }
 246.389 +         }
 246.390 +      }
 246.391 +      else
 246.392 +      {  /* freeze non-root subproblem */
 246.393 +         int root_m = tree->root_m;
 246.394 +         int pred_m = tree->pred_m;
 246.395 +         int i, j, k;
 246.396 +         xassert(pred_m <= m);
 246.397 +         /* build change lists for rows and columns which exist in the
 246.398 +            parent subproblem */
 246.399 +         xassert(node->b_ptr == NULL);
 246.400 +         xassert(node->s_ptr == NULL);
 246.401 +         for (k = 1; k <= pred_m + n; k++)
 246.402 +         {  int pred_type, pred_stat, type, stat;
 246.403 +            double pred_lb, pred_ub, lb, ub;
 246.404 +            /* determine attributes in the parent subproblem */
 246.405 +            pred_type = tree->pred_type[k];
 246.406 +            pred_lb = tree->pred_lb[k];
 246.407 +            pred_ub = tree->pred_ub[k];
 246.408 +            pred_stat = tree->pred_stat[k];
 246.409 +            /* determine attributes in the current subproblem */
 246.410 +            if (k <= pred_m)
 246.411 +            {  GLPROW *row = mip->row[k];
 246.412 +               type = row->type;
 246.413 +               lb = row->lb;
 246.414 +               ub = row->ub;
 246.415 +               stat = row->stat;
 246.416 +            }
 246.417 +            else
 246.418 +            {  GLPCOL *col = mip->col[k - pred_m];
 246.419 +               type = col->type;
 246.420 +               lb = col->lb;
 246.421 +               ub = col->ub;
 246.422 +               stat = col->stat;
 246.423 +            }
 246.424 +            /* save type and bounds of a row/column, if changed */
 246.425 +            if (!(pred_type == type && pred_lb == lb && pred_ub == ub))
 246.426 +            {  IOSBND *b;
 246.427 +               b = dmp_get_atom(tree->pool, sizeof(IOSBND));
 246.428 +               b->k = k;
 246.429 +               b->type = (unsigned char)type;
 246.430 +               b->lb = lb;
 246.431 +               b->ub = ub;
 246.432 +               b->next = node->b_ptr;
 246.433 +               node->b_ptr = b;
 246.434 +            }
 246.435 +            /* save status of a row/column, if changed */
 246.436 +            if (pred_stat != stat)
 246.437 +            {  IOSTAT *s;
 246.438 +               s = dmp_get_atom(tree->pool, sizeof(IOSTAT));
 246.439 +               s->k = k;
 246.440 +               s->stat = (unsigned char)stat;
 246.441 +               s->next = node->s_ptr;
 246.442 +               node->s_ptr = s;
 246.443 +            }
 246.444 +         }
 246.445 +         /* save new rows added to the current subproblem */
 246.446 +         xassert(node->r_ptr == NULL);
 246.447 +         if (pred_m < m)
 246.448 +         {  int i, len, *ind;
 246.449 +            double *val;
 246.450 +            ind = xcalloc(1+n, sizeof(int));
 246.451 +            val = xcalloc(1+n, sizeof(double));
 246.452 +            for (i = m; i > pred_m; i--)
 246.453 +            {  GLPROW *row = mip->row[i];
 246.454 +               IOSROW *r;
 246.455 +               const char *name;
 246.456 +               r = dmp_get_atom(tree->pool, sizeof(IOSROW));
 246.457 +               name = glp_get_row_name(mip, i);
 246.458 +               if (name == NULL)
 246.459 +                  r->name = NULL;
 246.460 +               else
 246.461 +               {  r->name = dmp_get_atom(tree->pool, strlen(name)+1);
 246.462 +                  strcpy(r->name, name);
 246.463 +               }
 246.464 +#if 1 /* 20/IX-2008 */
 246.465 +               r->origin = row->origin;
 246.466 +               r->klass = row->klass;
 246.467 +#endif
 246.468 +               r->type = (unsigned char)row->type;
 246.469 +               r->lb = row->lb;
 246.470 +               r->ub = row->ub;
 246.471 +               r->ptr = NULL;
 246.472 +               len = glp_get_mat_row(mip, i, ind, val);
 246.473 +               for (k = 1; k <= len; k++)
 246.474 +               {  IOSAIJ *a;
 246.475 +                  a = dmp_get_atom(tree->pool, sizeof(IOSAIJ));
 246.476 +                  a->j = ind[k];
 246.477 +                  a->val = val[k];
 246.478 +                  a->next = r->ptr;
 246.479 +                  r->ptr = a;
 246.480 +               }
 246.481 +               r->rii = row->rii;
 246.482 +               r->stat = (unsigned char)row->stat;
 246.483 +               r->next = node->r_ptr;
 246.484 +               node->r_ptr = r;
 246.485 +            }
 246.486 +            xfree(ind);
 246.487 +            xfree(val);
 246.488 +         }
 246.489 +         /* remove all rows missing in the root subproblem */
 246.490 +         if (m != root_m)
 246.491 +         {  int nrs, *num;
 246.492 +            nrs = m - root_m;
 246.493 +            xassert(nrs > 0);
 246.494 +            num = xcalloc(1+nrs, sizeof(int));
 246.495 +            for (i = 1; i <= nrs; i++) num[i] = root_m + i;
 246.496 +            glp_del_rows(mip, nrs, num);
 246.497 +            xfree(num);
 246.498 +         }
 246.499 +         m = mip->m;
 246.500 +         /* and restore attributes of all rows and columns for the root
 246.501 +            subproblem */
 246.502 +         xassert(m == root_m);
 246.503 +         for (i = 1; i <= m; i++)
 246.504 +         {  glp_set_row_bnds(mip, i, tree->root_type[i],
 246.505 +               tree->root_lb[i], tree->root_ub[i]);
 246.506 +            glp_set_row_stat(mip, i, tree->root_stat[i]);
 246.507 +         }
 246.508 +         for (j = 1; j <= n; j++)
 246.509 +         {  glp_set_col_bnds(mip, j, tree->root_type[m+j],
 246.510 +               tree->root_lb[m+j], tree->root_ub[m+j]);
 246.511 +            glp_set_col_stat(mip, j, tree->root_stat[m+j]);
 246.512 +         }
 246.513 +#if 1
 246.514 +         /* remove all edges and cliques missing in the conflict graph
 246.515 +            for the root subproblem */
 246.516 +         /* (not implemented yet) */
 246.517 +#endif
 246.518 +      }
 246.519 +      /* the current subproblem has been frozen */
 246.520 +      tree->curr = NULL;
 246.521 +      return;
 246.522 +}
 246.523 +
 246.524 +/***********************************************************************
 246.525 +*  NAME
 246.526 +*
 246.527 +*  ios_clone_node - clone specified subproblem
 246.528 +*
 246.529 +*  SYNOPSIS
 246.530 +*
 246.531 +*  #include "glpios.h"
 246.532 +*  void ios_clone_node(glp_tree *tree, int p, int nnn, int ref[]);
 246.533 +*
 246.534 +*  DESCRIPTION
 246.535 +*
 246.536 +*  The routine ios_clone_node clones the specified subproblem, whose
 246.537 +*  reference number is p, creating its nnn exact copies. Note that the
 246.538 +*  specified subproblem must be active and must be in the frozen state
 246.539 +*  (i.e. it must not be the current subproblem).
 246.540 +*
 246.541 +*  Each clone, an exact copy of the specified subproblem, becomes a new
 246.542 +*  active subproblem added to the end of the active list. After cloning
 246.543 +*  the specified subproblem becomes inactive.
 246.544 +*
 246.545 +*  The reference numbers of clone subproblems are stored to locations
 246.546 +*  ref[1], ..., ref[nnn]. */
 246.547 +
 246.548 +static int get_slot(glp_tree *tree)
 246.549 +{     int p;
 246.550 +      /* if no free slots are available, increase the room */
 246.551 +      if (tree->avail == 0)
 246.552 +      {  int nslots = tree->nslots;
 246.553 +         IOSLOT *save = tree->slot;
 246.554 +         if (nslots == 0)
 246.555 +            tree->nslots = 20;
 246.556 +         else
 246.557 +         {  tree->nslots = nslots + nslots;
 246.558 +            xassert(tree->nslots > nslots);
 246.559 +         }
 246.560 +         tree->slot = xcalloc(1+tree->nslots, sizeof(IOSLOT));
 246.561 +         if (save != NULL)
 246.562 +         {  memcpy(&tree->slot[1], &save[1], nslots * sizeof(IOSLOT));
 246.563 +            xfree(save);
 246.564 +         }
 246.565 +         /* push more free slots into the stack */
 246.566 +         for (p = tree->nslots; p > nslots; p--)
 246.567 +         {  tree->slot[p].node = NULL;
 246.568 +            tree->slot[p].next = tree->avail;
 246.569 +            tree->avail = p;
 246.570 +         }
 246.571 +      }
 246.572 +      /* pull a free slot from the stack */
 246.573 +      p = tree->avail;
 246.574 +      tree->avail = tree->slot[p].next;
 246.575 +      xassert(tree->slot[p].node == NULL);
 246.576 +      tree->slot[p].next = 0;
 246.577 +      return p;
 246.578 +}
 246.579 +
 246.580 +static IOSNPD *new_node(glp_tree *tree, IOSNPD *parent)
 246.581 +{     IOSNPD *node;
 246.582 +      int p;
 246.583 +      /* pull a free slot for the new node */
 246.584 +      p = get_slot(tree);
 246.585 +      /* create descriptor of the new subproblem */
 246.586 +      node = dmp_get_atom(tree->pool, sizeof(IOSNPD));
 246.587 +      tree->slot[p].node = node;
 246.588 +      node->p = p;
 246.589 +      node->up = parent;
 246.590 +      node->level = (parent == NULL ? 0 : parent->level + 1);
 246.591 +      node->count = 0;
 246.592 +      node->b_ptr = NULL;
 246.593 +      node->s_ptr = NULL;
 246.594 +      node->r_ptr = NULL;
 246.595 +      node->solved = 0;
 246.596 +#if 0
 246.597 +      node->own_nn = node->own_nc = 0;
 246.598 +      node->e_ptr = NULL;
 246.599 +#endif
 246.600 +#if 1 /* 04/X-2008 */
 246.601 +      node->lp_obj = (parent == NULL ? (tree->mip->dir == GLP_MIN ?
 246.602 +         -DBL_MAX : +DBL_MAX) : parent->lp_obj);
 246.603 +#endif
 246.604 +      node->bound = (parent == NULL ? (tree->mip->dir == GLP_MIN ?
 246.605 +         -DBL_MAX : +DBL_MAX) : parent->bound);
 246.606 +      node->br_var = 0;
 246.607 +      node->br_val = 0.0;
 246.608 +      node->ii_cnt = 0;
 246.609 +      node->ii_sum = 0.0;
 246.610 +#if 1 /* 30/XI-2009 */
 246.611 +      node->changed = 0;
 246.612 +#endif
 246.613 +      if (tree->parm->cb_size == 0)
 246.614 +         node->data = NULL;
 246.615 +      else
 246.616 +      {  node->data = dmp_get_atom(tree->pool, tree->parm->cb_size);
 246.617 +         memset(node->data, 0, tree->parm->cb_size);
 246.618 +      }
 246.619 +      node->temp = NULL;
 246.620 +      node->prev = tree->tail;
 246.621 +      node->next = NULL;
 246.622 +      /* add the new subproblem to the end of the active list */
 246.623 +      if (tree->head == NULL)
 246.624 +         tree->head = node;
 246.625 +      else
 246.626 +         tree->tail->next = node;
 246.627 +      tree->tail = node;
 246.628 +      tree->a_cnt++;
 246.629 +      tree->n_cnt++;
 246.630 +      tree->t_cnt++;
 246.631 +      /* increase the number of child subproblems */
 246.632 +      if (parent == NULL)
 246.633 +         xassert(p == 1);
 246.634 +      else
 246.635 +         parent->count++;
 246.636 +      return node;
 246.637 +}
 246.638 +
 246.639 +void ios_clone_node(glp_tree *tree, int p, int nnn, int ref[])
 246.640 +{     IOSNPD *node;
 246.641 +      int k;
 246.642 +      /* obtain pointer to the subproblem to be cloned */
 246.643 +      xassert(1 <= p && p <= tree->nslots);
 246.644 +      node = tree->slot[p].node;
 246.645 +      xassert(node != NULL);
 246.646 +      /* the specified subproblem must be active */
 246.647 +      xassert(node->count == 0);
 246.648 +      /* and must be in the frozen state */
 246.649 +      xassert(tree->curr != node);
 246.650 +      /* remove the specified subproblem from the active list, because
 246.651 +         it becomes inactive */
 246.652 +      if (node->prev == NULL)
 246.653 +         tree->head = node->next;
 246.654 +      else
 246.655 +         node->prev->next = node->next;
 246.656 +      if (node->next == NULL)
 246.657 +         tree->tail = node->prev;
 246.658 +      else
 246.659 +         node->next->prev = node->prev;
 246.660 +      node->prev = node->next = NULL;
 246.661 +      tree->a_cnt--;
 246.662 +      /* create clone subproblems */
 246.663 +      xassert(nnn > 0);
 246.664 +      for (k = 1; k <= nnn; k++)
 246.665 +         ref[k] = new_node(tree, node)->p;
 246.666 +      return;
 246.667 +}
 246.668 +
 246.669 +/***********************************************************************
 246.670 +*  NAME
 246.671 +*
 246.672 +*  ios_delete_node - delete specified subproblem
 246.673 +*
 246.674 +*  SYNOPSIS
 246.675 +*
 246.676 +*  #include "glpios.h"
 246.677 +*  void ios_delete_node(glp_tree *tree, int p);
 246.678 +*
 246.679 +*  DESCRIPTION
 246.680 +*
 246.681 +*  The routine ios_delete_node deletes the specified subproblem, whose
 246.682 +*  reference number is p. The subproblem must be active and must be in
 246.683 +*  the frozen state (i.e. it must not be the current subproblem).
 246.684 +*
 246.685 +*  Note that deletion is performed recursively, i.e. if a subproblem to
 246.686 +*  be deleted is the only child of its parent, the parent subproblem is
 246.687 +*  also deleted, etc. */
 246.688 +
 246.689 +void ios_delete_node(glp_tree *tree, int p)
 246.690 +{     IOSNPD *node, *temp;
 246.691 +      /* obtain pointer to the subproblem to be deleted */
 246.692 +      xassert(1 <= p && p <= tree->nslots);
 246.693 +      node = tree->slot[p].node;
 246.694 +      xassert(node != NULL);
 246.695 +      /* the specified subproblem must be active */
 246.696 +      xassert(node->count == 0);
 246.697 +      /* and must be in the frozen state */
 246.698 +      xassert(tree->curr != node);
 246.699 +      /* remove the specified subproblem from the active list, because
 246.700 +         it is gone from the tree */
 246.701 +      if (node->prev == NULL)
 246.702 +         tree->head = node->next;
 246.703 +      else
 246.704 +         node->prev->next = node->next;
 246.705 +      if (node->next == NULL)
 246.706 +         tree->tail = node->prev;
 246.707 +      else
 246.708 +         node->next->prev = node->prev;
 246.709 +      node->prev = node->next = NULL;
 246.710 +      tree->a_cnt--;
 246.711 +loop: /* recursive deletion starts here */
 246.712 +      /* delete the bound change list */
 246.713 +      {  IOSBND *b;
 246.714 +         while (node->b_ptr != NULL)
 246.715 +         {  b = node->b_ptr;
 246.716 +            node->b_ptr = b->next;
 246.717 +            dmp_free_atom(tree->pool, b, sizeof(IOSBND));
 246.718 +         }
 246.719 +      }
 246.720 +      /* delete the status change list */
 246.721 +      {  IOSTAT *s;
 246.722 +         while (node->s_ptr != NULL)
 246.723 +         {  s = node->s_ptr;
 246.724 +            node->s_ptr = s->next;
 246.725 +            dmp_free_atom(tree->pool, s, sizeof(IOSTAT));
 246.726 +         }
 246.727 +      }
 246.728 +      /* delete the row addition list */
 246.729 +      while (node->r_ptr != NULL)
 246.730 +      {  IOSROW *r;
 246.731 +         r = node->r_ptr;
 246.732 +         if (r->name != NULL)
 246.733 +            dmp_free_atom(tree->pool, r->name, strlen(r->name)+1);
 246.734 +         while (r->ptr != NULL)
 246.735 +         {  IOSAIJ *a;
 246.736 +            a = r->ptr;
 246.737 +            r->ptr = a->next;
 246.738 +            dmp_free_atom(tree->pool, a, sizeof(IOSAIJ));
 246.739 +         }
 246.740 +         node->r_ptr = r->next;
 246.741 +         dmp_free_atom(tree->pool, r, sizeof(IOSROW));
 246.742 +      }
 246.743 +#if 0
 246.744 +      /* delete the edge addition list */
 246.745 +      /* delete the clique addition list */
 246.746 +      /* (not implemented yet) */
 246.747 +      xassert(node->own_nn == 0);
 246.748 +      xassert(node->own_nc == 0);
 246.749 +      xassert(node->e_ptr == NULL);
 246.750 +#endif
 246.751 +      /* free application-specific data */
 246.752 +      if (tree->parm->cb_size == 0)
 246.753 +         xassert(node->data == NULL);
 246.754 +      else
 246.755 +         dmp_free_atom(tree->pool, node->data, tree->parm->cb_size);
 246.756 +      /* free the corresponding node slot */
 246.757 +      p = node->p;
 246.758 +      xassert(tree->slot[p].node == node);
 246.759 +      tree->slot[p].node = NULL;
 246.760 +      tree->slot[p].next = tree->avail;
 246.761 +      tree->avail = p;
 246.762 +      /* save pointer to the parent subproblem */
 246.763 +      temp = node->up;
 246.764 +      /* delete the subproblem descriptor */
 246.765 +      dmp_free_atom(tree->pool, node, sizeof(IOSNPD));
 246.766 +      tree->n_cnt--;
 246.767 +      /* take pointer to the parent subproblem */
 246.768 +      node = temp;
 246.769 +      if (node != NULL)
 246.770 +      {  /* the parent subproblem exists; decrease the number of its
 246.771 +            child subproblems */
 246.772 +         xassert(node->count > 0);
 246.773 +         node->count--;
 246.774 +         /* if now the parent subproblem has no childs, it also must be
 246.775 +            deleted */
 246.776 +         if (node->count == 0) goto loop;
 246.777 +      }
 246.778 +      return;
 246.779 +}
 246.780 +
 246.781 +/***********************************************************************
 246.782 +*  NAME
 246.783 +*
 246.784 +*  ios_delete_tree - delete branch-and-bound tree
 246.785 +*
 246.786 +*  SYNOPSIS
 246.787 +*
 246.788 +*  #include "glpios.h"
 246.789 +*  void ios_delete_tree(glp_tree *tree);
 246.790 +*
 246.791 +*  DESCRIPTION
 246.792 +*
 246.793 +*  The routine ios_delete_tree deletes the branch-and-bound tree, which
 246.794 +*  the parameter tree points to, and frees all the memory allocated to
 246.795 +*  this program object.
 246.796 +*
 246.797 +*  On exit components of the problem object are restored to correspond
 246.798 +*  to the original MIP passed to the routine ios_create_tree. */
 246.799 +
 246.800 +void ios_delete_tree(glp_tree *tree)
 246.801 +{     glp_prob *mip = tree->mip;
 246.802 +      int i, j;
 246.803 +      int m = mip->m;
 246.804 +      int n = mip->n;
 246.805 +      xassert(mip->tree == tree);
 246.806 +      /* remove all additional rows */
 246.807 +      if (m != tree->orig_m)
 246.808 +      {  int nrs, *num;
 246.809 +         nrs = m - tree->orig_m;
 246.810 +         xassert(nrs > 0);
 246.811 +         num = xcalloc(1+nrs, sizeof(int));
 246.812 +         for (i = 1; i <= nrs; i++) num[i] = tree->orig_m + i;
 246.813 +         glp_del_rows(mip, nrs, num);
 246.814 +         xfree(num);
 246.815 +      }
 246.816 +      m = tree->orig_m;
 246.817 +      /* restore original attributes of rows and columns */
 246.818 +      xassert(m == tree->orig_m);
 246.819 +      xassert(n == tree->n);
 246.820 +      for (i = 1; i <= m; i++)
 246.821 +      {  glp_set_row_bnds(mip, i, tree->orig_type[i],
 246.822 +            tree->orig_lb[i], tree->orig_ub[i]);
 246.823 +         glp_set_row_stat(mip, i, tree->orig_stat[i]);
 246.824 +         mip->row[i]->prim = tree->orig_prim[i];
 246.825 +         mip->row[i]->dual = tree->orig_dual[i];
 246.826 +      }
 246.827 +      for (j = 1; j <= n; j++)
 246.828 +      {  glp_set_col_bnds(mip, j, tree->orig_type[m+j],
 246.829 +            tree->orig_lb[m+j], tree->orig_ub[m+j]);
 246.830 +         glp_set_col_stat(mip, j, tree->orig_stat[m+j]);
 246.831 +         mip->col[j]->prim = tree->orig_prim[m+j];
 246.832 +         mip->col[j]->dual = tree->orig_dual[m+j];
 246.833 +      }
 246.834 +      mip->pbs_stat = mip->dbs_stat = GLP_FEAS;
 246.835 +      mip->obj_val = tree->orig_obj;
 246.836 +      /* delete the branch-and-bound tree */
 246.837 +      xassert(tree->local != NULL);
 246.838 +      ios_delete_pool(tree, tree->local);
 246.839 +      dmp_delete_pool(tree->pool);
 246.840 +      xfree(tree->orig_type);
 246.841 +      xfree(tree->orig_lb);
 246.842 +      xfree(tree->orig_ub);
 246.843 +      xfree(tree->orig_stat);
 246.844 +      xfree(tree->orig_prim);
 246.845 +      xfree(tree->orig_dual);
 246.846 +      xfree(tree->slot);
 246.847 +      if (tree->root_type != NULL) xfree(tree->root_type);
 246.848 +      if (tree->root_lb != NULL) xfree(tree->root_lb);
 246.849 +      if (tree->root_ub != NULL) xfree(tree->root_ub);
 246.850 +      if (tree->root_stat != NULL) xfree(tree->root_stat);
 246.851 +      xfree(tree->non_int);
 246.852 +#if 0
 246.853 +      xfree(tree->n_ref);
 246.854 +      xfree(tree->c_ref);
 246.855 +      xfree(tree->j_ref);
 246.856 +#endif
 246.857 +      if (tree->pcost != NULL) ios_pcost_free(tree);
 246.858 +      xfree(tree->iwrk);
 246.859 +      xfree(tree->dwrk);
 246.860 +#if 0
 246.861 +      scg_delete_graph(tree->g);
 246.862 +#endif
 246.863 +      if (tree->pred_type != NULL) xfree(tree->pred_type);
 246.864 +      if (tree->pred_lb != NULL) xfree(tree->pred_lb);
 246.865 +      if (tree->pred_ub != NULL) xfree(tree->pred_ub);
 246.866 +      if (tree->pred_stat != NULL) xfree(tree->pred_stat);
 246.867 +#if 0
 246.868 +      xassert(tree->cut_gen == NULL);
 246.869 +#endif
 246.870 +      xassert(tree->mir_gen == NULL);
 246.871 +      xassert(tree->clq_gen == NULL);
 246.872 +      xfree(tree);
 246.873 +      mip->tree = NULL;
 246.874 +      return;
 246.875 +}
 246.876 +
 246.877 +/***********************************************************************
 246.878 +*  NAME
 246.879 +*
 246.880 +*  ios_eval_degrad - estimate obj. degrad. for down- and up-branches
 246.881 +*
 246.882 +*  SYNOPSIS
 246.883 +*
 246.884 +*  #include "glpios.h"
 246.885 +*  void ios_eval_degrad(glp_tree *tree, int j, double *dn, double *up);
 246.886 +*
 246.887 +*  DESCRIPTION
 246.888 +*
 246.889 +*  Given optimal basis to LP relaxation of the current subproblem the
 246.890 +*  routine ios_eval_degrad performs the dual ratio test to compute the
 246.891 +*  objective values in the adjacent basis for down- and up-branches,
 246.892 +*  which are stored in locations *dn and *up, assuming that x[j] is a
 246.893 +*  variable chosen to branch upon. */
 246.894 +
 246.895 +void ios_eval_degrad(glp_tree *tree, int j, double *dn, double *up)
 246.896 +{     glp_prob *mip = tree->mip;
 246.897 +      int m = mip->m, n = mip->n;
 246.898 +      int len, kase, k, t, stat;
 246.899 +      double alfa, beta, gamma, delta, dz;
 246.900 +      int *ind = tree->iwrk;
 246.901 +      double *val = tree->dwrk;
 246.902 +      /* current basis must be optimal */
 246.903 +      xassert(glp_get_status(mip) == GLP_OPT);
 246.904 +      /* basis factorization must exist */
 246.905 +      xassert(glp_bf_exists(mip));
 246.906 +      /* obtain (fractional) value of x[j] in optimal basic solution
 246.907 +         to LP relaxation of the current subproblem */
 246.908 +      xassert(1 <= j && j <= n);
 246.909 +      beta = mip->col[j]->prim;
 246.910 +      /* since the value of x[j] is fractional, it is basic; compute
 246.911 +         corresponding row of the simplex table */
 246.912 +      len = lpx_eval_tab_row(mip, m+j, ind, val);
 246.913 +      /* kase < 0 means down-branch; kase > 0 means up-branch */
 246.914 +      for (kase = -1; kase <= +1; kase += 2)
 246.915 +      {  /* for down-branch we introduce new upper bound floor(beta)
 246.916 +            for x[j]; similarly, for up-branch we introduce new lower
 246.917 +            bound ceil(beta) for x[j]; in the current basis this new
 246.918 +            upper/lower bound is violated, so in the adjacent basis
 246.919 +            x[j] will leave the basis and go to its new upper/lower
 246.920 +            bound; we need to know which non-basic variable x[k] should
 246.921 +            enter the basis to keep dual feasibility */
 246.922 +#if 0 /* 23/XI-2009 */
 246.923 +         k = lpx_dual_ratio_test(mip, len, ind, val, kase, 1e-7);
 246.924 +#else
 246.925 +         k = lpx_dual_ratio_test(mip, len, ind, val, kase, 1e-9);
 246.926 +#endif
 246.927 +         /* if no variable has been chosen, current basis being primal
 246.928 +            infeasible due to the new upper/lower bound of x[j] is dual
 246.929 +            unbounded, therefore, LP relaxation to corresponding branch
 246.930 +            has no primal feasible solution */
 246.931 +         if (k == 0)
 246.932 +         {  if (mip->dir == GLP_MIN)
 246.933 +            {  if (kase < 0)
 246.934 +                  *dn = +DBL_MAX;
 246.935 +               else
 246.936 +                  *up = +DBL_MAX;
 246.937 +            }
 246.938 +            else if (mip->dir == GLP_MAX)
 246.939 +            {  if (kase < 0)
 246.940 +                  *dn = -DBL_MAX;
 246.941 +               else
 246.942 +                  *up = -DBL_MAX;
 246.943 +            }
 246.944 +            else
 246.945 +               xassert(mip != mip);
 246.946 +            continue;
 246.947 +         }
 246.948 +         xassert(1 <= k && k <= m+n);
 246.949 +         /* row of the simplex table corresponding to specified basic
 246.950 +            variable x[j] is the following:
 246.951 +               x[j] = ... + alfa * x[k] + ... ;
 246.952 +            we need to know influence coefficient, alfa, at non-basic
 246.953 +            variable x[k] chosen with the dual ratio test */
 246.954 +         for (t = 1; t <= len; t++)
 246.955 +            if (ind[t] == k) break;
 246.956 +         xassert(1 <= t && t <= len);
 246.957 +         alfa = val[t];
 246.958 +         /* determine status and reduced cost of variable x[k] */
 246.959 +         if (k <= m)
 246.960 +         {  stat = mip->row[k]->stat;
 246.961 +            gamma = mip->row[k]->dual;
 246.962 +         }
 246.963 +         else
 246.964 +         {  stat = mip->col[k-m]->stat;
 246.965 +            gamma = mip->col[k-m]->dual;
 246.966 +         }
 246.967 +         /* x[k] cannot be basic or fixed non-basic */
 246.968 +         xassert(stat == GLP_NL || stat == GLP_NU || stat == GLP_NF);
 246.969 +         /* if the current basis is dual degenerative, some reduced
 246.970 +            costs, which are close to zero, may have wrong sign due to
 246.971 +            round-off errors, so correct the sign of gamma */
 246.972 +         if (mip->dir == GLP_MIN)
 246.973 +         {  if (stat == GLP_NL && gamma < 0.0 ||
 246.974 +                stat == GLP_NU && gamma > 0.0 ||
 246.975 +                stat == GLP_NF) gamma = 0.0;
 246.976 +         }
 246.977 +         else if (mip->dir == GLP_MAX)
 246.978 +         {  if (stat == GLP_NL && gamma > 0.0 ||
 246.979 +                stat == GLP_NU && gamma < 0.0 ||
 246.980 +                stat == GLP_NF) gamma = 0.0;
 246.981 +         }
 246.982 +         else
 246.983 +            xassert(mip != mip);
 246.984 +         /* determine the change of x[j] in the adjacent basis:
 246.985 +            delta x[j] = new x[j] - old x[j] */
 246.986 +         delta = (kase < 0 ? floor(beta) : ceil(beta)) - beta;
 246.987 +         /* compute the change of x[k] in the adjacent basis:
 246.988 +            delta x[k] = new x[k] - old x[k] = delta x[j] / alfa */
 246.989 +         delta /= alfa;
 246.990 +         /* compute the change of the objective in the adjacent basis:
 246.991 +            delta z = new z - old z = gamma * delta x[k] */
 246.992 +         dz = gamma * delta;
 246.993 +         if (mip->dir == GLP_MIN)
 246.994 +            xassert(dz >= 0.0);
 246.995 +         else if (mip->dir == GLP_MAX)
 246.996 +            xassert(dz <= 0.0);
 246.997 +         else
 246.998 +            xassert(mip != mip);
 246.999 +         /* compute the new objective value in the adjacent basis:
246.1000 +            new z = old z + delta z */
246.1001 +         if (kase < 0)
246.1002 +            *dn = mip->obj_val + dz;
246.1003 +         else
246.1004 +            *up = mip->obj_val + dz;
246.1005 +      }
246.1006 +      /*xprintf("obj = %g; dn = %g; up = %g\n",
246.1007 +         mip->obj_val, *dn, *up);*/
246.1008 +      return;
246.1009 +}
246.1010 +
246.1011 +/***********************************************************************
246.1012 +*  NAME
246.1013 +*
246.1014 +*  ios_round_bound - improve local bound by rounding
246.1015 +*
246.1016 +*  SYNOPSIS
246.1017 +*
246.1018 +*  #include "glpios.h"
246.1019 +*  double ios_round_bound(glp_tree *tree, double bound);
246.1020 +*
246.1021 +*  RETURNS
246.1022 +*
246.1023 +*  For the given local bound for any integer feasible solution to the
246.1024 +*  current subproblem the routine ios_round_bound returns an improved
246.1025 +*  local bound for the same integer feasible solution.
246.1026 +*
246.1027 +*  BACKGROUND
246.1028 +*
246.1029 +*  Let the current subproblem has the following objective function:
246.1030 +*
246.1031 +*     z =   sum  c[j] * x[j] + s >= b,                               (1)
246.1032 +*         j in J
246.1033 +*
246.1034 +*  where J = {j: c[j] is non-zero and integer, x[j] is integer}, s is
246.1035 +*  the sum of terms corresponding to fixed variables, b is an initial
246.1036 +*  local bound (minimization).
246.1037 +*
246.1038 +*  From (1) it follows that:
246.1039 +*
246.1040 +*     d *  sum  (c[j] / d) * x[j] + s >= b,                          (2)
246.1041 +*        j in J
246.1042 +*
246.1043 +*  or, equivalently,
246.1044 +*
246.1045 +*     sum  (c[j] / d) * x[j] >= (b - s) / d = h,                     (3)
246.1046 +*   j in J
246.1047 +*
246.1048 +*  where d = gcd(c[j]). Since the left-hand side of (3) is integer,
246.1049 +*  h = (b - s) / d can be rounded up to the nearest integer:
246.1050 +*
246.1051 +*     h' = ceil(h) = (b' - s) / d,                                   (4)
246.1052 +*
246.1053 +*  that gives an rounded, improved local bound:
246.1054 +*
246.1055 +*     b' = d * h' + s.                                               (5)
246.1056 +*
246.1057 +*  In case of maximization '>=' in (1) should be replaced by '<=' that
246.1058 +*  leads to the following formula:
246.1059 +*
246.1060 +*     h' = floor(h) = (b' - s) / d,                                  (6)
246.1061 +*
246.1062 +*  which should used in the same way as (4).
246.1063 +*
246.1064 +*  NOTE: If b is a valid local bound for a child of the current
246.1065 +*        subproblem, b' is also valid for that child subproblem. */
246.1066 +
246.1067 +double ios_round_bound(glp_tree *tree, double bound)
246.1068 +{     glp_prob *mip = tree->mip;
246.1069 +      int n = mip->n;
246.1070 +      int d, j, nn, *c = tree->iwrk;
246.1071 +      double s, h;
246.1072 +      /* determine c[j] and compute s */
246.1073 +      nn = 0, s = mip->c0, d = 0;
246.1074 +      for (j = 1; j <= n; j++)
246.1075 +      {  GLPCOL *col = mip->col[j];
246.1076 +         if (col->coef == 0.0) continue;
246.1077 +         if (col->type == GLP_FX)
246.1078 +         {  /* fixed variable */
246.1079 +            s += col->coef * col->prim;
246.1080 +         }
246.1081 +         else
246.1082 +         {  /* non-fixed variable */
246.1083 +            if (col->kind != GLP_IV) goto skip;
246.1084 +            if (col->coef != floor(col->coef)) goto skip;
246.1085 +            if (fabs(col->coef) <= (double)INT_MAX)
246.1086 +               c[++nn] = (int)fabs(col->coef);
246.1087 +            else
246.1088 +               d = 1;
246.1089 +         }
246.1090 +      }
246.1091 +      /* compute d = gcd(c[1],...c[nn]) */
246.1092 +      if (d == 0)
246.1093 +      {  if (nn == 0) goto skip;
246.1094 +         d = gcdn(nn, c);
246.1095 +      }
246.1096 +      xassert(d > 0);
246.1097 +      /* compute new local bound */
246.1098 +      if (mip->dir == GLP_MIN)
246.1099 +      {  if (bound != +DBL_MAX)
246.1100 +         {  h = (bound - s) / (double)d;
246.1101 +            if (h >= floor(h) + 0.001)
246.1102 +            {  /* round up */
246.1103 +               h = ceil(h);
246.1104 +               /*xprintf("d = %d; old = %g; ", d, bound);*/
246.1105 +               bound = (double)d * h + s;
246.1106 +               /*xprintf("new = %g\n", bound);*/
246.1107 +            }
246.1108 +         }
246.1109 +      }
246.1110 +      else if (mip->dir == GLP_MAX)
246.1111 +      {  if (bound != -DBL_MAX)
246.1112 +         {  h = (bound - s) / (double)d;
246.1113 +            if (h <= ceil(h) - 0.001)
246.1114 +            {  /* round down */
246.1115 +               h = floor(h);
246.1116 +               bound = (double)d * h + s;
246.1117 +            }
246.1118 +         }
246.1119 +      }
246.1120 +      else
246.1121 +         xassert(mip != mip);
246.1122 +skip: return bound;
246.1123 +}
246.1124 +
246.1125 +/***********************************************************************
246.1126 +*  NAME
246.1127 +*
246.1128 +*  ios_is_hopeful - check if subproblem is hopeful
246.1129 +*
246.1130 +*  SYNOPSIS
246.1131 +*
246.1132 +*  #include "glpios.h"
246.1133 +*  int ios_is_hopeful(glp_tree *tree, double bound);
246.1134 +*
246.1135 +*  DESCRIPTION
246.1136 +*
246.1137 +*  Given the local bound of a subproblem the routine ios_is_hopeful
246.1138 +*  checks if the subproblem can have an integer optimal solution which
246.1139 +*  is better than the best one currently known.
246.1140 +*
246.1141 +*  RETURNS
246.1142 +*
246.1143 +*  If the subproblem can have a better integer optimal solution, the
246.1144 +*  routine returns non-zero; otherwise, if the corresponding branch can
246.1145 +*  be pruned, the routine returns zero. */
246.1146 +
246.1147 +int ios_is_hopeful(glp_tree *tree, double bound)
246.1148 +{     glp_prob *mip = tree->mip;
246.1149 +      int ret = 1;
246.1150 +      double eps;
246.1151 +      if (mip->mip_stat == GLP_FEAS)
246.1152 +      {  eps = tree->parm->tol_obj * (1.0 + fabs(mip->mip_obj));
246.1153 +         switch (mip->dir)
246.1154 +         {  case GLP_MIN:
246.1155 +               if (bound >= mip->mip_obj - eps) ret = 0;
246.1156 +               break;
246.1157 +            case GLP_MAX:
246.1158 +               if (bound <= mip->mip_obj + eps) ret = 0;
246.1159 +               break;
246.1160 +            default:
246.1161 +               xassert(mip != mip);
246.1162 +         }
246.1163 +      }
246.1164 +      else
246.1165 +      {  switch (mip->dir)
246.1166 +         {  case GLP_MIN:
246.1167 +               if (bound == +DBL_MAX) ret = 0;
246.1168 +               break;
246.1169 +            case GLP_MAX:
246.1170 +               if (bound == -DBL_MAX) ret = 0;
246.1171 +               break;
246.1172 +            default:
246.1173 +               xassert(mip != mip);
246.1174 +         }
246.1175 +      }
246.1176 +      return ret;
246.1177 +}
246.1178 +
246.1179 +/***********************************************************************
246.1180 +*  NAME
246.1181 +*
246.1182 +*  ios_best_node - find active node with best local bound
246.1183 +*
246.1184 +*  SYNOPSIS
246.1185 +*
246.1186 +*  #include "glpios.h"
246.1187 +*  int ios_best_node(glp_tree *tree);
246.1188 +*
246.1189 +*  DESCRIPTION
246.1190 +*
246.1191 +*  The routine ios_best_node finds an active node whose local bound is
246.1192 +*  best among other active nodes.
246.1193 +*
246.1194 +*  It is understood that the integer optimal solution of the original
246.1195 +*  mip problem cannot be better than the best bound, so the best bound
246.1196 +*  is an lower (minimization) or upper (maximization) global bound for
246.1197 +*  the original problem.
246.1198 +*
246.1199 +*  RETURNS
246.1200 +*
246.1201 +*  The routine ios_best_node returns the subproblem reference number
246.1202 +*  for the best node. However, if the tree is empty, it returns zero. */
246.1203 +
246.1204 +int ios_best_node(glp_tree *tree)
246.1205 +{     IOSNPD *node, *best = NULL;
246.1206 +      switch (tree->mip->dir)
246.1207 +      {  case GLP_MIN:
246.1208 +            /* minimization */
246.1209 +            for (node = tree->head; node != NULL; node = node->next)
246.1210 +               if (best == NULL || best->bound > node->bound)
246.1211 +                  best = node;
246.1212 +            break;
246.1213 +         case GLP_MAX:
246.1214 +            /* maximization */
246.1215 +            for (node = tree->head; node != NULL; node = node->next)
246.1216 +               if (best == NULL || best->bound < node->bound)
246.1217 +                  best = node;
246.1218 +            break;
246.1219 +         default:
246.1220 +            xassert(tree != tree);
246.1221 +      }
246.1222 +      return best == NULL ? 0 : best->p;
246.1223 +}
246.1224 +
246.1225 +/***********************************************************************
246.1226 +*  NAME
246.1227 +*
246.1228 +*  ios_relative_gap - compute relative mip gap
246.1229 +*
246.1230 +*  SYNOPSIS
246.1231 +*
246.1232 +*  #include "glpios.h"
246.1233 +*  double ios_relative_gap(glp_tree *tree);
246.1234 +*
246.1235 +*  DESCRIPTION
246.1236 +*
246.1237 +*  The routine ios_relative_gap computes the relative mip gap using the
246.1238 +*  formula:
246.1239 +*
246.1240 +*     gap = |best_mip - best_bnd| / (|best_mip| + DBL_EPSILON),
246.1241 +*
246.1242 +*  where best_mip is the best integer feasible solution found so far,
246.1243 +*  best_bnd is the best (global) bound. If no integer feasible solution
246.1244 +*  has been found yet, rel_gap is set to DBL_MAX.
246.1245 +*
246.1246 +*  RETURNS
246.1247 +*
246.1248 +*  The routine ios_relative_gap returns the relative mip gap. */
246.1249 +
246.1250 +double ios_relative_gap(glp_tree *tree)
246.1251 +{     glp_prob *mip = tree->mip;
246.1252 +      int p;
246.1253 +      double best_mip, best_bnd, gap;
246.1254 +      if (mip->mip_stat == GLP_FEAS)
246.1255 +      {  best_mip = mip->mip_obj;
246.1256 +         p = ios_best_node(tree);
246.1257 +         if (p == 0)
246.1258 +         {  /* the tree is empty */
246.1259 +            gap = 0.0;
246.1260 +         }
246.1261 +         else
246.1262 +         {  best_bnd = tree->slot[p].node->bound;
246.1263 +            gap = fabs(best_mip - best_bnd) / (fabs(best_mip) +
246.1264 +               DBL_EPSILON);
246.1265 +         }
246.1266 +      }
246.1267 +      else
246.1268 +      {  /* no integer feasible solution has been found yet */
246.1269 +         gap = DBL_MAX;
246.1270 +      }
246.1271 +      return gap;
246.1272 +}
246.1273 +
246.1274 +/***********************************************************************
246.1275 +*  NAME
246.1276 +*
246.1277 +*  ios_solve_node - solve LP relaxation of current subproblem
246.1278 +*
246.1279 +*  SYNOPSIS
246.1280 +*
246.1281 +*  #include "glpios.h"
246.1282 +*  int ios_solve_node(glp_tree *tree);
246.1283 +*
246.1284 +*  DESCRIPTION
246.1285 +*
246.1286 +*  The routine ios_solve_node re-optimizes LP relaxation of the current
246.1287 +*  subproblem using the dual simplex method.
246.1288 +*
246.1289 +*  RETURNS
246.1290 +*
246.1291 +*  The routine returns the code which is reported by glp_simplex. */
246.1292 +
246.1293 +int ios_solve_node(glp_tree *tree)
246.1294 +{     glp_prob *mip = tree->mip;
246.1295 +      glp_smcp parm;
246.1296 +      int ret;
246.1297 +      /* the current subproblem must exist */
246.1298 +      xassert(tree->curr != NULL);
246.1299 +      /* set some control parameters */
246.1300 +      glp_init_smcp(&parm);
246.1301 +      switch (tree->parm->msg_lev)
246.1302 +      {  case GLP_MSG_OFF:
246.1303 +            parm.msg_lev = GLP_MSG_OFF; break;
246.1304 +         case GLP_MSG_ERR:
246.1305 +            parm.msg_lev = GLP_MSG_ERR; break;
246.1306 +         case GLP_MSG_ON:
246.1307 +         case GLP_MSG_ALL:
246.1308 +            parm.msg_lev = GLP_MSG_ON; break;
246.1309 +         case GLP_MSG_DBG:
246.1310 +            parm.msg_lev = GLP_MSG_ALL; break;
246.1311 +         default:
246.1312 +            xassert(tree != tree);
246.1313 +      }
246.1314 +      parm.meth = GLP_DUALP;
246.1315 +      if (tree->parm->msg_lev < GLP_MSG_DBG)
246.1316 +         parm.out_dly = tree->parm->out_dly;
246.1317 +      else
246.1318 +         parm.out_dly = 0;
246.1319 +      /* if the incumbent objective value is already known, use it to
246.1320 +         prematurely terminate the dual simplex search */
246.1321 +      if (mip->mip_stat == GLP_FEAS)
246.1322 +      {  switch (tree->mip->dir)
246.1323 +         {  case GLP_MIN:
246.1324 +               parm.obj_ul = mip->mip_obj;
246.1325 +               break;
246.1326 +            case GLP_MAX:
246.1327 +               parm.obj_ll = mip->mip_obj;
246.1328 +               break;
246.1329 +            default:
246.1330 +               xassert(mip != mip);
246.1331 +         }
246.1332 +      }
246.1333 +      /* try to solve/re-optimize the LP relaxation */
246.1334 +      ret = glp_simplex(mip, &parm);
246.1335 +      tree->curr->solved++;
246.1336 +#if 0
246.1337 +      xprintf("ret = %d; status = %d; pbs = %d; dbs = %d; some = %d\n",
246.1338 +         ret, glp_get_status(mip), mip->pbs_stat, mip->dbs_stat,
246.1339 +         mip->some);
246.1340 +      lpx_print_sol(mip, "sol");
246.1341 +#endif
246.1342 +      return ret;
246.1343 +}
246.1344 +
246.1345 +/**********************************************************************/
246.1346 +
246.1347 +IOSPOOL *ios_create_pool(glp_tree *tree)
246.1348 +{     /* create cut pool */
246.1349 +      IOSPOOL *pool;
246.1350 +#if 0
246.1351 +      pool = dmp_get_atom(tree->pool, sizeof(IOSPOOL));
246.1352 +#else
246.1353 +      xassert(tree == tree);
246.1354 +      pool = xmalloc(sizeof(IOSPOOL));
246.1355 +#endif
246.1356 +      pool->size = 0;
246.1357 +      pool->head = pool->tail = NULL;
246.1358 +      pool->ord = 0, pool->curr = NULL;
246.1359 +      return pool;
246.1360 +}
246.1361 +
246.1362 +int ios_add_row(glp_tree *tree, IOSPOOL *pool,
246.1363 +      const char *name, int klass, int flags, int len, const int ind[],
246.1364 +      const double val[], int type, double rhs)
246.1365 +{     /* add row (constraint) to the cut pool */
246.1366 +      IOSCUT *cut;
246.1367 +      IOSAIJ *aij;
246.1368 +      int k;
246.1369 +      xassert(pool != NULL);
246.1370 +      cut = dmp_get_atom(tree->pool, sizeof(IOSCUT));
246.1371 +      if (name == NULL || name[0] == '\0')
246.1372 +         cut->name = NULL;
246.1373 +      else
246.1374 +      {  for (k = 0; name[k] != '\0'; k++)
246.1375 +         {  if (k == 256)
246.1376 +               xerror("glp_ios_add_row: cut name too long\n");
246.1377 +            if (iscntrl((unsigned char)name[k]))
246.1378 +               xerror("glp_ios_add_row: cut name contains invalid chara"
246.1379 +                  "cter(s)\n");
246.1380 +         }
246.1381 +         cut->name = dmp_get_atom(tree->pool, strlen(name)+1);
246.1382 +         strcpy(cut->name, name);
246.1383 +      }
246.1384 +      if (!(0 <= klass && klass <= 255))
246.1385 +         xerror("glp_ios_add_row: klass = %d; invalid cut class\n",
246.1386 +            klass);
246.1387 +      cut->klass = (unsigned char)klass;
246.1388 +      if (flags != 0)
246.1389 +         xerror("glp_ios_add_row: flags = %d; invalid cut flags\n",
246.1390 +            flags);
246.1391 +      cut->ptr = NULL;
246.1392 +      if (!(0 <= len && len <= tree->n))
246.1393 +         xerror("glp_ios_add_row: len = %d; invalid cut length\n",
246.1394 +            len);
246.1395 +      for (k = 1; k <= len; k++)
246.1396 +      {  aij = dmp_get_atom(tree->pool, sizeof(IOSAIJ));
246.1397 +         if (!(1 <= ind[k] && ind[k] <= tree->n))
246.1398 +            xerror("glp_ios_add_row: ind[%d] = %d; column index out of "
246.1399 +               "range\n", k, ind[k]);
246.1400 +         aij->j = ind[k];
246.1401 +         aij->val = val[k];
246.1402 +         aij->next = cut->ptr;
246.1403 +         cut->ptr = aij;
246.1404 +      }
246.1405 +      if (!(type == GLP_LO || type == GLP_UP || type == GLP_FX))
246.1406 +         xerror("glp_ios_add_row: type = %d; invalid cut type\n",
246.1407 +            type);
246.1408 +      cut->type = (unsigned char)type;
246.1409 +      cut->rhs = rhs;
246.1410 +      cut->prev = pool->tail;
246.1411 +      cut->next = NULL;
246.1412 +      if (cut->prev == NULL)
246.1413 +         pool->head = cut;
246.1414 +      else
246.1415 +         cut->prev->next = cut;
246.1416 +      pool->tail = cut;
246.1417 +      pool->size++;
246.1418 +      return pool->size;
246.1419 +}
246.1420 +
246.1421 +IOSCUT *ios_find_row(IOSPOOL *pool, int i)
246.1422 +{     /* find row (constraint) in the cut pool */
246.1423 +      /* (smart linear search) */
246.1424 +      xassert(pool != NULL);
246.1425 +      xassert(1 <= i && i <= pool->size);
246.1426 +      if (pool->ord == 0)
246.1427 +      {  xassert(pool->curr == NULL);
246.1428 +         pool->ord = 1;
246.1429 +         pool->curr = pool->head;
246.1430 +      }
246.1431 +      xassert(pool->curr != NULL);
246.1432 +      if (i < pool->ord)
246.1433 +      {  if (i < pool->ord - i)
246.1434 +         {  pool->ord = 1;
246.1435 +            pool->curr = pool->head;
246.1436 +            while (pool->ord != i)
246.1437 +            {  pool->ord++;
246.1438 +               xassert(pool->curr != NULL);
246.1439 +               pool->curr = pool->curr->next;
246.1440 +            }
246.1441 +         }
246.1442 +         else
246.1443 +         {  while (pool->ord != i)
246.1444 +            {  pool->ord--;
246.1445 +               xassert(pool->curr != NULL);
246.1446 +               pool->curr = pool->curr->prev;
246.1447 +            }
246.1448 +         }
246.1449 +      }
246.1450 +      else if (i > pool->ord)
246.1451 +      {  if (i - pool->ord < pool->size - i)
246.1452 +         {  while (pool->ord != i)
246.1453 +            {  pool->ord++;
246.1454 +               xassert(pool->curr != NULL);
246.1455 +               pool->curr = pool->curr->next;
246.1456 +            }
246.1457 +         }
246.1458 +         else
246.1459 +         {  pool->ord = pool->size;
246.1460 +            pool->curr = pool->tail;
246.1461 +            while (pool->ord != i)
246.1462 +            {  pool->ord--;
246.1463 +               xassert(pool->curr != NULL);
246.1464 +               pool->curr = pool->curr->prev;
246.1465 +            }
246.1466 +         }
246.1467 +      }
246.1468 +      xassert(pool->ord == i);
246.1469 +      xassert(pool->curr != NULL);
246.1470 +      return pool->curr;
246.1471 +}
246.1472 +
246.1473 +void ios_del_row(glp_tree *tree, IOSPOOL *pool, int i)
246.1474 +{     /* remove row (constraint) from the cut pool */
246.1475 +      IOSCUT *cut;
246.1476 +      IOSAIJ *aij;
246.1477 +      xassert(pool != NULL);
246.1478 +      if (!(1 <= i && i <= pool->size))
246.1479 +         xerror("glp_ios_del_row: i = %d; cut number out of range\n",
246.1480 +            i);
246.1481 +      cut = ios_find_row(pool, i);
246.1482 +      xassert(pool->curr == cut);
246.1483 +      if (cut->next != NULL)
246.1484 +         pool->curr = cut->next;
246.1485 +      else if (cut->prev != NULL)
246.1486 +         pool->ord--, pool->curr = cut->prev;
246.1487 +      else
246.1488 +         pool->ord = 0, pool->curr = NULL;
246.1489 +      if (cut->name != NULL)
246.1490 +         dmp_free_atom(tree->pool, cut->name, strlen(cut->name)+1);
246.1491 +      if (cut->prev == NULL)
246.1492 +      {  xassert(pool->head == cut);
246.1493 +         pool->head = cut->next;
246.1494 +      }
246.1495 +      else
246.1496 +      {  xassert(cut->prev->next == cut);
246.1497 +         cut->prev->next = cut->next;
246.1498 +      }
246.1499 +      if (cut->next == NULL)
246.1500 +      {  xassert(pool->tail == cut);
246.1501 +         pool->tail = cut->prev;
246.1502 +      }
246.1503 +      else
246.1504 +      {  xassert(cut->next->prev == cut);
246.1505 +         cut->next->prev = cut->prev;
246.1506 +      }
246.1507 +      while (cut->ptr != NULL)
246.1508 +      {  aij = cut->ptr;
246.1509 +         cut->ptr = aij->next;
246.1510 +         dmp_free_atom(tree->pool, aij, sizeof(IOSAIJ));
246.1511 +      }
246.1512 +      dmp_free_atom(tree->pool, cut, sizeof(IOSCUT));
246.1513 +      pool->size--;
246.1514 +      return;
246.1515 +}
246.1516 +
246.1517 +void ios_clear_pool(glp_tree *tree, IOSPOOL *pool)
246.1518 +{     /* remove all rows (constraints) from the cut pool */
246.1519 +      xassert(pool != NULL);
246.1520 +      while (pool->head != NULL)
246.1521 +      {  IOSCUT *cut = pool->head;
246.1522 +         pool->head = cut->next;
246.1523 +         if (cut->name != NULL)
246.1524 +            dmp_free_atom(tree->pool, cut->name, strlen(cut->name)+1);
246.1525 +         while (cut->ptr != NULL)
246.1526 +         {  IOSAIJ *aij = cut->ptr;
246.1527 +            cut->ptr = aij->next;
246.1528 +            dmp_free_atom(tree->pool, aij, sizeof(IOSAIJ));
246.1529 +         }
246.1530 +         dmp_free_atom(tree->pool, cut, sizeof(IOSCUT));
246.1531 +      }
246.1532 +      pool->size = 0;
246.1533 +      pool->head = pool->tail = NULL;
246.1534 +      pool->ord = 0, pool->curr = NULL;
246.1535 +      return;
246.1536 +}
246.1537 +
246.1538 +void ios_delete_pool(glp_tree *tree, IOSPOOL *pool)
246.1539 +{     /* delete cut pool */
246.1540 +      xassert(pool != NULL);
246.1541 +      ios_clear_pool(tree, pool);
246.1542 +      xfree(pool);
246.1543 +      return;
246.1544 +}
246.1545 +
246.1546 +/**********************************************************************/
246.1547 +
246.1548 +#if 0
246.1549 +static int refer_to_node(glp_tree *tree, int j)
246.1550 +{     /* determine node number corresponding to binary variable x[j] or
246.1551 +         its complement */
246.1552 +      glp_prob *mip = tree->mip;
246.1553 +      int n = mip->n;
246.1554 +      int *ref;
246.1555 +      if (j > 0)
246.1556 +         ref = tree->n_ref;
246.1557 +      else
246.1558 +         ref = tree->c_ref, j = - j;
246.1559 +      xassert(1 <= j && j <= n);
246.1560 +      if (ref[j] == 0)
246.1561 +      {  /* new node is needed */
246.1562 +         SCG *g = tree->g;
246.1563 +         int n_max = g->n_max;
246.1564 +         ref[j] = scg_add_nodes(g, 1);
246.1565 +         if (g->n_max > n_max)
246.1566 +         {  int *save = tree->j_ref;
246.1567 +            tree->j_ref = xcalloc(1+g->n_max, sizeof(int));
246.1568 +            memcpy(&tree->j_ref[1], &save[1], g->n * sizeof(int));
246.1569 +            xfree(save);
246.1570 +         }
246.1571 +         xassert(ref[j] == g->n);
246.1572 +         tree->j_ref[ref[j]] = j;
246.1573 +         xassert(tree->curr != NULL);
246.1574 +         if (tree->curr->level > 0) tree->curr->own_nn++;
246.1575 +      }
246.1576 +      return ref[j];
246.1577 +}
246.1578 +#endif
246.1579 +
246.1580 +#if 0
246.1581 +void ios_add_edge(glp_tree *tree, int j1, int j2)
246.1582 +{     /* add new edge to the conflict graph */
246.1583 +      glp_prob *mip = tree->mip;
246.1584 +      int n = mip->n;
246.1585 +      SCGRIB *e;
246.1586 +      int first, i1, i2;
246.1587 +      xassert(-n <= j1 && j1 <= +n && j1 != 0);
246.1588 +      xassert(-n <= j2 && j2 <= +n && j2 != 0);
246.1589 +      xassert(j1 != j2);
246.1590 +      /* determine number of the first node, which was added for the
246.1591 +         current subproblem */
246.1592 +      xassert(tree->curr != NULL);
246.1593 +      first = tree->g->n - tree->curr->own_nn + 1;
246.1594 +      /* determine node numbers for both endpoints */
246.1595 +      i1 = refer_to_node(tree, j1);
246.1596 +      i2 = refer_to_node(tree, j2);
246.1597 +      /* add edge (i1,i2) to the conflict graph */
246.1598 +      e = scg_add_edge(tree->g, i1, i2);
246.1599 +      /* if the current subproblem is not the root and both endpoints
246.1600 +         were created on some previous levels, save the edge */
246.1601 +      if (tree->curr->level > 0 && i1 < first && i2 < first)
246.1602 +      {  IOSRIB *rib;
246.1603 +         rib = dmp_get_atom(tree->pool, sizeof(IOSRIB));
246.1604 +         rib->j1 = j1;
246.1605 +         rib->j2 = j2;
246.1606 +         rib->e = e;
246.1607 +         rib->next = tree->curr->e_ptr;
246.1608 +         tree->curr->e_ptr = rib;
246.1609 +      }
246.1610 +      return;
246.1611 +}
246.1612 +#endif
246.1613 +
246.1614 +/* eof */
   247.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
   247.2 +++ b/deps/glpk/src/glpios02.c	Sun Nov 06 20:59:10 2011 +0100
   247.3 @@ -0,0 +1,825 @@
   247.4 +/* glpios02.c (preprocess current subproblem) */
   247.5 +
   247.6 +/***********************************************************************
   247.7 +*  This code is part of GLPK (GNU Linear Programming Kit).
   247.8 +*
   247.9 +*  Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008,
  247.10 +*  2009, 2010, 2011 Andrew Makhorin, Department for Applied Informatics,
  247.11 +*  Moscow Aviation Institute, Moscow, Russia. All rights reserved.
  247.12 +*  E-mail: <mao@gnu.org>.
  247.13 +*
  247.14 +*  GLPK is free software: you can redistribute it and/or modify it
  247.15 +*  under the terms of the GNU General Public License as published by
  247.16 +*  the Free Software Foundation, either version 3 of the License, or
  247.17 +*  (at your option) any later version.
  247.18 +*
  247.19 +*  GLPK is distributed in the hope that it will be useful, but WITHOUT
  247.20 +*  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
  247.21 +*  or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
  247.22 +*  License for more details.
  247.23 +*
  247.24 +*  You should have received a copy of the GNU General Public License
  247.25 +*  along with GLPK. If not, see <http://www.gnu.org/licenses/>.
  247.26 +***********************************************************************/
  247.27 +
  247.28 +#include "glpios.h"
  247.29 +
  247.30 +/***********************************************************************
  247.31 +*  prepare_row_info - prepare row info to determine implied bounds
  247.32 +*
  247.33 +*  Given a row (linear form)
  247.34 +*
  247.35 +*      n
  247.36 +*     sum a[j] * x[j]                                                (1)
  247.37 +*     j=1
  247.38 +*
  247.39 +*  and bounds of columns (variables)
  247.40 +*
  247.41 +*     l[j] <= x[j] <= u[j]                                           (2)
  247.42 +*
  247.43 +*  this routine computes f_min, j_min, f_max, j_max needed to determine
  247.44 +*  implied bounds.
  247.45 +*
  247.46 +*  ALGORITHM
  247.47 +*
  247.48 +*  Let J+ = {j : a[j] > 0} and J- = {j : a[j] < 0}.
  247.49 +*
  247.50 +*  Parameters f_min and j_min are computed as follows:
  247.51 +*
  247.52 +*  1) if there is no x[k] such that k in J+ and l[k] = -inf or k in J-
  247.53 +*     and u[k] = +inf, then
  247.54 +*
  247.55 +*     f_min :=   sum   a[j] * l[j] +   sum   a[j] * u[j]
  247.56 +*              j in J+               j in J-
  247.57 +*                                                                    (3)
  247.58 +*     j_min := 0
  247.59 +*
  247.60 +*  2) if there is exactly one x[k] such that k in J+ and l[k] = -inf
  247.61 +*     or k in J- and u[k] = +inf, then
  247.62 +*
  247.63 +*     f_min :=   sum       a[j] * l[j] +   sum       a[j] * u[j]
  247.64 +*              j in J+\{k}               j in J-\{k}
  247.65 +*                                                                    (4)
  247.66 +*     j_min := k
  247.67 +*
  247.68 +*  3) if there are two or more x[k] such that k in J+ and l[k] = -inf
  247.69 +*     or k in J- and u[k] = +inf, then
  247.70 +*
  247.71 +*     f_min := -inf
  247.72 +*                                                                    (5)
  247.73 +*     j_min := 0
  247.74 +*
  247.75 +*  Parameters f_max and j_max are computed in a similar way as follows:
  247.76 +*
  247.77 +*  1) if there is no x[k] such that k in J+ and u[k] = +inf or k in J-
  247.78 +*     and l[k] = -inf, then
  247.79 +*
  247.80 +*     f_max :=   sum   a[j] * u[j] +   sum   a[j] * l[j]
  247.81 +*              j in J+               j in J-
  247.82 +*                                                                    (6)
  247.83 +*     j_max := 0
  247.84 +*
  247.85 +*  2) if there is exactly one x[k] such that k in J+ and u[k] = +inf
  247.86 +*     or k in J- and l[k] = -inf, then
  247.87 +*
  247.88 +*     f_max :=   sum       a[j] * u[j] +   sum       a[j] * l[j]
  247.89 +*              j in J+\{k}               j in J-\{k}
  247.90 +*                                                                    (7)
  247.91 +*     j_max := k
  247.92 +*
  247.93 +*  3) if there are two or more x[k] such that k in J+ and u[k] = +inf
  247.94 +*     or k in J- and l[k] = -inf, then
  247.95 +*
  247.96 +*     f_max := +inf
  247.97 +*                                                                    (8)
  247.98 +*     j_max := 0                                                      */
  247.99 +
 247.100 +struct f_info
 247.101 +{     int j_min, j_max;
 247.102 +      double f_min, f_max;
 247.103 +};
 247.104 +
 247.105 +static void prepare_row_info(int n, const double a[], const double l[],
 247.106 +      const double u[], struct f_info *f)
 247.107 +{     int j, j_min, j_max;
 247.108 +      double f_min, f_max;
 247.109 +      xassert(n >= 0);
 247.110 +      /* determine f_min and j_min */
 247.111 +      f_min = 0.0, j_min = 0;
 247.112 +      for (j = 1; j <= n; j++)
 247.113 +      {  if (a[j] > 0.0)
 247.114 +         {  if (l[j] == -DBL_MAX)
 247.115 +            {  if (j_min == 0)
 247.116 +                  j_min = j;
 247.117 +               else
 247.118 +               {  f_min = -DBL_MAX, j_min = 0;
 247.119 +                  break;
 247.120 +               }
 247.121 +            }
 247.122 +            else
 247.123 +               f_min += a[j] * l[j];
 247.124 +         }
 247.125 +         else if (a[j] < 0.0)
 247.126 +         {  if (u[j] == +DBL_MAX)
 247.127 +            {  if (j_min == 0)
 247.128 +                  j_min = j;
 247.129 +               else
 247.130 +               {  f_min = -DBL_MAX, j_min = 0;
 247.131 +                  break;
 247.132 +               }
 247.133 +            }
 247.134 +            else
 247.135 +               f_min += a[j] * u[j];
 247.136 +         }
 247.137 +         else
 247.138 +            xassert(a != a);
 247.139 +      }
 247.140 +      f->f_min = f_min, f->j_min = j_min;
 247.141 +      /* determine f_max and j_max */
 247.142 +      f_max = 0.0, j_max = 0;
 247.143 +      for (j = 1; j <= n; j++)
 247.144 +      {  if (a[j] > 0.0)
 247.145 +         {  if (u[j] == +DBL_MAX)
 247.146 +            {  if (j_max == 0)
 247.147 +                  j_max = j;
 247.148 +               else
 247.149 +               {  f_max = +DBL_MAX, j_max = 0;
 247.150 +                  break;
 247.151 +               }
 247.152 +            }
 247.153 +            else
 247.154 +               f_max += a[j] * u[j];
 247.155 +         }
 247.156 +         else if (a[j] < 0.0)
 247.157 +         {  if (l[j] == -DBL_MAX)
 247.158 +            {  if (j_max == 0)
 247.159 +                  j_max = j;
 247.160 +               else
 247.161 +               {  f_max = +DBL_MAX, j_max = 0;
 247.162 +                  break;
 247.163 +               }
 247.164 +            }
 247.165 +            else
 247.166 +               f_max += a[j] * l[j];
 247.167 +         }
 247.168 +         else
 247.169 +            xassert(a != a);
 247.170 +      }
 247.171 +      f->f_max = f_max, f->j_max = j_max;
 247.172 +      return;
 247.173 +}
 247.174 +
 247.175 +/***********************************************************************
 247.176 +*  row_implied_bounds - determine row implied bounds
 247.177 +*
 247.178 +*  Given a row (linear form)
 247.179 +*
 247.180 +*      n
 247.181 +*     sum a[j] * x[j]
 247.182 +*     j=1
 247.183 +*
 247.184 +*  and bounds of columns (variables)
 247.185 +*
 247.186 +*     l[j] <= x[j] <= u[j]
 247.187 +*
 247.188 +*  this routine determines implied bounds of the row.
 247.189 +*
 247.190 +*  ALGORITHM
 247.191 +*
 247.192 +*  Let J+ = {j : a[j] > 0} and J- = {j : a[j] < 0}.
 247.193 +*
 247.194 +*  The implied lower bound of the row is computed as follows:
 247.195 +*
 247.196 +*     L' :=   sum   a[j] * l[j] +   sum   a[j] * u[j]                (9)
 247.197 +*           j in J+               j in J-
 247.198 +*
 247.199 +*  and as it follows from (3), (4), and (5):
 247.200 +*
 247.201 +*     L' := if j_min = 0 then f_min else -inf                       (10)
 247.202 +*
 247.203 +*  The implied upper bound of the row is computed as follows:
 247.204 +*
 247.205 +*     U' :=   sum   a[j] * u[j] +   sum   a[j] * l[j]               (11)
 247.206 +*           j in J+               j in J-
 247.207 +*
 247.208 +*  and as it follows from (6), (7), and (8):
 247.209 +*
 247.210 +*     U' := if j_max = 0 then f_max else +inf                       (12)
 247.211 +*
 247.212 +*  The implied bounds are stored in locations LL and UU. */
 247.213 +
 247.214 +static void row_implied_bounds(const struct f_info *f, double *LL,
 247.215 +      double *UU)
 247.216 +{     *LL = (f->j_min == 0 ? f->f_min : -DBL_MAX);
 247.217 +      *UU = (f->j_max == 0 ? f->f_max : +DBL_MAX);
 247.218 +      return;
 247.219 +}
 247.220 +
 247.221 +/***********************************************************************
 247.222 +*  col_implied_bounds - determine column implied bounds
 247.223 +*
 247.224 +*  Given a row (constraint)
 247.225 +*
 247.226 +*           n
 247.227 +*     L <= sum a[j] * x[j] <= U                                     (13)
 247.228 +*          j=1
 247.229 +*
 247.230 +*  and bounds of columns (variables)
 247.231 +*
 247.232 +*     l[j] <= x[j] <= u[j]
 247.233 +*
 247.234 +*  this routine determines implied bounds of variable x[k].
 247.235 +*
 247.236 +*  It is assumed that if L != -inf, the lower bound of the row can be
 247.237 +*  active, and if U != +inf, the upper bound of the row can be active.
 247.238 +*
 247.239 +*  ALGORITHM
 247.240 +*
 247.241 +*  From (13) it follows that
 247.242 +*
 247.243 +*     L <= sum a[j] * x[j] + a[k] * x[k] <= U
 247.244 +*          j!=k
 247.245 +*  or
 247.246 +*
 247.247 +*     L - sum a[j] * x[j] <= a[k] * x[k] <= U - sum a[j] * x[j]
 247.248 +*         j!=k                                  j!=k
 247.249 +*
 247.250 +*  Thus, if the row lower bound L can be active, implied lower bound of
 247.251 +*  term a[k] * x[k] can be determined as follows:
 247.252 +*
 247.253 +*     ilb(a[k] * x[k]) = min(L - sum a[j] * x[j]) =
 247.254 +*                                j!=k
 247.255 +*                                                                   (14)
 247.256 +*                      = L - max sum a[j] * x[j]
 247.257 +*                            j!=k
 247.258 +*
 247.259 +*  where, as it follows from (6), (7), and (8)
 247.260 +*
 247.261 +*                           / f_max - a[k] * u[k], j_max = 0, a[k] > 0
 247.262 +*                           |
 247.263 +*                           | f_max - a[k] * l[k], j_max = 0, a[k] < 0
 247.264 +*     max sum a[j] * x[j] = {
 247.265 +*         j!=k              | f_max,               j_max = k
 247.266 +*                           |
 247.267 +*                           \ +inf,                j_max != 0
 247.268 +*
 247.269 +*  and if the upper bound U can be active, implied upper bound of term
 247.270 +*  a[k] * x[k] can be determined as follows:
 247.271 +*
 247.272 +*     iub(a[k] * x[k]) = max(U - sum a[j] * x[j]) =
 247.273 +*                                j!=k
 247.274 +*                                                                   (15)
 247.275 +*                      = U - min sum a[j] * x[j]
 247.276 +*                            j!=k
 247.277 +*
 247.278 +*  where, as it follows from (3), (4), and (5)
 247.279 +*
 247.280 +*                           / f_min - a[k] * l[k], j_min = 0, a[k] > 0
 247.281 +*                           |
 247.282 +*                           | f_min - a[k] * u[k], j_min = 0, a[k] < 0
 247.283 +*     min sum a[j] * x[j] = {
 247.284 +*         j!=k              | f_min,               j_min = k
 247.285 +*                           |
 247.286 +*                           \ -inf,                j_min != 0
 247.287 +*
 247.288 +*  Since
 247.289 +*
 247.290 +*     ilb(a[k] * x[k]) <= a[k] * x[k] <= iub(a[k] * x[k])
 247.291 +*
 247.292 +*  implied lower and upper bounds of x[k] are determined as follows:
 247.293 +*
 247.294 +*     l'[k] := if a[k] > 0 then ilb / a[k] else ulb / a[k]          (16)
 247.295 +*
 247.296 +*     u'[k] := if a[k] > 0 then ulb / a[k] else ilb / a[k]          (17)
 247.297 +*
 247.298 +*  The implied bounds are stored in locations ll and uu. */
 247.299 +
 247.300 +static void col_implied_bounds(const struct f_info *f, int n,
 247.301 +      const double a[], double L, double U, const double l[],
 247.302 +      const double u[], int k, double *ll, double *uu)
 247.303 +{     double ilb, iub;
 247.304 +      xassert(n >= 0);
 247.305 +      xassert(1 <= k && k <= n);
 247.306 +      /* determine implied lower bound of term a[k] * x[k] (14) */
 247.307 +      if (L == -DBL_MAX || f->f_max == +DBL_MAX)
 247.308 +         ilb = -DBL_MAX;
 247.309 +      else if (f->j_max == 0)
 247.310 +      {  if (a[k] > 0.0)
 247.311 +         {  xassert(u[k] != +DBL_MAX);
 247.312 +            ilb = L - (f->f_max - a[k] * u[k]);
 247.313 +         }
 247.314 +         else if (a[k] < 0.0)
 247.315 +         {  xassert(l[k] != -DBL_MAX);
 247.316 +            ilb = L - (f->f_max - a[k] * l[k]);
 247.317 +         }
 247.318 +         else
 247.319 +            xassert(a != a);
 247.320 +      }
 247.321 +      else if (f->j_max == k)
 247.322 +         ilb = L - f->f_max;
 247.323 +      else
 247.324 +         ilb = -DBL_MAX;
 247.325 +      /* determine implied upper bound of term a[k] * x[k] (15) */
 247.326 +      if (U == +DBL_MAX || f->f_min == -DBL_MAX)
 247.327 +         iub = +DBL_MAX;
 247.328 +      else if (f->j_min == 0)
 247.329 +      {  if (a[k] > 0.0)
 247.330 +         {  xassert(l[k] != -DBL_MAX);
 247.331 +            iub = U - (f->f_min - a[k] * l[k]);
 247.332 +         }
 247.333 +         else if (a[k] < 0.0)
 247.334 +         {  xassert(u[k] != +DBL_MAX);
 247.335 +            iub = U - (f->f_min - a[k] * u[k]);
 247.336 +         }
 247.337 +         else
 247.338 +            xassert(a != a);
 247.339 +      }
 247.340 +      else if (f->j_min == k)
 247.341 +         iub = U - f->f_min;
 247.342 +      else
 247.343 +         iub = +DBL_MAX;
 247.344 +      /* determine implied bounds of x[k] (16) and (17) */
 247.345 +#if 1
 247.346 +      /* do not use a[k] if it has small magnitude to prevent wrong
 247.347 +         implied bounds; for example, 1e-15 * x1 >= x2 + x3, where
 247.348 +         x1 >= -10, x2, x3 >= 0, would lead to wrong conclusion that
 247.349 +         x1 >= 0 */
 247.350 +      if (fabs(a[k]) < 1e-6)
 247.351 +         *ll = -DBL_MAX, *uu = +DBL_MAX; else
 247.352 +#endif
 247.353 +      if (a[k] > 0.0)
 247.354 +      {  *ll = (ilb == -DBL_MAX ? -DBL_MAX : ilb / a[k]);
 247.355 +         *uu = (iub == +DBL_MAX ? +DBL_MAX : iub / a[k]);
 247.356 +      }
 247.357 +      else if (a[k] < 0.0)
 247.358 +      {  *ll = (iub == +DBL_MAX ? -DBL_MAX : iub / a[k]);
 247.359 +         *uu = (ilb == -DBL_MAX ? +DBL_MAX : ilb / a[k]);
 247.360 +      }
 247.361 +      else
 247.362 +         xassert(a != a);
 247.363 +      return;
 247.364 +}
 247.365 +
 247.366 +/***********************************************************************
 247.367 +*  check_row_bounds - check and relax original row bounds
 247.368 +*
 247.369 +*  Given a row (constraint)
 247.370 +*
 247.371 +*           n
 247.372 +*     L <= sum a[j] * x[j] <= U
 247.373 +*          j=1
 247.374 +*
 247.375 +*  and bounds of columns (variables)
 247.376 +*
 247.377 +*     l[j] <= x[j] <= u[j]
 247.378 +*
 247.379 +*  this routine checks the original row bounds L and U for feasibility
 247.380 +*  and redundancy. If the original lower bound L or/and upper bound U
 247.381 +*  cannot be active due to bounds of variables, the routine remove them
 247.382 +*  replacing by -inf or/and +inf, respectively.
 247.383 +*
 247.384 +*  If no primal infeasibility is detected, the routine returns zero,
 247.385 +*  otherwise non-zero. */
 247.386 +
 247.387 +static int check_row_bounds(const struct f_info *f, double *L_,
 247.388 +      double *U_)
 247.389 +{     int ret = 0;
 247.390 +      double L = *L_, U = *U_, LL, UU;
 247.391 +      /* determine implied bounds of the row */
 247.392 +      row_implied_bounds(f, &LL, &UU);
 247.393 +      /* check if the original lower bound is infeasible */
 247.394 +      if (L != -DBL_MAX)
 247.395 +      {  double eps = 1e-3 * (1.0 + fabs(L));
 247.396 +         if (UU < L - eps)
 247.397 +         {  ret = 1;
 247.398 +            goto done;
 247.399 +         }
 247.400 +      }
 247.401 +      /* check if the original upper bound is infeasible */
 247.402 +      if (U != +DBL_MAX)
 247.403 +      {  double eps = 1e-3 * (1.0 + fabs(U));
 247.404 +         if (LL > U + eps)
 247.405 +         {  ret = 1;
 247.406 +            goto done;
 247.407 +         }
 247.408 +      }
 247.409 +      /* check if the original lower bound is redundant */
 247.410 +      if (L != -DBL_MAX)
 247.411 +      {  double eps = 1e-12 * (1.0 + fabs(L));
 247.412 +         if (LL > L - eps)
 247.413 +         {  /* it cannot be active, so remove it */
 247.414 +            *L_ = -DBL_MAX;
 247.415 +         }
 247.416 +      }
 247.417 +      /* check if the original upper bound is redundant */
 247.418 +      if (U != +DBL_MAX)
 247.419 +      {  double eps = 1e-12 * (1.0 + fabs(U));
 247.420 +         if (UU < U + eps)
 247.421 +         {  /* it cannot be active, so remove it */
 247.422 +            *U_ = +DBL_MAX;
 247.423 +         }
 247.424 +      }
 247.425 +done: return ret;
 247.426 +}
 247.427 +
 247.428 +/***********************************************************************
 247.429 +*  check_col_bounds - check and tighten original column bounds
 247.430 +*
 247.431 +*  Given a row (constraint)
 247.432 +*
 247.433 +*           n
 247.434 +*     L <= sum a[j] * x[j] <= U
 247.435 +*          j=1
 247.436 +*
 247.437 +*  and bounds of columns (variables)
 247.438 +*
 247.439 +*     l[j] <= x[j] <= u[j]
 247.440 +*
 247.441 +*  for column (variable) x[j] this routine checks the original column
 247.442 +*  bounds l[j] and u[j] for feasibility and redundancy. If the original
 247.443 +*  lower bound l[j] or/and upper bound u[j] cannot be active due to
 247.444 +*  bounds of the constraint and other variables, the routine tighten
 247.445 +*  them replacing by corresponding implied bounds, if possible.
 247.446 +*
 247.447 +*  NOTE: It is assumed that if L != -inf, the row lower bound can be
 247.448 +*        active, and if U != +inf, the row upper bound can be active.
 247.449 +*
 247.450 +*  The flag means that variable x[j] is required to be integer.
 247.451 +*
 247.452 +*  New actual bounds for x[j] are stored in locations lj and uj.
 247.453 +*
 247.454 +*  If no primal infeasibility is detected, the routine returns zero,
 247.455 +*  otherwise non-zero. */
 247.456 +
 247.457 +static int check_col_bounds(const struct f_info *f, int n,
 247.458 +      const double a[], double L, double U, const double l[],
 247.459 +      const double u[], int flag, int j, double *_lj, double *_uj)
 247.460 +{     int ret = 0;
 247.461 +      double lj, uj, ll, uu;
 247.462 +      xassert(n >= 0);
 247.463 +      xassert(1 <= j && j <= n);
 247.464 +      lj = l[j], uj = u[j];
 247.465 +      /* determine implied bounds of the column */
 247.466 +      col_implied_bounds(f, n, a, L, U, l, u, j, &ll, &uu);
 247.467 +      /* if x[j] is integral, round its implied bounds */
 247.468 +      if (flag)
 247.469 +      {  if (ll != -DBL_MAX)
 247.470 +            ll = (ll - floor(ll) < 1e-3 ? floor(ll) : ceil(ll));
 247.471 +         if (uu != +DBL_MAX)
 247.472 +            uu = (ceil(uu) - uu < 1e-3 ? ceil(uu) : floor(uu));
 247.473 +      }
 247.474 +      /* check if the original lower bound is infeasible */
 247.475 +      if (lj != -DBL_MAX)
 247.476 +      {  double eps = 1e-3 * (1.0 + fabs(lj));
 247.477 +         if (uu < lj - eps)
 247.478 +         {  ret = 1;
 247.479 +            goto done;
 247.480 +         }
 247.481 +      }
 247.482 +      /* check if the original upper bound is infeasible */
 247.483 +      if (uj != +DBL_MAX)
 247.484 +      {  double eps = 1e-3 * (1.0 + fabs(uj));
 247.485 +         if (ll > uj + eps)
 247.486 +         {  ret = 1;
 247.487 +            goto done;
 247.488 +         }
 247.489 +      }
 247.490 +      /* check if the original lower bound is redundant */
 247.491 +      if (ll != -DBL_MAX)
 247.492 +      {  double eps = 1e-3 * (1.0 + fabs(ll));
 247.493 +         if (lj < ll - eps)
 247.494 +         {  /* it cannot be active, so tighten it */
 247.495 +            lj = ll;
 247.496 +         }
 247.497 +      }
 247.498 +      /* check if the original upper bound is redundant */
 247.499 +      if (uu != +DBL_MAX)
 247.500 +      {  double eps = 1e-3 * (1.0 + fabs(uu));
 247.501 +         if (uj > uu + eps)
 247.502 +         {  /* it cannot be active, so tighten it */
 247.503 +            uj = uu;
 247.504 +         }
 247.505 +      }
 247.506 +      /* due to round-off errors it may happen that lj > uj (although
 247.507 +         lj < uj + eps, since no primal infeasibility is detected), so
 247.508 +         adjuct the new actual bounds to provide lj <= uj */
 247.509 +      if (!(lj == -DBL_MAX || uj == +DBL_MAX))
 247.510 +      {  double t1 = fabs(lj), t2 = fabs(uj);
 247.511 +         double eps = 1e-10 * (1.0 + (t1 <= t2 ? t1 : t2));
 247.512 +         if (lj > uj - eps)
 247.513 +         {  if (lj == l[j])
 247.514 +               uj = lj;
 247.515 +            else if (uj == u[j])
 247.516 +               lj = uj;
 247.517 +            else if (t1 <= t2)
 247.518 +               uj = lj;
 247.519 +            else
 247.520 +               lj = uj;
 247.521 +         }
 247.522 +      }
 247.523 +      *_lj = lj, *_uj = uj;
 247.524 +done: return ret;
 247.525 +}
 247.526 +
 247.527 +/***********************************************************************
 247.528 +*  check_efficiency - check if change in column bounds is efficient
 247.529 +*
 247.530 +*  Given the original bounds of a column l and u and its new actual
 247.531 +*  bounds l' and u' (possibly tighten by the routine check_col_bounds)
 247.532 +*  this routine checks if the change in the column bounds is efficient
 247.533 +*  enough. If so, the routine returns non-zero, otherwise zero.
 247.534 +*
 247.535 +*  The flag means that the variable is required to be integer. */
 247.536 +
 247.537 +static int check_efficiency(int flag, double l, double u, double ll,
 247.538 +      double uu)
 247.539 +{     int eff = 0;
 247.540 +      /* check efficiency for lower bound */
 247.541 +      if (l < ll)
 247.542 +      {  if (flag || l == -DBL_MAX)
 247.543 +            eff++;
 247.544 +         else
 247.545 +         {  double r;
 247.546 +            if (u == +DBL_MAX)
 247.547 +               r = 1.0 + fabs(l);
 247.548 +            else
 247.549 +               r = 1.0 + (u - l);
 247.550 +            if (ll - l >= 0.25 * r)
 247.551 +               eff++;
 247.552 +         }
 247.553 +      }
 247.554 +      /* check efficiency for upper bound */
 247.555 +      if (u > uu)
 247.556 +      {  if (flag || u == +DBL_MAX)
 247.557 +            eff++;
 247.558 +         else
 247.559 +         {  double r;
 247.560 +            if (l == -DBL_MAX)
 247.561 +               r = 1.0 + fabs(u);
 247.562 +            else
 247.563 +               r = 1.0 + (u - l);
 247.564 +            if (u - uu >= 0.25 * r)
 247.565 +               eff++;
 247.566 +         }
 247.567 +      }
 247.568 +      return eff;
 247.569 +}
 247.570 +
 247.571 +/***********************************************************************
 247.572 +*  basic_preprocessing - perform basic preprocessing
 247.573 +*
 247.574 +*  This routine performs basic preprocessing of the specified MIP that
 247.575 +*  includes relaxing some row bounds and tightening some column bounds.
 247.576 +*
 247.577 +*  On entry the arrays L and U contains original row bounds, and the
 247.578 +*  arrays l and u contains original column bounds:
 247.579 +*
 247.580 +*  L[0] is the lower bound of the objective row;
 247.581 +*  L[i], i = 1,...,m, is the lower bound of i-th row;
 247.582 +*  U[0] is the upper bound of the objective row;
 247.583 +*  U[i], i = 1,...,m, is the upper bound of i-th row;
 247.584 +*  l[0] is not used;
 247.585 +*  l[j], j = 1,...,n, is the lower bound of j-th column;
 247.586 +*  u[0] is not used;
 247.587 +*  u[j], j = 1,...,n, is the upper bound of j-th column.
 247.588 +*
 247.589 +*  On exit the arrays L, U, l, and u contain new actual bounds of rows
 247.590 +*  and column in the same locations.
 247.591 +*
 247.592 +*  The parameters nrs and num specify an initial list of rows to be
 247.593 +*  processed:
 247.594 +*
 247.595 +*  nrs is the number of rows in the initial list, 0 <= nrs <= m+1;
 247.596 +*  num[0] is not used;
 247.597 +*  num[1,...,nrs] are row numbers (0 means the objective row).
 247.598 +*
 247.599 +*  The parameter max_pass specifies the maximal number of times that
 247.600 +*  each row can be processed, max_pass > 0.
 247.601 +*
 247.602 +*  If no primal infeasibility is detected, the routine returns zero,
 247.603 +*  otherwise non-zero. */
 247.604 +
 247.605 +static int basic_preprocessing(glp_prob *mip, double L[], double U[],
 247.606 +      double l[], double u[], int nrs, const int num[], int max_pass)
 247.607 +{     int m = mip->m;
 247.608 +      int n = mip->n;
 247.609 +      struct f_info f;
 247.610 +      int i, j, k, len, size, ret = 0;
 247.611 +      int *ind, *list, *mark, *pass;
 247.612 +      double *val, *lb, *ub;
 247.613 +      xassert(0 <= nrs && nrs <= m+1);
 247.614 +      xassert(max_pass > 0);
 247.615 +      /* allocate working arrays */
 247.616 +      ind = xcalloc(1+n, sizeof(int));
 247.617 +      list = xcalloc(1+m+1, sizeof(int));
 247.618 +      mark = xcalloc(1+m+1, sizeof(int));
 247.619 +      memset(&mark[0], 0, (m+1) * sizeof(int));
 247.620 +      pass = xcalloc(1+m+1, sizeof(int));
 247.621 +      memset(&pass[0], 0, (m+1) * sizeof(int));
 247.622 +      val = xcalloc(1+n, sizeof(double));
 247.623 +      lb = xcalloc(1+n, sizeof(double));
 247.624 +      ub = xcalloc(1+n, sizeof(double));
 247.625 +      /* initialize the list of rows to be processed */
 247.626 +      size = 0;
 247.627 +      for (k = 1; k <= nrs; k++)
 247.628 +      {  i = num[k];
 247.629 +         xassert(0 <= i && i <= m);
 247.630 +         /* duplicate row numbers are not allowed */
 247.631 +         xassert(!mark[i]);
 247.632 +         list[++size] = i, mark[i] = 1;
 247.633 +      }
 247.634 +      xassert(size == nrs);
 247.635 +      /* process rows in the list until it becomes empty */
 247.636 +      while (size > 0)
 247.637 +      {  /* get a next row from the list */
 247.638 +         i = list[size--], mark[i] = 0;
 247.639 +         /* increase the row processing count */
 247.640 +         pass[i]++;
 247.641 +         /* if the row is free, skip it */
 247.642 +         if (L[i] == -DBL_MAX && U[i] == +DBL_MAX) continue;
 247.643 +         /* obtain coefficients of the row */
 247.644 +         len = 0;
 247.645 +         if (i == 0)
 247.646 +         {  for (j = 1; j <= n; j++)
 247.647 +            {  GLPCOL *col = mip->col[j];
 247.648 +               if (col->coef != 0.0)
 247.649 +                  len++, ind[len] = j, val[len] = col->coef;
 247.650 +            }
 247.651 +         }
 247.652 +         else
 247.653 +         {  GLPROW *row = mip->row[i];
 247.654 +            GLPAIJ *aij;
 247.655 +            for (aij = row->ptr; aij != NULL; aij = aij->r_next)
 247.656 +               len++, ind[len] = aij->col->j, val[len] = aij->val;
 247.657 +         }
 247.658 +         /* determine lower and upper bounds of columns corresponding
 247.659 +            to non-zero row coefficients */
 247.660 +         for (k = 1; k <= len; k++)
 247.661 +            j = ind[k], lb[k] = l[j], ub[k] = u[j];
 247.662 +         /* prepare the row info to determine implied bounds */
 247.663 +         prepare_row_info(len, val, lb, ub, &f);
 247.664 +         /* check and relax bounds of the row */
 247.665 +         if (check_row_bounds(&f, &L[i], &U[i]))
 247.666 +         {  /* the feasible region is empty */
 247.667 +            ret = 1;
 247.668 +            goto done;
 247.669 +         }
 247.670 +         /* if the row became free, drop it */
 247.671 +         if (L[i] == -DBL_MAX && U[i] == +DBL_MAX) continue;
 247.672 +         /* process columns having non-zero coefficients in the row */
 247.673 +         for (k = 1; k <= len; k++)
 247.674 +         {  GLPCOL *col;
 247.675 +            int flag, eff;
 247.676 +            double ll, uu;
 247.677 +            /* take a next column in the row */
 247.678 +            j = ind[k], col = mip->col[j];
 247.679 +            flag = col->kind != GLP_CV;
 247.680 +            /* check and tighten bounds of the column */
 247.681 +            if (check_col_bounds(&f, len, val, L[i], U[i], lb, ub,
 247.682 +                flag, k, &ll, &uu))
 247.683 +            {  /* the feasible region is empty */
 247.684 +               ret = 1;
 247.685 +               goto done;
 247.686 +            }
 247.687 +            /* check if change in the column bounds is efficient */
 247.688 +            eff = check_efficiency(flag, l[j], u[j], ll, uu);
 247.689 +            /* set new actual bounds of the column */
 247.690 +            l[j] = ll, u[j] = uu;
 247.691 +            /* if the change is efficient, add all rows affected by the
 247.692 +               corresponding column, to the list */
 247.693 +            if (eff > 0)
 247.694 +            {  GLPAIJ *aij;
 247.695 +               for (aij = col->ptr; aij != NULL; aij = aij->c_next)
 247.696 +               {  int ii = aij->row->i;
 247.697 +                  /* if the row was processed maximal number of times,
 247.698 +                     skip it */
 247.699 +                  if (pass[ii] >= max_pass) continue;
 247.700 +                  /* if the row is free, skip it */
 247.701 +                  if (L[ii] == -DBL_MAX && U[ii] == +DBL_MAX) continue;
 247.702 +                  /* put the row into the list */
 247.703 +                  if (mark[ii] == 0)
 247.704 +                  {  xassert(size <= m);
 247.705 +                     list[++size] = ii, mark[ii] = 1;
 247.706 +                  }
 247.707 +               }
 247.708 +            }
 247.709 +         }
 247.710 +      }
 247.711 +done: /* free working arrays */
 247.712 +      xfree(ind);
 247.713 +      xfree(list);
 247.714 +      xfree(mark);
 247.715 +      xfree(pass);
 247.716 +      xfree(val);
 247.717 +      xfree(lb);
 247.718 +      xfree(ub);
 247.719 +      return ret;
 247.720 +}
 247.721 +
 247.722 +/***********************************************************************
 247.723 +*  NAME
 247.724 +*
 247.725 +*  ios_preprocess_node - preprocess current subproblem
 247.726 +*
 247.727 +*  SYNOPSIS
 247.728 +*
 247.729 +*  #include "glpios.h"
 247.730 +*  int ios_preprocess_node(glp_tree *tree, int max_pass);
 247.731 +*
 247.732 +*  DESCRIPTION
 247.733 +*
 247.734 +*  The routine ios_preprocess_node performs basic preprocessing of the
 247.735 +*  current subproblem.
 247.736 +*
 247.737 +*  RETURNS
 247.738 +*
 247.739 +*  If no primal infeasibility is detected, the routine returns zero,
 247.740 +*  otherwise non-zero. */
 247.741 +
 247.742 +int ios_preprocess_node(glp_tree *tree, int max_pass)
 247.743 +{     glp_prob *mip = tree->mip;
 247.744 +      int m = mip->m;
 247.745 +      int n = mip->n;
 247.746 +      int i, j, nrs, *num, ret = 0;
 247.747 +      double *L, *U, *l, *u;
 247.748 +      /* the current subproblem must exist */
 247.749 +      xassert(tree->curr != NULL);
 247.750 +      /* determine original row bounds */
 247.751 +      L = xcalloc(1+m, sizeof(double));
 247.752 +      U = xcalloc(1+m, sizeof(double));
 247.753 +      switch (mip->mip_stat)
 247.754 +      {  case GLP_UNDEF:
 247.755 +            L[0] = -DBL_MAX, U[0] = +DBL_MAX;
 247.756 +            break;
 247.757 +         case GLP_FEAS:
 247.758 +            switch (mip->dir)
 247.759 +            {  case GLP_MIN:
 247.760 +                  L[0] = -DBL_MAX, U[0] = mip->mip_obj - mip->c0;
 247.761 +                  break;
 247.762 +               case GLP_MAX:
 247.763 +                  L[0] = mip->mip_obj - mip->c0, U[0] = +DBL_MAX;
 247.764 +                  break;
 247.765 +               default:
 247.766 +                  xassert(mip != mip);
 247.767 +            }
 247.768 +            break;
 247.769 +         default:
 247.770 +            xassert(mip != mip);
 247.771 +      }
 247.772 +      for (i = 1; i <= m; i++)
 247.773 +      {  L[i] = glp_get_row_lb(mip, i);
 247.774 +         U[i] = glp_get_row_ub(mip, i);
 247.775 +      }
 247.776 +      /* determine original column bounds */
 247.777 +      l = xcalloc(1+n, sizeof(double));
 247.778 +      u = xcalloc(1+n, sizeof(double));
 247.779 +      for (j = 1; j <= n; j++)
 247.780 +      {  l[j] = glp_get_col_lb(mip, j);
 247.781 +         u[j] = glp_get_col_ub(mip, j);
 247.782 +      }
 247.783 +      /* build the initial list of rows to be analyzed */
 247.784 +      nrs = m + 1;
 247.785 +      num = xcalloc(1+nrs, sizeof(int));
 247.786 +      for (i = 1; i <= nrs; i++) num[i] = i - 1;
 247.787 +      /* perform basic preprocessing */
 247.788 +      if (basic_preprocessing(mip , L, U, l, u, nrs, num, max_pass))
 247.789 +      {  ret = 1;
 247.790 +         goto done;
 247.791 +      }
 247.792 +      /* set new actual (relaxed) row bounds */
 247.793 +      for (i = 1; i <= m; i++)
 247.794 +      {  /* consider only non-active rows to keep dual feasibility */
 247.795 +         if (glp_get_row_stat(mip, i) == GLP_BS)
 247.796 +         {  if (L[i] == -DBL_MAX && U[i] == +DBL_MAX)
 247.797 +               glp_set_row_bnds(mip, i, GLP_FR, 0.0, 0.0);
 247.798 +            else if (U[i] == +DBL_MAX)
 247.799 +               glp_set_row_bnds(mip, i, GLP_LO, L[i], 0.0);
 247.800 +            else if (L[i] == -DBL_MAX)
 247.801 +               glp_set_row_bnds(mip, i, GLP_UP, 0.0, U[i]);
 247.802 +         }
 247.803 +      }
 247.804 +      /* set new actual (tightened) column bounds */
 247.805 +      for (j = 1; j <= n; j++)
 247.806 +      {  int type;
 247.807 +         if (l[j] == -DBL_MAX && u[j] == +DBL_MAX)
 247.808 +            type = GLP_FR;
 247.809 +         else if (u[j] == +DBL_MAX)
 247.810 +            type = GLP_LO;
 247.811 +         else if (l[j] == -DBL_MAX)
 247.812 +            type = GLP_UP;
 247.813 +         else if (l[j] != u[j])
 247.814 +            type = GLP_DB;
 247.815 +         else
 247.816 +            type = GLP_FX;
 247.817 +         glp_set_col_bnds(mip, j, type, l[j], u[j]);
 247.818 +      }
 247.819 +done: /* free working arrays and return */
 247.820 +      xfree(L);
 247.821 +      xfree(U);
 247.822 +      xfree(l);
 247.823 +      xfree(u);
 247.824 +      xfree(num);
 247.825 +      return ret;
 247.826 +}
 247.827 +
 247.828 +/* eof */
   248.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
   248.2 +++ b/deps/glpk/src/glpios03.c	Sun Nov 06 20:59:10 2011 +0100
   248.3 @@ -0,0 +1,1155 @@
   248.4 +/* glpios03.c (branch-and-cut driver) */
   248.5 +
   248.6 +/***********************************************************************
   248.7 +*  This code is part of GLPK (GNU Linear Programming Kit).
   248.8 +*
   248.9 +*  Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008,
  248.10 +*  2009, 2010, 2011 Andrew Makhorin, Department for Applied Informatics,
  248.11 +*  Moscow Aviation Institute, Moscow, Russia. All rights reserved.
  248.12 +*  E-mail: <mao@gnu.org>.
  248.13 +*
  248.14 +*  GLPK is free software: you can redistribute it and/or modify it
  248.15 +*  under the terms of the GNU General Public License as published by
  248.16 +*  the Free Software Foundation, either version 3 of the License, or
  248.17 +*  (at your option) any later version.
  248.18 +*
  248.19 +*  GLPK is distributed in the hope that it will be useful, but WITHOUT
  248.20 +*  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
  248.21 +*  or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
  248.22 +*  License for more details.
  248.23 +*
  248.24 +*  You should have received a copy of the GNU General Public License
  248.25 +*  along with GLPK. If not, see <http://www.gnu.org/licenses/>.
  248.26 +***********************************************************************/
  248.27 +
  248.28 +#include "glpios.h"
  248.29 +
  248.30 +/***********************************************************************
  248.31 +*  show_progress - display current progress of the search
  248.32 +*
  248.33 +*  This routine displays some information about current progress of the
  248.34 +*  search.
  248.35 +*
  248.36 +*  The information includes:
  248.37 +*
  248.38 +*  the current number of iterations performed by the simplex solver;
  248.39 +*
  248.40 +*  the objective value for the best known integer feasible solution,
  248.41 +*  which is upper (minimization) or lower (maximization) global bound
  248.42 +*  for optimal solution of the original mip problem;
  248.43 +*
  248.44 +*  the best local bound for active nodes, which is lower (minimization)
  248.45 +*  or upper (maximization) global bound for optimal solution of the
  248.46 +*  original mip problem;
  248.47 +*
  248.48 +*  the relative mip gap, in percents;
  248.49 +*
  248.50 +*  the number of open (active) subproblems;
  248.51 +*
  248.52 +*  the number of completely explored subproblems, i.e. whose nodes have
  248.53 +*  been removed from the tree. */
  248.54 +
  248.55 +static void show_progress(glp_tree *T, int bingo)
  248.56 +{     int p;
  248.57 +      double temp;
  248.58 +      char best_mip[50], best_bound[50], *rho, rel_gap[50];
  248.59 +      /* format the best known integer feasible solution */
  248.60 +      if (T->mip->mip_stat == GLP_FEAS)
  248.61 +         sprintf(best_mip, "%17.9e", T->mip->mip_obj);
  248.62 +      else
  248.63 +         sprintf(best_mip, "%17s", "not found yet");
  248.64 +      /* determine reference number of an active subproblem whose local
  248.65 +         bound is best */
  248.66 +      p = ios_best_node(T);
  248.67 +      /* format the best bound */
  248.68 +      if (p == 0)
  248.69 +         sprintf(best_bound, "%17s", "tree is empty");
  248.70 +      else
  248.71 +      {  temp = T->slot[p].node->bound;
  248.72 +         if (temp == -DBL_MAX)
  248.73 +            sprintf(best_bound, "%17s", "-inf");
  248.74 +         else if (temp == +DBL_MAX)
  248.75 +            sprintf(best_bound, "%17s", "+inf");
  248.76 +         else
  248.77 +            sprintf(best_bound, "%17.9e", temp);
  248.78 +      }
  248.79 +      /* choose the relation sign between global bounds */
  248.80 +      if (T->mip->dir == GLP_MIN)
  248.81 +         rho = ">=";
  248.82 +      else if (T->mip->dir == GLP_MAX)
  248.83 +         rho = "<=";
  248.84 +      else
  248.85 +         xassert(T != T);
  248.86 +      /* format the relative mip gap */
  248.87 +      temp = ios_relative_gap(T);
  248.88 +      if (temp == 0.0)
  248.89 +         sprintf(rel_gap, "  0.0%%");
  248.90 +      else if (temp < 0.001)
  248.91 +         sprintf(rel_gap, "< 0.1%%");
  248.92 +      else if (temp <= 9.999)
  248.93 +         sprintf(rel_gap, "%5.1f%%", 100.0 * temp);
  248.94 +      else
  248.95 +         sprintf(rel_gap, "%6s", "");
  248.96 +      /* display progress of the search */
  248.97 +      xprintf("+%6d: %s %s %s %s %s (%d; %d)\n",
  248.98 +         T->mip->it_cnt, bingo ? ">>>>>" : "mip =", best_mip, rho,
  248.99 +         best_bound, rel_gap, T->a_cnt, T->t_cnt - T->n_cnt);
 248.100 +      T->tm_lag = xtime();
 248.101 +      return;
 248.102 +}
 248.103 +
 248.104 +/***********************************************************************
 248.105 +*  is_branch_hopeful - check if specified branch is hopeful
 248.106 +*
 248.107 +*  This routine checks if the specified subproblem can have an integer
 248.108 +*  optimal solution which is better than the best known one.
 248.109 +*
 248.110 +*  The check is based on comparison of the local objective bound stored
 248.111 +*  in the subproblem descriptor and the incumbent objective value which
 248.112 +*  is the global objective bound.
 248.113 +*
 248.114 +*  If there is a chance that the specified subproblem can have a better
 248.115 +*  integer optimal solution, the routine returns non-zero. Otherwise, if
 248.116 +*  the corresponding branch can pruned, zero is returned. */
 248.117 +
 248.118 +static int is_branch_hopeful(glp_tree *T, int p)
 248.119 +{     xassert(1 <= p && p <= T->nslots);
 248.120 +      xassert(T->slot[p].node != NULL);
 248.121 +      return ios_is_hopeful(T, T->slot[p].node->bound);
 248.122 +}
 248.123 +
 248.124 +/***********************************************************************
 248.125 +*  check_integrality - check integrality of basic solution
 248.126 +*
 248.127 +*  This routine checks if the basic solution of LP relaxation of the
 248.128 +*  current subproblem satisfies to integrality conditions, i.e. that all
 248.129 +*  variables of integer kind have integral primal values. (The solution
 248.130 +*  is assumed to be optimal.)
 248.131 +*
 248.132 +*  For each variable of integer kind the routine computes the following
 248.133 +*  quantity:
 248.134 +*
 248.135 +*     ii(x[j]) = min(x[j] - floor(x[j]), ceil(x[j]) - x[j]),         (1)
 248.136 +*
 248.137 +*  which is a measure of the integer infeasibility (non-integrality) of
 248.138 +*  x[j] (for example, ii(2.1) = 0.1, ii(3.7) = 0.3, ii(5.0) = 0). It is
 248.139 +*  understood that 0 <= ii(x[j]) <= 0.5, and variable x[j] is integer
 248.140 +*  feasible if ii(x[j]) = 0. However, due to floating-point arithmetic
 248.141 +*  the routine checks less restrictive condition:
 248.142 +*
 248.143 +*     ii(x[j]) <= tol_int,                                           (2)
 248.144 +*
 248.145 +*  where tol_int is a given tolerance (small positive number) and marks
 248.146 +*  each variable which does not satisfy to (2) as integer infeasible by
 248.147 +*  setting its fractionality flag.
 248.148 +*
 248.149 +*  In order to characterize integer infeasibility of the basic solution
 248.150 +*  in the whole the routine computes two parameters: ii_cnt, which is
 248.151 +*  the number of variables with the fractionality flag set, and ii_sum,
 248.152 +*  which is the sum of integer infeasibilities (1). */
 248.153 +
 248.154 +static void check_integrality(glp_tree *T)
 248.155 +{     glp_prob *mip = T->mip;
 248.156 +      int j, type, ii_cnt = 0;
 248.157 +      double lb, ub, x, temp1, temp2, ii_sum = 0.0;
 248.158 +      /* walk through the set of columns (structural variables) */
 248.159 +      for (j = 1; j <= mip->n; j++)
 248.160 +      {  GLPCOL *col = mip->col[j];
 248.161 +         T->non_int[j] = 0;
 248.162 +         /* if the column is not integer, skip it */
 248.163 +         if (col->kind != GLP_IV) continue;
 248.164 +         /* if the column is non-basic, it is integer feasible */
 248.165 +         if (col->stat != GLP_BS) continue;
 248.166 +         /* obtain the type and bounds of the column */
 248.167 +         type = col->type, lb = col->lb, ub = col->ub;
 248.168 +         /* obtain value of the column in optimal basic solution */
 248.169 +         x = col->prim;
 248.170 +         /* if the column's primal value is close to the lower bound,
 248.171 +            the column is integer feasible within given tolerance */
 248.172 +         if (type == GLP_LO || type == GLP_DB || type == GLP_FX)
 248.173 +         {  temp1 = lb - T->parm->tol_int;
 248.174 +            temp2 = lb + T->parm->tol_int;
 248.175 +            if (temp1 <= x && x <= temp2) continue;
 248.176 +#if 0
 248.177 +            /* the lower bound must not be violated */
 248.178 +            xassert(x >= lb);
 248.179 +#else
 248.180 +            if (x < lb) continue;
 248.181 +#endif
 248.182 +         }
 248.183 +         /* if the column's primal value is close to the upper bound,
 248.184 +            the column is integer feasible within given tolerance */
 248.185 +         if (type == GLP_UP || type == GLP_DB || type == GLP_FX)
 248.186 +         {  temp1 = ub - T->parm->tol_int;
 248.187 +            temp2 = ub + T->parm->tol_int;
 248.188 +            if (temp1 <= x && x <= temp2) continue;
 248.189 +#if 0
 248.190 +            /* the upper bound must not be violated */
 248.191 +            xassert(x <= ub);
 248.192 +#else
 248.193 +            if (x > ub) continue;
 248.194 +#endif
 248.195 +         }
 248.196 +         /* if the column's primal value is close to nearest integer,
 248.197 +            the column is integer feasible within given tolerance */
 248.198 +         temp1 = floor(x + 0.5) - T->parm->tol_int;
 248.199 +         temp2 = floor(x + 0.5) + T->parm->tol_int;
 248.200 +         if (temp1 <= x && x <= temp2) continue;
 248.201 +         /* otherwise the column is integer infeasible */
 248.202 +         T->non_int[j] = 1;
 248.203 +         /* increase the number of fractional-valued columns */
 248.204 +         ii_cnt++;
 248.205 +         /* compute the sum of integer infeasibilities */
 248.206 +         temp1 = x - floor(x);
 248.207 +         temp2 = ceil(x) - x;
 248.208 +         xassert(temp1 > 0.0 && temp2 > 0.0);
 248.209 +         ii_sum += (temp1 <= temp2 ? temp1 : temp2);
 248.210 +      }
 248.211 +      /* store ii_cnt and ii_sum to the current problem descriptor */
 248.212 +      xassert(T->curr != NULL);
 248.213 +      T->curr->ii_cnt = ii_cnt;
 248.214 +      T->curr->ii_sum = ii_sum;
 248.215 +      /* and also display these parameters */
 248.216 +      if (T->parm->msg_lev >= GLP_MSG_DBG)
 248.217 +      {  if (ii_cnt == 0)
 248.218 +            xprintf("There are no fractional columns\n");
 248.219 +         else if (ii_cnt == 1)
 248.220 +            xprintf("There is one fractional column, integer infeasibil"
 248.221 +               "ity is %.3e\n", ii_sum);
 248.222 +         else
 248.223 +            xprintf("There are %d fractional columns, integer infeasibi"
 248.224 +               "lity is %.3e\n", ii_cnt, ii_sum);
 248.225 +      }
 248.226 +      return;
 248.227 +}
 248.228 +
 248.229 +/***********************************************************************
 248.230 +*  record_solution - record better integer feasible solution
 248.231 +*
 248.232 +*  This routine records optimal basic solution of LP relaxation of the
 248.233 +*  current subproblem, which being integer feasible is better than the
 248.234 +*  best known integer feasible solution. */
 248.235 +
 248.236 +static void record_solution(glp_tree *T)
 248.237 +{     glp_prob *mip = T->mip;
 248.238 +      int i, j;
 248.239 +      mip->mip_stat = GLP_FEAS;
 248.240 +      mip->mip_obj = mip->obj_val;
 248.241 +      for (i = 1; i <= mip->m; i++)
 248.242 +      {  GLPROW *row = mip->row[i];
 248.243 +         row->mipx = row->prim;
 248.244 +      }
 248.245 +      for (j = 1; j <= mip->n; j++)
 248.246 +      {  GLPCOL *col = mip->col[j];
 248.247 +         if (col->kind == GLP_CV)
 248.248 +            col->mipx = col->prim;
 248.249 +         else if (col->kind == GLP_IV)
 248.250 +         {  /* value of the integer column must be integral */
 248.251 +            col->mipx = floor(col->prim + 0.5);
 248.252 +         }
 248.253 +         else
 248.254 +            xassert(col != col);
 248.255 +      }
 248.256 +      T->sol_cnt++;
 248.257 +      return;
 248.258 +}
 248.259 +
 248.260 +/***********************************************************************
 248.261 +*  fix_by_red_cost - fix non-basic integer columns by reduced costs
 248.262 +*
 248.263 +*  This routine fixes some non-basic integer columns if their reduced
 248.264 +*  costs indicate that increasing (decreasing) the column at least by
 248.265 +*  one involves the objective value becoming worse than the incumbent
 248.266 +*  objective value. */
 248.267 +
 248.268 +static void fix_by_red_cost(glp_tree *T)
 248.269 +{     glp_prob *mip = T->mip;
 248.270 +      int j, stat, fixed = 0;
 248.271 +      double obj, lb, ub, dj;
 248.272 +      /* the global bound must exist */
 248.273 +      xassert(T->mip->mip_stat == GLP_FEAS);
 248.274 +      /* basic solution of LP relaxation must be optimal */
 248.275 +      xassert(mip->pbs_stat == GLP_FEAS && mip->dbs_stat == GLP_FEAS);
 248.276 +      /* determine the objective function value */
 248.277 +      obj = mip->obj_val;
 248.278 +      /* walk through the column list */
 248.279 +      for (j = 1; j <= mip->n; j++)
 248.280 +      {  GLPCOL *col = mip->col[j];
 248.281 +         /* if the column is not integer, skip it */
 248.282 +         if (col->kind != GLP_IV) continue;
 248.283 +         /* obtain bounds of j-th column */
 248.284 +         lb = col->lb, ub = col->ub;
 248.285 +         /* and determine its status and reduced cost */
 248.286 +         stat = col->stat, dj = col->dual;
 248.287 +         /* analyze the reduced cost */
 248.288 +         switch (mip->dir)
 248.289 +         {  case GLP_MIN:
 248.290 +               /* minimization */
 248.291 +               if (stat == GLP_NL)
 248.292 +               {  /* j-th column is non-basic on its lower bound */
 248.293 +                  if (dj < 0.0) dj = 0.0;
 248.294 +                  if (obj + dj >= mip->mip_obj)
 248.295 +                     glp_set_col_bnds(mip, j, GLP_FX, lb, lb), fixed++;
 248.296 +               }
 248.297 +               else if (stat == GLP_NU)
 248.298 +               {  /* j-th column is non-basic on its upper bound */
 248.299 +                  if (dj > 0.0) dj = 0.0;
 248.300 +                  if (obj - dj >= mip->mip_obj)
 248.301 +                     glp_set_col_bnds(mip, j, GLP_FX, ub, ub), fixed++;
 248.302 +               }
 248.303 +               break;
 248.304 +            case GLP_MAX:
 248.305 +               /* maximization */
 248.306 +               if (stat == GLP_NL)
 248.307 +               {  /* j-th column is non-basic on its lower bound */
 248.308 +                  if (dj > 0.0) dj = 0.0;
 248.309 +                  if (obj + dj <= mip->mip_obj)
 248.310 +                     glp_set_col_bnds(mip, j, GLP_FX, lb, lb), fixed++;
 248.311 +               }
 248.312 +               else if (stat == GLP_NU)
 248.313 +               {  /* j-th column is non-basic on its upper bound */
 248.314 +                  if (dj < 0.0) dj = 0.0;
 248.315 +                  if (obj - dj <= mip->mip_obj)
 248.316 +                     glp_set_col_bnds(mip, j, GLP_FX, ub, ub), fixed++;
 248.317 +               }
 248.318 +               break;
 248.319 +            default:
 248.320 +               xassert(T != T);
 248.321 +         }
 248.322 +      }
 248.323 +      if (T->parm->msg_lev >= GLP_MSG_DBG)
 248.324 +      {  if (fixed == 0)
 248.325 +            /* nothing to say */;
 248.326 +         else if (fixed == 1)
 248.327 +            xprintf("One column has been fixed by reduced cost\n");
 248.328 +         else
 248.329 +            xprintf("%d columns have been fixed by reduced costs\n",
 248.330 +               fixed);
 248.331 +      }
 248.332 +      /* fixing non-basic columns on their current bounds does not
 248.333 +         change the basic solution */
 248.334 +      xassert(mip->pbs_stat == GLP_FEAS && mip->dbs_stat == GLP_FEAS);
 248.335 +      return;
 248.336 +}
 248.337 +
 248.338 +/***********************************************************************
 248.339 +*  branch_on - perform branching on specified variable
 248.340 +*
 248.341 +*  This routine performs branching on j-th column (structural variable)
 248.342 +*  of the current subproblem. The specified column must be of integer
 248.343 +*  kind and must have a fractional value in optimal basic solution of
 248.344 +*  LP relaxation of the current subproblem (i.e. only columns for which
 248.345 +*  the flag non_int[j] is set are valid candidates to branch on).
 248.346 +*
 248.347 +*  Let x be j-th structural variable, and beta be its primal fractional
 248.348 +*  value in the current basic solution. Branching on j-th variable is
 248.349 +*  dividing the current subproblem into two new subproblems, which are
 248.350 +*  identical to the current subproblem with the following exception: in
 248.351 +*  the first subproblem that begins the down-branch x has a new upper
 248.352 +*  bound x <= floor(beta), and in the second subproblem that begins the
 248.353 +*  up-branch x has a new lower bound x >= ceil(beta).
 248.354 +*
 248.355 +*  Depending on estimation of local bounds for down- and up-branches
 248.356 +*  this routine returns the following:
 248.357 +*
 248.358 +*  0 - both branches have been created;
 248.359 +*  1 - one branch is hopeless and has been pruned, so now the current
 248.360 +*      subproblem is other branch;
 248.361 +*  2 - both branches are hopeless and have been pruned; new subproblem
 248.362 +*      selection is needed to continue the search. */
 248.363 +
 248.364 +static int branch_on(glp_tree *T, int j, int next)
 248.365 +{     glp_prob *mip = T->mip;
 248.366 +      IOSNPD *node;
 248.367 +      int m = mip->m;
 248.368 +      int n = mip->n;
 248.369 +      int type, dn_type, up_type, dn_bad, up_bad, p, ret, clone[1+2];
 248.370 +      double lb, ub, beta, new_ub, new_lb, dn_lp, up_lp, dn_bnd, up_bnd;
 248.371 +      /* determine bounds and value of x[j] in optimal solution to LP
 248.372 +         relaxation of the current subproblem */
 248.373 +      xassert(1 <= j && j <= n);
 248.374 +      type = mip->col[j]->type;
 248.375 +      lb = mip->col[j]->lb;
 248.376 +      ub = mip->col[j]->ub;
 248.377 +      beta = mip->col[j]->prim;
 248.378 +      /* determine new bounds of x[j] for down- and up-branches */
 248.379 +      new_ub = floor(beta);
 248.380 +      new_lb = ceil(beta);
 248.381 +      switch (type)
 248.382 +      {  case GLP_FR:
 248.383 +            dn_type = GLP_UP;
 248.384 +            up_type = GLP_LO;
 248.385 +            break;
 248.386 +         case GLP_LO:
 248.387 +            xassert(lb <= new_ub);
 248.388 +            dn_type = (lb == new_ub ? GLP_FX : GLP_DB);
 248.389 +            xassert(lb + 1.0 <= new_lb);
 248.390 +            up_type = GLP_LO;
 248.391 +            break;
 248.392 +         case GLP_UP:
 248.393 +            xassert(new_ub <= ub - 1.0);
 248.394 +            dn_type = GLP_UP;
 248.395 +            xassert(new_lb <= ub);
 248.396 +            up_type = (new_lb == ub ? GLP_FX : GLP_DB);
 248.397 +            break;
 248.398 +         case GLP_DB:
 248.399 +            xassert(lb <= new_ub && new_ub <= ub - 1.0);
 248.400 +            dn_type = (lb == new_ub ? GLP_FX : GLP_DB);
 248.401 +            xassert(lb + 1.0 <= new_lb && new_lb <= ub);
 248.402 +            up_type = (new_lb == ub ? GLP_FX : GLP_DB);
 248.403 +            break;
 248.404 +         default:
 248.405 +            xassert(type != type);
 248.406 +      }
 248.407 +      /* compute local bounds to LP relaxation for both branches */
 248.408 +      ios_eval_degrad(T, j, &dn_lp, &up_lp);
 248.409 +      /* and improve them by rounding */
 248.410 +      dn_bnd = ios_round_bound(T, dn_lp);
 248.411 +      up_bnd = ios_round_bound(T, up_lp);
 248.412 +      /* check local bounds for down- and up-branches */
 248.413 +      dn_bad = !ios_is_hopeful(T, dn_bnd);
 248.414 +      up_bad = !ios_is_hopeful(T, up_bnd);
 248.415 +      if (dn_bad && up_bad)
 248.416 +      {  if (T->parm->msg_lev >= GLP_MSG_DBG)
 248.417 +            xprintf("Both down- and up-branches are hopeless\n");
 248.418 +         ret = 2;
 248.419 +         goto done;
 248.420 +      }
 248.421 +      else if (up_bad)
 248.422 +      {  if (T->parm->msg_lev >= GLP_MSG_DBG)
 248.423 +            xprintf("Up-branch is hopeless\n");
 248.424 +         glp_set_col_bnds(mip, j, dn_type, lb, new_ub);
 248.425 +         T->curr->lp_obj = dn_lp;
 248.426 +         if (mip->dir == GLP_MIN)
 248.427 +         {  if (T->curr->bound < dn_bnd)
 248.428 +                T->curr->bound = dn_bnd;
 248.429 +         }
 248.430 +         else if (mip->dir == GLP_MAX)
 248.431 +         {  if (T->curr->bound > dn_bnd)
 248.432 +                T->curr->bound = dn_bnd;
 248.433 +         }
 248.434 +         else
 248.435 +            xassert(mip != mip);
 248.436 +         ret = 1;
 248.437 +         goto done;
 248.438 +      }
 248.439 +      else if (dn_bad)
 248.440 +      {  if (T->parm->msg_lev >= GLP_MSG_DBG)
 248.441 +            xprintf("Down-branch is hopeless\n");
 248.442 +         glp_set_col_bnds(mip, j, up_type, new_lb, ub);
 248.443 +         T->curr->lp_obj = up_lp;
 248.444 +         if (mip->dir == GLP_MIN)
 248.445 +         {  if (T->curr->bound < up_bnd)
 248.446 +                T->curr->bound = up_bnd;
 248.447 +         }
 248.448 +         else if (mip->dir == GLP_MAX)
 248.449 +         {  if (T->curr->bound > up_bnd)
 248.450 +                T->curr->bound = up_bnd;
 248.451 +         }
 248.452 +         else
 248.453 +            xassert(mip != mip);
 248.454 +         ret = 1;
 248.455 +         goto done;
 248.456 +      }
 248.457 +      /* both down- and up-branches seem to be hopeful */
 248.458 +      if (T->parm->msg_lev >= GLP_MSG_DBG)
 248.459 +         xprintf("Branching on column %d, primal value is %.9e\n",
 248.460 +            j, beta);
 248.461 +      /* determine the reference number of the current subproblem */
 248.462 +      xassert(T->curr != NULL);
 248.463 +      p = T->curr->p;
 248.464 +      T->curr->br_var = j;
 248.465 +      T->curr->br_val = beta;
 248.466 +      /* freeze the current subproblem */
 248.467 +      ios_freeze_node(T);
 248.468 +      /* create two clones of the current subproblem; the first clone
 248.469 +         begins the down-branch, the second one begins the up-branch */
 248.470 +      ios_clone_node(T, p, 2, clone);
 248.471 +      if (T->parm->msg_lev >= GLP_MSG_DBG)
 248.472 +         xprintf("Node %d begins down branch, node %d begins up branch "
 248.473 +            "\n", clone[1], clone[2]);
 248.474 +      /* set new upper bound of j-th column in the down-branch */
 248.475 +      node = T->slot[clone[1]].node;
 248.476 +      xassert(node != NULL);
 248.477 +      xassert(node->up != NULL);
 248.478 +      xassert(node->b_ptr == NULL);
 248.479 +      node->b_ptr = dmp_get_atom(T->pool, sizeof(IOSBND));
 248.480 +      node->b_ptr->k = m + j;
 248.481 +      node->b_ptr->type = (unsigned char)dn_type;
 248.482 +      node->b_ptr->lb = lb;
 248.483 +      node->b_ptr->ub = new_ub;
 248.484 +      node->b_ptr->next = NULL;
 248.485 +      node->lp_obj = dn_lp;
 248.486 +      if (mip->dir == GLP_MIN)
 248.487 +      {  if (node->bound < dn_bnd)
 248.488 +             node->bound = dn_bnd;
 248.489 +      }
 248.490 +      else if (mip->dir == GLP_MAX)
 248.491 +      {  if (node->bound > dn_bnd)
 248.492 +             node->bound = dn_bnd;
 248.493 +      }
 248.494 +      else
 248.495 +         xassert(mip != mip);
 248.496 +      /* set new lower bound of j-th column in the up-branch */
 248.497 +      node = T->slot[clone[2]].node;
 248.498 +      xassert(node != NULL);
 248.499 +      xassert(node->up != NULL);
 248.500 +      xassert(node->b_ptr == NULL);
 248.501 +      node->b_ptr = dmp_get_atom(T->pool, sizeof(IOSBND));
 248.502 +      node->b_ptr->k = m + j;
 248.503 +      node->b_ptr->type = (unsigned char)up_type;
 248.504 +      node->b_ptr->lb = new_lb;
 248.505 +      node->b_ptr->ub = ub;
 248.506 +      node->b_ptr->next = NULL;
 248.507 +      node->lp_obj = up_lp;
 248.508 +      if (mip->dir == GLP_MIN)
 248.509 +      {  if (node->bound < up_bnd)
 248.510 +             node->bound = up_bnd;
 248.511 +      }
 248.512 +      else if (mip->dir == GLP_MAX)
 248.513 +      {  if (node->bound > up_bnd)
 248.514 +             node->bound = up_bnd;
 248.515 +      }
 248.516 +      else
 248.517 +         xassert(mip != mip);
 248.518 +      /* suggest the subproblem to be solved next */
 248.519 +      xassert(T->child == 0);
 248.520 +      if (next == GLP_NO_BRNCH)
 248.521 +         T->child = 0;
 248.522 +      else if (next == GLP_DN_BRNCH)
 248.523 +         T->child = clone[1];
 248.524 +      else if (next == GLP_UP_BRNCH)
 248.525 +         T->child = clone[2];
 248.526 +      else
 248.527 +         xassert(next != next);
 248.528 +      ret = 0;
 248.529 +done: return ret;
 248.530 +}
 248.531 +
 248.532 +/***********************************************************************
 248.533 +*  cleanup_the_tree - prune hopeless branches from the tree
 248.534 +*
 248.535 +*  This routine walks through the active list and checks the local
 248.536 +*  bound for every active subproblem. If the local bound indicates that
 248.537 +*  the subproblem cannot have integer optimal solution better than the
 248.538 +*  incumbent objective value, the routine deletes such subproblem that,
 248.539 +*  in turn, involves pruning the corresponding branch of the tree. */
 248.540 +
 248.541 +static void cleanup_the_tree(glp_tree *T)
 248.542 +{     IOSNPD *node, *next_node;
 248.543 +      int count = 0;
 248.544 +      /* the global bound must exist */
 248.545 +      xassert(T->mip->mip_stat == GLP_FEAS);
 248.546 +      /* walk through the list of active subproblems */
 248.547 +      for (node = T->head; node != NULL; node = next_node)
 248.548 +      {  /* deleting some active problem node may involve deleting its
 248.549 +            parents recursively; however, all its parents being created
 248.550 +            *before* it are always *precede* it in the node list, so
 248.551 +            the next problem node is never affected by such deletion */
 248.552 +         next_node = node->next;
 248.553 +         /* if the branch is hopeless, prune it */
 248.554 +         if (!is_branch_hopeful(T, node->p))
 248.555 +            ios_delete_node(T, node->p), count++;
 248.556 +      }
 248.557 +      if (T->parm->msg_lev >= GLP_MSG_DBG)
 248.558 +      {  if (count == 1)
 248.559 +            xprintf("One hopeless branch has been pruned\n");
 248.560 +         else if (count > 1)
 248.561 +            xprintf("%d hopeless branches have been pruned\n", count);
 248.562 +      }
 248.563 +      return;
 248.564 +}
 248.565 +
 248.566 +/**********************************************************************/
 248.567 +
 248.568 +static void generate_cuts(glp_tree *T)
 248.569 +{     /* generate generic cuts with built-in generators */
 248.570 +      if (!(T->parm->mir_cuts == GLP_ON ||
 248.571 +            T->parm->gmi_cuts == GLP_ON ||
 248.572 +            T->parm->cov_cuts == GLP_ON ||
 248.573 +            T->parm->clq_cuts == GLP_ON)) goto done;
 248.574 +#if 1 /* 20/IX-2008 */
 248.575 +      {  int i, max_cuts, added_cuts;
 248.576 +         max_cuts = T->n;
 248.577 +         if (max_cuts < 1000) max_cuts = 1000;
 248.578 +         added_cuts = 0;
 248.579 +         for (i = T->orig_m+1; i <= T->mip->m; i++)
 248.580 +         {  if (T->mip->row[i]->origin == GLP_RF_CUT)
 248.581 +               added_cuts++;
 248.582 +         }
 248.583 +         /* xprintf("added_cuts = %d\n", added_cuts); */
 248.584 +         if (added_cuts >= max_cuts) goto done;
 248.585 +      }
 248.586 +#endif
 248.587 +      /* generate and add to POOL all cuts violated by x* */
 248.588 +      if (T->parm->gmi_cuts == GLP_ON)
 248.589 +      {  if (T->curr->changed < 5)
 248.590 +            ios_gmi_gen(T);
 248.591 +      }
 248.592 +      if (T->parm->mir_cuts == GLP_ON)
 248.593 +      {  xassert(T->mir_gen != NULL);
 248.594 +         ios_mir_gen(T, T->mir_gen);
 248.595 +      }
 248.596 +      if (T->parm->cov_cuts == GLP_ON)
 248.597 +      {  /* cover cuts works well along with mir cuts */
 248.598 +         /*if (T->round <= 5)*/
 248.599 +            ios_cov_gen(T);
 248.600 +      }
 248.601 +      if (T->parm->clq_cuts == GLP_ON)
 248.602 +      {  if (T->clq_gen != NULL)
 248.603 +         {  if (T->curr->level == 0 && T->curr->changed < 50 ||
 248.604 +                T->curr->level >  0 && T->curr->changed < 5)
 248.605 +               ios_clq_gen(T, T->clq_gen);
 248.606 +         }
 248.607 +      }
 248.608 +done: return;
 248.609 +}
 248.610 +
 248.611 +/**********************************************************************/
 248.612 +
 248.613 +static void remove_cuts(glp_tree *T)
 248.614 +{     /* remove inactive cuts (some valueable globally valid cut might
 248.615 +         be saved in the global cut pool) */
 248.616 +      int i, cnt = 0, *num = NULL;
 248.617 +      xassert(T->curr != NULL);
 248.618 +      for (i = T->orig_m+1; i <= T->mip->m; i++)
 248.619 +      {  if (T->mip->row[i]->origin == GLP_RF_CUT &&
 248.620 +             T->mip->row[i]->level == T->curr->level &&
 248.621 +             T->mip->row[i]->stat == GLP_BS)
 248.622 +         {  if (num == NULL)
 248.623 +               num = xcalloc(1+T->mip->m, sizeof(int));
 248.624 +            num[++cnt] = i;
 248.625 +         }
 248.626 +      }
 248.627 +      if (cnt > 0)
 248.628 +      {  glp_del_rows(T->mip, cnt, num);
 248.629 +#if 0
 248.630 +         xprintf("%d inactive cut(s) removed\n", cnt);
 248.631 +#endif
 248.632 +         xfree(num);
 248.633 +         xassert(glp_factorize(T->mip) == 0);
 248.634 +      }
 248.635 +      return;
 248.636 +}
 248.637 +
 248.638 +/**********************************************************************/
 248.639 +
 248.640 +static void display_cut_info(glp_tree *T)
 248.641 +{     glp_prob *mip = T->mip;
 248.642 +      int i, gmi = 0, mir = 0, cov = 0, clq = 0, app = 0;
 248.643 +      for (i = mip->m; i > 0; i--)
 248.644 +      {  GLPROW *row;
 248.645 +         row = mip->row[i];
 248.646 +         /* if (row->level < T->curr->level) break; */
 248.647 +         if (row->origin == GLP_RF_CUT)
 248.648 +         {  if (row->klass == GLP_RF_GMI)
 248.649 +               gmi++;
 248.650 +            else if (row->klass == GLP_RF_MIR)
 248.651 +               mir++;
 248.652 +            else if (row->klass == GLP_RF_COV)
 248.653 +               cov++;
 248.654 +            else if (row->klass == GLP_RF_CLQ)
 248.655 +               clq++;
 248.656 +            else
 248.657 +               app++;
 248.658 +         }
 248.659 +      }
 248.660 +      xassert(T->curr != NULL);
 248.661 +      if (gmi + mir + cov + clq + app > 0)
 248.662 +      {  xprintf("Cuts on level %d:", T->curr->level);
 248.663 +         if (gmi > 0) xprintf(" gmi = %d;", gmi);
 248.664 +         if (mir > 0) xprintf(" mir = %d;", mir);
 248.665 +         if (cov > 0) xprintf(" cov = %d;", cov);
 248.666 +         if (clq > 0) xprintf(" clq = %d;", clq);
 248.667 +         if (app > 0) xprintf(" app = %d;", app);
 248.668 +         xprintf("\n");
 248.669 +      }
 248.670 +      return;
 248.671 +}
 248.672 +
 248.673 +/***********************************************************************
 248.674 +*  NAME
 248.675 +*
 248.676 +*  ios_driver - branch-and-cut driver
 248.677 +*
 248.678 +*  SYNOPSIS
 248.679 +*
 248.680 +*  #include "glpios.h"
 248.681 +*  int ios_driver(glp_tree *T);
 248.682 +*
 248.683 +*  DESCRIPTION
 248.684 +*
 248.685 +*  The routine ios_driver is a branch-and-cut driver. It controls the
 248.686 +*  MIP solution process.
 248.687 +*
 248.688 +*  RETURNS
 248.689 +*
 248.690 +*  0  The MIP problem instance has been successfully solved. This code
 248.691 +*     does not necessarily mean that the solver has found optimal
 248.692 +*     solution. It only means that the solution process was successful.
 248.693 +*
 248.694 +*  GLP_EFAIL
 248.695 +*     The search was prematurely terminated due to the solver failure.
 248.696 +*
 248.697 +*  GLP_EMIPGAP
 248.698 +*     The search was prematurely terminated, because the relative mip
 248.699 +*     gap tolerance has been reached.
 248.700 +*
 248.701 +*  GLP_ETMLIM
 248.702 +*     The search was prematurely terminated, because the time limit has
 248.703 +*     been exceeded.
 248.704 +*
 248.705 +*  GLP_ESTOP
 248.706 +*     The search was prematurely terminated by application. */
 248.707 +
 248.708 +int ios_driver(glp_tree *T)
 248.709 +{     int p, curr_p, p_stat, d_stat, ret;
 248.710 +#if 1 /* carry out to glp_tree */
 248.711 +      int pred_p = 0;
 248.712 +      /* if the current subproblem has been just created due to
 248.713 +         branching, pred_p is the reference number of its parent
 248.714 +         subproblem, otherwise pred_p is zero */
 248.715 +#endif
 248.716 +      glp_long ttt = T->tm_beg;
 248.717 +#if 0
 248.718 +      ((glp_iocp *)T->parm)->msg_lev = GLP_MSG_DBG;
 248.719 +#endif
 248.720 +      /* on entry to the B&B driver it is assumed that the active list
 248.721 +         contains the only active (i.e. root) subproblem, which is the
 248.722 +         original MIP problem to be solved */
 248.723 +loop: /* main loop starts here */
 248.724 +      /* at this point the current subproblem does not exist */
 248.725 +      xassert(T->curr == NULL);
 248.726 +      /* if the active list is empty, the search is finished */
 248.727 +      if (T->head == NULL)
 248.728 +      {  if (T->parm->msg_lev >= GLP_MSG_DBG)
 248.729 +            xprintf("Active list is empty!\n");
 248.730 +         xassert(dmp_in_use(T->pool).lo == 0);
 248.731 +         ret = 0;
 248.732 +         goto done;
 248.733 +      }
 248.734 +      /* select some active subproblem to continue the search */
 248.735 +      xassert(T->next_p == 0);
 248.736 +      /* let the application program select subproblem */
 248.737 +      if (T->parm->cb_func != NULL)
 248.738 +      {  xassert(T->reason == 0);
 248.739 +         T->reason = GLP_ISELECT;
 248.740 +         T->parm->cb_func(T, T->parm->cb_info);
 248.741 +         T->reason = 0;
 248.742 +         if (T->stop)
 248.743 +         {  ret = GLP_ESTOP;
 248.744 +            goto done;
 248.745 +         }
 248.746 +      }
 248.747 +      if (T->next_p != 0)
 248.748 +      {  /* the application program has selected something */
 248.749 +         ;
 248.750 +      }
 248.751 +      else if (T->a_cnt == 1)
 248.752 +      {  /* the only active subproblem exists, so select it */
 248.753 +         xassert(T->head->next == NULL);
 248.754 +         T->next_p = T->head->p;
 248.755 +      }
 248.756 +      else if (T->child != 0)
 248.757 +      {  /* select one of branching childs suggested by the branching
 248.758 +            heuristic */
 248.759 +         T->next_p = T->child;
 248.760 +      }
 248.761 +      else
 248.762 +      {  /* select active subproblem as specified by the backtracking
 248.763 +            technique option */
 248.764 +         T->next_p = ios_choose_node(T);
 248.765 +      }
 248.766 +      /* the active subproblem just selected becomes current */
 248.767 +      ios_revive_node(T, T->next_p);
 248.768 +      T->next_p = T->child = 0;
 248.769 +      /* invalidate pred_p, if it is not the reference number of the
 248.770 +         parent of the current subproblem */
 248.771 +      if (T->curr->up != NULL && T->curr->up->p != pred_p) pred_p = 0;
 248.772 +      /* determine the reference number of the current subproblem */
 248.773 +      p = T->curr->p;
 248.774 +      if (T->parm->msg_lev >= GLP_MSG_DBG)
 248.775 +      {  xprintf("-----------------------------------------------------"
 248.776 +            "-------------------\n");
 248.777 +         xprintf("Processing node %d at level %d\n", p, T->curr->level);
 248.778 +      }
 248.779 +      /* if it is the root subproblem, initialize cut generators */
 248.780 +      if (p == 1)
 248.781 +      {  if (T->parm->gmi_cuts == GLP_ON)
 248.782 +         {  if (T->parm->msg_lev >= GLP_MSG_ALL)
 248.783 +               xprintf("Gomory's cuts enabled\n");
 248.784 +         }
 248.785 +         if (T->parm->mir_cuts == GLP_ON)
 248.786 +         {  if (T->parm->msg_lev >= GLP_MSG_ALL)
 248.787 +               xprintf("MIR cuts enabled\n");
 248.788 +            xassert(T->mir_gen == NULL);
 248.789 +            T->mir_gen = ios_mir_init(T);
 248.790 +         }
 248.791 +         if (T->parm->cov_cuts == GLP_ON)
 248.792 +         {  if (T->parm->msg_lev >= GLP_MSG_ALL)
 248.793 +               xprintf("Cover cuts enabled\n");
 248.794 +         }
 248.795 +         if (T->parm->clq_cuts == GLP_ON)
 248.796 +         {  xassert(T->clq_gen == NULL);
 248.797 +            if (T->parm->msg_lev >= GLP_MSG_ALL)
 248.798 +               xprintf("Clique cuts enabled\n");
 248.799 +            T->clq_gen = ios_clq_init(T);
 248.800 +         }
 248.801 +      }
 248.802 +more: /* minor loop starts here */
 248.803 +      /* at this point the current subproblem needs either to be solved
 248.804 +         for the first time or re-optimized due to reformulation */
 248.805 +      /* display current progress of the search */
 248.806 +      if (T->parm->msg_lev >= GLP_MSG_DBG ||
 248.807 +          T->parm->msg_lev >= GLP_MSG_ON &&
 248.808 +        (double)(T->parm->out_frq - 1) <=
 248.809 +            1000.0 * xdifftime(xtime(), T->tm_lag))
 248.810 +         show_progress(T, 0);
 248.811 +      if (T->parm->msg_lev >= GLP_MSG_ALL &&
 248.812 +            xdifftime(xtime(), ttt) >= 60.0)
 248.813 +      {  glp_long total;
 248.814 +         glp_mem_usage(NULL, NULL, &total, NULL);
 248.815 +         xprintf("Time used: %.1f secs.  Memory used: %.1f Mb.\n",
 248.816 +            xdifftime(xtime(), T->tm_beg), xltod(total) / 1048576.0);
 248.817 +         ttt = xtime();
 248.818 +      }
 248.819 +      /* check the mip gap */
 248.820 +      if (T->parm->mip_gap > 0.0 &&
 248.821 +          ios_relative_gap(T) <= T->parm->mip_gap)
 248.822 +      {  if (T->parm->msg_lev >= GLP_MSG_DBG)
 248.823 +            xprintf("Relative gap tolerance reached; search terminated "
 248.824 +               "\n");
 248.825 +         ret = GLP_EMIPGAP;
 248.826 +         goto done;
 248.827 +      }
 248.828 +      /* check if the time limit has been exhausted */
 248.829 +      if (T->parm->tm_lim < INT_MAX &&
 248.830 +         (double)(T->parm->tm_lim - 1) <=
 248.831 +         1000.0 * xdifftime(xtime(), T->tm_beg))
 248.832 +      {  if (T->parm->msg_lev >= GLP_MSG_DBG)
 248.833 +            xprintf("Time limit exhausted; search terminated\n");
 248.834 +         ret = GLP_ETMLIM;
 248.835 +         goto done;
 248.836 +      }
 248.837 +      /* let the application program preprocess the subproblem */
 248.838 +      if (T->parm->cb_func != NULL)
 248.839 +      {  xassert(T->reason == 0);
 248.840 +         T->reason = GLP_IPREPRO;
 248.841 +         T->parm->cb_func(T, T->parm->cb_info);
 248.842 +         T->reason = 0;
 248.843 +         if (T->stop)
 248.844 +         {  ret = GLP_ESTOP;
 248.845 +            goto done;
 248.846 +         }
 248.847 +      }
 248.848 +      /* perform basic preprocessing */
 248.849 +      if (T->parm->pp_tech == GLP_PP_NONE)
 248.850 +         ;
 248.851 +      else if (T->parm->pp_tech == GLP_PP_ROOT)
 248.852 +      {  if (T->curr->level == 0)
 248.853 +         {  if (ios_preprocess_node(T, 100))
 248.854 +               goto fath;
 248.855 +         }
 248.856 +      }
 248.857 +      else if (T->parm->pp_tech == GLP_PP_ALL)
 248.858 +      {  if (ios_preprocess_node(T, T->curr->level == 0 ? 100 : 10))
 248.859 +            goto fath;
 248.860 +      }
 248.861 +      else
 248.862 +         xassert(T != T);
 248.863 +      /* preprocessing may improve the global bound */
 248.864 +      if (!is_branch_hopeful(T, p))
 248.865 +      {  xprintf("*** not tested yet ***\n");
 248.866 +         goto fath;
 248.867 +      }
 248.868 +      /* solve LP relaxation of the current subproblem */
 248.869 +      if (T->parm->msg_lev >= GLP_MSG_DBG)
 248.870 +         xprintf("Solving LP relaxation...\n");
 248.871 +      ret = ios_solve_node(T);
 248.872 +      if (!(ret == 0 || ret == GLP_EOBJLL || ret == GLP_EOBJUL))
 248.873 +      {  if (T->parm->msg_lev >= GLP_MSG_ERR)
 248.874 +            xprintf("ios_driver: unable to solve current LP relaxation;"
 248.875 +               " glp_simplex returned %d\n", ret);
 248.876 +         ret = GLP_EFAIL;
 248.877 +         goto done;
 248.878 +      }
 248.879 +      /* analyze status of the basic solution to LP relaxation found */
 248.880 +      p_stat = T->mip->pbs_stat;
 248.881 +      d_stat = T->mip->dbs_stat;
 248.882 +      if (p_stat == GLP_FEAS && d_stat == GLP_FEAS)
 248.883 +      {  /* LP relaxation has optimal solution */
 248.884 +         if (T->parm->msg_lev >= GLP_MSG_DBG)
 248.885 +            xprintf("Found optimal solution to LP relaxation\n");
 248.886 +      }
 248.887 +      else if (d_stat == GLP_NOFEAS)
 248.888 +      {  /* LP relaxation has no dual feasible solution */
 248.889 +         /* since the current subproblem cannot have a larger feasible
 248.890 +            region than its parent, there is something wrong */
 248.891 +         if (T->parm->msg_lev >= GLP_MSG_ERR)
 248.892 +            xprintf("ios_driver: current LP relaxation has no dual feas"
 248.893 +               "ible solution\n");
 248.894 +         ret = GLP_EFAIL;
 248.895 +         goto done;
 248.896 +      }
 248.897 +      else if (p_stat == GLP_INFEAS && d_stat == GLP_FEAS)
 248.898 +      {  /* LP relaxation has no primal solution which is better than
 248.899 +            the incumbent objective value */
 248.900 +         xassert(T->mip->mip_stat == GLP_FEAS);
 248.901 +         if (T->parm->msg_lev >= GLP_MSG_DBG)
 248.902 +            xprintf("LP relaxation has no solution better than incumben"
 248.903 +               "t objective value\n");
 248.904 +         /* prune the branch */
 248.905 +         goto fath;
 248.906 +      }
 248.907 +      else if (p_stat == GLP_NOFEAS)
 248.908 +      {  /* LP relaxation has no primal feasible solution */
 248.909 +         if (T->parm->msg_lev >= GLP_MSG_DBG)
 248.910 +            xprintf("LP relaxation has no feasible solution\n");
 248.911 +         /* prune the branch */
 248.912 +         goto fath;
 248.913 +      }
 248.914 +      else
 248.915 +      {  /* other cases cannot appear */
 248.916 +         xassert(T->mip != T->mip);
 248.917 +      }
 248.918 +      /* at this point basic solution to LP relaxation of the current
 248.919 +         subproblem is optimal */
 248.920 +      xassert(p_stat == GLP_FEAS && d_stat == GLP_FEAS);
 248.921 +      xassert(T->curr != NULL);
 248.922 +      T->curr->lp_obj = T->mip->obj_val;
 248.923 +      /* thus, it defines a local bound to integer optimal solution of
 248.924 +         the current subproblem */
 248.925 +      {  double bound = T->mip->obj_val;
 248.926 +         /* some local bound to the current subproblem could be already
 248.927 +            set before, so we should only improve it */
 248.928 +         bound = ios_round_bound(T, bound);
 248.929 +         if (T->mip->dir == GLP_MIN)
 248.930 +         {  if (T->curr->bound < bound)
 248.931 +               T->curr->bound = bound;
 248.932 +         }
 248.933 +         else if (T->mip->dir == GLP_MAX)
 248.934 +         {  if (T->curr->bound > bound)
 248.935 +               T->curr->bound = bound;
 248.936 +         }
 248.937 +         else
 248.938 +            xassert(T->mip != T->mip);
 248.939 +         if (T->parm->msg_lev >= GLP_MSG_DBG)
 248.940 +            xprintf("Local bound is %.9e\n", bound);
 248.941 +      }
 248.942 +      /* if the local bound indicates that integer optimal solution of
 248.943 +         the current subproblem cannot be better than the global bound,
 248.944 +         prune the branch */
 248.945 +      if (!is_branch_hopeful(T, p))
 248.946 +      {  if (T->parm->msg_lev >= GLP_MSG_DBG)
 248.947 +            xprintf("Current branch is hopeless and can be pruned\n");
 248.948 +         goto fath;
 248.949 +      }
 248.950 +      /* let the application program generate additional rows ("lazy"
 248.951 +         constraints) */
 248.952 +      xassert(T->reopt == 0);
 248.953 +      xassert(T->reinv == 0);
 248.954 +      if (T->parm->cb_func != NULL)
 248.955 +      {  xassert(T->reason == 0);
 248.956 +         T->reason = GLP_IROWGEN;
 248.957 +         T->parm->cb_func(T, T->parm->cb_info);
 248.958 +         T->reason = 0;
 248.959 +         if (T->stop)
 248.960 +         {  ret = GLP_ESTOP;
 248.961 +            goto done;
 248.962 +         }
 248.963 +         if (T->reopt)
 248.964 +         {  /* some rows were added; re-optimization is needed */
 248.965 +            T->reopt = T->reinv = 0;
 248.966 +            goto more;
 248.967 +         }
 248.968 +         if (T->reinv)
 248.969 +         {  /* no rows were added, however, some inactive rows were
 248.970 +               removed */
 248.971 +            T->reinv = 0;
 248.972 +            xassert(glp_factorize(T->mip) == 0);
 248.973 +         }
 248.974 +      }
 248.975 +      /* check if the basic solution is integer feasible */
 248.976 +      check_integrality(T);
 248.977 +      /* if the basic solution satisfies to all integrality conditions,
 248.978 +         it is a new, better integer feasible solution */
 248.979 +      if (T->curr->ii_cnt == 0)
 248.980 +      {  if (T->parm->msg_lev >= GLP_MSG_DBG)
 248.981 +            xprintf("New integer feasible solution found\n");
 248.982 +         if (T->parm->msg_lev >= GLP_MSG_ALL)
 248.983 +            display_cut_info(T);
 248.984 +         record_solution(T);
 248.985 +         if (T->parm->msg_lev >= GLP_MSG_ON)
 248.986 +            show_progress(T, 1);
 248.987 +         /* make the application program happy */
 248.988 +         if (T->parm->cb_func != NULL)
 248.989 +         {  xassert(T->reason == 0);
 248.990 +            T->reason = GLP_IBINGO;
 248.991 +            T->parm->cb_func(T, T->parm->cb_info);
 248.992 +            T->reason = 0;
 248.993 +            if (T->stop)
 248.994 +            {  ret = GLP_ESTOP;
 248.995 +               goto done;
 248.996 +            }
 248.997 +         }
 248.998 +         /* since the current subproblem has been fathomed, prune its
 248.999 +            branch */
248.1000 +         goto fath;
248.1001 +      }
248.1002 +      /* at this point basic solution to LP relaxation of the current
248.1003 +         subproblem is optimal, but integer infeasible */
248.1004 +      /* try to fix some non-basic structural variables of integer kind
248.1005 +         on their current bounds due to reduced costs */
248.1006 +      if (T->mip->mip_stat == GLP_FEAS)
248.1007 +         fix_by_red_cost(T);
248.1008 +      /* let the application program try to find some solution to the
248.1009 +         original MIP with a primal heuristic */
248.1010 +      if (T->parm->cb_func != NULL)
248.1011 +      {  xassert(T->reason == 0);
248.1012 +         T->reason = GLP_IHEUR;
248.1013 +         T->parm->cb_func(T, T->parm->cb_info);
248.1014 +         T->reason = 0;
248.1015 +         if (T->stop)
248.1016 +         {  ret = GLP_ESTOP;
248.1017 +            goto done;
248.1018 +         }
248.1019 +         /* check if the current branch became hopeless */
248.1020 +         if (!is_branch_hopeful(T, p))
248.1021 +         {  if (T->parm->msg_lev >= GLP_MSG_DBG)
248.1022 +               xprintf("Current branch became hopeless and can be prune"
248.1023 +                  "d\n");
248.1024 +            goto fath;
248.1025 +         }
248.1026 +      }
248.1027 +      /* try to find solution with the feasibility pump heuristic */
248.1028 +      if (T->parm->fp_heur)
248.1029 +      {  xassert(T->reason == 0);
248.1030 +         T->reason = GLP_IHEUR;
248.1031 +         ios_feas_pump(T);
248.1032 +         T->reason = 0;
248.1033 +         /* check if the current branch became hopeless */
248.1034 +         if (!is_branch_hopeful(T, p))
248.1035 +         {  if (T->parm->msg_lev >= GLP_MSG_DBG)
248.1036 +               xprintf("Current branch became hopeless and can be prune"
248.1037 +                  "d\n");
248.1038 +            goto fath;
248.1039 +         }
248.1040 +      }
248.1041 +      /* it's time to generate cutting planes */
248.1042 +      xassert(T->local != NULL);
248.1043 +      xassert(T->local->size == 0);
248.1044 +      /* let the application program generate some cuts; note that it
248.1045 +         can add cuts either to the local cut pool or directly to the
248.1046 +         current subproblem */
248.1047 +      if (T->parm->cb_func != NULL)
248.1048 +      {  xassert(T->reason == 0);
248.1049 +         T->reason = GLP_ICUTGEN;
248.1050 +         T->parm->cb_func(T, T->parm->cb_info);
248.1051 +         T->reason = 0;
248.1052 +         if (T->stop)
248.1053 +         {  ret = GLP_ESTOP;
248.1054 +            goto done;
248.1055 +         }
248.1056 +      }
248.1057 +      /* try to generate generic cuts with built-in generators
248.1058 +         (as suggested by Matteo Fischetti et al. the built-in cuts
248.1059 +         are not generated at each branching node; an intense attempt
248.1060 +         of generating new cuts is only made at the root node, and then
248.1061 +         a moderate effort is spent after each backtracking step) */
248.1062 +      if (T->curr->level == 0 || pred_p == 0)
248.1063 +      {  xassert(T->reason == 0);
248.1064 +         T->reason = GLP_ICUTGEN;
248.1065 +         generate_cuts(T);
248.1066 +         T->reason = 0;
248.1067 +      }
248.1068 +      /* if the local cut pool is not empty, select useful cuts and add
248.1069 +         them to the current subproblem */
248.1070 +      if (T->local->size > 0)
248.1071 +      {  xassert(T->reason == 0);
248.1072 +         T->reason = GLP_ICUTGEN;
248.1073 +         ios_process_cuts(T);
248.1074 +         T->reason = 0;
248.1075 +      }
248.1076 +      /* clear the local cut pool */
248.1077 +      ios_clear_pool(T, T->local);
248.1078 +      /* perform re-optimization, if necessary */
248.1079 +      if (T->reopt)
248.1080 +      {  T->reopt = 0;
248.1081 +         T->curr->changed++;
248.1082 +         goto more;
248.1083 +      }
248.1084 +      /* no cuts were generated; remove inactive cuts */
248.1085 +      remove_cuts(T);
248.1086 +      if (T->parm->msg_lev >= GLP_MSG_ALL && T->curr->level == 0)
248.1087 +         display_cut_info(T);
248.1088 +      /* update history information used on pseudocost branching */
248.1089 +      if (T->pcost != NULL) ios_pcost_update(T);
248.1090 +      /* it's time to perform branching */
248.1091 +      xassert(T->br_var == 0);
248.1092 +      xassert(T->br_sel == 0);
248.1093 +      /* let the application program choose variable to branch on */
248.1094 +      if (T->parm->cb_func != NULL)
248.1095 +      {  xassert(T->reason == 0);
248.1096 +         xassert(T->br_var == 0);
248.1097 +         xassert(T->br_sel == 0);
248.1098 +         T->reason = GLP_IBRANCH;
248.1099 +         T->parm->cb_func(T, T->parm->cb_info);
248.1100 +         T->reason = 0;
248.1101 +         if (T->stop)
248.1102 +         {  ret = GLP_ESTOP;
248.1103 +            goto done;
248.1104 +         }
248.1105 +      }
248.1106 +      /* if nothing has been chosen, choose some variable as specified
248.1107 +         by the branching technique option */
248.1108 +      if (T->br_var == 0)
248.1109 +         T->br_var = ios_choose_var(T, &T->br_sel);
248.1110 +      /* perform actual branching */
248.1111 +      curr_p = T->curr->p;
248.1112 +      ret = branch_on(T, T->br_var, T->br_sel);
248.1113 +      T->br_var = T->br_sel = 0;
248.1114 +      if (ret == 0)
248.1115 +      {  /* both branches have been created */
248.1116 +         pred_p = curr_p;
248.1117 +         goto loop;
248.1118 +      }
248.1119 +      else if (ret == 1)
248.1120 +      {  /* one branch is hopeless and has been pruned, so now the
248.1121 +            current subproblem is other branch */
248.1122 +         /* the current subproblem should be considered as a new one,
248.1123 +            since one bound of the branching variable was changed */
248.1124 +         T->curr->solved = T->curr->changed = 0;
248.1125 +         goto more;
248.1126 +      }
248.1127 +      else if (ret == 2)
248.1128 +      {  /* both branches are hopeless and have been pruned; new
248.1129 +            subproblem selection is needed to continue the search */
248.1130 +         goto fath;
248.1131 +      }
248.1132 +      else
248.1133 +         xassert(ret != ret);
248.1134 +fath: /* the current subproblem has been fathomed */
248.1135 +      if (T->parm->msg_lev >= GLP_MSG_DBG)
248.1136 +         xprintf("Node %d fathomed\n", p);
248.1137 +      /* freeze the current subproblem */
248.1138 +      ios_freeze_node(T);
248.1139 +      /* and prune the corresponding branch of the tree */
248.1140 +      ios_delete_node(T, p);
248.1141 +      /* if a new integer feasible solution has just been found, other
248.1142 +         branches may become hopeless and therefore must be pruned */
248.1143 +      if (T->mip->mip_stat == GLP_FEAS) cleanup_the_tree(T);
248.1144 +      /* new subproblem selection is needed due to backtracking */
248.1145 +      pred_p = 0;
248.1146 +      goto loop;
248.1147 +done: /* display progress of the search on exit from the solver */
248.1148 +      if (T->parm->msg_lev >= GLP_MSG_ON)
248.1149 +         show_progress(T, 0);
248.1150 +      if (T->mir_gen != NULL)
248.1151 +         ios_mir_term(T->mir_gen), T->mir_gen = NULL;
248.1152 +      if (T->clq_gen != NULL)
248.1153 +         ios_clq_term(T->clq_gen), T->clq_gen = NULL;
248.1154 +      /* return to the calling program */
248.1155 +      return ret;
248.1156 +}
248.1157 +
248.1158 +/* eof */
   249.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
   249.2 +++ b/deps/glpk/src/glpios04.c	Sun Nov 06 20:59:10 2011 +0100
   249.3 @@ -0,0 +1,303 @@
   249.4 +/* glpios04.c (operations on sparse vectors) */
   249.5 +
   249.6 +/***********************************************************************
   249.7 +*  This code is part of GLPK (GNU Linear Programming Kit).
   249.8 +*
   249.9 +*  Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008,
  249.10 +*  2009, 2010, 2011 Andrew Makhorin, Department for Applied Informatics,
  249.11 +*  Moscow Aviation Institute, Moscow, Russia. All rights reserved.
  249.12 +*  E-mail: <mao@gnu.org>.
  249.13 +*
  249.14 +*  GLPK is free software: you can redistribute it and/or modify it
  249.15 +*  under the terms of the GNU General Public License as published by
  249.16 +*  the Free Software Foundation, either version 3 of the License, or
  249.17 +*  (at your option) any later version.
  249.18 +*
  249.19 +*  GLPK is distributed in the hope that it will be useful, but WITHOUT
  249.20 +*  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
  249.21 +*  or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
  249.22 +*  License for more details.
  249.23 +*
  249.24 +*  You should have received a copy of the GNU General Public License
  249.25 +*  along with GLPK. If not, see <http://www.gnu.org/licenses/>.
  249.26 +***********************************************************************/
  249.27 +
  249.28 +#include "glpios.h"
  249.29 +
  249.30 +/***********************************************************************
  249.31 +*  NAME
  249.32 +*
  249.33 +*  ios_create_vec - create sparse vector
  249.34 +*
  249.35 +*  SYNOPSIS
  249.36 +*
  249.37 +*  #include "glpios.h"
  249.38 +*  IOSVEC *ios_create_vec(int n);
  249.39 +*
  249.40 +*  DESCRIPTION
  249.41 +*
  249.42 +*  The routine ios_create_vec creates a sparse vector of dimension n,
  249.43 +*  which initially is a null vector.
  249.44 +*
  249.45 +*  RETURNS
  249.46 +*
  249.47 +*  The routine returns a pointer to the vector created. */
  249.48 +
  249.49 +IOSVEC *ios_create_vec(int n)
  249.50 +{     IOSVEC *v;
  249.51 +      xassert(n >= 0);
  249.52 +      v = xmalloc(sizeof(IOSVEC));
  249.53 +      v->n = n;
  249.54 +      v->nnz = 0;
  249.55 +      v->pos = xcalloc(1+n, sizeof(int));
  249.56 +      memset(&v->pos[1], 0, n * sizeof(int));
  249.57 +      v->ind = xcalloc(1+n, sizeof(int));
  249.58 +      v->val = xcalloc(1+n, sizeof(double));
  249.59 +      return v;
  249.60 +}
  249.61 +
  249.62 +/***********************************************************************
  249.63 +*  NAME
  249.64 +*
  249.65 +*  ios_check_vec - check that sparse vector has correct representation
  249.66 +*
  249.67 +*  SYNOPSIS
  249.68 +*
  249.69 +*  #include "glpios.h"
  249.70 +*  void ios_check_vec(IOSVEC *v);
  249.71 +*
  249.72 +*  DESCRIPTION
  249.73 +*
  249.74 +*  The routine ios_check_vec checks that a sparse vector specified by
  249.75 +*  the parameter v has correct representation.
  249.76 +*
  249.77 +*  NOTE
  249.78 +*
  249.79 +*  Complexity of this operation is O(n). */
  249.80 +
  249.81 +void ios_check_vec(IOSVEC *v)
  249.82 +{     int j, k, nnz;
  249.83 +      xassert(v->n >= 0);
  249.84 +      nnz = 0;
  249.85 +      for (j = v->n; j >= 1; j--)
  249.86 +      {  k = v->pos[j];
  249.87 +         xassert(0 <= k && k <= v->nnz);
  249.88 +         if (k != 0)
  249.89 +         {  xassert(v->ind[k] == j);
  249.90 +            nnz++;
  249.91 +         }
  249.92 +      }
  249.93 +      xassert(v->nnz == nnz);
  249.94 +      return;
  249.95 +}
  249.96 +
  249.97 +/***********************************************************************
  249.98 +*  NAME
  249.99 +*
 249.100 +*  ios_get_vj - retrieve component of sparse vector
 249.101 +*
 249.102 +*  SYNOPSIS
 249.103 +*
 249.104 +*  #include "glpios.h"
 249.105 +*  double ios_get_vj(IOSVEC *v, int j);
 249.106 +*
 249.107 +*  RETURNS
 249.108 +*
 249.109 +*  The routine ios_get_vj returns j-th component of a sparse vector
 249.110 +*  specified by the parameter v. */
 249.111 +
 249.112 +double ios_get_vj(IOSVEC *v, int j)
 249.113 +{     int k;
 249.114 +      xassert(1 <= j && j <= v->n);
 249.115 +      k = v->pos[j];
 249.116 +      xassert(0 <= k && k <= v->nnz);
 249.117 +      return (k == 0 ? 0.0 : v->val[k]);
 249.118 +}
 249.119 +
 249.120 +/***********************************************************************
 249.121 +*  NAME
 249.122 +*
 249.123 +*  ios_set_vj - set/change component of sparse vector
 249.124 +*
 249.125 +*  SYNOPSIS
 249.126 +*
 249.127 +*  #include "glpios.h"
 249.128 +*  void ios_set_vj(IOSVEC *v, int j, double val);
 249.129 +*
 249.130 +*  DESCRIPTION
 249.131 +*
 249.132 +*  The routine ios_set_vj assigns val to j-th component of a sparse
 249.133 +*  vector specified by the parameter v. */
 249.134 +
 249.135 +void ios_set_vj(IOSVEC *v, int j, double val)
 249.136 +{     int k;
 249.137 +      xassert(1 <= j && j <= v->n);
 249.138 +      k = v->pos[j];
 249.139 +      if (val == 0.0)
 249.140 +      {  if (k != 0)
 249.141 +         {  /* remove j-th component */
 249.142 +            v->pos[j] = 0;
 249.143 +            if (k < v->nnz)
 249.144 +            {  v->pos[v->ind[v->nnz]] = k;
 249.145 +               v->ind[k] = v->ind[v->nnz];
 249.146 +               v->val[k] = v->val[v->nnz];
 249.147 +            }
 249.148 +            v->nnz--;
 249.149 +         }
 249.150 +      }
 249.151 +      else
 249.152 +      {  if (k == 0)
 249.153 +         {  /* create j-th component */
 249.154 +            k = ++(v->nnz);
 249.155 +            v->pos[j] = k;
 249.156 +            v->ind[k] = j;
 249.157 +         }
 249.158 +         v->val[k] = val;
 249.159 +      }
 249.160 +      return;
 249.161 +}
 249.162 +
 249.163 +/***********************************************************************
 249.164 +*  NAME
 249.165 +*
 249.166 +*  ios_clear_vec - set all components of sparse vector to zero
 249.167 +*
 249.168 +*  SYNOPSIS
 249.169 +*
 249.170 +*  #include "glpios.h"
 249.171 +*  void ios_clear_vec(IOSVEC *v);
 249.172 +*
 249.173 +*  DESCRIPTION
 249.174 +*
 249.175 +*  The routine ios_clear_vec sets all components of a sparse vector
 249.176 +*  specified by the parameter v to zero. */
 249.177 +
 249.178 +void ios_clear_vec(IOSVEC *v)
 249.179 +{     int k;
 249.180 +      for (k = 1; k <= v->nnz; k++)
 249.181 +         v->pos[v->ind[k]] = 0;
 249.182 +      v->nnz = 0;
 249.183 +      return;
 249.184 +}
 249.185 +
 249.186 +/***********************************************************************
 249.187 +*  NAME
 249.188 +*
 249.189 +*  ios_clean_vec - remove zero or small components from sparse vector
 249.190 +*
 249.191 +*  SYNOPSIS
 249.192 +*
 249.193 +*  #include "glpios.h"
 249.194 +*  void ios_clean_vec(IOSVEC *v, double eps);
 249.195 +*
 249.196 +*  DESCRIPTION
 249.197 +*
 249.198 +*  The routine ios_clean_vec removes zero components and components
 249.199 +*  whose magnitude is less than eps from a sparse vector specified by
 249.200 +*  the parameter v. If eps is 0.0, only zero components are removed. */
 249.201 +
 249.202 +void ios_clean_vec(IOSVEC *v, double eps)
 249.203 +{     int k, nnz;
 249.204 +      nnz = 0;
 249.205 +      for (k = 1; k <= v->nnz; k++)
 249.206 +      {  if (fabs(v->val[k]) == 0.0 || fabs(v->val[k]) < eps)
 249.207 +         {  /* remove component */
 249.208 +            v->pos[v->ind[k]] = 0;
 249.209 +         }
 249.210 +         else
 249.211 +         {  /* keep component */
 249.212 +            nnz++;
 249.213 +            v->pos[v->ind[k]] = nnz;
 249.214 +            v->ind[nnz] = v->ind[k];
 249.215 +            v->val[nnz] = v->val[k];
 249.216 +         }
 249.217 +      }
 249.218 +      v->nnz = nnz;
 249.219 +      return;
 249.220 +}
 249.221 +
 249.222 +/***********************************************************************
 249.223 +*  NAME
 249.224 +*
 249.225 +*  ios_copy_vec - copy sparse vector (x := y)
 249.226 +*
 249.227 +*  SYNOPSIS
 249.228 +*
 249.229 +*  #include "glpios.h"
 249.230 +*  void ios_copy_vec(IOSVEC *x, IOSVEC *y);
 249.231 +*
 249.232 +*  DESCRIPTION
 249.233 +*
 249.234 +*  The routine ios_copy_vec copies a sparse vector specified by the
 249.235 +*  parameter y to a sparse vector specified by the parameter x. */
 249.236 +
 249.237 +void ios_copy_vec(IOSVEC *x, IOSVEC *y)
 249.238 +{     int j;
 249.239 +      xassert(x != y);
 249.240 +      xassert(x->n == y->n);
 249.241 +      ios_clear_vec(x);
 249.242 +      x->nnz = y->nnz;
 249.243 +      memcpy(&x->ind[1], &y->ind[1], x->nnz * sizeof(int));
 249.244 +      memcpy(&x->val[1], &y->val[1], x->nnz * sizeof(double));
 249.245 +      for (j = 1; j <= x->nnz; j++)
 249.246 +         x->pos[x->ind[j]] = j;
 249.247 +      return;
 249.248 +}
 249.249 +
 249.250 +/***********************************************************************
 249.251 +*  NAME
 249.252 +*
 249.253 +*  ios_linear_comb - compute linear combination (x := x + a * y)
 249.254 +*
 249.255 +*  SYNOPSIS
 249.256 +*
 249.257 +*  #include "glpios.h"
 249.258 +*  void ios_linear_comb(IOSVEC *x, double a, IOSVEC *y);
 249.259 +*
 249.260 +*  DESCRIPTION
 249.261 +*
 249.262 +*  The routine ios_linear_comb computes the linear combination
 249.263 +*
 249.264 +*     x := x + a * y,
 249.265 +*
 249.266 +*  where x and y are sparse vectors, a is a scalar. */
 249.267 +
 249.268 +void ios_linear_comb(IOSVEC *x, double a, IOSVEC *y)
 249.269 +{     int j, k;
 249.270 +      double xj, yj;
 249.271 +      xassert(x != y);
 249.272 +      xassert(x->n == y->n);
 249.273 +      for (k = 1; k <= y->nnz; k++)
 249.274 +      {  j = y->ind[k];
 249.275 +         xj = ios_get_vj(x, j);
 249.276 +         yj = y->val[k];
 249.277 +         ios_set_vj(x, j, xj + a * yj);
 249.278 +      }
 249.279 +      return;
 249.280 +}
 249.281 +
 249.282 +/***********************************************************************
 249.283 +*  NAME
 249.284 +*
 249.285 +*  ios_delete_vec - delete sparse vector
 249.286 +*
 249.287 +*  SYNOPSIS
 249.288 +*
 249.289 +*  #include "glpios.h"
 249.290 +*  void ios_delete_vec(IOSVEC *v);
 249.291 +*
 249.292 +*  DESCRIPTION
 249.293 +*
 249.294 +*  The routine ios_delete_vec deletes a sparse vector specified by the
 249.295 +*  parameter v freeing all the memory allocated to this object. */
 249.296 +
 249.297 +void ios_delete_vec(IOSVEC *v)
 249.298 +{     /* delete sparse vector */
 249.299 +      xfree(v->pos);
 249.300 +      xfree(v->ind);
 249.301 +      xfree(v->val);
 249.302 +      xfree(v);
 249.303 +      return;
 249.304 +}
 249.305 +
 249.306 +/* eof */
   250.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
   250.2 +++ b/deps/glpk/src/glpios05.c	Sun Nov 06 20:59:10 2011 +0100
   250.3 @@ -0,0 +1,281 @@
   250.4 +/* glpios05.c (Gomory's mixed integer cut generator) */
   250.5 +
   250.6 +/***********************************************************************
   250.7 +*  This code is part of GLPK (GNU Linear Programming Kit).
   250.8 +*
   250.9 +*  Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008,
  250.10 +*  2009, 2010, 2011 Andrew Makhorin, Department for Applied Informatics,
  250.11 +*  Moscow Aviation Institute, Moscow, Russia. All rights reserved.
  250.12 +*  E-mail: <mao@gnu.org>.
  250.13 +*
  250.14 +*  GLPK is free software: you can redistribute it and/or modify it
  250.15 +*  under the terms of the GNU General Public License as published by
  250.16 +*  the Free Software Foundation, either version 3 of the License, or
  250.17 +*  (at your option) any later version.
  250.18 +*
  250.19 +*  GLPK is distributed in the hope that it will be useful, but WITHOUT
  250.20 +*  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
  250.21 +*  or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
  250.22 +*  License for more details.
  250.23 +*
  250.24 +*  You should have received a copy of the GNU General Public License
  250.25 +*  along with GLPK. If not, see <http://www.gnu.org/licenses/>.
  250.26 +***********************************************************************/
  250.27 +
  250.28 +#include "glpios.h"
  250.29 +
  250.30 +/***********************************************************************
  250.31 +*  NAME
  250.32 +*
  250.33 +*  ios_gmi_gen - generate Gomory's mixed integer cuts.
  250.34 +*
  250.35 +*  SYNOPSIS
  250.36 +*
  250.37 +*  #include "glpios.h"
  250.38 +*  void ios_gmi_gen(glp_tree *tree, IOSPOOL *pool);
  250.39 +*
  250.40 +*  DESCRIPTION
  250.41 +*
  250.42 +*  The routine ios_gmi_gen generates Gomory's mixed integer cuts for
  250.43 +*  the current point and adds them to the cut pool. */
  250.44 +
  250.45 +#define MAXCUTS 50
  250.46 +/* maximal number of cuts to be generated for one round */
  250.47 +
  250.48 +struct worka
  250.49 +{     /* Gomory's cut generator working area */
  250.50 +      int *ind; /* int ind[1+n]; */
  250.51 +      double *val; /* double val[1+n]; */
  250.52 +      double *phi; /* double phi[1+m+n]; */
  250.53 +};
  250.54 +
  250.55 +#define f(x) ((x) - floor(x))
  250.56 +/* compute fractional part of x */
  250.57 +
  250.58 +static void gen_cut(glp_tree *tree, struct worka *worka, int j)
  250.59 +{     /* this routine tries to generate Gomory's mixed integer cut for
  250.60 +         specified structural variable x[m+j] of integer kind, which is
  250.61 +         basic and has fractional value in optimal solution to current
  250.62 +         LP relaxation */
  250.63 +      glp_prob *mip = tree->mip;
  250.64 +      int m = mip->m;
  250.65 +      int n = mip->n;
  250.66 +      int *ind = worka->ind;
  250.67 +      double *val = worka->val;
  250.68 +      double *phi = worka->phi;
  250.69 +      int i, k, len, kind, stat;
  250.70 +      double lb, ub, alfa, beta, ksi, phi1, rhs;
  250.71 +      /* compute row of the simplex tableau, which (row) corresponds
  250.72 +         to specified basic variable xB[i] = x[m+j]; see (23) */
  250.73 +      len = glp_eval_tab_row(mip, m+j, ind, val);
  250.74 +      /* determine beta[i], which a value of xB[i] in optimal solution
  250.75 +         to current LP relaxation; note that this value is the same as
  250.76 +         if it would be computed with formula (27); it is assumed that
  250.77 +         beta[i] is fractional enough */
  250.78 +      beta = mip->col[j]->prim;
  250.79 +      /* compute cut coefficients phi and right-hand side rho, which
  250.80 +         correspond to formula (30); dense format is used, because rows
  250.81 +         of the simplex tableau is usually dense */
  250.82 +      for (k = 1; k <= m+n; k++) phi[k] = 0.0;
  250.83 +      rhs = f(beta); /* initial value of rho; see (28), (32) */
  250.84 +      for (j = 1; j <= len; j++)
  250.85 +      {  /* determine original number of non-basic variable xN[j] */
  250.86 +         k = ind[j];
  250.87 +         xassert(1 <= k && k <= m+n);
  250.88 +         /* determine the kind, bounds and current status of xN[j] in
  250.89 +            optimal solution to LP relaxation */
  250.90 +         if (k <= m)
  250.91 +         {  /* auxiliary variable */
  250.92 +            GLPROW *row = mip->row[k];
  250.93 +            kind = GLP_CV;
  250.94 +            lb = row->lb;
  250.95 +            ub = row->ub;
  250.96 +            stat = row->stat;
  250.97 +         }
  250.98 +         else
  250.99 +         {  /* structural variable */
 250.100 +            GLPCOL *col = mip->col[k-m];
 250.101 +            kind = col->kind;
 250.102 +            lb = col->lb;
 250.103 +            ub = col->ub;
 250.104 +            stat = col->stat;
 250.105 +         }
 250.106 +         /* xN[j] cannot be basic */
 250.107 +         xassert(stat != GLP_BS);
 250.108 +         /* determine row coefficient ksi[i,j] at xN[j]; see (23) */
 250.109 +         ksi = val[j];
 250.110 +         /* if ksi[i,j] is too large in the magnitude, do not generate
 250.111 +            the cut */
 250.112 +         if (fabs(ksi) > 1e+05) goto fini;
 250.113 +         /* if ksi[i,j] is too small in the magnitude, skip it */
 250.114 +         if (fabs(ksi) < 1e-10) goto skip;
 250.115 +         /* compute row coefficient alfa[i,j] at y[j]; see (26) */
 250.116 +         switch (stat)
 250.117 +         {  case GLP_NF:
 250.118 +               /* xN[j] is free (unbounded) having non-zero ksi[i,j];
 250.119 +                  do not generate the cut */
 250.120 +               goto fini;
 250.121 +            case GLP_NL:
 250.122 +               /* xN[j] has active lower bound */
 250.123 +               alfa = - ksi;
 250.124 +               break;
 250.125 +            case GLP_NU:
 250.126 +               /* xN[j] has active upper bound */
 250.127 +               alfa = + ksi;
 250.128 +               break;
 250.129 +            case GLP_NS:
 250.130 +               /* xN[j] is fixed; skip it */
 250.131 +               goto skip;
 250.132 +            default:
 250.133 +               xassert(stat != stat);
 250.134 +         }
 250.135 +         /* compute cut coefficient phi'[j] at y[j]; see (21), (28) */
 250.136 +         switch (kind)
 250.137 +         {  case GLP_IV:
 250.138 +               /* y[j] is integer */
 250.139 +               if (fabs(alfa - floor(alfa + 0.5)) < 1e-10)
 250.140 +               {  /* alfa[i,j] is close to nearest integer; skip it */
 250.141 +                  goto skip;
 250.142 +               }
 250.143 +               else if (f(alfa) <= f(beta))
 250.144 +                  phi1 = f(alfa);
 250.145 +               else
 250.146 +                  phi1 = (f(beta) / (1.0 - f(beta))) * (1.0 - f(alfa));
 250.147 +               break;
 250.148 +            case GLP_CV:
 250.149 +               /* y[j] is continuous */
 250.150 +               if (alfa >= 0.0)
 250.151 +                  phi1 = + alfa;
 250.152 +               else
 250.153 +                  phi1 = (f(beta) / (1.0 - f(beta))) * (- alfa);
 250.154 +               break;
 250.155 +            default:
 250.156 +               xassert(kind != kind);
 250.157 +         }
 250.158 +         /* compute cut coefficient phi[j] at xN[j] and update right-
 250.159 +            hand side rho; see (31), (32) */
 250.160 +         switch (stat)
 250.161 +         {  case GLP_NL:
 250.162 +               /* xN[j] has active lower bound */
 250.163 +               phi[k] = + phi1;
 250.164 +               rhs += phi1 * lb;
 250.165 +               break;
 250.166 +            case GLP_NU:
 250.167 +               /* xN[j] has active upper bound */
 250.168 +               phi[k] = - phi1;
 250.169 +               rhs -= phi1 * ub;
 250.170 +               break;
 250.171 +            default:
 250.172 +               xassert(stat != stat);
 250.173 +         }
 250.174 +skip:    ;
 250.175 +      }
 250.176 +      /* now the cut has the form sum_k phi[k] * x[k] >= rho, where cut
 250.177 +         coefficients are stored in the array phi in dense format;
 250.178 +         x[1,...,m] are auxiliary variables, x[m+1,...,m+n] are struc-
 250.179 +         tural variables; see (30) */
 250.180 +      /* eliminate auxiliary variables in order to express the cut only
 250.181 +         through structural variables; see (33) */
 250.182 +      for (i = 1; i <= m; i++)
 250.183 +      {  GLPROW *row;
 250.184 +         GLPAIJ *aij;
 250.185 +         if (fabs(phi[i]) < 1e-10) continue;
 250.186 +         /* auxiliary variable x[i] has non-zero cut coefficient */
 250.187 +         row = mip->row[i];
 250.188 +         /* x[i] cannot be fixed */
 250.189 +         xassert(row->type != GLP_FX);
 250.190 +         /* substitute x[i] = sum_j a[i,j] * x[m+j] */
 250.191 +         for (aij = row->ptr; aij != NULL; aij = aij->r_next)
 250.192 +            phi[m+aij->col->j] += phi[i] * aij->val;
 250.193 +      }
 250.194 +      /* convert the final cut to sparse format and substitute fixed
 250.195 +         (structural) variables */
 250.196 +      len = 0;
 250.197 +      for (j = 1; j <= n; j++)
 250.198 +      {  GLPCOL *col;
 250.199 +         if (fabs(phi[m+j]) < 1e-10) continue;
 250.200 +         /* structural variable x[m+j] has non-zero cut coefficient */
 250.201 +         col = mip->col[j];
 250.202 +         if (col->type == GLP_FX)
 250.203 +         {  /* eliminate x[m+j] */
 250.204 +            rhs -= phi[m+j] * col->lb;
 250.205 +         }
 250.206 +         else
 250.207 +         {  len++;
 250.208 +            ind[len] = j;
 250.209 +            val[len] = phi[m+j];
 250.210 +         }
 250.211 +      }
 250.212 +      if (fabs(rhs) < 1e-12) rhs = 0.0;
 250.213 +      /* if the cut inequality seems to be badly scaled, reject it to
 250.214 +         avoid numeric difficulties */
 250.215 +      for (k = 1; k <= len; k++)
 250.216 +      {  if (fabs(val[k]) < 1e-03) goto fini;
 250.217 +         if (fabs(val[k]) > 1e+03) goto fini;
 250.218 +      }
 250.219 +      /* add the cut to the cut pool for further consideration */
 250.220 +#if 0
 250.221 +      ios_add_cut_row(tree, pool, GLP_RF_GMI, len, ind, val, GLP_LO,
 250.222 +         rhs);
 250.223 +#else
 250.224 +      glp_ios_add_row(tree, NULL, GLP_RF_GMI, 0, len, ind, val, GLP_LO,
 250.225 +         rhs);
 250.226 +#endif
 250.227 +fini: return;
 250.228 +}
 250.229 +
 250.230 +struct var { int j; double f; };
 250.231 +
 250.232 +static int fcmp(const void *p1, const void *p2)
 250.233 +{     const struct var *v1 = p1, *v2 = p2;
 250.234 +      if (v1->f > v2->f) return -1;
 250.235 +      if (v1->f < v2->f) return +1;
 250.236 +      return 0;
 250.237 +}
 250.238 +
 250.239 +void ios_gmi_gen(glp_tree *tree)
 250.240 +{     /* main routine to generate Gomory's cuts */
 250.241 +      glp_prob *mip = tree->mip;
 250.242 +      int m = mip->m;
 250.243 +      int n = mip->n;
 250.244 +      struct var *var;
 250.245 +      int k, nv, j, size;
 250.246 +      struct worka _worka, *worka = &_worka;
 250.247 +      /* allocate working arrays */
 250.248 +      var = xcalloc(1+n, sizeof(struct var));
 250.249 +      worka->ind = xcalloc(1+n, sizeof(int));
 250.250 +      worka->val = xcalloc(1+n, sizeof(double));
 250.251 +      worka->phi = xcalloc(1+m+n, sizeof(double));
 250.252 +      /* build the list of integer structural variables, which are
 250.253 +         basic and have fractional value in optimal solution to current
 250.254 +         LP relaxation */
 250.255 +      nv = 0;
 250.256 +      for (j = 1; j <= n; j++)
 250.257 +      {  GLPCOL *col = mip->col[j];
 250.258 +         double frac;
 250.259 +         if (col->kind != GLP_IV) continue;
 250.260 +         if (col->type == GLP_FX) continue;
 250.261 +         if (col->stat != GLP_BS) continue;
 250.262 +         frac = f(col->prim);
 250.263 +         if (!(0.05 <= frac && frac <= 0.95)) continue;
 250.264 +         /* add variable to the list */
 250.265 +         nv++, var[nv].j = j, var[nv].f = frac;
 250.266 +      }
 250.267 +      /* order the list by descending fractionality */
 250.268 +      qsort(&var[1], nv, sizeof(struct var), fcmp);
 250.269 +      /* try to generate cuts by one for each variable in the list, but
 250.270 +         not more than MAXCUTS cuts */
 250.271 +      size = glp_ios_pool_size(tree);
 250.272 +      for (k = 1; k <= nv; k++)
 250.273 +      {  if (glp_ios_pool_size(tree) - size >= MAXCUTS) break;
 250.274 +         gen_cut(tree, worka, var[k].j);
 250.275 +      }
 250.276 +      /* free working arrays */
 250.277 +      xfree(var);
 250.278 +      xfree(worka->ind);
 250.279 +      xfree(worka->val);
 250.280 +      xfree(worka->phi);
 250.281 +      return;
 250.282 +}
 250.283 +
 250.284 +/* eof */
   251.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
   251.2 +++ b/deps/glpk/src/glpios06.c	Sun Nov 06 20:59:10 2011 +0100
   251.3 @@ -0,0 +1,1447 @@
   251.4 +/* glpios06.c (MIR cut generator) */
   251.5 +
   251.6 +/***********************************************************************
   251.7 +*  This code is part of GLPK (GNU Linear Programming Kit).
   251.8 +*
   251.9 +*  Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008,
  251.10 +*  2009, 2010, 2011 Andrew Makhorin, Department for Applied Informatics,
  251.11 +*  Moscow Aviation Institute, Moscow, Russia. All rights reserved.
  251.12 +*  E-mail: <mao@gnu.org>.
  251.13 +*
  251.14 +*  GLPK is free software: you can redistribute it and/or modify it
  251.15 +*  under the terms of the GNU General Public License as published by
  251.16 +*  the Free Software Foundation, either version 3 of the License, or
  251.17 +*  (at your option) any later version.
  251.18 +*
  251.19 +*  GLPK is distributed in the hope that it will be useful, but WITHOUT
  251.20 +*  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
  251.21 +*  or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
  251.22 +*  License for more details.
  251.23 +*
  251.24 +*  You should have received a copy of the GNU General Public License
  251.25 +*  along with GLPK. If not, see <http://www.gnu.org/licenses/>.
  251.26 +***********************************************************************/
  251.27 +
  251.28 +#include "glpios.h"
  251.29 +
  251.30 +#define _MIR_DEBUG 0
  251.31 +
  251.32 +#define MAXAGGR 5
  251.33 +/* maximal number of rows which can be aggregated */
  251.34 +
  251.35 +struct MIR
  251.36 +{     /* MIR cut generator working area */
  251.37 +      /*--------------------------------------------------------------*/
  251.38 +      /* global information valid for the root subproblem */
  251.39 +      int m;
  251.40 +      /* number of rows (in the root subproblem) */
  251.41 +      int n;
  251.42 +      /* number of columns */
  251.43 +      char *skip; /* char skip[1+m]; */
  251.44 +      /* skip[i], 1 <= i <= m, is a flag that means that row i should
  251.45 +         not be used because (1) it is not suitable, or (2) because it
  251.46 +         has been used in the aggregated constraint */
  251.47 +      char *isint; /* char isint[1+m+n]; */
  251.48 +      /* isint[k], 1 <= k <= m+n, is a flag that means that variable
  251.49 +         x[k] is integer (otherwise, continuous) */
  251.50 +      double *lb; /* double lb[1+m+n]; */
  251.51 +      /* lb[k], 1 <= k <= m+n, is lower bound of x[k]; -DBL_MAX means
  251.52 +         that x[k] has no lower bound */
  251.53 +      int *vlb; /* int vlb[1+m+n]; */
  251.54 +      /* vlb[k] = k', 1 <= k <= m+n, is the number of integer variable,
  251.55 +         which defines variable lower bound x[k] >= lb[k] * x[k']; zero
  251.56 +         means that x[k] has simple lower bound */
  251.57 +      double *ub; /* double ub[1+m+n]; */
  251.58 +      /* ub[k], 1 <= k <= m+n, is upper bound of x[k]; +DBL_MAX means
  251.59 +         that x[k] has no upper bound */
  251.60 +      int *vub; /* int vub[1+m+n]; */
  251.61 +      /* vub[k] = k', 1 <= k <= m+n, is the number of integer variable,
  251.62 +         which defines variable upper bound x[k] <= ub[k] * x[k']; zero
  251.63 +         means that x[k] has simple upper bound */
  251.64 +      /*--------------------------------------------------------------*/
  251.65 +      /* current (fractional) point to be separated */
  251.66 +      double *x; /* double x[1+m+n]; */
  251.67 +      /* x[k] is current value of auxiliary (1 <= k <= m) or structural
  251.68 +         (m+1 <= k <= m+n) variable */
  251.69 +      /*--------------------------------------------------------------*/
  251.70 +      /* aggregated constraint sum a[k] * x[k] = b, which is a linear
  251.71 +         combination of original constraints transformed to equalities
  251.72 +         by introducing auxiliary variables */
  251.73 +      int agg_cnt;
  251.74 +      /* number of rows (original constraints) used to build aggregated
  251.75 +         constraint, 1 <= agg_cnt <= MAXAGGR */
  251.76 +      int *agg_row; /* int agg_row[1+MAXAGGR]; */
  251.77 +      /* agg_row[k], 1 <= k <= agg_cnt, is the row number used to build
  251.78 +         aggregated constraint */
  251.79 +      IOSVEC *agg_vec; /* IOSVEC agg_vec[1:m+n]; */
  251.80 +      /* sparse vector of aggregated constraint coefficients, a[k] */
  251.81 +      double agg_rhs;
  251.82 +      /* right-hand side of the aggregated constraint, b */
  251.83 +      /*--------------------------------------------------------------*/
  251.84 +      /* bound substitution flags for modified constraint */
  251.85 +      char *subst; /* char subst[1+m+n]; */
  251.86 +      /* subst[k], 1 <= k <= m+n, is a bound substitution flag used for
  251.87 +         variable x[k]:
  251.88 +         '?' - x[k] is missing in modified constraint
  251.89 +         'L' - x[k] = (lower bound) + x'[k]
  251.90 +         'U' - x[k] = (upper bound) - x'[k] */
  251.91 +      /*--------------------------------------------------------------*/
  251.92 +      /* modified constraint sum a'[k] * x'[k] = b', where x'[k] >= 0,
  251.93 +         derived from aggregated constraint by substituting bounds;
  251.94 +         note that due to substitution of variable bounds there may be
  251.95 +         additional terms in the modified constraint */
  251.96 +      IOSVEC *mod_vec; /* IOSVEC mod_vec[1:m+n]; */
  251.97 +      /* sparse vector of modified constraint coefficients, a'[k] */
  251.98 +      double mod_rhs;
  251.99 +      /* right-hand side of the modified constraint, b' */
 251.100 +      /*--------------------------------------------------------------*/
 251.101 +      /* cutting plane sum alpha[k] * x[k] <= beta */
 251.102 +      IOSVEC *cut_vec; /* IOSVEC cut_vec[1:m+n]; */
 251.103 +      /* sparse vector of cutting plane coefficients, alpha[k] */
 251.104 +      double cut_rhs;
 251.105 +      /* right-hand size of the cutting plane, beta */
 251.106 +};
 251.107 +
 251.108 +/***********************************************************************
 251.109 +*  NAME
 251.110 +*
 251.111 +*  ios_mir_init - initialize MIR cut generator
 251.112 +*
 251.113 +*  SYNOPSIS
 251.114 +*
 251.115 +*  #include "glpios.h"
 251.116 +*  void *ios_mir_init(glp_tree *tree);
 251.117 +*
 251.118 +*  DESCRIPTION
 251.119 +*
 251.120 +*  The routine ios_mir_init initializes the MIR cut generator assuming
 251.121 +*  that the current subproblem is the root subproblem.
 251.122 +*
 251.123 +*  RETURNS
 251.124 +*
 251.125 +*  The routine ios_mir_init returns a pointer to the MIR cut generator
 251.126 +*  working area. */
 251.127 +
 251.128 +static void set_row_attrib(glp_tree *tree, struct MIR *mir)
 251.129 +{     /* set global row attributes */
 251.130 +      glp_prob *mip = tree->mip;
 251.131 +      int m = mir->m;
 251.132 +      int k;
 251.133 +      for (k = 1; k <= m; k++)
 251.134 +      {  GLPROW *row = mip->row[k];
 251.135 +         mir->skip[k] = 0;
 251.136 +         mir->isint[k] = 0;
 251.137 +         switch (row->type)
 251.138 +         {  case GLP_FR:
 251.139 +               mir->lb[k] = -DBL_MAX, mir->ub[k] = +DBL_MAX; break;
 251.140 +            case GLP_LO:
 251.141 +               mir->lb[k] = row->lb, mir->ub[k] = +DBL_MAX; break;
 251.142 +            case GLP_UP:
 251.143 +               mir->lb[k] = -DBL_MAX, mir->ub[k] = row->ub; break;
 251.144 +            case GLP_DB:
 251.145 +               mir->lb[k] = row->lb, mir->ub[k] = row->ub; break;
 251.146 +            case GLP_FX:
 251.147 +               mir->lb[k] = mir->ub[k] = row->lb; break;
 251.148 +            default:
 251.149 +               xassert(row != row);
 251.150 +         }
 251.151 +         mir->vlb[k] = mir->vub[k] = 0;
 251.152 +      }
 251.153 +      return;
 251.154 +}
 251.155 +
 251.156 +static void set_col_attrib(glp_tree *tree, struct MIR *mir)
 251.157 +{     /* set global column attributes */
 251.158 +      glp_prob *mip = tree->mip;
 251.159 +      int m = mir->m;
 251.160 +      int n = mir->n;
 251.161 +      int k;
 251.162 +      for (k = m+1; k <= m+n; k++)
 251.163 +      {  GLPCOL *col = mip->col[k-m];
 251.164 +         switch (col->kind)
 251.165 +         {  case GLP_CV:
 251.166 +               mir->isint[k] = 0; break;
 251.167 +            case GLP_IV:
 251.168 +               mir->isint[k] = 1; break;
 251.169 +            default:
 251.170 +               xassert(col != col);
 251.171 +         }
 251.172 +         switch (col->type)
 251.173 +         {  case GLP_FR:
 251.174 +               mir->lb[k] = -DBL_MAX, mir->ub[k] = +DBL_MAX; break;
 251.175 +            case GLP_LO:
 251.176 +               mir->lb[k] = col->lb, mir->ub[k] = +DBL_MAX; break;
 251.177 +            case GLP_UP:
 251.178 +               mir->lb[k] = -DBL_MAX, mir->ub[k] = col->ub; break;
 251.179 +            case GLP_DB:
 251.180 +               mir->lb[k] = col->lb, mir->ub[k] = col->ub; break;
 251.181 +            case GLP_FX:
 251.182 +               mir->lb[k] = mir->ub[k] = col->lb; break;
 251.183 +            default:
 251.184 +               xassert(col != col);
 251.185 +         }
 251.186 +         mir->vlb[k] = mir->vub[k] = 0;
 251.187 +      }
 251.188 +      return;
 251.189 +}
 251.190 +
 251.191 +static void set_var_bounds(glp_tree *tree, struct MIR *mir)
 251.192 +{     /* set variable bounds */
 251.193 +      glp_prob *mip = tree->mip;
 251.194 +      int m = mir->m;
 251.195 +      GLPAIJ *aij;
 251.196 +      int i, k1, k2;
 251.197 +      double a1, a2;
 251.198 +      for (i = 1; i <= m; i++)
 251.199 +      {  /* we need the row to be '>= 0' or '<= 0' */
 251.200 +         if (!(mir->lb[i] == 0.0 && mir->ub[i] == +DBL_MAX ||
 251.201 +               mir->lb[i] == -DBL_MAX && mir->ub[i] == 0.0)) continue;
 251.202 +         /* take first term */
 251.203 +         aij = mip->row[i]->ptr;
 251.204 +         if (aij == NULL) continue;
 251.205 +         k1 = m + aij->col->j, a1 = aij->val;
 251.206 +         /* take second term */
 251.207 +         aij = aij->r_next;
 251.208 +         if (aij == NULL) continue;
 251.209 +         k2 = m + aij->col->j, a2 = aij->val;
 251.210 +         /* there must be only two terms */
 251.211 +         if (aij->r_next != NULL) continue;
 251.212 +         /* interchange terms, if needed */
 251.213 +         if (!mir->isint[k1] && mir->isint[k2])
 251.214 +            ;
 251.215 +         else if (mir->isint[k1] && !mir->isint[k2])
 251.216 +         {  k2 = k1, a2 = a1;
 251.217 +            k1 = m + aij->col->j, a1 = aij->val;
 251.218 +         }
 251.219 +         else
 251.220 +         {  /* both terms are either continuous or integer */
 251.221 +            continue;
 251.222 +         }
 251.223 +         /* x[k2] should be double-bounded */
 251.224 +         if (mir->lb[k2] == -DBL_MAX || mir->ub[k2] == +DBL_MAX ||
 251.225 +             mir->lb[k2] == mir->ub[k2]) continue;
 251.226 +         /* change signs, if necessary */
 251.227 +         if (mir->ub[i] == 0.0) a1 = - a1, a2 = - a2;
 251.228 +         /* now the row has the form a1 * x1 + a2 * x2 >= 0, where x1
 251.229 +            is continuous, x2 is integer */
 251.230 +         if (a1 > 0.0)
 251.231 +         {  /* x1 >= - (a2 / a1) * x2 */
 251.232 +            if (mir->vlb[k1] == 0)
 251.233 +            {  /* set variable lower bound for x1 */
 251.234 +               mir->lb[k1] = - a2 / a1;
 251.235 +               mir->vlb[k1] = k2;
 251.236 +               /* the row should not be used */
 251.237 +               mir->skip[i] = 1;
 251.238 +            }
 251.239 +         }
 251.240 +         else /* a1 < 0.0 */
 251.241 +         {  /* x1 <= - (a2 / a1) * x2 */
 251.242 +            if (mir->vub[k1] == 0)
 251.243 +            {  /* set variable upper bound for x1 */
 251.244 +               mir->ub[k1] = - a2 / a1;
 251.245 +               mir->vub[k1] = k2;
 251.246 +               /* the row should not be used */
 251.247 +               mir->skip[i] = 1;
 251.248 +            }
 251.249 +         }
 251.250 +      }
 251.251 +      return;
 251.252 +}
 251.253 +
 251.254 +static void mark_useless_rows(glp_tree *tree, struct MIR *mir)
 251.255 +{     /* mark rows which should not be used */
 251.256 +      glp_prob *mip = tree->mip;
 251.257 +      int m = mir->m;
 251.258 +      GLPAIJ *aij;
 251.259 +      int i, k, nv;
 251.260 +      for (i = 1; i <= m; i++)
 251.261 +      {  /* free rows should not be used */
 251.262 +         if (mir->lb[i] == -DBL_MAX && mir->ub[i] == +DBL_MAX)
 251.263 +         {  mir->skip[i] = 1;
 251.264 +            continue;
 251.265 +         }
 251.266 +         nv = 0;
 251.267 +         for (aij = mip->row[i]->ptr; aij != NULL; aij = aij->r_next)
 251.268 +         {  k = m + aij->col->j;
 251.269 +            /* rows with free variables should not be used */
 251.270 +            if (mir->lb[k] == -DBL_MAX && mir->ub[k] == +DBL_MAX)
 251.271 +            {  mir->skip[i] = 1;
 251.272 +               break;
 251.273 +            }
 251.274 +            /* rows with integer variables having infinite (lower or
 251.275 +               upper) bound should not be used */
 251.276 +            if (mir->isint[k] && mir->lb[k] == -DBL_MAX ||
 251.277 +                mir->isint[k] && mir->ub[k] == +DBL_MAX)
 251.278 +            {  mir->skip[i] = 1;
 251.279 +               break;
 251.280 +            }
 251.281 +            /* count non-fixed variables */
 251.282 +            if (!(mir->vlb[k] == 0 && mir->vub[k] == 0 &&
 251.283 +                  mir->lb[k] == mir->ub[k])) nv++;
 251.284 +         }
 251.285 +         /* rows with all variables fixed should not be used */
 251.286 +         if (nv == 0)
 251.287 +         {  mir->skip[i] = 1;
 251.288 +            continue;
 251.289 +         }
 251.290 +      }
 251.291 +      return;
 251.292 +}
 251.293 +
 251.294 +void *ios_mir_init(glp_tree *tree)
 251.295 +{     /* initialize MIR cut generator */
 251.296 +      glp_prob *mip = tree->mip;
 251.297 +      int m = mip->m;
 251.298 +      int n = mip->n;
 251.299 +      struct MIR *mir;
 251.300 +#if _MIR_DEBUG
 251.301 +      xprintf("ios_mir_init: warning: debug mode enabled\n");
 251.302 +#endif
 251.303 +      /* allocate working area */
 251.304 +      mir = xmalloc(sizeof(struct MIR));
 251.305 +      mir->m = m;
 251.306 +      mir->n = n;
 251.307 +      mir->skip = xcalloc(1+m, sizeof(char));
 251.308 +      mir->isint = xcalloc(1+m+n, sizeof(char));
 251.309 +      mir->lb = xcalloc(1+m+n, sizeof(double));
 251.310 +      mir->vlb = xcalloc(1+m+n, sizeof(int));
 251.311 +      mir->ub = xcalloc(1+m+n, sizeof(double));
 251.312 +      mir->vub = xcalloc(1+m+n, sizeof(int));
 251.313 +      mir->x = xcalloc(1+m+n, sizeof(double));
 251.314 +      mir->agg_row = xcalloc(1+MAXAGGR, sizeof(int));
 251.315 +      mir->agg_vec = ios_create_vec(m+n);
 251.316 +      mir->subst = xcalloc(1+m+n, sizeof(char));
 251.317 +      mir->mod_vec = ios_create_vec(m+n);
 251.318 +      mir->cut_vec = ios_create_vec(m+n);
 251.319 +      /* set global row attributes */
 251.320 +      set_row_attrib(tree, mir);
 251.321 +      /* set global column attributes */
 251.322 +      set_col_attrib(tree, mir);
 251.323 +      /* set variable bounds */
 251.324 +      set_var_bounds(tree, mir);
 251.325 +      /* mark rows which should not be used */
 251.326 +      mark_useless_rows(tree, mir);
 251.327 +      return mir;
 251.328 +}
 251.329 +
 251.330 +/***********************************************************************
 251.331 +*  NAME
 251.332 +*
 251.333 +*  ios_mir_gen - generate MIR cuts
 251.334 +*
 251.335 +*  SYNOPSIS
 251.336 +*
 251.337 +*  #include "glpios.h"
 251.338 +*  void ios_mir_gen(glp_tree *tree, void *gen, IOSPOOL *pool);
 251.339 +*
 251.340 +*  DESCRIPTION
 251.341 +*
 251.342 +*  The routine ios_mir_gen generates MIR cuts for the current point and
 251.343 +*  adds them to the cut pool. */
 251.344 +
 251.345 +static void get_current_point(glp_tree *tree, struct MIR *mir)
 251.346 +{     /* obtain current point */
 251.347 +      glp_prob *mip = tree->mip;
 251.348 +      int m = mir->m;
 251.349 +      int n = mir->n;
 251.350 +      int k;
 251.351 +      for (k = 1; k <= m; k++)
 251.352 +         mir->x[k] = mip->row[k]->prim;
 251.353 +      for (k = m+1; k <= m+n; k++)
 251.354 +         mir->x[k] = mip->col[k-m]->prim;
 251.355 +      return;
 251.356 +}
 251.357 +
 251.358 +#if _MIR_DEBUG
 251.359 +static void check_current_point(struct MIR *mir)
 251.360 +{     /* check current point */
 251.361 +      int m = mir->m;
 251.362 +      int n = mir->n;
 251.363 +      int k, kk;
 251.364 +      double lb, ub, eps;
 251.365 +      for (k = 1; k <= m+n; k++)
 251.366 +      {  /* determine lower bound */
 251.367 +         lb = mir->lb[k];
 251.368 +         kk = mir->vlb[k];
 251.369 +         if (kk != 0)
 251.370 +         {  xassert(lb != -DBL_MAX);
 251.371 +            xassert(!mir->isint[k]);
 251.372 +            xassert(mir->isint[kk]);
 251.373 +            lb *= mir->x[kk];
 251.374 +         }
 251.375 +         /* check lower bound */
 251.376 +         if (lb != -DBL_MAX)
 251.377 +         {  eps = 1e-6 * (1.0 + fabs(lb));
 251.378 +            xassert(mir->x[k] >= lb - eps);
 251.379 +         }
 251.380 +         /* determine upper bound */
 251.381 +         ub = mir->ub[k];
 251.382 +         kk = mir->vub[k];
 251.383 +         if (kk != 0)
 251.384 +         {  xassert(ub != +DBL_MAX);
 251.385 +            xassert(!mir->isint[k]);
 251.386 +            xassert(mir->isint[kk]);
 251.387 +            ub *= mir->x[kk];
 251.388 +         }
 251.389 +         /* check upper bound */
 251.390 +         if (ub != +DBL_MAX)
 251.391 +         {  eps = 1e-6 * (1.0 + fabs(ub));
 251.392 +            xassert(mir->x[k] <= ub + eps);
 251.393 +         }
 251.394 +      }
 251.395 +      return;
 251.396 +}
 251.397 +#endif
 251.398 +
 251.399 +static void initial_agg_row(glp_tree *tree, struct MIR *mir, int i)
 251.400 +{     /* use original i-th row as initial aggregated constraint */
 251.401 +      glp_prob *mip = tree->mip;
 251.402 +      int m = mir->m;
 251.403 +      GLPAIJ *aij;
 251.404 +      xassert(1 <= i && i <= m);
 251.405 +      xassert(!mir->skip[i]);
 251.406 +      /* mark i-th row in order not to use it in the same aggregated
 251.407 +         constraint */
 251.408 +      mir->skip[i] = 2;
 251.409 +      mir->agg_cnt = 1;
 251.410 +      mir->agg_row[1] = i;
 251.411 +      /* use x[i] - sum a[i,j] * x[m+j] = 0, where x[i] is auxiliary
 251.412 +         variable of row i, x[m+j] are structural variables */
 251.413 +      ios_clear_vec(mir->agg_vec);
 251.414 +      ios_set_vj(mir->agg_vec, i, 1.0);
 251.415 +      for (aij = mip->row[i]->ptr; aij != NULL; aij = aij->r_next)
 251.416 +         ios_set_vj(mir->agg_vec, m + aij->col->j, - aij->val);
 251.417 +      mir->agg_rhs = 0.0;
 251.418 +#if _MIR_DEBUG
 251.419 +      ios_check_vec(mir->agg_vec);
 251.420 +#endif
 251.421 +      return;
 251.422 +}
 251.423 +
 251.424 +#if _MIR_DEBUG
 251.425 +static void check_agg_row(struct MIR *mir)
 251.426 +{     /* check aggregated constraint */
 251.427 +      int m = mir->m;
 251.428 +      int n = mir->n;
 251.429 +      int j, k;
 251.430 +      double r, big;
 251.431 +      /* compute the residual r = sum a[k] * x[k] - b and determine
 251.432 +         big = max(1, |a[k]|, |b|) */
 251.433 +      r = 0.0, big = 1.0;
 251.434 +      for (j = 1; j <= mir->agg_vec->nnz; j++)
 251.435 +      {  k = mir->agg_vec->ind[j];
 251.436 +         xassert(1 <= k && k <= m+n);
 251.437 +         r += mir->agg_vec->val[j] * mir->x[k];
 251.438 +         if (big < fabs(mir->agg_vec->val[j]))
 251.439 +            big = fabs(mir->agg_vec->val[j]);
 251.440 +      }
 251.441 +      r -= mir->agg_rhs;
 251.442 +      if (big < fabs(mir->agg_rhs))
 251.443 +         big = fabs(mir->agg_rhs);
 251.444 +      /* the residual must be close to zero */
 251.445 +      xassert(fabs(r) <= 1e-6 * big);
 251.446 +      return;
 251.447 +}
 251.448 +#endif
 251.449 +
 251.450 +static void subst_fixed_vars(struct MIR *mir)
 251.451 +{     /* substitute fixed variables into aggregated constraint */
 251.452 +      int m = mir->m;
 251.453 +      int n = mir->n;
 251.454 +      int j, k;
 251.455 +      for (j = 1; j <= mir->agg_vec->nnz; j++)
 251.456 +      {  k = mir->agg_vec->ind[j];
 251.457 +         xassert(1 <= k && k <= m+n);
 251.458 +         if (mir->vlb[k] == 0 && mir->vub[k] == 0 &&
 251.459 +             mir->lb[k] == mir->ub[k])
 251.460 +         {  /* x[k] is fixed */
 251.461 +            mir->agg_rhs -= mir->agg_vec->val[j] * mir->lb[k];
 251.462 +            mir->agg_vec->val[j] = 0.0;
 251.463 +         }
 251.464 +      }
 251.465 +      /* remove terms corresponding to fixed variables */
 251.466 +      ios_clean_vec(mir->agg_vec, DBL_EPSILON);
 251.467 +#if _MIR_DEBUG
 251.468 +      ios_check_vec(mir->agg_vec);
 251.469 +#endif
 251.470 +      return;
 251.471 +}
 251.472 +
 251.473 +static void bound_subst_heur(struct MIR *mir)
 251.474 +{     /* bound substitution heuristic */
 251.475 +      int m = mir->m;
 251.476 +      int n = mir->n;
 251.477 +      int j, k, kk;
 251.478 +      double d1, d2;
 251.479 +      for (j = 1; j <= mir->agg_vec->nnz; j++)
 251.480 +      {  k = mir->agg_vec->ind[j];
 251.481 +         xassert(1 <= k && k <= m+n);
 251.482 +         if (mir->isint[k]) continue; /* skip integer variable */
 251.483 +         /* compute distance from x[k] to its lower bound */
 251.484 +         kk = mir->vlb[k];
 251.485 +         if (kk == 0)
 251.486 +         {  if (mir->lb[k] == -DBL_MAX)
 251.487 +               d1 = DBL_MAX;
 251.488 +            else
 251.489 +               d1 = mir->x[k] - mir->lb[k];
 251.490 +         }
 251.491 +         else
 251.492 +         {  xassert(1 <= kk && kk <= m+n);
 251.493 +            xassert(mir->isint[kk]);
 251.494 +            xassert(mir->lb[k] != -DBL_MAX);
 251.495 +            d1 = mir->x[k] - mir->lb[k] * mir->x[kk];
 251.496 +         }
 251.497 +         /* compute distance from x[k] to its upper bound */
 251.498 +         kk = mir->vub[k];
 251.499 +         if (kk == 0)
 251.500 +         {  if (mir->vub[k] == +DBL_MAX)
 251.501 +               d2 = DBL_MAX;
 251.502 +            else
 251.503 +               d2 = mir->ub[k] - mir->x[k];
 251.504 +         }
 251.505 +         else
 251.506 +         {  xassert(1 <= kk && kk <= m+n);
 251.507 +            xassert(mir->isint[kk]);
 251.508 +            xassert(mir->ub[k] != +DBL_MAX);
 251.509 +            d2 = mir->ub[k] * mir->x[kk] - mir->x[k];
 251.510 +         }
 251.511 +         /* x[k] cannot be free */
 251.512 +         xassert(d1 != DBL_MAX || d2 != DBL_MAX);
 251.513 +         /* choose the bound which is closer to x[k] */
 251.514 +         xassert(mir->subst[k] == '?');
 251.515 +         if (d1 <= d2)
 251.516 +            mir->subst[k] = 'L';
 251.517 +         else
 251.518 +            mir->subst[k] = 'U';
 251.519 +      }
 251.520 +      return;
 251.521 +}
 251.522 +
 251.523 +static void build_mod_row(struct MIR *mir)
 251.524 +{     /* substitute bounds and build modified constraint */
 251.525 +      int m = mir->m;
 251.526 +      int n = mir->n;
 251.527 +      int j, jj, k, kk;
 251.528 +      /* initially modified constraint is aggregated constraint */
 251.529 +      ios_copy_vec(mir->mod_vec, mir->agg_vec);
 251.530 +      mir->mod_rhs = mir->agg_rhs;
 251.531 +#if _MIR_DEBUG
 251.532 +      ios_check_vec(mir->mod_vec);
 251.533 +#endif
 251.534 +      /* substitute bounds for continuous variables; note that due to
 251.535 +         substitution of variable bounds additional terms may appear in
 251.536 +         modified constraint */
 251.537 +      for (j = mir->mod_vec->nnz; j >= 1; j--)
 251.538 +      {  k = mir->mod_vec->ind[j];
 251.539 +         xassert(1 <= k && k <= m+n);
 251.540 +         if (mir->isint[k]) continue; /* skip integer variable */
 251.541 +         if (mir->subst[k] == 'L')
 251.542 +         {  /* x[k] = (lower bound) + x'[k] */
 251.543 +            xassert(mir->lb[k] != -DBL_MAX);
 251.544 +            kk = mir->vlb[k];
 251.545 +            if (kk == 0)
 251.546 +            {  /* x[k] = lb[k] + x'[k] */
 251.547 +               mir->mod_rhs -= mir->mod_vec->val[j] * mir->lb[k];
 251.548 +            }
 251.549 +            else
 251.550 +            {  /* x[k] = lb[k] * x[kk] + x'[k] */
 251.551 +               xassert(mir->isint[kk]);
 251.552 +               jj = mir->mod_vec->pos[kk];
 251.553 +               if (jj == 0)
 251.554 +               {  ios_set_vj(mir->mod_vec, kk, 1.0);
 251.555 +                  jj = mir->mod_vec->pos[kk];
 251.556 +                  mir->mod_vec->val[jj] = 0.0;
 251.557 +               }
 251.558 +               mir->mod_vec->val[jj] +=
 251.559 +                  mir->mod_vec->val[j] * mir->lb[k];
 251.560 +            }
 251.561 +         }
 251.562 +         else if (mir->subst[k] == 'U')
 251.563 +         {  /* x[k] = (upper bound) - x'[k] */
 251.564 +            xassert(mir->ub[k] != +DBL_MAX);
 251.565 +            kk = mir->vub[k];
 251.566 +            if (kk == 0)
 251.567 +            {  /* x[k] = ub[k] - x'[k] */
 251.568 +               mir->mod_rhs -= mir->mod_vec->val[j] * mir->ub[k];
 251.569 +            }
 251.570 +            else
 251.571 +            {  /* x[k] = ub[k] * x[kk] - x'[k] */
 251.572 +               xassert(mir->isint[kk]);
 251.573 +               jj = mir->mod_vec->pos[kk];
 251.574 +               if (jj == 0)
 251.575 +               {  ios_set_vj(mir->mod_vec, kk, 1.0);
 251.576 +                  jj = mir->mod_vec->pos[kk];
 251.577 +                  mir->mod_vec->val[jj] = 0.0;
 251.578 +               }
 251.579 +               mir->mod_vec->val[jj] +=
 251.580 +                  mir->mod_vec->val[j] * mir->ub[k];
 251.581 +            }
 251.582 +            mir->mod_vec->val[j] = - mir->mod_vec->val[j];
 251.583 +         }
 251.584 +         else
 251.585 +            xassert(k != k);
 251.586 +      }
 251.587 +#if _MIR_DEBUG
 251.588 +      ios_check_vec(mir->mod_vec);
 251.589 +#endif
 251.590 +      /* substitute bounds for integer variables */
 251.591 +      for (j = 1; j <= mir->mod_vec->nnz; j++)
 251.592 +      {  k = mir->mod_vec->ind[j];
 251.593 +         xassert(1 <= k && k <= m+n);
 251.594 +         if (!mir->isint[k]) continue; /* skip continuous variable */
 251.595 +         xassert(mir->subst[k] == '?');
 251.596 +         xassert(mir->vlb[k] == 0 && mir->vub[k] == 0);
 251.597 +         xassert(mir->lb[k] != -DBL_MAX && mir->ub[k] != +DBL_MAX);
 251.598 +         if (fabs(mir->lb[k]) <= fabs(mir->ub[k]))
 251.599 +         {  /* x[k] = lb[k] + x'[k] */
 251.600 +            mir->subst[k] = 'L';
 251.601 +            mir->mod_rhs -= mir->mod_vec->val[j] * mir->lb[k];
 251.602 +         }
 251.603 +         else
 251.604 +         {  /* x[k] = ub[k] - x'[k] */
 251.605 +            mir->subst[k] = 'U';
 251.606 +            mir->mod_rhs -= mir->mod_vec->val[j] * mir->ub[k];
 251.607 +            mir->mod_vec->val[j] = - mir->mod_vec->val[j];
 251.608 +         }
 251.609 +      }
 251.610 +#if _MIR_DEBUG
 251.611 +      ios_check_vec(mir->mod_vec);
 251.612 +#endif
 251.613 +      return;
 251.614 +}
 251.615 +
 251.616 +#if _MIR_DEBUG
 251.617 +static void check_mod_row(struct MIR *mir)
 251.618 +{     /* check modified constraint */
 251.619 +      int m = mir->m;
 251.620 +      int n = mir->n;
 251.621 +      int j, k, kk;
 251.622 +      double r, big, x;
 251.623 +      /* compute the residual r = sum a'[k] * x'[k] - b' and determine
 251.624 +         big = max(1, |a[k]|, |b|) */
 251.625 +      r = 0.0, big = 1.0;
 251.626 +      for (j = 1; j <= mir->mod_vec->nnz; j++)
 251.627 +      {  k = mir->mod_vec->ind[j];
 251.628 +         xassert(1 <= k && k <= m+n);
 251.629 +         if (mir->subst[k] == 'L')
 251.630 +         {  /* x'[k] = x[k] - (lower bound) */
 251.631 +            xassert(mir->lb[k] != -DBL_MAX);
 251.632 +            kk = mir->vlb[k];
 251.633 +            if (kk == 0)
 251.634 +               x = mir->x[k] - mir->lb[k];
 251.635 +            else
 251.636 +               x = mir->x[k] - mir->lb[k] * mir->x[kk];
 251.637 +         }
 251.638 +         else if (mir->subst[k] == 'U')
 251.639 +         {  /* x'[k] = (upper bound) - x[k] */
 251.640 +            xassert(mir->ub[k] != +DBL_MAX);
 251.641 +            kk = mir->vub[k];
 251.642 +            if (kk == 0)
 251.643 +               x = mir->ub[k] - mir->x[k];
 251.644 +            else
 251.645 +               x = mir->ub[k] * mir->x[kk] - mir->x[k];
 251.646 +         }
 251.647 +         else
 251.648 +            xassert(k != k);
 251.649 +         r += mir->mod_vec->val[j] * x;
 251.650 +         if (big < fabs(mir->mod_vec->val[j]))
 251.651 +            big = fabs(mir->mod_vec->val[j]);
 251.652 +      }
 251.653 +      r -= mir->mod_rhs;
 251.654 +      if (big < fabs(mir->mod_rhs))
 251.655 +         big = fabs(mir->mod_rhs);
 251.656 +      /* the residual must be close to zero */
 251.657 +      xassert(fabs(r) <= 1e-6 * big);
 251.658 +      return;
 251.659 +}
 251.660 +#endif
 251.661 +
 251.662 +/***********************************************************************
 251.663 +*  mir_ineq - construct MIR inequality
 251.664 +*
 251.665 +*  Given the single constraint mixed integer set
 251.666 +*
 251.667 +*                    |N|
 251.668 +*     X = {(x,s) in Z    x R  : sum   a[j] * x[j] <= b + s},
 251.669 +*                    +      +  j in N
 251.670 +*
 251.671 +*  this routine constructs the mixed integer rounding (MIR) inequality
 251.672 +*
 251.673 +*     sum   alpha[j] * x[j] <= beta + gamma * s,
 251.674 +*    j in N
 251.675 +*
 251.676 +*  which is valid for X.
 251.677 +*
 251.678 +*  If the MIR inequality has been successfully constructed, the routine
 251.679 +*  returns zero. Otherwise, if b is close to nearest integer, there may
 251.680 +*  be numeric difficulties due to big coefficients; so in this case the
 251.681 +*  routine returns non-zero. */
 251.682 +
 251.683 +static int mir_ineq(const int n, const double a[], const double b,
 251.684 +      double alpha[], double *beta, double *gamma)
 251.685 +{     int j;
 251.686 +      double f, t;
 251.687 +      if (fabs(b - floor(b + .5)) < 0.01)
 251.688 +         return 1;
 251.689 +      f = b - floor(b);
 251.690 +      for (j = 1; j <= n; j++)
 251.691 +      {  t = (a[j] - floor(a[j])) - f;
 251.692 +         if (t <= 0.0)
 251.693 +            alpha[j] = floor(a[j]);
 251.694 +         else
 251.695 +            alpha[j] = floor(a[j]) + t / (1.0 - f);
 251.696 +      }
 251.697 +      *beta = floor(b);
 251.698 +      *gamma = 1.0 / (1.0 - f);
 251.699 +      return 0;
 251.700 +}
 251.701 +
 251.702 +/***********************************************************************
 251.703 +*  cmir_ineq - construct c-MIR inequality
 251.704 +*
 251.705 +*  Given the mixed knapsack set
 251.706 +*
 251.707 +*      MK              |N|
 251.708 +*     X   = {(x,s) in Z    x R  : sum   a[j] * x[j] <= b + s,
 251.709 +*                      +      +  j in N
 251.710 +*
 251.711 +*             x[j] <= u[j]},
 251.712 +*
 251.713 +*  a subset C of variables to be complemented, and a divisor delta > 0,
 251.714 +*  this routine constructs the complemented MIR (c-MIR) inequality
 251.715 +*
 251.716 +*     sum   alpha[j] * x[j] <= beta + gamma * s,
 251.717 +*    j in N
 251.718 +*                      MK
 251.719 +*  which is valid for X  .
 251.720 +*
 251.721 +*  If the c-MIR inequality has been successfully constructed, the
 251.722 +*  routine returns zero. Otherwise, if there is a risk of numerical
 251.723 +*  difficulties due to big coefficients (see comments to the routine
 251.724 +*  mir_ineq), the routine cmir_ineq returns non-zero. */
 251.725 +
 251.726 +static int cmir_ineq(const int n, const double a[], const double b,
 251.727 +      const double u[], const char cset[], const double delta,
 251.728 +      double alpha[], double *beta, double *gamma)
 251.729 +{     int j;
 251.730 +      double *aa, bb;
 251.731 +      aa = alpha, bb = b;
 251.732 +      for (j = 1; j <= n; j++)
 251.733 +      {  aa[j] = a[j] / delta;
 251.734 +         if (cset[j])
 251.735 +            aa[j] = - aa[j], bb -= a[j] * u[j];
 251.736 +      }
 251.737 +      bb /= delta;
 251.738 +      if (mir_ineq(n, aa, bb, alpha, beta, gamma)) return 1;
 251.739 +      for (j = 1; j <= n; j++)
 251.740 +      {  if (cset[j])
 251.741 +            alpha[j] = - alpha[j], *beta += alpha[j] * u[j];
 251.742 +      }
 251.743 +      *gamma /= delta;
 251.744 +      return 0;
 251.745 +}
 251.746 +
 251.747 +/***********************************************************************
 251.748 +*  cmir_sep - c-MIR separation heuristic
 251.749 +*
 251.750 +*  Given the mixed knapsack set
 251.751 +*
 251.752 +*      MK              |N|
 251.753 +*     X   = {(x,s) in Z    x R  : sum   a[j] * x[j] <= b + s,
 251.754 +*                      +      +  j in N
 251.755 +*
 251.756 +*             x[j] <= u[j]}
 251.757 +*
 251.758 +*                           *   *
 251.759 +*  and a fractional point (x , s ), this routine tries to construct
 251.760 +*  c-MIR inequality
 251.761 +*
 251.762 +*     sum   alpha[j] * x[j] <= beta + gamma * s,
 251.763 +*    j in N
 251.764 +*                      MK
 251.765 +*  which is valid for X   and has (desirably maximal) violation at the
 251.766 +*  fractional point given. This is attained by choosing an appropriate
 251.767 +*  set C of variables to be complemented and a divisor delta > 0, which
 251.768 +*  together define corresponding c-MIR inequality.
 251.769 +*
 251.770 +*  If a violated c-MIR inequality has been successfully constructed,
 251.771 +*  the routine returns its violation:
 251.772 +*
 251.773 +*                       *                      *
 251.774 +*     sum   alpha[j] * x [j] - beta - gamma * s ,
 251.775 +*    j in N
 251.776 +*
 251.777 +*  which is positive. In case of failure the routine returns zero. */
 251.778 +
 251.779 +struct vset { int j; double v; };
 251.780 +
 251.781 +static int cmir_cmp(const void *p1, const void *p2)
 251.782 +{     const struct vset *v1 = p1, *v2 = p2;
 251.783 +      if (v1->v < v2->v) return -1;
 251.784 +      if (v1->v > v2->v) return +1;
 251.785 +      return 0;
 251.786 +}
 251.787 +
 251.788 +static double cmir_sep(const int n, const double a[], const double b,
 251.789 +      const double u[], const double x[], const double s,
 251.790 +      double alpha[], double *beta, double *gamma)
 251.791 +{     int fail, j, k, nv, v;
 251.792 +      double delta, eps, d_try[1+3], r, r_best;
 251.793 +      char *cset;
 251.794 +      struct vset *vset;
 251.795 +      /* allocate working arrays */
 251.796 +      cset = xcalloc(1+n, sizeof(char));
 251.797 +      vset = xcalloc(1+n, sizeof(struct vset));
 251.798 +      /* choose initial C */
 251.799 +      for (j = 1; j <= n; j++)
 251.800 +         cset[j] = (char)(x[j] >= 0.5 * u[j]);
 251.801 +      /* choose initial delta */
 251.802 +      r_best = delta = 0.0;
 251.803 +      for (j = 1; j <= n; j++)
 251.804 +      {  xassert(a[j] != 0.0);
 251.805 +         /* if x[j] is close to its bounds, skip it */
 251.806 +         eps = 1e-9 * (1.0 + fabs(u[j]));
 251.807 +         if (x[j] < eps || x[j] > u[j] - eps) continue;
 251.808 +         /* try delta = |a[j]| to construct c-MIR inequality */
 251.809 +         fail = cmir_ineq(n, a, b, u, cset, fabs(a[j]), alpha, beta,
 251.810 +            gamma);
 251.811 +         if (fail) continue;
 251.812 +         /* compute violation */
 251.813 +         r = - (*beta) - (*gamma) * s;
 251.814 +         for (k = 1; k <= n; k++) r += alpha[k] * x[k];
 251.815 +         if (r_best < r) r_best = r, delta = fabs(a[j]);
 251.816 +      }
 251.817 +      if (r_best < 0.001) r_best = 0.0;
 251.818 +      if (r_best == 0.0) goto done;
 251.819 +      xassert(delta > 0.0);
 251.820 +      /* try to increase violation by dividing delta by 2, 4, and 8,
 251.821 +         respectively */
 251.822 +      d_try[1] = delta / 2.0;
 251.823 +      d_try[2] = delta / 4.0;
 251.824 +      d_try[3] = delta / 8.0;
 251.825 +      for (j = 1; j <= 3; j++)
 251.826 +      {  /* construct c-MIR inequality */
 251.827 +         fail = cmir_ineq(n, a, b, u, cset, d_try[j], alpha, beta,
 251.828 +            gamma);
 251.829 +         if (fail) continue;
 251.830 +         /* compute violation */
 251.831 +         r = - (*beta) - (*gamma) * s;
 251.832 +         for (k = 1; k <= n; k++) r += alpha[k] * x[k];
 251.833 +         if (r_best < r) r_best = r, delta = d_try[j];
 251.834 +      }
 251.835 +      /* build subset of variables lying strictly between their bounds
 251.836 +         and order it by nondecreasing values of |x[j] - u[j]/2| */
 251.837 +      nv = 0;
 251.838 +      for (j = 1; j <= n; j++)
 251.839 +      {  /* if x[j] is close to its bounds, skip it */
 251.840 +         eps = 1e-9 * (1.0 + fabs(u[j]));
 251.841 +         if (x[j] < eps || x[j] > u[j] - eps) continue;
 251.842 +         /* add x[j] to the subset */
 251.843 +         nv++;
 251.844 +         vset[nv].j = j;
 251.845 +         vset[nv].v = fabs(x[j] - 0.5 * u[j]);
 251.846 +      }
 251.847 +      qsort(&vset[1], nv, sizeof(struct vset), cmir_cmp);
 251.848 +      /* try to increase violation by successively complementing each
 251.849 +         variable in the subset */
 251.850 +      for (v = 1; v <= nv; v++)
 251.851 +      {  j = vset[v].j;
 251.852 +         /* replace x[j] by its complement or vice versa */
 251.853 +         cset[j] = (char)!cset[j];
 251.854 +         /* construct c-MIR inequality */
 251.855 +         fail = cmir_ineq(n, a, b, u, cset, delta, alpha, beta, gamma);
 251.856 +         /* restore the variable */
 251.857 +         cset[j] = (char)!cset[j];
 251.858 +         /* do not replace the variable in case of failure */
 251.859 +         if (fail) continue;
 251.860 +         /* compute violation */
 251.861 +         r = - (*beta) - (*gamma) * s;
 251.862 +         for (k = 1; k <= n; k++) r += alpha[k] * x[k];
 251.863 +         if (r_best < r) r_best = r, cset[j] = (char)!cset[j];
 251.864 +      }
 251.865 +      /* construct the best c-MIR inequality chosen */
 251.866 +      fail = cmir_ineq(n, a, b, u, cset, delta, alpha, beta, gamma);
 251.867 +      xassert(!fail);
 251.868 +done: /* free working arrays */
 251.869 +      xfree(cset);
 251.870 +      xfree(vset);
 251.871 +      /* return to the calling routine */
 251.872 +      return r_best;
 251.873 +}
 251.874 +
 251.875 +static double generate(struct MIR *mir)
 251.876 +{     /* try to generate violated c-MIR cut for modified constraint */
 251.877 +      int m = mir->m;
 251.878 +      int n = mir->n;
 251.879 +      int j, k, kk, nint;
 251.880 +      double s, *u, *x, *alpha, r_best = 0.0, b, beta, gamma;
 251.881 +      ios_copy_vec(mir->cut_vec, mir->mod_vec);
 251.882 +      mir->cut_rhs = mir->mod_rhs;
 251.883 +      /* remove small terms, which can appear due to substitution of
 251.884 +         variable bounds */
 251.885 +      ios_clean_vec(mir->cut_vec, DBL_EPSILON);
 251.886 +#if _MIR_DEBUG
 251.887 +      ios_check_vec(mir->cut_vec);
 251.888 +#endif
 251.889 +      /* remove positive continuous terms to obtain MK relaxation */
 251.890 +      for (j = 1; j <= mir->cut_vec->nnz; j++)
 251.891 +      {  k = mir->cut_vec->ind[j];
 251.892 +         xassert(1 <= k && k <= m+n);
 251.893 +         if (!mir->isint[k] && mir->cut_vec->val[j] > 0.0)
 251.894 +            mir->cut_vec->val[j] = 0.0;
 251.895 +      }
 251.896 +      ios_clean_vec(mir->cut_vec, 0.0);
 251.897 +#if _MIR_DEBUG
 251.898 +      ios_check_vec(mir->cut_vec);
 251.899 +#endif
 251.900 +      /* move integer terms to the beginning of the sparse vector and
 251.901 +         determine the number of integer variables */
 251.902 +      nint = 0;
 251.903 +      for (j = 1; j <= mir->cut_vec->nnz; j++)
 251.904 +      {  k = mir->cut_vec->ind[j];
 251.905 +         xassert(1 <= k && k <= m+n);
 251.906 +         if (mir->isint[k])
 251.907 +         {  double temp;
 251.908 +            nint++;
 251.909 +            /* interchange elements [nint] and [j] */
 251.910 +            kk = mir->cut_vec->ind[nint];
 251.911 +            mir->cut_vec->pos[k] = nint;
 251.912 +            mir->cut_vec->pos[kk] = j;
 251.913 +            mir->cut_vec->ind[nint] = k;
 251.914 +            mir->cut_vec->ind[j] = kk;
 251.915 +            temp = mir->cut_vec->val[nint];
 251.916 +            mir->cut_vec->val[nint] = mir->cut_vec->val[j];
 251.917 +            mir->cut_vec->val[j] = temp;
 251.918 +         }
 251.919 +      }
 251.920 +#if _MIR_DEBUG
 251.921 +      ios_check_vec(mir->cut_vec);
 251.922 +#endif
 251.923 +      /* if there is no integer variable, nothing to generate */
 251.924 +      if (nint == 0) goto done;
 251.925 +      /* allocate working arrays */
 251.926 +      u = xcalloc(1+nint, sizeof(double));
 251.927 +      x = xcalloc(1+nint, sizeof(double));
 251.928 +      alpha = xcalloc(1+nint, sizeof(double));
 251.929 +      /* determine u and x */
 251.930 +      for (j = 1; j <= nint; j++)
 251.931 +      {  k = mir->cut_vec->ind[j];
 251.932 +         xassert(m+1 <= k && k <= m+n);
 251.933 +         xassert(mir->isint[k]);
 251.934 +         u[j] = mir->ub[k] - mir->lb[k];
 251.935 +         xassert(u[j] >= 1.0);
 251.936 +         if (mir->subst[k] == 'L')
 251.937 +            x[j] = mir->x[k] - mir->lb[k];
 251.938 +         else if (mir->subst[k] == 'U')
 251.939 +            x[j] = mir->ub[k] - mir->x[k];
 251.940 +         else
 251.941 +            xassert(k != k);
 251.942 +         xassert(x[j] >= -0.001);
 251.943 +         if (x[j] < 0.0) x[j] = 0.0;
 251.944 +      }
 251.945 +      /* compute s = - sum of continuous terms */
 251.946 +      s = 0.0;
 251.947 +      for (j = nint+1; j <= mir->cut_vec->nnz; j++)
 251.948 +      {  double x;
 251.949 +         k = mir->cut_vec->ind[j];
 251.950 +         xassert(1 <= k && k <= m+n);
 251.951 +         /* must be continuous */
 251.952 +         xassert(!mir->isint[k]);
 251.953 +         if (mir->subst[k] == 'L')
 251.954 +         {  xassert(mir->lb[k] != -DBL_MAX);
 251.955 +            kk = mir->vlb[k];
 251.956 +            if (kk == 0)
 251.957 +               x = mir->x[k] - mir->lb[k];
 251.958 +            else
 251.959 +               x = mir->x[k] - mir->lb[k] * mir->x[kk];
 251.960 +         }
 251.961 +         else if (mir->subst[k] == 'U')
 251.962 +         {  xassert(mir->ub[k] != +DBL_MAX);
 251.963 +            kk = mir->vub[k];
 251.964 +            if (kk == 0)
 251.965 +               x = mir->ub[k] - mir->x[k];
 251.966 +            else
 251.967 +               x = mir->ub[k] * mir->x[kk] - mir->x[k];
 251.968 +         }
 251.969 +         else
 251.970 +            xassert(k != k);
 251.971 +         xassert(x >= -0.001);
 251.972 +         if (x < 0.0) x = 0.0;
 251.973 +         s -= mir->cut_vec->val[j] * x;
 251.974 +      }
 251.975 +      xassert(s >= 0.0);
 251.976 +      /* apply heuristic to obtain most violated c-MIR inequality */
 251.977 +      b = mir->cut_rhs;
 251.978 +      r_best = cmir_sep(nint, mir->cut_vec->val, b, u, x, s, alpha,
 251.979 +         &beta, &gamma);
 251.980 +      if (r_best == 0.0) goto skip;
 251.981 +      xassert(r_best > 0.0);
 251.982 +      /* convert to raw cut */
 251.983 +      /* sum alpha[j] * x[j] <= beta + gamma * s */
 251.984 +      for (j = 1; j <= nint; j++)
 251.985 +         mir->cut_vec->val[j] = alpha[j];
 251.986 +      for (j = nint+1; j <= mir->cut_vec->nnz; j++)
 251.987 +      {  k = mir->cut_vec->ind[j];
 251.988 +         if (k <= m+n) mir->cut_vec->val[j] *= gamma;
 251.989 +      }
 251.990 +      mir->cut_rhs = beta;
 251.991 +#if _MIR_DEBUG
 251.992 +      ios_check_vec(mir->cut_vec);
 251.993 +#endif
 251.994 +skip: /* free working arrays */
 251.995 +      xfree(u);
 251.996 +      xfree(x);
 251.997 +      xfree(alpha);
 251.998 +done: return r_best;
 251.999 +}
251.1000 +
251.1001 +#if _MIR_DEBUG
251.1002 +static void check_raw_cut(struct MIR *mir, double r_best)
251.1003 +{     /* check raw cut before back bound substitution */
251.1004 +      int m = mir->m;
251.1005 +      int n = mir->n;
251.1006 +      int j, k, kk;
251.1007 +      double r, big, x;
251.1008 +      /* compute the residual r = sum a[k] * x[k] - b and determine
251.1009 +         big = max(1, |a[k]|, |b|) */
251.1010 +      r = 0.0, big = 1.0;
251.1011 +      for (j = 1; j <= mir->cut_vec->nnz; j++)
251.1012 +      {  k = mir->cut_vec->ind[j];
251.1013 +         xassert(1 <= k && k <= m+n);
251.1014 +         if (mir->subst[k] == 'L')
251.1015 +         {  xassert(mir->lb[k] != -DBL_MAX);
251.1016 +            kk = mir->vlb[k];
251.1017 +            if (kk == 0)
251.1018 +               x = mir->x[k] - mir->lb[k];
251.1019 +            else
251.1020 +               x = mir->x[k] - mir->lb[k] * mir->x[kk];
251.1021 +         }
251.1022 +         else if (mir->subst[k] == 'U')
251.1023 +         {  xassert(mir->ub[k] != +DBL_MAX);
251.1024 +            kk = mir->vub[k];
251.1025 +            if (kk == 0)
251.1026 +               x = mir->ub[k] - mir->x[k];
251.1027 +            else
251.1028 +               x = mir->ub[k] * mir->x[kk] - mir->x[k];
251.1029 +         }
251.1030 +         else
251.1031 +            xassert(k != k);
251.1032 +         r += mir->cut_vec->val[j] * x;
251.1033 +         if (big < fabs(mir->cut_vec->val[j]))
251.1034 +            big = fabs(mir->cut_vec->val[j]);
251.1035 +      }
251.1036 +      r -= mir->cut_rhs;
251.1037 +      if (big < fabs(mir->cut_rhs))
251.1038 +         big = fabs(mir->cut_rhs);
251.1039 +      /* the residual must be close to r_best */
251.1040 +      xassert(fabs(r - r_best) <= 1e-6 * big);
251.1041 +      return;
251.1042 +}
251.1043 +#endif
251.1044 +
251.1045 +static void back_subst(struct MIR *mir)
251.1046 +{     /* back substitution of original bounds */
251.1047 +      int m = mir->m;
251.1048 +      int n = mir->n;
251.1049 +      int j, jj, k, kk;
251.1050 +      /* at first, restore bounds of integer variables (because on
251.1051 +         restoring variable bounds of continuous variables we need
251.1052 +         original, not shifted, bounds of integer variables) */
251.1053 +      for (j = 1; j <= mir->cut_vec->nnz; j++)
251.1054 +      {  k = mir->cut_vec->ind[j];
251.1055 +         xassert(1 <= k && k <= m+n);
251.1056 +         if (!mir->isint[k]) continue; /* skip continuous */
251.1057 +         if (mir->subst[k] == 'L')
251.1058 +         {  /* x'[k] = x[k] - lb[k] */
251.1059 +            xassert(mir->lb[k] != -DBL_MAX);
251.1060 +            xassert(mir->vlb[k] == 0);
251.1061 +            mir->cut_rhs += mir->cut_vec->val[j] * mir->lb[k];
251.1062 +         }
251.1063 +         else if (mir->subst[k] == 'U')
251.1064 +         {  /* x'[k] = ub[k] - x[k] */
251.1065 +            xassert(mir->ub[k] != +DBL_MAX);
251.1066 +            xassert(mir->vub[k] == 0);
251.1067 +            mir->cut_rhs -= mir->cut_vec->val[j] * mir->ub[k];
251.1068 +            mir->cut_vec->val[j] = - mir->cut_vec->val[j];
251.1069 +         }
251.1070 +         else
251.1071 +            xassert(k != k);
251.1072 +      }
251.1073 +      /* now restore bounds of continuous variables */
251.1074 +      for (j = 1; j <= mir->cut_vec->nnz; j++)
251.1075 +      {  k = mir->cut_vec->ind[j];
251.1076 +         xassert(1 <= k && k <= m+n);
251.1077 +         if (mir->isint[k]) continue; /* skip integer */
251.1078 +         if (mir->subst[k] == 'L')
251.1079 +         {  /* x'[k] = x[k] - (lower bound) */
251.1080 +            xassert(mir->lb[k] != -DBL_MAX);
251.1081 +            kk = mir->vlb[k];
251.1082 +            if (kk == 0)
251.1083 +            {  /* x'[k] = x[k] - lb[k] */
251.1084 +               mir->cut_rhs += mir->cut_vec->val[j] * mir->lb[k];
251.1085 +            }
251.1086 +            else
251.1087 +            {  /* x'[k] = x[k] - lb[k] * x[kk] */
251.1088 +               jj = mir->cut_vec->pos[kk];
251.1089 +#if 0
251.1090 +               xassert(jj != 0);
251.1091 +#else
251.1092 +               if (jj == 0)
251.1093 +               {  ios_set_vj(mir->cut_vec, kk, 1.0);
251.1094 +                  jj = mir->cut_vec->pos[kk];
251.1095 +                  xassert(jj != 0);
251.1096 +                  mir->cut_vec->val[jj] = 0.0;
251.1097 +               }
251.1098 +#endif
251.1099 +               mir->cut_vec->val[jj] -= mir->cut_vec->val[j] *
251.1100 +                  mir->lb[k];
251.1101 +            }
251.1102 +         }
251.1103 +         else if (mir->subst[k] == 'U')
251.1104 +         {  /* x'[k] = (upper bound) - x[k] */
251.1105 +            xassert(mir->ub[k] != +DBL_MAX);
251.1106 +            kk = mir->vub[k];
251.1107 +            if (kk == 0)
251.1108 +            {  /* x'[k] = ub[k] - x[k] */
251.1109 +               mir->cut_rhs -= mir->cut_vec->val[j] * mir->ub[k];
251.1110 +            }
251.1111 +            else
251.1112 +            {  /* x'[k] = ub[k] * x[kk] - x[k] */
251.1113 +               jj = mir->cut_vec->pos[kk];
251.1114 +               if (jj == 0)
251.1115 +               {  ios_set_vj(mir->cut_vec, kk, 1.0);
251.1116 +                  jj = mir->cut_vec->pos[kk];
251.1117 +                  xassert(jj != 0);
251.1118 +                  mir->cut_vec->val[jj] = 0.0;
251.1119 +               }
251.1120 +               mir->cut_vec->val[jj] += mir->cut_vec->val[j] *
251.1121 +                  mir->ub[k];
251.1122 +            }
251.1123 +            mir->cut_vec->val[j] = - mir->cut_vec->val[j];
251.1124 +         }
251.1125 +         else
251.1126 +            xassert(k != k);
251.1127 +      }
251.1128 +#if _MIR_DEBUG
251.1129 +      ios_check_vec(mir->cut_vec);
251.1130 +#endif
251.1131 +      return;
251.1132 +}
251.1133 +
251.1134 +#if _MIR_DEBUG
251.1135 +static void check_cut_row(struct MIR *mir, double r_best)
251.1136 +{     /* check the cut after back bound substitution or elimination of
251.1137 +         auxiliary variables */
251.1138 +      int m = mir->m;
251.1139 +      int n = mir->n;
251.1140 +      int j, k;
251.1141 +      double r, big;
251.1142 +      /* compute the residual r = sum a[k] * x[k] - b and determine
251.1143 +         big = max(1, |a[k]|, |b|) */
251.1144 +      r = 0.0, big = 1.0;
251.1145 +      for (j = 1; j <= mir->cut_vec->nnz; j++)
251.1146 +      {  k = mir->cut_vec->ind[j];
251.1147 +         xassert(1 <= k && k <= m+n);
251.1148 +         r += mir->cut_vec->val[j] * mir->x[k];
251.1149 +         if (big < fabs(mir->cut_vec->val[j]))
251.1150 +            big = fabs(mir->cut_vec->val[j]);
251.1151 +      }
251.1152 +      r -= mir->cut_rhs;
251.1153 +      if (big < fabs(mir->cut_rhs))
251.1154 +         big = fabs(mir->cut_rhs);
251.1155 +      /* the residual must be close to r_best */
251.1156 +      xassert(fabs(r - r_best) <= 1e-6 * big);
251.1157 +      return;
251.1158 +}
251.1159 +#endif
251.1160 +
251.1161 +static void subst_aux_vars(glp_tree *tree, struct MIR *mir)
251.1162 +{     /* final substitution to eliminate auxiliary variables */
251.1163 +      glp_prob *mip = tree->mip;
251.1164 +      int m = mir->m;
251.1165 +      int n = mir->n;
251.1166 +      GLPAIJ *aij;
251.1167 +      int j, k, kk, jj;
251.1168 +      for (j = mir->cut_vec->nnz; j >= 1; j--)
251.1169 +      {  k = mir->cut_vec->ind[j];
251.1170 +         xassert(1 <= k && k <= m+n);
251.1171 +         if (k > m) continue; /* skip structurals */
251.1172 +         for (aij = mip->row[k]->ptr; aij != NULL; aij = aij->r_next)
251.1173 +         {  kk = m + aij->col->j; /* structural */
251.1174 +            jj = mir->cut_vec->pos[kk];
251.1175 +            if (jj == 0)
251.1176 +            {  ios_set_vj(mir->cut_vec, kk, 1.0);
251.1177 +               jj = mir->cut_vec->pos[kk];
251.1178 +               mir->cut_vec->val[jj] = 0.0;
251.1179 +            }
251.1180 +            mir->cut_vec->val[jj] += mir->cut_vec->val[j] * aij->val;
251.1181 +         }
251.1182 +         mir->cut_vec->val[j] = 0.0;
251.1183 +      }
251.1184 +      ios_clean_vec(mir->cut_vec, 0.0);
251.1185 +      return;
251.1186 +}
251.1187 +
251.1188 +static void add_cut(glp_tree *tree, struct MIR *mir)
251.1189 +{     /* add constructed cut inequality to the cut pool */
251.1190 +      int m = mir->m;
251.1191 +      int n = mir->n;
251.1192 +      int j, k, len;
251.1193 +      int *ind = xcalloc(1+n, sizeof(int));
251.1194 +      double *val = xcalloc(1+n, sizeof(double));
251.1195 +      len = 0;
251.1196 +      for (j = mir->cut_vec->nnz; j >= 1; j--)
251.1197 +      {  k = mir->cut_vec->ind[j];
251.1198 +         xassert(m+1 <= k && k <= m+n);
251.1199 +         len++, ind[len] = k - m, val[len] = mir->cut_vec->val[j];
251.1200 +      }
251.1201 +#if 0
251.1202 +      ios_add_cut_row(tree, pool, GLP_RF_MIR, len, ind, val, GLP_UP,
251.1203 +         mir->cut_rhs);
251.1204 +#else
251.1205 +      glp_ios_add_row(tree, NULL, GLP_RF_MIR, 0, len, ind, val, GLP_UP,
251.1206 +         mir->cut_rhs);
251.1207 +#endif
251.1208 +      xfree(ind);
251.1209 +      xfree(val);
251.1210 +      return;
251.1211 +}
251.1212 +
251.1213 +static int aggregate_row(glp_tree *tree, struct MIR *mir)
251.1214 +{     /* try to aggregate another row */
251.1215 +      glp_prob *mip = tree->mip;
251.1216 +      int m = mir->m;
251.1217 +      int n = mir->n;
251.1218 +      GLPAIJ *aij;
251.1219 +      IOSVEC *v;
251.1220 +      int ii, j, jj, k, kk, kappa = 0, ret = 0;
251.1221 +      double d1, d2, d, d_max = 0.0;
251.1222 +      /* choose appropriate structural variable in the aggregated row
251.1223 +         to be substituted */
251.1224 +      for (j = 1; j <= mir->agg_vec->nnz; j++)
251.1225 +      {  k = mir->agg_vec->ind[j];
251.1226 +         xassert(1 <= k && k <= m+n);
251.1227 +         if (k <= m) continue; /* skip auxiliary var */
251.1228 +         if (mir->isint[k]) continue; /* skip integer var */
251.1229 +         if (fabs(mir->agg_vec->val[j]) < 0.001) continue;
251.1230 +         /* compute distance from x[k] to its lower bound */
251.1231 +         kk = mir->vlb[k];
251.1232 +         if (kk == 0)
251.1233 +         {  if (mir->lb[k] == -DBL_MAX)
251.1234 +               d1 = DBL_MAX;
251.1235 +            else
251.1236 +               d1 = mir->x[k] - mir->lb[k];
251.1237 +         }
251.1238 +         else
251.1239 +         {  xassert(1 <= kk && kk <= m+n);
251.1240 +            xassert(mir->isint[kk]);
251.1241 +            xassert(mir->lb[k] != -DBL_MAX);
251.1242 +            d1 = mir->x[k] - mir->lb[k] * mir->x[kk];
251.1243 +         }
251.1244 +         /* compute distance from x[k] to its upper bound */
251.1245 +         kk = mir->vub[k];
251.1246 +         if (kk == 0)
251.1247 +         {  if (mir->vub[k] == +DBL_MAX)
251.1248 +               d2 = DBL_MAX;
251.1249 +            else
251.1250 +               d2 = mir->ub[k] - mir->x[k];
251.1251 +         }
251.1252 +         else
251.1253 +         {  xassert(1 <= kk && kk <= m+n);
251.1254 +            xassert(mir->isint[kk]);
251.1255 +            xassert(mir->ub[k] != +DBL_MAX);
251.1256 +            d2 = mir->ub[k] * mir->x[kk] - mir->x[k];
251.1257 +         }
251.1258 +         /* x[k] cannot be free */
251.1259 +         xassert(d1 != DBL_MAX || d2 != DBL_MAX);
251.1260 +         /* d = min(d1, d2) */
251.1261 +         d = (d1 <= d2 ? d1 : d2);
251.1262 +         xassert(d != DBL_MAX);
251.1263 +         /* should not be close to corresponding bound */
251.1264 +         if (d < 0.001) continue;
251.1265 +         if (d_max < d) d_max = d, kappa = k;
251.1266 +      }
251.1267 +      if (kappa == 0)
251.1268 +      {  /* nothing chosen */
251.1269 +         ret = 1;
251.1270 +         goto done;
251.1271 +      }
251.1272 +      /* x[kappa] has been chosen */
251.1273 +      xassert(m+1 <= kappa && kappa <= m+n);
251.1274 +      xassert(!mir->isint[kappa]);
251.1275 +      /* find another row, which have not been used yet, to eliminate
251.1276 +         x[kappa] from the aggregated row */
251.1277 +      for (ii = 1; ii <= m; ii++)
251.1278 +      {  if (mir->skip[ii]) continue;
251.1279 +         for (aij = mip->row[ii]->ptr; aij != NULL; aij = aij->r_next)
251.1280 +            if (aij->col->j == kappa - m) break;
251.1281 +         if (aij != NULL && fabs(aij->val) >= 0.001) break;
251.1282 +      }
251.1283 +      if (ii > m)
251.1284 +      {  /* nothing found */
251.1285 +         ret = 2;
251.1286 +         goto done;
251.1287 +      }
251.1288 +      /* row ii has been found; include it in the aggregated list */
251.1289 +      mir->agg_cnt++;
251.1290 +      xassert(mir->agg_cnt <= MAXAGGR);
251.1291 +      mir->agg_row[mir->agg_cnt] = ii;
251.1292 +      mir->skip[ii] = 2;
251.1293 +      /* v := new row */
251.1294 +      v = ios_create_vec(m+n);
251.1295 +      ios_set_vj(v, ii, 1.0);
251.1296 +      for (aij = mip->row[ii]->ptr; aij != NULL; aij = aij->r_next)
251.1297 +         ios_set_vj(v, m + aij->col->j, - aij->val);
251.1298 +#if _MIR_DEBUG
251.1299 +      ios_check_vec(v);
251.1300 +#endif
251.1301 +      /* perform gaussian elimination to remove x[kappa] */
251.1302 +      j = mir->agg_vec->pos[kappa];
251.1303 +      xassert(j != 0);
251.1304 +      jj = v->pos[kappa];
251.1305 +      xassert(jj != 0);
251.1306 +      ios_linear_comb(mir->agg_vec,
251.1307 +         - mir->agg_vec->val[j] / v->val[jj], v);
251.1308 +      ios_delete_vec(v);
251.1309 +      ios_set_vj(mir->agg_vec, kappa, 0.0);
251.1310 +#if _MIR_DEBUG
251.1311 +      ios_check_vec(mir->agg_vec);
251.1312 +#endif
251.1313 +done: return ret;
251.1314 +}
251.1315 +
251.1316 +void ios_mir_gen(glp_tree *tree, void *gen)
251.1317 +{     /* main routine to generate MIR cuts */
251.1318 +      glp_prob *mip = tree->mip;
251.1319 +      struct MIR *mir = gen;
251.1320 +      int m = mir->m;
251.1321 +      int n = mir->n;
251.1322 +      int i;
251.1323 +      double r_best;
251.1324 +      xassert(mip->m >= m);
251.1325 +      xassert(mip->n == n);
251.1326 +      /* obtain current point */
251.1327 +      get_current_point(tree, mir);
251.1328 +#if _MIR_DEBUG
251.1329 +      /* check current point */
251.1330 +      check_current_point(mir);
251.1331 +#endif
251.1332 +      /* reset bound substitution flags */
251.1333 +      memset(&mir->subst[1], '?', m+n);
251.1334 +      /* try to generate a set of violated MIR cuts */
251.1335 +      for (i = 1; i <= m; i++)
251.1336 +      {  if (mir->skip[i]) continue;
251.1337 +         /* use original i-th row as initial aggregated constraint */
251.1338 +         initial_agg_row(tree, mir, i);
251.1339 +loop:    ;
251.1340 +#if _MIR_DEBUG
251.1341 +         /* check aggregated row */
251.1342 +         check_agg_row(mir);
251.1343 +#endif
251.1344 +         /* substitute fixed variables into aggregated constraint */
251.1345 +         subst_fixed_vars(mir);
251.1346 +#if _MIR_DEBUG
251.1347 +         /* check aggregated row */
251.1348 +         check_agg_row(mir);
251.1349 +#endif
251.1350 +#if _MIR_DEBUG
251.1351 +         /* check bound substitution flags */
251.1352 +         {  int k;
251.1353 +            for (k = 1; k <= m+n; k++)
251.1354 +               xassert(mir->subst[k] == '?');
251.1355 +         }
251.1356 +#endif
251.1357 +         /* apply bound substitution heuristic */
251.1358 +         bound_subst_heur(mir);
251.1359 +         /* substitute bounds and build modified constraint */
251.1360 +         build_mod_row(mir);
251.1361 +#if _MIR_DEBUG
251.1362 +         /* check modified row */
251.1363 +         check_mod_row(mir);
251.1364 +#endif
251.1365 +         /* try to generate violated c-MIR cut for modified row */
251.1366 +         r_best = generate(mir);
251.1367 +         if (r_best > 0.0)
251.1368 +         {  /* success */
251.1369 +#if _MIR_DEBUG
251.1370 +            /* check raw cut before back bound substitution */
251.1371 +            check_raw_cut(mir, r_best);
251.1372 +#endif
251.1373 +            /* back substitution of original bounds */
251.1374 +            back_subst(mir);
251.1375 +#if _MIR_DEBUG
251.1376 +            /* check the cut after back bound substitution */
251.1377 +            check_cut_row(mir, r_best);
251.1378 +#endif
251.1379 +            /* final substitution to eliminate auxiliary variables */
251.1380 +            subst_aux_vars(tree, mir);
251.1381 +#if _MIR_DEBUG
251.1382 +            /* check the cut after elimination of auxiliaries */
251.1383 +            check_cut_row(mir, r_best);
251.1384 +#endif
251.1385 +            /* add constructed cut inequality to the cut pool */
251.1386 +            add_cut(tree, mir);
251.1387 +         }
251.1388 +         /* reset bound substitution flags */
251.1389 +         {  int j, k;
251.1390 +            for (j = 1; j <= mir->mod_vec->nnz; j++)
251.1391 +            {  k = mir->mod_vec->ind[j];
251.1392 +               xassert(1 <= k && k <= m+n);
251.1393 +               xassert(mir->subst[k] != '?');
251.1394 +               mir->subst[k] = '?';
251.1395 +            }
251.1396 +         }
251.1397 +         if (r_best == 0.0)
251.1398 +         {  /* failure */
251.1399 +            if (mir->agg_cnt < MAXAGGR)
251.1400 +            {  /* try to aggregate another row */
251.1401 +               if (aggregate_row(tree, mir) == 0) goto loop;
251.1402 +            }
251.1403 +         }
251.1404 +         /* unmark rows used in the aggregated constraint */
251.1405 +         {  int k, ii;
251.1406 +            for (k = 1; k <= mir->agg_cnt; k++)
251.1407 +            {  ii = mir->agg_row[k];
251.1408 +               xassert(1 <= ii && ii <= m);
251.1409 +               xassert(mir->skip[ii] == 2);
251.1410 +               mir->skip[ii] = 0;
251.1411 +            }
251.1412 +         }
251.1413 +      }
251.1414 +      return;
251.1415 +}
251.1416 +
251.1417 +/***********************************************************************
251.1418 +*  NAME
251.1419 +*
251.1420 +*  ios_mir_term - terminate MIR cut generator
251.1421 +*
251.1422 +*  SYNOPSIS
251.1423 +*
251.1424 +*  #include "glpios.h"
251.1425 +*  void ios_mir_term(void *gen);
251.1426 +*
251.1427 +*  DESCRIPTION
251.1428 +*
251.1429 +*  The routine ios_mir_term deletes the MIR cut generator working area
251.1430 +*  freeing all the memory allocated to it. */
251.1431 +
251.1432 +void ios_mir_term(void *gen)
251.1433 +{     struct MIR *mir = gen;
251.1434 +      xfree(mir->skip);
251.1435 +      xfree(mir->isint);
251.1436 +      xfree(mir->lb);
251.1437 +      xfree(mir->vlb);
251.1438 +      xfree(mir->ub);
251.1439 +      xfree(mir->vub);
251.1440 +      xfree(mir->x);
251.1441 +      xfree(mir->agg_row);
251.1442 +      ios_delete_vec(mir->agg_vec);
251.1443 +      xfree(mir->subst);
251.1444 +      ios_delete_vec(mir->mod_vec);
251.1445 +      ios_delete_vec(mir->cut_vec);
251.1446 +      xfree(mir);
251.1447 +      return;
251.1448 +}
251.1449 +
251.1450 +/* eof */
   252.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
   252.2 +++ b/deps/glpk/src/glpios07.c	Sun Nov 06 20:59:10 2011 +0100
   252.3 @@ -0,0 +1,554 @@
   252.4 +/* glpios07.c (mixed cover cut generator) */
   252.5 +
   252.6 +/***********************************************************************
   252.7 +*  This code is part of GLPK (GNU Linear Programming Kit).
   252.8 +*
   252.9 +*  Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008,
  252.10 +*  2009, 2010, 2011 Andrew Makhorin, Department for Applied Informatics,
  252.11 +*  Moscow Aviation Institute, Moscow, Russia. All rights reserved.
  252.12 +*  E-mail: <mao@gnu.org>.
  252.13 +*
  252.14 +*  GLPK is free software: you can redistribute it and/or modify it
  252.15 +*  under the terms of the GNU General Public License as published by
  252.16 +*  the Free Software Foundation, either version 3 of the License, or
  252.17 +*  (at your option) any later version.
  252.18 +*
  252.19 +*  GLPK is distributed in the hope that it will be useful, but WITHOUT
  252.20 +*  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
  252.21 +*  or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
  252.22 +*  License for more details.
  252.23 +*
  252.24 +*  You should have received a copy of the GNU General Public License
  252.25 +*  along with GLPK. If not, see <http://www.gnu.org/licenses/>.
  252.26 +***********************************************************************/
  252.27 +
  252.28 +#include "glpios.h"
  252.29 +
  252.30 +/*----------------------------------------------------------------------
  252.31 +-- COVER INEQUALITIES
  252.32 +--
  252.33 +-- Consider the set of feasible solutions to 0-1 knapsack problem:
  252.34 +--
  252.35 +--    sum a[j]*x[j] <= b,                                            (1)
  252.36 +--  j in J
  252.37 +--
  252.38 +--    x[j] is binary,                                                (2)
  252.39 +--
  252.40 +-- where, wlog, we assume that a[j] > 0 (since 0-1 variables can be
  252.41 +-- complemented) and a[j] <= b (since a[j] > b implies x[j] = 0).
  252.42 +--
  252.43 +-- A set C within J is called a cover if
  252.44 +--
  252.45 +--    sum a[j] > b.                                                  (3)
  252.46 +--  j in C
  252.47 +--
  252.48 +-- For any cover C the inequality
  252.49 +--
  252.50 +--    sum x[j] <= |C| - 1                                            (4)
  252.51 +--  j in C
  252.52 +--
  252.53 +-- is called a cover inequality and is valid for (1)-(2).
  252.54 +--
  252.55 +-- MIXED COVER INEQUALITIES
  252.56 +--
  252.57 +-- Consider the set of feasible solutions to mixed knapsack problem:
  252.58 +--
  252.59 +--    sum a[j]*x[j] + y <= b,                                        (5)
  252.60 +--  j in J
  252.61 +--
  252.62 +--    x[j] is binary,                                                (6)
  252.63 +--
  252.64 +--    0 <= y <= u is continuous,                                     (7)
  252.65 +--
  252.66 +-- where again we assume that a[j] > 0.
  252.67 +--
  252.68 +-- Let C within J be some set. From (1)-(4) it follows that
  252.69 +--
  252.70 +--    sum a[j] > b - y                                               (8)
  252.71 +--  j in C
  252.72 +--
  252.73 +-- implies
  252.74 +--
  252.75 +--    sum x[j] <= |C| - 1.                                           (9)
  252.76 +--  j in C
  252.77 +--
  252.78 +-- Thus, we need to modify the inequality (9) in such a way that it be
  252.79 +-- a constraint only if the condition (8) is satisfied.
  252.80 +--
  252.81 +-- Consider the following inequality:
  252.82 +--
  252.83 +--    sum x[j] <= |C| - t.                                          (10)
  252.84 +--  j in C
  252.85 +--
  252.86 +-- If 0 < t <= 1, then (10) is equivalent to (9), because all x[j] are
  252.87 +-- binary variables. On the other hand, if t <= 0, (10) being satisfied
  252.88 +-- for any values of x[j] is not a constraint.
  252.89 +--
  252.90 +-- Let
  252.91 +--
  252.92 +--    t' = sum a[j] + y - b.                                        (11)
  252.93 +--       j in C
  252.94 +--
  252.95 +-- It is understood that the condition t' > 0 is equivalent to (8).
  252.96 +-- Besides, from (6)-(7) it follows that t' has an implied upper bound:
  252.97 +--
  252.98 +--    t'max = sum a[j] + u - b.                                     (12)
  252.99 +--          j in C
 252.100 +--
 252.101 +-- This allows to express the parameter t having desired properties:
 252.102 +--
 252.103 +--    t = t' / t'max.                                               (13)
 252.104 +--
 252.105 +-- In fact, t <= 1 by definition, and t > 0 being equivalent to t' > 0
 252.106 +-- is equivalent to (8).
 252.107 +--
 252.108 +-- Thus, the inequality (10), where t is given by formula (13) is valid
 252.109 +-- for (5)-(7).
 252.110 +--
 252.111 +-- Note that if u = 0, then y = 0, so t = 1, and the conditions (8) and
 252.112 +-- (10) is transformed to the conditions (3) and (4).
 252.113 +--
 252.114 +-- GENERATING MIXED COVER CUTS
 252.115 +--
 252.116 +-- To generate a mixed cover cut in the form (10) we need to find such
 252.117 +-- set C which satisfies to the inequality (8) and for which, in turn,
 252.118 +-- the inequality (10) is violated in the current point.
 252.119 +--
 252.120 +-- Substituting t from (13) to (10) gives:
 252.121 +--
 252.122 +--                        1
 252.123 +--    sum x[j] <= |C| - -----  (sum a[j] + y - b),                  (14)
 252.124 +--  j in C              t'max j in C
 252.125 +--
 252.126 +-- and finally we have the cut inequality in the standard form:
 252.127 +--
 252.128 +--    sum x[j] + alfa * y <= beta,                                  (15)
 252.129 +--  j in C
 252.130 +--
 252.131 +-- where:
 252.132 +--
 252.133 +--    alfa = 1 / t'max,                                             (16)
 252.134 +--
 252.135 +--    beta = |C| - alfa *  (sum a[j] - b).                          (17)
 252.136 +--                        j in C                                      */
 252.137 +
 252.138 +#if 1
 252.139 +#define MAXTRY 1000
 252.140 +#else
 252.141 +#define MAXTRY 10000
 252.142 +#endif
 252.143 +
 252.144 +static int cover2(int n, double a[], double b, double u, double x[],
 252.145 +      double y, int cov[], double *_alfa, double *_beta)
 252.146 +{     /* try to generate mixed cover cut using two-element cover */
 252.147 +      int i, j, try = 0, ret = 0;
 252.148 +      double eps, alfa, beta, temp, rmax = 0.001;
 252.149 +      eps = 0.001 * (1.0 + fabs(b));
 252.150 +      for (i = 0+1; i <= n; i++)
 252.151 +      for (j = i+1; j <= n; j++)
 252.152 +      {  /* C = {i, j} */
 252.153 +         try++;
 252.154 +         if (try > MAXTRY) goto done;
 252.155 +         /* check if condition (8) is satisfied */
 252.156 +         if (a[i] + a[j] + y > b + eps)
 252.157 +         {  /* compute parameters for inequality (15) */
 252.158 +            temp = a[i] + a[j] - b;
 252.159 +            alfa = 1.0 / (temp + u);
 252.160 +            beta = 2.0 - alfa * temp;
 252.161 +            /* compute violation of inequality (15) */
 252.162 +            temp = x[i] + x[j] + alfa * y - beta;
 252.163 +            /* choose C providing maximum violation */
 252.164 +            if (rmax < temp)
 252.165 +            {  rmax = temp;
 252.166 +               cov[1] = i;
 252.167 +               cov[2] = j;
 252.168 +               *_alfa = alfa;
 252.169 +               *_beta = beta;
 252.170 +               ret = 1;
 252.171 +            }
 252.172 +         }
 252.173 +      }
 252.174 +done: return ret;
 252.175 +}
 252.176 +
 252.177 +static int cover3(int n, double a[], double b, double u, double x[],
 252.178 +      double y, int cov[], double *_alfa, double *_beta)
 252.179 +{     /* try to generate mixed cover cut using three-element cover */
 252.180 +      int i, j, k, try = 0, ret = 0;
 252.181 +      double eps, alfa, beta, temp, rmax = 0.001;
 252.182 +      eps = 0.001 * (1.0 + fabs(b));
 252.183 +      for (i = 0+1; i <= n; i++)
 252.184 +      for (j = i+1; j <= n; j++)
 252.185 +      for (k = j+1; k <= n; k++)
 252.186 +      {  /* C = {i, j, k} */
 252.187 +         try++;
 252.188 +         if (try > MAXTRY) goto done;
 252.189 +         /* check if condition (8) is satisfied */
 252.190 +         if (a[i] + a[j] + a[k] + y > b + eps)
 252.191 +         {  /* compute parameters for inequality (15) */
 252.192 +            temp = a[i] + a[j] + a[k] - b;
 252.193 +            alfa = 1.0 / (temp + u);
 252.194 +            beta = 3.0 - alfa * temp;
 252.195 +            /* compute violation of inequality (15) */
 252.196 +            temp = x[i] + x[j] + x[k] + alfa * y - beta;
 252.197 +            /* choose C providing maximum violation */
 252.198 +            if (rmax < temp)
 252.199 +            {  rmax = temp;
 252.200 +               cov[1] = i;
 252.201 +               cov[2] = j;
 252.202 +               cov[3] = k;
 252.203 +               *_alfa = alfa;
 252.204 +               *_beta = beta;
 252.205 +               ret = 1;
 252.206 +            }
 252.207 +         }
 252.208 +      }
 252.209 +done: return ret;
 252.210 +}
 252.211 +
 252.212 +static int cover4(int n, double a[], double b, double u, double x[],
 252.213 +      double y, int cov[], double *_alfa, double *_beta)
 252.214 +{     /* try to generate mixed cover cut using four-element cover */
 252.215 +      int i, j, k, l, try = 0, ret = 0;
 252.216 +      double eps, alfa, beta, temp, rmax = 0.001;
 252.217 +      eps = 0.001 * (1.0 + fabs(b));
 252.218 +      for (i = 0+1; i <= n; i++)
 252.219 +      for (j = i+1; j <= n; j++)
 252.220 +      for (k = j+1; k <= n; k++)
 252.221 +      for (l = k+1; l <= n; l++)
 252.222 +      {  /* C = {i, j, k, l} */
 252.223 +         try++;
 252.224 +         if (try > MAXTRY) goto done;
 252.225 +         /* check if condition (8) is satisfied */
 252.226 +         if (a[i] + a[j] + a[k] + a[l] + y > b + eps)
 252.227 +         {  /* compute parameters for inequality (15) */
 252.228 +            temp = a[i] + a[j] + a[k] + a[l] - b;
 252.229 +            alfa = 1.0 / (temp + u);
 252.230 +            beta = 4.0 - alfa * temp;
 252.231 +            /* compute violation of inequality (15) */
 252.232 +            temp = x[i] + x[j] + x[k] + x[l] + alfa * y - beta;
 252.233 +            /* choose C providing maximum violation */
 252.234 +            if (rmax < temp)
 252.235 +            {  rmax = temp;
 252.236 +               cov[1] = i;
 252.237 +               cov[2] = j;
 252.238 +               cov[3] = k;
 252.239 +               cov[4] = l;
 252.240 +               *_alfa = alfa;
 252.241 +               *_beta = beta;
 252.242 +               ret = 1;
 252.243 +            }
 252.244 +         }
 252.245 +      }
 252.246 +done: return ret;
 252.247 +}
 252.248 +
 252.249 +static int cover(int n, double a[], double b, double u, double x[],
 252.250 +      double y, int cov[], double *alfa, double *beta)
 252.251 +{     /* try to generate mixed cover cut;
 252.252 +         input (see (5)):
 252.253 +         n        is the number of binary variables;
 252.254 +         a[1:n]   are coefficients at binary variables;
 252.255 +         b        is the right-hand side;
 252.256 +         u        is upper bound of continuous variable;
 252.257 +         x[1:n]   are values of binary variables at current point;
 252.258 +         y        is value of continuous variable at current point;
 252.259 +         output (see (15), (16), (17)):
 252.260 +         cov[1:r] are indices of binary variables included in cover C,
 252.261 +                  where r is the set cardinality returned on exit;
 252.262 +         alfa     coefficient at continuous variable;
 252.263 +         beta     is the right-hand side; */
 252.264 +      int j;
 252.265 +      /* perform some sanity checks */
 252.266 +      xassert(n >= 2);
 252.267 +      for (j = 1; j <= n; j++) xassert(a[j] > 0.0);
 252.268 +#if 1 /* ??? */
 252.269 +      xassert(b > -1e-5);
 252.270 +#else
 252.271 +      xassert(b > 0.0);
 252.272 +#endif
 252.273 +      xassert(u >= 0.0);
 252.274 +      for (j = 1; j <= n; j++) xassert(0.0 <= x[j] && x[j] <= 1.0);
 252.275 +      xassert(0.0 <= y && y <= u);
 252.276 +      /* try to generate mixed cover cut */
 252.277 +      if (cover2(n, a, b, u, x, y, cov, alfa, beta)) return 2;
 252.278 +      if (cover3(n, a, b, u, x, y, cov, alfa, beta)) return 3;
 252.279 +      if (cover4(n, a, b, u, x, y, cov, alfa, beta)) return 4;
 252.280 +      return 0;
 252.281 +}
 252.282 +
 252.283 +/*----------------------------------------------------------------------
 252.284 +-- lpx_cover_cut - generate mixed cover cut.
 252.285 +--
 252.286 +-- SYNOPSIS
 252.287 +--
 252.288 +-- #include "glplpx.h"
 252.289 +-- int lpx_cover_cut(LPX *lp, int len, int ind[], double val[],
 252.290 +--    double work[]);
 252.291 +--
 252.292 +-- DESCRIPTION
 252.293 +--
 252.294 +-- The routine lpx_cover_cut generates a mixed cover cut for a given
 252.295 +-- row of the MIP problem.
 252.296 +--
 252.297 +-- The given row of the MIP problem should be explicitly specified in
 252.298 +-- the form:
 252.299 +--
 252.300 +--    sum{j in J} a[j]*x[j] <= b.                                    (1)
 252.301 +--
 252.302 +-- On entry indices (ordinal numbers) of structural variables, which
 252.303 +-- have non-zero constraint coefficients, should be placed in locations
 252.304 +-- ind[1], ..., ind[len], and corresponding constraint coefficients
 252.305 +-- should be placed in locations val[1], ..., val[len]. The right-hand
 252.306 +-- side b should be stored in location val[0].
 252.307 +--
 252.308 +-- The working array work should have at least nb locations, where nb
 252.309 +-- is the number of binary variables in (1).
 252.310 +--
 252.311 +-- The routine generates a mixed cover cut in the same form as (1) and
 252.312 +-- stores the cut coefficients and right-hand side in the same way as
 252.313 +-- just described above.
 252.314 +--
 252.315 +-- RETURNS
 252.316 +--
 252.317 +-- If the cutting plane has been successfully generated, the routine
 252.318 +-- returns 1 <= len' <= n, which is the number of non-zero coefficients
 252.319 +-- in the inequality constraint. Otherwise, the routine returns zero. */
 252.320 +
 252.321 +static int lpx_cover_cut(LPX *lp, int len, int ind[], double val[],
 252.322 +      double work[])
 252.323 +{     int cov[1+4], j, k, nb, newlen, r;
 252.324 +      double f_min, f_max, alfa, beta, u, *x = work, y;
 252.325 +      /* substitute and remove fixed variables */
 252.326 +      newlen = 0;
 252.327 +      for (k = 1; k <= len; k++)
 252.328 +      {  j = ind[k];
 252.329 +         if (lpx_get_col_type(lp, j) == LPX_FX)
 252.330 +            val[0] -= val[k] * lpx_get_col_lb(lp, j);
 252.331 +         else
 252.332 +         {  newlen++;
 252.333 +            ind[newlen] = ind[k];
 252.334 +            val[newlen] = val[k];
 252.335 +         }
 252.336 +      }
 252.337 +      len = newlen;
 252.338 +      /* move binary variables to the beginning of the list so that
 252.339 +         elements 1, 2, ..., nb correspond to binary variables, and
 252.340 +         elements nb+1, nb+2, ..., len correspond to rest variables */
 252.341 +      nb = 0;
 252.342 +      for (k = 1; k <= len; k++)
 252.343 +      {  j = ind[k];
 252.344 +         if (lpx_get_col_kind(lp, j) == LPX_IV &&
 252.345 +             lpx_get_col_type(lp, j) == LPX_DB &&
 252.346 +             lpx_get_col_lb(lp, j) == 0.0 &&
 252.347 +             lpx_get_col_ub(lp, j) == 1.0)
 252.348 +         {  /* binary variable */
 252.349 +            int ind_k;
 252.350 +            double val_k;
 252.351 +            nb++;
 252.352 +            ind_k = ind[nb], val_k = val[nb];
 252.353 +            ind[nb] = ind[k], val[nb] = val[k];
 252.354 +            ind[k] = ind_k, val[k] = val_k;
 252.355 +         }
 252.356 +      }
 252.357 +      /* now the specified row has the form:
 252.358 +         sum a[j]*x[j] + sum a[j]*y[j] <= b,
 252.359 +         where x[j] are binary variables, y[j] are rest variables */
 252.360 +      /* at least two binary variables are needed */
 252.361 +      if (nb < 2) return 0;
 252.362 +      /* compute implied lower and upper bounds for sum a[j]*y[j] */
 252.363 +      f_min = f_max = 0.0;
 252.364 +      for (k = nb+1; k <= len; k++)
 252.365 +      {  j = ind[k];
 252.366 +         /* both bounds must be finite */
 252.367 +         if (lpx_get_col_type(lp, j) != LPX_DB) return 0;
 252.368 +         if (val[k] > 0.0)
 252.369 +         {  f_min += val[k] * lpx_get_col_lb(lp, j);
 252.370 +            f_max += val[k] * lpx_get_col_ub(lp, j);
 252.371 +         }
 252.372 +         else
 252.373 +         {  f_min += val[k] * lpx_get_col_ub(lp, j);
 252.374 +            f_max += val[k] * lpx_get_col_lb(lp, j);
 252.375 +         }
 252.376 +      }
 252.377 +      /* sum a[j]*x[j] + sum a[j]*y[j] <= b ===>
 252.378 +         sum a[j]*x[j] + (sum a[j]*y[j] - f_min) <= b - f_min ===>
 252.379 +         sum a[j]*x[j] + y <= b - f_min,
 252.380 +         where y = sum a[j]*y[j] - f_min;
 252.381 +         note that 0 <= y <= u, u = f_max - f_min */
 252.382 +      /* determine upper bound of y */
 252.383 +      u = f_max - f_min;
 252.384 +      /* determine value of y at the current point */
 252.385 +      y = 0.0;
 252.386 +      for (k = nb+1; k <= len; k++)
 252.387 +      {  j = ind[k];
 252.388 +         y += val[k] * lpx_get_col_prim(lp, j);
 252.389 +      }
 252.390 +      y -= f_min;
 252.391 +      if (y < 0.0) y = 0.0;
 252.392 +      if (y > u) y = u;
 252.393 +      /* modify the right-hand side b */
 252.394 +      val[0] -= f_min;
 252.395 +      /* now the transformed row has the form:
 252.396 +         sum a[j]*x[j] + y <= b, where 0 <= y <= u */
 252.397 +      /* determine values of x[j] at the current point */
 252.398 +      for (k = 1; k <= nb; k++)
 252.399 +      {  j = ind[k];
 252.400 +         x[k] = lpx_get_col_prim(lp, j);
 252.401 +         if (x[k] < 0.0) x[k] = 0.0;
 252.402 +         if (x[k] > 1.0) x[k] = 1.0;
 252.403 +      }
 252.404 +      /* if a[j] < 0, replace x[j] by its complement 1 - x'[j] */
 252.405 +      for (k = 1; k <= nb; k++)
 252.406 +      {  if (val[k] < 0.0)
 252.407 +         {  ind[k] = - ind[k];
 252.408 +            val[k] = - val[k];
 252.409 +            val[0] += val[k];
 252.410 +            x[k] = 1.0 - x[k];
 252.411 +         }
 252.412 +      }
 252.413 +      /* try to generate a mixed cover cut for the transformed row */
 252.414 +      r = cover(nb, val, val[0], u, x, y, cov, &alfa, &beta);
 252.415 +      if (r == 0) return 0;
 252.416 +      xassert(2 <= r && r <= 4);
 252.417 +      /* now the cut is in the form:
 252.418 +         sum{j in C} x[j] + alfa * y <= beta */
 252.419 +      /* store the right-hand side beta */
 252.420 +      ind[0] = 0, val[0] = beta;
 252.421 +      /* restore the original ordinal numbers of x[j] */
 252.422 +      for (j = 1; j <= r; j++) cov[j] = ind[cov[j]];
 252.423 +      /* store cut coefficients at binary variables complementing back
 252.424 +         the variables having negative row coefficients */
 252.425 +      xassert(r <= nb);
 252.426 +      for (k = 1; k <= r; k++)
 252.427 +      {  if (cov[k] > 0)
 252.428 +         {  ind[k] = +cov[k];
 252.429 +            val[k] = +1.0;
 252.430 +         }
 252.431 +         else
 252.432 +         {  ind[k] = -cov[k];
 252.433 +            val[k] = -1.0;
 252.434 +            val[0] -= 1.0;
 252.435 +         }
 252.436 +      }
 252.437 +      /* substitute y = sum a[j]*y[j] - f_min */
 252.438 +      for (k = nb+1; k <= len; k++)
 252.439 +      {  r++;
 252.440 +         ind[r] = ind[k];
 252.441 +         val[r] = alfa * val[k];
 252.442 +      }
 252.443 +      val[0] += alfa * f_min;
 252.444 +      xassert(r <= len);
 252.445 +      len = r;
 252.446 +      return len;
 252.447 +}
 252.448 +
 252.449 +/*----------------------------------------------------------------------
 252.450 +-- lpx_eval_row - compute explictily specified row.
 252.451 +--
 252.452 +-- SYNOPSIS
 252.453 +--
 252.454 +-- #include "glplpx.h"
 252.455 +-- double lpx_eval_row(LPX *lp, int len, int ind[], double val[]);
 252.456 +--
 252.457 +-- DESCRIPTION
 252.458 +--
 252.459 +-- The routine lpx_eval_row computes the primal value of an explicitly
 252.460 +-- specified row using current values of structural variables.
 252.461 +--
 252.462 +-- The explicitly specified row may be thought as a linear form:
 252.463 +--
 252.464 +--    y = a[1]*x[m+1] + a[2]*x[m+2] + ... + a[n]*x[m+n],
 252.465 +--
 252.466 +-- where y is an auxiliary variable for this row, a[j] are coefficients
 252.467 +-- of the linear form, x[m+j] are structural variables.
 252.468 +--
 252.469 +-- On entry column indices and numerical values of non-zero elements of
 252.470 +-- the row should be stored in locations ind[1], ..., ind[len] and
 252.471 +-- val[1], ..., val[len], where len is the number of non-zero elements.
 252.472 +-- The array ind and val are not changed on exit.
 252.473 +--
 252.474 +-- RETURNS
 252.475 +--
 252.476 +-- The routine returns a computed value of y, the auxiliary variable of
 252.477 +-- the specified row. */
 252.478 +
 252.479 +static double lpx_eval_row(LPX *lp, int len, int ind[], double val[])
 252.480 +{     int n = lpx_get_num_cols(lp);
 252.481 +      int j, k;
 252.482 +      double sum = 0.0;
 252.483 +      if (len < 0)
 252.484 +         xerror("lpx_eval_row: len = %d; invalid row length\n", len);
 252.485 +      for (k = 1; k <= len; k++)
 252.486 +      {  j = ind[k];
 252.487 +         if (!(1 <= j && j <= n))
 252.488 +            xerror("lpx_eval_row: j = %d; column number out of range\n",
 252.489 +               j);
 252.490 +         sum += val[k] * lpx_get_col_prim(lp, j);
 252.491 +      }
 252.492 +      return sum;
 252.493 +}
 252.494 +
 252.495 +/***********************************************************************
 252.496 +*  NAME
 252.497 +*
 252.498 +*  ios_cov_gen - generate mixed cover cuts
 252.499 +*
 252.500 +*  SYNOPSIS
 252.501 +*
 252.502 +*  #include "glpios.h"
 252.503 +*  void ios_cov_gen(glp_tree *tree);
 252.504 +*
 252.505 +*  DESCRIPTION
 252.506 +*
 252.507 +*  The routine ios_cov_gen generates mixed cover cuts for the current
 252.508 +*  point and adds them to the cut pool. */
 252.509 +
 252.510 +void ios_cov_gen(glp_tree *tree)
 252.511 +{     glp_prob *prob = tree->mip;
 252.512 +      int m = lpx_get_num_rows(prob);
 252.513 +      int n = lpx_get_num_cols(prob);
 252.514 +      int i, k, type, kase, len, *ind;
 252.515 +      double r, *val, *work;
 252.516 +      xassert(lpx_get_status(prob) == LPX_OPT);
 252.517 +      /* allocate working arrays */
 252.518 +      ind = xcalloc(1+n, sizeof(int));
 252.519 +      val = xcalloc(1+n, sizeof(double));
 252.520 +      work = xcalloc(1+n, sizeof(double));
 252.521 +      /* look through all rows */
 252.522 +      for (i = 1; i <= m; i++)
 252.523 +      for (kase = 1; kase <= 2; kase++)
 252.524 +      {  type = lpx_get_row_type(prob, i);
 252.525 +         if (kase == 1)
 252.526 +         {  /* consider rows of '<=' type */
 252.527 +            if (!(type == LPX_UP || type == LPX_DB)) continue;
 252.528 +            len = lpx_get_mat_row(prob, i, ind, val);
 252.529 +            val[0] = lpx_get_row_ub(prob, i);
 252.530 +         }
 252.531 +         else
 252.532 +         {  /* consider rows of '>=' type */
 252.533 +            if (!(type == LPX_LO || type == LPX_DB)) continue;
 252.534 +            len = lpx_get_mat_row(prob, i, ind, val);
 252.535 +            for (k = 1; k <= len; k++) val[k] = - val[k];
 252.536 +            val[0] = - lpx_get_row_lb(prob, i);
 252.537 +         }
 252.538 +         /* generate mixed cover cut:
 252.539 +            sum{j in J} a[j] * x[j] <= b */
 252.540 +         len = lpx_cover_cut(prob, len, ind, val, work);
 252.541 +         if (len == 0) continue;
 252.542 +         /* at the current point the cut inequality is violated, i.e.
 252.543 +            sum{j in J} a[j] * x[j] - b > 0 */
 252.544 +         r = lpx_eval_row(prob, len, ind, val) - val[0];
 252.545 +         if (r < 1e-3) continue;
 252.546 +         /* add the cut to the cut pool */
 252.547 +         glp_ios_add_row(tree, NULL, GLP_RF_COV, 0, len, ind, val,
 252.548 +            GLP_UP, val[0]);
 252.549 +      }
 252.550 +      /* free working arrays */
 252.551 +      xfree(ind);
 252.552 +      xfree(val);
 252.553 +      xfree(work);
 252.554 +      return;
 252.555 +}
 252.556 +
 252.557 +/* eof */
   253.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
   253.2 +++ b/deps/glpk/src/glpios08.c	Sun Nov 06 20:59:10 2011 +0100
   253.3 @@ -0,0 +1,907 @@
   253.4 +/* glpios08.c (clique cut generator) */
   253.5 +
   253.6 +/***********************************************************************
   253.7 +*  This code is part of GLPK (GNU Linear Programming Kit).
   253.8 +*
   253.9 +*  Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008,
  253.10 +*  2009, 2010, 2011 Andrew Makhorin, Department for Applied Informatics,
  253.11 +*  Moscow Aviation Institute, Moscow, Russia. All rights reserved.
  253.12 +*  E-mail: <mao@gnu.org>.
  253.13 +*
  253.14 +*  GLPK is free software: you can redistribute it and/or modify it
  253.15 +*  under the terms of the GNU General Public License as published by
  253.16 +*  the Free Software Foundation, either version 3 of the License, or
  253.17 +*  (at your option) any later version.
  253.18 +*
  253.19 +*  GLPK is distributed in the hope that it will be useful, but WITHOUT
  253.20 +*  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
  253.21 +*  or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
  253.22 +*  License for more details.
  253.23 +*
  253.24 +*  You should have received a copy of the GNU General Public License
  253.25 +*  along with GLPK. If not, see <http://www.gnu.org/licenses/>.
  253.26 +***********************************************************************/
  253.27 +
  253.28 +#include "glpios.h"
  253.29 +
  253.30 +static double get_row_lb(LPX *lp, int i)
  253.31 +{     /* this routine returns lower bound of row i or -DBL_MAX if the
  253.32 +         row has no lower bound */
  253.33 +      double lb;
  253.34 +      switch (lpx_get_row_type(lp, i))
  253.35 +      {  case LPX_FR:
  253.36 +         case LPX_UP:
  253.37 +            lb = -DBL_MAX;
  253.38 +            break;
  253.39 +         case LPX_LO:
  253.40 +         case LPX_DB:
  253.41 +         case LPX_FX:
  253.42 +            lb = lpx_get_row_lb(lp, i);
  253.43 +            break;
  253.44 +         default:
  253.45 +            xassert(lp != lp);
  253.46 +      }
  253.47 +      return lb;
  253.48 +}
  253.49 +
  253.50 +static double get_row_ub(LPX *lp, int i)
  253.51 +{     /* this routine returns upper bound of row i or +DBL_MAX if the
  253.52 +         row has no upper bound */
  253.53 +      double ub;
  253.54 +      switch (lpx_get_row_type(lp, i))
  253.55 +      {  case LPX_FR:
  253.56 +         case LPX_LO:
  253.57 +            ub = +DBL_MAX;
  253.58 +            break;
  253.59 +         case LPX_UP:
  253.60 +         case LPX_DB:
  253.61 +         case LPX_FX:
  253.62 +            ub = lpx_get_row_ub(lp, i);
  253.63 +            break;
  253.64 +         default:
  253.65 +            xassert(lp != lp);
  253.66 +      }
  253.67 +      return ub;
  253.68 +}
  253.69 +
  253.70 +static double get_col_lb(LPX *lp, int j)
  253.71 +{     /* this routine returns lower bound of column j or -DBL_MAX if
  253.72 +         the column has no lower bound */
  253.73 +      double lb;
  253.74 +      switch (lpx_get_col_type(lp, j))
  253.75 +      {  case LPX_FR:
  253.76 +         case LPX_UP:
  253.77 +            lb = -DBL_MAX;
  253.78 +            break;
  253.79 +         case LPX_LO:
  253.80 +         case LPX_DB:
  253.81 +         case LPX_FX:
  253.82 +            lb = lpx_get_col_lb(lp, j);
  253.83 +            break;
  253.84 +         default:
  253.85 +            xassert(lp != lp);
  253.86 +      }
  253.87 +      return lb;
  253.88 +}
  253.89 +
  253.90 +static double get_col_ub(LPX *lp, int j)
  253.91 +{     /* this routine returns upper bound of column j or +DBL_MAX if
  253.92 +         the column has no upper bound */
  253.93 +      double ub;
  253.94 +      switch (lpx_get_col_type(lp, j))
  253.95 +      {  case LPX_FR:
  253.96 +         case LPX_LO:
  253.97 +            ub = +DBL_MAX;
  253.98 +            break;
  253.99 +         case LPX_UP:
 253.100 +         case LPX_DB:
 253.101 +         case LPX_FX:
 253.102 +            ub = lpx_get_col_ub(lp, j);
 253.103 +            break;
 253.104 +         default:
 253.105 +            xassert(lp != lp);
 253.106 +      }
 253.107 +      return ub;
 253.108 +}
 253.109 +
 253.110 +static int is_binary(LPX *lp, int j)
 253.111 +{     /* this routine checks if variable x[j] is binary */
 253.112 +      return
 253.113 +         lpx_get_col_kind(lp, j) == LPX_IV &&
 253.114 +         lpx_get_col_type(lp, j) == LPX_DB &&
 253.115 +         lpx_get_col_lb(lp, j) == 0.0 && lpx_get_col_ub(lp, j) == 1.0;
 253.116 +}
 253.117 +
 253.118 +static double eval_lf_min(LPX *lp, int len, int ind[], double val[])
 253.119 +{     /* this routine computes the minimum of a specified linear form
 253.120 +
 253.121 +            sum a[j]*x[j]
 253.122 +             j
 253.123 +
 253.124 +         using the formula:
 253.125 +
 253.126 +            min =   sum   a[j]*lb[j] +   sum   a[j]*ub[j],
 253.127 +                  j in J+              j in J-
 253.128 +
 253.129 +         where J+ = {j: a[j] > 0}, J- = {j: a[j] < 0}, lb[j] and ub[j]
 253.130 +         are lower and upper bound of variable x[j], resp. */
 253.131 +      int j, t;
 253.132 +      double lb, ub, sum;
 253.133 +      sum = 0.0;
 253.134 +      for (t = 1; t <= len; t++)
 253.135 +      {  j = ind[t];
 253.136 +         if (val[t] > 0.0)
 253.137 +         {  lb = get_col_lb(lp, j);
 253.138 +            if (lb == -DBL_MAX)
 253.139 +            {  sum = -DBL_MAX;
 253.140 +               break;
 253.141 +            }
 253.142 +            sum += val[t] * lb;
 253.143 +         }
 253.144 +         else if (val[t] < 0.0)
 253.145 +         {  ub = get_col_ub(lp, j);
 253.146 +            if (ub == +DBL_MAX)
 253.147 +            {  sum = -DBL_MAX;
 253.148 +               break;
 253.149 +            }
 253.150 +            sum += val[t] * ub;
 253.151 +         }
 253.152 +         else
 253.153 +            xassert(val != val);
 253.154 +      }
 253.155 +      return sum;
 253.156 +}
 253.157 +
 253.158 +static double eval_lf_max(LPX *lp, int len, int ind[], double val[])
 253.159 +{     /* this routine computes the maximum of a specified linear form
 253.160 +
 253.161 +            sum a[j]*x[j]
 253.162 +             j
 253.163 +
 253.164 +         using the formula:
 253.165 +
 253.166 +            max =   sum   a[j]*ub[j] +   sum   a[j]*lb[j],
 253.167 +                  j in J+              j in J-
 253.168 +
 253.169 +         where J+ = {j: a[j] > 0}, J- = {j: a[j] < 0}, lb[j] and ub[j]
 253.170 +         are lower and upper bound of variable x[j], resp. */
 253.171 +      int j, t;
 253.172 +      double lb, ub, sum;
 253.173 +      sum = 0.0;
 253.174 +      for (t = 1; t <= len; t++)
 253.175 +      {  j = ind[t];
 253.176 +         if (val[t] > 0.0)
 253.177 +         {  ub = get_col_ub(lp, j);
 253.178 +            if (ub == +DBL_MAX)
 253.179 +            {  sum = +DBL_MAX;
 253.180 +               break;
 253.181 +            }
 253.182 +            sum += val[t] * ub;
 253.183 +         }
 253.184 +         else if (val[t] < 0.0)
 253.185 +         {  lb = get_col_lb(lp, j);
 253.186 +            if (lb == -DBL_MAX)
 253.187 +            {  sum = +DBL_MAX;
 253.188 +               break;
 253.189 +            }
 253.190 +            sum += val[t] * lb;
 253.191 +         }
 253.192 +         else
 253.193 +            xassert(val != val);
 253.194 +      }
 253.195 +      return sum;
 253.196 +}
 253.197 +
 253.198 +/*----------------------------------------------------------------------
 253.199 +-- probing - determine logical relation between binary variables.
 253.200 +--
 253.201 +-- This routine tentatively sets a binary variable to 0 and then to 1
 253.202 +-- and examines whether another binary variable is caused to be fixed.
 253.203 +--
 253.204 +-- The examination is based only on one row (constraint), which is the
 253.205 +-- following:
 253.206 +--
 253.207 +--    L <= sum a[j]*x[j] <= U.                                       (1)
 253.208 +--          j
 253.209 +--
 253.210 +-- Let x[p] be a probing variable, x[q] be an examined variable. Then
 253.211 +-- (1) can be written as:
 253.212 +--
 253.213 +--    L <=   sum  a[j]*x[j] + a[p]*x[p] + a[q]*x[q] <= U,            (2)
 253.214 +--         j in J'
 253.215 +--
 253.216 +-- where J' = {j: j != p and j != q}.
 253.217 +--
 253.218 +-- Let
 253.219 +--
 253.220 +--    L' = L - a[p]*x[p],                                            (3)
 253.221 +--
 253.222 +--    U' = U - a[p]*x[p],                                            (4)
 253.223 +--
 253.224 +-- where x[p] is assumed to be fixed at 0 or 1. So (2) can be rewritten
 253.225 +-- as follows:
 253.226 +--
 253.227 +--    L' <=   sum  a[j]*x[j] + a[q]*x[q] <= U',                      (5)
 253.228 +--          j in J'
 253.229 +--
 253.230 +-- from where we have:
 253.231 +--
 253.232 +--    L' -  sum  a[j]*x[j] <= a[q]*x[q] <= U' -  sum  a[j]*x[j].     (6)
 253.233 +--        j in J'                              j in J'
 253.234 +--
 253.235 +-- Thus,
 253.236 +--
 253.237 +--    min a[q]*x[q] = L' - MAX,                                      (7)
 253.238 +--
 253.239 +--    max a[q]*x[q] = U' - MIN,                                      (8)
 253.240 +--
 253.241 +-- where
 253.242 +--
 253.243 +--    MIN = min  sum  a[j]*x[j],                                     (9)
 253.244 +--             j in J'
 253.245 +--
 253.246 +--    MAX = max  sum  a[j]*x[j].                                    (10)
 253.247 +--             j in J'
 253.248 +--
 253.249 +-- Formulae (7) and (8) allows determining implied lower and upper
 253.250 +-- bounds of x[q].
 253.251 +--
 253.252 +-- Parameters len, val, L and U specify the constraint (1).
 253.253 +--
 253.254 +-- Parameters lf_min and lf_max specify implied lower and upper bounds
 253.255 +-- of the linear form (1). It is assumed that these bounds are computed
 253.256 +-- with the routines eval_lf_min and eval_lf_max (see above).
 253.257 +--
 253.258 +-- Parameter p specifies the probing variable x[p], which is set to 0
 253.259 +-- (if set is 0) or to 1 (if set is 1).
 253.260 +--
 253.261 +-- Parameter q specifies the examined variable x[q].
 253.262 +--
 253.263 +-- On exit the routine returns one of the following codes:
 253.264 +--
 253.265 +-- 0 - there is no logical relation between x[p] and x[q];
 253.266 +-- 1 - x[q] can take only on value 0;
 253.267 +-- 2 - x[q] can take only on value 1. */
 253.268 +
 253.269 +static int probing(int len, double val[], double L, double U,
 253.270 +      double lf_min, double lf_max, int p, int set, int q)
 253.271 +{     double temp;
 253.272 +      xassert(1 <= p && p < q && q <= len);
 253.273 +      /* compute L' (3) */
 253.274 +      if (L != -DBL_MAX && set) L -= val[p];
 253.275 +      /* compute U' (4) */
 253.276 +      if (U != +DBL_MAX && set) U -= val[p];
 253.277 +      /* compute MIN (9) */
 253.278 +      if (lf_min != -DBL_MAX)
 253.279 +      {  if (val[p] < 0.0) lf_min -= val[p];
 253.280 +         if (val[q] < 0.0) lf_min -= val[q];
 253.281 +      }
 253.282 +      /* compute MAX (10) */
 253.283 +      if (lf_max != +DBL_MAX)
 253.284 +      {  if (val[p] > 0.0) lf_max -= val[p];
 253.285 +         if (val[q] > 0.0) lf_max -= val[q];
 253.286 +      }
 253.287 +      /* compute implied lower bound of x[q]; see (7), (8) */
 253.288 +      if (val[q] > 0.0)
 253.289 +      {  if (L == -DBL_MAX || lf_max == +DBL_MAX)
 253.290 +            temp = -DBL_MAX;
 253.291 +         else
 253.292 +            temp = (L - lf_max) / val[q];
 253.293 +      }
 253.294 +      else
 253.295 +      {  if (U == +DBL_MAX || lf_min == -DBL_MAX)
 253.296 +            temp = -DBL_MAX;
 253.297 +         else
 253.298 +            temp = (U - lf_min) / val[q];
 253.299 +      }
 253.300 +      if (temp > 0.001) return 2;
 253.301 +      /* compute implied upper bound of x[q]; see (7), (8) */
 253.302 +      if (val[q] > 0.0)
 253.303 +      {  if (U == +DBL_MAX || lf_min == -DBL_MAX)
 253.304 +            temp = +DBL_MAX;
 253.305 +         else
 253.306 +            temp = (U - lf_min) / val[q];
 253.307 +      }
 253.308 +      else
 253.309 +      {  if (L == -DBL_MAX || lf_max == +DBL_MAX)
 253.310 +            temp = +DBL_MAX;
 253.311 +         else
 253.312 +            temp = (L - lf_max) / val[q];
 253.313 +      }
 253.314 +      if (temp < 0.999) return 1;
 253.315 +      /* there is no logical relation between x[p] and x[q] */
 253.316 +      return 0;
 253.317 +}
 253.318 +
 253.319 +struct COG
 253.320 +{     /* conflict graph; it represents logical relations between binary
 253.321 +         variables and has a vertex for each binary variable and its
 253.322 +         complement, and an edge between two vertices when at most one
 253.323 +         of the variables represented by the vertices can equal one in
 253.324 +         an optimal solution */
 253.325 +      int n;
 253.326 +      /* number of variables */
 253.327 +      int nb;
 253.328 +      /* number of binary variables represented in the graph (note that
 253.329 +         not all binary variables can be represented); vertices which
 253.330 +         correspond to binary variables have numbers 1, ..., nb while
 253.331 +         vertices which correspond to complements of binary variables
 253.332 +         have numbers nb+1, ..., nb+nb */
 253.333 +      int ne;
 253.334 +      /* number of edges in the graph */
 253.335 +      int *vert; /* int vert[1+n]; */
 253.336 +      /* if x[j] is a binary variable represented in the graph, vert[j]
 253.337 +         is the vertex number corresponding to x[j]; otherwise vert[j]
 253.338 +         is zero */
 253.339 +      int *orig; /* int list[1:nb]; */
 253.340 +      /* if vert[j] = k > 0, then orig[k] = j */
 253.341 +      unsigned char *a;
 253.342 +      /* adjacency matrix of the graph having 2*nb rows and columns;
 253.343 +         only strict lower triangle is stored in dense packed form */
 253.344 +};
 253.345 +
 253.346 +/*----------------------------------------------------------------------
 253.347 +-- lpx_create_cog - create the conflict graph.
 253.348 +--
 253.349 +-- SYNOPSIS
 253.350 +--
 253.351 +-- #include "glplpx.h"
 253.352 +-- void *lpx_create_cog(LPX *lp);
 253.353 +--
 253.354 +-- DESCRIPTION
 253.355 +--
 253.356 +-- The routine lpx_create_cog creates the conflict graph for a given
 253.357 +-- problem instance.
 253.358 +--
 253.359 +-- RETURNS
 253.360 +--
 253.361 +-- If the graph has been created, the routine returns a pointer to it.
 253.362 +-- Otherwise the routine returns NULL. */
 253.363 +
 253.364 +#define MAX_NB 4000
 253.365 +#define MAX_ROW_LEN 500
 253.366 +
 253.367 +static void lpx_add_cog_edge(void *_cog, int i, int j);
 253.368 +
 253.369 +static void *lpx_create_cog(LPX *lp)
 253.370 +{     struct COG *cog = NULL;
 253.371 +      int m, n, nb, i, j, p, q, len, *ind, *vert, *orig;
 253.372 +      double L, U, lf_min, lf_max, *val;
 253.373 +      xprintf("Creating the conflict graph...\n");
 253.374 +      m = lpx_get_num_rows(lp);
 253.375 +      n = lpx_get_num_cols(lp);
 253.376 +      /* determine which binary variables should be included in the
 253.377 +         conflict graph */
 253.378 +      nb = 0;
 253.379 +      vert = xcalloc(1+n, sizeof(int));
 253.380 +      for (j = 1; j <= n; j++) vert[j] = 0;
 253.381 +      orig = xcalloc(1+n, sizeof(int));
 253.382 +      ind = xcalloc(1+n, sizeof(int));
 253.383 +      val = xcalloc(1+n, sizeof(double));
 253.384 +      for (i = 1; i <= m; i++)
 253.385 +      {  L = get_row_lb(lp, i);
 253.386 +         U = get_row_ub(lp, i);
 253.387 +         if (L == -DBL_MAX && U == +DBL_MAX) continue;
 253.388 +         len = lpx_get_mat_row(lp, i, ind, val);
 253.389 +         if (len > MAX_ROW_LEN) continue;
 253.390 +         lf_min = eval_lf_min(lp, len, ind, val);
 253.391 +         lf_max = eval_lf_max(lp, len, ind, val);
 253.392 +         for (p = 1; p <= len; p++)
 253.393 +         {  if (!is_binary(lp, ind[p])) continue;
 253.394 +            for (q = p+1; q <= len; q++)
 253.395 +            {  if (!is_binary(lp, ind[q])) continue;
 253.396 +               if (probing(len, val, L, U, lf_min, lf_max, p, 0, q) ||
 253.397 +                   probing(len, val, L, U, lf_min, lf_max, p, 1, q))
 253.398 +               {  /* there is a logical relation */
 253.399 +                  /* include the first variable in the graph */
 253.400 +                  j = ind[p];
 253.401 +                  if (vert[j] == 0) nb++, vert[j] = nb, orig[nb] = j;
 253.402 +                  /* incude the second variable in the graph */
 253.403 +                  j = ind[q];
 253.404 +                  if (vert[j] == 0) nb++, vert[j] = nb, orig[nb] = j;
 253.405 +               }
 253.406 +            }
 253.407 +         }
 253.408 +      }
 253.409 +      /* if the graph is either empty or has too many vertices, do not
 253.410 +         create it */
 253.411 +      if (nb == 0 || nb > MAX_NB)
 253.412 +      {  xprintf("The conflict graph is either empty or too big\n");
 253.413 +         xfree(vert);
 253.414 +         xfree(orig);
 253.415 +         goto done;
 253.416 +      }
 253.417 +      /* create the conflict graph */
 253.418 +      cog = xmalloc(sizeof(struct COG));
 253.419 +      cog->n = n;
 253.420 +      cog->nb = nb;
 253.421 +      cog->ne = 0;
 253.422 +      cog->vert = vert;
 253.423 +      cog->orig = orig;
 253.424 +      len = nb + nb; /* number of vertices */
 253.425 +      len = (len * (len - 1)) / 2; /* number of entries in triangle */
 253.426 +      len = (len + (CHAR_BIT - 1)) / CHAR_BIT; /* bytes needed */
 253.427 +      cog->a = xmalloc(len);
 253.428 +      memset(cog->a, 0, len);
 253.429 +      for (j = 1; j <= nb; j++)
 253.430 +      {  /* add edge between variable and its complement */
 253.431 +         lpx_add_cog_edge(cog, +orig[j], -orig[j]);
 253.432 +      }
 253.433 +      for (i = 1; i <= m; i++)
 253.434 +      {  L = get_row_lb(lp, i);
 253.435 +         U = get_row_ub(lp, i);
 253.436 +         if (L == -DBL_MAX && U == +DBL_MAX) continue;
 253.437 +         len = lpx_get_mat_row(lp, i, ind, val);
 253.438 +         if (len > MAX_ROW_LEN) continue;
 253.439 +         lf_min = eval_lf_min(lp, len, ind, val);
 253.440 +         lf_max = eval_lf_max(lp, len, ind, val);
 253.441 +         for (p = 1; p <= len; p++)
 253.442 +         {  if (!is_binary(lp, ind[p])) continue;
 253.443 +            for (q = p+1; q <= len; q++)
 253.444 +            {  if (!is_binary(lp, ind[q])) continue;
 253.445 +               /* set x[p] to 0 and examine x[q] */
 253.446 +               switch (probing(len, val, L, U, lf_min, lf_max, p, 0, q))
 253.447 +               {  case 0:
 253.448 +                     /* no logical relation */
 253.449 +                     break;
 253.450 +                  case 1:
 253.451 +                     /* x[p] = 0 implies x[q] = 0 */
 253.452 +                     lpx_add_cog_edge(cog, -ind[p], +ind[q]);
 253.453 +                     break;
 253.454 +                  case 2:
 253.455 +                     /* x[p] = 0 implies x[q] = 1 */
 253.456 +                     lpx_add_cog_edge(cog, -ind[p], -ind[q]);
 253.457 +                     break;
 253.458 +                  default:
 253.459 +                     xassert(lp != lp);
 253.460 +               }
 253.461 +               /* set x[p] to 1 and examine x[q] */
 253.462 +               switch (probing(len, val, L, U, lf_min, lf_max, p, 1, q))
 253.463 +               {  case 0:
 253.464 +                     /* no logical relation */
 253.465 +                     break;
 253.466 +                  case 1:
 253.467 +                     /* x[p] = 1 implies x[q] = 0 */
 253.468 +                     lpx_add_cog_edge(cog, +ind[p], +ind[q]);
 253.469 +                     break;
 253.470 +                  case 2:
 253.471 +                     /* x[p] = 1 implies x[q] = 1 */
 253.472 +                     lpx_add_cog_edge(cog, +ind[p], -ind[q]);
 253.473 +                     break;
 253.474 +                  default:
 253.475 +                     xassert(lp != lp);
 253.476 +               }
 253.477 +            }
 253.478 +         }
 253.479 +      }
 253.480 +      xprintf("The conflict graph has 2*%d vertices and %d edges\n",
 253.481 +         cog->nb, cog->ne);
 253.482 +done: xfree(ind);
 253.483 +      xfree(val);
 253.484 +      return cog;
 253.485 +}
 253.486 +
 253.487 +/*----------------------------------------------------------------------
 253.488 +-- lpx_add_cog_edge - add edge to the conflict graph.
 253.489 +--
 253.490 +-- SYNOPSIS
 253.491 +--
 253.492 +-- #include "glplpx.h"
 253.493 +-- void lpx_add_cog_edge(void *cog, int i, int j);
 253.494 +--
 253.495 +-- DESCRIPTION
 253.496 +--
 253.497 +-- The routine lpx_add_cog_edge adds an edge to the conflict graph.
 253.498 +-- The edge connects x[i] (if i > 0) or its complement (if i < 0) and
 253.499 +-- x[j] (if j > 0) or its complement (if j < 0), where i and j are
 253.500 +-- original ordinal numbers of corresponding variables. */
 253.501 +
 253.502 +static void lpx_add_cog_edge(void *_cog, int i, int j)
 253.503 +{     struct COG *cog = _cog;
 253.504 +      int k;
 253.505 +      xassert(i != j);
 253.506 +      /* determine indices of corresponding vertices */
 253.507 +      if (i > 0)
 253.508 +      {  xassert(1 <= i && i <= cog->n);
 253.509 +         i = cog->vert[i];
 253.510 +         xassert(i != 0);
 253.511 +      }
 253.512 +      else
 253.513 +      {  i = -i;
 253.514 +         xassert(1 <= i && i <= cog->n);
 253.515 +         i = cog->vert[i];
 253.516 +         xassert(i != 0);
 253.517 +         i += cog->nb;
 253.518 +      }
 253.519 +      if (j > 0)
 253.520 +      {  xassert(1 <= j && j <= cog->n);
 253.521 +         j = cog->vert[j];
 253.522 +         xassert(j != 0);
 253.523 +      }
 253.524 +      else
 253.525 +      {  j = -j;
 253.526 +         xassert(1 <= j && j <= cog->n);
 253.527 +         j = cog->vert[j];
 253.528 +         xassert(j != 0);
 253.529 +         j += cog->nb;
 253.530 +      }
 253.531 +      /* only lower triangle is stored, so we need i > j */
 253.532 +      if (i < j) k = i, i = j, j = k;
 253.533 +      k = ((i - 1) * (i - 2)) / 2 + (j - 1);
 253.534 +      cog->a[k / CHAR_BIT] |=
 253.535 +         (unsigned char)(1 << ((CHAR_BIT - 1) - k % CHAR_BIT));
 253.536 +      cog->ne++;
 253.537 +      return;
 253.538 +}
 253.539 +
 253.540 +/*----------------------------------------------------------------------
 253.541 +-- MAXIMUM WEIGHT CLIQUE
 253.542 +--
 253.543 +-- Two subroutines sub() and wclique() below are intended to find a
 253.544 +-- maximum weight clique in a given undirected graph. These subroutines
 253.545 +-- are slightly modified version of the program WCLIQUE developed by
 253.546 +-- Patric Ostergard <http://www.tcs.hut.fi/~pat/wclique.html> and based
 253.547 +-- on ideas from the article "P. R. J. Ostergard, A new algorithm for
 253.548 +-- the maximum-weight clique problem, submitted for publication", which
 253.549 +-- in turn is a generalization of the algorithm for unweighted graphs
 253.550 +-- presented in "P. R. J. Ostergard, A fast algorithm for the maximum
 253.551 +-- clique problem, submitted for publication".
 253.552 +--
 253.553 +-- USED WITH PERMISSION OF THE AUTHOR OF THE ORIGINAL CODE. */
 253.554 +
 253.555 +struct dsa
 253.556 +{     /* dynamic storage area */
 253.557 +      int n;
 253.558 +      /* number of vertices */
 253.559 +      int *wt; /* int wt[0:n-1]; */
 253.560 +      /* weights */
 253.561 +      unsigned char *a;
 253.562 +      /* adjacency matrix (packed lower triangle without main diag.) */
 253.563 +      int record;
 253.564 +      /* weight of best clique */
 253.565 +      int rec_level;
 253.566 +      /* number of vertices in best clique */
 253.567 +      int *rec; /* int rec[0:n-1]; */
 253.568 +      /* best clique so far */
 253.569 +      int *clique; /* int clique[0:n-1]; */
 253.570 +      /* table for pruning */
 253.571 +      int *set; /* int set[0:n-1]; */
 253.572 +      /* current clique */
 253.573 +};
 253.574 +
 253.575 +#define n         (dsa->n)
 253.576 +#define wt        (dsa->wt)
 253.577 +#define a         (dsa->a)
 253.578 +#define record    (dsa->record)
 253.579 +#define rec_level (dsa->rec_level)
 253.580 +#define rec       (dsa->rec)
 253.581 +#define clique    (dsa->clique)
 253.582 +#define set       (dsa->set)
 253.583 +
 253.584 +#if 0
 253.585 +static int is_edge(struct dsa *dsa, int i, int j)
 253.586 +{     /* if there is arc (i,j), the routine returns true; otherwise
 253.587 +         false; 0 <= i, j < n */
 253.588 +      int k;
 253.589 +      xassert(0 <= i && i < n);
 253.590 +      xassert(0 <= j && j < n);
 253.591 +      if (i == j) return 0;
 253.592 +      if (i < j) k = i, i = j, j = k;
 253.593 +      k = (i * (i - 1)) / 2 + j;
 253.594 +      return a[k / CHAR_BIT] &
 253.595 +         (unsigned char)(1 << ((CHAR_BIT - 1) - k % CHAR_BIT));
 253.596 +}
 253.597 +#else
 253.598 +#define is_edge(dsa, i, j) ((i) == (j) ? 0 : \
 253.599 +      (i) > (j) ? is_edge1(i, j) : is_edge1(j, i))
 253.600 +#define is_edge1(i, j) is_edge2(((i) * ((i) - 1)) / 2 + (j))
 253.601 +#define is_edge2(k) (a[(k) / CHAR_BIT] & \
 253.602 +      (unsigned char)(1 << ((CHAR_BIT - 1) - (k) % CHAR_BIT)))
 253.603 +#endif
 253.604 +
 253.605 +static void sub(struct dsa *dsa, int ct, int table[], int level,
 253.606 +      int weight, int l_weight)
 253.607 +{     int i, j, k, curr_weight, left_weight, *p1, *p2, *newtable;
 253.608 +      newtable = xcalloc(n, sizeof(int));
 253.609 +      if (ct <= 0)
 253.610 +      {  /* 0 or 1 elements left; include these */
 253.611 +         if (ct == 0)
 253.612 +         {  set[level++] = table[0];
 253.613 +            weight += l_weight;
 253.614 +         }
 253.615 +         if (weight > record)
 253.616 +         {  record = weight;
 253.617 +            rec_level = level;
 253.618 +            for (i = 0; i < level; i++) rec[i] = set[i];
 253.619 +         }
 253.620 +         goto done;
 253.621 +      }
 253.622 +      for (i = ct; i >= 0; i--)
 253.623 +      {  if ((level == 0) && (i < ct)) goto done;
 253.624 +         k = table[i];
 253.625 +         if ((level > 0) && (clique[k] <= (record - weight)))
 253.626 +            goto done; /* prune */
 253.627 +         set[level] = k;
 253.628 +         curr_weight = weight + wt[k];
 253.629 +         l_weight -= wt[k];
 253.630 +         if (l_weight <= (record - curr_weight))
 253.631 +            goto done; /* prune */
 253.632 +         p1 = newtable;
 253.633 +         p2 = table;
 253.634 +         left_weight = 0;
 253.635 +         while (p2 < table + i)
 253.636 +         {  j = *p2++;
 253.637 +            if (is_edge(dsa, j, k))
 253.638 +            {  *p1++ = j;
 253.639 +               left_weight += wt[j];
 253.640 +            }
 253.641 +         }
 253.642 +         if (left_weight <= (record - curr_weight)) continue;
 253.643 +         sub(dsa, p1 - newtable - 1, newtable, level + 1, curr_weight,
 253.644 +            left_weight);
 253.645 +      }
 253.646 +done: xfree(newtable);
 253.647 +      return;
 253.648 +}
 253.649 +
 253.650 +static int wclique(int _n, int w[], unsigned char _a[], int sol[])
 253.651 +{     struct dsa _dsa, *dsa = &_dsa;
 253.652 +      int i, j, p, max_wt, max_nwt, wth, *used, *nwt, *pos;
 253.653 +      glp_long timer;
 253.654 +      n = _n;
 253.655 +      wt = &w[1];
 253.656 +      a = _a;
 253.657 +      record = 0;
 253.658 +      rec_level = 0;
 253.659 +      rec = &sol[1];
 253.660 +      clique = xcalloc(n, sizeof(int));
 253.661 +      set = xcalloc(n, sizeof(int));
 253.662 +      used = xcalloc(n, sizeof(int));
 253.663 +      nwt = xcalloc(n, sizeof(int));
 253.664 +      pos = xcalloc(n, sizeof(int));
 253.665 +      /* start timer */
 253.666 +      timer = xtime();
 253.667 +      /* order vertices */
 253.668 +      for (i = 0; i < n; i++)
 253.669 +      {  nwt[i] = 0;
 253.670 +         for (j = 0; j < n; j++)
 253.671 +            if (is_edge(dsa, i, j)) nwt[i] += wt[j];
 253.672 +      }
 253.673 +      for (i = 0; i < n; i++)
 253.674 +         used[i] = 0;
 253.675 +      for (i = n-1; i >= 0; i--)
 253.676 +      {  max_wt = -1;
 253.677 +         max_nwt = -1;
 253.678 +         for (j = 0; j < n; j++)
 253.679 +         {  if ((!used[j]) && ((wt[j] > max_wt) || (wt[j] == max_wt
 253.680 +               && nwt[j] > max_nwt)))
 253.681 +            {  max_wt = wt[j];
 253.682 +               max_nwt = nwt[j];
 253.683 +               p = j;
 253.684 +            }
 253.685 +         }
 253.686 +         pos[i] = p;
 253.687 +         used[p] = 1;
 253.688 +         for (j = 0; j < n; j++)
 253.689 +            if ((!used[j]) && (j != p) && (is_edge(dsa, p, j)))
 253.690 +               nwt[j] -= wt[p];
 253.691 +      }
 253.692 +      /* main routine */
 253.693 +      wth = 0;
 253.694 +      for (i = 0; i < n; i++)
 253.695 +      {  wth += wt[pos[i]];
 253.696 +         sub(dsa, i, pos, 0, 0, wth);
 253.697 +         clique[pos[i]] = record;
 253.698 +#if 0
 253.699 +         if (utime() >= timer + 5.0)
 253.700 +#else
 253.701 +         if (xdifftime(xtime(), timer) >= 5.0 - 0.001)
 253.702 +#endif
 253.703 +         {  /* print current record and reset timer */
 253.704 +            xprintf("level = %d (%d); best = %d\n", i+1, n, record);
 253.705 +#if 0
 253.706 +            timer = utime();
 253.707 +#else
 253.708 +            timer = xtime();
 253.709 +#endif
 253.710 +         }
 253.711 +      }
 253.712 +      xfree(clique);
 253.713 +      xfree(set);
 253.714 +      xfree(used);
 253.715 +      xfree(nwt);
 253.716 +      xfree(pos);
 253.717 +      /* return the solution found */
 253.718 +      for (i = 1; i <= rec_level; i++) sol[i]++;
 253.719 +      return rec_level;
 253.720 +}
 253.721 +
 253.722 +#undef n
 253.723 +#undef wt
 253.724 +#undef a
 253.725 +#undef record
 253.726 +#undef rec_level
 253.727 +#undef rec
 253.728 +#undef clique
 253.729 +#undef set
 253.730 +
 253.731 +/*----------------------------------------------------------------------
 253.732 +-- lpx_clique_cut - generate cluque cut.
 253.733 +--
 253.734 +-- SYNOPSIS
 253.735 +--
 253.736 +-- #include "glplpx.h"
 253.737 +-- int lpx_clique_cut(LPX *lp, void *cog, int ind[], double val[]);
 253.738 +--
 253.739 +-- DESCRIPTION
 253.740 +--
 253.741 +-- The routine lpx_clique_cut generates a clique cut using the conflict
 253.742 +-- graph specified by the parameter cog.
 253.743 +--
 253.744 +-- If a violated clique cut has been found, it has the following form:
 253.745 +--
 253.746 +--    sum{j in J} a[j]*x[j] <= b.
 253.747 +--
 253.748 +-- Variable indices j in J are stored in elements ind[1], ..., ind[len]
 253.749 +-- while corresponding constraint coefficients are stored in elements
 253.750 +-- val[1], ..., val[len], where len is returned on exit. The right-hand
 253.751 +-- side b is stored in element val[0].
 253.752 +--
 253.753 +-- RETURNS
 253.754 +--
 253.755 +-- If the cutting plane has been successfully generated, the routine
 253.756 +-- returns 1 <= len <= n, which is the number of non-zero coefficients
 253.757 +-- in the inequality constraint. Otherwise, the routine returns zero. */
 253.758 +
 253.759 +static int lpx_clique_cut(LPX *lp, void *_cog, int ind[], double val[])
 253.760 +{     struct COG *cog = _cog;
 253.761 +      int n = lpx_get_num_cols(lp);
 253.762 +      int j, t, v, card, temp, len = 0, *w, *sol;
 253.763 +      double x, sum, b, *vec;
 253.764 +      /* allocate working arrays */
 253.765 +      w = xcalloc(1 + 2 * cog->nb, sizeof(int));
 253.766 +      sol = xcalloc(1 + 2 * cog->nb, sizeof(int));
 253.767 +      vec = xcalloc(1+n, sizeof(double));
 253.768 +      /* assign weights to vertices of the conflict graph */
 253.769 +      for (t = 1; t <= cog->nb; t++)
 253.770 +      {  j = cog->orig[t];
 253.771 +         x = lpx_get_col_prim(lp, j);
 253.772 +         temp = (int)(100.0 * x + 0.5);
 253.773 +         if (temp < 0) temp = 0;
 253.774 +         if (temp > 100) temp = 100;
 253.775 +         w[t] = temp;
 253.776 +         w[cog->nb + t] = 100 - temp;
 253.777 +      }
 253.778 +      /* find a clique of maximum weight */
 253.779 +      card = wclique(2 * cog->nb, w, cog->a, sol);
 253.780 +      /* compute the clique weight for unscaled values */
 253.781 +      sum = 0.0;
 253.782 +      for ( t = 1; t <= card; t++)
 253.783 +      {  v = sol[t];
 253.784 +         xassert(1 <= v && v <= 2 * cog->nb);
 253.785 +         if (v <= cog->nb)
 253.786 +         {  /* vertex v corresponds to binary variable x[j] */
 253.787 +            j = cog->orig[v];
 253.788 +            x = lpx_get_col_prim(lp, j);
 253.789 +            sum += x;
 253.790 +         }
 253.791 +         else
 253.792 +         {  /* vertex v corresponds to the complement of x[j] */
 253.793 +            j = cog->orig[v - cog->nb];
 253.794 +            x = lpx_get_col_prim(lp, j);
 253.795 +            sum += 1.0 - x;
 253.796 +         }
 253.797 +      }
 253.798 +      /* if the sum of binary variables and their complements in the
 253.799 +         clique greater than 1, the clique cut is violated */
 253.800 +      if (sum >= 1.01)
 253.801 +      {  /* construct the inquality */
 253.802 +         for (j = 1; j <= n; j++) vec[j] = 0;
 253.803 +         b = 1.0;
 253.804 +         for (t = 1; t <= card; t++)
 253.805 +         {  v = sol[t];
 253.806 +            if (v <= cog->nb)
 253.807 +            {  /* vertex v corresponds to binary variable x[j] */
 253.808 +               j = cog->orig[v];
 253.809 +               xassert(1 <= j && j <= n);
 253.810 +               vec[j] += 1.0;
 253.811 +            }
 253.812 +            else
 253.813 +            {  /* vertex v corresponds to the complement of x[j] */
 253.814 +               j = cog->orig[v - cog->nb];
 253.815 +               xassert(1 <= j && j <= n);
 253.816 +               vec[j] -= 1.0;
 253.817 +               b -= 1.0;
 253.818 +            }
 253.819 +         }
 253.820 +         xassert(len == 0);
 253.821 +         for (j = 1; j <= n; j++)
 253.822 +         {  if (vec[j] != 0.0)
 253.823 +            {  len++;
 253.824 +               ind[len] = j, val[len] = vec[j];
 253.825 +            }
 253.826 +         }
 253.827 +         ind[0] = 0, val[0] = b;
 253.828 +      }
 253.829 +      /* free working arrays */
 253.830 +      xfree(w);
 253.831 +      xfree(sol);
 253.832 +      xfree(vec);
 253.833 +      /* return to the calling program */
 253.834 +      return len;
 253.835 +}
 253.836 +
 253.837 +/*----------------------------------------------------------------------
 253.838 +-- lpx_delete_cog - delete the conflict graph.
 253.839 +--
 253.840 +-- SYNOPSIS
 253.841 +--
 253.842 +-- #include "glplpx.h"
 253.843 +-- void lpx_delete_cog(void *cog);
 253.844 +--
 253.845 +-- DESCRIPTION
 253.846 +--
 253.847 +-- The routine lpx_delete_cog deletes the conflict graph, which the
 253.848 +-- parameter cog points to, freeing all the memory allocated to this
 253.849 +-- object. */
 253.850 +
 253.851 +static void lpx_delete_cog(void *_cog)
 253.852 +{     struct COG *cog = _cog;
 253.853 +      xfree(cog->vert);
 253.854 +      xfree(cog->orig);
 253.855 +      xfree(cog->a);
 253.856 +      xfree(cog);
 253.857 +}
 253.858 +
 253.859 +/**********************************************************************/
 253.860 +
 253.861 +void *ios_clq_init(glp_tree *tree)
 253.862 +{     /* initialize clique cut generator */
 253.863 +      glp_prob *mip = tree->mip;
 253.864 +      xassert(mip != NULL);
 253.865 +      return lpx_create_cog(mip);
 253.866 +}
 253.867 +
 253.868 +/***********************************************************************
 253.869 +*  NAME
 253.870 +*
 253.871 +*  ios_clq_gen - generate clique cuts
 253.872 +*
 253.873 +*  SYNOPSIS
 253.874 +*
 253.875 +*  #include "glpios.h"
 253.876 +*  void ios_clq_gen(glp_tree *tree, void *gen);
 253.877 +*
 253.878 +*  DESCRIPTION
 253.879 +*
 253.880 +*  The routine ios_clq_gen generates clique cuts for the current point
 253.881 +*  and adds them to the clique pool. */
 253.882 +
 253.883 +void ios_clq_gen(glp_tree *tree, void *gen)
 253.884 +{     int n = lpx_get_num_cols(tree->mip);
 253.885 +      int len, *ind;
 253.886 +      double *val;
 253.887 +      xassert(gen != NULL);
 253.888 +      ind = xcalloc(1+n, sizeof(int));
 253.889 +      val = xcalloc(1+n, sizeof(double));
 253.890 +      len = lpx_clique_cut(tree->mip, gen, ind, val);
 253.891 +      if (len > 0)
 253.892 +      {  /* xprintf("len = %d\n", len); */
 253.893 +         glp_ios_add_row(tree, NULL, GLP_RF_CLQ, 0, len, ind, val,
 253.894 +            GLP_UP, val[0]);
 253.895 +      }
 253.896 +      xfree(ind);
 253.897 +      xfree(val);
 253.898 +      return;
 253.899 +}
 253.900 +
 253.901 +/**********************************************************************/
 253.902 +
 253.903 +void ios_clq_term(void *gen)
 253.904 +{     /* terminate clique cut generator */
 253.905 +      xassert(gen != NULL);
 253.906 +      lpx_delete_cog(gen);
 253.907 +      return;
 253.908 +}
 253.909 +
 253.910 +/* eof */
   254.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
   254.2 +++ b/deps/glpk/src/glpios09.c	Sun Nov 06 20:59:10 2011 +0100
   254.3 @@ -0,0 +1,659 @@
   254.4 +/* glpios09.c (branching heuristics) */
   254.5 +
   254.6 +/***********************************************************************
   254.7 +*  This code is part of GLPK (GNU Linear Programming Kit).
   254.8 +*
   254.9 +*  Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008,
  254.10 +*  2009, 2010, 2011 Andrew Makhorin, Department for Applied Informatics,
  254.11 +*  Moscow Aviation Institute, Moscow, Russia. All rights reserved.
  254.12 +*  E-mail: <mao@gnu.org>.
  254.13 +*
  254.14 +*  GLPK is free software: you can redistribute it and/or modify it
  254.15 +*  under the terms of the GNU General Public License as published by
  254.16 +*  the Free Software Foundation, either version 3 of the License, or
  254.17 +*  (at your option) any later version.
  254.18 +*
  254.19 +*  GLPK is distributed in the hope that it will be useful, but WITHOUT
  254.20 +*  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
  254.21 +*  or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
  254.22 +*  License for more details.
  254.23 +*
  254.24 +*  You should have received a copy of the GNU General Public License
  254.25 +*  along with GLPK. If not, see <http://www.gnu.org/licenses/>.
  254.26 +***********************************************************************/
  254.27 +
  254.28 +#include "glpios.h"
  254.29 +
  254.30 +/***********************************************************************
  254.31 +*  NAME
  254.32 +*
  254.33 +*  ios_choose_var - select variable to branch on
  254.34 +*
  254.35 +*  SYNOPSIS
  254.36 +*
  254.37 +*  #include "glpios.h"
  254.38 +*  int ios_choose_var(glp_tree *T, int *next);
  254.39 +*
  254.40 +*  The routine ios_choose_var chooses a variable from the candidate
  254.41 +*  list to branch on. Additionally the routine provides a flag stored
  254.42 +*  in the location next to suggests which of the child subproblems
  254.43 +*  should be solved next.
  254.44 +*
  254.45 +*  RETURNS
  254.46 +*
  254.47 +*  The routine ios_choose_var returns the ordinal number of the column
  254.48 +*  choosen. */
  254.49 +
  254.50 +static int branch_first(glp_tree *T, int *next);
  254.51 +static int branch_last(glp_tree *T, int *next);
  254.52 +static int branch_mostf(glp_tree *T, int *next);
  254.53 +static int branch_drtom(glp_tree *T, int *next);
  254.54 +
  254.55 +int ios_choose_var(glp_tree *T, int *next)
  254.56 +{     int j;
  254.57 +      if (T->parm->br_tech == GLP_BR_FFV)
  254.58 +      {  /* branch on first fractional variable */
  254.59 +         j = branch_first(T, next);
  254.60 +      }
  254.61 +      else if (T->parm->br_tech == GLP_BR_LFV)
  254.62 +      {  /* branch on last fractional variable */
  254.63 +         j = branch_last(T, next);
  254.64 +      }
  254.65 +      else if (T->parm->br_tech == GLP_BR_MFV)
  254.66 +      {  /* branch on most fractional variable */
  254.67 +         j = branch_mostf(T, next);
  254.68 +      }
  254.69 +      else if (T->parm->br_tech == GLP_BR_DTH)
  254.70 +      {  /* branch using the heuristic by Dreebeck and Tomlin */
  254.71 +         j = branch_drtom(T, next);
  254.72 +      }
  254.73 +      else if (T->parm->br_tech == GLP_BR_PCH)
  254.74 +      {  /* hybrid pseudocost heuristic */
  254.75 +         j = ios_pcost_branch(T, next);
  254.76 +      }
  254.77 +      else
  254.78 +         xassert(T != T);
  254.79 +      return j;
  254.80 +}
  254.81 +
  254.82 +/***********************************************************************
  254.83 +*  branch_first - choose first branching variable
  254.84 +*
  254.85 +*  This routine looks up the list of structural variables and chooses
  254.86 +*  the first one, which is of integer kind and has fractional value in
  254.87 +*  optimal solution to the current LP relaxation.
  254.88 +*
  254.89 +*  This routine also selects the branch to be solved next where integer
  254.90 +*  infeasibility of the chosen variable is less than in other one. */
  254.91 +
  254.92 +static int branch_first(glp_tree *T, int *_next)
  254.93 +{     int j, next;
  254.94 +      double beta;
  254.95 +      /* choose the column to branch on */
  254.96 +      for (j = 1; j <= T->n; j++)
  254.97 +         if (T->non_int[j]) break;
  254.98 +      xassert(1 <= j && j <= T->n);
  254.99 +      /* select the branch to be solved next */
 254.100 +      beta = glp_get_col_prim(T->mip, j);
 254.101 +      if (beta - floor(beta) < ceil(beta) - beta)
 254.102 +         next = GLP_DN_BRNCH;
 254.103 +      else
 254.104 +         next = GLP_UP_BRNCH;
 254.105 +      *_next = next;
 254.106 +      return j;
 254.107 +}
 254.108 +
 254.109 +/***********************************************************************
 254.110 +*  branch_last - choose last branching variable
 254.111 +*
 254.112 +*  This routine looks up the list of structural variables and chooses
 254.113 +*  the last one, which is of integer kind and has fractional value in
 254.114 +*  optimal solution to the current LP relaxation.
 254.115 +*
 254.116 +*  This routine also selects the branch to be solved next where integer
 254.117 +*  infeasibility of the chosen variable is less than in other one. */
 254.118 +
 254.119 +static int branch_last(glp_tree *T, int *_next)
 254.120 +{     int j, next;
 254.121 +      double beta;
 254.122 +      /* choose the column to branch on */
 254.123 +      for (j = T->n; j >= 1; j--)
 254.124 +         if (T->non_int[j]) break;
 254.125 +      xassert(1 <= j && j <= T->n);
 254.126 +      /* select the branch to be solved next */
 254.127 +      beta = glp_get_col_prim(T->mip, j);
 254.128 +      if (beta - floor(beta) < ceil(beta) - beta)
 254.129 +         next = GLP_DN_BRNCH;
 254.130 +      else
 254.131 +         next = GLP_UP_BRNCH;
 254.132 +      *_next = next;
 254.133 +      return j;
 254.134 +}
 254.135 +
 254.136 +/***********************************************************************
 254.137 +*  branch_mostf - choose most fractional branching variable
 254.138 +*
 254.139 +*  This routine looks up the list of structural variables and chooses
 254.140 +*  that one, which is of integer kind and has most fractional value in
 254.141 +*  optimal solution to the current LP relaxation.
 254.142 +*
 254.143 +*  This routine also selects the branch to be solved next where integer
 254.144 +*  infeasibility of the chosen variable is less than in other one.
 254.145 +*
 254.146 +*  (Alexander Martin notices that "...most infeasible is as good as
 254.147 +*  random...".) */
 254.148 +
 254.149 +static int branch_mostf(glp_tree *T, int *_next)
 254.150 +{     int j, jj, next;
 254.151 +      double beta, most, temp;
 254.152 +      /* choose the column to branch on */
 254.153 +      jj = 0, most = DBL_MAX;
 254.154 +      for (j = 1; j <= T->n; j++)
 254.155 +      {  if (T->non_int[j])
 254.156 +         {  beta = glp_get_col_prim(T->mip, j);
 254.157 +            temp = floor(beta) + 0.5;
 254.158 +            if (most > fabs(beta - temp))
 254.159 +            {  jj = j, most = fabs(beta - temp);
 254.160 +               if (beta < temp)
 254.161 +                  next = GLP_DN_BRNCH;
 254.162 +               else
 254.163 +                  next = GLP_UP_BRNCH;
 254.164 +            }
 254.165 +         }
 254.166 +      }
 254.167 +      *_next = next;
 254.168 +      return jj;
 254.169 +}
 254.170 +
 254.171 +/***********************************************************************
 254.172 +*  branch_drtom - choose branching var using Driebeck-Tomlin heuristic
 254.173 +*
 254.174 +*  This routine chooses a structural variable, which is required to be
 254.175 +*  integral and has fractional value in optimal solution of the current
 254.176 +*  LP relaxation, using a heuristic proposed by Driebeck and Tomlin.
 254.177 +*
 254.178 +*  The routine also selects the branch to be solved next, again due to
 254.179 +*  Driebeck and Tomlin.
 254.180 +*
 254.181 +*  This routine is based on the heuristic proposed in:
 254.182 +*
 254.183 +*  Driebeck N.J. An algorithm for the solution of mixed-integer
 254.184 +*  programming problems, Management Science, 12: 576-87 (1966);
 254.185 +*
 254.186 +*  and improved in:
 254.187 +*
 254.188 +*  Tomlin J.A. Branch and bound methods for integer and non-convex
 254.189 +*  programming, in J.Abadie (ed.), Integer and Nonlinear Programming,
 254.190 +*  North-Holland, Amsterdam, pp. 437-50 (1970).
 254.191 +*
 254.192 +*  Must note that this heuristic is time-expensive, because computing
 254.193 +*  one-step degradation (see the routine below) requires one BTRAN for
 254.194 +*  each fractional-valued structural variable. */
 254.195 +
 254.196 +static int branch_drtom(glp_tree *T, int *_next)
 254.197 +{     glp_prob *mip = T->mip;
 254.198 +      int m = mip->m;
 254.199 +      int n = mip->n;
 254.200 +      char *non_int = T->non_int;
 254.201 +      int j, jj, k, t, next, kase, len, stat, *ind;
 254.202 +      double x, dk, alfa, delta_j, delta_k, delta_z, dz_dn, dz_up,
 254.203 +         dd_dn, dd_up, degrad, *val;
 254.204 +      /* basic solution of LP relaxation must be optimal */
 254.205 +      xassert(glp_get_status(mip) == GLP_OPT);
 254.206 +      /* allocate working arrays */
 254.207 +      ind = xcalloc(1+n, sizeof(int));
 254.208 +      val = xcalloc(1+n, sizeof(double));
 254.209 +      /* nothing has been chosen so far */
 254.210 +      jj = 0, degrad = -1.0;
 254.211 +      /* walk through the list of columns (structural variables) */
 254.212 +      for (j = 1; j <= n; j++)
 254.213 +      {  /* if j-th column is not marked as fractional, skip it */
 254.214 +         if (!non_int[j]) continue;
 254.215 +         /* obtain (fractional) value of j-th column in basic solution
 254.216 +            of LP relaxation */
 254.217 +         x = glp_get_col_prim(mip, j);
 254.218 +         /* since the value of j-th column is fractional, the column is
 254.219 +            basic; compute corresponding row of the simplex table */
 254.220 +         len = glp_eval_tab_row(mip, m+j, ind, val);
 254.221 +         /* the following fragment computes a change in the objective
 254.222 +            function: delta Z = new Z - old Z, where old Z is the
 254.223 +            objective value in the current optimal basis, and new Z is
 254.224 +            the objective value in the adjacent basis, for two cases:
 254.225 +            1) if new upper bound ub' = floor(x[j]) is introduced for
 254.226 +               j-th column (down branch);
 254.227 +            2) if new lower bound lb' = ceil(x[j]) is introduced for
 254.228 +               j-th column (up branch);
 254.229 +            since in both cases the solution remaining dual feasible
 254.230 +            becomes primal infeasible, one implicit simplex iteration
 254.231 +            is performed to determine the change delta Z;
 254.232 +            it is obvious that new Z, which is never better than old Z,
 254.233 +            is a lower (minimization) or upper (maximization) bound of
 254.234 +            the objective function for down- and up-branches. */
 254.235 +         for (kase = -1; kase <= +1; kase += 2)
 254.236 +         {  /* if kase < 0, the new upper bound of x[j] is introduced;
 254.237 +               in this case x[j] should decrease in order to leave the
 254.238 +               basis and go to its new upper bound */
 254.239 +            /* if kase > 0, the new lower bound of x[j] is introduced;
 254.240 +               in this case x[j] should increase in order to leave the
 254.241 +               basis and go to its new lower bound */
 254.242 +            /* apply the dual ratio test in order to determine which
 254.243 +               auxiliary or structural variable should enter the basis
 254.244 +               to keep dual feasibility */
 254.245 +            k = glp_dual_rtest(mip, len, ind, val, kase, 1e-9);
 254.246 +            if (k != 0) k = ind[k];
 254.247 +            /* if no non-basic variable has been chosen, LP relaxation
 254.248 +               of corresponding branch being primal infeasible and dual
 254.249 +               unbounded has no primal feasible solution; in this case
 254.250 +               the change delta Z is formally set to infinity */
 254.251 +            if (k == 0)
 254.252 +            {  delta_z =
 254.253 +                  (T->mip->dir == GLP_MIN ? +DBL_MAX : -DBL_MAX);
 254.254 +               goto skip;
 254.255 +            }
 254.256 +            /* row of the simplex table that corresponds to non-basic
 254.257 +               variable x[k] choosen by the dual ratio test is:
 254.258 +                  x[j] = ... + alfa * x[k] + ...
 254.259 +               where alfa is the influence coefficient (an element of
 254.260 +               the simplex table row) */
 254.261 +            /* determine the coefficient alfa */
 254.262 +            for (t = 1; t <= len; t++) if (ind[t] == k) break;
 254.263 +            xassert(1 <= t && t <= len);
 254.264 +            alfa = val[t];
 254.265 +            /* since in the adjacent basis the variable x[j] becomes
 254.266 +               non-basic, knowing its value in the current basis we can
 254.267 +               determine its change delta x[j] = new x[j] - old x[j] */
 254.268 +            delta_j = (kase < 0 ? floor(x) : ceil(x)) - x;
 254.269 +            /* and knowing the coefficient alfa we can determine the
 254.270 +               corresponding change delta x[k] = new x[k] - old x[k],
 254.271 +               where old x[k] is a value of x[k] in the current basis,
 254.272 +               and new x[k] is a value of x[k] in the adjacent basis */
 254.273 +            delta_k = delta_j / alfa;
 254.274 +            /* Tomlin noticed that if the variable x[k] is of integer
 254.275 +               kind, its change cannot be less (eventually) than one in
 254.276 +               the magnitude */
 254.277 +            if (k > m && glp_get_col_kind(mip, k-m) != GLP_CV)
 254.278 +            {  /* x[k] is structural integer variable */
 254.279 +               if (fabs(delta_k - floor(delta_k + 0.5)) > 1e-3)
 254.280 +               {  if (delta_k > 0.0)
 254.281 +                     delta_k = ceil(delta_k);  /* +3.14 -> +4 */
 254.282 +                  else
 254.283 +                     delta_k = floor(delta_k); /* -3.14 -> -4 */
 254.284 +               }
 254.285 +            }
 254.286 +            /* now determine the status and reduced cost of x[k] in the
 254.287 +               current basis */
 254.288 +            if (k <= m)
 254.289 +            {  stat = glp_get_row_stat(mip, k);
 254.290 +               dk = glp_get_row_dual(mip, k);
 254.291 +            }
 254.292 +            else
 254.293 +            {  stat = glp_get_col_stat(mip, k-m);
 254.294 +               dk = glp_get_col_dual(mip, k-m);
 254.295 +            }
 254.296 +            /* if the current basis is dual degenerate, some reduced
 254.297 +               costs which are close to zero may have wrong sign due to
 254.298 +               round-off errors, so correct the sign of d[k] */
 254.299 +            switch (T->mip->dir)
 254.300 +            {  case GLP_MIN:
 254.301 +                  if (stat == GLP_NL && dk < 0.0 ||
 254.302 +                      stat == GLP_NU && dk > 0.0 ||
 254.303 +                      stat == GLP_NF) dk = 0.0;
 254.304 +                  break;
 254.305 +               case GLP_MAX:
 254.306 +                  if (stat == GLP_NL && dk > 0.0 ||
 254.307 +                      stat == GLP_NU && dk < 0.0 ||
 254.308 +                      stat == GLP_NF) dk = 0.0;
 254.309 +                  break;
 254.310 +               default:
 254.311 +                  xassert(T != T);
 254.312 +            }
 254.313 +            /* now knowing the change of x[k] and its reduced cost d[k]
 254.314 +               we can compute the corresponding change in the objective
 254.315 +               function delta Z = new Z - old Z = d[k] * delta x[k];
 254.316 +               note that due to Tomlin's modification new Z can be even
 254.317 +               worse than in the adjacent basis */
 254.318 +            delta_z = dk * delta_k;
 254.319 +skip:       /* new Z is never better than old Z, therefore the change
 254.320 +               delta Z is always non-negative (in case of minimization)
 254.321 +               or non-positive (in case of maximization) */
 254.322 +            switch (T->mip->dir)
 254.323 +            {  case GLP_MIN: xassert(delta_z >= 0.0); break;
 254.324 +               case GLP_MAX: xassert(delta_z <= 0.0); break;
 254.325 +               default: xassert(T != T);
 254.326 +            }
 254.327 +            /* save the change in the objective fnction for down- and
 254.328 +               up-branches, respectively */
 254.329 +            if (kase < 0) dz_dn = delta_z; else dz_up = delta_z;
 254.330 +         }
 254.331 +         /* thus, in down-branch no integer feasible solution can be
 254.332 +            better than Z + dz_dn, and in up-branch no integer feasible
 254.333 +            solution can be better than Z + dz_up, where Z is value of
 254.334 +            the objective function in the current basis */
 254.335 +         /* following the heuristic by Driebeck and Tomlin we choose a
 254.336 +            column (i.e. structural variable) which provides largest
 254.337 +            degradation of the objective function in some of branches;
 254.338 +            besides, we select the branch with smaller degradation to
 254.339 +            be solved next and keep other branch with larger degradation
 254.340 +            in the active list hoping to minimize the number of further
 254.341 +            backtrackings */
 254.342 +         if (degrad < fabs(dz_dn) || degrad < fabs(dz_up))
 254.343 +         {  jj = j;
 254.344 +            if (fabs(dz_dn) < fabs(dz_up))
 254.345 +            {  /* select down branch to be solved next */
 254.346 +               next = GLP_DN_BRNCH;
 254.347 +               degrad = fabs(dz_up);
 254.348 +            }
 254.349 +            else
 254.350 +            {  /* select up branch to be solved next */
 254.351 +               next = GLP_UP_BRNCH;
 254.352 +               degrad = fabs(dz_dn);
 254.353 +            }
 254.354 +            /* save the objective changes for printing */
 254.355 +            dd_dn = dz_dn, dd_up = dz_up;
 254.356 +            /* if down- or up-branch has no feasible solution, we does
 254.357 +               not need to consider other candidates (in principle, the
 254.358 +               corresponding branch could be pruned right now) */
 254.359 +            if (degrad == DBL_MAX) break;
 254.360 +         }
 254.361 +      }
 254.362 +      /* free working arrays */
 254.363 +      xfree(ind);
 254.364 +      xfree(val);
 254.365 +      /* something must be chosen */
 254.366 +      xassert(1 <= jj && jj <= n);
 254.367 +#if 1 /* 02/XI-2009 */
 254.368 +      if (degrad < 1e-6 * (1.0 + 0.001 * fabs(mip->obj_val)))
 254.369 +      {  jj = branch_mostf(T, &next);
 254.370 +         goto done;
 254.371 +      }
 254.372 +#endif
 254.373 +      if (T->parm->msg_lev >= GLP_MSG_DBG)
 254.374 +      {  xprintf("branch_drtom: column %d chosen to branch on\n", jj);
 254.375 +         if (fabs(dd_dn) == DBL_MAX)
 254.376 +            xprintf("branch_drtom: down-branch is infeasible\n");
 254.377 +         else
 254.378 +            xprintf("branch_drtom: down-branch bound is %.9e\n",
 254.379 +               lpx_get_obj_val(mip) + dd_dn);
 254.380 +         if (fabs(dd_up) == DBL_MAX)
 254.381 +            xprintf("branch_drtom: up-branch   is infeasible\n");
 254.382 +         else
 254.383 +            xprintf("branch_drtom: up-branch   bound is %.9e\n",
 254.384 +               lpx_get_obj_val(mip) + dd_up);
 254.385 +      }
 254.386 +done: *_next = next;
 254.387 +      return jj;
 254.388 +}
 254.389 +
 254.390 +/**********************************************************************/
 254.391 +
 254.392 +struct csa
 254.393 +{     /* common storage area */
 254.394 +      int *dn_cnt; /* int dn_cnt[1+n]; */
 254.395 +      /* dn_cnt[j] is the number of subproblems, whose LP relaxations
 254.396 +         have been solved and which are down-branches for variable x[j];
 254.397 +         dn_cnt[j] = 0 means the down pseudocost is uninitialized */
 254.398 +      double *dn_sum; /* double dn_sum[1+n]; */
 254.399 +      /* dn_sum[j] is the sum of per unit degradations of the objective
 254.400 +         over all dn_cnt[j] subproblems */
 254.401 +      int *up_cnt; /* int up_cnt[1+n]; */
 254.402 +      /* up_cnt[j] is the number of subproblems, whose LP relaxations
 254.403 +         have been solved and which are up-branches for variable x[j];
 254.404 +         up_cnt[j] = 0 means the up pseudocost is uninitialized */
 254.405 +      double *up_sum; /* double up_sum[1+n]; */
 254.406 +      /* up_sum[j] is the sum of per unit degradations of the objective
 254.407 +         over all up_cnt[j] subproblems */
 254.408 +};
 254.409 +
 254.410 +void *ios_pcost_init(glp_tree *tree)
 254.411 +{     /* initialize working data used on pseudocost branching */
 254.412 +      struct csa *csa;
 254.413 +      int n = tree->n, j;
 254.414 +      csa = xmalloc(sizeof(struct csa));
 254.415 +      csa->dn_cnt = xcalloc(1+n, sizeof(int));
 254.416 +      csa->dn_sum = xcalloc(1+n, sizeof(double));
 254.417 +      csa->up_cnt = xcalloc(1+n, sizeof(int));
 254.418 +      csa->up_sum = xcalloc(1+n, sizeof(double));
 254.419 +      for (j = 1; j <= n; j++)
 254.420 +      {  csa->dn_cnt[j] = csa->up_cnt[j] = 0;
 254.421 +         csa->dn_sum[j] = csa->up_sum[j] = 0.0;
 254.422 +      }
 254.423 +      return csa;
 254.424 +}
 254.425 +
 254.426 +static double eval_degrad(glp_prob *P, int j, double bnd)
 254.427 +{     /* compute degradation of the objective on fixing x[j] at given
 254.428 +         value with a limited number of dual simplex iterations */
 254.429 +      /* this routine fixes column x[j] at specified value bnd,
 254.430 +         solves resulting LP, and returns a lower bound to degradation
 254.431 +         of the objective, degrad >= 0 */
 254.432 +      glp_prob *lp;
 254.433 +      glp_smcp parm;
 254.434 +      int ret;
 254.435 +      double degrad;
 254.436 +      /* the current basis must be optimal */
 254.437 +      xassert(glp_get_status(P) == GLP_OPT);
 254.438 +      /* create a copy of P */
 254.439 +      lp = glp_create_prob();
 254.440 +      glp_copy_prob(lp, P, 0);
 254.441 +      /* fix column x[j] at specified value */
 254.442 +      glp_set_col_bnds(lp, j, GLP_FX, bnd, bnd);
 254.443 +      /* try to solve resulting LP */
 254.444 +      glp_init_smcp(&parm);
 254.445 +      parm.msg_lev = GLP_MSG_OFF;
 254.446 +      parm.meth = GLP_DUAL;
 254.447 +      parm.it_lim = 30;
 254.448 +      parm.out_dly = 1000;
 254.449 +      parm.meth = GLP_DUAL;
 254.450 +      ret = glp_simplex(lp, &parm);
 254.451 +      if (ret == 0 || ret == GLP_EITLIM)
 254.452 +      {  if (glp_get_prim_stat(lp) == GLP_NOFEAS)
 254.453 +         {  /* resulting LP has no primal feasible solution */
 254.454 +            degrad = DBL_MAX;
 254.455 +         }
 254.456 +         else if (glp_get_dual_stat(lp) == GLP_FEAS)
 254.457 +         {  /* resulting basis is optimal or at least dual feasible,
 254.458 +               so we have the correct lower bound to degradation */
 254.459 +            if (P->dir == GLP_MIN)
 254.460 +               degrad = lp->obj_val - P->obj_val;
 254.461 +            else if (P->dir == GLP_MAX)
 254.462 +               degrad = P->obj_val - lp->obj_val;
 254.463 +            else
 254.464 +               xassert(P != P);
 254.465 +            /* degradation cannot be negative by definition */
 254.466 +            /* note that the lower bound to degradation may be close
 254.467 +               to zero even if its exact value is zero due to round-off
 254.468 +               errors on computing the objective value */
 254.469 +            if (degrad < 1e-6 * (1.0 + 0.001 * fabs(P->obj_val)))
 254.470 +               degrad = 0.0;
 254.471 +         }
 254.472 +         else
 254.473 +         {  /* the final basis reported by the simplex solver is dual
 254.474 +               infeasible, so we cannot determine a non-trivial lower
 254.475 +               bound to degradation */
 254.476 +            degrad = 0.0;
 254.477 +         }
 254.478 +      }
 254.479 +      else
 254.480 +      {  /* the simplex solver failed */
 254.481 +         degrad = 0.0;
 254.482 +      }
 254.483 +      /* delete the copy of P */
 254.484 +      glp_delete_prob(lp);
 254.485 +      return degrad;
 254.486 +}
 254.487 +
 254.488 +void ios_pcost_update(glp_tree *tree)
 254.489 +{     /* update history information for pseudocost branching */
 254.490 +      /* this routine is called every time when LP relaxation of the
 254.491 +         current subproblem has been solved to optimality with all lazy
 254.492 +         and cutting plane constraints included */
 254.493 +      int j;
 254.494 +      double dx, dz, psi;
 254.495 +      struct csa *csa = tree->pcost;
 254.496 +      xassert(csa != NULL);
 254.497 +      xassert(tree->curr != NULL);
 254.498 +      /* if the current subproblem is the root, skip updating */
 254.499 +      if (tree->curr->up == NULL) goto skip;
 254.500 +      /* determine branching variable x[j], which was used in the
 254.501 +         parent subproblem to create the current subproblem */
 254.502 +      j = tree->curr->up->br_var;
 254.503 +      xassert(1 <= j && j <= tree->n);
 254.504 +      /* determine the change dx[j] = new x[j] - old x[j],
 254.505 +         where new x[j] is a value of x[j] in optimal solution to LP
 254.506 +         relaxation of the current subproblem, old x[j] is a value of
 254.507 +         x[j] in optimal solution to LP relaxation of the parent
 254.508 +         subproblem */
 254.509 +      dx = tree->mip->col[j]->prim - tree->curr->up->br_val;
 254.510 +      xassert(dx != 0.0);
 254.511 +      /* determine corresponding change dz = new dz - old dz in the
 254.512 +         objective function value */
 254.513 +      dz = tree->mip->obj_val - tree->curr->up->lp_obj;
 254.514 +      /* determine per unit degradation of the objective function */
 254.515 +      psi = fabs(dz / dx);
 254.516 +      /* update history information */
 254.517 +      if (dx < 0.0)
 254.518 +      {  /* the current subproblem is down-branch */
 254.519 +         csa->dn_cnt[j]++;
 254.520 +         csa->dn_sum[j] += psi;
 254.521 +      }
 254.522 +      else /* dx > 0.0 */
 254.523 +      {  /* the current subproblem is up-branch */
 254.524 +         csa->up_cnt[j]++;
 254.525 +         csa->up_sum[j] += psi;
 254.526 +      }
 254.527 +skip: return;
 254.528 +}
 254.529 +
 254.530 +void ios_pcost_free(glp_tree *tree)
 254.531 +{     /* free working area used on pseudocost branching */
 254.532 +      struct csa *csa = tree->pcost;
 254.533 +      xassert(csa != NULL);
 254.534 +      xfree(csa->dn_cnt);
 254.535 +      xfree(csa->dn_sum);
 254.536 +      xfree(csa->up_cnt);
 254.537 +      xfree(csa->up_sum);
 254.538 +      xfree(csa);
 254.539 +      tree->pcost = NULL;
 254.540 +      return;
 254.541 +}
 254.542 +
 254.543 +static double eval_psi(glp_tree *T, int j, int brnch)
 254.544 +{     /* compute estimation of pseudocost of variable x[j] for down-
 254.545 +         or up-branch */
 254.546 +      struct csa *csa = T->pcost;
 254.547 +      double beta, degrad, psi;
 254.548 +      xassert(csa != NULL);
 254.549 +      xassert(1 <= j && j <= T->n);
 254.550 +      if (brnch == GLP_DN_BRNCH)
 254.551 +      {  /* down-branch */
 254.552 +         if (csa->dn_cnt[j] == 0)
 254.553 +         {  /* initialize down pseudocost */
 254.554 +            beta = T->mip->col[j]->prim;
 254.555 +            degrad = eval_degrad(T->mip, j, floor(beta));
 254.556 +            if (degrad == DBL_MAX)
 254.557 +            {  psi = DBL_MAX;
 254.558 +               goto done;
 254.559 +            }
 254.560 +            csa->dn_cnt[j] = 1;
 254.561 +            csa->dn_sum[j] = degrad / (beta - floor(beta));
 254.562 +         }
 254.563 +         psi = csa->dn_sum[j] / (double)csa->dn_cnt[j];
 254.564 +      }
 254.565 +      else if (brnch == GLP_UP_BRNCH)
 254.566 +      {  /* up-branch */
 254.567 +         if (csa->up_cnt[j] == 0)
 254.568 +         {  /* initialize up pseudocost */
 254.569 +            beta = T->mip->col[j]->prim;
 254.570 +            degrad = eval_degrad(T->mip, j, ceil(beta));
 254.571 +            if (degrad == DBL_MAX)
 254.572 +            {  psi = DBL_MAX;
 254.573 +               goto done;
 254.574 +            }
 254.575 +            csa->up_cnt[j] = 1;
 254.576 +            csa->up_sum[j] = degrad / (ceil(beta) - beta);
 254.577 +         }
 254.578 +         psi = csa->up_sum[j] / (double)csa->up_cnt[j];
 254.579 +      }
 254.580 +      else
 254.581 +         xassert(brnch != brnch);
 254.582 +done: return psi;
 254.583 +}
 254.584 +
 254.585 +static void progress(glp_tree *T)
 254.586 +{     /* display progress of pseudocost initialization */
 254.587 +      struct csa *csa = T->pcost;
 254.588 +      int j, nv = 0, ni = 0;
 254.589 +      for (j = 1; j <= T->n; j++)
 254.590 +      {  if (glp_ios_can_branch(T, j))
 254.591 +         {  nv++;
 254.592 +            if (csa->dn_cnt[j] > 0 && csa->up_cnt[j] > 0) ni++;
 254.593 +         }
 254.594 +      }
 254.595 +      xprintf("Pseudocosts initialized for %d of %d variables\n",
 254.596 +         ni, nv);
 254.597 +      return;
 254.598 +}
 254.599 +
 254.600 +int ios_pcost_branch(glp_tree *T, int *_next)
 254.601 +{     /* choose branching variable with pseudocost branching */
 254.602 +      glp_long t = xtime();
 254.603 +      int j, jjj, sel;
 254.604 +      double beta, psi, d1, d2, d, dmax;
 254.605 +      /* initialize the working arrays */
 254.606 +      if (T->pcost == NULL)
 254.607 +         T->pcost = ios_pcost_init(T);
 254.608 +      /* nothing has been chosen so far */
 254.609 +      jjj = 0, dmax = -1.0;
 254.610 +      /* go through the list of branching candidates */
 254.611 +      for (j = 1; j <= T->n; j++)
 254.612 +      {  if (!glp_ios_can_branch(T, j)) continue;
 254.613 +         /* determine primal value of x[j] in optimal solution to LP
 254.614 +            relaxation of the current subproblem */
 254.615 +         beta = T->mip->col[j]->prim;
 254.616 +         /* estimate pseudocost of x[j] for down-branch */
 254.617 +         psi = eval_psi(T, j, GLP_DN_BRNCH);
 254.618 +         if (psi == DBL_MAX)
 254.619 +         {  /* down-branch has no primal feasible solution */
 254.620 +            jjj = j, sel = GLP_DN_BRNCH;
 254.621 +            goto done;
 254.622 +         }
 254.623 +         /* estimate degradation of the objective for down-branch */
 254.624 +         d1 = psi * (beta - floor(beta));
 254.625 +         /* estimate pseudocost of x[j] for up-branch */
 254.626 +         psi = eval_psi(T, j, GLP_UP_BRNCH);
 254.627 +         if (psi == DBL_MAX)
 254.628 +         {  /* up-branch has no primal feasible solution */
 254.629 +            jjj = j, sel = GLP_UP_BRNCH;
 254.630 +            goto done;
 254.631 +         }
 254.632 +         /* estimate degradation of the objective for up-branch */
 254.633 +         d2 = psi * (ceil(beta) - beta);
 254.634 +         /* determine d = max(d1, d2) */
 254.635 +         d = (d1 > d2 ? d1 : d2);
 254.636 +         /* choose x[j] which provides maximal estimated degradation of
 254.637 +            the objective either in down- or up-branch */
 254.638 +         if (dmax < d)
 254.639 +         {  dmax = d;
 254.640 +            jjj = j;
 254.641 +            /* continue the search from a subproblem, where degradation
 254.642 +               is less than in other one */
 254.643 +            sel = (d1 <= d2 ? GLP_DN_BRNCH : GLP_UP_BRNCH);
 254.644 +         }
 254.645 +         /* display progress of pseudocost initialization */
 254.646 +         if (T->parm->msg_lev >= GLP_ON)
 254.647 +         {  if (xdifftime(xtime(), t) >= 10.0)
 254.648 +            {  progress(T);
 254.649 +               t = xtime();
 254.650 +            }
 254.651 +         }
 254.652 +      }
 254.653 +      if (dmax == 0.0)
 254.654 +      {  /* no degradation is indicated; choose a variable having most
 254.655 +            fractional value */
 254.656 +         jjj = branch_mostf(T, &sel);
 254.657 +      }
 254.658 +done: *_next = sel;
 254.659 +      return jjj;
 254.660 +}
 254.661 +
 254.662 +/* eof */
   255.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
   255.2 +++ b/deps/glpk/src/glpios10.c	Sun Nov 06 20:59:10 2011 +0100
   255.3 @@ -0,0 +1,348 @@
   255.4 +/* glpios10.c (feasibility pump heuristic) */
   255.5 +
   255.6 +/***********************************************************************
   255.7 +*  This code is part of GLPK (GNU Linear Programming Kit).
   255.8 +*
   255.9 +*  Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008,
  255.10 +*  2009, 2010, 2011 Andrew Makhorin, Department for Applied Informatics,
  255.11 +*  Moscow Aviation Institute, Moscow, Russia. All rights reserved.
  255.12 +*  E-mail: <mao@gnu.org>.
  255.13 +*
  255.14 +*  GLPK is free software: you can redistribute it and/or modify it
  255.15 +*  under the terms of the GNU General Public License as published by
  255.16 +*  the Free Software Foundation, either version 3 of the License, or
  255.17 +*  (at your option) any later version.
  255.18 +*
  255.19 +*  GLPK is distributed in the hope that it will be useful, but WITHOUT
  255.20 +*  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
  255.21 +*  or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
  255.22 +*  License for more details.
  255.23 +*
  255.24 +*  You should have received a copy of the GNU General Public License
  255.25 +*  along with GLPK. If not, see <http://www.gnu.org/licenses/>.
  255.26 +***********************************************************************/
  255.27 +
  255.28 +#include "glpios.h"
  255.29 +#include "glprng.h"
  255.30 +
  255.31 +/***********************************************************************
  255.32 +*  NAME
  255.33 +*
  255.34 +*  ios_feas_pump - feasibility pump heuristic
  255.35 +*
  255.36 +*  SYNOPSIS
  255.37 +*
  255.38 +*  #include "glpios.h"
  255.39 +*  void ios_feas_pump(glp_tree *T);
  255.40 +*
  255.41 +*  DESCRIPTION
  255.42 +*
  255.43 +*  The routine ios_feas_pump is a simple implementation of the Feasi-
  255.44 +*  bility Pump heuristic.
  255.45 +*
  255.46 +*  REFERENCES
  255.47 +*
  255.48 +*  M.Fischetti, F.Glover, and A.Lodi. "The feasibility pump." Math.
  255.49 +*  Program., Ser. A 104, pp. 91-104 (2005). */
  255.50 +
  255.51 +struct VAR
  255.52 +{     /* binary variable */
  255.53 +      int j;
  255.54 +      /* ordinal number */
  255.55 +      int x;
  255.56 +      /* value in the rounded solution (0 or 1) */
  255.57 +      double d;
  255.58 +      /* sorting key */
  255.59 +};
  255.60 +
  255.61 +static int fcmp(const void *x, const void *y)
  255.62 +{     /* comparison routine */
  255.63 +      const struct VAR *vx = x, *vy = y;
  255.64 +      if (vx->d > vy->d)
  255.65 +         return -1;
  255.66 +      else if (vx->d < vy->d)
  255.67 +         return +1;
  255.68 +      else
  255.69 +         return 0;
  255.70 +}
  255.71 +
  255.72 +void ios_feas_pump(glp_tree *T)
  255.73 +{     glp_prob *P = T->mip;
  255.74 +      int n = P->n;
  255.75 +      glp_prob *lp = NULL;
  255.76 +      struct VAR *var = NULL;
  255.77 +      RNG *rand = NULL;
  255.78 +      GLPCOL *col;
  255.79 +      glp_smcp parm;
  255.80 +      int j, k, new_x, nfail, npass, nv, ret, stalling;
  255.81 +      double dist, tol;
  255.82 +      xassert(glp_get_status(P) == GLP_OPT);
  255.83 +      /* this heuristic is applied only once on the root level */
  255.84 +      if (!(T->curr->level == 0 && T->curr->solved == 1)) goto done;
  255.85 +      /* determine number of binary variables */
  255.86 +      nv = 0;
  255.87 +      for (j = 1; j <= n; j++)
  255.88 +      {  col = P->col[j];
  255.89 +         /* if x[j] is continuous, skip it */
  255.90 +         if (col->kind == GLP_CV) continue;
  255.91 +         /* if x[j] is fixed, skip it */
  255.92 +         if (col->type == GLP_FX) continue;
  255.93 +         /* x[j] is non-fixed integer */
  255.94 +         xassert(col->kind == GLP_IV);
  255.95 +         if (col->type == GLP_DB && col->lb == 0.0 && col->ub == 1.0)
  255.96 +         {  /* x[j] is binary */
  255.97 +            nv++;
  255.98 +         }
  255.99 +         else
 255.100 +         {  /* x[j] is general integer */
 255.101 +            if (T->parm->msg_lev >= GLP_MSG_ALL)
 255.102 +               xprintf("FPUMP heuristic cannot be applied due to genera"
 255.103 +                  "l integer variables\n");
 255.104 +            goto done;
 255.105 +         }
 255.106 +      }
 255.107 +      /* there must be at least one binary variable */
 255.108 +      if (nv == 0) goto done;
 255.109 +      if (T->parm->msg_lev >= GLP_MSG_ALL)
 255.110 +         xprintf("Applying FPUMP heuristic...\n");
 255.111 +      /* build the list of binary variables */
 255.112 +      var = xcalloc(1+nv, sizeof(struct VAR));
 255.113 +      k = 0;
 255.114 +      for (j = 1; j <= n; j++)
 255.115 +      {  col = P->col[j];
 255.116 +         if (col->kind == GLP_IV && col->type == GLP_DB)
 255.117 +            var[++k].j = j;
 255.118 +      }
 255.119 +      xassert(k == nv);
 255.120 +      /* create working problem object */
 255.121 +      lp = glp_create_prob();
 255.122 +more: /* copy the original problem object to keep it intact */
 255.123 +      glp_copy_prob(lp, P, GLP_OFF);
 255.124 +      /* we are interested to find an integer feasible solution, which
 255.125 +         is better than the best known one */
 255.126 +      if (P->mip_stat == GLP_FEAS)
 255.127 +      {  int *ind;
 255.128 +         double *val, bnd;
 255.129 +         /* add a row and make it identical to the objective row */
 255.130 +         glp_add_rows(lp, 1);
 255.131 +         ind = xcalloc(1+n, sizeof(int));
 255.132 +         val = xcalloc(1+n, sizeof(double));
 255.133 +         for (j = 1; j <= n; j++)
 255.134 +         {  ind[j] = j;
 255.135 +            val[j] = P->col[j]->coef;
 255.136 +         }
 255.137 +         glp_set_mat_row(lp, lp->m, n, ind, val);
 255.138 +         xfree(ind);
 255.139 +         xfree(val);
 255.140 +         /* introduce upper (minimization) or lower (maximization)
 255.141 +            bound to the original objective function; note that this
 255.142 +            additional constraint is not violated at the optimal point
 255.143 +            to LP relaxation */
 255.144 +#if 0 /* modified by xypron <xypron.glpk@gmx.de> */
 255.145 +         if (P->dir == GLP_MIN)
 255.146 +         {  bnd = P->mip_obj - 0.10 * (1.0 + fabs(P->mip_obj));
 255.147 +            if (bnd < P->obj_val) bnd = P->obj_val;
 255.148 +            glp_set_row_bnds(lp, lp->m, GLP_UP, 0.0, bnd - P->c0);
 255.149 +         }
 255.150 +         else if (P->dir == GLP_MAX)
 255.151 +         {  bnd = P->mip_obj + 0.10 * (1.0 + fabs(P->mip_obj));
 255.152 +            if (bnd > P->obj_val) bnd = P->obj_val;
 255.153 +            glp_set_row_bnds(lp, lp->m, GLP_LO, bnd - P->c0, 0.0);
 255.154 +         }
 255.155 +         else
 255.156 +            xassert(P != P);
 255.157 +#else
 255.158 +         bnd = 0.1 * P->obj_val + 0.9 * P->mip_obj;
 255.159 +         /* xprintf("bnd = %f\n", bnd); */
 255.160 +         if (P->dir == GLP_MIN)
 255.161 +            glp_set_row_bnds(lp, lp->m, GLP_UP, 0.0, bnd - P->c0);
 255.162 +         else if (P->dir == GLP_MAX)
 255.163 +            glp_set_row_bnds(lp, lp->m, GLP_LO, bnd - P->c0, 0.0);
 255.164 +         else
 255.165 +            xassert(P != P);
 255.166 +#endif
 255.167 +      }
 255.168 +      /* reset pass count */
 255.169 +      npass = 0;
 255.170 +      /* invalidate the rounded point */
 255.171 +      for (k = 1; k <= nv; k++)
 255.172 +         var[k].x = -1;
 255.173 +pass: /* next pass starts here */
 255.174 +      npass++;
 255.175 +      if (T->parm->msg_lev >= GLP_MSG_ALL)
 255.176 +         xprintf("Pass %d\n", npass);
 255.177 +      /* initialize minimal distance between the basic point and the
 255.178 +         rounded one obtained during this pass */
 255.179 +      dist = DBL_MAX;
 255.180 +      /* reset failure count (the number of succeeded iterations failed
 255.181 +         to improve the distance) */
 255.182 +      nfail = 0;
 255.183 +      /* if it is not the first pass, perturb the last rounded point
 255.184 +         rather than construct it from the basic solution */
 255.185 +      if (npass > 1)
 255.186 +      {  double rho, temp;
 255.187 +         if (rand == NULL)
 255.188 +            rand = rng_create_rand();
 255.189 +         for (k = 1; k <= nv; k++)
 255.190 +         {  j = var[k].j;
 255.191 +            col = lp->col[j];
 255.192 +            rho = rng_uniform(rand, -0.3, 0.7);
 255.193 +            if (rho < 0.0) rho = 0.0;
 255.194 +            temp = fabs((double)var[k].x - col->prim);
 255.195 +            if (temp + rho > 0.5) var[k].x = 1 - var[k].x;
 255.196 +         }
 255.197 +         goto skip;
 255.198 +      }
 255.199 +loop: /* innermost loop begins here */
 255.200 +      /* round basic solution (which is assumed primal feasible) */
 255.201 +      stalling = 1;
 255.202 +      for (k = 1; k <= nv; k++)
 255.203 +      {  col = lp->col[var[k].j];
 255.204 +         if (col->prim < 0.5)
 255.205 +         {  /* rounded value is 0 */
 255.206 +            new_x = 0;
 255.207 +         }
 255.208 +         else
 255.209 +         {  /* rounded value is 1 */
 255.210 +            new_x = 1;
 255.211 +         }
 255.212 +         if (var[k].x != new_x)
 255.213 +         {  stalling = 0;
 255.214 +            var[k].x = new_x;
 255.215 +         }
 255.216 +      }
 255.217 +      /* if the rounded point has not changed (stalling), choose and
 255.218 +         flip some its entries heuristically */
 255.219 +      if (stalling)
 255.220 +      {  /* compute d[j] = |x[j] - round(x[j])| */
 255.221 +         for (k = 1; k <= nv; k++)
 255.222 +         {  col = lp->col[var[k].j];
 255.223 +            var[k].d = fabs(col->prim - (double)var[k].x);
 255.224 +         }
 255.225 +         /* sort the list of binary variables by descending d[j] */
 255.226 +         qsort(&var[1], nv, sizeof(struct VAR), fcmp);
 255.227 +         /* choose and flip some rounded components */
 255.228 +         for (k = 1; k <= nv; k++)
 255.229 +         {  if (k >= 5 && var[k].d < 0.35 || k >= 10) break;
 255.230 +            var[k].x = 1 - var[k].x;
 255.231 +         }
 255.232 +      }
 255.233 +skip: /* check if the time limit has been exhausted */
 255.234 +      if (T->parm->tm_lim < INT_MAX &&
 255.235 +         (double)(T->parm->tm_lim - 1) <=
 255.236 +         1000.0 * xdifftime(xtime(), T->tm_beg)) goto done;
 255.237 +      /* build the objective, which is the distance between the current
 255.238 +         (basic) point and the rounded one */
 255.239 +      lp->dir = GLP_MIN;
 255.240 +      lp->c0 = 0.0;
 255.241 +      for (j = 1; j <= n; j++)
 255.242 +         lp->col[j]->coef = 0.0;
 255.243 +      for (k = 1; k <= nv; k++)
 255.244 +      {  j = var[k].j;
 255.245 +         if (var[k].x == 0)
 255.246 +            lp->col[j]->coef = +1.0;
 255.247 +         else
 255.248 +         {  lp->col[j]->coef = -1.0;
 255.249 +            lp->c0 += 1.0;
 255.250 +         }
 255.251 +      }
 255.252 +      /* minimize the distance with the simplex method */
 255.253 +      glp_init_smcp(&parm);
 255.254 +      if (T->parm->msg_lev <= GLP_MSG_ERR)
 255.255 +         parm.msg_lev = T->parm->msg_lev;
 255.256 +      else if (T->parm->msg_lev <= GLP_MSG_ALL)
 255.257 +      {  parm.msg_lev = GLP_MSG_ON;
 255.258 +         parm.out_dly = 10000;
 255.259 +      }
 255.260 +      ret = glp_simplex(lp, &parm);
 255.261 +      if (ret != 0)
 255.262 +      {  if (T->parm->msg_lev >= GLP_MSG_ERR)
 255.263 +            xprintf("Warning: glp_simplex returned %d\n", ret);
 255.264 +         goto done;
 255.265 +      }
 255.266 +      ret = glp_get_status(lp);
 255.267 +      if (ret != GLP_OPT)
 255.268 +      {  if (T->parm->msg_lev >= GLP_MSG_ERR)
 255.269 +            xprintf("Warning: glp_get_status returned %d\n", ret);
 255.270 +         goto done;
 255.271 +      }
 255.272 +      if (T->parm->msg_lev >= GLP_MSG_DBG)
 255.273 +         xprintf("delta = %g\n", lp->obj_val);
 255.274 +      /* check if the basic solution is integer feasible; note that it
 255.275 +         may be so even if the minimial distance is positive */
 255.276 +      tol = 0.3 * T->parm->tol_int;
 255.277 +      for (k = 1; k <= nv; k++)
 255.278 +      {  col = lp->col[var[k].j];
 255.279 +         if (tol < col->prim && col->prim < 1.0 - tol) break;
 255.280 +      }
 255.281 +      if (k > nv)
 255.282 +      {  /* okay; the basic solution seems to be integer feasible */
 255.283 +         double *x = xcalloc(1+n, sizeof(double));
 255.284 +         for (j = 1; j <= n; j++)
 255.285 +         {  x[j] = lp->col[j]->prim;
 255.286 +            if (P->col[j]->kind == GLP_IV) x[j] = floor(x[j] + 0.5);
 255.287 +         }
 255.288 +#if 1 /* modified by xypron <xypron.glpk@gmx.de> */
 255.289 +         /* reset direction and right-hand side of objective */
 255.290 +         lp->c0  = P->c0;
 255.291 +         lp->dir = P->dir;
 255.292 +         /* fix integer variables */
 255.293 +         for (k = 1; k <= nv; k++)
 255.294 +         {  lp->col[var[k].j]->lb   = x[var[k].j];
 255.295 +            lp->col[var[k].j]->ub   = x[var[k].j];
 255.296 +            lp->col[var[k].j]->type = GLP_FX;
 255.297 +         }
 255.298 +         /* copy original objective function */
 255.299 +         for (j = 1; j <= n; j++)
 255.300 +            lp->col[j]->coef = P->col[j]->coef;
 255.301 +         /* solve original LP and copy result */
 255.302 +         ret = glp_simplex(lp, &parm);
 255.303 +         if (ret != 0)
 255.304 +         {  if (T->parm->msg_lev >= GLP_MSG_ERR)
 255.305 +               xprintf("Warning: glp_simplex returned %d\n", ret);
 255.306 +            goto done;
 255.307 +         }
 255.308 +         ret = glp_get_status(lp);
 255.309 +         if (ret != GLP_OPT)
 255.310 +         {  if (T->parm->msg_lev >= GLP_MSG_ERR)
 255.311 +               xprintf("Warning: glp_get_status returned %d\n", ret);
 255.312 +            goto done;
 255.313 +         }
 255.314 +         for (j = 1; j <= n; j++)
 255.315 +            if (P->col[j]->kind != GLP_IV) x[j] = lp->col[j]->prim;
 255.316 +#endif
 255.317 +         ret = glp_ios_heur_sol(T, x);
 255.318 +         xfree(x);
 255.319 +         if (ret == 0)
 255.320 +         {  /* the integer solution is accepted */
 255.321 +            if (ios_is_hopeful(T, T->curr->bound))
 255.322 +            {  /* it is reasonable to apply the heuristic once again */
 255.323 +               goto more;
 255.324 +            }
 255.325 +            else
 255.326 +            {  /* the best known integer feasible solution just found
 255.327 +                  is close to optimal solution to LP relaxation */
 255.328 +               goto done;
 255.329 +            }
 255.330 +         }
 255.331 +      }
 255.332 +      /* the basic solution is fractional */
 255.333 +      if (dist == DBL_MAX ||
 255.334 +          lp->obj_val <= dist - 1e-6 * (1.0 + dist))
 255.335 +      {  /* the distance is reducing */
 255.336 +         nfail = 0, dist = lp->obj_val;
 255.337 +      }
 255.338 +      else
 255.339 +      {  /* improving the distance failed */
 255.340 +         nfail++;
 255.341 +      }
 255.342 +      if (nfail < 3) goto loop;
 255.343 +      if (npass < 5) goto pass;
 255.344 +done: /* delete working objects */
 255.345 +      if (lp != NULL) glp_delete_prob(lp);
 255.346 +      if (var != NULL) xfree(var);
 255.347 +      if (rand != NULL) rng_delete_rand(rand);
 255.348 +      return;
 255.349 +}
 255.350 +
 255.351 +/* eof */
   256.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
   256.2 +++ b/deps/glpk/src/glpios11.c	Sun Nov 06 20:59:10 2011 +0100
   256.3 @@ -0,0 +1,280 @@
   256.4 +/* glpios11.c (process cuts stored in the local cut pool) */
   256.5 +
   256.6 +/***********************************************************************
   256.7 +*  This code is part of GLPK (GNU Linear Programming Kit).
   256.8 +*
   256.9 +*  Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008,
  256.10 +*  2009, 2010, 2011 Andrew Makhorin, Department for Applied Informatics,
  256.11 +*  Moscow Aviation Institute, Moscow, Russia. All rights reserved.
  256.12 +*  E-mail: <mao@gnu.org>.
  256.13 +*
  256.14 +*  GLPK is free software: you can redistribute it and/or modify it
  256.15 +*  under the terms of the GNU General Public License as published by
  256.16 +*  the Free Software Foundation, either version 3 of the License, or
  256.17 +*  (at your option) any later version.
  256.18 +*
  256.19 +*  GLPK is distributed in the hope that it will be useful, but WITHOUT
  256.20 +*  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
  256.21 +*  or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
  256.22 +*  License for more details.
  256.23 +*
  256.24 +*  You should have received a copy of the GNU General Public License
  256.25 +*  along with GLPK. If not, see <http://www.gnu.org/licenses/>.
  256.26 +***********************************************************************/
  256.27 +
  256.28 +#include "glpios.h"
  256.29 +
  256.30 +/***********************************************************************
  256.31 +*  NAME
  256.32 +*
  256.33 +*  ios_process_cuts - process cuts stored in the local cut pool
  256.34 +*
  256.35 +*  SYNOPSIS
  256.36 +*
  256.37 +*  #include "glpios.h"
  256.38 +*  void ios_process_cuts(glp_tree *T);
  256.39 +*
  256.40 +*  DESCRIPTION
  256.41 +*
  256.42 +*  The routine ios_process_cuts analyzes each cut currently stored in
  256.43 +*  the local cut pool, which must be non-empty, and either adds the cut
  256.44 +*  to the current subproblem or just discards it. All cuts are assumed
  256.45 +*  to be locally valid. On exit the local cut pool remains unchanged.
  256.46 +*
  256.47 +*  REFERENCES
  256.48 +*
  256.49 +*  1. E.Balas, S.Ceria, G.Cornuejols, "Mixed 0-1 Programming by
  256.50 +*     Lift-and-Project in a Branch-and-Cut Framework", Management Sc.,
  256.51 +*     42 (1996) 1229-1246.
  256.52 +*
  256.53 +*  2. G.Andreello, A.Caprara, and M.Fischetti, "Embedding Cuts in
  256.54 +*     a Branch&Cut Framework: a Computational Study with {0,1/2}-Cuts",
  256.55 +*     Preliminary Draft, October 28, 2003, pp.6-8. */
  256.56 +
  256.57 +struct info
  256.58 +{     /* estimated cut efficiency */
  256.59 +      IOSCUT *cut;
  256.60 +      /* pointer to cut in the cut pool */
  256.61 +      char flag;
  256.62 +      /* if this flag is set, the cut is included into the current
  256.63 +         subproblem */
  256.64 +      double eff;
  256.65 +      /* cut efficacy (normalized residual) */
  256.66 +      double deg;
  256.67 +      /* lower bound to objective degradation */
  256.68 +};
  256.69 +
  256.70 +static int fcmp(const void *arg1, const void *arg2)
  256.71 +{     const struct info *info1 = arg1, *info2 = arg2;
  256.72 +      if (info1->deg == 0.0 && info2->deg == 0.0)
  256.73 +      {  if (info1->eff > info2->eff) return -1;
  256.74 +         if (info1->eff < info2->eff) return +1;
  256.75 +      }
  256.76 +      else
  256.77 +      {  if (info1->deg > info2->deg) return -1;
  256.78 +         if (info1->deg < info2->deg) return +1;
  256.79 +      }
  256.80 +      return 0;
  256.81 +}
  256.82 +
  256.83 +static double parallel(IOSCUT *a, IOSCUT *b, double work[]);
  256.84 +
  256.85 +void ios_process_cuts(glp_tree *T)
  256.86 +{     IOSPOOL *pool;
  256.87 +      IOSCUT *cut;
  256.88 +      IOSAIJ *aij;
  256.89 +      struct info *info;
  256.90 +      int k, kk, max_cuts, len, ret, *ind;
  256.91 +      double *val, *work;
  256.92 +      /* the current subproblem must exist */
  256.93 +      xassert(T->curr != NULL);
  256.94 +      /* the pool must exist and be non-empty */
  256.95 +      pool = T->local;
  256.96 +      xassert(pool != NULL);
  256.97 +      xassert(pool->size > 0);
  256.98 +      /* allocate working arrays */
  256.99 +      info = xcalloc(1+pool->size, sizeof(struct info));
 256.100 +      ind = xcalloc(1+T->n, sizeof(int));
 256.101 +      val = xcalloc(1+T->n, sizeof(double));
 256.102 +      work = xcalloc(1+T->n, sizeof(double));
 256.103 +      for (k = 1; k <= T->n; k++) work[k] = 0.0;
 256.104 +      /* build the list of cuts stored in the cut pool */
 256.105 +      for (k = 0, cut = pool->head; cut != NULL; cut = cut->next)
 256.106 +         k++, info[k].cut = cut, info[k].flag = 0;
 256.107 +      xassert(k == pool->size);
 256.108 +      /* estimate efficiency of all cuts in the cut pool */
 256.109 +      for (k = 1; k <= pool->size; k++)
 256.110 +      {  double temp, dy, dz;
 256.111 +         cut = info[k].cut;
 256.112 +         /* build the vector of cut coefficients and compute its
 256.113 +            Euclidean norm */
 256.114 +         len = 0; temp = 0.0;
 256.115 +         for (aij = cut->ptr; aij != NULL; aij = aij->next)
 256.116 +         {  xassert(1 <= aij->j && aij->j <= T->n);
 256.117 +            len++, ind[len] = aij->j, val[len] = aij->val;
 256.118 +            temp += aij->val * aij->val;
 256.119 +         }
 256.120 +         if (temp < DBL_EPSILON * DBL_EPSILON) temp = DBL_EPSILON;
 256.121 +         /* transform the cut to express it only through non-basic
 256.122 +            (auxiliary and structural) variables */
 256.123 +         len = glp_transform_row(T->mip, len, ind, val);
 256.124 +         /* determine change in the cut value and in the objective
 256.125 +            value for the adjacent basis by simulating one step of the
 256.126 +            dual simplex */
 256.127 +         ret = _glp_analyze_row(T->mip, len, ind, val, cut->type,
 256.128 +            cut->rhs, 1e-9, NULL, NULL, NULL, NULL, &dy, &dz);
 256.129 +         /* determine normalized residual and lower bound to objective
 256.130 +            degradation */
 256.131 +         if (ret == 0)
 256.132 +         {  info[k].eff = fabs(dy) / sqrt(temp);
 256.133 +            /* if some reduced costs violates (slightly) their zero
 256.134 +               bounds (i.e. have wrong signs) due to round-off errors,
 256.135 +               dz also may have wrong sign being close to zero */
 256.136 +            if (T->mip->dir == GLP_MIN)
 256.137 +            {  if (dz < 0.0) dz = 0.0;
 256.138 +               info[k].deg = + dz;
 256.139 +            }
 256.140 +            else /* GLP_MAX */
 256.141 +            {  if (dz > 0.0) dz = 0.0;
 256.142 +               info[k].deg = - dz;
 256.143 +            }
 256.144 +         }
 256.145 +         else if (ret == 1)
 256.146 +         {  /* the constraint is not violated at the current point */
 256.147 +            info[k].eff = info[k].deg = 0.0;
 256.148 +         }
 256.149 +         else if (ret == 2)
 256.150 +         {  /* no dual feasible adjacent basis exists */
 256.151 +            info[k].eff = 1.0;
 256.152 +            info[k].deg = DBL_MAX;
 256.153 +         }
 256.154 +         else
 256.155 +            xassert(ret != ret);
 256.156 +         /* if the degradation is too small, just ignore it */
 256.157 +         if (info[k].deg < 0.01) info[k].deg = 0.0;
 256.158 +      }
 256.159 +      /* sort the list of cuts by decreasing objective degradation and
 256.160 +         then by decreasing efficacy */
 256.161 +      qsort(&info[1], pool->size, sizeof(struct info), fcmp);
 256.162 +      /* only first (most efficient) max_cuts in the list are qualified
 256.163 +         as candidates to be added to the current subproblem */
 256.164 +      max_cuts = (T->curr->level == 0 ? 90 : 10);
 256.165 +      if (max_cuts > pool->size) max_cuts = pool->size;
 256.166 +      /* add cuts to the current subproblem */
 256.167 +#if 0
 256.168 +      xprintf("*** adding cuts ***\n");
 256.169 +#endif
 256.170 +      for (k = 1; k <= max_cuts; k++)
 256.171 +      {  int i, len;
 256.172 +         /* if this cut seems to be inefficient, skip it */
 256.173 +         if (info[k].deg < 0.01 && info[k].eff < 0.01) continue;
 256.174 +         /* if the angle between this cut and every other cut included
 256.175 +            in the current subproblem is small, skip this cut */
 256.176 +         for (kk = 1; kk < k; kk++)
 256.177 +         {  if (info[kk].flag)
 256.178 +            {  if (parallel(info[k].cut, info[kk].cut, work) > 0.90)
 256.179 +                  break;
 256.180 +            }
 256.181 +         }
 256.182 +         if (kk < k) continue;
 256.183 +         /* add this cut to the current subproblem */
 256.184 +#if 0
 256.185 +         xprintf("eff = %g; deg = %g\n", info[k].eff, info[k].deg);
 256.186 +#endif
 256.187 +         cut = info[k].cut, info[k].flag = 1;
 256.188 +         i = glp_add_rows(T->mip, 1);
 256.189 +         if (cut->name != NULL)
 256.190 +            glp_set_row_name(T->mip, i, cut->name);
 256.191 +         xassert(T->mip->row[i]->origin == GLP_RF_CUT);
 256.192 +         T->mip->row[i]->klass = cut->klass;
 256.193 +         len = 0;
 256.194 +         for (aij = cut->ptr; aij != NULL; aij = aij->next)
 256.195 +            len++, ind[len] = aij->j, val[len] = aij->val;
 256.196 +         glp_set_mat_row(T->mip, i, len, ind, val);
 256.197 +         xassert(cut->type == GLP_LO || cut->type == GLP_UP);
 256.198 +         glp_set_row_bnds(T->mip, i, cut->type, cut->rhs, cut->rhs);
 256.199 +      }
 256.200 +      /* free working arrays */
 256.201 +      xfree(info);
 256.202 +      xfree(ind);
 256.203 +      xfree(val);
 256.204 +      xfree(work);
 256.205 +      return;
 256.206 +}
 256.207 +
 256.208 +#if 0
 256.209 +/***********************************************************************
 256.210 +*  Given a cut a * x >= b (<= b) the routine efficacy computes the cut
 256.211 +*  efficacy as follows:
 256.212 +*
 256.213 +*     eff = d * (a * x~ - b) / ||a||,
 256.214 +*
 256.215 +*  where d is -1 (in case of '>= b') or +1 (in case of '<= b'), x~ is
 256.216 +*  the vector of values of structural variables in optimal solution to
 256.217 +*  LP relaxation of the current subproblem, ||a|| is the Euclidean norm
 256.218 +*  of the vector of cut coefficients.
 256.219 +*
 256.220 +*  If the cut is violated at point x~, the efficacy eff is positive,
 256.221 +*  and its value is the Euclidean distance between x~ and the cut plane
 256.222 +*  a * x = b in the space of structural variables.
 256.223 +*
 256.224 +*  Following geometrical intuition, it is quite natural to consider
 256.225 +*  this distance as a first-order measure of the expected efficacy of
 256.226 +*  the cut: the larger the distance the better the cut [1]. */
 256.227 +
 256.228 +static double efficacy(glp_tree *T, IOSCUT *cut)
 256.229 +{     glp_prob *mip = T->mip;
 256.230 +      IOSAIJ *aij;
 256.231 +      double s = 0.0, t = 0.0, temp;
 256.232 +      for (aij = cut->ptr; aij != NULL; aij = aij->next)
 256.233 +      {  xassert(1 <= aij->j && aij->j <= mip->n);
 256.234 +         s += aij->val * mip->col[aij->j]->prim;
 256.235 +         t += aij->val * aij->val;
 256.236 +      }
 256.237 +      temp = sqrt(t);
 256.238 +      if (temp < DBL_EPSILON) temp = DBL_EPSILON;
 256.239 +      if (cut->type == GLP_LO)
 256.240 +         temp = (s >= cut->rhs ? 0.0 : (cut->rhs - s) / temp);
 256.241 +      else if (cut->type == GLP_UP)
 256.242 +         temp = (s <= cut->rhs ? 0.0 : (s - cut->rhs) / temp);
 256.243 +      else
 256.244 +         xassert(cut != cut);
 256.245 +      return temp;
 256.246 +}
 256.247 +#endif
 256.248 +
 256.249 +/***********************************************************************
 256.250 +*  Given two cuts a1 * x >= b1 (<= b1) and a2 * x >= b2 (<= b2) the
 256.251 +*  routine parallel computes the cosine of angle between the cut planes
 256.252 +*  a1 * x = b1 and a2 * x = b2 (which is the acute angle between two
 256.253 +*  normals to these planes) in the space of structural variables as
 256.254 +*  follows:
 256.255 +*
 256.256 +*     cos phi = (a1' * a2) / (||a1|| * ||a2||),
 256.257 +*
 256.258 +*  where (a1' * a2) is a dot product of vectors of cut coefficients,
 256.259 +*  ||a1|| and ||a2|| are Euclidean norms of vectors a1 and a2.
 256.260 +*
 256.261 +*  Note that requirement cos phi = 0 forces the cuts to be orthogonal,
 256.262 +*  i.e. with disjoint support, while requirement cos phi <= 0.999 means
 256.263 +*  only avoiding duplicate (parallel) cuts [1]. */
 256.264 +
 256.265 +static double parallel(IOSCUT *a, IOSCUT *b, double work[])
 256.266 +{     IOSAIJ *aij;
 256.267 +      double s = 0.0, sa = 0.0, sb = 0.0, temp;
 256.268 +      for (aij = a->ptr; aij != NULL; aij = aij->next)
 256.269 +      {  work[aij->j] = aij->val;
 256.270 +         sa += aij->val * aij->val;
 256.271 +      }
 256.272 +      for (aij = b->ptr; aij != NULL; aij = aij->next)
 256.273 +      {  s += work[aij->j] * aij->val;
 256.274 +         sb += aij->val * aij->val;
 256.275 +      }
 256.276 +      for (aij = a->ptr; aij != NULL; aij = aij->next)
 256.277 +         work[aij->j] = 0.0;
 256.278 +      temp = sqrt(sa) * sqrt(sb);
 256.279 +      if (temp < DBL_EPSILON * DBL_EPSILON) temp = DBL_EPSILON;
 256.280 +      return s / temp;
 256.281 +}
 256.282 +
 256.283 +/* eof */
   257.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
   257.2 +++ b/deps/glpk/src/glpios12.c	Sun Nov 06 20:59:10 2011 +0100
   257.3 @@ -0,0 +1,176 @@
   257.4 +/* glpios12.c (node selection heuristics) */
   257.5 +
   257.6 +/***********************************************************************
   257.7 +*  This code is part of GLPK (GNU Linear Programming Kit).
   257.8 +*
   257.9 +*  Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008,
  257.10 +*  2009, 2010, 2011 Andrew Makhorin, Department for Applied Informatics,
  257.11 +*  Moscow Aviation Institute, Moscow, Russia. All rights reserved.
  257.12 +*  E-mail: <mao@gnu.org>.
  257.13 +*
  257.14 +*  GLPK is free software: you can redistribute it and/or modify it
  257.15 +*  under the terms of the GNU General Public License as published by
  257.16 +*  the Free Software Foundation, either version 3 of the License, or
  257.17 +*  (at your option) any later version.
  257.18 +*
  257.19 +*  GLPK is distributed in the hope that it will be useful, but WITHOUT
  257.20 +*  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
  257.21 +*  or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
  257.22 +*  License for more details.
  257.23 +*
  257.24 +*  You should have received a copy of the GNU General Public License
  257.25 +*  along with GLPK. If not, see <http://www.gnu.org/licenses/>.
  257.26 +***********************************************************************/
  257.27 +
  257.28 +#include "glpios.h"
  257.29 +
  257.30 +/***********************************************************************
  257.31 +*  NAME
  257.32 +*
  257.33 +*  ios_choose_node - select subproblem to continue the search
  257.34 +*
  257.35 +*  SYNOPSIS
  257.36 +*
  257.37 +*  #include "glpios.h"
  257.38 +*  int ios_choose_node(glp_tree *T);
  257.39 +*
  257.40 +*  DESCRIPTION
  257.41 +*
  257.42 +*  The routine ios_choose_node selects a subproblem from the active
  257.43 +*  list to continue the search. The choice depends on the backtracking
  257.44 +*  technique option.
  257.45 +*
  257.46 +*  RETURNS
  257.47 +*
  257.48 +*  The routine ios_choose_node return the reference number of the
  257.49 +*  subproblem selected. */
  257.50 +
  257.51 +static int most_feas(glp_tree *T);
  257.52 +static int best_proj(glp_tree *T);
  257.53 +static int best_node(glp_tree *T);
  257.54 +
  257.55 +int ios_choose_node(glp_tree *T)
  257.56 +{     int p;
  257.57 +      if (T->parm->bt_tech == GLP_BT_DFS)
  257.58 +      {  /* depth first search */
  257.59 +         xassert(T->tail != NULL);
  257.60 +         p = T->tail->p;
  257.61 +      }
  257.62 +      else if (T->parm->bt_tech == GLP_BT_BFS)
  257.63 +      {  /* breadth first search */
  257.64 +         xassert(T->head != NULL);
  257.65 +         p = T->head->p;
  257.66 +      }
  257.67 +      else if (T->parm->bt_tech == GLP_BT_BLB)
  257.68 +      {  /* select node with best local bound */
  257.69 +         p = best_node(T);
  257.70 +      }
  257.71 +      else if (T->parm->bt_tech == GLP_BT_BPH)
  257.72 +      {  if (T->mip->mip_stat == GLP_UNDEF)
  257.73 +         {  /* "most integer feasible" subproblem */
  257.74 +            p = most_feas(T);
  257.75 +         }
  257.76 +         else
  257.77 +         {  /* best projection heuristic */
  257.78 +            p = best_proj(T);
  257.79 +         }
  257.80 +      }
  257.81 +      else
  257.82 +         xassert(T != T);
  257.83 +      return p;
  257.84 +}
  257.85 +
  257.86 +static int most_feas(glp_tree *T)
  257.87 +{     /* select subproblem whose parent has minimal sum of integer
  257.88 +         infeasibilities */
  257.89 +      IOSNPD *node;
  257.90 +      int p;
  257.91 +      double best;
  257.92 +      p = 0, best = DBL_MAX;
  257.93 +      for (node = T->head; node != NULL; node = node->next)
  257.94 +      {  xassert(node->up != NULL);
  257.95 +         if (best > node->up->ii_sum)
  257.96 +            p = node->p, best = node->up->ii_sum;
  257.97 +      }
  257.98 +      return p;
  257.99 +}
 257.100 +
 257.101 +static int best_proj(glp_tree *T)
 257.102 +{     /* select subproblem using the best projection heuristic */
 257.103 +      IOSNPD *root, *node;
 257.104 +      int p;
 257.105 +      double best, deg, obj;
 257.106 +      /* the global bound must exist */
 257.107 +      xassert(T->mip->mip_stat == GLP_FEAS);
 257.108 +      /* obtain pointer to the root node, which must exist */
 257.109 +      root = T->slot[1].node;
 257.110 +      xassert(root != NULL);
 257.111 +      /* deg estimates degradation of the objective function per unit
 257.112 +         of the sum of integer infeasibilities */
 257.113 +      xassert(root->ii_sum > 0.0);
 257.114 +      deg = (T->mip->mip_obj - root->bound) / root->ii_sum;
 257.115 +      /* nothing has been selected so far */
 257.116 +      p = 0, best = DBL_MAX;
 257.117 +      /* walk through the list of active subproblems */
 257.118 +      for (node = T->head; node != NULL; node = node->next)
 257.119 +      {  xassert(node->up != NULL);
 257.120 +         /* obj estimates optimal objective value if the sum of integer
 257.121 +            infeasibilities were zero */
 257.122 +         obj = node->up->bound + deg * node->up->ii_sum;
 257.123 +         if (T->mip->dir == GLP_MAX) obj = - obj;
 257.124 +         /* select the subproblem which has the best estimated optimal
 257.125 +            objective value */
 257.126 +         if (best > obj) p = node->p, best = obj;
 257.127 +      }
 257.128 +      return p;
 257.129 +}
 257.130 +
 257.131 +static int best_node(glp_tree *T)
 257.132 +{     /* select subproblem with best local bound */
 257.133 +      IOSNPD *node, *best = NULL;
 257.134 +      double bound, eps;
 257.135 +      switch (T->mip->dir)
 257.136 +      {  case GLP_MIN:
 257.137 +            bound = +DBL_MAX;
 257.138 +            for (node = T->head; node != NULL; node = node->next)
 257.139 +               if (bound > node->bound) bound = node->bound;
 257.140 +            xassert(bound != +DBL_MAX);
 257.141 +            eps = 0.001 * (1.0 + fabs(bound));
 257.142 +            for (node = T->head; node != NULL; node = node->next)
 257.143 +            {  if (node->bound <= bound + eps)
 257.144 +               {  xassert(node->up != NULL);
 257.145 +                  if (best == NULL ||
 257.146 +#if 1
 257.147 +                  best->up->ii_sum > node->up->ii_sum) best = node;
 257.148 +#else
 257.149 +                  best->lp_obj > node->lp_obj) best = node;
 257.150 +#endif
 257.151 +               }
 257.152 +            }
 257.153 +            break;
 257.154 +         case GLP_MAX:
 257.155 +            bound = -DBL_MAX;
 257.156 +            for (node = T->head; node != NULL; node = node->next)
 257.157 +               if (bound < node->bound) bound = node->bound;
 257.158 +            xassert(bound != -DBL_MAX);
 257.159 +            eps = 0.001 * (1.0 + fabs(bound));
 257.160 +            for (node = T->head; node != NULL; node = node->next)
 257.161 +            {  if (node->bound >= bound - eps)
 257.162 +               {  xassert(node->up != NULL);
 257.163 +                  if (best == NULL ||
 257.164 +#if 1
 257.165 +                  best->up->ii_sum > node->up->ii_sum) best = node;
 257.166 +#else
 257.167 +                  best->lp_obj < node->lp_obj) best = node;
 257.168 +#endif
 257.169 +               }
 257.170 +            }
 257.171 +            break;
 257.172 +         default:
 257.173 +            xassert(T != T);
 257.174 +      }
 257.175 +      xassert(best != NULL);
 257.176 +      return best->p;
 257.177 +}
 257.178 +
 257.179 +/* eof */
   258.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
   258.2 +++ b/deps/glpk/src/glpipm.c	Sun Nov 06 20:59:10 2011 +0100
   258.3 @@ -0,0 +1,1143 @@
   258.4 +/* glpipm.c */
   258.5 +
   258.6 +/***********************************************************************
   258.7 +*  This code is part of GLPK (GNU Linear Programming Kit).
   258.8 +*
   258.9 +*  Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008,
  258.10 +*  2009, 2010, 2011 Andrew Makhorin, Department for Applied Informatics,
  258.11 +*  Moscow Aviation Institute, Moscow, Russia. All rights reserved.
  258.12 +*  E-mail: <mao@gnu.org>.
  258.13 +*
  258.14 +*  GLPK is free software: you can redistribute it and/or modify it
  258.15 +*  under the terms of the GNU General Public License as published by
  258.16 +*  the Free Software Foundation, either version 3 of the License, or
  258.17 +*  (at your option) any later version.
  258.18 +*
  258.19 +*  GLPK is distributed in the hope that it will be useful, but WITHOUT
  258.20 +*  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
  258.21 +*  or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
  258.22 +*  License for more details.
  258.23 +*
  258.24 +*  You should have received a copy of the GNU General Public License
  258.25 +*  along with GLPK. If not, see <http://www.gnu.org/licenses/>.
  258.26 +***********************************************************************/
  258.27 +
  258.28 +#include "glpipm.h"
  258.29 +#include "glpmat.h"
  258.30 +
  258.31 +#define ITER_MAX 100
  258.32 +/* maximal number of iterations */
  258.33 +
  258.34 +struct csa
  258.35 +{     /* common storage area */
  258.36 +      /*--------------------------------------------------------------*/
  258.37 +      /* LP data */
  258.38 +      int m;
  258.39 +      /* number of rows (equality constraints) */
  258.40 +      int n;
  258.41 +      /* number of columns (structural variables) */
  258.42 +      int *A_ptr; /* int A_ptr[1+m+1]; */
  258.43 +      int *A_ind; /* int A_ind[A_ptr[m+1]]; */
  258.44 +      double *A_val; /* double A_val[A_ptr[m+1]]; */
  258.45 +      /* mxn-matrix A in storage-by-rows format */
  258.46 +      double *b; /* double b[1+m]; */
  258.47 +      /* m-vector b of right-hand sides */
  258.48 +      double *c; /* double c[1+n]; */
  258.49 +      /* n-vector c of objective coefficients; c[0] is constant term of
  258.50 +         the objective function */
  258.51 +      /*--------------------------------------------------------------*/
  258.52 +      /* LP solution */
  258.53 +      double *x; /* double x[1+n]; */
  258.54 +      double *y; /* double y[1+m]; */
  258.55 +      double *z; /* double z[1+n]; */
  258.56 +      /* current point in primal-dual space; the best point on exit */
  258.57 +      /*--------------------------------------------------------------*/
  258.58 +      /* control parameters */
  258.59 +      const glp_iptcp *parm;
  258.60 +      /*--------------------------------------------------------------*/
  258.61 +      /* working arrays and variables */
  258.62 +      double *D; /* double D[1+n]; */
  258.63 +      /* diagonal nxn-matrix D = X*inv(Z), where X = diag(x[j]) and
  258.64 +         Z = diag(z[j]) */
  258.65 +      int *P; /* int P[1+m+m]; */
  258.66 +      /* permutation mxm-matrix P used to minimize fill-in in Cholesky
  258.67 +         factorization */
  258.68 +      int *S_ptr; /* int S_ptr[1+m+1]; */
  258.69 +      int *S_ind; /* int S_ind[S_ptr[m+1]]; */
  258.70 +      double *S_val; /* double S_val[S_ptr[m+1]]; */
  258.71 +      double *S_diag; /* double S_diag[1+m]; */
  258.72 +      /* symmetric mxm-matrix S = P*A*D*A'*P' whose upper triangular
  258.73 +         part without diagonal elements is stored in S_ptr, S_ind, and
  258.74 +         S_val in storage-by-rows format, diagonal elements are stored
  258.75 +         in S_diag */
  258.76 +      int *U_ptr; /* int U_ptr[1+m+1]; */
  258.77 +      int *U_ind; /* int U_ind[U_ptr[m+1]]; */
  258.78 +      double *U_val; /* double U_val[U_ptr[m+1]]; */
  258.79 +      double *U_diag; /* double U_diag[1+m]; */
  258.80 +      /* upper triangular mxm-matrix U defining Cholesky factorization
  258.81 +         S = U'*U; its non-diagonal elements are stored in U_ptr, U_ind,
  258.82 +         U_val in storage-by-rows format, diagonal elements are stored
  258.83 +         in U_diag */
  258.84 +      int iter;
  258.85 +      /* iteration number (0, 1, 2, ...); iter = 0 corresponds to the
  258.86 +         initial point */
  258.87 +      double obj;
  258.88 +      /* current value of the objective function */
  258.89 +      double rpi;
  258.90 +      /* relative primal infeasibility rpi = ||A*x-b||/(1+||b||) */
  258.91 +      double rdi;
  258.92 +      /* relative dual infeasibility rdi = ||A'*y+z-c||/(1+||c||) */
  258.93 +      double gap;
  258.94 +      /* primal-dual gap = |c'*x-b'*y|/(1+|c'*x|) which is a relative
  258.95 +         difference between primal and dual objective functions */
  258.96 +      double phi;
  258.97 +      /* merit function phi = ||A*x-b||/max(1,||b||) +
  258.98 +                            + ||A'*y+z-c||/max(1,||c||) +
  258.99 +                            + |c'*x-b'*y|/max(1,||b||,||c||) */
 258.100 +      double mu;
 258.101 +      /* duality measure mu = x'*z/n (used as barrier parameter) */
 258.102 +      double rmu;
 258.103 +      /* rmu = max(||A*x-b||,||A'*y+z-c||)/mu */
 258.104 +      double rmu0;
 258.105 +      /* the initial value of rmu on iteration 0 */
 258.106 +      double *phi_min; /* double phi_min[1+ITER_MAX]; */
 258.107 +      /* phi_min[k] = min(phi[k]), where phi[k] is the value of phi on
 258.108 +         k-th iteration, 0 <= k <= iter */
 258.109 +      int best_iter;
 258.110 +      /* iteration number, on which the value of phi reached its best
 258.111 +         (minimal) value */
 258.112 +      double *best_x; /* double best_x[1+n]; */
 258.113 +      double *best_y; /* double best_y[1+m]; */
 258.114 +      double *best_z; /* double best_z[1+n]; */
 258.115 +      /* best point (in the sense of the merit function phi) which has
 258.116 +         been reached on iteration iter_best */
 258.117 +      double best_obj;
 258.118 +      /* objective value at the best point */
 258.119 +      double *dx_aff; /* double dx_aff[1+n]; */
 258.120 +      double *dy_aff; /* double dy_aff[1+m]; */
 258.121 +      double *dz_aff; /* double dz_aff[1+n]; */
 258.122 +      /* affine scaling direction */
 258.123 +      double alfa_aff_p, alfa_aff_d;
 258.124 +      /* maximal primal and dual stepsizes in affine scaling direction,
 258.125 +         on which x and z are still non-negative */
 258.126 +      double mu_aff;
 258.127 +      /* duality measure mu_aff = x_aff'*z_aff/n in the boundary point
 258.128 +         x_aff' = x+alfa_aff_p*dx_aff, z_aff' = z+alfa_aff_d*dz_aff */
 258.129 +      double sigma;
 258.130 +      /* Mehrotra's heuristic parameter (0 <= sigma <= 1) */
 258.131 +      double *dx_cc; /* double dx_cc[1+n]; */
 258.132 +      double *dy_cc; /* double dy_cc[1+m]; */
 258.133 +      double *dz_cc; /* double dz_cc[1+n]; */
 258.134 +      /* centering corrector direction */
 258.135 +      double *dx; /* double dx[1+n]; */
 258.136 +      double *dy; /* double dy[1+m]; */
 258.137 +      double *dz; /* double dz[1+n]; */
 258.138 +      /* final combined direction dx = dx_aff+dx_cc, dy = dy_aff+dy_cc,
 258.139 +         dz = dz_aff+dz_cc */
 258.140 +      double alfa_max_p;
 258.141 +      double alfa_max_d;
 258.142 +      /* maximal primal and dual stepsizes in combined direction, on
 258.143 +         which x and z are still non-negative */
 258.144 +};
 258.145 +
 258.146 +/***********************************************************************
 258.147 +*  initialize - allocate and initialize common storage area
 258.148 +*
 258.149 +*  This routine allocates and initializes the common storage area (CSA)
 258.150 +*  used by interior-point method routines. */
 258.151 +
 258.152 +static void initialize(struct csa *csa)
 258.153 +{     int m = csa->m;
 258.154 +      int n = csa->n;
 258.155 +      int i;
 258.156 +      if (csa->parm->msg_lev >= GLP_MSG_ALL)
 258.157 +         xprintf("Matrix A has %d non-zeros\n", csa->A_ptr[m+1]-1);
 258.158 +      csa->D = xcalloc(1+n, sizeof(double));
 258.159 +      /* P := I */
 258.160 +      csa->P = xcalloc(1+m+m, sizeof(int));
 258.161 +      for (i = 1; i <= m; i++) csa->P[i] = csa->P[m+i] = i;
 258.162 +      /* S := A*A', symbolically */
 258.163 +      csa->S_ptr = xcalloc(1+m+1, sizeof(int));
 258.164 +      csa->S_ind = adat_symbolic(m, n, csa->P, csa->A_ptr, csa->A_ind,
 258.165 +         csa->S_ptr);
 258.166 +      if (csa->parm->msg_lev >= GLP_MSG_ALL)
 258.167 +         xprintf("Matrix S = A*A' has %d non-zeros (upper triangle)\n",
 258.168 +            csa->S_ptr[m+1]-1 + m);
 258.169 +      /* determine P using specified ordering algorithm */
 258.170 +      if (csa->parm->ord_alg == GLP_ORD_NONE)
 258.171 +      {  if (csa->parm->msg_lev >= GLP_MSG_ALL)
 258.172 +            xprintf("Original ordering is being used\n");
 258.173 +         for (i = 1; i <= m; i++)
 258.174 +            csa->P[i] = csa->P[m+i] = i;
 258.175 +      }
 258.176 +      else if (csa->parm->ord_alg == GLP_ORD_QMD)
 258.177 +      {  if (csa->parm->msg_lev >= GLP_MSG_ALL)
 258.178 +            xprintf("Minimum degree ordering (QMD)...\n");
 258.179 +         min_degree(m, csa->S_ptr, csa->S_ind, csa->P);
 258.180 +      }
 258.181 +      else if (csa->parm->ord_alg == GLP_ORD_AMD)
 258.182 +      {  if (csa->parm->msg_lev >= GLP_MSG_ALL)
 258.183 +            xprintf("Approximate minimum degree ordering (AMD)...\n");
 258.184 +         amd_order1(m, csa->S_ptr, csa->S_ind, csa->P);
 258.185 +      }
 258.186 +      else if (csa->parm->ord_alg == GLP_ORD_SYMAMD)
 258.187 +      {  if (csa->parm->msg_lev >= GLP_MSG_ALL)
 258.188 +            xprintf("Approximate minimum degree ordering (SYMAMD)...\n")
 258.189 +               ;
 258.190 +         symamd_ord(m, csa->S_ptr, csa->S_ind, csa->P);
 258.191 +      }
 258.192 +      else
 258.193 +         xassert(csa != csa);
 258.194 +      /* S := P*A*A'*P', symbolically */
 258.195 +      xfree(csa->S_ind);
 258.196 +      csa->S_ind = adat_symbolic(m, n, csa->P, csa->A_ptr, csa->A_ind,
 258.197 +         csa->S_ptr);
 258.198 +      csa->S_val = xcalloc(csa->S_ptr[m+1], sizeof(double));
 258.199 +      csa->S_diag = xcalloc(1+m, sizeof(double));
 258.200 +      /* compute Cholesky factorization S = U'*U, symbolically */
 258.201 +      if (csa->parm->msg_lev >= GLP_MSG_ALL)
 258.202 +         xprintf("Computing Cholesky factorization S = L*L'...\n");
 258.203 +      csa->U_ptr = xcalloc(1+m+1, sizeof(int));
 258.204 +      csa->U_ind = chol_symbolic(m, csa->S_ptr, csa->S_ind, csa->U_ptr);
 258.205 +      if (csa->parm->msg_lev >= GLP_MSG_ALL)
 258.206 +         xprintf("Matrix L has %d non-zeros\n", csa->U_ptr[m+1]-1 + m);
 258.207 +      csa->U_val = xcalloc(csa->U_ptr[m+1], sizeof(double));
 258.208 +      csa->U_diag = xcalloc(1+m, sizeof(double));
 258.209 +      csa->iter = 0;
 258.210 +      csa->obj = 0.0;
 258.211 +      csa->rpi = 0.0;
 258.212 +      csa->rdi = 0.0;
 258.213 +      csa->gap = 0.0;
 258.214 +      csa->phi = 0.0;
 258.215 +      csa->mu = 0.0;
 258.216 +      csa->rmu = 0.0;
 258.217 +      csa->rmu0 = 0.0;
 258.218 +      csa->phi_min = xcalloc(1+ITER_MAX, sizeof(double));
 258.219 +      csa->best_iter = 0;
 258.220 +      csa->best_x = xcalloc(1+n, sizeof(double));
 258.221 +      csa->best_y = xcalloc(1+m, sizeof(double));
 258.222 +      csa->best_z = xcalloc(1+n, sizeof(double));
 258.223 +      csa->best_obj = 0.0;
 258.224 +      csa->dx_aff = xcalloc(1+n, sizeof(double));
 258.225 +      csa->dy_aff = xcalloc(1+m, sizeof(double));
 258.226 +      csa->dz_aff = xcalloc(1+n, sizeof(double));
 258.227 +      csa->alfa_aff_p = 0.0;
 258.228 +      csa->alfa_aff_d = 0.0;
 258.229 +      csa->mu_aff = 0.0;
 258.230 +      csa->sigma = 0.0;
 258.231 +      csa->dx_cc = xcalloc(1+n, sizeof(double));
 258.232 +      csa->dy_cc = xcalloc(1+m, sizeof(double));
 258.233 +      csa->dz_cc = xcalloc(1+n, sizeof(double));
 258.234 +      csa->dx = csa->dx_aff;
 258.235 +      csa->dy = csa->dy_aff;
 258.236 +      csa->dz = csa->dz_aff;
 258.237 +      csa->alfa_max_p = 0.0;
 258.238 +      csa->alfa_max_d = 0.0;
 258.239 +      return;
 258.240 +}
 258.241 +
 258.242 +/***********************************************************************
 258.243 +*  A_by_vec - compute y = A*x
 258.244 +*
 258.245 +*  This routine computes matrix-vector product y = A*x, where A is the
 258.246 +*  constraint matrix. */
 258.247 +
 258.248 +static void A_by_vec(struct csa *csa, double x[], double y[])
 258.249 +{     /* compute y = A*x */
 258.250 +      int m = csa->m;
 258.251 +      int *A_ptr = csa->A_ptr;
 258.252 +      int *A_ind = csa->A_ind;
 258.253 +      double *A_val = csa->A_val;
 258.254 +      int i, t, beg, end;
 258.255 +      double temp;
 258.256 +      for (i = 1; i <= m; i++)
 258.257 +      {  temp = 0.0;
 258.258 +         beg = A_ptr[i], end = A_ptr[i+1];
 258.259 +         for (t = beg; t < end; t++) temp += A_val[t] * x[A_ind[t]];
 258.260 +         y[i] = temp;
 258.261 +      }
 258.262 +      return;
 258.263 +}
 258.264 +
 258.265 +/***********************************************************************
 258.266 +*  AT_by_vec - compute y = A'*x
 258.267 +*
 258.268 +*  This routine computes matrix-vector product y = A'*x, where A' is a
 258.269 +*  matrix transposed to the constraint matrix A. */
 258.270 +
 258.271 +static void AT_by_vec(struct csa *csa, double x[], double y[])
 258.272 +{     /* compute y = A'*x, where A' is transposed to A */
 258.273 +      int m = csa->m;
 258.274 +      int n = csa->n;
 258.275 +      int *A_ptr = csa->A_ptr;
 258.276 +      int *A_ind = csa->A_ind;
 258.277 +      double *A_val = csa->A_val;
 258.278 +      int i, j, t, beg, end;
 258.279 +      double temp;
 258.280 +      for (j = 1; j <= n; j++) y[j] = 0.0;
 258.281 +      for (i = 1; i <= m; i++)
 258.282 +      {  temp = x[i];
 258.283 +         if (temp == 0.0) continue;
 258.284 +         beg = A_ptr[i], end = A_ptr[i+1];
 258.285 +         for (t = beg; t < end; t++) y[A_ind[t]] += A_val[t] * temp;
 258.286 +      }
 258.287 +      return;
 258.288 +}
 258.289 +
 258.290 +/***********************************************************************
 258.291 +*  decomp_NE - numeric factorization of matrix S = P*A*D*A'*P'
 258.292 +*
 258.293 +*  This routine implements numeric phase of Cholesky factorization of
 258.294 +*  the matrix S = P*A*D*A'*P', which is a permuted matrix of the normal
 258.295 +*  equation system. Matrix D is assumed to be already computed. */
 258.296 +
 258.297 +static void decomp_NE(struct csa *csa)
 258.298 +{     adat_numeric(csa->m, csa->n, csa->P, csa->A_ptr, csa->A_ind,
 258.299 +         csa->A_val, csa->D, csa->S_ptr, csa->S_ind, csa->S_val,
 258.300 +         csa->S_diag);
 258.301 +      chol_numeric(csa->m, csa->S_ptr, csa->S_ind, csa->S_val,
 258.302 +         csa->S_diag, csa->U_ptr, csa->U_ind, csa->U_val, csa->U_diag);
 258.303 +      return;
 258.304 +}
 258.305 +
 258.306 +/***********************************************************************
 258.307 +*  solve_NE - solve normal equation system
 258.308 +*
 258.309 +*  This routine solves the normal equation system:
 258.310 +*
 258.311 +*     A*D*A'*y = h.
 258.312 +*
 258.313 +*  It is assumed that the matrix A*D*A' has been previously factorized
 258.314 +*  by the routine decomp_NE.
 258.315 +*
 258.316 +*  On entry the array y contains the vector of right-hand sides h. On
 258.317 +*  exit this array contains the computed vector of unknowns y.
 258.318 +*
 258.319 +*  Once the vector y has been computed the routine checks for numeric
 258.320 +*  stability. If the residual vector:
 258.321 +*
 258.322 +*     r = A*D*A'*y - h
 258.323 +*
 258.324 +*  is relatively small, the routine returns zero, otherwise non-zero is
 258.325 +*  returned. */
 258.326 +
 258.327 +static int solve_NE(struct csa *csa, double y[])
 258.328 +{     int m = csa->m;
 258.329 +      int n = csa->n;
 258.330 +      int *P = csa->P;
 258.331 +      int i, j, ret = 0;
 258.332 +      double *h, *r, *w;
 258.333 +      /* save vector of right-hand sides h */
 258.334 +      h = xcalloc(1+m, sizeof(double));
 258.335 +      for (i = 1; i <= m; i++) h[i] = y[i];
 258.336 +      /* solve normal equation system (A*D*A')*y = h */
 258.337 +      /* since S = P*A*D*A'*P' = U'*U, then A*D*A' = P'*U'*U*P, so we
 258.338 +         have inv(A*D*A') = P'*inv(U)*inv(U')*P */
 258.339 +      /* w := P*h */
 258.340 +      w = xcalloc(1+m, sizeof(double));
 258.341 +      for (i = 1; i <= m; i++) w[i] = y[P[i]];
 258.342 +      /* w := inv(U')*w */
 258.343 +      ut_solve(m, csa->U_ptr, csa->U_ind, csa->U_val, csa->U_diag, w);
 258.344 +      /* w := inv(U)*w */
 258.345 +      u_solve(m, csa->U_ptr, csa->U_ind, csa->U_val, csa->U_diag, w);
 258.346 +      /* y := P'*w */
 258.347 +      for (i = 1; i <= m; i++) y[i] = w[P[m+i]];
 258.348 +      xfree(w);
 258.349 +      /* compute residual vector r = A*D*A'*y - h */
 258.350 +      r = xcalloc(1+m, sizeof(double));
 258.351 +      /* w := A'*y */
 258.352 +      w = xcalloc(1+n, sizeof(double));
 258.353 +      AT_by_vec(csa, y, w);
 258.354 +      /* w := D*w */
 258.355 +      for (j = 1; j <= n; j++) w[j] *= csa->D[j];
 258.356 +      /* r := A*w */
 258.357 +      A_by_vec(csa, w, r);
 258.358 +      xfree(w);
 258.359 +      /* r := r - h */
 258.360 +      for (i = 1; i <= m; i++) r[i] -= h[i];
 258.361 +      /* check for numeric stability */
 258.362 +      for (i = 1; i <= m; i++)
 258.363 +      {  if (fabs(r[i]) / (1.0 + fabs(h[i])) > 1e-4)
 258.364 +         {  ret = 1;
 258.365 +            break;
 258.366 +         }
 258.367 +      }
 258.368 +      xfree(h);
 258.369 +      xfree(r);
 258.370 +      return ret;
 258.371 +}
 258.372 +
 258.373 +/***********************************************************************
 258.374 +*  solve_NS - solve Newtonian system
 258.375 +*
 258.376 +*  This routine solves the Newtonian system:
 258.377 +*
 258.378 +*     A*dx               = p
 258.379 +*
 258.380 +*           A'*dy +   dz = q
 258.381 +*
 258.382 +*     Z*dx        + X*dz = r
 258.383 +*
 258.384 +*  where X = diag(x[j]), Z = diag(z[j]), by reducing it to the normal
 258.385 +*  equation system:
 258.386 +*
 258.387 +*     (A*inv(Z)*X*A')*dy = A*inv(Z)*(X*q-r)+p
 258.388 +*
 258.389 +*  (it is assumed that the matrix A*inv(Z)*X*A' has been factorized by
 258.390 +*  the routine decomp_NE).
 258.391 +*
 258.392 +*  Once vector dy has been computed the routine computes vectors dx and
 258.393 +*  dz as follows:
 258.394 +*
 258.395 +*     dx = inv(Z)*(X*(A'*dy-q)+r)
 258.396 +*
 258.397 +*     dz = inv(X)*(r-Z*dx)
 258.398 +*
 258.399 +*  The routine solve_NS returns the same code which was reported by the
 258.400 +*  routine solve_NE (see above). */
 258.401 +
 258.402 +static int solve_NS(struct csa *csa, double p[], double q[], double r[],
 258.403 +      double dx[], double dy[], double dz[])
 258.404 +{     int m = csa->m;
 258.405 +      int n = csa->n;
 258.406 +      double *x = csa->x;
 258.407 +      double *z = csa->z;
 258.408 +      int i, j, ret;
 258.409 +      double *w = dx;
 258.410 +      /* compute the vector of right-hand sides A*inv(Z)*(X*q-r)+p for
 258.411 +         the normal equation system */
 258.412 +      for (j = 1; j <= n; j++)
 258.413 +         w[j] = (x[j] * q[j] - r[j]) / z[j];
 258.414 +      A_by_vec(csa, w, dy);
 258.415 +      for (i = 1; i <= m; i++) dy[i] += p[i];
 258.416 +      /* solve the normal equation system to compute vector dy */
 258.417 +      ret = solve_NE(csa, dy);
 258.418 +      /* compute vectors dx and dz */
 258.419 +      AT_by_vec(csa, dy, dx);
 258.420 +      for (j = 1; j <= n; j++)
 258.421 +      {  dx[j] = (x[j] * (dx[j] - q[j]) + r[j]) / z[j];
 258.422 +         dz[j] = (r[j] - z[j] * dx[j]) / x[j];
 258.423 +      }
 258.424 +      return ret;
 258.425 +}
 258.426 +
 258.427 +/***********************************************************************
 258.428 +*  initial_point - choose initial point using Mehrotra's heuristic
 258.429 +*
 258.430 +*  This routine chooses a starting point using a heuristic proposed in
 258.431 +*  the paper:
 258.432 +*
 258.433 +*  S. Mehrotra. On the implementation of a primal-dual interior point
 258.434 +*  method. SIAM J. on Optim., 2(4), pp. 575-601, 1992.
 258.435 +*
 258.436 +*  The starting point x in the primal space is chosen as a solution of
 258.437 +*  the following least squares problem:
 258.438 +*
 258.439 +*     minimize    ||x||
 258.440 +*
 258.441 +*     subject to  A*x = b
 258.442 +*
 258.443 +*  which can be computed explicitly as follows:
 258.444 +*
 258.445 +*     x = A'*inv(A*A')*b
 258.446 +*
 258.447 +*  Similarly, the starting point (y, z) in the dual space is chosen as
 258.448 +*  a solution of the following least squares problem:
 258.449 +*
 258.450 +*     minimize    ||z||
 258.451 +*
 258.452 +*     subject to  A'*y + z = c
 258.453 +*
 258.454 +*  which can be computed explicitly as follows:
 258.455 +*
 258.456 +*     y = inv(A*A')*A*c
 258.457 +*
 258.458 +*     z = c - A'*y
 258.459 +*
 258.460 +*  However, some components of the vectors x and z may be non-positive
 258.461 +*  or close to zero, so the routine uses a Mehrotra's heuristic to find
 258.462 +*  a more appropriate starting point. */
 258.463 +
 258.464 +static void initial_point(struct csa *csa)
 258.465 +{     int m = csa->m;
 258.466 +      int n = csa->n;
 258.467 +      double *b = csa->b;
 258.468 +      double *c = csa->c;
 258.469 +      double *x = csa->x;
 258.470 +      double *y = csa->y;
 258.471 +      double *z = csa->z;
 258.472 +      double *D = csa->D;
 258.473 +      int i, j;
 258.474 +      double dp, dd, ex, ez, xz;
 258.475 +      /* factorize A*A' */
 258.476 +      for (j = 1; j <= n; j++) D[j] = 1.0;
 258.477 +      decomp_NE(csa);
 258.478 +      /* x~ = A'*inv(A*A')*b */
 258.479 +      for (i = 1; i <= m; i++) y[i] = b[i];
 258.480 +      solve_NE(csa, y);
 258.481 +      AT_by_vec(csa, y, x);
 258.482 +      /* y~ = inv(A*A')*A*c */
 258.483 +      A_by_vec(csa, c, y);
 258.484 +      solve_NE(csa, y);
 258.485 +      /* z~ = c - A'*y~ */
 258.486 +      AT_by_vec(csa, y,z);
 258.487 +      for (j = 1; j <= n; j++) z[j] = c[j] - z[j];
 258.488 +      /* use Mehrotra's heuristic in order to choose more appropriate
 258.489 +         starting point with positive components of vectors x and z */
 258.490 +      dp = dd = 0.0;
 258.491 +      for (j = 1; j <= n; j++)
 258.492 +      {  if (dp < -1.5 * x[j]) dp = -1.5 * x[j];
 258.493 +         if (dd < -1.5 * z[j]) dd = -1.5 * z[j];
 258.494 +      }
 258.495 +      /* note that b = 0 involves x = 0, and c = 0 involves y = 0 and
 258.496 +         z = 0, so we need to be careful */
 258.497 +      if (dp == 0.0) dp = 1.5;
 258.498 +      if (dd == 0.0) dd = 1.5;
 258.499 +      ex = ez = xz = 0.0;
 258.500 +      for (j = 1; j <= n; j++)
 258.501 +      {  ex += (x[j] + dp);
 258.502 +         ez += (z[j] + dd);
 258.503 +         xz += (x[j] + dp) * (z[j] + dd);
 258.504 +      }
 258.505 +      dp += 0.5 * (xz / ez);
 258.506 +      dd += 0.5 * (xz / ex);
 258.507 +      for (j = 1; j <= n; j++)
 258.508 +      {  x[j] += dp;
 258.509 +         z[j] += dd;
 258.510 +         xassert(x[j] > 0.0 && z[j] > 0.0);
 258.511 +      }
 258.512 +      return;
 258.513 +}
 258.514 +
 258.515 +/***********************************************************************
 258.516 +*  basic_info - perform basic computations at the current point
 258.517 +*
 258.518 +*  This routine computes the following quantities at the current point:
 258.519 +*
 258.520 +*  1) value of the objective function:
 258.521 +*
 258.522 +*     F = c'*x + c[0]
 258.523 +*
 258.524 +*  2) relative primal infeasibility:
 258.525 +*
 258.526 +*     rpi = ||A*x-b|| / (1+||b||)
 258.527 +*
 258.528 +*  3) relative dual infeasibility:
 258.529 +*
 258.530 +*     rdi = ||A'*y+z-c|| / (1+||c||)
 258.531 +*
 258.532 +*  4) primal-dual gap (relative difference between the primal and the
 258.533 +*     dual objective function values):
 258.534 +*
 258.535 +*     gap = |c'*x-b'*y| / (1+|c'*x|)
 258.536 +*
 258.537 +*  5) merit function:
 258.538 +*
 258.539 +*     phi = ||A*x-b|| / max(1,||b||) + ||A'*y+z-c|| / max(1,||c||) +
 258.540 +*
 258.541 +*         + |c'*x-b'*y| / max(1,||b||,||c||)
 258.542 +*
 258.543 +*  6) duality measure:
 258.544 +*
 258.545 +*     mu = x'*z / n
 258.546 +*
 258.547 +*  7) the ratio of infeasibility to mu:
 258.548 +*
 258.549 +*     rmu = max(||A*x-b||,||A'*y+z-c||) / mu
 258.550 +*
 258.551 +*  where ||*|| denotes euclidian norm, *' denotes transposition. */
 258.552 +
 258.553 +static void basic_info(struct csa *csa)
 258.554 +{     int m = csa->m;
 258.555 +      int n = csa->n;
 258.556 +      double *b = csa->b;
 258.557 +      double *c = csa->c;
 258.558 +      double *x = csa->x;
 258.559 +      double *y = csa->y;
 258.560 +      double *z = csa->z;
 258.561 +      int i, j;
 258.562 +      double norm1, bnorm, norm2, cnorm, cx, by, *work, temp;
 258.563 +      /* compute value of the objective function */
 258.564 +      temp = c[0];
 258.565 +      for (j = 1; j <= n; j++) temp += c[j] * x[j];
 258.566 +      csa->obj = temp;
 258.567 +      /* norm1 = ||A*x-b|| */
 258.568 +      work = xcalloc(1+m, sizeof(double));
 258.569 +      A_by_vec(csa, x, work);
 258.570 +      norm1 = 0.0;
 258.571 +      for (i = 1; i <= m; i++)
 258.572 +         norm1 += (work[i] - b[i]) * (work[i] - b[i]);
 258.573 +      norm1 = sqrt(norm1);
 258.574 +      xfree(work);
 258.575 +      /* bnorm = ||b|| */
 258.576 +      bnorm = 0.0;
 258.577 +      for (i = 1; i <= m; i++) bnorm += b[i] * b[i];
 258.578 +      bnorm = sqrt(bnorm);
 258.579 +      /* compute relative primal infeasibility */
 258.580 +      csa->rpi = norm1 / (1.0 + bnorm);
 258.581 +      /* norm2 = ||A'*y+z-c|| */
 258.582 +      work = xcalloc(1+n, sizeof(double));
 258.583 +      AT_by_vec(csa, y, work);
 258.584 +      norm2 = 0.0;
 258.585 +      for (j = 1; j <= n; j++)
 258.586 +         norm2 += (work[j] + z[j] - c[j]) * (work[j] + z[j] - c[j]);
 258.587 +      norm2 = sqrt(norm2);
 258.588 +      xfree(work);
 258.589 +      /* cnorm = ||c|| */
 258.590 +      cnorm = 0.0;
 258.591 +      for (j = 1; j <= n; j++) cnorm += c[j] * c[j];
 258.592 +      cnorm = sqrt(cnorm);
 258.593 +      /* compute relative dual infeasibility */
 258.594 +      csa->rdi = norm2 / (1.0 + cnorm);
 258.595 +      /* by = b'*y */
 258.596 +      by = 0.0;
 258.597 +      for (i = 1; i <= m; i++) by += b[i] * y[i];
 258.598 +      /* cx = c'*x */
 258.599 +      cx = 0.0;
 258.600 +      for (j = 1; j <= n; j++) cx += c[j] * x[j];
 258.601 +      /* compute primal-dual gap */
 258.602 +      csa->gap = fabs(cx - by) / (1.0 + fabs(cx));
 258.603 +      /* compute merit function */
 258.604 +      csa->phi = 0.0;
 258.605 +      csa->phi += norm1 / (bnorm > 1.0 ? bnorm : 1.0);
 258.606 +      csa->phi += norm2 / (cnorm > 1.0 ? cnorm : 1.0);
 258.607 +      temp = 1.0;
 258.608 +      if (temp < bnorm) temp = bnorm;
 258.609 +      if (temp < cnorm) temp = cnorm;
 258.610 +      csa->phi += fabs(cx - by) / temp;
 258.611 +      /* compute duality measure */
 258.612 +      temp = 0.0;
 258.613 +      for (j = 1; j <= n; j++) temp += x[j] * z[j];
 258.614 +      csa->mu = temp / (double)n;
 258.615 +      /* compute the ratio of infeasibility to mu */
 258.616 +      csa->rmu = (norm1 > norm2 ? norm1 : norm2) / csa->mu;
 258.617 +      return;
 258.618 +}
 258.619 +
 258.620 +/***********************************************************************
 258.621 +*  make_step - compute next point using Mehrotra's technique
 258.622 +*
 258.623 +*  This routine computes the next point using the predictor-corrector
 258.624 +*  technique proposed in the paper:
 258.625 +*
 258.626 +*  S. Mehrotra. On the implementation of a primal-dual interior point
 258.627 +*  method. SIAM J. on Optim., 2(4), pp. 575-601, 1992.
 258.628 +*
 258.629 +*  At first, the routine computes so called affine scaling (predictor)
 258.630 +*  direction (dx_aff,dy_aff,dz_aff) which is a solution of the system:
 258.631 +*
 258.632 +*     A*dx_aff                       = b - A*x
 258.633 +*
 258.634 +*               A'*dy_aff +   dz_aff = c - A'*y - z
 258.635 +*
 258.636 +*     Z*dx_aff            + X*dz_aff = - X*Z*e
 258.637 +*
 258.638 +*  where (x,y,z) is the current point, X = diag(x[j]), Z = diag(z[j]),
 258.639 +*  e = (1,...,1)'.
 258.640 +*
 258.641 +*  Then, the routine computes the centering parameter sigma, using the
 258.642 +*  following Mehrotra's heuristic:
 258.643 +*
 258.644 +*     alfa_aff_p = inf{0 <= alfa <= 1 | x+alfa*dx_aff >= 0}
 258.645 +*
 258.646 +*     alfa_aff_d = inf{0 <= alfa <= 1 | z+alfa*dz_aff >= 0}
 258.647 +*
 258.648 +*     mu_aff = (x+alfa_aff_p*dx_aff)'*(z+alfa_aff_d*dz_aff)/n
 258.649 +*
 258.650 +*     sigma = (mu_aff/mu)^3
 258.651 +*
 258.652 +*  where alfa_aff_p is the maximal stepsize along the affine scaling
 258.653 +*  direction in the primal space, alfa_aff_d is the maximal stepsize
 258.654 +*  along the same direction in the dual space.
 258.655 +*
 258.656 +*  After determining sigma the routine computes so called centering
 258.657 +*  (corrector) direction (dx_cc,dy_cc,dz_cc) which is the solution of
 258.658 +*  the system:
 258.659 +*
 258.660 +*     A*dx_cc                     = 0
 258.661 +*
 258.662 +*              A'*dy_cc +   dz_cc = 0
 258.663 +*
 258.664 +*     Z*dx_cc           + X*dz_cc = sigma*mu*e - X*Z*e
 258.665 +*
 258.666 +*  Finally, the routine computes the combined direction
 258.667 +*
 258.668 +*     (dx,dy,dz) = (dx_aff,dy_aff,dz_aff) + (dx_cc,dy_cc,dz_cc)
 258.669 +*
 258.670 +*  and determines maximal primal and dual stepsizes along the combined
 258.671 +*  direction:
 258.672 +*
 258.673 +*     alfa_max_p = inf{0 <= alfa <= 1 | x+alfa*dx >= 0}
 258.674 +*
 258.675 +*     alfa_max_d = inf{0 <= alfa <= 1 | z+alfa*dz >= 0}
 258.676 +*
 258.677 +*  In order to prevent the next point to be too close to the boundary
 258.678 +*  of the positive ortant, the routine decreases maximal stepsizes:
 258.679 +*
 258.680 +*     alfa_p = gamma_p * alfa_max_p
 258.681 +*
 258.682 +*     alfa_d = gamma_d * alfa_max_d
 258.683 +*
 258.684 +*  where gamma_p and gamma_d are scaling factors, and computes the next
 258.685 +*  point:
 258.686 +*
 258.687 +*     x_new = x + alfa_p * dx
 258.688 +*
 258.689 +*     y_new = y + alfa_d * dy
 258.690 +*
 258.691 +*     z_new = z + alfa_d * dz
 258.692 +*
 258.693 +*  which becomes the current point on the next iteration. */
 258.694 +
 258.695 +static int make_step(struct csa *csa)
 258.696 +{     int m = csa->m;
 258.697 +      int n = csa->n;
 258.698 +      double *b = csa->b;
 258.699 +      double *c = csa->c;
 258.700 +      double *x = csa->x;
 258.701 +      double *y = csa->y;
 258.702 +      double *z = csa->z;
 258.703 +      double *dx_aff = csa->dx_aff;
 258.704 +      double *dy_aff = csa->dy_aff;
 258.705 +      double *dz_aff = csa->dz_aff;
 258.706 +      double *dx_cc = csa->dx_cc;
 258.707 +      double *dy_cc = csa->dy_cc;
 258.708 +      double *dz_cc = csa->dz_cc;
 258.709 +      double *dx = csa->dx;
 258.710 +      double *dy = csa->dy;
 258.711 +      double *dz = csa->dz;
 258.712 +      int i, j, ret = 0;
 258.713 +      double temp, gamma_p, gamma_d, *p, *q, *r;
 258.714 +      /* allocate working arrays */
 258.715 +      p = xcalloc(1+m, sizeof(double));
 258.716 +      q = xcalloc(1+n, sizeof(double));
 258.717 +      r = xcalloc(1+n, sizeof(double));
 258.718 +      /* p = b - A*x */
 258.719 +      A_by_vec(csa, x, p);
 258.720 +      for (i = 1; i <= m; i++) p[i] = b[i] - p[i];
 258.721 +      /* q = c - A'*y - z */
 258.722 +      AT_by_vec(csa, y,q);
 258.723 +      for (j = 1; j <= n; j++) q[j] = c[j] - q[j] - z[j];
 258.724 +      /* r = - X * Z * e */
 258.725 +      for (j = 1; j <= n; j++) r[j] = - x[j] * z[j];
 258.726 +      /* solve the first Newtonian system */
 258.727 +      if (solve_NS(csa, p, q, r, dx_aff, dy_aff, dz_aff))
 258.728 +      {  ret = 1;
 258.729 +         goto done;
 258.730 +      }
 258.731 +      /* alfa_aff_p = inf{0 <= alfa <= 1 | x + alfa*dx_aff >= 0} */
 258.732 +      /* alfa_aff_d = inf{0 <= alfa <= 1 | z + alfa*dz_aff >= 0} */
 258.733 +      csa->alfa_aff_p = csa->alfa_aff_d = 1.0;
 258.734 +      for (j = 1; j <= n; j++)
 258.735 +      {  if (dx_aff[j] < 0.0)
 258.736 +         {  temp = - x[j] / dx_aff[j];
 258.737 +            if (csa->alfa_aff_p > temp) csa->alfa_aff_p = temp;
 258.738 +         }
 258.739 +         if (dz_aff[j] < 0.0)
 258.740 +         {  temp = - z[j] / dz_aff[j];
 258.741 +            if (csa->alfa_aff_d > temp) csa->alfa_aff_d = temp;
 258.742 +         }
 258.743 +      }
 258.744 +      /* mu_aff = (x+alfa_aff_p*dx_aff)' * (z+alfa_aff_d*dz_aff) / n */
 258.745 +      temp = 0.0;
 258.746 +      for (j = 1; j <= n; j++)
 258.747 +         temp += (x[j] + csa->alfa_aff_p * dx_aff[j]) *
 258.748 +                 (z[j] + csa->alfa_aff_d * dz_aff[j]);
 258.749 +      csa->mu_aff = temp / (double)n;
 258.750 +      /* sigma = (mu_aff/mu)^3 */
 258.751 +      temp = csa->mu_aff / csa->mu;
 258.752 +      csa->sigma = temp * temp * temp;
 258.753 +      /* p = 0 */
 258.754 +      for (i = 1; i <= m; i++) p[i] = 0.0;
 258.755 +      /* q = 0 */
 258.756 +      for (j = 1; j <= n; j++) q[j] = 0.0;
 258.757 +      /* r = sigma * mu * e - X * Z * e */
 258.758 +      for (j = 1; j <= n; j++)
 258.759 +         r[j] = csa->sigma * csa->mu - dx_aff[j] * dz_aff[j];
 258.760 +      /* solve the second Newtonian system with the same coefficients
 258.761 +         but with altered right-hand sides */
 258.762 +      if (solve_NS(csa, p, q, r, dx_cc, dy_cc, dz_cc))
 258.763 +      {  ret = 1;
 258.764 +         goto done;
 258.765 +      }
 258.766 +      /* (dx,dy,dz) = (dx_aff,dy_aff,dz_aff) + (dx_cc,dy_cc,dz_cc) */
 258.767 +      for (j = 1; j <= n; j++) dx[j] = dx_aff[j] + dx_cc[j];
 258.768 +      for (i = 1; i <= m; i++) dy[i] = dy_aff[i] + dy_cc[i];
 258.769 +      for (j = 1; j <= n; j++) dz[j] = dz_aff[j] + dz_cc[j];
 258.770 +      /* alfa_max_p = inf{0 <= alfa <= 1 | x + alfa*dx >= 0} */
 258.771 +      /* alfa_max_d = inf{0 <= alfa <= 1 | z + alfa*dz >= 0} */
 258.772 +      csa->alfa_max_p = csa->alfa_max_d = 1.0;
 258.773 +      for (j = 1; j <= n; j++)
 258.774 +      {  if (dx[j] < 0.0)
 258.775 +         {  temp = - x[j] / dx[j];
 258.776 +            if (csa->alfa_max_p > temp) csa->alfa_max_p = temp;
 258.777 +         }
 258.778 +         if (dz[j] < 0.0)
 258.779 +         {  temp = - z[j] / dz[j];
 258.780 +            if (csa->alfa_max_d > temp) csa->alfa_max_d = temp;
 258.781 +         }
 258.782 +      }
 258.783 +      /* determine scale factors (not implemented yet) */
 258.784 +      gamma_p = 0.90;
 258.785 +      gamma_d = 0.90;
 258.786 +      /* compute the next point */
 258.787 +      for (j = 1; j <= n; j++)
 258.788 +      {  x[j] += gamma_p * csa->alfa_max_p * dx[j];
 258.789 +         xassert(x[j] > 0.0);
 258.790 +      }
 258.791 +      for (i = 1; i <= m; i++)
 258.792 +         y[i] += gamma_d * csa->alfa_max_d * dy[i];
 258.793 +      for (j = 1; j <= n; j++)
 258.794 +      {  z[j] += gamma_d * csa->alfa_max_d * dz[j];
 258.795 +         xassert(z[j] > 0.0);
 258.796 +      }
 258.797 +done: /* free working arrays */
 258.798 +      xfree(p);
 258.799 +      xfree(q);
 258.800 +      xfree(r);
 258.801 +      return ret;
 258.802 +}
 258.803 +
 258.804 +/***********************************************************************
 258.805 +*  terminate - deallocate common storage area
 258.806 +*
 258.807 +*  This routine frees all memory allocated to the common storage area
 258.808 +*  used by interior-point method routines. */
 258.809 +
 258.810 +static void terminate(struct csa *csa)
 258.811 +{     xfree(csa->D);
 258.812 +      xfree(csa->P);
 258.813 +      xfree(csa->S_ptr);
 258.814 +      xfree(csa->S_ind);
 258.815 +      xfree(csa->S_val);
 258.816 +      xfree(csa->S_diag);
 258.817 +      xfree(csa->U_ptr);
 258.818 +      xfree(csa->U_ind);
 258.819 +      xfree(csa->U_val);
 258.820 +      xfree(csa->U_diag);
 258.821 +      xfree(csa->phi_min);
 258.822 +      xfree(csa->best_x);
 258.823 +      xfree(csa->best_y);
 258.824 +      xfree(csa->best_z);
 258.825 +      xfree(csa->dx_aff);
 258.826 +      xfree(csa->dy_aff);
 258.827 +      xfree(csa->dz_aff);
 258.828 +      xfree(csa->dx_cc);
 258.829 +      xfree(csa->dy_cc);
 258.830 +      xfree(csa->dz_cc);
 258.831 +      return;
 258.832 +}
 258.833 +
 258.834 +/***********************************************************************
 258.835 +*  ipm_main - main interior-point method routine
 258.836 +*
 258.837 +*  This is a main routine of the primal-dual interior-point method.
 258.838 +*
 258.839 +*  The routine ipm_main returns one of the following codes:
 258.840 +*
 258.841 +*  0 - optimal solution found;
 258.842 +*  1 - problem has no feasible (primal or dual) solution;
 258.843 +*  2 - no convergence;
 258.844 +*  3 - iteration limit exceeded;
 258.845 +*  4 - numeric instability on solving Newtonian system.
 258.846 +*
 258.847 +*  In case of non-zero return code the routine returns the best point,
 258.848 +*  which has been reached during optimization. */
 258.849 +
 258.850 +static int ipm_main(struct csa *csa)
 258.851 +{     int m = csa->m;
 258.852 +      int n = csa->n;
 258.853 +      int i, j, status;
 258.854 +      double temp;
 258.855 +      /* choose initial point using Mehrotra's heuristic */
 258.856 +      if (csa->parm->msg_lev >= GLP_MSG_ALL)
 258.857 +         xprintf("Guessing initial point...\n");
 258.858 +      initial_point(csa);
 258.859 +      /* main loop starts here */
 258.860 +      if (csa->parm->msg_lev >= GLP_MSG_ALL)
 258.861 +         xprintf("Optimization begins...\n");
 258.862 +      for (;;)
 258.863 +      {  /* perform basic computations at the current point */
 258.864 +         basic_info(csa);
 258.865 +         /* save initial value of rmu */
 258.866 +         if (csa->iter == 0) csa->rmu0 = csa->rmu;
 258.867 +         /* accumulate values of min(phi[k]) and save the best point */
 258.868 +         xassert(csa->iter <= ITER_MAX);
 258.869 +         if (csa->iter == 0 || csa->phi_min[csa->iter-1] > csa->phi)
 258.870 +         {  csa->phi_min[csa->iter] = csa->phi;
 258.871 +            csa->best_iter = csa->iter;
 258.872 +            for (j = 1; j <= n; j++) csa->best_x[j] = csa->x[j];
 258.873 +            for (i = 1; i <= m; i++) csa->best_y[i] = csa->y[i];
 258.874 +            for (j = 1; j <= n; j++) csa->best_z[j] = csa->z[j];
 258.875 +            csa->best_obj = csa->obj;
 258.876 +         }
 258.877 +         else
 258.878 +            csa->phi_min[csa->iter] = csa->phi_min[csa->iter-1];
 258.879 +         /* display information at the current point */
 258.880 +         if (csa->parm->msg_lev >= GLP_MSG_ON)
 258.881 +            xprintf("%3d: obj = %17.9e; rpi = %8.1e; rdi = %8.1e; gap ="
 258.882 +               " %8.1e\n", csa->iter, csa->obj, csa->rpi, csa->rdi,
 258.883 +               csa->gap);
 258.884 +         /* check if the current point is optimal */
 258.885 +         if (csa->rpi < 1e-8 && csa->rdi < 1e-8 && csa->gap < 1e-8)
 258.886 +         {  if (csa->parm->msg_lev >= GLP_MSG_ALL)
 258.887 +               xprintf("OPTIMAL SOLUTION FOUND\n");
 258.888 +            status = 0;
 258.889 +            break;
 258.890 +         }
 258.891 +         /* check if the problem has no feasible solution */
 258.892 +         temp = 1e5 * csa->phi_min[csa->iter];
 258.893 +         if (temp < 1e-8) temp = 1e-8;
 258.894 +         if (csa->phi >= temp)
 258.895 +         {  if (csa->parm->msg_lev >= GLP_MSG_ALL)
 258.896 +               xprintf("PROBLEM HAS NO FEASIBLE PRIMAL/DUAL SOLUTION\n")
 258.897 +                  ;
 258.898 +            status = 1;
 258.899 +            break;
 258.900 +         }
 258.901 +         /* check for very slow convergence or divergence */
 258.902 +         if (((csa->rpi >= 1e-8 || csa->rdi >= 1e-8) && csa->rmu /
 258.903 +               csa->rmu0 >= 1e6) ||
 258.904 +               (csa->iter >= 30 && csa->phi_min[csa->iter] >= 0.5 *
 258.905 +               csa->phi_min[csa->iter - 30]))
 258.906 +         {  if (csa->parm->msg_lev >= GLP_MSG_ALL)
 258.907 +               xprintf("NO CONVERGENCE; SEARCH TERMINATED\n");
 258.908 +            status = 2;
 258.909 +            break;
 258.910 +         }
 258.911 +         /* check for maximal number of iterations */
 258.912 +         if (csa->iter == ITER_MAX)
 258.913 +         {  if (csa->parm->msg_lev >= GLP_MSG_ALL)
 258.914 +               xprintf("ITERATION LIMIT EXCEEDED; SEARCH TERMINATED\n");
 258.915 +            status = 3;
 258.916 +            break;
 258.917 +         }
 258.918 +         /* start the next iteration */
 258.919 +         csa->iter++;
 258.920 +         /* factorize normal equation system */
 258.921 +         for (j = 1; j <= n; j++) csa->D[j] = csa->x[j] / csa->z[j];
 258.922 +         decomp_NE(csa);
 258.923 +         /* compute the next point using Mehrotra's predictor-corrector
 258.924 +            technique */
 258.925 +         if (make_step(csa))
 258.926 +         {  if (csa->parm->msg_lev >= GLP_MSG_ALL)
 258.927 +               xprintf("NUMERIC INSTABILITY; SEARCH TERMINATED\n");
 258.928 +            status = 4;
 258.929 +            break;
 258.930 +         }
 258.931 +      }
 258.932 +      /* restore the best point */
 258.933 +      if (status != 0)
 258.934 +      {  for (j = 1; j <= n; j++) csa->x[j] = csa->best_x[j];
 258.935 +         for (i = 1; i <= m; i++) csa->y[i] = csa->best_y[i];
 258.936 +         for (j = 1; j <= n; j++) csa->z[j] = csa->best_z[j];
 258.937 +         if (csa->parm->msg_lev >= GLP_MSG_ALL)
 258.938 +            xprintf("Best point %17.9e was reached on iteration %d\n",
 258.939 +               csa->best_obj, csa->best_iter);
 258.940 +      }
 258.941 +      /* return to the calling program */
 258.942 +      return status;
 258.943 +}
 258.944 +
 258.945 +/***********************************************************************
 258.946 +*  NAME
 258.947 +*
 258.948 +*  ipm_solve - core LP solver based on the interior-point method
 258.949 +*
 258.950 +*  SYNOPSIS
 258.951 +*
 258.952 +*  #include "glpipm.h"
 258.953 +*  int ipm_solve(glp_prob *P, const glp_iptcp *parm);
 258.954 +*
 258.955 +*  DESCRIPTION
 258.956 +*
 258.957 +*  The routine ipm_solve is a core LP solver based on the primal-dual
 258.958 +*  interior-point method.
 258.959 +*
 258.960 +*  The routine assumes the following standard formulation of LP problem
 258.961 +*  to be solved:
 258.962 +*
 258.963 +*     minimize
 258.964 +*
 258.965 +*        F = c[0] + c[1]*x[1] + c[2]*x[2] + ... + c[n]*x[n]
 258.966 +*
 258.967 +*     subject to linear constraints
 258.968 +*
 258.969 +*        a[1,1]*x[1] + a[1,2]*x[2] + ... + a[1,n]*x[n] = b[1]
 258.970 +*
 258.971 +*        a[2,1]*x[1] + a[2,2]*x[2] + ... + a[2,n]*x[n] = b[2]
 258.972 +*
 258.973 +*              . . . . . .
 258.974 +*
 258.975 +*        a[m,1]*x[1] + a[m,2]*x[2] + ... + a[m,n]*x[n] = b[m]
 258.976 +*
 258.977 +*     and non-negative variables
 258.978 +*
 258.979 +*        x[1] >= 0, x[2] >= 0, ..., x[n] >= 0
 258.980 +*
 258.981 +*  where:
 258.982 +*  F                    is the objective function;
 258.983 +*  x[1], ..., x[n]      are (structural) variables;
 258.984 +*  c[0]                 is a constant term of the objective function;
 258.985 +*  c[1], ..., c[n]      are objective coefficients;
 258.986 +*  a[1,1], ..., a[m,n]  are constraint coefficients;
 258.987 +*  b[1], ..., b[n]      are right-hand sides.
 258.988 +*
 258.989 +*  The solution is three vectors x, y, and z, which are stored by the
 258.990 +*  routine in the arrays x, y, and z, respectively. These vectors
 258.991 +*  correspond to the best primal-dual point found during optimization.
 258.992 +*  They are approximate solution of the following system (which is the
 258.993 +*  Karush-Kuhn-Tucker optimality conditions):
 258.994 +*
 258.995 +*     A*x      = b      (primal feasibility condition)
 258.996 +*
 258.997 +*     A'*y + z = c      (dual feasibility condition)
 258.998 +*
 258.999 +*     x'*z     = 0      (primal-dual complementarity condition)
258.1000 +*
258.1001 +*     x >= 0, z >= 0    (non-negativity condition)
258.1002 +*
258.1003 +*  where:
258.1004 +*  x[1], ..., x[n]      are primal (structural) variables;
258.1005 +*  y[1], ..., y[m]      are dual variables (Lagrange multipliers) for
258.1006 +*                       equality constraints;
258.1007 +*  z[1], ..., z[n]      are dual variables (Lagrange multipliers) for
258.1008 +*                       non-negativity constraints.
258.1009 +*
258.1010 +*  RETURNS
258.1011 +*
258.1012 +*  0  LP has been successfully solved.
258.1013 +*
258.1014 +*  GLP_ENOCVG
258.1015 +*     No convergence.
258.1016 +*
258.1017 +*  GLP_EITLIM
258.1018 +*     Iteration limit exceeded.
258.1019 +*
258.1020 +*  GLP_EINSTAB
258.1021 +*     Numeric instability on solving Newtonian system.
258.1022 +*
258.1023 +*  In case of non-zero return code the routine returns the best point,
258.1024 +*  which has been reached during optimization. */
258.1025 +
258.1026 +int ipm_solve(glp_prob *P, const glp_iptcp *parm)
258.1027 +{     struct csa _dsa, *csa = &_dsa;
258.1028 +      int m = P->m;
258.1029 +      int n = P->n;
258.1030 +      int nnz = P->nnz;
258.1031 +      GLPROW *row;
258.1032 +      GLPCOL *col;
258.1033 +      GLPAIJ *aij;
258.1034 +      int i, j, loc, ret, *A_ind, *A_ptr;
258.1035 +      double dir, *A_val, *b, *c, *x, *y, *z;
258.1036 +      xassert(m > 0);
258.1037 +      xassert(n > 0);
258.1038 +      /* allocate working arrays */
258.1039 +      A_ptr = xcalloc(1+m+1, sizeof(int));
258.1040 +      A_ind = xcalloc(1+nnz, sizeof(int));
258.1041 +      A_val = xcalloc(1+nnz, sizeof(double));
258.1042 +      b = xcalloc(1+m, sizeof(double));
258.1043 +      c = xcalloc(1+n, sizeof(double));
258.1044 +      x = xcalloc(1+n, sizeof(double));
258.1045 +      y = xcalloc(1+m, sizeof(double));
258.1046 +      z = xcalloc(1+n, sizeof(double));
258.1047 +      /* prepare rows and constraint coefficients */
258.1048 +      loc = 1;
258.1049 +      for (i = 1; i <= m; i++)
258.1050 +      {  row = P->row[i];
258.1051 +         xassert(row->type == GLP_FX);
258.1052 +         b[i] = row->lb * row->rii;
258.1053 +         A_ptr[i] = loc;
258.1054 +         for (aij = row->ptr; aij != NULL; aij = aij->r_next)
258.1055 +         {  A_ind[loc] = aij->col->j;
258.1056 +            A_val[loc] = row->rii * aij->val * aij->col->sjj;
258.1057 +            loc++;
258.1058 +         }
258.1059 +      }
258.1060 +      A_ptr[m+1] = loc;
258.1061 +      xassert(loc-1 == nnz);
258.1062 +      /* prepare columns and objective coefficients */
258.1063 +      if (P->dir == GLP_MIN)
258.1064 +         dir = +1.0;
258.1065 +      else if (P->dir == GLP_MAX)
258.1066 +         dir = -1.0;
258.1067 +      else
258.1068 +         xassert(P != P);
258.1069 +      c[0] = dir * P->c0;
258.1070 +      for (j = 1; j <= n; j++)
258.1071 +      {  col = P->col[j];
258.1072 +         xassert(col->type == GLP_LO && col->lb == 0.0);
258.1073 +         c[j] = dir * col->coef * col->sjj;
258.1074 +      }
258.1075 +      /* allocate and initialize the common storage area */
258.1076 +      csa->m = m;
258.1077 +      csa->n = n;
258.1078 +      csa->A_ptr = A_ptr;
258.1079 +      csa->A_ind = A_ind;
258.1080 +      csa->A_val = A_val;
258.1081 +      csa->b = b;
258.1082 +      csa->c = c;
258.1083 +      csa->x = x;
258.1084 +      csa->y = y;
258.1085 +      csa->z = z;
258.1086 +      csa->parm = parm;
258.1087 +      initialize(csa);
258.1088 +      /* solve LP with the interior-point method */
258.1089 +      ret = ipm_main(csa);
258.1090 +      /* deallocate the common storage area */
258.1091 +      terminate(csa);
258.1092 +      /* determine solution status */
258.1093 +      if (ret == 0)
258.1094 +      {  /* optimal solution found */
258.1095 +         P->ipt_stat = GLP_OPT;
258.1096 +         ret = 0;
258.1097 +      }
258.1098 +      else if (ret == 1)
258.1099 +      {  /* problem has no feasible (primal or dual) solution */
258.1100 +         P->ipt_stat = GLP_NOFEAS;
258.1101 +         ret = 0;
258.1102 +      }
258.1103 +      else if (ret == 2)
258.1104 +      {  /* no convergence */
258.1105 +         P->ipt_stat = GLP_INFEAS;
258.1106 +         ret = GLP_ENOCVG;
258.1107 +      }
258.1108 +      else if (ret == 3)
258.1109 +      {  /* iteration limit exceeded */
258.1110 +         P->ipt_stat = GLP_INFEAS;
258.1111 +         ret = GLP_EITLIM;
258.1112 +      }
258.1113 +      else if (ret == 4)
258.1114 +      {  /* numeric instability on solving Newtonian system */
258.1115 +         P->ipt_stat = GLP_INFEAS;
258.1116 +         ret = GLP_EINSTAB;
258.1117 +      }
258.1118 +      else
258.1119 +         xassert(ret != ret);
258.1120 +      /* store row solution components */
258.1121 +      for (i = 1; i <= m; i++)
258.1122 +      {  row = P->row[i];
258.1123 +         row->pval = row->lb;
258.1124 +         row->dval = dir * y[i] * row->rii;
258.1125 +      }
258.1126 +      /* store column solution components */
258.1127 +      P->ipt_obj = P->c0;
258.1128 +      for (j = 1; j <= n; j++)
258.1129 +      {  col = P->col[j];
258.1130 +         col->pval = x[j] * col->sjj;
258.1131 +         col->dval = dir * z[j] / col->sjj;
258.1132 +         P->ipt_obj += col->coef * col->pval;
258.1133 +      }
258.1134 +      /* free working arrays */
258.1135 +      xfree(A_ptr);
258.1136 +      xfree(A_ind);
258.1137 +      xfree(A_val);
258.1138 +      xfree(b);
258.1139 +      xfree(c);
258.1140 +      xfree(x);
258.1141 +      xfree(y);
258.1142 +      xfree(z);
258.1143 +      return ret;
258.1144 +}
258.1145 +
258.1146 +/* eof */
   259.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
   259.2 +++ b/deps/glpk/src/glpipm.h	Sun Nov 06 20:59:10 2011 +0100
   259.3 @@ -0,0 +1,36 @@
   259.4 +/* glpipm.h (primal-dual interior-point method) */
   259.5 +
   259.6 +/***********************************************************************
   259.7 +*  This code is part of GLPK (GNU Linear Programming Kit).
   259.8 +*
   259.9 +*  Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008,
  259.10 +*  2009, 2010, 2011 Andrew Makhorin, Department for Applied Informatics,
  259.11 +*  Moscow Aviation Institute, Moscow, Russia. All rights reserved.
  259.12 +*  E-mail: <mao@gnu.org>.
  259.13 +*
  259.14 +*  GLPK is free software: you can redistribute it and/or modify it
  259.15 +*  under the terms of the GNU General Public License as published by
  259.16 +*  the Free Software Foundation, either version 3 of the License, or
  259.17 +*  (at your option) any later version.
  259.18 +*
  259.19 +*  GLPK is distributed in the hope that it will be useful, but WITHOUT
  259.20 +*  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
  259.21 +*  or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
  259.22 +*  License for more details.
  259.23 +*
  259.24 +*  You should have received a copy of the GNU General Public License
  259.25 +*  along with GLPK. If not, see <http://www.gnu.org/licenses/>.
  259.26 +***********************************************************************/
  259.27 +
  259.28 +#ifndef GLPIPM_H
  259.29 +#define GLPIPM_H
  259.30 +
  259.31 +#include "glpapi.h"
  259.32 +
  259.33 +#define ipm_solve _glp_ipm_solve
  259.34 +int ipm_solve(glp_prob *P, const glp_iptcp *parm);
  259.35 +/* core LP solver based on the interior-point method */
  259.36 +
  259.37 +#endif
  259.38 +
  259.39 +/* eof */
   260.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
   260.2 +++ b/deps/glpk/src/glpk.h	Sun Nov 06 20:59:10 2011 +0100
   260.3 @@ -0,0 +1,1767 @@
   260.4 +/* glpk.h */
   260.5 +
   260.6 +/***********************************************************************
   260.7 +*  This code is part of GLPK (GNU Linear Programming Kit).
   260.8 +*
   260.9 +*  Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008,
  260.10 +*  2009, 2010, 2011 Andrew Makhorin, Department for Applied Informatics,
  260.11 +*  Moscow Aviation Institute, Moscow, Russia. All rights reserved.
  260.12 +*  E-mail: <mao@gnu.org>.
  260.13 +*
  260.14 +*  GLPK is free software: you can redistribute it and/or modify it
  260.15 +*  under the terms of the GNU General Public License as published by
  260.16 +*  the Free Software Foundation, either version 3 of the License, or
  260.17 +*  (at your option) any later version.
  260.18 +*
  260.19 +*  GLPK is distributed in the hope that it will be useful, but WITHOUT
  260.20 +*  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
  260.21 +*  or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
  260.22 +*  License for more details.
  260.23 +*
  260.24 +*  You should have received a copy of the GNU General Public License
  260.25 +*  along with GLPK. If not, see <http://www.gnu.org/licenses/>.
  260.26 +***********************************************************************/
  260.27 +
  260.28 +#ifndef GLPK_H
  260.29 +#define GLPK_H
  260.30 +
  260.31 +#include <stdarg.h>
  260.32 +#include <stddef.h>
  260.33 +
  260.34 +#ifdef __cplusplus
  260.35 +extern "C" {
  260.36 +#endif
  260.37 +
  260.38 +/* library version numbers: */
  260.39 +#define GLP_MAJOR_VERSION  4
  260.40 +#define GLP_MINOR_VERSION  47
  260.41 +
  260.42 +#ifndef GLP_PROB_DEFINED
  260.43 +#define GLP_PROB_DEFINED
  260.44 +typedef struct { double _opaque_prob[100]; } glp_prob;
  260.45 +/* LP/MIP problem object */
  260.46 +#endif
  260.47 +
  260.48 +/* optimization direction flag: */
  260.49 +#define GLP_MIN            1  /* minimization */
  260.50 +#define GLP_MAX            2  /* maximization */
  260.51 +
  260.52 +/* kind of structural variable: */
  260.53 +#define GLP_CV             1  /* continuous variable */
  260.54 +#define GLP_IV             2  /* integer variable */
  260.55 +#define GLP_BV             3  /* binary variable */
  260.56 +
  260.57 +/* type of auxiliary/structural variable: */
  260.58 +#define GLP_FR             1  /* free variable */
  260.59 +#define GLP_LO             2  /* variable with lower bound */
  260.60 +#define GLP_UP             3  /* variable with upper bound */
  260.61 +#define GLP_DB             4  /* double-bounded variable */
  260.62 +#define GLP_FX             5  /* fixed variable */
  260.63 +
  260.64 +/* status of auxiliary/structural variable: */
  260.65 +#define GLP_BS             1  /* basic variable */
  260.66 +#define GLP_NL             2  /* non-basic variable on lower bound */
  260.67 +#define GLP_NU             3  /* non-basic variable on upper bound */
  260.68 +#define GLP_NF             4  /* non-basic free variable */
  260.69 +#define GLP_NS             5  /* non-basic fixed variable */
  260.70 +
  260.71 +/* scaling options: */
  260.72 +#define GLP_SF_GM       0x01  /* perform geometric mean scaling */
  260.73 +#define GLP_SF_EQ       0x10  /* perform equilibration scaling */
  260.74 +#define GLP_SF_2N       0x20  /* round scale factors to power of two */
  260.75 +#define GLP_SF_SKIP     0x40  /* skip if problem is well scaled */
  260.76 +#define GLP_SF_AUTO     0x80  /* choose scaling options automatically */
  260.77 +
  260.78 +/* solution indicator: */
  260.79 +#define GLP_SOL            1  /* basic solution */
  260.80 +#define GLP_IPT            2  /* interior-point solution */
  260.81 +#define GLP_MIP            3  /* mixed integer solution */
  260.82 +
  260.83 +/* solution status: */
  260.84 +#define GLP_UNDEF          1  /* solution is undefined */
  260.85 +#define GLP_FEAS           2  /* solution is feasible */
  260.86 +#define GLP_INFEAS         3  /* solution is infeasible */
  260.87 +#define GLP_NOFEAS         4  /* no feasible solution exists */
  260.88 +#define GLP_OPT            5  /* solution is optimal */
  260.89 +#define GLP_UNBND          6  /* solution is unbounded */
  260.90 +
  260.91 +typedef struct
  260.92 +{     /* basis factorization control parameters */
  260.93 +      int msg_lev;            /* (reserved) */
  260.94 +      int type;               /* factorization type: */
  260.95 +#define GLP_BF_FT          1  /* LUF + Forrest-Tomlin */
  260.96 +#define GLP_BF_BG          2  /* LUF + Schur compl. + Bartels-Golub */
  260.97 +#define GLP_BF_GR          3  /* LUF + Schur compl. + Givens rotation */
  260.98 +      int lu_size;            /* luf.sv_size */
  260.99 +      double piv_tol;         /* luf.piv_tol */
 260.100 +      int piv_lim;            /* luf.piv_lim */
 260.101 +      int suhl;               /* luf.suhl */
 260.102 +      double eps_tol;         /* luf.eps_tol */
 260.103 +      double max_gro;         /* luf.max_gro */
 260.104 +      int nfs_max;            /* fhv.hh_max */
 260.105 +      double upd_tol;         /* fhv.upd_tol */
 260.106 +      int nrs_max;            /* lpf.n_max */
 260.107 +      int rs_size;            /* lpf.v_size */
 260.108 +      double foo_bar[38];     /* (reserved) */
 260.109 +} glp_bfcp;
 260.110 +
 260.111 +typedef struct
 260.112 +{     /* simplex method control parameters */
 260.113 +      int msg_lev;            /* message level: */
 260.114 +#define GLP_MSG_OFF        0  /* no output */
 260.115 +#define GLP_MSG_ERR        1  /* warning and error messages only */
 260.116 +#define GLP_MSG_ON         2  /* normal output */
 260.117 +#define GLP_MSG_ALL        3  /* full output */
 260.118 +#define GLP_MSG_DBG        4  /* debug output */
 260.119 +      int meth;               /* simplex method option: */
 260.120 +#define GLP_PRIMAL         1  /* use primal simplex */
 260.121 +#define GLP_DUALP          2  /* use dual; if it fails, use primal */
 260.122 +#define GLP_DUAL           3  /* use dual simplex */
 260.123 +      int pricing;            /* pricing technique: */
 260.124 +#define GLP_PT_STD      0x11  /* standard (Dantzig rule) */
 260.125 +#define GLP_PT_PSE      0x22  /* projected steepest edge */
 260.126 +      int r_test;             /* ratio test technique: */
 260.127 +#define GLP_RT_STD      0x11  /* standard (textbook) */
 260.128 +#define GLP_RT_HAR      0x22  /* two-pass Harris' ratio test */
 260.129 +      double tol_bnd;         /* spx.tol_bnd */
 260.130 +      double tol_dj;          /* spx.tol_dj */
 260.131 +      double tol_piv;         /* spx.tol_piv */
 260.132 +      double obj_ll;          /* spx.obj_ll */
 260.133 +      double obj_ul;          /* spx.obj_ul */
 260.134 +      int it_lim;             /* spx.it_lim */
 260.135 +      int tm_lim;             /* spx.tm_lim (milliseconds) */
 260.136 +      int out_frq;            /* spx.out_frq */
 260.137 +      int out_dly;            /* spx.out_dly (milliseconds) */
 260.138 +      int presolve;           /* enable/disable using LP presolver */
 260.139 +      double foo_bar[36];     /* (reserved) */
 260.140 +} glp_smcp;
 260.141 +
 260.142 +typedef struct
 260.143 +{     /* interior-point solver control parameters */
 260.144 +      int msg_lev;            /* message level (see glp_smcp) */
 260.145 +      int ord_alg;            /* ordering algorithm: */
 260.146 +#define GLP_ORD_NONE       0  /* natural (original) ordering */
 260.147 +#define GLP_ORD_QMD        1  /* quotient minimum degree (QMD) */
 260.148 +#define GLP_ORD_AMD        2  /* approx. minimum degree (AMD) */
 260.149 +#define GLP_ORD_SYMAMD     3  /* approx. minimum degree (SYMAMD) */
 260.150 +      double foo_bar[48];     /* (reserved) */
 260.151 +} glp_iptcp;
 260.152 +
 260.153 +#ifndef GLP_TREE_DEFINED
 260.154 +#define GLP_TREE_DEFINED
 260.155 +typedef struct { double _opaque_tree[100]; } glp_tree;
 260.156 +/* branch-and-bound tree */
 260.157 +#endif
 260.158 +
 260.159 +typedef struct
 260.160 +{     /* integer optimizer control parameters */
 260.161 +      int msg_lev;            /* message level (see glp_smcp) */
 260.162 +      int br_tech;            /* branching technique: */
 260.163 +#define GLP_BR_FFV         1  /* first fractional variable */
 260.164 +#define GLP_BR_LFV         2  /* last fractional variable */
 260.165 +#define GLP_BR_MFV         3  /* most fractional variable */
 260.166 +#define GLP_BR_DTH         4  /* heuristic by Driebeck and Tomlin */
 260.167 +#define GLP_BR_PCH         5  /* hybrid pseudocost heuristic */
 260.168 +      int bt_tech;            /* backtracking technique: */
 260.169 +#define GLP_BT_DFS         1  /* depth first search */
 260.170 +#define GLP_BT_BFS         2  /* breadth first search */
 260.171 +#define GLP_BT_BLB         3  /* best local bound */
 260.172 +#define GLP_BT_BPH         4  /* best projection heuristic */
 260.173 +      double tol_int;         /* mip.tol_int */
 260.174 +      double tol_obj;         /* mip.tol_obj */
 260.175 +      int tm_lim;             /* mip.tm_lim (milliseconds) */
 260.176 +      int out_frq;            /* mip.out_frq (milliseconds) */
 260.177 +      int out_dly;            /* mip.out_dly (milliseconds) */
 260.178 +      void (*cb_func)(glp_tree *T, void *info);
 260.179 +                              /* mip.cb_func */
 260.180 +      void *cb_info;          /* mip.cb_info */
 260.181 +      int cb_size;            /* mip.cb_size */
 260.182 +      int pp_tech;            /* preprocessing technique: */
 260.183 +#define GLP_PP_NONE        0  /* disable preprocessing */
 260.184 +#define GLP_PP_ROOT        1  /* preprocessing only on root level */
 260.185 +#define GLP_PP_ALL         2  /* preprocessing on all levels */
 260.186 +      double mip_gap;         /* relative MIP gap tolerance */
 260.187 +      int mir_cuts;           /* MIR cuts       (GLP_ON/GLP_OFF) */
 260.188 +      int gmi_cuts;           /* Gomory's cuts  (GLP_ON/GLP_OFF) */
 260.189 +      int cov_cuts;           /* cover cuts     (GLP_ON/GLP_OFF) */
 260.190 +      int clq_cuts;           /* clique cuts    (GLP_ON/GLP_OFF) */
 260.191 +      int presolve;           /* enable/disable using MIP presolver */
 260.192 +      int binarize;           /* try to binarize integer variables */
 260.193 +      int fp_heur;            /* feasibility pump heuristic */
 260.194 +#if 1 /* 28/V-2010 */
 260.195 +      int alien;              /* use alien solver */
 260.196 +#endif
 260.197 +      double foo_bar[29];     /* (reserved) */
 260.198 +} glp_iocp;
 260.199 +
 260.200 +typedef struct
 260.201 +{     /* additional row attributes */
 260.202 +      int level;
 260.203 +      /* subproblem level at which the row was added */
 260.204 +      int origin;
 260.205 +      /* row origin flag: */
 260.206 +#define GLP_RF_REG         0  /* regular constraint */
 260.207 +#define GLP_RF_LAZY        1  /* "lazy" constraint */
 260.208 +#define GLP_RF_CUT         2  /* cutting plane constraint */
 260.209 +      int klass;
 260.210 +      /* row class descriptor: */
 260.211 +#define GLP_RF_GMI         1  /* Gomory's mixed integer cut */
 260.212 +#define GLP_RF_MIR         2  /* mixed integer rounding cut */
 260.213 +#define GLP_RF_COV         3  /* mixed cover cut */
 260.214 +#define GLP_RF_CLQ         4  /* clique cut */
 260.215 +      double foo_bar[7];
 260.216 +      /* (reserved) */
 260.217 +} glp_attr;
 260.218 +
 260.219 +/* enable/disable flag: */
 260.220 +#define GLP_ON             1  /* enable something */
 260.221 +#define GLP_OFF            0  /* disable something */
 260.222 +
 260.223 +/* reason codes: */
 260.224 +#define GLP_IROWGEN     0x01  /* request for row generation */
 260.225 +#define GLP_IBINGO      0x02  /* better integer solution found */
 260.226 +#define GLP_IHEUR       0x03  /* request for heuristic solution */
 260.227 +#define GLP_ICUTGEN     0x04  /* request for cut generation */
 260.228 +#define GLP_IBRANCH     0x05  /* request for branching */
 260.229 +#define GLP_ISELECT     0x06  /* request for subproblem selection */
 260.230 +#define GLP_IPREPRO     0x07  /* request for preprocessing */
 260.231 +
 260.232 +/* branch selection indicator: */
 260.233 +#define GLP_NO_BRNCH       0  /* select no branch */
 260.234 +#define GLP_DN_BRNCH       1  /* select down-branch */
 260.235 +#define GLP_UP_BRNCH       2  /* select up-branch */
 260.236 +
 260.237 +/* return codes: */
 260.238 +#define GLP_EBADB       0x01  /* invalid basis */
 260.239 +#define GLP_ESING       0x02  /* singular matrix */
 260.240 +#define GLP_ECOND       0x03  /* ill-conditioned matrix */
 260.241 +#define GLP_EBOUND      0x04  /* invalid bounds */
 260.242 +#define GLP_EFAIL       0x05  /* solver failed */
 260.243 +#define GLP_EOBJLL      0x06  /* objective lower limit reached */
 260.244 +#define GLP_EOBJUL      0x07  /* objective upper limit reached */
 260.245 +#define GLP_EITLIM      0x08  /* iteration limit exceeded */
 260.246 +#define GLP_ETMLIM      0x09  /* time limit exceeded */
 260.247 +#define GLP_ENOPFS      0x0A  /* no primal feasible solution */
 260.248 +#define GLP_ENODFS      0x0B  /* no dual feasible solution */
 260.249 +#define GLP_EROOT       0x0C  /* root LP optimum not provided */
 260.250 +#define GLP_ESTOP       0x0D  /* search terminated by application */
 260.251 +#define GLP_EMIPGAP     0x0E  /* relative mip gap tolerance reached */
 260.252 +#define GLP_ENOFEAS     0x0F  /* no primal/dual feasible solution */
 260.253 +#define GLP_ENOCVG      0x10  /* no convergence */
 260.254 +#define GLP_EINSTAB     0x11  /* numerical instability */
 260.255 +#define GLP_EDATA       0x12  /* invalid data */
 260.256 +#define GLP_ERANGE      0x13  /* result out of range */
 260.257 +
 260.258 +/* condition indicator: */
 260.259 +#define GLP_KKT_PE         1  /* primal equalities */
 260.260 +#define GLP_KKT_PB         2  /* primal bounds */
 260.261 +#define GLP_KKT_DE         3  /* dual equalities */
 260.262 +#define GLP_KKT_DB         4  /* dual bounds */
 260.263 +#define GLP_KKT_CS         5  /* complementary slackness */
 260.264 +
 260.265 +/* MPS file format: */
 260.266 +#define GLP_MPS_DECK       1  /* fixed (ancient) */
 260.267 +#define GLP_MPS_FILE       2  /* free (modern) */
 260.268 +
 260.269 +typedef struct
 260.270 +{     /* MPS format control parameters */
 260.271 +      int blank;
 260.272 +      /* character code to replace blanks in symbolic names */
 260.273 +      char *obj_name;
 260.274 +      /* objective row name */
 260.275 +      double tol_mps;
 260.276 +      /* zero tolerance for MPS data */
 260.277 +      double foo_bar[17];
 260.278 +      /* (reserved for use in the future) */
 260.279 +} glp_mpscp;
 260.280 +
 260.281 +typedef struct
 260.282 +{     /* CPLEX LP format control parameters */
 260.283 +      double foo_bar[20];
 260.284 +      /* (reserved for use in the future) */
 260.285 +} glp_cpxcp;
 260.286 +
 260.287 +#ifndef GLP_TRAN_DEFINED
 260.288 +#define GLP_TRAN_DEFINED
 260.289 +typedef struct { double _opaque_tran[100]; } glp_tran;
 260.290 +/* MathProg translator workspace */
 260.291 +#endif
 260.292 +
 260.293 +glp_prob *glp_create_prob(void);
 260.294 +/* create problem object */
 260.295 +
 260.296 +void glp_set_prob_name(glp_prob *P, const char *name);
 260.297 +/* assign (change) problem name */
 260.298 +
 260.299 +void glp_set_obj_name(glp_prob *P, const char *name);
 260.300 +/* assign (change) objective function name */
 260.301 +
 260.302 +void glp_set_obj_dir(glp_prob *P, int dir);
 260.303 +/* set (change) optimization direction flag */
 260.304 +
 260.305 +int glp_add_rows(glp_prob *P, int nrs);
 260.306 +/* add new rows to problem object */
 260.307 +
 260.308 +int glp_add_cols(glp_prob *P, int ncs);
 260.309 +/* add new columns to problem object */
 260.310 +
 260.311 +void glp_set_row_name(glp_prob *P, int i, const char *name);
 260.312 +/* assign (change) row name */
 260.313 +
 260.314 +void glp_set_col_name(glp_prob *P, int j, const char *name);
 260.315 +/* assign (change) column name */
 260.316 +
 260.317 +void glp_set_row_bnds(glp_prob *P, int i, int type, double lb,
 260.318 +      double ub);
 260.319 +/* set (change) row bounds */
 260.320 +
 260.321 +void glp_set_col_bnds(glp_prob *P, int j, int type, double lb,
 260.322 +      double ub);
 260.323 +/* set (change) column bounds */
 260.324 +
 260.325 +void glp_set_obj_coef(glp_prob *P, int j, double coef);
 260.326 +/* set (change) obj. coefficient or constant term */
 260.327 +
 260.328 +void glp_set_mat_row(glp_prob *P, int i, int len, const int ind[],
 260.329 +      const double val[]);
 260.330 +/* set (replace) row of the constraint matrix */
 260.331 +
 260.332 +void glp_set_mat_col(glp_prob *P, int j, int len, const int ind[],
 260.333 +      const double val[]);
 260.334 +/* set (replace) column of the constraint matrix */
 260.335 +
 260.336 +void glp_load_matrix(glp_prob *P, int ne, const int ia[],
 260.337 +      const int ja[], const double ar[]);
 260.338 +/* load (replace) the whole constraint matrix */
 260.339 +
 260.340 +int glp_check_dup(int m, int n, int ne, const int ia[], const int ja[]);
 260.341 +/* check for duplicate elements in sparse matrix */
 260.342 +
 260.343 +void glp_sort_matrix(glp_prob *P);
 260.344 +/* sort elements of the constraint matrix */
 260.345 +
 260.346 +void glp_del_rows(glp_prob *P, int nrs, const int num[]);
 260.347 +/* delete specified rows from problem object */
 260.348 +
 260.349 +void glp_del_cols(glp_prob *P, int ncs, const int num[]);
 260.350 +/* delete specified columns from problem object */
 260.351 +
 260.352 +void glp_copy_prob(glp_prob *dest, glp_prob *prob, int names);
 260.353 +/* copy problem object content */
 260.354 +
 260.355 +void glp_erase_prob(glp_prob *P);
 260.356 +/* erase problem object content */
 260.357 +
 260.358 +void glp_delete_prob(glp_prob *P);
 260.359 +/* delete problem object */
 260.360 +
 260.361 +const char *glp_get_prob_name(glp_prob *P);
 260.362 +/* retrieve problem name */
 260.363 +
 260.364 +const char *glp_get_obj_name(glp_prob *P);
 260.365 +/* retrieve objective function name */
 260.366 +
 260.367 +int glp_get_obj_dir(glp_prob *P);
 260.368 +/* retrieve optimization direction flag */
 260.369 +
 260.370 +int glp_get_num_rows(glp_prob *P);
 260.371 +/* retrieve number of rows */
 260.372 +
 260.373 +int glp_get_num_cols(glp_prob *P);
 260.374 +/* retrieve number of columns */
 260.375 +
 260.376 +const char *glp_get_row_name(glp_prob *P, int i);
 260.377 +/* retrieve row name */
 260.378 +
 260.379 +const char *glp_get_col_name(glp_prob *P, int j);
 260.380 +/* retrieve column name */
 260.381 +
 260.382 +int glp_get_row_type(glp_prob *P, int i);
 260.383 +/* retrieve row type */
 260.384 +
 260.385 +double glp_get_row_lb(glp_prob *P, int i);
 260.386 +/* retrieve row lower bound */
 260.387 +
 260.388 +double glp_get_row_ub(glp_prob *P, int i);
 260.389 +/* retrieve row upper bound */
 260.390 +
 260.391 +int glp_get_col_type(glp_prob *P, int j);
 260.392 +/* retrieve column type */
 260.393 +
 260.394 +double glp_get_col_lb(glp_prob *P, int j);
 260.395 +/* retrieve column lower bound */
 260.396 +
 260.397 +double glp_get_col_ub(glp_prob *P, int j);
 260.398 +/* retrieve column upper bound */
 260.399 +
 260.400 +double glp_get_obj_coef(glp_prob *P, int j);
 260.401 +/* retrieve obj. coefficient or constant term */
 260.402 +
 260.403 +int glp_get_num_nz(glp_prob *P);
 260.404 +/* retrieve number of constraint coefficients */
 260.405 +
 260.406 +int glp_get_mat_row(glp_prob *P, int i, int ind[], double val[]);
 260.407 +/* retrieve row of the constraint matrix */
 260.408 +
 260.409 +int glp_get_mat_col(glp_prob *P, int j, int ind[], double val[]);
 260.410 +/* retrieve column of the constraint matrix */
 260.411 +
 260.412 +void glp_create_index(glp_prob *P);
 260.413 +/* create the name index */
 260.414 +
 260.415 +int glp_find_row(glp_prob *P, const char *name);
 260.416 +/* find row by its name */
 260.417 +
 260.418 +int glp_find_col(glp_prob *P, const char *name);
 260.419 +/* find column by its name */
 260.420 +
 260.421 +void glp_delete_index(glp_prob *P);
 260.422 +/* delete the name index */
 260.423 +
 260.424 +void glp_set_rii(glp_prob *P, int i, double rii);
 260.425 +/* set (change) row scale factor */
 260.426 +
 260.427 +void glp_set_sjj(glp_prob *P, int j, double sjj);
 260.428 +/* set (change) column scale factor */
 260.429 +
 260.430 +double glp_get_rii(glp_prob *P, int i);
 260.431 +/* retrieve row scale factor */
 260.432 +
 260.433 +double glp_get_sjj(glp_prob *P, int j);
 260.434 +/* retrieve column scale factor */
 260.435 +
 260.436 +void glp_scale_prob(glp_prob *P, int flags);
 260.437 +/* scale problem data */
 260.438 +
 260.439 +void glp_unscale_prob(glp_prob *P);
 260.440 +/* unscale problem data */
 260.441 +
 260.442 +void glp_set_row_stat(glp_prob *P, int i, int stat);
 260.443 +/* set (change) row status */
 260.444 +
 260.445 +void glp_set_col_stat(glp_prob *P, int j, int stat);
 260.446 +/* set (change) column status */
 260.447 +
 260.448 +void glp_std_basis(glp_prob *P);
 260.449 +/* construct standard initial LP basis */
 260.450 +
 260.451 +void glp_adv_basis(glp_prob *P, int flags);
 260.452 +/* construct advanced initial LP basis */
 260.453 +
 260.454 +void glp_cpx_basis(glp_prob *P);
 260.455 +/* construct Bixby's initial LP basis */
 260.456 +
 260.457 +int glp_simplex(glp_prob *P, const glp_smcp *parm);
 260.458 +/* solve LP problem with the simplex method */
 260.459 +
 260.460 +int glp_exact(glp_prob *P, const glp_smcp *parm);
 260.461 +/* solve LP problem in exact arithmetic */
 260.462 +
 260.463 +void glp_init_smcp(glp_smcp *parm);
 260.464 +/* initialize simplex method control parameters */
 260.465 +
 260.466 +int glp_get_status(glp_prob *P);
 260.467 +/* retrieve generic status of basic solution */
 260.468 +
 260.469 +int glp_get_prim_stat(glp_prob *P);
 260.470 +/* retrieve status of primal basic solution */
 260.471 +
 260.472 +int glp_get_dual_stat(glp_prob *P);
 260.473 +/* retrieve status of dual basic solution */
 260.474 +
 260.475 +double glp_get_obj_val(glp_prob *P);
 260.476 +/* retrieve objective value (basic solution) */
 260.477 +
 260.478 +int glp_get_row_stat(glp_prob *P, int i);
 260.479 +/* retrieve row status */
 260.480 +
 260.481 +double glp_get_row_prim(glp_prob *P, int i);
 260.482 +/* retrieve row primal value (basic solution) */
 260.483 +
 260.484 +double glp_get_row_dual(glp_prob *P, int i);
 260.485 +/* retrieve row dual value (basic solution) */
 260.486 +
 260.487 +int glp_get_col_stat(glp_prob *P, int j);
 260.488 +/* retrieve column status */
 260.489 +
 260.490 +double glp_get_col_prim(glp_prob *P, int j);
 260.491 +/* retrieve column primal value (basic solution) */
 260.492 +
 260.493 +double glp_get_col_dual(glp_prob *P, int j);
 260.494 +/* retrieve column dual value (basic solution) */
 260.495 +
 260.496 +int glp_get_unbnd_ray(glp_prob *P);
 260.497 +/* determine variable causing unboundedness */
 260.498 +
 260.499 +int glp_interior(glp_prob *P, const glp_iptcp *parm);
 260.500 +/* solve LP problem with the interior-point method */
 260.501 +
 260.502 +void glp_init_iptcp(glp_iptcp *parm);
 260.503 +/* initialize interior-point solver control parameters */
 260.504 +
 260.505 +int glp_ipt_status(glp_prob *P);
 260.506 +/* retrieve status of interior-point solution */
 260.507 +
 260.508 +double glp_ipt_obj_val(glp_prob *P);
 260.509 +/* retrieve objective value (interior point) */
 260.510 +
 260.511 +double glp_ipt_row_prim(glp_prob *P, int i);
 260.512 +/* retrieve row primal value (interior point) */
 260.513 +
 260.514 +double glp_ipt_row_dual(glp_prob *P, int i);
 260.515 +/* retrieve row dual value (interior point) */
 260.516 +
 260.517 +double glp_ipt_col_prim(glp_prob *P, int j);
 260.518 +/* retrieve column primal value (interior point) */
 260.519 +
 260.520 +double glp_ipt_col_dual(glp_prob *P, int j);
 260.521 +/* retrieve column dual value (interior point) */
 260.522 +
 260.523 +void glp_set_col_kind(glp_prob *P, int j, int kind);
 260.524 +/* set (change) column kind */
 260.525 +
 260.526 +int glp_get_col_kind(glp_prob *P, int j);
 260.527 +/* retrieve column kind */
 260.528 +
 260.529 +int glp_get_num_int(glp_prob *P);
 260.530 +/* retrieve number of integer columns */
 260.531 +
 260.532 +int glp_get_num_bin(glp_prob *P);
 260.533 +/* retrieve number of binary columns */
 260.534 +
 260.535 +int glp_intopt(glp_prob *P, const glp_iocp *parm);
 260.536 +/* solve MIP problem with the branch-and-bound method */
 260.537 +
 260.538 +void glp_init_iocp(glp_iocp *parm);
 260.539 +/* initialize integer optimizer control parameters */
 260.540 +
 260.541 +int glp_mip_status(glp_prob *P);
 260.542 +/* retrieve status of MIP solution */
 260.543 +
 260.544 +double glp_mip_obj_val(glp_prob *P);
 260.545 +/* retrieve objective value (MIP solution) */
 260.546 +
 260.547 +double glp_mip_row_val(glp_prob *P, int i);
 260.548 +/* retrieve row value (MIP solution) */
 260.549 +
 260.550 +double glp_mip_col_val(glp_prob *P, int j);
 260.551 +/* retrieve column value (MIP solution) */
 260.552 +
 260.553 +int glp_print_sol(glp_prob *P, const char *fname);
 260.554 +/* write basic solution in printable format */
 260.555 +
 260.556 +int glp_read_sol(glp_prob *P, const char *fname);
 260.557 +/* read basic solution from text file */
 260.558 +
 260.559 +int glp_write_sol(glp_prob *P, const char *fname);
 260.560 +/* write basic solution to text file */
 260.561 +
 260.562 +int glp_print_ranges(glp_prob *P, int len, const int list[],
 260.563 +      int flags, const char *fname);
 260.564 +/* print sensitivity analysis report */
 260.565 +
 260.566 +int glp_print_ipt(glp_prob *P, const char *fname);
 260.567 +/* write interior-point solution in printable format */
 260.568 +
 260.569 +int glp_read_ipt(glp_prob *P, const char *fname);
 260.570 +/* read interior-point solution from text file */
 260.571 +
 260.572 +int glp_write_ipt(glp_prob *P, const char *fname);
 260.573 +/* write interior-point solution to text file */
 260.574 +
 260.575 +int glp_print_mip(glp_prob *P, const char *fname);
 260.576 +/* write MIP solution in printable format */
 260.577 +
 260.578 +int glp_read_mip(glp_prob *P, const char *fname);
 260.579 +/* read MIP solution from text file */
 260.580 +
 260.581 +int glp_write_mip(glp_prob *P, const char *fname);
 260.582 +/* write MIP solution to text file */
 260.583 +
 260.584 +int glp_bf_exists(glp_prob *P);
 260.585 +/* check if the basis factorization exists */
 260.586 +
 260.587 +int glp_factorize(glp_prob *P);
 260.588 +/* compute the basis factorization */
 260.589 +
 260.590 +int glp_bf_updated(glp_prob *P);
 260.591 +/* check if the basis factorization has been updated */
 260.592 +
 260.593 +void glp_get_bfcp(glp_prob *P, glp_bfcp *parm);
 260.594 +/* retrieve basis factorization control parameters */
 260.595 +
 260.596 +void glp_set_bfcp(glp_prob *P, const glp_bfcp *parm);
 260.597 +/* change basis factorization control parameters */
 260.598 +
 260.599 +int glp_get_bhead(glp_prob *P, int k);
 260.600 +/* retrieve the basis header information */
 260.601 +
 260.602 +int glp_get_row_bind(glp_prob *P, int i);
 260.603 +/* retrieve row index in the basis header */
 260.604 +
 260.605 +int glp_get_col_bind(glp_prob *P, int j);
 260.606 +/* retrieve column index in the basis header */
 260.607 +
 260.608 +void glp_ftran(glp_prob *P, double x[]);
 260.609 +/* perform forward transformation (solve system B*x = b) */
 260.610 +
 260.611 +void glp_btran(glp_prob *P, double x[]);
 260.612 +/* perform backward transformation (solve system B'*x = b) */
 260.613 +
 260.614 +int glp_warm_up(glp_prob *P);
 260.615 +/* "warm up" LP basis */
 260.616 +
 260.617 +int glp_eval_tab_row(glp_prob *P, int k, int ind[], double val[]);
 260.618 +/* compute row of the simplex tableau */
 260.619 +
 260.620 +int glp_eval_tab_col(glp_prob *P, int k, int ind[], double val[]);
 260.621 +/* compute column of the simplex tableau */
 260.622 +
 260.623 +int glp_transform_row(glp_prob *P, int len, int ind[], double val[]);
 260.624 +/* transform explicitly specified row */
 260.625 +
 260.626 +int glp_transform_col(glp_prob *P, int len, int ind[], double val[]);
 260.627 +/* transform explicitly specified column */
 260.628 +
 260.629 +int glp_prim_rtest(glp_prob *P, int len, const int ind[],
 260.630 +      const double val[], int dir, double eps);
 260.631 +/* perform primal ratio test */
 260.632 +
 260.633 +int glp_dual_rtest(glp_prob *P, int len, const int ind[],
 260.634 +      const double val[], int dir, double eps);
 260.635 +/* perform dual ratio test */
 260.636 +
 260.637 +void glp_analyze_bound(glp_prob *P, int k, double *value1, int *var1,
 260.638 +      double *value2, int *var2);
 260.639 +/* analyze active bound of non-basic variable */
 260.640 +
 260.641 +void glp_analyze_coef(glp_prob *P, int k, double *coef1, int *var1,
 260.642 +      double *value1, double *coef2, int *var2, double *value2);
 260.643 +/* analyze objective coefficient at basic variable */
 260.644 +
 260.645 +int glp_ios_reason(glp_tree *T);
 260.646 +/* determine reason for calling the callback routine */
 260.647 +
 260.648 +glp_prob *glp_ios_get_prob(glp_tree *T);
 260.649 +/* access the problem object */
 260.650 +
 260.651 +void glp_ios_tree_size(glp_tree *T, int *a_cnt, int *n_cnt,
 260.652 +      int *t_cnt);
 260.653 +/* determine size of the branch-and-bound tree */
 260.654 +
 260.655 +int glp_ios_curr_node(glp_tree *T);
 260.656 +/* determine current active subproblem */
 260.657 +
 260.658 +int glp_ios_next_node(glp_tree *T, int p);
 260.659 +/* determine next active subproblem */
 260.660 +
 260.661 +int glp_ios_prev_node(glp_tree *T, int p);
 260.662 +/* determine previous active subproblem */
 260.663 +
 260.664 +int glp_ios_up_node(glp_tree *T, int p);
 260.665 +/* determine parent subproblem */
 260.666 +
 260.667 +int glp_ios_node_level(glp_tree *T, int p);
 260.668 +/* determine subproblem level */
 260.669 +
 260.670 +double glp_ios_node_bound(glp_tree *T, int p);
 260.671 +/* determine subproblem local bound */
 260.672 +
 260.673 +int glp_ios_best_node(glp_tree *T);
 260.674 +/* find active subproblem with best local bound */
 260.675 +
 260.676 +double glp_ios_mip_gap(glp_tree *T);
 260.677 +/* compute relative MIP gap */
 260.678 +
 260.679 +void *glp_ios_node_data(glp_tree *T, int p);
 260.680 +/* access subproblem application-specific data */
 260.681 +
 260.682 +void glp_ios_row_attr(glp_tree *T, int i, glp_attr *attr);
 260.683 +/* retrieve additional row attributes */
 260.684 +
 260.685 +int glp_ios_pool_size(glp_tree *T);
 260.686 +/* determine current size of the cut pool */
 260.687 +
 260.688 +int glp_ios_add_row(glp_tree *T,
 260.689 +      const char *name, int klass, int flags, int len, const int ind[],
 260.690 +      const double val[], int type, double rhs);
 260.691 +/* add row (constraint) to the cut pool */
 260.692 +
 260.693 +void glp_ios_del_row(glp_tree *T, int i);
 260.694 +/* remove row (constraint) from the cut pool */
 260.695 +
 260.696 +void glp_ios_clear_pool(glp_tree *T);
 260.697 +/* remove all rows (constraints) from the cut pool */
 260.698 +
 260.699 +int glp_ios_can_branch(glp_tree *T, int j);
 260.700 +/* check if can branch upon specified variable */
 260.701 +
 260.702 +void glp_ios_branch_upon(glp_tree *T, int j, int sel);
 260.703 +/* choose variable to branch upon */
 260.704 +
 260.705 +void glp_ios_select_node(glp_tree *T, int p);
 260.706 +/* select subproblem to continue the search */
 260.707 +
 260.708 +int glp_ios_heur_sol(glp_tree *T, const double x[]);
 260.709 +/* provide solution found by heuristic */
 260.710 +
 260.711 +void glp_ios_terminate(glp_tree *T);
 260.712 +/* terminate the solution process */
 260.713 +
 260.714 +void glp_init_mpscp(glp_mpscp *parm);
 260.715 +/* initialize MPS format control parameters */
 260.716 +
 260.717 +int glp_read_mps(glp_prob *P, int fmt, const glp_mpscp *parm,
 260.718 +      const char *fname);
 260.719 +/* read problem data in MPS format */
 260.720 +
 260.721 +int glp_write_mps(glp_prob *P, int fmt, const glp_mpscp *parm,
 260.722 +      const char *fname);
 260.723 +/* write problem data in MPS format */
 260.724 +
 260.725 +void glp_init_cpxcp(glp_cpxcp *parm);
 260.726 +/* initialize CPLEX LP format control parameters */
 260.727 +
 260.728 +int glp_read_lp(glp_prob *P, const glp_cpxcp *parm, const char *fname);
 260.729 +/* read problem data in CPLEX LP format */
 260.730 +
 260.731 +int glp_write_lp(glp_prob *P, const glp_cpxcp *parm, const char *fname);
 260.732 +/* write problem data in CPLEX LP format */
 260.733 +
 260.734 +int glp_read_prob(glp_prob *P, int flags, const char *fname);
 260.735 +/* read problem data in GLPK format */
 260.736 +
 260.737 +int glp_write_prob(glp_prob *P, int flags, const char *fname);
 260.738 +/* write problem data in GLPK format */
 260.739 +
 260.740 +glp_tran *glp_mpl_alloc_wksp(void);
 260.741 +/* allocate the MathProg translator workspace */
 260.742 +
 260.743 +int glp_mpl_read_model(glp_tran *tran, const char *fname, int skip);
 260.744 +/* read and translate model section */
 260.745 +
 260.746 +int glp_mpl_read_data(glp_tran *tran, const char *fname);
 260.747 +/* read and translate data section */
 260.748 +
 260.749 +int glp_mpl_generate(glp_tran *tran, const char *fname);
 260.750 +/* generate the model */
 260.751 +
 260.752 +void glp_mpl_build_prob(glp_tran *tran, glp_prob *prob);
 260.753 +/* build LP/MIP problem instance from the model */
 260.754 +
 260.755 +int glp_mpl_postsolve(glp_tran *tran, glp_prob *prob, int sol);
 260.756 +/* postsolve the model */
 260.757 +
 260.758 +void glp_mpl_free_wksp(glp_tran *tran);
 260.759 +/* free the MathProg translator workspace */
 260.760 +
 260.761 +int glp_main(int argc, const char *argv[]);
 260.762 +/* stand-alone LP/MIP solver */
 260.763 +
 260.764 +/**********************************************************************/
 260.765 +
 260.766 +int glp_read_cnfsat(glp_prob *P, const char *fname);
 260.767 +/* read CNF-SAT problem data in DIMACS format */
 260.768 +
 260.769 +int glp_check_cnfsat(glp_prob *P);
 260.770 +/* check for CNF-SAT problem instance */
 260.771 +
 260.772 +int glp_write_cnfsat(glp_prob *P, const char *fname);
 260.773 +/* write CNF-SAT problem data in DIMACS format */
 260.774 +
 260.775 +int glp_minisat1(glp_prob *P);
 260.776 +/* solve CNF-SAT problem with MiniSat solver */
 260.777 +
 260.778 +int glp_intfeas1(glp_prob *P, int use_bound, int obj_bound);
 260.779 +/* solve integer feasibility problem */
 260.780 +
 260.781 +/**********************************************************************/
 260.782 +
 260.783 +#ifndef GLP_LONG_DEFINED
 260.784 +#define GLP_LONG_DEFINED
 260.785 +typedef struct { int lo, hi; } glp_long;
 260.786 +/* long integer data type */
 260.787 +#endif
 260.788 +
 260.789 +int glp_init_env(void);
 260.790 +/* initialize GLPK environment */
 260.791 +
 260.792 +const char *glp_version(void);
 260.793 +/* determine library version */
 260.794 +
 260.795 +int glp_free_env(void);
 260.796 +/* free GLPK environment */
 260.797 +
 260.798 +void glp_printf(const char *fmt, ...);
 260.799 +/* write formatted output to terminal */
 260.800 +
 260.801 +void glp_vprintf(const char *fmt, va_list arg);
 260.802 +/* write formatted output to terminal */
 260.803 +
 260.804 +int glp_term_out(int flag);
 260.805 +/* enable/disable terminal output */
 260.806 +
 260.807 +void glp_term_hook(int (*func)(void *info, const char *s), void *info);
 260.808 +/* install hook to intercept terminal output */
 260.809 +
 260.810 +int glp_open_tee(const char *fname);
 260.811 +/* start copying terminal output to text file */
 260.812 +
 260.813 +int glp_close_tee(void);
 260.814 +/* stop copying terminal output to text file */
 260.815 +
 260.816 +#ifndef GLP_ERROR_DEFINED
 260.817 +#define GLP_ERROR_DEFINED
 260.818 +typedef void (*_glp_error)(const char *fmt, ...);
 260.819 +#endif
 260.820 +
 260.821 +#define glp_error glp_error_(__FILE__, __LINE__)
 260.822 +_glp_error glp_error_(const char *file, int line);
 260.823 +/* display error message and terminate execution */
 260.824 +
 260.825 +#define glp_assert(expr) \
 260.826 +      ((void)((expr) || (glp_assert_(#expr, __FILE__, __LINE__), 1)))
 260.827 +void glp_assert_(const char *expr, const char *file, int line);
 260.828 +/* check for logical condition */
 260.829 +
 260.830 +void glp_error_hook(void (*func)(void *info), void *info);
 260.831 +/* install hook to intercept abnormal termination */
 260.832 +
 260.833 +void *glp_malloc(int size);
 260.834 +/* allocate memory block */
 260.835 +
 260.836 +void *glp_calloc(int n, int size);
 260.837 +/* allocate memory block */
 260.838 +
 260.839 +void glp_free(void *ptr);
 260.840 +/* free memory block */
 260.841 +
 260.842 +void glp_mem_limit(int limit);
 260.843 +/* set memory usage limit */
 260.844 +
 260.845 +void glp_mem_usage(int *count, int *cpeak, glp_long *total,
 260.846 +      glp_long *tpeak);
 260.847 +/* get memory usage information */
 260.848 +
 260.849 +glp_long glp_time(void);
 260.850 +/* determine current universal time */
 260.851 +
 260.852 +double glp_difftime(glp_long t1, glp_long t0);
 260.853 +/* compute difference between two time values */
 260.854 +
 260.855 +/**********************************************************************/
 260.856 +
 260.857 +#ifndef GLP_DATA_DEFINED
 260.858 +#define GLP_DATA_DEFINED
 260.859 +typedef struct { double _opaque_data[100]; } glp_data;
 260.860 +/* plain data file */
 260.861 +#endif
 260.862 +
 260.863 +glp_data *glp_sdf_open_file(const char *fname);
 260.864 +/* open plain data file */
 260.865 +
 260.866 +void glp_sdf_set_jump(glp_data *data, void *jump);
 260.867 +/* set up error handling */
 260.868 +
 260.869 +void glp_sdf_error(glp_data *data, const char *fmt, ...);
 260.870 +/* print error message */
 260.871 +
 260.872 +void glp_sdf_warning(glp_data *data, const char *fmt, ...);
 260.873 +/* print warning message */
 260.874 +
 260.875 +int glp_sdf_read_int(glp_data *data);
 260.876 +/* read integer number */
 260.877 +
 260.878 +double glp_sdf_read_num(glp_data *data);
 260.879 +/* read floating-point number */
 260.880 +
 260.881 +const char *glp_sdf_read_item(glp_data *data);
 260.882 +/* read data item */
 260.883 +
 260.884 +const char *glp_sdf_read_text(glp_data *data);
 260.885 +/* read text until end of line */
 260.886 +
 260.887 +int glp_sdf_line(glp_data *data);
 260.888 +/* determine current line number */
 260.889 +
 260.890 +void glp_sdf_close_file(glp_data *data);
 260.891 +/* close plain data file */
 260.892 +
 260.893 +/**********************************************************************/
 260.894 +
 260.895 +typedef struct _glp_graph glp_graph;
 260.896 +typedef struct _glp_vertex glp_vertex;
 260.897 +typedef struct _glp_arc glp_arc;
 260.898 +
 260.899 +struct _glp_graph
 260.900 +{     /* graph descriptor */
 260.901 +      void *pool; /* DMP *pool; */
 260.902 +      /* memory pool to store graph components */
 260.903 +      char *name;
 260.904 +      /* graph name (1 to 255 chars); NULL means no name is assigned
 260.905 +         to the graph */
 260.906 +      int nv_max;
 260.907 +      /* length of the vertex list (enlarged automatically) */
 260.908 +      int nv;
 260.909 +      /* number of vertices in the graph, 0 <= nv <= nv_max */
 260.910 +      int na;
 260.911 +      /* number of arcs in the graph, na >= 0 */
 260.912 +      glp_vertex **v; /* glp_vertex *v[1+nv_max]; */
 260.913 +      /* v[i], 1 <= i <= nv, is a pointer to i-th vertex */
 260.914 +      void *index; /* AVL *index; */
 260.915 +      /* vertex index to find vertices by their names; NULL means the
 260.916 +         index does not exist */
 260.917 +      int v_size;
 260.918 +      /* size of data associated with each vertex (0 to 256 bytes) */
 260.919 +      int a_size;
 260.920 +      /* size of data associated with each arc (0 to 256 bytes) */
 260.921 +};
 260.922 +
 260.923 +struct _glp_vertex
 260.924 +{     /* vertex descriptor */
 260.925 +      int i;
 260.926 +      /* vertex ordinal number, 1 <= i <= nv */
 260.927 +      char *name;
 260.928 +      /* vertex name (1 to 255 chars); NULL means no name is assigned
 260.929 +         to the vertex */
 260.930 +      void *entry; /* AVLNODE *entry; */
 260.931 +      /* pointer to corresponding entry in the vertex index; NULL means
 260.932 +         that either the index does not exist or the vertex has no name
 260.933 +         assigned */
 260.934 +      void *data;
 260.935 +      /* pointer to data associated with the vertex */
 260.936 +      void *temp;
 260.937 +      /* working pointer */
 260.938 +      glp_arc *in;
 260.939 +      /* pointer to the (unordered) list of incoming arcs */
 260.940 +      glp_arc *out;
 260.941 +      /* pointer to the (unordered) list of outgoing arcs */
 260.942 +};
 260.943 +
 260.944 +struct _glp_arc
 260.945 +{     /* arc descriptor */
 260.946 +      glp_vertex *tail;
 260.947 +      /* pointer to the tail endpoint */
 260.948 +      glp_vertex *head;
 260.949 +      /* pointer to the head endpoint */
 260.950 +      void *data;
 260.951 +      /* pointer to data associated with the arc */
 260.952 +      void *temp;
 260.953 +      /* working pointer */
 260.954 +      glp_arc *t_prev;
 260.955 +      /* pointer to previous arc having the same tail endpoint */
 260.956 +      glp_arc *t_next;
 260.957 +      /* pointer to next arc having the same tail endpoint */
 260.958 +      glp_arc *h_prev;
 260.959 +      /* pointer to previous arc having the same head endpoint */
 260.960 +      glp_arc *h_next;
 260.961 +      /* pointer to next arc having the same head endpoint */
 260.962 +};
 260.963 +
 260.964 +glp_graph *glp_create_graph(int v_size, int a_size);
 260.965 +/* create graph */
 260.966 +
 260.967 +void glp_set_graph_name(glp_graph *G, const char *name);
 260.968 +/* assign (change) graph name */
 260.969 +
 260.970 +int glp_add_vertices(glp_graph *G, int nadd);
 260.971 +/* add new vertices to graph */
 260.972 +
 260.973 +void glp_set_vertex_name(glp_graph *G, int i, const char *name);
 260.974 +/* assign (change) vertex name */
 260.975 +
 260.976 +glp_arc *glp_add_arc(glp_graph *G, int i, int j);
 260.977 +/* add new arc to graph */
 260.978 +
 260.979 +void glp_del_vertices(glp_graph *G, int ndel, const int num[]);
 260.980 +/* delete vertices from graph */
 260.981 +
 260.982 +void glp_del_arc(glp_graph *G, glp_arc *a);
 260.983 +/* delete arc from graph */
 260.984 +
 260.985 +void glp_erase_graph(glp_graph *G, int v_size, int a_size);
 260.986 +/* erase graph content */
 260.987 +
 260.988 +void glp_delete_graph(glp_graph *G);
 260.989 +/* delete graph */
 260.990 +
 260.991 +void glp_create_v_index(glp_graph *G);
 260.992 +/* create vertex name index */
 260.993 +
 260.994 +int glp_find_vertex(glp_graph *G, const char *name);
 260.995 +/* find vertex by its name */
 260.996 +
 260.997 +void glp_delete_v_index(glp_graph *G);
 260.998 +/* delete vertex name index */
 260.999 +
260.1000 +int glp_read_graph(glp_graph *G, const char *fname);
260.1001 +/* read graph from plain text file */
260.1002 +
260.1003 +int glp_write_graph(glp_graph *G, const char *fname);
260.1004 +/* write graph to plain text file */
260.1005 +
260.1006 +void glp_mincost_lp(glp_prob *P, glp_graph *G, int names, int v_rhs,
260.1007 +      int a_low, int a_cap, int a_cost);
260.1008 +/* convert minimum cost flow problem to LP */
260.1009 +
260.1010 +int glp_mincost_okalg(glp_graph *G, int v_rhs, int a_low, int a_cap,
260.1011 +      int a_cost, double *sol, int a_x, int v_pi);
260.1012 +/* find minimum-cost flow with out-of-kilter algorithm */
260.1013 +
260.1014 +void glp_maxflow_lp(glp_prob *P, glp_graph *G, int names, int s,
260.1015 +      int t, int a_cap);
260.1016 +/* convert maximum flow problem to LP */
260.1017 +
260.1018 +int glp_maxflow_ffalg(glp_graph *G, int s, int t, int a_cap,
260.1019 +      double *sol, int a_x, int v_cut);
260.1020 +/* find maximal flow with Ford-Fulkerson algorithm */
260.1021 +
260.1022 +int glp_check_asnprob(glp_graph *G, int v_set);
260.1023 +/* check correctness of assignment problem data */
260.1024 +
260.1025 +/* assignment problem formulation: */
260.1026 +#define GLP_ASN_MIN        1  /* perfect matching (minimization) */
260.1027 +#define GLP_ASN_MAX        2  /* perfect matching (maximization) */
260.1028 +#define GLP_ASN_MMP        3  /* maximum matching */
260.1029 +
260.1030 +int glp_asnprob_lp(glp_prob *P, int form, glp_graph *G, int names,
260.1031 +      int v_set, int a_cost);
260.1032 +/* convert assignment problem to LP */
260.1033 +
260.1034 +int glp_asnprob_okalg(int form, glp_graph *G, int v_set, int a_cost,
260.1035 +      double *sol, int a_x);
260.1036 +/* solve assignment problem with out-of-kilter algorithm */
260.1037 +
260.1038 +int glp_asnprob_hall(glp_graph *G, int v_set, int a_x);
260.1039 +/* find bipartite matching of maximum cardinality */
260.1040 +
260.1041 +double glp_cpp(glp_graph *G, int v_t, int v_es, int v_ls);
260.1042 +/* solve critical path problem */
260.1043 +
260.1044 +int glp_read_mincost(glp_graph *G, int v_rhs, int a_low, int a_cap,
260.1045 +      int a_cost, const char *fname);
260.1046 +/* read min-cost flow problem data in DIMACS format */
260.1047 +
260.1048 +int glp_write_mincost(glp_graph *G, int v_rhs, int a_low, int a_cap,
260.1049 +      int a_cost, const char *fname);
260.1050 +/* write min-cost flow problem data in DIMACS format */
260.1051 +
260.1052 +int glp_read_maxflow(glp_graph *G, int *s, int *t, int a_cap,
260.1053 +      const char *fname);
260.1054 +/* read maximum flow problem data in DIMACS format */
260.1055 +
260.1056 +int glp_write_maxflow(glp_graph *G, int s, int t, int a_cap,
260.1057 +      const char *fname);
260.1058 +/* write maximum flow problem data in DIMACS format */
260.1059 +
260.1060 +int glp_read_asnprob(glp_graph *G, int v_set, int a_cost, const char
260.1061 +      *fname);
260.1062 +/* read assignment problem data in DIMACS format */
260.1063 +
260.1064 +int glp_write_asnprob(glp_graph *G, int v_set, int a_cost, const char
260.1065 +      *fname);
260.1066 +/* write assignment problem data in DIMACS format */
260.1067 +
260.1068 +int glp_read_ccdata(glp_graph *G, int v_wgt, const char *fname);
260.1069 +/* read graph in DIMACS clique/coloring format */
260.1070 +
260.1071 +int glp_write_ccdata(glp_graph *G, int v_wgt, const char *fname);
260.1072 +/* write graph in DIMACS clique/coloring format */
260.1073 +
260.1074 +int glp_netgen(glp_graph *G, int v_rhs, int a_cap, int a_cost,
260.1075 +      const int parm[1+15]);
260.1076 +/* Klingman's network problem generator */
260.1077 +
260.1078 +int glp_gridgen(glp_graph *G, int v_rhs, int a_cap, int a_cost,
260.1079 +      const int parm[1+14]);
260.1080 +/* grid-like network problem generator */
260.1081 +
260.1082 +int glp_rmfgen(glp_graph *G, int *s, int *t, int a_cap,
260.1083 +      const int parm[1+5]);
260.1084 +/* Goldfarb's maximum flow problem generator */
260.1085 +
260.1086 +int glp_weak_comp(glp_graph *G, int v_num);
260.1087 +/* find all weakly connected components of graph */
260.1088 +
260.1089 +int glp_strong_comp(glp_graph *G, int v_num);
260.1090 +/* find all strongly connected components of graph */
260.1091 +
260.1092 +int glp_top_sort(glp_graph *G, int v_num);
260.1093 +/* topological sorting of acyclic digraph */
260.1094 +
260.1095 +int glp_wclique_exact(glp_graph *G, int v_wgt, double *sol, int v_set);
260.1096 +/* find maximum weight clique with exact algorithm */
260.1097 +
260.1098 +/***********************************************************************
260.1099 +*  NOTE: All symbols defined below are obsolete and kept here only for
260.1100 +*        backward compatibility.
260.1101 +***********************************************************************/
260.1102 +
260.1103 +#define LPX glp_prob
260.1104 +
260.1105 +/* problem class: */
260.1106 +#define LPX_LP          100   /* linear programming (LP) */
260.1107 +#define LPX_MIP         101   /* mixed integer programming (MIP) */
260.1108 +
260.1109 +/* type of auxiliary/structural variable: */
260.1110 +#define LPX_FR          110   /* free variable */
260.1111 +#define LPX_LO          111   /* variable with lower bound */
260.1112 +#define LPX_UP          112   /* variable with upper bound */
260.1113 +#define LPX_DB          113   /* double-bounded variable */
260.1114 +#define LPX_FX          114   /* fixed variable */
260.1115 +
260.1116 +/* optimization direction flag: */
260.1117 +#define LPX_MIN         120   /* minimization */
260.1118 +#define LPX_MAX         121   /* maximization */
260.1119 +
260.1120 +/* status of primal basic solution: */
260.1121 +#define LPX_P_UNDEF     132   /* primal solution is undefined */
260.1122 +#define LPX_P_FEAS      133   /* solution is primal feasible */
260.1123 +#define LPX_P_INFEAS    134   /* solution is primal infeasible */
260.1124 +#define LPX_P_NOFEAS    135   /* no primal feasible solution exists */
260.1125 +
260.1126 +/* status of dual basic solution: */
260.1127 +#define LPX_D_UNDEF     136   /* dual solution is undefined */
260.1128 +#define LPX_D_FEAS      137   /* solution is dual feasible */
260.1129 +#define LPX_D_INFEAS    138   /* solution is dual infeasible */
260.1130 +#define LPX_D_NOFEAS    139   /* no dual feasible solution exists */
260.1131 +
260.1132 +/* status of auxiliary/structural variable: */
260.1133 +#define LPX_BS          140   /* basic variable */
260.1134 +#define LPX_NL          141   /* non-basic variable on lower bound */
260.1135 +#define LPX_NU          142   /* non-basic variable on upper bound */
260.1136 +#define LPX_NF          143   /* non-basic free variable */
260.1137 +#define LPX_NS          144   /* non-basic fixed variable */
260.1138 +
260.1139 +/* status of interior-point solution: */
260.1140 +#define LPX_T_UNDEF     150   /* interior solution is undefined */
260.1141 +#define LPX_T_OPT       151   /* interior solution is optimal */
260.1142 +
260.1143 +/* kind of structural variable: */
260.1144 +#define LPX_CV          160   /* continuous variable */
260.1145 +#define LPX_IV          161   /* integer variable */
260.1146 +
260.1147 +/* status of integer solution: */
260.1148 +#define LPX_I_UNDEF     170   /* integer solution is undefined */
260.1149 +#define LPX_I_OPT       171   /* integer solution is optimal */
260.1150 +#define LPX_I_FEAS      172   /* integer solution is feasible */
260.1151 +#define LPX_I_NOFEAS    173   /* no integer solution exists */
260.1152 +
260.1153 +/* status codes reported by the routine lpx_get_status: */
260.1154 +#define LPX_OPT         180   /* optimal */
260.1155 +#define LPX_FEAS        181   /* feasible */
260.1156 +#define LPX_INFEAS      182   /* infeasible */
260.1157 +#define LPX_NOFEAS      183   /* no feasible */
260.1158 +#define LPX_UNBND       184   /* unbounded */
260.1159 +#define LPX_UNDEF       185   /* undefined */
260.1160 +
260.1161 +/* exit codes returned by solver routines: */
260.1162 +#define LPX_E_OK        200   /* success */
260.1163 +#define LPX_E_EMPTY     201   /* empty problem */
260.1164 +#define LPX_E_BADB      202   /* invalid initial basis */
260.1165 +#define LPX_E_INFEAS    203   /* infeasible initial solution */
260.1166 +#define LPX_E_FAULT     204   /* unable to start the search */
260.1167 +#define LPX_E_OBJLL     205   /* objective lower limit reached */
260.1168 +#define LPX_E_OBJUL     206   /* objective upper limit reached */
260.1169 +#define LPX_E_ITLIM     207   /* iterations limit exhausted */
260.1170 +#define LPX_E_TMLIM     208   /* time limit exhausted */
260.1171 +#define LPX_E_NOFEAS    209   /* no feasible solution */
260.1172 +#define LPX_E_INSTAB    210   /* numerical instability */
260.1173 +#define LPX_E_SING      211   /* problems with basis matrix */
260.1174 +#define LPX_E_NOCONV    212   /* no convergence (interior) */
260.1175 +#define LPX_E_NOPFS     213   /* no primal feas. sol. (LP presolver) */
260.1176 +#define LPX_E_NODFS     214   /* no dual feas. sol. (LP presolver) */
260.1177 +#define LPX_E_MIPGAP    215   /* relative mip gap tolerance reached */
260.1178 +
260.1179 +/* control parameter identifiers: */
260.1180 +#define LPX_K_MSGLEV    300   /* lp->msg_lev */
260.1181 +#define LPX_K_SCALE     301   /* lp->scale */
260.1182 +#define LPX_K_DUAL      302   /* lp->dual */
260.1183 +#define LPX_K_PRICE     303   /* lp->price */
260.1184 +#define LPX_K_RELAX     304   /* lp->relax */
260.1185 +#define LPX_K_TOLBND    305   /* lp->tol_bnd */
260.1186 +#define LPX_K_TOLDJ     306   /* lp->tol_dj */
260.1187 +#define LPX_K_TOLPIV    307   /* lp->tol_piv */
260.1188 +#define LPX_K_ROUND     308   /* lp->round */
260.1189 +#define LPX_K_OBJLL     309   /* lp->obj_ll */
260.1190 +#define LPX_K_OBJUL     310   /* lp->obj_ul */
260.1191 +#define LPX_K_ITLIM     311   /* lp->it_lim */
260.1192 +#define LPX_K_ITCNT     312   /* lp->it_cnt */
260.1193 +#define LPX_K_TMLIM     313   /* lp->tm_lim */
260.1194 +#define LPX_K_OUTFRQ    314   /* lp->out_frq */
260.1195 +#define LPX_K_OUTDLY    315   /* lp->out_dly */
260.1196 +#define LPX_K_BRANCH    316   /* lp->branch */
260.1197 +#define LPX_K_BTRACK    317   /* lp->btrack */
260.1198 +#define LPX_K_TOLINT    318   /* lp->tol_int */
260.1199 +#define LPX_K_TOLOBJ    319   /* lp->tol_obj */
260.1200 +#define LPX_K_MPSINFO   320   /* lp->mps_info */
260.1201 +#define LPX_K_MPSOBJ    321   /* lp->mps_obj */
260.1202 +#define LPX_K_MPSORIG   322   /* lp->mps_orig */
260.1203 +#define LPX_K_MPSWIDE   323   /* lp->mps_wide */
260.1204 +#define LPX_K_MPSFREE   324   /* lp->mps_free */
260.1205 +#define LPX_K_MPSSKIP   325   /* lp->mps_skip */
260.1206 +#define LPX_K_LPTORIG   326   /* lp->lpt_orig */
260.1207 +#define LPX_K_PRESOL    327   /* lp->presol */
260.1208 +#define LPX_K_BINARIZE  328   /* lp->binarize */
260.1209 +#define LPX_K_USECUTS   329   /* lp->use_cuts */
260.1210 +#define LPX_K_BFTYPE    330   /* lp->bfcp->type */
260.1211 +#define LPX_K_MIPGAP    331   /* lp->mip_gap */
260.1212 +
260.1213 +#define LPX_C_COVER     0x01  /* mixed cover cuts */
260.1214 +#define LPX_C_CLIQUE    0x02  /* clique cuts */
260.1215 +#define LPX_C_GOMORY    0x04  /* Gomory's mixed integer cuts */
260.1216 +#define LPX_C_MIR       0x08  /* mixed integer rounding cuts */
260.1217 +#define LPX_C_ALL       0xFF  /* all cuts */
260.1218 +
260.1219 +typedef struct
260.1220 +{     /* this structure contains results reported by the routines which
260.1221 +         checks Karush-Kuhn-Tucker conditions (for details see comments
260.1222 +         to those routines) */
260.1223 +      /*--------------------------------------------------------------*/
260.1224 +      /* xR - A * xS = 0 (KKT.PE) */
260.1225 +      double pe_ae_max;
260.1226 +      /* largest absolute error */
260.1227 +      int    pe_ae_row;
260.1228 +      /* number of row with largest absolute error */
260.1229 +      double pe_re_max;
260.1230 +      /* largest relative error */
260.1231 +      int    pe_re_row;
260.1232 +      /* number of row with largest relative error */
260.1233 +      int    pe_quality;
260.1234 +      /* quality of primal solution:
260.1235 +         'H' - high
260.1236 +         'M' - medium
260.1237 +         'L' - low
260.1238 +         '?' - primal solution is wrong */
260.1239 +      /*--------------------------------------------------------------*/
260.1240 +      /* l[k] <= x[k] <= u[k] (KKT.PB) */
260.1241 +      double pb_ae_max;
260.1242 +      /* largest absolute error */
260.1243 +      int    pb_ae_ind;
260.1244 +      /* number of variable with largest absolute error */
260.1245 +      double pb_re_max;
260.1246 +      /* largest relative error */
260.1247 +      int    pb_re_ind;
260.1248 +      /* number of variable with largest relative error */
260.1249 +      int    pb_quality;
260.1250 +      /* quality of primal feasibility:
260.1251 +         'H' - high
260.1252 +         'M' - medium
260.1253 +         'L' - low
260.1254 +         '?' - primal solution is infeasible */
260.1255 +      /*--------------------------------------------------------------*/
260.1256 +      /* A' * (dR - cR) + (dS - cS) = 0 (KKT.DE) */
260.1257 +      double de_ae_max;
260.1258 +      /* largest absolute error */
260.1259 +      int    de_ae_col;
260.1260 +      /* number of column with largest absolute error */
260.1261 +      double de_re_max;
260.1262 +      /* largest relative error */
260.1263 +      int    de_re_col;
260.1264 +      /* number of column with largest relative error */
260.1265 +      int    de_quality;
260.1266 +      /* quality of dual solution:
260.1267 +         'H' - high
260.1268 +         'M' - medium
260.1269 +         'L' - low
260.1270 +         '?' - dual solution is wrong */
260.1271 +      /*--------------------------------------------------------------*/
260.1272 +      /* d[k] >= 0 or d[k] <= 0 (KKT.DB) */
260.1273 +      double db_ae_max;
260.1274 +      /* largest absolute error */
260.1275 +      int    db_ae_ind;
260.1276 +      /* number of variable with largest absolute error */
260.1277 +      double db_re_max;
260.1278 +      /* largest relative error */
260.1279 +      int    db_re_ind;
260.1280 +      /* number of variable with largest relative error */
260.1281 +      int    db_quality;
260.1282 +      /* quality of dual feasibility:
260.1283 +         'H' - high
260.1284 +         'M' - medium
260.1285 +         'L' - low
260.1286 +         '?' - dual solution is infeasible */
260.1287 +      /*--------------------------------------------------------------*/
260.1288 +      /* (x[k] - bound of x[k]) * d[k] = 0 (KKT.CS) */
260.1289 +      double cs_ae_max;
260.1290 +      /* largest absolute error */
260.1291 +      int    cs_ae_ind;
260.1292 +      /* number of variable with largest absolute error */
260.1293 +      double cs_re_max;
260.1294 +      /* largest relative error */
260.1295 +      int    cs_re_ind;
260.1296 +      /* number of variable with largest relative error */
260.1297 +      int    cs_quality;
260.1298 +      /* quality of complementary slackness:
260.1299 +         'H' - high
260.1300 +         'M' - medium
260.1301 +         'L' - low
260.1302 +         '?' - primal and dual solutions are not complementary */
260.1303 +} LPXKKT;
260.1304 +
260.1305 +#define lpx_create_prob _glp_lpx_create_prob
260.1306 +LPX *lpx_create_prob(void);
260.1307 +/* create problem object */
260.1308 +
260.1309 +#define lpx_set_prob_name _glp_lpx_set_prob_name
260.1310 +void lpx_set_prob_name(LPX *lp, const char *name);
260.1311 +/* assign (change) problem name */
260.1312 +
260.1313 +#define lpx_set_obj_name _glp_lpx_set_obj_name
260.1314 +void lpx_set_obj_name(LPX *lp, const char *name);
260.1315 +/* assign (change) objective function name */
260.1316 +
260.1317 +#define lpx_set_obj_dir _glp_lpx_set_obj_dir
260.1318 +void lpx_set_obj_dir(LPX *lp, int dir);
260.1319 +/* set (change) optimization direction flag */
260.1320 +
260.1321 +#define lpx_add_rows _glp_lpx_add_rows
260.1322 +int lpx_add_rows(LPX *lp, int nrs);
260.1323 +/* add new rows to problem object */
260.1324 +
260.1325 +#define lpx_add_cols _glp_lpx_add_cols
260.1326 +int lpx_add_cols(LPX *lp, int ncs);
260.1327 +/* add new columns to problem object */
260.1328 +
260.1329 +#define lpx_set_row_name _glp_lpx_set_row_name
260.1330 +void lpx_set_row_name(LPX *lp, int i, const char *name);
260.1331 +/* assign (change) row name */
260.1332 +
260.1333 +#define lpx_set_col_name _glp_lpx_set_col_name
260.1334 +void lpx_set_col_name(LPX *lp, int j, const char *name);
260.1335 +/* assign (change) column name */
260.1336 +
260.1337 +#define lpx_set_row_bnds _glp_lpx_set_row_bnds
260.1338 +void lpx_set_row_bnds(LPX *lp, int i, int type, double lb, double ub);
260.1339 +/* set (change) row bounds */
260.1340 +
260.1341 +#define lpx_set_col_bnds _glp_lpx_set_col_bnds
260.1342 +void lpx_set_col_bnds(LPX *lp, int j, int type, double lb, double ub);
260.1343 +/* set (change) column bounds */
260.1344 +
260.1345 +#define lpx_set_obj_coef _glp_lpx_set_obj_coef
260.1346 +void lpx_set_obj_coef(glp_prob *lp, int j, double coef);
260.1347 +/* set (change) obj. coefficient or constant term */
260.1348 +
260.1349 +#define lpx_set_mat_row _glp_lpx_set_mat_row
260.1350 +void lpx_set_mat_row(LPX *lp, int i, int len, const int ind[],
260.1351 +      const double val[]);
260.1352 +/* set (replace) row of the constraint matrix */
260.1353 +
260.1354 +#define lpx_set_mat_col _glp_lpx_set_mat_col
260.1355 +void lpx_set_mat_col(LPX *lp, int j, int len, const int ind[],
260.1356 +      const double val[]);
260.1357 +/* set (replace) column of the constraint matrix */
260.1358 +
260.1359 +#define lpx_load_matrix _glp_lpx_load_matrix
260.1360 +void lpx_load_matrix(LPX *lp, int ne, const int ia[], const int ja[],
260.1361 +      const double ar[]);
260.1362 +/* load (replace) the whole constraint matrix */
260.1363 +
260.1364 +#define lpx_del_rows _glp_lpx_del_rows
260.1365 +void lpx_del_rows(LPX *lp, int nrs, const int num[]);
260.1366 +/* delete specified rows from problem object */
260.1367 +
260.1368 +#define lpx_del_cols _glp_lpx_del_cols
260.1369 +void lpx_del_cols(LPX *lp, int ncs, const int num[]);
260.1370 +/* delete specified columns from problem object */
260.1371 +
260.1372 +#define lpx_delete_prob _glp_lpx_delete_prob
260.1373 +void lpx_delete_prob(LPX *lp);
260.1374 +/* delete problem object */
260.1375 +
260.1376 +#define lpx_get_prob_name _glp_lpx_get_prob_name
260.1377 +const char *lpx_get_prob_name(LPX *lp);
260.1378 +/* retrieve problem name */
260.1379 +
260.1380 +#define lpx_get_obj_name _glp_lpx_get_obj_name
260.1381 +const char *lpx_get_obj_name(LPX *lp);
260.1382 +/* retrieve objective function name */
260.1383 +
260.1384 +#define lpx_get_obj_dir _glp_lpx_get_obj_dir
260.1385 +int lpx_get_obj_dir(LPX *lp);
260.1386 +/* retrieve optimization direction flag */
260.1387 +
260.1388 +#define lpx_get_num_rows _glp_lpx_get_num_rows
260.1389 +int lpx_get_num_rows(LPX *lp);
260.1390 +/* retrieve number of rows */
260.1391 +
260.1392 +#define lpx_get_num_cols _glp_lpx_get_num_cols
260.1393 +int lpx_get_num_cols(LPX *lp);
260.1394 +/* retrieve number of columns */
260.1395 +
260.1396 +#define lpx_get_row_name _glp_lpx_get_row_name
260.1397 +const char *lpx_get_row_name(LPX *lp, int i);
260.1398 +/* retrieve row name */
260.1399 +
260.1400 +#define lpx_get_col_name _glp_lpx_get_col_name
260.1401 +const char *lpx_get_col_name(LPX *lp, int j);
260.1402 +/* retrieve column name */
260.1403 +
260.1404 +#define lpx_get_row_type _glp_lpx_get_row_type
260.1405 +int lpx_get_row_type(LPX *lp, int i);
260.1406 +/* retrieve row type */
260.1407 +
260.1408 +#define lpx_get_row_lb _glp_lpx_get_row_lb
260.1409 +double lpx_get_row_lb(LPX *lp, int i);
260.1410 +/* retrieve row lower bound */
260.1411 +
260.1412 +#define lpx_get_row_ub _glp_lpx_get_row_ub
260.1413 +double lpx_get_row_ub(LPX *lp, int i);
260.1414 +/* retrieve row upper bound */
260.1415 +
260.1416 +#define lpx_get_row_bnds _glp_lpx_get_row_bnds
260.1417 +void lpx_get_row_bnds(LPX *lp, int i, int *typx, double *lb,
260.1418 +      double *ub);
260.1419 +/* retrieve row bounds */
260.1420 +
260.1421 +#define lpx_get_col_type _glp_lpx_get_col_type
260.1422 +int lpx_get_col_type(LPX *lp, int j);
260.1423 +/* retrieve column type */
260.1424 +
260.1425 +#define lpx_get_col_lb _glp_lpx_get_col_lb
260.1426 +double lpx_get_col_lb(LPX *lp, int j);
260.1427 +/* retrieve column lower bound */
260.1428 +
260.1429 +#define lpx_get_col_ub _glp_lpx_get_col_ub
260.1430 +double lpx_get_col_ub(LPX *lp, int j);
260.1431 +/* retrieve column upper bound */
260.1432 +
260.1433 +#define lpx_get_col_bnds _glp_lpx_get_col_bnds
260.1434 +void lpx_get_col_bnds(LPX *lp, int j, int *typx, double *lb,
260.1435 +      double *ub);
260.1436 +/* retrieve column bounds */
260.1437 +
260.1438 +#define lpx_get_obj_coef _glp_lpx_get_obj_coef
260.1439 +double lpx_get_obj_coef(LPX *lp, int j);
260.1440 +/* retrieve obj. coefficient or constant term */
260.1441 +
260.1442 +#define lpx_get_num_nz _glp_lpx_get_num_nz
260.1443 +int lpx_get_num_nz(LPX *lp);
260.1444 +/* retrieve number of constraint coefficients */
260.1445 +
260.1446 +#define lpx_get_mat_row _glp_lpx_get_mat_row
260.1447 +int lpx_get_mat_row(LPX *lp, int i, int ind[], double val[]);
260.1448 +/* retrieve row of the constraint matrix */
260.1449 +
260.1450 +#define lpx_get_mat_col _glp_lpx_get_mat_col
260.1451 +int lpx_get_mat_col(LPX *lp, int j, int ind[], double val[]);
260.1452 +/* retrieve column of the constraint matrix */
260.1453 +
260.1454 +#define lpx_create_index _glp_lpx_create_index
260.1455 +void lpx_create_index(LPX *lp);
260.1456 +/* create the name index */
260.1457 +
260.1458 +#define lpx_find_row _glp_lpx_find_row
260.1459 +int lpx_find_row(LPX *lp, const char *name);
260.1460 +/* find row by its name */
260.1461 +
260.1462 +#define lpx_find_col _glp_lpx_find_col
260.1463 +int lpx_find_col(LPX *lp, const char *name);
260.1464 +/* find column by its name */
260.1465 +
260.1466 +#define lpx_delete_index _glp_lpx_delete_index
260.1467 +void lpx_delete_index(LPX *lp);
260.1468 +/* delete the name index */
260.1469 +
260.1470 +#define lpx_scale_prob _glp_lpx_scale_prob
260.1471 +void lpx_scale_prob(LPX *lp);
260.1472 +/* scale problem data */
260.1473 +
260.1474 +#define lpx_unscale_prob _glp_lpx_unscale_prob
260.1475 +void lpx_unscale_prob(LPX *lp);
260.1476 +/* unscale problem data */
260.1477 +
260.1478 +#define lpx_set_row_stat _glp_lpx_set_row_stat
260.1479 +void lpx_set_row_stat(LPX *lp, int i, int stat);
260.1480 +/* set (change) row status */
260.1481 +
260.1482 +#define lpx_set_col_stat _glp_lpx_set_col_stat
260.1483 +void lpx_set_col_stat(LPX *lp, int j, int stat);
260.1484 +/* set (change) column status */
260.1485 +
260.1486 +#define lpx_std_basis _glp_lpx_std_basis
260.1487 +void lpx_std_basis(LPX *lp);
260.1488 +/* construct standard initial LP basis */
260.1489 +
260.1490 +#define lpx_adv_basis _glp_lpx_adv_basis
260.1491 +void lpx_adv_basis(LPX *lp);
260.1492 +/* construct advanced initial LP basis */
260.1493 +
260.1494 +#define lpx_cpx_basis _glp_lpx_cpx_basis
260.1495 +void lpx_cpx_basis(LPX *lp);
260.1496 +/* construct Bixby's initial LP basis */
260.1497 +
260.1498 +#define lpx_simplex _glp_lpx_simplex
260.1499 +int lpx_simplex(LPX *lp);
260.1500 +/* easy-to-use driver to the simplex method */
260.1501 +
260.1502 +#define lpx_exact _glp_lpx_exact
260.1503 +int lpx_exact(LPX *lp);
260.1504 +/* easy-to-use driver to the exact simplex method */
260.1505 +
260.1506 +#define lpx_get_status _glp_lpx_get_status
260.1507 +int lpx_get_status(LPX *lp);
260.1508 +/* retrieve generic status of basic solution */
260.1509 +
260.1510 +#define lpx_get_prim_stat _glp_lpx_get_prim_stat
260.1511 +int lpx_get_prim_stat(LPX *lp);
260.1512 +/* retrieve primal status of basic solution */
260.1513 +
260.1514 +#define lpx_get_dual_stat _glp_lpx_get_dual_stat
260.1515 +int lpx_get_dual_stat(LPX *lp);
260.1516 +/* retrieve dual status of basic solution */
260.1517 +
260.1518 +#define lpx_get_obj_val _glp_lpx_get_obj_val
260.1519 +double lpx_get_obj_val(LPX *lp);
260.1520 +/* retrieve objective value (basic solution) */
260.1521 +
260.1522 +#define lpx_get_row_stat _glp_lpx_get_row_stat
260.1523 +int lpx_get_row_stat(LPX *lp, int i);
260.1524 +/* retrieve row status (basic solution) */
260.1525 +
260.1526 +#define lpx_get_row_prim _glp_lpx_get_row_prim
260.1527 +double lpx_get_row_prim(LPX *lp, int i);
260.1528 +/* retrieve row primal value (basic solution) */
260.1529 +
260.1530 +#define lpx_get_row_dual _glp_lpx_get_row_dual
260.1531 +double lpx_get_row_dual(LPX *lp, int i);
260.1532 +/* retrieve row dual value (basic solution) */
260.1533 +
260.1534 +#define lpx_get_row_info _glp_lpx_get_row_info
260.1535 +void lpx_get_row_info(LPX *lp, int i, int *tagx, double *vx,
260.1536 +      double *dx);
260.1537 +/* obtain row solution information */
260.1538 +
260.1539 +#define lpx_get_col_stat _glp_lpx_get_col_stat
260.1540 +int lpx_get_col_stat(LPX *lp, int j);
260.1541 +/* retrieve column status (basic solution) */
260.1542 +
260.1543 +#define lpx_get_col_prim _glp_lpx_get_col_prim
260.1544 +double lpx_get_col_prim(LPX *lp, int j);
260.1545 +/* retrieve column primal value (basic solution) */
260.1546 +
260.1547 +#define lpx_get_col_dual _glp_lpx_get_col_dual
260.1548 +double lpx_get_col_dual(glp_prob *lp, int j);
260.1549 +/* retrieve column dual value (basic solution) */
260.1550 +
260.1551 +#define lpx_get_col_info _glp_lpx_get_col_info
260.1552 +void lpx_get_col_info(LPX *lp, int j, int *tagx, double *vx,
260.1553 +      double *dx);
260.1554 +/* obtain column solution information (obsolete) */
260.1555 +
260.1556 +#define lpx_get_ray_info _glp_lpx_get_ray_info
260.1557 +int lpx_get_ray_info(LPX *lp);
260.1558 +/* determine what causes primal unboundness */
260.1559 +
260.1560 +#define lpx_check_kkt _glp_lpx_check_kkt
260.1561 +void lpx_check_kkt(LPX *lp, int scaled, LPXKKT *kkt);
260.1562 +/* check Karush-Kuhn-Tucker conditions */
260.1563 +
260.1564 +#define lpx_warm_up _glp_lpx_warm_up
260.1565 +int lpx_warm_up(LPX *lp);
260.1566 +/* "warm up" LP basis */
260.1567 +
260.1568 +#define lpx_eval_tab_row _glp_lpx_eval_tab_row
260.1569 +int lpx_eval_tab_row(LPX *lp, int k, int ind[], double val[]);
260.1570 +/* compute row of the simplex table */
260.1571 +
260.1572 +#define lpx_eval_tab_col _glp_lpx_eval_tab_col
260.1573 +int lpx_eval_tab_col(LPX *lp, int k, int ind[], double val[]);
260.1574 +/* compute column of the simplex table */
260.1575 +
260.1576 +#define lpx_transform_row _glp_lpx_transform_row
260.1577 +int lpx_transform_row(LPX *lp, int len, int ind[], double val[]);
260.1578 +/* transform explicitly specified row */
260.1579 +
260.1580 +#define lpx_transform_col _glp_lpx_transform_col
260.1581 +int lpx_transform_col(LPX *lp, int len, int ind[], double val[]);
260.1582 +/* transform explicitly specified column */
260.1583 +
260.1584 +#define lpx_prim_ratio_test _glp_lpx_prim_ratio_test
260.1585 +int lpx_prim_ratio_test(LPX *lp, int len, const int ind[],
260.1586 +      const double val[], int how, double tol);
260.1587 +/* perform primal ratio test */
260.1588 +
260.1589 +#define lpx_dual_ratio_test _glp_lpx_dual_ratio_test
260.1590 +int lpx_dual_ratio_test(LPX *lp, int len, const int ind[],
260.1591 +      const double val[], int how, double tol);
260.1592 +/* perform dual ratio test */
260.1593 +
260.1594 +#define lpx_interior _glp_lpx_interior
260.1595 +int lpx_interior(LPX *lp);
260.1596 +/* easy-to-use driver to the interior point method */
260.1597 +
260.1598 +#define lpx_ipt_status _glp_lpx_ipt_status
260.1599 +int lpx_ipt_status(LPX *lp);
260.1600 +/* retrieve status of interior-point solution */
260.1601 +
260.1602 +#define lpx_ipt_obj_val _glp_lpx_ipt_obj_val
260.1603 +double lpx_ipt_obj_val(LPX *lp);
260.1604 +/* retrieve objective value (interior point) */
260.1605 +
260.1606 +#define lpx_ipt_row_prim _glp_lpx_ipt_row_prim
260.1607 +double lpx_ipt_row_prim(LPX *lp, int i);
260.1608 +/* retrieve row primal value (interior point) */
260.1609 +
260.1610 +#define lpx_ipt_row_dual _glp_lpx_ipt_row_dual
260.1611 +double lpx_ipt_row_dual(LPX *lp, int i);
260.1612 +/* retrieve row dual value (interior point) */
260.1613 +
260.1614 +#define lpx_ipt_col_prim _glp_lpx_ipt_col_prim
260.1615 +double lpx_ipt_col_prim(LPX *lp, int j);
260.1616 +/* retrieve column primal value (interior point) */
260.1617 +
260.1618 +#define lpx_ipt_col_dual _glp_lpx_ipt_col_dual
260.1619 +double lpx_ipt_col_dual(LPX *lp, int j);
260.1620 +/* retrieve column dual value (interior point) */
260.1621 +
260.1622 +#define lpx_set_class _glp_lpx_set_class
260.1623 +void lpx_set_class(LPX *lp, int klass);
260.1624 +/* set problem class */
260.1625 +
260.1626 +#define lpx_get_class _glp_lpx_get_class
260.1627 +int lpx_get_class(LPX *lp);
260.1628 +/* determine problem klass */
260.1629 +
260.1630 +#define lpx_set_col_kind _glp_lpx_set_col_kind
260.1631 +void lpx_set_col_kind(LPX *lp, int j, int kind);
260.1632 +/* set (change) column kind */
260.1633 +
260.1634 +#define lpx_get_col_kind _glp_lpx_get_col_kind
260.1635 +int lpx_get_col_kind(LPX *lp, int j);
260.1636 +/* retrieve column kind */
260.1637 +
260.1638 +#define lpx_get_num_int _glp_lpx_get_num_int
260.1639 +int lpx_get_num_int(LPX *lp);
260.1640 +/* retrieve number of integer columns */
260.1641 +
260.1642 +#define lpx_get_num_bin _glp_lpx_get_num_bin
260.1643 +int lpx_get_num_bin(LPX *lp);
260.1644 +/* retrieve number of binary columns */
260.1645 +
260.1646 +#define lpx_integer _glp_lpx_integer
260.1647 +int lpx_integer(LPX *lp);
260.1648 +/* easy-to-use driver to the branch-and-bound method */
260.1649 +
260.1650 +#define lpx_intopt _glp_lpx_intopt
260.1651 +int lpx_intopt(LPX *lp);
260.1652 +/* easy-to-use driver to the branch-and-bound method */
260.1653 +
260.1654 +#define lpx_mip_status _glp_lpx_mip_status
260.1655 +int lpx_mip_status(LPX *lp);
260.1656 +/* retrieve status of MIP solution */
260.1657 +
260.1658 +#define lpx_mip_obj_val _glp_lpx_mip_obj_val
260.1659 +double lpx_mip_obj_val(LPX *lp);
260.1660 +/* retrieve objective value (MIP solution) */
260.1661 +
260.1662 +#define lpx_mip_row_val _glp_lpx_mip_row_val
260.1663 +double lpx_mip_row_val(LPX *lp, int i);
260.1664 +/* retrieve row value (MIP solution) */
260.1665 +
260.1666 +#define lpx_mip_col_val _glp_lpx_mip_col_val
260.1667 +double lpx_mip_col_val(LPX *lp, int j);
260.1668 +/* retrieve column value (MIP solution) */
260.1669 +
260.1670 +#define lpx_check_int _glp_lpx_check_int
260.1671 +void lpx_check_int(LPX *lp, LPXKKT *kkt);
260.1672 +/* check integer feasibility conditions */
260.1673 +
260.1674 +#define lpx_reset_parms _glp_lpx_reset_parms
260.1675 +void lpx_reset_parms(LPX *lp);
260.1676 +/* reset control parameters to default values */
260.1677 +
260.1678 +#define lpx_set_int_parm _glp_lpx_set_int_parm
260.1679 +void lpx_set_int_parm(LPX *lp, int parm, int val);
260.1680 +/* set (change) integer control parameter */
260.1681 +
260.1682 +#define lpx_get_int_parm _glp_lpx_get_int_parm
260.1683 +int lpx_get_int_parm(LPX *lp, int parm);
260.1684 +/* query integer control parameter */
260.1685 +
260.1686 +#define lpx_set_real_parm _glp_lpx_set_real_parm
260.1687 +void lpx_set_real_parm(LPX *lp, int parm, double val);
260.1688 +/* set (change) real control parameter */
260.1689 +
260.1690 +#define lpx_get_real_parm _glp_lpx_get_real_parm
260.1691 +double lpx_get_real_parm(LPX *lp, int parm);
260.1692 +/* query real control parameter */
260.1693 +
260.1694 +#define lpx_read_mps _glp_lpx_read_mps
260.1695 +LPX *lpx_read_mps(const char *fname);
260.1696 +/* read problem data in fixed MPS format */
260.1697 +
260.1698 +#define lpx_write_mps _glp_lpx_write_mps
260.1699 +int lpx_write_mps(LPX *lp, const char *fname);
260.1700 +/* write problem data in fixed MPS format */
260.1701 +
260.1702 +#define lpx_read_bas _glp_lpx_read_bas
260.1703 +int lpx_read_bas(LPX *lp, const char *fname);
260.1704 +/* read LP basis in fixed MPS format */
260.1705 +
260.1706 +#define lpx_write_bas _glp_lpx_write_bas
260.1707 +int lpx_write_bas(LPX *lp, const char *fname);
260.1708 +/* write LP basis in fixed MPS format */
260.1709 +
260.1710 +#define lpx_read_freemps _glp_lpx_read_freemps
260.1711 +LPX *lpx_read_freemps(const char *fname);
260.1712 +/* read problem data in free MPS format */
260.1713 +
260.1714 +#define lpx_write_freemps _glp_lpx_write_freemps
260.1715 +int lpx_write_freemps(LPX *lp, const char *fname);
260.1716 +/* write problem data in free MPS format */
260.1717 +
260.1718 +#define lpx_read_cpxlp _glp_lpx_read_cpxlp
260.1719 +LPX *lpx_read_cpxlp(const char *fname);
260.1720 +/* read problem data in CPLEX LP format */
260.1721 +
260.1722 +#define lpx_write_cpxlp _glp_lpx_write_cpxlp
260.1723 +int lpx_write_cpxlp(LPX *lp, const char *fname);
260.1724 +/* write problem data in CPLEX LP format */
260.1725 +
260.1726 +#define lpx_read_model _glp_lpx_read_model
260.1727 +LPX *lpx_read_model(const char *model, const char *data,
260.1728 +      const char *output);
260.1729 +/* read LP/MIP model written in GNU MathProg language */
260.1730 +
260.1731 +#define lpx_print_prob _glp_lpx_print_prob
260.1732 +int lpx_print_prob(LPX *lp, const char *fname);
260.1733 +/* write problem data in plain text format */
260.1734 +
260.1735 +#define lpx_print_sol _glp_lpx_print_sol
260.1736 +int lpx_print_sol(LPX *lp, const char *fname);
260.1737 +/* write LP problem solution in printable format */
260.1738 +
260.1739 +#define lpx_print_sens_bnds _glp_lpx_print_sens_bnds
260.1740 +int lpx_print_sens_bnds(LPX *lp, const char *fname);
260.1741 +/* write bounds sensitivity information */
260.1742 +
260.1743 +#define lpx_print_ips _glp_lpx_print_ips
260.1744 +int lpx_print_ips(LPX *lp, const char *fname);
260.1745 +/* write interior point solution in printable format */
260.1746 +
260.1747 +#define lpx_print_mip _glp_lpx_print_mip
260.1748 +int lpx_print_mip(LPX *lp, const char *fname);
260.1749 +/* write MIP problem solution in printable format */
260.1750 +
260.1751 +#define lpx_is_b_avail _glp_lpx_is_b_avail
260.1752 +int lpx_is_b_avail(LPX *lp);
260.1753 +/* check if LP basis is available */
260.1754 +
260.1755 +#define lpx_write_pb _glp_lpx_write_pb
260.1756 +int lpx_write_pb(LPX *lp, const char *fname, int normalized,
260.1757 +      int binarize);
260.1758 +/* write problem data in (normalized) OPB format */
260.1759 +
260.1760 +#define lpx_main _glp_lpx_main
260.1761 +int lpx_main(int argc, const char *argv[]);
260.1762 +/* stand-alone LP/MIP solver */
260.1763 +
260.1764 +#ifdef __cplusplus
260.1765 +}
260.1766 +#endif
260.1767 +
260.1768 +#endif
260.1769 +
260.1770 +/* eof */
   261.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
   261.2 +++ b/deps/glpk/src/glplib.h	Sun Nov 06 20:59:10 2011 +0100
   261.3 @@ -0,0 +1,135 @@
   261.4 +/* glplib.h (miscellaneous library routines) */
   261.5 +
   261.6 +/***********************************************************************
   261.7 +*  This code is part of GLPK (GNU Linear Programming Kit).
   261.8 +*
   261.9 +*  Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008,
  261.10 +*  2009, 2010, 2011 Andrew Makhorin, Department for Applied Informatics,
  261.11 +*  Moscow Aviation Institute, Moscow, Russia. All rights reserved.
  261.12 +*  E-mail: <mao@gnu.org>.
  261.13 +*
  261.14 +*  GLPK is free software: you can redistribute it and/or modify it
  261.15 +*  under the terms of the GNU General Public License as published by
  261.16 +*  the Free Software Foundation, either version 3 of the License, or
  261.17 +*  (at your option) any later version.
  261.18 +*
  261.19 +*  GLPK is distributed in the hope that it will be useful, but WITHOUT
  261.20 +*  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
  261.21 +*  or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
  261.22 +*  License for more details.
  261.23 +*
  261.24 +*  You should have received a copy of the GNU General Public License
  261.25 +*  along with GLPK. If not, see <http://www.gnu.org/licenses/>.
  261.26 +***********************************************************************/
  261.27 +
  261.28 +#ifndef GLPLIB_H
  261.29 +#define GLPLIB_H
  261.30 +
  261.31 +#define bigmul _glp_lib_bigmul
  261.32 +void bigmul(int n, int m, unsigned short x[], unsigned short y[]);
  261.33 +/* multiply unsigned integer numbers of arbitrary precision */
  261.34 +
  261.35 +#define bigdiv _glp_lib_bigdiv
  261.36 +void bigdiv(int n, int m, unsigned short x[], unsigned short y[]);
  261.37 +/* divide unsigned integer numbers of arbitrary precision */
  261.38 +
  261.39 +#ifndef GLP_LONG_DEFINED
  261.40 +#define GLP_LONG_DEFINED
  261.41 +typedef struct { int lo, hi; } glp_long;
  261.42 +/* long integer data type */
  261.43 +#endif
  261.44 +
  261.45 +typedef struct { glp_long quot, rem; } glp_ldiv;
  261.46 +/* result of long integer division */
  261.47 +
  261.48 +#define xlset _glp_lib_xlset
  261.49 +glp_long xlset(int x);
  261.50 +/* expand integer to long integer */
  261.51 +
  261.52 +#define xlneg _glp_lib_xlneg
  261.53 +glp_long xlneg(glp_long x);
  261.54 +/* negate long integer */
  261.55 +
  261.56 +#define xladd _glp_lib_xladd
  261.57 +glp_long xladd(glp_long x, glp_long y);
  261.58 +/* add long integers */
  261.59 +
  261.60 +#define xlsub _glp_lib_xlsub
  261.61 +glp_long xlsub(glp_long x, glp_long y);
  261.62 +/* subtract long integers */
  261.63 +
  261.64 +#define xlcmp _glp_lib_xlcmp
  261.65 +int xlcmp(glp_long x, glp_long y);
  261.66 +/* compare long integers */
  261.67 +
  261.68 +#define xlmul _glp_lib_xlmul
  261.69 +glp_long xlmul(glp_long x, glp_long y);
  261.70 +/* multiply long integers */
  261.71 +
  261.72 +#define xldiv _glp_lib_xldiv
  261.73 +glp_ldiv xldiv(glp_long x, glp_long y);
  261.74 +/* divide long integers */
  261.75 +
  261.76 +#define xltod _glp_lib_xltod
  261.77 +double xltod(glp_long x);
  261.78 +/* convert long integer to double */
  261.79 +
  261.80 +#define xltoa _glp_lib_xltoa
  261.81 +char *xltoa(glp_long x, char *s);
  261.82 +/* convert long integer to character string */
  261.83 +
  261.84 +#define str2int _glp_lib_str2int
  261.85 +int str2int(const char *str, int *val);
  261.86 +/* convert character string to value of int type */
  261.87 +
  261.88 +#define str2num _glp_lib_str2num
  261.89 +int str2num(const char *str, double *val);
  261.90 +/* convert character string to value of double type */
  261.91 +
  261.92 +#define strspx _glp_lib_strspx
  261.93 +char *strspx(char *str);
  261.94 +/* remove all spaces from character string */
  261.95 +
  261.96 +#define strtrim _glp_lib_strtrim
  261.97 +char *strtrim(char *str);
  261.98 +/* remove trailing spaces from character string */
  261.99 +
 261.100 +#define strrev _glp_lib_strrev
 261.101 +char *strrev(char *s);
 261.102 +/* reverse character string */
 261.103 +
 261.104 +#define gcd _glp_lib_gcd
 261.105 +int gcd(int x, int y);
 261.106 +/* find greatest common divisor of two integers */
 261.107 +
 261.108 +#define gcdn _glp_lib_gcdn
 261.109 +int gcdn(int n, int x[]);
 261.110 +/* find greatest common divisor of n integers */
 261.111 +
 261.112 +#define lcm _glp_lib_lcm
 261.113 +int lcm(int x, int y);
 261.114 +/* find least common multiple of two integers */
 261.115 +
 261.116 +#define lcmn _glp_lib_lcmn
 261.117 +int lcmn(int n, int x[]);
 261.118 +/* find least common multiple of n integers */
 261.119 +
 261.120 +#define round2n _glp_lib_round2n
 261.121 +double round2n(double x);
 261.122 +/* round floating-point number to nearest power of two */
 261.123 +
 261.124 +#define fp2rat _glp_lib_fp2rat
 261.125 +int fp2rat(double x, double eps, double *p, double *q);
 261.126 +/* convert floating-point number to rational number */
 261.127 +
 261.128 +#define jday _glp_lib_jday
 261.129 +int jday(int d, int m, int y);
 261.130 +/* convert calendar date to Julian day number */
 261.131 +
 261.132 +#define jdate _glp_lib_jdate
 261.133 +int jdate(int j, int *d, int *m, int *y);
 261.134 +/* convert Julian day number to calendar date */
 261.135 +
 261.136 +#endif
 261.137 +
 261.138 +/* eof */
   262.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
   262.2 +++ b/deps/glpk/src/glplib01.c	Sun Nov 06 20:59:10 2011 +0100
   262.3 @@ -0,0 +1,287 @@
   262.4 +/* glplib01.c (bignum arithmetic) */
   262.5 +
   262.6 +/***********************************************************************
   262.7 +*  This code is part of GLPK (GNU Linear Programming Kit).
   262.8 +*
   262.9 +*  Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008,
  262.10 +*  2009, 2010, 2011 Andrew Makhorin, Department for Applied Informatics,
  262.11 +*  Moscow Aviation Institute, Moscow, Russia. All rights reserved.
  262.12 +*  E-mail: <mao@gnu.org>.
  262.13 +*
  262.14 +*  GLPK is free software: you can redistribute it and/or modify it
  262.15 +*  under the terms of the GNU General Public License as published by
  262.16 +*  the Free Software Foundation, either version 3 of the License, or
  262.17 +*  (at your option) any later version.
  262.18 +*
  262.19 +*  GLPK is distributed in the hope that it will be useful, but WITHOUT
  262.20 +*  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
  262.21 +*  or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
  262.22 +*  License for more details.
  262.23 +*
  262.24 +*  You should have received a copy of the GNU General Public License
  262.25 +*  along with GLPK. If not, see <http://www.gnu.org/licenses/>.
  262.26 +***********************************************************************/
  262.27 +
  262.28 +#include "glpenv.h"
  262.29 +#include "glplib.h"
  262.30 +
  262.31 +/***********************************************************************
  262.32 +*  Two routines below are intended to multiply and divide unsigned
  262.33 +*  integer numbers of arbitrary precision.
  262.34 +* 
  262.35 +*  The routines assume that an unsigned integer number is represented in
  262.36 +*  the positional numeral system with the base 2^16 = 65536, i.e. each
  262.37 +*  "digit" of the number is in the range [0, 65535] and represented as
  262.38 +*  a 16-bit value of the unsigned short type. In other words, a number x
  262.39 +*  has the following representation:
  262.40 +* 
  262.41 +*         n-1
  262.42 +*     x = sum d[j] * 65536^j,
  262.43 +*         j=0
  262.44 +* 
  262.45 +*  where n is the number of places (positions), and d[j] is j-th "digit"
  262.46 +*  of x, 0 <= d[j] <= 65535.
  262.47 +***********************************************************************/
  262.48 +
  262.49 +/***********************************************************************
  262.50 +*  NAME
  262.51 +*
  262.52 +*  bigmul - multiply unsigned integer numbers of arbitrary precision
  262.53 +* 
  262.54 +*  SYNOPSIS
  262.55 +* 
  262.56 +*  #include "glplib.h"
  262.57 +*  void bigmul(int n, int m, unsigned short x[], unsigned short y[]);
  262.58 +* 
  262.59 +*  DESCRIPTION
  262.60 +* 
  262.61 +*  The routine bigmul multiplies unsigned integer numbers of arbitrary
  262.62 +*  precision.
  262.63 +* 
  262.64 +*  n is the number of digits of multiplicand, n >= 1;
  262.65 +* 
  262.66 +*  m is the number of digits of multiplier, m >= 1;
  262.67 +* 
  262.68 +*  x is an array containing digits of the multiplicand in elements
  262.69 +*  x[m], x[m+1], ..., x[n+m-1]. Contents of x[0], x[1], ..., x[m-1] are
  262.70 +*  ignored on entry.
  262.71 +* 
  262.72 +*  y is an array containing digits of the multiplier in elements y[0],
  262.73 +*  y[1], ..., y[m-1].
  262.74 +* 
  262.75 +*  On exit digits of the product are stored in elements x[0], x[1], ...,
  262.76 +*  x[n+m-1]. The array y is not changed. */
  262.77 +
  262.78 +void bigmul(int n, int m, unsigned short x[], unsigned short y[])
  262.79 +{     int i, j;
  262.80 +      unsigned int t;
  262.81 +      xassert(n >= 1);
  262.82 +      xassert(m >= 1);
  262.83 +      for (j = 0; j < m; j++) x[j] = 0;
  262.84 +      for (i = 0; i < n; i++)
  262.85 +      {  if (x[i+m])
  262.86 +         {  t = 0;
  262.87 +            for (j = 0; j < m; j++)
  262.88 +            {  t += (unsigned int)x[i+m] * (unsigned int)y[j] +
  262.89 +                    (unsigned int)x[i+j];
  262.90 +               x[i+j] = (unsigned short)t;
  262.91 +               t >>= 16;
  262.92 +            }
  262.93 +            x[i+m] = (unsigned short)t;
  262.94 +         }
  262.95 +      }
  262.96 +      return;
  262.97 +}
  262.98 +
  262.99 +/***********************************************************************
 262.100 +*  NAME
 262.101 +*
 262.102 +*  bigdiv - divide unsigned integer numbers of arbitrary precision
 262.103 +* 
 262.104 +*  SYNOPSIS
 262.105 +* 
 262.106 +*  #include "glplib.h"
 262.107 +*  void bigdiv(int n, int m, unsigned short x[], unsigned short y[]);
 262.108 +* 
 262.109 +*  DESCRIPTION
 262.110 +* 
 262.111 +*  The routine bigdiv divides one unsigned integer number of arbitrary
 262.112 +*  precision by another with the algorithm described in [1].
 262.113 +* 
 262.114 +*  n is the difference between the number of digits of dividend and the
 262.115 +*  number of digits of divisor, n >= 0.
 262.116 +* 
 262.117 +*  m is the number of digits of divisor, m >= 1.
 262.118 +* 
 262.119 +*  x is an array containing digits of the dividend in elements x[0],
 262.120 +*  x[1], ..., x[n+m-1].
 262.121 +* 
 262.122 +*  y is an array containing digits of the divisor in elements y[0],
 262.123 +*  y[1], ..., y[m-1]. The highest digit y[m-1] must be non-zero.
 262.124 +* 
 262.125 +*  On exit n+1 digits of the quotient are stored in elements x[m],
 262.126 +*  x[m+1], ..., x[n+m], and m digits of the remainder are stored in
 262.127 +*  elements x[0], x[1], ..., x[m-1]. The array y is changed but then
 262.128 +*  restored.
 262.129 +*
 262.130 +*  REFERENCES
 262.131 +*
 262.132 +*  1. D. Knuth. The Art of Computer Programming. Vol. 2: Seminumerical
 262.133 +*  Algorithms. Stanford University, 1969. */
 262.134 +
 262.135 +void bigdiv(int n, int m, unsigned short x[], unsigned short y[])
 262.136 +{     int i, j;
 262.137 +      unsigned int t;
 262.138 +      unsigned short d, q, r;
 262.139 +      xassert(n >= 0);
 262.140 +      xassert(m >= 1);
 262.141 +      xassert(y[m-1] != 0);
 262.142 +      /* special case when divisor has the only digit */
 262.143 +      if (m == 1)
 262.144 +      {  d = 0;
 262.145 +         for (i = n; i >= 0; i--)
 262.146 +         {  t = ((unsigned int)d << 16) + (unsigned int)x[i];
 262.147 +            x[i+1] = (unsigned short)(t / y[0]);
 262.148 +            d = (unsigned short)(t % y[0]);
 262.149 +         }
 262.150 +         x[0] = d;
 262.151 +         goto done;
 262.152 +      }
 262.153 +      /* multiply dividend and divisor by a normalizing coefficient in
 262.154 +         order to provide the condition y[m-1] >= base / 2 */
 262.155 +      d = (unsigned short)(0x10000 / ((unsigned int)y[m-1] + 1));
 262.156 +      if (d == 1)
 262.157 +         x[n+m] = 0;
 262.158 +      else
 262.159 +      {  t = 0;
 262.160 +         for (i = 0; i < n+m; i++)
 262.161 +         {  t += (unsigned int)x[i] * (unsigned int)d;
 262.162 +            x[i] = (unsigned short)t;
 262.163 +            t >>= 16;
 262.164 +         }
 262.165 +         x[n+m] = (unsigned short)t;
 262.166 +         t = 0;
 262.167 +         for (j = 0; j < m; j++)
 262.168 +         {  t += (unsigned int)y[j] * (unsigned int)d;
 262.169 +            y[j] = (unsigned short)t;
 262.170 +            t >>= 16;
 262.171 +         }
 262.172 +      }
 262.173 +      /* main loop */
 262.174 +      for (i = n; i >= 0; i--)
 262.175 +      {  /* estimate and correct the current digit of quotient */
 262.176 +         if (x[i+m] < y[m-1])
 262.177 +         {  t = ((unsigned int)x[i+m] << 16) + (unsigned int)x[i+m-1];
 262.178 +            q = (unsigned short)(t / (unsigned int)y[m-1]);
 262.179 +            r = (unsigned short)(t % (unsigned int)y[m-1]);
 262.180 +            if (q == 0) goto putq; else goto test;
 262.181 +         }
 262.182 +         q = 0;
 262.183 +         r = x[i+m-1];
 262.184 +decr:    q--; /* if q = 0 then q-- = 0xFFFF */
 262.185 +         t = (unsigned int)r + (unsigned int)y[m-1];
 262.186 +         r = (unsigned short)t;
 262.187 +         if (t > 0xFFFF) goto msub;
 262.188 +test:    t = (unsigned int)y[m-2] * (unsigned int)q;
 262.189 +         if ((unsigned short)(t >> 16) > r) goto decr;
 262.190 +         if ((unsigned short)(t >> 16) < r) goto msub;
 262.191 +         if ((unsigned short)t > x[i+m-2]) goto decr;
 262.192 +msub:    /* now subtract divisor multiplied by the current digit of
 262.193 +            quotient from the current dividend */
 262.194 +         if (q == 0) goto putq;
 262.195 +         t = 0;
 262.196 +         for (j = 0; j < m; j++)
 262.197 +         {  t += (unsigned int)y[j] * (unsigned int)q;
 262.198 +            if (x[i+j] < (unsigned short)t) t += 0x10000;
 262.199 +            x[i+j] -= (unsigned short)t;
 262.200 +            t >>= 16;
 262.201 +         }
 262.202 +         if (x[i+m] >= (unsigned short)t) goto putq;
 262.203 +         /* perform correcting addition, because the current digit of
 262.204 +            quotient is greater by one than its correct value */
 262.205 +         q--;
 262.206 +         t = 0;
 262.207 +         for (j = 0; j < m; j++)
 262.208 +         {  t += (unsigned int)x[i+j] + (unsigned int)y[j];
 262.209 +            x[i+j] = (unsigned short)t;
 262.210 +            t >>= 16;
 262.211 +         }
 262.212 +putq:    /* store the current digit of quotient */
 262.213 +         x[i+m] = q;
 262.214 +      }
 262.215 +      /* divide divisor and remainder by the normalizing coefficient in
 262.216 +         order to restore their original values */
 262.217 +      if (d > 1)
 262.218 +      {  t = 0;
 262.219 +         for (i = m-1; i >= 0; i--)
 262.220 +         {  t = (t << 16) + (unsigned int)x[i];
 262.221 +            x[i] = (unsigned short)(t / (unsigned int)d);
 262.222 +            t %= (unsigned int)d;
 262.223 +         }
 262.224 +         t = 0;
 262.225 +         for (j = m-1; j >= 0; j--)
 262.226 +         {  t = (t << 16) + (unsigned int)y[j];
 262.227 +            y[j] = (unsigned short)(t / (unsigned int)d);
 262.228 +            t %= (unsigned int)d;
 262.229 +         }
 262.230 +      }
 262.231 +done: return;
 262.232 +}
 262.233 +
 262.234 +/**********************************************************************/
 262.235 +
 262.236 +#if 0
 262.237 +#include <assert.h>
 262.238 +#include <stdio.h>
 262.239 +#include <stdlib.h>
 262.240 +#include "glprng.h"
 262.241 +
 262.242 +#define N_MAX 7
 262.243 +/* maximal number of digits in multiplicand */
 262.244 +
 262.245 +#define M_MAX 5
 262.246 +/* maximal number of digits in multiplier */
 262.247 +
 262.248 +#define N_TEST 1000000
 262.249 +/* number of tests */
 262.250 +
 262.251 +int main(void)
 262.252 +{     RNG *rand;
 262.253 +      int d, j, n, m, test;
 262.254 +      unsigned short x[N_MAX], y[M_MAX], z[N_MAX+M_MAX];
 262.255 +      rand = rng_create_rand();
 262.256 +      for (test = 1; test <= N_TEST; test++)
 262.257 +      {  /* x[0,...,n-1] := multiplicand */
 262.258 +         n = 1 + rng_unif_rand(rand, N_MAX-1);
 262.259 +         assert(1 <= n && n <= N_MAX);
 262.260 +         for (j = 0; j < n; j++)
 262.261 +         {  d = rng_unif_rand(rand, 65536);
 262.262 +            assert(0 <= d && d <= 65535);
 262.263 +            x[j] = (unsigned short)d;
 262.264 +         }
 262.265 +         /* y[0,...,m-1] := multiplier */
 262.266 +         m = 1 + rng_unif_rand(rand, M_MAX-1);
 262.267 +         assert(1 <= m && m <= M_MAX);
 262.268 +         for (j = 0; j < m; j++)
 262.269 +         {  d = rng_unif_rand(rand, 65536);
 262.270 +            assert(0 <= d && d <= 65535);
 262.271 +            y[j] = (unsigned short)d;
 262.272 +         }
 262.273 +         if (y[m-1] == 0) y[m-1] = 1;
 262.274 +         /* z[0,...,n+m-1] := x * y */
 262.275 +         for (j = 0; j < n; j++) z[m+j] = x[j];
 262.276 +         bigmul(n, m, z, y);
 262.277 +         /* z[0,...,m-1] := z mod y, z[m,...,n+m-1] := z div y */
 262.278 +         bigdiv(n, m, z, y);
 262.279 +         /* z mod y must be 0 */
 262.280 +         for (j = 0; j < m; j++) assert(z[j] == 0);
 262.281 +         /* z div y must be x */
 262.282 +         for (j = 0; j < n; j++) assert(z[m+j] == x[j]);
 262.283 +      }
 262.284 +      fprintf(stderr, "%d tests successfully passed\n", N_TEST);
 262.285 +      rng_delete_rand(rand);
 262.286 +      return 0;
 262.287 +}
 262.288 +#endif
 262.289 +
 262.290 +/* eof */
   263.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
   263.2 +++ b/deps/glpk/src/glplib02.c	Sun Nov 06 20:59:10 2011 +0100
   263.3 @@ -0,0 +1,335 @@
   263.4 +/* glplib02.c (64-bit arithmetic) */
   263.5 +
   263.6 +/***********************************************************************
   263.7 +*  This code is part of GLPK (GNU Linear Programming Kit).
   263.8 +*
   263.9 +*  Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008,
  263.10 +*  2009, 2010, 2011 Andrew Makhorin, Department for Applied Informatics,
  263.11 +*  Moscow Aviation Institute, Moscow, Russia. All rights reserved.
  263.12 +*  E-mail: <mao@gnu.org>.
  263.13 +*
  263.14 +*  GLPK is free software: you can redistribute it and/or modify it
  263.15 +*  under the terms of the GNU General Public License as published by
  263.16 +*  the Free Software Foundation, either version 3 of the License, or
  263.17 +*  (at your option) any later version.
  263.18 +*
  263.19 +*  GLPK is distributed in the hope that it will be useful, but WITHOUT
  263.20 +*  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
  263.21 +*  or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
  263.22 +*  License for more details.
  263.23 +*
  263.24 +*  You should have received a copy of the GNU General Public License
  263.25 +*  along with GLPK. If not, see <http://www.gnu.org/licenses/>.
  263.26 +***********************************************************************/
  263.27 +
  263.28 +#include "glpenv.h"
  263.29 +#include "glplib.h"
  263.30 +
  263.31 +/***********************************************************************
  263.32 +*  NAME
  263.33 +*
  263.34 +*  xlset - expand integer to long integer
  263.35 +*
  263.36 +*  SYNOPSIS
  263.37 +*
  263.38 +*  #include "glplib.h"
  263.39 +*  glp_long xlset(int x);
  263.40 +*
  263.41 +*  RETURNS
  263.42 +*
  263.43 +*  The routine xlset returns x expanded to long integer. */
  263.44 +
  263.45 +glp_long xlset(int x)
  263.46 +{     glp_long t;
  263.47 +      t.lo = x, t.hi = (x >= 0 ? 0 : -1);
  263.48 +      return t;
  263.49 +}
  263.50 +
  263.51 +/***********************************************************************
  263.52 +*  NAME
  263.53 +*
  263.54 +*  xlneg - negate long integer
  263.55 +*
  263.56 +*  SYNOPSIS
  263.57 +*
  263.58 +*  #include "glplib.h"
  263.59 +*  glp_long xlneg(glp_long x);
  263.60 +*
  263.61 +*  RETURNS
  263.62 +*
  263.63 +*  The routine xlneg returns the difference  0 - x. */
  263.64 +
  263.65 +glp_long xlneg(glp_long x)
  263.66 +{     if (x.lo)
  263.67 +         x.lo = - x.lo, x.hi = ~x.hi;
  263.68 +      else
  263.69 +         x.hi = - x.hi;
  263.70 +      return x;
  263.71 +}
  263.72 +
  263.73 +/***********************************************************************
  263.74 +*  NAME
  263.75 +*
  263.76 +*  xladd - add long integers
  263.77 +*
  263.78 +*  SYNOPSIS
  263.79 +*
  263.80 +*  #include "glplib.h"
  263.81 +*  glp_long xladd(glp_long x, glp_long y);
  263.82 +*
  263.83 +*  RETURNS
  263.84 +*
  263.85 +*  The routine xladd returns the sum x + y. */
  263.86 +
  263.87 +glp_long xladd(glp_long x, glp_long y)
  263.88 +{     if ((unsigned int)x.lo <= 0xFFFFFFFF - (unsigned int)y.lo)
  263.89 +         x.lo += y.lo, x.hi += y.hi;
  263.90 +      else
  263.91 +         x.lo += y.lo, x.hi += y.hi + 1;
  263.92 +      return x;
  263.93 +}
  263.94 +
  263.95 +/***********************************************************************
  263.96 +*  NAME
  263.97 +*
  263.98 +*  xlsub - subtract long integers
  263.99 +*
 263.100 +*  SYNOPSIS
 263.101 +*
 263.102 +*  #include "glplib.h"
 263.103 +*  glp_long xlsub(glp_long x, glp_long y);
 263.104 +*
 263.105 +*  RETURNS
 263.106 +*
 263.107 +*  The routine xlsub returns the difference x - y. */
 263.108 +
 263.109 +glp_long xlsub(glp_long x, glp_long y)
 263.110 +{     return
 263.111 +         xladd(x, xlneg(y));
 263.112 +}
 263.113 +
 263.114 +/***********************************************************************
 263.115 +*  NAME
 263.116 +*
 263.117 +*  xlcmp - compare long integers
 263.118 +*
 263.119 +*  SYNOPSIS
 263.120 +*
 263.121 +*  #include "glplib.h"
 263.122 +*  int xlcmp(glp_long x, glp_long y);
 263.123 +*
 263.124 +*  RETURNS
 263.125 +*
 263.126 +*  The routine xlcmp returns the sign of the difference x - y. */
 263.127 +
 263.128 +int xlcmp(glp_long x, glp_long y)
 263.129 +{     if (x.hi >= 0 && y.hi <  0) return +1;
 263.130 +      if (x.hi <  0 && y.hi >= 0) return -1;
 263.131 +      if ((unsigned int)x.hi < (unsigned int)y.hi) return -1;
 263.132 +      if ((unsigned int)x.hi > (unsigned int)y.hi) return +1;
 263.133 +      if ((unsigned int)x.lo < (unsigned int)y.lo) return -1;
 263.134 +      if ((unsigned int)x.lo > (unsigned int)y.lo) return +1;
 263.135 +      return 0;
 263.136 +}
 263.137 +
 263.138 +/***********************************************************************
 263.139 +*  NAME
 263.140 +*
 263.141 +*  xlmul - multiply long integers
 263.142 +*
 263.143 +*  SYNOPSIS
 263.144 +*
 263.145 +*  #include "glplib.h"
 263.146 +*  glp_long xlmul(glp_long x, glp_long y);
 263.147 +*
 263.148 +*  RETURNS
 263.149 +*
 263.150 +*  The routine xlmul returns the product x * y. */
 263.151 +
 263.152 +glp_long xlmul(glp_long x, glp_long y)
 263.153 +{     unsigned short xx[8], yy[4];
 263.154 +      xx[4] = (unsigned short)x.lo;
 263.155 +      xx[5] = (unsigned short)(x.lo >> 16);
 263.156 +      xx[6] = (unsigned short)x.hi;
 263.157 +      xx[7] = (unsigned short)(x.hi >> 16);
 263.158 +      yy[0] = (unsigned short)y.lo;
 263.159 +      yy[1] = (unsigned short)(y.lo >> 16);
 263.160 +      yy[2] = (unsigned short)y.hi;
 263.161 +      yy[3] = (unsigned short)(y.hi >> 16);
 263.162 +      bigmul(4, 4, xx, yy);
 263.163 +      x.lo = (unsigned int)xx[0] | ((unsigned int)xx[1] << 16);
 263.164 +      x.hi = (unsigned int)xx[2] | ((unsigned int)xx[3] << 16);
 263.165 +      return x;
 263.166 +}
 263.167 +
 263.168 +/***********************************************************************
 263.169 +*  NAME
 263.170 +*
 263.171 +*  xldiv - divide long integers
 263.172 +*
 263.173 +*  SYNOPSIS
 263.174 +*
 263.175 +*  #include "glplib.h"
 263.176 +*  glp_ldiv xldiv(glp_long x, glp_long y);
 263.177 +*
 263.178 +*  RETURNS
 263.179 +*
 263.180 +*  The routine xldiv returns a structure of type glp_ldiv containing
 263.181 +*  members quot (the quotient) and rem (the remainder), both of type
 263.182 +*  glp_long. */
 263.183 +
 263.184 +glp_ldiv xldiv(glp_long x, glp_long y)
 263.185 +{     glp_ldiv t;
 263.186 +      int m, sx, sy;
 263.187 +      unsigned short xx[8], yy[4];
 263.188 +      /* sx := sign(x) */
 263.189 +      sx = (x.hi < 0);
 263.190 +      /* sy := sign(y) */
 263.191 +      sy = (y.hi < 0);
 263.192 +      /* x := |x| */
 263.193 +      if (sx) x = xlneg(x);
 263.194 +      /* y := |y| */
 263.195 +      if (sy) y = xlneg(y);
 263.196 +      /* compute x div y and x mod y */
 263.197 +      xx[0] = (unsigned short)x.lo;
 263.198 +      xx[1] = (unsigned short)(x.lo >> 16);
 263.199 +      xx[2] = (unsigned short)x.hi;
 263.200 +      xx[3] = (unsigned short)(x.hi >> 16);
 263.201 +      yy[0] = (unsigned short)y.lo;
 263.202 +      yy[1] = (unsigned short)(y.lo >> 16);
 263.203 +      yy[2] = (unsigned short)y.hi;
 263.204 +      yy[3] = (unsigned short)(y.hi >> 16);
 263.205 +      if (yy[3])
 263.206 +         m = 4;
 263.207 +      else if (yy[2])
 263.208 +         m = 3;
 263.209 +      else if (yy[1])
 263.210 +         m = 2;
 263.211 +      else if (yy[0])
 263.212 +         m = 1;
 263.213 +      else
 263.214 +         xerror("xldiv: divide by zero\n");
 263.215 +      bigdiv(4 - m, m, xx, yy);
 263.216 +      /* remainder in x[0], x[1], ..., x[m-1] */
 263.217 +      t.rem.lo = (unsigned int)xx[0], t.rem.hi = 0;
 263.218 +      if (m >= 2) t.rem.lo |= (unsigned int)xx[1] << 16;
 263.219 +      if (m >= 3) t.rem.hi = (unsigned int)xx[2];
 263.220 +      if (m >= 4) t.rem.hi |= (unsigned int)xx[3] << 16;
 263.221 +      if (sx) t.rem = xlneg(t.rem);
 263.222 +      /* quotient in x[m], x[m+1], ..., x[4] */
 263.223 +      t.quot.lo = (unsigned int)xx[m], t.quot.hi = 0;
 263.224 +      if (m <= 3) t.quot.lo |= (unsigned int)xx[m+1] << 16;
 263.225 +      if (m <= 2) t.quot.hi = (unsigned int)xx[m+2];
 263.226 +      if (m <= 1) t.quot.hi |= (unsigned int)xx[m+3] << 16;
 263.227 +      if (sx ^ sy) t.quot = xlneg(t.quot);
 263.228 +      return t;
 263.229 +}
 263.230 +
 263.231 +/***********************************************************************
 263.232 +*  NAME
 263.233 +*
 263.234 +*  xltod - convert long integer to double
 263.235 +*
 263.236 +*  SYNOPSIS
 263.237 +*
 263.238 +*  #include "glplib.h"
 263.239 +*  double xltod(glp_long x);
 263.240 +*
 263.241 +*  RETURNS
 263.242 +*
 263.243 +*  The routine xltod returns x converted to double. */
 263.244 +
 263.245 +double xltod(glp_long x)
 263.246 +{     double s, z;
 263.247 +      if (x.hi >= 0)
 263.248 +         s = +1.0;
 263.249 +      else
 263.250 +         s = -1.0, x = xlneg(x);
 263.251 +      if (x.hi >= 0)
 263.252 +         z = 4294967296.0 * (double)x.hi + (double)(unsigned int)x.lo;
 263.253 +      else
 263.254 +      {  xassert(x.hi == 0x80000000 && x.lo == 0x00000000);
 263.255 +         z = 9223372036854775808.0; /* 2^63 */
 263.256 +      }
 263.257 +      return s * z;
 263.258 +}
 263.259 +
 263.260 +char *xltoa(glp_long x, char *s)
 263.261 +{     /* convert long integer to character string */
 263.262 +      static const char *d = "0123456789";
 263.263 +      glp_ldiv t;
 263.264 +      int neg, len;
 263.265 +      if (x.hi >= 0)
 263.266 +         neg = 0;
 263.267 +      else
 263.268 +         neg = 1, x = xlneg(x);
 263.269 +      if (x.hi >= 0)
 263.270 +      {  len = 0;
 263.271 +         while (!(x.hi == 0 && x.lo == 0))
 263.272 +         {  t = xldiv(x, xlset(10));
 263.273 +            xassert(0 <= t.rem.lo && t.rem.lo <= 9);
 263.274 +            s[len++] = d[t.rem.lo];
 263.275 +            x = t.quot;
 263.276 +         }
 263.277 +         if (len == 0) s[len++] = d[0];
 263.278 +         if (neg) s[len++] = '-';
 263.279 +         s[len] = '\0';
 263.280 +         strrev(s);
 263.281 +      }
 263.282 +      else
 263.283 +         strcpy(s, "-9223372036854775808"); /* -2^63 */
 263.284 +      return s;
 263.285 +}
 263.286 +
 263.287 +/**********************************************************************/
 263.288 +
 263.289 +#if 0
 263.290 +#include "glprng.h"
 263.291 +
 263.292 +#define N_TEST 1000000
 263.293 +/* number of tests */
 263.294 +
 263.295 +static glp_long myrand(RNG *rand)
 263.296 +{     glp_long x;
 263.297 +      int k;
 263.298 +      k = rng_unif_rand(rand, 4);
 263.299 +      xassert(0 <= k && k <= 3);
 263.300 +      x.lo = rng_unif_rand(rand, 65536);
 263.301 +      if (k == 1 || k == 3)
 263.302 +      {  x.lo <<= 16;
 263.303 +         x.lo += rng_unif_rand(rand, 65536);
 263.304 +      }
 263.305 +      if (k <= 1)
 263.306 +         x.hi = 0;
 263.307 +      else
 263.308 +         x.hi = rng_unif_rand(rand, 65536);
 263.309 +      if (k == 3)
 263.310 +      {  x.hi <<= 16;
 263.311 +         x.hi += rng_unif_rand(rand, 65536);
 263.312 +      }
 263.313 +      if (rng_unif_rand(rand, 2)) x = xlneg(x);
 263.314 +      return x;
 263.315 +}
 263.316 +
 263.317 +int main(void)
 263.318 +{     RNG *rand;
 263.319 +      glp_long x, y;
 263.320 +      glp_ldiv z;
 263.321 +      int test;
 263.322 +      rand = rng_create_rand();
 263.323 +      for (test = 1; test <= N_TEST; test++)
 263.324 +      {  x = myrand(rand);
 263.325 +         y = myrand(rand);
 263.326 +         if (y.lo == 0 && y.hi == 0) y.lo = 1;
 263.327 +         /* z.quot := x div y, z.rem := x mod y */
 263.328 +         z = xldiv(x, y);
 263.329 +         /* x must be equal to y * z.quot + z.rem */
 263.330 +         xassert(xlcmp(x, xladd(xlmul(y, z.quot), z.rem)) == 0);
 263.331 +      }
 263.332 +      xprintf("%d tests successfully passed\n", N_TEST);
 263.333 +      rng_delete_rand(rand);
 263.334 +      return 0;
 263.335 +}
 263.336 +#endif
 263.337 +
 263.338 +/* eof */
   264.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
   264.2 +++ b/deps/glpk/src/glplib03.c	Sun Nov 06 20:59:10 2011 +0100
   264.3 @@ -0,0 +1,692 @@
   264.4 +/* glplib03.c (miscellaneous library routines) */
   264.5 +
   264.6 +/***********************************************************************
   264.7 +*  This code is part of GLPK (GNU Linear Programming Kit).
   264.8 +*
   264.9 +*  Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008,
  264.10 +*  2009, 2010, 2011 Andrew Makhorin, Department for Applied Informatics,
  264.11 +*  Moscow Aviation Institute, Moscow, Russia. All rights reserved.
  264.12 +*  E-mail: <mao@gnu.org>.
  264.13 +*
  264.14 +*  GLPK is free software: you can redistribute it and/or modify it
  264.15 +*  under the terms of the GNU General Public License as published by
  264.16 +*  the Free Software Foundation, either version 3 of the License, or
  264.17 +*  (at your option) any later version.
  264.18 +*
  264.19 +*  GLPK is distributed in the hope that it will be useful, but WITHOUT
  264.20 +*  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
  264.21 +*  or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
  264.22 +*  License for more details.
  264.23 +*
  264.24 +*  You should have received a copy of the GNU General Public License
  264.25 +*  along with GLPK. If not, see <http://www.gnu.org/licenses/>.
  264.26 +***********************************************************************/
  264.27 +
  264.28 +#include "glpenv.h"
  264.29 +#include "glplib.h"
  264.30 +
  264.31 +/***********************************************************************
  264.32 +*  NAME
  264.33 +*
  264.34 +*  str2int - convert character string to value of int type
  264.35 +*
  264.36 +*  SYNOPSIS
  264.37 +*
  264.38 +*  #include "glplib.h"
  264.39 +*  int str2int(const char *str, int *val);
  264.40 +*
  264.41 +*  DESCRIPTION
  264.42 +*
  264.43 +*  The routine str2int converts the character string str to a value of
  264.44 +*  integer type and stores the value into location, which the parameter
  264.45 +*  val points to (in the case of error content of this location is not
  264.46 +*  changed).
  264.47 +*
  264.48 +*  RETURNS
  264.49 +*
  264.50 +*  The routine returns one of the following error codes:
  264.51 +*
  264.52 +*  0 - no error;
  264.53 +*  1 - value out of range;
  264.54 +*  2 - character string is syntactically incorrect. */
  264.55 +
  264.56 +int str2int(const char *str, int *_val)
  264.57 +{     int d, k, s, val = 0;
  264.58 +      /* scan optional sign */
  264.59 +      if (str[0] == '+')
  264.60 +         s = +1, k = 1;
  264.61 +      else if (str[0] == '-')
  264.62 +         s = -1, k = 1;
  264.63 +      else
  264.64 +         s = +1, k = 0;
  264.65 +      /* check for the first digit */
  264.66 +      if (!isdigit((unsigned char)str[k])) return 2;
  264.67 +      /* scan digits */
  264.68 +      while (isdigit((unsigned char)str[k]))
  264.69 +      {  d = str[k++] - '0';
  264.70 +         if (s > 0)
  264.71 +         {  if (val > INT_MAX / 10) return 1;
  264.72 +            val *= 10;
  264.73 +            if (val > INT_MAX - d) return 1;
  264.74 +            val += d;
  264.75 +         }
  264.76 +         else
  264.77 +         {  if (val < INT_MIN / 10) return 1;
  264.78 +            val *= 10;
  264.79 +            if (val < INT_MIN + d) return 1;
  264.80 +            val -= d;
  264.81 +         }
  264.82 +      }
  264.83 +      /* check for terminator */
  264.84 +      if (str[k] != '\0') return 2;
  264.85 +      /* conversion has been done */
  264.86 +      *_val = val;
  264.87 +      return 0;
  264.88 +}
  264.89 +
  264.90 +/***********************************************************************
  264.91 +*  NAME
  264.92 +*
  264.93 +*  str2num - convert character string to value of double type
  264.94 +*
  264.95 +*  SYNOPSIS
  264.96 +*
  264.97 +*  #include "glplib.h"
  264.98 +*  int str2num(const char *str, double *val);
  264.99 +*
 264.100 +*  DESCRIPTION
 264.101 +*
 264.102 +*  The routine str2num converts the character string str to a value of
 264.103 +*  double type and stores the value into location, which the parameter
 264.104 +*  val points to (in the case of error content of this location is not
 264.105 +*  changed).
 264.106 +*
 264.107 +*  RETURNS
 264.108 +*
 264.109 +*  The routine returns one of the following error codes:
 264.110 +*
 264.111 +*  0 - no error;
 264.112 +*  1 - value out of range;
 264.113 +*  2 - character string is syntactically incorrect. */
 264.114 +
 264.115 +int str2num(const char *str, double *_val)
 264.116 +{     int k;
 264.117 +      double val;
 264.118 +      /* scan optional sign */
 264.119 +      k = (str[0] == '+' || str[0] == '-' ? 1 : 0);
 264.120 +      /* check for decimal point */
 264.121 +      if (str[k] == '.')
 264.122 +      {  k++;
 264.123 +         /* a digit should follow it */
 264.124 +         if (!isdigit((unsigned char)str[k])) return 2;
 264.125 +         k++;
 264.126 +         goto frac;
 264.127 +      }
 264.128 +      /* integer part should start with a digit */
 264.129 +      if (!isdigit((unsigned char)str[k])) return 2;
 264.130 +      /* scan integer part */
 264.131 +      while (isdigit((unsigned char)str[k])) k++;
 264.132 +      /* check for decimal point */
 264.133 +      if (str[k] == '.') k++;
 264.134 +frac: /* scan optional fraction part */
 264.135 +      while (isdigit((unsigned char)str[k])) k++;
 264.136 +      /* check for decimal exponent */
 264.137 +      if (str[k] == 'E' || str[k] == 'e')
 264.138 +      {  k++;
 264.139 +         /* scan optional sign */
 264.140 +         if (str[k] == '+' || str[k] == '-') k++;
 264.141 +         /* a digit should follow E, E+ or E- */
 264.142 +         if (!isdigit((unsigned char)str[k])) return 2;
 264.143 +      }
 264.144 +      /* scan optional exponent part */
 264.145 +      while (isdigit((unsigned char)str[k])) k++;
 264.146 +      /* check for terminator */
 264.147 +      if (str[k] != '\0') return 2;
 264.148 +      /* perform conversion */
 264.149 +      {  char *endptr;
 264.150 +         val = strtod(str, &endptr);
 264.151 +         if (*endptr != '\0') return 2;
 264.152 +      }
 264.153 +      /* check for overflow */
 264.154 +      if (!(-DBL_MAX <= val && val <= +DBL_MAX)) return 1;
 264.155 +      /* check for underflow */
 264.156 +      if (-DBL_MIN < val && val < +DBL_MIN) val = 0.0;
 264.157 +      /* conversion has been done */
 264.158 +      *_val = val;
 264.159 +      return 0;
 264.160 +}
 264.161 +
 264.162 +/***********************************************************************
 264.163 +*  NAME
 264.164 +*
 264.165 +*  strspx - remove all spaces from character string
 264.166 +*
 264.167 +*  SYNOPSIS
 264.168 +*
 264.169 +*  #include "glplib.h"
 264.170 +*  char *strspx(char *str);
 264.171 +*
 264.172 +*  DESCRIPTION
 264.173 +*
 264.174 +*  The routine strspx removes all spaces from the character string str.
 264.175 +*
 264.176 +*  RETURNS
 264.177 +*
 264.178 +*  The routine returns a pointer to the character string.
 264.179 +*
 264.180 +*  EXAMPLES
 264.181 +*
 264.182 +*  strspx("   Errare   humanum   est   ") => "Errarehumanumest"
 264.183 +*
 264.184 +*  strspx("      ")                       => "" */
 264.185 +
 264.186 +char *strspx(char *str)
 264.187 +{     char *s, *t;
 264.188 +      for (s = t = str; *s; s++) if (*s != ' ') *t++ = *s;
 264.189 +      *t = '\0';
 264.190 +      return str;
 264.191 +}
 264.192 +
 264.193 +/***********************************************************************
 264.194 +*  NAME
 264.195 +*
 264.196 +*  strtrim - remove trailing spaces from character string
 264.197 +*
 264.198 +*  SYNOPSIS
 264.199 +*
 264.200 +*  #include "glplib.h"
 264.201 +*  char *strtrim(char *str);
 264.202 +*
 264.203 +*  DESCRIPTION
 264.204 +*
 264.205 +*  The routine strtrim removes trailing spaces from the character
 264.206 +*  string str.
 264.207 +*
 264.208 +*  RETURNS
 264.209 +*
 264.210 +*  The routine returns a pointer to the character string.
 264.211 +*
 264.212 +*  EXAMPLES
 264.213 +*
 264.214 +*  strtrim("Errare humanum est   ") => "Errare humanum est"
 264.215 +*
 264.216 +*  strtrim("      ")                => "" */
 264.217 +
 264.218 +char *strtrim(char *str)
 264.219 +{     char *t;
 264.220 +      for (t = strrchr(str, '\0') - 1; t >= str; t--)
 264.221 +      {  if (*t != ' ') break;
 264.222 +         *t = '\0';
 264.223 +      }
 264.224 +      return str;
 264.225 +}
 264.226 +
 264.227 +/***********************************************************************
 264.228 +*  NAME
 264.229 +*
 264.230 +*  strrev - reverse character string
 264.231 +*
 264.232 +*  SYNOPSIS
 264.233 +*
 264.234 +*  #include "glplib.h"
 264.235 +*  char *strrev(char *s);
 264.236 +*
 264.237 +*  DESCRIPTION
 264.238 +*
 264.239 +*  The routine strrev changes characters in a character string s to the
 264.240 +*  reverse order, except the terminating null character.
 264.241 +*
 264.242 +*  RETURNS
 264.243 +*
 264.244 +*  The routine returns the pointer s.
 264.245 +*
 264.246 +*  EXAMPLES
 264.247 +*
 264.248 +*  strrev("")                => ""
 264.249 +*
 264.250 +*  strrev("Today is Monday") => "yadnoM si yadoT" */
 264.251 +
 264.252 +char *strrev(char *s)
 264.253 +{     int i, j;
 264.254 +      char t;
 264.255 +      for (i = 0, j = strlen(s)-1; i < j; i++, j--)
 264.256 +         t = s[i], s[i] = s[j], s[j] = t;
 264.257 +      return s;
 264.258 +}
 264.259 +
 264.260 +/***********************************************************************
 264.261 +*  NAME
 264.262 +*
 264.263 +*  gcd - find greatest common divisor of two integers
 264.264 +*
 264.265 +*  SYNOPSIS
 264.266 +*
 264.267 +*  #include "glplib.h"
 264.268 +*  int gcd(int x, int y);
 264.269 +*
 264.270 +*  RETURNS
 264.271 +*
 264.272 +*  The routine gcd returns gcd(x, y), the greatest common divisor of
 264.273 +*  the two positive integers given.
 264.274 +*
 264.275 +*  ALGORITHM
 264.276 +*
 264.277 +*  The routine gcd is based on Euclid's algorithm.
 264.278 +*
 264.279 +*  REFERENCES
 264.280 +*
 264.281 +*  Don Knuth, The Art of Computer Programming, Vol.2: Seminumerical
 264.282 +*  Algorithms, 3rd Edition, Addison-Wesley, 1997. Section 4.5.2: The
 264.283 +*  Greatest Common Divisor, pp. 333-56. */
 264.284 +
 264.285 +int gcd(int x, int y)
 264.286 +{     int r;
 264.287 +      xassert(x > 0 && y > 0);
 264.288 +      while (y > 0)
 264.289 +         r = x % y, x = y, y = r;
 264.290 +      return x;
 264.291 +}
 264.292 +
 264.293 +/***********************************************************************
 264.294 +*  NAME
 264.295 +*
 264.296 +*  gcdn - find greatest common divisor of n integers
 264.297 +*
 264.298 +*  SYNOPSIS
 264.299 +*
 264.300 +*  #include "glplib.h"
 264.301 +*  int gcdn(int n, int x[]);
 264.302 +*
 264.303 +*  RETURNS
 264.304 +*
 264.305 +*  The routine gcdn returns gcd(x[1], x[2], ..., x[n]), the greatest
 264.306 +*  common divisor of n positive integers given, n > 0.
 264.307 +*
 264.308 +*  BACKGROUND
 264.309 +*
 264.310 +*  The routine gcdn is based on the following identity:
 264.311 +*
 264.312 +*     gcd(x, y, z) = gcd(gcd(x, y), z).
 264.313 +*
 264.314 +*  REFERENCES
 264.315 +*
 264.316 +*  Don Knuth, The Art of Computer Programming, Vol.2: Seminumerical
 264.317 +*  Algorithms, 3rd Edition, Addison-Wesley, 1997. Section 4.5.2: The
 264.318 +*  Greatest Common Divisor, pp. 333-56. */
 264.319 +
 264.320 +int gcdn(int n, int x[])
 264.321 +{     int d, j;
 264.322 +      xassert(n > 0);
 264.323 +      for (j = 1; j <= n; j++)
 264.324 +      {  xassert(x[j] > 0);
 264.325 +         if (j == 1)
 264.326 +            d = x[1];
 264.327 +         else
 264.328 +            d = gcd(d, x[j]);
 264.329 +         if (d == 1) break;
 264.330 +      }
 264.331 +      return d;
 264.332 +}
 264.333 +
 264.334 +/***********************************************************************
 264.335 +*  NAME
 264.336 +*
 264.337 +*  lcm - find least common multiple of two integers
 264.338 +*
 264.339 +*  SYNOPSIS
 264.340 +*
 264.341 +*  #include "glplib.h"
 264.342 +*  int lcm(int x, int y);
 264.343 +*
 264.344 +*  RETURNS
 264.345 +*
 264.346 +*  The routine lcm returns lcm(x, y), the least common multiple of the
 264.347 +*  two positive integers given. In case of integer overflow the routine
 264.348 +*  returns zero.
 264.349 +*
 264.350 +*  BACKGROUND
 264.351 +*
 264.352 +*  The routine lcm is based on the following identity:
 264.353 +*
 264.354 +*     lcm(x, y) = (x * y) / gcd(x, y) = x * [y / gcd(x, y)],
 264.355 +*
 264.356 +*  where gcd(x, y) is the greatest common divisor of x and y. */
 264.357 +
 264.358 +int lcm(int x, int y)
 264.359 +{     xassert(x > 0);
 264.360 +      xassert(y > 0);
 264.361 +      y /= gcd(x, y);
 264.362 +      if (x > INT_MAX / y) return 0;
 264.363 +      return x * y;
 264.364 +}
 264.365 +
 264.366 +/***********************************************************************
 264.367 +*  NAME
 264.368 +*
 264.369 +*  lcmn - find least common multiple of n integers
 264.370 +*
 264.371 +*  SYNOPSIS
 264.372 +*
 264.373 +*  #include "glplib.h"
 264.374 +*  int lcmn(int n, int x[]);
 264.375 +*
 264.376 +*  RETURNS
 264.377 +*
 264.378 +*  The routine lcmn returns lcm(x[1], x[2], ..., x[n]), the least
 264.379 +*  common multiple of n positive integers given, n > 0. In case of
 264.380 +*  integer overflow the routine returns zero.
 264.381 +*
 264.382 +*  BACKGROUND
 264.383 +*
 264.384 +*  The routine lcmn is based on the following identity:
 264.385 +*
 264.386 +*     lcmn(x, y, z) = lcm(lcm(x, y), z),
 264.387 +*
 264.388 +*  where lcm(x, y) is the least common multiple of x and y. */
 264.389 +
 264.390 +int lcmn(int n, int x[])
 264.391 +{     int m, j;
 264.392 +      xassert(n > 0);
 264.393 +      for (j = 1; j <= n; j++)
 264.394 +      {  xassert(x[j] > 0);
 264.395 +         if (j == 1)
 264.396 +            m = x[1];
 264.397 +         else
 264.398 +            m = lcm(m, x[j]);
 264.399 +         if (m == 0) break;
 264.400 +      }
 264.401 +      return m;
 264.402 +}
 264.403 +
 264.404 +/***********************************************************************
 264.405 +*  NAME
 264.406 +*
 264.407 +*  round2n - round floating-point number to nearest power of two
 264.408 +*
 264.409 +*  SYNOPSIS
 264.410 +*
 264.411 +*  #include "glplib.h"
 264.412 +*  double round2n(double x);
 264.413 +*
 264.414 +*  RETURNS
 264.415 +*
 264.416 +*  Given a positive floating-point value x the routine round2n returns
 264.417 +*  2^n such that |x - 2^n| is minimal.
 264.418 +*
 264.419 +*  EXAMPLES
 264.420 +*
 264.421 +*  round2n(10.1) = 2^3 = 8
 264.422 +*  round2n(15.3) = 2^4 = 16
 264.423 +*  round2n(0.01) = 2^(-7) = 0.0078125
 264.424 +*
 264.425 +*  BACKGROUND
 264.426 +*
 264.427 +*  Let x = f * 2^e, where 0.5 <= f < 1 is a normalized fractional part,
 264.428 +*  e is an integer exponent. Then, obviously, 0.5 * 2^e <= x < 2^e, so
 264.429 +*  if x - 0.5 * 2^e <= 2^e - x, we choose 0.5 * 2^e = 2^(e-1), and 2^e
 264.430 +*  otherwise. The latter condition can be written as 2 * x <= 1.5 * 2^e
 264.431 +*  or 2 * f * 2^e <= 1.5 * 2^e or, finally, f <= 0.75. */
 264.432 +
 264.433 +double round2n(double x)
 264.434 +{     int e;
 264.435 +      double f;
 264.436 +      xassert(x > 0.0);
 264.437 +      f = frexp(x, &e);
 264.438 +      return ldexp(1.0, f <= 0.75 ? e-1 : e);
 264.439 +}
 264.440 +
 264.441 +/***********************************************************************
 264.442 +*  NAME
 264.443 +*
 264.444 +*  fp2rat - convert floating-point number to rational number
 264.445 +*
 264.446 +*  SYNOPSIS
 264.447 +*
 264.448 +*  #include "glplib.h"
 264.449 +*  int fp2rat(double x, double eps, double *p, double *q);
 264.450 +*
 264.451 +*  DESCRIPTION
 264.452 +*
 264.453 +*  Given a floating-point number 0 <= x < 1 the routine fp2rat finds
 264.454 +*  its "best" rational approximation p / q, where p >= 0 and q > 0 are
 264.455 +*  integer numbers, such that |x - p / q| <= eps.
 264.456 +*
 264.457 +*  RETURNS
 264.458 +*
 264.459 +*  The routine fp2rat returns the number of iterations used to achieve
 264.460 +*  the specified precision eps.
 264.461 +*
 264.462 +*  EXAMPLES
 264.463 +*
 264.464 +*  For x = sqrt(2) - 1 = 0.414213562373095 and eps = 1e-6 the routine
 264.465 +*  gives p = 408 and q = 985, where 408 / 985 = 0.414213197969543.
 264.466 +*
 264.467 +*  BACKGROUND
 264.468 +*
 264.469 +*  It is well known that every positive real number x can be expressed
 264.470 +*  as the following continued fraction:
 264.471 +*
 264.472 +*     x = b[0] + a[1]
 264.473 +*                ------------------------
 264.474 +*                b[1] + a[2]
 264.475 +*                       -----------------
 264.476 +*                       b[2] + a[3]
 264.477 +*                              ----------
 264.478 +*                              b[3] + ...
 264.479 +*
 264.480 +*  where:
 264.481 +*
 264.482 +*     a[k] = 1,                  k = 0, 1, 2, ...
 264.483 +*
 264.484 +*     b[k] = floor(x[k]),        k = 0, 1, 2, ...
 264.485 +*
 264.486 +*     x[0] = x,
 264.487 +*
 264.488 +*     x[k] = 1 / frac(x[k-1]),   k = 1, 2, 3, ...
 264.489 +*
 264.490 +*  To find the "best" rational approximation of x the routine computes
 264.491 +*  partial fractions f[k] by dropping after k terms as follows:
 264.492 +*
 264.493 +*     f[k] = A[k] / B[k],
 264.494 +*
 264.495 +*  where:
 264.496 +*
 264.497 +*     A[-1] = 1,   A[0] = b[0],   B[-1] = 0,   B[0] = 1,
 264.498 +*
 264.499 +*     A[k] = b[k] * A[k-1] + a[k] * A[k-2],
 264.500 +*
 264.501 +*     B[k] = b[k] * B[k-1] + a[k] * B[k-2].
 264.502 +*
 264.503 +*  Once the condition
 264.504 +*
 264.505 +*     |x - f[k]| <= eps
 264.506 +*
 264.507 +*  has been satisfied, the routine reports p = A[k] and q = B[k] as the
 264.508 +*  final answer.
 264.509 +*
 264.510 +*  In the table below here is some statistics obtained for one million
 264.511 +*  random numbers uniformly distributed in the range [0, 1).
 264.512 +*
 264.513 +*      eps      max p   mean p      max q    mean q  max k   mean k
 264.514 +*     -------------------------------------------------------------
 264.515 +*     1e-1          8      1.6          9       3.2    3      1.4
 264.516 +*     1e-2         98      6.2         99      12.4    5      2.4
 264.517 +*     1e-3        997     20.7        998      41.5    8      3.4
 264.518 +*     1e-4       9959     66.6       9960     133.5   10      4.4
 264.519 +*     1e-5      97403    211.7      97404     424.2   13      5.3
 264.520 +*     1e-6     479669    669.9     479670    1342.9   15      6.3
 264.521 +*     1e-7    1579030   2127.3    3962146    4257.8   16      7.3
 264.522 +*     1e-8   26188823   6749.4   26188824   13503.4   19      8.2
 264.523 +*
 264.524 +*  REFERENCES
 264.525 +*
 264.526 +*  W. B. Jones and W. J. Thron, "Continued Fractions: Analytic Theory
 264.527 +*  and Applications," Encyclopedia on Mathematics and Its Applications,
 264.528 +*  Addison-Wesley, 1980. */
 264.529 +
 264.530 +int fp2rat(double x, double eps, double *p, double *q)
 264.531 +{     int k;
 264.532 +      double xk, Akm1, Ak, Bkm1, Bk, ak, bk, fk, temp;
 264.533 +      if (!(0.0 <= x && x < 1.0))
 264.534 +         xerror("fp2rat: x = %g; number out of range\n", x);
 264.535 +      for (k = 0; ; k++)
 264.536 +      {  xassert(k <= 100);
 264.537 +         if (k == 0)
 264.538 +         {  /* x[0] = x */
 264.539 +            xk = x;
 264.540 +            /* A[-1] = 1 */
 264.541 +            Akm1 = 1.0;
 264.542 +            /* A[0] = b[0] = floor(x[0]) = 0 */
 264.543 +            Ak = 0.0;
 264.544 +            /* B[-1] = 0 */
 264.545 +            Bkm1 = 0.0;
 264.546 +            /* B[0] = 1 */
 264.547 +            Bk = 1.0;
 264.548 +         }
 264.549 +         else
 264.550 +         {  /* x[k] = 1 / frac(x[k-1]) */
 264.551 +            temp = xk - floor(xk);
 264.552 +            xassert(temp != 0.0);
 264.553 +            xk = 1.0 / temp;
 264.554 +            /* a[k] = 1 */
 264.555 +            ak = 1.0;
 264.556 +            /* b[k] = floor(x[k]) */
 264.557 +            bk = floor(xk);
 264.558 +            /* A[k] = b[k] * A[k-1] + a[k] * A[k-2] */
 264.559 +            temp = bk * Ak + ak * Akm1;
 264.560 +            Akm1 = Ak, Ak = temp;
 264.561 +            /* B[k] = b[k] * B[k-1] + a[k] * B[k-2] */
 264.562 +            temp = bk * Bk + ak * Bkm1;
 264.563 +            Bkm1 = Bk, Bk = temp;
 264.564 +         }
 264.565 +         /* f[k] = A[k] / B[k] */
 264.566 +         fk = Ak / Bk;
 264.567 +#if 0
 264.568 +         print("%.*g / %.*g = %.*g", DBL_DIG, Ak, DBL_DIG, Bk, DBL_DIG,
 264.569 +            fk);
 264.570 +#endif
 264.571 +         if (fabs(x - fk) <= eps) break;
 264.572 +      }
 264.573 +      *p = Ak;
 264.574 +      *q = Bk;
 264.575 +      return k;
 264.576 +}
 264.577 +
 264.578 +/***********************************************************************
 264.579 +*  NAME
 264.580 +*
 264.581 +*  jday - convert calendar date to Julian day number
 264.582 +*
 264.583 +*  SYNOPSIS
 264.584 +*
 264.585 +*  #include "glplib.h"
 264.586 +*  int jday(int d, int m, int y);
 264.587 +*
 264.588 +*  DESCRIPTION
 264.589 +*
 264.590 +*  The routine jday converts a calendar date, Gregorian calendar, to
 264.591 +*  corresponding Julian day number j.
 264.592 +*
 264.593 +*  From the given day d, month m, and year y, the Julian day number j
 264.594 +*  is computed without using tables.
 264.595 +*
 264.596 +*  The routine is valid for 1 <= y <= 4000.
 264.597 +*
 264.598 +*  RETURNS
 264.599 +*
 264.600 +*  The routine jday returns the Julian day number, or negative value if
 264.601 +*  the specified date is incorrect.
 264.602 +*
 264.603 +*  REFERENCES
 264.604 +*
 264.605 +*  R. G. Tantzen, Algorithm 199: conversions between calendar date and
 264.606 +*  Julian day number, Communications of the ACM, vol. 6, no. 8, p. 444,
 264.607 +*  Aug. 1963. */
 264.608 +
 264.609 +int jday(int d, int m, int y)
 264.610 +{     int c, ya, j, dd;
 264.611 +      if (!(1 <= d && d <= 31 && 1 <= m && m <= 12 && 1 <= y &&
 264.612 +            y <= 4000))
 264.613 +      {  j = -1;
 264.614 +         goto done;
 264.615 +      }
 264.616 +      if (m >= 3) m -= 3; else m += 9, y--;
 264.617 +      c = y / 100;
 264.618 +      ya = y - 100 * c;
 264.619 +      j = (146097 * c) / 4 + (1461 * ya) / 4 + (153 * m + 2) / 5 + d +
 264.620 +         1721119;
 264.621 +      jdate(j, &dd, NULL, NULL);
 264.622 +      if (d != dd) j = -1;
 264.623 +done: return j;
 264.624 +}
 264.625 +
 264.626 +/***********************************************************************
 264.627 +*  NAME
 264.628 +*
 264.629 +*  jdate - convert Julian day number to calendar date
 264.630 +*
 264.631 +*  SYNOPSIS
 264.632 +*
 264.633 +*  #include "glplib.h"
 264.634 +*  void jdate(int j, int *d, int *m, int *y);
 264.635 +*
 264.636 +*  DESCRIPTION
 264.637 +*
 264.638 +*  The routine jdate converts a Julian day number j to corresponding
 264.639 +*  calendar date, Gregorian calendar.
 264.640 +*
 264.641 +*  The day d, month m, and year y are computed without using tables and
 264.642 +*  stored in corresponding locations.
 264.643 +*
 264.644 +*  The routine is valid for 1721426 <= j <= 3182395.
 264.645 +*
 264.646 +*  RETURNS
 264.647 +*
 264.648 +*  If the conversion is successful, the routine returns zero, otherwise
 264.649 +*  non-zero.
 264.650 +*
 264.651 +*  REFERENCES
 264.652 +*
 264.653 +*  R. G. Tantzen, Algorithm 199: conversions between calendar date and
 264.654 +*  Julian day number, Communications of the ACM, vol. 6, no. 8, p. 444,
 264.655 +*  Aug. 1963. */
 264.656 +
 264.657 +int jdate(int j, int *_d, int *_m, int *_y)
 264.658 +{     int d, m, y, ret = 0;
 264.659 +      if (!(1721426 <= j && j <= 3182395))
 264.660 +      {  ret = 1;
 264.661 +         goto done;
 264.662 +      }
 264.663 +      j -= 1721119;
 264.664 +      y = (4 * j - 1) / 146097;
 264.665 +      j = (4 * j - 1) % 146097;
 264.666 +      d = j / 4;
 264.667 +      j = (4 * d + 3) / 1461;
 264.668 +      d = (4 * d + 3) % 1461;
 264.669 +      d = (d + 4) / 4;
 264.670 +      m = (5 * d - 3) / 153;
 264.671 +      d = (5 * d - 3) % 153;
 264.672 +      d = (d + 5) / 5;
 264.673 +      y = 100 * y + j;
 264.674 +      if (m <= 9) m += 3; else m -= 9, y++;
 264.675 +      if (_d != NULL) *_d = d;
 264.676 +      if (_m != NULL) *_m = m;
 264.677 +      if (_y != NULL) *_y = y;
 264.678 +done: return ret;
 264.679 +}
 264.680 +
 264.681 +#if 0
 264.682 +int main(void)
 264.683 +{     int jbeg, jend, j, d, m, y;
 264.684 +      jbeg = jday(1, 1, 1);
 264.685 +      jend = jday(31, 12, 4000);
 264.686 +      for (j = jbeg; j <= jend; j++)
 264.687 +      {  xassert(jdate(j, &d, &m, &y) == 0);
 264.688 +         xassert(jday(d, m, y) == j);
 264.689 +      }
 264.690 +      xprintf("Routines jday and jdate work correctly.\n");
 264.691 +      return 0;
 264.692 +}
 264.693 +#endif
 264.694 +
 264.695 +/* eof */
   265.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
   265.2 +++ b/deps/glpk/src/glplpf.c	Sun Nov 06 20:59:10 2011 +0100
   265.3 @@ -0,0 +1,978 @@
   265.4 +/* glplpf.c (LP basis factorization, Schur complement version) */
   265.5 +
   265.6 +/***********************************************************************
   265.7 +*  This code is part of GLPK (GNU Linear Programming Kit).
   265.8 +*
   265.9 +*  Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008,
  265.10 +*  2009, 2010, 2011 Andrew Makhorin, Department for Applied Informatics,
  265.11 +*  Moscow Aviation Institute, Moscow, Russia. All rights reserved.
  265.12 +*  E-mail: <mao@gnu.org>.
  265.13 +*
  265.14 +*  GLPK is free software: you can redistribute it and/or modify it
  265.15 +*  under the terms of the GNU General Public License as published by
  265.16 +*  the Free Software Foundation, either version 3 of the License, or
  265.17 +*  (at your option) any later version.
  265.18 +*
  265.19 +*  GLPK is distributed in the hope that it will be useful, but WITHOUT
  265.20 +*  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
  265.21 +*  or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
  265.22 +*  License for more details.
  265.23 +*
  265.24 +*  You should have received a copy of the GNU General Public License
  265.25 +*  along with GLPK. If not, see <http://www.gnu.org/licenses/>.
  265.26 +***********************************************************************/
  265.27 +
  265.28 +#include "glplpf.h"
  265.29 +#include "glpenv.h"
  265.30 +#define xfault xerror
  265.31 +
  265.32 +#define _GLPLPF_DEBUG 0
  265.33 +
  265.34 +/* CAUTION: DO NOT CHANGE THE LIMIT BELOW */
  265.35 +
  265.36 +#define M_MAX 100000000 /* = 100*10^6 */
  265.37 +/* maximal order of the basis matrix */
  265.38 +
  265.39 +/***********************************************************************
  265.40 +*  NAME
  265.41 +*
  265.42 +*  lpf_create_it - create LP basis factorization
  265.43 +*
  265.44 +*  SYNOPSIS
  265.45 +*
  265.46 +*  #include "glplpf.h"
  265.47 +*  LPF *lpf_create_it(void);
  265.48 +*
  265.49 +*  DESCRIPTION
  265.50 +*
  265.51 +*  The routine lpf_create_it creates a program object, which represents
  265.52 +*  a factorization of LP basis.
  265.53 +*
  265.54 +*  RETURNS
  265.55 +*
  265.56 +*  The routine lpf_create_it returns a pointer to the object created. */
  265.57 +
  265.58 +LPF *lpf_create_it(void)
  265.59 +{     LPF *lpf;
  265.60 +#if _GLPLPF_DEBUG
  265.61 +      xprintf("lpf_create_it: warning: debug mode enabled\n");
  265.62 +#endif
  265.63 +      lpf = xmalloc(sizeof(LPF));
  265.64 +      lpf->valid = 0;
  265.65 +      lpf->m0_max = lpf->m0 = 0;
  265.66 +      lpf->luf = luf_create_it();
  265.67 +      lpf->m = 0;
  265.68 +      lpf->B = NULL;
  265.69 +      lpf->n_max = 50;
  265.70 +      lpf->n = 0;
  265.71 +      lpf->R_ptr = lpf->R_len = NULL;
  265.72 +      lpf->S_ptr = lpf->S_len = NULL;
  265.73 +      lpf->scf = NULL;
  265.74 +      lpf->P_row = lpf->P_col = NULL;
  265.75 +      lpf->Q_row = lpf->Q_col = NULL;
  265.76 +      lpf->v_size = 1000;
  265.77 +      lpf->v_ptr = 0;
  265.78 +      lpf->v_ind = NULL;
  265.79 +      lpf->v_val = NULL;
  265.80 +      lpf->work1 = lpf->work2 = NULL;
  265.81 +      return lpf;
  265.82 +}
  265.83 +
  265.84 +/***********************************************************************
  265.85 +*  NAME
  265.86 +*
  265.87 +*  lpf_factorize - compute LP basis factorization
  265.88 +*
  265.89 +*  SYNOPSIS
  265.90 +*
  265.91 +*  #include "glplpf.h"
  265.92 +*  int lpf_factorize(LPF *lpf, int m, const int bh[], int (*col)
  265.93 +*     (void *info, int j, int ind[], double val[]), void *info);
  265.94 +*
  265.95 +*  DESCRIPTION
  265.96 +*
  265.97 +*  The routine lpf_factorize computes the factorization of the basis
  265.98 +*  matrix B specified by the routine col.
  265.99 +*
 265.100 +*  The parameter lpf specified the basis factorization data structure
 265.101 +*  created with the routine lpf_create_it.
 265.102 +*
 265.103 +*  The parameter m specifies the order of B, m > 0.
 265.104 +*
 265.105 +*  The array bh specifies the basis header: bh[j], 1 <= j <= m, is the
 265.106 +*  number of j-th column of B in some original matrix. The array bh is
 265.107 +*  optional and can be specified as NULL.
 265.108 +*
 265.109 +*  The formal routine col specifies the matrix B to be factorized. To
 265.110 +*  obtain j-th column of A the routine lpf_factorize calls the routine
 265.111 +*  col with the parameter j (1 <= j <= n). In response the routine col
 265.112 +*  should store row indices and numerical values of non-zero elements
 265.113 +*  of j-th column of B to locations ind[1,...,len] and val[1,...,len],
 265.114 +*  respectively, where len is the number of non-zeros in j-th column
 265.115 +*  returned on exit. Neither zero nor duplicate elements are allowed.
 265.116 +*
 265.117 +*  The parameter info is a transit pointer passed to the routine col.
 265.118 +*
 265.119 +*  RETURNS
 265.120 +*
 265.121 +*  0  The factorization has been successfully computed.
 265.122 +*
 265.123 +*  LPF_ESING
 265.124 +*     The specified matrix is singular within the working precision.
 265.125 +*
 265.126 +*  LPF_ECOND
 265.127 +*     The specified matrix is ill-conditioned.
 265.128 +*
 265.129 +*  For more details see comments to the routine luf_factorize. */
 265.130 +
 265.131 +int lpf_factorize(LPF *lpf, int m, const int bh[], int (*col)
 265.132 +      (void *info, int j, int ind[], double val[]), void *info)
 265.133 +{     int k, ret;
 265.134 +#if _GLPLPF_DEBUG
 265.135 +      int i, j, len, *ind;
 265.136 +      double *B, *val;
 265.137 +#endif
 265.138 +      xassert(bh == bh);
 265.139 +      if (m < 1)
 265.140 +         xfault("lpf_factorize: m = %d; invalid parameter\n", m);
 265.141 +      if (m > M_MAX)
 265.142 +         xfault("lpf_factorize: m = %d; matrix too big\n", m);
 265.143 +      lpf->m0 = lpf->m = m;
 265.144 +      /* invalidate the factorization */
 265.145 +      lpf->valid = 0;
 265.146 +      /* allocate/reallocate arrays, if necessary */
 265.147 +      if (lpf->R_ptr == NULL)
 265.148 +         lpf->R_ptr = xcalloc(1+lpf->n_max, sizeof(int));
 265.149 +      if (lpf->R_len == NULL)
 265.150 +         lpf->R_len = xcalloc(1+lpf->n_max, sizeof(int));
 265.151 +      if (lpf->S_ptr == NULL)
 265.152 +         lpf->S_ptr = xcalloc(1+lpf->n_max, sizeof(int));
 265.153 +      if (lpf->S_len == NULL)
 265.154 +         lpf->S_len = xcalloc(1+lpf->n_max, sizeof(int));
 265.155 +      if (lpf->scf == NULL)
 265.156 +         lpf->scf = scf_create_it(lpf->n_max);
 265.157 +      if (lpf->v_ind == NULL)
 265.158 +         lpf->v_ind = xcalloc(1+lpf->v_size, sizeof(int));
 265.159 +      if (lpf->v_val == NULL)
 265.160 +         lpf->v_val = xcalloc(1+lpf->v_size, sizeof(double));
 265.161 +      if (lpf->m0_max < m)
 265.162 +      {  if (lpf->P_row != NULL) xfree(lpf->P_row);
 265.163 +         if (lpf->P_col != NULL) xfree(lpf->P_col);
 265.164 +         if (lpf->Q_row != NULL) xfree(lpf->Q_row);
 265.165 +         if (lpf->Q_col != NULL) xfree(lpf->Q_col);
 265.166 +         if (lpf->work1 != NULL) xfree(lpf->work1);
 265.167 +         if (lpf->work2 != NULL) xfree(lpf->work2);
 265.168 +         lpf->m0_max = m + 100;
 265.169 +         lpf->P_row = xcalloc(1+lpf->m0_max+lpf->n_max, sizeof(int));
 265.170 +         lpf->P_col = xcalloc(1+lpf->m0_max+lpf->n_max, sizeof(int));
 265.171 +         lpf->Q_row = xcalloc(1+lpf->m0_max+lpf->n_max, sizeof(int));
 265.172 +         lpf->Q_col = xcalloc(1+lpf->m0_max+lpf->n_max, sizeof(int));
 265.173 +         lpf->work1 = xcalloc(1+lpf->m0_max+lpf->n_max, sizeof(double));
 265.174 +         lpf->work2 = xcalloc(1+lpf->m0_max+lpf->n_max, sizeof(double));
 265.175 +      }
 265.176 +      /* try to factorize the basis matrix */
 265.177 +      switch (luf_factorize(lpf->luf, m, col, info))
 265.178 +      {  case 0:
 265.179 +            break;
 265.180 +         case LUF_ESING:
 265.181 +            ret = LPF_ESING;
 265.182 +            goto done;
 265.183 +         case LUF_ECOND:
 265.184 +            ret = LPF_ECOND;
 265.185 +            goto done;
 265.186 +         default:
 265.187 +            xassert(lpf != lpf);
 265.188 +      }
 265.189 +      /* the basis matrix has been successfully factorized */
 265.190 +      lpf->valid = 1;
 265.191 +#if _GLPLPF_DEBUG
 265.192 +      /* store the basis matrix for debugging */
 265.193 +      if (lpf->B != NULL) xfree(lpf->B);
 265.194 +      xassert(m <= 32767);
 265.195 +      lpf->B = B = xcalloc(1+m*m, sizeof(double));
 265.196 +      ind = xcalloc(1+m, sizeof(int));
 265.197 +      val = xcalloc(1+m, sizeof(double));
 265.198 +      for (k = 1; k <= m * m; k++)
 265.199 +         B[k] = 0.0;
 265.200 +      for (j = 1; j <= m; j++)
 265.201 +      {  len = col(info, j, ind, val);
 265.202 +         xassert(0 <= len && len <= m);
 265.203 +         for (k = 1; k <= len; k++)
 265.204 +         {  i = ind[k];
 265.205 +            xassert(1 <= i && i <= m);
 265.206 +            xassert(B[(i - 1) * m + j] == 0.0);
 265.207 +            xassert(val[k] != 0.0);
 265.208 +            B[(i - 1) * m + j] = val[k];
 265.209 +         }
 265.210 +      }
 265.211 +      xfree(ind);
 265.212 +      xfree(val);
 265.213 +#endif
 265.214 +      /* B = B0, so there are no additional rows/columns */
 265.215 +      lpf->n = 0;
 265.216 +      /* reset the Schur complement factorization */
 265.217 +      scf_reset_it(lpf->scf);
 265.218 +      /* P := Q := I */
 265.219 +      for (k = 1; k <= m; k++)
 265.220 +      {  lpf->P_row[k] = lpf->P_col[k] = k;
 265.221 +         lpf->Q_row[k] = lpf->Q_col[k] = k;
 265.222 +      }
 265.223 +      /* make all SVA locations free */
 265.224 +      lpf->v_ptr = 1;
 265.225 +      ret = 0;
 265.226 +done: /* return to the calling program */
 265.227 +      return ret;
 265.228 +}
 265.229 +
 265.230 +/***********************************************************************
 265.231 +*  The routine r_prod computes the product y := y + alpha * R * x,
 265.232 +*  where x is a n-vector, alpha is a scalar, y is a m0-vector.
 265.233 +*
 265.234 +*  Since matrix R is available by columns, the product is computed as
 265.235 +*  a linear combination:
 265.236 +*
 265.237 +*     y := y + alpha * (R[1] * x[1] + ... + R[n] * x[n]),
 265.238 +*
 265.239 +*  where R[j] is j-th column of R. */
 265.240 +
 265.241 +static void r_prod(LPF *lpf, double y[], double a, const double x[])
 265.242 +{     int n = lpf->n;
 265.243 +      int *R_ptr = lpf->R_ptr;
 265.244 +      int *R_len = lpf->R_len;
 265.245 +      int *v_ind = lpf->v_ind;
 265.246 +      double *v_val = lpf->v_val;
 265.247 +      int j, beg, end, ptr;
 265.248 +      double t;
 265.249 +      for (j = 1; j <= n; j++)
 265.250 +      {  if (x[j] == 0.0) continue;
 265.251 +         /* y := y + alpha * R[j] * x[j] */
 265.252 +         t = a * x[j];
 265.253 +         beg = R_ptr[j];
 265.254 +         end = beg + R_len[j];
 265.255 +         for (ptr = beg; ptr < end; ptr++)
 265.256 +            y[v_ind[ptr]] += t * v_val[ptr];
 265.257 +      }
 265.258 +      return;
 265.259 +}
 265.260 +
 265.261 +/***********************************************************************
 265.262 +*  The routine rt_prod computes the product y := y + alpha * R' * x,
 265.263 +*  where R' is a matrix transposed to R, x is a m0-vector, alpha is a
 265.264 +*  scalar, y is a n-vector.
 265.265 +*
 265.266 +*  Since matrix R is available by columns, the product components are
 265.267 +*  computed as inner products:
 265.268 +*
 265.269 +*     y[j] := y[j] + alpha * (j-th column of R) * x
 265.270 +*
 265.271 +*  for j = 1, 2, ..., n. */
 265.272 +
 265.273 +static void rt_prod(LPF *lpf, double y[], double a, const double x[])
 265.274 +{     int n = lpf->n;
 265.275 +      int *R_ptr = lpf->R_ptr;
 265.276 +      int *R_len = lpf->R_len;
 265.277 +      int *v_ind = lpf->v_ind;
 265.278 +      double *v_val = lpf->v_val;
 265.279 +      int j, beg, end, ptr;
 265.280 +      double t;
 265.281 +      for (j = 1; j <= n; j++)
 265.282 +      {  /* t := (j-th column of R) * x */
 265.283 +         t = 0.0;
 265.284 +         beg = R_ptr[j];
 265.285 +         end = beg + R_len[j];
 265.286 +         for (ptr = beg; ptr < end; ptr++)
 265.287 +            t += v_val[ptr] * x[v_ind[ptr]];
 265.288 +         /* y[j] := y[j] + alpha * t */
 265.289 +         y[j] += a * t;
 265.290 +      }
 265.291 +      return;
 265.292 +}
 265.293 +
 265.294 +/***********************************************************************
 265.295 +*  The routine s_prod computes the product y := y + alpha * S * x,
 265.296 +*  where x is a m0-vector, alpha is a scalar, y is a n-vector.
 265.297 +*
 265.298 +*  Since matrix S is available by rows, the product components are
 265.299 +*  computed as inner products:
 265.300 +*
 265.301 +*     y[i] = y[i] + alpha * (i-th row of S) * x
 265.302 +*
 265.303 +*  for i = 1, 2, ..., n. */
 265.304 +
 265.305 +static void s_prod(LPF *lpf, double y[], double a, const double x[])
 265.306 +{     int n = lpf->n;
 265.307 +      int *S_ptr = lpf->S_ptr;
 265.308 +      int *S_len = lpf->S_len;
 265.309 +      int *v_ind = lpf->v_ind;
 265.310 +      double *v_val = lpf->v_val;
 265.311 +      int i, beg, end, ptr;
 265.312 +      double t;
 265.313 +      for (i = 1; i <= n; i++)
 265.314 +      {  /* t := (i-th row of S) * x */
 265.315 +         t = 0.0;
 265.316 +         beg = S_ptr[i];
 265.317 +         end = beg + S_len[i];
 265.318 +         for (ptr = beg; ptr < end; ptr++)
 265.319 +            t += v_val[ptr] * x[v_ind[ptr]];
 265.320 +         /* y[i] := y[i] + alpha * t */
 265.321 +         y[i] += a * t;
 265.322 +      }
 265.323 +      return;
 265.324 +}
 265.325 +
 265.326 +/***********************************************************************
 265.327 +*  The routine st_prod computes the product y := y + alpha * S' * x,
 265.328 +*  where S' is a matrix transposed to S, x is a n-vector, alpha is a
 265.329 +*  scalar, y is m0-vector.
 265.330 +*
 265.331 +*  Since matrix R is available by rows, the product is computed as a
 265.332 +*  linear combination:
 265.333 +*
 265.334 +*     y := y + alpha * (S'[1] * x[1] + ... + S'[n] * x[n]),
 265.335 +*
 265.336 +*  where S'[i] is i-th row of S. */
 265.337 +
 265.338 +static void st_prod(LPF *lpf, double y[], double a, const double x[])
 265.339 +{     int n = lpf->n;
 265.340 +      int *S_ptr = lpf->S_ptr;
 265.341 +      int *S_len = lpf->S_len;
 265.342 +      int *v_ind = lpf->v_ind;
 265.343 +      double *v_val = lpf->v_val;
 265.344 +      int i, beg, end, ptr;
 265.345 +      double t;
 265.346 +      for (i = 1; i <= n; i++)
 265.347 +      {  if (x[i] == 0.0) continue;
 265.348 +         /* y := y + alpha * S'[i] * x[i] */
 265.349 +         t = a * x[i];
 265.350 +         beg = S_ptr[i];
 265.351 +         end = beg + S_len[i];
 265.352 +         for (ptr = beg; ptr < end; ptr++)
 265.353 +            y[v_ind[ptr]] += t * v_val[ptr];
 265.354 +      }
 265.355 +      return;
 265.356 +}
 265.357 +
 265.358 +#if _GLPLPF_DEBUG
 265.359 +/***********************************************************************
 265.360 +*  The routine check_error computes the maximal relative error between
 265.361 +*  left- and right-hand sides for the system B * x = b (if tr is zero)
 265.362 +*  or B' * x = b (if tr is non-zero), where B' is a matrix transposed
 265.363 +*  to B. (This routine is intended for debugging only.) */
 265.364 +
 265.365 +static void check_error(LPF *lpf, int tr, const double x[],
 265.366 +      const double b[])
 265.367 +{     int m = lpf->m;
 265.368 +      double *B = lpf->B;
 265.369 +      int i, j;
 265.370 +      double  d, dmax = 0.0, s, t, tmax;
 265.371 +      for (i = 1; i <= m; i++)
 265.372 +      {  s = 0.0;
 265.373 +         tmax = 1.0;
 265.374 +         for (j = 1; j <= m; j++)
 265.375 +         {  if (!tr)
 265.376 +               t = B[m * (i - 1) + j] * x[j];
 265.377 +            else
 265.378 +               t = B[m * (j - 1) + i] * x[j];
 265.379 +            if (tmax < fabs(t)) tmax = fabs(t);
 265.380 +            s += t;
 265.381 +         }
 265.382 +         d = fabs(s - b[i]) / tmax;
 265.383 +         if (dmax < d) dmax = d;
 265.384 +      }
 265.385 +      if (dmax > 1e-8)
 265.386 +         xprintf("%s: dmax = %g; relative error too large\n",
 265.387 +            !tr ? "lpf_ftran" : "lpf_btran", dmax);
 265.388 +      return;
 265.389 +}
 265.390 +#endif
 265.391 +
 265.392 +/***********************************************************************
 265.393 +*  NAME
 265.394 +*
 265.395 +*  lpf_ftran - perform forward transformation (solve system B*x = b)
 265.396 +*
 265.397 +*  SYNOPSIS
 265.398 +*
 265.399 +*  #include "glplpf.h"
 265.400 +*  void lpf_ftran(LPF *lpf, double x[]);
 265.401 +*
 265.402 +*  DESCRIPTION
 265.403 +*
 265.404 +*  The routine lpf_ftran performs forward transformation, i.e. solves
 265.405 +*  the system B*x = b, where B is the basis matrix, x is the vector of
 265.406 +*  unknowns to be computed, b is the vector of right-hand sides.
 265.407 +*
 265.408 +*  On entry elements of the vector b should be stored in dense format
 265.409 +*  in locations x[1], ..., x[m], where m is the number of rows. On exit
 265.410 +*  the routine stores elements of the vector x in the same locations.
 265.411 +*
 265.412 +*  BACKGROUND
 265.413 +*
 265.414 +*  Solution of the system B * x = b can be obtained by solving the
 265.415 +*  following augmented system:
 265.416 +*
 265.417 +*     ( B  F^) ( x )   ( b )
 265.418 +*     (      ) (   ) = (   )
 265.419 +*     ( G^ H^) ( y )   ( 0 )
 265.420 +*
 265.421 +*  which, using the main equality, can be written as follows:
 265.422 +*
 265.423 +*       ( L0 0 ) ( U0 R )   ( x )   ( b )
 265.424 +*     P (      ) (      ) Q (   ) = (   )
 265.425 +*       ( S  I ) ( 0  C )   ( y )   ( 0 )
 265.426 +*
 265.427 +*  therefore,
 265.428 +*
 265.429 +*     ( x )      ( U0 R )-1 ( L0 0 )-1    ( b )
 265.430 +*     (   ) = Q' (      )   (      )   P' (   )
 265.431 +*     ( y )      ( 0  C )   ( S  I )      ( 0 )
 265.432 +*
 265.433 +*  Thus, computing the solution includes the following steps:
 265.434 +*
 265.435 +*  1. Compute
 265.436 +*
 265.437 +*     ( f )      ( b )
 265.438 +*     (   ) = P' (   )
 265.439 +*     ( g )      ( 0 )
 265.440 +*
 265.441 +*  2. Solve the system
 265.442 +*
 265.443 +*     ( f1 )   ( L0 0 )-1 ( f )      ( L0 0 ) ( f1 )   ( f )
 265.444 +*     (    ) = (      )   (   )  =>  (      ) (    ) = (   )
 265.445 +*     ( g1 )   ( S  I )   ( g )      ( S  I ) ( g1 )   ( g )
 265.446 +*
 265.447 +*     from which it follows that:
 265.448 +*
 265.449 +*     { L0 * f1      = f      f1 = inv(L0) * f
 265.450 +*     {                   =>
 265.451 +*     {  S * f1 + g1 = g      g1 = g - S * f1
 265.452 +*
 265.453 +*  3. Solve the system
 265.454 +*
 265.455 +*     ( f2 )   ( U0 R )-1 ( f1 )      ( U0 R ) ( f2 )   ( f1 )
 265.456 +*     (    ) = (      )   (    )  =>  (      ) (    ) = (    )
 265.457 +*     ( g2 )   ( 0  C )   ( g1 )      ( 0  C ) ( g2 )   ( g1 )
 265.458 +*
 265.459 +*     from which it follows that:
 265.460 +*
 265.461 +*     { U0 * f2 + R * g2 = f1      f2 = inv(U0) * (f1 - R * g2)
 265.462 +*     {                        =>
 265.463 +*     {           C * g2 = g1      g2 = inv(C) * g1
 265.464 +*
 265.465 +*  4. Compute
 265.466 +*
 265.467 +*     ( x )      ( f2 )
 265.468 +*     (   ) = Q' (    )
 265.469 +*     ( y )      ( g2 )                                               */
 265.470 +
 265.471 +void lpf_ftran(LPF *lpf, double x[])
 265.472 +{     int m0 = lpf->m0;
 265.473 +      int m = lpf->m;
 265.474 +      int n  = lpf->n;
 265.475 +      int *P_col = lpf->P_col;
 265.476 +      int *Q_col = lpf->Q_col;
 265.477 +      double *fg = lpf->work1;
 265.478 +      double *f = fg;
 265.479 +      double *g = fg + m0;
 265.480 +      int i, ii;
 265.481 +#if _GLPLPF_DEBUG
 265.482 +      double *b;
 265.483 +#endif
 265.484 +      if (!lpf->valid)
 265.485 +         xfault("lpf_ftran: the factorization is not valid\n");
 265.486 +      xassert(0 <= m && m <= m0 + n);
 265.487 +#if _GLPLPF_DEBUG
 265.488 +      /* save the right-hand side vector */
 265.489 +      b = xcalloc(1+m, sizeof(double));
 265.490 +      for (i = 1; i <= m; i++) b[i] = x[i];
 265.491 +#endif
 265.492 +      /* (f g) := inv(P) * (b 0) */
 265.493 +      for (i = 1; i <= m0 + n; i++)
 265.494 +         fg[i] = ((ii = P_col[i]) <= m ? x[ii] : 0.0);
 265.495 +      /* f1 := inv(L0) * f */
 265.496 +      luf_f_solve(lpf->luf, 0, f);
 265.497 +      /* g1 := g - S * f1 */
 265.498 +      s_prod(lpf, g, -1.0, f);
 265.499 +      /* g2 := inv(C) * g1 */
 265.500 +      scf_solve_it(lpf->scf, 0, g);
 265.501 +      /* f2 := inv(U0) * (f1 - R * g2) */
 265.502 +      r_prod(lpf, f, -1.0, g);
 265.503 +      luf_v_solve(lpf->luf, 0, f);
 265.504 +      /* (x y) := inv(Q) * (f2 g2) */
 265.505 +      for (i = 1; i <= m; i++)
 265.506 +         x[i] = fg[Q_col[i]];
 265.507 +#if _GLPLPF_DEBUG
 265.508 +      /* check relative error in solution */
 265.509 +      check_error(lpf, 0, x, b);
 265.510 +      xfree(b);
 265.511 +#endif
 265.512 +      return;
 265.513 +}
 265.514 +
 265.515 +/***********************************************************************
 265.516 +*  NAME
 265.517 +*
 265.518 +*  lpf_btran - perform backward transformation (solve system B'*x = b)
 265.519 +*
 265.520 +*  SYNOPSIS
 265.521 +*
 265.522 +*  #include "glplpf.h"
 265.523 +*  void lpf_btran(LPF *lpf, double x[]);
 265.524 +*
 265.525 +*  DESCRIPTION
 265.526 +*
 265.527 +*  The routine lpf_btran performs backward transformation, i.e. solves
 265.528 +*  the system B'*x = b, where B' is a matrix transposed to the basis
 265.529 +*  matrix B, x is the vector of unknowns to be computed, b is the vector
 265.530 +*  of right-hand sides.
 265.531 +*
 265.532 +*  On entry elements of the vector b should be stored in dense format
 265.533 +*  in locations x[1], ..., x[m], where m is the number of rows. On exit
 265.534 +*  the routine stores elements of the vector x in the same locations.
 265.535 +*
 265.536 +*  BACKGROUND
 265.537 +*
 265.538 +*  Solution of the system B' * x = b, where B' is a matrix transposed
 265.539 +*  to B, can be obtained by solving the following augmented system:
 265.540 +*
 265.541 +*     ( B  F^)T ( x )   ( b )
 265.542 +*     (      )  (   ) = (   )
 265.543 +*     ( G^ H^)  ( y )   ( 0 )
 265.544 +*
 265.545 +*  which, using the main equality, can be written as follows:
 265.546 +*
 265.547 +*      T ( U0 R )T ( L0 0 )T  T ( x )   ( b )
 265.548 +*     Q  (      )  (      )  P  (   ) = (   )
 265.549 +*        ( 0  C )  ( S  I )     ( y )   ( 0 )
 265.550 +*
 265.551 +*  or, equivalently, as follows:
 265.552 +*
 265.553 +*        ( U'0 0 ) ( L'0 S')    ( x )   ( b )
 265.554 +*     Q' (       ) (       ) P' (   ) = (   )
 265.555 +*        ( R'  C') ( 0   I )    ( y )   ( 0 )
 265.556 +*
 265.557 +*  therefore,
 265.558 +*
 265.559 +*     ( x )     ( L'0 S')-1 ( U'0 0 )-1   ( b )
 265.560 +*     (   ) = P (       )   (       )   Q (   )
 265.561 +*     ( y )     ( 0   I )   ( R'  C')     ( 0 )
 265.562 +*
 265.563 +*  Thus, computing the solution includes the following steps:
 265.564 +*
 265.565 +*  1. Compute
 265.566 +*
 265.567 +*     ( f )     ( b )
 265.568 +*     (   ) = Q (   )
 265.569 +*     ( g )     ( 0 )
 265.570 +*
 265.571 +*  2. Solve the system
 265.572 +*
 265.573 +*     ( f1 )   ( U'0 0 )-1 ( f )      ( U'0 0 ) ( f1 )   ( f )
 265.574 +*     (    ) = (       )   (   )  =>  (       ) (    ) = (   )
 265.575 +*     ( g1 )   ( R'  C')   ( g )      ( R'  C') ( g1 )   ( g )
 265.576 +*
 265.577 +*     from which it follows that:
 265.578 +*
 265.579 +*     { U'0 * f1           = f      f1 = inv(U'0) * f
 265.580 +*     {                         =>
 265.581 +*     { R'  * f1 + C' * g1 = g      g1 = inv(C') * (g - R' * f1)
 265.582 +*
 265.583 +*  3. Solve the system
 265.584 +*
 265.585 +*     ( f2 )   ( L'0 S')-1 ( f1 )      ( L'0 S') ( f2 )   ( f1 )
 265.586 +*     (    ) = (       )   (    )  =>  (       ) (    ) = (    )
 265.587 +*     ( g2 )   ( 0   I )   ( g1 )      ( 0   I ) ( g2 )   ( g1 )
 265.588 +*
 265.589 +*     from which it follows that:
 265.590 +*
 265.591 +*     { L'0 * f2 + S' * g2 = f1
 265.592 +*     {                          =>  f2 = inv(L'0) * ( f1 - S' * g2)
 265.593 +*     {                 g2 = g1
 265.594 +*
 265.595 +*  4. Compute
 265.596 +*
 265.597 +*     ( x )     ( f2 )
 265.598 +*     (   ) = P (    )
 265.599 +*     ( y )     ( g2 )                                                */
 265.600 +
 265.601 +void lpf_btran(LPF *lpf, double x[])
 265.602 +{     int m0 = lpf->m0;
 265.603 +      int m = lpf->m;
 265.604 +      int n = lpf->n;
 265.605 +      int *P_row = lpf->P_row;
 265.606 +      int *Q_row = lpf->Q_row;
 265.607 +      double *fg = lpf->work1;
 265.608 +      double *f = fg;
 265.609 +      double *g = fg + m0;
 265.610 +      int i, ii;
 265.611 +#if _GLPLPF_DEBUG
 265.612 +      double *b;
 265.613 +#endif
 265.614 +      if (!lpf->valid)
 265.615 +         xfault("lpf_btran: the factorization is not valid\n");
 265.616 +      xassert(0 <= m && m <= m0 + n);
 265.617 +#if _GLPLPF_DEBUG
 265.618 +      /* save the right-hand side vector */
 265.619 +      b = xcalloc(1+m, sizeof(double));
 265.620 +      for (i = 1; i <= m; i++) b[i] = x[i];
 265.621 +#endif
 265.622 +      /* (f g) := Q * (b 0) */
 265.623 +      for (i = 1; i <= m0 + n; i++)
 265.624 +         fg[i] = ((ii = Q_row[i]) <= m ? x[ii] : 0.0);
 265.625 +      /* f1 := inv(U'0) * f */
 265.626 +      luf_v_solve(lpf->luf, 1, f);
 265.627 +      /* g1 := inv(C') * (g - R' * f1) */
 265.628 +      rt_prod(lpf, g, -1.0, f);
 265.629 +      scf_solve_it(lpf->scf, 1, g);
 265.630 +      /* g2 := g1 */
 265.631 +      g = g;
 265.632 +      /* f2 := inv(L'0) * (f1 - S' * g2) */
 265.633 +      st_prod(lpf, f, -1.0, g);
 265.634 +      luf_f_solve(lpf->luf, 1, f);
 265.635 +      /* (x y) := P * (f2 g2) */
 265.636 +      for (i = 1; i <= m; i++)
 265.637 +         x[i] = fg[P_row[i]];
 265.638 +#if _GLPLPF_DEBUG
 265.639 +      /* check relative error in solution */
 265.640 +      check_error(lpf, 1, x, b);
 265.641 +      xfree(b);
 265.642 +#endif
 265.643 +      return;
 265.644 +}
 265.645 +
 265.646 +/***********************************************************************
 265.647 +*  The routine enlarge_sva enlarges the Sparse Vector Area to new_size
 265.648 +*  locations by reallocating the arrays v_ind and v_val. */
 265.649 +
 265.650 +static void enlarge_sva(LPF *lpf, int new_size)
 265.651 +{     int v_size = lpf->v_size;
 265.652 +      int used = lpf->v_ptr - 1;
 265.653 +      int *v_ind = lpf->v_ind;
 265.654 +      double *v_val = lpf->v_val;
 265.655 +      xassert(v_size < new_size);
 265.656 +      while (v_size < new_size) v_size += v_size;
 265.657 +      lpf->v_size = v_size;
 265.658 +      lpf->v_ind = xcalloc(1+v_size, sizeof(int));
 265.659 +      lpf->v_val = xcalloc(1+v_size, sizeof(double));
 265.660 +      xassert(used >= 0);
 265.661 +      memcpy(&lpf->v_ind[1], &v_ind[1], used * sizeof(int));
 265.662 +      memcpy(&lpf->v_val[1], &v_val[1], used * sizeof(double));
 265.663 +      xfree(v_ind);
 265.664 +      xfree(v_val);
 265.665 +      return;
 265.666 +}
 265.667 +
 265.668 +/***********************************************************************
 265.669 +*  NAME
 265.670 +*
 265.671 +*  lpf_update_it - update LP basis factorization
 265.672 +*
 265.673 +*  SYNOPSIS
 265.674 +*
 265.675 +*  #include "glplpf.h"
 265.676 +*  int lpf_update_it(LPF *lpf, int j, int bh, int len, const int ind[],
 265.677 +*     const double val[]);
 265.678 +*
 265.679 +*  DESCRIPTION
 265.680 +*
 265.681 +*  The routine lpf_update_it updates the factorization of the basis
 265.682 +*  matrix B after replacing its j-th column by a new vector.
 265.683 +*
 265.684 +*  The parameter j specifies the number of column of B, which has been
 265.685 +*  replaced, 1 <= j <= m, where m is the order of B.
 265.686 +*
 265.687 +*  The parameter bh specifies the basis header entry for the new column
 265.688 +*  of B, which is the number of the new column in some original matrix.
 265.689 +*  This parameter is optional and can be specified as 0.
 265.690 +*
 265.691 +*  Row indices and numerical values of non-zero elements of the new
 265.692 +*  column of B should be placed in locations ind[1], ..., ind[len] and
 265.693 +*  val[1], ..., val[len], resp., where len is the number of non-zeros
 265.694 +*  in the column. Neither zero nor duplicate elements are allowed.
 265.695 +*
 265.696 +*  RETURNS
 265.697 +*
 265.698 +*  0  The factorization has been successfully updated.
 265.699 +*
 265.700 +*  LPF_ESING
 265.701 +*     New basis B is singular within the working precision.
 265.702 +*
 265.703 +*  LPF_ELIMIT
 265.704 +*     Maximal number of additional rows and columns has been reached.
 265.705 +*
 265.706 +*  BACKGROUND
 265.707 +*
 265.708 +*  Let j-th column of the current basis matrix B have to be replaced by
 265.709 +*  a new column a. This replacement is equivalent to removing the old
 265.710 +*  j-th column by fixing it at zero and introducing the new column as
 265.711 +*  follows:
 265.712 +*
 265.713 +*                   ( B   F^| a )
 265.714 +*     ( B  F^)      (       |   )
 265.715 +*     (      ) ---> ( G^  H^| 0 )
 265.716 +*     ( G^ H^)      (-------+---)
 265.717 +*                   ( e'j 0 | 0 )
 265.718 +*
 265.719 +*  where ej is a unit vector with 1 in j-th position which used to fix
 265.720 +*  the old j-th column of B (at zero). Then using the main equality we
 265.721 +*  have:
 265.722 +*
 265.723 +*     ( B   F^| a )            ( B0  F | f )
 265.724 +*     (       |   )   ( P  0 ) (       |   ) ( Q  0 )
 265.725 +*     ( G^  H^| 0 ) = (      ) ( G   H | g ) (      ) =
 265.726 +*     (-------+---)   ( 0  1 ) (-------+---) ( 0  1 )
 265.727 +*     ( e'j 0 | 0 )            ( v'  w'| 0 )
 265.728 +*
 265.729 +*       [   ( B0  F )|   ( f ) ]            [   ( B0 F )  |   ( f ) ]
 265.730 +*       [ P (       )| P (   ) ] ( Q  0 )   [ P (      ) Q| P (   ) ]
 265.731 +*     = [   ( G   H )|   ( g ) ] (      ) = [   ( G  H )  |   ( g ) ]
 265.732 +*       [------------+-------- ] ( 0  1 )   [-------------+---------]
 265.733 +*       [   ( v'  w')|     0   ]            [   ( v' w') Q|    0    ]
 265.734 +*
 265.735 +*  where:
 265.736 +*
 265.737 +*     ( a )     ( f )      ( f )        ( a )
 265.738 +*     (   ) = P (   )  =>  (   ) = P' * (   )
 265.739 +*     ( 0 )     ( g )      ( g )        ( 0 )
 265.740 +*
 265.741 +*                                 ( ej )      ( v )    ( v )     ( ej )
 265.742 +*     ( e'j  0 ) = ( v' w' ) Q => (    ) = Q' (   ) => (   ) = Q (    )
 265.743 +*                                 ( 0  )      ( w )    ( w )     ( 0  )
 265.744 +*
 265.745 +*  On the other hand:
 265.746 +*
 265.747 +*              ( B0| F  f )
 265.748 +*     ( P  0 ) (---+------) ( Q  0 )         ( B0    new F )
 265.749 +*     (      ) ( G | H  g ) (      ) = new P (             ) new Q
 265.750 +*     ( 0  1 ) (   |      ) ( 0  1 )         ( new G new H )
 265.751 +*              ( v'| w' 0 )
 265.752 +*
 265.753 +*  where:
 265.754 +*                               ( G )           ( H  g )
 265.755 +*     new F = ( F  f ), new G = (   ),  new H = (      ),
 265.756 +*                               ( v')           ( w' 0 )
 265.757 +*
 265.758 +*             ( P  0 )           ( Q  0 )
 265.759 +*     new P = (      ) , new Q = (      ) .
 265.760 +*             ( 0  1 )           ( 0  1 )
 265.761 +*
 265.762 +*  The factorization structure for the new augmented matrix remains the
 265.763 +*  same, therefore:
 265.764 +*
 265.765 +*           ( B0    new F )         ( L0     0 ) ( U0 new R )
 265.766 +*     new P (             ) new Q = (          ) (          )
 265.767 +*           ( new G new H )         ( new S  I ) ( 0  new C )
 265.768 +*
 265.769 +*  where:
 265.770 +*
 265.771 +*     new F = L0 * new R  =>
 265.772 +*
 265.773 +*     new R = inv(L0) * new F = inv(L0) * (F  f) = ( R  inv(L0)*f )
 265.774 +*
 265.775 +*     new G = new S * U0  =>
 265.776 +*
 265.777 +*                               ( G )             (     S      )
 265.778 +*     new S = new G * inv(U0) = (   ) * inv(U0) = (            )
 265.779 +*                               ( v')             ( v'*inv(U0) )
 265.780 +*
 265.781 +*     new H = new S * new R + new C  =>
 265.782 +*
 265.783 +*     new C = new H - new S * new R =
 265.784 +*
 265.785 +*             ( H  g )   (     S      )
 265.786 +*           = (      ) - (            ) * ( R  inv(L0)*f ) =
 265.787 +*             ( w' 0 )   ( v'*inv(U0) )
 265.788 +*
 265.789 +*             ( H - S*R           g - S*inv(L0)*f      )   ( C  x )
 265.790 +*           = (                                        ) = (      )
 265.791 +*             ( w'- v'*inv(U0)*R  -v'*inv(U0)*inv(L0)*f)   ( y' z )
 265.792 +*
 265.793 +*  Note that new C is resulted by expanding old C with new column x,
 265.794 +*  row y', and diagonal element z, where:
 265.795 +*
 265.796 +*     x = g - S * inv(L0) * f = g - S * (new column of R)
 265.797 +*
 265.798 +*     y = w - R'* inv(U'0)* v = w - R'* (new row of S)
 265.799 +*
 265.800 +*     z = - (new row of S) * (new column of R)
 265.801 +*
 265.802 +*  Finally, to replace old B by new B we have to permute j-th and last
 265.803 +*  (just added) columns of the matrix
 265.804 +*
 265.805 +*     ( B   F^| a )
 265.806 +*     (       |   )
 265.807 +*     ( G^  H^| 0 )
 265.808 +*     (-------+---)
 265.809 +*     ( e'j 0 | 0 )
 265.810 +*
 265.811 +*  and to keep the main equality do the same for matrix Q. */
 265.812 +
 265.813 +int lpf_update_it(LPF *lpf, int j, int bh, int len, const int ind[],
 265.814 +      const double val[])
 265.815 +{     int m0 = lpf->m0;
 265.816 +      int m = lpf->m;
 265.817 +#if _GLPLPF_DEBUG
 265.818 +      double *B = lpf->B;
 265.819 +#endif
 265.820 +      int n = lpf->n;
 265.821 +      int *R_ptr = lpf->R_ptr;
 265.822 +      int *R_len = lpf->R_len;
 265.823 +      int *S_ptr = lpf->S_ptr;
 265.824 +      int *S_len = lpf->S_len;
 265.825 +      int *P_row = lpf->P_row;
 265.826 +      int *P_col = lpf->P_col;
 265.827 +      int *Q_row = lpf->Q_row;
 265.828 +      int *Q_col = lpf->Q_col;
 265.829 +      int v_ptr = lpf->v_ptr;
 265.830 +      int *v_ind = lpf->v_ind;
 265.831 +      double *v_val = lpf->v_val;
 265.832 +      double *a = lpf->work2; /* new column */
 265.833 +      double *fg = lpf->work1, *f = fg, *g = fg + m0;
 265.834 +      double *vw = lpf->work2, *v = vw, *w = vw + m0;
 265.835 +      double *x = g, *y = w, z;
 265.836 +      int i, ii, k, ret;
 265.837 +      xassert(bh == bh);
 265.838 +      if (!lpf->valid)
 265.839 +         xfault("lpf_update_it: the factorization is not valid\n");
 265.840 +      if (!(1 <= j && j <= m))
 265.841 +         xfault("lpf_update_it: j = %d; column number out of range\n",
 265.842 +            j);
 265.843 +      xassert(0 <= m && m <= m0 + n);
 265.844 +      /* check if the basis factorization can be expanded */
 265.845 +      if (n == lpf->n_max)
 265.846 +      {  lpf->valid = 0;
 265.847 +         ret = LPF_ELIMIT;
 265.848 +         goto done;
 265.849 +      }
 265.850 +      /* convert new j-th column of B to dense format */
 265.851 +      for (i = 1; i <= m; i++)
 265.852 +         a[i] = 0.0;
 265.853 +      for (k = 1; k <= len; k++)
 265.854 +      {  i = ind[k];
 265.855 +         if (!(1 <= i && i <= m))
 265.856 +            xfault("lpf_update_it: ind[%d] = %d; row number out of rang"
 265.857 +               "e\n", k, i);
 265.858 +         if (a[i] != 0.0)
 265.859 +            xfault("lpf_update_it: ind[%d] = %d; duplicate row index no"
 265.860 +               "t allowed\n", k, i);
 265.861 +         if (val[k] == 0.0)
 265.862 +            xfault("lpf_update_it: val[%d] = %g; zero element not allow"
 265.863 +               "ed\n", k, val[k]);
 265.864 +         a[i] = val[k];
 265.865 +      }
 265.866 +#if _GLPLPF_DEBUG
 265.867 +      /* change column in the basis matrix for debugging */
 265.868 +      for (i = 1; i <= m; i++)
 265.869 +         B[(i - 1) * m + j] = a[i];
 265.870 +#endif
 265.871 +      /* (f g) := inv(P) * (a 0) */
 265.872 +      for (i = 1; i <= m0+n; i++)
 265.873 +         fg[i] = ((ii = P_col[i]) <= m ? a[ii] : 0.0);
 265.874 +      /* (v w) := Q * (ej 0) */
 265.875 +      for (i = 1; i <= m0+n; i++) vw[i] = 0.0;
 265.876 +      vw[Q_col[j]] = 1.0;
 265.877 +      /* f1 := inv(L0) * f (new column of R) */
 265.878 +      luf_f_solve(lpf->luf, 0, f);
 265.879 +      /* v1 := inv(U'0) * v (new row of S) */
 265.880 +      luf_v_solve(lpf->luf, 1, v);
 265.881 +      /* we need at most 2 * m0 available locations in the SVA to store
 265.882 +         new column of matrix R and new row of matrix S */
 265.883 +      if (lpf->v_size < v_ptr + m0 + m0)
 265.884 +      {  enlarge_sva(lpf, v_ptr + m0 + m0);
 265.885 +         v_ind = lpf->v_ind;
 265.886 +         v_val = lpf->v_val;
 265.887 +      }
 265.888 +      /* store new column of R */
 265.889 +      R_ptr[n+1] = v_ptr;
 265.890 +      for (i = 1; i <= m0; i++)
 265.891 +      {  if (f[i] != 0.0)
 265.892 +            v_ind[v_ptr] = i, v_val[v_ptr] = f[i], v_ptr++;
 265.893 +      }
 265.894 +      R_len[n+1] = v_ptr - lpf->v_ptr;
 265.895 +      lpf->v_ptr = v_ptr;
 265.896 +      /* store new row of S */
 265.897 +      S_ptr[n+1] = v_ptr;
 265.898 +      for (i = 1; i <= m0; i++)
 265.899 +      {  if (v[i] != 0.0)
 265.900 +            v_ind[v_ptr] = i, v_val[v_ptr] = v[i], v_ptr++;
 265.901 +      }
 265.902 +      S_len[n+1] = v_ptr - lpf->v_ptr;
 265.903 +      lpf->v_ptr = v_ptr;
 265.904 +      /* x := g - S * f1 (new column of C) */
 265.905 +      s_prod(lpf, x, -1.0, f);
 265.906 +      /* y := w - R' * v1 (new row of C) */
 265.907 +      rt_prod(lpf, y, -1.0, v);
 265.908 +      /* z := - v1 * f1 (new diagonal element of C) */
 265.909 +      z = 0.0;
 265.910 +      for (i = 1; i <= m0; i++) z -= v[i] * f[i];
 265.911 +      /* update factorization of new matrix C */
 265.912 +      switch (scf_update_exp(lpf->scf, x, y, z))
 265.913 +      {  case 0:
 265.914 +            break;
 265.915 +         case SCF_ESING:
 265.916 +            lpf->valid = 0;
 265.917 +            ret = LPF_ESING;
 265.918 +            goto done;
 265.919 +         case SCF_ELIMIT:
 265.920 +            xassert(lpf != lpf);
 265.921 +         default:
 265.922 +            xassert(lpf != lpf);
 265.923 +      }
 265.924 +      /* expand matrix P */
 265.925 +      P_row[m0+n+1] = P_col[m0+n+1] = m0+n+1;
 265.926 +      /* expand matrix Q */
 265.927 +      Q_row[m0+n+1] = Q_col[m0+n+1] = m0+n+1;
 265.928 +      /* permute j-th and last (just added) column of matrix Q */
 265.929 +      i = Q_col[j], ii = Q_col[m0+n+1];
 265.930 +      Q_row[i] = m0+n+1, Q_col[m0+n+1] = i;
 265.931 +      Q_row[ii] = j, Q_col[j] = ii;
 265.932 +      /* increase the number of additional rows and columns */
 265.933 +      lpf->n++;
 265.934 +      xassert(lpf->n <= lpf->n_max);
 265.935 +      /* the factorization has been successfully updated */
 265.936 +      ret = 0;
 265.937 +done: /* return to the calling program */
 265.938 +      return ret;
 265.939 +}
 265.940 +
 265.941 +/***********************************************************************
 265.942 +*  NAME
 265.943 +*
 265.944 +*  lpf_delete_it - delete LP basis factorization
 265.945 +*
 265.946 +*  SYNOPSIS
 265.947 +*
 265.948 +*  #include "glplpf.h"
 265.949 +*  void lpf_delete_it(LPF *lpf)
 265.950 +*
 265.951 +*  DESCRIPTION
 265.952 +*
 265.953 +*  The routine lpf_delete_it deletes LP basis factorization specified
 265.954 +*  by the parameter lpf and frees all memory allocated to this program
 265.955 +*  object. */
 265.956 +
 265.957 +void lpf_delete_it(LPF *lpf)
 265.958 +{     luf_delete_it(lpf->luf);
 265.959 +#if _GLPLPF_DEBUG
 265.960 +      if (lpf->B != NULL) xfree(lpf->B);
 265.961 +#else
 265.962 +      xassert(lpf->B == NULL);
 265.963 +#endif
 265.964 +      if (lpf->R_ptr != NULL) xfree(lpf->R_ptr);
 265.965 +      if (lpf->R_len != NULL) xfree(lpf->R_len);
 265.966 +      if (lpf->S_ptr != NULL) xfree(lpf->S_ptr);
 265.967 +      if (lpf->S_len != NULL) xfree(lpf->S_len);
 265.968 +      if (lpf->scf != NULL) scf_delete_it(lpf->scf);
 265.969 +      if (lpf->P_row != NULL) xfree(lpf->P_row);
 265.970 +      if (lpf->P_col != NULL) xfree(lpf->P_col);
 265.971 +      if (lpf->Q_row != NULL) xfree(lpf->Q_row);
 265.972 +      if (lpf->Q_col != NULL) xfree(lpf->Q_col);
 265.973 +      if (lpf->v_ind != NULL) xfree(lpf->v_ind);
 265.974 +      if (lpf->v_val != NULL) xfree(lpf->v_val);
 265.975 +      if (lpf->work1 != NULL) xfree(lpf->work1);
 265.976 +      if (lpf->work2 != NULL) xfree(lpf->work2);
 265.977 +      xfree(lpf);
 265.978 +      return;
 265.979 +}
 265.980 +
 265.981 +/* eof */
   266.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
   266.2 +++ b/deps/glpk/src/glplpf.h	Sun Nov 06 20:59:10 2011 +0100
   266.3 @@ -0,0 +1,194 @@
   266.4 +/* glplpf.h (LP basis factorization, Schur complement version) */
   266.5 +
   266.6 +/***********************************************************************
   266.7 +*  This code is part of GLPK (GNU Linear Programming Kit).
   266.8 +*
   266.9 +*  Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008,
  266.10 +*  2009, 2010, 2011 Andrew Makhorin, Department for Applied Informatics,
  266.11 +*  Moscow Aviation Institute, Moscow, Russia. All rights reserved.
  266.12 +*  E-mail: <mao@gnu.org>.
  266.13 +*
  266.14 +*  GLPK is free software: you can redistribute it and/or modify it
  266.15 +*  under the terms of the GNU General Public License as published by
  266.16 +*  the Free Software Foundation, either version 3 of the License, or
  266.17 +*  (at your option) any later version.
  266.18 +*
  266.19 +*  GLPK is distributed in the hope that it will be useful, but WITHOUT
  266.20 +*  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
  266.21 +*  or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
  266.22 +*  License for more details.
  266.23 +*
  266.24 +*  You should have received a copy of the GNU General Public License
  266.25 +*  along with GLPK. If not, see <http://www.gnu.org/licenses/>.
  266.26 +***********************************************************************/
  266.27 +
  266.28 +#ifndef GLPLPF_H
  266.29 +#define GLPLPF_H
  266.30 +
  266.31 +#include "glpscf.h"
  266.32 +#include "glpluf.h"
  266.33 +
  266.34 +/***********************************************************************
  266.35 +*  The structure LPF defines the factorization of the basis mxm matrix
  266.36 +*  B, where m is the number of rows in corresponding problem instance.
  266.37 +*
  266.38 +*  This factorization is the following septet:
  266.39 +*
  266.40 +*     [B] = (L0, U0, R, S, C, P, Q),                                 (1)
  266.41 +*
  266.42 +*  and is based on the following main equality:
  266.43 +*
  266.44 +*     ( B  F^)     ( B0 F )       ( L0 0 ) ( U0 R )
  266.45 +*     (      ) = P (      ) Q = P (      ) (      ) Q,               (2)
  266.46 +*     ( G^ H^)     ( G  H )       ( S  I ) ( 0  C )
  266.47 +*
  266.48 +*  where:
  266.49 +*
  266.50 +*  B is the current basis matrix (not stored);
  266.51 +*
  266.52 +*  F^, G^, H^ are some additional matrices (not stored);
  266.53 +*
  266.54 +*  B0 is some initial basis matrix (not stored);
  266.55 +*
  266.56 +*  F, G, H are some additional matrices (not stored);
  266.57 +*
  266.58 +*  P, Q are permutation matrices (stored in both row- and column-like
  266.59 +*  formats);
  266.60 +*
  266.61 +*  L0, U0 are some matrices that defines a factorization of the initial
  266.62 +*  basis matrix B0 = L0 * U0 (stored in an invertable form);
  266.63 +*
  266.64 +*  R is a matrix defined from L0 * R = F, so R = inv(L0) * F (stored in
  266.65 +*  a column-wise sparse format);
  266.66 +*
  266.67 +*  S is a matrix defined from S * U0 = G, so S = G * inv(U0) (stored in
  266.68 +*  a row-wise sparse format);
  266.69 +*
  266.70 +*  C is the Schur complement for matrix (B0 F G H). It is defined from
  266.71 +*  S * R + C = H, so C = H - S * R = H - G * inv(U0) * inv(L0) * F =
  266.72 +*  = H - G * inv(B0) * F. Matrix C is stored in an invertable form.
  266.73 +*
  266.74 +*  REFERENCES
  266.75 +*
  266.76 +*  1. M.A.Saunders, "LUSOL: A basis package for constrained optimiza-
  266.77 +*     tion," SCCM, Stanford University, 2006.
  266.78 +*
  266.79 +*  2. M.A.Saunders, "Notes 5: Basis Updates," CME 318, Stanford Univer-
  266.80 +*     sity, Spring 2006.
  266.81 +*
  266.82 +*  3. M.A.Saunders, "Notes 6: LUSOL---a Basis Factorization Package,"
  266.83 +*     ibid. */
  266.84 +
  266.85 +typedef struct LPF LPF;
  266.86 +
  266.87 +struct LPF
  266.88 +{     /* LP basis factorization */
  266.89 +      int valid;
  266.90 +      /* the factorization is valid only if this flag is set */
  266.91 +      /*--------------------------------------------------------------*/
  266.92 +      /* initial basis matrix B0 */
  266.93 +      int m0_max;
  266.94 +      /* maximal value of m0 (increased automatically, if necessary) */
  266.95 +      int m0;
  266.96 +      /* the order of B0 */
  266.97 +      LUF *luf;
  266.98 +      /* LU-factorization of B0 */
  266.99 +      /*--------------------------------------------------------------*/
 266.100 +      /* current basis matrix B */
 266.101 +      int m;
 266.102 +      /* the order of B */
 266.103 +      double *B; /* double B[1+m*m]; */
 266.104 +      /* B in dense format stored by rows and used only for debugging;
 266.105 +         normally this array is not allocated */
 266.106 +      /*--------------------------------------------------------------*/
 266.107 +      /* augmented matrix (B0 F G H) of the order m0+n */
 266.108 +      int n_max;
 266.109 +      /* maximal number of additional rows and columns */
 266.110 +      int n;
 266.111 +      /* current number of additional rows and columns */
 266.112 +      /*--------------------------------------------------------------*/
 266.113 +      /* m0xn matrix R in column-wise format */
 266.114 +      int *R_ptr; /* int R_ptr[1+n_max]; */
 266.115 +      /* R_ptr[j], 1 <= j <= n, is a pointer to j-th column */
 266.116 +      int *R_len; /* int R_len[1+n_max]; */
 266.117 +      /* R_len[j], 1 <= j <= n, is the length of j-th column */
 266.118 +      /*--------------------------------------------------------------*/
 266.119 +      /* nxm0 matrix S in row-wise format */
 266.120 +      int *S_ptr; /* int S_ptr[1+n_max]; */
 266.121 +      /* S_ptr[i], 1 <= i <= n, is a pointer to i-th row */
 266.122 +      int *S_len; /* int S_len[1+n_max]; */
 266.123 +      /* S_len[i], 1 <= i <= n, is the length of i-th row */
 266.124 +      /*--------------------------------------------------------------*/
 266.125 +      /* Schur complement C of the order n */
 266.126 +      SCF *scf; /* SCF scf[1:n_max]; */
 266.127 +      /* factorization of the Schur complement */
 266.128 +      /*--------------------------------------------------------------*/
 266.129 +      /* matrix P of the order m0+n */
 266.130 +      int *P_row; /* int P_row[1+m0_max+n_max]; */
 266.131 +      /* P_row[i] = j means that P[i,j] = 1 */
 266.132 +      int *P_col; /* int P_col[1+m0_max+n_max]; */
 266.133 +      /* P_col[j] = i means that P[i,j] = 1 */
 266.134 +      /*--------------------------------------------------------------*/
 266.135 +      /* matrix Q of the order m0+n */
 266.136 +      int *Q_row; /* int Q_row[1+m0_max+n_max]; */
 266.137 +      /* Q_row[i] = j means that Q[i,j] = 1 */
 266.138 +      int *Q_col; /* int Q_col[1+m0_max+n_max]; */
 266.139 +      /* Q_col[j] = i means that Q[i,j] = 1 */
 266.140 +      /*--------------------------------------------------------------*/
 266.141 +      /* Sparse Vector Area (SVA) is a set of locations intended to
 266.142 +         store sparse vectors which represent columns of matrix R and
 266.143 +         rows of matrix S; each location is a doublet (ind, val), where
 266.144 +         ind is an index, val is a numerical value of a sparse vector
 266.145 +         element; in the whole each sparse vector is a set of adjacent
 266.146 +         locations defined by a pointer to its first element and its
 266.147 +         length, i.e. the number of its elements */
 266.148 +      int v_size;
 266.149 +      /* the SVA size, in locations; locations are numbered by integers
 266.150 +         1, 2, ..., v_size, and location 0 is not used */
 266.151 +      int v_ptr;
 266.152 +      /* pointer to the first available location */
 266.153 +      int *v_ind; /* int v_ind[1+v_size]; */
 266.154 +      /* v_ind[k], 1 <= k <= v_size, is the index field of location k */
 266.155 +      double *v_val; /* double v_val[1+v_size]; */
 266.156 +      /* v_val[k], 1 <= k <= v_size, is the value field of location k */
 266.157 +      /*--------------------------------------------------------------*/
 266.158 +      double *work1; /* double work1[1+m0+n_max]; */
 266.159 +      /* working array */
 266.160 +      double *work2; /* double work2[1+m0+n_max]; */
 266.161 +      /* working array */
 266.162 +};
 266.163 +
 266.164 +/* return codes: */
 266.165 +#define LPF_ESING    1  /* singular matrix */
 266.166 +#define LPF_ECOND    2  /* ill-conditioned matrix */
 266.167 +#define LPF_ELIMIT   3  /* update limit reached */
 266.168 +
 266.169 +#define lpf_create_it _glp_lpf_create_it
 266.170 +LPF *lpf_create_it(void);
 266.171 +/* create LP basis factorization */
 266.172 +
 266.173 +#define lpf_factorize _glp_lpf_factorize
 266.174 +int lpf_factorize(LPF *lpf, int m, const int bh[], int (*col)
 266.175 +      (void *info, int j, int ind[], double val[]), void *info);
 266.176 +/* compute LP basis factorization */
 266.177 +
 266.178 +#define lpf_ftran _glp_lpf_ftran
 266.179 +void lpf_ftran(LPF *lpf, double x[]);
 266.180 +/* perform forward transformation (solve system B*x = b) */
 266.181 +
 266.182 +#define lpf_btran _glp_lpf_btran
 266.183 +void lpf_btran(LPF *lpf, double x[]);
 266.184 +/* perform backward transformation (solve system B'*x = b) */
 266.185 +
 266.186 +#define lpf_update_it _glp_lpf_update_it
 266.187 +int lpf_update_it(LPF *lpf, int j, int bh, int len, const int ind[],
 266.188 +      const double val[]);
 266.189 +/* update LP basis factorization */
 266.190 +
 266.191 +#define lpf_delete_it _glp_lpf_delete_it
 266.192 +void lpf_delete_it(LPF *lpf);
 266.193 +/* delete LP basis factorization */
 266.194 +
 266.195 +#endif
 266.196 +
 266.197 +/* eof */
   267.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
   267.2 +++ b/deps/glpk/src/glplpx01.c	Sun Nov 06 20:59:10 2011 +0100
   267.3 @@ -0,0 +1,1542 @@
   267.4 +/* glplpx01.c (obsolete API routines) */
   267.5 +
   267.6 +/***********************************************************************
   267.7 +*  This code is part of GLPK (GNU Linear Programming Kit).
   267.8 +*
   267.9 +*  Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008,
  267.10 +*  2009, 2010, 2011 Andrew Makhorin, Department for Applied Informatics,
  267.11 +*  Moscow Aviation Institute, Moscow, Russia. All rights reserved.
  267.12 +*  E-mail: <mao@gnu.org>.
  267.13 +*
  267.14 +*  GLPK is free software: you can redistribute it and/or modify it
  267.15 +*  under the terms of the GNU General Public License as published by
  267.16 +*  the Free Software Foundation, either version 3 of the License, or
  267.17 +*  (at your option) any later version.
  267.18 +*
  267.19 +*  GLPK is distributed in the hope that it will be useful, but WITHOUT
  267.20 +*  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
  267.21 +*  or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
  267.22 +*  License for more details.
  267.23 +*
  267.24 +*  You should have received a copy of the GNU General Public License
  267.25 +*  along with GLPK. If not, see <http://www.gnu.org/licenses/>.
  267.26 +***********************************************************************/
  267.27 +
  267.28 +#include "glpapi.h"
  267.29 +
  267.30 +struct LPXCPS
  267.31 +{     /* control parameters and statistics */
  267.32 +      int msg_lev;
  267.33 +      /* level of messages output by the solver:
  267.34 +         0 - no output
  267.35 +         1 - error messages only
  267.36 +         2 - normal output
  267.37 +         3 - full output (includes informational messages) */
  267.38 +      int scale;
  267.39 +      /* scaling option:
  267.40 +         0 - no scaling
  267.41 +         1 - equilibration scaling
  267.42 +         2 - geometric mean scaling
  267.43 +         3 - geometric mean scaling, then equilibration scaling */
  267.44 +      int dual;
  267.45 +      /* dual simplex option:
  267.46 +         0 - use primal simplex
  267.47 +         1 - use dual simplex */
  267.48 +      int price;
  267.49 +      /* pricing option (for both primal and dual simplex):
  267.50 +         0 - textbook pricing
  267.51 +         1 - steepest edge pricing */
  267.52 +      double relax;
  267.53 +      /* relaxation parameter used in the ratio test; if it is zero,
  267.54 +         the textbook ratio test is used; if it is non-zero (should be
  267.55 +         positive), Harris' two-pass ratio test is used; in the latter
  267.56 +         case on the first pass basic variables (in the case of primal
  267.57 +         simplex) or reduced costs of non-basic variables (in the case
  267.58 +         of dual simplex) are allowed to slightly violate their bounds,
  267.59 +         but not more than (relax * tol_bnd) or (relax * tol_dj) (thus,
  267.60 +         relax is a percentage of tol_bnd or tol_dj) */
  267.61 +      double tol_bnd;
  267.62 +      /* relative tolerance used to check if the current basic solution
  267.63 +         is primal feasible */
  267.64 +      double tol_dj;
  267.65 +      /* absolute tolerance used to check if the current basic solution
  267.66 +         is dual feasible */
  267.67 +      double tol_piv;
  267.68 +      /* relative tolerance used to choose eligible pivotal elements of
  267.69 +         the simplex table in the ratio test */
  267.70 +      int round;
  267.71 +      /* solution rounding option:
  267.72 +         0 - report all computed values and reduced costs "as is"
  267.73 +         1 - if possible (allowed by the tolerances), replace computed
  267.74 +             values and reduced costs which are close to zero by exact
  267.75 +             zeros */
  267.76 +      double obj_ll;
  267.77 +      /* lower limit of the objective function; if on the phase II the
  267.78 +         objective function reaches this limit and continues decreasing,
  267.79 +         the solver stops the search */
  267.80 +      double obj_ul;
  267.81 +      /* upper limit of the objective function; if on the phase II the
  267.82 +         objective function reaches this limit and continues increasing,
  267.83 +         the solver stops the search */
  267.84 +      int it_lim;
  267.85 +      /* simplex iterations limit; if this value is positive, it is
  267.86 +         decreased by one each time when one simplex iteration has been
  267.87 +         performed, and reaching zero value signals the solver to stop
  267.88 +         the search; negative value means no iterations limit */
  267.89 +      double tm_lim;
  267.90 +      /* searching time limit, in seconds; if this value is positive,
  267.91 +         it is decreased each time when one simplex iteration has been
  267.92 +         performed by the amount of time spent for the iteration, and
  267.93 +         reaching zero value signals the solver to stop the search;
  267.94 +         negative value means no time limit */
  267.95 +      int out_frq;
  267.96 +      /* output frequency, in iterations; this parameter specifies how
  267.97 +         frequently the solver sends information about the solution to
  267.98 +         the standard output */
  267.99 +      double out_dly;
 267.100 +      /* output delay, in seconds; this parameter specifies how long
 267.101 +         the solver should delay sending information about the solution
 267.102 +         to the standard output; zero value means no delay */
 267.103 +      int branch; /* MIP */
 267.104 +      /* branching heuristic:
 267.105 +         0 - branch on first variable
 267.106 +         1 - branch on last variable
 267.107 +         2 - branch using heuristic by Driebeck and Tomlin
 267.108 +         3 - branch on most fractional variable */
 267.109 +      int btrack; /* MIP */
 267.110 +      /* backtracking heuristic:
 267.111 +         0 - select most recent node (depth first search)
 267.112 +         1 - select earliest node (breadth first search)
 267.113 +         2 - select node using the best projection heuristic
 267.114 +         3 - select node with best local bound */
 267.115 +      double tol_int; /* MIP */
 267.116 +      /* absolute tolerance used to check if the current basic solution
 267.117 +         is integer feasible */
 267.118 +      double tol_obj; /* MIP */
 267.119 +      /* relative tolerance used to check if the value of the objective
 267.120 +         function is not better than in the best known integer feasible
 267.121 +         solution */
 267.122 +      int mps_info; /* lpx_write_mps */
 267.123 +      /* if this flag is set, the routine lpx_write_mps outputs several
 267.124 +         comment cards that contains some information about the problem;
 267.125 +         otherwise the routine outputs no comment cards */
 267.126 +      int mps_obj; /* lpx_write_mps */
 267.127 +      /* this parameter tells the routine lpx_write_mps how to output
 267.128 +         the objective function row:
 267.129 +         0 - never output objective function row
 267.130 +         1 - always output objective function row
 267.131 +         2 - output objective function row if and only if the problem
 267.132 +             has no free rows */
 267.133 +      int mps_orig; /* lpx_write_mps */
 267.134 +      /* if this flag is set, the routine lpx_write_mps uses original
 267.135 +         row and column symbolic names; otherwise the routine generates
 267.136 +         plain names using ordinal numbers of rows and columns */
 267.137 +      int mps_wide; /* lpx_write_mps */
 267.138 +      /* if this flag is set, the routine lpx_write_mps uses all data
 267.139 +         fields; otherwise the routine keeps fields 5 and 6 empty */
 267.140 +      int mps_free; /* lpx_write_mps */
 267.141 +      /* if this flag is set, the routine lpx_write_mps omits column
 267.142 +         and vector names everytime if possible (free style); otherwise
 267.143 +         the routine never omits these names (pedantic style) */
 267.144 +      int mps_skip; /* lpx_write_mps */
 267.145 +      /* if this flag is set, the routine lpx_write_mps skips empty
 267.146 +         columns (i.e. which has no constraint coefficients); otherwise
 267.147 +         the routine outputs all columns */
 267.148 +      int lpt_orig; /* lpx_write_lpt */
 267.149 +      /* if this flag is set, the routine lpx_write_lpt uses original
 267.150 +         row and column symbolic names; otherwise the routine generates
 267.151 +         plain names using ordinal numbers of rows and columns */
 267.152 +      int presol; /* lpx_simplex */
 267.153 +      /* LP presolver option:
 267.154 +         0 - do not use LP presolver
 267.155 +         1 - use LP presolver */
 267.156 +      int binarize; /* lpx_intopt */
 267.157 +      /* if this flag is set, the routine lpx_intopt replaces integer
 267.158 +         columns by binary ones */
 267.159 +      int use_cuts; /* lpx_intopt */
 267.160 +      /* if this flag is set, the routine lpx_intopt tries generating
 267.161 +         cutting planes:
 267.162 +         LPX_C_COVER  - mixed cover cuts
 267.163 +         LPX_C_CLIQUE - clique cuts
 267.164 +         LPX_C_GOMORY - Gomory's mixed integer cuts
 267.165 +         LPX_C_ALL    - all cuts */
 267.166 +      double mip_gap; /* MIP */
 267.167 +      /* relative MIP gap tolerance */
 267.168 +};
 267.169 +
 267.170 +LPX *lpx_create_prob(void)
 267.171 +{     /* create problem object */
 267.172 +      return glp_create_prob();
 267.173 +}
 267.174 +
 267.175 +void lpx_set_prob_name(LPX *lp, const char *name)
 267.176 +{     /* assign (change) problem name */
 267.177 +      glp_set_prob_name(lp, name);
 267.178 +      return;
 267.179 +}
 267.180 +
 267.181 +void lpx_set_obj_name(LPX *lp, const char *name)
 267.182 +{     /* assign (change) objective function name */
 267.183 +      glp_set_obj_name(lp, name);
 267.184 +      return;
 267.185 +}
 267.186 +
 267.187 +void lpx_set_obj_dir(LPX *lp, int dir)
 267.188 +{     /* set (change) optimization direction flag */
 267.189 +      glp_set_obj_dir(lp, dir - LPX_MIN + GLP_MIN);
 267.190 +      return;
 267.191 +}
 267.192 +
 267.193 +int lpx_add_rows(LPX *lp, int nrs)
 267.194 +{     /* add new rows to problem object */
 267.195 +      return glp_add_rows(lp, nrs);
 267.196 +}
 267.197 +
 267.198 +int lpx_add_cols(LPX *lp, int ncs)
 267.199 +{     /* add new columns to problem object */
 267.200 +      return glp_add_cols(lp, ncs);
 267.201 +}
 267.202 +
 267.203 +void lpx_set_row_name(LPX *lp, int i, const char *name)
 267.204 +{     /* assign (change) row name */
 267.205 +      glp_set_row_name(lp, i, name);
 267.206 +      return;
 267.207 +}
 267.208 +
 267.209 +void lpx_set_col_name(LPX *lp, int j, const char *name)
 267.210 +{     /* assign (change) column name */
 267.211 +      glp_set_col_name(lp, j, name);
 267.212 +      return;
 267.213 +}
 267.214 +
 267.215 +void lpx_set_row_bnds(LPX *lp, int i, int type, double lb, double ub)
 267.216 +{     /* set (change) row bounds */
 267.217 +      glp_set_row_bnds(lp, i, type - LPX_FR + GLP_FR, lb, ub);
 267.218 +      return;
 267.219 +}
 267.220 +
 267.221 +void lpx_set_col_bnds(LPX *lp, int j, int type, double lb, double ub)
 267.222 +{     /* set (change) column bounds */
 267.223 +      glp_set_col_bnds(lp, j, type - LPX_FR + GLP_FR, lb, ub);
 267.224 +      return;
 267.225 +}
 267.226 +
 267.227 +void lpx_set_obj_coef(glp_prob *lp, int j, double coef)
 267.228 +{     /* set (change) obj. coefficient or constant term */
 267.229 +      glp_set_obj_coef(lp, j, coef);
 267.230 +      return;
 267.231 +}
 267.232 +
 267.233 +void lpx_set_mat_row(LPX *lp, int i, int len, const int ind[],
 267.234 +      const double val[])
 267.235 +{     /* set (replace) row of the constraint matrix */
 267.236 +      glp_set_mat_row(lp, i, len, ind, val);
 267.237 +      return;
 267.238 +}
 267.239 +
 267.240 +void lpx_set_mat_col(LPX *lp, int j, int len, const int ind[],
 267.241 +      const double val[])
 267.242 +{     /* set (replace) column of the constraint matrix */
 267.243 +      glp_set_mat_col(lp, j, len, ind, val);
 267.244 +      return;
 267.245 +}
 267.246 +
 267.247 +void lpx_load_matrix(LPX *lp, int ne, const int ia[], const int ja[],
 267.248 +      const double ar[])
 267.249 +{     /* load (replace) the whole constraint matrix */
 267.250 +      glp_load_matrix(lp, ne, ia, ja, ar);
 267.251 +      return;
 267.252 +}
 267.253 +
 267.254 +void lpx_del_rows(LPX *lp, int nrs, const int num[])
 267.255 +{     /* delete specified rows from problem object */
 267.256 +      glp_del_rows(lp, nrs, num);
 267.257 +      return;
 267.258 +}
 267.259 +
 267.260 +void lpx_del_cols(LPX *lp, int ncs, const int num[])
 267.261 +{     /* delete specified columns from problem object */
 267.262 +      glp_del_cols(lp, ncs, num);
 267.263 +      return;
 267.264 +}
 267.265 +
 267.266 +void lpx_delete_prob(LPX *lp)
 267.267 +{     /* delete problem object */
 267.268 +      glp_delete_prob(lp);
 267.269 +      return;
 267.270 +}
 267.271 +
 267.272 +const char *lpx_get_prob_name(LPX *lp)
 267.273 +{     /* retrieve problem name */
 267.274 +      return glp_get_prob_name(lp);
 267.275 +}
 267.276 +
 267.277 +const char *lpx_get_obj_name(LPX *lp)
 267.278 +{     /* retrieve objective function name */
 267.279 +      return glp_get_obj_name(lp);
 267.280 +}
 267.281 +
 267.282 +int lpx_get_obj_dir(LPX *lp)
 267.283 +{     /* retrieve optimization direction flag */
 267.284 +      return glp_get_obj_dir(lp) - GLP_MIN + LPX_MIN;
 267.285 +}
 267.286 +
 267.287 +int lpx_get_num_rows(LPX *lp)
 267.288 +{     /* retrieve number of rows */
 267.289 +      return glp_get_num_rows(lp);
 267.290 +}
 267.291 +
 267.292 +int lpx_get_num_cols(LPX *lp)
 267.293 +{     /* retrieve number of columns */
 267.294 +      return glp_get_num_cols(lp);
 267.295 +}
 267.296 +
 267.297 +const char *lpx_get_row_name(LPX *lp, int i)
 267.298 +{     /* retrieve row name */
 267.299 +      return glp_get_row_name(lp, i);
 267.300 +}
 267.301 +
 267.302 +const char *lpx_get_col_name(LPX *lp, int j)
 267.303 +{     /* retrieve column name */
 267.304 +      return glp_get_col_name(lp, j);
 267.305 +}
 267.306 +
 267.307 +int lpx_get_row_type(LPX *lp, int i)
 267.308 +{     /* retrieve row type */
 267.309 +      return glp_get_row_type(lp, i) - GLP_FR + LPX_FR;
 267.310 +}
 267.311 +
 267.312 +double lpx_get_row_lb(glp_prob *lp, int i)
 267.313 +{     /* retrieve row lower bound */
 267.314 +      double lb;
 267.315 +      lb = glp_get_row_lb(lp, i);
 267.316 +      if (lb == -DBL_MAX) lb = 0.0;
 267.317 +      return lb;
 267.318 +}
 267.319 +
 267.320 +double lpx_get_row_ub(glp_prob *lp, int i)
 267.321 +{     /* retrieve row upper bound */
 267.322 +      double ub;
 267.323 +      ub = glp_get_row_ub(lp, i);
 267.324 +      if (ub == +DBL_MAX) ub = 0.0;
 267.325 +      return ub;
 267.326 +}
 267.327 +
 267.328 +void lpx_get_row_bnds(glp_prob *lp, int i, int *typx, double *lb,
 267.329 +      double *ub)
 267.330 +{     /* retrieve row bounds */
 267.331 +      if (typx != NULL) *typx = lpx_get_row_type(lp, i);
 267.332 +      if (lb != NULL) *lb = lpx_get_row_lb(lp, i);
 267.333 +      if (ub != NULL) *ub = lpx_get_row_ub(lp, i);
 267.334 +      return;
 267.335 +}
 267.336 +
 267.337 +int lpx_get_col_type(LPX *lp, int j)
 267.338 +{     /* retrieve column type */
 267.339 +      return glp_get_col_type(lp, j) - GLP_FR + LPX_FR;
 267.340 +}
 267.341 +
 267.342 +double lpx_get_col_lb(glp_prob *lp, int j)
 267.343 +{     /* retrieve column lower bound */
 267.344 +      double lb;
 267.345 +      lb = glp_get_col_lb(lp, j);
 267.346 +      if (lb == -DBL_MAX) lb = 0.0;
 267.347 +      return lb;
 267.348 +}
 267.349 +
 267.350 +double lpx_get_col_ub(glp_prob *lp, int j)
 267.351 +{     /* retrieve column upper bound */
 267.352 +      double ub;
 267.353 +      ub = glp_get_col_ub(lp, j);
 267.354 +      if (ub == +DBL_MAX) ub = 0.0;
 267.355 +      return ub;
 267.356 +}
 267.357 +
 267.358 +void lpx_get_col_bnds(glp_prob *lp, int j, int *typx, double *lb,
 267.359 +      double *ub)
 267.360 +{     /* retrieve column bounds */
 267.361 +      if (typx != NULL) *typx = lpx_get_col_type(lp, j);
 267.362 +      if (lb != NULL) *lb = lpx_get_col_lb(lp, j);
 267.363 +      if (ub != NULL) *ub = lpx_get_col_ub(lp, j);
 267.364 +      return;
 267.365 +}
 267.366 +
 267.367 +double lpx_get_obj_coef(LPX *lp, int j)
 267.368 +{     /* retrieve obj. coefficient or constant term */
 267.369 +      return glp_get_obj_coef(lp, j);
 267.370 +}
 267.371 +
 267.372 +int lpx_get_num_nz(LPX *lp)
 267.373 +{     /* retrieve number of constraint coefficients */
 267.374 +      return glp_get_num_nz(lp);
 267.375 +}
 267.376 +
 267.377 +int lpx_get_mat_row(LPX *lp, int i, int ind[], double val[])
 267.378 +{     /* retrieve row of the constraint matrix */
 267.379 +      return glp_get_mat_row(lp, i, ind, val);
 267.380 +}
 267.381 +
 267.382 +int lpx_get_mat_col(LPX *lp, int j, int ind[], double val[])
 267.383 +{     /* retrieve column of the constraint matrix */
 267.384 +      return glp_get_mat_col(lp, j, ind, val);
 267.385 +}
 267.386 +
 267.387 +void lpx_create_index(LPX *lp)
 267.388 +{     /* create the name index */
 267.389 +      glp_create_index(lp);
 267.390 +      return;
 267.391 +}
 267.392 +
 267.393 +int lpx_find_row(LPX *lp, const char *name)
 267.394 +{     /* find row by its name */
 267.395 +      return glp_find_row(lp, name);
 267.396 +}
 267.397 +
 267.398 +int lpx_find_col(LPX *lp, const char *name)
 267.399 +{     /* find column by its name */
 267.400 +      return glp_find_col(lp, name);
 267.401 +}
 267.402 +
 267.403 +void lpx_delete_index(LPX *lp)
 267.404 +{     /* delete the name index */
 267.405 +      glp_delete_index(lp);
 267.406 +      return;
 267.407 +}
 267.408 +
 267.409 +void lpx_scale_prob(LPX *lp)
 267.410 +{     /* scale problem data */
 267.411 +      switch (lpx_get_int_parm(lp, LPX_K_SCALE))
 267.412 +      {  case 0:
 267.413 +            /* no scaling */
 267.414 +            glp_unscale_prob(lp);
 267.415 +            break;
 267.416 +         case 1:
 267.417 +            /* equilibration scaling */
 267.418 +            glp_scale_prob(lp, GLP_SF_EQ);
 267.419 +            break;
 267.420 +         case 2:
 267.421 +            /* geometric mean scaling */
 267.422 +            glp_scale_prob(lp, GLP_SF_GM);
 267.423 +            break;
 267.424 +         case 3:
 267.425 +            /* geometric mean scaling, then equilibration scaling */
 267.426 +            glp_scale_prob(lp, GLP_SF_GM | GLP_SF_EQ);
 267.427 +            break;
 267.428 +         default:
 267.429 +            xassert(lp != lp);
 267.430 +      }
 267.431 +      return;
 267.432 +}
 267.433 +
 267.434 +void lpx_unscale_prob(LPX *lp)
 267.435 +{     /* unscale problem data */
 267.436 +      glp_unscale_prob(lp);
 267.437 +      return;
 267.438 +}
 267.439 +
 267.440 +void lpx_set_row_stat(LPX *lp, int i, int stat)
 267.441 +{     /* set (change) row status */
 267.442 +      glp_set_row_stat(lp, i, stat - LPX_BS + GLP_BS);
 267.443 +      return;
 267.444 +}
 267.445 +
 267.446 +void lpx_set_col_stat(LPX *lp, int j, int stat)
 267.447 +{     /* set (change) column status */
 267.448 +      glp_set_col_stat(lp, j, stat - LPX_BS + GLP_BS);
 267.449 +      return;
 267.450 +}
 267.451 +
 267.452 +void lpx_std_basis(LPX *lp)
 267.453 +{     /* construct standard initial LP basis */
 267.454 +      glp_std_basis(lp);
 267.455 +      return;
 267.456 +}
 267.457 +
 267.458 +void lpx_adv_basis(LPX *lp)
 267.459 +{     /* construct advanced initial LP basis */
 267.460 +      glp_adv_basis(lp, 0);
 267.461 +      return;
 267.462 +}
 267.463 +
 267.464 +void lpx_cpx_basis(LPX *lp)
 267.465 +{     /* construct Bixby's initial LP basis */
 267.466 +      glp_cpx_basis(lp);
 267.467 +      return;
 267.468 +}
 267.469 +
 267.470 +static void fill_smcp(LPX *lp, glp_smcp *parm)
 267.471 +{     glp_init_smcp(parm);
 267.472 +      switch (lpx_get_int_parm(lp, LPX_K_MSGLEV))
 267.473 +      {  case 0:  parm->msg_lev = GLP_MSG_OFF;   break;
 267.474 +         case 1:  parm->msg_lev = GLP_MSG_ERR;   break;
 267.475 +         case 2:  parm->msg_lev = GLP_MSG_ON;    break;
 267.476 +         case 3:  parm->msg_lev = GLP_MSG_ALL;   break;
 267.477 +         default: xassert(lp != lp);
 267.478 +      }
 267.479 +      switch (lpx_get_int_parm(lp, LPX_K_DUAL))
 267.480 +      {  case 0:  parm->meth = GLP_PRIMAL;       break;
 267.481 +         case 1:  parm->meth = GLP_DUAL;         break;
 267.482 +         default: xassert(lp != lp);
 267.483 +      }
 267.484 +      switch (lpx_get_int_parm(lp, LPX_K_PRICE))
 267.485 +      {  case 0:  parm->pricing = GLP_PT_STD;    break;
 267.486 +         case 1:  parm->pricing = GLP_PT_PSE;    break;
 267.487 +         default: xassert(lp != lp);
 267.488 +      }
 267.489 +      if (lpx_get_real_parm(lp, LPX_K_RELAX) == 0.0)
 267.490 +         parm->r_test = GLP_RT_STD;
 267.491 +      else
 267.492 +         parm->r_test = GLP_RT_HAR;
 267.493 +      parm->tol_bnd = lpx_get_real_parm(lp, LPX_K_TOLBND);
 267.494 +      parm->tol_dj  = lpx_get_real_parm(lp, LPX_K_TOLDJ);
 267.495 +      parm->tol_piv = lpx_get_real_parm(lp, LPX_K_TOLPIV);
 267.496 +      parm->obj_ll  = lpx_get_real_parm(lp, LPX_K_OBJLL);
 267.497 +      parm->obj_ul  = lpx_get_real_parm(lp, LPX_K_OBJUL);
 267.498 +      if (lpx_get_int_parm(lp, LPX_K_ITLIM) < 0)
 267.499 +         parm->it_lim = INT_MAX;
 267.500 +      else
 267.501 +         parm->it_lim = lpx_get_int_parm(lp, LPX_K_ITLIM);
 267.502 +      if (lpx_get_real_parm(lp, LPX_K_TMLIM) < 0.0)
 267.503 +         parm->tm_lim = INT_MAX;
 267.504 +      else
 267.505 +         parm->tm_lim =
 267.506 +            (int)(1000.0 * lpx_get_real_parm(lp, LPX_K_TMLIM));
 267.507 +      parm->out_frq = lpx_get_int_parm(lp, LPX_K_OUTFRQ);
 267.508 +      parm->out_dly =
 267.509 +            (int)(1000.0 * lpx_get_real_parm(lp, LPX_K_OUTDLY));
 267.510 +      switch (lpx_get_int_parm(lp, LPX_K_PRESOL))
 267.511 +      {  case 0:  parm->presolve = GLP_OFF;      break;
 267.512 +         case 1:  parm->presolve = GLP_ON;       break;
 267.513 +         default: xassert(lp != lp);
 267.514 +      }
 267.515 +      return;
 267.516 +}
 267.517 +
 267.518 +int lpx_simplex(LPX *lp)
 267.519 +{     /* easy-to-use driver to the simplex method */
 267.520 +      glp_smcp parm;
 267.521 +      int ret;
 267.522 +      fill_smcp(lp, &parm);
 267.523 +      ret = glp_simplex(lp, &parm);
 267.524 +      switch (ret)
 267.525 +      {  case 0:           ret = LPX_E_OK;      break;
 267.526 +         case GLP_EBADB:
 267.527 +         case GLP_ESING:
 267.528 +         case GLP_ECOND:
 267.529 +         case GLP_EBOUND:  ret = LPX_E_FAULT;   break;
 267.530 +         case GLP_EFAIL:   ret = LPX_E_SING;    break;
 267.531 +         case GLP_EOBJLL:  ret = LPX_E_OBJLL;   break;
 267.532 +         case GLP_EOBJUL:  ret = LPX_E_OBJUL;   break;
 267.533 +         case GLP_EITLIM:  ret = LPX_E_ITLIM;   break;
 267.534 +         case GLP_ETMLIM:  ret = LPX_E_TMLIM;   break;
 267.535 +         case GLP_ENOPFS:  ret = LPX_E_NOPFS;   break;
 267.536 +         case GLP_ENODFS:  ret = LPX_E_NODFS;   break;
 267.537 +         default:          xassert(ret != ret);
 267.538 +      }
 267.539 +      return ret;
 267.540 +}
 267.541 +
 267.542 +int lpx_exact(LPX *lp)
 267.543 +{     /* easy-to-use driver to the exact simplex method */
 267.544 +      glp_smcp parm;
 267.545 +      int ret;
 267.546 +      fill_smcp(lp, &parm);
 267.547 +      ret = glp_exact(lp, &parm);
 267.548 +      switch (ret)
 267.549 +      {  case 0:           ret = LPX_E_OK;      break;
 267.550 +         case GLP_EBADB:
 267.551 +         case GLP_ESING:
 267.552 +         case GLP_EBOUND:
 267.553 +         case GLP_EFAIL:   ret = LPX_E_FAULT;   break;
 267.554 +         case GLP_EITLIM:  ret = LPX_E_ITLIM;   break;
 267.555 +         case GLP_ETMLIM:  ret = LPX_E_TMLIM;   break;
 267.556 +         default:          xassert(ret != ret);
 267.557 +      }
 267.558 +      return ret;
 267.559 +}
 267.560 +
 267.561 +int lpx_get_status(glp_prob *lp)
 267.562 +{     /* retrieve generic status of basic solution */
 267.563 +      int status;
 267.564 +      switch (glp_get_status(lp))
 267.565 +      {  case GLP_OPT:    status = LPX_OPT;    break;
 267.566 +         case GLP_FEAS:   status = LPX_FEAS;   break;
 267.567 +         case GLP_INFEAS: status = LPX_INFEAS; break;
 267.568 +         case GLP_NOFEAS: status = LPX_NOFEAS; break;
 267.569 +         case GLP_UNBND:  status = LPX_UNBND;  break;
 267.570 +         case GLP_UNDEF:  status = LPX_UNDEF;  break;
 267.571 +         default:         xassert(lp != lp);
 267.572 +      }
 267.573 +      return status;
 267.574 +}
 267.575 +
 267.576 +int lpx_get_prim_stat(glp_prob *lp)
 267.577 +{     /* retrieve status of primal basic solution */
 267.578 +      return glp_get_prim_stat(lp) - GLP_UNDEF + LPX_P_UNDEF;
 267.579 +}
 267.580 +
 267.581 +int lpx_get_dual_stat(glp_prob *lp)
 267.582 +{     /* retrieve status of dual basic solution */
 267.583 +      return glp_get_dual_stat(lp) - GLP_UNDEF + LPX_D_UNDEF;
 267.584 +}
 267.585 +
 267.586 +double lpx_get_obj_val(LPX *lp)
 267.587 +{     /* retrieve objective value (basic solution) */
 267.588 +      return glp_get_obj_val(lp);
 267.589 +}
 267.590 +
 267.591 +int lpx_get_row_stat(LPX *lp, int i)
 267.592 +{     /* retrieve row status (basic solution) */
 267.593 +      return glp_get_row_stat(lp, i) - GLP_BS + LPX_BS;
 267.594 +}
 267.595 +
 267.596 +double lpx_get_row_prim(LPX *lp, int i)
 267.597 +{     /* retrieve row primal value (basic solution) */
 267.598 +      return glp_get_row_prim(lp, i);
 267.599 +}
 267.600 +
 267.601 +double lpx_get_row_dual(LPX *lp, int i)
 267.602 +{     /* retrieve row dual value (basic solution) */
 267.603 +      return glp_get_row_dual(lp, i);
 267.604 +}
 267.605 +
 267.606 +void lpx_get_row_info(glp_prob *lp, int i, int *tagx, double *vx,
 267.607 +      double *dx)
 267.608 +{     /* obtain row solution information */
 267.609 +      if (tagx != NULL) *tagx = lpx_get_row_stat(lp, i);
 267.610 +      if (vx != NULL) *vx = lpx_get_row_prim(lp, i);
 267.611 +      if (dx != NULL) *dx = lpx_get_row_dual(lp, i);
 267.612 +      return;
 267.613 +}
 267.614 +
 267.615 +int lpx_get_col_stat(LPX *lp, int j)
 267.616 +{     /* retrieve column status (basic solution) */
 267.617 +      return glp_get_col_stat(lp, j) - GLP_BS + LPX_BS;
 267.618 +}
 267.619 +
 267.620 +double lpx_get_col_prim(LPX *lp, int j)
 267.621 +{     /* retrieve column primal value (basic solution) */
 267.622 +      return glp_get_col_prim(lp, j);
 267.623 +}
 267.624 +
 267.625 +double lpx_get_col_dual(glp_prob *lp, int j)
 267.626 +{     /* retrieve column dual value (basic solution) */
 267.627 +      return glp_get_col_dual(lp, j);
 267.628 +}
 267.629 +
 267.630 +void lpx_get_col_info(glp_prob *lp, int j, int *tagx, double *vx,
 267.631 +      double *dx)
 267.632 +{     /* obtain column solution information */
 267.633 +      if (tagx != NULL) *tagx = lpx_get_col_stat(lp, j);
 267.634 +      if (vx != NULL) *vx = lpx_get_col_prim(lp, j);
 267.635 +      if (dx != NULL) *dx = lpx_get_col_dual(lp, j);
 267.636 +      return;
 267.637 +}
 267.638 +
 267.639 +int lpx_get_ray_info(LPX *lp)
 267.640 +{     /* determine what causes primal unboundness */
 267.641 +      return glp_get_unbnd_ray(lp);
 267.642 +}
 267.643 +
 267.644 +void lpx_check_kkt(LPX *lp, int scaled, LPXKKT *kkt)
 267.645 +{     /* check Karush-Kuhn-Tucker conditions */
 267.646 +      int ae_ind, re_ind;
 267.647 +      double ae_max, re_max;
 267.648 +      xassert(scaled == scaled);
 267.649 +      _glp_check_kkt(lp, GLP_SOL, GLP_KKT_PE, &ae_max, &ae_ind, &re_max,
 267.650 +         &re_ind);
 267.651 +      kkt->pe_ae_max = ae_max;
 267.652 +      kkt->pe_ae_row = ae_ind;
 267.653 +      kkt->pe_re_max = re_max;
 267.654 +      kkt->pe_re_row = re_ind;
 267.655 +      if (re_max <= 1e-9)
 267.656 +         kkt->pe_quality = 'H';
 267.657 +      else if (re_max <= 1e-6)
 267.658 +         kkt->pe_quality = 'M';
 267.659 +      else if (re_max <= 1e-3)
 267.660 +         kkt->pe_quality = 'L';
 267.661 +      else
 267.662 +         kkt->pe_quality = '?';
 267.663 +      _glp_check_kkt(lp, GLP_SOL, GLP_KKT_PB, &ae_max, &ae_ind, &re_max,
 267.664 +         &re_ind);
 267.665 +      kkt->pb_ae_max = ae_max;
 267.666 +      kkt->pb_ae_ind = ae_ind;
 267.667 +      kkt->pb_re_max = re_max;
 267.668 +      kkt->pb_re_ind = re_ind;
 267.669 +      if (re_max <= 1e-9)
 267.670 +         kkt->pb_quality = 'H';
 267.671 +      else if (re_max <= 1e-6)
 267.672 +         kkt->pb_quality = 'M';
 267.673 +      else if (re_max <= 1e-3)
 267.674 +         kkt->pb_quality = 'L';
 267.675 +      else
 267.676 +         kkt->pb_quality = '?';
 267.677 +      _glp_check_kkt(lp, GLP_SOL, GLP_KKT_DE, &ae_max, &ae_ind, &re_max,
 267.678 +         &re_ind);
 267.679 +      kkt->de_ae_max = ae_max;
 267.680 +      if (ae_ind == 0)
 267.681 +         kkt->de_ae_col = 0;
 267.682 +      else
 267.683 +         kkt->de_ae_col = ae_ind - lp->m;
 267.684 +      kkt->de_re_max = re_max;
 267.685 +      if (re_ind == 0)
 267.686 +         kkt->de_re_col = 0;
 267.687 +      else
 267.688 +         kkt->de_re_col = ae_ind - lp->m;
 267.689 +      if (re_max <= 1e-9)
 267.690 +         kkt->de_quality = 'H';
 267.691 +      else if (re_max <= 1e-6)
 267.692 +         kkt->de_quality = 'M';
 267.693 +      else if (re_max <= 1e-3)
 267.694 +         kkt->de_quality = 'L';
 267.695 +      else
 267.696 +         kkt->de_quality = '?';
 267.697 +      _glp_check_kkt(lp, GLP_SOL, GLP_KKT_DB, &ae_max, &ae_ind, &re_max,
 267.698 +         &re_ind);
 267.699 +      kkt->db_ae_max = ae_max;
 267.700 +      kkt->db_ae_ind = ae_ind;
 267.701 +      kkt->db_re_max = re_max;
 267.702 +      kkt->db_re_ind = re_ind;
 267.703 +      if (re_max <= 1e-9)
 267.704 +         kkt->db_quality = 'H';
 267.705 +      else if (re_max <= 1e-6)
 267.706 +         kkt->db_quality = 'M';
 267.707 +      else if (re_max <= 1e-3)
 267.708 +         kkt->db_quality = 'L';
 267.709 +      else
 267.710 +         kkt->db_quality = '?';
 267.711 +      kkt->cs_ae_max = 0.0, kkt->cs_ae_ind = 0;
 267.712 +      kkt->cs_re_max = 0.0, kkt->cs_re_ind = 0;
 267.713 +      kkt->cs_quality = 'H';
 267.714 +      return;
 267.715 +}
 267.716 +
 267.717 +int lpx_warm_up(LPX *lp)
 267.718 +{     /* "warm up" LP basis */
 267.719 +      int ret;
 267.720 +      ret = glp_warm_up(lp);
 267.721 +      if (ret == 0)
 267.722 +         ret = LPX_E_OK;
 267.723 +      else if (ret == GLP_EBADB)
 267.724 +         ret = LPX_E_BADB;
 267.725 +      else if (ret == GLP_ESING)
 267.726 +         ret = LPX_E_SING;
 267.727 +      else if (ret == GLP_ECOND)
 267.728 +         ret = LPX_E_SING;
 267.729 +      else
 267.730 +         xassert(ret != ret);
 267.731 +      return ret;
 267.732 +}
 267.733 +
 267.734 +int lpx_eval_tab_row(LPX *lp, int k, int ind[], double val[])
 267.735 +{     /* compute row of the simplex tableau */
 267.736 +      return glp_eval_tab_row(lp, k, ind, val);
 267.737 +}
 267.738 +
 267.739 +int lpx_eval_tab_col(LPX *lp, int k, int ind[], double val[])
 267.740 +{     /* compute column of the simplex tableau */
 267.741 +      return glp_eval_tab_col(lp, k, ind, val);
 267.742 +}
 267.743 +
 267.744 +int lpx_transform_row(LPX *lp, int len, int ind[], double val[])
 267.745 +{     /* transform explicitly specified row */
 267.746 +      return glp_transform_row(lp, len, ind, val);
 267.747 +}
 267.748 +
 267.749 +int lpx_transform_col(LPX *lp, int len, int ind[], double val[])
 267.750 +{     /* transform explicitly specified column */
 267.751 +      return glp_transform_col(lp, len, ind, val);
 267.752 +}
 267.753 +
 267.754 +int lpx_prim_ratio_test(LPX *lp, int len, const int ind[],
 267.755 +      const double val[], int how, double tol)
 267.756 +{     /* perform primal ratio test */
 267.757 +      int piv;
 267.758 +      piv = glp_prim_rtest(lp, len, ind, val, how, tol);
 267.759 +      xassert(0 <= piv && piv <= len);
 267.760 +      return piv == 0 ? 0 : ind[piv];
 267.761 +}
 267.762 +
 267.763 +int lpx_dual_ratio_test(LPX *lp, int len, const int ind[],
 267.764 +      const double val[], int how, double tol)
 267.765 +{     /* perform dual ratio test */
 267.766 +      int piv;
 267.767 +      piv = glp_dual_rtest(lp, len, ind, val, how, tol);
 267.768 +      xassert(0 <= piv && piv <= len);
 267.769 +      return piv == 0 ? 0 : ind[piv];
 267.770 +}
 267.771 +
 267.772 +int lpx_interior(LPX *lp)
 267.773 +{     /* easy-to-use driver to the interior-point method */
 267.774 +      int ret;
 267.775 +      ret = glp_interior(lp, NULL);
 267.776 +      switch (ret)
 267.777 +      {  case 0:           ret = LPX_E_OK;      break;
 267.778 +         case GLP_EFAIL:   ret = LPX_E_FAULT;   break;
 267.779 +         case GLP_ENOFEAS: ret = LPX_E_NOFEAS;  break;
 267.780 +         case GLP_ENOCVG:  ret = LPX_E_NOCONV;  break;
 267.781 +         case GLP_EITLIM:  ret = LPX_E_ITLIM;   break;
 267.782 +         case GLP_EINSTAB: ret = LPX_E_INSTAB;  break;
 267.783 +         default:          xassert(ret != ret);
 267.784 +      }
 267.785 +      return ret;
 267.786 +}
 267.787 +
 267.788 +int lpx_ipt_status(glp_prob *lp)
 267.789 +{     /* retrieve status of interior-point solution */
 267.790 +      int status;
 267.791 +      switch (glp_ipt_status(lp))
 267.792 +      {  case GLP_UNDEF:  status = LPX_T_UNDEF;  break;
 267.793 +         case GLP_OPT:    status = LPX_T_OPT;    break;
 267.794 +         default:         xassert(lp != lp);
 267.795 +      }
 267.796 +      return status;
 267.797 +}
 267.798 +
 267.799 +double lpx_ipt_obj_val(LPX *lp)
 267.800 +{     /* retrieve objective value (interior point) */
 267.801 +      return glp_ipt_obj_val(lp);
 267.802 +}
 267.803 +
 267.804 +double lpx_ipt_row_prim(LPX *lp, int i)
 267.805 +{     /* retrieve row primal value (interior point) */
 267.806 +      return glp_ipt_row_prim(lp, i);
 267.807 +}
 267.808 +
 267.809 +double lpx_ipt_row_dual(LPX *lp, int i)
 267.810 +{     /* retrieve row dual value (interior point) */
 267.811 +      return glp_ipt_row_dual(lp, i);
 267.812 +}
 267.813 +
 267.814 +double lpx_ipt_col_prim(LPX *lp, int j)
 267.815 +{     /* retrieve column primal value (interior point) */
 267.816 +      return glp_ipt_col_prim(lp, j);
 267.817 +}
 267.818 +
 267.819 +double lpx_ipt_col_dual(LPX *lp, int j)
 267.820 +{     /* retrieve column dual value (interior point) */
 267.821 +      return glp_ipt_col_dual(lp, j);
 267.822 +}
 267.823 +
 267.824 +void lpx_set_class(LPX *lp, int klass)
 267.825 +{     /* set problem class */
 267.826 +      xassert(lp == lp);
 267.827 +      if (!(klass == LPX_LP || klass == LPX_MIP))
 267.828 +         xerror("lpx_set_class: invalid problem class\n");
 267.829 +      return;
 267.830 +}
 267.831 +
 267.832 +int lpx_get_class(LPX *lp)
 267.833 +{     /* determine problem klass */
 267.834 +      return glp_get_num_int(lp) == 0 ? LPX_LP : LPX_MIP;
 267.835 +}
 267.836 +
 267.837 +void lpx_set_col_kind(LPX *lp, int j, int kind)
 267.838 +{     /* set (change) column kind */
 267.839 +      glp_set_col_kind(lp, j, kind - LPX_CV + GLP_CV);
 267.840 +      return;
 267.841 +}
 267.842 +
 267.843 +int lpx_get_col_kind(LPX *lp, int j)
 267.844 +{     /* retrieve column kind */
 267.845 +      return glp_get_col_kind(lp, j) == GLP_CV ? LPX_CV : LPX_IV;
 267.846 +}
 267.847 +
 267.848 +int lpx_get_num_int(LPX *lp)
 267.849 +{     /* retrieve number of integer columns */
 267.850 +      return glp_get_num_int(lp);
 267.851 +}
 267.852 +
 267.853 +int lpx_get_num_bin(LPX *lp)
 267.854 +{     /* retrieve number of binary columns */
 267.855 +      return glp_get_num_bin(lp);
 267.856 +}
 267.857 +
 267.858 +static int solve_mip(LPX *lp, int presolve)
 267.859 +{     glp_iocp parm;
 267.860 +      int ret;
 267.861 +      glp_init_iocp(&parm);
 267.862 +      switch (lpx_get_int_parm(lp, LPX_K_MSGLEV))
 267.863 +      {  case 0:  parm.msg_lev = GLP_MSG_OFF;   break;
 267.864 +         case 1:  parm.msg_lev = GLP_MSG_ERR;   break;
 267.865 +         case 2:  parm.msg_lev = GLP_MSG_ON;    break;
 267.866 +         case 3:  parm.msg_lev = GLP_MSG_ALL;   break;
 267.867 +         default: xassert(lp != lp);
 267.868 +      }
 267.869 +      switch (lpx_get_int_parm(lp, LPX_K_BRANCH))
 267.870 +      {  case 0:  parm.br_tech = GLP_BR_FFV;    break;
 267.871 +         case 1:  parm.br_tech = GLP_BR_LFV;    break;
 267.872 +         case 2:  parm.br_tech = GLP_BR_DTH;    break;
 267.873 +         case 3:  parm.br_tech = GLP_BR_MFV;    break;
 267.874 +         default: xassert(lp != lp);
 267.875 +      }
 267.876 +      switch (lpx_get_int_parm(lp, LPX_K_BTRACK))
 267.877 +      {  case 0:  parm.bt_tech = GLP_BT_DFS;    break;
 267.878 +         case 1:  parm.bt_tech = GLP_BT_BFS;    break;
 267.879 +         case 2:  parm.bt_tech = GLP_BT_BPH;    break;
 267.880 +         case 3:  parm.bt_tech = GLP_BT_BLB;    break;
 267.881 +         default: xassert(lp != lp);
 267.882 +      }
 267.883 +      parm.tol_int = lpx_get_real_parm(lp, LPX_K_TOLINT);
 267.884 +      parm.tol_obj = lpx_get_real_parm(lp, LPX_K_TOLOBJ);
 267.885 +      if (lpx_get_real_parm(lp, LPX_K_TMLIM) < 0.0 ||
 267.886 +          lpx_get_real_parm(lp, LPX_K_TMLIM) > 1e6)
 267.887 +         parm.tm_lim = INT_MAX;
 267.888 +      else
 267.889 +         parm.tm_lim =
 267.890 +            (int)(1000.0 * lpx_get_real_parm(lp, LPX_K_TMLIM));
 267.891 +      parm.mip_gap = lpx_get_real_parm(lp, LPX_K_MIPGAP);
 267.892 +      if (lpx_get_int_parm(lp, LPX_K_USECUTS) & LPX_C_GOMORY)
 267.893 +         parm.gmi_cuts = GLP_ON;
 267.894 +      else
 267.895 +         parm.gmi_cuts = GLP_OFF;
 267.896 +      if (lpx_get_int_parm(lp, LPX_K_USECUTS) & LPX_C_MIR)
 267.897 +         parm.mir_cuts = GLP_ON;
 267.898 +      else
 267.899 +         parm.mir_cuts = GLP_OFF;
 267.900 +      if (lpx_get_int_parm(lp, LPX_K_USECUTS) & LPX_C_COVER)
 267.901 +         parm.cov_cuts = GLP_ON;
 267.902 +      else
 267.903 +         parm.cov_cuts = GLP_OFF;
 267.904 +      if (lpx_get_int_parm(lp, LPX_K_USECUTS) & LPX_C_CLIQUE)
 267.905 +         parm.clq_cuts = GLP_ON;
 267.906 +      else
 267.907 +         parm.clq_cuts = GLP_OFF;
 267.908 +      parm.presolve = presolve;
 267.909 +      if (lpx_get_int_parm(lp, LPX_K_BINARIZE))
 267.910 +         parm.binarize = GLP_ON;
 267.911 +      ret = glp_intopt(lp, &parm);
 267.912 +      switch (ret)
 267.913 +      {  case 0:           ret = LPX_E_OK;      break;
 267.914 +         case GLP_ENOPFS:  ret = LPX_E_NOPFS;   break;
 267.915 +         case GLP_ENODFS:  ret = LPX_E_NODFS;   break;
 267.916 +         case GLP_EBOUND:
 267.917 +         case GLP_EROOT:   ret = LPX_E_FAULT;   break;
 267.918 +         case GLP_EFAIL:   ret = LPX_E_SING;    break;
 267.919 +         case GLP_EMIPGAP: ret = LPX_E_MIPGAP;  break;
 267.920 +         case GLP_ETMLIM:  ret = LPX_E_TMLIM;   break;
 267.921 +         default:          xassert(ret != ret);
 267.922 +      }
 267.923 +      return ret;
 267.924 +}
 267.925 +
 267.926 +int lpx_integer(LPX *lp)
 267.927 +{     /* easy-to-use driver to the branch-and-bound method */
 267.928 +      return solve_mip(lp, GLP_OFF);
 267.929 +}
 267.930 +
 267.931 +int lpx_intopt(LPX *lp)
 267.932 +{     /* easy-to-use driver to the branch-and-bound method */
 267.933 +      return solve_mip(lp, GLP_ON);
 267.934 +}
 267.935 +
 267.936 +int lpx_mip_status(glp_prob *lp)
 267.937 +{     /* retrieve status of MIP solution */
 267.938 +      int status;
 267.939 +      switch (glp_mip_status(lp))
 267.940 +      {  case GLP_UNDEF:  status = LPX_I_UNDEF;  break;
 267.941 +         case GLP_OPT:    status = LPX_I_OPT;    break;
 267.942 +         case GLP_FEAS:   status = LPX_I_FEAS;   break;
 267.943 +         case GLP_NOFEAS: status = LPX_I_NOFEAS; break;
 267.944 +         default:         xassert(lp != lp);
 267.945 +      }
 267.946 +      return status;
 267.947 +}
 267.948 +
 267.949 +double lpx_mip_obj_val(LPX *lp)
 267.950 +{     /* retrieve objective value (MIP solution) */
 267.951 +      return glp_mip_obj_val(lp);
 267.952 +}
 267.953 +
 267.954 +double lpx_mip_row_val(LPX *lp, int i)
 267.955 +{     /* retrieve row value (MIP solution) */
 267.956 +      return glp_mip_row_val(lp, i);
 267.957 +}
 267.958 +
 267.959 +double lpx_mip_col_val(LPX *lp, int j)
 267.960 +{     /* retrieve column value (MIP solution) */
 267.961 +      return glp_mip_col_val(lp, j);
 267.962 +}
 267.963 +
 267.964 +void lpx_check_int(LPX *lp, LPXKKT *kkt)
 267.965 +{     /* check integer feasibility conditions */
 267.966 +      int ae_ind, re_ind;
 267.967 +      double ae_max, re_max;
 267.968 +      _glp_check_kkt(lp, GLP_MIP, GLP_KKT_PE, &ae_max, &ae_ind, &re_max,
 267.969 +         &re_ind);
 267.970 +      kkt->pe_ae_max = ae_max;
 267.971 +      kkt->pe_ae_row = ae_ind;
 267.972 +      kkt->pe_re_max = re_max;
 267.973 +      kkt->pe_re_row = re_ind;
 267.974 +      if (re_max <= 1e-9)
 267.975 +         kkt->pe_quality = 'H';
 267.976 +      else if (re_max <= 1e-6)
 267.977 +         kkt->pe_quality = 'M';
 267.978 +      else if (re_max <= 1e-3)
 267.979 +         kkt->pe_quality = 'L';
 267.980 +      else
 267.981 +         kkt->pe_quality = '?';
 267.982 +      _glp_check_kkt(lp, GLP_MIP, GLP_KKT_PB, &ae_max, &ae_ind, &re_max,
 267.983 +         &re_ind);
 267.984 +      kkt->pb_ae_max = ae_max;
 267.985 +      kkt->pb_ae_ind = ae_ind;
 267.986 +      kkt->pb_re_max = re_max;
 267.987 +      kkt->pb_re_ind = re_ind;
 267.988 +      if (re_max <= 1e-9)
 267.989 +         kkt->pb_quality = 'H';
 267.990 +      else if (re_max <= 1e-6)
 267.991 +         kkt->pb_quality = 'M';
 267.992 +      else if (re_max <= 1e-3)
 267.993 +         kkt->pb_quality = 'L';
 267.994 +      else
 267.995 +         kkt->pb_quality = '?';
 267.996 +      return;
 267.997 +}
 267.998 +
 267.999 +#if 1 /* 17/XI-2009 */
267.1000 +static void reset_parms(LPX *lp)
267.1001 +{     /* reset control parameters to default values */
267.1002 +      struct LPXCPS *cps = lp->parms;
267.1003 +      xassert(cps != NULL);
267.1004 +      cps->msg_lev  = 3;
267.1005 +      cps->scale    = 1;
267.1006 +      cps->dual     = 0;
267.1007 +      cps->price    = 1;
267.1008 +      cps->relax    = 0.07;
267.1009 +      cps->tol_bnd  = 1e-7;
267.1010 +      cps->tol_dj   = 1e-7;
267.1011 +      cps->tol_piv  = 1e-9;
267.1012 +      cps->round    = 0;
267.1013 +      cps->obj_ll   = -DBL_MAX;
267.1014 +      cps->obj_ul   = +DBL_MAX;
267.1015 +      cps->it_lim   = -1;
267.1016 +#if 0 /* 02/XII-2010 */
267.1017 +      lp->it_cnt   = 0;
267.1018 +#endif
267.1019 +      cps->tm_lim   = -1.0;
267.1020 +      cps->out_frq  = 200;
267.1021 +      cps->out_dly  = 0.0;
267.1022 +      cps->branch   = 2;
267.1023 +      cps->btrack   = 3;
267.1024 +      cps->tol_int  = 1e-5;
267.1025 +      cps->tol_obj  = 1e-7;
267.1026 +      cps->mps_info = 1;
267.1027 +      cps->mps_obj  = 2;
267.1028 +      cps->mps_orig = 0;
267.1029 +      cps->mps_wide = 1;
267.1030 +      cps->mps_free = 0;
267.1031 +      cps->mps_skip = 0;
267.1032 +      cps->lpt_orig = 0;
267.1033 +      cps->presol = 0;
267.1034 +      cps->binarize = 0;
267.1035 +      cps->use_cuts = 0;
267.1036 +      cps->mip_gap = 0.0;
267.1037 +      return;
267.1038 +}
267.1039 +#endif
267.1040 +
267.1041 +#if 1 /* 17/XI-2009 */
267.1042 +static struct LPXCPS *access_parms(LPX *lp)
267.1043 +{     /* allocate and initialize control parameters, if necessary */
267.1044 +      if (lp->parms == NULL)
267.1045 +      {  lp->parms = xmalloc(sizeof(struct LPXCPS));
267.1046 +         reset_parms(lp);
267.1047 +      }
267.1048 +      return lp->parms;
267.1049 +}
267.1050 +#endif
267.1051 +
267.1052 +#if 1 /* 17/XI-2009 */
267.1053 +void lpx_reset_parms(LPX *lp)
267.1054 +{     /* reset control parameters to default values */
267.1055 +      access_parms(lp);
267.1056 +      reset_parms(lp);
267.1057 +      return;
267.1058 +}
267.1059 +#endif
267.1060 +
267.1061 +void lpx_set_int_parm(LPX *lp, int parm, int val)
267.1062 +{     /* set (change) integer control parameter */
267.1063 +#if 0 /* 17/XI-2009 */
267.1064 +      struct LPXCPS *cps = lp->cps;
267.1065 +#else
267.1066 +      struct LPXCPS *cps = access_parms(lp);
267.1067 +#endif
267.1068 +      switch (parm)
267.1069 +      {  case LPX_K_MSGLEV:
267.1070 +            if (!(0 <= val && val <= 3))
267.1071 +               xerror("lpx_set_int_parm: MSGLEV = %d; invalid value\n",
267.1072 +                  val);
267.1073 +            cps->msg_lev = val;
267.1074 +            break;
267.1075 +         case LPX_K_SCALE:
267.1076 +            if (!(0 <= val && val <= 3))
267.1077 +               xerror("lpx_set_int_parm: SCALE = %d; invalid value\n",
267.1078 +                  val);
267.1079 +            cps->scale = val;
267.1080 +            break;
267.1081 +         case LPX_K_DUAL:
267.1082 +            if (!(val == 0 || val == 1))
267.1083 +               xerror("lpx_set_int_parm: DUAL = %d; invalid value\n",
267.1084 +                  val);
267.1085 +            cps->dual = val;
267.1086 +            break;
267.1087 +         case LPX_K_PRICE:
267.1088 +            if (!(val == 0 || val == 1))
267.1089 +               xerror("lpx_set_int_parm: PRICE = %d; invalid value\n",
267.1090 +                  val);
267.1091 +            cps->price = val;
267.1092 +            break;
267.1093 +         case LPX_K_ROUND:
267.1094 +            if (!(val == 0 || val == 1))
267.1095 +               xerror("lpx_set_int_parm: ROUND = %d; invalid value\n",
267.1096 +                  val);
267.1097 +            cps->round = val;
267.1098 +            break;
267.1099 +         case LPX_K_ITLIM:
267.1100 +            cps->it_lim = val;
267.1101 +            break;
267.1102 +         case LPX_K_ITCNT:
267.1103 +            lp->it_cnt = val;
267.1104 +            break;
267.1105 +         case LPX_K_OUTFRQ:
267.1106 +            if (!(val > 0))
267.1107 +               xerror("lpx_set_int_parm: OUTFRQ = %d; invalid value\n",
267.1108 +                  val);
267.1109 +            cps->out_frq = val;
267.1110 +            break;
267.1111 +         case LPX_K_BRANCH:
267.1112 +            if (!(val == 0 || val == 1 || val == 2 || val == 3))
267.1113 +               xerror("lpx_set_int_parm: BRANCH = %d; invalid value\n",
267.1114 +                  val);
267.1115 +            cps->branch = val;
267.1116 +            break;
267.1117 +         case LPX_K_BTRACK:
267.1118 +            if (!(val == 0 || val == 1 || val == 2 || val == 3))
267.1119 +               xerror("lpx_set_int_parm: BTRACK = %d; invalid value\n",
267.1120 +                  val);
267.1121 +            cps->btrack = val;
267.1122 +            break;
267.1123 +         case LPX_K_MPSINFO:
267.1124 +            if (!(val == 0 || val == 1))
267.1125 +               xerror("lpx_set_int_parm: MPSINFO = %d; invalid value\n",
267.1126 +                  val);
267.1127 +            cps->mps_info = val;
267.1128 +            break;
267.1129 +         case LPX_K_MPSOBJ:
267.1130 +            if (!(val == 0 || val == 1 || val == 2))
267.1131 +               xerror("lpx_set_int_parm: MPSOBJ = %d; invalid value\n",
267.1132 +                  val);
267.1133 +            cps->mps_obj = val;
267.1134 +            break;
267.1135 +         case LPX_K_MPSORIG:
267.1136 +            if (!(val == 0 || val == 1))
267.1137 +               xerror("lpx_set_int_parm: MPSORIG = %d; invalid value\n",
267.1138 +                  val);
267.1139 +            cps->mps_orig = val;
267.1140 +            break;
267.1141 +         case LPX_K_MPSWIDE:
267.1142 +            if (!(val == 0 || val == 1))
267.1143 +               xerror("lpx_set_int_parm: MPSWIDE = %d; invalid value\n",
267.1144 +                  val);
267.1145 +            cps->mps_wide = val;
267.1146 +            break;
267.1147 +         case LPX_K_MPSFREE:
267.1148 +            if (!(val == 0 || val == 1))
267.1149 +               xerror("lpx_set_int_parm: MPSFREE = %d; invalid value\n",
267.1150 +                  val);
267.1151 +            cps->mps_free = val;
267.1152 +            break;
267.1153 +         case LPX_K_MPSSKIP:
267.1154 +            if (!(val == 0 || val == 1))
267.1155 +               xerror("lpx_set_int_parm: MPSSKIP = %d; invalid value\n",
267.1156 +                  val);
267.1157 +            cps->mps_skip = val;
267.1158 +            break;
267.1159 +         case LPX_K_LPTORIG:
267.1160 +            if (!(val == 0 || val == 1))
267.1161 +               xerror("lpx_set_int_parm: LPTORIG = %d; invalid value\n",
267.1162 +                  val);
267.1163 +            cps->lpt_orig = val;
267.1164 +            break;
267.1165 +         case LPX_K_PRESOL:
267.1166 +            if (!(val == 0 || val == 1))
267.1167 +               xerror("lpx_set_int_parm: PRESOL = %d; invalid value\n",
267.1168 +                  val);
267.1169 +            cps->presol = val;
267.1170 +            break;
267.1171 +         case LPX_K_BINARIZE:
267.1172 +            if (!(val == 0 || val == 1))
267.1173 +               xerror("lpx_set_int_parm: BINARIZE = %d; invalid value\n"
267.1174 +                  , val);
267.1175 +            cps->binarize = val;
267.1176 +            break;
267.1177 +         case LPX_K_USECUTS:
267.1178 +            if (val & ~LPX_C_ALL)
267.1179 +            xerror("lpx_set_int_parm: USECUTS = 0x%X; invalid value\n",
267.1180 +                  val);
267.1181 +            cps->use_cuts = val;
267.1182 +            break;
267.1183 +         case LPX_K_BFTYPE:
267.1184 +#if 0
267.1185 +            if (!(1 <= val && val <= 3))
267.1186 +               xerror("lpx_set_int_parm: BFTYPE = %d; invalid value\n",
267.1187 +                  val);
267.1188 +            cps->bf_type = val;
267.1189 +#else
267.1190 +            {  glp_bfcp parm;
267.1191 +               glp_get_bfcp(lp, &parm);
267.1192 +               switch (val)
267.1193 +               {  case 1:
267.1194 +                     parm.type = GLP_BF_FT; break;
267.1195 +                  case 2:
267.1196 +                     parm.type = GLP_BF_BG; break;
267.1197 +                  case 3:
267.1198 +                     parm.type = GLP_BF_GR; break;
267.1199 +                  default:
267.1200 +                     xerror("lpx_set_int_parm: BFTYPE = %d; invalid val"
267.1201 +                        "ue\n", val);
267.1202 +               }
267.1203 +               glp_set_bfcp(lp, &parm);
267.1204 +            }
267.1205 +#endif
267.1206 +            break;
267.1207 +         default:
267.1208 +            xerror("lpx_set_int_parm: parm = %d; invalid parameter\n",
267.1209 +               parm);
267.1210 +      }
267.1211 +      return;
267.1212 +}
267.1213 +
267.1214 +int lpx_get_int_parm(LPX *lp, int parm)
267.1215 +{     /* query integer control parameter */
267.1216 +#if 0 /* 17/XI-2009 */
267.1217 +      struct LPXCPS *cps = lp->cps;
267.1218 +#else
267.1219 +      struct LPXCPS *cps = access_parms(lp);
267.1220 +#endif
267.1221 +      int val = 0;
267.1222 +      switch (parm)
267.1223 +      {  case LPX_K_MSGLEV:
267.1224 +            val = cps->msg_lev; break;
267.1225 +         case LPX_K_SCALE:
267.1226 +            val = cps->scale; break;
267.1227 +         case LPX_K_DUAL:
267.1228 +            val = cps->dual; break;
267.1229 +         case LPX_K_PRICE:
267.1230 +            val = cps->price; break;
267.1231 +         case LPX_K_ROUND:
267.1232 +            val = cps->round; break;
267.1233 +         case LPX_K_ITLIM:
267.1234 +            val = cps->it_lim; break;
267.1235 +         case LPX_K_ITCNT:
267.1236 +            val = lp->it_cnt; break;
267.1237 +         case LPX_K_OUTFRQ:
267.1238 +            val = cps->out_frq; break;
267.1239 +         case LPX_K_BRANCH:
267.1240 +            val = cps->branch; break;
267.1241 +         case LPX_K_BTRACK:
267.1242 +            val = cps->btrack; break;
267.1243 +         case LPX_K_MPSINFO:
267.1244 +            val = cps->mps_info; break;
267.1245 +         case LPX_K_MPSOBJ:
267.1246 +            val = cps->mps_obj; break;
267.1247 +         case LPX_K_MPSORIG:
267.1248 +            val = cps->mps_orig; break;
267.1249 +         case LPX_K_MPSWIDE:
267.1250 +            val = cps->mps_wide; break;
267.1251 +         case LPX_K_MPSFREE:
267.1252 +            val = cps->mps_free; break;
267.1253 +         case LPX_K_MPSSKIP:
267.1254 +            val = cps->mps_skip; break;
267.1255 +         case LPX_K_LPTORIG:
267.1256 +            val = cps->lpt_orig; break;
267.1257 +         case LPX_K_PRESOL:
267.1258 +            val = cps->presol; break;
267.1259 +         case LPX_K_BINARIZE:
267.1260 +            val = cps->binarize; break;
267.1261 +         case LPX_K_USECUTS:
267.1262 +            val = cps->use_cuts; break;
267.1263 +         case LPX_K_BFTYPE:
267.1264 +#if 0
267.1265 +            val = cps->bf_type; break;
267.1266 +#else
267.1267 +            {  glp_bfcp parm;
267.1268 +               glp_get_bfcp(lp, &parm);
267.1269 +               switch (parm.type)
267.1270 +               {  case GLP_BF_FT:
267.1271 +                     val = 1; break;
267.1272 +                  case GLP_BF_BG:
267.1273 +                     val = 2; break;
267.1274 +                  case GLP_BF_GR:
267.1275 +                     val = 3; break;
267.1276 +                  default:
267.1277 +                     xassert(lp != lp);
267.1278 +               }
267.1279 +            }
267.1280 +            break;
267.1281 +#endif
267.1282 +         default:
267.1283 +            xerror("lpx_get_int_parm: parm = %d; invalid parameter\n",
267.1284 +               parm);
267.1285 +      }
267.1286 +      return val;
267.1287 +}
267.1288 +
267.1289 +void lpx_set_real_parm(LPX *lp, int parm, double val)
267.1290 +{     /* set (change) real control parameter */
267.1291 +#if 0 /* 17/XI-2009 */
267.1292 +      struct LPXCPS *cps = lp->cps;
267.1293 +#else
267.1294 +      struct LPXCPS *cps = access_parms(lp);
267.1295 +#endif
267.1296 +      switch (parm)
267.1297 +      {  case LPX_K_RELAX:
267.1298 +            if (!(0.0 <= val && val <= 1.0))
267.1299 +               xerror("lpx_set_real_parm: RELAX = %g; invalid value\n",
267.1300 +                  val);
267.1301 +            cps->relax = val;
267.1302 +            break;
267.1303 +         case LPX_K_TOLBND:
267.1304 +            if (!(DBL_EPSILON <= val && val <= 0.001))
267.1305 +               xerror("lpx_set_real_parm: TOLBND = %g; invalid value\n",
267.1306 +                  val);
267.1307 +#if 0
267.1308 +            if (cps->tol_bnd > val)
267.1309 +            {  /* invalidate the basic solution */
267.1310 +               lp->p_stat = LPX_P_UNDEF;
267.1311 +               lp->d_stat = LPX_D_UNDEF;
267.1312 +            }
267.1313 +#endif
267.1314 +            cps->tol_bnd = val;
267.1315 +            break;
267.1316 +         case LPX_K_TOLDJ:
267.1317 +            if (!(DBL_EPSILON <= val && val <= 0.001))
267.1318 +               xerror("lpx_set_real_parm: TOLDJ = %g; invalid value\n",
267.1319 +                  val);
267.1320 +#if 0
267.1321 +            if (cps->tol_dj > val)
267.1322 +            {  /* invalidate the basic solution */
267.1323 +               lp->p_stat = LPX_P_UNDEF;
267.1324 +               lp->d_stat = LPX_D_UNDEF;
267.1325 +            }
267.1326 +#endif
267.1327 +            cps->tol_dj = val;
267.1328 +            break;
267.1329 +         case LPX_K_TOLPIV:
267.1330 +            if (!(DBL_EPSILON <= val && val <= 0.001))
267.1331 +               xerror("lpx_set_real_parm: TOLPIV = %g; invalid value\n",
267.1332 +                  val);
267.1333 +            cps->tol_piv = val;
267.1334 +            break;
267.1335 +         case LPX_K_OBJLL:
267.1336 +            cps->obj_ll = val;
267.1337 +            break;
267.1338 +         case LPX_K_OBJUL:
267.1339 +            cps->obj_ul = val;
267.1340 +            break;
267.1341 +         case LPX_K_TMLIM:
267.1342 +            cps->tm_lim = val;
267.1343 +            break;
267.1344 +         case LPX_K_OUTDLY:
267.1345 +            cps->out_dly = val;
267.1346 +            break;
267.1347 +         case LPX_K_TOLINT:
267.1348 +            if (!(DBL_EPSILON <= val && val <= 0.001))
267.1349 +               xerror("lpx_set_real_parm: TOLINT = %g; invalid value\n",
267.1350 +                  val);
267.1351 +            cps->tol_int = val;
267.1352 +            break;
267.1353 +         case LPX_K_TOLOBJ:
267.1354 +            if (!(DBL_EPSILON <= val && val <= 0.001))
267.1355 +               xerror("lpx_set_real_parm: TOLOBJ = %g; invalid value\n",
267.1356 +                  val);
267.1357 +            cps->tol_obj = val;
267.1358 +            break;
267.1359 +         case LPX_K_MIPGAP:
267.1360 +            if (val < 0.0)
267.1361 +               xerror("lpx_set_real_parm: MIPGAP = %g; invalid value\n",
267.1362 +                  val);
267.1363 +            cps->mip_gap = val;
267.1364 +            break;
267.1365 +         default:
267.1366 +            xerror("lpx_set_real_parm: parm = %d; invalid parameter\n",
267.1367 +               parm);
267.1368 +      }
267.1369 +      return;
267.1370 +}
267.1371 +
267.1372 +double lpx_get_real_parm(LPX *lp, int parm)
267.1373 +{     /* query real control parameter */
267.1374 +#if 0 /* 17/XI-2009 */
267.1375 +      struct LPXCPS *cps = lp->cps;
267.1376 +#else
267.1377 +      struct LPXCPS *cps = access_parms(lp);
267.1378 +#endif
267.1379 +      double val = 0.0;
267.1380 +      switch (parm)
267.1381 +      {  case LPX_K_RELAX:
267.1382 +            val = cps->relax;
267.1383 +            break;
267.1384 +         case LPX_K_TOLBND:
267.1385 +            val = cps->tol_bnd;
267.1386 +            break;
267.1387 +         case LPX_K_TOLDJ:
267.1388 +            val = cps->tol_dj;
267.1389 +            break;
267.1390 +         case LPX_K_TOLPIV:
267.1391 +            val = cps->tol_piv;
267.1392 +            break;
267.1393 +         case LPX_K_OBJLL:
267.1394 +            val = cps->obj_ll;
267.1395 +            break;
267.1396 +         case LPX_K_OBJUL:
267.1397 +            val = cps->obj_ul;
267.1398 +            break;
267.1399 +         case LPX_K_TMLIM:
267.1400 +            val = cps->tm_lim;
267.1401 +            break;
267.1402 +         case LPX_K_OUTDLY:
267.1403 +            val = cps->out_dly;
267.1404 +            break;
267.1405 +         case LPX_K_TOLINT:
267.1406 +            val = cps->tol_int;
267.1407 +            break;
267.1408 +         case LPX_K_TOLOBJ:
267.1409 +            val = cps->tol_obj;
267.1410 +            break;
267.1411 +         case LPX_K_MIPGAP:
267.1412 +            val = cps->mip_gap;
267.1413 +            break;
267.1414 +         default:
267.1415 +            xerror("lpx_get_real_parm: parm = %d; invalid parameter\n",
267.1416 +               parm);
267.1417 +      }
267.1418 +      return val;
267.1419 +}
267.1420 +
267.1421 +LPX *lpx_read_mps(const char *fname)
267.1422 +{     /* read problem data in fixed MPS format */
267.1423 +      LPX *lp = lpx_create_prob();
267.1424 +      if (glp_read_mps(lp, GLP_MPS_DECK, NULL, fname))
267.1425 +         lpx_delete_prob(lp), lp = NULL;
267.1426 +      return lp;
267.1427 +}
267.1428 +
267.1429 +int lpx_write_mps(LPX *lp, const char *fname)
267.1430 +{     /* write problem data in fixed MPS format */
267.1431 +      return glp_write_mps(lp, GLP_MPS_DECK, NULL, fname);
267.1432 +}
267.1433 +
267.1434 +int lpx_read_bas(LPX *lp, const char *fname)
267.1435 +{     /* read LP basis in fixed MPS format */
267.1436 +#if 0 /* 13/IV-2009 */
267.1437 +      return read_bas(lp, fname);
267.1438 +#else
267.1439 +      xassert(lp == lp);
267.1440 +      xassert(fname == fname);
267.1441 +      xerror("lpx_read_bas: operation not supported\n");
267.1442 +      return 0;
267.1443 +#endif
267.1444 +}
267.1445 +
267.1446 +int lpx_write_bas(LPX *lp, const char *fname)
267.1447 +{     /* write LP basis in fixed MPS format */
267.1448 +#if 0 /* 13/IV-2009 */
267.1449 +      return write_bas(lp, fname);
267.1450 +#else
267.1451 +      xassert(lp == lp);
267.1452 +      xassert(fname == fname);
267.1453 +      xerror("lpx_write_bas: operation not supported\n");
267.1454 +      return 0;
267.1455 +#endif
267.1456 +}
267.1457 +
267.1458 +LPX *lpx_read_freemps(const char *fname)
267.1459 +{     /* read problem data in free MPS format */
267.1460 +      LPX *lp = lpx_create_prob();
267.1461 +      if (glp_read_mps(lp, GLP_MPS_FILE, NULL, fname))
267.1462 +         lpx_delete_prob(lp), lp = NULL;
267.1463 +      return lp;
267.1464 +}
267.1465 +
267.1466 +int lpx_write_freemps(LPX *lp, const char *fname)
267.1467 +{     /* write problem data in free MPS format */
267.1468 +      return glp_write_mps(lp, GLP_MPS_FILE, NULL, fname);
267.1469 +}
267.1470 +
267.1471 +LPX *lpx_read_cpxlp(const char *fname)
267.1472 +{     /* read problem data in CPLEX LP format */
267.1473 +      LPX *lp;
267.1474 +      lp = lpx_create_prob();
267.1475 +      if (glp_read_lp(lp, NULL, fname))
267.1476 +         lpx_delete_prob(lp), lp = NULL;
267.1477 +      return lp;
267.1478 +}
267.1479 +
267.1480 +int lpx_write_cpxlp(LPX *lp, const char *fname)
267.1481 +{     /* write problem data in CPLEX LP format */
267.1482 +      return glp_write_lp(lp, NULL, fname);
267.1483 +}
267.1484 +
267.1485 +LPX *lpx_read_model(const char *model, const char *data, const char
267.1486 +      *output)
267.1487 +{     /* read LP/MIP model written in GNU MathProg language */
267.1488 +      LPX *lp = NULL;
267.1489 +      glp_tran *tran;
267.1490 +      /* allocate the translator workspace */
267.1491 +      tran = glp_mpl_alloc_wksp();
267.1492 +      /* read model section and optional data section */
267.1493 +      if (glp_mpl_read_model(tran, model, data != NULL)) goto done;
267.1494 +      /* read separate data section, if required */
267.1495 +      if (data != NULL)
267.1496 +         if (glp_mpl_read_data(tran, data)) goto done;
267.1497 +      /* generate the model */
267.1498 +      if (glp_mpl_generate(tran, output)) goto done;
267.1499 +      /* build the problem instance from the model */
267.1500 +      lp = glp_create_prob();
267.1501 +      glp_mpl_build_prob(tran, lp);
267.1502 +done: /* free the translator workspace */
267.1503 +      glp_mpl_free_wksp(tran);
267.1504 +      /* bring the problem object to the calling program */
267.1505 +      return lp;
267.1506 +}
267.1507 +
267.1508 +int lpx_print_prob(LPX *lp, const char *fname)
267.1509 +{     /* write problem data in plain text format */
267.1510 +      return glp_write_lp(lp, NULL, fname);
267.1511 +}
267.1512 +
267.1513 +int lpx_print_sol(LPX *lp, const char *fname)
267.1514 +{     /* write LP problem solution in printable format */
267.1515 +      return glp_print_sol(lp, fname);
267.1516 +}
267.1517 +
267.1518 +int lpx_print_sens_bnds(LPX *lp, const char *fname)
267.1519 +{     /* write bounds sensitivity information */
267.1520 +      if (glp_get_status(lp) == GLP_OPT && !glp_bf_exists(lp))
267.1521 +         glp_factorize(lp);
267.1522 +      return glp_print_ranges(lp, 0, NULL, 0, fname);
267.1523 +}
267.1524 +
267.1525 +int lpx_print_ips(LPX *lp, const char *fname)
267.1526 +{     /* write interior point solution in printable format */
267.1527 +      return glp_print_ipt(lp, fname);
267.1528 +}
267.1529 +
267.1530 +int lpx_print_mip(LPX *lp, const char *fname)
267.1531 +{     /* write MIP problem solution in printable format */
267.1532 +      return glp_print_mip(lp, fname);
267.1533 +}
267.1534 +
267.1535 +int lpx_is_b_avail(glp_prob *lp)
267.1536 +{     /* check if LP basis is available */
267.1537 +      return glp_bf_exists(lp);
267.1538 +}
267.1539 +
267.1540 +int lpx_main(int argc, const char *argv[])
267.1541 +{     /* stand-alone LP/MIP solver */
267.1542 +      return glp_main(argc, argv);
267.1543 +}
267.1544 +
267.1545 +/* eof */
   268.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
   268.2 +++ b/deps/glpk/src/glplpx02.c	Sun Nov 06 20:59:10 2011 +0100
   268.3 @@ -0,0 +1,264 @@
   268.4 +/* glplpx02.c */
   268.5 +
   268.6 +/***********************************************************************
   268.7 +*  This code is part of GLPK (GNU Linear Programming Kit).
   268.8 +*
   268.9 +*  Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008,
  268.10 +*  2009, 2010, 2011 Andrew Makhorin, Department for Applied Informatics,
  268.11 +*  Moscow Aviation Institute, Moscow, Russia. All rights reserved.
  268.12 +*  E-mail: <mao@gnu.org>.
  268.13 +*
  268.14 +*  GLPK is free software: you can redistribute it and/or modify it
  268.15 +*  under the terms of the GNU General Public License as published by
  268.16 +*  the Free Software Foundation, either version 3 of the License, or
  268.17 +*  (at your option) any later version.
  268.18 +*
  268.19 +*  GLPK is distributed in the hope that it will be useful, but WITHOUT
  268.20 +*  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
  268.21 +*  or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
  268.22 +*  License for more details.
  268.23 +*
  268.24 +*  You should have received a copy of the GNU General Public License
  268.25 +*  along with GLPK. If not, see <http://www.gnu.org/licenses/>.
  268.26 +***********************************************************************/
  268.27 +
  268.28 +#include "glpapi.h"
  268.29 +
  268.30 +/***********************************************************************
  268.31 +*  NAME
  268.32 +*
  268.33 +*  lpx_put_solution - store basic solution components
  268.34 +*
  268.35 +*  SYNOPSIS
  268.36 +*
  268.37 +*  void lpx_put_solution(glp_prob *lp, int inval, const int *p_stat,
  268.38 +*     const int *d_stat, const double *obj_val, const int r_stat[],
  268.39 +*     const double r_prim[], const double r_dual[], const int c_stat[],
  268.40 +*     const double c_prim[], const double c_dual[])
  268.41 +*
  268.42 +*  DESCRIPTION
  268.43 +*
  268.44 +*  The routine lpx_put_solution stores basic solution components to the
  268.45 +*  specified problem object.
  268.46 +*
  268.47 +*  The parameter inval is the basis factorization invalidity flag.
  268.48 +*  If this flag is clear, the current status of the basis factorization
  268.49 +*  remains unchanged. If this flag is set, the routine invalidates the
  268.50 +*  basis factorization.
  268.51 +*
  268.52 +*  The parameter p_stat is a pointer to the status of primal basic
  268.53 +*  solution, which should be specified as follows:
  268.54 +*
  268.55 +*  GLP_UNDEF  - primal solution is undefined;
  268.56 +*  GLP_FEAS   - primal solution is feasible;
  268.57 +*  GLP_INFEAS - primal solution is infeasible;
  268.58 +*  GLP_NOFEAS - no primal feasible solution exists.
  268.59 +*
  268.60 +*  If the parameter p_stat is NULL, the current status of primal basic
  268.61 +*  solution remains unchanged.
  268.62 +*
  268.63 +*  The parameter d_stat is a pointer to the status of dual basic
  268.64 +*  solution, which should be specified as follows:
  268.65 +*
  268.66 +*  GLP_UNDEF  - dual solution is undefined;
  268.67 +*  GLP_FEAS   - dual solution is feasible;
  268.68 +*  GLP_INFEAS - dual solution is infeasible;
  268.69 +*  GLP_NOFEAS - no dual feasible solution exists.
  268.70 +*
  268.71 +*  If the parameter d_stat is NULL, the current status of dual basic
  268.72 +*  solution remains unchanged.
  268.73 +*
  268.74 +*  The parameter obj_val is a pointer to the objective function value.
  268.75 +*  If it is NULL, the current value of the objective function remains
  268.76 +*  unchanged.
  268.77 +*
  268.78 +*  The array element r_stat[i], 1 <= i <= m (where m is the number of
  268.79 +*  rows in the problem object), specifies the status of i-th auxiliary
  268.80 +*  variable, which should be specified as follows:
  268.81 +*
  268.82 +*  GLP_BS - basic variable;
  268.83 +*  GLP_NL - non-basic variable on lower bound;
  268.84 +*  GLP_NU - non-basic variable on upper bound;
  268.85 +*  GLP_NF - non-basic free variable;
  268.86 +*  GLP_NS - non-basic fixed variable.
  268.87 +*
  268.88 +*  If the parameter r_stat is NULL, the current statuses of auxiliary
  268.89 +*  variables remain unchanged.
  268.90 +*
  268.91 +*  The array element r_prim[i], 1 <= i <= m (where m is the number of
  268.92 +*  rows in the problem object), specifies a primal value of i-th
  268.93 +*  auxiliary variable. If the parameter r_prim is NULL, the current
  268.94 +*  primal values of auxiliary variables remain unchanged.
  268.95 +*
  268.96 +*  The array element r_dual[i], 1 <= i <= m (where m is the number of
  268.97 +*  rows in the problem object), specifies a dual value (reduced cost)
  268.98 +*  of i-th auxiliary variable. If the parameter r_dual is NULL, the
  268.99 +*  current dual values of auxiliary variables remain unchanged.
 268.100 +*
 268.101 +*  The array element c_stat[j], 1 <= j <= n (where n is the number of
 268.102 +*  columns in the problem object), specifies the status of j-th
 268.103 +*  structural variable, which should be specified as follows:
 268.104 +*
 268.105 +*  GLP_BS - basic variable;
 268.106 +*  GLP_NL - non-basic variable on lower bound;
 268.107 +*  GLP_NU - non-basic variable on upper bound;
 268.108 +*  GLP_NF - non-basic free variable;
 268.109 +*  GLP_NS - non-basic fixed variable.
 268.110 +*
 268.111 +*  If the parameter c_stat is NULL, the current statuses of structural
 268.112 +*  variables remain unchanged.
 268.113 +*
 268.114 +*  The array element c_prim[j], 1 <= j <= n (where n is the number of
 268.115 +*  columns in the problem object), specifies a primal value of j-th
 268.116 +*  structural variable. If the parameter c_prim is NULL, the current
 268.117 +*  primal values of structural variables remain unchanged.
 268.118 +*
 268.119 +*  The array element c_dual[j], 1 <= j <= n (where n is the number of
 268.120 +*  columns in the problem object), specifies a dual value (reduced cost)
 268.121 +*  of j-th structural variable. If the parameter c_dual is NULL, the
 268.122 +*  current dual values of structural variables remain unchanged. */
 268.123 +
 268.124 +void lpx_put_solution(glp_prob *lp, int inval, const int *p_stat,
 268.125 +      const int *d_stat, const double *obj_val, const int r_stat[],
 268.126 +      const double r_prim[], const double r_dual[], const int c_stat[],
 268.127 +      const double c_prim[], const double c_dual[])
 268.128 +{     GLPROW *row;
 268.129 +      GLPCOL *col;
 268.130 +      int i, j;
 268.131 +      /* invalidate the basis factorization, if required */
 268.132 +      if (inval) lp->valid = 0;
 268.133 +      /* store primal status */
 268.134 +      if (p_stat != NULL)
 268.135 +      {  if (!(*p_stat == GLP_UNDEF  || *p_stat == GLP_FEAS ||
 268.136 +               *p_stat == GLP_INFEAS || *p_stat == GLP_NOFEAS))
 268.137 +            xerror("lpx_put_solution: p_stat = %d; invalid primal statu"
 268.138 +               "s\n", *p_stat);
 268.139 +         lp->pbs_stat = *p_stat;
 268.140 +      }
 268.141 +      /* store dual status */
 268.142 +      if (d_stat != NULL)
 268.143 +      {  if (!(*d_stat == GLP_UNDEF  || *d_stat == GLP_FEAS ||
 268.144 +               *d_stat == GLP_INFEAS || *d_stat == GLP_NOFEAS))
 268.145 +            xerror("lpx_put_solution: d_stat = %d; invalid dual status "
 268.146 +               "\n", *d_stat);
 268.147 +         lp->dbs_stat = *d_stat;
 268.148 +      }
 268.149 +      /* store objective function value */
 268.150 +      if (obj_val != NULL) lp->obj_val = *obj_val;
 268.151 +      /* store row solution components */
 268.152 +      for (i = 1; i <= lp->m; i++)
 268.153 +      {  row = lp->row[i];
 268.154 +         if (r_stat != NULL)
 268.155 +         {  if (!(r_stat[i] == GLP_BS ||
 268.156 +                  row->type == GLP_FR && r_stat[i] == GLP_NF ||
 268.157 +                  row->type == GLP_LO && r_stat[i] == GLP_NL ||
 268.158 +                  row->type == GLP_UP && r_stat[i] == GLP_NU ||
 268.159 +                  row->type == GLP_DB && r_stat[i] == GLP_NL ||
 268.160 +                  row->type == GLP_DB && r_stat[i] == GLP_NU ||
 268.161 +                  row->type == GLP_FX && r_stat[i] == GLP_NS))
 268.162 +               xerror("lpx_put_solution: r_stat[%d] = %d; invalid row s"
 268.163 +                  "tatus\n", i, r_stat[i]);
 268.164 +            row->stat = r_stat[i];
 268.165 +         }
 268.166 +         if (r_prim != NULL) row->prim = r_prim[i];
 268.167 +         if (r_dual != NULL) row->dual = r_dual[i];
 268.168 +      }
 268.169 +      /* store column solution components */
 268.170 +      for (j = 1; j <= lp->n; j++)
 268.171 +      {  col = lp->col[j];
 268.172 +         if (c_stat != NULL)
 268.173 +         {  if (!(c_stat[j] == GLP_BS ||
 268.174 +                  col->type == GLP_FR && c_stat[j] == GLP_NF ||
 268.175 +                  col->type == GLP_LO && c_stat[j] == GLP_NL ||
 268.176 +                  col->type == GLP_UP && c_stat[j] == GLP_NU ||
 268.177 +                  col->type == GLP_DB && c_stat[j] == GLP_NL ||
 268.178 +                  col->type == GLP_DB && c_stat[j] == GLP_NU ||
 268.179 +                  col->type == GLP_FX && c_stat[j] == GLP_NS))
 268.180 +               xerror("lpx_put_solution: c_stat[%d] = %d; invalid colum"
 268.181 +                  "n status\n", j, c_stat[j]);
 268.182 +            col->stat = c_stat[j];
 268.183 +         }
 268.184 +         if (c_prim != NULL) col->prim = c_prim[j];
 268.185 +         if (c_dual != NULL) col->dual = c_dual[j];
 268.186 +      }
 268.187 +      return;
 268.188 +}
 268.189 +
 268.190 +/*----------------------------------------------------------------------
 268.191 +-- lpx_put_mip_soln - store mixed integer solution components.
 268.192 +--
 268.193 +-- *Synopsis*
 268.194 +--
 268.195 +-- #include "glplpx.h"
 268.196 +-- void lpx_put_mip_soln(glp_prob *lp, int i_stat, double row_mipx[],
 268.197 +--    double col_mipx[]);
 268.198 +--
 268.199 +-- *Description*
 268.200 +--
 268.201 +-- The routine lpx_put_mip_soln stores solution components obtained by
 268.202 +-- branch-and-bound solver into the specified problem object.
 268.203 +--
 268.204 +-- NOTE: This routine is intended for internal use only. */
 268.205 +
 268.206 +void lpx_put_mip_soln(glp_prob *lp, int i_stat, double row_mipx[],
 268.207 +      double col_mipx[])
 268.208 +{     GLPROW *row;
 268.209 +      GLPCOL *col;
 268.210 +      int i, j;
 268.211 +      double sum;
 268.212 +      /* store mixed integer status */
 268.213 +#if 0
 268.214 +      if (!(i_stat == LPX_I_UNDEF || i_stat == LPX_I_OPT ||
 268.215 +            i_stat == LPX_I_FEAS  || i_stat == LPX_I_NOFEAS))
 268.216 +         fault("lpx_put_mip_soln: i_stat = %d; invalid mixed integer st"
 268.217 +            "atus", i_stat);
 268.218 +      lp->i_stat = i_stat;
 268.219 +#else
 268.220 +      switch (i_stat)
 268.221 +      {  case LPX_I_UNDEF:
 268.222 +            lp->mip_stat = GLP_UNDEF; break;
 268.223 +         case LPX_I_OPT:
 268.224 +            lp->mip_stat = GLP_OPT;  break;
 268.225 +         case LPX_I_FEAS:
 268.226 +            lp->mip_stat = GLP_FEAS; break;
 268.227 +         case LPX_I_NOFEAS:
 268.228 +            lp->mip_stat = GLP_NOFEAS; break;
 268.229 +         default:
 268.230 +            xerror("lpx_put_mip_soln: i_stat = %d; invalid mixed intege"
 268.231 +               "r status\n", i_stat);
 268.232 +      }
 268.233 +#endif
 268.234 +      /* store row solution components */
 268.235 +      if (row_mipx != NULL)
 268.236 +      {  for (i = 1; i <= lp->m; i++)
 268.237 +         {  row = lp->row[i];
 268.238 +            row->mipx = row_mipx[i];
 268.239 +         }
 268.240 +      }
 268.241 +      /* store column solution components */
 268.242 +      if (col_mipx != NULL)
 268.243 +      {  for (j = 1; j <= lp->n; j++)
 268.244 +         {  col = lp->col[j];
 268.245 +            col->mipx = col_mipx[j];
 268.246 +         }
 268.247 +      }
 268.248 +      /* if the solution is claimed to be integer feasible, check it */
 268.249 +      if (lp->mip_stat == GLP_OPT || lp->mip_stat == GLP_FEAS)
 268.250 +      {  for (j = 1; j <= lp->n; j++)
 268.251 +         {  col = lp->col[j];
 268.252 +            if (col->kind == GLP_IV && col->mipx != floor(col->mipx))
 268.253 +               xerror("lpx_put_mip_soln: col_mipx[%d] = %.*g; must be i"
 268.254 +                  "ntegral\n", j, DBL_DIG, col->mipx);
 268.255 +         }
 268.256 +      }
 268.257 +      /* compute the objective function value */
 268.258 +      sum = lp->c0;
 268.259 +      for (j = 1; j <= lp->n; j++)
 268.260 +      {  col = lp->col[j];
 268.261 +         sum += col->coef * col->mipx;
 268.262 +      }
 268.263 +      lp->mip_obj = sum;
 268.264 +      return;
 268.265 +}
 268.266 +
 268.267 +/* eof */
   269.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
   269.2 +++ b/deps/glpk/src/glplpx03.c	Sun Nov 06 20:59:10 2011 +0100
   269.3 @@ -0,0 +1,302 @@
   269.4 +/* glplpx03.c (OPB format) */
   269.5 +
   269.6 +/***********************************************************************
   269.7 +*  This code is part of GLPK (GNU Linear Programming Kit).
   269.8 +*
   269.9 +*  Author: Oscar Gustafsson <oscarg@isy.liu.se>.
  269.10 +*
  269.11 +*  Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008,
  269.12 +*  2009, 2010, 2011 Andrew Makhorin, Department for Applied Informatics,
  269.13 +*  Moscow Aviation Institute, Moscow, Russia. All rights reserved.
  269.14 +*  E-mail: <mao@gnu.org>.
  269.15 +*
  269.16 +*  GLPK is free software: you can redistribute it and/or modify it
  269.17 +*  under the terms of the GNU General Public License as published by
  269.18 +*  the Free Software Foundation, either version 3 of the License, or
  269.19 +*  (at your option) any later version.
  269.20 +*
  269.21 +*  GLPK is distributed in the hope that it will be useful, but WITHOUT
  269.22 +*  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
  269.23 +*  or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
  269.24 +*  License for more details.
  269.25 +*
  269.26 +*  You should have received a copy of the GNU General Public License
  269.27 +*  along with GLPK. If not, see <http://www.gnu.org/licenses/>.
  269.28 +***********************************************************************/
  269.29 +
  269.30 +#define _GLPSTD_ERRNO
  269.31 +#define _GLPSTD_STDIO
  269.32 +#include "glpapi.h"
  269.33 +#if 0 /* 24/XII-2009; by mao */
  269.34 +#include "glpipp.h"
  269.35 +#endif
  269.36 +
  269.37 +/*----------------------------------------------------------------------
  269.38 +-- lpx_write_pb - write problem data in (normalized) OPB format.
  269.39 +--
  269.40 +-- *Synopsis*
  269.41 +--
  269.42 +-- #include "glplpx.h"
  269.43 +-- int lpx_write_pb(LPX *lp, const char *fname, int normalized,
  269.44 +--    int binarize);
  269.45 +--
  269.46 +-- *Description*
  269.47 +--
  269.48 +-- The routine lpx_write_pb writes problem data in OPB format
  269.49 +-- to an output text file whose name is the character string fname.
  269.50 +-- If normalized is non-zero the output will be generated in a
  269.51 +-- normalized form with sequentially numbered variables, x1, x2 etc.
  269.52 +-- If binarize, any integer variable will be repalzec by binary ones,
  269.53 +-- see ipp_binarize
  269.54 +--
  269.55 +-- *Returns*
  269.56 +--
  269.57 +-- If the operation was successful, the routine returns zero. Otherwise
  269.58 +-- the routine prints an error message and returns non-zero. */
  269.59 +
  269.60 +#if 1 /* 24/XII-2009; by mao (disabled, because IPP was removed) */
  269.61 +int lpx_write_pb(LPX *lp, const char *fname, int normalized,
  269.62 +      int binarize)
  269.63 +{     xassert(lp == lp);
  269.64 +      xassert(fname == fname);
  269.65 +      xassert(normalized == normalized);
  269.66 +      xassert(binarize == binarize);
  269.67 +      xprintf("lpx_write_pb: sorry, currently this operation is not ava"
  269.68 +         "ilable\n");
  269.69 +      return 1;
  269.70 +}
  269.71 +#else
  269.72 +int lpx_write_pb(LPX *lp, const char *fname, int normalized,
  269.73 +      int binarize)
  269.74 +{
  269.75 +  FILE* fp;
  269.76 +  int m,n,i,j,k,o,nonfree=0, obj_dir, dbl, *ndx, row_type, emptylhs=0;
  269.77 +  double coeff, *val, bound, constant/*=0.0*/;
  269.78 +  char* objconstname = "dummy_one";
  269.79 +  char* emptylhsname = "dummy_zero";
  269.80 +
  269.81 +  /* Variables needed for possible binarization */
  269.82 +  /*LPX* tlp;*/
  269.83 +  IPP *ipp = NULL;
  269.84 +  /*tlp=lp;*/
  269.85 +
  269.86 +  if(binarize) /* Transform integer variables to binary ones */
  269.87 +    {
  269.88 +      ipp = ipp_create_wksp();
  269.89 +      ipp_load_orig(ipp, lp);
  269.90 +      ipp_binarize(ipp);
  269.91 +      lp = ipp_build_prob(ipp);
  269.92 +    }
  269.93 +  fp = fopen(fname, "w");
  269.94 +
  269.95 +  if(fp!= NULL)
  269.96 +    {
  269.97 +      xprintf(
  269.98 +          "lpx_write_pb: writing problem in %sOPB format to `%s'...\n",
  269.99 +              (normalized?"normalized ":""), fname);
 269.100 +
 269.101 +      m = glp_get_num_rows(lp);
 269.102 +      n = glp_get_num_cols(lp);
 269.103 +      for(i=1;i<=m;i++)
 269.104 +        {
 269.105 +          switch(glp_get_row_type(lp,i))
 269.106 +            {
 269.107 +            case GLP_LO:
 269.108 +            case GLP_UP:
 269.109 +            case GLP_FX:
 269.110 +              {
 269.111 +                nonfree += 1;
 269.112 +                break;
 269.113 +              }
 269.114 +            case GLP_DB:
 269.115 +              {
 269.116 +                nonfree += 2;
 269.117 +                break;
 269.118 +              }
 269.119 +            }
 269.120 +        }
 269.121 +      constant=glp_get_obj_coef(lp,0);
 269.122 +      fprintf(fp,"* #variables = %d #constraints = %d\n",
 269.123 +         n + (constant == 0?1:0), nonfree + (constant == 0?1:0));
 269.124 +      /* Objective function */
 269.125 +      obj_dir = glp_get_obj_dir(lp);
 269.126 +      fprintf(fp,"min: ");
 269.127 +      for(i=1;i<=n;i++)
 269.128 +        {
 269.129 +          coeff = glp_get_obj_coef(lp,i);
 269.130 +          if(coeff != 0.0)
 269.131 +            {
 269.132 +              if(obj_dir == GLP_MAX)
 269.133 +                coeff=-coeff;
 269.134 +              if(normalized)
 269.135 +                fprintf(fp, " %d x%d", (int)coeff, i);
 269.136 +              else
 269.137 +                fprintf(fp, " %d*%s", (int)coeff,
 269.138 +                  glp_get_col_name(lp,i));
 269.139 +
 269.140 +            }
 269.141 +        }
 269.142 +      if(constant)
 269.143 +        {
 269.144 +          if(normalized)
 269.145 +            fprintf(fp, " %d x%d", (int)constant, n+1);
 269.146 +          else
 269.147 +            fprintf(fp, " %d*%s", (int)constant, objconstname);
 269.148 +        }
 269.149 +      fprintf(fp,";\n");
 269.150 +
 269.151 +      if(normalized && !binarize)  /* Name substitution */
 269.152 +        {
 269.153 +          fprintf(fp,"* Variable name substitution:\n");
 269.154 +          for(j=1;j<=n;j++)
 269.155 +            {
 269.156 +              fprintf(fp, "* x%d = %s\n", j, glp_get_col_name(lp,j));
 269.157 +            }
 269.158 +          if(constant)
 269.159 +            fprintf(fp, "* x%d = %s\n", n+1, objconstname);
 269.160 +        }
 269.161 +
 269.162 +      ndx = xcalloc(1+n, sizeof(int));
 269.163 +      val = xcalloc(1+n, sizeof(double));
 269.164 +
 269.165 +      /* Constraints */
 269.166 +      for(j=1;j<=m;j++)
 269.167 +        {
 269.168 +          row_type=glp_get_row_type(lp,j);
 269.169 +          if(row_type!=GLP_FR)
 269.170 +            {
 269.171 +              if(row_type == GLP_DB)
 269.172 +                {
 269.173 +                  dbl=2;
 269.174 +                  row_type = GLP_UP;
 269.175 +                }
 269.176 +              else
 269.177 +                {
 269.178 +                  dbl=1;
 269.179 +                }
 269.180 +              k=glp_get_mat_row(lp, j, ndx, val);
 269.181 +              for(o=1;o<=dbl;o++)
 269.182 +                {
 269.183 +                  if(o==2)
 269.184 +                    {
 269.185 +                      row_type = GLP_LO;
 269.186 +                    }
 269.187 +                  if(k==0) /* Empty LHS */
 269.188 +                    {
 269.189 +                      emptylhs = 1;
 269.190 +                      if(normalized)
 269.191 +                        {
 269.192 +                          fprintf(fp, "0 x%d ", n+2);
 269.193 +                        }
 269.194 +                      else
 269.195 +                        {
 269.196 +                          fprintf(fp, "0*%s ", emptylhsname);
 269.197 +                        }
 269.198 +                    }
 269.199 +
 269.200 +                  for(i=1;i<=k;i++)
 269.201 +                    {
 269.202 +                      if(val[i] != 0.0)
 269.203 +                        {
 269.204 +
 269.205 +                          if(normalized)
 269.206 +                            {
 269.207 +                              fprintf(fp, "%d x%d ",
 269.208 +              (row_type==GLP_UP)?(-(int)val[i]):((int)val[i]), ndx[i]);
 269.209 +                            }
 269.210 +                          else
 269.211 +                            {
 269.212 +                              fprintf(fp, "%d*%s ", (int)val[i],
 269.213 +                                      glp_get_col_name(lp,ndx[i]));
 269.214 +                            }
 269.215 +                        }
 269.216 +                    }
 269.217 +                  switch(row_type)
 269.218 +                    {
 269.219 +                    case GLP_LO:
 269.220 +                      {
 269.221 +                        fprintf(fp, ">=");
 269.222 +                        bound = glp_get_row_lb(lp,j);
 269.223 +                        break;
 269.224 +                      }
 269.225 +                    case GLP_UP:
 269.226 +                      {
 269.227 +                        if(normalized)
 269.228 +                          {
 269.229 +                            fprintf(fp, ">=");
 269.230 +                            bound = -glp_get_row_ub(lp,j);
 269.231 +                          }
 269.232 +                        else
 269.233 +                          {
 269.234 +                            fprintf(fp, "<=");
 269.235 +                            bound = glp_get_row_ub(lp,j);
 269.236 +                          }
 269.237 +
 269.238 +                        break;
 269.239 +                      }
 269.240 +                    case GLP_FX:
 269.241 +                      {
 269.242 +                        fprintf(fp, "=");
 269.243 +                        bound = glp_get_row_lb(lp,j);
 269.244 +                        break;
 269.245 +                      }
 269.246 +                    }
 269.247 +                  fprintf(fp," %d;\n",(int)bound);
 269.248 +                }
 269.249 +            }
 269.250 +        }
 269.251 +      xfree(ndx);
 269.252 +      xfree(val);
 269.253 +
 269.254 +      if(constant)
 269.255 +        {
 269.256 +          xprintf(
 269.257 +        "lpx_write_pb: adding constant objective function variable\n");
 269.258 +
 269.259 +          if(normalized)
 269.260 +            fprintf(fp, "1 x%d = 1;\n", n+1);
 269.261 +          else
 269.262 +            fprintf(fp, "1*%s = 1;\n", objconstname);
 269.263 +        }
 269.264 +      if(emptylhs)
 269.265 +        {
 269.266 +          xprintf(
 269.267 +            "lpx_write_pb: adding dummy variable for empty left-hand si"
 269.268 +            "de constraint\n");
 269.269 +
 269.270 +          if(normalized)
 269.271 +            fprintf(fp, "1 x%d = 0;\n", n+2);
 269.272 +          else
 269.273 +            fprintf(fp, "1*%s = 0;\n", emptylhsname);
 269.274 +        }
 269.275 +
 269.276 +    }
 269.277 +  else
 269.278 +    {
 269.279 +      xprintf("Problems opening file for writing: %s\n", fname);
 269.280 +      return(1);
 269.281 +    }
 269.282 +  fflush(fp);
 269.283 +  if (ferror(fp))
 269.284 +    {  xprintf("lpx_write_pb: can't write to `%s' - %s\n", fname,
 269.285 +               strerror(errno));
 269.286 +    goto fail;
 269.287 +    }
 269.288 +  fclose(fp);
 269.289 +
 269.290 +
 269.291 +  if(binarize)
 269.292 +    {
 269.293 +      /* delete the resultant problem object */
 269.294 +      if (lp != NULL) lpx_delete_prob(lp);
 269.295 +      /* delete MIP presolver workspace */
 269.296 +      if (ipp != NULL) ipp_delete_wksp(ipp);
 269.297 +      /*lp=tlp;*/
 269.298 +    }
 269.299 +  return 0;
 269.300 + fail: if (fp != NULL) fclose(fp);
 269.301 +  return 1;
 269.302 +}
 269.303 +#endif
 269.304 +
 269.305 +/* eof */
   270.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
   270.2 +++ b/deps/glpk/src/glpluf.c	Sun Nov 06 20:59:10 2011 +0100
   270.3 @@ -0,0 +1,1846 @@
   270.4 +/* glpluf.c (LU-factorization) */
   270.5 +
   270.6 +/***********************************************************************
   270.7 +*  This code is part of GLPK (GNU Linear Programming Kit).
   270.8 +*
   270.9 +*  Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008,
  270.10 +*  2009, 2010, 2011 Andrew Makhorin, Department for Applied Informatics,
  270.11 +*  Moscow Aviation Institute, Moscow, Russia. All rights reserved.
  270.12 +*  E-mail: <mao@gnu.org>.
  270.13 +*
  270.14 +*  GLPK is free software: you can redistribute it and/or modify it
  270.15 +*  under the terms of the GNU General Public License as published by
  270.16 +*  the Free Software Foundation, either version 3 of the License, or
  270.17 +*  (at your option) any later version.
  270.18 +*
  270.19 +*  GLPK is distributed in the hope that it will be useful, but WITHOUT
  270.20 +*  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
  270.21 +*  or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
  270.22 +*  License for more details.
  270.23 +*
  270.24 +*  You should have received a copy of the GNU General Public License
  270.25 +*  along with GLPK. If not, see <http://www.gnu.org/licenses/>.
  270.26 +***********************************************************************/
  270.27 +
  270.28 +#include "glpenv.h"
  270.29 +#include "glpluf.h"
  270.30 +#define xfault xerror
  270.31 +
  270.32 +/* CAUTION: DO NOT CHANGE THE LIMIT BELOW */
  270.33 +
  270.34 +#define N_MAX 100000000 /* = 100*10^6 */
  270.35 +/* maximal order of the original matrix */
  270.36 +
  270.37 +/***********************************************************************
  270.38 +*  NAME
  270.39 +*
  270.40 +*  luf_create_it - create LU-factorization
  270.41 +*
  270.42 +*  SYNOPSIS
  270.43 +*
  270.44 +*  #include "glpluf.h"
  270.45 +*  LUF *luf_create_it(void);
  270.46 +*
  270.47 +*  DESCRIPTION
  270.48 +*
  270.49 +*  The routine luf_create_it creates a program object, which represents
  270.50 +*  LU-factorization of a square matrix.
  270.51 +*
  270.52 +*  RETURNS
  270.53 +*
  270.54 +*  The routine luf_create_it returns a pointer to the object created. */
  270.55 +
  270.56 +LUF *luf_create_it(void)
  270.57 +{     LUF *luf;
  270.58 +      luf = xmalloc(sizeof(LUF));
  270.59 +      luf->n_max = luf->n = 0;
  270.60 +      luf->valid = 0;
  270.61 +      luf->fr_ptr = luf->fr_len = NULL;
  270.62 +      luf->fc_ptr = luf->fc_len = NULL;
  270.63 +      luf->vr_ptr = luf->vr_len = luf->vr_cap = NULL;
  270.64 +      luf->vr_piv = NULL;
  270.65 +      luf->vc_ptr = luf->vc_len = luf->vc_cap = NULL;
  270.66 +      luf->pp_row = luf->pp_col = NULL;
  270.67 +      luf->qq_row = luf->qq_col = NULL;
  270.68 +      luf->sv_size = 0;
  270.69 +      luf->sv_beg = luf->sv_end = 0;
  270.70 +      luf->sv_ind = NULL;
  270.71 +      luf->sv_val = NULL;
  270.72 +      luf->sv_head = luf->sv_tail = 0;
  270.73 +      luf->sv_prev = luf->sv_next = NULL;
  270.74 +      luf->vr_max = NULL;
  270.75 +      luf->rs_head = luf->rs_prev = luf->rs_next = NULL;
  270.76 +      luf->cs_head = luf->cs_prev = luf->cs_next = NULL;
  270.77 +      luf->flag = NULL;
  270.78 +      luf->work = NULL;
  270.79 +      luf->new_sva = 0;
  270.80 +      luf->piv_tol = 0.10;
  270.81 +      luf->piv_lim = 4;
  270.82 +      luf->suhl = 1;
  270.83 +      luf->eps_tol = 1e-15;
  270.84 +      luf->max_gro = 1e+10;
  270.85 +      luf->nnz_a = luf->nnz_f = luf->nnz_v = 0;
  270.86 +      luf->max_a = luf->big_v = 0.0;
  270.87 +      luf->rank = 0;
  270.88 +      return luf;
  270.89 +}
  270.90 +
  270.91 +/***********************************************************************
  270.92 +*  NAME
  270.93 +*
  270.94 +*  luf_defrag_sva - defragment the sparse vector area
  270.95 +*
  270.96 +*  SYNOPSIS
  270.97 +*
  270.98 +*  #include "glpluf.h"
  270.99 +*  void luf_defrag_sva(LUF *luf);
 270.100 +*
 270.101 +*  DESCRIPTION
 270.102 +*
 270.103 +*  The routine luf_defrag_sva defragments the sparse vector area (SVA)
 270.104 +*  gathering all unused locations in one continuous extent. In order to
 270.105 +*  do that the routine moves all unused locations from the left part of
 270.106 +*  SVA (which contains rows and columns of the matrix V) to the middle
 270.107 +*  part (which contains free locations). This is attained by relocating
 270.108 +*  elements of rows and columns of the matrix V toward the beginning of
 270.109 +*  the left part.
 270.110 +*
 270.111 +*  NOTE that this "garbage collection" involves changing row and column
 270.112 +*  pointers of the matrix V. */
 270.113 +
 270.114 +void luf_defrag_sva(LUF *luf)
 270.115 +{     int n = luf->n;
 270.116 +      int *vr_ptr = luf->vr_ptr;
 270.117 +      int *vr_len = luf->vr_len;
 270.118 +      int *vr_cap = luf->vr_cap;
 270.119 +      int *vc_ptr = luf->vc_ptr;
 270.120 +      int *vc_len = luf->vc_len;
 270.121 +      int *vc_cap = luf->vc_cap;
 270.122 +      int *sv_ind = luf->sv_ind;
 270.123 +      double *sv_val = luf->sv_val;
 270.124 +      int *sv_next = luf->sv_next;
 270.125 +      int sv_beg = 1;
 270.126 +      int i, j, k;
 270.127 +      /* skip rows and columns, which do not need to be relocated */
 270.128 +      for (k = luf->sv_head; k != 0; k = sv_next[k])
 270.129 +      {  if (k <= n)
 270.130 +         {  /* i-th row of the matrix V */
 270.131 +            i = k;
 270.132 +            if (vr_ptr[i] != sv_beg) break;
 270.133 +            vr_cap[i] = vr_len[i];
 270.134 +            sv_beg += vr_cap[i];
 270.135 +         }
 270.136 +         else
 270.137 +         {  /* j-th column of the matrix V */
 270.138 +            j = k - n;
 270.139 +            if (vc_ptr[j] != sv_beg) break;
 270.140 +            vc_cap[j] = vc_len[j];
 270.141 +            sv_beg += vc_cap[j];
 270.142 +         }
 270.143 +      }
 270.144 +      /* relocate other rows and columns in order to gather all unused
 270.145 +         locations in one continuous extent */
 270.146 +      for (k = k; k != 0; k = sv_next[k])
 270.147 +      {  if (k <= n)
 270.148 +         {  /* i-th row of the matrix V */
 270.149 +            i = k;
 270.150 +            memmove(&sv_ind[sv_beg], &sv_ind[vr_ptr[i]],
 270.151 +               vr_len[i] * sizeof(int));
 270.152 +            memmove(&sv_val[sv_beg], &sv_val[vr_ptr[i]],
 270.153 +               vr_len[i] * sizeof(double));
 270.154 +            vr_ptr[i] = sv_beg;
 270.155 +            vr_cap[i] = vr_len[i];
 270.156 +            sv_beg += vr_cap[i];
 270.157 +         }
 270.158 +         else
 270.159 +         {  /* j-th column of the matrix V */
 270.160 +            j = k - n;
 270.161 +            memmove(&sv_ind[sv_beg], &sv_ind[vc_ptr[j]],
 270.162 +               vc_len[j] * sizeof(int));
 270.163 +            memmove(&sv_val[sv_beg], &sv_val[vc_ptr[j]],
 270.164 +               vc_len[j] * sizeof(double));
 270.165 +            vc_ptr[j] = sv_beg;
 270.166 +            vc_cap[j] = vc_len[j];
 270.167 +            sv_beg += vc_cap[j];
 270.168 +         }
 270.169 +      }
 270.170 +      /* set new pointer to the beginning of the free part */
 270.171 +      luf->sv_beg = sv_beg;
 270.172 +      return;
 270.173 +}
 270.174 +
 270.175 +/***********************************************************************
 270.176 +*  NAME
 270.177 +*
 270.178 +*  luf_enlarge_row - enlarge row capacity
 270.179 +*
 270.180 +*  SYNOPSIS
 270.181 +*
 270.182 +*  #include "glpluf.h"
 270.183 +*  int luf_enlarge_row(LUF *luf, int i, int cap);
 270.184 +*
 270.185 +*  DESCRIPTION
 270.186 +*
 270.187 +*  The routine luf_enlarge_row enlarges capacity of the i-th row of the
 270.188 +*  matrix V to cap locations (assuming that its current capacity is less
 270.189 +*  than cap). In order to do that the routine relocates elements of the
 270.190 +*  i-th row to the end of the left part of SVA (which contains rows and
 270.191 +*  columns of the matrix V) and then expands the left part by allocating
 270.192 +*  cap free locations from the free part. If there are less than cap
 270.193 +*  free locations, the routine defragments the sparse vector area.
 270.194 +*
 270.195 +*  Due to "garbage collection" this operation may change row and column
 270.196 +*  pointers of the matrix V.
 270.197 +*
 270.198 +*  RETURNS
 270.199 +*
 270.200 +*  If no error occured, the routine returns zero. Otherwise, in case of
 270.201 +*  overflow of the sparse vector area, the routine returns non-zero. */
 270.202 +
 270.203 +int luf_enlarge_row(LUF *luf, int i, int cap)
 270.204 +{     int n = luf->n;
 270.205 +      int *vr_ptr = luf->vr_ptr;
 270.206 +      int *vr_len = luf->vr_len;
 270.207 +      int *vr_cap = luf->vr_cap;
 270.208 +      int *vc_cap = luf->vc_cap;
 270.209 +      int *sv_ind = luf->sv_ind;
 270.210 +      double *sv_val = luf->sv_val;
 270.211 +      int *sv_prev = luf->sv_prev;
 270.212 +      int *sv_next = luf->sv_next;
 270.213 +      int ret = 0;
 270.214 +      int cur, k, kk;
 270.215 +      xassert(1 <= i && i <= n);
 270.216 +      xassert(vr_cap[i] < cap);
 270.217 +      /* if there are less than cap free locations, defragment SVA */
 270.218 +      if (luf->sv_end - luf->sv_beg < cap)
 270.219 +      {  luf_defrag_sva(luf);
 270.220 +         if (luf->sv_end - luf->sv_beg < cap)
 270.221 +         {  ret = 1;
 270.222 +            goto done;
 270.223 +         }
 270.224 +      }
 270.225 +      /* save current capacity of the i-th row */
 270.226 +      cur = vr_cap[i];
 270.227 +      /* copy existing elements to the beginning of the free part */
 270.228 +      memmove(&sv_ind[luf->sv_beg], &sv_ind[vr_ptr[i]],
 270.229 +         vr_len[i] * sizeof(int));
 270.230 +      memmove(&sv_val[luf->sv_beg], &sv_val[vr_ptr[i]],
 270.231 +         vr_len[i] * sizeof(double));
 270.232 +      /* set new pointer and new capacity of the i-th row */
 270.233 +      vr_ptr[i] = luf->sv_beg;
 270.234 +      vr_cap[i] = cap;
 270.235 +      /* set new pointer to the beginning of the free part */
 270.236 +      luf->sv_beg += cap;
 270.237 +      /* now the i-th row starts in the rightmost location among other
 270.238 +         rows and columns of the matrix V, so its node should be moved
 270.239 +         to the end of the row/column linked list */
 270.240 +      k = i;
 270.241 +      /* remove the i-th row node from the linked list */
 270.242 +      if (sv_prev[k] == 0)
 270.243 +         luf->sv_head = sv_next[k];
 270.244 +      else
 270.245 +      {  /* capacity of the previous row/column can be increased at the
 270.246 +            expense of old locations of the i-th row */
 270.247 +         kk = sv_prev[k];
 270.248 +         if (kk <= n) vr_cap[kk] += cur; else vc_cap[kk-n] += cur;
 270.249 +         sv_next[sv_prev[k]] = sv_next[k];
 270.250 +      }
 270.251 +      if (sv_next[k] == 0)
 270.252 +         luf->sv_tail = sv_prev[k];
 270.253 +      else
 270.254 +         sv_prev[sv_next[k]] = sv_prev[k];
 270.255 +      /* insert the i-th row node to the end of the linked list */
 270.256 +      sv_prev[k] = luf->sv_tail;
 270.257 +      sv_next[k] = 0;
 270.258 +      if (sv_prev[k] == 0)
 270.259 +         luf->sv_head = k;
 270.260 +      else
 270.261 +         sv_next[sv_prev[k]] = k;
 270.262 +      luf->sv_tail = k;
 270.263 +done: return ret;
 270.264 +}
 270.265 +
 270.266 +/***********************************************************************
 270.267 +*  NAME
 270.268 +*
 270.269 +*  luf_enlarge_col - enlarge column capacity
 270.270 +*
 270.271 +*  SYNOPSIS
 270.272 +*
 270.273 +*  #include "glpluf.h"
 270.274 +*  int luf_enlarge_col(LUF *luf, int j, int cap);
 270.275 +*
 270.276 +*  DESCRIPTION
 270.277 +*
 270.278 +*  The routine luf_enlarge_col enlarges capacity of the j-th column of
 270.279 +*  the matrix V to cap locations (assuming that its current capacity is
 270.280 +*  less than cap). In order to do that the routine relocates elements
 270.281 +*  of the j-th column to the end of the left part of SVA (which contains
 270.282 +*  rows and columns of the matrix V) and then expands the left part by
 270.283 +*  allocating cap free locations from the free part. If there are less
 270.284 +*  than cap free locations, the routine defragments the sparse vector
 270.285 +*  area.
 270.286 +*
 270.287 +*  Due to "garbage collection" this operation may change row and column
 270.288 +*  pointers of the matrix V.
 270.289 +*
 270.290 +*  RETURNS
 270.291 +*
 270.292 +*  If no error occured, the routine returns zero. Otherwise, in case of
 270.293 +*  overflow of the sparse vector area, the routine returns non-zero. */
 270.294 +
 270.295 +int luf_enlarge_col(LUF *luf, int j, int cap)
 270.296 +{     int n = luf->n;
 270.297 +      int *vr_cap = luf->vr_cap;
 270.298 +      int *vc_ptr = luf->vc_ptr;
 270.299 +      int *vc_len = luf->vc_len;
 270.300 +      int *vc_cap = luf->vc_cap;
 270.301 +      int *sv_ind = luf->sv_ind;
 270.302 +      double *sv_val = luf->sv_val;
 270.303 +      int *sv_prev = luf->sv_prev;
 270.304 +      int *sv_next = luf->sv_next;
 270.305 +      int ret = 0;
 270.306 +      int cur, k, kk;
 270.307 +      xassert(1 <= j && j <= n);
 270.308 +      xassert(vc_cap[j] < cap);
 270.309 +      /* if there are less than cap free locations, defragment SVA */
 270.310 +      if (luf->sv_end - luf->sv_beg < cap)
 270.311 +      {  luf_defrag_sva(luf);
 270.312 +         if (luf->sv_end - luf->sv_beg < cap)
 270.313 +         {  ret = 1;
 270.314 +            goto done;
 270.315 +         }
 270.316 +      }
 270.317 +      /* save current capacity of the j-th column */
 270.318 +      cur = vc_cap[j];
 270.319 +      /* copy existing elements to the beginning of the free part */
 270.320 +      memmove(&sv_ind[luf->sv_beg], &sv_ind[vc_ptr[j]],
 270.321 +         vc_len[j] * sizeof(int));
 270.322 +      memmove(&sv_val[luf->sv_beg], &sv_val[vc_ptr[j]],
 270.323 +         vc_len[j] * sizeof(double));
 270.324 +      /* set new pointer and new capacity of the j-th column */
 270.325 +      vc_ptr[j] = luf->sv_beg;
 270.326 +      vc_cap[j] = cap;
 270.327 +      /* set new pointer to the beginning of the free part */
 270.328 +      luf->sv_beg += cap;
 270.329 +      /* now the j-th column starts in the rightmost location among
 270.330 +         other rows and columns of the matrix V, so its node should be
 270.331 +         moved to the end of the row/column linked list */
 270.332 +      k = n + j;
 270.333 +      /* remove the j-th column node from the linked list */
 270.334 +      if (sv_prev[k] == 0)
 270.335 +         luf->sv_head = sv_next[k];
 270.336 +      else
 270.337 +      {  /* capacity of the previous row/column can be increased at the
 270.338 +            expense of old locations of the j-th column */
 270.339 +         kk = sv_prev[k];
 270.340 +         if (kk <= n) vr_cap[kk] += cur; else vc_cap[kk-n] += cur;
 270.341 +         sv_next[sv_prev[k]] = sv_next[k];
 270.342 +      }
 270.343 +      if (sv_next[k] == 0)
 270.344 +         luf->sv_tail = sv_prev[k];
 270.345 +      else
 270.346 +         sv_prev[sv_next[k]] = sv_prev[k];
 270.347 +      /* insert the j-th column node to the end of the linked list */
 270.348 +      sv_prev[k] = luf->sv_tail;
 270.349 +      sv_next[k] = 0;
 270.350 +      if (sv_prev[k] == 0)
 270.351 +         luf->sv_head = k;
 270.352 +      else
 270.353 +         sv_next[sv_prev[k]] = k;
 270.354 +      luf->sv_tail = k;
 270.355 +done: return ret;
 270.356 +}
 270.357 +
 270.358 +/***********************************************************************
 270.359 +*  reallocate - reallocate LU-factorization arrays
 270.360 +*
 270.361 +*  This routine reallocates arrays, whose size depends of n, the order
 270.362 +*  of the matrix A to be factorized. */
 270.363 +
 270.364 +static void reallocate(LUF *luf, int n)
 270.365 +{     int n_max = luf->n_max;
 270.366 +      luf->n = n;
 270.367 +      if (n <= n_max) goto done;
 270.368 +      if (luf->fr_ptr != NULL) xfree(luf->fr_ptr);
 270.369 +      if (luf->fr_len != NULL) xfree(luf->fr_len);
 270.370 +      if (luf->fc_ptr != NULL) xfree(luf->fc_ptr);
 270.371 +      if (luf->fc_len != NULL) xfree(luf->fc_len);
 270.372 +      if (luf->vr_ptr != NULL) xfree(luf->vr_ptr);
 270.373 +      if (luf->vr_len != NULL) xfree(luf->vr_len);
 270.374 +      if (luf->vr_cap != NULL) xfree(luf->vr_cap);
 270.375 +      if (luf->vr_piv != NULL) xfree(luf->vr_piv);
 270.376 +      if (luf->vc_ptr != NULL) xfree(luf->vc_ptr);
 270.377 +      if (luf->vc_len != NULL) xfree(luf->vc_len);
 270.378 +      if (luf->vc_cap != NULL) xfree(luf->vc_cap);
 270.379 +      if (luf->pp_row != NULL) xfree(luf->pp_row);
 270.380 +      if (luf->pp_col != NULL) xfree(luf->pp_col);
 270.381 +      if (luf->qq_row != NULL) xfree(luf->qq_row);
 270.382 +      if (luf->qq_col != NULL) xfree(luf->qq_col);
 270.383 +      if (luf->sv_prev != NULL) xfree(luf->sv_prev);
 270.384 +      if (luf->sv_next != NULL) xfree(luf->sv_next);
 270.385 +      if (luf->vr_max != NULL) xfree(luf->vr_max);
 270.386 +      if (luf->rs_head != NULL) xfree(luf->rs_head);
 270.387 +      if (luf->rs_prev != NULL) xfree(luf->rs_prev);
 270.388 +      if (luf->rs_next != NULL) xfree(luf->rs_next);
 270.389 +      if (luf->cs_head != NULL) xfree(luf->cs_head);
 270.390 +      if (luf->cs_prev != NULL) xfree(luf->cs_prev);
 270.391 +      if (luf->cs_next != NULL) xfree(luf->cs_next);
 270.392 +      if (luf->flag != NULL) xfree(luf->flag);
 270.393 +      if (luf->work != NULL) xfree(luf->work);
 270.394 +      luf->n_max = n_max = n + 100;
 270.395 +      luf->fr_ptr = xcalloc(1+n_max, sizeof(int));
 270.396 +      luf->fr_len = xcalloc(1+n_max, sizeof(int));
 270.397 +      luf->fc_ptr = xcalloc(1+n_max, sizeof(int));
 270.398 +      luf->fc_len = xcalloc(1+n_max, sizeof(int));
 270.399 +      luf->vr_ptr = xcalloc(1+n_max, sizeof(int));
 270.400 +      luf->vr_len = xcalloc(1+n_max, sizeof(int));
 270.401 +      luf->vr_cap = xcalloc(1+n_max, sizeof(int));
 270.402 +      luf->vr_piv = xcalloc(1+n_max, sizeof(double));
 270.403 +      luf->vc_ptr = xcalloc(1+n_max, sizeof(int));
 270.404 +      luf->vc_len = xcalloc(1+n_max, sizeof(int));
 270.405 +      luf->vc_cap = xcalloc(1+n_max, sizeof(int));
 270.406 +      luf->pp_row = xcalloc(1+n_max, sizeof(int));
 270.407 +      luf->pp_col = xcalloc(1+n_max, sizeof(int));
 270.408 +      luf->qq_row = xcalloc(1+n_max, sizeof(int));
 270.409 +      luf->qq_col = xcalloc(1+n_max, sizeof(int));
 270.410 +      luf->sv_prev = xcalloc(1+n_max+n_max, sizeof(int));
 270.411 +      luf->sv_next = xcalloc(1+n_max+n_max, sizeof(int));
 270.412 +      luf->vr_max = xcalloc(1+n_max, sizeof(double));
 270.413 +      luf->rs_head = xcalloc(1+n_max, sizeof(int));
 270.414 +      luf->rs_prev = xcalloc(1+n_max, sizeof(int));
 270.415 +      luf->rs_next = xcalloc(1+n_max, sizeof(int));
 270.416 +      luf->cs_head = xcalloc(1+n_max, sizeof(int));
 270.417 +      luf->cs_prev = xcalloc(1+n_max, sizeof(int));
 270.418 +      luf->cs_next = xcalloc(1+n_max, sizeof(int));
 270.419 +      luf->flag = xcalloc(1+n_max, sizeof(int));
 270.420 +      luf->work = xcalloc(1+n_max, sizeof(double));
 270.421 +done: return;
 270.422 +}
 270.423 +
 270.424 +/***********************************************************************
 270.425 +*  initialize - initialize LU-factorization data structures
 270.426 +*
 270.427 +*  This routine initializes data structures for subsequent computing
 270.428 +*  the LU-factorization of a given matrix A, which is specified by the
 270.429 +*  formal routine col. On exit V = A and F = P = Q = I, where I is the
 270.430 +*  unity matrix. (Row-wise representation of the matrix F is not used
 270.431 +*  at the factorization stage and therefore is not initialized.)
 270.432 +*
 270.433 +*  If no error occured, the routine returns zero. Otherwise, in case of
 270.434 +*  overflow of the sparse vector area, the routine returns non-zero. */
 270.435 +
 270.436 +static int initialize(LUF *luf, int (*col)(void *info, int j, int rn[],
 270.437 +      double aj[]), void *info)
 270.438 +{     int n = luf->n;
 270.439 +      int *fc_ptr = luf->fc_ptr;
 270.440 +      int *fc_len = luf->fc_len;
 270.441 +      int *vr_ptr = luf->vr_ptr;
 270.442 +      int *vr_len = luf->vr_len;
 270.443 +      int *vr_cap = luf->vr_cap;
 270.444 +      int *vc_ptr = luf->vc_ptr;
 270.445 +      int *vc_len = luf->vc_len;
 270.446 +      int *vc_cap = luf->vc_cap;
 270.447 +      int *pp_row = luf->pp_row;
 270.448 +      int *pp_col = luf->pp_col;
 270.449 +      int *qq_row = luf->qq_row;
 270.450 +      int *qq_col = luf->qq_col;
 270.451 +      int *sv_ind = luf->sv_ind;
 270.452 +      double *sv_val = luf->sv_val;
 270.453 +      int *sv_prev = luf->sv_prev;
 270.454 +      int *sv_next = luf->sv_next;
 270.455 +      double *vr_max = luf->vr_max;
 270.456 +      int *rs_head = luf->rs_head;
 270.457 +      int *rs_prev = luf->rs_prev;
 270.458 +      int *rs_next = luf->rs_next;
 270.459 +      int *cs_head = luf->cs_head;
 270.460 +      int *cs_prev = luf->cs_prev;
 270.461 +      int *cs_next = luf->cs_next;
 270.462 +      int *flag = luf->flag;
 270.463 +      double *work = luf->work;
 270.464 +      int ret = 0;
 270.465 +      int i, i_ptr, j, j_beg, j_end, k, len, nnz, sv_beg, sv_end, ptr;
 270.466 +      double big, val;
 270.467 +      /* free all locations of the sparse vector area */
 270.468 +      sv_beg = 1;
 270.469 +      sv_end = luf->sv_size + 1;
 270.470 +      /* (row-wise representation of the matrix F is not initialized,
 270.471 +         because it is not used at the factorization stage) */
 270.472 +      /* build the matrix F in column-wise format (initially F = I) */
 270.473 +      for (j = 1; j <= n; j++)
 270.474 +      {  fc_ptr[j] = sv_end;
 270.475 +         fc_len[j] = 0;
 270.476 +      }
 270.477 +      /* clear rows of the matrix V; clear the flag array */
 270.478 +      for (i = 1; i <= n; i++)
 270.479 +         vr_len[i] = vr_cap[i] = 0, flag[i] = 0;
 270.480 +      /* build the matrix V in column-wise format (initially V = A);
 270.481 +         count non-zeros in rows of this matrix; count total number of
 270.482 +         non-zeros; compute largest of absolute values of elements */
 270.483 +      nnz = 0;
 270.484 +      big = 0.0;
 270.485 +      for (j = 1; j <= n; j++)
 270.486 +      {  int *rn = pp_row;
 270.487 +         double *aj = work;
 270.488 +         /* obtain j-th column of the matrix A */
 270.489 +         len = col(info, j, rn, aj);
 270.490 +         if (!(0 <= len && len <= n))
 270.491 +            xfault("luf_factorize: j = %d; len = %d; invalid column len"
 270.492 +               "gth\n", j, len);
 270.493 +         /* check for free locations */
 270.494 +         if (sv_end - sv_beg < len)
 270.495 +         {  /* overflow of the sparse vector area */
 270.496 +            ret = 1;
 270.497 +            goto done;
 270.498 +         }
 270.499 +         /* set pointer to the j-th column */
 270.500 +         vc_ptr[j] = sv_beg;
 270.501 +         /* set length of the j-th column */
 270.502 +         vc_len[j] = vc_cap[j] = len;
 270.503 +         /* count total number of non-zeros */
 270.504 +         nnz += len;
 270.505 +         /* walk through elements of the j-th column */
 270.506 +         for (ptr = 1; ptr <= len; ptr++)
 270.507 +         {  /* get row index and numerical value of a[i,j] */
 270.508 +            i = rn[ptr];
 270.509 +            val = aj[ptr];
 270.510 +            if (!(1 <= i && i <= n))
 270.511 +               xfault("luf_factorize: i = %d; j = %d; invalid row index"
 270.512 +                  "\n", i, j);
 270.513 +            if (flag[i])
 270.514 +               xfault("luf_factorize: i = %d; j = %d; duplicate element"
 270.515 +                  " not allowed\n", i, j);
 270.516 +            if (val == 0.0)
 270.517 +               xfault("luf_factorize: i = %d; j = %d; zero element not "
 270.518 +                  "allowed\n", i, j);
 270.519 +            /* add new element v[i,j] = a[i,j] to j-th column */
 270.520 +            sv_ind[sv_beg] = i;
 270.521 +            sv_val[sv_beg] = val;
 270.522 +            sv_beg++;
 270.523 +            /* big := max(big, |a[i,j]|) */
 270.524 +            if (val < 0.0) val = - val;
 270.525 +            if (big < val) big = val;
 270.526 +            /* mark non-zero in the i-th position of the j-th column */
 270.527 +            flag[i] = 1;
 270.528 +            /* increase length of the i-th row */
 270.529 +            vr_cap[i]++;
 270.530 +         }
 270.531 +         /* reset all non-zero marks */
 270.532 +         for (ptr = 1; ptr <= len; ptr++) flag[rn[ptr]] = 0;
 270.533 +      }
 270.534 +      /* allocate rows of the matrix V */
 270.535 +      for (i = 1; i <= n; i++)
 270.536 +      {  /* get length of the i-th row */
 270.537 +         len = vr_cap[i];
 270.538 +         /* check for free locations */
 270.539 +         if (sv_end - sv_beg < len)
 270.540 +         {  /* overflow of the sparse vector area */
 270.541 +            ret = 1;
 270.542 +            goto done;
 270.543 +         }
 270.544 +         /* set pointer to the i-th row */
 270.545 +         vr_ptr[i] = sv_beg;
 270.546 +         /* reserve locations for the i-th row */
 270.547 +         sv_beg += len;
 270.548 +      }
 270.549 +      /* build the matrix V in row-wise format using representation of
 270.550 +         this matrix in column-wise format */
 270.551 +      for (j = 1; j <= n; j++)
 270.552 +      {  /* walk through elements of the j-th column */
 270.553 +         j_beg = vc_ptr[j];
 270.554 +         j_end = j_beg + vc_len[j] - 1;
 270.555 +         for (k = j_beg; k <= j_end; k++)
 270.556 +         {  /* get row index and numerical value of v[i,j] */
 270.557 +            i = sv_ind[k];
 270.558 +            val = sv_val[k];
 270.559 +            /* store element in the i-th row */
 270.560 +            i_ptr = vr_ptr[i] + vr_len[i];
 270.561 +            sv_ind[i_ptr] = j;
 270.562 +            sv_val[i_ptr] = val;
 270.563 +            /* increase count of the i-th row */
 270.564 +            vr_len[i]++;
 270.565 +         }
 270.566 +      }
 270.567 +      /* initialize the matrices P and Q (initially P = Q = I) */
 270.568 +      for (k = 1; k <= n; k++)
 270.569 +         pp_row[k] = pp_col[k] = qq_row[k] = qq_col[k] = k;
 270.570 +      /* set sva partitioning pointers */
 270.571 +      luf->sv_beg = sv_beg;
 270.572 +      luf->sv_end = sv_end;
 270.573 +      /* the initial physical order of rows and columns of the matrix V
 270.574 +         is n+1, ..., n+n, 1, ..., n (firstly columns, then rows) */
 270.575 +      luf->sv_head = n+1;
 270.576 +      luf->sv_tail = n;
 270.577 +      for (i = 1; i <= n; i++)
 270.578 +      {  sv_prev[i] = i-1;
 270.579 +         sv_next[i] = i+1;
 270.580 +      }
 270.581 +      sv_prev[1] = n+n;
 270.582 +      sv_next[n] = 0;
 270.583 +      for (j = 1; j <= n; j++)
 270.584 +      {  sv_prev[n+j] = n+j-1;
 270.585 +         sv_next[n+j] = n+j+1;
 270.586 +      }
 270.587 +      sv_prev[n+1] = 0;
 270.588 +      sv_next[n+n] = 1;
 270.589 +      /* clear working arrays */
 270.590 +      for (k = 1; k <= n; k++)
 270.591 +      {  flag[k] = 0;
 270.592 +         work[k] = 0.0;
 270.593 +      }
 270.594 +      /* initialize some statistics */
 270.595 +      luf->nnz_a = nnz;
 270.596 +      luf->nnz_f = 0;
 270.597 +      luf->nnz_v = nnz;
 270.598 +      luf->max_a = big;
 270.599 +      luf->big_v = big;
 270.600 +      luf->rank = -1;
 270.601 +      /* initially the active submatrix is the entire matrix V */
 270.602 +      /* largest of absolute values of elements in each active row is
 270.603 +         unknown yet */
 270.604 +      for (i = 1; i <= n; i++) vr_max[i] = -1.0;
 270.605 +      /* build linked lists of active rows */
 270.606 +      for (len = 0; len <= n; len++) rs_head[len] = 0;
 270.607 +      for (i = 1; i <= n; i++)
 270.608 +      {  len = vr_len[i];
 270.609 +         rs_prev[i] = 0;
 270.610 +         rs_next[i] = rs_head[len];
 270.611 +         if (rs_next[i] != 0) rs_prev[rs_next[i]] = i;
 270.612 +         rs_head[len] = i;
 270.613 +      }
 270.614 +      /* build linked lists of active columns */
 270.615 +      for (len = 0; len <= n; len++) cs_head[len] = 0;
 270.616 +      for (j = 1; j <= n; j++)
 270.617 +      {  len = vc_len[j];
 270.618 +         cs_prev[j] = 0;
 270.619 +         cs_next[j] = cs_head[len];
 270.620 +         if (cs_next[j] != 0) cs_prev[cs_next[j]] = j;
 270.621 +         cs_head[len] = j;
 270.622 +      }
 270.623 +done: /* return to the factorizing routine */
 270.624 +      return ret;
 270.625 +}
 270.626 +
 270.627 +/***********************************************************************
 270.628 +*  find_pivot - choose a pivot element
 270.629 +*
 270.630 +*  This routine chooses a pivot element in the active submatrix of the
 270.631 +*  matrix U = P*V*Q.
 270.632 +*
 270.633 +*  It is assumed that on entry the matrix U has the following partially
 270.634 +*  triangularized form:
 270.635 +* 
 270.636 +*        1       k         n
 270.637 +*     1  x x x x x x x x x x
 270.638 +*        . x x x x x x x x x
 270.639 +*        . . x x x x x x x x
 270.640 +*        . . . x x x x x x x
 270.641 +*     k  . . . . * * * * * *
 270.642 +*        . . . . * * * * * *
 270.643 +*        . . . . * * * * * *
 270.644 +*        . . . . * * * * * *
 270.645 +*        . . . . * * * * * *
 270.646 +*     n  . . . . * * * * * *
 270.647 +* 
 270.648 +*  where rows and columns k, k+1, ..., n belong to the active submatrix
 270.649 +*  (elements of the active submatrix are marked by '*').
 270.650 +*
 270.651 +*  Since the matrix U = P*V*Q is not stored, the routine works with the
 270.652 +*  matrix V. It is assumed that the row-wise representation corresponds
 270.653 +*  to the matrix V, but the column-wise representation corresponds to
 270.654 +*  the active submatrix of the matrix V, i.e. elements of the matrix V,
 270.655 +*  which doesn't belong to the active submatrix, are missing from the
 270.656 +*  column linked lists. It is also assumed that each active row of the
 270.657 +*  matrix V is in the set R[len], where len is number of non-zeros in
 270.658 +*  the row, and each active column of the matrix V is in the set C[len],
 270.659 +*  where len is number of non-zeros in the column (in the latter case
 270.660 +*  only elements of the active submatrix are counted; such elements are
 270.661 +*  marked by '*' on the figure above).
 270.662 +* 
 270.663 +*  For the reason of numerical stability the routine applies so called
 270.664 +*  threshold pivoting proposed by J.Reid. It is assumed that an element
 270.665 +*  v[i,j] can be selected as a pivot candidate if it is not very small
 270.666 +*  (in absolute value) among other elements in the same row, i.e. if it
 270.667 +*  satisfies to the stability condition |v[i,j]| >= tol * max|v[i,*]|,
 270.668 +*  where 0 < tol < 1 is a given tolerance.
 270.669 +* 
 270.670 +*  In order to keep sparsity of the matrix V the routine uses Markowitz
 270.671 +*  strategy, trying to choose such element v[p,q], which satisfies to
 270.672 +*  the stability condition (see above) and has smallest Markowitz cost
 270.673 +*  (nr[p]-1) * (nc[q]-1), where nr[p] and nc[q] are numbers of non-zero
 270.674 +*  elements, respectively, in the p-th row and in the q-th column of the
 270.675 +*  active submatrix.
 270.676 +* 
 270.677 +*  In order to reduce the search, i.e. not to walk through all elements
 270.678 +*  of the active submatrix, the routine exploits a technique proposed by
 270.679 +*  I.Duff. This technique is based on using the sets R[len] and C[len]
 270.680 +*  of active rows and columns.
 270.681 +* 
 270.682 +*  If the pivot element v[p,q] has been chosen, the routine stores its
 270.683 +*  indices to the locations *p and *q and returns zero. Otherwise, if
 270.684 +*  the active submatrix is empty and therefore the pivot element can't
 270.685 +*  be chosen, the routine returns non-zero. */
 270.686 +
 270.687 +static int find_pivot(LUF *luf, int *_p, int *_q)
 270.688 +{     int n = luf->n;
 270.689 +      int *vr_ptr = luf->vr_ptr;
 270.690 +      int *vr_len = luf->vr_len;
 270.691 +      int *vc_ptr = luf->vc_ptr;
 270.692 +      int *vc_len = luf->vc_len;
 270.693 +      int *sv_ind = luf->sv_ind;
 270.694 +      double *sv_val = luf->sv_val;
 270.695 +      double *vr_max = luf->vr_max;
 270.696 +      int *rs_head = luf->rs_head;
 270.697 +      int *rs_next = luf->rs_next;
 270.698 +      int *cs_head = luf->cs_head;
 270.699 +      int *cs_prev = luf->cs_prev;
 270.700 +      int *cs_next = luf->cs_next;
 270.701 +      double piv_tol = luf->piv_tol;
 270.702 +      int piv_lim = luf->piv_lim;
 270.703 +      int suhl = luf->suhl;
 270.704 +      int p, q, len, i, i_beg, i_end, i_ptr, j, j_beg, j_end, j_ptr,
 270.705 +         ncand, next_j, min_p, min_q, min_len;
 270.706 +      double best, cost, big, temp;
 270.707 +      /* initially no pivot candidates have been found so far */
 270.708 +      p = q = 0, best = DBL_MAX, ncand = 0;
 270.709 +      /* if in the active submatrix there is a column that has the only
 270.710 +         non-zero (column singleton), choose it as pivot */
 270.711 +      j = cs_head[1];
 270.712 +      if (j != 0)
 270.713 +      {  xassert(vc_len[j] == 1);
 270.714 +         p = sv_ind[vc_ptr[j]], q = j;
 270.715 +         goto done;
 270.716 +      }
 270.717 +      /* if in the active submatrix there is a row that has the only
 270.718 +         non-zero (row singleton), choose it as pivot */
 270.719 +      i = rs_head[1];
 270.720 +      if (i != 0)
 270.721 +      {  xassert(vr_len[i] == 1);
 270.722 +         p = i, q = sv_ind[vr_ptr[i]];
 270.723 +         goto done;
 270.724 +      }
 270.725 +      /* there are no singletons in the active submatrix; walk through
 270.726 +         other non-empty rows and columns */
 270.727 +      for (len = 2; len <= n; len++)
 270.728 +      {  /* consider active columns that have len non-zeros */
 270.729 +         for (j = cs_head[len]; j != 0; j = next_j)
 270.730 +         {  /* the j-th column has len non-zeros */
 270.731 +            j_beg = vc_ptr[j];
 270.732 +            j_end = j_beg + vc_len[j] - 1;
 270.733 +            /* save pointer to the next column with the same length */
 270.734 +            next_j = cs_next[j];
 270.735 +            /* find an element in the j-th column, which is placed in a
 270.736 +               row with minimal number of non-zeros and satisfies to the
 270.737 +               stability condition (such element may not exist) */
 270.738 +            min_p = min_q = 0, min_len = INT_MAX;
 270.739 +            for (j_ptr = j_beg; j_ptr <= j_end; j_ptr++)
 270.740 +            {  /* get row index of v[i,j] */
 270.741 +               i = sv_ind[j_ptr];
 270.742 +               i_beg = vr_ptr[i];
 270.743 +               i_end = i_beg + vr_len[i] - 1;
 270.744 +               /* if the i-th row is not shorter than that one, where
 270.745 +                  minimal element is currently placed, skip v[i,j] */
 270.746 +               if (vr_len[i] >= min_len) continue;
 270.747 +               /* determine the largest of absolute values of elements
 270.748 +                  in the i-th row */
 270.749 +               big = vr_max[i];
 270.750 +               if (big < 0.0)
 270.751 +               {  /* the largest value is unknown yet; compute it */
 270.752 +                  for (i_ptr = i_beg; i_ptr <= i_end; i_ptr++)
 270.753 +                  {  temp = sv_val[i_ptr];
 270.754 +                     if (temp < 0.0) temp = - temp;
 270.755 +                     if (big < temp) big = temp;
 270.756 +                  }
 270.757 +                  vr_max[i] = big;
 270.758 +               }
 270.759 +               /* find v[i,j] in the i-th row */
 270.760 +               for (i_ptr = vr_ptr[i]; sv_ind[i_ptr] != j; i_ptr++);
 270.761 +               xassert(i_ptr <= i_end);
 270.762 +               /* if v[i,j] doesn't satisfy to the stability condition,
 270.763 +                  skip it */
 270.764 +               temp = sv_val[i_ptr];
 270.765 +               if (temp < 0.0) temp = - temp;
 270.766 +               if (temp < piv_tol * big) continue;
 270.767 +               /* v[i,j] is better than the current minimal element */
 270.768 +               min_p = i, min_q = j, min_len = vr_len[i];
 270.769 +               /* if Markowitz cost of the current minimal element is
 270.770 +                  not greater than (len-1)**2, it can be chosen right
 270.771 +                  now; this heuristic reduces the search and works well
 270.772 +                  in many cases */
 270.773 +               if (min_len <= len)
 270.774 +               {  p = min_p, q = min_q;
 270.775 +                  goto done;
 270.776 +               }
 270.777 +            }
 270.778 +            /* the j-th column has been scanned */
 270.779 +            if (min_p != 0)
 270.780 +            {  /* the minimal element is a next pivot candidate */
 270.781 +               ncand++;
 270.782 +               /* compute its Markowitz cost */
 270.783 +               cost = (double)(min_len - 1) * (double)(len - 1);
 270.784 +               /* choose between the minimal element and the current
 270.785 +                  candidate */
 270.786 +               if (cost < best) p = min_p, q = min_q, best = cost;
 270.787 +               /* if piv_lim candidates have been considered, there are
 270.788 +                  doubts that a much better candidate exists; therefore
 270.789 +                  it's time to terminate the search */
 270.790 +               if (ncand == piv_lim) goto done;
 270.791 +            }
 270.792 +            else
 270.793 +            {  /* the j-th column has no elements, which satisfy to the
 270.794 +                  stability condition; Uwe Suhl suggests to exclude such
 270.795 +                  column from the further consideration until it becomes
 270.796 +                  a column singleton; in hard cases this significantly
 270.797 +                  reduces a time needed for pivot searching */
 270.798 +               if (suhl)
 270.799 +               {  /* remove the j-th column from the active set */
 270.800 +                  if (cs_prev[j] == 0)
 270.801 +                     cs_head[len] = cs_next[j];
 270.802 +                  else
 270.803 +                     cs_next[cs_prev[j]] = cs_next[j];
 270.804 +                  if (cs_next[j] == 0)
 270.805 +                     /* nop */;
 270.806 +                  else
 270.807 +                     cs_prev[cs_next[j]] = cs_prev[j];
 270.808 +                  /* the following assignment is used to avoid an error
 270.809 +                     when the routine eliminate (see below) will try to
 270.810 +                     remove the j-th column from the active set */
 270.811 +                  cs_prev[j] = cs_next[j] = j;
 270.812 +               }
 270.813 +            }
 270.814 +         }
 270.815 +         /* consider active rows that have len non-zeros */
 270.816 +         for (i = rs_head[len]; i != 0; i = rs_next[i])
 270.817 +         {  /* the i-th row has len non-zeros */
 270.818 +            i_beg = vr_ptr[i];
 270.819 +            i_end = i_beg + vr_len[i] - 1;
 270.820 +            /* determine the largest of absolute values of elements in
 270.821 +               the i-th row */
 270.822 +            big = vr_max[i];
 270.823 +            if (big < 0.0)
 270.824 +            {  /* the largest value is unknown yet; compute it */
 270.825 +               for (i_ptr = i_beg; i_ptr <= i_end; i_ptr++)
 270.826 +               {  temp = sv_val[i_ptr];
 270.827 +                  if (temp < 0.0) temp = - temp;
 270.828 +                  if (big < temp) big = temp;
 270.829 +               }
 270.830 +               vr_max[i] = big;
 270.831 +            }
 270.832 +            /* find an element in the i-th row, which is placed in a
 270.833 +               column with minimal number of non-zeros and satisfies to
 270.834 +               the stability condition (such element always exists) */
 270.835 +            min_p = min_q = 0, min_len = INT_MAX;
 270.836 +            for (i_ptr = i_beg; i_ptr <= i_end; i_ptr++)
 270.837 +            {  /* get column index of v[i,j] */
 270.838 +               j = sv_ind[i_ptr];
 270.839 +               /* if the j-th column is not shorter than that one, where
 270.840 +                  minimal element is currently placed, skip v[i,j] */
 270.841 +               if (vc_len[j] >= min_len) continue;
 270.842 +               /* if v[i,j] doesn't satisfy to the stability condition,
 270.843 +                  skip it */
 270.844 +               temp = sv_val[i_ptr];
 270.845 +               if (temp < 0.0) temp = - temp;
 270.846 +               if (temp < piv_tol * big) continue;
 270.847 +               /* v[i,j] is better than the current minimal element */
 270.848 +               min_p = i, min_q = j, min_len = vc_len[j];
 270.849 +               /* if Markowitz cost of the current minimal element is
 270.850 +                  not greater than (len-1)**2, it can be chosen right
 270.851 +                  now; this heuristic reduces the search and works well
 270.852 +                  in many cases */
 270.853 +               if (min_len <= len)
 270.854 +               {  p = min_p, q = min_q;
 270.855 +                  goto done;
 270.856 +               }
 270.857 +            }
 270.858 +            /* the i-th row has been scanned */
 270.859 +            if (min_p != 0)
 270.860 +            {  /* the minimal element is a next pivot candidate */
 270.861 +               ncand++;
 270.862 +               /* compute its Markowitz cost */
 270.863 +               cost = (double)(len - 1) * (double)(min_len - 1);
 270.864 +               /* choose between the minimal element and the current
 270.865 +                  candidate */
 270.866 +               if (cost < best) p = min_p, q = min_q, best = cost;
 270.867 +               /* if piv_lim candidates have been considered, there are
 270.868 +                  doubts that a much better candidate exists; therefore
 270.869 +                  it's time to terminate the search */
 270.870 +               if (ncand == piv_lim) goto done;
 270.871 +            }
 270.872 +            else
 270.873 +            {  /* this can't be because this can never be */
 270.874 +               xassert(min_p != min_p);
 270.875 +            }
 270.876 +         }
 270.877 +      }
 270.878 +done: /* bring the pivot to the factorizing routine */
 270.879 +      *_p = p, *_q = q;
 270.880 +      return (p == 0);
 270.881 +}
 270.882 +
 270.883 +/***********************************************************************
 270.884 +*  eliminate - perform gaussian elimination.
 270.885 +* 
 270.886 +*  This routine performs elementary gaussian transformations in order
 270.887 +*  to eliminate subdiagonal elements in the k-th column of the matrix
 270.888 +*  U = P*V*Q using the pivot element u[k,k], where k is the number of
 270.889 +*  the current elimination step.
 270.890 +* 
 270.891 +*  The parameters p and q are, respectively, row and column indices of
 270.892 +*  the element v[p,q], which corresponds to the element u[k,k].
 270.893 +* 
 270.894 +*  Each time when the routine applies the elementary transformation to
 270.895 +*  a non-pivot row of the matrix V, it stores the corresponding element
 270.896 +*  to the matrix F in order to keep the main equality A = F*V.
 270.897 +* 
 270.898 +*  The routine assumes that on entry the matrices L = P*F*inv(P) and
 270.899 +*  U = P*V*Q are the following:
 270.900 +* 
 270.901 +*        1       k                  1       k         n
 270.902 +*     1  1 . . . . . . . . .     1  x x x x x x x x x x
 270.903 +*        x 1 . . . . . . . .        . x x x x x x x x x
 270.904 +*        x x 1 . . . . . . .        . . x x x x x x x x
 270.905 +*        x x x 1 . . . . . .        . . . x x x x x x x
 270.906 +*     k  x x x x 1 . . . . .     k  . . . . * * * * * *
 270.907 +*        x x x x _ 1 . . . .        . . . . # * * * * *
 270.908 +*        x x x x _ . 1 . . .        . . . . # * * * * *
 270.909 +*        x x x x _ . . 1 . .        . . . . # * * * * *
 270.910 +*        x x x x _ . . . 1 .        . . . . # * * * * *
 270.911 +*     n  x x x x _ . . . . 1     n  . . . . # * * * * *
 270.912 +* 
 270.913 +*             matrix L                   matrix U
 270.914 +* 
 270.915 +*  where rows and columns of the matrix U with numbers k, k+1, ..., n
 270.916 +*  form the active submatrix (eliminated elements are marked by '#' and
 270.917 +*  other elements of the active submatrix are marked by '*'). Note that
 270.918 +*  each eliminated non-zero element u[i,k] of the matrix U gives the
 270.919 +*  corresponding element l[i,k] of the matrix L (marked by '_').
 270.920 +* 
 270.921 +*  Actually all operations are performed on the matrix V. Should note
 270.922 +*  that the row-wise representation corresponds to the matrix V, but the
 270.923 +*  column-wise representation corresponds to the active submatrix of the
 270.924 +*  matrix V, i.e. elements of the matrix V, which doesn't belong to the
 270.925 +*  active submatrix, are missing from the column linked lists.
 270.926 +* 
 270.927 +*  Let u[k,k] = v[p,q] be the pivot. In order to eliminate subdiagonal
 270.928 +*  elements u[i',k] = v[i,q], i' = k+1, k+2, ..., n, the routine applies
 270.929 +*  the following elementary gaussian transformations:
 270.930 +* 
 270.931 +*     (i-th row of V) := (i-th row of V) - f[i,p] * (p-th row of V),
 270.932 +* 
 270.933 +*  where f[i,p] = v[i,q] / v[p,q] is a gaussian multiplier.
 270.934 +*
 270.935 +*  Additionally, in order to keep the main equality A = F*V, each time
 270.936 +*  when the routine applies the transformation to i-th row of the matrix
 270.937 +*  V, it also adds f[i,p] as a new element to the matrix F.
 270.938 +*
 270.939 +*  IMPORTANT: On entry the working arrays flag and work should contain
 270.940 +*  zeros. This status is provided by the routine on exit.
 270.941 +*
 270.942 +*  If no error occured, the routine returns zero. Otherwise, in case of
 270.943 +*  overflow of the sparse vector area, the routine returns non-zero. */
 270.944 +
 270.945 +static int eliminate(LUF *luf, int p, int q)
 270.946 +{     int n = luf->n;
 270.947 +      int *fc_ptr = luf->fc_ptr;
 270.948 +      int *fc_len = luf->fc_len;
 270.949 +      int *vr_ptr = luf->vr_ptr;
 270.950 +      int *vr_len = luf->vr_len;
 270.951 +      int *vr_cap = luf->vr_cap;
 270.952 +      double *vr_piv = luf->vr_piv;
 270.953 +      int *vc_ptr = luf->vc_ptr;
 270.954 +      int *vc_len = luf->vc_len;
 270.955 +      int *vc_cap = luf->vc_cap;
 270.956 +      int *sv_ind = luf->sv_ind;
 270.957 +      double *sv_val = luf->sv_val;
 270.958 +      int *sv_prev = luf->sv_prev;
 270.959 +      int *sv_next = luf->sv_next;
 270.960 +      double *vr_max = luf->vr_max;
 270.961 +      int *rs_head = luf->rs_head;
 270.962 +      int *rs_prev = luf->rs_prev;
 270.963 +      int *rs_next = luf->rs_next;
 270.964 +      int *cs_head = luf->cs_head;
 270.965 +      int *cs_prev = luf->cs_prev;
 270.966 +      int *cs_next = luf->cs_next;
 270.967 +      int *flag = luf->flag;
 270.968 +      double *work = luf->work;
 270.969 +      double eps_tol = luf->eps_tol;
 270.970 +      /* at this stage the row-wise representation of the matrix F is
 270.971 +         not used, so fr_len can be used as a working array */
 270.972 +      int *ndx = luf->fr_len;
 270.973 +      int ret = 0;
 270.974 +      int len, fill, i, i_beg, i_end, i_ptr, j, j_beg, j_end, j_ptr, k,
 270.975 +         p_beg, p_end, p_ptr, q_beg, q_end, q_ptr;
 270.976 +      double fip, val, vpq, temp;
 270.977 +      xassert(1 <= p && p <= n);
 270.978 +      xassert(1 <= q && q <= n);
 270.979 +      /* remove the p-th (pivot) row from the active set; this row will
 270.980 +         never return there */
 270.981 +      if (rs_prev[p] == 0)
 270.982 +         rs_head[vr_len[p]] = rs_next[p];
 270.983 +      else
 270.984 +         rs_next[rs_prev[p]] = rs_next[p];
 270.985 +      if (rs_next[p] == 0)
 270.986 +         ;
 270.987 +      else
 270.988 +         rs_prev[rs_next[p]] = rs_prev[p];
 270.989 +      /* remove the q-th (pivot) column from the active set; this column
 270.990 +         will never return there */
 270.991 +      if (cs_prev[q] == 0)
 270.992 +         cs_head[vc_len[q]] = cs_next[q];
 270.993 +      else
 270.994 +         cs_next[cs_prev[q]] = cs_next[q];
 270.995 +      if (cs_next[q] == 0)
 270.996 +         ;
 270.997 +      else
 270.998 +         cs_prev[cs_next[q]] = cs_prev[q];
 270.999 +      /* find the pivot v[p,q] = u[k,k] in the p-th row */
270.1000 +      p_beg = vr_ptr[p];
270.1001 +      p_end = p_beg + vr_len[p] - 1;
270.1002 +      for (p_ptr = p_beg; sv_ind[p_ptr] != q; p_ptr++) /* nop */;
270.1003 +      xassert(p_ptr <= p_end);
270.1004 +      /* store value of the pivot */
270.1005 +      vpq = (vr_piv[p] = sv_val[p_ptr]);
270.1006 +      /* remove the pivot from the p-th row */
270.1007 +      sv_ind[p_ptr] = sv_ind[p_end];
270.1008 +      sv_val[p_ptr] = sv_val[p_end];
270.1009 +      vr_len[p]--;
270.1010 +      p_end--;
270.1011 +      /* find the pivot v[p,q] = u[k,k] in the q-th column */
270.1012 +      q_beg = vc_ptr[q];
270.1013 +      q_end = q_beg + vc_len[q] - 1;
270.1014 +      for (q_ptr = q_beg; sv_ind[q_ptr] != p; q_ptr++) /* nop */;
270.1015 +      xassert(q_ptr <= q_end);
270.1016 +      /* remove the pivot from the q-th column */
270.1017 +      sv_ind[q_ptr] = sv_ind[q_end];
270.1018 +      vc_len[q]--;
270.1019 +      q_end--;
270.1020 +      /* walk through the p-th (pivot) row, which doesn't contain the
270.1021 +         pivot v[p,q] already, and do the following... */
270.1022 +      for (p_ptr = p_beg; p_ptr <= p_end; p_ptr++)
270.1023 +      {  /* get column index of v[p,j] */
270.1024 +         j = sv_ind[p_ptr];
270.1025 +         /* store v[p,j] to the working array */
270.1026 +         flag[j] = 1;
270.1027 +         work[j] = sv_val[p_ptr];
270.1028 +         /* remove the j-th column from the active set; this column will
270.1029 +            return there later with new length */
270.1030 +         if (cs_prev[j] == 0)
270.1031 +            cs_head[vc_len[j]] = cs_next[j];
270.1032 +         else
270.1033 +            cs_next[cs_prev[j]] = cs_next[j];
270.1034 +         if (cs_next[j] == 0)
270.1035 +            ;
270.1036 +         else
270.1037 +            cs_prev[cs_next[j]] = cs_prev[j];
270.1038 +         /* find v[p,j] in the j-th column */
270.1039 +         j_beg = vc_ptr[j];
270.1040 +         j_end = j_beg + vc_len[j] - 1;
270.1041 +         for (j_ptr = j_beg; sv_ind[j_ptr] != p; j_ptr++) /* nop */;
270.1042 +         xassert(j_ptr <= j_end);
270.1043 +         /* since v[p,j] leaves the active submatrix, remove it from the
270.1044 +            j-th column; however, v[p,j] is kept in the p-th row */
270.1045 +         sv_ind[j_ptr] = sv_ind[j_end];
270.1046 +         vc_len[j]--;
270.1047 +      }
270.1048 +      /* walk through the q-th (pivot) column, which doesn't contain the
270.1049 +         pivot v[p,q] already, and perform gaussian elimination */
270.1050 +      while (q_beg <= q_end)
270.1051 +      {  /* element v[i,q] should be eliminated */
270.1052 +         /* get row index of v[i,q] */
270.1053 +         i = sv_ind[q_beg];
270.1054 +         /* remove the i-th row from the active set; later this row will
270.1055 +            return there with new length */
270.1056 +         if (rs_prev[i] == 0)
270.1057 +            rs_head[vr_len[i]] = rs_next[i];
270.1058 +         else
270.1059 +            rs_next[rs_prev[i]] = rs_next[i];
270.1060 +         if (rs_next[i] == 0)
270.1061 +            ;
270.1062 +         else
270.1063 +            rs_prev[rs_next[i]] = rs_prev[i];
270.1064 +         /* find v[i,q] in the i-th row */
270.1065 +         i_beg = vr_ptr[i];
270.1066 +         i_end = i_beg + vr_len[i] - 1;
270.1067 +         for (i_ptr = i_beg; sv_ind[i_ptr] != q; i_ptr++) /* nop */;
270.1068 +         xassert(i_ptr <= i_end);
270.1069 +         /* compute gaussian multiplier f[i,p] = v[i,q] / v[p,q] */
270.1070 +         fip = sv_val[i_ptr] / vpq;
270.1071 +         /* since v[i,q] should be eliminated, remove it from the i-th
270.1072 +            row */
270.1073 +         sv_ind[i_ptr] = sv_ind[i_end];
270.1074 +         sv_val[i_ptr] = sv_val[i_end];
270.1075 +         vr_len[i]--;
270.1076 +         i_end--;
270.1077 +         /* and from the q-th column */
270.1078 +         sv_ind[q_beg] = sv_ind[q_end];
270.1079 +         vc_len[q]--;
270.1080 +         q_end--;
270.1081 +         /* perform gaussian transformation:
270.1082 +            (i-th row) := (i-th row) - f[i,p] * (p-th row)
270.1083 +            note that now the p-th row, which is in the working array,
270.1084 +            doesn't contain the pivot v[p,q], and the i-th row doesn't
270.1085 +            contain the eliminated element v[i,q] */
270.1086 +         /* walk through the i-th row and transform existing non-zero
270.1087 +            elements */
270.1088 +         fill = vr_len[p];
270.1089 +         for (i_ptr = i_beg; i_ptr <= i_end; i_ptr++)
270.1090 +         {  /* get column index of v[i,j] */
270.1091 +            j = sv_ind[i_ptr];
270.1092 +            /* v[i,j] := v[i,j] - f[i,p] * v[p,j] */
270.1093 +            if (flag[j])
270.1094 +            {  /* v[p,j] != 0 */
270.1095 +               temp = (sv_val[i_ptr] -= fip * work[j]);
270.1096 +               if (temp < 0.0) temp = - temp;
270.1097 +               flag[j] = 0;
270.1098 +               fill--; /* since both v[i,j] and v[p,j] exist */
270.1099 +               if (temp == 0.0 || temp < eps_tol)
270.1100 +               {  /* new v[i,j] is closer to zero; replace it by exact
270.1101 +                     zero, i.e. remove it from the active submatrix */
270.1102 +                  /* remove v[i,j] from the i-th row */
270.1103 +                  sv_ind[i_ptr] = sv_ind[i_end];
270.1104 +                  sv_val[i_ptr] = sv_val[i_end];
270.1105 +                  vr_len[i]--;
270.1106 +                  i_ptr--;
270.1107 +                  i_end--;
270.1108 +                  /* find v[i,j] in the j-th column */
270.1109 +                  j_beg = vc_ptr[j];
270.1110 +                  j_end = j_beg + vc_len[j] - 1;
270.1111 +                  for (j_ptr = j_beg; sv_ind[j_ptr] != i; j_ptr++);
270.1112 +                  xassert(j_ptr <= j_end);
270.1113 +                  /* remove v[i,j] from the j-th column */
270.1114 +                  sv_ind[j_ptr] = sv_ind[j_end];
270.1115 +                  vc_len[j]--;
270.1116 +               }
270.1117 +               else
270.1118 +               {  /* v_big := max(v_big, |v[i,j]|) */
270.1119 +                  if (luf->big_v < temp) luf->big_v = temp;
270.1120 +               }
270.1121 +            }
270.1122 +         }
270.1123 +         /* now flag is the pattern of the set v[p,*] \ v[i,*], and fill
270.1124 +            is number of non-zeros in this set; therefore up to fill new
270.1125 +            non-zeros may appear in the i-th row */
270.1126 +         if (vr_len[i] + fill > vr_cap[i])
270.1127 +         {  /* enlarge the i-th row */
270.1128 +            if (luf_enlarge_row(luf, i, vr_len[i] + fill))
270.1129 +            {  /* overflow of the sparse vector area */
270.1130 +               ret = 1;
270.1131 +               goto done;
270.1132 +            }
270.1133 +            /* defragmentation may change row and column pointers of the
270.1134 +               matrix V */
270.1135 +            p_beg = vr_ptr[p];
270.1136 +            p_end = p_beg + vr_len[p] - 1;
270.1137 +            q_beg = vc_ptr[q];
270.1138 +            q_end = q_beg + vc_len[q] - 1;
270.1139 +         }
270.1140 +         /* walk through the p-th (pivot) row and create new elements
270.1141 +            of the i-th row that appear due to fill-in; column indices
270.1142 +            of these new elements are accumulated in the array ndx */
270.1143 +         len = 0;
270.1144 +         for (p_ptr = p_beg; p_ptr <= p_end; p_ptr++)
270.1145 +         {  /* get column index of v[p,j], which may cause fill-in */
270.1146 +            j = sv_ind[p_ptr];
270.1147 +            if (flag[j])
270.1148 +            {  /* compute new non-zero v[i,j] = 0 - f[i,p] * v[p,j] */
270.1149 +               temp = (val = - fip * work[j]);
270.1150 +               if (temp < 0.0) temp = - temp;
270.1151 +               if (temp == 0.0 || temp < eps_tol)
270.1152 +                  /* if v[i,j] is closer to zero; just ignore it */;
270.1153 +               else
270.1154 +               {  /* add v[i,j] to the i-th row */
270.1155 +                  i_ptr = vr_ptr[i] + vr_len[i];
270.1156 +                  sv_ind[i_ptr] = j;
270.1157 +                  sv_val[i_ptr] = val;
270.1158 +                  vr_len[i]++;
270.1159 +                  /* remember column index of v[i,j] */
270.1160 +                  ndx[++len] = j;
270.1161 +                  /* big_v := max(big_v, |v[i,j]|) */
270.1162 +                  if (luf->big_v < temp) luf->big_v = temp;
270.1163 +               }
270.1164 +            }
270.1165 +            else
270.1166 +            {  /* there is no fill-in, because v[i,j] already exists in
270.1167 +                  the i-th row; restore the flag of the element v[p,j],
270.1168 +                  which was reset before */
270.1169 +               flag[j] = 1;
270.1170 +            }
270.1171 +         }
270.1172 +         /* add new non-zeros v[i,j] to the corresponding columns */
270.1173 +         for (k = 1; k <= len; k++)
270.1174 +         {  /* get column index of new non-zero v[i,j] */
270.1175 +            j = ndx[k];
270.1176 +            /* one free location is needed in the j-th column */
270.1177 +            if (vc_len[j] + 1 > vc_cap[j])
270.1178 +            {  /* enlarge the j-th column */
270.1179 +               if (luf_enlarge_col(luf, j, vc_len[j] + 10))
270.1180 +               {  /* overflow of the sparse vector area */
270.1181 +                  ret = 1;
270.1182 +                  goto done;
270.1183 +               }
270.1184 +               /* defragmentation may change row and column pointers of
270.1185 +                  the matrix V */
270.1186 +               p_beg = vr_ptr[p];
270.1187 +               p_end = p_beg + vr_len[p] - 1;
270.1188 +               q_beg = vc_ptr[q];
270.1189 +               q_end = q_beg + vc_len[q] - 1;
270.1190 +            }
270.1191 +            /* add new non-zero v[i,j] to the j-th column */
270.1192 +            j_ptr = vc_ptr[j] + vc_len[j];
270.1193 +            sv_ind[j_ptr] = i;
270.1194 +            vc_len[j]++;
270.1195 +         }
270.1196 +         /* now the i-th row has been completely transformed, therefore
270.1197 +            it can return to the active set with new length */
270.1198 +         rs_prev[i] = 0;
270.1199 +         rs_next[i] = rs_head[vr_len[i]];
270.1200 +         if (rs_next[i] != 0) rs_prev[rs_next[i]] = i;
270.1201 +         rs_head[vr_len[i]] = i;
270.1202 +         /* the largest of absolute values of elements in the i-th row
270.1203 +            is currently unknown */
270.1204 +         vr_max[i] = -1.0;
270.1205 +         /* at least one free location is needed to store the gaussian
270.1206 +            multiplier */
270.1207 +         if (luf->sv_end - luf->sv_beg < 1)
270.1208 +         {  /* there are no free locations at all; defragment SVA */
270.1209 +            luf_defrag_sva(luf);
270.1210 +            if (luf->sv_end - luf->sv_beg < 1)
270.1211 +            {  /* overflow of the sparse vector area */
270.1212 +               ret = 1;
270.1213 +               goto done;
270.1214 +            }
270.1215 +            /* defragmentation may change row and column pointers of the
270.1216 +               matrix V */
270.1217 +            p_beg = vr_ptr[p];
270.1218 +            p_end = p_beg + vr_len[p] - 1;
270.1219 +            q_beg = vc_ptr[q];
270.1220 +            q_end = q_beg + vc_len[q] - 1;
270.1221 +         }
270.1222 +         /* add the element f[i,p], which is the gaussian multiplier,
270.1223 +            to the matrix F */
270.1224 +         luf->sv_end--;
270.1225 +         sv_ind[luf->sv_end] = i;
270.1226 +         sv_val[luf->sv_end] = fip;
270.1227 +         fc_len[p]++;
270.1228 +         /* end of elimination loop */
270.1229 +      }
270.1230 +      /* at this point the q-th (pivot) column should be empty */
270.1231 +      xassert(vc_len[q] == 0);
270.1232 +      /* reset capacity of the q-th column */
270.1233 +      vc_cap[q] = 0;
270.1234 +      /* remove node of the q-th column from the addressing list */
270.1235 +      k = n + q;
270.1236 +      if (sv_prev[k] == 0)
270.1237 +         luf->sv_head = sv_next[k];
270.1238 +      else
270.1239 +         sv_next[sv_prev[k]] = sv_next[k];
270.1240 +      if (sv_next[k] == 0)
270.1241 +         luf->sv_tail = sv_prev[k];
270.1242 +      else
270.1243 +         sv_prev[sv_next[k]] = sv_prev[k];
270.1244 +      /* the p-th column of the matrix F has been completely built; set
270.1245 +         its pointer */
270.1246 +      fc_ptr[p] = luf->sv_end;
270.1247 +      /* walk through the p-th (pivot) row and do the following... */
270.1248 +      for (p_ptr = p_beg; p_ptr <= p_end; p_ptr++)
270.1249 +      {  /* get column index of v[p,j] */
270.1250 +         j = sv_ind[p_ptr];
270.1251 +         /* erase v[p,j] from the working array */
270.1252 +         flag[j] = 0;
270.1253 +         work[j] = 0.0;
270.1254 +         /* the j-th column has been completely transformed, therefore
270.1255 +            it can return to the active set with new length; however
270.1256 +            the special case c_prev[j] = c_next[j] = j means that the
270.1257 +            routine find_pivot excluded the j-th column from the active
270.1258 +            set due to Uwe Suhl's rule, and therefore in this case the
270.1259 +            column can return to the active set only if it is a column
270.1260 +            singleton */
270.1261 +         if (!(vc_len[j] != 1 && cs_prev[j] == j && cs_next[j] == j))
270.1262 +         {  cs_prev[j] = 0;
270.1263 +            cs_next[j] = cs_head[vc_len[j]];
270.1264 +            if (cs_next[j] != 0) cs_prev[cs_next[j]] = j;
270.1265 +            cs_head[vc_len[j]] = j;
270.1266 +         }
270.1267 +      }
270.1268 +done: /* return to the factorizing routine */
270.1269 +      return ret;
270.1270 +}
270.1271 +
270.1272 +/***********************************************************************
270.1273 +*  build_v_cols - build the matrix V in column-wise format
270.1274 +*
270.1275 +*  This routine builds the column-wise representation of the matrix V
270.1276 +*  using its row-wise representation.
270.1277 +*
270.1278 +*  If no error occured, the routine returns zero. Otherwise, in case of
270.1279 +*  overflow of the sparse vector area, the routine returns non-zero. */
270.1280 +
270.1281 +static int build_v_cols(LUF *luf)
270.1282 +{     int n = luf->n;
270.1283 +      int *vr_ptr = luf->vr_ptr;
270.1284 +      int *vr_len = luf->vr_len;
270.1285 +      int *vc_ptr = luf->vc_ptr;
270.1286 +      int *vc_len = luf->vc_len;
270.1287 +      int *vc_cap = luf->vc_cap;
270.1288 +      int *sv_ind = luf->sv_ind;
270.1289 +      double *sv_val = luf->sv_val;
270.1290 +      int *sv_prev = luf->sv_prev;
270.1291 +      int *sv_next = luf->sv_next;
270.1292 +      int ret = 0;
270.1293 +      int i, i_beg, i_end, i_ptr, j, j_ptr, k, nnz;
270.1294 +      /* it is assumed that on entry all columns of the matrix V are
270.1295 +         empty, i.e. vc_len[j] = vc_cap[j] = 0 for all j = 1, ..., n,
270.1296 +         and have been removed from the addressing list */
270.1297 +      /* count non-zeros in columns of the matrix V; count total number
270.1298 +         of non-zeros in this matrix */
270.1299 +      nnz = 0;
270.1300 +      for (i = 1; i <= n; i++)
270.1301 +      {  /* walk through elements of the i-th row and count non-zeros
270.1302 +            in the corresponding columns */
270.1303 +         i_beg = vr_ptr[i];
270.1304 +         i_end = i_beg + vr_len[i] - 1;
270.1305 +         for (i_ptr = i_beg; i_ptr <= i_end; i_ptr++)
270.1306 +            vc_cap[sv_ind[i_ptr]]++;
270.1307 +         /* count total number of non-zeros */
270.1308 +         nnz += vr_len[i];
270.1309 +      }
270.1310 +      /* store total number of non-zeros */
270.1311 +      luf->nnz_v = nnz;
270.1312 +      /* check for free locations */
270.1313 +      if (luf->sv_end - luf->sv_beg < nnz)
270.1314 +      {  /* overflow of the sparse vector area */
270.1315 +         ret = 1;
270.1316 +         goto done;
270.1317 +      }
270.1318 +      /* allocate columns of the matrix V */
270.1319 +      for (j = 1; j <= n; j++)
270.1320 +      {  /* set pointer to the j-th column */
270.1321 +         vc_ptr[j] = luf->sv_beg;
270.1322 +         /* reserve locations for the j-th column */
270.1323 +         luf->sv_beg += vc_cap[j];
270.1324 +      }
270.1325 +      /* build the matrix V in column-wise format using this matrix in
270.1326 +         row-wise format */
270.1327 +      for (i = 1; i <= n; i++)
270.1328 +      {  /* walk through elements of the i-th row */
270.1329 +         i_beg = vr_ptr[i];
270.1330 +         i_end = i_beg + vr_len[i] - 1;
270.1331 +         for (i_ptr = i_beg; i_ptr <= i_end; i_ptr++)
270.1332 +         {  /* get column index */
270.1333 +            j = sv_ind[i_ptr];
270.1334 +            /* store element in the j-th column */
270.1335 +            j_ptr = vc_ptr[j] + vc_len[j];
270.1336 +            sv_ind[j_ptr] = i;
270.1337 +            sv_val[j_ptr] = sv_val[i_ptr];
270.1338 +            /* increase length of the j-th column */
270.1339 +            vc_len[j]++;
270.1340 +         }
270.1341 +      }
270.1342 +      /* now columns are placed in the sparse vector area behind rows
270.1343 +         in the order n+1, n+2, ..., n+n; so insert column nodes in the
270.1344 +         addressing list using this order */
270.1345 +      for (k = n+1; k <= n+n; k++)
270.1346 +      {  sv_prev[k] = k-1;
270.1347 +         sv_next[k] = k+1;
270.1348 +      }
270.1349 +      sv_prev[n+1] = luf->sv_tail;
270.1350 +      sv_next[luf->sv_tail] = n+1;
270.1351 +      sv_next[n+n] = 0;
270.1352 +      luf->sv_tail = n+n;
270.1353 +done: /* return to the factorizing routine */
270.1354 +      return ret;
270.1355 +}
270.1356 +
270.1357 +/***********************************************************************
270.1358 +*  build_f_rows - build the matrix F in row-wise format
270.1359 +*
270.1360 +*  This routine builds the row-wise representation of the matrix F using
270.1361 +*  its column-wise representation.
270.1362 +*
270.1363 +*  If no error occured, the routine returns zero. Otherwise, in case of
270.1364 +*  overflow of the sparse vector area, the routine returns non-zero. */
270.1365 +
270.1366 +static int build_f_rows(LUF *luf)
270.1367 +{     int n = luf->n;
270.1368 +      int *fr_ptr = luf->fr_ptr;
270.1369 +      int *fr_len = luf->fr_len;
270.1370 +      int *fc_ptr = luf->fc_ptr;
270.1371 +      int *fc_len = luf->fc_len;
270.1372 +      int *sv_ind = luf->sv_ind;
270.1373 +      double *sv_val = luf->sv_val;
270.1374 +      int ret = 0;
270.1375 +      int i, j, j_beg, j_end, j_ptr, ptr, nnz;
270.1376 +      /* clear rows of the matrix F */
270.1377 +      for (i = 1; i <= n; i++) fr_len[i] = 0;
270.1378 +      /* count non-zeros in rows of the matrix F; count total number of
270.1379 +         non-zeros in this matrix */
270.1380 +      nnz = 0;
270.1381 +      for (j = 1; j <= n; j++)
270.1382 +      {  /* walk through elements of the j-th column and count non-zeros
270.1383 +            in the corresponding rows */
270.1384 +         j_beg = fc_ptr[j];
270.1385 +         j_end = j_beg + fc_len[j] - 1;
270.1386 +         for (j_ptr = j_beg; j_ptr <= j_end; j_ptr++)
270.1387 +            fr_len[sv_ind[j_ptr]]++;
270.1388 +         /* increase total number of non-zeros */
270.1389 +         nnz += fc_len[j];
270.1390 +      }
270.1391 +      /* store total number of non-zeros */
270.1392 +      luf->nnz_f = nnz;
270.1393 +      /* check for free locations */
270.1394 +      if (luf->sv_end - luf->sv_beg < nnz)
270.1395 +      {  /* overflow of the sparse vector area */
270.1396 +         ret = 1;
270.1397 +         goto done;
270.1398 +      }
270.1399 +      /* allocate rows of the matrix F */
270.1400 +      for (i = 1; i <= n; i++)
270.1401 +      {  /* set pointer to the end of the i-th row; later this pointer
270.1402 +            will be set to the beginning of the i-th row */
270.1403 +         fr_ptr[i] = luf->sv_end;
270.1404 +         /* reserve locations for the i-th row */
270.1405 +         luf->sv_end -= fr_len[i];
270.1406 +      }
270.1407 +      /* build the matrix F in row-wise format using this matrix in
270.1408 +         column-wise format */
270.1409 +      for (j = 1; j <= n; j++)
270.1410 +      {  /* walk through elements of the j-th column */
270.1411 +         j_beg = fc_ptr[j];
270.1412 +         j_end = j_beg + fc_len[j] - 1;
270.1413 +         for (j_ptr = j_beg; j_ptr <= j_end; j_ptr++)
270.1414 +         {  /* get row index */
270.1415 +            i = sv_ind[j_ptr];
270.1416 +            /* store element in the i-th row */
270.1417 +            ptr = --fr_ptr[i];
270.1418 +            sv_ind[ptr] = j;
270.1419 +            sv_val[ptr] = sv_val[j_ptr];
270.1420 +         }
270.1421 +      }
270.1422 +done: /* return to the factorizing routine */
270.1423 +      return ret;
270.1424 +}
270.1425 +
270.1426 +/***********************************************************************
270.1427 +*  NAME
270.1428 +*
270.1429 +*  luf_factorize - compute LU-factorization
270.1430 +*
270.1431 +*  SYNOPSIS
270.1432 +*
270.1433 +*  #include "glpluf.h"
270.1434 +*  int luf_factorize(LUF *luf, int n, int (*col)(void *info, int j,
270.1435 +*     int ind[], double val[]), void *info);
270.1436 +*
270.1437 +*  DESCRIPTION
270.1438 +*
270.1439 +*  The routine luf_factorize computes LU-factorization of a specified
270.1440 +*  square matrix A.
270.1441 +*
270.1442 +*  The parameter luf specifies LU-factorization program object created
270.1443 +*  by the routine luf_create_it.
270.1444 +*
270.1445 +*  The parameter n specifies the order of A, n > 0.
270.1446 +*
270.1447 +*  The formal routine col specifies the matrix A to be factorized. To
270.1448 +*  obtain j-th column of A the routine luf_factorize calls the routine
270.1449 +*  col with the parameter j (1 <= j <= n). In response the routine col
270.1450 +*  should store row indices and numerical values of non-zero elements
270.1451 +*  of j-th column of A to locations ind[1,...,len] and val[1,...,len],
270.1452 +*  respectively, where len is the number of non-zeros in j-th column
270.1453 +*  returned on exit. Neither zero nor duplicate elements are allowed.
270.1454 +*
270.1455 +*  The parameter info is a transit pointer passed to the routine col.
270.1456 +*
270.1457 +*  RETURNS
270.1458 +*
270.1459 +*  0  LU-factorization has been successfully computed.
270.1460 +*
270.1461 +*  LUF_ESING
270.1462 +*     The specified matrix is singular within the working precision.
270.1463 +*     (On some elimination step the active submatrix is exactly zero,
270.1464 +*     so no pivot can be chosen.)
270.1465 +*
270.1466 +*  LUF_ECOND
270.1467 +*     The specified matrix is ill-conditioned.
270.1468 +*     (On some elimination step too intensive growth of elements of the
270.1469 +*     active submatix has been detected.)
270.1470 +*
270.1471 +*  If matrix A is well scaled, the return code LUF_ECOND may also mean
270.1472 +*  that the threshold pivoting tolerance piv_tol should be increased.
270.1473 +*
270.1474 +*  In case of non-zero return code the factorization becomes invalid.
270.1475 +*  It should not be used in other operations until the cause of failure
270.1476 +*  has been eliminated and the factorization has been recomputed again
270.1477 +*  with the routine luf_factorize.
270.1478 +*
270.1479 +*  REPAIRING SINGULAR MATRIX
270.1480 +*
270.1481 +*  If the routine luf_factorize returns non-zero code, it provides all
270.1482 +*  necessary information that can be used for "repairing" the matrix A,
270.1483 +*  where "repairing" means replacing linearly dependent columns of the
270.1484 +*  matrix A by appropriate columns of the unity matrix. This feature is
270.1485 +*  needed when this routine is used for factorizing the basis matrix
270.1486 +*  within the simplex method procedure.
270.1487 +*
270.1488 +*  On exit linearly dependent columns of the (partially transformed)
270.1489 +*  matrix U have numbers rank+1, rank+2, ..., n, where rank is estimated
270.1490 +*  rank of the matrix A stored by the routine to the member luf->rank.
270.1491 +*  The correspondence between columns of A and U is the same as between
270.1492 +*  columns of V and U. Thus, linearly dependent columns of the matrix A
270.1493 +*  have numbers qq_col[rank+1], qq_col[rank+2], ..., qq_col[n], where
270.1494 +*  qq_col is the column-like representation of the permutation matrix Q.
270.1495 +*  It is understood that each j-th linearly dependent column of the
270.1496 +*  matrix U should be replaced by the unity vector, where all elements
270.1497 +*  are zero except the unity diagonal element u[j,j]. On the other hand
270.1498 +*  j-th row of the matrix U corresponds to the row of the matrix V (and
270.1499 +*  therefore of the matrix A) with the number pp_row[j], where pp_row is
270.1500 +*  the row-like representation of the permutation matrix P. Thus, each
270.1501 +*  j-th linearly dependent column of the matrix U should be replaced by
270.1502 +*  column of the unity matrix with the number pp_row[j].
270.1503 +*
270.1504 +*  The code that repairs the matrix A may look like follows:
270.1505 +*
270.1506 +*     for (j = rank+1; j <= n; j++)
270.1507 +*     {  replace the column qq_col[j] of the matrix A by the column
270.1508 +*        pp_row[j] of the unity matrix;
270.1509 +*     }
270.1510 +*
270.1511 +*  where rank, pp_row, and qq_col are members of the structure LUF. */
270.1512 +
270.1513 +int luf_factorize(LUF *luf, int n, int (*col)(void *info, int j,
270.1514 +      int ind[], double val[]), void *info)
270.1515 +{     int *pp_row, *pp_col, *qq_row, *qq_col;
270.1516 +      double max_gro = luf->max_gro;
270.1517 +      int i, j, k, p, q, t, ret;
270.1518 +      if (n < 1)
270.1519 +         xfault("luf_factorize: n = %d; invalid parameter\n", n);
270.1520 +      if (n > N_MAX)
270.1521 +         xfault("luf_factorize: n = %d; matrix too big\n", n);
270.1522 +      /* invalidate the factorization */
270.1523 +      luf->valid = 0;
270.1524 +      /* reallocate arrays, if necessary */
270.1525 +      reallocate(luf, n);
270.1526 +      pp_row = luf->pp_row;
270.1527 +      pp_col = luf->pp_col;
270.1528 +      qq_row = luf->qq_row;
270.1529 +      qq_col = luf->qq_col;
270.1530 +      /* estimate initial size of the SVA, if not specified */
270.1531 +      if (luf->sv_size == 0 && luf->new_sva == 0)
270.1532 +         luf->new_sva = 5 * (n + 10);
270.1533 +more: /* reallocate the sparse vector area, if required */
270.1534 +      if (luf->new_sva > 0)
270.1535 +      {  if (luf->sv_ind != NULL) xfree(luf->sv_ind);
270.1536 +         if (luf->sv_val != NULL) xfree(luf->sv_val);
270.1537 +         luf->sv_size = luf->new_sva;
270.1538 +         luf->sv_ind = xcalloc(1+luf->sv_size, sizeof(int));
270.1539 +         luf->sv_val = xcalloc(1+luf->sv_size, sizeof(double));
270.1540 +         luf->new_sva = 0;
270.1541 +      }
270.1542 +      /* initialize LU-factorization data structures */
270.1543 +      if (initialize(luf, col, info))
270.1544 +      {  /* overflow of the sparse vector area */
270.1545 +         luf->new_sva = luf->sv_size + luf->sv_size;
270.1546 +         xassert(luf->new_sva > luf->sv_size);
270.1547 +         goto more;
270.1548 +      }
270.1549 +      /* main elimination loop */
270.1550 +      for (k = 1; k <= n; k++)
270.1551 +      {  /* choose a pivot element v[p,q] */
270.1552 +         if (find_pivot(luf, &p, &q))
270.1553 +         {  /* no pivot can be chosen, because the active submatrix is
270.1554 +               exactly zero */
270.1555 +            luf->rank = k - 1;
270.1556 +            ret = LUF_ESING;
270.1557 +            goto done;
270.1558 +         }
270.1559 +         /* let v[p,q] correspond to u[i',j']; permute k-th and i'-th
270.1560 +            rows and k-th and j'-th columns of the matrix U = P*V*Q to
270.1561 +            move the element u[i',j'] to the position u[k,k] */
270.1562 +         i = pp_col[p], j = qq_row[q];
270.1563 +         xassert(k <= i && i <= n && k <= j && j <= n);
270.1564 +         /* permute k-th and i-th rows of the matrix U */
270.1565 +         t = pp_row[k];
270.1566 +         pp_row[i] = t, pp_col[t] = i;
270.1567 +         pp_row[k] = p, pp_col[p] = k;
270.1568 +         /* permute k-th and j-th columns of the matrix U */
270.1569 +         t = qq_col[k];
270.1570 +         qq_col[j] = t, qq_row[t] = j;
270.1571 +         qq_col[k] = q, qq_row[q] = k;
270.1572 +         /* eliminate subdiagonal elements of k-th column of the matrix
270.1573 +            U = P*V*Q using the pivot element u[k,k] = v[p,q] */
270.1574 +         if (eliminate(luf, p, q))
270.1575 +         {  /* overflow of the sparse vector area */
270.1576 +            luf->new_sva = luf->sv_size + luf->sv_size;
270.1577 +            xassert(luf->new_sva > luf->sv_size);
270.1578 +            goto more;
270.1579 +         }
270.1580 +         /* check relative growth of elements of the matrix V */
270.1581 +         if (luf->big_v > max_gro * luf->max_a)
270.1582 +         {  /* the growth is too intensive, therefore most probably the
270.1583 +               matrix A is ill-conditioned */
270.1584 +            luf->rank = k - 1;
270.1585 +            ret = LUF_ECOND;
270.1586 +            goto done;
270.1587 +         }
270.1588 +      }
270.1589 +      /* now the matrix U = P*V*Q is upper triangular, the matrix V has
270.1590 +         been built in row-wise format, and the matrix F has been built
270.1591 +         in column-wise format */
270.1592 +      /* defragment the sparse vector area in order to merge all free
270.1593 +         locations in one continuous extent */
270.1594 +      luf_defrag_sva(luf);
270.1595 +      /* build the matrix V in column-wise format */
270.1596 +      if (build_v_cols(luf))
270.1597 +      {  /* overflow of the sparse vector area */
270.1598 +         luf->new_sva = luf->sv_size + luf->sv_size;
270.1599 +         xassert(luf->new_sva > luf->sv_size);
270.1600 +         goto more;
270.1601 +      }
270.1602 +      /* build the matrix F in row-wise format */
270.1603 +      if (build_f_rows(luf))
270.1604 +      {  /* overflow of the sparse vector area */
270.1605 +         luf->new_sva = luf->sv_size + luf->sv_size;
270.1606 +         xassert(luf->new_sva > luf->sv_size);
270.1607 +         goto more;
270.1608 +      }
270.1609 +      /* the LU-factorization has been successfully computed */
270.1610 +      luf->valid = 1;
270.1611 +      luf->rank = n;
270.1612 +      ret = 0;
270.1613 +      /* if there are few free locations in the sparse vector area, try
270.1614 +         increasing its size in the future */
270.1615 +      t = 3 * (n + luf->nnz_v) + 2 * luf->nnz_f;
270.1616 +      if (luf->sv_size < t)
270.1617 +      {  luf->new_sva = luf->sv_size;
270.1618 +         while (luf->new_sva < t)
270.1619 +         {  k = luf->new_sva;
270.1620 +            luf->new_sva = k + k;
270.1621 +            xassert(luf->new_sva > k);
270.1622 +         }
270.1623 +      }
270.1624 +done: /* return to the calling program */
270.1625 +      return ret;
270.1626 +}
270.1627 +
270.1628 +/***********************************************************************
270.1629 +*  NAME
270.1630 +*
270.1631 +*  luf_f_solve - solve system F*x = b or F'*x = b
270.1632 +*
270.1633 +*  SYNOPSIS
270.1634 +*
270.1635 +*  #include "glpluf.h"
270.1636 +*  void luf_f_solve(LUF *luf, int tr, double x[]);
270.1637 +*
270.1638 +*  DESCRIPTION
270.1639 +*
270.1640 +*  The routine luf_f_solve solves either the system F*x = b (if the
270.1641 +*  flag tr is zero) or the system F'*x = b (if the flag tr is non-zero),
270.1642 +*  where the matrix F is a component of LU-factorization specified by
270.1643 +*  the parameter luf, F' is a matrix transposed to F.
270.1644 +*
270.1645 +*  On entry the array x should contain elements of the right-hand side
270.1646 +*  vector b in locations x[1], ..., x[n], where n is the order of the
270.1647 +*  matrix F. On exit this array will contain elements of the solution
270.1648 +*  vector x in the same locations. */
270.1649 +
270.1650 +void luf_f_solve(LUF *luf, int tr, double x[])
270.1651 +{     int n = luf->n;
270.1652 +      int *fr_ptr = luf->fr_ptr;
270.1653 +      int *fr_len = luf->fr_len;
270.1654 +      int *fc_ptr = luf->fc_ptr;
270.1655 +      int *fc_len = luf->fc_len;
270.1656 +      int *pp_row = luf->pp_row;
270.1657 +      int *sv_ind = luf->sv_ind;
270.1658 +      double *sv_val = luf->sv_val;
270.1659 +      int i, j, k, beg, end, ptr;
270.1660 +      double xk;
270.1661 +      if (!luf->valid)
270.1662 +         xfault("luf_f_solve: LU-factorization is not valid\n");
270.1663 +      if (!tr)
270.1664 +      {  /* solve the system F*x = b */
270.1665 +         for (j = 1; j <= n; j++)
270.1666 +         {  k = pp_row[j];
270.1667 +            xk = x[k];
270.1668 +            if (xk != 0.0)
270.1669 +            {  beg = fc_ptr[k];
270.1670 +               end = beg + fc_len[k] - 1;
270.1671 +               for (ptr = beg; ptr <= end; ptr++)
270.1672 +                  x[sv_ind[ptr]] -= sv_val[ptr] * xk;
270.1673 +            }
270.1674 +         }
270.1675 +      }
270.1676 +      else
270.1677 +      {  /* solve the system F'*x = b */
270.1678 +         for (i = n; i >= 1; i--)
270.1679 +         {  k = pp_row[i];
270.1680 +            xk = x[k];
270.1681 +            if (xk != 0.0)
270.1682 +            {  beg = fr_ptr[k];
270.1683 +               end = beg + fr_len[k] - 1;
270.1684 +               for (ptr = beg; ptr <= end; ptr++)
270.1685 +                  x[sv_ind[ptr]] -= sv_val[ptr] * xk;
270.1686 +            }
270.1687 +         }
270.1688 +      }
270.1689 +      return;
270.1690 +}
270.1691 +
270.1692 +/***********************************************************************
270.1693 +*  NAME
270.1694 +*
270.1695 +*  luf_v_solve - solve system V*x = b or V'*x = b
270.1696 +*
270.1697 +*  SYNOPSIS
270.1698 +*
270.1699 +*  #include "glpluf.h"
270.1700 +*  void luf_v_solve(LUF *luf, int tr, double x[]);
270.1701 +*
270.1702 +*  DESCRIPTION
270.1703 +*
270.1704 +*  The routine luf_v_solve solves either the system V*x = b (if the
270.1705 +*  flag tr is zero) or the system V'*x = b (if the flag tr is non-zero),
270.1706 +*  where the matrix V is a component of LU-factorization specified by
270.1707 +*  the parameter luf, V' is a matrix transposed to V.
270.1708 +*
270.1709 +*  On entry the array x should contain elements of the right-hand side
270.1710 +*  vector b in locations x[1], ..., x[n], where n is the order of the
270.1711 +*  matrix V. On exit this array will contain elements of the solution
270.1712 +*  vector x in the same locations. */
270.1713 +
270.1714 +void luf_v_solve(LUF *luf, int tr, double x[])
270.1715 +{     int n = luf->n;
270.1716 +      int *vr_ptr = luf->vr_ptr;
270.1717 +      int *vr_len = luf->vr_len;
270.1718 +      double *vr_piv = luf->vr_piv;
270.1719 +      int *vc_ptr = luf->vc_ptr;
270.1720 +      int *vc_len = luf->vc_len;
270.1721 +      int *pp_row = luf->pp_row;
270.1722 +      int *qq_col = luf->qq_col;
270.1723 +      int *sv_ind = luf->sv_ind;
270.1724 +      double *sv_val = luf->sv_val;
270.1725 +      double *b = luf->work;
270.1726 +      int i, j, k, beg, end, ptr;
270.1727 +      double temp;
270.1728 +      if (!luf->valid)
270.1729 +         xfault("luf_v_solve: LU-factorization is not valid\n");
270.1730 +      for (k = 1; k <= n; k++) b[k] = x[k], x[k] = 0.0;
270.1731 +      if (!tr)
270.1732 +      {  /* solve the system V*x = b */
270.1733 +         for (k = n; k >= 1; k--)
270.1734 +         {  i = pp_row[k], j = qq_col[k];
270.1735 +            temp = b[i];
270.1736 +            if (temp != 0.0)
270.1737 +            {  x[j] = (temp /= vr_piv[i]);
270.1738 +               beg = vc_ptr[j];
270.1739 +               end = beg + vc_len[j] - 1;
270.1740 +               for (ptr = beg; ptr <= end; ptr++)
270.1741 +                  b[sv_ind[ptr]] -= sv_val[ptr] * temp;
270.1742 +            }
270.1743 +         }
270.1744 +      }
270.1745 +      else
270.1746 +      {  /* solve the system V'*x = b */
270.1747 +         for (k = 1; k <= n; k++)
270.1748 +         {  i = pp_row[k], j = qq_col[k];
270.1749 +            temp = b[j];
270.1750 +            if (temp != 0.0)
270.1751 +            {  x[i] = (temp /= vr_piv[i]);
270.1752 +               beg = vr_ptr[i];
270.1753 +               end = beg + vr_len[i] - 1;
270.1754 +               for (ptr = beg; ptr <= end; ptr++)
270.1755 +                  b[sv_ind[ptr]] -= sv_val[ptr] * temp;
270.1756 +            }
270.1757 +         }
270.1758 +      }
270.1759 +      return;
270.1760 +}
270.1761 +
270.1762 +/***********************************************************************
270.1763 +*  NAME
270.1764 +*
270.1765 +*  luf_a_solve - solve system A*x = b or A'*x = b
270.1766 +*
270.1767 +*  SYNOPSIS
270.1768 +*
270.1769 +*  #include "glpluf.h"
270.1770 +*  void luf_a_solve(LUF *luf, int tr, double x[]);
270.1771 +*
270.1772 +*  DESCRIPTION
270.1773 +*
270.1774 +*  The routine luf_a_solve solves either the system A*x = b (if the
270.1775 +*  flag tr is zero) or the system A'*x = b (if the flag tr is non-zero),
270.1776 +*  where the parameter luf specifies LU-factorization of the matrix A,
270.1777 +*  A' is a matrix transposed to A.
270.1778 +*
270.1779 +*  On entry the array x should contain elements of the right-hand side
270.1780 +*  vector b in locations x[1], ..., x[n], where n is the order of the
270.1781 +*  matrix A. On exit this array will contain elements of the solution
270.1782 +*  vector x in the same locations. */
270.1783 +
270.1784 +void luf_a_solve(LUF *luf, int tr, double x[])
270.1785 +{     if (!luf->valid)
270.1786 +         xfault("luf_a_solve: LU-factorization is not valid\n");
270.1787 +      if (!tr)
270.1788 +      {  /* A = F*V, therefore inv(A) = inv(V)*inv(F) */
270.1789 +         luf_f_solve(luf, 0, x);
270.1790 +         luf_v_solve(luf, 0, x);
270.1791 +      }
270.1792 +      else
270.1793 +      {  /* A' = V'*F', therefore inv(A') = inv(F')*inv(V') */
270.1794 +         luf_v_solve(luf, 1, x);
270.1795 +         luf_f_solve(luf, 1, x);
270.1796 +      }
270.1797 +      return;
270.1798 +}
270.1799 +
270.1800 +/***********************************************************************
270.1801 +*  NAME
270.1802 +*
270.1803 +*  luf_delete_it - delete LU-factorization
270.1804 +*
270.1805 +*  SYNOPSIS
270.1806 +*
270.1807 +*  #include "glpluf.h"
270.1808 +*  void luf_delete_it(LUF *luf);
270.1809 +*
270.1810 +*  DESCRIPTION
270.1811 +*
270.1812 +*  The routine luf_delete deletes LU-factorization specified by the
270.1813 +*  parameter luf and frees all the memory allocated to this program
270.1814 +*  object. */
270.1815 +
270.1816 +void luf_delete_it(LUF *luf)
270.1817 +{     if (luf->fr_ptr != NULL) xfree(luf->fr_ptr);
270.1818 +      if (luf->fr_len != NULL) xfree(luf->fr_len);
270.1819 +      if (luf->fc_ptr != NULL) xfree(luf->fc_ptr);
270.1820 +      if (luf->fc_len != NULL) xfree(luf->fc_len);
270.1821 +      if (luf->vr_ptr != NULL) xfree(luf->vr_ptr);
270.1822 +      if (luf->vr_len != NULL) xfree(luf->vr_len);
270.1823 +      if (luf->vr_cap != NULL) xfree(luf->vr_cap);
270.1824 +      if (luf->vr_piv != NULL) xfree(luf->vr_piv);
270.1825 +      if (luf->vc_ptr != NULL) xfree(luf->vc_ptr);
270.1826 +      if (luf->vc_len != NULL) xfree(luf->vc_len);
270.1827 +      if (luf->vc_cap != NULL) xfree(luf->vc_cap);
270.1828 +      if (luf->pp_row != NULL) xfree(luf->pp_row);
270.1829 +      if (luf->pp_col != NULL) xfree(luf->pp_col);
270.1830 +      if (luf->qq_row != NULL) xfree(luf->qq_row);
270.1831 +      if (luf->qq_col != NULL) xfree(luf->qq_col);
270.1832 +      if (luf->sv_ind != NULL) xfree(luf->sv_ind);
270.1833 +      if (luf->sv_val != NULL) xfree(luf->sv_val);
270.1834 +      if (luf->sv_prev != NULL) xfree(luf->sv_prev);
270.1835 +      if (luf->sv_next != NULL) xfree(luf->sv_next);
270.1836 +      if (luf->vr_max != NULL) xfree(luf->vr_max);
270.1837 +      if (luf->rs_head != NULL) xfree(luf->rs_head);
270.1838 +      if (luf->rs_prev != NULL) xfree(luf->rs_prev);
270.1839 +      if (luf->rs_next != NULL) xfree(luf->rs_next);
270.1840 +      if (luf->cs_head != NULL) xfree(luf->cs_head);
270.1841 +      if (luf->cs_prev != NULL) xfree(luf->cs_prev);
270.1842 +      if (luf->cs_next != NULL) xfree(luf->cs_next);
270.1843 +      if (luf->flag != NULL) xfree(luf->flag);
270.1844 +      if (luf->work != NULL) xfree(luf->work);
270.1845 +      xfree(luf);
270.1846 +      return;
270.1847 +}
270.1848 +
270.1849 +/* eof */
   271.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
   271.2 +++ b/deps/glpk/src/glpluf.h	Sun Nov 06 20:59:10 2011 +0100
   271.3 @@ -0,0 +1,326 @@
   271.4 +/* glpluf.h (LU-factorization) */
   271.5 +
   271.6 +/***********************************************************************
   271.7 +*  This code is part of GLPK (GNU Linear Programming Kit).
   271.8 +*
   271.9 +*  Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008,
  271.10 +*  2009, 2010, 2011 Andrew Makhorin, Department for Applied Informatics,
  271.11 +*  Moscow Aviation Institute, Moscow, Russia. All rights reserved.
  271.12 +*  E-mail: <mao@gnu.org>.
  271.13 +*
  271.14 +*  GLPK is free software: you can redistribute it and/or modify it
  271.15 +*  under the terms of the GNU General Public License as published by
  271.16 +*  the Free Software Foundation, either version 3 of the License, or
  271.17 +*  (at your option) any later version.
  271.18 +*
  271.19 +*  GLPK is distributed in the hope that it will be useful, but WITHOUT
  271.20 +*  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
  271.21 +*  or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
  271.22 +*  License for more details.
  271.23 +*
  271.24 +*  You should have received a copy of the GNU General Public License
  271.25 +*  along with GLPK. If not, see <http://www.gnu.org/licenses/>.
  271.26 +***********************************************************************/
  271.27 +
  271.28 +#ifndef GLPLUF_H
  271.29 +#define GLPLUF_H
  271.30 +
  271.31 +/***********************************************************************
  271.32 +*  The structure LUF defines LU-factorization of a square matrix A and
  271.33 +*  is the following quartet:
  271.34 +*
  271.35 +*     [A] = (F, V, P, Q),                                            (1)
  271.36 +*
  271.37 +*  where F and V are such matrices that
  271.38 +*
  271.39 +*     A = F * V,                                                     (2)
  271.40 +*
  271.41 +*  and P and Q are such permutation matrices that the matrix
  271.42 +*
  271.43 +*     L = P * F * inv(P)                                             (3)
  271.44 +*
  271.45 +*  is lower triangular with unity diagonal, and the matrix
  271.46 +*
  271.47 +*     U = P * V * Q                                                  (4)
  271.48 +*
  271.49 +*  is upper triangular. All the matrices have the order n.
  271.50 +*
  271.51 +*  Matrices F and V are stored in row- and column-wise sparse format
  271.52 +*  as row and column linked lists of non-zero elements. Unity elements
  271.53 +*  on the main diagonal of matrix F are not stored. Pivot elements of
  271.54 +*  matrix V (which correspond to diagonal elements of matrix U) are
  271.55 +*  stored separately in an ordinary array.
  271.56 +*
  271.57 +*  Permutation matrices P and Q are stored in ordinary arrays in both
  271.58 +*  row- and column-like formats.
  271.59 +*
  271.60 +*  Matrices L and U are completely defined by matrices F, V, P, and Q
  271.61 +*  and therefore not stored explicitly.
  271.62 +*
  271.63 +*  The factorization (1)-(4) is a version of LU-factorization. Indeed,
  271.64 +*  from (3) and (4) it follows that:
  271.65 +*
  271.66 +*     F = inv(P) * L * P,
  271.67 +*
  271.68 +*     U = inv(P) * U * inv(Q),
  271.69 +*
  271.70 +*  and substitution into (2) leads to:
  271.71 +*
  271.72 +*     A = F * V = inv(P) * L * U * inv(Q).
  271.73 +*
  271.74 +*  For more details see the program documentation. */
  271.75 +
  271.76 +typedef struct LUF LUF;
  271.77 +
  271.78 +struct LUF
  271.79 +{     /* LU-factorization of a square matrix */
  271.80 +      int n_max;
  271.81 +      /* maximal value of n (increased automatically, if necessary) */
  271.82 +      int n;
  271.83 +      /* the order of matrices A, F, V, P, Q */
  271.84 +      int valid;
  271.85 +      /* the factorization is valid only if this flag is set */
  271.86 +      /*--------------------------------------------------------------*/
  271.87 +      /* matrix F in row-wise format */
  271.88 +      int *fr_ptr; /* int fr_ptr[1+n_max]; */
  271.89 +      /* fr_ptr[i], i = 1,...,n, is a pointer to the first element of
  271.90 +         i-th row in SVA */
  271.91 +      int *fr_len; /* int fr_len[1+n_max]; */
  271.92 +      /* fr_len[i], i = 1,...,n, is the number of elements in i-th row
  271.93 +         (except unity diagonal element) */
  271.94 +      /*--------------------------------------------------------------*/
  271.95 +      /* matrix F in column-wise format */
  271.96 +      int *fc_ptr; /* int fc_ptr[1+n_max]; */
  271.97 +      /* fc_ptr[j], j = 1,...,n, is a pointer to the first element of
  271.98 +         j-th column in SVA */
  271.99 +      int *fc_len; /* int fc_len[1+n_max]; */
 271.100 +      /* fc_len[j], j = 1,...,n, is the number of elements in j-th
 271.101 +         column (except unity diagonal element) */
 271.102 +      /*--------------------------------------------------------------*/
 271.103 +      /* matrix V in row-wise format */
 271.104 +      int *vr_ptr; /* int vr_ptr[1+n_max]; */
 271.105 +      /* vr_ptr[i], i = 1,...,n, is a pointer to the first element of
 271.106 +         i-th row in SVA */
 271.107 +      int *vr_len; /* int vr_len[1+n_max]; */
 271.108 +      /* vr_len[i], i = 1,...,n, is the number of elements in i-th row
 271.109 +         (except pivot element) */
 271.110 +      int *vr_cap; /* int vr_cap[1+n_max]; */
 271.111 +      /* vr_cap[i], i = 1,...,n, is the capacity of i-th row, i.e.
 271.112 +         maximal number of elements which can be stored in the row
 271.113 +         without relocating it, vr_cap[i] >= vr_len[i] */
 271.114 +      double *vr_piv; /* double vr_piv[1+n_max]; */
 271.115 +      /* vr_piv[p], p = 1,...,n, is the pivot element v[p,q] which
 271.116 +         corresponds to a diagonal element of matrix U = P*V*Q */
 271.117 +      /*--------------------------------------------------------------*/
 271.118 +      /* matrix V in column-wise format */
 271.119 +      int *vc_ptr; /* int vc_ptr[1+n_max]; */
 271.120 +      /* vc_ptr[j], j = 1,...,n, is a pointer to the first element of
 271.121 +         j-th column in SVA */
 271.122 +      int *vc_len; /* int vc_len[1+n_max]; */
 271.123 +      /* vc_len[j], j = 1,...,n, is the number of elements in j-th
 271.124 +         column (except pivot element) */
 271.125 +      int *vc_cap; /* int vc_cap[1+n_max]; */
 271.126 +      /* vc_cap[j], j = 1,...,n, is the capacity of j-th column, i.e.
 271.127 +         maximal number of elements which can be stored in the column
 271.128 +         without relocating it, vc_cap[j] >= vc_len[j] */
 271.129 +      /*--------------------------------------------------------------*/
 271.130 +      /* matrix P */
 271.131 +      int *pp_row; /* int pp_row[1+n_max]; */
 271.132 +      /* pp_row[i] = j means that P[i,j] = 1 */
 271.133 +      int *pp_col; /* int pp_col[1+n_max]; */
 271.134 +      /* pp_col[j] = i means that P[i,j] = 1 */
 271.135 +      /* if i-th row or column of matrix F is i'-th row or column of
 271.136 +         matrix L, or if i-th row of matrix V is i'-th row of matrix U,
 271.137 +         then pp_row[i'] = i and pp_col[i] = i' */
 271.138 +      /*--------------------------------------------------------------*/
 271.139 +      /* matrix Q */
 271.140 +      int *qq_row; /* int qq_row[1+n_max]; */
 271.141 +      /* qq_row[i] = j means that Q[i,j] = 1 */
 271.142 +      int *qq_col; /* int qq_col[1+n_max]; */
 271.143 +      /* qq_col[j] = i means that Q[i,j] = 1 */
 271.144 +      /* if j-th column of matrix V is j'-th column of matrix U, then
 271.145 +         qq_row[j] = j' and qq_col[j'] = j */
 271.146 +      /*--------------------------------------------------------------*/
 271.147 +      /* the Sparse Vector Area (SVA) is a set of locations used to
 271.148 +         store sparse vectors representing rows and columns of matrices
 271.149 +         F and V; each location is a doublet (ind, val), where ind is
 271.150 +         an index, and val is a numerical value of a sparse vector
 271.151 +         element; in the whole each sparse vector is a set of adjacent
 271.152 +         locations defined by a pointer to the first element and the
 271.153 +         number of elements; these pointer and number are stored in the
 271.154 +         corresponding matrix data structure (see above); the left part
 271.155 +         of SVA is used to store rows and columns of matrix V, and its
 271.156 +         right part is used to store rows and columns of matrix F; the
 271.157 +         middle part of SVA contains free (unused) locations */
 271.158 +      int sv_size;
 271.159 +      /* the size of SVA, in locations; all locations are numbered by
 271.160 +         integers 1, ..., n, and location 0 is not used; if necessary,
 271.161 +         the SVA size is automatically increased */
 271.162 +      int sv_beg, sv_end;
 271.163 +      /* SVA partitioning pointers:
 271.164 +         locations from 1 to sv_beg-1 belong to the left part
 271.165 +         locations from sv_beg to sv_end-1 belong to the middle part
 271.166 +         locations from sv_end to sv_size belong to the right part
 271.167 +         the size of the middle part is (sv_end - sv_beg) */
 271.168 +      int *sv_ind; /* sv_ind[1+sv_size]; */
 271.169 +      /* sv_ind[k], 1 <= k <= sv_size, is the index field of k-th
 271.170 +         location */
 271.171 +      double *sv_val; /* sv_val[1+sv_size]; */
 271.172 +      /* sv_val[k], 1 <= k <= sv_size, is the value field of k-th
 271.173 +         location */
 271.174 +      /*--------------------------------------------------------------*/
 271.175 +      /* in order to efficiently defragment the left part of SVA there
 271.176 +         is a doubly linked list of rows and columns of matrix V, where
 271.177 +         rows are numbered by 1, ..., n, while columns are numbered by
 271.178 +         n+1, ..., n+n, that allows uniquely identifying each row and
 271.179 +         column of V by only one integer; in this list rows and columns
 271.180 +         are ordered by ascending their pointers vr_ptr and vc_ptr */
 271.181 +      int sv_head;
 271.182 +      /* the number of leftmost row/column */
 271.183 +      int sv_tail;
 271.184 +      /* the number of rightmost row/column */
 271.185 +      int *sv_prev; /* int sv_prev[1+n_max+n_max]; */
 271.186 +      /* sv_prev[k], k = 1,...,n+n, is the number of a row/column which
 271.187 +         precedes k-th row/column */
 271.188 +      int *sv_next; /* int sv_next[1+n_max+n_max]; */
 271.189 +      /* sv_next[k], k = 1,...,n+n, is the number of a row/column which
 271.190 +         succedes k-th row/column */
 271.191 +      /*--------------------------------------------------------------*/
 271.192 +      /* working segment (used only during factorization) */
 271.193 +      double *vr_max; /* int vr_max[1+n_max]; */
 271.194 +      /* vr_max[i], 1 <= i <= n, is used only if i-th row of matrix V
 271.195 +         is active (i.e. belongs to the active submatrix), and is the
 271.196 +         largest magnitude of elements in i-th row; if vr_max[i] < 0,
 271.197 +         the largest magnitude is not known yet and should be computed
 271.198 +         by the pivoting routine */
 271.199 +      /*--------------------------------------------------------------*/
 271.200 +      /* in order to efficiently implement Markowitz strategy and Duff
 271.201 +         search technique there are two families {R[0], R[1], ..., R[n]}
 271.202 +         and {C[0], C[1], ..., C[n]}; member R[k] is the set of active
 271.203 +         rows of matrix V, which have k non-zeros, and member C[k] is
 271.204 +         the set of active columns of V, which have k non-zeros in the
 271.205 +         active submatrix (i.e. in the active rows); each set R[k] and
 271.206 +         C[k] is implemented as a separate doubly linked list */
 271.207 +      int *rs_head; /* int rs_head[1+n_max]; */
 271.208 +      /* rs_head[k], 0 <= k <= n, is the number of first active row,
 271.209 +         which has k non-zeros */
 271.210 +      int *rs_prev; /* int rs_prev[1+n_max]; */
 271.211 +      /* rs_prev[i], 1 <= i <= n, is the number of previous row, which
 271.212 +         has the same number of non-zeros as i-th row */
 271.213 +      int *rs_next; /* int rs_next[1+n_max]; */
 271.214 +      /* rs_next[i], 1 <= i <= n, is the number of next row, which has
 271.215 +         the same number of non-zeros as i-th row */
 271.216 +      int *cs_head; /* int cs_head[1+n_max]; */
 271.217 +      /* cs_head[k], 0 <= k <= n, is the number of first active column,
 271.218 +         which has k non-zeros (in the active rows) */
 271.219 +      int *cs_prev; /* int cs_prev[1+n_max]; */
 271.220 +      /* cs_prev[j], 1 <= j <= n, is the number of previous column,
 271.221 +         which has the same number of non-zeros (in the active rows) as
 271.222 +         j-th column */
 271.223 +      int *cs_next; /* int cs_next[1+n_max]; */
 271.224 +      /* cs_next[j], 1 <= j <= n, is the number of next column, which
 271.225 +         has the same number of non-zeros (in the active rows) as j-th
 271.226 +         column */
 271.227 +      /* (end of working segment) */
 271.228 +      /*--------------------------------------------------------------*/
 271.229 +      /* working arrays */
 271.230 +      int *flag; /* int flag[1+n_max]; */
 271.231 +      /* integer working array */
 271.232 +      double *work; /* double work[1+n_max]; */
 271.233 +      /* floating-point working array */
 271.234 +      /*--------------------------------------------------------------*/
 271.235 +      /* control parameters */
 271.236 +      int new_sva;
 271.237 +      /* new required size of the sparse vector area, in locations; set
 271.238 +         automatically by the factorizing routine */
 271.239 +      double piv_tol;
 271.240 +      /* threshold pivoting tolerance, 0 < piv_tol < 1; element v[i,j]
 271.241 +         of the active submatrix fits to be pivot if it satisfies to the
 271.242 +         stability criterion |v[i,j]| >= piv_tol * max |v[i,*]|, i.e. if
 271.243 +         it is not very small in the magnitude among other elements in
 271.244 +         the same row; decreasing this parameter gives better sparsity
 271.245 +         at the expense of numerical accuracy and vice versa */
 271.246 +      int piv_lim;
 271.247 +      /* maximal allowable number of pivot candidates to be considered;
 271.248 +         if piv_lim pivot candidates have been considered, the pivoting
 271.249 +         routine terminates the search with the best candidate found */
 271.250 +      int suhl;
 271.251 +      /* if this flag is set, the pivoting routine applies a heuristic
 271.252 +         proposed by Uwe Suhl: if a column of the active submatrix has
 271.253 +         no eligible pivot candidates (i.e. all its elements do not
 271.254 +         satisfy to the stability criterion), the routine excludes it
 271.255 +         from futher consideration until it becomes column singleton;
 271.256 +         in many cases this allows reducing the time needed for pivot
 271.257 +         searching */
 271.258 +      double eps_tol;
 271.259 +      /* epsilon tolerance; each element of the active submatrix, whose
 271.260 +         magnitude is less than eps_tol, is replaced by exact zero */
 271.261 +      double max_gro;
 271.262 +      /* maximal allowable growth of elements of matrix V during all
 271.263 +         the factorization process; if on some eliminaion step the ratio
 271.264 +         big_v / max_a (see below) becomes greater than max_gro, matrix
 271.265 +         A is considered as ill-conditioned (assuming that the pivoting
 271.266 +         tolerance piv_tol has an appropriate value) */
 271.267 +      /*--------------------------------------------------------------*/
 271.268 +      /* some statistics */
 271.269 +      int nnz_a;
 271.270 +      /* the number of non-zeros in matrix A */
 271.271 +      int nnz_f;
 271.272 +      /* the number of non-zeros in matrix F (except diagonal elements,
 271.273 +         which are not stored) */
 271.274 +      int nnz_v;
 271.275 +      /* the number of non-zeros in matrix V (except its pivot elements,
 271.276 +         which are stored in a separate array) */
 271.277 +      double max_a;
 271.278 +      /* the largest magnitude of elements of matrix A */
 271.279 +      double big_v;
 271.280 +      /* the largest magnitude of elements of matrix V appeared in the
 271.281 +         active submatrix during all the factorization process */
 271.282 +      int rank;
 271.283 +      /* estimated rank of matrix A */
 271.284 +};
 271.285 +
 271.286 +/* return codes: */
 271.287 +#define LUF_ESING    1  /* singular matrix */
 271.288 +#define LUF_ECOND    2  /* ill-conditioned matrix */
 271.289 +
 271.290 +#define luf_create_it _glp_luf_create_it
 271.291 +LUF *luf_create_it(void);
 271.292 +/* create LU-factorization */
 271.293 +
 271.294 +#define luf_defrag_sva _glp_luf_defrag_sva
 271.295 +void luf_defrag_sva(LUF *luf);
 271.296 +/* defragment the sparse vector area */
 271.297 +
 271.298 +#define luf_enlarge_row _glp_luf_enlarge_row
 271.299 +int luf_enlarge_row(LUF *luf, int i, int cap);
 271.300 +/* enlarge row capacity */
 271.301 +
 271.302 +#define luf_enlarge_col _glp_luf_enlarge_col
 271.303 +int luf_enlarge_col(LUF *luf, int j, int cap);
 271.304 +/* enlarge column capacity */
 271.305 +
 271.306 +#define luf_factorize _glp_luf_factorize
 271.307 +int luf_factorize(LUF *luf, int n, int (*col)(void *info, int j,
 271.308 +      int ind[], double val[]), void *info);
 271.309 +/* compute LU-factorization */
 271.310 +
 271.311 +#define luf_f_solve _glp_luf_f_solve
 271.312 +void luf_f_solve(LUF *luf, int tr, double x[]);
 271.313 +/* solve system F*x = b or F'*x = b */
 271.314 +
 271.315 +#define luf_v_solve _glp_luf_v_solve
 271.316 +void luf_v_solve(LUF *luf, int tr, double x[]);
 271.317 +/* solve system V*x = b or V'*x = b */
 271.318 +
 271.319 +#define luf_a_solve _glp_luf_a_solve
 271.320 +void luf_a_solve(LUF *luf, int tr, double x[]);
 271.321 +/* solve system A*x = b or A'*x = b */
 271.322 +
 271.323 +#define luf_delete_it _glp_luf_delete_it
 271.324 +void luf_delete_it(LUF *luf);
 271.325 +/* delete LU-factorization */
 271.326 +
 271.327 +#endif
 271.328 +
 271.329 +/* eof */
   272.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
   272.2 +++ b/deps/glpk/src/glplux.c	Sun Nov 06 20:59:10 2011 +0100
   272.3 @@ -0,0 +1,1028 @@
   272.4 +/* glplux.c */
   272.5 +
   272.6 +/***********************************************************************
   272.7 +*  This code is part of GLPK (GNU Linear Programming Kit).
   272.8 +*
   272.9 +*  Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008,
  272.10 +*  2009, 2010, 2011 Andrew Makhorin, Department for Applied Informatics,
  272.11 +*  Moscow Aviation Institute, Moscow, Russia. All rights reserved.
  272.12 +*  E-mail: <mao@gnu.org>.
  272.13 +*
  272.14 +*  GLPK is free software: you can redistribute it and/or modify it
  272.15 +*  under the terms of the GNU General Public License as published by
  272.16 +*  the Free Software Foundation, either version 3 of the License, or
  272.17 +*  (at your option) any later version.
  272.18 +*
  272.19 +*  GLPK is distributed in the hope that it will be useful, but WITHOUT
  272.20 +*  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
  272.21 +*  or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
  272.22 +*  License for more details.
  272.23 +*
  272.24 +*  You should have received a copy of the GNU General Public License
  272.25 +*  along with GLPK. If not, see <http://www.gnu.org/licenses/>.
  272.26 +***********************************************************************/
  272.27 +
  272.28 +#include "glplux.h"
  272.29 +#define xfault xerror
  272.30 +#define dmp_create_poolx(size) dmp_create_pool()
  272.31 +
  272.32 +/*----------------------------------------------------------------------
  272.33 +// lux_create - create LU-factorization.
  272.34 +//
  272.35 +// SYNOPSIS
  272.36 +//
  272.37 +// #include "glplux.h"
  272.38 +// LUX *lux_create(int n);
  272.39 +//
  272.40 +// DESCRIPTION
  272.41 +//
  272.42 +// The routine lux_create creates LU-factorization data structure for
  272.43 +// a matrix of the order n. Initially the factorization corresponds to
  272.44 +// the unity matrix (F = V = P = Q = I, so A = I).
  272.45 +//
  272.46 +// RETURNS
  272.47 +//
  272.48 +// The routine returns a pointer to the created LU-factorization data
  272.49 +// structure, which represents the unity matrix of the order n. */
  272.50 +
  272.51 +LUX *lux_create(int n)
  272.52 +{     LUX *lux;
  272.53 +      int k;
  272.54 +      if (n < 1)
  272.55 +         xfault("lux_create: n = %d; invalid parameter\n", n);
  272.56 +      lux = xmalloc(sizeof(LUX));
  272.57 +      lux->n = n;
  272.58 +      lux->pool = dmp_create_poolx(sizeof(LUXELM));
  272.59 +      lux->F_row = xcalloc(1+n, sizeof(LUXELM *));
  272.60 +      lux->F_col = xcalloc(1+n, sizeof(LUXELM *));
  272.61 +      lux->V_piv = xcalloc(1+n, sizeof(mpq_t));
  272.62 +      lux->V_row = xcalloc(1+n, sizeof(LUXELM *));
  272.63 +      lux->V_col = xcalloc(1+n, sizeof(LUXELM *));
  272.64 +      lux->P_row = xcalloc(1+n, sizeof(int));
  272.65 +      lux->P_col = xcalloc(1+n, sizeof(int));
  272.66 +      lux->Q_row = xcalloc(1+n, sizeof(int));
  272.67 +      lux->Q_col = xcalloc(1+n, sizeof(int));
  272.68 +      for (k = 1; k <= n; k++)
  272.69 +      {  lux->F_row[k] = lux->F_col[k] = NULL;
  272.70 +         mpq_init(lux->V_piv[k]);
  272.71 +         mpq_set_si(lux->V_piv[k], 1, 1);
  272.72 +         lux->V_row[k] = lux->V_col[k] = NULL;
  272.73 +         lux->P_row[k] = lux->P_col[k] = k;
  272.74 +         lux->Q_row[k] = lux->Q_col[k] = k;
  272.75 +      }
  272.76 +      lux->rank = n;
  272.77 +      return lux;
  272.78 +}
  272.79 +
  272.80 +/*----------------------------------------------------------------------
  272.81 +// initialize - initialize LU-factorization data structures.
  272.82 +//
  272.83 +// This routine initializes data structures for subsequent computing
  272.84 +// the LU-factorization of a given matrix A, which is specified by the
  272.85 +// formal routine col. On exit V = A and F = P = Q = I, where I is the
  272.86 +// unity matrix. */
  272.87 +
  272.88 +static void initialize(LUX *lux, int (*col)(void *info, int j,
  272.89 +      int ind[], mpq_t val[]), void *info, LUXWKA *wka)
  272.90 +{     int n = lux->n;
  272.91 +      DMP *pool = lux->pool;
  272.92 +      LUXELM **F_row = lux->F_row;
  272.93 +      LUXELM **F_col = lux->F_col;
  272.94 +      mpq_t *V_piv = lux->V_piv;
  272.95 +      LUXELM **V_row = lux->V_row;
  272.96 +      LUXELM **V_col = lux->V_col;
  272.97 +      int *P_row = lux->P_row;
  272.98 +      int *P_col = lux->P_col;
  272.99 +      int *Q_row = lux->Q_row;
 272.100 +      int *Q_col = lux->Q_col;
 272.101 +      int *R_len = wka->R_len;
 272.102 +      int *R_head = wka->R_head;
 272.103 +      int *R_prev = wka->R_prev;
 272.104 +      int *R_next = wka->R_next;
 272.105 +      int *C_len = wka->C_len;
 272.106 +      int *C_head = wka->C_head;
 272.107 +      int *C_prev = wka->C_prev;
 272.108 +      int *C_next = wka->C_next;
 272.109 +      LUXELM *fij, *vij;
 272.110 +      int i, j, k, len, *ind;
 272.111 +      mpq_t *val;
 272.112 +      /* F := I */
 272.113 +      for (i = 1; i <= n; i++)
 272.114 +      {  while (F_row[i] != NULL)
 272.115 +         {  fij = F_row[i], F_row[i] = fij->r_next;
 272.116 +            mpq_clear(fij->val);
 272.117 +            dmp_free_atom(pool, fij, sizeof(LUXELM));
 272.118 +         }
 272.119 +      }
 272.120 +      for (j = 1; j <= n; j++) F_col[j] = NULL;
 272.121 +      /* V := 0 */
 272.122 +      for (k = 1; k <= n; k++) mpq_set_si(V_piv[k], 0, 1);
 272.123 +      for (i = 1; i <= n; i++)
 272.124 +      {  while (V_row[i] != NULL)
 272.125 +         {  vij = V_row[i], V_row[i] = vij->r_next;
 272.126 +            mpq_clear(vij->val);
 272.127 +            dmp_free_atom(pool, vij, sizeof(LUXELM));
 272.128 +         }
 272.129 +      }
 272.130 +      for (j = 1; j <= n; j++) V_col[j] = NULL;
 272.131 +      /* V := A */
 272.132 +      ind = xcalloc(1+n, sizeof(int));
 272.133 +      val = xcalloc(1+n, sizeof(mpq_t));
 272.134 +      for (k = 1; k <= n; k++) mpq_init(val[k]);
 272.135 +      for (j = 1; j <= n; j++)
 272.136 +      {  /* obtain j-th column of matrix A */
 272.137 +         len = col(info, j, ind, val);
 272.138 +         if (!(0 <= len && len <= n))
 272.139 +            xfault("lux_decomp: j = %d: len = %d; invalid column length"
 272.140 +               "\n", j, len);
 272.141 +         /* copy elements of j-th column to matrix V */
 272.142 +         for (k = 1; k <= len; k++)
 272.143 +         {  /* get row index of a[i,j] */
 272.144 +            i = ind[k];
 272.145 +            if (!(1 <= i && i <= n))
 272.146 +               xfault("lux_decomp: j = %d: i = %d; row index out of ran"
 272.147 +                  "ge\n", j, i);
 272.148 +            /* check for duplicate indices */
 272.149 +            if (V_row[i] != NULL && V_row[i]->j == j)
 272.150 +               xfault("lux_decomp: j = %d: i = %d; duplicate row indice"
 272.151 +                  "s not allowed\n", j, i);
 272.152 +            /* check for zero value */
 272.153 +            if (mpq_sgn(val[k]) == 0)
 272.154 +               xfault("lux_decomp: j = %d: i = %d; zero elements not al"
 272.155 +                  "lowed\n", j, i);
 272.156 +            /* add new element v[i,j] = a[i,j] to V */
 272.157 +            vij = dmp_get_atom(pool, sizeof(LUXELM));
 272.158 +            vij->i = i, vij->j = j;
 272.159 +            mpq_init(vij->val);
 272.160 +            mpq_set(vij->val, val[k]);
 272.161 +            vij->r_prev = NULL;
 272.162 +            vij->r_next = V_row[i];
 272.163 +            vij->c_prev = NULL;
 272.164 +            vij->c_next = V_col[j];
 272.165 +            if (vij->r_next != NULL) vij->r_next->r_prev = vij;
 272.166 +            if (vij->c_next != NULL) vij->c_next->c_prev = vij;
 272.167 +            V_row[i] = V_col[j] = vij;
 272.168 +         }
 272.169 +      }
 272.170 +      xfree(ind);
 272.171 +      for (k = 1; k <= n; k++) mpq_clear(val[k]);
 272.172 +      xfree(val);
 272.173 +      /* P := Q := I */
 272.174 +      for (k = 1; k <= n; k++)
 272.175 +         P_row[k] = P_col[k] = Q_row[k] = Q_col[k] = k;
 272.176 +      /* the rank of A and V is not determined yet */
 272.177 +      lux->rank = -1;
 272.178 +      /* initially the entire matrix V is active */
 272.179 +      /* determine its row lengths */
 272.180 +      for (i = 1; i <= n; i++)
 272.181 +      {  len = 0;
 272.182 +         for (vij = V_row[i]; vij != NULL; vij = vij->r_next) len++;
 272.183 +         R_len[i] = len;
 272.184 +      }
 272.185 +      /* build linked lists of active rows */
 272.186 +      for (len = 0; len <= n; len++) R_head[len] = 0;
 272.187 +      for (i = 1; i <= n; i++)
 272.188 +      {  len = R_len[i];
 272.189 +         R_prev[i] = 0;
 272.190 +         R_next[i] = R_head[len];
 272.191 +         if (R_next[i] != 0) R_prev[R_next[i]] = i;
 272.192 +         R_head[len] = i;
 272.193 +      }
 272.194 +      /* determine its column lengths */
 272.195 +      for (j = 1; j <= n; j++)
 272.196 +      {  len = 0;
 272.197 +         for (vij = V_col[j]; vij != NULL; vij = vij->c_next) len++;
 272.198 +         C_len[j] = len;
 272.199 +      }
 272.200 +      /* build linked lists of active columns */
 272.201 +      for (len = 0; len <= n; len++) C_head[len] = 0;
 272.202 +      for (j = 1; j <= n; j++)
 272.203 +      {  len = C_len[j];
 272.204 +         C_prev[j] = 0;
 272.205 +         C_next[j] = C_head[len];
 272.206 +         if (C_next[j] != 0) C_prev[C_next[j]] = j;
 272.207 +         C_head[len] = j;
 272.208 +      }
 272.209 +      return;
 272.210 +}
 272.211 +
 272.212 +/*----------------------------------------------------------------------
 272.213 +// find_pivot - choose a pivot element.
 272.214 +//
 272.215 +// This routine chooses a pivot element v[p,q] in the active submatrix
 272.216 +// of matrix U = P*V*Q.
 272.217 +//
 272.218 +// It is assumed that on entry the matrix U has the following partially
 272.219 +// triangularized form:
 272.220 +//
 272.221 +//       1       k         n
 272.222 +//    1  x x x x x x x x x x
 272.223 +//       . x x x x x x x x x
 272.224 +//       . . x x x x x x x x
 272.225 +//       . . . x x x x x x x
 272.226 +//    k  . . . . * * * * * *
 272.227 +//       . . . . * * * * * *
 272.228 +//       . . . . * * * * * *
 272.229 +//       . . . . * * * * * *
 272.230 +//       . . . . * * * * * *
 272.231 +//    n  . . . . * * * * * *
 272.232 +//
 272.233 +// where rows and columns k, k+1, ..., n belong to the active submatrix
 272.234 +// (elements of the active submatrix are marked by '*').
 272.235 +//
 272.236 +// Since the matrix U = P*V*Q is not stored, the routine works with the
 272.237 +// matrix V. It is assumed that the row-wise representation corresponds
 272.238 +// to the matrix V, but the column-wise representation corresponds to
 272.239 +// the active submatrix of the matrix V, i.e. elements of the matrix V,
 272.240 +// which does not belong to the active submatrix, are missing from the
 272.241 +// column linked lists. It is also assumed that each active row of the
 272.242 +// matrix V is in the set R[len], where len is number of non-zeros in
 272.243 +// the row, and each active column of the matrix V is in the set C[len],
 272.244 +// where len is number of non-zeros in the column (in the latter case
 272.245 +// only elements of the active submatrix are counted; such elements are
 272.246 +// marked by '*' on the figure above).
 272.247 +//
 272.248 +// Due to exact arithmetic any non-zero element of the active submatrix
 272.249 +// can be chosen as a pivot. However, to keep sparsity of the matrix V
 272.250 +// the routine uses Markowitz strategy, trying to choose such element
 272.251 +// v[p,q], which has smallest Markowitz cost (nr[p]-1) * (nc[q]-1),
 272.252 +// where nr[p] and nc[q] are the number of non-zero elements, resp., in
 272.253 +// p-th row and in q-th column of the active submatrix.
 272.254 +//
 272.255 +// In order to reduce the search, i.e. not to walk through all elements
 272.256 +// of the active submatrix, the routine exploits a technique proposed by
 272.257 +// I.Duff. This technique is based on using the sets R[len] and C[len]
 272.258 +// of active rows and columns.
 272.259 +//
 272.260 +// On exit the routine returns a pointer to a pivot v[p,q] chosen, or
 272.261 +// NULL, if the active submatrix is empty. */
 272.262 +
 272.263 +static LUXELM *find_pivot(LUX *lux, LUXWKA *wka)
 272.264 +{     int n = lux->n;
 272.265 +      LUXELM **V_row = lux->V_row;
 272.266 +      LUXELM **V_col = lux->V_col;
 272.267 +      int *R_len = wka->R_len;
 272.268 +      int *R_head = wka->R_head;
 272.269 +      int *R_next = wka->R_next;
 272.270 +      int *C_len = wka->C_len;
 272.271 +      int *C_head = wka->C_head;
 272.272 +      int *C_next = wka->C_next;
 272.273 +      LUXELM *piv, *some, *vij;
 272.274 +      int i, j, len, min_len, ncand, piv_lim = 5;
 272.275 +      double best, cost;
 272.276 +      /* nothing is chosen so far */
 272.277 +      piv = NULL, best = DBL_MAX, ncand = 0;
 272.278 +      /* if in the active submatrix there is a column that has the only
 272.279 +         non-zero (column singleton), choose it as a pivot */
 272.280 +      j = C_head[1];
 272.281 +      if (j != 0)
 272.282 +      {  xassert(C_len[j] == 1);
 272.283 +         piv = V_col[j];
 272.284 +         xassert(piv != NULL && piv->c_next == NULL);
 272.285 +         goto done;
 272.286 +      }
 272.287 +      /* if in the active submatrix there is a row that has the only
 272.288 +         non-zero (row singleton), choose it as a pivot */
 272.289 +      i = R_head[1];
 272.290 +      if (i != 0)
 272.291 +      {  xassert(R_len[i] == 1);
 272.292 +         piv = V_row[i];
 272.293 +         xassert(piv != NULL && piv->r_next == NULL);
 272.294 +         goto done;
 272.295 +      }
 272.296 +      /* there are no singletons in the active submatrix; walk through
 272.297 +         other non-empty rows and columns */
 272.298 +      for (len = 2; len <= n; len++)
 272.299 +      {  /* consider active columns having len non-zeros */
 272.300 +         for (j = C_head[len]; j != 0; j = C_next[j])
 272.301 +         {  /* j-th column has len non-zeros */
 272.302 +            /* find an element in the row of minimal length */
 272.303 +            some = NULL, min_len = INT_MAX;
 272.304 +            for (vij = V_col[j]; vij != NULL; vij = vij->c_next)
 272.305 +            {  if (min_len > R_len[vij->i])
 272.306 +                  some = vij, min_len = R_len[vij->i];
 272.307 +               /* if Markowitz cost of this element is not greater than
 272.308 +                  (len-1)**2, it can be chosen right now; this heuristic
 272.309 +                  reduces the search and works well in many cases */
 272.310 +               if (min_len <= len)
 272.311 +               {  piv = some;
 272.312 +                  goto done;
 272.313 +               }
 272.314 +            }
 272.315 +            /* j-th column has been scanned */
 272.316 +            /* the minimal element found is a next pivot candidate */
 272.317 +            xassert(some != NULL);
 272.318 +            ncand++;
 272.319 +            /* compute its Markowitz cost */
 272.320 +            cost = (double)(min_len - 1) * (double)(len - 1);
 272.321 +            /* choose between the current candidate and this element */
 272.322 +            if (cost < best) piv = some, best = cost;
 272.323 +            /* if piv_lim candidates have been considered, there is a
 272.324 +               doubt that a much better candidate exists; therefore it
 272.325 +               is the time to terminate the search */
 272.326 +            if (ncand == piv_lim) goto done;
 272.327 +         }
 272.328 +         /* now consider active rows having len non-zeros */
 272.329 +         for (i = R_head[len]; i != 0; i = R_next[i])
 272.330 +         {  /* i-th row has len non-zeros */
 272.331 +            /* find an element in the column of minimal length */
 272.332 +            some = NULL, min_len = INT_MAX;
 272.333 +            for (vij = V_row[i]; vij != NULL; vij = vij->r_next)
 272.334 +            {  if (min_len > C_len[vij->j])
 272.335 +                  some = vij, min_len = C_len[vij->j];
 272.336 +               /* if Markowitz cost of this element is not greater than
 272.337 +                  (len-1)**2, it can be chosen right now; this heuristic
 272.338 +                  reduces the search and works well in many cases */
 272.339 +               if (min_len <= len)
 272.340 +               {  piv = some;
 272.341 +                  goto done;
 272.342 +               }
 272.343 +            }
 272.344 +            /* i-th row has been scanned */
 272.345 +            /* the minimal element found is a next pivot candidate */
 272.346 +            xassert(some != NULL);
 272.347 +            ncand++;
 272.348 +            /* compute its Markowitz cost */
 272.349 +            cost = (double)(len - 1) * (double)(min_len - 1);
 272.350 +            /* choose between the current candidate and this element */
 272.351 +            if (cost < best) piv = some, best = cost;
 272.352 +            /* if piv_lim candidates have been considered, there is a
 272.353 +               doubt that a much better candidate exists; therefore it
 272.354 +               is the time to terminate the search */
 272.355 +            if (ncand == piv_lim) goto done;
 272.356 +         }
 272.357 +      }
 272.358 +done: /* bring the pivot v[p,q] to the factorizing routine */
 272.359 +      return piv;
 272.360 +}
 272.361 +
 272.362 +/*----------------------------------------------------------------------
 272.363 +// eliminate - perform gaussian elimination.
 272.364 +//
 272.365 +// This routine performs elementary gaussian transformations in order
 272.366 +// to eliminate subdiagonal elements in the k-th column of the matrix
 272.367 +// U = P*V*Q using the pivot element u[k,k], where k is the number of
 272.368 +// the current elimination step.
 272.369 +//
 272.370 +// The parameter piv specifies the pivot element v[p,q] = u[k,k].
 272.371 +//
 272.372 +// Each time when the routine applies the elementary transformation to
 272.373 +// a non-pivot row of the matrix V, it stores the corresponding element
 272.374 +// to the matrix F in order to keep the main equality A = F*V.
 272.375 +//
 272.376 +// The routine assumes that on entry the matrices L = P*F*inv(P) and
 272.377 +// U = P*V*Q are the following:
 272.378 +//
 272.379 +//       1       k                  1       k         n
 272.380 +//    1  1 . . . . . . . . .     1  x x x x x x x x x x
 272.381 +//       x 1 . . . . . . . .        . x x x x x x x x x
 272.382 +//       x x 1 . . . . . . .        . . x x x x x x x x
 272.383 +//       x x x 1 . . . . . .        . . . x x x x x x x
 272.384 +//    k  x x x x 1 . . . . .     k  . . . . * * * * * *
 272.385 +//       x x x x _ 1 . . . .        . . . . # * * * * *
 272.386 +//       x x x x _ . 1 . . .        . . . . # * * * * *
 272.387 +//       x x x x _ . . 1 . .        . . . . # * * * * *
 272.388 +//       x x x x _ . . . 1 .        . . . . # * * * * *
 272.389 +//    n  x x x x _ . . . . 1     n  . . . . # * * * * *
 272.390 +//
 272.391 +//            matrix L                   matrix U
 272.392 +//
 272.393 +// where rows and columns of the matrix U with numbers k, k+1, ..., n
 272.394 +// form the active submatrix (eliminated elements are marked by '#' and
 272.395 +// other elements of the active submatrix are marked by '*'). Note that
 272.396 +// each eliminated non-zero element u[i,k] of the matrix U gives the
 272.397 +// corresponding element l[i,k] of the matrix L (marked by '_').
 272.398 +//
 272.399 +// Actually all operations are performed on the matrix V. Should note
 272.400 +// that the row-wise representation corresponds to the matrix V, but the
 272.401 +// column-wise representation corresponds to the active submatrix of the
 272.402 +// matrix V, i.e. elements of the matrix V, which doesn't belong to the
 272.403 +// active submatrix, are missing from the column linked lists.
 272.404 +//
 272.405 +// Let u[k,k] = v[p,q] be the pivot. In order to eliminate subdiagonal
 272.406 +// elements u[i',k] = v[i,q], i' = k+1, k+2, ..., n, the routine applies
 272.407 +// the following elementary gaussian transformations:
 272.408 +//
 272.409 +//    (i-th row of V) := (i-th row of V) - f[i,p] * (p-th row of V),
 272.410 +//
 272.411 +// where f[i,p] = v[i,q] / v[p,q] is a gaussian multiplier.
 272.412 +//
 272.413 +// Additionally, in order to keep the main equality A = F*V, each time
 272.414 +// when the routine applies the transformation to i-th row of the matrix
 272.415 +// V, it also adds f[i,p] as a new element to the matrix F.
 272.416 +//
 272.417 +// IMPORTANT: On entry the working arrays flag and work should contain
 272.418 +// zeros. This status is provided by the routine on exit. */
 272.419 +
 272.420 +static void eliminate(LUX *lux, LUXWKA *wka, LUXELM *piv, int flag[],
 272.421 +      mpq_t work[])
 272.422 +{     DMP *pool = lux->pool;
 272.423 +      LUXELM **F_row = lux->F_row;
 272.424 +      LUXELM **F_col = lux->F_col;
 272.425 +      mpq_t *V_piv = lux->V_piv;
 272.426 +      LUXELM **V_row = lux->V_row;
 272.427 +      LUXELM **V_col = lux->V_col;
 272.428 +      int *R_len = wka->R_len;
 272.429 +      int *R_head = wka->R_head;
 272.430 +      int *R_prev = wka->R_prev;
 272.431 +      int *R_next = wka->R_next;
 272.432 +      int *C_len = wka->C_len;
 272.433 +      int *C_head = wka->C_head;
 272.434 +      int *C_prev = wka->C_prev;
 272.435 +      int *C_next = wka->C_next;
 272.436 +      LUXELM *fip, *vij, *vpj, *viq, *next;
 272.437 +      mpq_t temp;
 272.438 +      int i, j, p, q;
 272.439 +      mpq_init(temp);
 272.440 +      /* determine row and column indices of the pivot v[p,q] */
 272.441 +      xassert(piv != NULL);
 272.442 +      p = piv->i, q = piv->j;
 272.443 +      /* remove p-th (pivot) row from the active set; it will never
 272.444 +         return there */
 272.445 +      if (R_prev[p] == 0)
 272.446 +         R_head[R_len[p]] = R_next[p];
 272.447 +      else
 272.448 +         R_next[R_prev[p]] = R_next[p];
 272.449 +      if (R_next[p] == 0)
 272.450 +         ;
 272.451 +      else
 272.452 +         R_prev[R_next[p]] = R_prev[p];
 272.453 +      /* remove q-th (pivot) column from the active set; it will never
 272.454 +         return there */
 272.455 +      if (C_prev[q] == 0)
 272.456 +         C_head[C_len[q]] = C_next[q];
 272.457 +      else
 272.458 +         C_next[C_prev[q]] = C_next[q];
 272.459 +      if (C_next[q] == 0)
 272.460 +         ;
 272.461 +      else
 272.462 +         C_prev[C_next[q]] = C_prev[q];
 272.463 +      /* store the pivot value in a separate array */
 272.464 +      mpq_set(V_piv[p], piv->val);
 272.465 +      /* remove the pivot from p-th row */
 272.466 +      if (piv->r_prev == NULL)
 272.467 +         V_row[p] = piv->r_next;
 272.468 +      else
 272.469 +         piv->r_prev->r_next = piv->r_next;
 272.470 +      if (piv->r_next == NULL)
 272.471 +         ;
 272.472 +      else
 272.473 +         piv->r_next->r_prev = piv->r_prev;
 272.474 +      R_len[p]--;
 272.475 +      /* remove the pivot from q-th column */
 272.476 +      if (piv->c_prev == NULL)
 272.477 +         V_col[q] = piv->c_next;
 272.478 +      else
 272.479 +         piv->c_prev->c_next = piv->c_next;
 272.480 +      if (piv->c_next == NULL)
 272.481 +         ;
 272.482 +      else
 272.483 +         piv->c_next->c_prev = piv->c_prev;
 272.484 +      C_len[q]--;
 272.485 +      /* free the space occupied by the pivot */
 272.486 +      mpq_clear(piv->val);
 272.487 +      dmp_free_atom(pool, piv, sizeof(LUXELM));
 272.488 +      /* walk through p-th (pivot) row, which already does not contain
 272.489 +         the pivot v[p,q], and do the following... */
 272.490 +      for (vpj = V_row[p]; vpj != NULL; vpj = vpj->r_next)
 272.491 +      {  /* get column index of v[p,j] */
 272.492 +         j = vpj->j;
 272.493 +         /* store v[p,j] in the working array */
 272.494 +         flag[j] = 1;
 272.495 +         mpq_set(work[j], vpj->val);
 272.496 +         /* remove j-th column from the active set; it will return there
 272.497 +            later with a new length */
 272.498 +         if (C_prev[j] == 0)
 272.499 +            C_head[C_len[j]] = C_next[j];
 272.500 +         else
 272.501 +            C_next[C_prev[j]] = C_next[j];
 272.502 +         if (C_next[j] == 0)
 272.503 +            ;
 272.504 +         else
 272.505 +            C_prev[C_next[j]] = C_prev[j];
 272.506 +         /* v[p,j] leaves the active submatrix, so remove it from j-th
 272.507 +            column; however, v[p,j] is kept in p-th row */
 272.508 +         if (vpj->c_prev == NULL)
 272.509 +            V_col[j] = vpj->c_next;
 272.510 +         else
 272.511 +            vpj->c_prev->c_next = vpj->c_next;
 272.512 +         if (vpj->c_next == NULL)
 272.513 +            ;
 272.514 +         else
 272.515 +            vpj->c_next->c_prev = vpj->c_prev;
 272.516 +         C_len[j]--;
 272.517 +      }
 272.518 +      /* now walk through q-th (pivot) column, which already does not
 272.519 +         contain the pivot v[p,q], and perform gaussian elimination */
 272.520 +      while (V_col[q] != NULL)
 272.521 +      {  /* element v[i,q] has to be eliminated */
 272.522 +         viq = V_col[q];
 272.523 +         /* get row index of v[i,q] */
 272.524 +         i = viq->i;
 272.525 +         /* remove i-th row from the active set; later it will return
 272.526 +            there with a new length */
 272.527 +         if (R_prev[i] == 0)
 272.528 +            R_head[R_len[i]] = R_next[i];
 272.529 +         else
 272.530 +            R_next[R_prev[i]] = R_next[i];
 272.531 +         if (R_next[i] == 0)
 272.532 +            ;
 272.533 +         else
 272.534 +            R_prev[R_next[i]] = R_prev[i];
 272.535 +         /* compute gaussian multiplier f[i,p] = v[i,q] / v[p,q] and
 272.536 +            store it in the matrix F */
 272.537 +         fip = dmp_get_atom(pool, sizeof(LUXELM));
 272.538 +         fip->i = i, fip->j = p;
 272.539 +         mpq_init(fip->val);
 272.540 +         mpq_div(fip->val, viq->val, V_piv[p]);
 272.541 +         fip->r_prev = NULL;
 272.542 +         fip->r_next = F_row[i];
 272.543 +         fip->c_prev = NULL;
 272.544 +         fip->c_next = F_col[p];
 272.545 +         if (fip->r_next != NULL) fip->r_next->r_prev = fip;
 272.546 +         if (fip->c_next != NULL) fip->c_next->c_prev = fip;
 272.547 +         F_row[i] = F_col[p] = fip;
 272.548 +         /* v[i,q] has to be eliminated, so remove it from i-th row */
 272.549 +         if (viq->r_prev == NULL)
 272.550 +            V_row[i] = viq->r_next;
 272.551 +         else
 272.552 +            viq->r_prev->r_next = viq->r_next;
 272.553 +         if (viq->r_next == NULL)
 272.554 +            ;
 272.555 +         else
 272.556 +            viq->r_next->r_prev = viq->r_prev;
 272.557 +         R_len[i]--;
 272.558 +         /* and also from q-th column */
 272.559 +         V_col[q] = viq->c_next;
 272.560 +         C_len[q]--;
 272.561 +         /* free the space occupied by v[i,q] */
 272.562 +         mpq_clear(viq->val);
 272.563 +         dmp_free_atom(pool, viq, sizeof(LUXELM));
 272.564 +         /* perform gaussian transformation:
 272.565 +            (i-th row) := (i-th row) - f[i,p] * (p-th row)
 272.566 +            note that now p-th row, which is in the working array,
 272.567 +            does not contain the pivot v[p,q], and i-th row does not
 272.568 +            contain the element v[i,q] to be eliminated */
 272.569 +         /* walk through i-th row and transform existing non-zero
 272.570 +            elements */
 272.571 +         for (vij = V_row[i]; vij != NULL; vij = next)
 272.572 +         {  next = vij->r_next;
 272.573 +            /* get column index of v[i,j] */
 272.574 +            j = vij->j;
 272.575 +            /* v[i,j] := v[i,j] - f[i,p] * v[p,j] */
 272.576 +            if (flag[j])
 272.577 +            {  /* v[p,j] != 0 */
 272.578 +               flag[j] = 0;
 272.579 +               mpq_mul(temp, fip->val, work[j]);
 272.580 +               mpq_sub(vij->val, vij->val, temp);
 272.581 +               if (mpq_sgn(vij->val) == 0)
 272.582 +               {  /* new v[i,j] is zero, so remove it from the active
 272.583 +                     submatrix */
 272.584 +                  /* remove v[i,j] from i-th row */
 272.585 +                  if (vij->r_prev == NULL)
 272.586 +                     V_row[i] = vij->r_next;
 272.587 +                  else
 272.588 +                     vij->r_prev->r_next = vij->r_next;
 272.589 +                  if (vij->r_next == NULL)
 272.590 +                     ;
 272.591 +                  else
 272.592 +                     vij->r_next->r_prev = vij->r_prev;
 272.593 +                  R_len[i]--;
 272.594 +                  /* remove v[i,j] from j-th column */
 272.595 +                  if (vij->c_prev == NULL)
 272.596 +                     V_col[j] = vij->c_next;
 272.597 +                  else
 272.598 +                     vij->c_prev->c_next = vij->c_next;
 272.599 +                  if (vij->c_next == NULL)
 272.600 +                     ;
 272.601 +                  else
 272.602 +                     vij->c_next->c_prev = vij->c_prev;
 272.603 +                  C_len[j]--;
 272.604 +                  /* free the space occupied by v[i,j] */
 272.605 +                  mpq_clear(vij->val);
 272.606 +                  dmp_free_atom(pool, vij, sizeof(LUXELM));
 272.607 +               }
 272.608 +            }
 272.609 +         }
 272.610 +         /* now flag is the pattern of the set v[p,*] \ v[i,*] */
 272.611 +         /* walk through p-th (pivot) row and create new elements in
 272.612 +            i-th row, which appear due to fill-in */
 272.613 +         for (vpj = V_row[p]; vpj != NULL; vpj = vpj->r_next)
 272.614 +         {  j = vpj->j;
 272.615 +            if (flag[j])
 272.616 +            {  /* create new non-zero v[i,j] = 0 - f[i,p] * v[p,j] and
 272.617 +                  add it to i-th row and j-th column */
 272.618 +               vij = dmp_get_atom(pool, sizeof(LUXELM));
 272.619 +               vij->i = i, vij->j = j;
 272.620 +               mpq_init(vij->val);
 272.621 +               mpq_mul(vij->val, fip->val, work[j]);
 272.622 +               mpq_neg(vij->val, vij->val);
 272.623 +               vij->r_prev = NULL;
 272.624 +               vij->r_next = V_row[i];
 272.625 +               vij->c_prev = NULL;
 272.626 +               vij->c_next = V_col[j];
 272.627 +               if (vij->r_next != NULL) vij->r_next->r_prev = vij;
 272.628 +               if (vij->c_next != NULL) vij->c_next->c_prev = vij;
 272.629 +               V_row[i] = V_col[j] = vij;
 272.630 +               R_len[i]++, C_len[j]++;
 272.631 +            }
 272.632 +            else
 272.633 +            {  /* there is no fill-in, because v[i,j] already exists in
 272.634 +                  i-th row; restore the flag, which was reset before */
 272.635 +               flag[j] = 1;
 272.636 +            }
 272.637 +         }
 272.638 +         /* now i-th row has been completely transformed and can return
 272.639 +            to the active set with a new length */
 272.640 +         R_prev[i] = 0;
 272.641 +         R_next[i] = R_head[R_len[i]];
 272.642 +         if (R_next[i] != 0) R_prev[R_next[i]] = i;
 272.643 +         R_head[R_len[i]] = i;
 272.644 +      }
 272.645 +      /* at this point q-th (pivot) column must be empty */
 272.646 +      xassert(C_len[q] == 0);
 272.647 +      /* walk through p-th (pivot) row again and do the following... */
 272.648 +      for (vpj = V_row[p]; vpj != NULL; vpj = vpj->r_next)
 272.649 +      {  /* get column index of v[p,j] */
 272.650 +         j = vpj->j;
 272.651 +         /* erase v[p,j] from the working array */
 272.652 +         flag[j] = 0;
 272.653 +         mpq_set_si(work[j], 0, 1);
 272.654 +         /* now j-th column has been completely transformed, so it can
 272.655 +            return to the active list with a new length */
 272.656 +         C_prev[j] = 0;
 272.657 +         C_next[j] = C_head[C_len[j]];
 272.658 +         if (C_next[j] != 0) C_prev[C_next[j]] = j;
 272.659 +         C_head[C_len[j]] = j;
 272.660 +      }
 272.661 +      mpq_clear(temp);
 272.662 +      /* return to the factorizing routine */
 272.663 +      return;
 272.664 +}
 272.665 +
 272.666 +/*----------------------------------------------------------------------
 272.667 +// lux_decomp - compute LU-factorization.
 272.668 +//
 272.669 +// SYNOPSIS
 272.670 +//
 272.671 +// #include "glplux.h"
 272.672 +// int lux_decomp(LUX *lux, int (*col)(void *info, int j, int ind[],
 272.673 +//    mpq_t val[]), void *info);
 272.674 +//
 272.675 +// DESCRIPTION
 272.676 +//
 272.677 +// The routine lux_decomp computes LU-factorization of a given square
 272.678 +// matrix A.
 272.679 +//
 272.680 +// The parameter lux specifies LU-factorization data structure built by
 272.681 +// means of the routine lux_create.
 272.682 +//
 272.683 +// The formal routine col specifies the original matrix A. In order to
 272.684 +// obtain j-th column of the matrix A the routine lux_decomp calls the
 272.685 +// routine col with the parameter j (1 <= j <= n, where n is the order
 272.686 +// of A). In response the routine col should store row indices and
 272.687 +// numerical values of non-zero elements of j-th column of A to the
 272.688 +// locations ind[1], ..., ind[len] and val[1], ..., val[len], resp.,
 272.689 +// where len is the number of non-zeros in j-th column, which should be
 272.690 +// returned on exit. Neiter zero nor duplicate elements are allowed.
 272.691 +//
 272.692 +// The parameter info is a transit pointer passed to the formal routine
 272.693 +// col; it can be used for various purposes.
 272.694 +//
 272.695 +// RETURNS
 272.696 +//
 272.697 +// The routine lux_decomp returns the singularity flag. Zero flag means
 272.698 +// that the original matrix A is non-singular while non-zero flag means
 272.699 +// that A is (exactly!) singular.
 272.700 +//
 272.701 +// Note that LU-factorization is valid in both cases, however, in case
 272.702 +// of singularity some rows of the matrix V (including pivot elements)
 272.703 +// will be empty.
 272.704 +//
 272.705 +// REPAIRING SINGULAR MATRIX
 272.706 +//
 272.707 +// If the routine lux_decomp returns non-zero flag, it provides all
 272.708 +// necessary information that can be used for "repairing" the matrix A,
 272.709 +// where "repairing" means replacing linearly dependent columns of the
 272.710 +// matrix A by appropriate columns of the unity matrix. This feature is
 272.711 +// needed when the routine lux_decomp is used for reinverting the basis
 272.712 +// matrix within the simplex method procedure.
 272.713 +//
 272.714 +// On exit linearly dependent columns of the matrix U have the numbers
 272.715 +// rank+1, rank+2, ..., n, where rank is the exact rank of the matrix A
 272.716 +// stored by the routine to the member lux->rank. The correspondence
 272.717 +// between columns of A and U is the same as between columns of V and U.
 272.718 +// Thus, linearly dependent columns of the matrix A have the numbers
 272.719 +// Q_col[rank+1], Q_col[rank+2], ..., Q_col[n], where Q_col is an array
 272.720 +// representing the permutation matrix Q in column-like format. It is
 272.721 +// understood that each j-th linearly dependent column of the matrix U
 272.722 +// should be replaced by the unity vector, where all elements are zero
 272.723 +// except the unity diagonal element u[j,j]. On the other hand j-th row
 272.724 +// of the matrix U corresponds to the row of the matrix V (and therefore
 272.725 +// of the matrix A) with the number P_row[j], where P_row is an array
 272.726 +// representing the permutation matrix P in row-like format. Thus, each
 272.727 +// j-th linearly dependent column of the matrix U should be replaced by
 272.728 +// a column of the unity matrix with the number P_row[j].
 272.729 +//
 272.730 +// The code that repairs the matrix A may look like follows:
 272.731 +//
 272.732 +//    for (j = rank+1; j <= n; j++)
 272.733 +//    {  replace column Q_col[j] of the matrix A by column P_row[j] of
 272.734 +//       the unity matrix;
 272.735 +//    }
 272.736 +//
 272.737 +// where rank, P_row, and Q_col are members of the structure LUX. */
 272.738 +
 272.739 +int lux_decomp(LUX *lux, int (*col)(void *info, int j, int ind[],
 272.740 +      mpq_t val[]), void *info)
 272.741 +{     int n = lux->n;
 272.742 +      LUXELM **V_row = lux->V_row;
 272.743 +      LUXELM **V_col = lux->V_col;
 272.744 +      int *P_row = lux->P_row;
 272.745 +      int *P_col = lux->P_col;
 272.746 +      int *Q_row = lux->Q_row;
 272.747 +      int *Q_col = lux->Q_col;
 272.748 +      LUXELM *piv, *vij;
 272.749 +      LUXWKA *wka;
 272.750 +      int i, j, k, p, q, t, *flag;
 272.751 +      mpq_t *work;
 272.752 +      /* allocate working area */
 272.753 +      wka = xmalloc(sizeof(LUXWKA));
 272.754 +      wka->R_len = xcalloc(1+n, sizeof(int));
 272.755 +      wka->R_head = xcalloc(1+n, sizeof(int));
 272.756 +      wka->R_prev = xcalloc(1+n, sizeof(int));
 272.757 +      wka->R_next = xcalloc(1+n, sizeof(int));
 272.758 +      wka->C_len = xcalloc(1+n, sizeof(int));
 272.759 +      wka->C_head = xcalloc(1+n, sizeof(int));
 272.760 +      wka->C_prev = xcalloc(1+n, sizeof(int));
 272.761 +      wka->C_next = xcalloc(1+n, sizeof(int));
 272.762 +      /* initialize LU-factorization data structures */
 272.763 +      initialize(lux, col, info, wka);
 272.764 +      /* allocate working arrays */
 272.765 +      flag = xcalloc(1+n, sizeof(int));
 272.766 +      work = xcalloc(1+n, sizeof(mpq_t));
 272.767 +      for (k = 1; k <= n; k++)
 272.768 +      {  flag[k] = 0;
 272.769 +         mpq_init(work[k]);
 272.770 +      }
 272.771 +      /* main elimination loop */
 272.772 +      for (k = 1; k <= n; k++)
 272.773 +      {  /* choose a pivot element v[p,q] */
 272.774 +         piv = find_pivot(lux, wka);
 272.775 +         if (piv == NULL)
 272.776 +         {  /* no pivot can be chosen, because the active submatrix is
 272.777 +               empty */
 272.778 +            break;
 272.779 +         }
 272.780 +         /* determine row and column indices of the pivot element */
 272.781 +         p = piv->i, q = piv->j;
 272.782 +         /* let v[p,q] correspond to u[i',j']; permute k-th and i'-th
 272.783 +            rows and k-th and j'-th columns of the matrix U = P*V*Q to
 272.784 +            move the element u[i',j'] to the position u[k,k] */
 272.785 +         i = P_col[p], j = Q_row[q];
 272.786 +         xassert(k <= i && i <= n && k <= j && j <= n);
 272.787 +         /* permute k-th and i-th rows of the matrix U */
 272.788 +         t = P_row[k];
 272.789 +         P_row[i] = t, P_col[t] = i;
 272.790 +         P_row[k] = p, P_col[p] = k;
 272.791 +         /* permute k-th and j-th columns of the matrix U */
 272.792 +         t = Q_col[k];
 272.793 +         Q_col[j] = t, Q_row[t] = j;
 272.794 +         Q_col[k] = q, Q_row[q] = k;
 272.795 +         /* eliminate subdiagonal elements of k-th column of the matrix
 272.796 +            U = P*V*Q using the pivot element u[k,k] = v[p,q] */
 272.797 +         eliminate(lux, wka, piv, flag, work);
 272.798 +      }
 272.799 +      /* determine the rank of A (and V) */
 272.800 +      lux->rank = k - 1;
 272.801 +      /* free working arrays */
 272.802 +      xfree(flag);
 272.803 +      for (k = 1; k <= n; k++) mpq_clear(work[k]);
 272.804 +      xfree(work);
 272.805 +      /* build column lists of the matrix V using its row lists */
 272.806 +      for (j = 1; j <= n; j++)
 272.807 +         xassert(V_col[j] == NULL);
 272.808 +      for (i = 1; i <= n; i++)
 272.809 +      {  for (vij = V_row[i]; vij != NULL; vij = vij->r_next)
 272.810 +         {  j = vij->j;
 272.811 +            vij->c_prev = NULL;
 272.812 +            vij->c_next = V_col[j];
 272.813 +            if (vij->c_next != NULL) vij->c_next->c_prev = vij;
 272.814 +            V_col[j] = vij;
 272.815 +         }
 272.816 +      }
 272.817 +      /* free working area */
 272.818 +      xfree(wka->R_len);
 272.819 +      xfree(wka->R_head);
 272.820 +      xfree(wka->R_prev);
 272.821 +      xfree(wka->R_next);
 272.822 +      xfree(wka->C_len);
 272.823 +      xfree(wka->C_head);
 272.824 +      xfree(wka->C_prev);
 272.825 +      xfree(wka->C_next);
 272.826 +      xfree(wka);
 272.827 +      /* return to the calling program */
 272.828 +      return (lux->rank < n);
 272.829 +}
 272.830 +
 272.831 +/*----------------------------------------------------------------------
 272.832 +// lux_f_solve - solve system F*x = b or F'*x = b.
 272.833 +//
 272.834 +// SYNOPSIS
 272.835 +//
 272.836 +// #include "glplux.h"
 272.837 +// void lux_f_solve(LUX *lux, int tr, mpq_t x[]);
 272.838 +//
 272.839 +// DESCRIPTION
 272.840 +//
 272.841 +// The routine lux_f_solve solves either the system F*x = b (if the
 272.842 +// flag tr is zero) or the system F'*x = b (if the flag tr is non-zero),
 272.843 +// where the matrix F is a component of LU-factorization specified by
 272.844 +// the parameter lux, F' is a matrix transposed to F.
 272.845 +//
 272.846 +// On entry the array x should contain elements of the right-hand side
 272.847 +// vector b in locations x[1], ..., x[n], where n is the order of the
 272.848 +// matrix F. On exit this array will contain elements of the solution
 272.849 +// vector x in the same locations. */
 272.850 +
 272.851 +void lux_f_solve(LUX *lux, int tr, mpq_t x[])
 272.852 +{     int n = lux->n;
 272.853 +      LUXELM **F_row = lux->F_row;
 272.854 +      LUXELM **F_col = lux->F_col;
 272.855 +      int *P_row = lux->P_row;
 272.856 +      LUXELM *fik, *fkj;
 272.857 +      int i, j, k;
 272.858 +      mpq_t temp;
 272.859 +      mpq_init(temp);
 272.860 +      if (!tr)
 272.861 +      {  /* solve the system F*x = b */
 272.862 +         for (j = 1; j <= n; j++)
 272.863 +         {  k = P_row[j];
 272.864 +            if (mpq_sgn(x[k]) != 0)
 272.865 +            {  for (fik = F_col[k]; fik != NULL; fik = fik->c_next)
 272.866 +               {  mpq_mul(temp, fik->val, x[k]);
 272.867 +                  mpq_sub(x[fik->i], x[fik->i], temp);
 272.868 +               }
 272.869 +            }
 272.870 +         }
 272.871 +      }
 272.872 +      else
 272.873 +      {  /* solve the system F'*x = b */
 272.874 +         for (i = n; i >= 1; i--)
 272.875 +         {  k = P_row[i];
 272.876 +            if (mpq_sgn(x[k]) != 0)
 272.877 +            {  for (fkj = F_row[k]; fkj != NULL; fkj = fkj->r_next)
 272.878 +               {  mpq_mul(temp, fkj->val, x[k]);
 272.879 +                  mpq_sub(x[fkj->j], x[fkj->j], temp);
 272.880 +               }
 272.881 +            }
 272.882 +         }
 272.883 +      }
 272.884 +      mpq_clear(temp);
 272.885 +      return;
 272.886 +}
 272.887 +
 272.888 +/*----------------------------------------------------------------------
 272.889 +// lux_v_solve - solve system V*x = b or V'*x = b.
 272.890 +//
 272.891 +// SYNOPSIS
 272.892 +//
 272.893 +// #include "glplux.h"
 272.894 +// void lux_v_solve(LUX *lux, int tr, double x[]);
 272.895 +//
 272.896 +// DESCRIPTION
 272.897 +//
 272.898 +// The routine lux_v_solve solves either the system V*x = b (if the
 272.899 +// flag tr is zero) or the system V'*x = b (if the flag tr is non-zero),
 272.900 +// where the matrix V is a component of LU-factorization specified by
 272.901 +// the parameter lux, V' is a matrix transposed to V.
 272.902 +//
 272.903 +// On entry the array x should contain elements of the right-hand side
 272.904 +// vector b in locations x[1], ..., x[n], where n is the order of the
 272.905 +// matrix V. On exit this array will contain elements of the solution
 272.906 +// vector x in the same locations. */
 272.907 +
 272.908 +void lux_v_solve(LUX *lux, int tr, mpq_t x[])
 272.909 +{     int n = lux->n;
 272.910 +      mpq_t *V_piv = lux->V_piv;
 272.911 +      LUXELM **V_row = lux->V_row;
 272.912 +      LUXELM **V_col = lux->V_col;
 272.913 +      int *P_row = lux->P_row;
 272.914 +      int *Q_col = lux->Q_col;
 272.915 +      LUXELM *vij;
 272.916 +      int i, j, k;
 272.917 +      mpq_t *b, temp;
 272.918 +      b = xcalloc(1+n, sizeof(mpq_t));
 272.919 +      for (k = 1; k <= n; k++)
 272.920 +         mpq_init(b[k]), mpq_set(b[k], x[k]), mpq_set_si(x[k], 0, 1);
 272.921 +      mpq_init(temp);
 272.922 +      if (!tr)
 272.923 +      {  /* solve the system V*x = b */
 272.924 +         for (k = n; k >= 1; k--)
 272.925 +         {  i = P_row[k], j = Q_col[k];
 272.926 +            if (mpq_sgn(b[i]) != 0)
 272.927 +            {  mpq_set(x[j], b[i]);
 272.928 +               mpq_div(x[j], x[j], V_piv[i]);
 272.929 +               for (vij = V_col[j]; vij != NULL; vij = vij->c_next)
 272.930 +               {  mpq_mul(temp, vij->val, x[j]);
 272.931 +                  mpq_sub(b[vij->i], b[vij->i], temp);
 272.932 +               }
 272.933 +            }
 272.934 +         }
 272.935 +      }
 272.936 +      else
 272.937 +      {  /* solve the system V'*x = b */
 272.938 +         for (k = 1; k <= n; k++)
 272.939 +         {  i = P_row[k], j = Q_col[k];
 272.940 +            if (mpq_sgn(b[j]) != 0)
 272.941 +            {  mpq_set(x[i], b[j]);
 272.942 +               mpq_div(x[i], x[i], V_piv[i]);
 272.943 +               for (vij = V_row[i]; vij != NULL; vij = vij->r_next)
 272.944 +               {  mpq_mul(temp, vij->val, x[i]);
 272.945 +                  mpq_sub(b[vij->j], b[vij->j], temp);
 272.946 +               }
 272.947 +            }
 272.948 +         }
 272.949 +      }
 272.950 +      for (k = 1; k <= n; k++) mpq_clear(b[k]);
 272.951 +      mpq_clear(temp);
 272.952 +      xfree(b);
 272.953 +      return;
 272.954 +}
 272.955 +
 272.956 +/*----------------------------------------------------------------------
 272.957 +// lux_solve - solve system A*x = b or A'*x = b.
 272.958 +//
 272.959 +// SYNOPSIS
 272.960 +//
 272.961 +// #include "glplux.h"
 272.962 +// void lux_solve(LUX *lux, int tr, mpq_t x[]);
 272.963 +//
 272.964 +// DESCRIPTION
 272.965 +//
 272.966 +// The routine lux_solve solves either the system A*x = b (if the flag
 272.967 +// tr is zero) or the system A'*x = b (if the flag tr is non-zero),
 272.968 +// where the parameter lux specifies LU-factorization of the matrix A,
 272.969 +// A' is a matrix transposed to A.
 272.970 +//
 272.971 +// On entry the array x should contain elements of the right-hand side
 272.972 +// vector b in locations x[1], ..., x[n], where n is the order of the
 272.973 +// matrix A. On exit this array will contain elements of the solution
 272.974 +// vector x in the same locations. */
 272.975 +
 272.976 +void lux_solve(LUX *lux, int tr, mpq_t x[])
 272.977 +{     if (lux->rank < lux->n)
 272.978 +         xfault("lux_solve: LU-factorization has incomplete rank\n");
 272.979 +      if (!tr)
 272.980 +      {  /* A = F*V, therefore inv(A) = inv(V)*inv(F) */
 272.981 +         lux_f_solve(lux, 0, x);
 272.982 +         lux_v_solve(lux, 0, x);
 272.983 +      }
 272.984 +      else
 272.985 +      {  /* A' = V'*F', therefore inv(A') = inv(F')*inv(V') */
 272.986 +         lux_v_solve(lux, 1, x);
 272.987 +         lux_f_solve(lux, 1, x);
 272.988 +      }
 272.989 +      return;
 272.990 +}
 272.991 +
 272.992 +/*----------------------------------------------------------------------
 272.993 +// lux_delete - delete LU-factorization.
 272.994 +//
 272.995 +// SYNOPSIS
 272.996 +//
 272.997 +// #include "glplux.h"
 272.998 +// void lux_delete(LUX *lux);
 272.999 +//
272.1000 +// DESCRIPTION
272.1001 +//
272.1002 +// The routine lux_delete deletes LU-factorization data structure,
272.1003 +// which the parameter lux points to, freeing all the memory allocated
272.1004 +// to this object. */
272.1005 +
272.1006 +void lux_delete(LUX *lux)
272.1007 +{     int n = lux->n;
272.1008 +      LUXELM *fij, *vij;
272.1009 +      int i;
272.1010 +      for (i = 1; i <= n; i++)
272.1011 +      {  for (fij = lux->F_row[i]; fij != NULL; fij = fij->r_next)
272.1012 +            mpq_clear(fij->val);
272.1013 +         mpq_clear(lux->V_piv[i]);
272.1014 +         for (vij = lux->V_row[i]; vij != NULL; vij = vij->r_next)
272.1015 +            mpq_clear(vij->val);
272.1016 +      }
272.1017 +      dmp_delete_pool(lux->pool);
272.1018 +      xfree(lux->F_row);
272.1019 +      xfree(lux->F_col);
272.1020 +      xfree(lux->V_piv);
272.1021 +      xfree(lux->V_row);
272.1022 +      xfree(lux->V_col);
272.1023 +      xfree(lux->P_row);
272.1024 +      xfree(lux->P_col);
272.1025 +      xfree(lux->Q_row);
272.1026 +      xfree(lux->Q_col);
272.1027 +      xfree(lux);
272.1028 +      return;
272.1029 +}
272.1030 +
272.1031 +/* eof */
   273.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
   273.2 +++ b/deps/glpk/src/glplux.h	Sun Nov 06 20:59:10 2011 +0100
   273.3 @@ -0,0 +1,221 @@
   273.4 +/* glplux.h (LU-factorization, bignum arithmetic) */
   273.5 +
   273.6 +/***********************************************************************
   273.7 +*  This code is part of GLPK (GNU Linear Programming Kit).
   273.8 +*
   273.9 +*  Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008,
  273.10 +*  2009, 2010, 2011 Andrew Makhorin, Department for Applied Informatics,
  273.11 +*  Moscow Aviation Institute, Moscow, Russia. All rights reserved.
  273.12 +*  E-mail: <mao@gnu.org>.
  273.13 +*
  273.14 +*  GLPK is free software: you can redistribute it and/or modify it
  273.15 +*  under the terms of the GNU General Public License as published by
  273.16 +*  the Free Software Foundation, either version 3 of the License, or
  273.17 +*  (at your option) any later version.
  273.18 +*
  273.19 +*  GLPK is distributed in the hope that it will be useful, but WITHOUT
  273.20 +*  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
  273.21 +*  or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
  273.22 +*  License for more details.
  273.23 +*
  273.24 +*  You should have received a copy of the GNU General Public License
  273.25 +*  along with GLPK. If not, see <http://www.gnu.org/licenses/>.
  273.26 +***********************************************************************/
  273.27 +
  273.28 +#ifndef GLPLUX_H
  273.29 +#define GLPLUX_H
  273.30 +
  273.31 +#include "glpdmp.h"
  273.32 +#include "glpgmp.h"
  273.33 +
  273.34 +/*----------------------------------------------------------------------
  273.35 +// The structure LUX defines LU-factorization of a square matrix A,
  273.36 +// which is the following quartet:
  273.37 +//
  273.38 +//    [A] = (F, V, P, Q),                                            (1)
  273.39 +//
  273.40 +// where F and V are such matrices that
  273.41 +//
  273.42 +//    A = F * V,                                                     (2)
  273.43 +//
  273.44 +// and P and Q are such permutation matrices that the matrix
  273.45 +//
  273.46 +//    L = P * F * inv(P)                                             (3)
  273.47 +//
  273.48 +// is lower triangular with unity diagonal, and the matrix
  273.49 +//
  273.50 +//    U = P * V * Q                                                  (4)
  273.51 +//
  273.52 +// is upper triangular. All the matrices have the order n.
  273.53 +//
  273.54 +// The matrices F and V are stored in row/column-wise sparse format as
  273.55 +// row and column linked lists of non-zero elements. Unity elements on
  273.56 +// the main diagonal of the matrix F are not stored. Pivot elements of
  273.57 +// the matrix V (that correspond to diagonal elements of the matrix U)
  273.58 +// are also missing from the row and column lists and stored separately
  273.59 +// in an ordinary array.
  273.60 +//
  273.61 +// The permutation matrices P and Q are stored as ordinary arrays using
  273.62 +// both row- and column-like formats.
  273.63 +//
  273.64 +// The matrices L and U being completely defined by the matrices F, V,
  273.65 +// P, and Q are not stored explicitly.
  273.66 +//
  273.67 +// It is easy to show that the factorization (1)-(3) is some version of
  273.68 +// LU-factorization. Indeed, from (3) and (4) it follows that:
  273.69 +//
  273.70 +//    F = inv(P) * L * P,
  273.71 +//
  273.72 +//    V = inv(P) * U * inv(Q),
  273.73 +//
  273.74 +// and substitution into (2) gives:
  273.75 +//
  273.76 +//    A = F * V = inv(P) * L * U * inv(Q).
  273.77 +//
  273.78 +// For more details see the program documentation. */
  273.79 +
  273.80 +typedef struct LUX LUX;
  273.81 +typedef struct LUXELM LUXELM;
  273.82 +typedef struct LUXWKA LUXWKA;
  273.83 +
  273.84 +struct LUX
  273.85 +{     /* LU-factorization of a square matrix */
  273.86 +      int n;
  273.87 +      /* the order of matrices A, F, V, P, Q */
  273.88 +      DMP *pool;
  273.89 +      /* memory pool for elements of matrices F and V */
  273.90 +      LUXELM **F_row; /* LUXELM *F_row[1+n]; */
  273.91 +      /* F_row[0] is not used;
  273.92 +         F_row[i], 1 <= i <= n, is a pointer to the list of elements in
  273.93 +         i-th row of matrix F (diagonal elements are not stored) */
  273.94 +      LUXELM **F_col; /* LUXELM *F_col[1+n]; */
  273.95 +      /* F_col[0] is not used;
  273.96 +         F_col[j], 1 <= j <= n, is a pointer to the list of elements in
  273.97 +         j-th column of matrix F (diagonal elements are not stored) */
  273.98 +      mpq_t *V_piv; /* mpq_t V_piv[1+n]; */
  273.99 +      /* V_piv[0] is not used;
 273.100 +         V_piv[p], 1 <= p <= n, is a pivot element v[p,q] corresponding
 273.101 +         to a diagonal element u[k,k] of matrix U = P*V*Q (used on k-th
 273.102 +         elimination step, k = 1, 2, ..., n) */
 273.103 +      LUXELM **V_row; /* LUXELM *V_row[1+n]; */
 273.104 +      /* V_row[0] is not used;
 273.105 +         V_row[i], 1 <= i <= n, is a pointer to the list of elements in
 273.106 +         i-th row of matrix V (except pivot elements) */
 273.107 +      LUXELM **V_col; /* LUXELM *V_col[1+n]; */
 273.108 +      /* V_col[0] is not used;
 273.109 +         V_col[j], 1 <= j <= n, is a pointer to the list of elements in
 273.110 +         j-th column of matrix V (except pivot elements) */
 273.111 +      int *P_row; /* int P_row[1+n]; */
 273.112 +      /* P_row[0] is not used;
 273.113 +         P_row[i] = j means that p[i,j] = 1, where p[i,j] is an element
 273.114 +         of permutation matrix P */
 273.115 +      int *P_col; /* int P_col[1+n]; */
 273.116 +      /* P_col[0] is not used;
 273.117 +         P_col[j] = i means that p[i,j] = 1, where p[i,j] is an element
 273.118 +         of permutation matrix P */
 273.119 +      /* if i-th row or column of matrix F is i'-th row or column of
 273.120 +         matrix L = P*F*inv(P), or if i-th row of matrix V is i'-th row
 273.121 +         of matrix U = P*V*Q, then P_row[i'] = i and P_col[i] = i' */
 273.122 +      int *Q_row; /* int Q_row[1+n]; */
 273.123 +      /* Q_row[0] is not used;
 273.124 +         Q_row[i] = j means that q[i,j] = 1, where q[i,j] is an element
 273.125 +         of permutation matrix Q */
 273.126 +      int *Q_col; /* int Q_col[1+n]; */
 273.127 +      /* Q_col[0] is not used;
 273.128 +         Q_col[j] = i means that q[i,j] = 1, where q[i,j] is an element
 273.129 +         of permutation matrix Q */
 273.130 +      /* if j-th column of matrix V is j'-th column of matrix U = P*V*Q,
 273.131 +         then Q_row[j] = j' and Q_col[j'] = j */
 273.132 +      int rank;
 273.133 +      /* the (exact) rank of matrices A and V */
 273.134 +};
 273.135 +
 273.136 +struct LUXELM
 273.137 +{     /* element of matrix F or V */
 273.138 +      int i;
 273.139 +      /* row index, 1 <= i <= m */
 273.140 +      int j;
 273.141 +      /* column index, 1 <= j <= n */
 273.142 +      mpq_t val;
 273.143 +      /* numeric (non-zero) element value */
 273.144 +      LUXELM *r_prev;
 273.145 +      /* pointer to previous element in the same row */
 273.146 +      LUXELM *r_next;
 273.147 +      /* pointer to next element in the same row */
 273.148 +      LUXELM *c_prev;
 273.149 +      /* pointer to previous element in the same column */
 273.150 +      LUXELM *c_next;
 273.151 +      /* pointer to next element in the same column */
 273.152 +};
 273.153 +
 273.154 +struct LUXWKA
 273.155 +{     /* working area (used only during factorization) */
 273.156 +      /* in order to efficiently implement Markowitz strategy and Duff
 273.157 +         search technique there are two families {R[0], R[1], ..., R[n]}
 273.158 +         and {C[0], C[1], ..., C[n]}; member R[k] is a set of active
 273.159 +         rows of matrix V having k non-zeros, and member C[k] is a set
 273.160 +         of active columns of matrix V having k non-zeros (in the active
 273.161 +         submatrix); each set R[k] and C[k] is implemented as a separate
 273.162 +         doubly linked list */
 273.163 +      int *R_len; /* int R_len[1+n]; */
 273.164 +      /* R_len[0] is not used;
 273.165 +         R_len[i], 1 <= i <= n, is the number of non-zero elements in
 273.166 +         i-th row of matrix V (that is the length of i-th row) */
 273.167 +      int *R_head; /* int R_head[1+n]; */
 273.168 +      /* R_head[k], 0 <= k <= n, is the number of a first row, which is
 273.169 +         active and whose length is k */
 273.170 +      int *R_prev; /* int R_prev[1+n]; */
 273.171 +      /* R_prev[0] is not used;
 273.172 +         R_prev[i], 1 <= i <= n, is the number of a previous row, which
 273.173 +         is active and has the same length as i-th row */
 273.174 +      int *R_next; /* int R_next[1+n]; */
 273.175 +      /* R_prev[0] is not used;
 273.176 +         R_prev[i], 1 <= i <= n, is the number of a next row, which is
 273.177 +         active and has the same length as i-th row */
 273.178 +      int *C_len; /* int C_len[1+n]; */
 273.179 +      /* C_len[0] is not used;
 273.180 +         C_len[j], 1 <= j <= n, is the number of non-zero elements in
 273.181 +         j-th column of the active submatrix of matrix V (that is the
 273.182 +         length of j-th column in the active submatrix) */
 273.183 +      int *C_head; /* int C_head[1+n]; */
 273.184 +      /* C_head[k], 0 <= k <= n, is the number of a first column, which
 273.185 +         is active and whose length is k */
 273.186 +      int *C_prev; /* int C_prev[1+n]; */
 273.187 +      /* C_prev[0] is not used;
 273.188 +         C_prev[j], 1 <= j <= n, is the number of a previous column,
 273.189 +         which is active and has the same length as j-th column */
 273.190 +      int *C_next; /* int C_next[1+n]; */
 273.191 +      /* C_next[0] is not used;
 273.192 +         C_next[j], 1 <= j <= n, is the number of a next column, which
 273.193 +         is active and has the same length as j-th column */
 273.194 +};
 273.195 +
 273.196 +#define lux_create            _glp_lux_create
 273.197 +#define lux_decomp            _glp_lux_decomp
 273.198 +#define lux_f_solve           _glp_lux_f_solve
 273.199 +#define lux_v_solve           _glp_lux_v_solve
 273.200 +#define lux_solve             _glp_lux_solve
 273.201 +#define lux_delete            _glp_lux_delete
 273.202 +
 273.203 +LUX *lux_create(int n);
 273.204 +/* create LU-factorization */
 273.205 +
 273.206 +int lux_decomp(LUX *lux, int (*col)(void *info, int j, int ind[],
 273.207 +      mpq_t val[]), void *info);
 273.208 +/* compute LU-factorization */
 273.209 +
 273.210 +void lux_f_solve(LUX *lux, int tr, mpq_t x[]);
 273.211 +/* solve system F*x = b or F'*x = b */
 273.212 +
 273.213 +void lux_v_solve(LUX *lux, int tr, mpq_t x[]);
 273.214 +/* solve system V*x = b or V'*x = b */
 273.215 +
 273.216 +void lux_solve(LUX *lux, int tr, mpq_t x[]);
 273.217 +/* solve system A*x = b or A'*x = b */
 273.218 +
 273.219 +void lux_delete(LUX *lux);
 273.220 +/* delete LU-factorization */
 273.221 +
 273.222 +#endif
 273.223 +
 273.224 +/* eof */
   274.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
   274.2 +++ b/deps/glpk/src/glpmat.c	Sun Nov 06 20:59:10 2011 +0100
   274.3 @@ -0,0 +1,924 @@
   274.4 +/* glpmat.c */
   274.5 +
   274.6 +/***********************************************************************
   274.7 +*  This code is part of GLPK (GNU Linear Programming Kit).
   274.8 +*
   274.9 +*  Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008,
  274.10 +*  2009, 2010, 2011 Andrew Makhorin, Department for Applied Informatics,
  274.11 +*  Moscow Aviation Institute, Moscow, Russia. All rights reserved.
  274.12 +*  E-mail: <mao@gnu.org>.
  274.13 +*
  274.14 +*  GLPK is free software: you can redistribute it and/or modify it
  274.15 +*  under the terms of the GNU General Public License as published by
  274.16 +*  the Free Software Foundation, either version 3 of the License, or
  274.17 +*  (at your option) any later version.
  274.18 +*
  274.19 +*  GLPK is distributed in the hope that it will be useful, but WITHOUT
  274.20 +*  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
  274.21 +*  or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
  274.22 +*  License for more details.
  274.23 +*
  274.24 +*  You should have received a copy of the GNU General Public License
  274.25 +*  along with GLPK. If not, see <http://www.gnu.org/licenses/>.
  274.26 +***********************************************************************/
  274.27 +
  274.28 +#include "glpenv.h"
  274.29 +#include "glpmat.h"
  274.30 +#include "glpqmd.h"
  274.31 +#include "amd/amd.h"
  274.32 +#include "colamd/colamd.h"
  274.33 +
  274.34 +/*----------------------------------------------------------------------
  274.35 +-- check_fvs - check sparse vector in full-vector storage format.
  274.36 +--
  274.37 +-- SYNOPSIS
  274.38 +--
  274.39 +-- #include "glpmat.h"
  274.40 +-- int check_fvs(int n, int nnz, int ind[], double vec[]);
  274.41 +--
  274.42 +-- DESCRIPTION
  274.43 +--
  274.44 +-- The routine check_fvs checks if a given vector of dimension n in
  274.45 +-- full-vector storage format has correct representation.
  274.46 +--
  274.47 +-- RETURNS
  274.48 +--
  274.49 +-- The routine returns one of the following codes:
  274.50 +--
  274.51 +-- 0 - the vector is correct;
  274.52 +-- 1 - the number of elements (n) is negative;
  274.53 +-- 2 - the number of non-zero elements (nnz) is negative;
  274.54 +-- 3 - some element index is out of range;
  274.55 +-- 4 - some element index is duplicate;
  274.56 +-- 5 - some non-zero element is out of pattern. */
  274.57 +
  274.58 +int check_fvs(int n, int nnz, int ind[], double vec[])
  274.59 +{     int i, t, ret, *flag = NULL;
  274.60 +      /* check the number of elements */
  274.61 +      if (n < 0)
  274.62 +      {  ret = 1;
  274.63 +         goto done;
  274.64 +      }
  274.65 +      /* check the number of non-zero elements */
  274.66 +      if (nnz < 0)
  274.67 +      {  ret = 2;
  274.68 +         goto done;
  274.69 +      }
  274.70 +      /* check vector indices */
  274.71 +      flag = xcalloc(1+n, sizeof(int));
  274.72 +      for (i = 1; i <= n; i++) flag[i] = 0;
  274.73 +      for (t = 1; t <= nnz; t++)
  274.74 +      {  i = ind[t];
  274.75 +         if (!(1 <= i && i <= n))
  274.76 +         {  ret = 3;
  274.77 +            goto done;
  274.78 +         }
  274.79 +         if (flag[i])
  274.80 +         {  ret = 4;
  274.81 +            goto done;
  274.82 +         }
  274.83 +         flag[i] = 1;
  274.84 +      }
  274.85 +      /* check vector elements */
  274.86 +      for (i = 1; i <= n; i++)
  274.87 +      {  if (!flag[i] && vec[i] != 0.0)
  274.88 +         {  ret = 5;
  274.89 +            goto done;
  274.90 +         }
  274.91 +      }
  274.92 +      /* the vector is ok */
  274.93 +      ret = 0;
  274.94 +done: if (flag != NULL) xfree(flag);
  274.95 +      return ret;
  274.96 +}
  274.97 +
  274.98 +/*----------------------------------------------------------------------
  274.99 +-- check_pattern - check pattern of sparse matrix.
 274.100 +--
 274.101 +-- SYNOPSIS
 274.102 +--
 274.103 +-- #include "glpmat.h"
 274.104 +-- int check_pattern(int m, int n, int A_ptr[], int A_ind[]);
 274.105 +--
 274.106 +-- DESCRIPTION
 274.107 +--
 274.108 +-- The routine check_pattern checks the pattern of a given mxn matrix
 274.109 +-- in storage-by-rows format.
 274.110 +--
 274.111 +-- RETURNS
 274.112 +--
 274.113 +-- The routine returns one of the following codes:
 274.114 +--
 274.115 +-- 0 - the pattern is correct;
 274.116 +-- 1 - the number of rows (m) is negative;
 274.117 +-- 2 - the number of columns (n) is negative;
 274.118 +-- 3 - A_ptr[1] is not 1;
 274.119 +-- 4 - some column index is out of range;
 274.120 +-- 5 - some column indices are duplicate. */
 274.121 +
 274.122 +int check_pattern(int m, int n, int A_ptr[], int A_ind[])
 274.123 +{     int i, j, ptr, ret, *flag = NULL;
 274.124 +      /* check the number of rows */
 274.125 +      if (m < 0)
 274.126 +      {  ret = 1;
 274.127 +         goto done;
 274.128 +      }
 274.129 +      /* check the number of columns */
 274.130 +      if (n < 0)
 274.131 +      {  ret = 2;
 274.132 +         goto done;
 274.133 +      }
 274.134 +      /* check location A_ptr[1] */
 274.135 +      if (A_ptr[1] != 1)
 274.136 +      {  ret = 3;
 274.137 +         goto done;
 274.138 +      }
 274.139 +      /* check row patterns */
 274.140 +      flag = xcalloc(1+n, sizeof(int));
 274.141 +      for (j = 1; j <= n; j++) flag[j] = 0;
 274.142 +      for (i = 1; i <= m; i++)
 274.143 +      {  /* check pattern of row i */
 274.144 +         for (ptr = A_ptr[i]; ptr < A_ptr[i+1]; ptr++)
 274.145 +         {  j = A_ind[ptr];
 274.146 +            /* check column index */
 274.147 +            if (!(1 <= j && j <= n))
 274.148 +            {  ret = 4;
 274.149 +               goto done;
 274.150 +            }
 274.151 +            /* check for duplication */
 274.152 +            if (flag[j])
 274.153 +            {  ret = 5;
 274.154 +               goto done;
 274.155 +            }
 274.156 +            flag[j] = 1;
 274.157 +         }
 274.158 +         /* clear flags */
 274.159 +         for (ptr = A_ptr[i]; ptr < A_ptr[i+1]; ptr++)
 274.160 +         {  j = A_ind[ptr];
 274.161 +            flag[j] = 0;
 274.162 +         }
 274.163 +      }
 274.164 +      /* the pattern is ok */
 274.165 +      ret = 0;
 274.166 +done: if (flag != NULL) xfree(flag);
 274.167 +      return ret;
 274.168 +}
 274.169 +
 274.170 +/*----------------------------------------------------------------------
 274.171 +-- transpose - transpose sparse matrix.
 274.172 +--
 274.173 +-- *Synopsis*
 274.174 +--
 274.175 +-- #include "glpmat.h"
 274.176 +-- void transpose(int m, int n, int A_ptr[], int A_ind[],
 274.177 +--    double A_val[], int AT_ptr[], int AT_ind[], double AT_val[]);
 274.178 +--
 274.179 +-- *Description*
 274.180 +--
 274.181 +-- For a given mxn sparse matrix A the routine transpose builds a nxm
 274.182 +-- sparse matrix A' which is a matrix transposed to A.
 274.183 +--
 274.184 +-- The arrays A_ptr, A_ind, and A_val specify a given mxn matrix A to
 274.185 +-- be transposed in storage-by-rows format. The parameter A_val can be
 274.186 +-- NULL, in which case numeric values are not copied. The arrays A_ptr,
 274.187 +-- A_ind, and A_val are not changed on exit.
 274.188 +--
 274.189 +-- On entry the arrays AT_ptr, AT_ind, and AT_val must be allocated,
 274.190 +-- but their content is ignored. On exit the routine stores a resultant
 274.191 +-- nxm matrix A' in these arrays in storage-by-rows format. Note that
 274.192 +-- if the parameter A_val is NULL, the array AT_val is not used.
 274.193 +--
 274.194 +-- The routine transpose has a side effect that elements in rows of the
 274.195 +-- resultant matrix A' follow in ascending their column indices. */
 274.196 +
 274.197 +void transpose(int m, int n, int A_ptr[], int A_ind[], double A_val[],
 274.198 +      int AT_ptr[], int AT_ind[], double AT_val[])
 274.199 +{     int i, j, t, beg, end, pos, len;
 274.200 +      /* determine row lengths of resultant matrix */
 274.201 +      for (j = 1; j <= n; j++) AT_ptr[j] = 0;
 274.202 +      for (i = 1; i <= m; i++)
 274.203 +      {  beg = A_ptr[i], end = A_ptr[i+1];
 274.204 +         for (t = beg; t < end; t++) AT_ptr[A_ind[t]]++;
 274.205 +      }
 274.206 +      /* set up row pointers of resultant matrix */
 274.207 +      pos = 1;
 274.208 +      for (j = 1; j <= n; j++)
 274.209 +         len = AT_ptr[j], pos += len, AT_ptr[j] = pos;
 274.210 +      AT_ptr[n+1] = pos;
 274.211 +      /* build resultant matrix */
 274.212 +      for (i = m; i >= 1; i--)
 274.213 +      {  beg = A_ptr[i], end = A_ptr[i+1];
 274.214 +         for (t = beg; t < end; t++)
 274.215 +         {  pos = --AT_ptr[A_ind[t]];
 274.216 +            AT_ind[pos] = i;
 274.217 +            if (A_val != NULL) AT_val[pos] = A_val[t];
 274.218 +         }
 274.219 +      }
 274.220 +      return;
 274.221 +}
 274.222 +
 274.223 +/*----------------------------------------------------------------------
 274.224 +-- adat_symbolic - compute S = P*A*D*A'*P' (symbolic phase).
 274.225 +--
 274.226 +-- *Synopsis*
 274.227 +--
 274.228 +-- #include "glpmat.h"
 274.229 +-- int *adat_symbolic(int m, int n, int P_per[], int A_ptr[],
 274.230 +--    int A_ind[], int S_ptr[]);
 274.231 +--
 274.232 +-- *Description*
 274.233 +--
 274.234 +-- The routine adat_symbolic implements the symbolic phase to compute
 274.235 +-- symmetric matrix S = P*A*D*A'*P', where P is a permutation matrix,
 274.236 +-- A is a given sparse matrix, D is a diagonal matrix, A' is a matrix
 274.237 +-- transposed to A, P' is an inverse of P.
 274.238 +--
 274.239 +-- The parameter m is the number of rows in A and the order of P.
 274.240 +--
 274.241 +-- The parameter n is the number of columns in A and the order of D.
 274.242 +--
 274.243 +-- The array P_per specifies permutation matrix P. It is not changed on
 274.244 +-- exit.
 274.245 +--
 274.246 +-- The arrays A_ptr and A_ind specify the pattern of matrix A. They are
 274.247 +-- not changed on exit.
 274.248 +--
 274.249 +-- On exit the routine stores the pattern of upper triangular part of
 274.250 +-- matrix S without diagonal elements in the arrays S_ptr and S_ind in
 274.251 +-- storage-by-rows format. The array S_ptr should be allocated on entry,
 274.252 +-- however, its content is ignored. The array S_ind is allocated by the
 274.253 +-- routine itself which returns a pointer to it.
 274.254 +--
 274.255 +-- *Returns*
 274.256 +--
 274.257 +-- The routine returns a pointer to the array S_ind. */
 274.258 +
 274.259 +int *adat_symbolic(int m, int n, int P_per[], int A_ptr[], int A_ind[],
 274.260 +      int S_ptr[])
 274.261 +{     int i, j, t, ii, jj, tt, k, size, len;
 274.262 +      int *S_ind, *AT_ptr, *AT_ind, *ind, *map, *temp;
 274.263 +      /* build the pattern of A', which is a matrix transposed to A, to
 274.264 +         efficiently access A in column-wise manner */
 274.265 +      AT_ptr = xcalloc(1+n+1, sizeof(int));
 274.266 +      AT_ind = xcalloc(A_ptr[m+1], sizeof(int));
 274.267 +      transpose(m, n, A_ptr, A_ind, NULL, AT_ptr, AT_ind, NULL);
 274.268 +      /* allocate the array S_ind */
 274.269 +      size = A_ptr[m+1] - 1;
 274.270 +      if (size < m) size = m;
 274.271 +      S_ind = xcalloc(1+size, sizeof(int));
 274.272 +      /* allocate and initialize working arrays */
 274.273 +      ind = xcalloc(1+m, sizeof(int));
 274.274 +      map = xcalloc(1+m, sizeof(int));
 274.275 +      for (jj = 1; jj <= m; jj++) map[jj] = 0;
 274.276 +      /* compute pattern of S; note that symbolically S = B*B', where
 274.277 +         B = P*A, B' is matrix transposed to B */
 274.278 +      S_ptr[1] = 1;
 274.279 +      for (ii = 1; ii <= m; ii++)
 274.280 +      {  /* compute pattern of ii-th row of S */
 274.281 +         len = 0;
 274.282 +         i = P_per[ii]; /* i-th row of A = ii-th row of B */
 274.283 +         for (t = A_ptr[i]; t < A_ptr[i+1]; t++)
 274.284 +         {  k = A_ind[t];
 274.285 +            /* walk through k-th column of A */
 274.286 +            for (tt = AT_ptr[k]; tt < AT_ptr[k+1]; tt++)
 274.287 +            {  j = AT_ind[tt];
 274.288 +               jj = P_per[m+j]; /* j-th row of A = jj-th row of B */
 274.289 +               /* a[i,k] != 0 and a[j,k] != 0 ergo s[ii,jj] != 0 */
 274.290 +               if (ii < jj && !map[jj]) ind[++len] = jj, map[jj] = 1;
 274.291 +            }
 274.292 +         }
 274.293 +         /* now (ind) is pattern of ii-th row of S */
 274.294 +         S_ptr[ii+1] = S_ptr[ii] + len;
 274.295 +         /* at least (S_ptr[ii+1] - 1) locations should be available in
 274.296 +            the array S_ind */
 274.297 +         if (S_ptr[ii+1] - 1 > size)
 274.298 +         {  temp = S_ind;
 274.299 +            size += size;
 274.300 +            S_ind = xcalloc(1+size, sizeof(int));
 274.301 +            memcpy(&S_ind[1], &temp[1], (S_ptr[ii] - 1) * sizeof(int));
 274.302 +            xfree(temp);
 274.303 +         }
 274.304 +         xassert(S_ptr[ii+1] - 1 <= size);
 274.305 +         /* (ii-th row of S) := (ind) */
 274.306 +         memcpy(&S_ind[S_ptr[ii]], &ind[1], len * sizeof(int));
 274.307 +         /* clear the row pattern map */
 274.308 +         for (t = 1; t <= len; t++) map[ind[t]] = 0;
 274.309 +      }
 274.310 +      /* free working arrays */
 274.311 +      xfree(AT_ptr);
 274.312 +      xfree(AT_ind);
 274.313 +      xfree(ind);
 274.314 +      xfree(map);
 274.315 +      /* reallocate the array S_ind to free unused locations */
 274.316 +      temp = S_ind;
 274.317 +      size = S_ptr[m+1] - 1;
 274.318 +      S_ind = xcalloc(1+size, sizeof(int));
 274.319 +      memcpy(&S_ind[1], &temp[1], size * sizeof(int));
 274.320 +      xfree(temp);
 274.321 +      return S_ind;
 274.322 +}
 274.323 +
 274.324 +/*----------------------------------------------------------------------
 274.325 +-- adat_numeric - compute S = P*A*D*A'*P' (numeric phase).
 274.326 +--
 274.327 +-- *Synopsis*
 274.328 +--
 274.329 +-- #include "glpmat.h"
 274.330 +-- void adat_numeric(int m, int n, int P_per[],
 274.331 +--    int A_ptr[], int A_ind[], double A_val[], double D_diag[],
 274.332 +--    int S_ptr[], int S_ind[], double S_val[], double S_diag[]);
 274.333 +--
 274.334 +-- *Description*
 274.335 +--
 274.336 +-- The routine adat_numeric implements the numeric phase to compute
 274.337 +-- symmetric matrix S = P*A*D*A'*P', where P is a permutation matrix,
 274.338 +-- A is a given sparse matrix, D is a diagonal matrix, A' is a matrix
 274.339 +-- transposed to A, P' is an inverse of P.
 274.340 +--
 274.341 +-- The parameter m is the number of rows in A and the order of P.
 274.342 +--
 274.343 +-- The parameter n is the number of columns in A and the order of D.
 274.344 +--
 274.345 +-- The matrix P is specified in the array P_per, which is not changed
 274.346 +-- on exit.
 274.347 +--
 274.348 +-- The matrix A is specified in the arrays A_ptr, A_ind, and A_val in
 274.349 +-- storage-by-rows format. These arrays are not changed on exit.
 274.350 +--
 274.351 +-- Diagonal elements of the matrix D are specified in the array D_diag,
 274.352 +-- where D_diag[0] is not used, D_diag[i] = d[i,i] for i = 1, ..., n.
 274.353 +-- The array D_diag is not changed on exit.
 274.354 +--
 274.355 +-- The pattern of the upper triangular part of the matrix S without
 274.356 +-- diagonal elements (previously computed by the routine adat_symbolic)
 274.357 +-- is specified in the arrays S_ptr and S_ind, which are not changed on
 274.358 +-- exit. Numeric values of non-diagonal elements of S are stored in
 274.359 +-- corresponding locations of the array S_val, and values of diagonal
 274.360 +-- elements of S are stored in locations S_diag[1], ..., S_diag[n]. */
 274.361 +
 274.362 +void adat_numeric(int m, int n, int P_per[],
 274.363 +      int A_ptr[], int A_ind[], double A_val[], double D_diag[],
 274.364 +      int S_ptr[], int S_ind[], double S_val[], double S_diag[])
 274.365 +{     int i, j, t, ii, jj, tt, beg, end, beg1, end1, k;
 274.366 +      double sum, *work;
 274.367 +      work = xcalloc(1+n, sizeof(double));
 274.368 +      for (j = 1; j <= n; j++) work[j] = 0.0;
 274.369 +      /* compute S = B*D*B', where B = P*A, B' is a matrix transposed
 274.370 +         to B */
 274.371 +      for (ii = 1; ii <= m; ii++)
 274.372 +      {  i = P_per[ii]; /* i-th row of A = ii-th row of B */
 274.373 +         /* (work) := (i-th row of A) */
 274.374 +         beg = A_ptr[i], end = A_ptr[i+1];
 274.375 +         for (t = beg; t < end; t++)
 274.376 +            work[A_ind[t]] = A_val[t];
 274.377 +         /* compute ii-th row of S */
 274.378 +         beg = S_ptr[ii], end = S_ptr[ii+1];
 274.379 +         for (t = beg; t < end; t++)
 274.380 +         {  jj = S_ind[t];
 274.381 +            j = P_per[jj]; /* j-th row of A = jj-th row of B */
 274.382 +            /* s[ii,jj] := sum a[i,k] * d[k,k] * a[j,k] */
 274.383 +            sum = 0.0;
 274.384 +            beg1 = A_ptr[j], end1 = A_ptr[j+1];
 274.385 +            for (tt = beg1; tt < end1; tt++)
 274.386 +            {  k = A_ind[tt];
 274.387 +               sum += work[k] * D_diag[k] * A_val[tt];
 274.388 +            }
 274.389 +            S_val[t] = sum;
 274.390 +         }
 274.391 +         /* s[ii,ii] := sum a[i,k] * d[k,k] * a[i,k] */
 274.392 +         sum = 0.0;
 274.393 +         beg = A_ptr[i], end = A_ptr[i+1];
 274.394 +         for (t = beg; t < end; t++)
 274.395 +         {  k = A_ind[t];
 274.396 +            sum += A_val[t] * D_diag[k] * A_val[t];
 274.397 +            work[k] = 0.0;
 274.398 +         }
 274.399 +         S_diag[ii] = sum;
 274.400 +      }
 274.401 +      xfree(work);
 274.402 +      return;
 274.403 +}
 274.404 +
 274.405 +/*----------------------------------------------------------------------
 274.406 +-- min_degree - minimum degree ordering.
 274.407 +--
 274.408 +-- *Synopsis*
 274.409 +--
 274.410 +-- #include "glpmat.h"
 274.411 +-- void min_degree(int n, int A_ptr[], int A_ind[], int P_per[]);
 274.412 +--
 274.413 +-- *Description*
 274.414 +--
 274.415 +-- The routine min_degree uses the minimum degree ordering algorithm
 274.416 +-- to find a permutation matrix P for a given sparse symmetric positive
 274.417 +-- matrix A which minimizes the number of non-zeros in upper triangular
 274.418 +-- factor U for Cholesky factorization P*A*P' = U'*U.
 274.419 +--
 274.420 +-- The parameter n is the order of matrices A and P.
 274.421 +--
 274.422 +-- The pattern of the given matrix A is specified on entry in the arrays
 274.423 +-- A_ptr and A_ind in storage-by-rows format. Only the upper triangular
 274.424 +-- part without diagonal elements (which all are assumed to be non-zero)
 274.425 +-- should be specified as if A were upper triangular. The arrays A_ptr
 274.426 +-- and A_ind are not changed on exit.
 274.427 +--
 274.428 +-- The permutation matrix P is stored by the routine in the array P_per
 274.429 +-- on exit.
 274.430 +--
 274.431 +-- *Algorithm*
 274.432 +--
 274.433 +-- The routine min_degree is based on some subroutines from the package
 274.434 +-- SPARSPAK (see comments in the module glpqmd). */
 274.435 +
 274.436 +void min_degree(int n, int A_ptr[], int A_ind[], int P_per[])
 274.437 +{     int i, j, ne, t, pos, len;
 274.438 +      int *xadj, *adjncy, *deg, *marker, *rchset, *nbrhd, *qsize,
 274.439 +         *qlink, nofsub;
 274.440 +      /* determine number of non-zeros in complete pattern */
 274.441 +      ne = A_ptr[n+1] - 1;
 274.442 +      ne += ne;
 274.443 +      /* allocate working arrays */
 274.444 +      xadj = xcalloc(1+n+1, sizeof(int));
 274.445 +      adjncy = xcalloc(1+ne, sizeof(int));
 274.446 +      deg = xcalloc(1+n, sizeof(int));
 274.447 +      marker = xcalloc(1+n, sizeof(int));
 274.448 +      rchset = xcalloc(1+n, sizeof(int));
 274.449 +      nbrhd = xcalloc(1+n, sizeof(int));
 274.450 +      qsize = xcalloc(1+n, sizeof(int));
 274.451 +      qlink = xcalloc(1+n, sizeof(int));
 274.452 +      /* determine row lengths in complete pattern */
 274.453 +      for (i = 1; i <= n; i++) xadj[i] = 0;
 274.454 +      for (i = 1; i <= n; i++)
 274.455 +      {  for (t = A_ptr[i]; t < A_ptr[i+1]; t++)
 274.456 +         {  j = A_ind[t];
 274.457 +            xassert(i < j && j <= n);
 274.458 +            xadj[i]++, xadj[j]++;
 274.459 +         }
 274.460 +      }
 274.461 +      /* set up row pointers for complete pattern */
 274.462 +      pos = 1;
 274.463 +      for (i = 1; i <= n; i++)
 274.464 +         len = xadj[i], pos += len, xadj[i] = pos;
 274.465 +      xadj[n+1] = pos;
 274.466 +      xassert(pos - 1 == ne);
 274.467 +      /* construct complete pattern */
 274.468 +      for (i = 1; i <= n; i++)
 274.469 +      {  for (t = A_ptr[i]; t < A_ptr[i+1]; t++)
 274.470 +         {  j = A_ind[t];
 274.471 +            adjncy[--xadj[i]] = j, adjncy[--xadj[j]] = i;
 274.472 +         }
 274.473 +      }
 274.474 +      /* call the main minimimum degree ordering routine */
 274.475 +      genqmd(&n, xadj, adjncy, P_per, P_per + n, deg, marker, rchset,
 274.476 +         nbrhd, qsize, qlink, &nofsub);
 274.477 +      /* make sure that permutation matrix P is correct */
 274.478 +      for (i = 1; i <= n; i++)
 274.479 +      {  j = P_per[i];
 274.480 +         xassert(1 <= j && j <= n);
 274.481 +         xassert(P_per[n+j] == i);
 274.482 +      }
 274.483 +      /* free working arrays */
 274.484 +      xfree(xadj);
 274.485 +      xfree(adjncy);
 274.486 +      xfree(deg);
 274.487 +      xfree(marker);
 274.488 +      xfree(rchset);
 274.489 +      xfree(nbrhd);
 274.490 +      xfree(qsize);
 274.491 +      xfree(qlink);
 274.492 +      return;
 274.493 +}
 274.494 +
 274.495 +/**********************************************************************/
 274.496 +
 274.497 +void amd_order1(int n, int A_ptr[], int A_ind[], int P_per[])
 274.498 +{     /* approximate minimum degree ordering (AMD) */
 274.499 +      int k, ret;
 274.500 +      double Control[AMD_CONTROL], Info[AMD_INFO];
 274.501 +      /* get the default parameters */
 274.502 +      amd_defaults(Control);
 274.503 +#if 0
 274.504 +      /* and print them */
 274.505 +      amd_control(Control);
 274.506 +#endif
 274.507 +      /* make all indices 0-based */
 274.508 +      for (k = 1; k < A_ptr[n+1]; k++) A_ind[k]--;
 274.509 +      for (k = 1; k <= n+1; k++) A_ptr[k]--;
 274.510 +      /* call the ordering routine */
 274.511 +      ret = amd_order(n, &A_ptr[1], &A_ind[1], &P_per[1], Control, Info)
 274.512 +         ;
 274.513 +#if 0
 274.514 +      amd_info(Info);
 274.515 +#endif
 274.516 +      xassert(ret == AMD_OK || ret == AMD_OK_BUT_JUMBLED);
 274.517 +      /* retsore 1-based indices */
 274.518 +      for (k = 1; k <= n+1; k++) A_ptr[k]++;
 274.519 +      for (k = 1; k < A_ptr[n+1]; k++) A_ind[k]++;
 274.520 +      /* patch up permutation matrix */
 274.521 +      memset(&P_per[n+1], 0, n * sizeof(int));
 274.522 +      for (k = 1; k <= n; k++)
 274.523 +      {  P_per[k]++;
 274.524 +         xassert(1 <= P_per[k] && P_per[k] <= n);
 274.525 +         xassert(P_per[n+P_per[k]] == 0);
 274.526 +         P_per[n+P_per[k]] = k;
 274.527 +      }
 274.528 +      return;
 274.529 +}
 274.530 +
 274.531 +/**********************************************************************/
 274.532 +
 274.533 +static void *allocate(size_t n, size_t size)
 274.534 +{     void *ptr;
 274.535 +      ptr = xcalloc(n, size);
 274.536 +      memset(ptr, 0, n * size);
 274.537 +      return ptr;
 274.538 +}
 274.539 +
 274.540 +static void release(void *ptr)
 274.541 +{     xfree(ptr);
 274.542 +      return;
 274.543 +}
 274.544 +
 274.545 +void symamd_ord(int n, int A_ptr[], int A_ind[], int P_per[])
 274.546 +{     /* approximate minimum degree ordering (SYMAMD) */
 274.547 +      int k, ok;
 274.548 +      int stats[COLAMD_STATS];
 274.549 +      /* make all indices 0-based */
 274.550 +      for (k = 1; k < A_ptr[n+1]; k++) A_ind[k]--;
 274.551 +      for (k = 1; k <= n+1; k++) A_ptr[k]--;
 274.552 +      /* call the ordering routine */
 274.553 +      ok = symamd(n, &A_ind[1], &A_ptr[1], &P_per[1], NULL, stats,
 274.554 +         allocate, release);
 274.555 +#if 0
 274.556 +      symamd_report(stats);
 274.557 +#endif
 274.558 +      xassert(ok);
 274.559 +      /* restore 1-based indices */
 274.560 +      for (k = 1; k <= n+1; k++) A_ptr[k]++;
 274.561 +      for (k = 1; k < A_ptr[n+1]; k++) A_ind[k]++;
 274.562 +      /* patch up permutation matrix */
 274.563 +      memset(&P_per[n+1], 0, n * sizeof(int));
 274.564 +      for (k = 1; k <= n; k++)
 274.565 +      {  P_per[k]++;
 274.566 +         xassert(1 <= P_per[k] && P_per[k] <= n);
 274.567 +         xassert(P_per[n+P_per[k]] == 0);
 274.568 +         P_per[n+P_per[k]] = k;
 274.569 +      }
 274.570 +      return;
 274.571 +}
 274.572 +
 274.573 +/*----------------------------------------------------------------------
 274.574 +-- chol_symbolic - compute Cholesky factorization (symbolic phase).
 274.575 +--
 274.576 +-- *Synopsis*
 274.577 +--
 274.578 +-- #include "glpmat.h"
 274.579 +-- int *chol_symbolic(int n, int A_ptr[], int A_ind[], int U_ptr[]);
 274.580 +--
 274.581 +-- *Description*
 274.582 +--
 274.583 +-- The routine chol_symbolic implements the symbolic phase of Cholesky
 274.584 +-- factorization A = U'*U, where A is a given sparse symmetric positive
 274.585 +-- definite matrix, U is a resultant upper triangular factor, U' is a
 274.586 +-- matrix transposed to U.
 274.587 +--
 274.588 +-- The parameter n is the order of matrices A and U.
 274.589 +--
 274.590 +-- The pattern of the given matrix A is specified on entry in the arrays
 274.591 +-- A_ptr and A_ind in storage-by-rows format. Only the upper triangular
 274.592 +-- part without diagonal elements (which all are assumed to be non-zero)
 274.593 +-- should be specified as if A were upper triangular. The arrays A_ptr
 274.594 +-- and A_ind are not changed on exit.
 274.595 +--
 274.596 +-- The pattern of the matrix U without diagonal elements (which all are
 274.597 +-- assumed to be non-zero) is stored on exit from the routine in the
 274.598 +-- arrays U_ptr and U_ind in storage-by-rows format. The array U_ptr
 274.599 +-- should be allocated on entry, however, its content is ignored. The
 274.600 +-- array U_ind is allocated by the routine which returns a pointer to it
 274.601 +-- on exit.
 274.602 +--
 274.603 +-- *Returns*
 274.604 +--
 274.605 +-- The routine returns a pointer to the array U_ind.
 274.606 +--
 274.607 +-- *Method*
 274.608 +--
 274.609 +-- The routine chol_symbolic computes the pattern of the matrix U in a
 274.610 +-- row-wise manner. No pivoting is used.
 274.611 +--
 274.612 +-- It is known that to compute the pattern of row k of the matrix U we
 274.613 +-- need to merge the pattern of row k of the matrix A and the patterns
 274.614 +-- of each row i of U, where u[i,k] is non-zero (these rows are already
 274.615 +-- computed and placed above row k).
 274.616 +--
 274.617 +-- However, to reduce the number of rows to be merged the routine uses
 274.618 +-- an advanced algorithm proposed in:
 274.619 +--
 274.620 +-- D.J.Rose, R.E.Tarjan, and G.S.Lueker. Algorithmic aspects of vertex
 274.621 +-- elimination on graphs. SIAM J. Comput. 5, 1976, 266-83.
 274.622 +--
 274.623 +-- The authors of the cited paper show that we have the same result if
 274.624 +-- we merge row k of the matrix A and such rows of the matrix U (among
 274.625 +-- rows 1, ..., k-1) whose leftmost non-diagonal non-zero element is
 274.626 +-- placed in k-th column. This feature signficantly reduces the number
 274.627 +-- of rows to be merged, especially on the final steps, where rows of
 274.628 +-- the matrix U become quite dense.
 274.629 +--
 274.630 +-- To determine rows, which should be merged on k-th step, for a fixed
 274.631 +-- time the routine uses linked lists of row numbers of the matrix U.
 274.632 +-- Location head[k] contains the number of a first row, whose leftmost
 274.633 +-- non-diagonal non-zero element is placed in column k, and location
 274.634 +-- next[i] contains the number of a next row with the same property as
 274.635 +-- row i. */
 274.636 +
 274.637 +int *chol_symbolic(int n, int A_ptr[], int A_ind[], int U_ptr[])
 274.638 +{     int i, j, k, t, len, size, beg, end, min_j, *U_ind, *head, *next,
 274.639 +         *ind, *map, *temp;
 274.640 +      /* initially we assume that on computing the pattern of U fill-in
 274.641 +         will double the number of non-zeros in A */
 274.642 +      size = A_ptr[n+1] - 1;
 274.643 +      if (size < n) size = n;
 274.644 +      size += size;
 274.645 +      U_ind = xcalloc(1+size, sizeof(int));
 274.646 +      /* allocate and initialize working arrays */
 274.647 +      head = xcalloc(1+n, sizeof(int));
 274.648 +      for (i = 1; i <= n; i++) head[i] = 0;
 274.649 +      next = xcalloc(1+n, sizeof(int));
 274.650 +      ind = xcalloc(1+n, sizeof(int));
 274.651 +      map = xcalloc(1+n, sizeof(int));
 274.652 +      for (j = 1; j <= n; j++) map[j] = 0;
 274.653 +      /* compute the pattern of matrix U */
 274.654 +      U_ptr[1] = 1;
 274.655 +      for (k = 1; k <= n; k++)
 274.656 +      {  /* compute the pattern of k-th row of U, which is the union of
 274.657 +            k-th row of A and those rows of U (among 1, ..., k-1) whose
 274.658 +            leftmost non-diagonal non-zero is placed in k-th column */
 274.659 +         /* (ind) := (k-th row of A) */
 274.660 +         len = A_ptr[k+1] - A_ptr[k];
 274.661 +         memcpy(&ind[1], &A_ind[A_ptr[k]], len * sizeof(int));
 274.662 +         for (t = 1; t <= len; t++)
 274.663 +         {  j = ind[t];
 274.664 +            xassert(k < j && j <= n);
 274.665 +            map[j] = 1;
 274.666 +         }
 274.667 +         /* walk through rows of U whose leftmost non-diagonal non-zero
 274.668 +            is placed in k-th column */
 274.669 +         for (i = head[k]; i != 0; i = next[i])
 274.670 +         {  /* (ind) := (ind) union (i-th row of U) */
 274.671 +            beg = U_ptr[i], end = U_ptr[i+1];
 274.672 +            for (t = beg; t < end; t++)
 274.673 +            {  j = U_ind[t];
 274.674 +               if (j > k && !map[j]) ind[++len] = j, map[j] = 1;
 274.675 +            }
 274.676 +         }
 274.677 +         /* now (ind) is the pattern of k-th row of U */
 274.678 +         U_ptr[k+1] = U_ptr[k] + len;
 274.679 +         /* at least (U_ptr[k+1] - 1) locations should be available in
 274.680 +            the array U_ind */
 274.681 +         if (U_ptr[k+1] - 1 > size)
 274.682 +         {  temp = U_ind;
 274.683 +            size += size;
 274.684 +            U_ind = xcalloc(1+size, sizeof(int));
 274.685 +            memcpy(&U_ind[1], &temp[1], (U_ptr[k] - 1) * sizeof(int));
 274.686 +            xfree(temp);
 274.687 +         }
 274.688 +         xassert(U_ptr[k+1] - 1 <= size);
 274.689 +         /* (k-th row of U) := (ind) */
 274.690 +         memcpy(&U_ind[U_ptr[k]], &ind[1], len * sizeof(int));
 274.691 +         /* determine column index of leftmost non-diagonal non-zero in
 274.692 +            k-th row of U and clear the row pattern map */
 274.693 +         min_j = n + 1;
 274.694 +         for (t = 1; t <= len; t++)
 274.695 +         {  j = ind[t], map[j] = 0;
 274.696 +            if (min_j > j) min_j = j;
 274.697 +         }
 274.698 +         /* include k-th row into corresponding linked list */
 274.699 +         if (min_j <= n) next[k] = head[min_j], head[min_j] = k;
 274.700 +      }
 274.701 +      /* free working arrays */
 274.702 +      xfree(head);
 274.703 +      xfree(next);
 274.704 +      xfree(ind);
 274.705 +      xfree(map);
 274.706 +      /* reallocate the array U_ind to free unused locations */
 274.707 +      temp = U_ind;
 274.708 +      size = U_ptr[n+1] - 1;
 274.709 +      U_ind = xcalloc(1+size, sizeof(int));
 274.710 +      memcpy(&U_ind[1], &temp[1], size * sizeof(int));
 274.711 +      xfree(temp);
 274.712 +      return U_ind;
 274.713 +}
 274.714 +
 274.715 +/*----------------------------------------------------------------------
 274.716 +-- chol_numeric - compute Cholesky factorization (numeric phase).
 274.717 +--
 274.718 +-- *Synopsis*
 274.719 +--
 274.720 +-- #include "glpmat.h"
 274.721 +-- int chol_numeric(int n,
 274.722 +--    int A_ptr[], int A_ind[], double A_val[], double A_diag[],
 274.723 +--    int U_ptr[], int U_ind[], double U_val[], double U_diag[]);
 274.724 +--
 274.725 +-- *Description*
 274.726 +--
 274.727 +-- The routine chol_symbolic implements the numeric phase of Cholesky
 274.728 +-- factorization A = U'*U, where A is a given sparse symmetric positive
 274.729 +-- definite matrix, U is a resultant upper triangular factor, U' is a
 274.730 +-- matrix transposed to U.
 274.731 +--
 274.732 +-- The parameter n is the order of matrices A and U.
 274.733 +--
 274.734 +-- Upper triangular part of the matrix A without diagonal elements is
 274.735 +-- specified in the arrays A_ptr, A_ind, and A_val in storage-by-rows
 274.736 +-- format. Diagonal elements of A are specified in the array A_diag,
 274.737 +-- where A_diag[0] is not used, A_diag[i] = a[i,i] for i = 1, ..., n.
 274.738 +-- The arrays A_ptr, A_ind, A_val, and A_diag are not changed on exit.
 274.739 +--
 274.740 +-- The pattern of the matrix U without diagonal elements (previously
 274.741 +-- computed with the routine chol_symbolic) is specified in the arrays
 274.742 +-- U_ptr and U_ind, which are not changed on exit. Numeric values of
 274.743 +-- non-diagonal elements of U are stored in corresponding locations of
 274.744 +-- the array U_val, and values of diagonal elements of U are stored in
 274.745 +-- locations U_diag[1], ..., U_diag[n].
 274.746 +--
 274.747 +-- *Returns*
 274.748 +--
 274.749 +-- The routine returns the number of non-positive diagonal elements of
 274.750 +-- the matrix U which have been replaced by a huge positive number (see
 274.751 +-- the method description below). Zero return code means the matrix A
 274.752 +-- has been successfully factorized.
 274.753 +--
 274.754 +-- *Method*
 274.755 +--
 274.756 +-- The routine chol_numeric computes the matrix U in a row-wise manner
 274.757 +-- using standard gaussian elimination technique. No pivoting is used.
 274.758 +--
 274.759 +-- Initially the routine sets U = A, and before k-th elimination step
 274.760 +-- the matrix U is the following:
 274.761 +--
 274.762 +--       1       k         n
 274.763 +--    1  x x x x x x x x x x
 274.764 +--       . x x x x x x x x x
 274.765 +--       . . x x x x x x x x
 274.766 +--       . . . x x x x x x x
 274.767 +--    k  . . . . * * * * * *
 274.768 +--       . . . . * * * * * *
 274.769 +--       . . . . * * * * * *
 274.770 +--       . . . . * * * * * *
 274.771 +--       . . . . * * * * * *
 274.772 +--    n  . . . . * * * * * *
 274.773 +--
 274.774 +-- where 'x' are elements of already computed rows, '*' are elements of
 274.775 +-- the active submatrix. (Note that the lower triangular part of the
 274.776 +-- active submatrix being symmetric is not stored and diagonal elements
 274.777 +-- are stored separately in the array U_diag.)
 274.778 +--
 274.779 +-- The matrix A is assumed to be positive definite. However, if it is
 274.780 +-- close to semi-definite, on some elimination step a pivot u[k,k] may
 274.781 +-- happen to be non-positive due to round-off errors. In this case the
 274.782 +-- routine uses a technique proposed in:
 274.783 +--
 274.784 +-- S.J.Wright. The Cholesky factorization in interior-point and barrier
 274.785 +-- methods. Preprint MCS-P600-0596, Mathematics and Computer Science
 274.786 +-- Division, Argonne National Laboratory, Argonne, Ill., May 1996.
 274.787 +--
 274.788 +-- The routine just replaces non-positive u[k,k] by a huge positive
 274.789 +-- number. This involves non-diagonal elements in k-th row of U to be
 274.790 +-- close to zero that, in turn, involves k-th component of a solution
 274.791 +-- vector to be close to zero. Note, however, that this technique works
 274.792 +-- only if the system A*x = b is consistent. */
 274.793 +
 274.794 +int chol_numeric(int n,
 274.795 +      int A_ptr[], int A_ind[], double A_val[], double A_diag[],
 274.796 +      int U_ptr[], int U_ind[], double U_val[], double U_diag[])
 274.797 +{     int i, j, k, t, t1, beg, end, beg1, end1, count = 0;
 274.798 +      double ukk, uki, *work;
 274.799 +      work = xcalloc(1+n, sizeof(double));
 274.800 +      for (j = 1; j <= n; j++) work[j] = 0.0;
 274.801 +      /* U := (upper triangle of A) */
 274.802 +      /* note that the upper traingle of A is a subset of U */
 274.803 +      for (i = 1; i <= n; i++)
 274.804 +      {  beg = A_ptr[i], end = A_ptr[i+1];
 274.805 +         for (t = beg; t < end; t++)
 274.806 +            j = A_ind[t], work[j] = A_val[t];
 274.807 +         beg = U_ptr[i], end = U_ptr[i+1];
 274.808 +         for (t = beg; t < end; t++)
 274.809 +            j = U_ind[t], U_val[t] = work[j], work[j] = 0.0;
 274.810 +         U_diag[i] = A_diag[i];
 274.811 +      }
 274.812 +      /* main elimination loop */
 274.813 +      for (k = 1; k <= n; k++)
 274.814 +      {  /* transform k-th row of U */
 274.815 +         ukk = U_diag[k];
 274.816 +         if (ukk > 0.0)
 274.817 +            U_diag[k] = ukk = sqrt(ukk);
 274.818 +         else
 274.819 +            U_diag[k] = ukk = DBL_MAX, count++;
 274.820 +         /* (work) := (transformed k-th row) */
 274.821 +         beg = U_ptr[k], end = U_ptr[k+1];
 274.822 +         for (t = beg; t < end; t++)
 274.823 +            work[U_ind[t]] = (U_val[t] /= ukk);
 274.824 +         /* transform other rows of U */
 274.825 +         for (t = beg; t < end; t++)
 274.826 +         {  i = U_ind[t];
 274.827 +            xassert(i > k);
 274.828 +            /* (i-th row) := (i-th row) - u[k,i] * (k-th row) */
 274.829 +            uki = work[i];
 274.830 +            beg1 = U_ptr[i], end1 = U_ptr[i+1];
 274.831 +            for (t1 = beg1; t1 < end1; t1++)
 274.832 +               U_val[t1] -= uki * work[U_ind[t1]];
 274.833 +            U_diag[i] -= uki * uki;
 274.834 +         }
 274.835 +         /* (work) := 0 */
 274.836 +         for (t = beg; t < end; t++)
 274.837 +            work[U_ind[t]] = 0.0;
 274.838 +      }
 274.839 +      xfree(work);
 274.840 +      return count;
 274.841 +}
 274.842 +
 274.843 +/*----------------------------------------------------------------------
 274.844 +-- u_solve - solve upper triangular system U*x = b.
 274.845 +--
 274.846 +-- *Synopsis*
 274.847 +--
 274.848 +-- #include "glpmat.h"
 274.849 +-- void u_solve(int n, int U_ptr[], int U_ind[], double U_val[],
 274.850 +--    double U_diag[], double x[]);
 274.851 +--
 274.852 +-- *Description*
 274.853 +--
 274.854 +-- The routine u_solve solves an linear system U*x = b, where U is an
 274.855 +-- upper triangular matrix.
 274.856 +--
 274.857 +-- The parameter n is the order of matrix U.
 274.858 +--
 274.859 +-- The matrix U without diagonal elements is specified in the arrays
 274.860 +-- U_ptr, U_ind, and U_val in storage-by-rows format. Diagonal elements
 274.861 +-- of U are specified in the array U_diag, where U_diag[0] is not used,
 274.862 +-- U_diag[i] = u[i,i] for i = 1, ..., n. All these four arrays are not
 274.863 +-- changed on exit.
 274.864 +--
 274.865 +-- The right-hand side vector b is specified on entry in the array x,
 274.866 +-- where x[0] is not used, and x[i] = b[i] for i = 1, ..., n. On exit
 274.867 +-- the routine stores computed components of the vector of unknowns x
 274.868 +-- in the array x in the same manner. */
 274.869 +
 274.870 +void u_solve(int n, int U_ptr[], int U_ind[], double U_val[],
 274.871 +      double U_diag[], double x[])
 274.872 +{     int i, t, beg, end;
 274.873 +      double temp;
 274.874 +      for (i = n; i >= 1; i--)
 274.875 +      {  temp = x[i];
 274.876 +         beg = U_ptr[i], end = U_ptr[i+1];
 274.877 +         for (t = beg; t < end; t++)
 274.878 +            temp -= U_val[t] * x[U_ind[t]];
 274.879 +         xassert(U_diag[i] != 0.0);
 274.880 +         x[i] = temp / U_diag[i];
 274.881 +      }
 274.882 +      return;
 274.883 +}
 274.884 +
 274.885 +/*----------------------------------------------------------------------
 274.886 +-- ut_solve - solve lower triangular system U'*x = b.
 274.887 +--
 274.888 +-- *Synopsis*
 274.889 +--
 274.890 +-- #include "glpmat.h"
 274.891 +-- void ut_solve(int n, int U_ptr[], int U_ind[], double U_val[],
 274.892 +--    double U_diag[], double x[]);
 274.893 +--
 274.894 +-- *Description*
 274.895 +--
 274.896 +-- The routine ut_solve solves an linear system U'*x = b, where U is a
 274.897 +-- matrix transposed to an upper triangular matrix.
 274.898 +--
 274.899 +-- The parameter n is the order of matrix U.
 274.900 +--
 274.901 +-- The matrix U without diagonal elements is specified in the arrays
 274.902 +-- U_ptr, U_ind, and U_val in storage-by-rows format. Diagonal elements
 274.903 +-- of U are specified in the array U_diag, where U_diag[0] is not used,
 274.904 +-- U_diag[i] = u[i,i] for i = 1, ..., n. All these four arrays are not
 274.905 +-- changed on exit.
 274.906 +--
 274.907 +-- The right-hand side vector b is specified on entry in the array x,
 274.908 +-- where x[0] is not used, and x[i] = b[i] for i = 1, ..., n. On exit
 274.909 +-- the routine stores computed components of the vector of unknowns x
 274.910 +-- in the array x in the same manner. */
 274.911 +
 274.912 +void ut_solve(int n, int U_ptr[], int U_ind[], double U_val[],
 274.913 +      double U_diag[], double x[])
 274.914 +{     int i, t, beg, end;
 274.915 +      double temp;
 274.916 +      for (i = 1; i <= n; i++)
 274.917 +      {  xassert(U_diag[i] != 0.0);
 274.918 +         temp = (x[i] /= U_diag[i]);
 274.919 +         if (temp == 0.0) continue;
 274.920 +         beg = U_ptr[i], end = U_ptr[i+1];
 274.921 +         for (t = beg; t < end; t++)
 274.922 +            x[U_ind[t]] -= U_val[t] * temp;
 274.923 +      }
 274.924 +      return;
 274.925 +}
 274.926 +
 274.927 +/* eof */
   275.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
   275.2 +++ b/deps/glpk/src/glpmat.h	Sun Nov 06 20:59:10 2011 +0100
   275.3 @@ -0,0 +1,198 @@
   275.4 +/* glpmat.h (linear algebra routines) */
   275.5 +
   275.6 +/***********************************************************************
   275.7 +*  This code is part of GLPK (GNU Linear Programming Kit).
   275.8 +*
   275.9 +*  Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008,
  275.10 +*  2009, 2010, 2011 Andrew Makhorin, Department for Applied Informatics,
  275.11 +*  Moscow Aviation Institute, Moscow, Russia. All rights reserved.
  275.12 +*  E-mail: <mao@gnu.org>.
  275.13 +*
  275.14 +*  GLPK is free software: you can redistribute it and/or modify it
  275.15 +*  under the terms of the GNU General Public License as published by
  275.16 +*  the Free Software Foundation, either version 3 of the License, or
  275.17 +*  (at your option) any later version.
  275.18 +*
  275.19 +*  GLPK is distributed in the hope that it will be useful, but WITHOUT
  275.20 +*  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
  275.21 +*  or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
  275.22 +*  License for more details.
  275.23 +*
  275.24 +*  You should have received a copy of the GNU General Public License
  275.25 +*  along with GLPK. If not, see <http://www.gnu.org/licenses/>.
  275.26 +***********************************************************************/
  275.27 +
  275.28 +#ifndef GLPMAT_H
  275.29 +#define GLPMAT_H
  275.30 +
  275.31 +/***********************************************************************
  275.32 +*  FULL-VECTOR STORAGE
  275.33 +* 
  275.34 +*  For a sparse vector x having n elements, ne of which are non-zero,
  275.35 +*  the full-vector storage format uses two arrays x_ind and x_vec, which
  275.36 +*  are set up as follows:
  275.37 +* 
  275.38 +*  x_ind is an integer array of length [1+ne]. Location x_ind[0] is
  275.39 +*  not used, and locations x_ind[1], ..., x_ind[ne] contain indices of
  275.40 +*  non-zero elements in vector x.
  275.41 +* 
  275.42 +*  x_vec is a floating-point array of length [1+n]. Location x_vec[0]
  275.43 +*  is not used, and locations x_vec[1], ..., x_vec[n] contain numeric
  275.44 +*  values of ALL elements in vector x, including its zero elements.
  275.45 +* 
  275.46 +*  Let, for example, the following sparse vector x be given:
  275.47 +* 
  275.48 +*     (0, 1, 0, 0, 2, 3, 0, 4)
  275.49 +* 
  275.50 +*  Then the arrays are:
  275.51 +* 
  275.52 +*     x_ind = { X; 2, 5, 6, 8 }
  275.53 +* 
  275.54 +*     x_vec = { X; 0, 1, 0, 0, 2, 3, 0, 4 }
  275.55 +* 
  275.56 +*  COMPRESSED-VECTOR STORAGE
  275.57 +* 
  275.58 +*  For a sparse vector x having n elements, ne of which are non-zero,
  275.59 +*  the compressed-vector storage format uses two arrays x_ind and x_vec,
  275.60 +*  which are set up as follows:
  275.61 +* 
  275.62 +*  x_ind is an integer array of length [1+ne]. Location x_ind[0] is
  275.63 +*  not used, and locations x_ind[1], ..., x_ind[ne] contain indices of
  275.64 +*  non-zero elements in vector x.
  275.65 +* 
  275.66 +*  x_vec is a floating-point array of length [1+ne]. Location x_vec[0]
  275.67 +*  is not used, and locations x_vec[1], ..., x_vec[ne] contain numeric
  275.68 +*  values of corresponding non-zero elements in vector x.
  275.69 +* 
  275.70 +*  Let, for example, the following sparse vector x be given:
  275.71 +* 
  275.72 +*     (0, 1, 0, 0, 2, 3, 0, 4)
  275.73 +* 
  275.74 +*  Then the arrays are:
  275.75 +*
  275.76 +*     x_ind = { X; 2, 5, 6, 8 }
  275.77 +* 
  275.78 +*     x_vec = { X; 1, 2, 3, 4 }
  275.79 +* 
  275.80 +*  STORAGE-BY-ROWS
  275.81 +* 
  275.82 +*  For a sparse matrix A, which has m rows, n columns, and ne non-zero
  275.83 +*  elements the storage-by-rows format uses three arrays A_ptr, A_ind,
  275.84 +*  and A_val, which are set up as follows:
  275.85 +* 
  275.86 +*  A_ptr is an integer array of length [1+m+1] also called "row pointer
  275.87 +*  array". It contains the relative starting positions of each row of A
  275.88 +*  in the arrays A_ind and A_val, i.e. element A_ptr[i], 1 <= i <= m,
  275.89 +*  indicates where row i begins in the arrays A_ind and A_val. If all
  275.90 +*  elements in row i are zero, then A_ptr[i] = A_ptr[i+1]. Location
  275.91 +*  A_ptr[0] is not used, location A_ptr[1] must contain 1, and location
  275.92 +*  A_ptr[m+1] must contain ne+1 that indicates the position after the
  275.93 +*  last element in the arrays A_ind and A_val.
  275.94 +* 
  275.95 +*  A_ind is an integer array of length [1+ne]. Location A_ind[0] is not
  275.96 +*  used, and locations A_ind[1], ..., A_ind[ne] contain column indices
  275.97 +*  of (non-zero) elements in matrix A.
  275.98 +*
  275.99 +*  A_val is a floating-point array of length [1+ne]. Location A_val[0]
 275.100 +*  is not used, and locations A_val[1], ..., A_val[ne] contain numeric
 275.101 +*  values of non-zero elements in matrix A.
 275.102 +* 
 275.103 +*  Non-zero elements of matrix A are stored contiguously, and the rows
 275.104 +*  of matrix A are stored consecutively from 1 to m in the arrays A_ind
 275.105 +*  and A_val. The elements in each row of A may be stored in any order
 275.106 +*  in A_ind and A_val. Note that elements with duplicate column indices
 275.107 +*  are not allowed.
 275.108 +* 
 275.109 +*  Let, for example, the following sparse matrix A be given:
 275.110 +* 
 275.111 +*     | 11  . 13  .  .  . |
 275.112 +*     | 21 22  . 24  .  . |
 275.113 +*     |  . 32 33  .  .  . |
 275.114 +*     |  .  . 43 44  . 46 |
 275.115 +*     |  .  .  .  .  .  . |
 275.116 +*     | 61 62  .  .  . 66 |
 275.117 +* 
 275.118 +*  Then the arrays are:
 275.119 +* 
 275.120 +*     A_ptr = { X; 1, 3, 6, 8, 11, 11; 14 }
 275.121 +*
 275.122 +*     A_ind = { X;  1,  3;  4,  2,  1;  2,  3;  4,  3,  6;  1,  2,  6 }
 275.123 +* 
 275.124 +*     A_val = { X; 11, 13; 24, 22, 21; 32, 33; 44, 43, 46; 61, 62, 66 }
 275.125 +* 
 275.126 +*  PERMUTATION MATRICES
 275.127 +* 
 275.128 +*  Let P be a permutation matrix of the order n. It is represented as
 275.129 +*  an integer array P_per of length [1+n+n] as follows: if p[i,j] = 1,
 275.130 +*  then P_per[i] = j and P_per[n+j] = i. Location P_per[0] is not used.
 275.131 +* 
 275.132 +*  Let A' = P*A. If i-th row of A corresponds to i'-th row of A', then
 275.133 +*  P_per[i'] = i and P_per[n+i] = i'.
 275.134 +* 
 275.135 +*  References:
 275.136 +* 
 275.137 +*  1. Gustavson F.G. Some basic techniques for solving sparse systems of
 275.138 +*     linear equations. In Rose and Willoughby (1972), pp. 41-52.
 275.139 +* 
 275.140 +*  2. Basic Linear Algebra Subprograms Technical (BLAST) Forum Standard.
 275.141 +*     University of Tennessee (2001). */
 275.142 +
 275.143 +#define check_fvs _glp_mat_check_fvs
 275.144 +int check_fvs(int n, int nnz, int ind[], double vec[]);
 275.145 +/* check sparse vector in full-vector storage format */
 275.146 +
 275.147 +#define check_pattern _glp_mat_check_pattern
 275.148 +int check_pattern(int m, int n, int A_ptr[], int A_ind[]);
 275.149 +/* check pattern of sparse matrix */
 275.150 +
 275.151 +#define transpose _glp_mat_transpose
 275.152 +void transpose(int m, int n, int A_ptr[], int A_ind[], double A_val[],
 275.153 +      int AT_ptr[], int AT_ind[], double AT_val[]);
 275.154 +/* transpose sparse matrix */
 275.155 +
 275.156 +#define adat_symbolic _glp_mat_adat_symbolic
 275.157 +int *adat_symbolic(int m, int n, int P_per[], int A_ptr[], int A_ind[],
 275.158 +      int S_ptr[]);
 275.159 +/* compute S = P*A*D*A'*P' (symbolic phase) */
 275.160 +
 275.161 +#define adat_numeric _glp_mat_adat_numeric
 275.162 +void adat_numeric(int m, int n, int P_per[],
 275.163 +      int A_ptr[], int A_ind[], double A_val[], double D_diag[],
 275.164 +      int S_ptr[], int S_ind[], double S_val[], double S_diag[]);
 275.165 +/* compute S = P*A*D*A'*P' (numeric phase) */
 275.166 +
 275.167 +#define min_degree _glp_mat_min_degree
 275.168 +void min_degree(int n, int A_ptr[], int A_ind[], int P_per[]);
 275.169 +/* minimum degree ordering */
 275.170 +
 275.171 +#define amd_order1 _glp_mat_amd_order1
 275.172 +void amd_order1(int n, int A_ptr[], int A_ind[], int P_per[]);
 275.173 +/* approximate minimum degree ordering (AMD) */
 275.174 +
 275.175 +#define symamd_ord _glp_mat_symamd_ord
 275.176 +void symamd_ord(int n, int A_ptr[], int A_ind[], int P_per[]);
 275.177 +/* approximate minimum degree ordering (SYMAMD) */
 275.178 +
 275.179 +#define chol_symbolic _glp_mat_chol_symbolic
 275.180 +int *chol_symbolic(int n, int A_ptr[], int A_ind[], int U_ptr[]);
 275.181 +/* compute Cholesky factorization (symbolic phase) */
 275.182 +
 275.183 +#define chol_numeric _glp_mat_chol_numeric
 275.184 +int chol_numeric(int n,
 275.185 +      int A_ptr[], int A_ind[], double A_val[], double A_diag[],
 275.186 +      int U_ptr[], int U_ind[], double U_val[], double U_diag[]);
 275.187 +/* compute Cholesky factorization (numeric phase) */
 275.188 +
 275.189 +#define u_solve _glp_mat_u_solve
 275.190 +void u_solve(int n, int U_ptr[], int U_ind[], double U_val[],
 275.191 +      double U_diag[], double x[]);
 275.192 +/* solve upper triangular system U*x = b */
 275.193 +
 275.194 +#define ut_solve _glp_mat_ut_solve
 275.195 +void ut_solve(int n, int U_ptr[], int U_ind[], double U_val[],
 275.196 +      double U_diag[], double x[]);
 275.197 +/* solve lower triangular system U'*x = b */
 275.198 +
 275.199 +#endif
 275.200 +
 275.201 +/* eof */
   276.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
   276.2 +++ b/deps/glpk/src/glpmpl.h	Sun Nov 06 20:59:10 2011 +0100
   276.3 @@ -0,0 +1,2583 @@
   276.4 +/* glpmpl.h (GNU MathProg translator) */
   276.5 +
   276.6 +/***********************************************************************
   276.7 +*  This code is part of GLPK (GNU Linear Programming Kit).
   276.8 +*
   276.9 +*  Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008,
  276.10 +*  2009, 2010, 2011 Andrew Makhorin, Department for Applied Informatics,
  276.11 +*  Moscow Aviation Institute, Moscow, Russia. All rights reserved.
  276.12 +*  E-mail: <mao@gnu.org>.
  276.13 +*
  276.14 +*  GLPK is free software: you can redistribute it and/or modify it
  276.15 +*  under the terms of the GNU General Public License as published by
  276.16 +*  the Free Software Foundation, either version 3 of the License, or
  276.17 +*  (at your option) any later version.
  276.18 +*
  276.19 +*  GLPK is distributed in the hope that it will be useful, but WITHOUT
  276.20 +*  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
  276.21 +*  or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
  276.22 +*  License for more details.
  276.23 +*
  276.24 +*  You should have received a copy of the GNU General Public License
  276.25 +*  along with GLPK. If not, see <http://www.gnu.org/licenses/>.
  276.26 +***********************************************************************/
  276.27 +
  276.28 +#ifndef GLPMPL_H
  276.29 +#define GLPMPL_H
  276.30 +
  276.31 +#include "glpavl.h"
  276.32 +#include "glprng.h"
  276.33 +
  276.34 +typedef struct MPL MPL;
  276.35 +typedef char STRING;
  276.36 +typedef struct SYMBOL SYMBOL;
  276.37 +typedef struct TUPLE TUPLE;
  276.38 +typedef struct ARRAY ELEMSET;
  276.39 +typedef struct ELEMVAR ELEMVAR;
  276.40 +typedef struct FORMULA FORMULA;
  276.41 +typedef struct ELEMCON ELEMCON;
  276.42 +typedef union VALUE VALUE;
  276.43 +typedef struct ARRAY ARRAY;
  276.44 +typedef struct MEMBER MEMBER;
  276.45 +#if 1
  276.46 +/* many C compilers have DOMAIN declared in <math.h> :( */
  276.47 +#undef DOMAIN
  276.48 +#define DOMAIN DOMAIN1
  276.49 +#endif
  276.50 +typedef struct DOMAIN DOMAIN;
  276.51 +typedef struct DOMAIN_BLOCK DOMAIN_BLOCK;
  276.52 +typedef struct DOMAIN_SLOT DOMAIN_SLOT;
  276.53 +typedef struct SET SET;
  276.54 +typedef struct WITHIN WITHIN;
  276.55 +typedef struct GADGET GADGET;
  276.56 +typedef struct PARAMETER PARAMETER;
  276.57 +typedef struct CONDITION CONDITION;
  276.58 +typedef struct VARIABLE VARIABLE;
  276.59 +typedef struct CONSTRAINT CONSTRAINT;
  276.60 +typedef struct TABLE TABLE;
  276.61 +typedef struct TABARG TABARG;
  276.62 +typedef struct TABFLD TABFLD;
  276.63 +typedef struct TABIN TABIN;
  276.64 +typedef struct TABOUT TABOUT;
  276.65 +typedef struct TABDCA TABDCA;
  276.66 +typedef union OPERANDS OPERANDS;
  276.67 +typedef struct ARG_LIST ARG_LIST;
  276.68 +typedef struct CODE CODE;
  276.69 +typedef struct CHECK CHECK;
  276.70 +typedef struct DISPLAY DISPLAY;
  276.71 +typedef struct DISPLAY1 DISPLAY1;
  276.72 +typedef struct PRINTF PRINTF;
  276.73 +typedef struct PRINTF1 PRINTF1;
  276.74 +typedef struct FOR FOR;
  276.75 +typedef struct STATEMENT STATEMENT;
  276.76 +typedef struct TUPLE SLICE;
  276.77 +
  276.78 +/**********************************************************************/
  276.79 +/* * *                    TRANSLATOR DATABASE                     * * */
  276.80 +/**********************************************************************/
  276.81 +
  276.82 +#define A_BINARY        101   /* something binary */
  276.83 +#define A_CHECK         102   /* check statement */
  276.84 +#define A_CONSTRAINT    103   /* model constraint */
  276.85 +#define A_DISPLAY       104   /* display statement */
  276.86 +#define A_ELEMCON       105   /* elemental constraint/objective */
  276.87 +#define A_ELEMSET       106   /* elemental set */
  276.88 +#define A_ELEMVAR       107   /* elemental variable */
  276.89 +#define A_EXPRESSION    108   /* expression */
  276.90 +#define A_FOR           109   /* for statement */
  276.91 +#define A_FORMULA       110   /* formula */
  276.92 +#define A_INDEX         111   /* dummy index */
  276.93 +#define A_INPUT         112   /* input table */
  276.94 +#define A_INTEGER       113   /* something integer */
  276.95 +#define A_LOGICAL       114   /* something logical */
  276.96 +#define A_MAXIMIZE      115   /* objective has to be maximized */
  276.97 +#define A_MINIMIZE      116   /* objective has to be minimized */
  276.98 +#define A_NONE          117   /* nothing */
  276.99 +#define A_NUMERIC       118   /* something numeric */
 276.100 +#define A_OUTPUT        119   /* output table */
 276.101 +#define A_PARAMETER     120   /* model parameter */
 276.102 +#define A_PRINTF        121   /* printf statement */
 276.103 +#define A_SET           122   /* model set */
 276.104 +#define A_SOLVE         123   /* solve statement */
 276.105 +#define A_SYMBOLIC      124   /* something symbolic */
 276.106 +#define A_TABLE         125   /* data table */
 276.107 +#define A_TUPLE         126   /* n-tuple */
 276.108 +#define A_VARIABLE      127   /* model variable */
 276.109 +
 276.110 +#define MAX_LENGTH 100
 276.111 +/* maximal length of any symbolic value (this includes symbolic names,
 276.112 +   numeric and string literals, and all symbolic values that may appear
 276.113 +   during the evaluation phase) */
 276.114 +
 276.115 +#define CONTEXT_SIZE 60
 276.116 +/* size of the context queue, in characters */
 276.117 +
 276.118 +#define OUTBUF_SIZE 1024
 276.119 +/* size of the output buffer, in characters */
 276.120 +
 276.121 +struct MPL
 276.122 +{     /* translator database */
 276.123 +      /*--------------------------------------------------------------*/
 276.124 +      /* scanning segment */
 276.125 +      int line;
 276.126 +      /* number of the current text line */
 276.127 +      int c;
 276.128 +      /* the current character or EOF */
 276.129 +      int token;
 276.130 +      /* the current token: */
 276.131 +#define T_EOF           201   /* end of file */
 276.132 +#define T_NAME          202   /* symbolic name (model section only) */
 276.133 +#define T_SYMBOL        203   /* symbol (data section only) */
 276.134 +#define T_NUMBER        204   /* numeric literal */
 276.135 +#define T_STRING        205   /* string literal */
 276.136 +#define T_AND           206   /* and && */
 276.137 +#define T_BY            207   /* by */
 276.138 +#define T_CROSS         208   /* cross */
 276.139 +#define T_DIFF          209   /* diff */
 276.140 +#define T_DIV           210   /* div */
 276.141 +#define T_ELSE          211   /* else */
 276.142 +#define T_IF            212   /* if */
 276.143 +#define T_IN            213   /* in */
 276.144 +#define T_INFINITY      214   /* Infinity */
 276.145 +#define T_INTER         215   /* inter */
 276.146 +#define T_LESS          216   /* less */
 276.147 +#define T_MOD           217   /* mod */
 276.148 +#define T_NOT           218   /* not ! */
 276.149 +#define T_OR            219   /* or || */
 276.150 +#define T_SPTP          220   /* s.t. */
 276.151 +#define T_SYMDIFF       221   /* symdiff */
 276.152 +#define T_THEN          222   /* then */
 276.153 +#define T_UNION         223   /* union */
 276.154 +#define T_WITHIN        224   /* within */
 276.155 +#define T_PLUS          225   /* + */
 276.156 +#define T_MINUS         226   /* - */
 276.157 +#define T_ASTERISK      227   /* * */
 276.158 +#define T_SLASH         228   /* / */
 276.159 +#define T_POWER         229   /* ^ ** */
 276.160 +#define T_LT            230   /* <  */
 276.161 +#define T_LE            231   /* <= */
 276.162 +#define T_EQ            232   /* = == */
 276.163 +#define T_GE            233   /* >= */
 276.164 +#define T_GT            234   /* >  */
 276.165 +#define T_NE            235   /* <> != */
 276.166 +#define T_CONCAT        236   /* & */
 276.167 +#define T_BAR           237   /* | */
 276.168 +#define T_POINT         238   /* . */
 276.169 +#define T_COMMA         239   /* , */
 276.170 +#define T_COLON         240   /* : */
 276.171 +#define T_SEMICOLON     241   /* ; */
 276.172 +#define T_ASSIGN        242   /* := */
 276.173 +#define T_DOTS          243   /* .. */
 276.174 +#define T_LEFT          244   /* ( */
 276.175 +#define T_RIGHT         245   /* ) */
 276.176 +#define T_LBRACKET      246   /* [ */
 276.177 +#define T_RBRACKET      247   /* ] */
 276.178 +#define T_LBRACE        248   /* { */
 276.179 +#define T_RBRACE        249   /* } */
 276.180 +#define T_APPEND        250   /* >> */
 276.181 +#define T_TILDE         251   /* ~ */
 276.182 +#define T_INPUT         252   /* <- */
 276.183 +      int imlen;
 276.184 +      /* length of the current token */
 276.185 +      char *image; /* char image[MAX_LENGTH+1]; */
 276.186 +      /* image of the current token */
 276.187 +      double value;
 276.188 +      /* value of the current token (for T_NUMBER only) */
 276.189 +      int b_token;
 276.190 +      /* the previous token */
 276.191 +      int b_imlen;
 276.192 +      /* length of the previous token */
 276.193 +      char *b_image; /* char b_image[MAX_LENGTH+1]; */
 276.194 +      /* image of the previous token */
 276.195 +      double b_value;
 276.196 +      /* value of the previous token (if token is T_NUMBER) */
 276.197 +      int f_dots;
 276.198 +      /* if this flag is set, the next token should be recognized as
 276.199 +         T_DOTS, not as T_POINT */
 276.200 +      int f_scan;
 276.201 +      /* if this flag is set, the next token is already scanned */
 276.202 +      int f_token;
 276.203 +      /* the next token */
 276.204 +      int f_imlen;
 276.205 +      /* length of the next token */
 276.206 +      char *f_image; /* char f_image[MAX_LENGTH+1]; */
 276.207 +      /* image of the next token */
 276.208 +      double f_value;
 276.209 +      /* value of the next token (if token is T_NUMBER) */
 276.210 +      char *context; /* char context[CONTEXT_SIZE]; */
 276.211 +      /* context circular queue (not null-terminated!) */
 276.212 +      int c_ptr;
 276.213 +      /* pointer to the current position in the context queue */
 276.214 +      int flag_d;
 276.215 +      /* if this flag is set, the data section is being processed */
 276.216 +      /*--------------------------------------------------------------*/
 276.217 +      /* translating segment */
 276.218 +      DMP *pool;
 276.219 +      /* memory pool used to allocate all data instances created during
 276.220 +         the translation phase */
 276.221 +      AVL *tree;
 276.222 +      /* symbolic name table:
 276.223 +         node.type = A_INDEX     => node.link -> DOMAIN_SLOT
 276.224 +         node.type = A_SET       => node.link -> SET
 276.225 +         node.type = A_PARAMETER => node.link -> PARAMETER
 276.226 +         node.type = A_VARIABLE  => node.link -> VARIABLE
 276.227 +         node.type = A_CONSTRANT => node.link -> CONSTRAINT */
 276.228 +      STATEMENT *model;
 276.229 +      /* linked list of model statements in the original order */
 276.230 +      int flag_x;
 276.231 +      /* if this flag is set, the current token being left parenthesis
 276.232 +         begins a slice that allows recognizing any undeclared symbolic
 276.233 +         names as dummy indices; this flag is automatically reset once
 276.234 +         the next token has been scanned */
 276.235 +      int as_within;
 276.236 +      /* the warning "in understood as within" has been issued */
 276.237 +      int as_in;
 276.238 +      /* the warning "within understood as in" has been issued */
 276.239 +      int as_binary;
 276.240 +      /* the warning "logical understood as binary" has been issued */
 276.241 +      int flag_s;
 276.242 +      /* if this flag is set, the solve statement has been parsed */
 276.243 +      /*--------------------------------------------------------------*/
 276.244 +      /* common segment */
 276.245 +      DMP *strings;
 276.246 +      /* memory pool to allocate STRING data structures */
 276.247 +      DMP *symbols;
 276.248 +      /* memory pool to allocate SYMBOL data structures */
 276.249 +      DMP *tuples;
 276.250 +      /* memory pool to allocate TUPLE data structures */
 276.251 +      DMP *arrays;
 276.252 +      /* memory pool to allocate ARRAY data structures */
 276.253 +      DMP *members;
 276.254 +      /* memory pool to allocate MEMBER data structures */
 276.255 +      DMP *elemvars;
 276.256 +      /* memory pool to allocate ELEMVAR data structures */
 276.257 +      DMP *formulae;
 276.258 +      /* memory pool to allocate FORMULA data structures */
 276.259 +      DMP *elemcons;
 276.260 +      /* memory pool to allocate ELEMCON data structures */
 276.261 +      ARRAY *a_list;
 276.262 +      /* linked list of all arrays in the database */
 276.263 +      char *sym_buf; /* char sym_buf[255+1]; */
 276.264 +      /* working buffer used by the routine format_symbol */
 276.265 +      char *tup_buf; /* char tup_buf[255+1]; */
 276.266 +      /* working buffer used by the routine format_tuple */
 276.267 +      /*--------------------------------------------------------------*/
 276.268 +      /* generating/postsolving segment */
 276.269 +      RNG *rand;
 276.270 +      /* pseudo-random number generator */
 276.271 +      int flag_p;
 276.272 +      /* if this flag is set, the postsolving phase is in effect */
 276.273 +      STATEMENT *stmt;
 276.274 +      /* model statement being currently executed */
 276.275 +      TABDCA *dca;
 276.276 +      /* pointer to table driver communication area for table statement
 276.277 +         currently executed */
 276.278 +      int m;
 276.279 +      /* number of rows in the problem, m >= 0 */
 276.280 +      int n;
 276.281 +      /* number of columns in the problem, n >= 0 */
 276.282 +      ELEMCON **row; /* ELEMCON *row[1+m]; */
 276.283 +      /* row[0] is not used;
 276.284 +         row[i] is elemental constraint or objective, which corresponds
 276.285 +         to i-th row of the problem, 1 <= i <= m */
 276.286 +      ELEMVAR **col; /* ELEMVAR *col[1+n]; */
 276.287 +      /* col[0] is not used;
 276.288 +         col[j] is elemental variable, which corresponds to j-th column
 276.289 +         of the problem, 1 <= j <= n */
 276.290 +      /*--------------------------------------------------------------*/
 276.291 +      /* input/output segment */
 276.292 +      XFILE *in_fp;
 276.293 +      /* stream assigned to the input text file */
 276.294 +      char *in_file;
 276.295 +      /* name of the input text file */
 276.296 +      XFILE *out_fp;
 276.297 +      /* stream assigned to the output text file used to write all data
 276.298 +         produced by display and printf statements; NULL means the data
 276.299 +         should be sent to stdout via the routine xprintf */
 276.300 +      char *out_file;
 276.301 +      /* name of the output text file */
 276.302 +#if 0 /* 08/XI-2009 */
 276.303 +      char *out_buf; /* char out_buf[OUTBUF_SIZE] */
 276.304 +      /* buffer to accumulate output data */
 276.305 +      int out_cnt;
 276.306 +      /* count of data bytes stored in the output buffer */
 276.307 +#endif
 276.308 +      XFILE *prt_fp;
 276.309 +      /* stream assigned to the print text file; may be NULL */
 276.310 +      char *prt_file;
 276.311 +      /* name of the output print file */
 276.312 +      /*--------------------------------------------------------------*/
 276.313 +      /* solver interface segment */
 276.314 +      jmp_buf jump;
 276.315 +      /* jump address for non-local go to in case of error */
 276.316 +      int phase;
 276.317 +      /* phase of processing:
 276.318 +         0 - database is being or has been initialized
 276.319 +         1 - model section is being or has been read
 276.320 +         2 - data section is being or has been read
 276.321 +         3 - model is being or has been generated/postsolved
 276.322 +         4 - model processing error has occurred */
 276.323 +      char *mod_file;
 276.324 +      /* name of the input text file, which contains model section */
 276.325 +      char *mpl_buf; /* char mpl_buf[255+1]; */
 276.326 +      /* working buffer used by some interface routines */
 276.327 +};
 276.328 +
 276.329 +/**********************************************************************/
 276.330 +/* * *                  PROCESSING MODEL SECTION                  * * */
 276.331 +/**********************************************************************/
 276.332 +
 276.333 +#define alloc(type) ((type *)dmp_get_atomv(mpl->pool, sizeof(type)))
 276.334 +/* allocate atom of given type */
 276.335 +
 276.336 +#define enter_context _glp_mpl_enter_context
 276.337 +void enter_context(MPL *mpl);
 276.338 +/* enter current token into context queue */
 276.339 +
 276.340 +#define print_context _glp_mpl_print_context
 276.341 +void print_context(MPL *mpl);
 276.342 +/* print current content of context queue */
 276.343 +
 276.344 +#define get_char _glp_mpl_get_char
 276.345 +void get_char(MPL *mpl);
 276.346 +/* scan next character from input text file */
 276.347 +
 276.348 +#define append_char _glp_mpl_append_char
 276.349 +void append_char(MPL *mpl);
 276.350 +/* append character to current token */
 276.351 +
 276.352 +#define get_token _glp_mpl_get_token
 276.353 +void get_token(MPL *mpl);
 276.354 +/* scan next token from input text file */
 276.355 +
 276.356 +#define unget_token _glp_mpl_unget_token
 276.357 +void unget_token(MPL *mpl);
 276.358 +/* return current token back to input stream */
 276.359 +
 276.360 +#define is_keyword _glp_mpl_is_keyword
 276.361 +int is_keyword(MPL *mpl, char *keyword);
 276.362 +/* check if current token is given non-reserved keyword */
 276.363 +
 276.364 +#define is_reserved _glp_mpl_is_reserved
 276.365 +int is_reserved(MPL *mpl);
 276.366 +/* check if current token is reserved keyword */
 276.367 +
 276.368 +#define make_code _glp_mpl_make_code
 276.369 +CODE *make_code(MPL *mpl, int op, OPERANDS *arg, int type, int dim);
 276.370 +/* generate pseudo-code (basic routine) */
 276.371 +
 276.372 +#define make_unary _glp_mpl_make_unary
 276.373 +CODE *make_unary(MPL *mpl, int op, CODE *x, int type, int dim);
 276.374 +/* generate pseudo-code for unary operation */
 276.375 +
 276.376 +#define make_binary _glp_mpl_make_binary
 276.377 +CODE *make_binary(MPL *mpl, int op, CODE *x, CODE *y, int type,
 276.378 +      int dim);
 276.379 +/* generate pseudo-code for binary operation */
 276.380 +
 276.381 +#define make_ternary _glp_mpl_make_ternary
 276.382 +CODE *make_ternary(MPL *mpl, int op, CODE *x, CODE *y, CODE *z,
 276.383 +      int type, int dim);
 276.384 +/* generate pseudo-code for ternary operation */
 276.385 +
 276.386 +#define numeric_literal _glp_mpl_numeric_literal
 276.387 +CODE *numeric_literal(MPL *mpl);
 276.388 +/* parse reference to numeric literal */
 276.389 +
 276.390 +#define string_literal _glp_mpl_string_literal
 276.391 +CODE *string_literal(MPL *mpl);
 276.392 +/* parse reference to string literal */
 276.393 +
 276.394 +#define create_arg_list _glp_mpl_create_arg_list
 276.395 +ARG_LIST *create_arg_list(MPL *mpl);
 276.396 +/* create empty operands list */
 276.397 +
 276.398 +#define expand_arg_list _glp_mpl_expand_arg_list
 276.399 +ARG_LIST *expand_arg_list(MPL *mpl, ARG_LIST *list, CODE *x);
 276.400 +/* append operand to operands list */
 276.401 +
 276.402 +#define arg_list_len _glp_mpl_arg_list_len
 276.403 +int arg_list_len(MPL *mpl, ARG_LIST *list);
 276.404 +/* determine length of operands list */
 276.405 +
 276.406 +#define subscript_list _glp_mpl_subscript_list
 276.407 +ARG_LIST *subscript_list(MPL *mpl);
 276.408 +/* parse subscript list */
 276.409 +
 276.410 +#define object_reference _glp_mpl_object_reference
 276.411 +CODE *object_reference(MPL *mpl);
 276.412 +/* parse reference to named object */
 276.413 +
 276.414 +#define numeric_argument _glp_mpl_numeric_argument
 276.415 +CODE *numeric_argument(MPL *mpl, char *func);
 276.416 +/* parse argument passed to built-in function */
 276.417 +
 276.418 +#define symbolic_argument _glp_mpl_symbolic_argument
 276.419 +CODE *symbolic_argument(MPL *mpl, char *func);
 276.420 +
 276.421 +#define elemset_argument _glp_mpl_elemset_argument
 276.422 +CODE *elemset_argument(MPL *mpl, char *func);
 276.423 +
 276.424 +#define function_reference _glp_mpl_function_reference
 276.425 +CODE *function_reference(MPL *mpl);
 276.426 +/* parse reference to built-in function */
 276.427 +
 276.428 +#define create_domain _glp_mpl_create_domain
 276.429 +DOMAIN *create_domain(MPL *mpl);
 276.430 +/* create empty domain */
 276.431 +
 276.432 +#define create_block _glp_mpl_create_block
 276.433 +DOMAIN_BLOCK *create_block(MPL *mpl);
 276.434 +/* create empty domain block */
 276.435 +
 276.436 +#define append_block _glp_mpl_append_block
 276.437 +void append_block(MPL *mpl, DOMAIN *domain, DOMAIN_BLOCK *block);
 276.438 +/* append domain block to specified domain */
 276.439 +
 276.440 +#define append_slot _glp_mpl_append_slot
 276.441 +DOMAIN_SLOT *append_slot(MPL *mpl, DOMAIN_BLOCK *block, char *name,
 276.442 +      CODE *code);
 276.443 +/* create and append new slot to domain block */
 276.444 +
 276.445 +#define expression_list _glp_mpl_expression_list
 276.446 +CODE *expression_list(MPL *mpl);
 276.447 +/* parse expression list */
 276.448 +
 276.449 +#define literal_set _glp_mpl_literal_set
 276.450 +CODE *literal_set(MPL *mpl, CODE *code);
 276.451 +/* parse literal set */
 276.452 +
 276.453 +#define indexing_expression _glp_mpl_indexing_expression
 276.454 +DOMAIN *indexing_expression(MPL *mpl);
 276.455 +/* parse indexing expression */
 276.456 +
 276.457 +#define close_scope _glp_mpl_close_scope
 276.458 +void close_scope(MPL *mpl, DOMAIN *domain);
 276.459 +/* close scope of indexing expression */
 276.460 +
 276.461 +#define iterated_expression _glp_mpl_iterated_expression
 276.462 +CODE *iterated_expression(MPL *mpl);
 276.463 +/* parse iterated expression */
 276.464 +
 276.465 +#define domain_arity _glp_mpl_domain_arity
 276.466 +int domain_arity(MPL *mpl, DOMAIN *domain);
 276.467 +/* determine arity of domain */
 276.468 +
 276.469 +#define set_expression _glp_mpl_set_expression
 276.470 +CODE *set_expression(MPL *mpl);
 276.471 +/* parse set expression */
 276.472 +
 276.473 +#define branched_expression _glp_mpl_branched_expression
 276.474 +CODE *branched_expression(MPL *mpl);
 276.475 +/* parse conditional expression */
 276.476 +
 276.477 +#define primary_expression _glp_mpl_primary_expression
 276.478 +CODE *primary_expression(MPL *mpl);
 276.479 +/* parse primary expression */
 276.480 +
 276.481 +#define error_preceding _glp_mpl_error_preceding
 276.482 +void error_preceding(MPL *mpl, char *opstr);
 276.483 +/* raise error if preceding operand has wrong type */
 276.484 +
 276.485 +#define error_following _glp_mpl_error_following
 276.486 +void error_following(MPL *mpl, char *opstr);
 276.487 +/* raise error if following operand has wrong type */
 276.488 +
 276.489 +#define error_dimension _glp_mpl_error_dimension
 276.490 +void error_dimension(MPL *mpl, char *opstr, int dim1, int dim2);
 276.491 +/* raise error if operands have different dimension */
 276.492 +
 276.493 +#define expression_0 _glp_mpl_expression_0
 276.494 +CODE *expression_0(MPL *mpl);
 276.495 +/* parse expression of level 0 */
 276.496 +
 276.497 +#define expression_1 _glp_mpl_expression_1
 276.498 +CODE *expression_1(MPL *mpl);
 276.499 +/* parse expression of level 1 */
 276.500 +
 276.501 +#define expression_2 _glp_mpl_expression_2
 276.502 +CODE *expression_2(MPL *mpl);
 276.503 +/* parse expression of level 2 */
 276.504 +
 276.505 +#define expression_3 _glp_mpl_expression_3
 276.506 +CODE *expression_3(MPL *mpl);
 276.507 +/* parse expression of level 3 */
 276.508 +
 276.509 +#define expression_4 _glp_mpl_expression_4
 276.510 +CODE *expression_4(MPL *mpl);
 276.511 +/* parse expression of level 4 */
 276.512 +
 276.513 +#define expression_5 _glp_mpl_expression_5
 276.514 +CODE *expression_5(MPL *mpl);
 276.515 +/* parse expression of level 5 */
 276.516 +
 276.517 +#define expression_6 _glp_mpl_expression_6
 276.518 +CODE *expression_6(MPL *mpl);
 276.519 +/* parse expression of level 6 */
 276.520 +
 276.521 +#define expression_7 _glp_mpl_expression_7
 276.522 +CODE *expression_7(MPL *mpl);
 276.523 +/* parse expression of level 7 */
 276.524 +
 276.525 +#define expression_8 _glp_mpl_expression_8
 276.526 +CODE *expression_8(MPL *mpl);
 276.527 +/* parse expression of level 8 */
 276.528 +
 276.529 +#define expression_9 _glp_mpl_expression_9
 276.530 +CODE *expression_9(MPL *mpl);
 276.531 +/* parse expression of level 9 */
 276.532 +
 276.533 +#define expression_10 _glp_mpl_expression_10
 276.534 +CODE *expression_10(MPL *mpl);
 276.535 +/* parse expression of level 10 */
 276.536 +
 276.537 +#define expression_11 _glp_mpl_expression_11
 276.538 +CODE *expression_11(MPL *mpl);
 276.539 +/* parse expression of level 11 */
 276.540 +
 276.541 +#define expression_12 _glp_mpl_expression_12
 276.542 +CODE *expression_12(MPL *mpl);
 276.543 +/* parse expression of level 12 */
 276.544 +
 276.545 +#define expression_13 _glp_mpl_expression_13
 276.546 +CODE *expression_13(MPL *mpl);
 276.547 +/* parse expression of level 13 */
 276.548 +
 276.549 +#define set_statement _glp_mpl_set_statement
 276.550 +SET *set_statement(MPL *mpl);
 276.551 +/* parse set statement */
 276.552 +
 276.553 +#define parameter_statement _glp_mpl_parameter_statement
 276.554 +PARAMETER *parameter_statement(MPL *mpl);
 276.555 +/* parse parameter statement */
 276.556 +
 276.557 +#define variable_statement _glp_mpl_variable_statement
 276.558 +VARIABLE *variable_statement(MPL *mpl);
 276.559 +/* parse variable statement */
 276.560 +
 276.561 +#define constraint_statement _glp_mpl_constraint_statement
 276.562 +CONSTRAINT *constraint_statement(MPL *mpl);
 276.563 +/* parse constraint statement */
 276.564 +
 276.565 +#define objective_statement _glp_mpl_objective_statement
 276.566 +CONSTRAINT *objective_statement(MPL *mpl);
 276.567 +/* parse objective statement */
 276.568 +
 276.569 +#define table_statement _glp_mpl_table_statement
 276.570 +TABLE *table_statement(MPL *mpl);
 276.571 +/* parse table statement */
 276.572 +
 276.573 +#define solve_statement _glp_mpl_solve_statement
 276.574 +void *solve_statement(MPL *mpl);
 276.575 +/* parse solve statement */
 276.576 +
 276.577 +#define check_statement _glp_mpl_check_statement
 276.578 +CHECK *check_statement(MPL *mpl);
 276.579 +/* parse check statement */
 276.580 +
 276.581 +#define display_statement _glp_mpl_display_statement
 276.582 +DISPLAY *display_statement(MPL *mpl);
 276.583 +/* parse display statement */
 276.584 +
 276.585 +#define printf_statement _glp_mpl_printf_statement
 276.586 +PRINTF *printf_statement(MPL *mpl);
 276.587 +/* parse printf statement */
 276.588 +
 276.589 +#define for_statement _glp_mpl_for_statement
 276.590 +FOR *for_statement(MPL *mpl);
 276.591 +/* parse for statement */
 276.592 +
 276.593 +#define end_statement _glp_mpl_end_statement
 276.594 +void end_statement(MPL *mpl);
 276.595 +/* parse end statement */
 276.596 +
 276.597 +#define simple_statement _glp_mpl_simple_statement
 276.598 +STATEMENT *simple_statement(MPL *mpl, int spec);
 276.599 +/* parse simple statement */
 276.600 +
 276.601 +#define model_section _glp_mpl_model_section
 276.602 +void model_section(MPL *mpl);
 276.603 +/* parse model section */
 276.604 +
 276.605 +/**********************************************************************/
 276.606 +/* * *                  PROCESSING DATA SECTION                   * * */
 276.607 +/**********************************************************************/
 276.608 +
 276.609 +#if 2 + 2 == 5
 276.610 +struct SLICE /* see TUPLE */
 276.611 +{     /* component of slice; the slice itself is associated with its
 276.612 +         first component; slices are similar to n-tuples with exception
 276.613 +         that some slice components (which are indicated by asterisks)
 276.614 +         don't refer to any symbols */
 276.615 +      SYMBOL *sym;
 276.616 +      /* symbol, which this component refers to; can be NULL */
 276.617 +      SLICE *next;
 276.618 +      /* the next component of slice */
 276.619 +};
 276.620 +#endif
 276.621 +
 276.622 +#define create_slice _glp_mpl_create_slice
 276.623 +SLICE *create_slice(MPL *mpl);
 276.624 +/* create slice */
 276.625 +
 276.626 +#define expand_slice _glp_mpl_expand_slice
 276.627 +SLICE *expand_slice
 276.628 +(     MPL *mpl,
 276.629 +      SLICE *slice,           /* destroyed */
 276.630 +      SYMBOL *sym             /* destroyed */
 276.631 +);
 276.632 +/* append new component to slice */
 276.633 +
 276.634 +#define slice_dimen _glp_mpl_slice_dimen
 276.635 +int slice_dimen
 276.636 +(     MPL *mpl,
 276.637 +      SLICE *slice            /* not changed */
 276.638 +);
 276.639 +/* determine dimension of slice */
 276.640 +
 276.641 +#define slice_arity _glp_mpl_slice_arity
 276.642 +int slice_arity
 276.643 +(     MPL *mpl,
 276.644 +      SLICE *slice            /* not changed */
 276.645 +);
 276.646 +/* determine arity of slice */
 276.647 +
 276.648 +#define fake_slice _glp_mpl_fake_slice
 276.649 +SLICE *fake_slice(MPL *mpl, int dim);
 276.650 +/* create fake slice of all asterisks */
 276.651 +
 276.652 +#define delete_slice _glp_mpl_delete_slice
 276.653 +void delete_slice
 276.654 +(     MPL *mpl,
 276.655 +      SLICE *slice            /* destroyed */
 276.656 +);
 276.657 +/* delete slice */
 276.658 +
 276.659 +#define is_number _glp_mpl_is_number
 276.660 +int is_number(MPL *mpl);
 276.661 +/* check if current token is number */
 276.662 +
 276.663 +#define is_symbol _glp_mpl_is_symbol
 276.664 +int is_symbol(MPL *mpl);
 276.665 +/* check if current token is symbol */
 276.666 +
 276.667 +#define is_literal _glp_mpl_is_literal
 276.668 +int is_literal(MPL *mpl, char *literal);
 276.669 +/* check if current token is given symbolic literal */
 276.670 +
 276.671 +#define read_number _glp_mpl_read_number
 276.672 +double read_number(MPL *mpl);
 276.673 +/* read number */
 276.674 +
 276.675 +#define read_symbol _glp_mpl_read_symbol
 276.676 +SYMBOL *read_symbol(MPL *mpl);
 276.677 +/* read symbol */
 276.678 +
 276.679 +#define read_slice _glp_mpl_read_slice
 276.680 +SLICE *read_slice
 276.681 +(     MPL *mpl,
 276.682 +      char *name,             /* not changed */
 276.683 +      int dim
 276.684 +);
 276.685 +/* read slice */
 276.686 +
 276.687 +#define select_set _glp_mpl_select_set
 276.688 +SET *select_set
 276.689 +(     MPL *mpl,
 276.690 +      char *name              /* not changed */
 276.691 +);
 276.692 +/* select set to saturate it with elemental sets */
 276.693 +
 276.694 +#define simple_format _glp_mpl_simple_format
 276.695 +void simple_format
 276.696 +(     MPL *mpl,
 276.697 +      SET *set,               /* not changed */
 276.698 +      MEMBER *memb,           /* modified */
 276.699 +      SLICE *slice            /* not changed */
 276.700 +);
 276.701 +/* read set data block in simple format */
 276.702 +
 276.703 +#define matrix_format _glp_mpl_matrix_format
 276.704 +void matrix_format
 276.705 +(     MPL *mpl,
 276.706 +      SET *set,               /* not changed */
 276.707 +      MEMBER *memb,           /* modified */
 276.708 +      SLICE *slice,           /* not changed */
 276.709 +      int tr
 276.710 +);
 276.711 +/* read set data block in matrix format */
 276.712 +
 276.713 +#define set_data _glp_mpl_set_data
 276.714 +void set_data(MPL *mpl);
 276.715 +/* read set data */
 276.716 +
 276.717 +#define select_parameter _glp_mpl_select_parameter
 276.718 +PARAMETER *select_parameter
 276.719 +(     MPL *mpl,
 276.720 +      char *name              /* not changed */
 276.721 +);
 276.722 +/* select parameter to saturate it with data */
 276.723 +
 276.724 +#define set_default _glp_mpl_set_default
 276.725 +void set_default
 276.726 +(     MPL *mpl,
 276.727 +      PARAMETER *par,         /* not changed */
 276.728 +      SYMBOL *altval          /* destroyed */
 276.729 +);
 276.730 +/* set default parameter value */
 276.731 +
 276.732 +#define read_value _glp_mpl_read_value
 276.733 +MEMBER *read_value
 276.734 +(     MPL *mpl,
 276.735 +      PARAMETER *par,         /* not changed */
 276.736 +      TUPLE *tuple            /* destroyed */
 276.737 +);
 276.738 +/* read value and assign it to parameter member */
 276.739 +
 276.740 +#define plain_format _glp_mpl_plain_format
 276.741 +void plain_format
 276.742 +(     MPL *mpl,
 276.743 +      PARAMETER *par,         /* not changed */
 276.744 +      SLICE *slice            /* not changed */
 276.745 +);
 276.746 +/* read parameter data block in plain format */
 276.747 +
 276.748 +#define tabular_format _glp_mpl_tabular_format
 276.749 +void tabular_format
 276.750 +(     MPL *mpl,
 276.751 +      PARAMETER *par,         /* not changed */
 276.752 +      SLICE *slice,           /* not changed */
 276.753 +      int tr
 276.754 +);
 276.755 +/* read parameter data block in tabular format */
 276.756 +
 276.757 +#define tabbing_format _glp_mpl_tabbing_format
 276.758 +void tabbing_format
 276.759 +(     MPL *mpl,
 276.760 +      SYMBOL *altval          /* not changed */
 276.761 +);
 276.762 +/* read parameter data block in tabbing format */
 276.763 +
 276.764 +#define parameter_data _glp_mpl_parameter_data
 276.765 +void parameter_data(MPL *mpl);
 276.766 +/* read parameter data */
 276.767 +
 276.768 +#define data_section _glp_mpl_data_section
 276.769 +void data_section(MPL *mpl);
 276.770 +/* read data section */
 276.771 +
 276.772 +/**********************************************************************/
 276.773 +/* * *                   FLOATING-POINT NUMBERS                   * * */
 276.774 +/**********************************************************************/
 276.775 +
 276.776 +#define fp_add _glp_mpl_fp_add
 276.777 +double fp_add(MPL *mpl, double x, double y);
 276.778 +/* floating-point addition */
 276.779 +
 276.780 +#define fp_sub _glp_mpl_fp_sub
 276.781 +double fp_sub(MPL *mpl, double x, double y);
 276.782 +/* floating-point subtraction */
 276.783 +
 276.784 +#define fp_less _glp_mpl_fp_less
 276.785 +double fp_less(MPL *mpl, double x, double y);
 276.786 +/* floating-point non-negative subtraction */
 276.787 +
 276.788 +#define fp_mul _glp_mpl_fp_mul
 276.789 +double fp_mul(MPL *mpl, double x, double y);
 276.790 +/* floating-point multiplication */
 276.791 +
 276.792 +#define fp_div _glp_mpl_fp_div
 276.793 +double fp_div(MPL *mpl, double x, double y);
 276.794 +/* floating-point division */
 276.795 +
 276.796 +#define fp_idiv _glp_mpl_fp_idiv
 276.797 +double fp_idiv(MPL *mpl, double x, double y);
 276.798 +/* floating-point quotient of exact division */
 276.799 +
 276.800 +#define fp_mod _glp_mpl_fp_mod
 276.801 +double fp_mod(MPL *mpl, double x, double y);
 276.802 +/* floating-point remainder of exact division */
 276.803 +
 276.804 +#define fp_power _glp_mpl_fp_power
 276.805 +double fp_power(MPL *mpl, double x, double y);
 276.806 +/* floating-point exponentiation (raise to power) */
 276.807 +
 276.808 +#define fp_exp _glp_mpl_fp_exp
 276.809 +double fp_exp(MPL *mpl, double x);
 276.810 +/* floating-point base-e exponential */
 276.811 +
 276.812 +#define fp_log _glp_mpl_fp_log
 276.813 +double fp_log(MPL *mpl, double x);
 276.814 +/* floating-point natural logarithm */
 276.815 +
 276.816 +#define fp_log10 _glp_mpl_fp_log10
 276.817 +double fp_log10(MPL *mpl, double x);
 276.818 +/* floating-point common (decimal) logarithm */
 276.819 +
 276.820 +#define fp_sqrt _glp_mpl_fp_sqrt
 276.821 +double fp_sqrt(MPL *mpl, double x);
 276.822 +/* floating-point square root */
 276.823 +
 276.824 +#define fp_sin _glp_mpl_fp_sin
 276.825 +double fp_sin(MPL *mpl, double x);
 276.826 +/* floating-point trigonometric sine */
 276.827 +
 276.828 +#define fp_cos _glp_mpl_fp_cos
 276.829 +double fp_cos(MPL *mpl, double x);
 276.830 +/* floating-point trigonometric cosine */
 276.831 +
 276.832 +#define fp_atan _glp_mpl_fp_atan
 276.833 +double fp_atan(MPL *mpl, double x);
 276.834 +/* floating-point trigonometric arctangent */
 276.835 +
 276.836 +#define fp_atan2 _glp_mpl_fp_atan2
 276.837 +double fp_atan2(MPL *mpl, double y, double x);
 276.838 +/* floating-point trigonometric arctangent */
 276.839 +
 276.840 +#define fp_round _glp_mpl_fp_round
 276.841 +double fp_round(MPL *mpl, double x, double n);
 276.842 +/* round floating-point value to n fractional digits */
 276.843 +
 276.844 +#define fp_trunc _glp_mpl_fp_trunc
 276.845 +double fp_trunc(MPL *mpl, double x, double n);
 276.846 +/* truncate floating-point value to n fractional digits */
 276.847 +
 276.848 +/**********************************************************************/
 276.849 +/* * *              PSEUDO-RANDOM NUMBER GENERATORS               * * */
 276.850 +/**********************************************************************/
 276.851 +
 276.852 +#define fp_irand224 _glp_mpl_fp_irand224
 276.853 +double fp_irand224(MPL *mpl);
 276.854 +/* pseudo-random integer in the range [0, 2^24) */
 276.855 +
 276.856 +#define fp_uniform01 _glp_mpl_fp_uniform01
 276.857 +double fp_uniform01(MPL *mpl);
 276.858 +/* pseudo-random number in the range [0, 1) */
 276.859 +
 276.860 +#define fp_uniform _glp_mpl_uniform
 276.861 +double fp_uniform(MPL *mpl, double a, double b);
 276.862 +/* pseudo-random number in the range [a, b) */
 276.863 +
 276.864 +#define fp_normal01 _glp_mpl_fp_normal01
 276.865 +double fp_normal01(MPL *mpl);
 276.866 +/* Gaussian random variate with mu = 0 and sigma = 1 */
 276.867 +
 276.868 +#define fp_normal _glp_mpl_fp_normal
 276.869 +double fp_normal(MPL *mpl, double mu, double sigma);
 276.870 +/* Gaussian random variate with specified mu and sigma */
 276.871 +
 276.872 +/**********************************************************************/
 276.873 +/* * *                         DATE/TIME                          * * */
 276.874 +/**********************************************************************/
 276.875 +
 276.876 +#define fn_gmtime _glp_mpl_fn_gmtime
 276.877 +double fn_gmtime(MPL *mpl);
 276.878 +/* obtain the current calendar time (UTC) */
 276.879 +
 276.880 +#define fn_str2time _glp_mpl_fn_str2time
 276.881 +double fn_str2time(MPL *mpl, const char *str, const char *fmt);
 276.882 +/* convert character string to the calendar time */
 276.883 +
 276.884 +#define fn_time2str _glp_mpl_fn_time2str
 276.885 +void fn_time2str(MPL *mpl, char *str, double t, const char *fmt);
 276.886 +/* convert the calendar time to character string */
 276.887 +
 276.888 +/**********************************************************************/
 276.889 +/* * *                     CHARACTER STRINGS                      * * */
 276.890 +/**********************************************************************/
 276.891 +
 276.892 +#define create_string _glp_mpl_create_string
 276.893 +STRING *create_string
 276.894 +(     MPL *mpl,
 276.895 +      char buf[MAX_LENGTH+1]  /* not changed */
 276.896 +);
 276.897 +/* create character string */
 276.898 +
 276.899 +#define copy_string _glp_mpl_copy_string
 276.900 +STRING *copy_string
 276.901 +(     MPL *mpl,
 276.902 +      STRING *str             /* not changed */
 276.903 +);
 276.904 +/* make copy of character string */
 276.905 +
 276.906 +#define compare_strings _glp_mpl_compare_strings
 276.907 +int compare_strings
 276.908 +(     MPL *mpl,
 276.909 +      STRING *str1,           /* not changed */
 276.910 +      STRING *str2            /* not changed */
 276.911 +);
 276.912 +/* compare one character string with another */
 276.913 +
 276.914 +#define fetch_string _glp_mpl_fetch_string
 276.915 +char *fetch_string
 276.916 +(     MPL *mpl,
 276.917 +      STRING *str,            /* not changed */
 276.918 +      char buf[MAX_LENGTH+1]  /* modified */
 276.919 +);
 276.920 +/* extract content of character string */
 276.921 +
 276.922 +#define delete_string _glp_mpl_delete_string
 276.923 +void delete_string
 276.924 +(     MPL *mpl,
 276.925 +      STRING *str             /* destroyed */
 276.926 +);
 276.927 +/* delete character string */
 276.928 +
 276.929 +/**********************************************************************/
 276.930 +/* * *                          SYMBOLS                           * * */
 276.931 +/**********************************************************************/
 276.932 +
 276.933 +struct SYMBOL
 276.934 +{     /* symbol (numeric or abstract quantity) */
 276.935 +      double num;
 276.936 +      /* numeric value of symbol (used only if str == NULL) */
 276.937 +      STRING *str;
 276.938 +      /* abstract value of symbol (used only if str != NULL) */
 276.939 +};
 276.940 +
 276.941 +#define create_symbol_num _glp_mpl_create_symbol_num
 276.942 +SYMBOL *create_symbol_num(MPL *mpl, double num);
 276.943 +/* create symbol of numeric type */
 276.944 +
 276.945 +#define create_symbol_str _glp_mpl_create_symbol_str
 276.946 +SYMBOL *create_symbol_str
 276.947 +(     MPL *mpl,
 276.948 +      STRING *str             /* destroyed */
 276.949 +);
 276.950 +/* create symbol of abstract type */
 276.951 +
 276.952 +#define copy_symbol _glp_mpl_copy_symbol
 276.953 +SYMBOL *copy_symbol
 276.954 +(     MPL *mpl,
 276.955 +      SYMBOL *sym             /* not changed */
 276.956 +);
 276.957 +/* make copy of symbol */
 276.958 +
 276.959 +#define compare_symbols _glp_mpl_compare_symbols
 276.960 +int compare_symbols
 276.961 +(     MPL *mpl,
 276.962 +      SYMBOL *sym1,           /* not changed */
 276.963 +      SYMBOL *sym2            /* not changed */
 276.964 +);
 276.965 +/* compare one symbol with another */
 276.966 +
 276.967 +#define delete_symbol _glp_mpl_delete_symbol
 276.968 +void delete_symbol
 276.969 +(     MPL *mpl,
 276.970 +      SYMBOL *sym             /* destroyed */
 276.971 +);
 276.972 +/* delete symbol */
 276.973 +
 276.974 +#define format_symbol _glp_mpl_format_symbol
 276.975 +char *format_symbol
 276.976 +(     MPL *mpl,
 276.977 +      SYMBOL *sym             /* not changed */
 276.978 +);
 276.979 +/* format symbol for displaying or printing */
 276.980 +
 276.981 +#define concat_symbols _glp_mpl_concat_symbols
 276.982 +SYMBOL *concat_symbols
 276.983 +(     MPL *mpl,
 276.984 +      SYMBOL *sym1,           /* destroyed */
 276.985 +      SYMBOL *sym2            /* destroyed */
 276.986 +);
 276.987 +/* concatenate one symbol with another */
 276.988 +
 276.989 +/**********************************************************************/
 276.990 +/* * *                          N-TUPLES                          * * */
 276.991 +/**********************************************************************/
 276.992 +
 276.993 +struct TUPLE
 276.994 +{     /* component of n-tuple; the n-tuple itself is associated with
 276.995 +         its first component; (note that 0-tuple has no components) */
 276.996 +      SYMBOL *sym;
 276.997 +      /* symbol, which the component refers to; cannot be NULL */
 276.998 +      TUPLE *next;
 276.999 +      /* the next component of n-tuple */
276.1000 +};
276.1001 +
276.1002 +#define create_tuple _glp_mpl_create_tuple
276.1003 +TUPLE *create_tuple(MPL *mpl);
276.1004 +/* create n-tuple */
276.1005 +
276.1006 +#define expand_tuple _glp_mpl_expand_tuple
276.1007 +TUPLE *expand_tuple
276.1008 +(     MPL *mpl,
276.1009 +      TUPLE *tuple,           /* destroyed */
276.1010 +      SYMBOL *sym             /* destroyed */
276.1011 +);
276.1012 +/* append symbol to n-tuple */
276.1013 +
276.1014 +#define tuple_dimen _glp_mpl_tuple_dimen
276.1015 +int tuple_dimen
276.1016 +(     MPL *mpl,
276.1017 +      TUPLE *tuple            /* not changed */
276.1018 +);
276.1019 +/* determine dimension of n-tuple */
276.1020 +
276.1021 +#define copy_tuple _glp_mpl_copy_tuple
276.1022 +TUPLE *copy_tuple
276.1023 +(     MPL *mpl,
276.1024 +      TUPLE *tuple            /* not changed */
276.1025 +);
276.1026 +/* make copy of n-tuple */
276.1027 +
276.1028 +#define compare_tuples _glp_mpl_compare_tuples
276.1029 +int compare_tuples
276.1030 +(     MPL *mpl,
276.1031 +      TUPLE *tuple1,          /* not changed */
276.1032 +      TUPLE *tuple2           /* not changed */
276.1033 +);
276.1034 +/* compare one n-tuple with another */
276.1035 +
276.1036 +#define build_subtuple _glp_mpl_build_subtuple
276.1037 +TUPLE *build_subtuple
276.1038 +(     MPL *mpl,
276.1039 +      TUPLE *tuple,           /* not changed */
276.1040 +      int dim
276.1041 +);
276.1042 +/* build subtuple of given n-tuple */
276.1043 +
276.1044 +#define delete_tuple _glp_mpl_delete_tuple
276.1045 +void delete_tuple
276.1046 +(     MPL *mpl,
276.1047 +      TUPLE *tuple            /* destroyed */
276.1048 +);
276.1049 +/* delete n-tuple */
276.1050 +
276.1051 +#define format_tuple _glp_mpl_format_tuple
276.1052 +char *format_tuple
276.1053 +(     MPL *mpl,
276.1054 +      int c,
276.1055 +      TUPLE *tuple            /* not changed */
276.1056 +);
276.1057 +/* format n-tuple for displaying or printing */
276.1058 +
276.1059 +/**********************************************************************/
276.1060 +/* * *                       ELEMENTAL SETS                       * * */
276.1061 +/**********************************************************************/
276.1062 +
276.1063 +#if 2 + 2 == 5
276.1064 +struct ELEMSET /* see ARRAY */
276.1065 +{     /* elemental set of n-tuples; formally it is a "value" assigned
276.1066 +         to members of model sets (like numbers and symbols, which are
276.1067 +         values assigned to members of model parameters); note that a
276.1068 +         simple model set is not an elemental set, it is 0-dimensional
276.1069 +         array, the only member of which (if it exists) is assigned an
276.1070 +         elemental set */
276.1071 +#endif
276.1072 +
276.1073 +#define create_elemset _glp_mpl_create_elemset
276.1074 +ELEMSET *create_elemset(MPL *mpl, int dim);
276.1075 +/* create elemental set */
276.1076 +
276.1077 +#define find_tuple _glp_mpl_find_tuple
276.1078 +MEMBER *find_tuple
276.1079 +(     MPL *mpl,
276.1080 +      ELEMSET *set,           /* not changed */
276.1081 +      TUPLE *tuple            /* not changed */
276.1082 +);
276.1083 +/* check if elemental set contains given n-tuple */
276.1084 +
276.1085 +#define add_tuple _glp_mpl_add_tuple
276.1086 +MEMBER *add_tuple
276.1087 +(     MPL *mpl,
276.1088 +      ELEMSET *set,           /* modified */
276.1089 +      TUPLE *tuple            /* destroyed */
276.1090 +);
276.1091 +/* add new n-tuple to elemental set */
276.1092 +
276.1093 +#define check_then_add _glp_mpl_check_then_add
276.1094 +MEMBER *check_then_add
276.1095 +(     MPL *mpl,
276.1096 +      ELEMSET *set,           /* modified */
276.1097 +      TUPLE *tuple            /* destroyed */
276.1098 +);
276.1099 +/* check and add new n-tuple to elemental set */
276.1100 +
276.1101 +#define copy_elemset _glp_mpl_copy_elemset
276.1102 +ELEMSET *copy_elemset
276.1103 +(     MPL *mpl,
276.1104 +      ELEMSET *set            /* not changed */
276.1105 +);
276.1106 +/* make copy of elemental set */
276.1107 +
276.1108 +#define delete_elemset _glp_mpl_delete_elemset
276.1109 +void delete_elemset
276.1110 +(     MPL *mpl,
276.1111 +      ELEMSET *set            /* destroyed */
276.1112 +);
276.1113 +/* delete elemental set */
276.1114 +
276.1115 +#define arelset_size _glp_mpl_arelset_size
276.1116 +int arelset_size(MPL *mpl, double t0, double tf, double dt);
276.1117 +/* compute size of "arithmetic" elemental set */
276.1118 +
276.1119 +#define arelset_member _glp_mpl_arelset_member
276.1120 +double arelset_member(MPL *mpl, double t0, double tf, double dt, int j);
276.1121 +/* compute member of "arithmetic" elemental set */
276.1122 +
276.1123 +#define create_arelset _glp_mpl_create_arelset
276.1124 +ELEMSET *create_arelset(MPL *mpl, double t0, double tf, double dt);
276.1125 +/* create "arithmetic" elemental set */
276.1126 +
276.1127 +#define set_union _glp_mpl_set_union
276.1128 +ELEMSET *set_union
276.1129 +(     MPL *mpl,
276.1130 +      ELEMSET *X,             /* destroyed */
276.1131 +      ELEMSET *Y              /* destroyed */
276.1132 +);
276.1133 +/* union of two elemental sets */
276.1134 +
276.1135 +#define set_diff _glp_mpl_set_diff
276.1136 +ELEMSET *set_diff
276.1137 +(     MPL *mpl,
276.1138 +      ELEMSET *X,             /* destroyed */
276.1139 +      ELEMSET *Y              /* destroyed */
276.1140 +);
276.1141 +/* difference between two elemental sets */
276.1142 +
276.1143 +#define set_symdiff _glp_mpl_set_symdiff
276.1144 +ELEMSET *set_symdiff
276.1145 +(     MPL *mpl,
276.1146 +      ELEMSET *X,             /* destroyed */
276.1147 +      ELEMSET *Y              /* destroyed */
276.1148 +);
276.1149 +/* symmetric difference between two elemental sets */
276.1150 +
276.1151 +#define set_inter _glp_mpl_set_inter
276.1152 +ELEMSET *set_inter
276.1153 +(     MPL *mpl,
276.1154 +      ELEMSET *X,             /* destroyed */
276.1155 +      ELEMSET *Y              /* destroyed */
276.1156 +);
276.1157 +/* intersection of two elemental sets */
276.1158 +
276.1159 +#define set_cross _glp_mpl_set_cross
276.1160 +ELEMSET *set_cross
276.1161 +(     MPL *mpl,
276.1162 +      ELEMSET *X,             /* destroyed */
276.1163 +      ELEMSET *Y              /* destroyed */
276.1164 +);
276.1165 +/* cross (Cartesian) product of two elemental sets */
276.1166 +
276.1167 +/**********************************************************************/
276.1168 +/* * *                    ELEMENTAL VARIABLES                     * * */
276.1169 +/**********************************************************************/
276.1170 +
276.1171 +struct ELEMVAR
276.1172 +{     /* elemental variable; formally it is a "value" assigned to
276.1173 +         members of model variables (like numbers and symbols, which
276.1174 +         are values assigned to members of model parameters) */
276.1175 +      int j;
276.1176 +      /* LP column number assigned to this elemental variable */
276.1177 +      VARIABLE *var;
276.1178 +      /* model variable, which contains this elemental variable */
276.1179 +      MEMBER *memb;
276.1180 +      /* array member, which is assigned this elemental variable */
276.1181 +      double lbnd;
276.1182 +      /* lower bound */
276.1183 +      double ubnd;
276.1184 +      /* upper bound */
276.1185 +      double temp;
276.1186 +      /* working quantity used in operations on linear forms; normally
276.1187 +         it contains floating-point zero */
276.1188 +#if 1 /* 15/V-2010 */
276.1189 +      int stat;
276.1190 +      double prim, dual;
276.1191 +      /* solution components provided by the solver */
276.1192 +#endif
276.1193 +};
276.1194 +
276.1195 +/**********************************************************************/
276.1196 +/* * *                        LINEAR FORMS                        * * */
276.1197 +/**********************************************************************/
276.1198 +
276.1199 +struct FORMULA
276.1200 +{     /* term of linear form c * x, where c is a coefficient, x is an
276.1201 +         elemental variable; the linear form itself is the sum of terms
276.1202 +         and is associated with its first term; (note that the linear
276.1203 +         form may be empty that means the sum is equal to zero) */
276.1204 +      double coef;
276.1205 +      /* coefficient at elemental variable or constant term */
276.1206 +      ELEMVAR *var;
276.1207 +      /* reference to elemental variable; NULL means constant term */
276.1208 +      FORMULA *next;
276.1209 +      /* the next term of linear form */
276.1210 +};
276.1211 +
276.1212 +#define constant_term _glp_mpl_constant_term
276.1213 +FORMULA *constant_term(MPL *mpl, double coef);
276.1214 +/* create constant term */
276.1215 +
276.1216 +#define single_variable _glp_mpl_single_variable
276.1217 +FORMULA *single_variable
276.1218 +(     MPL *mpl,
276.1219 +      ELEMVAR *var            /* referenced */
276.1220 +);
276.1221 +/* create single variable */
276.1222 +
276.1223 +#define copy_formula _glp_mpl_copy_formula
276.1224 +FORMULA *copy_formula
276.1225 +(     MPL *mpl,
276.1226 +      FORMULA *form           /* not changed */
276.1227 +);
276.1228 +/* make copy of linear form */
276.1229 +
276.1230 +#define delete_formula _glp_mpl_delete_formula
276.1231 +void delete_formula
276.1232 +(     MPL *mpl,
276.1233 +      FORMULA *form           /* destroyed */
276.1234 +);
276.1235 +/* delete linear form */
276.1236 +
276.1237 +#define linear_comb _glp_mpl_linear_comb
276.1238 +FORMULA *linear_comb
276.1239 +(     MPL *mpl,
276.1240 +      double a, FORMULA *fx,  /* destroyed */
276.1241 +      double b, FORMULA *fy   /* destroyed */
276.1242 +);
276.1243 +/* linear combination of two linear forms */
276.1244 +
276.1245 +#define remove_constant _glp_mpl_remove_constant
276.1246 +FORMULA *remove_constant
276.1247 +(     MPL *mpl,
276.1248 +      FORMULA *form,          /* destroyed */
276.1249 +      double *coef            /* modified */
276.1250 +);
276.1251 +/* remove constant term from linear form */
276.1252 +
276.1253 +#define reduce_terms _glp_mpl_reduce_terms
276.1254 +FORMULA *reduce_terms
276.1255 +(     MPL *mpl,
276.1256 +      FORMULA *form           /* destroyed */
276.1257 +);
276.1258 +/* reduce identical terms in linear form */
276.1259 +
276.1260 +/**********************************************************************/
276.1261 +/* * *                   ELEMENTAL CONSTRAINTS                    * * */
276.1262 +/**********************************************************************/
276.1263 +
276.1264 +struct ELEMCON
276.1265 +{     /* elemental constraint; formally it is a "value" assigned to
276.1266 +         members of model constraints (like numbers or symbols, which
276.1267 +         are values assigned to members of model parameters) */
276.1268 +      int i;
276.1269 +      /* LP row number assigned to this elemental constraint */
276.1270 +      CONSTRAINT *con;
276.1271 +      /* model constraint, which contains this elemental constraint */
276.1272 +      MEMBER *memb;
276.1273 +      /* array member, which is assigned this elemental constraint */
276.1274 +      FORMULA *form;
276.1275 +      /* linear form */
276.1276 +      double lbnd;
276.1277 +      /* lower bound */
276.1278 +      double ubnd;
276.1279 +      /* upper bound */
276.1280 +#if 1 /* 15/V-2010 */
276.1281 +      int stat;
276.1282 +      double prim, dual;
276.1283 +      /* solution components provided by the solver */
276.1284 +#endif
276.1285 +};
276.1286 +
276.1287 +/**********************************************************************/
276.1288 +/* * *                       GENERIC VALUES                       * * */
276.1289 +/**********************************************************************/
276.1290 +
276.1291 +union VALUE
276.1292 +{     /* generic value, which can be assigned to object member or be a
276.1293 +         result of evaluation of expression */
276.1294 +      /* indicator that specifies the particular type of generic value
276.1295 +         is stored in the corresponding array or pseudo-code descriptor
276.1296 +         and can be one of the following:
276.1297 +         A_NONE     - no value
276.1298 +         A_NUMERIC  - floating-point number
276.1299 +         A_SYMBOLIC - symbol
276.1300 +         A_LOGICAL  - logical value
276.1301 +         A_TUPLE    - n-tuple
276.1302 +         A_ELEMSET  - elemental set
276.1303 +         A_ELEMVAR  - elemental variable
276.1304 +         A_FORMULA  - linear form
276.1305 +         A_ELEMCON  - elemental constraint */
276.1306 +      void *none;    /* null */
276.1307 +      double num;    /* value */
276.1308 +      SYMBOL *sym;   /* value */
276.1309 +      int bit;       /* value */
276.1310 +      TUPLE *tuple;  /* value */
276.1311 +      ELEMSET *set;  /* value */
276.1312 +      ELEMVAR *var;  /* reference */
276.1313 +      FORMULA *form; /* value */
276.1314 +      ELEMCON *con;  /* reference */
276.1315 +};
276.1316 +
276.1317 +#define delete_value _glp_mpl_delete_value
276.1318 +void delete_value
276.1319 +(     MPL *mpl,
276.1320 +      int type,
276.1321 +      VALUE *value            /* content destroyed */
276.1322 +);
276.1323 +/* delete generic value */
276.1324 +
276.1325 +/**********************************************************************/
276.1326 +/* * *                SYMBOLICALLY INDEXED ARRAYS                 * * */
276.1327 +/**********************************************************************/
276.1328 +
276.1329 +struct ARRAY
276.1330 +{     /* multi-dimensional array, a set of members indexed over simple
276.1331 +         or compound sets of symbols; arrays are used to represent the
276.1332 +         contents of model objects (i.e. sets, parameters, variables,
276.1333 +         constraints, and objectives); arrays also are used as "values"
276.1334 +         that are assigned to members of set objects, in which case the
276.1335 +         array itself represents an elemental set */
276.1336 +      int type;
276.1337 +      /* type of generic values assigned to the array members:
276.1338 +         A_NONE     - none (members have no assigned values)
276.1339 +         A_NUMERIC  - floating-point numbers
276.1340 +         A_SYMBOLIC - symbols
276.1341 +         A_ELEMSET  - elemental sets
276.1342 +         A_ELEMVAR  - elemental variables
276.1343 +         A_ELEMCON  - elemental constraints */
276.1344 +      int dim;
276.1345 +      /* dimension of the array that determines number of components in
276.1346 +         n-tuples for all members of the array, dim >= 0; dim = 0 means
276.1347 +         the array is 0-dimensional */
276.1348 +      int size;
276.1349 +      /* size of the array, i.e. number of its members */
276.1350 +      MEMBER *head;
276.1351 +      /* the first array member; NULL means the array is empty */
276.1352 +      MEMBER *tail;
276.1353 +      /* the last array member; NULL means the array is empty */
276.1354 +      AVL *tree;
276.1355 +      /* the search tree intended to find array members for logarithmic
276.1356 +         time; NULL means the search tree doesn't exist */
276.1357 +      ARRAY *prev;
276.1358 +      /* the previous array in the translator database */
276.1359 +      ARRAY *next;
276.1360 +      /* the next array in the translator database */
276.1361 +};
276.1362 +
276.1363 +struct MEMBER
276.1364 +{     /* array member */
276.1365 +      TUPLE *tuple;
276.1366 +      /* n-tuple, which identifies the member; number of its components
276.1367 +         is the same for all members within the array and determined by
276.1368 +         the array dimension; duplicate members are not allowed */
276.1369 +      MEMBER *next;
276.1370 +      /* the next array member */
276.1371 +      VALUE value;
276.1372 +      /* generic value assigned to the member */
276.1373 +};
276.1374 +
276.1375 +#define create_array _glp_mpl_create_array
276.1376 +ARRAY *create_array(MPL *mpl, int type, int dim);
276.1377 +/* create array */
276.1378 +
276.1379 +#define find_member _glp_mpl_find_member
276.1380 +MEMBER *find_member
276.1381 +(     MPL *mpl,
276.1382 +      ARRAY *array,           /* not changed */
276.1383 +      TUPLE *tuple            /* not changed */
276.1384 +);
276.1385 +/* find array member with given n-tuple */
276.1386 +
276.1387 +#define add_member _glp_mpl_add_member
276.1388 +MEMBER *add_member
276.1389 +(     MPL *mpl,
276.1390 +      ARRAY *array,           /* modified */
276.1391 +      TUPLE *tuple            /* destroyed */
276.1392 +);
276.1393 +/* add new member to array */
276.1394 +
276.1395 +#define delete_array _glp_mpl_delete_array
276.1396 +void delete_array
276.1397 +(     MPL *mpl,
276.1398 +      ARRAY *array            /* destroyed */
276.1399 +);
276.1400 +/* delete array */
276.1401 +
276.1402 +/**********************************************************************/
276.1403 +/* * *                 DOMAINS AND DUMMY INDICES                  * * */
276.1404 +/**********************************************************************/
276.1405 +
276.1406 +struct DOMAIN
276.1407 +{     /* domain (a simple or compound set); syntactically domain looks
276.1408 +         like '{ i in I, (j,k) in S, t in T : <predicate> }'; domains
276.1409 +         are used to define sets, over which model objects are indexed,
276.1410 +         and also as constituents of iterated operators */
276.1411 +      DOMAIN_BLOCK *list;
276.1412 +      /* linked list of domain blocks (in the example above such blocks
276.1413 +         are 'i in I', '(j,k) in S', and 't in T'); this list cannot be
276.1414 +         empty */
276.1415 +      CODE *code;
276.1416 +      /* pseudo-code for computing the logical predicate, which follows
276.1417 +         the colon; NULL means no predicate is specified */
276.1418 +};
276.1419 +
276.1420 +struct DOMAIN_BLOCK
276.1421 +{     /* domain block; syntactically domain blocks look like 'i in I',
276.1422 +         '(j,k) in S', and 't in T' in the example above (in the sequel
276.1423 +         sets like I, S, and T are called basic sets) */
276.1424 +      DOMAIN_SLOT *list;
276.1425 +      /* linked list of domain slots (i.e. indexing positions); number
276.1426 +         of slots in this list is the same as dimension of n-tuples in
276.1427 +         the basic set; this list cannot be empty */
276.1428 +      CODE *code;
276.1429 +      /* pseudo-code for computing basic set; cannot be NULL */
276.1430 +      TUPLE *backup;
276.1431 +      /* if this n-tuple is not empty, current values of dummy indices
276.1432 +         in the domain block are the same as components of this n-tuple
276.1433 +         (note that this n-tuple may have larger dimension than number
276.1434 +         of dummy indices in this block, in which case extra components
276.1435 +         are ignored); this n-tuple is used to restore former values of
276.1436 +         dummy indices, if they were changed due to recursive calls to
276.1437 +         the domain block */
276.1438 +      DOMAIN_BLOCK *next;
276.1439 +      /* the next block in the same domain */
276.1440 +};
276.1441 +
276.1442 +struct DOMAIN_SLOT
276.1443 +{     /* domain slot; it specifies an individual indexing position and
276.1444 +         defines the corresponding dummy index */
276.1445 +      char *name;
276.1446 +      /* symbolic name of the dummy index; null pointer means the dummy
276.1447 +         index is not explicitly specified */
276.1448 +      CODE *code;
276.1449 +      /* pseudo-code for computing symbolic value, at which the dummy
276.1450 +         index is bound; NULL means the dummy index is free within the
276.1451 +         domain scope */
276.1452 +      SYMBOL *value;
276.1453 +      /* current value assigned to the dummy index; NULL means no value
276.1454 +         is assigned at the moment */
276.1455 +      CODE *list;
276.1456 +      /* linked list of pseudo-codes with operation O_INDEX referring
276.1457 +         to this slot; this linked list is used to invalidate resultant
276.1458 +         values of the operation, which depend on this dummy index */
276.1459 +      DOMAIN_SLOT *next;
276.1460 +      /* the next slot in the same domain block */
276.1461 +};
276.1462 +
276.1463 +#define assign_dummy_index _glp_mpl_assign_dummy_index
276.1464 +void assign_dummy_index
276.1465 +(     MPL *mpl,
276.1466 +      DOMAIN_SLOT *slot,      /* modified */
276.1467 +      SYMBOL *value           /* not changed */
276.1468 +);
276.1469 +/* assign new value to dummy index */
276.1470 +
276.1471 +#define update_dummy_indices _glp_mpl_update_dummy_indices
276.1472 +void update_dummy_indices
276.1473 +(     MPL *mpl,
276.1474 +      DOMAIN_BLOCK *block     /* not changed */
276.1475 +);
276.1476 +/* update current values of dummy indices */
276.1477 +
276.1478 +#define enter_domain_block _glp_mpl_enter_domain_block
276.1479 +int enter_domain_block
276.1480 +(     MPL *mpl,
276.1481 +      DOMAIN_BLOCK *block,    /* not changed */
276.1482 +      TUPLE *tuple,           /* not changed */
276.1483 +      void *info, void (*func)(MPL *mpl, void *info)
276.1484 +);
276.1485 +/* enter domain block */
276.1486 +
276.1487 +#define eval_within_domain _glp_mpl_eval_within_domain
276.1488 +int eval_within_domain
276.1489 +(     MPL *mpl,
276.1490 +      DOMAIN *domain,         /* not changed */
276.1491 +      TUPLE *tuple,           /* not changed */
276.1492 +      void *info, void (*func)(MPL *mpl, void *info)
276.1493 +);
276.1494 +/* perform evaluation within domain scope */
276.1495 +
276.1496 +#define loop_within_domain _glp_mpl_loop_within_domain
276.1497 +void loop_within_domain
276.1498 +(     MPL *mpl,
276.1499 +      DOMAIN *domain,         /* not changed */
276.1500 +      void *info, int (*func)(MPL *mpl, void *info)
276.1501 +);
276.1502 +/* perform iterations within domain scope */
276.1503 +
276.1504 +#define out_of_domain _glp_mpl_out_of_domain
276.1505 +void out_of_domain
276.1506 +(     MPL *mpl,
276.1507 +      char *name,             /* not changed */
276.1508 +      TUPLE *tuple            /* not changed */
276.1509 +);
276.1510 +/* raise domain exception */
276.1511 +
276.1512 +#define get_domain_tuple _glp_mpl_get_domain_tuple
276.1513 +TUPLE *get_domain_tuple
276.1514 +(     MPL *mpl,
276.1515 +      DOMAIN *domain          /* not changed */
276.1516 +);
276.1517 +/* obtain current n-tuple from domain */
276.1518 +
276.1519 +#define clean_domain _glp_mpl_clean_domain
276.1520 +void clean_domain(MPL *mpl, DOMAIN *domain);
276.1521 +/* clean domain */
276.1522 +
276.1523 +/**********************************************************************/
276.1524 +/* * *                         MODEL SETS                         * * */
276.1525 +/**********************************************************************/
276.1526 +
276.1527 +struct SET
276.1528 +{     /* model set */
276.1529 +      char *name;
276.1530 +      /* symbolic name; cannot be NULL */
276.1531 +      char *alias;
276.1532 +      /* alias; NULL means alias is not specified */
276.1533 +      int dim; /* aka arity */
276.1534 +      /* dimension (number of subscripts); dim = 0 means 0-dimensional
276.1535 +         (unsubscripted) set, dim > 0 means set of sets */
276.1536 +      DOMAIN *domain;
276.1537 +      /* subscript domain; NULL for 0-dimensional set */
276.1538 +      int dimen;
276.1539 +      /* dimension of n-tuples, which members of this set consist of
276.1540 +         (note that the model set itself is an array of elemental sets,
276.1541 +         which are its members; so, don't confuse this dimension with
276.1542 +         dimension of the model set); always non-zero */
276.1543 +      WITHIN *within;
276.1544 +      /* list of supersets, which restrict each member of the set to be
276.1545 +         in every superset from this list; this list can be empty */
276.1546 +      CODE *assign;
276.1547 +      /* pseudo-code for computing assigned value; can be NULL */
276.1548 +      CODE *option;
276.1549 +      /* pseudo-code for computing default value; can be NULL */
276.1550 +      GADGET *gadget;
276.1551 +      /* plain set used to initialize the array of sets; can be NULL */
276.1552 +      int data;
276.1553 +      /* data status flag:
276.1554 +         0 - no data are provided in the data section
276.1555 +         1 - data are provided, but not checked yet
276.1556 +         2 - data are provided and have been checked */
276.1557 +      ARRAY *array;
276.1558 +      /* array of members, which are assigned elemental sets */
276.1559 +};
276.1560 +
276.1561 +struct WITHIN
276.1562 +{     /* restricting superset list entry */
276.1563 +      CODE *code;
276.1564 +      /* pseudo-code for computing the superset; cannot be NULL */
276.1565 +      WITHIN *next;
276.1566 +      /* the next entry for the same set or parameter */
276.1567 +};
276.1568 +
276.1569 +struct GADGET
276.1570 +{     /* plain set used to initialize the array of sets with data */
276.1571 +      SET *set;
276.1572 +      /* pointer to plain set; cannot be NULL */
276.1573 +      int ind[20]; /* ind[dim+dimen]; */
276.1574 +      /* permutation of integers 1, 2, ..., dim+dimen */
276.1575 +};
276.1576 +
276.1577 +#define check_elem_set _glp_mpl_check_elem_set
276.1578 +void check_elem_set
276.1579 +(     MPL *mpl,
276.1580 +      SET *set,               /* not changed */
276.1581 +      TUPLE *tuple,           /* not changed */
276.1582 +      ELEMSET *refer          /* not changed */
276.1583 +);
276.1584 +/* check elemental set assigned to set member */
276.1585 +
276.1586 +#define take_member_set _glp_mpl_take_member_set
276.1587 +ELEMSET *take_member_set      /* returns reference, not value */
276.1588 +(     MPL *mpl,
276.1589 +      SET *set,               /* not changed */
276.1590 +      TUPLE *tuple            /* not changed */
276.1591 +);
276.1592 +/* obtain elemental set assigned to set member */
276.1593 +
276.1594 +#define eval_member_set _glp_mpl_eval_member_set
276.1595 +ELEMSET *eval_member_set      /* returns reference, not value */
276.1596 +(     MPL *mpl,
276.1597 +      SET *set,               /* not changed */
276.1598 +      TUPLE *tuple            /* not changed */
276.1599 +);
276.1600 +/* evaluate elemental set assigned to set member */
276.1601 +
276.1602 +#define eval_whole_set _glp_mpl_eval_whole_set
276.1603 +void eval_whole_set(MPL *mpl, SET *set);
276.1604 +/* evaluate model set over entire domain */
276.1605 +
276.1606 +#define clean_set _glp_mpl_clean_set
276.1607 +void clean_set(MPL *mpl, SET *set);
276.1608 +/* clean model set */
276.1609 +
276.1610 +/**********************************************************************/
276.1611 +/* * *                      MODEL PARAMETERS                      * * */
276.1612 +/**********************************************************************/
276.1613 +
276.1614 +struct PARAMETER
276.1615 +{     /* model parameter */
276.1616 +      char *name;
276.1617 +      /* symbolic name; cannot be NULL */
276.1618 +      char *alias;
276.1619 +      /* alias; NULL means alias is not specified */
276.1620 +      int dim; /* aka arity */
276.1621 +      /* dimension (number of subscripts); dim = 0 means 0-dimensional
276.1622 +         (unsubscripted) parameter */
276.1623 +      DOMAIN *domain;
276.1624 +      /* subscript domain; NULL for 0-dimensional parameter */
276.1625 +      int type;
276.1626 +      /* parameter type:
276.1627 +         A_NUMERIC  - numeric
276.1628 +         A_INTEGER  - integer
276.1629 +         A_BINARY   - binary
276.1630 +         A_SYMBOLIC - symbolic */
276.1631 +      CONDITION *cond;
276.1632 +      /* list of conditions, which restrict each parameter member to
276.1633 +         satisfy to every condition from this list; this list is used
276.1634 +         only for numeric parameters and can be empty */
276.1635 +      WITHIN *in;
276.1636 +      /* list of supersets, which restrict each parameter member to be
276.1637 +         in every superset from this list; this list is used only for
276.1638 +         symbolic parameters and can be empty */
276.1639 +      CODE *assign;
276.1640 +      /* pseudo-code for computing assigned value; can be NULL */
276.1641 +      CODE *option;
276.1642 +      /* pseudo-code for computing default value; can be NULL */
276.1643 +      int data;
276.1644 +      /* data status flag:
276.1645 +         0 - no data are provided in the data section
276.1646 +         1 - data are provided, but not checked yet
276.1647 +         2 - data are provided and have been checked */
276.1648 +      SYMBOL *defval;
276.1649 +      /* default value provided in the data section; can be NULL */
276.1650 +      ARRAY *array;
276.1651 +      /* array of members, which are assigned numbers or symbols */
276.1652 +};
276.1653 +
276.1654 +struct CONDITION
276.1655 +{     /* restricting condition list entry */
276.1656 +      int rho;
276.1657 +      /* flag that specifies the form of the condition:
276.1658 +         O_LT - less than
276.1659 +         O_LE - less than or equal to
276.1660 +         O_EQ - equal to
276.1661 +         O_GE - greater than or equal to
276.1662 +         O_GT - greater than
276.1663 +         O_NE - not equal to */
276.1664 +      CODE *code;
276.1665 +      /* pseudo-code for computing the reference value */
276.1666 +      CONDITION *next;
276.1667 +      /* the next entry for the same parameter */
276.1668 +};
276.1669 +
276.1670 +#define check_value_num _glp_mpl_check_value_num
276.1671 +void check_value_num
276.1672 +(     MPL *mpl,
276.1673 +      PARAMETER *par,         /* not changed */
276.1674 +      TUPLE *tuple,           /* not changed */
276.1675 +      double value
276.1676 +);
276.1677 +/* check numeric value assigned to parameter member */
276.1678 +
276.1679 +#define take_member_num _glp_mpl_take_member_num
276.1680 +double take_member_num
276.1681 +(     MPL *mpl,
276.1682 +      PARAMETER *par,         /* not changed */
276.1683 +      TUPLE *tuple            /* not changed */
276.1684 +);
276.1685 +/* obtain numeric value assigned to parameter member */
276.1686 +
276.1687 +#define eval_member_num _glp_mpl_eval_member_num
276.1688 +double eval_member_num
276.1689 +(     MPL *mpl,
276.1690 +      PARAMETER *par,         /* not changed */
276.1691 +      TUPLE *tuple            /* not changed */
276.1692 +);
276.1693 +/* evaluate numeric value assigned to parameter member */
276.1694 +
276.1695 +#define check_value_sym _glp_mpl_check_value_sym
276.1696 +void check_value_sym
276.1697 +(     MPL *mpl,
276.1698 +      PARAMETER *par,         /* not changed */
276.1699 +      TUPLE *tuple,           /* not changed */
276.1700 +      SYMBOL *value           /* not changed */
276.1701 +);
276.1702 +/* check symbolic value assigned to parameter member */
276.1703 +
276.1704 +#define take_member_sym _glp_mpl_take_member_sym
276.1705 +SYMBOL *take_member_sym       /* returns value, not reference */
276.1706 +(     MPL *mpl,
276.1707 +      PARAMETER *par,         /* not changed */
276.1708 +      TUPLE *tuple            /* not changed */
276.1709 +);
276.1710 +/* obtain symbolic value assigned to parameter member */
276.1711 +
276.1712 +#define eval_member_sym _glp_mpl_eval_member_sym
276.1713 +SYMBOL *eval_member_sym       /* returns value, not reference */
276.1714 +(     MPL *mpl,
276.1715 +      PARAMETER *par,         /* not changed */
276.1716 +      TUPLE *tuple            /* not changed */
276.1717 +);
276.1718 +/* evaluate symbolic value assigned to parameter member */
276.1719 +
276.1720 +#define eval_whole_par _glp_mpl_eval_whole_par
276.1721 +void eval_whole_par(MPL *mpl, PARAMETER *par);
276.1722 +/* evaluate model parameter over entire domain */
276.1723 +
276.1724 +#define clean_parameter _glp_mpl_clean_parameter
276.1725 +void clean_parameter(MPL *mpl, PARAMETER *par);
276.1726 +/* clean model parameter */
276.1727 +
276.1728 +/**********************************************************************/
276.1729 +/* * *                      MODEL VARIABLES                       * * */
276.1730 +/**********************************************************************/
276.1731 +
276.1732 +struct VARIABLE
276.1733 +{     /* model variable */
276.1734 +      char *name;
276.1735 +      /* symbolic name; cannot be NULL */
276.1736 +      char *alias;
276.1737 +      /* alias; NULL means alias is not specified */
276.1738 +      int dim; /* aka arity */
276.1739 +      /* dimension (number of subscripts); dim = 0 means 0-dimensional
276.1740 +         (unsubscripted) variable */
276.1741 +      DOMAIN *domain;
276.1742 +      /* subscript domain; NULL for 0-dimensional variable */
276.1743 +      int type;
276.1744 +      /* variable type:
276.1745 +         A_NUMERIC - continuous
276.1746 +         A_INTEGER - integer
276.1747 +         A_BINARY  - binary */
276.1748 +      CODE *lbnd;
276.1749 +      /* pseudo-code for computing lower bound; NULL means lower bound
276.1750 +         is not specified */
276.1751 +      CODE *ubnd;
276.1752 +      /* pseudo-code for computing upper bound; NULL means upper bound
276.1753 +         is not specified */
276.1754 +      /* if both the pointers lbnd and ubnd refer to the same code, the
276.1755 +         variable is fixed at the corresponding value */
276.1756 +      ARRAY *array;
276.1757 +      /* array of members, which are assigned elemental variables */
276.1758 +};
276.1759 +
276.1760 +#define take_member_var _glp_mpl_take_member_var
276.1761 +ELEMVAR *take_member_var      /* returns reference */
276.1762 +(     MPL *mpl,
276.1763 +      VARIABLE *var,          /* not changed */
276.1764 +      TUPLE *tuple            /* not changed */
276.1765 +);
276.1766 +/* obtain reference to elemental variable */
276.1767 +
276.1768 +#define eval_member_var _glp_mpl_eval_member_var
276.1769 +ELEMVAR *eval_member_var      /* returns reference */
276.1770 +(     MPL *mpl,
276.1771 +      VARIABLE *var,          /* not changed */
276.1772 +      TUPLE *tuple            /* not changed */
276.1773 +);
276.1774 +/* evaluate reference to elemental variable */
276.1775 +
276.1776 +#define eval_whole_var _glp_mpl_eval_whole_var
276.1777 +void eval_whole_var(MPL *mpl, VARIABLE *var);
276.1778 +/* evaluate model variable over entire domain */
276.1779 +
276.1780 +#define clean_variable _glp_mpl_clean_variable
276.1781 +void clean_variable(MPL *mpl, VARIABLE *var);
276.1782 +/* clean model variable */
276.1783 +
276.1784 +/**********************************************************************/
276.1785 +/* * *              MODEL CONSTRAINTS AND OBJECTIVES              * * */
276.1786 +/**********************************************************************/
276.1787 +
276.1788 +struct CONSTRAINT
276.1789 +{     /* model constraint or objective */
276.1790 +      char *name;
276.1791 +      /* symbolic name; cannot be NULL */
276.1792 +      char *alias;
276.1793 +      /* alias; NULL means alias is not specified */
276.1794 +      int dim; /* aka arity */
276.1795 +      /* dimension (number of subscripts); dim = 0 means 0-dimensional
276.1796 +         (unsubscripted) constraint */
276.1797 +      DOMAIN *domain;
276.1798 +      /* subscript domain; NULL for 0-dimensional constraint */
276.1799 +      int type;
276.1800 +      /* constraint type:
276.1801 +         A_CONSTRAINT - constraint
276.1802 +         A_MINIMIZE   - objective (minimization)
276.1803 +         A_MAXIMIZE   - objective (maximization) */
276.1804 +      CODE *code;
276.1805 +      /* pseudo-code for computing main linear form; cannot be NULL */
276.1806 +      CODE *lbnd;
276.1807 +      /* pseudo-code for computing lower bound; NULL means lower bound
276.1808 +         is not specified */
276.1809 +      CODE *ubnd;
276.1810 +      /* pseudo-code for computing upper bound; NULL means upper bound
276.1811 +         is not specified */
276.1812 +      /* if both the pointers lbnd and ubnd refer to the same code, the
276.1813 +         constraint has the form of equation */
276.1814 +      ARRAY *array;
276.1815 +      /* array of members, which are assigned elemental constraints */
276.1816 +};
276.1817 +
276.1818 +#define take_member_con _glp_mpl_take_member_con
276.1819 +ELEMCON *take_member_con      /* returns reference */
276.1820 +(     MPL *mpl,
276.1821 +      CONSTRAINT *con,        /* not changed */
276.1822 +      TUPLE *tuple            /* not changed */
276.1823 +);
276.1824 +/* obtain reference to elemental constraint */
276.1825 +
276.1826 +#define eval_member_con _glp_mpl_eval_member_con
276.1827 +ELEMCON *eval_member_con      /* returns reference */
276.1828 +(     MPL *mpl,
276.1829 +      CONSTRAINT *con,        /* not changed */
276.1830 +      TUPLE *tuple            /* not changed */
276.1831 +);
276.1832 +/* evaluate reference to elemental constraint */
276.1833 +
276.1834 +#define eval_whole_con _glp_mpl_eval_whole_con
276.1835 +void eval_whole_con(MPL *mpl, CONSTRAINT *con);
276.1836 +/* evaluate model constraint over entire domain */
276.1837 +
276.1838 +#define clean_constraint _glp_mpl_clean_constraint
276.1839 +void clean_constraint(MPL *mpl, CONSTRAINT *con);
276.1840 +/* clean model constraint */
276.1841 +
276.1842 +/**********************************************************************/
276.1843 +/* * *                        DATA TABLES                         * * */
276.1844 +/**********************************************************************/
276.1845 +
276.1846 +struct TABLE
276.1847 +{     /* data table */
276.1848 +      char *name;
276.1849 +      /* symbolic name; cannot be NULL */
276.1850 +      char *alias;
276.1851 +      /* alias; NULL means alias is not specified */
276.1852 +      int type;
276.1853 +      /* table type:
276.1854 +         A_INPUT  - input table
276.1855 +         A_OUTPUT - output table */
276.1856 +      TABARG *arg;
276.1857 +      /* argument list; cannot be empty */
276.1858 +      union
276.1859 +      {  struct
276.1860 +         {  SET *set;
276.1861 +            /* input set; NULL means the set is not specified */
276.1862 +            TABFLD *fld;
276.1863 +            /* field list; cannot be empty */
276.1864 +            TABIN *list;
276.1865 +            /* input list; can be empty */
276.1866 +         } in;
276.1867 +         struct
276.1868 +         {  DOMAIN *domain;
276.1869 +            /* subscript domain; cannot be NULL */
276.1870 +            TABOUT *list;
276.1871 +            /* output list; cannot be empty */
276.1872 +         } out;
276.1873 +      } u;
276.1874 +};
276.1875 +
276.1876 +struct TABARG
276.1877 +{     /* table argument list entry */
276.1878 +      CODE *code;
276.1879 +      /* pseudo-code for computing the argument */
276.1880 +      TABARG *next;
276.1881 +      /* next entry for the same table */
276.1882 +};
276.1883 +
276.1884 +struct TABFLD
276.1885 +{     /* table field list entry */
276.1886 +      char *name;
276.1887 +      /* field name; cannot be NULL */
276.1888 +      TABFLD *next;
276.1889 +      /* next entry for the same table */
276.1890 +};
276.1891 +
276.1892 +struct TABIN
276.1893 +{     /* table input list entry */
276.1894 +      PARAMETER *par;
276.1895 +      /* parameter to be read; cannot be NULL */
276.1896 +      char *name;
276.1897 +      /* column name; cannot be NULL */
276.1898 +      TABIN *next;
276.1899 +      /* next entry for the same table */
276.1900 +};
276.1901 +
276.1902 +struct TABOUT
276.1903 +{     /* table output list entry */
276.1904 +      CODE *code;
276.1905 +      /* pseudo-code for computing the value to be written */
276.1906 +      char *name;
276.1907 +      /* column name; cannot be NULL */
276.1908 +      TABOUT *next;
276.1909 +      /* next entry for the same table */
276.1910 +};
276.1911 +
276.1912 +struct TABDCA
276.1913 +{     /* table driver communication area */
276.1914 +      int id;
276.1915 +      /* driver identifier (set by mpl_tab_drv_open) */
276.1916 +      void *link;
276.1917 +      /* driver link pointer (set by mpl_tab_drv_open) */
276.1918 +      int na;
276.1919 +      /* number of arguments */
276.1920 +      char **arg; /* char *arg[1+ns]; */
276.1921 +      /* arg[k], 1 <= k <= ns, is pointer to k-th argument */
276.1922 +      int nf;
276.1923 +      /* number of fields */
276.1924 +      char **name; /* char *name[1+nc]; */
276.1925 +      /* name[k], 1 <= k <= nc, is name of k-th field */
276.1926 +      int *type; /* int type[1+nc]; */
276.1927 +      /* type[k], 1 <= k <= nc, is type of k-th field:
276.1928 +         '?' - value not assigned
276.1929 +         'N' - number
276.1930 +         'S' - character string */
276.1931 +      double *num; /* double num[1+nc]; */
276.1932 +      /* num[k], 1 <= k <= nc, is numeric value of k-th field */
276.1933 +      char **str;
276.1934 +      /* str[k], 1 <= k <= nc, is string value of k-th field */
276.1935 +};
276.1936 +
276.1937 +#define mpl_tab_num_args _glp_mpl_tab_num_args
276.1938 +int mpl_tab_num_args(TABDCA *dca);
276.1939 +
276.1940 +#define mpl_tab_get_arg _glp_mpl_tab_get_arg
276.1941 +const char *mpl_tab_get_arg(TABDCA *dca, int k);
276.1942 +
276.1943 +#define mpl_tab_num_flds _glp_mpl_tab_num_flds
276.1944 +int mpl_tab_num_flds(TABDCA *dca);
276.1945 +
276.1946 +#define mpl_tab_get_name _glp_mpl_tab_get_name
276.1947 +const char *mpl_tab_get_name(TABDCA *dca, int k);
276.1948 +
276.1949 +#define mpl_tab_get_type _glp_mpl_tab_get_type
276.1950 +int mpl_tab_get_type(TABDCA *dca, int k);
276.1951 +
276.1952 +#define mpl_tab_get_num _glp_mpl_tab_get_num
276.1953 +double mpl_tab_get_num(TABDCA *dca, int k);
276.1954 +
276.1955 +#define mpl_tab_get_str _glp_mpl_tab_get_str
276.1956 +const char *mpl_tab_get_str(TABDCA *dca, int k);
276.1957 +
276.1958 +#define mpl_tab_set_num _glp_mpl_tab_set_num
276.1959 +void mpl_tab_set_num(TABDCA *dca, int k, double num);
276.1960 +
276.1961 +#define mpl_tab_set_str _glp_mpl_tab_set_str
276.1962 +void mpl_tab_set_str(TABDCA *dca, int k, const char *str);
276.1963 +
276.1964 +#define mpl_tab_drv_open _glp_mpl_tab_drv_open
276.1965 +void mpl_tab_drv_open(MPL *mpl, int mode);
276.1966 +
276.1967 +#define mpl_tab_drv_read _glp_mpl_tab_drv_read
276.1968 +int mpl_tab_drv_read(MPL *mpl);
276.1969 +
276.1970 +#define mpl_tab_drv_write _glp_mpl_tab_drv_write
276.1971 +void mpl_tab_drv_write(MPL *mpl);
276.1972 +
276.1973 +#define mpl_tab_drv_close _glp_mpl_tab_drv_close
276.1974 +void mpl_tab_drv_close(MPL *mpl);
276.1975 +
276.1976 +/**********************************************************************/
276.1977 +/* * *                        PSEUDO-CODE                         * * */
276.1978 +/**********************************************************************/
276.1979 +
276.1980 +union OPERANDS
276.1981 +{     /* operands that participate in pseudo-code operation (choice of
276.1982 +         particular operands depends on the operation code) */
276.1983 +      /*--------------------------------------------------------------*/
276.1984 +      double num;             /* O_NUMBER */
276.1985 +      /* floaing-point number to be taken */
276.1986 +      /*--------------------------------------------------------------*/
276.1987 +      char *str;              /* O_STRING */
276.1988 +      /* character string to be taken */
276.1989 +      /*--------------------------------------------------------------*/
276.1990 +      struct                  /* O_INDEX */
276.1991 +      {  DOMAIN_SLOT *slot;
276.1992 +         /* domain slot, which contains dummy index to be taken */
276.1993 +         CODE *next;
276.1994 +         /* the next pseudo-code with op = O_INDEX, which refers to the
276.1995 +            same slot as this one; pointer to the beginning of this list
276.1996 +            is stored in the corresponding domain slot */
276.1997 +      } index;
276.1998 +      /*--------------------------------------------------------------*/
276.1999 +      struct                  /* O_MEMNUM, O_MEMSYM */
276.2000 +      {  PARAMETER *par;
276.2001 +         /* model parameter, which contains member to be taken */
276.2002 +         ARG_LIST *list;
276.2003 +         /* list of subscripts; NULL for 0-dimensional parameter */
276.2004 +      } par;
276.2005 +      /*--------------------------------------------------------------*/
276.2006 +      struct                  /* O_MEMSET */
276.2007 +      {  SET *set;
276.2008 +         /* model set, which contains member to be taken */
276.2009 +         ARG_LIST *list;
276.2010 +         /* list of subscripts; NULL for 0-dimensional set */
276.2011 +      } set;
276.2012 +      /*--------------------------------------------------------------*/
276.2013 +      struct                  /* O_MEMVAR */
276.2014 +      {  VARIABLE *var;
276.2015 +         /* model variable, which contains member to be taken */
276.2016 +         ARG_LIST *list;
276.2017 +         /* list of subscripts; NULL for 0-dimensional variable */
276.2018 +#if 1 /* 15/V-2010 */
276.2019 +         int suff;
276.2020 +         /* suffix specified: */
276.2021 +#define DOT_NONE        0x00  /* none     (means variable itself) */
276.2022 +#define DOT_LB          0x01  /* .lb      (lower bound) */
276.2023 +#define DOT_UB          0x02  /* .ub      (upper bound) */
276.2024 +#define DOT_STATUS      0x03  /* .status  (status) */
276.2025 +#define DOT_VAL         0x04  /* .val     (primal value) */
276.2026 +#define DOT_DUAL        0x05  /* .dual    (dual value) */
276.2027 +#endif
276.2028 +      } var;
276.2029 +#if 1 /* 15/V-2010 */
276.2030 +      /*--------------------------------------------------------------*/
276.2031 +      struct                  /* O_MEMCON */
276.2032 +      {  CONSTRAINT *con;
276.2033 +         /* model constraint, which contains member to be taken */
276.2034 +         ARG_LIST *list;
276.2035 +         /* list of subscripys; NULL for 0-dimensional constraint */
276.2036 +         int suff;
276.2037 +         /* suffix specified (see O_MEMVAR above) */
276.2038 +      } con;
276.2039 +#endif
276.2040 +      /*--------------------------------------------------------------*/
276.2041 +      ARG_LIST *list;         /* O_TUPLE, O_MAKE, n-ary operations */
276.2042 +      /* list of operands */
276.2043 +      /*--------------------------------------------------------------*/
276.2044 +      DOMAIN_BLOCK *slice;    /* O_SLICE */
276.2045 +      /* domain block, which specifies slice (i.e. n-tuple that contains
276.2046 +         free dummy indices); this operation is never evaluated */
276.2047 +      /*--------------------------------------------------------------*/
276.2048 +      struct                  /* unary, binary, ternary operations */
276.2049 +      {  CODE *x;
276.2050 +         /* pseudo-code for computing first operand */
276.2051 +         CODE *y;
276.2052 +         /* pseudo-code for computing second operand */
276.2053 +         CODE *z;
276.2054 +         /* pseudo-code for computing third operand */
276.2055 +      } arg;
276.2056 +      /*--------------------------------------------------------------*/
276.2057 +      struct                  /* iterated operations */
276.2058 +      {  DOMAIN *domain;
276.2059 +         /* domain, over which the operation is performed */
276.2060 +         CODE *x;
276.2061 +         /* pseudo-code for computing "integrand" */
276.2062 +      } loop;
276.2063 +      /*--------------------------------------------------------------*/
276.2064 +};
276.2065 +
276.2066 +struct ARG_LIST
276.2067 +{     /* operands list entry */
276.2068 +      CODE *x;
276.2069 +      /* pseudo-code for computing operand */
276.2070 +      ARG_LIST *next;
276.2071 +      /* the next operand of the same operation */
276.2072 +};
276.2073 +
276.2074 +struct CODE
276.2075 +{     /* pseudo-code (internal form of expressions) */
276.2076 +      int op;
276.2077 +      /* operation code: */
276.2078 +#define O_NUMBER        301   /* take floating-point number */
276.2079 +#define O_STRING        302   /* take character string */
276.2080 +#define O_INDEX         303   /* take dummy index */
276.2081 +#define O_MEMNUM        304   /* take member of numeric parameter */
276.2082 +#define O_MEMSYM        305   /* take member of symbolic parameter */
276.2083 +#define O_MEMSET        306   /* take member of set */
276.2084 +#define O_MEMVAR        307   /* take member of variable */
276.2085 +#define O_MEMCON        308   /* take member of constraint */
276.2086 +#define O_TUPLE         309   /* make n-tuple */
276.2087 +#define O_MAKE          310   /* make elemental set of n-tuples */
276.2088 +#define O_SLICE         311   /* define domain block (dummy op) */
276.2089 +                              /* 0-ary operations --------------------*/
276.2090 +#define O_IRAND224      312   /* pseudo-random in [0, 2^24-1] */
276.2091 +#define O_UNIFORM01     313   /* pseudo-random in [0, 1) */
276.2092 +#define O_NORMAL01      314   /* gaussian random, mu = 0, sigma = 1 */
276.2093 +#define O_GMTIME        315   /* current calendar time (UTC) */
276.2094 +                              /* unary operations --------------------*/
276.2095 +#define O_CVTNUM        316   /* conversion to numeric */
276.2096 +#define O_CVTSYM        317   /* conversion to symbolic */
276.2097 +#define O_CVTLOG        318   /* conversion to logical */
276.2098 +#define O_CVTTUP        319   /* conversion to 1-tuple */
276.2099 +#define O_CVTLFM        320   /* conversion to linear form */
276.2100 +#define O_PLUS          321   /* unary plus */
276.2101 +#define O_MINUS         322   /* unary minus */
276.2102 +#define O_NOT           323   /* negation (logical "not") */
276.2103 +#define O_ABS           324   /* absolute value */
276.2104 +#define O_CEIL          325   /* round upward ("ceiling of x") */
276.2105 +#define O_FLOOR         326   /* round downward ("floor of x") */
276.2106 +#define O_EXP           327   /* base-e exponential */
276.2107 +#define O_LOG           328   /* natural logarithm */
276.2108 +#define O_LOG10         329   /* common (decimal) logarithm */
276.2109 +#define O_SQRT          330   /* square root */
276.2110 +#define O_SIN           331   /* trigonometric sine */
276.2111 +#define O_COS           332   /* trigonometric cosine */
276.2112 +#define O_ATAN          333   /* trigonometric arctangent */
276.2113 +#define O_ROUND         334   /* round to nearest integer */
276.2114 +#define O_TRUNC         335   /* truncate to nearest integer */
276.2115 +#define O_CARD          336   /* cardinality of set */
276.2116 +#define O_LENGTH        337   /* length of symbolic value */
276.2117 +                              /* binary operations -------------------*/
276.2118 +#define O_ADD           338   /* addition */
276.2119 +#define O_SUB           339   /* subtraction */
276.2120 +#define O_LESS          340   /* non-negative subtraction */
276.2121 +#define O_MUL           341   /* multiplication */
276.2122 +#define O_DIV           342   /* division */
276.2123 +#define O_IDIV          343   /* quotient of exact division */
276.2124 +#define O_MOD           344   /* remainder of exact division */
276.2125 +#define O_POWER         345   /* exponentiation (raise to power) */
276.2126 +#define O_ATAN2         346   /* trigonometric arctangent */
276.2127 +#define O_ROUND2        347   /* round to n fractional digits */
276.2128 +#define O_TRUNC2        348   /* truncate to n fractional digits */
276.2129 +#define O_UNIFORM       349   /* pseudo-random in [a, b) */
276.2130 +#define O_NORMAL        350   /* gaussian random, given mu and sigma */
276.2131 +#define O_CONCAT        351   /* concatenation */
276.2132 +#define O_LT            352   /* comparison on 'less than' */
276.2133 +#define O_LE            353   /* comparison on 'not greater than' */
276.2134 +#define O_EQ            354   /* comparison on 'equal to' */
276.2135 +#define O_GE            355   /* comparison on 'not less than' */
276.2136 +#define O_GT            356   /* comparison on 'greater than' */
276.2137 +#define O_NE            357   /* comparison on 'not equal to' */
276.2138 +#define O_AND           358   /* conjunction (logical "and") */
276.2139 +#define O_OR            359   /* disjunction (logical "or") */
276.2140 +#define O_UNION         360   /* union */
276.2141 +#define O_DIFF          361   /* difference */
276.2142 +#define O_SYMDIFF       362   /* symmetric difference */
276.2143 +#define O_INTER         363   /* intersection */
276.2144 +#define O_CROSS         364   /* cross (Cartesian) product */
276.2145 +#define O_IN            365   /* test on 'x in Y' */
276.2146 +#define O_NOTIN         366   /* test on 'x not in Y' */
276.2147 +#define O_WITHIN        367   /* test on 'X within Y' */
276.2148 +#define O_NOTWITHIN     368   /* test on 'X not within Y' */
276.2149 +#define O_SUBSTR        369   /* substring */
276.2150 +#define O_STR2TIME      370   /* convert string to time */
276.2151 +#define O_TIME2STR      371   /* convert time to string */
276.2152 +                              /* ternary operations ------------------*/
276.2153 +#define O_DOTS          372   /* build "arithmetic" set */
276.2154 +#define O_FORK          373   /* if-then-else */
276.2155 +#define O_SUBSTR3       374   /* substring */
276.2156 +                              /* n-ary operations --------------------*/
276.2157 +#define O_MIN           375   /* minimal value (n-ary) */
276.2158 +#define O_MAX           376   /* maximal value (n-ary) */
276.2159 +                              /* iterated operations -----------------*/
276.2160 +#define O_SUM           377   /* summation */
276.2161 +#define O_PROD          378   /* multiplication */
276.2162 +#define O_MINIMUM       379   /* minimum */
276.2163 +#define O_MAXIMUM       380   /* maximum */
276.2164 +#define O_FORALL        381   /* conjunction (A-quantification) */
276.2165 +#define O_EXISTS        382   /* disjunction (E-quantification) */
276.2166 +#define O_SETOF         383   /* compute elemental set */
276.2167 +#define O_BUILD         384   /* build elemental set */
276.2168 +      OPERANDS arg;
276.2169 +      /* operands that participate in the operation */
276.2170 +      int type;
276.2171 +      /* type of the resultant value:
276.2172 +         A_NUMERIC  - numeric
276.2173 +         A_SYMBOLIC - symbolic
276.2174 +         A_LOGICAL  - logical
276.2175 +         A_TUPLE    - n-tuple
276.2176 +         A_ELEMSET  - elemental set
276.2177 +         A_FORMULA  - linear form */
276.2178 +      int dim;
276.2179 +      /* dimension of the resultant value; for A_TUPLE and A_ELEMSET it
276.2180 +         is the dimension of the corresponding n-tuple(s) and cannot be
276.2181 +         zero; for other resultant types it is always zero */
276.2182 +      CODE *up;
276.2183 +      /* parent pseudo-code, which refers to this pseudo-code as to its
276.2184 +         operand; NULL means this pseudo-code has no parent and defines
276.2185 +         an expression, which is not contained in another expression */
276.2186 +      int vflag;
276.2187 +      /* volatile flag; being set this flag means that this operation
276.2188 +         has a side effect; for primary expressions this flag is set
276.2189 +         directly by corresponding parsing routines (for example, if
276.2190 +         primary expression is a reference to a function that generates
276.2191 +         pseudo-random numbers); in other cases this flag is inherited
276.2192 +         from operands */
276.2193 +      int valid;
276.2194 +      /* if this flag is set, the resultant value, which is a temporary
276.2195 +         result of evaluating this operation on particular values of
276.2196 +         operands, is valid; if this flag is clear, the resultant value
276.2197 +         doesn't exist and therefore not valid; having been evaluated
276.2198 +         the resultant value is stored here and not destroyed until the
276.2199 +         dummy indices, which this value depends on, have been changed
276.2200 +         (and if it doesn't depend on dummy indices at all, it is never
276.2201 +         destroyed); thus, if the resultant value is valid, evaluating
276.2202 +         routine can immediately take its copy not computing the result
276.2203 +         from scratch; this mechanism is similar to moving invariants
276.2204 +         out of loops and allows improving efficiency at the expense of
276.2205 +         some extra memory needed to keep temporary results */
276.2206 +      /* however, if the volatile flag (see above) is set, even if the
276.2207 +         resultant value is valid, evaluating routine computes it as if
276.2208 +         it were not valid, i.e. caching is not used in this case */
276.2209 +      VALUE value;
276.2210 +      /* resultant value in generic format */
276.2211 +};
276.2212 +
276.2213 +#define eval_numeric _glp_mpl_eval_numeric
276.2214 +double eval_numeric(MPL *mpl, CODE *code);
276.2215 +/* evaluate pseudo-code to determine numeric value */
276.2216 +
276.2217 +#define eval_symbolic _glp_mpl_eval_symbolic
276.2218 +SYMBOL *eval_symbolic(MPL *mpl, CODE *code);
276.2219 +/* evaluate pseudo-code to determine symbolic value */
276.2220 +
276.2221 +#define eval_logical _glp_mpl_eval_logical
276.2222 +int eval_logical(MPL *mpl, CODE *code);
276.2223 +/* evaluate pseudo-code to determine logical value */
276.2224 +
276.2225 +#define eval_tuple _glp_mpl_eval_tuple
276.2226 +TUPLE *eval_tuple(MPL *mpl, CODE *code);
276.2227 +/* evaluate pseudo-code to construct n-tuple */
276.2228 +
276.2229 +#define eval_elemset _glp_mpl_eval_elemset
276.2230 +ELEMSET *eval_elemset(MPL *mpl, CODE *code);
276.2231 +/* evaluate pseudo-code to construct elemental set */
276.2232 +
276.2233 +#define is_member _glp_mpl_is_member
276.2234 +int is_member(MPL *mpl, CODE *code, TUPLE *tuple);
276.2235 +/* check if n-tuple is in set specified by pseudo-code */
276.2236 +
276.2237 +#define eval_formula _glp_mpl_eval_formula
276.2238 +FORMULA *eval_formula(MPL *mpl, CODE *code);
276.2239 +/* evaluate pseudo-code to construct linear form */
276.2240 +
276.2241 +#define clean_code _glp_mpl_clean_code
276.2242 +void clean_code(MPL *mpl, CODE *code);
276.2243 +/* clean pseudo-code */
276.2244 +
276.2245 +/**********************************************************************/
276.2246 +/* * *                      MODEL STATEMENTS                      * * */
276.2247 +/**********************************************************************/
276.2248 +
276.2249 +struct CHECK
276.2250 +{     /* check statement */
276.2251 +      DOMAIN *domain;
276.2252 +      /* subscript domain; NULL means domain is not used */
276.2253 +      CODE *code;
276.2254 +      /* code for computing the predicate to be checked */
276.2255 +};
276.2256 +
276.2257 +struct DISPLAY
276.2258 +{     /* display statement */
276.2259 +      DOMAIN *domain;
276.2260 +      /* subscript domain; NULL means domain is not used */
276.2261 +      DISPLAY1 *list;
276.2262 +      /* display list; cannot be empty */
276.2263 +};
276.2264 +
276.2265 +struct DISPLAY1
276.2266 +{     /* display list entry */
276.2267 +      int type;
276.2268 +      /* item type:
276.2269 +         A_INDEX      - dummy index
276.2270 +         A_SET        - model set
276.2271 +         A_PARAMETER  - model parameter
276.2272 +         A_VARIABLE   - model variable
276.2273 +         A_CONSTRAINT - model constraint/objective
276.2274 +         A_EXPRESSION - expression */
276.2275 +      union
276.2276 +      {  DOMAIN_SLOT *slot;
276.2277 +         SET *set;
276.2278 +         PARAMETER *par;
276.2279 +         VARIABLE *var;
276.2280 +         CONSTRAINT *con;
276.2281 +         CODE *code;
276.2282 +      } u;
276.2283 +      /* item to be displayed */
276.2284 +#if 0 /* 15/V-2010 */
276.2285 +      ARG_LIST *list;
276.2286 +      /* optional subscript list (for constraint/objective only) */
276.2287 +#endif
276.2288 +      DISPLAY1 *next;
276.2289 +      /* the next entry for the same statement */
276.2290 +};
276.2291 +
276.2292 +struct PRINTF
276.2293 +{     /* printf statement */
276.2294 +      DOMAIN *domain;
276.2295 +      /* subscript domain; NULL means domain is not used */
276.2296 +      CODE *fmt;
276.2297 +      /* pseudo-code for computing format string */
276.2298 +      PRINTF1 *list;
276.2299 +      /* printf list; can be empty */
276.2300 +      CODE *fname;
276.2301 +      /* pseudo-code for computing filename to redirect the output;
276.2302 +         NULL means the output goes to stdout */
276.2303 +      int app;
276.2304 +      /* if this flag is set, the output is appended */
276.2305 +};
276.2306 +
276.2307 +struct PRINTF1
276.2308 +{     /* printf list entry */
276.2309 +      CODE *code;
276.2310 +      /* pseudo-code for computing value to be printed */
276.2311 +      PRINTF1 *next;
276.2312 +      /* the next entry for the same statement */
276.2313 +};
276.2314 +
276.2315 +struct FOR
276.2316 +{     /* for statement */
276.2317 +      DOMAIN *domain;
276.2318 +      /* subscript domain; cannot be NULL */
276.2319 +      STATEMENT *list;
276.2320 +      /* linked list of model statements within this for statement in
276.2321 +         the original order */
276.2322 +};
276.2323 +
276.2324 +struct STATEMENT
276.2325 +{     /* model statement */
276.2326 +      int line;
276.2327 +      /* number of source text line, where statement begins */
276.2328 +      int type;
276.2329 +      /* statement type:
276.2330 +         A_SET        - set statement
276.2331 +         A_PARAMETER  - parameter statement
276.2332 +         A_VARIABLE   - variable statement
276.2333 +         A_CONSTRAINT - constraint/objective statement
276.2334 +         A_TABLE      - table statement
276.2335 +         A_SOLVE      - solve statement
276.2336 +         A_CHECK      - check statement
276.2337 +         A_DISPLAY    - display statement
276.2338 +         A_PRINTF     - printf statement
276.2339 +         A_FOR        - for statement */
276.2340 +      union
276.2341 +      {  SET *set;
276.2342 +         PARAMETER *par;
276.2343 +         VARIABLE *var;
276.2344 +         CONSTRAINT *con;
276.2345 +         TABLE *tab;
276.2346 +         void *slv; /* currently not used (set to NULL) */
276.2347 +         CHECK *chk;
276.2348 +         DISPLAY *dpy;
276.2349 +         PRINTF *prt;
276.2350 +         FOR *fur;
276.2351 +      } u;
276.2352 +      /* specific part of statement */
276.2353 +      STATEMENT *next;
276.2354 +      /* the next statement; in this list statements follow in the same
276.2355 +         order as they appear in the model section */
276.2356 +};
276.2357 +
276.2358 +#define execute_table _glp_mpl_execute_table
276.2359 +void execute_table(MPL *mpl, TABLE *tab);
276.2360 +/* execute table statement */
276.2361 +
276.2362 +#define free_dca _glp_mpl_free_dca
276.2363 +void free_dca(MPL *mpl);
276.2364 +/* free table driver communucation area */
276.2365 +
276.2366 +#define clean_table _glp_mpl_clean_table
276.2367 +void clean_table(MPL *mpl, TABLE *tab);
276.2368 +/* clean table statement */
276.2369 +
276.2370 +#define execute_check _glp_mpl_execute_check
276.2371 +void execute_check(MPL *mpl, CHECK *chk);
276.2372 +/* execute check statement */
276.2373 +
276.2374 +#define clean_check _glp_mpl_clean_check
276.2375 +void clean_check(MPL *mpl, CHECK *chk);
276.2376 +/* clean check statement */
276.2377 +
276.2378 +#define execute_display _glp_mpl_execute_display
276.2379 +void execute_display(MPL *mpl, DISPLAY *dpy);
276.2380 +/* execute display statement */
276.2381 +
276.2382 +#define clean_display _glp_mpl_clean_display
276.2383 +void clean_display(MPL *mpl, DISPLAY *dpy);
276.2384 +/* clean display statement */
276.2385 +
276.2386 +#define execute_printf _glp_mpl_execute_printf
276.2387 +void execute_printf(MPL *mpl, PRINTF *prt);
276.2388 +/* execute printf statement */
276.2389 +
276.2390 +#define clean_printf _glp_mpl_clean_printf
276.2391 +void clean_printf(MPL *mpl, PRINTF *prt);
276.2392 +/* clean printf statement */
276.2393 +
276.2394 +#define execute_for _glp_mpl_execute_for
276.2395 +void execute_for(MPL *mpl, FOR *fur);
276.2396 +/* execute for statement */
276.2397 +
276.2398 +#define clean_for _glp_mpl_clean_for
276.2399 +void clean_for(MPL *mpl, FOR *fur);
276.2400 +/* clean for statement */
276.2401 +
276.2402 +#define execute_statement _glp_mpl_execute_statement
276.2403 +void execute_statement(MPL *mpl, STATEMENT *stmt);
276.2404 +/* execute specified model statement */
276.2405 +
276.2406 +#define clean_statement _glp_mpl_clean_statement
276.2407 +void clean_statement(MPL *mpl, STATEMENT *stmt);
276.2408 +/* clean specified model statement */
276.2409 +
276.2410 +/**********************************************************************/
276.2411 +/* * *              GENERATING AND POSTSOLVING MODEL              * * */
276.2412 +/**********************************************************************/
276.2413 +
276.2414 +#define alloc_content _glp_mpl_alloc_content
276.2415 +void alloc_content(MPL *mpl);
276.2416 +/* allocate content arrays for all model objects */
276.2417 +
276.2418 +#define generate_model _glp_mpl_generate_model
276.2419 +void generate_model(MPL *mpl);
276.2420 +/* generate model */
276.2421 +
276.2422 +#define build_problem _glp_mpl_build_problem
276.2423 +void build_problem(MPL *mpl);
276.2424 +/* build problem instance */
276.2425 +
276.2426 +#define postsolve_model _glp_mpl_postsolve_model
276.2427 +void postsolve_model(MPL *mpl);
276.2428 +/* postsolve model */
276.2429 +
276.2430 +#define clean_model _glp_mpl_clean_model
276.2431 +void clean_model(MPL *mpl);
276.2432 +/* clean model content */
276.2433 +
276.2434 +/**********************************************************************/
276.2435 +/* * *                        INPUT/OUTPUT                        * * */
276.2436 +/**********************************************************************/
276.2437 +
276.2438 +#define open_input _glp_mpl_open_input
276.2439 +void open_input(MPL *mpl, char *file);
276.2440 +/* open input text file */
276.2441 +
276.2442 +#define read_char _glp_mpl_read_char
276.2443 +int read_char(MPL *mpl);
276.2444 +/* read next character from input text file */
276.2445 +
276.2446 +#define close_input _glp_mpl_close_input
276.2447 +void close_input(MPL *mpl);
276.2448 +/* close input text file */
276.2449 +
276.2450 +#define open_output _glp_mpl_open_output
276.2451 +void open_output(MPL *mpl, char *file);
276.2452 +/* open output text file */
276.2453 +
276.2454 +#define write_char _glp_mpl_write_char
276.2455 +void write_char(MPL *mpl, int c);
276.2456 +/* write next character to output text file */
276.2457 +
276.2458 +#define write_text _glp_mpl_write_text
276.2459 +void write_text(MPL *mpl, char *fmt, ...);
276.2460 +/* format and write text to output text file */
276.2461 +
276.2462 +#define flush_output _glp_mpl_flush_output
276.2463 +void flush_output(MPL *mpl);
276.2464 +/* finalize writing data to output text file */
276.2465 +
276.2466 +/**********************************************************************/
276.2467 +/* * *                      SOLVER INTERFACE                      * * */
276.2468 +/**********************************************************************/
276.2469 +
276.2470 +#define MPL_FR          401   /* free (unbounded) */
276.2471 +#define MPL_LO          402   /* lower bound */
276.2472 +#define MPL_UP          403   /* upper bound */
276.2473 +#define MPL_DB          404   /* both lower and upper bounds */
276.2474 +#define MPL_FX          405   /* fixed */
276.2475 +
276.2476 +#define MPL_ST          411   /* constraint */
276.2477 +#define MPL_MIN         412   /* objective (minimization) */
276.2478 +#define MPL_MAX         413   /* objective (maximization) */
276.2479 +
276.2480 +#define MPL_NUM         421   /* continuous */
276.2481 +#define MPL_INT         422   /* integer */
276.2482 +#define MPL_BIN         423   /* binary */
276.2483 +
276.2484 +#define error _glp_mpl_error
276.2485 +void error(MPL *mpl, char *fmt, ...);
276.2486 +/* print error message and terminate model processing */
276.2487 +
276.2488 +#define warning _glp_mpl_warning
276.2489 +void warning(MPL *mpl, char *fmt, ...);
276.2490 +/* print warning message and continue model processing */
276.2491 +
276.2492 +#define mpl_initialize _glp_mpl_initialize
276.2493 +MPL *mpl_initialize(void);
276.2494 +/* create and initialize translator database */
276.2495 +
276.2496 +#define mpl_read_model _glp_mpl_read_model
276.2497 +int mpl_read_model(MPL *mpl, char *file, int skip_data);
276.2498 +/* read model section and optional data section */
276.2499 +
276.2500 +#define mpl_read_data _glp_mpl_read_data
276.2501 +int mpl_read_data(MPL *mpl, char *file);
276.2502 +/* read data section */
276.2503 +
276.2504 +#define mpl_generate _glp_mpl_generate
276.2505 +int mpl_generate(MPL *mpl, char *file);
276.2506 +/* generate model */
276.2507 +
276.2508 +#define mpl_get_prob_name _glp_mpl_get_prob_name
276.2509 +char *mpl_get_prob_name(MPL *mpl);
276.2510 +/* obtain problem (model) name */
276.2511 +
276.2512 +#define mpl_get_num_rows _glp_mpl_get_num_rows
276.2513 +int mpl_get_num_rows(MPL *mpl);
276.2514 +/* determine number of rows */
276.2515 +
276.2516 +#define mpl_get_num_cols _glp_mpl_get_num_cols
276.2517 +int mpl_get_num_cols(MPL *mpl);
276.2518 +/* determine number of columns */
276.2519 +
276.2520 +#define mpl_get_row_name _glp_mpl_get_row_name
276.2521 +char *mpl_get_row_name(MPL *mpl, int i);
276.2522 +/* obtain row name */
276.2523 +
276.2524 +#define mpl_get_row_kind _glp_mpl_get_row_kind
276.2525 +int mpl_get_row_kind(MPL *mpl, int i);
276.2526 +/* determine row kind */
276.2527 +
276.2528 +#define mpl_get_row_bnds _glp_mpl_get_row_bnds
276.2529 +int mpl_get_row_bnds(MPL *mpl, int i, double *lb, double *ub);
276.2530 +/* obtain row bounds */
276.2531 +
276.2532 +#define mpl_get_mat_row _glp_mpl_get_mat_row
276.2533 +int mpl_get_mat_row(MPL *mpl, int i, int ndx[], double val[]);
276.2534 +/* obtain row of the constraint matrix */
276.2535 +
276.2536 +#define mpl_get_row_c0 _glp_mpl_get_row_c0
276.2537 +double mpl_get_row_c0(MPL *mpl, int i);
276.2538 +/* obtain constant term of free row */
276.2539 +
276.2540 +#define mpl_get_col_name _glp_mpl_get_col_name
276.2541 +char *mpl_get_col_name(MPL *mpl, int j);
276.2542 +/* obtain column name */
276.2543 +
276.2544 +#define mpl_get_col_kind _glp_mpl_get_col_kind
276.2545 +int mpl_get_col_kind(MPL *mpl, int j);
276.2546 +/* determine column kind */
276.2547 +
276.2548 +#define mpl_get_col_bnds _glp_mpl_get_col_bnds
276.2549 +int mpl_get_col_bnds(MPL *mpl, int j, double *lb, double *ub);
276.2550 +/* obtain column bounds */
276.2551 +
276.2552 +#define mpl_has_solve_stmt _glp_mpl_has_solve_stmt
276.2553 +int mpl_has_solve_stmt(MPL *mpl);
276.2554 +/* check if model has solve statement */
276.2555 +
276.2556 +#if 1 /* 15/V-2010 */
276.2557 +#define mpl_put_row_soln _glp_mpl_put_row_soln
276.2558 +void mpl_put_row_soln(MPL *mpl, int i, int stat, double prim,
276.2559 +      double dual);
276.2560 +/* store row (constraint/objective) solution components */
276.2561 +#endif
276.2562 +
276.2563 +#if 1 /* 15/V-2010 */
276.2564 +#define mpl_put_col_soln _glp_mpl_put_col_soln
276.2565 +void mpl_put_col_soln(MPL *mpl, int j, int stat, double prim,
276.2566 +      double dual);
276.2567 +/* store column (variable) solution components */
276.2568 +#endif
276.2569 +
276.2570 +#if 0 /* 15/V-2010 */
276.2571 +#define mpl_put_col_value _glp_mpl_put_col_value
276.2572 +void mpl_put_col_value(MPL *mpl, int j, double val);
276.2573 +/* store column value */
276.2574 +#endif
276.2575 +
276.2576 +#define mpl_postsolve _glp_mpl_postsolve
276.2577 +int mpl_postsolve(MPL *mpl);
276.2578 +/* postsolve model */
276.2579 +
276.2580 +#define mpl_terminate _glp_mpl_terminate
276.2581 +void mpl_terminate(MPL *mpl);
276.2582 +/* free all resources used by translator */
276.2583 +
276.2584 +#endif
276.2585 +
276.2586 +/* eof */
   277.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
   277.2 +++ b/deps/glpk/src/glpmpl01.c	Sun Nov 06 20:59:10 2011 +0100
   277.3 @@ -0,0 +1,4715 @@
   277.4 +/* glpmpl01.c */
   277.5 +
   277.6 +/***********************************************************************
   277.7 +*  This code is part of GLPK (GNU Linear Programming Kit).
   277.8 +*
   277.9 +*  Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008,
  277.10 +*  2009, 2010, 2011 Andrew Makhorin, Department for Applied Informatics,
  277.11 +*  Moscow Aviation Institute, Moscow, Russia. All rights reserved.
  277.12 +*  E-mail: <mao@gnu.org>.
  277.13 +*
  277.14 +*  GLPK is free software: you can redistribute it and/or modify it
  277.15 +*  under the terms of the GNU General Public License as published by
  277.16 +*  the Free Software Foundation, either version 3 of the License, or
  277.17 +*  (at your option) any later version.
  277.18 +*
  277.19 +*  GLPK is distributed in the hope that it will be useful, but WITHOUT
  277.20 +*  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
  277.21 +*  or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
  277.22 +*  License for more details.
  277.23 +*
  277.24 +*  You should have received a copy of the GNU General Public License
  277.25 +*  along with GLPK. If not, see <http://www.gnu.org/licenses/>.
  277.26 +***********************************************************************/
  277.27 +
  277.28 +#define _GLPSTD_STDIO
  277.29 +#include "glpmpl.h"
  277.30 +#define dmp_get_atomv dmp_get_atom
  277.31 +
  277.32 +/**********************************************************************/
  277.33 +/* * *                  PROCESSING MODEL SECTION                  * * */
  277.34 +/**********************************************************************/
  277.35 +
  277.36 +/*----------------------------------------------------------------------
  277.37 +-- enter_context - enter current token into context queue.
  277.38 +--
  277.39 +-- This routine enters the current token into the context queue. */
  277.40 +
  277.41 +void enter_context(MPL *mpl)
  277.42 +{     char *image, *s;
  277.43 +      if (mpl->token == T_EOF)
  277.44 +         image = "_|_";
  277.45 +      else if (mpl->token == T_STRING)
  277.46 +         image = "'...'";
  277.47 +      else
  277.48 +         image = mpl->image;
  277.49 +      xassert(0 <= mpl->c_ptr && mpl->c_ptr < CONTEXT_SIZE);
  277.50 +      mpl->context[mpl->c_ptr++] = ' ';
  277.51 +      if (mpl->c_ptr == CONTEXT_SIZE) mpl->c_ptr = 0;
  277.52 +      for (s = image; *s != '\0'; s++)
  277.53 +      {  mpl->context[mpl->c_ptr++] = *s;
  277.54 +         if (mpl->c_ptr == CONTEXT_SIZE) mpl->c_ptr = 0;
  277.55 +      }
  277.56 +      return;
  277.57 +}
  277.58 +
  277.59 +/*----------------------------------------------------------------------
  277.60 +-- print_context - print current content of context queue.
  277.61 +--
  277.62 +-- This routine prints current content of the context queue. */
  277.63 +
  277.64 +void print_context(MPL *mpl)
  277.65 +{     int c;
  277.66 +      while (mpl->c_ptr > 0)
  277.67 +      {  mpl->c_ptr--;
  277.68 +         c = mpl->context[0];
  277.69 +         memmove(mpl->context, mpl->context+1, CONTEXT_SIZE-1);
  277.70 +         mpl->context[CONTEXT_SIZE-1] = (char)c;
  277.71 +      }
  277.72 +      xprintf("Context: %s%.*s\n", mpl->context[0] == ' ' ? "" : "...",
  277.73 +         CONTEXT_SIZE, mpl->context);
  277.74 +      return;
  277.75 +}
  277.76 +
  277.77 +/*----------------------------------------------------------------------
  277.78 +-- get_char - scan next character from input text file.
  277.79 +--
  277.80 +-- This routine scans a next ASCII character from the input text file.
  277.81 +-- In case of end-of-file, the character is assigned EOF. */
  277.82 +
  277.83 +void get_char(MPL *mpl)
  277.84 +{     int c;
  277.85 +      if (mpl->c == EOF) goto done;
  277.86 +      if (mpl->c == '\n') mpl->line++;
  277.87 +      c = read_char(mpl);
  277.88 +      if (c == EOF)
  277.89 +      {  if (mpl->c == '\n')
  277.90 +            mpl->line--;
  277.91 +         else
  277.92 +            warning(mpl, "final NL missing before end of file");
  277.93 +      }
  277.94 +      else if (c == '\n')
  277.95 +         ;
  277.96 +      else if (isspace(c))
  277.97 +         c = ' ';
  277.98 +      else if (iscntrl(c))
  277.99 +      {  enter_context(mpl);
 277.100 +         error(mpl, "control character 0x%02X not allowed", c);
 277.101 +      }
 277.102 +      mpl->c = c;
 277.103 +done: return;
 277.104 +}
 277.105 +
 277.106 +/*----------------------------------------------------------------------
 277.107 +-- append_char - append character to current token.
 277.108 +--
 277.109 +-- This routine appends the current character to the current token and
 277.110 +-- then scans a next character. */
 277.111 +
 277.112 +void append_char(MPL *mpl)
 277.113 +{     xassert(0 <= mpl->imlen && mpl->imlen <= MAX_LENGTH);
 277.114 +      if (mpl->imlen == MAX_LENGTH)
 277.115 +      {  switch (mpl->token)
 277.116 +         {  case T_NAME:
 277.117 +               enter_context(mpl);
 277.118 +               error(mpl, "symbolic name %s... too long", mpl->image);
 277.119 +            case T_SYMBOL:
 277.120 +               enter_context(mpl);
 277.121 +               error(mpl, "symbol %s... too long", mpl->image);
 277.122 +            case T_NUMBER:
 277.123 +               enter_context(mpl);
 277.124 +               error(mpl, "numeric literal %s... too long", mpl->image);
 277.125 +            case T_STRING:
 277.126 +               enter_context(mpl);
 277.127 +               error(mpl, "string literal too long");
 277.128 +            default:
 277.129 +               xassert(mpl != mpl);
 277.130 +         }
 277.131 +      }
 277.132 +      mpl->image[mpl->imlen++] = (char)mpl->c;
 277.133 +      mpl->image[mpl->imlen] = '\0';
 277.134 +      get_char(mpl);
 277.135 +      return;
 277.136 +}
 277.137 +
 277.138 +/*----------------------------------------------------------------------
 277.139 +-- get_token - scan next token from input text file.
 277.140 +--
 277.141 +-- This routine scans a next token from the input text file using the
 277.142 +-- standard finite automation technique. */
 277.143 +
 277.144 +void get_token(MPL *mpl)
 277.145 +{     /* save the current token */
 277.146 +      mpl->b_token = mpl->token;
 277.147 +      mpl->b_imlen = mpl->imlen;
 277.148 +      strcpy(mpl->b_image, mpl->image);
 277.149 +      mpl->b_value = mpl->value;
 277.150 +      /* if the next token is already scanned, make it current */
 277.151 +      if (mpl->f_scan)
 277.152 +      {  mpl->f_scan = 0;
 277.153 +         mpl->token = mpl->f_token;
 277.154 +         mpl->imlen = mpl->f_imlen;
 277.155 +         strcpy(mpl->image, mpl->f_image);
 277.156 +         mpl->value = mpl->f_value;
 277.157 +         goto done;
 277.158 +      }
 277.159 +loop: /* nothing has been scanned so far */
 277.160 +      mpl->token = 0;
 277.161 +      mpl->imlen = 0;
 277.162 +      mpl->image[0] = '\0';
 277.163 +      mpl->value = 0.0;
 277.164 +      /* skip any uninteresting characters */
 277.165 +      while (mpl->c == ' ' || mpl->c == '\n') get_char(mpl);
 277.166 +      /* recognize and construct the token */
 277.167 +      if (mpl->c == EOF)
 277.168 +      {  /* end-of-file reached */
 277.169 +         mpl->token = T_EOF;
 277.170 +      }
 277.171 +      else if (mpl->c == '#')
 277.172 +      {  /* comment; skip anything until end-of-line */
 277.173 +         while (mpl->c != '\n' && mpl->c != EOF) get_char(mpl);
 277.174 +         goto loop;
 277.175 +      }
 277.176 +      else if (!mpl->flag_d && (isalpha(mpl->c) || mpl->c == '_'))
 277.177 +      {  /* symbolic name or reserved keyword */
 277.178 +         mpl->token = T_NAME;
 277.179 +         while (isalnum(mpl->c) || mpl->c == '_') append_char(mpl);
 277.180 +         if (strcmp(mpl->image, "and") == 0)
 277.181 +            mpl->token = T_AND;
 277.182 +         else if (strcmp(mpl->image, "by") == 0)
 277.183 +            mpl->token = T_BY;
 277.184 +         else if (strcmp(mpl->image, "cross") == 0)
 277.185 +            mpl->token = T_CROSS;
 277.186 +         else if (strcmp(mpl->image, "diff") == 0)
 277.187 +            mpl->token = T_DIFF;
 277.188 +         else if (strcmp(mpl->image, "div") == 0)
 277.189 +            mpl->token = T_DIV;
 277.190 +         else if (strcmp(mpl->image, "else") == 0)
 277.191 +            mpl->token = T_ELSE;
 277.192 +         else if (strcmp(mpl->image, "if") == 0)
 277.193 +            mpl->token = T_IF;
 277.194 +         else if (strcmp(mpl->image, "in") == 0)
 277.195 +            mpl->token = T_IN;
 277.196 +#if 1 /* 21/VII-2006 */
 277.197 +         else if (strcmp(mpl->image, "Infinity") == 0)
 277.198 +            mpl->token = T_INFINITY;
 277.199 +#endif
 277.200 +         else if (strcmp(mpl->image, "inter") == 0)
 277.201 +            mpl->token = T_INTER;
 277.202 +         else if (strcmp(mpl->image, "less") == 0)
 277.203 +            mpl->token = T_LESS;
 277.204 +         else if (strcmp(mpl->image, "mod") == 0)
 277.205 +            mpl->token = T_MOD;
 277.206 +         else if (strcmp(mpl->image, "not") == 0)
 277.207 +            mpl->token = T_NOT;
 277.208 +         else if (strcmp(mpl->image, "or") == 0)
 277.209 +            mpl->token = T_OR;
 277.210 +         else if (strcmp(mpl->image, "s") == 0 && mpl->c == '.')
 277.211 +         {  mpl->token = T_SPTP;
 277.212 +            append_char(mpl);
 277.213 +            if (mpl->c != 't')
 277.214 +sptp:       {  enter_context(mpl);
 277.215 +               error(mpl, "keyword s.t. incomplete");
 277.216 +            }
 277.217 +            append_char(mpl);
 277.218 +            if (mpl->c != '.') goto sptp;
 277.219 +            append_char(mpl);
 277.220 +         }
 277.221 +         else if (strcmp(mpl->image, "symdiff") == 0)
 277.222 +            mpl->token = T_SYMDIFF;
 277.223 +         else if (strcmp(mpl->image, "then") == 0)
 277.224 +            mpl->token = T_THEN;
 277.225 +         else if (strcmp(mpl->image, "union") == 0)
 277.226 +            mpl->token = T_UNION;
 277.227 +         else if (strcmp(mpl->image, "within") == 0)
 277.228 +            mpl->token = T_WITHIN;
 277.229 +      }
 277.230 +      else if (!mpl->flag_d && isdigit(mpl->c))
 277.231 +      {  /* numeric literal */
 277.232 +         mpl->token = T_NUMBER;
 277.233 +         /* scan integer part */
 277.234 +         while (isdigit(mpl->c)) append_char(mpl);
 277.235 +         /* scan optional fractional part */
 277.236 +         if (mpl->c == '.')
 277.237 +         {  append_char(mpl);
 277.238 +            if (mpl->c == '.')
 277.239 +            {  /* hmm, it is not the fractional part, it is dots that
 277.240 +                  follow the integer part */
 277.241 +               mpl->imlen--;
 277.242 +               mpl->image[mpl->imlen] = '\0';
 277.243 +               mpl->f_dots = 1;
 277.244 +               goto conv;
 277.245 +            }
 277.246 +frac:       while (isdigit(mpl->c)) append_char(mpl);
 277.247 +         }
 277.248 +         /* scan optional decimal exponent */
 277.249 +         if (mpl->c == 'e' || mpl->c == 'E')
 277.250 +         {  append_char(mpl);
 277.251 +            if (mpl->c == '+' || mpl->c == '-') append_char(mpl);
 277.252 +            if (!isdigit(mpl->c))
 277.253 +            {  enter_context(mpl);
 277.254 +               error(mpl, "numeric literal %s incomplete", mpl->image);
 277.255 +            }
 277.256 +            while (isdigit(mpl->c)) append_char(mpl);
 277.257 +         }
 277.258 +         /* there must be no letter following the numeric literal */
 277.259 +         if (isalpha(mpl->c) || mpl->c == '_')
 277.260 +         {  enter_context(mpl);
 277.261 +            error(mpl, "symbol %s%c... should be enclosed in quotes",
 277.262 +               mpl->image, mpl->c);
 277.263 +         }
 277.264 +conv:    /* convert numeric literal to floating-point */
 277.265 +         if (str2num(mpl->image, &mpl->value))
 277.266 +err:     {  enter_context(mpl);
 277.267 +            error(mpl, "cannot convert numeric literal %s to floating-p"
 277.268 +               "oint number", mpl->image);
 277.269 +         }
 277.270 +      }
 277.271 +      else if (mpl->c == '\'' || mpl->c == '"')
 277.272 +      {  /* character string */
 277.273 +         int quote = mpl->c;
 277.274 +         mpl->token = T_STRING;
 277.275 +         get_char(mpl);
 277.276 +         for (;;)
 277.277 +         {  if (mpl->c == '\n' || mpl->c == EOF)
 277.278 +            {  enter_context(mpl);
 277.279 +               error(mpl, "unexpected end of line; string literal incom"
 277.280 +                  "plete");
 277.281 +            }
 277.282 +            if (mpl->c == quote)
 277.283 +            {  get_char(mpl);
 277.284 +               if (mpl->c != quote) break;
 277.285 +            }
 277.286 +            append_char(mpl);
 277.287 +         }
 277.288 +      }
 277.289 +      else if (!mpl->flag_d && mpl->c == '+')
 277.290 +         mpl->token = T_PLUS, append_char(mpl);
 277.291 +      else if (!mpl->flag_d && mpl->c == '-')
 277.292 +         mpl->token = T_MINUS, append_char(mpl);
 277.293 +      else if (mpl->c == '*')
 277.294 +      {  mpl->token = T_ASTERISK, append_char(mpl);
 277.295 +         if (mpl->c == '*')
 277.296 +            mpl->token = T_POWER, append_char(mpl);
 277.297 +      }
 277.298 +      else if (mpl->c == '/')
 277.299 +      {  mpl->token = T_SLASH, append_char(mpl);
 277.300 +         if (mpl->c == '*')
 277.301 +         {  /* comment sequence */
 277.302 +            get_char(mpl);
 277.303 +            for (;;)
 277.304 +            {  if (mpl->c == EOF)
 277.305 +               {  /* do not call enter_context at this point */
 277.306 +                  error(mpl, "unexpected end of file; comment sequence "
 277.307 +                     "incomplete");
 277.308 +               }
 277.309 +               else if (mpl->c == '*')
 277.310 +               {  get_char(mpl);
 277.311 +                  if (mpl->c == '/') break;
 277.312 +               }
 277.313 +               else
 277.314 +                  get_char(mpl);
 277.315 +            }
 277.316 +            get_char(mpl);
 277.317 +            goto loop;
 277.318 +         }
 277.319 +      }
 277.320 +      else if (mpl->c == '^')
 277.321 +         mpl->token = T_POWER, append_char(mpl);
 277.322 +      else if (mpl->c == '<')
 277.323 +      {  mpl->token = T_LT, append_char(mpl);
 277.324 +         if (mpl->c == '=')
 277.325 +            mpl->token = T_LE, append_char(mpl);
 277.326 +         else if (mpl->c == '>')
 277.327 +            mpl->token = T_NE, append_char(mpl);
 277.328 +#if 1 /* 11/II-2008 */
 277.329 +         else if (mpl->c == '-')
 277.330 +            mpl->token = T_INPUT, append_char(mpl);
 277.331 +#endif
 277.332 +      }
 277.333 +      else if (mpl->c == '=')
 277.334 +      {  mpl->token = T_EQ, append_char(mpl);
 277.335 +         if (mpl->c == '=') append_char(mpl);
 277.336 +      }
 277.337 +      else if (mpl->c == '>')
 277.338 +      {  mpl->token = T_GT, append_char(mpl);
 277.339 +         if (mpl->c == '=')
 277.340 +            mpl->token = T_GE, append_char(mpl);
 277.341 +#if 1 /* 14/VII-2006 */
 277.342 +         else if (mpl->c == '>')
 277.343 +            mpl->token = T_APPEND, append_char(mpl);
 277.344 +#endif
 277.345 +      }
 277.346 +      else if (mpl->c == '!')
 277.347 +      {  mpl->token = T_NOT, append_char(mpl);
 277.348 +         if (mpl->c == '=')
 277.349 +            mpl->token = T_NE, append_char(mpl);
 277.350 +      }
 277.351 +      else if (mpl->c == '&')
 277.352 +      {  mpl->token = T_CONCAT, append_char(mpl);
 277.353 +         if (mpl->c == '&')
 277.354 +            mpl->token = T_AND, append_char(mpl);
 277.355 +      }
 277.356 +      else if (mpl->c == '|')
 277.357 +      {  mpl->token = T_BAR, append_char(mpl);
 277.358 +         if (mpl->c == '|')
 277.359 +            mpl->token = T_OR, append_char(mpl);
 277.360 +      }
 277.361 +      else if (!mpl->flag_d && mpl->c == '.')
 277.362 +      {  mpl->token = T_POINT, append_char(mpl);
 277.363 +         if (mpl->f_dots)
 277.364 +         {  /* dots; the first dot was read on the previous call to the
 277.365 +               scanner, so the current character is the second dot */
 277.366 +            mpl->token = T_DOTS;
 277.367 +            mpl->imlen = 2;
 277.368 +            strcpy(mpl->image, "..");
 277.369 +            mpl->f_dots = 0;
 277.370 +         }
 277.371 +         else if (mpl->c == '.')
 277.372 +            mpl->token = T_DOTS, append_char(mpl);
 277.373 +         else if (isdigit(mpl->c))
 277.374 +         {  /* numeric literal that begins with the decimal point */
 277.375 +            mpl->token = T_NUMBER, append_char(mpl);
 277.376 +            goto frac;
 277.377 +         }
 277.378 +      }
 277.379 +      else if (mpl->c == ',')
 277.380 +         mpl->token = T_COMMA, append_char(mpl);
 277.381 +      else if (mpl->c == ':')
 277.382 +      {  mpl->token = T_COLON, append_char(mpl);
 277.383 +         if (mpl->c == '=')
 277.384 +            mpl->token = T_ASSIGN, append_char(mpl);
 277.385 +      }
 277.386 +      else if (mpl->c == ';')
 277.387 +         mpl->token = T_SEMICOLON, append_char(mpl);
 277.388 +      else if (mpl->c == '(')
 277.389 +         mpl->token = T_LEFT, append_char(mpl);
 277.390 +      else if (mpl->c == ')')
 277.391 +         mpl->token = T_RIGHT, append_char(mpl);
 277.392 +      else if (mpl->c == '[')
 277.393 +         mpl->token = T_LBRACKET, append_char(mpl);
 277.394 +      else if (mpl->c == ']')
 277.395 +         mpl->token = T_RBRACKET, append_char(mpl);
 277.396 +      else if (mpl->c == '{')
 277.397 +         mpl->token = T_LBRACE, append_char(mpl);
 277.398 +      else if (mpl->c == '}')
 277.399 +         mpl->token = T_RBRACE, append_char(mpl);
 277.400 +#if 1 /* 11/II-2008 */
 277.401 +      else if (mpl->c == '~')
 277.402 +         mpl->token = T_TILDE, append_char(mpl);
 277.403 +#endif
 277.404 +      else if (isalnum(mpl->c) || strchr("+-._", mpl->c) != NULL)
 277.405 +      {  /* symbol */
 277.406 +         xassert(mpl->flag_d);
 277.407 +         mpl->token = T_SYMBOL;
 277.408 +         while (isalnum(mpl->c) || strchr("+-._", mpl->c) != NULL)
 277.409 +            append_char(mpl);
 277.410 +         switch (str2num(mpl->image, &mpl->value))
 277.411 +         {  case 0:
 277.412 +               mpl->token = T_NUMBER;
 277.413 +               break;
 277.414 +            case 1:
 277.415 +               goto err;
 277.416 +            case 2:
 277.417 +               break;
 277.418 +            default:
 277.419 +               xassert(mpl != mpl);
 277.420 +         }
 277.421 +      }
 277.422 +      else
 277.423 +      {  enter_context(mpl);
 277.424 +         error(mpl, "character %c not allowed", mpl->c);
 277.425 +      }
 277.426 +      /* enter the current token into the context queue */
 277.427 +      enter_context(mpl);
 277.428 +      /* reset the flag, which may be set by indexing_expression() and
 277.429 +         is used by expression_list() */
 277.430 +      mpl->flag_x = 0;
 277.431 +done: return;
 277.432 +}
 277.433 +
 277.434 +/*----------------------------------------------------------------------
 277.435 +-- unget_token - return current token back to input stream.
 277.436 +--
 277.437 +-- This routine returns the current token back to the input stream, so
 277.438 +-- the previously scanned token becomes the current one. */
 277.439 +
 277.440 +void unget_token(MPL *mpl)
 277.441 +{     /* save the current token, which becomes the next one */
 277.442 +      xassert(!mpl->f_scan);
 277.443 +      mpl->f_scan = 1;
 277.444 +      mpl->f_token = mpl->token;
 277.445 +      mpl->f_imlen = mpl->imlen;
 277.446 +      strcpy(mpl->f_image, mpl->image);
 277.447 +      mpl->f_value = mpl->value;
 277.448 +      /* restore the previous token, which becomes the current one */
 277.449 +      mpl->token = mpl->b_token;
 277.450 +      mpl->imlen = mpl->b_imlen;
 277.451 +      strcpy(mpl->image, mpl->b_image);
 277.452 +      mpl->value = mpl->b_value;
 277.453 +      return;
 277.454 +}
 277.455 +
 277.456 +/*----------------------------------------------------------------------
 277.457 +-- is_keyword - check if current token is given non-reserved keyword.
 277.458 +--
 277.459 +-- If the current token is given (non-reserved) keyword, this routine
 277.460 +-- returns non-zero. Otherwise zero is returned. */
 277.461 +
 277.462 +int is_keyword(MPL *mpl, char *keyword)
 277.463 +{     return
 277.464 +         mpl->token == T_NAME && strcmp(mpl->image, keyword) == 0;
 277.465 +}
 277.466 +
 277.467 +/*----------------------------------------------------------------------
 277.468 +-- is_reserved - check if current token is reserved keyword.
 277.469 +--
 277.470 +-- If the current token is a reserved keyword, this routine returns
 277.471 +-- non-zero. Otherwise zero is returned. */
 277.472 +
 277.473 +int is_reserved(MPL *mpl)
 277.474 +{     return
 277.475 +         mpl->token == T_AND && mpl->image[0] == 'a' ||
 277.476 +         mpl->token == T_BY ||
 277.477 +         mpl->token == T_CROSS ||
 277.478 +         mpl->token == T_DIFF ||
 277.479 +         mpl->token == T_DIV ||
 277.480 +         mpl->token == T_ELSE ||
 277.481 +         mpl->token == T_IF ||
 277.482 +         mpl->token == T_IN ||
 277.483 +         mpl->token == T_INTER ||
 277.484 +         mpl->token == T_LESS ||
 277.485 +         mpl->token == T_MOD ||
 277.486 +         mpl->token == T_NOT && mpl->image[0] == 'n' ||
 277.487 +         mpl->token == T_OR && mpl->image[0] == 'o' ||
 277.488 +         mpl->token == T_SYMDIFF ||
 277.489 +         mpl->token == T_THEN ||
 277.490 +         mpl->token == T_UNION ||
 277.491 +         mpl->token == T_WITHIN;
 277.492 +}
 277.493 +
 277.494 +/*----------------------------------------------------------------------
 277.495 +-- make_code - generate pseudo-code (basic routine).
 277.496 +--
 277.497 +-- This routine generates specified pseudo-code. It is assumed that all
 277.498 +-- other translator routines use this basic routine. */
 277.499 +
 277.500 +CODE *make_code(MPL *mpl, int op, OPERANDS *arg, int type, int dim)
 277.501 +{     CODE *code;
 277.502 +      DOMAIN *domain;
 277.503 +      DOMAIN_BLOCK *block;
 277.504 +      ARG_LIST *e;
 277.505 +      /* generate pseudo-code */
 277.506 +      code = alloc(CODE);
 277.507 +      code->op = op;
 277.508 +      code->vflag = 0; /* is inherited from operand(s) */
 277.509 +      /* copy operands and also make them referring to the pseudo-code
 277.510 +         being generated, because the latter becomes the parent for all
 277.511 +         its operands */
 277.512 +      memset(&code->arg, '?', sizeof(OPERANDS));
 277.513 +      switch (op)
 277.514 +      {  case O_NUMBER:
 277.515 +            code->arg.num = arg->num;
 277.516 +            break;
 277.517 +         case O_STRING:
 277.518 +            code->arg.str = arg->str;
 277.519 +            break;
 277.520 +         case O_INDEX:
 277.521 +            code->arg.index.slot = arg->index.slot;
 277.522 +            code->arg.index.next = arg->index.next;
 277.523 +            break;
 277.524 +         case O_MEMNUM:
 277.525 +         case O_MEMSYM:
 277.526 +            for (e = arg->par.list; e != NULL; e = e->next)
 277.527 +            {  xassert(e->x != NULL);
 277.528 +               xassert(e->x->up == NULL);
 277.529 +               e->x->up = code;
 277.530 +               code->vflag |= e->x->vflag;
 277.531 +            }
 277.532 +            code->arg.par.par = arg->par.par;
 277.533 +            code->arg.par.list = arg->par.list;
 277.534 +            break;
 277.535 +         case O_MEMSET:
 277.536 +            for (e = arg->set.list; e != NULL; e = e->next)
 277.537 +            {  xassert(e->x != NULL);
 277.538 +               xassert(e->x->up == NULL);
 277.539 +               e->x->up = code;
 277.540 +               code->vflag |= e->x->vflag;
 277.541 +            }
 277.542 +            code->arg.set.set = arg->set.set;
 277.543 +            code->arg.set.list = arg->set.list;
 277.544 +            break;
 277.545 +         case O_MEMVAR:
 277.546 +            for (e = arg->var.list; e != NULL; e = e->next)
 277.547 +            {  xassert(e->x != NULL);
 277.548 +               xassert(e->x->up == NULL);
 277.549 +               e->x->up = code;
 277.550 +               code->vflag |= e->x->vflag;
 277.551 +            }
 277.552 +            code->arg.var.var = arg->var.var;
 277.553 +            code->arg.var.list = arg->var.list;
 277.554 +#if 1 /* 15/V-2010 */
 277.555 +            code->arg.var.suff = arg->var.suff;
 277.556 +#endif
 277.557 +            break;
 277.558 +#if 1 /* 15/V-2010 */
 277.559 +         case O_MEMCON:
 277.560 +            for (e = arg->con.list; e != NULL; e = e->next)
 277.561 +            {  xassert(e->x != NULL);
 277.562 +               xassert(e->x->up == NULL);
 277.563 +               e->x->up = code;
 277.564 +               code->vflag |= e->x->vflag;
 277.565 +            }
 277.566 +            code->arg.con.con = arg->con.con;
 277.567 +            code->arg.con.list = arg->con.list;
 277.568 +            code->arg.con.suff = arg->con.suff;
 277.569 +            break;
 277.570 +#endif
 277.571 +         case O_TUPLE:
 277.572 +         case O_MAKE:
 277.573 +            for (e = arg->list; e != NULL; e = e->next)
 277.574 +            {  xassert(e->x != NULL);
 277.575 +               xassert(e->x->up == NULL);
 277.576 +               e->x->up = code;
 277.577 +               code->vflag |= e->x->vflag;
 277.578 +            }
 277.579 +            code->arg.list = arg->list;
 277.580 +            break;
 277.581 +         case O_SLICE:
 277.582 +            xassert(arg->slice != NULL);
 277.583 +            code->arg.slice = arg->slice;
 277.584 +            break;
 277.585 +         case O_IRAND224:
 277.586 +         case O_UNIFORM01:
 277.587 +         case O_NORMAL01:
 277.588 +         case O_GMTIME:
 277.589 +            code->vflag = 1;
 277.590 +            break;
 277.591 +         case O_CVTNUM:
 277.592 +         case O_CVTSYM:
 277.593 +         case O_CVTLOG:
 277.594 +         case O_CVTTUP:
 277.595 +         case O_CVTLFM:
 277.596 +         case O_PLUS:
 277.597 +         case O_MINUS:
 277.598 +         case O_NOT:
 277.599 +         case O_ABS:
 277.600 +         case O_CEIL:
 277.601 +         case O_FLOOR:
 277.602 +         case O_EXP:
 277.603 +         case O_LOG:
 277.604 +         case O_LOG10:
 277.605 +         case O_SQRT:
 277.606 +         case O_SIN:
 277.607 +         case O_COS:
 277.608 +         case O_ATAN:
 277.609 +         case O_ROUND:
 277.610 +         case O_TRUNC:
 277.611 +         case O_CARD:
 277.612 +         case O_LENGTH:
 277.613 +            /* unary operation */
 277.614 +            xassert(arg->arg.x != NULL);
 277.615 +            xassert(arg->arg.x->up == NULL);
 277.616 +            arg->arg.x->up = code;
 277.617 +            code->vflag |= arg->arg.x->vflag;
 277.618 +            code->arg.arg.x = arg->arg.x;
 277.619 +            break;
 277.620 +         case O_ADD:
 277.621 +         case O_SUB:
 277.622 +         case O_LESS:
 277.623 +         case O_MUL:
 277.624 +         case O_DIV:
 277.625 +         case O_IDIV:
 277.626 +         case O_MOD:
 277.627 +         case O_POWER:
 277.628 +         case O_ATAN2:
 277.629 +         case O_ROUND2:
 277.630 +         case O_TRUNC2:
 277.631 +         case O_UNIFORM:
 277.632 +            if (op == O_UNIFORM) code->vflag = 1;
 277.633 +         case O_NORMAL:
 277.634 +            if (op == O_NORMAL) code->vflag = 1;
 277.635 +         case O_CONCAT:
 277.636 +         case O_LT:
 277.637 +         case O_LE:
 277.638 +         case O_EQ:
 277.639 +         case O_GE:
 277.640 +         case O_GT:
 277.641 +         case O_NE:
 277.642 +         case O_AND:
 277.643 +         case O_OR:
 277.644 +         case O_UNION:
 277.645 +         case O_DIFF:
 277.646 +         case O_SYMDIFF:
 277.647 +         case O_INTER:
 277.648 +         case O_CROSS:
 277.649 +         case O_IN:
 277.650 +         case O_NOTIN:
 277.651 +         case O_WITHIN:
 277.652 +         case O_NOTWITHIN:
 277.653 +         case O_SUBSTR:
 277.654 +         case O_STR2TIME:
 277.655 +         case O_TIME2STR:
 277.656 +            /* binary operation */
 277.657 +            xassert(arg->arg.x != NULL);
 277.658 +            xassert(arg->arg.x->up == NULL);
 277.659 +            arg->arg.x->up = code;
 277.660 +            code->vflag |= arg->arg.x->vflag;
 277.661 +            xassert(arg->arg.y != NULL);
 277.662 +            xassert(arg->arg.y->up == NULL);
 277.663 +            arg->arg.y->up = code;
 277.664 +            code->vflag |= arg->arg.y->vflag;
 277.665 +            code->arg.arg.x = arg->arg.x;
 277.666 +            code->arg.arg.y = arg->arg.y;
 277.667 +            break;
 277.668 +         case O_DOTS:
 277.669 +         case O_FORK:
 277.670 +         case O_SUBSTR3:
 277.671 +            /* ternary operation */
 277.672 +            xassert(arg->arg.x != NULL);
 277.673 +            xassert(arg->arg.x->up == NULL);
 277.674 +            arg->arg.x->up = code;
 277.675 +            code->vflag |= arg->arg.x->vflag;
 277.676 +            xassert(arg->arg.y != NULL);
 277.677 +            xassert(arg->arg.y->up == NULL);
 277.678 +            arg->arg.y->up = code;
 277.679 +            code->vflag |= arg->arg.y->vflag;
 277.680 +            if (arg->arg.z != NULL)
 277.681 +            {  xassert(arg->arg.z->up == NULL);
 277.682 +               arg->arg.z->up = code;
 277.683 +               code->vflag |= arg->arg.z->vflag;
 277.684 +            }
 277.685 +            code->arg.arg.x = arg->arg.x;
 277.686 +            code->arg.arg.y = arg->arg.y;
 277.687 +            code->arg.arg.z = arg->arg.z;
 277.688 +            break;
 277.689 +         case O_MIN:
 277.690 +         case O_MAX:
 277.691 +            /* n-ary operation */
 277.692 +            for (e = arg->list; e != NULL; e = e->next)
 277.693 +            {  xassert(e->x != NULL);
 277.694 +               xassert(e->x->up == NULL);
 277.695 +               e->x->up = code;
 277.696 +               code->vflag |= e->x->vflag;
 277.697 +            }
 277.698 +            code->arg.list = arg->list;
 277.699 +            break;
 277.700 +         case O_SUM:
 277.701 +         case O_PROD:
 277.702 +         case O_MINIMUM:
 277.703 +         case O_MAXIMUM:
 277.704 +         case O_FORALL:
 277.705 +         case O_EXISTS:
 277.706 +         case O_SETOF:
 277.707 +         case O_BUILD:
 277.708 +            /* iterated operation */
 277.709 +            domain = arg->loop.domain;
 277.710 +            xassert(domain != NULL);
 277.711 +            if (domain->code != NULL)
 277.712 +            {  xassert(domain->code->up == NULL);
 277.713 +               domain->code->up = code;
 277.714 +               code->vflag |= domain->code->vflag;
 277.715 +            }
 277.716 +            for (block = domain->list; block != NULL; block =
 277.717 +               block->next)
 277.718 +            {  xassert(block->code != NULL);
 277.719 +               xassert(block->code->up == NULL);
 277.720 +               block->code->up = code;
 277.721 +               code->vflag |= block->code->vflag;
 277.722 +            }
 277.723 +            if (arg->loop.x != NULL)
 277.724 +            {  xassert(arg->loop.x->up == NULL);
 277.725 +               arg->loop.x->up = code;
 277.726 +               code->vflag |= arg->loop.x->vflag;
 277.727 +            }
 277.728 +            code->arg.loop.domain = arg->loop.domain;
 277.729 +            code->arg.loop.x = arg->loop.x;
 277.730 +            break;
 277.731 +         default:
 277.732 +            xassert(op != op);
 277.733 +      }
 277.734 +      /* set other attributes of the pseudo-code */
 277.735 +      code->type = type;
 277.736 +      code->dim = dim;
 277.737 +      code->up = NULL;
 277.738 +      code->valid = 0;
 277.739 +      memset(&code->value, '?', sizeof(VALUE));
 277.740 +      return code;
 277.741 +}
 277.742 +
 277.743 +/*----------------------------------------------------------------------
 277.744 +-- make_unary - generate pseudo-code for unary operation.
 277.745 +--
 277.746 +-- This routine generates pseudo-code for unary operation. */
 277.747 +
 277.748 +CODE *make_unary(MPL *mpl, int op, CODE *x, int type, int dim)
 277.749 +{     CODE *code;
 277.750 +      OPERANDS arg;
 277.751 +      xassert(x != NULL);
 277.752 +      arg.arg.x = x;
 277.753 +      code = make_code(mpl, op, &arg, type, dim);
 277.754 +      return code;
 277.755 +}
 277.756 +
 277.757 +/*----------------------------------------------------------------------
 277.758 +-- make_binary - generate pseudo-code for binary operation.
 277.759 +--
 277.760 +-- This routine generates pseudo-code for binary operation. */
 277.761 +
 277.762 +CODE *make_binary(MPL *mpl, int op, CODE *x, CODE *y, int type,
 277.763 +      int dim)
 277.764 +{     CODE *code;
 277.765 +      OPERANDS arg;
 277.766 +      xassert(x != NULL);
 277.767 +      xassert(y != NULL);
 277.768 +      arg.arg.x = x;
 277.769 +      arg.arg.y = y;
 277.770 +      code = make_code(mpl, op, &arg, type, dim);
 277.771 +      return code;
 277.772 +}
 277.773 +
 277.774 +/*----------------------------------------------------------------------
 277.775 +-- make_ternary - generate pseudo-code for ternary operation.
 277.776 +--
 277.777 +-- This routine generates pseudo-code for ternary operation. */
 277.778 +
 277.779 +CODE *make_ternary(MPL *mpl, int op, CODE *x, CODE *y, CODE *z,
 277.780 +      int type, int dim)
 277.781 +{     CODE *code;
 277.782 +      OPERANDS arg;
 277.783 +      xassert(x != NULL);
 277.784 +      xassert(y != NULL);
 277.785 +      /* third operand can be NULL */
 277.786 +      arg.arg.x = x;
 277.787 +      arg.arg.y = y;
 277.788 +      arg.arg.z = z;
 277.789 +      code = make_code(mpl, op, &arg, type, dim);
 277.790 +      return code;
 277.791 +}
 277.792 +
 277.793 +/*----------------------------------------------------------------------
 277.794 +-- numeric_literal - parse reference to numeric literal.
 277.795 +--
 277.796 +-- This routine parses primary expression using the syntax:
 277.797 +--
 277.798 +-- <primary expression> ::= <numeric literal> */
 277.799 +
 277.800 +CODE *numeric_literal(MPL *mpl)
 277.801 +{     CODE *code;
 277.802 +      OPERANDS arg;
 277.803 +      xassert(mpl->token == T_NUMBER);
 277.804 +      arg.num = mpl->value;
 277.805 +      code = make_code(mpl, O_NUMBER, &arg, A_NUMERIC, 0);
 277.806 +      get_token(mpl /* <numeric literal> */);
 277.807 +      return code;
 277.808 +}
 277.809 +
 277.810 +/*----------------------------------------------------------------------
 277.811 +-- string_literal - parse reference to string literal.
 277.812 +--
 277.813 +-- This routine parses primary expression using the syntax:
 277.814 +--
 277.815 +-- <primary expression> ::= <string literal> */
 277.816 +
 277.817 +CODE *string_literal(MPL *mpl)
 277.818 +{     CODE *code;
 277.819 +      OPERANDS arg;
 277.820 +      xassert(mpl->token == T_STRING);
 277.821 +      arg.str = dmp_get_atomv(mpl->pool, strlen(mpl->image)+1);
 277.822 +      strcpy(arg.str, mpl->image);
 277.823 +      code = make_code(mpl, O_STRING, &arg, A_SYMBOLIC, 0);
 277.824 +      get_token(mpl /* <string literal> */);
 277.825 +      return code;
 277.826 +}
 277.827 +
 277.828 +/*----------------------------------------------------------------------
 277.829 +-- create_arg_list - create empty operands list.
 277.830 +--
 277.831 +-- This routine creates operands list, which is initially empty. */
 277.832 +
 277.833 +ARG_LIST *create_arg_list(MPL *mpl)
 277.834 +{     ARG_LIST *list;
 277.835 +      xassert(mpl == mpl);
 277.836 +      list = NULL;
 277.837 +      return list;
 277.838 +}
 277.839 +
 277.840 +/*----------------------------------------------------------------------
 277.841 +-- expand_arg_list - append operand to operands list.
 277.842 +--
 277.843 +-- This routine appends new operand to specified operands list. */
 277.844 +
 277.845 +ARG_LIST *expand_arg_list(MPL *mpl, ARG_LIST *list, CODE *x)
 277.846 +{     ARG_LIST *tail, *temp;
 277.847 +      xassert(x != NULL);
 277.848 +      /* create new operands list entry */
 277.849 +      tail = alloc(ARG_LIST);
 277.850 +      tail->x = x;
 277.851 +      tail->next = NULL;
 277.852 +      /* and append it to the operands list */
 277.853 +      if (list == NULL)
 277.854 +         list = tail;
 277.855 +      else
 277.856 +      {  for (temp = list; temp->next != NULL; temp = temp->next);
 277.857 +         temp->next = tail;
 277.858 +      }
 277.859 +      return list;
 277.860 +}
 277.861 +
 277.862 +/*----------------------------------------------------------------------
 277.863 +-- arg_list_len - determine length of operands list.
 277.864 +--
 277.865 +-- This routine returns the number of operands in operands list. */
 277.866 +
 277.867 +int arg_list_len(MPL *mpl, ARG_LIST *list)
 277.868 +{     ARG_LIST *temp;
 277.869 +      int len;
 277.870 +      xassert(mpl == mpl);
 277.871 +      len = 0;
 277.872 +      for (temp = list; temp != NULL; temp = temp->next) len++;
 277.873 +      return len;
 277.874 +}
 277.875 +
 277.876 +/*----------------------------------------------------------------------
 277.877 +-- subscript_list - parse subscript list.
 277.878 +--
 277.879 +-- This routine parses subscript list using the syntax:
 277.880 +--
 277.881 +-- <subscript list> ::= <subscript>
 277.882 +-- <subscript list> ::= <subscript list> , <subscript>
 277.883 +-- <subscript> ::= <expression 5> */
 277.884 +
 277.885 +ARG_LIST *subscript_list(MPL *mpl)
 277.886 +{     ARG_LIST *list;
 277.887 +      CODE *x;
 277.888 +      list = create_arg_list(mpl);
 277.889 +      for (;;)
 277.890 +      {  /* parse subscript expression */
 277.891 +         x = expression_5(mpl);
 277.892 +         /* convert it to symbolic type, if necessary */
 277.893 +         if (x->type == A_NUMERIC)
 277.894 +            x = make_unary(mpl, O_CVTSYM, x, A_SYMBOLIC, 0);
 277.895 +         /* check that now the expression is of symbolic type */
 277.896 +         if (x->type != A_SYMBOLIC)
 277.897 +            error(mpl, "subscript expression has invalid type");
 277.898 +         xassert(x->dim == 0);
 277.899 +         /* and append it to the subscript list */
 277.900 +         list = expand_arg_list(mpl, list, x);
 277.901 +         /* check a token that follows the subscript expression */
 277.902 +         if (mpl->token == T_COMMA)
 277.903 +            get_token(mpl /* , */);
 277.904 +         else if (mpl->token == T_RBRACKET)
 277.905 +            break;
 277.906 +         else
 277.907 +            error(mpl, "syntax error in subscript list");
 277.908 +      }
 277.909 +      return list;
 277.910 +}
 277.911 +
 277.912 +#if 1 /* 15/V-2010 */
 277.913 +/*----------------------------------------------------------------------
 277.914 +-- object_reference - parse reference to named object.
 277.915 +--
 277.916 +-- This routine parses primary expression using the syntax:
 277.917 +--
 277.918 +-- <primary expression> ::= <dummy index>
 277.919 +-- <primary expression> ::= <set name>
 277.920 +-- <primary expression> ::= <set name> [ <subscript list> ]
 277.921 +-- <primary expression> ::= <parameter name>
 277.922 +-- <primary expression> ::= <parameter name> [ <subscript list> ]
 277.923 +-- <primary expression> ::= <variable name> <suffix>
 277.924 +-- <primary expression> ::= <variable name> [ <subscript list> ]
 277.925 +--                          <suffix>
 277.926 +-- <primary expression> ::= <constraint name> <suffix>
 277.927 +-- <primary expression> ::= <constraint name> [ <subscript list> ]
 277.928 +--                          <suffix>
 277.929 +-- <dummy index> ::= <symbolic name>
 277.930 +-- <set name> ::= <symbolic name>
 277.931 +-- <parameter name> ::= <symbolic name>
 277.932 +-- <variable name> ::= <symbolic name>
 277.933 +-- <constraint name> ::= <symbolic name>
 277.934 +-- <suffix> ::= <empty> | .lb | .ub | .status | .val | .dual */
 277.935 +
 277.936 +CODE *object_reference(MPL *mpl)
 277.937 +{     AVLNODE *node;
 277.938 +      DOMAIN_SLOT *slot;
 277.939 +      SET *set;
 277.940 +      PARAMETER *par;
 277.941 +      VARIABLE *var;
 277.942 +      CONSTRAINT *con;
 277.943 +      ARG_LIST *list;
 277.944 +      OPERANDS arg;
 277.945 +      CODE *code;
 277.946 +      char *name;
 277.947 +      int dim, suff;
 277.948 +      /* find the object in the symbolic name table */
 277.949 +      xassert(mpl->token == T_NAME);
 277.950 +      node = avl_find_node(mpl->tree, mpl->image);
 277.951 +      if (node == NULL)
 277.952 +         error(mpl, "%s not defined", mpl->image);
 277.953 +      /* check the object type and obtain its dimension */
 277.954 +      switch (avl_get_node_type(node))
 277.955 +      {  case A_INDEX:
 277.956 +            /* dummy index */
 277.957 +            slot = (DOMAIN_SLOT *)avl_get_node_link(node);
 277.958 +            name = slot->name;
 277.959 +            dim = 0;
 277.960 +            break;
 277.961 +         case A_SET:
 277.962 +            /* model set */
 277.963 +            set = (SET *)avl_get_node_link(node);
 277.964 +            name = set->name;
 277.965 +            dim = set->dim;
 277.966 +            /* if a set object is referenced in its own declaration and
 277.967 +               the dimen attribute is not specified yet, use dimen 1 by
 277.968 +               default */
 277.969 +            if (set->dimen == 0) set->dimen = 1;
 277.970 +            break;
 277.971 +         case A_PARAMETER:
 277.972 +            /* model parameter */
 277.973 +            par = (PARAMETER *)avl_get_node_link(node);
 277.974 +            name = par->name;
 277.975 +            dim = par->dim;
 277.976 +            break;
 277.977 +         case A_VARIABLE:
 277.978 +            /* model variable */
 277.979 +            var = (VARIABLE *)avl_get_node_link(node);
 277.980 +            name = var->name;
 277.981 +            dim = var->dim;
 277.982 +            break;
 277.983 +         case A_CONSTRAINT:
 277.984 +            /* model constraint or objective */
 277.985 +            con = (CONSTRAINT *)avl_get_node_link(node);
 277.986 +            name = con->name;
 277.987 +            dim = con->dim;
 277.988 +            break;
 277.989 +         default:
 277.990 +            xassert(node != node);
 277.991 +      }
 277.992 +      get_token(mpl /* <symbolic name> */);
 277.993 +      /* parse optional subscript list */
 277.994 +      if (mpl->token == T_LBRACKET)
 277.995 +      {  /* subscript list is specified */
 277.996 +         if (dim == 0)
 277.997 +            error(mpl, "%s cannot be subscripted", name);
 277.998 +         get_token(mpl /* [ */);
 277.999 +         list = subscript_list(mpl);
277.1000 +         if (dim != arg_list_len(mpl, list))
277.1001 +            error(mpl, "%s must have %d subscript%s rather than %d",
277.1002 +               name, dim, dim == 1 ? "" : "s", arg_list_len(mpl, list));
277.1003 +         xassert(mpl->token == T_RBRACKET);
277.1004 +         get_token(mpl /* ] */);
277.1005 +      }
277.1006 +      else
277.1007 +      {  /* subscript list is not specified */
277.1008 +         if (dim != 0)
277.1009 +            error(mpl, "%s must be subscripted", name);
277.1010 +         list = create_arg_list(mpl);
277.1011 +      }
277.1012 +      /* parse optional suffix */
277.1013 +      if (!mpl->flag_s && avl_get_node_type(node) == A_VARIABLE)
277.1014 +         suff = DOT_NONE;
277.1015 +      else
277.1016 +         suff = DOT_VAL;
277.1017 +      if (mpl->token == T_POINT)
277.1018 +      {  get_token(mpl /* . */);
277.1019 +         if (mpl->token != T_NAME)
277.1020 +            error(mpl, "invalid use of period");
277.1021 +         if (!(avl_get_node_type(node) == A_VARIABLE ||
277.1022 +               avl_get_node_type(node) == A_CONSTRAINT))
277.1023 +            error(mpl, "%s cannot have a suffix", name);
277.1024 +         if (strcmp(mpl->image, "lb") == 0)
277.1025 +            suff = DOT_LB;
277.1026 +         else if (strcmp(mpl->image, "ub") == 0)
277.1027 +            suff = DOT_UB;
277.1028 +         else if (strcmp(mpl->image, "status") == 0)
277.1029 +            suff = DOT_STATUS;
277.1030 +         else if (strcmp(mpl->image, "val") == 0)
277.1031 +            suff = DOT_VAL;
277.1032 +         else if (strcmp(mpl->image, "dual") == 0)
277.1033 +            suff = DOT_DUAL;
277.1034 +         else
277.1035 +            error(mpl, "suffix .%s invalid", mpl->image);
277.1036 +         get_token(mpl /* suffix */);
277.1037 +      }
277.1038 +      /* generate pseudo-code to take value of the object */
277.1039 +      switch (avl_get_node_type(node))
277.1040 +      {  case A_INDEX:
277.1041 +            arg.index.slot = slot;
277.1042 +            arg.index.next = slot->list;
277.1043 +            code = make_code(mpl, O_INDEX, &arg, A_SYMBOLIC, 0);
277.1044 +            slot->list = code;
277.1045 +            break;
277.1046 +         case A_SET:
277.1047 +            arg.set.set = set;
277.1048 +            arg.set.list = list;
277.1049 +            code = make_code(mpl, O_MEMSET, &arg, A_ELEMSET,
277.1050 +               set->dimen);
277.1051 +            break;
277.1052 +         case A_PARAMETER:
277.1053 +            arg.par.par = par;
277.1054 +            arg.par.list = list;
277.1055 +            if (par->type == A_SYMBOLIC)
277.1056 +               code = make_code(mpl, O_MEMSYM, &arg, A_SYMBOLIC, 0);
277.1057 +            else
277.1058 +               code = make_code(mpl, O_MEMNUM, &arg, A_NUMERIC, 0);
277.1059 +            break;
277.1060 +         case A_VARIABLE:
277.1061 +            if (!mpl->flag_s && (suff == DOT_STATUS || suff == DOT_VAL
277.1062 +               || suff == DOT_DUAL))
277.1063 +               error(mpl, "invalid reference to status, primal value, o"
277.1064 +                  "r dual value of variable %s above solve statement",
277.1065 +                  var->name);
277.1066 +            arg.var.var = var;
277.1067 +            arg.var.list = list;
277.1068 +            arg.var.suff = suff;
277.1069 +            code = make_code(mpl, O_MEMVAR, &arg, suff == DOT_NONE ?
277.1070 +               A_FORMULA : A_NUMERIC, 0);
277.1071 +            break;
277.1072 +         case A_CONSTRAINT:
277.1073 +            if (!mpl->flag_s && (suff == DOT_STATUS || suff == DOT_VAL
277.1074 +               || suff == DOT_DUAL))
277.1075 +               error(mpl, "invalid reference to status, primal value, o"
277.1076 +                  "r dual value of %s %s above solve statement",
277.1077 +                  con->type == A_CONSTRAINT ? "constraint" : "objective"
277.1078 +                  , con->name);
277.1079 +            arg.con.con = con;
277.1080 +            arg.con.list = list;
277.1081 +            arg.con.suff = suff;
277.1082 +            code = make_code(mpl, O_MEMCON, &arg, A_NUMERIC, 0);
277.1083 +            break;
277.1084 +         default:
277.1085 +            xassert(node != node);
277.1086 +      }
277.1087 +      return code;
277.1088 +}
277.1089 +#endif
277.1090 +
277.1091 +/*----------------------------------------------------------------------
277.1092 +-- numeric_argument - parse argument passed to built-in function.
277.1093 +--
277.1094 +-- This routine parses an argument passed to numeric built-in function
277.1095 +-- using the syntax:
277.1096 +--
277.1097 +-- <arg> ::= <expression 5> */
277.1098 +
277.1099 +CODE *numeric_argument(MPL *mpl, char *func)
277.1100 +{     CODE *x;
277.1101 +      x = expression_5(mpl);
277.1102 +      /* convert the argument to numeric type, if necessary */
277.1103 +      if (x->type == A_SYMBOLIC)
277.1104 +         x = make_unary(mpl, O_CVTNUM, x, A_NUMERIC, 0);
277.1105 +      /* check that now the argument is of numeric type */
277.1106 +      if (x->type != A_NUMERIC)
277.1107 +         error(mpl, "argument for %s has invalid type", func);
277.1108 +      xassert(x->dim == 0);
277.1109 +      return x;
277.1110 +}
277.1111 +
277.1112 +#if 1 /* 15/VII-2006 */
277.1113 +CODE *symbolic_argument(MPL *mpl, char *func)
277.1114 +{     CODE *x;
277.1115 +      x = expression_5(mpl);
277.1116 +      /* convert the argument to symbolic type, if necessary */
277.1117 +      if (x->type == A_NUMERIC)
277.1118 +         x = make_unary(mpl, O_CVTSYM, x, A_SYMBOLIC, 0);
277.1119 +      /* check that now the argument is of symbolic type */
277.1120 +      if (x->type != A_SYMBOLIC)
277.1121 +         error(mpl, "argument for %s has invalid type", func);
277.1122 +      xassert(x->dim == 0);
277.1123 +      return x;
277.1124 +}
277.1125 +#endif
277.1126 +
277.1127 +#if 1 /* 15/VII-2006 */
277.1128 +CODE *elemset_argument(MPL *mpl, char *func)
277.1129 +{     CODE *x;
277.1130 +      x = expression_9(mpl);
277.1131 +      if (x->type != A_ELEMSET)
277.1132 +         error(mpl, "argument for %s has invalid type", func);
277.1133 +      xassert(x->dim > 0);
277.1134 +      return x;
277.1135 +}
277.1136 +#endif
277.1137 +
277.1138 +/*----------------------------------------------------------------------
277.1139 +-- function_reference - parse reference to built-in function.
277.1140 +--
277.1141 +-- This routine parses primary expression using the syntax:
277.1142 +--
277.1143 +-- <primary expression> ::= abs ( <arg> )
277.1144 +-- <primary expression> ::= ceil ( <arg> )
277.1145 +-- <primary expression> ::= floor ( <arg> )
277.1146 +-- <primary expression> ::= exp ( <arg> )
277.1147 +-- <primary expression> ::= log ( <arg> )
277.1148 +-- <primary expression> ::= log10 ( <arg> )
277.1149 +-- <primary expression> ::= max ( <arg list> )
277.1150 +-- <primary expression> ::= min ( <arg list> )
277.1151 +-- <primary expression> ::= sqrt ( <arg> )
277.1152 +-- <primary expression> ::= sin ( <arg> )
277.1153 +-- <primary expression> ::= cos ( <arg> )
277.1154 +-- <primary expression> ::= atan ( <arg> )
277.1155 +-- <primary expression> ::= atan2 ( <arg> , <arg> )
277.1156 +-- <primary expression> ::= round ( <arg> )
277.1157 +-- <primary expression> ::= round ( <arg> , <arg> )
277.1158 +-- <primary expression> ::= trunc ( <arg> )
277.1159 +-- <primary expression> ::= trunc ( <arg> , <arg> )
277.1160 +-- <primary expression> ::= Irand224 ( )
277.1161 +-- <primary expression> ::= Uniform01 ( )
277.1162 +-- <primary expression> ::= Uniform ( <arg> , <arg> )
277.1163 +-- <primary expression> ::= Normal01 ( )
277.1164 +-- <primary expression> ::= Normal ( <arg> , <arg> )
277.1165 +-- <primary expression> ::= card ( <arg> )
277.1166 +-- <primary expression> ::= length ( <arg> )
277.1167 +-- <primary expression> ::= substr ( <arg> , <arg> )
277.1168 +-- <primary expression> ::= substr ( <arg> , <arg> , <arg> )
277.1169 +-- <primary expression> ::= str2time ( <arg> , <arg> )
277.1170 +-- <primary expression> ::= time2str ( <arg> , <arg> )
277.1171 +-- <primary expression> ::= gmtime ( )
277.1172 +-- <arg list> ::= <arg>
277.1173 +-- <arg list> ::= <arg list> , <arg> */
277.1174 +
277.1175 +CODE *function_reference(MPL *mpl)
277.1176 +{     CODE *code;
277.1177 +      OPERANDS arg;
277.1178 +      int op;
277.1179 +      char func[15+1];
277.1180 +      /* determine operation code */
277.1181 +      xassert(mpl->token == T_NAME);
277.1182 +      if (strcmp(mpl->image, "abs") == 0)
277.1183 +         op = O_ABS;
277.1184 +      else if (strcmp(mpl->image, "ceil") == 0)
277.1185 +         op = O_CEIL;
277.1186 +      else if (strcmp(mpl->image, "floor") == 0)
277.1187 +         op = O_FLOOR;
277.1188 +      else if (strcmp(mpl->image, "exp") == 0)
277.1189 +         op = O_EXP;
277.1190 +      else if (strcmp(mpl->image, "log") == 0)
277.1191 +         op = O_LOG;
277.1192 +      else if (strcmp(mpl->image, "log10") == 0)
277.1193 +         op = O_LOG10;
277.1194 +      else if (strcmp(mpl->image, "sqrt") == 0)
277.1195 +         op = O_SQRT;
277.1196 +      else if (strcmp(mpl->image, "sin") == 0)
277.1197 +         op = O_SIN;
277.1198 +      else if (strcmp(mpl->image, "cos") == 0)
277.1199 +         op = O_COS;
277.1200 +      else if (strcmp(mpl->image, "atan") == 0)
277.1201 +         op = O_ATAN;
277.1202 +      else if (strcmp(mpl->image, "min") == 0)
277.1203 +         op = O_MIN;
277.1204 +      else if (strcmp(mpl->image, "max") == 0)
277.1205 +         op = O_MAX;
277.1206 +      else if (strcmp(mpl->image, "round") == 0)
277.1207 +         op = O_ROUND;
277.1208 +      else if (strcmp(mpl->image, "trunc") == 0)
277.1209 +         op = O_TRUNC;
277.1210 +      else if (strcmp(mpl->image, "Irand224") == 0)
277.1211 +         op = O_IRAND224;
277.1212 +      else if (strcmp(mpl->image, "Uniform01") == 0)
277.1213 +         op = O_UNIFORM01;
277.1214 +      else if (strcmp(mpl->image, "Uniform") == 0)
277.1215 +         op = O_UNIFORM;
277.1216 +      else if (strcmp(mpl->image, "Normal01") == 0)
277.1217 +         op = O_NORMAL01;
277.1218 +      else if (strcmp(mpl->image, "Normal") == 0)
277.1219 +         op = O_NORMAL;
277.1220 +      else if (strcmp(mpl->image, "card") == 0)
277.1221 +         op = O_CARD;
277.1222 +      else if (strcmp(mpl->image, "length") == 0)
277.1223 +         op = O_LENGTH;
277.1224 +      else if (strcmp(mpl->image, "substr") == 0)
277.1225 +         op = O_SUBSTR;
277.1226 +      else if (strcmp(mpl->image, "str2time") == 0)
277.1227 +         op = O_STR2TIME;
277.1228 +      else if (strcmp(mpl->image, "time2str") == 0)
277.1229 +         op = O_TIME2STR;
277.1230 +      else if (strcmp(mpl->image, "gmtime") == 0)
277.1231 +         op = O_GMTIME;
277.1232 +      else
277.1233 +         error(mpl, "function %s unknown", mpl->image);
277.1234 +      /* save symbolic name of the function */
277.1235 +      strcpy(func, mpl->image);
277.1236 +      xassert(strlen(func) < sizeof(func));
277.1237 +      get_token(mpl /* <symbolic name> */);
277.1238 +      /* check the left parenthesis that follows the function name */
277.1239 +      xassert(mpl->token == T_LEFT);
277.1240 +      get_token(mpl /* ( */);
277.1241 +      /* parse argument list */
277.1242 +      if (op == O_MIN || op == O_MAX)
277.1243 +      {  /* min and max allow arbitrary number of arguments */
277.1244 +         arg.list = create_arg_list(mpl);
277.1245 +         /* parse argument list */
277.1246 +         for (;;)
277.1247 +         {  /* parse argument and append it to the operands list */
277.1248 +            arg.list = expand_arg_list(mpl, arg.list,
277.1249 +               numeric_argument(mpl, func));
277.1250 +            /* check a token that follows the argument */
277.1251 +            if (mpl->token == T_COMMA)
277.1252 +               get_token(mpl /* , */);
277.1253 +            else if (mpl->token == T_RIGHT)
277.1254 +               break;
277.1255 +            else
277.1256 +               error(mpl, "syntax error in argument list for %s", func);
277.1257 +         }
277.1258 +      }
277.1259 +      else if (op == O_IRAND224 || op == O_UNIFORM01 || op ==
277.1260 +         O_NORMAL01 || op == O_GMTIME)
277.1261 +      {  /* Irand224, Uniform01, Normal01, gmtime need no arguments */
277.1262 +         if (mpl->token != T_RIGHT)
277.1263 +            error(mpl, "%s needs no arguments", func);
277.1264 +      }
277.1265 +      else if (op == O_UNIFORM || op == O_NORMAL)
277.1266 +      {  /* Uniform and Normal need two arguments */
277.1267 +         /* parse the first argument */
277.1268 +         arg.arg.x = numeric_argument(mpl, func);
277.1269 +         /* check a token that follows the first argument */
277.1270 +         if (mpl->token == T_COMMA)
277.1271 +            ;
277.1272 +         else if (mpl->token == T_RIGHT)
277.1273 +            error(mpl, "%s needs two arguments", func);
277.1274 +         else
277.1275 +            error(mpl, "syntax error in argument for %s", func);
277.1276 +         get_token(mpl /* , */);
277.1277 +         /* parse the second argument */
277.1278 +         arg.arg.y = numeric_argument(mpl, func);
277.1279 +         /* check a token that follows the second argument */
277.1280 +         if (mpl->token == T_COMMA)
277.1281 +            error(mpl, "%s needs two argument", func);
277.1282 +         else if (mpl->token == T_RIGHT)
277.1283 +            ;
277.1284 +         else
277.1285 +            error(mpl, "syntax error in argument for %s", func);
277.1286 +      }
277.1287 +      else if (op == O_ATAN || op == O_ROUND || op == O_TRUNC)
277.1288 +      {  /* atan, round, and trunc need one or two arguments */
277.1289 +         /* parse the first argument */
277.1290 +         arg.arg.x = numeric_argument(mpl, func);
277.1291 +         /* parse the second argument, if specified */
277.1292 +         if (mpl->token == T_COMMA)
277.1293 +         {  switch (op)
277.1294 +            {  case O_ATAN:  op = O_ATAN2;  break;
277.1295 +               case O_ROUND: op = O_ROUND2; break;
277.1296 +               case O_TRUNC: op = O_TRUNC2; break;
277.1297 +               default: xassert(op != op);
277.1298 +            }
277.1299 +            get_token(mpl /* , */);
277.1300 +            arg.arg.y = numeric_argument(mpl, func);
277.1301 +         }
277.1302 +         /* check a token that follows the last argument */
277.1303 +         if (mpl->token == T_COMMA)
277.1304 +            error(mpl, "%s needs one or two arguments", func);
277.1305 +         else if (mpl->token == T_RIGHT)
277.1306 +            ;
277.1307 +         else
277.1308 +            error(mpl, "syntax error in argument for %s", func);
277.1309 +      }
277.1310 +      else if (op == O_SUBSTR)
277.1311 +      {  /* substr needs two or three arguments */
277.1312 +         /* parse the first argument */
277.1313 +         arg.arg.x = symbolic_argument(mpl, func);
277.1314 +         /* check a token that follows the first argument */
277.1315 +         if (mpl->token == T_COMMA)
277.1316 +            ;
277.1317 +         else if (mpl->token == T_RIGHT)
277.1318 +            error(mpl, "%s needs two or three arguments", func);
277.1319 +         else
277.1320 +            error(mpl, "syntax error in argument for %s", func);
277.1321 +         get_token(mpl /* , */);
277.1322 +         /* parse the second argument */
277.1323 +         arg.arg.y = numeric_argument(mpl, func);
277.1324 +         /* parse the third argument, if specified */
277.1325 +         if (mpl->token == T_COMMA)
277.1326 +         {  op = O_SUBSTR3;
277.1327 +            get_token(mpl /* , */);
277.1328 +            arg.arg.z = numeric_argument(mpl, func);
277.1329 +         }
277.1330 +         /* check a token that follows the last argument */
277.1331 +         if (mpl->token == T_COMMA)
277.1332 +            error(mpl, "%s needs two or three arguments", func);
277.1333 +         else if (mpl->token == T_RIGHT)
277.1334 +            ;
277.1335 +         else
277.1336 +            error(mpl, "syntax error in argument for %s", func);
277.1337 +      }
277.1338 +      else if (op == O_STR2TIME)
277.1339 +      {  /* str2time needs two arguments, both symbolic */
277.1340 +         /* parse the first argument */
277.1341 +         arg.arg.x = symbolic_argument(mpl, func);
277.1342 +         /* check a token that follows the first argument */
277.1343 +         if (mpl->token == T_COMMA)
277.1344 +            ;
277.1345 +         else if (mpl->token == T_RIGHT)
277.1346 +            error(mpl, "%s needs two arguments", func);
277.1347 +         else
277.1348 +            error(mpl, "syntax error in argument for %s", func);
277.1349 +         get_token(mpl /* , */);
277.1350 +         /* parse the second argument */
277.1351 +         arg.arg.y = symbolic_argument(mpl, func);
277.1352 +         /* check a token that follows the second argument */
277.1353 +         if (mpl->token == T_COMMA)
277.1354 +            error(mpl, "%s needs two argument", func);
277.1355 +         else if (mpl->token == T_RIGHT)
277.1356 +            ;
277.1357 +         else
277.1358 +            error(mpl, "syntax error in argument for %s", func);
277.1359 +      }
277.1360 +      else if (op == O_TIME2STR)
277.1361 +      {  /* time2str needs two arguments, numeric and symbolic */
277.1362 +         /* parse the first argument */
277.1363 +         arg.arg.x = numeric_argument(mpl, func);
277.1364 +         /* check a token that follows the first argument */
277.1365 +         if (mpl->token == T_COMMA)
277.1366 +            ;
277.1367 +         else if (mpl->token == T_RIGHT)
277.1368 +            error(mpl, "%s needs two arguments", func);
277.1369 +         else
277.1370 +            error(mpl, "syntax error in argument for %s", func);
277.1371 +         get_token(mpl /* , */);
277.1372 +         /* parse the second argument */
277.1373 +         arg.arg.y = symbolic_argument(mpl, func);
277.1374 +         /* check a token that follows the second argument */
277.1375 +         if (mpl->token == T_COMMA)
277.1376 +            error(mpl, "%s needs two argument", func);
277.1377 +         else if (mpl->token == T_RIGHT)
277.1378 +            ;
277.1379 +         else
277.1380 +            error(mpl, "syntax error in argument for %s", func);
277.1381 +      }
277.1382 +      else
277.1383 +      {  /* other functions need one argument */
277.1384 +         if (op == O_CARD)
277.1385 +            arg.arg.x = elemset_argument(mpl, func);
277.1386 +         else if (op == O_LENGTH)
277.1387 +            arg.arg.x = symbolic_argument(mpl, func);
277.1388 +         else
277.1389 +            arg.arg.x = numeric_argument(mpl, func);
277.1390 +         /* check a token that follows the argument */
277.1391 +         if (mpl->token == T_COMMA)
277.1392 +            error(mpl, "%s needs one argument", func);
277.1393 +         else if (mpl->token == T_RIGHT)
277.1394 +            ;
277.1395 +         else
277.1396 +            error(mpl, "syntax error in argument for %s", func);
277.1397 +      }
277.1398 +      /* make pseudo-code to call the built-in function */
277.1399 +      if (op == O_SUBSTR || op == O_SUBSTR3 || op == O_TIME2STR)
277.1400 +         code = make_code(mpl, op, &arg, A_SYMBOLIC, 0);
277.1401 +      else
277.1402 +         code = make_code(mpl, op, &arg, A_NUMERIC, 0);
277.1403 +      /* the reference ends with the right parenthesis */
277.1404 +      xassert(mpl->token == T_RIGHT);
277.1405 +      get_token(mpl /* ) */);
277.1406 +      return code;
277.1407 +}
277.1408 +
277.1409 +/*----------------------------------------------------------------------
277.1410 +-- create_domain - create empty domain.
277.1411 +--
277.1412 +-- This routine creates empty domain, which is initially empty, i.e.
277.1413 +-- has no domain blocks. */
277.1414 +
277.1415 +DOMAIN *create_domain(MPL *mpl)
277.1416 +{     DOMAIN *domain;
277.1417 +      domain = alloc(DOMAIN);
277.1418 +      domain->list = NULL;
277.1419 +      domain->code = NULL;
277.1420 +      return domain;
277.1421 +}
277.1422 +
277.1423 +/*----------------------------------------------------------------------
277.1424 +-- create_block - create empty domain block.
277.1425 +--
277.1426 +-- This routine creates empty domain block, which is initially empty,
277.1427 +-- i.e. has no domain slots. */
277.1428 +
277.1429 +DOMAIN_BLOCK *create_block(MPL *mpl)
277.1430 +{     DOMAIN_BLOCK *block;
277.1431 +      block = alloc(DOMAIN_BLOCK);
277.1432 +      block->list = NULL;
277.1433 +      block->code = NULL;
277.1434 +      block->backup = NULL;
277.1435 +      block->next = NULL;
277.1436 +      return block;
277.1437 +}
277.1438 +
277.1439 +/*----------------------------------------------------------------------
277.1440 +-- append_block - append domain block to specified domain.
277.1441 +--
277.1442 +-- This routine adds given domain block to the end of the block list of
277.1443 +-- specified domain. */
277.1444 +
277.1445 +void append_block(MPL *mpl, DOMAIN *domain, DOMAIN_BLOCK *block)
277.1446 +{     DOMAIN_BLOCK *temp;
277.1447 +      xassert(mpl == mpl);
277.1448 +      xassert(domain != NULL);
277.1449 +      xassert(block != NULL);
277.1450 +      xassert(block->next == NULL);
277.1451 +      if (domain->list == NULL)
277.1452 +         domain->list = block;
277.1453 +      else
277.1454 +      {  for (temp = domain->list; temp->next != NULL; temp =
277.1455 +            temp->next);
277.1456 +         temp->next = block;
277.1457 +      }
277.1458 +      return;
277.1459 +}
277.1460 +
277.1461 +/*----------------------------------------------------------------------
277.1462 +-- append_slot - create and append new slot to domain block.
277.1463 +--
277.1464 +-- This routine creates new domain slot and adds it to the end of slot
277.1465 +-- list of specified domain block.
277.1466 +--
277.1467 +-- The parameter name is symbolic name of the dummy index associated
277.1468 +-- with the slot (the character string must be allocated). NULL means
277.1469 +-- the dummy index is not explicitly specified.
277.1470 +--
277.1471 +-- The parameter code is pseudo-code for computing symbolic value, at
277.1472 +-- which the dummy index is bounded. NULL means the dummy index is free
277.1473 +-- in the domain scope. */
277.1474 +
277.1475 +DOMAIN_SLOT *append_slot(MPL *mpl, DOMAIN_BLOCK *block, char *name,
277.1476 +      CODE *code)
277.1477 +{     DOMAIN_SLOT *slot, *temp;
277.1478 +      xassert(block != NULL);
277.1479 +      slot = alloc(DOMAIN_SLOT);
277.1480 +      slot->name = name;
277.1481 +      slot->code = code;
277.1482 +      slot->value = NULL;
277.1483 +      slot->list = NULL;
277.1484 +      slot->next = NULL;
277.1485 +      if (block->list == NULL)
277.1486 +         block->list = slot;
277.1487 +      else
277.1488 +      {  for (temp = block->list; temp->next != NULL; temp =
277.1489 +            temp->next);
277.1490 +         temp->next = slot;
277.1491 +      }
277.1492 +      return slot;
277.1493 +}
277.1494 +
277.1495 +/*----------------------------------------------------------------------
277.1496 +-- expression_list - parse expression list.
277.1497 +--
277.1498 +-- This routine parses a list of one or more expressions enclosed into
277.1499 +-- the parentheses using the syntax:
277.1500 +--
277.1501 +-- <primary expression> ::= ( <expression list> )
277.1502 +-- <expression list> ::= <expression 13>
277.1503 +-- <expression list> ::= <expression 13> , <expression list>
277.1504 +--
277.1505 +-- Note that this construction may have three different meanings:
277.1506 +--
277.1507 +-- 1. If <expression list> consists of only one expression, <primary
277.1508 +--    expression> is a parenthesized expression, which may be of any
277.1509 +--    valid type (not necessarily 1-tuple).
277.1510 +--
277.1511 +-- 2. If <expression list> consists of several expressions separated by
277.1512 +--    commae, where no expression is undeclared symbolic name, <primary
277.1513 +--    expression> is a n-tuple.
277.1514 +--
277.1515 +-- 3. If <expression list> consists of several expressions separated by
277.1516 +--    commae, where at least one expression is undeclared symbolic name
277.1517 +--    (that denotes a dummy index), <primary expression> is a slice and
277.1518 +--    can be only used as constituent of indexing expression. */
277.1519 +
277.1520 +#define max_dim 20
277.1521 +/* maximal number of components allowed within parentheses */
277.1522 +
277.1523 +CODE *expression_list(MPL *mpl)
277.1524 +{     CODE *code;
277.1525 +      OPERANDS arg;
277.1526 +      struct { char *name; CODE *code; } list[1+max_dim];
277.1527 +      int flag_x, next_token, dim, j, slice = 0;
277.1528 +      xassert(mpl->token == T_LEFT);
277.1529 +      /* the flag, which allows recognizing undeclared symbolic names
277.1530 +         as dummy indices, will be automatically reset by get_token(),
277.1531 +         so save it before scanning the next token */
277.1532 +      flag_x = mpl->flag_x;
277.1533 +      get_token(mpl /* ( */);
277.1534 +      /* parse <expression list> */
277.1535 +      for (dim = 1; ; dim++)
277.1536 +      {  if (dim > max_dim)
277.1537 +            error(mpl, "too many components within parentheses");
277.1538 +         /* current component of <expression list> can be either dummy
277.1539 +            index or expression */
277.1540 +         if (mpl->token == T_NAME)
277.1541 +         {  /* symbolic name is recognized as dummy index only if:
277.1542 +               the flag, which allows that, is set, and
277.1543 +               the name is followed by comma or right parenthesis, and
277.1544 +               the name is undeclared */
277.1545 +            get_token(mpl /* <symbolic name> */);
277.1546 +            next_token = mpl->token;
277.1547 +            unget_token(mpl);
277.1548 +            if (!(flag_x &&
277.1549 +                  (next_token == T_COMMA || next_token == T_RIGHT) &&
277.1550 +                  avl_find_node(mpl->tree, mpl->image) == NULL))
277.1551 +            {  /* this is not dummy index */
277.1552 +               goto expr;
277.1553 +            }
277.1554 +            /* all dummy indices within the same slice must have unique
277.1555 +               symbolic names */
277.1556 +            for (j = 1; j < dim; j++)
277.1557 +            {  if (list[j].name != NULL && strcmp(list[j].name,
277.1558 +                  mpl->image) == 0)
277.1559 +                  error(mpl, "duplicate dummy index %s not allowed",
277.1560 +                     mpl->image);
277.1561 +            }
277.1562 +            /* current component of <expression list> is dummy index */
277.1563 +            list[dim].name
277.1564 +               = dmp_get_atomv(mpl->pool, strlen(mpl->image)+1);
277.1565 +            strcpy(list[dim].name, mpl->image);
277.1566 +            list[dim].code = NULL;
277.1567 +            get_token(mpl /* <symbolic name> */);
277.1568 +            /* <expression list> is a slice, because at least one dummy
277.1569 +               index has appeared */
277.1570 +            slice = 1;
277.1571 +            /* note that the context ( <dummy index> ) is not allowed,
277.1572 +               i.e. in this case <primary expression> is considered as
277.1573 +               a parenthesized expression */
277.1574 +            if (dim == 1 && mpl->token == T_RIGHT)
277.1575 +               error(mpl, "%s not defined", list[dim].name);
277.1576 +         }
277.1577 +         else
277.1578 +expr:    {  /* current component of <expression list> is expression */
277.1579 +            code = expression_13(mpl);
277.1580 +            /* if the current expression is followed by comma or it is
277.1581 +               not the very first expression, entire <expression list>
277.1582 +               is n-tuple or slice, in which case the current expression
277.1583 +               should be converted to symbolic type, if necessary */
277.1584 +            if (mpl->token == T_COMMA || dim > 1)
277.1585 +            {  if (code->type == A_NUMERIC)
277.1586 +                  code = make_unary(mpl, O_CVTSYM, code, A_SYMBOLIC, 0);
277.1587 +               /* now the expression must be of symbolic type */
277.1588 +               if (code->type != A_SYMBOLIC)
277.1589 +                  error(mpl, "component expression has invalid type");
277.1590 +               xassert(code->dim == 0);
277.1591 +            }
277.1592 +            list[dim].name = NULL;
277.1593 +            list[dim].code = code;
277.1594 +         }
277.1595 +         /* check a token that follows the current component */
277.1596 +         if (mpl->token == T_COMMA)
277.1597 +            get_token(mpl /* , */);
277.1598 +         else if (mpl->token == T_RIGHT)
277.1599 +            break;
277.1600 +         else
277.1601 +            error(mpl, "right parenthesis missing where expected");
277.1602 +      }
277.1603 +      /* generate pseudo-code for <primary expression> */
277.1604 +      if (dim == 1 && !slice)
277.1605 +      {  /* <primary expression> is a parenthesized expression */
277.1606 +         code = list[1].code;
277.1607 +      }
277.1608 +      else if (!slice)
277.1609 +      {  /* <primary expression> is a n-tuple */
277.1610 +         arg.list = create_arg_list(mpl);
277.1611 +         for (j = 1; j <= dim; j++)
277.1612 +            arg.list = expand_arg_list(mpl, arg.list, list[j].code);
277.1613 +         code = make_code(mpl, O_TUPLE, &arg, A_TUPLE, dim);
277.1614 +      }
277.1615 +      else
277.1616 +      {  /* <primary expression> is a slice */
277.1617 +         arg.slice = create_block(mpl);
277.1618 +         for (j = 1; j <= dim; j++)
277.1619 +            append_slot(mpl, arg.slice, list[j].name, list[j].code);
277.1620 +         /* note that actually pseudo-codes with op = O_SLICE are never
277.1621 +            evaluated */
277.1622 +         code = make_code(mpl, O_SLICE, &arg, A_TUPLE, dim);
277.1623 +      }
277.1624 +      get_token(mpl /* ) */);
277.1625 +      /* if <primary expression> is a slice, there must be the keyword
277.1626 +         'in', which follows the right parenthesis */
277.1627 +      if (slice && mpl->token != T_IN)
277.1628 +         error(mpl, "keyword in missing where expected");
277.1629 +      /* if the slice flag is set and there is the keyword 'in', which
277.1630 +         follows <primary expression>, the latter must be a slice */
277.1631 +      if (flag_x && mpl->token == T_IN && !slice)
277.1632 +      {  if (dim == 1)
277.1633 +            error(mpl, "syntax error in indexing expression");
277.1634 +         else
277.1635 +            error(mpl, "0-ary slice not allowed");
277.1636 +      }
277.1637 +      return code;
277.1638 +}
277.1639 +
277.1640 +/*----------------------------------------------------------------------
277.1641 +-- literal set - parse literal set.
277.1642 +--
277.1643 +-- This routine parses literal set using the syntax:
277.1644 +--
277.1645 +-- <literal set> ::= { <member list> }
277.1646 +-- <member list> ::= <member expression>
277.1647 +-- <member list> ::= <member list> , <member expression>
277.1648 +-- <member expression> ::= <expression 5>
277.1649 +--
277.1650 +-- It is assumed that the left curly brace and the very first member
277.1651 +-- expression that follows it are already parsed. The right curly brace
277.1652 +-- remains unscanned on exit. */
277.1653 +
277.1654 +CODE *literal_set(MPL *mpl, CODE *code)
277.1655 +{     OPERANDS arg;
277.1656 +      int j;
277.1657 +      xassert(code != NULL);
277.1658 +      arg.list = create_arg_list(mpl);
277.1659 +      /* parse <member list> */
277.1660 +      for (j = 1; ; j++)
277.1661 +      {  /* all member expressions must be n-tuples; so, if the current
277.1662 +            expression is not n-tuple, convert it to 1-tuple */
277.1663 +         if (code->type == A_NUMERIC)
277.1664 +            code = make_unary(mpl, O_CVTSYM, code, A_SYMBOLIC, 0);
277.1665 +         if (code->type == A_SYMBOLIC)
277.1666 +            code = make_unary(mpl, O_CVTTUP, code, A_TUPLE, 1);
277.1667 +         /* now the expression must be n-tuple */
277.1668 +         if (code->type != A_TUPLE)
277.1669 +            error(mpl, "member expression has invalid type");
277.1670 +         /* all member expressions must have identical dimension */
277.1671 +         if (arg.list != NULL && arg.list->x->dim != code->dim)
277.1672 +            error(mpl, "member %d has %d component%s while member %d ha"
277.1673 +               "s %d component%s",
277.1674 +               j-1, arg.list->x->dim, arg.list->x->dim == 1 ? "" : "s",
277.1675 +               j, code->dim, code->dim == 1 ? "" : "s");
277.1676 +         /* append the current expression to the member list */
277.1677 +         arg.list = expand_arg_list(mpl, arg.list, code);
277.1678 +         /* check a token that follows the current expression */
277.1679 +         if (mpl->token == T_COMMA)
277.1680 +            get_token(mpl /* , */);
277.1681 +         else if (mpl->token == T_RBRACE)
277.1682 +            break;
277.1683 +         else
277.1684 +            error(mpl, "syntax error in literal set");
277.1685 +         /* parse the next expression that follows the comma */
277.1686 +         code = expression_5(mpl);
277.1687 +      }
277.1688 +      /* generate pseudo-code for <literal set> */
277.1689 +      code = make_code(mpl, O_MAKE, &arg, A_ELEMSET, arg.list->x->dim);
277.1690 +      return code;
277.1691 +}
277.1692 +
277.1693 +/*----------------------------------------------------------------------
277.1694 +-- indexing_expression - parse indexing expression.
277.1695 +--
277.1696 +-- This routine parses indexing expression using the syntax:
277.1697 +--
277.1698 +-- <indexing expression> ::= <literal set>
277.1699 +-- <indexing expression> ::= { <indexing list> }
277.1700 +-- <indexing expression> ::= { <indexing list> : <logical expression> }
277.1701 +-- <indexing list> ::= <indexing element>
277.1702 +-- <indexing list> ::= <indexing list> , <indexing element>
277.1703 +-- <indexing element> ::= <basic expression>
277.1704 +-- <indexing element> ::= <dummy index> in <basic expression>
277.1705 +-- <indexing element> ::= <slice> in <basic expression>
277.1706 +-- <dummy index> ::= <symbolic name>
277.1707 +-- <slice> ::= ( <expression list> )
277.1708 +-- <basic expression> ::= <expression 9>
277.1709 +-- <logical expression> ::= <expression 13>
277.1710 +--
277.1711 +-- This routine creates domain for <indexing expression>, where each
277.1712 +-- domain block corresponds to <indexing element>, and each domain slot
277.1713 +-- corresponds to individual indexing position. */
277.1714 +
277.1715 +DOMAIN *indexing_expression(MPL *mpl)
277.1716 +{     DOMAIN *domain;
277.1717 +      DOMAIN_BLOCK *block;
277.1718 +      DOMAIN_SLOT *slot;
277.1719 +      CODE *code;
277.1720 +      xassert(mpl->token == T_LBRACE);
277.1721 +      get_token(mpl /* { */);
277.1722 +      if (mpl->token == T_RBRACE)
277.1723 +         error(mpl, "empty indexing expression not allowed");
277.1724 +      /* create domain to be constructed */
277.1725 +      domain = create_domain(mpl);
277.1726 +      /* parse either <member list> or <indexing list> that follows the
277.1727 +         left brace */
277.1728 +      for (;;)
277.1729 +      {  /* domain block for <indexing element> is not created yet */
277.1730 +         block = NULL;
277.1731 +         /* pseudo-code for <basic expression> is not generated yet */
277.1732 +         code = NULL;
277.1733 +         /* check a token, which <indexing element> begins with */
277.1734 +         if (mpl->token == T_NAME)
277.1735 +         {  /* it is a symbolic name */
277.1736 +            int next_token;
277.1737 +            char *name;
277.1738 +            /* symbolic name is recognized as dummy index only if it is
277.1739 +               followed by the keyword 'in' and not declared */
277.1740 +            get_token(mpl /* <symbolic name> */);
277.1741 +            next_token = mpl->token;
277.1742 +            unget_token(mpl);
277.1743 +            if (!(next_token == T_IN &&
277.1744 +                  avl_find_node(mpl->tree, mpl->image) == NULL))
277.1745 +            {  /* this is not dummy index; the symbolic name begins an
277.1746 +                  expression, which is either <basic expression> or the
277.1747 +                  very first <member expression> in <literal set> */
277.1748 +               goto expr;
277.1749 +            }
277.1750 +            /* create domain block with one slot, which is assigned the
277.1751 +               dummy index */
277.1752 +            block = create_block(mpl);
277.1753 +            name = dmp_get_atomv(mpl->pool, strlen(mpl->image)+1);
277.1754 +            strcpy(name, mpl->image);
277.1755 +            append_slot(mpl, block, name, NULL);
277.1756 +            get_token(mpl /* <symbolic name> */);
277.1757 +            /* the keyword 'in' is already checked above */
277.1758 +            xassert(mpl->token == T_IN);
277.1759 +            get_token(mpl /* in */);
277.1760 +            /* <basic expression> that follows the keyword 'in' will be
277.1761 +               parsed below */
277.1762 +         }
277.1763 +         else if (mpl->token == T_LEFT)
277.1764 +         {  /* it is the left parenthesis; parse expression that begins
277.1765 +               with this parenthesis (the flag is set in order to allow
277.1766 +               recognizing slices; see the routine expression_list) */
277.1767 +            mpl->flag_x = 1;
277.1768 +            code = expression_9(mpl);
277.1769 +            if (code->op != O_SLICE)
277.1770 +            {  /* this is either <basic expression> or the very first
277.1771 +                  <member expression> in <literal set> */
277.1772 +               goto expr;
277.1773 +            }
277.1774 +            /* this is a slice; besides the corresponding domain block
277.1775 +               is already created by expression_list() */
277.1776 +            block = code->arg.slice;
277.1777 +            code = NULL; /* <basic expression> is not parsed yet */
277.1778 +            /* the keyword 'in' following the slice is already checked
277.1779 +               by expression_list() */
277.1780 +            xassert(mpl->token == T_IN);
277.1781 +            get_token(mpl /* in */);
277.1782 +            /* <basic expression> that follows the keyword 'in' will be
277.1783 +               parsed below */
277.1784 +         }
277.1785 +expr:    /* parse expression that follows either the keyword 'in' (in
277.1786 +            which case it can be <basic expression) or the left brace
277.1787 +            (in which case it can be <basic expression> as well as the
277.1788 +            very first <member expression> in <literal set>); note that
277.1789 +            this expression can be already parsed above */
277.1790 +         if (code == NULL) code = expression_9(mpl);
277.1791 +         /* check the type of the expression just parsed */
277.1792 +         if (code->type != A_ELEMSET)
277.1793 +         {  /* it is not <basic expression> and therefore it can only
277.1794 +               be the very first <member expression> in <literal set>;
277.1795 +               however, then there must be no dummy index neither slice
277.1796 +               between the left brace and this expression */
277.1797 +            if (block != NULL)
277.1798 +               error(mpl, "domain expression has invalid type");
277.1799 +            /* parse the rest part of <literal set> and make this set
277.1800 +               be <basic expression>, i.e. the construction {a, b, c}
277.1801 +               is parsed as it were written as {A}, where A = {a, b, c}
277.1802 +               is a temporary elemental set */
277.1803 +            code = literal_set(mpl, code);
277.1804 +         }
277.1805 +         /* now pseudo-code for <basic set> has been built */
277.1806 +         xassert(code != NULL);
277.1807 +         xassert(code->type == A_ELEMSET);
277.1808 +         xassert(code->dim > 0);
277.1809 +         /* if domain block for the current <indexing element> is still
277.1810 +            not created, create it for fake slice of the same dimension
277.1811 +            as <basic set> */
277.1812 +         if (block == NULL)
277.1813 +         {  int j;
277.1814 +            block = create_block(mpl);
277.1815 +            for (j = 1; j <= code->dim; j++)
277.1816 +               append_slot(mpl, block, NULL, NULL);
277.1817 +         }
277.1818 +         /* number of indexing positions in <indexing element> must be
277.1819 +            the same as dimension of n-tuples in basic set */
277.1820 +         {  int dim = 0;
277.1821 +            for (slot = block->list; slot != NULL; slot = slot->next)
277.1822 +               dim++;
277.1823 +            if (dim != code->dim)
277.1824 +               error(mpl,"%d %s specified for set of dimension %d",
277.1825 +                  dim, dim == 1 ? "index" : "indices", code->dim);
277.1826 +         }
277.1827 +         /* store pseudo-code for <basic set> in the domain block */
277.1828 +         xassert(block->code == NULL);
277.1829 +         block->code = code;
277.1830 +         /* and append the domain block to the domain */
277.1831 +         append_block(mpl, domain, block);
277.1832 +         /* the current <indexing element> has been completely parsed;
277.1833 +            include all its dummy indices into the symbolic name table
277.1834 +            to make them available for referencing from expressions;
277.1835 +            implicit declarations of dummy indices remain valid while
277.1836 +            the corresponding domain scope is valid */
277.1837 +         for (slot = block->list; slot != NULL; slot = slot->next)
277.1838 +         if (slot->name != NULL)
277.1839 +         {  AVLNODE *node;
277.1840 +            xassert(avl_find_node(mpl->tree, slot->name) == NULL);
277.1841 +            node = avl_insert_node(mpl->tree, slot->name);
277.1842 +            avl_set_node_type(node, A_INDEX);
277.1843 +            avl_set_node_link(node, (void *)slot);
277.1844 +         }
277.1845 +         /* check a token that follows <indexing element> */
277.1846 +         if (mpl->token == T_COMMA)
277.1847 +            get_token(mpl /* , */);
277.1848 +         else if (mpl->token == T_COLON || mpl->token == T_RBRACE)
277.1849 +            break;
277.1850 +         else
277.1851 +            error(mpl, "syntax error in indexing expression");
277.1852 +      }
277.1853 +      /* parse <logical expression> that follows the colon */
277.1854 +      if (mpl->token == T_COLON)
277.1855 +      {  get_token(mpl /* : */);
277.1856 +         code = expression_13(mpl);
277.1857 +         /* convert the expression to logical type, if necessary */
277.1858 +         if (code->type == A_SYMBOLIC)
277.1859 +            code = make_unary(mpl, O_CVTNUM, code, A_NUMERIC, 0);
277.1860 +         if (code->type == A_NUMERIC)
277.1861 +            code = make_unary(mpl, O_CVTLOG, code, A_LOGICAL, 0);
277.1862 +         /* now the expression must be of logical type */
277.1863 +         if (code->type != A_LOGICAL)
277.1864 +            error(mpl, "expression following colon has invalid type");
277.1865 +         xassert(code->dim == 0);
277.1866 +         domain->code = code;
277.1867 +         /* the right brace must follow the logical expression */
277.1868 +         if (mpl->token != T_RBRACE)
277.1869 +            error(mpl, "syntax error in indexing expression");
277.1870 +      }
277.1871 +      get_token(mpl /* } */);
277.1872 +      return domain;
277.1873 +}
277.1874 +
277.1875 +/*----------------------------------------------------------------------
277.1876 +-- close_scope - close scope of indexing expression.
277.1877 +--
277.1878 +-- The routine closes the scope of indexing expression specified by its
277.1879 +-- domain and thereby makes all dummy indices introduced in the indexing
277.1880 +-- expression no longer available for referencing. */
277.1881 +
277.1882 +void close_scope(MPL *mpl, DOMAIN *domain)
277.1883 +{     DOMAIN_BLOCK *block;
277.1884 +      DOMAIN_SLOT *slot;
277.1885 +      AVLNODE *node;
277.1886 +      xassert(domain != NULL);
277.1887 +      /* remove all dummy indices from the symbolic names table */
277.1888 +      for (block = domain->list; block != NULL; block = block->next)
277.1889 +      {  for (slot = block->list; slot != NULL; slot = slot->next)
277.1890 +         {  if (slot->name != NULL)
277.1891 +            {  node = avl_find_node(mpl->tree, slot->name);
277.1892 +               xassert(node != NULL);
277.1893 +               xassert(avl_get_node_type(node) == A_INDEX);
277.1894 +               avl_delete_node(mpl->tree, node);
277.1895 +            }
277.1896 +         }
277.1897 +      }
277.1898 +      return;
277.1899 +}
277.1900 +
277.1901 +/*----------------------------------------------------------------------
277.1902 +-- iterated_expression - parse iterated expression.
277.1903 +--
277.1904 +-- This routine parses primary expression using the syntax:
277.1905 +--
277.1906 +-- <primary expression> ::= <iterated expression>
277.1907 +-- <iterated expression> ::= sum <indexing expression> <expression 3>
277.1908 +-- <iterated expression> ::= prod <indexing expression> <expression 3>
277.1909 +-- <iterated expression> ::= min <indexing expression> <expression 3>
277.1910 +-- <iterated expression> ::= max <indexing expression> <expression 3>
277.1911 +-- <iterated expression> ::= exists <indexing expression>
277.1912 +--                           <expression 12>
277.1913 +-- <iterated expression> ::= forall <indexing expression>
277.1914 +--                           <expression 12>
277.1915 +-- <iterated expression> ::= setof <indexing expression> <expression 5>
277.1916 +--
277.1917 +-- Note that parsing "integrand" depends on the iterated operator. */
277.1918 +
277.1919 +#if 1 /* 07/IX-2008 */
277.1920 +static void link_up(CODE *code)
277.1921 +{     /* if we have something like sum{(i+1,j,k-1) in E} x[i,j,k],
277.1922 +         where i and k are dummy indices defined out of the iterated
277.1923 +         expression, we should link up pseudo-code for computing i+1
277.1924 +         and k-1 to pseudo-code for computing the iterated expression;
277.1925 +         this is needed to invalidate current value of the iterated
277.1926 +         expression once i or k have been changed */
277.1927 +      DOMAIN_BLOCK *block;
277.1928 +      DOMAIN_SLOT *slot;
277.1929 +      for (block = code->arg.loop.domain->list; block != NULL;
277.1930 +         block = block->next)
277.1931 +      {  for (slot = block->list; slot != NULL; slot = slot->next)
277.1932 +         {  if (slot->code != NULL)
277.1933 +            {  xassert(slot->code->up == NULL);
277.1934 +               slot->code->up = code;
277.1935 +            }
277.1936 +         }
277.1937 +      }
277.1938 +      return;
277.1939 +}
277.1940 +#endif
277.1941 +
277.1942 +CODE *iterated_expression(MPL *mpl)
277.1943 +{     CODE *code;
277.1944 +      OPERANDS arg;
277.1945 +      int op;
277.1946 +      char opstr[8];
277.1947 +      /* determine operation code */
277.1948 +      xassert(mpl->token == T_NAME);
277.1949 +      if (strcmp(mpl->image, "sum") == 0)
277.1950 +         op = O_SUM;
277.1951 +      else if (strcmp(mpl->image, "prod") == 0)
277.1952 +         op = O_PROD;
277.1953 +      else if (strcmp(mpl->image, "min") == 0)
277.1954 +         op = O_MINIMUM;
277.1955 +      else if (strcmp(mpl->image, "max") == 0)
277.1956 +         op = O_MAXIMUM;
277.1957 +      else if (strcmp(mpl->image, "forall") == 0)
277.1958 +         op = O_FORALL;
277.1959 +      else if (strcmp(mpl->image, "exists") == 0)
277.1960 +         op = O_EXISTS;
277.1961 +      else if (strcmp(mpl->image, "setof") == 0)
277.1962 +         op = O_SETOF;
277.1963 +      else
277.1964 +         error(mpl, "operator %s unknown", mpl->image);
277.1965 +      strcpy(opstr, mpl->image);
277.1966 +      xassert(strlen(opstr) < sizeof(opstr));
277.1967 +      get_token(mpl /* <symbolic name> */);
277.1968 +      /* check the left brace that follows the operator name */
277.1969 +      xassert(mpl->token == T_LBRACE);
277.1970 +      /* parse indexing expression that controls iterating */
277.1971 +      arg.loop.domain = indexing_expression(mpl);
277.1972 +      /* parse "integrand" expression and generate pseudo-code */
277.1973 +      switch (op)
277.1974 +      {  case O_SUM:
277.1975 +         case O_PROD:
277.1976 +         case O_MINIMUM:
277.1977 +         case O_MAXIMUM:
277.1978 +            arg.loop.x = expression_3(mpl);
277.1979 +            /* convert the integrand to numeric type, if necessary */
277.1980 +            if (arg.loop.x->type == A_SYMBOLIC)
277.1981 +               arg.loop.x = make_unary(mpl, O_CVTNUM, arg.loop.x,
277.1982 +                  A_NUMERIC, 0);
277.1983 +            /* now the integrand must be of numeric type or linear form
277.1984 +               (the latter is only allowed for the sum operator) */
277.1985 +            if (!(arg.loop.x->type == A_NUMERIC ||
277.1986 +                  op == O_SUM && arg.loop.x->type == A_FORMULA))
277.1987 +err:           error(mpl, "integrand following %s{...} has invalid type"
277.1988 +                  , opstr);
277.1989 +            xassert(arg.loop.x->dim == 0);
277.1990 +            /* generate pseudo-code */
277.1991 +            code = make_code(mpl, op, &arg, arg.loop.x->type, 0);
277.1992 +            break;
277.1993 +         case O_FORALL:
277.1994 +         case O_EXISTS:
277.1995 +            arg.loop.x = expression_12(mpl);
277.1996 +            /* convert the integrand to logical type, if necessary */
277.1997 +            if (arg.loop.x->type == A_SYMBOLIC)
277.1998 +               arg.loop.x = make_unary(mpl, O_CVTNUM, arg.loop.x,
277.1999 +                  A_NUMERIC, 0);
277.2000 +            if (arg.loop.x->type == A_NUMERIC)
277.2001 +               arg.loop.x = make_unary(mpl, O_CVTLOG, arg.loop.x,
277.2002 +                  A_LOGICAL, 0);
277.2003 +            /* now the integrand must be of logical type */
277.2004 +            if (arg.loop.x->type != A_LOGICAL) goto err;
277.2005 +            xassert(arg.loop.x->dim == 0);
277.2006 +            /* generate pseudo-code */
277.2007 +            code = make_code(mpl, op, &arg, A_LOGICAL, 0);
277.2008 +            break;
277.2009 +         case O_SETOF:
277.2010 +            arg.loop.x = expression_5(mpl);
277.2011 +            /* convert the integrand to 1-tuple, if necessary */
277.2012 +            if (arg.loop.x->type == A_NUMERIC)
277.2013 +               arg.loop.x = make_unary(mpl, O_CVTSYM, arg.loop.x,
277.2014 +                  A_SYMBOLIC, 0);
277.2015 +            if (arg.loop.x->type == A_SYMBOLIC)
277.2016 +               arg.loop.x = make_unary(mpl, O_CVTTUP, arg.loop.x,
277.2017 +                  A_TUPLE, 1);
277.2018 +            /* now the integrand must be n-tuple */
277.2019 +            if (arg.loop.x->type != A_TUPLE) goto err;
277.2020 +            xassert(arg.loop.x->dim > 0);
277.2021 +            /* generate pseudo-code */
277.2022 +            code = make_code(mpl, op, &arg, A_ELEMSET, arg.loop.x->dim);
277.2023 +            break;
277.2024 +         default:
277.2025 +            xassert(op != op);
277.2026 +      }
277.2027 +      /* close the scope of the indexing expression */
277.2028 +      close_scope(mpl, arg.loop.domain);
277.2029 +#if 1 /* 07/IX-2008 */
277.2030 +      link_up(code);
277.2031 +#endif
277.2032 +      return code;
277.2033 +}
277.2034 +
277.2035 +/*----------------------------------------------------------------------
277.2036 +-- domain_arity - determine arity of domain.
277.2037 +--
277.2038 +-- This routine returns arity of specified domain, which is number of
277.2039 +-- its free dummy indices. */
277.2040 +
277.2041 +int domain_arity(MPL *mpl, DOMAIN *domain)
277.2042 +{     DOMAIN_BLOCK *block;
277.2043 +      DOMAIN_SLOT *slot;
277.2044 +      int arity;
277.2045 +      xassert(mpl == mpl);
277.2046 +      arity = 0;
277.2047 +      for (block = domain->list; block != NULL; block = block->next)
277.2048 +         for (slot = block->list; slot != NULL; slot = slot->next)
277.2049 +            if (slot->code == NULL) arity++;
277.2050 +      return arity;
277.2051 +}
277.2052 +
277.2053 +/*----------------------------------------------------------------------
277.2054 +-- set_expression - parse set expression.
277.2055 +--
277.2056 +-- This routine parses primary expression using the syntax:
277.2057 +--
277.2058 +-- <primary expression> ::= { }
277.2059 +-- <primary expression> ::= <indexing expression> */
277.2060 +
277.2061 +CODE *set_expression(MPL *mpl)
277.2062 +{     CODE *code;
277.2063 +      OPERANDS arg;
277.2064 +      xassert(mpl->token == T_LBRACE);
277.2065 +      get_token(mpl /* { */);
277.2066 +      /* check a token that follows the left brace */
277.2067 +      if (mpl->token == T_RBRACE)
277.2068 +      {  /* it is the right brace, so the resultant is an empty set of
277.2069 +            dimension 1 */
277.2070 +         arg.list = NULL;
277.2071 +         /* generate pseudo-code to build the resultant set */
277.2072 +         code = make_code(mpl, O_MAKE, &arg, A_ELEMSET, 1);
277.2073 +         get_token(mpl /* } */);
277.2074 +      }
277.2075 +      else
277.2076 +      {  /* the next token begins an indexing expression */
277.2077 +         unget_token(mpl);
277.2078 +         arg.loop.domain = indexing_expression(mpl);
277.2079 +         arg.loop.x = NULL; /* integrand is not used */
277.2080 +         /* close the scope of the indexing expression */
277.2081 +         close_scope(mpl, arg.loop.domain);
277.2082 +         /* generate pseudo-code to build the resultant set */
277.2083 +         code = make_code(mpl, O_BUILD, &arg, A_ELEMSET,
277.2084 +            domain_arity(mpl, arg.loop.domain));
277.2085 +#if 1 /* 07/IX-2008 */
277.2086 +         link_up(code);
277.2087 +#endif
277.2088 +      }
277.2089 +      return code;
277.2090 +}
277.2091 +
277.2092 +/*----------------------------------------------------------------------
277.2093 +-- branched_expression - parse conditional expression.
277.2094 +--
277.2095 +-- This routine parses primary expression using the syntax:
277.2096 +--
277.2097 +-- <primary expression> ::= <branched expression>
277.2098 +-- <branched expression> ::= if <logical expression> then <expression 9>
277.2099 +-- <branched expression> ::= if <logical expression> then <expression 9>
277.2100 +--                           else <expression 9>
277.2101 +-- <logical expression> ::= <expression 13> */
277.2102 +
277.2103 +CODE *branched_expression(MPL *mpl)
277.2104 +{     CODE *code, *x, *y, *z;
277.2105 +      xassert(mpl->token == T_IF);
277.2106 +      get_token(mpl /* if */);
277.2107 +      /* parse <logical expression> that follows 'if' */
277.2108 +      x = expression_13(mpl);
277.2109 +      /* convert the expression to logical type, if necessary */
277.2110 +      if (x->type == A_SYMBOLIC)
277.2111 +         x = make_unary(mpl, O_CVTNUM, x, A_NUMERIC, 0);
277.2112 +      if (x->type == A_NUMERIC)
277.2113 +         x = make_unary(mpl, O_CVTLOG, x, A_LOGICAL, 0);
277.2114 +      /* now the expression must be of logical type */
277.2115 +      if (x->type != A_LOGICAL)
277.2116 +         error(mpl, "expression following if has invalid type");
277.2117 +      xassert(x->dim == 0);
277.2118 +      /* the keyword 'then' must follow the logical expression */
277.2119 +      if (mpl->token != T_THEN)
277.2120 +         error(mpl, "keyword then missing where expected");
277.2121 +      get_token(mpl /* then */);
277.2122 +      /* parse <expression> that follows 'then' and check its type */
277.2123 +      y = expression_9(mpl);
277.2124 +      if (!(y->type == A_NUMERIC || y->type == A_SYMBOLIC ||
277.2125 +            y->type == A_ELEMSET || y->type == A_FORMULA))
277.2126 +         error(mpl, "expression following then has invalid type");
277.2127 +      /* if the expression that follows the keyword 'then' is elemental
277.2128 +         set, the keyword 'else' cannot be omitted; otherwise else-part
277.2129 +         is optional */
277.2130 +      if (mpl->token != T_ELSE)
277.2131 +      {  if (y->type == A_ELEMSET)
277.2132 +            error(mpl, "keyword else missing where expected");
277.2133 +         z = NULL;
277.2134 +         goto skip;
277.2135 +      }
277.2136 +      get_token(mpl /* else */);
277.2137 +      /* parse <expression> that follow 'else' and check its type */
277.2138 +      z = expression_9(mpl);
277.2139 +      if (!(z->type == A_NUMERIC || z->type == A_SYMBOLIC ||
277.2140 +            z->type == A_ELEMSET || z->type == A_FORMULA))
277.2141 +         error(mpl, "expression following else has invalid type");
277.2142 +      /* convert to identical types, if necessary */
277.2143 +      if (y->type == A_FORMULA || z->type == A_FORMULA)
277.2144 +      {  if (y->type == A_SYMBOLIC)
277.2145 +            y = make_unary(mpl, O_CVTNUM, y, A_NUMERIC, 0);
277.2146 +         if (y->type == A_NUMERIC)
277.2147 +            y = make_unary(mpl, O_CVTLFM, y, A_FORMULA, 0);
277.2148 +         if (z->type == A_SYMBOLIC)
277.2149 +            z = make_unary(mpl, O_CVTNUM, z, A_NUMERIC, 0);
277.2150 +         if (z->type == A_NUMERIC)
277.2151 +            z = make_unary(mpl, O_CVTLFM, z, A_FORMULA, 0);
277.2152 +      }
277.2153 +      if (y->type == A_SYMBOLIC || z->type == A_SYMBOLIC)
277.2154 +      {  if (y->type == A_NUMERIC)
277.2155 +            y = make_unary(mpl, O_CVTSYM, y, A_SYMBOLIC, 0);
277.2156 +         if (z->type == A_NUMERIC)
277.2157 +            z = make_unary(mpl, O_CVTSYM, z, A_SYMBOLIC, 0);
277.2158 +      }
277.2159 +      /* now both expressions must have identical types */
277.2160 +      if (y->type != z->type)
277.2161 +         error(mpl, "expressions following then and else have incompati"
277.2162 +            "ble types");
277.2163 +      /* and identical dimensions */
277.2164 +      if (y->dim != z->dim)
277.2165 +         error(mpl, "expressions following then and else have different"
277.2166 +            " dimensions %d and %d, respectively", y->dim, z->dim);
277.2167 +skip: /* generate pseudo-code to perform branching */
277.2168 +      code = make_ternary(mpl, O_FORK, x, y, z, y->type, y->dim);
277.2169 +      return code;
277.2170 +}
277.2171 +
277.2172 +/*----------------------------------------------------------------------
277.2173 +-- primary_expression - parse primary expression.
277.2174 +--
277.2175 +-- This routine parses primary expression using the syntax:
277.2176 +--
277.2177 +-- <primary expression> ::= <numeric literal>
277.2178 +-- <primary expression> ::= Infinity
277.2179 +-- <primary expression> ::= <string literal>
277.2180 +-- <primary expression> ::= <dummy index>
277.2181 +-- <primary expression> ::= <set name>
277.2182 +-- <primary expression> ::= <set name> [ <subscript list> ]
277.2183 +-- <primary expression> ::= <parameter name>
277.2184 +-- <primary expression> ::= <parameter name> [ <subscript list> ]
277.2185 +-- <primary expression> ::= <variable name>
277.2186 +-- <primary expression> ::= <variable name> [ <subscript list> ]
277.2187 +-- <primary expression> ::= <built-in function> ( <argument list> )
277.2188 +-- <primary expression> ::= ( <expression list> )
277.2189 +-- <primary expression> ::= <iterated expression>
277.2190 +-- <primary expression> ::= { }
277.2191 +-- <primary expression> ::= <indexing expression>
277.2192 +-- <primary expression> ::= <branched expression>
277.2193 +--
277.2194 +-- For complete list of syntactic rules for <primary expression> see
277.2195 +-- comments to the corresponding parsing routines. */
277.2196 +
277.2197 +CODE *primary_expression(MPL *mpl)
277.2198 +{     CODE *code;
277.2199 +      if (mpl->token == T_NUMBER)
277.2200 +      {  /* parse numeric literal */
277.2201 +         code = numeric_literal(mpl);
277.2202 +      }
277.2203 +#if 1 /* 21/VII-2006 */
277.2204 +      else if (mpl->token == T_INFINITY)
277.2205 +      {  /* parse "infinity" */
277.2206 +         OPERANDS arg;
277.2207 +         arg.num = DBL_MAX;
277.2208 +         code = make_code(mpl, O_NUMBER, &arg, A_NUMERIC, 0);
277.2209 +         get_token(mpl /* Infinity */);
277.2210 +      }
277.2211 +#endif
277.2212 +      else if (mpl->token == T_STRING)
277.2213 +      {  /* parse string literal */
277.2214 +         code = string_literal(mpl);
277.2215 +      }
277.2216 +      else if (mpl->token == T_NAME)
277.2217 +      {  int next_token;
277.2218 +         get_token(mpl /* <symbolic name> */);
277.2219 +         next_token = mpl->token;
277.2220 +         unget_token(mpl);
277.2221 +         /* check a token that follows <symbolic name> */
277.2222 +         switch (next_token)
277.2223 +         {  case T_LBRACKET:
277.2224 +               /* parse reference to subscripted object */
277.2225 +               code = object_reference(mpl);
277.2226 +               break;
277.2227 +            case T_LEFT:
277.2228 +               /* parse reference to built-in function */
277.2229 +               code = function_reference(mpl);
277.2230 +               break;
277.2231 +            case T_LBRACE:
277.2232 +               /* parse iterated expression */
277.2233 +               code = iterated_expression(mpl);
277.2234 +               break;
277.2235 +            default:
277.2236 +               /* parse reference to unsubscripted object */
277.2237 +               code = object_reference(mpl);
277.2238 +               break;
277.2239 +         }
277.2240 +      }
277.2241 +      else if (mpl->token == T_LEFT)
277.2242 +      {  /* parse parenthesized expression */
277.2243 +         code = expression_list(mpl);
277.2244 +      }
277.2245 +      else if (mpl->token == T_LBRACE)
277.2246 +      {  /* parse set expression */
277.2247 +         code = set_expression(mpl);
277.2248 +      }
277.2249 +      else if (mpl->token == T_IF)
277.2250 +      {  /* parse conditional expression */
277.2251 +         code = branched_expression(mpl);
277.2252 +      }
277.2253 +      else if (is_reserved(mpl))
277.2254 +      {  /* other reserved keywords cannot be used here */
277.2255 +         error(mpl, "invalid use of reserved keyword %s", mpl->image);
277.2256 +      }
277.2257 +      else
277.2258 +         error(mpl, "syntax error in expression");
277.2259 +      return code;
277.2260 +}
277.2261 +
277.2262 +/*----------------------------------------------------------------------
277.2263 +-- error_preceding - raise error if preceding operand has wrong type.
277.2264 +--
277.2265 +-- This routine is called to raise error if operand that precedes some
277.2266 +-- infix operator has invalid type. */
277.2267 +
277.2268 +void error_preceding(MPL *mpl, char *opstr)
277.2269 +{     error(mpl, "operand preceding %s has invalid type", opstr);
277.2270 +      /* no return */
277.2271 +}
277.2272 +
277.2273 +/*----------------------------------------------------------------------
277.2274 +-- error_following - raise error if following operand has wrong type.
277.2275 +--
277.2276 +-- This routine is called to raise error if operand that follows some
277.2277 +-- infix operator has invalid type. */
277.2278 +
277.2279 +void error_following(MPL *mpl, char *opstr)
277.2280 +{     error(mpl, "operand following %s has invalid type", opstr);
277.2281 +      /* no return */
277.2282 +}
277.2283 +
277.2284 +/*----------------------------------------------------------------------
277.2285 +-- error_dimension - raise error if operands have different dimension.
277.2286 +--
277.2287 +-- This routine is called to raise error if two operands of some infix
277.2288 +-- operator have different dimension. */
277.2289 +
277.2290 +void error_dimension(MPL *mpl, char *opstr, int dim1, int dim2)
277.2291 +{     error(mpl, "operands preceding and following %s have different di"
277.2292 +         "mensions %d and %d, respectively", opstr, dim1, dim2);
277.2293 +      /* no return */
277.2294 +}
277.2295 +
277.2296 +/*----------------------------------------------------------------------
277.2297 +-- expression_0 - parse expression of level 0.
277.2298 +--
277.2299 +-- This routine parses expression of level 0 using the syntax:
277.2300 +--
277.2301 +-- <expression 0> ::= <primary expression> */
277.2302 +
277.2303 +CODE *expression_0(MPL *mpl)
277.2304 +{     CODE *code;
277.2305 +      code = primary_expression(mpl);
277.2306 +      return code;
277.2307 +}
277.2308 +
277.2309 +/*----------------------------------------------------------------------
277.2310 +-- expression_1 - parse expression of level 1.
277.2311 +--
277.2312 +-- This routine parses expression of level 1 using the syntax:
277.2313 +--
277.2314 +-- <expression 1> ::= <expression 0>
277.2315 +-- <expression 1> ::= <expression 0> <power> <expression 1>
277.2316 +-- <expression 1> ::= <expression 0> <power> <expression 2>
277.2317 +-- <power> ::= ^ | ** */
277.2318 +
277.2319 +CODE *expression_1(MPL *mpl)
277.2320 +{     CODE *x, *y;
277.2321 +      char opstr[8];
277.2322 +      x = expression_0(mpl);
277.2323 +      if (mpl->token == T_POWER)
277.2324 +      {  strcpy(opstr, mpl->image);
277.2325 +         xassert(strlen(opstr) < sizeof(opstr));
277.2326 +         if (x->type == A_SYMBOLIC)
277.2327 +            x = make_unary(mpl, O_CVTNUM, x, A_NUMERIC, 0);
277.2328 +         if (x->type != A_NUMERIC)
277.2329 +            error_preceding(mpl, opstr);
277.2330 +         get_token(mpl /* ^ | ** */);
277.2331 +         if (mpl->token == T_PLUS || mpl->token == T_MINUS)
277.2332 +            y = expression_2(mpl);
277.2333 +         else
277.2334 +            y = expression_1(mpl);
277.2335 +         if (y->type == A_SYMBOLIC)
277.2336 +            y = make_unary(mpl, O_CVTNUM, y, A_NUMERIC, 0);
277.2337 +         if (y->type != A_NUMERIC)
277.2338 +            error_following(mpl, opstr);
277.2339 +         x = make_binary(mpl, O_POWER, x, y, A_NUMERIC, 0);
277.2340 +      }
277.2341 +      return x;
277.2342 +}
277.2343 +
277.2344 +/*----------------------------------------------------------------------
277.2345 +-- expression_2 - parse expression of level 2.
277.2346 +--
277.2347 +-- This routine parses expression of level 2 using the syntax:
277.2348 +--
277.2349 +-- <expression 2> ::= <expression 1>
277.2350 +-- <expression 2> ::= + <expression 1>
277.2351 +-- <expression 2> ::= - <expression 1> */
277.2352 +
277.2353 +CODE *expression_2(MPL *mpl)
277.2354 +{     CODE *x;
277.2355 +      if (mpl->token == T_PLUS)
277.2356 +      {  get_token(mpl /* + */);
277.2357 +         x = expression_1(mpl);
277.2358 +         if (x->type == A_SYMBOLIC)
277.2359 +            x = make_unary(mpl, O_CVTNUM, x, A_NUMERIC, 0);
277.2360 +         if (!(x->type == A_NUMERIC || x->type == A_FORMULA))
277.2361 +            error_following(mpl, "+");
277.2362 +         x = make_unary(mpl, O_PLUS, x, x->type, 0);
277.2363 +      }
277.2364 +      else if (mpl->token == T_MINUS)
277.2365 +      {  get_token(mpl /* - */);
277.2366 +         x = expression_1(mpl);
277.2367 +         if (x->type == A_SYMBOLIC)
277.2368 +            x = make_unary(mpl, O_CVTNUM, x, A_NUMERIC, 0);
277.2369 +         if (!(x->type == A_NUMERIC || x->type == A_FORMULA))
277.2370 +            error_following(mpl, "-");
277.2371 +         x = make_unary(mpl, O_MINUS, x, x->type, 0);
277.2372 +      }
277.2373 +      else
277.2374 +         x = expression_1(mpl);
277.2375 +      return x;
277.2376 +}
277.2377 +
277.2378 +/*----------------------------------------------------------------------
277.2379 +-- expression_3 - parse expression of level 3.
277.2380 +--
277.2381 +-- This routine parses expression of level 3 using the syntax:
277.2382 +--
277.2383 +-- <expression 3> ::= <expression 2>
277.2384 +-- <expression 3> ::= <expression 3> * <expression 2>
277.2385 +-- <expression 3> ::= <expression 3> / <expression 2>
277.2386 +-- <expression 3> ::= <expression 3> div <expression 2>
277.2387 +-- <expression 3> ::= <expression 3> mod <expression 2> */
277.2388 +
277.2389 +CODE *expression_3(MPL *mpl)
277.2390 +{     CODE *x, *y;
277.2391 +      x = expression_2(mpl);
277.2392 +      for (;;)
277.2393 +      {  if (mpl->token == T_ASTERISK)
277.2394 +         {  if (x->type == A_SYMBOLIC)
277.2395 +               x = make_unary(mpl, O_CVTNUM, x, A_NUMERIC, 0);
277.2396 +            if (!(x->type == A_NUMERIC || x->type == A_FORMULA))
277.2397 +               error_preceding(mpl, "*");
277.2398 +            get_token(mpl /* * */);
277.2399 +            y = expression_2(mpl);
277.2400 +            if (y->type == A_SYMBOLIC)
277.2401 +               y = make_unary(mpl, O_CVTNUM, y, A_NUMERIC, 0);
277.2402 +            if (!(y->type == A_NUMERIC || y->type == A_FORMULA))
277.2403 +               error_following(mpl, "*");
277.2404 +            if (x->type == A_FORMULA && y->type == A_FORMULA)
277.2405 +               error(mpl, "multiplication of linear forms not allowed");
277.2406 +            if (x->type == A_NUMERIC && y->type == A_NUMERIC)
277.2407 +               x = make_binary(mpl, O_MUL, x, y, A_NUMERIC, 0);
277.2408 +            else
277.2409 +               x = make_binary(mpl, O_MUL, x, y, A_FORMULA, 0);
277.2410 +         }
277.2411 +         else if (mpl->token == T_SLASH)
277.2412 +         {  if (x->type == A_SYMBOLIC)
277.2413 +               x = make_unary(mpl, O_CVTNUM, x, A_NUMERIC, 0);
277.2414 +            if (!(x->type == A_NUMERIC || x->type == A_FORMULA))
277.2415 +               error_preceding(mpl, "/");
277.2416 +            get_token(mpl /* / */);
277.2417 +            y = expression_2(mpl);
277.2418 +            if (y->type == A_SYMBOLIC)
277.2419 +               y = make_unary(mpl, O_CVTNUM, y, A_NUMERIC, 0);
277.2420 +            if (y->type != A_NUMERIC)
277.2421 +               error_following(mpl, "/");
277.2422 +            if (x->type == A_NUMERIC)
277.2423 +               x = make_binary(mpl, O_DIV, x, y, A_NUMERIC, 0);
277.2424 +            else
277.2425 +               x = make_binary(mpl, O_DIV, x, y, A_FORMULA, 0);
277.2426 +         }
277.2427 +         else if (mpl->token == T_DIV)
277.2428 +         {  if (x->type == A_SYMBOLIC)
277.2429 +               x = make_unary(mpl, O_CVTNUM, x, A_NUMERIC, 0);
277.2430 +            if (x->type != A_NUMERIC)
277.2431 +               error_preceding(mpl, "div");
277.2432 +            get_token(mpl /* div */);
277.2433 +            y = expression_2(mpl);
277.2434 +            if (y->type == A_SYMBOLIC)
277.2435 +               y = make_unary(mpl, O_CVTNUM, y, A_NUMERIC, 0);
277.2436 +            if (y->type != A_NUMERIC)
277.2437 +               error_following(mpl, "div");
277.2438 +            x = make_binary(mpl, O_IDIV, x, y, A_NUMERIC, 0);
277.2439 +         }
277.2440 +         else if (mpl->token == T_MOD)
277.2441 +         {  if (x->type == A_SYMBOLIC)
277.2442 +               x = make_unary(mpl, O_CVTNUM, x, A_NUMERIC, 0);
277.2443 +            if (x->type != A_NUMERIC)
277.2444 +               error_preceding(mpl, "mod");
277.2445 +            get_token(mpl /* mod */);
277.2446 +            y = expression_2(mpl);
277.2447 +            if (y->type == A_SYMBOLIC)
277.2448 +               y = make_unary(mpl, O_CVTNUM, y, A_NUMERIC, 0);
277.2449 +            if (y->type != A_NUMERIC)
277.2450 +               error_following(mpl, "mod");
277.2451 +            x = make_binary(mpl, O_MOD, x, y, A_NUMERIC, 0);
277.2452 +         }
277.2453 +         else
277.2454 +            break;
277.2455 +      }
277.2456 +      return x;
277.2457 +}
277.2458 +
277.2459 +/*----------------------------------------------------------------------
277.2460 +-- expression_4 - parse expression of level 4.
277.2461 +--
277.2462 +-- This routine parses expression of level 4 using the syntax:
277.2463 +--
277.2464 +-- <expression 4> ::= <expression 3>
277.2465 +-- <expression 4> ::= <expression 4> + <expression 3>
277.2466 +-- <expression 4> ::= <expression 4> - <expression 3>
277.2467 +-- <expression 4> ::= <expression 4> less <expression 3> */
277.2468 +
277.2469 +CODE *expression_4(MPL *mpl)
277.2470 +{     CODE *x, *y;
277.2471 +      x = expression_3(mpl);
277.2472 +      for (;;)
277.2473 +      {  if (mpl->token == T_PLUS)
277.2474 +         {  if (x->type == A_SYMBOLIC)
277.2475 +               x = make_unary(mpl, O_CVTNUM, x, A_NUMERIC, 0);
277.2476 +            if (!(x->type == A_NUMERIC || x->type == A_FORMULA))
277.2477 +               error_preceding(mpl, "+");
277.2478 +            get_token(mpl /* + */);
277.2479 +            y = expression_3(mpl);
277.2480 +            if (y->type == A_SYMBOLIC)
277.2481 +               y = make_unary(mpl, O_CVTNUM, y, A_NUMERIC, 0);
277.2482 +            if (!(y->type == A_NUMERIC || y->type == A_FORMULA))
277.2483 +               error_following(mpl, "+");
277.2484 +            if (x->type == A_NUMERIC && y->type == A_FORMULA)
277.2485 +               x = make_unary(mpl, O_CVTLFM, x, A_FORMULA, 0);
277.2486 +            if (x->type == A_FORMULA && y->type == A_NUMERIC)
277.2487 +               y = make_unary(mpl, O_CVTLFM, y, A_FORMULA, 0);
277.2488 +            x = make_binary(mpl, O_ADD, x, y, x->type, 0);
277.2489 +         }
277.2490 +         else if (mpl->token == T_MINUS)
277.2491 +         {  if (x->type == A_SYMBOLIC)
277.2492 +               x = make_unary(mpl, O_CVTNUM, x, A_NUMERIC, 0);
277.2493 +            if (!(x->type == A_NUMERIC || x->type == A_FORMULA))
277.2494 +               error_preceding(mpl, "-");
277.2495 +            get_token(mpl /* - */);
277.2496 +            y = expression_3(mpl);
277.2497 +            if (y->type == A_SYMBOLIC)
277.2498 +               y = make_unary(mpl, O_CVTNUM, y, A_NUMERIC, 0);
277.2499 +            if (!(y->type == A_NUMERIC || y->type == A_FORMULA))
277.2500 +               error_following(mpl, "-");
277.2501 +            if (x->type == A_NUMERIC && y->type == A_FORMULA)
277.2502 +               x = make_unary(mpl, O_CVTLFM, x, A_FORMULA, 0);
277.2503 +            if (x->type == A_FORMULA && y->type == A_NUMERIC)
277.2504 +               y = make_unary(mpl, O_CVTLFM, y, A_FORMULA, 0);
277.2505 +            x = make_binary(mpl, O_SUB, x, y, x->type, 0);
277.2506 +         }
277.2507 +         else if (mpl->token == T_LESS)
277.2508 +         {  if (x->type == A_SYMBOLIC)
277.2509 +               x = make_unary(mpl, O_CVTNUM, x, A_NUMERIC, 0);
277.2510 +            if (x->type != A_NUMERIC)
277.2511 +               error_preceding(mpl, "less");
277.2512 +            get_token(mpl /* less */);
277.2513 +            y = expression_3(mpl);
277.2514 +            if (y->type == A_SYMBOLIC)
277.2515 +               y = make_unary(mpl, O_CVTNUM, y, A_NUMERIC, 0);
277.2516 +            if (y->type != A_NUMERIC)
277.2517 +               error_following(mpl, "less");
277.2518 +            x = make_binary(mpl, O_LESS, x, y, A_NUMERIC, 0);
277.2519 +         }
277.2520 +         else
277.2521 +            break;
277.2522 +      }
277.2523 +      return x;
277.2524 +}
277.2525 +
277.2526 +/*----------------------------------------------------------------------
277.2527 +-- expression_5 - parse expression of level 5.
277.2528 +--
277.2529 +-- This routine parses expression of level 5 using the syntax:
277.2530 +--
277.2531 +-- <expression 5> ::= <expression 4>
277.2532 +-- <expression 5> ::= <expression 5> & <expression 4> */
277.2533 +
277.2534 +CODE *expression_5(MPL *mpl)
277.2535 +{     CODE *x, *y;
277.2536 +      x = expression_4(mpl);
277.2537 +      for (;;)
277.2538 +      {  if (mpl->token == T_CONCAT)
277.2539 +         {  if (x->type == A_NUMERIC)
277.2540 +               x = make_unary(mpl, O_CVTSYM, x, A_SYMBOLIC, 0);
277.2541 +            if (x->type != A_SYMBOLIC)
277.2542 +               error_preceding(mpl, "&");
277.2543 +            get_token(mpl /* & */);
277.2544 +            y = expression_4(mpl);
277.2545 +            if (y->type == A_NUMERIC)
277.2546 +               y = make_unary(mpl, O_CVTSYM, y, A_SYMBOLIC, 0);
277.2547 +            if (y->type != A_SYMBOLIC)
277.2548 +               error_following(mpl, "&");
277.2549 +            x = make_binary(mpl, O_CONCAT, x, y, A_SYMBOLIC, 0);
277.2550 +         }
277.2551 +         else
277.2552 +            break;
277.2553 +      }
277.2554 +      return x;
277.2555 +}
277.2556 +
277.2557 +/*----------------------------------------------------------------------
277.2558 +-- expression_6 - parse expression of level 6.
277.2559 +--
277.2560 +-- This routine parses expression of level 6 using the syntax:
277.2561 +--
277.2562 +-- <expression 6> ::= <expression 5>
277.2563 +-- <expression 6> ::= <expression 5> .. <expression 5>
277.2564 +-- <expression 6> ::= <expression 5> .. <expression 5> by
277.2565 +--                    <expression 5> */
277.2566 +
277.2567 +CODE *expression_6(MPL *mpl)
277.2568 +{     CODE *x, *y, *z;
277.2569 +      x = expression_5(mpl);
277.2570 +      if (mpl->token == T_DOTS)
277.2571 +      {  if (x->type == A_SYMBOLIC)
277.2572 +            x = make_unary(mpl, O_CVTNUM, x, A_NUMERIC, 0);
277.2573 +         if (x->type != A_NUMERIC)
277.2574 +            error_preceding(mpl, "..");
277.2575 +         get_token(mpl /* .. */);
277.2576 +         y = expression_5(mpl);
277.2577 +         if (y->type == A_SYMBOLIC)
277.2578 +            y = make_unary(mpl, O_CVTNUM, y, A_NUMERIC, 0);
277.2579 +         if (y->type != A_NUMERIC)
277.2580 +            error_following(mpl, "..");
277.2581 +         if (mpl->token == T_BY)
277.2582 +         {  get_token(mpl /* by */);
277.2583 +            z = expression_5(mpl);
277.2584 +            if (z->type == A_SYMBOLIC)
277.2585 +               z = make_unary(mpl, O_CVTNUM, z, A_NUMERIC, 0);
277.2586 +            if (z->type != A_NUMERIC)
277.2587 +               error_following(mpl, "by");
277.2588 +         }
277.2589 +         else
277.2590 +            z = NULL;
277.2591 +         x = make_ternary(mpl, O_DOTS, x, y, z, A_ELEMSET, 1);
277.2592 +      }
277.2593 +      return x;
277.2594 +}
277.2595 +
277.2596 +/*----------------------------------------------------------------------
277.2597 +-- expression_7 - parse expression of level 7.
277.2598 +--
277.2599 +-- This routine parses expression of level 7 using the syntax:
277.2600 +--
277.2601 +-- <expression 7> ::= <expression 6>
277.2602 +-- <expression 7> ::= <expression 7> cross <expression 6> */
277.2603 +
277.2604 +CODE *expression_7(MPL *mpl)
277.2605 +{     CODE *x, *y;
277.2606 +      x = expression_6(mpl);
277.2607 +      for (;;)
277.2608 +      {  if (mpl->token == T_CROSS)
277.2609 +         {  if (x->type != A_ELEMSET)
277.2610 +               error_preceding(mpl, "cross");
277.2611 +            get_token(mpl /* cross */);
277.2612 +            y = expression_6(mpl);
277.2613 +            if (y->type != A_ELEMSET)
277.2614 +               error_following(mpl, "cross");
277.2615 +            x = make_binary(mpl, O_CROSS, x, y, A_ELEMSET,
277.2616 +               x->dim + y->dim);
277.2617 +         }
277.2618 +         else
277.2619 +            break;
277.2620 +      }
277.2621 +      return x;
277.2622 +}
277.2623 +
277.2624 +/*----------------------------------------------------------------------
277.2625 +-- expression_8 - parse expression of level 8.
277.2626 +--
277.2627 +-- This routine parses expression of level 8 using the syntax:
277.2628 +--
277.2629 +-- <expression 8> ::= <expression 7>
277.2630 +-- <expression 8> ::= <expression 8> inter <expression 7> */
277.2631 +
277.2632 +CODE *expression_8(MPL *mpl)
277.2633 +{     CODE *x, *y;
277.2634 +      x = expression_7(mpl);
277.2635 +      for (;;)
277.2636 +      {  if (mpl->token == T_INTER)
277.2637 +         {  if (x->type != A_ELEMSET)
277.2638 +               error_preceding(mpl, "inter");
277.2639 +            get_token(mpl /* inter */);
277.2640 +            y = expression_7(mpl);
277.2641 +            if (y->type != A_ELEMSET)
277.2642 +               error_following(mpl, "inter");
277.2643 +            if (x->dim != y->dim)
277.2644 +               error_dimension(mpl, "inter", x->dim, y->dim);
277.2645 +            x = make_binary(mpl, O_INTER, x, y, A_ELEMSET, x->dim);
277.2646 +         }
277.2647 +         else
277.2648 +            break;
277.2649 +      }
277.2650 +      return x;
277.2651 +}
277.2652 +
277.2653 +/*----------------------------------------------------------------------
277.2654 +-- expression_9 - parse expression of level 9.
277.2655 +--
277.2656 +-- This routine parses expression of level 9 using the syntax:
277.2657 +--
277.2658 +-- <expression 9> ::= <expression 8>
277.2659 +-- <expression 9> ::= <expression 9> union <expression 8>
277.2660 +-- <expression 9> ::= <expression 9> diff <expression 8>
277.2661 +-- <expression 9> ::= <expression 9> symdiff <expression 8> */
277.2662 +
277.2663 +CODE *expression_9(MPL *mpl)
277.2664 +{     CODE *x, *y;
277.2665 +      x = expression_8(mpl);
277.2666 +      for (;;)
277.2667 +      {  if (mpl->token == T_UNION)
277.2668 +         {  if (x->type != A_ELEMSET)
277.2669 +               error_preceding(mpl, "union");
277.2670 +            get_token(mpl /* union */);
277.2671 +            y = expression_8(mpl);
277.2672 +            if (y->type != A_ELEMSET)
277.2673 +               error_following(mpl, "union");
277.2674 +            if (x->dim != y->dim)
277.2675 +               error_dimension(mpl, "union", x->dim, y->dim);
277.2676 +            x = make_binary(mpl, O_UNION, x, y, A_ELEMSET, x->dim);
277.2677 +         }
277.2678 +         else if (mpl->token == T_DIFF)
277.2679 +         {  if (x->type != A_ELEMSET)
277.2680 +               error_preceding(mpl, "diff");
277.2681 +            get_token(mpl /* diff */);
277.2682 +            y = expression_8(mpl);
277.2683 +            if (y->type != A_ELEMSET)
277.2684 +               error_following(mpl, "diff");
277.2685 +            if (x->dim != y->dim)
277.2686 +               error_dimension(mpl, "diff", x->dim, y->dim);
277.2687 +            x = make_binary(mpl, O_DIFF, x, y, A_ELEMSET, x->dim);
277.2688 +         }
277.2689 +         else if (mpl->token == T_SYMDIFF)
277.2690 +         {  if (x->type != A_ELEMSET)
277.2691 +               error_preceding(mpl, "symdiff");
277.2692 +            get_token(mpl /* symdiff */);
277.2693 +            y = expression_8(mpl);
277.2694 +            if (y->type != A_ELEMSET)
277.2695 +               error_following(mpl, "symdiff");
277.2696 +            if (x->dim != y->dim)
277.2697 +               error_dimension(mpl, "symdiff", x->dim, y->dim);
277.2698 +            x = make_binary(mpl, O_SYMDIFF, x, y, A_ELEMSET, x->dim);
277.2699 +         }
277.2700 +         else
277.2701 +            break;
277.2702 +      }
277.2703 +      return x;
277.2704 +}
277.2705 +
277.2706 +/*----------------------------------------------------------------------
277.2707 +-- expression_10 - parse expression of level 10.
277.2708 +--
277.2709 +-- This routine parses expression of level 10 using the syntax:
277.2710 +--
277.2711 +-- <expression 10> ::= <expression 9>
277.2712 +-- <expression 10> ::= <expression 9> <rho> <expression 9>
277.2713 +-- <rho> ::= < | <= | = | == | >= | > | <> | != | in | not in | ! in |
277.2714 +--           within | not within | ! within */
277.2715 +
277.2716 +CODE *expression_10(MPL *mpl)
277.2717 +{     CODE *x, *y;
277.2718 +      int op = -1;
277.2719 +      char opstr[16];
277.2720 +      x = expression_9(mpl);
277.2721 +      strcpy(opstr, "");
277.2722 +      switch (mpl->token)
277.2723 +      {  case T_LT:
277.2724 +            op = O_LT; break;
277.2725 +         case T_LE:
277.2726 +            op = O_LE; break;
277.2727 +         case T_EQ:
277.2728 +            op = O_EQ; break;
277.2729 +         case T_GE:
277.2730 +            op = O_GE; break;
277.2731 +         case T_GT:
277.2732 +            op = O_GT; break;
277.2733 +         case T_NE:
277.2734 +            op = O_NE; break;
277.2735 +         case T_IN:
277.2736 +            op = O_IN; break;
277.2737 +         case T_WITHIN:
277.2738 +            op = O_WITHIN; break;
277.2739 +         case T_NOT:
277.2740 +            strcpy(opstr, mpl->image);
277.2741 +            get_token(mpl /* not | ! */);
277.2742 +            if (mpl->token == T_IN)
277.2743 +               op = O_NOTIN;
277.2744 +            else if (mpl->token == T_WITHIN)
277.2745 +               op = O_NOTWITHIN;
277.2746 +            else
277.2747 +               error(mpl, "invalid use of %s", opstr);
277.2748 +            strcat(opstr, " ");
277.2749 +            break;
277.2750 +         default:
277.2751 +            goto done;
277.2752 +      }
277.2753 +      strcat(opstr, mpl->image);
277.2754 +      xassert(strlen(opstr) < sizeof(opstr));
277.2755 +      switch (op)
277.2756 +      {  case O_EQ:
277.2757 +         case O_NE:
277.2758 +#if 1 /* 02/VIII-2008 */
277.2759 +         case O_LT:
277.2760 +         case O_LE:
277.2761 +         case O_GT:
277.2762 +         case O_GE:
277.2763 +#endif
277.2764 +            if (!(x->type == A_NUMERIC || x->type == A_SYMBOLIC))
277.2765 +               error_preceding(mpl, opstr);
277.2766 +            get_token(mpl /* <rho> */);
277.2767 +            y = expression_9(mpl);
277.2768 +            if (!(y->type == A_NUMERIC || y->type == A_SYMBOLIC))
277.2769 +               error_following(mpl, opstr);
277.2770 +            if (x->type == A_NUMERIC && y->type == A_SYMBOLIC)
277.2771 +               x = make_unary(mpl, O_CVTSYM, x, A_SYMBOLIC, 0);
277.2772 +            if (x->type == A_SYMBOLIC && y->type == A_NUMERIC)
277.2773 +               y = make_unary(mpl, O_CVTSYM, y, A_SYMBOLIC, 0);
277.2774 +            x = make_binary(mpl, op, x, y, A_LOGICAL, 0);
277.2775 +            break;
277.2776 +#if 0 /* 02/VIII-2008 */
277.2777 +         case O_LT:
277.2778 +         case O_LE:
277.2779 +         case O_GT:
277.2780 +         case O_GE:
277.2781 +            if (x->type == A_SYMBOLIC)
277.2782 +               x = make_unary(mpl, O_CVTNUM, x, A_NUMERIC, 0);
277.2783 +            if (x->type != A_NUMERIC)
277.2784 +               error_preceding(mpl, opstr);
277.2785 +            get_token(mpl /* <rho> */);
277.2786 +            y = expression_9(mpl);
277.2787 +            if (y->type == A_SYMBOLIC)
277.2788 +               y = make_unary(mpl, O_CVTNUM, y, A_NUMERIC, 0);
277.2789 +            if (y->type != A_NUMERIC)
277.2790 +               error_following(mpl, opstr);
277.2791 +            x = make_binary(mpl, op, x, y, A_LOGICAL, 0);
277.2792 +            break;
277.2793 +#endif
277.2794 +         case O_IN:
277.2795 +         case O_NOTIN:
277.2796 +            if (x->type == A_NUMERIC)
277.2797 +               x = make_unary(mpl, O_CVTSYM, x, A_SYMBOLIC, 0);
277.2798 +            if (x->type == A_SYMBOLIC)
277.2799 +               x = make_unary(mpl, O_CVTTUP, x, A_TUPLE, 1);
277.2800 +            if (x->type != A_TUPLE)
277.2801 +               error_preceding(mpl, opstr);
277.2802 +            get_token(mpl /* <rho> */);
277.2803 +            y = expression_9(mpl);
277.2804 +            if (y->type != A_ELEMSET)
277.2805 +               error_following(mpl, opstr);
277.2806 +            if (x->dim != y->dim)
277.2807 +               error_dimension(mpl, opstr, x->dim, y->dim);
277.2808 +            x = make_binary(mpl, op, x, y, A_LOGICAL, 0);
277.2809 +            break;
277.2810 +         case O_WITHIN:
277.2811 +         case O_NOTWITHIN:
277.2812 +            if (x->type != A_ELEMSET)
277.2813 +               error_preceding(mpl, opstr);
277.2814 +            get_token(mpl /* <rho> */);
277.2815 +            y = expression_9(mpl);
277.2816 +            if (y->type != A_ELEMSET)
277.2817 +               error_following(mpl, opstr);
277.2818 +            if (x->dim != y->dim)
277.2819 +               error_dimension(mpl, opstr, x->dim, y->dim);
277.2820 +            x = make_binary(mpl, op, x, y, A_LOGICAL, 0);
277.2821 +            break;
277.2822 +         default:
277.2823 +            xassert(op != op);
277.2824 +      }
277.2825 +done: return x;
277.2826 +}
277.2827 +
277.2828 +/*----------------------------------------------------------------------
277.2829 +-- expression_11 - parse expression of level 11.
277.2830 +--
277.2831 +-- This routine parses expression of level 11 using the syntax:
277.2832 +--
277.2833 +-- <expression 11> ::= <expression 10>
277.2834 +-- <expression 11> ::= not <expression 10>
277.2835 +-- <expression 11> ::= ! <expression 10> */
277.2836 +
277.2837 +CODE *expression_11(MPL *mpl)
277.2838 +{     CODE *x;
277.2839 +      char opstr[8];
277.2840 +      if (mpl->token == T_NOT)
277.2841 +      {  strcpy(opstr, mpl->image);
277.2842 +         xassert(strlen(opstr) < sizeof(opstr));
277.2843 +         get_token(mpl /* not | ! */);
277.2844 +         x = expression_10(mpl);
277.2845 +         if (x->type == A_SYMBOLIC)
277.2846 +            x = make_unary(mpl, O_CVTNUM, x, A_NUMERIC, 0);
277.2847 +         if (x->type == A_NUMERIC)
277.2848 +            x = make_unary(mpl, O_CVTLOG, x, A_LOGICAL, 0);
277.2849 +         if (x->type != A_LOGICAL)
277.2850 +            error_following(mpl, opstr);
277.2851 +         x = make_unary(mpl, O_NOT, x, A_LOGICAL, 0);
277.2852 +      }
277.2853 +      else
277.2854 +         x = expression_10(mpl);
277.2855 +      return x;
277.2856 +}
277.2857 +
277.2858 +/*----------------------------------------------------------------------
277.2859 +-- expression_12 - parse expression of level 12.
277.2860 +--
277.2861 +-- This routine parses expression of level 12 using the syntax:
277.2862 +--
277.2863 +-- <expression 12> ::= <expression 11>
277.2864 +-- <expression 12> ::= <expression 12> and <expression 11>
277.2865 +-- <expression 12> ::= <expression 12> && <expression 11> */
277.2866 +
277.2867 +CODE *expression_12(MPL *mpl)
277.2868 +{     CODE *x, *y;
277.2869 +      char opstr[8];
277.2870 +      x = expression_11(mpl);
277.2871 +      for (;;)
277.2872 +      {  if (mpl->token == T_AND)
277.2873 +         {  strcpy(opstr, mpl->image);
277.2874 +            xassert(strlen(opstr) < sizeof(opstr));
277.2875 +            if (x->type == A_SYMBOLIC)
277.2876 +               x = make_unary(mpl, O_CVTNUM, x, A_NUMERIC, 0);
277.2877 +            if (x->type == A_NUMERIC)
277.2878 +               x = make_unary(mpl, O_CVTLOG, x, A_LOGICAL, 0);
277.2879 +            if (x->type != A_LOGICAL)
277.2880 +               error_preceding(mpl, opstr);
277.2881 +            get_token(mpl /* and | && */);
277.2882 +            y = expression_11(mpl);
277.2883 +            if (y->type == A_SYMBOLIC)
277.2884 +               y = make_unary(mpl, O_CVTNUM, y, A_NUMERIC, 0);
277.2885 +            if (y->type == A_NUMERIC)
277.2886 +               y = make_unary(mpl, O_CVTLOG, y, A_LOGICAL, 0);
277.2887 +            if (y->type != A_LOGICAL)
277.2888 +               error_following(mpl, opstr);
277.2889 +            x = make_binary(mpl, O_AND, x, y, A_LOGICAL, 0);
277.2890 +         }
277.2891 +         else
277.2892 +            break;
277.2893 +      }
277.2894 +      return x;
277.2895 +}
277.2896 +
277.2897 +/*----------------------------------------------------------------------
277.2898 +-- expression_13 - parse expression of level 13.
277.2899 +--
277.2900 +-- This routine parses expression of level 13 using the syntax:
277.2901 +--
277.2902 +-- <expression 13> ::= <expression 12>
277.2903 +-- <expression 13> ::= <expression 13> or <expression 12>
277.2904 +-- <expression 13> ::= <expression 13> || <expression 12> */
277.2905 +
277.2906 +CODE *expression_13(MPL *mpl)
277.2907 +{     CODE *x, *y;
277.2908 +      char opstr[8];
277.2909 +      x = expression_12(mpl);
277.2910 +      for (;;)
277.2911 +      {  if (mpl->token == T_OR)
277.2912 +         {  strcpy(opstr, mpl->image);
277.2913 +            xassert(strlen(opstr) < sizeof(opstr));
277.2914 +            if (x->type == A_SYMBOLIC)
277.2915 +               x = make_unary(mpl, O_CVTNUM, x, A_NUMERIC, 0);
277.2916 +            if (x->type == A_NUMERIC)
277.2917 +               x = make_unary(mpl, O_CVTLOG, x, A_LOGICAL, 0);
277.2918 +            if (x->type != A_LOGICAL)
277.2919 +               error_preceding(mpl, opstr);
277.2920 +            get_token(mpl /* or | || */);
277.2921 +            y = expression_12(mpl);
277.2922 +            if (y->type == A_SYMBOLIC)
277.2923 +               y = make_unary(mpl, O_CVTNUM, y, A_NUMERIC, 0);
277.2924 +            if (y->type == A_NUMERIC)
277.2925 +               y = make_unary(mpl, O_CVTLOG, y, A_LOGICAL, 0);
277.2926 +            if (y->type != A_LOGICAL)
277.2927 +               error_following(mpl, opstr);
277.2928 +            x = make_binary(mpl, O_OR, x, y, A_LOGICAL, 0);
277.2929 +         }
277.2930 +         else
277.2931 +            break;
277.2932 +      }
277.2933 +      return x;
277.2934 +}
277.2935 +
277.2936 +/*----------------------------------------------------------------------
277.2937 +-- set_statement - parse set statement.
277.2938 +--
277.2939 +-- This routine parses set statement using the syntax:
277.2940 +--
277.2941 +-- <set statement> ::= set <symbolic name> <alias> <domain>
277.2942 +--                     <attributes> ;
277.2943 +-- <alias> ::= <empty>
277.2944 +-- <alias> ::= <string literal>
277.2945 +-- <domain> ::= <empty>
277.2946 +-- <domain> ::= <indexing expression>
277.2947 +-- <attributes> ::= <empty>
277.2948 +-- <attributes> ::= <attributes> , dimen <numeric literal>
277.2949 +-- <attributes> ::= <attributes> , within <expression 9>
277.2950 +-- <attributes> ::= <attributes> , := <expression 9>
277.2951 +-- <attributes> ::= <attributes> , default <expression 9>
277.2952 +--
277.2953 +-- Commae in <attributes> are optional and may be omitted anywhere. */
277.2954 +
277.2955 +SET *set_statement(MPL *mpl)
277.2956 +{     SET *set;
277.2957 +      int dimen_used = 0;
277.2958 +      xassert(is_keyword(mpl, "set"));
277.2959 +      get_token(mpl /* set */);
277.2960 +      /* symbolic name must follow the keyword 'set' */
277.2961 +      if (mpl->token == T_NAME)
277.2962 +         ;
277.2963 +      else if (is_reserved(mpl))
277.2964 +         error(mpl, "invalid use of reserved keyword %s", mpl->image);
277.2965 +      else
277.2966 +         error(mpl, "symbolic name missing where expected");
277.2967 +      /* there must be no other object with the same name */
277.2968 +      if (avl_find_node(mpl->tree, mpl->image) != NULL)
277.2969 +         error(mpl, "%s multiply declared", mpl->image);
277.2970 +      /* create model set */
277.2971 +      set = alloc(SET);
277.2972 +      set->name = dmp_get_atomv(mpl->pool, strlen(mpl->image)+1);
277.2973 +      strcpy(set->name, mpl->image);
277.2974 +      set->alias = NULL;
277.2975 +      set->dim = 0;
277.2976 +      set->domain = NULL;
277.2977 +      set->dimen = 0;
277.2978 +      set->within = NULL;
277.2979 +      set->assign = NULL;
277.2980 +      set->option = NULL;
277.2981 +      set->gadget = NULL;
277.2982 +      set->data = 0;
277.2983 +      set->array = NULL;
277.2984 +      get_token(mpl /* <symbolic name> */);
277.2985 +      /* parse optional alias */
277.2986 +      if (mpl->token == T_STRING)
277.2987 +      {  set->alias = dmp_get_atomv(mpl->pool, strlen(mpl->image)+1);
277.2988 +         strcpy(set->alias, mpl->image);
277.2989 +         get_token(mpl /* <string literal> */);
277.2990 +      }
277.2991 +      /* parse optional indexing expression */
277.2992 +      if (mpl->token == T_LBRACE)
277.2993 +      {  set->domain = indexing_expression(mpl);
277.2994 +         set->dim = domain_arity(mpl, set->domain);
277.2995 +      }
277.2996 +      /* include the set name in the symbolic names table */
277.2997 +      {  AVLNODE *node;
277.2998 +         node = avl_insert_node(mpl->tree, set->name);
277.2999 +         avl_set_node_type(node, A_SET);
277.3000 +         avl_set_node_link(node, (void *)set);
277.3001 +      }
277.3002 +      /* parse the list of optional attributes */
277.3003 +      for (;;)
277.3004 +      {  if (mpl->token == T_COMMA)
277.3005 +            get_token(mpl /* , */);
277.3006 +         else if (mpl->token == T_SEMICOLON)
277.3007 +            break;
277.3008 +         if (is_keyword(mpl, "dimen"))
277.3009 +         {  /* dimension of set members */
277.3010 +            int dimen;
277.3011 +            get_token(mpl /* dimen */);
277.3012 +            if (!(mpl->token == T_NUMBER &&
277.3013 +                  1.0 <= mpl->value && mpl->value <= 20.0 &&
277.3014 +                  floor(mpl->value) == mpl->value))
277.3015 +               error(mpl, "dimension must be integer between 1 and 20");
277.3016 +            dimen = (int)(mpl->value + 0.5);
277.3017 +            if (dimen_used)
277.3018 +               error(mpl, "at most one dimension attribute allowed");
277.3019 +            if (set->dimen > 0)
277.3020 +               error(mpl, "dimension %d conflicts with dimension %d alr"
277.3021 +                  "eady determined", dimen, set->dimen);
277.3022 +            set->dimen = dimen;
277.3023 +            dimen_used = 1;
277.3024 +            get_token(mpl /* <numeric literal> */);
277.3025 +         }
277.3026 +         else if (mpl->token == T_WITHIN || mpl->token == T_IN)
277.3027 +         {  /* restricting superset */
277.3028 +            WITHIN *within, *temp;
277.3029 +            if (mpl->token == T_IN && !mpl->as_within)
277.3030 +            {  warning(mpl, "keyword in understood as within");
277.3031 +               mpl->as_within = 1;
277.3032 +            }
277.3033 +            get_token(mpl /* within */);
277.3034 +            /* create new restricting superset list entry and append it
277.3035 +               to the within-list */
277.3036 +            within = alloc(WITHIN);
277.3037 +            within->code = NULL;
277.3038 +            within->next = NULL;
277.3039 +            if (set->within == NULL)
277.3040 +               set->within = within;
277.3041 +            else
277.3042 +            {  for (temp = set->within; temp->next != NULL; temp =
277.3043 +                  temp->next);
277.3044 +               temp->next = within;
277.3045 +            }
277.3046 +            /* parse an expression that follows 'within' */
277.3047 +            within->code = expression_9(mpl);
277.3048 +            if (within->code->type != A_ELEMSET)
277.3049 +               error(mpl, "expression following within has invalid type"
277.3050 +                  );
277.3051 +            xassert(within->code->dim > 0);
277.3052 +            /* check/set dimension of set members */
277.3053 +            if (set->dimen == 0) set->dimen = within->code->dim;
277.3054 +            if (set->dimen != within->code->dim)
277.3055 +               error(mpl, "set expression following within must have di"
277.3056 +                  "mension %d rather than %d",
277.3057 +                  set->dimen, within->code->dim);
277.3058 +         }
277.3059 +         else if (mpl->token == T_ASSIGN)
277.3060 +         {  /* assignment expression */
277.3061 +            if (!(set->assign == NULL && set->option == NULL &&
277.3062 +                  set->gadget == NULL))
277.3063 +err:           error(mpl, "at most one := or default/data allowed");
277.3064 +            get_token(mpl /* := */);
277.3065 +            /* parse an expression that follows ':=' */
277.3066 +            set->assign = expression_9(mpl);
277.3067 +            if (set->assign->type != A_ELEMSET)
277.3068 +               error(mpl, "expression following := has invalid type");
277.3069 +            xassert(set->assign->dim > 0);
277.3070 +            /* check/set dimension of set members */
277.3071 +            if (set->dimen == 0) set->dimen = set->assign->dim;
277.3072 +            if (set->dimen != set->assign->dim)
277.3073 +               error(mpl, "set expression following := must have dimens"
277.3074 +                  "ion %d rather than %d",
277.3075 +                  set->dimen, set->assign->dim);
277.3076 +         }
277.3077 +         else if (is_keyword(mpl, "default"))
277.3078 +         {  /* expression for default value */
277.3079 +            if (!(set->assign == NULL && set->option == NULL)) goto err;
277.3080 +            get_token(mpl /* := */);
277.3081 +            /* parse an expression that follows 'default' */
277.3082 +            set->option = expression_9(mpl);
277.3083 +            if (set->option->type != A_ELEMSET)
277.3084 +               error(mpl, "expression following default has invalid typ"
277.3085 +                  "e");
277.3086 +            xassert(set->option->dim > 0);
277.3087 +            /* check/set dimension of set members */
277.3088 +            if (set->dimen == 0) set->dimen = set->option->dim;
277.3089 +            if (set->dimen != set->option->dim)
277.3090 +               error(mpl, "set expression following default must have d"
277.3091 +                  "imension %d rather than %d",
277.3092 +                  set->dimen, set->option->dim);
277.3093 +         }
277.3094 +#if 1 /* 12/XII-2008 */
277.3095 +         else if (is_keyword(mpl, "data"))
277.3096 +         {  /* gadget to initialize the set by data from plain set */
277.3097 +            GADGET *gadget;
277.3098 +            AVLNODE *node;
277.3099 +            int i, k, fff[20];
277.3100 +            if (!(set->assign == NULL && set->gadget == NULL)) goto err;
277.3101 +            get_token(mpl /* data */);
277.3102 +            set->gadget = gadget = alloc(GADGET);
277.3103 +            /* set name must follow the keyword 'data' */
277.3104 +            if (mpl->token == T_NAME)
277.3105 +               ;
277.3106 +            else if (is_reserved(mpl))
277.3107 +               error(mpl, "invalid use of reserved keyword %s",
277.3108 +                  mpl->image);
277.3109 +            else
277.3110 +               error(mpl, "set name missing where expected");
277.3111 +            /* find the set in the symbolic name table */
277.3112 +            node = avl_find_node(mpl->tree, mpl->image);
277.3113 +            if (node == NULL)
277.3114 +               error(mpl, "%s not defined", mpl->image);
277.3115 +            if (avl_get_node_type(node) != A_SET)
277.3116 +err1:          error(mpl, "%s not a plain set", mpl->image);
277.3117 +            gadget->set = avl_get_node_link(node);
277.3118 +            if (gadget->set->dim != 0) goto err1;
277.3119 +            if (gadget->set == set)
277.3120 +               error(mpl, "set cannot be initialized by itself");
277.3121 +            /* check and set dimensions */
277.3122 +            if (set->dim >= gadget->set->dimen)
277.3123 +err2:          error(mpl, "dimension of %s too small", mpl->image);
277.3124 +            if (set->dimen == 0)
277.3125 +               set->dimen = gadget->set->dimen - set->dim;
277.3126 +            if (set->dim + set->dimen > gadget->set->dimen)
277.3127 +               goto err2;
277.3128 +            else if (set->dim + set->dimen < gadget->set->dimen)
277.3129 +               error(mpl, "dimension of %s too big", mpl->image);
277.3130 +            get_token(mpl /* set name */);
277.3131 +            /* left parenthesis must follow the set name */
277.3132 +            if (mpl->token == T_LEFT)
277.3133 +               get_token(mpl /* ( */);
277.3134 +            else
277.3135 +               error(mpl, "left parenthesis missing where expected");
277.3136 +            /* parse permutation of component numbers */
277.3137 +            for (k = 0; k < gadget->set->dimen; k++) fff[k] = 0;
277.3138 +            k = 0;
277.3139 +            for (;;)
277.3140 +            {  if (mpl->token != T_NUMBER)
277.3141 +                  error(mpl, "component number missing where expected");
277.3142 +               if (str2int(mpl->image, &i) != 0)
277.3143 +err3:             error(mpl, "component number must be integer between "
277.3144 +                     "1 and %d", gadget->set->dimen);
277.3145 +               if (!(1 <= i && i <= gadget->set->dimen)) goto err3;
277.3146 +               if (fff[i-1] != 0)
277.3147 +                  error(mpl, "component %d multiply specified", i);
277.3148 +               gadget->ind[k++] = i, fff[i-1] = 1;
277.3149 +               xassert(k <= gadget->set->dimen);
277.3150 +               get_token(mpl /* number */);
277.3151 +               if (mpl->token == T_COMMA)
277.3152 +                  get_token(mpl /* , */);
277.3153 +               else if (mpl->token == T_RIGHT)
277.3154 +                  break;
277.3155 +               else
277.3156 +                  error(mpl, "syntax error in data attribute");
277.3157 +            }
277.3158 +            if (k < gadget->set->dimen)
277.3159 +               error(mpl, "there are must be %d components rather than "
277.3160 +                  "%d", gadget->set->dimen, k);
277.3161 +            get_token(mpl /* ) */);
277.3162 +         }
277.3163 +#endif
277.3164 +         else
277.3165 +            error(mpl, "syntax error in set statement");
277.3166 +      }
277.3167 +      /* close the domain scope */
277.3168 +      if (set->domain != NULL) close_scope(mpl, set->domain);
277.3169 +      /* if dimension of set members is still unknown, set it to 1 */
277.3170 +      if (set->dimen == 0) set->dimen = 1;
277.3171 +      /* the set statement has been completely parsed */
277.3172 +      xassert(mpl->token == T_SEMICOLON);
277.3173 +      get_token(mpl /* ; */);
277.3174 +      return set;
277.3175 +}
277.3176 +
277.3177 +/*----------------------------------------------------------------------
277.3178 +-- parameter_statement - parse parameter statement.
277.3179 +--
277.3180 +-- This routine parses parameter statement using the syntax:
277.3181 +--
277.3182 +-- <parameter statement> ::= param <symbolic name> <alias> <domain>
277.3183 +--                           <attributes> ;
277.3184 +-- <alias> ::= <empty>
277.3185 +-- <alias> ::= <string literal>
277.3186 +-- <domain> ::= <empty>
277.3187 +-- <domain> ::= <indexing expression>
277.3188 +-- <attributes> ::= <empty>
277.3189 +-- <attributes> ::= <attributes> , integer
277.3190 +-- <attributes> ::= <attributes> , binary
277.3191 +-- <attributes> ::= <attributes> , symbolic
277.3192 +-- <attributes> ::= <attributes> , <rho> <expression 5>
277.3193 +-- <attributes> ::= <attributes> , in <expression 9>
277.3194 +-- <attributes> ::= <attributes> , := <expression 5>
277.3195 +-- <attributes> ::= <attributes> , default <expression 5>
277.3196 +-- <rho> ::= < | <= | = | == | >= | > | <> | !=
277.3197 +--
277.3198 +-- Commae in <attributes> are optional and may be omitted anywhere. */
277.3199 +
277.3200 +PARAMETER *parameter_statement(MPL *mpl)
277.3201 +{     PARAMETER *par;
277.3202 +      int integer_used = 0, binary_used = 0, symbolic_used = 0;
277.3203 +      xassert(is_keyword(mpl, "param"));
277.3204 +      get_token(mpl /* param */);
277.3205 +      /* symbolic name must follow the keyword 'param' */
277.3206 +      if (mpl->token == T_NAME)
277.3207 +         ;
277.3208 +      else if (is_reserved(mpl))
277.3209 +         error(mpl, "invalid use of reserved keyword %s", mpl->image);
277.3210 +      else
277.3211 +         error(mpl, "symbolic name missing where expected");
277.3212 +      /* there must be no other object with the same name */
277.3213 +      if (avl_find_node(mpl->tree, mpl->image) != NULL)
277.3214 +         error(mpl, "%s multiply declared", mpl->image);
277.3215 +      /* create model parameter */
277.3216 +      par = alloc(PARAMETER);
277.3217 +      par->name = dmp_get_atomv(mpl->pool, strlen(mpl->image)+1);
277.3218 +      strcpy(par->name, mpl->image);
277.3219 +      par->alias = NULL;
277.3220 +      par->dim = 0;
277.3221 +      par->domain = NULL;
277.3222 +      par->type = A_NUMERIC;
277.3223 +      par->cond = NULL;
277.3224 +      par->in = NULL;
277.3225 +      par->assign = NULL;
277.3226 +      par->option = NULL;
277.3227 +      par->data = 0;
277.3228 +      par->defval = NULL;
277.3229 +      par->array = NULL;
277.3230 +      get_token(mpl /* <symbolic name> */);
277.3231 +      /* parse optional alias */
277.3232 +      if (mpl->token == T_STRING)
277.3233 +      {  par->alias = dmp_get_atomv(mpl->pool, strlen(mpl->image)+1);
277.3234 +         strcpy(par->alias, mpl->image);
277.3235 +         get_token(mpl /* <string literal> */);
277.3236 +      }
277.3237 +      /* parse optional indexing expression */
277.3238 +      if (mpl->token == T_LBRACE)
277.3239 +      {  par->domain = indexing_expression(mpl);
277.3240 +         par->dim = domain_arity(mpl, par->domain);
277.3241 +      }
277.3242 +      /* include the parameter name in the symbolic names table */
277.3243 +      {  AVLNODE *node;
277.3244 +         node = avl_insert_node(mpl->tree, par->name);
277.3245 +         avl_set_node_type(node, A_PARAMETER);
277.3246 +         avl_set_node_link(node, (void *)par);
277.3247 +      }
277.3248 +      /* parse the list of optional attributes */
277.3249 +      for (;;)
277.3250 +      {  if (mpl->token == T_COMMA)
277.3251 +            get_token(mpl /* , */);
277.3252 +         else if (mpl->token == T_SEMICOLON)
277.3253 +            break;
277.3254 +         if (is_keyword(mpl, "integer"))
277.3255 +         {  if (integer_used)
277.3256 +               error(mpl, "at most one integer allowed");
277.3257 +            if (par->type == A_SYMBOLIC)
277.3258 +               error(mpl, "symbolic parameter cannot be integer");
277.3259 +            if (par->type != A_BINARY) par->type = A_INTEGER;
277.3260 +            integer_used = 1;
277.3261 +            get_token(mpl /* integer */);
277.3262 +         }
277.3263 +         else if (is_keyword(mpl, "binary"))
277.3264 +bin:     {  if (binary_used)
277.3265 +               error(mpl, "at most one binary allowed");
277.3266 +            if (par->type == A_SYMBOLIC)
277.3267 +               error(mpl, "symbolic parameter cannot be binary");
277.3268 +            par->type = A_BINARY;
277.3269 +            binary_used = 1;
277.3270 +            get_token(mpl /* binary */);
277.3271 +         }
277.3272 +         else if (is_keyword(mpl, "logical"))
277.3273 +         {  if (!mpl->as_binary)
277.3274 +            {  warning(mpl, "keyword logical understood as binary");
277.3275 +               mpl->as_binary = 1;
277.3276 +            }
277.3277 +            goto bin;
277.3278 +         }
277.3279 +         else if (is_keyword(mpl, "symbolic"))
277.3280 +         {  if (symbolic_used)
277.3281 +               error(mpl, "at most one symbolic allowed");
277.3282 +            if (par->type != A_NUMERIC)
277.3283 +               error(mpl, "integer or binary parameter cannot be symbol"
277.3284 +                  "ic");
277.3285 +            /* the parameter may be referenced from expressions given
277.3286 +               in the same parameter declaration, so its type must be
277.3287 +               completed before parsing that expressions */
277.3288 +            if (!(par->cond == NULL && par->in == NULL &&
277.3289 +                  par->assign == NULL && par->option == NULL))
277.3290 +               error(mpl, "keyword symbolic must precede any other para"
277.3291 +                  "meter attributes");
277.3292 +            par->type = A_SYMBOLIC;
277.3293 +            symbolic_used = 1;
277.3294 +            get_token(mpl /* symbolic */);
277.3295 +         }
277.3296 +         else if (mpl->token == T_LT || mpl->token == T_LE ||
277.3297 +                  mpl->token == T_EQ || mpl->token == T_GE ||
277.3298 +                  mpl->token == T_GT || mpl->token == T_NE)
277.3299 +         {  /* restricting condition */
277.3300 +            CONDITION *cond, *temp;
277.3301 +            char opstr[8];
277.3302 +            /* create new restricting condition list entry and append
277.3303 +               it to the conditions list */
277.3304 +            cond = alloc(CONDITION);
277.3305 +            switch (mpl->token)
277.3306 +            {  case T_LT:
277.3307 +                  cond->rho = O_LT, strcpy(opstr, mpl->image); break;
277.3308 +               case T_LE:
277.3309 +                  cond->rho = O_LE, strcpy(opstr, mpl->image); break;
277.3310 +               case T_EQ:
277.3311 +                  cond->rho = O_EQ, strcpy(opstr, mpl->image); break;
277.3312 +               case T_GE:
277.3313 +                  cond->rho = O_GE, strcpy(opstr, mpl->image); break;
277.3314 +               case T_GT:
277.3315 +                  cond->rho = O_GT, strcpy(opstr, mpl->image); break;
277.3316 +               case T_NE:
277.3317 +                  cond->rho = O_NE, strcpy(opstr, mpl->image); break;
277.3318 +               default:
277.3319 +                  xassert(mpl->token != mpl->token);
277.3320 +            }
277.3321 +            xassert(strlen(opstr) < sizeof(opstr));
277.3322 +            cond->code = NULL;
277.3323 +            cond->next = NULL;
277.3324 +            if (par->cond == NULL)
277.3325 +               par->cond = cond;
277.3326 +            else
277.3327 +            {  for (temp = par->cond; temp->next != NULL; temp =
277.3328 +                  temp->next);
277.3329 +               temp->next = cond;
277.3330 +            }
277.3331 +#if 0 /* 13/VIII-2008 */
277.3332 +            if (par->type == A_SYMBOLIC &&
277.3333 +               !(cond->rho == O_EQ || cond->rho == O_NE))
277.3334 +               error(mpl, "inequality restriction not allowed");
277.3335 +#endif
277.3336 +            get_token(mpl /* rho */);
277.3337 +            /* parse an expression that follows relational operator */
277.3338 +            cond->code = expression_5(mpl);
277.3339 +            if (!(cond->code->type == A_NUMERIC ||
277.3340 +                  cond->code->type == A_SYMBOLIC))
277.3341 +               error(mpl, "expression following %s has invalid type",
277.3342 +                  opstr);
277.3343 +            xassert(cond->code->dim == 0);
277.3344 +            /* convert to the parameter type, if necessary */
277.3345 +            if (par->type != A_SYMBOLIC && cond->code->type ==
277.3346 +               A_SYMBOLIC)
277.3347 +               cond->code = make_unary(mpl, O_CVTNUM, cond->code,
277.3348 +                  A_NUMERIC, 0);
277.3349 +            if (par->type == A_SYMBOLIC && cond->code->type !=
277.3350 +               A_SYMBOLIC)
277.3351 +               cond->code = make_unary(mpl, O_CVTSYM, cond->code,
277.3352 +                  A_SYMBOLIC, 0);
277.3353 +         }
277.3354 +         else if (mpl->token == T_IN || mpl->token == T_WITHIN)
277.3355 +         {  /* restricting superset */
277.3356 +            WITHIN *in, *temp;
277.3357 +            if (mpl->token == T_WITHIN && !mpl->as_in)
277.3358 +            {  warning(mpl, "keyword within understood as in");
277.3359 +               mpl->as_in = 1;
277.3360 +            }
277.3361 +            get_token(mpl /* in */);
277.3362 +            /* create new restricting superset list entry and append it
277.3363 +               to the in-list */
277.3364 +            in = alloc(WITHIN);
277.3365 +            in->code = NULL;
277.3366 +            in->next = NULL;
277.3367 +            if (par->in == NULL)
277.3368 +               par->in = in;
277.3369 +            else
277.3370 +            {  for (temp = par->in; temp->next != NULL; temp =
277.3371 +                  temp->next);
277.3372 +               temp->next = in;
277.3373 +            }
277.3374 +            /* parse an expression that follows 'in' */
277.3375 +            in->code = expression_9(mpl);
277.3376 +            if (in->code->type != A_ELEMSET)
277.3377 +               error(mpl, "expression following in has invalid type");
277.3378 +            xassert(in->code->dim > 0);
277.3379 +            if (in->code->dim != 1)
277.3380 +               error(mpl, "set expression following in must have dimens"
277.3381 +                  "ion 1 rather than %d", in->code->dim);
277.3382 +         }
277.3383 +         else if (mpl->token == T_ASSIGN)
277.3384 +         {  /* assignment expression */
277.3385 +            if (!(par->assign == NULL && par->option == NULL))
277.3386 +err:           error(mpl, "at most one := or default allowed");
277.3387 +            get_token(mpl /* := */);
277.3388 +            /* parse an expression that follows ':=' */
277.3389 +            par->assign = expression_5(mpl);
277.3390 +            /* the expression must be of numeric/symbolic type */
277.3391 +            if (!(par->assign->type == A_NUMERIC ||
277.3392 +                  par->assign->type == A_SYMBOLIC))
277.3393 +               error(mpl, "expression following := has invalid type");
277.3394 +            xassert(par->assign->dim == 0);
277.3395 +            /* convert to the parameter type, if necessary */
277.3396 +            if (par->type != A_SYMBOLIC && par->assign->type ==
277.3397 +               A_SYMBOLIC)
277.3398 +               par->assign = make_unary(mpl, O_CVTNUM, par->assign,
277.3399 +                  A_NUMERIC, 0);
277.3400 +            if (par->type == A_SYMBOLIC && par->assign->type !=
277.3401 +               A_SYMBOLIC)
277.3402 +               par->assign = make_unary(mpl, O_CVTSYM, par->assign,
277.3403 +                  A_SYMBOLIC, 0);
277.3404 +         }
277.3405 +         else if (is_keyword(mpl, "default"))
277.3406 +         {  /* expression for default value */
277.3407 +            if (!(par->assign == NULL && par->option == NULL)) goto err;
277.3408 +            get_token(mpl /* default */);
277.3409 +            /* parse an expression that follows 'default' */
277.3410 +            par->option = expression_5(mpl);
277.3411 +            if (!(par->option->type == A_NUMERIC ||
277.3412 +                  par->option->type == A_SYMBOLIC))
277.3413 +               error(mpl, "expression following default has invalid typ"
277.3414 +                  "e");
277.3415 +            xassert(par->option->dim == 0);
277.3416 +            /* convert to the parameter type, if necessary */
277.3417 +            if (par->type != A_SYMBOLIC && par->option->type ==
277.3418 +               A_SYMBOLIC)
277.3419 +               par->option = make_unary(mpl, O_CVTNUM, par->option,
277.3420 +                  A_NUMERIC, 0);
277.3421 +            if (par->type == A_SYMBOLIC && par->option->type !=
277.3422 +               A_SYMBOLIC)
277.3423 +               par->option = make_unary(mpl, O_CVTSYM, par->option,
277.3424 +                  A_SYMBOLIC, 0);
277.3425 +         }
277.3426 +         else
277.3427 +            error(mpl, "syntax error in parameter statement");
277.3428 +      }
277.3429 +      /* close the domain scope */
277.3430 +      if (par->domain != NULL) close_scope(mpl, par->domain);
277.3431 +      /* the parameter statement has been completely parsed */
277.3432 +      xassert(mpl->token == T_SEMICOLON);
277.3433 +      get_token(mpl /* ; */);
277.3434 +      return par;
277.3435 +}
277.3436 +
277.3437 +/*----------------------------------------------------------------------
277.3438 +-- variable_statement - parse variable statement.
277.3439 +--
277.3440 +-- This routine parses variable statement using the syntax:
277.3441 +--
277.3442 +-- <variable statement> ::= var <symbolic name> <alias> <domain>
277.3443 +--                          <attributes> ;
277.3444 +-- <alias> ::= <empty>
277.3445 +-- <alias> ::= <string literal>
277.3446 +-- <domain> ::= <empty>
277.3447 +-- <domain> ::= <indexing expression>
277.3448 +-- <attributes> ::= <empty>
277.3449 +-- <attributes> ::= <attributes> , integer
277.3450 +-- <attributes> ::= <attributes> , binary
277.3451 +-- <attributes> ::= <attributes> , <rho> <expression 5>
277.3452 +-- <rho> ::= >= | <= | = | ==
277.3453 +--
277.3454 +-- Commae in <attributes> are optional and may be omitted anywhere. */
277.3455 +
277.3456 +VARIABLE *variable_statement(MPL *mpl)
277.3457 +{     VARIABLE *var;
277.3458 +      int integer_used = 0, binary_used = 0;
277.3459 +      xassert(is_keyword(mpl, "var"));
277.3460 +      if (mpl->flag_s)
277.3461 +         error(mpl, "variable statement must precede solve statement");
277.3462 +      get_token(mpl /* var */);
277.3463 +      /* symbolic name must follow the keyword 'var' */
277.3464 +      if (mpl->token == T_NAME)
277.3465 +         ;
277.3466 +      else if (is_reserved(mpl))
277.3467 +         error(mpl, "invalid use of reserved keyword %s", mpl->image);
277.3468 +      else
277.3469 +         error(mpl, "symbolic name missing where expected");
277.3470 +      /* there must be no other object with the same name */
277.3471 +      if (avl_find_node(mpl->tree, mpl->image) != NULL)
277.3472 +         error(mpl, "%s multiply declared", mpl->image);
277.3473 +      /* create model variable */
277.3474 +      var = alloc(VARIABLE);
277.3475 +      var->name = dmp_get_atomv(mpl->pool, strlen(mpl->image)+1);
277.3476 +      strcpy(var->name, mpl->image);
277.3477 +      var->alias = NULL;
277.3478 +      var->dim = 0;
277.3479 +      var->domain = NULL;
277.3480 +      var->type = A_NUMERIC;
277.3481 +      var->lbnd = NULL;
277.3482 +      var->ubnd = NULL;
277.3483 +      var->array = NULL;
277.3484 +      get_token(mpl /* <symbolic name> */);
277.3485 +      /* parse optional alias */
277.3486 +      if (mpl->token == T_STRING)
277.3487 +      {  var->alias = dmp_get_atomv(mpl->pool, strlen(mpl->image)+1);
277.3488 +         strcpy(var->alias, mpl->image);
277.3489 +         get_token(mpl /* <string literal> */);
277.3490 +      }
277.3491 +      /* parse optional indexing expression */
277.3492 +      if (mpl->token == T_LBRACE)
277.3493 +      {  var->domain = indexing_expression(mpl);
277.3494 +         var->dim = domain_arity(mpl, var->domain);
277.3495 +      }
277.3496 +      /* include the variable name in the symbolic names table */
277.3497 +      {  AVLNODE *node;
277.3498 +         node = avl_insert_node(mpl->tree, var->name);
277.3499 +         avl_set_node_type(node, A_VARIABLE);
277.3500 +         avl_set_node_link(node, (void *)var);
277.3501 +      }
277.3502 +      /* parse the list of optional attributes */
277.3503 +      for (;;)
277.3504 +      {  if (mpl->token == T_COMMA)
277.3505 +            get_token(mpl /* , */);
277.3506 +         else if (mpl->token == T_SEMICOLON)
277.3507 +            break;
277.3508 +         if (is_keyword(mpl, "integer"))
277.3509 +         {  if (integer_used)
277.3510 +               error(mpl, "at most one integer allowed");
277.3511 +            if (var->type != A_BINARY) var->type = A_INTEGER;
277.3512 +            integer_used = 1;
277.3513 +            get_token(mpl /* integer */);
277.3514 +         }
277.3515 +         else if (is_keyword(mpl, "binary"))
277.3516 +bin:     {  if (binary_used)
277.3517 +               error(mpl, "at most one binary allowed");
277.3518 +            var->type = A_BINARY;
277.3519 +            binary_used = 1;
277.3520 +            get_token(mpl /* binary */);
277.3521 +         }
277.3522 +         else if (is_keyword(mpl, "logical"))
277.3523 +         {  if (!mpl->as_binary)
277.3524 +            {  warning(mpl, "keyword logical understood as binary");
277.3525 +               mpl->as_binary = 1;
277.3526 +            }
277.3527 +            goto bin;
277.3528 +         }
277.3529 +         else if (is_keyword(mpl, "symbolic"))
277.3530 +            error(mpl, "variable cannot be symbolic");
277.3531 +         else if (mpl->token == T_GE)
277.3532 +         {  /* lower bound */
277.3533 +            if (var->lbnd != NULL)
277.3534 +            {  if (var->lbnd == var->ubnd)
277.3535 +                  error(mpl, "both fixed value and lower bound not allo"
277.3536 +                     "wed");
277.3537 +               else
277.3538 +                  error(mpl, "at most one lower bound allowed");
277.3539 +            }
277.3540 +            get_token(mpl /* >= */);
277.3541 +            /* parse an expression that specifies the lower bound */
277.3542 +            var->lbnd = expression_5(mpl);
277.3543 +            if (var->lbnd->type == A_SYMBOLIC)
277.3544 +               var->lbnd = make_unary(mpl, O_CVTNUM, var->lbnd,
277.3545 +                  A_NUMERIC, 0);
277.3546 +            if (var->lbnd->type != A_NUMERIC)
277.3547 +               error(mpl, "expression following >= has invalid type");
277.3548 +            xassert(var->lbnd->dim == 0);
277.3549 +         }
277.3550 +         else if (mpl->token == T_LE)
277.3551 +         {  /* upper bound */
277.3552 +            if (var->ubnd != NULL)
277.3553 +            {  if (var->ubnd == var->lbnd)
277.3554 +                  error(mpl, "both fixed value and upper bound not allo"
277.3555 +                     "wed");
277.3556 +               else
277.3557 +                  error(mpl, "at most one upper bound allowed");
277.3558 +            }
277.3559 +            get_token(mpl /* <= */);
277.3560 +            /* parse an expression that specifies the upper bound */
277.3561 +            var->ubnd = expression_5(mpl);
277.3562 +            if (var->ubnd->type == A_SYMBOLIC)
277.3563 +               var->ubnd = make_unary(mpl, O_CVTNUM, var->ubnd,
277.3564 +                  A_NUMERIC, 0);
277.3565 +            if (var->ubnd->type != A_NUMERIC)
277.3566 +               error(mpl, "expression following <= has invalid type");
277.3567 +            xassert(var->ubnd->dim == 0);
277.3568 +         }
277.3569 +         else if (mpl->token == T_EQ)
277.3570 +         {  /* fixed value */
277.3571 +            char opstr[8];
277.3572 +            if (!(var->lbnd == NULL && var->ubnd == NULL))
277.3573 +            {  if (var->lbnd == var->ubnd)
277.3574 +                  error(mpl, "at most one fixed value allowed");
277.3575 +               else if (var->lbnd != NULL)
277.3576 +                  error(mpl, "both lower bound and fixed value not allo"
277.3577 +                     "wed");
277.3578 +               else
277.3579 +                  error(mpl, "both upper bound and fixed value not allo"
277.3580 +                     "wed");
277.3581 +            }
277.3582 +            strcpy(opstr, mpl->image);
277.3583 +            xassert(strlen(opstr) < sizeof(opstr));
277.3584 +            get_token(mpl /* = | == */);
277.3585 +            /* parse an expression that specifies the fixed value */
277.3586 +            var->lbnd = expression_5(mpl);
277.3587 +            if (var->lbnd->type == A_SYMBOLIC)
277.3588 +               var->lbnd = make_unary(mpl, O_CVTNUM, var->lbnd,
277.3589 +                  A_NUMERIC, 0);
277.3590 +            if (var->lbnd->type != A_NUMERIC)
277.3591 +               error(mpl, "expression following %s has invalid type",
277.3592 +                  opstr);
277.3593 +            xassert(var->lbnd->dim == 0);
277.3594 +            /* indicate that the variable is fixed, not bounded */
277.3595 +            var->ubnd = var->lbnd;
277.3596 +         }
277.3597 +         else if (mpl->token == T_LT || mpl->token == T_GT ||
277.3598 +                  mpl->token == T_NE)
277.3599 +            error(mpl, "strict bound not allowed");
277.3600 +         else
277.3601 +            error(mpl, "syntax error in variable statement");
277.3602 +      }
277.3603 +      /* close the domain scope */
277.3604 +      if (var->domain != NULL) close_scope(mpl, var->domain);
277.3605 +      /* the variable statement has been completely parsed */
277.3606 +      xassert(mpl->token == T_SEMICOLON);
277.3607 +      get_token(mpl /* ; */);
277.3608 +      return var;
277.3609 +}
277.3610 +
277.3611 +/*----------------------------------------------------------------------
277.3612 +-- constraint_statement - parse constraint statement.
277.3613 +--
277.3614 +-- This routine parses constraint statement using the syntax:
277.3615 +--
277.3616 +-- <constraint statement> ::= <subject to> <symbolic name> <alias>
277.3617 +--                            <domain> : <constraint> ;
277.3618 +-- <subject to> ::= <empty>
277.3619 +-- <subject to> ::= subject to
277.3620 +-- <subject to> ::= subj to
277.3621 +-- <subject to> ::= s.t.
277.3622 +-- <alias> ::= <empty>
277.3623 +-- <alias> ::= <string literal>
277.3624 +-- <domain> ::= <empty>
277.3625 +-- <domain> ::= <indexing expression>
277.3626 +-- <constraint> ::= <formula> , >= <formula>
277.3627 +-- <constraint> ::= <formula> , <= <formula>
277.3628 +-- <constraint> ::= <formula> , = <formula>
277.3629 +-- <constraint> ::= <formula> , <= <formula> , <= <formula>
277.3630 +-- <constraint> ::= <formula> , >= <formula> , >= <formula>
277.3631 +-- <formula> ::= <expression 5>
277.3632 +--
277.3633 +-- Commae in <constraint> are optional and may be omitted anywhere. */
277.3634 +
277.3635 +CONSTRAINT *constraint_statement(MPL *mpl)
277.3636 +{     CONSTRAINT *con;
277.3637 +      CODE *first, *second, *third;
277.3638 +      int rho;
277.3639 +      char opstr[8];
277.3640 +      if (mpl->flag_s)
277.3641 +         error(mpl, "constraint statement must precede solve statement")
277.3642 +            ;
277.3643 +      if (is_keyword(mpl, "subject"))
277.3644 +      {  get_token(mpl /* subject */);
277.3645 +         if (!is_keyword(mpl, "to"))
277.3646 +            error(mpl, "keyword subject to incomplete");
277.3647 +         get_token(mpl /* to */);
277.3648 +      }
277.3649 +      else if (is_keyword(mpl, "subj"))
277.3650 +      {  get_token(mpl /* subj */);
277.3651 +         if (!is_keyword(mpl, "to"))
277.3652 +            error(mpl, "keyword subj to incomplete");
277.3653 +         get_token(mpl /* to */);
277.3654 +      }
277.3655 +      else if (mpl->token == T_SPTP)
277.3656 +         get_token(mpl /* s.t. */);
277.3657 +      /* the current token must be symbolic name of constraint */
277.3658 +      if (mpl->token == T_NAME)
277.3659 +         ;
277.3660 +      else if (is_reserved(mpl))
277.3661 +         error(mpl, "invalid use of reserved keyword %s", mpl->image);
277.3662 +      else
277.3663 +         error(mpl, "symbolic name missing where expected");
277.3664 +      /* there must be no other object with the same name */
277.3665 +      if (avl_find_node(mpl->tree, mpl->image) != NULL)
277.3666 +         error(mpl, "%s multiply declared", mpl->image);
277.3667 +      /* create model constraint */
277.3668 +      con = alloc(CONSTRAINT);
277.3669 +      con->name = dmp_get_atomv(mpl->pool, strlen(mpl->image)+1);
277.3670 +      strcpy(con->name, mpl->image);
277.3671 +      con->alias = NULL;
277.3672 +      con->dim = 0;
277.3673 +      con->domain = NULL;
277.3674 +      con->type = A_CONSTRAINT;
277.3675 +      con->code = NULL;
277.3676 +      con->lbnd = NULL;
277.3677 +      con->ubnd = NULL;
277.3678 +      con->array = NULL;
277.3679 +      get_token(mpl /* <symbolic name> */);
277.3680 +      /* parse optional alias */
277.3681 +      if (mpl->token == T_STRING)
277.3682 +      {  con->alias = dmp_get_atomv(mpl->pool, strlen(mpl->image)+1);
277.3683 +         strcpy(con->alias, mpl->image);
277.3684 +         get_token(mpl /* <string literal> */);
277.3685 +      }
277.3686 +      /* parse optional indexing expression */
277.3687 +      if (mpl->token == T_LBRACE)
277.3688 +      {  con->domain = indexing_expression(mpl);
277.3689 +         con->dim = domain_arity(mpl, con->domain);
277.3690 +      }
277.3691 +      /* include the constraint name in the symbolic names table */
277.3692 +      {  AVLNODE *node;
277.3693 +         node = avl_insert_node(mpl->tree, con->name);
277.3694 +         avl_set_node_type(node, A_CONSTRAINT);
277.3695 +         avl_set_node_link(node, (void *)con);
277.3696 +      }
277.3697 +      /* the colon must precede the first expression */
277.3698 +      if (mpl->token != T_COLON)
277.3699 +         error(mpl, "colon missing where expected");
277.3700 +      get_token(mpl /* : */);
277.3701 +      /* parse the first expression */
277.3702 +      first = expression_5(mpl);
277.3703 +      if (first->type == A_SYMBOLIC)
277.3704 +         first = make_unary(mpl, O_CVTNUM, first, A_NUMERIC, 0);
277.3705 +      if (!(first->type == A_NUMERIC || first->type == A_FORMULA))
277.3706 +         error(mpl, "expression following colon has invalid type");
277.3707 +      xassert(first->dim == 0);
277.3708 +      /* relational operator must follow the first expression */
277.3709 +      if (mpl->token == T_COMMA) get_token(mpl /* , */);
277.3710 +      switch (mpl->token)
277.3711 +      {  case T_LE:
277.3712 +         case T_GE:
277.3713 +         case T_EQ:
277.3714 +            break;
277.3715 +         case T_LT:
277.3716 +         case T_GT:
277.3717 +         case T_NE:
277.3718 +            error(mpl, "strict inequality not allowed");
277.3719 +         case T_SEMICOLON:
277.3720 +            error(mpl, "constraint must be equality or inequality");
277.3721 +         default:
277.3722 +            goto err;
277.3723 +      }
277.3724 +      rho = mpl->token;
277.3725 +      strcpy(opstr, mpl->image);
277.3726 +      xassert(strlen(opstr) < sizeof(opstr));
277.3727 +      get_token(mpl /* rho */);
277.3728 +      /* parse the second expression */
277.3729 +      second = expression_5(mpl);
277.3730 +      if (second->type == A_SYMBOLIC)
277.3731 +         second = make_unary(mpl, O_CVTNUM, second, A_NUMERIC, 0);
277.3732 +      if (!(second->type == A_NUMERIC || second->type == A_FORMULA))
277.3733 +         error(mpl, "expression following %s has invalid type", opstr);
277.3734 +      xassert(second->dim == 0);
277.3735 +      /* check a token that follow the second expression */
277.3736 +      if (mpl->token == T_COMMA)
277.3737 +      {  get_token(mpl /* , */);
277.3738 +         if (mpl->token == T_SEMICOLON) goto err;
277.3739 +      }
277.3740 +      if (mpl->token == T_LT || mpl->token == T_LE ||
277.3741 +          mpl->token == T_EQ || mpl->token == T_GE ||
277.3742 +          mpl->token == T_GT || mpl->token == T_NE)
277.3743 +      {  /* it is another relational operator, therefore the constraint
277.3744 +            is double inequality */
277.3745 +         if (rho == T_EQ || mpl->token != rho)
277.3746 +            error(mpl, "double inequality must be ... <= ... <= ... or "
277.3747 +               "... >= ... >= ...");
277.3748 +         /* the first expression cannot be linear form */
277.3749 +         if (first->type == A_FORMULA)
277.3750 +            error(mpl, "leftmost expression in double inequality cannot"
277.3751 +               " be linear form");
277.3752 +         get_token(mpl /* rho */);
277.3753 +         /* parse the third expression */
277.3754 +         third = expression_5(mpl);
277.3755 +         if (third->type == A_SYMBOLIC)
277.3756 +            third = make_unary(mpl, O_CVTNUM, second, A_NUMERIC, 0);
277.3757 +         if (!(third->type == A_NUMERIC || third->type == A_FORMULA))
277.3758 +            error(mpl, "rightmost expression in double inequality const"
277.3759 +               "raint has invalid type");
277.3760 +         xassert(third->dim == 0);
277.3761 +         /* the third expression also cannot be linear form */
277.3762 +         if (third->type == A_FORMULA)
277.3763 +            error(mpl, "rightmost expression in double inequality canno"
277.3764 +               "t be linear form");
277.3765 +      }
277.3766 +      else
277.3767 +      {  /* the constraint is equality or single inequality */
277.3768 +         third = NULL;
277.3769 +      }
277.3770 +      /* close the domain scope */
277.3771 +      if (con->domain != NULL) close_scope(mpl, con->domain);
277.3772 +      /* convert all expressions to linear form, if necessary */
277.3773 +      if (first->type != A_FORMULA)
277.3774 +         first = make_unary(mpl, O_CVTLFM, first, A_FORMULA, 0);
277.3775 +      if (second->type != A_FORMULA)
277.3776 +         second = make_unary(mpl, O_CVTLFM, second, A_FORMULA, 0);
277.3777 +      if (third != NULL)
277.3778 +         third = make_unary(mpl, O_CVTLFM, third, A_FORMULA, 0);
277.3779 +      /* arrange expressions in the constraint */
277.3780 +      if (third == NULL)
277.3781 +      {  /* the constraint is equality or single inequality */
277.3782 +         switch (rho)
277.3783 +         {  case T_LE:
277.3784 +               /* first <= second */
277.3785 +               con->code = first;
277.3786 +               con->lbnd = NULL;
277.3787 +               con->ubnd = second;
277.3788 +               break;
277.3789 +            case T_GE:
277.3790 +               /* first >= second */
277.3791 +               con->code = first;
277.3792 +               con->lbnd = second;
277.3793 +               con->ubnd = NULL;
277.3794 +               break;
277.3795 +            case T_EQ:
277.3796 +               /* first = second */
277.3797 +               con->code = first;
277.3798 +               con->lbnd = second;
277.3799 +               con->ubnd = second;
277.3800 +               break;
277.3801 +            default:
277.3802 +               xassert(rho != rho);
277.3803 +         }
277.3804 +      }
277.3805 +      else
277.3806 +      {  /* the constraint is double inequality */
277.3807 +         switch (rho)
277.3808 +         {  case T_LE:
277.3809 +               /* first <= second <= third */
277.3810 +               con->code = second;
277.3811 +               con->lbnd = first;
277.3812 +               con->ubnd = third;
277.3813 +               break;
277.3814 +            case T_GE:
277.3815 +               /* first >= second >= third */
277.3816 +               con->code = second;
277.3817 +               con->lbnd = third;
277.3818 +               con->ubnd = first;
277.3819 +               break;
277.3820 +            default:
277.3821 +               xassert(rho != rho);
277.3822 +         }
277.3823 +      }
277.3824 +      /* the constraint statement has been completely parsed */
277.3825 +      if (mpl->token != T_SEMICOLON)
277.3826 +err:     error(mpl, "syntax error in constraint statement");
277.3827 +      get_token(mpl /* ; */);
277.3828 +      return con;
277.3829 +}
277.3830 +
277.3831 +/*----------------------------------------------------------------------
277.3832 +-- objective_statement - parse objective statement.
277.3833 +--
277.3834 +-- This routine parses objective statement using the syntax:
277.3835 +--
277.3836 +-- <objective statement> ::= <verb> <symbolic name> <alias> <domain> :
277.3837 +--                           <formula> ;
277.3838 +-- <verb> ::= minimize
277.3839 +-- <verb> ::= maximize
277.3840 +-- <alias> ::= <empty>
277.3841 +-- <alias> ::= <string literal>
277.3842 +-- <domain> ::= <empty>
277.3843 +-- <domain> ::= <indexing expression>
277.3844 +-- <formula> ::= <expression 5> */
277.3845 +
277.3846 +CONSTRAINT *objective_statement(MPL *mpl)
277.3847 +{     CONSTRAINT *obj;
277.3848 +      int type;
277.3849 +      if (is_keyword(mpl, "minimize"))
277.3850 +         type = A_MINIMIZE;
277.3851 +      else if (is_keyword(mpl, "maximize"))
277.3852 +         type = A_MAXIMIZE;
277.3853 +      else
277.3854 +         xassert(mpl != mpl);
277.3855 +      if (mpl->flag_s)
277.3856 +         error(mpl, "objective statement must precede solve statement");
277.3857 +      get_token(mpl /* minimize | maximize */);
277.3858 +      /* symbolic name must follow the verb 'minimize' or 'maximize' */
277.3859 +      if (mpl->token == T_NAME)
277.3860 +         ;
277.3861 +      else if (is_reserved(mpl))
277.3862 +         error(mpl, "invalid use of reserved keyword %s", mpl->image);
277.3863 +      else
277.3864 +         error(mpl, "symbolic name missing where expected");
277.3865 +      /* there must be no other object with the same name */
277.3866 +      if (avl_find_node(mpl->tree, mpl->image) != NULL)
277.3867 +         error(mpl, "%s multiply declared", mpl->image);
277.3868 +      /* create model objective */
277.3869 +      obj = alloc(CONSTRAINT);
277.3870 +      obj->name = dmp_get_atomv(mpl->pool, strlen(mpl->image)+1);
277.3871 +      strcpy(obj->name, mpl->image);
277.3872 +      obj->alias = NULL;
277.3873 +      obj->dim = 0;
277.3874 +      obj->domain = NULL;
277.3875 +      obj->type = type;
277.3876 +      obj->code = NULL;
277.3877 +      obj->lbnd = NULL;
277.3878 +      obj->ubnd = NULL;
277.3879 +      obj->array = NULL;
277.3880 +      get_token(mpl /* <symbolic name> */);
277.3881 +      /* parse optional alias */
277.3882 +      if (mpl->token == T_STRING)
277.3883 +      {  obj->alias = dmp_get_atomv(mpl->pool, strlen(mpl->image)+1);
277.3884 +         strcpy(obj->alias, mpl->image);
277.3885 +         get_token(mpl /* <string literal> */);
277.3886 +      }
277.3887 +      /* parse optional indexing expression */
277.3888 +      if (mpl->token == T_LBRACE)
277.3889 +      {  obj->domain = indexing_expression(mpl);
277.3890 +         obj->dim = domain_arity(mpl, obj->domain);
277.3891 +      }
277.3892 +      /* include the constraint name in the symbolic names table */
277.3893 +      {  AVLNODE *node;
277.3894 +         node = avl_insert_node(mpl->tree, obj->name);
277.3895 +         avl_set_node_type(node, A_CONSTRAINT);
277.3896 +         avl_set_node_link(node, (void *)obj);
277.3897 +      }
277.3898 +      /* the colon must precede the objective expression */
277.3899 +      if (mpl->token != T_COLON)
277.3900 +         error(mpl, "colon missing where expected");
277.3901 +      get_token(mpl /* : */);
277.3902 +      /* parse the objective expression */
277.3903 +      obj->code = expression_5(mpl);
277.3904 +      if (obj->code->type == A_SYMBOLIC)
277.3905 +         obj->code = make_unary(mpl, O_CVTNUM, obj->code, A_NUMERIC, 0);
277.3906 +      if (obj->code->type == A_NUMERIC)
277.3907 +         obj->code = make_unary(mpl, O_CVTLFM, obj->code, A_FORMULA, 0);
277.3908 +      if (obj->code->type != A_FORMULA)
277.3909 +         error(mpl, "expression following colon has invalid type");
277.3910 +      xassert(obj->code->dim == 0);
277.3911 +      /* close the domain scope */
277.3912 +      if (obj->domain != NULL) close_scope(mpl, obj->domain);
277.3913 +      /* the objective statement has been completely parsed */
277.3914 +      if (mpl->token != T_SEMICOLON)
277.3915 +         error(mpl, "syntax error in objective statement");
277.3916 +      get_token(mpl /* ; */);
277.3917 +      return obj;
277.3918 +}
277.3919 +
277.3920 +#if 1 /* 11/II-2008 */
277.3921 +/***********************************************************************
277.3922 +*  table_statement - parse table statement
277.3923 +*
277.3924 +*  This routine parses table statement using the syntax:
277.3925 +*
277.3926 +*  <table statement> ::= <input table statement>
277.3927 +*  <table statement> ::= <output table statement>
277.3928 +*
277.3929 +*  <input table statement> ::=
277.3930 +*        table <table name> <alias> IN <argument list> :
277.3931 +*        <input set> [ <field list> ] , <input list> ;
277.3932 +*  <alias> ::= <empty>
277.3933 +*  <alias> ::= <string literal>
277.3934 +*  <argument list> ::= <expression 5>
277.3935 +*  <argument list> ::= <argument list> <expression 5>
277.3936 +*  <argument list> ::= <argument list> , <expression 5>
277.3937 +*  <input set> ::= <empty>
277.3938 +*  <input set> ::= <set name> <-
277.3939 +*  <field list> ::= <field name>
277.3940 +*  <field list> ::= <field list> , <field name>
277.3941 +*  <input list> ::= <input item>
277.3942 +*  <input list> ::= <input list> , <input item>
277.3943 +*  <input item> ::= <parameter name>
277.3944 +*  <input item> ::= <parameter name> ~ <field name>
277.3945 +*
277.3946 +*  <output table statement> ::=
277.3947 +*        table <table name> <alias> <domain> OUT <argument list> :
277.3948 +*        <output list> ;
277.3949 +*  <domain> ::= <indexing expression>
277.3950 +*  <output list> ::= <output item>
277.3951 +*  <output list> ::= <output list> , <output item>
277.3952 +*  <output item> ::= <expression 5>
277.3953 +*  <output item> ::= <expression 5> ~ <field name> */
277.3954 +
277.3955 +TABLE *table_statement(MPL *mpl)
277.3956 +{     TABLE *tab;
277.3957 +      TABARG *last_arg, *arg;
277.3958 +      TABFLD *last_fld, *fld;
277.3959 +      TABIN *last_in, *in;
277.3960 +      TABOUT *last_out, *out;
277.3961 +      AVLNODE *node;
277.3962 +      int nflds;
277.3963 +      char name[MAX_LENGTH+1];
277.3964 +      xassert(is_keyword(mpl, "table"));
277.3965 +      get_token(mpl /* solve */);
277.3966 +      /* symbolic name must follow the keyword table */
277.3967 +      if (mpl->token == T_NAME)
277.3968 +         ;
277.3969 +      else if (is_reserved(mpl))
277.3970 +         error(mpl, "invalid use of reserved keyword %s", mpl->image);
277.3971 +      else
277.3972 +         error(mpl, "symbolic name missing where expected");
277.3973 +      /* there must be no other object with the same name */
277.3974 +      if (avl_find_node(mpl->tree, mpl->image) != NULL)
277.3975 +         error(mpl, "%s multiply declared", mpl->image);
277.3976 +      /* create data table */
277.3977 +      tab = alloc(TABLE);
277.3978 +      tab->name = dmp_get_atomv(mpl->pool, strlen(mpl->image)+1);
277.3979 +      strcpy(tab->name, mpl->image);
277.3980 +      get_token(mpl /* <symbolic name> */);
277.3981 +      /* parse optional alias */
277.3982 +      if (mpl->token == T_STRING)
277.3983 +      {  tab->alias = dmp_get_atomv(mpl->pool, strlen(mpl->image)+1);
277.3984 +         strcpy(tab->alias, mpl->image);
277.3985 +         get_token(mpl /* <string literal> */);
277.3986 +      }
277.3987 +      else
277.3988 +         tab->alias = NULL;
277.3989 +      /* parse optional indexing expression */
277.3990 +      if (mpl->token == T_LBRACE)
277.3991 +      {  /* this is output table */
277.3992 +         tab->type = A_OUTPUT;
277.3993 +         tab->u.out.domain = indexing_expression(mpl);
277.3994 +         if (!is_keyword(mpl, "OUT"))
277.3995 +            error(mpl, "keyword OUT missing where expected");
277.3996 +         get_token(mpl /* OUT */);
277.3997 +      }
277.3998 +      else
277.3999 +      {  /* this is input table */
277.4000 +         tab->type = A_INPUT;
277.4001 +         if (!is_keyword(mpl, "IN"))
277.4002 +            error(mpl, "keyword IN missing where expected");
277.4003 +         get_token(mpl /* IN */);
277.4004 +      }
277.4005 +      /* parse argument list */
277.4006 +      tab->arg = last_arg = NULL;
277.4007 +      for (;;)
277.4008 +      {  /* create argument list entry */
277.4009 +         arg = alloc(TABARG);
277.4010 +         /* parse argument expression */
277.4011 +         if (mpl->token == T_COMMA || mpl->token == T_COLON ||
277.4012 +             mpl->token == T_SEMICOLON)
277.4013 +            error(mpl, "argument expression missing where expected");
277.4014 +         arg->code = expression_5(mpl);
277.4015 +         /* convert the result to symbolic type, if necessary */
277.4016 +         if (arg->code->type == A_NUMERIC)
277.4017 +            arg->code =
277.4018 +               make_unary(mpl, O_CVTSYM, arg->code, A_SYMBOLIC, 0);
277.4019 +         /* check that now the result is of symbolic type */
277.4020 +         if (arg->code->type != A_SYMBOLIC)
277.4021 +            error(mpl, "argument expression has invalid type");
277.4022 +         /* add the entry to the end of the list */
277.4023 +         arg->next = NULL;
277.4024 +         if (last_arg == NULL)
277.4025 +            tab->arg = arg;
277.4026 +         else
277.4027 +            last_arg->next = arg;
277.4028 +         last_arg = arg;
277.4029 +         /* argument expression has been parsed */
277.4030 +         if (mpl->token == T_COMMA)
277.4031 +            get_token(mpl /* , */);
277.4032 +         else if (mpl->token == T_COLON || mpl->token == T_SEMICOLON)
277.4033 +            break;
277.4034 +      }
277.4035 +      xassert(tab->arg != NULL);
277.4036 +      /* argument list must end with colon */
277.4037 +      if (mpl->token == T_COLON)
277.4038 +         get_token(mpl /* : */);
277.4039 +      else
277.4040 +         error(mpl, "colon missing where expected");
277.4041 +      /* parse specific part of the table statement */
277.4042 +      switch (tab->type)
277.4043 +      {  case A_INPUT:  goto input_table;
277.4044 +         case A_OUTPUT: goto output_table;
277.4045 +         default:       xassert(tab != tab);
277.4046 +      }
277.4047 +input_table:
277.4048 +      /* parse optional set name */
277.4049 +      if (mpl->token == T_NAME)
277.4050 +      {  node = avl_find_node(mpl->tree, mpl->image);
277.4051 +         if (node == NULL)
277.4052 +            error(mpl, "%s not defined", mpl->image);
277.4053 +         if (avl_get_node_type(node) != A_SET)
277.4054 +            error(mpl, "%s not a set", mpl->image);
277.4055 +         tab->u.in.set = (SET *)avl_get_node_link(node);
277.4056 +         if (tab->u.in.set->assign != NULL)
277.4057 +            error(mpl, "%s needs no data", mpl->image);
277.4058 +         if (tab->u.in.set->dim != 0)
277.4059 +            error(mpl, "%s must be a simple set", mpl->image);
277.4060 +         get_token(mpl /* <symbolic name> */);
277.4061 +         if (mpl->token == T_INPUT)
277.4062 +            get_token(mpl /* <- */);
277.4063 +         else
277.4064 +            error(mpl, "delimiter <- missing where expected");
277.4065 +      }
277.4066 +      else if (is_reserved(mpl))
277.4067 +         error(mpl, "invalid use of reserved keyword %s", mpl->image);
277.4068 +      else
277.4069 +         tab->u.in.set = NULL;
277.4070 +      /* parse field list */
277.4071 +      tab->u.in.fld = last_fld = NULL;
277.4072 +      nflds = 0;
277.4073 +      if (mpl->token == T_LBRACKET)
277.4074 +         get_token(mpl /* [ */);
277.4075 +      else
277.4076 +         error(mpl, "field list missing where expected");
277.4077 +      for (;;)
277.4078 +      {  /* create field list entry */
277.4079 +         fld = alloc(TABFLD);
277.4080 +         /* parse field name */
277.4081 +         if (mpl->token == T_NAME)
277.4082 +            ;
277.4083 +         else if (is_reserved(mpl))
277.4084 +            error(mpl,
277.4085 +               "invalid use of reserved keyword %s", mpl->image);
277.4086 +         else
277.4087 +            error(mpl, "field name missing where expected");
277.4088 +         fld->name = dmp_get_atomv(mpl->pool, strlen(mpl->image)+1);
277.4089 +         strcpy(fld->name, mpl->image);
277.4090 +         get_token(mpl /* <symbolic name> */);
277.4091 +         /* add the entry to the end of the list */
277.4092 +         fld->next = NULL;
277.4093 +         if (last_fld == NULL)
277.4094 +            tab->u.in.fld = fld;
277.4095 +         else
277.4096 +            last_fld->next = fld;
277.4097 +         last_fld = fld;
277.4098 +         nflds++;
277.4099 +         /* field name has been parsed */
277.4100 +         if (mpl->token == T_COMMA)
277.4101 +            get_token(mpl /* , */);
277.4102 +         else if (mpl->token == T_RBRACKET)
277.4103 +            break;
277.4104 +         else
277.4105 +            error(mpl, "syntax error in field list");
277.4106 +      }
277.4107 +      /* check that the set dimen is equal to the number of fields */
277.4108 +      if (tab->u.in.set != NULL && tab->u.in.set->dimen != nflds)
277.4109 +         error(mpl, "there must be %d field%s rather than %d",
277.4110 +            tab->u.in.set->dimen, tab->u.in.set->dimen == 1 ? "" : "s",
277.4111 +            nflds);
277.4112 +      get_token(mpl /* ] */);
277.4113 +      /* parse optional input list */
277.4114 +      tab->u.in.list = last_in = NULL;
277.4115 +      while (mpl->token == T_COMMA)
277.4116 +      {  get_token(mpl /* , */);
277.4117 +         /* create input list entry */
277.4118 +         in = alloc(TABIN);
277.4119 +         /* parse parameter name */
277.4120 +         if (mpl->token == T_NAME)
277.4121 +            ;
277.4122 +         else if (is_reserved(mpl))
277.4123 +            error(mpl,
277.4124 +               "invalid use of reserved keyword %s", mpl->image);
277.4125 +         else
277.4126 +            error(mpl, "parameter name missing where expected");
277.4127 +         node = avl_find_node(mpl->tree, mpl->image);
277.4128 +         if (node == NULL)
277.4129 +            error(mpl, "%s not defined", mpl->image);
277.4130 +         if (avl_get_node_type(node) != A_PARAMETER)
277.4131 +            error(mpl, "%s not a parameter", mpl->image);
277.4132 +         in->par = (PARAMETER *)avl_get_node_link(node);
277.4133 +         if (in->par->dim != nflds)
277.4134 +            error(mpl, "%s must have %d subscript%s rather than %d",
277.4135 +               mpl->image, nflds, nflds == 1 ? "" : "s", in->par->dim);
277.4136 +         if (in->par->assign != NULL)
277.4137 +            error(mpl, "%s needs no data", mpl->image);
277.4138 +         get_token(mpl /* <symbolic name> */);
277.4139 +         /* parse optional field name */
277.4140 +         if (mpl->token == T_TILDE)
277.4141 +         {  get_token(mpl /* ~ */);
277.4142 +            /* parse field name */
277.4143 +            if (mpl->token == T_NAME)
277.4144 +               ;
277.4145 +            else if (is_reserved(mpl))
277.4146 +               error(mpl,
277.4147 +                  "invalid use of reserved keyword %s", mpl->image);
277.4148 +            else
277.4149 +               error(mpl, "field name missing where expected");
277.4150 +            xassert(strlen(mpl->image) < sizeof(name));
277.4151 +            strcpy(name, mpl->image);
277.4152 +            get_token(mpl /* <symbolic name> */);
277.4153 +         }
277.4154 +         else
277.4155 +         {  /* field name is the same as the parameter name */
277.4156 +            xassert(strlen(in->par->name) < sizeof(name));
277.4157 +            strcpy(name, in->par->name);
277.4158 +         }
277.4159 +         /* assign field name */
277.4160 +         in->name = dmp_get_atomv(mpl->pool, strlen(name)+1);
277.4161 +         strcpy(in->name, name);
277.4162 +         /* add the entry to the end of the list */
277.4163 +         in->next = NULL;
277.4164 +         if (last_in == NULL)
277.4165 +            tab->u.in.list = in;
277.4166 +         else
277.4167 +            last_in->next = in;
277.4168 +         last_in = in;
277.4169 +      }
277.4170 +      goto end_of_table;
277.4171 +output_table:
277.4172 +      /* parse output list */
277.4173 +      tab->u.out.list = last_out = NULL;
277.4174 +      for (;;)
277.4175 +      {  /* create output list entry */
277.4176 +         out = alloc(TABOUT);
277.4177 +         /* parse expression */
277.4178 +         if (mpl->token == T_COMMA || mpl->token == T_SEMICOLON)
277.4179 +            error(mpl, "expression missing where expected");
277.4180 +         if (mpl->token == T_NAME)
277.4181 +         {  xassert(strlen(mpl->image) < sizeof(name));
277.4182 +            strcpy(name, mpl->image);
277.4183 +         }
277.4184 +         else
277.4185 +            name[0] = '\0';
277.4186 +         out->code = expression_5(mpl);
277.4187 +         /* parse optional field name */
277.4188 +         if (mpl->token == T_TILDE)
277.4189 +         {  get_token(mpl /* ~ */);
277.4190 +            /* parse field name */
277.4191 +            if (mpl->token == T_NAME)
277.4192 +               ;
277.4193 +            else if (is_reserved(mpl))
277.4194 +               error(mpl,
277.4195 +                  "invalid use of reserved keyword %s", mpl->image);
277.4196 +            else
277.4197 +               error(mpl, "field name missing where expected");
277.4198 +            xassert(strlen(mpl->image) < sizeof(name));
277.4199 +            strcpy(name, mpl->image);
277.4200 +            get_token(mpl /* <symbolic name> */);
277.4201 +         }
277.4202 +         /* assign field name */
277.4203 +         if (name[0] == '\0')
277.4204 +            error(mpl, "field name required");
277.4205 +         out->name = dmp_get_atomv(mpl->pool, strlen(name)+1);
277.4206 +         strcpy(out->name, name);
277.4207 +         /* add the entry to the end of the list */
277.4208 +         out->next = NULL;
277.4209 +         if (last_out == NULL)
277.4210 +            tab->u.out.list = out;
277.4211 +         else
277.4212 +            last_out->next = out;
277.4213 +         last_out = out;
277.4214 +         /* output item has been parsed */
277.4215 +         if (mpl->token == T_COMMA)
277.4216 +            get_token(mpl /* , */);
277.4217 +         else if (mpl->token == T_SEMICOLON)
277.4218 +            break;
277.4219 +         else
277.4220 +            error(mpl, "syntax error in output list");
277.4221 +      }
277.4222 +      /* close the domain scope */
277.4223 +      close_scope(mpl,tab->u.out.domain);
277.4224 +end_of_table:
277.4225 +      /* the table statement must end with semicolon */
277.4226 +      if (mpl->token != T_SEMICOLON)
277.4227 +         error(mpl, "syntax error in table statement");
277.4228 +      get_token(mpl /* ; */);
277.4229 +      return tab;
277.4230 +}
277.4231 +#endif
277.4232 +
277.4233 +/*----------------------------------------------------------------------
277.4234 +-- solve_statement - parse solve statement.
277.4235 +--
277.4236 +-- This routine parses solve statement using the syntax:
277.4237 +--
277.4238 +-- <solve statement> ::= solve ;
277.4239 +--
277.4240 +-- The solve statement can be used at most once. */
277.4241 +
277.4242 +void *solve_statement(MPL *mpl)
277.4243 +{     xassert(is_keyword(mpl, "solve"));
277.4244 +      if (mpl->flag_s)
277.4245 +         error(mpl, "at most one solve statement allowed");
277.4246 +      mpl->flag_s = 1;
277.4247 +      get_token(mpl /* solve */);
277.4248 +      /* semicolon must follow solve statement */
277.4249 +      if (mpl->token != T_SEMICOLON)
277.4250 +         error(mpl, "syntax error in solve statement");
277.4251 +      get_token(mpl /* ; */);
277.4252 +      return NULL;
277.4253 +}
277.4254 +
277.4255 +/*----------------------------------------------------------------------
277.4256 +-- check_statement - parse check statement.
277.4257 +--
277.4258 +-- This routine parses check statement using the syntax:
277.4259 +--
277.4260 +-- <check statement> ::= check <domain> : <expression 13> ;
277.4261 +-- <domain> ::= <empty>
277.4262 +-- <domain> ::= <indexing expression>
277.4263 +--
277.4264 +-- If <domain> is omitted, colon following it may also be omitted. */
277.4265 +
277.4266 +CHECK *check_statement(MPL *mpl)
277.4267 +{     CHECK *chk;
277.4268 +      xassert(is_keyword(mpl, "check"));
277.4269 +      /* create check descriptor */
277.4270 +      chk = alloc(CHECK);
277.4271 +      chk->domain = NULL;
277.4272 +      chk->code = NULL;
277.4273 +      get_token(mpl /* check */);
277.4274 +      /* parse optional indexing expression */
277.4275 +      if (mpl->token == T_LBRACE)
277.4276 +      {  chk->domain = indexing_expression(mpl);
277.4277 +#if 0
277.4278 +         if (mpl->token != T_COLON)
277.4279 +            error(mpl, "colon missing where expected");
277.4280 +#endif
277.4281 +      }
277.4282 +      /* skip optional colon */
277.4283 +      if (mpl->token == T_COLON) get_token(mpl /* : */);
277.4284 +      /* parse logical expression */
277.4285 +      chk->code = expression_13(mpl);
277.4286 +      if (chk->code->type != A_LOGICAL)
277.4287 +         error(mpl, "expression has invalid type");
277.4288 +      xassert(chk->code->dim == 0);
277.4289 +      /* close the domain scope */
277.4290 +      if (chk->domain != NULL) close_scope(mpl, chk->domain);
277.4291 +      /* the check statement has been completely parsed */
277.4292 +      if (mpl->token != T_SEMICOLON)
277.4293 +         error(mpl, "syntax error in check statement");
277.4294 +      get_token(mpl /* ; */);
277.4295 +      return chk;
277.4296 +}
277.4297 +
277.4298 +#if 1 /* 15/V-2010 */
277.4299 +/*----------------------------------------------------------------------
277.4300 +-- display_statement - parse display statement.
277.4301 +--
277.4302 +-- This routine parses display statement using the syntax:
277.4303 +--
277.4304 +-- <display statement> ::= display <domain> : <display list> ;
277.4305 +-- <display statement> ::= display <domain> <display list> ;
277.4306 +-- <domain> ::= <empty>
277.4307 +-- <domain> ::= <indexing expression>
277.4308 +-- <display list> ::= <display entry>
277.4309 +-- <display list> ::= <display list> , <display entry>
277.4310 +-- <display entry> ::= <dummy index>
277.4311 +-- <display entry> ::= <set name>
277.4312 +-- <display entry> ::= <set name> [ <subscript list> ]
277.4313 +-- <display entry> ::= <parameter name>
277.4314 +-- <display entry> ::= <parameter name> [ <subscript list> ]
277.4315 +-- <display entry> ::= <variable name>
277.4316 +-- <display entry> ::= <variable name> [ <subscript list> ]
277.4317 +-- <display entry> ::= <constraint name>
277.4318 +-- <display entry> ::= <constraint name> [ <subscript list> ]
277.4319 +-- <display entry> ::= <expression 13> */
277.4320 +
277.4321 +DISPLAY *display_statement(MPL *mpl)
277.4322 +{     DISPLAY *dpy;
277.4323 +      DISPLAY1 *entry, *last_entry;
277.4324 +      xassert(is_keyword(mpl, "display"));
277.4325 +      /* create display descriptor */
277.4326 +      dpy = alloc(DISPLAY);
277.4327 +      dpy->domain = NULL;
277.4328 +      dpy->list = last_entry = NULL;
277.4329 +      get_token(mpl /* display */);
277.4330 +      /* parse optional indexing expression */
277.4331 +      if (mpl->token == T_LBRACE)
277.4332 +         dpy->domain = indexing_expression(mpl);
277.4333 +      /* skip optional colon */
277.4334 +      if (mpl->token == T_COLON) get_token(mpl /* : */);
277.4335 +      /* parse display list */
277.4336 +      for (;;)
277.4337 +      {  /* create new display entry */
277.4338 +         entry = alloc(DISPLAY1);
277.4339 +         entry->type = 0;
277.4340 +         entry->next = NULL;
277.4341 +         /* and append it to the display list */
277.4342 +         if (dpy->list == NULL)
277.4343 +            dpy->list = entry;
277.4344 +         else
277.4345 +            last_entry->next = entry;
277.4346 +         last_entry = entry;
277.4347 +         /* parse display entry */
277.4348 +         if (mpl->token == T_NAME)
277.4349 +         {  AVLNODE *node;
277.4350 +            int next_token;
277.4351 +            get_token(mpl /* <symbolic name> */);
277.4352 +            next_token = mpl->token;
277.4353 +            unget_token(mpl);
277.4354 +            if (!(next_token == T_COMMA || next_token == T_SEMICOLON))
277.4355 +            {  /* symbolic name begins expression */
277.4356 +               goto expr;
277.4357 +            }
277.4358 +            /* display entry is dummy index or model object */
277.4359 +            node = avl_find_node(mpl->tree, mpl->image);
277.4360 +            if (node == NULL)
277.4361 +               error(mpl, "%s not defined", mpl->image);
277.4362 +            entry->type = avl_get_node_type(node);
277.4363 +            switch (avl_get_node_type(node))
277.4364 +            {  case A_INDEX:
277.4365 +                  entry->u.slot =
277.4366 +                     (DOMAIN_SLOT *)avl_get_node_link(node);
277.4367 +                  break;
277.4368 +               case A_SET:
277.4369 +                  entry->u.set = (SET *)avl_get_node_link(node);
277.4370 +                  break;
277.4371 +               case A_PARAMETER:
277.4372 +                  entry->u.par = (PARAMETER *)avl_get_node_link(node);
277.4373 +                  break;
277.4374 +               case A_VARIABLE:
277.4375 +                  entry->u.var = (VARIABLE *)avl_get_node_link(node);
277.4376 +                  if (!mpl->flag_s)
277.4377 +                     error(mpl, "invalid reference to variable %s above"
277.4378 +                        " solve statement", entry->u.var->name);
277.4379 +                  break;
277.4380 +               case A_CONSTRAINT:
277.4381 +                  entry->u.con = (CONSTRAINT *)avl_get_node_link(node);
277.4382 +                  if (!mpl->flag_s)
277.4383 +                     error(mpl, "invalid reference to %s %s above solve"
277.4384 +                        " statement",
277.4385 +                        entry->u.con->type == A_CONSTRAINT ?
277.4386 +                        "constraint" : "objective", entry->u.con->name);
277.4387 +                  break;
277.4388 +               default:
277.4389 +                  xassert(node != node);
277.4390 +            }
277.4391 +            get_token(mpl /* <symbolic name> */);
277.4392 +         }
277.4393 +         else
277.4394 +expr:    {  /* display entry is expression */
277.4395 +            entry->type = A_EXPRESSION;
277.4396 +            entry->u.code = expression_13(mpl);
277.4397 +         }
277.4398 +         /* check a token that follows the entry parsed */
277.4399 +         if (mpl->token == T_COMMA)
277.4400 +            get_token(mpl /* , */);
277.4401 +         else
277.4402 +            break;
277.4403 +      }
277.4404 +      /* close the domain scope */
277.4405 +      if (dpy->domain != NULL) close_scope(mpl, dpy->domain);
277.4406 +      /* the display statement has been completely parsed */
277.4407 +      if (mpl->token != T_SEMICOLON)
277.4408 +         error(mpl, "syntax error in display statement");
277.4409 +      get_token(mpl /* ; */);
277.4410 +      return dpy;
277.4411 +}
277.4412 +#endif
277.4413 +
277.4414 +/*----------------------------------------------------------------------
277.4415 +-- printf_statement - parse printf statement.
277.4416 +--
277.4417 +-- This routine parses print statement using the syntax:
277.4418 +--
277.4419 +-- <printf statement> ::= <printf clause> ;
277.4420 +-- <printf statement> ::= <printf clause> > <file name> ;
277.4421 +-- <printf statement> ::= <printf clause> >> <file name> ;
277.4422 +-- <printf clause> ::= printf <domain> : <format> <printf list>
277.4423 +-- <printf clause> ::= printf <domain> <format> <printf list>
277.4424 +-- <domain> ::= <empty>
277.4425 +-- <domain> ::= <indexing expression>
277.4426 +-- <format> ::= <expression 5>
277.4427 +-- <printf list> ::= <empty>
277.4428 +-- <printf list> ::= <printf list> , <printf entry>
277.4429 +-- <printf entry> ::= <expression 9>
277.4430 +-- <file name> ::= <expression 5> */
277.4431 +
277.4432 +PRINTF *printf_statement(MPL *mpl)
277.4433 +{     PRINTF *prt;
277.4434 +      PRINTF1 *entry, *last_entry;
277.4435 +      xassert(is_keyword(mpl, "printf"));
277.4436 +      /* create printf descriptor */
277.4437 +      prt = alloc(PRINTF);
277.4438 +      prt->domain = NULL;
277.4439 +      prt->fmt = NULL;
277.4440 +      prt->list = last_entry = NULL;
277.4441 +      get_token(mpl /* printf */);
277.4442 +      /* parse optional indexing expression */
277.4443 +      if (mpl->token == T_LBRACE)
277.4444 +      {  prt->domain = indexing_expression(mpl);
277.4445 +#if 0
277.4446 +         if (mpl->token != T_COLON)
277.4447 +            error(mpl, "colon missing where expected");
277.4448 +#endif
277.4449 +      }
277.4450 +      /* skip optional colon */
277.4451 +      if (mpl->token == T_COLON) get_token(mpl /* : */);
277.4452 +      /* parse expression for format string */
277.4453 +      prt->fmt = expression_5(mpl);
277.4454 +      /* convert it to symbolic type, if necessary */
277.4455 +      if (prt->fmt->type == A_NUMERIC)
277.4456 +         prt->fmt = make_unary(mpl, O_CVTSYM, prt->fmt, A_SYMBOLIC, 0);
277.4457 +      /* check that now the expression is of symbolic type */
277.4458 +      if (prt->fmt->type != A_SYMBOLIC)
277.4459 +         error(mpl, "format expression has invalid type");
277.4460 +      /* parse printf list */
277.4461 +      while (mpl->token == T_COMMA)
277.4462 +      {  get_token(mpl /* , */);
277.4463 +         /* create new printf entry */
277.4464 +         entry = alloc(PRINTF1);
277.4465 +         entry->code = NULL;
277.4466 +         entry->next = NULL;
277.4467 +         /* and append it to the printf list */
277.4468 +         if (prt->list == NULL)
277.4469 +            prt->list = entry;
277.4470 +         else
277.4471 +            last_entry->next = entry;
277.4472 +         last_entry = entry;
277.4473 +         /* parse printf entry */
277.4474 +         entry->code = expression_9(mpl);
277.4475 +         if (!(entry->code->type == A_NUMERIC ||
277.4476 +               entry->code->type == A_SYMBOLIC ||
277.4477 +               entry->code->type == A_LOGICAL))
277.4478 +            error(mpl, "only numeric, symbolic, or logical expression a"
277.4479 +               "llowed");
277.4480 +      }
277.4481 +      /* close the domain scope */
277.4482 +      if (prt->domain != NULL) close_scope(mpl, prt->domain);
277.4483 +#if 1 /* 14/VII-2006 */
277.4484 +      /* parse optional redirection */
277.4485 +      prt->fname = NULL, prt->app = 0;
277.4486 +      if (mpl->token == T_GT || mpl->token == T_APPEND)
277.4487 +      {  prt->app = (mpl->token == T_APPEND);
277.4488 +         get_token(mpl /* > or >> */);
277.4489 +         /* parse expression for file name string */
277.4490 +         prt->fname = expression_5(mpl);
277.4491 +         /* convert it to symbolic type, if necessary */
277.4492 +         if (prt->fname->type == A_NUMERIC)
277.4493 +            prt->fname = make_unary(mpl, O_CVTSYM, prt->fname,
277.4494 +               A_SYMBOLIC, 0);
277.4495 +         /* check that now the expression is of symbolic type */
277.4496 +         if (prt->fname->type != A_SYMBOLIC)
277.4497 +            error(mpl, "file name expression has invalid type");
277.4498 +      }
277.4499 +#endif
277.4500 +      /* the printf statement has been completely parsed */
277.4501 +      if (mpl->token != T_SEMICOLON)
277.4502 +         error(mpl, "syntax error in printf statement");
277.4503 +      get_token(mpl /* ; */);
277.4504 +      return prt;
277.4505 +}
277.4506 +
277.4507 +/*----------------------------------------------------------------------
277.4508 +-- for_statement - parse for statement.
277.4509 +--
277.4510 +-- This routine parses for statement using the syntax:
277.4511 +--
277.4512 +-- <for statement> ::= for <domain> <statement>
277.4513 +-- <for statement> ::= for <domain> { <statement list> }
277.4514 +-- <domain> ::= <indexing expression>
277.4515 +-- <statement list> ::= <empty>
277.4516 +-- <statement list> ::= <statement list> <statement>
277.4517 +-- <statement> ::= <check statement>
277.4518 +-- <statement> ::= <display statement>
277.4519 +-- <statement> ::= <printf statement>
277.4520 +-- <statement> ::= <for statement> */
277.4521 +
277.4522 +FOR *for_statement(MPL *mpl)
277.4523 +{     FOR *fur;
277.4524 +      STATEMENT *stmt, *last_stmt;
277.4525 +      xassert(is_keyword(mpl, "for"));
277.4526 +      /* create for descriptor */
277.4527 +      fur = alloc(FOR);
277.4528 +      fur->domain = NULL;
277.4529 +      fur->list = last_stmt = NULL;
277.4530 +      get_token(mpl /* for */);
277.4531 +      /* parse indexing expression */
277.4532 +      if (mpl->token != T_LBRACE)
277.4533 +         error(mpl, "indexing expression missing where expected");
277.4534 +      fur->domain = indexing_expression(mpl);
277.4535 +      /* skip optional colon */
277.4536 +      if (mpl->token == T_COLON) get_token(mpl /* : */);
277.4537 +      /* parse for statement body */
277.4538 +      if (mpl->token != T_LBRACE)
277.4539 +      {  /* parse simple statement */
277.4540 +         fur->list = simple_statement(mpl, 1);
277.4541 +      }
277.4542 +      else
277.4543 +      {  /* parse compound statement */
277.4544 +         get_token(mpl /* { */);
277.4545 +         while (mpl->token != T_RBRACE)
277.4546 +         {  /* parse statement */
277.4547 +            stmt = simple_statement(mpl, 1);
277.4548 +            /* and append it to the end of the statement list */
277.4549 +            if (last_stmt == NULL)
277.4550 +               fur->list = stmt;
277.4551 +            else
277.4552 +               last_stmt->next = stmt;
277.4553 +            last_stmt = stmt;
277.4554 +         }
277.4555 +         get_token(mpl /* } */);
277.4556 +      }
277.4557 +      /* close the domain scope */
277.4558 +      xassert(fur->domain != NULL);
277.4559 +      close_scope(mpl, fur->domain);
277.4560 +      /* the for statement has been completely parsed */
277.4561 +      return fur;
277.4562 +}
277.4563 +
277.4564 +/*----------------------------------------------------------------------
277.4565 +-- end_statement - parse end statement.
277.4566 +--
277.4567 +-- This routine parses end statement using the syntax:
277.4568 +--
277.4569 +-- <end statement> ::= end ; <eof> */
277.4570 +
277.4571 +void end_statement(MPL *mpl)
277.4572 +{     if (!mpl->flag_d && is_keyword(mpl, "end") ||
277.4573 +           mpl->flag_d && is_literal(mpl, "end"))
277.4574 +      {  get_token(mpl /* end */);
277.4575 +         if (mpl->token == T_SEMICOLON)
277.4576 +            get_token(mpl /* ; */);
277.4577 +         else
277.4578 +            warning(mpl, "no semicolon following end statement; missing"
277.4579 +               " semicolon inserted");
277.4580 +      }
277.4581 +      else
277.4582 +         warning(mpl, "unexpected end of file; missing end statement in"
277.4583 +            "serted");
277.4584 +      if (mpl->token != T_EOF)
277.4585 +         warning(mpl, "some text detected beyond end statement; text ig"
277.4586 +            "nored");
277.4587 +      return;
277.4588 +}
277.4589 +
277.4590 +/*----------------------------------------------------------------------
277.4591 +-- simple_statement - parse simple statement.
277.4592 +--
277.4593 +-- This routine parses simple statement using the syntax:
277.4594 +--
277.4595 +-- <statement> ::= <set statement>
277.4596 +-- <statement> ::= <parameter statement>
277.4597 +-- <statement> ::= <variable statement>
277.4598 +-- <statement> ::= <constraint statement>
277.4599 +-- <statement> ::= <objective statement>
277.4600 +-- <statement> ::= <solve statement>
277.4601 +-- <statement> ::= <check statement>
277.4602 +-- <statement> ::= <display statement>
277.4603 +-- <statement> ::= <printf statement>
277.4604 +-- <statement> ::= <for statement>
277.4605 +--
277.4606 +-- If the flag spec is set, some statements cannot be used. */
277.4607 +
277.4608 +STATEMENT *simple_statement(MPL *mpl, int spec)
277.4609 +{     STATEMENT *stmt;
277.4610 +      stmt = alloc(STATEMENT);
277.4611 +      stmt->line = mpl->line;
277.4612 +      stmt->next = NULL;
277.4613 +      if (is_keyword(mpl, "set"))
277.4614 +      {  if (spec)
277.4615 +            error(mpl, "set statement not allowed here");
277.4616 +         stmt->type = A_SET;
277.4617 +         stmt->u.set = set_statement(mpl);
277.4618 +      }
277.4619 +      else if (is_keyword(mpl, "param"))
277.4620 +      {  if (spec)
277.4621 +            error(mpl, "parameter statement not allowed here");
277.4622 +         stmt->type = A_PARAMETER;
277.4623 +         stmt->u.par = parameter_statement(mpl);
277.4624 +      }
277.4625 +      else if (is_keyword(mpl, "var"))
277.4626 +      {  if (spec)
277.4627 +            error(mpl, "variable statement not allowed here");
277.4628 +         stmt->type = A_VARIABLE;
277.4629 +         stmt->u.var = variable_statement(mpl);
277.4630 +      }
277.4631 +      else if (is_keyword(mpl, "subject") ||
277.4632 +               is_keyword(mpl, "subj") ||
277.4633 +               mpl->token == T_SPTP)
277.4634 +      {  if (spec)
277.4635 +            error(mpl, "constraint statement not allowed here");
277.4636 +         stmt->type = A_CONSTRAINT;
277.4637 +         stmt->u.con = constraint_statement(mpl);
277.4638 +      }
277.4639 +      else if (is_keyword(mpl, "minimize") ||
277.4640 +               is_keyword(mpl, "maximize"))
277.4641 +      {  if (spec)
277.4642 +            error(mpl, "objective statement not allowed here");
277.4643 +         stmt->type = A_CONSTRAINT;
277.4644 +         stmt->u.con = objective_statement(mpl);
277.4645 +      }
277.4646 +#if 1 /* 11/II-2008 */
277.4647 +      else if (is_keyword(mpl, "table"))
277.4648 +      {  if (spec)
277.4649 +            error(mpl, "table statement not allowed here");
277.4650 +         stmt->type = A_TABLE;
277.4651 +         stmt->u.tab = table_statement(mpl);
277.4652 +      }
277.4653 +#endif
277.4654 +      else if (is_keyword(mpl, "solve"))
277.4655 +      {  if (spec)
277.4656 +            error(mpl, "solve statement not allowed here");
277.4657 +         stmt->type = A_SOLVE;
277.4658 +         stmt->u.slv = solve_statement(mpl);
277.4659 +      }
277.4660 +      else if (is_keyword(mpl, "check"))
277.4661 +      {  stmt->type = A_CHECK;
277.4662 +         stmt->u.chk = check_statement(mpl);
277.4663 +      }
277.4664 +      else if (is_keyword(mpl, "display"))
277.4665 +      {  stmt->type = A_DISPLAY;
277.4666 +         stmt->u.dpy = display_statement(mpl);
277.4667 +      }
277.4668 +      else if (is_keyword(mpl, "printf"))
277.4669 +      {  stmt->type = A_PRINTF;
277.4670 +         stmt->u.prt = printf_statement(mpl);
277.4671 +      }
277.4672 +      else if (is_keyword(mpl, "for"))
277.4673 +      {  stmt->type = A_FOR;
277.4674 +         stmt->u.fur = for_statement(mpl);
277.4675 +      }
277.4676 +      else if (mpl->token == T_NAME)
277.4677 +      {  if (spec)
277.4678 +            error(mpl, "constraint statement not allowed here");
277.4679 +         stmt->type = A_CONSTRAINT;
277.4680 +         stmt->u.con = constraint_statement(mpl);
277.4681 +      }
277.4682 +      else if (is_reserved(mpl))
277.4683 +         error(mpl, "invalid use of reserved keyword %s", mpl->image);
277.4684 +      else
277.4685 +         error(mpl, "syntax error in model section");
277.4686 +      return stmt;
277.4687 +}
277.4688 +
277.4689 +/*----------------------------------------------------------------------
277.4690 +-- model_section - parse model section.
277.4691 +--
277.4692 +-- This routine parses model section using the syntax:
277.4693 +--
277.4694 +-- <model section> ::= <empty>
277.4695 +-- <model section> ::= <model section> <statement>
277.4696 +--
277.4697 +-- Parsing model section is terminated by either the keyword 'data', or
277.4698 +-- the keyword 'end', or the end of file. */
277.4699 +
277.4700 +void model_section(MPL *mpl)
277.4701 +{     STATEMENT *stmt, *last_stmt;
277.4702 +      xassert(mpl->model == NULL);
277.4703 +      last_stmt = NULL;
277.4704 +      while (!(mpl->token == T_EOF || is_keyword(mpl, "data") ||
277.4705 +               is_keyword(mpl, "end")))
277.4706 +      {  /* parse statement */
277.4707 +         stmt = simple_statement(mpl, 0);
277.4708 +         /* and append it to the end of the statement list */
277.4709 +         if (last_stmt == NULL)
277.4710 +            mpl->model = stmt;
277.4711 +         else
277.4712 +            last_stmt->next = stmt;
277.4713 +         last_stmt = stmt;
277.4714 +      }
277.4715 +      return;
277.4716 +}
277.4717 +
277.4718 +/* eof */
   278.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
   278.2 +++ b/deps/glpk/src/glpmpl02.c	Sun Nov 06 20:59:10 2011 +0100
   278.3 @@ -0,0 +1,1205 @@
   278.4 +/* glpmpl02.c */
   278.5 +
   278.6 +/***********************************************************************
   278.7 +*  This code is part of GLPK (GNU Linear Programming Kit).
   278.8 +*
   278.9 +*  Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008,
  278.10 +*  2009, 2010, 2011 Andrew Makhorin, Department for Applied Informatics,
  278.11 +*  Moscow Aviation Institute, Moscow, Russia. All rights reserved.
  278.12 +*  E-mail: <mao@gnu.org>.
  278.13 +*
  278.14 +*  GLPK is free software: you can redistribute it and/or modify it
  278.15 +*  under the terms of the GNU General Public License as published by
  278.16 +*  the Free Software Foundation, either version 3 of the License, or
  278.17 +*  (at your option) any later version.
  278.18 +*
  278.19 +*  GLPK is distributed in the hope that it will be useful, but WITHOUT
  278.20 +*  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
  278.21 +*  or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
  278.22 +*  License for more details.
  278.23 +*
  278.24 +*  You should have received a copy of the GNU General Public License
  278.25 +*  along with GLPK. If not, see <http://www.gnu.org/licenses/>.
  278.26 +***********************************************************************/
  278.27 +
  278.28 +#define _GLPSTD_STDIO
  278.29 +#include "glpenv.h"
  278.30 +#include "glpmpl.h"
  278.31 +
  278.32 +/**********************************************************************/
  278.33 +/* * *                  PROCESSING DATA SECTION                   * * */
  278.34 +/**********************************************************************/
  278.35 +
  278.36 +/*----------------------------------------------------------------------
  278.37 +-- create_slice - create slice.
  278.38 +--
  278.39 +-- This routine creates a slice, which initially has no components. */
  278.40 +
  278.41 +SLICE *create_slice(MPL *mpl)
  278.42 +{     SLICE *slice;
  278.43 +      xassert(mpl == mpl);
  278.44 +      slice = NULL;
  278.45 +      return slice;
  278.46 +}
  278.47 +
  278.48 +/*----------------------------------------------------------------------
  278.49 +-- expand_slice - append new component to slice.
  278.50 +--
  278.51 +-- This routine expands slice appending to it either a given symbol or
  278.52 +-- null component, which becomes the last component of the slice. */
  278.53 +
  278.54 +SLICE *expand_slice
  278.55 +(     MPL *mpl,
  278.56 +      SLICE *slice,           /* destroyed */
  278.57 +      SYMBOL *sym             /* destroyed */
  278.58 +)
  278.59 +{     SLICE *tail, *temp;
  278.60 +      /* create a new component */
  278.61 +      tail = dmp_get_atom(mpl->tuples, sizeof(SLICE));
  278.62 +      tail->sym = sym;
  278.63 +      tail->next = NULL;
  278.64 +      /* and append it to the component list */
  278.65 +      if (slice == NULL)
  278.66 +         slice = tail;
  278.67 +      else
  278.68 +      {  for (temp = slice; temp->next != NULL; temp = temp->next);
  278.69 +         temp->next = tail;
  278.70 +      }
  278.71 +      return slice;
  278.72 +}
  278.73 +
  278.74 +/*----------------------------------------------------------------------
  278.75 +-- slice_dimen - determine dimension of slice.
  278.76 +--
  278.77 +-- This routine returns dimension of slice, which is number of all its
  278.78 +-- components including null ones. */
  278.79 +
  278.80 +int slice_dimen
  278.81 +(     MPL *mpl,
  278.82 +      SLICE *slice            /* not changed */
  278.83 +)
  278.84 +{     SLICE *temp;
  278.85 +      int dim;
  278.86 +      xassert(mpl == mpl);
  278.87 +      dim = 0;
  278.88 +      for (temp = slice; temp != NULL; temp = temp->next) dim++;
  278.89 +      return dim;
  278.90 +}
  278.91 +
  278.92 +/*----------------------------------------------------------------------
  278.93 +-- slice_arity - determine arity of slice.
  278.94 +--
  278.95 +-- This routine returns arity of slice, i.e. number of null components
  278.96 +-- (indicated by asterisks) in the slice. */
  278.97 +
  278.98 +int slice_arity
  278.99 +(     MPL *mpl,
 278.100 +      SLICE *slice            /* not changed */
 278.101 +)
 278.102 +{     SLICE *temp;
 278.103 +      int arity;
 278.104 +      xassert(mpl == mpl);
 278.105 +      arity = 0;
 278.106 +      for (temp = slice; temp != NULL; temp = temp->next)
 278.107 +         if (temp->sym == NULL) arity++;
 278.108 +      return arity;
 278.109 +}
 278.110 +
 278.111 +/*----------------------------------------------------------------------
 278.112 +-- fake_slice - create fake slice of all asterisks.
 278.113 +--
 278.114 +-- This routine creates a fake slice of given dimension, which contains
 278.115 +-- asterisks in all components. Zero dimension is allowed. */
 278.116 +
 278.117 +SLICE *fake_slice(MPL *mpl, int dim)
 278.118 +{     SLICE *slice;
 278.119 +      slice = create_slice(mpl);
 278.120 +      while (dim-- > 0) slice = expand_slice(mpl, slice, NULL);
 278.121 +      return slice;
 278.122 +}
 278.123 +
 278.124 +/*----------------------------------------------------------------------
 278.125 +-- delete_slice - delete slice.
 278.126 +--
 278.127 +-- This routine deletes specified slice. */
 278.128 +
 278.129 +void delete_slice
 278.130 +(     MPL *mpl,
 278.131 +      SLICE *slice            /* destroyed */
 278.132 +)
 278.133 +{     SLICE *temp;
 278.134 +      while (slice != NULL)
 278.135 +      {  temp = slice;
 278.136 +         slice = temp->next;
 278.137 +         if (temp->sym != NULL) delete_symbol(mpl, temp->sym);
 278.138 +xassert(sizeof(SLICE) == sizeof(TUPLE));
 278.139 +         dmp_free_atom(mpl->tuples, temp, sizeof(TUPLE));
 278.140 +      }
 278.141 +      return;
 278.142 +}
 278.143 +
 278.144 +/*----------------------------------------------------------------------
 278.145 +-- is_number - check if current token is number.
 278.146 +--
 278.147 +-- If the current token is a number, this routine returns non-zero.
 278.148 +-- Otherwise zero is returned. */
 278.149 +
 278.150 +int is_number(MPL *mpl)
 278.151 +{     return
 278.152 +         mpl->token == T_NUMBER;
 278.153 +}
 278.154 +
 278.155 +/*----------------------------------------------------------------------
 278.156 +-- is_symbol - check if current token is symbol.
 278.157 +--
 278.158 +-- If the current token is suitable to be a symbol, the routine returns
 278.159 +-- non-zero. Otherwise zero is returned. */
 278.160 +
 278.161 +int is_symbol(MPL *mpl)
 278.162 +{     return
 278.163 +         mpl->token == T_NUMBER ||
 278.164 +         mpl->token == T_SYMBOL ||
 278.165 +         mpl->token == T_STRING;
 278.166 +}
 278.167 +
 278.168 +/*----------------------------------------------------------------------
 278.169 +-- is_literal - check if current token is given symbolic literal.
 278.170 +--
 278.171 +-- If the current token is given symbolic literal, this routine returns
 278.172 +-- non-zero. Otherwise zero is returned.
 278.173 +--
 278.174 +-- This routine is used on processing the data section in the same way
 278.175 +-- as the routine is_keyword on processing the model section. */
 278.176 +
 278.177 +int is_literal(MPL *mpl, char *literal)
 278.178 +{     return
 278.179 +         is_symbol(mpl) && strcmp(mpl->image, literal) == 0;
 278.180 +}
 278.181 +
 278.182 +/*----------------------------------------------------------------------
 278.183 +-- read_number - read number.
 278.184 +--
 278.185 +-- This routine reads the current token, which must be a number, and
 278.186 +-- returns its numeric value. */
 278.187 +
 278.188 +double read_number(MPL *mpl)
 278.189 +{     double num;
 278.190 +      xassert(is_number(mpl));
 278.191 +      num = mpl->value;
 278.192 +      get_token(mpl /* <number> */);
 278.193 +      return num;
 278.194 +}
 278.195 +
 278.196 +/*----------------------------------------------------------------------
 278.197 +-- read_symbol - read symbol.
 278.198 +--
 278.199 +-- This routine reads the current token, which must be a symbol, and
 278.200 +-- returns its symbolic value. */
 278.201 +
 278.202 +SYMBOL *read_symbol(MPL *mpl)
 278.203 +{     SYMBOL *sym;
 278.204 +      xassert(is_symbol(mpl));
 278.205 +      if (is_number(mpl))
 278.206 +         sym = create_symbol_num(mpl, mpl->value);
 278.207 +      else
 278.208 +         sym = create_symbol_str(mpl, create_string(mpl, mpl->image));
 278.209 +      get_token(mpl /* <symbol> */);
 278.210 +      return sym;
 278.211 +}
 278.212 +
 278.213 +/*----------------------------------------------------------------------
 278.214 +-- read_slice - read slice.
 278.215 +--
 278.216 +-- This routine reads slice using the syntax:
 278.217 +--
 278.218 +-- <slice> ::= [ <symbol list> ]
 278.219 +-- <slice> ::= ( <symbol list> )
 278.220 +-- <symbol list> ::= <symbol or star>
 278.221 +-- <symbol list> ::= <symbol list> , <symbol or star>
 278.222 +-- <symbol or star> ::= <symbol>
 278.223 +-- <symbol or star> ::= *
 278.224 +--
 278.225 +-- The bracketed form of slice is used for members of multi-dimensional
 278.226 +-- objects while the parenthesized form is used for elemental sets. */
 278.227 +
 278.228 +SLICE *read_slice
 278.229 +(     MPL *mpl,
 278.230 +      char *name,             /* not changed */
 278.231 +      int dim
 278.232 +)
 278.233 +{     SLICE *slice;
 278.234 +      int close;
 278.235 +      xassert(name != NULL);
 278.236 +      switch (mpl->token)
 278.237 +      {  case T_LBRACKET:
 278.238 +            close = T_RBRACKET;
 278.239 +            break;
 278.240 +         case T_LEFT:
 278.241 +            xassert(dim > 0);
 278.242 +            close = T_RIGHT;
 278.243 +            break;
 278.244 +         default:
 278.245 +            xassert(mpl != mpl);
 278.246 +      }
 278.247 +      if (dim == 0)
 278.248 +         error(mpl, "%s cannot be subscripted", name);
 278.249 +      get_token(mpl /* ( | [ */);
 278.250 +      /* read slice components */
 278.251 +      slice = create_slice(mpl);
 278.252 +      for (;;)
 278.253 +      {  /* the current token must be a symbol or asterisk */
 278.254 +         if (is_symbol(mpl))
 278.255 +            slice = expand_slice(mpl, slice, read_symbol(mpl));
 278.256 +         else if (mpl->token == T_ASTERISK)
 278.257 +         {  slice = expand_slice(mpl, slice, NULL);
 278.258 +            get_token(mpl /* * */);
 278.259 +         }
 278.260 +         else
 278.261 +            error(mpl, "number, symbol, or asterisk missing where expec"
 278.262 +               "ted");
 278.263 +         /* check a token that follows the symbol */
 278.264 +         if (mpl->token == T_COMMA)
 278.265 +            get_token(mpl /* , */);
 278.266 +         else if (mpl->token == close)
 278.267 +            break;
 278.268 +         else
 278.269 +            error(mpl, "syntax error in slice");
 278.270 +      }
 278.271 +      /* number of slice components must be the same as the appropriate
 278.272 +         dimension */
 278.273 +      if (slice_dimen(mpl, slice) != dim)
 278.274 +      {  switch (close)
 278.275 +         {  case T_RBRACKET:
 278.276 +               error(mpl, "%s must have %d subscript%s, not %d", name,
 278.277 +                  dim, dim == 1 ? "" : "s", slice_dimen(mpl, slice));
 278.278 +               break;
 278.279 +            case T_RIGHT:
 278.280 +               error(mpl, "%s has dimension %d, not %d", name, dim,
 278.281 +                  slice_dimen(mpl, slice));
 278.282 +               break;
 278.283 +            default:
 278.284 +               xassert(close != close);
 278.285 +         }
 278.286 +      }
 278.287 +      get_token(mpl /* ) | ] */);
 278.288 +      return slice;
 278.289 +}
 278.290 +
 278.291 +/*----------------------------------------------------------------------
 278.292 +-- select_set - select set to saturate it with elemental sets.
 278.293 +--
 278.294 +-- This routine selects set to saturate it with elemental sets provided
 278.295 +-- in the data section. */
 278.296 +
 278.297 +SET *select_set
 278.298 +(     MPL *mpl,
 278.299 +      char *name              /* not changed */
 278.300 +)
 278.301 +{     SET *set;
 278.302 +      AVLNODE *node;
 278.303 +      xassert(name != NULL);
 278.304 +      node = avl_find_node(mpl->tree, name);
 278.305 +      if (node == NULL || avl_get_node_type(node) != A_SET)
 278.306 +         error(mpl, "%s not a set", name);
 278.307 +      set = (SET *)avl_get_node_link(node);
 278.308 +      if (set->assign != NULL || set->gadget != NULL)
 278.309 +         error(mpl, "%s needs no data", name);
 278.310 +      set->data = 1;
 278.311 +      return set;
 278.312 +}
 278.313 +
 278.314 +/*----------------------------------------------------------------------
 278.315 +-- simple_format - read set data block in simple format.
 278.316 +--
 278.317 +-- This routine reads set data block using the syntax:
 278.318 +--
 278.319 +-- <simple format> ::= <symbol> , <symbol> , ... , <symbol>
 278.320 +--
 278.321 +-- where <symbols> are used to construct a complete n-tuple, which is
 278.322 +-- included in elemental set assigned to the set member. Commae between
 278.323 +-- symbols are optional and may be omitted anywhere.
 278.324 +--
 278.325 +-- Number of components in the slice must be the same as dimension of
 278.326 +-- n-tuples in elemental sets assigned to the set members. To construct
 278.327 +-- complete n-tuple the routine replaces null positions in the slice by
 278.328 +-- corresponding <symbols>.
 278.329 +--
 278.330 +-- If the slice contains at least one null position, the current token
 278.331 +-- must be symbol. Otherwise, the routine reads no symbols to construct
 278.332 +-- the n-tuple, so the current token is not checked. */
 278.333 +
 278.334 +void simple_format
 278.335 +(     MPL *mpl,
 278.336 +      SET *set,               /* not changed */
 278.337 +      MEMBER *memb,           /* modified */
 278.338 +      SLICE *slice            /* not changed */
 278.339 +)
 278.340 +{     TUPLE *tuple;
 278.341 +      SLICE *temp;
 278.342 +      SYMBOL *sym, *with = NULL;
 278.343 +      xassert(set != NULL);
 278.344 +      xassert(memb != NULL);
 278.345 +      xassert(slice != NULL);
 278.346 +      xassert(set->dimen == slice_dimen(mpl, slice));
 278.347 +      xassert(memb->value.set->dim == set->dimen);
 278.348 +      if (slice_arity(mpl, slice) > 0) xassert(is_symbol(mpl));
 278.349 +      /* read symbols and construct complete n-tuple */
 278.350 +      tuple = create_tuple(mpl);
 278.351 +      for (temp = slice; temp != NULL; temp = temp->next)
 278.352 +      {  if (temp->sym == NULL)
 278.353 +         {  /* substitution is needed; read symbol */
 278.354 +            if (!is_symbol(mpl))
 278.355 +            {  int lack = slice_arity(mpl, temp);
 278.356 +               /* with cannot be null due to assertion above */
 278.357 +               xassert(with != NULL);
 278.358 +               if (lack == 1)
 278.359 +                  error(mpl, "one item missing in data group beginning "
 278.360 +                     "with %s", format_symbol(mpl, with));
 278.361 +               else
 278.362 +                  error(mpl, "%d items missing in data group beginning "
 278.363 +                     "with %s", lack, format_symbol(mpl, with));
 278.364 +            }
 278.365 +            sym = read_symbol(mpl);
 278.366 +            if (with == NULL) with = sym;
 278.367 +         }
 278.368 +         else
 278.369 +         {  /* copy symbol from the slice */
 278.370 +            sym = copy_symbol(mpl, temp->sym);
 278.371 +         }
 278.372 +         /* append the symbol to the n-tuple */
 278.373 +         tuple = expand_tuple(mpl, tuple, sym);
 278.374 +         /* skip optional comma *between* <symbols> */
 278.375 +         if (temp->next != NULL && mpl->token == T_COMMA)
 278.376 +            get_token(mpl /* , */);
 278.377 +      }
 278.378 +      /* add constructed n-tuple to elemental set */
 278.379 +      check_then_add(mpl, memb->value.set, tuple);
 278.380 +      return;
 278.381 +}
 278.382 +
 278.383 +/*----------------------------------------------------------------------
 278.384 +-- matrix_format - read set data block in matrix format.
 278.385 +--
 278.386 +-- This routine reads set data block using the syntax:
 278.387 +--
 278.388 +-- <matrix format> ::= <column> <column> ... <column> :=
 278.389 +--               <row>   +/-      +/-    ...   +/-
 278.390 +--               <row>   +/-      +/-    ...   +/-
 278.391 +--                 .  .  .  .  .  .  .  .  .  .  .
 278.392 +--               <row>   +/-      +/-    ...   +/-
 278.393 +--
 278.394 +-- where <rows> are symbols that denote rows of the matrix, <columns>
 278.395 +-- are symbols that denote columns of the matrix, "+" and "-" indicate
 278.396 +-- whether corresponding n-tuple needs to be included in the elemental
 278.397 +-- set or not, respectively.
 278.398 +--
 278.399 +-- Number of the slice components must be the same as dimension of the
 278.400 +-- elemental set. The slice must have two null positions. To construct
 278.401 +-- complete n-tuple for particular element of the matrix the routine
 278.402 +-- replaces first null position of the slice by the corresponding <row>
 278.403 +-- (or <column>, if the flag tr is on) and second null position by the
 278.404 +-- corresponding <column> (or by <row>, if the flag tr is on). */
 278.405 +
 278.406 +void matrix_format
 278.407 +(     MPL *mpl,
 278.408 +      SET *set,               /* not changed */
 278.409 +      MEMBER *memb,           /* modified */
 278.410 +      SLICE *slice,           /* not changed */
 278.411 +      int tr
 278.412 +)
 278.413 +{     SLICE *list, *col, *temp;
 278.414 +      TUPLE *tuple;
 278.415 +      SYMBOL *row;
 278.416 +      xassert(set != NULL);
 278.417 +      xassert(memb != NULL);
 278.418 +      xassert(slice != NULL);
 278.419 +      xassert(set->dimen == slice_dimen(mpl, slice));
 278.420 +      xassert(memb->value.set->dim == set->dimen);
 278.421 +      xassert(slice_arity(mpl, slice) == 2);
 278.422 +      /* read the matrix heading that contains column symbols (there
 278.423 +         may be no columns at all) */
 278.424 +      list = create_slice(mpl);
 278.425 +      while (mpl->token != T_ASSIGN)
 278.426 +      {  /* read column symbol and append it to the column list */
 278.427 +         if (!is_symbol(mpl))
 278.428 +            error(mpl, "number, symbol, or := missing where expected");
 278.429 +         list = expand_slice(mpl, list, read_symbol(mpl));
 278.430 +      }
 278.431 +      get_token(mpl /* := */);
 278.432 +      /* read zero or more rows that contain matrix data */
 278.433 +      while (is_symbol(mpl))
 278.434 +      {  /* read row symbol (if the matrix has no columns, row symbols
 278.435 +            are just ignored) */
 278.436 +         row = read_symbol(mpl);
 278.437 +         /* read the matrix row accordingly to the column list */
 278.438 +         for (col = list; col != NULL; col = col->next)
 278.439 +         {  int which = 0;
 278.440 +            /* check indicator */
 278.441 +            if (is_literal(mpl, "+"))
 278.442 +               ;
 278.443 +            else if (is_literal(mpl, "-"))
 278.444 +            {  get_token(mpl /* - */);
 278.445 +               continue;
 278.446 +            }
 278.447 +            else
 278.448 +            {  int lack = slice_dimen(mpl, col);
 278.449 +               if (lack == 1)
 278.450 +                  error(mpl, "one item missing in data group beginning "
 278.451 +                     "with %s", format_symbol(mpl, row));
 278.452 +               else
 278.453 +                  error(mpl, "%d items missing in data group beginning "
 278.454 +                     "with %s", lack, format_symbol(mpl, row));
 278.455 +            }
 278.456 +            /* construct complete n-tuple */
 278.457 +            tuple = create_tuple(mpl);
 278.458 +            for (temp = slice; temp != NULL; temp = temp->next)
 278.459 +            {  if (temp->sym == NULL)
 278.460 +               {  /* substitution is needed */
 278.461 +                  switch (++which)
 278.462 +                  {  case 1:
 278.463 +                        /* substitute in the first null position */
 278.464 +                        tuple = expand_tuple(mpl, tuple,
 278.465 +                           copy_symbol(mpl, tr ? col->sym : row));
 278.466 +                        break;
 278.467 +                     case 2:
 278.468 +                        /* substitute in the second null position */
 278.469 +                        tuple = expand_tuple(mpl, tuple,
 278.470 +                           copy_symbol(mpl, tr ? row : col->sym));
 278.471 +                        break;
 278.472 +                     default:
 278.473 +                        xassert(which != which);
 278.474 +                  }
 278.475 +               }
 278.476 +               else
 278.477 +               {  /* copy symbol from the slice */
 278.478 +                  tuple = expand_tuple(mpl, tuple, copy_symbol(mpl,
 278.479 +                     temp->sym));
 278.480 +               }
 278.481 +            }
 278.482 +            xassert(which == 2);
 278.483 +            /* add constructed n-tuple to elemental set */
 278.484 +            check_then_add(mpl, memb->value.set, tuple);
 278.485 +            get_token(mpl /* + */);
 278.486 +         }
 278.487 +         /* delete the row symbol */
 278.488 +         delete_symbol(mpl, row);
 278.489 +      }
 278.490 +      /* delete the column list */
 278.491 +      delete_slice(mpl, list);
 278.492 +      return;
 278.493 +}
 278.494 +
 278.495 +/*----------------------------------------------------------------------
 278.496 +-- set_data - read set data.
 278.497 +--
 278.498 +-- This routine reads set data using the syntax:
 278.499 +--
 278.500 +-- <set data> ::= set <set name> <assignments> ;
 278.501 +-- <set data> ::= set <set name> [ <symbol list> ] <assignments> ;
 278.502 +-- <set name> ::= <symbolic name>
 278.503 +-- <assignments> ::= <empty>
 278.504 +-- <assignments> ::= <assignments> , :=
 278.505 +-- <assignments> ::= <assignments> , ( <symbol list> )
 278.506 +-- <assignments> ::= <assignments> , <simple format>
 278.507 +-- <assignments> ::= <assignments> , : <matrix format>
 278.508 +-- <assignments> ::= <assignments> , (tr) <matrix format>
 278.509 +-- <assignments> ::= <assignments> , (tr) : <matrix format>
 278.510 +--
 278.511 +-- Commae in <assignments> are optional and may be omitted anywhere. */
 278.512 +
 278.513 +void set_data(MPL *mpl)
 278.514 +{     SET *set;
 278.515 +      TUPLE *tuple;
 278.516 +      MEMBER *memb;
 278.517 +      SLICE *slice;
 278.518 +      int tr = 0;
 278.519 +      xassert(is_literal(mpl, "set"));
 278.520 +      get_token(mpl /* set */);
 278.521 +      /* symbolic name of set must follows the keyword 'set' */
 278.522 +      if (!is_symbol(mpl))
 278.523 +         error(mpl, "set name missing where expected");
 278.524 +      /* select the set to saturate it with data */
 278.525 +      set = select_set(mpl, mpl->image);
 278.526 +      get_token(mpl /* <symbolic name> */);
 278.527 +      /* read optional subscript list, which identifies member of the
 278.528 +         set to be read */
 278.529 +      tuple = create_tuple(mpl);
 278.530 +      if (mpl->token == T_LBRACKET)
 278.531 +      {  /* subscript list is specified */
 278.532 +         if (set->dim == 0)
 278.533 +            error(mpl, "%s cannot be subscripted", set->name);
 278.534 +         get_token(mpl /* [ */);
 278.535 +         /* read symbols and construct subscript list */
 278.536 +         for (;;)
 278.537 +         {  if (!is_symbol(mpl))
 278.538 +               error(mpl, "number or symbol missing where expected");
 278.539 +            tuple = expand_tuple(mpl, tuple, read_symbol(mpl));
 278.540 +            if (mpl->token == T_COMMA)
 278.541 +               get_token(mpl /* , */);
 278.542 +            else if (mpl->token == T_RBRACKET)
 278.543 +               break;
 278.544 +            else
 278.545 +               error(mpl, "syntax error in subscript list");
 278.546 +         }
 278.547 +         if (set->dim != tuple_dimen(mpl, tuple))
 278.548 +            error(mpl, "%s must have %d subscript%s rather than %d",
 278.549 +               set->name, set->dim, set->dim == 1 ? "" : "s",
 278.550 +               tuple_dimen(mpl, tuple));
 278.551 +         get_token(mpl /* ] */);
 278.552 +      }
 278.553 +      else
 278.554 +      {  /* subscript list is not specified */
 278.555 +         if (set->dim != 0)
 278.556 +            error(mpl, "%s must be subscripted", set->name);
 278.557 +      }
 278.558 +      /* there must be no member with the same subscript list */
 278.559 +      if (find_member(mpl, set->array, tuple) != NULL)
 278.560 +         error(mpl, "%s%s already defined",
 278.561 +            set->name, format_tuple(mpl, '[', tuple));
 278.562 +      /* add new member to the set and assign it empty elemental set */
 278.563 +      memb = add_member(mpl, set->array, tuple);
 278.564 +      memb->value.set = create_elemset(mpl, set->dimen);
 278.565 +      /* create an initial fake slice of all asterisks */
 278.566 +      slice = fake_slice(mpl, set->dimen);
 278.567 +      /* read zero or more data assignments */
 278.568 +      for (;;)
 278.569 +      {  /* skip optional comma */
 278.570 +         if (mpl->token == T_COMMA) get_token(mpl /* , */);
 278.571 +         /* process assignment element */
 278.572 +         if (mpl->token == T_ASSIGN)
 278.573 +         {  /* assignment ligature is non-significant element */
 278.574 +            get_token(mpl /* := */);
 278.575 +         }
 278.576 +         else if (mpl->token == T_LEFT)
 278.577 +         {  /* left parenthesis begins either new slice or "transpose"
 278.578 +               indicator */
 278.579 +            int is_tr;
 278.580 +            get_token(mpl /* ( */);
 278.581 +            is_tr = is_literal(mpl, "tr");
 278.582 +            unget_token(mpl /* ( */);
 278.583 +            if (is_tr) goto left;
 278.584 +            /* delete the current slice and read new one */
 278.585 +            delete_slice(mpl, slice);
 278.586 +            slice = read_slice(mpl, set->name, set->dimen);
 278.587 +            /* each new slice resets the "transpose" indicator */
 278.588 +            tr = 0;
 278.589 +            /* if the new slice is 0-ary, formally there is one 0-tuple
 278.590 +               (in the simple format) that follows it */
 278.591 +            if (slice_arity(mpl, slice) == 0)
 278.592 +               simple_format(mpl, set, memb, slice);
 278.593 +         }
 278.594 +         else if (is_symbol(mpl))
 278.595 +         {  /* number or symbol begins data in the simple format */
 278.596 +            simple_format(mpl, set, memb, slice);
 278.597 +         }
 278.598 +         else if (mpl->token == T_COLON)
 278.599 +         {  /* colon begins data in the matrix format */
 278.600 +            if (slice_arity(mpl, slice) != 2)
 278.601 +err1:          error(mpl, "slice currently used must specify 2 asterisk"
 278.602 +                  "s, not %d", slice_arity(mpl, slice));
 278.603 +            get_token(mpl /* : */);
 278.604 +            /* read elemental set data in the matrix format */
 278.605 +            matrix_format(mpl, set, memb, slice, tr);
 278.606 +         }
 278.607 +         else if (mpl->token == T_LEFT)
 278.608 +left:    {  /* left parenthesis begins the "transpose" indicator, which
 278.609 +               is followed by data in the matrix format */
 278.610 +            get_token(mpl /* ( */);
 278.611 +            if (!is_literal(mpl, "tr"))
 278.612 +err2:          error(mpl, "transpose indicator (tr) incomplete");
 278.613 +            if (slice_arity(mpl, slice) != 2) goto err1;
 278.614 +            get_token(mpl /* tr */);
 278.615 +            if (mpl->token != T_RIGHT) goto err2;
 278.616 +            get_token(mpl /* ) */);
 278.617 +            /* in this case the colon is optional */
 278.618 +            if (mpl->token == T_COLON) get_token(mpl /* : */);
 278.619 +            /* set the "transpose" indicator */
 278.620 +            tr = 1;
 278.621 +            /* read elemental set data in the matrix format */
 278.622 +            matrix_format(mpl, set, memb, slice, tr);
 278.623 +         }
 278.624 +         else if (mpl->token == T_SEMICOLON)
 278.625 +         {  /* semicolon terminates the data block */
 278.626 +            get_token(mpl /* ; */);
 278.627 +            break;
 278.628 +         }
 278.629 +         else
 278.630 +            error(mpl, "syntax error in set data block");
 278.631 +      }
 278.632 +      /* delete the current slice */
 278.633 +      delete_slice(mpl, slice);
 278.634 +      return;
 278.635 +}
 278.636 +
 278.637 +/*----------------------------------------------------------------------
 278.638 +-- select_parameter - select parameter to saturate it with data.
 278.639 +--
 278.640 +-- This routine selects parameter to saturate it with data provided in
 278.641 +-- the data section. */
 278.642 +
 278.643 +PARAMETER *select_parameter
 278.644 +(     MPL *mpl,
 278.645 +      char *name              /* not changed */
 278.646 +)
 278.647 +{     PARAMETER *par;
 278.648 +      AVLNODE *node;
 278.649 +      xassert(name != NULL);
 278.650 +      node = avl_find_node(mpl->tree, name);
 278.651 +      if (node == NULL || avl_get_node_type(node) != A_PARAMETER)
 278.652 +         error(mpl, "%s not a parameter", name);
 278.653 +      par = (PARAMETER *)avl_get_node_link(node);
 278.654 +      if (par->assign != NULL)
 278.655 +         error(mpl, "%s needs no data", name);
 278.656 +      if (par->data)
 278.657 +         error(mpl, "%s already provided with data", name);
 278.658 +      par->data = 1;
 278.659 +      return par;
 278.660 +}
 278.661 +
 278.662 +/*----------------------------------------------------------------------
 278.663 +-- set_default - set default parameter value.
 278.664 +--
 278.665 +-- This routine sets default value for specified parameter. */
 278.666 +
 278.667 +void set_default
 278.668 +(     MPL *mpl,
 278.669 +      PARAMETER *par,         /* not changed */
 278.670 +      SYMBOL *altval          /* destroyed */
 278.671 +)
 278.672 +{     xassert(par != NULL);
 278.673 +      xassert(altval != NULL);
 278.674 +      if (par->option != NULL)
 278.675 +         error(mpl, "default value for %s already specified in model se"
 278.676 +            "ction", par->name);
 278.677 +      xassert(par->defval == NULL);
 278.678 +      par->defval = altval;
 278.679 +      return;
 278.680 +}
 278.681 +
 278.682 +/*----------------------------------------------------------------------
 278.683 +-- read_value - read value and assign it to parameter member.
 278.684 +--
 278.685 +-- This routine reads numeric or symbolic value from the input stream
 278.686 +-- and assigns to new parameter member specified by its n-tuple, which
 278.687 +-- (the member) is created and added to the parameter array. */
 278.688 +
 278.689 +MEMBER *read_value
 278.690 +(     MPL *mpl,
 278.691 +      PARAMETER *par,         /* not changed */
 278.692 +      TUPLE *tuple            /* destroyed */
 278.693 +)
 278.694 +{     MEMBER *memb;
 278.695 +      xassert(par != NULL);
 278.696 +      xassert(is_symbol(mpl));
 278.697 +      /* there must be no member with the same n-tuple */
 278.698 +      if (find_member(mpl, par->array, tuple) != NULL)
 278.699 +         error(mpl, "%s%s already defined",
 278.700 +            par->name, format_tuple(mpl, '[', tuple));
 278.701 +      /* create new parameter member with given n-tuple */
 278.702 +      memb = add_member(mpl, par->array, tuple);
 278.703 +      /* read value and assigns it to the new parameter member */
 278.704 +      switch (par->type)
 278.705 +      {  case A_NUMERIC:
 278.706 +         case A_INTEGER:
 278.707 +         case A_BINARY:
 278.708 +            if (!is_number(mpl))
 278.709 +               error(mpl, "%s requires numeric data", par->name);
 278.710 +            memb->value.num = read_number(mpl);
 278.711 +            break;
 278.712 +         case A_SYMBOLIC:
 278.713 +            memb->value.sym = read_symbol(mpl);
 278.714 +            break;
 278.715 +         default:
 278.716 +            xassert(par != par);
 278.717 +      }
 278.718 +      return memb;
 278.719 +}
 278.720 +
 278.721 +/*----------------------------------------------------------------------
 278.722 +-- plain_format - read parameter data block in plain format.
 278.723 +--
 278.724 +-- This routine reads parameter data block using the syntax:
 278.725 +--
 278.726 +-- <plain format> ::= <symbol> , <symbol> , ... , <symbol> , <value>
 278.727 +--
 278.728 +-- where <symbols> are used to determine a complete subscript list for
 278.729 +-- parameter member, <value> is a numeric or symbolic value assigned to
 278.730 +-- the parameter member. Commae between data items are optional and may
 278.731 +-- be omitted anywhere.
 278.732 +--
 278.733 +-- Number of components in the slice must be the same as dimension of
 278.734 +-- the parameter. To construct the complete subscript list the routine
 278.735 +-- replaces null positions in the slice by corresponding <symbols>. */
 278.736 +
 278.737 +void plain_format
 278.738 +(     MPL *mpl,
 278.739 +      PARAMETER *par,         /* not changed */
 278.740 +      SLICE *slice            /* not changed */
 278.741 +)
 278.742 +{     TUPLE *tuple;
 278.743 +      SLICE *temp;
 278.744 +      SYMBOL *sym, *with = NULL;
 278.745 +      xassert(par != NULL);
 278.746 +      xassert(par->dim == slice_dimen(mpl, slice));
 278.747 +      xassert(is_symbol(mpl));
 278.748 +      /* read symbols and construct complete subscript list */
 278.749 +      tuple = create_tuple(mpl);
 278.750 +      for (temp = slice; temp != NULL; temp = temp->next)
 278.751 +      {  if (temp->sym == NULL)
 278.752 +         {  /* substitution is needed; read symbol */
 278.753 +            if (!is_symbol(mpl))
 278.754 +            {  int lack = slice_arity(mpl, temp) + 1;
 278.755 +               xassert(with != NULL);
 278.756 +               xassert(lack > 1);
 278.757 +               error(mpl, "%d items missing in data group beginning wit"
 278.758 +                  "h %s", lack, format_symbol(mpl, with));
 278.759 +            }
 278.760 +            sym = read_symbol(mpl);
 278.761 +            if (with == NULL) with = sym;
 278.762 +         }
 278.763 +         else
 278.764 +         {  /* copy symbol from the slice */
 278.765 +            sym = copy_symbol(mpl, temp->sym);
 278.766 +         }
 278.767 +         /* append the symbol to the subscript list */
 278.768 +         tuple = expand_tuple(mpl, tuple, sym);
 278.769 +         /* skip optional comma */
 278.770 +         if (mpl->token == T_COMMA) get_token(mpl /* , */);
 278.771 +      }
 278.772 +      /* read value and assign it to new parameter member */
 278.773 +      if (!is_symbol(mpl))
 278.774 +      {  xassert(with != NULL);
 278.775 +         error(mpl, "one item missing in data group beginning with %s",
 278.776 +            format_symbol(mpl, with));
 278.777 +      }
 278.778 +      read_value(mpl, par, tuple);
 278.779 +      return;
 278.780 +}
 278.781 +
 278.782 +/*----------------------------------------------------------------------
 278.783 +-- tabular_format - read parameter data block in tabular format.
 278.784 +--
 278.785 +-- This routine reads parameter data block using the syntax:
 278.786 +--
 278.787 +-- <tabular format> ::= <column> <column> ... <column> :=
 278.788 +--                <row> <value>  <value>  ... <value>
 278.789 +--                <row> <value>  <value>  ... <value>
 278.790 +--                  .  .  .  .  .  .  .  .  .  .  .
 278.791 +--                <row> <value>  <value>  ... <value>
 278.792 +--
 278.793 +-- where <rows> are symbols that denote rows of the table, <columns>
 278.794 +-- are symbols that denote columns of the table, <values> are numeric
 278.795 +-- or symbolic values assigned to the corresponding parameter members.
 278.796 +-- If <value> is specified as single point, no value is provided.
 278.797 +--
 278.798 +-- Number of components in the slice must be the same as dimension of
 278.799 +-- the parameter. The slice must have two null positions. To construct
 278.800 +-- complete subscript list for particular <value> the routine replaces
 278.801 +-- the first null position of the slice by the corresponding <row> (or
 278.802 +-- <column>, if the flag tr is on) and the second null position by the
 278.803 +-- corresponding <column> (or by <row>, if the flag tr is on). */
 278.804 +
 278.805 +void tabular_format
 278.806 +(     MPL *mpl,
 278.807 +      PARAMETER *par,         /* not changed */
 278.808 +      SLICE *slice,           /* not changed */
 278.809 +      int tr
 278.810 +)
 278.811 +{     SLICE *list, *col, *temp;
 278.812 +      TUPLE *tuple;
 278.813 +      SYMBOL *row;
 278.814 +      xassert(par != NULL);
 278.815 +      xassert(par->dim == slice_dimen(mpl, slice));
 278.816 +      xassert(slice_arity(mpl, slice) == 2);
 278.817 +      /* read the table heading that contains column symbols (the table
 278.818 +         may have no columns) */
 278.819 +      list = create_slice(mpl);
 278.820 +      while (mpl->token != T_ASSIGN)
 278.821 +      {  /* read column symbol and append it to the column list */
 278.822 +         if (!is_symbol(mpl))
 278.823 +            error(mpl, "number, symbol, or := missing where expected");
 278.824 +         list = expand_slice(mpl, list, read_symbol(mpl));
 278.825 +      }
 278.826 +      get_token(mpl /* := */);
 278.827 +      /* read zero or more rows that contain tabular data */
 278.828 +      while (is_symbol(mpl))
 278.829 +      {  /* read row symbol (if the table has no columns, these symbols
 278.830 +            are just ignored) */
 278.831 +         row = read_symbol(mpl);
 278.832 +         /* read values accordingly to the column list */
 278.833 +         for (col = list; col != NULL; col = col->next)
 278.834 +         {  int which = 0;
 278.835 +            /* if the token is single point, no value is provided */
 278.836 +            if (is_literal(mpl, "."))
 278.837 +            {  get_token(mpl /* . */);
 278.838 +               continue;
 278.839 +            }
 278.840 +            /* construct complete subscript list */
 278.841 +            tuple = create_tuple(mpl);
 278.842 +            for (temp = slice; temp != NULL; temp = temp->next)
 278.843 +            {  if (temp->sym == NULL)
 278.844 +               {  /* substitution is needed */
 278.845 +                  switch (++which)
 278.846 +                  {  case 1:
 278.847 +                        /* substitute in the first null position */
 278.848 +                        tuple = expand_tuple(mpl, tuple,
 278.849 +                           copy_symbol(mpl, tr ? col->sym : row));
 278.850 +                        break;
 278.851 +                     case 2:
 278.852 +                        /* substitute in the second null position */
 278.853 +                        tuple = expand_tuple(mpl, tuple,
 278.854 +                           copy_symbol(mpl, tr ? row : col->sym));
 278.855 +                        break;
 278.856 +                     default:
 278.857 +                        xassert(which != which);
 278.858 +                  }
 278.859 +               }
 278.860 +               else
 278.861 +               {  /* copy symbol from the slice */
 278.862 +                  tuple = expand_tuple(mpl, tuple, copy_symbol(mpl,
 278.863 +                     temp->sym));
 278.864 +               }
 278.865 +            }
 278.866 +            xassert(which == 2);
 278.867 +            /* read value and assign it to new parameter member */
 278.868 +            if (!is_symbol(mpl))
 278.869 +            {  int lack = slice_dimen(mpl, col);
 278.870 +               if (lack == 1)
 278.871 +                  error(mpl, "one item missing in data group beginning "
 278.872 +                     "with %s", format_symbol(mpl, row));
 278.873 +               else
 278.874 +                  error(mpl, "%d items missing in data group beginning "
 278.875 +                     "with %s", lack, format_symbol(mpl, row));
 278.876 +            }
 278.877 +            read_value(mpl, par, tuple);
 278.878 +         }
 278.879 +         /* delete the row symbol */
 278.880 +         delete_symbol(mpl, row);
 278.881 +      }
 278.882 +      /* delete the column list */
 278.883 +      delete_slice(mpl, list);
 278.884 +      return;
 278.885 +}
 278.886 +
 278.887 +/*----------------------------------------------------------------------
 278.888 +-- tabbing_format - read parameter data block in tabbing format.
 278.889 +--
 278.890 +-- This routine reads parameter data block using the syntax:
 278.891 +--
 278.892 +-- <tabbing format> ::=  <prefix> <name>  , ... , <name>  , := ,
 278.893 +--    <symbol> , ... , <symbol> , <value> , ... , <value> ,
 278.894 +--    <symbol> , ... , <symbol> , <value> , ... , <value> ,
 278.895 +--     .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .
 278.896 +--    <symbol> , ... , <symbol> , <value> , ... , <value>
 278.897 +-- <prefix> ::= <empty>
 278.898 +-- <prefix> ::= <set name> :
 278.899 +--
 278.900 +-- where <names> are names of parameters (all the parameters must be
 278.901 +-- subscripted and have identical dimensions), <symbols> are symbols
 278.902 +-- used to define subscripts of parameter members, <values> are numeric
 278.903 +-- or symbolic values assigned to the corresponding parameter members.
 278.904 +-- Optional <prefix> may specify a simple set, in which case n-tuples
 278.905 +-- built of <symbols> for each row of the data table (i.e. subscripts
 278.906 +-- of parameter members) are added to the specified set. Commae between
 278.907 +-- data items are optional and may be omitted anywhere.
 278.908 +--
 278.909 +-- If the parameter altval is not NULL, it specifies a default value
 278.910 +-- provided for all the parameters specified in the data block.  */
 278.911 +
 278.912 +void tabbing_format
 278.913 +(     MPL *mpl,
 278.914 +      SYMBOL *altval          /* not changed */
 278.915 +)
 278.916 +{     SET *set = NULL;
 278.917 +      PARAMETER *par;
 278.918 +      SLICE *list, *col;
 278.919 +      TUPLE *tuple;
 278.920 +      int next_token, j, dim = 0;
 278.921 +      char *last_name = NULL;
 278.922 +      /* read the optional <prefix> */
 278.923 +      if (is_symbol(mpl))
 278.924 +      {  get_token(mpl /* <symbol> */);
 278.925 +         next_token = mpl->token;
 278.926 +         unget_token(mpl /* <symbol> */);
 278.927 +         if (next_token == T_COLON)
 278.928 +         {  /* select the set to saturate it with data */
 278.929 +            set = select_set(mpl, mpl->image);
 278.930 +            /* the set must be simple (i.e. not set of sets) */
 278.931 +            if (set->dim != 0)
 278.932 +               error(mpl, "%s must be a simple set", set->name);
 278.933 +            /* and must not be defined yet */
 278.934 +            if (set->array->head != NULL)
 278.935 +               error(mpl, "%s already defined", set->name);
 278.936 +            /* add new (the only) member to the set and assign it empty
 278.937 +               elemental set */
 278.938 +            add_member(mpl, set->array, NULL)->value.set =
 278.939 +               create_elemset(mpl, set->dimen);
 278.940 +            last_name = set->name, dim = set->dimen;
 278.941 +            get_token(mpl /* <symbol> */);
 278.942 +            xassert(mpl->token == T_COLON);
 278.943 +            get_token(mpl /* : */);
 278.944 +         }
 278.945 +      }
 278.946 +      /* read the table heading that contains parameter names */
 278.947 +      list = create_slice(mpl);
 278.948 +      while (mpl->token != T_ASSIGN)
 278.949 +      {  /* there must be symbolic name of parameter */
 278.950 +         if (!is_symbol(mpl))
 278.951 +            error(mpl, "parameter name or := missing where expected");
 278.952 +         /* select the parameter to saturate it with data */
 278.953 +         par = select_parameter(mpl, mpl->image);
 278.954 +         /* the parameter must be subscripted */
 278.955 +         if (par->dim == 0)
 278.956 +            error(mpl, "%s not a subscripted parameter", mpl->image);
 278.957 +         /* the set (if specified) and all the parameters in the data
 278.958 +            block must have identical dimension */
 278.959 +         if (dim != 0 && par->dim != dim)
 278.960 +         {  xassert(last_name != NULL);
 278.961 +            error(mpl, "%s has dimension %d while %s has dimension %d",
 278.962 +               last_name, dim, par->name, par->dim);
 278.963 +         }
 278.964 +         /* set default value for the parameter (if specified) */
 278.965 +         if (altval != NULL)
 278.966 +            set_default(mpl, par, copy_symbol(mpl, altval));
 278.967 +         /* append the parameter to the column list */
 278.968 +         list = expand_slice(mpl, list, (SYMBOL *)par);
 278.969 +         last_name = par->name, dim = par->dim;
 278.970 +         get_token(mpl /* <symbol> */);
 278.971 +         /* skip optional comma */
 278.972 +         if (mpl->token == T_COMMA) get_token(mpl /* , */);
 278.973 +      }
 278.974 +      if (slice_dimen(mpl, list) == 0)
 278.975 +         error(mpl, "at least one parameter name required");
 278.976 +      get_token(mpl /* := */);
 278.977 +      /* skip optional comma */
 278.978 +      if (mpl->token == T_COMMA) get_token(mpl /* , */);
 278.979 +      /* read rows that contain tabbing data */
 278.980 +      while (is_symbol(mpl))
 278.981 +      {  /* read subscript list */
 278.982 +         tuple = create_tuple(mpl);
 278.983 +         for (j = 1; j <= dim; j++)
 278.984 +         {  /* read j-th subscript */
 278.985 +            if (!is_symbol(mpl))
 278.986 +            {  int lack = slice_dimen(mpl, list) + dim - j + 1;
 278.987 +               xassert(tuple != NULL);
 278.988 +               xassert(lack > 1);
 278.989 +               error(mpl, "%d items missing in data group beginning wit"
 278.990 +                  "h %s", lack, format_symbol(mpl, tuple->sym));
 278.991 +            }
 278.992 +            /* read and append j-th subscript to the n-tuple */
 278.993 +            tuple = expand_tuple(mpl, tuple, read_symbol(mpl));
 278.994 +            /* skip optional comma *between* <symbols> */
 278.995 +            if (j < dim && mpl->token == T_COMMA)
 278.996 +               get_token(mpl /* , */);
 278.997 +         }
 278.998 +         /* if the set is specified, add to it new n-tuple, which is a
 278.999 +            copy of the subscript list just read */
278.1000 +         if (set != NULL)
278.1001 +            check_then_add(mpl, set->array->head->value.set,
278.1002 +               copy_tuple(mpl, tuple));
278.1003 +         /* skip optional comma between <symbol> and <value> */
278.1004 +         if (mpl->token == T_COMMA) get_token(mpl /* , */);
278.1005 +         /* read values accordingly to the column list */
278.1006 +         for (col = list; col != NULL; col = col->next)
278.1007 +         {  /* if the token is single point, no value is provided */
278.1008 +            if (is_literal(mpl, "."))
278.1009 +            {  get_token(mpl /* . */);
278.1010 +               continue;
278.1011 +            }
278.1012 +            /* read value and assign it to new parameter member */
278.1013 +            if (!is_symbol(mpl))
278.1014 +            {  int lack = slice_dimen(mpl, col);
278.1015 +               xassert(tuple != NULL);
278.1016 +               if (lack == 1)
278.1017 +                  error(mpl, "one item missing in data group beginning "
278.1018 +                     "with %s", format_symbol(mpl, tuple->sym));
278.1019 +               else
278.1020 +                  error(mpl, "%d items missing in data group beginning "
278.1021 +                     "with %s", lack, format_symbol(mpl, tuple->sym));
278.1022 +            }
278.1023 +            read_value(mpl, (PARAMETER *)col->sym, copy_tuple(mpl,
278.1024 +               tuple));
278.1025 +            /* skip optional comma preceding the next value */
278.1026 +            if (col->next != NULL && mpl->token == T_COMMA)
278.1027 +               get_token(mpl /* , */);
278.1028 +         }
278.1029 +         /* delete the original subscript list */
278.1030 +         delete_tuple(mpl, tuple);
278.1031 +         /* skip optional comma (only if there is next data group) */
278.1032 +         if (mpl->token == T_COMMA)
278.1033 +         {  get_token(mpl /* , */);
278.1034 +            if (!is_symbol(mpl)) unget_token(mpl /* , */);
278.1035 +         }
278.1036 +      }
278.1037 +      /* delete the column list (it contains parameters, not symbols,
278.1038 +         so nullify it before) */
278.1039 +      for (col = list; col != NULL; col = col->next) col->sym = NULL;
278.1040 +      delete_slice(mpl, list);
278.1041 +      return;
278.1042 +}
278.1043 +
278.1044 +/*----------------------------------------------------------------------
278.1045 +-- parameter_data - read parameter data.
278.1046 +--
278.1047 +-- This routine reads parameter data using the syntax:
278.1048 +--
278.1049 +-- <parameter data> ::= param <default value> : <tabbing format> ;
278.1050 +-- <parameter data> ::= param <parameter name> <default value>
278.1051 +--                      <assignments> ;
278.1052 +-- <parameter name> ::= <symbolic name>
278.1053 +-- <default value> ::= <empty>
278.1054 +-- <default value> ::= default <symbol>
278.1055 +-- <assignments> ::= <empty>
278.1056 +-- <assignments> ::= <assignments> , :=
278.1057 +-- <assignments> ::= <assignments> , [ <symbol list> ]
278.1058 +-- <assignments> ::= <assignments> , <plain format>
278.1059 +-- <assignemnts> ::= <assignments> , : <tabular format>
278.1060 +-- <assignments> ::= <assignments> , (tr) <tabular format>
278.1061 +-- <assignments> ::= <assignments> , (tr) : <tabular format>
278.1062 +--
278.1063 +-- Commae in <assignments> are optional and may be omitted anywhere. */
278.1064 +
278.1065 +void parameter_data(MPL *mpl)
278.1066 +{     PARAMETER *par;
278.1067 +      SYMBOL *altval = NULL;
278.1068 +      SLICE *slice;
278.1069 +      int tr = 0;
278.1070 +      xassert(is_literal(mpl, "param"));
278.1071 +      get_token(mpl /* param */);
278.1072 +      /* read optional default value */
278.1073 +      if (is_literal(mpl, "default"))
278.1074 +      {  get_token(mpl /* default */);
278.1075 +         if (!is_symbol(mpl))
278.1076 +            error(mpl, "default value missing where expected");
278.1077 +         altval = read_symbol(mpl);
278.1078 +         /* if the default value follows the keyword 'param', the next
278.1079 +            token must be only the colon */
278.1080 +         if (mpl->token != T_COLON)
278.1081 +            error(mpl, "colon missing where expected");
278.1082 +      }
278.1083 +      /* being used after the keyword 'param' or the optional default
278.1084 +         value the colon begins data in the tabbing format */
278.1085 +      if (mpl->token == T_COLON)
278.1086 +      {  get_token(mpl /* : */);
278.1087 +         /* skip optional comma */
278.1088 +         if (mpl->token == T_COMMA) get_token(mpl /* , */);
278.1089 +         /* read parameter data in the tabbing format */
278.1090 +         tabbing_format(mpl, altval);
278.1091 +         /* on reading data in the tabbing format the default value is
278.1092 +            always copied, so delete the original symbol */
278.1093 +         if (altval != NULL) delete_symbol(mpl, altval);
278.1094 +         /* the next token must be only semicolon */
278.1095 +         if (mpl->token != T_SEMICOLON)
278.1096 +            error(mpl, "symbol, number, or semicolon missing where expe"
278.1097 +               "cted");
278.1098 +         get_token(mpl /* ; */);
278.1099 +         goto done;
278.1100 +      }
278.1101 +      /* in other cases there must be symbolic name of parameter, which
278.1102 +         follows the keyword 'param' */
278.1103 +      if (!is_symbol(mpl))
278.1104 +         error(mpl, "parameter name missing where expected");
278.1105 +      /* select the parameter to saturate it with data */
278.1106 +      par = select_parameter(mpl, mpl->image);
278.1107 +      get_token(mpl /* <symbol> */);
278.1108 +      /* read optional default value */
278.1109 +      if (is_literal(mpl, "default"))
278.1110 +      {  get_token(mpl /* default */);
278.1111 +         if (!is_symbol(mpl))
278.1112 +            error(mpl, "default value missing where expected");
278.1113 +         altval = read_symbol(mpl);
278.1114 +         /* set default value for the parameter */
278.1115 +         set_default(mpl, par, altval);
278.1116 +      }
278.1117 +      /* create initial fake slice of all asterisks */
278.1118 +      slice = fake_slice(mpl, par->dim);
278.1119 +      /* read zero or more data assignments */
278.1120 +      for (;;)
278.1121 +      {  /* skip optional comma */
278.1122 +         if (mpl->token == T_COMMA) get_token(mpl /* , */);
278.1123 +         /* process current assignment */
278.1124 +         if (mpl->token == T_ASSIGN)
278.1125 +         {  /* assignment ligature is non-significant element */
278.1126 +            get_token(mpl /* := */);
278.1127 +         }
278.1128 +         else if (mpl->token == T_LBRACKET)
278.1129 +         {  /* left bracket begins new slice; delete the current slice
278.1130 +               and read new one */
278.1131 +            delete_slice(mpl, slice);
278.1132 +            slice = read_slice(mpl, par->name, par->dim);
278.1133 +            /* each new slice resets the "transpose" indicator */
278.1134 +            tr = 0;
278.1135 +         }
278.1136 +         else if (is_symbol(mpl))
278.1137 +         {  /* number or symbol begins data in the plain format */
278.1138 +            plain_format(mpl, par, slice);
278.1139 +         }
278.1140 +         else if (mpl->token == T_COLON)
278.1141 +         {  /* colon begins data in the tabular format */
278.1142 +            if (par->dim == 0)
278.1143 +err1:          error(mpl, "%s not a subscripted parameter",
278.1144 +                  par->name);
278.1145 +            if (slice_arity(mpl, slice) != 2)
278.1146 +err2:          error(mpl, "slice currently used must specify 2 asterisk"
278.1147 +                  "s, not %d", slice_arity(mpl, slice));
278.1148 +            get_token(mpl /* : */);
278.1149 +            /* read parameter data in the tabular format */
278.1150 +            tabular_format(mpl, par, slice, tr);
278.1151 +         }
278.1152 +         else if (mpl->token == T_LEFT)
278.1153 +         {  /* left parenthesis begins the "transpose" indicator, which
278.1154 +               is followed by data in the tabular format */
278.1155 +            get_token(mpl /* ( */);
278.1156 +            if (!is_literal(mpl, "tr"))
278.1157 +err3:          error(mpl, "transpose indicator (tr) incomplete");
278.1158 +            if (par->dim == 0) goto err1;
278.1159 +            if (slice_arity(mpl, slice) != 2) goto err2;
278.1160 +            get_token(mpl /* tr */);
278.1161 +            if (mpl->token != T_RIGHT) goto err3;
278.1162 +            get_token(mpl /* ) */);
278.1163 +            /* in this case the colon is optional */
278.1164 +            if (mpl->token == T_COLON) get_token(mpl /* : */);
278.1165 +            /* set the "transpose" indicator */
278.1166 +            tr = 1;
278.1167 +            /* read parameter data in the tabular format */
278.1168 +            tabular_format(mpl, par, slice, tr);
278.1169 +         }
278.1170 +         else if (mpl->token == T_SEMICOLON)
278.1171 +         {  /* semicolon terminates the data block */
278.1172 +            get_token(mpl /* ; */);
278.1173 +            break;
278.1174 +         }
278.1175 +         else
278.1176 +            error(mpl, "syntax error in parameter data block");
278.1177 +      }
278.1178 +      /* delete the current slice */
278.1179 +      delete_slice(mpl, slice);
278.1180 +done: return;
278.1181 +}
278.1182 +
278.1183 +/*----------------------------------------------------------------------
278.1184 +-- data_section - read data section.
278.1185 +--
278.1186 +-- This routine reads data section using the syntax:
278.1187 +--
278.1188 +-- <data section> ::= <empty>
278.1189 +-- <data section> ::= <data section> <data block> ;
278.1190 +-- <data block> ::= <set data>
278.1191 +-- <data block> ::= <parameter data>
278.1192 +--
278.1193 +-- Reading data section is terminated by either the keyword 'end' or
278.1194 +-- the end of file. */
278.1195 +
278.1196 +void data_section(MPL *mpl)
278.1197 +{     while (!(mpl->token == T_EOF || is_literal(mpl, "end")))
278.1198 +      {  if (is_literal(mpl, "set"))
278.1199 +            set_data(mpl);
278.1200 +         else if (is_literal(mpl, "param"))
278.1201 +            parameter_data(mpl);
278.1202 +         else
278.1203 +            error(mpl, "syntax error in data section");
278.1204 +      }
278.1205 +      return;
278.1206 +}
278.1207 +
278.1208 +/* eof */
   279.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
   279.2 +++ b/deps/glpk/src/glpmpl03.c	Sun Nov 06 20:59:10 2011 +0100
   279.3 @@ -0,0 +1,6078 @@
   279.4 +/* glpmpl03.c */
   279.5 +
   279.6 +/***********************************************************************
   279.7 +*  This code is part of GLPK (GNU Linear Programming Kit).
   279.8 +*
   279.9 +*  Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008,
  279.10 +*  2009, 2010, 2011 Andrew Makhorin, Department for Applied Informatics,
  279.11 +*  Moscow Aviation Institute, Moscow, Russia. All rights reserved.
  279.12 +*  E-mail: <mao@gnu.org>.
  279.13 +*
  279.14 +*  GLPK is free software: you can redistribute it and/or modify it
  279.15 +*  under the terms of the GNU General Public License as published by
  279.16 +*  the Free Software Foundation, either version 3 of the License, or
  279.17 +*  (at your option) any later version.
  279.18 +*
  279.19 +*  GLPK is distributed in the hope that it will be useful, but WITHOUT
  279.20 +*  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
  279.21 +*  or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
  279.22 +*  License for more details.
  279.23 +*
  279.24 +*  You should have received a copy of the GNU General Public License
  279.25 +*  along with GLPK. If not, see <http://www.gnu.org/licenses/>.
  279.26 +***********************************************************************/
  279.27 +
  279.28 +#define _GLPSTD_ERRNO
  279.29 +#define _GLPSTD_STDIO
  279.30 +#include "glpenv.h"
  279.31 +#include "glpmpl.h"
  279.32 +
  279.33 +/**********************************************************************/
  279.34 +/* * *                   FLOATING-POINT NUMBERS                   * * */
  279.35 +/**********************************************************************/
  279.36 +
  279.37 +/*----------------------------------------------------------------------
  279.38 +-- fp_add - floating-point addition.
  279.39 +--
  279.40 +-- This routine computes the sum x + y. */
  279.41 +
  279.42 +double fp_add(MPL *mpl, double x, double y)
  279.43 +{     if (x > 0.0 && y > 0.0 && x > + 0.999 * DBL_MAX - y ||
  279.44 +          x < 0.0 && y < 0.0 && x < - 0.999 * DBL_MAX - y)
  279.45 +         error(mpl, "%.*g + %.*g; floating-point overflow",
  279.46 +            DBL_DIG, x, DBL_DIG, y);
  279.47 +      return x + y;
  279.48 +}
  279.49 +
  279.50 +/*----------------------------------------------------------------------
  279.51 +-- fp_sub - floating-point subtraction.
  279.52 +--
  279.53 +-- This routine computes the difference x - y. */
  279.54 +
  279.55 +double fp_sub(MPL *mpl, double x, double y)
  279.56 +{     if (x > 0.0 && y < 0.0 && x > + 0.999 * DBL_MAX + y ||
  279.57 +          x < 0.0 && y > 0.0 && x < - 0.999 * DBL_MAX + y)
  279.58 +         error(mpl, "%.*g - %.*g; floating-point overflow",
  279.59 +            DBL_DIG, x, DBL_DIG, y);
  279.60 +      return x - y;
  279.61 +}
  279.62 +
  279.63 +/*----------------------------------------------------------------------
  279.64 +-- fp_less - floating-point non-negative subtraction.
  279.65 +--
  279.66 +-- This routine computes the non-negative difference max(0, x - y). */
  279.67 +
  279.68 +double fp_less(MPL *mpl, double x, double y)
  279.69 +{     if (x < y) return 0.0;
  279.70 +      if (x > 0.0 && y < 0.0 && x > + 0.999 * DBL_MAX + y)
  279.71 +         error(mpl, "%.*g less %.*g; floating-point overflow",
  279.72 +            DBL_DIG, x, DBL_DIG, y);
  279.73 +      return x - y;
  279.74 +}
  279.75 +
  279.76 +/*----------------------------------------------------------------------
  279.77 +-- fp_mul - floating-point multiplication.
  279.78 +--
  279.79 +-- This routine computes the product x * y. */
  279.80 +
  279.81 +double fp_mul(MPL *mpl, double x, double y)
  279.82 +{     if (fabs(y) > 1.0 && fabs(x) > (0.999 * DBL_MAX) / fabs(y))
  279.83 +         error(mpl, "%.*g * %.*g; floating-point overflow",
  279.84 +            DBL_DIG, x, DBL_DIG, y);
  279.85 +      return x * y;
  279.86 +}
  279.87 +
  279.88 +/*----------------------------------------------------------------------
  279.89 +-- fp_div - floating-point division.
  279.90 +--
  279.91 +-- This routine computes the quotient x / y. */
  279.92 +
  279.93 +double fp_div(MPL *mpl, double x, double y)
  279.94 +{     if (fabs(y) < DBL_MIN)
  279.95 +         error(mpl, "%.*g / %.*g; floating-point zero divide",
  279.96 +            DBL_DIG, x, DBL_DIG, y);
  279.97 +      if (fabs(y) < 1.0 && fabs(x) > (0.999 * DBL_MAX) * fabs(y))
  279.98 +         error(mpl, "%.*g / %.*g; floating-point overflow",
  279.99 +            DBL_DIG, x, DBL_DIG, y);
 279.100 +      return x / y;
 279.101 +}
 279.102 +
 279.103 +/*----------------------------------------------------------------------
 279.104 +-- fp_idiv - floating-point quotient of exact division.
 279.105 +--
 279.106 +-- This routine computes the quotient of exact division x div y. */
 279.107 +
 279.108 +double fp_idiv(MPL *mpl, double x, double y)
 279.109 +{     if (fabs(y) < DBL_MIN)
 279.110 +         error(mpl, "%.*g div %.*g; floating-point zero divide",
 279.111 +            DBL_DIG, x, DBL_DIG, y);
 279.112 +      if (fabs(y) < 1.0 && fabs(x) > (0.999 * DBL_MAX) * fabs(y))
 279.113 +         error(mpl, "%.*g div %.*g; floating-point overflow",
 279.114 +            DBL_DIG, x, DBL_DIG, y);
 279.115 +      x /= y;
 279.116 +      return x > 0.0 ? floor(x) : x < 0.0 ? ceil(x) : 0.0;
 279.117 +}
 279.118 +
 279.119 +/*----------------------------------------------------------------------
 279.120 +-- fp_mod - floating-point remainder of exact division.
 279.121 +--
 279.122 +-- This routine computes the remainder of exact division x mod y.
 279.123 +--
 279.124 +-- NOTE: By definition x mod y = x - y * floor(x / y). */
 279.125 +
 279.126 +double fp_mod(MPL *mpl, double x, double y)
 279.127 +{     double r;
 279.128 +      xassert(mpl == mpl);
 279.129 +      if (x == 0.0)
 279.130 +         r = 0.0;
 279.131 +      else if (y == 0.0)
 279.132 +         r = x;
 279.133 +      else
 279.134 +      {  r = fmod(fabs(x), fabs(y));
 279.135 +         if (r != 0.0)
 279.136 +         {  if (x < 0.0) r = - r;
 279.137 +            if (x > 0.0 && y < 0.0 || x < 0.0 && y > 0.0) r += y;
 279.138 +         }
 279.139 +      }
 279.140 +      return r;
 279.141 +}
 279.142 +
 279.143 +/*----------------------------------------------------------------------
 279.144 +-- fp_power - floating-point exponentiation (raise to power).
 279.145 +--
 279.146 +-- This routine computes the exponentiation x ** y. */
 279.147 +
 279.148 +double fp_power(MPL *mpl, double x, double y)
 279.149 +{     double r;
 279.150 +      if (x == 0.0 && y <= 0.0 || x < 0.0 && y != floor(y))
 279.151 +         error(mpl, "%.*g ** %.*g; result undefined",
 279.152 +            DBL_DIG, x, DBL_DIG, y);
 279.153 +      if (x == 0.0) goto eval;
 279.154 +      if (fabs(x) > 1.0 && y > +1.0 &&
 279.155 +            +log(fabs(x)) > (0.999 * log(DBL_MAX)) / y ||
 279.156 +          fabs(x) < 1.0 && y < -1.0 &&
 279.157 +            +log(fabs(x)) < (0.999 * log(DBL_MAX)) / y)
 279.158 +         error(mpl, "%.*g ** %.*g; floating-point overflow",
 279.159 +            DBL_DIG, x, DBL_DIG, y);
 279.160 +      if (fabs(x) > 1.0 && y < -1.0 &&
 279.161 +            -log(fabs(x)) < (0.999 * log(DBL_MAX)) / y ||
 279.162 +          fabs(x) < 1.0 && y > +1.0 &&
 279.163 +            -log(fabs(x)) > (0.999 * log(DBL_MAX)) / y)
 279.164 +         r = 0.0;
 279.165 +      else
 279.166 +eval:    r = pow(x, y);
 279.167 +      return r;
 279.168 +}
 279.169 +
 279.170 +/*----------------------------------------------------------------------
 279.171 +-- fp_exp - floating-point base-e exponential.
 279.172 +--
 279.173 +-- This routine computes the base-e exponential e ** x. */
 279.174 +
 279.175 +double fp_exp(MPL *mpl, double x)
 279.176 +{     if (x > 0.999 * log(DBL_MAX))
 279.177 +         error(mpl, "exp(%.*g); floating-point overflow", DBL_DIG, x);
 279.178 +      return exp(x);
 279.179 +}
 279.180 +
 279.181 +/*----------------------------------------------------------------------
 279.182 +-- fp_log - floating-point natural logarithm.
 279.183 +--
 279.184 +-- This routine computes the natural logarithm log x. */
 279.185 +
 279.186 +double fp_log(MPL *mpl, double x)
 279.187 +{     if (x <= 0.0)
 279.188 +         error(mpl, "log(%.*g); non-positive argument", DBL_DIG, x);
 279.189 +      return log(x);
 279.190 +}
 279.191 +
 279.192 +/*----------------------------------------------------------------------
 279.193 +-- fp_log10 - floating-point common (decimal) logarithm.
 279.194 +--
 279.195 +-- This routine computes the common (decimal) logarithm lg x. */
 279.196 +
 279.197 +double fp_log10(MPL *mpl, double x)
 279.198 +{     if (x <= 0.0)
 279.199 +         error(mpl, "log10(%.*g); non-positive argument", DBL_DIG, x);
 279.200 +      return log10(x);
 279.201 +}
 279.202 +
 279.203 +/*----------------------------------------------------------------------
 279.204 +-- fp_sqrt - floating-point square root.
 279.205 +--
 279.206 +-- This routine computes the square root x ** 0.5. */
 279.207 +
 279.208 +double fp_sqrt(MPL *mpl, double x)
 279.209 +{     if (x < 0.0)
 279.210 +         error(mpl, "sqrt(%.*g); negative argument", DBL_DIG, x);
 279.211 +      return sqrt(x);
 279.212 +}
 279.213 +
 279.214 +/*----------------------------------------------------------------------
 279.215 +-- fp_sin - floating-point trigonometric sine.
 279.216 +--
 279.217 +-- This routine computes the trigonometric sine sin(x). */
 279.218 +
 279.219 +double fp_sin(MPL *mpl, double x)
 279.220 +{     if (!(-1e6 <= x && x <= +1e6))
 279.221 +         error(mpl, "sin(%.*g); argument too large", DBL_DIG, x);
 279.222 +      return sin(x);
 279.223 +}
 279.224 +
 279.225 +/*----------------------------------------------------------------------
 279.226 +-- fp_cos - floating-point trigonometric cosine.
 279.227 +--
 279.228 +-- This routine computes the trigonometric cosine cos(x). */
 279.229 +
 279.230 +double fp_cos(MPL *mpl, double x)
 279.231 +{     if (!(-1e6 <= x && x <= +1e6))
 279.232 +         error(mpl, "cos(%.*g); argument too large", DBL_DIG, x);
 279.233 +      return cos(x);
 279.234 +}
 279.235 +
 279.236 +/*----------------------------------------------------------------------
 279.237 +-- fp_atan - floating-point trigonometric arctangent.
 279.238 +--
 279.239 +-- This routine computes the trigonometric arctangent atan(x). */
 279.240 +
 279.241 +double fp_atan(MPL *mpl, double x)
 279.242 +{     xassert(mpl == mpl);
 279.243 +      return atan(x);
 279.244 +}
 279.245 +
 279.246 +/*----------------------------------------------------------------------
 279.247 +-- fp_atan2 - floating-point trigonometric arctangent.
 279.248 +--
 279.249 +-- This routine computes the trigonometric arctangent atan(y / x). */
 279.250 +
 279.251 +double fp_atan2(MPL *mpl, double y, double x)
 279.252 +{     xassert(mpl == mpl);
 279.253 +      return atan2(y, x);
 279.254 +}
 279.255 +
 279.256 +/*----------------------------------------------------------------------
 279.257 +-- fp_round - round floating-point value to n fractional digits.
 279.258 +--
 279.259 +-- This routine rounds given floating-point value x to n fractional
 279.260 +-- digits with the formula:
 279.261 +--
 279.262 +--    round(x, n) = floor(x * 10^n + 0.5) / 10^n.
 279.263 +--
 279.264 +-- The parameter n is assumed to be integer. */
 279.265 +
 279.266 +double fp_round(MPL *mpl, double x, double n)
 279.267 +{     double ten_to_n;
 279.268 +      if (n != floor(n))
 279.269 +         error(mpl, "round(%.*g, %.*g); non-integer second argument",
 279.270 +            DBL_DIG, x, DBL_DIG, n);
 279.271 +      if (n <= DBL_DIG + 2)
 279.272 +      {  ten_to_n = pow(10.0, n);
 279.273 +         if (fabs(x) < (0.999 * DBL_MAX) / ten_to_n)
 279.274 +         {  x = floor(x * ten_to_n + 0.5);
 279.275 +            if (x != 0.0) x /= ten_to_n;
 279.276 +         }
 279.277 +      }
 279.278 +      return x;
 279.279 +}
 279.280 +
 279.281 +/*----------------------------------------------------------------------
 279.282 +-- fp_trunc - truncate floating-point value to n fractional digits.
 279.283 +--
 279.284 +-- This routine truncates given floating-point value x to n fractional
 279.285 +-- digits with the formula:
 279.286 +--
 279.287 +--                  ( floor(x * 10^n) / 10^n,  if x >= 0
 279.288 +--    trunc(x, n) = <
 279.289 +--                  ( ceil(x * 10^n) / 10^n,   if x < 0
 279.290 +--
 279.291 +-- The parameter n is assumed to be integer. */
 279.292 +
 279.293 +double fp_trunc(MPL *mpl, double x, double n)
 279.294 +{     double ten_to_n;
 279.295 +      if (n != floor(n))
 279.296 +         error(mpl, "trunc(%.*g, %.*g); non-integer second argument",
 279.297 +            DBL_DIG, x, DBL_DIG, n);
 279.298 +      if (n <= DBL_DIG + 2)
 279.299 +      {  ten_to_n = pow(10.0, n);
 279.300 +         if (fabs(x) < (0.999 * DBL_MAX) / ten_to_n)
 279.301 +         {  x = (x >= 0.0 ? floor(x * ten_to_n) : ceil(x * ten_to_n));
 279.302 +            if (x != 0.0) x /= ten_to_n;
 279.303 +         }
 279.304 +      }
 279.305 +      return x;
 279.306 +}
 279.307 +
 279.308 +/**********************************************************************/
 279.309 +/* * *              PSEUDO-RANDOM NUMBER GENERATORS               * * */
 279.310 +/**********************************************************************/
 279.311 +
 279.312 +/*----------------------------------------------------------------------
 279.313 +-- fp_irand224 - pseudo-random integer in the range [0, 2^24).
 279.314 +--
 279.315 +-- This routine returns a next pseudo-random integer (converted to
 279.316 +-- floating-point) which is uniformly distributed between 0 and 2^24-1,
 279.317 +-- inclusive. */
 279.318 +
 279.319 +#define two_to_the_24 0x1000000
 279.320 +
 279.321 +double fp_irand224(MPL *mpl)
 279.322 +{     return
 279.323 +         (double)rng_unif_rand(mpl->rand, two_to_the_24);
 279.324 +}
 279.325 +
 279.326 +/*----------------------------------------------------------------------
 279.327 +-- fp_uniform01 - pseudo-random number in the range [0, 1).
 279.328 +--
 279.329 +-- This routine returns a next pseudo-random number which is uniformly
 279.330 +-- distributed in the range [0, 1). */
 279.331 +
 279.332 +#define two_to_the_31 ((unsigned int)0x80000000)
 279.333 +
 279.334 +double fp_uniform01(MPL *mpl)
 279.335 +{     return
 279.336 +         (double)rng_next_rand(mpl->rand) / (double)two_to_the_31;
 279.337 +}
 279.338 +
 279.339 +/*----------------------------------------------------------------------
 279.340 +-- fp_uniform - pseudo-random number in the range [a, b).
 279.341 +--
 279.342 +-- This routine returns a next pseudo-random number which is uniformly
 279.343 +-- distributed in the range [a, b). */
 279.344 +
 279.345 +double fp_uniform(MPL *mpl, double a, double b)
 279.346 +{     double x;
 279.347 +      if (a >= b)
 279.348 +         error(mpl, "Uniform(%.*g, %.*g); invalid range",
 279.349 +            DBL_DIG, a, DBL_DIG, b);
 279.350 +      x = fp_uniform01(mpl);
 279.351 +#if 0
 279.352 +      x = a * (1.0 - x) + b * x;
 279.353 +#else
 279.354 +      x = fp_add(mpl, a * (1.0 - x), b * x);
 279.355 +#endif
 279.356 +      return x;
 279.357 +}
 279.358 +
 279.359 +/*----------------------------------------------------------------------
 279.360 +-- fp_normal01 - Gaussian random variate with mu = 0 and sigma = 1.
 279.361 +--
 279.362 +-- This routine returns a Gaussian random variate with zero mean and
 279.363 +-- unit standard deviation. The polar (Box-Mueller) method is used.
 279.364 +--
 279.365 +-- This code is a modified version of the routine gsl_ran_gaussian from
 279.366 +-- the GNU Scientific Library Version 1.0. */
 279.367 +
 279.368 +double fp_normal01(MPL *mpl)
 279.369 +{     double x, y, r2;
 279.370 +      do
 279.371 +      {  /* choose x, y in uniform square (-1,-1) to (+1,+1) */
 279.372 +         x = -1.0 + 2.0 * fp_uniform01(mpl);
 279.373 +         y = -1.0 + 2.0 * fp_uniform01(mpl);
 279.374 +         /* see if it is in the unit circle */
 279.375 +         r2 = x * x + y * y;
 279.376 +      } while (r2 > 1.0 || r2 == 0.0);
 279.377 +      /* Box-Muller transform */
 279.378 +      return y * sqrt(-2.0 * log (r2) / r2);
 279.379 +}
 279.380 +
 279.381 +/*----------------------------------------------------------------------
 279.382 +-- fp_normal - Gaussian random variate with specified mu and sigma.
 279.383 +--
 279.384 +-- This routine returns a Gaussian random variate with mean mu and
 279.385 +-- standard deviation sigma. */
 279.386 +
 279.387 +double fp_normal(MPL *mpl, double mu, double sigma)
 279.388 +{     double x;
 279.389 +#if 0
 279.390 +      x = mu + sigma * fp_normal01(mpl);
 279.391 +#else
 279.392 +      x = fp_add(mpl, mu, fp_mul(mpl, sigma, fp_normal01(mpl)));
 279.393 +#endif
 279.394 +      return x;
 279.395 +}
 279.396 +
 279.397 +/**********************************************************************/
 279.398 +/* * *                SEGMENTED CHARACTER STRINGS                 * * */
 279.399 +/**********************************************************************/
 279.400 +
 279.401 +/*----------------------------------------------------------------------
 279.402 +-- create_string - create character string.
 279.403 +--
 279.404 +-- This routine creates a segmented character string, which is exactly
 279.405 +-- equivalent to specified character string. */
 279.406 +
 279.407 +STRING *create_string
 279.408 +(     MPL *mpl,
 279.409 +      char buf[MAX_LENGTH+1]  /* not changed */
 279.410 +)
 279.411 +#if 0
 279.412 +{     STRING *head, *tail;
 279.413 +      int i, j;
 279.414 +      xassert(buf != NULL);
 279.415 +      xassert(strlen(buf) <= MAX_LENGTH);
 279.416 +      head = tail = dmp_get_atom(mpl->strings, sizeof(STRING));
 279.417 +      for (i = j = 0; ; i++)
 279.418 +      {  if ((tail->seg[j++] = buf[i]) == '\0') break;
 279.419 +         if (j == STRSEG_SIZE)
 279.420 +tail = (tail->next = dmp_get_atom(mpl->strings, sizeof(STRING))), j = 0;
 279.421 +      }
 279.422 +      tail->next = NULL;
 279.423 +      return head;
 279.424 +}
 279.425 +#else
 279.426 +{     STRING *str;
 279.427 +      xassert(strlen(buf) <= MAX_LENGTH);
 279.428 +      str = dmp_get_atom(mpl->strings, strlen(buf)+1);
 279.429 +      strcpy(str, buf);
 279.430 +      return str;
 279.431 +}
 279.432 +#endif
 279.433 +
 279.434 +/*----------------------------------------------------------------------
 279.435 +-- copy_string - make copy of character string.
 279.436 +--
 279.437 +-- This routine returns an exact copy of segmented character string. */
 279.438 +
 279.439 +STRING *copy_string
 279.440 +(     MPL *mpl,
 279.441 +      STRING *str             /* not changed */
 279.442 +)
 279.443 +#if 0
 279.444 +{     STRING *head, *tail;
 279.445 +      xassert(str != NULL);
 279.446 +      head = tail = dmp_get_atom(mpl->strings, sizeof(STRING));
 279.447 +      for (; str != NULL; str = str->next)
 279.448 +      {  memcpy(tail->seg, str->seg, STRSEG_SIZE);
 279.449 +         if (str->next != NULL)
 279.450 +tail = (tail->next = dmp_get_atom(mpl->strings, sizeof(STRING)));
 279.451 +      }
 279.452 +      tail->next = NULL;
 279.453 +      return head;
 279.454 +}
 279.455 +#else
 279.456 +{     xassert(mpl == mpl);
 279.457 +      return create_string(mpl, str);
 279.458 +}
 279.459 +#endif
 279.460 +
 279.461 +/*----------------------------------------------------------------------
 279.462 +-- compare_strings - compare one character string with another.
 279.463 +--
 279.464 +-- This routine compares one segmented character strings with another
 279.465 +-- and returns the result of comparison as follows:
 279.466 +--
 279.467 +-- = 0 - both strings are identical;
 279.468 +-- < 0 - the first string precedes the second one;
 279.469 +-- > 0 - the first string follows the second one. */
 279.470 +
 279.471 +int compare_strings
 279.472 +(     MPL *mpl,
 279.473 +      STRING *str1,           /* not changed */
 279.474 +      STRING *str2            /* not changed */
 279.475 +)
 279.476 +#if 0
 279.477 +{     int j, c1, c2;
 279.478 +      xassert(mpl == mpl);
 279.479 +      for (;; str1 = str1->next, str2 = str2->next)
 279.480 +      {  xassert(str1 != NULL);
 279.481 +         xassert(str2 != NULL);
 279.482 +         for (j = 0; j < STRSEG_SIZE; j++)
 279.483 +         {  c1 = (unsigned char)str1->seg[j];
 279.484 +            c2 = (unsigned char)str2->seg[j];
 279.485 +            if (c1 < c2) return -1;
 279.486 +            if (c1 > c2) return +1;
 279.487 +            if (c1 == '\0') goto done;
 279.488 +         }
 279.489 +      }
 279.490 +done: return 0;
 279.491 +}
 279.492 +#else
 279.493 +{     xassert(mpl == mpl);
 279.494 +      return strcmp(str1, str2);
 279.495 +}
 279.496 +#endif
 279.497 +
 279.498 +/*----------------------------------------------------------------------
 279.499 +-- fetch_string - extract content of character string.
 279.500 +--
 279.501 +-- This routine returns a character string, which is exactly equivalent
 279.502 +-- to specified segmented character string. */
 279.503 +
 279.504 +char *fetch_string
 279.505 +(     MPL *mpl,
 279.506 +      STRING *str,            /* not changed */
 279.507 +      char buf[MAX_LENGTH+1]  /* modified */
 279.508 +)
 279.509 +#if 0
 279.510 +{     int i, j;
 279.511 +      xassert(mpl == mpl);
 279.512 +      xassert(buf != NULL);
 279.513 +      for (i = 0; ; str = str->next)
 279.514 +      {  xassert(str != NULL);
 279.515 +         for (j = 0; j < STRSEG_SIZE; j++)
 279.516 +            if ((buf[i++] = str->seg[j]) == '\0') goto done;
 279.517 +      }
 279.518 +done: xassert(strlen(buf) <= MAX_LENGTH);
 279.519 +      return buf;
 279.520 +}
 279.521 +#else
 279.522 +{     xassert(mpl == mpl);
 279.523 +      return strcpy(buf, str);
 279.524 +}
 279.525 +#endif
 279.526 +
 279.527 +/*----------------------------------------------------------------------
 279.528 +-- delete_string - delete character string.
 279.529 +--
 279.530 +-- This routine deletes specified segmented character string. */
 279.531 +
 279.532 +void delete_string
 279.533 +(     MPL *mpl,
 279.534 +      STRING *str             /* destroyed */
 279.535 +)
 279.536 +#if 0
 279.537 +{     STRING *temp;
 279.538 +      xassert(str != NULL);
 279.539 +      while (str != NULL)
 279.540 +      {  temp = str;
 279.541 +         str = str->next;
 279.542 +         dmp_free_atom(mpl->strings, temp, sizeof(STRING));
 279.543 +      }
 279.544 +      return;
 279.545 +}
 279.546 +#else
 279.547 +{     dmp_free_atom(mpl->strings, str, strlen(str)+1);
 279.548 +      return;
 279.549 +}
 279.550 +#endif
 279.551 +
 279.552 +/**********************************************************************/
 279.553 +/* * *                          SYMBOLS                           * * */
 279.554 +/**********************************************************************/
 279.555 +
 279.556 +/*----------------------------------------------------------------------
 279.557 +-- create_symbol_num - create symbol of numeric type.
 279.558 +--
 279.559 +-- This routine creates a symbol, which has a numeric value specified
 279.560 +-- as floating-point number. */
 279.561 +
 279.562 +SYMBOL *create_symbol_num(MPL *mpl, double num)
 279.563 +{     SYMBOL *sym;
 279.564 +      sym = dmp_get_atom(mpl->symbols, sizeof(SYMBOL));
 279.565 +      sym->num = num;
 279.566 +      sym->str = NULL;
 279.567 +      return sym;
 279.568 +}
 279.569 +
 279.570 +/*----------------------------------------------------------------------
 279.571 +-- create_symbol_str - create symbol of abstract type.
 279.572 +--
 279.573 +-- This routine creates a symbol, which has an abstract value specified
 279.574 +-- as segmented character string. */
 279.575 +
 279.576 +SYMBOL *create_symbol_str
 279.577 +(     MPL *mpl,
 279.578 +      STRING *str             /* destroyed */
 279.579 +)
 279.580 +{     SYMBOL *sym;
 279.581 +      xassert(str != NULL);
 279.582 +      sym = dmp_get_atom(mpl->symbols, sizeof(SYMBOL));
 279.583 +      sym->num = 0.0;
 279.584 +      sym->str = str;
 279.585 +      return sym;
 279.586 +}
 279.587 +
 279.588 +/*----------------------------------------------------------------------
 279.589 +-- copy_symbol - make copy of symbol.
 279.590 +--
 279.591 +-- This routine returns an exact copy of symbol. */
 279.592 +
 279.593 +SYMBOL *copy_symbol
 279.594 +(     MPL *mpl,
 279.595 +      SYMBOL *sym             /* not changed */
 279.596 +)
 279.597 +{     SYMBOL *copy;
 279.598 +      xassert(sym != NULL);
 279.599 +      copy = dmp_get_atom(mpl->symbols, sizeof(SYMBOL));
 279.600 +      if (sym->str == NULL)
 279.601 +      {  copy->num = sym->num;
 279.602 +         copy->str = NULL;
 279.603 +      }
 279.604 +      else
 279.605 +      {  copy->num = 0.0;
 279.606 +         copy->str = copy_string(mpl, sym->str);
 279.607 +      }
 279.608 +      return copy;
 279.609 +}
 279.610 +
 279.611 +/*----------------------------------------------------------------------
 279.612 +-- compare_symbols - compare one symbol with another.
 279.613 +--
 279.614 +-- This routine compares one symbol with another and returns the result
 279.615 +-- of comparison as follows:
 279.616 +--
 279.617 +-- = 0 - both symbols are identical;
 279.618 +-- < 0 - the first symbol precedes the second one;
 279.619 +-- > 0 - the first symbol follows the second one.
 279.620 +--
 279.621 +-- Note that the linear order, in which symbols follow each other, is
 279.622 +-- implementation-dependent. It may be not an alphabetical order. */
 279.623 +
 279.624 +int compare_symbols
 279.625 +(     MPL *mpl,
 279.626 +      SYMBOL *sym1,           /* not changed */
 279.627 +      SYMBOL *sym2            /* not changed */
 279.628 +)
 279.629 +{     xassert(sym1 != NULL);
 279.630 +      xassert(sym2 != NULL);
 279.631 +      /* let all numeric quantities precede all symbolic quantities */
 279.632 +      if (sym1->str == NULL && sym2->str == NULL)
 279.633 +      {  if (sym1->num < sym2->num) return -1;
 279.634 +         if (sym1->num > sym2->num) return +1;
 279.635 +         return 0;
 279.636 +      }
 279.637 +      if (sym1->str == NULL) return -1;
 279.638 +      if (sym2->str == NULL) return +1;
 279.639 +      return compare_strings(mpl, sym1->str, sym2->str);
 279.640 +}
 279.641 +
 279.642 +/*----------------------------------------------------------------------
 279.643 +-- delete_symbol - delete symbol.
 279.644 +--
 279.645 +-- This routine deletes specified symbol. */
 279.646 +
 279.647 +void delete_symbol
 279.648 +(     MPL *mpl,
 279.649 +      SYMBOL *sym             /* destroyed */
 279.650 +)
 279.651 +{     xassert(sym != NULL);
 279.652 +      if (sym->str != NULL) delete_string(mpl, sym->str);
 279.653 +      dmp_free_atom(mpl->symbols, sym, sizeof(SYMBOL));
 279.654 +      return;
 279.655 +}
 279.656 +
 279.657 +/*----------------------------------------------------------------------
 279.658 +-- format_symbol - format symbol for displaying or printing.
 279.659 +--
 279.660 +-- This routine converts specified symbol to a charater string, which
 279.661 +-- is suitable for displaying or printing.
 279.662 +--
 279.663 +-- The resultant string is never longer than 255 characters. If it gets
 279.664 +-- longer, it is truncated from the right and appended by dots. */
 279.665 +
 279.666 +char *format_symbol
 279.667 +(     MPL *mpl,
 279.668 +      SYMBOL *sym             /* not changed */
 279.669 +)
 279.670 +{     char *buf = mpl->sym_buf;
 279.671 +      xassert(sym != NULL);
 279.672 +      if (sym->str == NULL)
 279.673 +         sprintf(buf, "%.*g", DBL_DIG, sym->num);
 279.674 +      else
 279.675 +      {  char str[MAX_LENGTH+1];
 279.676 +         int quoted, j, len;
 279.677 +         fetch_string(mpl, sym->str, str);
 279.678 +         if (!(isalpha((unsigned char)str[0]) || str[0] == '_'))
 279.679 +            quoted = 1;
 279.680 +         else
 279.681 +         {  quoted = 0;
 279.682 +            for (j = 1; str[j] != '\0'; j++)
 279.683 +            {  if (!(isalnum((unsigned char)str[j]) ||
 279.684 +                     strchr("+-._", (unsigned char)str[j]) != NULL))
 279.685 +               {  quoted = 1;
 279.686 +                  break;
 279.687 +               }
 279.688 +            }
 279.689 +         }
 279.690 +#        define safe_append(c) \
 279.691 +            (void)(len < 255 ? (buf[len++] = (char)(c)) : 0)
 279.692 +         buf[0] = '\0', len = 0;
 279.693 +         if (quoted) safe_append('\'');
 279.694 +         for (j = 0; str[j] != '\0'; j++)
 279.695 +         {  if (quoted && str[j] == '\'') safe_append('\'');
 279.696 +            safe_append(str[j]);
 279.697 +         }
 279.698 +         if (quoted) safe_append('\'');
 279.699 +#        undef safe_append
 279.700 +         buf[len] = '\0';
 279.701 +         if (len == 255) strcpy(buf+252, "...");
 279.702 +      }
 279.703 +      xassert(strlen(buf) <= 255);
 279.704 +      return buf;
 279.705 +}
 279.706 +
 279.707 +/*----------------------------------------------------------------------
 279.708 +-- concat_symbols - concatenate one symbol with another.
 279.709 +--
 279.710 +-- This routine concatenates values of two given symbols and assigns
 279.711 +-- the resultant character string to a new symbol, which is returned on
 279.712 +-- exit. Both original symbols are destroyed. */
 279.713 +
 279.714 +SYMBOL *concat_symbols
 279.715 +(     MPL *mpl,
 279.716 +      SYMBOL *sym1,           /* destroyed */
 279.717 +      SYMBOL *sym2            /* destroyed */
 279.718 +)
 279.719 +{     char str1[MAX_LENGTH+1], str2[MAX_LENGTH+1];
 279.720 +      xassert(MAX_LENGTH >= DBL_DIG + DBL_DIG);
 279.721 +      if (sym1->str == NULL)
 279.722 +         sprintf(str1, "%.*g", DBL_DIG, sym1->num);
 279.723 +      else
 279.724 +         fetch_string(mpl, sym1->str, str1);
 279.725 +      if (sym2->str == NULL)
 279.726 +         sprintf(str2, "%.*g", DBL_DIG, sym2->num);
 279.727 +      else
 279.728 +         fetch_string(mpl, sym2->str, str2);
 279.729 +      if (strlen(str1) + strlen(str2) > MAX_LENGTH)
 279.730 +      {  char buf[255+1];
 279.731 +         strcpy(buf, format_symbol(mpl, sym1));
 279.732 +         xassert(strlen(buf) < sizeof(buf));
 279.733 +         error(mpl, "%s & %s; resultant symbol exceeds %d characters",
 279.734 +            buf, format_symbol(mpl, sym2), MAX_LENGTH);
 279.735 +      }
 279.736 +      delete_symbol(mpl, sym1);
 279.737 +      delete_symbol(mpl, sym2);
 279.738 +      return create_symbol_str(mpl, create_string(mpl, strcat(str1,
 279.739 +         str2)));
 279.740 +}
 279.741 +
 279.742 +/**********************************************************************/
 279.743 +/* * *                          N-TUPLES                          * * */
 279.744 +/**********************************************************************/
 279.745 +
 279.746 +/*----------------------------------------------------------------------
 279.747 +-- create_tuple - create n-tuple.
 279.748 +--
 279.749 +-- This routine creates a n-tuple, which initially has no components,
 279.750 +-- i.e. which is 0-tuple. */
 279.751 +
 279.752 +TUPLE *create_tuple(MPL *mpl)
 279.753 +{     TUPLE *tuple;
 279.754 +      xassert(mpl == mpl);
 279.755 +      tuple = NULL;
 279.756 +      return tuple;
 279.757 +}
 279.758 +
 279.759 +/*----------------------------------------------------------------------
 279.760 +-- expand_tuple - append symbol to n-tuple.
 279.761 +--
 279.762 +-- This routine expands n-tuple appending to it a given symbol, which
 279.763 +-- becomes its new last component. */
 279.764 +
 279.765 +TUPLE *expand_tuple
 279.766 +(     MPL *mpl,
 279.767 +      TUPLE *tuple,           /* destroyed */
 279.768 +      SYMBOL *sym             /* destroyed */
 279.769 +)
 279.770 +{     TUPLE *tail, *temp;
 279.771 +      xassert(sym != NULL);
 279.772 +      /* create a new component */
 279.773 +      tail = dmp_get_atom(mpl->tuples, sizeof(TUPLE));
 279.774 +      tail->sym = sym;
 279.775 +      tail->next = NULL;
 279.776 +      /* and append it to the component list */
 279.777 +      if (tuple == NULL)
 279.778 +         tuple = tail;
 279.779 +      else
 279.780 +      {  for (temp = tuple; temp->next != NULL; temp = temp->next);
 279.781 +         temp->next = tail;
 279.782 +      }
 279.783 +      return tuple;
 279.784 +}
 279.785 +
 279.786 +/*----------------------------------------------------------------------
 279.787 +-- tuple_dimen - determine dimension of n-tuple.
 279.788 +--
 279.789 +-- This routine returns dimension of n-tuple, i.e. number of components
 279.790 +-- in the n-tuple. */
 279.791 +
 279.792 +int tuple_dimen
 279.793 +(     MPL *mpl,
 279.794 +      TUPLE *tuple            /* not changed */
 279.795 +)
 279.796 +{     TUPLE *temp;
 279.797 +      int dim = 0;
 279.798 +      xassert(mpl == mpl);
 279.799 +      for (temp = tuple; temp != NULL; temp = temp->next) dim++;
 279.800 +      return dim;
 279.801 +}
 279.802 +
 279.803 +/*----------------------------------------------------------------------
 279.804 +-- copy_tuple - make copy of n-tuple.
 279.805 +--
 279.806 +-- This routine returns an exact copy of n-tuple. */
 279.807 +
 279.808 +TUPLE *copy_tuple
 279.809 +(     MPL *mpl,
 279.810 +      TUPLE *tuple            /* not changed */
 279.811 +)
 279.812 +{     TUPLE *head, *tail;
 279.813 +      if (tuple == NULL)
 279.814 +         head = NULL;
 279.815 +      else
 279.816 +      {  head = tail = dmp_get_atom(mpl->tuples, sizeof(TUPLE));
 279.817 +         for (; tuple != NULL; tuple = tuple->next)
 279.818 +         {  xassert(tuple->sym != NULL);
 279.819 +            tail->sym = copy_symbol(mpl, tuple->sym);
 279.820 +            if (tuple->next != NULL)
 279.821 +tail = (tail->next = dmp_get_atom(mpl->tuples, sizeof(TUPLE)));
 279.822 +         }
 279.823 +         tail->next = NULL;
 279.824 +      }
 279.825 +      return head;
 279.826 +}
 279.827 +
 279.828 +/*----------------------------------------------------------------------
 279.829 +-- compare_tuples - compare one n-tuple with another.
 279.830 +--
 279.831 +-- This routine compares two given n-tuples, which must have the same
 279.832 +-- dimension (not checked for the sake of efficiency), and returns one
 279.833 +-- of the following codes:
 279.834 +--
 279.835 +-- = 0 - both n-tuples are identical;
 279.836 +-- < 0 - the first n-tuple precedes the second one;
 279.837 +-- > 0 - the first n-tuple follows the second one.
 279.838 +--
 279.839 +-- Note that the linear order, in which n-tuples follow each other, is
 279.840 +-- implementation-dependent. It may be not an alphabetical order. */
 279.841 +
 279.842 +int compare_tuples
 279.843 +(     MPL *mpl,
 279.844 +      TUPLE *tuple1,          /* not changed */
 279.845 +      TUPLE *tuple2           /* not changed */
 279.846 +)
 279.847 +{     TUPLE *item1, *item2;
 279.848 +      int ret;
 279.849 +      xassert(mpl == mpl);
 279.850 +      for (item1 = tuple1, item2 = tuple2; item1 != NULL;
 279.851 +           item1 = item1->next, item2 = item2->next)
 279.852 +      {  xassert(item2 != NULL);
 279.853 +         xassert(item1->sym != NULL);
 279.854 +         xassert(item2->sym != NULL);
 279.855 +         ret = compare_symbols(mpl, item1->sym, item2->sym);
 279.856 +         if (ret != 0) return ret;
 279.857 +      }
 279.858 +      xassert(item2 == NULL);
 279.859 +      return 0;
 279.860 +}
 279.861 +
 279.862 +/*----------------------------------------------------------------------
 279.863 +-- build_subtuple - build subtuple of given n-tuple.
 279.864 +--
 279.865 +-- This routine builds subtuple, which consists of first dim components
 279.866 +-- of given n-tuple. */
 279.867 +
 279.868 +TUPLE *build_subtuple
 279.869 +(     MPL *mpl,
 279.870 +      TUPLE *tuple,           /* not changed */
 279.871 +      int dim
 279.872 +)
 279.873 +{     TUPLE *head, *temp;
 279.874 +      int j;
 279.875 +      head = create_tuple(mpl);
 279.876 +      for (j = 1, temp = tuple; j <= dim; j++, temp = temp->next)
 279.877 +      {  xassert(temp != NULL);
 279.878 +         head = expand_tuple(mpl, head, copy_symbol(mpl, temp->sym));
 279.879 +      }
 279.880 +      return head;
 279.881 +}
 279.882 +
 279.883 +/*----------------------------------------------------------------------
 279.884 +-- delete_tuple - delete n-tuple.
 279.885 +--
 279.886 +-- This routine deletes specified n-tuple. */
 279.887 +
 279.888 +void delete_tuple
 279.889 +(     MPL *mpl,
 279.890 +      TUPLE *tuple            /* destroyed */
 279.891 +)
 279.892 +{     TUPLE *temp;
 279.893 +      while (tuple != NULL)
 279.894 +      {  temp = tuple;
 279.895 +         tuple = temp->next;
 279.896 +         xassert(temp->sym != NULL);
 279.897 +         delete_symbol(mpl, temp->sym);
 279.898 +         dmp_free_atom(mpl->tuples, temp, sizeof(TUPLE));
 279.899 +      }
 279.900 +      return;
 279.901 +}
 279.902 +
 279.903 +/*----------------------------------------------------------------------
 279.904 +-- format_tuple - format n-tuple for displaying or printing.
 279.905 +--
 279.906 +-- This routine converts specified n-tuple to a character string, which
 279.907 +-- is suitable for displaying or printing.
 279.908 +--
 279.909 +-- The resultant string is never longer than 255 characters. If it gets
 279.910 +-- longer, it is truncated from the right and appended by dots. */
 279.911 +
 279.912 +char *format_tuple
 279.913 +(     MPL *mpl,
 279.914 +      int c,
 279.915 +      TUPLE *tuple            /* not changed */
 279.916 +)
 279.917 +{     TUPLE *temp;
 279.918 +      int dim, j, len;
 279.919 +      char *buf = mpl->tup_buf, str[255+1], *save;
 279.920 +#     define safe_append(c) \
 279.921 +         (void)(len < 255 ? (buf[len++] = (char)(c)) : 0)
 279.922 +      buf[0] = '\0', len = 0;
 279.923 +      dim = tuple_dimen(mpl, tuple);
 279.924 +      if (c == '[' && dim > 0) safe_append('[');
 279.925 +      if (c == '(' && dim > 1) safe_append('(');
 279.926 +      for (temp = tuple; temp != NULL; temp = temp->next)
 279.927 +      {  if (temp != tuple) safe_append(',');
 279.928 +         xassert(temp->sym != NULL);
 279.929 +         save = mpl->sym_buf;
 279.930 +         mpl->sym_buf = str;
 279.931 +         format_symbol(mpl, temp->sym);
 279.932 +         mpl->sym_buf = save;
 279.933 +         xassert(strlen(str) < sizeof(str));
 279.934 +         for (j = 0; str[j] != '\0'; j++) safe_append(str[j]);
 279.935 +      }
 279.936 +      if (c == '[' && dim > 0) safe_append(']');
 279.937 +      if (c == '(' && dim > 1) safe_append(')');
 279.938 +#     undef safe_append
 279.939 +      buf[len] = '\0';
 279.940 +      if (len == 255) strcpy(buf+252, "...");
 279.941 +      xassert(strlen(buf) <= 255);
 279.942 +      return buf;
 279.943 +}
 279.944 +
 279.945 +/**********************************************************************/
 279.946 +/* * *                       ELEMENTAL SETS                       * * */
 279.947 +/**********************************************************************/
 279.948 +
 279.949 +/*----------------------------------------------------------------------
 279.950 +-- create_elemset - create elemental set.
 279.951 +--
 279.952 +-- This routine creates an elemental set, whose members are n-tuples of
 279.953 +-- specified dimension. Being created the set is initially empty. */
 279.954 +
 279.955 +ELEMSET *create_elemset(MPL *mpl, int dim)
 279.956 +{     ELEMSET *set;
 279.957 +      xassert(dim > 0);
 279.958 +      set = create_array(mpl, A_NONE, dim);
 279.959 +      return set;
 279.960 +}
 279.961 +
 279.962 +/*----------------------------------------------------------------------
 279.963 +-- find_tuple - check if elemental set contains given n-tuple.
 279.964 +--
 279.965 +-- This routine finds given n-tuple in specified elemental set in order
 279.966 +-- to check if the set contains that n-tuple. If the n-tuple is found,
 279.967 +-- the routine returns pointer to corresponding array member. Otherwise
 279.968 +-- null pointer is returned. */
 279.969 +
 279.970 +MEMBER *find_tuple
 279.971 +(     MPL *mpl,
 279.972 +      ELEMSET *set,           /* not changed */
 279.973 +      TUPLE *tuple            /* not changed */
 279.974 +)
 279.975 +{     xassert(set != NULL);
 279.976 +      xassert(set->type == A_NONE);
 279.977 +      xassert(set->dim == tuple_dimen(mpl, tuple));
 279.978 +      return find_member(mpl, set, tuple);
 279.979 +}
 279.980 +
 279.981 +/*----------------------------------------------------------------------
 279.982 +-- add_tuple - add new n-tuple to elemental set.
 279.983 +--
 279.984 +-- This routine adds given n-tuple to specified elemental set.
 279.985 +--
 279.986 +-- For the sake of efficiency this routine doesn't check whether the
 279.987 +-- set already contains the same n-tuple or not. Therefore the calling
 279.988 +-- program should use the routine find_tuple (if necessary) in order to
 279.989 +-- make sure that the given n-tuple is not contained in the set, since
 279.990 +-- duplicate n-tuples within the same set are not allowed. */
 279.991 +
 279.992 +MEMBER *add_tuple
 279.993 +(     MPL *mpl,
 279.994 +      ELEMSET *set,           /* modified */
 279.995 +      TUPLE *tuple            /* destroyed */
 279.996 +)
 279.997 +{     MEMBER *memb;
 279.998 +      xassert(set != NULL);
 279.999 +      xassert(set->type == A_NONE);
279.1000 +      xassert(set->dim == tuple_dimen(mpl, tuple));
279.1001 +      memb = add_member(mpl, set, tuple);
279.1002 +      memb->value.none = NULL;
279.1003 +      return memb;
279.1004 +}
279.1005 +
279.1006 +/*----------------------------------------------------------------------
279.1007 +-- check_then_add - check and add new n-tuple to elemental set.
279.1008 +--
279.1009 +-- This routine is equivalent to the routine add_tuple except that it
279.1010 +-- does check for duplicate n-tuples. */
279.1011 +
279.1012 +MEMBER *check_then_add
279.1013 +(     MPL *mpl,
279.1014 +      ELEMSET *set,           /* modified */
279.1015 +      TUPLE *tuple            /* destroyed */
279.1016 +)
279.1017 +{     if (find_tuple(mpl, set, tuple) != NULL)
279.1018 +         error(mpl, "duplicate tuple %s detected", format_tuple(mpl,
279.1019 +            '(', tuple));
279.1020 +      return add_tuple(mpl, set, tuple);
279.1021 +}
279.1022 +
279.1023 +/*----------------------------------------------------------------------
279.1024 +-- copy_elemset - make copy of elemental set.
279.1025 +--
279.1026 +-- This routine makes an exact copy of elemental set. */
279.1027 +
279.1028 +ELEMSET *copy_elemset
279.1029 +(     MPL *mpl,
279.1030 +      ELEMSET *set            /* not changed */
279.1031 +)
279.1032 +{     ELEMSET *copy;
279.1033 +      MEMBER *memb;
279.1034 +      xassert(set != NULL);
279.1035 +      xassert(set->type == A_NONE);
279.1036 +      xassert(set->dim > 0);
279.1037 +      copy = create_elemset(mpl, set->dim);
279.1038 +      for (memb = set->head; memb != NULL; memb = memb->next)
279.1039 +         add_tuple(mpl, copy, copy_tuple(mpl, memb->tuple));
279.1040 +      return copy;
279.1041 +}
279.1042 +
279.1043 +/*----------------------------------------------------------------------
279.1044 +-- delete_elemset - delete elemental set.
279.1045 +--
279.1046 +-- This routine deletes specified elemental set. */
279.1047 +
279.1048 +void delete_elemset
279.1049 +(     MPL *mpl,
279.1050 +      ELEMSET *set            /* destroyed */
279.1051 +)
279.1052 +{     xassert(set != NULL);
279.1053 +      xassert(set->type == A_NONE);
279.1054 +      delete_array(mpl, set);
279.1055 +      return;
279.1056 +}
279.1057 +
279.1058 +/*----------------------------------------------------------------------
279.1059 +-- arelset_size - compute size of "arithmetic" elemental set.
279.1060 +--
279.1061 +-- This routine computes the size of "arithmetic" elemental set, which
279.1062 +-- is specified in the form of arithmetic progression:
279.1063 +--
279.1064 +--    { t0 .. tf by dt }.
279.1065 +--
279.1066 +-- The size is computed using the formula:
279.1067 +--
279.1068 +--    n = max(0, floor((tf - t0) / dt) + 1). */
279.1069 +
279.1070 +int arelset_size(MPL *mpl, double t0, double tf, double dt)
279.1071 +{     double temp;
279.1072 +      if (dt == 0.0)
279.1073 +         error(mpl, "%.*g .. %.*g by %.*g; zero stride not allowed",
279.1074 +            DBL_DIG, t0, DBL_DIG, tf, DBL_DIG, dt);
279.1075 +      if (tf > 0.0 && t0 < 0.0 && tf > + 0.999 * DBL_MAX + t0)
279.1076 +         temp = +DBL_MAX;
279.1077 +      else if (tf < 0.0 && t0 > 0.0 && tf < - 0.999 * DBL_MAX + t0)
279.1078 +         temp = -DBL_MAX;
279.1079 +      else
279.1080 +         temp = tf - t0;
279.1081 +      if (fabs(dt) < 1.0 && fabs(temp) > (0.999 * DBL_MAX) * fabs(dt))
279.1082 +      {  if (temp > 0.0 && dt > 0.0 || temp < 0.0 && dt < 0.0)
279.1083 +            temp = +DBL_MAX;
279.1084 +         else
279.1085 +            temp = 0.0;
279.1086 +      }
279.1087 +      else
279.1088 +      {  temp = floor(temp / dt) + 1.0;
279.1089 +         if (temp < 0.0) temp = 0.0;
279.1090 +      }
279.1091 +      xassert(temp >= 0.0);
279.1092 +      if (temp > (double)(INT_MAX - 1))
279.1093 +         error(mpl, "%.*g .. %.*g by %.*g; set too large",
279.1094 +            DBL_DIG, t0, DBL_DIG, tf, DBL_DIG, dt);
279.1095 +      return (int)(temp + 0.5);
279.1096 +}
279.1097 +
279.1098 +/*----------------------------------------------------------------------
279.1099 +-- arelset_member - compute member of "arithmetic" elemental set.
279.1100 +--
279.1101 +-- This routine returns a numeric value of symbol, which is equivalent
279.1102 +-- to j-th member of given "arithmetic" elemental set specified in the
279.1103 +-- form of arithmetic progression:
279.1104 +--
279.1105 +--    { t0 .. tf by dt }.
279.1106 +--
279.1107 +-- The symbol value is computed with the formula:
279.1108 +--
279.1109 +--    j-th member = t0 + (j - 1) * dt,
279.1110 +--
279.1111 +-- The number j must satisfy to the restriction 1 <= j <= n, where n is
279.1112 +-- the set size computed by the routine arelset_size. */
279.1113 +
279.1114 +double arelset_member(MPL *mpl, double t0, double tf, double dt, int j)
279.1115 +{     xassert(1 <= j && j <= arelset_size(mpl, t0, tf, dt));
279.1116 +      return t0 + (double)(j - 1) * dt;
279.1117 +}
279.1118 +
279.1119 +/*----------------------------------------------------------------------
279.1120 +-- create_arelset - create "arithmetic" elemental set.
279.1121 +--
279.1122 +-- This routine creates "arithmetic" elemental set, which is specified
279.1123 +-- in the form of arithmetic progression:
279.1124 +--
279.1125 +--    { t0 .. tf by dt }.
279.1126 +--
279.1127 +-- Components of this set are 1-tuples. */
279.1128 +
279.1129 +ELEMSET *create_arelset(MPL *mpl, double t0, double tf, double dt)
279.1130 +{     ELEMSET *set;
279.1131 +      int j, n;
279.1132 +      set = create_elemset(mpl, 1);
279.1133 +      n = arelset_size(mpl, t0, tf, dt);
279.1134 +      for (j = 1; j <= n; j++)
279.1135 +      {  add_tuple
279.1136 +         (  mpl,
279.1137 +            set,
279.1138 +            expand_tuple
279.1139 +            (  mpl,
279.1140 +               create_tuple(mpl),
279.1141 +               create_symbol_num
279.1142 +               (  mpl,
279.1143 +                  arelset_member(mpl, t0, tf, dt, j)
279.1144 +               )
279.1145 +            )
279.1146 +         );
279.1147 +      }
279.1148 +      return set;
279.1149 +}
279.1150 +
279.1151 +/*----------------------------------------------------------------------
279.1152 +-- set_union - union of two elemental sets.
279.1153 +--
279.1154 +-- This routine computes the union:
279.1155 +--
279.1156 +--    X U Y = { j | (j in X) or (j in Y) },
279.1157 +--
279.1158 +-- where X and Y are given elemental sets (destroyed on exit). */
279.1159 +
279.1160 +ELEMSET *set_union
279.1161 +(     MPL *mpl,
279.1162 +      ELEMSET *X,             /* destroyed */
279.1163 +      ELEMSET *Y              /* destroyed */
279.1164 +)
279.1165 +{     MEMBER *memb;
279.1166 +      xassert(X != NULL);
279.1167 +      xassert(X->type == A_NONE);
279.1168 +      xassert(X->dim > 0);
279.1169 +      xassert(Y != NULL);
279.1170 +      xassert(Y->type == A_NONE);
279.1171 +      xassert(Y->dim > 0);
279.1172 +      xassert(X->dim == Y->dim);
279.1173 +      for (memb = Y->head; memb != NULL; memb = memb->next)
279.1174 +      {  if (find_tuple(mpl, X, memb->tuple) == NULL)
279.1175 +            add_tuple(mpl, X, copy_tuple(mpl, memb->tuple));
279.1176 +      }
279.1177 +      delete_elemset(mpl, Y);
279.1178 +      return X;
279.1179 +}
279.1180 +
279.1181 +/*----------------------------------------------------------------------
279.1182 +-- set_diff - difference between two elemental sets.
279.1183 +--
279.1184 +-- This routine computes the difference:
279.1185 +--
279.1186 +--    X \ Y = { j | (j in X) and (j not in Y) },
279.1187 +--
279.1188 +-- where X and Y are given elemental sets (destroyed on exit). */
279.1189 +
279.1190 +ELEMSET *set_diff
279.1191 +(     MPL *mpl,
279.1192 +      ELEMSET *X,             /* destroyed */
279.1193 +      ELEMSET *Y              /* destroyed */
279.1194 +)
279.1195 +{     ELEMSET *Z;
279.1196 +      MEMBER *memb;
279.1197 +      xassert(X != NULL);
279.1198 +      xassert(X->type == A_NONE);
279.1199 +      xassert(X->dim > 0);
279.1200 +      xassert(Y != NULL);
279.1201 +      xassert(Y->type == A_NONE);
279.1202 +      xassert(Y->dim > 0);
279.1203 +      xassert(X->dim == Y->dim);
279.1204 +      Z = create_elemset(mpl, X->dim);
279.1205 +      for (memb = X->head; memb != NULL; memb = memb->next)
279.1206 +      {  if (find_tuple(mpl, Y, memb->tuple) == NULL)
279.1207 +            add_tuple(mpl, Z, copy_tuple(mpl, memb->tuple));
279.1208 +      }
279.1209 +      delete_elemset(mpl, X);
279.1210 +      delete_elemset(mpl, Y);
279.1211 +      return Z;
279.1212 +}
279.1213 +
279.1214 +/*----------------------------------------------------------------------
279.1215 +-- set_symdiff - symmetric difference between two elemental sets.
279.1216 +--
279.1217 +-- This routine computes the symmetric difference:
279.1218 +--
279.1219 +--    X (+) Y = (X \ Y) U (Y \ X),
279.1220 +--
279.1221 +-- where X and Y are given elemental sets (destroyed on exit). */
279.1222 +
279.1223 +ELEMSET *set_symdiff
279.1224 +(     MPL *mpl,
279.1225 +      ELEMSET *X,             /* destroyed */
279.1226 +      ELEMSET *Y              /* destroyed */
279.1227 +)
279.1228 +{     ELEMSET *Z;
279.1229 +      MEMBER *memb;
279.1230 +      xassert(X != NULL);
279.1231 +      xassert(X->type == A_NONE);
279.1232 +      xassert(X->dim > 0);
279.1233 +      xassert(Y != NULL);
279.1234 +      xassert(Y->type == A_NONE);
279.1235 +      xassert(Y->dim > 0);
279.1236 +      xassert(X->dim == Y->dim);
279.1237 +      /* Z := X \ Y */
279.1238 +      Z = create_elemset(mpl, X->dim);
279.1239 +      for (memb = X->head; memb != NULL; memb = memb->next)
279.1240 +      {  if (find_tuple(mpl, Y, memb->tuple) == NULL)
279.1241 +            add_tuple(mpl, Z, copy_tuple(mpl, memb->tuple));
279.1242 +      }
279.1243 +      /* Z := Z U (Y \ X) */
279.1244 +      for (memb = Y->head; memb != NULL; memb = memb->next)
279.1245 +      {  if (find_tuple(mpl, X, memb->tuple) == NULL)
279.1246 +            add_tuple(mpl, Z, copy_tuple(mpl, memb->tuple));
279.1247 +      }
279.1248 +      delete_elemset(mpl, X);
279.1249 +      delete_elemset(mpl, Y);
279.1250 +      return Z;
279.1251 +}
279.1252 +
279.1253 +/*----------------------------------------------------------------------
279.1254 +-- set_inter - intersection of two elemental sets.
279.1255 +--
279.1256 +-- This routine computes the intersection:
279.1257 +--
279.1258 +--    X ^ Y = { j | (j in X) and (j in Y) },
279.1259 +--
279.1260 +-- where X and Y are given elemental sets (destroyed on exit). */
279.1261 +
279.1262 +ELEMSET *set_inter
279.1263 +(     MPL *mpl,
279.1264 +      ELEMSET *X,             /* destroyed */
279.1265 +      ELEMSET *Y              /* destroyed */
279.1266 +)
279.1267 +{     ELEMSET *Z;
279.1268 +      MEMBER *memb;
279.1269 +      xassert(X != NULL);
279.1270 +      xassert(X->type == A_NONE);
279.1271 +      xassert(X->dim > 0);
279.1272 +      xassert(Y != NULL);
279.1273 +      xassert(Y->type == A_NONE);
279.1274 +      xassert(Y->dim > 0);
279.1275 +      xassert(X->dim == Y->dim);
279.1276 +      Z = create_elemset(mpl, X->dim);
279.1277 +      for (memb = X->head; memb != NULL; memb = memb->next)
279.1278 +      {  if (find_tuple(mpl, Y, memb->tuple) != NULL)
279.1279 +            add_tuple(mpl, Z, copy_tuple(mpl, memb->tuple));
279.1280 +      }
279.1281 +      delete_elemset(mpl, X);
279.1282 +      delete_elemset(mpl, Y);
279.1283 +      return Z;
279.1284 +}
279.1285 +
279.1286 +/*----------------------------------------------------------------------
279.1287 +-- set_cross - cross (Cartesian) product of two elemental sets.
279.1288 +--
279.1289 +-- This routine computes the cross (Cartesian) product:
279.1290 +--
279.1291 +--    X x Y = { (i,j) | (i in X) and (j in Y) },
279.1292 +--
279.1293 +-- where X and Y are given elemental sets (destroyed on exit). */
279.1294 +
279.1295 +ELEMSET *set_cross
279.1296 +(     MPL *mpl,
279.1297 +      ELEMSET *X,             /* destroyed */
279.1298 +      ELEMSET *Y              /* destroyed */
279.1299 +)
279.1300 +{     ELEMSET *Z;
279.1301 +      MEMBER *memx, *memy;
279.1302 +      TUPLE *tuple, *temp;
279.1303 +      xassert(X != NULL);
279.1304 +      xassert(X->type == A_NONE);
279.1305 +      xassert(X->dim > 0);
279.1306 +      xassert(Y != NULL);
279.1307 +      xassert(Y->type == A_NONE);
279.1308 +      xassert(Y->dim > 0);
279.1309 +      Z = create_elemset(mpl, X->dim + Y->dim);
279.1310 +      for (memx = X->head; memx != NULL; memx = memx->next)
279.1311 +      {  for (memy = Y->head; memy != NULL; memy = memy->next)
279.1312 +         {  tuple = copy_tuple(mpl, memx->tuple);
279.1313 +            for (temp = memy->tuple; temp != NULL; temp = temp->next)
279.1314 +               tuple = expand_tuple(mpl, tuple, copy_symbol(mpl,
279.1315 +                  temp->sym));
279.1316 +            add_tuple(mpl, Z, tuple);
279.1317 +         }
279.1318 +      }
279.1319 +      delete_elemset(mpl, X);
279.1320 +      delete_elemset(mpl, Y);
279.1321 +      return Z;
279.1322 +}
279.1323 +
279.1324 +/**********************************************************************/
279.1325 +/* * *                    ELEMENTAL VARIABLES                     * * */
279.1326 +/**********************************************************************/
279.1327 +
279.1328 +/* (there are no specific routines for elemental variables) */
279.1329 +
279.1330 +/**********************************************************************/
279.1331 +/* * *                        LINEAR FORMS                        * * */
279.1332 +/**********************************************************************/
279.1333 +
279.1334 +/*----------------------------------------------------------------------
279.1335 +-- constant_term - create constant term.
279.1336 +--
279.1337 +-- This routine creates the linear form, which is a constant term. */
279.1338 +
279.1339 +FORMULA *constant_term(MPL *mpl, double coef)
279.1340 +{     FORMULA *form;
279.1341 +      if (coef == 0.0)
279.1342 +         form = NULL;
279.1343 +      else
279.1344 +      {  form = dmp_get_atom(mpl->formulae, sizeof(FORMULA));
279.1345 +         form->coef = coef;
279.1346 +         form->var = NULL;
279.1347 +         form->next = NULL;
279.1348 +      }
279.1349 +      return form;
279.1350 +}
279.1351 +
279.1352 +/*----------------------------------------------------------------------
279.1353 +-- single_variable - create single variable.
279.1354 +--
279.1355 +-- This routine creates the linear form, which is a single elemental
279.1356 +-- variable. */
279.1357 +
279.1358 +FORMULA *single_variable
279.1359 +(     MPL *mpl,
279.1360 +      ELEMVAR *var            /* referenced */
279.1361 +)
279.1362 +{     FORMULA *form;
279.1363 +      xassert(var != NULL);
279.1364 +      form = dmp_get_atom(mpl->formulae, sizeof(FORMULA));
279.1365 +      form->coef = 1.0;
279.1366 +      form->var = var;
279.1367 +      form->next = NULL;
279.1368 +      return form;
279.1369 +}
279.1370 +
279.1371 +/*----------------------------------------------------------------------
279.1372 +-- copy_formula - make copy of linear form.
279.1373 +--
279.1374 +-- This routine returns an exact copy of linear form. */
279.1375 +
279.1376 +FORMULA *copy_formula
279.1377 +(     MPL *mpl,
279.1378 +      FORMULA *form           /* not changed */
279.1379 +)
279.1380 +{     FORMULA *head, *tail;
279.1381 +      if (form == NULL)
279.1382 +         head = NULL;
279.1383 +      else
279.1384 +      {  head = tail = dmp_get_atom(mpl->formulae, sizeof(FORMULA));
279.1385 +         for (; form != NULL; form = form->next)
279.1386 +         {  tail->coef = form->coef;
279.1387 +            tail->var = form->var;
279.1388 +            if (form->next != NULL)
279.1389 +tail = (tail->next = dmp_get_atom(mpl->formulae, sizeof(FORMULA)));
279.1390 +         }
279.1391 +         tail->next = NULL;
279.1392 +      }
279.1393 +      return head;
279.1394 +}
279.1395 +
279.1396 +/*----------------------------------------------------------------------
279.1397 +-- delete_formula - delete linear form.
279.1398 +--
279.1399 +-- This routine deletes specified linear form. */
279.1400 +
279.1401 +void delete_formula
279.1402 +(     MPL *mpl,
279.1403 +      FORMULA *form           /* destroyed */
279.1404 +)
279.1405 +{     FORMULA *temp;
279.1406 +      while (form != NULL)
279.1407 +      {  temp = form;
279.1408 +         form = form->next;
279.1409 +         dmp_free_atom(mpl->formulae, temp, sizeof(FORMULA));
279.1410 +      }
279.1411 +      return;
279.1412 +}
279.1413 +
279.1414 +/*----------------------------------------------------------------------
279.1415 +-- linear_comb - linear combination of two linear forms.
279.1416 +--
279.1417 +-- This routine computes the linear combination:
279.1418 +--
279.1419 +--    a * fx + b * fy,
279.1420 +--
279.1421 +-- where a and b are numeric coefficients, fx and fy are linear forms
279.1422 +-- (destroyed on exit). */
279.1423 +
279.1424 +FORMULA *linear_comb
279.1425 +(     MPL *mpl,
279.1426 +      double a, FORMULA *fx,  /* destroyed */
279.1427 +      double b, FORMULA *fy   /* destroyed */
279.1428 +)
279.1429 +{     FORMULA *form = NULL, *term, *temp;
279.1430 +      double c0 = 0.0;
279.1431 +      for (term = fx; term != NULL; term = term->next)
279.1432 +      {  if (term->var == NULL)
279.1433 +            c0 = fp_add(mpl, c0, fp_mul(mpl, a, term->coef));
279.1434 +         else
279.1435 +            term->var->temp =
279.1436 +               fp_add(mpl, term->var->temp, fp_mul(mpl, a, term->coef));
279.1437 +      }
279.1438 +      for (term = fy; term != NULL; term = term->next)
279.1439 +      {  if (term->var == NULL)
279.1440 +            c0 = fp_add(mpl, c0, fp_mul(mpl, b, term->coef));
279.1441 +         else
279.1442 +            term->var->temp =
279.1443 +               fp_add(mpl, term->var->temp, fp_mul(mpl, b, term->coef));
279.1444 +      }
279.1445 +      for (term = fx; term != NULL; term = term->next)
279.1446 +      {  if (term->var != NULL && term->var->temp != 0.0)
279.1447 +         {  temp = dmp_get_atom(mpl->formulae, sizeof(FORMULA));
279.1448 +            temp->coef = term->var->temp, temp->var = term->var;
279.1449 +            temp->next = form, form = temp;
279.1450 +            term->var->temp = 0.0;
279.1451 +         }
279.1452 +      }
279.1453 +      for (term = fy; term != NULL; term = term->next)
279.1454 +      {  if (term->var != NULL && term->var->temp != 0.0)
279.1455 +         {  temp = dmp_get_atom(mpl->formulae, sizeof(FORMULA));
279.1456 +            temp->coef = term->var->temp, temp->var = term->var;
279.1457 +            temp->next = form, form = temp;
279.1458 +            term->var->temp = 0.0;
279.1459 +         }
279.1460 +      }
279.1461 +      if (c0 != 0.0)
279.1462 +      {  temp = dmp_get_atom(mpl->formulae, sizeof(FORMULA));
279.1463 +         temp->coef = c0, temp->var = NULL;
279.1464 +         temp->next = form, form = temp;
279.1465 +      }
279.1466 +      delete_formula(mpl, fx);
279.1467 +      delete_formula(mpl, fy);
279.1468 +      return form;
279.1469 +}
279.1470 +
279.1471 +/*----------------------------------------------------------------------
279.1472 +-- remove_constant - remove constant term from linear form.
279.1473 +--
279.1474 +-- This routine removes constant term from linear form and stores its
279.1475 +-- value to given location. */
279.1476 +
279.1477 +FORMULA *remove_constant
279.1478 +(     MPL *mpl,
279.1479 +      FORMULA *form,          /* destroyed */
279.1480 +      double *coef            /* modified */
279.1481 +)
279.1482 +{     FORMULA *head = NULL, *temp;
279.1483 +      *coef = 0.0;
279.1484 +      while (form != NULL)
279.1485 +      {  temp = form;
279.1486 +         form = form->next;
279.1487 +         if (temp->var == NULL)
279.1488 +         {  /* constant term */
279.1489 +            *coef = fp_add(mpl, *coef, temp->coef);
279.1490 +            dmp_free_atom(mpl->formulae, temp, sizeof(FORMULA));
279.1491 +         }
279.1492 +         else
279.1493 +         {  /* linear term */
279.1494 +            temp->next = head;
279.1495 +            head = temp;
279.1496 +         }
279.1497 +      }
279.1498 +      return head;
279.1499 +}
279.1500 +
279.1501 +/*----------------------------------------------------------------------
279.1502 +-- reduce_terms - reduce identical terms in linear form.
279.1503 +--
279.1504 +-- This routine reduces identical terms in specified linear form. */
279.1505 +
279.1506 +FORMULA *reduce_terms
279.1507 +(     MPL *mpl,
279.1508 +      FORMULA *form           /* destroyed */
279.1509 +)
279.1510 +{     FORMULA *term, *next_term;
279.1511 +      double c0 = 0.0;
279.1512 +      for (term = form; term != NULL; term = term->next)
279.1513 +      {  if (term->var == NULL)
279.1514 +            c0 = fp_add(mpl, c0, term->coef);
279.1515 +         else
279.1516 +            term->var->temp = fp_add(mpl, term->var->temp, term->coef);
279.1517 +      }
279.1518 +      next_term = form, form = NULL;
279.1519 +      for (term = next_term; term != NULL; term = next_term)
279.1520 +      {  next_term = term->next;
279.1521 +         if (term->var == NULL && c0 != 0.0)
279.1522 +         {  term->coef = c0, c0 = 0.0;
279.1523 +            term->next = form, form = term;
279.1524 +         }
279.1525 +         else if (term->var != NULL && term->var->temp != 0.0)
279.1526 +         {  term->coef = term->var->temp, term->var->temp = 0.0;
279.1527 +            term->next = form, form = term;
279.1528 +         }
279.1529 +         else
279.1530 +            dmp_free_atom(mpl->formulae, term, sizeof(FORMULA));
279.1531 +      }
279.1532 +      return form;
279.1533 +}
279.1534 +
279.1535 +/**********************************************************************/
279.1536 +/* * *                   ELEMENTAL CONSTRAINTS                    * * */
279.1537 +/**********************************************************************/
279.1538 +
279.1539 +/* (there are no specific routines for elemental constraints) */
279.1540 +
279.1541 +/**********************************************************************/
279.1542 +/* * *                       GENERIC VALUES                       * * */
279.1543 +/**********************************************************************/
279.1544 +
279.1545 +/*----------------------------------------------------------------------
279.1546 +-- delete_value - delete generic value.
279.1547 +--
279.1548 +-- This routine deletes specified generic value.
279.1549 +--
279.1550 +-- NOTE: The generic value to be deleted must be valid. */
279.1551 +
279.1552 +void delete_value
279.1553 +(     MPL *mpl,
279.1554 +      int type,
279.1555 +      VALUE *value            /* content destroyed */
279.1556 +)
279.1557 +{     xassert(value != NULL);
279.1558 +      switch (type)
279.1559 +      {  case A_NONE:
279.1560 +            value->none = NULL;
279.1561 +            break;
279.1562 +         case A_NUMERIC:
279.1563 +            value->num = 0.0;
279.1564 +            break;
279.1565 +         case A_SYMBOLIC:
279.1566 +            delete_symbol(mpl, value->sym), value->sym = NULL;
279.1567 +            break;
279.1568 +         case A_LOGICAL:
279.1569 +            value->bit = 0;
279.1570 +            break;
279.1571 +         case A_TUPLE:
279.1572 +            delete_tuple(mpl, value->tuple), value->tuple = NULL;
279.1573 +            break;
279.1574 +         case A_ELEMSET:
279.1575 +            delete_elemset(mpl, value->set), value->set = NULL;
279.1576 +            break;
279.1577 +         case A_ELEMVAR:
279.1578 +            value->var = NULL;
279.1579 +            break;
279.1580 +         case A_FORMULA:
279.1581 +            delete_formula(mpl, value->form), value->form = NULL;
279.1582 +            break;
279.1583 +         case A_ELEMCON:
279.1584 +            value->con = NULL;
279.1585 +            break;
279.1586 +         default:
279.1587 +            xassert(type != type);
279.1588 +      }
279.1589 +      return;
279.1590 +}
279.1591 +
279.1592 +/**********************************************************************/
279.1593 +/* * *                SYMBOLICALLY INDEXED ARRAYS                 * * */
279.1594 +/**********************************************************************/
279.1595 +
279.1596 +/*----------------------------------------------------------------------
279.1597 +-- create_array - create array.
279.1598 +--
279.1599 +-- This routine creates an array of specified type and dimension. Being
279.1600 +-- created the array is initially empty.
279.1601 +--
279.1602 +-- The type indicator determines generic values, which can be assigned
279.1603 +-- to the array members:
279.1604 +--
279.1605 +-- A_NONE     - none (members have no assigned values)
279.1606 +-- A_NUMERIC  - floating-point numbers
279.1607 +-- A_SYMBOLIC - symbols
279.1608 +-- A_ELEMSET  - elemental sets
279.1609 +-- A_ELEMVAR  - elemental variables
279.1610 +-- A_ELEMCON  - elemental constraints
279.1611 +--
279.1612 +-- The dimension may be 0, in which case the array consists of the only
279.1613 +-- member (such arrays represent 0-dimensional objects). */
279.1614 +
279.1615 +ARRAY *create_array(MPL *mpl, int type, int dim)
279.1616 +{     ARRAY *array;
279.1617 +      xassert(type == A_NONE || type == A_NUMERIC ||
279.1618 +             type == A_SYMBOLIC || type == A_ELEMSET ||
279.1619 +             type == A_ELEMVAR || type == A_ELEMCON);
279.1620 +      xassert(dim >= 0);
279.1621 +      array = dmp_get_atom(mpl->arrays, sizeof(ARRAY));
279.1622 +      array->type = type;
279.1623 +      array->dim = dim;
279.1624 +      array->size = 0;
279.1625 +      array->head = NULL;
279.1626 +      array->tail = NULL;
279.1627 +      array->tree = NULL;
279.1628 +      array->prev = NULL;
279.1629 +      array->next = mpl->a_list;
279.1630 +      /* include the array in the global array list */
279.1631 +      if (array->next != NULL) array->next->prev = array;
279.1632 +      mpl->a_list = array;
279.1633 +      return array;
279.1634 +}
279.1635 +
279.1636 +/*----------------------------------------------------------------------
279.1637 +-- find_member - find array member with given n-tuple.
279.1638 +--
279.1639 +-- This routine finds an array member, which has given n-tuple. If the
279.1640 +-- array is short, the linear search is used. Otherwise the routine
279.1641 +-- autimatically creates the search tree (i.e. the array index) to find
279.1642 +-- members for logarithmic time. */
279.1643 +
279.1644 +static int compare_member_tuples(void *info, const void *key1,
279.1645 +      const void *key2)
279.1646 +{     /* this is an auxiliary routine used to compare keys, which are
279.1647 +         n-tuples assigned to array members */
279.1648 +      return compare_tuples((MPL *)info, (TUPLE *)key1, (TUPLE *)key2);
279.1649 +}
279.1650 +
279.1651 +MEMBER *find_member
279.1652 +(     MPL *mpl,
279.1653 +      ARRAY *array,           /* not changed */
279.1654 +      TUPLE *tuple            /* not changed */
279.1655 +)
279.1656 +{     MEMBER *memb;
279.1657 +      xassert(array != NULL);
279.1658 +      /* the n-tuple must have the same dimension as the array */
279.1659 +      xassert(tuple_dimen(mpl, tuple) == array->dim);
279.1660 +      /* if the array is large enough, create the search tree and index
279.1661 +         all existing members of the array */
279.1662 +      if (array->size > 30 && array->tree == NULL)
279.1663 +      {  array->tree = avl_create_tree(compare_member_tuples, mpl);
279.1664 +         for (memb = array->head; memb != NULL; memb = memb->next)
279.1665 +avl_set_node_link(avl_insert_node(array->tree, memb->tuple),
279.1666 +               (void *)memb);
279.1667 +      }
279.1668 +      /* find a member, which has the given tuple */
279.1669 +      if (array->tree == NULL)
279.1670 +      {  /* the search tree doesn't exist; use the linear search */
279.1671 +         for (memb = array->head; memb != NULL; memb = memb->next)
279.1672 +            if (compare_tuples(mpl, memb->tuple, tuple) == 0) break;
279.1673 +      }
279.1674 +      else
279.1675 +      {  /* the search tree exists; use the binary search */
279.1676 +         AVLNODE *node;
279.1677 +         node = avl_find_node(array->tree, tuple);
279.1678 +memb = (MEMBER *)(node == NULL ? NULL : avl_get_node_link(node));
279.1679 +      }
279.1680 +      return memb;
279.1681 +}
279.1682 +
279.1683 +/*----------------------------------------------------------------------
279.1684 +-- add_member - add new member to array.
279.1685 +--
279.1686 +-- This routine creates a new member with given n-tuple and adds it to
279.1687 +-- specified array.
279.1688 +--
279.1689 +-- For the sake of efficiency this routine doesn't check whether the
279.1690 +-- array already contains a member with the given n-tuple or not. Thus,
279.1691 +-- if necessary, the calling program should use the routine find_member
279.1692 +-- in order to be sure that the array contains no member with the same
279.1693 +-- n-tuple, because members with duplicate n-tuples are not allowed.
279.1694 +--
279.1695 +-- This routine assigns no generic value to the new member, because the
279.1696 +-- calling program must do that. */
279.1697 +
279.1698 +MEMBER *add_member
279.1699 +(     MPL *mpl,
279.1700 +      ARRAY *array,           /* modified */
279.1701 +      TUPLE *tuple            /* destroyed */
279.1702 +)
279.1703 +{     MEMBER *memb;
279.1704 +      xassert(array != NULL);
279.1705 +      /* the n-tuple must have the same dimension as the array */
279.1706 +      xassert(tuple_dimen(mpl, tuple) == array->dim);
279.1707 +      /* create new member */
279.1708 +      memb = dmp_get_atom(mpl->members, sizeof(MEMBER));
279.1709 +      memb->tuple = tuple;
279.1710 +      memb->next = NULL;
279.1711 +      memset(&memb->value, '?', sizeof(VALUE));
279.1712 +      /* and append it to the member list */
279.1713 +      array->size++;
279.1714 +      if (array->head == NULL)
279.1715 +         array->head = memb;
279.1716 +      else
279.1717 +         array->tail->next = memb;
279.1718 +      array->tail = memb;
279.1719 +      /* if the search tree exists, index the new member */
279.1720 +      if (array->tree != NULL)
279.1721 +avl_set_node_link(avl_insert_node(array->tree, memb->tuple),
279.1722 +            (void *)memb);
279.1723 +      return memb;
279.1724 +}
279.1725 +
279.1726 +/*----------------------------------------------------------------------
279.1727 +-- delete_array - delete array.
279.1728 +--
279.1729 +-- This routine deletes specified array.
279.1730 +--
279.1731 +-- Generic values assigned to the array members are not deleted by this
279.1732 +-- routine. The calling program itself must delete all assigned generic
279.1733 +-- values before deleting the array. */
279.1734 +
279.1735 +void delete_array
279.1736 +(     MPL *mpl,
279.1737 +      ARRAY *array            /* destroyed */
279.1738 +)
279.1739 +{     MEMBER *memb;
279.1740 +      xassert(array != NULL);
279.1741 +      /* delete all existing array members */
279.1742 +      while (array->head != NULL)
279.1743 +      {  memb = array->head;
279.1744 +         array->head = memb->next;
279.1745 +         delete_tuple(mpl, memb->tuple);
279.1746 +         dmp_free_atom(mpl->members, memb, sizeof(MEMBER));
279.1747 +      }
279.1748 +      /* if the search tree exists, also delete it */
279.1749 +      if (array->tree != NULL) avl_delete_tree(array->tree);
279.1750 +      /* remove the array from the global array list */
279.1751 +      if (array->prev == NULL)
279.1752 +         mpl->a_list = array->next;
279.1753 +      else
279.1754 +         array->prev->next = array->next;
279.1755 +      if (array->next == NULL)
279.1756 +         ;
279.1757 +      else
279.1758 +         array->next->prev = array->prev;
279.1759 +      /* delete the array descriptor */
279.1760 +      dmp_free_atom(mpl->arrays, array, sizeof(ARRAY));
279.1761 +      return;
279.1762 +}
279.1763 +
279.1764 +/**********************************************************************/
279.1765 +/* * *                 DOMAINS AND DUMMY INDICES                  * * */
279.1766 +/**********************************************************************/
279.1767 +
279.1768 +/*----------------------------------------------------------------------
279.1769 +-- assign_dummy_index - assign new value to dummy index.
279.1770 +--
279.1771 +-- This routine assigns new value to specified dummy index and, that is
279.1772 +-- important, invalidates all temporary resultant values, which depends
279.1773 +-- on that dummy index. */
279.1774 +
279.1775 +void assign_dummy_index
279.1776 +(     MPL *mpl,
279.1777 +      DOMAIN_SLOT *slot,      /* modified */
279.1778 +      SYMBOL *value           /* not changed */
279.1779 +)
279.1780 +{     CODE *leaf, *code;
279.1781 +      xassert(slot != NULL);
279.1782 +      xassert(value != NULL);
279.1783 +      /* delete the current value assigned to the dummy index */
279.1784 +      if (slot->value != NULL)
279.1785 +      {  /* if the current value and the new one are identical, actual
279.1786 +            assignment is not needed */
279.1787 +         if (compare_symbols(mpl, slot->value, value) == 0) goto done;
279.1788 +         /* delete a symbol, which is the current value */
279.1789 +         delete_symbol(mpl, slot->value), slot->value = NULL;
279.1790 +      }
279.1791 +      /* now walk through all the pseudo-codes with op = O_INDEX, which
279.1792 +         refer to the dummy index to be changed (these pseudo-codes are
279.1793 +         leaves in the forest of *all* expressions in the database) */
279.1794 +      for (leaf = slot->list; leaf != NULL; leaf = leaf->arg.index.
279.1795 +         next)
279.1796 +      {  xassert(leaf->op == O_INDEX);
279.1797 +         /* invalidate all resultant values, which depend on the dummy
279.1798 +            index, walking from the current leaf toward the root of the
279.1799 +            corresponding expression tree */
279.1800 +         for (code = leaf; code != NULL; code = code->up)
279.1801 +         {  if (code->valid)
279.1802 +            {  /* invalidate and delete resultant value */
279.1803 +               code->valid = 0;
279.1804 +               delete_value(mpl, code->type, &code->value);
279.1805 +            }
279.1806 +         }
279.1807 +      }
279.1808 +      /* assign new value to the dummy index */
279.1809 +      slot->value = copy_symbol(mpl, value);
279.1810 +done: return;
279.1811 +}
279.1812 +
279.1813 +/*----------------------------------------------------------------------
279.1814 +-- update_dummy_indices - update current values of dummy indices.
279.1815 +--
279.1816 +-- This routine assigns components of "backup" n-tuple to dummy indices
279.1817 +-- of specified domain block. If no "backup" n-tuple is defined for the
279.1818 +-- domain block, values of the dummy indices remain untouched. */
279.1819 +
279.1820 +void update_dummy_indices
279.1821 +(     MPL *mpl,
279.1822 +      DOMAIN_BLOCK *block     /* not changed */
279.1823 +)
279.1824 +{     DOMAIN_SLOT *slot;
279.1825 +      TUPLE *temp;
279.1826 +      if (block->backup != NULL)
279.1827 +      {  for (slot = block->list, temp = block->backup; slot != NULL;
279.1828 +            slot = slot->next, temp = temp->next)
279.1829 +         {  xassert(temp != NULL);
279.1830 +            xassert(temp->sym != NULL);
279.1831 +            assign_dummy_index(mpl, slot, temp->sym);
279.1832 +         }
279.1833 +      }
279.1834 +      return;
279.1835 +}
279.1836 +
279.1837 +/*----------------------------------------------------------------------
279.1838 +-- enter_domain_block - enter domain block.
279.1839 +--
279.1840 +-- Let specified domain block have the form:
279.1841 +--
279.1842 +--    { ..., (j1, j2, ..., jn) in J, ... }
279.1843 +--
279.1844 +-- where j1, j2, ..., jn are dummy indices, J is a basic set.
279.1845 +--
279.1846 +-- This routine does the following:
279.1847 +--
279.1848 +-- 1. Checks if the given n-tuple is a member of the basic set J. Note
279.1849 +--    that J being *out of the scope* of the domain block cannot depend
279.1850 +--    on the dummy indices in the same and inner domain blocks, so it
279.1851 +--    can be computed before the dummy indices are assigned new values.
279.1852 +--    If this check fails, the routine returns with non-zero code.
279.1853 +--
279.1854 +-- 2. Saves current values of the dummy indices j1, j2, ..., jn.
279.1855 +--
279.1856 +-- 3. Assigns new values, which are components of the given n-tuple, to
279.1857 +--    the dummy indices j1, j2, ..., jn. If dimension of the n-tuple is
279.1858 +--    larger than n, its extra components n+1, n+2, ... are not used.
279.1859 +--
279.1860 +-- 4. Calls the formal routine func which either enters the next domain
279.1861 +--    block or evaluates some code within the domain scope.
279.1862 +--
279.1863 +-- 5. Restores former values of the dummy indices j1, j2, ..., jn.
279.1864 +--
279.1865 +-- Since current values assigned to the dummy indices on entry to this
279.1866 +-- routine are restored on exit, the formal routine func is allowed to
279.1867 +-- call this routine recursively. */
279.1868 +
279.1869 +int enter_domain_block
279.1870 +(     MPL *mpl,
279.1871 +      DOMAIN_BLOCK *block,    /* not changed */
279.1872 +      TUPLE *tuple,           /* not changed */
279.1873 +      void *info, void (*func)(MPL *mpl, void *info)
279.1874 +)
279.1875 +{     TUPLE *backup;
279.1876 +      int ret = 0;
279.1877 +      /* check if the given n-tuple is a member of the basic set */
279.1878 +      xassert(block->code != NULL);
279.1879 +      if (!is_member(mpl, block->code, tuple))
279.1880 +      {  ret = 1;
279.1881 +         goto done;
279.1882 +      }
279.1883 +      /* save reference to "backup" n-tuple, which was used to assign
279.1884 +         current values of the dummy indices (it is sufficient to save
279.1885 +         reference, not value, because that n-tuple is defined in some
279.1886 +         outer level of recursion and therefore cannot be changed on
279.1887 +         this and deeper recursive calls) */
279.1888 +      backup = block->backup;
279.1889 +      /* set up new "backup" n-tuple, which defines new values of the
279.1890 +         dummy indices */
279.1891 +      block->backup = tuple;
279.1892 +      /* assign new values to the dummy indices */
279.1893 +      update_dummy_indices(mpl, block);
279.1894 +      /* call the formal routine that does the rest part of the job */
279.1895 +      func(mpl, info);
279.1896 +      /* restore reference to the former "backup" n-tuple */
279.1897 +      block->backup = backup;
279.1898 +      /* restore former values of the dummy indices; note that if the
279.1899 +         domain block just escaped has no other active instances which
279.1900 +         may exist due to recursion (it is indicated by a null pointer
279.1901 +         to the former n-tuple), former values of the dummy indices are
279.1902 +         undefined; therefore in this case the routine keeps currently
279.1903 +         assigned values of the dummy indices that involves keeping all
279.1904 +         dependent temporary results and thereby, if this domain block
279.1905 +         is not used recursively, allows improving efficiency */
279.1906 +      update_dummy_indices(mpl, block);
279.1907 +done: return ret;
279.1908 +}
279.1909 +
279.1910 +/*----------------------------------------------------------------------
279.1911 +-- eval_within_domain - perform evaluation within domain scope.
279.1912 +--
279.1913 +-- This routine assigns new values (symbols) to all dummy indices of
279.1914 +-- specified domain and calls the formal routine func, which is used to
279.1915 +-- evaluate some code in the domain scope. Each free dummy index in the
279.1916 +-- domain is assigned a value specified in the corresponding component
279.1917 +-- of given n-tuple. Non-free dummy indices are assigned values, which
279.1918 +-- are computed by this routine.
279.1919 +--
279.1920 +-- Number of components in the given n-tuple must be the same as number
279.1921 +-- of free indices in the domain.
279.1922 +--
279.1923 +-- If the given n-tuple is not a member of the domain set, the routine
279.1924 +-- func is not called, and non-zero code is returned.
279.1925 +--
279.1926 +-- For the sake of convenience it is allowed to specify domain as NULL
279.1927 +-- (then n-tuple also must be 0-tuple, i.e. empty), in which case this
279.1928 +-- routine just calls the routine func and returns zero.
279.1929 +--
279.1930 +-- This routine allows recursive calls from the routine func providing
279.1931 +-- correct values of dummy indices for each instance.
279.1932 +--
279.1933 +-- NOTE: The n-tuple passed to this routine must not be changed by any
279.1934 +--       other routines called from the formal routine func until this
279.1935 +--       routine has returned. */
279.1936 +
279.1937 +struct eval_domain_info
279.1938 +{     /* working info used by the routine eval_within_domain */
279.1939 +      DOMAIN *domain;
279.1940 +      /* domain, which has to be entered */
279.1941 +      DOMAIN_BLOCK *block;
279.1942 +      /* domain block, which is currently processed */
279.1943 +      TUPLE *tuple;
279.1944 +      /* tail of original n-tuple, whose components have to be assigned
279.1945 +         to free dummy indices in the current domain block */
279.1946 +      void *info;
279.1947 +      /* transit pointer passed to the formal routine func */
279.1948 +      void (*func)(MPL *mpl, void *info);
279.1949 +      /* routine, which has to be executed in the domain scope */
279.1950 +      int failure;
279.1951 +      /* this flag indicates that given n-tuple is not a member of the
279.1952 +         domain set */
279.1953 +};
279.1954 +
279.1955 +static void eval_domain_func(MPL *mpl, void *_my_info)
279.1956 +{     /* this routine recursively enters into the domain scope and then
279.1957 +         calls the routine func */
279.1958 +      struct eval_domain_info *my_info = _my_info;
279.1959 +      if (my_info->block != NULL)
279.1960 +      {  /* the current domain block to be entered exists */
279.1961 +         DOMAIN_BLOCK *block;
279.1962 +         DOMAIN_SLOT *slot;
279.1963 +         TUPLE *tuple = NULL, *temp = NULL;
279.1964 +         /* save pointer to the current domain block */
279.1965 +         block = my_info->block;
279.1966 +         /* and get ready to enter the next block (if it exists) */
279.1967 +         my_info->block = block->next;
279.1968 +         /* construct temporary n-tuple, whose components correspond to
279.1969 +            dummy indices (slots) of the current domain; components of
279.1970 +            the temporary n-tuple that correspond to free dummy indices
279.1971 +            are assigned references (not values!) to symbols specified
279.1972 +            in the corresponding components of the given n-tuple, while
279.1973 +            other components that correspond to non-free dummy indices
279.1974 +            are assigned symbolic values computed here */
279.1975 +         for (slot = block->list; slot != NULL; slot = slot->next)
279.1976 +         {  /* create component that corresponds to the current slot */
279.1977 +            if (tuple == NULL)
279.1978 +               tuple = temp = dmp_get_atom(mpl->tuples, sizeof(TUPLE));
279.1979 +            else
279.1980 +temp = (temp->next = dmp_get_atom(mpl->tuples, sizeof(TUPLE)));
279.1981 +            if (slot->code == NULL)
279.1982 +            {  /* dummy index is free; take reference to symbol, which
279.1983 +                  is specified in the corresponding component of given
279.1984 +                  n-tuple */
279.1985 +               xassert(my_info->tuple != NULL);
279.1986 +               temp->sym = my_info->tuple->sym;
279.1987 +               xassert(temp->sym != NULL);
279.1988 +               my_info->tuple = my_info->tuple->next;
279.1989 +            }
279.1990 +            else
279.1991 +            {  /* dummy index is non-free; compute symbolic value to be
279.1992 +                  temporarily assigned to the dummy index */
279.1993 +               temp->sym = eval_symbolic(mpl, slot->code);
279.1994 +            }
279.1995 +         }
279.1996 +         temp->next = NULL;
279.1997 +         /* enter the current domain block */
279.1998 +         if (enter_domain_block(mpl, block, tuple, my_info,
279.1999 +               eval_domain_func)) my_info->failure = 1;
279.2000 +         /* delete temporary n-tuple as well as symbols that correspond
279.2001 +            to non-free dummy indices (they were computed here) */
279.2002 +         for (slot = block->list; slot != NULL; slot = slot->next)
279.2003 +         {  xassert(tuple != NULL);
279.2004 +            temp = tuple;
279.2005 +            tuple = tuple->next;
279.2006 +            if (slot->code != NULL)
279.2007 +            {  /* dummy index is non-free; delete symbolic value */
279.2008 +               delete_symbol(mpl, temp->sym);
279.2009 +            }
279.2010 +            /* delete component that corresponds to the current slot */
279.2011 +            dmp_free_atom(mpl->tuples, temp, sizeof(TUPLE));
279.2012 +         }
279.2013 +      }
279.2014 +      else
279.2015 +      {  /* there are no more domain blocks, i.e. we have reached the
279.2016 +            domain scope */
279.2017 +         xassert(my_info->tuple == NULL);
279.2018 +         /* check optional predicate specified for the domain */
279.2019 +         if (my_info->domain->code != NULL && !eval_logical(mpl,
279.2020 +            my_info->domain->code))
279.2021 +         {  /* the predicate is false */
279.2022 +            my_info->failure = 2;
279.2023 +         }
279.2024 +         else
279.2025 +         {  /* the predicate is true; do the job */
279.2026 +            my_info->func(mpl, my_info->info);
279.2027 +         }
279.2028 +      }
279.2029 +      return;
279.2030 +}
279.2031 +
279.2032 +int eval_within_domain
279.2033 +(     MPL *mpl,
279.2034 +      DOMAIN *domain,         /* not changed */
279.2035 +      TUPLE *tuple,           /* not changed */
279.2036 +      void *info, void (*func)(MPL *mpl, void *info)
279.2037 +)
279.2038 +{     /* this routine performs evaluation within domain scope */
279.2039 +      struct eval_domain_info _my_info, *my_info = &_my_info;
279.2040 +      if (domain == NULL)
279.2041 +      {  xassert(tuple == NULL);
279.2042 +         func(mpl, info);
279.2043 +         my_info->failure = 0;
279.2044 +      }
279.2045 +      else
279.2046 +      {  xassert(tuple != NULL);
279.2047 +         my_info->domain = domain;
279.2048 +         my_info->block = domain->list;
279.2049 +         my_info->tuple = tuple;
279.2050 +         my_info->info = info;
279.2051 +         my_info->func = func;
279.2052 +         my_info->failure = 0;
279.2053 +         /* enter the very first domain block */
279.2054 +         eval_domain_func(mpl, my_info);
279.2055 +      }
279.2056 +      return my_info->failure;
279.2057 +}
279.2058 +
279.2059 +/*----------------------------------------------------------------------
279.2060 +-- loop_within_domain - perform iterations within domain scope.
279.2061 +--
279.2062 +-- This routine iteratively assigns new values (symbols) to the dummy
279.2063 +-- indices of specified domain by enumerating all n-tuples, which are
279.2064 +-- members of the domain set, and for every n-tuple it calls the formal
279.2065 +-- routine func to evaluate some code within the domain scope.
279.2066 +--
279.2067 +-- If the routine func returns non-zero, enumeration within the domain
279.2068 +-- is prematurely terminated.
279.2069 +--
279.2070 +-- For the sake of convenience it is allowed to specify domain as NULL,
279.2071 +-- in which case this routine just calls the routine func only once and
279.2072 +-- returns zero.
279.2073 +--
279.2074 +-- This routine allows recursive calls from the routine func providing
279.2075 +-- correct values of dummy indices for each instance. */
279.2076 +
279.2077 +struct loop_domain_info
279.2078 +{     /* working info used by the routine loop_within_domain */
279.2079 +      DOMAIN *domain;
279.2080 +      /* domain, which has to be entered */
279.2081 +      DOMAIN_BLOCK *block;
279.2082 +      /* domain block, which is currently processed */
279.2083 +      int looping;
279.2084 +      /* clearing this flag leads to terminating enumeration */
279.2085 +      void *info;
279.2086 +      /* transit pointer passed to the formal routine func */
279.2087 +      int (*func)(MPL *mpl, void *info);
279.2088 +      /* routine, which needs to be executed in the domain scope */
279.2089 +};
279.2090 +
279.2091 +static void loop_domain_func(MPL *mpl, void *_my_info)
279.2092 +{     /* this routine enumerates all n-tuples in the basic set of the
279.2093 +         current domain block, enters recursively into the domain scope
279.2094 +         for every n-tuple, and then calls the routine func */
279.2095 +      struct loop_domain_info *my_info = _my_info;
279.2096 +      if (my_info->block != NULL)
279.2097 +      {  /* the current domain block to be entered exists */
279.2098 +         DOMAIN_BLOCK *block;
279.2099 +         DOMAIN_SLOT *slot;
279.2100 +         TUPLE *bound;
279.2101 +         /* save pointer to the current domain block */
279.2102 +         block = my_info->block;
279.2103 +         /* and get ready to enter the next block (if it exists) */
279.2104 +         my_info->block = block->next;
279.2105 +         /* compute symbolic values, at which non-free dummy indices of
279.2106 +            the current domain block are bound; since that values don't
279.2107 +            depend on free dummy indices of the current block, they can
279.2108 +            be computed once out of the enumeration loop */
279.2109 +         bound = create_tuple(mpl);
279.2110 +         for (slot = block->list; slot != NULL; slot = slot->next)
279.2111 +         {  if (slot->code != NULL)
279.2112 +               bound = expand_tuple(mpl, bound, eval_symbolic(mpl,
279.2113 +                  slot->code));
279.2114 +         }
279.2115 +         /* start enumeration */
279.2116 +         xassert(block->code != NULL);
279.2117 +         if (block->code->op == O_DOTS)
279.2118 +         {  /* the basic set is "arithmetic", in which case it doesn't
279.2119 +               need to be computed explicitly */
279.2120 +            TUPLE *tuple;
279.2121 +            int n, j;
279.2122 +            double t0, tf, dt;
279.2123 +            /* compute "parameters" of the basic set */
279.2124 +            t0 = eval_numeric(mpl, block->code->arg.arg.x);
279.2125 +            tf = eval_numeric(mpl, block->code->arg.arg.y);
279.2126 +            if (block->code->arg.arg.z == NULL)
279.2127 +               dt = 1.0;
279.2128 +            else
279.2129 +               dt = eval_numeric(mpl, block->code->arg.arg.z);
279.2130 +            /* determine cardinality of the basic set */
279.2131 +            n = arelset_size(mpl, t0, tf, dt);
279.2132 +            /* create dummy 1-tuple for members of the basic set */
279.2133 +            tuple = expand_tuple(mpl, create_tuple(mpl),
279.2134 +               create_symbol_num(mpl, 0.0));
279.2135 +            /* in case of "arithmetic" set there is exactly one dummy
279.2136 +               index, which cannot be non-free */
279.2137 +            xassert(bound == NULL);
279.2138 +            /* walk through 1-tuples of the basic set */
279.2139 +            for (j = 1; j <= n && my_info->looping; j++)
279.2140 +            {  /* construct dummy 1-tuple for the current member */
279.2141 +               tuple->sym->num = arelset_member(mpl, t0, tf, dt, j);
279.2142 +               /* enter the current domain block */
279.2143 +               enter_domain_block(mpl, block, tuple, my_info,
279.2144 +                  loop_domain_func);
279.2145 +            }
279.2146 +            /* delete dummy 1-tuple */
279.2147 +            delete_tuple(mpl, tuple);
279.2148 +         }
279.2149 +         else
279.2150 +         {  /* the basic set is of general kind, in which case it needs
279.2151 +               to be explicitly computed */
279.2152 +            ELEMSET *set;
279.2153 +            MEMBER *memb;
279.2154 +            TUPLE *temp1, *temp2;
279.2155 +            /* compute the basic set */
279.2156 +            set = eval_elemset(mpl, block->code);
279.2157 +            /* walk through all n-tuples of the basic set */
279.2158 +            for (memb = set->head; memb != NULL && my_info->looping;
279.2159 +               memb = memb->next)
279.2160 +            {  /* all components of the current n-tuple that correspond
279.2161 +                  to non-free dummy indices must be feasible; otherwise
279.2162 +                  the n-tuple is not in the basic set */
279.2163 +               temp1 = memb->tuple;
279.2164 +               temp2 = bound;
279.2165 +               for (slot = block->list; slot != NULL; slot = slot->next)
279.2166 +               {  xassert(temp1 != NULL);
279.2167 +                  if (slot->code != NULL)
279.2168 +                  {  /* non-free dummy index */
279.2169 +                     xassert(temp2 != NULL);
279.2170 +                     if (compare_symbols(mpl, temp1->sym, temp2->sym)
279.2171 +                        != 0)
279.2172 +                     {  /* the n-tuple is not in the basic set */
279.2173 +                        goto skip;
279.2174 +                     }
279.2175 +                     temp2 = temp2->next;
279.2176 +                  }
279.2177 +                  temp1 = temp1->next;
279.2178 +               }
279.2179 +               xassert(temp1 == NULL);
279.2180 +               xassert(temp2 == NULL);
279.2181 +               /* enter the current domain block */
279.2182 +               enter_domain_block(mpl, block, memb->tuple, my_info,
279.2183 +                  loop_domain_func);
279.2184 +skip:          ;
279.2185 +            }
279.2186 +            /* delete the basic set */
279.2187 +            delete_elemset(mpl, set);
279.2188 +         }
279.2189 +         /* delete symbolic values binding non-free dummy indices */
279.2190 +         delete_tuple(mpl, bound);
279.2191 +         /* restore pointer to the current domain block */
279.2192 +         my_info->block = block;
279.2193 +      }
279.2194 +      else
279.2195 +      {  /* there are no more domain blocks, i.e. we have reached the
279.2196 +            domain scope */
279.2197 +         /* check optional predicate specified for the domain */
279.2198 +         if (my_info->domain->code != NULL && !eval_logical(mpl,
279.2199 +            my_info->domain->code))
279.2200 +         {  /* the predicate is false */
279.2201 +            /* nop */;
279.2202 +         }
279.2203 +         else
279.2204 +         {  /* the predicate is true; do the job */
279.2205 +            my_info->looping = !my_info->func(mpl, my_info->info);
279.2206 +         }
279.2207 +      }
279.2208 +      return;
279.2209 +}
279.2210 +
279.2211 +void loop_within_domain
279.2212 +(     MPL *mpl,
279.2213 +      DOMAIN *domain,         /* not changed */
279.2214 +      void *info, int (*func)(MPL *mpl, void *info)
279.2215 +)
279.2216 +{     /* this routine performs iterations within domain scope */
279.2217 +      struct loop_domain_info _my_info, *my_info = &_my_info;
279.2218 +      if (domain == NULL)
279.2219 +         func(mpl, info);
279.2220 +      else
279.2221 +      {  my_info->domain = domain;
279.2222 +         my_info->block = domain->list;
279.2223 +         my_info->looping = 1;
279.2224 +         my_info->info = info;
279.2225 +         my_info->func = func;
279.2226 +         /* enter the very first domain block */
279.2227 +         loop_domain_func(mpl, my_info);
279.2228 +      }
279.2229 +      return;
279.2230 +}
279.2231 +
279.2232 +/*----------------------------------------------------------------------
279.2233 +-- out_of_domain - raise domain exception.
279.2234 +--
279.2235 +-- This routine is called when a reference is made to a member of some
279.2236 +-- model object, but its n-tuple is out of the object domain. */
279.2237 +
279.2238 +void out_of_domain
279.2239 +(     MPL *mpl,
279.2240 +      char *name,             /* not changed */
279.2241 +      TUPLE *tuple            /* not changed */
279.2242 +)
279.2243 +{     xassert(name != NULL);
279.2244 +      xassert(tuple != NULL);
279.2245 +      error(mpl, "%s%s out of domain", name, format_tuple(mpl, '[',
279.2246 +         tuple));
279.2247 +      /* no return */
279.2248 +}
279.2249 +
279.2250 +/*----------------------------------------------------------------------
279.2251 +-- get_domain_tuple - obtain current n-tuple from domain.
279.2252 +--
279.2253 +-- This routine constructs n-tuple, whose components are current values
279.2254 +-- assigned to *free* dummy indices of specified domain.
279.2255 +--
279.2256 +-- For the sake of convenience it is allowed to specify domain as NULL,
279.2257 +-- in which case this routine returns 0-tuple.
279.2258 +--
279.2259 +-- NOTE: This routine must not be called out of domain scope. */
279.2260 +
279.2261 +TUPLE *get_domain_tuple
279.2262 +(     MPL *mpl,
279.2263 +      DOMAIN *domain          /* not changed */
279.2264 +)
279.2265 +{     DOMAIN_BLOCK *block;
279.2266 +      DOMAIN_SLOT *slot;
279.2267 +      TUPLE *tuple;
279.2268 +      tuple = create_tuple(mpl);
279.2269 +      if (domain != NULL)
279.2270 +      {  for (block = domain->list; block != NULL; block = block->next)
279.2271 +         {  for (slot = block->list; slot != NULL; slot = slot->next)
279.2272 +            {  if (slot->code == NULL)
279.2273 +               {  xassert(slot->value != NULL);
279.2274 +                  tuple = expand_tuple(mpl, tuple, copy_symbol(mpl,
279.2275 +                     slot->value));
279.2276 +               }
279.2277 +            }
279.2278 +         }
279.2279 +      }
279.2280 +      return tuple;
279.2281 +}
279.2282 +
279.2283 +/*----------------------------------------------------------------------
279.2284 +-- clean_domain - clean domain.
279.2285 +--
279.2286 +-- This routine cleans specified domain that assumes deleting all stuff
279.2287 +-- dynamically allocated during the generation phase. */
279.2288 +
279.2289 +void clean_domain(MPL *mpl, DOMAIN *domain)
279.2290 +{     DOMAIN_BLOCK *block;
279.2291 +      DOMAIN_SLOT *slot;
279.2292 +      /* if no domain is specified, do nothing */
279.2293 +      if (domain == NULL) goto done;
279.2294 +      /* clean all domain blocks */
279.2295 +      for (block = domain->list; block != NULL; block = block->next)
279.2296 +      {  /* clean all domain slots */
279.2297 +         for (slot = block->list; slot != NULL; slot = slot->next)
279.2298 +         {  /* clean pseudo-code for computing bound value */
279.2299 +            clean_code(mpl, slot->code);
279.2300 +            /* delete symbolic value assigned to dummy index */
279.2301 +            if (slot->value != NULL)
279.2302 +               delete_symbol(mpl, slot->value), slot->value = NULL;
279.2303 +         }
279.2304 +         /* clean pseudo-code for computing basic set */
279.2305 +         clean_code(mpl, block->code);
279.2306 +      }
279.2307 +      /* clean pseudo-code for computing domain predicate */
279.2308 +      clean_code(mpl, domain->code);
279.2309 +done: return;
279.2310 +}
279.2311 +
279.2312 +/**********************************************************************/
279.2313 +/* * *                         MODEL SETS                         * * */
279.2314 +/**********************************************************************/
279.2315 +
279.2316 +/*----------------------------------------------------------------------
279.2317 +-- check_elem_set - check elemental set assigned to set member.
279.2318 +--
279.2319 +-- This routine checks if given elemental set being assigned to member
279.2320 +-- of specified model set satisfies to all restrictions.
279.2321 +--
279.2322 +-- NOTE: This routine must not be called out of domain scope. */
279.2323 +
279.2324 +void check_elem_set
279.2325 +(     MPL *mpl,
279.2326 +      SET *set,               /* not changed */
279.2327 +      TUPLE *tuple,           /* not changed */
279.2328 +      ELEMSET *refer          /* not changed */
279.2329 +)
279.2330 +{     WITHIN *within;
279.2331 +      MEMBER *memb;
279.2332 +      int eqno;
279.2333 +      /* elemental set must be within all specified supersets */
279.2334 +      for (within = set->within, eqno = 1; within != NULL; within =
279.2335 +         within->next, eqno++)
279.2336 +      {  xassert(within->code != NULL);
279.2337 +         for (memb = refer->head; memb != NULL; memb = memb->next)
279.2338 +         {  if (!is_member(mpl, within->code, memb->tuple))
279.2339 +            {  char buf[255+1];
279.2340 +               strcpy(buf, format_tuple(mpl, '(', memb->tuple));
279.2341 +               xassert(strlen(buf) < sizeof(buf));
279.2342 +               error(mpl, "%s%s contains %s which not within specified "
279.2343 +                  "set; see (%d)", set->name, format_tuple(mpl, '[',
279.2344 +                     tuple), buf, eqno);
279.2345 +            }
279.2346 +         }
279.2347 +      }
279.2348 +      return;
279.2349 +}
279.2350 +
279.2351 +/*----------------------------------------------------------------------
279.2352 +-- take_member_set - obtain elemental set assigned to set member.
279.2353 +--
279.2354 +-- This routine obtains a reference to elemental set assigned to given
279.2355 +-- member of specified model set and returns it on exit.
279.2356 +--
279.2357 +-- NOTE: This routine must not be called out of domain scope. */
279.2358 +
279.2359 +ELEMSET *take_member_set      /* returns reference, not value */
279.2360 +(     MPL *mpl,
279.2361 +      SET *set,               /* not changed */
279.2362 +      TUPLE *tuple            /* not changed */
279.2363 +)
279.2364 +{     MEMBER *memb;
279.2365 +      ELEMSET *refer;
279.2366 +      /* find member in the set array */
279.2367 +      memb = find_member(mpl, set->array, tuple);
279.2368 +      if (memb != NULL)
279.2369 +      {  /* member exists, so just take the reference */
279.2370 +         refer = memb->value.set;
279.2371 +      }
279.2372 +      else if (set->assign != NULL)
279.2373 +      {  /* compute value using assignment expression */
279.2374 +         refer = eval_elemset(mpl, set->assign);
279.2375 +add:     /* check that the elemental set satisfies to all restrictions,
279.2376 +            assign it to new member, and add the member to the array */
279.2377 +         check_elem_set(mpl, set, tuple, refer);
279.2378 +         memb = add_member(mpl, set->array, copy_tuple(mpl, tuple));
279.2379 +         memb->value.set = refer;
279.2380 +      }
279.2381 +      else if (set->option != NULL)
279.2382 +      {  /* compute default elemental set */
279.2383 +         refer = eval_elemset(mpl, set->option);
279.2384 +         goto add;
279.2385 +      }
279.2386 +      else
279.2387 +      {  /* no value (elemental set) is provided */
279.2388 +         error(mpl, "no value for %s%s", set->name, format_tuple(mpl,
279.2389 +            '[', tuple));
279.2390 +      }
279.2391 +      return refer;
279.2392 +}
279.2393 +
279.2394 +/*----------------------------------------------------------------------
279.2395 +-- eval_member_set - evaluate elemental set assigned to set member.
279.2396 +--
279.2397 +-- This routine evaluates a reference to elemental set assigned to given
279.2398 +-- member of specified model set and returns it on exit. */
279.2399 +
279.2400 +struct eval_set_info
279.2401 +{     /* working info used by the routine eval_member_set */
279.2402 +      SET *set;
279.2403 +      /* model set */
279.2404 +      TUPLE *tuple;
279.2405 +      /* n-tuple, which defines set member */
279.2406 +      MEMBER *memb;
279.2407 +      /* normally this pointer is NULL; the routine uses this pointer
279.2408 +         to check data provided in the data section, in which case it
279.2409 +         points to a member currently checked; this check is performed
279.2410 +         automatically only once when a reference to any member occurs
279.2411 +         for the first time */
279.2412 +      ELEMSET *refer;
279.2413 +      /* evaluated reference to elemental set */
279.2414 +};
279.2415 +
279.2416 +static void eval_set_func(MPL *mpl, void *_info)
279.2417 +{     /* this is auxiliary routine to work within domain scope */
279.2418 +      struct eval_set_info *info = _info;
279.2419 +      if (info->memb != NULL)
279.2420 +      {  /* checking call; check elemental set being assigned */
279.2421 +         check_elem_set(mpl, info->set, info->memb->tuple,
279.2422 +            info->memb->value.set);
279.2423 +      }
279.2424 +      else
279.2425 +      {  /* normal call; evaluate member, which has given n-tuple */
279.2426 +         info->refer = take_member_set(mpl, info->set, info->tuple);
279.2427 +      }
279.2428 +      return;
279.2429 +}
279.2430 +
279.2431 +#if 1 /* 12/XII-2008 */
279.2432 +static void saturate_set(MPL *mpl, SET *set)
279.2433 +{     GADGET *gadget = set->gadget;
279.2434 +      ELEMSET *data;
279.2435 +      MEMBER *elem, *memb;
279.2436 +      TUPLE *tuple, *work[20];
279.2437 +      int i;
279.2438 +      xprintf("Generating %s...\n", set->name);
279.2439 +      eval_whole_set(mpl, gadget->set);
279.2440 +      /* gadget set must have exactly one member */
279.2441 +      xassert(gadget->set->array != NULL);
279.2442 +      xassert(gadget->set->array->head != NULL);
279.2443 +      xassert(gadget->set->array->head == gadget->set->array->tail);
279.2444 +      data = gadget->set->array->head->value.set;
279.2445 +      xassert(data->type == A_NONE);
279.2446 +      xassert(data->dim == gadget->set->dimen);
279.2447 +      /* walk thru all elements of the plain set */
279.2448 +      for (elem = data->head; elem != NULL; elem = elem->next)
279.2449 +      {  /* create a copy of n-tuple */
279.2450 +         tuple = copy_tuple(mpl, elem->tuple);
279.2451 +         /* rearrange component of the n-tuple */
279.2452 +         for (i = 0; i < gadget->set->dimen; i++)
279.2453 +            work[i] = NULL;
279.2454 +         for (i = 0; tuple != NULL; tuple = tuple->next)
279.2455 +            work[gadget->ind[i++]-1] = tuple;
279.2456 +         xassert(i == gadget->set->dimen);
279.2457 +         for (i = 0; i < gadget->set->dimen; i++)
279.2458 +         {  xassert(work[i] != NULL);
279.2459 +            work[i]->next = work[i+1];
279.2460 +         }
279.2461 +         /* construct subscript list from first set->dim components */
279.2462 +         if (set->dim == 0)
279.2463 +            tuple = NULL;
279.2464 +         else
279.2465 +            tuple = work[0], work[set->dim-1]->next = NULL;
279.2466 +         /* find corresponding member of the set to be initialized */
279.2467 +         memb = find_member(mpl, set->array, tuple);
279.2468 +         if (memb == NULL)
279.2469 +         {  /* not found; add new member to the set and assign it empty
279.2470 +               elemental set */
279.2471 +            memb = add_member(mpl, set->array, tuple);
279.2472 +            memb->value.set = create_elemset(mpl, set->dimen);
279.2473 +         }
279.2474 +         else
279.2475 +         {  /* found; free subscript list */
279.2476 +            delete_tuple(mpl, tuple);
279.2477 +         }
279.2478 +         /* construct new n-tuple from rest set->dimen components */
279.2479 +         tuple = work[set->dim];
279.2480 +         xassert(set->dim + set->dimen == gadget->set->dimen);
279.2481 +         work[gadget->set->dimen-1]->next = NULL;
279.2482 +         /* and add it to the elemental set assigned to the member
279.2483 +            (no check for duplicates is needed) */
279.2484 +         add_tuple(mpl, memb->value.set, tuple);
279.2485 +      }
279.2486 +      /* the set has been saturated with data */
279.2487 +      set->data = 1;
279.2488 +      return;
279.2489 +}
279.2490 +#endif
279.2491 +
279.2492 +ELEMSET *eval_member_set      /* returns reference, not value */
279.2493 +(     MPL *mpl,
279.2494 +      SET *set,               /* not changed */
279.2495 +      TUPLE *tuple            /* not changed */
279.2496 +)
279.2497 +{     /* this routine evaluates set member */
279.2498 +      struct eval_set_info _info, *info = &_info;
279.2499 +      xassert(set->dim == tuple_dimen(mpl, tuple));
279.2500 +      info->set = set;
279.2501 +      info->tuple = tuple;
279.2502 +#if 1 /* 12/XII-2008 */
279.2503 +      if (set->gadget != NULL && set->data == 0)
279.2504 +      {  /* initialize the set with data from a plain set */
279.2505 +         saturate_set(mpl, set);
279.2506 +      }
279.2507 +#endif
279.2508 +      if (set->data == 1)
279.2509 +      {  /* check data, which are provided in the data section, but not
279.2510 +            checked yet */
279.2511 +         /* save pointer to the last array member; note that during the
279.2512 +            check new members may be added beyond the last member due to
279.2513 +            references to the same parameter from default expression as
279.2514 +            well as from expressions that define restricting supersets;
279.2515 +            however, values assigned to the new members will be checked
279.2516 +            by other routine, so we don't need to check them here */
279.2517 +         MEMBER *tail = set->array->tail;
279.2518 +         /* change the data status to prevent infinite recursive loop
279.2519 +            due to references to the same set during the check */
279.2520 +         set->data = 2;
279.2521 +         /* check elemental sets assigned to array members in the data
279.2522 +            section until the marked member has been reached */
279.2523 +         for (info->memb = set->array->head; info->memb != NULL;
279.2524 +            info->memb = info->memb->next)
279.2525 +         {  if (eval_within_domain(mpl, set->domain, info->memb->tuple,
279.2526 +               info, eval_set_func))
279.2527 +               out_of_domain(mpl, set->name, info->memb->tuple);
279.2528 +            if (info->memb == tail) break;
279.2529 +         }
279.2530 +         /* the check has been finished */
279.2531 +      }
279.2532 +      /* evaluate member, which has given n-tuple */
279.2533 +      info->memb = NULL;
279.2534 +      if (eval_within_domain(mpl, info->set->domain, info->tuple, info,
279.2535 +         eval_set_func))
279.2536 +      out_of_domain(mpl, set->name, info->tuple);
279.2537 +      /* bring evaluated reference to the calling program */
279.2538 +      return info->refer;
279.2539 +}
279.2540 +
279.2541 +/*----------------------------------------------------------------------
279.2542 +-- eval_whole_set - evaluate model set over entire domain.
279.2543 +--
279.2544 +-- This routine evaluates all members of specified model set over entire
279.2545 +-- domain. */
279.2546 +
279.2547 +static int whole_set_func(MPL *mpl, void *info)
279.2548 +{     /* this is auxiliary routine to work within domain scope */
279.2549 +      SET *set = (SET *)info;
279.2550 +      TUPLE *tuple = get_domain_tuple(mpl, set->domain);
279.2551 +      eval_member_set(mpl, set, tuple);
279.2552 +      delete_tuple(mpl, tuple);
279.2553 +      return 0;
279.2554 +}
279.2555 +
279.2556 +void eval_whole_set(MPL *mpl, SET *set)
279.2557 +{     loop_within_domain(mpl, set->domain, set, whole_set_func);
279.2558 +      return;
279.2559 +}
279.2560 +
279.2561 +/*----------------------------------------------------------------------
279.2562 +-- clean set - clean model set.
279.2563 +--
279.2564 +-- This routine cleans specified model set that assumes deleting all
279.2565 +-- stuff dynamically allocated during the generation phase. */
279.2566 +
279.2567 +void clean_set(MPL *mpl, SET *set)
279.2568 +{     WITHIN *within;
279.2569 +      MEMBER *memb;
279.2570 +      /* clean subscript domain */
279.2571 +      clean_domain(mpl, set->domain);
279.2572 +      /* clean pseudo-code for computing supersets */
279.2573 +      for (within = set->within; within != NULL; within = within->next)
279.2574 +         clean_code(mpl, within->code);
279.2575 +      /* clean pseudo-code for computing assigned value */
279.2576 +      clean_code(mpl, set->assign);
279.2577 +      /* clean pseudo-code for computing default value */
279.2578 +      clean_code(mpl, set->option);
279.2579 +      /* reset data status flag */
279.2580 +      set->data = 0;
279.2581 +      /* delete content array */
279.2582 +      for (memb = set->array->head; memb != NULL; memb = memb->next)
279.2583 +         delete_value(mpl, set->array->type, &memb->value);
279.2584 +      delete_array(mpl, set->array), set->array = NULL;
279.2585 +      return;
279.2586 +}
279.2587 +
279.2588 +/**********************************************************************/
279.2589 +/* * *                      MODEL PARAMETERS                      * * */
279.2590 +/**********************************************************************/
279.2591 +
279.2592 +/*----------------------------------------------------------------------
279.2593 +-- check_value_num - check numeric value assigned to parameter member.
279.2594 +--
279.2595 +-- This routine checks if numeric value being assigned to some member
279.2596 +-- of specified numeric model parameter satisfies to all restrictions.
279.2597 +--
279.2598 +-- NOTE: This routine must not be called out of domain scope. */
279.2599 +
279.2600 +void check_value_num
279.2601 +(     MPL *mpl,
279.2602 +      PARAMETER *par,         /* not changed */
279.2603 +      TUPLE *tuple,           /* not changed */
279.2604 +      double value
279.2605 +)
279.2606 +{     CONDITION *cond;
279.2607 +      WITHIN *in;
279.2608 +      int eqno;
279.2609 +      /* the value must satisfy to the parameter type */
279.2610 +      switch (par->type)
279.2611 +      {  case A_NUMERIC:
279.2612 +            break;
279.2613 +         case A_INTEGER:
279.2614 +            if (value != floor(value))
279.2615 +               error(mpl, "%s%s = %.*g not integer", par->name,
279.2616 +                  format_tuple(mpl, '[', tuple), DBL_DIG, value);
279.2617 +            break;
279.2618 +         case A_BINARY:
279.2619 +            if (!(value == 0.0 || value == 1.0))
279.2620 +               error(mpl, "%s%s = %.*g not binary", par->name,
279.2621 +                  format_tuple(mpl, '[', tuple), DBL_DIG, value);
279.2622 +            break;
279.2623 +         default:
279.2624 +            xassert(par != par);
279.2625 +      }
279.2626 +      /* the value must satisfy to all specified conditions */
279.2627 +      for (cond = par->cond, eqno = 1; cond != NULL; cond = cond->next,
279.2628 +         eqno++)
279.2629 +      {  double bound;
279.2630 +         char *rho;
279.2631 +         xassert(cond->code != NULL);
279.2632 +         bound = eval_numeric(mpl, cond->code);
279.2633 +         switch (cond->rho)
279.2634 +         {  case O_LT:
279.2635 +               if (!(value < bound))
279.2636 +               {  rho = "<";
279.2637 +err:              error(mpl, "%s%s = %.*g not %s %.*g; see (%d)",
279.2638 +                     par->name, format_tuple(mpl, '[', tuple), DBL_DIG,
279.2639 +                     value, rho, DBL_DIG, bound, eqno);
279.2640 +               }
279.2641 +               break;
279.2642 +            case O_LE:
279.2643 +               if (!(value <= bound)) { rho = "<="; goto err; }
279.2644 +               break;
279.2645 +            case O_EQ:
279.2646 +               if (!(value == bound)) { rho = "="; goto err; }
279.2647 +               break;
279.2648 +            case O_GE:
279.2649 +               if (!(value >= bound)) { rho = ">="; goto err; }
279.2650 +               break;
279.2651 +            case O_GT:
279.2652 +               if (!(value > bound)) { rho = ">"; goto err; }
279.2653 +               break;
279.2654 +            case O_NE:
279.2655 +               if (!(value != bound)) { rho = "<>"; goto err; }
279.2656 +               break;
279.2657 +            default:
279.2658 +               xassert(cond != cond);
279.2659 +         }
279.2660 +      }
279.2661 +      /* the value must be in all specified supersets */
279.2662 +      for (in = par->in, eqno = 1; in != NULL; in = in->next, eqno++)
279.2663 +      {  TUPLE *dummy;
279.2664 +         xassert(in->code != NULL);
279.2665 +         xassert(in->code->dim == 1);
279.2666 +         dummy = expand_tuple(mpl, create_tuple(mpl),
279.2667 +            create_symbol_num(mpl, value));
279.2668 +         if (!is_member(mpl, in->code, dummy))
279.2669 +            error(mpl, "%s%s = %.*g not in specified set; see (%d)",
279.2670 +               par->name, format_tuple(mpl, '[', tuple), DBL_DIG,
279.2671 +               value, eqno);
279.2672 +         delete_tuple(mpl, dummy);
279.2673 +      }
279.2674 +      return;
279.2675 +}
279.2676 +
279.2677 +/*----------------------------------------------------------------------
279.2678 +-- take_member_num - obtain num. value assigned to parameter member.
279.2679 +--
279.2680 +-- This routine obtains a numeric value assigned to member of specified
279.2681 +-- numeric model parameter and returns it on exit.
279.2682 +--
279.2683 +-- NOTE: This routine must not be called out of domain scope. */
279.2684 +
279.2685 +double take_member_num
279.2686 +(     MPL *mpl,
279.2687 +      PARAMETER *par,         /* not changed */
279.2688 +      TUPLE *tuple            /* not changed */
279.2689 +)
279.2690 +{     MEMBER *memb;
279.2691 +      double value;
279.2692 +      /* find member in the parameter array */
279.2693 +      memb = find_member(mpl, par->array, tuple);
279.2694 +      if (memb != NULL)
279.2695 +      {  /* member exists, so just take its value */
279.2696 +         value = memb->value.num;
279.2697 +      }
279.2698 +      else if (par->assign != NULL)
279.2699 +      {  /* compute value using assignment expression */
279.2700 +         value = eval_numeric(mpl, par->assign);
279.2701 +add:     /* check that the value satisfies to all restrictions, assign
279.2702 +            it to new member, and add the member to the array */
279.2703 +         check_value_num(mpl, par, tuple, value);
279.2704 +         memb = add_member(mpl, par->array, copy_tuple(mpl, tuple));
279.2705 +         memb->value.num = value;
279.2706 +      }
279.2707 +      else if (par->option != NULL)
279.2708 +      {  /* compute default value */
279.2709 +         value = eval_numeric(mpl, par->option);
279.2710 +         goto add;
279.2711 +      }
279.2712 +      else if (par->defval != NULL)
279.2713 +      {  /* take default value provided in the data section */
279.2714 +         if (par->defval->str != NULL)
279.2715 +            error(mpl, "cannot convert %s to floating-point number",
279.2716 +               format_symbol(mpl, par->defval));
279.2717 +         value = par->defval->num;
279.2718 +         goto add;
279.2719 +      }
279.2720 +      else
279.2721 +      {  /* no value is provided */
279.2722 +         error(mpl, "no value for %s%s", par->name, format_tuple(mpl,
279.2723 +            '[', tuple));
279.2724 +      }
279.2725 +      return value;
279.2726 +}
279.2727 +
279.2728 +/*----------------------------------------------------------------------
279.2729 +-- eval_member_num - evaluate num. value assigned to parameter member.
279.2730 +--
279.2731 +-- This routine evaluates a numeric value assigned to given member of
279.2732 +-- specified numeric model parameter and returns it on exit. */
279.2733 +
279.2734 +struct eval_num_info
279.2735 +{     /* working info used by the routine eval_member_num */
279.2736 +      PARAMETER *par;
279.2737 +      /* model parameter  */
279.2738 +      TUPLE *tuple;
279.2739 +      /* n-tuple, which defines parameter member */
279.2740 +      MEMBER *memb;
279.2741 +      /* normally this pointer is NULL; the routine uses this pointer
279.2742 +         to check data provided in the data section, in which case it
279.2743 +         points to a member currently checked; this check is performed
279.2744 +         automatically only once when a reference to any member occurs
279.2745 +         for the first time */
279.2746 +      double value;
279.2747 +      /* evaluated numeric value */
279.2748 +};
279.2749 +
279.2750 +static void eval_num_func(MPL *mpl, void *_info)
279.2751 +{     /* this is auxiliary routine to work within domain scope */
279.2752 +      struct eval_num_info *info = _info;
279.2753 +      if (info->memb != NULL)
279.2754 +      {  /* checking call; check numeric value being assigned */
279.2755 +         check_value_num(mpl, info->par, info->memb->tuple,
279.2756 +            info->memb->value.num);
279.2757 +      }
279.2758 +      else
279.2759 +      {  /* normal call; evaluate member, which has given n-tuple */
279.2760 +         info->value = take_member_num(mpl, info->par, info->tuple);
279.2761 +      }
279.2762 +      return;
279.2763 +}
279.2764 +
279.2765 +double eval_member_num
279.2766 +(     MPL *mpl,
279.2767 +      PARAMETER *par,         /* not changed */
279.2768 +      TUPLE *tuple            /* not changed */
279.2769 +)
279.2770 +{     /* this routine evaluates numeric parameter member */
279.2771 +      struct eval_num_info _info, *info = &_info;
279.2772 +      xassert(par->type == A_NUMERIC || par->type == A_INTEGER ||
279.2773 +             par->type == A_BINARY);
279.2774 +      xassert(par->dim == tuple_dimen(mpl, tuple));
279.2775 +      info->par = par;
279.2776 +      info->tuple = tuple;
279.2777 +      if (par->data == 1)
279.2778 +      {  /* check data, which are provided in the data section, but not
279.2779 +            checked yet */
279.2780 +         /* save pointer to the last array member; note that during the
279.2781 +            check new members may be added beyond the last member due to
279.2782 +            references to the same parameter from default expression as
279.2783 +            well as from expressions that define restricting conditions;
279.2784 +            however, values assigned to the new members will be checked
279.2785 +            by other routine, so we don't need to check them here */
279.2786 +         MEMBER *tail = par->array->tail;
279.2787 +         /* change the data status to prevent infinite recursive loop
279.2788 +            due to references to the same parameter during the check */
279.2789 +         par->data = 2;
279.2790 +         /* check values assigned to array members in the data section
279.2791 +            until the marked member has been reached */
279.2792 +         for (info->memb = par->array->head; info->memb != NULL;
279.2793 +            info->memb = info->memb->next)
279.2794 +         {  if (eval_within_domain(mpl, par->domain, info->memb->tuple,
279.2795 +               info, eval_num_func))
279.2796 +               out_of_domain(mpl, par->name, info->memb->tuple);
279.2797 +            if (info->memb == tail) break;
279.2798 +         }
279.2799 +         /* the check has been finished */
279.2800 +      }
279.2801 +      /* evaluate member, which has given n-tuple */
279.2802 +      info->memb = NULL;
279.2803 +      if (eval_within_domain(mpl, info->par->domain, info->tuple, info,
279.2804 +         eval_num_func))
279.2805 +         out_of_domain(mpl, par->name, info->tuple);
279.2806 +      /* bring evaluated value to the calling program */
279.2807 +      return info->value;
279.2808 +}
279.2809 +
279.2810 +/*----------------------------------------------------------------------
279.2811 +-- check_value_sym - check symbolic value assigned to parameter member.
279.2812 +--
279.2813 +-- This routine checks if symbolic value being assigned to some member
279.2814 +-- of specified symbolic model parameter satisfies to all restrictions.
279.2815 +--
279.2816 +-- NOTE: This routine must not be called out of domain scope. */
279.2817 +
279.2818 +void check_value_sym
279.2819 +(     MPL *mpl,
279.2820 +      PARAMETER *par,         /* not changed */
279.2821 +      TUPLE *tuple,           /* not changed */
279.2822 +      SYMBOL *value           /* not changed */
279.2823 +)
279.2824 +{     CONDITION *cond;
279.2825 +      WITHIN *in;
279.2826 +      int eqno;
279.2827 +      /* the value must satisfy to all specified conditions */
279.2828 +      for (cond = par->cond, eqno = 1; cond != NULL; cond = cond->next,
279.2829 +         eqno++)
279.2830 +      {  SYMBOL *bound;
279.2831 +         char buf[255+1];
279.2832 +         xassert(cond->code != NULL);
279.2833 +         bound = eval_symbolic(mpl, cond->code);
279.2834 +         switch (cond->rho)
279.2835 +         {
279.2836 +#if 1 /* 13/VIII-2008 */
279.2837 +            case O_LT:
279.2838 +               if (!(compare_symbols(mpl, value, bound) < 0))
279.2839 +               {  strcpy(buf, format_symbol(mpl, bound));
279.2840 +                  xassert(strlen(buf) < sizeof(buf));
279.2841 +                  error(mpl, "%s%s = %s not < %s",
279.2842 +                     par->name, format_tuple(mpl, '[', tuple),
279.2843 +                     format_symbol(mpl, value), buf, eqno);
279.2844 +               }
279.2845 +               break;
279.2846 +            case O_LE:
279.2847 +               if (!(compare_symbols(mpl, value, bound) <= 0))
279.2848 +               {  strcpy(buf, format_symbol(mpl, bound));
279.2849 +                  xassert(strlen(buf) < sizeof(buf));
279.2850 +                  error(mpl, "%s%s = %s not <= %s",
279.2851 +                     par->name, format_tuple(mpl, '[', tuple),
279.2852 +                     format_symbol(mpl, value), buf, eqno);
279.2853 +               }
279.2854 +               break;
279.2855 +#endif
279.2856 +            case O_EQ:
279.2857 +               if (!(compare_symbols(mpl, value, bound) == 0))
279.2858 +               {  strcpy(buf, format_symbol(mpl, bound));
279.2859 +                  xassert(strlen(buf) < sizeof(buf));
279.2860 +                  error(mpl, "%s%s = %s not = %s",
279.2861 +                     par->name, format_tuple(mpl, '[', tuple),
279.2862 +                     format_symbol(mpl, value), buf, eqno);
279.2863 +               }
279.2864 +               break;
279.2865 +#if 1 /* 13/VIII-2008 */
279.2866 +            case O_GE:
279.2867 +               if (!(compare_symbols(mpl, value, bound) >= 0))
279.2868 +               {  strcpy(buf, format_symbol(mpl, bound));
279.2869 +                  xassert(strlen(buf) < sizeof(buf));
279.2870 +                  error(mpl, "%s%s = %s not >= %s",
279.2871 +                     par->name, format_tuple(mpl, '[', tuple),
279.2872 +                     format_symbol(mpl, value), buf, eqno);
279.2873 +               }
279.2874 +               break;
279.2875 +            case O_GT:
279.2876 +               if (!(compare_symbols(mpl, value, bound) > 0))
279.2877 +               {  strcpy(buf, format_symbol(mpl, bound));
279.2878 +                  xassert(strlen(buf) < sizeof(buf));
279.2879 +                  error(mpl, "%s%s = %s not > %s",
279.2880 +                     par->name, format_tuple(mpl, '[', tuple),
279.2881 +                     format_symbol(mpl, value), buf, eqno);
279.2882 +               }
279.2883 +               break;
279.2884 +#endif
279.2885 +            case O_NE:
279.2886 +               if (!(compare_symbols(mpl, value, bound) != 0))
279.2887 +               {  strcpy(buf, format_symbol(mpl, bound));
279.2888 +                  xassert(strlen(buf) < sizeof(buf));
279.2889 +                  error(mpl, "%s%s = %s not <> %s",
279.2890 +                     par->name, format_tuple(mpl, '[', tuple),
279.2891 +                     format_symbol(mpl, value), buf, eqno);
279.2892 +               }
279.2893 +               break;
279.2894 +            default:
279.2895 +               xassert(cond != cond);
279.2896 +         }
279.2897 +         delete_symbol(mpl, bound);
279.2898 +      }
279.2899 +      /* the value must be in all specified supersets */
279.2900 +      for (in = par->in, eqno = 1; in != NULL; in = in->next, eqno++)
279.2901 +      {  TUPLE *dummy;
279.2902 +         xassert(in->code != NULL);
279.2903 +         xassert(in->code->dim == 1);
279.2904 +         dummy = expand_tuple(mpl, create_tuple(mpl), copy_symbol(mpl,
279.2905 +            value));
279.2906 +         if (!is_member(mpl, in->code, dummy))
279.2907 +            error(mpl, "%s%s = %s not in specified set; see (%d)",
279.2908 +               par->name, format_tuple(mpl, '[', tuple),
279.2909 +               format_symbol(mpl, value), eqno);
279.2910 +         delete_tuple(mpl, dummy);
279.2911 +      }
279.2912 +      return;
279.2913 +}
279.2914 +
279.2915 +/*----------------------------------------------------------------------
279.2916 +-- take_member_sym - obtain symb. value assigned to parameter member.
279.2917 +--
279.2918 +-- This routine obtains a symbolic value assigned to member of specified
279.2919 +-- symbolic model parameter and returns it on exit.
279.2920 +--
279.2921 +-- NOTE: This routine must not be called out of domain scope. */
279.2922 +
279.2923 +SYMBOL *take_member_sym       /* returns value, not reference */
279.2924 +(     MPL *mpl,
279.2925 +      PARAMETER *par,         /* not changed */
279.2926 +      TUPLE *tuple            /* not changed */
279.2927 +)
279.2928 +{     MEMBER *memb;
279.2929 +      SYMBOL *value;
279.2930 +      /* find member in the parameter array */
279.2931 +      memb = find_member(mpl, par->array, tuple);
279.2932 +      if (memb != NULL)
279.2933 +      {  /* member exists, so just take its value */
279.2934 +         value = copy_symbol(mpl, memb->value.sym);
279.2935 +      }
279.2936 +      else if (par->assign != NULL)
279.2937 +      {  /* compute value using assignment expression */
279.2938 +         value = eval_symbolic(mpl, par->assign);
279.2939 +add:     /* check that the value satisfies to all restrictions, assign
279.2940 +            it to new member, and add the member to the array */
279.2941 +         check_value_sym(mpl, par, tuple, value);
279.2942 +         memb = add_member(mpl, par->array, copy_tuple(mpl, tuple));
279.2943 +         memb->value.sym = copy_symbol(mpl, value);
279.2944 +      }
279.2945 +      else if (par->option != NULL)
279.2946 +      {  /* compute default value */
279.2947 +         value = eval_symbolic(mpl, par->option);
279.2948 +         goto add;
279.2949 +      }
279.2950 +      else if (par->defval != NULL)
279.2951 +      {  /* take default value provided in the data section */
279.2952 +         value = copy_symbol(mpl, par->defval);
279.2953 +         goto add;
279.2954 +      }
279.2955 +      else
279.2956 +      {  /* no value is provided */
279.2957 +         error(mpl, "no value for %s%s", par->name, format_tuple(mpl,
279.2958 +            '[', tuple));
279.2959 +      }
279.2960 +      return value;
279.2961 +}
279.2962 +
279.2963 +/*----------------------------------------------------------------------
279.2964 +-- eval_member_sym - evaluate symb. value assigned to parameter member.
279.2965 +--
279.2966 +-- This routine evaluates a symbolic value assigned to given member of
279.2967 +-- specified symbolic model parameter and returns it on exit. */
279.2968 +
279.2969 +struct eval_sym_info
279.2970 +{     /* working info used by the routine eval_member_sym */
279.2971 +      PARAMETER *par;
279.2972 +      /* model parameter */
279.2973 +      TUPLE *tuple;
279.2974 +      /* n-tuple, which defines parameter member */
279.2975 +      MEMBER *memb;
279.2976 +      /* normally this pointer is NULL; the routine uses this pointer
279.2977 +         to check data provided in the data section, in which case it
279.2978 +         points to a member currently checked; this check is performed
279.2979 +         automatically only once when a reference to any member occurs
279.2980 +         for the first time */
279.2981 +      SYMBOL *value;
279.2982 +      /* evaluated symbolic value */
279.2983 +};
279.2984 +
279.2985 +static void eval_sym_func(MPL *mpl, void *_info)
279.2986 +{     /* this is auxiliary routine to work within domain scope */
279.2987 +      struct eval_sym_info *info = _info;
279.2988 +      if (info->memb != NULL)
279.2989 +      {  /* checking call; check symbolic value being assigned */
279.2990 +         check_value_sym(mpl, info->par, info->memb->tuple,
279.2991 +            info->memb->value.sym);
279.2992 +      }
279.2993 +      else
279.2994 +      {  /* normal call; evaluate member, which has given n-tuple */
279.2995 +         info->value = take_member_sym(mpl, info->par, info->tuple);
279.2996 +      }
279.2997 +      return;
279.2998 +}
279.2999 +
279.3000 +SYMBOL *eval_member_sym       /* returns value, not reference */
279.3001 +(     MPL *mpl,
279.3002 +      PARAMETER *par,         /* not changed */
279.3003 +      TUPLE *tuple            /* not changed */
279.3004 +)
279.3005 +{     /* this routine evaluates symbolic parameter member */
279.3006 +      struct eval_sym_info _info, *info = &_info;
279.3007 +      xassert(par->type == A_SYMBOLIC);
279.3008 +      xassert(par->dim == tuple_dimen(mpl, tuple));
279.3009 +      info->par = par;
279.3010 +      info->tuple = tuple;
279.3011 +      if (par->data == 1)
279.3012 +      {  /* check data, which are provided in the data section, but not
279.3013 +            checked yet */
279.3014 +         /* save pointer to the last array member; note that during the
279.3015 +            check new members may be added beyond the last member due to
279.3016 +            references to the same parameter from default expression as
279.3017 +            well as from expressions that define restricting conditions;
279.3018 +            however, values assigned to the new members will be checked
279.3019 +            by other routine, so we don't need to check them here */
279.3020 +         MEMBER *tail = par->array->tail;
279.3021 +         /* change the data status to prevent infinite recursive loop
279.3022 +            due to references to the same parameter during the check */
279.3023 +         par->data = 2;
279.3024 +         /* check values assigned to array members in the data section
279.3025 +            until the marked member has been reached */
279.3026 +         for (info->memb = par->array->head; info->memb != NULL;
279.3027 +            info->memb = info->memb->next)
279.3028 +         {  if (eval_within_domain(mpl, par->domain, info->memb->tuple,
279.3029 +               info, eval_sym_func))
279.3030 +               out_of_domain(mpl, par->name, info->memb->tuple);
279.3031 +            if (info->memb == tail) break;
279.3032 +         }
279.3033 +         /* the check has been finished */
279.3034 +      }
279.3035 +      /* evaluate member, which has given n-tuple */
279.3036 +      info->memb = NULL;
279.3037 +      if (eval_within_domain(mpl, info->par->domain, info->tuple, info,
279.3038 +         eval_sym_func))
279.3039 +         out_of_domain(mpl, par->name, info->tuple);
279.3040 +      /* bring evaluated value to the calling program */
279.3041 +      return info->value;
279.3042 +}
279.3043 +
279.3044 +/*----------------------------------------------------------------------
279.3045 +-- eval_whole_par - evaluate model parameter over entire domain.
279.3046 +--
279.3047 +-- This routine evaluates all members of specified model parameter over
279.3048 +-- entire domain. */
279.3049 +
279.3050 +static int whole_par_func(MPL *mpl, void *info)
279.3051 +{     /* this is auxiliary routine to work within domain scope */
279.3052 +      PARAMETER *par = (PARAMETER *)info;
279.3053 +      TUPLE *tuple = get_domain_tuple(mpl, par->domain);
279.3054 +      switch (par->type)
279.3055 +      {  case A_NUMERIC:
279.3056 +         case A_INTEGER:
279.3057 +         case A_BINARY:
279.3058 +            eval_member_num(mpl, par, tuple);
279.3059 +            break;
279.3060 +         case A_SYMBOLIC:
279.3061 +            delete_symbol(mpl, eval_member_sym(mpl, par, tuple));
279.3062 +            break;
279.3063 +         default:
279.3064 +            xassert(par != par);
279.3065 +      }
279.3066 +      delete_tuple(mpl, tuple);
279.3067 +      return 0;
279.3068 +}
279.3069 +
279.3070 +void eval_whole_par(MPL *mpl, PARAMETER *par)
279.3071 +{     loop_within_domain(mpl, par->domain, par, whole_par_func);
279.3072 +      return;
279.3073 +}
279.3074 +
279.3075 +/*----------------------------------------------------------------------
279.3076 +-- clean_parameter - clean model parameter.
279.3077 +--
279.3078 +-- This routine cleans specified model parameter that assumes deleting
279.3079 +-- all stuff dynamically allocated during the generation phase. */
279.3080 +
279.3081 +void clean_parameter(MPL *mpl, PARAMETER *par)
279.3082 +{     CONDITION *cond;
279.3083 +      WITHIN *in;
279.3084 +      MEMBER *memb;
279.3085 +      /* clean subscript domain */
279.3086 +      clean_domain(mpl, par->domain);
279.3087 +      /* clean pseudo-code for computing restricting conditions */
279.3088 +      for (cond = par->cond; cond != NULL; cond = cond->next)
279.3089 +         clean_code(mpl, cond->code);
279.3090 +      /* clean pseudo-code for computing restricting supersets */
279.3091 +      for (in = par->in; in != NULL; in = in->next)
279.3092 +         clean_code(mpl, in->code);
279.3093 +      /* clean pseudo-code for computing assigned value */
279.3094 +      clean_code(mpl, par->assign);
279.3095 +      /* clean pseudo-code for computing default value */
279.3096 +      clean_code(mpl, par->option);
279.3097 +      /* reset data status flag */
279.3098 +      par->data = 0;
279.3099 +      /* delete default symbolic value */
279.3100 +      if (par->defval != NULL)
279.3101 +         delete_symbol(mpl, par->defval), par->defval = NULL;
279.3102 +      /* delete content array */
279.3103 +      for (memb = par->array->head; memb != NULL; memb = memb->next)
279.3104 +         delete_value(mpl, par->array->type, &memb->value);
279.3105 +      delete_array(mpl, par->array), par->array = NULL;
279.3106 +      return;
279.3107 +}
279.3108 +
279.3109 +/**********************************************************************/
279.3110 +/* * *                      MODEL VARIABLES                       * * */
279.3111 +/**********************************************************************/
279.3112 +
279.3113 +/*----------------------------------------------------------------------
279.3114 +-- take_member_var - obtain reference to elemental variable.
279.3115 +--
279.3116 +-- This routine obtains a reference to elemental variable assigned to
279.3117 +-- given member of specified model variable and returns it on exit. If
279.3118 +-- necessary, new elemental variable is created.
279.3119 +--
279.3120 +-- NOTE: This routine must not be called out of domain scope. */
279.3121 +
279.3122 +ELEMVAR *take_member_var      /* returns reference */
279.3123 +(     MPL *mpl,
279.3124 +      VARIABLE *var,          /* not changed */
279.3125 +      TUPLE *tuple            /* not changed */
279.3126 +)
279.3127 +{     MEMBER *memb;
279.3128 +      ELEMVAR *refer;
279.3129 +      /* find member in the variable array */
279.3130 +      memb = find_member(mpl, var->array, tuple);
279.3131 +      if (memb != NULL)
279.3132 +      {  /* member exists, so just take the reference */
279.3133 +         refer = memb->value.var;
279.3134 +      }
279.3135 +      else
279.3136 +      {  /* member is referenced for the first time and therefore does
279.3137 +            not exist; create new elemental variable, assign it to new
279.3138 +            member, and add the member to the variable array */
279.3139 +         memb = add_member(mpl, var->array, copy_tuple(mpl, tuple));
279.3140 +         refer = (memb->value.var =
279.3141 +            dmp_get_atom(mpl->elemvars, sizeof(ELEMVAR)));
279.3142 +         refer->j = 0;
279.3143 +         refer->var = var;
279.3144 +         refer->memb = memb;
279.3145 +         /* compute lower bound */
279.3146 +         if (var->lbnd == NULL)
279.3147 +            refer->lbnd = 0.0;
279.3148 +         else
279.3149 +            refer->lbnd = eval_numeric(mpl, var->lbnd);
279.3150 +         /* compute upper bound */
279.3151 +         if (var->ubnd == NULL)
279.3152 +            refer->ubnd = 0.0;
279.3153 +         else if (var->ubnd == var->lbnd)
279.3154 +            refer->ubnd = refer->lbnd;
279.3155 +         else
279.3156 +            refer->ubnd = eval_numeric(mpl, var->ubnd);
279.3157 +         /* nullify working quantity */
279.3158 +         refer->temp = 0.0;
279.3159 +#if 1 /* 15/V-2010 */
279.3160 +         /* solution has not been obtained by the solver yet */
279.3161 +         refer->stat = 0;
279.3162 +         refer->prim = refer->dual = 0.0;
279.3163 +#endif
279.3164 +      }
279.3165 +      return refer;
279.3166 +}
279.3167 +
279.3168 +/*----------------------------------------------------------------------
279.3169 +-- eval_member_var - evaluate reference to elemental variable.
279.3170 +--
279.3171 +-- This routine evaluates a reference to elemental variable assigned to
279.3172 +-- member of specified model variable and returns it on exit. */
279.3173 +
279.3174 +struct eval_var_info
279.3175 +{     /* working info used by the routine eval_member_var */
279.3176 +      VARIABLE *var;
279.3177 +      /* model variable */
279.3178 +      TUPLE *tuple;
279.3179 +      /* n-tuple, which defines variable member */
279.3180 +      ELEMVAR *refer;
279.3181 +      /* evaluated reference to elemental variable */
279.3182 +};
279.3183 +
279.3184 +static void eval_var_func(MPL *mpl, void *_info)
279.3185 +{     /* this is auxiliary routine to work within domain scope */
279.3186 +      struct eval_var_info *info = _info;
279.3187 +      info->refer = take_member_var(mpl, info->var, info->tuple);
279.3188 +      return;
279.3189 +}
279.3190 +
279.3191 +ELEMVAR *eval_member_var      /* returns reference */
279.3192 +(     MPL *mpl,
279.3193 +      VARIABLE *var,          /* not changed */
279.3194 +      TUPLE *tuple            /* not changed */
279.3195 +)
279.3196 +{     /* this routine evaluates variable member */
279.3197 +      struct eval_var_info _info, *info = &_info;
279.3198 +      xassert(var->dim == tuple_dimen(mpl, tuple));
279.3199 +      info->var = var;
279.3200 +      info->tuple = tuple;
279.3201 +      /* evaluate member, which has given n-tuple */
279.3202 +      if (eval_within_domain(mpl, info->var->domain, info->tuple, info,
279.3203 +         eval_var_func))
279.3204 +         out_of_domain(mpl, var->name, info->tuple);
279.3205 +      /* bring evaluated reference to the calling program */
279.3206 +      return info->refer;
279.3207 +}
279.3208 +
279.3209 +/*----------------------------------------------------------------------
279.3210 +-- eval_whole_var - evaluate model variable over entire domain.
279.3211 +--
279.3212 +-- This routine evaluates all members of specified model variable over
279.3213 +-- entire domain. */
279.3214 +
279.3215 +static int whole_var_func(MPL *mpl, void *info)
279.3216 +{     /* this is auxiliary routine to work within domain scope */
279.3217 +      VARIABLE *var = (VARIABLE *)info;
279.3218 +      TUPLE *tuple = get_domain_tuple(mpl, var->domain);
279.3219 +      eval_member_var(mpl, var, tuple);
279.3220 +      delete_tuple(mpl, tuple);
279.3221 +      return 0;
279.3222 +}
279.3223 +
279.3224 +void eval_whole_var(MPL *mpl, VARIABLE *var)
279.3225 +{     loop_within_domain(mpl, var->domain, var, whole_var_func);
279.3226 +      return;
279.3227 +}
279.3228 +
279.3229 +/*----------------------------------------------------------------------
279.3230 +-- clean_variable - clean model variable.
279.3231 +--
279.3232 +-- This routine cleans specified model variable that assumes deleting
279.3233 +-- all stuff dynamically allocated during the generation phase. */
279.3234 +
279.3235 +void clean_variable(MPL *mpl, VARIABLE *var)
279.3236 +{     MEMBER *memb;
279.3237 +      /* clean subscript domain */
279.3238 +      clean_domain(mpl, var->domain);
279.3239 +      /* clean code for computing lower bound */
279.3240 +      clean_code(mpl, var->lbnd);
279.3241 +      /* clean code for computing upper bound */
279.3242 +      if (var->ubnd != var->lbnd) clean_code(mpl, var->ubnd);
279.3243 +      /* delete content array */
279.3244 +      for (memb = var->array->head; memb != NULL; memb = memb->next)
279.3245 +         dmp_free_atom(mpl->elemvars, memb->value.var, sizeof(ELEMVAR));
279.3246 +      delete_array(mpl, var->array), var->array = NULL;
279.3247 +      return;
279.3248 +}
279.3249 +
279.3250 +/**********************************************************************/
279.3251 +/* * *              MODEL CONSTRAINTS AND OBJECTIVES              * * */
279.3252 +/**********************************************************************/
279.3253 +
279.3254 +/*----------------------------------------------------------------------
279.3255 +-- take_member_con - obtain reference to elemental constraint.
279.3256 +--
279.3257 +-- This routine obtains a reference to elemental constraint assigned
279.3258 +-- to given member of specified model constraint and returns it on exit.
279.3259 +-- If necessary, new elemental constraint is created.
279.3260 +--
279.3261 +-- NOTE: This routine must not be called out of domain scope. */
279.3262 +
279.3263 +ELEMCON *take_member_con      /* returns reference */
279.3264 +(     MPL *mpl,
279.3265 +      CONSTRAINT *con,        /* not changed */
279.3266 +      TUPLE *tuple            /* not changed */
279.3267 +)
279.3268 +{     MEMBER *memb;
279.3269 +      ELEMCON *refer;
279.3270 +      /* find member in the constraint array */
279.3271 +      memb = find_member(mpl, con->array, tuple);
279.3272 +      if (memb != NULL)
279.3273 +      {  /* member exists, so just take the reference */
279.3274 +         refer = memb->value.con;
279.3275 +      }
279.3276 +      else
279.3277 +      {  /* member is referenced for the first time and therefore does
279.3278 +            not exist; create new elemental constraint, assign it to new
279.3279 +            member, and add the member to the constraint array */
279.3280 +         memb = add_member(mpl, con->array, copy_tuple(mpl, tuple));
279.3281 +         refer = (memb->value.con =
279.3282 +            dmp_get_atom(mpl->elemcons, sizeof(ELEMCON)));
279.3283 +         refer->i = 0;
279.3284 +         refer->con = con;
279.3285 +         refer->memb = memb;
279.3286 +         /* compute linear form */
279.3287 +         xassert(con->code != NULL);
279.3288 +         refer->form = eval_formula(mpl, con->code);
279.3289 +         /* compute lower and upper bounds */
279.3290 +         if (con->lbnd == NULL && con->ubnd == NULL)
279.3291 +         {  /* objective has no bounds */
279.3292 +            double temp;
279.3293 +            xassert(con->type == A_MINIMIZE || con->type == A_MAXIMIZE);
279.3294 +            /* carry the constant term to the right-hand side */
279.3295 +            refer->form = remove_constant(mpl, refer->form, &temp);
279.3296 +            refer->lbnd = refer->ubnd = - temp;
279.3297 +         }
279.3298 +         else if (con->lbnd != NULL && con->ubnd == NULL)
279.3299 +         {  /* constraint a * x + b >= c * y + d is transformed to the
279.3300 +               standard form a * x - c * y >= d - b */
279.3301 +            double temp;
279.3302 +            xassert(con->type == A_CONSTRAINT);
279.3303 +            refer->form = linear_comb(mpl,
279.3304 +               +1.0, refer->form,
279.3305 +               -1.0, eval_formula(mpl, con->lbnd));
279.3306 +            refer->form = remove_constant(mpl, refer->form, &temp);
279.3307 +            refer->lbnd = - temp;
279.3308 +            refer->ubnd = 0.0;
279.3309 +         }
279.3310 +         else if (con->lbnd == NULL && con->ubnd != NULL)
279.3311 +         {  /* constraint a * x + b <= c * y + d is transformed to the
279.3312 +               standard form a * x - c * y <= d - b */
279.3313 +            double temp;
279.3314 +            xassert(con->type == A_CONSTRAINT);
279.3315 +            refer->form = linear_comb(mpl,
279.3316 +               +1.0, refer->form,
279.3317 +               -1.0, eval_formula(mpl, con->ubnd));
279.3318 +            refer->form = remove_constant(mpl, refer->form, &temp);
279.3319 +            refer->lbnd = 0.0;
279.3320 +            refer->ubnd = - temp;
279.3321 +         }
279.3322 +         else if (con->lbnd == con->ubnd)
279.3323 +         {  /* constraint a * x + b = c * y + d is transformed to the
279.3324 +               standard form a * x - c * y = d - b */
279.3325 +            double temp;
279.3326 +            xassert(con->type == A_CONSTRAINT);
279.3327 +            refer->form = linear_comb(mpl,
279.3328 +               +1.0, refer->form,
279.3329 +               -1.0, eval_formula(mpl, con->lbnd));
279.3330 +            refer->form = remove_constant(mpl, refer->form, &temp);
279.3331 +            refer->lbnd = refer->ubnd = - temp;
279.3332 +         }
279.3333 +         else
279.3334 +         {  /* ranged constraint c <= a * x + b <= d is transformed to
279.3335 +               the standard form c - b <= a * x <= d - b */
279.3336 +            double temp, temp1, temp2;
279.3337 +            xassert(con->type == A_CONSTRAINT);
279.3338 +            refer->form = remove_constant(mpl, refer->form, &temp);
279.3339 +            xassert(remove_constant(mpl, eval_formula(mpl, con->lbnd),
279.3340 +               &temp1) == NULL);
279.3341 +            xassert(remove_constant(mpl, eval_formula(mpl, con->ubnd),
279.3342 +               &temp2) == NULL);
279.3343 +            refer->lbnd = fp_sub(mpl, temp1, temp);
279.3344 +            refer->ubnd = fp_sub(mpl, temp2, temp);
279.3345 +         }
279.3346 +#if 1 /* 15/V-2010 */
279.3347 +         /* solution has not been obtained by the solver yet */
279.3348 +         refer->stat = 0;
279.3349 +         refer->prim = refer->dual = 0.0;
279.3350 +#endif
279.3351 +      }
279.3352 +      return refer;
279.3353 +}
279.3354 +
279.3355 +/*----------------------------------------------------------------------
279.3356 +-- eval_member_con - evaluate reference to elemental constraint.
279.3357 +--
279.3358 +-- This routine evaluates a reference to elemental constraint assigned
279.3359 +-- to member of specified model constraint and returns it on exit. */
279.3360 +
279.3361 +struct eval_con_info
279.3362 +{     /* working info used by the routine eval_member_con */
279.3363 +      CONSTRAINT *con;
279.3364 +      /* model constraint */
279.3365 +      TUPLE *tuple;
279.3366 +      /* n-tuple, which defines constraint member */
279.3367 +      ELEMCON *refer;
279.3368 +      /* evaluated reference to elemental constraint */
279.3369 +};
279.3370 +
279.3371 +static void eval_con_func(MPL *mpl, void *_info)
279.3372 +{     /* this is auxiliary routine to work within domain scope */
279.3373 +      struct eval_con_info *info = _info;
279.3374 +      info->refer = take_member_con(mpl, info->con, info->tuple);
279.3375 +      return;
279.3376 +}
279.3377 +
279.3378 +ELEMCON *eval_member_con      /* returns reference */
279.3379 +(     MPL *mpl,
279.3380 +      CONSTRAINT *con,        /* not changed */
279.3381 +      TUPLE *tuple            /* not changed */
279.3382 +)
279.3383 +{     /* this routine evaluates constraint member */
279.3384 +      struct eval_con_info _info, *info = &_info;
279.3385 +      xassert(con->dim == tuple_dimen(mpl, tuple));
279.3386 +      info->con = con;
279.3387 +      info->tuple = tuple;
279.3388 +      /* evaluate member, which has given n-tuple */
279.3389 +      if (eval_within_domain(mpl, info->con->domain, info->tuple, info,
279.3390 +         eval_con_func))
279.3391 +         out_of_domain(mpl, con->name, info->tuple);
279.3392 +      /* bring evaluated reference to the calling program */
279.3393 +      return info->refer;
279.3394 +}
279.3395 +
279.3396 +/*----------------------------------------------------------------------
279.3397 +-- eval_whole_con - evaluate model constraint over entire domain.
279.3398 +--
279.3399 +-- This routine evaluates all members of specified model constraint over
279.3400 +-- entire domain. */
279.3401 +
279.3402 +static int whole_con_func(MPL *mpl, void *info)
279.3403 +{     /* this is auxiliary routine to work within domain scope */
279.3404 +      CONSTRAINT *con = (CONSTRAINT *)info;
279.3405 +      TUPLE *tuple = get_domain_tuple(mpl, con->domain);
279.3406 +      eval_member_con(mpl, con, tuple);
279.3407 +      delete_tuple(mpl, tuple);
279.3408 +      return 0;
279.3409 +}
279.3410 +
279.3411 +void eval_whole_con(MPL *mpl, CONSTRAINT *con)
279.3412 +{     loop_within_domain(mpl, con->domain, con, whole_con_func);
279.3413 +      return;
279.3414 +}
279.3415 +
279.3416 +/*----------------------------------------------------------------------
279.3417 +-- clean_constraint - clean model constraint.
279.3418 +--
279.3419 +-- This routine cleans specified model constraint that assumes deleting
279.3420 +-- all stuff dynamically allocated during the generation phase. */
279.3421 +
279.3422 +void clean_constraint(MPL *mpl, CONSTRAINT *con)
279.3423 +{     MEMBER *memb;
279.3424 +      /* clean subscript domain */
279.3425 +      clean_domain(mpl, con->domain);
279.3426 +      /* clean code for computing main linear form */
279.3427 +      clean_code(mpl, con->code);
279.3428 +      /* clean code for computing lower bound */
279.3429 +      clean_code(mpl, con->lbnd);
279.3430 +      /* clean code for computing upper bound */
279.3431 +      if (con->ubnd != con->lbnd) clean_code(mpl, con->ubnd);
279.3432 +      /* delete content array */
279.3433 +      for (memb = con->array->head; memb != NULL; memb = memb->next)
279.3434 +      {  delete_formula(mpl, memb->value.con->form);
279.3435 +         dmp_free_atom(mpl->elemcons, memb->value.con, sizeof(ELEMCON));
279.3436 +      }
279.3437 +      delete_array(mpl, con->array), con->array = NULL;
279.3438 +      return;
279.3439 +}
279.3440 +
279.3441 +/**********************************************************************/
279.3442 +/* * *                        PSEUDO-CODE                         * * */
279.3443 +/**********************************************************************/
279.3444 +
279.3445 +/*----------------------------------------------------------------------
279.3446 +-- eval_numeric - evaluate pseudo-code to determine numeric value.
279.3447 +--
279.3448 +-- This routine evaluates specified pseudo-code to determine resultant
279.3449 +-- numeric value, which is returned on exit. */
279.3450 +
279.3451 +struct iter_num_info
279.3452 +{     /* working info used by the routine iter_num_func */
279.3453 +      CODE *code;
279.3454 +      /* pseudo-code for iterated operation to be performed */
279.3455 +      double value;
279.3456 +      /* resultant value */
279.3457 +};
279.3458 +
279.3459 +static int iter_num_func(MPL *mpl, void *_info)
279.3460 +{     /* this is auxiliary routine used to perform iterated operation
279.3461 +         on numeric "integrand" within domain scope */
279.3462 +      struct iter_num_info *info = _info;
279.3463 +      double temp;
279.3464 +      temp = eval_numeric(mpl, info->code->arg.loop.x);
279.3465 +      switch (info->code->op)
279.3466 +      {  case O_SUM:
279.3467 +            /* summation over domain */
279.3468 +            info->value = fp_add(mpl, info->value, temp);
279.3469 +            break;
279.3470 +         case O_PROD:
279.3471 +            /* multiplication over domain */
279.3472 +            info->value = fp_mul(mpl, info->value, temp);
279.3473 +            break;
279.3474 +         case O_MINIMUM:
279.3475 +            /* minimum over domain */
279.3476 +            if (info->value > temp) info->value = temp;
279.3477 +            break;
279.3478 +         case O_MAXIMUM:
279.3479 +            /* maximum over domain */
279.3480 +            if (info->value < temp) info->value = temp;
279.3481 +            break;
279.3482 +         default:
279.3483 +            xassert(info != info);
279.3484 +      }
279.3485 +      return 0;
279.3486 +}
279.3487 +
279.3488 +double eval_numeric(MPL *mpl, CODE *code)
279.3489 +{     double value;
279.3490 +      xassert(code != NULL);
279.3491 +      xassert(code->type == A_NUMERIC);
279.3492 +      xassert(code->dim == 0);
279.3493 +      /* if the operation has a side effect, invalidate and delete the
279.3494 +         resultant value */
279.3495 +      if (code->vflag && code->valid)
279.3496 +      {  code->valid = 0;
279.3497 +         delete_value(mpl, code->type, &code->value);
279.3498 +      }
279.3499 +      /* if resultant value is valid, no evaluation is needed */
279.3500 +      if (code->valid)
279.3501 +      {  value = code->value.num;
279.3502 +         goto done;
279.3503 +      }
279.3504 +      /* evaluate pseudo-code recursively */
279.3505 +      switch (code->op)
279.3506 +      {  case O_NUMBER:
279.3507 +            /* take floating-point number */
279.3508 +            value = code->arg.num;
279.3509 +            break;
279.3510 +         case O_MEMNUM:
279.3511 +            /* take member of numeric parameter */
279.3512 +            {  TUPLE *tuple;
279.3513 +               ARG_LIST *e;
279.3514 +               tuple = create_tuple(mpl);
279.3515 +               for (e = code->arg.par.list; e != NULL; e = e->next)
279.3516 +                  tuple = expand_tuple(mpl, tuple, eval_symbolic(mpl,
279.3517 +                     e->x));
279.3518 +               value = eval_member_num(mpl, code->arg.par.par, tuple);
279.3519 +               delete_tuple(mpl, tuple);
279.3520 +            }
279.3521 +            break;
279.3522 +         case O_MEMVAR:
279.3523 +            /* take computed value of elemental variable */
279.3524 +            {  TUPLE *tuple;
279.3525 +               ARG_LIST *e;
279.3526 +#if 1 /* 15/V-2010 */
279.3527 +               ELEMVAR *var;
279.3528 +#endif
279.3529 +               tuple = create_tuple(mpl);
279.3530 +               for (e = code->arg.var.list; e != NULL; e = e->next)
279.3531 +                  tuple = expand_tuple(mpl, tuple, eval_symbolic(mpl,
279.3532 +                     e->x));
279.3533 +#if 0 /* 15/V-2010 */
279.3534 +               value = eval_member_var(mpl, code->arg.var.var, tuple)
279.3535 +                  ->value;
279.3536 +#else
279.3537 +               var = eval_member_var(mpl, code->arg.var.var, tuple);
279.3538 +               switch (code->arg.var.suff)
279.3539 +               {  case DOT_LB:
279.3540 +                     if (var->var->lbnd == NULL)
279.3541 +                        value = -DBL_MAX;
279.3542 +                     else
279.3543 +                        value = var->lbnd;
279.3544 +                     break;
279.3545 +                  case DOT_UB:
279.3546 +                     if (var->var->ubnd == NULL)
279.3547 +                        value = +DBL_MAX;
279.3548 +                     else
279.3549 +                        value = var->ubnd;
279.3550 +                     break;
279.3551 +                  case DOT_STATUS:
279.3552 +                     value = var->stat;
279.3553 +                     break;
279.3554 +                  case DOT_VAL:
279.3555 +                     value = var->prim;
279.3556 +                     break;
279.3557 +                  case DOT_DUAL:
279.3558 +                     value = var->dual;
279.3559 +                     break;
279.3560 +                  default:
279.3561 +                     xassert(code != code);
279.3562 +               }
279.3563 +#endif
279.3564 +               delete_tuple(mpl, tuple);
279.3565 +            }
279.3566 +            break;
279.3567 +#if 1 /* 15/V-2010 */
279.3568 +         case O_MEMCON:
279.3569 +            /* take computed value of elemental constraint */
279.3570 +            {  TUPLE *tuple;
279.3571 +               ARG_LIST *e;
279.3572 +               ELEMCON *con;
279.3573 +               tuple = create_tuple(mpl);
279.3574 +               for (e = code->arg.con.list; e != NULL; e = e->next)
279.3575 +                  tuple = expand_tuple(mpl, tuple, eval_symbolic(mpl,
279.3576 +                     e->x));
279.3577 +               con = eval_member_con(mpl, code->arg.con.con, tuple);
279.3578 +               switch (code->arg.con.suff)
279.3579 +               {  case DOT_LB:
279.3580 +                     if (con->con->lbnd == NULL)
279.3581 +                        value = -DBL_MAX;
279.3582 +                     else
279.3583 +                        value = con->lbnd;
279.3584 +                     break;
279.3585 +                  case DOT_UB:
279.3586 +                     if (con->con->ubnd == NULL)
279.3587 +                        value = +DBL_MAX;
279.3588 +                     else
279.3589 +                        value = con->ubnd;
279.3590 +                     break;
279.3591 +                  case DOT_STATUS:
279.3592 +                     value = con->stat;
279.3593 +                     break;
279.3594 +                  case DOT_VAL:
279.3595 +                     value = con->prim;
279.3596 +                     break;
279.3597 +                  case DOT_DUAL:
279.3598 +                     value = con->dual;
279.3599 +                     break;
279.3600 +                  default:
279.3601 +                     xassert(code != code);
279.3602 +               }
279.3603 +               delete_tuple(mpl, tuple);
279.3604 +            }
279.3605 +            break;
279.3606 +#endif
279.3607 +         case O_IRAND224:
279.3608 +            /* pseudo-random in [0, 2^24-1] */
279.3609 +            value = fp_irand224(mpl);
279.3610 +            break;
279.3611 +         case O_UNIFORM01:
279.3612 +            /* pseudo-random in [0, 1) */
279.3613 +            value = fp_uniform01(mpl);
279.3614 +            break;
279.3615 +         case O_NORMAL01:
279.3616 +            /* gaussian random, mu = 0, sigma = 1 */
279.3617 +            value = fp_normal01(mpl);
279.3618 +            break;
279.3619 +         case O_GMTIME:
279.3620 +            /* current calendar time */
279.3621 +            value = fn_gmtime(mpl);
279.3622 +            break;
279.3623 +         case O_CVTNUM:
279.3624 +            /* conversion to numeric */
279.3625 +            {  SYMBOL *sym;
279.3626 +               sym = eval_symbolic(mpl, code->arg.arg.x);
279.3627 +#if 0 /* 23/XI-2008 */
279.3628 +               if (sym->str != NULL)
279.3629 +                  error(mpl, "cannot convert %s to floating-point numbe"
279.3630 +                     "r", format_symbol(mpl, sym));
279.3631 +               value = sym->num;
279.3632 +#else
279.3633 +               if (sym->str == NULL)
279.3634 +                  value = sym->num;
279.3635 +               else
279.3636 +               {  if (str2num(sym->str, &value))
279.3637 +                     error(mpl, "cannot convert %s to floating-point nu"
279.3638 +                        "mber", format_symbol(mpl, sym));
279.3639 +               }
279.3640 +#endif
279.3641 +               delete_symbol(mpl, sym);
279.3642 +            }
279.3643 +            break;
279.3644 +         case O_PLUS:
279.3645 +            /* unary plus */
279.3646 +            value = + eval_numeric(mpl, code->arg.arg.x);
279.3647 +            break;
279.3648 +         case O_MINUS:
279.3649 +            /* unary minus */
279.3650 +            value = - eval_numeric(mpl, code->arg.arg.x);
279.3651 +            break;
279.3652 +         case O_ABS:
279.3653 +            /* absolute value */
279.3654 +            value = fabs(eval_numeric(mpl, code->arg.arg.x));
279.3655 +            break;
279.3656 +         case O_CEIL:
279.3657 +            /* round upward ("ceiling of x") */
279.3658 +            value = ceil(eval_numeric(mpl, code->arg.arg.x));
279.3659 +            break;
279.3660 +         case O_FLOOR:
279.3661 +            /* round downward ("floor of x") */
279.3662 +            value = floor(eval_numeric(mpl, code->arg.arg.x));
279.3663 +            break;
279.3664 +         case O_EXP:
279.3665 +            /* base-e exponential */
279.3666 +            value = fp_exp(mpl, eval_numeric(mpl, code->arg.arg.x));
279.3667 +            break;
279.3668 +         case O_LOG:
279.3669 +            /* natural logarithm */
279.3670 +            value = fp_log(mpl, eval_numeric(mpl, code->arg.arg.x));
279.3671 +            break;
279.3672 +         case O_LOG10:
279.3673 +            /* common (decimal) logarithm */
279.3674 +            value = fp_log10(mpl, eval_numeric(mpl, code->arg.arg.x));
279.3675 +            break;
279.3676 +         case O_SQRT:
279.3677 +            /* square root */
279.3678 +            value = fp_sqrt(mpl, eval_numeric(mpl, code->arg.arg.x));
279.3679 +            break;
279.3680 +         case O_SIN:
279.3681 +            /* trigonometric sine */
279.3682 +            value = fp_sin(mpl, eval_numeric(mpl, code->arg.arg.x));
279.3683 +            break;
279.3684 +         case O_COS:
279.3685 +            /* trigonometric cosine */
279.3686 +            value = fp_cos(mpl, eval_numeric(mpl, code->arg.arg.x));
279.3687 +            break;
279.3688 +         case O_ATAN:
279.3689 +            /* trigonometric arctangent (one argument) */
279.3690 +            value = fp_atan(mpl, eval_numeric(mpl, code->arg.arg.x));
279.3691 +            break;
279.3692 +         case O_ATAN2:
279.3693 +            /* trigonometric arctangent (two arguments) */
279.3694 +            value = fp_atan2(mpl,
279.3695 +               eval_numeric(mpl, code->arg.arg.x),
279.3696 +               eval_numeric(mpl, code->arg.arg.y));
279.3697 +            break;
279.3698 +         case O_ROUND:
279.3699 +            /* round to nearest integer */
279.3700 +            value = fp_round(mpl,
279.3701 +               eval_numeric(mpl, code->arg.arg.x), 0.0);
279.3702 +            break;
279.3703 +         case O_ROUND2:
279.3704 +            /* round to n fractional digits */
279.3705 +            value = fp_round(mpl,
279.3706 +               eval_numeric(mpl, code->arg.arg.x),
279.3707 +               eval_numeric(mpl, code->arg.arg.y));
279.3708 +            break;
279.3709 +         case O_TRUNC:
279.3710 +            /* truncate to nearest integer */
279.3711 +            value = fp_trunc(mpl,
279.3712 +               eval_numeric(mpl, code->arg.arg.x), 0.0);
279.3713 +            break;
279.3714 +         case O_TRUNC2:
279.3715 +            /* truncate to n fractional digits */
279.3716 +            value = fp_trunc(mpl,
279.3717 +               eval_numeric(mpl, code->arg.arg.x),
279.3718 +               eval_numeric(mpl, code->arg.arg.y));
279.3719 +            break;
279.3720 +         case O_ADD:
279.3721 +            /* addition */
279.3722 +            value = fp_add(mpl,
279.3723 +               eval_numeric(mpl, code->arg.arg.x),
279.3724 +               eval_numeric(mpl, code->arg.arg.y));
279.3725 +            break;
279.3726 +         case O_SUB:
279.3727 +            /* subtraction */
279.3728 +            value = fp_sub(mpl,
279.3729 +               eval_numeric(mpl, code->arg.arg.x),
279.3730 +               eval_numeric(mpl, code->arg.arg.y));
279.3731 +            break;
279.3732 +         case O_LESS:
279.3733 +            /* non-negative subtraction */
279.3734 +            value = fp_less(mpl,
279.3735 +               eval_numeric(mpl, code->arg.arg.x),
279.3736 +               eval_numeric(mpl, code->arg.arg.y));
279.3737 +            break;
279.3738 +         case O_MUL:
279.3739 +            /* multiplication */
279.3740 +            value = fp_mul(mpl,
279.3741 +               eval_numeric(mpl, code->arg.arg.x),
279.3742 +               eval_numeric(mpl, code->arg.arg.y));
279.3743 +            break;
279.3744 +         case O_DIV:
279.3745 +            /* division */
279.3746 +            value = fp_div(mpl,
279.3747 +               eval_numeric(mpl, code->arg.arg.x),
279.3748 +               eval_numeric(mpl, code->arg.arg.y));
279.3749 +            break;
279.3750 +         case O_IDIV:
279.3751 +            /* quotient of exact division */
279.3752 +            value = fp_idiv(mpl,
279.3753 +               eval_numeric(mpl, code->arg.arg.x),
279.3754 +               eval_numeric(mpl, code->arg.arg.y));
279.3755 +            break;
279.3756 +         case O_MOD:
279.3757 +            /* remainder of exact division */
279.3758 +            value = fp_mod(mpl,
279.3759 +               eval_numeric(mpl, code->arg.arg.x),
279.3760 +               eval_numeric(mpl, code->arg.arg.y));
279.3761 +            break;
279.3762 +         case O_POWER:
279.3763 +            /* exponentiation (raise to power) */
279.3764 +            value = fp_power(mpl,
279.3765 +               eval_numeric(mpl, code->arg.arg.x),
279.3766 +               eval_numeric(mpl, code->arg.arg.y));
279.3767 +            break;
279.3768 +         case O_UNIFORM:
279.3769 +            /* pseudo-random in [a, b) */
279.3770 +            value = fp_uniform(mpl,
279.3771 +               eval_numeric(mpl, code->arg.arg.x),
279.3772 +               eval_numeric(mpl, code->arg.arg.y));
279.3773 +            break;
279.3774 +         case O_NORMAL:
279.3775 +            /* gaussian random, given mu and sigma */
279.3776 +            value = fp_normal(mpl,
279.3777 +               eval_numeric(mpl, code->arg.arg.x),
279.3778 +               eval_numeric(mpl, code->arg.arg.y));
279.3779 +            break;
279.3780 +         case O_CARD:
279.3781 +            {  ELEMSET *set;
279.3782 +               set = eval_elemset(mpl, code->arg.arg.x);
279.3783 +               value = set->size;
279.3784 +               delete_array(mpl, set);
279.3785 +            }
279.3786 +            break;
279.3787 +         case O_LENGTH:
279.3788 +            {  SYMBOL *sym;
279.3789 +               char str[MAX_LENGTH+1];
279.3790 +               sym = eval_symbolic(mpl, code->arg.arg.x);
279.3791 +               if (sym->str == NULL)
279.3792 +                  sprintf(str, "%.*g", DBL_DIG, sym->num);
279.3793 +               else
279.3794 +                  fetch_string(mpl, sym->str, str);
279.3795 +               delete_symbol(mpl, sym);
279.3796 +               value = strlen(str);
279.3797 +            }
279.3798 +            break;
279.3799 +         case O_STR2TIME:
279.3800 +            {  SYMBOL *sym;
279.3801 +               char str[MAX_LENGTH+1], fmt[MAX_LENGTH+1];
279.3802 +               sym = eval_symbolic(mpl, code->arg.arg.x);
279.3803 +               if (sym->str == NULL)
279.3804 +                  sprintf(str, "%.*g", DBL_DIG, sym->num);
279.3805 +               else
279.3806 +                  fetch_string(mpl, sym->str, str);
279.3807 +               delete_symbol(mpl, sym);
279.3808 +               sym = eval_symbolic(mpl, code->arg.arg.y);
279.3809 +               if (sym->str == NULL)
279.3810 +                  sprintf(fmt, "%.*g", DBL_DIG, sym->num);
279.3811 +               else
279.3812 +                  fetch_string(mpl, sym->str, fmt);
279.3813 +               delete_symbol(mpl, sym);
279.3814 +               value = fn_str2time(mpl, str, fmt);
279.3815 +            }
279.3816 +            break;
279.3817 +         case O_FORK:
279.3818 +            /* if-then-else */
279.3819 +            if (eval_logical(mpl, code->arg.arg.x))
279.3820 +               value = eval_numeric(mpl, code->arg.arg.y);
279.3821 +            else if (code->arg.arg.z == NULL)
279.3822 +               value = 0.0;
279.3823 +            else
279.3824 +               value = eval_numeric(mpl, code->arg.arg.z);
279.3825 +            break;
279.3826 +         case O_MIN:
279.3827 +            /* minimal value (n-ary) */
279.3828 +            {  ARG_LIST *e;
279.3829 +               double temp;
279.3830 +               value = +DBL_MAX;
279.3831 +               for (e = code->arg.list; e != NULL; e = e->next)
279.3832 +               {  temp = eval_numeric(mpl, e->x);
279.3833 +                  if (value > temp) value = temp;
279.3834 +               }
279.3835 +            }
279.3836 +            break;
279.3837 +         case O_MAX:
279.3838 +            /* maximal value (n-ary) */
279.3839 +            {  ARG_LIST *e;
279.3840 +               double temp;
279.3841 +               value = -DBL_MAX;
279.3842 +               for (e = code->arg.list; e != NULL; e = e->next)
279.3843 +               {  temp = eval_numeric(mpl, e->x);
279.3844 +                  if (value < temp) value = temp;
279.3845 +               }
279.3846 +            }
279.3847 +            break;
279.3848 +         case O_SUM:
279.3849 +            /* summation over domain */
279.3850 +            {  struct iter_num_info _info, *info = &_info;
279.3851 +               info->code = code;
279.3852 +               info->value = 0.0;
279.3853 +               loop_within_domain(mpl, code->arg.loop.domain, info,
279.3854 +                  iter_num_func);
279.3855 +               value = info->value;
279.3856 +            }
279.3857 +            break;
279.3858 +         case O_PROD:
279.3859 +            /* multiplication over domain */
279.3860 +            {  struct iter_num_info _info, *info = &_info;
279.3861 +               info->code = code;
279.3862 +               info->value = 1.0;
279.3863 +               loop_within_domain(mpl, code->arg.loop.domain, info,
279.3864 +                  iter_num_func);
279.3865 +               value = info->value;
279.3866 +            }
279.3867 +            break;
279.3868 +         case O_MINIMUM:
279.3869 +            /* minimum over domain */
279.3870 +            {  struct iter_num_info _info, *info = &_info;
279.3871 +               info->code = code;
279.3872 +               info->value = +DBL_MAX;
279.3873 +               loop_within_domain(mpl, code->arg.loop.domain, info,
279.3874 +                  iter_num_func);
279.3875 +               if (info->value == +DBL_MAX)
279.3876 +                  error(mpl, "min{} over empty set; result undefined");
279.3877 +               value = info->value;
279.3878 +            }
279.3879 +            break;
279.3880 +         case O_MAXIMUM:
279.3881 +            /* maximum over domain */
279.3882 +            {  struct iter_num_info _info, *info = &_info;
279.3883 +               info->code = code;
279.3884 +               info->value = -DBL_MAX;
279.3885 +               loop_within_domain(mpl, code->arg.loop.domain, info,
279.3886 +                  iter_num_func);
279.3887 +               if (info->value == -DBL_MAX)
279.3888 +                  error(mpl, "max{} over empty set; result undefined");
279.3889 +               value = info->value;
279.3890 +            }
279.3891 +            break;
279.3892 +         default:
279.3893 +            xassert(code != code);
279.3894 +      }
279.3895 +      /* save resultant value */
279.3896 +      xassert(!code->valid);
279.3897 +      code->valid = 1;
279.3898 +      code->value.num = value;
279.3899 +done: return value;
279.3900 +}
279.3901 +
279.3902 +/*----------------------------------------------------------------------
279.3903 +-- eval_symbolic - evaluate pseudo-code to determine symbolic value.
279.3904 +--
279.3905 +-- This routine evaluates specified pseudo-code to determine resultant
279.3906 +-- symbolic value, which is returned on exit. */
279.3907 +
279.3908 +SYMBOL *eval_symbolic(MPL *mpl, CODE *code)
279.3909 +{     SYMBOL *value;
279.3910 +      xassert(code != NULL);
279.3911 +      xassert(code->type == A_SYMBOLIC);
279.3912 +      xassert(code->dim == 0);
279.3913 +      /* if the operation has a side effect, invalidate and delete the
279.3914 +         resultant value */
279.3915 +      if (code->vflag && code->valid)
279.3916 +      {  code->valid = 0;
279.3917 +         delete_value(mpl, code->type, &code->value);
279.3918 +      }
279.3919 +      /* if resultant value is valid, no evaluation is needed */
279.3920 +      if (code->valid)
279.3921 +      {  value = copy_symbol(mpl, code->value.sym);
279.3922 +         goto done;
279.3923 +      }
279.3924 +      /* evaluate pseudo-code recursively */
279.3925 +      switch (code->op)
279.3926 +      {  case O_STRING:
279.3927 +            /* take character string */
279.3928 +            value = create_symbol_str(mpl, create_string(mpl,
279.3929 +               code->arg.str));
279.3930 +            break;
279.3931 +         case O_INDEX:
279.3932 +            /* take dummy index */
279.3933 +            xassert(code->arg.index.slot->value != NULL);
279.3934 +            value = copy_symbol(mpl, code->arg.index.slot->value);
279.3935 +            break;
279.3936 +         case O_MEMSYM:
279.3937 +            /* take member of symbolic parameter */
279.3938 +            {  TUPLE *tuple;
279.3939 +               ARG_LIST *e;
279.3940 +               tuple = create_tuple(mpl);
279.3941 +               for (e = code->arg.par.list; e != NULL; e = e->next)
279.3942 +                  tuple = expand_tuple(mpl, tuple, eval_symbolic(mpl,
279.3943 +                     e->x));
279.3944 +               value = eval_member_sym(mpl, code->arg.par.par, tuple);
279.3945 +               delete_tuple(mpl, tuple);
279.3946 +            }
279.3947 +            break;
279.3948 +         case O_CVTSYM:
279.3949 +            /* conversion to symbolic */
279.3950 +            value = create_symbol_num(mpl, eval_numeric(mpl,
279.3951 +               code->arg.arg.x));
279.3952 +            break;
279.3953 +         case O_CONCAT:
279.3954 +            /* concatenation */
279.3955 +            value = concat_symbols(mpl,
279.3956 +               eval_symbolic(mpl, code->arg.arg.x),
279.3957 +               eval_symbolic(mpl, code->arg.arg.y));
279.3958 +            break;
279.3959 +         case O_FORK:
279.3960 +            /* if-then-else */
279.3961 +            if (eval_logical(mpl, code->arg.arg.x))
279.3962 +               value = eval_symbolic(mpl, code->arg.arg.y);
279.3963 +            else if (code->arg.arg.z == NULL)
279.3964 +               value = create_symbol_num(mpl, 0.0);
279.3965 +            else
279.3966 +               value = eval_symbolic(mpl, code->arg.arg.z);
279.3967 +            break;
279.3968 +         case O_SUBSTR:
279.3969 +         case O_SUBSTR3:
279.3970 +            {  double pos, len;
279.3971 +               char str[MAX_LENGTH+1];
279.3972 +               value = eval_symbolic(mpl, code->arg.arg.x);
279.3973 +               if (value->str == NULL)
279.3974 +                  sprintf(str, "%.*g", DBL_DIG, value->num);
279.3975 +               else
279.3976 +                  fetch_string(mpl, value->str, str);
279.3977 +               delete_symbol(mpl, value);
279.3978 +               if (code->op == O_SUBSTR)
279.3979 +               {  pos = eval_numeric(mpl, code->arg.arg.y);
279.3980 +                  if (pos != floor(pos))
279.3981 +                     error(mpl, "substr('...', %.*g); non-integer secon"
279.3982 +                        "d argument", DBL_DIG, pos);
279.3983 +                  if (pos < 1 || pos > strlen(str) + 1)
279.3984 +                     error(mpl, "substr('...', %.*g); substring out of "
279.3985 +                        "range", DBL_DIG, pos);
279.3986 +               }
279.3987 +               else
279.3988 +               {  pos = eval_numeric(mpl, code->arg.arg.y);
279.3989 +                  len = eval_numeric(mpl, code->arg.arg.z);
279.3990 +                  if (pos != floor(pos) || len != floor(len))
279.3991 +                     error(mpl, "substr('...', %.*g, %.*g); non-integer"
279.3992 +                        " second and/or third argument", DBL_DIG, pos,
279.3993 +                        DBL_DIG, len);
279.3994 +                  if (pos < 1 || len < 0 || pos + len > strlen(str) + 1)
279.3995 +                     error(mpl, "substr('...', %.*g, %.*g); substring o"
279.3996 +                        "ut of range", DBL_DIG, pos, DBL_DIG, len);
279.3997 +                  str[(int)pos + (int)len - 1] = '\0';
279.3998 +               }
279.3999 +               value = create_symbol_str(mpl, create_string(mpl, str +
279.4000 +                  (int)pos - 1));
279.4001 +            }
279.4002 +            break;
279.4003 +         case O_TIME2STR:
279.4004 +            {  double num;
279.4005 +               SYMBOL *sym;
279.4006 +               char str[MAX_LENGTH+1], fmt[MAX_LENGTH+1];
279.4007 +               num = eval_numeric(mpl, code->arg.arg.x);
279.4008 +               sym = eval_symbolic(mpl, code->arg.arg.y);
279.4009 +               if (sym->str == NULL)
279.4010 +                  sprintf(fmt, "%.*g", DBL_DIG, sym->num);
279.4011 +               else
279.4012 +                  fetch_string(mpl, sym->str, fmt);
279.4013 +               delete_symbol(mpl, sym);
279.4014 +               fn_time2str(mpl, str, num, fmt);
279.4015 +               value = create_symbol_str(mpl, create_string(mpl, str));
279.4016 +            }
279.4017 +            break;
279.4018 +         default:
279.4019 +            xassert(code != code);
279.4020 +      }
279.4021 +      /* save resultant value */
279.4022 +      xassert(!code->valid);
279.4023 +      code->valid = 1;
279.4024 +      code->value.sym = copy_symbol(mpl, value);
279.4025 +done: return value;
279.4026 +}
279.4027 +
279.4028 +/*----------------------------------------------------------------------
279.4029 +-- eval_logical - evaluate pseudo-code to determine logical value.
279.4030 +--
279.4031 +-- This routine evaluates specified pseudo-code to determine resultant
279.4032 +-- logical value, which is returned on exit. */
279.4033 +
279.4034 +struct iter_log_info
279.4035 +{     /* working info used by the routine iter_log_func */
279.4036 +      CODE *code;
279.4037 +      /* pseudo-code for iterated operation to be performed */
279.4038 +      int value;
279.4039 +      /* resultant value */
279.4040 +};
279.4041 +
279.4042 +static int iter_log_func(MPL *mpl, void *_info)
279.4043 +{     /* this is auxiliary routine used to perform iterated operation
279.4044 +         on logical "integrand" within domain scope */
279.4045 +      struct iter_log_info *info = _info;
279.4046 +      int ret = 0;
279.4047 +      switch (info->code->op)
279.4048 +      {  case O_FORALL:
279.4049 +            /* conjunction over domain */
279.4050 +            info->value &= eval_logical(mpl, info->code->arg.loop.x);
279.4051 +            if (!info->value) ret = 1;
279.4052 +            break;
279.4053 +         case O_EXISTS:
279.4054 +            /* disjunction over domain */
279.4055 +            info->value |= eval_logical(mpl, info->code->arg.loop.x);
279.4056 +            if (info->value) ret = 1;
279.4057 +            break;
279.4058 +         default:
279.4059 +            xassert(info != info);
279.4060 +      }
279.4061 +      return ret;
279.4062 +}
279.4063 +
279.4064 +int eval_logical(MPL *mpl, CODE *code)
279.4065 +{     int value;
279.4066 +      xassert(code->type == A_LOGICAL);
279.4067 +      xassert(code->dim == 0);
279.4068 +      /* if the operation has a side effect, invalidate and delete the
279.4069 +         resultant value */
279.4070 +      if (code->vflag && code->valid)
279.4071 +      {  code->valid = 0;
279.4072 +         delete_value(mpl, code->type, &code->value);
279.4073 +      }
279.4074 +      /* if resultant value is valid, no evaluation is needed */
279.4075 +      if (code->valid)
279.4076 +      {  value = code->value.bit;
279.4077 +         goto done;
279.4078 +      }
279.4079 +      /* evaluate pseudo-code recursively */
279.4080 +      switch (code->op)
279.4081 +      {  case O_CVTLOG:
279.4082 +            /* conversion to logical */
279.4083 +            value = (eval_numeric(mpl, code->arg.arg.x) != 0.0);
279.4084 +            break;
279.4085 +         case O_NOT:
279.4086 +            /* negation (logical "not") */
279.4087 +            value = !eval_logical(mpl, code->arg.arg.x);
279.4088 +            break;
279.4089 +         case O_LT:
279.4090 +            /* comparison on 'less than' */
279.4091 +#if 0 /* 02/VIII-2008 */
279.4092 +            value = (eval_numeric(mpl, code->arg.arg.x) <
279.4093 +                     eval_numeric(mpl, code->arg.arg.y));
279.4094 +#else
279.4095 +            xassert(code->arg.arg.x != NULL);
279.4096 +            if (code->arg.arg.x->type == A_NUMERIC)
279.4097 +               value = (eval_numeric(mpl, code->arg.arg.x) <
279.4098 +                        eval_numeric(mpl, code->arg.arg.y));
279.4099 +            else
279.4100 +            {  SYMBOL *sym1 = eval_symbolic(mpl, code->arg.arg.x);
279.4101 +               SYMBOL *sym2 = eval_symbolic(mpl, code->arg.arg.y);
279.4102 +               value = (compare_symbols(mpl, sym1, sym2) < 0);
279.4103 +               delete_symbol(mpl, sym1);
279.4104 +               delete_symbol(mpl, sym2);
279.4105 +            }
279.4106 +#endif
279.4107 +            break;
279.4108 +         case O_LE:
279.4109 +            /* comparison on 'not greater than' */
279.4110 +#if 0 /* 02/VIII-2008 */
279.4111 +            value = (eval_numeric(mpl, code->arg.arg.x) <=
279.4112 +                     eval_numeric(mpl, code->arg.arg.y));
279.4113 +#else
279.4114 +            xassert(code->arg.arg.x != NULL);
279.4115 +            if (code->arg.arg.x->type == A_NUMERIC)
279.4116 +               value = (eval_numeric(mpl, code->arg.arg.x) <=
279.4117 +                        eval_numeric(mpl, code->arg.arg.y));
279.4118 +            else
279.4119 +            {  SYMBOL *sym1 = eval_symbolic(mpl, code->arg.arg.x);
279.4120 +               SYMBOL *sym2 = eval_symbolic(mpl, code->arg.arg.y);
279.4121 +               value = (compare_symbols(mpl, sym1, sym2) <= 0);
279.4122 +               delete_symbol(mpl, sym1);
279.4123 +               delete_symbol(mpl, sym2);
279.4124 +            }
279.4125 +#endif
279.4126 +            break;
279.4127 +         case O_EQ:
279.4128 +            /* comparison on 'equal to' */
279.4129 +            xassert(code->arg.arg.x != NULL);
279.4130 +            if (code->arg.arg.x->type == A_NUMERIC)
279.4131 +               value = (eval_numeric(mpl, code->arg.arg.x) ==
279.4132 +                        eval_numeric(mpl, code->arg.arg.y));
279.4133 +            else
279.4134 +            {  SYMBOL *sym1 = eval_symbolic(mpl, code->arg.arg.x);
279.4135 +               SYMBOL *sym2 = eval_symbolic(mpl, code->arg.arg.y);
279.4136 +               value = (compare_symbols(mpl, sym1, sym2) == 0);
279.4137 +               delete_symbol(mpl, sym1);
279.4138 +               delete_symbol(mpl, sym2);
279.4139 +            }
279.4140 +            break;
279.4141 +         case O_GE:
279.4142 +            /* comparison on 'not less than' */
279.4143 +#if 0 /* 02/VIII-2008 */
279.4144 +            value = (eval_numeric(mpl, code->arg.arg.x) >=
279.4145 +                     eval_numeric(mpl, code->arg.arg.y));
279.4146 +#else
279.4147 +            xassert(code->arg.arg.x != NULL);
279.4148 +            if (code->arg.arg.x->type == A_NUMERIC)
279.4149 +               value = (eval_numeric(mpl, code->arg.arg.x) >=
279.4150 +                        eval_numeric(mpl, code->arg.arg.y));
279.4151 +            else
279.4152 +            {  SYMBOL *sym1 = eval_symbolic(mpl, code->arg.arg.x);
279.4153 +               SYMBOL *sym2 = eval_symbolic(mpl, code->arg.arg.y);
279.4154 +               value = (compare_symbols(mpl, sym1, sym2) >= 0);
279.4155 +               delete_symbol(mpl, sym1);
279.4156 +               delete_symbol(mpl, sym2);
279.4157 +            }
279.4158 +#endif
279.4159 +            break;
279.4160 +         case O_GT:
279.4161 +            /* comparison on 'greater than' */
279.4162 +#if 0 /* 02/VIII-2008 */
279.4163 +            value = (eval_numeric(mpl, code->arg.arg.x) >
279.4164 +                     eval_numeric(mpl, code->arg.arg.y));
279.4165 +#else
279.4166 +            xassert(code->arg.arg.x != NULL);
279.4167 +            if (code->arg.arg.x->type == A_NUMERIC)
279.4168 +               value = (eval_numeric(mpl, code->arg.arg.x) >
279.4169 +                        eval_numeric(mpl, code->arg.arg.y));
279.4170 +            else
279.4171 +            {  SYMBOL *sym1 = eval_symbolic(mpl, code->arg.arg.x);
279.4172 +               SYMBOL *sym2 = eval_symbolic(mpl, code->arg.arg.y);
279.4173 +               value = (compare_symbols(mpl, sym1, sym2) > 0);
279.4174 +               delete_symbol(mpl, sym1);
279.4175 +               delete_symbol(mpl, sym2);
279.4176 +            }
279.4177 +#endif
279.4178 +            break;
279.4179 +         case O_NE:
279.4180 +            /* comparison on 'not equal to' */
279.4181 +            xassert(code->arg.arg.x != NULL);
279.4182 +            if (code->arg.arg.x->type == A_NUMERIC)
279.4183 +               value = (eval_numeric(mpl, code->arg.arg.x) !=
279.4184 +                        eval_numeric(mpl, code->arg.arg.y));
279.4185 +            else
279.4186 +            {  SYMBOL *sym1 = eval_symbolic(mpl, code->arg.arg.x);
279.4187 +               SYMBOL *sym2 = eval_symbolic(mpl, code->arg.arg.y);
279.4188 +               value = (compare_symbols(mpl, sym1, sym2) != 0);
279.4189 +               delete_symbol(mpl, sym1);
279.4190 +               delete_symbol(mpl, sym2);
279.4191 +            }
279.4192 +            break;
279.4193 +         case O_AND:
279.4194 +            /* conjunction (logical "and") */
279.4195 +            value = eval_logical(mpl, code->arg.arg.x) &&
279.4196 +                    eval_logical(mpl, code->arg.arg.y);
279.4197 +            break;
279.4198 +         case O_OR:
279.4199 +            /* disjunction (logical "or") */
279.4200 +            value = eval_logical(mpl, code->arg.arg.x) ||
279.4201 +                    eval_logical(mpl, code->arg.arg.y);
279.4202 +            break;
279.4203 +         case O_IN:
279.4204 +            /* test on 'x in Y' */
279.4205 +            {  TUPLE *tuple;
279.4206 +               tuple = eval_tuple(mpl, code->arg.arg.x);
279.4207 +               value = is_member(mpl, code->arg.arg.y, tuple);
279.4208 +               delete_tuple(mpl, tuple);
279.4209 +            }
279.4210 +            break;
279.4211 +         case O_NOTIN:
279.4212 +            /* test on 'x not in Y' */
279.4213 +            {  TUPLE *tuple;
279.4214 +               tuple = eval_tuple(mpl, code->arg.arg.x);
279.4215 +               value = !is_member(mpl, code->arg.arg.y, tuple);
279.4216 +               delete_tuple(mpl, tuple);
279.4217 +            }
279.4218 +            break;
279.4219 +         case O_WITHIN:
279.4220 +            /* test on 'X within Y' */
279.4221 +            {  ELEMSET *set;
279.4222 +               MEMBER *memb;
279.4223 +               set = eval_elemset(mpl, code->arg.arg.x);
279.4224 +               value = 1;
279.4225 +               for (memb = set->head; memb != NULL; memb = memb->next)
279.4226 +               {  if (!is_member(mpl, code->arg.arg.y, memb->tuple))
279.4227 +                  {  value = 0;
279.4228 +                     break;
279.4229 +                  }
279.4230 +               }
279.4231 +               delete_elemset(mpl, set);
279.4232 +            }
279.4233 +            break;
279.4234 +         case O_NOTWITHIN:
279.4235 +            /* test on 'X not within Y' */
279.4236 +            {  ELEMSET *set;
279.4237 +               MEMBER *memb;
279.4238 +               set = eval_elemset(mpl, code->arg.arg.x);
279.4239 +               value = 1;
279.4240 +               for (memb = set->head; memb != NULL; memb = memb->next)
279.4241 +               {  if (is_member(mpl, code->arg.arg.y, memb->tuple))
279.4242 +                  {  value = 0;
279.4243 +                     break;
279.4244 +                  }
279.4245 +               }
279.4246 +               delete_elemset(mpl, set);
279.4247 +            }
279.4248 +            break;
279.4249 +         case O_FORALL:
279.4250 +            /* conjunction (A-quantification) */
279.4251 +            {  struct iter_log_info _info, *info = &_info;
279.4252 +               info->code = code;
279.4253 +               info->value = 1;
279.4254 +               loop_within_domain(mpl, code->arg.loop.domain, info,
279.4255 +                  iter_log_func);
279.4256 +               value = info->value;
279.4257 +            }
279.4258 +            break;
279.4259 +         case O_EXISTS:
279.4260 +            /* disjunction (E-quantification) */
279.4261 +            {  struct iter_log_info _info, *info = &_info;
279.4262 +               info->code = code;
279.4263 +               info->value = 0;
279.4264 +               loop_within_domain(mpl, code->arg.loop.domain, info,
279.4265 +                  iter_log_func);
279.4266 +               value = info->value;
279.4267 +            }
279.4268 +            break;
279.4269 +         default:
279.4270 +            xassert(code != code);
279.4271 +      }
279.4272 +      /* save resultant value */
279.4273 +      xassert(!code->valid);
279.4274 +      code->valid = 1;
279.4275 +      code->value.bit = value;
279.4276 +done: return value;
279.4277 +}
279.4278 +
279.4279 +/*----------------------------------------------------------------------
279.4280 +-- eval_tuple - evaluate pseudo-code to construct n-tuple.
279.4281 +--
279.4282 +-- This routine evaluates specified pseudo-code to construct resultant
279.4283 +-- n-tuple, which is returned on exit. */
279.4284 +
279.4285 +TUPLE *eval_tuple(MPL *mpl, CODE *code)
279.4286 +{     TUPLE *value;
279.4287 +      xassert(code != NULL);
279.4288 +      xassert(code->type == A_TUPLE);
279.4289 +      xassert(code->dim > 0);
279.4290 +      /* if the operation has a side effect, invalidate and delete the
279.4291 +         resultant value */
279.4292 +      if (code->vflag && code->valid)
279.4293 +      {  code->valid = 0;
279.4294 +         delete_value(mpl, code->type, &code->value);
279.4295 +      }
279.4296 +      /* if resultant value is valid, no evaluation is needed */
279.4297 +      if (code->valid)
279.4298 +      {  value = copy_tuple(mpl, code->value.tuple);
279.4299 +         goto done;
279.4300 +      }
279.4301 +      /* evaluate pseudo-code recursively */
279.4302 +      switch (code->op)
279.4303 +      {  case O_TUPLE:
279.4304 +            /* make n-tuple */
279.4305 +            {  ARG_LIST *e;
279.4306 +               value = create_tuple(mpl);
279.4307 +               for (e = code->arg.list; e != NULL; e = e->next)
279.4308 +                  value = expand_tuple(mpl, value, eval_symbolic(mpl,
279.4309 +                     e->x));
279.4310 +            }
279.4311 +            break;
279.4312 +         case O_CVTTUP:
279.4313 +            /* convert to 1-tuple */
279.4314 +            value = expand_tuple(mpl, create_tuple(mpl),
279.4315 +               eval_symbolic(mpl, code->arg.arg.x));
279.4316 +            break;
279.4317 +         default:
279.4318 +            xassert(code != code);
279.4319 +      }
279.4320 +      /* save resultant value */
279.4321 +      xassert(!code->valid);
279.4322 +      code->valid = 1;
279.4323 +      code->value.tuple = copy_tuple(mpl, value);
279.4324 +done: return value;
279.4325 +}
279.4326 +
279.4327 +/*----------------------------------------------------------------------
279.4328 +-- eval_elemset - evaluate pseudo-code to construct elemental set.
279.4329 +--
279.4330 +-- This routine evaluates specified pseudo-code to construct resultant
279.4331 +-- elemental set, which is returned on exit. */
279.4332 +
279.4333 +struct iter_set_info
279.4334 +{     /* working info used by the routine iter_set_func */
279.4335 +      CODE *code;
279.4336 +      /* pseudo-code for iterated operation to be performed */
279.4337 +      ELEMSET *value;
279.4338 +      /* resultant value */
279.4339 +};
279.4340 +
279.4341 +static int iter_set_func(MPL *mpl, void *_info)
279.4342 +{     /* this is auxiliary routine used to perform iterated operation
279.4343 +         on n-tuple "integrand" within domain scope */
279.4344 +      struct iter_set_info *info = _info;
279.4345 +      TUPLE *tuple;
279.4346 +      switch (info->code->op)
279.4347 +      {  case O_SETOF:
279.4348 +            /* compute next n-tuple and add it to the set; in this case
279.4349 +               duplicate n-tuples are silently ignored */
279.4350 +            tuple = eval_tuple(mpl, info->code->arg.loop.x);
279.4351 +            if (find_tuple(mpl, info->value, tuple) == NULL)
279.4352 +               add_tuple(mpl, info->value, tuple);
279.4353 +            else
279.4354 +               delete_tuple(mpl, tuple);
279.4355 +            break;
279.4356 +         case O_BUILD:
279.4357 +            /* construct next n-tuple using current values assigned to
279.4358 +               *free* dummy indices as its components and add it to the
279.4359 +               set; in this case duplicate n-tuples cannot appear */
279.4360 +            add_tuple(mpl, info->value, get_domain_tuple(mpl,
279.4361 +               info->code->arg.loop.domain));
279.4362 +            break;
279.4363 +         default:
279.4364 +            xassert(info != info);
279.4365 +      }
279.4366 +      return 0;
279.4367 +}
279.4368 +
279.4369 +ELEMSET *eval_elemset(MPL *mpl, CODE *code)
279.4370 +{     ELEMSET *value;
279.4371 +      xassert(code != NULL);
279.4372 +      xassert(code->type == A_ELEMSET);
279.4373 +      xassert(code->dim > 0);
279.4374 +      /* if the operation has a side effect, invalidate and delete the
279.4375 +         resultant value */
279.4376 +      if (code->vflag && code->valid)
279.4377 +      {  code->valid = 0;
279.4378 +         delete_value(mpl, code->type, &code->value);
279.4379 +      }
279.4380 +      /* if resultant value is valid, no evaluation is needed */
279.4381 +      if (code->valid)
279.4382 +      {  value = copy_elemset(mpl, code->value.set);
279.4383 +         goto done;
279.4384 +      }
279.4385 +      /* evaluate pseudo-code recursively */
279.4386 +      switch (code->op)
279.4387 +      {  case O_MEMSET:
279.4388 +            /* take member of set */
279.4389 +            {  TUPLE *tuple;
279.4390 +               ARG_LIST *e;
279.4391 +               tuple = create_tuple(mpl);
279.4392 +               for (e = code->arg.set.list; e != NULL; e = e->next)
279.4393 +                  tuple = expand_tuple(mpl, tuple, eval_symbolic(mpl,
279.4394 +                     e->x));
279.4395 +               value = copy_elemset(mpl,
279.4396 +                  eval_member_set(mpl, code->arg.set.set, tuple));
279.4397 +               delete_tuple(mpl, tuple);
279.4398 +            }
279.4399 +            break;
279.4400 +         case O_MAKE:
279.4401 +            /* make elemental set of n-tuples */
279.4402 +            {  ARG_LIST *e;
279.4403 +               value = create_elemset(mpl, code->dim);
279.4404 +               for (e = code->arg.list; e != NULL; e = e->next)
279.4405 +                  check_then_add(mpl, value, eval_tuple(mpl, e->x));
279.4406 +            }
279.4407 +            break;
279.4408 +         case O_UNION:
279.4409 +            /* union of two elemental sets */
279.4410 +            value = set_union(mpl,
279.4411 +               eval_elemset(mpl, code->arg.arg.x),
279.4412 +               eval_elemset(mpl, code->arg.arg.y));
279.4413 +            break;
279.4414 +         case O_DIFF:
279.4415 +            /* difference between two elemental sets */
279.4416 +            value = set_diff(mpl,
279.4417 +               eval_elemset(mpl, code->arg.arg.x),
279.4418 +               eval_elemset(mpl, code->arg.arg.y));
279.4419 +            break;
279.4420 +         case O_SYMDIFF:
279.4421 +            /* symmetric difference between two elemental sets */
279.4422 +            value = set_symdiff(mpl,
279.4423 +               eval_elemset(mpl, code->arg.arg.x),
279.4424 +               eval_elemset(mpl, code->arg.arg.y));
279.4425 +            break;
279.4426 +         case O_INTER:
279.4427 +            /* intersection of two elemental sets */
279.4428 +            value = set_inter(mpl,
279.4429 +               eval_elemset(mpl, code->arg.arg.x),
279.4430 +               eval_elemset(mpl, code->arg.arg.y));
279.4431 +            break;
279.4432 +         case O_CROSS:
279.4433 +            /* cross (Cartesian) product of two elemental sets */
279.4434 +            value = set_cross(mpl,
279.4435 +               eval_elemset(mpl, code->arg.arg.x),
279.4436 +               eval_elemset(mpl, code->arg.arg.y));
279.4437 +            break;
279.4438 +         case O_DOTS:
279.4439 +            /* build "arithmetic" elemental set */
279.4440 +            value = create_arelset(mpl,
279.4441 +               eval_numeric(mpl, code->arg.arg.x),
279.4442 +               eval_numeric(mpl, code->arg.arg.y),
279.4443 +               code->arg.arg.z == NULL ? 1.0 : eval_numeric(mpl,
279.4444 +                  code->arg.arg.z));
279.4445 +            break;
279.4446 +         case O_FORK:
279.4447 +            /* if-then-else */
279.4448 +            if (eval_logical(mpl, code->arg.arg.x))
279.4449 +               value = eval_elemset(mpl, code->arg.arg.y);
279.4450 +            else
279.4451 +               value = eval_elemset(mpl, code->arg.arg.z);
279.4452 +            break;
279.4453 +         case O_SETOF:
279.4454 +            /* compute elemental set */
279.4455 +            {  struct iter_set_info _info, *info = &_info;
279.4456 +               info->code = code;
279.4457 +               info->value = create_elemset(mpl, code->dim);
279.4458 +               loop_within_domain(mpl, code->arg.loop.domain, info,
279.4459 +                  iter_set_func);
279.4460 +               value = info->value;
279.4461 +            }
279.4462 +            break;
279.4463 +         case O_BUILD:
279.4464 +            /* build elemental set identical to domain set */
279.4465 +            {  struct iter_set_info _info, *info = &_info;
279.4466 +               info->code = code;
279.4467 +               info->value = create_elemset(mpl, code->dim);
279.4468 +               loop_within_domain(mpl, code->arg.loop.domain, info,
279.4469 +                  iter_set_func);
279.4470 +               value = info->value;
279.4471 +            }
279.4472 +            break;
279.4473 +         default:
279.4474 +            xassert(code != code);
279.4475 +      }
279.4476 +      /* save resultant value */
279.4477 +      xassert(!code->valid);
279.4478 +      code->valid = 1;
279.4479 +      code->value.set = copy_elemset(mpl, value);
279.4480 +done: return value;
279.4481 +}
279.4482 +
279.4483 +/*----------------------------------------------------------------------
279.4484 +-- is_member - check if n-tuple is in set specified by pseudo-code.
279.4485 +--
279.4486 +-- This routine checks if given n-tuple is a member of elemental set
279.4487 +-- specified in the form of pseudo-code (i.e. by expression).
279.4488 +--
279.4489 +-- The n-tuple may have more components that dimension of the elemental
279.4490 +-- set, in which case the extra components are ignored. */
279.4491 +
279.4492 +static void null_func(MPL *mpl, void *info)
279.4493 +{     /* this is dummy routine used to enter the domain scope */
279.4494 +      xassert(mpl == mpl);
279.4495 +      xassert(info == NULL);
279.4496 +      return;
279.4497 +}
279.4498 +
279.4499 +int is_member(MPL *mpl, CODE *code, TUPLE *tuple)
279.4500 +{     int value;
279.4501 +      xassert(code != NULL);
279.4502 +      xassert(code->type == A_ELEMSET);
279.4503 +      xassert(code->dim > 0);
279.4504 +      xassert(tuple != NULL);
279.4505 +      switch (code->op)
279.4506 +      {  case O_MEMSET:
279.4507 +            /* check if given n-tuple is member of elemental set, which
279.4508 +               is assigned to member of model set */
279.4509 +            {  ARG_LIST *e;
279.4510 +               TUPLE *temp;
279.4511 +               ELEMSET *set;
279.4512 +               /* evaluate reference to elemental set */
279.4513 +               temp = create_tuple(mpl);
279.4514 +               for (e = code->arg.set.list; e != NULL; e = e->next)
279.4515 +                  temp = expand_tuple(mpl, temp, eval_symbolic(mpl,
279.4516 +                     e->x));
279.4517 +               set = eval_member_set(mpl, code->arg.set.set, temp);
279.4518 +               delete_tuple(mpl, temp);
279.4519 +               /* check if the n-tuple is contained in the set array */
279.4520 +               temp = build_subtuple(mpl, tuple, set->dim);
279.4521 +               value = (find_tuple(mpl, set, temp) != NULL);
279.4522 +               delete_tuple(mpl, temp);
279.4523 +            }
279.4524 +            break;
279.4525 +         case O_MAKE:
279.4526 +            /* check if given n-tuple is member of literal set */
279.4527 +            {  ARG_LIST *e;
279.4528 +               TUPLE *temp, *that;
279.4529 +               value = 0;
279.4530 +               temp = build_subtuple(mpl, tuple, code->dim);
279.4531 +               for (e = code->arg.list; e != NULL; e = e->next)
279.4532 +               {  that = eval_tuple(mpl, e->x);
279.4533 +                  value = (compare_tuples(mpl, temp, that) == 0);
279.4534 +                  delete_tuple(mpl, that);
279.4535 +                  if (value) break;
279.4536 +               }
279.4537 +               delete_tuple(mpl, temp);
279.4538 +            }
279.4539 +            break;
279.4540 +         case O_UNION:
279.4541 +            value = is_member(mpl, code->arg.arg.x, tuple) ||
279.4542 +                    is_member(mpl, code->arg.arg.y, tuple);
279.4543 +            break;
279.4544 +         case O_DIFF:
279.4545 +            value = is_member(mpl, code->arg.arg.x, tuple) &&
279.4546 +                   !is_member(mpl, code->arg.arg.y, tuple);
279.4547 +            break;
279.4548 +         case O_SYMDIFF:
279.4549 +            {  int in1 = is_member(mpl, code->arg.arg.x, tuple);
279.4550 +               int in2 = is_member(mpl, code->arg.arg.y, tuple);
279.4551 +               value = (in1 && !in2) || (!in1 && in2);
279.4552 +            }
279.4553 +            break;
279.4554 +         case O_INTER:
279.4555 +            value = is_member(mpl, code->arg.arg.x, tuple) &&
279.4556 +                    is_member(mpl, code->arg.arg.y, tuple);
279.4557 +            break;
279.4558 +         case O_CROSS:
279.4559 +            {  int j;
279.4560 +               value = is_member(mpl, code->arg.arg.x, tuple);
279.4561 +               if (value)
279.4562 +               {  for (j = 1; j <= code->arg.arg.x->dim; j++)
279.4563 +                  {  xassert(tuple != NULL);
279.4564 +                     tuple = tuple->next;
279.4565 +                  }
279.4566 +                  value = is_member(mpl, code->arg.arg.y, tuple);
279.4567 +               }
279.4568 +            }
279.4569 +            break;
279.4570 +         case O_DOTS:
279.4571 +            /* check if given 1-tuple is member of "arithmetic" set */
279.4572 +            {  int j;
279.4573 +               double x, t0, tf, dt;
279.4574 +               xassert(code->dim == 1);
279.4575 +               /* compute "parameters" of the "arithmetic" set */
279.4576 +               t0 = eval_numeric(mpl, code->arg.arg.x);
279.4577 +               tf = eval_numeric(mpl, code->arg.arg.y);
279.4578 +               if (code->arg.arg.z == NULL)
279.4579 +                  dt = 1.0;
279.4580 +               else
279.4581 +                  dt = eval_numeric(mpl, code->arg.arg.z);
279.4582 +               /* make sure the parameters are correct */
279.4583 +               arelset_size(mpl, t0, tf, dt);
279.4584 +               /* if component of 1-tuple is symbolic, not numeric, the
279.4585 +                  1-tuple cannot be member of "arithmetic" set */
279.4586 +               xassert(tuple->sym != NULL);
279.4587 +               if (tuple->sym->str != NULL)
279.4588 +               {  value = 0;
279.4589 +                  break;
279.4590 +               }
279.4591 +               /* determine numeric value of the component */
279.4592 +               x = tuple->sym->num;
279.4593 +               /* if the component value is out of the set range, the
279.4594 +                  1-tuple is not in the set */
279.4595 +               if (dt > 0.0 && !(t0 <= x && x <= tf) ||
279.4596 +                   dt < 0.0 && !(tf <= x && x <= t0))
279.4597 +               {  value = 0;
279.4598 +                  break;
279.4599 +               }
279.4600 +               /* estimate ordinal number of the 1-tuple in the set */
279.4601 +               j = (int)(((x - t0) / dt) + 0.5) + 1;
279.4602 +               /* perform the main check */
279.4603 +               value = (arelset_member(mpl, t0, tf, dt, j) == x);
279.4604 +            }
279.4605 +            break;
279.4606 +         case O_FORK:
279.4607 +            /* check if given n-tuple is member of conditional set */
279.4608 +            if (eval_logical(mpl, code->arg.arg.x))
279.4609 +               value = is_member(mpl, code->arg.arg.y, tuple);
279.4610 +            else
279.4611 +               value = is_member(mpl, code->arg.arg.z, tuple);
279.4612 +            break;
279.4613 +         case O_SETOF:
279.4614 +            /* check if given n-tuple is member of computed set */
279.4615 +            /* it is not clear how to efficiently perform the check not
279.4616 +               computing the entire elemental set :+( */
279.4617 +            error(mpl, "implementation restriction; in/within setof{} n"
279.4618 +               "ot allowed");
279.4619 +            break;
279.4620 +         case O_BUILD:
279.4621 +            /* check if given n-tuple is member of domain set */
279.4622 +            {  TUPLE *temp;
279.4623 +               temp = build_subtuple(mpl, tuple, code->dim);
279.4624 +               /* try to enter the domain scope; if it is successful,
279.4625 +                  the n-tuple is in the domain set */
279.4626 +               value = (eval_within_domain(mpl, code->arg.loop.domain,
279.4627 +                  temp, NULL, null_func) == 0);
279.4628 +               delete_tuple(mpl, temp);
279.4629 +            }
279.4630 +            break;
279.4631 +         default:
279.4632 +            xassert(code != code);
279.4633 +      }
279.4634 +      return value;
279.4635 +}
279.4636 +
279.4637 +/*----------------------------------------------------------------------
279.4638 +-- eval_formula - evaluate pseudo-code to construct linear form.
279.4639 +--
279.4640 +-- This routine evaluates specified pseudo-code to construct resultant
279.4641 +-- linear form, which is returned on exit. */
279.4642 +
279.4643 +struct iter_form_info
279.4644 +{     /* working info used by the routine iter_form_func */
279.4645 +      CODE *code;
279.4646 +      /* pseudo-code for iterated operation to be performed */
279.4647 +      FORMULA *value;
279.4648 +      /* resultant value */
279.4649 +      FORMULA *tail;
279.4650 +      /* pointer to the last term */
279.4651 +};
279.4652 +
279.4653 +static int iter_form_func(MPL *mpl, void *_info)
279.4654 +{     /* this is auxiliary routine used to perform iterated operation
279.4655 +         on linear form "integrand" within domain scope */
279.4656 +      struct iter_form_info *info = _info;
279.4657 +      switch (info->code->op)
279.4658 +      {  case O_SUM:
279.4659 +            /* summation over domain */
279.4660 +#if 0
279.4661 +            info->value =
279.4662 +               linear_comb(mpl,
279.4663 +                  +1.0, info->value,
279.4664 +                  +1.0, eval_formula(mpl, info->code->arg.loop.x));
279.4665 +#else
279.4666 +            /* the routine linear_comb needs to look through all terms
279.4667 +               of both linear forms to reduce identical terms, so using
279.4668 +               it here is not a good idea (for example, evaluation of
279.4669 +               sum{i in 1..n} x[i] required quadratic time); the better
279.4670 +               idea is to gather all terms of the integrand in one list
279.4671 +               and reduce identical terms only once after all terms of
279.4672 +               the resultant linear form have been evaluated */
279.4673 +            {  FORMULA *form, *term;
279.4674 +               form = eval_formula(mpl, info->code->arg.loop.x);
279.4675 +               if (info->value == NULL)
279.4676 +               {  xassert(info->tail == NULL);
279.4677 +                  info->value = form;
279.4678 +               }
279.4679 +               else
279.4680 +               {  xassert(info->tail != NULL);
279.4681 +                  info->tail->next = form;
279.4682 +               }
279.4683 +               for (term = form; term != NULL; term = term->next)
279.4684 +                  info->tail = term;
279.4685 +            }
279.4686 +#endif
279.4687 +            break;
279.4688 +         default:
279.4689 +            xassert(info != info);
279.4690 +      }
279.4691 +      return 0;
279.4692 +}
279.4693 +
279.4694 +FORMULA *eval_formula(MPL *mpl, CODE *code)
279.4695 +{     FORMULA *value;
279.4696 +      xassert(code != NULL);
279.4697 +      xassert(code->type == A_FORMULA);
279.4698 +      xassert(code->dim == 0);
279.4699 +      /* if the operation has a side effect, invalidate and delete the
279.4700 +         resultant value */
279.4701 +      if (code->vflag && code->valid)
279.4702 +      {  code->valid = 0;
279.4703 +         delete_value(mpl, code->type, &code->value);
279.4704 +      }
279.4705 +      /* if resultant value is valid, no evaluation is needed */
279.4706 +      if (code->valid)
279.4707 +      {  value = copy_formula(mpl, code->value.form);
279.4708 +         goto done;
279.4709 +      }
279.4710 +      /* evaluate pseudo-code recursively */
279.4711 +      switch (code->op)
279.4712 +      {  case O_MEMVAR:
279.4713 +            /* take member of variable */
279.4714 +            {  TUPLE *tuple;
279.4715 +               ARG_LIST *e;
279.4716 +               tuple = create_tuple(mpl);
279.4717 +               for (e = code->arg.var.list; e != NULL; e = e->next)
279.4718 +                  tuple = expand_tuple(mpl, tuple, eval_symbolic(mpl,
279.4719 +                     e->x));
279.4720 +#if 1 /* 15/V-2010 */
279.4721 +               xassert(code->arg.var.suff == DOT_NONE);
279.4722 +#endif
279.4723 +               value = single_variable(mpl,
279.4724 +                  eval_member_var(mpl, code->arg.var.var, tuple));
279.4725 +               delete_tuple(mpl, tuple);
279.4726 +            }
279.4727 +            break;
279.4728 +         case O_CVTLFM:
279.4729 +            /* convert to linear form */
279.4730 +            value = constant_term(mpl, eval_numeric(mpl,
279.4731 +               code->arg.arg.x));
279.4732 +            break;
279.4733 +         case O_PLUS:
279.4734 +            /* unary plus */
279.4735 +            value = linear_comb(mpl,
279.4736 +                0.0, constant_term(mpl, 0.0),
279.4737 +               +1.0, eval_formula(mpl, code->arg.arg.x));
279.4738 +            break;
279.4739 +         case O_MINUS:
279.4740 +            /* unary minus */
279.4741 +            value = linear_comb(mpl,
279.4742 +                0.0, constant_term(mpl, 0.0),
279.4743 +               -1.0, eval_formula(mpl, code->arg.arg.x));
279.4744 +            break;
279.4745 +         case O_ADD:
279.4746 +            /* addition */
279.4747 +            value = linear_comb(mpl,
279.4748 +               +1.0, eval_formula(mpl, code->arg.arg.x),
279.4749 +               +1.0, eval_formula(mpl, code->arg.arg.y));
279.4750 +            break;
279.4751 +         case O_SUB:
279.4752 +            /* subtraction */
279.4753 +            value = linear_comb(mpl,
279.4754 +               +1.0, eval_formula(mpl, code->arg.arg.x),
279.4755 +               -1.0, eval_formula(mpl, code->arg.arg.y));
279.4756 +            break;
279.4757 +         case O_MUL:
279.4758 +            /* multiplication */
279.4759 +            xassert(code->arg.arg.x != NULL);
279.4760 +            xassert(code->arg.arg.y != NULL);
279.4761 +            if (code->arg.arg.x->type == A_NUMERIC)
279.4762 +            {  xassert(code->arg.arg.y->type == A_FORMULA);
279.4763 +               value = linear_comb(mpl,
279.4764 +                  eval_numeric(mpl, code->arg.arg.x),
279.4765 +                  eval_formula(mpl, code->arg.arg.y),
279.4766 +                  0.0, constant_term(mpl, 0.0));
279.4767 +            }
279.4768 +            else
279.4769 +            {  xassert(code->arg.arg.x->type == A_FORMULA);
279.4770 +               xassert(code->arg.arg.y->type == A_NUMERIC);
279.4771 +               value = linear_comb(mpl,
279.4772 +                  eval_numeric(mpl, code->arg.arg.y),
279.4773 +                  eval_formula(mpl, code->arg.arg.x),
279.4774 +                  0.0, constant_term(mpl, 0.0));
279.4775 +            }
279.4776 +            break;
279.4777 +         case O_DIV:
279.4778 +            /* division */
279.4779 +            value = linear_comb(mpl,
279.4780 +               fp_div(mpl, 1.0, eval_numeric(mpl, code->arg.arg.y)),
279.4781 +               eval_formula(mpl, code->arg.arg.x),
279.4782 +               0.0, constant_term(mpl, 0.0));
279.4783 +            break;
279.4784 +         case O_FORK:
279.4785 +            /* if-then-else */
279.4786 +            if (eval_logical(mpl, code->arg.arg.x))
279.4787 +               value = eval_formula(mpl, code->arg.arg.y);
279.4788 +            else if (code->arg.arg.z == NULL)
279.4789 +               value = constant_term(mpl, 0.0);
279.4790 +            else
279.4791 +               value = eval_formula(mpl, code->arg.arg.z);
279.4792 +            break;
279.4793 +         case O_SUM:
279.4794 +            /* summation over domain */
279.4795 +            {  struct iter_form_info _info, *info = &_info;
279.4796 +               info->code = code;
279.4797 +               info->value = constant_term(mpl, 0.0);
279.4798 +               info->tail = NULL;
279.4799 +               loop_within_domain(mpl, code->arg.loop.domain, info,
279.4800 +                  iter_form_func);
279.4801 +               value = reduce_terms(mpl, info->value);
279.4802 +            }
279.4803 +            break;
279.4804 +         default:
279.4805 +            xassert(code != code);
279.4806 +      }
279.4807 +      /* save resultant value */
279.4808 +      xassert(!code->valid);
279.4809 +      code->valid = 1;
279.4810 +      code->value.form = copy_formula(mpl, value);
279.4811 +done: return value;
279.4812 +}
279.4813 +
279.4814 +/*----------------------------------------------------------------------
279.4815 +-- clean_code - clean pseudo-code.
279.4816 +--
279.4817 +-- This routine recursively cleans specified pseudo-code that assumes
279.4818 +-- deleting all temporary resultant values. */
279.4819 +
279.4820 +void clean_code(MPL *mpl, CODE *code)
279.4821 +{     ARG_LIST *e;
279.4822 +      /* if no pseudo-code is specified, do nothing */
279.4823 +      if (code == NULL) goto done;
279.4824 +      /* if resultant value is valid (exists), delete it */
279.4825 +      if (code->valid)
279.4826 +      {  code->valid = 0;
279.4827 +         delete_value(mpl, code->type, &code->value);
279.4828 +      }
279.4829 +      /* recursively clean pseudo-code for operands */
279.4830 +      switch (code->op)
279.4831 +      {  case O_NUMBER:
279.4832 +         case O_STRING:
279.4833 +         case O_INDEX:
279.4834 +            break;
279.4835 +         case O_MEMNUM:
279.4836 +         case O_MEMSYM:
279.4837 +            for (e = code->arg.par.list; e != NULL; e = e->next)
279.4838 +               clean_code(mpl, e->x);
279.4839 +            break;
279.4840 +         case O_MEMSET:
279.4841 +            for (e = code->arg.set.list; e != NULL; e = e->next)
279.4842 +               clean_code(mpl, e->x);
279.4843 +            break;
279.4844 +         case O_MEMVAR:
279.4845 +            for (e = code->arg.var.list; e != NULL; e = e->next)
279.4846 +               clean_code(mpl, e->x);
279.4847 +            break;
279.4848 +#if 1 /* 15/V-2010 */
279.4849 +         case O_MEMCON:
279.4850 +            for (e = code->arg.con.list; e != NULL; e = e->next)
279.4851 +               clean_code(mpl, e->x);
279.4852 +            break;
279.4853 +#endif
279.4854 +         case O_TUPLE:
279.4855 +         case O_MAKE:
279.4856 +            for (e = code->arg.list; e != NULL; e = e->next)
279.4857 +               clean_code(mpl, e->x);
279.4858 +            break;
279.4859 +         case O_SLICE:
279.4860 +            xassert(code != code);
279.4861 +         case O_IRAND224:
279.4862 +         case O_UNIFORM01:
279.4863 +         case O_NORMAL01:
279.4864 +         case O_GMTIME:
279.4865 +            break;
279.4866 +         case O_CVTNUM:
279.4867 +         case O_CVTSYM:
279.4868 +         case O_CVTLOG:
279.4869 +         case O_CVTTUP:
279.4870 +         case O_CVTLFM:
279.4871 +         case O_PLUS:
279.4872 +         case O_MINUS:
279.4873 +         case O_NOT:
279.4874 +         case O_ABS:
279.4875 +         case O_CEIL:
279.4876 +         case O_FLOOR:
279.4877 +         case O_EXP:
279.4878 +         case O_LOG:
279.4879 +         case O_LOG10:
279.4880 +         case O_SQRT:
279.4881 +         case O_SIN:
279.4882 +         case O_COS:
279.4883 +         case O_ATAN:
279.4884 +         case O_ROUND:
279.4885 +         case O_TRUNC:
279.4886 +         case O_CARD:
279.4887 +         case O_LENGTH:
279.4888 +            /* unary operation */
279.4889 +            clean_code(mpl, code->arg.arg.x);
279.4890 +            break;
279.4891 +         case O_ADD:
279.4892 +         case O_SUB:
279.4893 +         case O_LESS:
279.4894 +         case O_MUL:
279.4895 +         case O_DIV:
279.4896 +         case O_IDIV:
279.4897 +         case O_MOD:
279.4898 +         case O_POWER:
279.4899 +         case O_ATAN2:
279.4900 +         case O_ROUND2:
279.4901 +         case O_TRUNC2:
279.4902 +         case O_UNIFORM:
279.4903 +         case O_NORMAL:
279.4904 +         case O_CONCAT:
279.4905 +         case O_LT:
279.4906 +         case O_LE:
279.4907 +         case O_EQ:
279.4908 +         case O_GE:
279.4909 +         case O_GT:
279.4910 +         case O_NE:
279.4911 +         case O_AND:
279.4912 +         case O_OR:
279.4913 +         case O_UNION:
279.4914 +         case O_DIFF:
279.4915 +         case O_SYMDIFF:
279.4916 +         case O_INTER:
279.4917 +         case O_CROSS:
279.4918 +         case O_IN:
279.4919 +         case O_NOTIN:
279.4920 +         case O_WITHIN:
279.4921 +         case O_NOTWITHIN:
279.4922 +         case O_SUBSTR:
279.4923 +         case O_STR2TIME:
279.4924 +         case O_TIME2STR:
279.4925 +            /* binary operation */
279.4926 +            clean_code(mpl, code->arg.arg.x);
279.4927 +            clean_code(mpl, code->arg.arg.y);
279.4928 +            break;
279.4929 +         case O_DOTS:
279.4930 +         case O_FORK:
279.4931 +         case O_SUBSTR3:
279.4932 +            /* ternary operation */
279.4933 +            clean_code(mpl, code->arg.arg.x);
279.4934 +            clean_code(mpl, code->arg.arg.y);
279.4935 +            clean_code(mpl, code->arg.arg.z);
279.4936 +            break;
279.4937 +         case O_MIN:
279.4938 +         case O_MAX:
279.4939 +            /* n-ary operation */
279.4940 +            for (e = code->arg.list; e != NULL; e = e->next)
279.4941 +               clean_code(mpl, e->x);
279.4942 +            break;
279.4943 +         case O_SUM:
279.4944 +         case O_PROD:
279.4945 +         case O_MINIMUM:
279.4946 +         case O_MAXIMUM:
279.4947 +         case O_FORALL:
279.4948 +         case O_EXISTS:
279.4949 +         case O_SETOF:
279.4950 +         case O_BUILD:
279.4951 +            /* iterated operation */
279.4952 +            clean_domain(mpl, code->arg.loop.domain);
279.4953 +            clean_code(mpl, code->arg.loop.x);
279.4954 +            break;
279.4955 +         default:
279.4956 +            xassert(code->op != code->op);
279.4957 +      }
279.4958 +done: return;
279.4959 +}
279.4960 +
279.4961 +#if 1 /* 11/II-2008 */
279.4962 +/**********************************************************************/
279.4963 +/* * *                        DATA TABLES                         * * */
279.4964 +/**********************************************************************/
279.4965 +
279.4966 +int mpl_tab_num_args(TABDCA *dca)
279.4967 +{     /* returns the number of arguments */
279.4968 +      return dca->na;
279.4969 +}
279.4970 +
279.4971 +const char *mpl_tab_get_arg(TABDCA *dca, int k)
279.4972 +{     /* returns pointer to k-th argument */
279.4973 +      xassert(1 <= k && k <= dca->na);
279.4974 +      return dca->arg[k];
279.4975 +}
279.4976 +
279.4977 +int mpl_tab_num_flds(TABDCA *dca)
279.4978 +{     /* returns the number of fields */
279.4979 +      return dca->nf;
279.4980 +}
279.4981 +
279.4982 +const char *mpl_tab_get_name(TABDCA *dca, int k)
279.4983 +{     /* returns pointer to name of k-th field */
279.4984 +      xassert(1 <= k && k <= dca->nf);
279.4985 +      return dca->name[k];
279.4986 +}
279.4987 +
279.4988 +int mpl_tab_get_type(TABDCA *dca, int k)
279.4989 +{     /* returns type of k-th field */
279.4990 +      xassert(1 <= k && k <= dca->nf);
279.4991 +      return dca->type[k];
279.4992 +}
279.4993 +
279.4994 +double mpl_tab_get_num(TABDCA *dca, int k)
279.4995 +{     /* returns numeric value of k-th field */
279.4996 +      xassert(1 <= k && k <= dca->nf);
279.4997 +      xassert(dca->type[k] == 'N');
279.4998 +      return dca->num[k];
279.4999 +}
279.5000 +
279.5001 +const char *mpl_tab_get_str(TABDCA *dca, int k)
279.5002 +{     /* returns pointer to string value of k-th field */
279.5003 +      xassert(1 <= k && k <= dca->nf);
279.5004 +      xassert(dca->type[k] == 'S');
279.5005 +      xassert(dca->str[k] != NULL);
279.5006 +      return dca->str[k];
279.5007 +}
279.5008 +
279.5009 +void mpl_tab_set_num(TABDCA *dca, int k, double num)
279.5010 +{     /* assign numeric value to k-th field */
279.5011 +      xassert(1 <= k && k <= dca->nf);
279.5012 +      xassert(dca->type[k] == '?');
279.5013 +      dca->type[k] = 'N';
279.5014 +      dca->num[k] = num;
279.5015 +      return;
279.5016 +}
279.5017 +
279.5018 +void mpl_tab_set_str(TABDCA *dca, int k, const char *str)
279.5019 +{     /* assign string value to k-th field */
279.5020 +      xassert(1 <= k && k <= dca->nf);
279.5021 +      xassert(dca->type[k] == '?');
279.5022 +      xassert(strlen(str) <= MAX_LENGTH);
279.5023 +      xassert(dca->str[k] != NULL);
279.5024 +      dca->type[k] = 'S';
279.5025 +      strcpy(dca->str[k], str);
279.5026 +      return;
279.5027 +}
279.5028 +
279.5029 +static int write_func(MPL *mpl, void *info)
279.5030 +{     /* this is auxiliary routine to work within domain scope */
279.5031 +      TABLE *tab = info;
279.5032 +      TABDCA *dca = mpl->dca;
279.5033 +      TABOUT *out;
279.5034 +      SYMBOL *sym;
279.5035 +      int k;
279.5036 +      char buf[MAX_LENGTH+1];
279.5037 +      /* evaluate field values */
279.5038 +      k = 0;
279.5039 +      for (out = tab->u.out.list; out != NULL; out = out->next)
279.5040 +      {  k++;
279.5041 +         switch (out->code->type)
279.5042 +         {  case A_NUMERIC:
279.5043 +               dca->type[k] = 'N';
279.5044 +               dca->num[k] = eval_numeric(mpl, out->code);
279.5045 +               dca->str[k][0] = '\0';
279.5046 +               break;
279.5047 +            case A_SYMBOLIC:
279.5048 +               sym = eval_symbolic(mpl, out->code);
279.5049 +               if (sym->str == NULL)
279.5050 +               {  dca->type[k] = 'N';
279.5051 +                  dca->num[k] = sym->num;
279.5052 +                  dca->str[k][0] = '\0';
279.5053 +               }
279.5054 +               else
279.5055 +               {  dca->type[k] = 'S';
279.5056 +                  dca->num[k] = 0.0;
279.5057 +                  fetch_string(mpl, sym->str, buf);
279.5058 +                  strcpy(dca->str[k], buf);
279.5059 +               }
279.5060 +               delete_symbol(mpl, sym);
279.5061 +               break;
279.5062 +            default:
279.5063 +               xassert(out != out);
279.5064 +         }
279.5065 +      }
279.5066 +      /* write record to output table */
279.5067 +      mpl_tab_drv_write(mpl);
279.5068 +      return 0;
279.5069 +}
279.5070 +
279.5071 +void execute_table(MPL *mpl, TABLE *tab)
279.5072 +{     /* execute table statement */
279.5073 +      TABARG *arg;
279.5074 +      TABFLD *fld;
279.5075 +      TABIN *in;
279.5076 +      TABOUT *out;
279.5077 +      TABDCA *dca;
279.5078 +      SET *set;
279.5079 +      int k;
279.5080 +      char buf[MAX_LENGTH+1];
279.5081 +      /* allocate table driver communication area */
279.5082 +      xassert(mpl->dca == NULL);
279.5083 +      mpl->dca = dca = xmalloc(sizeof(TABDCA));
279.5084 +      dca->id = 0;
279.5085 +      dca->link = NULL;
279.5086 +      dca->na = 0;
279.5087 +      dca->arg = NULL;
279.5088 +      dca->nf = 0;
279.5089 +      dca->name = NULL;
279.5090 +      dca->type = NULL;
279.5091 +      dca->num = NULL;
279.5092 +      dca->str = NULL;
279.5093 +      /* allocate arguments */
279.5094 +      xassert(dca->na == 0);
279.5095 +      for (arg = tab->arg; arg != NULL; arg = arg->next)
279.5096 +         dca->na++;
279.5097 +      dca->arg = xcalloc(1+dca->na, sizeof(char *));
279.5098 +#if 1 /* 28/IX-2008 */
279.5099 +      for (k = 1; k <= dca->na; k++) dca->arg[k] = NULL;
279.5100 +#endif
279.5101 +      /* evaluate argument values */
279.5102 +      k = 0;
279.5103 +      for (arg = tab->arg; arg != NULL; arg = arg->next)
279.5104 +      {  SYMBOL *sym;
279.5105 +         k++;
279.5106 +         xassert(arg->code->type == A_SYMBOLIC);
279.5107 +         sym = eval_symbolic(mpl, arg->code);
279.5108 +         if (sym->str == NULL)
279.5109 +            sprintf(buf, "%.*g", DBL_DIG, sym->num);
279.5110 +         else
279.5111 +            fetch_string(mpl, sym->str, buf);
279.5112 +         delete_symbol(mpl, sym);
279.5113 +         dca->arg[k] = xmalloc(strlen(buf)+1);
279.5114 +         strcpy(dca->arg[k], buf);
279.5115 +      }
279.5116 +      /* perform table input/output */
279.5117 +      switch (tab->type)
279.5118 +      {  case A_INPUT:  goto read_table;
279.5119 +         case A_OUTPUT: goto write_table;
279.5120 +         default:       xassert(tab != tab);
279.5121 +      }
279.5122 +read_table:
279.5123 +      /* read data from input table */
279.5124 +      /* add the only member to the control set and assign it empty
279.5125 +         elemental set */
279.5126 +      set = tab->u.in.set;
279.5127 +      if (set != NULL)
279.5128 +      {  if (set->data)
279.5129 +            error(mpl, "%s already provided with data", set->name);
279.5130 +         xassert(set->array->head == NULL);
279.5131 +         add_member(mpl, set->array, NULL)->value.set =
279.5132 +            create_elemset(mpl, set->dimen);
279.5133 +         set->data = 1;
279.5134 +      }
279.5135 +      /* check parameters specified in the input list */
279.5136 +      for (in = tab->u.in.list; in != NULL; in = in->next)
279.5137 +      {  if (in->par->data)
279.5138 +            error(mpl, "%s already provided with data", in->par->name);
279.5139 +         in->par->data = 1;
279.5140 +      }
279.5141 +      /* allocate and initialize fields */
279.5142 +      xassert(dca->nf == 0);
279.5143 +      for (fld = tab->u.in.fld; fld != NULL; fld = fld->next)
279.5144 +         dca->nf++;
279.5145 +      for (in = tab->u.in.list; in != NULL; in = in->next)
279.5146 +         dca->nf++;
279.5147 +      dca->name = xcalloc(1+dca->nf, sizeof(char *));
279.5148 +      dca->type = xcalloc(1+dca->nf, sizeof(int));
279.5149 +      dca->num = xcalloc(1+dca->nf, sizeof(double));
279.5150 +      dca->str = xcalloc(1+dca->nf, sizeof(char *));
279.5151 +      k = 0;
279.5152 +      for (fld = tab->u.in.fld; fld != NULL; fld = fld->next)
279.5153 +      {  k++;
279.5154 +         dca->name[k] = fld->name;
279.5155 +         dca->type[k] = '?';
279.5156 +         dca->num[k] = 0.0;
279.5157 +         dca->str[k] = xmalloc(MAX_LENGTH+1);
279.5158 +         dca->str[k][0] = '\0';
279.5159 +      }
279.5160 +      for (in = tab->u.in.list; in != NULL; in = in->next)
279.5161 +      {  k++;
279.5162 +         dca->name[k] = in->name;
279.5163 +         dca->type[k] = '?';
279.5164 +         dca->num[k] = 0.0;
279.5165 +         dca->str[k] = xmalloc(MAX_LENGTH+1);
279.5166 +         dca->str[k][0] = '\0';
279.5167 +      }
279.5168 +      /* open input table */
279.5169 +      mpl_tab_drv_open(mpl, 'R');
279.5170 +      /* read and process records */
279.5171 +      for (;;)
279.5172 +      {  TUPLE *tup;
279.5173 +         /* reset field types */
279.5174 +         for (k = 1; k <= dca->nf; k++)
279.5175 +            dca->type[k] = '?';
279.5176 +         /* read next record */
279.5177 +         if (mpl_tab_drv_read(mpl)) break;
279.5178 +         /* all fields must be set by the driver */
279.5179 +         for (k = 1; k <= dca->nf; k++)
279.5180 +         {  if (dca->type[k] == '?')
279.5181 +               error(mpl, "field %s missing in input table",
279.5182 +                  dca->name[k]);
279.5183 +         }
279.5184 +         /* construct n-tuple */
279.5185 +         tup = create_tuple(mpl);
279.5186 +         k = 0;
279.5187 +         for (fld = tab->u.in.fld; fld != NULL; fld = fld->next)
279.5188 +         {  k++;
279.5189 +            xassert(k <= dca->nf);
279.5190 +            switch (dca->type[k])
279.5191 +            {  case 'N':
279.5192 +                  tup = expand_tuple(mpl, tup, create_symbol_num(mpl,
279.5193 +                     dca->num[k]));
279.5194 +                  break;
279.5195 +               case 'S':
279.5196 +                  xassert(strlen(dca->str[k]) <= MAX_LENGTH);
279.5197 +                  tup = expand_tuple(mpl, tup, create_symbol_str(mpl,
279.5198 +                     create_string(mpl, dca->str[k])));
279.5199 +                  break;
279.5200 +               default:
279.5201 +                  xassert(dca != dca);
279.5202 +            }
279.5203 +         }
279.5204 +         /* add n-tuple just read to the control set */
279.5205 +         if (tab->u.in.set != NULL)
279.5206 +            check_then_add(mpl, tab->u.in.set->array->head->value.set,
279.5207 +               copy_tuple(mpl, tup));
279.5208 +         /* assign values to the parameters in the input list */
279.5209 +         for (in = tab->u.in.list; in != NULL; in = in->next)
279.5210 +         {  MEMBER *memb;
279.5211 +            k++;
279.5212 +            xassert(k <= dca->nf);
279.5213 +            /* there must be no member with the same n-tuple */
279.5214 +            if (find_member(mpl, in->par->array, tup) != NULL)
279.5215 +               error(mpl, "%s%s already defined", in->par->name,
279.5216 +               format_tuple(mpl, '[', tup));
279.5217 +            /* create new parameter member with given n-tuple */
279.5218 +            memb = add_member(mpl, in->par->array, copy_tuple(mpl, tup))
279.5219 +               ;
279.5220 +            /* assign value to the parameter member */
279.5221 +            switch (in->par->type)
279.5222 +            {  case A_NUMERIC:
279.5223 +               case A_INTEGER:
279.5224 +               case A_BINARY:
279.5225 +                  if (dca->type[k] != 'N')
279.5226 +                     error(mpl, "%s requires numeric data",
279.5227 +                        in->par->name);
279.5228 +                  memb->value.num = dca->num[k];
279.5229 +                  break;
279.5230 +               case A_SYMBOLIC:
279.5231 +                  switch (dca->type[k])
279.5232 +                  {  case 'N':
279.5233 +                        memb->value.sym = create_symbol_num(mpl,
279.5234 +                           dca->num[k]);
279.5235 +                        break;
279.5236 +                     case 'S':
279.5237 +                        xassert(strlen(dca->str[k]) <= MAX_LENGTH);
279.5238 +                        memb->value.sym = create_symbol_str(mpl,
279.5239 +                           create_string(mpl,dca->str[k]));
279.5240 +                        break;
279.5241 +                     default:
279.5242 +                        xassert(dca != dca);
279.5243 +                  }
279.5244 +                  break;
279.5245 +               default:
279.5246 +                  xassert(in != in);
279.5247 +            }
279.5248 +         }
279.5249 +         /* n-tuple is no more needed */
279.5250 +         delete_tuple(mpl, tup);
279.5251 +      }
279.5252 +      /* close input table */
279.5253 +      mpl_tab_drv_close(mpl);
279.5254 +      goto done;
279.5255 +write_table:
279.5256 +      /* write data to output table */
279.5257 +      /* allocate and initialize fields */
279.5258 +      xassert(dca->nf == 0);
279.5259 +      for (out = tab->u.out.list; out != NULL; out = out->next)
279.5260 +         dca->nf++;
279.5261 +      dca->name = xcalloc(1+dca->nf, sizeof(char *));
279.5262 +      dca->type = xcalloc(1+dca->nf, sizeof(int));
279.5263 +      dca->num = xcalloc(1+dca->nf, sizeof(double));
279.5264 +      dca->str = xcalloc(1+dca->nf, sizeof(char *));
279.5265 +      k = 0;
279.5266 +      for (out = tab->u.out.list; out != NULL; out = out->next)
279.5267 +      {  k++;
279.5268 +         dca->name[k] = out->name;
279.5269 +         dca->type[k] = '?';
279.5270 +         dca->num[k] = 0.0;
279.5271 +         dca->str[k] = xmalloc(MAX_LENGTH+1);
279.5272 +         dca->str[k][0] = '\0';
279.5273 +      }
279.5274 +      /* open output table */
279.5275 +      mpl_tab_drv_open(mpl, 'W');
279.5276 +      /* evaluate fields and write records */
279.5277 +      loop_within_domain(mpl, tab->u.out.domain, tab, write_func);
279.5278 +      /* close output table */
279.5279 +      mpl_tab_drv_close(mpl);
279.5280 +done: /* free table driver communication area */
279.5281 +      free_dca(mpl);
279.5282 +      return;
279.5283 +}
279.5284 +
279.5285 +void free_dca(MPL *mpl)
279.5286 +{     /* free table driver communucation area */
279.5287 +      TABDCA *dca = mpl->dca;
279.5288 +      int k;
279.5289 +      if (dca != NULL)
279.5290 +      {  if (dca->link != NULL)
279.5291 +            mpl_tab_drv_close(mpl);
279.5292 +         if (dca->arg != NULL)
279.5293 +         {  for (k = 1; k <= dca->na; k++)
279.5294 +#if 1 /* 28/IX-2008 */
279.5295 +               if (dca->arg[k] != NULL)
279.5296 +#endif
279.5297 +               xfree(dca->arg[k]);
279.5298 +            xfree(dca->arg);
279.5299 +         }
279.5300 +         if (dca->name != NULL) xfree(dca->name);
279.5301 +         if (dca->type != NULL) xfree(dca->type);
279.5302 +         if (dca->num != NULL) xfree(dca->num);
279.5303 +         if (dca->str != NULL)
279.5304 +         {  for (k = 1; k <= dca->nf; k++)
279.5305 +               xfree(dca->str[k]);
279.5306 +            xfree(dca->str);
279.5307 +         }
279.5308 +         xfree(dca), mpl->dca = NULL;
279.5309 +      }
279.5310 +      return;
279.5311 +}
279.5312 +
279.5313 +void clean_table(MPL *mpl, TABLE *tab)
279.5314 +{     /* clean table statement */
279.5315 +      TABARG *arg;
279.5316 +      TABOUT *out;
279.5317 +      /* clean string list */
279.5318 +      for (arg = tab->arg; arg != NULL; arg = arg->next)
279.5319 +         clean_code(mpl, arg->code);
279.5320 +      switch (tab->type)
279.5321 +      {  case A_INPUT:
279.5322 +            break;
279.5323 +         case A_OUTPUT:
279.5324 +            /* clean subscript domain */
279.5325 +            clean_domain(mpl, tab->u.out.domain);
279.5326 +            /* clean output list */
279.5327 +            for (out = tab->u.out.list; out != NULL; out = out->next)
279.5328 +               clean_code(mpl, out->code);
279.5329 +            break;
279.5330 +         default:
279.5331 +            xassert(tab != tab);
279.5332 +      }
279.5333 +      return;
279.5334 +}
279.5335 +#endif
279.5336 +
279.5337 +/**********************************************************************/
279.5338 +/* * *                      MODEL STATEMENTS                      * * */
279.5339 +/**********************************************************************/
279.5340 +
279.5341 +/*----------------------------------------------------------------------
279.5342 +-- execute_check - execute check statement.
279.5343 +--
279.5344 +-- This routine executes specified check statement. */
279.5345 +
279.5346 +static int check_func(MPL *mpl, void *info)
279.5347 +{     /* this is auxiliary routine to work within domain scope */
279.5348 +      CHECK *chk = (CHECK *)info;
279.5349 +      if (!eval_logical(mpl, chk->code))
279.5350 +         error(mpl, "check%s failed", format_tuple(mpl, '[',
279.5351 +            get_domain_tuple(mpl, chk->domain)));
279.5352 +      return 0;
279.5353 +}
279.5354 +
279.5355 +void execute_check(MPL *mpl, CHECK *chk)
279.5356 +{     loop_within_domain(mpl, chk->domain, chk, check_func);
279.5357 +      return;
279.5358 +}
279.5359 +
279.5360 +/*----------------------------------------------------------------------
279.5361 +-- clean_check - clean check statement.
279.5362 +--
279.5363 +-- This routine cleans specified check statement that assumes deleting
279.5364 +-- all stuff dynamically allocated on generating/postsolving phase. */
279.5365 +
279.5366 +void clean_check(MPL *mpl, CHECK *chk)
279.5367 +{     /* clean subscript domain */
279.5368 +      clean_domain(mpl, chk->domain);
279.5369 +      /* clean pseudo-code for computing predicate */
279.5370 +      clean_code(mpl, chk->code);
279.5371 +      return;
279.5372 +}
279.5373 +
279.5374 +/*----------------------------------------------------------------------
279.5375 +-- execute_display - execute display statement.
279.5376 +--
279.5377 +-- This routine executes specified display statement. */
279.5378 +
279.5379 +static void display_set(MPL *mpl, SET *set, MEMBER *memb)
279.5380 +{     /* display member of model set */
279.5381 +      ELEMSET *s = memb->value.set;
279.5382 +      MEMBER *m;
279.5383 +      write_text(mpl, "%s%s%s\n", set->name,
279.5384 +         format_tuple(mpl, '[', memb->tuple),
279.5385 +         s->head == NULL ? " is empty" : ":");
279.5386 +      for (m = s->head; m != NULL; m = m->next)
279.5387 +         write_text(mpl, "   %s\n", format_tuple(mpl, '(', m->tuple));
279.5388 +      return;
279.5389 +}
279.5390 +
279.5391 +static void display_par(MPL *mpl, PARAMETER *par, MEMBER *memb)
279.5392 +{     /* display member of model parameter */
279.5393 +      switch (par->type)
279.5394 +      {  case A_NUMERIC:
279.5395 +         case A_INTEGER:
279.5396 +         case A_BINARY:
279.5397 +            write_text(mpl, "%s%s = %.*g\n", par->name,
279.5398 +               format_tuple(mpl, '[', memb->tuple),
279.5399 +               DBL_DIG, memb->value.num);
279.5400 +            break;
279.5401 +         case A_SYMBOLIC:
279.5402 +            write_text(mpl, "%s%s = %s\n", par->name,
279.5403 +               format_tuple(mpl, '[', memb->tuple),
279.5404 +               format_symbol(mpl, memb->value.sym));
279.5405 +            break;
279.5406 +         default:
279.5407 +            xassert(par != par);
279.5408 +      }
279.5409 +      return;
279.5410 +}
279.5411 +
279.5412 +#if 1 /* 15/V-2010 */
279.5413 +static void display_var(MPL *mpl, VARIABLE *var, MEMBER *memb,
279.5414 +      int suff)
279.5415 +{     /* display member of model variable */
279.5416 +      if (suff == DOT_NONE || suff == DOT_VAL)
279.5417 +         write_text(mpl, "%s%s.val = %.*g\n", var->name,
279.5418 +            format_tuple(mpl, '[', memb->tuple), DBL_DIG,
279.5419 +            memb->value.var->prim);
279.5420 +      else if (suff == DOT_LB)
279.5421 +         write_text(mpl, "%s%s.lb = %.*g\n", var->name,
279.5422 +            format_tuple(mpl, '[', memb->tuple), DBL_DIG,
279.5423 +            memb->value.var->var->lbnd == NULL ? -DBL_MAX :
279.5424 +            memb->value.var->lbnd);
279.5425 +      else if (suff == DOT_UB)
279.5426 +         write_text(mpl, "%s%s.ub = %.*g\n", var->name,
279.5427 +            format_tuple(mpl, '[', memb->tuple), DBL_DIG,
279.5428 +            memb->value.var->var->ubnd == NULL ? +DBL_MAX :
279.5429 +            memb->value.var->ubnd);
279.5430 +      else if (suff == DOT_STATUS)
279.5431 +         write_text(mpl, "%s%s.status = %d\n", var->name, format_tuple
279.5432 +            (mpl, '[', memb->tuple), memb->value.var->stat);
279.5433 +      else if (suff == DOT_DUAL)
279.5434 +         write_text(mpl, "%s%s.dual = %.*g\n", var->name,
279.5435 +            format_tuple(mpl, '[', memb->tuple), DBL_DIG,
279.5436 +            memb->value.var->dual);
279.5437 +      else
279.5438 +         xassert(suff != suff);
279.5439 +      return;
279.5440 +}
279.5441 +#endif
279.5442 +
279.5443 +#if 1 /* 15/V-2010 */
279.5444 +static void display_con(MPL *mpl, CONSTRAINT *con, MEMBER *memb,
279.5445 +      int suff)
279.5446 +{     /* display member of model constraint */
279.5447 +      if (suff == DOT_NONE || suff == DOT_VAL)
279.5448 +         write_text(mpl, "%s%s.val = %.*g\n", con->name,
279.5449 +            format_tuple(mpl, '[', memb->tuple), DBL_DIG,
279.5450 +            memb->value.con->prim);
279.5451 +      else if (suff == DOT_LB)
279.5452 +         write_text(mpl, "%s%s.lb = %.*g\n", con->name,
279.5453 +            format_tuple(mpl, '[', memb->tuple), DBL_DIG,
279.5454 +            memb->value.con->con->lbnd == NULL ? -DBL_MAX :
279.5455 +            memb->value.con->lbnd);
279.5456 +      else if (suff == DOT_UB)
279.5457 +         write_text(mpl, "%s%s.ub = %.*g\n", con->name,
279.5458 +            format_tuple(mpl, '[', memb->tuple), DBL_DIG,
279.5459 +            memb->value.con->con->ubnd == NULL ? +DBL_MAX :
279.5460 +            memb->value.con->ubnd);
279.5461 +      else if (suff == DOT_STATUS)
279.5462 +         write_text(mpl, "%s%s.status = %d\n", con->name, format_tuple
279.5463 +            (mpl, '[', memb->tuple), memb->value.con->stat);
279.5464 +      else if (suff == DOT_DUAL)
279.5465 +         write_text(mpl, "%s%s.dual = %.*g\n", con->name,
279.5466 +            format_tuple(mpl, '[', memb->tuple), DBL_DIG,
279.5467 +            memb->value.con->dual);
279.5468 +      else
279.5469 +         xassert(suff != suff);
279.5470 +      return;
279.5471 +}
279.5472 +#endif
279.5473 +
279.5474 +static void display_memb(MPL *mpl, CODE *code)
279.5475 +{     /* display member specified by pseudo-code */
279.5476 +      MEMBER memb;
279.5477 +      ARG_LIST *e;
279.5478 +      xassert(code->op == O_MEMNUM || code->op == O_MEMSYM
279.5479 +         || code->op == O_MEMSET || code->op == O_MEMVAR
279.5480 +         || code->op == O_MEMCON);
279.5481 +      memb.tuple = create_tuple(mpl);
279.5482 +      for (e = code->arg.par.list; e != NULL; e = e->next)
279.5483 +         memb.tuple = expand_tuple(mpl, memb.tuple, eval_symbolic(mpl,
279.5484 +            e->x));
279.5485 +      switch (code->op)
279.5486 +      {  case O_MEMNUM:
279.5487 +            memb.value.num = eval_member_num(mpl, code->arg.par.par,
279.5488 +               memb.tuple);
279.5489 +            display_par(mpl, code->arg.par.par, &memb);
279.5490 +            break;
279.5491 +         case O_MEMSYM:
279.5492 +            memb.value.sym = eval_member_sym(mpl, code->arg.par.par,
279.5493 +               memb.tuple);
279.5494 +            display_par(mpl, code->arg.par.par, &memb);
279.5495 +            delete_symbol(mpl, memb.value.sym);
279.5496 +            break;
279.5497 +         case O_MEMSET:
279.5498 +            memb.value.set = eval_member_set(mpl, code->arg.set.set,
279.5499 +               memb.tuple);
279.5500 +            display_set(mpl, code->arg.set.set, &memb);
279.5501 +            break;
279.5502 +         case O_MEMVAR:
279.5503 +            memb.value.var = eval_member_var(mpl, code->arg.var.var,
279.5504 +               memb.tuple);
279.5505 +            display_var
279.5506 +               (mpl, code->arg.var.var, &memb, code->arg.var.suff);
279.5507 +            break;
279.5508 +         case O_MEMCON:
279.5509 +            memb.value.con = eval_member_con(mpl, code->arg.con.con,
279.5510 +               memb.tuple);
279.5511 +            display_con
279.5512 +               (mpl, code->arg.con.con, &memb, code->arg.con.suff);
279.5513 +            break;
279.5514 +         default:
279.5515 +            xassert(code != code);
279.5516 +      }
279.5517 +      delete_tuple(mpl, memb.tuple);
279.5518 +      return;
279.5519 +}
279.5520 +
279.5521 +static void display_code(MPL *mpl, CODE *code)
279.5522 +{     /* display value of expression */
279.5523 +      switch (code->type)
279.5524 +      {  case A_NUMERIC:
279.5525 +            /* numeric value */
279.5526 +            {  double num;
279.5527 +               num = eval_numeric(mpl, code);
279.5528 +               write_text(mpl, "%.*g\n", DBL_DIG, num);
279.5529 +            }
279.5530 +            break;
279.5531 +         case A_SYMBOLIC:
279.5532 +            /* symbolic value */
279.5533 +            {  SYMBOL *sym;
279.5534 +               sym = eval_symbolic(mpl, code);
279.5535 +               write_text(mpl, "%s\n", format_symbol(mpl, sym));
279.5536 +               delete_symbol(mpl, sym);
279.5537 +            }
279.5538 +            break;
279.5539 +         case A_LOGICAL:
279.5540 +            /* logical value */
279.5541 +            {  int bit;
279.5542 +               bit = eval_logical(mpl, code);
279.5543 +               write_text(mpl, "%s\n", bit ? "true" : "false");
279.5544 +            }
279.5545 +            break;
279.5546 +         case A_TUPLE:
279.5547 +            /* n-tuple */
279.5548 +            {  TUPLE *tuple;
279.5549 +               tuple = eval_tuple(mpl, code);
279.5550 +               write_text(mpl, "%s\n", format_tuple(mpl, '(', tuple));
279.5551 +               delete_tuple(mpl, tuple);
279.5552 +            }
279.5553 +            break;
279.5554 +         case A_ELEMSET:
279.5555 +            /* elemental set */
279.5556 +            {  ELEMSET *set;
279.5557 +               MEMBER *memb;
279.5558 +               set = eval_elemset(mpl, code);
279.5559 +               if (set->head == 0)
279.5560 +                  write_text(mpl, "set is empty\n");
279.5561 +               for (memb = set->head; memb != NULL; memb = memb->next)
279.5562 +                  write_text(mpl, "   %s\n", format_tuple(mpl, '(',
279.5563 +                     memb->tuple));
279.5564 +               delete_elemset(mpl, set);
279.5565 +            }
279.5566 +            break;
279.5567 +         case A_FORMULA:
279.5568 +            /* linear form */
279.5569 +            {  FORMULA *form, *term;
279.5570 +               form = eval_formula(mpl, code);
279.5571 +               if (form == NULL)
279.5572 +                  write_text(mpl, "linear form is empty\n");
279.5573 +               for (term = form; term != NULL; term = term->next)
279.5574 +               {  if (term->var == NULL)
279.5575 +                     write_text(mpl, "   %.*g\n", term->coef);
279.5576 +                  else
279.5577 +                     write_text(mpl, "   %.*g %s%s\n", DBL_DIG,
279.5578 +                        term->coef, term->var->var->name,
279.5579 +                        format_tuple(mpl, '[', term->var->memb->tuple));
279.5580 +               }
279.5581 +               delete_formula(mpl, form);
279.5582 +            }
279.5583 +            break;
279.5584 +         default:
279.5585 +            xassert(code != code);
279.5586 +      }
279.5587 +      return;
279.5588 +}
279.5589 +
279.5590 +static int display_func(MPL *mpl, void *info)
279.5591 +{     /* this is auxiliary routine to work within domain scope */
279.5592 +      DISPLAY *dpy = (DISPLAY *)info;
279.5593 +      DISPLAY1 *entry;
279.5594 +      for (entry = dpy->list; entry != NULL; entry = entry->next)
279.5595 +      {  if (entry->type == A_INDEX)
279.5596 +         {  /* dummy index */
279.5597 +            DOMAIN_SLOT *slot = entry->u.slot;
279.5598 +            write_text(mpl, "%s = %s\n", slot->name,
279.5599 +            format_symbol(mpl, slot->value));
279.5600 +         }
279.5601 +         else if (entry->type == A_SET)
279.5602 +         {  /* model set */
279.5603 +            SET *set = entry->u.set;
279.5604 +            MEMBER *memb;
279.5605 +            if (set->assign != NULL)
279.5606 +            {  /* the set has assignment expression; evaluate all its
279.5607 +                  members over entire domain */
279.5608 +               eval_whole_set(mpl, set);
279.5609 +            }
279.5610 +            else
279.5611 +            {  /* the set has no assignment expression; refer to its
279.5612 +                  any existing member ignoring resultant value to check
279.5613 +                  the data provided the data section */
279.5614 +#if 1 /* 12/XII-2008 */
279.5615 +               if (set->gadget != NULL && set->data == 0)
279.5616 +               {  /* initialize the set with data from a plain set */
279.5617 +                  saturate_set(mpl, set);
279.5618 +               }
279.5619 +#endif
279.5620 +               if (set->array->head != NULL)
279.5621 +                  eval_member_set(mpl, set, set->array->head->tuple);
279.5622 +            }
279.5623 +            /* display all members of the set array */
279.5624 +            if (set->array->head == NULL)
279.5625 +               write_text(mpl, "%s has empty content\n", set->name);
279.5626 +            for (memb = set->array->head; memb != NULL; memb =
279.5627 +               memb->next) display_set(mpl, set, memb);
279.5628 +         }
279.5629 +         else if (entry->type == A_PARAMETER)
279.5630 +         {  /* model parameter */
279.5631 +            PARAMETER *par = entry->u.par;
279.5632 +            MEMBER *memb;
279.5633 +            if (par->assign != NULL)
279.5634 +            {  /* the parameter has an assignment expression; evaluate
279.5635 +                  all its member over entire domain */
279.5636 +               eval_whole_par(mpl, par);
279.5637 +            }
279.5638 +            else
279.5639 +            {  /* the parameter has no assignment expression; refer to
279.5640 +                  its any existing member ignoring resultant value to
279.5641 +                  check the data provided in the data section */
279.5642 +               if (par->array->head != NULL)
279.5643 +               {  if (par->type != A_SYMBOLIC)
279.5644 +                     eval_member_num(mpl, par, par->array->head->tuple);
279.5645 +                  else
279.5646 +                     delete_symbol(mpl, eval_member_sym(mpl, par,
279.5647 +                        par->array->head->tuple));
279.5648 +               }
279.5649 +            }
279.5650 +            /* display all members of the parameter array */
279.5651 +            if (par->array->head == NULL)
279.5652 +               write_text(mpl, "%s has empty content\n", par->name);
279.5653 +            for (memb = par->array->head; memb != NULL; memb =
279.5654 +               memb->next) display_par(mpl, par, memb);
279.5655 +         }
279.5656 +         else if (entry->type == A_VARIABLE)
279.5657 +         {  /* model variable */
279.5658 +            VARIABLE *var = entry->u.var;
279.5659 +            MEMBER *memb;
279.5660 +            xassert(mpl->flag_p);
279.5661 +            /* display all members of the variable array */
279.5662 +            if (var->array->head == NULL)
279.5663 +               write_text(mpl, "%s has empty content\n", var->name);
279.5664 +            for (memb = var->array->head; memb != NULL; memb =
279.5665 +               memb->next) display_var(mpl, var, memb, DOT_NONE);
279.5666 +         }
279.5667 +         else if (entry->type == A_CONSTRAINT)
279.5668 +         {  /* model constraint */
279.5669 +            CONSTRAINT *con = entry->u.con;
279.5670 +            MEMBER *memb;
279.5671 +            xassert(mpl->flag_p);
279.5672 +            /* display all members of the constraint array */
279.5673 +            if (con->array->head == NULL)
279.5674 +               write_text(mpl, "%s has empty content\n", con->name);
279.5675 +            for (memb = con->array->head; memb != NULL; memb =
279.5676 +               memb->next) display_con(mpl, con, memb, DOT_NONE);
279.5677 +         }
279.5678 +         else if (entry->type == A_EXPRESSION)
279.5679 +         {  /* expression */
279.5680 +            CODE *code = entry->u.code;
279.5681 +            if (code->op == O_MEMNUM || code->op == O_MEMSYM ||
279.5682 +                code->op == O_MEMSET || code->op == O_MEMVAR ||
279.5683 +                code->op == O_MEMCON)
279.5684 +               display_memb(mpl, code);
279.5685 +            else
279.5686 +               display_code(mpl, code);
279.5687 +         }
279.5688 +         else
279.5689 +            xassert(entry != entry);
279.5690 +      }
279.5691 +      return 0;
279.5692 +}
279.5693 +
279.5694 +void execute_display(MPL *mpl, DISPLAY *dpy)
279.5695 +{     loop_within_domain(mpl, dpy->domain, dpy, display_func);
279.5696 +      return;
279.5697 +}
279.5698 +
279.5699 +/*----------------------------------------------------------------------
279.5700 +-- clean_display - clean display statement.
279.5701 +--
279.5702 +-- This routine cleans specified display statement that assumes deleting
279.5703 +-- all stuff dynamically allocated on generating/postsolving phase. */
279.5704 +
279.5705 +void clean_display(MPL *mpl, DISPLAY *dpy)
279.5706 +{     DISPLAY1 *d;
279.5707 +#if 0 /* 15/V-2010 */
279.5708 +      ARG_LIST *e;
279.5709 +#endif
279.5710 +      /* clean subscript domain */
279.5711 +      clean_domain(mpl, dpy->domain);
279.5712 +      /* clean display list */
279.5713 +      for (d = dpy->list; d != NULL; d = d->next)
279.5714 +      {  /* clean pseudo-code for computing expression */
279.5715 +         if (d->type == A_EXPRESSION)
279.5716 +            clean_code(mpl, d->u.code);
279.5717 +#if 0 /* 15/V-2010 */
279.5718 +         /* clean pseudo-code for computing subscripts */
279.5719 +         for (e = d->list; e != NULL; e = e->next)
279.5720 +            clean_code(mpl, e->x);
279.5721 +#endif
279.5722 +      }
279.5723 +      return;
279.5724 +}
279.5725 +
279.5726 +/*----------------------------------------------------------------------
279.5727 +-- execute_printf - execute printf statement.
279.5728 +--
279.5729 +-- This routine executes specified printf statement. */
279.5730 +
279.5731 +#if 1 /* 14/VII-2006 */
279.5732 +static void print_char(MPL *mpl, int c)
279.5733 +{     if (mpl->prt_fp == NULL)
279.5734 +         write_char(mpl, c);
279.5735 +      else
279.5736 +         xfputc(c, mpl->prt_fp);
279.5737 +      return;
279.5738 +}
279.5739 +
279.5740 +static void print_text(MPL *mpl, char *fmt, ...)
279.5741 +{     va_list arg;
279.5742 +      char buf[OUTBUF_SIZE], *c;
279.5743 +      va_start(arg, fmt);
279.5744 +      vsprintf(buf, fmt, arg);
279.5745 +      xassert(strlen(buf) < sizeof(buf));
279.5746 +      va_end(arg);
279.5747 +      for (c = buf; *c != '\0'; c++) print_char(mpl, *c);
279.5748 +      return;
279.5749 +}
279.5750 +#endif
279.5751 +
279.5752 +static int printf_func(MPL *mpl, void *info)
279.5753 +{     /* this is auxiliary routine to work within domain scope */
279.5754 +      PRINTF *prt = (PRINTF *)info;
279.5755 +      PRINTF1 *entry;
279.5756 +      SYMBOL *sym;
279.5757 +      char fmt[MAX_LENGTH+1], *c, *from, save;
279.5758 +      /* evaluate format control string */
279.5759 +      sym = eval_symbolic(mpl, prt->fmt);
279.5760 +      if (sym->str == NULL)
279.5761 +         sprintf(fmt, "%.*g", DBL_DIG, sym->num);
279.5762 +      else
279.5763 +         fetch_string(mpl, sym->str, fmt);
279.5764 +      delete_symbol(mpl, sym);
279.5765 +      /* scan format control string and perform formatting output */
279.5766 +      entry = prt->list;
279.5767 +      for (c = fmt; *c != '\0'; c++)
279.5768 +      {  if (*c == '%')
279.5769 +         {  /* scan format specifier */
279.5770 +            from = c++;
279.5771 +            if (*c == '%')
279.5772 +            {  print_char(mpl, '%');
279.5773 +               continue;
279.5774 +            }
279.5775 +            if (entry == NULL) break;
279.5776 +            /* scan optional flags */
279.5777 +            while (*c == '-' || *c == '+' || *c == ' ' || *c == '#' ||
279.5778 +                   *c == '0') c++;
279.5779 +            /* scan optional minimum field width */
279.5780 +            while (isdigit((unsigned char)*c)) c++;
279.5781 +            /* scan optional precision */
279.5782 +            if (*c == '.')
279.5783 +            {  c++;
279.5784 +               while (isdigit((unsigned char)*c)) c++;
279.5785 +            }
279.5786 +            /* scan conversion specifier and perform formatting */
279.5787 +            save = *(c+1), *(c+1) = '\0';
279.5788 +            if (*c == 'd' || *c == 'i' || *c == 'e' || *c == 'E' ||
279.5789 +                *c == 'f' || *c == 'F' || *c == 'g' || *c == 'G')
279.5790 +            {  /* the specifier requires numeric value */
279.5791 +               double value;
279.5792 +               xassert(entry != NULL);
279.5793 +               switch (entry->code->type)
279.5794 +               {  case A_NUMERIC:
279.5795 +                     value = eval_numeric(mpl, entry->code);
279.5796 +                     break;
279.5797 +                  case A_SYMBOLIC:
279.5798 +                     sym = eval_symbolic(mpl, entry->code);
279.5799 +                     if (sym->str != NULL)
279.5800 +                        error(mpl, "cannot convert %s to floating-point"
279.5801 +                           " number", format_symbol(mpl, sym));
279.5802 +                     value = sym->num;
279.5803 +                     delete_symbol(mpl, sym);
279.5804 +                     break;
279.5805 +                  case A_LOGICAL:
279.5806 +                     if (eval_logical(mpl, entry->code))
279.5807 +                        value = 1.0;
279.5808 +                     else
279.5809 +                        value = 0.0;
279.5810 +                     break;
279.5811 +                  default:
279.5812 +                     xassert(entry != entry);
279.5813 +               }
279.5814 +               if (*c == 'd' || *c == 'i')
279.5815 +               {  double int_max = (double)INT_MAX;
279.5816 +                  if (!(-int_max <= value && value <= +int_max))
279.5817 +                     error(mpl, "cannot convert %.*g to integer",
279.5818 +                        DBL_DIG, value);
279.5819 +                  print_text(mpl, from, (int)floor(value + 0.5));
279.5820 +               }
279.5821 +               else
279.5822 +                  print_text(mpl, from, value);
279.5823 +            }
279.5824 +            else if (*c == 's')
279.5825 +            {  /* the specifier requires symbolic value */
279.5826 +               char value[MAX_LENGTH+1];
279.5827 +               switch (entry->code->type)
279.5828 +               {  case A_NUMERIC:
279.5829 +                     sprintf(value, "%.*g", DBL_DIG, eval_numeric(mpl,
279.5830 +                        entry->code));
279.5831 +                     break;
279.5832 +                  case A_LOGICAL:
279.5833 +                     if (eval_logical(mpl, entry->code))
279.5834 +                        strcpy(value, "T");
279.5835 +                     else
279.5836 +                        strcpy(value, "F");
279.5837 +                     break;
279.5838 +                  case A_SYMBOLIC:
279.5839 +                     sym = eval_symbolic(mpl, entry->code);
279.5840 +                     if (sym->str == NULL)
279.5841 +                        sprintf(value, "%.*g", DBL_DIG, sym->num);
279.5842 +                     else
279.5843 +                        fetch_string(mpl, sym->str, value);
279.5844 +                     delete_symbol(mpl, sym);
279.5845 +                     break;
279.5846 +                  default:
279.5847 +                     xassert(entry != entry);
279.5848 +               }
279.5849 +               print_text(mpl, from, value);
279.5850 +            }
279.5851 +            else
279.5852 +               error(mpl, "format specifier missing or invalid");
279.5853 +            *(c+1) = save;
279.5854 +            entry = entry->next;
279.5855 +         }
279.5856 +         else if (*c == '\\')
279.5857 +         {  /* write some control character */
279.5858 +            c++;
279.5859 +            if (*c == 't')
279.5860 +               print_char(mpl, '\t');
279.5861 +            else if (*c == 'n')
279.5862 +               print_char(mpl, '\n');
279.5863 +#if 1 /* 28/X-2010 */
279.5864 +            else if (*c == '\0')
279.5865 +            {  /* format string ends with backslash */
279.5866 +               error(mpl, "invalid use of escape character \\ in format"
279.5867 +                  " control string");
279.5868 +            }
279.5869 +#endif
279.5870 +            else
279.5871 +               print_char(mpl, *c);
279.5872 +         }
279.5873 +         else
279.5874 +         {  /* write character without formatting */
279.5875 +            print_char(mpl, *c);
279.5876 +         }
279.5877 +      }
279.5878 +      return 0;
279.5879 +}
279.5880 +
279.5881 +#if 0 /* 14/VII-2006 */
279.5882 +void execute_printf(MPL *mpl, PRINTF *prt)
279.5883 +{     loop_within_domain(mpl, prt->domain, prt, printf_func);
279.5884 +      return;
279.5885 +}
279.5886 +#else
279.5887 +void execute_printf(MPL *mpl, PRINTF *prt)
279.5888 +{     if (prt->fname == NULL)
279.5889 +      {  /* switch to the standard output */
279.5890 +         if (mpl->prt_fp != NULL)
279.5891 +         {  xfclose(mpl->prt_fp), mpl->prt_fp = NULL;
279.5892 +            xfree(mpl->prt_file), mpl->prt_file = NULL;
279.5893 +         }
279.5894 +      }
279.5895 +      else
279.5896 +      {  /* evaluate file name string */
279.5897 +         SYMBOL *sym;
279.5898 +         char fname[MAX_LENGTH+1];
279.5899 +         sym = eval_symbolic(mpl, prt->fname);
279.5900 +         if (sym->str == NULL)
279.5901 +            sprintf(fname, "%.*g", DBL_DIG, sym->num);
279.5902 +         else
279.5903 +            fetch_string(mpl, sym->str, fname);
279.5904 +         delete_symbol(mpl, sym);
279.5905 +         /* close the current print file, if necessary */
279.5906 +         if (mpl->prt_fp != NULL &&
279.5907 +            (!prt->app || strcmp(mpl->prt_file, fname) != 0))
279.5908 +         {  xfclose(mpl->prt_fp), mpl->prt_fp = NULL;
279.5909 +            xfree(mpl->prt_file), mpl->prt_file = NULL;
279.5910 +         }
279.5911 +         /* open the specified print file, if necessary */
279.5912 +         if (mpl->prt_fp == NULL)
279.5913 +         {  mpl->prt_fp = xfopen(fname, prt->app ? "a" : "w");
279.5914 +            if (mpl->prt_fp == NULL)
279.5915 +               error(mpl, "unable to open `%s' for writing - %s",
279.5916 +                  fname, xerrmsg());
279.5917 +            mpl->prt_file = xmalloc(strlen(fname)+1);
279.5918 +            strcpy(mpl->prt_file, fname);
279.5919 +         }
279.5920 +      }
279.5921 +      loop_within_domain(mpl, prt->domain, prt, printf_func);
279.5922 +      if (mpl->prt_fp != NULL)
279.5923 +      {  xfflush(mpl->prt_fp);
279.5924 +         if (xferror(mpl->prt_fp))
279.5925 +            error(mpl, "writing error to `%s' - %s", mpl->prt_file,
279.5926 +               xerrmsg());
279.5927 +      }
279.5928 +      return;
279.5929 +}
279.5930 +#endif
279.5931 +
279.5932 +/*----------------------------------------------------------------------
279.5933 +-- clean_printf - clean printf statement.
279.5934 +--
279.5935 +-- This routine cleans specified printf statement that assumes deleting
279.5936 +-- all stuff dynamically allocated on generating/postsolving phase. */
279.5937 +
279.5938 +void clean_printf(MPL *mpl, PRINTF *prt)
279.5939 +{     PRINTF1 *p;
279.5940 +      /* clean subscript domain */
279.5941 +      clean_domain(mpl, prt->domain);
279.5942 +      /* clean pseudo-code for computing format string */
279.5943 +      clean_code(mpl, prt->fmt);
279.5944 +      /* clean printf list */
279.5945 +      for (p = prt->list; p != NULL; p = p->next)
279.5946 +      {  /* clean pseudo-code for computing value to be printed */
279.5947 +         clean_code(mpl, p->code);
279.5948 +      }
279.5949 +#if 1 /* 14/VII-2006 */
279.5950 +      /* clean pseudo-code for computing file name string */
279.5951 +      clean_code(mpl, prt->fname);
279.5952 +#endif
279.5953 +      return;
279.5954 +}
279.5955 +
279.5956 +/*----------------------------------------------------------------------
279.5957 +-- execute_for - execute for statement.
279.5958 +--
279.5959 +-- This routine executes specified for statement. */
279.5960 +
279.5961 +static int for_func(MPL *mpl, void *info)
279.5962 +{     /* this is auxiliary routine to work within domain scope */
279.5963 +      FOR *fur = (FOR *)info;
279.5964 +      STATEMENT *stmt, *save;
279.5965 +      save = mpl->stmt;
279.5966 +      for (stmt = fur->list; stmt != NULL; stmt = stmt->next)
279.5967 +         execute_statement(mpl, stmt);
279.5968 +      mpl->stmt = save;
279.5969 +      return 0;
279.5970 +}
279.5971 +
279.5972 +void execute_for(MPL *mpl, FOR *fur)
279.5973 +{     loop_within_domain(mpl, fur->domain, fur, for_func);
279.5974 +      return;
279.5975 +}
279.5976 +
279.5977 +/*----------------------------------------------------------------------
279.5978 +-- clean_for - clean for statement.
279.5979 +--
279.5980 +-- This routine cleans specified for statement that assumes deleting all
279.5981 +-- stuff dynamically allocated on generating/postsolving phase. */
279.5982 +
279.5983 +void clean_for(MPL *mpl, FOR *fur)
279.5984 +{     STATEMENT *stmt;
279.5985 +      /* clean subscript domain */
279.5986 +      clean_domain(mpl, fur->domain);
279.5987 +      /* clean all sub-statements */
279.5988 +      for (stmt = fur->list; stmt != NULL; stmt = stmt->next)
279.5989 +         clean_statement(mpl, stmt);
279.5990 +      return;
279.5991 +}
279.5992 +
279.5993 +/*----------------------------------------------------------------------
279.5994 +-- execute_statement - execute specified model statement.
279.5995 +--
279.5996 +-- This routine executes specified model statement. */
279.5997 +
279.5998 +void execute_statement(MPL *mpl, STATEMENT *stmt)
279.5999 +{     mpl->stmt = stmt;
279.6000 +      switch (stmt->type)
279.6001 +      {  case A_SET:
279.6002 +         case A_PARAMETER:
279.6003 +         case A_VARIABLE:
279.6004 +            break;
279.6005 +         case A_CONSTRAINT:
279.6006 +            xprintf("Generating %s...\n", stmt->u.con->name);
279.6007 +            eval_whole_con(mpl, stmt->u.con);
279.6008 +            break;
279.6009 +         case A_TABLE:
279.6010 +            switch (stmt->u.tab->type)
279.6011 +            {  case A_INPUT:
279.6012 +                  xprintf("Reading %s...\n", stmt->u.tab->name);
279.6013 +                  break;
279.6014 +               case A_OUTPUT:
279.6015 +                  xprintf("Writing %s...\n", stmt->u.tab->name);
279.6016 +                  break;
279.6017 +               default:
279.6018 +                  xassert(stmt != stmt);
279.6019 +            }
279.6020 +            execute_table(mpl, stmt->u.tab);
279.6021 +            break;
279.6022 +         case A_SOLVE:
279.6023 +            break;
279.6024 +         case A_CHECK:
279.6025 +            xprintf("Checking (line %d)...\n", stmt->line);
279.6026 +            execute_check(mpl, stmt->u.chk);
279.6027 +            break;
279.6028 +         case A_DISPLAY:
279.6029 +            write_text(mpl, "Display statement at line %d\n",
279.6030 +               stmt->line);
279.6031 +            execute_display(mpl, stmt->u.dpy);
279.6032 +            break;
279.6033 +         case A_PRINTF:
279.6034 +            execute_printf(mpl, stmt->u.prt);
279.6035 +            break;
279.6036 +         case A_FOR:
279.6037 +            execute_for(mpl, stmt->u.fur);
279.6038 +            break;
279.6039 +         default:
279.6040 +            xassert(stmt != stmt);
279.6041 +      }
279.6042 +      return;
279.6043 +}
279.6044 +
279.6045 +/*----------------------------------------------------------------------
279.6046 +-- clean_statement - clean specified model statement.
279.6047 +--
279.6048 +-- This routine cleans specified model statement that assumes deleting
279.6049 +-- all stuff dynamically allocated on generating/postsolving phase. */
279.6050 +
279.6051 +void clean_statement(MPL *mpl, STATEMENT *stmt)
279.6052 +{     switch(stmt->type)
279.6053 +      {  case A_SET:
279.6054 +            clean_set(mpl, stmt->u.set); break;
279.6055 +         case A_PARAMETER:
279.6056 +            clean_parameter(mpl, stmt->u.par); break;
279.6057 +         case A_VARIABLE:
279.6058 +            clean_variable(mpl, stmt->u.var); break;
279.6059 +         case A_CONSTRAINT:
279.6060 +            clean_constraint(mpl, stmt->u.con); break;
279.6061 +#if 1 /* 11/II-2008 */
279.6062 +         case A_TABLE:
279.6063 +            clean_table(mpl, stmt->u.tab); break;
279.6064 +#endif
279.6065 +         case A_SOLVE:
279.6066 +            break;
279.6067 +         case A_CHECK:
279.6068 +            clean_check(mpl, stmt->u.chk); break;
279.6069 +         case A_DISPLAY:
279.6070 +            clean_display(mpl, stmt->u.dpy); break;
279.6071 +         case A_PRINTF:
279.6072 +            clean_printf(mpl, stmt->u.prt); break;
279.6073 +         case A_FOR:
279.6074 +            clean_for(mpl, stmt->u.fur); break;
279.6075 +         default:
279.6076 +            xassert(stmt != stmt);
279.6077 +      }
279.6078 +      return;
279.6079 +}
279.6080 +
279.6081 +/* eof */
   280.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
   280.2 +++ b/deps/glpk/src/glpmpl04.c	Sun Nov 06 20:59:10 2011 +0100
   280.3 @@ -0,0 +1,1424 @@
   280.4 +/* glpmpl04.c */
   280.5 +
   280.6 +/***********************************************************************
   280.7 +*  This code is part of GLPK (GNU Linear Programming Kit).
   280.8 +*
   280.9 +*  Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008,
  280.10 +*  2009, 2010, 2011 Andrew Makhorin, Department for Applied Informatics,
  280.11 +*  Moscow Aviation Institute, Moscow, Russia. All rights reserved.
  280.12 +*  E-mail: <mao@gnu.org>.
  280.13 +*
  280.14 +*  GLPK is free software: you can redistribute it and/or modify it
  280.15 +*  under the terms of the GNU General Public License as published by
  280.16 +*  the Free Software Foundation, either version 3 of the License, or
  280.17 +*  (at your option) any later version.
  280.18 +*
  280.19 +*  GLPK is distributed in the hope that it will be useful, but WITHOUT
  280.20 +*  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
  280.21 +*  or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
  280.22 +*  License for more details.
  280.23 +*
  280.24 +*  You should have received a copy of the GNU General Public License
  280.25 +*  along with GLPK. If not, see <http://www.gnu.org/licenses/>.
  280.26 +***********************************************************************/
  280.27 +
  280.28 +#define _GLPSTD_ERRNO
  280.29 +#define _GLPSTD_STDIO
  280.30 +#include "glpmpl.h"
  280.31 +#define xfault xerror
  280.32 +#define dmp_create_poolx(size) dmp_create_pool()
  280.33 +
  280.34 +/**********************************************************************/
  280.35 +/* * *              GENERATING AND POSTSOLVING MODEL              * * */
  280.36 +/**********************************************************************/
  280.37 +
  280.38 +/*----------------------------------------------------------------------
  280.39 +-- alloc_content - allocate content arrays for all model objects.
  280.40 +--
  280.41 +-- This routine allocates content arrays for all existing model objects
  280.42 +-- and thereby finalizes creating model.
  280.43 +--
  280.44 +-- This routine must be called immediately after reading model section,
  280.45 +-- i.e. before reading data section or generating model. */
  280.46 +
  280.47 +void alloc_content(MPL *mpl)
  280.48 +{     STATEMENT *stmt;
  280.49 +      /* walk through all model statements */
  280.50 +      for (stmt = mpl->model; stmt != NULL; stmt = stmt->next)
  280.51 +      {  switch (stmt->type)
  280.52 +         {  case A_SET:
  280.53 +               /* model set */
  280.54 +               xassert(stmt->u.set->array == NULL);
  280.55 +               stmt->u.set->array = create_array(mpl, A_ELEMSET,
  280.56 +                  stmt->u.set->dim);
  280.57 +               break;
  280.58 +            case A_PARAMETER:
  280.59 +               /* model parameter */
  280.60 +               xassert(stmt->u.par->array == NULL);
  280.61 +               switch (stmt->u.par->type)
  280.62 +               {  case A_NUMERIC:
  280.63 +                  case A_INTEGER:
  280.64 +                  case A_BINARY:
  280.65 +                     stmt->u.par->array = create_array(mpl, A_NUMERIC,
  280.66 +                        stmt->u.par->dim);
  280.67 +                     break;
  280.68 +                  case A_SYMBOLIC:
  280.69 +                     stmt->u.par->array = create_array(mpl, A_SYMBOLIC,
  280.70 +                        stmt->u.par->dim);
  280.71 +                     break;
  280.72 +                  default:
  280.73 +                     xassert(stmt != stmt);
  280.74 +               }
  280.75 +               break;
  280.76 +            case A_VARIABLE:
  280.77 +               /* model variable */
  280.78 +               xassert(stmt->u.var->array == NULL);
  280.79 +               stmt->u.var->array = create_array(mpl, A_ELEMVAR,
  280.80 +                  stmt->u.var->dim);
  280.81 +               break;
  280.82 +            case A_CONSTRAINT:
  280.83 +               /* model constraint/objective */
  280.84 +               xassert(stmt->u.con->array == NULL);
  280.85 +               stmt->u.con->array = create_array(mpl, A_ELEMCON,
  280.86 +                  stmt->u.con->dim);
  280.87 +               break;
  280.88 +#if 1 /* 11/II-2008 */
  280.89 +            case A_TABLE:
  280.90 +#endif
  280.91 +            case A_SOLVE:
  280.92 +            case A_CHECK:
  280.93 +            case A_DISPLAY:
  280.94 +            case A_PRINTF:
  280.95 +            case A_FOR:
  280.96 +               /* functional statements have no content array */
  280.97 +               break;
  280.98 +            default:
  280.99 +               xassert(stmt != stmt);
 280.100 +         }
 280.101 +      }
 280.102 +      return;
 280.103 +}
 280.104 +
 280.105 +/*----------------------------------------------------------------------
 280.106 +-- generate_model - generate model.
 280.107 +--
 280.108 +-- This routine executes the model statements which precede the solve
 280.109 +-- statement. */
 280.110 +
 280.111 +void generate_model(MPL *mpl)
 280.112 +{     STATEMENT *stmt;
 280.113 +      xassert(!mpl->flag_p);
 280.114 +      for (stmt = mpl->model; stmt != NULL; stmt = stmt->next)
 280.115 +      {  execute_statement(mpl, stmt);
 280.116 +         if (mpl->stmt->type == A_SOLVE) break;
 280.117 +      }
 280.118 +      mpl->stmt = stmt;
 280.119 +      return;
 280.120 +}
 280.121 +
 280.122 +/*----------------------------------------------------------------------
 280.123 +-- build_problem - build problem instance.
 280.124 +--
 280.125 +-- This routine builds lists of rows and columns for problem instance,
 280.126 +-- which corresponds to the generated model. */
 280.127 +
 280.128 +void build_problem(MPL *mpl)
 280.129 +{     STATEMENT *stmt;
 280.130 +      MEMBER *memb;
 280.131 +      VARIABLE *v;
 280.132 +      CONSTRAINT *c;
 280.133 +      FORMULA *t;
 280.134 +      int i, j;
 280.135 +      xassert(mpl->m == 0);
 280.136 +      xassert(mpl->n == 0);
 280.137 +      xassert(mpl->row == NULL);
 280.138 +      xassert(mpl->col == NULL);
 280.139 +      /* check that all elemental variables has zero column numbers */
 280.140 +      for (stmt = mpl->model; stmt != NULL; stmt = stmt->next)
 280.141 +      {  if (stmt->type == A_VARIABLE)
 280.142 +         {  v = stmt->u.var;
 280.143 +            for (memb = v->array->head; memb != NULL; memb = memb->next)
 280.144 +               xassert(memb->value.var->j == 0);
 280.145 +         }
 280.146 +      }
 280.147 +      /* assign row numbers to elemental constraints and objectives */
 280.148 +      for (stmt = mpl->model; stmt != NULL; stmt = stmt->next)
 280.149 +      {  if (stmt->type == A_CONSTRAINT)
 280.150 +         {  c = stmt->u.con;
 280.151 +            for (memb = c->array->head; memb != NULL; memb = memb->next)
 280.152 +            {  xassert(memb->value.con->i == 0);
 280.153 +               memb->value.con->i = ++mpl->m;
 280.154 +               /* walk through linear form and mark elemental variables,
 280.155 +                  which are referenced at least once */
 280.156 +               for (t = memb->value.con->form; t != NULL; t = t->next)
 280.157 +               {  xassert(t->var != NULL);
 280.158 +                  t->var->memb->value.var->j = -1;
 280.159 +               }
 280.160 +            }
 280.161 +         }
 280.162 +      }
 280.163 +      /* assign column numbers to marked elemental variables */
 280.164 +      for (stmt = mpl->model; stmt != NULL; stmt = stmt->next)
 280.165 +      {  if (stmt->type == A_VARIABLE)
 280.166 +         {  v = stmt->u.var;
 280.167 +            for (memb = v->array->head; memb != NULL; memb = memb->next)
 280.168 +               if (memb->value.var->j != 0) memb->value.var->j =
 280.169 +                  ++mpl->n;
 280.170 +         }
 280.171 +      }
 280.172 +      /* build list of rows */
 280.173 +      mpl->row = xcalloc(1+mpl->m, sizeof(ELEMCON *));
 280.174 +      for (i = 1; i <= mpl->m; i++) mpl->row[i] = NULL;
 280.175 +      for (stmt = mpl->model; stmt != NULL; stmt = stmt->next)
 280.176 +      {  if (stmt->type == A_CONSTRAINT)
 280.177 +         {  c = stmt->u.con;
 280.178 +            for (memb = c->array->head; memb != NULL; memb = memb->next)
 280.179 +            {  i = memb->value.con->i;
 280.180 +               xassert(1 <= i && i <= mpl->m);
 280.181 +               xassert(mpl->row[i] == NULL);
 280.182 +               mpl->row[i] = memb->value.con;
 280.183 +            }
 280.184 +         }
 280.185 +      }
 280.186 +      for (i = 1; i <= mpl->m; i++) xassert(mpl->row[i] != NULL);
 280.187 +      /* build list of columns */
 280.188 +      mpl->col = xcalloc(1+mpl->n, sizeof(ELEMVAR *));
 280.189 +      for (j = 1; j <= mpl->n; j++) mpl->col[j] = NULL;
 280.190 +      for (stmt = mpl->model; stmt != NULL; stmt = stmt->next)
 280.191 +      {  if (stmt->type == A_VARIABLE)
 280.192 +         {  v = stmt->u.var;
 280.193 +            for (memb = v->array->head; memb != NULL; memb = memb->next)
 280.194 +            {  j = memb->value.var->j;
 280.195 +               if (j == 0) continue;
 280.196 +               xassert(1 <= j && j <= mpl->n);
 280.197 +               xassert(mpl->col[j] == NULL);
 280.198 +               mpl->col[j] = memb->value.var;
 280.199 +            }
 280.200 +         }
 280.201 +      }
 280.202 +      for (j = 1; j <= mpl->n; j++) xassert(mpl->col[j] != NULL);
 280.203 +      return;
 280.204 +}
 280.205 +
 280.206 +/*----------------------------------------------------------------------
 280.207 +-- postsolve_model - postsolve model.
 280.208 +--
 280.209 +-- This routine executes the model statements which follow the solve
 280.210 +-- statement. */
 280.211 +
 280.212 +void postsolve_model(MPL *mpl)
 280.213 +{     STATEMENT *stmt;
 280.214 +      xassert(!mpl->flag_p);
 280.215 +      mpl->flag_p = 1;
 280.216 +      for (stmt = mpl->stmt; stmt != NULL; stmt = stmt->next)
 280.217 +         execute_statement(mpl, stmt);
 280.218 +      mpl->stmt = NULL;
 280.219 +      return;
 280.220 +}
 280.221 +
 280.222 +/*----------------------------------------------------------------------
 280.223 +-- clean_model - clean model content.
 280.224 +--
 280.225 +-- This routine cleans the model content that assumes deleting all stuff
 280.226 +-- dynamically allocated on generating/postsolving phase.
 280.227 +--
 280.228 +-- Actually cleaning model content is not needed. This function is used
 280.229 +-- mainly to be sure that there were no logical errors on using dynamic
 280.230 +-- memory pools during the generation phase.
 280.231 +--
 280.232 +-- NOTE: This routine must not be called if any errors were detected on
 280.233 +--       the generation phase. */
 280.234 +
 280.235 +void clean_model(MPL *mpl)
 280.236 +{     STATEMENT *stmt;
 280.237 +      for (stmt = mpl->model; stmt != NULL; stmt = stmt->next)
 280.238 +         clean_statement(mpl, stmt);
 280.239 +      /* check that all atoms have been returned to their pools */
 280.240 +      if (dmp_in_use(mpl->strings).lo != 0)
 280.241 +         error(mpl, "internal logic error: %d string segment(s) were lo"
 280.242 +            "st", dmp_in_use(mpl->strings).lo);
 280.243 +      if (dmp_in_use(mpl->symbols).lo != 0)
 280.244 +         error(mpl, "internal logic error: %d symbol(s) were lost",
 280.245 +            dmp_in_use(mpl->symbols).lo);
 280.246 +      if (dmp_in_use(mpl->tuples).lo != 0)
 280.247 +         error(mpl, "internal logic error: %d n-tuple component(s) were"
 280.248 +            " lost", dmp_in_use(mpl->tuples).lo);
 280.249 +      if (dmp_in_use(mpl->arrays).lo != 0)
 280.250 +         error(mpl, "internal logic error: %d array(s) were lost",
 280.251 +            dmp_in_use(mpl->arrays).lo);
 280.252 +      if (dmp_in_use(mpl->members).lo != 0)
 280.253 +         error(mpl, "internal logic error: %d array member(s) were lost"
 280.254 +            , dmp_in_use(mpl->members).lo);
 280.255 +      if (dmp_in_use(mpl->elemvars).lo != 0)
 280.256 +         error(mpl, "internal logic error: %d elemental variable(s) wer"
 280.257 +            "e lost", dmp_in_use(mpl->elemvars).lo);
 280.258 +      if (dmp_in_use(mpl->formulae).lo != 0)
 280.259 +         error(mpl, "internal logic error: %d linear term(s) were lost",
 280.260 +            dmp_in_use(mpl->formulae).lo);
 280.261 +      if (dmp_in_use(mpl->elemcons).lo != 0)
 280.262 +         error(mpl, "internal logic error: %d elemental constraint(s) w"
 280.263 +            "ere lost", dmp_in_use(mpl->elemcons).lo);
 280.264 +      return;
 280.265 +}
 280.266 +
 280.267 +/**********************************************************************/
 280.268 +/* * *                        INPUT/OUTPUT                        * * */
 280.269 +/**********************************************************************/
 280.270 +
 280.271 +/*----------------------------------------------------------------------
 280.272 +-- open_input - open input text file.
 280.273 +--
 280.274 +-- This routine opens the input text file for scanning. */
 280.275 +
 280.276 +void open_input(MPL *mpl, char *file)
 280.277 +{     mpl->line = 0;
 280.278 +      mpl->c = '\n';
 280.279 +      mpl->token = 0;
 280.280 +      mpl->imlen = 0;
 280.281 +      mpl->image[0] = '\0';
 280.282 +      mpl->value = 0.0;
 280.283 +      mpl->b_token = T_EOF;
 280.284 +      mpl->b_imlen = 0;
 280.285 +      mpl->b_image[0] = '\0';
 280.286 +      mpl->b_value = 0.0;
 280.287 +      mpl->f_dots = 0;
 280.288 +      mpl->f_scan = 0;
 280.289 +      mpl->f_token = 0;
 280.290 +      mpl->f_imlen = 0;
 280.291 +      mpl->f_image[0] = '\0';
 280.292 +      mpl->f_value = 0.0;
 280.293 +      memset(mpl->context, ' ', CONTEXT_SIZE);
 280.294 +      mpl->c_ptr = 0;
 280.295 +      xassert(mpl->in_fp == NULL);
 280.296 +      mpl->in_fp = xfopen(file, "r");
 280.297 +      if (mpl->in_fp == NULL)
 280.298 +         error(mpl, "unable to open %s - %s", file, xerrmsg());
 280.299 +      mpl->in_file = file;
 280.300 +      /* scan the very first character */
 280.301 +      get_char(mpl);
 280.302 +      /* scan the very first token */
 280.303 +      get_token(mpl);
 280.304 +      return;
 280.305 +}
 280.306 +
 280.307 +/*----------------------------------------------------------------------
 280.308 +-- read_char - read next character from input text file.
 280.309 +--
 280.310 +-- This routine returns a next ASCII character read from the input text
 280.311 +-- file. If the end of file has been reached, EOF is returned. */
 280.312 +
 280.313 +int read_char(MPL *mpl)
 280.314 +{     int c;
 280.315 +      xassert(mpl->in_fp != NULL);
 280.316 +      c = xfgetc(mpl->in_fp);
 280.317 +      if (c < 0)
 280.318 +      {  if (xferror(mpl->in_fp))
 280.319 +            error(mpl, "read error on %s - %s", mpl->in_file,
 280.320 +               xerrmsg());
 280.321 +         c = EOF;
 280.322 +      }
 280.323 +      return c;
 280.324 +}
 280.325 +
 280.326 +/*----------------------------------------------------------------------
 280.327 +-- close_input - close input text file.
 280.328 +--
 280.329 +-- This routine closes the input text file. */
 280.330 +
 280.331 +void close_input(MPL *mpl)
 280.332 +{     xassert(mpl->in_fp != NULL);
 280.333 +      xfclose(mpl->in_fp);
 280.334 +      mpl->in_fp = NULL;
 280.335 +      mpl->in_file = NULL;
 280.336 +      return;
 280.337 +}
 280.338 +
 280.339 +/*----------------------------------------------------------------------
 280.340 +-- open_output - open output text file.
 280.341 +--
 280.342 +-- This routine opens the output text file for writing data produced by
 280.343 +-- display and printf statements. */
 280.344 +
 280.345 +void open_output(MPL *mpl, char *file)
 280.346 +{     xassert(mpl->out_fp == NULL);
 280.347 +      if (file == NULL)
 280.348 +      {  file = "<stdout>";
 280.349 +         mpl->out_fp = (void *)stdout;
 280.350 +      }
 280.351 +      else
 280.352 +      {  mpl->out_fp = xfopen(file, "w");
 280.353 +         if (mpl->out_fp == NULL)
 280.354 +            error(mpl, "unable to create %s - %s", file, xerrmsg());
 280.355 +      }
 280.356 +      mpl->out_file = xmalloc(strlen(file)+1);
 280.357 +      strcpy(mpl->out_file, file);
 280.358 +      return;
 280.359 +}
 280.360 +
 280.361 +/*----------------------------------------------------------------------
 280.362 +-- write_char - write next character to output text file.
 280.363 +--
 280.364 +-- This routine writes an ASCII character to the output text file. */
 280.365 +
 280.366 +void write_char(MPL *mpl, int c)
 280.367 +{     xassert(mpl->out_fp != NULL);
 280.368 +      if (mpl->out_fp == (void *)stdout)
 280.369 +         xprintf("%c", c);
 280.370 +      else
 280.371 +         xfprintf(mpl->out_fp, "%c", c);
 280.372 +      return;
 280.373 +}
 280.374 +
 280.375 +/*----------------------------------------------------------------------
 280.376 +-- write_text - format and write text to output text file.
 280.377 +--
 280.378 +-- This routine formats a text using the format control string and then
 280.379 +-- writes this text to the output text file. */
 280.380 +
 280.381 +void write_text(MPL *mpl, char *fmt, ...)
 280.382 +{     va_list arg;
 280.383 +      char buf[OUTBUF_SIZE], *c;
 280.384 +      va_start(arg, fmt);
 280.385 +      vsprintf(buf, fmt, arg);
 280.386 +      xassert(strlen(buf) < sizeof(buf));
 280.387 +      va_end(arg);
 280.388 +      for (c = buf; *c != '\0'; c++) write_char(mpl, *c);
 280.389 +      return;
 280.390 +}
 280.391 +
 280.392 +/*----------------------------------------------------------------------
 280.393 +-- flush_output - finalize writing data to output text file.
 280.394 +--
 280.395 +-- This routine finalizes writing data to the output text file. */
 280.396 +
 280.397 +void flush_output(MPL *mpl)
 280.398 +{     xassert(mpl->out_fp != NULL);
 280.399 +      if (mpl->out_fp != (void *)stdout)
 280.400 +      {  xfflush(mpl->out_fp);
 280.401 +         if (xferror(mpl->out_fp))
 280.402 +            error(mpl, "write error on %s - %s", mpl->out_file,
 280.403 +               xerrmsg());
 280.404 +      }
 280.405 +      return;
 280.406 +}
 280.407 +
 280.408 +/**********************************************************************/
 280.409 +/* * *                      SOLVER INTERFACE                      * * */
 280.410 +/**********************************************************************/
 280.411 +
 280.412 +/*----------------------------------------------------------------------
 280.413 +-- error - print error message and terminate model processing.
 280.414 +--
 280.415 +-- This routine formats and prints an error message and then terminates
 280.416 +-- model processing. */
 280.417 +
 280.418 +void error(MPL *mpl, char *fmt, ...)
 280.419 +{     va_list arg;
 280.420 +      char msg[4095+1];
 280.421 +      va_start(arg, fmt);
 280.422 +      vsprintf(msg, fmt, arg);
 280.423 +      xassert(strlen(msg) < sizeof(msg));
 280.424 +      va_end(arg);
 280.425 +      switch (mpl->phase)
 280.426 +      {  case 1:
 280.427 +         case 2:
 280.428 +            /* translation phase */
 280.429 +            xprintf("%s:%d: %s\n",
 280.430 +               mpl->in_file == NULL ? "(unknown)" : mpl->in_file,
 280.431 +               mpl->line, msg);
 280.432 +            print_context(mpl);
 280.433 +            break;
 280.434 +         case 3:
 280.435 +            /* generation/postsolve phase */
 280.436 +            xprintf("%s:%d: %s\n",
 280.437 +               mpl->mod_file == NULL ? "(unknown)" : mpl->mod_file,
 280.438 +               mpl->stmt == NULL ? 0 : mpl->stmt->line, msg);
 280.439 +            break;
 280.440 +         default:
 280.441 +            xassert(mpl != mpl);
 280.442 +      }
 280.443 +      mpl->phase = 4;
 280.444 +      longjmp(mpl->jump, 1);
 280.445 +      /* no return */
 280.446 +}
 280.447 +
 280.448 +/*----------------------------------------------------------------------
 280.449 +-- warning - print warning message and continue model processing.
 280.450 +--
 280.451 +-- This routine formats and prints a warning message and returns to the
 280.452 +-- calling program. */
 280.453 +
 280.454 +void warning(MPL *mpl, char *fmt, ...)
 280.455 +{     va_list arg;
 280.456 +      char msg[4095+1];
 280.457 +      va_start(arg, fmt);
 280.458 +      vsprintf(msg, fmt, arg);
 280.459 +      xassert(strlen(msg) < sizeof(msg));
 280.460 +      va_end(arg);
 280.461 +      switch (mpl->phase)
 280.462 +      {  case 1:
 280.463 +         case 2:
 280.464 +            /* translation phase */
 280.465 +            xprintf("%s:%d: warning: %s\n",
 280.466 +               mpl->in_file == NULL ? "(unknown)" : mpl->in_file,
 280.467 +               mpl->line, msg);
 280.468 +            break;
 280.469 +         case 3:
 280.470 +            /* generation/postsolve phase */
 280.471 +            xprintf("%s:%d: warning: %s\n",
 280.472 +               mpl->mod_file == NULL ? "(unknown)" : mpl->mod_file,
 280.473 +               mpl->stmt == NULL ? 0 : mpl->stmt->line, msg);
 280.474 +            break;
 280.475 +         default:
 280.476 +            xassert(mpl != mpl);
 280.477 +      }
 280.478 +      return;
 280.479 +}
 280.480 +
 280.481 +/*----------------------------------------------------------------------
 280.482 +-- mpl_initialize - create and initialize translator database.
 280.483 +--
 280.484 +-- *Synopsis*
 280.485 +--
 280.486 +-- #include "glpmpl.h"
 280.487 +-- MPL *mpl_initialize(void);
 280.488 +--
 280.489 +-- *Description*
 280.490 +--
 280.491 +-- The routine mpl_initialize creates and initializes the database used
 280.492 +-- by the GNU MathProg translator.
 280.493 +--
 280.494 +-- *Returns*
 280.495 +--
 280.496 +-- The routine returns a pointer to the database created. */
 280.497 +
 280.498 +MPL *mpl_initialize(void)
 280.499 +{     MPL *mpl;
 280.500 +      mpl = xmalloc(sizeof(MPL));
 280.501 +      /* scanning segment */
 280.502 +      mpl->line = 0;
 280.503 +      mpl->c = 0;
 280.504 +      mpl->token = 0;
 280.505 +      mpl->imlen = 0;
 280.506 +      mpl->image = xcalloc(MAX_LENGTH+1, sizeof(char));
 280.507 +      mpl->image[0] = '\0';
 280.508 +      mpl->value = 0.0;
 280.509 +      mpl->b_token = 0;
 280.510 +      mpl->b_imlen = 0;
 280.511 +      mpl->b_image = xcalloc(MAX_LENGTH+1, sizeof(char));
 280.512 +      mpl->b_image[0] = '\0';
 280.513 +      mpl->b_value = 0.0;
 280.514 +      mpl->f_dots = 0;
 280.515 +      mpl->f_scan = 0;
 280.516 +      mpl->f_token = 0;
 280.517 +      mpl->f_imlen = 0;
 280.518 +      mpl->f_image = xcalloc(MAX_LENGTH+1, sizeof(char));
 280.519 +      mpl->f_image[0] = '\0';
 280.520 +      mpl->f_value = 0.0;
 280.521 +      mpl->context = xcalloc(CONTEXT_SIZE, sizeof(char));
 280.522 +      memset(mpl->context, ' ', CONTEXT_SIZE);
 280.523 +      mpl->c_ptr = 0;
 280.524 +      mpl->flag_d = 0;
 280.525 +      /* translating segment */
 280.526 +      mpl->pool = dmp_create_poolx(0);
 280.527 +      mpl->tree = avl_create_tree(avl_strcmp, NULL);
 280.528 +      mpl->model = NULL;
 280.529 +      mpl->flag_x = 0;
 280.530 +      mpl->as_within = 0;
 280.531 +      mpl->as_in = 0;
 280.532 +      mpl->as_binary = 0;
 280.533 +      mpl->flag_s = 0;
 280.534 +      /* common segment */
 280.535 +      mpl->strings = dmp_create_poolx(sizeof(STRING));
 280.536 +      mpl->symbols = dmp_create_poolx(sizeof(SYMBOL));
 280.537 +      mpl->tuples = dmp_create_poolx(sizeof(TUPLE));
 280.538 +      mpl->arrays = dmp_create_poolx(sizeof(ARRAY));
 280.539 +      mpl->members = dmp_create_poolx(sizeof(MEMBER));
 280.540 +      mpl->elemvars = dmp_create_poolx(sizeof(ELEMVAR));
 280.541 +      mpl->formulae = dmp_create_poolx(sizeof(FORMULA));
 280.542 +      mpl->elemcons = dmp_create_poolx(sizeof(ELEMCON));
 280.543 +      mpl->a_list = NULL;
 280.544 +      mpl->sym_buf = xcalloc(255+1, sizeof(char));
 280.545 +      mpl->sym_buf[0] = '\0';
 280.546 +      mpl->tup_buf = xcalloc(255+1, sizeof(char));
 280.547 +      mpl->tup_buf[0] = '\0';
 280.548 +      /* generating/postsolving segment */
 280.549 +      mpl->rand = rng_create_rand();
 280.550 +      mpl->flag_p = 0;
 280.551 +      mpl->stmt = NULL;
 280.552 +#if 1 /* 11/II-2008 */
 280.553 +      mpl->dca = NULL;
 280.554 +#endif
 280.555 +      mpl->m = 0;
 280.556 +      mpl->n = 0;
 280.557 +      mpl->row = NULL;
 280.558 +      mpl->col = NULL;
 280.559 +      /* input/output segment */
 280.560 +      mpl->in_fp = NULL;
 280.561 +      mpl->in_file = NULL;
 280.562 +      mpl->out_fp = NULL;
 280.563 +      mpl->out_file = NULL;
 280.564 +      mpl->prt_fp = NULL;
 280.565 +      mpl->prt_file = NULL;
 280.566 +      /* solver interface segment */
 280.567 +      if (setjmp(mpl->jump)) xassert(mpl != mpl);
 280.568 +      mpl->phase = 0;
 280.569 +      mpl->mod_file = NULL;
 280.570 +      mpl->mpl_buf = xcalloc(255+1, sizeof(char));
 280.571 +      mpl->mpl_buf[0] = '\0';
 280.572 +      return mpl;
 280.573 +}
 280.574 +
 280.575 +/*----------------------------------------------------------------------
 280.576 +-- mpl_read_model - read model section and optional data section.
 280.577 +--
 280.578 +-- *Synopsis*
 280.579 +--
 280.580 +-- #include "glpmpl.h"
 280.581 +-- int mpl_read_model(MPL *mpl, char *file, int skip_data);
 280.582 +--
 280.583 +-- *Description*
 280.584 +--
 280.585 +-- The routine mpl_read_model reads model section and optionally data
 280.586 +-- section, which may follow the model section, from the text file,
 280.587 +-- whose name is the character string file, performs translating model
 280.588 +-- statements and data blocks, and stores all the information in the
 280.589 +-- translator database.
 280.590 +--
 280.591 +-- The parameter skip_data is a flag. If the input file contains the
 280.592 +-- data section and this flag is set, the data section is not read as
 280.593 +-- if there were no data section and a warning message is issued. This
 280.594 +-- allows reading the data section from another input file.
 280.595 +--
 280.596 +-- This routine should be called once after the routine mpl_initialize
 280.597 +-- and before other API routines.
 280.598 +--
 280.599 +-- *Returns*
 280.600 +--
 280.601 +-- The routine mpl_read_model returns one the following codes:
 280.602 +--
 280.603 +-- 1 - translation successful. The input text file contains only model
 280.604 +--     section. In this case the calling program may call the routine
 280.605 +--     mpl_read_data to read data section from another file.
 280.606 +-- 2 - translation successful. The input text file contains both model
 280.607 +--     and data section.
 280.608 +-- 4 - processing failed due to some errors. In this case the calling
 280.609 +--     program should call the routine mpl_terminate to terminate model
 280.610 +--     processing. */
 280.611 +
 280.612 +int mpl_read_model(MPL *mpl, char *file, int skip_data)
 280.613 +{     if (mpl->phase != 0)
 280.614 +         xfault("mpl_read_model: invalid call sequence\n");
 280.615 +      if (file == NULL)
 280.616 +         xfault("mpl_read_model: no input filename specified\n");
 280.617 +      /* set up error handler */
 280.618 +      if (setjmp(mpl->jump)) goto done;
 280.619 +      /* translate model section */
 280.620 +      mpl->phase = 1;
 280.621 +      xprintf("Reading model section from %s...\n", file);
 280.622 +      open_input(mpl, file);
 280.623 +      model_section(mpl);
 280.624 +      if (mpl->model == NULL)
 280.625 +         error(mpl, "empty model section not allowed");
 280.626 +      /* save name of the input text file containing model section for
 280.627 +         error diagnostics during the generation phase */
 280.628 +      mpl->mod_file = xcalloc(strlen(file)+1, sizeof(char));
 280.629 +      strcpy(mpl->mod_file, mpl->in_file);
 280.630 +      /* allocate content arrays for all model objects */
 280.631 +      alloc_content(mpl);
 280.632 +      /* optional data section may begin with the keyword 'data' */
 280.633 +      if (is_keyword(mpl, "data"))
 280.634 +      {  if (skip_data)
 280.635 +         {  warning(mpl, "data section ignored");
 280.636 +            goto skip;
 280.637 +         }
 280.638 +         mpl->flag_d = 1;
 280.639 +         get_token(mpl /* data */);
 280.640 +         if (mpl->token != T_SEMICOLON)
 280.641 +            error(mpl, "semicolon missing where expected");
 280.642 +         get_token(mpl /* ; */);
 280.643 +         /* translate data section */
 280.644 +         mpl->phase = 2;
 280.645 +         xprintf("Reading data section from %s...\n", file);
 280.646 +         data_section(mpl);
 280.647 +      }
 280.648 +      /* process end statement */
 280.649 +      end_statement(mpl);
 280.650 +skip: xprintf("%d line%s were read\n",
 280.651 +         mpl->line, mpl->line == 1 ? "" : "s");
 280.652 +      close_input(mpl);
 280.653 +done: /* return to the calling program */
 280.654 +      return mpl->phase;
 280.655 +}
 280.656 +
 280.657 +/*----------------------------------------------------------------------
 280.658 +-- mpl_read_data - read data section.
 280.659 +--
 280.660 +-- *Synopsis*
 280.661 +--
 280.662 +-- #include "glpmpl.h"
 280.663 +-- int mpl_read_data(MPL *mpl, char *file);
 280.664 +--
 280.665 +-- *Description*
 280.666 +--
 280.667 +-- The routine mpl_read_data reads data section from the text file,
 280.668 +-- whose name is the character string file, performs translating data
 280.669 +-- blocks, and stores the data read in the translator database.
 280.670 +--
 280.671 +-- If this routine is used, it should be called once after the routine
 280.672 +-- mpl_read_model and if the latter returned the code 1.
 280.673 +--
 280.674 +-- *Returns*
 280.675 +--
 280.676 +-- The routine mpl_read_data returns one of the following codes:
 280.677 +--
 280.678 +-- 2 - data section has been successfully processed.
 280.679 +-- 4 - processing failed due to some errors. In this case the calling
 280.680 +--     program should call the routine mpl_terminate to terminate model
 280.681 +--     processing. */
 280.682 +
 280.683 +int mpl_read_data(MPL *mpl, char *file)
 280.684 +#if 0 /* 02/X-2008 */
 280.685 +{     if (mpl->phase != 1)
 280.686 +#else
 280.687 +{     if (!(mpl->phase == 1 || mpl->phase == 2))
 280.688 +#endif
 280.689 +         xfault("mpl_read_data: invalid call sequence\n");
 280.690 +      if (file == NULL)
 280.691 +         xfault("mpl_read_data: no input filename specified\n");
 280.692 +      /* set up error handler */
 280.693 +      if (setjmp(mpl->jump)) goto done;
 280.694 +      /* process data section */
 280.695 +      mpl->phase = 2;
 280.696 +      xprintf("Reading data section from %s...\n", file);
 280.697 +      mpl->flag_d = 1;
 280.698 +      open_input(mpl, file);
 280.699 +      /* in this case the keyword 'data' is optional */
 280.700 +      if (is_literal(mpl, "data"))
 280.701 +      {  get_token(mpl /* data */);
 280.702 +         if (mpl->token != T_SEMICOLON)
 280.703 +            error(mpl, "semicolon missing where expected");
 280.704 +         get_token(mpl /* ; */);
 280.705 +      }
 280.706 +      data_section(mpl);
 280.707 +      /* process end statement */
 280.708 +      end_statement(mpl);
 280.709 +      xprintf("%d line%s were read\n",
 280.710 +         mpl->line, mpl->line == 1 ? "" : "s");
 280.711 +      close_input(mpl);
 280.712 +done: /* return to the calling program */
 280.713 +      return mpl->phase;
 280.714 +}
 280.715 +
 280.716 +/*----------------------------------------------------------------------
 280.717 +-- mpl_generate - generate model.
 280.718 +--
 280.719 +-- *Synopsis*
 280.720 +--
 280.721 +-- #include "glpmpl.h"
 280.722 +-- int mpl_generate(MPL *mpl, char *file);
 280.723 +--
 280.724 +-- *Description*
 280.725 +--
 280.726 +-- The routine mpl_generate generates the model using its description
 280.727 +-- stored in the translator database. This phase means generating all
 280.728 +-- variables, constraints, and objectives, executing check and display
 280.729 +-- statements, which precede the solve statement (if it is presented),
 280.730 +-- and building the problem instance.
 280.731 +--
 280.732 +-- The character string file specifies the name of output text file, to
 280.733 +-- which output produced by display statements should be written. It is
 280.734 +-- allowed to specify NULL, in which case the output goes to stdout via
 280.735 +-- the routine print.
 280.736 +--
 280.737 +-- This routine should be called once after the routine mpl_read_model
 280.738 +-- or mpl_read_data and if one of the latters returned the code 2.
 280.739 +--
 280.740 +-- *Returns*
 280.741 +--
 280.742 +-- The routine mpl_generate returns one of the following codes:
 280.743 +--
 280.744 +-- 3 - model has been successfully generated. In this case the calling
 280.745 +--     program may call other api routines to obtain components of the
 280.746 +--     problem instance from the translator database.
 280.747 +-- 4 - processing failed due to some errors. In this case the calling
 280.748 +--     program should call the routine mpl_terminate to terminate model
 280.749 +--     processing. */
 280.750 +
 280.751 +int mpl_generate(MPL *mpl, char *file)
 280.752 +{     if (!(mpl->phase == 1 || mpl->phase == 2))
 280.753 +         xfault("mpl_generate: invalid call sequence\n");
 280.754 +      /* set up error handler */
 280.755 +      if (setjmp(mpl->jump)) goto done;
 280.756 +      /* generate model */
 280.757 +      mpl->phase = 3;
 280.758 +      open_output(mpl, file);
 280.759 +      generate_model(mpl);
 280.760 +      flush_output(mpl);
 280.761 +      /* build problem instance */
 280.762 +      build_problem(mpl);
 280.763 +      /* generation phase has been finished */
 280.764 +      xprintf("Model has been successfully generated\n");
 280.765 +done: /* return to the calling program */
 280.766 +      return mpl->phase;
 280.767 +}
 280.768 +
 280.769 +/*----------------------------------------------------------------------
 280.770 +-- mpl_get_prob_name - obtain problem (model) name.
 280.771 +--
 280.772 +-- *Synopsis*
 280.773 +--
 280.774 +-- #include "glpmpl.h"
 280.775 +-- char *mpl_get_prob_name(MPL *mpl);
 280.776 +--
 280.777 +-- *Returns*
 280.778 +--
 280.779 +-- The routine mpl_get_prob_name returns a pointer to internal buffer,
 280.780 +-- which contains symbolic name of the problem (model).
 280.781 +--
 280.782 +-- *Note*
 280.783 +--
 280.784 +-- Currently MathProg has no feature to assign a symbolic name to the
 280.785 +-- model. Therefore the routine mpl_get_prob_name tries to construct
 280.786 +-- such name using the name of input text file containing model section,
 280.787 +-- although this is not a good idea (due to portability problems). */
 280.788 +
 280.789 +char *mpl_get_prob_name(MPL *mpl)
 280.790 +{     char *name = mpl->mpl_buf;
 280.791 +      char *file = mpl->mod_file;
 280.792 +      int k;
 280.793 +      if (mpl->phase != 3)
 280.794 +         xfault("mpl_get_prob_name: invalid call sequence\n");
 280.795 +      for (;;)
 280.796 +      {  if (strchr(file, '/') != NULL)
 280.797 +            file = strchr(file, '/') + 1;
 280.798 +         else if (strchr(file, '\\') != NULL)
 280.799 +            file = strchr(file, '\\') + 1;
 280.800 +         else if (strchr(file, ':') != NULL)
 280.801 +            file = strchr(file, ':') + 1;
 280.802 +         else
 280.803 +            break;
 280.804 +      }
 280.805 +      for (k = 0; ; k++)
 280.806 +      {  if (k == 255) break;
 280.807 +         if (!(isalnum((unsigned char)*file) || *file == '_')) break;
 280.808 +         name[k] = *file++;
 280.809 +      }
 280.810 +      if (k == 0)
 280.811 +         strcpy(name, "Unknown");
 280.812 +      else
 280.813 +         name[k] = '\0';
 280.814 +      xassert(strlen(name) <= 255);
 280.815 +      return name;
 280.816 +}
 280.817 +
 280.818 +/*----------------------------------------------------------------------
 280.819 +-- mpl_get_num_rows - determine number of rows.
 280.820 +--
 280.821 +-- *Synopsis*
 280.822 +--
 280.823 +-- #include "glpmpl.h"
 280.824 +-- int mpl_get_num_rows(MPL *mpl);
 280.825 +--
 280.826 +-- *Returns*
 280.827 +--
 280.828 +-- The routine mpl_get_num_rows returns total number of rows in the
 280.829 +-- problem, where each row is an individual constraint or objective. */
 280.830 +
 280.831 +int mpl_get_num_rows(MPL *mpl)
 280.832 +{     if (mpl->phase != 3)
 280.833 +         xfault("mpl_get_num_rows: invalid call sequence\n");
 280.834 +      return mpl->m;
 280.835 +}
 280.836 +
 280.837 +/*----------------------------------------------------------------------
 280.838 +-- mpl_get_num_cols - determine number of columns.
 280.839 +--
 280.840 +-- *Synopsis*
 280.841 +--
 280.842 +-- #include "glpmpl.h"
 280.843 +-- int mpl_get_num_cols(MPL *mpl);
 280.844 +--
 280.845 +-- *Returns*
 280.846 +--
 280.847 +-- The routine mpl_get_num_cols returns total number of columns in the
 280.848 +-- problem, where each column is an individual variable. */
 280.849 +
 280.850 +int mpl_get_num_cols(MPL *mpl)
 280.851 +{     if (mpl->phase != 3)
 280.852 +         xfault("mpl_get_num_cols: invalid call sequence\n");
 280.853 +      return mpl->n;
 280.854 +}
 280.855 +
 280.856 +/*----------------------------------------------------------------------
 280.857 +-- mpl_get_row_name - obtain row name.
 280.858 +--
 280.859 +-- *Synopsis*
 280.860 +--
 280.861 +-- #include "glpmpl.h"
 280.862 +-- char *mpl_get_row_name(MPL *mpl, int i);
 280.863 +--
 280.864 +-- *Returns*
 280.865 +--
 280.866 +-- The routine mpl_get_row_name returns a pointer to internal buffer,
 280.867 +-- which contains symbolic name of i-th row of the problem. */
 280.868 +
 280.869 +char *mpl_get_row_name(MPL *mpl, int i)
 280.870 +{     char *name = mpl->mpl_buf, *t;
 280.871 +      int len;
 280.872 +      if (mpl->phase != 3)
 280.873 +         xfault("mpl_get_row_name: invalid call sequence\n");
 280.874 +      if (!(1 <= i && i <= mpl->m))
 280.875 +         xfault("mpl_get_row_name: i = %d; row number out of range\n",
 280.876 +            i);
 280.877 +      strcpy(name, mpl->row[i]->con->name);
 280.878 +      len = strlen(name);
 280.879 +      xassert(len <= 255);
 280.880 +      t = format_tuple(mpl, '[', mpl->row[i]->memb->tuple);
 280.881 +      while (*t)
 280.882 +      {  if (len == 255) break;
 280.883 +         name[len++] = *t++;
 280.884 +      }
 280.885 +      name[len] = '\0';
 280.886 +      if (len == 255) strcpy(name+252, "...");
 280.887 +      xassert(strlen(name) <= 255);
 280.888 +      return name;
 280.889 +}
 280.890 +
 280.891 +/*----------------------------------------------------------------------
 280.892 +-- mpl_get_row_kind - determine row kind.
 280.893 +--
 280.894 +-- *Synopsis*
 280.895 +--
 280.896 +-- #include "glpmpl.h"
 280.897 +-- int mpl_get_row_kind(MPL *mpl, int i);
 280.898 +--
 280.899 +-- *Returns*
 280.900 +--
 280.901 +-- The routine mpl_get_row_kind returns the kind of i-th row, which can
 280.902 +-- be one of the following:
 280.903 +--
 280.904 +-- MPL_ST  - non-free (constraint) row;
 280.905 +-- MPL_MIN - free (objective) row to be minimized;
 280.906 +-- MPL_MAX - free (objective) row to be maximized. */
 280.907 +
 280.908 +int mpl_get_row_kind(MPL *mpl, int i)
 280.909 +{     int kind;
 280.910 +      if (mpl->phase != 3)
 280.911 +         xfault("mpl_get_row_kind: invalid call sequence\n");
 280.912 +      if (!(1 <= i && i <= mpl->m))
 280.913 +         xfault("mpl_get_row_kind: i = %d; row number out of range\n",
 280.914 +            i);
 280.915 +      switch (mpl->row[i]->con->type)
 280.916 +      {  case A_CONSTRAINT:
 280.917 +            kind = MPL_ST; break;
 280.918 +         case A_MINIMIZE:
 280.919 +            kind = MPL_MIN; break;
 280.920 +         case A_MAXIMIZE:
 280.921 +            kind = MPL_MAX; break;
 280.922 +         default:
 280.923 +            xassert(mpl != mpl);
 280.924 +      }
 280.925 +      return kind;
 280.926 +}
 280.927 +
 280.928 +/*----------------------------------------------------------------------
 280.929 +-- mpl_get_row_bnds - obtain row bounds.
 280.930 +--
 280.931 +-- *Synopsis*
 280.932 +--
 280.933 +-- #include "glpmpl.h"
 280.934 +-- int mpl_get_row_bnds(MPL *mpl, int i, double *lb, double *ub);
 280.935 +--
 280.936 +-- *Description*
 280.937 +--
 280.938 +-- The routine mpl_get_row_bnds stores lower and upper bounds of i-th
 280.939 +-- row of the problem to the locations, which the parameters lb and ub
 280.940 +-- point to, respectively. Besides the routine returns the type of the
 280.941 +-- i-th row.
 280.942 +--
 280.943 +-- If some of the parameters lb and ub is NULL, the corresponding bound
 280.944 +-- value is not stored.
 280.945 +--
 280.946 +-- Types and bounds have the following meaning:
 280.947 +--
 280.948 +--     Type           Bounds          Note
 280.949 +--    -----------------------------------------------------------
 280.950 +--    MPL_FR   -inf <  f(x) <  +inf   Free linear form
 280.951 +--    MPL_LO     lb <= f(x) <  +inf   Inequality f(x) >= lb
 280.952 +--    MPL_UP   -inf <  f(x) <=  ub    Inequality f(x) <= ub
 280.953 +--    MPL_DB     lb <= f(x) <=  ub    Inequality lb <= f(x) <= ub
 280.954 +--    MPL_FX           f(x)  =  lb    Equality f(x) = lb
 280.955 +--
 280.956 +-- where f(x) is the corresponding linear form of the i-th row.
 280.957 +--
 280.958 +-- If the row has no lower bound, *lb is set to zero; if the row has
 280.959 +-- no upper bound, *ub is set to zero; and if the row is of fixed type,
 280.960 +-- both *lb and *ub are set to the same value.
 280.961 +--
 280.962 +-- *Returns*
 280.963 +--
 280.964 +-- The routine returns the type of the i-th row as it is stated in the
 280.965 +-- table above. */
 280.966 +
 280.967 +int mpl_get_row_bnds(MPL *mpl, int i, double *_lb, double *_ub)
 280.968 +{     ELEMCON *con;
 280.969 +      int type;
 280.970 +      double lb, ub;
 280.971 +      if (mpl->phase != 3)
 280.972 +         xfault("mpl_get_row_bnds: invalid call sequence\n");
 280.973 +      if (!(1 <= i && i <= mpl->m))
 280.974 +         xfault("mpl_get_row_bnds: i = %d; row number out of range\n",
 280.975 +            i);
 280.976 +      con = mpl->row[i];
 280.977 +#if 0 /* 21/VII-2006 */
 280.978 +      if (con->con->lbnd == NULL && con->con->ubnd == NULL)
 280.979 +         type = MPL_FR, lb = ub = 0.0;
 280.980 +      else if (con->con->ubnd == NULL)
 280.981 +         type = MPL_LO, lb = con->lbnd, ub = 0.0;
 280.982 +      else if (con->con->lbnd == NULL)
 280.983 +         type = MPL_UP, lb = 0.0, ub = con->ubnd;
 280.984 +      else if (con->con->lbnd != con->con->ubnd)
 280.985 +         type = MPL_DB, lb = con->lbnd, ub = con->ubnd;
 280.986 +      else
 280.987 +         type = MPL_FX, lb = ub = con->lbnd;
 280.988 +#else
 280.989 +      lb = (con->con->lbnd == NULL ? -DBL_MAX : con->lbnd);
 280.990 +      ub = (con->con->ubnd == NULL ? +DBL_MAX : con->ubnd);
 280.991 +      if (lb == -DBL_MAX && ub == +DBL_MAX)
 280.992 +         type = MPL_FR, lb = ub = 0.0;
 280.993 +      else if (ub == +DBL_MAX)
 280.994 +         type = MPL_LO, ub = 0.0;
 280.995 +      else if (lb == -DBL_MAX)
 280.996 +         type = MPL_UP, lb = 0.0;
 280.997 +      else if (con->con->lbnd != con->con->ubnd)
 280.998 +         type = MPL_DB;
 280.999 +      else
280.1000 +         type = MPL_FX;
280.1001 +#endif
280.1002 +      if (_lb != NULL) *_lb = lb;
280.1003 +      if (_ub != NULL) *_ub = ub;
280.1004 +      return type;
280.1005 +}
280.1006 +
280.1007 +/*----------------------------------------------------------------------
280.1008 +-- mpl_get_mat_row - obtain row of the constraint matrix.
280.1009 +--
280.1010 +-- *Synopsis*
280.1011 +--
280.1012 +-- #include "glpmpl.h"
280.1013 +-- int mpl_get_mat_row(MPL *mpl, int i, int ndx[], double val[]);
280.1014 +--
280.1015 +-- *Description*
280.1016 +--
280.1017 +-- The routine mpl_get_mat_row stores column indices and numeric values
280.1018 +-- of constraint coefficients for the i-th row to locations ndx[1], ...,
280.1019 +-- ndx[len] and val[1], ..., val[len], respectively, where 0 <= len <= n
280.1020 +-- is number of (structural) non-zero constraint coefficients, and n is
280.1021 +-- number of columns in the problem.
280.1022 +--
280.1023 +-- If the parameter ndx is NULL, column indices are not stored. If the
280.1024 +-- parameter val is NULL, numeric values are not stored.
280.1025 +--
280.1026 +-- Note that free rows may have constant terms, which are not part of
280.1027 +-- the constraint matrix and therefore not reported by this routine. The
280.1028 +-- constant term of a particular row can be obtained, if necessary, via
280.1029 +-- the routine mpl_get_row_c0.
280.1030 +--
280.1031 +-- *Returns*
280.1032 +--
280.1033 +-- The routine mpl_get_mat_row returns len, which is length of i-th row
280.1034 +-- of the constraint matrix (i.e. number of non-zero coefficients). */
280.1035 +
280.1036 +int mpl_get_mat_row(MPL *mpl, int i, int ndx[], double val[])
280.1037 +{     FORMULA *term;
280.1038 +      int len = 0;
280.1039 +      if (mpl->phase != 3)
280.1040 +         xfault("mpl_get_mat_row: invalid call sequence\n");
280.1041 +      if (!(1 <= i && i <= mpl->m))
280.1042 +         xfault("mpl_get_mat_row: i = %d; row number out of range\n",
280.1043 +            i);
280.1044 +      for (term = mpl->row[i]->form; term != NULL; term = term->next)
280.1045 +      {  xassert(term->var != NULL);
280.1046 +         len++;
280.1047 +         xassert(len <= mpl->n);
280.1048 +         if (ndx != NULL) ndx[len] = term->var->j;
280.1049 +         if (val != NULL) val[len] = term->coef;
280.1050 +      }
280.1051 +      return len;
280.1052 +}
280.1053 +
280.1054 +/*----------------------------------------------------------------------
280.1055 +-- mpl_get_row_c0 - obtain constant term of free row.
280.1056 +--
280.1057 +-- *Synopsis*
280.1058 +--
280.1059 +-- #include "glpmpl.h"
280.1060 +-- double mpl_get_row_c0(MPL *mpl, int i);
280.1061 +--
280.1062 +-- *Returns*
280.1063 +--
280.1064 +-- The routine mpl_get_row_c0 returns numeric value of constant term of
280.1065 +-- i-th row.
280.1066 +--
280.1067 +-- Note that only free rows may have non-zero constant terms. Therefore
280.1068 +-- if i-th row is not free, the routine returns zero. */
280.1069 +
280.1070 +double mpl_get_row_c0(MPL *mpl, int i)
280.1071 +{     ELEMCON *con;
280.1072 +      double c0;
280.1073 +      if (mpl->phase != 3)
280.1074 +         xfault("mpl_get_row_c0: invalid call sequence\n");
280.1075 +      if (!(1 <= i && i <= mpl->m))
280.1076 +         xfault("mpl_get_row_c0: i = %d; row number out of range\n",
280.1077 +            i);
280.1078 +      con = mpl->row[i];
280.1079 +      if (con->con->lbnd == NULL && con->con->ubnd == NULL)
280.1080 +         c0 = - con->lbnd;
280.1081 +      else
280.1082 +         c0 = 0.0;
280.1083 +      return c0;
280.1084 +}
280.1085 +
280.1086 +/*----------------------------------------------------------------------
280.1087 +-- mpl_get_col_name - obtain column name.
280.1088 +--
280.1089 +-- *Synopsis*
280.1090 +--
280.1091 +-- #include "glpmpl.h"
280.1092 +-- char *mpl_get_col_name(MPL *mpl, int j);
280.1093 +--
280.1094 +-- *Returns*
280.1095 +--
280.1096 +-- The routine mpl_get_col_name returns a pointer to internal buffer,
280.1097 +-- which contains symbolic name of j-th column of the problem. */
280.1098 +
280.1099 +char *mpl_get_col_name(MPL *mpl, int j)
280.1100 +{     char *name = mpl->mpl_buf, *t;
280.1101 +      int len;
280.1102 +      if (mpl->phase != 3)
280.1103 +         xfault("mpl_get_col_name: invalid call sequence\n");
280.1104 +      if (!(1 <= j && j <= mpl->n))
280.1105 +         xfault("mpl_get_col_name: j = %d; column number out of range\n"
280.1106 +            , j);
280.1107 +      strcpy(name, mpl->col[j]->var->name);
280.1108 +      len = strlen(name);
280.1109 +      xassert(len <= 255);
280.1110 +      t = format_tuple(mpl, '[', mpl->col[j]->memb->tuple);
280.1111 +      while (*t)
280.1112 +      {  if (len == 255) break;
280.1113 +         name[len++] = *t++;
280.1114 +      }
280.1115 +      name[len] = '\0';
280.1116 +      if (len == 255) strcpy(name+252, "...");
280.1117 +      xassert(strlen(name) <= 255);
280.1118 +      return name;
280.1119 +}
280.1120 +
280.1121 +/*----------------------------------------------------------------------
280.1122 +-- mpl_get_col_kind - determine column kind.
280.1123 +--
280.1124 +-- *Synopsis*
280.1125 +--
280.1126 +-- #include "glpmpl.h"
280.1127 +-- int mpl_get_col_kind(MPL *mpl, int j);
280.1128 +--
280.1129 +-- *Returns*
280.1130 +--
280.1131 +-- The routine mpl_get_col_kind returns the kind of j-th column, which
280.1132 +-- can be one of the following:
280.1133 +--
280.1134 +-- MPL_NUM - continuous variable;
280.1135 +-- MPL_INT - integer variable;
280.1136 +-- MPL_BIN - binary variable.
280.1137 +--
280.1138 +-- Note that column kinds are defined independently on type and bounds
280.1139 +-- (reported by the routine mpl_get_col_bnds) of corresponding columns.
280.1140 +-- This means, in particular, that bounds of an integer column may be
280.1141 +-- fractional, or a binary column may have lower and upper bounds that
280.1142 +-- are not 0 and 1 (or it may have no lower/upper bound at all). */
280.1143 +
280.1144 +int mpl_get_col_kind(MPL *mpl, int j)
280.1145 +{     int kind;
280.1146 +      if (mpl->phase != 3)
280.1147 +         xfault("mpl_get_col_kind: invalid call sequence\n");
280.1148 +      if (!(1 <= j && j <= mpl->n))
280.1149 +         xfault("mpl_get_col_kind: j = %d; column number out of range\n"
280.1150 +            , j);
280.1151 +      switch (mpl->col[j]->var->type)
280.1152 +      {  case A_NUMERIC:
280.1153 +            kind = MPL_NUM; break;
280.1154 +         case A_INTEGER:
280.1155 +            kind = MPL_INT; break;
280.1156 +         case A_BINARY:
280.1157 +            kind = MPL_BIN; break;
280.1158 +         default:
280.1159 +            xassert(mpl != mpl);
280.1160 +      }
280.1161 +      return kind;
280.1162 +}
280.1163 +
280.1164 +/*----------------------------------------------------------------------
280.1165 +-- mpl_get_col_bnds - obtain column bounds.
280.1166 +--
280.1167 +-- *Synopsis*
280.1168 +--
280.1169 +-- #include "glpmpl.h"
280.1170 +-- int mpl_get_col_bnds(MPL *mpl, int j, double *lb, double *ub);
280.1171 +--
280.1172 +-- *Description*
280.1173 +--
280.1174 +-- The routine mpl_get_col_bnds stores lower and upper bound of j-th
280.1175 +-- column of the problem to the locations, which the parameters lb and
280.1176 +-- ub point to, respectively. Besides the routine returns the type of
280.1177 +-- the j-th column.
280.1178 +--
280.1179 +-- If some of the parameters lb and ub is NULL, the corresponding bound
280.1180 +-- value is not stored.
280.1181 +--
280.1182 +-- Types and bounds have the following meaning:
280.1183 +--
280.1184 +--     Type         Bounds         Note
280.1185 +--    ------------------------------------------------------
280.1186 +--    MPL_FR   -inf <  x <  +inf   Free (unbounded) variable
280.1187 +--    MPL_LO     lb <= x <  +inf   Variable with lower bound
280.1188 +--    MPL_UP   -inf <  x <=  ub    Variable with upper bound
280.1189 +--    MPL_DB     lb <= x <=  ub    Double-bounded variable
280.1190 +--    MPL_FX           x  =  lb    Fixed variable
280.1191 +--
280.1192 +-- where x is individual variable corresponding to the j-th column.
280.1193 +--
280.1194 +-- If the column has no lower bound, *lb is set to zero; if the column
280.1195 +-- has no upper bound, *ub is set to zero; and if the column is of fixed
280.1196 +-- type, both *lb and *ub are set to the same value.
280.1197 +--
280.1198 +-- *Returns*
280.1199 +--
280.1200 +-- The routine returns the type of the j-th column as it is stated in
280.1201 +-- the table above. */
280.1202 +
280.1203 +int mpl_get_col_bnds(MPL *mpl, int j, double *_lb, double *_ub)
280.1204 +{     ELEMVAR *var;
280.1205 +      int type;
280.1206 +      double lb, ub;
280.1207 +      if (mpl->phase != 3)
280.1208 +         xfault("mpl_get_col_bnds: invalid call sequence\n");
280.1209 +      if (!(1 <= j && j <= mpl->n))
280.1210 +         xfault("mpl_get_col_bnds: j = %d; column number out of range\n"
280.1211 +            , j);
280.1212 +      var = mpl->col[j];
280.1213 +#if 0 /* 21/VII-2006 */
280.1214 +      if (var->var->lbnd == NULL && var->var->ubnd == NULL)
280.1215 +         type = MPL_FR, lb = ub = 0.0;
280.1216 +      else if (var->var->ubnd == NULL)
280.1217 +         type = MPL_LO, lb = var->lbnd, ub = 0.0;
280.1218 +      else if (var->var->lbnd == NULL)
280.1219 +         type = MPL_UP, lb = 0.0, ub = var->ubnd;
280.1220 +      else if (var->var->lbnd != var->var->ubnd)
280.1221 +         type = MPL_DB, lb = var->lbnd, ub = var->ubnd;
280.1222 +      else
280.1223 +         type = MPL_FX, lb = ub = var->lbnd;
280.1224 +#else
280.1225 +      lb = (var->var->lbnd == NULL ? -DBL_MAX : var->lbnd);
280.1226 +      ub = (var->var->ubnd == NULL ? +DBL_MAX : var->ubnd);
280.1227 +      if (lb == -DBL_MAX && ub == +DBL_MAX)
280.1228 +         type = MPL_FR, lb = ub = 0.0;
280.1229 +      else if (ub == +DBL_MAX)
280.1230 +         type = MPL_LO, ub = 0.0;
280.1231 +      else if (lb == -DBL_MAX)
280.1232 +         type = MPL_UP, lb = 0.0;
280.1233 +      else if (var->var->lbnd != var->var->ubnd)
280.1234 +         type = MPL_DB;
280.1235 +      else
280.1236 +         type = MPL_FX;
280.1237 +#endif
280.1238 +      if (_lb != NULL) *_lb = lb;
280.1239 +      if (_ub != NULL) *_ub = ub;
280.1240 +      return type;
280.1241 +}
280.1242 +
280.1243 +/*----------------------------------------------------------------------
280.1244 +-- mpl_has_solve_stmt - check if model has solve statement.
280.1245 +--
280.1246 +-- *Synopsis*
280.1247 +--
280.1248 +-- #include "glpmpl.h"
280.1249 +-- int mpl_has_solve_stmt(MPL *mpl);
280.1250 +--
280.1251 +-- *Returns*
280.1252 +--
280.1253 +-- If the model has the solve statement, the routine returns non-zero,
280.1254 +-- otherwise zero is returned. */
280.1255 +
280.1256 +int mpl_has_solve_stmt(MPL *mpl)
280.1257 +{     if (mpl->phase != 3)
280.1258 +         xfault("mpl_has_solve_stmt: invalid call sequence\n");
280.1259 +      return mpl->flag_s;
280.1260 +}
280.1261 +
280.1262 +#if 1 /* 15/V-2010 */
280.1263 +void mpl_put_row_soln(MPL *mpl, int i, int stat, double prim,
280.1264 +      double dual)
280.1265 +{     /* store row (constraint/objective) solution components */
280.1266 +      xassert(mpl->phase == 3);
280.1267 +      xassert(1 <= i && i <= mpl->m);
280.1268 +      mpl->row[i]->stat = stat;
280.1269 +      mpl->row[i]->prim = prim;
280.1270 +      mpl->row[i]->dual = dual;
280.1271 +      return;
280.1272 +}
280.1273 +#endif
280.1274 +
280.1275 +#if 1 /* 15/V-2010 */
280.1276 +void mpl_put_col_soln(MPL *mpl, int j, int stat, double prim,
280.1277 +      double dual)
280.1278 +{     /* store column (variable) solution components */
280.1279 +      xassert(mpl->phase == 3);
280.1280 +      xassert(1 <= j && j <= mpl->n);
280.1281 +      mpl->col[j]->stat = stat;
280.1282 +      mpl->col[j]->prim = prim;
280.1283 +      mpl->col[j]->dual = dual;
280.1284 +      return;
280.1285 +}
280.1286 +#endif
280.1287 +
280.1288 +#if 0 /* 15/V-2010 */
280.1289 +/*----------------------------------------------------------------------
280.1290 +-- mpl_put_col_value - store column value.
280.1291 +--
280.1292 +-- *Synopsis*
280.1293 +--
280.1294 +-- #include "glpmpl.h"
280.1295 +-- void mpl_put_col_value(MPL *mpl, int j, double val);
280.1296 +--
280.1297 +-- *Description*
280.1298 +--
280.1299 +-- The routine mpl_put_col_value stores numeric value of j-th column
280.1300 +-- into the translator database. It is assumed that the column value is
280.1301 +-- provided by the solver. */
280.1302 +
280.1303 +void mpl_put_col_value(MPL *mpl, int j, double val)
280.1304 +{     if (mpl->phase != 3)
280.1305 +         xfault("mpl_put_col_value: invalid call sequence\n");
280.1306 +      if (!(1 <= j && j <= mpl->n))
280.1307 +         xfault(
280.1308 +         "mpl_put_col_value: j = %d; column number out of range\n", j);
280.1309 +      mpl->col[j]->prim = val;
280.1310 +      return;
280.1311 +}
280.1312 +#endif
280.1313 +
280.1314 +/*----------------------------------------------------------------------
280.1315 +-- mpl_postsolve - postsolve model.
280.1316 +--
280.1317 +-- *Synopsis*
280.1318 +--
280.1319 +-- #include "glpmpl.h"
280.1320 +-- int mpl_postsolve(MPL *mpl);
280.1321 +--
280.1322 +-- *Description*
280.1323 +--
280.1324 +-- The routine mpl_postsolve performs postsolving of the model using
280.1325 +-- its description stored in the translator database. This phase means
280.1326 +-- executing statements, which follow the solve statement.
280.1327 +--
280.1328 +-- If this routine is used, it should be called once after the routine
280.1329 +-- mpl_generate and if the latter returned the code 3.
280.1330 +--
280.1331 +-- *Returns*
280.1332 +--
280.1333 +-- The routine mpl_postsolve returns one of the following codes:
280.1334 +--
280.1335 +-- 3 - model has been successfully postsolved.
280.1336 +-- 4 - processing failed due to some errors. In this case the calling
280.1337 +--     program should call the routine mpl_terminate to terminate model
280.1338 +--     processing. */
280.1339 +
280.1340 +int mpl_postsolve(MPL *mpl)
280.1341 +{     if (!(mpl->phase == 3 && !mpl->flag_p))
280.1342 +         xfault("mpl_postsolve: invalid call sequence\n");
280.1343 +      /* set up error handler */
280.1344 +      if (setjmp(mpl->jump)) goto done;
280.1345 +      /* perform postsolving */
280.1346 +      postsolve_model(mpl);
280.1347 +      flush_output(mpl);
280.1348 +      /* postsolving phase has been finished */
280.1349 +      xprintf("Model has been successfully processed\n");
280.1350 +done: /* return to the calling program */
280.1351 +      return mpl->phase;
280.1352 +}
280.1353 +
280.1354 +/*----------------------------------------------------------------------
280.1355 +-- mpl_terminate - free all resources used by translator.
280.1356 +--
280.1357 +-- *Synopsis*
280.1358 +--
280.1359 +-- #include "glpmpl.h"
280.1360 +-- void mpl_terminate(MPL *mpl);
280.1361 +--
280.1362 +-- *Description*
280.1363 +--
280.1364 +-- The routine mpl_terminate frees all the resources used by the GNU
280.1365 +-- MathProg translator. */
280.1366 +
280.1367 +void mpl_terminate(MPL *mpl)
280.1368 +{     if (setjmp(mpl->jump)) xassert(mpl != mpl);
280.1369 +      switch (mpl->phase)
280.1370 +      {  case 0:
280.1371 +         case 1:
280.1372 +         case 2:
280.1373 +         case 3:
280.1374 +            /* there were no errors; clean the model content */
280.1375 +            clean_model(mpl);
280.1376 +            xassert(mpl->a_list == NULL);
280.1377 +#if 1 /* 11/II-2008 */
280.1378 +            xassert(mpl->dca == NULL);
280.1379 +#endif
280.1380 +            break;
280.1381 +         case 4:
280.1382 +            /* model processing has been finished due to error; delete
280.1383 +               search trees, which may be created for some arrays */
280.1384 +            {  ARRAY *a;
280.1385 +               for (a = mpl->a_list; a != NULL; a = a->next)
280.1386 +                  if (a->tree != NULL) avl_delete_tree(a->tree);
280.1387 +            }
280.1388 +#if 1 /* 11/II-2008 */
280.1389 +            free_dca(mpl);
280.1390 +#endif
280.1391 +            break;
280.1392 +         default:
280.1393 +            xassert(mpl != mpl);
280.1394 +      }
280.1395 +      /* delete the translator database */
280.1396 +      xfree(mpl->image);
280.1397 +      xfree(mpl->b_image);
280.1398 +      xfree(mpl->f_image);
280.1399 +      xfree(mpl->context);
280.1400 +      dmp_delete_pool(mpl->pool);
280.1401 +      avl_delete_tree(mpl->tree);
280.1402 +      dmp_delete_pool(mpl->strings);
280.1403 +      dmp_delete_pool(mpl->symbols);
280.1404 +      dmp_delete_pool(mpl->tuples);
280.1405 +      dmp_delete_pool(mpl->arrays);
280.1406 +      dmp_delete_pool(mpl->members);
280.1407 +      dmp_delete_pool(mpl->elemvars);
280.1408 +      dmp_delete_pool(mpl->formulae);
280.1409 +      dmp_delete_pool(mpl->elemcons);
280.1410 +      xfree(mpl->sym_buf);
280.1411 +      xfree(mpl->tup_buf);
280.1412 +      rng_delete_rand(mpl->rand);
280.1413 +      if (mpl->row != NULL) xfree(mpl->row);
280.1414 +      if (mpl->col != NULL) xfree(mpl->col);
280.1415 +      if (mpl->in_fp != NULL) xfclose(mpl->in_fp);
280.1416 +      if (mpl->out_fp != NULL && mpl->out_fp != (void *)stdout)
280.1417 +         xfclose(mpl->out_fp);
280.1418 +      if (mpl->out_file != NULL) xfree(mpl->out_file);
280.1419 +      if (mpl->prt_fp != NULL) xfclose(mpl->prt_fp);
280.1420 +      if (mpl->prt_file != NULL) xfree(mpl->prt_file);
280.1421 +      if (mpl->mod_file != NULL) xfree(mpl->mod_file);
280.1422 +      xfree(mpl->mpl_buf);
280.1423 +      xfree(mpl);
280.1424 +      return;
280.1425 +}
280.1426 +
280.1427 +/* eof */
   281.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
   281.2 +++ b/deps/glpk/src/glpmpl05.c	Sun Nov 06 20:59:10 2011 +0100
   281.3 @@ -0,0 +1,562 @@
   281.4 +/* glpmpl05.c */
   281.5 +
   281.6 +/***********************************************************************
   281.7 +*  This code is part of GLPK (GNU Linear Programming Kit).
   281.8 +*
   281.9 +*  Authors: Andrew Makhorin <mao@gnu.org>
  281.10 +*           Heinrich Schuchardt <xypron.glpk@gmx.de>
  281.11 +*
  281.12 +*  Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008,
  281.13 +*  2009, 2010, 2011 Andrew Makhorin, Department for Applied Informatics,
  281.14 +*  Moscow Aviation Institute, Moscow, Russia. All rights reserved.
  281.15 +*  E-mail: <mao@gnu.org>.
  281.16 +*
  281.17 +*  GLPK is free software: you can redistribute it and/or modify it
  281.18 +*  under the terms of the GNU General Public License as published by
  281.19 +*  the Free Software Foundation, either version 3 of the License, or
  281.20 +*  (at your option) any later version.
  281.21 +*
  281.22 +*  GLPK is distributed in the hope that it will be useful, but WITHOUT
  281.23 +*  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
  281.24 +*  or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
  281.25 +*  License for more details.
  281.26 +*
  281.27 +*  You should have received a copy of the GNU General Public License
  281.28 +*  along with GLPK. If not, see <http://www.gnu.org/licenses/>.
  281.29 +***********************************************************************/
  281.30 +
  281.31 +#define _GLPSTD_STDIO
  281.32 +#define _GLPSTD_TIME
  281.33 +#include "glpmpl.h"
  281.34 +
  281.35 +double fn_gmtime(MPL *mpl)
  281.36 +{     /* obtain the current calendar time (UTC) */
  281.37 +      time_t timer;
  281.38 +      struct tm *tm;
  281.39 +      int j;
  281.40 +      time(&timer);
  281.41 +      if (timer == (time_t)(-1))
  281.42 +err:     error(mpl, "gmtime(); unable to obtain current calendar time");
  281.43 +      tm = gmtime(&timer);
  281.44 +      if (tm == NULL) goto err;
  281.45 +      j = jday(tm->tm_mday, tm->tm_mon + 1, 1900 + tm->tm_year);
  281.46 +      if (j < 0) goto err;
  281.47 +      return (((double)(j - jday(1, 1, 1970)) * 24.0 +
  281.48 +         (double)tm->tm_hour) * 60.0 + (double)tm->tm_min) * 60.0 +
  281.49 +         (double)tm->tm_sec;
  281.50 +}
  281.51 +
  281.52 +static char *week[] = { "Monday", "Tuesday", "Wednesday", "Thursday",
  281.53 +      "Friday", "Saturday", "Sunday" };
  281.54 +
  281.55 +static char *moon[] = { "January", "February", "March", "April", "May",
  281.56 +      "June", "July", "August", "September", "October", "November",
  281.57 +      "December" };
  281.58 +
  281.59 +static void error1(MPL *mpl, const char *str, const char *s,
  281.60 +      const char *fmt, const char *f, const char *msg)
  281.61 +{     xprintf("Input string passed to str2time:\n");
  281.62 +      xprintf("%s\n", str);
  281.63 +      xprintf("%*s\n", (s - str) + 1, "^");
  281.64 +      xprintf("Format string passed to str2time:\n");
  281.65 +      xprintf("%s\n", fmt);
  281.66 +      xprintf("%*s\n", (f - fmt) + 1, "^");
  281.67 +      error(mpl, "%s", msg);
  281.68 +      /* no return */
  281.69 +}
  281.70 +
  281.71 +double fn_str2time(MPL *mpl, const char *str, const char *fmt)
  281.72 +{     /* convert character string to the calendar time */
  281.73 +      int j, year, month, day, hh, mm, ss, zone;
  281.74 +      const char *s, *f;
  281.75 +      year = month = day = hh = mm = ss = -1, zone = INT_MAX;
  281.76 +      s = str;
  281.77 +      for (f = fmt; *f != '\0'; f++)
  281.78 +      {  if (*f == '%')
  281.79 +         {  f++;
  281.80 +            if (*f == 'b' || *f == 'h')
  281.81 +            {  /* the abbreviated month name */
  281.82 +               int k;
  281.83 +               char *name;
  281.84 +               if (month >= 0)
  281.85 +                  error1(mpl, str, s, fmt, f, "month multiply specified"
  281.86 +                     );
  281.87 +               while (*s == ' ') s++;
  281.88 +               for (month = 1; month <= 12; month++)
  281.89 +               {  name = moon[month-1];
  281.90 +                  for (k = 0; k <= 2; k++)
  281.91 +                  {  if (toupper((unsigned char)s[k]) !=
  281.92 +                         toupper((unsigned char)name[k])) goto next;
  281.93 +                  }
  281.94 +                  s += 3;
  281.95 +                  for (k = 3; name[k] != '\0'; k++)
  281.96 +                  {  if (toupper((unsigned char)*s) !=
  281.97 +                         toupper((unsigned char)name[k])) break;
  281.98 +                     s++;
  281.99 +                  }
 281.100 +                  break;
 281.101 +next:             ;
 281.102 +               }
 281.103 +               if (month > 12)
 281.104 +                  error1(mpl, str, s, fmt, f, "abbreviated month name m"
 281.105 +                     "issing or invalid");
 281.106 +            }
 281.107 +            else if (*f == 'd')
 281.108 +            {  /* the day of the month as a decimal number (01..31) */
 281.109 +               if (day >= 0)
 281.110 +                  error1(mpl, str, s, fmt, f, "day multiply specified");
 281.111 +               while (*s == ' ') s++;
 281.112 +               if (!('0' <= *s && *s <= '9'))
 281.113 +                  error1(mpl, str, s, fmt, f, "day missing or invalid");
 281.114 +               day = (*s++) - '0';
 281.115 +               if ('0' <= *s && *s <= '9')
 281.116 +                  day = 10 * day + ((*s++) - '0');
 281.117 +               if (!(1 <= day && day <= 31))
 281.118 +                  error1(mpl, str, s, fmt, f, "day out of range");
 281.119 +            }
 281.120 +            else if (*f == 'H')
 281.121 +            {  /* the hour as a decimal number, using a 24-hour clock
 281.122 +                  (00..23) */
 281.123 +               if (hh >= 0)
 281.124 +                  error1(mpl, str, s, fmt, f, "hour multiply specified")
 281.125 +                     ;
 281.126 +               while (*s == ' ') s++;
 281.127 +               if (!('0' <= *s && *s <= '9'))
 281.128 +                  error1(mpl, str, s, fmt, f, "hour missing or invalid")
 281.129 +                     ;
 281.130 +               hh = (*s++) - '0';
 281.131 +               if ('0' <= *s && *s <= '9')
 281.132 +                  hh = 10 * hh + ((*s++) - '0');
 281.133 +               if (!(0 <= hh && hh <= 23))
 281.134 +                  error1(mpl, str, s, fmt, f, "hour out of range");
 281.135 +            }
 281.136 +            else if (*f == 'm')
 281.137 +            {  /* the month as a decimal number (01..12) */
 281.138 +               if (month >= 0)
 281.139 +                  error1(mpl, str, s, fmt, f, "month multiply specified"
 281.140 +                     );
 281.141 +               while (*s == ' ') s++;
 281.142 +               if (!('0' <= *s && *s <= '9'))
 281.143 +                  error1(mpl, str, s, fmt, f, "month missing or invalid"
 281.144 +                     );
 281.145 +               month = (*s++) - '0';
 281.146 +               if ('0' <= *s && *s <= '9')
 281.147 +                  month = 10 * month + ((*s++) - '0');
 281.148 +               if (!(1 <= month && month <= 12))
 281.149 +                  error1(mpl, str, s, fmt, f, "month out of range");
 281.150 +            }
 281.151 +            else if (*f == 'M')
 281.152 +            {  /* the minute as a decimal number (00..59) */
 281.153 +               if (mm >= 0)
 281.154 +                  error1(mpl, str, s, fmt, f, "minute multiply specifie"
 281.155 +                     "d");
 281.156 +               while (*s == ' ') s++;
 281.157 +               if (!('0' <= *s && *s <= '9'))
 281.158 +                  error1(mpl, str, s, fmt, f, "minute missing or invali"
 281.159 +                     "d");
 281.160 +               mm = (*s++) - '0';
 281.161 +               if ('0' <= *s && *s <= '9')
 281.162 +                  mm = 10 * mm + ((*s++) - '0');
 281.163 +               if (!(0 <= mm && mm <= 59))
 281.164 +                  error1(mpl, str, s, fmt, f, "minute out of range");
 281.165 +            }
 281.166 +            else if (*f == 'S')
 281.167 +            {  /* the second as a decimal number (00..60) */
 281.168 +               if (ss >= 0)
 281.169 +                  error1(mpl, str, s, fmt, f, "second multiply specifie"
 281.170 +                     "d");
 281.171 +               while (*s == ' ') s++;
 281.172 +               if (!('0' <= *s && *s <= '9'))
 281.173 +                  error1(mpl, str, s, fmt, f, "second missing or invali"
 281.174 +                     "d");
 281.175 +               ss = (*s++) - '0';
 281.176 +               if ('0' <= *s && *s <= '9')
 281.177 +                  ss = 10 * ss + ((*s++) - '0');
 281.178 +               if (!(0 <= ss && ss <= 60))
 281.179 +                  error1(mpl, str, s, fmt, f, "second out of range");
 281.180 +            }
 281.181 +            else if (*f == 'y')
 281.182 +            {  /* the year without a century as a decimal number
 281.183 +                  (00..99); the values 00 to 68 mean the years 2000 to
 281.184 +                  2068 while the values 69 to 99 mean the years 1969 to
 281.185 +                  1999 */
 281.186 +               if (year >= 0)
 281.187 +                  error1(mpl, str, s, fmt, f, "year multiply specified")
 281.188 +                     ;
 281.189 +               while (*s == ' ') s++;
 281.190 +               if (!('0' <= *s && *s <= '9'))
 281.191 +                  error1(mpl, str, s, fmt, f, "year missing or invalid")
 281.192 +                     ;
 281.193 +               year = (*s++) - '0';
 281.194 +               if ('0' <= *s && *s <= '9')
 281.195 +                  year = 10 * year + ((*s++) - '0');
 281.196 +               year += (year >= 69 ? 1900 : 2000);
 281.197 +            }
 281.198 +            else if (*f == 'Y')
 281.199 +            {  /* the year as a decimal number, using the Gregorian
 281.200 +                  calendar */
 281.201 +               if (year >= 0)
 281.202 +                  error1(mpl, str, s, fmt, f, "year multiply specified")
 281.203 +                     ;
 281.204 +               while (*s == ' ') s++;
 281.205 +               if (!('0' <= *s && *s <= '9'))
 281.206 +                  error1(mpl, str, s, fmt, f, "year missing or invalid")
 281.207 +                     ;
 281.208 +               year = 0;
 281.209 +               for (j = 1; j <= 4; j++)
 281.210 +               {  if (!('0' <= *s && *s <= '9')) break;
 281.211 +                  year = 10 * year + ((*s++) - '0');
 281.212 +               }
 281.213 +               if (!(1 <= year && year <= 4000))
 281.214 +                  error1(mpl, str, s, fmt, f, "year out of range");
 281.215 +            }
 281.216 +            else if (*f == 'z')
 281.217 +            {  /* time zone offset in the form zhhmm */
 281.218 +               int z, hh, mm;
 281.219 +               if (zone != INT_MAX)
 281.220 +                  error1(mpl, str, s, fmt, f, "time zone offset multipl"
 281.221 +                     "y specified");
 281.222 +               while (*s == ' ') s++;
 281.223 +               if (*s == 'Z')
 281.224 +               {  z = hh = mm = 0, s++;
 281.225 +                  goto skip;
 281.226 +               }
 281.227 +               if (*s == '+')
 281.228 +                  z = +1, s++;
 281.229 +               else if (*s == '-')
 281.230 +                  z = -1, s++;
 281.231 +               else
 281.232 +                  error1(mpl, str, s, fmt, f, "time zone offset sign mi"
 281.233 +                     "ssing");
 281.234 +               hh = 0;
 281.235 +               for (j = 1; j <= 2; j++)
 281.236 +               {  if (!('0' <= *s && *s <= '9'))
 281.237 +err1:                error1(mpl, str, s, fmt, f, "time zone offset valu"
 281.238 +                        "e incomplete or invalid");
 281.239 +                  hh = 10 * hh + ((*s++) - '0');
 281.240 +               }
 281.241 +               if (hh > 23)
 281.242 +err2:             error1(mpl, str, s, fmt, f, "time zone offset value o"
 281.243 +                     "ut of range");
 281.244 +               if (*s == ':')
 281.245 +               {  s++;
 281.246 +                  if (!('0' <= *s && *s <= '9')) goto err1;
 281.247 +               }
 281.248 +               mm = 0;
 281.249 +               if (!('0' <= *s && *s <= '9')) goto skip;
 281.250 +               for (j = 1; j <= 2; j++)
 281.251 +               {  if (!('0' <= *s && *s <= '9')) goto err1;
 281.252 +                  mm = 10 * mm + ((*s++) - '0');
 281.253 +               }
 281.254 +               if (mm > 59) goto err2;
 281.255 +skip:          zone = z * (60 * hh + mm);
 281.256 +            }
 281.257 +            else if (*f == '%')
 281.258 +            {  /* literal % character */
 281.259 +               goto test;
 281.260 +            }
 281.261 +            else
 281.262 +               error1(mpl, str, s, fmt, f, "invalid conversion specifie"
 281.263 +                  "r");
 281.264 +         }
 281.265 +         else if (*f == ' ')
 281.266 +            ;
 281.267 +         else
 281.268 +test:    {  /* check a matching character in the input string */
 281.269 +            if (*s != *f)
 281.270 +               error1(mpl, str, s, fmt, f, "character mismatch");
 281.271 +            s++;
 281.272 +         }
 281.273 +      }
 281.274 +      if (year < 0) year = 1970;
 281.275 +      if (month < 0) month = 1;
 281.276 +      if (day < 0) day = 1;
 281.277 +      if (hh < 0) hh = 0;
 281.278 +      if (mm < 0) mm = 0;
 281.279 +      if (ss < 0) ss = 0;
 281.280 +      if (zone == INT_MAX) zone = 0;
 281.281 +      j = jday(day, month, year);
 281.282 +      xassert(j >= 0);
 281.283 +      return (((double)(j - jday(1, 1, 1970)) * 24.0 + (double)hh) *
 281.284 +         60.0 + (double)mm) * 60.0 + (double)ss - 60.0 * (double)zone;
 281.285 +}
 281.286 +
 281.287 +static void error2(MPL *mpl, const char *fmt, const char *f,
 281.288 +      const char *msg)
 281.289 +{     xprintf("Format string passed to time2str:\n");
 281.290 +      xprintf("%s\n", fmt);
 281.291 +      xprintf("%*s\n", (f - fmt) + 1, "^");
 281.292 +      error(mpl, "%s", msg);
 281.293 +      /* no return */
 281.294 +}
 281.295 +
 281.296 +static int weekday(int j)
 281.297 +{     /* determine weekday number (1 = Mon, ..., 7 = Sun) */
 281.298 +      return (j + jday(1, 1, 1970)) % 7 + 1;
 281.299 +}
 281.300 +
 281.301 +static int firstday(int year)
 281.302 +{     /* determine the first day of the first week for a specified year
 281.303 +         according to ISO 8601 */
 281.304 +      int j;
 281.305 +      /* if 1 January is Monday, Tuesday, Wednesday or Thursday, it is
 281.306 +         in week 01; if 1 January is Friday, Saturday or Sunday, it is
 281.307 +         in week 52 or 53 of the previous year */
 281.308 +      j = jday(1, 1, year) - jday(1, 1, 1970);
 281.309 +      switch (weekday(j))
 281.310 +      {  case 1: /* 1 Jan is Mon */ j += 0; break;
 281.311 +         case 2: /* 1 Jan is Tue */ j -= 1; break;
 281.312 +         case 3: /* 1 Jan is Wed */ j -= 2; break;
 281.313 +         case 4: /* 1 Jan is Thu */ j -= 3; break;
 281.314 +         case 5: /* 1 Jan is Fri */ j += 3; break;
 281.315 +         case 6: /* 1 Jan is Sat */ j += 2; break;
 281.316 +         case 7: /* 1 Jan is Sun */ j += 1; break;
 281.317 +         default: xassert(j != j);
 281.318 +      }
 281.319 +      /* the first day of the week must be Monday */
 281.320 +      xassert(weekday(j) == 1);
 281.321 +      return j;
 281.322 +}
 281.323 +
 281.324 +void fn_time2str(MPL *mpl, char *str, double t, const char *fmt)
 281.325 +{     /* convert the calendar time to character string */
 281.326 +      int j, year, month, day, hh, mm, ss, len;
 281.327 +      double temp;
 281.328 +      const char *f;
 281.329 +      char buf[MAX_LENGTH+1];
 281.330 +      if (!(-62135596800.0 <= t && t <= 64092211199.0))
 281.331 +         error(mpl, "time2str(%.*g,...); argument out of range",
 281.332 +            DBL_DIG, t);
 281.333 +      t = floor(t + 0.5);
 281.334 +      temp = fabs(t) / 86400.0;
 281.335 +      j = (int)floor(temp);
 281.336 +      if (t < 0.0)
 281.337 +      {  if (temp == floor(temp))
 281.338 +            j = - j;
 281.339 +         else
 281.340 +            j = - (j + 1);
 281.341 +      }
 281.342 +      xassert(jdate(j + jday(1, 1, 1970), &day, &month, &year) == 0);
 281.343 +      ss = (int)(t - 86400.0 * (double)j);
 281.344 +      xassert(0 <= ss && ss < 86400);
 281.345 +      mm = ss / 60, ss %= 60;
 281.346 +      hh = mm / 60, mm %= 60;
 281.347 +      len = 0;
 281.348 +      for (f = fmt; *f != '\0'; f++)
 281.349 +      {  if (*f == '%')
 281.350 +         {  f++;
 281.351 +            if (*f == 'a')
 281.352 +            {  /* the abbreviated weekday name */
 281.353 +               memcpy(buf, week[weekday(j)-1], 3), buf[3] = '\0';
 281.354 +            }
 281.355 +            else if (*f == 'A')
 281.356 +            {  /* the full weekday name */
 281.357 +               strcpy(buf, week[weekday(j)-1]);
 281.358 +            }
 281.359 +            else if (*f == 'b' || *f == 'h')
 281.360 +            {  /* the abbreviated month name */
 281.361 +               memcpy(buf, moon[month-1], 3), buf[3] = '\0';
 281.362 +            }
 281.363 +            else if (*f == 'B')
 281.364 +            {  /* the full month name */
 281.365 +               strcpy(buf, moon[month-1]);
 281.366 +            }
 281.367 +            else if (*f == 'C')
 281.368 +            {  /* the century of the year */
 281.369 +               sprintf(buf, "%02d", year / 100);
 281.370 +            }
 281.371 +            else if (*f == 'd')
 281.372 +            {  /* the day of the month as a decimal number (01..31) */
 281.373 +               sprintf(buf, "%02d", day);
 281.374 +            }
 281.375 +            else if (*f == 'D')
 281.376 +            {  /* the date using the format %m/%d/%y */
 281.377 +               sprintf(buf, "%02d/%02d/%02d", month, day, year % 100);
 281.378 +            }
 281.379 +            else if (*f == 'e')
 281.380 +            {  /* the day of the month like with %d, but padded with
 281.381 +                  blank (1..31) */
 281.382 +               sprintf(buf, "%2d", day);
 281.383 +            }
 281.384 +            else if (*f == 'F')
 281.385 +            {  /* the date using the format %Y-%m-%d */
 281.386 +               sprintf(buf, "%04d-%02d-%02d", year, month, day);
 281.387 +            }
 281.388 +            else if (*f == 'g')
 281.389 +            {  /* the year corresponding to the ISO week number, but
 281.390 +                  without the century (range 00 through 99); this has
 281.391 +                  the same format and value as %y, except that if the
 281.392 +                  ISO week number (see %V) belongs to the previous or
 281.393 +                  next year, that year is used instead */
 281.394 +               int iso;
 281.395 +               if (j < firstday(year))
 281.396 +                  iso = year - 1;
 281.397 +               else if (j < firstday(year + 1))
 281.398 +                  iso = year;
 281.399 +               else
 281.400 +                  iso = year + 1;
 281.401 +               sprintf(buf, "%02d", iso % 100);
 281.402 +            }
 281.403 +            else if (*f == 'G')
 281.404 +            {  /* the year corresponding to the ISO week number; this
 281.405 +                  has the same format and value as %Y, excepth that if
 281.406 +                  the ISO week number (see %V) belongs to the previous
 281.407 +                  or next year, that year is used instead */
 281.408 +               int iso;
 281.409 +               if (j < firstday(year))
 281.410 +                  iso = year - 1;
 281.411 +               else if (j < firstday(year + 1))
 281.412 +                  iso = year;
 281.413 +               else
 281.414 +                  iso = year + 1;
 281.415 +               sprintf(buf, "%04d", iso);
 281.416 +            }
 281.417 +            else if (*f == 'H')
 281.418 +            {  /* the hour as a decimal number, using a 24-hour clock
 281.419 +                  (00..23) */
 281.420 +               sprintf(buf, "%02d", hh);
 281.421 +            }
 281.422 +            else if (*f == 'I')
 281.423 +            {  /* the hour as a decimal number, using a 12-hour clock
 281.424 +                  (01..12) */
 281.425 +               sprintf(buf, "%02d",
 281.426 +                  hh == 0 ? 12 : hh <= 12 ? hh : hh - 12);
 281.427 +            }
 281.428 +            else if (*f == 'j')
 281.429 +            {  /* the day of the year as a decimal number (001..366) */
 281.430 +               sprintf(buf, "%03d",
 281.431 +                  jday(day, month, year) - jday(1, 1, year) + 1);
 281.432 +            }
 281.433 +            else if (*f == 'k')
 281.434 +            {  /* the hour as a decimal number, using a 24-hour clock
 281.435 +                  like %H, but padded with blank (0..23) */
 281.436 +               sprintf(buf, "%2d", hh);
 281.437 +            }
 281.438 +            else if (*f == 'l')
 281.439 +            {  /* the hour as a decimal number, using a 12-hour clock
 281.440 +                  like %I, but padded with blank (1..12) */
 281.441 +               sprintf(buf, "%2d",
 281.442 +                  hh == 0 ? 12 : hh <= 12 ? hh : hh - 12);
 281.443 +            }
 281.444 +            else if (*f == 'm')
 281.445 +            {  /* the month as a decimal number (01..12) */
 281.446 +               sprintf(buf, "%02d", month);
 281.447 +            }
 281.448 +            else if (*f == 'M')
 281.449 +            {  /* the minute as a decimal number (00..59) */
 281.450 +               sprintf(buf, "%02d", mm);
 281.451 +            }
 281.452 +            else if (*f == 'p')
 281.453 +            {  /* either AM or PM, according to the given time value;
 281.454 +                  noon is treated as PM and midnight as AM */
 281.455 +               strcpy(buf, hh <= 11 ? "AM" : "PM");
 281.456 +            }
 281.457 +            else if (*f == 'P')
 281.458 +            {  /* either am or pm, according to the given time value;
 281.459 +                  noon is treated as pm and midnight as am */
 281.460 +               strcpy(buf, hh <= 11 ? "am" : "pm");
 281.461 +            }
 281.462 +            else if (*f == 'r')
 281.463 +            {  /* the calendar time using the format %I:%M:%S %p */
 281.464 +               sprintf(buf, "%02d:%02d:%02d %s",
 281.465 +                  hh == 0 ? 12 : hh <= 12 ? hh : hh - 12,
 281.466 +                  mm, ss, hh <= 11 ? "AM" : "PM");
 281.467 +            }
 281.468 +            else if (*f == 'R')
 281.469 +            {  /* the hour and minute using the format %H:%M */
 281.470 +               sprintf(buf, "%02d:%02d", hh, mm);
 281.471 +            }
 281.472 +            else if (*f == 'S')
 281.473 +            {  /* the second as a decimal number (00..59) */
 281.474 +               sprintf(buf, "%02d", ss);
 281.475 +            }
 281.476 +            else if (*f == 'T')
 281.477 +            {  /* the time of day using the format %H:%M:%S */
 281.478 +               sprintf(buf, "%02d:%02d:%02d", hh, mm, ss);
 281.479 +            }
 281.480 +            else if (*f == 'u')
 281.481 +            {  /* the day of the week as a decimal number (1..7),
 281.482 +                  Monday being 1 */
 281.483 +               sprintf(buf, "%d", weekday(j));
 281.484 +            }
 281.485 +            else if (*f == 'U')
 281.486 +            {  /* the week number of the current year as a decimal
 281.487 +                  number (range 00 through 53), starting with the first
 281.488 +                  Sunday as the first day of the first week; days
 281.489 +                  preceding the first Sunday in the year are considered
 281.490 +                  to be in week 00 */
 281.491 +#if 1 /* 09/I-2009 */
 281.492 +#undef sun
 281.493 +/* causes compilation error in SunOS */
 281.494 +#endif
 281.495 +               int sun;
 281.496 +               /* sun = the first Sunday of the year */
 281.497 +               sun = jday(1, 1, year) - jday(1, 1, 1970);
 281.498 +               sun += (7 - weekday(sun));
 281.499 +               sprintf(buf, "%02d", (j + 7 - sun) / 7);
 281.500 +            }
 281.501 +            else if (*f == 'V')
 281.502 +            {  /* the ISO week number as a decimal number (range 01
 281.503 +                  through 53); ISO weeks start with Monday and end with
 281.504 +                  Sunday; week 01 of a year is the first week which has
 281.505 +                  the majority of its days in that year; week 01 of
 281.506 +                  a year can contain days from the previous year; the
 281.507 +                  week before week 01 of a year is the last week (52 or
 281.508 +                  53) of the previous year even if it contains days
 281.509 +                  from the new year */
 281.510 +               int iso;
 281.511 +               if (j < firstday(year))
 281.512 +                  iso = j - firstday(year - 1);
 281.513 +               else if (j < firstday(year + 1))
 281.514 +                  iso = j - firstday(year);
 281.515 +               else
 281.516 +                  iso = j - firstday(year + 1);
 281.517 +               sprintf(buf, "%02d", iso / 7 + 1);
 281.518 +            }
 281.519 +            else if (*f == 'w')
 281.520 +            {  /* the day of the week as a decimal number (0..6),
 281.521 +                  Sunday being 0 */
 281.522 +               sprintf(buf, "%d", weekday(j) % 7);
 281.523 +            }
 281.524 +            else if (*f == 'W')
 281.525 +            {  /* the week number of the current year as a decimal
 281.526 +                  number (range 00 through 53), starting with the first
 281.527 +                  Monday as the first day of the first week; days
 281.528 +                  preceding the first Monday in the year are considered
 281.529 +                  to be in week 00 */
 281.530 +               int mon;
 281.531 +               /* mon = the first Monday of the year */
 281.532 +               mon = jday(1, 1, year) - jday(1, 1, 1970);
 281.533 +               mon += (8 - weekday(mon)) % 7;
 281.534 +               sprintf(buf, "%02d", (j + 7 - mon) / 7);
 281.535 +            }
 281.536 +            else if (*f == 'y')
 281.537 +            {  /* the year without a century as a decimal number
 281.538 +                  (00..99) */
 281.539 +               sprintf(buf, "%02d", year % 100);
 281.540 +            }
 281.541 +            else if (*f == 'Y')
 281.542 +            {  /* the year as a decimal number, using the Gregorian
 281.543 +                  calendar */
 281.544 +               sprintf(buf, "%04d", year);
 281.545 +            }
 281.546 +            else if (*f == '%')
 281.547 +            {  /* a literal % character */
 281.548 +               buf[0] = '%', buf[1] = '\0';
 281.549 +            }
 281.550 +            else
 281.551 +               error2(mpl, fmt, f, "invalid conversion specifier");
 281.552 +         }
 281.553 +         else
 281.554 +            buf[0] = *f, buf[1] = '\0';
 281.555 +         if (len + strlen(buf) > MAX_LENGTH)
 281.556 +            error(mpl, "time2str; output string length exceeds %d chara"
 281.557 +               "cters", MAX_LENGTH);
 281.558 +         memcpy(str+len, buf, strlen(buf));
 281.559 +         len += strlen(buf);
 281.560 +      }
 281.561 +      str[len] = '\0';
 281.562 +      return;
 281.563 +}
 281.564 +
 281.565 +/* eof */
   282.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
   282.2 +++ b/deps/glpk/src/glpmpl06.c	Sun Nov 06 20:59:10 2011 +0100
   282.3 @@ -0,0 +1,1002 @@
   282.4 +/* glpmpl06.c */
   282.5 +
   282.6 +/***********************************************************************
   282.7 +*  This code is part of GLPK (GNU Linear Programming Kit).
   282.8 +*
   282.9 +*  Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008,
  282.10 +*  2009, 2010, 2011 Andrew Makhorin, Department for Applied Informatics,
  282.11 +*  Moscow Aviation Institute, Moscow, Russia. All rights reserved.
  282.12 +*  E-mail: <mao@gnu.org>.
  282.13 +*
  282.14 +*  GLPK is free software: you can redistribute it and/or modify it
  282.15 +*  under the terms of the GNU General Public License as published by
  282.16 +*  the Free Software Foundation, either version 3 of the License, or
  282.17 +*  (at your option) any later version.
  282.18 +*
  282.19 +*  GLPK is distributed in the hope that it will be useful, but WITHOUT
  282.20 +*  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
  282.21 +*  or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
  282.22 +*  License for more details.
  282.23 +*
  282.24 +*  You should have received a copy of the GNU General Public License
  282.25 +*  along with GLPK. If not, see <http://www.gnu.org/licenses/>.
  282.26 +***********************************************************************/
  282.27 +
  282.28 +#define _GLPSTD_ERRNO
  282.29 +#define _GLPSTD_STDIO
  282.30 +#include "glpmpl.h"
  282.31 +#include "glpsql.h"
  282.32 +
  282.33 +/**********************************************************************/
  282.34 +
  282.35 +#define CSV_FIELD_MAX 50
  282.36 +/* maximal number of fields in record */
  282.37 +
  282.38 +#define CSV_FDLEN_MAX 100
  282.39 +/* maximal field length */
  282.40 +
  282.41 +struct csv
  282.42 +{     /* comma-separated values file */
  282.43 +      int mode;
  282.44 +      /* 'R' = reading; 'W' = writing */
  282.45 +      char *fname;
  282.46 +      /* name of csv file */
  282.47 +      FILE *fp;
  282.48 +      /* stream assigned to csv file */
  282.49 +      jmp_buf jump;
  282.50 +      /* address for non-local go to in case of error */
  282.51 +      int count;
  282.52 +      /* record count */
  282.53 +      /*--------------------------------------------------------------*/
  282.54 +      /* used only for input csv file */
  282.55 +      int c;
  282.56 +      /* current character or EOF */
  282.57 +      int what;
  282.58 +      /* current marker: */
  282.59 +#define CSV_EOF   0  /* end-of-file */
  282.60 +#define CSV_EOR   1  /* end-of-record */
  282.61 +#define CSV_NUM   2  /* floating-point number */
  282.62 +#define CSV_STR   3  /* character string */
  282.63 +      char field[CSV_FDLEN_MAX+1];
  282.64 +      /* current field just read */
  282.65 +      int nf;
  282.66 +      /* number of fields in the csv file */
  282.67 +      int ref[1+CSV_FIELD_MAX];
  282.68 +      /* ref[k] = k', if k-th field of the csv file corresponds to
  282.69 +         k'-th field in the table statement; if ref[k] = 0, k-th field
  282.70 +         of the csv file is ignored */
  282.71 +#if 1 /* 01/VI-2010 */
  282.72 +      int nskip;
  282.73 +      /* number of comment records preceding the header record */
  282.74 +#endif
  282.75 +};
  282.76 +
  282.77 +#undef read_char
  282.78 +
  282.79 +static void read_char(struct csv *csv)
  282.80 +{     /* read character from csv data file */
  282.81 +      int c;
  282.82 +      xassert(csv->c != EOF);
  282.83 +      if (csv->c == '\n') csv->count++;
  282.84 +loop: c = fgetc(csv->fp);
  282.85 +      if (ferror(csv->fp))
  282.86 +      {  xprintf("%s:%d: read error - %s\n", csv->fname, csv->count,
  282.87 +            strerror(errno));
  282.88 +         longjmp(csv->jump, 0);
  282.89 +      }
  282.90 +      if (feof(csv->fp))
  282.91 +      {  if (csv->c == '\n')
  282.92 +         {  csv->count--;
  282.93 +            c = EOF;
  282.94 +         }
  282.95 +         else
  282.96 +         {  xprintf("%s:%d: warning: missing final end-of-line\n",
  282.97 +               csv->fname, csv->count);
  282.98 +            c = '\n';
  282.99 +         }
 282.100 +      }
 282.101 +      else if (c == '\r')
 282.102 +         goto loop;
 282.103 +      else if (c == '\n')
 282.104 +         ;
 282.105 +      else if (iscntrl(c))
 282.106 +      {  xprintf("%s:%d: invalid control character 0x%02X\n",
 282.107 +            csv->fname, csv->count, c);
 282.108 +         longjmp(csv->jump, 0);
 282.109 +      }
 282.110 +      csv->c = c;
 282.111 +      return;
 282.112 +}
 282.113 +
 282.114 +static void read_field(struct csv *csv)
 282.115 +{     /* read field from csv data file */
 282.116 +      /* check for end of file */
 282.117 +      if (csv->c == EOF)
 282.118 +      {  csv->what = CSV_EOF;
 282.119 +         strcpy(csv->field, "EOF");
 282.120 +         goto done;
 282.121 +      }
 282.122 +      /* check for end of record */
 282.123 +      if (csv->c == '\n')
 282.124 +      {  csv->what = CSV_EOR;
 282.125 +         strcpy(csv->field, "EOR");
 282.126 +         read_char(csv);
 282.127 +         if (csv->c == ',')
 282.128 +err1:    {  xprintf("%s:%d: empty field not allowed\n", csv->fname,
 282.129 +               csv->count);
 282.130 +            longjmp(csv->jump, 0);
 282.131 +         }
 282.132 +         if (csv->c == '\n')
 282.133 +         {  xprintf("%s:%d: empty record not allowed\n", csv->fname,
 282.134 +               csv->count);
 282.135 +            longjmp(csv->jump, 0);
 282.136 +         }
 282.137 +#if 1 /* 01/VI-2010 */
 282.138 +         /* skip comment records; may appear only before the very first
 282.139 +            record containing field names */
 282.140 +         if (csv->c == '#' && csv->count == 1)
 282.141 +         {  while (csv->c == '#')
 282.142 +            {  while (csv->c != '\n')
 282.143 +                  read_char(csv);
 282.144 +               read_char(csv);
 282.145 +               csv->nskip++;
 282.146 +            }
 282.147 +         }
 282.148 +#endif
 282.149 +         goto done;
 282.150 +      }
 282.151 +      /* skip comma before next field */
 282.152 +      if (csv->c == ',')
 282.153 +         read_char(csv);
 282.154 +      /* read field */
 282.155 +      if (csv->c == '\'' || csv->c == '"')
 282.156 +      {  /* read a field enclosed in quotes */
 282.157 +         int quote = csv->c, len = 0;
 282.158 +         csv->what = CSV_STR;
 282.159 +         /* skip opening quote */
 282.160 +         read_char(csv);
 282.161 +         /* read field characters within quotes */
 282.162 +         for (;;)
 282.163 +         {  /* check for closing quote and read it */
 282.164 +            if (csv->c == quote)
 282.165 +            {  read_char(csv);
 282.166 +               if (csv->c == quote)
 282.167 +                  ;
 282.168 +               else if (csv->c == ',' || csv->c == '\n')
 282.169 +                  break;
 282.170 +               else
 282.171 +               {  xprintf("%s:%d: invalid field\n", csv->fname,
 282.172 +                     csv->count);
 282.173 +                  longjmp(csv->jump, 0);
 282.174 +               }
 282.175 +            }
 282.176 +            /* check the current field length */
 282.177 +            if (len == CSV_FDLEN_MAX)
 282.178 +err2:       {  xprintf("%s:%d: field too long\n", csv->fname,
 282.179 +                  csv->count);
 282.180 +               longjmp(csv->jump, 0);
 282.181 +            }
 282.182 +            /* add the current character to the field */
 282.183 +            csv->field[len++] = (char)csv->c;
 282.184 +            /* read the next character */
 282.185 +            read_char(csv);
 282.186 +         }
 282.187 +         /* the field has been read */
 282.188 +         if (len == 0) goto err1;
 282.189 +         csv->field[len] = '\0';
 282.190 +      }
 282.191 +      else
 282.192 +      {  /* read a field not enclosed in quotes */
 282.193 +         int len = 0;
 282.194 +         double temp;
 282.195 +         csv->what = CSV_NUM;
 282.196 +         while (!(csv->c == ',' || csv->c == '\n'))
 282.197 +         {  /* quotes within the field are not allowed */
 282.198 +            if (csv->c == '\'' || csv->c == '"')
 282.199 +            {  xprintf("%s:%d: invalid use of single or double quote wi"
 282.200 +                  "thin field\n", csv->fname, csv->count);
 282.201 +               longjmp(csv->jump, 0);
 282.202 +            }
 282.203 +            /* check the current field length */
 282.204 +            if (len == CSV_FDLEN_MAX) goto err2;
 282.205 +            /* add the current character to the field */
 282.206 +            csv->field[len++] = (char)csv->c;
 282.207 +            /* read the next character */
 282.208 +            read_char(csv);
 282.209 +         }
 282.210 +         /* the field has been read */
 282.211 +         if (len == 0) goto err1;
 282.212 +         csv->field[len] = '\0';
 282.213 +         /* check the field type */
 282.214 +         if (str2num(csv->field, &temp)) csv->what = CSV_STR;
 282.215 +      }
 282.216 +done: return;
 282.217 +}
 282.218 +
 282.219 +static struct csv *csv_open_file(TABDCA *dca, int mode)
 282.220 +{     /* open csv data file */
 282.221 +      struct csv *csv;
 282.222 +      /* create control structure */
 282.223 +      csv = xmalloc(sizeof(struct csv));
 282.224 +      csv->mode = mode;
 282.225 +      csv->fname = NULL;
 282.226 +      csv->fp = NULL;
 282.227 +      if (setjmp(csv->jump)) goto fail;
 282.228 +      csv->count = 0;
 282.229 +      csv->c = '\n';
 282.230 +      csv->what = 0;
 282.231 +      csv->field[0] = '\0';
 282.232 +      csv->nf = 0;
 282.233 +      /* try to open the csv data file */
 282.234 +      if (mpl_tab_num_args(dca) < 2)
 282.235 +      {  xprintf("csv_driver: file name not specified\n");
 282.236 +         longjmp(csv->jump, 0);
 282.237 +      }
 282.238 +      csv->fname = xmalloc(strlen(mpl_tab_get_arg(dca, 2))+1);
 282.239 +      strcpy(csv->fname, mpl_tab_get_arg(dca, 2));
 282.240 +      if (mode == 'R')
 282.241 +      {  /* open the file for reading */
 282.242 +         int k;
 282.243 +         csv->fp = fopen(csv->fname, "r");
 282.244 +         if (csv->fp == NULL)
 282.245 +         {  xprintf("csv_driver: unable to open %s - %s\n",
 282.246 +               csv->fname, strerror(errno));
 282.247 +            longjmp(csv->jump, 0);
 282.248 +         }
 282.249 +#if 1 /* 01/VI-2010 */
 282.250 +         csv->nskip = 0;
 282.251 +#endif
 282.252 +         /* skip fake new-line */
 282.253 +         read_field(csv);
 282.254 +         xassert(csv->what == CSV_EOR);
 282.255 +         /* read field names */
 282.256 +         xassert(csv->nf == 0);
 282.257 +         for (;;)
 282.258 +         {  read_field(csv);
 282.259 +            if (csv->what == CSV_EOR)
 282.260 +               break;
 282.261 +            if (csv->what != CSV_STR)
 282.262 +            {  xprintf("%s:%d: invalid field name\n", csv->fname,
 282.263 +                  csv->count);
 282.264 +               longjmp(csv->jump, 0);
 282.265 +            }
 282.266 +            if (csv->nf == CSV_FIELD_MAX)
 282.267 +            {  xprintf("%s:%d: too many fields\n", csv->fname,
 282.268 +                  csv->count);
 282.269 +               longjmp(csv->jump, 0);
 282.270 +            }
 282.271 +            csv->nf++;
 282.272 +            /* find corresponding field in the table statement */
 282.273 +            for (k = mpl_tab_num_flds(dca); k >= 1; k--)
 282.274 +            {  if (strcmp(mpl_tab_get_name(dca, k), csv->field) == 0)
 282.275 +                  break;
 282.276 +            }
 282.277 +            csv->ref[csv->nf] = k;
 282.278 +         }
 282.279 +         /* find dummy RECNO field in the table statement */
 282.280 +         for (k = mpl_tab_num_flds(dca); k >= 1; k--)
 282.281 +            if (strcmp(mpl_tab_get_name(dca, k), "RECNO") == 0) break;
 282.282 +         csv->ref[0] = k;
 282.283 +      }
 282.284 +      else if (mode == 'W')
 282.285 +      {  /* open the file for writing */
 282.286 +         int k, nf;
 282.287 +         csv->fp = fopen(csv->fname, "w");
 282.288 +         if (csv->fp == NULL)
 282.289 +         {  xprintf("csv_driver: unable to create %s - %s\n",
 282.290 +               csv->fname, strerror(errno));
 282.291 +            longjmp(csv->jump, 0);
 282.292 +         }
 282.293 +         /* write field names */
 282.294 +         nf = mpl_tab_num_flds(dca);
 282.295 +         for (k = 1; k <= nf; k++)
 282.296 +            fprintf(csv->fp, "%s%c", mpl_tab_get_name(dca, k),
 282.297 +               k < nf ? ',' : '\n');
 282.298 +         csv->count++;
 282.299 +      }
 282.300 +      else
 282.301 +         xassert(mode != mode);
 282.302 +      /* the file has been open */
 282.303 +      return csv;
 282.304 +fail: /* the file cannot be open */
 282.305 +      if (csv->fname != NULL) xfree(csv->fname);
 282.306 +      if (csv->fp != NULL) fclose(csv->fp);
 282.307 +      xfree(csv);
 282.308 +      return NULL;
 282.309 +}
 282.310 +
 282.311 +static int csv_read_record(TABDCA *dca, struct csv *csv)
 282.312 +{     /* read next record from csv data file */
 282.313 +      int k, ret = 0;
 282.314 +      xassert(csv->mode == 'R');
 282.315 +      if (setjmp(csv->jump))
 282.316 +      {  ret = 1;
 282.317 +         goto done;
 282.318 +      }
 282.319 +      /* read dummy RECNO field */
 282.320 +      if (csv->ref[0] > 0)
 282.321 +#if 0 /* 01/VI-2010 */
 282.322 +         mpl_tab_set_num(dca, csv->ref[0], csv->count-1);
 282.323 +#else
 282.324 +         mpl_tab_set_num(dca, csv->ref[0], csv->count-csv->nskip-1);
 282.325 +#endif
 282.326 +      /* read fields */
 282.327 +      for (k = 1; k <= csv->nf; k++)
 282.328 +      {  read_field(csv);
 282.329 +         if (csv->what == CSV_EOF)
 282.330 +         {  /* end-of-file reached */
 282.331 +            xassert(k == 1);
 282.332 +            ret = -1;
 282.333 +            goto done;
 282.334 +         }
 282.335 +         else if (csv->what == CSV_EOR)
 282.336 +         {  /* end-of-record reached */
 282.337 +            int lack = csv->nf - k + 1;
 282.338 +            if (lack == 1)
 282.339 +               xprintf("%s:%d: one field missing\n", csv->fname,
 282.340 +                  csv->count);
 282.341 +            else
 282.342 +               xprintf("%s:%d: %d fields missing\n", csv->fname,
 282.343 +                  csv->count, lack);
 282.344 +            longjmp(csv->jump, 0);
 282.345 +         }
 282.346 +         else if (csv->what == CSV_NUM)
 282.347 +         {  /* floating-point number */
 282.348 +            if (csv->ref[k] > 0)
 282.349 +            {  double num;
 282.350 +               xassert(str2num(csv->field, &num) == 0);
 282.351 +               mpl_tab_set_num(dca, csv->ref[k], num);
 282.352 +            }
 282.353 +         }
 282.354 +         else if (csv->what == CSV_STR)
 282.355 +         {  /* character string */
 282.356 +            if (csv->ref[k] > 0)
 282.357 +               mpl_tab_set_str(dca, csv->ref[k], csv->field);
 282.358 +         }
 282.359 +         else
 282.360 +            xassert(csv != csv);
 282.361 +      }
 282.362 +      /* now there must be NL */
 282.363 +      read_field(csv);
 282.364 +      xassert(csv->what != CSV_EOF);
 282.365 +      if (csv->what != CSV_EOR)
 282.366 +      {  xprintf("%s:%d: too many fields\n", csv->fname, csv->count);
 282.367 +         longjmp(csv->jump, 0);
 282.368 +      }
 282.369 +done: return ret;
 282.370 +}
 282.371 +
 282.372 +static int csv_write_record(TABDCA *dca, struct csv *csv)
 282.373 +{     /* write next record to csv data file */
 282.374 +      int k, nf, ret = 0;
 282.375 +      const char *c;
 282.376 +      xassert(csv->mode == 'W');
 282.377 +      nf = mpl_tab_num_flds(dca);
 282.378 +      for (k = 1; k <= nf; k++)
 282.379 +      {  switch (mpl_tab_get_type(dca, k))
 282.380 +         {  case 'N':
 282.381 +               fprintf(csv->fp, "%.*g", DBL_DIG,
 282.382 +                  mpl_tab_get_num(dca, k));
 282.383 +               break;
 282.384 +            case 'S':
 282.385 +               fputc('"', csv->fp);
 282.386 +               for (c = mpl_tab_get_str(dca, k); *c != '\0'; c++)
 282.387 +               {  if (*c == '"')
 282.388 +                     fputc('"', csv->fp), fputc('"', csv->fp);
 282.389 +                  else
 282.390 +                     fputc(*c, csv->fp);
 282.391 +               }
 282.392 +               fputc('"', csv->fp);
 282.393 +               break;
 282.394 +            default:
 282.395 +               xassert(dca != dca);
 282.396 +         }
 282.397 +         fputc(k < nf ? ',' : '\n', csv->fp);
 282.398 +      }
 282.399 +      csv->count++;
 282.400 +      if (ferror(csv->fp))
 282.401 +      {  xprintf("%s:%d: write error - %s\n", csv->fname, csv->count,
 282.402 +            strerror(errno));
 282.403 +         ret = 1;
 282.404 +      }
 282.405 +      return ret;
 282.406 +}
 282.407 +
 282.408 +static int csv_close_file(TABDCA *dca, struct csv *csv)
 282.409 +{     /* close csv data file */
 282.410 +      int ret = 0;
 282.411 +      xassert(dca == dca);
 282.412 +      if (csv->mode == 'W')
 282.413 +      {  fflush(csv->fp);
 282.414 +         if (ferror(csv->fp))
 282.415 +         {  xprintf("%s:%d: write error - %s\n", csv->fname,
 282.416 +               csv->count, strerror(errno));
 282.417 +            ret = 1;
 282.418 +         }
 282.419 +      }
 282.420 +      xfree(csv->fname);
 282.421 +      fclose(csv->fp);
 282.422 +      xfree(csv);
 282.423 +      return ret;
 282.424 +}
 282.425 +
 282.426 +/**********************************************************************/
 282.427 +
 282.428 +#define DBF_FIELD_MAX 50
 282.429 +/* maximal number of fields in record */
 282.430 +
 282.431 +#define DBF_FDLEN_MAX 100
 282.432 +/* maximal field length */
 282.433 +
 282.434 +struct dbf
 282.435 +{     /* xBASE data file */
 282.436 +      int mode;
 282.437 +      /* 'R' = reading; 'W' = writing */
 282.438 +      char *fname;
 282.439 +      /* name of xBASE file */
 282.440 +      FILE *fp;
 282.441 +      /* stream assigned to xBASE file */
 282.442 +      jmp_buf jump;
 282.443 +      /* address for non-local go to in case of error */
 282.444 +      int offset;
 282.445 +      /* offset of a byte to be read next */
 282.446 +      int count;
 282.447 +      /* record count */
 282.448 +      int nf;
 282.449 +      /* number of fields */
 282.450 +      int ref[1+DBF_FIELD_MAX];
 282.451 +      /* ref[k] = k', if k-th field of the csv file corresponds to
 282.452 +         k'-th field in the table statement; if ref[k] = 0, k-th field
 282.453 +         of the csv file is ignored */
 282.454 +      int type[1+DBF_FIELD_MAX];
 282.455 +      /* type[k] is type of k-th field */
 282.456 +      int len[1+DBF_FIELD_MAX];
 282.457 +      /* len[k] is length of k-th field */
 282.458 +      int prec[1+DBF_FIELD_MAX];
 282.459 +      /* prec[k] is precision of k-th field */
 282.460 +};
 282.461 +
 282.462 +static int read_byte(struct dbf *dbf)
 282.463 +{     /* read byte from xBASE data file */
 282.464 +      int b;
 282.465 +      b = fgetc(dbf->fp);
 282.466 +      if (ferror(dbf->fp))
 282.467 +      {  xprintf("%s:0x%X: read error - %s\n", dbf->fname,
 282.468 +            dbf->offset, strerror(errno));
 282.469 +         longjmp(dbf->jump, 0);
 282.470 +      }
 282.471 +      if (feof(dbf->fp))
 282.472 +      {  xprintf("%s:0x%X: unexpected end of file\n", dbf->fname,
 282.473 +            dbf->offset);
 282.474 +         longjmp(dbf->jump, 0);
 282.475 +      }
 282.476 +      xassert(0x00 <= b && b <= 0xFF);
 282.477 +      dbf->offset++;
 282.478 +      return b;
 282.479 +}
 282.480 +
 282.481 +static void read_header(TABDCA *dca, struct dbf *dbf)
 282.482 +{     /* read xBASE data file header */
 282.483 +      int b, j, k, recl;
 282.484 +      char name[10+1];
 282.485 +      /* (ignored) */
 282.486 +      for (j = 1; j <= 10; j++)
 282.487 +         read_byte(dbf);
 282.488 +      /* length of each record, in bytes */
 282.489 +      recl = read_byte(dbf);
 282.490 +      recl += read_byte(dbf) << 8;
 282.491 +      /* (ignored) */
 282.492 +      for (j = 1; j <= 20; j++)
 282.493 +         read_byte(dbf);
 282.494 +      /* field descriptor array */
 282.495 +      xassert(dbf->nf == 0);
 282.496 +      for (;;)
 282.497 +      {  /* check for end of array */
 282.498 +         b = read_byte(dbf);
 282.499 +         if (b == 0x0D) break;
 282.500 +         if (dbf->nf == DBF_FIELD_MAX)
 282.501 +         {  xprintf("%s:0x%X: too many fields\n", dbf->fname,
 282.502 +               dbf->offset);
 282.503 +            longjmp(dbf->jump, 0);
 282.504 +         }
 282.505 +         dbf->nf++;
 282.506 +         /* field name */
 282.507 +         name[0] = (char)b;
 282.508 +         for (j = 1; j < 10; j++)
 282.509 +         {  b = read_byte(dbf);
 282.510 +            name[j] = (char)b;
 282.511 +         }
 282.512 +         name[10] = '\0';
 282.513 +         b = read_byte(dbf);
 282.514 +         if (b != 0x00)
 282.515 +         {  xprintf("%s:0x%X: invalid field name\n", dbf->fname,
 282.516 +               dbf->offset);
 282.517 +            longjmp(dbf->jump, 0);
 282.518 +         }
 282.519 +         /* find corresponding field in the table statement */
 282.520 +         for (k = mpl_tab_num_flds(dca); k >= 1; k--)
 282.521 +            if (strcmp(mpl_tab_get_name(dca, k), name) == 0) break;
 282.522 +         dbf->ref[dbf->nf] = k;
 282.523 +         /* field type */
 282.524 +         b = read_byte(dbf);
 282.525 +         if (!(b == 'C' || b == 'N'))
 282.526 +         {  xprintf("%s:0x%X: invalid field type\n", dbf->fname,
 282.527 +               dbf->offset);
 282.528 +            longjmp(dbf->jump, 0);
 282.529 +         }
 282.530 +         dbf->type[dbf->nf] = b;
 282.531 +         /* (ignored) */
 282.532 +         for (j = 1; j <= 4; j++)
 282.533 +            read_byte(dbf);
 282.534 +         /* field length */
 282.535 +         b = read_byte(dbf);
 282.536 +         if (b == 0)
 282.537 +         {  xprintf("%s:0x%X: invalid field length\n", dbf->fname,
 282.538 +               dbf->offset);
 282.539 +            longjmp(dbf->jump, 0);
 282.540 +         }
 282.541 +         if (b > DBF_FDLEN_MAX)
 282.542 +         {  xprintf("%s:0x%X: field too long\n", dbf->fname,
 282.543 +               dbf->offset);
 282.544 +            longjmp(dbf->jump, 0);
 282.545 +         }
 282.546 +         dbf->len[dbf->nf] = b;
 282.547 +         recl -= b;
 282.548 +         /* (ignored) */
 282.549 +         for (j = 1; j <= 15; j++)
 282.550 +            read_byte(dbf);
 282.551 +      }
 282.552 +      if (recl != 1)
 282.553 +      {  xprintf("%s:0x%X: invalid file header\n", dbf->fname,
 282.554 +            dbf->offset);
 282.555 +         longjmp(dbf->jump, 0);
 282.556 +      }
 282.557 +      /* find dummy RECNO field in the table statement */
 282.558 +      for (k = mpl_tab_num_flds(dca); k >= 1; k--)
 282.559 +         if (strcmp(mpl_tab_get_name(dca, k), "RECNO") == 0) break;
 282.560 +      dbf->ref[0] = k;
 282.561 +      return;
 282.562 +}
 282.563 +
 282.564 +static void parse_third_arg(TABDCA *dca, struct dbf *dbf)
 282.565 +{     /* parse xBASE file format (third argument) */
 282.566 +      int j, k, temp;
 282.567 +      const char *arg;
 282.568 +      dbf->nf = mpl_tab_num_flds(dca);
 282.569 +      arg = mpl_tab_get_arg(dca, 3), j = 0;
 282.570 +      for (k = 1; k <= dbf->nf; k++)
 282.571 +      {  /* parse specification of k-th field */
 282.572 +         if (arg[j] == '\0')
 282.573 +         {  xprintf("xBASE driver: field %s: specification missing\n",
 282.574 +               mpl_tab_get_name(dca, k));
 282.575 +            longjmp(dbf->jump, 0);
 282.576 +         }
 282.577 +         /* parse field type */
 282.578 +         if (arg[j] == 'C' || arg[j] == 'N')
 282.579 +            dbf->type[k] = arg[j], j++;
 282.580 +         else
 282.581 +         {  xprintf("xBASE driver: field %s: invalid field type\n",
 282.582 +               mpl_tab_get_name(dca, k));
 282.583 +            longjmp(dbf->jump, 0);
 282.584 +         }
 282.585 +         /* check for left parenthesis */
 282.586 +         if (arg[j] == '(')
 282.587 +            j++;
 282.588 +         else
 282.589 +err:     {  xprintf("xBASE driver: field %s: invalid field format\n",
 282.590 +               mpl_tab_get_name(dca, k));
 282.591 +            longjmp(dbf->jump, 0);
 282.592 +         }
 282.593 +         /* parse field length */
 282.594 +         temp = 0;
 282.595 +         while (isdigit(arg[j]))
 282.596 +         {  if (temp > DBF_FDLEN_MAX) break;
 282.597 +            temp = 10 * temp + (arg[j] - '0'), j++;
 282.598 +         }
 282.599 +         if (!(1 <= temp && temp <= DBF_FDLEN_MAX))
 282.600 +         {  xprintf("xBASE driver: field %s: invalid field length\n",
 282.601 +               mpl_tab_get_name(dca, k));
 282.602 +            longjmp(dbf->jump, 0);
 282.603 +         }
 282.604 +         dbf->len[k] = temp;
 282.605 +         /* parse optional field precision */
 282.606 +         if (dbf->type[k] == 'N' && arg[j] == ',')
 282.607 +         {  j++;
 282.608 +            temp = 0;
 282.609 +            while (isdigit(arg[j]))
 282.610 +            {  if (temp > dbf->len[k]) break;
 282.611 +               temp = 10 * temp + (arg[j] - '0'), j++;
 282.612 +            }
 282.613 +            if (temp > dbf->len[k])
 282.614 +            {  xprintf("xBASE driver: field %s: invalid field precision"
 282.615 +                  "\n", mpl_tab_get_name(dca, k));
 282.616 +               longjmp(dbf->jump, 0);
 282.617 +            }
 282.618 +            dbf->prec[k] = temp;
 282.619 +         }
 282.620 +         else
 282.621 +            dbf->prec[k] = 0;
 282.622 +         /* check for right parenthesis */
 282.623 +         if (arg[j] == ')')
 282.624 +            j++;
 282.625 +         else
 282.626 +            goto err;
 282.627 +      }
 282.628 +      /* ignore other specifications */
 282.629 +      return;
 282.630 +}
 282.631 +
 282.632 +static void write_byte(struct dbf *dbf, int b)
 282.633 +{     /* write byte to xBASE data file */
 282.634 +      fputc(b, dbf->fp);
 282.635 +      dbf->offset++;
 282.636 +      return;
 282.637 +}
 282.638 +
 282.639 +static void write_header(TABDCA *dca, struct dbf *dbf)
 282.640 +{     /* write xBASE data file header */
 282.641 +      int j, k, temp;
 282.642 +      const char *name;
 282.643 +      /* version number */
 282.644 +      write_byte(dbf, 0x03 /* file without DBT */);
 282.645 +      /* date of last update (YYMMDD) */
 282.646 +      write_byte(dbf, 70 /* 1970 */);
 282.647 +      write_byte(dbf, 1 /* January */);
 282.648 +      write_byte(dbf, 1 /* 1st */);
 282.649 +      /* number of records (unknown so far) */
 282.650 +      for (j = 1; j <= 4; j++)
 282.651 +         write_byte(dbf, 0xFF);
 282.652 +      /* length of the header, in bytes */
 282.653 +      temp = 32 + dbf->nf * 32 + 1;
 282.654 +      write_byte(dbf, temp);
 282.655 +      write_byte(dbf, temp >> 8);
 282.656 +      /* length of each record, in bytes */
 282.657 +      temp = 1;
 282.658 +      for (k = 1; k <= dbf->nf; k++)
 282.659 +         temp += dbf->len[k];
 282.660 +      write_byte(dbf, temp);
 282.661 +      write_byte(dbf, temp >> 8);
 282.662 +      /* (reserved) */
 282.663 +      for (j = 1; j <= 20; j++)
 282.664 +         write_byte(dbf, 0x00);
 282.665 +      /* field descriptor array */
 282.666 +      for (k = 1; k <= dbf->nf; k++)
 282.667 +      {  /* field name (terminated by 0x00) */
 282.668 +         name = mpl_tab_get_name(dca, k);
 282.669 +         for (j = 0; j < 10 && name[j] != '\0'; j++)
 282.670 +            write_byte(dbf, name[j]);
 282.671 +         for (j = j; j < 11; j++)
 282.672 +            write_byte(dbf, 0x00);
 282.673 +         /* field type */
 282.674 +         write_byte(dbf, dbf->type[k]);
 282.675 +         /* (reserved) */
 282.676 +         for (j = 1; j <= 4; j++)
 282.677 +            write_byte(dbf, 0x00);
 282.678 +         /* field length */
 282.679 +         write_byte(dbf, dbf->len[k]);
 282.680 +         /* field precision */
 282.681 +         write_byte(dbf, dbf->prec[k]);
 282.682 +         /* (reserved) */
 282.683 +         for (j = 1; j <= 14; j++)
 282.684 +            write_byte(dbf, 0x00);
 282.685 +      }
 282.686 +      /* end of header */
 282.687 +      write_byte(dbf, 0x0D);
 282.688 +      return;
 282.689 +}
 282.690 +
 282.691 +static struct dbf *dbf_open_file(TABDCA *dca, int mode)
 282.692 +{     /* open xBASE data file */
 282.693 +      struct dbf *dbf;
 282.694 +      /* create control structure */
 282.695 +      dbf = xmalloc(sizeof(struct dbf));
 282.696 +      dbf->mode = mode;
 282.697 +      dbf->fname = NULL;
 282.698 +      dbf->fp = NULL;
 282.699 +      if (setjmp(dbf->jump)) goto fail;
 282.700 +      dbf->offset = 0;
 282.701 +      dbf->count = 0;
 282.702 +      dbf->nf = 0;
 282.703 +      /* try to open the xBASE data file */
 282.704 +      if (mpl_tab_num_args(dca) < 2)
 282.705 +      {  xprintf("xBASE driver: file name not specified\n");
 282.706 +         longjmp(dbf->jump, 0);
 282.707 +      }
 282.708 +      dbf->fname = xmalloc(strlen(mpl_tab_get_arg(dca, 2))+1);
 282.709 +      strcpy(dbf->fname, mpl_tab_get_arg(dca, 2));
 282.710 +      if (mode == 'R')
 282.711 +      {  /* open the file for reading */
 282.712 +         dbf->fp = fopen(dbf->fname, "rb");
 282.713 +         if (dbf->fp == NULL)
 282.714 +         {  xprintf("xBASE driver: unable to open %s - %s\n",
 282.715 +               dbf->fname, strerror(errno));
 282.716 +            longjmp(dbf->jump, 0);
 282.717 +         }
 282.718 +         read_header(dca, dbf);
 282.719 +      }
 282.720 +      else if (mode == 'W')
 282.721 +      {  /* open the file for writing */
 282.722 +         if (mpl_tab_num_args(dca) < 3)
 282.723 +         {  xprintf("xBASE driver: file format not specified\n");
 282.724 +            longjmp(dbf->jump, 0);
 282.725 +         }
 282.726 +         parse_third_arg(dca, dbf);
 282.727 +         dbf->fp = fopen(dbf->fname, "wb");
 282.728 +         if (dbf->fp == NULL)
 282.729 +         {  xprintf("xBASE driver: unable to create %s - %s\n",
 282.730 +               dbf->fname, strerror(errno));
 282.731 +            longjmp(dbf->jump, 0);
 282.732 +         }
 282.733 +         write_header(dca, dbf);
 282.734 +      }
 282.735 +      else
 282.736 +         xassert(mode != mode);
 282.737 +      /* the file has been open */
 282.738 +      return dbf;
 282.739 +fail: /* the file cannot be open */
 282.740 +      if (dbf->fname != NULL) xfree(dbf->fname);
 282.741 +      if (dbf->fp != NULL) fclose(dbf->fp);
 282.742 +      xfree(dbf);
 282.743 +      return NULL;
 282.744 +}
 282.745 +
 282.746 +static int dbf_read_record(TABDCA *dca, struct dbf *dbf)
 282.747 +{     /* read next record from xBASE data file */
 282.748 +      int b, j, k, ret = 0;
 282.749 +      char buf[DBF_FDLEN_MAX+1];
 282.750 +      xassert(dbf->mode == 'R');
 282.751 +      if (setjmp(dbf->jump))
 282.752 +      {  ret = 1;
 282.753 +         goto done;
 282.754 +      }
 282.755 +      /* check record flag */
 282.756 +      b = read_byte(dbf);
 282.757 +      if (b == 0x1A)
 282.758 +      {  /* end of data */
 282.759 +         ret = -1;
 282.760 +         goto done;
 282.761 +      }
 282.762 +      if (b != 0x20)
 282.763 +      {  xprintf("%s:0x%X: invalid record flag\n", dbf->fname,
 282.764 +            dbf->offset);
 282.765 +         longjmp(dbf->jump, 0);
 282.766 +      }
 282.767 +      /* read dummy RECNO field */
 282.768 +      if (dbf->ref[0] > 0)
 282.769 +         mpl_tab_set_num(dca, dbf->ref[0], dbf->count+1);
 282.770 +      /* read fields */
 282.771 +      for (k = 1; k <= dbf->nf; k++)
 282.772 +      {  /* read k-th field */
 282.773 +         for (j = 0; j < dbf->len[k]; j++)
 282.774 +            buf[j] = (char)read_byte(dbf);
 282.775 +         buf[dbf->len[k]] = '\0';
 282.776 +         /* set field value */
 282.777 +         if (dbf->type[k] == 'C')
 282.778 +         {  /* character field */
 282.779 +            if (dbf->ref[k] > 0)
 282.780 +               mpl_tab_set_str(dca, dbf->ref[k], strtrim(buf));
 282.781 +         }
 282.782 +         else if (dbf->type[k] == 'N')
 282.783 +         {  /* numeric field */
 282.784 +            if (dbf->ref[k] > 0)
 282.785 +            {  double num;
 282.786 +               strspx(buf);
 282.787 +               xassert(str2num(buf, &num) == 0);
 282.788 +               mpl_tab_set_num(dca, dbf->ref[k], num);
 282.789 +            }
 282.790 +         }
 282.791 +         else
 282.792 +            xassert(dbf != dbf);
 282.793 +      }
 282.794 +      /* increase record count */
 282.795 +      dbf->count++;
 282.796 +done: return ret;
 282.797 +}
 282.798 +
 282.799 +static int dbf_write_record(TABDCA *dca, struct dbf *dbf)
 282.800 +{     /* write next record to xBASE data file */
 282.801 +      int j, k, ret = 0;
 282.802 +      char buf[255+1];
 282.803 +      xassert(dbf->mode == 'W');
 282.804 +      if (setjmp(dbf->jump))
 282.805 +      {  ret = 1;
 282.806 +         goto done;
 282.807 +      }
 282.808 +      /* record flag */
 282.809 +      write_byte(dbf, 0x20);
 282.810 +      xassert(dbf->nf == mpl_tab_num_flds(dca));
 282.811 +      for (k = 1; k <= dbf->nf; k++)
 282.812 +      {  if (dbf->type[k] == 'C')
 282.813 +         {  /* character field */
 282.814 +            const char *str;
 282.815 +            if (mpl_tab_get_type(dca, k) == 'N')
 282.816 +            {  sprintf(buf, "%.*g", DBL_DIG, mpl_tab_get_num(dca, k));
 282.817 +               str = buf;
 282.818 +            }
 282.819 +            else if (mpl_tab_get_type(dca, k) == 'S')
 282.820 +               str = mpl_tab_get_str(dca, k);
 282.821 +            else
 282.822 +               xassert(dca != dca);
 282.823 +            if ((int)strlen(str) > dbf->len[k])
 282.824 +            {  xprintf("xBASE driver: field %s: cannot convert %.15s..."
 282.825 +                  " to field format\n", mpl_tab_get_name(dca, k), str);
 282.826 +               longjmp(dbf->jump, 0);
 282.827 +            }
 282.828 +            for (j = 0; j < dbf->len[k] && str[j] != '\0'; j++)
 282.829 +                write_byte(dbf, str[j]);
 282.830 +            for (j = j; j < dbf->len[k]; j++)
 282.831 +                write_byte(dbf, ' ');
 282.832 +         }
 282.833 +         else if (dbf->type[k] == 'N')
 282.834 +         {  /* numeric field */
 282.835 +            double num = mpl_tab_get_num(dca, k);
 282.836 +            if (fabs(num) > 1e20)
 282.837 +err:        {  xprintf("xBASE driver: field %s: cannot convert %g to fi"
 282.838 +                  "eld format\n", mpl_tab_get_name(dca, k), num);
 282.839 +               longjmp(dbf->jump, 0);
 282.840 +            }
 282.841 +            sprintf(buf, "%*.*f", dbf->len[k], dbf->prec[k], num);
 282.842 +            xassert(strlen(buf) < sizeof(buf));
 282.843 +            if ((int)strlen(buf) != dbf->len[k]) goto err;
 282.844 +            for (j = 0; j < dbf->len[k]; j++)
 282.845 +               write_byte(dbf, buf[j]);
 282.846 +         }
 282.847 +         else
 282.848 +            xassert(dbf != dbf);
 282.849 +      }
 282.850 +      /* increase record count */
 282.851 +      dbf->count++;
 282.852 +done: return ret;
 282.853 +}
 282.854 +
 282.855 +static int dbf_close_file(TABDCA *dca, struct dbf *dbf)
 282.856 +{     /* close xBASE data file */
 282.857 +      int ret = 0;
 282.858 +      xassert(dca == dca);
 282.859 +      if (dbf->mode == 'W')
 282.860 +      {  if (setjmp(dbf->jump))
 282.861 +         {  ret = 1;
 282.862 +            goto skip;
 282.863 +         }
 282.864 +         /* end-of-file flag */
 282.865 +         write_byte(dbf, 0x1A);
 282.866 +         /* number of records */
 282.867 +         dbf->offset = 4;
 282.868 +         if (fseek(dbf->fp, dbf->offset, SEEK_SET))
 282.869 +         {  xprintf("%s:0x%X: seek error - %s\n", dbf->fname,
 282.870 +               dbf->offset, strerror(errno));
 282.871 +            longjmp(dbf->jump, 0);
 282.872 +         }
 282.873 +         write_byte(dbf, dbf->count);
 282.874 +         write_byte(dbf, dbf->count >> 8);
 282.875 +         write_byte(dbf, dbf->count >> 16);
 282.876 +         write_byte(dbf, dbf->count >> 24);
 282.877 +         fflush(dbf->fp);
 282.878 +         if (ferror(dbf->fp))
 282.879 +         {  xprintf("%s:0x%X: write error - %s\n", dbf->fname,
 282.880 +               dbf->offset, strerror(errno));
 282.881 +            longjmp(dbf->jump, 0);
 282.882 +         }
 282.883 +skip:    ;
 282.884 +      }
 282.885 +      xfree(dbf->fname);
 282.886 +      fclose(dbf->fp);
 282.887 +      xfree(dbf);
 282.888 +      return ret;
 282.889 +}
 282.890 +
 282.891 +/**********************************************************************/
 282.892 +
 282.893 +#define TAB_CSV   1
 282.894 +#define TAB_XBASE 2
 282.895 +#define TAB_ODBC  3
 282.896 +#define TAB_MYSQL 4
 282.897 +
 282.898 +void mpl_tab_drv_open(MPL *mpl, int mode)
 282.899 +{     TABDCA *dca = mpl->dca;
 282.900 +      xassert(dca->id == 0);
 282.901 +      xassert(dca->link == NULL);
 282.902 +      xassert(dca->na >= 1);
 282.903 +      if (strcmp(dca->arg[1], "CSV") == 0)
 282.904 +      {  dca->id = TAB_CSV;
 282.905 +         dca->link = csv_open_file(dca, mode);
 282.906 +      }
 282.907 +      else if (strcmp(dca->arg[1], "xBASE") == 0)
 282.908 +      {  dca->id = TAB_XBASE;
 282.909 +         dca->link = dbf_open_file(dca, mode);
 282.910 +      }
 282.911 +      else if (strcmp(dca->arg[1], "ODBC") == 0 ||
 282.912 +               strcmp(dca->arg[1], "iODBC") == 0)
 282.913 +      {  dca->id = TAB_ODBC;
 282.914 +         dca->link = db_iodbc_open(dca, mode);
 282.915 +      }
 282.916 +      else if (strcmp(dca->arg[1], "MySQL") == 0)
 282.917 +      {  dca->id = TAB_MYSQL;
 282.918 +         dca->link = db_mysql_open(dca, mode);
 282.919 +      }
 282.920 +      else
 282.921 +         xprintf("Invalid table driver `%s'\n", dca->arg[1]);
 282.922 +      if (dca->link == NULL)
 282.923 +         error(mpl, "error on opening table %s",
 282.924 +            mpl->stmt->u.tab->name);
 282.925 +      return;
 282.926 +}
 282.927 +
 282.928 +int mpl_tab_drv_read(MPL *mpl)
 282.929 +{     TABDCA *dca = mpl->dca;
 282.930 +      int ret;
 282.931 +      switch (dca->id)
 282.932 +      {  case TAB_CSV:
 282.933 +            ret = csv_read_record(dca, dca->link);
 282.934 +            break;
 282.935 +         case TAB_XBASE:
 282.936 +            ret = dbf_read_record(dca, dca->link);
 282.937 +            break;
 282.938 +         case TAB_ODBC:
 282.939 +            ret = db_iodbc_read(dca, dca->link);
 282.940 +            break;
 282.941 +         case TAB_MYSQL:
 282.942 +            ret = db_mysql_read(dca, dca->link);
 282.943 +            break;
 282.944 +         default:
 282.945 +            xassert(dca != dca);
 282.946 +      }
 282.947 +      if (ret > 0)
 282.948 +         error(mpl, "error on reading data from table %s",
 282.949 +            mpl->stmt->u.tab->name);
 282.950 +      return ret;
 282.951 +}
 282.952 +
 282.953 +void mpl_tab_drv_write(MPL *mpl)
 282.954 +{     TABDCA *dca = mpl->dca;
 282.955 +      int ret;
 282.956 +      switch (dca->id)
 282.957 +      {  case TAB_CSV:
 282.958 +            ret = csv_write_record(dca, dca->link);
 282.959 +            break;
 282.960 +         case TAB_XBASE:
 282.961 +            ret = dbf_write_record(dca, dca->link);
 282.962 +            break;
 282.963 +         case TAB_ODBC:
 282.964 +            ret = db_iodbc_write(dca, dca->link);
 282.965 +            break;
 282.966 +         case TAB_MYSQL:
 282.967 +            ret = db_mysql_write(dca, dca->link);
 282.968 +            break;
 282.969 +         default:
 282.970 +            xassert(dca != dca);
 282.971 +      }
 282.972 +      if (ret)
 282.973 +         error(mpl, "error on writing data to table %s",
 282.974 +            mpl->stmt->u.tab->name);
 282.975 +      return;
 282.976 +}
 282.977 +
 282.978 +void mpl_tab_drv_close(MPL *mpl)
 282.979 +{     TABDCA *dca = mpl->dca;
 282.980 +      int ret;
 282.981 +      switch (dca->id)
 282.982 +      {  case TAB_CSV:
 282.983 +            ret = csv_close_file(dca, dca->link);
 282.984 +            break;
 282.985 +         case TAB_XBASE:
 282.986 +            ret = dbf_close_file(dca, dca->link);
 282.987 +            break;
 282.988 +         case TAB_ODBC:
 282.989 +            ret = db_iodbc_close(dca, dca->link);
 282.990 +            break;
 282.991 +         case TAB_MYSQL:
 282.992 +            ret = db_mysql_close(dca, dca->link);
 282.993 +            break;
 282.994 +         default:
 282.995 +            xassert(dca != dca);
 282.996 +      }
 282.997 +      dca->id = 0;
 282.998 +      dca->link = NULL;
 282.999 +      if (ret)
282.1000 +         error(mpl, "error on closing table %s",
282.1001 +            mpl->stmt->u.tab->name);
282.1002 +      return;
282.1003 +}
282.1004 +
282.1005 +/* eof */
   283.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
   283.2 +++ b/deps/glpk/src/glpmps.c	Sun Nov 06 20:59:10 2011 +0100
   283.3 @@ -0,0 +1,1401 @@
   283.4 +/* glpmps.c (MPS format routines) */
   283.5 +
   283.6 +/***********************************************************************
   283.7 +*  This code is part of GLPK (GNU Linear Programming Kit).
   283.8 +*
   283.9 +*  Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008,
  283.10 +*  2009, 2010, 2011 Andrew Makhorin, Department for Applied Informatics,
  283.11 +*  Moscow Aviation Institute, Moscow, Russia. All rights reserved.
  283.12 +*  E-mail: <mao@gnu.org>.
  283.13 +*
  283.14 +*  GLPK is free software: you can redistribute it and/or modify it
  283.15 +*  under the terms of the GNU General Public License as published by
  283.16 +*  the Free Software Foundation, either version 3 of the License, or
  283.17 +*  (at your option) any later version.
  283.18 +*
  283.19 +*  GLPK is distributed in the hope that it will be useful, but WITHOUT
  283.20 +*  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
  283.21 +*  or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
  283.22 +*  License for more details.
  283.23 +*
  283.24 +*  You should have received a copy of the GNU General Public License
  283.25 +*  along with GLPK. If not, see <http://www.gnu.org/licenses/>.
  283.26 +***********************************************************************/
  283.27 +
  283.28 +#include "glpapi.h"
  283.29 +
  283.30 +/***********************************************************************
  283.31 +*  NAME
  283.32 +*
  283.33 +*  glp_init_mpscp - initialize MPS format control parameters
  283.34 +*
  283.35 +*  SYNOPSIS
  283.36 +*
  283.37 +*  void glp_init_mpscp(glp_mpscp *parm);
  283.38 +*
  283.39 +*  DESCRIPTION
  283.40 +*
  283.41 +*  The routine glp_init_mpscp initializes control parameters, which are
  283.42 +*  used by the MPS input/output routines glp_read_mps and glp_write_mps,
  283.43 +*  with default values.
  283.44 +*
  283.45 +*  Default values of the control parameters are stored in the glp_mpscp
  283.46 +*  structure, which the parameter parm points to. */
  283.47 +
  283.48 +void glp_init_mpscp(glp_mpscp *parm)
  283.49 +{     parm->blank = '\0';
  283.50 +      parm->obj_name = NULL;
  283.51 +      parm->tol_mps = 1e-12;
  283.52 +      return;
  283.53 +}
  283.54 +
  283.55 +static void check_parm(const char *func, const glp_mpscp *parm)
  283.56 +{     /* check control parameters */
  283.57 +      if (!(0x00 <= parm->blank && parm->blank <= 0xFF) ||
  283.58 +          !(parm->blank == '\0' || isprint(parm->blank)))
  283.59 +         xerror("%s: blank = 0x%02X; invalid parameter\n",
  283.60 +            func, parm->blank);
  283.61 +      if (!(parm->obj_name == NULL || strlen(parm->obj_name) <= 255))
  283.62 +         xerror("%s: obj_name = \"%.12s...\"; parameter too long\n",
  283.63 +            func, parm->obj_name);
  283.64 +      if (!(0.0 <= parm->tol_mps && parm->tol_mps < 1.0))
  283.65 +         xerror("%s: tol_mps = %g; invalid parameter\n",
  283.66 +            func, parm->tol_mps);
  283.67 +      return;
  283.68 +}
  283.69 +
  283.70 +/***********************************************************************
  283.71 +*  NAME
  283.72 +*
  283.73 +*  glp_read_mps - read problem data in MPS format
  283.74 +*
  283.75 +*  SYNOPSIS
  283.76 +*
  283.77 +*  int glp_read_mps(glp_prob *P, int fmt, const glp_mpscp *parm,
  283.78 +*     const char *fname);
  283.79 +*
  283.80 +*  DESCRIPTION
  283.81 +*
  283.82 +*  The routine glp_read_mps reads problem data in MPS format from a
  283.83 +*  text file.
  283.84 +*
  283.85 +*  The parameter fmt specifies the version of MPS format:
  283.86 +*
  283.87 +*  GLP_MPS_DECK - fixed (ancient) MPS format;
  283.88 +*  GLP_MPS_FILE - free (modern) MPS format.
  283.89 +*
  283.90 +*  The parameter parm is a pointer to the structure glp_mpscp, which
  283.91 +*  specifies control parameters used by the routine. If parm is NULL,
  283.92 +*  the routine uses default settings.
  283.93 +*
  283.94 +*  The character string fname specifies a name of the text file to be
  283.95 +*  read.
  283.96 +*
  283.97 +*  Note that before reading data the current content of the problem
  283.98 +*  object is completely erased with the routine glp_erase_prob.
  283.99 +*
 283.100 +*  RETURNS
 283.101 +*
 283.102 +*  If the operation was successful, the routine glp_read_mps returns
 283.103 +*  zero. Otherwise, it prints an error message and returns non-zero. */
 283.104 +
 283.105 +struct csa
 283.106 +{     /* common storage area */
 283.107 +      glp_prob *P;
 283.108 +      /* pointer to problem object */
 283.109 +      int deck;
 283.110 +      /* MPS format (0 - free, 1 - fixed) */
 283.111 +      const glp_mpscp *parm;
 283.112 +      /* pointer to control parameters */
 283.113 +      const char *fname;
 283.114 +      /* name of input MPS file */
 283.115 +      XFILE *fp;
 283.116 +      /* stream assigned to input MPS file */
 283.117 +      jmp_buf jump;
 283.118 +      /* label for go to in case of error */
 283.119 +      int recno;
 283.120 +      /* current record (card) number */
 283.121 +      int recpos;
 283.122 +      /* current record (card) position */
 283.123 +      int c;
 283.124 +      /* current character */
 283.125 +      int fldno;
 283.126 +      /* current field number */
 283.127 +      char field[255+1];
 283.128 +      /* current field content */
 283.129 +      int w80;
 283.130 +      /* warning 'record must not be longer than 80 chars' issued */
 283.131 +      int wef;
 283.132 +      /* warning 'extra fields detected beyond field 6' issued */
 283.133 +      int obj_row;
 283.134 +      /* objective row number */
 283.135 +      void *work1, *work2, *work3;
 283.136 +      /* working arrays */
 283.137 +};
 283.138 +
 283.139 +static void error(struct csa *csa, const char *fmt, ...)
 283.140 +{     /* print error message and terminate processing */
 283.141 +      va_list arg;
 283.142 +      xprintf("%s:%d: ", csa->fname, csa->recno);
 283.143 +      va_start(arg, fmt);
 283.144 +      xvprintf(fmt, arg);
 283.145 +      va_end(arg);
 283.146 +      longjmp(csa->jump, 1);
 283.147 +      /* no return */
 283.148 +}
 283.149 +
 283.150 +static void warning(struct csa *csa, const char *fmt, ...)
 283.151 +{     /* print warning message and continue processing */
 283.152 +      va_list arg;
 283.153 +      xprintf("%s:%d: warning: ", csa->fname, csa->recno);
 283.154 +      va_start(arg, fmt);
 283.155 +      xvprintf(fmt, arg);
 283.156 +      va_end(arg);
 283.157 +      return;
 283.158 +}
 283.159 +
 283.160 +static void read_char(struct csa *csa)
 283.161 +{     /* read next character */
 283.162 +      int c;
 283.163 +      if (csa->c == '\n')
 283.164 +         csa->recno++, csa->recpos = 0;
 283.165 +      csa->recpos++;
 283.166 +read: c = xfgetc(csa->fp);
 283.167 +      if (c < 0)
 283.168 +      {  if (xferror(csa->fp))
 283.169 +            error(csa, "read error - %s\n", xerrmsg());
 283.170 +         else if (csa->c == '\n')
 283.171 +            error(csa, "unexpected end of file\n");
 283.172 +         else
 283.173 +         {  warning(csa, "missing final end of line\n");
 283.174 +            c = '\n';
 283.175 +         }
 283.176 +      }
 283.177 +      else if (c == '\n')
 283.178 +         ;
 283.179 +      else if (csa->c == '\r')
 283.180 +      {  c = '\r';
 283.181 +         goto badc;
 283.182 +      }
 283.183 +      else if (csa->deck && c == '\r')
 283.184 +      {  csa->c = '\r';
 283.185 +         goto read;
 283.186 +      }
 283.187 +      else if (c == ' ')
 283.188 +         ;
 283.189 +      else if (isspace(c))
 283.190 +      {  if (csa->deck)
 283.191 +badc:       error(csa, "in fixed MPS format white-space character 0x%02"
 283.192 +               "X is not allowed\n", c);
 283.193 +         c = ' ';
 283.194 +      }
 283.195 +      else if (iscntrl(c))
 283.196 +         error(csa, "invalid control character 0x%02X\n", c);
 283.197 +      if (csa->deck && csa->recpos == 81 && c != '\n' && csa->w80 < 1)
 283.198 +      {  warning(csa, "in fixed MPS format record must not be longer th"
 283.199 +            "an 80 characters\n");
 283.200 +         csa->w80++;
 283.201 +      }
 283.202 +      csa->c = c;
 283.203 +      return;
 283.204 +}
 283.205 +
 283.206 +static int indicator(struct csa *csa, int name)
 283.207 +{     /* skip comment records and read possible indicator record */
 283.208 +      int ret;
 283.209 +      /* reset current field number */
 283.210 +      csa->fldno = 0;
 283.211 +loop: /* read the very first character of the next record */
 283.212 +      xassert(csa->c == '\n');
 283.213 +      read_char(csa);
 283.214 +      if (csa->c == ' ' || csa->c == '\n')
 283.215 +      {  /* data record */
 283.216 +         ret = 0;
 283.217 +      }
 283.218 +      else if (csa->c == '*')
 283.219 +      {  /* comment record */
 283.220 +         while (csa->c != '\n')
 283.221 +            read_char(csa);
 283.222 +         goto loop;
 283.223 +      }
 283.224 +      else
 283.225 +      {  /* indicator record */
 283.226 +         int len = 0;
 283.227 +         while (csa->c != ' ' && csa->c != '\n' && len < 12)
 283.228 +         {  csa->field[len++] = (char)csa->c;
 283.229 +            read_char(csa);
 283.230 +         }
 283.231 +         csa->field[len] = '\0';
 283.232 +         if (!(strcmp(csa->field, "NAME")    == 0 ||
 283.233 +               strcmp(csa->field, "ROWS")    == 0 ||
 283.234 +               strcmp(csa->field, "COLUMNS") == 0 ||
 283.235 +               strcmp(csa->field, "RHS")     == 0 ||
 283.236 +               strcmp(csa->field, "RANGES")  == 0 ||
 283.237 +               strcmp(csa->field, "BOUNDS")  == 0 ||
 283.238 +               strcmp(csa->field, "ENDATA")  == 0))
 283.239 +            error(csa, "invalid indicator record\n");
 283.240 +         if (!name)
 283.241 +         {  while (csa->c != '\n')
 283.242 +               read_char(csa);
 283.243 +         }
 283.244 +         ret = 1;
 283.245 +      }
 283.246 +      return ret;
 283.247 +}
 283.248 +
 283.249 +static void read_field(struct csa *csa)
 283.250 +{     /* read next field of the current data record */
 283.251 +      csa->fldno++;
 283.252 +      if (csa->deck)
 283.253 +      {  /* fixed MPS format */
 283.254 +         int beg, end, pos;
 283.255 +         /* determine predefined field positions */
 283.256 +         if (csa->fldno == 1)
 283.257 +            beg = 2, end = 3;
 283.258 +         else if (csa->fldno == 2)
 283.259 +            beg = 5, end = 12;
 283.260 +         else if (csa->fldno == 3)
 283.261 +            beg = 15, end = 22;
 283.262 +         else if (csa->fldno == 4)
 283.263 +            beg = 25, end = 36;
 283.264 +         else if (csa->fldno == 5)
 283.265 +            beg = 40, end = 47;
 283.266 +         else if (csa->fldno == 6)
 283.267 +            beg = 50, end = 61;
 283.268 +         else
 283.269 +            xassert(csa != csa);
 283.270 +         /* skip blanks preceding the current field */
 283.271 +         if (csa->c != '\n')
 283.272 +         {  pos = csa->recpos;
 283.273 +            while (csa->recpos < beg)
 283.274 +            {  if (csa->c == ' ')
 283.275 +                  ;
 283.276 +               else if (csa->c == '\n')
 283.277 +                  break;
 283.278 +               else
 283.279 +                  error(csa, "in fixed MPS format positions %d-%d must "
 283.280 +                     "be blank\n", pos, beg-1);
 283.281 +               read_char(csa);
 283.282 +            }
 283.283 +         }
 283.284 +         /* skip possible comment beginning in the field 3 or 5 */
 283.285 +         if ((csa->fldno == 3 || csa->fldno == 5) && csa->c == '$')
 283.286 +         {  while (csa->c != '\n')
 283.287 +               read_char(csa);
 283.288 +         }
 283.289 +         /* read the current field */
 283.290 +         for (pos = beg; pos <= end; pos++)
 283.291 +         {  if (csa->c == '\n') break;
 283.292 +            csa->field[pos-beg] = (char)csa->c;
 283.293 +            read_char(csa);
 283.294 +         }
 283.295 +         csa->field[pos-beg] = '\0';
 283.296 +         strtrim(csa->field);
 283.297 +         /* skip blanks following the last field */
 283.298 +         if (csa->fldno == 6 && csa->c != '\n')
 283.299 +         {  while (csa->recpos <= 72)
 283.300 +            {  if (csa->c == ' ')
 283.301 +                  ;
 283.302 +               else if (csa->c == '\n')
 283.303 +                  break;
 283.304 +               else
 283.305 +                  error(csa, "in fixed MPS format positions 62-72 must "
 283.306 +                     "be blank\n");
 283.307 +               read_char(csa);
 283.308 +            }
 283.309 +            while (csa->c != '\n')
 283.310 +               read_char(csa);
 283.311 +         }
 283.312 +      }
 283.313 +      else
 283.314 +      {  /* free MPS format */
 283.315 +         int len;
 283.316 +         /* skip blanks preceding the current field */
 283.317 +         while (csa->c == ' ')
 283.318 +            read_char(csa);
 283.319 +         /* skip possible comment */
 283.320 +         if (csa->c == '$')
 283.321 +         {  while (csa->c != '\n')
 283.322 +               read_char(csa);
 283.323 +         }
 283.324 +         /* read the current field */
 283.325 +         len = 0;
 283.326 +         while (!(csa->c == ' ' || csa->c == '\n'))
 283.327 +         {  if (len == 255)
 283.328 +               error(csa, "length of field %d exceeds 255 characters\n",
 283.329 +                  csa->fldno++);
 283.330 +            csa->field[len++] = (char)csa->c;
 283.331 +            read_char(csa);
 283.332 +         }
 283.333 +         csa->field[len] = '\0';
 283.334 +         /* skip anything following the last field (any extra fields
 283.335 +            are considered to be comments) */
 283.336 +         if (csa->fldno == 6)
 283.337 +         {  while (csa->c == ' ')
 283.338 +               read_char(csa);
 283.339 +            if (csa->c != '$' && csa->c != '\n' && csa->wef < 1)
 283.340 +            {  warning(csa, "some extra field(s) detected beyond field "
 283.341 +                  "6; field(s) ignored\n");
 283.342 +               csa->wef++;
 283.343 +            }
 283.344 +            while (csa->c != '\n')
 283.345 +               read_char(csa);
 283.346 +         }
 283.347 +      }
 283.348 +      return;
 283.349 +}
 283.350 +
 283.351 +static void patch_name(struct csa *csa, char *name)
 283.352 +{     /* process embedded blanks in symbolic name */
 283.353 +      int blank = csa->parm->blank;
 283.354 +      if (blank == '\0')
 283.355 +      {  /* remove emedded blanks */
 283.356 +         strspx(name);
 283.357 +      }
 283.358 +      else
 283.359 +      {  /* replace embedded blanks by specified character */
 283.360 +         for (; *name != '\0'; name++)
 283.361 +            if (*name == ' ') *name = (char)blank;
 283.362 +      }
 283.363 +      return;
 283.364 +}
 283.365 +
 283.366 +static double read_number(struct csa *csa)
 283.367 +{     /* read next field and convert it to floating-point number */
 283.368 +      double x;
 283.369 +      char *s;
 283.370 +      /* read next field */
 283.371 +      read_field(csa);
 283.372 +      xassert(csa->fldno == 4 || csa->fldno == 6);
 283.373 +      if (csa->field[0] == '\0')
 283.374 +         error(csa, "missing numeric value in field %d\n", csa->fldno);
 283.375 +      /* skip initial spaces of the field */
 283.376 +      for (s = csa->field; *s == ' '; s++);
 283.377 +      /* perform conversion */
 283.378 +      if (str2num(s, &x) != 0)
 283.379 +         error(csa, "cannot convert `%s' to floating-point number\n",
 283.380 +            s);
 283.381 +      return x;
 283.382 +}
 283.383 +
 283.384 +static void skip_field(struct csa *csa)
 283.385 +{     /* read and skip next field (assumed to be blank) */
 283.386 +      read_field(csa);
 283.387 +      if (csa->field[0] != '\0')
 283.388 +         error(csa, "field %d must be blank\n", csa->fldno);
 283.389 +      return;
 283.390 +}
 283.391 +
 283.392 +static void read_name(struct csa *csa)
 283.393 +{     /* read NAME indicator record */
 283.394 +      if (!(indicator(csa, 1) && strcmp(csa->field, "NAME") == 0))
 283.395 +         error(csa, "missing NAME indicator record\n");
 283.396 +      /* this indicator record looks like a data record; simulate that
 283.397 +         fields 1 and 2 were read */
 283.398 +      csa->fldno = 2;
 283.399 +      /* field 3: model name */
 283.400 +      read_field(csa), patch_name(csa, csa->field);
 283.401 +      if (csa->field[0] == '\0')
 283.402 +         warning(csa, "missing model name in field 3\n");
 283.403 +      else
 283.404 +         glp_set_prob_name(csa->P, csa->field);
 283.405 +      /* skip anything following field 3 */
 283.406 +      while (csa->c != '\n')
 283.407 +         read_char(csa);
 283.408 +      return;
 283.409 +}
 283.410 +
 283.411 +static void read_rows(struct csa *csa)
 283.412 +{     /* read ROWS section */
 283.413 +      int i, type;
 283.414 +loop: if (indicator(csa, 0)) goto done;
 283.415 +      /* field 1: row type */
 283.416 +      read_field(csa), strspx(csa->field);
 283.417 +      if (strcmp(csa->field, "N") == 0)
 283.418 +         type = GLP_FR;
 283.419 +      else if (strcmp(csa->field, "G") == 0)
 283.420 +         type = GLP_LO;
 283.421 +      else if (strcmp(csa->field, "L") == 0)
 283.422 +         type = GLP_UP;
 283.423 +      else if (strcmp(csa->field, "E") == 0)
 283.424 +         type = GLP_FX;
 283.425 +      else if (csa->field[0] == '\0')
 283.426 +         error(csa, "missing row type in field 1\n");
 283.427 +      else
 283.428 +         error(csa, "invalid row type in field 1\n");
 283.429 +      /* field 2: row name */
 283.430 +      read_field(csa), patch_name(csa, csa->field);
 283.431 +      if (csa->field[0] == '\0')
 283.432 +         error(csa, "missing row name in field 2\n");
 283.433 +      if (glp_find_row(csa->P, csa->field) != 0)
 283.434 +         error(csa, "row `%s' multiply specified\n", csa->field);
 283.435 +      i = glp_add_rows(csa->P, 1);
 283.436 +      glp_set_row_name(csa->P, i, csa->field);
 283.437 +      glp_set_row_bnds(csa->P, i, type, 0.0, 0.0);
 283.438 +      /* fields 3, 4, 5, and 6 must be blank */
 283.439 +      skip_field(csa);
 283.440 +      skip_field(csa);
 283.441 +      skip_field(csa);
 283.442 +      skip_field(csa);
 283.443 +      goto loop;
 283.444 +done: return;
 283.445 +}
 283.446 +
 283.447 +static void read_columns(struct csa *csa)
 283.448 +{     /* read COLUMNS section */
 283.449 +      int i, j, f, len, kind = GLP_CV, *ind;
 283.450 +      double aij, *val;
 283.451 +      char name[255+1], *flag;
 283.452 +      /* allocate working arrays */
 283.453 +      csa->work1 = ind = xcalloc(1+csa->P->m, sizeof(int));
 283.454 +      csa->work2 = val = xcalloc(1+csa->P->m, sizeof(double));
 283.455 +      csa->work3 = flag = xcalloc(1+csa->P->m, sizeof(char));
 283.456 +      memset(&flag[1], 0, csa->P->m);
 283.457 +      /* no current column exists */
 283.458 +      j = 0, len = 0;
 283.459 +loop: if (indicator(csa, 0)) goto done;
 283.460 +      /* field 1 must be blank */
 283.461 +      if (csa->deck)
 283.462 +      {  read_field(csa);
 283.463 +         if (csa->field[0] != '\0')
 283.464 +            error(csa, "field 1 must be blank\n");
 283.465 +      }
 283.466 +      else
 283.467 +         csa->fldno++;
 283.468 +      /* field 2: column or kind name */
 283.469 +      read_field(csa), patch_name(csa, csa->field);
 283.470 +      strcpy(name, csa->field);
 283.471 +      /* field 3: row name or keyword 'MARKER' */
 283.472 +      read_field(csa), patch_name(csa, csa->field);
 283.473 +      if (strcmp(csa->field, "'MARKER'") == 0)
 283.474 +      {  /* process kind data record */
 283.475 +         /* field 4 must be blank */
 283.476 +         if (csa->deck)
 283.477 +         {  read_field(csa);
 283.478 +            if (csa->field[0] != '\0')
 283.479 +               error(csa, "field 4 must be blank\n");
 283.480 +         }
 283.481 +         else
 283.482 +            csa->fldno++;
 283.483 +         /* field 5: keyword 'INTORG' or 'INTEND' */
 283.484 +         read_field(csa), patch_name(csa, csa->field);
 283.485 +         if (strcmp(csa->field, "'INTORG'") == 0)
 283.486 +            kind = GLP_IV;
 283.487 +         else if (strcmp(csa->field, "'INTEND'") == 0)
 283.488 +            kind = GLP_CV;
 283.489 +         else if (csa->field[0] == '\0')
 283.490 +            error(csa, "missing keyword in field 5\n");
 283.491 +         else
 283.492 +            error(csa, "invalid keyword in field 5\n");
 283.493 +         /* field 6 must be blank */
 283.494 +         skip_field(csa);
 283.495 +         goto loop;
 283.496 +      }
 283.497 +      /* process column name specified in field 2 */
 283.498 +      if (name[0] == '\0')
 283.499 +      {  /* the same column as in previous data record */
 283.500 +         if (j == 0)
 283.501 +            error(csa, "missing column name in field 2\n");
 283.502 +      }
 283.503 +      else if (j != 0 && strcmp(name, csa->P->col[j]->name) == 0)
 283.504 +      {  /* the same column as in previous data record */
 283.505 +         xassert(j != 0);
 283.506 +      }
 283.507 +      else
 283.508 +      {  /* store the current column */
 283.509 +         if (j != 0)
 283.510 +         {  glp_set_mat_col(csa->P, j, len, ind, val);
 283.511 +            while (len > 0) flag[ind[len--]] = 0;
 283.512 +         }
 283.513 +         /* create new column */
 283.514 +         if (glp_find_col(csa->P, name) != 0)
 283.515 +            error(csa, "column `%s' multiply specified\n", name);
 283.516 +         j = glp_add_cols(csa->P, 1);
 283.517 +         glp_set_col_name(csa->P, j, name);
 283.518 +         glp_set_col_kind(csa->P, j, kind);
 283.519 +         if (kind == GLP_CV)
 283.520 +            glp_set_col_bnds(csa->P, j, GLP_LO, 0.0, 0.0);
 283.521 +         else if (kind == GLP_IV)
 283.522 +            glp_set_col_bnds(csa->P, j, GLP_DB, 0.0, 1.0);
 283.523 +         else
 283.524 +            xassert(kind != kind);
 283.525 +      }
 283.526 +      /* process fields 3-4 and 5-6 */
 283.527 +      for (f = 3; f <= 5; f += 2)
 283.528 +      {  /* field 3 or 5: row name */
 283.529 +         if (f == 3)
 283.530 +         {  if (csa->field[0] == '\0')
 283.531 +               error(csa, "missing row name in field 3\n");
 283.532 +         }
 283.533 +         else
 283.534 +         {  read_field(csa), patch_name(csa, csa->field);
 283.535 +            if (csa->field[0] == '\0')
 283.536 +            {  /* if field 5 is blank, field 6 also must be blank */
 283.537 +               skip_field(csa);
 283.538 +               continue;
 283.539 +            }
 283.540 +         }
 283.541 +         i = glp_find_row(csa->P, csa->field);
 283.542 +         if (i == 0)
 283.543 +            error(csa, "row `%s' not found\n", csa->field);
 283.544 +         if (flag[i])
 283.545 +            error(csa, "duplicate coefficient in row `%s'\n",
 283.546 +               csa->field);
 283.547 +         /* field 4 or 6: coefficient value */
 283.548 +         aij = read_number(csa);
 283.549 +         if (fabs(aij) < csa->parm->tol_mps) aij = 0.0;
 283.550 +         len++, ind[len] = i, val[len] = aij, flag[i] = 1;
 283.551 +      }
 283.552 +      goto loop;
 283.553 +done: /* store the last column */
 283.554 +      if (j != 0)
 283.555 +         glp_set_mat_col(csa->P, j, len, ind, val);
 283.556 +      /* free working arrays */
 283.557 +      xfree(ind);
 283.558 +      xfree(val);
 283.559 +      xfree(flag);
 283.560 +      csa->work1 = csa->work2 = csa->work3 = NULL;
 283.561 +      return;
 283.562 +}
 283.563 +
 283.564 +static void read_rhs(struct csa *csa)
 283.565 +{     /* read RHS section */
 283.566 +      int i, f, v, type;
 283.567 +      double rhs;
 283.568 +      char name[255+1], *flag;
 283.569 +      /* allocate working array */
 283.570 +      csa->work3 = flag = xcalloc(1+csa->P->m, sizeof(char));
 283.571 +      memset(&flag[1], 0, csa->P->m);
 283.572 +      /* no current RHS vector exists */
 283.573 +      v = 0;
 283.574 +loop: if (indicator(csa, 0)) goto done;
 283.575 +      /* field 1 must be blank */
 283.576 +      if (csa->deck)
 283.577 +      {  read_field(csa);
 283.578 +         if (csa->field[0] != '\0')
 283.579 +            error(csa, "field 1 must be blank\n");
 283.580 +      }
 283.581 +      else
 283.582 +         csa->fldno++;
 283.583 +      /* field 2: RHS vector name */
 283.584 +      read_field(csa), patch_name(csa, csa->field);
 283.585 +      if (csa->field[0] == '\0')
 283.586 +      {  /* the same RHS vector as in previous data record */
 283.587 +         if (v == 0)
 283.588 +         {  warning(csa, "missing RHS vector name in field 2\n");
 283.589 +            goto blnk;
 283.590 +         }
 283.591 +      }
 283.592 +      else if (v != 0 && strcmp(csa->field, name) == 0)
 283.593 +      {  /* the same RHS vector as in previous data record */
 283.594 +         xassert(v != 0);
 283.595 +      }
 283.596 +      else
 283.597 +blnk: {  /* new RHS vector */
 283.598 +         if (v != 0)
 283.599 +            error(csa, "multiple RHS vectors not supported\n");
 283.600 +         v++;
 283.601 +         strcpy(name, csa->field);
 283.602 +      }
 283.603 +      /* process fields 3-4 and 5-6 */
 283.604 +      for (f = 3; f <= 5; f += 2)
 283.605 +      {  /* field 3 or 5: row name */
 283.606 +         read_field(csa), patch_name(csa, csa->field);
 283.607 +         if (csa->field[0] == '\0')
 283.608 +         {  if (f == 3)
 283.609 +               error(csa, "missing row name in field 3\n");
 283.610 +            else
 283.611 +            {  /* if field 5 is blank, field 6 also must be blank */
 283.612 +               skip_field(csa);
 283.613 +               continue;
 283.614 +            }
 283.615 +         }
 283.616 +         i = glp_find_row(csa->P, csa->field);
 283.617 +         if (i == 0)
 283.618 +            error(csa, "row `%s' not found\n", csa->field);
 283.619 +         if (flag[i])
 283.620 +            error(csa, "duplicate right-hand side for row `%s'\n",
 283.621 +               csa->field);
 283.622 +         /* field 4 or 6: right-hand side value */
 283.623 +         rhs = read_number(csa);
 283.624 +         if (fabs(rhs) < csa->parm->tol_mps) rhs = 0.0;
 283.625 +         type = csa->P->row[i]->type;
 283.626 +         if (type == GLP_FR)
 283.627 +         {  if (i == csa->obj_row)
 283.628 +               glp_set_obj_coef(csa->P, 0, rhs);
 283.629 +            else if (rhs != 0.0)
 283.630 +               warning(csa, "non-zero right-hand side for free row `%s'"
 283.631 +                  " ignored\n", csa->P->row[i]->name);
 283.632 +         }
 283.633 +         else
 283.634 +            glp_set_row_bnds(csa->P, i, type, rhs, rhs);
 283.635 +         flag[i] = 1;
 283.636 +      }
 283.637 +      goto loop;
 283.638 +done: /* free working array */
 283.639 +      xfree(flag);
 283.640 +      csa->work3 = NULL;
 283.641 +      return;
 283.642 +}
 283.643 +
 283.644 +static void read_ranges(struct csa *csa)
 283.645 +{     /* read RANGES section */
 283.646 +      int i, f, v, type;
 283.647 +      double rhs, rng;
 283.648 +      char name[255+1], *flag;
 283.649 +      /* allocate working array */
 283.650 +      csa->work3 = flag = xcalloc(1+csa->P->m, sizeof(char));
 283.651 +      memset(&flag[1], 0, csa->P->m);
 283.652 +      /* no current RANGES vector exists */
 283.653 +      v = 0;
 283.654 +loop: if (indicator(csa, 0)) goto done;
 283.655 +      /* field 1 must be blank */
 283.656 +      if (csa->deck)
 283.657 +      {  read_field(csa);
 283.658 +         if (csa->field[0] != '\0')
 283.659 +            error(csa, "field 1 must be blank\n");
 283.660 +      }
 283.661 +      else
 283.662 +         csa->fldno++;
 283.663 +      /* field 2: RANGES vector name */
 283.664 +      read_field(csa), patch_name(csa, csa->field);
 283.665 +      if (csa->field[0] == '\0')
 283.666 +      {  /* the same RANGES vector as in previous data record */
 283.667 +         if (v == 0)
 283.668 +         {  warning(csa, "missing RANGES vector name in field 2\n");
 283.669 +            goto blnk;
 283.670 +         }
 283.671 +      }
 283.672 +      else if (v != 0 && strcmp(csa->field, name) == 0)
 283.673 +      {  /* the same RANGES vector as in previous data record */
 283.674 +         xassert(v != 0);
 283.675 +      }
 283.676 +      else
 283.677 +blnk: {  /* new RANGES vector */
 283.678 +         if (v != 0)
 283.679 +            error(csa, "multiple RANGES vectors not supported\n");
 283.680 +         v++;
 283.681 +         strcpy(name, csa->field);
 283.682 +      }
 283.683 +      /* process fields 3-4 and 5-6 */
 283.684 +      for (f = 3; f <= 5; f += 2)
 283.685 +      {  /* field 3 or 5: row name */
 283.686 +         read_field(csa), patch_name(csa, csa->field);
 283.687 +         if (csa->field[0] == '\0')
 283.688 +         {  if (f == 3)
 283.689 +               error(csa, "missing row name in field 3\n");
 283.690 +            else
 283.691 +            {  /* if field 5 is blank, field 6 also must be blank */
 283.692 +               skip_field(csa);
 283.693 +               continue;
 283.694 +            }
 283.695 +         }
 283.696 +         i = glp_find_row(csa->P, csa->field);
 283.697 +         if (i == 0)
 283.698 +            error(csa, "row `%s' not found\n", csa->field);
 283.699 +         if (flag[i])
 283.700 +            error(csa, "duplicate range for row `%s'\n", csa->field);
 283.701 +         /* field 4 or 6: range value */
 283.702 +         rng = read_number(csa);
 283.703 +         if (fabs(rng) < csa->parm->tol_mps) rng = 0.0;
 283.704 +         type = csa->P->row[i]->type;
 283.705 +         if (type == GLP_FR)
 283.706 +            warning(csa, "range for free row `%s' ignored\n",
 283.707 +               csa->P->row[i]->name);
 283.708 +         else if (type == GLP_LO)
 283.709 +         {  rhs = csa->P->row[i]->lb;
 283.710 +            glp_set_row_bnds(csa->P, i, rhs == 0.0 ? GLP_FX : GLP_DB,
 283.711 +               rhs, rhs + fabs(rng));
 283.712 +         }
 283.713 +         else if (type == GLP_UP)
 283.714 +         {  rhs = csa->P->row[i]->ub;
 283.715 +            glp_set_row_bnds(csa->P, i, rhs == 0.0 ? GLP_FX : GLP_DB,
 283.716 +               rhs - fabs(rng), rhs);
 283.717 +         }
 283.718 +         else if (type == GLP_FX)
 283.719 +         {  rhs = csa->P->row[i]->lb;
 283.720 +            if (rng > 0.0)
 283.721 +               glp_set_row_bnds(csa->P, i, GLP_DB, rhs, rhs + rng);
 283.722 +            else if (rng < 0.0)
 283.723 +               glp_set_row_bnds(csa->P, i, GLP_DB, rhs + rng, rhs);
 283.724 +         }
 283.725 +         else
 283.726 +            xassert(type != type);
 283.727 +         flag[i] = 1;
 283.728 +      }
 283.729 +      goto loop;
 283.730 +done: /* free working array */
 283.731 +      xfree(flag);
 283.732 +      csa->work3 = NULL;
 283.733 +      return;
 283.734 +}
 283.735 +
 283.736 +static void read_bounds(struct csa *csa)
 283.737 +{     /* read BOUNDS section */
 283.738 +      GLPCOL *col;
 283.739 +      int j, v, mask, data;
 283.740 +      double bnd, lb, ub;
 283.741 +      char type[2+1], name[255+1], *flag;
 283.742 +      /* allocate working array */
 283.743 +      csa->work3 = flag = xcalloc(1+csa->P->n, sizeof(char));
 283.744 +      memset(&flag[1], 0, csa->P->n);
 283.745 +      /* no current BOUNDS vector exists */
 283.746 +      v = 0;
 283.747 +loop: if (indicator(csa, 0)) goto done;
 283.748 +      /* field 1: bound type */
 283.749 +      read_field(csa);
 283.750 +      if (strcmp(csa->field, "LO") == 0)
 283.751 +         mask = 0x01, data = 1;
 283.752 +      else if (strcmp(csa->field, "UP") == 0)
 283.753 +         mask = 0x10, data = 1;
 283.754 +      else if (strcmp(csa->field, "FX") == 0)
 283.755 +         mask = 0x11, data = 1;
 283.756 +      else if (strcmp(csa->field, "FR") == 0)
 283.757 +         mask = 0x11, data = 0;
 283.758 +      else if (strcmp(csa->field, "MI") == 0)
 283.759 +         mask = 0x01, data = 0;
 283.760 +      else if (strcmp(csa->field, "PL") == 0)
 283.761 +         mask = 0x10, data = 0;
 283.762 +      else if (strcmp(csa->field, "LI") == 0)
 283.763 +         mask = 0x01, data = 1;
 283.764 +      else if (strcmp(csa->field, "UI") == 0)
 283.765 +         mask = 0x10, data = 1;
 283.766 +      else if (strcmp(csa->field, "BV") == 0)
 283.767 +         mask = 0x11, data = 0;
 283.768 +      else if (csa->field[0] == '\0')
 283.769 +         error(csa, "missing bound type in field 1\n");
 283.770 +      else
 283.771 +         error(csa, "invalid bound type in field 1\n");
 283.772 +      strcpy(type, csa->field);
 283.773 +      /* field 2: BOUNDS vector name */
 283.774 +      read_field(csa), patch_name(csa, csa->field);
 283.775 +      if (csa->field[0] == '\0')
 283.776 +      {  /* the same BOUNDS vector as in previous data record */
 283.777 +         if (v == 0)
 283.778 +         {  warning(csa, "missing BOUNDS vector name in field 2\n");
 283.779 +            goto blnk;
 283.780 +         }
 283.781 +      }
 283.782 +      else if (v != 0 && strcmp(csa->field, name) == 0)
 283.783 +      {  /* the same BOUNDS vector as in previous data record */
 283.784 +         xassert(v != 0);
 283.785 +      }
 283.786 +      else
 283.787 +blnk: {  /* new BOUNDS vector */
 283.788 +         if (v != 0)
 283.789 +            error(csa, "multiple BOUNDS vectors not supported\n");
 283.790 +         v++;
 283.791 +         strcpy(name, csa->field);
 283.792 +      }
 283.793 +      /* field 3: column name */
 283.794 +      read_field(csa), patch_name(csa, csa->field);
 283.795 +      if (csa->field[0] == '\0')
 283.796 +         error(csa, "missing column name in field 3\n");
 283.797 +      j = glp_find_col(csa->P, csa->field);
 283.798 +      if (j == 0)
 283.799 +         error(csa, "column `%s' not found\n", csa->field);
 283.800 +      if ((flag[j] & mask) == 0x01)
 283.801 +         error(csa, "duplicate lower bound for column `%s'\n",
 283.802 +            csa->field);
 283.803 +      if ((flag[j] & mask) == 0x10)
 283.804 +         error(csa, "duplicate upper bound for column `%s'\n",
 283.805 +            csa->field);
 283.806 +      xassert((flag[j] & mask) == 0x00);
 283.807 +      /* field 4: bound value */
 283.808 +      if (data)
 283.809 +      {  bnd = read_number(csa);
 283.810 +         if (fabs(bnd) < csa->parm->tol_mps) bnd = 0.0;
 283.811 +      }
 283.812 +      else
 283.813 +         read_field(csa), bnd = 0.0;
 283.814 +      /* get current column bounds */
 283.815 +      col = csa->P->col[j];
 283.816 +      if (col->type == GLP_FR)
 283.817 +         lb = -DBL_MAX, ub = +DBL_MAX;
 283.818 +      else if (col->type == GLP_LO)
 283.819 +         lb = col->lb, ub = +DBL_MAX;
 283.820 +      else if (col->type == GLP_UP)
 283.821 +         lb = -DBL_MAX, ub = col->ub;
 283.822 +      else if (col->type == GLP_DB)
 283.823 +         lb = col->lb, ub = col->ub;
 283.824 +      else if (col->type == GLP_FX)
 283.825 +         lb = ub = col->lb;
 283.826 +      else
 283.827 +         xassert(col != col);
 283.828 +      /* change column bounds */
 283.829 +      if (strcmp(type, "LO") == 0)
 283.830 +         lb = bnd;
 283.831 +      else if (strcmp(type, "UP") == 0)
 283.832 +         ub = bnd;
 283.833 +      else if (strcmp(type, "FX") == 0)
 283.834 +         lb = ub = bnd;
 283.835 +      else if (strcmp(type, "FR") == 0)
 283.836 +         lb = -DBL_MAX, ub = +DBL_MAX;
 283.837 +      else if (strcmp(type, "MI") == 0)
 283.838 +         lb = -DBL_MAX;
 283.839 +      else if (strcmp(type, "PL") == 0)
 283.840 +         ub = +DBL_MAX;
 283.841 +      else if (strcmp(type, "LI") == 0)
 283.842 +      {  glp_set_col_kind(csa->P, j, GLP_IV);
 283.843 +         lb = ceil(bnd);
 283.844 +      }
 283.845 +      else if (strcmp(type, "UI") == 0)
 283.846 +      {  glp_set_col_kind(csa->P, j, GLP_IV);
 283.847 +         ub = floor(bnd);
 283.848 +      }
 283.849 +      else if (strcmp(type, "BV") == 0)
 283.850 +      {  glp_set_col_kind(csa->P, j, GLP_IV);
 283.851 +         lb = 0.0, ub = 1.0;
 283.852 +      }
 283.853 +      else
 283.854 +         xassert(type != type);
 283.855 +      /* set new column bounds */
 283.856 +      if (lb == -DBL_MAX && ub == +DBL_MAX)
 283.857 +         glp_set_col_bnds(csa->P, j, GLP_FR, lb, ub);
 283.858 +      else if (ub == +DBL_MAX)
 283.859 +         glp_set_col_bnds(csa->P, j, GLP_LO, lb, ub);
 283.860 +      else if (lb == -DBL_MAX)
 283.861 +         glp_set_col_bnds(csa->P, j, GLP_UP, lb, ub);
 283.862 +      else if (lb != ub)
 283.863 +         glp_set_col_bnds(csa->P, j, GLP_DB, lb, ub);
 283.864 +      else
 283.865 +         glp_set_col_bnds(csa->P, j, GLP_FX, lb, ub);
 283.866 +      flag[j] |= (char)mask;
 283.867 +      /* fields 5 and 6 must be blank */
 283.868 +      skip_field(csa);
 283.869 +      skip_field(csa);
 283.870 +      goto loop;
 283.871 +done: /* free working array */
 283.872 +      xfree(flag);
 283.873 +      csa->work3 = NULL;
 283.874 +      return;
 283.875 +}
 283.876 +
 283.877 +int glp_read_mps(glp_prob *P, int fmt, const glp_mpscp *parm,
 283.878 +      const char *fname)
 283.879 +{     /* read problem data in MPS format */
 283.880 +      glp_mpscp _parm;
 283.881 +      struct csa _csa, *csa = &_csa;
 283.882 +      int ret;
 283.883 +      xprintf("Reading problem data from `%s'...\n", fname);
 283.884 +      if (!(fmt == GLP_MPS_DECK || fmt == GLP_MPS_FILE))
 283.885 +         xerror("glp_read_mps: fmt = %d; invalid parameter\n", fmt);
 283.886 +      if (parm == NULL)
 283.887 +         glp_init_mpscp(&_parm), parm = &_parm;
 283.888 +      /* check control parameters */
 283.889 +      check_parm("glp_read_mps", parm);
 283.890 +      /* initialize common storage area */
 283.891 +      csa->P = P;
 283.892 +      csa->deck = (fmt == GLP_MPS_DECK);
 283.893 +      csa->parm = parm;
 283.894 +      csa->fname = fname;
 283.895 +      csa->fp = NULL;
 283.896 +      if (setjmp(csa->jump))
 283.897 +      {  ret = 1;
 283.898 +         goto done;
 283.899 +      }
 283.900 +      csa->recno = csa->recpos = 0;
 283.901 +      csa->c = '\n';
 283.902 +      csa->fldno = 0;
 283.903 +      csa->field[0] = '\0';
 283.904 +      csa->w80 = csa->wef = 0;
 283.905 +      csa->obj_row = 0;
 283.906 +      csa->work1 = csa->work2 = csa->work3 = NULL;
 283.907 +      /* erase problem object */
 283.908 +      glp_erase_prob(P);
 283.909 +      glp_create_index(P);
 283.910 +      /* open input MPS file */
 283.911 +      csa->fp = xfopen(fname, "r");
 283.912 +      if (csa->fp == NULL)
 283.913 +      {  xprintf("Unable to open `%s' - %s\n", fname, xerrmsg());
 283.914 +         ret = 1;
 283.915 +         goto done;
 283.916 +      }
 283.917 +      /* read NAME indicator record */
 283.918 +      read_name(csa);
 283.919 +      if (P->name != NULL)
 283.920 +         xprintf("Problem: %s\n", P->name);
 283.921 +      /* read ROWS section */
 283.922 +      if (!(indicator(csa, 0) && strcmp(csa->field, "ROWS") == 0))
 283.923 +         error(csa, "missing ROWS indicator record\n");
 283.924 +      read_rows(csa);
 283.925 +      /* determine objective row */
 283.926 +      if (parm->obj_name == NULL || parm->obj_name[0] == '\0')
 283.927 +      {  /* use the first row of N type */
 283.928 +         int i;
 283.929 +         for (i = 1; i <= P->m; i++)
 283.930 +         {  if (P->row[i]->type == GLP_FR)
 283.931 +            {  csa->obj_row = i;
 283.932 +               break;
 283.933 +            }
 283.934 +         }
 283.935 +         if (csa->obj_row == 0)
 283.936 +            warning(csa, "unable to determine objective row\n");
 283.937 +      }
 283.938 +      else
 283.939 +      {  /* use a row with specified name */
 283.940 +         int i;
 283.941 +         for (i = 1; i <= P->m; i++)
 283.942 +         {  xassert(P->row[i]->name != NULL);
 283.943 +            if (strcmp(parm->obj_name, P->row[i]->name) == 0)
 283.944 +            {  csa->obj_row = i;
 283.945 +               break;
 283.946 +            }
 283.947 +         }
 283.948 +         if (csa->obj_row == 0)
 283.949 +            error(csa, "objective row `%s' not found\n",
 283.950 +               parm->obj_name);
 283.951 +      }
 283.952 +      if (csa->obj_row != 0)
 283.953 +      {  glp_set_obj_name(P, P->row[csa->obj_row]->name);
 283.954 +         xprintf("Objective: %s\n", P->obj);
 283.955 +      }
 283.956 +      /* read COLUMNS section */
 283.957 +      if (strcmp(csa->field, "COLUMNS") != 0)
 283.958 +         error(csa, "missing COLUMNS indicator record\n");
 283.959 +      read_columns(csa);
 283.960 +      /* set objective coefficients */
 283.961 +      if (csa->obj_row != 0)
 283.962 +      {  GLPAIJ *aij;
 283.963 +         for (aij = P->row[csa->obj_row]->ptr; aij != NULL; aij =
 283.964 +            aij->r_next) glp_set_obj_coef(P, aij->col->j, aij->val);
 283.965 +      }
 283.966 +      /* read optional RHS section */
 283.967 +      if (strcmp(csa->field, "RHS") == 0)
 283.968 +         read_rhs(csa);
 283.969 +      /* read optional RANGES section */
 283.970 +      if (strcmp(csa->field, "RANGES") == 0)
 283.971 +         read_ranges(csa);
 283.972 +      /* read optional BOUNDS section */
 283.973 +      if (strcmp(csa->field, "BOUNDS") == 0)
 283.974 +         read_bounds(csa);
 283.975 +      /* read ENDATA indicator record */
 283.976 +      if (strcmp(csa->field, "ENDATA") != 0)
 283.977 +         error(csa, "invalid use of %s indicator record\n",
 283.978 +            csa->field);
 283.979 +      /* print some statistics */
 283.980 +      xprintf("%d row%s, %d column%s, %d non-zero%s\n",
 283.981 +         P->m, P->m == 1 ? "" : "s", P->n, P->n == 1 ? "" : "s",
 283.982 +         P->nnz, P->nnz == 1 ? "" : "s");
 283.983 +      if (glp_get_num_int(P) > 0)
 283.984 +      {  int ni = glp_get_num_int(P);
 283.985 +         int nb = glp_get_num_bin(P);
 283.986 +         if (ni == 1)
 283.987 +         {  if (nb == 0)
 283.988 +               xprintf("One variable is integer\n");
 283.989 +            else
 283.990 +               xprintf("One variable is binary\n");
 283.991 +         }
 283.992 +         else
 283.993 +         {  xprintf("%d integer variables, ", ni);
 283.994 +            if (nb == 0)
 283.995 +               xprintf("none");
 283.996 +            else if (nb == 1)
 283.997 +               xprintf("one");
 283.998 +            else if (nb == ni)
 283.999 +               xprintf("all");
283.1000 +            else
283.1001 +               xprintf("%d", nb);
283.1002 +            xprintf(" of which %s binary\n", nb == 1 ? "is" : "are");
283.1003 +         }
283.1004 +      }
283.1005 +      xprintf("%d records were read\n", csa->recno);
283.1006 +      /* problem data has been successfully read */
283.1007 +      glp_delete_index(P);
283.1008 +      glp_sort_matrix(P);
283.1009 +      ret = 0;
283.1010 +done: if (csa->fp != NULL) xfclose(csa->fp);
283.1011 +      if (csa->work1 != NULL) xfree(csa->work1);
283.1012 +      if (csa->work2 != NULL) xfree(csa->work2);
283.1013 +      if (csa->work3 != NULL) xfree(csa->work3);
283.1014 +      if (ret != 0) glp_erase_prob(P);
283.1015 +      return ret;
283.1016 +}
283.1017 +
283.1018 +/***********************************************************************
283.1019 +*  NAME
283.1020 +*
283.1021 +*  glp_write_mps - write problem data in MPS format
283.1022 +*
283.1023 +*  SYNOPSIS
283.1024 +*
283.1025 +*  int glp_write_mps(glp_prob *P, int fmt, const glp_mpscp *parm,
283.1026 +*     const char *fname);
283.1027 +*
283.1028 +*  DESCRIPTION
283.1029 +*
283.1030 +*  The routine glp_write_mps writes problem data in MPS format to a
283.1031 +*  text file.
283.1032 +*
283.1033 +*  The parameter fmt specifies the version of MPS format:
283.1034 +*
283.1035 +*  GLP_MPS_DECK - fixed (ancient) MPS format;
283.1036 +*  GLP_MPS_FILE - free (modern) MPS format.
283.1037 +*
283.1038 +*  The parameter parm is a pointer to the structure glp_mpscp, which
283.1039 +*  specifies control parameters used by the routine. If parm is NULL,
283.1040 +*  the routine uses default settings.
283.1041 +*
283.1042 +*  The character string fname specifies a name of the text file to be
283.1043 +*  written.
283.1044 +*
283.1045 +*  RETURNS
283.1046 +*
283.1047 +*  If the operation was successful, the routine glp_read_mps returns
283.1048 +*  zero. Otherwise, it prints an error message and returns non-zero. */
283.1049 +
283.1050 +#define csa csa1
283.1051 +
283.1052 +struct csa
283.1053 +{     /* common storage area */
283.1054 +      glp_prob *P;
283.1055 +      /* pointer to problem object */
283.1056 +      int deck;
283.1057 +      /* MPS format (0 - free, 1 - fixed) */
283.1058 +      const glp_mpscp *parm;
283.1059 +      /* pointer to control parameters */
283.1060 +      char field[255+1];
283.1061 +      /* field buffer */
283.1062 +};
283.1063 +
283.1064 +static char *mps_name(struct csa *csa)
283.1065 +{     /* make problem name */
283.1066 +      char *f;
283.1067 +      if (csa->P->name == NULL)
283.1068 +         csa->field[0] = '\0';
283.1069 +      else if (csa->deck)
283.1070 +      {  strncpy(csa->field, csa->P->name, 8);
283.1071 +         csa->field[8] = '\0';
283.1072 +      }
283.1073 +      else
283.1074 +         strcpy(csa->field, csa->P->name);
283.1075 +      for (f = csa->field; *f != '\0'; f++)
283.1076 +         if (*f == ' ') *f = '_';
283.1077 +      return csa->field;
283.1078 +}
283.1079 +
283.1080 +static char *row_name(struct csa *csa, int i)
283.1081 +{     /* make i-th row name */
283.1082 +      char *f;
283.1083 +      xassert(0 <= i && i <= csa->P->m);
283.1084 +      if (i == 0 || csa->P->row[i]->name == NULL ||
283.1085 +          csa->deck && strlen(csa->P->row[i]->name) > 8)
283.1086 +         sprintf(csa->field, "R%07d", i);
283.1087 +      else
283.1088 +      {  strcpy(csa->field, csa->P->row[i]->name);
283.1089 +         for (f = csa->field; *f != '\0'; f++)
283.1090 +            if (*f == ' ') *f = '_';
283.1091 +      }
283.1092 +      return csa->field;
283.1093 +}
283.1094 +
283.1095 +static char *col_name(struct csa *csa, int j)
283.1096 +{     /* make j-th column name */
283.1097 +      char *f;
283.1098 +      xassert(1 <= j && j <= csa->P->n);
283.1099 +      if (csa->P->col[j]->name == NULL ||
283.1100 +          csa->deck && strlen(csa->P->col[j]->name) > 8)
283.1101 +         sprintf(csa->field, "C%07d", j);
283.1102 +      else
283.1103 +      {  strcpy(csa->field, csa->P->col[j]->name);
283.1104 +         for (f = csa->field; *f != '\0'; f++)
283.1105 +            if (*f == ' ') *f = '_';
283.1106 +      }
283.1107 +      return csa->field;
283.1108 +}
283.1109 +
283.1110 +static char *mps_numb(struct csa *csa, double val)
283.1111 +{     /* format floating-point number */
283.1112 +      int dig;
283.1113 +      char *exp;
283.1114 +      for (dig = 12; dig >= 6; dig--)
283.1115 +      {  if (val != 0.0 && fabs(val) < 0.002)
283.1116 +            sprintf(csa->field, "%.*E", dig-1, val);
283.1117 +         else
283.1118 +            sprintf(csa->field, "%.*G", dig, val);
283.1119 +         exp = strchr(csa->field, 'E');
283.1120 +         if (exp != NULL)
283.1121 +            sprintf(exp+1, "%d", atoi(exp+1));
283.1122 +         if (strlen(csa->field) <= 12) break;
283.1123 +      }
283.1124 +      xassert(strlen(csa->field) <= 12);
283.1125 +      return csa->field;
283.1126 +}
283.1127 +
283.1128 +int glp_write_mps(glp_prob *P, int fmt, const glp_mpscp *parm,
283.1129 +      const char *fname)
283.1130 +{     /* write problem data in MPS format */
283.1131 +      glp_mpscp _parm;
283.1132 +      struct csa _csa, *csa = &_csa;
283.1133 +      XFILE *fp;
283.1134 +      int out_obj, one_col = 0, empty = 0;
283.1135 +      int i, j, recno, marker, count, gap, ret;
283.1136 +      xprintf("Writing problem data to `%s'...\n", fname);
283.1137 +      if (!(fmt == GLP_MPS_DECK || fmt == GLP_MPS_FILE))
283.1138 +         xerror("glp_write_mps: fmt = %d; invalid parameter\n", fmt);
283.1139 +      if (parm == NULL)
283.1140 +         glp_init_mpscp(&_parm), parm = &_parm;
283.1141 +      /* check control parameters */
283.1142 +      check_parm("glp_write_mps", parm);
283.1143 +      /* initialize common storage area */
283.1144 +      csa->P = P;
283.1145 +      csa->deck = (fmt == GLP_MPS_DECK);
283.1146 +      csa->parm = parm;
283.1147 +      /* create output MPS file */
283.1148 +      fp = xfopen(fname, "w"), recno = 0;
283.1149 +      if (fp == NULL)
283.1150 +      {  xprintf("Unable to create `%s' - %s\n", fname, xerrmsg());
283.1151 +         ret = 1;
283.1152 +         goto done;
283.1153 +      }
283.1154 +      /* write comment records */
283.1155 +      xfprintf(fp, "* %-*s%s\n", P->name == NULL ? 1 : 12, "Problem:",
283.1156 +         P->name == NULL ? "" : P->name), recno++;
283.1157 +      xfprintf(fp, "* %-12s%s\n", "Class:", glp_get_num_int(P) == 0 ?
283.1158 +         "LP" : "MIP"), recno++;
283.1159 +      xfprintf(fp, "* %-12s%d\n", "Rows:", P->m), recno++;
283.1160 +      if (glp_get_num_int(P) == 0)
283.1161 +         xfprintf(fp, "* %-12s%d\n", "Columns:", P->n), recno++;
283.1162 +      else
283.1163 +         xfprintf(fp, "* %-12s%d (%d integer, %d binary)\n",
283.1164 +            "Columns:", P->n, glp_get_num_int(P), glp_get_num_bin(P)),
283.1165 +            recno++;
283.1166 +      xfprintf(fp, "* %-12s%d\n", "Non-zeros:", P->nnz), recno++;
283.1167 +      xfprintf(fp, "* %-12s%s\n", "Format:", csa->deck ? "Fixed MPS" :
283.1168 +         "Free MPS"), recno++;
283.1169 +      xfprintf(fp, "*\n", recno++);
283.1170 +      /* write NAME indicator record */
283.1171 +      xfprintf(fp, "NAME%*s%s\n",
283.1172 +         P->name == NULL ? 0 : csa->deck ? 10 : 1, "", mps_name(csa)),
283.1173 +         recno++;
283.1174 +#if 1
283.1175 +      /* determine whether to write the objective row */
283.1176 +      out_obj = 1;
283.1177 +      for (i = 1; i <= P->m; i++)
283.1178 +      {  if (P->row[i]->type == GLP_FR)
283.1179 +         {  out_obj = 0;
283.1180 +            break;
283.1181 +         }
283.1182 +      }
283.1183 +#endif
283.1184 +      /* write ROWS section */
283.1185 +      xfprintf(fp, "ROWS\n"), recno++;
283.1186 +      for (i = (out_obj ? 0 : 1); i <= P->m; i++)
283.1187 +      {  int type;
283.1188 +         type = (i == 0 ? GLP_FR : P->row[i]->type);
283.1189 +         if (type == GLP_FR)
283.1190 +            type = 'N';
283.1191 +         else if (type == GLP_LO)
283.1192 +            type = 'G';
283.1193 +         else if (type == GLP_UP)
283.1194 +            type = 'L';
283.1195 +         else if (type == GLP_DB || type == GLP_FX)
283.1196 +            type = 'E';
283.1197 +         else
283.1198 +            xassert(type != type);
283.1199 +         xfprintf(fp, " %c%*s%s\n", type, csa->deck ? 2 : 1, "",
283.1200 +            row_name(csa, i)), recno++;
283.1201 +      }
283.1202 +      /* write COLUMNS section */
283.1203 +      xfprintf(fp, "COLUMNS\n"), recno++;
283.1204 +      marker = 0;
283.1205 +      for (j = 1; j <= P->n; j++)
283.1206 +      {  GLPAIJ cj, *aij;
283.1207 +         int kind;
283.1208 +         kind = P->col[j]->kind;
283.1209 +         if (kind == GLP_CV)
283.1210 +         {  if (marker % 2 == 1)
283.1211 +            {  /* close current integer block */
283.1212 +               marker++;
283.1213 +               xfprintf(fp, "%*sM%07d%*s'MARKER'%*s'INTEND'\n",
283.1214 +                  csa->deck ? 4 : 1, "", marker, csa->deck ? 2 : 1, "",
283.1215 +                  csa->deck ? 17 : 1, ""), recno++;
283.1216 +            }
283.1217 +         }
283.1218 +         else if (kind == GLP_IV)
283.1219 +         {  if (marker % 2 == 0)
283.1220 +            {  /* open new integer block */
283.1221 +               marker++;
283.1222 +               xfprintf(fp, "%*sM%07d%*s'MARKER'%*s'INTORG'\n",
283.1223 +                  csa->deck ? 4 : 1, "", marker, csa->deck ? 2 : 1, "",
283.1224 +                  csa->deck ? 17 : 1, ""), recno++;
283.1225 +            }
283.1226 +         }
283.1227 +         else
283.1228 +            xassert(kind != kind);
283.1229 +         if (out_obj && P->col[j]->coef != 0.0)
283.1230 +         {  /* make fake objective coefficient */
283.1231 +            aij = &cj;
283.1232 +            aij->row = NULL;
283.1233 +            aij->val = P->col[j]->coef;
283.1234 +            aij->c_next = P->col[j]->ptr;
283.1235 +         }
283.1236 +         else
283.1237 +            aij = P->col[j]->ptr;
283.1238 +#if 1 /* FIXME */
283.1239 +         if (aij == NULL)
283.1240 +         {  /* empty column */
283.1241 +            empty++;
283.1242 +            xfprintf(fp, "%*s%-*s", csa->deck ? 4 : 1, "",
283.1243 +               csa->deck ? 8 : 1, col_name(csa, j));
283.1244 +            /* we need a row */
283.1245 +            xassert(P->m > 0);
283.1246 +            xfprintf(fp, "%*s%-*s",
283.1247 +               csa->deck ? 2 : 1, "", csa->deck ? 8 : 1,
283.1248 +               row_name(csa, 1));
283.1249 +            xfprintf(fp, "%*s0%*s$ empty column\n",
283.1250 +               csa->deck ? 13 : 1, "", csa->deck ? 3 : 1, ""), recno++;
283.1251 +         }
283.1252 +#endif
283.1253 +         count = 0;
283.1254 +         for (aij = aij; aij != NULL; aij = aij->c_next)
283.1255 +         {  if (one_col || count % 2 == 0)
283.1256 +               xfprintf(fp, "%*s%-*s", csa->deck ? 4 : 1, "",
283.1257 +                  csa->deck ? 8 : 1, col_name(csa, j));
283.1258 +            gap = (one_col || count % 2 == 0 ? 2 : 3);
283.1259 +            xfprintf(fp, "%*s%-*s",
283.1260 +               csa->deck ? gap : 1, "", csa->deck ? 8 : 1,
283.1261 +               row_name(csa, aij->row == NULL ? 0 : aij->row->i));
283.1262 +            xfprintf(fp, "%*s%*s",
283.1263 +               csa->deck ? 2 : 1, "", csa->deck ? 12 : 1,
283.1264 +               mps_numb(csa, aij->val)), count++;
283.1265 +            if (one_col || count % 2 == 0)
283.1266 +               xfprintf(fp, "\n"), recno++;
283.1267 +         }
283.1268 +         if (!(one_col || count % 2 == 0))
283.1269 +            xfprintf(fp, "\n"), recno++;
283.1270 +      }
283.1271 +      if (marker % 2 == 1)
283.1272 +      {  /* close last integer block */
283.1273 +         marker++;
283.1274 +         xfprintf(fp, "%*sM%07d%*s'MARKER'%*s'INTEND'\n",
283.1275 +            csa->deck ? 4 : 1, "", marker, csa->deck ? 2 : 1, "",
283.1276 +            csa->deck ? 17 : 1, ""), recno++;
283.1277 +      }
283.1278 +#if 1
283.1279 +      if (empty > 0)
283.1280 +         xprintf("Warning: problem has %d empty column(s)\n", empty);
283.1281 +#endif
283.1282 +      /* write RHS section */
283.1283 +      xfprintf(fp, "RHS\n"), recno++;
283.1284 +      count = 0;
283.1285 +      for (i = (out_obj ? 0 : 1); i <= P->m; i++)
283.1286 +      {  int type;
283.1287 +         double rhs;
283.1288 +         if (i == 0)
283.1289 +            rhs = P->c0;
283.1290 +         else
283.1291 +         {  type = P->row[i]->type;
283.1292 +            if (type == GLP_FR)
283.1293 +               rhs = 0.0;
283.1294 +            else if (type == GLP_LO)
283.1295 +               rhs = P->row[i]->lb;
283.1296 +            else if (type == GLP_UP)
283.1297 +               rhs = P->row[i]->ub;
283.1298 +            else if (type == GLP_DB || type == GLP_FX)
283.1299 +               rhs = P->row[i]->lb;
283.1300 +            else
283.1301 +               xassert(type != type);
283.1302 +         }
283.1303 +         if (rhs != 0.0)
283.1304 +         {  if (one_col || count % 2 == 0)
283.1305 +               xfprintf(fp, "%*s%-*s", csa->deck ? 4 : 1, "",
283.1306 +                  csa->deck ? 8 : 1, "RHS1");
283.1307 +            gap = (one_col || count % 2 == 0 ? 2 : 3);
283.1308 +            xfprintf(fp, "%*s%-*s",
283.1309 +               csa->deck ? gap : 1, "", csa->deck ? 8 : 1,
283.1310 +               row_name(csa, i));
283.1311 +            xfprintf(fp, "%*s%*s",
283.1312 +               csa->deck ? 2 : 1, "", csa->deck ? 12 : 1,
283.1313 +               mps_numb(csa, rhs)), count++;
283.1314 +            if (one_col || count % 2 == 0)
283.1315 +               xfprintf(fp, "\n"), recno++;
283.1316 +         }
283.1317 +      }
283.1318 +      if (!(one_col || count % 2 == 0))
283.1319 +         xfprintf(fp, "\n"), recno++;
283.1320 +      /* write RANGES section */
283.1321 +      for (i = P->m; i >= 1; i--)
283.1322 +         if (P->row[i]->type == GLP_DB) break;
283.1323 +      if (i == 0) goto bnds;
283.1324 +      xfprintf(fp, "RANGES\n"), recno++;
283.1325 +      count = 0;
283.1326 +      for (i = 1; i <= P->m; i++)
283.1327 +      {  if (P->row[i]->type == GLP_DB)
283.1328 +         {  if (one_col || count % 2 == 0)
283.1329 +               xfprintf(fp, "%*s%-*s", csa->deck ? 4 : 1, "",
283.1330 +                  csa->deck ? 8 : 1, "RNG1");
283.1331 +            gap = (one_col || count % 2 == 0 ? 2 : 3);
283.1332 +            xfprintf(fp, "%*s%-*s",
283.1333 +               csa->deck ? gap : 1, "", csa->deck ? 8 : 1,
283.1334 +               row_name(csa, i));
283.1335 +            xfprintf(fp, "%*s%*s",
283.1336 +               csa->deck ? 2 : 1, "", csa->deck ? 12 : 1,
283.1337 +               mps_numb(csa, P->row[i]->ub - P->row[i]->lb)), count++;
283.1338 +            if (one_col || count % 2 == 0)
283.1339 +               xfprintf(fp, "\n"), recno++;
283.1340 +         }
283.1341 +      }
283.1342 +      if (!(one_col || count % 2 == 0))
283.1343 +         xfprintf(fp, "\n"), recno++;
283.1344 +bnds: /* write BOUNDS section */
283.1345 +      for (j = P->n; j >= 1; j--)
283.1346 +         if (!(P->col[j]->type == GLP_LO && P->col[j]->lb == 0.0))
283.1347 +            break;
283.1348 +      if (j == 0) goto endt;
283.1349 +      xfprintf(fp, "BOUNDS\n"), recno++;
283.1350 +      for (j = 1; j <= P->n; j++)
283.1351 +      {  int type, data[2];
283.1352 +         double bnd[2];
283.1353 +         char *spec[2];
283.1354 +         spec[0] = spec[1] = NULL;
283.1355 +         type = P->col[j]->type;
283.1356 +         if (type == GLP_FR)
283.1357 +            spec[0] = "FR", data[0] = 0;
283.1358 +         else if (type == GLP_LO)
283.1359 +         {  if (P->col[j]->lb != 0.0)
283.1360 +               spec[0] = "LO", data[0] = 1, bnd[0] = P->col[j]->lb;
283.1361 +            if (P->col[j]->kind == GLP_IV)
283.1362 +               spec[1] = "PL", data[1] = 0;
283.1363 +         }
283.1364 +         else if (type == GLP_UP)
283.1365 +         {  spec[0] = "MI", data[0] = 0;
283.1366 +            spec[1] = "UP", data[1] = 1, bnd[1] = P->col[j]->ub;
283.1367 +         }
283.1368 +         else if (type == GLP_DB)
283.1369 +         {  if (P->col[j]->lb != 0.0)
283.1370 +               spec[0] = "LO", data[0] = 1, bnd[0] = P->col[j]->lb;
283.1371 +            spec[1] = "UP", data[1] = 1, bnd[1] = P->col[j]->ub;
283.1372 +         }
283.1373 +         else if (type == GLP_FX)
283.1374 +            spec[0] = "FX", data[0] = 1, bnd[0] = P->col[j]->lb;
283.1375 +         else
283.1376 +            xassert(type != type);
283.1377 +         for (i = 0; i <= 1; i++)
283.1378 +         {  if (spec[i] != NULL)
283.1379 +            {  xfprintf(fp, " %s %-*s%*s%-*s", spec[i],
283.1380 +                  csa->deck ? 8 : 1, "BND1", csa->deck ? 2 : 1, "",
283.1381 +                  csa->deck ? 8 : 1, col_name(csa, j));
283.1382 +               if (data[i])
283.1383 +                  xfprintf(fp, "%*s%*s", csa->deck ? 2 : 1, "",
283.1384 +                     csa->deck ? 12 : 1, mps_numb(csa, bnd[i]));
283.1385 +               xfprintf(fp, "\n"), recno++;
283.1386 +            }
283.1387 +         }
283.1388 +      }
283.1389 +endt: /* write ENDATA indicator record */
283.1390 +      xfprintf(fp, "ENDATA\n"), recno++;
283.1391 +      xfflush(fp);
283.1392 +      if (xferror(fp))
283.1393 +      {  xprintf("Write error on `%s' - %s\n", fname, xerrmsg());
283.1394 +         ret = 1;
283.1395 +         goto done;
283.1396 +      }
283.1397 +      /* problem data has been successfully written */
283.1398 +      xprintf("%d records were written\n", recno);
283.1399 +      ret = 0;
283.1400 +done: if (fp != NULL) xfclose(fp);
283.1401 +      return ret;
283.1402 +}
283.1403 +
283.1404 +/* eof */
   284.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
   284.2 +++ b/deps/glpk/src/glpnet.h	Sun Nov 06 20:59:10 2011 +0100
   284.3 @@ -0,0 +1,60 @@
   284.4 +/* glpnet.h (graph and network algorithms) */
   284.5 +
   284.6 +/***********************************************************************
   284.7 +*  This code is part of GLPK (GNU Linear Programming Kit).
   284.8 +*
   284.9 +*  Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008,
  284.10 +*  2009, 2010, 2011 Andrew Makhorin, Department for Applied Informatics,
  284.11 +*  Moscow Aviation Institute, Moscow, Russia. All rights reserved.
  284.12 +*  E-mail: <mao@gnu.org>.
  284.13 +*
  284.14 +*  GLPK is free software: you can redistribute it and/or modify it
  284.15 +*  under the terms of the GNU General Public License as published by
  284.16 +*  the Free Software Foundation, either version 3 of the License, or
  284.17 +*  (at your option) any later version.
  284.18 +*
  284.19 +*  GLPK is distributed in the hope that it will be useful, but WITHOUT
  284.20 +*  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
  284.21 +*  or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
  284.22 +*  License for more details.
  284.23 +*
  284.24 +*  You should have received a copy of the GNU General Public License
  284.25 +*  along with GLPK. If not, see <http://www.gnu.org/licenses/>.
  284.26 +***********************************************************************/
  284.27 +
  284.28 +#ifndef GLPNET_H
  284.29 +#define GLPNET_H
  284.30 +
  284.31 +#define mc21a _glp_mc21a
  284.32 +int mc21a(int n, const int icn[], const int ip[], const int lenr[],
  284.33 +      int iperm[], int pr[], int arp[], int cv[], int out[]);
  284.34 +/* permutations for zero-free diagonal */
  284.35 +
  284.36 +#define mc13d _glp_mc13d
  284.37 +int mc13d(int n, const int icn[], const int ip[], const int lenr[],
  284.38 +      int ior[], int ib[], int lowl[], int numb[], int prev[]);
  284.39 +/* permutations to block triangular form */
  284.40 +
  284.41 +#define okalg _glp_okalg
  284.42 +int okalg(int nv, int na, const int tail[], const int head[],
  284.43 +      const int low[], const int cap[], const int cost[], int x[],
  284.44 +      int pi[]);
  284.45 +/* out-of-kilter algorithm */
  284.46 +
  284.47 +#define ffalg _glp_ffalg
  284.48 +void ffalg(int nv, int na, const int tail[], const int head[],
  284.49 +      int s, int t, const int cap[], int x[], char cut[]);
  284.50 +/* Ford-Fulkerson algorithm */
  284.51 +
  284.52 +#define wclique _glp_wclique
  284.53 +int wclique(int n, const int w[], const unsigned char a[], int ind[]);
  284.54 +/* find maximum weight clique with Ostergard's algorithm */
  284.55 +
  284.56 +#define kellerman _glp_kellerman
  284.57 +int kellerman(int n, int (*func)(void *info, int i, int ind[]),
  284.58 +      void *info, void /* glp_graph */ *H);
  284.59 +/* cover edges by cliques with Kellerman's heuristic */
  284.60 +
  284.61 +#endif
  284.62 +
  284.63 +/* eof */
   285.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
   285.2 +++ b/deps/glpk/src/glpnet01.c	Sun Nov 06 20:59:10 2011 +0100
   285.3 @@ -0,0 +1,301 @@
   285.4 +/* glpnet01.c (permutations for zero-free diagonal) */
   285.5 +
   285.6 +/***********************************************************************
   285.7 +*  This code is part of GLPK (GNU Linear Programming Kit).
   285.8 +*
   285.9 +*  This code is the result of translation of the Fortran subroutines
  285.10 +*  MC21A and MC21B associated with the following paper:
  285.11 +*
  285.12 +*  I.S.Duff, Algorithm 575: Permutations for zero-free diagonal, ACM
  285.13 +*  Trans. on Math. Softw. 7 (1981), 387-390.
  285.14 +*
  285.15 +*  Use of ACM Algorithms is subject to the ACM Software Copyright and
  285.16 +*  License Agreement. See <http://www.acm.org/publications/policies>.
  285.17 +*
  285.18 +*  The translation was made by Andrew Makhorin <mao@gnu.org>.
  285.19 +*
  285.20 +*  GLPK is free software: you can redistribute it and/or modify it
  285.21 +*  under the terms of the GNU General Public License as published by
  285.22 +*  the Free Software Foundation, either version 3 of the License, or
  285.23 +*  (at your option) any later version.
  285.24 +*
  285.25 +*  GLPK is distributed in the hope that it will be useful, but WITHOUT
  285.26 +*  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
  285.27 +*  or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
  285.28 +*  License for more details.
  285.29 +*
  285.30 +*  You should have received a copy of the GNU General Public License
  285.31 +*  along with GLPK. If not, see <http://www.gnu.org/licenses/>.
  285.32 +***********************************************************************/
  285.33 +
  285.34 +#include "glpnet.h"
  285.35 +
  285.36 +/***********************************************************************
  285.37 +*  NAME
  285.38 +*
  285.39 +*  mc21a - permutations for zero-free diagonal
  285.40 +*
  285.41 +*  SYNOPSIS
  285.42 +*
  285.43 +*  #include "glpnet.h"
  285.44 +*  int mc21a(int n, const int icn[], const int ip[], const int lenr[],
  285.45 +*     int iperm[], int pr[], int arp[], int cv[], int out[]);
  285.46 +*
  285.47 +*  DESCRIPTION
  285.48 +*
  285.49 +*  Given the pattern of nonzeros of a sparse matrix, the routine mc21a
  285.50 +*  attempts to find a permutation of its rows that makes the matrix have
  285.51 +*  no zeros on its diagonal.
  285.52 +*
  285.53 +*  INPUT PARAMETERS
  285.54 +*
  285.55 +*  n     order of matrix.
  285.56 +*
  285.57 +*  icn   array containing the column indices of the non-zeros. Those
  285.58 +*        belonging to a single row must be contiguous but the ordering
  285.59 +*        of column indices within each row is unimportant and wasted
  285.60 +*        space between rows is permitted.
  285.61 +*
  285.62 +*  ip    ip[i], i = 1,2,...,n, is the position in array icn of the
  285.63 +*        first column index of a non-zero in row i.
  285.64 +*
  285.65 +*  lenr  lenr[i], i = 1,2,...,n, is the number of non-zeros in row i.
  285.66 +*
  285.67 +*  OUTPUT PARAMETER
  285.68 +*
  285.69 +*  iperm contains permutation to make diagonal have the smallest
  285.70 +*        number of zeros on it. Elements (iperm[i], i), i = 1,2,...,n,
  285.71 +*        are non-zero at the end of the algorithm unless the matrix is
  285.72 +*        structurally singular. In this case, (iperm[i], i) will be
  285.73 +*        zero for n - numnz entries.
  285.74 +*
  285.75 +*  WORKING ARRAYS
  285.76 +*
  285.77 +*  pr    working array of length [1+n], where pr[0] is not used.
  285.78 +*        pr[i] is the previous row to i in the depth first search.
  285.79 +*
  285.80 +*  arp   working array of length [1+n], where arp[0] is not used.
  285.81 +*        arp[i] is one less than the number of non-zeros in row i which
  285.82 +*        have not been scanned when looking for a cheap assignment.
  285.83 +*
  285.84 +*  cv    working array of length [1+n], where cv[0] is not used.
  285.85 +*        cv[i] is the most recent row extension at which column i was
  285.86 +*        visited.
  285.87 +*
  285.88 +*  out   working array of length [1+n], where out[0] is not used.
  285.89 +*        out[i] is one less than the number of non-zeros in row i
  285.90 +*        which have not been scanned during one pass through the main
  285.91 +*        loop.
  285.92 +*
  285.93 +*  RETURNS
  285.94 +*
  285.95 +*  The routine mc21a returns numnz, the number of non-zeros on diagonal
  285.96 +*  of permuted matrix. */
  285.97 +
  285.98 +int mc21a(int n, const int icn[], const int ip[], const int lenr[],
  285.99 +      int iperm[], int pr[], int arp[], int cv[], int out[])
 285.100 +{     int i, ii, in1, in2, j, j1, jord, k, kk, numnz;
 285.101 +      /* Initialization of arrays. */
 285.102 +      for (i = 1; i <= n; i++)
 285.103 +      {  arp[i] = lenr[i] - 1;
 285.104 +         cv[i] = iperm[i] = 0;
 285.105 +      }
 285.106 +      numnz = 0;
 285.107 +      /* Main loop. */
 285.108 +      /* Each pass round this loop either results in a new assignment
 285.109 +         or gives a row with no assignment. */
 285.110 +      for (jord = 1; jord <= n; jord++)
 285.111 +      {  j = jord;
 285.112 +         pr[j] = -1;
 285.113 +         for (k = 1; k <= jord; k++)
 285.114 +         {  /* Look for a cheap assignment. */
 285.115 +            in1 = arp[j];
 285.116 +            if (in1 >= 0)
 285.117 +            {  in2 = ip[j] + lenr[j] - 1;
 285.118 +               in1 = in2 - in1;
 285.119 +               for (ii = in1; ii <= in2; ii++)
 285.120 +               {  i = icn[ii];
 285.121 +                  if (iperm[i] == 0) goto L110;
 285.122 +               }
 285.123 +               /* No cheap assignment in row. */
 285.124 +               arp[j] = -1;
 285.125 +            }
 285.126 +            /* Begin looking for assignment chain starting with row j.*/
 285.127 +            out[j] = lenr[j] - 1;
 285.128 +            /* Inner loop. Extends chain by one or backtracks. */
 285.129 +            for (kk = 1; kk <= jord; kk++)
 285.130 +            {  in1 = out[j];
 285.131 +               if (in1 >= 0)
 285.132 +               {  in2 = ip[j] + lenr[j] - 1;
 285.133 +                  in1 = in2 - in1;
 285.134 +                  /* Forward scan. */
 285.135 +                  for (ii = in1; ii <= in2; ii++)
 285.136 +                  {  i = icn[ii];
 285.137 +                     if (cv[i] != jord)
 285.138 +                     {  /* Column i has not yet been accessed during
 285.139 +                           this pass. */
 285.140 +                        j1 = j;
 285.141 +                        j = iperm[i];
 285.142 +                        cv[i] = jord;
 285.143 +                        pr[j] = j1;
 285.144 +                        out[j1] = in2 - ii - 1;
 285.145 +                        goto L100;
 285.146 +                     }
 285.147 +                  }
 285.148 +               }
 285.149 +               /* Backtracking step. */
 285.150 +               j = pr[j];
 285.151 +               if (j == -1) goto L130;
 285.152 +            }
 285.153 +L100:       ;
 285.154 +         }
 285.155 +L110:    /* New assignment is made. */
 285.156 +         iperm[i] = j;
 285.157 +         arp[j] = in2 - ii - 1;
 285.158 +         numnz++;
 285.159 +         for (k = 1; k <= jord; k++)
 285.160 +         {  j = pr[j];
 285.161 +            if (j == -1) break;
 285.162 +            ii = ip[j] + lenr[j] - out[j] - 2;
 285.163 +            i = icn[ii];
 285.164 +            iperm[i] = j;
 285.165 +         }
 285.166 +L130:    ;
 285.167 +      }
 285.168 +      /* If matrix is structurally singular, we now complete the
 285.169 +         permutation iperm. */
 285.170 +      if (numnz < n)
 285.171 +      {  for (i = 1; i <= n; i++)
 285.172 +            arp[i] = 0;
 285.173 +         k = 0;
 285.174 +         for (i = 1; i <= n; i++)
 285.175 +         {  if (iperm[i] == 0)
 285.176 +               out[++k] = i;
 285.177 +            else
 285.178 +               arp[iperm[i]] = i;
 285.179 +         }
 285.180 +         k = 0;
 285.181 +         for (i = 1; i <= n; i++)
 285.182 +         {  if (arp[i] == 0)
 285.183 +               iperm[out[++k]] = i;
 285.184 +         }
 285.185 +      }
 285.186 +      return numnz;
 285.187 +}
 285.188 +
 285.189 +/**********************************************************************/
 285.190 +
 285.191 +#if 0
 285.192 +#include "glplib.h"
 285.193 +
 285.194 +int sing;
 285.195 +
 285.196 +void ranmat(int m, int n, int icn[], int iptr[], int nnnp1, int *knum,
 285.197 +      int iw[]);
 285.198 +
 285.199 +void fa01bs(int max, int *nrand);
 285.200 +
 285.201 +int main(void)
 285.202 +{     /* test program for the routine mc21a */
 285.203 +      /* these runs on random matrices cause all possible statements in
 285.204 +         mc21a to be executed */
 285.205 +      int i, iold, j, j1, j2, jj, knum, l, licn, n, nov4, num, numnz;
 285.206 +      int ip[1+21], icn[1+1000], iperm[1+20], lenr[1+20], iw1[1+80];
 285.207 +      licn = 1000;
 285.208 +      /* run on random matrices of orders 1 through 20 */
 285.209 +      for (n = 1; n <= 20; n++)
 285.210 +      {  nov4 = n / 4;
 285.211 +         if (nov4 < 1) nov4 = 1;
 285.212 +L10:     fa01bs(nov4, &l);
 285.213 +         knum = l * n;
 285.214 +         /* knum is requested number of non-zeros in random matrix */
 285.215 +         if (knum > licn) goto L10;
 285.216 +         /* if sing is false, matrix is guaranteed structurally
 285.217 +            non-singular */
 285.218 +         sing = ((n / 2) * 2 == n);
 285.219 +         /* call to subroutine to generate random matrix */
 285.220 +         ranmat(n, n, icn, ip, n+1, &knum, iw1);
 285.221 +         /* knum is now actual number of non-zeros in random matrix */
 285.222 +         if (knum > licn) goto L10;
 285.223 +         xprintf("n = %2d; nz = %4d; sing = %d\n", n, knum, sing);
 285.224 +         /* set up array of row lengths */
 285.225 +         for (i = 1; i <= n; i++)
 285.226 +            lenr[i] = ip[i+1] - ip[i];
 285.227 +         /* call to mc21a */
 285.228 +         numnz = mc21a(n, icn, ip, lenr, iperm, &iw1[0], &iw1[n],
 285.229 +            &iw1[n+n], &iw1[n+n+n]);
 285.230 +         /* testing to see if there are numnz non-zeros on the diagonal
 285.231 +            of the permuted matrix. */
 285.232 +         num = 0;
 285.233 +         for (i = 1; i <= n; i++)
 285.234 +         {  iold = iperm[i];
 285.235 +            j1 = ip[iold];
 285.236 +            j2 = j1 + lenr[iold] - 1;
 285.237 +            if (j2 < j1) continue;
 285.238 +            for (jj = j1; jj <= j2; jj++)
 285.239 +            {  j = icn[jj];
 285.240 +               if (j == i)
 285.241 +               {  num++;
 285.242 +                  break;
 285.243 +               }
 285.244 +            }
 285.245 +         }
 285.246 +         if (num != numnz)
 285.247 +            xprintf("Failure in mc21a, numnz = %d instead of %d\n",
 285.248 +               numnz, num);
 285.249 +      }
 285.250 +      return 0;
 285.251 +}
 285.252 +
 285.253 +void ranmat(int m, int n, int icn[], int iptr[], int nnnp1, int *knum,
 285.254 +      int iw[])
 285.255 +{     /* subroutine to generate random matrix */
 285.256 +      int i, ii, inum, j, lrow, matnum;
 285.257 +      inum = (*knum / n) * 2;
 285.258 +      if (inum > n-1) inum = n-1;
 285.259 +      matnum = 1;
 285.260 +      /* each pass through this loop generates a row of the matrix */
 285.261 +      for (j = 1; j <= m; j++)
 285.262 +      {  iptr[j] = matnum;
 285.263 +         if (!(sing || j > n))
 285.264 +            icn[matnum++] = j;
 285.265 +         if (n == 1) continue;
 285.266 +         for (i = 1; i <= n; i++) iw[i] = 0;
 285.267 +         if (!sing) iw[j] = 1;
 285.268 +         fa01bs(inum, &lrow);
 285.269 +         lrow--;
 285.270 +         if (lrow == 0) continue;
 285.271 +         /* lrow off-diagonal non-zeros in row j of the matrix */
 285.272 +         for (ii = 1; ii <= lrow; ii++)
 285.273 +         {  for (;;)
 285.274 +            {  fa01bs(n, &i);
 285.275 +               if (iw[i] != 1) break;
 285.276 +            }
 285.277 +            iw[i] = 1;
 285.278 +            icn[matnum++] = i;
 285.279 +         }
 285.280 +      }
 285.281 +      for (i = m+1; i <= nnnp1; i++)
 285.282 +         iptr[i] = matnum;
 285.283 +      *knum = matnum - 1;
 285.284 +      return;
 285.285 +}
 285.286 +
 285.287 +double g = 1431655765.0;
 285.288 +
 285.289 +double fa01as(int i)
 285.290 +{     /* random number generator */
 285.291 +      g = fmod(g * 9228907.0, 4294967296.0);
 285.292 +      if (i >= 0)
 285.293 +         return g / 4294967296.0;
 285.294 +      else
 285.295 +         return 2.0 * g / 4294967296.0 - 1.0;
 285.296 +}
 285.297 +
 285.298 +void fa01bs(int max, int *nrand)
 285.299 +{     *nrand = (int)(fa01as(1) * (double)max) + 1;
 285.300 +      return;
 285.301 +}
 285.302 +#endif
 285.303 +
 285.304 +/* eof */
   286.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
   286.2 +++ b/deps/glpk/src/glpnet02.c	Sun Nov 06 20:59:10 2011 +0100
   286.3 @@ -0,0 +1,314 @@
   286.4 +/* glpnet02.c (permutations to block triangular form) */
   286.5 +
   286.6 +/***********************************************************************
   286.7 +*  This code is part of GLPK (GNU Linear Programming Kit).
   286.8 +*
   286.9 +*  This code is the result of translation of the Fortran subroutines
  286.10 +*  MC13D and MC13E associated with the following paper:
  286.11 +*
  286.12 +*  I.S.Duff, J.K.Reid, Algorithm 529: Permutations to block triangular
  286.13 +*  form, ACM Trans. on Math. Softw. 4 (1978), 189-192.
  286.14 +*
  286.15 +*  Use of ACM Algorithms is subject to the ACM Software Copyright and
  286.16 +*  License Agreement. See <http://www.acm.org/publications/policies>.
  286.17 +*
  286.18 +*  The translation was made by Andrew Makhorin <mao@gnu.org>.
  286.19 +*
  286.20 +*  GLPK is free software: you can redistribute it and/or modify it
  286.21 +*  under the terms of the GNU General Public License as published by
  286.22 +*  the Free Software Foundation, either version 3 of the License, or
  286.23 +*  (at your option) any later version.
  286.24 +*
  286.25 +*  GLPK is distributed in the hope that it will be useful, but WITHOUT
  286.26 +*  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
  286.27 +*  or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
  286.28 +*  License for more details.
  286.29 +*
  286.30 +*  You should have received a copy of the GNU General Public License
  286.31 +*  along with GLPK. If not, see <http://www.gnu.org/licenses/>.
  286.32 +***********************************************************************/
  286.33 +
  286.34 +#include "glpnet.h"
  286.35 +
  286.36 +/***********************************************************************
  286.37 +*  NAME
  286.38 +*
  286.39 +*  mc13d - permutations to block triangular form
  286.40 +*
  286.41 +*  SYNOPSIS
  286.42 +*
  286.43 +*  #include "glpnet.h"
  286.44 +*  int mc13d(int n, const int icn[], const int ip[], const int lenr[],
  286.45 +*     int ior[], int ib[], int lowl[], int numb[], int prev[]);
  286.46 +*
  286.47 +*  DESCRIPTION
  286.48 +*
  286.49 +*  Given the column numbers of the nonzeros in each row of the sparse
  286.50 +*  matrix, the routine mc13d finds a symmetric permutation that makes
  286.51 +*  the matrix block lower triangular.
  286.52 +*
  286.53 +*  INPUT PARAMETERS
  286.54 +*
  286.55 +*  n     order of the matrix.
  286.56 +*
  286.57 +*  icn   array containing the column indices of the non-zeros. Those
  286.58 +*        belonging to a single row must be contiguous but the ordering
  286.59 +*        of column indices within each row is unimportant and wasted
  286.60 +*        space between rows is permitted.
  286.61 +*
  286.62 +*  ip    ip[i], i = 1,2,...,n, is the position in array icn of the
  286.63 +*        first column index of a non-zero in row i.
  286.64 +*
  286.65 +*  lenr  lenr[i], i = 1,2,...,n, is the number of non-zeros in row i.
  286.66 +*
  286.67 +*  OUTPUT PARAMETERS
  286.68 +*
  286.69 +*  ior   ior[i], i = 1,2,...,n, gives the position on the original
  286.70 +*        ordering of the row or column which is in position i in the
  286.71 +*        permuted form.
  286.72 +*
  286.73 +*  ib    ib[i], i = 1,2,...,num, is the row number in the permuted
  286.74 +*        matrix of the beginning of block i, 1 <= num <= n.
  286.75 +*
  286.76 +*  WORKING ARRAYS
  286.77 +*
  286.78 +*  arp   working array of length [1+n], where arp[0] is not used.
  286.79 +*        arp[i] is one less than the number of unsearched edges leaving
  286.80 +*        node i. At the end of the algorithm it is set to a permutation
  286.81 +*        which puts the matrix in block lower triangular form.
  286.82 +*
  286.83 +*  ib    working array of length [1+n], where ib[0] is not used.
  286.84 +*        ib[i] is the position in the ordering of the start of the ith
  286.85 +*        block. ib[n+1-i] holds the node number of the ith node on the
  286.86 +*        stack.
  286.87 +*
  286.88 +*  lowl  working array of length [1+n], where lowl[0] is not used.
  286.89 +*        lowl[i] is the smallest stack position of any node to which a
  286.90 +*        path from node i has been found. It is set to n+1 when node i
  286.91 +*        is removed from the stack.
  286.92 +*
  286.93 +*  numb  working array of length [1+n], where numb[0] is not used.
  286.94 +*        numb[i] is the position of node i in the stack if it is on it,
  286.95 +*        is the permuted order of node i for those nodes whose final
  286.96 +*        position has been found and is otherwise zero.
  286.97 +*
  286.98 +*  prev  working array of length [1+n], where prev[0] is not used.
  286.99 +*        prev[i] is the node at the end of the path when node i was
 286.100 +*        placed on the stack.
 286.101 +*
 286.102 +*  RETURNS
 286.103 +*
 286.104 +*  The routine mc13d returns num, the number of blocks found. */
 286.105 +
 286.106 +int mc13d(int n, const int icn[], const int ip[], const int lenr[],
 286.107 +      int ior[], int ib[], int lowl[], int numb[], int prev[])
 286.108 +{     int *arp = ior;
 286.109 +      int dummy, i, i1, i2, icnt, ii, isn, ist, ist1, iv, iw, j, lcnt,
 286.110 +         nnm1, num, stp;
 286.111 +      /* icnt is the number of nodes whose positions in final ordering
 286.112 +         have been found. */
 286.113 +      icnt = 0;
 286.114 +      /* num is the number of blocks that have been found. */
 286.115 +      num = 0;
 286.116 +      nnm1 = n + n - 1;
 286.117 +      /* Initialization of arrays. */
 286.118 +      for (j = 1; j <= n; j++)
 286.119 +      {  numb[j] = 0;
 286.120 +         arp[j] = lenr[j] - 1;
 286.121 +      }
 286.122 +      for (isn = 1; isn <= n; isn++)
 286.123 +      {  /* Look for a starting node. */
 286.124 +         if (numb[isn] != 0) continue;
 286.125 +         iv = isn;
 286.126 +         /* ist is the number of nodes on the stack ... it is the stack
 286.127 +            pointer. */
 286.128 +         ist = 1;
 286.129 +         /* Put node iv at beginning of stack. */
 286.130 +         lowl[iv] = numb[iv] = 1;
 286.131 +         ib[n] = iv;
 286.132 +         /* The body of this loop puts a new node on the stack or
 286.133 +            backtracks. */
 286.134 +         for (dummy = 1; dummy <= nnm1; dummy++)
 286.135 +         {  i1 = arp[iv];
 286.136 +            /* Have all edges leaving node iv been searched? */
 286.137 +            if (i1 >= 0)
 286.138 +            {  i2 = ip[iv] + lenr[iv] - 1;
 286.139 +               i1 = i2 - i1;
 286.140 +               /* Look at edges leaving node iv until one enters a new
 286.141 +                  node or all edges are exhausted. */
 286.142 +               for (ii = i1; ii <= i2; ii++)
 286.143 +               {  iw = icn[ii];
 286.144 +                  /* Has node iw been on stack already? */
 286.145 +                  if (numb[iw] == 0) goto L70;
 286.146 +                  /* Update value of lowl[iv] if necessary. */
 286.147 +                  if (lowl[iw] < lowl[iv]) lowl[iv] = lowl[iw];
 286.148 +               }
 286.149 +               /* There are no more edges leaving node iv. */
 286.150 +               arp[iv] = -1;
 286.151 +            }
 286.152 +            /* Is node iv the root of a block? */
 286.153 +            if (lowl[iv] < numb[iv]) goto L60;
 286.154 +            /* Order nodes in a block. */
 286.155 +            num++;
 286.156 +            ist1 = n + 1 - ist;
 286.157 +            lcnt = icnt + 1;
 286.158 +            /* Peel block off the top of the stack starting at the top
 286.159 +               and working down to the root of the block. */
 286.160 +            for (stp = ist1; stp <= n; stp++)
 286.161 +            {  iw = ib[stp];
 286.162 +               lowl[iw] = n + 1;
 286.163 +               numb[iw] = ++icnt;
 286.164 +               if (iw == iv) break;
 286.165 +            }
 286.166 +            ist = n - stp;
 286.167 +            ib[num] = lcnt;
 286.168 +            /* Are there any nodes left on the stack? */
 286.169 +            if (ist != 0) goto L60;
 286.170 +            /* Have all the nodes been ordered? */
 286.171 +            if (icnt < n) break;
 286.172 +            goto L100;
 286.173 +L60:        /* Backtrack to previous node on path. */
 286.174 +            iw = iv;
 286.175 +            iv = prev[iv];
 286.176 +            /* Update value of lowl[iv] if necessary. */
 286.177 +            if (lowl[iw] < lowl[iv]) lowl[iv] = lowl[iw];
 286.178 +            continue;
 286.179 +L70:        /* Put new node on the stack. */
 286.180 +            arp[iv] = i2 - ii - 1;
 286.181 +            prev[iw] = iv;
 286.182 +            iv = iw;
 286.183 +            lowl[iv] = numb[iv] = ++ist;
 286.184 +            ib[n+1-ist] = iv;
 286.185 +         }
 286.186 +      }
 286.187 +L100: /* Put permutation in the required form. */
 286.188 +      for (i = 1; i <= n; i++)
 286.189 +         arp[numb[i]] = i;
 286.190 +      return num;
 286.191 +}
 286.192 +
 286.193 +/**********************************************************************/
 286.194 +
 286.195 +#if 0
 286.196 +#include "glplib.h"
 286.197 +
 286.198 +void test(int n, int ipp);
 286.199 +
 286.200 +int main(void)
 286.201 +{     /* test program for routine mc13d */
 286.202 +      test( 1,   0);
 286.203 +      test( 2,   1);
 286.204 +      test( 2,   2);
 286.205 +      test( 3,   3);
 286.206 +      test( 4,   4);
 286.207 +      test( 5,  10);
 286.208 +      test(10,  10);
 286.209 +      test(10,  20);
 286.210 +      test(20,  20);
 286.211 +      test(20,  50);
 286.212 +      test(50,  50);
 286.213 +      test(50, 200);
 286.214 +      return 0;
 286.215 +}
 286.216 +
 286.217 +void fa01bs(int max, int *nrand);
 286.218 +
 286.219 +void setup(int n, char a[1+50][1+50], int ip[], int icn[], int lenr[]);
 286.220 +
 286.221 +void test(int n, int ipp)
 286.222 +{     int ip[1+50], icn[1+1000], ior[1+50], ib[1+51], iw[1+150],
 286.223 +         lenr[1+50];
 286.224 +      char a[1+50][1+50], hold[1+100];
 286.225 +      int i, ii, iblock, ij, index, j, jblock, jj, k9, num;
 286.226 +      xprintf("\n\n\nMatrix is of order %d and has %d off-diagonal non-"
 286.227 +         "zeros\n", n, ipp);
 286.228 +      for (j = 1; j <= n; j++)
 286.229 +      {  for (i = 1; i <= n; i++)
 286.230 +            a[i][j] = 0;
 286.231 +         a[j][j] = 1;
 286.232 +      }
 286.233 +      for (k9 = 1; k9 <= ipp; k9++)
 286.234 +      {  /* these statements should be replaced by calls to your
 286.235 +            favorite random number generator to place two pseudo-random
 286.236 +            numbers between 1 and n in the variables i and j */
 286.237 +         for (;;)
 286.238 +         {  fa01bs(n, &i);
 286.239 +            fa01bs(n, &j);
 286.240 +            if (!a[i][j]) break;
 286.241 +         }
 286.242 +         a[i][j] = 1;
 286.243 +      }
 286.244 +      /* setup converts matrix a[i,j] to required sparsity-oriented
 286.245 +         storage format */
 286.246 +      setup(n, a, ip, icn, lenr);
 286.247 +      num = mc13d(n, icn, ip, lenr, ior, ib, &iw[0], &iw[n], &iw[n+n]);
 286.248 +      /* output reordered matrix with blocking to improve clarity */
 286.249 +      xprintf("\nThe reordered matrix which has %d block%s is of the fo"
 286.250 +         "rm\n", num, num == 1 ? "" : "s");
 286.251 +      ib[num+1] = n + 1;
 286.252 +      index = 100;
 286.253 +      iblock = 1;
 286.254 +      for (i = 1; i <= n; i++)
 286.255 +      {  for (ij = 1; ij <= index; ij++)
 286.256 +            hold[ij] = ' ';
 286.257 +         if (i == ib[iblock])
 286.258 +         {  xprintf("\n");
 286.259 +            iblock++;
 286.260 +         }
 286.261 +         jblock = 1;
 286.262 +         index = 0;
 286.263 +         for (j = 1; j <= n; j++)
 286.264 +         {  if (j == ib[jblock])
 286.265 +            {  hold[++index] = ' ';
 286.266 +               jblock++;
 286.267 +            }
 286.268 +            ii = ior[i];
 286.269 +            jj = ior[j];
 286.270 +            hold[++index] = (char)(a[ii][jj] ? 'X' : '0');
 286.271 +         }
 286.272 +         xprintf("%.*s\n", index, &hold[1]);
 286.273 +      }
 286.274 +      xprintf("\nThe starting point for each block is given by\n");
 286.275 +      for (i = 1; i <= num; i++)
 286.276 +      {  if ((i - 1) % 12 == 0) xprintf("\n");
 286.277 +         xprintf(" %4d", ib[i]);
 286.278 +      }
 286.279 +      xprintf("\n");
 286.280 +      return;
 286.281 +}
 286.282 +
 286.283 +void setup(int n, char a[1+50][1+50], int ip[], int icn[], int lenr[])
 286.284 +{     int i, j, ind;
 286.285 +      for (i = 1; i <= n; i++)
 286.286 +         lenr[i] = 0;
 286.287 +      ind = 1;
 286.288 +      for (i = 1; i <= n; i++)
 286.289 +      {  ip[i] = ind;
 286.290 +         for (j = 1; j <= n; j++)
 286.291 +         {  if (a[i][j])
 286.292 +            {  lenr[i]++;
 286.293 +               icn[ind++] = j;
 286.294 +            }
 286.295 +         }
 286.296 +      }
 286.297 +      return;
 286.298 +}
 286.299 +
 286.300 +double g = 1431655765.0;
 286.301 +
 286.302 +double fa01as(int i)
 286.303 +{     /* random number generator */
 286.304 +      g = fmod(g * 9228907.0, 4294967296.0);
 286.305 +      if (i >= 0)
 286.306 +         return g / 4294967296.0;
 286.307 +      else
 286.308 +         return 2.0 * g / 4294967296.0 - 1.0;
 286.309 +}
 286.310 +
 286.311 +void fa01bs(int max, int *nrand)
 286.312 +{     *nrand = (int)(fa01as(1) * (double)max) + 1;
 286.313 +      return;
 286.314 +}
 286.315 +#endif
 286.316 +
 286.317 +/* eof */
   287.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
   287.2 +++ b/deps/glpk/src/glpnet03.c	Sun Nov 06 20:59:10 2011 +0100
   287.3 @@ -0,0 +1,776 @@
   287.4 +/* glpnet03.c (Klingman's network problem generator) */
   287.5 +
   287.6 +/***********************************************************************
   287.7 +*  This code is part of GLPK (GNU Linear Programming Kit).
   287.8 +*
   287.9 +*  This code is the result of translation of the Fortran program NETGEN
  287.10 +*  developed by Dr. Darwin Klingman, which is publically available from
  287.11 +*  NETLIB at <http://www.netlib.org/lp/generators>.
  287.12 +*
  287.13 +*  The translation was made by Andrew Makhorin <mao@gnu.org>.
  287.14 +*
  287.15 +*  GLPK is free software: you can redistribute it and/or modify it
  287.16 +*  under the terms of the GNU General Public License as published by
  287.17 +*  the Free Software Foundation, either version 3 of the License, or
  287.18 +*  (at your option) any later version.
  287.19 +*
  287.20 +*  GLPK is distributed in the hope that it will be useful, but WITHOUT
  287.21 +*  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
  287.22 +*  or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
  287.23 +*  License for more details.
  287.24 +*
  287.25 +*  You should have received a copy of the GNU General Public License
  287.26 +*  along with GLPK. If not, see <http://www.gnu.org/licenses/>.
  287.27 +***********************************************************************/
  287.28 +
  287.29 +#include "glpapi.h"
  287.30 +
  287.31 +/***********************************************************************
  287.32 +*  NAME
  287.33 +*
  287.34 +*  glp_netgen - Klingman's network problem generator
  287.35 +*
  287.36 +*  SYNOPSIS
  287.37 +*
  287.38 +*  int glp_netgen(glp_graph *G, int v_rhs, int a_cap, int a_cost,
  287.39 +*     const int parm[1+15]);
  287.40 +*
  287.41 +*  DESCRIPTION
  287.42 +*
  287.43 +*  The routine glp_netgen is a network problem generator developed by
  287.44 +*  Dr. Darwin Klingman. It can create capacitated and uncapacitated
  287.45 +*  minimum cost flow (or transshipment), transportation, and assignment
  287.46 +*  problems.
  287.47 +*
  287.48 +*  The parameter G specifies the graph object, to which the generated
  287.49 +*  problem data have to be stored. Note that on entry the graph object
  287.50 +*  is erased with the routine glp_erase_graph.
  287.51 +*
  287.52 +*  The parameter v_rhs specifies an offset of the field of type double
  287.53 +*  in the vertex data block, to which the routine stores the supply or
  287.54 +*  demand value. If v_rhs < 0, the value is not stored.
  287.55 +*
  287.56 +*  The parameter a_cap specifies an offset of the field of type double
  287.57 +*  in the arc data block, to which the routine stores the arc capacity.
  287.58 +*  If a_cap < 0, the capacity is not stored.
  287.59 +*
  287.60 +*  The parameter a_cost specifies an offset of the field of type double
  287.61 +*  in the arc data block, to which the routine stores the per-unit cost
  287.62 +*  if the arc flow. If a_cost < 0, the cost is not stored.
  287.63 +*
  287.64 +*  The array parm contains description of the network to be generated:
  287.65 +*
  287.66 +*  parm[0]           not used
  287.67 +*  parm[1]  (iseed)  8-digit positive random number seed
  287.68 +*  parm[2]  (nprob)  8-digit problem id number
  287.69 +*  parm[3]  (nodes)  total number of nodes
  287.70 +*  parm[4]  (nsorc)  total number of source nodes (including
  287.71 +*                    transshipment nodes)
  287.72 +*  parm[5]  (nsink)  total number of sink nodes (including
  287.73 +*                    transshipment nodes)
  287.74 +*  parm[6]  (iarcs)  number of arcs
  287.75 +*  parm[7]  (mincst) minimum cost for arcs
  287.76 +*  parm[8]  (maxcst) maximum cost for arcs
  287.77 +*  parm[9]  (itsup)  total supply
  287.78 +*  parm[10] (ntsorc) number of transshipment source nodes
  287.79 +*  parm[11] (ntsink) number of transshipment sink nodes
  287.80 +*  parm[12] (iphic)  percentage of skeleton arcs to be given
  287.81 +*                    the maximum cost
  287.82 +*  parm[13] (ipcap)  percentage of arcs to be capacitated
  287.83 +*  parm[14] (mincap) minimum upper bound for capacitated arcs
  287.84 +*  parm[15] (maxcap) maximum upper bound for capacitated arcs
  287.85 +*
  287.86 +*  The routine generates a transportation problem if:
  287.87 +*
  287.88 +*     nsorc + nsink = nodes, ntsorc = 0, and ntsink = 0.
  287.89 +*
  287.90 +*  The routine generates an assignment problem if the requirements for
  287.91 +*  a transportation problem are met and:
  287.92 +*
  287.93 +*     nsorc = nsink and itsup = nsorc.
  287.94 +*
  287.95 +*  RETURNS
  287.96 +*
  287.97 +*  If the instance was successfully generated, the routine glp_netgen
  287.98 +*  returns zero; otherwise, if specified parameters are inconsistent,
  287.99 +*  the routine returns a non-zero error code.
 287.100 +*
 287.101 +*  REFERENCES
 287.102 +*
 287.103 +*  D.Klingman, A.Napier, and J.Stutz. NETGEN: A program for generating
 287.104 +*  large scale capacitated assignment, transportation, and minimum cost
 287.105 +*  flow networks. Management Science 20 (1974), 814-20. */
 287.106 +
 287.107 +struct csa
 287.108 +{     /* common storage area */
 287.109 +      glp_graph *G;
 287.110 +      int v_rhs, a_cap, a_cost;
 287.111 +      int nodes, iarcs, mincst, maxcst, itsup, nsorc, nsink, nonsor,
 287.112 +         nfsink, narcs, nsort, nftsor, ipcap, mincap, maxcap, ktl,
 287.113 +         nodlft, *ipred, *ihead, *itail, *iflag, *isup, *lsinks, mult,
 287.114 +         modul, i15, i16, jran;
 287.115 +};
 287.116 +
 287.117 +#define G      (csa->G)
 287.118 +#define v_rhs  (csa->v_rhs)
 287.119 +#define a_cap  (csa->a_cap)
 287.120 +#define a_cost (csa->a_cost)
 287.121 +#define nodes  (csa->nodes)
 287.122 +#define iarcs  (csa->iarcs)
 287.123 +#define mincst (csa->mincst)
 287.124 +#define maxcst (csa->maxcst)
 287.125 +#define itsup  (csa->itsup)
 287.126 +#define nsorc  (csa->nsorc)
 287.127 +#define nsink  (csa->nsink)
 287.128 +#define nonsor (csa->nonsor)
 287.129 +#define nfsink (csa->nfsink)
 287.130 +#define narcs  (csa->narcs)
 287.131 +#define nsort  (csa->nsort)
 287.132 +#define nftsor (csa->nftsor)
 287.133 +#define ipcap  (csa->ipcap)
 287.134 +#define mincap (csa->mincap)
 287.135 +#define maxcap (csa->maxcap)
 287.136 +#define ktl    (csa->ktl)
 287.137 +#define nodlft (csa->nodlft)
 287.138 +#if 0
 287.139 +/* spent a day to find out this bug */
 287.140 +#define ist    (csa->ist)
 287.141 +#else
 287.142 +#define ist    (ipred[0])
 287.143 +#endif
 287.144 +#define ipred  (csa->ipred)
 287.145 +#define ihead  (csa->ihead)
 287.146 +#define itail  (csa->itail)
 287.147 +#define iflag  (csa->iflag)
 287.148 +#define isup   (csa->isup)
 287.149 +#define lsinks (csa->lsinks)
 287.150 +#define mult   (csa->mult)
 287.151 +#define modul  (csa->modul)
 287.152 +#define i15    (csa->i15)
 287.153 +#define i16    (csa->i16)
 287.154 +#define jran   (csa->jran)
 287.155 +
 287.156 +static void cresup(struct csa *csa);
 287.157 +static void chain(struct csa *csa, int lpick, int lsorc);
 287.158 +static void chnarc(struct csa *csa, int lsorc);
 287.159 +static void sort(struct csa *csa);
 287.160 +static void pickj(struct csa *csa, int it);
 287.161 +static void assign(struct csa *csa);
 287.162 +static void setran(struct csa *csa, int iseed);
 287.163 +static int iran(struct csa *csa, int ilow, int ihigh);
 287.164 +
 287.165 +int glp_netgen(glp_graph *G_, int _v_rhs, int _a_cap, int _a_cost,
 287.166 +      const int parm[1+15])
 287.167 +{     struct csa _csa, *csa = &_csa;
 287.168 +      int iseed, nprob, ntsorc, ntsink, iphic, i, nskel, nltr, ltsink,
 287.169 +         ntrans, npsink, nftr, npsorc, ntravl, ntrrem, lsorc, lpick,
 287.170 +         nsksr, nsrchn, j, item, l, ks, k, ksp, li, n, ii, it, ih, icap,
 287.171 +         jcap, icost, jcost, ret;
 287.172 +      G = G_;
 287.173 +      v_rhs = _v_rhs;
 287.174 +      a_cap = _a_cap;
 287.175 +      a_cost = _a_cost;
 287.176 +      if (G != NULL)
 287.177 +      {  if (v_rhs >= 0 && v_rhs > G->v_size - (int)sizeof(double))
 287.178 +            xerror("glp_netgen: v_rhs = %d; invalid offset\n", v_rhs);
 287.179 +         if (a_cap >= 0 && a_cap > G->a_size - (int)sizeof(double))
 287.180 +            xerror("glp_netgen: a_cap = %d; invalid offset\n", a_cap);
 287.181 +         if (a_cost >= 0 && a_cost > G->a_size - (int)sizeof(double))
 287.182 +            xerror("glp_netgen: a_cost = %d; invalid offset\n", a_cost);
 287.183 +      }
 287.184 +      /* Input the user's random number seed and fix it if
 287.185 +         non-positive. */
 287.186 +      iseed = parm[1];
 287.187 +      nprob = parm[2];
 287.188 +      if (iseed <= 0) iseed = 13502460;
 287.189 +      setran(csa, iseed);
 287.190 +      /* Input the user's problem characteristics. */
 287.191 +      nodes = parm[3];
 287.192 +      nsorc = parm[4];
 287.193 +      nsink = parm[5];
 287.194 +      iarcs = parm[6];
 287.195 +      mincst = parm[7];
 287.196 +      maxcst = parm[8];
 287.197 +      itsup = parm[9];
 287.198 +      ntsorc = parm[10];
 287.199 +      ntsink = parm[11];
 287.200 +      iphic = parm[12];
 287.201 +      ipcap = parm[13];
 287.202 +      mincap = parm[14];
 287.203 +      maxcap = parm[15];
 287.204 +      /* Check the size of the problem. */
 287.205 +      if (!(10 <= nodes && nodes <= 100000))
 287.206 +      {  ret = 1;
 287.207 +         goto done;
 287.208 +      }
 287.209 +      /* Check user supplied parameters for consistency. */
 287.210 +      if (!(nsorc >= 0 && nsink >= 0 && nsorc + nsink <= nodes))
 287.211 +      {  ret = 2;
 287.212 +         goto done;
 287.213 +      }
 287.214 +      if (iarcs < 0)
 287.215 +      {  ret = 3;
 287.216 +         goto done;
 287.217 +      }
 287.218 +      if (mincst > maxcst)
 287.219 +      {  ret = 4;
 287.220 +         goto done;
 287.221 +      }
 287.222 +      if (itsup < 0)
 287.223 +      {  ret = 5;
 287.224 +         goto done;
 287.225 +      }
 287.226 +      if (!(0 <= ntsorc && ntsorc <= nsorc))
 287.227 +      {  ret = 6;
 287.228 +         goto done;
 287.229 +      }
 287.230 +      if (!(0 <= ntsink && ntsink <= nsink))
 287.231 +      {  ret = 7;
 287.232 +         goto done;
 287.233 +      }
 287.234 +      if (!(0 <= iphic && iphic <= 100))
 287.235 +      {  ret = 8;
 287.236 +         goto done;
 287.237 +      }
 287.238 +      if (!(0 <= ipcap && ipcap <= 100))
 287.239 +      {  ret = 9;
 287.240 +         goto done;
 287.241 +      }
 287.242 +      if (mincap > maxcap)
 287.243 +      {  ret = 10;
 287.244 +         goto done;
 287.245 +      }
 287.246 +      /* Initailize the graph object. */
 287.247 +      if (G != NULL)
 287.248 +      {  glp_erase_graph(G, G->v_size, G->a_size);
 287.249 +         glp_add_vertices(G, nodes);
 287.250 +         if (v_rhs >= 0)
 287.251 +         {  double zero = 0.0;
 287.252 +            for (i = 1; i <= nodes; i++)
 287.253 +            {  glp_vertex *v = G->v[i];
 287.254 +               memcpy((char *)v->data + v_rhs, &zero, sizeof(double));
 287.255 +            }
 287.256 +         }
 287.257 +      }
 287.258 +      /* Allocate working arrays. */
 287.259 +      ipred = xcalloc(1+nodes, sizeof(int));
 287.260 +      ihead = xcalloc(1+nodes, sizeof(int));
 287.261 +      itail = xcalloc(1+nodes, sizeof(int));
 287.262 +      iflag = xcalloc(1+nodes, sizeof(int));
 287.263 +      isup = xcalloc(1+nodes, sizeof(int));
 287.264 +      lsinks = xcalloc(1+nodes, sizeof(int));
 287.265 +      /* Print the problem documentation records. */
 287.266 +      if (G == NULL)
 287.267 +      {  xprintf("BEGIN\n");
 287.268 +         xprintf("NETGEN PROBLEM%8d%10s%10d NODES AND%10d ARCS\n",
 287.269 +            nprob, "", nodes, iarcs);
 287.270 +         xprintf("USER:%11d%11d%11d%11d%11d%11d\nDATA:%11d%11d%11d%11d%"
 287.271 +            "11d%11d\n", iseed, nsorc, nsink, mincst,
 287.272 +            maxcst, itsup, ntsorc, ntsink, iphic, ipcap,
 287.273 +            mincap, maxcap);
 287.274 +      }
 287.275 +      else
 287.276 +         glp_set_graph_name(G, "NETGEN");
 287.277 +      /* Set various constants used in the program. */
 287.278 +      narcs = 0;
 287.279 +      nskel = 0;
 287.280 +      nltr = nodes - nsink;
 287.281 +      ltsink = nltr + ntsink;
 287.282 +      ntrans = nltr - nsorc;
 287.283 +      nfsink = nltr + 1;
 287.284 +      nonsor = nodes - nsorc + ntsorc;
 287.285 +      npsink = nsink - ntsink;
 287.286 +      nodlft = nodes - nsink + ntsink;
 287.287 +      nftr = nsorc + 1;
 287.288 +      nftsor = nsorc - ntsorc + 1;
 287.289 +      npsorc = nsorc - ntsorc;
 287.290 +      /* Randomly distribute the supply among the source nodes. */
 287.291 +      if (npsorc + npsink == nodes && npsorc == npsink &&
 287.292 +          itsup == nsorc)
 287.293 +      {  assign(csa);
 287.294 +         nskel = nsorc;
 287.295 +         goto L390;
 287.296 +      }
 287.297 +      cresup(csa);
 287.298 +      /* Print the supply records. */
 287.299 +      if (G == NULL)
 287.300 +      {  xprintf("SUPPLY\n");
 287.301 +         for (i = 1; i <= nsorc; i++)
 287.302 +            xprintf("%6s%6d%18s%10d\n", "", i, "", isup[i]);
 287.303 +         xprintf("ARCS\n");
 287.304 +      }
 287.305 +      else
 287.306 +      {  if (v_rhs >= 0)
 287.307 +         {  for (i = 1; i <= nsorc; i++)
 287.308 +            {  double temp = (double)isup[i];
 287.309 +               glp_vertex *v = G->v[i];
 287.310 +               memcpy((char *)v->data + v_rhs, &temp, sizeof(double));
 287.311 +            }
 287.312 +         }
 287.313 +      }
 287.314 +      /* Make the sources point to themselves in ipred array. */
 287.315 +      for (i = 1; i <= nsorc; i++)
 287.316 +         ipred[i] = i;
 287.317 +      if (ntrans == 0) goto L170;
 287.318 +      /* Chain the transshipment nodes together in the ipred array. */
 287.319 +      ist = nftr;
 287.320 +      ipred[nltr] = 0;
 287.321 +      for (i = nftr; i < nltr; i++)
 287.322 +         ipred[i] = i+1;
 287.323 +      /* Form even length chains for 60 percent of the transshipments.*/
 287.324 +      ntravl = 6 * ntrans / 10;
 287.325 +      ntrrem = ntrans - ntravl;
 287.326 +L140: lsorc = 1;
 287.327 +      while (ntravl != 0)
 287.328 +      {  lpick = iran(csa, 1, ntravl + ntrrem);
 287.329 +         ntravl--;
 287.330 +         chain(csa, lpick, lsorc);
 287.331 +         if (lsorc == nsorc) goto L140;
 287.332 +         lsorc++;
 287.333 +      }
 287.334 +      /* Add the remaining transshipments to the chains. */
 287.335 +      while (ntrrem != 0)
 287.336 +      {
 287.337 +         lpick = iran(csa, 1, ntrrem);
 287.338 +         ntrrem--;
 287.339 +         lsorc = iran(csa, 1, nsorc);
 287.340 +         chain(csa, lpick, lsorc);
 287.341 +      }
 287.342 +L170: /* Set all demands equal to zero. */
 287.343 +      for (i = nfsink; i <= nodes; i++)
 287.344 +         ipred[i] = 0;
 287.345 +      /* The following loop takes one chain at a time (through the use
 287.346 +         of logic contained in the loop and calls to other routines) and
 287.347 +         creates the remaining network arcs. */
 287.348 +      for (lsorc = 1; lsorc <= nsorc; lsorc++)
 287.349 +      {  chnarc(csa, lsorc);
 287.350 +         for (i = nfsink; i <= nodes; i++)
 287.351 +            iflag[i] = 0;
 287.352 +         /* Choose the number of sinks to be hooked up to the current
 287.353 +            chain. */
 287.354 +         if (ntrans != 0)
 287.355 +            nsksr = (nsort * 2 * nsink) / ntrans;
 287.356 +         else
 287.357 +            nsksr = nsink / nsorc + 1;
 287.358 +         if (nsksr < 2) nsksr = 2;
 287.359 +         if (nsksr > nsink) nsksr = nsink;
 287.360 +         nsrchn = nsort;
 287.361 +         /* Randomly pick nsksr sinks and put their names in lsinks. */
 287.362 +         ktl = nsink;
 287.363 +         for (j = 1; j <= nsksr; j++)
 287.364 +         {  item = iran(csa, 1, ktl);
 287.365 +            ktl--;
 287.366 +            for (l = nfsink; l <= nodes; l++)
 287.367 +            {  if (iflag[l] != 1)
 287.368 +               {  item--;
 287.369 +                  if (item == 0) goto L230;
 287.370 +               }
 287.371 +            }
 287.372 +            break;
 287.373 +L230:       lsinks[j] = l;
 287.374 +            iflag[l] = 1;
 287.375 +         }
 287.376 +         /* If last source chain, add all sinks with zero demand to
 287.377 +            lsinks list. */
 287.378 +         if (lsorc == nsorc)
 287.379 +         {  for (j = nfsink; j <= nodes; j++)
 287.380 +            {  if (ipred[j] == 0 && iflag[j] != 1)
 287.381 +               {  nsksr++;
 287.382 +                  lsinks[nsksr] = j;
 287.383 +                  iflag[j] = 1;
 287.384 +               }
 287.385 +            }
 287.386 +         }
 287.387 +         /* Create demands for group of sinks in lsinks. */
 287.388 +         ks = isup[lsorc] / nsksr;
 287.389 +         k = ipred[lsorc];
 287.390 +         for (i = 1; i <= nsksr; i++)
 287.391 +         {  nsort++;
 287.392 +            ksp = iran(csa, 1, ks);
 287.393 +            j = iran(csa, 1, nsksr);
 287.394 +            itail[nsort] = k;
 287.395 +            li = lsinks[i];
 287.396 +            ihead[nsort] = li;
 287.397 +            ipred[li] += ksp;
 287.398 +            li = lsinks[j];
 287.399 +            ipred[li] += ks - ksp;
 287.400 +            n = iran(csa, 1, nsrchn);
 287.401 +            k = lsorc;
 287.402 +            for (ii = 1; ii <= n; ii++)
 287.403 +               k = ipred[k];
 287.404 +         }
 287.405 +         li = lsinks[1];
 287.406 +         ipred[li] += isup[lsorc] - ks * nsksr;
 287.407 +         nskel += nsort;
 287.408 +         /* Sort the arcs in the chain from source lsorc using itail as
 287.409 +            sort key. */
 287.410 +         sort(csa);
 287.411 +         /* Print this part of skeleton and create the arcs for these
 287.412 +            nodes. */
 287.413 +         i = 1;
 287.414 +         itail[nsort+1] = 0;
 287.415 +L300:    for (j = nftsor; j <= nodes; j++)
 287.416 +            iflag[j] = 0;
 287.417 +         ktl = nonsor - 1;
 287.418 +         it = itail[i];
 287.419 +         iflag[it] = 1;
 287.420 +L320:    ih = ihead[i];
 287.421 +         iflag[ih] = 1;
 287.422 +         narcs++;
 287.423 +         ktl--;
 287.424 +         /* Determine if this skeleton arc should be capacitated. */
 287.425 +         icap = itsup;
 287.426 +         jcap = iran(csa, 1, 100);
 287.427 +         if (jcap <= ipcap)
 287.428 +         {  icap = isup[lsorc];
 287.429 +            if (mincap > icap) icap = mincap;
 287.430 +         }
 287.431 +         /* Determine if this skeleton arc should have the maximum
 287.432 +            cost. */
 287.433 +         icost = maxcst;
 287.434 +         jcost = iran(csa, 1, 100);
 287.435 +         if (jcost > iphic)
 287.436 +            icost = iran(csa, mincst, maxcst);
 287.437 +         if (G == NULL)
 287.438 +            xprintf("%6s%6d%6d%2s%10d%10d\n", "", it, ih, "", icost,
 287.439 +               icap);
 287.440 +         else
 287.441 +         {  glp_arc *a = glp_add_arc(G, it, ih);
 287.442 +            if (a_cap >= 0)
 287.443 +            {  double temp = (double)icap;
 287.444 +               memcpy((char *)a->data + a_cap, &temp, sizeof(double));
 287.445 +            }
 287.446 +            if (a_cost >= 0)
 287.447 +            {  double temp = (double)icost;
 287.448 +               memcpy((char *)a->data + a_cost, &temp, sizeof(double));
 287.449 +            }
 287.450 +         }
 287.451 +         i++;
 287.452 +         if (itail[i] == it) goto L320;
 287.453 +         pickj(csa, it);
 287.454 +         if (i <= nsort) goto L300;
 287.455 +      }
 287.456 +      /* Create arcs from the transshipment sinks. */
 287.457 +      if (ntsink != 0)
 287.458 +      {  for (i = nfsink; i <= ltsink; i++)
 287.459 +         {  for (j = nftsor; j <= nodes; j++)
 287.460 +               iflag[j] = 0;
 287.461 +            ktl = nonsor - 1;
 287.462 +            iflag[i] = 1;
 287.463 +            pickj(csa, i);
 287.464 +         }
 287.465 +      }
 287.466 +L390: /* Print the demand records and end record. */
 287.467 +      if (G == NULL)
 287.468 +      {  xprintf("DEMAND\n");
 287.469 +         for (i = nfsink; i <= nodes; i++)
 287.470 +            xprintf("%6s%6d%18s%10d\n", "", i, "", ipred[i]);
 287.471 +         xprintf("END\n");
 287.472 +      }
 287.473 +      else
 287.474 +      {  if (v_rhs >= 0)
 287.475 +         {  for (i = nfsink; i <= nodes; i++)
 287.476 +            {  double temp = - (double)ipred[i];
 287.477 +               glp_vertex *v = G->v[i];
 287.478 +               memcpy((char *)v->data + v_rhs, &temp, sizeof(double));
 287.479 +            }
 287.480 +         }
 287.481 +      }
 287.482 +      /* Free working arrays. */
 287.483 +      xfree(ipred);
 287.484 +      xfree(ihead);
 287.485 +      xfree(itail);
 287.486 +      xfree(iflag);
 287.487 +      xfree(isup);
 287.488 +      xfree(lsinks);
 287.489 +      /* The instance has been successfully generated. */
 287.490 +      ret = 0;
 287.491 +done: return ret;
 287.492 +}
 287.493 +
 287.494 +/***********************************************************************
 287.495 +*  The routine cresup randomly distributes the total supply among the
 287.496 +*  source nodes. */
 287.497 +
 287.498 +static void cresup(struct csa *csa)
 287.499 +{     int i, j, ks, ksp;
 287.500 +      xassert(itsup > nsorc);
 287.501 +      ks = itsup / nsorc;
 287.502 +      for (i = 1; i <= nsorc; i++)
 287.503 +         isup[i] = 0;
 287.504 +      for (i = 1; i <= nsorc; i++)
 287.505 +      {  ksp = iran(csa, 1, ks);
 287.506 +         j = iran(csa, 1, nsorc);
 287.507 +         isup[i] += ksp;
 287.508 +         isup[j] += ks - ksp;
 287.509 +      }
 287.510 +      j = iran(csa, 1, nsorc);
 287.511 +      isup[j] += itsup - ks * nsorc;
 287.512 +      return;
 287.513 +}
 287.514 +
 287.515 +/***********************************************************************
 287.516 +*  The routine chain adds node lpick to the end of the chain with source
 287.517 +*  node lsorc. */
 287.518 +
 287.519 +static void chain(struct csa *csa, int lpick, int lsorc)
 287.520 +{     int i, j, k, l, m;
 287.521 +      k = 0;
 287.522 +      m = ist;
 287.523 +      for (i = 1; i <= lpick; i++)
 287.524 +      {  l = k;
 287.525 +         k = m;
 287.526 +         m = ipred[k];
 287.527 +      }
 287.528 +      ipred[l] = m;
 287.529 +      j = ipred[lsorc];
 287.530 +      ipred[k] = j;
 287.531 +      ipred[lsorc] = k;
 287.532 +      return;
 287.533 +}
 287.534 +
 287.535 +/***********************************************************************
 287.536 +*  The routine chnarc puts the arcs in the chain from source lsorc into
 287.537 +*  the ihead and itail arrays for sorting. */
 287.538 +
 287.539 +static void chnarc(struct csa *csa, int lsorc)
 287.540 +{     int ito, ifrom;
 287.541 +      nsort = 0;
 287.542 +      ito = ipred[lsorc];
 287.543 +L10:  if (ito == lsorc) return;
 287.544 +      nsort++;
 287.545 +      ifrom = ipred[ito];
 287.546 +      ihead[nsort] = ito;
 287.547 +      itail[nsort] = ifrom;
 287.548 +      ito = ifrom;
 287.549 +      goto L10;
 287.550 +}
 287.551 +
 287.552 +/***********************************************************************
 287.553 +*  The routine sort sorts the nsort arcs in the ihead and itail arrays.
 287.554 +*  ihead is used as the sort key (i.e. forward star sort order). */
 287.555 +
 287.556 +static void sort(struct csa *csa)
 287.557 +{     int i, j, k, l, m, n, it;
 287.558 +      n = nsort;
 287.559 +      m = n;
 287.560 +L10:  m /= 2;
 287.561 +      if (m == 0) return;
 287.562 +      k = n - m;
 287.563 +      j = 1;
 287.564 +L20:  i = j;
 287.565 +L30:  l = i + m;
 287.566 +      if (itail[i] <= itail[l]) goto L40;
 287.567 +      it = itail[i];
 287.568 +      itail[i] = itail[l];
 287.569 +      itail[l] = it;
 287.570 +      it = ihead[i];
 287.571 +      ihead[i] = ihead[l];
 287.572 +      ihead[l] = it;
 287.573 +      i -= m;
 287.574 +      if (i >= 1) goto L30;
 287.575 +L40:  j++;
 287.576 +      if (j <= k) goto L20;
 287.577 +      goto L10;
 287.578 +}
 287.579 +
 287.580 +/***********************************************************************
 287.581 +*  The routine pickj creates a random number of arcs out of node 'it'.
 287.582 +*  Various parameters are dynamically adjusted in an attempt to ensure
 287.583 +*  that the generated network has the correct number of arcs. */
 287.584 +
 287.585 +static void pickj(struct csa *csa, int it)
 287.586 +{     int j, k, l, nn, nupbnd, icap, jcap, icost;
 287.587 +      if ((nodlft - 1) * 2 > iarcs - narcs - 1)
 287.588 +      {  nodlft--;
 287.589 +         return;
 287.590 +      }
 287.591 +      if ((iarcs - narcs + nonsor - ktl - 1) / nodlft - nonsor + 1 >= 0)
 287.592 +         k = nonsor;
 287.593 +      else
 287.594 +      {  nupbnd = (iarcs - narcs - nodlft) / nodlft * 2;
 287.595 +L40:     k = iran(csa, 1, nupbnd);
 287.596 +         if (nodlft == 1) k = iarcs - narcs;
 287.597 +         if ((nodlft - 1) * (nonsor - 1) < iarcs - narcs - k) goto L40;
 287.598 +      }
 287.599 +      nodlft--;
 287.600 +      for (j = 1; j <= k; j++)
 287.601 +      {  nn = iran(csa, 1, ktl);
 287.602 +         ktl--;
 287.603 +         for (l = nftsor; l <= nodes; l++)
 287.604 +         {  if (iflag[l] != 1)
 287.605 +            {  nn--;
 287.606 +               if (nn == 0) goto L70;
 287.607 +            }
 287.608 +         }
 287.609 +         return;
 287.610 +L70:     iflag[l] = 1;
 287.611 +         icap = itsup;
 287.612 +         jcap = iran(csa, 1, 100);
 287.613 +         if (jcap <= ipcap)
 287.614 +            icap = iran(csa, mincap, maxcap);
 287.615 +         icost = iran(csa, mincst, maxcst);
 287.616 +         if (G == NULL)
 287.617 +            xprintf("%6s%6d%6d%2s%10d%10d\n", "", it, l, "", icost,
 287.618 +               icap);
 287.619 +         else
 287.620 +         {  glp_arc *a = glp_add_arc(G, it, l);
 287.621 +            if (a_cap >= 0)
 287.622 +            {  double temp = (double)icap;
 287.623 +               memcpy((char *)a->data + a_cap, &temp, sizeof(double));
 287.624 +            }
 287.625 +            if (a_cost >= 0)
 287.626 +            {  double temp = (double)icost;
 287.627 +               memcpy((char *)a->data + a_cost, &temp, sizeof(double));
 287.628 +            }
 287.629 +         }
 287.630 +         narcs++;
 287.631 +      }
 287.632 +      return;
 287.633 +}
 287.634 +
 287.635 +/***********************************************************************
 287.636 +*  The routine assign generate assignment problems. It defines the unit
 287.637 +*  supplies, builds a skeleton, then calls pickj to create the arcs. */
 287.638 +
 287.639 +static void assign(struct csa *csa)
 287.640 +{     int i, it, nn, l, ll, icost;
 287.641 +      if (G == NULL)
 287.642 +         xprintf("SUPPLY\n");
 287.643 +      for (i = 1; i <= nsorc; i++)
 287.644 +      {  isup[i] = 1;
 287.645 +         iflag[i] = 0;
 287.646 +         if (G == NULL)
 287.647 +            xprintf("%6s%6d%18s%10d\n", "", i, "", isup[i]);
 287.648 +         else
 287.649 +         {  if (v_rhs >= 0)
 287.650 +            {  double temp = (double)isup[i];
 287.651 +               glp_vertex *v = G->v[i];
 287.652 +               memcpy((char *)v->data + v_rhs, &temp, sizeof(double));
 287.653 +            }
 287.654 +         }
 287.655 +      }
 287.656 +      if (G == NULL)
 287.657 +         xprintf("ARCS\n");
 287.658 +      for (i = nfsink; i <= nodes; i++)
 287.659 +         ipred[i] = 1;
 287.660 +      for (it = 1; it <= nsorc; it++)
 287.661 +      {  for (i = nfsink; i <= nodes; i++)
 287.662 +            iflag[i] = 0;
 287.663 +         ktl = nsink - 1;
 287.664 +         nn = iran(csa, 1, nsink - it + 1);
 287.665 +         for (l = 1; l <= nsorc; l++)
 287.666 +         {  if (iflag[l] != 1)
 287.667 +            {  nn--;
 287.668 +               if (nn == 0) break;
 287.669 +            }
 287.670 +         }
 287.671 +         narcs++;
 287.672 +         ll = nsorc + l;
 287.673 +         icost = iran(csa, mincst, maxcst);
 287.674 +         if (G == NULL)
 287.675 +            xprintf("%6s%6d%6d%2s%10d%10d\n", "", it, ll, "", icost,
 287.676 +               isup[1]);
 287.677 +         else
 287.678 +         {  glp_arc *a = glp_add_arc(G, it, ll);
 287.679 +            if (a_cap >= 0)
 287.680 +            {  double temp = (double)isup[1];
 287.681 +               memcpy((char *)a->data + a_cap, &temp, sizeof(double));
 287.682 +            }
 287.683 +            if (a_cost >= 0)
 287.684 +            {  double temp = (double)icost;
 287.685 +               memcpy((char *)a->data + a_cost, &temp, sizeof(double));
 287.686 +            }
 287.687 +         }
 287.688 +         iflag[l] = 1;
 287.689 +         iflag[ll] = 1;
 287.690 +         pickj(csa, it);
 287.691 +      }
 287.692 +      return;
 287.693 +}
 287.694 +
 287.695 +/***********************************************************************
 287.696 +*  Portable congruential (uniform) random number generator:
 287.697 +*
 287.698 +*     next_value = ((7**5) * previous_value) modulo ((2**31)-1)
 287.699 +*
 287.700 +*  This generator consists of three routines:
 287.701 +*
 287.702 +*  (1) setran - initializes constants and seed
 287.703 +*  (2) iran   - generates an integer random number
 287.704 +*  (3) rran   - generates a real random number
 287.705 +*
 287.706 +*  The generator requires a machine with at least 32 bits of precision.
 287.707 +*  The seed (iseed) must be in the range [1,(2**31)-1]. */
 287.708 +
 287.709 +static void setran(struct csa *csa, int iseed)
 287.710 +{     xassert(iseed >= 1);
 287.711 +      mult = 16807;
 287.712 +      modul = 2147483647;
 287.713 +      i15 = 1 << 15;
 287.714 +      i16 = 1 << 16;
 287.715 +      jran = iseed;
 287.716 +      return;
 287.717 +}
 287.718 +
 287.719 +/***********************************************************************
 287.720 +*  The routine iran generates an integer random number between ilow and
 287.721 +*  ihigh. If ilow > ihigh then iran returns ihigh. */
 287.722 +
 287.723 +static int iran(struct csa *csa, int ilow, int ihigh)
 287.724 +{     int ixhi, ixlo, ixalo, leftlo, ixahi, ifulhi, irtlo, iover,
 287.725 +         irthi, j;
 287.726 +      ixhi = jran / i16;
 287.727 +      ixlo = jran - ixhi * i16;
 287.728 +      ixalo = ixlo * mult;
 287.729 +      leftlo = ixalo / i16;
 287.730 +      ixahi = ixhi * mult;
 287.731 +      ifulhi = ixahi + leftlo;
 287.732 +      irtlo = ixalo - leftlo * i16;
 287.733 +      iover = ifulhi / i15;
 287.734 +      irthi = ifulhi - iover * i15;
 287.735 +      jran = ((irtlo - modul) + irthi * i16) + iover;
 287.736 +      if (jran < 0) jran += modul;
 287.737 +      j = ihigh - ilow + 1;
 287.738 +      if (j > 0)
 287.739 +         return jran % j + ilow;
 287.740 +      else
 287.741 +         return ihigh;
 287.742 +}
 287.743 +
 287.744 +/**********************************************************************/
 287.745 +
 287.746 +#if 0
 287.747 +static int scan(char card[80+1], int pos, int len)
 287.748 +{     char buf[10+1];
 287.749 +      memcpy(buf, &card[pos-1], len);
 287.750 +      buf[len] = '\0';
 287.751 +      return atoi(buf);
 287.752 +}
 287.753 +
 287.754 +int main(void)
 287.755 +{     int parm[1+15];
 287.756 +      char card[80+1];
 287.757 +      xassert(fgets(card, sizeof(card), stdin) == card);
 287.758 +      parm[1] = scan(card, 1, 8);
 287.759 +      parm[2] = scan(card, 9, 8);
 287.760 +      xassert(fgets(card, sizeof(card), stdin) == card);
 287.761 +      parm[3] = scan(card, 1, 5);
 287.762 +      parm[4] = scan(card, 6, 5);
 287.763 +      parm[5] = scan(card, 11, 5);
 287.764 +      parm[6] = scan(card, 16, 5);
 287.765 +      parm[7] = scan(card, 21, 5);
 287.766 +      parm[8] = scan(card, 26, 5);
 287.767 +      parm[9] = scan(card, 31, 10);
 287.768 +      parm[10] = scan(card, 41, 5);
 287.769 +      parm[11] = scan(card, 46, 5);
 287.770 +      parm[12] = scan(card, 51, 5);
 287.771 +      parm[13] = scan(card, 56, 5);
 287.772 +      parm[14] = scan(card, 61, 10);
 287.773 +      parm[15] = scan(card, 71, 10);
 287.774 +      glp_netgen(NULL, 0, 0, 0, parm);
 287.775 +      return 0;
 287.776 +}
 287.777 +#endif
 287.778 +
 287.779 +/* eof */
   288.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
   288.2 +++ b/deps/glpk/src/glpnet04.c	Sun Nov 06 20:59:10 2011 +0100
   288.3 @@ -0,0 +1,768 @@
   288.4 +/* glpnet04.c (grid-like network problem generator) */
   288.5 +
   288.6 +/***********************************************************************
   288.7 +*  This code is part of GLPK (GNU Linear Programming Kit).
   288.8 +*
   288.9 +*  This code is a modified version of the program GRIDGEN, a grid-like
  288.10 +*  network problem generator developed by Yusin Lee and Jim Orlin.
  288.11 +*  The original code is publically available on the DIMACS ftp site at:
  288.12 +*  <ftp://dimacs.rutgers.edu/pub/netflow/generators/network/gridgen>.
  288.13 +*
  288.14 +*  All changes concern only the program interface, so this modified
  288.15 +*  version produces exactly the same instances as the original version.
  288.16 +*
  288.17 +*  Changes were made by Andrew Makhorin <mao@gnu.org>.
  288.18 +*
  288.19 +*  GLPK is free software: you can redistribute it and/or modify it
  288.20 +*  under the terms of the GNU General Public License as published by
  288.21 +*  the Free Software Foundation, either version 3 of the License, or
  288.22 +*  (at your option) any later version.
  288.23 +*
  288.24 +*  GLPK is distributed in the hope that it will be useful, but WITHOUT
  288.25 +*  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
  288.26 +*  or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
  288.27 +*  License for more details.
  288.28 +*
  288.29 +*  You should have received a copy of the GNU General Public License
  288.30 +*  along with GLPK. If not, see <http://www.gnu.org/licenses/>.
  288.31 +***********************************************************************/
  288.32 +
  288.33 +#include "glpapi.h"
  288.34 +
  288.35 +/***********************************************************************
  288.36 +*  NAME
  288.37 +*
  288.38 +*  glp_gridgen - grid-like network problem generator
  288.39 +*
  288.40 +*  SYNOPSIS
  288.41 +*
  288.42 +*  int glp_gridgen(glp_graph *G, int v_rhs, int a_cap, int a_cost,
  288.43 +*     const int parm[1+14]);
  288.44 +*
  288.45 +*  DESCRIPTION
  288.46 +*
  288.47 +*  The routine glp_gridgen is a grid-like network problem generator
  288.48 +*  developed by Yusin Lee and Jim Orlin.
  288.49 +*
  288.50 +*  The parameter G specifies the graph object, to which the generated
  288.51 +*  problem data have to be stored. Note that on entry the graph object
  288.52 +*  is erased with the routine glp_erase_graph.
  288.53 +*
  288.54 +*  The parameter v_rhs specifies an offset of the field of type double
  288.55 +*  in the vertex data block, to which the routine stores the supply or
  288.56 +*  demand value. If v_rhs < 0, the value is not stored.
  288.57 +*
  288.58 +*  The parameter a_cap specifies an offset of the field of type double
  288.59 +*  in the arc data block, to which the routine stores the arc capacity.
  288.60 +*  If a_cap < 0, the capacity is not stored.
  288.61 +*
  288.62 +*  The parameter a_cost specifies an offset of the field of type double
  288.63 +*  in the arc data block, to which the routine stores the per-unit cost
  288.64 +*  if the arc flow. If a_cost < 0, the cost is not stored.
  288.65 +*
  288.66 +*  The array parm contains description of the network to be generated:
  288.67 +*
  288.68 +*  parm[0]  not used
  288.69 +*  parm[1]  two-ways arcs indicator:
  288.70 +*           1 - if links in both direction should be generated
  288.71 +*           0 - otherwise
  288.72 +*  parm[2]  random number seed (a positive integer)
  288.73 +*  parm[3]  number of nodes (the number of nodes generated might be
  288.74 +*           slightly different to make the network a grid)
  288.75 +*  parm[4]  grid width
  288.76 +*  parm[5]  number of sources
  288.77 +*  parm[6]  number of sinks
  288.78 +*  parm[7]  average degree
  288.79 +*  parm[8]  total flow
  288.80 +*  parm[9]  distribution of arc costs:
  288.81 +*           1 - uniform
  288.82 +*           2 - exponential
  288.83 +*  parm[10] lower bound for arc cost (uniform)
  288.84 +*           100 * lambda (exponential)
  288.85 +*  parm[11] upper bound for arc cost (uniform)
  288.86 +*           not used (exponential)
  288.87 +*  parm[12] distribution of arc capacities:
  288.88 +*           1 - uniform
  288.89 +*           2 - exponential
  288.90 +*  parm[13] lower bound for arc capacity (uniform)
  288.91 +*           100 * lambda (exponential)
  288.92 +*  parm[14] upper bound for arc capacity (uniform)
  288.93 +*           not used (exponential)
  288.94 +*
  288.95 +*  RETURNS
  288.96 +*
  288.97 +*  If the instance was successfully generated, the routine glp_gridgen
  288.98 +*  returns zero; otherwise, if specified parameters are inconsistent,
  288.99 +*  the routine returns a non-zero error code.
 288.100 +*
 288.101 +*  COMMENTS
 288.102 +*
 288.103 +*  This network generator generates a grid-like network plus a super
 288.104 +*  node. In additional to the arcs connecting the nodes in the grid,
 288.105 +*  there is an arc from each supply node to the super node and from the
 288.106 +*  super node to each demand node to guarantee feasiblity. These arcs
 288.107 +*  have very high costs and very big capacities.
 288.108 +*
 288.109 +*  The idea of this network generator is as follows: First, a grid of
 288.110 +*  n1 * n2 is generated. For example, 5 * 3. The nodes are numbered as
 288.111 +*  1 to 15, and the supernode is numbered as n1*n2+1. Then arcs between
 288.112 +*  adjacent nodes are generated. For these arcs, the user is allowed to
 288.113 +*  specify either to generate two-way arcs or one-way arcs. If two-way
 288.114 +*  arcs are to be generated, two arcs, one in each direction, will be
 288.115 +*  generated between each adjacent node pairs. Otherwise, only one arc
 288.116 +*  will be generated. If this is the case, the arcs will be generated
 288.117 +*  in alterntive directions as shown below.
 288.118 +*
 288.119 +*      1 ---> 2 ---> 3 ---> 4 ---> 5
 288.120 +*      |      ^      |      ^      |
 288.121 +*      |      |      |      |      |
 288.122 +*      V      |      V      |      V
 288.123 +*      6 <--- 7 <--- 8 <--- 9 <--- 10
 288.124 +*      |      ^      |      ^      |
 288.125 +*      |      |      |      |      |
 288.126 +*      V      |      V      |      V
 288.127 +*     11 --->12 --->13 --->14 ---> 15
 288.128 +*
 288.129 +*  Then the arcs between the super node and the source/sink nodes are
 288.130 +*  added as mentioned before. If the number of arcs still doesn't reach
 288.131 +*  the requirement, additional arcs will be added by uniformly picking
 288.132 +*  random node pairs. There is no checking to prevent multiple arcs
 288.133 +*  between any pair of nodes. However, there will be no self-arcs (arcs
 288.134 +*  that poins back to its tail node) in the network.
 288.135 +*
 288.136 +*  The source and sink nodes are selected uniformly in the network, and
 288.137 +*  the imbalances of each source/sink node are also assigned by uniform
 288.138 +*  distribution. */
 288.139 +
 288.140 +struct stat_para
 288.141 +{     /* structure for statistical distributions */
 288.142 +      int distribution;
 288.143 +      /* the distribution: */
 288.144 +#define UNIFORM      1  /* uniform distribution */
 288.145 +#define EXPONENTIAL  2  /* exponential distribution */
 288.146 +      double parameter[5];
 288.147 +      /* the parameters of the distribution */
 288.148 +};
 288.149 +
 288.150 +struct arcs
 288.151 +{     int from;
 288.152 +      /* the FROM node of that arc */
 288.153 +      int to;
 288.154 +      /* the TO node of that arc */
 288.155 +      int cost;
 288.156 +      /* original cost of that arc */
 288.157 +      int u;
 288.158 +      /* capacity of the arc */
 288.159 +};
 288.160 +
 288.161 +struct imbalance
 288.162 +{     int node;
 288.163 +      /* Node ID */
 288.164 +      int supply;
 288.165 +      /* Supply of that node */
 288.166 +};
 288.167 +
 288.168 +struct csa
 288.169 +{     /* common storage area */
 288.170 +      glp_graph *G;
 288.171 +      int v_rhs, a_cap, a_cost;
 288.172 +      int seed;
 288.173 +      /* random number seed */
 288.174 +      int seed_original;
 288.175 +      /* the original seed from input */
 288.176 +      int two_way;
 288.177 +      /* 0: generate arcs in both direction for the basic grid, except
 288.178 +         for the arcs to/from the super node.  1: o/w */
 288.179 +      int n_node;
 288.180 +      /* total number of nodes in the network, numbered 1 to n_node,
 288.181 +         including the super node, which is the last one */
 288.182 +      int n_arc;
 288.183 +      /* total number of arcs in the network, counting EVERY arc. */
 288.184 +      int n_grid_arc;
 288.185 +      /* number of arcs in the basic grid, including the arcs to/from
 288.186 +         the super node */
 288.187 +      int n_source, n_sink;
 288.188 +      /* number of source and sink nodes */
 288.189 +      int avg_degree;
 288.190 +      /* average degree, arcs to and from the super node are counted */
 288.191 +      int t_supply;
 288.192 +      /* total supply in the network */
 288.193 +      int n1, n2;
 288.194 +      /* the two edges of the network grid.  n1 >= n2 */
 288.195 +      struct imbalance *source_list, *sink_list;
 288.196 +      /* head of the array of source/sink nodes */
 288.197 +      struct stat_para arc_costs;
 288.198 +      /* the distribution of arc costs */
 288.199 +      struct stat_para capacities;
 288.200 +      /* distribution of the capacities of the arcs */
 288.201 +      struct arcs *arc_list;
 288.202 +      /* head of the arc list array.  Arcs in this array are in the
 288.203 +         order of grid_arcs, arcs to/from super node, and other arcs */
 288.204 +};
 288.205 +
 288.206 +#define G (csa->G)
 288.207 +#define v_rhs (csa->v_rhs)
 288.208 +#define a_cap (csa->a_cap)
 288.209 +#define a_cost (csa->a_cost)
 288.210 +#define seed (csa->seed)
 288.211 +#define seed_original (csa->seed_original)
 288.212 +#define two_way (csa->two_way)
 288.213 +#define n_node (csa->n_node)
 288.214 +#define n_arc (csa->n_arc)
 288.215 +#define n_grid_arc (csa->n_grid_arc)
 288.216 +#define n_source (csa->n_source)
 288.217 +#define n_sink (csa->n_sink)
 288.218 +#define avg_degree (csa->avg_degree)
 288.219 +#define t_supply (csa->t_supply)
 288.220 +#define n1 (csa->n1)
 288.221 +#define n2 (csa->n2)
 288.222 +#define source_list (csa->source_list)
 288.223 +#define sink_list (csa->sink_list)
 288.224 +#define arc_costs (csa->arc_costs)
 288.225 +#define capacities (csa->capacities)
 288.226 +#define arc_list (csa->arc_list)
 288.227 +
 288.228 +static void assign_capacities(struct csa *csa);
 288.229 +static void assign_costs(struct csa *csa);
 288.230 +static void assign_imbalance(struct csa *csa);
 288.231 +static int exponential(struct csa *csa, double lambda[1]);
 288.232 +static struct arcs *gen_additional_arcs(struct csa *csa, struct arcs
 288.233 +      *arc_ptr);
 288.234 +static struct arcs *gen_basic_grid(struct csa *csa, struct arcs
 288.235 +      *arc_ptr);
 288.236 +static void gen_more_arcs(struct csa *csa, struct arcs *arc_ptr);
 288.237 +static void generate(struct csa *csa);
 288.238 +static void output(struct csa *csa);
 288.239 +static double randy(struct csa *csa);
 288.240 +static void select_source_sinks(struct csa *csa);
 288.241 +static int uniform(struct csa *csa, double a[2]);
 288.242 +
 288.243 +int glp_gridgen(glp_graph *G_, int _v_rhs, int _a_cap, int _a_cost,
 288.244 +      const int parm[1+14])
 288.245 +{     struct csa _csa, *csa = &_csa;
 288.246 +      int n, ret;
 288.247 +      G = G_;
 288.248 +      v_rhs = _v_rhs;
 288.249 +      a_cap = _a_cap;
 288.250 +      a_cost = _a_cost;
 288.251 +      if (G != NULL)
 288.252 +      {  if (v_rhs >= 0 && v_rhs > G->v_size - (int)sizeof(double))
 288.253 +            xerror("glp_gridgen: v_rhs = %d; invalid offset\n", v_rhs);
 288.254 +         if (a_cap >= 0 && a_cap > G->a_size - (int)sizeof(double))
 288.255 +            xerror("glp_gridgen: a_cap = %d; invalid offset\n", a_cap);
 288.256 +         if (a_cost >= 0 && a_cost > G->a_size - (int)sizeof(double))
 288.257 +            xerror("glp_gridgen: a_cost = %d; invalid offset\n", a_cost)
 288.258 +               ;
 288.259 +      }
 288.260 +      /* Check the parameters for consistency. */
 288.261 +      if (!(parm[1] == 0 || parm[1] == 1))
 288.262 +      {  ret = 1;
 288.263 +         goto done;
 288.264 +      }
 288.265 +      if (parm[2] < 1)
 288.266 +      {  ret = 2;
 288.267 +         goto done;
 288.268 +      }
 288.269 +      if (!(10 <= parm[3] && parm[3] <= 40000))
 288.270 +      {  ret = 3;
 288.271 +         goto done;
 288.272 +      }
 288.273 +      if (!(1 <= parm[4] && parm[4] <= 40000))
 288.274 +      {  ret = 4;
 288.275 +         goto done;
 288.276 +      }
 288.277 +      if (!(parm[5] >= 0 && parm[6] >= 0 && parm[5] + parm[6] <=
 288.278 +         parm[3]))
 288.279 +      {  ret = 5;
 288.280 +         goto done;
 288.281 +      }
 288.282 +      if (!(1 <= parm[7] && parm[7] <= parm[3]))
 288.283 +      {  ret = 6;
 288.284 +         goto done;
 288.285 +      }
 288.286 +      if (parm[8] < 0)
 288.287 +      {  ret = 7;
 288.288 +         goto done;
 288.289 +      }
 288.290 +      if (!(parm[9] == 1 || parm[9] == 2))
 288.291 +      {  ret = 8;
 288.292 +         goto done;
 288.293 +      }
 288.294 +      if (parm[9] == 1 && parm[10] > parm[11] ||
 288.295 +          parm[9] == 2 && parm[10] < 1)
 288.296 +      {  ret = 9;
 288.297 +         goto done;
 288.298 +      }
 288.299 +      if (!(parm[12] == 1 || parm[12] == 2))
 288.300 +      {  ret = 10;
 288.301 +         goto done;
 288.302 +      }
 288.303 +      if (parm[12] == 1 && !(0 <= parm[13] && parm[13] <= parm[14]) ||
 288.304 +          parm[12] == 2 && parm[13] < 1)
 288.305 +      {  ret = 11;
 288.306 +         goto done;
 288.307 +      }
 288.308 +      /* Initialize the graph object. */
 288.309 +      if (G != NULL)
 288.310 +      {  glp_erase_graph(G, G->v_size, G->a_size);
 288.311 +         glp_set_graph_name(G, "GRIDGEN");
 288.312 +      }
 288.313 +      /* Copy the generator parameters. */
 288.314 +      two_way = parm[1];
 288.315 +      seed_original = seed = parm[2];
 288.316 +      n_node = parm[3];
 288.317 +      n = parm[4];
 288.318 +      n_source = parm[5];
 288.319 +      n_sink = parm[6];
 288.320 +      avg_degree = parm[7];
 288.321 +      t_supply = parm[8];
 288.322 +      arc_costs.distribution = parm[9];
 288.323 +      if (parm[9] == 1)
 288.324 +      {  arc_costs.parameter[0] = parm[10];
 288.325 +         arc_costs.parameter[1] = parm[11];
 288.326 +      }
 288.327 +      else
 288.328 +      {  arc_costs.parameter[0] = (double)parm[10] / 100.0;
 288.329 +         arc_costs.parameter[1] = 0.0;
 288.330 +      }
 288.331 +      capacities.distribution = parm[12];
 288.332 +      if (parm[12] == 1)
 288.333 +      {  capacities.parameter[0] = parm[13];
 288.334 +         capacities.parameter[1] = parm[14];
 288.335 +      }
 288.336 +      else
 288.337 +      {  capacities.parameter[0] = (double)parm[13] / 100.0;
 288.338 +         capacities.parameter[1] = 0.0;
 288.339 +      }
 288.340 +      /* Calculate the edge lengths of the grid according to the
 288.341 +         input. */
 288.342 +      if (n * n >= n_node)
 288.343 +      {  n1 = n;
 288.344 +         n2 = (int)((double)n_node / (double)n + 0.5);
 288.345 +      }
 288.346 +      else
 288.347 +      {  n2 = n;
 288.348 +         n1 = (int)((double)n_node / (double)n + 0.5);
 288.349 +      }
 288.350 +      /* Recalculate the total number of nodes and plus 1 for the super
 288.351 +         node. */
 288.352 +      n_node = n1 * n2 + 1;
 288.353 +      n_arc = n_node * avg_degree;
 288.354 +      n_grid_arc = (two_way + 1) * ((n1 - 1) * n2 + (n2 - 1) * n1) +
 288.355 +         n_source + n_sink;
 288.356 +      if (n_grid_arc > n_arc) n_arc = n_grid_arc;
 288.357 +      arc_list = xcalloc(n_arc, sizeof(struct arcs));
 288.358 +      source_list = xcalloc(n_source, sizeof(struct imbalance));
 288.359 +      sink_list = xcalloc(n_sink, sizeof(struct imbalance));
 288.360 +      /* Generate a random network. */
 288.361 +      generate(csa);
 288.362 +      /* Output the network. */
 288.363 +      output(csa);
 288.364 +      /* Free all allocated memory. */
 288.365 +      xfree(arc_list);
 288.366 +      xfree(source_list);
 288.367 +      xfree(sink_list);
 288.368 +      /* The instance has been successfully generated. */
 288.369 +      ret = 0;
 288.370 +done: return ret;
 288.371 +}
 288.372 +
 288.373 +#undef random
 288.374 +
 288.375 +static void assign_capacities(struct csa *csa)
 288.376 +{     /* Assign a capacity to each arc. */
 288.377 +      struct arcs *arc_ptr = arc_list;
 288.378 +      int (*random)(struct csa *csa, double *);
 288.379 +      int i;
 288.380 +      /* Determine the random number generator to use. */
 288.381 +      switch (arc_costs.distribution)
 288.382 +      {  case UNIFORM:
 288.383 +            random = uniform;
 288.384 +            break;
 288.385 +         case EXPONENTIAL:
 288.386 +            random = exponential;
 288.387 +            break;
 288.388 +         default:
 288.389 +            xassert(csa != csa);
 288.390 +      }
 288.391 +      /* Assign capacities to grid arcs. */
 288.392 +      for (i = n_source + n_sink; i < n_grid_arc; i++, arc_ptr++)
 288.393 +         arc_ptr->u = random(csa, capacities.parameter);
 288.394 +      i = i - n_source - n_sink;
 288.395 +      /* Assign capacities to arcs to/from supernode. */
 288.396 +      for (; i < n_grid_arc; i++, arc_ptr++)
 288.397 +         arc_ptr->u = t_supply;
 288.398 +      /* Assign capacities to all other arcs. */
 288.399 +      for (; i < n_arc; i++, arc_ptr++)
 288.400 +         arc_ptr->u = random(csa, capacities.parameter);
 288.401 +      return;
 288.402 +}
 288.403 +
 288.404 +static void assign_costs(struct csa *csa)
 288.405 +{     /* Assign a cost to each arc. */
 288.406 +      struct arcs *arc_ptr = arc_list;
 288.407 +      int (*random)(struct csa *csa, double *);
 288.408 +      int i;
 288.409 +      /* A high cost assigned to arcs to/from the supernode. */
 288.410 +      int high_cost;
 288.411 +      /* The maximum cost assigned to arcs in the base grid. */
 288.412 +      int max_cost = 0;
 288.413 +      /* Determine the random number generator to use. */
 288.414 +      switch (arc_costs.distribution)
 288.415 +      {  case UNIFORM:
 288.416 +            random = uniform;
 288.417 +            break;
 288.418 +         case EXPONENTIAL:
 288.419 +            random = exponential;
 288.420 +            break;
 288.421 +         default:
 288.422 +            xassert(csa != csa);
 288.423 +      }
 288.424 +      /* Assign costs to arcs in the base grid. */
 288.425 +      for (i = n_source + n_sink; i < n_grid_arc; i++, arc_ptr++)
 288.426 +      {  arc_ptr->cost = random(csa, arc_costs.parameter);
 288.427 +         if (max_cost < arc_ptr->cost) max_cost = arc_ptr->cost;
 288.428 +      }
 288.429 +      i = i - n_source - n_sink;
 288.430 +      /* Assign costs to arcs to/from the super node. */
 288.431 +      high_cost = max_cost * 2;
 288.432 +      for (; i < n_grid_arc; i++, arc_ptr++)
 288.433 +         arc_ptr->cost = high_cost;
 288.434 +      /* Assign costs to all other arcs. */
 288.435 +      for (; i < n_arc; i++, arc_ptr++)
 288.436 +         arc_ptr->cost = random(csa, arc_costs.parameter);
 288.437 +      return;
 288.438 +}
 288.439 +
 288.440 +static void assign_imbalance(struct csa *csa)
 288.441 +{     /* Assign an imbalance to each node. */
 288.442 +      int total, i;
 288.443 +      double avg;
 288.444 +      struct imbalance *ptr;
 288.445 +      /* assign the supply nodes */
 288.446 +      avg = 2.0 * t_supply / n_source;
 288.447 +      do
 288.448 +      {  for (i = 1, total = t_supply, ptr = source_list + 1;
 288.449 +            i < n_source; i++, ptr++)
 288.450 +         {  ptr->supply = (int)(randy(csa) * avg + 0.5);
 288.451 +            total -= ptr->supply;
 288.452 +         }
 288.453 +         source_list->supply = total;
 288.454 +      }
 288.455 +      /* redo all if the assignment "overshooted" */
 288.456 +      while (total <= 0);
 288.457 +      /* assign the demand nodes */
 288.458 +      avg = -2.0 * t_supply / n_sink;
 288.459 +      do
 288.460 +      {  for (i = 1, total = t_supply, ptr = sink_list + 1;
 288.461 +            i < n_sink; i++, ptr++)
 288.462 +         {  ptr->supply = (int)(randy(csa) * avg - 0.5);
 288.463 +            total += ptr->supply;
 288.464 +         }
 288.465 +         sink_list->supply = - total;
 288.466 +      }
 288.467 +      while (total <= 0);
 288.468 +      return;
 288.469 +}
 288.470 +
 288.471 +static int exponential(struct csa *csa, double lambda[1])
 288.472 +{     /* Returns an "exponentially distributed" integer with parameter
 288.473 +         lambda. */
 288.474 +      return ((int)(- lambda[0] * log((double)randy(csa)) + 0.5));
 288.475 +}
 288.476 +
 288.477 +static struct arcs *gen_additional_arcs(struct csa *csa, struct arcs
 288.478 +      *arc_ptr)
 288.479 +{     /* Generate an arc from each source to the supernode and from
 288.480 +         supernode to each sink. */
 288.481 +      int i;
 288.482 +      for (i = 0; i < n_source; i++, arc_ptr++)
 288.483 +      {  arc_ptr->from = source_list[i].node;
 288.484 +         arc_ptr->to = n_node;
 288.485 +      }
 288.486 +      for (i = 0; i < n_sink; i++, arc_ptr++)
 288.487 +      {  arc_ptr->to = sink_list[i].node;
 288.488 +         arc_ptr->from = n_node;
 288.489 +      }
 288.490 +      return arc_ptr;
 288.491 +}
 288.492 +
 288.493 +static struct arcs *gen_basic_grid(struct csa *csa, struct arcs
 288.494 +      *arc_ptr)
 288.495 +{     /* Generate the basic grid. */
 288.496 +      int direction = 1, i, j, k;
 288.497 +      if (two_way)
 288.498 +      {  /* Generate an arc in each direction. */
 288.499 +         for (i = 1; i < n_node; i += n1)
 288.500 +         {  for (j = i, k = j + n1 - 1; j < k; j++)
 288.501 +            {  arc_ptr->from = j;
 288.502 +               arc_ptr->to = j + 1;
 288.503 +               arc_ptr++;
 288.504 +               arc_ptr->from = j + 1;
 288.505 +               arc_ptr->to = j;
 288.506 +               arc_ptr++;
 288.507 +            }
 288.508 +         }
 288.509 +         for (i = 1; i <= n1; i++)
 288.510 +         {  for (j = i + n1; j < n_node; j += n1)
 288.511 +            {  arc_ptr->from = j;
 288.512 +               arc_ptr->to = j - n1;
 288.513 +               arc_ptr++;
 288.514 +               arc_ptr->from = j - n1;
 288.515 +               arc_ptr->to = j;
 288.516 +               arc_ptr++;
 288.517 +            }
 288.518 +         }
 288.519 +      }
 288.520 +      else
 288.521 +      {  /* Generate one arc in each direction. */
 288.522 +         for (i = 1; i < n_node; i += n1)
 288.523 +         {  if (direction == 1)
 288.524 +               j = i;
 288.525 +            else
 288.526 +               j = i + 1;
 288.527 +            for (k = j + n1 - 1; j < k; j++)
 288.528 +            {  arc_ptr->from = j;
 288.529 +               arc_ptr->to = j + direction;
 288.530 +               arc_ptr++;
 288.531 +            }
 288.532 +            direction = - direction;
 288.533 +         }
 288.534 +         for (i = 1; i <= n1; i++)
 288.535 +         {  j = i + n1;
 288.536 +            if (direction == 1)
 288.537 +            {  for (; j < n_node; j += n1)
 288.538 +               {  arc_ptr->from = j - n1;
 288.539 +                  arc_ptr->to = j;
 288.540 +                  arc_ptr++;
 288.541 +               }
 288.542 +            }
 288.543 +            else
 288.544 +            {  for (; j < n_node; j += n1)
 288.545 +               {  arc_ptr->from = j - n1;
 288.546 +                  arc_ptr->to = j;
 288.547 +                  arc_ptr++;
 288.548 +               }
 288.549 +            }
 288.550 +            direction = - direction;
 288.551 +         }
 288.552 +      }
 288.553 +      return arc_ptr;
 288.554 +}
 288.555 +
 288.556 +static void gen_more_arcs(struct csa *csa, struct arcs *arc_ptr)
 288.557 +{     /* Generate random arcs to meet the specified density. */
 288.558 +      int i;
 288.559 +      double ab[2];
 288.560 +      ab[0] = 0.9;
 288.561 +      ab[1] = n_node - 0.99;  /* upper limit is n_node-1 because the
 288.562 +                                 supernode cannot be selected */
 288.563 +      for (i = n_grid_arc; i < n_arc; i++, arc_ptr++)
 288.564 +      {  arc_ptr->from = uniform(csa, ab);
 288.565 +         arc_ptr->to = uniform(csa, ab);
 288.566 +         if (arc_ptr->from == arc_ptr->to)
 288.567 +         {  arc_ptr--;
 288.568 +            i--;
 288.569 +         }
 288.570 +      }
 288.571 +      return;
 288.572 +}
 288.573 +
 288.574 +static void generate(struct csa *csa)
 288.575 +{     /* Generate a random network. */
 288.576 +      struct arcs *arc_ptr = arc_list;
 288.577 +      arc_ptr = gen_basic_grid(csa, arc_ptr);
 288.578 +      select_source_sinks(csa);
 288.579 +      arc_ptr = gen_additional_arcs(csa, arc_ptr);
 288.580 +      gen_more_arcs(csa, arc_ptr);
 288.581 +      assign_costs(csa);
 288.582 +      assign_capacities(csa);
 288.583 +      assign_imbalance(csa);
 288.584 +      return;
 288.585 +}
 288.586 +
 288.587 +static void output(struct csa *csa)
 288.588 +{     /* Output the network in DIMACS format. */
 288.589 +      struct arcs *arc_ptr;
 288.590 +      struct imbalance *imb_ptr;
 288.591 +      int i;
 288.592 +      if (G != NULL) goto skip;
 288.593 +      /* Output "c", "p" records. */
 288.594 +      xprintf("c generated by GRIDGEN\n");
 288.595 +      xprintf("c seed %d\n", seed_original);
 288.596 +      xprintf("c nodes %d\n", n_node);
 288.597 +      xprintf("c grid size %d X %d\n", n1, n2);
 288.598 +      xprintf("c sources %d sinks %d\n", n_source, n_sink);
 288.599 +      xprintf("c avg. degree %d\n", avg_degree);
 288.600 +      xprintf("c supply %d\n", t_supply);
 288.601 +      switch (arc_costs.distribution)
 288.602 +      {  case UNIFORM:
 288.603 +            xprintf("c arc costs: UNIFORM distr. min %d max %d\n",
 288.604 +               (int)arc_costs.parameter[0],
 288.605 +               (int)arc_costs.parameter[1]);
 288.606 +            break;
 288.607 +         case EXPONENTIAL:
 288.608 +            xprintf("c arc costs: EXPONENTIAL distr. lambda %d\n",
 288.609 +               (int)arc_costs.parameter[0]);
 288.610 +            break;
 288.611 +         default:
 288.612 +            xassert(csa != csa);
 288.613 +      }
 288.614 +      switch (capacities.distribution)
 288.615 +      {  case UNIFORM:
 288.616 +            xprintf("c arc caps :  UNIFORM distr. min %d max %d\n",
 288.617 +               (int)capacities.parameter[0],
 288.618 +               (int)capacities.parameter[1]);
 288.619 +            break;
 288.620 +         case EXPONENTIAL:
 288.621 +            xprintf("c arc caps :  EXPONENTIAL distr. %d lambda %d\n",
 288.622 +               (int)capacities.parameter[0]);
 288.623 +            break;
 288.624 +         default:
 288.625 +            xassert(csa != csa);
 288.626 +      }
 288.627 +skip: if (G == NULL)
 288.628 +         xprintf("p min %d %d\n", n_node, n_arc);
 288.629 +      else
 288.630 +      {  glp_add_vertices(G, n_node);
 288.631 +         if (v_rhs >= 0)
 288.632 +         {  double zero = 0.0;
 288.633 +            for (i = 1; i <= n_node; i++)
 288.634 +            {  glp_vertex *v = G->v[i];
 288.635 +               memcpy((char *)v->data + v_rhs, &zero, sizeof(double));
 288.636 +            }
 288.637 +         }
 288.638 +      }
 288.639 +      /* Output "n node supply". */
 288.640 +      for (i = 0, imb_ptr = source_list; i < n_source; i++, imb_ptr++)
 288.641 +      {  if (G == NULL)
 288.642 +            xprintf("n %d %d\n", imb_ptr->node, imb_ptr->supply);
 288.643 +         else
 288.644 +         {  if (v_rhs >= 0)
 288.645 +            {  double temp = (double)imb_ptr->supply;
 288.646 +               glp_vertex *v = G->v[imb_ptr->node];
 288.647 +               memcpy((char *)v->data + v_rhs, &temp, sizeof(double));
 288.648 +            }
 288.649 +         }
 288.650 +      }
 288.651 +      for (i = 0, imb_ptr = sink_list; i < n_sink; i++, imb_ptr++)
 288.652 +      {  if (G == NULL)
 288.653 +            xprintf("n %d %d\n", imb_ptr->node, imb_ptr->supply);
 288.654 +         else
 288.655 +         {  if (v_rhs >= 0)
 288.656 +            {  double temp = (double)imb_ptr->supply;
 288.657 +               glp_vertex *v = G->v[imb_ptr->node];
 288.658 +               memcpy((char *)v->data + v_rhs, &temp, sizeof(double));
 288.659 +            }
 288.660 +         }
 288.661 +      }
 288.662 +      /* Output "a from to lowcap=0 hicap cost". */
 288.663 +      for (i = 0, arc_ptr = arc_list; i < n_arc; i++, arc_ptr++)
 288.664 +      {  if (G == NULL)
 288.665 +            xprintf("a %d %d 0 %d %d\n", arc_ptr->from, arc_ptr->to,
 288.666 +               arc_ptr->u, arc_ptr->cost);
 288.667 +         else
 288.668 +         {  glp_arc *a = glp_add_arc(G, arc_ptr->from, arc_ptr->to);
 288.669 +            if (a_cap >= 0)
 288.670 +            {  double temp = (double)arc_ptr->u;
 288.671 +               memcpy((char *)a->data + a_cap, &temp, sizeof(double));
 288.672 +            }
 288.673 +            if (a_cost >= 0)
 288.674 +            {  double temp = (double)arc_ptr->cost;
 288.675 +               memcpy((char *)a->data + a_cost, &temp, sizeof(double));
 288.676 +            }
 288.677 +         }
 288.678 +      }
 288.679 +      return;
 288.680 +}
 288.681 +
 288.682 +static double randy(struct csa *csa)
 288.683 +{     /* Returns a random number between 0.0 and 1.0.
 288.684 +         See Ward Cheney & David Kincaid, "Numerical Mathematics and
 288.685 +         Computing," 2Ed, pp. 335. */
 288.686 +      seed = 16807 * seed % 2147483647;
 288.687 +      if (seed < 0) seed = - seed;
 288.688 +      return seed * 4.6566128752459e-10;
 288.689 +}
 288.690 +
 288.691 +static void select_source_sinks(struct csa *csa)
 288.692 +{     /* Randomly select the source nodes and sink nodes. */
 288.693 +      int i, *int_ptr;
 288.694 +      int *temp_list;   /* a temporary list of nodes */
 288.695 +      struct imbalance *ptr;
 288.696 +      double ab[2];     /* parameter for random number generator */
 288.697 +      ab[0] = 0.9;
 288.698 +      ab[1] = n_node - 0.99;  /* upper limit is n_node-1 because the
 288.699 +                                 supernode cannot be selected */
 288.700 +      temp_list = xcalloc(n_node, sizeof(int));
 288.701 +      for (i = 0, int_ptr = temp_list; i < n_node; i++, int_ptr++)
 288.702 +         *int_ptr = 0;
 288.703 +      /* Select the source nodes. */
 288.704 +      for (i = 0, ptr = source_list; i < n_source; i++, ptr++)
 288.705 +      {  ptr->node = uniform(csa, ab);
 288.706 +         if (temp_list[ptr->node] == 1) /* check for duplicates */
 288.707 +         {  ptr--;
 288.708 +            i--;
 288.709 +         }
 288.710 +         else
 288.711 +            temp_list[ptr->node] = 1;
 288.712 +      }
 288.713 +      /* Select the sink nodes. */
 288.714 +      for (i = 0, ptr = sink_list; i < n_sink; i++, ptr++)
 288.715 +      {  ptr->node = uniform(csa, ab);
 288.716 +         if (temp_list[ptr->node] == 1)
 288.717 +         {  ptr--;
 288.718 +            i--;
 288.719 +         }
 288.720 +         else
 288.721 +            temp_list[ptr->node] = 1;
 288.722 +      }
 288.723 +      xfree(temp_list);
 288.724 +      return;
 288.725 +}
 288.726 +
 288.727 +int uniform(struct csa *csa, double a[2])
 288.728 +{     /* Generates an integer uniformly selected from [a[0],a[1]]. */
 288.729 +      return (int)((a[1] - a[0]) * randy(csa) + a[0] + 0.5);
 288.730 +}
 288.731 +
 288.732 +/**********************************************************************/
 288.733 +
 288.734 +#if 0
 288.735 +int main(void)
 288.736 +{     int parm[1+14];
 288.737 +      double temp;
 288.738 +      scanf("%d", &parm[1]);
 288.739 +      scanf("%d", &parm[2]);
 288.740 +      scanf("%d", &parm[3]);
 288.741 +      scanf("%d", &parm[4]);
 288.742 +      scanf("%d", &parm[5]);
 288.743 +      scanf("%d", &parm[6]);
 288.744 +      scanf("%d", &parm[7]);
 288.745 +      scanf("%d", &parm[8]);
 288.746 +      scanf("%d", &parm[9]);
 288.747 +      if (parm[9] == 1)
 288.748 +      {  scanf("%d", &parm[10]);
 288.749 +         scanf("%d", &parm[11]);
 288.750 +      }
 288.751 +      else
 288.752 +      {  scanf("%le", &temp);
 288.753 +         parm[10] = (int)(100.0 * temp + .5);
 288.754 +         parm[11] = 0;
 288.755 +      }
 288.756 +      scanf("%d", &parm[12]);
 288.757 +      if (parm[12] == 1)
 288.758 +      {  scanf("%d", &parm[13]);
 288.759 +         scanf("%d", &parm[14]);
 288.760 +      }
 288.761 +      else
 288.762 +      {  scanf("%le", &temp);
 288.763 +         parm[13] = (int)(100.0 * temp + .5);
 288.764 +         parm[14] = 0;
 288.765 +      }
 288.766 +      glp_gridgen(NULL, 0, 0, 0, parm);
 288.767 +      return 0;
 288.768 +}
 288.769 +#endif
 288.770 +
 288.771 +/* eof */
   289.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
   289.2 +++ b/deps/glpk/src/glpnet05.c	Sun Nov 06 20:59:10 2011 +0100
   289.3 @@ -0,0 +1,367 @@
   289.4 +/* glpnet05.c (Goldfarb's maximum flow problem generator) */
   289.5 +
   289.6 +/***********************************************************************
   289.7 +*  This code is part of GLPK (GNU Linear Programming Kit).
   289.8 +*
   289.9 +*  This code is a modified version of the program RMFGEN, a maxflow
  289.10 +*  problem generator developed by D.Goldfarb and M.Grigoriadis, and
  289.11 +*  originally implemented by Tamas Badics <badics@rutcor.rutgers.edu>.
  289.12 +*  The original code is publically available on the DIMACS ftp site at:
  289.13 +*  <ftp://dimacs.rutgers.edu/pub/netflow/generators/network/genrmf>.
  289.14 +*
  289.15 +*  All changes concern only the program interface, so this modified
  289.16 +*  version produces exactly the same instances as the original version.
  289.17 +*
  289.18 +*  Changes were made by Andrew Makhorin <mao@gnu.org>.
  289.19 +*
  289.20 +*  GLPK is free software: you can redistribute it and/or modify it
  289.21 +*  under the terms of the GNU General Public License as published by
  289.22 +*  the Free Software Foundation, either version 3 of the License, or
  289.23 +*  (at your option) any later version.
  289.24 +*
  289.25 +*  GLPK is distributed in the hope that it will be useful, but WITHOUT
  289.26 +*  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
  289.27 +*  or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
  289.28 +*  License for more details.
  289.29 +*
  289.30 +*  You should have received a copy of the GNU General Public License
  289.31 +*  along with GLPK. If not, see <http://www.gnu.org/licenses/>.
  289.32 +***********************************************************************/
  289.33 +
  289.34 +#include "glpapi.h"
  289.35 +#include "glprng.h"
  289.36 +
  289.37 +/***********************************************************************
  289.38 +*  NAME
  289.39 +*
  289.40 +*  glp_rmfgen - Goldfarb's maximum flow problem generator
  289.41 +*
  289.42 +*  SYNOPSIS
  289.43 +*
  289.44 +*  int glp_rmfgen(glp_graph *G, int *s, int *t, int a_cap,
  289.45 +*     const int parm[1+5]);
  289.46 +*
  289.47 +*  DESCRIPTION
  289.48 +*
  289.49 +*  The routine glp_rmfgen is a maximum flow problem generator developed
  289.50 +*  by D.Goldfarb and M.Grigoriadis.
  289.51 +*
  289.52 +*  The parameter G specifies the graph object, to which the generated
  289.53 +*  problem data have to be stored. Note that on entry the graph object
  289.54 +*  is erased with the routine glp_erase_graph.
  289.55 +*
  289.56 +*  The pointer s specifies a location, to which the routine stores the
  289.57 +*  source node number. If s is NULL, the node number is not stored.
  289.58 +*
  289.59 +*  The pointer t specifies a location, to which the routine stores the
  289.60 +*  sink node number. If t is NULL, the node number is not stored.
  289.61 +*
  289.62 +*  The parameter a_cap specifies an offset of the field of type double
  289.63 +*  in the arc data block, to which the routine stores the arc capacity.
  289.64 +*  If a_cap < 0, the capacity is not stored.
  289.65 +*
  289.66 +*  The array parm contains description of the network to be generated:
  289.67 +*
  289.68 +*  parm[0]  not used
  289.69 +*  parm[1]  (seed)   random number seed (a positive integer)
  289.70 +*  parm[2]  (a)      frame size
  289.71 +*  parm[3]  (b)      depth
  289.72 +*  parm[4]  (c1)     minimal arc capacity
  289.73 +*  parm[5]  (c2)     maximal arc capacity
  289.74 +*
  289.75 +*  RETURNS
  289.76 +*
  289.77 +*  If the instance was successfully generated, the routine glp_netgen
  289.78 +*  returns zero; otherwise, if specified parameters are inconsistent,
  289.79 +*  the routine returns a non-zero error code.
  289.80 +*
  289.81 +*  COMMENTS
  289.82 +*
  289.83 +*  The generated network is as follows. It has b pieces of frames of
  289.84 +*  size a * a. (So alltogether the number of vertices is a * a * b)
  289.85 +*
  289.86 +*  In each frame all the vertices are connected with their neighbours
  289.87 +*  (forth and back). In addition the vertices of a frame are connected
  289.88 +*  one to one with the vertices of next frame using a random permutation
  289.89 +*  of those vertices.
  289.90 +*
  289.91 +*  The source is the lower left vertex of the first frame, the sink is
  289.92 +*  the upper right vertex of the b'th frame.
  289.93 +*
  289.94 +*                    t
  289.95 +*           +-------+
  289.96 +*           |      .|
  289.97 +*           |     . |
  289.98 +*        /  |    /  |
  289.99 +*       +-------+/ -+ b
 289.100 +*       |    |  |/.
 289.101 +*     a |   -v- |/
 289.102 +*       |    |  |/
 289.103 +*       +-------+ 1
 289.104 +*      s    a
 289.105 +*
 289.106 +*  The capacities are randomly chosen integers from the range of [c1,c2]
 289.107 +*  in the case of interconnecting edges, and c2 * a * a for the in-frame
 289.108 +*  edges.
 289.109 +*
 289.110 +*  REFERENCES
 289.111 +*
 289.112 +*  D.Goldfarb and M.D.Grigoriadis, "A computational comparison of the
 289.113 +*  Dinic and network simplex methods for maximum flow." Annals of Op.
 289.114 +*  Res. 13 (1988), pp. 83-123.
 289.115 +*
 289.116 +*  U.Derigs and W.Meier, "Implementing Goldberg's max-flow algorithm:
 289.117 +*  A computational investigation." Zeitschrift fuer Operations Research
 289.118 +*  33 (1989), pp. 383-403. */
 289.119 +
 289.120 +typedef struct VERTEX
 289.121 +{     struct EDGE **edgelist;
 289.122 +      /* Pointer to the list of pointers to the adjacent edges.
 289.123 +         (No matter that to or from edges) */
 289.124 +      struct EDGE **current;
 289.125 +      /* Pointer to the current edge */
 289.126 +      int degree;
 289.127 +      /* Number of adjacent edges (both direction) */
 289.128 +      int index;
 289.129 +} vertex;
 289.130 +
 289.131 +typedef struct EDGE
 289.132 +{     int from;
 289.133 +      int to;
 289.134 +      int cap;
 289.135 +      /* Capacity */
 289.136 +} edge;
 289.137 +
 289.138 +typedef struct NETWORK
 289.139 +{     struct NETWORK *next, *prev;
 289.140 +      int vertnum;
 289.141 +      int edgenum;
 289.142 +      vertex *verts;
 289.143 +      /* Vertex array[1..vertnum] */
 289.144 +      edge *edges;
 289.145 +      /* Edge array[1..edgenum] */
 289.146 +      int source;
 289.147 +      /* Pointer to the source */
 289.148 +      int sink;
 289.149 +      /* Pointer to the sink */
 289.150 +} network;
 289.151 +
 289.152 +struct csa
 289.153 +{     /* common storage area */
 289.154 +      glp_graph *G;
 289.155 +      int *s, *t, a_cap;
 289.156 +      RNG *rand;
 289.157 +      network *N;
 289.158 +      int *Parr;
 289.159 +      int A, AA, C2AA, Ec;
 289.160 +};
 289.161 +
 289.162 +#define G      (csa->G)
 289.163 +#define s      (csa->s)
 289.164 +#define t      (csa->t)
 289.165 +#define a_cap  (csa->a_cap)
 289.166 +#define N      (csa->N)
 289.167 +#define Parr   (csa->Parr)
 289.168 +#define A      (csa->A)
 289.169 +#define AA     (csa->AA)
 289.170 +#define C2AA   (csa->C2AA)
 289.171 +#define Ec     (csa->Ec)
 289.172 +
 289.173 +#undef random
 289.174 +#define random(A) (int)(rng_unif_01(csa->rand) * (double)(A))
 289.175 +#define RANDOM(A, B) (int)(random((B) - (A) + 1) + (A))
 289.176 +#define sgn(A) (((A) > 0) ? 1 : ((A) == 0) ? 0 : -1)
 289.177 +
 289.178 +static void make_edge(struct csa *csa, int from, int to, int c1, int c2)
 289.179 +{     Ec++;
 289.180 +      N->edges[Ec].from = from;
 289.181 +      N->edges[Ec].to = to;
 289.182 +      N->edges[Ec].cap = RANDOM(c1, c2);
 289.183 +      return;
 289.184 +}
 289.185 +
 289.186 +static void permute(struct csa *csa)
 289.187 +{     int i, j, tmp;
 289.188 +      for (i = 1; i < AA; i++)
 289.189 +      {  j = RANDOM(i, AA);
 289.190 +         tmp = Parr[i];
 289.191 +         Parr[i] = Parr[j];
 289.192 +         Parr[j] = tmp;
 289.193 +      }
 289.194 +      return;
 289.195 +}
 289.196 +
 289.197 +static void connect(struct csa *csa, int offset, int cv, int x1, int y1)
 289.198 +{     int cv1;
 289.199 +      cv1 = offset + (x1 - 1) * A + y1;
 289.200 +      Ec++;
 289.201 +      N->edges[Ec].from = cv;
 289.202 +      N->edges[Ec].to = cv1;
 289.203 +      N->edges[Ec].cap = C2AA;
 289.204 +      return;
 289.205 +}
 289.206 +
 289.207 +static network *gen_rmf(struct csa *csa, int a, int b, int c1, int c2)
 289.208 +{     /* generates a network with a*a*b nodes and 6a*a*b-4ab-2a*a edges
 289.209 +         random_frame network:
 289.210 +         Derigs & Meier, Methods & Models of OR (1989), 33:383-403 */
 289.211 +      int x, y, z, offset, cv;
 289.212 +      A = a;
 289.213 +      AA = a * a;
 289.214 +      C2AA = c2 * AA;
 289.215 +      Ec = 0;
 289.216 +      N = (network *)xmalloc(sizeof(network));
 289.217 +      N->vertnum = AA * b;
 289.218 +      N->edgenum = 5 * AA * b - 4 * A * b - AA;
 289.219 +      N->edges = (edge *)xcalloc(N->edgenum + 1, sizeof(edge));
 289.220 +      N->source = 1;
 289.221 +      N->sink = N->vertnum;
 289.222 +      Parr = (int *)xcalloc(AA + 1, sizeof(int));
 289.223 +      for (x = 1; x <= AA; x++)
 289.224 +         Parr[x] = x;
 289.225 +      for (z = 1; z <= b; z++)
 289.226 +      {  offset = AA * (z - 1);
 289.227 +         if (z != b)
 289.228 +            permute(csa);
 289.229 +         for (x = 1; x <= A; x++)
 289.230 +         {  for (y = 1; y <= A; y++)
 289.231 +            {  cv = offset + (x - 1) * A + y;
 289.232 +               if (z != b)
 289.233 +                  make_edge(csa, cv, offset + AA + Parr[cv - offset],
 289.234 +                     c1, c2); /* the intermediate edges */
 289.235 +               if (y < A)
 289.236 +                  connect(csa, offset, cv, x, y + 1);
 289.237 +               if (y > 1)
 289.238 +                  connect(csa, offset, cv, x, y - 1);
 289.239 +               if (x < A)
 289.240 +                  connect(csa, offset, cv, x + 1, y);
 289.241 +               if (x > 1)
 289.242 +                  connect(csa, offset, cv, x - 1, y);
 289.243 +            }
 289.244 +         }
 289.245 +      }
 289.246 +      xfree(Parr);
 289.247 +      return N;
 289.248 +}
 289.249 +
 289.250 +static void print_max_format(struct csa *csa, network *n, char *comm[],
 289.251 +      int dim)
 289.252 +{     /* prints a network heading with dim lines of comments (no \n
 289.253 +         needs at the ends) */
 289.254 +      int i, vnum, e_num;
 289.255 +      edge *e;
 289.256 +      vnum = n->vertnum;
 289.257 +      e_num = n->edgenum;
 289.258 +      if (G == NULL)
 289.259 +      {  for (i = 0; i < dim; i++)
 289.260 +            xprintf("c %s\n", comm[i]);
 289.261 +         xprintf("p max %7d %10d\n", vnum, e_num);
 289.262 +         xprintf("n %7d s\n", n->source);
 289.263 +         xprintf("n %7d t\n", n->sink);
 289.264 +      }
 289.265 +      else
 289.266 +      {  glp_add_vertices(G, vnum);
 289.267 +         if (s != NULL) *s = n->source;
 289.268 +         if (t != NULL) *t = n->sink;
 289.269 +      }
 289.270 +      for (i = 1; i <= e_num; i++)
 289.271 +      {  e = &n->edges[i];
 289.272 +         if (G == NULL)
 289.273 +            xprintf("a %7d %7d %10d\n", e->from, e->to, (int)e->cap);
 289.274 +         else
 289.275 +         {  glp_arc *a = glp_add_arc(G, e->from, e->to);
 289.276 +            if (a_cap >= 0)
 289.277 +            {  double temp = (double)e->cap;
 289.278 +               memcpy((char *)a->data + a_cap, &temp, sizeof(double));
 289.279 +            }
 289.280 +         }
 289.281 +      }
 289.282 +      return;
 289.283 +}
 289.284 +
 289.285 +static void gen_free_net(network *n)
 289.286 +{     xfree(n->edges);
 289.287 +      xfree(n);
 289.288 +      return;
 289.289 +}
 289.290 +
 289.291 +int glp_rmfgen(glp_graph *G_, int *_s, int *_t, int _a_cap,
 289.292 +      const int parm[1+5])
 289.293 +{     struct csa _csa, *csa = &_csa;
 289.294 +      network *n;
 289.295 +      char comm[10][80], *com1[10];
 289.296 +      int seed, a, b, c1, c2, ret;
 289.297 +      G = G_;
 289.298 +      s = _s;
 289.299 +      t = _t;
 289.300 +      a_cap = _a_cap;
 289.301 +      if (G != NULL)
 289.302 +      {  if (a_cap >= 0 && a_cap > G->a_size - (int)sizeof(double))
 289.303 +           xerror("glp_rmfgen: a_cap = %d; invalid offset\n", a_cap);
 289.304 +      }
 289.305 +      seed = parm[1];
 289.306 +      a = parm[2];
 289.307 +      b = parm[3];
 289.308 +      c1 = parm[4];
 289.309 +      c2 = parm[5];
 289.310 +      if (!(seed > 0 && 1 <= a && a <= 1000 && 1 <= b && b <= 1000 &&
 289.311 +            0 <= c1 && c1 <= c2 && c2 <= 1000))
 289.312 +      {  ret = 1;
 289.313 +         goto done;
 289.314 +      }
 289.315 +      if (G != NULL)
 289.316 +      {  glp_erase_graph(G, G->v_size, G->a_size);
 289.317 +         glp_set_graph_name(G, "RMFGEN");
 289.318 +      }
 289.319 +      csa->rand = rng_create_rand();
 289.320 +      rng_init_rand(csa->rand, seed);
 289.321 +      n = gen_rmf(csa, a, b, c1, c2);
 289.322 +      sprintf(comm[0], "This file was generated by genrmf.");
 289.323 +      sprintf(comm[1], "The parameters are: a: %d b: %d c1: %d c2: %d",
 289.324 +         a, b, c1, c2);
 289.325 +      com1[0] = comm[0];
 289.326 +      com1[1] = comm[1];
 289.327 +      print_max_format(csa, n, com1, 2);
 289.328 +      gen_free_net(n);
 289.329 +      rng_delete_rand(csa->rand);
 289.330 +      ret = 0;
 289.331 +done: return ret;
 289.332 +}
 289.333 +
 289.334 +/**********************************************************************/
 289.335 +
 289.336 +#if 0
 289.337 +int main(int argc, char *argv[])
 289.338 +{     int seed, a, b, c1, c2, i, parm[1+5];
 289.339 +      seed = 123;
 289.340 +      a = b = c1 = c2 = -1;
 289.341 +      for (i = 1; i < argc; i++)
 289.342 +      {  if (strcmp(argv[i], "-seed") == 0)
 289.343 +            seed = atoi(argv[++i]);
 289.344 +         else if (strcmp(argv[i], "-a") == 0)
 289.345 +            a = atoi(argv[++i]);
 289.346 +         else if (strcmp(argv[i], "-b") == 0)
 289.347 +            b = atoi(argv[++i]);
 289.348 +         else if (strcmp(argv[i], "-c1") == 0)
 289.349 +            c1 = atoi(argv[++i]);
 289.350 +         else if (strcmp(argv[i], "-c2") == 0)
 289.351 +            c2 = atoi(argv[++i]);
 289.352 +      }
 289.353 +      if (a < 0 || b < 0 || c1 < 0 || c2 < 0)
 289.354 +      {  xprintf("Usage:\n");
 289.355 +         xprintf("genrmf [-seed seed] -a frame_size -b depth\n");
 289.356 +         xprintf("        -c1 cap_range1 -c2 cap_range2\n");
 289.357 +      }
 289.358 +      else
 289.359 +      {  parm[1] = seed;
 289.360 +         parm[2] = a;
 289.361 +         parm[3] = b;
 289.362 +         parm[4] = c1;
 289.363 +         parm[5] = c2;
 289.364 +         glp_rmfgen(NULL, NULL, NULL, 0, parm);
 289.365 +      }
 289.366 +      return 0;
 289.367 +}
 289.368 +#endif
 289.369 +
 289.370 +/* eof */
   290.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
   290.2 +++ b/deps/glpk/src/glpnet06.c	Sun Nov 06 20:59:10 2011 +0100
   290.3 @@ -0,0 +1,383 @@
   290.4 +/* glpnet06.c (out-of-kilter algorithm) */
   290.5 +
   290.6 +/***********************************************************************
   290.7 +*  This code is part of GLPK (GNU Linear Programming Kit).
   290.8 +*
   290.9 +*  Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008,
  290.10 +*  2009, 2010, 2011 Andrew Makhorin, Department for Applied Informatics,
  290.11 +*  Moscow Aviation Institute, Moscow, Russia. All rights reserved.
  290.12 +*  E-mail: <mao@gnu.org>.
  290.13 +*
  290.14 +*  GLPK is free software: you can redistribute it and/or modify it
  290.15 +*  under the terms of the GNU General Public License as published by
  290.16 +*  the Free Software Foundation, either version 3 of the License, or
  290.17 +*  (at your option) any later version.
  290.18 +*
  290.19 +*  GLPK is distributed in the hope that it will be useful, but WITHOUT
  290.20 +*  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
  290.21 +*  or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
  290.22 +*  License for more details.
  290.23 +*
  290.24 +*  You should have received a copy of the GNU General Public License
  290.25 +*  along with GLPK. If not, see <http://www.gnu.org/licenses/>.
  290.26 +***********************************************************************/
  290.27 +
  290.28 +#include "glpenv.h"
  290.29 +#include "glpnet.h"
  290.30 +
  290.31 +/***********************************************************************
  290.32 +*  NAME
  290.33 +*
  290.34 +*  okalg - out-of-kilter algorithm
  290.35 +*
  290.36 +*  SYNOPSIS
  290.37 +*
  290.38 +*  #include "glpnet.h"
  290.39 +*  int okalg(int nv, int na, const int tail[], const int head[],
  290.40 +*     const int low[], const int cap[], const int cost[], int x[],
  290.41 +*     int pi[]);
  290.42 +*
  290.43 +*  DESCRIPTION
  290.44 +*
  290.45 +*  The routine okalg implements the out-of-kilter algorithm to find a
  290.46 +*  minimal-cost circulation in the specified flow network.
  290.47 +*
  290.48 +*  INPUT PARAMETERS
  290.49 +*
  290.50 +*  nv is the number of nodes, nv >= 0.
  290.51 +*
  290.52 +*  na is the number of arcs, na >= 0.
  290.53 +*
  290.54 +*  tail[a], a = 1,...,na, is the index of tail node of arc a.
  290.55 +*
  290.56 +*  head[a], a = 1,...,na, is the index of head node of arc a.
  290.57 +*
  290.58 +*  low[a], a = 1,...,na, is an lower bound to the flow through arc a.
  290.59 +*
  290.60 +*  cap[a], a = 1,...,na, is an upper bound to the flow through arc a,
  290.61 +*  which is the capacity of the arc.
  290.62 +*
  290.63 +*  cost[a], a = 1,...,na, is a per-unit cost of the flow through arc a.
  290.64 +*
  290.65 +*  NOTES
  290.66 +*
  290.67 +*  1. Multiple arcs are allowed, but self-loops are not allowed.
  290.68 +*
  290.69 +*  2. It is required that 0 <= low[a] <= cap[a] for all arcs.
  290.70 +*
  290.71 +*  3. Arc costs may have any sign.
  290.72 +*
  290.73 +*  OUTPUT PARAMETERS
  290.74 +*
  290.75 +*  x[a], a = 1,...,na, is optimal value of the flow through arc a.
  290.76 +*
  290.77 +*  pi[i], i = 1,...,nv, is Lagrange multiplier for flow conservation
  290.78 +*  equality constraint corresponding to node i (the node potential).
  290.79 +*
  290.80 +*  RETURNS
  290.81 +*
  290.82 +*  0  optimal circulation found;
  290.83 +*
  290.84 +*  1  there is no feasible circulation;
  290.85 +*
  290.86 +*  2  integer overflow occured;
  290.87 +*
  290.88 +*  3  optimality test failed (logic error).
  290.89 +*
  290.90 +*  REFERENCES
  290.91 +*
  290.92 +*  L.R.Ford, Jr., and D.R.Fulkerson, "Flows in Networks," The RAND
  290.93 +*  Corp., Report R-375-PR (August 1962), Chap. III "Minimal Cost Flow
  290.94 +*  Problems," pp.113-26. */
  290.95 +
  290.96 +static int overflow(int u, int v)
  290.97 +{     /* check for integer overflow on computing u + v */
  290.98 +      if (u > 0 && v > 0 && u + v < 0) return 1;
  290.99 +      if (u < 0 && v < 0 && u + v > 0) return 1;
 290.100 +      return 0;
 290.101 +}
 290.102 +
 290.103 +int okalg(int nv, int na, const int tail[], const int head[],
 290.104 +      const int low[], const int cap[], const int cost[], int x[],
 290.105 +      int pi[])
 290.106 +{     int a, aok, delta, i, j, k, lambda, pos1, pos2, s, t, temp, ret,
 290.107 +         *ptr, *arc, *link, *list;
 290.108 +      /* sanity checks */
 290.109 +      xassert(nv >= 0);
 290.110 +      xassert(na >= 0);
 290.111 +      for (a = 1; a <= na; a++)
 290.112 +      {  i = tail[a], j = head[a];
 290.113 +         xassert(1 <= i && i <= nv);
 290.114 +         xassert(1 <= j && j <= nv);
 290.115 +         xassert(i != j);
 290.116 +         xassert(0 <= low[a] && low[a] <= cap[a]);
 290.117 +      }
 290.118 +      /* allocate working arrays */
 290.119 +      ptr = xcalloc(1+nv+1, sizeof(int));
 290.120 +      arc = xcalloc(1+na+na, sizeof(int));
 290.121 +      link = xcalloc(1+nv, sizeof(int));
 290.122 +      list = xcalloc(1+nv, sizeof(int));
 290.123 +      /* ptr[i] := (degree of node i) */
 290.124 +      for (i = 1; i <= nv; i++)
 290.125 +         ptr[i] = 0;
 290.126 +      for (a = 1; a <= na; a++)
 290.127 +      {  ptr[tail[a]]++;
 290.128 +         ptr[head[a]]++;
 290.129 +      }
 290.130 +      /* initialize arc pointers */
 290.131 +      ptr[1]++;
 290.132 +      for (i = 1; i < nv; i++)
 290.133 +         ptr[i+1] += ptr[i];
 290.134 +      ptr[nv+1] = ptr[nv];
 290.135 +      /* build arc lists */
 290.136 +      for (a = 1; a <= na; a++)
 290.137 +      {  arc[--ptr[tail[a]]] = a;
 290.138 +         arc[--ptr[head[a]]] = a;
 290.139 +      }
 290.140 +      xassert(ptr[1] == 1);
 290.141 +      xassert(ptr[nv+1] == na+na+1);
 290.142 +      /* now the indices of arcs incident to node i are stored in
 290.143 +         locations arc[ptr[i]], arc[ptr[i]+1], ..., arc[ptr[i+1]-1] */
 290.144 +      /* initialize arc flows and node potentials */
 290.145 +      for (a = 1; a <= na; a++)
 290.146 +         x[a] = 0;
 290.147 +      for (i = 1; i <= nv; i++)
 290.148 +         pi[i] = 0;
 290.149 +loop: /* main loop starts here */
 290.150 +      /* find out-of-kilter arc */
 290.151 +      aok = 0;
 290.152 +      for (a = 1; a <= na; a++)
 290.153 +      {  i = tail[a], j = head[a];
 290.154 +         if (overflow(cost[a], pi[i] - pi[j]))
 290.155 +         {  ret = 2;
 290.156 +            goto done;
 290.157 +         }
 290.158 +         lambda = cost[a] + (pi[i] - pi[j]);
 290.159 +         if (x[a] < low[a] || lambda < 0 && x[a] < cap[a])
 290.160 +         {  /* arc a = i->j is out of kilter, and we need to increase
 290.161 +               the flow through this arc */
 290.162 +            aok = a, s = j, t = i;
 290.163 +            break;
 290.164 +         }
 290.165 +         if (x[a] > cap[a] || lambda > 0 && x[a] > low[a])
 290.166 +         {  /* arc a = i->j is out of kilter, and we need to decrease
 290.167 +               the flow through this arc */
 290.168 +            aok = a, s = i, t = j;
 290.169 +            break;
 290.170 +         }
 290.171 +      }
 290.172 +      if (aok == 0)
 290.173 +      {  /* all arcs are in kilter */
 290.174 +         /* check for feasibility */
 290.175 +         for (a = 1; a <= na; a++)
 290.176 +         {  if (!(low[a] <= x[a] && x[a] <= cap[a]))
 290.177 +            {  ret = 3;
 290.178 +               goto done;
 290.179 +            }
 290.180 +         }
 290.181 +         for (i = 1; i <= nv; i++)
 290.182 +         {  temp = 0;
 290.183 +            for (k = ptr[i]; k < ptr[i+1]; k++)
 290.184 +            {  a = arc[k];
 290.185 +               if (tail[a] == i)
 290.186 +               {  /* a is outgoing arc */
 290.187 +                  temp += x[a];
 290.188 +               }
 290.189 +               else if (head[a] == i)
 290.190 +               {  /* a is incoming arc */
 290.191 +                  temp -= x[a];
 290.192 +               }
 290.193 +               else
 290.194 +                  xassert(a != a);
 290.195 +            }
 290.196 +            if (temp != 0)
 290.197 +            {  ret = 3;
 290.198 +               goto done;
 290.199 +            }
 290.200 +         }
 290.201 +         /* check for optimality */
 290.202 +         for (a = 1; a <= na; a++)
 290.203 +         {  i = tail[a], j = head[a];
 290.204 +            lambda = cost[a] + (pi[i] - pi[j]);
 290.205 +            if (lambda > 0 && x[a] != low[a] ||
 290.206 +                lambda < 0 && x[a] != cap[a])
 290.207 +            {  ret = 3;
 290.208 +               goto done;
 290.209 +            }
 290.210 +         }
 290.211 +         /* current circulation is optimal */
 290.212 +         ret = 0;
 290.213 +         goto done;
 290.214 +      }
 290.215 +      /* now we need to find a cycle (t, a, s, ..., t), which allows
 290.216 +         increasing the flow along it, where a is the out-of-kilter arc
 290.217 +         just found */
 290.218 +      /* link[i] = 0 means that node i is not labelled yet;
 290.219 +         link[i] = a means that arc a immediately precedes node i */
 290.220 +      /* initially only node s is labelled */
 290.221 +      for (i = 1; i <= nv; i++)
 290.222 +         link[i] = 0;
 290.223 +      link[s] = aok, list[1] = s, pos1 = pos2 = 1;
 290.224 +      /* breadth first search */
 290.225 +      while (pos1 <= pos2)
 290.226 +      {  /* dequeue node i */
 290.227 +         i = list[pos1++];
 290.228 +         /* consider all arcs incident to node i */
 290.229 +         for (k = ptr[i]; k < ptr[i+1]; k++)
 290.230 +         {  a = arc[k];
 290.231 +            if (tail[a] == i)
 290.232 +            {  /* a = i->j is a forward arc from s to t */
 290.233 +               j = head[a];
 290.234 +               /* if node j has been labelled, skip the arc */
 290.235 +               if (link[j] != 0) continue;
 290.236 +               /* if the arc does not allow increasing the flow through
 290.237 +                  it, skip the arc */
 290.238 +               if (x[a] >= cap[a]) continue;
 290.239 +               if (overflow(cost[a], pi[i] - pi[j]))
 290.240 +               {  ret = 2;
 290.241 +                  goto done;
 290.242 +               }
 290.243 +               lambda = cost[a] + (pi[i] - pi[j]);
 290.244 +               if (lambda > 0 && x[a] >= low[a]) continue;
 290.245 +            }
 290.246 +            else if (head[a] == i)
 290.247 +            {  /* a = i<-j is a backward arc from s to t */
 290.248 +               j = tail[a];
 290.249 +               /* if node j has been labelled, skip the arc */
 290.250 +               if (link[j] != 0) continue;
 290.251 +               /* if the arc does not allow decreasing the flow through
 290.252 +                  it, skip the arc */
 290.253 +               if (x[a] <= low[a]) continue;
 290.254 +               if (overflow(cost[a], pi[j] - pi[i]))
 290.255 +               {  ret = 2;
 290.256 +                  goto done;
 290.257 +               }
 290.258 +               lambda = cost[a] + (pi[j] - pi[i]);
 290.259 +               if (lambda < 0 && x[a] <= cap[a]) continue;
 290.260 +            }
 290.261 +            else
 290.262 +               xassert(a != a);
 290.263 +            /* label node j and enqueue it */
 290.264 +            link[j] = a, list[++pos2] = j;
 290.265 +            /* check for breakthrough */
 290.266 +            if (j == t) goto brkt;
 290.267 +         }
 290.268 +      }
 290.269 +      /* NONBREAKTHROUGH */
 290.270 +      /* consider all arcs, whose one endpoint is labelled and other is
 290.271 +         not, and determine maximal change of node potentials */
 290.272 +      delta = 0;
 290.273 +      for (a = 1; a <= na; a++)
 290.274 +      {  i = tail[a], j = head[a];
 290.275 +         if (link[i] != 0 && link[j] == 0)
 290.276 +         {  /* a = i->j, where node i is labelled, node j is not */
 290.277 +            if (overflow(cost[a], pi[i] - pi[j]))
 290.278 +            {  ret = 2;
 290.279 +               goto done;
 290.280 +            }
 290.281 +            lambda = cost[a] + (pi[i] - pi[j]);
 290.282 +            if (x[a] <= cap[a] && lambda > 0)
 290.283 +               if (delta == 0 || delta > + lambda) delta = + lambda;
 290.284 +         }
 290.285 +         else if (link[i] == 0 && link[j] != 0)
 290.286 +         {  /* a = j<-i, where node j is labelled, node i is not */
 290.287 +            if (overflow(cost[a], pi[i] - pi[j]))
 290.288 +            {  ret = 2;
 290.289 +               goto done;
 290.290 +            }
 290.291 +            lambda = cost[a] + (pi[i] - pi[j]);
 290.292 +            if (x[a] >= low[a] && lambda < 0)
 290.293 +               if (delta == 0 || delta > - lambda) delta = - lambda;
 290.294 +         }
 290.295 +      }
 290.296 +      if (delta == 0)
 290.297 +      {  /* there is no feasible circulation */
 290.298 +         ret = 1;
 290.299 +         goto done;
 290.300 +      }
 290.301 +      /* increase potentials of all unlabelled nodes */
 290.302 +      for (i = 1; i <= nv; i++)
 290.303 +      {  if (link[i] == 0)
 290.304 +         {  if (overflow(pi[i], delta))
 290.305 +            {  ret = 2;
 290.306 +               goto done;
 290.307 +            }
 290.308 +            pi[i] += delta;
 290.309 +         }
 290.310 +      }
 290.311 +      goto loop;
 290.312 +brkt: /* BREAKTHROUGH */
 290.313 +      /* walk through arcs of the cycle (t, a, s, ..., t) found in the
 290.314 +         reverse order and determine maximal change of the flow */
 290.315 +      delta = 0;
 290.316 +      for (j = t;; j = i)
 290.317 +      {  /* arc a immediately precedes node j in the cycle */
 290.318 +         a = link[j];
 290.319 +         if (head[a] == j)
 290.320 +         {  /* a = i->j is a forward arc of the cycle */
 290.321 +            i = tail[a];
 290.322 +            lambda = cost[a] + (pi[i] - pi[j]);
 290.323 +            if (lambda > 0 && x[a] < low[a])
 290.324 +            {  /* x[a] may be increased until its lower bound */
 290.325 +               temp = low[a] - x[a];
 290.326 +            }
 290.327 +            else if (lambda <= 0 && x[a] < cap[a])
 290.328 +            {  /* x[a] may be increased until its upper bound */
 290.329 +               temp = cap[a] - x[a];
 290.330 +            }
 290.331 +            else
 290.332 +               xassert(a != a);
 290.333 +         }
 290.334 +         else if (tail[a] == j)
 290.335 +         {  /* a = i<-j is a backward arc of the cycle */
 290.336 +            i = head[a];
 290.337 +            lambda = cost[a] + (pi[j] - pi[i]);
 290.338 +            if (lambda < 0 && x[a] > cap[a])
 290.339 +            {  /* x[a] may be decreased until its upper bound */
 290.340 +               temp = x[a] - cap[a];
 290.341 +            }
 290.342 +            else if (lambda >= 0 && x[a] > low[a])
 290.343 +            {  /* x[a] may be decreased until its lower bound */
 290.344 +               temp = x[a] - low[a];
 290.345 +            }
 290.346 +            else
 290.347 +               xassert(a != a);
 290.348 +         }
 290.349 +         else
 290.350 +            xassert(a != a);
 290.351 +         if (delta == 0 || delta > temp) delta = temp;
 290.352 +         /* check for end of the cycle */
 290.353 +         if (i == t) break;
 290.354 +      }
 290.355 +      xassert(delta > 0);
 290.356 +      /* increase the flow along the cycle */
 290.357 +      for (j = t;; j = i)
 290.358 +      {  /* arc a immediately precedes node j in the cycle */
 290.359 +         a = link[j];
 290.360 +         if (head[a] == j)
 290.361 +         {  /* a = i->j is a forward arc of the cycle */
 290.362 +            i = tail[a];
 290.363 +            /* overflow cannot occur */
 290.364 +            x[a] += delta;
 290.365 +         }
 290.366 +         else if (tail[a] == j)
 290.367 +         {  /* a = i<-j is a backward arc of the cycle */
 290.368 +            i = head[a];
 290.369 +            /* overflow cannot occur */
 290.370 +            x[a] -= delta;
 290.371 +         }
 290.372 +         else
 290.373 +            xassert(a != a);
 290.374 +         /* check for end of the cycle */
 290.375 +         if (i == t) break;
 290.376 +      }
 290.377 +      goto loop;
 290.378 +done: /* free working arrays */
 290.379 +      xfree(ptr);
 290.380 +      xfree(arc);
 290.381 +      xfree(link);
 290.382 +      xfree(list);
 290.383 +      return ret;
 290.384 +}
 290.385 +
 290.386 +/* eof */
   291.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
   291.2 +++ b/deps/glpk/src/glpnet07.c	Sun Nov 06 20:59:10 2011 +0100
   291.3 @@ -0,0 +1,222 @@
   291.4 +/* glpnet07.c (Ford-Fulkerson algorithm) */
   291.5 +
   291.6 +/***********************************************************************
   291.7 +*  This code is part of GLPK (GNU Linear Programming Kit).
   291.8 +*
   291.9 +*  Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008,
  291.10 +*  2009, 2010, 2011 Andrew Makhorin, Department for Applied Informatics,
  291.11 +*  Moscow Aviation Institute, Moscow, Russia. All rights reserved.
  291.12 +*  E-mail: <mao@gnu.org>.
  291.13 +*
  291.14 +*  GLPK is free software: you can redistribute it and/or modify it
  291.15 +*  under the terms of the GNU General Public License as published by
  291.16 +*  the Free Software Foundation, either version 3 of the License, or
  291.17 +*  (at your option) any later version.
  291.18 +*
  291.19 +*  GLPK is distributed in the hope that it will be useful, but WITHOUT
  291.20 +*  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
  291.21 +*  or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
  291.22 +*  License for more details.
  291.23 +*
  291.24 +*  You should have received a copy of the GNU General Public License
  291.25 +*  along with GLPK. If not, see <http://www.gnu.org/licenses/>.
  291.26 +***********************************************************************/
  291.27 +
  291.28 +#include "glpenv.h"
  291.29 +#include "glpnet.h"
  291.30 +
  291.31 +/***********************************************************************
  291.32 +*  NAME
  291.33 +*
  291.34 +*  ffalg - Ford-Fulkerson algorithm
  291.35 +*
  291.36 +*  SYNOPSIS
  291.37 +*
  291.38 +*  #include "glpnet.h"
  291.39 +*  void ffalg(int nv, int na, const int tail[], const int head[],
  291.40 +*     int s, int t, const int cap[], int x[], char cut[]);
  291.41 +*
  291.42 +*  DESCRIPTION
  291.43 +*
  291.44 +*  The routine ffalg implements the Ford-Fulkerson algorithm to find a
  291.45 +*  maximal flow in the specified flow network.
  291.46 +*
  291.47 +*  INPUT PARAMETERS
  291.48 +*
  291.49 +*  nv is the number of nodes, nv >= 2.
  291.50 +*
  291.51 +*  na is the number of arcs, na >= 0.
  291.52 +*
  291.53 +*  tail[a], a = 1,...,na, is the index of tail node of arc a.
  291.54 +*
  291.55 +*  head[a], a = 1,...,na, is the index of head node of arc a.
  291.56 +*
  291.57 +*  s is the source node index, 1 <= s <= nv.
  291.58 +*
  291.59 +*  t is the sink node index, 1 <= t <= nv, t != s.
  291.60 +*
  291.61 +*  cap[a], a = 1,...,na, is the capacity of arc a, cap[a] >= 0.
  291.62 +*
  291.63 +*  NOTE: Multiple arcs are allowed, but self-loops are not allowed.
  291.64 +*
  291.65 +*  OUTPUT PARAMETERS
  291.66 +*
  291.67 +*  x[a], a = 1,...,na, is optimal value of the flow through arc a.
  291.68 +*
  291.69 +*  cut[i], i = 1,...,nv, is 1 if node i is labelled, and 0 otherwise.
  291.70 +*  The set of arcs, whose one endpoint is labelled and other is not,
  291.71 +*  defines the minimal cut corresponding to the maximal flow found.
  291.72 +*  If the parameter cut is NULL, the cut information are not stored.
  291.73 +*
  291.74 +*  REFERENCES
  291.75 +*
  291.76 +*  L.R.Ford, Jr., and D.R.Fulkerson, "Flows in Networks," The RAND
  291.77 +*  Corp., Report R-375-PR (August 1962), Chap. I "Static Maximal Flow,"
  291.78 +*  pp.30-33. */
  291.79 +
  291.80 +void ffalg(int nv, int na, const int tail[], const int head[],
  291.81 +      int s, int t, const int cap[], int x[], char cut[])
  291.82 +{     int a, delta, i, j, k, pos1, pos2, temp,
  291.83 +         *ptr, *arc, *link, *list;
  291.84 +      /* sanity checks */
  291.85 +      xassert(nv >= 2);
  291.86 +      xassert(na >= 0);
  291.87 +      xassert(1 <= s && s <= nv);
  291.88 +      xassert(1 <= t && t <= nv);
  291.89 +      xassert(s != t);
  291.90 +      for (a = 1; a <= na; a++)
  291.91 +      {  i = tail[a], j = head[a];
  291.92 +         xassert(1 <= i && i <= nv);
  291.93 +         xassert(1 <= j && j <= nv);
  291.94 +         xassert(i != j);
  291.95 +         xassert(cap[a] >= 0);
  291.96 +      }
  291.97 +      /* allocate working arrays */
  291.98 +      ptr = xcalloc(1+nv+1, sizeof(int));
  291.99 +      arc = xcalloc(1+na+na, sizeof(int));
 291.100 +      link = xcalloc(1+nv, sizeof(int));
 291.101 +      list = xcalloc(1+nv, sizeof(int));
 291.102 +      /* ptr[i] := (degree of node i) */
 291.103 +      for (i = 1; i <= nv; i++)
 291.104 +         ptr[i] = 0;
 291.105 +      for (a = 1; a <= na; a++)
 291.106 +      {  ptr[tail[a]]++;
 291.107 +         ptr[head[a]]++;
 291.108 +      }
 291.109 +      /* initialize arc pointers */
 291.110 +      ptr[1]++;
 291.111 +      for (i = 1; i < nv; i++)
 291.112 +         ptr[i+1] += ptr[i];
 291.113 +      ptr[nv+1] = ptr[nv];
 291.114 +      /* build arc lists */
 291.115 +      for (a = 1; a <= na; a++)
 291.116 +      {  arc[--ptr[tail[a]]] = a;
 291.117 +         arc[--ptr[head[a]]] = a;
 291.118 +      }
 291.119 +      xassert(ptr[1] == 1);
 291.120 +      xassert(ptr[nv+1] == na+na+1);
 291.121 +      /* now the indices of arcs incident to node i are stored in
 291.122 +         locations arc[ptr[i]], arc[ptr[i]+1], ..., arc[ptr[i+1]-1] */
 291.123 +      /* initialize arc flows */
 291.124 +      for (a = 1; a <= na; a++)
 291.125 +         x[a] = 0;
 291.126 +loop: /* main loop starts here */
 291.127 +      /* build augmenting tree rooted at s */
 291.128 +      /* link[i] = 0 means that node i is not labelled yet;
 291.129 +         link[i] = a means that arc a immediately precedes node i */
 291.130 +      /* initially node s is labelled as the root */
 291.131 +      for (i = 1; i <= nv; i++)
 291.132 +         link[i] = 0;
 291.133 +      link[s] = -1, list[1] = s, pos1 = pos2 = 1;
 291.134 +      /* breadth first search */
 291.135 +      while (pos1 <= pos2)
 291.136 +      {  /* dequeue node i */
 291.137 +         i = list[pos1++];
 291.138 +         /* consider all arcs incident to node i */
 291.139 +         for (k = ptr[i]; k < ptr[i+1]; k++)
 291.140 +         {  a = arc[k];
 291.141 +            if (tail[a] == i)
 291.142 +            {  /* a = i->j is a forward arc from s to t */
 291.143 +               j = head[a];
 291.144 +               /* if node j has been labelled, skip the arc */
 291.145 +               if (link[j] != 0) continue;
 291.146 +               /* if the arc does not allow increasing the flow through
 291.147 +                  it, skip the arc */
 291.148 +               if (x[a] == cap[a]) continue;
 291.149 +            }
 291.150 +            else if (head[a] == i)
 291.151 +            {  /* a = i<-j is a backward arc from s to t */
 291.152 +               j = tail[a];
 291.153 +               /* if node j has been labelled, skip the arc */
 291.154 +               if (link[j] != 0) continue;
 291.155 +               /* if the arc does not allow decreasing the flow through
 291.156 +                  it, skip the arc */
 291.157 +               if (x[a] == 0) continue;
 291.158 +            }
 291.159 +            else
 291.160 +               xassert(a != a);
 291.161 +            /* label node j and enqueue it */
 291.162 +            link[j] = a, list[++pos2] = j;
 291.163 +            /* check for breakthrough */
 291.164 +            if (j == t) goto brkt;
 291.165 +         }
 291.166 +      }
 291.167 +      /* NONBREAKTHROUGH */
 291.168 +      /* no augmenting path exists; current flow is maximal */
 291.169 +      /* store minimal cut information, if necessary */
 291.170 +      if (cut != NULL)
 291.171 +      {  for (i = 1; i <= nv; i++)
 291.172 +            cut[i] = (char)(link[i] != 0);
 291.173 +      }
 291.174 +      goto done;
 291.175 +brkt: /* BREAKTHROUGH */
 291.176 +      /* walk through arcs of the augmenting path (s, ..., t) found in
 291.177 +         the reverse order and determine maximal change of the flow */
 291.178 +      delta = 0;
 291.179 +      for (j = t; j != s; j = i)
 291.180 +      {  /* arc a immediately precedes node j in the path */
 291.181 +         a = link[j];
 291.182 +         if (head[a] == j)
 291.183 +         {  /* a = i->j is a forward arc of the cycle */
 291.184 +            i = tail[a];
 291.185 +            /* x[a] may be increased until its upper bound */
 291.186 +            temp = cap[a] - x[a];
 291.187 +         }
 291.188 +         else if (tail[a] == j)
 291.189 +         {  /* a = i<-j is a backward arc of the cycle */
 291.190 +            i = head[a];
 291.191 +            /* x[a] may be decreased until its lower bound */
 291.192 +            temp = x[a];
 291.193 +         }
 291.194 +         else
 291.195 +            xassert(a != a);
 291.196 +         if (delta == 0 || delta > temp) delta = temp;
 291.197 +      }
 291.198 +      xassert(delta > 0);
 291.199 +      /* increase the flow along the path */
 291.200 +      for (j = t; j != s; j = i)
 291.201 +      {  /* arc a immediately precedes node j in the path */
 291.202 +         a = link[j];
 291.203 +         if (head[a] == j)
 291.204 +         {  /* a = i->j is a forward arc of the cycle */
 291.205 +            i = tail[a];
 291.206 +            x[a] += delta;
 291.207 +         }
 291.208 +         else if (tail[a] == j)
 291.209 +         {  /* a = i<-j is a backward arc of the cycle */
 291.210 +            i = head[a];
 291.211 +            x[a] -= delta;
 291.212 +         }
 291.213 +         else
 291.214 +            xassert(a != a);
 291.215 +      }
 291.216 +      goto loop;
 291.217 +done: /* free working arrays */
 291.218 +      xfree(ptr);
 291.219 +      xfree(arc);
 291.220 +      xfree(link);
 291.221 +      xfree(list);
 291.222 +      return;
 291.223 +}
 291.224 +
 291.225 +/* eof */
   292.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
   292.2 +++ b/deps/glpk/src/glpnet08.c	Sun Nov 06 20:59:10 2011 +0100
   292.3 @@ -0,0 +1,241 @@
   292.4 +/* glpnet08.c */
   292.5 +
   292.6 +/***********************************************************************
   292.7 +*  This code is part of GLPK (GNU Linear Programming Kit).
   292.8 +*
   292.9 +*  Two subroutines sub() and wclique() below are intended to find a
  292.10 +*  maximum weight clique in a given undirected graph. These subroutines
  292.11 +*  are slightly modified version of the program WCLIQUE developed by
  292.12 +*  Patric Ostergard <http://www.tcs.hut.fi/~pat/wclique.html> and based
  292.13 +*  on ideas from the article "P. R. J. Ostergard, A new algorithm for
  292.14 +*  the maximum-weight clique problem, submitted for publication", which
  292.15 +*  in turn is a generalization of the algorithm for unweighted graphs
  292.16 +*  presented in "P. R. J. Ostergard, A fast algorithm for the maximum
  292.17 +*  clique problem, submitted for publication".
  292.18 +*
  292.19 +*  USED WITH PERMISSION OF THE AUTHOR OF THE ORIGINAL CODE.
  292.20 +*
  292.21 +*  Changes were made by Andrew Makhorin <mao@gnu.org>.
  292.22 +*
  292.23 +*  GLPK is free software: you can redistribute it and/or modify it
  292.24 +*  under the terms of the GNU General Public License as published by
  292.25 +*  the Free Software Foundation, either version 3 of the License, or
  292.26 +*  (at your option) any later version.
  292.27 +*
  292.28 +*  GLPK is distributed in the hope that it will be useful, but WITHOUT
  292.29 +*  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
  292.30 +*  or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
  292.31 +*  License for more details.
  292.32 +*
  292.33 +*  You should have received a copy of the GNU General Public License
  292.34 +*  along with GLPK. If not, see <http://www.gnu.org/licenses/>.
  292.35 +***********************************************************************/
  292.36 +
  292.37 +#include "glpenv.h"
  292.38 +#include "glpnet.h"
  292.39 +
  292.40 +/***********************************************************************
  292.41 +*  NAME
  292.42 +*
  292.43 +*  wclique - find maximum weight clique with Ostergard's algorithm
  292.44 +*
  292.45 +*  SYNOPSIS
  292.46 +*
  292.47 +*  int wclique(int n, const int w[], const unsigned char a[],
  292.48 +*     int ind[]);
  292.49 +*
  292.50 +*  DESCRIPTION
  292.51 +*
  292.52 +*  The routine wclique finds a maximum weight clique in an undirected
  292.53 +*  graph with Ostergard's algorithm.
  292.54 +*
  292.55 +*  INPUT PARAMETERS
  292.56 +*
  292.57 +*  n is the number of vertices, n > 0.
  292.58 +*
  292.59 +*  w[i], i = 1,...,n, is a weight of vertex i.
  292.60 +*
  292.61 +*  a[*] is the strict (without main diagonal) lower triangle of the
  292.62 +*  graph adjacency matrix in packed format.
  292.63 +*
  292.64 +*  OUTPUT PARAMETER
  292.65 +*
  292.66 +*  ind[k], k = 1,...,size, is the number of a vertex included in the
  292.67 +*  clique found, 1 <= ind[k] <= n, where size is the number of vertices
  292.68 +*  in the clique returned on exit.
  292.69 +*
  292.70 +*  RETURNS
  292.71 +*
  292.72 +*  The routine returns the clique size, i.e. the number of vertices in
  292.73 +*  the clique. */
  292.74 +
  292.75 +struct csa
  292.76 +{     /* common storage area */
  292.77 +      int n;
  292.78 +      /* number of vertices */
  292.79 +      const int *wt; /* int wt[0:n-1]; */
  292.80 +      /* weights */
  292.81 +      const unsigned char *a;
  292.82 +      /* adjacency matrix (packed lower triangle without main diag.) */
  292.83 +      int record;
  292.84 +      /* weight of best clique */
  292.85 +      int rec_level;
  292.86 +      /* number of vertices in best clique */
  292.87 +      int *rec; /* int rec[0:n-1]; */
  292.88 +      /* best clique so far */
  292.89 +      int *clique; /* int clique[0:n-1]; */
  292.90 +      /* table for pruning */
  292.91 +      int *set; /* int set[0:n-1]; */
  292.92 +      /* current clique */
  292.93 +};
  292.94 +
  292.95 +#define n         (csa->n)
  292.96 +#define wt        (csa->wt)
  292.97 +#define a         (csa->a)
  292.98 +#define record    (csa->record)
  292.99 +#define rec_level (csa->rec_level)
 292.100 +#define rec       (csa->rec)
 292.101 +#define clique    (csa->clique)
 292.102 +#define set       (csa->set)
 292.103 +
 292.104 +#if 0
 292.105 +static int is_edge(struct csa *csa, int i, int j)
 292.106 +{     /* if there is arc (i,j), the routine returns true; otherwise
 292.107 +         false; 0 <= i, j < n */
 292.108 +      int k;
 292.109 +      xassert(0 <= i && i < n);
 292.110 +      xassert(0 <= j && j < n);
 292.111 +      if (i == j) return 0;
 292.112 +      if (i < j) k = i, i = j, j = k;
 292.113 +      k = (i * (i - 1)) / 2 + j;
 292.114 +      return a[k / CHAR_BIT] &
 292.115 +         (unsigned char)(1 << ((CHAR_BIT - 1) - k % CHAR_BIT));
 292.116 +}
 292.117 +#else
 292.118 +#define is_edge(csa, i, j) ((i) == (j) ? 0 : \
 292.119 +      (i) > (j) ? is_edge1(i, j) : is_edge1(j, i))
 292.120 +#define is_edge1(i, j) is_edge2(((i) * ((i) - 1)) / 2 + (j))
 292.121 +#define is_edge2(k) (a[(k) / CHAR_BIT] & \
 292.122 +      (unsigned char)(1 << ((CHAR_BIT - 1) - (k) % CHAR_BIT)))
 292.123 +#endif
 292.124 +
 292.125 +static void sub(struct csa *csa, int ct, int table[], int level,
 292.126 +      int weight, int l_weight)
 292.127 +{     int i, j, k, curr_weight, left_weight, *p1, *p2, *newtable;
 292.128 +      newtable = xcalloc(n, sizeof(int));
 292.129 +      if (ct <= 0)
 292.130 +      {  /* 0 or 1 elements left; include these */
 292.131 +         if (ct == 0)
 292.132 +         {  set[level++] = table[0];
 292.133 +            weight += l_weight;
 292.134 +         }
 292.135 +         if (weight > record)
 292.136 +         {  record = weight;
 292.137 +            rec_level = level;
 292.138 +            for (i = 0; i < level; i++) rec[i] = set[i];
 292.139 +         }
 292.140 +         goto done;
 292.141 +      }
 292.142 +      for (i = ct; i >= 0; i--)
 292.143 +      {  if ((level == 0) && (i < ct)) goto done;
 292.144 +         k = table[i];
 292.145 +         if ((level > 0) && (clique[k] <= (record - weight)))
 292.146 +            goto done; /* prune */
 292.147 +         set[level] = k;
 292.148 +         curr_weight = weight + wt[k];
 292.149 +         l_weight -= wt[k];
 292.150 +         if (l_weight <= (record - curr_weight))
 292.151 +            goto done; /* prune */
 292.152 +         p1 = newtable;
 292.153 +         p2 = table;
 292.154 +         left_weight = 0;
 292.155 +         while (p2 < table + i)
 292.156 +         {  j = *p2++;
 292.157 +            if (is_edge(csa, j, k))
 292.158 +            {  *p1++ = j;
 292.159 +               left_weight += wt[j];
 292.160 +            }
 292.161 +         }
 292.162 +         if (left_weight <= (record - curr_weight)) continue;
 292.163 +         sub(csa, p1 - newtable - 1, newtable, level + 1, curr_weight,
 292.164 +            left_weight);
 292.165 +      }
 292.166 +done: xfree(newtable);
 292.167 +      return;
 292.168 +}
 292.169 +
 292.170 +int wclique(int _n, const int w[], const unsigned char _a[], int ind[])
 292.171 +{     struct csa _csa, *csa = &_csa;
 292.172 +      int i, j, p, max_wt, max_nwt, wth, *used, *nwt, *pos;
 292.173 +      glp_long timer;
 292.174 +      n = _n;
 292.175 +      xassert(n > 0);
 292.176 +      wt = &w[1];
 292.177 +      a = _a;
 292.178 +      record = 0;
 292.179 +      rec_level = 0;
 292.180 +      rec = &ind[1];
 292.181 +      clique = xcalloc(n, sizeof(int));
 292.182 +      set = xcalloc(n, sizeof(int));
 292.183 +      used = xcalloc(n, sizeof(int));
 292.184 +      nwt = xcalloc(n, sizeof(int));
 292.185 +      pos = xcalloc(n, sizeof(int));
 292.186 +      /* start timer */
 292.187 +      timer = xtime();
 292.188 +      /* order vertices */
 292.189 +      for (i = 0; i < n; i++)
 292.190 +      {  nwt[i] = 0;
 292.191 +         for (j = 0; j < n; j++)
 292.192 +            if (is_edge(csa, i, j)) nwt[i] += wt[j];
 292.193 +      }
 292.194 +      for (i = 0; i < n; i++)
 292.195 +         used[i] = 0;
 292.196 +      for (i = n-1; i >= 0; i--)
 292.197 +      {  max_wt = -1;
 292.198 +         max_nwt = -1;
 292.199 +         for (j = 0; j < n; j++)
 292.200 +         {  if ((!used[j]) && ((wt[j] > max_wt) || (wt[j] == max_wt
 292.201 +               && nwt[j] > max_nwt)))
 292.202 +            {  max_wt = wt[j];
 292.203 +               max_nwt = nwt[j];
 292.204 +               p = j;
 292.205 +            }
 292.206 +         }
 292.207 +         pos[i] = p;
 292.208 +         used[p] = 1;
 292.209 +         for (j = 0; j < n; j++)
 292.210 +            if ((!used[j]) && (j != p) && (is_edge(csa, p, j)))
 292.211 +               nwt[j] -= wt[p];
 292.212 +      }
 292.213 +      /* main routine */
 292.214 +      wth = 0;
 292.215 +      for (i = 0; i < n; i++)
 292.216 +      {  wth += wt[pos[i]];
 292.217 +         sub(csa, i, pos, 0, 0, wth);
 292.218 +         clique[pos[i]] = record;
 292.219 +         if (xdifftime(xtime(), timer) >= 5.0 - 0.001)
 292.220 +         {  /* print current record and reset timer */
 292.221 +            xprintf("level = %d (%d); best = %d\n", i+1, n, record);
 292.222 +            timer = xtime();
 292.223 +         }
 292.224 +      }
 292.225 +      xfree(clique);
 292.226 +      xfree(set);
 292.227 +      xfree(used);
 292.228 +      xfree(nwt);
 292.229 +      xfree(pos);
 292.230 +      /* return the solution found */
 292.231 +      for (i = 1; i <= rec_level; i++) ind[i]++;
 292.232 +      return rec_level;
 292.233 +}
 292.234 +
 292.235 +#undef n
 292.236 +#undef wt
 292.237 +#undef a
 292.238 +#undef record
 292.239 +#undef rec_level
 292.240 +#undef rec
 292.241 +#undef clique
 292.242 +#undef set
 292.243 +
 292.244 +/* eof */
   293.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
   293.2 +++ b/deps/glpk/src/glpnet09.c	Sun Nov 06 20:59:10 2011 +0100
   293.3 @@ -0,0 +1,235 @@
   293.4 +/* glpnet09.c */
   293.5 +
   293.6 +/***********************************************************************
   293.7 +*  This code is part of GLPK (GNU Linear Programming Kit).
   293.8 +*
   293.9 +*  Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008,
  293.10 +*  2009, 2010, 2011 Andrew Makhorin, Department for Applied Informatics,
  293.11 +*  Moscow Aviation Institute, Moscow, Russia. All rights reserved.
  293.12 +*  E-mail: <mao@gnu.org>.
  293.13 +*
  293.14 +*  GLPK is free software: you can redistribute it and/or modify it
  293.15 +*  under the terms of the GNU General Public License as published by
  293.16 +*  the Free Software Foundation, either version 3 of the License, or
  293.17 +*  (at your option) any later version.
  293.18 +*
  293.19 +*  GLPK is distributed in the hope that it will be useful, but WITHOUT
  293.20 +*  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
  293.21 +*  or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
  293.22 +*  License for more details.
  293.23 +*
  293.24 +*  You should have received a copy of the GNU General Public License
  293.25 +*  along with GLPK. If not, see <http://www.gnu.org/licenses/>.
  293.26 +***********************************************************************/
  293.27 +
  293.28 +#include "glpapi.h"
  293.29 +#include "glpnet.h"
  293.30 +
  293.31 +/***********************************************************************
  293.32 +*  NAME
  293.33 +*
  293.34 +*  kellerman - cover edges by cliques with Kellerman's heuristic
  293.35 +*
  293.36 +*  SYNOPSIS
  293.37 +*
  293.38 +*  #include "glpnet.h"
  293.39 +*  int kellerman(int n, int (*func)(void *info, int i, int ind[]),
  293.40 +*     void *info, glp_graph *H);
  293.41 +*
  293.42 +*  DESCRIPTION
  293.43 +*
  293.44 +*  The routine kellerman implements Kellerman's heuristic algorithm
  293.45 +*  to find a minimal set of cliques which cover all edges of specified
  293.46 +*  graph G = (V, E).
  293.47 +*
  293.48 +*  The parameter n specifies the number of vertices |V|, n >= 0.
  293.49 +*
  293.50 +*  Formal routine func specifies the set of edges E in the following
  293.51 +*  way. Running the routine kellerman calls the routine func and passes
  293.52 +*  to it parameter i, which is the number of some vertex, 1 <= i <= n.
  293.53 +*  In response the routine func should store numbers of all vertices
  293.54 +*  adjacent to vertex i to locations ind[1], ind[2], ..., ind[len] and
  293.55 +*  return the value of len, which is the number of adjacent vertices,
  293.56 +*  0 <= len <= n. Self-loops are allowed, but ignored. Multiple edges
  293.57 +*  are not allowed.
  293.58 +*
  293.59 +*  The parameter info is a transit pointer (magic cookie) passed to the
  293.60 +*  formal routine func as its first parameter.
  293.61 +*
  293.62 +*  The result provided by the routine kellerman is the bipartite graph
  293.63 +*  H = (V union C, F), which defines the covering found. (The program
  293.64 +*  object of type glp_graph specified by the parameter H should be
  293.65 +*  previously created with the routine glp_create_graph. On entry the
  293.66 +*  routine kellerman erases the content of this object with the routine
  293.67 +*  glp_erase_graph.) Vertices of first part V correspond to vertices of
  293.68 +*  the graph G and have the same ordinal numbers 1, 2, ..., n. Vertices
  293.69 +*  of second part C correspond to cliques and have ordinal numbers
  293.70 +*  n+1, n+2, ..., n+k, where k is the total number of cliques in the
  293.71 +*  edge covering found. Every edge f in F in the program object H is
  293.72 +*  represented as arc f = (i->j), where i in V and j in C, which means
  293.73 +*  that vertex i of the graph G is in clique C[j], 1 <= j <= k. (Thus,
  293.74 +*  if two vertices of the graph G are in the same clique, these vertices
  293.75 +*  are adjacent in G, and corresponding edge is covered by that clique.)
  293.76 +*
  293.77 +*  RETURNS
  293.78 +*
  293.79 +*  The routine Kellerman returns k, the total number of cliques in the
  293.80 +*  edge covering found.
  293.81 +*
  293.82 +*  REFERENCE
  293.83 +*
  293.84 +*  For more details see: glpk/doc/notes/keller.pdf (in Russian). */
  293.85 +
  293.86 +struct set
  293.87 +{     /* set of vertices */
  293.88 +      int size;
  293.89 +      /* size (cardinality) of the set, 0 <= card <= n */
  293.90 +      int *list; /* int list[1+n]; */
  293.91 +      /* the set contains vertices list[1,...,size] */
  293.92 +      int *pos; /* int pos[1+n]; */
  293.93 +      /* pos[i] > 0 means that vertex i is in the set and
  293.94 +         list[pos[i]] = i; pos[i] = 0 means that vertex i is not in
  293.95 +         the set */
  293.96 +};
  293.97 +
  293.98 +int kellerman(int n, int (*func)(void *info, int i, int ind[]),
  293.99 +      void *info, void /* glp_graph */ *H_)
 293.100 +{     glp_graph *H = H_;
 293.101 +      struct set W_, *W = &W_, V_, *V = &V_;
 293.102 +      glp_arc *a;
 293.103 +      int i, j, k, m, t, len, card, best;
 293.104 +      xassert(n >= 0);
 293.105 +      /* H := (V, 0; 0), where V is the set of vertices of graph G */
 293.106 +      glp_erase_graph(H, H->v_size, H->a_size);
 293.107 +      glp_add_vertices(H, n);
 293.108 +      /* W := 0 */
 293.109 +      W->size = 0;
 293.110 +      W->list = xcalloc(1+n, sizeof(int));
 293.111 +      W->pos = xcalloc(1+n, sizeof(int));
 293.112 +      memset(&W->pos[1], 0, sizeof(int) * n);
 293.113 +      /* V := 0 */
 293.114 +      V->size = 0;
 293.115 +      V->list = xcalloc(1+n, sizeof(int));
 293.116 +      V->pos = xcalloc(1+n, sizeof(int));
 293.117 +      memset(&V->pos[1], 0, sizeof(int) * n);
 293.118 +      /* main loop */
 293.119 +      for (i = 1; i <= n; i++)
 293.120 +      {  /* W must be empty */
 293.121 +         xassert(W->size == 0);
 293.122 +         /* W := { j : i > j and (i,j) in E } */
 293.123 +         len = func(info, i, W->list);
 293.124 +         xassert(0 <= len && len <= n);
 293.125 +         for (t = 1; t <= len; t++)
 293.126 +         {  j = W->list[t];
 293.127 +            xassert(1 <= j && j <= n);
 293.128 +            if (j >= i) continue;
 293.129 +            xassert(W->pos[j] == 0);
 293.130 +            W->list[++W->size] = j, W->pos[j] = W->size;
 293.131 +         }
 293.132 +         /* on i-th iteration we need to cover edges (i,j) for all
 293.133 +            j in W */
 293.134 +         /* if W is empty, it is a special case */
 293.135 +         if (W->size == 0)
 293.136 +         {  /* set k := k + 1 and create new clique C[k] = { i } */
 293.137 +            k = glp_add_vertices(H, 1) - n;
 293.138 +            glp_add_arc(H, i, n + k);
 293.139 +            continue;
 293.140 +         }
 293.141 +         /* try to include vertex i into existing cliques */
 293.142 +         /* V must be empty */
 293.143 +         xassert(V->size == 0);
 293.144 +         /* k is the number of cliques found so far */
 293.145 +         k = H->nv - n;
 293.146 +         for (m = 1; m <= k; m++)
 293.147 +         {  /* do while V != W; since here V is within W, we can use
 293.148 +               equivalent condition: do while |V| < |W| */
 293.149 +            if (V->size == W->size) break;
 293.150 +            /* check if C[m] is within W */
 293.151 +            for (a = H->v[n + m]->in; a != NULL; a = a->h_next)
 293.152 +            {  j = a->tail->i;
 293.153 +               if (W->pos[j] == 0) break;
 293.154 +            }
 293.155 +            if (a != NULL) continue;
 293.156 +            /* C[m] is within W, expand clique C[m] with vertex i */
 293.157 +            /* C[m] := C[m] union {i} */
 293.158 +            glp_add_arc(H, i, n + m);
 293.159 +            /* V is a set of vertices whose incident edges are already
 293.160 +               covered by existing cliques */
 293.161 +            /* V := V union C[m] */
 293.162 +            for (a = H->v[n + m]->in; a != NULL; a = a->h_next)
 293.163 +            {  j = a->tail->i;
 293.164 +               if (V->pos[j] == 0)
 293.165 +                  V->list[++V->size] = j, V->pos[j] = V->size;
 293.166 +            }
 293.167 +         }
 293.168 +         /* remove from set W the vertices whose incident edges are
 293.169 +            already covered by existing cliques */
 293.170 +         /* W := W \ V, V := 0 */
 293.171 +         for (t = 1; t <= V->size; t++)
 293.172 +         {  j = V->list[t], V->pos[j] = 0;
 293.173 +            if (W->pos[j] != 0)
 293.174 +            {  /* remove vertex j from W */
 293.175 +               if (W->pos[j] != W->size)
 293.176 +               {  int jj = W->list[W->size];
 293.177 +                  W->list[W->pos[j]] = jj;
 293.178 +                  W->pos[jj] = W->pos[j];
 293.179 +               }
 293.180 +               W->size--, W->pos[j] = 0;
 293.181 +            }
 293.182 +         }
 293.183 +         V->size = 0;
 293.184 +         /* now set W contains only vertices whose incident edges are
 293.185 +            still not covered by existing cliques; create new cliques
 293.186 +            to cover remaining edges until set W becomes empty */
 293.187 +         while (W->size > 0)
 293.188 +         {  /* find clique C[m], 1 <= m <= k, which shares maximal
 293.189 +               number of vertices with W; to break ties choose clique
 293.190 +               having smallest number m */
 293.191 +            m = 0, best = -1;
 293.192 +            k = H->nv - n;
 293.193 +            for (t = 1; t <= k; t++)
 293.194 +            {  /* compute cardinality of intersection of W and C[t] */
 293.195 +               card = 0;
 293.196 +               for (a = H->v[n + t]->in; a != NULL; a = a->h_next)
 293.197 +               {  j = a->tail->i;
 293.198 +                  if (W->pos[j] != 0) card++;
 293.199 +               }
 293.200 +               if (best < card)
 293.201 +                  m = t, best = card;
 293.202 +            }
 293.203 +            xassert(m > 0);
 293.204 +            /* set k := k + 1 and create new clique:
 293.205 +               C[k] := (W intersect C[m]) union { i }, which covers all
 293.206 +               edges incident to vertices from (W intersect C[m]) */
 293.207 +            k = glp_add_vertices(H, 1) - n;
 293.208 +            for (a = H->v[n + m]->in; a != NULL; a = a->h_next)
 293.209 +            {  j = a->tail->i;
 293.210 +               if (W->pos[j] != 0)
 293.211 +               {  /* vertex j is in both W and C[m]; include it in new
 293.212 +                     clique C[k] */
 293.213 +                  glp_add_arc(H, j, n + k);
 293.214 +                  /* remove vertex j from W, since edge (i,j) will be
 293.215 +                     covered by new clique C[k] */
 293.216 +                  if (W->pos[j] != W->size)
 293.217 +                  {  int jj = W->list[W->size];
 293.218 +                     W->list[W->pos[j]] = jj;
 293.219 +                     W->pos[jj] = W->pos[j];
 293.220 +                  }
 293.221 +                  W->size--, W->pos[j] = 0;
 293.222 +               }
 293.223 +            }
 293.224 +            /* include vertex i to new clique C[k] to cover edges (i,j)
 293.225 +               incident to all vertices j just removed from W */
 293.226 +            glp_add_arc(H, i, n + k);
 293.227 +         }
 293.228 +      }
 293.229 +      /* free working arrays */
 293.230 +      xfree(W->list);
 293.231 +      xfree(W->pos);
 293.232 +      xfree(V->list);
 293.233 +      xfree(V->pos);
 293.234 +      /* return the number of cliques in the edge covering found */
 293.235 +      return H->nv - n;
 293.236 +}
 293.237 +
 293.238 +/* eof */
   294.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
   294.2 +++ b/deps/glpk/src/glpnpp.h	Sun Nov 06 20:59:10 2011 +0100
   294.3 @@ -0,0 +1,638 @@
   294.4 +/* glpnpp.h (LP/MIP preprocessor) */
   294.5 +
   294.6 +/***********************************************************************
   294.7 +*  This code is part of GLPK (GNU Linear Programming Kit).
   294.8 +*
   294.9 +*  Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008,
  294.10 +*  2009, 2010, 2011 Andrew Makhorin, Department for Applied Informatics,
  294.11 +*  Moscow Aviation Institute, Moscow, Russia. All rights reserved.
  294.12 +*  E-mail: <mao@gnu.org>.
  294.13 +*
  294.14 +*  GLPK is free software: you can redistribute it and/or modify it
  294.15 +*  under the terms of the GNU General Public License as published by
  294.16 +*  the Free Software Foundation, either version 3 of the License, or
  294.17 +*  (at your option) any later version.
  294.18 +*
  294.19 +*  GLPK is distributed in the hope that it will be useful, but WITHOUT
  294.20 +*  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
  294.21 +*  or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
  294.22 +*  License for more details.
  294.23 +*
  294.24 +*  You should have received a copy of the GNU General Public License
  294.25 +*  along with GLPK. If not, see <http://www.gnu.org/licenses/>.
  294.26 +***********************************************************************/
  294.27 +
  294.28 +#ifndef GLPNPP_H
  294.29 +#define GLPNPP_H
  294.30 +
  294.31 +#include "glpapi.h"
  294.32 +
  294.33 +typedef struct NPP NPP;
  294.34 +typedef struct NPPROW NPPROW;
  294.35 +typedef struct NPPCOL NPPCOL;
  294.36 +typedef struct NPPAIJ NPPAIJ;
  294.37 +typedef struct NPPTSE NPPTSE;
  294.38 +typedef struct NPPLFE NPPLFE;
  294.39 +
  294.40 +struct NPP
  294.41 +{     /* LP/MIP preprocessor workspace */
  294.42 +      /*--------------------------------------------------------------*/
  294.43 +      /* original problem segment */
  294.44 +      int orig_dir;
  294.45 +      /* optimization direction flag:
  294.46 +         GLP_MIN - minimization
  294.47 +         GLP_MAX - maximization */
  294.48 +      int orig_m;
  294.49 +      /* number of rows */
  294.50 +      int orig_n;
  294.51 +      /* number of columns */
  294.52 +      int orig_nnz;
  294.53 +      /* number of non-zero constraint coefficients */
  294.54 +      /*--------------------------------------------------------------*/
  294.55 +      /* transformed problem segment (always minimization) */
  294.56 +      DMP *pool;
  294.57 +      /* memory pool to store problem components */
  294.58 +      char *name;
  294.59 +      /* problem name (1 to 255 chars); NULL means no name is assigned
  294.60 +         to the problem */
  294.61 +      char *obj;
  294.62 +      /* objective function name (1 to 255 chars); NULL means no name
  294.63 +         is assigned to the objective function */
  294.64 +      double c0;
  294.65 +      /* constant term of the objective function */
  294.66 +      int nrows;
  294.67 +      /* number of rows introduced into the problem; this count
  294.68 +         increases by one every time a new row is added and never
  294.69 +         decreases; thus, actual number of rows may be less than nrows
  294.70 +         due to row deletions */
  294.71 +      int ncols;
  294.72 +      /* number of columns introduced into the problem; this count
  294.73 +         increases by one every time a new column is added and never
  294.74 +         decreases; thus, actual number of column may be less than
  294.75 +         ncols due to column deletions */
  294.76 +      NPPROW *r_head;
  294.77 +      /* pointer to the beginning of the row list */
  294.78 +      NPPROW *r_tail;
  294.79 +      /* pointer to the end of the row list */
  294.80 +      NPPCOL *c_head;
  294.81 +      /* pointer to the beginning of the column list */
  294.82 +      NPPCOL *c_tail;
  294.83 +      /* pointer to the end of the column list */
  294.84 +      /*--------------------------------------------------------------*/
  294.85 +      /* transformation history */
  294.86 +      DMP *stack;
  294.87 +      /* memory pool to store transformation entries */
  294.88 +      NPPTSE *top;
  294.89 +      /* pointer to most recent transformation entry */
  294.90 +#if 0 /* 16/XII-2009 */
  294.91 +      int count[1+25];
  294.92 +      /* transformation statistics */
  294.93 +#endif
  294.94 +      /*--------------------------------------------------------------*/
  294.95 +      /* resultant (preprocessed) problem segment */
  294.96 +      int m;
  294.97 +      /* number of rows */
  294.98 +      int n;
  294.99 +      /* number of columns */
 294.100 +      int nnz;
 294.101 +      /* number of non-zero constraint coefficients */
 294.102 +      int *row_ref; /* int row_ref[1+m]; */
 294.103 +      /* row_ref[i], 1 <= i <= m, is the reference number assigned to
 294.104 +         a row, which is i-th row of the resultant problem */
 294.105 +      int *col_ref; /* int col_ref[1+n]; */
 294.106 +      /* col_ref[j], 1 <= j <= n, is the reference number assigned to
 294.107 +         a column, which is j-th column of the resultant problem */
 294.108 +      /*--------------------------------------------------------------*/
 294.109 +      /* recovered solution segment */
 294.110 +      int sol;
 294.111 +      /* solution indicator:
 294.112 +         GLP_SOL - basic solution
 294.113 +         GLP_IPT - interior-point solution
 294.114 +         GLP_MIP - mixed integer solution */
 294.115 +      int scaling;
 294.116 +      /* scaling option:
 294.117 +         GLP_OFF - scaling is disabled
 294.118 +         GLP_ON  - scaling is enabled */
 294.119 +      int p_stat;
 294.120 +      /* status of primal basic solution:
 294.121 +         GLP_UNDEF  - primal solution is undefined
 294.122 +         GLP_FEAS   - primal solution is feasible
 294.123 +         GLP_INFEAS - primal solution is infeasible
 294.124 +         GLP_NOFEAS - no primal feasible solution exists */
 294.125 +      int d_stat;
 294.126 +      /* status of dual basic solution:
 294.127 +         GLP_UNDEF  - dual solution is undefined
 294.128 +         GLP_FEAS   - dual solution is feasible
 294.129 +         GLP_INFEAS - dual solution is infeasible
 294.130 +         GLP_NOFEAS - no dual feasible solution exists */
 294.131 +      int t_stat;
 294.132 +      /* status of interior-point solution:
 294.133 +         GLP_UNDEF  - interior solution is undefined
 294.134 +         GLP_OPT    - interior solution is optimal */
 294.135 +      int i_stat;
 294.136 +      /* status of mixed integer solution:
 294.137 +         GLP_UNDEF  - integer solution is undefined
 294.138 +         GLP_OPT    - integer solution is optimal
 294.139 +         GLP_FEAS   - integer solution is feasible
 294.140 +         GLP_NOFEAS - no integer solution exists */
 294.141 +      char *r_stat; /* char r_stat[1+nrows]; */
 294.142 +      /* r_stat[i], 1 <= i <= nrows, is status of i-th row:
 294.143 +         GLP_BS - inactive constraint
 294.144 +         GLP_NL - active constraint on lower bound
 294.145 +         GLP_NU - active constraint on upper bound
 294.146 +         GLP_NF - active free row
 294.147 +         GLP_NS - active equality constraint */
 294.148 +      char *c_stat; /* char c_stat[1+nrows]; */
 294.149 +      /* c_stat[j], 1 <= j <= nrows, is status of j-th column:
 294.150 +         GLP_BS - basic variable
 294.151 +         GLP_NL - non-basic variable on lower bound
 294.152 +         GLP_NU - non-basic variable on upper bound
 294.153 +         GLP_NF - non-basic free variable
 294.154 +         GLP_NS - non-basic fixed variable */
 294.155 +      double *r_pi; /* double r_pi[1+nrows]; */
 294.156 +      /* r_pi[i], 1 <= i <= nrows, is Lagrange multiplier (dual value)
 294.157 +         for i-th row (constraint) */
 294.158 +      double *c_value; /* double c_value[1+ncols]; */
 294.159 +      /* c_value[j], 1 <= j <= ncols, is primal value of j-th column
 294.160 +         (structural variable) */
 294.161 +};
 294.162 +
 294.163 +struct NPPROW
 294.164 +{     /* row (constraint) */
 294.165 +      int i;
 294.166 +      /* reference number assigned to the row, 1 <= i <= nrows */
 294.167 +      char *name;
 294.168 +      /* row name (1 to 255 chars); NULL means no name is assigned to
 294.169 +         the row */
 294.170 +      double lb;
 294.171 +      /* lower bound; -DBL_MAX means the row has no lower bound */
 294.172 +      double ub;
 294.173 +      /* upper bound; +DBL_MAX means the row has no upper bound */
 294.174 +      NPPAIJ *ptr;
 294.175 +      /* pointer to the linked list of constraint coefficients */
 294.176 +      int temp;
 294.177 +      /* working field used by preprocessor routines */
 294.178 +      NPPROW *prev;
 294.179 +      /* pointer to previous row in the row list */
 294.180 +      NPPROW *next;
 294.181 +      /* pointer to next row in the row list */
 294.182 +};
 294.183 +
 294.184 +struct NPPCOL
 294.185 +{     /* column (variable) */
 294.186 +      int j;
 294.187 +      /* reference number assigned to the column, 1 <= j <= ncols */
 294.188 +      char *name;
 294.189 +      /* column name (1 to 255 chars); NULL means no name is assigned
 294.190 +         to the column */
 294.191 +      char is_int;
 294.192 +      /* 0 means continuous variable; 1 means integer variable */
 294.193 +      double lb;
 294.194 +      /* lower bound; -DBL_MAX means the column has no lower bound */
 294.195 +      double ub;
 294.196 +      /* upper bound; +DBL_MAX means the column has no upper bound */
 294.197 +      double coef;
 294.198 +      /* objective coefficient */
 294.199 +      NPPAIJ *ptr;
 294.200 +      /* pointer to the linked list of constraint coefficients */
 294.201 +      int temp;
 294.202 +      /* working field used by preprocessor routines */
 294.203 +#if 1 /* 28/XII-2009 */
 294.204 +      union
 294.205 +      {  double ll;
 294.206 +         /* implied column lower bound */
 294.207 +         int pos;
 294.208 +         /* vertex ordinal number corresponding to this binary column
 294.209 +            in the conflict graph (0, if the vertex does not exist) */
 294.210 +      }  ll;
 294.211 +      union
 294.212 +      {  double uu;
 294.213 +         /* implied column upper bound */
 294.214 +         int neg;
 294.215 +         /* vertex ordinal number corresponding to complement of this
 294.216 +            binary column in the conflict graph (0, if the vertex does
 294.217 +            not exist) */
 294.218 +      }  uu;
 294.219 +#endif
 294.220 +      NPPCOL *prev;
 294.221 +      /* pointer to previous column in the column list */
 294.222 +      NPPCOL *next;
 294.223 +      /* pointer to next column in the column list */
 294.224 +};
 294.225 +
 294.226 +struct NPPAIJ
 294.227 +{     /* constraint coefficient */
 294.228 +      NPPROW *row;
 294.229 +      /* pointer to corresponding row */
 294.230 +      NPPCOL *col;
 294.231 +      /* pointer to corresponding column */
 294.232 +      double val;
 294.233 +      /* (non-zero) coefficient value */
 294.234 +      NPPAIJ *r_prev;
 294.235 +      /* pointer to previous coefficient in the same row */
 294.236 +      NPPAIJ *r_next;
 294.237 +      /* pointer to next coefficient in the same row */
 294.238 +      NPPAIJ *c_prev;
 294.239 +      /* pointer to previous coefficient in the same column */
 294.240 +      NPPAIJ *c_next;
 294.241 +      /* pointer to next coefficient in the same column */
 294.242 +};
 294.243 +
 294.244 +struct NPPTSE
 294.245 +{     /* transformation stack entry */
 294.246 +      int (*func)(NPP *npp, void *info);
 294.247 +      /* pointer to routine performing back transformation */
 294.248 +      void *info;
 294.249 +      /* pointer to specific info (depends on the transformation) */
 294.250 +      NPPTSE *link;
 294.251 +      /* pointer to another entry created *before* this entry */
 294.252 +};
 294.253 +
 294.254 +struct NPPLFE
 294.255 +{     /* linear form element */
 294.256 +      int ref;
 294.257 +      /* row/column reference number */
 294.258 +      double val;
 294.259 +      /* (non-zero) coefficient value */
 294.260 +      NPPLFE *next;
 294.261 +      /* pointer to another element */
 294.262 +};
 294.263 +
 294.264 +#define npp_create_wksp _glp_npp_create_wksp
 294.265 +NPP *npp_create_wksp(void);
 294.266 +/* create LP/MIP preprocessor workspace */
 294.267 +
 294.268 +#define npp_insert_row _glp_npp_insert_row
 294.269 +void npp_insert_row(NPP *npp, NPPROW *row, int where);
 294.270 +/* insert row to the row list */
 294.271 +
 294.272 +#define npp_remove_row _glp_npp_remove_row
 294.273 +void npp_remove_row(NPP *npp, NPPROW *row);
 294.274 +/* remove row from the row list */
 294.275 +
 294.276 +#define npp_activate_row _glp_npp_activate_row
 294.277 +void npp_activate_row(NPP *npp, NPPROW *row);
 294.278 +/* make row active */
 294.279 +
 294.280 +#define npp_deactivate_row _glp_npp_deactivate_row
 294.281 +void npp_deactivate_row(NPP *npp, NPPROW *row);
 294.282 +/* make row inactive */
 294.283 +
 294.284 +#define npp_insert_col _glp_npp_insert_col
 294.285 +void npp_insert_col(NPP *npp, NPPCOL *col, int where);
 294.286 +/* insert column to the column list */
 294.287 +
 294.288 +#define npp_remove_col _glp_npp_remove_col
 294.289 +void npp_remove_col(NPP *npp, NPPCOL *col);
 294.290 +/* remove column from the column list */
 294.291 +
 294.292 +#define npp_activate_col _glp_npp_activate_col
 294.293 +void npp_activate_col(NPP *npp, NPPCOL *col);
 294.294 +/* make column active */
 294.295 +
 294.296 +#define npp_deactivate_col _glp_npp_deactivate_col
 294.297 +void npp_deactivate_col(NPP *npp, NPPCOL *col);
 294.298 +/* make column inactive */
 294.299 +
 294.300 +#define npp_add_row _glp_npp_add_row
 294.301 +NPPROW *npp_add_row(NPP *npp);
 294.302 +/* add new row to the current problem */
 294.303 +
 294.304 +#define npp_add_col _glp_npp_add_col
 294.305 +NPPCOL *npp_add_col(NPP *npp);
 294.306 +/* add new column to the current problem */
 294.307 +
 294.308 +#define npp_add_aij _glp_npp_add_aij
 294.309 +NPPAIJ *npp_add_aij(NPP *npp, NPPROW *row, NPPCOL *col, double val);
 294.310 +/* add new element to the constraint matrix */
 294.311 +
 294.312 +#define npp_row_nnz _glp_npp_row_nnz
 294.313 +int npp_row_nnz(NPP *npp, NPPROW *row);
 294.314 +/* count number of non-zero coefficients in row */
 294.315 +
 294.316 +#define npp_col_nnz _glp_npp_col_nnz
 294.317 +int npp_col_nnz(NPP *npp, NPPCOL *col);
 294.318 +/* count number of non-zero coefficients in column */
 294.319 +
 294.320 +#define npp_push_tse _glp_npp_push_tse
 294.321 +void *npp_push_tse(NPP *npp, int (*func)(NPP *npp, void *info),
 294.322 +      int size);
 294.323 +/* push new entry to the transformation stack */
 294.324 +
 294.325 +#define npp_erase_row _glp_npp_erase_row
 294.326 +void npp_erase_row(NPP *npp, NPPROW *row);
 294.327 +/* erase row content to make it empty */
 294.328 +
 294.329 +#define npp_del_row _glp_npp_del_row
 294.330 +void npp_del_row(NPP *npp, NPPROW *row);
 294.331 +/* remove row from the current problem */
 294.332 +
 294.333 +#define npp_del_col _glp_npp_del_col
 294.334 +void npp_del_col(NPP *npp, NPPCOL *col);
 294.335 +/* remove column from the current problem */
 294.336 +
 294.337 +#define npp_del_aij _glp_npp_del_aij
 294.338 +void npp_del_aij(NPP *npp, NPPAIJ *aij);
 294.339 +/* remove element from the constraint matrix */
 294.340 +
 294.341 +#define npp_load_prob _glp_npp_load_prob
 294.342 +void npp_load_prob(NPP *npp, glp_prob *orig, int names, int sol,
 294.343 +      int scaling);
 294.344 +/* load original problem into the preprocessor workspace */
 294.345 +
 294.346 +#define npp_build_prob _glp_npp_build_prob
 294.347 +void npp_build_prob(NPP *npp, glp_prob *prob);
 294.348 +/* build resultant (preprocessed) problem */
 294.349 +
 294.350 +#define npp_postprocess _glp_npp_postprocess
 294.351 +void npp_postprocess(NPP *npp, glp_prob *prob);
 294.352 +/* postprocess solution from the resultant problem */
 294.353 +
 294.354 +#define npp_unload_sol _glp_npp_unload_sol
 294.355 +void npp_unload_sol(NPP *npp, glp_prob *orig);
 294.356 +/* store solution to the original problem */
 294.357 +
 294.358 +#define npp_delete_wksp _glp_npp_delete_wksp
 294.359 +void npp_delete_wksp(NPP *npp);
 294.360 +/* delete LP/MIP preprocessor workspace */
 294.361 +
 294.362 +#define npp_error()
 294.363 +
 294.364 +#define npp_free_row _glp_npp_free_row
 294.365 +void npp_free_row(NPP *npp, NPPROW *p);
 294.366 +/* process free (unbounded) row */
 294.367 +
 294.368 +#define npp_geq_row _glp_npp_geq_row
 294.369 +void npp_geq_row(NPP *npp, NPPROW *p);
 294.370 +/* process row of 'not less than' type */
 294.371 +
 294.372 +#define npp_leq_row _glp_npp_leq_row
 294.373 +void npp_leq_row(NPP *npp, NPPROW *p);
 294.374 +/* process row of 'not greater than' type */
 294.375 +
 294.376 +#define npp_free_col _glp_npp_free_col
 294.377 +void npp_free_col(NPP *npp, NPPCOL *q);
 294.378 +/* process free (unbounded) column */
 294.379 +
 294.380 +#define npp_lbnd_col _glp_npp_lbnd_col
 294.381 +void npp_lbnd_col(NPP *npp, NPPCOL *q);
 294.382 +/* process column with (non-zero) lower bound */
 294.383 +
 294.384 +#define npp_ubnd_col _glp_npp_ubnd_col
 294.385 +void npp_ubnd_col(NPP *npp, NPPCOL *q);
 294.386 +/* process column with upper bound */
 294.387 +
 294.388 +#define npp_dbnd_col _glp_npp_dbnd_col
 294.389 +void npp_dbnd_col(NPP *npp, NPPCOL *q);
 294.390 +/* process non-negative column with upper bound */
 294.391 +
 294.392 +#define npp_fixed_col _glp_npp_fixed_col
 294.393 +void npp_fixed_col(NPP *npp, NPPCOL *q);
 294.394 +/* process fixed column */
 294.395 +
 294.396 +#define npp_make_equality _glp_npp_make_equality
 294.397 +int npp_make_equality(NPP *npp, NPPROW *p);
 294.398 +/* process row with almost identical bounds */
 294.399 +
 294.400 +#define npp_make_fixed _glp_npp_make_fixed
 294.401 +int npp_make_fixed(NPP *npp, NPPCOL *q);
 294.402 +/* process column with almost identical bounds */
 294.403 +
 294.404 +#define npp_empty_row _glp_npp_empty_row
 294.405 +int npp_empty_row(NPP *npp, NPPROW *p);
 294.406 +/* process empty row */
 294.407 +
 294.408 +#define npp_empty_col _glp_npp_empty_col
 294.409 +int npp_empty_col(NPP *npp, NPPCOL *q);
 294.410 +/* process empty column */
 294.411 +
 294.412 +#define npp_implied_value _glp_npp_implied_value
 294.413 +int npp_implied_value(NPP *npp, NPPCOL *q, double s);
 294.414 +/* process implied column value */
 294.415 +
 294.416 +#define npp_eq_singlet _glp_npp_eq_singlet
 294.417 +int npp_eq_singlet(NPP *npp, NPPROW *p);
 294.418 +/* process row singleton (equality constraint) */
 294.419 +
 294.420 +#define npp_implied_lower _glp_npp_implied_lower
 294.421 +int npp_implied_lower(NPP *npp, NPPCOL *q, double l);
 294.422 +/* process implied column lower bound */
 294.423 +
 294.424 +#define npp_implied_upper _glp_npp_implied_upper
 294.425 +int npp_implied_upper(NPP *npp, NPPCOL *q, double u);
 294.426 +/* process implied upper bound of column */
 294.427 +
 294.428 +#define npp_ineq_singlet _glp_npp_ineq_singlet
 294.429 +int npp_ineq_singlet(NPP *npp, NPPROW *p);
 294.430 +/* process row singleton (inequality constraint) */
 294.431 +
 294.432 +#define npp_implied_slack _glp_npp_implied_slack
 294.433 +void npp_implied_slack(NPP *npp, NPPCOL *q);
 294.434 +/* process column singleton (implied slack variable) */
 294.435 +
 294.436 +#define npp_implied_free _glp_npp_implied_free
 294.437 +int npp_implied_free(NPP *npp, NPPCOL *q);
 294.438 +/* process column singleton (implied free variable) */
 294.439 +
 294.440 +#define npp_eq_doublet _glp_npp_eq_doublet
 294.441 +NPPCOL *npp_eq_doublet(NPP *npp, NPPROW *p);
 294.442 +/* process row doubleton (equality constraint) */
 294.443 +
 294.444 +#define npp_forcing_row _glp_npp_forcing_row
 294.445 +int npp_forcing_row(NPP *npp, NPPROW *p, int at);
 294.446 +/* process forcing row */
 294.447 +
 294.448 +#define npp_analyze_row _glp_npp_analyze_row
 294.449 +int npp_analyze_row(NPP *npp, NPPROW *p);
 294.450 +/* perform general row analysis */
 294.451 +
 294.452 +#define npp_inactive_bound _glp_npp_inactive_bound
 294.453 +void npp_inactive_bound(NPP *npp, NPPROW *p, int which);
 294.454 +/* remove row lower/upper inactive bound */
 294.455 +
 294.456 +#define npp_implied_bounds _glp_npp_implied_bounds
 294.457 +void npp_implied_bounds(NPP *npp, NPPROW *p);
 294.458 +/* determine implied column bounds */
 294.459 +
 294.460 +#define npp_binarize_prob _glp_npp_binarize_prob
 294.461 +int npp_binarize_prob(NPP *npp);
 294.462 +/* binarize MIP problem */
 294.463 +
 294.464 +#define npp_is_packing _glp_npp_is_packing
 294.465 +int npp_is_packing(NPP *npp, NPPROW *row);
 294.466 +/* test if constraint is packing inequality */
 294.467 +
 294.468 +#define npp_hidden_packing _glp_npp_hidden_packing
 294.469 +int npp_hidden_packing(NPP *npp, NPPROW *row);
 294.470 +/* identify hidden packing inequality */
 294.471 +
 294.472 +#define npp_implied_packing _glp_npp_implied_packing
 294.473 +int npp_implied_packing(NPP *npp, NPPROW *row, int which,
 294.474 +      NPPCOL *var[], char set[]);
 294.475 +/* identify implied packing inequality */
 294.476 +
 294.477 +#define npp_is_covering _glp_npp_is_covering
 294.478 +int npp_is_covering(NPP *npp, NPPROW *row);
 294.479 +/* test if constraint is covering inequality */
 294.480 +
 294.481 +#define npp_hidden_covering _glp_npp_hidden_covering
 294.482 +int npp_hidden_covering(NPP *npp, NPPROW *row);
 294.483 +/* identify hidden covering inequality */
 294.484 +
 294.485 +#define npp_is_partitioning _glp_npp_is_partitioning
 294.486 +int npp_is_partitioning(NPP *npp, NPPROW *row);
 294.487 +/* test if constraint is partitioning equality */
 294.488 +
 294.489 +#define npp_reduce_ineq_coef _glp_npp_reduce_ineq_coef
 294.490 +int npp_reduce_ineq_coef(NPP *npp, NPPROW *row);
 294.491 +/* reduce inequality constraint coefficients */
 294.492 +
 294.493 +#define npp_clean_prob _glp_npp_clean_prob
 294.494 +void npp_clean_prob(NPP *npp);
 294.495 +/* perform initial LP/MIP processing */
 294.496 +
 294.497 +#define npp_process_row _glp_npp_process_row
 294.498 +int npp_process_row(NPP *npp, NPPROW *row, int hard);
 294.499 +/* perform basic row processing */
 294.500 +
 294.501 +#define npp_improve_bounds _glp_npp_improve_bounds
 294.502 +int npp_improve_bounds(NPP *npp, NPPROW *row, int flag);
 294.503 +/* improve current column bounds */
 294.504 +
 294.505 +#define npp_process_col _glp_npp_process_col
 294.506 +int npp_process_col(NPP *npp, NPPCOL *col);
 294.507 +/* perform basic column processing */
 294.508 +
 294.509 +#define npp_process_prob _glp_npp_process_prob
 294.510 +int npp_process_prob(NPP *npp, int hard);
 294.511 +/* perform basic LP/MIP processing */
 294.512 +
 294.513 +#define npp_simplex _glp_npp_simplex
 294.514 +int npp_simplex(NPP *npp, const glp_smcp *parm);
 294.515 +/* process LP prior to applying primal/dual simplex method */
 294.516 +
 294.517 +#define npp_integer _glp_npp_integer
 294.518 +int npp_integer(NPP *npp, const glp_iocp *parm);
 294.519 +/* process MIP prior to applying branch-and-bound method */
 294.520 +
 294.521 +/**********************************************************************/
 294.522 +
 294.523 +#define npp_sat_free_row _glp_npp_sat_free_row
 294.524 +void npp_sat_free_row(NPP *npp, NPPROW *p);
 294.525 +/* process free (unbounded) row */
 294.526 +
 294.527 +#define npp_sat_fixed_col _glp_npp_sat_fixed_col
 294.528 +int npp_sat_fixed_col(NPP *npp, NPPCOL *q);
 294.529 +/* process fixed column */
 294.530 +
 294.531 +#define npp_sat_is_bin_comb _glp_npp_sat_is_bin_comb
 294.532 +int npp_sat_is_bin_comb(NPP *npp, NPPROW *row);
 294.533 +/* test if row is binary combination */
 294.534 +
 294.535 +#define npp_sat_num_pos_coef _glp_npp_sat_num_pos_coef
 294.536 +int npp_sat_num_pos_coef(NPP *npp, NPPROW *row);
 294.537 +/* determine number of positive coefficients */
 294.538 +
 294.539 +#define npp_sat_num_neg_coef _glp_npp_sat_num_neg_coef
 294.540 +int npp_sat_num_neg_coef(NPP *npp, NPPROW *row);
 294.541 +/* determine number of negative coefficients */
 294.542 +
 294.543 +#define npp_sat_is_cover_ineq _glp_npp_sat_is_cover_ineq
 294.544 +int npp_sat_is_cover_ineq(NPP *npp, NPPROW *row);
 294.545 +/* test if row is covering inequality */
 294.546 +
 294.547 +#define npp_sat_is_pack_ineq _glp_npp_sat_is_pack_ineq
 294.548 +int npp_sat_is_pack_ineq(NPP *npp, NPPROW *row);
 294.549 +/* test if row is packing inequality */
 294.550 +
 294.551 +#define npp_sat_is_partn_eq _glp_npp_sat_is_partn_eq
 294.552 +int npp_sat_is_partn_eq(NPP *npp, NPPROW *row);
 294.553 +/* test if row is partitioning equality */
 294.554 +
 294.555 +#define npp_sat_reverse_row _glp_npp_sat_reverse_row
 294.556 +int npp_sat_reverse_row(NPP *npp, NPPROW *row);
 294.557 +/* multiply both sides of row by -1 */
 294.558 +
 294.559 +#define npp_sat_split_pack _glp_npp_sat_split_pack
 294.560 +NPPROW *npp_sat_split_pack(NPP *npp, NPPROW *row, int nnn);
 294.561 +/* split packing inequality */
 294.562 +
 294.563 +#define npp_sat_encode_pack _glp_npp_sat_encode_pack
 294.564 +void npp_sat_encode_pack(NPP *npp, NPPROW *row);
 294.565 +/* encode packing inequality */
 294.566 +
 294.567 +typedef struct NPPLIT NPPLIT;
 294.568 +typedef struct NPPLSE NPPLSE;
 294.569 +typedef struct NPPSED NPPSED;
 294.570 +
 294.571 +struct NPPLIT
 294.572 +{     /* literal (binary variable or its negation) */
 294.573 +      NPPCOL *col;
 294.574 +      /* pointer to binary variable; NULL means constant false */
 294.575 +      int neg;
 294.576 +      /* negation flag:
 294.577 +         0 - literal is variable (or constant false)
 294.578 +         1 - literal is negation of variable (or constant true) */
 294.579 +};
 294.580 +
 294.581 +struct NPPLSE
 294.582 +{     /* literal set element */
 294.583 +      NPPLIT lit;
 294.584 +      /* literal */
 294.585 +      NPPLSE *next;
 294.586 +      /* pointer to another element */
 294.587 +};
 294.588 +
 294.589 +struct NPPSED
 294.590 +{     /* summation encoding descriptor */
 294.591 +      /* this struct describes the equality
 294.592 +            x + y + z = s + 2 * c,
 294.593 +         which was encoded as CNF and included into the transformed
 294.594 +         problem; here x and y are literals, z is either a literal or
 294.595 +         constant zero, s and c are binary variables modeling, resp.,
 294.596 +         the low and high (carry) sum bits */
 294.597 +      NPPLIT x, y, z;
 294.598 +      /* literals; if z.col = NULL, z is constant zero */
 294.599 +      NPPCOL *s, *c;
 294.600 +      /* binary variables modeling the sum bits */
 294.601 +};
 294.602 +
 294.603 +#define npp_sat_encode_sum2 _glp_npp_sat_encode_sum2
 294.604 +void npp_sat_encode_sum2(NPP *npp, NPPLSE *set, NPPSED *sed);
 294.605 +/* encode 2-bit summation */
 294.606 +
 294.607 +#define npp_sat_encode_sum3 _glp_npp_sat_encode_sum3
 294.608 +void npp_sat_encode_sum3(NPP *npp, NPPLSE *set, NPPSED *sed);
 294.609 +/* encode 3-bit summation */
 294.610 +
 294.611 +#define npp_sat_encode_sum_ax _glp_npp_sat_encode_sum_ax
 294.612 +int npp_sat_encode_sum_ax(NPP *npp, NPPROW *row, NPPLIT y[]);
 294.613 +/* encode linear combination of 0-1 variables */
 294.614 +
 294.615 +#define npp_sat_normalize_clause _glp_npp_sat_normalize_clause
 294.616 +int npp_sat_normalize_clause(NPP *npp, int size, NPPLIT lit[]);
 294.617 +/* normalize clause */
 294.618 +
 294.619 +#define npp_sat_encode_clause _glp_npp_sat_encode_clause
 294.620 +NPPROW *npp_sat_encode_clause(NPP *npp, int size, NPPLIT lit[]);
 294.621 +/* translate clause to cover inequality */
 294.622 +
 294.623 +#define npp_sat_encode_geq _glp_npp_sat_encode_geq
 294.624 +int npp_sat_encode_geq(NPP *npp, int n, NPPLIT y[], int rhs);
 294.625 +/* encode "not less than" constraint */
 294.626 +
 294.627 +#define npp_sat_encode_leq _glp_npp_sat_encode_leq
 294.628 +int npp_sat_encode_leq(NPP *npp, int n, NPPLIT y[], int rhs);
 294.629 +/* encode "not greater than" constraint */
 294.630 +
 294.631 +#define npp_sat_encode_row _glp_npp_sat_encode_row
 294.632 +int npp_sat_encode_row(NPP *npp, NPPROW *row);
 294.633 +/* encode constraint (row) of general type */
 294.634 +
 294.635 +#define npp_sat_encode_prob _glp_npp_sat_encode_prob
 294.636 +int npp_sat_encode_prob(NPP *npp);
 294.637 +/* encode 0-1 feasibility problem */
 294.638 +
 294.639 +#endif
 294.640 +
 294.641 +/* eof */
   295.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
   295.2 +++ b/deps/glpk/src/glpnpp01.c	Sun Nov 06 20:59:10 2011 +0100
   295.3 @@ -0,0 +1,927 @@
   295.4 +/* glpnpp01.c */
   295.5 +
   295.6 +/***********************************************************************
   295.7 +*  This code is part of GLPK (GNU Linear Programming Kit).
   295.8 +*
   295.9 +*  Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008,
  295.10 +*  2009, 2010, 2011 Andrew Makhorin, Department for Applied Informatics,
  295.11 +*  Moscow Aviation Institute, Moscow, Russia. All rights reserved.
  295.12 +*  E-mail: <mao@gnu.org>.
  295.13 +*
  295.14 +*  GLPK is free software: you can redistribute it and/or modify it
  295.15 +*  under the terms of the GNU General Public License as published by
  295.16 +*  the Free Software Foundation, either version 3 of the License, or
  295.17 +*  (at your option) any later version.
  295.18 +*
  295.19 +*  GLPK is distributed in the hope that it will be useful, but WITHOUT
  295.20 +*  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
  295.21 +*  or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
  295.22 +*  License for more details.
  295.23 +*
  295.24 +*  You should have received a copy of the GNU General Public License
  295.25 +*  along with GLPK. If not, see <http://www.gnu.org/licenses/>.
  295.26 +***********************************************************************/
  295.27 +
  295.28 +#include "glpnpp.h"
  295.29 +
  295.30 +NPP *npp_create_wksp(void)
  295.31 +{     /* create LP/MIP preprocessor workspace */
  295.32 +      NPP *npp;
  295.33 +      npp = xmalloc(sizeof(NPP));
  295.34 +      npp->orig_dir = 0;
  295.35 +      npp->orig_m = npp->orig_n = npp->orig_nnz = 0;
  295.36 +      npp->pool = dmp_create_pool();
  295.37 +      npp->name = npp->obj = NULL;
  295.38 +      npp->c0 = 0.0;
  295.39 +      npp->nrows = npp->ncols = 0;
  295.40 +      npp->r_head = npp->r_tail = NULL;
  295.41 +      npp->c_head = npp->c_tail = NULL;
  295.42 +      npp->stack = dmp_create_pool();
  295.43 +      npp->top = NULL;
  295.44 +#if 0 /* 16/XII-2009 */
  295.45 +      memset(&npp->count, 0, sizeof(npp->count));
  295.46 +#endif
  295.47 +      npp->m = npp->n = npp->nnz = 0;
  295.48 +      npp->row_ref = npp->col_ref = NULL;
  295.49 +      npp->sol = npp->scaling = 0;
  295.50 +      npp->p_stat = npp->d_stat = npp->t_stat = npp->i_stat = 0;
  295.51 +      npp->r_stat = NULL;
  295.52 +      /*npp->r_prim =*/ npp->r_pi = NULL;
  295.53 +      npp->c_stat = NULL;
  295.54 +      npp->c_value = /*npp->c_dual =*/ NULL;
  295.55 +      return npp;
  295.56 +}
  295.57 +
  295.58 +void npp_insert_row(NPP *npp, NPPROW *row, int where)
  295.59 +{     /* insert row to the row list */
  295.60 +      if (where == 0)
  295.61 +      {  /* insert row to the beginning of the row list */
  295.62 +         row->prev = NULL;
  295.63 +         row->next = npp->r_head;
  295.64 +         if (row->next == NULL)
  295.65 +            npp->r_tail = row;
  295.66 +         else
  295.67 +            row->next->prev = row;
  295.68 +         npp->r_head = row;
  295.69 +      }
  295.70 +      else
  295.71 +      {  /* insert row to the end of the row list */
  295.72 +         row->prev = npp->r_tail;
  295.73 +         row->next = NULL;
  295.74 +         if (row->prev == NULL)
  295.75 +            npp->r_head = row;
  295.76 +         else
  295.77 +            row->prev->next = row;
  295.78 +         npp->r_tail = row;
  295.79 +      }
  295.80 +      return;
  295.81 +}
  295.82 +
  295.83 +void npp_remove_row(NPP *npp, NPPROW *row)
  295.84 +{     /* remove row from the row list */
  295.85 +      if (row->prev == NULL)
  295.86 +         npp->r_head = row->next;
  295.87 +      else
  295.88 +         row->prev->next = row->next;
  295.89 +      if (row->next == NULL)
  295.90 +         npp->r_tail = row->prev;
  295.91 +      else
  295.92 +         row->next->prev = row->prev;
  295.93 +      return;
  295.94 +}
  295.95 +
  295.96 +void npp_activate_row(NPP *npp, NPPROW *row)
  295.97 +{     /* make row active */
  295.98 +      if (!row->temp)
  295.99 +      {  row->temp = 1;
 295.100 +         /* move the row to the beginning of the row list */
 295.101 +         npp_remove_row(npp, row);
 295.102 +         npp_insert_row(npp, row, 0);
 295.103 +      }
 295.104 +      return;
 295.105 +}
 295.106 +
 295.107 +void npp_deactivate_row(NPP *npp, NPPROW *row)
 295.108 +{     /* make row inactive */
 295.109 +      if (row->temp)
 295.110 +      {  row->temp = 0;
 295.111 +         /* move the row to the end of the row list */
 295.112 +         npp_remove_row(npp, row);
 295.113 +         npp_insert_row(npp, row, 1);
 295.114 +      }
 295.115 +      return;
 295.116 +}
 295.117 +
 295.118 +void npp_insert_col(NPP *npp, NPPCOL *col, int where)
 295.119 +{     /* insert column to the column list */
 295.120 +      if (where == 0)
 295.121 +      {  /* insert column to the beginning of the column list */
 295.122 +         col->prev = NULL;
 295.123 +         col->next = npp->c_head;
 295.124 +         if (col->next == NULL)
 295.125 +            npp->c_tail = col;
 295.126 +         else
 295.127 +            col->next->prev = col;
 295.128 +         npp->c_head = col;
 295.129 +      }
 295.130 +      else
 295.131 +      {  /* insert column to the end of the column list */
 295.132 +         col->prev = npp->c_tail;
 295.133 +         col->next = NULL;
 295.134 +         if (col->prev == NULL)
 295.135 +            npp->c_head = col;
 295.136 +         else
 295.137 +            col->prev->next = col;
 295.138 +         npp->c_tail = col;
 295.139 +      }
 295.140 +      return;
 295.141 +}
 295.142 +
 295.143 +void npp_remove_col(NPP *npp, NPPCOL *col)
 295.144 +{     /* remove column from the column list */
 295.145 +      if (col->prev == NULL)
 295.146 +         npp->c_head = col->next;
 295.147 +      else
 295.148 +         col->prev->next = col->next;
 295.149 +      if (col->next == NULL)
 295.150 +         npp->c_tail = col->prev;
 295.151 +      else
 295.152 +         col->next->prev = col->prev;
 295.153 +      return;
 295.154 +}
 295.155 +
 295.156 +void npp_activate_col(NPP *npp, NPPCOL *col)
 295.157 +{     /* make column active */
 295.158 +      if (!col->temp)
 295.159 +      {  col->temp = 1;
 295.160 +         /* move the column to the beginning of the column list */
 295.161 +         npp_remove_col(npp, col);
 295.162 +         npp_insert_col(npp, col, 0);
 295.163 +      }
 295.164 +      return;
 295.165 +}
 295.166 +
 295.167 +void npp_deactivate_col(NPP *npp, NPPCOL *col)
 295.168 +{     /* make column inactive */
 295.169 +      if (col->temp)
 295.170 +      {  col->temp = 0;
 295.171 +         /* move the column to the end of the column list */
 295.172 +         npp_remove_col(npp, col);
 295.173 +         npp_insert_col(npp, col, 1);
 295.174 +      }
 295.175 +      return;
 295.176 +}
 295.177 +
 295.178 +NPPROW *npp_add_row(NPP *npp)
 295.179 +{     /* add new row to the current problem */
 295.180 +      NPPROW *row;
 295.181 +      row = dmp_get_atom(npp->pool, sizeof(NPPROW));
 295.182 +      row->i = ++(npp->nrows);
 295.183 +      row->name = NULL;
 295.184 +      row->lb = -DBL_MAX, row->ub = +DBL_MAX;
 295.185 +      row->ptr = NULL;
 295.186 +      row->temp = 0;
 295.187 +      npp_insert_row(npp, row, 1);
 295.188 +      return row;
 295.189 +}
 295.190 +
 295.191 +NPPCOL *npp_add_col(NPP *npp)
 295.192 +{     /* add new column to the current problem */
 295.193 +      NPPCOL *col;
 295.194 +      col = dmp_get_atom(npp->pool, sizeof(NPPCOL));
 295.195 +      col->j = ++(npp->ncols);
 295.196 +      col->name = NULL;
 295.197 +#if 0
 295.198 +      col->kind = GLP_CV;
 295.199 +#else
 295.200 +      col->is_int = 0;
 295.201 +#endif
 295.202 +      col->lb = col->ub = col->coef = 0.0;
 295.203 +      col->ptr = NULL;
 295.204 +      col->temp = 0;
 295.205 +      npp_insert_col(npp, col, 1);
 295.206 +      return col;
 295.207 +}
 295.208 +
 295.209 +NPPAIJ *npp_add_aij(NPP *npp, NPPROW *row, NPPCOL *col, double val)
 295.210 +{     /* add new element to the constraint matrix */
 295.211 +      NPPAIJ *aij;
 295.212 +      aij = dmp_get_atom(npp->pool, sizeof(NPPAIJ));
 295.213 +      aij->row = row;
 295.214 +      aij->col = col;
 295.215 +      aij->val = val;
 295.216 +      aij->r_prev = NULL;
 295.217 +      aij->r_next = row->ptr;
 295.218 +      aij->c_prev = NULL;
 295.219 +      aij->c_next = col->ptr;
 295.220 +      if (aij->r_next != NULL)
 295.221 +         aij->r_next->r_prev = aij;
 295.222 +      if (aij->c_next != NULL)
 295.223 +         aij->c_next->c_prev = aij;
 295.224 +      row->ptr = col->ptr = aij;
 295.225 +      return aij;
 295.226 +}
 295.227 +
 295.228 +int npp_row_nnz(NPP *npp, NPPROW *row)
 295.229 +{     /* count number of non-zero coefficients in row */
 295.230 +      NPPAIJ *aij;
 295.231 +      int nnz;
 295.232 +      xassert(npp == npp);
 295.233 +      nnz = 0;
 295.234 +      for (aij = row->ptr; aij != NULL; aij = aij->r_next)
 295.235 +         nnz++;
 295.236 +      return nnz;
 295.237 +}
 295.238 +
 295.239 +int npp_col_nnz(NPP *npp, NPPCOL *col)
 295.240 +{     /* count number of non-zero coefficients in column */
 295.241 +      NPPAIJ *aij;
 295.242 +      int nnz;
 295.243 +      xassert(npp == npp);
 295.244 +      nnz = 0;
 295.245 +      for (aij = col->ptr; aij != NULL; aij = aij->c_next)
 295.246 +         nnz++;
 295.247 +      return nnz;
 295.248 +}
 295.249 +
 295.250 +void *npp_push_tse(NPP *npp, int (*func)(NPP *npp, void *info),
 295.251 +      int size)
 295.252 +{     /* push new entry to the transformation stack */
 295.253 +      NPPTSE *tse;
 295.254 +      tse = dmp_get_atom(npp->stack, sizeof(NPPTSE));
 295.255 +      tse->func = func;
 295.256 +      tse->info = dmp_get_atom(npp->stack, size);
 295.257 +      tse->link = npp->top;
 295.258 +      npp->top = tse;
 295.259 +      return tse->info;
 295.260 +}
 295.261 +
 295.262 +#if 1 /* 23/XII-2009 */
 295.263 +void npp_erase_row(NPP *npp, NPPROW *row)
 295.264 +{     /* erase row content to make it empty */
 295.265 +      NPPAIJ *aij;
 295.266 +      while (row->ptr != NULL)
 295.267 +      {  aij = row->ptr;
 295.268 +         row->ptr = aij->r_next;
 295.269 +         if (aij->c_prev == NULL)
 295.270 +            aij->col->ptr = aij->c_next;
 295.271 +         else
 295.272 +            aij->c_prev->c_next = aij->c_next;
 295.273 +         if (aij->c_next == NULL)
 295.274 +            ;
 295.275 +         else
 295.276 +            aij->c_next->c_prev = aij->c_prev;
 295.277 +         dmp_free_atom(npp->pool, aij, sizeof(NPPAIJ));
 295.278 +      }
 295.279 +      return;
 295.280 +}
 295.281 +#endif
 295.282 +
 295.283 +void npp_del_row(NPP *npp, NPPROW *row)
 295.284 +{     /* remove row from the current problem */
 295.285 +#if 0 /* 23/XII-2009 */
 295.286 +      NPPAIJ *aij;
 295.287 +#endif
 295.288 +      if (row->name != NULL)
 295.289 +         dmp_free_atom(npp->pool, row->name, strlen(row->name)+1);
 295.290 +#if 0 /* 23/XII-2009 */
 295.291 +      while (row->ptr != NULL)
 295.292 +      {  aij = row->ptr;
 295.293 +         row->ptr = aij->r_next;
 295.294 +         if (aij->c_prev == NULL)
 295.295 +            aij->col->ptr = aij->c_next;
 295.296 +         else
 295.297 +            aij->c_prev->c_next = aij->c_next;
 295.298 +         if (aij->c_next == NULL)
 295.299 +            ;
 295.300 +         else
 295.301 +            aij->c_next->c_prev = aij->c_prev;
 295.302 +         dmp_free_atom(npp->pool, aij, sizeof(NPPAIJ));
 295.303 +      }
 295.304 +#else
 295.305 +      npp_erase_row(npp, row);
 295.306 +#endif
 295.307 +      npp_remove_row(npp, row);
 295.308 +      dmp_free_atom(npp->pool, row, sizeof(NPPROW));
 295.309 +      return;
 295.310 +}
 295.311 +
 295.312 +void npp_del_col(NPP *npp, NPPCOL *col)
 295.313 +{     /* remove column from the current problem */
 295.314 +      NPPAIJ *aij;
 295.315 +      if (col->name != NULL)
 295.316 +         dmp_free_atom(npp->pool, col->name, strlen(col->name)+1);
 295.317 +      while (col->ptr != NULL)
 295.318 +      {  aij = col->ptr;
 295.319 +         col->ptr = aij->c_next;
 295.320 +         if (aij->r_prev == NULL)
 295.321 +            aij->row->ptr = aij->r_next;
 295.322 +         else
 295.323 +            aij->r_prev->r_next = aij->r_next;
 295.324 +         if (aij->r_next == NULL)
 295.325 +            ;
 295.326 +         else
 295.327 +            aij->r_next->r_prev = aij->r_prev;
 295.328 +         dmp_free_atom(npp->pool, aij, sizeof(NPPAIJ));
 295.329 +      }
 295.330 +      npp_remove_col(npp, col);
 295.331 +      dmp_free_atom(npp->pool, col, sizeof(NPPCOL));
 295.332 +      return;
 295.333 +}
 295.334 +
 295.335 +void npp_del_aij(NPP *npp, NPPAIJ *aij)
 295.336 +{     /* remove element from the constraint matrix */
 295.337 +      if (aij->r_prev == NULL)
 295.338 +         aij->row->ptr = aij->r_next;
 295.339 +      else
 295.340 +         aij->r_prev->r_next = aij->r_next;
 295.341 +      if (aij->r_next == NULL)
 295.342 +         ;
 295.343 +      else
 295.344 +         aij->r_next->r_prev = aij->r_prev;
 295.345 +      if (aij->c_prev == NULL)
 295.346 +         aij->col->ptr = aij->c_next;
 295.347 +      else
 295.348 +         aij->c_prev->c_next = aij->c_next;
 295.349 +      if (aij->c_next == NULL)
 295.350 +         ;
 295.351 +      else
 295.352 +         aij->c_next->c_prev = aij->c_prev;
 295.353 +      dmp_free_atom(npp->pool, aij, sizeof(NPPAIJ));
 295.354 +      return;
 295.355 +}
 295.356 +
 295.357 +void npp_load_prob(NPP *npp, glp_prob *orig, int names, int sol,
 295.358 +      int scaling)
 295.359 +{     /* load original problem into the preprocessor workspace */
 295.360 +      int m = orig->m;
 295.361 +      int n = orig->n;
 295.362 +      NPPROW **link;
 295.363 +      int i, j;
 295.364 +      double dir;
 295.365 +      xassert(names == GLP_OFF || names == GLP_ON);
 295.366 +      xassert(sol == GLP_SOL || sol == GLP_IPT || sol == GLP_MIP);
 295.367 +      xassert(scaling == GLP_OFF || scaling == GLP_ON);
 295.368 +      if (sol == GLP_MIP) xassert(!scaling);
 295.369 +      npp->orig_dir = orig->dir;
 295.370 +      if (npp->orig_dir == GLP_MIN)
 295.371 +         dir = +1.0;
 295.372 +      else if (npp->orig_dir == GLP_MAX)
 295.373 +         dir = -1.0;
 295.374 +      else
 295.375 +         xassert(npp != npp);
 295.376 +      npp->orig_m = m;
 295.377 +      npp->orig_n = n;
 295.378 +      npp->orig_nnz = orig->nnz;
 295.379 +      if (names && orig->name != NULL)
 295.380 +      {  npp->name = dmp_get_atom(npp->pool, strlen(orig->name)+1);
 295.381 +         strcpy(npp->name, orig->name);
 295.382 +      }
 295.383 +      if (names && orig->obj != NULL)
 295.384 +      {  npp->obj = dmp_get_atom(npp->pool, strlen(orig->obj)+1);
 295.385 +         strcpy(npp->obj, orig->obj);
 295.386 +      }
 295.387 +      npp->c0 = dir * orig->c0;
 295.388 +      /* load rows */
 295.389 +      link = xcalloc(1+m, sizeof(NPPROW *));
 295.390 +      for (i = 1; i <= m; i++)
 295.391 +      {  GLPROW *rrr = orig->row[i];
 295.392 +         NPPROW *row;
 295.393 +         link[i] = row = npp_add_row(npp);
 295.394 +         xassert(row->i == i);
 295.395 +         if (names && rrr->name != NULL)
 295.396 +         {  row->name = dmp_get_atom(npp->pool, strlen(rrr->name)+1);
 295.397 +            strcpy(row->name, rrr->name);
 295.398 +         }
 295.399 +         if (!scaling)
 295.400 +         {  if (rrr->type == GLP_FR)
 295.401 +               row->lb = -DBL_MAX, row->ub = +DBL_MAX;
 295.402 +            else if (rrr->type == GLP_LO)
 295.403 +               row->lb = rrr->lb, row->ub = +DBL_MAX;
 295.404 +            else if (rrr->type == GLP_UP)
 295.405 +               row->lb = -DBL_MAX, row->ub = rrr->ub;
 295.406 +            else if (rrr->type == GLP_DB)
 295.407 +               row->lb = rrr->lb, row->ub = rrr->ub;
 295.408 +            else if (rrr->type == GLP_FX)
 295.409 +               row->lb = row->ub = rrr->lb;
 295.410 +            else
 295.411 +               xassert(rrr != rrr);
 295.412 +         }
 295.413 +         else
 295.414 +         {  double rii = rrr->rii;
 295.415 +            if (rrr->type == GLP_FR)
 295.416 +               row->lb = -DBL_MAX, row->ub = +DBL_MAX;
 295.417 +            else if (rrr->type == GLP_LO)
 295.418 +               row->lb = rrr->lb * rii, row->ub = +DBL_MAX;
 295.419 +            else if (rrr->type == GLP_UP)
 295.420 +               row->lb = -DBL_MAX, row->ub = rrr->ub * rii;
 295.421 +            else if (rrr->type == GLP_DB)
 295.422 +               row->lb = rrr->lb * rii, row->ub = rrr->ub * rii;
 295.423 +            else if (rrr->type == GLP_FX)
 295.424 +               row->lb = row->ub = rrr->lb * rii;
 295.425 +            else
 295.426 +               xassert(rrr != rrr);
 295.427 +         }
 295.428 +      }
 295.429 +      /* load columns and constraint coefficients */
 295.430 +      for (j = 1; j <= n; j++)
 295.431 +      {  GLPCOL *ccc = orig->col[j];
 295.432 +         GLPAIJ *aaa;
 295.433 +         NPPCOL *col;
 295.434 +         col = npp_add_col(npp);
 295.435 +         xassert(col->j == j);
 295.436 +         if (names && ccc->name != NULL)
 295.437 +         {  col->name = dmp_get_atom(npp->pool, strlen(ccc->name)+1);
 295.438 +            strcpy(col->name, ccc->name);
 295.439 +         }
 295.440 +         if (sol == GLP_MIP)
 295.441 +#if 0
 295.442 +            col->kind = ccc->kind;
 295.443 +#else
 295.444 +            col->is_int = (char)(ccc->kind == GLP_IV);
 295.445 +#endif
 295.446 +         if (!scaling)
 295.447 +         {  if (ccc->type == GLP_FR)
 295.448 +               col->lb = -DBL_MAX, col->ub = +DBL_MAX;
 295.449 +            else if (ccc->type == GLP_LO)
 295.450 +               col->lb = ccc->lb, col->ub = +DBL_MAX;
 295.451 +            else if (ccc->type == GLP_UP)
 295.452 +               col->lb = -DBL_MAX, col->ub = ccc->ub;
 295.453 +            else if (ccc->type == GLP_DB)
 295.454 +               col->lb = ccc->lb, col->ub = ccc->ub;
 295.455 +            else if (ccc->type == GLP_FX)
 295.456 +               col->lb = col->ub = ccc->lb;
 295.457 +            else
 295.458 +               xassert(ccc != ccc);
 295.459 +            col->coef = dir * ccc->coef;
 295.460 +            for (aaa = ccc->ptr; aaa != NULL; aaa = aaa->c_next)
 295.461 +               npp_add_aij(npp, link[aaa->row->i], col, aaa->val);
 295.462 +         }
 295.463 +         else
 295.464 +         {  double sjj = ccc->sjj;
 295.465 +            if (ccc->type == GLP_FR)
 295.466 +               col->lb = -DBL_MAX, col->ub = +DBL_MAX;
 295.467 +            else if (ccc->type == GLP_LO)
 295.468 +               col->lb = ccc->lb / sjj, col->ub = +DBL_MAX;
 295.469 +            else if (ccc->type == GLP_UP)
 295.470 +               col->lb = -DBL_MAX, col->ub = ccc->ub / sjj;
 295.471 +            else if (ccc->type == GLP_DB)
 295.472 +               col->lb = ccc->lb / sjj, col->ub = ccc->ub / sjj;
 295.473 +            else if (ccc->type == GLP_FX)
 295.474 +               col->lb = col->ub = ccc->lb / sjj;
 295.475 +            else
 295.476 +               xassert(ccc != ccc);
 295.477 +            col->coef = dir * ccc->coef * sjj;
 295.478 +            for (aaa = ccc->ptr; aaa != NULL; aaa = aaa->c_next)
 295.479 +               npp_add_aij(npp, link[aaa->row->i], col,
 295.480 +                  aaa->row->rii * aaa->val * sjj);
 295.481 +         }
 295.482 +      }
 295.483 +      xfree(link);
 295.484 +      /* keep solution indicator and scaling option */
 295.485 +      npp->sol = sol;
 295.486 +      npp->scaling = scaling;
 295.487 +      return;
 295.488 +}
 295.489 +
 295.490 +void npp_build_prob(NPP *npp, glp_prob *prob)
 295.491 +{     /* build resultant (preprocessed) problem */
 295.492 +      NPPROW *row;
 295.493 +      NPPCOL *col;
 295.494 +      NPPAIJ *aij;
 295.495 +      int i, j, type, len, *ind;
 295.496 +      double dir, *val;
 295.497 +      glp_erase_prob(prob);
 295.498 +      glp_set_prob_name(prob, npp->name);
 295.499 +      glp_set_obj_name(prob, npp->obj);
 295.500 +      glp_set_obj_dir(prob, npp->orig_dir);
 295.501 +      if (npp->orig_dir == GLP_MIN)
 295.502 +         dir = +1.0;
 295.503 +      else if (npp->orig_dir == GLP_MAX)
 295.504 +         dir = -1.0;
 295.505 +      else
 295.506 +         xassert(npp != npp);
 295.507 +      glp_set_obj_coef(prob, 0, dir * npp->c0);
 295.508 +      /* build rows */
 295.509 +      for (row = npp->r_head; row != NULL; row = row->next)
 295.510 +      {  row->temp = i = glp_add_rows(prob, 1);
 295.511 +         glp_set_row_name(prob, i, row->name);
 295.512 +         if (row->lb == -DBL_MAX && row->ub == +DBL_MAX)
 295.513 +            type = GLP_FR;
 295.514 +         else if (row->ub == +DBL_MAX)
 295.515 +            type = GLP_LO;
 295.516 +         else if (row->lb == -DBL_MAX)
 295.517 +            type = GLP_UP;
 295.518 +         else if (row->lb != row->ub)
 295.519 +            type = GLP_DB;
 295.520 +         else
 295.521 +            type = GLP_FX;
 295.522 +         glp_set_row_bnds(prob, i, type, row->lb, row->ub);
 295.523 +      }
 295.524 +      /* build columns and the constraint matrix */
 295.525 +      ind = xcalloc(1+prob->m, sizeof(int));
 295.526 +      val = xcalloc(1+prob->m, sizeof(double));
 295.527 +      for (col = npp->c_head; col != NULL; col = col->next)
 295.528 +      {  j = glp_add_cols(prob, 1);
 295.529 +         glp_set_col_name(prob, j, col->name);
 295.530 +#if 0
 295.531 +         glp_set_col_kind(prob, j, col->kind);
 295.532 +#else
 295.533 +         glp_set_col_kind(prob, j, col->is_int ? GLP_IV : GLP_CV);
 295.534 +#endif
 295.535 +         if (col->lb == -DBL_MAX && col->ub == +DBL_MAX)
 295.536 +            type = GLP_FR;
 295.537 +         else if (col->ub == +DBL_MAX)
 295.538 +            type = GLP_LO;
 295.539 +         else if (col->lb == -DBL_MAX)
 295.540 +            type = GLP_UP;
 295.541 +         else if (col->lb != col->ub)
 295.542 +            type = GLP_DB;
 295.543 +         else
 295.544 +            type = GLP_FX;
 295.545 +         glp_set_col_bnds(prob, j, type, col->lb, col->ub);
 295.546 +         glp_set_obj_coef(prob, j, dir * col->coef);
 295.547 +         len = 0;
 295.548 +         for (aij = col->ptr; aij != NULL; aij = aij->c_next)
 295.549 +         {  len++;
 295.550 +            ind[len] = aij->row->temp;
 295.551 +            val[len] = aij->val;
 295.552 +         }
 295.553 +         glp_set_mat_col(prob, j, len, ind, val);
 295.554 +      }
 295.555 +      xfree(ind);
 295.556 +      xfree(val);
 295.557 +      /* resultant problem has been built */
 295.558 +      npp->m = prob->m;
 295.559 +      npp->n = prob->n;
 295.560 +      npp->nnz = prob->nnz;
 295.561 +      npp->row_ref = xcalloc(1+npp->m, sizeof(int));
 295.562 +      npp->col_ref = xcalloc(1+npp->n, sizeof(int));
 295.563 +      for (row = npp->r_head, i = 0; row != NULL; row = row->next)
 295.564 +         npp->row_ref[++i] = row->i;
 295.565 +      for (col = npp->c_head, j = 0; col != NULL; col = col->next)
 295.566 +         npp->col_ref[++j] = col->j;
 295.567 +      /* transformed problem segment is no longer needed */
 295.568 +      dmp_delete_pool(npp->pool), npp->pool = NULL;
 295.569 +      npp->name = npp->obj = NULL;
 295.570 +      npp->c0 = 0.0;
 295.571 +      npp->r_head = npp->r_tail = NULL;
 295.572 +      npp->c_head = npp->c_tail = NULL;
 295.573 +      return;
 295.574 +}
 295.575 +
 295.576 +void npp_postprocess(NPP *npp, glp_prob *prob)
 295.577 +{     /* postprocess solution from the resultant problem */
 295.578 +      GLPROW *row;
 295.579 +      GLPCOL *col;
 295.580 +      NPPTSE *tse;
 295.581 +      int i, j, k;
 295.582 +      double dir;
 295.583 +      xassert(npp->orig_dir == prob->dir);
 295.584 +      if (npp->orig_dir == GLP_MIN)
 295.585 +         dir = +1.0;
 295.586 +      else if (npp->orig_dir == GLP_MAX)
 295.587 +         dir = -1.0;
 295.588 +      else
 295.589 +         xassert(npp != npp);
 295.590 +      xassert(npp->m == prob->m);
 295.591 +      xassert(npp->n == prob->n);
 295.592 +      xassert(npp->nnz == prob->nnz);
 295.593 +      /* copy solution status */
 295.594 +      if (npp->sol == GLP_SOL)
 295.595 +      {  npp->p_stat = prob->pbs_stat;
 295.596 +         npp->d_stat = prob->dbs_stat;
 295.597 +      }
 295.598 +      else if (npp->sol == GLP_IPT)
 295.599 +         npp->t_stat = prob->ipt_stat;
 295.600 +      else if (npp->sol == GLP_MIP)
 295.601 +         npp->i_stat = prob->mip_stat;
 295.602 +      else
 295.603 +         xassert(npp != npp);
 295.604 +      /* allocate solution arrays */
 295.605 +      if (npp->sol == GLP_SOL)
 295.606 +      {  if (npp->r_stat == NULL)
 295.607 +            npp->r_stat = xcalloc(1+npp->nrows, sizeof(char));
 295.608 +         for (i = 1; i <= npp->nrows; i++)
 295.609 +            npp->r_stat[i] = 0;
 295.610 +         if (npp->c_stat == NULL)
 295.611 +            npp->c_stat = xcalloc(1+npp->ncols, sizeof(char));
 295.612 +         for (j = 1; j <= npp->ncols; j++)
 295.613 +            npp->c_stat[j] = 0;
 295.614 +      }
 295.615 +#if 0
 295.616 +      if (npp->r_prim == NULL)
 295.617 +         npp->r_prim = xcalloc(1+npp->nrows, sizeof(double));
 295.618 +      for (i = 1; i <= npp->nrows; i++)
 295.619 +         npp->r_prim[i] = DBL_MAX;
 295.620 +#endif
 295.621 +      if (npp->c_value == NULL)
 295.622 +         npp->c_value = xcalloc(1+npp->ncols, sizeof(double));
 295.623 +      for (j = 1; j <= npp->ncols; j++)
 295.624 +         npp->c_value[j] = DBL_MAX;
 295.625 +      if (npp->sol != GLP_MIP)
 295.626 +      {  if (npp->r_pi == NULL)
 295.627 +            npp->r_pi = xcalloc(1+npp->nrows, sizeof(double));
 295.628 +         for (i = 1; i <= npp->nrows; i++)
 295.629 +            npp->r_pi[i] = DBL_MAX;
 295.630 +#if 0
 295.631 +         if (npp->c_dual == NULL)
 295.632 +            npp->c_dual = xcalloc(1+npp->ncols, sizeof(double));
 295.633 +         for (j = 1; j <= npp->ncols; j++)
 295.634 +            npp->c_dual[j] = DBL_MAX;
 295.635 +#endif
 295.636 +      }
 295.637 +      /* copy solution components from the resultant problem */
 295.638 +      if (npp->sol == GLP_SOL)
 295.639 +      {  for (i = 1; i <= npp->m; i++)
 295.640 +         {  row = prob->row[i];
 295.641 +            k = npp->row_ref[i];
 295.642 +            npp->r_stat[k] = (char)row->stat;
 295.643 +            /*npp->r_prim[k] = row->prim;*/
 295.644 +            npp->r_pi[k] = dir * row->dual;
 295.645 +         }
 295.646 +         for (j = 1; j <= npp->n; j++)
 295.647 +         {  col = prob->col[j];
 295.648 +            k = npp->col_ref[j];
 295.649 +            npp->c_stat[k] = (char)col->stat;
 295.650 +            npp->c_value[k] = col->prim;
 295.651 +            /*npp->c_dual[k] = dir * col->dual;*/
 295.652 +         }
 295.653 +      }
 295.654 +      else if (npp->sol == GLP_IPT)
 295.655 +      {  for (i = 1; i <= npp->m; i++)
 295.656 +         {  row = prob->row[i];
 295.657 +            k = npp->row_ref[i];
 295.658 +            /*npp->r_prim[k] = row->pval;*/
 295.659 +            npp->r_pi[k] = dir * row->dval;
 295.660 +         }
 295.661 +         for (j = 1; j <= npp->n; j++)
 295.662 +         {  col = prob->col[j];
 295.663 +            k = npp->col_ref[j];
 295.664 +            npp->c_value[k] = col->pval;
 295.665 +            /*npp->c_dual[k] = dir * col->dval;*/
 295.666 +         }
 295.667 +      }
 295.668 +      else if (npp->sol == GLP_MIP)
 295.669 +      {
 295.670 +#if 0
 295.671 +         for (i = 1; i <= npp->m; i++)
 295.672 +         {  row = prob->row[i];
 295.673 +            k = npp->row_ref[i];
 295.674 +            /*npp->r_prim[k] = row->mipx;*/
 295.675 +         }
 295.676 +#endif
 295.677 +         for (j = 1; j <= npp->n; j++)
 295.678 +         {  col = prob->col[j];
 295.679 +            k = npp->col_ref[j];
 295.680 +            npp->c_value[k] = col->mipx;
 295.681 +         }
 295.682 +      }
 295.683 +      else
 295.684 +         xassert(npp != npp);
 295.685 +      /* perform postprocessing to construct solution to the original
 295.686 +         problem */
 295.687 +      for (tse = npp->top; tse != NULL; tse = tse->link)
 295.688 +      {  xassert(tse->func != NULL);
 295.689 +         xassert(tse->func(npp, tse->info) == 0);
 295.690 +      }
 295.691 +      return;
 295.692 +}
 295.693 +
 295.694 +void npp_unload_sol(NPP *npp, glp_prob *orig)
 295.695 +{     /* store solution to the original problem */
 295.696 +      GLPROW *row;
 295.697 +      GLPCOL *col;
 295.698 +      int i, j;
 295.699 +      double dir;
 295.700 +      xassert(npp->orig_dir == orig->dir);
 295.701 +      if (npp->orig_dir == GLP_MIN)
 295.702 +         dir = +1.0;
 295.703 +      else if (npp->orig_dir == GLP_MAX)
 295.704 +         dir = -1.0;
 295.705 +      else
 295.706 +         xassert(npp != npp);
 295.707 +      xassert(npp->orig_m == orig->m);
 295.708 +      xassert(npp->orig_n == orig->n);
 295.709 +      xassert(npp->orig_nnz == orig->nnz);
 295.710 +      if (npp->sol == GLP_SOL)
 295.711 +      {  /* store basic solution */
 295.712 +         orig->valid = 0;
 295.713 +         orig->pbs_stat = npp->p_stat;
 295.714 +         orig->dbs_stat = npp->d_stat;
 295.715 +         orig->obj_val = orig->c0;
 295.716 +         orig->some = 0;
 295.717 +         for (i = 1; i <= orig->m; i++)
 295.718 +         {  row = orig->row[i];
 295.719 +            row->stat = npp->r_stat[i];
 295.720 +            if (!npp->scaling)
 295.721 +            {  /*row->prim = npp->r_prim[i];*/
 295.722 +               row->dual = dir * npp->r_pi[i];
 295.723 +            }
 295.724 +            else
 295.725 +            {  /*row->prim = npp->r_prim[i] / row->rii;*/
 295.726 +               row->dual = dir * npp->r_pi[i] * row->rii;
 295.727 +            }
 295.728 +            if (row->stat == GLP_BS)
 295.729 +               row->dual = 0.0;
 295.730 +            else if (row->stat == GLP_NL)
 295.731 +            {  xassert(row->type == GLP_LO || row->type == GLP_DB);
 295.732 +               row->prim = row->lb;
 295.733 +            }
 295.734 +            else if (row->stat == GLP_NU)
 295.735 +            {  xassert(row->type == GLP_UP || row->type == GLP_DB);
 295.736 +               row->prim = row->ub;
 295.737 +            }
 295.738 +            else if (row->stat == GLP_NF)
 295.739 +            {  xassert(row->type == GLP_FR);
 295.740 +               row->prim = 0.0;
 295.741 +            }
 295.742 +            else if (row->stat == GLP_NS)
 295.743 +            {  xassert(row->type == GLP_FX);
 295.744 +               row->prim = row->lb;
 295.745 +            }
 295.746 +            else
 295.747 +               xassert(row != row);
 295.748 +         }
 295.749 +         for (j = 1; j <= orig->n; j++)
 295.750 +         {  col = orig->col[j];
 295.751 +            col->stat = npp->c_stat[j];
 295.752 +            if (!npp->scaling)
 295.753 +            {  col->prim = npp->c_value[j];
 295.754 +               /*col->dual = dir * npp->c_dual[j];*/
 295.755 +            }
 295.756 +            else
 295.757 +            {  col->prim = npp->c_value[j] * col->sjj;
 295.758 +               /*col->dual = dir * npp->c_dual[j] / col->sjj;*/
 295.759 +            }
 295.760 +            if (col->stat == GLP_BS)
 295.761 +               col->dual = 0.0;
 295.762 +#if 1
 295.763 +            else if (col->stat == GLP_NL)
 295.764 +            {  xassert(col->type == GLP_LO || col->type == GLP_DB);
 295.765 +               col->prim = col->lb;
 295.766 +            }
 295.767 +            else if (col->stat == GLP_NU)
 295.768 +            {  xassert(col->type == GLP_UP || col->type == GLP_DB);
 295.769 +               col->prim = col->ub;
 295.770 +            }
 295.771 +            else if (col->stat == GLP_NF)
 295.772 +            {  xassert(col->type == GLP_FR);
 295.773 +               col->prim = 0.0;
 295.774 +            }
 295.775 +            else if (col->stat == GLP_NS)
 295.776 +            {  xassert(col->type == GLP_FX);
 295.777 +               col->prim = col->lb;
 295.778 +            }
 295.779 +            else
 295.780 +               xassert(col != col);
 295.781 +#endif
 295.782 +            orig->obj_val += col->coef * col->prim;
 295.783 +         }
 295.784 +#if 1
 295.785 +         /* compute primal values of inactive rows */
 295.786 +         for (i = 1; i <= orig->m; i++)
 295.787 +         {  row = orig->row[i];
 295.788 +            if (row->stat == GLP_BS)
 295.789 +            {  GLPAIJ *aij;
 295.790 +               double temp;
 295.791 +               temp = 0.0;
 295.792 +               for (aij = row->ptr; aij != NULL; aij = aij->r_next)
 295.793 +                  temp += aij->val * aij->col->prim;
 295.794 +               row->prim = temp;
 295.795 +            }
 295.796 +         }
 295.797 +         /* compute reduced costs of active columns */
 295.798 +         for (j = 1; j <= orig->n; j++)
 295.799 +         {  col = orig->col[j];
 295.800 +            if (col->stat != GLP_BS)
 295.801 +            {  GLPAIJ *aij;
 295.802 +               double temp;
 295.803 +               temp = col->coef;
 295.804 +               for (aij = col->ptr; aij != NULL; aij = aij->c_next)
 295.805 +                  temp -= aij->val * aij->row->dual;
 295.806 +               col->dual = temp;
 295.807 +            }
 295.808 +         }
 295.809 +#endif
 295.810 +      }
 295.811 +      else if (npp->sol == GLP_IPT)
 295.812 +      {  /* store interior-point solution */
 295.813 +         orig->ipt_stat = npp->t_stat;
 295.814 +         orig->ipt_obj = orig->c0;
 295.815 +         for (i = 1; i <= orig->m; i++)
 295.816 +         {  row = orig->row[i];
 295.817 +            if (!npp->scaling)
 295.818 +            {  /*row->pval = npp->r_prim[i];*/
 295.819 +               row->dval = dir * npp->r_pi[i];
 295.820 +            }
 295.821 +            else
 295.822 +            {  /*row->pval = npp->r_prim[i] / row->rii;*/
 295.823 +               row->dval = dir * npp->r_pi[i] * row->rii;
 295.824 +            }
 295.825 +         }
 295.826 +         for (j = 1; j <= orig->n; j++)
 295.827 +         {  col = orig->col[j];
 295.828 +            if (!npp->scaling)
 295.829 +            {  col->pval = npp->c_value[j];
 295.830 +               /*col->dval = dir * npp->c_dual[j];*/
 295.831 +            }
 295.832 +            else
 295.833 +            {  col->pval = npp->c_value[j] * col->sjj;
 295.834 +               /*col->dval = dir * npp->c_dual[j] / col->sjj;*/
 295.835 +            }
 295.836 +            orig->ipt_obj += col->coef * col->pval;
 295.837 +         }
 295.838 +#if 1
 295.839 +         /* compute row primal values */
 295.840 +         for (i = 1; i <= orig->m; i++)
 295.841 +         {  row = orig->row[i];
 295.842 +            {  GLPAIJ *aij;
 295.843 +               double temp;
 295.844 +               temp = 0.0;
 295.845 +               for (aij = row->ptr; aij != NULL; aij = aij->r_next)
 295.846 +                  temp += aij->val * aij->col->pval;
 295.847 +               row->pval = temp;
 295.848 +            }
 295.849 +         }
 295.850 +         /* compute column dual values */
 295.851 +         for (j = 1; j <= orig->n; j++)
 295.852 +         {  col = orig->col[j];
 295.853 +            {  GLPAIJ *aij;
 295.854 +               double temp;
 295.855 +               temp = col->coef;
 295.856 +               for (aij = col->ptr; aij != NULL; aij = aij->c_next)
 295.857 +                  temp -= aij->val * aij->row->dval;
 295.858 +               col->dval = temp;
 295.859 +            }
 295.860 +         }
 295.861 +#endif
 295.862 +      }
 295.863 +      else if (npp->sol == GLP_MIP)
 295.864 +      {  /* store MIP solution */
 295.865 +         xassert(!npp->scaling);
 295.866 +         orig->mip_stat = npp->i_stat;
 295.867 +         orig->mip_obj = orig->c0;
 295.868 +#if 0
 295.869 +         for (i = 1; i <= orig->m; i++)
 295.870 +         {  row = orig->row[i];
 295.871 +            /*row->mipx = npp->r_prim[i];*/
 295.872 +         }
 295.873 +#endif
 295.874 +         for (j = 1; j <= orig->n; j++)
 295.875 +         {  col = orig->col[j];
 295.876 +            col->mipx = npp->c_value[j];
 295.877 +            if (col->kind == GLP_IV)
 295.878 +               xassert(col->mipx == floor(col->mipx));
 295.879 +            orig->mip_obj += col->coef * col->mipx;
 295.880 +         }
 295.881 +#if 1
 295.882 +         /* compute row primal values */
 295.883 +         for (i = 1; i <= orig->m; i++)
 295.884 +         {  row = orig->row[i];
 295.885 +            {  GLPAIJ *aij;
 295.886 +               double temp;
 295.887 +               temp = 0.0;
 295.888 +               for (aij = row->ptr; aij != NULL; aij = aij->r_next)
 295.889 +                  temp += aij->val * aij->col->mipx;
 295.890 +               row->mipx = temp;
 295.891 +            }
 295.892 +         }
 295.893 +#endif
 295.894 +      }
 295.895 +      else
 295.896 +         xassert(npp != npp);
 295.897 +      return;
 295.898 +}
 295.899 +
 295.900 +void npp_delete_wksp(NPP *npp)
 295.901 +{     /* delete LP/MIP preprocessor workspace */
 295.902 +      if (npp->pool != NULL)
 295.903 +         dmp_delete_pool(npp->pool);
 295.904 +      if (npp->stack != NULL)
 295.905 +         dmp_delete_pool(npp->stack);
 295.906 +      if (npp->row_ref != NULL)
 295.907 +         xfree(npp->row_ref);
 295.908 +      if (npp->col_ref != NULL)
 295.909 +         xfree(npp->col_ref);
 295.910 +      if (npp->r_stat != NULL)
 295.911 +         xfree(npp->r_stat);
 295.912 +#if 0
 295.913 +      if (npp->r_prim != NULL)
 295.914 +         xfree(npp->r_prim);
 295.915 +#endif
 295.916 +      if (npp->r_pi != NULL)
 295.917 +         xfree(npp->r_pi);
 295.918 +      if (npp->c_stat != NULL)
 295.919 +         xfree(npp->c_stat);
 295.920 +      if (npp->c_value != NULL)
 295.921 +         xfree(npp->c_value);
 295.922 +#if 0
 295.923 +      if (npp->c_dual != NULL)
 295.924 +         xfree(npp->c_dual);
 295.925 +#endif
 295.926 +      xfree(npp);
 295.927 +      return;
 295.928 +}
 295.929 +
 295.930 +/* eof */
   296.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
   296.2 +++ b/deps/glpk/src/glpnpp02.c	Sun Nov 06 20:59:10 2011 +0100
   296.3 @@ -0,0 +1,1433 @@
   296.4 +/* glpnpp02.c */
   296.5 +
   296.6 +/***********************************************************************
   296.7 +*  This code is part of GLPK (GNU Linear Programming Kit).
   296.8 +*
   296.9 +*  Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008,
  296.10 +*  2009, 2010, 2011 Andrew Makhorin, Department for Applied Informatics,
  296.11 +*  Moscow Aviation Institute, Moscow, Russia. All rights reserved.
  296.12 +*  E-mail: <mao@gnu.org>.
  296.13 +*
  296.14 +*  GLPK is free software: you can redistribute it and/or modify it
  296.15 +*  under the terms of the GNU General Public License as published by
  296.16 +*  the Free Software Foundation, either version 3 of the License, or
  296.17 +*  (at your option) any later version.
  296.18 +*
  296.19 +*  GLPK is distributed in the hope that it will be useful, but WITHOUT
  296.20 +*  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
  296.21 +*  or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
  296.22 +*  License for more details.
  296.23 +*
  296.24 +*  You should have received a copy of the GNU General Public License
  296.25 +*  along with GLPK. If not, see <http://www.gnu.org/licenses/>.
  296.26 +***********************************************************************/
  296.27 +
  296.28 +#include "glpnpp.h"
  296.29 +
  296.30 +/***********************************************************************
  296.31 +*  NAME
  296.32 +*
  296.33 +*  npp_free_row - process free (unbounded) row
  296.34 +*
  296.35 +*  SYNOPSIS
  296.36 +*
  296.37 +*  #include "glpnpp.h"
  296.38 +*  void npp_free_row(NPP *npp, NPPROW *p);
  296.39 +*
  296.40 +*  DESCRIPTION
  296.41 +*
  296.42 +*  The routine npp_free_row processes row p, which is free (i.e. has
  296.43 +*  no finite bounds):
  296.44 +*
  296.45 +*     -inf < sum a[p,j] x[j] < +inf.                                 (1)
  296.46 +*             j
  296.47 +*
  296.48 +*  PROBLEM TRANSFORMATION
  296.49 +*
  296.50 +*  Constraint (1) cannot be active, so it is redundant and can be
  296.51 +*  removed from the original problem.
  296.52 +*
  296.53 +*  Removing row p leads to removing a column of multiplier pi[p] for
  296.54 +*  this row in the dual system. Since row p has no bounds, pi[p] = 0,
  296.55 +*  so removing the column does not affect the dual solution.
  296.56 +*
  296.57 +*  RECOVERING BASIC SOLUTION
  296.58 +*
  296.59 +*  In solution to the original problem row p is inactive constraint,
  296.60 +*  so it is assigned status GLP_BS, and multiplier pi[p] is assigned
  296.61 +*  zero value.
  296.62 +*
  296.63 +*  RECOVERING INTERIOR-POINT SOLUTION
  296.64 +*
  296.65 +*  In solution to the original problem row p is inactive constraint,
  296.66 +*  so its multiplier pi[p] is assigned zero value.
  296.67 +*
  296.68 +*  RECOVERING MIP SOLUTION
  296.69 +*
  296.70 +*  None needed. */
  296.71 +
  296.72 +struct free_row
  296.73 +{     /* free (unbounded) row */
  296.74 +      int p;
  296.75 +      /* row reference number */
  296.76 +};
  296.77 +
  296.78 +static int rcv_free_row(NPP *npp, void *info);
  296.79 +
  296.80 +void npp_free_row(NPP *npp, NPPROW *p)
  296.81 +{     /* process free (unbounded) row */
  296.82 +      struct free_row *info;
  296.83 +      /* the row must be free */
  296.84 +      xassert(p->lb == -DBL_MAX && p->ub == +DBL_MAX);
  296.85 +      /* create transformation stack entry */
  296.86 +      info = npp_push_tse(npp,
  296.87 +         rcv_free_row, sizeof(struct free_row));
  296.88 +      info->p = p->i;
  296.89 +      /* remove the row from the problem */
  296.90 +      npp_del_row(npp, p);
  296.91 +      return;
  296.92 +}
  296.93 +
  296.94 +static int rcv_free_row(NPP *npp, void *_info)
  296.95 +{     /* recover free (unbounded) row */
  296.96 +      struct free_row *info = _info;
  296.97 +      if (npp->sol == GLP_SOL)
  296.98 +         npp->r_stat[info->p] = GLP_BS;
  296.99 +      if (npp->sol != GLP_MIP)
 296.100 +         npp->r_pi[info->p] = 0.0;
 296.101 +      return 0;
 296.102 +}
 296.103 +
 296.104 +/***********************************************************************
 296.105 +*  NAME
 296.106 +*
 296.107 +*  npp_geq_row - process row of 'not less than' type
 296.108 +*
 296.109 +*  SYNOPSIS
 296.110 +*
 296.111 +*  #include "glpnpp.h"
 296.112 +*  void npp_geq_row(NPP *npp, NPPROW *p);
 296.113 +*
 296.114 +*  DESCRIPTION
 296.115 +*
 296.116 +*  The routine npp_geq_row processes row p, which is 'not less than'
 296.117 +*  inequality constraint:
 296.118 +*
 296.119 +*     L[p] <= sum a[p,j] x[j] (<= U[p]),                             (1)
 296.120 +*              j
 296.121 +*
 296.122 +*  where L[p] < U[p], and upper bound may not exist (U[p] = +oo).
 296.123 +*
 296.124 +*  PROBLEM TRANSFORMATION
 296.125 +*
 296.126 +*  Constraint (1) can be replaced by equality constraint:
 296.127 +*
 296.128 +*     sum a[p,j] x[j] - s = L[p],                                    (2)
 296.129 +*      j
 296.130 +*
 296.131 +*  where
 296.132 +*
 296.133 +*     0 <= s (<= U[p] - L[p])                                        (3)
 296.134 +*
 296.135 +*  is a non-negative surplus variable.
 296.136 +*
 296.137 +*  Since in the primal system there appears column s having the only
 296.138 +*  non-zero coefficient in row p, in the dual system there appears a
 296.139 +*  new row:
 296.140 +*
 296.141 +*     (-1) pi[p] + lambda = 0,                                       (4)
 296.142 +*
 296.143 +*  where (-1) is coefficient of column s in row p, pi[p] is multiplier
 296.144 +*  of row p, lambda is multiplier of column q, 0 is coefficient of
 296.145 +*  column s in the objective row.
 296.146 +*
 296.147 +*  RECOVERING BASIC SOLUTION
 296.148 +*
 296.149 +*  Status of row p in solution to the original problem is determined
 296.150 +*  by its status and status of column q in solution to the transformed
 296.151 +*  problem as follows:
 296.152 +*
 296.153 +*     +--------------------------------------+------------------+
 296.154 +*     |         Transformed problem          | Original problem |
 296.155 +*     +-----------------+--------------------+------------------+
 296.156 +*     | Status of row p | Status of column s | Status of row p  |
 296.157 +*     +-----------------+--------------------+------------------+
 296.158 +*     |     GLP_BS      |       GLP_BS       |       N/A        |
 296.159 +*     |     GLP_BS      |       GLP_NL       |      GLP_BS      |
 296.160 +*     |     GLP_BS      |       GLP_NU       |      GLP_BS      |
 296.161 +*     |     GLP_NS      |       GLP_BS       |      GLP_BS      |
 296.162 +*     |     GLP_NS      |       GLP_NL       |      GLP_NL      |
 296.163 +*     |     GLP_NS      |       GLP_NU       |      GLP_NU      |
 296.164 +*     +-----------------+--------------------+------------------+
 296.165 +*
 296.166 +*  Value of row multiplier pi[p] in solution to the original problem
 296.167 +*  is the same as in solution to the transformed problem.
 296.168 +*
 296.169 +*  1. In solution to the transformed problem row p and column q cannot
 296.170 +*     be basic at the same time; otherwise the basis matrix would have
 296.171 +*     two linear dependent columns: unity column of auxiliary variable
 296.172 +*     of row p and unity column of variable s.
 296.173 +*
 296.174 +*  2. Though in the transformed problem row p is equality constraint,
 296.175 +*     it may be basic due to primal degenerate solution.
 296.176 +*
 296.177 +*  RECOVERING INTERIOR-POINT SOLUTION
 296.178 +*
 296.179 +*  Value of row multiplier pi[p] in solution to the original problem
 296.180 +*  is the same as in solution to the transformed problem.
 296.181 +*
 296.182 +*  RECOVERING MIP SOLUTION
 296.183 +*
 296.184 +*  None needed. */
 296.185 +
 296.186 +struct ineq_row
 296.187 +{     /* inequality constraint row */
 296.188 +      int p;
 296.189 +      /* row reference number */
 296.190 +      int s;
 296.191 +      /* column reference number for slack/surplus variable */
 296.192 +};
 296.193 +
 296.194 +static int rcv_geq_row(NPP *npp, void *info);
 296.195 +
 296.196 +void npp_geq_row(NPP *npp, NPPROW *p)
 296.197 +{     /* process row of 'not less than' type */
 296.198 +      struct ineq_row *info;
 296.199 +      NPPCOL *s;
 296.200 +      /* the row must have lower bound */
 296.201 +      xassert(p->lb != -DBL_MAX);
 296.202 +      xassert(p->lb < p->ub);
 296.203 +      /* create column for surplus variable */
 296.204 +      s = npp_add_col(npp);
 296.205 +      s->lb = 0.0;
 296.206 +      s->ub = (p->ub == +DBL_MAX ? +DBL_MAX : p->ub - p->lb);
 296.207 +      /* and add it to the transformed problem */
 296.208 +      npp_add_aij(npp, p, s, -1.0);
 296.209 +      /* create transformation stack entry */
 296.210 +      info = npp_push_tse(npp,
 296.211 +         rcv_geq_row, sizeof(struct ineq_row));
 296.212 +      info->p = p->i;
 296.213 +      info->s = s->j;
 296.214 +      /* replace the row by equality constraint */
 296.215 +      p->ub = p->lb;
 296.216 +      return;
 296.217 +}
 296.218 +
 296.219 +static int rcv_geq_row(NPP *npp, void *_info)
 296.220 +{     /* recover row of 'not less than' type */
 296.221 +      struct ineq_row *info = _info;
 296.222 +      if (npp->sol == GLP_SOL)
 296.223 +      {  if (npp->r_stat[info->p] == GLP_BS)
 296.224 +         {  if (npp->c_stat[info->s] == GLP_BS)
 296.225 +            {  npp_error();
 296.226 +               return 1;
 296.227 +            }
 296.228 +            else if (npp->c_stat[info->s] == GLP_NL ||
 296.229 +                     npp->c_stat[info->s] == GLP_NU)
 296.230 +               npp->r_stat[info->p] = GLP_BS;
 296.231 +            else
 296.232 +            {  npp_error();
 296.233 +               return 1;
 296.234 +            }
 296.235 +         }
 296.236 +         else if (npp->r_stat[info->p] == GLP_NS)
 296.237 +         {  if (npp->c_stat[info->s] == GLP_BS)
 296.238 +               npp->r_stat[info->p] = GLP_BS;
 296.239 +            else if (npp->c_stat[info->s] == GLP_NL)
 296.240 +               npp->r_stat[info->p] = GLP_NL;
 296.241 +            else if (npp->c_stat[info->s] == GLP_NU)
 296.242 +               npp->r_stat[info->p] = GLP_NU;
 296.243 +            else
 296.244 +            {  npp_error();
 296.245 +               return 1;
 296.246 +            }
 296.247 +         }
 296.248 +         else
 296.249 +         {  npp_error();
 296.250 +            return 1;
 296.251 +         }
 296.252 +      }
 296.253 +      return 0;
 296.254 +}
 296.255 +
 296.256 +/***********************************************************************
 296.257 +*  NAME
 296.258 +*
 296.259 +*  npp_leq_row - process row of 'not greater than' type
 296.260 +*
 296.261 +*  SYNOPSIS
 296.262 +*
 296.263 +*  #include "glpnpp.h"
 296.264 +*  void npp_leq_row(NPP *npp, NPPROW *p);
 296.265 +*
 296.266 +*  DESCRIPTION
 296.267 +*
 296.268 +*  The routine npp_leq_row processes row p, which is 'not greater than'
 296.269 +*  inequality constraint:
 296.270 +*
 296.271 +*     (L[p] <=) sum a[p,j] x[j] <= U[p],                             (1)
 296.272 +*                j
 296.273 +*
 296.274 +*  where L[p] < U[p], and lower bound may not exist (L[p] = +oo).
 296.275 +*
 296.276 +*  PROBLEM TRANSFORMATION
 296.277 +*
 296.278 +*  Constraint (1) can be replaced by equality constraint:
 296.279 +*
 296.280 +*     sum a[p,j] x[j] + s = L[p],                                    (2)
 296.281 +*      j
 296.282 +*
 296.283 +*  where
 296.284 +*
 296.285 +*     0 <= s (<= U[p] - L[p])                                        (3)
 296.286 +*
 296.287 +*  is a non-negative slack variable.
 296.288 +*
 296.289 +*  Since in the primal system there appears column s having the only
 296.290 +*  non-zero coefficient in row p, in the dual system there appears a
 296.291 +*  new row:
 296.292 +*
 296.293 +*     (+1) pi[p] + lambda = 0,                                       (4)
 296.294 +*
 296.295 +*  where (+1) is coefficient of column s in row p, pi[p] is multiplier
 296.296 +*  of row p, lambda is multiplier of column q, 0 is coefficient of
 296.297 +*  column s in the objective row.
 296.298 +*
 296.299 +*  RECOVERING BASIC SOLUTION
 296.300 +*
 296.301 +*  Status of row p in solution to the original problem is determined
 296.302 +*  by its status and status of column q in solution to the transformed
 296.303 +*  problem as follows:
 296.304 +*
 296.305 +*     +--------------------------------------+------------------+
 296.306 +*     |         Transformed problem          | Original problem |
 296.307 +*     +-----------------+--------------------+------------------+
 296.308 +*     | Status of row p | Status of column s | Status of row p  |
 296.309 +*     +-----------------+--------------------+------------------+
 296.310 +*     |     GLP_BS      |       GLP_BS       |       N/A        |
 296.311 +*     |     GLP_BS      |       GLP_NL       |      GLP_BS      |
 296.312 +*     |     GLP_BS      |       GLP_NU       |      GLP_BS      |
 296.313 +*     |     GLP_NS      |       GLP_BS       |      GLP_BS      |
 296.314 +*     |     GLP_NS      |       GLP_NL       |      GLP_NU      |
 296.315 +*     |     GLP_NS      |       GLP_NU       |      GLP_NL      |
 296.316 +*     +-----------------+--------------------+------------------+
 296.317 +*
 296.318 +*  Value of row multiplier pi[p] in solution to the original problem
 296.319 +*  is the same as in solution to the transformed problem.
 296.320 +*
 296.321 +*  1. In solution to the transformed problem row p and column q cannot
 296.322 +*     be basic at the same time; otherwise the basis matrix would have
 296.323 +*     two linear dependent columns: unity column of auxiliary variable
 296.324 +*     of row p and unity column of variable s.
 296.325 +*
 296.326 +*  2. Though in the transformed problem row p is equality constraint,
 296.327 +*     it may be basic due to primal degeneracy.
 296.328 +*
 296.329 +*  RECOVERING INTERIOR-POINT SOLUTION
 296.330 +*
 296.331 +*  Value of row multiplier pi[p] in solution to the original problem
 296.332 +*  is the same as in solution to the transformed problem.
 296.333 +*
 296.334 +*  RECOVERING MIP SOLUTION
 296.335 +*
 296.336 +*  None needed. */
 296.337 +
 296.338 +static int rcv_leq_row(NPP *npp, void *info);
 296.339 +
 296.340 +void npp_leq_row(NPP *npp, NPPROW *p)
 296.341 +{     /* process row of 'not greater than' type */
 296.342 +      struct ineq_row *info;
 296.343 +      NPPCOL *s;
 296.344 +      /* the row must have upper bound */
 296.345 +      xassert(p->ub != +DBL_MAX);
 296.346 +      xassert(p->lb < p->ub);
 296.347 +      /* create column for slack variable */
 296.348 +      s = npp_add_col(npp);
 296.349 +      s->lb = 0.0;
 296.350 +      s->ub = (p->lb == -DBL_MAX ? +DBL_MAX : p->ub - p->lb);
 296.351 +      /* and add it to the transformed problem */
 296.352 +      npp_add_aij(npp, p, s, +1.0);
 296.353 +      /* create transformation stack entry */
 296.354 +      info = npp_push_tse(npp,
 296.355 +         rcv_leq_row, sizeof(struct ineq_row));
 296.356 +      info->p = p->i;
 296.357 +      info->s = s->j;
 296.358 +      /* replace the row by equality constraint */
 296.359 +      p->lb = p->ub;
 296.360 +      return;
 296.361 +}
 296.362 +
 296.363 +static int rcv_leq_row(NPP *npp, void *_info)
 296.364 +{     /* recover row of 'not greater than' type */
 296.365 +      struct ineq_row *info = _info;
 296.366 +      if (npp->sol == GLP_SOL)
 296.367 +      {  if (npp->r_stat[info->p] == GLP_BS)
 296.368 +         {  if (npp->c_stat[info->s] == GLP_BS)
 296.369 +            {  npp_error();
 296.370 +               return 1;
 296.371 +            }
 296.372 +            else if (npp->c_stat[info->s] == GLP_NL ||
 296.373 +                     npp->c_stat[info->s] == GLP_NU)
 296.374 +               npp->r_stat[info->p] = GLP_BS;
 296.375 +            else
 296.376 +            {  npp_error();
 296.377 +               return 1;
 296.378 +            }
 296.379 +         }
 296.380 +         else if (npp->r_stat[info->p] == GLP_NS)
 296.381 +         {  if (npp->c_stat[info->s] == GLP_BS)
 296.382 +               npp->r_stat[info->p] = GLP_BS;
 296.383 +            else if (npp->c_stat[info->s] == GLP_NL)
 296.384 +               npp->r_stat[info->p] = GLP_NU;
 296.385 +            else if (npp->c_stat[info->s] == GLP_NU)
 296.386 +               npp->r_stat[info->p] = GLP_NL;
 296.387 +            else
 296.388 +            {  npp_error();
 296.389 +               return 1;
 296.390 +            }
 296.391 +         }
 296.392 +         else
 296.393 +         {  npp_error();
 296.394 +            return 1;
 296.395 +         }
 296.396 +      }
 296.397 +      return 0;
 296.398 +}
 296.399 +
 296.400 +/***********************************************************************
 296.401 +*  NAME
 296.402 +*
 296.403 +*  npp_free_col - process free (unbounded) column
 296.404 +*
 296.405 +*  SYNOPSIS
 296.406 +*
 296.407 +*  #include "glpnpp.h"
 296.408 +*  void npp_free_col(NPP *npp, NPPCOL *q);
 296.409 +*
 296.410 +*  DESCRIPTION
 296.411 +*
 296.412 +*  The routine npp_free_col processes column q, which is free (i.e. has
 296.413 +*  no finite bounds):
 296.414 +*
 296.415 +*     -oo < x[q] < +oo.                                              (1)
 296.416 +*
 296.417 +*  PROBLEM TRANSFORMATION
 296.418 +*
 296.419 +*  Free (unbounded) variable can be replaced by the difference of two
 296.420 +*  non-negative variables:
 296.421 +*
 296.422 +*     x[q] = s' - s'',   s', s'' >= 0.                               (2)
 296.423 +*
 296.424 +*  Assuming that in the transformed problem x[q] becomes s',
 296.425 +*  transformation (2) causes new column s'' to appear, which differs
 296.426 +*  from column s' only in the sign of coefficients in constraint and
 296.427 +*  objective rows. Thus, if in the dual system the following row
 296.428 +*  corresponds to column s':
 296.429 +*
 296.430 +*     sum a[i,q] pi[i] + lambda' = c[q],                             (3)
 296.431 +*      i
 296.432 +*
 296.433 +*  the row which corresponds to column s'' is the following:
 296.434 +*
 296.435 +*     sum (-a[i,q]) pi[i] + lambda'' = -c[q].                        (4)
 296.436 +*      i
 296.437 +*
 296.438 +*  Then from (3) and (4) it follows that:
 296.439 +*
 296.440 +*     lambda' + lambda'' = 0   =>   lambda' = lmabda'' = 0,          (5)
 296.441 +*
 296.442 +*  where lambda' and lambda'' are multipliers for columns s' and s'',
 296.443 +*  resp.
 296.444 +*
 296.445 +*  RECOVERING BASIC SOLUTION
 296.446 +*
 296.447 +*  With respect to (5) status of column q in solution to the original
 296.448 +*  problem is determined by statuses of columns s' and s'' in solution
 296.449 +*  to the transformed problem as follows:
 296.450 +*
 296.451 +*     +--------------------------------------+------------------+
 296.452 +*     |         Transformed problem          | Original problem |
 296.453 +*     +------------------+-------------------+------------------+
 296.454 +*     | Status of col s' | Status of col s'' | Status of col q  |
 296.455 +*     +------------------+-------------------+------------------+
 296.456 +*     |      GLP_BS      |      GLP_BS       |       N/A        |
 296.457 +*     |      GLP_BS      |      GLP_NL       |      GLP_BS      |
 296.458 +*     |      GLP_NL      |      GLP_BS       |      GLP_BS      |
 296.459 +*     |      GLP_NL      |      GLP_NL       |      GLP_NF      |
 296.460 +*     +------------------+-------------------+------------------+
 296.461 +*
 296.462 +*  Value of column q is computed with formula (2).
 296.463 +*
 296.464 +*  1. In solution to the transformed problem columns s' and s'' cannot
 296.465 +*     be basic at the same time, because they differ only in the sign,
 296.466 +*     hence, are linear dependent.
 296.467 +*
 296.468 +*  2. Though column q is free, it can be non-basic due to dual
 296.469 +*     degeneracy.
 296.470 +*
 296.471 +*  3. If column q is integral, columns s' and s'' are also integral.
 296.472 +*
 296.473 +*  RECOVERING INTERIOR-POINT SOLUTION
 296.474 +*
 296.475 +*  Value of column q is computed with formula (2).
 296.476 +*
 296.477 +*  RECOVERING MIP SOLUTION
 296.478 +*
 296.479 +*  Value of column q is computed with formula (2). */
 296.480 +
 296.481 +struct free_col
 296.482 +{     /* free (unbounded) column */
 296.483 +      int q;
 296.484 +      /* column reference number for variables x[q] and s' */
 296.485 +      int s;
 296.486 +      /* column reference number for variable s'' */
 296.487 +};
 296.488 +
 296.489 +static int rcv_free_col(NPP *npp, void *info);
 296.490 +
 296.491 +void npp_free_col(NPP *npp, NPPCOL *q)
 296.492 +{     /* process free (unbounded) column */
 296.493 +      struct free_col *info;
 296.494 +      NPPCOL *s;
 296.495 +      NPPAIJ *aij;
 296.496 +      /* the column must be free */
 296.497 +      xassert(q->lb == -DBL_MAX && q->ub == +DBL_MAX);
 296.498 +      /* variable x[q] becomes s' */
 296.499 +      q->lb = 0.0, q->ub = +DBL_MAX;
 296.500 +      /* create variable s'' */
 296.501 +      s = npp_add_col(npp);
 296.502 +      s->is_int = q->is_int;
 296.503 +      s->lb = 0.0, s->ub = +DBL_MAX;
 296.504 +      /* duplicate objective coefficient */
 296.505 +      s->coef = -q->coef;
 296.506 +      /* duplicate column of the constraint matrix */
 296.507 +      for (aij = q->ptr; aij != NULL; aij = aij->c_next)
 296.508 +         npp_add_aij(npp, aij->row, s, -aij->val);
 296.509 +      /* create transformation stack entry */
 296.510 +      info = npp_push_tse(npp,
 296.511 +         rcv_free_col, sizeof(struct free_col));
 296.512 +      info->q = q->j;
 296.513 +      info->s = s->j;
 296.514 +      return;
 296.515 +}
 296.516 +
 296.517 +static int rcv_free_col(NPP *npp, void *_info)
 296.518 +{     /* recover free (unbounded) column */
 296.519 +      struct free_col *info = _info;
 296.520 +      if (npp->sol == GLP_SOL)
 296.521 +      {  if (npp->c_stat[info->q] == GLP_BS)
 296.522 +         {  if (npp->c_stat[info->s] == GLP_BS)
 296.523 +            {  npp_error();
 296.524 +               return 1;
 296.525 +            }
 296.526 +            else if (npp->c_stat[info->s] == GLP_NL)
 296.527 +               npp->c_stat[info->q] = GLP_BS;
 296.528 +            else
 296.529 +            {  npp_error();
 296.530 +               return -1;
 296.531 +            }
 296.532 +         }
 296.533 +         else if (npp->c_stat[info->q] == GLP_NL)
 296.534 +         {  if (npp->c_stat[info->s] == GLP_BS)
 296.535 +               npp->c_stat[info->q] = GLP_BS;
 296.536 +            else if (npp->c_stat[info->s] == GLP_NL)
 296.537 +               npp->c_stat[info->q] = GLP_NF;
 296.538 +            else
 296.539 +            {  npp_error();
 296.540 +               return -1;
 296.541 +            }
 296.542 +         }
 296.543 +         else
 296.544 +         {  npp_error();
 296.545 +            return -1;
 296.546 +         }
 296.547 +      }
 296.548 +      /* compute value of x[q] with formula (2) */
 296.549 +      npp->c_value[info->q] -= npp->c_value[info->s];
 296.550 +      return 0;
 296.551 +}
 296.552 +
 296.553 +/***********************************************************************
 296.554 +*  NAME
 296.555 +*
 296.556 +*  npp_lbnd_col - process column with (non-zero) lower bound
 296.557 +*
 296.558 +*  SYNOPSIS
 296.559 +*
 296.560 +*  #include "glpnpp.h"
 296.561 +*  void npp_lbnd_col(NPP *npp, NPPCOL *q);
 296.562 +*
 296.563 +*  DESCRIPTION
 296.564 +*
 296.565 +*  The routine npp_lbnd_col processes column q, which has (non-zero)
 296.566 +*  lower bound:
 296.567 +*
 296.568 +*     l[q] <= x[q] (<= u[q]),                                        (1)
 296.569 +*
 296.570 +*  where l[q] < u[q], and upper bound may not exist (u[q] = +oo).
 296.571 +*
 296.572 +*  PROBLEM TRANSFORMATION
 296.573 +*
 296.574 +*  Column q can be replaced as follows:
 296.575 +*
 296.576 +*     x[q] = l[q] + s,                                               (2)
 296.577 +*
 296.578 +*  where
 296.579 +*
 296.580 +*     0 <= s (<= u[q] - l[q])                                        (3)
 296.581 +*
 296.582 +*  is a non-negative variable.
 296.583 +*
 296.584 +*  Substituting x[q] from (2) into the objective row, we have:
 296.585 +*
 296.586 +*     z = sum c[j] x[j] + c0 =
 296.587 +*          j
 296.588 +*
 296.589 +*       = sum c[j] x[j] + c[q] x[q] + c0 =
 296.590 +*         j!=q
 296.591 +*
 296.592 +*       = sum c[j] x[j] + c[q] (l[q] + s) + c0 =
 296.593 +*         j!=q
 296.594 +*
 296.595 +*       = sum c[j] x[j] + c[q] s + c~0,
 296.596 +*
 296.597 +*  where
 296.598 +*
 296.599 +*     c~0 = c0 + c[q] l[q]                                           (4)
 296.600 +*
 296.601 +*  is the constant term of the objective in the transformed problem.
 296.602 +*  Similarly, substituting x[q] into constraint row i, we have:
 296.603 +*
 296.604 +*     L[i] <= sum a[i,j] x[j] <= U[i]  ==>
 296.605 +*              j
 296.606 +*
 296.607 +*     L[i] <= sum a[i,j] x[j] + a[i,q] x[q] <= U[i]  ==>
 296.608 +*             j!=q
 296.609 +*
 296.610 +*     L[i] <= sum a[i,j] x[j] + a[i,q] (l[q] + s) <= U[i]  ==>
 296.611 +*             j!=q
 296.612 +*
 296.613 +*     L~[i] <= sum a[i,j] x[j] + a[i,q] s <= U~[i],
 296.614 +*              j!=q
 296.615 +*
 296.616 +*  where
 296.617 +*
 296.618 +*     L~[i] = L[i] - a[i,q] l[q],  U~[i] = U[i] - a[i,q] l[q]        (5)
 296.619 +*
 296.620 +*  are lower and upper bounds of row i in the transformed problem,
 296.621 +*  resp.
 296.622 +*
 296.623 +*  Transformation (2) does not affect the dual system.
 296.624 +*
 296.625 +*  RECOVERING BASIC SOLUTION
 296.626 +*
 296.627 +*  Status of column q in solution to the original problem is the same
 296.628 +*  as in solution to the transformed problem (GLP_BS, GLP_NL or GLP_NU).
 296.629 +*  Value of column q is computed with formula (2).
 296.630 +*
 296.631 +*  RECOVERING INTERIOR-POINT SOLUTION
 296.632 +*
 296.633 +*  Value of column q is computed with formula (2).
 296.634 +*
 296.635 +*  RECOVERING MIP SOLUTION
 296.636 +*
 296.637 +*  Value of column q is computed with formula (2). */
 296.638 +
 296.639 +struct bnd_col
 296.640 +{     /* bounded column */
 296.641 +      int q;
 296.642 +      /* column reference number for variables x[q] and s */
 296.643 +      double bnd;
 296.644 +      /* lower/upper bound l[q] or u[q] */
 296.645 +};
 296.646 +
 296.647 +static int rcv_lbnd_col(NPP *npp, void *info);
 296.648 +
 296.649 +void npp_lbnd_col(NPP *npp, NPPCOL *q)
 296.650 +{     /* process column with (non-zero) lower bound */
 296.651 +      struct bnd_col *info;
 296.652 +      NPPROW *i;
 296.653 +      NPPAIJ *aij;
 296.654 +      /* the column must have non-zero lower bound */
 296.655 +      xassert(q->lb != 0.0);
 296.656 +      xassert(q->lb != -DBL_MAX);
 296.657 +      xassert(q->lb < q->ub);
 296.658 +      /* create transformation stack entry */
 296.659 +      info = npp_push_tse(npp,
 296.660 +         rcv_lbnd_col, sizeof(struct bnd_col));
 296.661 +      info->q = q->j;
 296.662 +      info->bnd = q->lb;
 296.663 +      /* substitute x[q] into objective row */
 296.664 +      npp->c0 += q->coef * q->lb;
 296.665 +      /* substitute x[q] into constraint rows */
 296.666 +      for (aij = q->ptr; aij != NULL; aij = aij->c_next)
 296.667 +      {  i = aij->row;
 296.668 +         if (i->lb == i->ub)
 296.669 +            i->ub = (i->lb -= aij->val * q->lb);
 296.670 +         else
 296.671 +         {  if (i->lb != -DBL_MAX)
 296.672 +               i->lb -= aij->val * q->lb;
 296.673 +            if (i->ub != +DBL_MAX)
 296.674 +               i->ub -= aij->val * q->lb;
 296.675 +         }
 296.676 +      }
 296.677 +      /* column x[q] becomes column s */
 296.678 +      if (q->ub != +DBL_MAX)
 296.679 +         q->ub -= q->lb;
 296.680 +      q->lb = 0.0;
 296.681 +      return;
 296.682 +}
 296.683 +
 296.684 +static int rcv_lbnd_col(NPP *npp, void *_info)
 296.685 +{     /* recover column with (non-zero) lower bound */
 296.686 +      struct bnd_col *info = _info;
 296.687 +      if (npp->sol == GLP_SOL)
 296.688 +      {  if (npp->c_stat[info->q] == GLP_BS ||
 296.689 +             npp->c_stat[info->q] == GLP_NL ||
 296.690 +             npp->c_stat[info->q] == GLP_NU)
 296.691 +            npp->c_stat[info->q] = npp->c_stat[info->q];
 296.692 +         else
 296.693 +         {  npp_error();
 296.694 +            return 1;
 296.695 +         }
 296.696 +      }
 296.697 +      /* compute value of x[q] with formula (2) */
 296.698 +      npp->c_value[info->q] = info->bnd + npp->c_value[info->q];
 296.699 +      return 0;
 296.700 +}
 296.701 +
 296.702 +/***********************************************************************
 296.703 +*  NAME
 296.704 +*
 296.705 +*  npp_ubnd_col - process column with upper bound
 296.706 +*
 296.707 +*  SYNOPSIS
 296.708 +*
 296.709 +*  #include "glpnpp.h"
 296.710 +*  void npp_ubnd_col(NPP *npp, NPPCOL *q);
 296.711 +*
 296.712 +*  DESCRIPTION
 296.713 +*
 296.714 +*  The routine npp_ubnd_col processes column q, which has upper bound:
 296.715 +*
 296.716 +*     (l[q] <=) x[q] <= u[q],                                        (1)
 296.717 +*
 296.718 +*  where l[q] < u[q], and lower bound may not exist (l[q] = -oo).
 296.719 +*
 296.720 +*  PROBLEM TRANSFORMATION
 296.721 +*
 296.722 +*  Column q can be replaced as follows:
 296.723 +*
 296.724 +*     x[q] = u[q] - s,                                               (2)
 296.725 +*
 296.726 +*  where
 296.727 +*
 296.728 +*     0 <= s (<= u[q] - l[q])                                        (3)
 296.729 +*
 296.730 +*  is a non-negative variable.
 296.731 +*
 296.732 +*  Substituting x[q] from (2) into the objective row, we have:
 296.733 +*
 296.734 +*     z = sum c[j] x[j] + c0 =
 296.735 +*          j
 296.736 +*
 296.737 +*       = sum c[j] x[j] + c[q] x[q] + c0 =
 296.738 +*         j!=q
 296.739 +*
 296.740 +*       = sum c[j] x[j] + c[q] (u[q] - s) + c0 =
 296.741 +*         j!=q
 296.742 +*
 296.743 +*       = sum c[j] x[j] - c[q] s + c~0,
 296.744 +*
 296.745 +*  where
 296.746 +*
 296.747 +*     c~0 = c0 + c[q] u[q]                                           (4)
 296.748 +*
 296.749 +*  is the constant term of the objective in the transformed problem.
 296.750 +*  Similarly, substituting x[q] into constraint row i, we have:
 296.751 +*
 296.752 +*     L[i] <= sum a[i,j] x[j] <= U[i]  ==>
 296.753 +*              j
 296.754 +*
 296.755 +*     L[i] <= sum a[i,j] x[j] + a[i,q] x[q] <= U[i]  ==>
 296.756 +*             j!=q
 296.757 +*
 296.758 +*     L[i] <= sum a[i,j] x[j] + a[i,q] (u[q] - s) <= U[i]  ==>
 296.759 +*             j!=q
 296.760 +*
 296.761 +*     L~[i] <= sum a[i,j] x[j] - a[i,q] s <= U~[i],
 296.762 +*              j!=q
 296.763 +*
 296.764 +*  where
 296.765 +*
 296.766 +*     L~[i] = L[i] - a[i,q] u[q],  U~[i] = U[i] - a[i,q] u[q]        (5)
 296.767 +*
 296.768 +*  are lower and upper bounds of row i in the transformed problem,
 296.769 +*  resp.
 296.770 +*
 296.771 +*  Note that in the transformed problem coefficients c[q] and a[i,q]
 296.772 +*  change their sign. Thus, the row of the dual system corresponding to
 296.773 +*  column q:
 296.774 +*
 296.775 +*     sum a[i,q] pi[i] + lambda[q] = c[q]                            (6)
 296.776 +*      i
 296.777 +*
 296.778 +*  in the transformed problem becomes the following:
 296.779 +*
 296.780 +*     sum (-a[i,q]) pi[i] + lambda[s] = -c[q].                       (7)
 296.781 +*      i
 296.782 +*
 296.783 +*  Therefore:
 296.784 +*
 296.785 +*     lambda[q] = - lambda[s],                                       (8)
 296.786 +*
 296.787 +*  where lambda[q] is multiplier for column q, lambda[s] is multiplier
 296.788 +*  for column s.
 296.789 +*
 296.790 +*  RECOVERING BASIC SOLUTION
 296.791 +*
 296.792 +*  With respect to (8) status of column q in solution to the original
 296.793 +*  problem is determined by status of column s in solution to the
 296.794 +*  transformed problem as follows:
 296.795 +*
 296.796 +*     +-----------------------+--------------------+
 296.797 +*     |  Status of column s   | Status of column q |
 296.798 +*     | (transformed problem) | (original problem) |
 296.799 +*     +-----------------------+--------------------+
 296.800 +*     |        GLP_BS         |       GLP_BS       |
 296.801 +*     |        GLP_NL         |       GLP_NU       |
 296.802 +*     |        GLP_NU         |       GLP_NL       |
 296.803 +*     +-----------------------+--------------------+
 296.804 +*
 296.805 +*  Value of column q is computed with formula (2).
 296.806 +*
 296.807 +*  RECOVERING INTERIOR-POINT SOLUTION
 296.808 +*
 296.809 +*  Value of column q is computed with formula (2).
 296.810 +*
 296.811 +*  RECOVERING MIP SOLUTION
 296.812 +*
 296.813 +*  Value of column q is computed with formula (2). */
 296.814 +
 296.815 +static int rcv_ubnd_col(NPP *npp, void *info);
 296.816 +
 296.817 +void npp_ubnd_col(NPP *npp, NPPCOL *q)
 296.818 +{     /* process column with upper bound */
 296.819 +      struct bnd_col *info;
 296.820 +      NPPROW *i;
 296.821 +      NPPAIJ *aij;
 296.822 +      /* the column must have upper bound */
 296.823 +      xassert(q->ub != +DBL_MAX);
 296.824 +      xassert(q->lb < q->ub);
 296.825 +      /* create transformation stack entry */
 296.826 +      info = npp_push_tse(npp,
 296.827 +         rcv_ubnd_col, sizeof(struct bnd_col));
 296.828 +      info->q = q->j;
 296.829 +      info->bnd = q->ub;
 296.830 +      /* substitute x[q] into objective row */
 296.831 +      npp->c0 += q->coef * q->ub;
 296.832 +      q->coef = -q->coef;
 296.833 +      /* substitute x[q] into constraint rows */
 296.834 +      for (aij = q->ptr; aij != NULL; aij = aij->c_next)
 296.835 +      {  i = aij->row;
 296.836 +         if (i->lb == i->ub)
 296.837 +            i->ub = (i->lb -= aij->val * q->ub);
 296.838 +         else
 296.839 +         {  if (i->lb != -DBL_MAX)
 296.840 +               i->lb -= aij->val * q->ub;
 296.841 +            if (i->ub != +DBL_MAX)
 296.842 +               i->ub -= aij->val * q->ub;
 296.843 +         }
 296.844 +         aij->val = -aij->val;
 296.845 +      }
 296.846 +      /* column x[q] becomes column s */
 296.847 +      if (q->lb != -DBL_MAX)
 296.848 +         q->ub -= q->lb;
 296.849 +      else
 296.850 +         q->ub = +DBL_MAX;
 296.851 +      q->lb = 0.0;
 296.852 +      return;
 296.853 +}
 296.854 +
 296.855 +static int rcv_ubnd_col(NPP *npp, void *_info)
 296.856 +{     /* recover column with upper bound */
 296.857 +      struct bnd_col *info = _info;
 296.858 +      if (npp->sol == GLP_BS)
 296.859 +      {  if (npp->c_stat[info->q] == GLP_BS)
 296.860 +            npp->c_stat[info->q] = GLP_BS;
 296.861 +         else if (npp->c_stat[info->q] == GLP_NL)
 296.862 +            npp->c_stat[info->q] = GLP_NU;
 296.863 +         else if (npp->c_stat[info->q] == GLP_NU)
 296.864 +            npp->c_stat[info->q] = GLP_NL;
 296.865 +         else
 296.866 +         {  npp_error();
 296.867 +            return 1;
 296.868 +         }
 296.869 +      }
 296.870 +      /* compute value of x[q] with formula (2) */
 296.871 +      npp->c_value[info->q] = info->bnd - npp->c_value[info->q];
 296.872 +      return 0;
 296.873 +}
 296.874 +
 296.875 +/***********************************************************************
 296.876 +*  NAME
 296.877 +*
 296.878 +*  npp_dbnd_col - process non-negative column with upper bound
 296.879 +*
 296.880 +*  SYNOPSIS
 296.881 +*
 296.882 +*  #include "glpnpp.h"
 296.883 +*  void npp_dbnd_col(NPP *npp, NPPCOL *q);
 296.884 +*
 296.885 +*  DESCRIPTION
 296.886 +*
 296.887 +*  The routine npp_dbnd_col processes column q, which is non-negative
 296.888 +*  and has upper bound:
 296.889 +*
 296.890 +*     0 <= x[q] <= u[q],                                             (1)
 296.891 +*
 296.892 +*  where u[q] > 0.
 296.893 +*
 296.894 +*  PROBLEM TRANSFORMATION
 296.895 +*
 296.896 +*  Upper bound of column q can be replaced by the following equality
 296.897 +*  constraint:
 296.898 +*
 296.899 +*     x[q] + s = u[q],                                               (2)
 296.900 +*
 296.901 +*  where s >= 0 is a non-negative complement variable.
 296.902 +*
 296.903 +*  Since in the primal system along with new row (2) there appears a
 296.904 +*  new column s having the only non-zero coefficient in this row, in
 296.905 +*  the dual system there appears a new row:
 296.906 +*
 296.907 +*     (+1)pi + lambda[s] = 0,                                        (3)
 296.908 +*
 296.909 +*  where (+1) is coefficient at column s in row (2), pi is multiplier
 296.910 +*  for row (2), lambda[s] is multiplier for column s, 0 is coefficient
 296.911 +*  at column s in the objective row.
 296.912 +*
 296.913 +*  RECOVERING BASIC SOLUTION
 296.914 +*
 296.915 +*  Status of column q in solution to the original problem is determined
 296.916 +*  by its status and status of column s in solution to the transformed
 296.917 +*  problem as follows:
 296.918 +*
 296.919 +*     +-----------------------------------+------------------+
 296.920 +*     |         Transformed problem       | Original problem |
 296.921 +*     +-----------------+-----------------+------------------+
 296.922 +*     | Status of col q | Status of col s | Status of col q  |
 296.923 +*     +-----------------+-----------------+------------------+
 296.924 +*     |     GLP_BS      |     GLP_BS      |      GLP_BS      |
 296.925 +*     |     GLP_BS      |     GLP_NL      |      GLP_NU      |
 296.926 +*     |     GLP_NL      |     GLP_BS      |      GLP_NL      |
 296.927 +*     |     GLP_NL      |     GLP_NL      |      GLP_NL (*)  |
 296.928 +*     +-----------------+-----------------+------------------+
 296.929 +*
 296.930 +*  Value of column q in solution to the original problem is the same as
 296.931 +*  in solution to the transformed problem.
 296.932 +*
 296.933 +*  1. Formally, in solution to the transformed problem columns q and s
 296.934 +*     cannot be non-basic at the same time, since the constraint (2)
 296.935 +*     would be violated. However, if u[q] is close to zero, violation
 296.936 +*     may be less than a working precision even if both columns q and s
 296.937 +*     are non-basic. In this degenerate case row (2) can be only basic,
 296.938 +*     i.e. non-active constraint (otherwise corresponding row of the
 296.939 +*     basis matrix would be zero). This allows to pivot out auxiliary
 296.940 +*     variable and pivot in column s, in which case the row becomes
 296.941 +*     active while column s becomes basic.
 296.942 +*
 296.943 +*  2. If column q is integral, column s is also integral.
 296.944 +*
 296.945 +*  RECOVERING INTERIOR-POINT SOLUTION
 296.946 +*
 296.947 +*  Value of column q in solution to the original problem is the same as
 296.948 +*  in solution to the transformed problem.
 296.949 +*
 296.950 +*  RECOVERING MIP SOLUTION
 296.951 +*
 296.952 +*  Value of column q in solution to the original problem is the same as
 296.953 +*  in solution to the transformed problem. */
 296.954 +
 296.955 +struct dbnd_col
 296.956 +{     /* double-bounded column */
 296.957 +      int q;
 296.958 +      /* column reference number for variable x[q] */
 296.959 +      int s;
 296.960 +      /* column reference number for complement variable s */
 296.961 +};
 296.962 +
 296.963 +static int rcv_dbnd_col(NPP *npp, void *info);
 296.964 +
 296.965 +void npp_dbnd_col(NPP *npp, NPPCOL *q)
 296.966 +{     /* process non-negative column with upper bound */
 296.967 +      struct dbnd_col *info;
 296.968 +      NPPROW *p;
 296.969 +      NPPCOL *s;
 296.970 +      /* the column must be non-negative with upper bound */
 296.971 +      xassert(q->lb == 0.0);
 296.972 +      xassert(q->ub > 0.0);
 296.973 +      xassert(q->ub != +DBL_MAX);
 296.974 +      /* create variable s */
 296.975 +      s = npp_add_col(npp);
 296.976 +      s->is_int = q->is_int;
 296.977 +      s->lb = 0.0, s->ub = +DBL_MAX;
 296.978 +      /* create equality constraint (2) */
 296.979 +      p = npp_add_row(npp);
 296.980 +      p->lb = p->ub = q->ub;
 296.981 +      npp_add_aij(npp, p, q, +1.0);
 296.982 +      npp_add_aij(npp, p, s, +1.0);
 296.983 +      /* create transformation stack entry */
 296.984 +      info = npp_push_tse(npp,
 296.985 +         rcv_dbnd_col, sizeof(struct dbnd_col));
 296.986 +      info->q = q->j;
 296.987 +      info->s = s->j;
 296.988 +      /* remove upper bound of x[q] */
 296.989 +      q->ub = +DBL_MAX;
 296.990 +      return;
 296.991 +}
 296.992 +
 296.993 +static int rcv_dbnd_col(NPP *npp, void *_info)
 296.994 +{     /* recover non-negative column with upper bound */
 296.995 +      struct dbnd_col *info = _info;
 296.996 +      if (npp->sol == GLP_BS)
 296.997 +      {  if (npp->c_stat[info->q] == GLP_BS)
 296.998 +         {  if (npp->c_stat[info->s] == GLP_BS)
 296.999 +               npp->c_stat[info->q] = GLP_BS;
296.1000 +            else if (npp->c_stat[info->s] == GLP_NL)
296.1001 +               npp->c_stat[info->q] = GLP_NU;
296.1002 +            else
296.1003 +            {  npp_error();
296.1004 +               return 1;
296.1005 +            }
296.1006 +         }
296.1007 +         else if (npp->c_stat[info->q] == GLP_NL)
296.1008 +         {  if (npp->c_stat[info->s] == GLP_BS ||
296.1009 +                npp->c_stat[info->s] == GLP_NL)
296.1010 +               npp->c_stat[info->q] = GLP_NL;
296.1011 +            else
296.1012 +            {  npp_error();
296.1013 +               return 1;
296.1014 +            }
296.1015 +         }
296.1016 +         else
296.1017 +         {  npp_error();
296.1018 +            return 1;
296.1019 +         }
296.1020 +      }
296.1021 +      return 0;
296.1022 +}
296.1023 +
296.1024 +/***********************************************************************
296.1025 +*  NAME
296.1026 +*
296.1027 +*  npp_fixed_col - process fixed column
296.1028 +*
296.1029 +*  SYNOPSIS
296.1030 +*
296.1031 +*  #include "glpnpp.h"
296.1032 +*  void npp_fixed_col(NPP *npp, NPPCOL *q);
296.1033 +*
296.1034 +*  DESCRIPTION
296.1035 +*
296.1036 +*  The routine npp_fixed_col processes column q, which is fixed:
296.1037 +*
296.1038 +*     x[q] = s[q],                                                   (1)
296.1039 +*
296.1040 +*  where s[q] is a fixed column value.
296.1041 +*
296.1042 +*  PROBLEM TRANSFORMATION
296.1043 +*
296.1044 +*  The value of a fixed column can be substituted into the objective
296.1045 +*  and constraint rows that allows removing the column from the problem.
296.1046 +*
296.1047 +*  Substituting x[q] = s[q] into the objective row, we have:
296.1048 +*
296.1049 +*     z = sum c[j] x[j] + c0 =
296.1050 +*          j
296.1051 +*
296.1052 +*       = sum c[j] x[j] + c[q] x[q] + c0 =
296.1053 +*         j!=q
296.1054 +*
296.1055 +*       = sum c[j] x[j] + c[q] s[q] + c0 =
296.1056 +*         j!=q
296.1057 +*
296.1058 +*       = sum c[j] x[j] + c~0,
296.1059 +*         j!=q
296.1060 +*
296.1061 +*  where
296.1062 +*
296.1063 +*     c~0 = c0 + c[q] s[q]                                           (2)
296.1064 +*
296.1065 +*  is the constant term of the objective in the transformed problem.
296.1066 +*  Similarly, substituting x[q] = s[q] into constraint row i, we have:
296.1067 +*
296.1068 +*     L[i] <= sum a[i,j] x[j] <= U[i]  ==>
296.1069 +*              j
296.1070 +*
296.1071 +*     L[i] <= sum a[i,j] x[j] + a[i,q] x[q] <= U[i]  ==>
296.1072 +*             j!=q
296.1073 +*
296.1074 +*     L[i] <= sum a[i,j] x[j] + a[i,q] s[q] <= U[i]  ==>
296.1075 +*             j!=q
296.1076 +*
296.1077 +*     L~[i] <= sum a[i,j] x[j] + a[i,q] s <= U~[i],
296.1078 +*              j!=q
296.1079 +*
296.1080 +*  where
296.1081 +*
296.1082 +*     L~[i] = L[i] - a[i,q] s[q],  U~[i] = U[i] - a[i,q] s[q]        (3)
296.1083 +*
296.1084 +*  are lower and upper bounds of row i in the transformed problem,
296.1085 +*  resp.
296.1086 +*
296.1087 +*  RECOVERING BASIC SOLUTION
296.1088 +*
296.1089 +*  Column q is assigned status GLP_NS and its value is assigned s[q].
296.1090 +*
296.1091 +*  RECOVERING INTERIOR-POINT SOLUTION
296.1092 +*
296.1093 +*  Value of column q is assigned s[q].
296.1094 +*
296.1095 +*  RECOVERING MIP SOLUTION
296.1096 +*
296.1097 +*  Value of column q is assigned s[q]. */
296.1098 +
296.1099 +struct fixed_col
296.1100 +{     /* fixed column */
296.1101 +      int q;
296.1102 +      /* column reference number for variable x[q] */
296.1103 +      double s;
296.1104 +      /* value, at which x[q] is fixed */
296.1105 +};
296.1106 +
296.1107 +static int rcv_fixed_col(NPP *npp, void *info);
296.1108 +
296.1109 +void npp_fixed_col(NPP *npp, NPPCOL *q)
296.1110 +{     /* process fixed column */
296.1111 +      struct fixed_col *info;
296.1112 +      NPPROW *i;
296.1113 +      NPPAIJ *aij;
296.1114 +      /* the column must be fixed */
296.1115 +      xassert(q->lb == q->ub);
296.1116 +      /* create transformation stack entry */
296.1117 +      info = npp_push_tse(npp,
296.1118 +         rcv_fixed_col, sizeof(struct fixed_col));
296.1119 +      info->q = q->j;
296.1120 +      info->s = q->lb;
296.1121 +      /* substitute x[q] = s[q] into objective row */
296.1122 +      npp->c0 += q->coef * q->lb;
296.1123 +      /* substitute x[q] = s[q] into constraint rows */
296.1124 +      for (aij = q->ptr; aij != NULL; aij = aij->c_next)
296.1125 +      {  i = aij->row;
296.1126 +         if (i->lb == i->ub)
296.1127 +            i->ub = (i->lb -= aij->val * q->lb);
296.1128 +         else
296.1129 +         {  if (i->lb != -DBL_MAX)
296.1130 +               i->lb -= aij->val * q->lb;
296.1131 +            if (i->ub != +DBL_MAX)
296.1132 +               i->ub -= aij->val * q->lb;
296.1133 +         }
296.1134 +      }
296.1135 +      /* remove the column from the problem */
296.1136 +      npp_del_col(npp, q);
296.1137 +      return;
296.1138 +}
296.1139 +
296.1140 +static int rcv_fixed_col(NPP *npp, void *_info)
296.1141 +{     /* recover fixed column */
296.1142 +      struct fixed_col *info = _info;
296.1143 +      if (npp->sol == GLP_SOL)
296.1144 +         npp->c_stat[info->q] = GLP_NS;
296.1145 +      npp->c_value[info->q] = info->s;
296.1146 +      return 0;
296.1147 +}
296.1148 +
296.1149 +/***********************************************************************
296.1150 +*  NAME
296.1151 +*
296.1152 +*  npp_make_equality - process row with almost identical bounds
296.1153 +*
296.1154 +*  SYNOPSIS
296.1155 +*
296.1156 +*  #include "glpnpp.h"
296.1157 +*  int npp_make_equality(NPP *npp, NPPROW *p);
296.1158 +*
296.1159 +*  DESCRIPTION
296.1160 +*
296.1161 +*  The routine npp_make_equality processes row p:
296.1162 +*
296.1163 +*     L[p] <= sum a[p,j] x[j] <= U[p],                               (1)
296.1164 +*              j
296.1165 +*
296.1166 +*  where -oo < L[p] < U[p] < +oo, i.e. which is double-sided inequality
296.1167 +*  constraint.
296.1168 +*
296.1169 +*  RETURNS
296.1170 +*
296.1171 +*  0 - row bounds have not been changed;
296.1172 +*
296.1173 +*  1 - row has been replaced by equality constraint.
296.1174 +*
296.1175 +*  PROBLEM TRANSFORMATION
296.1176 +*
296.1177 +*  If bounds of row (1) are very close to each other:
296.1178 +*
296.1179 +*     U[p] - L[p] <= eps,                                            (2)
296.1180 +*
296.1181 +*  where eps is an absolute tolerance for row value, the row can be
296.1182 +*  replaced by the following almost equivalent equiality constraint:
296.1183 +*
296.1184 +*     sum a[p,j] x[j] = b,                                           (3)
296.1185 +*      j
296.1186 +*
296.1187 +*  where b = (L[p] + U[p]) / 2. If the right-hand side in (3) happens
296.1188 +*  to be very close to its nearest integer:
296.1189 +*
296.1190 +*     |b - floor(b + 0.5)| <= eps,                                   (4)
296.1191 +*
296.1192 +*  it is reasonable to use this nearest integer as the right-hand side.
296.1193 +*
296.1194 +*  RECOVERING BASIC SOLUTION
296.1195 +*
296.1196 +*  Status of row p in solution to the original problem is determined
296.1197 +*  by its status and the sign of its multiplier pi[p] in solution to
296.1198 +*  the transformed problem as follows:
296.1199 +*
296.1200 +*     +-----------------------+---------+--------------------+
296.1201 +*     |    Status of row p    | Sign of |  Status of row p   |
296.1202 +*     | (transformed problem) |  pi[p]  | (original problem) |
296.1203 +*     +-----------------------+---------+--------------------+
296.1204 +*     |        GLP_BS         |  + / -  |       GLP_BS       |
296.1205 +*     |        GLP_NS         |    +    |       GLP_NL       |
296.1206 +*     |        GLP_NS         |    -    |       GLP_NU       |
296.1207 +*     +-----------------------+---------+--------------------+
296.1208 +*
296.1209 +*  Value of row multiplier pi[p] in solution to the original problem is
296.1210 +*  the same as in solution to the transformed problem.
296.1211 +*
296.1212 +*  RECOVERING INTERIOR POINT SOLUTION
296.1213 +*
296.1214 +*  Value of row multiplier pi[p] in solution to the original problem is
296.1215 +*  the same as in solution to the transformed problem.
296.1216 +*
296.1217 +*  RECOVERING MIP SOLUTION
296.1218 +*
296.1219 +*  None needed. */
296.1220 +
296.1221 +struct make_equality
296.1222 +{     /* row with almost identical bounds */
296.1223 +      int p;
296.1224 +      /* row reference number */
296.1225 +};
296.1226 +
296.1227 +static int rcv_make_equality(NPP *npp, void *info);
296.1228 +
296.1229 +int npp_make_equality(NPP *npp, NPPROW *p)
296.1230 +{     /* process row with almost identical bounds */
296.1231 +      struct make_equality *info;
296.1232 +      double b, eps, nint;
296.1233 +      /* the row must be double-sided inequality */
296.1234 +      xassert(p->lb != -DBL_MAX);
296.1235 +      xassert(p->ub != +DBL_MAX);
296.1236 +      xassert(p->lb < p->ub);
296.1237 +      /* check row bounds */
296.1238 +      eps = 1e-9 + 1e-12 * fabs(p->lb);
296.1239 +      if (p->ub - p->lb > eps) return 0;
296.1240 +      /* row bounds are very close to each other */
296.1241 +      /* create transformation stack entry */
296.1242 +      info = npp_push_tse(npp,
296.1243 +         rcv_make_equality, sizeof(struct make_equality));
296.1244 +      info->p = p->i;
296.1245 +      /* compute right-hand side */
296.1246 +      b = 0.5 * (p->ub + p->lb);
296.1247 +      nint = floor(b + 0.5);
296.1248 +      if (fabs(b - nint) <= eps) b = nint;
296.1249 +      /* replace row p by almost equivalent equality constraint */
296.1250 +      p->lb = p->ub = b;
296.1251 +      return 1;
296.1252 +}
296.1253 +
296.1254 +int rcv_make_equality(NPP *npp, void *_info)
296.1255 +{     /* recover row with almost identical bounds */
296.1256 +      struct make_equality *info = _info;
296.1257 +      if (npp->sol == GLP_SOL)
296.1258 +      {  if (npp->r_stat[info->p] == GLP_BS)
296.1259 +            npp->r_stat[info->p] = GLP_BS;
296.1260 +         else if (npp->r_stat[info->p] == GLP_NS)
296.1261 +         {  if (npp->r_pi[info->p] >= 0.0)
296.1262 +               npp->r_stat[info->p] = GLP_NL;
296.1263 +            else
296.1264 +               npp->r_stat[info->p] = GLP_NU;
296.1265 +         }
296.1266 +         else
296.1267 +         {  npp_error();
296.1268 +            return 1;
296.1269 +         }
296.1270 +      }
296.1271 +      return 0;
296.1272 +}
296.1273 +
296.1274 +/***********************************************************************
296.1275 +*  NAME
296.1276 +*
296.1277 +*  npp_make_fixed - process column with almost identical bounds
296.1278 +*
296.1279 +*  SYNOPSIS
296.1280 +*
296.1281 +*  #include "glpnpp.h"
296.1282 +*  int npp_make_fixed(NPP *npp, NPPCOL *q);
296.1283 +*
296.1284 +*  DESCRIPTION
296.1285 +*
296.1286 +*  The routine npp_make_fixed processes column q:
296.1287 +*
296.1288 +*     l[q] <= x[q] <= u[q],                                          (1)
296.1289 +*
296.1290 +*  where -oo < l[q] < u[q] < +oo, i.e. which has both lower and upper
296.1291 +*  bounds.
296.1292 +*
296.1293 +*  RETURNS
296.1294 +*
296.1295 +*  0 - column bounds have not been changed;
296.1296 +*
296.1297 +*  1 - column has been fixed.
296.1298 +*
296.1299 +*  PROBLEM TRANSFORMATION
296.1300 +*
296.1301 +*  If bounds of column (1) are very close to each other:
296.1302 +*
296.1303 +*     u[q] - l[q] <= eps,                                            (2)
296.1304 +*
296.1305 +*  where eps is an absolute tolerance for column value, the column can
296.1306 +*  be fixed:
296.1307 +*
296.1308 +*     x[q] = s[q],                                                   (3)
296.1309 +*
296.1310 +*  where s[q] = (l[q] + u[q]) / 2. And if the fixed column value s[q]
296.1311 +*  happens to be very close to its nearest integer:
296.1312 +*
296.1313 +*     |s[q] - floor(s[q] + 0.5)| <= eps,                             (4)
296.1314 +*
296.1315 +*  it is reasonable to use this nearest integer as the fixed value.
296.1316 +*
296.1317 +*  RECOVERING BASIC SOLUTION
296.1318 +*
296.1319 +*  In the dual system of the original (as well as transformed) problem
296.1320 +*  column q corresponds to the following row:
296.1321 +*
296.1322 +*     sum a[i,q] pi[i] + lambda[q] = c[q].                           (5)
296.1323 +*      i
296.1324 +*
296.1325 +*  Since multipliers pi[i] are known for all rows from solution to the
296.1326 +*  transformed problem, formula (5) allows computing value of multiplier
296.1327 +*  (reduced cost) for column q:
296.1328 +*
296.1329 +*     lambda[q] = c[q] - sum a[i,q] pi[i].                           (6)
296.1330 +*                         i
296.1331 +*
296.1332 +*  Status of column q in solution to the original problem is determined
296.1333 +*  by its status and the sign of its multiplier lambda[q] in solution to
296.1334 +*  the transformed problem as follows:
296.1335 +*
296.1336 +*     +-----------------------+-----------+--------------------+
296.1337 +*     |  Status of column q   |  Sign of  | Status of column q |
296.1338 +*     | (transformed problem) | lambda[q] | (original problem) |
296.1339 +*     +-----------------------+-----------+--------------------+
296.1340 +*     |        GLP_BS         |   + / -   |       GLP_BS       |
296.1341 +*     |        GLP_NS         |     +     |       GLP_NL       |
296.1342 +*     |        GLP_NS         |     -     |       GLP_NU       |
296.1343 +*     +-----------------------+-----------+--------------------+
296.1344 +*
296.1345 +*  Value of column q in solution to the original problem is the same as
296.1346 +*  in solution to the transformed problem.
296.1347 +*
296.1348 +*  RECOVERING INTERIOR POINT SOLUTION
296.1349 +*
296.1350 +*  Value of column q in solution to the original problem is the same as
296.1351 +*  in solution to the transformed problem.
296.1352 +*
296.1353 +*  RECOVERING MIP SOLUTION
296.1354 +*
296.1355 +*  None needed. */
296.1356 +
296.1357 +struct make_fixed
296.1358 +{     /* column with almost identical bounds */
296.1359 +      int q;
296.1360 +      /* column reference number */
296.1361 +      double c;
296.1362 +      /* objective coefficient at x[q] */
296.1363 +      NPPLFE *ptr;
296.1364 +      /* list of non-zero coefficients a[i,q] */
296.1365 +};
296.1366 +
296.1367 +static int rcv_make_fixed(NPP *npp, void *info);
296.1368 +
296.1369 +int npp_make_fixed(NPP *npp, NPPCOL *q)
296.1370 +{     /* process column with almost identical bounds */
296.1371 +      struct make_fixed *info;
296.1372 +      NPPAIJ *aij;
296.1373 +      NPPLFE *lfe;
296.1374 +      double s, eps, nint;
296.1375 +      /* the column must be double-bounded */
296.1376 +      xassert(q->lb != -DBL_MAX);
296.1377 +      xassert(q->ub != +DBL_MAX);
296.1378 +      xassert(q->lb < q->ub);
296.1379 +      /* check column bounds */
296.1380 +      eps = 1e-9 + 1e-12 * fabs(q->lb);
296.1381 +      if (q->ub - q->lb > eps) return 0;
296.1382 +      /* column bounds are very close to each other */
296.1383 +      /* create transformation stack entry */
296.1384 +      info = npp_push_tse(npp,
296.1385 +         rcv_make_fixed, sizeof(struct make_fixed));
296.1386 +      info->q = q->j;
296.1387 +      info->c = q->coef;
296.1388 +      info->ptr = NULL;
296.1389 +      /* save column coefficients a[i,q] (needed for basic solution
296.1390 +         only) */
296.1391 +      if (npp->sol == GLP_SOL)
296.1392 +      {  for (aij = q->ptr; aij != NULL; aij = aij->c_next)
296.1393 +         {  lfe = dmp_get_atom(npp->stack, sizeof(NPPLFE));
296.1394 +            lfe->ref = aij->row->i;
296.1395 +            lfe->val = aij->val;
296.1396 +            lfe->next = info->ptr;
296.1397 +            info->ptr = lfe;
296.1398 +         }
296.1399 +      }
296.1400 +      /* compute column fixed value */
296.1401 +      s = 0.5 * (q->ub + q->lb);
296.1402 +      nint = floor(s + 0.5);
296.1403 +      if (fabs(s - nint) <= eps) s = nint;
296.1404 +      /* make column q fixed */
296.1405 +      q->lb = q->ub = s;
296.1406 +      return 1;
296.1407 +}
296.1408 +
296.1409 +static int rcv_make_fixed(NPP *npp, void *_info)
296.1410 +{     /* recover column with almost identical bounds */
296.1411 +      struct make_fixed *info = _info;
296.1412 +      NPPLFE *lfe;
296.1413 +      double lambda;
296.1414 +      if (npp->sol == GLP_SOL)
296.1415 +      {  if (npp->c_stat[info->q] == GLP_BS)
296.1416 +            npp->c_stat[info->q] = GLP_BS;
296.1417 +         else if (npp->c_stat[info->q] == GLP_NS)
296.1418 +         {  /* compute multiplier for column q with formula (6) */
296.1419 +            lambda = info->c;
296.1420 +            for (lfe = info->ptr; lfe != NULL; lfe = lfe->next)
296.1421 +               lambda -= lfe->val * npp->r_pi[lfe->ref];
296.1422 +            /* assign status to non-basic column */
296.1423 +            if (lambda >= 0.0)
296.1424 +               npp->c_stat[info->q] = GLP_NL;
296.1425 +            else
296.1426 +               npp->c_stat[info->q] = GLP_NU;
296.1427 +         }
296.1428 +         else
296.1429 +         {  npp_error();
296.1430 +            return 1;
296.1431 +         }
296.1432 +      }
296.1433 +      return 0;
296.1434 +}
296.1435 +
296.1436 +/* eof */
   297.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
   297.2 +++ b/deps/glpk/src/glpnpp03.c	Sun Nov 06 20:59:10 2011 +0100
   297.3 @@ -0,0 +1,2861 @@
   297.4 +/* glpnpp03.c */
   297.5 +
   297.6 +/***********************************************************************
   297.7 +*  This code is part of GLPK (GNU Linear Programming Kit).
   297.8 +*
   297.9 +*  Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008,
  297.10 +*  2009, 2010, 2011 Andrew Makhorin, Department for Applied Informatics,
  297.11 +*  Moscow Aviation Institute, Moscow, Russia. All rights reserved.
  297.12 +*  E-mail: <mao@gnu.org>.
  297.13 +*
  297.14 +*  GLPK is free software: you can redistribute it and/or modify it
  297.15 +*  under the terms of the GNU General Public License as published by
  297.16 +*  the Free Software Foundation, either version 3 of the License, or
  297.17 +*  (at your option) any later version.
  297.18 +*
  297.19 +*  GLPK is distributed in the hope that it will be useful, but WITHOUT
  297.20 +*  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
  297.21 +*  or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
  297.22 +*  License for more details.
  297.23 +*
  297.24 +*  You should have received a copy of the GNU General Public License
  297.25 +*  along with GLPK. If not, see <http://www.gnu.org/licenses/>.
  297.26 +***********************************************************************/
  297.27 +
  297.28 +#include "glpnpp.h"
  297.29 +
  297.30 +/***********************************************************************
  297.31 +*  NAME
  297.32 +*
  297.33 +*  npp_empty_row - process empty row
  297.34 +*
  297.35 +*  SYNOPSIS
  297.36 +*
  297.37 +*  #include "glpnpp.h"
  297.38 +*  int npp_empty_row(NPP *npp, NPPROW *p);
  297.39 +*
  297.40 +*  DESCRIPTION
  297.41 +*
  297.42 +*  The routine npp_empty_row processes row p, which is empty, i.e.
  297.43 +*  coefficients at all columns in this row are zero:
  297.44 +*
  297.45 +*     L[p] <= sum 0 x[j] <= U[p],                                    (1)
  297.46 +*
  297.47 +*  where L[p] <= U[p].
  297.48 +*
  297.49 +*  RETURNS
  297.50 +*
  297.51 +*  0 - success;
  297.52 +*
  297.53 +*  1 - problem has no primal feasible solution.
  297.54 +*
  297.55 +*  PROBLEM TRANSFORMATION
  297.56 +*
  297.57 +*  If the following conditions hold:
  297.58 +*
  297.59 +*     L[p] <= +eps,  U[p] >= -eps,                                   (2)
  297.60 +*
  297.61 +*  where eps is an absolute tolerance for row value, the row p is
  297.62 +*  redundant. In this case it can be replaced by equivalent redundant
  297.63 +*  row, which is free (unbounded), and then removed from the problem.
  297.64 +*  Otherwise, the row p is infeasible and, thus, the problem has no
  297.65 +*  primal feasible solution.
  297.66 +*
  297.67 +*  RECOVERING BASIC SOLUTION
  297.68 +*
  297.69 +*  See the routine npp_free_row.
  297.70 +*
  297.71 +*  RECOVERING INTERIOR-POINT SOLUTION
  297.72 +*
  297.73 +*  See the routine npp_free_row.
  297.74 +*
  297.75 +*  RECOVERING MIP SOLUTION
  297.76 +*
  297.77 +*  None needed. */
  297.78 +
  297.79 +int npp_empty_row(NPP *npp, NPPROW *p)
  297.80 +{     /* process empty row */
  297.81 +      double eps = 1e-3;
  297.82 +      /* the row must be empty */
  297.83 +      xassert(p->ptr == NULL);
  297.84 +      /* check primal feasibility */
  297.85 +      if (p->lb > +eps || p->ub < -eps)
  297.86 +         return 1;
  297.87 +      /* replace the row by equivalent free (unbounded) row */
  297.88 +      p->lb = -DBL_MAX, p->ub = +DBL_MAX;
  297.89 +      /* and process it */
  297.90 +      npp_free_row(npp, p);
  297.91 +      return 0;
  297.92 +}
  297.93 +
  297.94 +/***********************************************************************
  297.95 +*  NAME
  297.96 +*
  297.97 +*  npp_empty_col - process empty column
  297.98 +*
  297.99 +*  SYNOPSIS
 297.100 +*
 297.101 +*  #include "glpnpp.h"
 297.102 +*  int npp_empty_col(NPP *npp, NPPCOL *q);
 297.103 +*
 297.104 +*  DESCRIPTION
 297.105 +*
 297.106 +*  The routine npp_empty_col processes column q:
 297.107 +*
 297.108 +*     l[q] <= x[q] <= u[q],                                          (1)
 297.109 +*
 297.110 +*  where l[q] <= u[q], which is empty, i.e. has zero coefficients in
 297.111 +*  all constraint rows.
 297.112 +*
 297.113 +*  RETURNS
 297.114 +*
 297.115 +*  0 - success;
 297.116 +*
 297.117 +*  1 - problem has no dual feasible solution.
 297.118 +*
 297.119 +*  PROBLEM TRANSFORMATION
 297.120 +*
 297.121 +*  The row of the dual system corresponding to the empty column is the
 297.122 +*  following:
 297.123 +*
 297.124 +*     sum 0 pi[i] + lambda[q] = c[q],                                (2)
 297.125 +*      i
 297.126 +*
 297.127 +*  from which it follows that:
 297.128 +*
 297.129 +*     lambda[q] = c[q].                                              (3)
 297.130 +*
 297.131 +*  If the following condition holds:
 297.132 +*
 297.133 +*     c[q] < - eps,                                                  (4)
 297.134 +*
 297.135 +*  where eps is an absolute tolerance for column multiplier, the lower
 297.136 +*  column bound l[q] must be active to provide dual feasibility (note
 297.137 +*  that being preprocessed the problem is always minimization). In this
 297.138 +*  case the column can be fixed on its lower bound and removed from the
 297.139 +*  problem (if the column is integral, its bounds are also assumed to
 297.140 +*  be integral). And if the column has no lower bound (l[q] = -oo), the
 297.141 +*  problem has no dual feasible solution.
 297.142 +*
 297.143 +*  If the following condition holds:
 297.144 +*
 297.145 +*     c[q] > + eps,                                                  (5)
 297.146 +*
 297.147 +*  the upper column bound u[q] must be active to provide dual
 297.148 +*  feasibility. In this case the column can be fixed on its upper bound
 297.149 +*  and removed from the problem. And if the column has no upper bound
 297.150 +*  (u[q] = +oo), the problem has no dual feasible solution.
 297.151 +*
 297.152 +*  Finally, if the following condition holds:
 297.153 +*
 297.154 +*     - eps <= c[q] <= +eps,                                         (6)
 297.155 +*
 297.156 +*  dual feasibility does not depend on a particular value of column q.
 297.157 +*  In this case the column can be fixed either on its lower bound (if
 297.158 +*  l[q] > -oo) or on its upper bound (if u[q] < +oo) or at zero (if the
 297.159 +*  column is unbounded) and then removed from the problem.
 297.160 +*
 297.161 +*  RECOVERING BASIC SOLUTION
 297.162 +*
 297.163 +*  See the routine npp_fixed_col. Having been recovered the column
 297.164 +*  is assigned status GLP_NS. However, if actually it is not fixed
 297.165 +*  (l[q] < u[q]), its status should be changed to GLP_NL, GLP_NU, or
 297.166 +*  GLP_NF depending on which bound it was fixed on transformation stage.
 297.167 +*
 297.168 +*  RECOVERING INTERIOR-POINT SOLUTION
 297.169 +*
 297.170 +*  See the routine npp_fixed_col.
 297.171 +*
 297.172 +*  RECOVERING MIP SOLUTION
 297.173 +*
 297.174 +*  See the routine npp_fixed_col. */
 297.175 +
 297.176 +struct empty_col
 297.177 +{     /* empty column */
 297.178 +      int q;
 297.179 +      /* column reference number */
 297.180 +      char stat;
 297.181 +      /* status in basic solution */
 297.182 +};
 297.183 +
 297.184 +static int rcv_empty_col(NPP *npp, void *info);
 297.185 +
 297.186 +int npp_empty_col(NPP *npp, NPPCOL *q)
 297.187 +{     /* process empty column */
 297.188 +      struct empty_col *info;
 297.189 +      double eps = 1e-3;
 297.190 +      /* the column must be empty */
 297.191 +      xassert(q->ptr == NULL);
 297.192 +      /* check dual feasibility */
 297.193 +      if (q->coef > +eps && q->lb == -DBL_MAX)
 297.194 +         return 1;
 297.195 +      if (q->coef < -eps && q->ub == +DBL_MAX)
 297.196 +         return 1;
 297.197 +      /* create transformation stack entry */
 297.198 +      info = npp_push_tse(npp,
 297.199 +         rcv_empty_col, sizeof(struct empty_col));
 297.200 +      info->q = q->j;
 297.201 +      /* fix the column */
 297.202 +      if (q->lb == -DBL_MAX && q->ub == +DBL_MAX)
 297.203 +      {  /* free column */
 297.204 +         info->stat = GLP_NF;
 297.205 +         q->lb = q->ub = 0.0;
 297.206 +      }
 297.207 +      else if (q->ub == +DBL_MAX)
 297.208 +lo:   {  /* column with lower bound */
 297.209 +         info->stat = GLP_NL;
 297.210 +         q->ub = q->lb;
 297.211 +      }
 297.212 +      else if (q->lb == -DBL_MAX)
 297.213 +up:   {  /* column with upper bound */
 297.214 +         info->stat = GLP_NU;
 297.215 +         q->lb = q->ub;
 297.216 +      }
 297.217 +      else if (q->lb != q->ub)
 297.218 +      {  /* double-bounded column */
 297.219 +         if (q->coef >= +DBL_EPSILON) goto lo;
 297.220 +         if (q->coef <= -DBL_EPSILON) goto up;
 297.221 +         if (fabs(q->lb) <= fabs(q->ub)) goto lo; else goto up;
 297.222 +      }
 297.223 +      else
 297.224 +      {  /* fixed column */
 297.225 +         info->stat = GLP_NS;
 297.226 +      }
 297.227 +      /* process fixed column */
 297.228 +      npp_fixed_col(npp, q);
 297.229 +      return 0;
 297.230 +}
 297.231 +
 297.232 +static int rcv_empty_col(NPP *npp, void *_info)
 297.233 +{     /* recover empty column */
 297.234 +      struct empty_col *info = _info;
 297.235 +      if (npp->sol == GLP_SOL)
 297.236 +         npp->c_stat[info->q] = info->stat;
 297.237 +      return 0;
 297.238 +}
 297.239 +
 297.240 +/***********************************************************************
 297.241 +*  NAME
 297.242 +*
 297.243 +*  npp_implied_value - process implied column value
 297.244 +*
 297.245 +*  SYNOPSIS
 297.246 +*
 297.247 +*  #include "glpnpp.h"
 297.248 +*  int npp_implied_value(NPP *npp, NPPCOL *q, double s);
 297.249 +*
 297.250 +*  DESCRIPTION
 297.251 +*
 297.252 +*  For column q:
 297.253 +*
 297.254 +*     l[q] <= x[q] <= u[q],                                          (1)
 297.255 +*
 297.256 +*  where l[q] < u[q], the routine npp_implied_value processes its
 297.257 +*  implied value s[q]. If this implied value satisfies to the current
 297.258 +*  column bounds and integrality condition, the routine fixes column q
 297.259 +*  at the given point. Note that the column is kept in the problem in
 297.260 +*  any case.
 297.261 +*
 297.262 +*  RETURNS
 297.263 +*
 297.264 +*  0 - column has been fixed;
 297.265 +*
 297.266 +*  1 - implied value violates to current column bounds;
 297.267 +*
 297.268 +*  2 - implied value violates integrality condition.
 297.269 +*
 297.270 +*  ALGORITHM
 297.271 +*
 297.272 +*  Implied column value s[q] satisfies to the current column bounds if
 297.273 +*  the following condition holds:
 297.274 +*
 297.275 +*     l[q] - eps <= s[q] <= u[q] + eps,                              (2)
 297.276 +*
 297.277 +*  where eps is an absolute tolerance for column value. If the column
 297.278 +*  is integral, the following condition also must hold:
 297.279 +*
 297.280 +*     |s[q] - floor(s[q]+0.5)| <= eps,                               (3)
 297.281 +*
 297.282 +*  where floor(s[q]+0.5) is the nearest integer to s[q].
 297.283 +*
 297.284 +*  If both condition (2) and (3) are satisfied, the column can be fixed
 297.285 +*  at the value s[q], or, if it is integral, at floor(s[q]+0.5).
 297.286 +*  Otherwise, if s[q] violates (2) or (3), the problem has no feasible
 297.287 +*  solution.
 297.288 +*
 297.289 +*  Note: If s[q] is close to l[q] or u[q], it seems to be reasonable to
 297.290 +*  fix the column at its lower or upper bound, resp. rather than at the
 297.291 +*  implied value. */
 297.292 +
 297.293 +int npp_implied_value(NPP *npp, NPPCOL *q, double s)
 297.294 +{     /* process implied column value */
 297.295 +      double eps, nint;
 297.296 +      xassert(npp == npp);
 297.297 +      /* column must not be fixed */
 297.298 +      xassert(q->lb < q->ub);
 297.299 +      /* check integrality */
 297.300 +      if (q->is_int)
 297.301 +      {  nint = floor(s + 0.5);
 297.302 +         if (fabs(s - nint) <= 1e-5)
 297.303 +            s = nint;
 297.304 +         else
 297.305 +            return 2;
 297.306 +      }
 297.307 +      /* check current column lower bound */
 297.308 +      if (q->lb != -DBL_MAX)
 297.309 +      {  eps = (q->is_int ? 1e-5 : 1e-5 + 1e-8 * fabs(q->lb));
 297.310 +         if (s < q->lb - eps) return 1;
 297.311 +         /* if s[q] is close to l[q], fix column at its lower bound
 297.312 +            rather than at the implied value */
 297.313 +         if (s < q->lb + 1e-3 * eps)
 297.314 +         {  q->ub = q->lb;
 297.315 +            return 0;
 297.316 +         }
 297.317 +      }
 297.318 +      /* check current column upper bound */
 297.319 +      if (q->ub != +DBL_MAX)
 297.320 +      {  eps = (q->is_int ? 1e-5 : 1e-5 + 1e-8 * fabs(q->ub));
 297.321 +         if (s > q->ub + eps) return 1;
 297.322 +         /* if s[q] is close to u[q], fix column at its upper bound
 297.323 +            rather than at the implied value */
 297.324 +         if (s > q->ub - 1e-3 * eps)
 297.325 +         {  q->lb = q->ub;
 297.326 +            return 0;
 297.327 +         }
 297.328 +      }
 297.329 +      /* fix column at the implied value */
 297.330 +      q->lb = q->ub = s;
 297.331 +      return 0;
 297.332 +}
 297.333 +
 297.334 +/***********************************************************************
 297.335 +*  NAME
 297.336 +*
 297.337 +*  npp_eq_singlet - process row singleton (equality constraint)
 297.338 +*
 297.339 +*  SYNOPSIS
 297.340 +*
 297.341 +*  #include "glpnpp.h"
 297.342 +*  int npp_eq_singlet(NPP *npp, NPPROW *p);
 297.343 +*
 297.344 +*  DESCRIPTION
 297.345 +*
 297.346 +*  The routine npp_eq_singlet processes row p, which is equiality
 297.347 +*  constraint having the only non-zero coefficient:
 297.348 +*
 297.349 +*     a[p,q] x[q] = b.                                               (1)
 297.350 +*
 297.351 +*  RETURNS
 297.352 +*
 297.353 +*  0 - success;
 297.354 +*
 297.355 +*  1 - problem has no primal feasible solution;
 297.356 +*
 297.357 +*  2 - problem has no integer feasible solution.
 297.358 +*
 297.359 +*  PROBLEM TRANSFORMATION
 297.360 +*
 297.361 +*  The equality constraint defines implied value of column q:
 297.362 +*
 297.363 +*     x[q] = s[q] = b / a[p,q].                                      (2)
 297.364 +*
 297.365 +*  If the implied value s[q] satisfies to the column bounds (see the
 297.366 +*  routine npp_implied_value), the column can be fixed at s[q] and
 297.367 +*  removed from the problem. In this case row p becomes redundant, so
 297.368 +*  it can be replaced by equivalent free row and also removed from the
 297.369 +*  problem.
 297.370 +*
 297.371 +*  Note that the routine removes from the problem only row p. Column q
 297.372 +*  becomes fixed, however, it is kept in the problem.
 297.373 +*
 297.374 +*  RECOVERING BASIC SOLUTION
 297.375 +*
 297.376 +*  In solution to the original problem row p is assigned status GLP_NS
 297.377 +*  (active equality constraint), and column q is assigned status GLP_BS
 297.378 +*  (basic column).
 297.379 +*
 297.380 +*  Multiplier for row p can be computed as follows. In the dual system
 297.381 +*  of the original problem column q corresponds to the following row:
 297.382 +*
 297.383 +*     sum a[i,q] pi[i] + lambda[q] = c[q]  ==>
 297.384 +*      i
 297.385 +*
 297.386 +*     sum a[i,q] pi[i] + a[p,q] pi[p] + lambda[q] = c[q].
 297.387 +*     i!=p
 297.388 +*
 297.389 +*  Therefore:
 297.390 +*
 297.391 +*               1
 297.392 +*     pi[p] = ------ (c[q] - lambda[q] - sum a[i,q] pi[i]),          (3)
 297.393 +*             a[p,q]                     i!=q
 297.394 +*
 297.395 +*  where lambda[q] = 0 (since column[q] is basic), and pi[i] for all
 297.396 +*  i != p are known in solution to the transformed problem.
 297.397 +*
 297.398 +*  Value of column q in solution to the original problem is assigned
 297.399 +*  its implied value s[q].
 297.400 +*
 297.401 +*  RECOVERING INTERIOR-POINT SOLUTION
 297.402 +*
 297.403 +*  Multiplier for row p is computed with formula (3). Value of column
 297.404 +*  q is assigned its implied value s[q].
 297.405 +*
 297.406 +*  RECOVERING MIP SOLUTION
 297.407 +*
 297.408 +*  Value of column q is assigned its implied value s[q]. */
 297.409 +
 297.410 +struct eq_singlet
 297.411 +{     /* row singleton (equality constraint) */
 297.412 +      int p;
 297.413 +      /* row reference number */
 297.414 +      int q;
 297.415 +      /* column reference number */
 297.416 +      double apq;
 297.417 +      /* constraint coefficient a[p,q] */
 297.418 +      double c;
 297.419 +      /* objective coefficient at x[q] */
 297.420 +      NPPLFE *ptr;
 297.421 +      /* list of non-zero coefficients a[i,q], i != p */
 297.422 +};
 297.423 +
 297.424 +static int rcv_eq_singlet(NPP *npp, void *info);
 297.425 +
 297.426 +int npp_eq_singlet(NPP *npp, NPPROW *p)
 297.427 +{     /* process row singleton (equality constraint) */
 297.428 +      struct eq_singlet *info;
 297.429 +      NPPCOL *q;
 297.430 +      NPPAIJ *aij;
 297.431 +      NPPLFE *lfe;
 297.432 +      int ret;
 297.433 +      double s;
 297.434 +      /* the row must be singleton equality constraint */
 297.435 +      xassert(p->lb == p->ub);
 297.436 +      xassert(p->ptr != NULL && p->ptr->r_next == NULL);
 297.437 +      /* compute and process implied column value */
 297.438 +      aij = p->ptr;
 297.439 +      q = aij->col;
 297.440 +      s = p->lb / aij->val;
 297.441 +      ret = npp_implied_value(npp, q, s);
 297.442 +      xassert(0 <= ret && ret <= 2);
 297.443 +      if (ret != 0) return ret;
 297.444 +      /* create transformation stack entry */
 297.445 +      info = npp_push_tse(npp,
 297.446 +         rcv_eq_singlet, sizeof(struct eq_singlet));
 297.447 +      info->p = p->i;
 297.448 +      info->q = q->j;
 297.449 +      info->apq = aij->val;
 297.450 +      info->c = q->coef;
 297.451 +      info->ptr = NULL;
 297.452 +      /* save column coefficients a[i,q], i != p (not needed for MIP
 297.453 +         solution) */
 297.454 +      if (npp->sol != GLP_MIP)
 297.455 +      {  for (aij = q->ptr; aij != NULL; aij = aij->c_next)
 297.456 +         {  if (aij->row == p) continue; /* skip a[p,q] */
 297.457 +            lfe = dmp_get_atom(npp->stack, sizeof(NPPLFE));
 297.458 +            lfe->ref = aij->row->i;
 297.459 +            lfe->val = aij->val;
 297.460 +            lfe->next = info->ptr;
 297.461 +            info->ptr = lfe;
 297.462 +         }
 297.463 +      }
 297.464 +      /* remove the row from the problem */
 297.465 +      npp_del_row(npp, p);
 297.466 +      return 0;
 297.467 +}
 297.468 +
 297.469 +static int rcv_eq_singlet(NPP *npp, void *_info)
 297.470 +{     /* recover row singleton (equality constraint) */
 297.471 +      struct eq_singlet *info = _info;
 297.472 +      NPPLFE *lfe;
 297.473 +      double temp;
 297.474 +      if (npp->sol == GLP_SOL)
 297.475 +      {  /* column q must be already recovered as GLP_NS */
 297.476 +         if (npp->c_stat[info->q] != GLP_NS)
 297.477 +         {  npp_error();
 297.478 +            return 1;
 297.479 +         }
 297.480 +         npp->r_stat[info->p] = GLP_NS;
 297.481 +         npp->c_stat[info->q] = GLP_BS;
 297.482 +      }
 297.483 +      if (npp->sol != GLP_MIP)
 297.484 +      {  /* compute multiplier for row p with formula (3) */
 297.485 +         temp = info->c;
 297.486 +         for (lfe = info->ptr; lfe != NULL; lfe = lfe->next)
 297.487 +            temp -= lfe->val * npp->r_pi[lfe->ref];
 297.488 +         npp->r_pi[info->p] = temp / info->apq;
 297.489 +      }
 297.490 +      return 0;
 297.491 +}
 297.492 +
 297.493 +/***********************************************************************
 297.494 +*  NAME
 297.495 +*
 297.496 +*  npp_implied_lower - process implied column lower bound
 297.497 +*
 297.498 +*  SYNOPSIS
 297.499 +*
 297.500 +*  #include "glpnpp.h"
 297.501 +*  int npp_implied_lower(NPP *npp, NPPCOL *q, double l);
 297.502 +*
 297.503 +*  DESCRIPTION
 297.504 +*
 297.505 +*  For column q:
 297.506 +*
 297.507 +*     l[q] <= x[q] <= u[q],                                          (1)
 297.508 +*
 297.509 +*  where l[q] < u[q], the routine npp_implied_lower processes its
 297.510 +*  implied lower bound l'[q]. As the result the current column lower
 297.511 +*  bound may increase. Note that the column is kept in the problem in
 297.512 +*  any case.
 297.513 +*
 297.514 +*  RETURNS
 297.515 +*
 297.516 +*  0 - current column lower bound has not changed;
 297.517 +*
 297.518 +*  1 - current column lower bound has changed, but not significantly;
 297.519 +*
 297.520 +*  2 - current column lower bound has significantly changed;
 297.521 +*
 297.522 +*  3 - column has been fixed on its upper bound;
 297.523 +*
 297.524 +*  4 - implied lower bound violates current column upper bound.
 297.525 +*
 297.526 +*  ALGORITHM
 297.527 +*
 297.528 +*  If column q is integral, before processing its implied lower bound
 297.529 +*  should be rounded up:
 297.530 +*
 297.531 +*              ( floor(l'[q]+0.5), if |l'[q] - floor(l'[q]+0.5)| <= eps
 297.532 +*     l'[q] := <                                                     (2)
 297.533 +*              ( ceil(l'[q]),      otherwise
 297.534 +*
 297.535 +*  where floor(l'[q]+0.5) is the nearest integer to l'[q], ceil(l'[q])
 297.536 +*  is smallest integer not less than l'[q], and eps is an absolute
 297.537 +*  tolerance for column value.
 297.538 +*
 297.539 +*  Processing implied column lower bound l'[q] includes the following
 297.540 +*  cases:
 297.541 +*
 297.542 +*  1) if l'[q] < l[q] + eps, implied lower bound is redundant;
 297.543 +*
 297.544 +*  2) if l[q] + eps <= l[q] <= u[q] + eps, current column lower bound
 297.545 +*     l[q] can be strengthened by replacing it with l'[q]. If in this
 297.546 +*     case new column lower bound becomes close to current column upper
 297.547 +*     bound u[q], the column can be fixed on its upper bound;
 297.548 +*
 297.549 +*  3) if l'[q] > u[q] + eps, implied lower bound violates current
 297.550 +*     column upper bound u[q], in which case the problem has no primal
 297.551 +*     feasible solution. */
 297.552 +
 297.553 +int npp_implied_lower(NPP *npp, NPPCOL *q, double l)
 297.554 +{     /* process implied column lower bound */
 297.555 +      int ret;
 297.556 +      double eps, nint;
 297.557 +      xassert(npp == npp);
 297.558 +      /* column must not be fixed */
 297.559 +      xassert(q->lb < q->ub);
 297.560 +      /* implied lower bound must be finite */
 297.561 +      xassert(l != -DBL_MAX);
 297.562 +      /* if column is integral, round up l'[q] */
 297.563 +      if (q->is_int)
 297.564 +      {  nint = floor(l + 0.5);
 297.565 +         if (fabs(l - nint) <= 1e-5)
 297.566 +            l = nint;
 297.567 +         else
 297.568 +            l = ceil(l);
 297.569 +      }
 297.570 +      /* check current column lower bound */
 297.571 +      if (q->lb != -DBL_MAX)
 297.572 +      {  eps = (q->is_int ? 1e-3 : 1e-3 + 1e-6 * fabs(q->lb));
 297.573 +         if (l < q->lb + eps)
 297.574 +         {  ret = 0; /* redundant */
 297.575 +            goto done;
 297.576 +         }
 297.577 +      }
 297.578 +      /* check current column upper bound */
 297.579 +      if (q->ub != +DBL_MAX)
 297.580 +      {  eps = (q->is_int ? 1e-5 : 1e-5 + 1e-8 * fabs(q->ub));
 297.581 +         if (l > q->ub + eps)
 297.582 +         {  ret = 4; /* infeasible */
 297.583 +            goto done;
 297.584 +         }
 297.585 +         /* if l'[q] is close to u[q], fix column at its upper bound */
 297.586 +         if (l > q->ub - 1e-3 * eps)
 297.587 +         {  q->lb = q->ub;
 297.588 +            ret = 3; /* fixed */
 297.589 +            goto done;
 297.590 +         }
 297.591 +      }
 297.592 +      /* check if column lower bound changes significantly */
 297.593 +      if (q->lb == -DBL_MAX)
 297.594 +         ret = 2; /* significantly */
 297.595 +      else if (q->is_int && l > q->lb + 0.5)
 297.596 +         ret = 2; /* significantly */
 297.597 +      else if (l > q->lb + 0.30 * (1.0 + fabs(q->lb)))
 297.598 +         ret = 2; /* significantly */
 297.599 +      else
 297.600 +         ret = 1; /* not significantly */
 297.601 +      /* set new column lower bound */
 297.602 +      q->lb = l;
 297.603 +done: return ret;
 297.604 +}
 297.605 +
 297.606 +/***********************************************************************
 297.607 +*  NAME
 297.608 +*
 297.609 +*  npp_implied_upper - process implied column upper bound
 297.610 +*
 297.611 +*  SYNOPSIS
 297.612 +*
 297.613 +*  #include "glpnpp.h"
 297.614 +*  int npp_implied_upper(NPP *npp, NPPCOL *q, double u);
 297.615 +*
 297.616 +*  DESCRIPTION
 297.617 +*
 297.618 +*  For column q:
 297.619 +*
 297.620 +*     l[q] <= x[q] <= u[q],                                          (1)
 297.621 +*
 297.622 +*  where l[q] < u[q], the routine npp_implied_upper processes its
 297.623 +*  implied upper bound u'[q]. As the result the current column upper
 297.624 +*  bound may decrease. Note that the column is kept in the problem in
 297.625 +*  any case.
 297.626 +*
 297.627 +*  RETURNS
 297.628 +*
 297.629 +*  0 - current column upper bound has not changed;
 297.630 +*
 297.631 +*  1 - current column upper bound has changed, but not significantly;
 297.632 +*
 297.633 +*  2 - current column upper bound has significantly changed;
 297.634 +*
 297.635 +*  3 - column has been fixed on its lower bound;
 297.636 +*
 297.637 +*  4 - implied upper bound violates current column lower bound.
 297.638 +*
 297.639 +*  ALGORITHM
 297.640 +*
 297.641 +*  If column q is integral, before processing its implied upper bound
 297.642 +*  should be rounded down:
 297.643 +*
 297.644 +*              ( floor(u'[q]+0.5), if |u'[q] - floor(l'[q]+0.5)| <= eps
 297.645 +*     u'[q] := <                                                     (2)
 297.646 +*              ( floor(l'[q]),     otherwise
 297.647 +*
 297.648 +*  where floor(u'[q]+0.5) is the nearest integer to u'[q],
 297.649 +*  floor(u'[q]) is largest integer not greater than u'[q], and eps is
 297.650 +*  an absolute tolerance for column value.
 297.651 +*
 297.652 +*  Processing implied column upper bound u'[q] includes the following
 297.653 +*  cases:
 297.654 +*
 297.655 +*  1) if u'[q] > u[q] - eps, implied upper bound is redundant;
 297.656 +*
 297.657 +*  2) if l[q] - eps <= u[q] <= u[q] - eps, current column upper bound
 297.658 +*     u[q] can be strengthened by replacing it with u'[q]. If in this
 297.659 +*     case new column upper bound becomes close to current column lower
 297.660 +*     bound, the column can be fixed on its lower bound;
 297.661 +*
 297.662 +*  3) if u'[q] < l[q] - eps, implied upper bound violates current
 297.663 +*     column lower bound l[q], in which case the problem has no primal
 297.664 +*     feasible solution. */
 297.665 +
 297.666 +int npp_implied_upper(NPP *npp, NPPCOL *q, double u)
 297.667 +{     int ret;
 297.668 +      double eps, nint;
 297.669 +      xassert(npp == npp);
 297.670 +      /* column must not be fixed */
 297.671 +      xassert(q->lb < q->ub);
 297.672 +      /* implied upper bound must be finite */
 297.673 +      xassert(u != +DBL_MAX);
 297.674 +      /* if column is integral, round down u'[q] */
 297.675 +      if (q->is_int)
 297.676 +      {  nint = floor(u + 0.5);
 297.677 +         if (fabs(u - nint) <= 1e-5)
 297.678 +            u = nint;
 297.679 +         else
 297.680 +            u = floor(u);
 297.681 +      }
 297.682 +      /* check current column upper bound */
 297.683 +      if (q->ub != +DBL_MAX)
 297.684 +      {  eps = (q->is_int ? 1e-3 : 1e-3 + 1e-6 * fabs(q->ub));
 297.685 +         if (u > q->ub - eps)
 297.686 +         {  ret = 0; /* redundant */
 297.687 +            goto done;
 297.688 +         }
 297.689 +      }
 297.690 +      /* check current column lower bound */
 297.691 +      if (q->lb != -DBL_MAX)
 297.692 +      {  eps = (q->is_int ? 1e-5 : 1e-5 + 1e-8 * fabs(q->lb));
 297.693 +         if (u < q->lb - eps)
 297.694 +         {  ret = 4; /* infeasible */
 297.695 +            goto done;
 297.696 +         }
 297.697 +         /* if u'[q] is close to l[q], fix column at its lower bound */
 297.698 +         if (u < q->lb + 1e-3 * eps)
 297.699 +         {  q->ub = q->lb;
 297.700 +            ret = 3; /* fixed */
 297.701 +            goto done;
 297.702 +         }
 297.703 +      }
 297.704 +      /* check if column upper bound changes significantly */
 297.705 +      if (q->ub == +DBL_MAX)
 297.706 +         ret = 2; /* significantly */
 297.707 +      else if (q->is_int && u < q->ub - 0.5)
 297.708 +         ret = 2; /* significantly */
 297.709 +      else if (u < q->ub - 0.30 * (1.0 + fabs(q->ub)))
 297.710 +         ret = 2; /* significantly */
 297.711 +      else
 297.712 +         ret = 1; /* not significantly */
 297.713 +      /* set new column upper bound */
 297.714 +      q->ub = u;
 297.715 +done: return ret;
 297.716 +}
 297.717 +
 297.718 +/***********************************************************************
 297.719 +*  NAME
 297.720 +*
 297.721 +*  npp_ineq_singlet - process row singleton (inequality constraint)
 297.722 +*
 297.723 +*  SYNOPSIS
 297.724 +*
 297.725 +*  #include "glpnpp.h"
 297.726 +*  int npp_ineq_singlet(NPP *npp, NPPROW *p);
 297.727 +*
 297.728 +*  DESCRIPTION
 297.729 +*
 297.730 +*  The routine npp_ineq_singlet processes row p, which is inequality
 297.731 +*  constraint having the only non-zero coefficient:
 297.732 +*
 297.733 +*     L[p] <= a[p,q] * x[q] <= U[p],                                 (1)
 297.734 +*
 297.735 +*  where L[p] < U[p], L[p] > -oo and/or U[p] < +oo.
 297.736 +*
 297.737 +*  RETURNS
 297.738 +*
 297.739 +*  0 - current column bounds have not changed;
 297.740 +*
 297.741 +*  1 - current column bounds have changed, but not significantly;
 297.742 +*
 297.743 +*  2 - current column bounds have significantly changed;
 297.744 +*
 297.745 +*  3 - column has been fixed on its lower or upper bound;
 297.746 +*
 297.747 +*  4 - problem has no primal feasible solution.
 297.748 +*
 297.749 +*  PROBLEM TRANSFORMATION
 297.750 +*
 297.751 +*  Inequality constraint (1) defines implied bounds of column q:
 297.752 +*
 297.753 +*             (  L[p] / a[p,q],  if a[p,q] > 0
 297.754 +*     l'[q] = <                                                      (2)
 297.755 +*             (  U[p] / a[p,q],  if a[p,q] < 0
 297.756 +*
 297.757 +*             (  U[p] / a[p,q],  if a[p,q] > 0
 297.758 +*     u'[q] = <                                                      (3)
 297.759 +*             (  L[p] / a[p,q],  if a[p,q] < 0
 297.760 +*
 297.761 +*  If these implied bounds do not violate current bounds of column q:
 297.762 +*
 297.763 +*     l[q] <= x[q] <= u[q],                                          (4)
 297.764 +*
 297.765 +*  they can be used to strengthen the current column bounds:
 297.766 +*
 297.767 +*     l[q] := max(l[q], l'[q]),                                      (5)
 297.768 +*
 297.769 +*     u[q] := min(u[q], u'[q]).                                      (6)
 297.770 +*
 297.771 +*  (See the routines npp_implied_lower and npp_implied_upper.)
 297.772 +*
 297.773 +*  Once bounds of row p (1) have been carried over column q, the row
 297.774 +*  becomes redundant, so it can be replaced by equivalent free row and
 297.775 +*  removed from the problem.
 297.776 +*
 297.777 +*  Note that the routine removes from the problem only row p. Column q,
 297.778 +*  even it has been fixed, is kept in the problem.
 297.779 +*
 297.780 +*  RECOVERING BASIC SOLUTION
 297.781 +*
 297.782 +*  Note that the row in the dual system corresponding to column q is
 297.783 +*  the following:
 297.784 +*
 297.785 +*     sum a[i,q] pi[i] + lambda[q] = c[q]  ==>
 297.786 +*      i
 297.787 +*                                                                    (7)
 297.788 +*     sum a[i,q] pi[i] + a[p,q] pi[p] + lambda[q] = c[q],
 297.789 +*     i!=p
 297.790 +*
 297.791 +*  where pi[i] for all i != p are known in solution to the transformed
 297.792 +*  problem. Row p does not exist in the transformed problem, so it has
 297.793 +*  zero multiplier there. This allows computing multiplier for column q
 297.794 +*  in solution to the transformed problem:
 297.795 +*
 297.796 +*     lambda~[q] = c[q] - sum a[i,q] pi[i].                          (8)
 297.797 +*                         i!=p
 297.798 +*
 297.799 +*  Let in solution to the transformed problem column q be non-basic
 297.800 +*  with lower bound active (GLP_NL, lambda~[q] >= 0), and this lower
 297.801 +*  bound be implied one l'[q]. From the original problem's standpoint
 297.802 +*  this then means that actually the original column lower bound l[q]
 297.803 +*  is inactive, and active is that row bound L[p] or U[p] that defines
 297.804 +*  the implied bound l'[q] (2). In this case in solution to the
 297.805 +*  original problem column q is assigned status GLP_BS while row p is
 297.806 +*  assigned status GLP_NL (if a[p,q] > 0) or GLP_NU (if a[p,q] < 0).
 297.807 +*  Since now column q is basic, its multiplier lambda[q] is zero. This
 297.808 +*  allows using (7) and (8) to find multiplier for row p in solution to
 297.809 +*  the original problem:
 297.810 +*
 297.811 +*               1
 297.812 +*     pi[p] = ------ (c[q] - sum a[i,q] pi[i]) = lambda~[q] / a[p,q] (9)
 297.813 +*             a[p,q]         i!=p
 297.814 +*
 297.815 +*  Now let in solution to the transformed problem column q be non-basic
 297.816 +*  with upper bound active (GLP_NU, lambda~[q] <= 0), and this upper
 297.817 +*  bound be implied one u'[q]. As in the previous case this then means
 297.818 +*  that from the original problem's standpoint actually the original
 297.819 +*  column upper bound u[q] is inactive, and active is that row bound
 297.820 +*  L[p] or U[p] that defines the implied bound u'[q] (3). In this case
 297.821 +*  in solution to the original problem column q is assigned status
 297.822 +*  GLP_BS, row p is assigned status GLP_NU (if a[p,q] > 0) or GLP_NL
 297.823 +*  (if a[p,q] < 0), and its multiplier is computed with formula (9).
 297.824 +*
 297.825 +*  Strengthening bounds of column q according to (5) and (6) may make
 297.826 +*  it fixed. Thus, if in solution to the transformed problem column q is
 297.827 +*  non-basic and fixed (GLP_NS), we can suppose that if lambda~[q] > 0,
 297.828 +*  column q has active lower bound (GLP_NL), and if lambda~[q] < 0,
 297.829 +*  column q has active upper bound (GLP_NU), reducing this case to two
 297.830 +*  previous ones. If, however, lambda~[q] is close to zero or
 297.831 +*  corresponding bound of row p does not exist (this may happen if
 297.832 +*  lambda~[q] has wrong sign due to round-off errors, in which case it
 297.833 +*  is expected to be close to zero, since solution is assumed to be dual
 297.834 +*  feasible), column q can be assigned status GLP_BS (basic), and row p
 297.835 +*  can be made active on its existing bound. In the latter case row
 297.836 +*  multiplier pi[p] computed with formula (9) will be also close to
 297.837 +*  zero, and dual feasibility will be kept.
 297.838 +*
 297.839 +*  In all other cases, namely, if in solution to the transformed
 297.840 +*  problem column q is basic (GLP_BS), or non-basic with original lower
 297.841 +*  bound l[q] active (GLP_NL), or non-basic with original upper bound
 297.842 +*  u[q] active (GLP_NU), constraint (1) is inactive. So in solution to
 297.843 +*  the original problem status of column q remains unchanged, row p is
 297.844 +*  assigned status GLP_BS, and its multiplier pi[p] is assigned zero
 297.845 +*  value.
 297.846 +*
 297.847 +*  RECOVERING INTERIOR-POINT SOLUTION
 297.848 +*
 297.849 +*  First, value of multiplier for column q in solution to the original
 297.850 +*  problem is computed with formula (8). If lambda~[q] > 0 and column q
 297.851 +*  has implied lower bound, or if lambda~[q] < 0 and column q has
 297.852 +*  implied upper bound, this means that from the original problem's
 297.853 +*  standpoint actually row p has corresponding active bound, in which
 297.854 +*  case its multiplier pi[p] is computed with formula (9). In other
 297.855 +*  cases, when the sign of lambda~[q] corresponds to original bound of
 297.856 +*  column q, or when lambda~[q] =~ 0, value of row multiplier pi[p] is
 297.857 +*  assigned zero value.
 297.858 +*
 297.859 +*  RECOVERING MIP SOLUTION
 297.860 +*
 297.861 +*  None needed. */
 297.862 +
 297.863 +struct ineq_singlet
 297.864 +{     /* row singleton (inequality constraint) */
 297.865 +      int p;
 297.866 +      /* row reference number */
 297.867 +      int q;
 297.868 +      /* column reference number */
 297.869 +      double apq;
 297.870 +      /* constraint coefficient a[p,q] */
 297.871 +      double c;
 297.872 +      /* objective coefficient at x[q] */
 297.873 +      double lb;
 297.874 +      /* row lower bound */
 297.875 +      double ub;
 297.876 +      /* row upper bound */
 297.877 +      char lb_changed;
 297.878 +      /* this flag is set if column lower bound was changed */
 297.879 +      char ub_changed;
 297.880 +      /* this flag is set if column upper bound was changed */
 297.881 +      NPPLFE *ptr;
 297.882 +      /* list of non-zero coefficients a[i,q], i != p */
 297.883 +};
 297.884 +
 297.885 +static int rcv_ineq_singlet(NPP *npp, void *info);
 297.886 +
 297.887 +int npp_ineq_singlet(NPP *npp, NPPROW *p)
 297.888 +{     /* process row singleton (inequality constraint) */
 297.889 +      struct ineq_singlet *info;
 297.890 +      NPPCOL *q;
 297.891 +      NPPAIJ *apq, *aij;
 297.892 +      NPPLFE *lfe;
 297.893 +      int lb_changed, ub_changed;
 297.894 +      double ll, uu;
 297.895 +      /* the row must be singleton inequality constraint */
 297.896 +      xassert(p->lb != -DBL_MAX || p->ub != +DBL_MAX);
 297.897 +      xassert(p->lb < p->ub);
 297.898 +      xassert(p->ptr != NULL && p->ptr->r_next == NULL);
 297.899 +      /* compute implied column bounds */
 297.900 +      apq = p->ptr;
 297.901 +      q = apq->col;
 297.902 +      xassert(q->lb < q->ub);
 297.903 +      if (apq->val > 0.0)
 297.904 +      {  ll = (p->lb == -DBL_MAX ? -DBL_MAX : p->lb / apq->val);
 297.905 +         uu = (p->ub == +DBL_MAX ? +DBL_MAX : p->ub / apq->val);
 297.906 +      }
 297.907 +      else
 297.908 +      {  ll = (p->ub == +DBL_MAX ? -DBL_MAX : p->ub / apq->val);
 297.909 +         uu = (p->lb == -DBL_MAX ? +DBL_MAX : p->lb / apq->val);
 297.910 +      }
 297.911 +      /* process implied column lower bound */
 297.912 +      if (ll == -DBL_MAX)
 297.913 +         lb_changed = 0;
 297.914 +      else
 297.915 +      {  lb_changed = npp_implied_lower(npp, q, ll);
 297.916 +         xassert(0 <= lb_changed && lb_changed <= 4);
 297.917 +         if (lb_changed == 4) return 4; /* infeasible */
 297.918 +      }
 297.919 +      /* process implied column upper bound */
 297.920 +      if (uu == +DBL_MAX)
 297.921 +         ub_changed = 0;
 297.922 +      else if (lb_changed == 3)
 297.923 +      {  /* column was fixed on its upper bound due to l'[q] = u[q] */
 297.924 +         /* note that L[p] < U[p], so l'[q] = u[q] < u'[q] */
 297.925 +         ub_changed = 0;
 297.926 +      }
 297.927 +      else
 297.928 +      {  ub_changed = npp_implied_upper(npp, q, uu);
 297.929 +         xassert(0 <= ub_changed && ub_changed <= 4);
 297.930 +         if (ub_changed == 4) return 4; /* infeasible */
 297.931 +      }
 297.932 +      /* if neither lower nor upper column bound was changed, the row
 297.933 +         is originally redundant and can be replaced by free row */
 297.934 +      if (!lb_changed && !ub_changed)
 297.935 +      {  p->lb = -DBL_MAX, p->ub = +DBL_MAX;
 297.936 +         npp_free_row(npp, p);
 297.937 +         return 0;
 297.938 +      }
 297.939 +      /* create transformation stack entry */
 297.940 +      info = npp_push_tse(npp,
 297.941 +         rcv_ineq_singlet, sizeof(struct ineq_singlet));
 297.942 +      info->p = p->i;
 297.943 +      info->q = q->j;
 297.944 +      info->apq = apq->val;
 297.945 +      info->c = q->coef;
 297.946 +      info->lb = p->lb;
 297.947 +      info->ub = p->ub;
 297.948 +      info->lb_changed = (char)lb_changed;
 297.949 +      info->ub_changed = (char)ub_changed;
 297.950 +      info->ptr = NULL;
 297.951 +      /* save column coefficients a[i,q], i != p (not needed for MIP
 297.952 +         solution) */
 297.953 +      if (npp->sol != GLP_MIP)
 297.954 +      {  for (aij = q->ptr; aij != NULL; aij = aij->c_next)
 297.955 +         {  if (aij == apq) continue; /* skip a[p,q] */
 297.956 +            lfe = dmp_get_atom(npp->stack, sizeof(NPPLFE));
 297.957 +            lfe->ref = aij->row->i;
 297.958 +            lfe->val = aij->val;
 297.959 +            lfe->next = info->ptr;
 297.960 +            info->ptr = lfe;
 297.961 +         }
 297.962 +      }
 297.963 +      /* remove the row from the problem */
 297.964 +      npp_del_row(npp, p);
 297.965 +      return lb_changed >= ub_changed ? lb_changed : ub_changed;
 297.966 +}
 297.967 +
 297.968 +static int rcv_ineq_singlet(NPP *npp, void *_info)
 297.969 +{     /* recover row singleton (inequality constraint) */
 297.970 +      struct ineq_singlet *info = _info;
 297.971 +      NPPLFE *lfe;
 297.972 +      double lambda;
 297.973 +      if (npp->sol == GLP_MIP) goto done;
 297.974 +      /* compute lambda~[q] in solution to the transformed problem
 297.975 +         with formula (8) */
 297.976 +      lambda = info->c;
 297.977 +      for (lfe = info->ptr; lfe != NULL; lfe = lfe->next)
 297.978 +         lambda -= lfe->val * npp->r_pi[lfe->ref];
 297.979 +      if (npp->sol == GLP_SOL)
 297.980 +      {  /* recover basic solution */
 297.981 +         if (npp->c_stat[info->q] == GLP_BS)
 297.982 +         {  /* column q is basic, so row p is inactive */
 297.983 +            npp->r_stat[info->p] = GLP_BS;
 297.984 +            npp->r_pi[info->p] = 0.0;
 297.985 +         }
 297.986 +         else if (npp->c_stat[info->q] == GLP_NL)
 297.987 +nl:      {  /* column q is non-basic with lower bound active */
 297.988 +            if (info->lb_changed)
 297.989 +            {  /* it is implied bound, so actually row p is active
 297.990 +                  while column q is basic */
 297.991 +               npp->r_stat[info->p] =
 297.992 +                  (char)(info->apq > 0.0 ? GLP_NL : GLP_NU);
 297.993 +               npp->c_stat[info->q] = GLP_BS;
 297.994 +               npp->r_pi[info->p] = lambda / info->apq;
 297.995 +            }
 297.996 +            else
 297.997 +            {  /* it is original bound, so row p is inactive */
 297.998 +               npp->r_stat[info->p] = GLP_BS;
 297.999 +               npp->r_pi[info->p] = 0.0;
297.1000 +            }
297.1001 +         }
297.1002 +         else if (npp->c_stat[info->q] == GLP_NU)
297.1003 +nu:      {  /* column q is non-basic with upper bound active */
297.1004 +            if (info->ub_changed)
297.1005 +            {  /* it is implied bound, so actually row p is active
297.1006 +                  while column q is basic */
297.1007 +               npp->r_stat[info->p] =
297.1008 +                  (char)(info->apq > 0.0 ? GLP_NU : GLP_NL);
297.1009 +               npp->c_stat[info->q] = GLP_BS;
297.1010 +               npp->r_pi[info->p] = lambda / info->apq;
297.1011 +            }
297.1012 +            else
297.1013 +            {  /* it is original bound, so row p is inactive */
297.1014 +               npp->r_stat[info->p] = GLP_BS;
297.1015 +               npp->r_pi[info->p] = 0.0;
297.1016 +            }
297.1017 +         }
297.1018 +         else if (npp->c_stat[info->q] == GLP_NS)
297.1019 +         {  /* column q is non-basic and fixed; note, however, that in
297.1020 +               in the original problem it is non-fixed */
297.1021 +            if (lambda > +1e-7)
297.1022 +            {  if (info->apq > 0.0 && info->lb != -DBL_MAX ||
297.1023 +                   info->apq < 0.0 && info->ub != +DBL_MAX ||
297.1024 +                  !info->lb_changed)
297.1025 +               {  /* either corresponding bound of row p exists or
297.1026 +                     column q remains non-basic with its original lower
297.1027 +                     bound active */
297.1028 +                  npp->c_stat[info->q] = GLP_NL;
297.1029 +                  goto nl;
297.1030 +               }
297.1031 +            }
297.1032 +            if (lambda < -1e-7)
297.1033 +            {  if (info->apq > 0.0 && info->ub != +DBL_MAX ||
297.1034 +                   info->apq < 0.0 && info->lb != -DBL_MAX ||
297.1035 +                  !info->ub_changed)
297.1036 +               {  /* either corresponding bound of row p exists or
297.1037 +                     column q remains non-basic with its original upper
297.1038 +                     bound active */
297.1039 +                  npp->c_stat[info->q] = GLP_NU;
297.1040 +                  goto nu;
297.1041 +               }
297.1042 +            }
297.1043 +            /* either lambda~[q] is close to zero, or corresponding
297.1044 +               bound of row p does not exist, because lambda~[q] has
297.1045 +               wrong sign due to round-off errors; in the latter case
297.1046 +               lambda~[q] is also assumed to be close to zero; so, we
297.1047 +               can make row p active on its existing bound and column q
297.1048 +               basic; pi[p] will have wrong sign, but it also will be
297.1049 +               close to zero (rarus casus of dual degeneracy) */
297.1050 +            if (info->lb != -DBL_MAX && info->ub == +DBL_MAX)
297.1051 +            {  /* row lower bound exists, but upper bound doesn't */
297.1052 +               npp->r_stat[info->p] = GLP_NL;
297.1053 +            }
297.1054 +            else if (info->lb == -DBL_MAX && info->ub != +DBL_MAX)
297.1055 +            {  /* row upper bound exists, but lower bound doesn't */
297.1056 +               npp->r_stat[info->p] = GLP_NU;
297.1057 +            }
297.1058 +            else if (info->lb != -DBL_MAX && info->ub != +DBL_MAX)
297.1059 +            {  /* both row lower and upper bounds exist */
297.1060 +               /* to choose proper active row bound we should not use
297.1061 +                  lambda~[q], because its value being close to zero is
297.1062 +                  unreliable; so we choose that bound which provides
297.1063 +                  primal feasibility for original constraint (1) */
297.1064 +               if (info->apq * npp->c_value[info->q] <=
297.1065 +                   0.5 * (info->lb + info->ub))
297.1066 +                  npp->r_stat[info->p] = GLP_NL;
297.1067 +               else
297.1068 +                  npp->r_stat[info->p] = GLP_NU;
297.1069 +            }
297.1070 +            else
297.1071 +            {  npp_error();
297.1072 +               return 1;
297.1073 +            }
297.1074 +            npp->c_stat[info->q] = GLP_BS;
297.1075 +            npp->r_pi[info->p] = lambda / info->apq;
297.1076 +         }
297.1077 +         else
297.1078 +         {  npp_error();
297.1079 +            return 1;
297.1080 +         }
297.1081 +      }
297.1082 +      if (npp->sol == GLP_IPT)
297.1083 +      {  /* recover interior-point solution */
297.1084 +         if (lambda > +DBL_EPSILON && info->lb_changed ||
297.1085 +             lambda < -DBL_EPSILON && info->ub_changed)
297.1086 +         {  /* actually row p has corresponding active bound */
297.1087 +            npp->r_pi[info->p] = lambda / info->apq;
297.1088 +         }
297.1089 +         else
297.1090 +         {  /* either bounds of column q are both inactive or its
297.1091 +               original bound is active */
297.1092 +            npp->r_pi[info->p] = 0.0;
297.1093 +         }
297.1094 +      }
297.1095 +done: return 0;
297.1096 +}
297.1097 +
297.1098 +/***********************************************************************
297.1099 +*  NAME
297.1100 +*
297.1101 +*  npp_implied_slack - process column singleton (implied slack variable)
297.1102 +*
297.1103 +*  SYNOPSIS
297.1104 +*
297.1105 +*  #include "glpnpp.h"
297.1106 +*  void npp_implied_slack(NPP *npp, NPPCOL *q);
297.1107 +*
297.1108 +*  DESCRIPTION
297.1109 +*
297.1110 +*  The routine npp_implied_slack processes column q:
297.1111 +*
297.1112 +*     l[q] <= x[q] <= u[q],                                          (1)
297.1113 +*
297.1114 +*  where l[q] < u[q], having the only non-zero coefficient in row p,
297.1115 +*  which is equality constraint:
297.1116 +*
297.1117 +*     sum a[p,j] x[j] + a[p,q] x[q] = b.                             (2)
297.1118 +*     j!=q
297.1119 +*
297.1120 +*  PROBLEM TRANSFORMATION
297.1121 +*
297.1122 +*  (If x[q] is integral, this transformation must not be used.)
297.1123 +*
297.1124 +*  The term a[p,q] x[q] in constraint (2) can be considered as a slack
297.1125 +*  variable that allows to carry bounds of column q over row p and then
297.1126 +*  remove column q from the problem.
297.1127 +*
297.1128 +*  Constraint (2) can be written as follows:
297.1129 +*
297.1130 +*     sum a[p,j] x[j] = b - a[p,q] x[q].                             (3)
297.1131 +*     j!=q
297.1132 +*
297.1133 +*  According to (1) constraint (3) is equivalent to the following
297.1134 +*  inequality constraint:
297.1135 +*
297.1136 +*     L[p] <= sum a[p,j] x[j] <= U[p],                               (4)
297.1137 +*             j!=q
297.1138 +*
297.1139 +*  where
297.1140 +*
297.1141 +*            ( b - a[p,q] u[q],  if a[p,q] > 0
297.1142 +*     L[p] = <                                                       (5)
297.1143 +*            ( b - a[p,q] l[q],  if a[p,q] < 0
297.1144 +*
297.1145 +*            ( b - a[p,q] l[q],  if a[p,q] > 0
297.1146 +*     U[p] = <                                                       (6)
297.1147 +*            ( b - a[p,q] u[q],  if a[p,q] < 0
297.1148 +*
297.1149 +*  From (2) it follows that:
297.1150 +*
297.1151 +*              1
297.1152 +*     x[q] = ------ (b - sum a[p,j] x[j]).                           (7)
297.1153 +*            a[p,q]      j!=q
297.1154 +*
297.1155 +*  In order to eliminate x[q] from the objective row we substitute it
297.1156 +*  from (6) to that row:
297.1157 +*
297.1158 +*     z = sum c[j] x[j] + c[q] x[q] + c[0] =
297.1159 +*         j!=q
297.1160 +*                                 1
297.1161 +*       = sum c[j] x[j] + c[q] [------ (b - sum a[p,j] x[j])] + c0 =
297.1162 +*         j!=q                  a[p,q]      j!=q
297.1163 +*
297.1164 +*       = sum c~[j] x[j] + c~[0],
297.1165 +*         j!=q
297.1166 +*                         a[p,j]                     b
297.1167 +*     c~[j] = c[j] - c[q] ------,  c~0 = c0 - c[q] ------            (8)
297.1168 +*                         a[p,q]                   a[p,q]
297.1169 +*
297.1170 +*  are values of objective coefficients and constant term, resp., in
297.1171 +*  the transformed problem.
297.1172 +*
297.1173 +*  Note that column q is column singleton, so in the dual system of the
297.1174 +*  original problem it corresponds to the following row singleton:
297.1175 +*
297.1176 +*     a[p,q] pi[p] + lambda[q] = c[q].                               (9)
297.1177 +*
297.1178 +*  In the transformed problem row (9) would be the following:
297.1179 +*
297.1180 +*     a[p,q] pi~[p] + lambda[q] = c~[q] = 0.                        (10)
297.1181 +*
297.1182 +*  Subtracting (10) from (9) we have:
297.1183 +*
297.1184 +*     a[p,q] (pi[p] - pi~[p]) = c[q]
297.1185 +*
297.1186 +*  that gives the following formula to compute multiplier for row p in
297.1187 +*  solution to the original problem using its value in solution to the
297.1188 +*  transformed problem:
297.1189 +*
297.1190 +*     pi[p] = pi~[p] + c[q] / a[p,q].                               (11)
297.1191 +*
297.1192 +*  RECOVERING BASIC SOLUTION
297.1193 +*
297.1194 +*  Status of column q in solution to the original problem is defined
297.1195 +*  by status of row p in solution to the transformed problem and the
297.1196 +*  sign of coefficient a[p,q] in the original inequality constraint (2)
297.1197 +*  as follows:
297.1198 +*
297.1199 +*     +-----------------------+---------+--------------------+
297.1200 +*     |    Status of row p    | Sign of | Status of column q |
297.1201 +*     | (transformed problem) | a[p,q]  | (original problem) |
297.1202 +*     +-----------------------+---------+--------------------+
297.1203 +*     |        GLP_BS         |  + / -  |       GLP_BS       |
297.1204 +*     |        GLP_NL         |    +    |       GLP_NU       |
297.1205 +*     |        GLP_NL         |    -    |       GLP_NL       |
297.1206 +*     |        GLP_NU         |    +    |       GLP_NL       |
297.1207 +*     |        GLP_NU         |    -    |       GLP_NU       |
297.1208 +*     |        GLP_NF         |  + / -  |       GLP_NF       |
297.1209 +*     +-----------------------+---------+--------------------+
297.1210 +*
297.1211 +*  Value of column q is computed with formula (7). Since originally row
297.1212 +*  p is equality constraint, its status is assigned GLP_NS, and value of
297.1213 +*  its multiplier pi[p] is computed with formula (11).
297.1214 +*
297.1215 +*  RECOVERING INTERIOR-POINT SOLUTION
297.1216 +*
297.1217 +*  Value of column q is computed with formula (7). Row multiplier value
297.1218 +*  pi[p] is computed with formula (11).
297.1219 +*
297.1220 +*  RECOVERING MIP SOLUTION
297.1221 +*
297.1222 +*  Value of column q is computed with formula (7). */
297.1223 +
297.1224 +struct implied_slack
297.1225 +{     /* column singleton (implied slack variable) */
297.1226 +      int p;
297.1227 +      /* row reference number */
297.1228 +      int q;
297.1229 +      /* column reference number */
297.1230 +      double apq;
297.1231 +      /* constraint coefficient a[p,q] */
297.1232 +      double b;
297.1233 +      /* right-hand side of original equality constraint */
297.1234 +      double c;
297.1235 +      /* original objective coefficient at x[q] */
297.1236 +      NPPLFE *ptr;
297.1237 +      /* list of non-zero coefficients a[p,j], j != q */
297.1238 +};
297.1239 +
297.1240 +static int rcv_implied_slack(NPP *npp, void *info);
297.1241 +
297.1242 +void npp_implied_slack(NPP *npp, NPPCOL *q)
297.1243 +{     /* process column singleton (implied slack variable) */
297.1244 +      struct implied_slack *info;
297.1245 +      NPPROW *p;
297.1246 +      NPPAIJ *aij;
297.1247 +      NPPLFE *lfe;
297.1248 +      /* the column must be non-integral non-fixed singleton */
297.1249 +      xassert(!q->is_int);
297.1250 +      xassert(q->lb < q->ub);
297.1251 +      xassert(q->ptr != NULL && q->ptr->c_next == NULL);
297.1252 +      /* corresponding row must be equality constraint */
297.1253 +      aij = q->ptr;
297.1254 +      p = aij->row;
297.1255 +      xassert(p->lb == p->ub);
297.1256 +      /* create transformation stack entry */
297.1257 +      info = npp_push_tse(npp,
297.1258 +         rcv_implied_slack, sizeof(struct implied_slack));
297.1259 +      info->p = p->i;
297.1260 +      info->q = q->j;
297.1261 +      info->apq = aij->val;
297.1262 +      info->b = p->lb;
297.1263 +      info->c = q->coef;
297.1264 +      info->ptr = NULL;
297.1265 +      /* save row coefficients a[p,j], j != q, and substitute x[q]
297.1266 +         into the objective row */
297.1267 +      for (aij = p->ptr; aij != NULL; aij = aij->r_next)
297.1268 +      {  if (aij->col == q) continue; /* skip a[p,q] */
297.1269 +         lfe = dmp_get_atom(npp->stack, sizeof(NPPLFE));
297.1270 +         lfe->ref = aij->col->j;
297.1271 +         lfe->val = aij->val;
297.1272 +         lfe->next = info->ptr;
297.1273 +         info->ptr = lfe;
297.1274 +         aij->col->coef -= info->c * (aij->val / info->apq);
297.1275 +      }
297.1276 +      npp->c0 += info->c * (info->b / info->apq);
297.1277 +      /* compute new row bounds */
297.1278 +      if (info->apq > 0.0)
297.1279 +      {  p->lb = (q->ub == +DBL_MAX ?
297.1280 +            -DBL_MAX : info->b - info->apq * q->ub);
297.1281 +         p->ub = (q->lb == -DBL_MAX ?
297.1282 +            +DBL_MAX : info->b - info->apq * q->lb);
297.1283 +      }
297.1284 +      else
297.1285 +      {  p->lb = (q->lb == -DBL_MAX ?
297.1286 +            -DBL_MAX : info->b - info->apq * q->lb);
297.1287 +         p->ub = (q->ub == +DBL_MAX ?
297.1288 +            +DBL_MAX : info->b - info->apq * q->ub);
297.1289 +      }
297.1290 +      /* remove the column from the problem */
297.1291 +      npp_del_col(npp, q);
297.1292 +      return;
297.1293 +}
297.1294 +
297.1295 +static int rcv_implied_slack(NPP *npp, void *_info)
297.1296 +{     /* recover column singleton (implied slack variable) */
297.1297 +      struct implied_slack *info = _info;
297.1298 +      NPPLFE *lfe;
297.1299 +      double temp;
297.1300 +      if (npp->sol == GLP_SOL)
297.1301 +      {  /* assign statuses to row p and column q */
297.1302 +         if (npp->r_stat[info->p] == GLP_BS ||
297.1303 +             npp->r_stat[info->p] == GLP_NF)
297.1304 +            npp->c_stat[info->q] = npp->r_stat[info->p];
297.1305 +         else if (npp->r_stat[info->p] == GLP_NL)
297.1306 +            npp->c_stat[info->q] =
297.1307 +               (char)(info->apq > 0.0 ? GLP_NU : GLP_NL);
297.1308 +         else if (npp->r_stat[info->p] == GLP_NU)
297.1309 +            npp->c_stat[info->q] =
297.1310 +               (char)(info->apq > 0.0 ? GLP_NL : GLP_NU);
297.1311 +         else
297.1312 +         {  npp_error();
297.1313 +            return 1;
297.1314 +         }
297.1315 +         npp->r_stat[info->p] = GLP_NS;
297.1316 +      }
297.1317 +      if (npp->sol != GLP_MIP)
297.1318 +      {  /* compute multiplier for row p */
297.1319 +         npp->r_pi[info->p] += info->c / info->apq;
297.1320 +      }
297.1321 +      /* compute value of column q */
297.1322 +      temp = info->b;
297.1323 +      for (lfe = info->ptr; lfe != NULL; lfe = lfe->next)
297.1324 +         temp -= lfe->val * npp->c_value[lfe->ref];
297.1325 +      npp->c_value[info->q] = temp / info->apq;
297.1326 +      return 0;
297.1327 +}
297.1328 +
297.1329 +/***********************************************************************
297.1330 +*  NAME
297.1331 +*
297.1332 +*  npp_implied_free - process column singleton (implied free variable)
297.1333 +*
297.1334 +*  SYNOPSIS
297.1335 +*
297.1336 +*  #include "glpnpp.h"
297.1337 +*  int npp_implied_free(NPP *npp, NPPCOL *q);
297.1338 +*
297.1339 +*  DESCRIPTION
297.1340 +*
297.1341 +*  The routine npp_implied_free processes column q:
297.1342 +*
297.1343 +*     l[q] <= x[q] <= u[q],                                          (1)
297.1344 +*
297.1345 +*  having non-zero coefficient in the only row p, which is inequality
297.1346 +*  constraint:
297.1347 +*
297.1348 +*     L[p] <= sum a[p,j] x[j] + a[p,q] x[q] <= U[p],                 (2)
297.1349 +*             j!=q
297.1350 +*
297.1351 +*  where l[q] < u[q], L[p] < U[p], L[p] > -oo and/or U[p] < +oo.
297.1352 +*
297.1353 +*  RETURNS
297.1354 +*
297.1355 +*  0 - success;
297.1356 +*
297.1357 +*  1 - column lower and/or upper bound(s) can be active;
297.1358 +*
297.1359 +*  2 - problem has no dual feasible solution.
297.1360 +*
297.1361 +*  PROBLEM TRANSFORMATION
297.1362 +*
297.1363 +*  Constraint (2) can be written as follows:
297.1364 +*
297.1365 +*     L[p] - sum a[p,j] x[j] <= a[p,q] x[q] <= U[p] - sum a[p,j] x[j],
297.1366 +*            j!=q                                     j!=q
297.1367 +*
297.1368 +*  from which it follows that:
297.1369 +*
297.1370 +*     alfa <= a[p,q] x[q] <= beta,                                   (3)
297.1371 +*
297.1372 +*  where
297.1373 +*
297.1374 +*     alfa = inf(L[p] - sum a[p,j] x[j]) =
297.1375 +*                       j!=q
297.1376 +*
297.1377 +*          = L[p] - sup sum a[p,j] x[j] =                            (4)
297.1378 +*                       j!=q
297.1379 +*
297.1380 +*          = L[p] -  sum  a[p,j] u[j] -  sum  a[p,j] l[j],
297.1381 +*                  j in Jp             j in Jn
297.1382 +*
297.1383 +*     beta = sup(L[p] - sum a[p,j] x[j]) =
297.1384 +*                       j!=q
297.1385 +*
297.1386 +*          = L[p] - inf sum a[p,j] x[j] =                            (5)
297.1387 +*                       j!=q
297.1388 +*
297.1389 +*          = L[p] -  sum  a[p,j] l[j] -  sum  a[p,j] u[j],
297.1390 +*                  j in Jp             j in Jn
297.1391 +*
297.1392 +*     Jp = {j != q: a[p,j] > 0},  Jn = {j != q: a[p,j] < 0}.         (6)
297.1393 +*
297.1394 +*  Inequality (3) defines implied bounds of variable x[q]:
297.1395 +*
297.1396 +*     l'[q] <= x[q] <= u'[q],                                        (7)
297.1397 +*
297.1398 +*  where
297.1399 +*
297.1400 +*             ( alfa / a[p,q], if a[p,q] > 0
297.1401 +*     l'[q] = <                                                     (8a)
297.1402 +*             ( beta / a[p,q], if a[p,q] < 0
297.1403 +*
297.1404 +*             ( beta / a[p,q], if a[p,q] > 0
297.1405 +*     u'[q] = <                                                     (8b)
297.1406 +*             ( alfa / a[p,q], if a[p,q] < 0
297.1407 +*
297.1408 +*  Thus, if l'[q] > l[q] - eps and u'[q] < u[q] + eps, where eps is
297.1409 +*  an absolute tolerance for column value, column bounds (1) cannot be
297.1410 +*  active, in which case column q can be replaced by equivalent free
297.1411 +*  (unbounded) column.
297.1412 +*
297.1413 +*  Note that column q is column singleton, so in the dual system of the
297.1414 +*  original problem it corresponds to the following row singleton:
297.1415 +*
297.1416 +*     a[p,q] pi[p] + lambda[q] = c[q],                               (9)
297.1417 +*
297.1418 +*  from which it follows that:
297.1419 +*
297.1420 +*     pi[p] = (c[q] - lambda[q]) / a[p,q].                          (10)
297.1421 +*
297.1422 +*  Let x[q] be implied free (unbounded) variable. Then column q can be
297.1423 +*  only basic, so its multiplier lambda[q] is equal to zero, and from
297.1424 +*  (10) we have:
297.1425 +*
297.1426 +*     pi[p] = c[q] / a[p,q].                                        (11)
297.1427 +*
297.1428 +*  There are possible three cases:
297.1429 +*
297.1430 +*  1) pi[p] < -eps, where eps is an absolute tolerance for row
297.1431 +*     multiplier. In this case, to provide dual feasibility of the
297.1432 +*     original problem, row p must be active on its lower bound, and
297.1433 +*     if its lower bound does not exist (L[p] = -oo), the problem has
297.1434 +*     no dual feasible solution;
297.1435 +*
297.1436 +*  2) pi[p] > +eps. In this case row p must be active on its upper
297.1437 +*     bound, and if its upper bound does not exist (U[p] = +oo), the
297.1438 +*     problem has no dual feasible solution;
297.1439 +*
297.1440 +*  3) -eps <= pi[p] <= +eps. In this case any (either lower or upper)
297.1441 +*     bound of row p can be active, because this does not affect dual
297.1442 +*     feasibility.
297.1443 +*
297.1444 +*  Thus, in all three cases original inequality constraint (2) can be
297.1445 +*  replaced by equality constraint, where the right-hand side is either
297.1446 +*  lower or upper bound of row p, and bounds of column q can be removed
297.1447 +*  that makes it free (unbounded). (May note that this transformation
297.1448 +*  can be followed by transformation "Column singleton (implied slack
297.1449 +*  variable)" performed by the routine npp_implied_slack.)
297.1450 +*
297.1451 +*  RECOVERING BASIC SOLUTION
297.1452 +*
297.1453 +*  Status of row p in solution to the original problem is determined
297.1454 +*  by its status in solution to the transformed problem and its bound,
297.1455 +*  which was choosen to be active:
297.1456 +*
297.1457 +*     +-----------------------+--------+--------------------+
297.1458 +*     |    Status of row p    | Active | Status of row p    |
297.1459 +*     | (transformed problem) | bound  | (original problem) |
297.1460 +*     +-----------------------+--------+--------------------+
297.1461 +*     |        GLP_BS         |  L[p]  |       GLP_BS       |
297.1462 +*     |        GLP_BS         |  U[p]  |       GLP_BS       |
297.1463 +*     |        GLP_NS         |  L[p]  |       GLP_NL       |
297.1464 +*     |        GLP_NS         |  U[p]  |       GLP_NU       |
297.1465 +*     +-----------------------+--------+--------------------+
297.1466 +*
297.1467 +*  Value of row multiplier pi[p] (as well as value of column q) in
297.1468 +*  solution to the original problem is the same as in solution to the
297.1469 +*  transformed problem.
297.1470 +*
297.1471 +*  RECOVERING INTERIOR-POINT SOLUTION
297.1472 +*
297.1473 +*  Value of row multiplier pi[p] in solution to the original problem is
297.1474 +*  the same as in solution to the transformed problem.
297.1475 +*
297.1476 +*  RECOVERING MIP SOLUTION
297.1477 +*
297.1478 +*  None needed. */
297.1479 +
297.1480 +struct implied_free
297.1481 +{     /* column singleton (implied free variable) */
297.1482 +      int p;
297.1483 +      /* row reference number */
297.1484 +      char stat;
297.1485 +      /* row status:
297.1486 +         GLP_NL - active constraint on lower bound
297.1487 +         GLP_NU - active constraint on upper bound */
297.1488 +};
297.1489 +
297.1490 +static int rcv_implied_free(NPP *npp, void *info);
297.1491 +
297.1492 +int npp_implied_free(NPP *npp, NPPCOL *q)
297.1493 +{     /* process column singleton (implied free variable) */
297.1494 +      struct implied_free *info;
297.1495 +      NPPROW *p;
297.1496 +      NPPAIJ *apq, *aij;
297.1497 +      double alfa, beta, l, u, pi, eps;
297.1498 +      /* the column must be non-fixed singleton */
297.1499 +      xassert(q->lb < q->ub);
297.1500 +      xassert(q->ptr != NULL && q->ptr->c_next == NULL);
297.1501 +      /* corresponding row must be inequality constraint */
297.1502 +      apq = q->ptr;
297.1503 +      p = apq->row;
297.1504 +      xassert(p->lb != -DBL_MAX || p->ub != +DBL_MAX);
297.1505 +      xassert(p->lb < p->ub);
297.1506 +      /* compute alfa */
297.1507 +      alfa = p->lb;
297.1508 +      if (alfa != -DBL_MAX)
297.1509 +      {  for (aij = p->ptr; aij != NULL; aij = aij->r_next)
297.1510 +         {  if (aij == apq) continue; /* skip a[p,q] */
297.1511 +            if (aij->val > 0.0)
297.1512 +            {  if (aij->col->ub == +DBL_MAX)
297.1513 +               {  alfa = -DBL_MAX;
297.1514 +                  break;
297.1515 +               }
297.1516 +               alfa -= aij->val * aij->col->ub;
297.1517 +            }
297.1518 +            else /* < 0.0 */
297.1519 +            {  if (aij->col->lb == -DBL_MAX)
297.1520 +               {  alfa = -DBL_MAX;
297.1521 +                  break;
297.1522 +               }
297.1523 +               alfa -= aij->val * aij->col->lb;
297.1524 +            }
297.1525 +         }
297.1526 +      }
297.1527 +      /* compute beta */
297.1528 +      beta = p->ub;
297.1529 +      if (beta != +DBL_MAX)
297.1530 +      {  for (aij = p->ptr; aij != NULL; aij = aij->r_next)
297.1531 +         {  if (aij == apq) continue; /* skip a[p,q] */
297.1532 +            if (aij->val > 0.0)
297.1533 +            {  if (aij->col->lb == -DBL_MAX)
297.1534 +               {  beta = +DBL_MAX;
297.1535 +                  break;
297.1536 +               }
297.1537 +               beta -= aij->val * aij->col->lb;
297.1538 +            }
297.1539 +            else /* < 0.0 */
297.1540 +            {  if (aij->col->ub == +DBL_MAX)
297.1541 +               {  beta = +DBL_MAX;
297.1542 +                  break;
297.1543 +               }
297.1544 +               beta -= aij->val * aij->col->ub;
297.1545 +            }
297.1546 +         }
297.1547 +      }
297.1548 +      /* compute implied column lower bound l'[q] */
297.1549 +      if (apq->val > 0.0)
297.1550 +         l = (alfa == -DBL_MAX ? -DBL_MAX : alfa / apq->val);
297.1551 +      else /* < 0.0 */
297.1552 +         l = (beta == +DBL_MAX ? -DBL_MAX : beta / apq->val);
297.1553 +      /* compute implied column upper bound u'[q] */
297.1554 +      if (apq->val > 0.0)
297.1555 +         u = (beta == +DBL_MAX ? +DBL_MAX : beta / apq->val);
297.1556 +      else
297.1557 +         u = (alfa == -DBL_MAX ? +DBL_MAX : alfa / apq->val);
297.1558 +      /* check if column lower bound l[q] can be active */
297.1559 +      if (q->lb != -DBL_MAX)
297.1560 +      {  eps = 1e-9 + 1e-12 * fabs(q->lb);
297.1561 +         if (l < q->lb - eps) return 1; /* yes, it can */
297.1562 +      }
297.1563 +      /* check if column upper bound u[q] can be active */
297.1564 +      if (q->ub != +DBL_MAX)
297.1565 +      {  eps = 1e-9 + 1e-12 * fabs(q->ub);
297.1566 +         if (u > q->ub + eps) return 1; /* yes, it can */
297.1567 +      }
297.1568 +      /* okay; make column q free (unbounded) */
297.1569 +      q->lb = -DBL_MAX, q->ub = +DBL_MAX;
297.1570 +      /* create transformation stack entry */
297.1571 +      info = npp_push_tse(npp,
297.1572 +         rcv_implied_free, sizeof(struct implied_free));
297.1573 +      info->p = p->i;
297.1574 +      info->stat = -1;
297.1575 +      /* compute row multiplier pi[p] */
297.1576 +      pi = q->coef / apq->val;
297.1577 +      /* check dual feasibility for row p */
297.1578 +      if (pi > +DBL_EPSILON)
297.1579 +      {  /* lower bound L[p] must be active */
297.1580 +         if (p->lb != -DBL_MAX)
297.1581 +nl:      {  info->stat = GLP_NL;
297.1582 +            p->ub = p->lb;
297.1583 +         }
297.1584 +         else
297.1585 +         {  if (pi > +1e-5) return 2; /* dual infeasibility */
297.1586 +            /* take a chance on U[p] */
297.1587 +            xassert(p->ub != +DBL_MAX);
297.1588 +            goto nu;
297.1589 +         }
297.1590 +      }
297.1591 +      else if (pi < -DBL_EPSILON)
297.1592 +      {  /* upper bound U[p] must be active */
297.1593 +         if (p->ub != +DBL_MAX)
297.1594 +nu:      {  info->stat = GLP_NU;
297.1595 +            p->lb = p->ub;
297.1596 +         }
297.1597 +         else
297.1598 +         {  if (pi < -1e-5) return 2; /* dual infeasibility */
297.1599 +            /* take a chance on L[p] */
297.1600 +            xassert(p->lb != -DBL_MAX);
297.1601 +            goto nl;
297.1602 +         }
297.1603 +      }
297.1604 +      else
297.1605 +      {  /* any bound (either L[p] or U[p]) can be made active  */
297.1606 +         if (p->ub == +DBL_MAX)
297.1607 +         {  xassert(p->lb != -DBL_MAX);
297.1608 +            goto nl;
297.1609 +         }
297.1610 +         if (p->lb == -DBL_MAX)
297.1611 +         {  xassert(p->ub != +DBL_MAX);
297.1612 +            goto nu;
297.1613 +         }
297.1614 +         if (fabs(p->lb) <= fabs(p->ub)) goto nl; else goto nu;
297.1615 +      }
297.1616 +      return 0;
297.1617 +}
297.1618 +
297.1619 +static int rcv_implied_free(NPP *npp, void *_info)
297.1620 +{     /* recover column singleton (implied free variable) */
297.1621 +      struct implied_free *info = _info;
297.1622 +      if (npp->sol == GLP_SOL)
297.1623 +      {  if (npp->r_stat[info->p] == GLP_BS)
297.1624 +            npp->r_stat[info->p] = GLP_BS;
297.1625 +         else if (npp->r_stat[info->p] == GLP_NS)
297.1626 +         {  xassert(info->stat == GLP_NL || info->stat == GLP_NU);
297.1627 +            npp->r_stat[info->p] = info->stat;
297.1628 +         }
297.1629 +         else
297.1630 +         {  npp_error();
297.1631 +            return 1;
297.1632 +         }
297.1633 +      }
297.1634 +      return 0;
297.1635 +}
297.1636 +
297.1637 +/***********************************************************************
297.1638 +*  NAME
297.1639 +*
297.1640 +*  npp_eq_doublet - process row doubleton (equality constraint)
297.1641 +*
297.1642 +*  SYNOPSIS
297.1643 +*
297.1644 +*  #include "glpnpp.h"
297.1645 +*  NPPCOL *npp_eq_doublet(NPP *npp, NPPROW *p);
297.1646 +*
297.1647 +*  DESCRIPTION
297.1648 +*
297.1649 +*  The routine npp_eq_doublet processes row p, which is equality
297.1650 +*  constraint having exactly two non-zero coefficients:
297.1651 +*
297.1652 +*     a[p,q] x[q] + a[p,r] x[r] = b.                                 (1)
297.1653 +*
297.1654 +*  As the result of processing one of columns q or r is eliminated from
297.1655 +*  all other rows and, thus, becomes column singleton of type "implied
297.1656 +*  slack variable". Row p is not changed and along with column q and r
297.1657 +*  remains in the problem.
297.1658 +*
297.1659 +*  RETURNS
297.1660 +*
297.1661 +*  The routine npp_eq_doublet returns pointer to the descriptor of that
297.1662 +*  column q or r which has been eliminated. If, due to some reason, the
297.1663 +*  elimination was not performed, the routine returns NULL.
297.1664 +*
297.1665 +*  PROBLEM TRANSFORMATION
297.1666 +*
297.1667 +*  First, we decide which column q or r will be eliminated. Let it be
297.1668 +*  column q. Consider i-th constraint row, where column q has non-zero
297.1669 +*  coefficient a[i,q] != 0:
297.1670 +*
297.1671 +*     L[i] <= sum a[i,j] x[j] <= U[i].                               (2)
297.1672 +*              j
297.1673 +*
297.1674 +*  In order to eliminate column q from row (2) we subtract from it row
297.1675 +*  (1) multiplied by gamma[i] = a[i,q] / a[p,q], i.e. we replace in the
297.1676 +*  transformed problem row (2) by its linear combination with row (1).
297.1677 +*  This transformation changes only coefficients in columns q and r,
297.1678 +*  and bounds of row i as follows:
297.1679 +*
297.1680 +*     a~[i,q] = a[i,q] - gamma[i] a[p,q] = 0,                        (3)
297.1681 +*
297.1682 +*     a~[i,r] = a[i,r] - gamma[i] a[p,r],                            (4)
297.1683 +*
297.1684 +*       L~[i] = L[i] - gamma[i] b,                                   (5)
297.1685 +*
297.1686 +*       U~[i] = U[i] - gamma[i] b.                                   (6)
297.1687 +*
297.1688 +*  RECOVERING BASIC SOLUTION
297.1689 +*
297.1690 +*  The transformation of the primal system of the original problem:
297.1691 +*
297.1692 +*     L <= A x <= U                                                  (7)
297.1693 +*
297.1694 +*  is equivalent to multiplying from the left a transformation matrix F
297.1695 +*  by components of this primal system, which in the transformed problem
297.1696 +*  becomes the following:
297.1697 +*
297.1698 +*     F L <= F A x <= F U  ==>  L~ <= A~x <= U~.                     (8)
297.1699 +*
297.1700 +*  The matrix F has the following structure:
297.1701 +*
297.1702 +*         ( 1           -gamma[1]            )
297.1703 +*         (                                  )
297.1704 +*         (    1        -gamma[2]            )
297.1705 +*         (                                  )
297.1706 +*         (      ...       ...               )
297.1707 +*         (                                  )
297.1708 +*     F = (          1  -gamma[p-1]          )                       (9)
297.1709 +*         (                                  )
297.1710 +*         (                 1                )
297.1711 +*         (                                  )
297.1712 +*         (             -gamma[p+1]  1       )
297.1713 +*         (                                  )
297.1714 +*         (                ...          ...  )
297.1715 +*
297.1716 +*  where its column containing elements -gamma[i] corresponds to row p
297.1717 +*  of the primal system.
297.1718 +*
297.1719 +*  From (8) it follows that the dual system of the original problem:
297.1720 +*
297.1721 +*     A'pi + lambda = c,                                            (10)
297.1722 +*
297.1723 +*  in the transformed problem becomes the following:
297.1724 +*
297.1725 +*     A'F'inv(F')pi + lambda = c  ==>  (A~)'pi~ + lambda = c,       (11)
297.1726 +*
297.1727 +*  where:
297.1728 +*
297.1729 +*     pi~ = inv(F')pi                                               (12)
297.1730 +*
297.1731 +*  is the vector of row multipliers in the transformed problem. Thus:
297.1732 +*
297.1733 +*     pi = F'pi~.                                                   (13)
297.1734 +*
297.1735 +*  Therefore, as it follows from (13), value of multiplier for row p in
297.1736 +*  solution to the original problem can be computed as follows:
297.1737 +*
297.1738 +*     pi[p] = pi~[p] - sum gamma[i] pi~[i],                         (14)
297.1739 +*                       i
297.1740 +*
297.1741 +*  where pi~[i] = pi[i] is multiplier for row i (i != p).
297.1742 +*
297.1743 +*  Note that the statuses of all rows and columns are not changed.
297.1744 +*
297.1745 +*  RECOVERING INTERIOR-POINT SOLUTION
297.1746 +*
297.1747 +*  Multiplier for row p in solution to the original problem is computed
297.1748 +*  with formula (14).
297.1749 +*
297.1750 +*  RECOVERING MIP SOLUTION
297.1751 +*
297.1752 +*  None needed. */
297.1753 +
297.1754 +struct eq_doublet
297.1755 +{     /* row doubleton (equality constraint) */
297.1756 +      int p;
297.1757 +      /* row reference number */
297.1758 +      double apq;
297.1759 +      /* constraint coefficient a[p,q] */
297.1760 +      NPPLFE *ptr;
297.1761 +      /* list of non-zero coefficients a[i,q], i != p */
297.1762 +};
297.1763 +
297.1764 +static int rcv_eq_doublet(NPP *npp, void *info);
297.1765 +
297.1766 +NPPCOL *npp_eq_doublet(NPP *npp, NPPROW *p)
297.1767 +{     /* process row doubleton (equality constraint) */
297.1768 +      struct eq_doublet *info;
297.1769 +      NPPROW *i;
297.1770 +      NPPCOL *q, *r;
297.1771 +      NPPAIJ *apq, *apr, *aiq, *air, *next;
297.1772 +      NPPLFE *lfe;
297.1773 +      double gamma;
297.1774 +      /* the row must be doubleton equality constraint */
297.1775 +      xassert(p->lb == p->ub);
297.1776 +      xassert(p->ptr != NULL && p->ptr->r_next != NULL &&
297.1777 +              p->ptr->r_next->r_next == NULL);
297.1778 +      /* choose column to be eliminated */
297.1779 +      {  NPPAIJ *a1, *a2;
297.1780 +         a1 = p->ptr, a2 = a1->r_next;
297.1781 +         if (fabs(a2->val) < 0.001 * fabs(a1->val))
297.1782 +         {  /* only first column can be eliminated, because second one
297.1783 +               has too small constraint coefficient */
297.1784 +            apq = a1, apr = a2;
297.1785 +         }
297.1786 +         else if (fabs(a1->val) < 0.001 * fabs(a2->val))
297.1787 +         {  /* only second column can be eliminated, because first one
297.1788 +               has too small constraint coefficient */
297.1789 +            apq = a2, apr = a1;
297.1790 +         }
297.1791 +         else
297.1792 +         {  /* both columns are appropriate; choose that one which is
297.1793 +               shorter to minimize fill-in */
297.1794 +            if (npp_col_nnz(npp, a1->col) <= npp_col_nnz(npp, a2->col))
297.1795 +            {  /* first column is shorter */
297.1796 +               apq = a1, apr = a2;
297.1797 +            }
297.1798 +            else
297.1799 +            {  /* second column is shorter */
297.1800 +               apq = a2, apr = a1;
297.1801 +            }
297.1802 +         }
297.1803 +      }
297.1804 +      /* now columns q and r have been chosen */
297.1805 +      q = apq->col, r = apr->col;
297.1806 +      /* create transformation stack entry */
297.1807 +      info = npp_push_tse(npp,
297.1808 +         rcv_eq_doublet, sizeof(struct eq_doublet));
297.1809 +      info->p = p->i;
297.1810 +      info->apq = apq->val;
297.1811 +      info->ptr = NULL;
297.1812 +      /* transform each row i (i != p), where a[i,q] != 0, to eliminate
297.1813 +         column q */
297.1814 +      for (aiq = q->ptr; aiq != NULL; aiq = next)
297.1815 +      {  next = aiq->c_next;
297.1816 +         if (aiq == apq) continue; /* skip row p */
297.1817 +         i = aiq->row; /* row i to be transformed */
297.1818 +         /* save constraint coefficient a[i,q] */
297.1819 +         if (npp->sol != GLP_MIP)
297.1820 +         {  lfe = dmp_get_atom(npp->stack, sizeof(NPPLFE));
297.1821 +            lfe->ref = i->i;
297.1822 +            lfe->val = aiq->val;
297.1823 +            lfe->next = info->ptr;
297.1824 +            info->ptr = lfe;
297.1825 +         }
297.1826 +         /* find coefficient a[i,r] in row i */
297.1827 +         for (air = i->ptr; air != NULL; air = air->r_next)
297.1828 +            if (air->col == r) break;
297.1829 +         /* if a[i,r] does not exist, create a[i,r] = 0 */
297.1830 +         if (air == NULL)
297.1831 +            air = npp_add_aij(npp, i, r, 0.0);
297.1832 +         /* compute gamma[i] = a[i,q] / a[p,q] */
297.1833 +         gamma = aiq->val / apq->val;
297.1834 +         /* (row i) := (row i) - gamma[i] * (row p); see (3)-(6) */
297.1835 +         /* new a[i,q] is exact zero due to elimnation; remove it from
297.1836 +            row i */
297.1837 +         npp_del_aij(npp, aiq);
297.1838 +         /* compute new a[i,r] */
297.1839 +         air->val -= gamma * apr->val;
297.1840 +         /* if new a[i,r] is close to zero due to numeric cancelation,
297.1841 +            remove it from row i */
297.1842 +         if (fabs(air->val) <= 1e-10)
297.1843 +            npp_del_aij(npp, air);
297.1844 +         /* compute new lower and upper bounds of row i */
297.1845 +         if (i->lb == i->ub)
297.1846 +            i->lb = i->ub = (i->lb - gamma * p->lb);
297.1847 +         else
297.1848 +         {  if (i->lb != -DBL_MAX)
297.1849 +               i->lb -= gamma * p->lb;
297.1850 +            if (i->ub != +DBL_MAX)
297.1851 +               i->ub -= gamma * p->lb;
297.1852 +         }
297.1853 +      }
297.1854 +      return q;
297.1855 +}
297.1856 +
297.1857 +static int rcv_eq_doublet(NPP *npp, void *_info)
297.1858 +{     /* recover row doubleton (equality constraint) */
297.1859 +      struct eq_doublet *info = _info;
297.1860 +      NPPLFE *lfe;
297.1861 +      double gamma, temp;
297.1862 +      /* we assume that processing row p is followed by processing
297.1863 +         column q as singleton of type "implied slack variable", in
297.1864 +         which case row p must always be active equality constraint */
297.1865 +      if (npp->sol == GLP_SOL)
297.1866 +      {  if (npp->r_stat[info->p] != GLP_NS)
297.1867 +         {  npp_error();
297.1868 +            return 1;
297.1869 +         }
297.1870 +      }
297.1871 +      if (npp->sol != GLP_MIP)
297.1872 +      {  /* compute value of multiplier for row p; see (14) */
297.1873 +         temp = npp->r_pi[info->p];
297.1874 +         for (lfe = info->ptr; lfe != NULL; lfe = lfe->next)
297.1875 +         {  gamma = lfe->val / info->apq; /* a[i,q] / a[p,q] */
297.1876 +            temp -= gamma * npp->r_pi[lfe->ref];
297.1877 +         }
297.1878 +         npp->r_pi[info->p] = temp;
297.1879 +      }
297.1880 +      return 0;
297.1881 +}
297.1882 +
297.1883 +/***********************************************************************
297.1884 +*  NAME
297.1885 +*
297.1886 +*  npp_forcing_row - process forcing row
297.1887 +*
297.1888 +*  SYNOPSIS
297.1889 +*
297.1890 +*  #include "glpnpp.h"
297.1891 +*  int npp_forcing_row(NPP *npp, NPPROW *p, int at);
297.1892 +*
297.1893 +*  DESCRIPTION
297.1894 +*
297.1895 +*  The routine npp_forcing row processes row p of general format:
297.1896 +*
297.1897 +*     L[p] <= sum a[p,j] x[j] <= U[p],                               (1)
297.1898 +*              j
297.1899 +*
297.1900 +*     l[j] <= x[j] <= u[j],                                          (2)
297.1901 +*
297.1902 +*  where L[p] <= U[p] and l[j] < u[j] for all a[p,j] != 0. It is also
297.1903 +*  assumed that:
297.1904 +*
297.1905 +*  1) if at = 0 then |L[p] - U'[p]| <= eps, where U'[p] is implied
297.1906 +*     row upper bound (see below), eps is an absolute tolerance for row
297.1907 +*     value;
297.1908 +*
297.1909 +*  2) if at = 1 then |U[p] - L'[p]| <= eps, where L'[p] is implied
297.1910 +*     row lower bound (see below).
297.1911 +*
297.1912 +*  RETURNS
297.1913 +*
297.1914 +*  0 - success;
297.1915 +*
297.1916 +*  1 - cannot fix columns due to too small constraint coefficients.
297.1917 +*
297.1918 +*  PROBLEM TRANSFORMATION
297.1919 +*
297.1920 +*  Implied lower and upper bounds of row (1) are determined by bounds
297.1921 +*  of corresponding columns (variables) as follows:
297.1922 +*
297.1923 +*     L'[p] = inf sum a[p,j] x[j] =
297.1924 +*                  j
297.1925 +*                                                                    (3)
297.1926 +*           =  sum  a[p,j] l[j] +  sum  a[p,j] u[j],
297.1927 +*            j in Jp             j in Jn
297.1928 +*
297.1929 +*     U'[p] = sup sum a[p,j] x[j] =
297.1930 +*                                                                    (4)
297.1931 +*           =  sum  a[p,j] u[j] +  sum  a[p,j] l[j],
297.1932 +*            j in Jp             j in Jn
297.1933 +*
297.1934 +*     Jp = {j: a[p,j] > 0},  Jn = {j: a[p,j] < 0}.                   (5)
297.1935 +*
297.1936 +*  If L[p] =~ U'[p] (at = 0), solution can be primal feasible only when
297.1937 +*  all variables take their boundary values as defined by (4):
297.1938 +*
297.1939 +*            ( u[j], if j in Jp
297.1940 +*     x[j] = <                                                       (6)
297.1941 +*            ( l[j], if j in Jn
297.1942 +*
297.1943 +*  Similarly, if U[p] =~ L'[p] (at = 1), solution can be primal feasible
297.1944 +*  only when all variables take their boundary values as defined by (3):
297.1945 +*
297.1946 +*            ( l[j], if j in Jp
297.1947 +*     x[j] = <                                                       (7)
297.1948 +*            ( u[j], if j in Jn
297.1949 +*
297.1950 +*  Condition (6) or (7) allows fixing all columns (variables x[j])
297.1951 +*  in row (1) on their bounds and then removing them from the problem
297.1952 +*  (see the routine npp_fixed_col). Due to this row p becomes redundant,
297.1953 +*  so it can be replaced by equivalent free (unbounded) row and also
297.1954 +*  removed from the problem (see the routine npp_free_row).
297.1955 +*
297.1956 +*  1. To apply this transformation row (1) should not have coefficients
297.1957 +*     whose magnitude is too small, i.e. all a[p,j] should satisfy to
297.1958 +*     the following condition:
297.1959 +*
297.1960 +*        |a[p,j]| >= eps * max(1, |a[p,k]|),                         (8)
297.1961 +*                           k
297.1962 +*     where eps is a relative tolerance for constraint coefficients.
297.1963 +*     Otherwise, fixing columns may be numerically unreliable and may
297.1964 +*     lead to wrong solution.
297.1965 +*
297.1966 +*  2. The routine fixes columns and remove bounds of row p, however,
297.1967 +*     it does not remove the row and columns from the problem.
297.1968 +*
297.1969 +*  RECOVERING BASIC SOLUTION
297.1970 +*
297.1971 +*  In the transformed problem row p being inactive constraint is
297.1972 +*  assigned status GLP_BS (as the result of transformation of free
297.1973 +*  row), and all columns in this row are assigned status GLP_NS (as the
297.1974 +*  result of transformation of fixed columns).
297.1975 +*
297.1976 +*  Note that in the dual system of the transformed (as well as original)
297.1977 +*  problem every column j in row p corresponds to the following row:
297.1978 +*
297.1979 +*     sum  a[i,j] pi[i] + a[p,j] pi[p] + lambda[j] = c[j],           (9)
297.1980 +*     i!=p
297.1981 +*
297.1982 +*  from which it follows that:
297.1983 +*
297.1984 +*     lambda[j] = c[j] - sum a[i,j] pi[i] - a[p,j] pi[p].           (10)
297.1985 +*                        i!=p
297.1986 +*
297.1987 +*  In the transformed problem values of all multipliers pi[i] are known
297.1988 +*  (including pi[i], whose value is zero, since row p is inactive).
297.1989 +*  Thus, using formula (10) it is possible to compute values of
297.1990 +*  multipliers lambda[j] for all columns in row p.
297.1991 +*
297.1992 +*  Note also that in the original problem all columns in row p are
297.1993 +*  bounded, not fixed. So status GLP_NS assigned to every such column
297.1994 +*  must be changed to GLP_NL or GLP_NU depending on which bound the
297.1995 +*  corresponding column has been fixed. This status change may lead to
297.1996 +*  dual feasibility violation for solution of the original problem,
297.1997 +*  because now column multipliers must satisfy to the following
297.1998 +*  condition:
297.1999 +*
297.2000 +*               ( >= 0, if status of column j is GLP_NL,
297.2001 +*     lambda[j] <                                                   (11)
297.2002 +*               ( <= 0, if status of column j is GLP_NU.
297.2003 +*
297.2004 +*  If this condition holds, solution to the original problem is the
297.2005 +*  same as to the transformed problem. Otherwise, we have to perform
297.2006 +*  one degenerate pivoting step of the primal simplex method to obtain
297.2007 +*  dual feasible (hence, optimal) solution to the original problem as
297.2008 +*  follows. If, on problem transformation, row p was made active on its
297.2009 +*  lower bound (case at = 0), we change its status to GLP_NL (or GLP_NS)
297.2010 +*  and start increasing its multiplier pi[p]. Otherwise, if row p was
297.2011 +*  made active on its upper bound (case at = 1), we change its status
297.2012 +*  to GLP_NU (or GLP_NS) and start decreasing pi[p]. From (10) it
297.2013 +*  follows that:
297.2014 +*
297.2015 +*     delta lambda[j] = - a[p,j] * delta pi[p] = - a[p,j] pi[p].    (12)
297.2016 +*
297.2017 +*  Simple analysis of formulae (3)-(5) shows that changing pi[p] in the
297.2018 +*  specified direction causes increasing lambda[j] for every column j
297.2019 +*  assigned status GLP_NL (delta lambda[j] > 0) and decreasing lambda[j]
297.2020 +*  for every column j assigned status GLP_NU (delta lambda[j] < 0). It
297.2021 +*  is understood that once the last lambda[q], which violates condition
297.2022 +*  (11), has reached zero, multipliers lambda[j] for all columns get
297.2023 +*  valid signs. Such column q can be determined as follows. Let d[j] be
297.2024 +*  initial value of lambda[j] (i.e. reduced cost of column j) in the
297.2025 +*  transformed problem computed with formula (10) when pi[p] = 0. Then
297.2026 +*  lambda[j] = d[j] + delta lambda[j], and from (12) it follows that
297.2027 +*  lambda[j] becomes zero if:
297.2028 +*
297.2029 +*     delta lambda[j] = - a[p,j] pi[p] = - d[j]  ==>
297.2030 +*                                                                   (13)
297.2031 +*     pi[p] = d[j] / a[p,j].
297.2032 +*
297.2033 +*  Therefore, the last column q, for which lambda[q] becomes zero, can
297.2034 +*  be determined from the following condition:
297.2035 +*
297.2036 +*     |d[q] / a[p,q]| = max  |pi[p]| = max  |d[j] / a[p,j]|,        (14)
297.2037 +*                      j in D         j in D
297.2038 +*
297.2039 +*  where D is a set of columns j whose, reduced costs d[j] have invalid
297.2040 +*  signs, i.e. violate condition (11). (Thus, if D is empty, solution
297.2041 +*  to the original problem is the same as solution to the transformed
297.2042 +*  problem, and no correction is needed as was noticed above.) In
297.2043 +*  solution to the original problem column q is assigned status GLP_BS,
297.2044 +*  since it replaces column of auxiliary variable of row p (becoming
297.2045 +*  active) in the basis, and multiplier for row p is assigned its new
297.2046 +*  value, which is pi[p] = d[q] / a[p,q]. Note that due to primal
297.2047 +*  degeneracy values of all columns having non-zero coefficients in row
297.2048 +*  p remain unchanged.
297.2049 +*
297.2050 +*  RECOVERING INTERIOR-POINT SOLUTION
297.2051 +*
297.2052 +*  Value of multiplier pi[p] in solution to the original problem is
297.2053 +*  corrected in the same way as for basic solution. Values of all
297.2054 +*  columns having non-zero coefficients in row p remain unchanged.
297.2055 +*
297.2056 +*  RECOVERING MIP SOLUTION
297.2057 +*
297.2058 +*  None needed. */
297.2059 +
297.2060 +struct forcing_col
297.2061 +{     /* column fixed on its bound by forcing row */
297.2062 +      int j;
297.2063 +      /* column reference number */
297.2064 +      char stat;
297.2065 +      /* original column status:
297.2066 +         GLP_NL - fixed on lower bound
297.2067 +         GLP_NU - fixed on upper bound */
297.2068 +      double a;
297.2069 +      /* constraint coefficient a[p,j] */
297.2070 +      double c;
297.2071 +      /* objective coefficient c[j] */
297.2072 +      NPPLFE *ptr;
297.2073 +      /* list of non-zero coefficients a[i,j], i != p */
297.2074 +      struct forcing_col *next;
297.2075 +      /* pointer to another column fixed by forcing row */
297.2076 +};
297.2077 +
297.2078 +struct forcing_row
297.2079 +{     /* forcing row */
297.2080 +      int p;
297.2081 +      /* row reference number */
297.2082 +      char stat;
297.2083 +      /* status assigned to the row if it becomes active:
297.2084 +         GLP_NS - active equality constraint
297.2085 +         GLP_NL - inequality constraint with lower bound active
297.2086 +         GLP_NU - inequality constraint with upper bound active */
297.2087 +      struct forcing_col *ptr;
297.2088 +      /* list of all columns having non-zero constraint coefficient
297.2089 +         a[p,j] in the forcing row */
297.2090 +};
297.2091 +
297.2092 +static int rcv_forcing_row(NPP *npp, void *info);
297.2093 +
297.2094 +int npp_forcing_row(NPP *npp, NPPROW *p, int at)
297.2095 +{     /* process forcing row */
297.2096 +      struct forcing_row *info;
297.2097 +      struct forcing_col *col = NULL;
297.2098 +      NPPCOL *j;
297.2099 +      NPPAIJ *apj, *aij;
297.2100 +      NPPLFE *lfe;
297.2101 +      double big;
297.2102 +      xassert(at == 0 || at == 1);
297.2103 +      /* determine maximal magnitude of the row coefficients */
297.2104 +      big = 1.0;
297.2105 +      for (apj = p->ptr; apj != NULL; apj = apj->r_next)
297.2106 +         if (big < fabs(apj->val)) big = fabs(apj->val);
297.2107 +      /* if there are too small coefficients in the row, transformation
297.2108 +         should not be applied */
297.2109 +      for (apj = p->ptr; apj != NULL; apj = apj->r_next)
297.2110 +         if (fabs(apj->val) < 1e-7 * big) return 1;
297.2111 +      /* create transformation stack entry */
297.2112 +      info = npp_push_tse(npp,
297.2113 +         rcv_forcing_row, sizeof(struct forcing_row));
297.2114 +      info->p = p->i;
297.2115 +      if (p->lb == p->ub)
297.2116 +      {  /* equality constraint */
297.2117 +         info->stat = GLP_NS;
297.2118 +      }
297.2119 +      else if (at == 0)
297.2120 +      {  /* inequality constraint; case L[p] = U'[p] */
297.2121 +         info->stat = GLP_NL;
297.2122 +         xassert(p->lb != -DBL_MAX);
297.2123 +      }
297.2124 +      else /* at == 1 */
297.2125 +      {  /* inequality constraint; case U[p] = L'[p] */
297.2126 +         info->stat = GLP_NU;
297.2127 +         xassert(p->ub != +DBL_MAX);
297.2128 +      }
297.2129 +      info->ptr = NULL;
297.2130 +      /* scan the forcing row, fix columns at corresponding bounds, and
297.2131 +         save column information (the latter is not needed for MIP) */
297.2132 +      for (apj = p->ptr; apj != NULL; apj = apj->r_next)
297.2133 +      {  /* column j has non-zero coefficient in the forcing row */
297.2134 +         j = apj->col;
297.2135 +         /* it must be non-fixed */
297.2136 +         xassert(j->lb < j->ub);
297.2137 +         /* allocate stack entry to save column information */
297.2138 +         if (npp->sol != GLP_MIP)
297.2139 +         {  col = dmp_get_atom(npp->stack, sizeof(struct forcing_col));
297.2140 +            col->j = j->j;
297.2141 +            col->stat = -1; /* will be set below */
297.2142 +            col->a = apj->val;
297.2143 +            col->c = j->coef;
297.2144 +            col->ptr = NULL;
297.2145 +            col->next = info->ptr;
297.2146 +            info->ptr = col;
297.2147 +         }
297.2148 +         /* fix column j */
297.2149 +         if (at == 0 && apj->val < 0.0 || at != 0 && apj->val > 0.0)
297.2150 +         {  /* at its lower bound */
297.2151 +            if (npp->sol != GLP_MIP)
297.2152 +               col->stat = GLP_NL;
297.2153 +            xassert(j->lb != -DBL_MAX);
297.2154 +            j->ub = j->lb;
297.2155 +         }
297.2156 +         else
297.2157 +         {  /* at its upper bound */
297.2158 +            if (npp->sol != GLP_MIP)
297.2159 +               col->stat = GLP_NU;
297.2160 +            xassert(j->ub != +DBL_MAX);
297.2161 +            j->lb = j->ub;
297.2162 +         }
297.2163 +         /* save column coefficients a[i,j], i != p */
297.2164 +         if (npp->sol != GLP_MIP)
297.2165 +         {  for (aij = j->ptr; aij != NULL; aij = aij->c_next)
297.2166 +            {  if (aij == apj) continue; /* skip a[p,j] */
297.2167 +               lfe = dmp_get_atom(npp->stack, sizeof(NPPLFE));
297.2168 +               lfe->ref = aij->row->i;
297.2169 +               lfe->val = aij->val;
297.2170 +               lfe->next = col->ptr;
297.2171 +               col->ptr = lfe;
297.2172 +            }
297.2173 +         }
297.2174 +      }
297.2175 +      /* make the row free (unbounded) */
297.2176 +      p->lb = -DBL_MAX, p->ub = +DBL_MAX;
297.2177 +      return 0;
297.2178 +}
297.2179 +
297.2180 +static int rcv_forcing_row(NPP *npp, void *_info)
297.2181 +{     /* recover forcing row */
297.2182 +      struct forcing_row *info = _info;
297.2183 +      struct forcing_col *col, *piv;
297.2184 +      NPPLFE *lfe;
297.2185 +      double d, big, temp;
297.2186 +      if (npp->sol == GLP_MIP) goto done;
297.2187 +      /* initially solution to the original problem is the same as
297.2188 +         to the transformed problem, where row p is inactive constraint
297.2189 +         with pi[p] = 0, and all columns are non-basic */
297.2190 +      if (npp->sol == GLP_SOL)
297.2191 +      {  if (npp->r_stat[info->p] != GLP_BS)
297.2192 +         {  npp_error();
297.2193 +            return 1;
297.2194 +         }
297.2195 +         for (col = info->ptr; col != NULL; col = col->next)
297.2196 +         {  if (npp->c_stat[col->j] != GLP_NS)
297.2197 +            {  npp_error();
297.2198 +               return 1;
297.2199 +            }
297.2200 +            npp->c_stat[col->j] = col->stat; /* original status */
297.2201 +         }
297.2202 +      }
297.2203 +      /* compute reduced costs d[j] for all columns with formula (10)
297.2204 +         and store them in col.c instead objective coefficients */
297.2205 +      for (col = info->ptr; col != NULL; col = col->next)
297.2206 +      {  d = col->c;
297.2207 +         for (lfe = col->ptr; lfe != NULL; lfe = lfe->next)
297.2208 +            d -= lfe->val * npp->r_pi[lfe->ref];
297.2209 +         col->c = d;
297.2210 +      }
297.2211 +      /* consider columns j, whose multipliers lambda[j] has wrong
297.2212 +         sign in solution to the transformed problem (where lambda[j] =
297.2213 +         d[j]), and choose column q, whose multipler lambda[q] reaches
297.2214 +         zero last on changing row multiplier pi[p]; see (14) */
297.2215 +      piv = NULL, big = 0.0;
297.2216 +      for (col = info->ptr; col != NULL; col = col->next)
297.2217 +      {  d = col->c; /* d[j] */
297.2218 +         temp = fabs(d / col->a);
297.2219 +         if (col->stat == GLP_NL)
297.2220 +         {  /* column j has active lower bound */
297.2221 +            if (d < 0.0 && big < temp)
297.2222 +               piv = col, big = temp;
297.2223 +         }
297.2224 +         else if (col->stat == GLP_NU)
297.2225 +         {  /* column j has active upper bound */
297.2226 +            if (d > 0.0 && big < temp)
297.2227 +               piv = col, big = temp;
297.2228 +         }
297.2229 +         else
297.2230 +         {  npp_error();
297.2231 +            return 1;
297.2232 +         }
297.2233 +      }
297.2234 +      /* if column q does not exist, no correction is needed */
297.2235 +      if (piv != NULL)
297.2236 +      {  /* correct solution; row p becomes active constraint while
297.2237 +            column q becomes basic */
297.2238 +         if (npp->sol == GLP_SOL)
297.2239 +         {  npp->r_stat[info->p] = info->stat;
297.2240 +            npp->c_stat[piv->j] = GLP_BS;
297.2241 +         }
297.2242 +         /* assign new value to row multiplier pi[p] = d[p] / a[p,q] */
297.2243 +         npp->r_pi[info->p] = piv->c / piv->a;
297.2244 +      }
297.2245 +done: return 0;
297.2246 +}
297.2247 +
297.2248 +/***********************************************************************
297.2249 +*  NAME
297.2250 +*
297.2251 +*  npp_analyze_row - perform general row analysis
297.2252 +*
297.2253 +*  SYNOPSIS
297.2254 +*
297.2255 +*  #include "glpnpp.h"
297.2256 +*  int npp_analyze_row(NPP *npp, NPPROW *p);
297.2257 +*
297.2258 +*  DESCRIPTION
297.2259 +*
297.2260 +*  The routine npp_analyze_row performs analysis of row p of general
297.2261 +*  format:
297.2262 +*
297.2263 +*     L[p] <= sum a[p,j] x[j] <= U[p],                               (1)
297.2264 +*              j
297.2265 +*
297.2266 +*     l[j] <= x[j] <= u[j],                                          (2)
297.2267 +*
297.2268 +*  where L[p] <= U[p] and l[j] <= u[j] for all a[p,j] != 0.
297.2269 +*
297.2270 +*  RETURNS
297.2271 +*
297.2272 +*  0x?0 - row lower bound does not exist or is redundant;
297.2273 +*
297.2274 +*  0x?1 - row lower bound can be active;
297.2275 +*
297.2276 +*  0x?2 - row lower bound is a forcing bound;
297.2277 +*
297.2278 +*  0x0? - row upper bound does not exist or is redundant;
297.2279 +*
297.2280 +*  0x1? - row upper bound can be active;
297.2281 +*
297.2282 +*  0x2? - row upper bound is a forcing bound;
297.2283 +*
297.2284 +*  0x33 - row bounds are inconsistent with column bounds.
297.2285 +*
297.2286 +*  ALGORITHM
297.2287 +*
297.2288 +*  Analysis of row (1) is based on analysis of its implied lower and
297.2289 +*  upper bounds, which are determined by bounds of corresponding columns
297.2290 +*  (variables) as follows:
297.2291 +*
297.2292 +*     L'[p] = inf sum a[p,j] x[j] =
297.2293 +*                  j
297.2294 +*                                                                    (3)
297.2295 +*           =  sum  a[p,j] l[j] +  sum  a[p,j] u[j],
297.2296 +*            j in Jp             j in Jn
297.2297 +*
297.2298 +*     U'[p] = sup sum a[p,j] x[j] =
297.2299 +*                                                                    (4)
297.2300 +*           =  sum  a[p,j] u[j] +  sum  a[p,j] l[j],
297.2301 +*            j in Jp             j in Jn
297.2302 +*
297.2303 +*     Jp = {j: a[p,j] > 0},  Jn = {j: a[p,j] < 0}.                   (5)
297.2304 +*
297.2305 +*  (Note that bounds of all columns in row p are assumed to be correct,
297.2306 +*  so L'[p] <= U'[p].)
297.2307 +*
297.2308 +*  Analysis of row lower bound L[p] includes the following cases:
297.2309 +*
297.2310 +*  1) if L[p] > U'[p] + eps, where eps is an absolute tolerance for row
297.2311 +*     value, row lower bound L[p] and implied row upper bound U'[p] are
297.2312 +*     inconsistent, ergo, the problem has no primal feasible solution;
297.2313 +*
297.2314 +*  2) if U'[p] - eps <= L[p] <= U'[p] + eps, i.e. if L[p] =~ U'[p],
297.2315 +*     the row is a forcing row on its lower bound (see description of
297.2316 +*     the routine npp_forcing_row);
297.2317 +*
297.2318 +*  3) if L[p] > L'[p] + eps, row lower bound L[p] can be active (this
297.2319 +*     conclusion does not account other rows in the problem);
297.2320 +*
297.2321 +*  4) if L[p] <= L'[p] + eps, row lower bound L[p] cannot be active, so
297.2322 +*     it is redundant and can be removed (replaced by -oo).
297.2323 +*
297.2324 +*  Analysis of row upper bound U[p] is performed in a similar way and
297.2325 +*  includes the following cases:
297.2326 +*
297.2327 +*  1) if U[p] < L'[p] - eps, row upper bound U[p] and implied row lower
297.2328 +*     bound L'[p] are inconsistent, ergo the problem has no primal
297.2329 +*     feasible solution;
297.2330 +*
297.2331 +*  2) if L'[p] - eps <= U[p] <= L'[p] + eps, i.e. if U[p] =~ L'[p],
297.2332 +*     the row is a forcing row on its upper bound (see description of
297.2333 +*     the routine npp_forcing_row);
297.2334 +*
297.2335 +*  3) if U[p] < U'[p] - eps, row upper bound U[p] can be active (this
297.2336 +*     conclusion does not account other rows in the problem);
297.2337 +*
297.2338 +*  4) if U[p] >= U'[p] - eps, row upper bound U[p] cannot be active, so
297.2339 +*     it is redundant and can be removed (replaced by +oo). */
297.2340 +
297.2341 +int npp_analyze_row(NPP *npp, NPPROW *p)
297.2342 +{     /* perform general row analysis */
297.2343 +      NPPAIJ *aij;
297.2344 +      int ret = 0x00;
297.2345 +      double l, u, eps;
297.2346 +      xassert(npp == npp);
297.2347 +      /* compute implied lower bound L'[p]; see (3) */
297.2348 +      l = 0.0;
297.2349 +      for (aij = p->ptr; aij != NULL; aij = aij->r_next)
297.2350 +      {  if (aij->val > 0.0)
297.2351 +         {  if (aij->col->lb == -DBL_MAX)
297.2352 +            {  l = -DBL_MAX;
297.2353 +               break;
297.2354 +            }
297.2355 +            l += aij->val * aij->col->lb;
297.2356 +         }
297.2357 +         else /* aij->val < 0.0 */
297.2358 +         {  if (aij->col->ub == +DBL_MAX)
297.2359 +            {  l = -DBL_MAX;
297.2360 +               break;
297.2361 +            }
297.2362 +            l += aij->val * aij->col->ub;
297.2363 +         }
297.2364 +      }
297.2365 +      /* compute implied upper bound U'[p]; see (4) */
297.2366 +      u = 0.0;
297.2367 +      for (aij = p->ptr; aij != NULL; aij = aij->r_next)
297.2368 +      {  if (aij->val > 0.0)
297.2369 +         {  if (aij->col->ub == +DBL_MAX)
297.2370 +            {  u = +DBL_MAX;
297.2371 +               break;
297.2372 +            }
297.2373 +            u += aij->val * aij->col->ub;
297.2374 +         }
297.2375 +         else /* aij->val < 0.0 */
297.2376 +         {  if (aij->col->lb == -DBL_MAX)
297.2377 +            {  u = +DBL_MAX;
297.2378 +               break;
297.2379 +            }
297.2380 +            u += aij->val * aij->col->lb;
297.2381 +         }
297.2382 +      }
297.2383 +      /* column bounds are assumed correct, so L'[p] <= U'[p] */
297.2384 +      /* check if row lower bound is consistent */
297.2385 +      if (p->lb != -DBL_MAX)
297.2386 +      {  eps = 1e-3 + 1e-6 * fabs(p->lb);
297.2387 +         if (p->lb - eps > u)
297.2388 +         {  ret = 0x33;
297.2389 +            goto done;
297.2390 +         }
297.2391 +      }
297.2392 +      /* check if row upper bound is consistent */
297.2393 +      if (p->ub != +DBL_MAX)
297.2394 +      {  eps = 1e-3 + 1e-6 * fabs(p->ub);
297.2395 +         if (p->ub + eps < l)
297.2396 +         {  ret = 0x33;
297.2397 +            goto done;
297.2398 +         }
297.2399 +      }
297.2400 +      /* check if row lower bound can be active/forcing */
297.2401 +      if (p->lb != -DBL_MAX)
297.2402 +      {  eps = 1e-9 + 1e-12 * fabs(p->lb);
297.2403 +         if (p->lb - eps > l)
297.2404 +         {  if (p->lb + eps <= u)
297.2405 +               ret |= 0x01;
297.2406 +            else
297.2407 +               ret |= 0x02;
297.2408 +         }
297.2409 +      }
297.2410 +      /* check if row upper bound can be active/forcing */
297.2411 +      if (p->ub != +DBL_MAX)
297.2412 +      {  eps = 1e-9 + 1e-12 * fabs(p->ub);
297.2413 +         if (p->ub + eps < u)
297.2414 +         {  /* check if the upper bound is forcing */
297.2415 +            if (p->ub - eps >= l)
297.2416 +               ret |= 0x10;
297.2417 +            else
297.2418 +               ret |= 0x20;
297.2419 +         }
297.2420 +      }
297.2421 +done: return ret;
297.2422 +}
297.2423 +
297.2424 +/***********************************************************************
297.2425 +*  NAME
297.2426 +*
297.2427 +*  npp_inactive_bound - remove row lower/upper inactive bound
297.2428 +*
297.2429 +*  SYNOPSIS
297.2430 +*
297.2431 +*  #include "glpnpp.h"
297.2432 +*  void npp_inactive_bound(NPP *npp, NPPROW *p, int which);
297.2433 +*
297.2434 +*  DESCRIPTION
297.2435 +*
297.2436 +*  The routine npp_inactive_bound removes lower (if which = 0) or upper
297.2437 +*  (if which = 1) bound of row p:
297.2438 +*
297.2439 +*     L[p] <= sum a[p,j] x[j] <= U[p],
297.2440 +*
297.2441 +*  which (bound) is assumed to be redundant.
297.2442 +*
297.2443 +*  PROBLEM TRANSFORMATION
297.2444 +*
297.2445 +*  If which = 0, current lower bound L[p] of row p is assigned -oo.
297.2446 +*  If which = 1, current upper bound U[p] of row p is assigned +oo.
297.2447 +*
297.2448 +*  RECOVERING BASIC SOLUTION
297.2449 +*
297.2450 +*  If in solution to the transformed problem row p is inactive
297.2451 +*  constraint (GLP_BS), its status is not changed in solution to the
297.2452 +*  original problem. Otherwise, status of row p in solution to the
297.2453 +*  original problem is defined by its type before transformation and
297.2454 +*  its status in solution to the transformed problem as follows:
297.2455 +*
297.2456 +*     +---------------------+-------+---------------+---------------+
297.2457 +*     |        Row          | Flag  | Row status in | Row status in |
297.2458 +*     |        type         | which | transfmd soln | original soln |
297.2459 +*     +---------------------+-------+---------------+---------------+
297.2460 +*     |     sum >= L[p]     |   0   |    GLP_NF     |    GLP_NL     |
297.2461 +*     |     sum <= U[p]     |   1   |    GLP_NF     |    GLP_NU     |
297.2462 +*     | L[p] <= sum <= U[p] |   0   |    GLP_NU     |    GLP_NU     |
297.2463 +*     | L[p] <= sum <= U[p] |   1   |    GLP_NL     |    GLP_NL     |
297.2464 +*     |  sum = L[p] = U[p]  |   0   |    GLP_NU     |    GLP_NS     |
297.2465 +*     |  sum = L[p] = U[p]  |   1   |    GLP_NL     |    GLP_NS     |
297.2466 +*     +---------------------+-------+---------------+---------------+
297.2467 +*
297.2468 +*  RECOVERING INTERIOR-POINT SOLUTION
297.2469 +*
297.2470 +*  None needed.
297.2471 +*
297.2472 +*  RECOVERING MIP SOLUTION
297.2473 +*
297.2474 +*  None needed. */
297.2475 +
297.2476 +struct inactive_bound
297.2477 +{     /* row inactive bound */
297.2478 +      int p;
297.2479 +      /* row reference number */
297.2480 +      char stat;
297.2481 +      /* row status (if active constraint) */
297.2482 +};
297.2483 +
297.2484 +static int rcv_inactive_bound(NPP *npp, void *info);
297.2485 +
297.2486 +void npp_inactive_bound(NPP *npp, NPPROW *p, int which)
297.2487 +{     /* remove row lower/upper inactive bound */
297.2488 +      struct inactive_bound *info;
297.2489 +      if (npp->sol == GLP_SOL)
297.2490 +      {  /* create transformation stack entry */
297.2491 +         info = npp_push_tse(npp,
297.2492 +            rcv_inactive_bound, sizeof(struct inactive_bound));
297.2493 +         info->p = p->i;
297.2494 +         if (p->ub == +DBL_MAX)
297.2495 +            info->stat = GLP_NL;
297.2496 +         else if (p->lb == -DBL_MAX)
297.2497 +            info->stat = GLP_NU;
297.2498 +         else if (p->lb != p->ub)
297.2499 +            info->stat = (char)(which == 0 ? GLP_NU : GLP_NL);
297.2500 +         else
297.2501 +            info->stat = GLP_NS;
297.2502 +      }
297.2503 +      /* remove row inactive bound */
297.2504 +      if (which == 0)
297.2505 +      {  xassert(p->lb != -DBL_MAX);
297.2506 +         p->lb = -DBL_MAX;
297.2507 +      }
297.2508 +      else if (which == 1)
297.2509 +      {  xassert(p->ub != +DBL_MAX);
297.2510 +         p->ub = +DBL_MAX;
297.2511 +      }
297.2512 +      else
297.2513 +         xassert(which != which);
297.2514 +      return;
297.2515 +}
297.2516 +
297.2517 +static int rcv_inactive_bound(NPP *npp, void *_info)
297.2518 +{     /* recover row status */
297.2519 +      struct inactive_bound *info = _info;
297.2520 +      if (npp->sol != GLP_SOL)
297.2521 +      {  npp_error();
297.2522 +         return 1;
297.2523 +      }
297.2524 +      if (npp->r_stat[info->p] == GLP_BS)
297.2525 +         npp->r_stat[info->p] = GLP_BS;
297.2526 +      else
297.2527 +         npp->r_stat[info->p] = info->stat;
297.2528 +      return 0;
297.2529 +}
297.2530 +
297.2531 +/***********************************************************************
297.2532 +*  NAME
297.2533 +*
297.2534 +*  npp_implied_bounds - determine implied column bounds
297.2535 +*
297.2536 +*  SYNOPSIS
297.2537 +*
297.2538 +*  #include "glpnpp.h"
297.2539 +*  void npp_implied_bounds(NPP *npp, NPPROW *p);
297.2540 +*
297.2541 +*  DESCRIPTION
297.2542 +*
297.2543 +*  The routine npp_implied_bounds inspects general row (constraint) p:
297.2544 +*
297.2545 +*     L[p] <= sum a[p,j] x[j] <= U[p],                               (1)
297.2546 +*
297.2547 +*     l[j] <= x[j] <= u[j],                                          (2)
297.2548 +*
297.2549 +*  where L[p] <= U[p] and l[j] <= u[j] for all a[p,j] != 0, to compute
297.2550 +*  implied bounds of columns (variables x[j]) in this row.
297.2551 +*
297.2552 +*  The routine stores implied column bounds l'[j] and u'[j] in column
297.2553 +*  descriptors (NPPCOL); it does not change current column bounds l[j]
297.2554 +*  and u[j]. (Implied column bounds can be then used to strengthen the
297.2555 +*  current column bounds; see the routines npp_implied_lower and
297.2556 +*  npp_implied_upper).
297.2557 +*
297.2558 +*  ALGORITHM
297.2559 +*
297.2560 +*  Current column bounds (2) define implied lower and upper bounds of
297.2561 +*  row (1) as follows:
297.2562 +*
297.2563 +*     L'[p] = inf sum a[p,j] x[j] =
297.2564 +*                  j
297.2565 +*                                                                    (3)
297.2566 +*           =  sum  a[p,j] l[j] +  sum  a[p,j] u[j],
297.2567 +*            j in Jp             j in Jn
297.2568 +*
297.2569 +*     U'[p] = sup sum a[p,j] x[j] =
297.2570 +*                                                                    (4)
297.2571 +*           =  sum  a[p,j] u[j] +  sum  a[p,j] l[j],
297.2572 +*            j in Jp             j in Jn
297.2573 +*
297.2574 +*     Jp = {j: a[p,j] > 0},  Jn = {j: a[p,j] < 0}.                   (5)
297.2575 +*
297.2576 +*  (Note that bounds of all columns in row p are assumed to be correct,
297.2577 +*  so L'[p] <= U'[p].)
297.2578 +*
297.2579 +*  If L[p] > L'[p] and/or U[p] < U'[p], the lower and/or upper bound of
297.2580 +*  row (1) can be active, in which case such row defines implied bounds
297.2581 +*  of its variables.
297.2582 +*
297.2583 +*  Let x[k] be some variable having in row (1) coefficient a[p,k] != 0.
297.2584 +*  Consider a case when row lower bound can be active (L[p] > L'[p]):
297.2585 +*
297.2586 +*     sum a[p,j] x[j] >= L[p]  ==>
297.2587 +*      j
297.2588 +*
297.2589 +*     sum a[p,j] x[j] + a[p,k] x[k] >= L[p]  ==>
297.2590 +*     j!=k
297.2591 +*                                                                    (6)
297.2592 +*     a[p,k] x[k] >= L[p] - sum a[p,j] x[j]  ==>
297.2593 +*                           j!=k
297.2594 +*
297.2595 +*     a[p,k] x[k] >= L[p,k],
297.2596 +*
297.2597 +*  where
297.2598 +*
297.2599 +*     L[p,k] = inf(L[p] - sum a[p,j] x[j]) =
297.2600 +*                         j!=k
297.2601 +*
297.2602 +*            = L[p] - sup sum a[p,j] x[j] =                          (7)
297.2603 +*                         j!=k
297.2604 +*
297.2605 +*            = L[p] - sum a[p,j] u[j] - sum a[p,j] l[j].
297.2606 +*                    j in Jp\{k}       j in Jn\{k}
297.2607 +*
297.2608 +*  Thus:
297.2609 +*
297.2610 +*     x[k] >= l'[k] = L[p,k] / a[p,k],  if a[p,k] > 0,               (8)
297.2611 +*
297.2612 +*     x[k] <= u'[k] = L[p,k] / a[p,k],  if a[p,k] < 0.               (9)
297.2613 +*
297.2614 +*  where l'[k] and u'[k] are implied lower and upper bounds of variable
297.2615 +*  x[k], resp.
297.2616 +*
297.2617 +*  Now consider a similar case when row upper bound can be active
297.2618 +*  (U[p] < U'[p]):
297.2619 +*
297.2620 +*     sum a[p,j] x[j] <= U[p]  ==>
297.2621 +*      j
297.2622 +*
297.2623 +*     sum a[p,j] x[j] + a[p,k] x[k] <= U[p]  ==>
297.2624 +*     j!=k
297.2625 +*                                                                   (10)
297.2626 +*     a[p,k] x[k] <= U[p] - sum a[p,j] x[j]  ==>
297.2627 +*                           j!=k
297.2628 +*
297.2629 +*     a[p,k] x[k] <= U[p,k],
297.2630 +*
297.2631 +*  where:
297.2632 +*
297.2633 +*     U[p,k] = sup(U[p] - sum a[p,j] x[j]) =
297.2634 +*                         j!=k
297.2635 +*
297.2636 +*            = U[p] - inf sum a[p,j] x[j] =                         (11)
297.2637 +*                         j!=k
297.2638 +*
297.2639 +*            = U[p] - sum a[p,j] l[j] - sum a[p,j] u[j].
297.2640 +*                    j in Jp\{k}       j in Jn\{k}
297.2641 +*
297.2642 +*  Thus:
297.2643 +*
297.2644 +*     x[k] <= u'[k] = U[p,k] / a[p,k],  if a[p,k] > 0,              (12)
297.2645 +*
297.2646 +*     x[k] >= l'[k] = U[p,k] / a[p,k],  if a[p,k] < 0.              (13)
297.2647 +*
297.2648 +*  Note that in formulae (8), (9), (12), and (13) coefficient a[p,k]
297.2649 +*  must not be too small in magnitude relatively to other non-zero
297.2650 +*  coefficients in row (1), i.e. the following condition must hold:
297.2651 +*
297.2652 +*     |a[p,k]| >= eps * max(1, |a[p,j]|),                           (14)
297.2653 +*                        j
297.2654 +*
297.2655 +*  where eps is a relative tolerance for constraint coefficients.
297.2656 +*  Otherwise the implied column bounds can be numerical inreliable. For
297.2657 +*  example, using formula (8) for the following inequality constraint:
297.2658 +*
297.2659 +*     1e-12 x1 - x2 - x3 >= 0,
297.2660 +*
297.2661 +*  where x1 >= -1, x2, x3, >= 0, may lead to numerically unreliable
297.2662 +*  conclusion that x1 >= 0.
297.2663 +*
297.2664 +*  Using formulae (8), (9), (12), and (13) to compute implied bounds
297.2665 +*  for one variable requires |J| operations, where J = {j: a[p,j] != 0},
297.2666 +*  because this needs computing L[p,k] and U[p,k]. Thus, computing
297.2667 +*  implied bounds for all variables in row (1) would require |J|^2
297.2668 +*  operations, that is not a good technique. However, the total number
297.2669 +*  of operations can be reduced to |J| as follows.
297.2670 +*
297.2671 +*  Let a[p,k] > 0. Then from (7) and (11) we have:
297.2672 +*
297.2673 +*     L[p,k] = L[p] - (U'[p] - a[p,k] u[k]) =
297.2674 +*
297.2675 +*            = L[p] - U'[p] + a[p,k] u[k],
297.2676 +*
297.2677 +*     U[p,k] = U[p] - (L'[p] - a[p,k] l[k]) =
297.2678 +*
297.2679 +*            = U[p] - L'[p] + a[p,k] l[k],
297.2680 +*
297.2681 +*  where L'[p] and U'[p] are implied row lower and upper bounds defined
297.2682 +*  by formulae (3) and (4). Substituting these expressions into (8) and
297.2683 +*  (12) gives:
297.2684 +*
297.2685 +*     l'[k] = L[p,k] / a[p,k] = u[k] + (L[p] - U'[p]) / a[p,k],     (15)
297.2686 +*
297.2687 +*     u'[k] = U[p,k] / a[p,k] = l[k] + (U[p] - L'[p]) / a[p,k].     (16)
297.2688 +*
297.2689 +*  Similarly, if a[p,k] < 0, according to (7) and (11) we have:
297.2690 +*
297.2691 +*     L[p,k] = L[p] - (U'[p] - a[p,k] l[k]) =
297.2692 +*
297.2693 +*            = L[p] - U'[p] + a[p,k] l[k],
297.2694 +*
297.2695 +*     U[p,k] = U[p] - (L'[p] - a[p,k] u[k]) =
297.2696 +*
297.2697 +*            = U[p] - L'[p] + a[p,k] u[k],
297.2698 +*
297.2699 +*  and substituting these expressions into (8) and (12) gives:
297.2700 +*
297.2701 +*     l'[k] = U[p,k] / a[p,k] = u[k] + (U[p] - L'[p]) / a[p,k],     (17)
297.2702 +*
297.2703 +*     u'[k] = L[p,k] / a[p,k] = l[k] + (L[p] - U'[p]) / a[p,k].     (18)
297.2704 +*
297.2705 +*  Note that formulae (15)-(18) can be used only if L'[p] and U'[p]
297.2706 +*  exist. However, if for some variable x[j] it happens that l[j] = -oo
297.2707 +*  and/or u[j] = +oo, values of L'[p] (if a[p,j] > 0) and/or U'[p] (if
297.2708 +*  a[p,j] < 0) are undefined. Consider, therefore, the most general
297.2709 +*  situation, when some column bounds (2) may not exist.
297.2710 +*
297.2711 +*  Let:
297.2712 +*
297.2713 +*     J' = {j : (a[p,j] > 0 and l[j] = -oo) or
297.2714 +*                                                                   (19)
297.2715 +*               (a[p,j] < 0 and u[j] = +oo)}.
297.2716 +*
297.2717 +*  Then (assuming that row upper bound U[p] can be active) the following
297.2718 +*  three cases are possible:
297.2719 +*
297.2720 +*  1) |J'| = 0. In this case L'[p] exists, thus, for all variables x[j]
297.2721 +*     in row (1) we can use formulae (16) and (17);
297.2722 +*
297.2723 +*  2) J' = {k}. In this case L'[p] = -oo, however, U[p,k] (11) exists,
297.2724 +*     so for variable x[k] we can use formulae (12) and (13). Note that
297.2725 +*     for all other variables x[j] (j != k) l'[j] = -oo (if a[p,j] < 0)
297.2726 +*     or u'[j] = +oo (if a[p,j] > 0);
297.2727 +*
297.2728 +*  3) |J'| > 1. In this case for all variables x[j] in row [1] we have
297.2729 +*     l'[j] = -oo (if a[p,j] < 0) or u'[j] = +oo (if a[p,j] > 0).
297.2730 +*
297.2731 +*  Similarly, let:
297.2732 +*
297.2733 +*     J'' = {j : (a[p,j] > 0 and u[j] = +oo) or
297.2734 +*                                                                   (20)
297.2735 +*                (a[p,j] < 0 and l[j] = -oo)}.
297.2736 +*
297.2737 +*  Then (assuming that row lower bound L[p] can be active) the following
297.2738 +*  three cases are possible:
297.2739 +*
297.2740 +*  1) |J''| = 0. In this case U'[p] exists, thus, for all variables x[j]
297.2741 +*     in row (1) we can use formulae (15) and (18);
297.2742 +*
297.2743 +*  2) J'' = {k}. In this case U'[p] = +oo, however, L[p,k] (7) exists,
297.2744 +*     so for variable x[k] we can use formulae (8) and (9). Note that
297.2745 +*     for all other variables x[j] (j != k) l'[j] = -oo (if a[p,j] > 0)
297.2746 +*     or u'[j] = +oo (if a[p,j] < 0);
297.2747 +*
297.2748 +*  3) |J''| > 1. In this case for all variables x[j] in row (1) we have
297.2749 +*     l'[j] = -oo (if a[p,j] > 0) or u'[j] = +oo (if a[p,j] < 0). */
297.2750 +
297.2751 +void npp_implied_bounds(NPP *npp, NPPROW *p)
297.2752 +{     NPPAIJ *apj, *apk;
297.2753 +      double big, eps, temp;
297.2754 +      xassert(npp == npp);
297.2755 +      /* initialize implied bounds for all variables and determine
297.2756 +         maximal magnitude of row coefficients a[p,j] */
297.2757 +      big = 1.0;
297.2758 +      for (apj = p->ptr; apj != NULL; apj = apj->r_next)
297.2759 +      {  apj->col->ll.ll = -DBL_MAX, apj->col->uu.uu = +DBL_MAX;
297.2760 +         if (big < fabs(apj->val)) big = fabs(apj->val);
297.2761 +      }
297.2762 +      eps = 1e-6 * big;
297.2763 +      /* process row lower bound (assuming that it can be active) */
297.2764 +      if (p->lb != -DBL_MAX)
297.2765 +      {  apk = NULL;
297.2766 +         for (apj = p->ptr; apj != NULL; apj = apj->r_next)
297.2767 +         {  if (apj->val > 0.0 && apj->col->ub == +DBL_MAX ||
297.2768 +                apj->val < 0.0 && apj->col->lb == -DBL_MAX)
297.2769 +            {  if (apk == NULL)
297.2770 +                  apk = apj;
297.2771 +               else
297.2772 +                  goto skip1;
297.2773 +            }
297.2774 +         }
297.2775 +         /* if a[p,k] = NULL then |J'| = 0 else J' = { k } */
297.2776 +         temp = p->lb;
297.2777 +         for (apj = p->ptr; apj != NULL; apj = apj->r_next)
297.2778 +         {  if (apj == apk)
297.2779 +               /* skip a[p,k] */;
297.2780 +            else if (apj->val > 0.0)
297.2781 +               temp -= apj->val * apj->col->ub;
297.2782 +            else /* apj->val < 0.0 */
297.2783 +               temp -= apj->val * apj->col->lb;
297.2784 +         }
297.2785 +         /* compute column implied bounds */
297.2786 +         if (apk == NULL)
297.2787 +         {  /* temp = L[p] - U'[p] */
297.2788 +            for (apj = p->ptr; apj != NULL; apj = apj->r_next)
297.2789 +            {  if (apj->val >= +eps)
297.2790 +               {  /* l'[j] := u[j] + (L[p] - U'[p]) / a[p,j] */
297.2791 +                  apj->col->ll.ll = apj->col->ub + temp / apj->val;
297.2792 +               }
297.2793 +               else if (apj->val <= -eps)
297.2794 +               {  /* u'[j] := l[j] + (L[p] - U'[p]) / a[p,j] */
297.2795 +                  apj->col->uu.uu = apj->col->lb + temp / apj->val;
297.2796 +               }
297.2797 +            }
297.2798 +         }
297.2799 +         else
297.2800 +         {  /* temp = L[p,k] */
297.2801 +            if (apk->val >= +eps)
297.2802 +            {  /* l'[k] := L[p,k] / a[p,k] */
297.2803 +               apk->col->ll.ll = temp / apk->val;
297.2804 +            }
297.2805 +            else if (apk->val <= -eps)
297.2806 +            {  /* u'[k] := L[p,k] / a[p,k] */
297.2807 +               apk->col->uu.uu = temp / apk->val;
297.2808 +            }
297.2809 +         }
297.2810 +skip1:   ;
297.2811 +      }
297.2812 +      /* process row upper bound (assuming that it can be active) */
297.2813 +      if (p->ub != +DBL_MAX)
297.2814 +      {  apk = NULL;
297.2815 +         for (apj = p->ptr; apj != NULL; apj = apj->r_next)
297.2816 +         {  if (apj->val > 0.0 && apj->col->lb == -DBL_MAX ||
297.2817 +                apj->val < 0.0 && apj->col->ub == +DBL_MAX)
297.2818 +            {  if (apk == NULL)
297.2819 +                  apk = apj;
297.2820 +               else
297.2821 +                  goto skip2;
297.2822 +            }
297.2823 +         }
297.2824 +         /* if a[p,k] = NULL then |J''| = 0 else J'' = { k } */
297.2825 +         temp = p->ub;
297.2826 +         for (apj = p->ptr; apj != NULL; apj = apj->r_next)
297.2827 +         {  if (apj == apk)
297.2828 +               /* skip a[p,k] */;
297.2829 +            else if (apj->val > 0.0)
297.2830 +               temp -= apj->val * apj->col->lb;
297.2831 +            else /* apj->val < 0.0 */
297.2832 +               temp -= apj->val * apj->col->ub;
297.2833 +         }
297.2834 +         /* compute column implied bounds */
297.2835 +         if (apk == NULL)
297.2836 +         {  /* temp = U[p] - L'[p] */
297.2837 +            for (apj = p->ptr; apj != NULL; apj = apj->r_next)
297.2838 +            {  if (apj->val >= +eps)
297.2839 +               {  /* u'[j] := l[j] + (U[p] - L'[p]) / a[p,j] */
297.2840 +                  apj->col->uu.uu = apj->col->lb + temp / apj->val;
297.2841 +               }
297.2842 +               else if (apj->val <= -eps)
297.2843 +               {  /* l'[j] := u[j] + (U[p] - L'[p]) / a[p,j] */
297.2844 +                  apj->col->ll.ll = apj->col->ub + temp / apj->val;
297.2845 +               }
297.2846 +            }
297.2847 +         }
297.2848 +         else
297.2849 +         {  /* temp = U[p,k] */
297.2850 +            if (apk->val >= +eps)
297.2851 +            {  /* u'[k] := U[p,k] / a[p,k] */
297.2852 +               apk->col->uu.uu = temp / apk->val;
297.2853 +            }
297.2854 +            else if (apk->val <= -eps)
297.2855 +            {  /* l'[k] := U[p,k] / a[p,k] */
297.2856 +               apk->col->ll.ll = temp / apk->val;
297.2857 +            }
297.2858 +         }
297.2859 +skip2:   ;
297.2860 +      }
297.2861 +      return;
297.2862 +}
297.2863 +
297.2864 +/* eof */
   298.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
   298.2 +++ b/deps/glpk/src/glpnpp04.c	Sun Nov 06 20:59:10 2011 +0100
   298.3 @@ -0,0 +1,1414 @@
   298.4 +/* glpnpp04.c */
   298.5 +
   298.6 +/***********************************************************************
   298.7 +*  This code is part of GLPK (GNU Linear Programming Kit).
   298.8 +*
   298.9 +*  Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008,
  298.10 +*  2009, 2010, 2011 Andrew Makhorin, Department for Applied Informatics,
  298.11 +*  Moscow Aviation Institute, Moscow, Russia. All rights reserved.
  298.12 +*  E-mail: <mao@gnu.org>.
  298.13 +*
  298.14 +*  GLPK is free software: you can redistribute it and/or modify it
  298.15 +*  under the terms of the GNU General Public License as published by
  298.16 +*  the Free Software Foundation, either version 3 of the License, or
  298.17 +*  (at your option) any later version.
  298.18 +*
  298.19 +*  GLPK is distributed in the hope that it will be useful, but WITHOUT
  298.20 +*  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
  298.21 +*  or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
  298.22 +*  License for more details.
  298.23 +*
  298.24 +*  You should have received a copy of the GNU General Public License
  298.25 +*  along with GLPK. If not, see <http://www.gnu.org/licenses/>.
  298.26 +***********************************************************************/
  298.27 +
  298.28 +#include "glpnpp.h"
  298.29 +
  298.30 +/***********************************************************************
  298.31 +*  NAME
  298.32 +*
  298.33 +*  npp_binarize_prob - binarize MIP problem
  298.34 +*
  298.35 +*  SYNOPSIS
  298.36 +*
  298.37 +*  #include "glpnpp.h"
  298.38 +*  int npp_binarize_prob(NPP *npp);
  298.39 +*
  298.40 +*  DESCRIPTION
  298.41 +*
  298.42 +*  The routine npp_binarize_prob replaces in the original MIP problem
  298.43 +*  every integer variable:
  298.44 +*
  298.45 +*     l[q] <= x[q] <= u[q],                                          (1)
  298.46 +*
  298.47 +*  where l[q] < u[q], by an equivalent sum of binary variables.
  298.48 +*
  298.49 +*  RETURNS
  298.50 +*
  298.51 +*  The routine returns the number of integer variables for which the
  298.52 +*  transformation failed, because u[q] - l[q] > d_max.
  298.53 +*
  298.54 +*  PROBLEM TRANSFORMATION
  298.55 +*
  298.56 +*  If variable x[q] has non-zero lower bound, it is first processed
  298.57 +*  with the routine npp_lbnd_col. Thus, we can assume that:
  298.58 +*
  298.59 +*     0 <= x[q] <= u[q].                                             (2)
  298.60 +*
  298.61 +*  If u[q] = 1, variable x[q] is already binary, so further processing
  298.62 +*  is not needed. Let, therefore, that 2 <= u[q] <= d_max, and n be a
  298.63 +*  smallest integer such that u[q] <= 2^n - 1 (n >= 2, since u[q] >= 2).
  298.64 +*  Then variable x[q] can be replaced by the following sum:
  298.65 +*
  298.66 +*            n-1
  298.67 +*     x[q] = sum 2^k x[k],                                           (3)
  298.68 +*            k=0
  298.69 +*
  298.70 +*  where x[k] are binary columns (variables). If u[q] < 2^n - 1, the
  298.71 +*  following additional inequality constraint must be also included in
  298.72 +*  the transformed problem:
  298.73 +*
  298.74 +*     n-1
  298.75 +*     sum 2^k x[k] <= u[q].                                          (4)
  298.76 +*     k=0
  298.77 +*
  298.78 +*  Note: Assuming that in the transformed problem x[q] becomes binary
  298.79 +*  variable x[0], this transformation causes new n-1 binary variables
  298.80 +*  to appear.
  298.81 +*
  298.82 +*  Substituting x[q] from (3) to the objective row gives:
  298.83 +*
  298.84 +*     z = sum c[j] x[j] + c[0] =
  298.85 +*          j
  298.86 +*
  298.87 +*       = sum c[j] x[j] + c[q] x[q] + c[0] =
  298.88 +*         j!=q
  298.89 +*                              n-1
  298.90 +*       = sum c[j] x[j] + c[q] sum 2^k x[k] + c[0] =
  298.91 +*         j!=q                 k=0
  298.92 +*                         n-1
  298.93 +*       = sum c[j] x[j] + sum c[k] x[k] + c[0],
  298.94 +*         j!=q            k=0
  298.95 +*
  298.96 +*  where:
  298.97 +*
  298.98 +*     c[k] = 2^k c[q],  k = 0, ..., n-1.                             (5)
  298.99 +*
 298.100 +*  And substituting x[q] from (3) to i-th constraint row i gives:
 298.101 +*
 298.102 +*     L[i] <= sum a[i,j] x[j] <= U[i]  ==>
 298.103 +*              j
 298.104 +*
 298.105 +*     L[i] <= sum a[i,j] x[j] + a[i,q] x[q] <= U[i]  ==>
 298.106 +*             j!=q
 298.107 +*                                      n-1
 298.108 +*     L[i] <= sum a[i,j] x[j] + a[i,q] sum 2^k x[k] <= U[i]  ==>
 298.109 +*             j!=q                     k=0
 298.110 +*                               n-1
 298.111 +*     L[i] <= sum a[i,j] x[j] + sum a[i,k] x[k] <= U[i],
 298.112 +*             j!=q              k=0
 298.113 +*
 298.114 +*  where:
 298.115 +*
 298.116 +*     a[i,k] = 2^k a[i,q],  k = 0, ..., n-1.                         (6)
 298.117 +*
 298.118 +*  RECOVERING SOLUTION
 298.119 +*
 298.120 +*  Value of variable x[q] is computed with formula (3). */
 298.121 +
 298.122 +struct binarize
 298.123 +{     int q;
 298.124 +      /* column reference number for x[q] = x[0] */
 298.125 +      int j;
 298.126 +      /* column reference number for x[1]; x[2] has reference number
 298.127 +         j+1, x[3] - j+2, etc. */
 298.128 +      int n;
 298.129 +      /* total number of binary variables, n >= 2 */
 298.130 +};
 298.131 +
 298.132 +static int rcv_binarize_prob(NPP *npp, void *info);
 298.133 +
 298.134 +int npp_binarize_prob(NPP *npp)
 298.135 +{     /* binarize MIP problem */
 298.136 +      struct binarize *info;
 298.137 +      NPPROW *row;
 298.138 +      NPPCOL *col, *bin;
 298.139 +      NPPAIJ *aij;
 298.140 +      int u, n, k, temp, nfails, nvars, nbins, nrows;
 298.141 +      /* new variables will be added to the end of the column list, so
 298.142 +         we go from the end to beginning of the column list */
 298.143 +      nfails = nvars = nbins = nrows = 0;
 298.144 +      for (col = npp->c_tail; col != NULL; col = col->prev)
 298.145 +      {  /* skip continuous variable */
 298.146 +         if (!col->is_int) continue;
 298.147 +         /* skip fixed variable */
 298.148 +         if (col->lb == col->ub) continue;
 298.149 +         /* skip binary variable */
 298.150 +         if (col->lb == 0.0 && col->ub == 1.0) continue;
 298.151 +         /* check if the transformation is applicable */
 298.152 +         if (col->lb < -1e6 || col->ub > +1e6 ||
 298.153 +             col->ub - col->lb > 4095.0)
 298.154 +         {  /* unfortunately, not */
 298.155 +            nfails++;
 298.156 +            continue;
 298.157 +         }
 298.158 +         /* process integer non-binary variable x[q] */
 298.159 +         nvars++;
 298.160 +         /* make x[q] non-negative, if its lower bound is non-zero */
 298.161 +         if (col->lb != 0.0)
 298.162 +            npp_lbnd_col(npp, col);
 298.163 +         /* now 0 <= x[q] <= u[q] */
 298.164 +         xassert(col->lb == 0.0);
 298.165 +         u = (int)col->ub;
 298.166 +         xassert(col->ub == (double)u);
 298.167 +         /* if x[q] is binary, further processing is not needed */
 298.168 +         if (u == 1) continue;
 298.169 +         /* determine smallest n such that u <= 2^n - 1 (thus, n is the
 298.170 +            number of binary variables needed) */
 298.171 +         n = 2, temp = 4;
 298.172 +         while (u >= temp)
 298.173 +            n++, temp += temp;
 298.174 +         nbins += n;
 298.175 +         /* create transformation stack entry */
 298.176 +         info = npp_push_tse(npp,
 298.177 +            rcv_binarize_prob, sizeof(struct binarize));
 298.178 +         info->q = col->j;
 298.179 +         info->j = 0; /* will be set below */
 298.180 +         info->n = n;
 298.181 +         /* if u < 2^n - 1, we need one additional row for (4) */
 298.182 +         if (u < temp - 1)
 298.183 +         {  row = npp_add_row(npp), nrows++;
 298.184 +            row->lb = -DBL_MAX, row->ub = u;
 298.185 +         }
 298.186 +         else
 298.187 +            row = NULL;
 298.188 +         /* in the transformed problem variable x[q] becomes binary
 298.189 +            variable x[0], so its objective and constraint coefficients
 298.190 +            are not changed */
 298.191 +         col->ub = 1.0;
 298.192 +         /* include x[0] into constraint (4) */
 298.193 +         if (row != NULL)
 298.194 +            npp_add_aij(npp, row, col, 1.0);
 298.195 +         /* add other binary variables x[1], ..., x[n-1] */
 298.196 +         for (k = 1, temp = 2; k < n; k++, temp += temp)
 298.197 +         {  /* add new binary variable x[k] */
 298.198 +            bin = npp_add_col(npp);
 298.199 +            bin->is_int = 1;
 298.200 +            bin->lb = 0.0, bin->ub = 1.0;
 298.201 +            bin->coef = (double)temp * col->coef;
 298.202 +            /* store column reference number for x[1] */
 298.203 +            if (info->j == 0)
 298.204 +               info->j = bin->j;
 298.205 +            else
 298.206 +               xassert(info->j + (k-1) == bin->j);
 298.207 +            /* duplicate constraint coefficients for x[k]; this also
 298.208 +               automatically includes x[k] into constraint (4) */
 298.209 +            for (aij = col->ptr; aij != NULL; aij = aij->c_next)
 298.210 +               npp_add_aij(npp, aij->row, bin, (double)temp * aij->val);
 298.211 +         }
 298.212 +      }
 298.213 +      if (nvars > 0)
 298.214 +         xprintf("%d integer variable(s) were replaced by %d binary one"
 298.215 +            "s\n", nvars, nbins);
 298.216 +      if (nrows > 0)
 298.217 +         xprintf("%d row(s) were added due to binarization\n", nrows);
 298.218 +      if (nfails > 0)
 298.219 +         xprintf("Binarization failed for %d integer variable(s)\n",
 298.220 +            nfails);
 298.221 +      return nfails;
 298.222 +}
 298.223 +
 298.224 +static int rcv_binarize_prob(NPP *npp, void *_info)
 298.225 +{     /* recovery binarized variable */
 298.226 +      struct binarize *info = _info;
 298.227 +      int k, temp;
 298.228 +      double sum;
 298.229 +      /* compute value of x[q]; see formula (3) */
 298.230 +      sum = npp->c_value[info->q];
 298.231 +      for (k = 1, temp = 2; k < info->n; k++, temp += temp)
 298.232 +         sum += (double)temp * npp->c_value[info->j + (k-1)];
 298.233 +      npp->c_value[info->q] = sum;
 298.234 +      return 0;
 298.235 +}
 298.236 +
 298.237 +/**********************************************************************/
 298.238 +
 298.239 +struct elem
 298.240 +{     /* linear form element a[j] x[j] */
 298.241 +      double aj;
 298.242 +      /* non-zero coefficient value */
 298.243 +      NPPCOL *xj;
 298.244 +      /* pointer to variable (column) */
 298.245 +      struct elem *next;
 298.246 +      /* pointer to another term */
 298.247 +};
 298.248 +
 298.249 +static struct elem *copy_form(NPP *npp, NPPROW *row, double s)
 298.250 +{     /* copy linear form */
 298.251 +      NPPAIJ *aij;
 298.252 +      struct elem *ptr, *e;
 298.253 +      ptr = NULL;
 298.254 +      for (aij = row->ptr; aij != NULL; aij = aij->r_next)
 298.255 +      {  e = dmp_get_atom(npp->pool, sizeof(struct elem));
 298.256 +         e->aj = s * aij->val;
 298.257 +         e->xj = aij->col;
 298.258 +         e->next = ptr;
 298.259 +         ptr = e;
 298.260 +      }
 298.261 +      return ptr;
 298.262 +}
 298.263 +
 298.264 +static void drop_form(NPP *npp, struct elem *ptr)
 298.265 +{     /* drop linear form */
 298.266 +      struct elem *e;
 298.267 +      while (ptr != NULL)
 298.268 +      {  e = ptr;
 298.269 +         ptr = e->next;
 298.270 +         dmp_free_atom(npp->pool, e, sizeof(struct elem));
 298.271 +      }
 298.272 +      return;
 298.273 +}
 298.274 +
 298.275 +/***********************************************************************
 298.276 +*  NAME
 298.277 +*
 298.278 +*  npp_is_packing - test if constraint is packing inequality
 298.279 +*
 298.280 +*  SYNOPSIS
 298.281 +*
 298.282 +*  #include "glpnpp.h"
 298.283 +*  int npp_is_packing(NPP *npp, NPPROW *row);
 298.284 +*
 298.285 +*  RETURNS
 298.286 +*
 298.287 +*  If the specified row (constraint) is packing inequality (see below),
 298.288 +*  the routine npp_is_packing returns non-zero. Otherwise, it returns
 298.289 +*  zero.
 298.290 +*
 298.291 +*  PACKING INEQUALITIES
 298.292 +*
 298.293 +*  In canonical format the packing inequality is the following:
 298.294 +*
 298.295 +*     sum  x[j] <= 1,                                                (1)
 298.296 +*    j in J
 298.297 +*
 298.298 +*  where all variables x[j] are binary. This inequality expresses the
 298.299 +*  condition that in any integer feasible solution at most one variable
 298.300 +*  from set J can take non-zero (unity) value while other variables
 298.301 +*  must be equal to zero. W.l.o.g. it is assumed that |J| >= 2, because
 298.302 +*  if J is empty or |J| = 1, the inequality (1) is redundant.
 298.303 +*
 298.304 +*  In general case the packing inequality may include original variables
 298.305 +*  x[j] as well as their complements x~[j]:
 298.306 +*
 298.307 +*     sum   x[j] + sum   x~[j] <= 1,                                 (2)
 298.308 +*    j in Jp      j in Jn
 298.309 +*
 298.310 +*  where Jp and Jn are not intersected. Therefore, using substitution
 298.311 +*  x~[j] = 1 - x[j] gives the packing inequality in generalized format:
 298.312 +*
 298.313 +*     sum   x[j] - sum   x[j] <= 1 - |Jn|.                           (3)
 298.314 +*    j in Jp      j in Jn */
 298.315 +
 298.316 +int npp_is_packing(NPP *npp, NPPROW *row)
 298.317 +{     /* test if constraint is packing inequality */
 298.318 +      NPPCOL *col;
 298.319 +      NPPAIJ *aij;
 298.320 +      int b;
 298.321 +      xassert(npp == npp);
 298.322 +      if (!(row->lb == -DBL_MAX && row->ub != +DBL_MAX))
 298.323 +         return 0;
 298.324 +      b = 1;
 298.325 +      for (aij = row->ptr; aij != NULL; aij = aij->r_next)
 298.326 +      {  col = aij->col;
 298.327 +         if (!(col->is_int && col->lb == 0.0 && col->ub == 1.0))
 298.328 +            return 0;
 298.329 +         if (aij->val == +1.0)
 298.330 +            ;
 298.331 +         else if (aij->val == -1.0)
 298.332 +            b--;
 298.333 +         else
 298.334 +            return 0;
 298.335 +      }
 298.336 +      if (row->ub != (double)b) return 0;
 298.337 +      return 1;
 298.338 +}
 298.339 +
 298.340 +/***********************************************************************
 298.341 +*  NAME
 298.342 +*
 298.343 +*  npp_hidden_packing - identify hidden packing inequality
 298.344 +*
 298.345 +*  SYNOPSIS
 298.346 +*
 298.347 +*  #include "glpnpp.h"
 298.348 +*  int npp_hidden_packing(NPP *npp, NPPROW *row);
 298.349 +*
 298.350 +*  DESCRIPTION
 298.351 +*
 298.352 +*  The routine npp_hidden_packing processes specified inequality
 298.353 +*  constraint, which includes only binary variables, and the number of
 298.354 +*  the variables is not less than two. If the original inequality is
 298.355 +*  equivalent to a packing inequality, the routine replaces it by this
 298.356 +*  equivalent inequality. If the original constraint is double-sided
 298.357 +*  inequality, it is replaced by a pair of single-sided inequalities,
 298.358 +*  if necessary.
 298.359 +*
 298.360 +*  RETURNS
 298.361 +*
 298.362 +*  If the original inequality constraint was replaced by equivalent
 298.363 +*  packing inequality, the routine npp_hidden_packing returns non-zero.
 298.364 +*  Otherwise, it returns zero.
 298.365 +*
 298.366 +*  PROBLEM TRANSFORMATION
 298.367 +*
 298.368 +*  Consider an inequality constraint:
 298.369 +*
 298.370 +*     sum  a[j] x[j] <= b,                                           (1)
 298.371 +*    j in J
 298.372 +*
 298.373 +*  where all variables x[j] are binary, and |J| >= 2. (In case of '>='
 298.374 +*  inequality it can be transformed to '<=' format by multiplying both
 298.375 +*  its sides by -1.)
 298.376 +*
 298.377 +*  Let Jp = {j: a[j] > 0}, Jn = {j: a[j] < 0}. Performing substitution
 298.378 +*  x[j] = 1 - x~[j] for all j in Jn, we have:
 298.379 +*
 298.380 +*     sum   a[j] x[j] <= b  ==>
 298.381 +*    j in J
 298.382 +*
 298.383 +*     sum   a[j] x[j] + sum   a[j] x[j] <= b  ==>
 298.384 +*    j in Jp           j in Jn
 298.385 +*
 298.386 +*     sum   a[j] x[j] + sum   a[j] (1 - x~[j]) <= b  ==>
 298.387 +*    j in Jp           j in Jn
 298.388 +*
 298.389 +*     sum   a[j] x[j] - sum   a[j] x~[j] <= b - sum   a[j].
 298.390 +*    j in Jp           j in Jn                 j in Jn
 298.391 +*
 298.392 +*  Thus, meaning the transformation above, we can assume that in
 298.393 +*  inequality (1) all coefficients a[j] are positive. Moreover, we can
 298.394 +*  assume that a[j] <= b. In fact, let a[j] > b; then the following
 298.395 +*  three cases are possible:
 298.396 +*
 298.397 +*  1) b < 0. In this case inequality (1) is infeasible, so the problem
 298.398 +*     has no feasible solution (see the routine npp_analyze_row);
 298.399 +*
 298.400 +*  2) b = 0. In this case inequality (1) is a forcing inequality on its
 298.401 +*     upper bound (see the routine npp_forcing row), from which it
 298.402 +*     follows that all variables x[j] should be fixed at zero;
 298.403 +*
 298.404 +*  3) b > 0. In this case inequality (1) defines an implied zero upper
 298.405 +*     bound for variable x[j] (see the routine npp_implied_bounds), from
 298.406 +*     which it follows that x[j] should be fixed at zero.
 298.407 +*
 298.408 +*  It is assumed that all three cases listed above have been recognized
 298.409 +*  by the routine npp_process_prob, which performs basic MIP processing
 298.410 +*  prior to a call the routine npp_hidden_packing. So, if one of these
 298.411 +*  cases occurs, we should just skip processing such constraint.
 298.412 +*
 298.413 +*  Thus, let 0 < a[j] <= b. Then it is obvious that constraint (1) is
 298.414 +*  equivalent to packing inquality only if:
 298.415 +*
 298.416 +*     a[j] + a[k] > b + eps                                          (2)
 298.417 +*
 298.418 +*  for all j, k in J, j != k, where eps is an absolute tolerance for
 298.419 +*  row (linear form) value. Checking the condition (2) for all j and k,
 298.420 +*  j != k, requires time O(|J|^2). However, this time can be reduced to
 298.421 +*  O(|J|), if use minimal a[j] and a[k], in which case it is sufficient
 298.422 +*  to check the condition (2) only once.
 298.423 +*
 298.424 +*  Once the original inequality (1) is replaced by equivalent packing
 298.425 +*  inequality, we need to perform back substitution x~[j] = 1 - x[j] for
 298.426 +*  all j in Jn (see above).
 298.427 +*
 298.428 +*  RECOVERING SOLUTION
 298.429 +*
 298.430 +*  None needed. */
 298.431 +
 298.432 +static int hidden_packing(NPP *npp, struct elem *ptr, double *_b)
 298.433 +{     /* process inequality constraint: sum a[j] x[j] <= b;
 298.434 +         0 - specified row is NOT hidden packing inequality;
 298.435 +         1 - specified row is packing inequality;
 298.436 +         2 - specified row is hidden packing inequality. */
 298.437 +      struct elem *e, *ej, *ek;
 298.438 +      int neg;
 298.439 +      double b = *_b, eps;
 298.440 +      xassert(npp == npp);
 298.441 +      /* a[j] must be non-zero, x[j] must be binary, for all j in J */
 298.442 +      for (e = ptr; e != NULL; e = e->next)
 298.443 +      {  xassert(e->aj != 0.0);
 298.444 +         xassert(e->xj->is_int);
 298.445 +         xassert(e->xj->lb == 0.0 && e->xj->ub == 1.0);
 298.446 +      }
 298.447 +      /* check if the specified inequality constraint already has the
 298.448 +         form of packing inequality */
 298.449 +      neg = 0; /* neg is |Jn| */
 298.450 +      for (e = ptr; e != NULL; e = e->next)
 298.451 +      {  if (e->aj == +1.0)
 298.452 +            ;
 298.453 +         else if (e->aj == -1.0)
 298.454 +            neg++;
 298.455 +         else
 298.456 +            break;
 298.457 +      }
 298.458 +      if (e == NULL)
 298.459 +      {  /* all coefficients a[j] are +1 or -1; check rhs b */
 298.460 +         if (b == (double)(1 - neg))
 298.461 +         {  /* it is packing inequality; no processing is needed */
 298.462 +            return 1;
 298.463 +         }
 298.464 +      }
 298.465 +      /* substitute x[j] = 1 - x~[j] for all j in Jn to make all a[j]
 298.466 +         positive; the result is a~[j] = |a[j]| and new rhs b */
 298.467 +      for (e = ptr; e != NULL; e = e->next)
 298.468 +         if (e->aj < 0) b -= e->aj;
 298.469 +      /* now a[j] > 0 for all j in J (actually |a[j]| are used) */
 298.470 +      /* if a[j] > b, skip processing--this case must not appear */
 298.471 +      for (e = ptr; e != NULL; e = e->next)
 298.472 +         if (fabs(e->aj) > b) return 0;
 298.473 +      /* now 0 < a[j] <= b for all j in J */
 298.474 +      /* find two minimal coefficients a[j] and a[k], j != k */
 298.475 +      ej = NULL;
 298.476 +      for (e = ptr; e != NULL; e = e->next)
 298.477 +         if (ej == NULL || fabs(ej->aj) > fabs(e->aj)) ej = e;
 298.478 +      xassert(ej != NULL);
 298.479 +      ek = NULL;
 298.480 +      for (e = ptr; e != NULL; e = e->next)
 298.481 +         if (e != ej)
 298.482 +            if (ek == NULL || fabs(ek->aj) > fabs(e->aj)) ek = e;
 298.483 +      xassert(ek != NULL);
 298.484 +      /* the specified constraint is equivalent to packing inequality
 298.485 +         iff a[j] + a[k] > b + eps */
 298.486 +      eps = 1e-3 + 1e-6 * fabs(b);
 298.487 +      if (fabs(ej->aj) + fabs(ek->aj) <= b + eps) return 0;
 298.488 +      /* perform back substitution x~[j] = 1 - x[j] and construct the
 298.489 +         final equivalent packing inequality in generalized format */
 298.490 +      b = 1.0;
 298.491 +      for (e = ptr; e != NULL; e = e->next)
 298.492 +      {  if (e->aj > 0.0)
 298.493 +            e->aj = +1.0;
 298.494 +         else /* e->aj < 0.0 */
 298.495 +            e->aj = -1.0, b -= 1.0;
 298.496 +      }
 298.497 +      *_b = b;
 298.498 +      return 2;
 298.499 +}
 298.500 +
 298.501 +int npp_hidden_packing(NPP *npp, NPPROW *row)
 298.502 +{     /* identify hidden packing inequality */
 298.503 +      NPPROW *copy;
 298.504 +      NPPAIJ *aij;
 298.505 +      struct elem *ptr, *e;
 298.506 +      int kase, ret, count = 0;
 298.507 +      double b;
 298.508 +      /* the row must be inequality constraint */
 298.509 +      xassert(row->lb < row->ub);
 298.510 +      for (kase = 0; kase <= 1; kase++)
 298.511 +      {  if (kase == 0)
 298.512 +         {  /* process row upper bound */
 298.513 +            if (row->ub == +DBL_MAX) continue;
 298.514 +            ptr = copy_form(npp, row, +1.0);
 298.515 +            b = + row->ub;
 298.516 +         }
 298.517 +         else
 298.518 +         {  /* process row lower bound */
 298.519 +            if (row->lb == -DBL_MAX) continue;
 298.520 +            ptr = copy_form(npp, row, -1.0);
 298.521 +            b = - row->lb;
 298.522 +         }
 298.523 +         /* now the inequality has the form "sum a[j] x[j] <= b" */
 298.524 +         ret = hidden_packing(npp, ptr, &b);
 298.525 +         xassert(0 <= ret && ret <= 2);
 298.526 +         if (kase == 1 && ret == 1 || ret == 2)
 298.527 +         {  /* the original inequality has been identified as hidden
 298.528 +               packing inequality */
 298.529 +            count++;
 298.530 +#ifdef GLP_DEBUG
 298.531 +            xprintf("Original constraint:\n");
 298.532 +            for (aij = row->ptr; aij != NULL; aij = aij->r_next)
 298.533 +               xprintf(" %+g x%d", aij->val, aij->col->j);
 298.534 +            if (row->lb != -DBL_MAX) xprintf(", >= %g", row->lb);
 298.535 +            if (row->ub != +DBL_MAX) xprintf(", <= %g", row->ub);
 298.536 +            xprintf("\n");
 298.537 +            xprintf("Equivalent packing inequality:\n");
 298.538 +            for (e = ptr; e != NULL; e = e->next)
 298.539 +               xprintf(" %sx%d", e->aj > 0.0 ? "+" : "-", e->xj->j);
 298.540 +            xprintf(", <= %g\n", b);
 298.541 +#endif
 298.542 +            if (row->lb == -DBL_MAX || row->ub == +DBL_MAX)
 298.543 +            {  /* the original row is single-sided inequality; no copy
 298.544 +                  is needed */
 298.545 +               copy = NULL;
 298.546 +            }
 298.547 +            else
 298.548 +            {  /* the original row is double-sided inequality; we need
 298.549 +                  to create its copy for other bound before replacing it
 298.550 +                  with the equivalent inequality */
 298.551 +               copy = npp_add_row(npp);
 298.552 +               if (kase == 0)
 298.553 +               {  /* the copy is for lower bound */
 298.554 +                  copy->lb = row->lb, copy->ub = +DBL_MAX;
 298.555 +               }
 298.556 +               else
 298.557 +               {  /* the copy is for upper bound */
 298.558 +                  copy->lb = -DBL_MAX, copy->ub = row->ub;
 298.559 +               }
 298.560 +               /* copy original row coefficients */
 298.561 +               for (aij = row->ptr; aij != NULL; aij = aij->r_next)
 298.562 +                  npp_add_aij(npp, copy, aij->col, aij->val);
 298.563 +            }
 298.564 +            /* replace the original inequality by equivalent one */
 298.565 +            npp_erase_row(npp, row);
 298.566 +            row->lb = -DBL_MAX, row->ub = b;
 298.567 +            for (e = ptr; e != NULL; e = e->next)
 298.568 +               npp_add_aij(npp, row, e->xj, e->aj);
 298.569 +            /* continue processing lower bound for the copy */
 298.570 +            if (copy != NULL) row = copy;
 298.571 +         }
 298.572 +         drop_form(npp, ptr);
 298.573 +      }
 298.574 +      return count;
 298.575 +}
 298.576 +
 298.577 +/***********************************************************************
 298.578 +*  NAME
 298.579 +*
 298.580 +*  npp_implied_packing - identify implied packing inequality
 298.581 +*
 298.582 +*  SYNOPSIS
 298.583 +*
 298.584 +*  #include "glpnpp.h"
 298.585 +*  int npp_implied_packing(NPP *npp, NPPROW *row, int which,
 298.586 +*     NPPCOL *var[], char set[]);
 298.587 +*
 298.588 +*  DESCRIPTION
 298.589 +*
 298.590 +*  The routine npp_implied_packing processes specified row (constraint)
 298.591 +*  of general format:
 298.592 +*
 298.593 +*     L <= sum a[j] x[j] <= U.                                       (1)
 298.594 +*           j
 298.595 +*
 298.596 +*  If which = 0, only lower bound L, which must exist, is considered,
 298.597 +*  while upper bound U is ignored. Similarly, if which = 1, only upper
 298.598 +*  bound U, which must exist, is considered, while lower bound L is
 298.599 +*  ignored. Thus, if the specified row is a double-sided inequality or
 298.600 +*  equality constraint, this routine should be called twice for both
 298.601 +*  lower and upper bounds.
 298.602 +*
 298.603 +*  The routine npp_implied_packing attempts to find a non-trivial (i.e.
 298.604 +*  having not less than two binary variables) packing inequality:
 298.605 +*
 298.606 +*     sum   x[j] - sum   x[j] <= 1 - |Jn|,                           (2)
 298.607 +*    j in Jp      j in Jn
 298.608 +*
 298.609 +*  which is relaxation of the constraint (1) in the sense that any
 298.610 +*  solution satisfying to that constraint also satisfies to the packing
 298.611 +*  inequality (2). If such relaxation exists, the routine stores
 298.612 +*  pointers to descriptors of corresponding binary variables and their
 298.613 +*  flags, resp., to locations var[1], var[2], ..., var[len] and set[1],
 298.614 +*  set[2], ..., set[len], where set[j] = 0 means that j in Jp and
 298.615 +*  set[j] = 1 means that j in Jn.
 298.616 +*
 298.617 +*  RETURNS
 298.618 +*
 298.619 +*  The routine npp_implied_packing returns len, which is the total
 298.620 +*  number of binary variables in the packing inequality found, len >= 2.
 298.621 +*  However, if the relaxation does not exist, the routine returns zero.
 298.622 +*
 298.623 +*  ALGORITHM
 298.624 +*
 298.625 +*  If which = 0, the constraint coefficients (1) are multiplied by -1
 298.626 +*  and b is assigned -L; if which = 1, the constraint coefficients (1)
 298.627 +*  are not changed and b is assigned +U. In both cases the specified
 298.628 +*  constraint gets the following format:
 298.629 +*
 298.630 +*     sum a[j] x[j] <= b.                                            (3)
 298.631 +*      j
 298.632 +*
 298.633 +*  (Note that (3) is a relaxation of (1), because one of bounds L or U
 298.634 +*  is ignored.)
 298.635 +*
 298.636 +*  Let J be set of binary variables, Kp be set of non-binary (integer
 298.637 +*  or continuous) variables with a[j] > 0, and Kn be set of non-binary
 298.638 +*  variables with a[j] < 0. Then the inequality (3) can be written as
 298.639 +*  follows:
 298.640 +*
 298.641 +*     sum  a[j] x[j] <= b - sum   a[j] x[j] - sum   a[j] x[j].       (4)
 298.642 +*    j in J                j in Kp           j in Kn
 298.643 +*
 298.644 +*  To get rid of non-binary variables we can replace the inequality (4)
 298.645 +*  by the following relaxed inequality:
 298.646 +*
 298.647 +*     sum  a[j] x[j] <= b~,                                          (5)
 298.648 +*    j in J
 298.649 +*
 298.650 +*  where:
 298.651 +*
 298.652 +*     b~ = sup(b - sum   a[j] x[j] - sum   a[j] x[j]) =
 298.653 +*                 j in Kp           j in Kn
 298.654 +*
 298.655 +*        = b - inf sum   a[j] x[j] - inf sum   a[j] x[j] =           (6)
 298.656 +*                 j in Kp               j in Kn
 298.657 +*
 298.658 +*        = b - sum   a[j] l[j] - sum   a[j] u[j].
 298.659 +*             j in Kp           j in Kn
 298.660 +*
 298.661 +*  Note that if lower bound l[j] (if j in Kp) or upper bound u[j]
 298.662 +*  (if j in Kn) of some non-binary variable x[j] does not exist, then
 298.663 +*  formally b = +oo, in which case further analysis is not performed.
 298.664 +*
 298.665 +*  Let Bp = {j in J: a[j] > 0}, Bn = {j in J: a[j] < 0}. To make all
 298.666 +*  the inequality coefficients in (5) positive, we replace all x[j] in
 298.667 +*  Bn by their complementaries, substituting x[j] = 1 - x~[j] for all
 298.668 +*  j in Bn, that gives:
 298.669 +*
 298.670 +*     sum   a[j] x[j] - sum   a[j] x~[j] <= b~ - sum   a[j].         (7)
 298.671 +*    j in Bp           j in Bn                  j in Bn
 298.672 +*
 298.673 +*  This inequality is a relaxation of the original constraint (1), and
 298.674 +*  it is a binary knapsack inequality. Writing it in the standard format
 298.675 +*  we have:
 298.676 +*
 298.677 +*     sum  alfa[j] z[j] <= beta,                                     (8)
 298.678 +*    j in J
 298.679 +*
 298.680 +*  where:
 298.681 +*               ( + a[j],   if j in Bp,
 298.682 +*     alfa[j] = <                                                    (9)
 298.683 +*               ( - a[j],   if j in Bn,
 298.684 +*
 298.685 +*               ( x[j],     if j in Bp,
 298.686 +*        z[j] = <                                                   (10)
 298.687 +*               ( 1 - x[j], if j in Bn,
 298.688 +*
 298.689 +*        beta = b~ - sum   a[j].                                    (11)
 298.690 +*                   j in Bn
 298.691 +*
 298.692 +*  In the inequality (8) all coefficients are positive, therefore, the
 298.693 +*  packing relaxation to be found for this inequality is the following:
 298.694 +*
 298.695 +*     sum  z[j] <= 1.                                               (12)
 298.696 +*    j in P
 298.697 +*
 298.698 +*  It is obvious that set P within J, which we would like to find, must
 298.699 +*  satisfy to the following condition:
 298.700 +*
 298.701 +*     alfa[j] + alfa[k] > beta + eps  for all j, k in P, j != k,    (13)
 298.702 +*
 298.703 +*  where eps is an absolute tolerance for value of the linear form.
 298.704 +*  Thus, it is natural to take P = {j: alpha[j] > (beta + eps) / 2}.
 298.705 +*  Moreover, if in the equality (8) there exist coefficients alfa[k],
 298.706 +*  for which alfa[k] <= (beta + eps) / 2, but which, nevertheless,
 298.707 +*  satisfies to the condition (13) for all j in P, *one* corresponding
 298.708 +*  variable z[k] (having, for example, maximal coefficient alfa[k]) can
 298.709 +*  be included in set P, that allows increasing the number of binary
 298.710 +*  variables in (12) by one.
 298.711 +*
 298.712 +*  Once the set P has been built, for the inequality (12) we need to
 298.713 +*  perform back substitution according to (10) in order to express it
 298.714 +*  through the original binary variables. As the result of such back
 298.715 +*  substitution the relaxed packing inequality get its final format (2),
 298.716 +*  where Jp = J intersect Bp, and Jn = J intersect Bn. */
 298.717 +
 298.718 +int npp_implied_packing(NPP *npp, NPPROW *row, int which,
 298.719 +      NPPCOL *var[], char set[])
 298.720 +{     struct elem *ptr, *e, *i, *k;
 298.721 +      int len = 0;
 298.722 +      double b, eps;
 298.723 +      /* build inequality (3) */
 298.724 +      if (which == 0)
 298.725 +      {  ptr = copy_form(npp, row, -1.0);
 298.726 +         xassert(row->lb != -DBL_MAX);
 298.727 +         b = - row->lb;
 298.728 +      }
 298.729 +      else if (which == 1)
 298.730 +      {  ptr = copy_form(npp, row, +1.0);
 298.731 +         xassert(row->ub != +DBL_MAX);
 298.732 +         b = + row->ub;
 298.733 +      }
 298.734 +      /* remove non-binary variables to build relaxed inequality (5);
 298.735 +         compute its right-hand side b~ with formula (6) */
 298.736 +      for (e = ptr; e != NULL; e = e->next)
 298.737 +      {  if (!(e->xj->is_int && e->xj->lb == 0.0 && e->xj->ub == 1.0))
 298.738 +         {  /* x[j] is non-binary variable */
 298.739 +            if (e->aj > 0.0)
 298.740 +            {  if (e->xj->lb == -DBL_MAX) goto done;
 298.741 +               b -= e->aj * e->xj->lb;
 298.742 +            }
 298.743 +            else /* e->aj < 0.0 */
 298.744 +            {  if (e->xj->ub == +DBL_MAX) goto done;
 298.745 +               b -= e->aj * e->xj->ub;
 298.746 +            }
 298.747 +            /* a[j] = 0 means that variable x[j] is removed */
 298.748 +            e->aj = 0.0;
 298.749 +         }
 298.750 +      }
 298.751 +      /* substitute x[j] = 1 - x~[j] to build knapsack inequality (8);
 298.752 +         compute its right-hand side beta with formula (11) */
 298.753 +      for (e = ptr; e != NULL; e = e->next)
 298.754 +         if (e->aj < 0.0) b -= e->aj;
 298.755 +      /* if beta is close to zero, the knapsack inequality is either
 298.756 +         infeasible or forcing inequality; this must never happen, so
 298.757 +         we skip further analysis */
 298.758 +      if (b < 1e-3) goto done;
 298.759 +      /* build set P as well as sets Jp and Jn, and determine x[k] as
 298.760 +         explained above in comments to the routine */
 298.761 +      eps = 1e-3 + 1e-6 * b;
 298.762 +      i = k = NULL;
 298.763 +      for (e = ptr; e != NULL; e = e->next)
 298.764 +      {  /* note that alfa[j] = |a[j]| */
 298.765 +         if (fabs(e->aj) > 0.5 * (b + eps))
 298.766 +         {  /* alfa[j] > (b + eps) / 2; include x[j] in set P, i.e. in
 298.767 +               set Jp or Jn */
 298.768 +            var[++len] = e->xj;
 298.769 +            set[len] = (char)(e->aj > 0.0 ? 0 : 1);
 298.770 +            /* alfa[i] = min alfa[j] over all j included in set P */
 298.771 +            if (i == NULL || fabs(i->aj) > fabs(e->aj)) i = e;
 298.772 +         }
 298.773 +         else if (fabs(e->aj) >= 1e-3)
 298.774 +         {  /* alfa[k] = max alfa[j] over all j not included in set P;
 298.775 +               we skip coefficient a[j] if it is close to zero to avoid
 298.776 +               numerically unreliable results */
 298.777 +            if (k == NULL || fabs(k->aj) < fabs(e->aj)) k = e;
 298.778 +         }
 298.779 +      }
 298.780 +      /* if alfa[k] satisfies to condition (13) for all j in P, include
 298.781 +         x[k] in P */
 298.782 +      if (i != NULL && k != NULL && fabs(i->aj) + fabs(k->aj) > b + eps)
 298.783 +      {  var[++len] = k->xj;
 298.784 +         set[len] = (char)(k->aj > 0.0 ? 0 : 1);
 298.785 +      }
 298.786 +      /* trivial packing inequality being redundant must never appear,
 298.787 +         so we just ignore it */
 298.788 +      if (len < 2) len = 0;
 298.789 +done: drop_form(npp, ptr);
 298.790 +      return len;
 298.791 +}
 298.792 +
 298.793 +/***********************************************************************
 298.794 +*  NAME
 298.795 +*
 298.796 +*  npp_is_covering - test if constraint is covering inequality
 298.797 +*
 298.798 +*  SYNOPSIS
 298.799 +*
 298.800 +*  #include "glpnpp.h"
 298.801 +*  int npp_is_covering(NPP *npp, NPPROW *row);
 298.802 +*
 298.803 +*  RETURNS
 298.804 +*
 298.805 +*  If the specified row (constraint) is covering inequality (see below),
 298.806 +*  the routine npp_is_covering returns non-zero. Otherwise, it returns
 298.807 +*  zero.
 298.808 +*
 298.809 +*  COVERING INEQUALITIES
 298.810 +*
 298.811 +*  In canonical format the covering inequality is the following:
 298.812 +*
 298.813 +*     sum  x[j] >= 1,                                                (1)
 298.814 +*    j in J
 298.815 +*
 298.816 +*  where all variables x[j] are binary. This inequality expresses the
 298.817 +*  condition that in any integer feasible solution variables in set J
 298.818 +*  cannot be all equal to zero at the same time, i.e. at least one
 298.819 +*  variable must take non-zero (unity) value. W.l.o.g. it is assumed
 298.820 +*  that |J| >= 2, because if J is empty, the inequality (1) is
 298.821 +*  infeasible, and if |J| = 1, the inequality (1) is a forcing row.
 298.822 +*
 298.823 +*  In general case the covering inequality may include original
 298.824 +*  variables x[j] as well as their complements x~[j]:
 298.825 +*
 298.826 +*     sum   x[j] + sum   x~[j] >= 1,                                 (2)
 298.827 +*    j in Jp      j in Jn
 298.828 +*
 298.829 +*  where Jp and Jn are not intersected. Therefore, using substitution
 298.830 +*  x~[j] = 1 - x[j] gives the packing inequality in generalized format:
 298.831 +*
 298.832 +*     sum   x[j] - sum   x[j] >= 1 - |Jn|.                           (3)
 298.833 +*    j in Jp      j in Jn
 298.834 +*
 298.835 +*  (May note that the inequality (3) cuts off infeasible solutions,
 298.836 +*  where x[j] = 0 for all j in Jp and x[j] = 1 for all j in Jn.)
 298.837 +*
 298.838 +*  NOTE: If |J| = 2, the inequality (3) is equivalent to packing
 298.839 +*        inequality (see the routine npp_is_packing). */
 298.840 +
 298.841 +int npp_is_covering(NPP *npp, NPPROW *row)
 298.842 +{     /* test if constraint is covering inequality */
 298.843 +      NPPCOL *col;
 298.844 +      NPPAIJ *aij;
 298.845 +      int b;
 298.846 +      xassert(npp == npp);
 298.847 +      if (!(row->lb != -DBL_MAX && row->ub == +DBL_MAX))
 298.848 +         return 0;
 298.849 +      b = 1;
 298.850 +      for (aij = row->ptr; aij != NULL; aij = aij->r_next)
 298.851 +      {  col = aij->col;
 298.852 +         if (!(col->is_int && col->lb == 0.0 && col->ub == 1.0))
 298.853 +            return 0;
 298.854 +         if (aij->val == +1.0)
 298.855 +            ;
 298.856 +         else if (aij->val == -1.0)
 298.857 +            b--;
 298.858 +         else
 298.859 +            return 0;
 298.860 +      }
 298.861 +      if (row->lb != (double)b) return 0;
 298.862 +      return 1;
 298.863 +}
 298.864 +
 298.865 +/***********************************************************************
 298.866 +*  NAME
 298.867 +*
 298.868 +*  npp_hidden_covering - identify hidden covering inequality
 298.869 +*
 298.870 +*  SYNOPSIS
 298.871 +*
 298.872 +*  #include "glpnpp.h"
 298.873 +*  int npp_hidden_covering(NPP *npp, NPPROW *row);
 298.874 +*
 298.875 +*  DESCRIPTION
 298.876 +*
 298.877 +*  The routine npp_hidden_covering processes specified inequality
 298.878 +*  constraint, which includes only binary variables, and the number of
 298.879 +*  the variables is not less than three. If the original inequality is
 298.880 +*  equivalent to a covering inequality (see below), the routine
 298.881 +*  replaces it by the equivalent inequality. If the original constraint
 298.882 +*  is double-sided inequality, it is replaced by a pair of single-sided
 298.883 +*  inequalities, if necessary.
 298.884 +*
 298.885 +*  RETURNS
 298.886 +*
 298.887 +*  If the original inequality constraint was replaced by equivalent
 298.888 +*  covering inequality, the routine npp_hidden_covering returns
 298.889 +*  non-zero. Otherwise, it returns zero.
 298.890 +*
 298.891 +*  PROBLEM TRANSFORMATION
 298.892 +*
 298.893 +*  Consider an inequality constraint:
 298.894 +*
 298.895 +*     sum  a[j] x[j] >= b,                                           (1)
 298.896 +*    j in J
 298.897 +*
 298.898 +*  where all variables x[j] are binary, and |J| >= 3. (In case of '<='
 298.899 +*  inequality it can be transformed to '>=' format by multiplying both
 298.900 +*  its sides by -1.)
 298.901 +*
 298.902 +*  Let Jp = {j: a[j] > 0}, Jn = {j: a[j] < 0}. Performing substitution
 298.903 +*  x[j] = 1 - x~[j] for all j in Jn, we have:
 298.904 +*
 298.905 +*     sum   a[j] x[j] >= b  ==>
 298.906 +*    j in J
 298.907 +*
 298.908 +*     sum   a[j] x[j] + sum   a[j] x[j] >= b  ==>
 298.909 +*    j in Jp           j in Jn
 298.910 +*
 298.911 +*     sum   a[j] x[j] + sum   a[j] (1 - x~[j]) >= b  ==>
 298.912 +*    j in Jp           j in Jn
 298.913 +*
 298.914 +*     sum  m   a[j] x[j] - sum   a[j] x~[j] >= b - sum   a[j].
 298.915 +*    j in Jp              j in Jn                 j in Jn
 298.916 +*
 298.917 +*  Thus, meaning the transformation above, we can assume that in
 298.918 +*  inequality (1) all coefficients a[j] are positive. Moreover, we can
 298.919 +*  assume that b > 0, because otherwise the inequality (1) would be
 298.920 +*  redundant (see the routine npp_analyze_row). It is then obvious that
 298.921 +*  constraint (1) is equivalent to covering inequality only if:
 298.922 +*
 298.923 +*     a[j] >= b,                                                     (2)
 298.924 +*
 298.925 +*  for all j in J.
 298.926 +*
 298.927 +*  Once the original inequality (1) is replaced by equivalent covering
 298.928 +*  inequality, we need to perform back substitution x~[j] = 1 - x[j] for
 298.929 +*  all j in Jn (see above).
 298.930 +*
 298.931 +*  RECOVERING SOLUTION
 298.932 +*
 298.933 +*  None needed. */
 298.934 +
 298.935 +static int hidden_covering(NPP *npp, struct elem *ptr, double *_b)
 298.936 +{     /* process inequality constraint: sum a[j] x[j] >= b;
 298.937 +         0 - specified row is NOT hidden covering inequality;
 298.938 +         1 - specified row is covering inequality;
 298.939 +         2 - specified row is hidden covering inequality. */
 298.940 +      struct elem *e;
 298.941 +      int neg;
 298.942 +      double b = *_b, eps;
 298.943 +      xassert(npp == npp);
 298.944 +      /* a[j] must be non-zero, x[j] must be binary, for all j in J */
 298.945 +      for (e = ptr; e != NULL; e = e->next)
 298.946 +      {  xassert(e->aj != 0.0);
 298.947 +         xassert(e->xj->is_int);
 298.948 +         xassert(e->xj->lb == 0.0 && e->xj->ub == 1.0);
 298.949 +      }
 298.950 +      /* check if the specified inequality constraint already has the
 298.951 +         form of covering inequality */
 298.952 +      neg = 0; /* neg is |Jn| */
 298.953 +      for (e = ptr; e != NULL; e = e->next)
 298.954 +      {  if (e->aj == +1.0)
 298.955 +            ;
 298.956 +         else if (e->aj == -1.0)
 298.957 +            neg++;
 298.958 +         else
 298.959 +            break;
 298.960 +      }
 298.961 +      if (e == NULL)
 298.962 +      {  /* all coefficients a[j] are +1 or -1; check rhs b */
 298.963 +         if (b == (double)(1 - neg))
 298.964 +         {  /* it is covering inequality; no processing is needed */
 298.965 +            return 1;
 298.966 +         }
 298.967 +      }
 298.968 +      /* substitute x[j] = 1 - x~[j] for all j in Jn to make all a[j]
 298.969 +         positive; the result is a~[j] = |a[j]| and new rhs b */
 298.970 +      for (e = ptr; e != NULL; e = e->next)
 298.971 +         if (e->aj < 0) b -= e->aj;
 298.972 +      /* now a[j] > 0 for all j in J (actually |a[j]| are used) */
 298.973 +      /* if b <= 0, skip processing--this case must not appear */
 298.974 +      if (b < 1e-3) return 0;
 298.975 +      /* now a[j] > 0 for all j in J, and b > 0 */
 298.976 +      /* the specified constraint is equivalent to covering inequality
 298.977 +         iff a[j] >= b for all j in J */
 298.978 +      eps = 1e-9 + 1e-12 * fabs(b);
 298.979 +      for (e = ptr; e != NULL; e = e->next)
 298.980 +         if (fabs(e->aj) < b - eps) return 0;
 298.981 +      /* perform back substitution x~[j] = 1 - x[j] and construct the
 298.982 +         final equivalent covering inequality in generalized format */
 298.983 +      b = 1.0;
 298.984 +      for (e = ptr; e != NULL; e = e->next)
 298.985 +      {  if (e->aj > 0.0)
 298.986 +            e->aj = +1.0;
 298.987 +         else /* e->aj < 0.0 */
 298.988 +            e->aj = -1.0, b -= 1.0;
 298.989 +      }
 298.990 +      *_b = b;
 298.991 +      return 2;
 298.992 +}
 298.993 +
 298.994 +int npp_hidden_covering(NPP *npp, NPPROW *row)
 298.995 +{     /* identify hidden covering inequality */
 298.996 +      NPPROW *copy;
 298.997 +      NPPAIJ *aij;
 298.998 +      struct elem *ptr, *e;
 298.999 +      int kase, ret, count = 0;
298.1000 +      double b;
298.1001 +      /* the row must be inequality constraint */
298.1002 +      xassert(row->lb < row->ub);
298.1003 +      for (kase = 0; kase <= 1; kase++)
298.1004 +      {  if (kase == 0)
298.1005 +         {  /* process row lower bound */
298.1006 +            if (row->lb == -DBL_MAX) continue;
298.1007 +            ptr = copy_form(npp, row, +1.0);
298.1008 +            b = + row->lb;
298.1009 +         }
298.1010 +         else
298.1011 +         {  /* process row upper bound */
298.1012 +            if (row->ub == +DBL_MAX) continue;
298.1013 +            ptr = copy_form(npp, row, -1.0);
298.1014 +            b = - row->ub;
298.1015 +         }
298.1016 +         /* now the inequality has the form "sum a[j] x[j] >= b" */
298.1017 +         ret = hidden_covering(npp, ptr, &b);
298.1018 +         xassert(0 <= ret && ret <= 2);
298.1019 +         if (kase == 1 && ret == 1 || ret == 2)
298.1020 +         {  /* the original inequality has been identified as hidden
298.1021 +               covering inequality */
298.1022 +            count++;
298.1023 +#ifdef GLP_DEBUG
298.1024 +            xprintf("Original constraint:\n");
298.1025 +            for (aij = row->ptr; aij != NULL; aij = aij->r_next)
298.1026 +               xprintf(" %+g x%d", aij->val, aij->col->j);
298.1027 +            if (row->lb != -DBL_MAX) xprintf(", >= %g", row->lb);
298.1028 +            if (row->ub != +DBL_MAX) xprintf(", <= %g", row->ub);
298.1029 +            xprintf("\n");
298.1030 +            xprintf("Equivalent covering inequality:\n");
298.1031 +            for (e = ptr; e != NULL; e = e->next)
298.1032 +               xprintf(" %sx%d", e->aj > 0.0 ? "+" : "-", e->xj->j);
298.1033 +            xprintf(", >= %g\n", b);
298.1034 +#endif
298.1035 +            if (row->lb == -DBL_MAX || row->ub == +DBL_MAX)
298.1036 +            {  /* the original row is single-sided inequality; no copy
298.1037 +                  is needed */
298.1038 +               copy = NULL;
298.1039 +            }
298.1040 +            else
298.1041 +            {  /* the original row is double-sided inequality; we need
298.1042 +                  to create its copy for other bound before replacing it
298.1043 +                  with the equivalent inequality */
298.1044 +               copy = npp_add_row(npp);
298.1045 +               if (kase == 0)
298.1046 +               {  /* the copy is for upper bound */
298.1047 +                  copy->lb = -DBL_MAX, copy->ub = row->ub;
298.1048 +               }
298.1049 +               else
298.1050 +               {  /* the copy is for lower bound */
298.1051 +                  copy->lb = row->lb, copy->ub = +DBL_MAX;
298.1052 +               }
298.1053 +               /* copy original row coefficients */
298.1054 +               for (aij = row->ptr; aij != NULL; aij = aij->r_next)
298.1055 +                  npp_add_aij(npp, copy, aij->col, aij->val);
298.1056 +            }
298.1057 +            /* replace the original inequality by equivalent one */
298.1058 +            npp_erase_row(npp, row);
298.1059 +            row->lb = b, row->ub = +DBL_MAX;
298.1060 +            for (e = ptr; e != NULL; e = e->next)
298.1061 +               npp_add_aij(npp, row, e->xj, e->aj);
298.1062 +            /* continue processing upper bound for the copy */
298.1063 +            if (copy != NULL) row = copy;
298.1064 +         }
298.1065 +         drop_form(npp, ptr);
298.1066 +      }
298.1067 +      return count;
298.1068 +}
298.1069 +
298.1070 +/***********************************************************************
298.1071 +*  NAME
298.1072 +*
298.1073 +*  npp_is_partitioning - test if constraint is partitioning equality
298.1074 +*
298.1075 +*  SYNOPSIS
298.1076 +*
298.1077 +*  #include "glpnpp.h"
298.1078 +*  int npp_is_partitioning(NPP *npp, NPPROW *row);
298.1079 +*
298.1080 +*  RETURNS
298.1081 +*
298.1082 +*  If the specified row (constraint) is partitioning equality (see
298.1083 +*  below), the routine npp_is_partitioning returns non-zero. Otherwise,
298.1084 +*  it returns zero.
298.1085 +*
298.1086 +*  PARTITIONING EQUALITIES
298.1087 +*
298.1088 +*  In canonical format the partitioning equality is the following:
298.1089 +*
298.1090 +*     sum  x[j] = 1,                                                 (1)
298.1091 +*    j in J
298.1092 +*
298.1093 +*  where all variables x[j] are binary. This equality expresses the
298.1094 +*  condition that in any integer feasible solution exactly one variable
298.1095 +*  in set J must take non-zero (unity) value while other variables must
298.1096 +*  be equal to zero. W.l.o.g. it is assumed that |J| >= 2, because if
298.1097 +*  J is empty, the inequality (1) is infeasible, and if |J| = 1, the
298.1098 +*  inequality (1) is a fixing row.
298.1099 +*
298.1100 +*  In general case the partitioning equality may include original
298.1101 +*  variables x[j] as well as their complements x~[j]:
298.1102 +*
298.1103 +*     sum   x[j] + sum   x~[j] = 1,                                  (2)
298.1104 +*    j in Jp      j in Jn
298.1105 +*
298.1106 +*  where Jp and Jn are not intersected. Therefore, using substitution
298.1107 +*  x~[j] = 1 - x[j] leads to the partitioning equality in generalized
298.1108 +*  format:
298.1109 +*
298.1110 +*     sum   x[j] - sum   x[j] = 1 - |Jn|.                            (3)
298.1111 +*    j in Jp      j in Jn */
298.1112 +
298.1113 +int npp_is_partitioning(NPP *npp, NPPROW *row)
298.1114 +{     /* test if constraint is partitioning equality */
298.1115 +      NPPCOL *col;
298.1116 +      NPPAIJ *aij;
298.1117 +      int b;
298.1118 +      xassert(npp == npp);
298.1119 +      if (row->lb != row->ub) return 0;
298.1120 +      b = 1;
298.1121 +      for (aij = row->ptr; aij != NULL; aij = aij->r_next)
298.1122 +      {  col = aij->col;
298.1123 +         if (!(col->is_int && col->lb == 0.0 && col->ub == 1.0))
298.1124 +            return 0;
298.1125 +         if (aij->val == +1.0)
298.1126 +            ;
298.1127 +         else if (aij->val == -1.0)
298.1128 +            b--;
298.1129 +         else
298.1130 +            return 0;
298.1131 +      }
298.1132 +      if (row->lb != (double)b) return 0;
298.1133 +      return 1;
298.1134 +}
298.1135 +
298.1136 +/***********************************************************************
298.1137 +*  NAME
298.1138 +*
298.1139 +*  npp_reduce_ineq_coef - reduce inequality constraint coefficients
298.1140 +*
298.1141 +*  SYNOPSIS
298.1142 +*
298.1143 +*  #include "glpnpp.h"
298.1144 +*  int npp_reduce_ineq_coef(NPP *npp, NPPROW *row);
298.1145 +*
298.1146 +*  DESCRIPTION
298.1147 +*
298.1148 +*  The routine npp_reduce_ineq_coef processes specified inequality
298.1149 +*  constraint attempting to replace it by an equivalent constraint,
298.1150 +*  where magnitude of coefficients at binary variables is smaller than
298.1151 +*  in the original constraint. If the inequality is double-sided, it is
298.1152 +*  replaced by a pair of single-sided inequalities, if necessary.
298.1153 +*
298.1154 +*  RETURNS
298.1155 +*
298.1156 +*  The routine npp_reduce_ineq_coef returns the number of coefficients
298.1157 +*  reduced.
298.1158 +*
298.1159 +*  BACKGROUND
298.1160 +*
298.1161 +*  Consider an inequality constraint:
298.1162 +*
298.1163 +*     sum  a[j] x[j] >= b.                                           (1)
298.1164 +*    j in J
298.1165 +*
298.1166 +*  (In case of '<=' inequality it can be transformed to '>=' format by
298.1167 +*  multiplying both its sides by -1.) Let x[k] be a binary variable;
298.1168 +*  other variables can be integer as well as continuous. We can write
298.1169 +*  constraint (1) as follows:
298.1170 +*
298.1171 +*     a[k] x[k] + t[k] >= b,                                         (2)
298.1172 +*
298.1173 +*  where:
298.1174 +*
298.1175 +*     t[k] = sum      a[j] x[j].                                     (3)
298.1176 +*           j in J\{k}
298.1177 +*
298.1178 +*  Since x[k] is binary, constraint (2) is equivalent to disjunction of
298.1179 +*  the following two constraints:
298.1180 +*
298.1181 +*     x[k] = 0,  t[k] >= b                                           (4)
298.1182 +*
298.1183 +*        OR
298.1184 +*
298.1185 +*     x[k] = 1,  t[k] >= b - a[k].                                   (5)
298.1186 +*
298.1187 +*  Let also that for the partial sum t[k] be known some its implied
298.1188 +*  lower bound inf t[k].
298.1189 +*
298.1190 +*  Case a[k] > 0. Let inf t[k] < b, since otherwise both constraints
298.1191 +*  (4) and (5) and therefore constraint (2) are redundant.
298.1192 +*  If inf t[k] > b - a[k], only constraint (5) is redundant, in which
298.1193 +*  case it can be replaced with the following redundant and therefore
298.1194 +*  equivalent constraint:
298.1195 +*
298.1196 +*     t[k] >= b - a'[k] = inf t[k],                                  (6)
298.1197 +*
298.1198 +*  where:
298.1199 +*
298.1200 +*     a'[k] = b - inf t[k].                                          (7)
298.1201 +*
298.1202 +*  Thus, the original constraint (2) is equivalent to the following
298.1203 +*  constraint with coefficient at variable x[k] changed:
298.1204 +*
298.1205 +*     a'[k] x[k] + t[k] >= b.                                        (8)
298.1206 +*
298.1207 +*  From inf t[k] < b it follows that a'[k] > 0, i.e. the coefficient
298.1208 +*  at x[k] keeps its sign. And from inf t[k] > b - a[k] it follows that
298.1209 +*  a'[k] < a[k], i.e. the coefficient reduces in magnitude.
298.1210 +*
298.1211 +*  Case a[k] < 0. Let inf t[k] < b - a[k], since otherwise both
298.1212 +*  constraints (4) and (5) and therefore constraint (2) are redundant.
298.1213 +*  If inf t[k] > b, only constraint (4) is redundant, in which case it
298.1214 +*  can be replaced with the following redundant and therefore equivalent
298.1215 +*  constraint:
298.1216 +*
298.1217 +*     t[k] >= b' = inf t[k].                                         (9)
298.1218 +*
298.1219 +*  Rewriting constraint (5) as follows:
298.1220 +*
298.1221 +*     t[k] >= b - a[k] = b' - a'[k],                                (10)
298.1222 +*
298.1223 +*  where:
298.1224 +*
298.1225 +*     a'[k] = a[k] + b' - b = a[k] + inf t[k] - b,                  (11)
298.1226 +*
298.1227 +*  we can see that disjunction of constraint (9) and (10) is equivalent
298.1228 +*  to disjunction of constraint (4) and (5), from which it follows that
298.1229 +*  the original constraint (2) is equivalent to the following constraint
298.1230 +*  with both coefficient at variable x[k] and right-hand side changed:
298.1231 +*
298.1232 +*     a'[k] x[k] + t[k] >= b'.                                      (12)
298.1233 +*
298.1234 +*  From inf t[k] < b - a[k] it follows that a'[k] < 0, i.e. the
298.1235 +*  coefficient at x[k] keeps its sign. And from inf t[k] > b it follows
298.1236 +*  that a'[k] > a[k], i.e. the coefficient reduces in magnitude.
298.1237 +*
298.1238 +*  PROBLEM TRANSFORMATION
298.1239 +*
298.1240 +*  In the routine npp_reduce_ineq_coef the following implied lower
298.1241 +*  bound of the partial sum (3) is used:
298.1242 +*
298.1243 +*     inf t[k] = sum       a[j] l[j] + sum       a[j] u[j],         (13)
298.1244 +*               j in Jp\{k}           k in Jn\{k}
298.1245 +*
298.1246 +*  where Jp = {j : a[j] > 0}, Jn = {j : a[j] < 0}, l[j] and u[j] are
298.1247 +*  lower and upper bounds, resp., of variable x[j].
298.1248 +*
298.1249 +*  In order to compute inf t[k] more efficiently, the following formula,
298.1250 +*  which is equivalent to (13), is actually used:
298.1251 +*
298.1252 +*                ( h - a[k] l[k] = h,        if a[k] > 0,
298.1253 +*     inf t[k] = <                                                  (14)
298.1254 +*                ( h - a[k] u[k] = h - a[k], if a[k] < 0,
298.1255 +*
298.1256 +*  where:
298.1257 +*
298.1258 +*     h = sum   a[j] l[j] + sum   a[j] u[j]                         (15)
298.1259 +*        j in Jp           j in Jn
298.1260 +*
298.1261 +*  is the implied lower bound of row (1).
298.1262 +*
298.1263 +*  Reduction of positive coefficient (a[k] > 0) does not change value
298.1264 +*  of h, since l[k] = 0. In case of reduction of negative coefficient
298.1265 +*  (a[k] < 0) from (11) it follows that:
298.1266 +*
298.1267 +*     delta a[k] = a'[k] - a[k] = inf t[k] - b  (> 0),              (16)
298.1268 +*
298.1269 +*  so new value of h (accounting that u[k] = 1) can be computed as
298.1270 +*  follows:
298.1271 +*
298.1272 +*     h := h + delta a[k] = h + (inf t[k] - b).                     (17)
298.1273 +*
298.1274 +*  RECOVERING SOLUTION
298.1275 +*
298.1276 +*  None needed. */
298.1277 +
298.1278 +static int reduce_ineq_coef(NPP *npp, struct elem *ptr, double *_b)
298.1279 +{     /* process inequality constraint: sum a[j] x[j] >= b */
298.1280 +      /* returns: the number of coefficients reduced */
298.1281 +      struct elem *e;
298.1282 +      int count = 0;
298.1283 +      double h, inf_t, new_a, b = *_b;
298.1284 +      xassert(npp == npp);
298.1285 +      /* compute h; see (15) */
298.1286 +      h = 0.0;
298.1287 +      for (e = ptr; e != NULL; e = e->next)
298.1288 +      {  if (e->aj > 0.0)
298.1289 +         {  if (e->xj->lb == -DBL_MAX) goto done;
298.1290 +            h += e->aj * e->xj->lb;
298.1291 +         }
298.1292 +         else /* e->aj < 0.0 */
298.1293 +         {  if (e->xj->ub == +DBL_MAX) goto done;
298.1294 +            h += e->aj * e->xj->ub;
298.1295 +         }
298.1296 +      }
298.1297 +      /* perform reduction of coefficients at binary variables */
298.1298 +      for (e = ptr; e != NULL; e = e->next)
298.1299 +      {  /* skip non-binary variable */
298.1300 +         if (!(e->xj->is_int && e->xj->lb == 0.0 && e->xj->ub == 1.0))
298.1301 +            continue;
298.1302 +         if (e->aj > 0.0)
298.1303 +         {  /* compute inf t[k]; see (14) */
298.1304 +            inf_t = h;
298.1305 +            if (b - e->aj < inf_t && inf_t < b)
298.1306 +            {  /* compute reduced coefficient a'[k]; see (7) */
298.1307 +               new_a = b - inf_t;
298.1308 +               if (new_a >= +1e-3 &&
298.1309 +                   e->aj - new_a >= 0.01 * (1.0 + e->aj))
298.1310 +               {  /* accept a'[k] */
298.1311 +#ifdef GLP_DEBUG
298.1312 +                  xprintf("+");
298.1313 +#endif
298.1314 +                  e->aj = new_a;
298.1315 +                  count++;
298.1316 +               }
298.1317 +            }
298.1318 +         }
298.1319 +         else /* e->aj < 0.0 */
298.1320 +         {  /* compute inf t[k]; see (14) */
298.1321 +            inf_t = h - e->aj;
298.1322 +            if (b < inf_t && inf_t < b - e->aj)
298.1323 +            {  /* compute reduced coefficient a'[k]; see (11) */
298.1324 +               new_a = e->aj + (inf_t - b);
298.1325 +               if (new_a <= -1e-3 &&
298.1326 +                   new_a - e->aj >= 0.01 * (1.0 - e->aj))
298.1327 +               {  /* accept a'[k] */
298.1328 +#ifdef GLP_DEBUG
298.1329 +                  xprintf("-");
298.1330 +#endif
298.1331 +                  e->aj = new_a;
298.1332 +                  /* update h; see (17) */
298.1333 +                  h += (inf_t - b);
298.1334 +                  /* compute b'; see (9) */
298.1335 +                  b = inf_t;
298.1336 +                  count++;
298.1337 +               }
298.1338 +            }
298.1339 +         }
298.1340 +      }
298.1341 +      *_b = b;
298.1342 +done: return count;
298.1343 +}
298.1344 +
298.1345 +int npp_reduce_ineq_coef(NPP *npp, NPPROW *row)
298.1346 +{     /* reduce inequality constraint coefficients */
298.1347 +      NPPROW *copy;
298.1348 +      NPPAIJ *aij;
298.1349 +      struct elem *ptr, *e;
298.1350 +      int kase, count[2];
298.1351 +      double b;
298.1352 +      /* the row must be inequality constraint */
298.1353 +      xassert(row->lb < row->ub);
298.1354 +      count[0] = count[1] = 0;
298.1355 +      for (kase = 0; kase <= 1; kase++)
298.1356 +      {  if (kase == 0)
298.1357 +         {  /* process row lower bound */
298.1358 +            if (row->lb == -DBL_MAX) continue;
298.1359 +#ifdef GLP_DEBUG
298.1360 +            xprintf("L");
298.1361 +#endif
298.1362 +            ptr = copy_form(npp, row, +1.0);
298.1363 +            b = + row->lb;
298.1364 +         }
298.1365 +         else
298.1366 +         {  /* process row upper bound */
298.1367 +            if (row->ub == +DBL_MAX) continue;
298.1368 +#ifdef GLP_DEBUG
298.1369 +            xprintf("U");
298.1370 +#endif
298.1371 +            ptr = copy_form(npp, row, -1.0);
298.1372 +            b = - row->ub;
298.1373 +         }
298.1374 +         /* now the inequality has the form "sum a[j] x[j] >= b" */
298.1375 +         count[kase] = reduce_ineq_coef(npp, ptr, &b);
298.1376 +         if (count[kase] > 0)
298.1377 +         {  /* the original inequality has been replaced by equivalent
298.1378 +               one with coefficients reduced */
298.1379 +            if (row->lb == -DBL_MAX || row->ub == +DBL_MAX)
298.1380 +            {  /* the original row is single-sided inequality; no copy
298.1381 +                  is needed */
298.1382 +               copy = NULL;
298.1383 +            }
298.1384 +            else
298.1385 +            {  /* the original row is double-sided inequality; we need
298.1386 +                  to create its copy for other bound before replacing it
298.1387 +                  with the equivalent inequality */
298.1388 +#ifdef GLP_DEBUG
298.1389 +               xprintf("*");
298.1390 +#endif
298.1391 +               copy = npp_add_row(npp);
298.1392 +               if (kase == 0)
298.1393 +               {  /* the copy is for upper bound */
298.1394 +                  copy->lb = -DBL_MAX, copy->ub = row->ub;
298.1395 +               }
298.1396 +               else
298.1397 +               {  /* the copy is for lower bound */
298.1398 +                  copy->lb = row->lb, copy->ub = +DBL_MAX;
298.1399 +               }
298.1400 +               /* copy original row coefficients */
298.1401 +               for (aij = row->ptr; aij != NULL; aij = aij->r_next)
298.1402 +                  npp_add_aij(npp, copy, aij->col, aij->val);
298.1403 +            }
298.1404 +            /* replace the original inequality by equivalent one */
298.1405 +            npp_erase_row(npp, row);
298.1406 +            row->lb = b, row->ub = +DBL_MAX;
298.1407 +            for (e = ptr; e != NULL; e = e->next)
298.1408 +               npp_add_aij(npp, row, e->xj, e->aj);
298.1409 +            /* continue processing upper bound for the copy */
298.1410 +            if (copy != NULL) row = copy;
298.1411 +         }
298.1412 +         drop_form(npp, ptr);
298.1413 +      }
298.1414 +      return count[0] + count[1];
298.1415 +}
298.1416 +
298.1417 +/* eof */
   299.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
   299.2 +++ b/deps/glpk/src/glpnpp05.c	Sun Nov 06 20:59:10 2011 +0100
   299.3 @@ -0,0 +1,809 @@
   299.4 +/* glpnpp05.c */
   299.5 +
   299.6 +/***********************************************************************
   299.7 +*  This code is part of GLPK (GNU Linear Programming Kit).
   299.8 +*
   299.9 +*  Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008,
  299.10 +*  2009, 2010, 2011 Andrew Makhorin, Department for Applied Informatics,
  299.11 +*  Moscow Aviation Institute, Moscow, Russia. All rights reserved.
  299.12 +*  E-mail: <mao@gnu.org>.
  299.13 +*
  299.14 +*  GLPK is free software: you can redistribute it and/or modify it
  299.15 +*  under the terms of the GNU General Public License as published by
  299.16 +*  the Free Software Foundation, either version 3 of the License, or
  299.17 +*  (at your option) any later version.
  299.18 +*
  299.19 +*  GLPK is distributed in the hope that it will be useful, but WITHOUT
  299.20 +*  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
  299.21 +*  or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
  299.22 +*  License for more details.
  299.23 +*
  299.24 +*  You should have received a copy of the GNU General Public License
  299.25 +*  along with GLPK. If not, see <http://www.gnu.org/licenses/>.
  299.26 +***********************************************************************/
  299.27 +
  299.28 +#include "glpnpp.h"
  299.29 +
  299.30 +/***********************************************************************
  299.31 +*  NAME
  299.32 +*
  299.33 +*  npp_clean_prob - perform initial LP/MIP processing
  299.34 +*
  299.35 +*  SYNOPSIS
  299.36 +*
  299.37 +*  #include "glpnpp.h"
  299.38 +*  void npp_clean_prob(NPP *npp);
  299.39 +*
  299.40 +*  DESCRIPTION
  299.41 +*
  299.42 +*  The routine npp_clean_prob performs initial LP/MIP processing that
  299.43 +*  currently includes:
  299.44 +*
  299.45 +*  1) removing free rows;
  299.46 +*
  299.47 +*  2) replacing double-sided constraint rows with almost identical
  299.48 +*     bounds, by equality constraint rows;
  299.49 +*
  299.50 +*  3) removing fixed columns;
  299.51 +*
  299.52 +*  4) replacing double-bounded columns with almost identical bounds by
  299.53 +*     fixed columns and removing those columns;
  299.54 +*
  299.55 +*  5) initial processing constraint coefficients (not implemented);
  299.56 +*
  299.57 +*  6) initial processing objective coefficients (not implemented). */
  299.58 +
  299.59 +void npp_clean_prob(NPP *npp)
  299.60 +{     /* perform initial LP/MIP processing */
  299.61 +      NPPROW *row, *next_row;
  299.62 +      NPPCOL *col, *next_col;
  299.63 +      int ret;
  299.64 +      xassert(npp == npp);
  299.65 +      /* process rows which originally are free */
  299.66 +      for (row = npp->r_head; row != NULL; row = next_row)
  299.67 +      {  next_row = row->next;
  299.68 +         if (row->lb == -DBL_MAX && row->ub == +DBL_MAX)
  299.69 +         {  /* process free row */
  299.70 +#ifdef GLP_DEBUG
  299.71 +            xprintf("1");
  299.72 +#endif
  299.73 +            npp_free_row(npp, row);
  299.74 +            /* row was deleted */
  299.75 +         }
  299.76 +      }
  299.77 +      /* process rows which originally are double-sided inequalities */
  299.78 +      for (row = npp->r_head; row != NULL; row = next_row)
  299.79 +      {  next_row = row->next;
  299.80 +         if (row->lb != -DBL_MAX && row->ub != +DBL_MAX &&
  299.81 +             row->lb < row->ub)
  299.82 +         {  ret = npp_make_equality(npp, row);
  299.83 +            if (ret == 0)
  299.84 +               ;
  299.85 +            else if (ret == 1)
  299.86 +            {  /* row was replaced by equality constraint */
  299.87 +#ifdef GLP_DEBUG
  299.88 +               xprintf("2");
  299.89 +#endif
  299.90 +            }
  299.91 +            else
  299.92 +               xassert(ret != ret);
  299.93 +         }
  299.94 +      }
  299.95 +      /* process columns which are originally fixed */
  299.96 +      for (col = npp->c_head; col != NULL; col = next_col)
  299.97 +      {  next_col = col->next;
  299.98 +         if (col->lb == col->ub)
  299.99 +         {  /* process fixed column */
 299.100 +#ifdef GLP_DEBUG
 299.101 +            xprintf("3");
 299.102 +#endif
 299.103 +            npp_fixed_col(npp, col);
 299.104 +            /* column was deleted */
 299.105 +         }
 299.106 +      }
 299.107 +      /* process columns which are originally double-bounded */
 299.108 +      for (col = npp->c_head; col != NULL; col = next_col)
 299.109 +      {  next_col = col->next;
 299.110 +         if (col->lb != -DBL_MAX && col->ub != +DBL_MAX &&
 299.111 +             col->lb < col->ub)
 299.112 +         {  ret = npp_make_fixed(npp, col);
 299.113 +            if (ret == 0)
 299.114 +               ;
 299.115 +            else if (ret == 1)
 299.116 +            {  /* column was replaced by fixed column; process it */
 299.117 +#ifdef GLP_DEBUG
 299.118 +               xprintf("4");
 299.119 +#endif
 299.120 +               npp_fixed_col(npp, col);
 299.121 +               /* column was deleted */
 299.122 +            }
 299.123 +         }
 299.124 +      }
 299.125 +      return;
 299.126 +}
 299.127 +
 299.128 +/***********************************************************************
 299.129 +*  NAME
 299.130 +*
 299.131 +*  npp_process_row - perform basic row processing
 299.132 +*
 299.133 +*  SYNOPSIS
 299.134 +*
 299.135 +*  #include "glpnpp.h"
 299.136 +*  int npp_process_row(NPP *npp, NPPROW *row, int hard);
 299.137 +*
 299.138 +*  DESCRIPTION
 299.139 +*
 299.140 +*  The routine npp_process_row performs basic row processing that
 299.141 +*  currently includes:
 299.142 +*
 299.143 +*  1) removing empty row;
 299.144 +*
 299.145 +*  2) removing equality constraint row singleton and corresponding
 299.146 +*     column;
 299.147 +*
 299.148 +*  3) removing inequality constraint row singleton and corresponding
 299.149 +*     column if it was fixed;
 299.150 +*
 299.151 +*  4) performing general row analysis;
 299.152 +*
 299.153 +*  5) removing redundant row bounds;
 299.154 +*
 299.155 +*  6) removing forcing row and corresponding columns;
 299.156 +*
 299.157 +*  7) removing row which becomes free due to redundant bounds;
 299.158 +*
 299.159 +*  8) computing implied bounds for all columns in the row and using
 299.160 +*     them to strengthen current column bounds (MIP only, optional,
 299.161 +*     performed if the flag hard is on).
 299.162 +*
 299.163 +*  Additionally the routine may activate affected rows and/or columns
 299.164 +*  for further processing.
 299.165 +*
 299.166 +*  RETURNS
 299.167 +*
 299.168 +*  0           success;
 299.169 +*
 299.170 +*  GLP_ENOPFS  primal/integer infeasibility detected;
 299.171 +*
 299.172 +*  GLP_ENODFS  dual infeasibility detected. */
 299.173 +
 299.174 +int npp_process_row(NPP *npp, NPPROW *row, int hard)
 299.175 +{     /* perform basic row processing */
 299.176 +      NPPCOL *col;
 299.177 +      NPPAIJ *aij, *next_aij, *aaa;
 299.178 +      int ret;
 299.179 +      /* row must not be free */
 299.180 +      xassert(!(row->lb == -DBL_MAX && row->ub == +DBL_MAX));
 299.181 +      /* start processing row */
 299.182 +      if (row->ptr == NULL)
 299.183 +      {  /* empty row */
 299.184 +         ret = npp_empty_row(npp, row);
 299.185 +         if (ret == 0)
 299.186 +         {  /* row was deleted */
 299.187 +#ifdef GLP_DEBUG
 299.188 +            xprintf("A");
 299.189 +#endif
 299.190 +            return 0;
 299.191 +         }
 299.192 +         else if (ret == 1)
 299.193 +         {  /* primal infeasibility */
 299.194 +            return GLP_ENOPFS;
 299.195 +         }
 299.196 +         else
 299.197 +            xassert(ret != ret);
 299.198 +      }
 299.199 +      if (row->ptr->r_next == NULL)
 299.200 +      {  /* row singleton */
 299.201 +         col = row->ptr->col;
 299.202 +         if (row->lb == row->ub)
 299.203 +         {  /* equality constraint */
 299.204 +            ret = npp_eq_singlet(npp, row);
 299.205 +            if (ret == 0)
 299.206 +            {  /* column was fixed, row was deleted */
 299.207 +#ifdef GLP_DEBUG
 299.208 +               xprintf("B");
 299.209 +#endif
 299.210 +               /* activate rows affected by column */
 299.211 +               for (aij = col->ptr; aij != NULL; aij = aij->c_next)
 299.212 +                  npp_activate_row(npp, aij->row);
 299.213 +               /* process fixed column */
 299.214 +               npp_fixed_col(npp, col);
 299.215 +               /* column was deleted */
 299.216 +               return 0;
 299.217 +            }
 299.218 +            else if (ret == 1 || ret == 2)
 299.219 +            {  /* primal/integer infeasibility */
 299.220 +               return GLP_ENOPFS;
 299.221 +            }
 299.222 +            else
 299.223 +               xassert(ret != ret);
 299.224 +         }
 299.225 +         else
 299.226 +         {  /* inequality constraint */
 299.227 +            ret = npp_ineq_singlet(npp, row);
 299.228 +            if (0 <= ret && ret <= 3)
 299.229 +            {  /* row was deleted */
 299.230 +#ifdef GLP_DEBUG
 299.231 +               xprintf("C");
 299.232 +#endif
 299.233 +               /* activate column, since its length was changed due to
 299.234 +                  row deletion */
 299.235 +               npp_activate_col(npp, col);
 299.236 +               if (ret >= 2)
 299.237 +               {  /* column bounds changed significantly or column was
 299.238 +                     fixed */
 299.239 +                  /* activate rows affected by column */
 299.240 +                  for (aij = col->ptr; aij != NULL; aij = aij->c_next)
 299.241 +                     npp_activate_row(npp, aij->row);
 299.242 +               }
 299.243 +               if (ret == 3)
 299.244 +               {  /* column was fixed; process it */
 299.245 +#ifdef GLP_DEBUG
 299.246 +                  xprintf("D");
 299.247 +#endif
 299.248 +                  npp_fixed_col(npp, col);
 299.249 +                  /* column was deleted */
 299.250 +               }
 299.251 +               return 0;
 299.252 +            }
 299.253 +            else if (ret == 4)
 299.254 +            {  /* primal infeasibility */
 299.255 +               return GLP_ENOPFS;
 299.256 +            }
 299.257 +            else
 299.258 +               xassert(ret != ret);
 299.259 +         }
 299.260 +      }
 299.261 +#if 0
 299.262 +      /* sometimes this causes too large round-off errors; probably
 299.263 +         pivot coefficient should be chosen more carefully */
 299.264 +      if (row->ptr->r_next->r_next == NULL)
 299.265 +      {  /* row doubleton */
 299.266 +         if (row->lb == row->ub)
 299.267 +         {  /* equality constraint */
 299.268 +            if (!(row->ptr->col->is_int ||
 299.269 +                  row->ptr->r_next->col->is_int))
 299.270 +            {  /* both columns are continuous */
 299.271 +               NPPCOL *q;
 299.272 +               q = npp_eq_doublet(npp, row);
 299.273 +               if (q != NULL)
 299.274 +               {  /* column q was eliminated */
 299.275 +#ifdef GLP_DEBUG
 299.276 +                  xprintf("E");
 299.277 +#endif
 299.278 +                  /* now column q is singleton of type "implied slack
 299.279 +                     variable"; we process it here to make sure that on
 299.280 +                     recovering basic solution the row is always active
 299.281 +                     equality constraint (as required by the routine
 299.282 +                     rcv_eq_doublet) */
 299.283 +                  xassert(npp_process_col(npp, q) == 0);
 299.284 +                  /* column q was deleted; note that row p also may be
 299.285 +                     deleted */
 299.286 +                  return 0;
 299.287 +               }
 299.288 +            }
 299.289 +         }
 299.290 +      }
 299.291 +#endif
 299.292 +      /* general row analysis */
 299.293 +      ret = npp_analyze_row(npp, row);
 299.294 +      xassert(0x00 <= ret && ret <= 0xFF);
 299.295 +      if (ret == 0x33)
 299.296 +      {  /* row bounds are inconsistent with column bounds */
 299.297 +         return GLP_ENOPFS;
 299.298 +      }
 299.299 +      if ((ret & 0x0F) == 0x00)
 299.300 +      {  /* row lower bound does not exist or redundant */
 299.301 +         if (row->lb != -DBL_MAX)
 299.302 +         {  /* remove redundant row lower bound */
 299.303 +#ifdef GLP_DEBUG
 299.304 +            xprintf("F");
 299.305 +#endif
 299.306 +            npp_inactive_bound(npp, row, 0);
 299.307 +         }
 299.308 +      }
 299.309 +      else if ((ret & 0x0F) == 0x01)
 299.310 +      {  /* row lower bound can be active */
 299.311 +         /* see below */
 299.312 +      }
 299.313 +      else if ((ret & 0x0F) == 0x02)
 299.314 +      {  /* row lower bound is a forcing bound */
 299.315 +#ifdef GLP_DEBUG
 299.316 +         xprintf("G");
 299.317 +#endif
 299.318 +         /* process forcing row */
 299.319 +         if (npp_forcing_row(npp, row, 0) == 0)
 299.320 +fixup:   {  /* columns were fixed, row was made free */
 299.321 +            for (aij = row->ptr; aij != NULL; aij = next_aij)
 299.322 +            {  /* process column fixed by forcing row */
 299.323 +#ifdef GLP_DEBUG
 299.324 +               xprintf("H");
 299.325 +#endif
 299.326 +               col = aij->col;
 299.327 +               next_aij = aij->r_next;
 299.328 +               /* activate rows affected by column */
 299.329 +               for (aaa = col->ptr; aaa != NULL; aaa = aaa->c_next)
 299.330 +                  npp_activate_row(npp, aaa->row);
 299.331 +               /* process fixed column */
 299.332 +               npp_fixed_col(npp, col);
 299.333 +               /* column was deleted */
 299.334 +            }
 299.335 +            /* process free row (which now is empty due to deletion of
 299.336 +               all its columns) */
 299.337 +            npp_free_row(npp, row);
 299.338 +            /* row was deleted */
 299.339 +            return 0;
 299.340 +         }
 299.341 +      }
 299.342 +      else
 299.343 +         xassert(ret != ret);
 299.344 +      if ((ret & 0xF0) == 0x00)
 299.345 +      {  /* row upper bound does not exist or redundant */
 299.346 +         if (row->ub != +DBL_MAX)
 299.347 +         {  /* remove redundant row upper bound */
 299.348 +#ifdef GLP_DEBUG
 299.349 +            xprintf("I");
 299.350 +#endif
 299.351 +            npp_inactive_bound(npp, row, 1);
 299.352 +         }
 299.353 +      }
 299.354 +      else if ((ret & 0xF0) == 0x10)
 299.355 +      {  /* row upper bound can be active */
 299.356 +         /* see below */
 299.357 +      }
 299.358 +      else if ((ret & 0xF0) == 0x20)
 299.359 +      {  /* row upper bound is a forcing bound */
 299.360 +#ifdef GLP_DEBUG
 299.361 +         xprintf("J");
 299.362 +#endif
 299.363 +         /* process forcing row */
 299.364 +         if (npp_forcing_row(npp, row, 1) == 0) goto fixup;
 299.365 +      }
 299.366 +      else
 299.367 +         xassert(ret != ret);
 299.368 +      if (row->lb == -DBL_MAX && row->ub == +DBL_MAX)
 299.369 +      {  /* row became free due to redundant bounds removal */
 299.370 +#ifdef GLP_DEBUG
 299.371 +         xprintf("K");
 299.372 +#endif
 299.373 +         /* activate its columns, since their length will change due
 299.374 +            to row deletion */
 299.375 +         for (aij = row->ptr; aij != NULL; aij = aij->r_next)
 299.376 +            npp_activate_col(npp, aij->col);
 299.377 +         /* process free row */
 299.378 +         npp_free_row(npp, row);
 299.379 +         /* row was deleted */
 299.380 +         return 0;
 299.381 +      }
 299.382 +#if 1 /* 23/XII-2009 */
 299.383 +      /* row lower and/or upper bounds can be active */
 299.384 +      if (npp->sol == GLP_MIP && hard)
 299.385 +      {  /* improve current column bounds (optional) */
 299.386 +         if (npp_improve_bounds(npp, row, 1) < 0)
 299.387 +            return GLP_ENOPFS;
 299.388 +      }
 299.389 +#endif
 299.390 +      return 0;
 299.391 +}
 299.392 +
 299.393 +/***********************************************************************
 299.394 +*  NAME
 299.395 +*
 299.396 +*  npp_improve_bounds - improve current column bounds
 299.397 +*
 299.398 +*  SYNOPSIS
 299.399 +*
 299.400 +*  #include "glpnpp.h"
 299.401 +*  int npp_improve_bounds(NPP *npp, NPPROW *row, int flag);
 299.402 +*
 299.403 +*  DESCRIPTION
 299.404 +*
 299.405 +*  The routine npp_improve_bounds analyzes specified row (inequality
 299.406 +*  or equality constraint) to determine implied column bounds and then
 299.407 +*  uses these bounds to improve (strengthen) current column bounds.
 299.408 +*
 299.409 +*  If the flag is on and current column bounds changed significantly
 299.410 +*  or the column was fixed, the routine activate rows affected by the
 299.411 +*  column for further processing. (This feature is intended to be used
 299.412 +*  in the main loop of the routine npp_process_row.)
 299.413 +*
 299.414 +*  NOTE: This operation can be used for MIP problem only.
 299.415 +*
 299.416 +*  RETURNS
 299.417 +*
 299.418 +*  The routine npp_improve_bounds returns the number of significantly
 299.419 +*  changed bounds plus the number of column having been fixed due to
 299.420 +*  bound improvements. However, if the routine detects primal/integer
 299.421 +*  infeasibility, it returns a negative value. */
 299.422 +
 299.423 +int npp_improve_bounds(NPP *npp, NPPROW *row, int flag)
 299.424 +{     /* improve current column bounds */
 299.425 +      NPPCOL *col;
 299.426 +      NPPAIJ *aij, *next_aij, *aaa;
 299.427 +      int kase, ret, count = 0;
 299.428 +      double lb, ub;
 299.429 +      xassert(npp->sol == GLP_MIP);
 299.430 +      /* row must not be free */
 299.431 +      xassert(!(row->lb == -DBL_MAX && row->ub == +DBL_MAX));
 299.432 +      /* determine implied column bounds */
 299.433 +      npp_implied_bounds(npp, row);
 299.434 +      /* and use these bounds to strengthen current column bounds */
 299.435 +      for (aij = row->ptr; aij != NULL; aij = next_aij)
 299.436 +      {  col = aij->col;
 299.437 +         next_aij = aij->r_next;
 299.438 +         for (kase = 0; kase <= 1; kase++)
 299.439 +         {  /* save current column bounds */
 299.440 +            lb = col->lb, ub = col->ub;
 299.441 +            if (kase == 0)
 299.442 +            {  /* process implied column lower bound */
 299.443 +               if (col->ll.ll == -DBL_MAX) continue;
 299.444 +               ret = npp_implied_lower(npp, col, col->ll.ll);
 299.445 +            }
 299.446 +            else
 299.447 +            {  /* process implied column upper bound */
 299.448 +               if (col->uu.uu == +DBL_MAX) continue;
 299.449 +               ret = npp_implied_upper(npp, col, col->uu.uu);
 299.450 +            }
 299.451 +            if (ret == 0 || ret == 1)
 299.452 +            {  /* current column bounds did not change or changed, but
 299.453 +                  not significantly; restore current column bounds */
 299.454 +               col->lb = lb, col->ub = ub;
 299.455 +            }
 299.456 +            else if (ret == 2 || ret == 3)
 299.457 +            {  /* current column bounds changed significantly or column
 299.458 +                  was fixed */
 299.459 +#ifdef GLP_DEBUG
 299.460 +               xprintf("L");
 299.461 +#endif
 299.462 +               count++;
 299.463 +               /* activate other rows affected by column, if required */
 299.464 +               if (flag)
 299.465 +               {  for (aaa = col->ptr; aaa != NULL; aaa = aaa->c_next)
 299.466 +                  {  if (aaa->row != row)
 299.467 +                        npp_activate_row(npp, aaa->row);
 299.468 +                  }
 299.469 +               }
 299.470 +               if (ret == 3)
 299.471 +               {  /* process fixed column */
 299.472 +#ifdef GLP_DEBUG
 299.473 +                  xprintf("M");
 299.474 +#endif
 299.475 +                  npp_fixed_col(npp, col);
 299.476 +                  /* column was deleted */
 299.477 +                  break; /* for kase */
 299.478 +               }
 299.479 +            }
 299.480 +            else if (ret == 4)
 299.481 +            {  /* primal/integer infeasibility */
 299.482 +               return -1;
 299.483 +            }
 299.484 +            else
 299.485 +               xassert(ret != ret);
 299.486 +         }
 299.487 +      }
 299.488 +      return count;
 299.489 +}
 299.490 +
 299.491 +/***********************************************************************
 299.492 +*  NAME
 299.493 +*
 299.494 +*  npp_process_col - perform basic column processing
 299.495 +*
 299.496 +*  SYNOPSIS
 299.497 +*
 299.498 +*  #include "glpnpp.h"
 299.499 +*  int npp_process_col(NPP *npp, NPPCOL *col);
 299.500 +*
 299.501 +*  DESCRIPTION
 299.502 +*
 299.503 +*  The routine npp_process_col performs basic column processing that
 299.504 +*  currently includes:
 299.505 +*
 299.506 +*  1) fixing and removing empty column;
 299.507 +*
 299.508 +*  2) removing column singleton, which is implied slack variable, and
 299.509 +*     corresponding row if it becomes free;
 299.510 +*
 299.511 +*  3) removing bounds of column, which is implied free variable, and
 299.512 +*     replacing corresponding row by equality constraint.
 299.513 +*
 299.514 +*  Additionally the routine may activate affected rows and/or columns
 299.515 +*  for further processing.
 299.516 +*
 299.517 +*  RETURNS
 299.518 +*
 299.519 +*  0           success;
 299.520 +*
 299.521 +*  GLP_ENOPFS  primal/integer infeasibility detected;
 299.522 +*
 299.523 +*  GLP_ENODFS  dual infeasibility detected. */
 299.524 +
 299.525 +int npp_process_col(NPP *npp, NPPCOL *col)
 299.526 +{     /* perform basic column processing */
 299.527 +      NPPROW *row;
 299.528 +      NPPAIJ *aij;
 299.529 +      int ret;
 299.530 +      /* column must not be fixed */
 299.531 +      xassert(col->lb < col->ub);
 299.532 +      /* start processing column */
 299.533 +      if (col->ptr == NULL)
 299.534 +      {  /* empty column */
 299.535 +         ret = npp_empty_col(npp, col);
 299.536 +         if (ret == 0)
 299.537 +         {  /* column was fixed and deleted */
 299.538 +#ifdef GLP_DEBUG
 299.539 +            xprintf("N");
 299.540 +#endif
 299.541 +            return 0;
 299.542 +         }
 299.543 +         else if (ret == 1)
 299.544 +         {  /* dual infeasibility */
 299.545 +            return GLP_ENODFS;
 299.546 +         }
 299.547 +         else
 299.548 +            xassert(ret != ret);
 299.549 +      }
 299.550 +      if (col->ptr->c_next == NULL)
 299.551 +      {  /* column singleton */
 299.552 +         row = col->ptr->row;
 299.553 +         if (row->lb == row->ub)
 299.554 +         {  /* equality constraint */
 299.555 +            if (!col->is_int)
 299.556 +slack:      {  /* implied slack variable */
 299.557 +#ifdef GLP_DEBUG
 299.558 +               xprintf("O");
 299.559 +#endif
 299.560 +               npp_implied_slack(npp, col);
 299.561 +               /* column was deleted */
 299.562 +               if (row->lb == -DBL_MAX && row->ub == +DBL_MAX)
 299.563 +               {  /* row became free due to implied slack variable */
 299.564 +#ifdef GLP_DEBUG
 299.565 +                  xprintf("P");
 299.566 +#endif
 299.567 +                  /* activate columns affected by row */
 299.568 +                  for (aij = row->ptr; aij != NULL; aij = aij->r_next)
 299.569 +                     npp_activate_col(npp, aij->col);
 299.570 +                  /* process free row */
 299.571 +                  npp_free_row(npp, row);
 299.572 +                  /* row was deleted */
 299.573 +               }
 299.574 +               else
 299.575 +               {  /* row became inequality constraint; activate it
 299.576 +                     since its length changed due to column deletion */
 299.577 +                  npp_activate_row(npp, row);
 299.578 +               }
 299.579 +               return 0;
 299.580 +            }
 299.581 +         }
 299.582 +         else
 299.583 +         {  /* inequality constraint */
 299.584 +            if (!col->is_int)
 299.585 +            {  ret = npp_implied_free(npp, col);
 299.586 +               if (ret == 0)
 299.587 +               {  /* implied free variable */
 299.588 +#ifdef GLP_DEBUG
 299.589 +                  xprintf("Q");
 299.590 +#endif
 299.591 +                  /* column bounds were removed, row was replaced by
 299.592 +                     equality constraint */
 299.593 +                  goto slack;
 299.594 +               }
 299.595 +               else if (ret == 1)
 299.596 +               {  /* column is not implied free variable, because its
 299.597 +                     lower and/or upper bounds can be active */
 299.598 +               }
 299.599 +               else if (ret == 2)
 299.600 +               {  /* dual infeasibility */
 299.601 +                  return GLP_ENODFS;
 299.602 +               }
 299.603 +            }
 299.604 +         }
 299.605 +      }
 299.606 +      /* column still exists */
 299.607 +      return 0;
 299.608 +}
 299.609 +
 299.610 +/***********************************************************************
 299.611 +*  NAME
 299.612 +*
 299.613 +*  npp_process_prob - perform basic LP/MIP processing
 299.614 +*
 299.615 +*  SYNOPSIS
 299.616 +*
 299.617 +*  #include "glpnpp.h"
 299.618 +*  int npp_process_prob(NPP *npp, int hard);
 299.619 +*
 299.620 +*  DESCRIPTION
 299.621 +*
 299.622 +*  The routine npp_process_prob performs basic LP/MIP processing that
 299.623 +*  currently includes:
 299.624 +*
 299.625 +*  1) initial LP/MIP processing (see the routine npp_clean_prob),
 299.626 +*
 299.627 +*  2) basic row processing (see the routine npp_process_row), and
 299.628 +*
 299.629 +*  3) basic column processing (see the routine npp_process_col).
 299.630 +*
 299.631 +*  If the flag hard is on, the routine attempts to improve current
 299.632 +*  column bounds multiple times within the main processing loop, in
 299.633 +*  which case this feature may take a time. Otherwise, if the flag hard
 299.634 +*  is off, improving column bounds is performed only once at the end of
 299.635 +*  the main loop. (Note that this feature is used for MIP only.)
 299.636 +*
 299.637 +*  The routine uses two sets: the set of active rows and the set of
 299.638 +*  active columns. Rows/columns are marked by a flag (the field temp in
 299.639 +*  NPPROW/NPPCOL). If the flag is non-zero, the row/column is active,
 299.640 +*  in which case it is placed in the beginning of the row/column list;
 299.641 +*  otherwise, if the flag is zero, the row/column is inactive, in which
 299.642 +*  case it is placed in the end of the row/column list. If a row/column
 299.643 +*  being currently processed may affect other rows/columns, the latters
 299.644 +*  are activated for further processing.
 299.645 +*
 299.646 +*  RETURNS
 299.647 +*
 299.648 +*  0           success;
 299.649 +*
 299.650 +*  GLP_ENOPFS  primal/integer infeasibility detected;
 299.651 +*
 299.652 +*  GLP_ENODFS  dual infeasibility detected. */
 299.653 +
 299.654 +int npp_process_prob(NPP *npp, int hard)
 299.655 +{     /* perform basic LP/MIP processing */
 299.656 +      NPPROW *row;
 299.657 +      NPPCOL *col;
 299.658 +      int processing, ret;
 299.659 +      /* perform initial LP/MIP processing */
 299.660 +      npp_clean_prob(npp);
 299.661 +      /* activate all remaining rows and columns */
 299.662 +      for (row = npp->r_head; row != NULL; row = row->next)
 299.663 +         row->temp = 1;
 299.664 +      for (col = npp->c_head; col != NULL; col = col->next)
 299.665 +         col->temp = 1;
 299.666 +      /* main processing loop */
 299.667 +      processing = 1;
 299.668 +      while (processing)
 299.669 +      {  processing = 0;
 299.670 +         /* process all active rows */
 299.671 +         for (;;)
 299.672 +         {  row = npp->r_head;
 299.673 +            if (row == NULL || !row->temp) break;
 299.674 +            npp_deactivate_row(npp, row);
 299.675 +            ret = npp_process_row(npp, row, hard);
 299.676 +            if (ret != 0) goto done;
 299.677 +            processing = 1;
 299.678 +         }
 299.679 +         /* process all active columns */
 299.680 +         for (;;)
 299.681 +         {  col = npp->c_head;
 299.682 +            if (col == NULL || !col->temp) break;
 299.683 +            npp_deactivate_col(npp, col);
 299.684 +            ret = npp_process_col(npp, col);
 299.685 +            if (ret != 0) goto done;
 299.686 +            processing = 1;
 299.687 +         }
 299.688 +      }
 299.689 +#if 1 /* 23/XII-2009 */
 299.690 +      if (npp->sol == GLP_MIP && !hard)
 299.691 +      {  /* improve current column bounds (optional) */
 299.692 +         for (row = npp->r_head; row != NULL; row = row->next)
 299.693 +         {  if (npp_improve_bounds(npp, row, 0) < 0)
 299.694 +            {  ret = GLP_ENOPFS;
 299.695 +               goto done;
 299.696 +            }
 299.697 +         }
 299.698 +      }
 299.699 +#endif
 299.700 +      /* all seems ok */
 299.701 +      ret = 0;
 299.702 +done: xassert(ret == 0 || ret == GLP_ENOPFS || ret == GLP_ENODFS);
 299.703 +#ifdef GLP_DEBUG
 299.704 +      xprintf("\n");
 299.705 +#endif
 299.706 +      return ret;
 299.707 +}
 299.708 +
 299.709 +/**********************************************************************/
 299.710 +
 299.711 +int npp_simplex(NPP *npp, const glp_smcp *parm)
 299.712 +{     /* process LP prior to applying primal/dual simplex method */
 299.713 +      int ret;
 299.714 +      xassert(npp->sol == GLP_SOL);
 299.715 +      xassert(parm == parm);
 299.716 +      ret = npp_process_prob(npp, 0);
 299.717 +      return ret;
 299.718 +}
 299.719 +
 299.720 +/**********************************************************************/
 299.721 +
 299.722 +int npp_integer(NPP *npp, const glp_iocp *parm)
 299.723 +{     /* process MIP prior to applying branch-and-bound method */
 299.724 +      NPPROW *row, *prev_row;
 299.725 +      NPPCOL *col;
 299.726 +      NPPAIJ *aij;
 299.727 +      int count, ret;
 299.728 +      xassert(npp->sol == GLP_MIP);
 299.729 +      xassert(parm == parm);
 299.730 +      /*==============================================================*/
 299.731 +      /* perform basic MIP processing */
 299.732 +      ret = npp_process_prob(npp, 1);
 299.733 +      if (ret != 0) goto done;
 299.734 +      /*==============================================================*/
 299.735 +      /* binarize problem, if required */
 299.736 +      if (parm->binarize)
 299.737 +         npp_binarize_prob(npp);
 299.738 +      /*==============================================================*/
 299.739 +      /* identify hidden packing inequalities */
 299.740 +      count = 0;
 299.741 +      /* new rows will be added to the end of the row list, so we go
 299.742 +         from the end to beginning of the row list */
 299.743 +      for (row = npp->r_tail; row != NULL; row = prev_row)
 299.744 +      {  prev_row = row->prev;
 299.745 +         /* skip free row */
 299.746 +         if (row->lb == -DBL_MAX && row->ub == +DBL_MAX) continue;
 299.747 +         /* skip equality constraint */
 299.748 +         if (row->lb == row->ub) continue;
 299.749 +         /* skip row having less than two variables */
 299.750 +         if (row->ptr == NULL || row->ptr->r_next == NULL) continue;
 299.751 +         /* skip row having non-binary variables */
 299.752 +         for (aij = row->ptr; aij != NULL; aij = aij->r_next)
 299.753 +         {  col = aij->col;
 299.754 +            if (!(col->is_int && col->lb == 0.0 && col->ub == 1.0))
 299.755 +               break;
 299.756 +         }
 299.757 +         if (aij != NULL) continue;
 299.758 +         count += npp_hidden_packing(npp, row);
 299.759 +      }
 299.760 +      if (count > 0)
 299.761 +         xprintf("%d hidden packing inequaliti(es) were detected\n",
 299.762 +            count);
 299.763 +      /*==============================================================*/
 299.764 +      /* identify hidden covering inequalities */
 299.765 +      count = 0;
 299.766 +      /* new rows will be added to the end of the row list, so we go
 299.767 +         from the end to beginning of the row list */
 299.768 +      for (row = npp->r_tail; row != NULL; row = prev_row)
 299.769 +      {  prev_row = row->prev;
 299.770 +         /* skip free row */
 299.771 +         if (row->lb == -DBL_MAX && row->ub == +DBL_MAX) continue;
 299.772 +         /* skip equality constraint */
 299.773 +         if (row->lb == row->ub) continue;
 299.774 +         /* skip row having less than three variables */
 299.775 +         if (row->ptr == NULL || row->ptr->r_next == NULL ||
 299.776 +             row->ptr->r_next->r_next == NULL) continue;
 299.777 +         /* skip row having non-binary variables */
 299.778 +         for (aij = row->ptr; aij != NULL; aij = aij->r_next)
 299.779 +         {  col = aij->col;
 299.780 +            if (!(col->is_int && col->lb == 0.0 && col->ub == 1.0))
 299.781 +               break;
 299.782 +         }
 299.783 +         if (aij != NULL) continue;
 299.784 +         count += npp_hidden_covering(npp, row);
 299.785 +      }
 299.786 +      if (count > 0)
 299.787 +         xprintf("%d hidden covering inequaliti(es) were detected\n",
 299.788 +            count);
 299.789 +      /*==============================================================*/
 299.790 +      /* reduce inequality constraint coefficients */
 299.791 +      count = 0;
 299.792 +      /* new rows will be added to the end of the row list, so we go
 299.793 +         from the end to beginning of the row list */
 299.794 +      for (row = npp->r_tail; row != NULL; row = prev_row)
 299.795 +      {  prev_row = row->prev;
 299.796 +         /* skip equality constraint */
 299.797 +         if (row->lb == row->ub) continue;
 299.798 +         count += npp_reduce_ineq_coef(npp, row);
 299.799 +      }
 299.800 +      if (count > 0)
 299.801 +         xprintf("%d constraint coefficient(s) were reduced\n", count);
 299.802 +      /*==============================================================*/
 299.803 +#ifdef GLP_DEBUG
 299.804 +      routine(npp);
 299.805 +#endif
 299.806 +      /*==============================================================*/
 299.807 +      /* all seems ok */
 299.808 +      ret = 0;
 299.809 +done: return ret;
 299.810 +}
 299.811 +
 299.812 +/* eof */
   300.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
   300.2 +++ b/deps/glpk/src/glpnpp06.c	Sun Nov 06 20:59:10 2011 +0100
   300.3 @@ -0,0 +1,1500 @@
   300.4 +/* glpnpp06.c (translate feasibility problem to CNF-SAT) */
   300.5 +
   300.6 +/***********************************************************************
   300.7 +*  This code is part of GLPK (GNU Linear Programming Kit).
   300.8 +*
   300.9 +*  Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008,
  300.10 +*  2009, 2010, 2011 Andrew Makhorin, Department for Applied Informatics,
  300.11 +*  Moscow Aviation Institute, Moscow, Russia. All rights reserved.
  300.12 +*  E-mail: <mao@gnu.org>.
  300.13 +*
  300.14 +*  GLPK is free software: you can redistribute it and/or modify it
  300.15 +*  under the terms of the GNU General Public License as published by
  300.16 +*  the Free Software Foundation, either version 3 of the License, or
  300.17 +*  (at your option) any later version.
  300.18 +*
  300.19 +*  GLPK is distributed in the hope that it will be useful, but WITHOUT
  300.20 +*  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
  300.21 +*  or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
  300.22 +*  License for more details.
  300.23 +*
  300.24 +*  You should have received a copy of the GNU General Public License
  300.25 +*  along with GLPK. If not, see <http://www.gnu.org/licenses/>.
  300.26 +***********************************************************************/
  300.27 +
  300.28 +#include "glpnpp.h"
  300.29 +
  300.30 +/***********************************************************************
  300.31 +*  npp_sat_free_row - process free (unbounded) row
  300.32 +*
  300.33 +*  This routine processes row p, which is free (i.e. has no finite
  300.34 +*  bounds):
  300.35 +*
  300.36 +*     -inf < sum a[p,j] x[j] < +inf.                                 (1)
  300.37 +*
  300.38 +*  The constraint (1) cannot be active and therefore it is redundant,
  300.39 +*  so the routine simply removes it from the original problem. */
  300.40 +
  300.41 +void npp_sat_free_row(NPP *npp, NPPROW *p)
  300.42 +{     /* the row should be free */
  300.43 +      xassert(p->lb == -DBL_MAX && p->ub == +DBL_MAX);
  300.44 +      /* remove the row from the problem */
  300.45 +      npp_del_row(npp, p);
  300.46 +      return;
  300.47 +}
  300.48 +
  300.49 +/***********************************************************************
  300.50 +*  npp_sat_fixed_col - process fixed column
  300.51 +*
  300.52 +*  This routine processes column q, which is fixed:
  300.53 +*
  300.54 +*     x[q] = s[q],                                                   (1)
  300.55 +*
  300.56 +*  where s[q] is a fixed column value.
  300.57 +*
  300.58 +*  The routine substitutes fixed value s[q] into constraint rows and
  300.59 +*  then removes column x[q] from the original problem.
  300.60 +*
  300.61 +*  Substitution of x[q] = s[q] into row i gives:
  300.62 +*
  300.63 +*     L[i] <= sum a[i,j] x[j] <= U[i]   ==>
  300.64 +*              j
  300.65 +*
  300.66 +*     L[i] <= sum a[i,j] x[j] + a[i,q] x[q] <= U[i]   ==>
  300.67 +*            j!=q
  300.68 +*
  300.69 +*     L[i] <= sum a[i,j] x[j] + a[i,q] s[q] <= U[i]   ==>
  300.70 +*            j!=q
  300.71 +*
  300.72 +*     L~[i] <= sum a[i,j] x[j] <= U~[i],
  300.73 +*             j!=q
  300.74 +*
  300.75 +*  where
  300.76 +*
  300.77 +*     L~[i] = L[i] - a[i,q] s[q],                                    (2)
  300.78 +*
  300.79 +*     U~[i] = U[i] - a[i,q] s[q]                                     (3)
  300.80 +*
  300.81 +*  are, respectively, lower and upper bound of row i in the transformed
  300.82 +*  problem.
  300.83 +*
  300.84 +*  On recovering solution x[q] is assigned the value of s[q]. */
  300.85 +
  300.86 +struct sat_fixed_col
  300.87 +{     /* fixed column */
  300.88 +      int q;
  300.89 +      /* column reference number for variable x[q] */
  300.90 +      int s;
  300.91 +      /* value, at which x[q] is fixed */
  300.92 +};
  300.93 +
  300.94 +static int rcv_sat_fixed_col(NPP *, void *);
  300.95 +
  300.96 +int npp_sat_fixed_col(NPP *npp, NPPCOL *q)
  300.97 +{     struct sat_fixed_col *info;
  300.98 +      NPPROW *i;
  300.99 +      NPPAIJ *aij;
 300.100 +      int temp;
 300.101 +      /* the column should be fixed */
 300.102 +      xassert(q->lb == q->ub);
 300.103 +      /* create transformation stack entry */
 300.104 +      info = npp_push_tse(npp,
 300.105 +         rcv_sat_fixed_col, sizeof(struct sat_fixed_col));
 300.106 +      info->q = q->j;
 300.107 +      info->s = (int)q->lb;
 300.108 +      xassert((double)info->s == q->lb);
 300.109 +      /* substitute x[q] = s[q] into constraint rows */
 300.110 +      if (info->s == 0)
 300.111 +         goto skip;
 300.112 +      for (aij = q->ptr; aij != NULL; aij = aij->c_next)
 300.113 +      {  i = aij->row;
 300.114 +         if (i->lb != -DBL_MAX)
 300.115 +         {  i->lb -= aij->val * (double)info->s;
 300.116 +            temp = (int)i->lb;
 300.117 +            if ((double)temp != i->lb)
 300.118 +               return 1; /* integer arithmetic error */
 300.119 +         }
 300.120 +         if (i->ub != +DBL_MAX)
 300.121 +         {  i->ub -= aij->val * (double)info->s;
 300.122 +            temp = (int)i->ub;
 300.123 +            if ((double)temp != i->ub)
 300.124 +               return 2; /* integer arithmetic error */
 300.125 +         }
 300.126 +      }
 300.127 +skip: /* remove the column from the problem */
 300.128 +      npp_del_col(npp, q);
 300.129 +      return 0;
 300.130 +}
 300.131 +
 300.132 +static int rcv_sat_fixed_col(NPP *npp, void *info_)
 300.133 +{     struct sat_fixed_col *info = info_;
 300.134 +      npp->c_value[info->q] = (double)info->s;
 300.135 +      return 0;
 300.136 +}
 300.137 +
 300.138 +/***********************************************************************
 300.139 +*  npp_sat_is_bin_comb - test if row is binary combination
 300.140 +*
 300.141 +*  This routine tests if the specified row is a binary combination,
 300.142 +*  i.e. all its constraint coefficients are +1 and -1 and all variables
 300.143 +*  are binary. If the test was passed, the routine returns non-zero,
 300.144 +*  otherwise zero. */
 300.145 +
 300.146 +int npp_sat_is_bin_comb(NPP *npp, NPPROW *row)
 300.147 +{     NPPCOL *col;
 300.148 +      NPPAIJ *aij;
 300.149 +      xassert(npp == npp);
 300.150 +      for (aij = row->ptr; aij != NULL; aij = aij->r_next)
 300.151 +      {  if (!(aij->val == +1.0 || aij->val == -1.0))
 300.152 +            return 0; /* non-unity coefficient */
 300.153 +         col = aij->col;
 300.154 +         if (!(col->is_int && col->lb == 0.0 && col->ub == 1.0))
 300.155 +            return 0; /* non-binary column */
 300.156 +      }
 300.157 +      return 1; /* test was passed */
 300.158 +}
 300.159 +
 300.160 +/***********************************************************************
 300.161 +*  npp_sat_num_pos_coef - determine number of positive coefficients
 300.162 +*
 300.163 +*  This routine returns the number of positive coefficients in the
 300.164 +*  specified row. */
 300.165 +
 300.166 +int npp_sat_num_pos_coef(NPP *npp, NPPROW *row)
 300.167 +{     NPPAIJ *aij;
 300.168 +      int num = 0;
 300.169 +      xassert(npp == npp);
 300.170 +      for (aij = row->ptr; aij != NULL; aij = aij->r_next)
 300.171 +      {  if (aij->val > 0.0)
 300.172 +            num++;
 300.173 +      }
 300.174 +      return num;
 300.175 +}
 300.176 +
 300.177 +/***********************************************************************
 300.178 +*  npp_sat_num_neg_coef - determine number of negative coefficients
 300.179 +*
 300.180 +*  This routine returns the number of negative coefficients in the
 300.181 +*  specified row. */
 300.182 +
 300.183 +int npp_sat_num_neg_coef(NPP *npp, NPPROW *row)
 300.184 +{     NPPAIJ *aij;
 300.185 +      int num = 0;
 300.186 +      xassert(npp == npp);
 300.187 +      for (aij = row->ptr; aij != NULL; aij = aij->r_next)
 300.188 +      {  if (aij->val < 0.0)
 300.189 +            num++;
 300.190 +      }
 300.191 +      return num;
 300.192 +}
 300.193 +
 300.194 +/***********************************************************************
 300.195 +*  npp_sat_is_cover_ineq - test if row is covering inequality
 300.196 +*
 300.197 +*  The canonical form of a covering inequality is the following:
 300.198 +*
 300.199 +*     sum x[j] >= 1,                                                 (1)
 300.200 +*   j in J
 300.201 +*
 300.202 +*  where all x[j] are binary variables.
 300.203 +*
 300.204 +*  In general case a covering inequality may have one of the following
 300.205 +*  two forms:
 300.206 +*
 300.207 +*     sum  x[j] -  sum  x[j] >= 1 - |J-|,                            (2)
 300.208 +*   j in J+      j in J-
 300.209 +*
 300.210 +*
 300.211 +*     sum  x[j] -  sum  x[j] <= |J+| - 1.                            (3)
 300.212 +*   j in J+      j in J-
 300.213 +*
 300.214 +*  Obviously, the inequality (2) can be transformed to the form (1) by
 300.215 +*  substitution x[j] = 1 - x'[j] for all j in J-, where x'[j] is the
 300.216 +*  negation of variable x[j]. And the inequality (3) can be transformed
 300.217 +*  to (2) by multiplying both left- and right-hand sides by -1.
 300.218 +*
 300.219 +*  This routine returns one of the following codes:
 300.220 +*
 300.221 +*  0, if the specified row is not a covering inequality;
 300.222 +*
 300.223 +*  1, if the specified row has the form (2);
 300.224 +*
 300.225 +*  2, if the specified row has the form (3). */
 300.226 +
 300.227 +int npp_sat_is_cover_ineq(NPP *npp, NPPROW *row)
 300.228 +{     xassert(npp == npp);
 300.229 +      if (row->lb != -DBL_MAX && row->ub == +DBL_MAX)
 300.230 +      {  /* row is inequality of '>=' type */
 300.231 +         if (npp_sat_is_bin_comb(npp, row))
 300.232 +         {  /* row is a binary combination */
 300.233 +            if (row->lb == 1.0 - npp_sat_num_neg_coef(npp, row))
 300.234 +            {  /* row has the form (2) */
 300.235 +               return 1;
 300.236 +            }
 300.237 +         }
 300.238 +      }
 300.239 +      else if (row->lb == -DBL_MAX && row->ub != +DBL_MAX)
 300.240 +      {  /* row is inequality of '<=' type */
 300.241 +         if (npp_sat_is_bin_comb(npp, row))
 300.242 +         {  /* row is a binary combination */
 300.243 +            if (row->ub == npp_sat_num_pos_coef(npp, row) - 1.0)
 300.244 +            {  /* row has the form (3) */
 300.245 +               return 2;
 300.246 +            }
 300.247 +         }
 300.248 +      }
 300.249 +      /* row is not a covering inequality */
 300.250 +      return 0;
 300.251 +}
 300.252 +
 300.253 +/***********************************************************************
 300.254 +*  npp_sat_is_pack_ineq - test if row is packing inequality
 300.255 +*
 300.256 +*  The canonical form of a packing inequality is the following:
 300.257 +*
 300.258 +*     sum x[j] <= 1,                                                 (1)
 300.259 +*   j in J
 300.260 +*
 300.261 +*  where all x[j] are binary variables.
 300.262 +*
 300.263 +*  In general case a packing inequality may have one of the following
 300.264 +*  two forms:
 300.265 +*
 300.266 +*     sum  x[j] -  sum  x[j] <= 1 - |J-|,                            (2)
 300.267 +*   j in J+      j in J-
 300.268 +*
 300.269 +*
 300.270 +*     sum  x[j] -  sum  x[j] >= |J+| - 1.                            (3)
 300.271 +*   j in J+      j in J-
 300.272 +*
 300.273 +*  Obviously, the inequality (2) can be transformed to the form (1) by
 300.274 +*  substitution x[j] = 1 - x'[j] for all j in J-, where x'[j] is the
 300.275 +*  negation of variable x[j]. And the inequality (3) can be transformed
 300.276 +*  to (2) by multiplying both left- and right-hand sides by -1.
 300.277 +*
 300.278 +*  This routine returns one of the following codes:
 300.279 +*
 300.280 +*  0, if the specified row is not a packing inequality;
 300.281 +*
 300.282 +*  1, if the specified row has the form (2);
 300.283 +*
 300.284 +*  2, if the specified row has the form (3). */
 300.285 +
 300.286 +int npp_sat_is_pack_ineq(NPP *npp, NPPROW *row)
 300.287 +{     xassert(npp == npp);
 300.288 +      if (row->lb == -DBL_MAX && row->ub != +DBL_MAX)
 300.289 +      {  /* row is inequality of '<=' type */
 300.290 +         if (npp_sat_is_bin_comb(npp, row))
 300.291 +         {  /* row is a binary combination */
 300.292 +            if (row->ub == 1.0 - npp_sat_num_neg_coef(npp, row))
 300.293 +            {  /* row has the form (2) */
 300.294 +               return 1;
 300.295 +            }
 300.296 +         }
 300.297 +      }
 300.298 +      else if (row->lb != -DBL_MAX && row->ub == +DBL_MAX)
 300.299 +      {  /* row is inequality of '>=' type */
 300.300 +         if (npp_sat_is_bin_comb(npp, row))
 300.301 +         {  /* row is a binary combination */
 300.302 +            if (row->lb == npp_sat_num_pos_coef(npp, row) - 1.0)
 300.303 +            {  /* row has the form (3) */
 300.304 +               return 2;
 300.305 +            }
 300.306 +         }
 300.307 +      }
 300.308 +      /* row is not a packing inequality */
 300.309 +      return 0;
 300.310 +}
 300.311 +
 300.312 +/***********************************************************************
 300.313 +*  npp_sat_is_partn_eq - test if row is partitioning equality
 300.314 +*
 300.315 +*  The canonical form of a partitioning equality is the following:
 300.316 +*
 300.317 +*     sum x[j] = 1,                                                  (1)
 300.318 +*   j in J
 300.319 +*
 300.320 +*  where all x[j] are binary variables.
 300.321 +*
 300.322 +*  In general case a partitioning equality may have one of the following
 300.323 +*  two forms:
 300.324 +*
 300.325 +*     sum  x[j] -  sum  x[j] = 1 - |J-|,                             (2)
 300.326 +*   j in J+      j in J-
 300.327 +*
 300.328 +*
 300.329 +*     sum  x[j] -  sum  x[j] = |J+| - 1.                             (3)
 300.330 +*   j in J+      j in J-
 300.331 +*
 300.332 +*  Obviously, the equality (2) can be transformed to the form (1) by
 300.333 +*  substitution x[j] = 1 - x'[j] for all j in J-, where x'[j] is the
 300.334 +*  negation of variable x[j]. And the equality (3) can be transformed
 300.335 +*  to (2) by multiplying both left- and right-hand sides by -1.
 300.336 +*
 300.337 +*  This routine returns one of the following codes:
 300.338 +*
 300.339 +*  0, if the specified row is not a partitioning equality;
 300.340 +*
 300.341 +*  1, if the specified row has the form (2);
 300.342 +*
 300.343 +*  2, if the specified row has the form (3). */
 300.344 +
 300.345 +int npp_sat_is_partn_eq(NPP *npp, NPPROW *row)
 300.346 +{     xassert(npp == npp);
 300.347 +      if (row->lb == row->ub)
 300.348 +      {  /* row is equality constraint */
 300.349 +         if (npp_sat_is_bin_comb(npp, row))
 300.350 +         {  /* row is a binary combination */
 300.351 +            if (row->lb == 1.0 - npp_sat_num_neg_coef(npp, row))
 300.352 +            {  /* row has the form (2) */
 300.353 +               return 1;
 300.354 +            }
 300.355 +            if (row->ub == npp_sat_num_pos_coef(npp, row) - 1.0)
 300.356 +            {  /* row has the form (3) */
 300.357 +               return 2;
 300.358 +            }
 300.359 +         }
 300.360 +      }
 300.361 +      /* row is not a partitioning equality */
 300.362 +      return 0;
 300.363 +}
 300.364 +
 300.365 +/***********************************************************************
 300.366 +*  npp_sat_reverse_row - multiply both sides of row by -1
 300.367 +*
 300.368 +*  This routines multiplies by -1 both left- and right-hand sides of
 300.369 +*  the specified row:
 300.370 +*
 300.371 +*     L <= sum x[j] <= U,
 300.372 +*
 300.373 +*  that results in the following row:
 300.374 +*
 300.375 +*     -U <= sum (-x[j]) <= -L.
 300.376 +*
 300.377 +*  If no integer overflow occured, the routine returns zero, otherwise
 300.378 +*  non-zero. */
 300.379 +
 300.380 +int npp_sat_reverse_row(NPP *npp, NPPROW *row)
 300.381 +{     NPPAIJ *aij;
 300.382 +      int temp, ret = 0;
 300.383 +      double old_lb, old_ub;
 300.384 +      xassert(npp == npp);
 300.385 +      for (aij = row->ptr; aij != NULL; aij = aij->r_next)
 300.386 +      {  aij->val = -aij->val;
 300.387 +         temp = (int)aij->val;
 300.388 +         if ((double)temp != aij->val)
 300.389 +            ret = 1;
 300.390 +      }
 300.391 +      old_lb = row->lb, old_ub = row->ub;
 300.392 +      if (old_ub == +DBL_MAX)
 300.393 +         row->lb = -DBL_MAX;
 300.394 +      else
 300.395 +      {  row->lb = -old_ub;
 300.396 +         temp = (int)row->lb;
 300.397 +         if ((double)temp != row->lb)
 300.398 +            ret = 2;
 300.399 +      }
 300.400 +      if (old_lb == -DBL_MAX)
 300.401 +         row->ub = +DBL_MAX;
 300.402 +      else
 300.403 +      {  row->ub = -old_lb;
 300.404 +         temp = (int)row->ub;
 300.405 +         if ((double)temp != row->ub)
 300.406 +            ret = 3;
 300.407 +      }
 300.408 +      return ret;
 300.409 +}
 300.410 +
 300.411 +/***********************************************************************
 300.412 +*  npp_sat_split_pack - split packing inequality
 300.413 +*
 300.414 +*  Let there be given a packing inequality in canonical form:
 300.415 +*
 300.416 +*     sum  t[j] <= 1,                                                (1)
 300.417 +*   j in J
 300.418 +*
 300.419 +*  where t[j] = x[j] or t[j] = 1 - x[j], x[j] is a binary variable.
 300.420 +*  And let J = J1 U J2 is a partition of the set of literals. Then the
 300.421 +*  inequality (1) is obviously equivalent to the following two packing
 300.422 +*  inequalities:
 300.423 +*
 300.424 +*     sum  t[j] <= y       <-->   sum  t[j] + (1 - y) <= 1,          (2)
 300.425 +*   j in J1                     j in J1
 300.426 +*
 300.427 +*     sum  t[j] <= 1 - y   <-->   sum  t[j] + y       <= 1,          (3)
 300.428 +*   j in J2                     j in J2
 300.429 +*
 300.430 +*  where y is a new binary variable added to the transformed problem.
 300.431 +*
 300.432 +*  Assuming that the specified row is a packing inequality (1), this
 300.433 +*  routine constructs the set J1 by including there first nlit literals
 300.434 +*  (terms) from the specified row, and the set J2 = J \ J1. Then the
 300.435 +*  routine creates a new row, which corresponds to inequality (2), and
 300.436 +*  replaces the specified row with inequality (3). */
 300.437 +
 300.438 +NPPROW *npp_sat_split_pack(NPP *npp, NPPROW *row, int nlit)
 300.439 +{     NPPROW *rrr;
 300.440 +      NPPCOL *col;
 300.441 +      NPPAIJ *aij;
 300.442 +      int k;
 300.443 +      /* original row should be packing inequality (1) */
 300.444 +      xassert(npp_sat_is_pack_ineq(npp, row) == 1);
 300.445 +      /* and nlit should be less than the number of literals (terms)
 300.446 +         in the original row */
 300.447 +      xassert(0 < nlit && nlit < npp_row_nnz(npp, row));
 300.448 +      /* create new row corresponding to inequality (2) */
 300.449 +      rrr = npp_add_row(npp);
 300.450 +      rrr->lb = -DBL_MAX, rrr->ub = 1.0;
 300.451 +      /* move first nlit literals (terms) from the original row to the
 300.452 +         new row; the original row becomes inequality (3) */
 300.453 +      for (k = 1; k <= nlit; k++)
 300.454 +      {  aij = row->ptr;
 300.455 +         xassert(aij != NULL);
 300.456 +         /* add literal to the new row */
 300.457 +         npp_add_aij(npp, rrr, aij->col, aij->val);
 300.458 +         /* correct rhs */
 300.459 +         if (aij->val < 0.0)
 300.460 +            rrr->ub -= 1.0, row->ub += 1.0;
 300.461 +         /* remove literal from the original row */
 300.462 +         npp_del_aij(npp, aij);
 300.463 +      }
 300.464 +      /* create new binary variable y */
 300.465 +      col = npp_add_col(npp);
 300.466 +      col->is_int = 1, col->lb = 0.0, col->ub = 1.0;
 300.467 +      /* include literal (1 - y) in the new row */
 300.468 +      npp_add_aij(npp, rrr, col, -1.0);
 300.469 +      rrr->ub -= 1.0;
 300.470 +      /* include literal y in the original row */
 300.471 +      npp_add_aij(npp, row, col, +1.0);
 300.472 +      return rrr;
 300.473 +}
 300.474 +
 300.475 +/***********************************************************************
 300.476 +*  npp_sat_encode_pack - encode packing inequality
 300.477 +*
 300.478 +*  Given a packing inequality in canonical form:
 300.479 +*
 300.480 +*     sum  t[j] <= 1,                                                (1)
 300.481 +*   j in J
 300.482 +*
 300.483 +*  where t[j] = x[j] or t[j] = 1 - x[j], x[j] is a binary variable,
 300.484 +*  this routine translates it to CNF by replacing it with the following
 300.485 +*  equivalent set of edge packing inequalities:
 300.486 +*
 300.487 +*     t[j] + t[k] <= 1   for all j, k in J, j != k.                  (2)
 300.488 +*
 300.489 +*  Then the routine transforms each edge packing inequality (2) to
 300.490 +*  corresponding covering inequality (that encodes two-literal clause)
 300.491 +*  by multiplying both its part by -1:
 300.492 +*
 300.493 +*     - t[j] - t[k] >= -1   <-->   (1 - t[j]) + (1 - t[k]) >= 1.     (3)
 300.494 +*
 300.495 +*  On exit the routine removes the original row from the problem. */
 300.496 +
 300.497 +void npp_sat_encode_pack(NPP *npp, NPPROW *row)
 300.498 +{     NPPROW *rrr;
 300.499 +      NPPAIJ *aij, *aik;
 300.500 +      /* original row should be packing inequality (1) */
 300.501 +      xassert(npp_sat_is_pack_ineq(npp, row) == 1);
 300.502 +      /* create equivalent system of covering inequalities (3) */
 300.503 +      for (aij = row->ptr; aij != NULL; aij = aij->r_next)
 300.504 +      {  /* due to symmetry only one of inequalities t[j] + t[k] <= 1
 300.505 +            and t[k] <= t[j] <= 1 can be considered */
 300.506 +         for (aik = aij->r_next; aik != NULL; aik = aik->r_next)
 300.507 +         {  /* create edge packing inequality (2) */
 300.508 +            rrr = npp_add_row(npp);
 300.509 +            rrr->lb = -DBL_MAX, rrr->ub = 1.0;
 300.510 +            npp_add_aij(npp, rrr, aij->col, aij->val);
 300.511 +            if (aij->val < 0.0)
 300.512 +               rrr->ub -= 1.0;
 300.513 +            npp_add_aij(npp, rrr, aik->col, aik->val);
 300.514 +            if (aik->val < 0.0)
 300.515 +               rrr->ub -= 1.0;
 300.516 +            /* and transform it to covering inequality (3) */
 300.517 +            npp_sat_reverse_row(npp, rrr);
 300.518 +            xassert(npp_sat_is_cover_ineq(npp, rrr) == 1);
 300.519 +         }
 300.520 +      }
 300.521 +      /* remove the original row from the problem */
 300.522 +      npp_del_row(npp, row);
 300.523 +      return;
 300.524 +}
 300.525 +
 300.526 +/***********************************************************************
 300.527 +*  npp_sat_encode_sum2 - encode 2-bit summation
 300.528 +*
 300.529 +*  Given a set containing two literals x and y this routine encodes
 300.530 +*  the equality
 300.531 +*
 300.532 +*     x + y = s + 2 * c,                                             (1)
 300.533 +*
 300.534 +*  where
 300.535 +*
 300.536 +*     s = (x + y) % 2                                                (2)
 300.537 +*
 300.538 +*  is a binary variable modeling the low sum bit, and
 300.539 +*
 300.540 +*     c = (x + y) / 2                                                (3)
 300.541 +*
 300.542 +*  is a binary variable modeling the high (carry) sum bit. */
 300.543 +
 300.544 +void npp_sat_encode_sum2(NPP *npp, NPPLSE *set, NPPSED *sed)
 300.545 +{     NPPROW *row;
 300.546 +      int x, y, s, c;
 300.547 +      /* the set should contain exactly two literals */
 300.548 +      xassert(set != NULL);
 300.549 +      xassert(set->next != NULL);
 300.550 +      xassert(set->next->next == NULL);
 300.551 +      sed->x = set->lit;
 300.552 +      xassert(sed->x.neg == 0 || sed->x.neg == 1);
 300.553 +      sed->y = set->next->lit;
 300.554 +      xassert(sed->y.neg == 0 || sed->y.neg == 1);
 300.555 +      sed->z.col = NULL, sed->z.neg = 0;
 300.556 +      /* perform encoding s = (x + y) % 2 */
 300.557 +      sed->s = npp_add_col(npp);
 300.558 +      sed->s->is_int = 1, sed->s->lb = 0.0, sed->s->ub = 1.0;
 300.559 +      for (x = 0; x <= 1; x++)
 300.560 +      {  for (y = 0; y <= 1; y++)
 300.561 +         {  for (s = 0; s <= 1; s++)
 300.562 +            {  if ((x + y) % 2 != s)
 300.563 +               {  /* generate CNF clause to disable infeasible
 300.564 +                     combination */
 300.565 +                  row = npp_add_row(npp);
 300.566 +                  row->lb = 1.0, row->ub = +DBL_MAX;
 300.567 +                  if (x == sed->x.neg)
 300.568 +                     npp_add_aij(npp, row, sed->x.col, +1.0);
 300.569 +                  else
 300.570 +                  {  npp_add_aij(npp, row, sed->x.col, -1.0);
 300.571 +                     row->lb -= 1.0;
 300.572 +                  }
 300.573 +                  if (y == sed->y.neg)
 300.574 +                     npp_add_aij(npp, row, sed->y.col, +1.0);
 300.575 +                  else
 300.576 +                  {  npp_add_aij(npp, row, sed->y.col, -1.0);
 300.577 +                     row->lb -= 1.0;
 300.578 +                  }
 300.579 +                  if (s == 0)
 300.580 +                     npp_add_aij(npp, row, sed->s, +1.0);
 300.581 +                  else
 300.582 +                  {  npp_add_aij(npp, row, sed->s, -1.0);
 300.583 +                     row->lb -= 1.0;
 300.584 +                  }
 300.585 +               }
 300.586 +            }
 300.587 +         }
 300.588 +      }
 300.589 +      /* perform encoding c = (x + y) / 2 */
 300.590 +      sed->c = npp_add_col(npp);
 300.591 +      sed->c->is_int = 1, sed->c->lb = 0.0, sed->c->ub = 1.0;
 300.592 +      for (x = 0; x <= 1; x++)
 300.593 +      {  for (y = 0; y <= 1; y++)
 300.594 +         {  for (c = 0; c <= 1; c++)
 300.595 +            {  if ((x + y) / 2 != c)
 300.596 +               {  /* generate CNF clause to disable infeasible
 300.597 +                     combination */
 300.598 +                  row = npp_add_row(npp);
 300.599 +                  row->lb = 1.0, row->ub = +DBL_MAX;
 300.600 +                  if (x == sed->x.neg)
 300.601 +                     npp_add_aij(npp, row, sed->x.col, +1.0);
 300.602 +                  else
 300.603 +                  {  npp_add_aij(npp, row, sed->x.col, -1.0);
 300.604 +                     row->lb -= 1.0;
 300.605 +                  }
 300.606 +                  if (y == sed->y.neg)
 300.607 +                     npp_add_aij(npp, row, sed->y.col, +1.0);
 300.608 +                  else
 300.609 +                  {  npp_add_aij(npp, row, sed->y.col, -1.0);
 300.610 +                     row->lb -= 1.0;
 300.611 +                  }
 300.612 +                  if (c == 0)
 300.613 +                     npp_add_aij(npp, row, sed->c, +1.0);
 300.614 +                  else
 300.615 +                  {  npp_add_aij(npp, row, sed->c, -1.0);
 300.616 +                     row->lb -= 1.0;
 300.617 +                  }
 300.618 +               }
 300.619 +            }
 300.620 +         }
 300.621 +      }
 300.622 +      return;
 300.623 +}
 300.624 +
 300.625 +/***********************************************************************
 300.626 +*  npp_sat_encode_sum3 - encode 3-bit summation
 300.627 +*
 300.628 +*  Given a set containing at least three literals this routine chooses
 300.629 +*  some literals x, y, z from that set and encodes the equality
 300.630 +*
 300.631 +*     x + y + z = s + 2 * c,                                         (1)
 300.632 +*
 300.633 +*  where
 300.634 +*
 300.635 +*     s = (x + y + z) % 2                                            (2)
 300.636 +*
 300.637 +*  is a binary variable modeling the low sum bit, and
 300.638 +*
 300.639 +*     c = (x + y + z) / 2                                            (3)
 300.640 +*
 300.641 +*  is a binary variable modeling the high (carry) sum bit. */
 300.642 +
 300.643 +void npp_sat_encode_sum3(NPP *npp, NPPLSE *set, NPPSED *sed)
 300.644 +{     NPPROW *row;
 300.645 +      int x, y, z, s, c;
 300.646 +      /* the set should contain at least three literals */
 300.647 +      xassert(set != NULL);
 300.648 +      xassert(set->next != NULL);
 300.649 +      xassert(set->next->next != NULL);
 300.650 +      sed->x = set->lit;
 300.651 +      xassert(sed->x.neg == 0 || sed->x.neg == 1);
 300.652 +      sed->y = set->next->lit;
 300.653 +      xassert(sed->y.neg == 0 || sed->y.neg == 1);
 300.654 +      sed->z = set->next->next->lit;
 300.655 +      xassert(sed->z.neg == 0 || sed->z.neg == 1);
 300.656 +      /* perform encoding s = (x + y + z) % 2 */
 300.657 +      sed->s = npp_add_col(npp);
 300.658 +      sed->s->is_int = 1, sed->s->lb = 0.0, sed->s->ub = 1.0;
 300.659 +      for (x = 0; x <= 1; x++)
 300.660 +      {  for (y = 0; y <= 1; y++)
 300.661 +         {  for (z = 0; z <= 1; z++)
 300.662 +            {  for (s = 0; s <= 1; s++)
 300.663 +               {  if ((x + y + z) % 2 != s)
 300.664 +                  {  /* generate CNF clause to disable infeasible
 300.665 +                        combination */
 300.666 +                     row = npp_add_row(npp);
 300.667 +                     row->lb = 1.0, row->ub = +DBL_MAX;
 300.668 +                     if (x == sed->x.neg)
 300.669 +                        npp_add_aij(npp, row, sed->x.col, +1.0);
 300.670 +                     else
 300.671 +                     {  npp_add_aij(npp, row, sed->x.col, -1.0);
 300.672 +                        row->lb -= 1.0;
 300.673 +                     }
 300.674 +                     if (y == sed->y.neg)
 300.675 +                        npp_add_aij(npp, row, sed->y.col, +1.0);
 300.676 +                     else
 300.677 +                     {  npp_add_aij(npp, row, sed->y.col, -1.0);
 300.678 +                        row->lb -= 1.0;
 300.679 +                     }
 300.680 +                     if (z == sed->z.neg)
 300.681 +                        npp_add_aij(npp, row, sed->z.col, +1.0);
 300.682 +                     else
 300.683 +                     {  npp_add_aij(npp, row, sed->z.col, -1.0);
 300.684 +                        row->lb -= 1.0;
 300.685 +                     }
 300.686 +                     if (s == 0)
 300.687 +                        npp_add_aij(npp, row, sed->s, +1.0);
 300.688 +                     else
 300.689 +                     {  npp_add_aij(npp, row, sed->s, -1.0);
 300.690 +                        row->lb -= 1.0;
 300.691 +                     }
 300.692 +                  }
 300.693 +               }
 300.694 +            }
 300.695 +         }
 300.696 +      }
 300.697 +      /* perform encoding c = (x + y + z) / 2 */
 300.698 +      sed->c = npp_add_col(npp);
 300.699 +      sed->c->is_int = 1, sed->c->lb = 0.0, sed->c->ub = 1.0;
 300.700 +      for (x = 0; x <= 1; x++)
 300.701 +      {  for (y = 0; y <= 1; y++)
 300.702 +         {  for (z = 0; z <= 1; z++)
 300.703 +            {  for (c = 0; c <= 1; c++)
 300.704 +               {  if ((x + y + z) / 2 != c)
 300.705 +                  {  /* generate CNF clause to disable infeasible
 300.706 +                        combination */
 300.707 +                     row = npp_add_row(npp);
 300.708 +                     row->lb = 1.0, row->ub = +DBL_MAX;
 300.709 +                     if (x == sed->x.neg)
 300.710 +                        npp_add_aij(npp, row, sed->x.col, +1.0);
 300.711 +                     else
 300.712 +                     {  npp_add_aij(npp, row, sed->x.col, -1.0);
 300.713 +                        row->lb -= 1.0;
 300.714 +                     }
 300.715 +                     if (y == sed->y.neg)
 300.716 +                        npp_add_aij(npp, row, sed->y.col, +1.0);
 300.717 +                     else
 300.718 +                     {  npp_add_aij(npp, row, sed->y.col, -1.0);
 300.719 +                        row->lb -= 1.0;
 300.720 +                     }
 300.721 +                     if (z == sed->z.neg)
 300.722 +                        npp_add_aij(npp, row, sed->z.col, +1.0);
 300.723 +                     else
 300.724 +                     {  npp_add_aij(npp, row, sed->z.col, -1.0);
 300.725 +                        row->lb -= 1.0;
 300.726 +                     }
 300.727 +                     if (c == 0)
 300.728 +                        npp_add_aij(npp, row, sed->c, +1.0);
 300.729 +                     else
 300.730 +                     {  npp_add_aij(npp, row, sed->c, -1.0);
 300.731 +                        row->lb -= 1.0;
 300.732 +                     }
 300.733 +                  }
 300.734 +               }
 300.735 +            }
 300.736 +         }
 300.737 +      }
 300.738 +      return;
 300.739 +}
 300.740 +
 300.741 +/***********************************************************************
 300.742 +*  npp_sat_encode_sum_ax - encode linear combination of 0-1 variables
 300.743 +*
 300.744 +*  PURPOSE
 300.745 +*
 300.746 +*  Given a linear combination of binary variables:
 300.747 +*
 300.748 +*     sum a[j] x[j],                                                 (1)
 300.749 +*      j
 300.750 +*
 300.751 +*  which is the linear form of the specified row, this routine encodes
 300.752 +*  (i.e. translates to CNF) the following equality:
 300.753 +*
 300.754 +*                        n
 300.755 +*     sum |a[j]| t[j] = sum 2**(k-1) * y[k],                         (2)
 300.756 +*      j                k=1
 300.757 +*
 300.758 +*  where t[j] = x[j] (if a[j] > 0) or t[j] = 1 - x[j] (if a[j] < 0),
 300.759 +*  and y[k] is either t[j] or a new literal created by the routine or
 300.760 +*  a constant zero. Note that the sum in the right-hand side of (2) can
 300.761 +*  be thought as a n-bit representation of the sum in the left-hand
 300.762 +*  side, which is a non-negative integer number.
 300.763 +*
 300.764 +*  ALGORITHM
 300.765 +*
 300.766 +*  First, the number of bits, n, sufficient to represent any value in
 300.767 +*  the left-hand side of (2) is determined. Obviously, n is the number
 300.768 +*  of bits sufficient to represent the sum (sum |a[j]|).
 300.769 +*
 300.770 +*  Let
 300.771 +*
 300.772 +*               n
 300.773 +*     |a[j]| = sum 2**(k-1) b[j,k],                                  (3)
 300.774 +*              k=1
 300.775 +*
 300.776 +*  where b[j,k] is k-th bit in a n-bit representation of |a[j]|. Then
 300.777 +*
 300.778 +*                          m            n
 300.779 +*     sum |a[j]| * t[j] = sum 2**(k-1) sum b[j,k] * t[j].            (4)
 300.780 +*      j                  k=1          j=1
 300.781 +*
 300.782 +*  Introducing the set
 300.783 +*
 300.784 +*     J[k] = { j : b[j,k] = 1 }                                      (5)
 300.785 +*
 300.786 +*  allows rewriting (4) as follows:
 300.787 +*
 300.788 +*                          n
 300.789 +*     sum |a[j]| * t[j] = sum 2**(k-1)  sum    t[j].                 (6)
 300.790 +*      j                  k=1         j in J[k]
 300.791 +*
 300.792 +*  Thus, our goal is to provide |J[k]| <= 1 for all k, in which case
 300.793 +*  we will have the representation (1).
 300.794 +*
 300.795 +*  Let |J[k]| = 2, i.e. J[k] has exactly two literals u and v. In this
 300.796 +*  case we can apply the following transformation:
 300.797 +*
 300.798 +*     u + v = s + 2 * c,                                             (7)
 300.799 +*
 300.800 +*  where s and c are, respectively, low (sum) and high (carry) bits of
 300.801 +*  the sum of two bits. This allows to replace two literals u and v in
 300.802 +*  J[k] by one literal s, and carry out literal c to J[k+1].
 300.803 +*
 300.804 +*  If |J[k]| >= 3, i.e. J[k] has at least three literals u, v, and w,
 300.805 +*  we can apply the following transformation:
 300.806 +*
 300.807 +*     u + v + w = s + 2 * c.                                         (8)
 300.808 +*
 300.809 +*  Again, literal s replaces literals u, v, and w in J[k], and literal
 300.810 +*  c goes into J[k+1].
 300.811 +*
 300.812 +*  On exit the routine stores each literal from J[k] in element y[k],
 300.813 +*  1 <= k <= n. If J[k] is empty, y[k] is set to constant false.
 300.814 +*
 300.815 +*  RETURNS
 300.816 +*
 300.817 +*  The routine returns n, the number of literals in the right-hand side
 300.818 +*  of (2), 0 <= n <= NBIT_MAX. If the sum (sum |a[j]|) is too large, so
 300.819 +*  more than NBIT_MAX (= 31) literals are needed to encode the original
 300.820 +*  linear combination, the routine returns a negative value. */
 300.821 +
 300.822 +#define NBIT_MAX 31
 300.823 +/* maximal number of literals in the right hand-side of (2) */
 300.824 +
 300.825 +static NPPLSE *remove_lse(NPP *npp, NPPLSE *set, NPPCOL *col)
 300.826 +{     /* remove specified literal from specified literal set */
 300.827 +      NPPLSE *lse, *prev = NULL;
 300.828 +      for (lse = set; lse != NULL; prev = lse, lse = lse->next)
 300.829 +         if (lse->lit.col == col) break;
 300.830 +      xassert(lse != NULL);
 300.831 +      if (prev == NULL)
 300.832 +         set = lse->next;
 300.833 +      else
 300.834 +         prev->next = lse->next;
 300.835 +      dmp_free_atom(npp->pool, lse, sizeof(NPPLSE));
 300.836 +      return set;
 300.837 +}
 300.838 +
 300.839 +int npp_sat_encode_sum_ax(NPP *npp, NPPROW *row, NPPLIT y[])
 300.840 +{     NPPAIJ *aij;
 300.841 +      NPPLSE *set[1+NBIT_MAX], *lse;
 300.842 +      NPPSED sed;
 300.843 +      int k, n, temp;
 300.844 +      double sum;
 300.845 +      /* compute the sum (sum |a[j]|) */
 300.846 +      sum = 0.0;
 300.847 +      for (aij = row->ptr; aij != NULL; aij = aij->r_next)
 300.848 +         sum += fabs(aij->val);
 300.849 +      /* determine n, the number of bits in the sum */
 300.850 +      temp = (int)sum;
 300.851 +      if ((double)temp != sum)
 300.852 +         return -1; /* integer arithmetic error */
 300.853 +      for (n = 0; temp > 0; n++, temp >>= 1);
 300.854 +      xassert(0 <= n && n <= NBIT_MAX);
 300.855 +      /* build initial sets J[k], 1 <= k <= n; see (5) */
 300.856 +      /* set[k] is a pointer to the list of literals in J[k] */
 300.857 +      for (k = 1; k <= n; k++)
 300.858 +         set[k] = NULL;
 300.859 +      for (aij = row->ptr; aij != NULL; aij = aij->r_next)
 300.860 +      {  temp = (int)fabs(aij->val);
 300.861 +         xassert((int)temp == fabs(aij->val));
 300.862 +         for (k = 1; temp > 0; k++, temp >>= 1)
 300.863 +         {  if (temp & 1)
 300.864 +            {  xassert(k <= n);
 300.865 +               lse = dmp_get_atom(npp->pool, sizeof(NPPLSE));
 300.866 +               lse->lit.col = aij->col;
 300.867 +               lse->lit.neg = (aij->val > 0.0 ? 0 : 1);
 300.868 +               lse->next = set[k];
 300.869 +               set[k] = lse;
 300.870 +            }
 300.871 +         }
 300.872 +      }
 300.873 +      /* main transformation loop */
 300.874 +      for (k = 1; k <= n; k++)
 300.875 +      {  /* reduce J[k] and set y[k] */
 300.876 +         for (;;)
 300.877 +         {  if (set[k] == NULL)
 300.878 +            {  /* J[k] is empty */
 300.879 +               /* set y[k] to constant false */
 300.880 +               y[k].col = NULL, y[k].neg = 0;
 300.881 +               break;
 300.882 +            }
 300.883 +            if (set[k]->next == NULL)
 300.884 +            {  /* J[k] contains one literal */
 300.885 +               /* set y[k] to that literal */
 300.886 +               y[k] = set[k]->lit;
 300.887 +               dmp_free_atom(npp->pool, set[k], sizeof(NPPLSE));
 300.888 +               break;
 300.889 +            }
 300.890 +            if (set[k]->next->next == NULL)
 300.891 +            {  /* J[k] contains two literals */
 300.892 +               /* apply transformation (7) */
 300.893 +               npp_sat_encode_sum2(npp, set[k], &sed);
 300.894 +            }
 300.895 +            else
 300.896 +            {  /* J[k] contains at least three literals */
 300.897 +               /* apply transformation (8) */
 300.898 +               npp_sat_encode_sum3(npp, set[k], &sed);
 300.899 +               /* remove third literal from set[k] */
 300.900 +               set[k] = remove_lse(npp, set[k], sed.z.col);
 300.901 +            }
 300.902 +            /* remove second literal from set[k] */
 300.903 +            set[k] = remove_lse(npp, set[k], sed.y.col);
 300.904 +            /* remove first literal from set[k] */
 300.905 +            set[k] = remove_lse(npp, set[k], sed.x.col);
 300.906 +            /* include new literal s to set[k] */
 300.907 +            lse = dmp_get_atom(npp->pool, sizeof(NPPLSE));
 300.908 +            lse->lit.col = sed.s, lse->lit.neg = 0;
 300.909 +            lse->next = set[k];
 300.910 +            set[k] = lse;
 300.911 +            /* include new literal c to set[k+1] */
 300.912 +            xassert(k < n); /* FIXME: can "overflow" happen? */
 300.913 +            lse = dmp_get_atom(npp->pool, sizeof(NPPLSE));
 300.914 +            lse->lit.col = sed.c, lse->lit.neg = 0;
 300.915 +            lse->next = set[k+1];
 300.916 +            set[k+1] = lse;
 300.917 +         }
 300.918 +      }
 300.919 +      return n;
 300.920 +}
 300.921 +
 300.922 +/***********************************************************************
 300.923 +*  npp_sat_normalize_clause - normalize clause
 300.924 +*
 300.925 +*  This routine normalizes the specified clause, which is a disjunction
 300.926 +*  of literals, by replacing multiple literals, which refer to the same
 300.927 +*  binary variable, with a single literal.
 300.928 +*
 300.929 +*  On exit the routine returns the number of literals in the resulting
 300.930 +*  clause. However, if the specified clause includes both a literal and
 300.931 +*  its negation, the routine returns a negative value meaning that the
 300.932 +*  clause is equivalent to the value true. */
 300.933 +
 300.934 +int npp_sat_normalize_clause(NPP *npp, int size, NPPLIT lit[])
 300.935 +{     int j, k, new_size;
 300.936 +      xassert(npp == npp);
 300.937 +      xassert(size >= 0);
 300.938 +      new_size = 0;
 300.939 +      for (k = 1; k <= size; k++)
 300.940 +      {  for (j = 1; j <= new_size; j++)
 300.941 +         {  if (lit[k].col == lit[j].col)
 300.942 +            {  /* lit[k] refers to the same variable as lit[j], which
 300.943 +                  is already included in the resulting clause */
 300.944 +               if (lit[k].neg == lit[j].neg)
 300.945 +               {  /* ignore lit[k] due to the idempotent law */
 300.946 +                  goto skip;
 300.947 +               }
 300.948 +               else
 300.949 +               {  /* lit[k] is NOT lit[j]; the clause is equivalent to
 300.950 +                     the value true */
 300.951 +                  return -1;
 300.952 +               }
 300.953 +            }
 300.954 +         }
 300.955 +         /* include lit[k] in the resulting clause */
 300.956 +         lit[++new_size] = lit[k];
 300.957 +skip:    ;
 300.958 +      }
 300.959 +      return new_size;
 300.960 +}
 300.961 +
 300.962 +/***********************************************************************
 300.963 +*  npp_sat_encode_clause - translate clause to cover inequality
 300.964 +*
 300.965 +*  Given a clause
 300.966 +*
 300.967 +*     OR  t[j],                                                      (1)
 300.968 +*   j in J
 300.969 +*
 300.970 +*  where t[j] is a literal, i.e. t[j] = x[j] or t[j] = NOT x[j], this
 300.971 +*  routine translates it to the following equivalent cover inequality,
 300.972 +*  which is added to the transformed problem:
 300.973 +*
 300.974 +*     sum t[j] >= 1,                                                 (2)
 300.975 +*   j in J
 300.976 +*
 300.977 +*  where t[j] = x[j] or t[j] = 1 - x[j].
 300.978 +*
 300.979 +*  If necessary, the clause should be normalized before a call to this
 300.980 +*  routine. */
 300.981 +
 300.982 +NPPROW *npp_sat_encode_clause(NPP *npp, int size, NPPLIT lit[])
 300.983 +{     NPPROW *row;
 300.984 +      int k;
 300.985 +      xassert(size >= 1);
 300.986 +      row = npp_add_row(npp);
 300.987 +      row->lb = 1.0, row->ub = +DBL_MAX;
 300.988 +      for (k = 1; k <= size; k++)
 300.989 +      {  xassert(lit[k].col != NULL);
 300.990 +         if (lit[k].neg == 0)
 300.991 +            npp_add_aij(npp, row, lit[k].col, +1.0);
 300.992 +         else if (lit[k].neg == 1)
 300.993 +         {  npp_add_aij(npp, row, lit[k].col, -1.0);
 300.994 +            row->lb -= 1.0;
 300.995 +         }
 300.996 +         else
 300.997 +            xassert(lit != lit);
 300.998 +      }
 300.999 +      return row;
300.1000 +}
300.1001 +
300.1002 +/***********************************************************************
300.1003 +*  npp_sat_encode_geq - encode "not less than" constraint
300.1004 +*
300.1005 +*  PURPOSE
300.1006 +*
300.1007 +*  This routine translates to CNF the following constraint:
300.1008 +*
300.1009 +*      n
300.1010 +*     sum 2**(k-1) * y[k] >= b,                                      (1)
300.1011 +*     k=1
300.1012 +*
300.1013 +*  where y[k] is either a literal (i.e. y[k] = x[k] or y[k] = 1 - x[k])
300.1014 +*  or constant false (zero), b is a given lower bound.
300.1015 +*
300.1016 +*  ALGORITHM
300.1017 +*
300.1018 +*  If b < 0, the constraint is redundant, so assume that b >= 0. Let
300.1019 +*
300.1020 +*          n
300.1021 +*     b = sum 2**(k-1) b[k],                                         (2)
300.1022 +*         k=1
300.1023 +*
300.1024 +*  where b[k] is k-th binary digit of b. (Note that if b >= 2**n and
300.1025 +*  therefore cannot be represented in the form (2), the constraint (1)
300.1026 +*  is infeasible.) In this case the condition (1) is equivalent to the
300.1027 +*  following condition:
300.1028 +*
300.1029 +*     y[n] y[n-1] ... y[2] y[1] >= b[n] b[n-1] ... b[2] b[1],        (3)
300.1030 +*
300.1031 +*  where ">=" is understood lexicographically.
300.1032 +*
300.1033 +*  Algorithmically the condition (3) can be tested as follows:
300.1034 +*
300.1035 +*     for (k = n; k >= 1; k--)
300.1036 +*     {  if (y[k] < b[k])
300.1037 +*           y is less than b;
300.1038 +*        if (y[k] > b[k])
300.1039 +*           y is greater than b;
300.1040 +*     }
300.1041 +*     y is equal to b;
300.1042 +*
300.1043 +*  Thus, y is less than b iff there exists k, 1 <= k <= n, for which
300.1044 +*  the following condition is satisfied:
300.1045 +*
300.1046 +*     y[n] = b[n] AND ... AND y[k+1] = b[k+1] AND y[k] < b[k].       (4)
300.1047 +*
300.1048 +*  Negating the condition (4) we have that y is not less than b iff for
300.1049 +*  all k, 1 <= k <= n, the following condition is satisfied:
300.1050 +*
300.1051 +*     y[n] != b[n] OR ... OR y[k+1] != b[k+1] OR y[k] >= b[k].       (5)
300.1052 +*
300.1053 +*  Note that if b[k] = 0, the literal y[k] >= b[k] is always true, in
300.1054 +*  which case the entire clause (5) is true and can be omitted.
300.1055 +*
300.1056 +*  RETURNS
300.1057 +*
300.1058 +*  Normally the routine returns zero. However, if the constraint (1) is
300.1059 +*  infeasible, the routine returns non-zero. */
300.1060 +
300.1061 +int npp_sat_encode_geq(NPP *npp, int n, NPPLIT y[], int rhs)
300.1062 +{     NPPLIT lit[1+NBIT_MAX];
300.1063 +      int j, k, size, temp, b[1+NBIT_MAX];
300.1064 +      xassert(0 <= n && n <= NBIT_MAX);
300.1065 +      /* if the constraint (1) is redundant, do nothing */
300.1066 +      if (rhs < 0)
300.1067 +         return 0;
300.1068 +      /* determine binary digits of b according to (2) */
300.1069 +      for (k = 1, temp = rhs; k <= n; k++, temp >>= 1)
300.1070 +         b[k] = temp & 1;
300.1071 +      if (temp != 0)
300.1072 +      {  /* b >= 2**n; the constraint (1) is infeasible */
300.1073 +         return 1;
300.1074 +      }
300.1075 +      /* main transformation loop */
300.1076 +      for (k = 1; k <= n; k++)
300.1077 +      {  /* build the clause (5) for current k */
300.1078 +         size = 0; /* clause size = number of literals */
300.1079 +         /* add literal y[k] >= b[k] */
300.1080 +         if (b[k] == 0)
300.1081 +         {  /* b[k] = 0 -> the literal is true */
300.1082 +            goto skip;
300.1083 +         }
300.1084 +         else if (y[k].col == NULL)
300.1085 +         {  /* y[k] = 0, b[k] = 1 -> the literal is false */
300.1086 +            xassert(y[k].neg == 0);
300.1087 +         }
300.1088 +         else
300.1089 +         {  /* add literal y[k] = 1 */
300.1090 +            lit[++size] = y[k];
300.1091 +         }
300.1092 +         for (j = k+1; j <= n; j++)
300.1093 +         {  /* add literal y[j] != b[j] */
300.1094 +            if (y[j].col == NULL)
300.1095 +            {  xassert(y[j].neg == 0);
300.1096 +               if (b[j] == 0)
300.1097 +               {  /* y[j] = 0, b[j] = 0 -> the literal is false */
300.1098 +                  continue;
300.1099 +               }
300.1100 +               else
300.1101 +               {  /* y[j] = 0, b[j] = 1 -> the literal is true */
300.1102 +                  goto skip;
300.1103 +               }
300.1104 +            }
300.1105 +            else
300.1106 +            {  lit[++size] = y[j];
300.1107 +               if (b[j] != 0)
300.1108 +                  lit[size].neg = 1 - lit[size].neg;
300.1109 +            }
300.1110 +         }
300.1111 +         /* normalize the clause */
300.1112 +         size = npp_sat_normalize_clause(npp, size, lit);
300.1113 +         if (size < 0)
300.1114 +         {  /* the clause is equivalent to the value true */
300.1115 +            goto skip;
300.1116 +         }
300.1117 +         if (size == 0)
300.1118 +         {  /* the clause is equivalent to the value false; this means
300.1119 +               that the constraint (1) is infeasible */
300.1120 +            return 2;
300.1121 +         }
300.1122 +         /* translate the clause to corresponding cover inequality */
300.1123 +         npp_sat_encode_clause(npp, size, lit);
300.1124 +skip:    ;
300.1125 +      }
300.1126 +      return 0;
300.1127 +}
300.1128 +
300.1129 +/***********************************************************************
300.1130 +*  npp_sat_encode_leq - encode "not greater than" constraint
300.1131 +*
300.1132 +*  PURPOSE
300.1133 +*
300.1134 +*  This routine translates to CNF the following constraint:
300.1135 +*
300.1136 +*      n
300.1137 +*     sum 2**(k-1) * y[k] <= b,                                      (1)
300.1138 +*     k=1
300.1139 +*
300.1140 +*  where y[k] is either a literal (i.e. y[k] = x[k] or y[k] = 1 - x[k])
300.1141 +*  or constant false (zero), b is a given upper bound.
300.1142 +*
300.1143 +*  ALGORITHM
300.1144 +*
300.1145 +*  If b < 0, the constraint is infeasible, so assume that b >= 0. Let
300.1146 +*
300.1147 +*          n
300.1148 +*     b = sum 2**(k-1) b[k],                                         (2)
300.1149 +*         k=1
300.1150 +*
300.1151 +*  where b[k] is k-th binary digit of b. (Note that if b >= 2**n and
300.1152 +*  therefore cannot be represented in the form (2), the constraint (1)
300.1153 +*  is redundant.) In this case the condition (1) is equivalent to the
300.1154 +*  following condition:
300.1155 +*
300.1156 +*     y[n] y[n-1] ... y[2] y[1] <= b[n] b[n-1] ... b[2] b[1],        (3)
300.1157 +*
300.1158 +*  where "<=" is understood lexicographically.
300.1159 +*
300.1160 +*  Algorithmically the condition (3) can be tested as follows:
300.1161 +*
300.1162 +*     for (k = n; k >= 1; k--)
300.1163 +*     {  if (y[k] < b[k])
300.1164 +*           y is less than b;
300.1165 +*        if (y[k] > b[k])
300.1166 +*           y is greater than b;
300.1167 +*     }
300.1168 +*     y is equal to b;
300.1169 +*
300.1170 +*  Thus, y is greater than b iff there exists k, 1 <= k <= n, for which
300.1171 +*  the following condition is satisfied:
300.1172 +*
300.1173 +*     y[n] = b[n] AND ... AND y[k+1] = b[k+1] AND y[k] > b[k].       (4)
300.1174 +*
300.1175 +*  Negating the condition (4) we have that y is not greater than b iff
300.1176 +*  for all k, 1 <= k <= n, the following condition is satisfied:
300.1177 +*
300.1178 +*     y[n] != b[n] OR ... OR y[k+1] != b[k+1] OR y[k] <= b[k].       (5)
300.1179 +*
300.1180 +*  Note that if b[k] = 1, the literal y[k] <= b[k] is always true, in
300.1181 +*  which case the entire clause (5) is true and can be omitted.
300.1182 +*
300.1183 +*  RETURNS
300.1184 +*
300.1185 +*  Normally the routine returns zero. However, if the constraint (1) is
300.1186 +*  infeasible, the routine returns non-zero. */
300.1187 +
300.1188 +int npp_sat_encode_leq(NPP *npp, int n, NPPLIT y[], int rhs)
300.1189 +{     NPPLIT lit[1+NBIT_MAX];
300.1190 +      int j, k, size, temp, b[1+NBIT_MAX];
300.1191 +      xassert(0 <= n && n <= NBIT_MAX);
300.1192 +      /* check if the constraint (1) is infeasible */
300.1193 +      if (rhs < 0)
300.1194 +         return 1;
300.1195 +      /* determine binary digits of b according to (2) */
300.1196 +      for (k = 1, temp = rhs; k <= n; k++, temp >>= 1)
300.1197 +         b[k] = temp & 1;
300.1198 +      if (temp != 0)
300.1199 +      {  /* b >= 2**n; the constraint (1) is redundant */
300.1200 +         return 0;
300.1201 +      }
300.1202 +      /* main transformation loop */
300.1203 +      for (k = 1; k <= n; k++)
300.1204 +      {  /* build the clause (5) for current k */
300.1205 +         size = 0; /* clause size = number of literals */
300.1206 +         /* add literal y[k] <= b[k] */
300.1207 +         if (b[k] == 1)
300.1208 +         {  /* b[k] = 1 -> the literal is true */
300.1209 +            goto skip;
300.1210 +         }
300.1211 +         else if (y[k].col == NULL)
300.1212 +         {  /* y[k] = 0, b[k] = 0 -> the literal is true */
300.1213 +            xassert(y[k].neg == 0);
300.1214 +            goto skip;
300.1215 +         }
300.1216 +         else
300.1217 +         {  /* add literal y[k] = 0 */
300.1218 +            lit[++size] = y[k];
300.1219 +            lit[size].neg = 1 - lit[size].neg;
300.1220 +         }
300.1221 +         for (j = k+1; j <= n; j++)
300.1222 +         {  /* add literal y[j] != b[j] */
300.1223 +            if (y[j].col == NULL)
300.1224 +            {  xassert(y[j].neg == 0);
300.1225 +               if (b[j] == 0)
300.1226 +               {  /* y[j] = 0, b[j] = 0 -> the literal is false */
300.1227 +                  continue;
300.1228 +               }
300.1229 +               else
300.1230 +               {  /* y[j] = 0, b[j] = 1 -> the literal is true */
300.1231 +                  goto skip;
300.1232 +               }
300.1233 +            }
300.1234 +            else
300.1235 +            {  lit[++size] = y[j];
300.1236 +               if (b[j] != 0)
300.1237 +                  lit[size].neg = 1 - lit[size].neg;
300.1238 +            }
300.1239 +         }
300.1240 +         /* normalize the clause */
300.1241 +         size = npp_sat_normalize_clause(npp, size, lit);
300.1242 +         if (size < 0)
300.1243 +         {  /* the clause is equivalent to the value true */
300.1244 +            goto skip;
300.1245 +         }
300.1246 +         if (size == 0)
300.1247 +         {  /* the clause is equivalent to the value false; this means
300.1248 +               that the constraint (1) is infeasible */
300.1249 +            return 2;
300.1250 +         }
300.1251 +         /* translate the clause to corresponding cover inequality */
300.1252 +         npp_sat_encode_clause(npp, size, lit);
300.1253 +skip:    ;
300.1254 +      }
300.1255 +      return 0;
300.1256 +}
300.1257 +
300.1258 +/***********************************************************************
300.1259 +*  npp_sat_encode_row - encode constraint (row) of general type
300.1260 +*
300.1261 +*  PURPOSE
300.1262 +*
300.1263 +*  This routine translates to CNF the following constraint (row):
300.1264 +*
300.1265 +*     L <= sum a[j] x[j] <= U,                                       (1)
300.1266 +*           j
300.1267 +*
300.1268 +*  where all x[j] are binary variables.
300.1269 +*
300.1270 +*  ALGORITHM
300.1271 +*
300.1272 +*  First, the routine performs substitution x[j] = t[j] for j in J+
300.1273 +*  and x[j] = 1 - t[j] for j in J-, where J+ = { j : a[j] > 0 } and
300.1274 +*  J- = { j : a[j] < 0 }. This gives:
300.1275 +*
300.1276 +*     L <=  sum  a[j] t[j] +   sum  a[j] (1 - t[j]) <= U  ==>
300.1277 +*         j in J+            j in J-
300.1278 +*
300.1279 +*     L' <= sum |a[j]| t[j] <= U',                                   (2)
300.1280 +*            j
300.1281 +*
300.1282 +*  where
300.1283 +*
300.1284 +*     L' = L -   sum  a[j],   U' = U -   sum  a[j].                  (3)
300.1285 +*              j in J-                 j in J-
300.1286 +*
300.1287 +*  (Actually only new bounds L' and U' are computed.)
300.1288 +*
300.1289 +*  Then the routine translates to CNF the following equality:
300.1290 +*
300.1291 +*                        n
300.1292 +*     sum |a[j]| t[j] = sum 2**(k-1) * y[k],                         (4)
300.1293 +*      j                k=1
300.1294 +*
300.1295 +*  where y[k] is either some t[j] or a new literal or a constant zero
300.1296 +*  (see the routine npp_sat_encode_sum_ax).
300.1297 +*
300.1298 +*  Finally, the routine translates to CNF the following conditions:
300.1299 +*
300.1300 +*      n
300.1301 +*     sum 2**(k-1) * y[k] >= L'                                      (5)
300.1302 +*     k=1
300.1303 +*
300.1304 +*  and
300.1305 +*
300.1306 +*      n
300.1307 +*     sum 2**(k-1) * y[k] <= U'                                      (6)
300.1308 +*     k=1
300.1309 +*
300.1310 +*  (see the routines npp_sat_encode_geq and npp_sat_encode_leq).
300.1311 +*
300.1312 +*  All resulting clauses are encoded as cover inequalities and included
300.1313 +*  into the transformed problem.
300.1314 +*
300.1315 +*  Note that on exit the routine removes the specified constraint (row)
300.1316 +*  from the original problem.
300.1317 +*
300.1318 +*  RETURNS
300.1319 +*
300.1320 +*  The routine returns one of the following codes:
300.1321 +*
300.1322 +*  0 - translation was successful;
300.1323 +*  1 - constraint (1) was found infeasible;
300.1324 +*  2 - integer arithmetic error occured. */
300.1325 +
300.1326 +int npp_sat_encode_row(NPP *npp, NPPROW *row)
300.1327 +{     NPPAIJ *aij;
300.1328 +      NPPLIT y[1+NBIT_MAX];
300.1329 +      int n, rhs;
300.1330 +      double lb, ub;
300.1331 +      /* the row should not be free */
300.1332 +      xassert(!(row->lb == -DBL_MAX && row->ub == +DBL_MAX));
300.1333 +      /* compute new bounds L' and U' (3) */
300.1334 +      lb = row->lb;
300.1335 +      ub = row->ub;
300.1336 +      for (aij = row->ptr; aij != NULL; aij = aij->r_next)
300.1337 +      {  if (aij->val < 0.0)
300.1338 +         {  if (lb != -DBL_MAX)
300.1339 +               lb -= aij->val;
300.1340 +            if (ub != -DBL_MAX)
300.1341 +               ub -= aij->val;
300.1342 +         }
300.1343 +      }
300.1344 +      /* encode the equality (4) */
300.1345 +      n = npp_sat_encode_sum_ax(npp, row, y);
300.1346 +      if (n < 0)
300.1347 +         return 2; /* integer arithmetic error */
300.1348 +      /* encode the condition (5) */
300.1349 +      if (lb != -DBL_MAX)
300.1350 +      {  rhs = (int)lb;
300.1351 +         if ((double)rhs != lb)
300.1352 +            return 2; /* integer arithmetic error */
300.1353 +         if (npp_sat_encode_geq(npp, n, y, rhs) != 0)
300.1354 +            return 1; /* original constraint is infeasible */
300.1355 +      }
300.1356 +      /* encode the condition (6) */
300.1357 +      if (ub != +DBL_MAX)
300.1358 +      {  rhs = (int)ub;
300.1359 +         if ((double)rhs != ub)
300.1360 +            return 2; /* integer arithmetic error */
300.1361 +         if (npp_sat_encode_leq(npp, n, y, rhs) != 0)
300.1362 +            return 1; /* original constraint is infeasible */
300.1363 +      }
300.1364 +      /* remove the specified row from the problem */
300.1365 +      npp_del_row(npp, row);
300.1366 +      return 0;
300.1367 +}
300.1368 +
300.1369 +/***********************************************************************
300.1370 +*  npp_sat_encode_prob - encode 0-1 feasibility problem
300.1371 +*
300.1372 +*  This routine translates the specified 0-1 feasibility problem to an
300.1373 +*  equivalent SAT-CNF problem.
300.1374 +*
300.1375 +*  N.B. Currently this is a very crude implementation.
300.1376 +*
300.1377 +*  RETURNS
300.1378 +*
300.1379 +*  0           success;
300.1380 +*
300.1381 +*  GLP_ENOPFS  primal/integer infeasibility detected;
300.1382 +*
300.1383 +*  GLP_ERANGE  integer overflow occured. */
300.1384 +
300.1385 +int npp_sat_encode_prob(NPP *npp)
300.1386 +{     NPPROW *row, *next_row, *prev_row;
300.1387 +      NPPCOL *col, *next_col;
300.1388 +      int cover = 0, pack = 0, partn = 0, ret;
300.1389 +      /* process and remove free rows */
300.1390 +      for (row = npp->r_head; row != NULL; row = next_row)
300.1391 +      {  next_row = row->next;
300.1392 +         if (row->lb == -DBL_MAX && row->ub == +DBL_MAX)
300.1393 +            npp_sat_free_row(npp, row);
300.1394 +      }
300.1395 +      /* process and remove fixed columns */
300.1396 +      for (col = npp->c_head; col != NULL; col = next_col)
300.1397 +      {  next_col = col->next;
300.1398 +         if (col->lb == col->ub)
300.1399 +            xassert(npp_sat_fixed_col(npp, col) == 0);
300.1400 +      }
300.1401 +      /* only binary variables should remain */
300.1402 +      for (col = npp->c_head; col != NULL; col = col->next)
300.1403 +         xassert(col->is_int && col->lb == 0.0 && col->ub == 1.0);
300.1404 +      /* new rows may be added to the end of the row list, so we walk
300.1405 +         from the end to beginning of the list */
300.1406 +      for (row = npp->r_tail; row != NULL; row = prev_row)
300.1407 +      {  prev_row = row->prev;
300.1408 +         /* process special cases */
300.1409 +         ret = npp_sat_is_cover_ineq(npp, row);
300.1410 +         if (ret != 0)
300.1411 +         {  /* row is covering inequality */
300.1412 +            cover++;
300.1413 +            /* since it already encodes a clause, just transform it to
300.1414 +               canonical form */
300.1415 +            if (ret == 2)
300.1416 +            {  xassert(npp_sat_reverse_row(npp, row) == 0);
300.1417 +               ret = npp_sat_is_cover_ineq(npp, row);
300.1418 +            }
300.1419 +            xassert(ret == 1);
300.1420 +            continue;
300.1421 +         }
300.1422 +         ret = npp_sat_is_partn_eq(npp, row);
300.1423 +         if (ret != 0)
300.1424 +         {  /* row is partitioning equality */
300.1425 +            NPPROW *cov;
300.1426 +            NPPAIJ *aij;
300.1427 +            partn++;
300.1428 +            /* transform it to canonical form */
300.1429 +            if (ret == 2)
300.1430 +            {  xassert(npp_sat_reverse_row(npp, row) == 0);
300.1431 +               ret = npp_sat_is_partn_eq(npp, row);
300.1432 +            }
300.1433 +            xassert(ret == 1);
300.1434 +            /* and split it into covering and packing inequalities,
300.1435 +               both in canonical forms */
300.1436 +            cov = npp_add_row(npp);
300.1437 +            cov->lb = row->lb, cov->ub = +DBL_MAX;
300.1438 +            for (aij = row->ptr; aij != NULL; aij = aij->r_next)
300.1439 +               npp_add_aij(npp, cov, aij->col, aij->val);
300.1440 +            xassert(npp_sat_is_cover_ineq(npp, cov) == 1);
300.1441 +            /* the cover inequality already encodes a clause and do
300.1442 +               not need any further processing */
300.1443 +            row->lb = -DBL_MAX;
300.1444 +            xassert(npp_sat_is_pack_ineq(npp, row) == 1);
300.1445 +            /* the packing inequality will be processed below */
300.1446 +            pack--;
300.1447 +         }
300.1448 +         ret = npp_sat_is_pack_ineq(npp, row);
300.1449 +         if (ret != 0)
300.1450 +         {  /* row is packing inequality */
300.1451 +            NPPROW *rrr;
300.1452 +            int nlit, desired_nlit = 4;
300.1453 +            pack++;
300.1454 +            /* transform it to canonical form */
300.1455 +            if (ret == 2)
300.1456 +            {  xassert(npp_sat_reverse_row(npp, row) == 0);
300.1457 +               ret = npp_sat_is_pack_ineq(npp, row);
300.1458 +            }
300.1459 +            xassert(ret == 1);
300.1460 +            /* process the packing inequality */
300.1461 +            for (;;)
300.1462 +            {  /* determine the number of literals in the remaining
300.1463 +                  inequality */
300.1464 +               nlit = npp_row_nnz(npp, row);
300.1465 +               if (nlit <= desired_nlit)
300.1466 +                  break;
300.1467 +               /* split the current inequality into one having not more
300.1468 +                  than desired_nlit literals and remaining one */
300.1469 +               rrr = npp_sat_split_pack(npp, row, desired_nlit-1);
300.1470 +               /* translate the former inequality to CNF and remove it
300.1471 +                  from the original problem */
300.1472 +               npp_sat_encode_pack(npp, rrr);
300.1473 +            }
300.1474 +            /* translate the remaining inequality to CNF and remove it
300.1475 +               from the original problem */
300.1476 +            npp_sat_encode_pack(npp, row);
300.1477 +            continue;
300.1478 +         }
300.1479 +         /* translate row of general type to CNF and remove it from the
300.1480 +            original problem */
300.1481 +         ret = npp_sat_encode_row(npp, row);
300.1482 +         if (ret == 0)
300.1483 +            ;
300.1484 +         else if (ret == 1)
300.1485 +            ret = GLP_ENOPFS;
300.1486 +         else if (ret == 2)
300.1487 +            ret = GLP_ERANGE;
300.1488 +         else
300.1489 +            xassert(ret != ret);
300.1490 +         if (ret != 0)
300.1491 +            goto done;
300.1492 +      }
300.1493 +      ret = 0;
300.1494 +      if (cover != 0)
300.1495 +         xprintf("%d covering inequalities\n", cover);
300.1496 +      if (pack != 0)
300.1497 +         xprintf("%d packing inequalities\n", pack);
300.1498 +      if (partn != 0)
300.1499 +         xprintf("%d partitioning equalities\n", partn);
300.1500 +done: return ret;
300.1501 +}
300.1502 +
300.1503 +/* eof */
   301.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
   301.2 +++ b/deps/glpk/src/glpqmd.c	Sun Nov 06 20:59:10 2011 +0100
   301.3 @@ -0,0 +1,584 @@
   301.4 +/* glpqmd.c (quotient minimum degree algorithm) */
   301.5 +
   301.6 +/***********************************************************************
   301.7 +*  This code is part of GLPK (GNU Linear Programming Kit).
   301.8 +*
   301.9 +*  THIS CODE IS THE RESULT OF TRANSLATION OF THE FORTRAN SUBROUTINES
  301.10 +*  GENQMD, QMDRCH, QMDQT, QMDUPD, AND QMDMRG FROM THE BOOK:
  301.11 +*
  301.12 +*  ALAN GEORGE, JOSEPH W-H LIU. COMPUTER SOLUTION OF LARGE SPARSE
  301.13 +*  POSITIVE DEFINITE SYSTEMS. PRENTICE-HALL, 1981.
  301.14 +*
  301.15 +*  THE TRANSLATION HAS BEEN DONE WITH THE PERMISSION OF THE AUTHORS
  301.16 +*  OF THE ORIGINAL FORTRAN SUBROUTINES: ALAN GEORGE AND JOSEPH LIU,
  301.17 +*  UNIVERSITY OF WATERLOO, WATERLOO, ONTARIO, CANADA.
  301.18 +*
  301.19 +*  The translation was made by Andrew Makhorin <mao@gnu.org>.
  301.20 +*
  301.21 +*  GLPK is free software: you can redistribute it and/or modify it
  301.22 +*  under the terms of the GNU General Public License as published by
  301.23 +*  the Free Software Foundation, either version 3 of the License, or
  301.24 +*  (at your option) any later version.
  301.25 +*
  301.26 +*  GLPK is distributed in the hope that it will be useful, but WITHOUT
  301.27 +*  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
  301.28 +*  or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
  301.29 +*  License for more details.
  301.30 +*
  301.31 +*  You should have received a copy of the GNU General Public License
  301.32 +*  along with GLPK. If not, see <http://www.gnu.org/licenses/>.
  301.33 +***********************************************************************/
  301.34 +
  301.35 +#include "glpqmd.h"
  301.36 +
  301.37 +/***********************************************************************
  301.38 +*  NAME
  301.39 +*
  301.40 +*  genqmd - GENeral Quotient Minimum Degree algorithm
  301.41 +*
  301.42 +*  SYNOPSIS
  301.43 +*
  301.44 +*  #include "glpqmd.h"
  301.45 +*  void genqmd(int *neqns, int xadj[], int adjncy[], int perm[],
  301.46 +*     int invp[], int deg[], int marker[], int rchset[], int nbrhd[],
  301.47 +*     int qsize[], int qlink[], int *nofsub);
  301.48 +*
  301.49 +*  PURPOSE
  301.50 +*
  301.51 +*  This routine implements the minimum degree algorithm. It makes use
  301.52 +*  of the implicit representation of the elimination graph by quotient
  301.53 +*  graphs, and the notion of indistinguishable nodes.
  301.54 +*
  301.55 +*  CAUTION
  301.56 +*
  301.57 +*  The adjancy vector adjncy will be destroyed.
  301.58 +*
  301.59 +*  INPUT PARAMETERS
  301.60 +*
  301.61 +*  neqns  - number of equations;
  301.62 +*  (xadj, adjncy) -
  301.63 +*           the adjancy structure.
  301.64 +*
  301.65 +*  OUTPUT PARAMETERS
  301.66 +*
  301.67 +*  perm   - the minimum degree ordering;
  301.68 +*  invp   - the inverse of perm.
  301.69 +*
  301.70 +*  WORKING PARAMETERS
  301.71 +*
  301.72 +*  deg    - the degree vector. deg[i] is negative means node i has been
  301.73 +*           numbered;
  301.74 +*  marker - a marker vector, where marker[i] is negative means node i
  301.75 +*           has been merged with another nodeand thus can be ignored;
  301.76 +*  rchset - vector used for the reachable set;
  301.77 +*  nbrhd  - vector used for neighborhood set;
  301.78 +*  qsize  - vector used to store the size of indistinguishable
  301.79 +*           supernodes;
  301.80 +*  qlink  - vector used to store indistinguishable nodes, i, qlink[i],
  301.81 +*           qlink[qlink[i]], ... are the members of the supernode
  301.82 +*           represented by i.
  301.83 +*
  301.84 +*  PROGRAM SUBROUTINES
  301.85 +*
  301.86 +*  qmdrch, qmdqt, qmdupd.
  301.87 +***********************************************************************/
  301.88 +
  301.89 +void genqmd(int *_neqns, int xadj[], int adjncy[], int perm[],
  301.90 +      int invp[], int deg[], int marker[], int rchset[], int nbrhd[],
  301.91 +      int qsize[], int qlink[], int *_nofsub)
  301.92 +{     int inode, ip, irch, j, mindeg, ndeg, nhdsze, node, np, num,
  301.93 +         nump1, nxnode, rchsze, search, thresh;
  301.94 +#     define neqns  (*_neqns)
  301.95 +#     define nofsub (*_nofsub)
  301.96 +      /* Initialize degree vector and other working variables. */
  301.97 +      mindeg = neqns;
  301.98 +      nofsub = 0;
  301.99 +      for (node = 1; node <= neqns; node++)
 301.100 +      {  perm[node] = node;
 301.101 +         invp[node] = node;
 301.102 +         marker[node] = 0;
 301.103 +         qsize[node] = 1;
 301.104 +         qlink[node] = 0;
 301.105 +         ndeg = xadj[node+1] - xadj[node];
 301.106 +         deg[node] = ndeg;
 301.107 +         if (ndeg < mindeg) mindeg = ndeg;
 301.108 +      }
 301.109 +      num = 0;
 301.110 +      /* Perform threshold search to get a node of min degree.
 301.111 +         Variable search point to where search should start. */
 301.112 +s200: search = 1;
 301.113 +      thresh = mindeg;
 301.114 +      mindeg = neqns;
 301.115 +s300: nump1 = num + 1;
 301.116 +      if (nump1 > search) search = nump1;
 301.117 +      for (j = search; j <= neqns; j++)
 301.118 +      {  node = perm[j];
 301.119 +         if (marker[node] >= 0)
 301.120 +         {  ndeg = deg[node];
 301.121 +            if (ndeg <= thresh) goto s500;
 301.122 +            if (ndeg < mindeg) mindeg = ndeg;
 301.123 +         }
 301.124 +      }
 301.125 +      goto s200;
 301.126 +      /* Node has minimum degree. Find its reachable sets by calling
 301.127 +         qmdrch. */
 301.128 +s500: search = j;
 301.129 +      nofsub += deg[node];
 301.130 +      marker[node] = 1;
 301.131 +      qmdrch(&node, xadj, adjncy, deg, marker, &rchsze, rchset, &nhdsze,
 301.132 +         nbrhd);
 301.133 +      /* Eliminate all nodes indistinguishable from node. They are given
 301.134 +         by node, qlink[node], ... . */
 301.135 +      nxnode = node;
 301.136 +s600: num++;
 301.137 +      np = invp[nxnode];
 301.138 +      ip = perm[num];
 301.139 +      perm[np] = ip;
 301.140 +      invp[ip] = np;
 301.141 +      perm[num] = nxnode;
 301.142 +      invp[nxnode] = num;
 301.143 +      deg[nxnode] = -1;
 301.144 +      nxnode = qlink[nxnode];
 301.145 +      if (nxnode > 0) goto s600;
 301.146 +      if (rchsze > 0)
 301.147 +      {  /* Update the degrees of the nodes in the reachable set and
 301.148 +            identify indistinguishable nodes. */
 301.149 +         qmdupd(xadj, adjncy, &rchsze, rchset, deg, qsize, qlink,
 301.150 +            marker, &rchset[rchsze+1], &nbrhd[nhdsze+1]);
 301.151 +         /* Reset marker value of nodes in reach set. Update threshold
 301.152 +            value for cyclic search. Also call qmdqt to form new
 301.153 +            quotient graph. */
 301.154 +         marker[node] = 0;
 301.155 +         for (irch = 1; irch <= rchsze; irch++)
 301.156 +         {  inode = rchset[irch];
 301.157 +            if (marker[inode] >= 0)
 301.158 +            {  marker[inode] = 0;
 301.159 +               ndeg = deg[inode];
 301.160 +               if (ndeg < mindeg) mindeg = ndeg;
 301.161 +               if (ndeg <= thresh)
 301.162 +               {  mindeg = thresh;
 301.163 +                  thresh = ndeg;
 301.164 +                  search = invp[inode];
 301.165 +               }
 301.166 +            }
 301.167 +         }
 301.168 +         if (nhdsze > 0)
 301.169 +            qmdqt(&node, xadj, adjncy, marker, &rchsze, rchset, nbrhd);
 301.170 +      }
 301.171 +      if (num < neqns) goto s300;
 301.172 +      return;
 301.173 +#     undef neqns
 301.174 +#     undef nofsub
 301.175 +}
 301.176 +
 301.177 +/***********************************************************************
 301.178 +*  NAME
 301.179 +*
 301.180 +*  qmdrch - Quotient MD ReaCHable set
 301.181 +*
 301.182 +*  SYNOPSIS
 301.183 +*
 301.184 +*  #include "glpqmd.h"
 301.185 +*  void qmdrch(int *root, int xadj[], int adjncy[], int deg[],
 301.186 +*     int marker[], int *rchsze, int rchset[], int *nhdsze,
 301.187 +*     int nbrhd[]);
 301.188 +*
 301.189 +*  PURPOSE
 301.190 +*
 301.191 +*  This subroutine determines the reachable set of a node through a
 301.192 +*  given subset. The adjancy structure is assumed to be stored in a
 301.193 +*  quotient graph format.
 301.194 +* 
 301.195 +*  INPUT PARAMETERS
 301.196 +*
 301.197 +*  root   - the given node not in the subset;
 301.198 +*  (xadj, adjncy) -
 301.199 +*           the adjancy structure pair;
 301.200 +*  deg    - the degree vector. deg[i] < 0 means the node belongs to the
 301.201 +*           given subset.
 301.202 +*
 301.203 +*  OUTPUT PARAMETERS
 301.204 +*
 301.205 +*  (rchsze, rchset) -
 301.206 +*           the reachable set;
 301.207 +*  (nhdsze, nbrhd) -
 301.208 +*           the neighborhood set.
 301.209 +*
 301.210 +*  UPDATED PARAMETERS
 301.211 +*
 301.212 +*  marker - the marker vector for reach and nbrhd sets. > 0 means the
 301.213 +*           node is in reach set. < 0 means the node has been merged
 301.214 +*           with others in the quotient or it is in nbrhd set.
 301.215 +***********************************************************************/
 301.216 +
 301.217 +void qmdrch(int *_root, int xadj[], int adjncy[], int deg[],
 301.218 +      int marker[], int *_rchsze, int rchset[], int *_nhdsze,
 301.219 +      int nbrhd[])
 301.220 +{     int i, istop, istrt, j, jstop, jstrt, nabor, node;
 301.221 +#     define root   (*_root)
 301.222 +#     define rchsze (*_rchsze)
 301.223 +#     define nhdsze (*_nhdsze)
 301.224 +      /* Loop through the neighbors of root in the quotient graph. */
 301.225 +      nhdsze = 0;
 301.226 +      rchsze = 0;
 301.227 +      istrt = xadj[root];
 301.228 +      istop = xadj[root+1] - 1;
 301.229 +      if (istop < istrt) return;
 301.230 +      for (i = istrt; i <= istop; i++)
 301.231 +      {  nabor = adjncy[i];
 301.232 +         if (nabor == 0) return;
 301.233 +         if (marker[nabor] == 0)
 301.234 +         {  if (deg[nabor] >= 0)
 301.235 +            {  /* Include nabor into the reachable set. */
 301.236 +               rchsze++;
 301.237 +               rchset[rchsze] = nabor;
 301.238 +               marker[nabor] = 1;
 301.239 +               goto s600;
 301.240 +            }
 301.241 +            /* nabor has been eliminated. Find nodes reachable from
 301.242 +               it. */
 301.243 +            marker[nabor] = -1;
 301.244 +            nhdsze++;
 301.245 +            nbrhd[nhdsze] = nabor;
 301.246 +s300:       jstrt = xadj[nabor];
 301.247 +            jstop = xadj[nabor+1] - 1;
 301.248 +            for (j = jstrt; j <= jstop; j++)
 301.249 +            {  node = adjncy[j];
 301.250 +               nabor = - node;
 301.251 +               if (node < 0) goto s300;
 301.252 +               if (node == 0) goto s600;
 301.253 +               if (marker[node] == 0)
 301.254 +               {  rchsze++;
 301.255 +                  rchset[rchsze] = node;
 301.256 +                  marker[node] = 1;
 301.257 +               }
 301.258 +            }
 301.259 +         }
 301.260 +s600:    ;
 301.261 +      }
 301.262 +      return;
 301.263 +#     undef root
 301.264 +#     undef rchsze
 301.265 +#     undef nhdsze
 301.266 +}
 301.267 +
 301.268 +/***********************************************************************
 301.269 +*  NAME
 301.270 +*
 301.271 +*  qmdqt - Quotient MD Quotient graph Transformation
 301.272 +*
 301.273 +*  SYNOPSIS
 301.274 +*
 301.275 +*  #include "glpqmd.h"
 301.276 +*  void qmdqt(int *root, int xadj[], int adjncy[], int marker[],
 301.277 +*     int *rchsze, int rchset[], int nbrhd[]);
 301.278 +*
 301.279 +*  PURPOSE
 301.280 +*
 301.281 +*  This subroutine performs the quotient graph transformation after a
 301.282 +*  node has been eliminated.
 301.283 +*
 301.284 +*  INPUT PARAMETERS
 301.285 +*
 301.286 +*  root   - the node just eliminated. It becomes the representative of
 301.287 +*           the new supernode;
 301.288 +*  (xadj, adjncy) -
 301.289 +*           the adjancy structure;
 301.290 +*  (rchsze, rchset) -
 301.291 +*           the reachable set of root in the old quotient graph;
 301.292 +*  nbrhd  - the neighborhood set which will be merged with root to form
 301.293 +*           the new supernode;
 301.294 +*  marker - the marker vector.
 301.295 +*
 301.296 +*  UPDATED PARAMETERS
 301.297 +*
 301.298 +*  adjncy - becomes the adjncy of the quotient graph.
 301.299 +***********************************************************************/
 301.300 +
 301.301 +void qmdqt(int *_root, int xadj[], int adjncy[], int marker[],
 301.302 +      int *_rchsze, int rchset[], int nbrhd[])
 301.303 +{     int inhd, irch, j, jstop, jstrt, link, nabor, node;
 301.304 +#     define root   (*_root)
 301.305 +#     define rchsze (*_rchsze)
 301.306 +      irch = 0;
 301.307 +      inhd = 0;
 301.308 +      node = root;
 301.309 +s100: jstrt = xadj[node];
 301.310 +      jstop = xadj[node+1] - 2;
 301.311 +      if (jstop >= jstrt)
 301.312 +      {  /* Place reach nodes into the adjacent list of node. */
 301.313 +         for (j = jstrt; j <= jstop; j++)
 301.314 +         {  irch++;
 301.315 +            adjncy[j] = rchset[irch];
 301.316 +            if (irch >= rchsze) goto s400;
 301.317 +         }
 301.318 +      }
 301.319 +      /* Link to other space provided by the nbrhd set. */
 301.320 +      link = adjncy[jstop+1];
 301.321 +      node = - link;
 301.322 +      if (link >= 0)
 301.323 +      {  inhd++;
 301.324 +         node = nbrhd[inhd];
 301.325 +         adjncy[jstop+1] = - node;
 301.326 +      }
 301.327 +      goto s100;
 301.328 +      /* All reachable nodes have been saved. End the adjacent list.
 301.329 +         Add root to the neighborhood list of each node in the reach
 301.330 +         set. */
 301.331 +s400: adjncy[j+1] = 0;
 301.332 +      for (irch = 1; irch <= rchsze; irch++)
 301.333 +      {  node = rchset[irch];
 301.334 +         if (marker[node] >= 0)
 301.335 +         {  jstrt = xadj[node];
 301.336 +            jstop = xadj[node+1] - 1;
 301.337 +            for (j = jstrt; j <= jstop; j++)
 301.338 +            {  nabor = adjncy[j];
 301.339 +               if (marker[nabor] < 0)
 301.340 +               {  adjncy[j] = root;
 301.341 +                  goto s600;
 301.342 +               }
 301.343 +            }
 301.344 +         }
 301.345 +s600:    ;
 301.346 +      }
 301.347 +      return;
 301.348 +#     undef root
 301.349 +#     undef rchsze
 301.350 +}
 301.351 +
 301.352 +/***********************************************************************
 301.353 +*  NAME
 301.354 +*
 301.355 +*  qmdupd - Quotient MD UPDate
 301.356 +*
 301.357 +*  SYNOPSIS
 301.358 +*
 301.359 +*  #include "glpqmd.h"
 301.360 +*  void qmdupd(int xadj[], int adjncy[], int *nlist, int list[],
 301.361 +*     int deg[], int qsize[], int qlink[], int marker[], int rchset[],
 301.362 +*     int nbrhd[]);
 301.363 +*
 301.364 +*  PURPOSE
 301.365 +*
 301.366 +*  This routine performs degree update for a set of nodes in the minimum
 301.367 +*  degree algorithm.
 301.368 +*
 301.369 +*  INPUT PARAMETERS
 301.370 +*
 301.371 +*  (xadj, adjncy) -
 301.372 +*           the adjancy structure;
 301.373 +*  (nlist, list) -
 301.374 +*           the list of nodes whose degree has to be updated.
 301.375 +*
 301.376 +*  UPDATED PARAMETERS
 301.377 +*
 301.378 +*  deg    - the degree vector;
 301.379 +*  qsize  - size of indistinguishable supernodes;
 301.380 +*  qlink  - linked list for indistinguishable nodes;
 301.381 +*  marker - used to mark those nodes in reach/nbrhd sets.
 301.382 +*
 301.383 +*  WORKING PARAMETERS
 301.384 +*
 301.385 +*  rchset - the reachable set;
 301.386 +*  nbrhd  - the neighborhood set.
 301.387 +*
 301.388 +*  PROGRAM SUBROUTINES
 301.389 +*
 301.390 +*  qmdmrg.
 301.391 +***********************************************************************/
 301.392 +
 301.393 +void qmdupd(int xadj[], int adjncy[], int *_nlist, int list[],
 301.394 +      int deg[], int qsize[], int qlink[], int marker[], int rchset[],
 301.395 +      int nbrhd[])
 301.396 +{     int deg0, deg1, il, inhd, inode, irch, j, jstop, jstrt, mark,
 301.397 +         nabor, nhdsze, node, rchsze;
 301.398 +#     define nlist  (*_nlist)
 301.399 +      /* Find all eliminated supernodes that are adjacent to some nodes
 301.400 +         in the given list. Put them into (nhdsze, nbrhd). deg0 contains
 301.401 +         the number of nodes in the list. */
 301.402 +      if (nlist <= 0) return;
 301.403 +      deg0 = 0;
 301.404 +      nhdsze = 0;
 301.405 +      for (il = 1; il <= nlist; il++)
 301.406 +      {  node = list[il];
 301.407 +         deg0 += qsize[node];
 301.408 +         jstrt = xadj[node];
 301.409 +         jstop = xadj[node+1] - 1;
 301.410 +         for (j = jstrt; j <= jstop; j++)
 301.411 +         {  nabor = adjncy[j];
 301.412 +            if (marker[nabor] == 0 && deg[nabor] < 0)
 301.413 +            {  marker[nabor] = -1;
 301.414 +               nhdsze++;
 301.415 +               nbrhd[nhdsze] = nabor;
 301.416 +            }
 301.417 +         }
 301.418 +      }
 301.419 +      /* Merge indistinguishable nodes in the list by calling the
 301.420 +         subroutine qmdmrg. */
 301.421 +      if (nhdsze > 0)
 301.422 +         qmdmrg(xadj, adjncy, deg, qsize, qlink, marker, &deg0, &nhdsze,
 301.423 +            nbrhd, rchset, &nbrhd[nhdsze+1]);
 301.424 +      /* Find the new degrees of the nodes that have not been merged. */
 301.425 +      for (il = 1; il <= nlist; il++)
 301.426 +      {  node = list[il];
 301.427 +         mark = marker[node];
 301.428 +         if (mark == 0 || mark == 1)
 301.429 +         {  marker[node] = 2;
 301.430 +            qmdrch(&node, xadj, adjncy, deg, marker, &rchsze, rchset,
 301.431 +               &nhdsze, nbrhd);
 301.432 +            deg1 = deg0;
 301.433 +            if (rchsze > 0)
 301.434 +            {  for (irch = 1; irch <= rchsze; irch++)
 301.435 +               {  inode = rchset[irch];
 301.436 +                  deg1 += qsize[inode];
 301.437 +                  marker[inode] = 0;
 301.438 +               }
 301.439 +            }
 301.440 +            deg[node] = deg1 - 1;
 301.441 +            if (nhdsze > 0)
 301.442 +            {  for (inhd = 1; inhd <= nhdsze; inhd++)
 301.443 +               {  inode = nbrhd[inhd];
 301.444 +                  marker[inode] = 0;
 301.445 +               }
 301.446 +            }
 301.447 +         }
 301.448 +      }
 301.449 +      return;
 301.450 +#     undef nlist
 301.451 +}
 301.452 +
 301.453 +/***********************************************************************
 301.454 +*  NAME
 301.455 +*
 301.456 +*  qmdmrg - Quotient MD MeRGe
 301.457 +*
 301.458 +*  SYNOPSIS
 301.459 +*
 301.460 +*  #include "qmdmrg.h"
 301.461 +*  void qmdmrg(int xadj[], int adjncy[], int deg[], int qsize[],
 301.462 +*     int qlink[], int marker[], int *deg0, int *nhdsze, int nbrhd[],
 301.463 +*     int rchset[], int ovrlp[]);
 301.464 +*
 301.465 +*  PURPOSE
 301.466 +*
 301.467 +*  This routine merges indistinguishable nodes in the minimum degree
 301.468 +*  ordering algorithm. It also computes the new degrees of these new
 301.469 +*  supernodes.
 301.470 +*
 301.471 +*  INPUT PARAMETERS
 301.472 +*
 301.473 +*  (xadj, adjncy) -
 301.474 +*           the adjancy structure;
 301.475 +*  deg0   - the number of nodes in the given set;
 301.476 +*  (nhdsze, nbrhd) -
 301.477 +*           the set of eliminated supernodes adjacent to some nodes in
 301.478 +*           the set.
 301.479 +*
 301.480 +*  UPDATED PARAMETERS
 301.481 +*
 301.482 +*  deg    - the degree vector;
 301.483 +*  qsize  - size of indistinguishable nodes;
 301.484 +*  qlink  - linked list for indistinguishable nodes;
 301.485 +*  marker - the given set is given by those nodes with marker value set
 301.486 +*           to 1. Those nodes with degree updated will have marker value
 301.487 +*           set to 2.
 301.488 +*
 301.489 +*  WORKING PARAMETERS
 301.490 +*
 301.491 +*  rchset - the reachable set;
 301.492 +*  ovrlp  - temp vector to store the intersection of two reachable sets.
 301.493 +***********************************************************************/
 301.494 +
 301.495 +void qmdmrg(int xadj[], int adjncy[], int deg[], int qsize[],
 301.496 +      int qlink[], int marker[], int *_deg0, int *_nhdsze, int nbrhd[],
 301.497 +      int rchset[], int ovrlp[])
 301.498 +{     int deg1, head, inhd, iov, irch, j, jstop, jstrt, link, lnode,
 301.499 +         mark, mrgsze, nabor, node, novrlp, rchsze, root;
 301.500 +#     define deg0   (*_deg0)
 301.501 +#     define nhdsze (*_nhdsze)
 301.502 +      /* Initialization. */
 301.503 +      if (nhdsze <= 0) return;
 301.504 +      for (inhd = 1; inhd <= nhdsze; inhd++)
 301.505 +      {  root = nbrhd[inhd];
 301.506 +         marker[root] = 0;
 301.507 +      }
 301.508 +      /* Loop through each eliminated supernode in the set
 301.509 +         (nhdsze, nbrhd). */
 301.510 +      for (inhd = 1; inhd <= nhdsze; inhd++)
 301.511 +      {  root = nbrhd[inhd];
 301.512 +         marker[root] = -1;
 301.513 +         rchsze = 0;
 301.514 +         novrlp = 0;
 301.515 +         deg1 = 0;
 301.516 +s200:    jstrt = xadj[root];
 301.517 +         jstop = xadj[root+1] - 1;
 301.518 +         /* Determine the reachable set and its intersection with the
 301.519 +            input reachable set. */
 301.520 +         for (j = jstrt; j <= jstop; j++)
 301.521 +         {  nabor = adjncy[j];
 301.522 +            root = - nabor;
 301.523 +            if (nabor < 0) goto s200;
 301.524 +            if (nabor == 0) break;
 301.525 +            mark = marker[nabor];
 301.526 +            if (mark == 0)
 301.527 +            {  rchsze++;
 301.528 +               rchset[rchsze] = nabor;
 301.529 +               deg1 += qsize[nabor];
 301.530 +               marker[nabor] = 1;
 301.531 +            }
 301.532 +            else if (mark == 1)
 301.533 +            {  novrlp++;
 301.534 +               ovrlp[novrlp] = nabor;
 301.535 +               marker[nabor] = 2;
 301.536 +            }
 301.537 +         }
 301.538 +         /* From the overlapped set, determine the nodes that can be
 301.539 +            merged together. */
 301.540 +         head = 0;
 301.541 +         mrgsze = 0;
 301.542 +         for (iov = 1; iov <= novrlp; iov++)
 301.543 +         {  node = ovrlp[iov];
 301.544 +            jstrt = xadj[node];
 301.545 +            jstop = xadj[node+1] - 1;
 301.546 +            for (j = jstrt; j <= jstop; j++)
 301.547 +            {  nabor = adjncy[j];
 301.548 +               if (marker[nabor] == 0)
 301.549 +               {  marker[node] = 1;
 301.550 +                  goto s1100;
 301.551 +               }
 301.552 +            }
 301.553 +            /* Node belongs to the new merged supernode. Update the
 301.554 +               vectors qlink and qsize. */
 301.555 +            mrgsze += qsize[node];
 301.556 +            marker[node] = -1;
 301.557 +            lnode = node;
 301.558 +s900:       link = qlink[lnode];
 301.559 +            if (link > 0)
 301.560 +            {  lnode = link;
 301.561 +               goto s900;
 301.562 +            }
 301.563 +            qlink[lnode] = head;
 301.564 +            head = node;
 301.565 +s1100:      ;
 301.566 +         }
 301.567 +         if (head > 0)
 301.568 +         {  qsize[head] = mrgsze;
 301.569 +            deg[head] = deg0 + deg1 - 1;
 301.570 +            marker[head] = 2;
 301.571 +         }
 301.572 +         /* Reset marker values. */
 301.573 +         root = nbrhd[inhd];
 301.574 +         marker[root] = 0;
 301.575 +         if (rchsze > 0)
 301.576 +         {  for (irch = 1; irch <= rchsze; irch++)
 301.577 +            {  node = rchset[irch];
 301.578 +               marker[node] = 0;
 301.579 +            }
 301.580 +         }
 301.581 +      }
 301.582 +      return;
 301.583 +#     undef deg0
 301.584 +#     undef nhdsze
 301.585 +}
 301.586 +
 301.587 +/* eof */
   302.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
   302.2 +++ b/deps/glpk/src/glpqmd.h	Sun Nov 06 20:59:10 2011 +0100
   302.3 @@ -0,0 +1,59 @@
   302.4 +/* glpqmd.h (quotient minimum degree algorithm) */
   302.5 +
   302.6 +/***********************************************************************
   302.7 +*  This code is part of GLPK (GNU Linear Programming Kit).
   302.8 +*
   302.9 +*  Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008,
  302.10 +*  2009, 2010, 2011 Andrew Makhorin, Department for Applied Informatics,
  302.11 +*  Moscow Aviation Institute, Moscow, Russia. All rights reserved.
  302.12 +*  E-mail: <mao@gnu.org>.
  302.13 +*
  302.14 +*  GLPK is free software: you can redistribute it and/or modify it
  302.15 +*  under the terms of the GNU General Public License as published by
  302.16 +*  the Free Software Foundation, either version 3 of the License, or
  302.17 +*  (at your option) any later version.
  302.18 +*
  302.19 +*  GLPK is distributed in the hope that it will be useful, but WITHOUT
  302.20 +*  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
  302.21 +*  or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
  302.22 +*  License for more details.
  302.23 +*
  302.24 +*  You should have received a copy of the GNU General Public License
  302.25 +*  along with GLPK. If not, see <http://www.gnu.org/licenses/>.
  302.26 +***********************************************************************/
  302.27 +
  302.28 +#ifndef GLPQMD_H
  302.29 +#define GLPQMD_H
  302.30 +
  302.31 +#define genqmd _glp_qmd_genqmd
  302.32 +void genqmd(int *neqns, int xadj[], int adjncy[], int perm[],
  302.33 +      int invp[], int deg[], int marker[], int rchset[], int nbrhd[],
  302.34 +      int qsize[], int qlink[], int *nofsub);
  302.35 +/* GENeral Quotient Minimum Degree algorithm */
  302.36 +
  302.37 +#define qmdrch _glp_qmd_qmdrch
  302.38 +void qmdrch(int *root, int xadj[], int adjncy[], int deg[],
  302.39 +      int marker[], int *rchsze, int rchset[], int *nhdsze,
  302.40 +      int nbrhd[]);
  302.41 +/* Quotient MD ReaCHable set */
  302.42 +
  302.43 +#define qmdqt _glp_qmd_qmdqt
  302.44 +void qmdqt(int *root, int xadj[], int adjncy[], int marker[],
  302.45 +      int *rchsze, int rchset[], int nbrhd[]);
  302.46 +/* Quotient MD Quotient graph Transformation */
  302.47 +
  302.48 +#define qmdupd _glp_qmd_qmdupd
  302.49 +void qmdupd(int xadj[], int adjncy[], int *nlist, int list[],
  302.50 +      int deg[], int qsize[], int qlink[], int marker[], int rchset[],
  302.51 +      int nbrhd[]);
  302.52 +/* Quotient MD UPDate */
  302.53 +
  302.54 +#define qmdmrg _glp_qmd_qmdmrg
  302.55 +void qmdmrg(int xadj[], int adjncy[], int deg[], int qsize[],
  302.56 +      int qlink[], int marker[], int *deg0, int *nhdsze, int nbrhd[],
  302.57 +      int rchset[], int ovrlp[]);
  302.58 +/* Quotient MD MeRGe */
  302.59 +
  302.60 +#endif
  302.61 +
  302.62 +/* eof */
   303.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
   303.2 +++ b/deps/glpk/src/glprgr.c	Sun Nov 06 20:59:10 2011 +0100
   303.3 @@ -0,0 +1,165 @@
   303.4 +/* glprgr.c */
   303.5 +
   303.6 +/***********************************************************************
   303.7 +*  This code is part of GLPK (GNU Linear Programming Kit).
   303.8 +*
   303.9 +*  Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008,
  303.10 +*  2009, 2010, 2011 Andrew Makhorin, Department for Applied Informatics,
  303.11 +*  Moscow Aviation Institute, Moscow, Russia. All rights reserved.
  303.12 +*  E-mail: <mao@gnu.org>.
  303.13 +*
  303.14 +*  GLPK is free software: you can redistribute it and/or modify it
  303.15 +*  under the terms of the GNU General Public License as published by
  303.16 +*  the Free Software Foundation, either version 3 of the License, or
  303.17 +*  (at your option) any later version.
  303.18 +*
  303.19 +*  GLPK is distributed in the hope that it will be useful, but WITHOUT
  303.20 +*  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
  303.21 +*  or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
  303.22 +*  License for more details.
  303.23 +*
  303.24 +*  You should have received a copy of the GNU General Public License
  303.25 +*  along with GLPK. If not, see <http://www.gnu.org/licenses/>.
  303.26 +***********************************************************************/
  303.27 +
  303.28 +#define _GLPSTD_ERRNO
  303.29 +#define _GLPSTD_STDIO
  303.30 +#include "glpenv.h"
  303.31 +#include "glprgr.h"
  303.32 +#define xfault xerror
  303.33 +
  303.34 +/***********************************************************************
  303.35 +*  NAME
  303.36 +*
  303.37 +*  rgr_write_bmp16 - write 16-color raster image in BMP file format
  303.38 +*
  303.39 +*  SYNOPSIS
  303.40 +*
  303.41 +*  #include "glprgr.h"
  303.42 +*  int rgr_write_bmp16(const char *fname, int m, int n, const char
  303.43 +*     map[]);
  303.44 +*
  303.45 +*  DESCRIPTION
  303.46 +*
  303.47 +*  The routine rgr_write_bmp16 writes 16-color raster image in
  303.48 +*  uncompressed BMP file format (Windows bitmap) to a binary file whose
  303.49 +*  name is specified by the character string fname.
  303.50 +*
  303.51 +*  The parameters m and n specify, respectively, the number of rows and
  303.52 +*  the numbers of columns (i.e. height and width) of the raster image.
  303.53 +*
  303.54 +*  The character array map has m*n elements. Elements map[0, ..., n-1]
  303.55 +*  correspond to the first (top) scanline, elements map[n, ..., 2*n-1]
  303.56 +*  correspond to the second scanline, etc.
  303.57 +*
  303.58 +*  Each element of the array map specifies a color of the corresponding
  303.59 +*  pixel as 8-bit binary number XXXXIRGB, where four high-order bits (X)
  303.60 +*  are ignored, I is high intensity bit, R is red color bit, G is green
  303.61 +*  color bit, and B is blue color bit. Thus, all 16 possible colors are
  303.62 +*  coded as following hexadecimal numbers:
  303.63 +*
  303.64 +*     0x00 = black         0x08 = dark gray
  303.65 +*     0x01 = blue          0x09 = bright blue
  303.66 +*     0x02 = green         0x0A = bright green
  303.67 +*     0x03 = cyan          0x0B = bright cyan
  303.68 +*     0x04 = red           0x0C = bright red
  303.69 +*     0x05 = magenta       0x0D = bright magenta
  303.70 +*     0x06 = brown         0x0E = yellow
  303.71 +*     0x07 = light gray    0x0F = white
  303.72 +*
  303.73 +*  RETURNS
  303.74 +*
  303.75 +*  If no error occured, the routine returns zero; otherwise, it prints
  303.76 +*  an appropriate error message and returns non-zero. */
  303.77 +
  303.78 +static void put_byte(FILE *fp, int c)
  303.79 +{     fputc(c, fp);
  303.80 +      return;
  303.81 +}
  303.82 +
  303.83 +static void put_word(FILE *fp, int w)
  303.84 +{     /* big endian */
  303.85 +      put_byte(fp, w);
  303.86 +      put_byte(fp, w >> 8);
  303.87 +      return;
  303.88 +}
  303.89 +
  303.90 +static void put_dword(FILE *fp, int d)
  303.91 +{     /* big endian */
  303.92 +      put_word(fp, d);
  303.93 +      put_word(fp, d >> 16);
  303.94 +      return;
  303.95 +}
  303.96 +
  303.97 +int rgr_write_bmp16(const char *fname, int m, int n, const char map[])
  303.98 +{     FILE *fp;
  303.99 +      int offset, bmsize, i, j, b, ret = 0;
 303.100 +      if (!(1 <= m && m <= 32767))
 303.101 +         xfault("rgr_write_bmp16: m = %d; invalid height\n", m);
 303.102 +      if (!(1 <= n && n <= 32767))
 303.103 +         xfault("rgr_write_bmp16: n = %d; invalid width\n", n);
 303.104 +      fp = fopen(fname, "wb");
 303.105 +      if (fp == NULL)
 303.106 +      {  xprintf("rgr_write_bmp16: unable to create `%s' - %s\n",
 303.107 +            fname, strerror(errno));
 303.108 +         ret = 1;
 303.109 +         goto fini;
 303.110 +      }
 303.111 +      offset = 14 + 40 + 16 * 4;
 303.112 +      bmsize = (4 * n + 31) / 32;
 303.113 +      /* struct BMPFILEHEADER (14 bytes) */
 303.114 +      /* UINT bfType */          put_byte(fp, 'B'), put_byte(fp, 'M');
 303.115 +      /* DWORD bfSize */         put_dword(fp, offset + bmsize * 4);
 303.116 +      /* UINT bfReserved1 */     put_word(fp, 0);
 303.117 +      /* UNIT bfReserved2 */     put_word(fp, 0);
 303.118 +      /* DWORD bfOffBits */      put_dword(fp, offset);
 303.119 +      /* struct BMPINFOHEADER (40 bytes) */
 303.120 +      /* DWORD biSize */         put_dword(fp, 40);
 303.121 +      /* LONG biWidth */         put_dword(fp, n);
 303.122 +      /* LONG biHeight */        put_dword(fp, m);
 303.123 +      /* WORD biPlanes */        put_word(fp, 1);
 303.124 +      /* WORD biBitCount */      put_word(fp, 4);
 303.125 +      /* DWORD biCompression */  put_dword(fp, 0 /* BI_RGB */);
 303.126 +      /* DWORD biSizeImage */    put_dword(fp, 0);
 303.127 +      /* LONG biXPelsPerMeter */ put_dword(fp, 2953 /* 75 dpi */);
 303.128 +      /* LONG biYPelsPerMeter */ put_dword(fp, 2953 /* 75 dpi */);
 303.129 +      /* DWORD biClrUsed */      put_dword(fp, 0);
 303.130 +      /* DWORD biClrImportant */ put_dword(fp, 0);
 303.131 +      /* struct RGBQUAD (16 * 4 = 64 bytes) */
 303.132 +      /* CGA-compatible colors: */
 303.133 +      /* 0x00 = black */         put_dword(fp, 0x000000);
 303.134 +      /* 0x01 = blue */          put_dword(fp, 0x000080);
 303.135 +      /* 0x02 = green */         put_dword(fp, 0x008000);
 303.136 +      /* 0x03 = cyan */          put_dword(fp, 0x008080);
 303.137 +      /* 0x04 = red */           put_dword(fp, 0x800000);
 303.138 +      /* 0x05 = magenta */       put_dword(fp, 0x800080);
 303.139 +      /* 0x06 = brown */         put_dword(fp, 0x808000);
 303.140 +      /* 0x07 = light gray */    put_dword(fp, 0xC0C0C0);
 303.141 +      /* 0x08 = dark gray */     put_dword(fp, 0x808080);
 303.142 +      /* 0x09 = bright blue */   put_dword(fp, 0x0000FF);
 303.143 +      /* 0x0A = bright green */  put_dword(fp, 0x00FF00);
 303.144 +      /* 0x0B = bright cyan */   put_dword(fp, 0x00FFFF);
 303.145 +      /* 0x0C = bright red */    put_dword(fp, 0xFF0000);
 303.146 +      /* 0x0D = bright magenta */ put_dword(fp, 0xFF00FF);
 303.147 +      /* 0x0E = yellow */        put_dword(fp, 0xFFFF00);
 303.148 +      /* 0x0F = white */         put_dword(fp, 0xFFFFFF);
 303.149 +      /* pixel data bits */
 303.150 +      b = 0;
 303.151 +      for (i = m - 1; i >= 0; i--)
 303.152 +      {  for (j = 0; j < ((n + 7) / 8) * 8; j++)
 303.153 +         {  b <<= 4;
 303.154 +            b |= (j < n ? map[i * n + j] & 15 : 0);
 303.155 +            if (j & 1) put_byte(fp, b);
 303.156 +         }
 303.157 +      }
 303.158 +      fflush(fp);
 303.159 +      if (ferror(fp))
 303.160 +      {  xprintf("rgr_write_bmp16: write error on `%s' - %s\n",
 303.161 +            fname, strerror(errno));
 303.162 +         ret = 1;
 303.163 +      }
 303.164 +fini: if (fp != NULL) fclose(fp);
 303.165 +      return ret;
 303.166 +}
 303.167 +
 303.168 +/* eof */
   304.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
   304.2 +++ b/deps/glpk/src/glprgr.h	Sun Nov 06 20:59:10 2011 +0100
   304.3 @@ -0,0 +1,34 @@
   304.4 +/* glprgr.h (raster graphics) */
   304.5 +
   304.6 +/***********************************************************************
   304.7 +*  This code is part of GLPK (GNU Linear Programming Kit).
   304.8 +*
   304.9 +*  Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008,
  304.10 +*  2009, 2010, 2011 Andrew Makhorin, Department for Applied Informatics,
  304.11 +*  Moscow Aviation Institute, Moscow, Russia. All rights reserved.
  304.12 +*  E-mail: <mao@gnu.org>.
  304.13 +*
  304.14 +*  GLPK is free software: you can redistribute it and/or modify it
  304.15 +*  under the terms of the GNU General Public License as published by
  304.16 +*  the Free Software Foundation, either version 3 of the License, or
  304.17 +*  (at your option) any later version.
  304.18 +*
  304.19 +*  GLPK is distributed in the hope that it will be useful, but WITHOUT
  304.20 +*  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
  304.21 +*  or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
  304.22 +*  License for more details.
  304.23 +*
  304.24 +*  You should have received a copy of the GNU General Public License
  304.25 +*  along with GLPK. If not, see <http://www.gnu.org/licenses/>.
  304.26 +***********************************************************************/
  304.27 +
  304.28 +#ifndef GLPRGR_H
  304.29 +#define GLPRGR_H
  304.30 +
  304.31 +#define rgr_write_bmp16 _glp_rgr_write_bmp16
  304.32 +int rgr_write_bmp16(const char *fname, int m, int n, const char map[]);
  304.33 +/* write 16-color raster image in BMP file format */
  304.34 +
  304.35 +#endif
  304.36 +
  304.37 +/* eof */
   305.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
   305.2 +++ b/deps/glpk/src/glprng.h	Sun Nov 06 20:59:10 2011 +0100
   305.3 @@ -0,0 +1,68 @@
   305.4 +/* glprng.h (pseudo-random number generator) */
   305.5 +
   305.6 +/***********************************************************************
   305.7 +*  This code is part of GLPK (GNU Linear Programming Kit).
   305.8 +*
   305.9 +*  Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008,
  305.10 +*  2009, 2010, 2011 Andrew Makhorin, Department for Applied Informatics,
  305.11 +*  Moscow Aviation Institute, Moscow, Russia. All rights reserved.
  305.12 +*  E-mail: <mao@gnu.org>.
  305.13 +*
  305.14 +*  GLPK is free software: you can redistribute it and/or modify it
  305.15 +*  under the terms of the GNU General Public License as published by
  305.16 +*  the Free Software Foundation, either version 3 of the License, or
  305.17 +*  (at your option) any later version.
  305.18 +*
  305.19 +*  GLPK is distributed in the hope that it will be useful, but WITHOUT
  305.20 +*  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
  305.21 +*  or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
  305.22 +*  License for more details.
  305.23 +*
  305.24 +*  You should have received a copy of the GNU General Public License
  305.25 +*  along with GLPK. If not, see <http://www.gnu.org/licenses/>.
  305.26 +***********************************************************************/
  305.27 +
  305.28 +#ifndef GLPRNG_H
  305.29 +#define GLPRNG_H
  305.30 +
  305.31 +typedef struct RNG RNG;
  305.32 +
  305.33 +struct RNG
  305.34 +{     /* Knuth's portable pseudo-random number generator */
  305.35 +      int A[56];
  305.36 +      /* pseudo-random values */
  305.37 +      int *fptr;
  305.38 +      /* the next A value to be exported */
  305.39 +};
  305.40 +
  305.41 +#define rng_create_rand _glp_rng_create_rand
  305.42 +RNG *rng_create_rand(void);
  305.43 +/* create pseudo-random number generator */
  305.44 +
  305.45 +#define rng_init_rand _glp_rng_init_rand
  305.46 +void rng_init_rand(RNG *rand, int seed);
  305.47 +/* initialize pseudo-random number generator */
  305.48 +
  305.49 +#define rng_next_rand _glp_rng_next_rand
  305.50 +int rng_next_rand(RNG *rand);
  305.51 +/* obtain pseudo-random integer in the range [0, 2^31-1] */
  305.52 +
  305.53 +#define rng_unif_rand _glp_rng_unif_rand
  305.54 +int rng_unif_rand(RNG *rand, int m);
  305.55 +/* obtain pseudo-random integer in the range [0, m-1] */
  305.56 +
  305.57 +#define rng_delete_rand _glp_rng_delete_rand
  305.58 +void rng_delete_rand(RNG *rand);
  305.59 +/* delete pseudo-random number generator */
  305.60 +
  305.61 +#define rng_unif_01 _glp_rng_unif_01
  305.62 +double rng_unif_01(RNG *rand);
  305.63 +/* obtain pseudo-random number in the range [0, 1] */
  305.64 +
  305.65 +#define rng_uniform _glp_rng_uniform
  305.66 +double rng_uniform(RNG *rand, double a, double b);
  305.67 +/* obtain pseudo-random number in the range [a, b] */
  305.68 +
  305.69 +#endif
  305.70 +
  305.71 +/* eof */
   306.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
   306.2 +++ b/deps/glpk/src/glprng01.c	Sun Nov 06 20:59:10 2011 +0100
   306.3 @@ -0,0 +1,227 @@
   306.4 +/* glprng01.c */
   306.5 +
   306.6 +/***********************************************************************
   306.7 +*  This code is part of GLPK (GNU Linear Programming Kit).
   306.8 +*
   306.9 +*  This code is a modified version of the module GB_FLIP, a portable
  306.10 +*  pseudo-random number generator. The original version of GB_FLIP is
  306.11 +*  a part of The Stanford GraphBase developed by Donald E. Knuth (see
  306.12 +*  http://www-cs-staff.stanford.edu/~knuth/sgb.html).
  306.13 +*
  306.14 +*  Note that all changes concern only external names, so this modified
  306.15 +*  version produces exactly the same results as the original version.
  306.16 +*
  306.17 +*  Changes were made by Andrew Makhorin <mao@gnu.org>.
  306.18 +*
  306.19 +*  GLPK is free software: you can redistribute it and/or modify it
  306.20 +*  under the terms of the GNU General Public License as published by
  306.21 +*  the Free Software Foundation, either version 3 of the License, or
  306.22 +*  (at your option) any later version.
  306.23 +*
  306.24 +*  GLPK is distributed in the hope that it will be useful, but WITHOUT
  306.25 +*  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
  306.26 +*  or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
  306.27 +*  License for more details.
  306.28 +*
  306.29 +*  You should have received a copy of the GNU General Public License
  306.30 +*  along with GLPK. If not, see <http://www.gnu.org/licenses/>.
  306.31 +***********************************************************************/
  306.32 +
  306.33 +#include "glpenv.h"
  306.34 +#include "glprng.h"
  306.35 +
  306.36 +#if 0
  306.37 +int A[56] = { -1 };
  306.38 +#else
  306.39 +#define A (rand->A)
  306.40 +#endif
  306.41 +/* pseudo-random values */
  306.42 +
  306.43 +#if 0
  306.44 +int *fptr = A;
  306.45 +#else
  306.46 +#define fptr (rand->fptr)
  306.47 +#endif
  306.48 +/* the next A value to be exported */
  306.49 +
  306.50 +#define mod_diff(x, y) (((x) - (y)) & 0x7FFFFFFF)
  306.51 +/* difference modulo 2^31 */
  306.52 +
  306.53 +static int flip_cycle(RNG *rand)
  306.54 +{     /* this is an auxiliary routine to do 55 more steps of the basic
  306.55 +         recurrence, at high speed, and to reset fptr */
  306.56 +      int *ii, *jj;
  306.57 +      for (ii = &A[1], jj = &A[32]; jj <= &A[55]; ii++, jj++)
  306.58 +         *ii = mod_diff(*ii, *jj);
  306.59 +      for (jj = &A[1]; ii <= &A[55]; ii++, jj++)
  306.60 +         *ii = mod_diff(*ii, *jj);
  306.61 +      fptr = &A[54];
  306.62 +      return A[55];
  306.63 +}
  306.64 +
  306.65 +/***********************************************************************
  306.66 +*  NAME
  306.67 +*
  306.68 +*  rng_create_rand - create pseudo-random number generator
  306.69 +*
  306.70 +*  SYNOPSIS
  306.71 +*
  306.72 +*  #include "glprng.h"
  306.73 +*  RNG *rng_create_rand(void);
  306.74 +*
  306.75 +*  DESCRIPTION
  306.76 +*
  306.77 +*  The routine rng_create_rand creates and initializes a pseudo-random
  306.78 +*  number generator.
  306.79 +*
  306.80 +*  RETURNS
  306.81 +*
  306.82 +*  The routine returns a pointer to the generator created. */
  306.83 +
  306.84 +RNG *rng_create_rand(void)
  306.85 +{     RNG *rand;
  306.86 +      int i;
  306.87 +      rand = xmalloc(sizeof(RNG));
  306.88 +      A[0] = -1;
  306.89 +      for (i = 1; i <= 55; i++) A[i] = 0;
  306.90 +      fptr = A;
  306.91 +      rng_init_rand(rand, 1);
  306.92 +      return rand;
  306.93 +}
  306.94 +
  306.95 +/***********************************************************************
  306.96 +*  NAME
  306.97 +*
  306.98 +*  rng_init_rand - initialize pseudo-random number generator
  306.99 +*
 306.100 +*  SYNOPSIS
 306.101 +*
 306.102 +*  #include "glprng.h"
 306.103 +*  void rng_init_rand(RNG *rand, int seed);
 306.104 +*
 306.105 +*  DESCRIPTION
 306.106 +*
 306.107 +*  The routine rng_init_rand initializes the pseudo-random number
 306.108 +*  generator. The parameter seed may be any integer number. Note that
 306.109 +*  on creating the generator this routine is called with the parameter
 306.110 +*  seed equal to 1. */
 306.111 +
 306.112 +void rng_init_rand(RNG *rand, int seed)
 306.113 +{     int i;
 306.114 +      int prev = seed, next = 1;
 306.115 +      seed = prev = mod_diff(prev, 0);
 306.116 +      A[55] = prev;
 306.117 +      for (i = 21; i; i = (i + 21) % 55)
 306.118 +      {  A[i] = next;
 306.119 +         next = mod_diff(prev, next);
 306.120 +         if (seed & 1)
 306.121 +            seed = 0x40000000 + (seed >> 1);
 306.122 +         else
 306.123 +            seed >>= 1;
 306.124 +         next = mod_diff(next, seed);
 306.125 +         prev = A[i];
 306.126 +      }
 306.127 +      flip_cycle(rand);
 306.128 +      flip_cycle(rand);
 306.129 +      flip_cycle(rand);
 306.130 +      flip_cycle(rand);
 306.131 +      flip_cycle(rand);
 306.132 +      return;
 306.133 +}
 306.134 +
 306.135 +/***********************************************************************
 306.136 +*  NAME
 306.137 +*
 306.138 +*  rng_next_rand - obtain pseudo-random integer in the range [0, 2^31-1]
 306.139 +*
 306.140 +*  SYNOPSIS
 306.141 +*
 306.142 +*  #include "glprng.h"
 306.143 +*  int rng_next_rand(RNG *rand);
 306.144 +*
 306.145 +*  RETURNS
 306.146 +*
 306.147 +*  The routine rng_next_rand returns a next pseudo-random integer which
 306.148 +*  is uniformly distributed between 0 and 2^31-1, inclusive. The period
 306.149 +*  length of the generated numbers is 2^85 - 2^30. The low order bits of
 306.150 +*  the generated numbers are just as random as the high-order bits. */
 306.151 +
 306.152 +int rng_next_rand(RNG *rand)
 306.153 +{     return
 306.154 +         *fptr >= 0 ? *fptr-- : flip_cycle(rand);
 306.155 +}
 306.156 +
 306.157 +/***********************************************************************
 306.158 +*  NAME
 306.159 +*
 306.160 +*  rng_unif_rand - obtain pseudo-random integer in the range [0, m-1]
 306.161 +*
 306.162 +*  SYNOPSIS
 306.163 +*
 306.164 +*  #include "glprng.h"
 306.165 +*  int rng_unif_rand(RNG *rand, int m);
 306.166 +*
 306.167 +*  RETURNS
 306.168 +*
 306.169 +*  The routine rng_unif_rand returns a next pseudo-random integer which
 306.170 +*  is uniformly distributed between 0 and m-1, inclusive, where m is any
 306.171 +*  positive integer less than 2^31. */
 306.172 +
 306.173 +#define two_to_the_31 ((unsigned int)0x80000000)
 306.174 +
 306.175 +int rng_unif_rand(RNG *rand, int m)
 306.176 +{     unsigned int t = two_to_the_31 - (two_to_the_31 % m);
 306.177 +      int r;
 306.178 +      xassert(m > 0);
 306.179 +      do { r = rng_next_rand(rand); } while (t <= (unsigned int)r);
 306.180 +      return r % m;
 306.181 +}
 306.182 +
 306.183 +/***********************************************************************
 306.184 +*  NAME
 306.185 +*
 306.186 +*  rng_delete_rand - delete pseudo-random number generator
 306.187 +*
 306.188 +*  SYNOPSIS
 306.189 +*
 306.190 +*  #include "glprng.h"
 306.191 +*  void rng_delete_rand(RNG *rand);
 306.192 +*
 306.193 +*  DESCRIPTION
 306.194 +*
 306.195 +*  The routine rng_delete_rand frees all the memory allocated to the
 306.196 +*  specified pseudo-random number generator. */
 306.197 +
 306.198 +void rng_delete_rand(RNG *rand)
 306.199 +{     xfree(rand);
 306.200 +      return;
 306.201 +}
 306.202 +
 306.203 +/**********************************************************************/
 306.204 +
 306.205 +#if 0
 306.206 +/* To be sure that this modified version produces the same results as
 306.207 +   the original version, run this validation program. */
 306.208 +
 306.209 +int main(void)
 306.210 +{     RNG *rand;
 306.211 +      int j;
 306.212 +      rand = rng_create_rand();
 306.213 +      rng_init_rand(rand, -314159);
 306.214 +      if (rng_next_rand(rand) != 119318998)
 306.215 +      {  fprintf(stderr, "Failure on the first try!\n");
 306.216 +         return -1;
 306.217 +      }
 306.218 +      for (j = 1; j <= 133; j++) rng_next_rand(rand);
 306.219 +      if (rng_unif_rand(rand, 0x55555555) != 748103812)
 306.220 +      {  fprintf(stderr, "Failure on the second try!\n");
 306.221 +         return -2;
 306.222 +      }
 306.223 +      fprintf(stderr, "OK, the random-number generator routines seem to"
 306.224 +         " work!\n");
 306.225 +      rng_delete_rand(rand);
 306.226 +      return 0;
 306.227 +}
 306.228 +#endif
 306.229 +
 306.230 +/* eof */
   307.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
   307.2 +++ b/deps/glpk/src/glprng02.c	Sun Nov 06 20:59:10 2011 +0100
   307.3 @@ -0,0 +1,76 @@
   307.4 +/* glprng02.c */
   307.5 +
   307.6 +/***********************************************************************
   307.7 +*  This code is part of GLPK (GNU Linear Programming Kit).
   307.8 +*
   307.9 +*  Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008,
  307.10 +*  2009, 2010, 2011 Andrew Makhorin, Department for Applied Informatics,
  307.11 +*  Moscow Aviation Institute, Moscow, Russia. All rights reserved.
  307.12 +*  E-mail: <mao@gnu.org>.
  307.13 +*
  307.14 +*  GLPK is free software: you can redistribute it and/or modify it
  307.15 +*  under the terms of the GNU General Public License as published by
  307.16 +*  the Free Software Foundation, either version 3 of the License, or
  307.17 +*  (at your option) any later version.
  307.18 +*
  307.19 +*  GLPK is distributed in the hope that it will be useful, but WITHOUT
  307.20 +*  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
  307.21 +*  or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
  307.22 +*  License for more details.
  307.23 +*
  307.24 +*  You should have received a copy of the GNU General Public License
  307.25 +*  along with GLPK. If not, see <http://www.gnu.org/licenses/>.
  307.26 +***********************************************************************/
  307.27 +
  307.28 +#include "glpenv.h"
  307.29 +#include "glprng.h"
  307.30 +#define xfault xerror
  307.31 +
  307.32 +/***********************************************************************
  307.33 +*  NAME
  307.34 +*
  307.35 +*  rng_unif_01 - obtain pseudo-random number in the range [0, 1]
  307.36 +*
  307.37 +*  SYNOPSIS
  307.38 +*
  307.39 +*  #include "glprng.h"
  307.40 +*  double rng_unif_01(RNG *rand);
  307.41 +*
  307.42 +*  RETURNS
  307.43 +*
  307.44 +*  The routine rng_unif_01 returns a next pseudo-random number which is
  307.45 +*  uniformly distributed in the range [0, 1]. */
  307.46 +
  307.47 +double rng_unif_01(RNG *rand)
  307.48 +{     double x;
  307.49 +      x = (double)rng_next_rand(rand) / 2147483647.0;
  307.50 +      xassert(0.0 <= x && x <= 1.0);
  307.51 +      return x;
  307.52 +}
  307.53 +
  307.54 +/***********************************************************************
  307.55 +*  NAME
  307.56 +*
  307.57 +*  rng_uniform - obtain pseudo-random number in the range [a, b]
  307.58 +*
  307.59 +*  SYNOPSIS
  307.60 +*
  307.61 +*  #include "glprng.h"
  307.62 +*  double rng_uniform(RNG *rand, double a, double b);
  307.63 +*
  307.64 +*  RETURNS
  307.65 +*
  307.66 +*  The routine rng_uniform returns a next pseudo-random number which is
  307.67 +*  uniformly distributed in the range [a, b]. */
  307.68 +
  307.69 +double rng_uniform(RNG *rand, double a, double b)
  307.70 +{     double x;
  307.71 +      if (a >= b)
  307.72 +         xfault("rng_uniform: a = %g, b = %g; invalid range\n", a, b);
  307.73 +      x = rng_unif_01(rand);
  307.74 +      x = a * (1.0 - x) + b * x;
  307.75 +      xassert(a <= x && x <= b);
  307.76 +      return x;
  307.77 +}
  307.78 +
  307.79 +/* eof */
   308.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
   308.2 +++ b/deps/glpk/src/glpscf.c	Sun Nov 06 20:59:10 2011 +0100
   308.3 @@ -0,0 +1,634 @@
   308.4 +/* glpscf.c (Schur complement factorization) */
   308.5 +
   308.6 +/***********************************************************************
   308.7 +*  This code is part of GLPK (GNU Linear Programming Kit).
   308.8 +*
   308.9 +*  Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008,
  308.10 +*  2009, 2010, 2011 Andrew Makhorin, Department for Applied Informatics,
  308.11 +*  Moscow Aviation Institute, Moscow, Russia. All rights reserved.
  308.12 +*  E-mail: <mao@gnu.org>.
  308.13 +*
  308.14 +*  GLPK is free software: you can redistribute it and/or modify it
  308.15 +*  under the terms of the GNU General Public License as published by
  308.16 +*  the Free Software Foundation, either version 3 of the License, or
  308.17 +*  (at your option) any later version.
  308.18 +*
  308.19 +*  GLPK is distributed in the hope that it will be useful, but WITHOUT
  308.20 +*  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
  308.21 +*  or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
  308.22 +*  License for more details.
  308.23 +*
  308.24 +*  You should have received a copy of the GNU General Public License
  308.25 +*  along with GLPK. If not, see <http://www.gnu.org/licenses/>.
  308.26 +***********************************************************************/
  308.27 +
  308.28 +#include "glpenv.h"
  308.29 +#include "glpscf.h"
  308.30 +#define xfault xerror
  308.31 +
  308.32 +#define _GLPSCF_DEBUG 0
  308.33 +
  308.34 +#define eps 1e-10
  308.35 +
  308.36 +/***********************************************************************
  308.37 +*  NAME
  308.38 +*
  308.39 +*  scf_create_it - create Schur complement factorization
  308.40 +*
  308.41 +*  SYNOPSIS
  308.42 +*
  308.43 +*  #include "glpscf.h"
  308.44 +*  SCF *scf_create_it(int n_max);
  308.45 +*
  308.46 +*  DESCRIPTION
  308.47 +*
  308.48 +*  The routine scf_create_it creates the factorization of matrix C,
  308.49 +*  which initially has no rows and columns.
  308.50 +*
  308.51 +*  The parameter n_max specifies the maximal order of matrix C to be
  308.52 +*  factorized, 1 <= n_max <= 32767.
  308.53 +*
  308.54 +*  RETURNS
  308.55 +*
  308.56 +*  The routine scf_create_it returns a pointer to the structure SCF,
  308.57 +*  which defines the factorization. */
  308.58 +
  308.59 +SCF *scf_create_it(int n_max)
  308.60 +{     SCF *scf;
  308.61 +#if _GLPSCF_DEBUG
  308.62 +      xprintf("scf_create_it: warning: debug mode enabled\n");
  308.63 +#endif
  308.64 +      if (!(1 <= n_max && n_max <= 32767))
  308.65 +         xfault("scf_create_it: n_max = %d; invalid parameter\n",
  308.66 +            n_max);
  308.67 +      scf = xmalloc(sizeof(SCF));
  308.68 +      scf->n_max = n_max;
  308.69 +      scf->n = 0;
  308.70 +      scf->f = xcalloc(1 + n_max * n_max, sizeof(double));
  308.71 +      scf->u = xcalloc(1 + n_max * (n_max + 1) / 2, sizeof(double));
  308.72 +      scf->p = xcalloc(1 + n_max, sizeof(int));
  308.73 +      scf->t_opt = SCF_TBG;
  308.74 +      scf->rank = 0;
  308.75 +#if _GLPSCF_DEBUG
  308.76 +      scf->c = xcalloc(1 + n_max * n_max, sizeof(double));
  308.77 +#else
  308.78 +      scf->c = NULL;
  308.79 +#endif
  308.80 +      scf->w = xcalloc(1 + n_max, sizeof(double));
  308.81 +      return scf;
  308.82 +}
  308.83 +
  308.84 +/***********************************************************************
  308.85 +*  The routine f_loc determines location of matrix element F[i,j] in
  308.86 +*  the one-dimensional array f. */
  308.87 +
  308.88 +static int f_loc(SCF *scf, int i, int j)
  308.89 +{     int n_max = scf->n_max;
  308.90 +      int n = scf->n;
  308.91 +      xassert(1 <= i && i <= n);
  308.92 +      xassert(1 <= j && j <= n);
  308.93 +      return (i - 1) * n_max + j;
  308.94 +}
  308.95 +
  308.96 +/***********************************************************************
  308.97 +*  The routine u_loc determines location of matrix element U[i,j] in
  308.98 +*  the one-dimensional array u. */
  308.99 +
 308.100 +static int u_loc(SCF *scf, int i, int j)
 308.101 +{     int n_max = scf->n_max;
 308.102 +      int n = scf->n;
 308.103 +      xassert(1 <= i && i <= n);
 308.104 +      xassert(i <= j && j <= n);
 308.105 +      return (i - 1) * n_max + j - i * (i - 1) / 2;
 308.106 +}
 308.107 +
 308.108 +/***********************************************************************
 308.109 +*  The routine bg_transform applies Bartels-Golub version of gaussian
 308.110 +*  elimination to restore triangular structure of matrix U.
 308.111 +*
 308.112 +*  On entry matrix U has the following structure:
 308.113 +*
 308.114 +*        1       k         n
 308.115 +*     1  * * * * * * * * * *
 308.116 +*        . * * * * * * * * *
 308.117 +*        . . * * * * * * * *
 308.118 +*        . . . * * * * * * *
 308.119 +*     k  . . . . * * * * * *
 308.120 +*        . . . . . * * * * *
 308.121 +*        . . . . . . * * * *
 308.122 +*        . . . . . . . * * *
 308.123 +*        . . . . . . . . * *
 308.124 +*     n  . . . . # # # # # #
 308.125 +*
 308.126 +*  where '#' is a row spike to be eliminated.
 308.127 +*
 308.128 +*  Elements of n-th row are passed separately in locations un[k], ...,
 308.129 +*  un[n]. On exit the content of the array un is destroyed.
 308.130 +*
 308.131 +*  REFERENCES
 308.132 +*
 308.133 +*  R.H.Bartels, G.H.Golub, "The Simplex Method of Linear Programming
 308.134 +*  Using LU-decomposition", Comm. ACM, 12, pp. 266-68, 1969. */
 308.135 +
 308.136 +static void bg_transform(SCF *scf, int k, double un[])
 308.137 +{     int n = scf->n;
 308.138 +      double *f = scf->f;
 308.139 +      double *u = scf->u;
 308.140 +      int j, k1, kj, kk, n1, nj;
 308.141 +      double t;
 308.142 +      xassert(1 <= k && k <= n);
 308.143 +      /* main elimination loop */
 308.144 +      for (k = k; k < n; k++)
 308.145 +      {  /* determine location of U[k,k] */
 308.146 +         kk = u_loc(scf, k, k);
 308.147 +         /* determine location of F[k,1] */
 308.148 +         k1 = f_loc(scf, k, 1);
 308.149 +         /* determine location of F[n,1] */
 308.150 +         n1 = f_loc(scf, n, 1);
 308.151 +         /* if |U[k,k]| < |U[n,k]|, interchange k-th and n-th rows to
 308.152 +            provide |U[k,k]| >= |U[n,k]| */
 308.153 +         if (fabs(u[kk]) < fabs(un[k]))
 308.154 +         {  /* interchange k-th and n-th rows of matrix U */
 308.155 +            for (j = k, kj = kk; j <= n; j++, kj++)
 308.156 +               t = u[kj], u[kj] = un[j], un[j] = t;
 308.157 +            /* interchange k-th and n-th rows of matrix F to keep the
 308.158 +               main equality F * C = U * P */
 308.159 +            for (j = 1, kj = k1, nj = n1; j <= n; j++, kj++, nj++)
 308.160 +               t = f[kj], f[kj] = f[nj], f[nj] = t;
 308.161 +         }
 308.162 +         /* now |U[k,k]| >= |U[n,k]| */
 308.163 +         /* if U[k,k] is too small in the magnitude, replace U[k,k] and
 308.164 +            U[n,k] by exact zero */
 308.165 +         if (fabs(u[kk]) < eps) u[kk] = un[k] = 0.0;
 308.166 +         /* if U[n,k] is already zero, elimination is not needed */
 308.167 +         if (un[k] == 0.0) continue;
 308.168 +         /* compute gaussian multiplier t = U[n,k] / U[k,k] */
 308.169 +         t = un[k] / u[kk];
 308.170 +         /* apply gaussian elimination to nullify U[n,k] */
 308.171 +         /* (n-th row of U) := (n-th row of U) - t * (k-th row of U) */
 308.172 +         for (j = k+1, kj = kk+1; j <= n; j++, kj++)
 308.173 +            un[j] -= t * u[kj];
 308.174 +         /* (n-th row of F) := (n-th row of F) - t * (k-th row of F)
 308.175 +            to keep the main equality F * C = U * P */
 308.176 +         for (j = 1, kj = k1, nj = n1; j <= n; j++, kj++, nj++)
 308.177 +            f[nj] -= t * f[kj];
 308.178 +      }
 308.179 +      /* if U[n,n] is too small in the magnitude, replace it by exact
 308.180 +         zero */
 308.181 +      if (fabs(un[n]) < eps) un[n] = 0.0;
 308.182 +      /* store U[n,n] in a proper location */
 308.183 +      u[u_loc(scf, n, n)] = un[n];
 308.184 +      return;
 308.185 +}
 308.186 +
 308.187 +/***********************************************************************
 308.188 +*  The routine givens computes the parameters of Givens plane rotation
 308.189 +*  c = cos(teta) and s = sin(teta) such that:
 308.190 +*
 308.191 +*     ( c -s ) ( a )   ( r )
 308.192 +*     (      ) (   ) = (   ) ,
 308.193 +*     ( s  c ) ( b )   ( 0 )
 308.194 +*
 308.195 +*  where a and b are given scalars.
 308.196 +*
 308.197 +*  REFERENCES
 308.198 +*
 308.199 +*  G.H.Golub, C.F.Van Loan, "Matrix Computations", 2nd ed. */
 308.200 +
 308.201 +static void givens(double a, double b, double *c, double *s)
 308.202 +{     double t;
 308.203 +      if (b == 0.0)
 308.204 +         (*c) = 1.0, (*s) = 0.0;
 308.205 +      else if (fabs(a) <= fabs(b))
 308.206 +         t = - a / b, (*s) = 1.0 / sqrt(1.0 + t * t), (*c) = (*s) * t;
 308.207 +      else
 308.208 +         t = - b / a, (*c) = 1.0 / sqrt(1.0 + t * t), (*s) = (*c) * t;
 308.209 +      return;
 308.210 +}
 308.211 +
 308.212 +/*----------------------------------------------------------------------
 308.213 +*  The routine gr_transform applies Givens plane rotations to restore
 308.214 +*  triangular structure of matrix U.
 308.215 +*
 308.216 +*  On entry matrix U has the following structure:
 308.217 +*
 308.218 +*        1       k         n
 308.219 +*     1  * * * * * * * * * *
 308.220 +*        . * * * * * * * * *
 308.221 +*        . . * * * * * * * *
 308.222 +*        . . . * * * * * * *
 308.223 +*     k  . . . . * * * * * *
 308.224 +*        . . . . . * * * * *
 308.225 +*        . . . . . . * * * *
 308.226 +*        . . . . . . . * * *
 308.227 +*        . . . . . . . . * *
 308.228 +*     n  . . . . # # # # # #
 308.229 +*
 308.230 +*  where '#' is a row spike to be eliminated.
 308.231 +*
 308.232 +*  Elements of n-th row are passed separately in locations un[k], ...,
 308.233 +*  un[n]. On exit the content of the array un is destroyed.
 308.234 +*
 308.235 +*  REFERENCES
 308.236 +*
 308.237 +*  R.H.Bartels, G.H.Golub, "The Simplex Method of Linear Programming
 308.238 +*  Using LU-decomposition", Comm. ACM, 12, pp. 266-68, 1969. */
 308.239 +
 308.240 +static void gr_transform(SCF *scf, int k, double un[])
 308.241 +{     int n = scf->n;
 308.242 +      double *f = scf->f;
 308.243 +      double *u = scf->u;
 308.244 +      int j, k1, kj, kk, n1, nj;
 308.245 +      double c, s;
 308.246 +      xassert(1 <= k && k <= n);
 308.247 +      /* main elimination loop */
 308.248 +      for (k = k; k < n; k++)
 308.249 +      {  /* determine location of U[k,k] */
 308.250 +         kk = u_loc(scf, k, k);
 308.251 +         /* determine location of F[k,1] */
 308.252 +         k1 = f_loc(scf, k, 1);
 308.253 +         /* determine location of F[n,1] */
 308.254 +         n1 = f_loc(scf, n, 1);
 308.255 +         /* if both U[k,k] and U[n,k] are too small in the magnitude,
 308.256 +            replace them by exact zero */
 308.257 +         if (fabs(u[kk]) < eps && fabs(un[k]) < eps)
 308.258 +            u[kk] = un[k] = 0.0;
 308.259 +         /* if U[n,k] is already zero, elimination is not needed */
 308.260 +         if (un[k] == 0.0) continue;
 308.261 +         /* compute the parameters of Givens plane rotation */
 308.262 +         givens(u[kk], un[k], &c, &s);
 308.263 +         /* apply Givens rotation to k-th and n-th rows of matrix U */
 308.264 +         for (j = k, kj = kk; j <= n; j++, kj++)
 308.265 +         {  double ukj = u[kj], unj = un[j];
 308.266 +            u[kj] = c * ukj - s * unj;
 308.267 +            un[j] = s * ukj + c * unj;
 308.268 +         }
 308.269 +         /* apply Givens rotation to k-th and n-th rows of matrix F
 308.270 +            to keep the main equality F * C = U * P */
 308.271 +         for (j = 1, kj = k1, nj = n1; j <= n; j++, kj++, nj++)
 308.272 +         {  double fkj = f[kj], fnj = f[nj];
 308.273 +            f[kj] = c * fkj - s * fnj;
 308.274 +            f[nj] = s * fkj + c * fnj;
 308.275 +         }
 308.276 +      }
 308.277 +      /* if U[n,n] is too small in the magnitude, replace it by exact
 308.278 +         zero */
 308.279 +      if (fabs(un[n]) < eps) un[n] = 0.0;
 308.280 +      /* store U[n,n] in a proper location */
 308.281 +      u[u_loc(scf, n, n)] = un[n];
 308.282 +      return;
 308.283 +}
 308.284 +
 308.285 +/***********************************************************************
 308.286 +*  The routine transform restores triangular structure of matrix U.
 308.287 +*  It is a driver to the routines bg_transform and gr_transform (see
 308.288 +*  comments to these routines above). */
 308.289 +
 308.290 +static void transform(SCF *scf, int k, double un[])
 308.291 +{     switch (scf->t_opt)
 308.292 +      {  case SCF_TBG:
 308.293 +            bg_transform(scf, k, un);
 308.294 +            break;
 308.295 +         case SCF_TGR:
 308.296 +            gr_transform(scf, k, un);
 308.297 +            break;
 308.298 +         default:
 308.299 +            xassert(scf != scf);
 308.300 +      }
 308.301 +      return;
 308.302 +}
 308.303 +
 308.304 +/***********************************************************************
 308.305 +*  The routine estimate_rank estimates the rank of matrix C.
 308.306 +*
 308.307 +*  Since all transformations applied to matrix F are non-singular,
 308.308 +*  and F is assumed to be well conditioned, from the main equaility
 308.309 +*  F * C = U * P it follows that rank(C) = rank(U), where rank(U) is
 308.310 +*  estimated as the number of non-zero diagonal elements of U. */
 308.311 +
 308.312 +static int estimate_rank(SCF *scf)
 308.313 +{     int n_max = scf->n_max;
 308.314 +      int n = scf->n;
 308.315 +      double *u = scf->u;
 308.316 +      int i, ii, inc, rank = 0;
 308.317 +      for (i = 1, ii = u_loc(scf, i, i), inc = n_max; i <= n;
 308.318 +         i++, ii += inc, inc--)
 308.319 +         if (u[ii] != 0.0) rank++;
 308.320 +      return rank;
 308.321 +}
 308.322 +
 308.323 +#if _GLPSCF_DEBUG
 308.324 +/***********************************************************************
 308.325 +*  The routine check_error computes the maximal relative error between
 308.326 +*  left- and right-hand sides of the main equality F * C = U * P. (This
 308.327 +*  routine is intended only for debugging.) */
 308.328 +
 308.329 +static void check_error(SCF *scf, const char *func)
 308.330 +{     int n = scf->n;
 308.331 +      double *f = scf->f;
 308.332 +      double *u = scf->u;
 308.333 +      int *p = scf->p;
 308.334 +      double *c = scf->c;
 308.335 +      int i, j, k;
 308.336 +      double d, dmax = 0.0, s, t;
 308.337 +      xassert(c != NULL);
 308.338 +      for (i = 1; i <= n; i++)
 308.339 +      {  for (j = 1; j <= n; j++)
 308.340 +         {  /* compute element (i,j) of product F * C */
 308.341 +            s = 0.0;
 308.342 +            for (k = 1; k <= n; k++)
 308.343 +               s += f[f_loc(scf, i, k)] * c[f_loc(scf, k, j)];
 308.344 +            /* compute element (i,j) of product U * P */
 308.345 +            k = p[j];
 308.346 +            t = (i <= k ? u[u_loc(scf, i, k)] : 0.0);
 308.347 +            /* compute the maximal relative error */
 308.348 +            d = fabs(s - t) / (1.0 + fabs(t));
 308.349 +            if (dmax < d) dmax = d;
 308.350 +         }
 308.351 +      }
 308.352 +      if (dmax > 1e-8)
 308.353 +         xprintf("%s: dmax = %g; relative error too large\n", func,
 308.354 +            dmax);
 308.355 +      return;
 308.356 +}
 308.357 +#endif
 308.358 +
 308.359 +/***********************************************************************
 308.360 +*  NAME
 308.361 +*
 308.362 +*  scf_update_exp - update factorization on expanding C
 308.363 +*
 308.364 +*  SYNOPSIS
 308.365 +*
 308.366 +*  #include "glpscf.h"
 308.367 +*  int scf_update_exp(SCF *scf, const double x[], const double y[],
 308.368 +*     double z);
 308.369 +*
 308.370 +*  DESCRIPTION
 308.371 +*
 308.372 +*  The routine scf_update_exp updates the factorization of matrix C on
 308.373 +*  expanding it by adding a new row and column as follows:
 308.374 +*
 308.375 +*             ( C  x )
 308.376 +*     new C = (      )
 308.377 +*             ( y' z )
 308.378 +*
 308.379 +*  where x[1,...,n] is a new column, y[1,...,n] is a new row, and z is
 308.380 +*  a new diagonal element.
 308.381 +*
 308.382 +*  If on entry the factorization is empty, the parameters x and y can
 308.383 +*  be specified as NULL.
 308.384 +*
 308.385 +*  RETURNS
 308.386 +*
 308.387 +*  0  The factorization has been successfully updated.
 308.388 +*
 308.389 +*  SCF_ESING
 308.390 +*     The factorization has been successfully updated, however, new
 308.391 +*     matrix C is singular within working precision. Note that the new
 308.392 +*     factorization remains valid.
 308.393 +*
 308.394 +*  SCF_ELIMIT
 308.395 +*     There is not enough room to expand the factorization, because
 308.396 +*     n = n_max. The factorization remains unchanged.
 308.397 +*
 308.398 +*  ALGORITHM
 308.399 +*
 308.400 +*  We can see that:
 308.401 +*
 308.402 +*     ( F  0 ) ( C  x )   ( FC  Fx )   ( UP  Fx )
 308.403 +*     (      ) (      ) = (        ) = (        ) =
 308.404 +*     ( 0  1 ) ( y' z )   ( y'   z )   ( y'   z )
 308.405 +*
 308.406 +*        ( U   Fx ) ( P  0 )
 308.407 +*     =  (        ) (      ),
 308.408 +*        ( y'P' z ) ( 0  1 )
 308.409 +*
 308.410 +*  therefore to keep the main equality F * C = U * P we can take:
 308.411 +*
 308.412 +*             ( F  0 )           ( U   Fx )           ( P  0 )
 308.413 +*     new F = (      ),  new U = (        ),  new P = (      ),
 308.414 +*             ( 0  1 )           ( y'P' z )           ( 0  1 )
 308.415 +*
 308.416 +*  and eliminate the row spike y'P' in the last row of new U to restore
 308.417 +*  its upper triangular structure. */
 308.418 +
 308.419 +int scf_update_exp(SCF *scf, const double x[], const double y[],
 308.420 +      double z)
 308.421 +{     int n_max = scf->n_max;
 308.422 +      int n = scf->n;
 308.423 +      double *f = scf->f;
 308.424 +      double *u = scf->u;
 308.425 +      int *p = scf->p;
 308.426 +#if _GLPSCF_DEBUG
 308.427 +      double *c = scf->c;
 308.428 +#endif
 308.429 +      double *un = scf->w;
 308.430 +      int i, ij, in, j, k, nj, ret = 0;
 308.431 +      double t;
 308.432 +      /* check if the factorization can be expanded */
 308.433 +      if (n == n_max)
 308.434 +      {  /* there is not enough room */
 308.435 +         ret = SCF_ELIMIT;
 308.436 +         goto done;
 308.437 +      }
 308.438 +      /* increase the order of the factorization */
 308.439 +      scf->n = ++n;
 308.440 +      /* fill new zero column of matrix F */
 308.441 +      for (i = 1, in = f_loc(scf, i, n); i < n; i++, in += n_max)
 308.442 +         f[in] = 0.0;
 308.443 +      /* fill new zero row of matrix F */
 308.444 +      for (j = 1, nj = f_loc(scf, n, j); j < n; j++, nj++)
 308.445 +         f[nj] = 0.0;
 308.446 +      /* fill new unity diagonal element of matrix F */
 308.447 +      f[f_loc(scf, n, n)] = 1.0;
 308.448 +      /* compute new column of matrix U, which is (old F) * x */
 308.449 +      for (i = 1; i < n; i++)
 308.450 +      {  /* u[i,n] := (i-th row of old F) * x */
 308.451 +         t = 0.0;
 308.452 +         for (j = 1, ij = f_loc(scf, i, 1); j < n; j++, ij++)
 308.453 +            t += f[ij] * x[j];
 308.454 +         u[u_loc(scf, i, n)] = t;
 308.455 +      }
 308.456 +      /* compute new (spiked) row of matrix U, which is (old P) * y */
 308.457 +      for (j = 1; j < n; j++) un[j] = y[p[j]];
 308.458 +      /* store new diagonal element of matrix U, which is z */
 308.459 +      un[n] = z;
 308.460 +      /* expand matrix P */
 308.461 +      p[n] = n;
 308.462 +#if _GLPSCF_DEBUG
 308.463 +      /* expand matrix C */
 308.464 +      /* fill its new column, which is x */
 308.465 +      for (i = 1, in = f_loc(scf, i, n); i < n; i++, in += n_max)
 308.466 +         c[in] = x[i];
 308.467 +      /* fill its new row, which is y */
 308.468 +      for (j = 1, nj = f_loc(scf, n, j); j < n; j++, nj++)
 308.469 +         c[nj] = y[j];
 308.470 +      /* fill its new diagonal element, which is z */
 308.471 +      c[f_loc(scf, n, n)] = z;
 308.472 +#endif
 308.473 +      /* restore upper triangular structure of matrix U */
 308.474 +      for (k = 1; k < n; k++)
 308.475 +         if (un[k] != 0.0) break;
 308.476 +      transform(scf, k, un);
 308.477 +      /* estimate the rank of matrices C and U */
 308.478 +      scf->rank = estimate_rank(scf);
 308.479 +      if (scf->rank != n) ret = SCF_ESING;
 308.480 +#if _GLPSCF_DEBUG
 308.481 +      /* check that the factorization is accurate enough */
 308.482 +      check_error(scf, "scf_update_exp");
 308.483 +#endif
 308.484 +done: return ret;
 308.485 +}
 308.486 +
 308.487 +/***********************************************************************
 308.488 +*  The routine solve solves the system C * x = b.
 308.489 +*
 308.490 +*  From the main equation F * C = U * P it follows that:
 308.491 +*
 308.492 +*     C * x = b  =>  F * C * x = F * b  =>  U * P * x = F * b  =>
 308.493 +*
 308.494 +*     P * x = inv(U) * F * b  =>  x = P' * inv(U) * F * b.
 308.495 +*
 308.496 +*  On entry the array x contains right-hand side vector b. On exit this
 308.497 +*  array contains solution vector x. */
 308.498 +
 308.499 +static void solve(SCF *scf, double x[])
 308.500 +{     int n = scf->n;
 308.501 +      double *f = scf->f;
 308.502 +      double *u = scf->u;
 308.503 +      int *p = scf->p;
 308.504 +      double *y = scf->w;
 308.505 +      int i, j, ij;
 308.506 +      double t;
 308.507 +      /* y := F * b */
 308.508 +      for (i = 1; i <= n; i++)
 308.509 +      {  /* y[i] = (i-th row of F) * b */
 308.510 +         t = 0.0;
 308.511 +         for (j = 1, ij = f_loc(scf, i, 1); j <= n; j++, ij++)
 308.512 +            t += f[ij] * x[j];
 308.513 +         y[i] = t;
 308.514 +      }
 308.515 +      /* y := inv(U) * y */
 308.516 +      for (i = n; i >= 1; i--)
 308.517 +      {  t = y[i];
 308.518 +         for (j = n, ij = u_loc(scf, i, n); j > i; j--, ij--)
 308.519 +            t -= u[ij] * y[j];
 308.520 +         y[i] = t / u[ij];
 308.521 +      }
 308.522 +      /* x := P' * y */
 308.523 +      for (i = 1; i <= n; i++) x[p[i]] = y[i];
 308.524 +      return;
 308.525 +}
 308.526 +
 308.527 +/***********************************************************************
 308.528 +*  The routine tsolve solves the transposed system C' * x = b.
 308.529 +*
 308.530 +*  From the main equation F * C = U * P it follows that:
 308.531 +*
 308.532 +*     C' * F' = P' * U',
 308.533 +*
 308.534 +*  therefore:
 308.535 +*
 308.536 +*     C' * x = b  =>  C' * F' * inv(F') * x = b  =>
 308.537 +*
 308.538 +*     P' * U' * inv(F') * x = b  =>  U' * inv(F') * x = P * b  =>
 308.539 +*
 308.540 +*     inv(F') * x = inv(U') * P * b  =>  x = F' * inv(U') * P * b.
 308.541 +*
 308.542 +*  On entry the array x contains right-hand side vector b. On exit this
 308.543 +*  array contains solution vector x. */
 308.544 +
 308.545 +static void tsolve(SCF *scf, double x[])
 308.546 +{     int n = scf->n;
 308.547 +      double *f = scf->f;
 308.548 +      double *u = scf->u;
 308.549 +      int *p = scf->p;
 308.550 +      double *y = scf->w;
 308.551 +      int i, j, ij;
 308.552 +      double t;
 308.553 +      /* y := P * b */
 308.554 +      for (i = 1; i <= n; i++) y[i] = x[p[i]];
 308.555 +      /* y := inv(U') * y */
 308.556 +      for (i = 1; i <= n; i++)
 308.557 +      {  /* compute y[i] */
 308.558 +         ij = u_loc(scf, i, i);
 308.559 +         t = (y[i] /= u[ij]);
 308.560 +         /* substitute y[i] in other equations */
 308.561 +         for (j = i+1, ij++; j <= n; j++, ij++)
 308.562 +            y[j] -= u[ij] * t;
 308.563 +      }
 308.564 +      /* x := F' * y (computed as linear combination of rows of F) */
 308.565 +      for (j = 1; j <= n; j++) x[j] = 0.0;
 308.566 +      for (i = 1; i <= n; i++)
 308.567 +      {  t = y[i]; /* coefficient of linear combination */
 308.568 +         for (j = 1, ij = f_loc(scf, i, 1); j <= n; j++, ij++)
 308.569 +            x[j] += f[ij] * t;
 308.570 +      }
 308.571 +      return;
 308.572 +}
 308.573 +
 308.574 +/***********************************************************************
 308.575 +*  NAME
 308.576 +*
 308.577 +*  scf_solve_it - solve either system C * x = b or C' * x = b
 308.578 +*
 308.579 +*  SYNOPSIS
 308.580 +*
 308.581 +*  #include "glpscf.h"
 308.582 +*  void scf_solve_it(SCF *scf, int tr, double x[]);
 308.583 +*
 308.584 +*  DESCRIPTION
 308.585 +*
 308.586 +*  The routine scf_solve_it solves either the system C * x = b (if tr
 308.587 +*  is zero) or the system C' * x = b, where C' is a matrix transposed
 308.588 +*  to C (if tr is non-zero). C is assumed to be non-singular.
 308.589 +*
 308.590 +*  On entry the array x should contain the right-hand side vector b in
 308.591 +*  locations x[1], ..., x[n], where n is the order of matrix C. On exit
 308.592 +*  the array x contains the solution vector x in the same locations. */
 308.593 +
 308.594 +void scf_solve_it(SCF *scf, int tr, double x[])
 308.595 +{     if (scf->rank < scf->n)
 308.596 +         xfault("scf_solve_it: singular matrix\n");
 308.597 +      if (!tr)
 308.598 +         solve(scf, x);
 308.599 +      else
 308.600 +         tsolve(scf, x);
 308.601 +      return;
 308.602 +}
 308.603 +
 308.604 +void scf_reset_it(SCF *scf)
 308.605 +{     /* reset factorization for empty matrix C */
 308.606 +      scf->n = scf->rank = 0;
 308.607 +      return;
 308.608 +}
 308.609 +
 308.610 +/***********************************************************************
 308.611 +*  NAME
 308.612 +*
 308.613 +*  scf_delete_it - delete Schur complement factorization
 308.614 +*
 308.615 +*  SYNOPSIS
 308.616 +*
 308.617 +*  #include "glpscf.h"
 308.618 +*  void scf_delete_it(SCF *scf);
 308.619 +*
 308.620 +*  DESCRIPTION
 308.621 +*
 308.622 +*  The routine scf_delete_it deletes the specified factorization and
 308.623 +*  frees all the memory allocated to this object. */
 308.624 +
 308.625 +void scf_delete_it(SCF *scf)
 308.626 +{     xfree(scf->f);
 308.627 +      xfree(scf->u);
 308.628 +      xfree(scf->p);
 308.629 +#if _GLPSCF_DEBUG
 308.630 +      xfree(scf->c);
 308.631 +#endif
 308.632 +      xfree(scf->w);
 308.633 +      xfree(scf);
 308.634 +      return;
 308.635 +}
 308.636 +
 308.637 +/* eof */
   309.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
   309.2 +++ b/deps/glpk/src/glpscf.h	Sun Nov 06 20:59:10 2011 +0100
   309.3 @@ -0,0 +1,126 @@
   309.4 +/* glpscf.h (Schur complement factorization) */
   309.5 +
   309.6 +/***********************************************************************
   309.7 +*  This code is part of GLPK (GNU Linear Programming Kit).
   309.8 +*
   309.9 +*  Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008,
  309.10 +*  2009, 2010, 2011 Andrew Makhorin, Department for Applied Informatics,
  309.11 +*  Moscow Aviation Institute, Moscow, Russia. All rights reserved.
  309.12 +*  E-mail: <mao@gnu.org>.
  309.13 +*
  309.14 +*  GLPK is free software: you can redistribute it and/or modify it
  309.15 +*  under the terms of the GNU General Public License as published by
  309.16 +*  the Free Software Foundation, either version 3 of the License, or
  309.17 +*  (at your option) any later version.
  309.18 +*
  309.19 +*  GLPK is distributed in the hope that it will be useful, but WITHOUT
  309.20 +*  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
  309.21 +*  or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
  309.22 +*  License for more details.
  309.23 +*
  309.24 +*  You should have received a copy of the GNU General Public License
  309.25 +*  along with GLPK. If not, see <http://www.gnu.org/licenses/>.
  309.26 +***********************************************************************/
  309.27 +
  309.28 +#ifndef GLPSCF_H
  309.29 +#define GLPSCF_H
  309.30 +
  309.31 +/***********************************************************************
  309.32 +*  The structure SCF defines the following factorization of a square
  309.33 +*  nxn matrix C (which is the Schur complement):
  309.34 +*
  309.35 +*     F * C = U * P,
  309.36 +*
  309.37 +*  where F is a square transforming matrix, U is an upper triangular
  309.38 +*  matrix, P is a permutation matrix.
  309.39 +*
  309.40 +*  It is assumed that matrix C is small and dense, so matrices F and U
  309.41 +*  are stored in the dense format by rows as follows:
  309.42 +*
  309.43 +*        1         n       n_max    1         n       n_max
  309.44 +*      1 * * * * * * x x x x      1 * * * * * * x x x x
  309.45 +*        * * * * * * x x x x        . * * * * * x x x x
  309.46 +*        * * * * * * x x x x        . . * * * * x x x x
  309.47 +*        * * * * * * x x x x        . . . * * * x x x x
  309.48 +*        * * * * * * x x x x        . . . . * * x x x x
  309.49 +*      n * * * * * * x x x x      n . . . . . * x x x x
  309.50 +*        x x x x x x x x x x        . . . . . . x x x x
  309.51 +*        x x x x x x x x x x        . . . . . . . x x x
  309.52 +*        x x x x x x x x x x        . . . . . . . . x x
  309.53 +*  n_max x x x x x x x x x x  n_max . . . . . . . . . x
  309.54 +*
  309.55 +*             matrix F                   matrix U
  309.56 +*
  309.57 +*  where '*' are matrix elements, 'x' are reserved locations.
  309.58 +*
  309.59 +*  Permutation matrix P is stored in row-like format.
  309.60 +*
  309.61 +*  Matrix C normally is not stored.
  309.62 +*
  309.63 +*  REFERENCES
  309.64 +*
  309.65 +*  1. M.A.Saunders, "LUSOL: A basis package for constrained optimiza-
  309.66 +*     tion," SCCM, Stanford University, 2006.
  309.67 +*
  309.68 +*  2. M.A.Saunders, "Notes 5: Basis Updates," CME 318, Stanford Univer-
  309.69 +*     sity, Spring 2006.
  309.70 +*
  309.71 +*  3. M.A.Saunders, "Notes 6: LUSOL---a Basis Factorization Package,"
  309.72 +*     ibid. */
  309.73 +
  309.74 +typedef struct SCF SCF;
  309.75 +
  309.76 +struct SCF
  309.77 +{     /* Schur complement factorization */
  309.78 +      int n_max;
  309.79 +      /* maximal order of matrices C, F, U, P; n_max >= 1 */
  309.80 +      int n;
  309.81 +      /* current order of matrices C, F, U, P; n >= 0 */
  309.82 +      double *f; /* double f[1+n_max*n_max]; */
  309.83 +      /* matrix F stored by rows */
  309.84 +      double *u; /* double u[1+n_max*(n_max+1)/2]; */
  309.85 +      /* upper triangle of matrix U stored by rows */
  309.86 +      int *p; /* int p[1+n_max]; */
  309.87 +      /* matrix P; p[i] = j means that P[i,j] = 1 */
  309.88 +      int t_opt;
  309.89 +      /* type of transformation used to restore triangular structure of
  309.90 +         matrix U: */
  309.91 +#define SCF_TBG      1  /* Bartels-Golub elimination */
  309.92 +#define SCF_TGR      2  /* Givens plane rotation */
  309.93 +      int rank;
  309.94 +      /* estimated rank of matrices C and U */
  309.95 +      double *c; /* double c[1+n_max*n_max]; */
  309.96 +      /* matrix C stored in the same format as matrix F and used only
  309.97 +         for debugging; normally this array is not allocated */
  309.98 +      double *w; /* double w[1+n_max]; */
  309.99 +      /* working array */
 309.100 +};
 309.101 +
 309.102 +/* return codes: */
 309.103 +#define SCF_ESING    1  /* singular matrix */
 309.104 +#define SCF_ELIMIT   2  /* update limit reached */
 309.105 +
 309.106 +#define scf_create_it _glp_scf_create_it
 309.107 +SCF *scf_create_it(int n_max);
 309.108 +/* create Schur complement factorization */
 309.109 +
 309.110 +#define scf_update_exp _glp_scf_update_exp
 309.111 +int scf_update_exp(SCF *scf, const double x[], const double y[],
 309.112 +      double z);
 309.113 +/* update factorization on expanding C */
 309.114 +
 309.115 +#define scf_solve_it _glp_scf_solve_it
 309.116 +void scf_solve_it(SCF *scf, int tr, double x[]);
 309.117 +/* solve either system C * x = b or C' * x = b */
 309.118 +
 309.119 +#define scf_reset_it _glp_scf_reset_it
 309.120 +void scf_reset_it(SCF *scf);
 309.121 +/* reset factorization for empty matrix C */
 309.122 +
 309.123 +#define scf_delete_it _glp_scf_delete_it
 309.124 +void scf_delete_it(SCF *scf);
 309.125 +/* delete Schur complement factorization */
 309.126 +
 309.127 +#endif
 309.128 +
 309.129 +/* eof */
   310.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
   310.2 +++ b/deps/glpk/src/glpscl.c	Sun Nov 06 20:59:10 2011 +0100
   310.3 @@ -0,0 +1,476 @@
   310.4 +/* glpscl.c (problem scaling routines) */
   310.5 +
   310.6 +/***********************************************************************
   310.7 +*  This code is part of GLPK (GNU Linear Programming Kit).
   310.8 +*
   310.9 +*  Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008,
  310.10 +*  2009, 2010, 2011 Andrew Makhorin, Department for Applied Informatics,
  310.11 +*  Moscow Aviation Institute, Moscow, Russia. All rights reserved.
  310.12 +*  E-mail: <mao@gnu.org>.
  310.13 +*
  310.14 +*  GLPK is free software: you can redistribute it and/or modify it
  310.15 +*  under the terms of the GNU General Public License as published by
  310.16 +*  the Free Software Foundation, either version 3 of the License, or
  310.17 +*  (at your option) any later version.
  310.18 +*
  310.19 +*  GLPK is distributed in the hope that it will be useful, but WITHOUT
  310.20 +*  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
  310.21 +*  or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
  310.22 +*  License for more details.
  310.23 +*
  310.24 +*  You should have received a copy of the GNU General Public License
  310.25 +*  along with GLPK. If not, see <http://www.gnu.org/licenses/>.
  310.26 +***********************************************************************/
  310.27 +
  310.28 +#include "glpapi.h"
  310.29 +
  310.30 +/***********************************************************************
  310.31 +*  min_row_aij - determine minimal |a[i,j]| in i-th row
  310.32 +*
  310.33 +*  This routine returns minimal magnitude of (non-zero) constraint
  310.34 +*  coefficients in i-th row of the constraint matrix.
  310.35 +*
  310.36 +*  If the parameter scaled is zero, the original constraint matrix A is
  310.37 +*  assumed. Otherwise, the scaled constraint matrix R*A*S is assumed.
  310.38 +*
  310.39 +*  If i-th row of the matrix is empty, the routine returns 1. */
  310.40 +
  310.41 +static double min_row_aij(glp_prob *lp, int i, int scaled)
  310.42 +{     GLPAIJ *aij;
  310.43 +      double min_aij, temp;
  310.44 +      xassert(1 <= i && i <= lp->m);
  310.45 +      min_aij = 1.0;
  310.46 +      for (aij = lp->row[i]->ptr; aij != NULL; aij = aij->r_next)
  310.47 +      {  temp = fabs(aij->val);
  310.48 +         if (scaled) temp *= (aij->row->rii * aij->col->sjj);
  310.49 +         if (aij->r_prev == NULL || min_aij > temp)
  310.50 +            min_aij = temp;
  310.51 +      }
  310.52 +      return min_aij;
  310.53 +}
  310.54 +
  310.55 +/***********************************************************************
  310.56 +*  max_row_aij - determine maximal |a[i,j]| in i-th row
  310.57 +*
  310.58 +*  This routine returns maximal magnitude of (non-zero) constraint
  310.59 +*  coefficients in i-th row of the constraint matrix.
  310.60 +*
  310.61 +*  If the parameter scaled is zero, the original constraint matrix A is
  310.62 +*  assumed. Otherwise, the scaled constraint matrix R*A*S is assumed.
  310.63 +*
  310.64 +*  If i-th row of the matrix is empty, the routine returns 1. */
  310.65 +
  310.66 +static double max_row_aij(glp_prob *lp, int i, int scaled)
  310.67 +{     GLPAIJ *aij;
  310.68 +      double max_aij, temp;
  310.69 +      xassert(1 <= i && i <= lp->m);
  310.70 +      max_aij = 1.0;
  310.71 +      for (aij = lp->row[i]->ptr; aij != NULL; aij = aij->r_next)
  310.72 +      {  temp = fabs(aij->val);
  310.73 +         if (scaled) temp *= (aij->row->rii * aij->col->sjj);
  310.74 +         if (aij->r_prev == NULL || max_aij < temp)
  310.75 +            max_aij = temp;
  310.76 +      }
  310.77 +      return max_aij;
  310.78 +}
  310.79 +
  310.80 +/***********************************************************************
  310.81 +*  min_col_aij - determine minimal |a[i,j]| in j-th column
  310.82 +*
  310.83 +*  This routine returns minimal magnitude of (non-zero) constraint
  310.84 +*  coefficients in j-th column of the constraint matrix.
  310.85 +*
  310.86 +*  If the parameter scaled is zero, the original constraint matrix A is
  310.87 +*  assumed. Otherwise, the scaled constraint matrix R*A*S is assumed.
  310.88 +*
  310.89 +*  If j-th column of the matrix is empty, the routine returns 1. */
  310.90 +
  310.91 +static double min_col_aij(glp_prob *lp, int j, int scaled)
  310.92 +{     GLPAIJ *aij;
  310.93 +      double min_aij, temp;
  310.94 +      xassert(1 <= j && j <= lp->n);
  310.95 +      min_aij = 1.0;
  310.96 +      for (aij = lp->col[j]->ptr; aij != NULL; aij = aij->c_next)
  310.97 +      {  temp = fabs(aij->val);
  310.98 +         if (scaled) temp *= (aij->row->rii * aij->col->sjj);
  310.99 +         if (aij->c_prev == NULL || min_aij > temp)
 310.100 +            min_aij = temp;
 310.101 +      }
 310.102 +      return min_aij;
 310.103 +}
 310.104 +
 310.105 +/***********************************************************************
 310.106 +*  max_col_aij - determine maximal |a[i,j]| in j-th column
 310.107 +*
 310.108 +*  This routine returns maximal magnitude of (non-zero) constraint
 310.109 +*  coefficients in j-th column of the constraint matrix.
 310.110 +*
 310.111 +*  If the parameter scaled is zero, the original constraint matrix A is
 310.112 +*  assumed. Otherwise, the scaled constraint matrix R*A*S is assumed.
 310.113 +*
 310.114 +*  If j-th column of the matrix is empty, the routine returns 1. */
 310.115 +
 310.116 +static double max_col_aij(glp_prob *lp, int j, int scaled)
 310.117 +{     GLPAIJ *aij;
 310.118 +      double max_aij, temp;
 310.119 +      xassert(1 <= j && j <= lp->n);
 310.120 +      max_aij = 1.0;
 310.121 +      for (aij = lp->col[j]->ptr; aij != NULL; aij = aij->c_next)
 310.122 +      {  temp = fabs(aij->val);
 310.123 +         if (scaled) temp *= (aij->row->rii * aij->col->sjj);
 310.124 +         if (aij->c_prev == NULL || max_aij < temp)
 310.125 +            max_aij = temp;
 310.126 +      }
 310.127 +      return max_aij;
 310.128 +}
 310.129 +
 310.130 +/***********************************************************************
 310.131 +*  min_mat_aij - determine minimal |a[i,j]| in constraint matrix
 310.132 +*
 310.133 +*  This routine returns minimal magnitude of (non-zero) constraint
 310.134 +*  coefficients in the constraint matrix.
 310.135 +*
 310.136 +*  If the parameter scaled is zero, the original constraint matrix A is
 310.137 +*  assumed. Otherwise, the scaled constraint matrix R*A*S is assumed.
 310.138 +*
 310.139 +*  If the matrix is empty, the routine returns 1. */
 310.140 +
 310.141 +static double min_mat_aij(glp_prob *lp, int scaled)
 310.142 +{     int i;
 310.143 +      double min_aij, temp;
 310.144 +      min_aij = 1.0;
 310.145 +      for (i = 1; i <= lp->m; i++)
 310.146 +      {  temp = min_row_aij(lp, i, scaled);
 310.147 +         if (i == 1 || min_aij > temp)
 310.148 +            min_aij = temp;
 310.149 +      }
 310.150 +      return min_aij;
 310.151 +}
 310.152 +
 310.153 +/***********************************************************************
 310.154 +*  max_mat_aij - determine maximal |a[i,j]| in constraint matrix
 310.155 +*
 310.156 +*  This routine returns maximal magnitude of (non-zero) constraint
 310.157 +*  coefficients in the constraint matrix.
 310.158 +*
 310.159 +*  If the parameter scaled is zero, the original constraint matrix A is
 310.160 +*  assumed. Otherwise, the scaled constraint matrix R*A*S is assumed.
 310.161 +*
 310.162 +*  If the matrix is empty, the routine returns 1. */
 310.163 +
 310.164 +static double max_mat_aij(glp_prob *lp, int scaled)
 310.165 +{     int i;
 310.166 +      double max_aij, temp;
 310.167 +      max_aij = 1.0;
 310.168 +      for (i = 1; i <= lp->m; i++)
 310.169 +      {  temp = max_row_aij(lp, i, scaled);
 310.170 +         if (i == 1 || max_aij < temp)
 310.171 +            max_aij = temp;
 310.172 +      }
 310.173 +      return max_aij;
 310.174 +}
 310.175 +
 310.176 +/***********************************************************************
 310.177 +*  eq_scaling - perform equilibration scaling
 310.178 +*
 310.179 +*  This routine performs equilibration scaling of rows and columns of
 310.180 +*  the constraint matrix.
 310.181 +*
 310.182 +*  If the parameter flag is zero, the routine scales rows at first and
 310.183 +*  then columns. Otherwise, the routine scales columns and then rows.
 310.184 +*
 310.185 +*  Rows are scaled as follows:
 310.186 +*
 310.187 +*                         n
 310.188 +*     a'[i,j] = a[i,j] / max |a[i,j]|,  i = 1,...,m.
 310.189 +*                        j=1
 310.190 +*
 310.191 +*  This makes the infinity (maximum) norm of each row of the matrix
 310.192 +*  equal to 1.
 310.193 +*
 310.194 +*  Columns are scaled as follows:
 310.195 +*
 310.196 +*                         m
 310.197 +*     a'[i,j] = a[i,j] / max |a[i,j]|,  j = 1,...,n.
 310.198 +*                        i=1
 310.199 +*
 310.200 +*  This makes the infinity (maximum) norm of each column of the matrix
 310.201 +*  equal to 1. */
 310.202 +
 310.203 +static void eq_scaling(glp_prob *lp, int flag)
 310.204 +{     int i, j, pass;
 310.205 +      double temp;
 310.206 +      xassert(flag == 0 || flag == 1);
 310.207 +      for (pass = 0; pass <= 1; pass++)
 310.208 +      {  if (pass == flag)
 310.209 +         {  /* scale rows */
 310.210 +            for (i = 1; i <= lp->m; i++)
 310.211 +            {  temp = max_row_aij(lp, i, 1);
 310.212 +               glp_set_rii(lp, i, glp_get_rii(lp, i) / temp);
 310.213 +            }
 310.214 +         }
 310.215 +         else
 310.216 +         {  /* scale columns */
 310.217 +            for (j = 1; j <= lp->n; j++)
 310.218 +            {  temp = max_col_aij(lp, j, 1);
 310.219 +               glp_set_sjj(lp, j, glp_get_sjj(lp, j) / temp);
 310.220 +            }
 310.221 +         }
 310.222 +      }
 310.223 +      return;
 310.224 +}
 310.225 +
 310.226 +/***********************************************************************
 310.227 +*  gm_scaling - perform geometric mean scaling
 310.228 +*
 310.229 +*  This routine performs geometric mean scaling of rows and columns of
 310.230 +*  the constraint matrix.
 310.231 +*
 310.232 +*  If the parameter flag is zero, the routine scales rows at first and
 310.233 +*  then columns. Otherwise, the routine scales columns and then rows.
 310.234 +*
 310.235 +*  Rows are scaled as follows:
 310.236 +*
 310.237 +*     a'[i,j] = a[i,j] / sqrt(alfa[i] * beta[i]),  i = 1,...,m,
 310.238 +*
 310.239 +*  where:
 310.240 +*                n                        n
 310.241 +*     alfa[i] = min |a[i,j]|,  beta[i] = max |a[i,j]|.
 310.242 +*               j=1                      j=1
 310.243 +*
 310.244 +*  This allows decreasing the ratio beta[i] / alfa[i] for each row of
 310.245 +*  the matrix.
 310.246 +*
 310.247 +*  Columns are scaled as follows:
 310.248 +*
 310.249 +*     a'[i,j] = a[i,j] / sqrt(alfa[j] * beta[j]),  j = 1,...,n,
 310.250 +*
 310.251 +*  where:
 310.252 +*                m                        m
 310.253 +*     alfa[j] = min |a[i,j]|,  beta[j] = max |a[i,j]|.
 310.254 +*               i=1                      i=1
 310.255 +*
 310.256 +*  This allows decreasing the ratio beta[j] / alfa[j] for each column
 310.257 +*  of the matrix. */
 310.258 +
 310.259 +static void gm_scaling(glp_prob *lp, int flag)
 310.260 +{     int i, j, pass;
 310.261 +      double temp;
 310.262 +      xassert(flag == 0 || flag == 1);
 310.263 +      for (pass = 0; pass <= 1; pass++)
 310.264 +      {  if (pass == flag)
 310.265 +         {  /* scale rows */
 310.266 +            for (i = 1; i <= lp->m; i++)
 310.267 +            {  temp = min_row_aij(lp, i, 1) * max_row_aij(lp, i, 1);
 310.268 +               glp_set_rii(lp, i, glp_get_rii(lp, i) / sqrt(temp));
 310.269 +            }
 310.270 +         }
 310.271 +         else
 310.272 +         {  /* scale columns */
 310.273 +            for (j = 1; j <= lp->n; j++)
 310.274 +            {  temp = min_col_aij(lp, j, 1) * max_col_aij(lp, j, 1);
 310.275 +               glp_set_sjj(lp, j, glp_get_sjj(lp, j) / sqrt(temp));
 310.276 +            }
 310.277 +         }
 310.278 +      }
 310.279 +      return;
 310.280 +}
 310.281 +
 310.282 +/***********************************************************************
 310.283 +*  max_row_ratio - determine worst scaling "quality" for rows
 310.284 +*
 310.285 +*  This routine returns the worst scaling "quality" for rows of the
 310.286 +*  currently scaled constraint matrix:
 310.287 +*
 310.288 +*              m
 310.289 +*     ratio = max ratio[i],
 310.290 +*             i=1
 310.291 +*  where:
 310.292 +*                 n              n
 310.293 +*     ratio[i] = max |a[i,j]| / min |a[i,j]|,  1 <= i <= m,
 310.294 +*                j=1            j=1
 310.295 +*
 310.296 +*  is the scaling "quality" of i-th row. */
 310.297 +
 310.298 +static double max_row_ratio(glp_prob *lp)
 310.299 +{     int i;
 310.300 +      double ratio, temp;
 310.301 +      ratio = 1.0;
 310.302 +      for (i = 1; i <= lp->m; i++)
 310.303 +      {  temp = max_row_aij(lp, i, 1) / min_row_aij(lp, i, 1);
 310.304 +         if (i == 1 || ratio < temp) ratio = temp;
 310.305 +      }
 310.306 +      return ratio;
 310.307 +}
 310.308 +
 310.309 +/***********************************************************************
 310.310 +*  max_col_ratio - determine worst scaling "quality" for columns
 310.311 +*
 310.312 +*  This routine returns the worst scaling "quality" for columns of the
 310.313 +*  currently scaled constraint matrix:
 310.314 +*
 310.315 +*              n
 310.316 +*     ratio = max ratio[j],
 310.317 +*             j=1
 310.318 +*  where:
 310.319 +*                 m              m
 310.320 +*     ratio[j] = max |a[i,j]| / min |a[i,j]|,  1 <= j <= n,
 310.321 +*                i=1            i=1
 310.322 +*
 310.323 +*  is the scaling "quality" of j-th column. */
 310.324 +
 310.325 +static double max_col_ratio(glp_prob *lp)
 310.326 +{     int j;
 310.327 +      double ratio, temp;
 310.328 +      ratio = 1.0;
 310.329 +      for (j = 1; j <= lp->n; j++)
 310.330 +      {  temp = max_col_aij(lp, j, 1) / min_col_aij(lp, j, 1);
 310.331 +         if (j == 1 || ratio < temp) ratio = temp;
 310.332 +      }
 310.333 +      return ratio;
 310.334 +}
 310.335 +
 310.336 +/***********************************************************************
 310.337 +*  gm_iterate - perform iterative geometric mean scaling
 310.338 +*
 310.339 +*  This routine performs iterative geometric mean scaling of rows and
 310.340 +*  columns of the constraint matrix.
 310.341 +*
 310.342 +*  The parameter it_max specifies the maximal number of iterations.
 310.343 +*  Recommended value of it_max is 15.
 310.344 +*
 310.345 +*  The parameter tau specifies a minimal improvement of the scaling
 310.346 +*  "quality" on each iteration, 0 < tau < 1. It means than the scaling
 310.347 +*  process continues while the following condition is satisfied:
 310.348 +*
 310.349 +*     ratio[k] <= tau * ratio[k-1],
 310.350 +*
 310.351 +*  where ratio = max |a[i,j]| / min |a[i,j]| is the scaling "quality"
 310.352 +*  to be minimized, k is the iteration number. Recommended value of tau
 310.353 +*  is 0.90. */
 310.354 +
 310.355 +static void gm_iterate(glp_prob *lp, int it_max, double tau)
 310.356 +{     int k, flag;
 310.357 +      double ratio = 0.0, r_old;
 310.358 +      /* if the scaling "quality" for rows is better than for columns,
 310.359 +         the rows are scaled first; otherwise, the columns are scaled
 310.360 +         first */
 310.361 +      flag = (max_row_ratio(lp) > max_col_ratio(lp));
 310.362 +      for (k = 1; k <= it_max; k++)
 310.363 +      {  /* save the scaling "quality" from previous iteration */
 310.364 +         r_old = ratio;
 310.365 +         /* determine the current scaling "quality" */
 310.366 +         ratio = max_mat_aij(lp, 1) / min_mat_aij(lp, 1);
 310.367 +#if 0
 310.368 +         xprintf("k = %d; ratio = %g\n", k, ratio);
 310.369 +#endif
 310.370 +         /* if improvement is not enough, terminate scaling */
 310.371 +         if (k > 1 && ratio > tau * r_old) break;
 310.372 +         /* otherwise, perform another iteration */
 310.373 +         gm_scaling(lp, flag);
 310.374 +      }
 310.375 +      return;
 310.376 +}
 310.377 +
 310.378 +/***********************************************************************
 310.379 +*  NAME
 310.380 +*
 310.381 +*  scale_prob - scale problem data
 310.382 +*
 310.383 +*  SYNOPSIS
 310.384 +*
 310.385 +*  #include "glpscl.h"
 310.386 +*  void scale_prob(glp_prob *lp, int flags);
 310.387 +*
 310.388 +*  DESCRIPTION
 310.389 +*
 310.390 +*  The routine scale_prob performs automatic scaling of problem data
 310.391 +*  for the specified problem object. */
 310.392 +
 310.393 +static void scale_prob(glp_prob *lp, int flags)
 310.394 +{     static const char *fmt =
 310.395 +         "%s: min|aij| = %10.3e  max|aij| = %10.3e  ratio = %10.3e\n";
 310.396 +      double min_aij, max_aij, ratio;
 310.397 +      xprintf("Scaling...\n");
 310.398 +      /* cancel the current scaling effect */
 310.399 +      glp_unscale_prob(lp);
 310.400 +      /* report original scaling "quality" */
 310.401 +      min_aij = min_mat_aij(lp, 1);
 310.402 +      max_aij = max_mat_aij(lp, 1);
 310.403 +      ratio = max_aij / min_aij;
 310.404 +      xprintf(fmt, " A", min_aij, max_aij, ratio);
 310.405 +      /* check if the problem is well scaled */
 310.406 +      if (min_aij >= 0.10 && max_aij <= 10.0)
 310.407 +      {  xprintf("Problem data seem to be well scaled\n");
 310.408 +         /* skip scaling, if required */
 310.409 +         if (flags & GLP_SF_SKIP) goto done;
 310.410 +      }
 310.411 +      /* perform iterative geometric mean scaling, if required */
 310.412 +      if (flags & GLP_SF_GM)
 310.413 +      {  gm_iterate(lp, 15, 0.90);
 310.414 +         min_aij = min_mat_aij(lp, 1);
 310.415 +         max_aij = max_mat_aij(lp, 1);
 310.416 +         ratio = max_aij / min_aij;
 310.417 +         xprintf(fmt, "GM", min_aij, max_aij, ratio);
 310.418 +      }
 310.419 +      /* perform equilibration scaling, if required */
 310.420 +      if (flags & GLP_SF_EQ)
 310.421 +      {  eq_scaling(lp, max_row_ratio(lp) > max_col_ratio(lp));
 310.422 +         min_aij = min_mat_aij(lp, 1);
 310.423 +         max_aij = max_mat_aij(lp, 1);
 310.424 +         ratio = max_aij / min_aij;
 310.425 +         xprintf(fmt, "EQ", min_aij, max_aij, ratio);
 310.426 +      }
 310.427 +      /* round scale factors to nearest power of two, if required */
 310.428 +      if (flags & GLP_SF_2N)
 310.429 +      {  int i, j;
 310.430 +         for (i = 1; i <= lp->m; i++)
 310.431 +            glp_set_rii(lp, i, round2n(glp_get_rii(lp, i)));
 310.432 +         for (j = 1; j <= lp->n; j++)
 310.433 +            glp_set_sjj(lp, j, round2n(glp_get_sjj(lp, j)));
 310.434 +         min_aij = min_mat_aij(lp, 1);
 310.435 +         max_aij = max_mat_aij(lp, 1);
 310.436 +         ratio = max_aij / min_aij;
 310.437 +         xprintf(fmt, "2N", min_aij, max_aij, ratio);
 310.438 +      }
 310.439 +done: return;
 310.440 +}
 310.441 +
 310.442 +/***********************************************************************
 310.443 +*  NAME
 310.444 +*
 310.445 +*  glp_scale_prob - scale problem data
 310.446 +*
 310.447 +*  SYNOPSIS
 310.448 +*
 310.449 +*  void glp_scale_prob(glp_prob *lp, int flags);
 310.450 +*
 310.451 +*  DESCRIPTION
 310.452 +*
 310.453 +*  The routine glp_scale_prob performs automatic scaling of problem
 310.454 +*  data for the specified problem object.
 310.455 +*
 310.456 +*  The parameter flags specifies scaling options used by the routine.
 310.457 +*  Options can be combined with the bitwise OR operator and may be the
 310.458 +*  following:
 310.459 +*
 310.460 +*  GLP_SF_GM      perform geometric mean scaling;
 310.461 +*  GLP_SF_EQ      perform equilibration scaling;
 310.462 +*  GLP_SF_2N      round scale factors to nearest power of two;
 310.463 +*  GLP_SF_SKIP    skip scaling, if the problem is well scaled.
 310.464 +*
 310.465 +*  The parameter flags may be specified as GLP_SF_AUTO, in which case
 310.466 +*  the routine chooses scaling options automatically. */
 310.467 +
 310.468 +void glp_scale_prob(glp_prob *lp, int flags)
 310.469 +{     if (flags & ~(GLP_SF_GM | GLP_SF_EQ | GLP_SF_2N | GLP_SF_SKIP |
 310.470 +                    GLP_SF_AUTO))
 310.471 +         xerror("glp_scale_prob: flags = 0x%02X; invalid scaling option"
 310.472 +            "s\n", flags);
 310.473 +      if (flags & GLP_SF_AUTO)
 310.474 +         flags = (GLP_SF_GM | GLP_SF_EQ | GLP_SF_SKIP);
 310.475 +      scale_prob(lp, flags);
 310.476 +      return;
 310.477 +}
 310.478 +
 310.479 +/* eof */
   311.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
   311.2 +++ b/deps/glpk/src/glpsdf.c	Sun Nov 06 20:59:10 2011 +0100
   311.3 @@ -0,0 +1,262 @@
   311.4 +/* glpsdf.c (plain data file reading routines) */
   311.5 +
   311.6 +/***********************************************************************
   311.7 +*  This code is part of GLPK (GNU Linear Programming Kit).
   311.8 +*
   311.9 +*  Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008,
  311.10 +*  2009, 2010, 2011 Andrew Makhorin, Department for Applied Informatics,
  311.11 +*  Moscow Aviation Institute, Moscow, Russia. All rights reserved.
  311.12 +*  E-mail: <mao@gnu.org>.
  311.13 +*
  311.14 +*  GLPK is free software: you can redistribute it and/or modify it
  311.15 +*  under the terms of the GNU General Public License as published by
  311.16 +*  the Free Software Foundation, either version 3 of the License, or
  311.17 +*  (at your option) any later version.
  311.18 +*
  311.19 +*  GLPK is distributed in the hope that it will be useful, but WITHOUT
  311.20 +*  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
  311.21 +*  or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
  311.22 +*  License for more details.
  311.23 +*
  311.24 +*  You should have received a copy of the GNU General Public License
  311.25 +*  along with GLPK. If not, see <http://www.gnu.org/licenses/>.
  311.26 +***********************************************************************/
  311.27 +
  311.28 +#define GLPSDF_H
  311.29 +
  311.30 +#define GLP_DATA_DEFINED
  311.31 +typedef struct glp_data glp_data;
  311.32 +
  311.33 +#include "glpapi.h"
  311.34 +
  311.35 +struct glp_data
  311.36 +{     /* plain data file */
  311.37 +      char *fname;
  311.38 +      /* name of data file */
  311.39 +      XFILE *fp;
  311.40 +      /* stream assigned to data file */
  311.41 +      void *jump; /* jmp_buf jump; */
  311.42 +      /* label for go to in case of error */
  311.43 +      int count;
  311.44 +      /* line count */
  311.45 +      int c;
  311.46 +      /* current character of XEOF */
  311.47 +      char item[255+1];
  311.48 +      /* current data item */
  311.49 +};
  311.50 +
  311.51 +static void next_char(glp_data *data);
  311.52 +
  311.53 +glp_data *glp_sdf_open_file(const char *fname)
  311.54 +{     /* open plain data file */
  311.55 +      glp_data *data = NULL;
  311.56 +      XFILE *fp;
  311.57 +      jmp_buf jump;
  311.58 +      fp = xfopen(fname, "r");
  311.59 +      if (fp == NULL)
  311.60 +      {  xprintf("Unable to open `%s' - %s\n", fname, xerrmsg());
  311.61 +         goto done;
  311.62 +      }
  311.63 +      data = xmalloc(sizeof(glp_data));
  311.64 +      data->fname = xmalloc(strlen(fname)+1);
  311.65 +      strcpy(data->fname, fname);
  311.66 +      data->fp = fp;
  311.67 +      data->jump = NULL;
  311.68 +      data->count = 0;
  311.69 +      data->c = '\n';
  311.70 +      data->item[0] = '\0';
  311.71 +      /* read the very first character */
  311.72 +      if (setjmp(jump))
  311.73 +      {  glp_sdf_close_file(data);
  311.74 +         data = NULL;
  311.75 +         goto done;
  311.76 +      }
  311.77 +      data->jump = jump;
  311.78 +      next_char(data);
  311.79 +      data->jump = NULL;
  311.80 +done: return data;
  311.81 +}
  311.82 +
  311.83 +void glp_sdf_set_jump(glp_data *data, void *jump)
  311.84 +{     /* set up error handling */
  311.85 +      data->jump = jump;
  311.86 +      return;
  311.87 +}
  311.88 +
  311.89 +void glp_sdf_error(glp_data *data, const char *fmt, ...)
  311.90 +{     /* print error message */
  311.91 +      va_list arg;
  311.92 +      xprintf("%s:%d: ", data->fname, data->count);
  311.93 +      va_start(arg, fmt);
  311.94 +      xvprintf(fmt, arg);
  311.95 +      va_end(arg);
  311.96 +      if (data->jump == NULL)
  311.97 +         xerror("");
  311.98 +      else
  311.99 +         longjmp(data->jump, 1);
 311.100 +      /* no return */
 311.101 +}
 311.102 +
 311.103 +void glp_sdf_warning(glp_data *data, const char *fmt, ...)
 311.104 +{     /* print warning message */
 311.105 +      va_list arg;
 311.106 +      xprintf("%s:%d: warning: ", data->fname, data->count);
 311.107 +      va_start(arg, fmt);
 311.108 +      xvprintf(fmt, arg);
 311.109 +      va_end(arg);
 311.110 +      return;
 311.111 +}
 311.112 +
 311.113 +static void next_char(glp_data *data)
 311.114 +{     /* read next character */
 311.115 +      int c;
 311.116 +      if (data->c == XEOF)
 311.117 +         glp_sdf_error(data, "unexpected end of file\n");
 311.118 +      else if (data->c == '\n')
 311.119 +         data->count++;
 311.120 +      c = xfgetc(data->fp);
 311.121 +      if (c < 0)
 311.122 +      {  if (xferror(data->fp))
 311.123 +            glp_sdf_error(data, "read error - %s\n", xerrmsg());
 311.124 +         else if (data->c == '\n')
 311.125 +            c = XEOF;
 311.126 +         else
 311.127 +         {  glp_sdf_warning(data, "missing final end of line\n");
 311.128 +            c = '\n';
 311.129 +         }
 311.130 +      }
 311.131 +      else if (c == '\n')
 311.132 +         ;
 311.133 +      else if (isspace(c))
 311.134 +         c = ' ';
 311.135 +      else if (iscntrl(c))
 311.136 +         glp_sdf_error(data, "invalid control character 0x%02X\n", c);
 311.137 +      data->c = c;
 311.138 +      return;
 311.139 +}
 311.140 +
 311.141 +static void skip_pad(glp_data *data)
 311.142 +{     /* skip uninteresting characters and comments */
 311.143 +loop: while (data->c == ' ' || data->c == '\n')
 311.144 +         next_char(data);
 311.145 +      if (data->c == '/')
 311.146 +      {  next_char(data);
 311.147 +         if (data->c != '*')
 311.148 +            glp_sdf_error(data, "invalid use of slash\n");
 311.149 +         next_char(data);
 311.150 +         for (;;)
 311.151 +         {  if (data->c == '*')
 311.152 +            {  next_char(data);
 311.153 +               if (data->c == '/')
 311.154 +               {  next_char(data);
 311.155 +                  break;
 311.156 +               }
 311.157 +            }
 311.158 +            next_char(data);
 311.159 +         }
 311.160 +         goto loop;
 311.161 +      }
 311.162 +      return;
 311.163 +}
 311.164 +
 311.165 +static void next_item(glp_data *data)
 311.166 +{     /* read next item */
 311.167 +      int len;
 311.168 +      skip_pad(data);
 311.169 +      len = 0;
 311.170 +      while (!(data->c == ' ' || data->c == '\n'))
 311.171 +      {  data->item[len++] = (char)data->c;
 311.172 +         if (len == sizeof(data->item))
 311.173 +            glp_sdf_error(data, "data item `%.31s...' too long\n",
 311.174 +               data->item);
 311.175 +         next_char(data);
 311.176 +      }
 311.177 +      data->item[len] = '\0';
 311.178 +      return;
 311.179 +}
 311.180 +
 311.181 +int glp_sdf_read_int(glp_data *data)
 311.182 +{     /* read integer number */
 311.183 +      int x;
 311.184 +      next_item(data);
 311.185 +      switch (str2int(data->item, &x))
 311.186 +      {  case 0:
 311.187 +            break;
 311.188 +         case 1:
 311.189 +            glp_sdf_error(data, "integer `%s' out of range\n",
 311.190 +               data->item);
 311.191 +         case 2:
 311.192 +            glp_sdf_error(data, "cannot convert `%s' to integer\n",
 311.193 +               data->item);
 311.194 +         default:
 311.195 +            xassert(data != data);
 311.196 +      }
 311.197 +      return x;
 311.198 +}
 311.199 +
 311.200 +double glp_sdf_read_num(glp_data *data)
 311.201 +{     /* read floating-point number */
 311.202 +      double x;
 311.203 +      next_item(data);
 311.204 +      switch (str2num(data->item, &x))
 311.205 +      {  case 0:
 311.206 +            break;
 311.207 +         case 1:
 311.208 +            glp_sdf_error(data, "number `%s' out of range\n",
 311.209 +               data->item);
 311.210 +         case 2:
 311.211 +            glp_sdf_error(data, "cannot convert `%s' to number\n",
 311.212 +               data->item);
 311.213 +         default:
 311.214 +            xassert(data != data);
 311.215 +      }
 311.216 +      return x;
 311.217 +}
 311.218 +
 311.219 +const char *glp_sdf_read_item(glp_data *data)
 311.220 +{     /* read data item */
 311.221 +      next_item(data);
 311.222 +      return data->item;
 311.223 +}
 311.224 +
 311.225 +const char *glp_sdf_read_text(glp_data *data)
 311.226 +{     /* read text until end of line */
 311.227 +      int c, len = 0;
 311.228 +      for (;;)
 311.229 +      {  c = data->c;
 311.230 +         next_char(data);
 311.231 +         if (c == ' ')
 311.232 +         {  /* ignore initial spaces */
 311.233 +            if (len == 0) continue;
 311.234 +            /* and multiple ones */
 311.235 +            if (data->item[len-1] == ' ') continue;
 311.236 +         }
 311.237 +         else if (c == '\n')
 311.238 +         {  /* remove trailing space */
 311.239 +            if (len > 0 && data->item[len-1] == ' ') len--;
 311.240 +            /* and stop reading */
 311.241 +            break;
 311.242 +         }
 311.243 +         /* add current character to the buffer */
 311.244 +         data->item[len++] = (char)c;
 311.245 +         if (len == sizeof(data->item))
 311.246 +            glp_sdf_error(data, "line too long\n", data->item);
 311.247 +      }
 311.248 +      data->item[len] = '\0';
 311.249 +      return data->item;
 311.250 +}
 311.251 +
 311.252 +int glp_sdf_line(glp_data *data)
 311.253 +{     /* determine current line number */
 311.254 +      return data->count;
 311.255 +}
 311.256 +
 311.257 +void glp_sdf_close_file(glp_data *data)
 311.258 +{     /* close plain data file */
 311.259 +      xfclose(data->fp);
 311.260 +      xfree(data->fname);
 311.261 +      xfree(data);
 311.262 +      return;
 311.263 +}
 311.264 +
 311.265 +/* eof */
   312.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
   312.2 +++ b/deps/glpk/src/glpspm.c	Sun Nov 06 20:59:10 2011 +0100
   312.3 @@ -0,0 +1,846 @@
   312.4 +/* glpspm.c */
   312.5 +
   312.6 +/***********************************************************************
   312.7 +*  This code is part of GLPK (GNU Linear Programming Kit).
   312.8 +*
   312.9 +*  Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008,
  312.10 +*  2009, 2010, 2011 Andrew Makhorin, Department for Applied Informatics,
  312.11 +*  Moscow Aviation Institute, Moscow, Russia. All rights reserved.
  312.12 +*  E-mail: <mao@gnu.org>.
  312.13 +*
  312.14 +*  GLPK is free software: you can redistribute it and/or modify it
  312.15 +*  under the terms of the GNU General Public License as published by
  312.16 +*  the Free Software Foundation, either version 3 of the License, or
  312.17 +*  (at your option) any later version.
  312.18 +*
  312.19 +*  GLPK is distributed in the hope that it will be useful, but WITHOUT
  312.20 +*  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
  312.21 +*  or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
  312.22 +*  License for more details.
  312.23 +*
  312.24 +*  You should have received a copy of the GNU General Public License
  312.25 +*  along with GLPK. If not, see <http://www.gnu.org/licenses/>.
  312.26 +***********************************************************************/
  312.27 +
  312.28 +#include "glphbm.h"
  312.29 +#include "glprgr.h"
  312.30 +#include "glpspm.h"
  312.31 +
  312.32 +/***********************************************************************
  312.33 +*  NAME
  312.34 +*
  312.35 +*  spm_create_mat - create general sparse matrix
  312.36 +*
  312.37 +*  SYNOPSIS
  312.38 +*
  312.39 +*  #include "glpspm.h"
  312.40 +*  SPM *spm_create_mat(int m, int n);
  312.41 +*
  312.42 +*  DESCRIPTION
  312.43 +*
  312.44 +*  The routine spm_create_mat creates a general sparse matrix having
  312.45 +*  m rows and n columns. Being created the matrix is zero (empty), i.e.
  312.46 +*  has no elements.
  312.47 +*
  312.48 +*  RETURNS
  312.49 +*
  312.50 +*  The routine returns a pointer to the matrix created. */
  312.51 +
  312.52 +SPM *spm_create_mat(int m, int n)
  312.53 +{     SPM *A;
  312.54 +      xassert(0 <= m && m < INT_MAX);
  312.55 +      xassert(0 <= n && n < INT_MAX);
  312.56 +      A = xmalloc(sizeof(SPM));
  312.57 +      A->m = m;
  312.58 +      A->n = n;
  312.59 +      if (m == 0 || n == 0)
  312.60 +      {  A->pool = NULL;
  312.61 +         A->row = NULL;
  312.62 +         A->col = NULL;
  312.63 +      }
  312.64 +      else
  312.65 +      {  int i, j;
  312.66 +         A->pool = dmp_create_pool();
  312.67 +         A->row = xcalloc(1+m, sizeof(SPME *));
  312.68 +         for (i = 1; i <= m; i++) A->row[i] = NULL;
  312.69 +         A->col = xcalloc(1+n, sizeof(SPME *));
  312.70 +         for (j = 1; j <= n; j++) A->col[j] = NULL;
  312.71 +      }
  312.72 +      return A;
  312.73 +}
  312.74 +
  312.75 +/***********************************************************************
  312.76 +*  NAME
  312.77 +*
  312.78 +*  spm_new_elem - add new element to sparse matrix
  312.79 +*
  312.80 +*  SYNOPSIS
  312.81 +*
  312.82 +*  #include "glpspm.h"
  312.83 +*  SPME *spm_new_elem(SPM *A, int i, int j, double val);
  312.84 +*
  312.85 +*  DESCRIPTION
  312.86 +*
  312.87 +*  The routine spm_new_elem adds a new element to the specified sparse
  312.88 +*  matrix. Parameters i, j, and val specify the row number, the column
  312.89 +*  number, and a numerical value of the element, respectively.
  312.90 +*
  312.91 +*  RETURNS
  312.92 +*
  312.93 +*  The routine returns a pointer to the new element added. */
  312.94 +
  312.95 +SPME *spm_new_elem(SPM *A, int i, int j, double val)
  312.96 +{     SPME *e;
  312.97 +      xassert(1 <= i && i <= A->m);
  312.98 +      xassert(1 <= j && j <= A->n);
  312.99 +      e = dmp_get_atom(A->pool, sizeof(SPME));
 312.100 +      e->i = i;
 312.101 +      e->j = j;
 312.102 +      e->val = val;
 312.103 +      e->r_prev = NULL;
 312.104 +      e->r_next = A->row[i];
 312.105 +      if (e->r_next != NULL) e->r_next->r_prev = e;
 312.106 +      e->c_prev = NULL;
 312.107 +      e->c_next = A->col[j];
 312.108 +      if (e->c_next != NULL) e->c_next->c_prev = e;
 312.109 +      A->row[i] = A->col[j] = e;
 312.110 +      return e;
 312.111 +}
 312.112 +
 312.113 +/***********************************************************************
 312.114 +*  NAME
 312.115 +*
 312.116 +*  spm_delete_mat - delete general sparse matrix
 312.117 +*
 312.118 +*  SYNOPSIS
 312.119 +*
 312.120 +*  #include "glpspm.h"
 312.121 +*  void spm_delete_mat(SPM *A);
 312.122 +*
 312.123 +*  DESCRIPTION
 312.124 +*
 312.125 +*  The routine deletes the specified general sparse matrix freeing all
 312.126 +*  the memory allocated to this object. */
 312.127 +
 312.128 +void spm_delete_mat(SPM *A)
 312.129 +{     /* delete sparse matrix */
 312.130 +      if (A->pool != NULL) dmp_delete_pool(A->pool);
 312.131 +      if (A->row != NULL) xfree(A->row);
 312.132 +      if (A->col != NULL) xfree(A->col);
 312.133 +      xfree(A);
 312.134 +      return;
 312.135 +}
 312.136 +
 312.137 +/***********************************************************************
 312.138 +*  NAME
 312.139 +*
 312.140 +*  spm_test_mat_e - create test sparse matrix of E(n,c) class
 312.141 +*
 312.142 +*  SYNOPSIS
 312.143 +*
 312.144 +*  #include "glpspm.h"
 312.145 +*  SPM *spm_test_mat_e(int n, int c);
 312.146 +*
 312.147 +*  DESCRIPTION
 312.148 +*
 312.149 +*  The routine spm_test_mat_e creates a test sparse matrix of E(n,c)
 312.150 +*  class as described in the book: Ole 0sterby, Zahari Zlatev. Direct
 312.151 +*  Methods for Sparse Matrices. Springer-Verlag, 1983.
 312.152 +*
 312.153 +*  Matrix of E(n,c) class is a symmetric positive definite matrix of
 312.154 +*  the order n. It has the number 4 on its main diagonal and the number
 312.155 +*  -1 on its four co-diagonals, two of which are neighbour to the main
 312.156 +*  diagonal and two others are shifted from the main diagonal on the
 312.157 +*  distance c.
 312.158 +*
 312.159 +*  It is necessary that n >= 3 and 2 <= c <= n-1.
 312.160 +*
 312.161 +*  RETURNS
 312.162 +*
 312.163 +*  The routine returns a pointer to the matrix created. */
 312.164 +
 312.165 +SPM *spm_test_mat_e(int n, int c)
 312.166 +{     SPM *A;
 312.167 +      int i;
 312.168 +      xassert(n >= 3 && 2 <= c && c <= n-1);
 312.169 +      A = spm_create_mat(n, n);
 312.170 +      for (i = 1; i <= n; i++)
 312.171 +         spm_new_elem(A, i, i, 4.0);
 312.172 +      for (i = 1; i <= n-1; i++)
 312.173 +      {  spm_new_elem(A, i, i+1, -1.0);
 312.174 +         spm_new_elem(A, i+1, i, -1.0);
 312.175 +      }
 312.176 +      for (i = 1; i <= n-c; i++)
 312.177 +      {  spm_new_elem(A, i, i+c, -1.0);
 312.178 +         spm_new_elem(A, i+c, i, -1.0);
 312.179 +      }
 312.180 +      return A;
 312.181 +}
 312.182 +
 312.183 +/***********************************************************************
 312.184 +*  NAME
 312.185 +*
 312.186 +*  spm_test_mat_d - create test sparse matrix of D(n,c) class
 312.187 +*
 312.188 +*  SYNOPSIS
 312.189 +*
 312.190 +*  #include "glpspm.h"
 312.191 +*  SPM *spm_test_mat_d(int n, int c);
 312.192 +*
 312.193 +*  DESCRIPTION
 312.194 +*
 312.195 +*  The routine spm_test_mat_d creates a test sparse matrix of D(n,c)
 312.196 +*  class as described in the book: Ole 0sterby, Zahari Zlatev. Direct
 312.197 +*  Methods for Sparse Matrices. Springer-Verlag, 1983.
 312.198 +*
 312.199 +*  Matrix of D(n,c) class is a non-singular matrix of the order n. It
 312.200 +*  has unity main diagonal, three co-diagonals above the main diagonal
 312.201 +*  on the distance c, which are cyclically continued below the main
 312.202 +*  diagonal, and a triangle block of the size 10x10 in the upper right
 312.203 +*  corner.
 312.204 +*
 312.205 +*  It is necessary that n >= 14 and 1 <= c <= n-13.
 312.206 +*
 312.207 +*  RETURNS
 312.208 +*
 312.209 +*  The routine returns a pointer to the matrix created. */
 312.210 +
 312.211 +SPM *spm_test_mat_d(int n, int c)
 312.212 +{     SPM *A;
 312.213 +      int i, j;
 312.214 +      xassert(n >= 14 && 1 <= c && c <= n-13);
 312.215 +      A = spm_create_mat(n, n);
 312.216 +      for (i = 1; i <= n; i++)
 312.217 +         spm_new_elem(A, i, i, 1.0);
 312.218 +      for (i = 1; i <= n-c; i++)
 312.219 +         spm_new_elem(A, i, i+c, (double)(i+1));
 312.220 +      for (i = n-c+1; i <= n; i++)
 312.221 +         spm_new_elem(A, i, i-n+c, (double)(i+1));
 312.222 +      for (i = 1; i <= n-c-1; i++)
 312.223 +         spm_new_elem(A, i, i+c+1, (double)(-i));
 312.224 +      for (i = n-c; i <= n; i++)
 312.225 +         spm_new_elem(A, i, i-n+c+1, (double)(-i));
 312.226 +      for (i = 1; i <= n-c-2; i++)
 312.227 +         spm_new_elem(A, i, i+c+2, 16.0);
 312.228 +      for (i = n-c-1; i <= n; i++)
 312.229 +         spm_new_elem(A, i, i-n+c+2, 16.0);
 312.230 +      for (j = 1; j <= 10; j++)
 312.231 +         for (i = 1; i <= 11-j; i++)
 312.232 +            spm_new_elem(A, i, n-11+i+j, 100.0 * (double)j);
 312.233 +      return A;
 312.234 +}
 312.235 +
 312.236 +/***********************************************************************
 312.237 +*  NAME
 312.238 +*
 312.239 +*  spm_show_mat - write sparse matrix pattern in BMP file format
 312.240 +*
 312.241 +*  SYNOPSIS
 312.242 +*
 312.243 +*  #include "glpspm.h"
 312.244 +*  int spm_show_mat(const SPM *A, const char *fname);
 312.245 +*
 312.246 +*  DESCRIPTION
 312.247 +*
 312.248 +*  The routine spm_show_mat writes pattern of the specified sparse
 312.249 +*  matrix in uncompressed BMP file format (Windows bitmap) to a binary
 312.250 +*  file whose name is specified by the character string fname.
 312.251 +*
 312.252 +*  Each pixel corresponds to one matrix element. The pixel colors have
 312.253 +*  the following meaning:
 312.254 +*
 312.255 +*  Black    structurally zero element
 312.256 +*  White    positive element
 312.257 +*  Cyan     negative element
 312.258 +*  Green    zero element
 312.259 +*  Red      duplicate element
 312.260 +*
 312.261 +*  RETURNS
 312.262 +*
 312.263 +*  If no error occured, the routine returns zero. Otherwise, it prints
 312.264 +*  an appropriate error message and returns non-zero. */
 312.265 +
 312.266 +int spm_show_mat(const SPM *A, const char *fname)
 312.267 +{     int m = A->m;
 312.268 +      int n = A->n;
 312.269 +      int i, j, k, ret;
 312.270 +      char *map;
 312.271 +      xprintf("spm_show_mat: writing matrix pattern to `%s'...\n",
 312.272 +         fname);
 312.273 +      xassert(1 <= m && m <= 32767);
 312.274 +      xassert(1 <= n && n <= 32767);
 312.275 +      map = xmalloc(m * n);
 312.276 +      memset(map, 0x08, m * n);
 312.277 +      for (i = 1; i <= m; i++)
 312.278 +      {  SPME *e;
 312.279 +         for (e = A->row[i]; e != NULL; e = e->r_next)
 312.280 +         {  j = e->j;
 312.281 +            xassert(1 <= j && j <= n);
 312.282 +            k = n * (i - 1) + (j - 1);
 312.283 +            if (map[k] != 0x08)
 312.284 +               map[k] = 0x0C;
 312.285 +            else if (e->val > 0.0)
 312.286 +               map[k] = 0x0F;
 312.287 +            else if (e->val < 0.0)
 312.288 +               map[k] = 0x0B;
 312.289 +            else
 312.290 +               map[k] = 0x0A;
 312.291 +         }
 312.292 +      }
 312.293 +      ret = rgr_write_bmp16(fname, m, n, map);
 312.294 +      xfree(map);
 312.295 +      return ret;
 312.296 +}
 312.297 +
 312.298 +/***********************************************************************
 312.299 +*  NAME
 312.300 +*
 312.301 +*  spm_read_hbm - read sparse matrix in Harwell-Boeing format
 312.302 +*
 312.303 +*  SYNOPSIS
 312.304 +*
 312.305 +*  #include "glpspm.h"
 312.306 +*  SPM *spm_read_hbm(const char *fname);
 312.307 +*
 312.308 +*  DESCRIPTION
 312.309 +*
 312.310 +*  The routine spm_read_hbm reads a sparse matrix in the Harwell-Boeing
 312.311 +*  format from a text file whose name is the character string fname.
 312.312 +*
 312.313 +*  Detailed description of the Harwell-Boeing format recognised by this
 312.314 +*  routine can be found in the following report:
 312.315 +*
 312.316 +*  I.S.Duff, R.G.Grimes, J.G.Lewis. User's Guide for the Harwell-Boeing
 312.317 +*  Sparse Matrix Collection (Release I), TR/PA/92/86, October 1992.
 312.318 +*
 312.319 +*  NOTE
 312.320 +*
 312.321 +*  The routine spm_read_hbm reads the matrix "as is", due to which zero
 312.322 +*  and/or duplicate elements can appear in the matrix.
 312.323 +*
 312.324 +*  RETURNS
 312.325 +*
 312.326 +*  If no error occured, the routine returns a pointer to the matrix
 312.327 +*  created. Otherwise, the routine prints an appropriate error message
 312.328 +*  and returns NULL. */
 312.329 +
 312.330 +SPM *spm_read_hbm(const char *fname)
 312.331 +{     SPM *A = NULL;
 312.332 +      HBM *hbm;
 312.333 +      int nrow, ncol, nnzero, i, j, beg, end, ptr, *colptr, *rowind;
 312.334 +      double val, *values;
 312.335 +      char *mxtype;
 312.336 +      hbm = hbm_read_mat(fname);
 312.337 +      if (hbm == NULL)
 312.338 +      {  xprintf("spm_read_hbm: unable to read matrix\n");
 312.339 +         goto fini;
 312.340 +      }
 312.341 +      mxtype = hbm->mxtype;
 312.342 +      nrow = hbm->nrow;
 312.343 +      ncol = hbm->ncol;
 312.344 +      nnzero = hbm->nnzero;
 312.345 +      colptr = hbm->colptr;
 312.346 +      rowind = hbm->rowind;
 312.347 +      values = hbm->values;
 312.348 +      if (!(strcmp(mxtype, "RSA") == 0 || strcmp(mxtype, "PSA") == 0 ||
 312.349 +            strcmp(mxtype, "RUA") == 0 || strcmp(mxtype, "PUA") == 0 ||
 312.350 +            strcmp(mxtype, "RRA") == 0 || strcmp(mxtype, "PRA") == 0))
 312.351 +      {  xprintf("spm_read_hbm: matrix type `%s' not supported\n",
 312.352 +            mxtype);
 312.353 +         goto fini;
 312.354 +      }
 312.355 +      A = spm_create_mat(nrow, ncol);
 312.356 +      if (mxtype[1] == 'S' || mxtype[1] == 'U')
 312.357 +         xassert(nrow == ncol);
 312.358 +      for (j = 1; j <= ncol; j++)
 312.359 +      {  beg = colptr[j];
 312.360 +         end = colptr[j+1];
 312.361 +         xassert(1 <= beg && beg <= end && end <= nnzero + 1);
 312.362 +         for (ptr = beg; ptr < end; ptr++)
 312.363 +         {  i = rowind[ptr];
 312.364 +            xassert(1 <= i && i <= nrow);
 312.365 +            if (mxtype[0] == 'R')
 312.366 +               val = values[ptr];
 312.367 +            else
 312.368 +               val = 1.0;
 312.369 +            spm_new_elem(A, i, j, val);
 312.370 +            if (mxtype[1] == 'S' && i != j)
 312.371 +               spm_new_elem(A, j, i, val);
 312.372 +         }
 312.373 +      }
 312.374 +fini: if (hbm != NULL) hbm_free_mat(hbm);
 312.375 +      return A;
 312.376 +}
 312.377 +
 312.378 +/***********************************************************************
 312.379 +*  NAME
 312.380 +*
 312.381 +*  spm_count_nnz - determine number of non-zeros in sparse matrix
 312.382 +*
 312.383 +*  SYNOPSIS
 312.384 +*
 312.385 +*  #include "glpspm.h"
 312.386 +*  int spm_count_nnz(const SPM *A);
 312.387 +*
 312.388 +*  RETURNS
 312.389 +*
 312.390 +*  The routine spm_count_nnz returns the number of structural non-zero
 312.391 +*  elements in the specified sparse matrix. */
 312.392 +
 312.393 +int spm_count_nnz(const SPM *A)
 312.394 +{     SPME *e;
 312.395 +      int i, nnz = 0;
 312.396 +      for (i = 1; i <= A->m; i++)
 312.397 +         for (e = A->row[i]; e != NULL; e = e->r_next) nnz++;
 312.398 +      return nnz;
 312.399 +}
 312.400 +
 312.401 +/***********************************************************************
 312.402 +*  NAME
 312.403 +*
 312.404 +*  spm_drop_zeros - remove zero elements from sparse matrix
 312.405 +*
 312.406 +*  SYNOPSIS
 312.407 +*
 312.408 +*  #include "glpspm.h"
 312.409 +*  int spm_drop_zeros(SPM *A, double eps);
 312.410 +*
 312.411 +*  DESCRIPTION
 312.412 +*
 312.413 +*  The routine spm_drop_zeros removes all elements from the specified
 312.414 +*  sparse matrix, whose absolute value is less than eps.
 312.415 +*
 312.416 +*  If the parameter eps is 0, only zero elements are removed from the
 312.417 +*  matrix.
 312.418 +*
 312.419 +*  RETURNS
 312.420 +*
 312.421 +*  The routine returns the number of elements removed. */
 312.422 +
 312.423 +int spm_drop_zeros(SPM *A, double eps)
 312.424 +{     SPME *e, *next;
 312.425 +      int i, count = 0;
 312.426 +      for (i = 1; i <= A->m; i++)
 312.427 +      {  for (e = A->row[i]; e != NULL; e = next)
 312.428 +         {  next = e->r_next;
 312.429 +            if (e->val == 0.0 || fabs(e->val) < eps)
 312.430 +            {  /* remove element from the row list */
 312.431 +               if (e->r_prev == NULL)
 312.432 +                  A->row[e->i] = e->r_next;
 312.433 +               else
 312.434 +                  e->r_prev->r_next = e->r_next;
 312.435 +               if (e->r_next == NULL)
 312.436 +                  ;
 312.437 +               else
 312.438 +                  e->r_next->r_prev = e->r_prev;
 312.439 +               /* remove element from the column list */
 312.440 +               if (e->c_prev == NULL)
 312.441 +                  A->col[e->j] = e->c_next;
 312.442 +               else
 312.443 +                  e->c_prev->c_next = e->c_next;
 312.444 +               if (e->c_next == NULL)
 312.445 +                  ;
 312.446 +               else
 312.447 +                  e->c_next->c_prev = e->c_prev;
 312.448 +               /* return element to the memory pool */
 312.449 +               dmp_free_atom(A->pool, e, sizeof(SPME));
 312.450 +               count++;
 312.451 +            }
 312.452 +         }
 312.453 +      }
 312.454 +      return count;
 312.455 +}
 312.456 +
 312.457 +/***********************************************************************
 312.458 +*  NAME
 312.459 +*
 312.460 +*  spm_read_mat - read sparse matrix from text file
 312.461 +*
 312.462 +*  SYNOPSIS
 312.463 +*
 312.464 +*  #include "glpspm.h"
 312.465 +*  SPM *spm_read_mat(const char *fname);
 312.466 +*
 312.467 +*  DESCRIPTION
 312.468 +*
 312.469 +*  The routine reads a sparse matrix from a text file whose name is
 312.470 +*  specified by the parameter fname.
 312.471 +*
 312.472 +*  For the file format see description of the routine spm_write_mat.
 312.473 +*
 312.474 +*  RETURNS
 312.475 +*
 312.476 +*  On success the routine returns a pointer to the matrix created,
 312.477 +*  otherwise NULL. */
 312.478 +
 312.479 +#if 1
 312.480 +SPM *spm_read_mat(const char *fname)
 312.481 +{     xassert(fname != fname);
 312.482 +      return NULL;
 312.483 +}
 312.484 +#else
 312.485 +SPM *spm_read_mat(const char *fname)
 312.486 +{     SPM *A = NULL;
 312.487 +      PDS *pds;
 312.488 +      jmp_buf jump;
 312.489 +      int i, j, k, m, n, nnz, fail = 0;
 312.490 +      double val;
 312.491 +      xprintf("spm_read_mat: reading matrix from `%s'...\n", fname);
 312.492 +      pds = pds_open_file(fname);
 312.493 +      if (pds == NULL)
 312.494 +      {  xprintf("spm_read_mat: unable to open `%s' - %s\n", fname,
 312.495 +            strerror(errno));
 312.496 +         fail = 1;
 312.497 +         goto done;
 312.498 +      }
 312.499 +      if (setjmp(jump))
 312.500 +      {  fail = 1;
 312.501 +         goto done;
 312.502 +      }
 312.503 +      pds_set_jump(pds, jump);
 312.504 +      /* number of rows, number of columns, number of non-zeros */
 312.505 +      m = pds_scan_int(pds);
 312.506 +      if (m < 0)
 312.507 +         pds_error(pds, "invalid number of rows\n");
 312.508 +      n = pds_scan_int(pds);
 312.509 +      if (n < 0)
 312.510 +         pds_error(pds, "invalid number of columns\n");
 312.511 +      nnz = pds_scan_int(pds);
 312.512 +      if (nnz < 0)
 312.513 +         pds_error(pds, "invalid number of non-zeros\n");
 312.514 +      /* create matrix */
 312.515 +      xprintf("spm_read_mat: %d rows, %d columns, %d non-zeros\n",
 312.516 +         m, n, nnz);
 312.517 +      A = spm_create_mat(m, n);
 312.518 +      /* read matrix elements */
 312.519 +      for (k = 1; k <= nnz; k++)
 312.520 +      {  /* row index, column index, element value */
 312.521 +         i = pds_scan_int(pds);
 312.522 +         if (!(1 <= i && i <= m))
 312.523 +            pds_error(pds, "row index out of range\n");
 312.524 +         j = pds_scan_int(pds);
 312.525 +         if (!(1 <= j && j <= n))
 312.526 +            pds_error(pds, "column index out of range\n");
 312.527 +         val = pds_scan_num(pds);
 312.528 +         /* add new element to the matrix */
 312.529 +         spm_new_elem(A, i, j, val);
 312.530 +      }
 312.531 +      xprintf("spm_read_mat: %d lines were read\n", pds->count);
 312.532 +done: if (pds != NULL) pds_close_file(pds);
 312.533 +      if (fail && A != NULL) spm_delete_mat(A), A = NULL;
 312.534 +      return A;
 312.535 +}
 312.536 +#endif
 312.537 +
 312.538 +/***********************************************************************
 312.539 +*  NAME
 312.540 +*
 312.541 +*  spm_write_mat - write sparse matrix to text file
 312.542 +*
 312.543 +*  SYNOPSIS
 312.544 +*
 312.545 +*  #include "glpspm.h"
 312.546 +*  int spm_write_mat(const SPM *A, const char *fname);
 312.547 +*
 312.548 +*  DESCRIPTION
 312.549 +*
 312.550 +*  The routine spm_write_mat writes the specified sparse matrix to a
 312.551 +*  text file whose name is specified by the parameter fname. This file
 312.552 +*  can be read back with the routine spm_read_mat.
 312.553 +*
 312.554 +*  RETURNS
 312.555 +*
 312.556 +*  On success the routine returns zero, otherwise non-zero.
 312.557 +*
 312.558 +*  FILE FORMAT
 312.559 +*
 312.560 +*  The file created by the routine spm_write_mat is a plain text file,
 312.561 +*  which contains the following information:
 312.562 +*
 312.563 +*     m n nnz
 312.564 +*     row[1] col[1] val[1]
 312.565 +*     row[2] col[2] val[2]
 312.566 +*     . . .
 312.567 +*     row[nnz] col[nnz] val[nnz]
 312.568 +*
 312.569 +*  where:
 312.570 +*  m is the number of rows;
 312.571 +*  n is the number of columns;
 312.572 +*  nnz is the number of non-zeros;
 312.573 +*  row[k], k = 1,...,nnz, are row indices;
 312.574 +*  col[k], k = 1,...,nnz, are column indices;
 312.575 +*  val[k], k = 1,...,nnz, are element values. */
 312.576 +
 312.577 +#if 1
 312.578 +int spm_write_mat(const SPM *A, const char *fname)
 312.579 +{     xassert(A != A);
 312.580 +      xassert(fname != fname);
 312.581 +      return 0;
 312.582 +}
 312.583 +#else
 312.584 +int spm_write_mat(const SPM *A, const char *fname)
 312.585 +{     FILE *fp;
 312.586 +      int i, nnz, ret = 0;
 312.587 +      xprintf("spm_write_mat: writing matrix to `%s'...\n", fname);
 312.588 +      fp = fopen(fname, "w");
 312.589 +      if (fp == NULL)
 312.590 +      {  xprintf("spm_write_mat: unable to create `%s' - %s\n", fname,
 312.591 +            strerror(errno));
 312.592 +         ret = 1;
 312.593 +         goto done;
 312.594 +      }
 312.595 +      /* number of rows, number of columns, number of non-zeros */
 312.596 +      nnz = spm_count_nnz(A);
 312.597 +      fprintf(fp, "%d %d %d\n", A->m, A->n, nnz);
 312.598 +      /* walk through rows of the matrix */
 312.599 +      for (i = 1; i <= A->m; i++)
 312.600 +      {  SPME *e;
 312.601 +         /* walk through elements of i-th row */
 312.602 +         for (e = A->row[i]; e != NULL; e = e->r_next)
 312.603 +         {  /* row index, column index, element value */
 312.604 +            fprintf(fp, "%d %d %.*g\n", e->i, e->j, DBL_DIG, e->val);
 312.605 +         }
 312.606 +      }
 312.607 +      fflush(fp);
 312.608 +      if (ferror(fp))
 312.609 +      {  xprintf("spm_write_mat: writing error on `%s' - %s\n", fname,
 312.610 +            strerror(errno));
 312.611 +         ret = 1;
 312.612 +         goto done;
 312.613 +      }
 312.614 +      xprintf("spm_write_mat: %d lines were written\n", 1 + nnz);
 312.615 +done: if (fp != NULL) fclose(fp);
 312.616 +      return ret;
 312.617 +}
 312.618 +#endif
 312.619 +
 312.620 +/***********************************************************************
 312.621 +*  NAME
 312.622 +*
 312.623 +*  spm_transpose - transpose sparse matrix
 312.624 +*
 312.625 +*  SYNOPSIS
 312.626 +*
 312.627 +*  #include "glpspm.h"
 312.628 +*  SPM *spm_transpose(const SPM *A);
 312.629 +*
 312.630 +*  RETURNS
 312.631 +*
 312.632 +*  The routine computes and returns sparse matrix B, which is a matrix
 312.633 +*  transposed to sparse matrix A. */
 312.634 +
 312.635 +SPM *spm_transpose(const SPM *A)
 312.636 +{     SPM *B;
 312.637 +      int i;
 312.638 +      B = spm_create_mat(A->n, A->m);
 312.639 +      for (i = 1; i <= A->m; i++)
 312.640 +      {  SPME *e;
 312.641 +         for (e = A->row[i]; e != NULL; e = e->r_next)
 312.642 +            spm_new_elem(B, e->j, i, e->val);
 312.643 +      }
 312.644 +      return B;
 312.645 +}
 312.646 +
 312.647 +SPM *spm_add_sym(const SPM *A, const SPM *B)
 312.648 +{     /* add two sparse matrices (symbolic phase) */
 312.649 +      SPM *C;
 312.650 +      int i, j, *flag;
 312.651 +      xassert(A->m == B->m);
 312.652 +      xassert(A->n == B->n);
 312.653 +      /* create resultant matrix */
 312.654 +      C = spm_create_mat(A->m, A->n);
 312.655 +      /* allocate and clear the flag array */
 312.656 +      flag = xcalloc(1+C->n, sizeof(int));
 312.657 +      for (j = 1; j <= C->n; j++)
 312.658 +         flag[j] = 0;
 312.659 +      /* compute pattern of C = A + B */
 312.660 +      for (i = 1; i <= C->m; i++)
 312.661 +      {  SPME *e;
 312.662 +         /* at the beginning i-th row of C is empty */
 312.663 +         /* (i-th row of C) := (i-th row of C) union (i-th row of A) */
 312.664 +         for (e = A->row[i]; e != NULL; e = e->r_next)
 312.665 +         {  /* (note that i-th row of A may have duplicate elements) */
 312.666 +            j = e->j;
 312.667 +            if (!flag[j])
 312.668 +            {  spm_new_elem(C, i, j, 0.0);
 312.669 +               flag[j] = 1;
 312.670 +            }
 312.671 +         }
 312.672 +         /* (i-th row of C) := (i-th row of C) union (i-th row of B) */
 312.673 +         for (e = B->row[i]; e != NULL; e = e->r_next)
 312.674 +         {  /* (note that i-th row of B may have duplicate elements) */
 312.675 +            j = e->j;
 312.676 +            if (!flag[j])
 312.677 +            {  spm_new_elem(C, i, j, 0.0);
 312.678 +               flag[j] = 1;
 312.679 +            }
 312.680 +         }
 312.681 +         /* reset the flag array */
 312.682 +         for (e = C->row[i]; e != NULL; e = e->r_next)
 312.683 +            flag[e->j] = 0;
 312.684 +      }
 312.685 +      /* check and deallocate the flag array */
 312.686 +      for (j = 1; j <= C->n; j++)
 312.687 +         xassert(!flag[j]);
 312.688 +      xfree(flag);
 312.689 +      return C;
 312.690 +}
 312.691 +
 312.692 +void spm_add_num(SPM *C, double alfa, const SPM *A, double beta,
 312.693 +      const SPM *B)
 312.694 +{     /* add two sparse matrices (numeric phase) */
 312.695 +      int i, j;
 312.696 +      double *work;
 312.697 +      /* allocate and clear the working array */
 312.698 +      work = xcalloc(1+C->n, sizeof(double));
 312.699 +      for (j = 1; j <= C->n; j++)
 312.700 +         work[j] = 0.0;
 312.701 +      /* compute matrix C = alfa * A + beta * B */
 312.702 +      for (i = 1; i <= C->n; i++)
 312.703 +      {  SPME *e;
 312.704 +         /* work := alfa * (i-th row of A) + beta * (i-th row of B) */
 312.705 +         /* (note that A and/or B may have duplicate elements) */
 312.706 +         for (e = A->row[i]; e != NULL; e = e->r_next)
 312.707 +            work[e->j] += alfa * e->val;
 312.708 +         for (e = B->row[i]; e != NULL; e = e->r_next)
 312.709 +            work[e->j] += beta * e->val;
 312.710 +         /* (i-th row of C) := work, work := 0 */
 312.711 +         for (e = C->row[i]; e != NULL; e = e->r_next)
 312.712 +         {  j = e->j;
 312.713 +            e->val = work[j];
 312.714 +            work[j] = 0.0;
 312.715 +         }
 312.716 +      }
 312.717 +      /* check and deallocate the working array */
 312.718 +      for (j = 1; j <= C->n; j++)
 312.719 +         xassert(work[j] == 0.0);
 312.720 +      xfree(work);
 312.721 +      return;
 312.722 +}
 312.723 +
 312.724 +SPM *spm_add_mat(double alfa, const SPM *A, double beta, const SPM *B)
 312.725 +{     /* add two sparse matrices (driver routine) */
 312.726 +      SPM *C;
 312.727 +      C = spm_add_sym(A, B);
 312.728 +      spm_add_num(C, alfa, A, beta, B);
 312.729 +      return C;
 312.730 +}
 312.731 +
 312.732 +SPM *spm_mul_sym(const SPM *A, const SPM *B)
 312.733 +{     /* multiply two sparse matrices (symbolic phase) */
 312.734 +      int i, j, k, *flag;
 312.735 +      SPM *C;
 312.736 +      xassert(A->n == B->m);
 312.737 +      /* create resultant matrix */
 312.738 +      C = spm_create_mat(A->m, B->n);
 312.739 +      /* allocate and clear the flag array */
 312.740 +      flag = xcalloc(1+C->n, sizeof(int));
 312.741 +      for (j = 1; j <= C->n; j++)
 312.742 +         flag[j] = 0;
 312.743 +      /* compute pattern of C = A * B */
 312.744 +      for (i = 1; i <= C->m; i++)
 312.745 +      {  SPME *e, *ee;
 312.746 +         /* compute pattern of i-th row of C */
 312.747 +         for (e = A->row[i]; e != NULL; e = e->r_next)
 312.748 +         {  k = e->j;
 312.749 +            for (ee = B->row[k]; ee != NULL; ee = ee->r_next)
 312.750 +            {  j = ee->j;
 312.751 +               /* if a[i,k] != 0 and b[k,j] != 0 then c[i,j] != 0 */
 312.752 +               if (!flag[j])
 312.753 +               {  /* c[i,j] does not exist, so create it */
 312.754 +                  spm_new_elem(C, i, j, 0.0);
 312.755 +                  flag[j] = 1;
 312.756 +               }
 312.757 +            }
 312.758 +         }
 312.759 +         /* reset the flag array */
 312.760 +         for (e = C->row[i]; e != NULL; e = e->r_next)
 312.761 +            flag[e->j] = 0;
 312.762 +      }
 312.763 +      /* check and deallocate the flag array */
 312.764 +      for (j = 1; j <= C->n; j++)
 312.765 +         xassert(!flag[j]);
 312.766 +      xfree(flag);
 312.767 +      return C;
 312.768 +}
 312.769 +
 312.770 +void spm_mul_num(SPM *C, const SPM *A, const SPM *B)
 312.771 +{     /* multiply two sparse matrices (numeric phase) */
 312.772 +      int i, j;
 312.773 +      double *work;
 312.774 +      /* allocate and clear the working array */
 312.775 +      work = xcalloc(1+A->n, sizeof(double));
 312.776 +      for (j = 1; j <= A->n; j++)
 312.777 +         work[j] = 0.0;
 312.778 +      /* compute matrix C = A * B */
 312.779 +      for (i = 1; i <= C->m; i++)
 312.780 +      {  SPME *e, *ee;
 312.781 +         double temp;
 312.782 +         /* work := (i-th row of A) */
 312.783 +         /* (note that A may have duplicate elements) */
 312.784 +         for (e = A->row[i]; e != NULL; e = e->r_next)
 312.785 +            work[e->j] += e->val;
 312.786 +         /* compute i-th row of C */
 312.787 +         for (e = C->row[i]; e != NULL; e = e->r_next)
 312.788 +         {  j = e->j;
 312.789 +            /* c[i,j] := work * (j-th column of B) */
 312.790 +            temp = 0.0;
 312.791 +            for (ee = B->col[j]; ee != NULL; ee = ee->c_next)
 312.792 +               temp += work[ee->i] * ee->val;
 312.793 +            e->val = temp;
 312.794 +         }
 312.795 +         /* reset the working array */
 312.796 +         for (e = A->row[i]; e != NULL; e = e->r_next)
 312.797 +            work[e->j] = 0.0;
 312.798 +      }
 312.799 +      /* check and deallocate the working array */
 312.800 +      for (j = 1; j <= A->n; j++)
 312.801 +         xassert(work[j] == 0.0);
 312.802 +      xfree(work);
 312.803 +      return;
 312.804 +}
 312.805 +
 312.806 +SPM *spm_mul_mat(const SPM *A, const SPM *B)
 312.807 +{     /* multiply two sparse matrices (driver routine) */
 312.808 +      SPM *C;
 312.809 +      C = spm_mul_sym(A, B);
 312.810 +      spm_mul_num(C, A, B);
 312.811 +      return C;
 312.812 +}
 312.813 +
 312.814 +PER *spm_create_per(int n)
 312.815 +{     /* create permutation matrix */
 312.816 +      PER *P;
 312.817 +      int k;
 312.818 +      xassert(n >= 0);
 312.819 +      P = xmalloc(sizeof(PER));
 312.820 +      P->n = n;
 312.821 +      P->row = xcalloc(1+n, sizeof(int));
 312.822 +      P->col = xcalloc(1+n, sizeof(int));
 312.823 +      /* initially it is identity matrix */
 312.824 +      for (k = 1; k <= n; k++)
 312.825 +         P->row[k] = P->col[k] = k;
 312.826 +      return P;
 312.827 +}
 312.828 +
 312.829 +void spm_check_per(PER *P)
 312.830 +{     /* check permutation matrix for correctness */
 312.831 +      int i, j;
 312.832 +      xassert(P->n >= 0);
 312.833 +      for (i = 1; i <= P->n; i++)
 312.834 +      {  j = P->row[i];
 312.835 +         xassert(1 <= j && j <= P->n);
 312.836 +         xassert(P->col[j] == i);
 312.837 +      }
 312.838 +      return;
 312.839 +}
 312.840 +
 312.841 +void spm_delete_per(PER *P)
 312.842 +{     /* delete permutation matrix */
 312.843 +      xfree(P->row);
 312.844 +      xfree(P->col);
 312.845 +      xfree(P);
 312.846 +      return;
 312.847 +}
 312.848 +
 312.849 +/* eof */
   313.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
   313.2 +++ b/deps/glpk/src/glpspm.h	Sun Nov 06 20:59:10 2011 +0100
   313.3 @@ -0,0 +1,165 @@
   313.4 +/* glpspm.h (general sparse matrix) */
   313.5 +
   313.6 +/***********************************************************************
   313.7 +*  This code is part of GLPK (GNU Linear Programming Kit).
   313.8 +*
   313.9 +*  Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008,
  313.10 +*  2009, 2010, 2011 Andrew Makhorin, Department for Applied Informatics,
  313.11 +*  Moscow Aviation Institute, Moscow, Russia. All rights reserved.
  313.12 +*  E-mail: <mao@gnu.org>.
  313.13 +*
  313.14 +*  GLPK is free software: you can redistribute it and/or modify it
  313.15 +*  under the terms of the GNU General Public License as published by
  313.16 +*  the Free Software Foundation, either version 3 of the License, or
  313.17 +*  (at your option) any later version.
  313.18 +*
  313.19 +*  GLPK is distributed in the hope that it will be useful, but WITHOUT
  313.20 +*  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
  313.21 +*  or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
  313.22 +*  License for more details.
  313.23 +*
  313.24 +*  You should have received a copy of the GNU General Public License
  313.25 +*  along with GLPK. If not, see <http://www.gnu.org/licenses/>.
  313.26 +***********************************************************************/
  313.27 +
  313.28 +#ifndef GLPSPM_H
  313.29 +#define GLPSPM_H
  313.30 +
  313.31 +#include "glpdmp.h"
  313.32 +
  313.33 +typedef struct SPM SPM;
  313.34 +typedef struct SPME SPME;
  313.35 +
  313.36 +struct SPM
  313.37 +{     /* general sparse matrix */
  313.38 +      int m;
  313.39 +      /* number of rows, m >= 0 */
  313.40 +      int n;
  313.41 +      /* number of columns, n >= 0 */
  313.42 +      DMP *pool;
  313.43 +      /* memory pool to store matrix elements */
  313.44 +      SPME **row; /* SPME *row[1+m]; */
  313.45 +      /* row[i], 1 <= i <= m, is a pointer to i-th row list */
  313.46 +      SPME **col; /* SPME *col[1+n]; */
  313.47 +      /* col[j], 1 <= j <= n, is a pointer to j-th column list */
  313.48 +};
  313.49 +
  313.50 +struct SPME
  313.51 +{     /* sparse matrix element */
  313.52 +      int i;
  313.53 +      /* row number */
  313.54 +      int j;
  313.55 +      /* column number */
  313.56 +      double val;
  313.57 +      /* element value */
  313.58 +      SPME *r_prev;
  313.59 +      /* pointer to previous element in the same row */
  313.60 +      SPME *r_next;
  313.61 +      /* pointer to next element in the same row */
  313.62 +      SPME *c_prev;
  313.63 +      /* pointer to previous element in the same column */
  313.64 +      SPME *c_next;
  313.65 +      /* pointer to next element in the same column */
  313.66 +};
  313.67 +
  313.68 +typedef struct PER PER;
  313.69 +
  313.70 +struct PER
  313.71 +{     /* permutation matrix */
  313.72 +      int n;
  313.73 +      /* matrix order, n >= 0 */
  313.74 +      int *row; /* int row[1+n]; */
  313.75 +      /* row[i] = j means p[i,j] = 1 */
  313.76 +      int *col; /* int col[1+n]; */
  313.77 +      /* col[j] = i means p[i,j] = 1 */
  313.78 +};
  313.79 +
  313.80 +#define spm_create_mat _glp_spm_create_mat
  313.81 +SPM *spm_create_mat(int m, int n);
  313.82 +/* create general sparse matrix */
  313.83 +
  313.84 +#define spm_new_elem _glp_spm_new_elem
  313.85 +SPME *spm_new_elem(SPM *A, int i, int j, double val);
  313.86 +/* add new element to sparse matrix */
  313.87 +
  313.88 +#define spm_delete_mat _glp_spm_delete_mat
  313.89 +void spm_delete_mat(SPM *A);
  313.90 +/* delete general sparse matrix */
  313.91 +
  313.92 +#define spm_test_mat_e _glp_spm_test_mat_e
  313.93 +SPM *spm_test_mat_e(int n, int c);
  313.94 +/* create test sparse matrix of E(n,c) class */
  313.95 +
  313.96 +#define spm_test_mat_d _glp_spm_test_mat_d
  313.97 +SPM *spm_test_mat_d(int n, int c);
  313.98 +/* create test sparse matrix of D(n,c) class */
  313.99 +
 313.100 +#define spm_show_mat _glp_spm_show_mat
 313.101 +int spm_show_mat(const SPM *A, const char *fname);
 313.102 +/* write sparse matrix pattern in BMP file format */
 313.103 +
 313.104 +#define spm_read_hbm _glp_spm_read_hbm
 313.105 +SPM *spm_read_hbm(const char *fname);
 313.106 +/* read sparse matrix in Harwell-Boeing format */
 313.107 +
 313.108 +#define spm_count_nnz _glp_spm_count_nnz
 313.109 +int spm_count_nnz(const SPM *A);
 313.110 +/* determine number of non-zeros in sparse matrix */
 313.111 +
 313.112 +#define spm_drop_zeros _glp_spm_drop_zeros
 313.113 +int spm_drop_zeros(SPM *A, double eps);
 313.114 +/* remove zero elements from sparse matrix */
 313.115 +
 313.116 +#define spm_read_mat _glp_spm_read_mat
 313.117 +SPM *spm_read_mat(const char *fname);
 313.118 +/* read sparse matrix from text file */
 313.119 +
 313.120 +#define spm_write_mat _glp_spm_write_mat
 313.121 +int spm_write_mat(const SPM *A, const char *fname);
 313.122 +/* write sparse matrix to text file */
 313.123 +
 313.124 +#define spm_transpose _glp_spm_transpose
 313.125 +SPM *spm_transpose(const SPM *A);
 313.126 +/* transpose sparse matrix */
 313.127 +
 313.128 +#define spm_add_sym _glp_spm_add_sym
 313.129 +SPM *spm_add_sym(const SPM *A, const SPM *B);
 313.130 +/* add two sparse matrices (symbolic phase) */
 313.131 +
 313.132 +#define spm_add_num _glp_spm_add_num
 313.133 +void spm_add_num(SPM *C, double alfa, const SPM *A, double beta,
 313.134 +      const SPM *B);
 313.135 +/* add two sparse matrices (numeric phase) */
 313.136 +
 313.137 +#define spm_add_mat _glp_spm_add_mat
 313.138 +SPM *spm_add_mat(double alfa, const SPM *A, double beta,
 313.139 +      const SPM *B);
 313.140 +/* add two sparse matrices (driver routine) */
 313.141 +
 313.142 +#define spm_mul_sym _glp_spm_mul_sym
 313.143 +SPM *spm_mul_sym(const SPM *A, const SPM *B);
 313.144 +/* multiply two sparse matrices (symbolic phase) */
 313.145 +
 313.146 +#define spm_mul_num _glp_spm_mul_num
 313.147 +void spm_mul_num(SPM *C, const SPM *A, const SPM *B);
 313.148 +/* multiply two sparse matrices (numeric phase) */
 313.149 +
 313.150 +#define spm_mul_mat _glp_spm_mul_mat
 313.151 +SPM *spm_mul_mat(const SPM *A, const SPM *B);
 313.152 +/* multiply two sparse matrices (driver routine) */
 313.153 +
 313.154 +#define spm_create_per _glp_spm_create_per
 313.155 +PER *spm_create_per(int n);
 313.156 +/* create permutation matrix */
 313.157 +
 313.158 +#define spm_check_per _glp_spm_check_per
 313.159 +void spm_check_per(PER *P);
 313.160 +/* check permutation matrix for correctness */
 313.161 +
 313.162 +#define spm_delete_per _glp_spm_delete_per
 313.163 +void spm_delete_per(PER *P);
 313.164 +/* delete permutation matrix */
 313.165 +
 313.166 +#endif
 313.167 +
 313.168 +/* eof */
   314.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
   314.2 +++ b/deps/glpk/src/glpspx.h	Sun Nov 06 20:59:10 2011 +0100
   314.3 @@ -0,0 +1,40 @@
   314.4 +/* glpspx.h (core simplex solvers) */
   314.5 +
   314.6 +/***********************************************************************
   314.7 +*  This code is part of GLPK (GNU Linear Programming Kit).
   314.8 +*
   314.9 +*  Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008,
  314.10 +*  2009, 2010, 2011 Andrew Makhorin, Department for Applied Informatics,
  314.11 +*  Moscow Aviation Institute, Moscow, Russia. All rights reserved.
  314.12 +*  E-mail: <mao@gnu.org>.
  314.13 +*
  314.14 +*  GLPK is free software: you can redistribute it and/or modify it
  314.15 +*  under the terms of the GNU General Public License as published by
  314.16 +*  the Free Software Foundation, either version 3 of the License, or
  314.17 +*  (at your option) any later version.
  314.18 +*
  314.19 +*  GLPK is distributed in the hope that it will be useful, but WITHOUT
  314.20 +*  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
  314.21 +*  or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
  314.22 +*  License for more details.
  314.23 +*
  314.24 +*  You should have received a copy of the GNU General Public License
  314.25 +*  along with GLPK. If not, see <http://www.gnu.org/licenses/>.
  314.26 +***********************************************************************/
  314.27 +
  314.28 +#ifndef GLPSPX_H
  314.29 +#define GLPSPX_H
  314.30 +
  314.31 +#include "glpapi.h"
  314.32 +
  314.33 +#define spx_primal _glp_spx_primal
  314.34 +int spx_primal(glp_prob *lp, const glp_smcp *parm);
  314.35 +/* core LP solver based on the primal simplex method */
  314.36 +
  314.37 +#define spx_dual _glp_spx_dual
  314.38 +int spx_dual(glp_prob *lp, const glp_smcp *parm);
  314.39 +/* core LP solver based on the dual simplex method */
  314.40 +
  314.41 +#endif
  314.42 +
  314.43 +/* eof */
   315.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
   315.2 +++ b/deps/glpk/src/glpspx01.c	Sun Nov 06 20:59:10 2011 +0100
   315.3 @@ -0,0 +1,2954 @@
   315.4 +/* glpspx01.c (primal simplex method) */
   315.5 +
   315.6 +/***********************************************************************
   315.7 +*  This code is part of GLPK (GNU Linear Programming Kit).
   315.8 +*
   315.9 +*  Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008,
  315.10 +*  2009, 2010, 2011 Andrew Makhorin, Department for Applied Informatics,
  315.11 +*  Moscow Aviation Institute, Moscow, Russia. All rights reserved.
  315.12 +*  E-mail: <mao@gnu.org>.
  315.13 +*
  315.14 +*  GLPK is free software: you can redistribute it and/or modify it
  315.15 +*  under the terms of the GNU General Public License as published by
  315.16 +*  the Free Software Foundation, either version 3 of the License, or
  315.17 +*  (at your option) any later version.
  315.18 +*
  315.19 +*  GLPK is distributed in the hope that it will be useful, but WITHOUT
  315.20 +*  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
  315.21 +*  or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
  315.22 +*  License for more details.
  315.23 +*
  315.24 +*  You should have received a copy of the GNU General Public License
  315.25 +*  along with GLPK. If not, see <http://www.gnu.org/licenses/>.
  315.26 +***********************************************************************/
  315.27 +
  315.28 +#include "glpspx.h"
  315.29 +
  315.30 +struct csa
  315.31 +{     /* common storage area */
  315.32 +      /*--------------------------------------------------------------*/
  315.33 +      /* LP data */
  315.34 +      int m;
  315.35 +      /* number of rows (auxiliary variables), m > 0 */
  315.36 +      int n;
  315.37 +      /* number of columns (structural variables), n > 0 */
  315.38 +      char *type; /* char type[1+m+n]; */
  315.39 +      /* type[0] is not used;
  315.40 +         type[k], 1 <= k <= m+n, is the type of variable x[k]:
  315.41 +         GLP_FR - free variable
  315.42 +         GLP_LO - variable with lower bound
  315.43 +         GLP_UP - variable with upper bound
  315.44 +         GLP_DB - double-bounded variable
  315.45 +         GLP_FX - fixed variable */
  315.46 +      double *lb; /* double lb[1+m+n]; */
  315.47 +      /* lb[0] is not used;
  315.48 +         lb[k], 1 <= k <= m+n, is an lower bound of variable x[k];
  315.49 +         if x[k] has no lower bound, lb[k] is zero */
  315.50 +      double *ub; /* double ub[1+m+n]; */
  315.51 +      /* ub[0] is not used;
  315.52 +         ub[k], 1 <= k <= m+n, is an upper bound of variable x[k];
  315.53 +         if x[k] has no upper bound, ub[k] is zero;
  315.54 +         if x[k] is of fixed type, ub[k] is the same as lb[k] */
  315.55 +      double *coef; /* double coef[1+m+n]; */
  315.56 +      /* coef[0] is not used;
  315.57 +         coef[k], 1 <= k <= m+n, is an objective coefficient at
  315.58 +         variable x[k] (note that on phase I auxiliary variables also
  315.59 +         may have non-zero objective coefficients) */
  315.60 +      /*--------------------------------------------------------------*/
  315.61 +      /* original objective function */
  315.62 +      double *obj; /* double obj[1+n]; */
  315.63 +      /* obj[0] is a constant term of the original objective function;
  315.64 +         obj[j], 1 <= j <= n, is an original objective coefficient at
  315.65 +         structural variable x[m+j] */
  315.66 +      double zeta;
  315.67 +      /* factor used to scale original objective coefficients; its
  315.68 +         sign defines original optimization direction: zeta > 0 means
  315.69 +         minimization, zeta < 0 means maximization */
  315.70 +      /*--------------------------------------------------------------*/
  315.71 +      /* constraint matrix A; it has m rows and n columns and is stored
  315.72 +         by columns */
  315.73 +      int *A_ptr; /* int A_ptr[1+n+1]; */
  315.74 +      /* A_ptr[0] is not used;
  315.75 +         A_ptr[j], 1 <= j <= n, is starting position of j-th column in
  315.76 +         arrays A_ind and A_val; note that A_ptr[1] is always 1;
  315.77 +         A_ptr[n+1] indicates the position after the last element in
  315.78 +         arrays A_ind and A_val */
  315.79 +      int *A_ind; /* int A_ind[A_ptr[n+1]]; */
  315.80 +      /* row indices */
  315.81 +      double *A_val; /* double A_val[A_ptr[n+1]]; */
  315.82 +      /* non-zero element values */
  315.83 +      /*--------------------------------------------------------------*/
  315.84 +      /* basis header */
  315.85 +      int *head; /* int head[1+m+n]; */
  315.86 +      /* head[0] is not used;
  315.87 +         head[i], 1 <= i <= m, is the ordinal number of basic variable
  315.88 +         xB[i]; head[i] = k means that xB[i] = x[k] and i-th column of
  315.89 +         matrix B is k-th column of matrix (I|-A);
  315.90 +         head[m+j], 1 <= j <= n, is the ordinal number of non-basic
  315.91 +         variable xN[j]; head[m+j] = k means that xN[j] = x[k] and j-th
  315.92 +         column of matrix N is k-th column of matrix (I|-A) */
  315.93 +      char *stat; /* char stat[1+n]; */
  315.94 +      /* stat[0] is not used;
  315.95 +         stat[j], 1 <= j <= n, is the status of non-basic variable
  315.96 +         xN[j], which defines its active bound:
  315.97 +         GLP_NL - lower bound is active
  315.98 +         GLP_NU - upper bound is active
  315.99 +         GLP_NF - free variable
 315.100 +         GLP_NS - fixed variable */
 315.101 +      /*--------------------------------------------------------------*/
 315.102 +      /* matrix B is the basis matrix; it is composed from columns of
 315.103 +         the augmented constraint matrix (I|-A) corresponding to basic
 315.104 +         variables and stored in a factorized (invertable) form */
 315.105 +      int valid;
 315.106 +      /* factorization is valid only if this flag is set */
 315.107 +      BFD *bfd; /* BFD bfd[1:m,1:m]; */
 315.108 +      /* factorized (invertable) form of the basis matrix */
 315.109 +      /*--------------------------------------------------------------*/
 315.110 +      /* matrix N is a matrix composed from columns of the augmented
 315.111 +         constraint matrix (I|-A) corresponding to non-basic variables
 315.112 +         except fixed ones; it is stored by rows and changes every time
 315.113 +         the basis changes */
 315.114 +      int *N_ptr; /* int N_ptr[1+m+1]; */
 315.115 +      /* N_ptr[0] is not used;
 315.116 +         N_ptr[i], 1 <= i <= m, is starting position of i-th row in
 315.117 +         arrays N_ind and N_val; note that N_ptr[1] is always 1;
 315.118 +         N_ptr[m+1] indicates the position after the last element in
 315.119 +         arrays N_ind and N_val */
 315.120 +      int *N_len; /* int N_len[1+m]; */
 315.121 +      /* N_len[0] is not used;
 315.122 +         N_len[i], 1 <= i <= m, is length of i-th row (0 to n) */
 315.123 +      int *N_ind; /* int N_ind[N_ptr[m+1]]; */
 315.124 +      /* column indices */
 315.125 +      double *N_val; /* double N_val[N_ptr[m+1]]; */
 315.126 +      /* non-zero element values */
 315.127 +      /*--------------------------------------------------------------*/
 315.128 +      /* working parameters */
 315.129 +      int phase;
 315.130 +      /* search phase:
 315.131 +         0 - not determined yet
 315.132 +         1 - search for primal feasible solution
 315.133 +         2 - search for optimal solution */
 315.134 +      glp_long tm_beg;
 315.135 +      /* time value at the beginning of the search */
 315.136 +      int it_beg;
 315.137 +      /* simplex iteration count at the beginning of the search */
 315.138 +      int it_cnt;
 315.139 +      /* simplex iteration count; it increases by one every time the
 315.140 +         basis changes (including the case when a non-basic variable
 315.141 +         jumps to its opposite bound) */
 315.142 +      int it_dpy;
 315.143 +      /* simplex iteration count at the most recent display output */
 315.144 +      /*--------------------------------------------------------------*/
 315.145 +      /* basic solution components */
 315.146 +      double *bbar; /* double bbar[1+m]; */
 315.147 +      /* bbar[0] is not used;
 315.148 +         bbar[i], 1 <= i <= m, is primal value of basic variable xB[i]
 315.149 +         (if xB[i] is free, its primal value is not updated) */
 315.150 +      double *cbar; /* double cbar[1+n]; */
 315.151 +      /* cbar[0] is not used;
 315.152 +         cbar[j], 1 <= j <= n, is reduced cost of non-basic variable
 315.153 +         xN[j] (if xN[j] is fixed, its reduced cost is not updated) */
 315.154 +      /*--------------------------------------------------------------*/
 315.155 +      /* the following pricing technique options may be used:
 315.156 +         GLP_PT_STD - standard ("textbook") pricing;
 315.157 +         GLP_PT_PSE - projected steepest edge;
 315.158 +         GLP_PT_DVX - Devex pricing (not implemented yet);
 315.159 +         in case of GLP_PT_STD the reference space is not used, and all
 315.160 +         steepest edge coefficients are set to 1 */
 315.161 +      int refct;
 315.162 +      /* this count is set to an initial value when the reference space
 315.163 +         is defined and decreases by one every time the basis changes;
 315.164 +         once this count reaches zero, the reference space is redefined
 315.165 +         again */
 315.166 +      char *refsp; /* char refsp[1+m+n]; */
 315.167 +      /* refsp[0] is not used;
 315.168 +         refsp[k], 1 <= k <= m+n, is the flag which means that variable
 315.169 +         x[k] belongs to the current reference space */
 315.170 +      double *gamma; /* double gamma[1+n]; */
 315.171 +      /* gamma[0] is not used;
 315.172 +         gamma[j], 1 <= j <= n, is the steepest edge coefficient for
 315.173 +         non-basic variable xN[j]; if xN[j] is fixed, gamma[j] is not
 315.174 +         used and just set to 1 */
 315.175 +      /*--------------------------------------------------------------*/
 315.176 +      /* non-basic variable xN[q] chosen to enter the basis */
 315.177 +      int q;
 315.178 +      /* index of the non-basic variable xN[q] chosen, 1 <= q <= n;
 315.179 +         if the set of eligible non-basic variables is empty and thus
 315.180 +         no variable has been chosen, q is set to 0 */
 315.181 +      /*--------------------------------------------------------------*/
 315.182 +      /* pivot column of the simplex table corresponding to non-basic
 315.183 +         variable xN[q] chosen is the following vector:
 315.184 +            T * e[q] = - inv(B) * N * e[q] = - inv(B) * N[q],
 315.185 +         where B is the current basis matrix, N[q] is a column of the
 315.186 +         matrix (I|-A) corresponding to xN[q] */
 315.187 +      int tcol_nnz;
 315.188 +      /* number of non-zero components, 0 <= nnz <= m */
 315.189 +      int *tcol_ind; /* int tcol_ind[1+m]; */
 315.190 +      /* tcol_ind[0] is not used;
 315.191 +         tcol_ind[t], 1 <= t <= nnz, is an index of non-zero component,
 315.192 +         i.e. tcol_ind[t] = i means that tcol_vec[i] != 0 */
 315.193 +      double *tcol_vec; /* double tcol_vec[1+m]; */
 315.194 +      /* tcol_vec[0] is not used;
 315.195 +         tcol_vec[i], 1 <= i <= m, is a numeric value of i-th component
 315.196 +         of the column */
 315.197 +      double tcol_max;
 315.198 +      /* infinity (maximum) norm of the column (max |tcol_vec[i]|) */
 315.199 +      int tcol_num;
 315.200 +      /* number of significant non-zero components, which means that:
 315.201 +         |tcol_vec[i]| >= eps for i in tcol_ind[1,...,num],
 315.202 +         |tcol_vec[i]| <  eps for i in tcol_ind[num+1,...,nnz],
 315.203 +         where eps is a pivot tolerance */
 315.204 +      /*--------------------------------------------------------------*/
 315.205 +      /* basic variable xB[p] chosen to leave the basis */
 315.206 +      int p;
 315.207 +      /* index of the basic variable xB[p] chosen, 1 <= p <= m;
 315.208 +         p = 0 means that no basic variable reaches its bound;
 315.209 +         p < 0 means that non-basic variable xN[q] reaches its opposite
 315.210 +         bound before any basic variable */
 315.211 +      int p_stat;
 315.212 +      /* new status (GLP_NL, GLP_NU, or GLP_NS) to be assigned to xB[p]
 315.213 +         once it has left the basis */
 315.214 +      double teta;
 315.215 +      /* change of non-basic variable xN[q] (see above), on which xB[p]
 315.216 +         (or, if p < 0, xN[q] itself) reaches its bound */
 315.217 +      /*--------------------------------------------------------------*/
 315.218 +      /* pivot row of the simplex table corresponding to basic variable
 315.219 +         xB[p] chosen is the following vector:
 315.220 +            T' * e[p] = - N' * inv(B') * e[p] = - N' * rho,
 315.221 +         where B' is a matrix transposed to the current basis matrix,
 315.222 +         N' is a matrix, whose rows are columns of the matrix (I|-A)
 315.223 +         corresponding to non-basic non-fixed variables */
 315.224 +      int trow_nnz;
 315.225 +      /* number of non-zero components, 0 <= nnz <= n */
 315.226 +      int *trow_ind; /* int trow_ind[1+n]; */
 315.227 +      /* trow_ind[0] is not used;
 315.228 +         trow_ind[t], 1 <= t <= nnz, is an index of non-zero component,
 315.229 +         i.e. trow_ind[t] = j means that trow_vec[j] != 0 */
 315.230 +      double *trow_vec; /* int trow_vec[1+n]; */
 315.231 +      /* trow_vec[0] is not used;
 315.232 +         trow_vec[j], 1 <= j <= n, is a numeric value of j-th component
 315.233 +         of the row */
 315.234 +      /*--------------------------------------------------------------*/
 315.235 +      /* working arrays */
 315.236 +      double *work1; /* double work1[1+m]; */
 315.237 +      double *work2; /* double work2[1+m]; */
 315.238 +      double *work3; /* double work3[1+m]; */
 315.239 +      double *work4; /* double work4[1+m]; */
 315.240 +};
 315.241 +
 315.242 +static const double kappa = 0.10;
 315.243 +
 315.244 +/***********************************************************************
 315.245 +*  alloc_csa - allocate common storage area
 315.246 +*
 315.247 +*  This routine allocates all arrays in the common storage area (CSA)
 315.248 +*  and returns a pointer to the CSA. */
 315.249 +
 315.250 +static struct csa *alloc_csa(glp_prob *lp)
 315.251 +{     struct csa *csa;
 315.252 +      int m = lp->m;
 315.253 +      int n = lp->n;
 315.254 +      int nnz = lp->nnz;
 315.255 +      csa = xmalloc(sizeof(struct csa));
 315.256 +      xassert(m > 0 && n > 0);
 315.257 +      csa->m = m;
 315.258 +      csa->n = n;
 315.259 +      csa->type = xcalloc(1+m+n, sizeof(char));
 315.260 +      csa->lb = xcalloc(1+m+n, sizeof(double));
 315.261 +      csa->ub = xcalloc(1+m+n, sizeof(double));
 315.262 +      csa->coef = xcalloc(1+m+n, sizeof(double));
 315.263 +      csa->obj = xcalloc(1+n, sizeof(double));
 315.264 +      csa->A_ptr = xcalloc(1+n+1, sizeof(int));
 315.265 +      csa->A_ind = xcalloc(1+nnz, sizeof(int));
 315.266 +      csa->A_val = xcalloc(1+nnz, sizeof(double));
 315.267 +      csa->head = xcalloc(1+m+n, sizeof(int));
 315.268 +      csa->stat = xcalloc(1+n, sizeof(char));
 315.269 +      csa->N_ptr = xcalloc(1+m+1, sizeof(int));
 315.270 +      csa->N_len = xcalloc(1+m, sizeof(int));
 315.271 +      csa->N_ind = NULL; /* will be allocated later */
 315.272 +      csa->N_val = NULL; /* will be allocated later */
 315.273 +      csa->bbar = xcalloc(1+m, sizeof(double));
 315.274 +      csa->cbar = xcalloc(1+n, sizeof(double));
 315.275 +      csa->refsp = xcalloc(1+m+n, sizeof(char));
 315.276 +      csa->gamma = xcalloc(1+n, sizeof(double));
 315.277 +      csa->tcol_ind = xcalloc(1+m, sizeof(int));
 315.278 +      csa->tcol_vec = xcalloc(1+m, sizeof(double));
 315.279 +      csa->trow_ind = xcalloc(1+n, sizeof(int));
 315.280 +      csa->trow_vec = xcalloc(1+n, sizeof(double));
 315.281 +      csa->work1 = xcalloc(1+m, sizeof(double));
 315.282 +      csa->work2 = xcalloc(1+m, sizeof(double));
 315.283 +      csa->work3 = xcalloc(1+m, sizeof(double));
 315.284 +      csa->work4 = xcalloc(1+m, sizeof(double));
 315.285 +      return csa;
 315.286 +}
 315.287 +
 315.288 +/***********************************************************************
 315.289 +*  init_csa - initialize common storage area
 315.290 +*
 315.291 +*  This routine initializes all data structures in the common storage
 315.292 +*  area (CSA). */
 315.293 +
 315.294 +static void alloc_N(struct csa *csa);
 315.295 +static void build_N(struct csa *csa);
 315.296 +
 315.297 +static void init_csa(struct csa *csa, glp_prob *lp)
 315.298 +{     int m = csa->m;
 315.299 +      int n = csa->n;
 315.300 +      char *type = csa->type;
 315.301 +      double *lb = csa->lb;
 315.302 +      double *ub = csa->ub;
 315.303 +      double *coef = csa->coef;
 315.304 +      double *obj = csa->obj;
 315.305 +      int *A_ptr = csa->A_ptr;
 315.306 +      int *A_ind = csa->A_ind;
 315.307 +      double *A_val = csa->A_val;
 315.308 +      int *head = csa->head;
 315.309 +      char *stat = csa->stat;
 315.310 +      char *refsp = csa->refsp;
 315.311 +      double *gamma = csa->gamma;
 315.312 +      int i, j, k, loc;
 315.313 +      double cmax;
 315.314 +      /* auxiliary variables */
 315.315 +      for (i = 1; i <= m; i++)
 315.316 +      {  GLPROW *row = lp->row[i];
 315.317 +         type[i] = (char)row->type;
 315.318 +         lb[i] = row->lb * row->rii;
 315.319 +         ub[i] = row->ub * row->rii;
 315.320 +         coef[i] = 0.0;
 315.321 +      }
 315.322 +      /* structural variables */
 315.323 +      for (j = 1; j <= n; j++)
 315.324 +      {  GLPCOL *col = lp->col[j];
 315.325 +         type[m+j] = (char)col->type;
 315.326 +         lb[m+j] = col->lb / col->sjj;
 315.327 +         ub[m+j] = col->ub / col->sjj;
 315.328 +         coef[m+j] = col->coef * col->sjj;
 315.329 +      }
 315.330 +      /* original objective function */
 315.331 +      obj[0] = lp->c0;
 315.332 +      memcpy(&obj[1], &coef[m+1], n * sizeof(double));
 315.333 +      /* factor used to scale original objective coefficients */
 315.334 +      cmax = 0.0;
 315.335 +      for (j = 1; j <= n; j++)
 315.336 +         if (cmax < fabs(obj[j])) cmax = fabs(obj[j]);
 315.337 +      if (cmax == 0.0) cmax = 1.0;
 315.338 +      switch (lp->dir)
 315.339 +      {  case GLP_MIN:
 315.340 +            csa->zeta = + 1.0 / cmax;
 315.341 +            break;
 315.342 +         case GLP_MAX:
 315.343 +            csa->zeta = - 1.0 / cmax;
 315.344 +            break;
 315.345 +         default:
 315.346 +            xassert(lp != lp);
 315.347 +      }
 315.348 +#if 1
 315.349 +      if (fabs(csa->zeta) < 1.0) csa->zeta *= 1000.0;
 315.350 +#endif
 315.351 +      /* matrix A (by columns) */
 315.352 +      loc = 1;
 315.353 +      for (j = 1; j <= n; j++)
 315.354 +      {  GLPAIJ *aij;
 315.355 +         A_ptr[j] = loc;
 315.356 +         for (aij = lp->col[j]->ptr; aij != NULL; aij = aij->c_next)
 315.357 +         {  A_ind[loc] = aij->row->i;
 315.358 +            A_val[loc] = aij->row->rii * aij->val * aij->col->sjj;
 315.359 +            loc++;
 315.360 +         }
 315.361 +      }
 315.362 +      A_ptr[n+1] = loc;
 315.363 +      xassert(loc == lp->nnz+1);
 315.364 +      /* basis header */
 315.365 +      xassert(lp->valid);
 315.366 +      memcpy(&head[1], &lp->head[1], m * sizeof(int));
 315.367 +      k = 0;
 315.368 +      for (i = 1; i <= m; i++)
 315.369 +      {  GLPROW *row = lp->row[i];
 315.370 +         if (row->stat != GLP_BS)
 315.371 +         {  k++;
 315.372 +            xassert(k <= n);
 315.373 +            head[m+k] = i;
 315.374 +            stat[k] = (char)row->stat;
 315.375 +         }
 315.376 +      }
 315.377 +      for (j = 1; j <= n; j++)
 315.378 +      {  GLPCOL *col = lp->col[j];
 315.379 +         if (col->stat != GLP_BS)
 315.380 +         {  k++;
 315.381 +            xassert(k <= n);
 315.382 +            head[m+k] = m + j;
 315.383 +            stat[k] = (char)col->stat;
 315.384 +         }
 315.385 +      }
 315.386 +      xassert(k == n);
 315.387 +      /* factorization of matrix B */
 315.388 +      csa->valid = 1, lp->valid = 0;
 315.389 +      csa->bfd = lp->bfd, lp->bfd = NULL;
 315.390 +      /* matrix N (by rows) */
 315.391 +      alloc_N(csa);
 315.392 +      build_N(csa);
 315.393 +      /* working parameters */
 315.394 +      csa->phase = 0;
 315.395 +      csa->tm_beg = xtime();
 315.396 +      csa->it_beg = csa->it_cnt = lp->it_cnt;
 315.397 +      csa->it_dpy = -1;
 315.398 +      /* reference space and steepest edge coefficients */
 315.399 +      csa->refct = 0;
 315.400 +      memset(&refsp[1], 0, (m+n) * sizeof(char));
 315.401 +      for (j = 1; j <= n; j++) gamma[j] = 1.0;
 315.402 +      return;
 315.403 +}
 315.404 +
 315.405 +/***********************************************************************
 315.406 +*  invert_B - compute factorization of the basis matrix
 315.407 +*
 315.408 +*  This routine computes factorization of the current basis matrix B.
 315.409 +*
 315.410 +*  If the operation is successful, the routine returns zero, otherwise
 315.411 +*  non-zero. */
 315.412 +
 315.413 +static int inv_col(void *info, int i, int ind[], double val[])
 315.414 +{     /* this auxiliary routine returns row indices and numeric values
 315.415 +         of non-zero elements of i-th column of the basis matrix */
 315.416 +      struct csa *csa = info;
 315.417 +      int m = csa->m;
 315.418 +#ifdef GLP_DEBUG
 315.419 +      int n = csa->n;
 315.420 +#endif
 315.421 +      int *A_ptr = csa->A_ptr;
 315.422 +      int *A_ind = csa->A_ind;
 315.423 +      double *A_val = csa->A_val;
 315.424 +      int *head = csa->head;
 315.425 +      int k, len, ptr, t;
 315.426 +#ifdef GLP_DEBUG
 315.427 +      xassert(1 <= i && i <= m);
 315.428 +#endif
 315.429 +      k = head[i]; /* B[i] is k-th column of (I|-A) */
 315.430 +#ifdef GLP_DEBUG
 315.431 +      xassert(1 <= k && k <= m+n);
 315.432 +#endif
 315.433 +      if (k <= m)
 315.434 +      {  /* B[i] is k-th column of submatrix I */
 315.435 +         len = 1;
 315.436 +         ind[1] = k;
 315.437 +         val[1] = 1.0;
 315.438 +      }
 315.439 +      else
 315.440 +      {  /* B[i] is (k-m)-th column of submatrix (-A) */
 315.441 +         ptr = A_ptr[k-m];
 315.442 +         len = A_ptr[k-m+1] - ptr;
 315.443 +         memcpy(&ind[1], &A_ind[ptr], len * sizeof(int));
 315.444 +         memcpy(&val[1], &A_val[ptr], len * sizeof(double));
 315.445 +         for (t = 1; t <= len; t++) val[t] = - val[t];
 315.446 +      }
 315.447 +      return len;
 315.448 +}
 315.449 +
 315.450 +static int invert_B(struct csa *csa)
 315.451 +{     int ret;
 315.452 +      ret = bfd_factorize(csa->bfd, csa->m, NULL, inv_col, csa);
 315.453 +      csa->valid = (ret == 0);
 315.454 +      return ret;
 315.455 +}
 315.456 +
 315.457 +/***********************************************************************
 315.458 +*  update_B - update factorization of the basis matrix
 315.459 +*
 315.460 +*  This routine replaces i-th column of the basis matrix B by k-th
 315.461 +*  column of the augmented constraint matrix (I|-A) and then updates
 315.462 +*  the factorization of B.
 315.463 +*
 315.464 +*  If the factorization has been successfully updated, the routine
 315.465 +*  returns zero, otherwise non-zero. */
 315.466 +
 315.467 +static int update_B(struct csa *csa, int i, int k)
 315.468 +{     int m = csa->m;
 315.469 +#ifdef GLP_DEBUG
 315.470 +      int n = csa->n;
 315.471 +#endif
 315.472 +      int ret;
 315.473 +#ifdef GLP_DEBUG
 315.474 +      xassert(1 <= i && i <= m);
 315.475 +      xassert(1 <= k && k <= m+n);
 315.476 +#endif
 315.477 +      if (k <= m)
 315.478 +      {  /* new i-th column of B is k-th column of I */
 315.479 +         int ind[1+1];
 315.480 +         double val[1+1];
 315.481 +         ind[1] = k;
 315.482 +         val[1] = 1.0;
 315.483 +         xassert(csa->valid);
 315.484 +         ret = bfd_update_it(csa->bfd, i, 0, 1, ind, val);
 315.485 +      }
 315.486 +      else
 315.487 +      {  /* new i-th column of B is (k-m)-th column of (-A) */
 315.488 +         int *A_ptr = csa->A_ptr;
 315.489 +         int *A_ind = csa->A_ind;
 315.490 +         double *A_val = csa->A_val;
 315.491 +         double *val = csa->work1;
 315.492 +         int beg, end, ptr, len;
 315.493 +         beg = A_ptr[k-m];
 315.494 +         end = A_ptr[k-m+1];
 315.495 +         len = 0;
 315.496 +         for (ptr = beg; ptr < end; ptr++)
 315.497 +            val[++len] = - A_val[ptr];
 315.498 +         xassert(csa->valid);
 315.499 +         ret = bfd_update_it(csa->bfd, i, 0, len, &A_ind[beg-1], val);
 315.500 +      }
 315.501 +      csa->valid = (ret == 0);
 315.502 +      return ret;
 315.503 +}
 315.504 +
 315.505 +/***********************************************************************
 315.506 +*  error_ftran - compute residual vector r = h - B * x
 315.507 +*
 315.508 +*  This routine computes the residual vector r = h - B * x, where B is
 315.509 +*  the current basis matrix, h is the vector of right-hand sides, x is
 315.510 +*  the solution vector. */
 315.511 +
 315.512 +static void error_ftran(struct csa *csa, double h[], double x[],
 315.513 +      double r[])
 315.514 +{     int m = csa->m;
 315.515 +#ifdef GLP_DEBUG
 315.516 +      int n = csa->n;
 315.517 +#endif
 315.518 +      int *A_ptr = csa->A_ptr;
 315.519 +      int *A_ind = csa->A_ind;
 315.520 +      double *A_val = csa->A_val;
 315.521 +      int *head = csa->head;
 315.522 +      int i, k, beg, end, ptr;
 315.523 +      double temp;
 315.524 +      /* compute the residual vector:
 315.525 +         r = h - B * x = h - B[1] * x[1] - ... - B[m] * x[m],
 315.526 +         where B[1], ..., B[m] are columns of matrix B */
 315.527 +      memcpy(&r[1], &h[1], m * sizeof(double));
 315.528 +      for (i = 1; i <= m; i++)
 315.529 +      {  temp = x[i];
 315.530 +         if (temp == 0.0) continue;
 315.531 +         k = head[i]; /* B[i] is k-th column of (I|-A) */
 315.532 +#ifdef GLP_DEBUG
 315.533 +         xassert(1 <= k && k <= m+n);
 315.534 +#endif
 315.535 +         if (k <= m)
 315.536 +         {  /* B[i] is k-th column of submatrix I */
 315.537 +            r[k] -= temp;
 315.538 +         }
 315.539 +         else
 315.540 +         {  /* B[i] is (k-m)-th column of submatrix (-A) */
 315.541 +            beg = A_ptr[k-m];
 315.542 +            end = A_ptr[k-m+1];
 315.543 +            for (ptr = beg; ptr < end; ptr++)
 315.544 +               r[A_ind[ptr]] += A_val[ptr] * temp;
 315.545 +         }
 315.546 +      }
 315.547 +      return;
 315.548 +}
 315.549 +
 315.550 +/***********************************************************************
 315.551 +*  refine_ftran - refine solution of B * x = h
 315.552 +*
 315.553 +*  This routine performs one iteration to refine the solution of
 315.554 +*  the system B * x = h, where B is the current basis matrix, h is the
 315.555 +*  vector of right-hand sides, x is the solution vector. */
 315.556 +
 315.557 +static void refine_ftran(struct csa *csa, double h[], double x[])
 315.558 +{     int m = csa->m;
 315.559 +      double *r = csa->work1;
 315.560 +      double *d = csa->work1;
 315.561 +      int i;
 315.562 +      /* compute the residual vector r = h - B * x */
 315.563 +      error_ftran(csa, h, x, r);
 315.564 +      /* compute the correction vector d = inv(B) * r */
 315.565 +      xassert(csa->valid);
 315.566 +      bfd_ftran(csa->bfd, d);
 315.567 +      /* refine the solution vector (new x) = (old x) + d */
 315.568 +      for (i = 1; i <= m; i++) x[i] += d[i];
 315.569 +      return;
 315.570 +}
 315.571 +
 315.572 +/***********************************************************************
 315.573 +*  error_btran - compute residual vector r = h - B'* x
 315.574 +*
 315.575 +*  This routine computes the residual vector r = h - B'* x, where B'
 315.576 +*  is a matrix transposed to the current basis matrix, h is the vector
 315.577 +*  of right-hand sides, x is the solution vector. */
 315.578 +
 315.579 +static void error_btran(struct csa *csa, double h[], double x[],
 315.580 +      double r[])
 315.581 +{     int m = csa->m;
 315.582 +#ifdef GLP_DEBUG
 315.583 +      int n = csa->n;
 315.584 +#endif
 315.585 +      int *A_ptr = csa->A_ptr;
 315.586 +      int *A_ind = csa->A_ind;
 315.587 +      double *A_val = csa->A_val;
 315.588 +      int *head = csa->head;
 315.589 +      int i, k, beg, end, ptr;
 315.590 +      double temp;
 315.591 +      /* compute the residual vector r = b - B'* x */
 315.592 +      for (i = 1; i <= m; i++)
 315.593 +      {  /* r[i] := b[i] - (i-th column of B)'* x */
 315.594 +         k = head[i]; /* B[i] is k-th column of (I|-A) */
 315.595 +#ifdef GLP_DEBUG
 315.596 +         xassert(1 <= k && k <= m+n);
 315.597 +#endif
 315.598 +         temp = h[i];
 315.599 +         if (k <= m)
 315.600 +         {  /* B[i] is k-th column of submatrix I */
 315.601 +            temp -= x[k];
 315.602 +         }
 315.603 +         else
 315.604 +         {  /* B[i] is (k-m)-th column of submatrix (-A) */
 315.605 +            beg = A_ptr[k-m];
 315.606 +            end = A_ptr[k-m+1];
 315.607 +            for (ptr = beg; ptr < end; ptr++)
 315.608 +               temp += A_val[ptr] * x[A_ind[ptr]];
 315.609 +         }
 315.610 +         r[i] = temp;
 315.611 +      }
 315.612 +      return;
 315.613 +}
 315.614 +
 315.615 +/***********************************************************************
 315.616 +*  refine_btran - refine solution of B'* x = h
 315.617 +*
 315.618 +*  This routine performs one iteration to refine the solution of the
 315.619 +*  system B'* x = h, where B' is a matrix transposed to the current
 315.620 +*  basis matrix, h is the vector of right-hand sides, x is the solution
 315.621 +*  vector. */
 315.622 +
 315.623 +static void refine_btran(struct csa *csa, double h[], double x[])
 315.624 +{     int m = csa->m;
 315.625 +      double *r = csa->work1;
 315.626 +      double *d = csa->work1;
 315.627 +      int i;
 315.628 +      /* compute the residual vector r = h - B'* x */
 315.629 +      error_btran(csa, h, x, r);
 315.630 +      /* compute the correction vector d = inv(B') * r */
 315.631 +      xassert(csa->valid);
 315.632 +      bfd_btran(csa->bfd, d);
 315.633 +      /* refine the solution vector (new x) = (old x) + d */
 315.634 +      for (i = 1; i <= m; i++) x[i] += d[i];
 315.635 +      return;
 315.636 +}
 315.637 +
 315.638 +/***********************************************************************
 315.639 +*  alloc_N - allocate matrix N
 315.640 +*
 315.641 +*  This routine determines maximal row lengths of matrix N, sets its
 315.642 +*  row pointers, and then allocates arrays N_ind and N_val.
 315.643 +*
 315.644 +*  Note that some fixed structural variables may temporarily become
 315.645 +*  double-bounded, so corresponding columns of matrix A should not be
 315.646 +*  ignored on calculating maximal row lengths of matrix N. */
 315.647 +
 315.648 +static void alloc_N(struct csa *csa)
 315.649 +{     int m = csa->m;
 315.650 +      int n = csa->n;
 315.651 +      int *A_ptr = csa->A_ptr;
 315.652 +      int *A_ind = csa->A_ind;
 315.653 +      int *N_ptr = csa->N_ptr;
 315.654 +      int *N_len = csa->N_len;
 315.655 +      int i, j, beg, end, ptr;
 315.656 +      /* determine number of non-zeros in each row of the augmented
 315.657 +         constraint matrix (I|-A) */
 315.658 +      for (i = 1; i <= m; i++)
 315.659 +         N_len[i] = 1;
 315.660 +      for (j = 1; j <= n; j++)
 315.661 +      {  beg = A_ptr[j];
 315.662 +         end = A_ptr[j+1];
 315.663 +         for (ptr = beg; ptr < end; ptr++)
 315.664 +            N_len[A_ind[ptr]]++;
 315.665 +      }
 315.666 +      /* determine maximal row lengths of matrix N and set its row
 315.667 +         pointers */
 315.668 +      N_ptr[1] = 1;
 315.669 +      for (i = 1; i <= m; i++)
 315.670 +      {  /* row of matrix N cannot have more than n non-zeros */
 315.671 +         if (N_len[i] > n) N_len[i] = n;
 315.672 +         N_ptr[i+1] = N_ptr[i] + N_len[i];
 315.673 +      }
 315.674 +      /* now maximal number of non-zeros in matrix N is known */
 315.675 +      csa->N_ind = xcalloc(N_ptr[m+1], sizeof(int));
 315.676 +      csa->N_val = xcalloc(N_ptr[m+1], sizeof(double));
 315.677 +      return;
 315.678 +}
 315.679 +
 315.680 +/***********************************************************************
 315.681 +*  add_N_col - add column of matrix (I|-A) to matrix N
 315.682 +*
 315.683 +*  This routine adds j-th column to matrix N which is k-th column of
 315.684 +*  the augmented constraint matrix (I|-A). (It is assumed that old j-th
 315.685 +*  column was previously removed from matrix N.) */
 315.686 +
 315.687 +static void add_N_col(struct csa *csa, int j, int k)
 315.688 +{     int m = csa->m;
 315.689 +#ifdef GLP_DEBUG
 315.690 +      int n = csa->n;
 315.691 +#endif
 315.692 +      int *N_ptr = csa->N_ptr;
 315.693 +      int *N_len = csa->N_len;
 315.694 +      int *N_ind = csa->N_ind;
 315.695 +      double *N_val = csa->N_val;
 315.696 +      int pos;
 315.697 +#ifdef GLP_DEBUG
 315.698 +      xassert(1 <= j && j <= n);
 315.699 +      xassert(1 <= k && k <= m+n);
 315.700 +#endif
 315.701 +      if (k <= m)
 315.702 +      {  /* N[j] is k-th column of submatrix I */
 315.703 +         pos = N_ptr[k] + (N_len[k]++);
 315.704 +#ifdef GLP_DEBUG
 315.705 +         xassert(pos < N_ptr[k+1]);
 315.706 +#endif
 315.707 +         N_ind[pos] = j;
 315.708 +         N_val[pos] = 1.0;
 315.709 +      }
 315.710 +      else
 315.711 +      {  /* N[j] is (k-m)-th column of submatrix (-A) */
 315.712 +         int *A_ptr = csa->A_ptr;
 315.713 +         int *A_ind = csa->A_ind;
 315.714 +         double *A_val = csa->A_val;
 315.715 +         int i, beg, end, ptr;
 315.716 +         beg = A_ptr[k-m];
 315.717 +         end = A_ptr[k-m+1];
 315.718 +         for (ptr = beg; ptr < end; ptr++)
 315.719 +         {  i = A_ind[ptr]; /* row number */
 315.720 +            pos = N_ptr[i] + (N_len[i]++);
 315.721 +#ifdef GLP_DEBUG
 315.722 +            xassert(pos < N_ptr[i+1]);
 315.723 +#endif
 315.724 +            N_ind[pos] = j;
 315.725 +            N_val[pos] = - A_val[ptr];
 315.726 +         }
 315.727 +      }
 315.728 +      return;
 315.729 +}
 315.730 +
 315.731 +/***********************************************************************
 315.732 +*  del_N_col - remove column of matrix (I|-A) from matrix N
 315.733 +*
 315.734 +*  This routine removes j-th column from matrix N which is k-th column
 315.735 +*  of the augmented constraint matrix (I|-A). */
 315.736 +
 315.737 +static void del_N_col(struct csa *csa, int j, int k)
 315.738 +{     int m = csa->m;
 315.739 +#ifdef GLP_DEBUG
 315.740 +      int n = csa->n;
 315.741 +#endif
 315.742 +      int *N_ptr = csa->N_ptr;
 315.743 +      int *N_len = csa->N_len;
 315.744 +      int *N_ind = csa->N_ind;
 315.745 +      double *N_val = csa->N_val;
 315.746 +      int pos, head, tail;
 315.747 +#ifdef GLP_DEBUG
 315.748 +      xassert(1 <= j && j <= n);
 315.749 +      xassert(1 <= k && k <= m+n);
 315.750 +#endif
 315.751 +      if (k <= m)
 315.752 +      {  /* N[j] is k-th column of submatrix I */
 315.753 +         /* find element in k-th row of N */
 315.754 +         head = N_ptr[k];
 315.755 +         for (pos = head; N_ind[pos] != j; pos++) /* nop */;
 315.756 +         /* and remove it from the row list */
 315.757 +         tail = head + (--N_len[k]);
 315.758 +#ifdef GLP_DEBUG
 315.759 +         xassert(pos <= tail);
 315.760 +#endif
 315.761 +         N_ind[pos] = N_ind[tail];
 315.762 +         N_val[pos] = N_val[tail];
 315.763 +      }
 315.764 +      else
 315.765 +      {  /* N[j] is (k-m)-th column of submatrix (-A) */
 315.766 +         int *A_ptr = csa->A_ptr;
 315.767 +         int *A_ind = csa->A_ind;
 315.768 +         int i, beg, end, ptr;
 315.769 +         beg = A_ptr[k-m];
 315.770 +         end = A_ptr[k-m+1];
 315.771 +         for (ptr = beg; ptr < end; ptr++)
 315.772 +         {  i = A_ind[ptr]; /* row number */
 315.773 +            /* find element in i-th row of N */
 315.774 +            head = N_ptr[i];
 315.775 +            for (pos = head; N_ind[pos] != j; pos++) /* nop */;
 315.776 +            /* and remove it from the row list */
 315.777 +            tail = head + (--N_len[i]);
 315.778 +#ifdef GLP_DEBUG
 315.779 +            xassert(pos <= tail);
 315.780 +#endif
 315.781 +            N_ind[pos] = N_ind[tail];
 315.782 +            N_val[pos] = N_val[tail];
 315.783 +         }
 315.784 +      }
 315.785 +      return;
 315.786 +}
 315.787 +
 315.788 +/***********************************************************************
 315.789 +*  build_N - build matrix N for current basis
 315.790 +*
 315.791 +*  This routine builds matrix N for the current basis from columns
 315.792 +*  of the augmented constraint matrix (I|-A) corresponding to non-basic
 315.793 +*  non-fixed variables. */
 315.794 +
 315.795 +static void build_N(struct csa *csa)
 315.796 +{     int m = csa->m;
 315.797 +      int n = csa->n;
 315.798 +      int *head = csa->head;
 315.799 +      char *stat = csa->stat;
 315.800 +      int *N_len = csa->N_len;
 315.801 +      int j, k;
 315.802 +      /* N := empty matrix */
 315.803 +      memset(&N_len[1], 0, m * sizeof(int));
 315.804 +      /* go through non-basic columns of matrix (I|-A) */
 315.805 +      for (j = 1; j <= n; j++)
 315.806 +      {  if (stat[j] != GLP_NS)
 315.807 +         {  /* xN[j] is non-fixed; add j-th column to matrix N which is
 315.808 +               k-th column of matrix (I|-A) */
 315.809 +            k = head[m+j]; /* x[k] = xN[j] */
 315.810 +#ifdef GLP_DEBUG
 315.811 +            xassert(1 <= k && k <= m+n);
 315.812 +#endif
 315.813 +            add_N_col(csa, j, k);
 315.814 +         }
 315.815 +      }
 315.816 +      return;
 315.817 +}
 315.818 +
 315.819 +/***********************************************************************
 315.820 +*  get_xN - determine current value of non-basic variable xN[j]
 315.821 +*
 315.822 +*  This routine returns the current value of non-basic variable xN[j],
 315.823 +*  which is a value of its active bound. */
 315.824 +
 315.825 +static double get_xN(struct csa *csa, int j)
 315.826 +{     int m = csa->m;
 315.827 +#ifdef GLP_DEBUG
 315.828 +      int n = csa->n;
 315.829 +#endif
 315.830 +      double *lb = csa->lb;
 315.831 +      double *ub = csa->ub;
 315.832 +      int *head = csa->head;
 315.833 +      char *stat = csa->stat;
 315.834 +      int k;
 315.835 +      double xN;
 315.836 +#ifdef GLP_DEBUG
 315.837 +      xassert(1 <= j && j <= n);
 315.838 +#endif
 315.839 +      k = head[m+j]; /* x[k] = xN[j] */
 315.840 +#ifdef GLP_DEBUG
 315.841 +      xassert(1 <= k && k <= m+n);
 315.842 +#endif
 315.843 +      switch (stat[j])
 315.844 +      {  case GLP_NL:
 315.845 +            /* x[k] is on its lower bound */
 315.846 +            xN = lb[k]; break;
 315.847 +         case GLP_NU:
 315.848 +            /* x[k] is on its upper bound */
 315.849 +            xN = ub[k]; break;
 315.850 +         case GLP_NF:
 315.851 +            /* x[k] is free non-basic variable */
 315.852 +            xN = 0.0; break;
 315.853 +         case GLP_NS:
 315.854 +            /* x[k] is fixed non-basic variable */
 315.855 +            xN = lb[k]; break;
 315.856 +         default:
 315.857 +            xassert(stat != stat);
 315.858 +      }
 315.859 +      return xN;
 315.860 +}
 315.861 +
 315.862 +/***********************************************************************
 315.863 +*  eval_beta - compute primal values of basic variables
 315.864 +*
 315.865 +*  This routine computes current primal values of all basic variables:
 315.866 +*
 315.867 +*     beta = - inv(B) * N * xN,
 315.868 +*
 315.869 +*  where B is the current basis matrix, N is a matrix built of columns
 315.870 +*  of matrix (I|-A) corresponding to non-basic variables, and xN is the
 315.871 +*  vector of current values of non-basic variables. */
 315.872 +
 315.873 +static void eval_beta(struct csa *csa, double beta[])
 315.874 +{     int m = csa->m;
 315.875 +      int n = csa->n;
 315.876 +      int *A_ptr = csa->A_ptr;
 315.877 +      int *A_ind = csa->A_ind;
 315.878 +      double *A_val = csa->A_val;
 315.879 +      int *head = csa->head;
 315.880 +      double *h = csa->work2;
 315.881 +      int i, j, k, beg, end, ptr;
 315.882 +      double xN;
 315.883 +      /* compute the right-hand side vector:
 315.884 +         h := - N * xN = - N[1] * xN[1] - ... - N[n] * xN[n],
 315.885 +         where N[1], ..., N[n] are columns of matrix N */
 315.886 +      for (i = 1; i <= m; i++)
 315.887 +         h[i] = 0.0;
 315.888 +      for (j = 1; j <= n; j++)
 315.889 +      {  k = head[m+j]; /* x[k] = xN[j] */
 315.890 +#ifdef GLP_DEBUG
 315.891 +         xassert(1 <= k && k <= m+n);
 315.892 +#endif
 315.893 +         /* determine current value of xN[j] */
 315.894 +         xN = get_xN(csa, j);
 315.895 +         if (xN == 0.0) continue;
 315.896 +         if (k <= m)
 315.897 +         {  /* N[j] is k-th column of submatrix I */
 315.898 +            h[k] -= xN;
 315.899 +         }
 315.900 +         else
 315.901 +         {  /* N[j] is (k-m)-th column of submatrix (-A) */
 315.902 +            beg = A_ptr[k-m];
 315.903 +            end = A_ptr[k-m+1];
 315.904 +            for (ptr = beg; ptr < end; ptr++)
 315.905 +               h[A_ind[ptr]] += xN * A_val[ptr];
 315.906 +         }
 315.907 +      }
 315.908 +      /* solve system B * beta = h */
 315.909 +      memcpy(&beta[1], &h[1], m * sizeof(double));
 315.910 +      xassert(csa->valid);
 315.911 +      bfd_ftran(csa->bfd, beta);
 315.912 +      /* and refine the solution */
 315.913 +      refine_ftran(csa, h, beta);
 315.914 +      return;
 315.915 +}
 315.916 +
 315.917 +/***********************************************************************
 315.918 +*  eval_pi - compute vector of simplex multipliers
 315.919 +*
 315.920 +*  This routine computes the vector of current simplex multipliers:
 315.921 +*
 315.922 +*     pi = inv(B') * cB,
 315.923 +*
 315.924 +*  where B' is a matrix transposed to the current basis matrix, cB is
 315.925 +*  a subvector of objective coefficients at basic variables. */
 315.926 +
 315.927 +static void eval_pi(struct csa *csa, double pi[])
 315.928 +{     int m = csa->m;
 315.929 +      double *c = csa->coef;
 315.930 +      int *head = csa->head;
 315.931 +      double *cB = csa->work2;
 315.932 +      int i;
 315.933 +      /* construct the right-hand side vector cB */
 315.934 +      for (i = 1; i <= m; i++)
 315.935 +         cB[i] = c[head[i]];
 315.936 +      /* solve system B'* pi = cB */
 315.937 +      memcpy(&pi[1], &cB[1], m * sizeof(double));
 315.938 +      xassert(csa->valid);
 315.939 +      bfd_btran(csa->bfd, pi);
 315.940 +      /* and refine the solution */
 315.941 +      refine_btran(csa, cB, pi);
 315.942 +      return;
 315.943 +}
 315.944 +
 315.945 +/***********************************************************************
 315.946 +*  eval_cost - compute reduced cost of non-basic variable xN[j]
 315.947 +*
 315.948 +*  This routine computes the current reduced cost of non-basic variable
 315.949 +*  xN[j]:
 315.950 +*
 315.951 +*     d[j] = cN[j] - N'[j] * pi,
 315.952 +*
 315.953 +*  where cN[j] is the objective coefficient at variable xN[j], N[j] is
 315.954 +*  a column of the augmented constraint matrix (I|-A) corresponding to
 315.955 +*  xN[j], pi is the vector of simplex multipliers. */
 315.956 +
 315.957 +static double eval_cost(struct csa *csa, double pi[], int j)
 315.958 +{     int m = csa->m;
 315.959 +#ifdef GLP_DEBUG
 315.960 +      int n = csa->n;
 315.961 +#endif
 315.962 +      double *coef = csa->coef;
 315.963 +      int *head = csa->head;
 315.964 +      int k;
 315.965 +      double dj;
 315.966 +#ifdef GLP_DEBUG
 315.967 +      xassert(1 <= j && j <= n);
 315.968 +#endif
 315.969 +      k = head[m+j]; /* x[k] = xN[j] */
 315.970 +#ifdef GLP_DEBUG
 315.971 +      xassert(1 <= k && k <= m+n);
 315.972 +#endif
 315.973 +      dj = coef[k];
 315.974 +      if (k <= m)
 315.975 +      {  /* N[j] is k-th column of submatrix I */
 315.976 +         dj -= pi[k];
 315.977 +      }
 315.978 +      else
 315.979 +      {  /* N[j] is (k-m)-th column of submatrix (-A) */
 315.980 +         int *A_ptr = csa->A_ptr;
 315.981 +         int *A_ind = csa->A_ind;
 315.982 +         double *A_val = csa->A_val;
 315.983 +         int beg, end, ptr;
 315.984 +         beg = A_ptr[k-m];
 315.985 +         end = A_ptr[k-m+1];
 315.986 +         for (ptr = beg; ptr < end; ptr++)
 315.987 +            dj += A_val[ptr] * pi[A_ind[ptr]];
 315.988 +      }
 315.989 +      return dj;
 315.990 +}
 315.991 +
 315.992 +/***********************************************************************
 315.993 +*  eval_bbar - compute and store primal values of basic variables
 315.994 +*
 315.995 +*  This routine computes primal values of all basic variables and then
 315.996 +*  stores them in the solution array. */
 315.997 +
 315.998 +static void eval_bbar(struct csa *csa)
 315.999 +{     eval_beta(csa, csa->bbar);
315.1000 +      return;
315.1001 +}
315.1002 +
315.1003 +/***********************************************************************
315.1004 +*  eval_cbar - compute and store reduced costs of non-basic variables
315.1005 +*
315.1006 +*  This routine computes reduced costs of all non-basic variables and
315.1007 +*  then stores them in the solution array. */
315.1008 +
315.1009 +static void eval_cbar(struct csa *csa)
315.1010 +{
315.1011 +#ifdef GLP_DEBUG
315.1012 +      int m = csa->m;
315.1013 +#endif
315.1014 +      int n = csa->n;
315.1015 +#ifdef GLP_DEBUG
315.1016 +      int *head = csa->head;
315.1017 +#endif
315.1018 +      double *cbar = csa->cbar;
315.1019 +      double *pi = csa->work3;
315.1020 +      int j;
315.1021 +#ifdef GLP_DEBUG
315.1022 +      int k;
315.1023 +#endif
315.1024 +      /* compute simplex multipliers */
315.1025 +      eval_pi(csa, pi);
315.1026 +      /* compute and store reduced costs */
315.1027 +      for (j = 1; j <= n; j++)
315.1028 +      {
315.1029 +#ifdef GLP_DEBUG
315.1030 +         k = head[m+j]; /* x[k] = xN[j] */
315.1031 +         xassert(1 <= k && k <= m+n);
315.1032 +#endif
315.1033 +         cbar[j] = eval_cost(csa, pi, j);
315.1034 +      }
315.1035 +      return;
315.1036 +}
315.1037 +
315.1038 +/***********************************************************************
315.1039 +*  reset_refsp - reset the reference space
315.1040 +*
315.1041 +*  This routine resets (redefines) the reference space used in the
315.1042 +*  projected steepest edge pricing algorithm. */
315.1043 +
315.1044 +static void reset_refsp(struct csa *csa)
315.1045 +{     int m = csa->m;
315.1046 +      int n = csa->n;
315.1047 +      int *head = csa->head;
315.1048 +      char *refsp = csa->refsp;
315.1049 +      double *gamma = csa->gamma;
315.1050 +      int j, k;
315.1051 +      xassert(csa->refct == 0);
315.1052 +      csa->refct = 1000;
315.1053 +      memset(&refsp[1], 0, (m+n) * sizeof(char));
315.1054 +      for (j = 1; j <= n; j++)
315.1055 +      {  k = head[m+j]; /* x[k] = xN[j] */
315.1056 +         refsp[k] = 1;
315.1057 +         gamma[j] = 1.0;
315.1058 +      }
315.1059 +      return;
315.1060 +}
315.1061 +
315.1062 +/***********************************************************************
315.1063 +*  eval_gamma - compute steepest edge coefficient
315.1064 +*
315.1065 +*  This routine computes the steepest edge coefficient for non-basic
315.1066 +*  variable xN[j] using its direct definition:
315.1067 +*
315.1068 +*     gamma[j] = delta[j] +  sum   alfa[i,j]^2,
315.1069 +*                           i in R
315.1070 +*
315.1071 +*  where delta[j] = 1, if xN[j] is in the current reference space,
315.1072 +*  and 0 otherwise; R is a set of basic variables xB[i], which are in
315.1073 +*  the current reference space; alfa[i,j] are elements of the current
315.1074 +*  simplex table.
315.1075 +*
315.1076 +*  NOTE: The routine is intended only for debugginig purposes. */
315.1077 +
315.1078 +static double eval_gamma(struct csa *csa, int j)
315.1079 +{     int m = csa->m;
315.1080 +#ifdef GLP_DEBUG
315.1081 +      int n = csa->n;
315.1082 +#endif
315.1083 +      int *head = csa->head;
315.1084 +      char *refsp = csa->refsp;
315.1085 +      double *alfa = csa->work3;
315.1086 +      double *h = csa->work3;
315.1087 +      int i, k;
315.1088 +      double gamma;
315.1089 +#ifdef GLP_DEBUG
315.1090 +      xassert(1 <= j && j <= n);
315.1091 +#endif
315.1092 +      k = head[m+j]; /* x[k] = xN[j] */
315.1093 +#ifdef GLP_DEBUG
315.1094 +      xassert(1 <= k && k <= m+n);
315.1095 +#endif
315.1096 +      /* construct the right-hand side vector h = - N[j] */
315.1097 +      for (i = 1; i <= m; i++)
315.1098 +         h[i] = 0.0;
315.1099 +      if (k <= m)
315.1100 +      {  /* N[j] is k-th column of submatrix I */
315.1101 +         h[k] = -1.0;
315.1102 +      }
315.1103 +      else
315.1104 +      {  /* N[j] is (k-m)-th column of submatrix (-A) */
315.1105 +         int *A_ptr = csa->A_ptr;
315.1106 +         int *A_ind = csa->A_ind;
315.1107 +         double *A_val = csa->A_val;
315.1108 +         int beg, end, ptr;
315.1109 +         beg = A_ptr[k-m];
315.1110 +         end = A_ptr[k-m+1];
315.1111 +         for (ptr = beg; ptr < end; ptr++)
315.1112 +            h[A_ind[ptr]] = A_val[ptr];
315.1113 +      }
315.1114 +      /* solve system B * alfa = h */
315.1115 +      xassert(csa->valid);
315.1116 +      bfd_ftran(csa->bfd, alfa);
315.1117 +      /* compute gamma */
315.1118 +      gamma = (refsp[k] ? 1.0 : 0.0);
315.1119 +      for (i = 1; i <= m; i++)
315.1120 +      {  k = head[i];
315.1121 +#ifdef GLP_DEBUG
315.1122 +         xassert(1 <= k && k <= m+n);
315.1123 +#endif
315.1124 +         if (refsp[k]) gamma += alfa[i] * alfa[i];
315.1125 +      }
315.1126 +      return gamma;
315.1127 +}
315.1128 +
315.1129 +/***********************************************************************
315.1130 +*  chuzc - choose non-basic variable (column of the simplex table)
315.1131 +*
315.1132 +*  This routine chooses non-basic variable xN[q], which has largest
315.1133 +*  weighted reduced cost:
315.1134 +*
315.1135 +*     |d[q]| / sqrt(gamma[q]) = max  |d[j]| / sqrt(gamma[j]),
315.1136 +*                              j in J
315.1137 +*
315.1138 +*  where J is a subset of eligible non-basic variables xN[j], d[j] is
315.1139 +*  reduced cost of xN[j], gamma[j] is the steepest edge coefficient.
315.1140 +*
315.1141 +*  The working objective function is always minimized, so the sign of
315.1142 +*  d[q] determines direction, in which xN[q] has to change:
315.1143 +*
315.1144 +*     if d[q] < 0, xN[q] has to increase;
315.1145 +*
315.1146 +*     if d[q] > 0, xN[q] has to decrease.
315.1147 +*
315.1148 +*  If |d[j]| <= tol_dj, where tol_dj is a specified tolerance, xN[j]
315.1149 +*  is not included in J and therefore ignored. (It is assumed that the
315.1150 +*  working objective row is appropriately scaled, i.e. max|c[k]| = 1.)
315.1151 +*
315.1152 +*  If J is empty and no variable has been chosen, q is set to 0. */
315.1153 +
315.1154 +static void chuzc(struct csa *csa, double tol_dj)
315.1155 +{     int n = csa->n;
315.1156 +      char *stat = csa->stat;
315.1157 +      double *cbar = csa->cbar;
315.1158 +      double *gamma = csa->gamma;
315.1159 +      int j, q;
315.1160 +      double dj, best, temp;
315.1161 +      /* nothing is chosen so far */
315.1162 +      q = 0, best = 0.0;
315.1163 +      /* look through the list of non-basic variables */
315.1164 +      for (j = 1; j <= n; j++)
315.1165 +      {  dj = cbar[j];
315.1166 +         switch (stat[j])
315.1167 +         {  case GLP_NL:
315.1168 +               /* xN[j] can increase */
315.1169 +               if (dj >= - tol_dj) continue;
315.1170 +               break;
315.1171 +            case GLP_NU:
315.1172 +               /* xN[j] can decrease */
315.1173 +               if (dj <= + tol_dj) continue;
315.1174 +               break;
315.1175 +            case GLP_NF:
315.1176 +               /* xN[j] can change in any direction */
315.1177 +               if (- tol_dj <= dj && dj <= + tol_dj) continue;
315.1178 +               break;
315.1179 +            case GLP_NS:
315.1180 +               /* xN[j] cannot change at all */
315.1181 +               continue;
315.1182 +            default:
315.1183 +               xassert(stat != stat);
315.1184 +         }
315.1185 +         /* xN[j] is eligible non-basic variable; choose one which has
315.1186 +            largest weighted reduced cost */
315.1187 +#ifdef GLP_DEBUG
315.1188 +         xassert(gamma[j] > 0.0);
315.1189 +#endif
315.1190 +         temp = (dj * dj) / gamma[j];
315.1191 +         if (best < temp)
315.1192 +            q = j, best = temp;
315.1193 +      }
315.1194 +      /* store the index of non-basic variable xN[q] chosen */
315.1195 +      csa->q = q;
315.1196 +      return;
315.1197 +}
315.1198 +
315.1199 +/***********************************************************************
315.1200 +*  eval_tcol - compute pivot column of the simplex table
315.1201 +*
315.1202 +*  This routine computes the pivot column of the simplex table, which
315.1203 +*  corresponds to non-basic variable xN[q] chosen.
315.1204 +*
315.1205 +*  The pivot column is the following vector:
315.1206 +*
315.1207 +*     tcol = T * e[q] = - inv(B) * N * e[q] = - inv(B) * N[q],
315.1208 +*
315.1209 +*  where B is the current basis matrix, N[q] is a column of the matrix
315.1210 +*  (I|-A) corresponding to variable xN[q]. */
315.1211 +
315.1212 +static void eval_tcol(struct csa *csa)
315.1213 +{     int m = csa->m;
315.1214 +#ifdef GLP_DEBUG
315.1215 +      int n = csa->n;
315.1216 +#endif
315.1217 +      int *head = csa->head;
315.1218 +      int q = csa->q;
315.1219 +      int *tcol_ind = csa->tcol_ind;
315.1220 +      double *tcol_vec = csa->tcol_vec;
315.1221 +      double *h = csa->tcol_vec;
315.1222 +      int i, k, nnz;
315.1223 +#ifdef GLP_DEBUG
315.1224 +      xassert(1 <= q && q <= n);
315.1225 +#endif
315.1226 +      k = head[m+q]; /* x[k] = xN[q] */
315.1227 +#ifdef GLP_DEBUG
315.1228 +      xassert(1 <= k && k <= m+n);
315.1229 +#endif
315.1230 +      /* construct the right-hand side vector h = - N[q] */
315.1231 +      for (i = 1; i <= m; i++)
315.1232 +         h[i] = 0.0;
315.1233 +      if (k <= m)
315.1234 +      {  /* N[q] is k-th column of submatrix I */
315.1235 +         h[k] = -1.0;
315.1236 +      }
315.1237 +      else
315.1238 +      {  /* N[q] is (k-m)-th column of submatrix (-A) */
315.1239 +         int *A_ptr = csa->A_ptr;
315.1240 +         int *A_ind = csa->A_ind;
315.1241 +         double *A_val = csa->A_val;
315.1242 +         int beg, end, ptr;
315.1243 +         beg = A_ptr[k-m];
315.1244 +         end = A_ptr[k-m+1];
315.1245 +         for (ptr = beg; ptr < end; ptr++)
315.1246 +            h[A_ind[ptr]] = A_val[ptr];
315.1247 +      }
315.1248 +      /* solve system B * tcol = h */
315.1249 +      xassert(csa->valid);
315.1250 +      bfd_ftran(csa->bfd, tcol_vec);
315.1251 +      /* construct sparse pattern of the pivot column */
315.1252 +      nnz = 0;
315.1253 +      for (i = 1; i <= m; i++)
315.1254 +      {  if (tcol_vec[i] != 0.0)
315.1255 +            tcol_ind[++nnz] = i;
315.1256 +      }
315.1257 +      csa->tcol_nnz = nnz;
315.1258 +      return;
315.1259 +}
315.1260 +
315.1261 +/***********************************************************************
315.1262 +*  refine_tcol - refine pivot column of the simplex table
315.1263 +*
315.1264 +*  This routine refines the pivot column of the simplex table assuming
315.1265 +*  that it was previously computed by the routine eval_tcol. */
315.1266 +
315.1267 +static void refine_tcol(struct csa *csa)
315.1268 +{     int m = csa->m;
315.1269 +#ifdef GLP_DEBUG
315.1270 +      int n = csa->n;
315.1271 +#endif
315.1272 +      int *head = csa->head;
315.1273 +      int q = csa->q;
315.1274 +      int *tcol_ind = csa->tcol_ind;
315.1275 +      double *tcol_vec = csa->tcol_vec;
315.1276 +      double *h = csa->work3;
315.1277 +      int i, k, nnz;
315.1278 +#ifdef GLP_DEBUG
315.1279 +      xassert(1 <= q && q <= n);
315.1280 +#endif
315.1281 +      k = head[m+q]; /* x[k] = xN[q] */
315.1282 +#ifdef GLP_DEBUG
315.1283 +      xassert(1 <= k && k <= m+n);
315.1284 +#endif
315.1285 +      /* construct the right-hand side vector h = - N[q] */
315.1286 +      for (i = 1; i <= m; i++)
315.1287 +         h[i] = 0.0;
315.1288 +      if (k <= m)
315.1289 +      {  /* N[q] is k-th column of submatrix I */
315.1290 +         h[k] = -1.0;
315.1291 +      }
315.1292 +      else
315.1293 +      {  /* N[q] is (k-m)-th column of submatrix (-A) */
315.1294 +         int *A_ptr = csa->A_ptr;
315.1295 +         int *A_ind = csa->A_ind;
315.1296 +         double *A_val = csa->A_val;
315.1297 +         int beg, end, ptr;
315.1298 +         beg = A_ptr[k-m];
315.1299 +         end = A_ptr[k-m+1];
315.1300 +         for (ptr = beg; ptr < end; ptr++)
315.1301 +            h[A_ind[ptr]] = A_val[ptr];
315.1302 +      }
315.1303 +      /* refine solution of B * tcol = h */
315.1304 +      refine_ftran(csa, h, tcol_vec);
315.1305 +      /* construct sparse pattern of the pivot column */
315.1306 +      nnz = 0;
315.1307 +      for (i = 1; i <= m; i++)
315.1308 +      {  if (tcol_vec[i] != 0.0)
315.1309 +            tcol_ind[++nnz] = i;
315.1310 +      }
315.1311 +      csa->tcol_nnz = nnz;
315.1312 +      return;
315.1313 +}
315.1314 +
315.1315 +/***********************************************************************
315.1316 +*  sort_tcol - sort pivot column of the simplex table
315.1317 +*
315.1318 +*  This routine reorders the list of non-zero elements of the pivot
315.1319 +*  column to put significant elements, whose magnitude is not less than
315.1320 +*  a specified tolerance, in front of the list, and stores the number
315.1321 +*  of significant elements in tcol_num. */
315.1322 +
315.1323 +static void sort_tcol(struct csa *csa, double tol_piv)
315.1324 +{
315.1325 +#ifdef GLP_DEBUG
315.1326 +      int m = csa->m;
315.1327 +#endif
315.1328 +      int nnz = csa->tcol_nnz;
315.1329 +      int *tcol_ind = csa->tcol_ind;
315.1330 +      double *tcol_vec = csa->tcol_vec;
315.1331 +      int i, num, pos;
315.1332 +      double big, eps, temp;
315.1333 +      /* compute infinity (maximum) norm of the column */
315.1334 +      big = 0.0;
315.1335 +      for (pos = 1; pos <= nnz; pos++)
315.1336 +      {
315.1337 +#ifdef GLP_DEBUG
315.1338 +         i = tcol_ind[pos];
315.1339 +         xassert(1 <= i && i <= m);
315.1340 +#endif
315.1341 +         temp = fabs(tcol_vec[tcol_ind[pos]]);
315.1342 +         if (big < temp) big = temp;
315.1343 +      }
315.1344 +      csa->tcol_max = big;
315.1345 +      /* determine absolute pivot tolerance */
315.1346 +      eps = tol_piv * (1.0 + 0.01 * big);
315.1347 +      /* move significant column components to front of the list */
315.1348 +      for (num = 0; num < nnz; )
315.1349 +      {  i = tcol_ind[nnz];
315.1350 +         if (fabs(tcol_vec[i]) < eps)
315.1351 +            nnz--;
315.1352 +         else
315.1353 +         {  num++;
315.1354 +            tcol_ind[nnz] = tcol_ind[num];
315.1355 +            tcol_ind[num] = i;
315.1356 +         }
315.1357 +      }
315.1358 +      csa->tcol_num = num;
315.1359 +      return;
315.1360 +}
315.1361 +
315.1362 +/***********************************************************************
315.1363 +*  chuzr - choose basic variable (row of the simplex table)
315.1364 +*
315.1365 +*  This routine chooses basic variable xB[p], which reaches its bound
315.1366 +*  first on changing non-basic variable xN[q] in valid direction.
315.1367 +*
315.1368 +*  The parameter rtol is a relative tolerance used to relax bounds of
315.1369 +*  basic variables. If rtol = 0, the routine implements the standard
315.1370 +*  ratio test. Otherwise, if rtol > 0, the routine implements Harris'
315.1371 +*  two-pass ratio test. In the latter case rtol should be about three
315.1372 +*  times less than a tolerance used to check primal feasibility. */
315.1373 +
315.1374 +static void chuzr(struct csa *csa, double rtol)
315.1375 +{     int m = csa->m;
315.1376 +#ifdef GLP_DEBUG
315.1377 +      int n = csa->n;
315.1378 +#endif
315.1379 +      char *type = csa->type;
315.1380 +      double *lb = csa->lb;
315.1381 +      double *ub = csa->ub;
315.1382 +      double *coef = csa->coef;
315.1383 +      int *head = csa->head;
315.1384 +      int phase = csa->phase;
315.1385 +      double *bbar = csa->bbar;
315.1386 +      double *cbar = csa->cbar;
315.1387 +      int q = csa->q;
315.1388 +      int *tcol_ind = csa->tcol_ind;
315.1389 +      double *tcol_vec = csa->tcol_vec;
315.1390 +      int tcol_num = csa->tcol_num;
315.1391 +      int i, i_stat, k, p, p_stat, pos;
315.1392 +      double alfa, big, delta, s, t, teta, tmax;
315.1393 +#ifdef GLP_DEBUG
315.1394 +      xassert(1 <= q && q <= n);
315.1395 +#endif
315.1396 +      /* s := - sign(d[q]), where d[q] is reduced cost of xN[q] */
315.1397 +#ifdef GLP_DEBUG
315.1398 +      xassert(cbar[q] != 0.0);
315.1399 +#endif
315.1400 +      s = (cbar[q] > 0.0 ? -1.0 : +1.0);
315.1401 +      /*** FIRST PASS ***/
315.1402 +      k = head[m+q]; /* x[k] = xN[q] */
315.1403 +#ifdef GLP_DEBUG
315.1404 +      xassert(1 <= k && k <= m+n);
315.1405 +#endif
315.1406 +      if (type[k] == GLP_DB)
315.1407 +      {  /* xN[q] has both lower and upper bounds */
315.1408 +         p = -1, p_stat = 0, teta = ub[k] - lb[k], big = 1.0;
315.1409 +      }
315.1410 +      else
315.1411 +      {  /* xN[q] has no opposite bound */
315.1412 +         p = 0, p_stat = 0, teta = DBL_MAX, big = 0.0;
315.1413 +      }
315.1414 +      /* walk through significant elements of the pivot column */
315.1415 +      for (pos = 1; pos <= tcol_num; pos++)
315.1416 +      {  i = tcol_ind[pos];
315.1417 +#ifdef GLP_DEBUG
315.1418 +         xassert(1 <= i && i <= m);
315.1419 +#endif
315.1420 +         k = head[i]; /* x[k] = xB[i] */
315.1421 +#ifdef GLP_DEBUG
315.1422 +         xassert(1 <= k && k <= m+n);
315.1423 +#endif
315.1424 +         alfa = s * tcol_vec[i];
315.1425 +#ifdef GLP_DEBUG
315.1426 +         xassert(alfa != 0.0);
315.1427 +#endif
315.1428 +         /* xB[i] = ... + alfa * xN[q] + ..., and due to s we need to
315.1429 +            consider the only case when xN[q] is increasing */
315.1430 +         if (alfa > 0.0)
315.1431 +         {  /* xB[i] is increasing */
315.1432 +            if (phase == 1 && coef[k] < 0.0)
315.1433 +            {  /* xB[i] violates its lower bound, which plays the role
315.1434 +                  of an upper bound on phase I */
315.1435 +               delta = rtol * (1.0 + kappa * fabs(lb[k]));
315.1436 +               t = ((lb[k] + delta) - bbar[i]) / alfa;
315.1437 +               i_stat = GLP_NL;
315.1438 +            }
315.1439 +            else if (phase == 1 && coef[k] > 0.0)
315.1440 +            {  /* xB[i] violates its upper bound, which plays the role
315.1441 +                  of an lower bound on phase I */
315.1442 +               continue;
315.1443 +            }
315.1444 +            else if (type[k] == GLP_UP || type[k] == GLP_DB ||
315.1445 +                     type[k] == GLP_FX)
315.1446 +            {  /* xB[i] is within its bounds and has an upper bound */
315.1447 +               delta = rtol * (1.0 + kappa * fabs(ub[k]));
315.1448 +               t = ((ub[k] + delta) - bbar[i]) / alfa;
315.1449 +               i_stat = GLP_NU;
315.1450 +            }
315.1451 +            else
315.1452 +            {  /* xB[i] is within its bounds and has no upper bound */
315.1453 +               continue;
315.1454 +            }
315.1455 +         }
315.1456 +         else
315.1457 +         {  /* xB[i] is decreasing */
315.1458 +            if (phase == 1 && coef[k] > 0.0)
315.1459 +            {  /* xB[i] violates its upper bound, which plays the role
315.1460 +                  of an lower bound on phase I */
315.1461 +               delta = rtol * (1.0 + kappa * fabs(ub[k]));
315.1462 +               t = ((ub[k] - delta) - bbar[i]) / alfa;
315.1463 +               i_stat = GLP_NU;
315.1464 +            }
315.1465 +            else if (phase == 1 && coef[k] < 0.0)
315.1466 +            {  /* xB[i] violates its lower bound, which plays the role
315.1467 +                  of an upper bound on phase I */
315.1468 +               continue;
315.1469 +            }
315.1470 +            else if (type[k] == GLP_LO || type[k] == GLP_DB ||
315.1471 +                     type[k] == GLP_FX)
315.1472 +            {  /* xB[i] is within its bounds and has an lower bound */
315.1473 +               delta = rtol * (1.0 + kappa * fabs(lb[k]));
315.1474 +               t = ((lb[k] - delta) - bbar[i]) / alfa;
315.1475 +               i_stat = GLP_NL;
315.1476 +            }
315.1477 +            else
315.1478 +            {  /* xB[i] is within its bounds and has no lower bound */
315.1479 +               continue;
315.1480 +            }
315.1481 +         }
315.1482 +         /* t is a change of xN[q], on which xB[i] reaches its bound
315.1483 +            (possibly relaxed); since the basic solution is assumed to
315.1484 +            be primal feasible (or pseudo feasible on phase I), t has
315.1485 +            to be non-negative by definition; however, it may happen
315.1486 +            that xB[i] slightly (i.e. within a tolerance) violates its
315.1487 +            bound, that leads to negative t; in the latter case, if
315.1488 +            xB[i] is chosen, negative t means that xN[q] changes in
315.1489 +            wrong direction; if pivot alfa[i,q] is close to zero, even
315.1490 +            small bound violation of xB[i] may lead to a large change
315.1491 +            of xN[q] in wrong direction; let, for example, xB[i] >= 0
315.1492 +            and in the current basis its value be -5e-9; let also xN[q]
315.1493 +            be on its zero bound and should increase; from the ratio
315.1494 +            test rule it follows that the pivot alfa[i,q] < 0; however,
315.1495 +            if alfa[i,q] is, say, -1e-9, the change of xN[q] in wrong
315.1496 +            direction is 5e-9 / (-1e-9) = -5, and using it for updating
315.1497 +            values of other basic variables will give absolutely wrong
315.1498 +            results; therefore, if t is negative, we should replace it
315.1499 +            by exact zero assuming that xB[i] is exactly on its bound,
315.1500 +            and the violation appears due to round-off errors */
315.1501 +         if (t < 0.0) t = 0.0;
315.1502 +         /* apply minimal ratio test */
315.1503 +         if (teta > t || teta == t && big < fabs(alfa))
315.1504 +            p = i, p_stat = i_stat, teta = t, big = fabs(alfa);
315.1505 +      }
315.1506 +      /* the second pass is skipped in the following cases: */
315.1507 +      /* if the standard ratio test is used */
315.1508 +      if (rtol == 0.0) goto done;
315.1509 +      /* if xN[q] reaches its opposite bound or if no basic variable
315.1510 +         has been chosen on the first pass */
315.1511 +      if (p <= 0) goto done;
315.1512 +      /* if xB[p] is a blocking variable, i.e. if it prevents xN[q]
315.1513 +         from any change */
315.1514 +      if (teta == 0.0) goto done;
315.1515 +      /*** SECOND PASS ***/
315.1516 +      /* here tmax is a maximal change of xN[q], on which the solution
315.1517 +         remains primal feasible (or pseudo feasible on phase I) within
315.1518 +         a tolerance */
315.1519 +#if 0
315.1520 +      tmax = (1.0 + 10.0 * DBL_EPSILON) * teta;
315.1521 +#else
315.1522 +      tmax = teta;
315.1523 +#endif
315.1524 +      /* nothing is chosen so far */
315.1525 +      p = 0, p_stat = 0, teta = DBL_MAX, big = 0.0;
315.1526 +      /* walk through significant elements of the pivot column */
315.1527 +      for (pos = 1; pos <= tcol_num; pos++)
315.1528 +      {  i = tcol_ind[pos];
315.1529 +#ifdef GLP_DEBUG
315.1530 +         xassert(1 <= i && i <= m);
315.1531 +#endif
315.1532 +         k = head[i]; /* x[k] = xB[i] */
315.1533 +#ifdef GLP_DEBUG
315.1534 +         xassert(1 <= k && k <= m+n);
315.1535 +#endif
315.1536 +         alfa = s * tcol_vec[i];
315.1537 +#ifdef GLP_DEBUG
315.1538 +         xassert(alfa != 0.0);
315.1539 +#endif
315.1540 +         /* xB[i] = ... + alfa * xN[q] + ..., and due to s we need to
315.1541 +            consider the only case when xN[q] is increasing */
315.1542 +         if (alfa > 0.0)
315.1543 +         {  /* xB[i] is increasing */
315.1544 +            if (phase == 1 && coef[k] < 0.0)
315.1545 +            {  /* xB[i] violates its lower bound, which plays the role
315.1546 +                  of an upper bound on phase I */
315.1547 +               t = (lb[k] - bbar[i]) / alfa;
315.1548 +               i_stat = GLP_NL;
315.1549 +            }
315.1550 +            else if (phase == 1 && coef[k] > 0.0)
315.1551 +            {  /* xB[i] violates its upper bound, which plays the role
315.1552 +                  of an lower bound on phase I */
315.1553 +               continue;
315.1554 +            }
315.1555 +            else if (type[k] == GLP_UP || type[k] == GLP_DB ||
315.1556 +                     type[k] == GLP_FX)
315.1557 +            {  /* xB[i] is within its bounds and has an upper bound */
315.1558 +               t = (ub[k] - bbar[i]) / alfa;
315.1559 +               i_stat = GLP_NU;
315.1560 +            }
315.1561 +            else
315.1562 +            {  /* xB[i] is within its bounds and has no upper bound */
315.1563 +               continue;
315.1564 +            }
315.1565 +         }
315.1566 +         else
315.1567 +         {  /* xB[i] is decreasing */
315.1568 +            if (phase == 1 && coef[k] > 0.0)
315.1569 +            {  /* xB[i] violates its upper bound, which plays the role
315.1570 +                  of an lower bound on phase I */
315.1571 +               t = (ub[k] - bbar[i]) / alfa;
315.1572 +               i_stat = GLP_NU;
315.1573 +            }
315.1574 +            else if (phase == 1 && coef[k] < 0.0)
315.1575 +            {  /* xB[i] violates its lower bound, which plays the role
315.1576 +                  of an upper bound on phase I */
315.1577 +               continue;
315.1578 +            }
315.1579 +            else if (type[k] == GLP_LO || type[k] == GLP_DB ||
315.1580 +                     type[k] == GLP_FX)
315.1581 +            {  /* xB[i] is within its bounds and has an lower bound */
315.1582 +               t = (lb[k] - bbar[i]) / alfa;
315.1583 +               i_stat = GLP_NL;
315.1584 +            }
315.1585 +            else
315.1586 +            {  /* xB[i] is within its bounds and has no lower bound */
315.1587 +               continue;
315.1588 +            }
315.1589 +         }
315.1590 +         /* (see comments for the first pass) */
315.1591 +         if (t < 0.0) t = 0.0;
315.1592 +         /* t is a change of xN[q], on which xB[i] reaches its bound;
315.1593 +            if t <= tmax, all basic variables can violate their bounds
315.1594 +            only within relaxation tolerance delta; we can use this
315.1595 +            freedom and choose basic variable having largest influence
315.1596 +            coefficient to avoid possible numeric instability */
315.1597 +         if (t <= tmax && big < fabs(alfa))
315.1598 +            p = i, p_stat = i_stat, teta = t, big = fabs(alfa);
315.1599 +      }
315.1600 +      /* something must be chosen on the second pass */
315.1601 +      xassert(p != 0);
315.1602 +done: /* store the index and status of basic variable xB[p] chosen */
315.1603 +      csa->p = p;
315.1604 +      if (p > 0 && type[head[p]] == GLP_FX)
315.1605 +         csa->p_stat = GLP_NS;
315.1606 +      else
315.1607 +         csa->p_stat = p_stat;
315.1608 +      /* store corresponding change of non-basic variable xN[q] */
315.1609 +#ifdef GLP_DEBUG
315.1610 +      xassert(teta >= 0.0);
315.1611 +#endif
315.1612 +      csa->teta = s * teta;
315.1613 +      return;
315.1614 +}
315.1615 +
315.1616 +/***********************************************************************
315.1617 +*  eval_rho - compute pivot row of the inverse
315.1618 +*
315.1619 +*  This routine computes the pivot (p-th) row of the inverse inv(B),
315.1620 +*  which corresponds to basic variable xB[p] chosen:
315.1621 +*
315.1622 +*     rho = inv(B') * e[p],
315.1623 +*
315.1624 +*  where B' is a matrix transposed to the current basis matrix, e[p]
315.1625 +*  is unity vector. */
315.1626 +
315.1627 +static void eval_rho(struct csa *csa, double rho[])
315.1628 +{     int m = csa->m;
315.1629 +      int p = csa->p;
315.1630 +      double *e = rho;
315.1631 +      int i;
315.1632 +#ifdef GLP_DEBUG
315.1633 +      xassert(1 <= p && p <= m);
315.1634 +#endif
315.1635 +      /* construct the right-hand side vector e[p] */
315.1636 +      for (i = 1; i <= m; i++)
315.1637 +         e[i] = 0.0;
315.1638 +      e[p] = 1.0;
315.1639 +      /* solve system B'* rho = e[p] */
315.1640 +      xassert(csa->valid);
315.1641 +      bfd_btran(csa->bfd, rho);
315.1642 +      return;
315.1643 +}
315.1644 +
315.1645 +/***********************************************************************
315.1646 +*  refine_rho - refine pivot row of the inverse
315.1647 +*
315.1648 +*  This routine refines the pivot row of the inverse inv(B) assuming
315.1649 +*  that it was previously computed by the routine eval_rho. */
315.1650 +
315.1651 +static void refine_rho(struct csa *csa, double rho[])
315.1652 +{     int m = csa->m;
315.1653 +      int p = csa->p;
315.1654 +      double *e = csa->work3;
315.1655 +      int i;
315.1656 +#ifdef GLP_DEBUG
315.1657 +      xassert(1 <= p && p <= m);
315.1658 +#endif
315.1659 +      /* construct the right-hand side vector e[p] */
315.1660 +      for (i = 1; i <= m; i++)
315.1661 +         e[i] = 0.0;
315.1662 +      e[p] = 1.0;
315.1663 +      /* refine solution of B'* rho = e[p] */
315.1664 +      refine_btran(csa, e, rho);
315.1665 +      return;
315.1666 +}
315.1667 +
315.1668 +/***********************************************************************
315.1669 +*  eval_trow - compute pivot row of the simplex table
315.1670 +*
315.1671 +*  This routine computes the pivot row of the simplex table, which
315.1672 +*  corresponds to basic variable xB[p] chosen.
315.1673 +*
315.1674 +*  The pivot row is the following vector:
315.1675 +*
315.1676 +*     trow = T'* e[p] = - N'* inv(B') * e[p] = - N' * rho,
315.1677 +*
315.1678 +*  where rho is the pivot row of the inverse inv(B) previously computed
315.1679 +*  by the routine eval_rho.
315.1680 +*
315.1681 +*  Note that elements of the pivot row corresponding to fixed non-basic
315.1682 +*  variables are not computed. */
315.1683 +
315.1684 +static void eval_trow(struct csa *csa, double rho[])
315.1685 +{     int m = csa->m;
315.1686 +      int n = csa->n;
315.1687 +#ifdef GLP_DEBUG
315.1688 +      char *stat = csa->stat;
315.1689 +#endif
315.1690 +      int *N_ptr = csa->N_ptr;
315.1691 +      int *N_len = csa->N_len;
315.1692 +      int *N_ind = csa->N_ind;
315.1693 +      double *N_val = csa->N_val;
315.1694 +      int *trow_ind = csa->trow_ind;
315.1695 +      double *trow_vec = csa->trow_vec;
315.1696 +      int i, j, beg, end, ptr, nnz;
315.1697 +      double temp;
315.1698 +      /* clear the pivot row */
315.1699 +      for (j = 1; j <= n; j++)
315.1700 +         trow_vec[j] = 0.0;
315.1701 +      /* compute the pivot row as a linear combination of rows of the
315.1702 +         matrix N: trow = - rho[1] * N'[1] - ... - rho[m] * N'[m] */
315.1703 +      for (i = 1; i <= m; i++)
315.1704 +      {  temp = rho[i];
315.1705 +         if (temp == 0.0) continue;
315.1706 +         /* trow := trow - rho[i] * N'[i] */
315.1707 +         beg = N_ptr[i];
315.1708 +         end = beg + N_len[i];
315.1709 +         for (ptr = beg; ptr < end; ptr++)
315.1710 +         {
315.1711 +#ifdef GLP_DEBUG
315.1712 +            j = N_ind[ptr];
315.1713 +            xassert(1 <= j && j <= n);
315.1714 +            xassert(stat[j] != GLP_NS);
315.1715 +#endif
315.1716 +            trow_vec[N_ind[ptr]] -= temp * N_val[ptr];
315.1717 +         }
315.1718 +      }
315.1719 +      /* construct sparse pattern of the pivot row */
315.1720 +      nnz = 0;
315.1721 +      for (j = 1; j <= n; j++)
315.1722 +      {  if (trow_vec[j] != 0.0)
315.1723 +            trow_ind[++nnz] = j;
315.1724 +      }
315.1725 +      csa->trow_nnz = nnz;
315.1726 +      return;
315.1727 +}
315.1728 +
315.1729 +/***********************************************************************
315.1730 +*  update_bbar - update values of basic variables
315.1731 +*
315.1732 +*  This routine updates values of all basic variables for the adjacent
315.1733 +*  basis. */
315.1734 +
315.1735 +static void update_bbar(struct csa *csa)
315.1736 +{
315.1737 +#ifdef GLP_DEBUG
315.1738 +      int m = csa->m;
315.1739 +      int n = csa->n;
315.1740 +#endif
315.1741 +      double *bbar = csa->bbar;
315.1742 +      int q = csa->q;
315.1743 +      int tcol_nnz = csa->tcol_nnz;
315.1744 +      int *tcol_ind = csa->tcol_ind;
315.1745 +      double *tcol_vec = csa->tcol_vec;
315.1746 +      int p = csa->p;
315.1747 +      double teta = csa->teta;
315.1748 +      int i, pos;
315.1749 +#ifdef GLP_DEBUG
315.1750 +      xassert(1 <= q && q <= n);
315.1751 +      xassert(p < 0 || 1 <= p && p <= m);
315.1752 +#endif
315.1753 +      /* if xN[q] leaves the basis, compute its value in the adjacent
315.1754 +         basis, where it will replace xB[p] */
315.1755 +      if (p > 0)
315.1756 +         bbar[p] = get_xN(csa, q) + teta;
315.1757 +      /* update values of other basic variables (except xB[p], because
315.1758 +         it will be replaced by xN[q]) */
315.1759 +      if (teta == 0.0) goto done;
315.1760 +      for (pos = 1; pos <= tcol_nnz; pos++)
315.1761 +      {  i = tcol_ind[pos];
315.1762 +         /* skip xB[p] */
315.1763 +         if (i == p) continue;
315.1764 +         /* (change of xB[i]) = alfa[i,q] * (change of xN[q]) */
315.1765 +         bbar[i] += tcol_vec[i] * teta;
315.1766 +      }
315.1767 +done: return;
315.1768 +}
315.1769 +
315.1770 +/***********************************************************************
315.1771 +*  reeval_cost - recompute reduced cost of non-basic variable xN[q]
315.1772 +*
315.1773 +*  This routine recomputes reduced cost of non-basic variable xN[q] for
315.1774 +*  the current basis more accurately using its direct definition:
315.1775 +*
315.1776 +*     d[q] = cN[q] - N'[q] * pi =
315.1777 +*
315.1778 +*          = cN[q] - N'[q] * (inv(B') * cB) =
315.1779 +*
315.1780 +*          = cN[q] - (cB' * inv(B) * N[q]) =
315.1781 +*
315.1782 +*          = cN[q] + cB' * (pivot column).
315.1783 +*
315.1784 +*  It is assumed that the pivot column of the simplex table is already
315.1785 +*  computed. */
315.1786 +
315.1787 +static double reeval_cost(struct csa *csa)
315.1788 +{     int m = csa->m;
315.1789 +#ifdef GLP_DEBUG
315.1790 +      int n = csa->n;
315.1791 +#endif
315.1792 +      double *coef = csa->coef;
315.1793 +      int *head = csa->head;
315.1794 +      int q = csa->q;
315.1795 +      int tcol_nnz = csa->tcol_nnz;
315.1796 +      int *tcol_ind = csa->tcol_ind;
315.1797 +      double *tcol_vec = csa->tcol_vec;
315.1798 +      int i, pos;
315.1799 +      double dq;
315.1800 +#ifdef GLP_DEBUG
315.1801 +      xassert(1 <= q && q <= n);
315.1802 +#endif
315.1803 +      dq = coef[head[m+q]];
315.1804 +      for (pos = 1; pos <= tcol_nnz; pos++)
315.1805 +      {  i = tcol_ind[pos];
315.1806 +#ifdef GLP_DEBUG
315.1807 +         xassert(1 <= i && i <= m);
315.1808 +#endif
315.1809 +         dq += coef[head[i]] * tcol_vec[i];
315.1810 +      }
315.1811 +      return dq;
315.1812 +}
315.1813 +
315.1814 +/***********************************************************************
315.1815 +*  update_cbar - update reduced costs of non-basic variables
315.1816 +*
315.1817 +*  This routine updates reduced costs of all (except fixed) non-basic
315.1818 +*  variables for the adjacent basis. */
315.1819 +
315.1820 +static void update_cbar(struct csa *csa)
315.1821 +{
315.1822 +#ifdef GLP_DEBUG
315.1823 +      int n = csa->n;
315.1824 +#endif
315.1825 +      double *cbar = csa->cbar;
315.1826 +      int q = csa->q;
315.1827 +      int trow_nnz = csa->trow_nnz;
315.1828 +      int *trow_ind = csa->trow_ind;
315.1829 +      double *trow_vec = csa->trow_vec;
315.1830 +      int j, pos;
315.1831 +      double new_dq;
315.1832 +#ifdef GLP_DEBUG
315.1833 +      xassert(1 <= q && q <= n);
315.1834 +#endif
315.1835 +      /* compute reduced cost of xB[p] in the adjacent basis, where it
315.1836 +         will replace xN[q] */
315.1837 +#ifdef GLP_DEBUG
315.1838 +      xassert(trow_vec[q] != 0.0);
315.1839 +#endif
315.1840 +      new_dq = (cbar[q] /= trow_vec[q]);
315.1841 +      /* update reduced costs of other non-basic variables (except
315.1842 +         xN[q], because it will be replaced by xB[p]) */
315.1843 +      for (pos = 1; pos <= trow_nnz; pos++)
315.1844 +      {  j = trow_ind[pos];
315.1845 +         /* skip xN[q] */
315.1846 +         if (j == q) continue;
315.1847 +         cbar[j] -= trow_vec[j] * new_dq;
315.1848 +      }
315.1849 +      return;
315.1850 +}
315.1851 +
315.1852 +/***********************************************************************
315.1853 +*  update_gamma - update steepest edge coefficients
315.1854 +*
315.1855 +*  This routine updates steepest-edge coefficients for the adjacent
315.1856 +*  basis. */
315.1857 +
315.1858 +static void update_gamma(struct csa *csa)
315.1859 +{     int m = csa->m;
315.1860 +#ifdef GLP_DEBUG
315.1861 +      int n = csa->n;
315.1862 +#endif
315.1863 +      char *type = csa->type;
315.1864 +      int *A_ptr = csa->A_ptr;
315.1865 +      int *A_ind = csa->A_ind;
315.1866 +      double *A_val = csa->A_val;
315.1867 +      int *head = csa->head;
315.1868 +      char *refsp = csa->refsp;
315.1869 +      double *gamma = csa->gamma;
315.1870 +      int q = csa->q;
315.1871 +      int tcol_nnz = csa->tcol_nnz;
315.1872 +      int *tcol_ind = csa->tcol_ind;
315.1873 +      double *tcol_vec = csa->tcol_vec;
315.1874 +      int p = csa->p;
315.1875 +      int trow_nnz = csa->trow_nnz;
315.1876 +      int *trow_ind = csa->trow_ind;
315.1877 +      double *trow_vec = csa->trow_vec;
315.1878 +      double *u = csa->work3;
315.1879 +      int i, j, k, pos, beg, end, ptr;
315.1880 +      double gamma_q, delta_q, pivot, s, t, t1, t2;
315.1881 +#ifdef GLP_DEBUG
315.1882 +      xassert(1 <= p && p <= m);
315.1883 +      xassert(1 <= q && q <= n);
315.1884 +#endif
315.1885 +      /* the basis changes, so decrease the count */
315.1886 +      xassert(csa->refct > 0);
315.1887 +      csa->refct--;
315.1888 +      /* recompute gamma[q] for the current basis more accurately and
315.1889 +         compute auxiliary vector u */
315.1890 +      gamma_q = delta_q = (refsp[head[m+q]] ? 1.0 : 0.0);
315.1891 +      for (i = 1; i <= m; i++) u[i] = 0.0;
315.1892 +      for (pos = 1; pos <= tcol_nnz; pos++)
315.1893 +      {  i = tcol_ind[pos];
315.1894 +         if (refsp[head[i]])
315.1895 +         {  u[i] = t = tcol_vec[i];
315.1896 +            gamma_q += t * t;
315.1897 +         }
315.1898 +         else
315.1899 +            u[i] = 0.0;
315.1900 +      }
315.1901 +      xassert(csa->valid);
315.1902 +      bfd_btran(csa->bfd, u);
315.1903 +      /* update gamma[k] for other non-basic variables (except fixed
315.1904 +         variables and xN[q], because it will be replaced by xB[p]) */
315.1905 +      pivot = trow_vec[q];
315.1906 +#ifdef GLP_DEBUG
315.1907 +      xassert(pivot != 0.0);
315.1908 +#endif
315.1909 +      for (pos = 1; pos <= trow_nnz; pos++)
315.1910 +      {  j = trow_ind[pos];
315.1911 +         /* skip xN[q] */
315.1912 +         if (j == q) continue;
315.1913 +         /* compute t */
315.1914 +         t = trow_vec[j] / pivot;
315.1915 +         /* compute inner product s = N'[j] * u */
315.1916 +         k = head[m+j]; /* x[k] = xN[j] */
315.1917 +         if (k <= m)
315.1918 +            s = u[k];
315.1919 +         else
315.1920 +         {  s = 0.0;
315.1921 +            beg = A_ptr[k-m];
315.1922 +            end = A_ptr[k-m+1];
315.1923 +            for (ptr = beg; ptr < end; ptr++)
315.1924 +               s -= A_val[ptr] * u[A_ind[ptr]];
315.1925 +         }
315.1926 +         /* compute gamma[k] for the adjacent basis */
315.1927 +         t1 = gamma[j] + t * t * gamma_q + 2.0 * t * s;
315.1928 +         t2 = (refsp[k] ? 1.0 : 0.0) + delta_q * t * t;
315.1929 +         gamma[j] = (t1 >= t2 ? t1 : t2);
315.1930 +         if (gamma[j] < DBL_EPSILON) gamma[j] = DBL_EPSILON;
315.1931 +      }
315.1932 +      /* compute gamma[q] for the adjacent basis */
315.1933 +      if (type[head[p]] == GLP_FX)
315.1934 +         gamma[q] = 1.0;
315.1935 +      else
315.1936 +      {  gamma[q] = gamma_q / (pivot * pivot);
315.1937 +         if (gamma[q] < DBL_EPSILON) gamma[q] = DBL_EPSILON;
315.1938 +      }
315.1939 +      return;
315.1940 +}
315.1941 +
315.1942 +/***********************************************************************
315.1943 +*  err_in_bbar - compute maximal relative error in primal solution
315.1944 +*
315.1945 +*  This routine returns maximal relative error:
315.1946 +*
315.1947 +*     max |beta[i] - bbar[i]| / (1 + |beta[i]|),
315.1948 +*
315.1949 +*  where beta and bbar are, respectively, directly computed and the
315.1950 +*  current (updated) values of basic variables.
315.1951 +*
315.1952 +*  NOTE: The routine is intended only for debugginig purposes. */
315.1953 +
315.1954 +static double err_in_bbar(struct csa *csa)
315.1955 +{     int m = csa->m;
315.1956 +      double *bbar = csa->bbar;
315.1957 +      int i;
315.1958 +      double e, emax, *beta;
315.1959 +      beta = xcalloc(1+m, sizeof(double));
315.1960 +      eval_beta(csa, beta);
315.1961 +      emax = 0.0;
315.1962 +      for (i = 1; i <= m; i++)
315.1963 +      {  e = fabs(beta[i] - bbar[i]) / (1.0 + fabs(beta[i]));
315.1964 +         if (emax < e) emax = e;
315.1965 +      }
315.1966 +      xfree(beta);
315.1967 +      return emax;
315.1968 +}
315.1969 +
315.1970 +/***********************************************************************
315.1971 +*  err_in_cbar - compute maximal relative error in dual solution
315.1972 +*
315.1973 +*  This routine returns maximal relative error:
315.1974 +*
315.1975 +*     max |cost[j] - cbar[j]| / (1 + |cost[j]|),
315.1976 +*
315.1977 +*  where cost and cbar are, respectively, directly computed and the
315.1978 +*  current (updated) reduced costs of non-basic non-fixed variables.
315.1979 +*
315.1980 +*  NOTE: The routine is intended only for debugginig purposes. */
315.1981 +
315.1982 +static double err_in_cbar(struct csa *csa)
315.1983 +{     int m = csa->m;
315.1984 +      int n = csa->n;
315.1985 +      char *stat = csa->stat;
315.1986 +      double *cbar = csa->cbar;
315.1987 +      int j;
315.1988 +      double e, emax, cost, *pi;
315.1989 +      pi = xcalloc(1+m, sizeof(double));
315.1990 +      eval_pi(csa, pi);
315.1991 +      emax = 0.0;
315.1992 +      for (j = 1; j <= n; j++)
315.1993 +      {  if (stat[j] == GLP_NS) continue;
315.1994 +         cost = eval_cost(csa, pi, j);
315.1995 +         e = fabs(cost - cbar[j]) / (1.0 + fabs(cost));
315.1996 +         if (emax < e) emax = e;
315.1997 +      }
315.1998 +      xfree(pi);
315.1999 +      return emax;
315.2000 +}
315.2001 +
315.2002 +/***********************************************************************
315.2003 +*  err_in_gamma - compute maximal relative error in steepest edge cff.
315.2004 +*
315.2005 +*  This routine returns maximal relative error:
315.2006 +*
315.2007 +*     max |gamma'[j] - gamma[j]| / (1 + |gamma'[j]),
315.2008 +*
315.2009 +*  where gamma'[j] and gamma[j] are, respectively, directly computed
315.2010 +*  and the current (updated) steepest edge coefficients for non-basic
315.2011 +*  non-fixed variable x[j].
315.2012 +*
315.2013 +*  NOTE: The routine is intended only for debugginig purposes. */
315.2014 +
315.2015 +static double err_in_gamma(struct csa *csa)
315.2016 +{     int n = csa->n;
315.2017 +      char *stat = csa->stat;
315.2018 +      double *gamma = csa->gamma;
315.2019 +      int j;
315.2020 +      double e, emax, temp;
315.2021 +      emax = 0.0;
315.2022 +      for (j = 1; j <= n; j++)
315.2023 +      {  if (stat[j] == GLP_NS)
315.2024 +         {  xassert(gamma[j] == 1.0);
315.2025 +            continue;
315.2026 +         }
315.2027 +         temp = eval_gamma(csa, j);
315.2028 +         e = fabs(temp - gamma[j]) / (1.0 + fabs(temp));
315.2029 +         if (emax < e) emax = e;
315.2030 +      }
315.2031 +      return emax;
315.2032 +}
315.2033 +
315.2034 +/***********************************************************************
315.2035 +*  change_basis - change basis header
315.2036 +*
315.2037 +*  This routine changes the basis header to make it corresponding to
315.2038 +*  the adjacent basis. */
315.2039 +
315.2040 +static void change_basis(struct csa *csa)
315.2041 +{     int m = csa->m;
315.2042 +#ifdef GLP_DEBUG
315.2043 +      int n = csa->n;
315.2044 +      char *type = csa->type;
315.2045 +#endif
315.2046 +      int *head = csa->head;
315.2047 +      char *stat = csa->stat;
315.2048 +      int q = csa->q;
315.2049 +      int p = csa->p;
315.2050 +      int p_stat = csa->p_stat;
315.2051 +      int k;
315.2052 +#ifdef GLP_DEBUG
315.2053 +      xassert(1 <= q && q <= n);
315.2054 +#endif
315.2055 +      if (p < 0)
315.2056 +      {  /* xN[q] goes to its opposite bound */
315.2057 +#ifdef GLP_DEBUG
315.2058 +         k = head[m+q]; /* x[k] = xN[q] */
315.2059 +         xassert(1 <= k && k <= m+n);
315.2060 +         xassert(type[k] == GLP_DB);
315.2061 +#endif
315.2062 +         switch (stat[q])
315.2063 +         {  case GLP_NL:
315.2064 +               /* xN[q] increases */
315.2065 +               stat[q] = GLP_NU;
315.2066 +               break;
315.2067 +            case GLP_NU:
315.2068 +               /* xN[q] decreases */
315.2069 +               stat[q] = GLP_NL;
315.2070 +               break;
315.2071 +            default:
315.2072 +               xassert(stat != stat);
315.2073 +         }
315.2074 +      }
315.2075 +      else
315.2076 +      {  /* xB[p] leaves the basis, xN[q] enters the basis */
315.2077 +#ifdef GLP_DEBUG
315.2078 +         xassert(1 <= p && p <= m);
315.2079 +         k = head[p]; /* x[k] = xB[p] */
315.2080 +         switch (p_stat)
315.2081 +         {  case GLP_NL:
315.2082 +               /* xB[p] goes to its lower bound */
315.2083 +               xassert(type[k] == GLP_LO || type[k] == GLP_DB);
315.2084 +               break;
315.2085 +            case GLP_NU:
315.2086 +               /* xB[p] goes to its upper bound */
315.2087 +               xassert(type[k] == GLP_UP || type[k] == GLP_DB);
315.2088 +               break;
315.2089 +            case GLP_NS:
315.2090 +               /* xB[p] goes to its fixed value */
315.2091 +               xassert(type[k] == GLP_NS);
315.2092 +               break;
315.2093 +            default:
315.2094 +               xassert(p_stat != p_stat);
315.2095 +         }
315.2096 +#endif
315.2097 +         /* xB[p] <-> xN[q] */
315.2098 +         k = head[p], head[p] = head[m+q], head[m+q] = k;
315.2099 +         stat[q] = (char)p_stat;
315.2100 +      }
315.2101 +      return;
315.2102 +}
315.2103 +
315.2104 +/***********************************************************************
315.2105 +*  set_aux_obj - construct auxiliary objective function
315.2106 +*
315.2107 +*  The auxiliary objective function is a separable piecewise linear
315.2108 +*  convex function, which is the sum of primal infeasibilities:
315.2109 +*
315.2110 +*     z = t[1] + ... + t[m+n] -> minimize,
315.2111 +*
315.2112 +*  where:
315.2113 +*
315.2114 +*            / lb[k] - x[k], if x[k] < lb[k]
315.2115 +*            |
315.2116 +*     t[k] = <  0, if lb[k] <= x[k] <= ub[k]
315.2117 +*            |
315.2118 +*            \ x[k] - ub[k], if x[k] > ub[k]
315.2119 +*
315.2120 +*  This routine computes objective coefficients for the current basis
315.2121 +*  and returns the number of non-zero terms t[k]. */
315.2122 +
315.2123 +static int set_aux_obj(struct csa *csa, double tol_bnd)
315.2124 +{     int m = csa->m;
315.2125 +      int n = csa->n;
315.2126 +      char *type = csa->type;
315.2127 +      double *lb = csa->lb;
315.2128 +      double *ub = csa->ub;
315.2129 +      double *coef = csa->coef;
315.2130 +      int *head = csa->head;
315.2131 +      double *bbar = csa->bbar;
315.2132 +      int i, k, cnt = 0;
315.2133 +      double eps;
315.2134 +      /* use a bit more restrictive tolerance */
315.2135 +      tol_bnd *= 0.90;
315.2136 +      /* clear all objective coefficients */
315.2137 +      for (k = 1; k <= m+n; k++)
315.2138 +         coef[k] = 0.0;
315.2139 +      /* walk through the list of basic variables */
315.2140 +      for (i = 1; i <= m; i++)
315.2141 +      {  k = head[i]; /* x[k] = xB[i] */
315.2142 +         if (type[k] == GLP_LO || type[k] == GLP_DB ||
315.2143 +             type[k] == GLP_FX)
315.2144 +         {  /* x[k] has lower bound */
315.2145 +            eps = tol_bnd * (1.0 + kappa * fabs(lb[k]));
315.2146 +            if (bbar[i] < lb[k] - eps)
315.2147 +            {  /* and violates it */
315.2148 +               coef[k] = -1.0;
315.2149 +               cnt++;
315.2150 +            }
315.2151 +         }
315.2152 +         if (type[k] == GLP_UP || type[k] == GLP_DB ||
315.2153 +             type[k] == GLP_FX)
315.2154 +         {  /* x[k] has upper bound */
315.2155 +            eps = tol_bnd * (1.0 + kappa * fabs(ub[k]));
315.2156 +            if (bbar[i] > ub[k] + eps)
315.2157 +            {  /* and violates it */
315.2158 +               coef[k] = +1.0;
315.2159 +               cnt++;
315.2160 +            }
315.2161 +         }
315.2162 +      }
315.2163 +      return cnt;
315.2164 +}
315.2165 +
315.2166 +/***********************************************************************
315.2167 +*  set_orig_obj - restore original objective function
315.2168 +*
315.2169 +*  This routine assigns scaled original objective coefficients to the
315.2170 +*  working objective function. */
315.2171 +
315.2172 +static void set_orig_obj(struct csa *csa)
315.2173 +{     int m = csa->m;
315.2174 +      int n = csa->n;
315.2175 +      double *coef = csa->coef;
315.2176 +      double *obj = csa->obj;
315.2177 +      double zeta = csa->zeta;
315.2178 +      int i, j;
315.2179 +      for (i = 1; i <= m; i++)
315.2180 +         coef[i] = 0.0;
315.2181 +      for (j = 1; j <= n; j++)
315.2182 +         coef[m+j] = zeta * obj[j];
315.2183 +      return;
315.2184 +}
315.2185 +
315.2186 +/***********************************************************************
315.2187 +*  check_stab - check numerical stability of basic solution
315.2188 +*
315.2189 +*  If the current basic solution is primal feasible (or pseudo feasible
315.2190 +*  on phase I) within a tolerance, this routine returns zero, otherwise
315.2191 +*  it returns non-zero. */
315.2192 +
315.2193 +static int check_stab(struct csa *csa, double tol_bnd)
315.2194 +{     int m = csa->m;
315.2195 +#ifdef GLP_DEBUG
315.2196 +      int n = csa->n;
315.2197 +#endif
315.2198 +      char *type = csa->type;
315.2199 +      double *lb = csa->lb;
315.2200 +      double *ub = csa->ub;
315.2201 +      double *coef = csa->coef;
315.2202 +      int *head = csa->head;
315.2203 +      int phase = csa->phase;
315.2204 +      double *bbar = csa->bbar;
315.2205 +      int i, k;
315.2206 +      double eps;
315.2207 +      /* walk through the list of basic variables */
315.2208 +      for (i = 1; i <= m; i++)
315.2209 +      {  k = head[i]; /* x[k] = xB[i] */
315.2210 +#ifdef GLP_DEBUG
315.2211 +         xassert(1 <= k && k <= m+n);
315.2212 +#endif
315.2213 +         if (phase == 1 && coef[k] < 0.0)
315.2214 +         {  /* x[k] must not be greater than its lower bound */
315.2215 +#ifdef GLP_DEBUG
315.2216 +            xassert(type[k] == GLP_LO || type[k] == GLP_DB ||
315.2217 +                    type[k] == GLP_FX);
315.2218 +#endif
315.2219 +            eps = tol_bnd * (1.0 + kappa * fabs(lb[k]));
315.2220 +            if (bbar[i] > lb[k] + eps) return 1;
315.2221 +         }
315.2222 +         else if (phase == 1 && coef[k] > 0.0)
315.2223 +         {  /* x[k] must not be less than its upper bound */
315.2224 +#ifdef GLP_DEBUG
315.2225 +            xassert(type[k] == GLP_UP || type[k] == GLP_DB ||
315.2226 +                    type[k] == GLP_FX);
315.2227 +#endif
315.2228 +            eps = tol_bnd * (1.0 + kappa * fabs(ub[k]));
315.2229 +            if (bbar[i] < ub[k] - eps) return 1;
315.2230 +         }
315.2231 +         else
315.2232 +         {  /* either phase = 1 and coef[k] = 0, or phase = 2 */
315.2233 +            if (type[k] == GLP_LO || type[k] == GLP_DB ||
315.2234 +                type[k] == GLP_FX)
315.2235 +            {  /* x[k] must not be less than its lower bound */
315.2236 +               eps = tol_bnd * (1.0 + kappa * fabs(lb[k]));
315.2237 +               if (bbar[i] < lb[k] - eps) return 1;
315.2238 +            }
315.2239 +            if (type[k] == GLP_UP || type[k] == GLP_DB ||
315.2240 +                type[k] == GLP_FX)
315.2241 +            {  /* x[k] must not be greater then its upper bound */
315.2242 +               eps = tol_bnd * (1.0 + kappa * fabs(ub[k]));
315.2243 +               if (bbar[i] > ub[k] + eps) return 1;
315.2244 +            }
315.2245 +         }
315.2246 +      }
315.2247 +      /* basic solution is primal feasible within a tolerance */
315.2248 +      return 0;
315.2249 +}
315.2250 +
315.2251 +/***********************************************************************
315.2252 +*  check_feas - check primal feasibility of basic solution
315.2253 +*
315.2254 +*  If the current basic solution is primal feasible within a tolerance,
315.2255 +*  this routine returns zero, otherwise it returns non-zero. */
315.2256 +
315.2257 +static int check_feas(struct csa *csa, double tol_bnd)
315.2258 +{     int m = csa->m;
315.2259 +#ifdef GLP_DEBUG
315.2260 +      int n = csa->n;
315.2261 +      char *type = csa->type;
315.2262 +#endif
315.2263 +      double *lb = csa->lb;
315.2264 +      double *ub = csa->ub;
315.2265 +      double *coef = csa->coef;
315.2266 +      int *head = csa->head;
315.2267 +      double *bbar = csa->bbar;
315.2268 +      int i, k;
315.2269 +      double eps;
315.2270 +      xassert(csa->phase == 1);
315.2271 +      /* walk through the list of basic variables */
315.2272 +      for (i = 1; i <= m; i++)
315.2273 +      {  k = head[i]; /* x[k] = xB[i] */
315.2274 +#ifdef GLP_DEBUG
315.2275 +         xassert(1 <= k && k <= m+n);
315.2276 +#endif
315.2277 +         if (coef[k] < 0.0)
315.2278 +         {  /* check if x[k] still violates its lower bound */
315.2279 +#ifdef GLP_DEBUG
315.2280 +            xassert(type[k] == GLP_LO || type[k] == GLP_DB ||
315.2281 +                    type[k] == GLP_FX);
315.2282 +#endif
315.2283 +            eps = tol_bnd * (1.0 + kappa * fabs(lb[k]));
315.2284 +            if (bbar[i] < lb[k] - eps) return 1;
315.2285 +         }
315.2286 +         else if (coef[k] > 0.0)
315.2287 +         {  /* check if x[k] still violates its upper bound */
315.2288 +#ifdef GLP_DEBUG
315.2289 +            xassert(type[k] == GLP_UP || type[k] == GLP_DB ||
315.2290 +                    type[k] == GLP_FX);
315.2291 +#endif
315.2292 +            eps = tol_bnd * (1.0 + kappa * fabs(ub[k]));
315.2293 +            if (bbar[i] > ub[k] + eps) return 1;
315.2294 +         }
315.2295 +      }
315.2296 +      /* basic solution is primal feasible within a tolerance */
315.2297 +      return 0;
315.2298 +}
315.2299 +
315.2300 +/***********************************************************************
315.2301 +*  eval_obj - compute original objective function
315.2302 +*
315.2303 +*  This routine computes the current value of the original objective
315.2304 +*  function. */
315.2305 +
315.2306 +static double eval_obj(struct csa *csa)
315.2307 +{     int m = csa->m;
315.2308 +      int n = csa->n;
315.2309 +      double *obj = csa->obj;
315.2310 +      int *head = csa->head;
315.2311 +      double *bbar = csa->bbar;
315.2312 +      int i, j, k;
315.2313 +      double sum;
315.2314 +      sum = obj[0];
315.2315 +      /* walk through the list of basic variables */
315.2316 +      for (i = 1; i <= m; i++)
315.2317 +      {  k = head[i]; /* x[k] = xB[i] */
315.2318 +#ifdef GLP_DEBUG
315.2319 +         xassert(1 <= k && k <= m+n);
315.2320 +#endif
315.2321 +         if (k > m)
315.2322 +            sum += obj[k-m] * bbar[i];
315.2323 +      }
315.2324 +      /* walk through the list of non-basic variables */
315.2325 +      for (j = 1; j <= n; j++)
315.2326 +      {  k = head[m+j]; /* x[k] = xN[j] */
315.2327 +#ifdef GLP_DEBUG
315.2328 +         xassert(1 <= k && k <= m+n);
315.2329 +#endif
315.2330 +         if (k > m)
315.2331 +            sum += obj[k-m] * get_xN(csa, j);
315.2332 +      }
315.2333 +      return sum;
315.2334 +}
315.2335 +
315.2336 +/***********************************************************************
315.2337 +*  display - display the search progress
315.2338 +*
315.2339 +*  This routine displays some information about the search progress
315.2340 +*  that includes:
315.2341 +*
315.2342 +*  the search phase;
315.2343 +*
315.2344 +*  the number of simplex iterations performed by the solver;
315.2345 +*
315.2346 +*  the original objective value;
315.2347 +*
315.2348 +*  the sum of (scaled) primal infeasibilities;
315.2349 +*
315.2350 +*  the number of basic fixed variables. */
315.2351 +
315.2352 +static void display(struct csa *csa, const glp_smcp *parm, int spec)
315.2353 +{     int m = csa->m;
315.2354 +#ifdef GLP_DEBUG
315.2355 +      int n = csa->n;
315.2356 +#endif
315.2357 +      char *type = csa->type;
315.2358 +      double *lb = csa->lb;
315.2359 +      double *ub = csa->ub;
315.2360 +      int phase = csa->phase;
315.2361 +      int *head = csa->head;
315.2362 +      double *bbar = csa->bbar;
315.2363 +      int i, k, cnt;
315.2364 +      double sum;
315.2365 +      if (parm->msg_lev < GLP_MSG_ON) goto skip;
315.2366 +      if (parm->out_dly > 0 &&
315.2367 +         1000.0 * xdifftime(xtime(), csa->tm_beg) < parm->out_dly)
315.2368 +         goto skip;
315.2369 +      if (csa->it_cnt == csa->it_dpy) goto skip;
315.2370 +      if (!spec && csa->it_cnt % parm->out_frq != 0) goto skip;
315.2371 +      /* compute the sum of primal infeasibilities and determine the
315.2372 +         number of basic fixed variables */
315.2373 +      sum = 0.0, cnt = 0;
315.2374 +      for (i = 1; i <= m; i++)
315.2375 +      {  k = head[i]; /* x[k] = xB[i] */
315.2376 +#ifdef GLP_DEBUG
315.2377 +         xassert(1 <= k && k <= m+n);
315.2378 +#endif
315.2379 +         if (type[k] == GLP_LO || type[k] == GLP_DB ||
315.2380 +             type[k] == GLP_FX)
315.2381 +         {  /* x[k] has lower bound */
315.2382 +            if (bbar[i] < lb[k])
315.2383 +               sum += (lb[k] - bbar[i]);
315.2384 +         }
315.2385 +         if (type[k] == GLP_UP || type[k] == GLP_DB ||
315.2386 +             type[k] == GLP_FX)
315.2387 +         {  /* x[k] has upper bound */
315.2388 +            if (bbar[i] > ub[k])
315.2389 +               sum += (bbar[i] - ub[k]);
315.2390 +         }
315.2391 +         if (type[k] == GLP_FX) cnt++;
315.2392 +      }
315.2393 +      xprintf("%c%6d: obj = %17.9e  infeas = %10.3e (%d)\n",
315.2394 +         phase == 1 ? ' ' : '*', csa->it_cnt, eval_obj(csa), sum, cnt);
315.2395 +      csa->it_dpy = csa->it_cnt;
315.2396 +skip: return;
315.2397 +}
315.2398 +
315.2399 +/***********************************************************************
315.2400 +*  store_sol - store basic solution back to the problem object
315.2401 +*
315.2402 +*  This routine stores basic solution components back to the problem
315.2403 +*  object. */
315.2404 +
315.2405 +static void store_sol(struct csa *csa, glp_prob *lp, int p_stat,
315.2406 +      int d_stat, int ray)
315.2407 +{     int m = csa->m;
315.2408 +      int n = csa->n;
315.2409 +      double zeta = csa->zeta;
315.2410 +      int *head = csa->head;
315.2411 +      char *stat = csa->stat;
315.2412 +      double *bbar = csa->bbar;
315.2413 +      double *cbar = csa->cbar;
315.2414 +      int i, j, k;
315.2415 +#ifdef GLP_DEBUG
315.2416 +      xassert(lp->m == m);
315.2417 +      xassert(lp->n == n);
315.2418 +#endif
315.2419 +      /* basis factorization */
315.2420 +#ifdef GLP_DEBUG
315.2421 +      xassert(!lp->valid && lp->bfd == NULL);
315.2422 +      xassert(csa->valid && csa->bfd != NULL);
315.2423 +#endif
315.2424 +      lp->valid = 1, csa->valid = 0;
315.2425 +      lp->bfd = csa->bfd, csa->bfd = NULL;
315.2426 +      memcpy(&lp->head[1], &head[1], m * sizeof(int));
315.2427 +      /* basic solution status */
315.2428 +      lp->pbs_stat = p_stat;
315.2429 +      lp->dbs_stat = d_stat;
315.2430 +      /* objective function value */
315.2431 +      lp->obj_val = eval_obj(csa);
315.2432 +      /* simplex iteration count */
315.2433 +      lp->it_cnt = csa->it_cnt;
315.2434 +      /* unbounded ray */
315.2435 +      lp->some = ray;
315.2436 +      /* basic variables */
315.2437 +      for (i = 1; i <= m; i++)
315.2438 +      {  k = head[i]; /* x[k] = xB[i] */
315.2439 +#ifdef GLP_DEBUG
315.2440 +         xassert(1 <= k && k <= m+n);
315.2441 +#endif
315.2442 +         if (k <= m)
315.2443 +         {  GLPROW *row = lp->row[k];
315.2444 +            row->stat = GLP_BS;
315.2445 +            row->bind = i;
315.2446 +            row->prim = bbar[i] / row->rii;
315.2447 +            row->dual = 0.0;
315.2448 +         }
315.2449 +         else
315.2450 +         {  GLPCOL *col = lp->col[k-m];
315.2451 +            col->stat = GLP_BS;
315.2452 +            col->bind = i;
315.2453 +            col->prim = bbar[i] * col->sjj;
315.2454 +            col->dual = 0.0;
315.2455 +         }
315.2456 +      }
315.2457 +      /* non-basic variables */
315.2458 +      for (j = 1; j <= n; j++)
315.2459 +      {  k = head[m+j]; /* x[k] = xN[j] */
315.2460 +#ifdef GLP_DEBUG
315.2461 +         xassert(1 <= k && k <= m+n);
315.2462 +#endif
315.2463 +         if (k <= m)
315.2464 +         {  GLPROW *row = lp->row[k];
315.2465 +            row->stat = stat[j];
315.2466 +            row->bind = 0;
315.2467 +#if 0
315.2468 +            row->prim = get_xN(csa, j) / row->rii;
315.2469 +#else
315.2470 +            switch (stat[j])
315.2471 +            {  case GLP_NL:
315.2472 +                  row->prim = row->lb; break;
315.2473 +               case GLP_NU:
315.2474 +                  row->prim = row->ub; break;
315.2475 +               case GLP_NF:
315.2476 +                  row->prim = 0.0; break;
315.2477 +               case GLP_NS:
315.2478 +                  row->prim = row->lb; break;
315.2479 +               default:
315.2480 +                  xassert(stat != stat);
315.2481 +            }
315.2482 +#endif
315.2483 +            row->dual = (cbar[j] * row->rii) / zeta;
315.2484 +         }
315.2485 +         else
315.2486 +         {  GLPCOL *col = lp->col[k-m];
315.2487 +            col->stat = stat[j];
315.2488 +            col->bind = 0;
315.2489 +#if 0
315.2490 +            col->prim = get_xN(csa, j) * col->sjj;
315.2491 +#else
315.2492 +            switch (stat[j])
315.2493 +            {  case GLP_NL:
315.2494 +                  col->prim = col->lb; break;
315.2495 +               case GLP_NU:
315.2496 +                  col->prim = col->ub; break;
315.2497 +               case GLP_NF:
315.2498 +                  col->prim = 0.0; break;
315.2499 +               case GLP_NS:
315.2500 +                  col->prim = col->lb; break;
315.2501 +               default:
315.2502 +                  xassert(stat != stat);
315.2503 +            }
315.2504 +#endif
315.2505 +            col->dual = (cbar[j] / col->sjj) / zeta;
315.2506 +         }
315.2507 +      }
315.2508 +      return;
315.2509 +}
315.2510 +
315.2511 +/***********************************************************************
315.2512 +*  free_csa - deallocate common storage area
315.2513 +*
315.2514 +*  This routine frees all the memory allocated to arrays in the common
315.2515 +*  storage area (CSA). */
315.2516 +
315.2517 +static void free_csa(struct csa *csa)
315.2518 +{     xfree(csa->type);
315.2519 +      xfree(csa->lb);
315.2520 +      xfree(csa->ub);
315.2521 +      xfree(csa->coef);
315.2522 +      xfree(csa->obj);
315.2523 +      xfree(csa->A_ptr);
315.2524 +      xfree(csa->A_ind);
315.2525 +      xfree(csa->A_val);
315.2526 +      xfree(csa->head);
315.2527 +      xfree(csa->stat);
315.2528 +      xfree(csa->N_ptr);
315.2529 +      xfree(csa->N_len);
315.2530 +      xfree(csa->N_ind);
315.2531 +      xfree(csa->N_val);
315.2532 +      xfree(csa->bbar);
315.2533 +      xfree(csa->cbar);
315.2534 +      xfree(csa->refsp);
315.2535 +      xfree(csa->gamma);
315.2536 +      xfree(csa->tcol_ind);
315.2537 +      xfree(csa->tcol_vec);
315.2538 +      xfree(csa->trow_ind);
315.2539 +      xfree(csa->trow_vec);
315.2540 +      xfree(csa->work1);
315.2541 +      xfree(csa->work2);
315.2542 +      xfree(csa->work3);
315.2543 +      xfree(csa->work4);
315.2544 +      xfree(csa);
315.2545 +      return;
315.2546 +}
315.2547 +
315.2548 +/***********************************************************************
315.2549 +*  spx_primal - core LP solver based on the primal simplex method
315.2550 +*
315.2551 +*  SYNOPSIS
315.2552 +*
315.2553 +*  #include "glpspx.h"
315.2554 +*  int spx_primal(glp_prob *lp, const glp_smcp *parm);
315.2555 +*
315.2556 +*  DESCRIPTION
315.2557 +*
315.2558 +*  The routine spx_primal is a core LP solver based on the two-phase
315.2559 +*  primal simplex method.
315.2560 +*
315.2561 +*  RETURNS
315.2562 +*
315.2563 +*  0  LP instance has been successfully solved.
315.2564 +*
315.2565 +*  GLP_EITLIM
315.2566 +*     Iteration limit has been exhausted.
315.2567 +*
315.2568 +*  GLP_ETMLIM
315.2569 +*     Time limit has been exhausted.
315.2570 +*
315.2571 +*  GLP_EFAIL
315.2572 +*     The solver failed to solve LP instance. */
315.2573 +
315.2574 +int spx_primal(glp_prob *lp, const glp_smcp *parm)
315.2575 +{     struct csa *csa;
315.2576 +      int binv_st = 2;
315.2577 +      /* status of basis matrix factorization:
315.2578 +         0 - invalid; 1 - just computed; 2 - updated */
315.2579 +      int bbar_st = 0;
315.2580 +      /* status of primal values of basic variables:
315.2581 +         0 - invalid; 1 - just computed; 2 - updated */
315.2582 +      int cbar_st = 0;
315.2583 +      /* status of reduced costs of non-basic variables:
315.2584 +         0 - invalid; 1 - just computed; 2 - updated */
315.2585 +      int rigorous = 0;
315.2586 +      /* rigorous mode flag; this flag is used to enable iterative
315.2587 +         refinement on computing pivot rows and columns of the simplex
315.2588 +         table */
315.2589 +      int check = 0;
315.2590 +      int p_stat, d_stat, ret;
315.2591 +      /* allocate and initialize the common storage area */
315.2592 +      csa = alloc_csa(lp);
315.2593 +      init_csa(csa, lp);
315.2594 +      if (parm->msg_lev >= GLP_MSG_DBG)
315.2595 +         xprintf("Objective scale factor = %g\n", csa->zeta);
315.2596 +loop: /* main loop starts here */
315.2597 +      /* compute factorization of the basis matrix */
315.2598 +      if (binv_st == 0)
315.2599 +      {  ret = invert_B(csa);
315.2600 +         if (ret != 0)
315.2601 +         {  if (parm->msg_lev >= GLP_MSG_ERR)
315.2602 +            {  xprintf("Error: unable to factorize the basis matrix (%d"
315.2603 +                  ")\n", ret);
315.2604 +               xprintf("Sorry, basis recovery procedure not implemented"
315.2605 +                  " yet\n");
315.2606 +            }
315.2607 +            xassert(!lp->valid && lp->bfd == NULL);
315.2608 +            lp->bfd = csa->bfd, csa->bfd = NULL;
315.2609 +            lp->pbs_stat = lp->dbs_stat = GLP_UNDEF;
315.2610 +            lp->obj_val = 0.0;
315.2611 +            lp->it_cnt = csa->it_cnt;
315.2612 +            lp->some = 0;
315.2613 +            ret = GLP_EFAIL;
315.2614 +            goto done;
315.2615 +         }
315.2616 +         csa->valid = 1;
315.2617 +         binv_st = 1; /* just computed */
315.2618 +         /* invalidate basic solution components */
315.2619 +         bbar_st = cbar_st = 0;
315.2620 +      }
315.2621 +      /* compute primal values of basic variables */
315.2622 +      if (bbar_st == 0)
315.2623 +      {  eval_bbar(csa);
315.2624 +         bbar_st = 1; /* just computed */
315.2625 +         /* determine the search phase, if not determined yet */
315.2626 +         if (csa->phase == 0)
315.2627 +         {  if (set_aux_obj(csa, parm->tol_bnd) > 0)
315.2628 +            {  /* current basic solution is primal infeasible */
315.2629 +               /* start to minimize the sum of infeasibilities */
315.2630 +               csa->phase = 1;
315.2631 +            }
315.2632 +            else
315.2633 +            {  /* current basic solution is primal feasible */
315.2634 +               /* start to minimize the original objective function */
315.2635 +               set_orig_obj(csa);
315.2636 +               csa->phase = 2;
315.2637 +            }
315.2638 +            xassert(check_stab(csa, parm->tol_bnd) == 0);
315.2639 +            /* working objective coefficients have been changed, so
315.2640 +               invalidate reduced costs */
315.2641 +            cbar_st = 0;
315.2642 +            display(csa, parm, 1);
315.2643 +         }
315.2644 +         /* make sure that the current basic solution remains primal
315.2645 +            feasible (or pseudo feasible on phase I) */
315.2646 +         if (check_stab(csa, parm->tol_bnd))
315.2647 +         {  /* there are excessive bound violations due to round-off
315.2648 +               errors */
315.2649 +            if (parm->msg_lev >= GLP_MSG_ERR)
315.2650 +               xprintf("Warning: numerical instability (primal simplex,"
315.2651 +                  " phase %s)\n", csa->phase == 1 ? "I" : "II");
315.2652 +            /* restart the search */
315.2653 +            csa->phase = 0;
315.2654 +            binv_st = 0;
315.2655 +            rigorous = 5;
315.2656 +            goto loop;
315.2657 +         }
315.2658 +      }
315.2659 +      xassert(csa->phase == 1 || csa->phase == 2);
315.2660 +      /* on phase I we do not need to wait until the current basic
315.2661 +         solution becomes dual feasible; it is sufficient to make sure
315.2662 +         that no basic variable violates its bounds */
315.2663 +      if (csa->phase == 1 && !check_feas(csa, parm->tol_bnd))
315.2664 +      {  /* the current basis is primal feasible; switch to phase II */
315.2665 +         csa->phase = 2;
315.2666 +         set_orig_obj(csa);
315.2667 +         cbar_st = 0;
315.2668 +         display(csa, parm, 1);
315.2669 +      }
315.2670 +      /* compute reduced costs of non-basic variables */
315.2671 +      if (cbar_st == 0)
315.2672 +      {  eval_cbar(csa);
315.2673 +         cbar_st = 1; /* just computed */
315.2674 +      }
315.2675 +      /* redefine the reference space, if required */
315.2676 +      switch (parm->pricing)
315.2677 +      {  case GLP_PT_STD:
315.2678 +            break;
315.2679 +         case GLP_PT_PSE:
315.2680 +            if (csa->refct == 0) reset_refsp(csa);
315.2681 +            break;
315.2682 +         default:
315.2683 +            xassert(parm != parm);
315.2684 +      }
315.2685 +      /* at this point the basis factorization and all basic solution
315.2686 +         components are valid */
315.2687 +      xassert(binv_st && bbar_st && cbar_st);
315.2688 +      /* check accuracy of current basic solution components (only for
315.2689 +         debugging) */
315.2690 +      if (check)
315.2691 +      {  double e_bbar = err_in_bbar(csa);
315.2692 +         double e_cbar = err_in_cbar(csa);
315.2693 +         double e_gamma =
315.2694 +            (parm->pricing == GLP_PT_PSE ? err_in_gamma(csa) : 0.0);
315.2695 +         xprintf("e_bbar = %10.3e; e_cbar = %10.3e; e_gamma = %10.3e\n",
315.2696 +            e_bbar, e_cbar, e_gamma);
315.2697 +         xassert(e_bbar <= 1e-5 && e_cbar <= 1e-5 && e_gamma <= 1e-3);
315.2698 +      }
315.2699 +      /* check if the iteration limit has been exhausted */
315.2700 +      if (parm->it_lim < INT_MAX &&
315.2701 +          csa->it_cnt - csa->it_beg >= parm->it_lim)
315.2702 +      {  if (bbar_st != 1 || csa->phase == 2 && cbar_st != 1)
315.2703 +         {  if (bbar_st != 1) bbar_st = 0;
315.2704 +            if (csa->phase == 2 && cbar_st != 1) cbar_st = 0;
315.2705 +            goto loop;
315.2706 +         }
315.2707 +         display(csa, parm, 1);
315.2708 +         if (parm->msg_lev >= GLP_MSG_ALL)
315.2709 +            xprintf("ITERATION LIMIT EXCEEDED; SEARCH TERMINATED\n");
315.2710 +         switch (csa->phase)
315.2711 +         {  case 1:
315.2712 +               p_stat = GLP_INFEAS;
315.2713 +               set_orig_obj(csa);
315.2714 +               eval_cbar(csa);
315.2715 +               break;
315.2716 +            case 2:
315.2717 +               p_stat = GLP_FEAS;
315.2718 +               break;
315.2719 +            default:
315.2720 +               xassert(csa != csa);
315.2721 +         }
315.2722 +         chuzc(csa, parm->tol_dj);
315.2723 +         d_stat = (csa->q == 0 ? GLP_FEAS : GLP_INFEAS);
315.2724 +         store_sol(csa, lp, p_stat, d_stat, 0);
315.2725 +         ret = GLP_EITLIM;
315.2726 +         goto done;
315.2727 +      }
315.2728 +      /* check if the time limit has been exhausted */
315.2729 +      if (parm->tm_lim < INT_MAX &&
315.2730 +          1000.0 * xdifftime(xtime(), csa->tm_beg) >= parm->tm_lim)
315.2731 +      {  if (bbar_st != 1 || csa->phase == 2 && cbar_st != 1)
315.2732 +         {  if (bbar_st != 1) bbar_st = 0;
315.2733 +            if (csa->phase == 2 && cbar_st != 1) cbar_st = 0;
315.2734 +            goto loop;
315.2735 +         }
315.2736 +         display(csa, parm, 1);
315.2737 +         if (parm->msg_lev >= GLP_MSG_ALL)
315.2738 +            xprintf("TIME LIMIT EXCEEDED; SEARCH TERMINATED\n");
315.2739 +         switch (csa->phase)
315.2740 +         {  case 1:
315.2741 +               p_stat = GLP_INFEAS;
315.2742 +               set_orig_obj(csa);
315.2743 +               eval_cbar(csa);
315.2744 +               break;
315.2745 +            case 2:
315.2746 +               p_stat = GLP_FEAS;
315.2747 +               break;
315.2748 +            default:
315.2749 +               xassert(csa != csa);
315.2750 +         }
315.2751 +         chuzc(csa, parm->tol_dj);
315.2752 +         d_stat = (csa->q == 0 ? GLP_FEAS : GLP_INFEAS);
315.2753 +         store_sol(csa, lp, p_stat, d_stat, 0);
315.2754 +         ret = GLP_ETMLIM;
315.2755 +         goto done;
315.2756 +      }
315.2757 +      /* display the search progress */
315.2758 +      display(csa, parm, 0);
315.2759 +      /* choose non-basic variable xN[q] */
315.2760 +      chuzc(csa, parm->tol_dj);
315.2761 +      if (csa->q == 0)
315.2762 +      {  if (bbar_st != 1 || cbar_st != 1)
315.2763 +         {  if (bbar_st != 1) bbar_st = 0;
315.2764 +            if (cbar_st != 1) cbar_st = 0;
315.2765 +            goto loop;
315.2766 +         }
315.2767 +         display(csa, parm, 1);
315.2768 +         switch (csa->phase)
315.2769 +         {  case 1:
315.2770 +               if (parm->msg_lev >= GLP_MSG_ALL)
315.2771 +                  xprintf("PROBLEM HAS NO FEASIBLE SOLUTION\n");
315.2772 +               p_stat = GLP_NOFEAS;
315.2773 +               set_orig_obj(csa);
315.2774 +               eval_cbar(csa);
315.2775 +               chuzc(csa, parm->tol_dj);
315.2776 +               d_stat = (csa->q == 0 ? GLP_FEAS : GLP_INFEAS);
315.2777 +               break;
315.2778 +            case 2:
315.2779 +               if (parm->msg_lev >= GLP_MSG_ALL)
315.2780 +                  xprintf("OPTIMAL SOLUTION FOUND\n");
315.2781 +               p_stat = d_stat = GLP_FEAS;
315.2782 +               break;
315.2783 +            default:
315.2784 +               xassert(csa != csa);
315.2785 +         }
315.2786 +         store_sol(csa, lp, p_stat, d_stat, 0);
315.2787 +         ret = 0;
315.2788 +         goto done;
315.2789 +      }
315.2790 +      /* compute pivot column of the simplex table */
315.2791 +      eval_tcol(csa);
315.2792 +      if (rigorous) refine_tcol(csa);
315.2793 +      sort_tcol(csa, parm->tol_piv);
315.2794 +      /* check accuracy of the reduced cost of xN[q] */
315.2795 +      {  double d1 = csa->cbar[csa->q]; /* less accurate */
315.2796 +         double d2 = reeval_cost(csa);  /* more accurate */
315.2797 +         xassert(d1 != 0.0);
315.2798 +         if (fabs(d1 - d2) > 1e-5 * (1.0 + fabs(d2)) ||
315.2799 +             !(d1 < 0.0 && d2 < 0.0 || d1 > 0.0 && d2 > 0.0))
315.2800 +         {  if (parm->msg_lev >= GLP_MSG_DBG)
315.2801 +               xprintf("d1 = %.12g; d2 = %.12g\n", d1, d2);
315.2802 +            if (cbar_st != 1 || !rigorous)
315.2803 +            {  if (cbar_st != 1) cbar_st = 0;
315.2804 +               rigorous = 5;
315.2805 +               goto loop;
315.2806 +            }
315.2807 +         }
315.2808 +         /* replace cbar[q] by more accurate value keeping its sign */
315.2809 +         if (d1 > 0.0)
315.2810 +            csa->cbar[csa->q] = (d2 > 0.0 ? d2 : +DBL_EPSILON);
315.2811 +         else
315.2812 +            csa->cbar[csa->q] = (d2 < 0.0 ? d2 : -DBL_EPSILON);
315.2813 +      }
315.2814 +      /* choose basic variable xB[p] */
315.2815 +      switch (parm->r_test)
315.2816 +      {  case GLP_RT_STD:
315.2817 +            chuzr(csa, 0.0);
315.2818 +            break;
315.2819 +         case GLP_RT_HAR:
315.2820 +            chuzr(csa, 0.30 * parm->tol_bnd);
315.2821 +            break;
315.2822 +         default:
315.2823 +            xassert(parm != parm);
315.2824 +      }
315.2825 +      if (csa->p == 0)
315.2826 +      {  if (bbar_st != 1 || cbar_st != 1 || !rigorous)
315.2827 +         {  if (bbar_st != 1) bbar_st = 0;
315.2828 +            if (cbar_st != 1) cbar_st = 0;
315.2829 +            rigorous = 1;
315.2830 +            goto loop;
315.2831 +         }
315.2832 +         display(csa, parm, 1);
315.2833 +         switch (csa->phase)
315.2834 +         {  case 1:
315.2835 +               if (parm->msg_lev >= GLP_MSG_ERR)
315.2836 +                  xprintf("Error: unable to choose basic variable on ph"
315.2837 +                     "ase I\n");
315.2838 +               xassert(!lp->valid && lp->bfd == NULL);
315.2839 +               lp->bfd = csa->bfd, csa->bfd = NULL;
315.2840 +               lp->pbs_stat = lp->dbs_stat = GLP_UNDEF;
315.2841 +               lp->obj_val = 0.0;
315.2842 +               lp->it_cnt = csa->it_cnt;
315.2843 +               lp->some = 0;
315.2844 +               ret = GLP_EFAIL;
315.2845 +               break;
315.2846 +            case 2:
315.2847 +               if (parm->msg_lev >= GLP_MSG_ALL)
315.2848 +                  xprintf("PROBLEM HAS UNBOUNDED SOLUTION\n");
315.2849 +               store_sol(csa, lp, GLP_FEAS, GLP_NOFEAS,
315.2850 +                  csa->head[csa->m+csa->q]);
315.2851 +               ret = 0;
315.2852 +               break;
315.2853 +            default:
315.2854 +               xassert(csa != csa);
315.2855 +         }
315.2856 +         goto done;
315.2857 +      }
315.2858 +      /* check if the pivot element is acceptable */
315.2859 +      if (csa->p > 0)
315.2860 +      {  double piv = csa->tcol_vec[csa->p];
315.2861 +         double eps = 1e-5 * (1.0 + 0.01 * csa->tcol_max);
315.2862 +         if (fabs(piv) < eps)
315.2863 +         {  if (parm->msg_lev >= GLP_MSG_DBG)
315.2864 +               xprintf("piv = %.12g; eps = %g\n", piv, eps);
315.2865 +            if (!rigorous)
315.2866 +            {  rigorous = 5;
315.2867 +               goto loop;
315.2868 +            }
315.2869 +         }
315.2870 +      }
315.2871 +      /* now xN[q] and xB[p] have been chosen anyhow */
315.2872 +      /* compute pivot row of the simplex table */
315.2873 +      if (csa->p > 0)
315.2874 +      {  double *rho = csa->work4;
315.2875 +         eval_rho(csa, rho);
315.2876 +         if (rigorous) refine_rho(csa, rho);
315.2877 +         eval_trow(csa, rho);
315.2878 +      }
315.2879 +      /* accuracy check based on the pivot element */
315.2880 +      if (csa->p > 0)
315.2881 +      {  double piv1 = csa->tcol_vec[csa->p]; /* more accurate */
315.2882 +         double piv2 = csa->trow_vec[csa->q]; /* less accurate */
315.2883 +         xassert(piv1 != 0.0);
315.2884 +         if (fabs(piv1 - piv2) > 1e-8 * (1.0 + fabs(piv1)) ||
315.2885 +             !(piv1 > 0.0 && piv2 > 0.0 || piv1 < 0.0 && piv2 < 0.0))
315.2886 +         {  if (parm->msg_lev >= GLP_MSG_DBG)
315.2887 +               xprintf("piv1 = %.12g; piv2 = %.12g\n", piv1, piv2);
315.2888 +            if (binv_st != 1 || !rigorous)
315.2889 +            {  if (binv_st != 1) binv_st = 0;
315.2890 +               rigorous = 5;
315.2891 +               goto loop;
315.2892 +            }
315.2893 +            /* use more accurate version in the pivot row */
315.2894 +            if (csa->trow_vec[csa->q] == 0.0)
315.2895 +            {  csa->trow_nnz++;
315.2896 +               xassert(csa->trow_nnz <= csa->n);
315.2897 +               csa->trow_ind[csa->trow_nnz] = csa->q;
315.2898 +            }
315.2899 +            csa->trow_vec[csa->q] = piv1;
315.2900 +         }
315.2901 +      }
315.2902 +      /* update primal values of basic variables */
315.2903 +      update_bbar(csa);
315.2904 +      bbar_st = 2; /* updated */
315.2905 +      /* update reduced costs of non-basic variables */
315.2906 +      if (csa->p > 0)
315.2907 +      {  update_cbar(csa);
315.2908 +         cbar_st = 2; /* updated */
315.2909 +         /* on phase I objective coefficient of xB[p] in the adjacent
315.2910 +            basis becomes zero */
315.2911 +         if (csa->phase == 1)
315.2912 +         {  int k = csa->head[csa->p]; /* x[k] = xB[p] -> xN[q] */
315.2913 +            csa->cbar[csa->q] -= csa->coef[k];
315.2914 +            csa->coef[k] = 0.0;
315.2915 +         }
315.2916 +      }
315.2917 +      /* update steepest edge coefficients */
315.2918 +      if (csa->p > 0)
315.2919 +      {  switch (parm->pricing)
315.2920 +         {  case GLP_PT_STD:
315.2921 +               break;
315.2922 +            case GLP_PT_PSE:
315.2923 +               if (csa->refct > 0) update_gamma(csa);
315.2924 +               break;
315.2925 +            default:
315.2926 +               xassert(parm != parm);
315.2927 +         }
315.2928 +      }
315.2929 +      /* update factorization of the basis matrix */
315.2930 +      if (csa->p > 0)
315.2931 +      {  ret = update_B(csa, csa->p, csa->head[csa->m+csa->q]);
315.2932 +         if (ret == 0)
315.2933 +            binv_st = 2; /* updated */
315.2934 +         else
315.2935 +         {  csa->valid = 0;
315.2936 +            binv_st = 0; /* invalid */
315.2937 +         }
315.2938 +      }
315.2939 +      /* update matrix N */
315.2940 +      if (csa->p > 0)
315.2941 +      {  del_N_col(csa, csa->q, csa->head[csa->m+csa->q]);
315.2942 +         if (csa->type[csa->head[csa->p]] != GLP_FX)
315.2943 +            add_N_col(csa, csa->q, csa->head[csa->p]);
315.2944 +      }
315.2945 +      /* change the basis header */
315.2946 +      change_basis(csa);
315.2947 +      /* iteration complete */
315.2948 +      csa->it_cnt++;
315.2949 +      if (rigorous > 0) rigorous--;
315.2950 +      goto loop;
315.2951 +done: /* deallocate the common storage area */
315.2952 +      free_csa(csa);
315.2953 +      /* return to the calling program */
315.2954 +      return ret;
315.2955 +}
315.2956 +
315.2957 +/* eof */
   316.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
   316.2 +++ b/deps/glpk/src/glpspx02.c	Sun Nov 06 20:59:10 2011 +0100
   316.3 @@ -0,0 +1,3077 @@
   316.4 +/* glpspx02.c (dual simplex method) */
   316.5 +
   316.6 +/***********************************************************************
   316.7 +*  This code is part of GLPK (GNU Linear Programming Kit).
   316.8 +*
   316.9 +*  Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008,
  316.10 +*  2009, 2010, 2011 Andrew Makhorin, Department for Applied Informatics,
  316.11 +*  Moscow Aviation Institute, Moscow, Russia. All rights reserved.
  316.12 +*  E-mail: <mao@gnu.org>.
  316.13 +*
  316.14 +*  GLPK is free software: you can redistribute it and/or modify it
  316.15 +*  under the terms of the GNU General Public License as published by
  316.16 +*  the Free Software Foundation, either version 3 of the License, or
  316.17 +*  (at your option) any later version.
  316.18 +*
  316.19 +*  GLPK is distributed in the hope that it will be useful, but WITHOUT
  316.20 +*  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
  316.21 +*  or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
  316.22 +*  License for more details.
  316.23 +*
  316.24 +*  You should have received a copy of the GNU General Public License
  316.25 +*  along with GLPK. If not, see <http://www.gnu.org/licenses/>.
  316.26 +***********************************************************************/
  316.27 +
  316.28 +#include "glpspx.h"
  316.29 +
  316.30 +#define GLP_DEBUG 1
  316.31 +
  316.32 +#if 0
  316.33 +#define GLP_LONG_STEP 1
  316.34 +#endif
  316.35 +
  316.36 +struct csa
  316.37 +{     /* common storage area */
  316.38 +      /*--------------------------------------------------------------*/
  316.39 +      /* LP data */
  316.40 +      int m;
  316.41 +      /* number of rows (auxiliary variables), m > 0 */
  316.42 +      int n;
  316.43 +      /* number of columns (structural variables), n > 0 */
  316.44 +      char *type; /* char type[1+m+n]; */
  316.45 +      /* type[0] is not used;
  316.46 +         type[k], 1 <= k <= m+n, is the type of variable x[k]:
  316.47 +         GLP_FR - free variable
  316.48 +         GLP_LO - variable with lower bound
  316.49 +         GLP_UP - variable with upper bound
  316.50 +         GLP_DB - double-bounded variable
  316.51 +         GLP_FX - fixed variable */
  316.52 +      double *lb; /* double lb[1+m+n]; */
  316.53 +      /* lb[0] is not used;
  316.54 +         lb[k], 1 <= k <= m+n, is an lower bound of variable x[k];
  316.55 +         if x[k] has no lower bound, lb[k] is zero */
  316.56 +      double *ub; /* double ub[1+m+n]; */
  316.57 +      /* ub[0] is not used;
  316.58 +         ub[k], 1 <= k <= m+n, is an upper bound of variable x[k];
  316.59 +         if x[k] has no upper bound, ub[k] is zero;
  316.60 +         if x[k] is of fixed type, ub[k] is the same as lb[k] */
  316.61 +      double *coef; /* double coef[1+m+n]; */
  316.62 +      /* coef[0] is not used;
  316.63 +         coef[k], 1 <= k <= m+n, is an objective coefficient at
  316.64 +         variable x[k] */
  316.65 +      /*--------------------------------------------------------------*/
  316.66 +      /* original bounds of variables */
  316.67 +      char *orig_type; /* char orig_type[1+m+n]; */
  316.68 +      double *orig_lb; /* double orig_lb[1+m+n]; */
  316.69 +      double *orig_ub; /* double orig_ub[1+m+n]; */
  316.70 +      /*--------------------------------------------------------------*/
  316.71 +      /* original objective function */
  316.72 +      double *obj; /* double obj[1+n]; */
  316.73 +      /* obj[0] is a constant term of the original objective function;
  316.74 +         obj[j], 1 <= j <= n, is an original objective coefficient at
  316.75 +         structural variable x[m+j] */
  316.76 +      double zeta;
  316.77 +      /* factor used to scale original objective coefficients; its
  316.78 +         sign defines original optimization direction: zeta > 0 means
  316.79 +         minimization, zeta < 0 means maximization */
  316.80 +      /*--------------------------------------------------------------*/
  316.81 +      /* constraint matrix A; it has m rows and n columns and is stored
  316.82 +         by columns */
  316.83 +      int *A_ptr; /* int A_ptr[1+n+1]; */
  316.84 +      /* A_ptr[0] is not used;
  316.85 +         A_ptr[j], 1 <= j <= n, is starting position of j-th column in
  316.86 +         arrays A_ind and A_val; note that A_ptr[1] is always 1;
  316.87 +         A_ptr[n+1] indicates the position after the last element in
  316.88 +         arrays A_ind and A_val */
  316.89 +      int *A_ind; /* int A_ind[A_ptr[n+1]]; */
  316.90 +      /* row indices */
  316.91 +      double *A_val; /* double A_val[A_ptr[n+1]]; */
  316.92 +      /* non-zero element values */
  316.93 +#if 1 /* 06/IV-2009 */
  316.94 +      /* constraint matrix A stored by rows */
  316.95 +      int *AT_ptr; /* int AT_ptr[1+m+1]; */
  316.96 +      /* AT_ptr[0] is not used;
  316.97 +         AT_ptr[i], 1 <= i <= m, is starting position of i-th row in
  316.98 +         arrays AT_ind and AT_val; note that AT_ptr[1] is always 1;
  316.99 +         AT_ptr[m+1] indicates the position after the last element in
 316.100 +         arrays AT_ind and AT_val */
 316.101 +      int *AT_ind; /* int AT_ind[AT_ptr[m+1]]; */
 316.102 +      /* column indices */
 316.103 +      double *AT_val; /* double AT_val[AT_ptr[m+1]]; */
 316.104 +      /* non-zero element values */
 316.105 +#endif
 316.106 +      /*--------------------------------------------------------------*/
 316.107 +      /* basis header */
 316.108 +      int *head; /* int head[1+m+n]; */
 316.109 +      /* head[0] is not used;
 316.110 +         head[i], 1 <= i <= m, is the ordinal number of basic variable
 316.111 +         xB[i]; head[i] = k means that xB[i] = x[k] and i-th column of
 316.112 +         matrix B is k-th column of matrix (I|-A);
 316.113 +         head[m+j], 1 <= j <= n, is the ordinal number of non-basic
 316.114 +         variable xN[j]; head[m+j] = k means that xN[j] = x[k] and j-th
 316.115 +         column of matrix N is k-th column of matrix (I|-A) */
 316.116 +#if 1 /* 06/IV-2009 */
 316.117 +      int *bind; /* int bind[1+m+n]; */
 316.118 +      /* bind[0] is not used;
 316.119 +         bind[k], 1 <= k <= m+n, is the position of k-th column of the
 316.120 +         matrix (I|-A) in the matrix (B|N); that is, bind[k] = k' means
 316.121 +         that head[k'] = k */
 316.122 +#endif
 316.123 +      char *stat; /* char stat[1+n]; */
 316.124 +      /* stat[0] is not used;
 316.125 +         stat[j], 1 <= j <= n, is the status of non-basic variable
 316.126 +         xN[j], which defines its active bound:
 316.127 +         GLP_NL - lower bound is active
 316.128 +         GLP_NU - upper bound is active
 316.129 +         GLP_NF - free variable
 316.130 +         GLP_NS - fixed variable */
 316.131 +      /*--------------------------------------------------------------*/
 316.132 +      /* matrix B is the basis matrix; it is composed from columns of
 316.133 +         the augmented constraint matrix (I|-A) corresponding to basic
 316.134 +         variables and stored in a factorized (invertable) form */
 316.135 +      int valid;
 316.136 +      /* factorization is valid only if this flag is set */
 316.137 +      BFD *bfd; /* BFD bfd[1:m,1:m]; */
 316.138 +      /* factorized (invertable) form of the basis matrix */
 316.139 +#if 0 /* 06/IV-2009 */
 316.140 +      /*--------------------------------------------------------------*/
 316.141 +      /* matrix N is a matrix composed from columns of the augmented
 316.142 +         constraint matrix (I|-A) corresponding to non-basic variables
 316.143 +         except fixed ones; it is stored by rows and changes every time
 316.144 +         the basis changes */
 316.145 +      int *N_ptr; /* int N_ptr[1+m+1]; */
 316.146 +      /* N_ptr[0] is not used;
 316.147 +         N_ptr[i], 1 <= i <= m, is starting position of i-th row in
 316.148 +         arrays N_ind and N_val; note that N_ptr[1] is always 1;
 316.149 +         N_ptr[m+1] indicates the position after the last element in
 316.150 +         arrays N_ind and N_val */
 316.151 +      int *N_len; /* int N_len[1+m]; */
 316.152 +      /* N_len[0] is not used;
 316.153 +         N_len[i], 1 <= i <= m, is length of i-th row (0 to n) */
 316.154 +      int *N_ind; /* int N_ind[N_ptr[m+1]]; */
 316.155 +      /* column indices */
 316.156 +      double *N_val; /* double N_val[N_ptr[m+1]]; */
 316.157 +      /* non-zero element values */
 316.158 +#endif
 316.159 +      /*--------------------------------------------------------------*/
 316.160 +      /* working parameters */
 316.161 +      int phase;
 316.162 +      /* search phase:
 316.163 +         0 - not determined yet
 316.164 +         1 - search for dual feasible solution
 316.165 +         2 - search for optimal solution */
 316.166 +      glp_long tm_beg;
 316.167 +      /* time value at the beginning of the search */
 316.168 +      int it_beg;
 316.169 +      /* simplex iteration count at the beginning of the search */
 316.170 +      int it_cnt;
 316.171 +      /* simplex iteration count; it increases by one every time the
 316.172 +         basis changes */
 316.173 +      int it_dpy;
 316.174 +      /* simplex iteration count at the most recent display output */
 316.175 +      /*--------------------------------------------------------------*/
 316.176 +      /* basic solution components */
 316.177 +      double *bbar; /* double bbar[1+m]; */
 316.178 +      /* bbar[0] is not used on phase I; on phase II it is the current
 316.179 +         value of the original objective function;
 316.180 +         bbar[i], 1 <= i <= m, is primal value of basic variable xB[i]
 316.181 +         (if xB[i] is free, its primal value is not updated) */
 316.182 +      double *cbar; /* double cbar[1+n]; */
 316.183 +      /* cbar[0] is not used;
 316.184 +         cbar[j], 1 <= j <= n, is reduced cost of non-basic variable
 316.185 +         xN[j] (if xN[j] is fixed, its reduced cost is not updated) */
 316.186 +      /*--------------------------------------------------------------*/
 316.187 +      /* the following pricing technique options may be used:
 316.188 +         GLP_PT_STD - standard ("textbook") pricing;
 316.189 +         GLP_PT_PSE - projected steepest edge;
 316.190 +         GLP_PT_DVX - Devex pricing (not implemented yet);
 316.191 +         in case of GLP_PT_STD the reference space is not used, and all
 316.192 +         steepest edge coefficients are set to 1 */
 316.193 +      int refct;
 316.194 +      /* this count is set to an initial value when the reference space
 316.195 +         is defined and decreases by one every time the basis changes;
 316.196 +         once this count reaches zero, the reference space is redefined
 316.197 +         again */
 316.198 +      char *refsp; /* char refsp[1+m+n]; */
 316.199 +      /* refsp[0] is not used;
 316.200 +         refsp[k], 1 <= k <= m+n, is the flag which means that variable
 316.201 +         x[k] belongs to the current reference space */
 316.202 +      double *gamma; /* double gamma[1+m]; */
 316.203 +      /* gamma[0] is not used;
 316.204 +         gamma[i], 1 <= i <= n, is the steepest edge coefficient for
 316.205 +         basic variable xB[i]; if xB[i] is free, gamma[i] is not used
 316.206 +         and just set to 1 */
 316.207 +      /*--------------------------------------------------------------*/
 316.208 +      /* basic variable xB[p] chosen to leave the basis */
 316.209 +      int p;
 316.210 +      /* index of the basic variable xB[p] chosen, 1 <= p <= m;
 316.211 +         if the set of eligible basic variables is empty (i.e. if the
 316.212 +         current basic solution is primal feasible within a tolerance)
 316.213 +         and thus no variable has been chosen, p is set to 0 */
 316.214 +      double delta;
 316.215 +      /* change of xB[p] in the adjacent basis;
 316.216 +         delta > 0 means that xB[p] violates its lower bound and will
 316.217 +         increase to achieve it in the adjacent basis;
 316.218 +         delta < 0 means that xB[p] violates its upper bound and will
 316.219 +         decrease to achieve it in the adjacent basis */
 316.220 +      /*--------------------------------------------------------------*/
 316.221 +      /* pivot row of the simplex table corresponding to basic variable
 316.222 +         xB[p] chosen is the following vector:
 316.223 +            T' * e[p] = - N' * inv(B') * e[p] = - N' * rho,
 316.224 +         where B' is a matrix transposed to the current basis matrix,
 316.225 +         N' is a matrix, whose rows are columns of the matrix (I|-A)
 316.226 +         corresponding to non-basic non-fixed variables */
 316.227 +      int trow_nnz;
 316.228 +      /* number of non-zero components, 0 <= nnz <= n */
 316.229 +      int *trow_ind; /* int trow_ind[1+n]; */
 316.230 +      /* trow_ind[0] is not used;
 316.231 +         trow_ind[t], 1 <= t <= nnz, is an index of non-zero component,
 316.232 +         i.e. trow_ind[t] = j means that trow_vec[j] != 0 */
 316.233 +      double *trow_vec; /* int trow_vec[1+n]; */
 316.234 +      /* trow_vec[0] is not used;
 316.235 +         trow_vec[j], 1 <= j <= n, is a numeric value of j-th component
 316.236 +         of the row */
 316.237 +      double trow_max;
 316.238 +      /* infinity (maximum) norm of the row (max |trow_vec[j]|) */
 316.239 +      int trow_num;
 316.240 +      /* number of significant non-zero components, which means that:
 316.241 +         |trow_vec[j]| >= eps for j in trow_ind[1,...,num],
 316.242 +         |tcol_vec[j]| <  eps for j in trow_ind[num+1,...,nnz],
 316.243 +         where eps is a pivot tolerance */
 316.244 +      /*--------------------------------------------------------------*/
 316.245 +#ifdef GLP_LONG_STEP /* 07/IV-2009 */
 316.246 +      int nbps;
 316.247 +      /* number of breakpoints, 0 <= nbps <= n */
 316.248 +      struct bkpt
 316.249 +      {     int j;
 316.250 +            /* index of non-basic variable xN[j], 1 <= j <= n */
 316.251 +            double t;
 316.252 +            /* value of dual ray parameter at breakpoint, t >= 0 */
 316.253 +            double dz;
 316.254 +            /* dz = zeta(t = t[k]) - zeta(t = 0) */
 316.255 +      } *bkpt; /* struct bkpt bkpt[1+n]; */
 316.256 +      /* bkpt[0] is not used;
 316.257 +         bkpt[k], 1 <= k <= nbps, is k-th breakpoint of the dual
 316.258 +         objective */
 316.259 +#endif
 316.260 +      /*--------------------------------------------------------------*/
 316.261 +      /* non-basic variable xN[q] chosen to enter the basis */
 316.262 +      int q;
 316.263 +      /* index of the non-basic variable xN[q] chosen, 1 <= q <= n;
 316.264 +         if no variable has been chosen, q is set to 0 */
 316.265 +      double new_dq;
 316.266 +      /* reduced cost of xN[q] in the adjacent basis (it is the change
 316.267 +         of lambdaB[p]) */
 316.268 +      /*--------------------------------------------------------------*/
 316.269 +      /* pivot column of the simplex table corresponding to non-basic
 316.270 +         variable xN[q] chosen is the following vector:
 316.271 +            T * e[q] = - inv(B) * N * e[q] = - inv(B) * N[q],
 316.272 +         where B is the current basis matrix, N[q] is a column of the
 316.273 +         matrix (I|-A) corresponding to xN[q] */
 316.274 +      int tcol_nnz;
 316.275 +      /* number of non-zero components, 0 <= nnz <= m */
 316.276 +      int *tcol_ind; /* int tcol_ind[1+m]; */
 316.277 +      /* tcol_ind[0] is not used;
 316.278 +         tcol_ind[t], 1 <= t <= nnz, is an index of non-zero component,
 316.279 +         i.e. tcol_ind[t] = i means that tcol_vec[i] != 0 */
 316.280 +      double *tcol_vec; /* double tcol_vec[1+m]; */
 316.281 +      /* tcol_vec[0] is not used;
 316.282 +         tcol_vec[i], 1 <= i <= m, is a numeric value of i-th component
 316.283 +         of the column */
 316.284 +      /*--------------------------------------------------------------*/
 316.285 +      /* working arrays */
 316.286 +      double *work1; /* double work1[1+m]; */
 316.287 +      double *work2; /* double work2[1+m]; */
 316.288 +      double *work3; /* double work3[1+m]; */
 316.289 +      double *work4; /* double work4[1+m]; */
 316.290 +};
 316.291 +
 316.292 +static const double kappa = 0.10;
 316.293 +
 316.294 +/***********************************************************************
 316.295 +*  alloc_csa - allocate common storage area
 316.296 +*
 316.297 +*  This routine allocates all arrays in the common storage area (CSA)
 316.298 +*  and returns a pointer to the CSA. */
 316.299 +
 316.300 +static struct csa *alloc_csa(glp_prob *lp)
 316.301 +{     struct csa *csa;
 316.302 +      int m = lp->m;
 316.303 +      int n = lp->n;
 316.304 +      int nnz = lp->nnz;
 316.305 +      csa = xmalloc(sizeof(struct csa));
 316.306 +      xassert(m > 0 && n > 0);
 316.307 +      csa->m = m;
 316.308 +      csa->n = n;
 316.309 +      csa->type = xcalloc(1+m+n, sizeof(char));
 316.310 +      csa->lb = xcalloc(1+m+n, sizeof(double));
 316.311 +      csa->ub = xcalloc(1+m+n, sizeof(double));
 316.312 +      csa->coef = xcalloc(1+m+n, sizeof(double));
 316.313 +      csa->orig_type = xcalloc(1+m+n, sizeof(char));
 316.314 +      csa->orig_lb = xcalloc(1+m+n, sizeof(double));
 316.315 +      csa->orig_ub = xcalloc(1+m+n, sizeof(double));
 316.316 +      csa->obj = xcalloc(1+n, sizeof(double));
 316.317 +      csa->A_ptr = xcalloc(1+n+1, sizeof(int));
 316.318 +      csa->A_ind = xcalloc(1+nnz, sizeof(int));
 316.319 +      csa->A_val = xcalloc(1+nnz, sizeof(double));
 316.320 +#if 1 /* 06/IV-2009 */
 316.321 +      csa->AT_ptr = xcalloc(1+m+1, sizeof(int));
 316.322 +      csa->AT_ind = xcalloc(1+nnz, sizeof(int));
 316.323 +      csa->AT_val = xcalloc(1+nnz, sizeof(double));
 316.324 +#endif
 316.325 +      csa->head = xcalloc(1+m+n, sizeof(int));
 316.326 +#if 1 /* 06/IV-2009 */
 316.327 +      csa->bind = xcalloc(1+m+n, sizeof(int));
 316.328 +#endif
 316.329 +      csa->stat = xcalloc(1+n, sizeof(char));
 316.330 +#if 0 /* 06/IV-2009 */
 316.331 +      csa->N_ptr = xcalloc(1+m+1, sizeof(int));
 316.332 +      csa->N_len = xcalloc(1+m, sizeof(int));
 316.333 +      csa->N_ind = NULL; /* will be allocated later */
 316.334 +      csa->N_val = NULL; /* will be allocated later */
 316.335 +#endif
 316.336 +      csa->bbar = xcalloc(1+m, sizeof(double));
 316.337 +      csa->cbar = xcalloc(1+n, sizeof(double));
 316.338 +      csa->refsp = xcalloc(1+m+n, sizeof(char));
 316.339 +      csa->gamma = xcalloc(1+m, sizeof(double));
 316.340 +      csa->trow_ind = xcalloc(1+n, sizeof(int));
 316.341 +      csa->trow_vec = xcalloc(1+n, sizeof(double));
 316.342 +#ifdef GLP_LONG_STEP /* 07/IV-2009 */
 316.343 +      csa->bkpt = xcalloc(1+n, sizeof(struct bkpt));
 316.344 +#endif
 316.345 +      csa->tcol_ind = xcalloc(1+m, sizeof(int));
 316.346 +      csa->tcol_vec = xcalloc(1+m, sizeof(double));
 316.347 +      csa->work1 = xcalloc(1+m, sizeof(double));
 316.348 +      csa->work2 = xcalloc(1+m, sizeof(double));
 316.349 +      csa->work3 = xcalloc(1+m, sizeof(double));
 316.350 +      csa->work4 = xcalloc(1+m, sizeof(double));
 316.351 +      return csa;
 316.352 +}
 316.353 +
 316.354 +/***********************************************************************
 316.355 +*  init_csa - initialize common storage area
 316.356 +*
 316.357 +*  This routine initializes all data structures in the common storage
 316.358 +*  area (CSA). */
 316.359 +
 316.360 +static void init_csa(struct csa *csa, glp_prob *lp)
 316.361 +{     int m = csa->m;
 316.362 +      int n = csa->n;
 316.363 +      char *type = csa->type;
 316.364 +      double *lb = csa->lb;
 316.365 +      double *ub = csa->ub;
 316.366 +      double *coef = csa->coef;
 316.367 +      char *orig_type = csa->orig_type;
 316.368 +      double *orig_lb = csa->orig_lb;
 316.369 +      double *orig_ub = csa->orig_ub;
 316.370 +      double *obj = csa->obj;
 316.371 +      int *A_ptr = csa->A_ptr;
 316.372 +      int *A_ind = csa->A_ind;
 316.373 +      double *A_val = csa->A_val;
 316.374 +#if 1 /* 06/IV-2009 */
 316.375 +      int *AT_ptr = csa->AT_ptr;
 316.376 +      int *AT_ind = csa->AT_ind;
 316.377 +      double *AT_val = csa->AT_val;
 316.378 +#endif
 316.379 +      int *head = csa->head;
 316.380 +#if 1 /* 06/IV-2009 */
 316.381 +      int *bind = csa->bind;
 316.382 +#endif
 316.383 +      char *stat = csa->stat;
 316.384 +      char *refsp = csa->refsp;
 316.385 +      double *gamma = csa->gamma;
 316.386 +      int i, j, k, loc;
 316.387 +      double cmax;
 316.388 +      /* auxiliary variables */
 316.389 +      for (i = 1; i <= m; i++)
 316.390 +      {  GLPROW *row = lp->row[i];
 316.391 +         type[i] = (char)row->type;
 316.392 +         lb[i] = row->lb * row->rii;
 316.393 +         ub[i] = row->ub * row->rii;
 316.394 +         coef[i] = 0.0;
 316.395 +      }
 316.396 +      /* structural variables */
 316.397 +      for (j = 1; j <= n; j++)
 316.398 +      {  GLPCOL *col = lp->col[j];
 316.399 +         type[m+j] = (char)col->type;
 316.400 +         lb[m+j] = col->lb / col->sjj;
 316.401 +         ub[m+j] = col->ub / col->sjj;
 316.402 +         coef[m+j] = col->coef * col->sjj;
 316.403 +      }
 316.404 +      /* original bounds of variables */
 316.405 +      memcpy(&orig_type[1], &type[1], (m+n) * sizeof(char));
 316.406 +      memcpy(&orig_lb[1], &lb[1], (m+n) * sizeof(double));
 316.407 +      memcpy(&orig_ub[1], &ub[1], (m+n) * sizeof(double));
 316.408 +      /* original objective function */
 316.409 +      obj[0] = lp->c0;
 316.410 +      memcpy(&obj[1], &coef[m+1], n * sizeof(double));
 316.411 +      /* factor used to scale original objective coefficients */
 316.412 +      cmax = 0.0;
 316.413 +      for (j = 1; j <= n; j++)
 316.414 +         if (cmax < fabs(obj[j])) cmax = fabs(obj[j]);
 316.415 +      if (cmax == 0.0) cmax = 1.0;
 316.416 +      switch (lp->dir)
 316.417 +      {  case GLP_MIN:
 316.418 +            csa->zeta = + 1.0 / cmax;
 316.419 +            break;
 316.420 +         case GLP_MAX:
 316.421 +            csa->zeta = - 1.0 / cmax;
 316.422 +            break;
 316.423 +         default:
 316.424 +            xassert(lp != lp);
 316.425 +      }
 316.426 +#if 1
 316.427 +      if (fabs(csa->zeta) < 1.0) csa->zeta *= 1000.0;
 316.428 +#endif
 316.429 +      /* scale working objective coefficients */
 316.430 +      for (j = 1; j <= n; j++) coef[m+j] *= csa->zeta;
 316.431 +      /* matrix A (by columns) */
 316.432 +      loc = 1;
 316.433 +      for (j = 1; j <= n; j++)
 316.434 +      {  GLPAIJ *aij;
 316.435 +         A_ptr[j] = loc;
 316.436 +         for (aij = lp->col[j]->ptr; aij != NULL; aij = aij->c_next)
 316.437 +         {  A_ind[loc] = aij->row->i;
 316.438 +            A_val[loc] = aij->row->rii * aij->val * aij->col->sjj;
 316.439 +            loc++;
 316.440 +         }
 316.441 +      }
 316.442 +      A_ptr[n+1] = loc;
 316.443 +      xassert(loc-1 == lp->nnz);
 316.444 +#if 1 /* 06/IV-2009 */
 316.445 +      /* matrix A (by rows) */
 316.446 +      loc = 1;
 316.447 +      for (i = 1; i <= m; i++)
 316.448 +      {  GLPAIJ *aij;
 316.449 +         AT_ptr[i] = loc;
 316.450 +         for (aij = lp->row[i]->ptr; aij != NULL; aij = aij->r_next)
 316.451 +         {  AT_ind[loc] = aij->col->j;
 316.452 +            AT_val[loc] = aij->row->rii * aij->val * aij->col->sjj;
 316.453 +            loc++;
 316.454 +         }
 316.455 +      }
 316.456 +      AT_ptr[m+1] = loc;
 316.457 +      xassert(loc-1 == lp->nnz);
 316.458 +#endif
 316.459 +      /* basis header */
 316.460 +      xassert(lp->valid);
 316.461 +      memcpy(&head[1], &lp->head[1], m * sizeof(int));
 316.462 +      k = 0;
 316.463 +      for (i = 1; i <= m; i++)
 316.464 +      {  GLPROW *row = lp->row[i];
 316.465 +         if (row->stat != GLP_BS)
 316.466 +         {  k++;
 316.467 +            xassert(k <= n);
 316.468 +            head[m+k] = i;
 316.469 +            stat[k] = (char)row->stat;
 316.470 +         }
 316.471 +      }
 316.472 +      for (j = 1; j <= n; j++)
 316.473 +      {  GLPCOL *col = lp->col[j];
 316.474 +         if (col->stat != GLP_BS)
 316.475 +         {  k++;
 316.476 +            xassert(k <= n);
 316.477 +            head[m+k] = m + j;
 316.478 +            stat[k] = (char)col->stat;
 316.479 +         }
 316.480 +      }
 316.481 +      xassert(k == n);
 316.482 +#if 1 /* 06/IV-2009 */
 316.483 +      for (k = 1; k <= m+n; k++)
 316.484 +         bind[head[k]] = k;
 316.485 +#endif
 316.486 +      /* factorization of matrix B */
 316.487 +      csa->valid = 1, lp->valid = 0;
 316.488 +      csa->bfd = lp->bfd, lp->bfd = NULL;
 316.489 +#if 0 /* 06/IV-2009 */
 316.490 +      /* matrix N (by rows) */
 316.491 +      alloc_N(csa);
 316.492 +      build_N(csa);
 316.493 +#endif
 316.494 +      /* working parameters */
 316.495 +      csa->phase = 0;
 316.496 +      csa->tm_beg = xtime();
 316.497 +      csa->it_beg = csa->it_cnt = lp->it_cnt;
 316.498 +      csa->it_dpy = -1;
 316.499 +      /* reference space and steepest edge coefficients */
 316.500 +      csa->refct = 0;
 316.501 +      memset(&refsp[1], 0, (m+n) * sizeof(char));
 316.502 +      for (i = 1; i <= m; i++) gamma[i] = 1.0;
 316.503 +      return;
 316.504 +}
 316.505 +
 316.506 +#if 1 /* copied from primal */
 316.507 +/***********************************************************************
 316.508 +*  invert_B - compute factorization of the basis matrix
 316.509 +*
 316.510 +*  This routine computes factorization of the current basis matrix B.
 316.511 +*
 316.512 +*  If the operation is successful, the routine returns zero, otherwise
 316.513 +*  non-zero. */
 316.514 +
 316.515 +static int inv_col(void *info, int i, int ind[], double val[])
 316.516 +{     /* this auxiliary routine returns row indices and numeric values
 316.517 +         of non-zero elements of i-th column of the basis matrix */
 316.518 +      struct csa *csa = info;
 316.519 +      int m = csa->m;
 316.520 +#ifdef GLP_DEBUG
 316.521 +      int n = csa->n;
 316.522 +#endif
 316.523 +      int *A_ptr = csa->A_ptr;
 316.524 +      int *A_ind = csa->A_ind;
 316.525 +      double *A_val = csa->A_val;
 316.526 +      int *head = csa->head;
 316.527 +      int k, len, ptr, t;
 316.528 +#ifdef GLP_DEBUG
 316.529 +      xassert(1 <= i && i <= m);
 316.530 +#endif
 316.531 +      k = head[i]; /* B[i] is k-th column of (I|-A) */
 316.532 +#ifdef GLP_DEBUG
 316.533 +      xassert(1 <= k && k <= m+n);
 316.534 +#endif
 316.535 +      if (k <= m)
 316.536 +      {  /* B[i] is k-th column of submatrix I */
 316.537 +         len = 1;
 316.538 +         ind[1] = k;
 316.539 +         val[1] = 1.0;
 316.540 +      }
 316.541 +      else
 316.542 +      {  /* B[i] is (k-m)-th column of submatrix (-A) */
 316.543 +         ptr = A_ptr[k-m];
 316.544 +         len = A_ptr[k-m+1] - ptr;
 316.545 +         memcpy(&ind[1], &A_ind[ptr], len * sizeof(int));
 316.546 +         memcpy(&val[1], &A_val[ptr], len * sizeof(double));
 316.547 +         for (t = 1; t <= len; t++) val[t] = - val[t];
 316.548 +      }
 316.549 +      return len;
 316.550 +}
 316.551 +
 316.552 +static int invert_B(struct csa *csa)
 316.553 +{     int ret;
 316.554 +      ret = bfd_factorize(csa->bfd, csa->m, NULL, inv_col, csa);
 316.555 +      csa->valid = (ret == 0);
 316.556 +      return ret;
 316.557 +}
 316.558 +#endif
 316.559 +
 316.560 +#if 1 /* copied from primal */
 316.561 +/***********************************************************************
 316.562 +*  update_B - update factorization of the basis matrix
 316.563 +*
 316.564 +*  This routine replaces i-th column of the basis matrix B by k-th
 316.565 +*  column of the augmented constraint matrix (I|-A) and then updates
 316.566 +*  the factorization of B.
 316.567 +*
 316.568 +*  If the factorization has been successfully updated, the routine
 316.569 +*  returns zero, otherwise non-zero. */
 316.570 +
 316.571 +static int update_B(struct csa *csa, int i, int k)
 316.572 +{     int m = csa->m;
 316.573 +#ifdef GLP_DEBUG
 316.574 +      int n = csa->n;
 316.575 +#endif
 316.576 +      int ret;
 316.577 +#ifdef GLP_DEBUG
 316.578 +      xassert(1 <= i && i <= m);
 316.579 +      xassert(1 <= k && k <= m+n);
 316.580 +#endif
 316.581 +      if (k <= m)
 316.582 +      {  /* new i-th column of B is k-th column of I */
 316.583 +         int ind[1+1];
 316.584 +         double val[1+1];
 316.585 +         ind[1] = k;
 316.586 +         val[1] = 1.0;
 316.587 +         xassert(csa->valid);
 316.588 +         ret = bfd_update_it(csa->bfd, i, 0, 1, ind, val);
 316.589 +      }
 316.590 +      else
 316.591 +      {  /* new i-th column of B is (k-m)-th column of (-A) */
 316.592 +         int *A_ptr = csa->A_ptr;
 316.593 +         int *A_ind = csa->A_ind;
 316.594 +         double *A_val = csa->A_val;
 316.595 +         double *val = csa->work1;
 316.596 +         int beg, end, ptr, len;
 316.597 +         beg = A_ptr[k-m];
 316.598 +         end = A_ptr[k-m+1];
 316.599 +         len = 0;
 316.600 +         for (ptr = beg; ptr < end; ptr++)
 316.601 +            val[++len] = - A_val[ptr];
 316.602 +         xassert(csa->valid);
 316.603 +         ret = bfd_update_it(csa->bfd, i, 0, len, &A_ind[beg-1], val);
 316.604 +      }
 316.605 +      csa->valid = (ret == 0);
 316.606 +      return ret;
 316.607 +}
 316.608 +#endif
 316.609 +
 316.610 +#if 1 /* copied from primal */
 316.611 +/***********************************************************************
 316.612 +*  error_ftran - compute residual vector r = h - B * x
 316.613 +*
 316.614 +*  This routine computes the residual vector r = h - B * x, where B is
 316.615 +*  the current basis matrix, h is the vector of right-hand sides, x is
 316.616 +*  the solution vector. */
 316.617 +
 316.618 +static void error_ftran(struct csa *csa, double h[], double x[],
 316.619 +      double r[])
 316.620 +{     int m = csa->m;
 316.621 +#ifdef GLP_DEBUG
 316.622 +      int n = csa->n;
 316.623 +#endif
 316.624 +      int *A_ptr = csa->A_ptr;
 316.625 +      int *A_ind = csa->A_ind;
 316.626 +      double *A_val = csa->A_val;
 316.627 +      int *head = csa->head;
 316.628 +      int i, k, beg, end, ptr;
 316.629 +      double temp;
 316.630 +      /* compute the residual vector:
 316.631 +         r = h - B * x = h - B[1] * x[1] - ... - B[m] * x[m],
 316.632 +         where B[1], ..., B[m] are columns of matrix B */
 316.633 +      memcpy(&r[1], &h[1], m * sizeof(double));
 316.634 +      for (i = 1; i <= m; i++)
 316.635 +      {  temp = x[i];
 316.636 +         if (temp == 0.0) continue;
 316.637 +         k = head[i]; /* B[i] is k-th column of (I|-A) */
 316.638 +#ifdef GLP_DEBUG
 316.639 +         xassert(1 <= k && k <= m+n);
 316.640 +#endif
 316.641 +         if (k <= m)
 316.642 +         {  /* B[i] is k-th column of submatrix I */
 316.643 +            r[k] -= temp;
 316.644 +         }
 316.645 +         else
 316.646 +         {  /* B[i] is (k-m)-th column of submatrix (-A) */
 316.647 +            beg = A_ptr[k-m];
 316.648 +            end = A_ptr[k-m+1];
 316.649 +            for (ptr = beg; ptr < end; ptr++)
 316.650 +               r[A_ind[ptr]] += A_val[ptr] * temp;
 316.651 +         }
 316.652 +      }
 316.653 +      return;
 316.654 +}
 316.655 +#endif
 316.656 +
 316.657 +#if 1 /* copied from primal */
 316.658 +/***********************************************************************
 316.659 +*  refine_ftran - refine solution of B * x = h
 316.660 +*
 316.661 +*  This routine performs one iteration to refine the solution of
 316.662 +*  the system B * x = h, where B is the current basis matrix, h is the
 316.663 +*  vector of right-hand sides, x is the solution vector. */
 316.664 +
 316.665 +static void refine_ftran(struct csa *csa, double h[], double x[])
 316.666 +{     int m = csa->m;
 316.667 +      double *r = csa->work1;
 316.668 +      double *d = csa->work1;
 316.669 +      int i;
 316.670 +      /* compute the residual vector r = h - B * x */
 316.671 +      error_ftran(csa, h, x, r);
 316.672 +      /* compute the correction vector d = inv(B) * r */
 316.673 +      xassert(csa->valid);
 316.674 +      bfd_ftran(csa->bfd, d);
 316.675 +      /* refine the solution vector (new x) = (old x) + d */
 316.676 +      for (i = 1; i <= m; i++) x[i] += d[i];
 316.677 +      return;
 316.678 +}
 316.679 +#endif
 316.680 +
 316.681 +#if 1 /* copied from primal */
 316.682 +/***********************************************************************
 316.683 +*  error_btran - compute residual vector r = h - B'* x
 316.684 +*
 316.685 +*  This routine computes the residual vector r = h - B'* x, where B'
 316.686 +*  is a matrix transposed to the current basis matrix, h is the vector
 316.687 +*  of right-hand sides, x is the solution vector. */
 316.688 +
 316.689 +static void error_btran(struct csa *csa, double h[], double x[],
 316.690 +      double r[])
 316.691 +{     int m = csa->m;
 316.692 +#ifdef GLP_DEBUG
 316.693 +      int n = csa->n;
 316.694 +#endif
 316.695 +      int *A_ptr = csa->A_ptr;
 316.696 +      int *A_ind = csa->A_ind;
 316.697 +      double *A_val = csa->A_val;
 316.698 +      int *head = csa->head;
 316.699 +      int i, k, beg, end, ptr;
 316.700 +      double temp;
 316.701 +      /* compute the residual vector r = b - B'* x */
 316.702 +      for (i = 1; i <= m; i++)
 316.703 +      {  /* r[i] := b[i] - (i-th column of B)'* x */
 316.704 +         k = head[i]; /* B[i] is k-th column of (I|-A) */
 316.705 +#ifdef GLP_DEBUG
 316.706 +         xassert(1 <= k && k <= m+n);
 316.707 +#endif
 316.708 +         temp = h[i];
 316.709 +         if (k <= m)
 316.710 +         {  /* B[i] is k-th column of submatrix I */
 316.711 +            temp -= x[k];
 316.712 +         }
 316.713 +         else
 316.714 +         {  /* B[i] is (k-m)-th column of submatrix (-A) */
 316.715 +            beg = A_ptr[k-m];
 316.716 +            end = A_ptr[k-m+1];
 316.717 +            for (ptr = beg; ptr < end; ptr++)
 316.718 +               temp += A_val[ptr] * x[A_ind[ptr]];
 316.719 +         }
 316.720 +         r[i] = temp;
 316.721 +      }
 316.722 +      return;
 316.723 +}
 316.724 +#endif
 316.725 +
 316.726 +#if 1 /* copied from primal */
 316.727 +/***********************************************************************
 316.728 +*  refine_btran - refine solution of B'* x = h
 316.729 +*
 316.730 +*  This routine performs one iteration to refine the solution of the
 316.731 +*  system B'* x = h, where B' is a matrix transposed to the current
 316.732 +*  basis matrix, h is the vector of right-hand sides, x is the solution
 316.733 +*  vector. */
 316.734 +
 316.735 +static void refine_btran(struct csa *csa, double h[], double x[])
 316.736 +{     int m = csa->m;
 316.737 +      double *r = csa->work1;
 316.738 +      double *d = csa->work1;
 316.739 +      int i;
 316.740 +      /* compute the residual vector r = h - B'* x */
 316.741 +      error_btran(csa, h, x, r);
 316.742 +      /* compute the correction vector d = inv(B') * r */
 316.743 +      xassert(csa->valid);
 316.744 +      bfd_btran(csa->bfd, d);
 316.745 +      /* refine the solution vector (new x) = (old x) + d */
 316.746 +      for (i = 1; i <= m; i++) x[i] += d[i];
 316.747 +      return;
 316.748 +}
 316.749 +#endif
 316.750 +
 316.751 +#if 1 /* copied from primal */
 316.752 +/***********************************************************************
 316.753 +*  get_xN - determine current value of non-basic variable xN[j]
 316.754 +*
 316.755 +*  This routine returns the current value of non-basic variable xN[j],
 316.756 +*  which is a value of its active bound. */
 316.757 +
 316.758 +static double get_xN(struct csa *csa, int j)
 316.759 +{     int m = csa->m;
 316.760 +#ifdef GLP_DEBUG
 316.761 +      int n = csa->n;
 316.762 +#endif
 316.763 +      double *lb = csa->lb;
 316.764 +      double *ub = csa->ub;
 316.765 +      int *head = csa->head;
 316.766 +      char *stat = csa->stat;
 316.767 +      int k;
 316.768 +      double xN;
 316.769 +#ifdef GLP_DEBUG
 316.770 +      xassert(1 <= j && j <= n);
 316.771 +#endif
 316.772 +      k = head[m+j]; /* x[k] = xN[j] */
 316.773 +#ifdef GLP_DEBUG
 316.774 +      xassert(1 <= k && k <= m+n);
 316.775 +#endif
 316.776 +      switch (stat[j])
 316.777 +      {  case GLP_NL:
 316.778 +            /* x[k] is on its lower bound */
 316.779 +            xN = lb[k]; break;
 316.780 +         case GLP_NU:
 316.781 +            /* x[k] is on its upper bound */
 316.782 +            xN = ub[k]; break;
 316.783 +         case GLP_NF:
 316.784 +            /* x[k] is free non-basic variable */
 316.785 +            xN = 0.0; break;
 316.786 +         case GLP_NS:
 316.787 +            /* x[k] is fixed non-basic variable */
 316.788 +            xN = lb[k]; break;
 316.789 +         default:
 316.790 +            xassert(stat != stat);
 316.791 +      }
 316.792 +      return xN;
 316.793 +}
 316.794 +#endif
 316.795 +
 316.796 +#if 1 /* copied from primal */
 316.797 +/***********************************************************************
 316.798 +*  eval_beta - compute primal values of basic variables
 316.799 +*
 316.800 +*  This routine computes current primal values of all basic variables:
 316.801 +*
 316.802 +*     beta = - inv(B) * N * xN,
 316.803 +*
 316.804 +*  where B is the current basis matrix, N is a matrix built of columns
 316.805 +*  of matrix (I|-A) corresponding to non-basic variables, and xN is the
 316.806 +*  vector of current values of non-basic variables. */
 316.807 +
 316.808 +static void eval_beta(struct csa *csa, double beta[])
 316.809 +{     int m = csa->m;
 316.810 +      int n = csa->n;
 316.811 +      int *A_ptr = csa->A_ptr;
 316.812 +      int *A_ind = csa->A_ind;
 316.813 +      double *A_val = csa->A_val;
 316.814 +      int *head = csa->head;
 316.815 +      double *h = csa->work2;
 316.816 +      int i, j, k, beg, end, ptr;
 316.817 +      double xN;
 316.818 +      /* compute the right-hand side vector:
 316.819 +         h := - N * xN = - N[1] * xN[1] - ... - N[n] * xN[n],
 316.820 +         where N[1], ..., N[n] are columns of matrix N */
 316.821 +      for (i = 1; i <= m; i++)
 316.822 +         h[i] = 0.0;
 316.823 +      for (j = 1; j <= n; j++)
 316.824 +      {  k = head[m+j]; /* x[k] = xN[j] */
 316.825 +#ifdef GLP_DEBUG
 316.826 +         xassert(1 <= k && k <= m+n);
 316.827 +#endif
 316.828 +         /* determine current value of xN[j] */
 316.829 +         xN = get_xN(csa, j);
 316.830 +         if (xN == 0.0) continue;
 316.831 +         if (k <= m)
 316.832 +         {  /* N[j] is k-th column of submatrix I */
 316.833 +            h[k] -= xN;
 316.834 +         }
 316.835 +         else
 316.836 +         {  /* N[j] is (k-m)-th column of submatrix (-A) */
 316.837 +            beg = A_ptr[k-m];
 316.838 +            end = A_ptr[k-m+1];
 316.839 +            for (ptr = beg; ptr < end; ptr++)
 316.840 +               h[A_ind[ptr]] += xN * A_val[ptr];
 316.841 +         }
 316.842 +      }
 316.843 +      /* solve system B * beta = h */
 316.844 +      memcpy(&beta[1], &h[1], m * sizeof(double));
 316.845 +      xassert(csa->valid);
 316.846 +      bfd_ftran(csa->bfd, beta);
 316.847 +      /* and refine the solution */
 316.848 +      refine_ftran(csa, h, beta);
 316.849 +      return;
 316.850 +}
 316.851 +#endif
 316.852 +
 316.853 +#if 1 /* copied from primal */
 316.854 +/***********************************************************************
 316.855 +*  eval_pi - compute vector of simplex multipliers
 316.856 +*
 316.857 +*  This routine computes the vector of current simplex multipliers:
 316.858 +*
 316.859 +*     pi = inv(B') * cB,
 316.860 +*
 316.861 +*  where B' is a matrix transposed to the current basis matrix, cB is
 316.862 +*  a subvector of objective coefficients at basic variables. */
 316.863 +
 316.864 +static void eval_pi(struct csa *csa, double pi[])
 316.865 +{     int m = csa->m;
 316.866 +      double *c = csa->coef;
 316.867 +      int *head = csa->head;
 316.868 +      double *cB = csa->work2;
 316.869 +      int i;
 316.870 +      /* construct the right-hand side vector cB */
 316.871 +      for (i = 1; i <= m; i++)
 316.872 +         cB[i] = c[head[i]];
 316.873 +      /* solve system B'* pi = cB */
 316.874 +      memcpy(&pi[1], &cB[1], m * sizeof(double));
 316.875 +      xassert(csa->valid);
 316.876 +      bfd_btran(csa->bfd, pi);
 316.877 +      /* and refine the solution */
 316.878 +      refine_btran(csa, cB, pi);
 316.879 +      return;
 316.880 +}
 316.881 +#endif
 316.882 +
 316.883 +#if 1 /* copied from primal */
 316.884 +/***********************************************************************
 316.885 +*  eval_cost - compute reduced cost of non-basic variable xN[j]
 316.886 +*
 316.887 +*  This routine computes the current reduced cost of non-basic variable
 316.888 +*  xN[j]:
 316.889 +*
 316.890 +*     d[j] = cN[j] - N'[j] * pi,
 316.891 +*
 316.892 +*  where cN[j] is the objective coefficient at variable xN[j], N[j] is
 316.893 +*  a column of the augmented constraint matrix (I|-A) corresponding to
 316.894 +*  xN[j], pi is the vector of simplex multipliers. */
 316.895 +
 316.896 +static double eval_cost(struct csa *csa, double pi[], int j)
 316.897 +{     int m = csa->m;
 316.898 +#ifdef GLP_DEBUG
 316.899 +      int n = csa->n;
 316.900 +#endif
 316.901 +      double *coef = csa->coef;
 316.902 +      int *head = csa->head;
 316.903 +      int k;
 316.904 +      double dj;
 316.905 +#ifdef GLP_DEBUG
 316.906 +      xassert(1 <= j && j <= n);
 316.907 +#endif
 316.908 +      k = head[m+j]; /* x[k] = xN[j] */
 316.909 +#ifdef GLP_DEBUG
 316.910 +      xassert(1 <= k && k <= m+n);
 316.911 +#endif
 316.912 +      dj = coef[k];
 316.913 +      if (k <= m)
 316.914 +      {  /* N[j] is k-th column of submatrix I */
 316.915 +         dj -= pi[k];
 316.916 +      }
 316.917 +      else
 316.918 +      {  /* N[j] is (k-m)-th column of submatrix (-A) */
 316.919 +         int *A_ptr = csa->A_ptr;
 316.920 +         int *A_ind = csa->A_ind;
 316.921 +         double *A_val = csa->A_val;
 316.922 +         int beg, end, ptr;
 316.923 +         beg = A_ptr[k-m];
 316.924 +         end = A_ptr[k-m+1];
 316.925 +         for (ptr = beg; ptr < end; ptr++)
 316.926 +            dj += A_val[ptr] * pi[A_ind[ptr]];
 316.927 +      }
 316.928 +      return dj;
 316.929 +}
 316.930 +#endif
 316.931 +
 316.932 +#if 1 /* copied from primal */
 316.933 +/***********************************************************************
 316.934 +*  eval_bbar - compute and store primal values of basic variables
 316.935 +*
 316.936 +*  This routine computes primal values of all basic variables and then
 316.937 +*  stores them in the solution array. */
 316.938 +
 316.939 +static void eval_bbar(struct csa *csa)
 316.940 +{     eval_beta(csa, csa->bbar);
 316.941 +      return;
 316.942 +}
 316.943 +#endif
 316.944 +
 316.945 +#if 1 /* copied from primal */
 316.946 +/***********************************************************************
 316.947 +*  eval_cbar - compute and store reduced costs of non-basic variables
 316.948 +*
 316.949 +*  This routine computes reduced costs of all non-basic variables and
 316.950 +*  then stores them in the solution array. */
 316.951 +
 316.952 +static void eval_cbar(struct csa *csa)
 316.953 +{
 316.954 +#ifdef GLP_DEBUG
 316.955 +      int m = csa->m;
 316.956 +#endif
 316.957 +      int n = csa->n;
 316.958 +#ifdef GLP_DEBUG
 316.959 +      int *head = csa->head;
 316.960 +#endif
 316.961 +      double *cbar = csa->cbar;
 316.962 +      double *pi = csa->work3;
 316.963 +      int j;
 316.964 +#ifdef GLP_DEBUG
 316.965 +      int k;
 316.966 +#endif
 316.967 +      /* compute simplex multipliers */
 316.968 +      eval_pi(csa, pi);
 316.969 +      /* compute and store reduced costs */
 316.970 +      for (j = 1; j <= n; j++)
 316.971 +      {
 316.972 +#ifdef GLP_DEBUG
 316.973 +         k = head[m+j]; /* x[k] = xN[j] */
 316.974 +         xassert(1 <= k && k <= m+n);
 316.975 +#endif
 316.976 +         cbar[j] = eval_cost(csa, pi, j);
 316.977 +      }
 316.978 +      return;
 316.979 +}
 316.980 +#endif
 316.981 +
 316.982 +/***********************************************************************
 316.983 +*  reset_refsp - reset the reference space
 316.984 +*
 316.985 +*  This routine resets (redefines) the reference space used in the
 316.986 +*  projected steepest edge pricing algorithm. */
 316.987 +
 316.988 +static void reset_refsp(struct csa *csa)
 316.989 +{     int m = csa->m;
 316.990 +      int n = csa->n;
 316.991 +      int *head = csa->head;
 316.992 +      char *refsp = csa->refsp;
 316.993 +      double *gamma = csa->gamma;
 316.994 +      int i, k;
 316.995 +      xassert(csa->refct == 0);
 316.996 +      csa->refct = 1000;
 316.997 +      memset(&refsp[1], 0, (m+n) * sizeof(char));
 316.998 +      for (i = 1; i <= m; i++)
 316.999 +      {  k = head[i]; /* x[k] = xB[i] */
316.1000 +         refsp[k] = 1;
316.1001 +         gamma[i] = 1.0;
316.1002 +      }
316.1003 +      return;
316.1004 +}
316.1005 +
316.1006 +/***********************************************************************
316.1007 +*  eval_gamma - compute steepest edge coefficients
316.1008 +*
316.1009 +*  This routine computes the vector of steepest edge coefficients for
316.1010 +*  all basic variables (except free ones) using its direct definition:
316.1011 +*
316.1012 +*     gamma[i] = eta[i] +  sum   alfa[i,j]^2,  i = 1,...,m,
316.1013 +*                         j in C
316.1014 +*
316.1015 +*  where eta[i] = 1 means that xB[i] is in the current reference space,
316.1016 +*  and 0 otherwise; C is a set of non-basic non-fixed variables xN[j],
316.1017 +*  which are in the current reference space; alfa[i,j] are elements of
316.1018 +*  the current simplex table.
316.1019 +*
316.1020 +*  NOTE: The routine is intended only for debugginig purposes. */
316.1021 +
316.1022 +static void eval_gamma(struct csa *csa, double gamma[])
316.1023 +{     int m = csa->m;
316.1024 +      int n = csa->n;
316.1025 +      char *type = csa->type;
316.1026 +      int *head = csa->head;
316.1027 +      char *refsp = csa->refsp;
316.1028 +      double *alfa = csa->work3;
316.1029 +      double *h = csa->work3;
316.1030 +      int i, j, k;
316.1031 +      /* gamma[i] := eta[i] (or 1, if xB[i] is free) */
316.1032 +      for (i = 1; i <= m; i++)
316.1033 +      {  k = head[i]; /* x[k] = xB[i] */
316.1034 +#ifdef GLP_DEBUG
316.1035 +         xassert(1 <= k && k <= m+n);
316.1036 +#endif
316.1037 +         if (type[k] == GLP_FR)
316.1038 +            gamma[i] = 1.0;
316.1039 +         else
316.1040 +            gamma[i] = (refsp[k] ? 1.0 : 0.0);
316.1041 +      }
316.1042 +      /* compute columns of the current simplex table */
316.1043 +      for (j = 1; j <= n; j++)
316.1044 +      {  k = head[m+j]; /* x[k] = xN[j] */
316.1045 +#ifdef GLP_DEBUG
316.1046 +         xassert(1 <= k && k <= m+n);
316.1047 +#endif
316.1048 +         /* skip column, if xN[j] is not in C */
316.1049 +         if (!refsp[k]) continue;
316.1050 +#ifdef GLP_DEBUG
316.1051 +         /* set C must not contain fixed variables */
316.1052 +         xassert(type[k] != GLP_FX);
316.1053 +#endif
316.1054 +         /* construct the right-hand side vector h = - N[j] */
316.1055 +         for (i = 1; i <= m; i++)
316.1056 +            h[i] = 0.0;
316.1057 +         if (k <= m)
316.1058 +         {  /* N[j] is k-th column of submatrix I */
316.1059 +            h[k] = -1.0;
316.1060 +         }
316.1061 +         else
316.1062 +         {  /* N[j] is (k-m)-th column of submatrix (-A) */
316.1063 +            int *A_ptr = csa->A_ptr;
316.1064 +            int *A_ind = csa->A_ind;
316.1065 +            double *A_val = csa->A_val;
316.1066 +            int beg, end, ptr;
316.1067 +            beg = A_ptr[k-m];
316.1068 +            end = A_ptr[k-m+1];
316.1069 +            for (ptr = beg; ptr < end; ptr++)
316.1070 +               h[A_ind[ptr]] = A_val[ptr];
316.1071 +         }
316.1072 +         /* solve system B * alfa = h */
316.1073 +         xassert(csa->valid);
316.1074 +         bfd_ftran(csa->bfd, alfa);
316.1075 +         /* gamma[i] := gamma[i] + alfa[i,j]^2 */
316.1076 +         for (i = 1; i <= m; i++)
316.1077 +         {  k = head[i]; /* x[k] = xB[i] */
316.1078 +            if (type[k] != GLP_FR)
316.1079 +               gamma[i] += alfa[i] * alfa[i];
316.1080 +         }
316.1081 +      }
316.1082 +      return;
316.1083 +}
316.1084 +
316.1085 +/***********************************************************************
316.1086 +*  chuzr - choose basic variable (row of the simplex table)
316.1087 +*
316.1088 +*  This routine chooses basic variable xB[p] having largest weighted
316.1089 +*  bound violation:
316.1090 +*
316.1091 +*     |r[p]| / sqrt(gamma[p]) = max  |r[i]| / sqrt(gamma[i]),
316.1092 +*                              i in I
316.1093 +*
316.1094 +*            / lB[i] - beta[i], if beta[i] < lB[i]
316.1095 +*            |
316.1096 +*     r[i] = < 0,               if lB[i] <= beta[i] <= uB[i]
316.1097 +*            |
316.1098 +*            \ uB[i] - beta[i], if beta[i] > uB[i]
316.1099 +*
316.1100 +*  where beta[i] is primal value of xB[i] in the current basis, lB[i]
316.1101 +*  and uB[i] are lower and upper bounds of xB[i], I is a subset of
316.1102 +*  eligible basic variables, which significantly violates their bounds,
316.1103 +*  gamma[i] is the steepest edge coefficient.
316.1104 +*
316.1105 +*  If |r[i]| is less than a specified tolerance, xB[i] is not included
316.1106 +*  in I and therefore ignored.
316.1107 +*
316.1108 +*  If I is empty and no variable has been chosen, p is set to 0. */
316.1109 +
316.1110 +static void chuzr(struct csa *csa, double tol_bnd)
316.1111 +{     int m = csa->m;
316.1112 +#ifdef GLP_DEBUG
316.1113 +      int n = csa->n;
316.1114 +#endif
316.1115 +      char *type = csa->type;
316.1116 +      double *lb = csa->lb;
316.1117 +      double *ub = csa->ub;
316.1118 +      int *head = csa->head;
316.1119 +      double *bbar = csa->bbar;
316.1120 +      double *gamma = csa->gamma;
316.1121 +      int i, k, p;
316.1122 +      double delta, best, eps, ri, temp;
316.1123 +      /* nothing is chosen so far */
316.1124 +      p = 0, delta = 0.0, best = 0.0;
316.1125 +      /* look through the list of basic variables */
316.1126 +      for (i = 1; i <= m; i++)
316.1127 +      {  k = head[i]; /* x[k] = xB[i] */
316.1128 +#ifdef GLP_DEBUG
316.1129 +         xassert(1 <= k && k <= m+n);
316.1130 +#endif
316.1131 +         /* determine bound violation ri[i] */
316.1132 +         ri = 0.0;
316.1133 +         if (type[k] == GLP_LO || type[k] == GLP_DB ||
316.1134 +             type[k] == GLP_FX)
316.1135 +         {  /* xB[i] has lower bound */
316.1136 +            eps = tol_bnd * (1.0 + kappa * fabs(lb[k]));
316.1137 +            if (bbar[i] < lb[k] - eps)
316.1138 +            {  /* and significantly violates it */
316.1139 +               ri = lb[k] - bbar[i];
316.1140 +            }
316.1141 +         }
316.1142 +         if (type[k] == GLP_UP || type[k] == GLP_DB ||
316.1143 +             type[k] == GLP_FX)
316.1144 +         {  /* xB[i] has upper bound */
316.1145 +            eps = tol_bnd * (1.0 + kappa * fabs(ub[k]));
316.1146 +            if (bbar[i] > ub[k] + eps)
316.1147 +            {  /* and significantly violates it */
316.1148 +               ri = ub[k] - bbar[i];
316.1149 +            }
316.1150 +         }
316.1151 +         /* if xB[i] is not eligible, skip it */
316.1152 +         if (ri == 0.0) continue;
316.1153 +         /* xB[i] is eligible basic variable; choose one with largest
316.1154 +            weighted bound violation */
316.1155 +#ifdef GLP_DEBUG
316.1156 +         xassert(gamma[i] >= 0.0);
316.1157 +#endif
316.1158 +         temp = gamma[i];
316.1159 +         if (temp < DBL_EPSILON) temp = DBL_EPSILON;
316.1160 +         temp = (ri * ri) / temp;
316.1161 +         if (best < temp)
316.1162 +            p = i, delta = ri, best = temp;
316.1163 +      }
316.1164 +      /* store the index of basic variable xB[p] chosen and its change
316.1165 +         in the adjacent basis */
316.1166 +      csa->p = p;
316.1167 +      csa->delta = delta;
316.1168 +      return;
316.1169 +}
316.1170 +
316.1171 +#if 1 /* copied from primal */
316.1172 +/***********************************************************************
316.1173 +*  eval_rho - compute pivot row of the inverse
316.1174 +*
316.1175 +*  This routine computes the pivot (p-th) row of the inverse inv(B),
316.1176 +*  which corresponds to basic variable xB[p] chosen:
316.1177 +*
316.1178 +*     rho = inv(B') * e[p],
316.1179 +*
316.1180 +*  where B' is a matrix transposed to the current basis matrix, e[p]
316.1181 +*  is unity vector. */
316.1182 +
316.1183 +static void eval_rho(struct csa *csa, double rho[])
316.1184 +{     int m = csa->m;
316.1185 +      int p = csa->p;
316.1186 +      double *e = rho;
316.1187 +      int i;
316.1188 +#ifdef GLP_DEBUG
316.1189 +      xassert(1 <= p && p <= m);
316.1190 +#endif
316.1191 +      /* construct the right-hand side vector e[p] */
316.1192 +      for (i = 1; i <= m; i++)
316.1193 +         e[i] = 0.0;
316.1194 +      e[p] = 1.0;
316.1195 +      /* solve system B'* rho = e[p] */
316.1196 +      xassert(csa->valid);
316.1197 +      bfd_btran(csa->bfd, rho);
316.1198 +      return;
316.1199 +}
316.1200 +#endif
316.1201 +
316.1202 +#if 1 /* copied from primal */
316.1203 +/***********************************************************************
316.1204 +*  refine_rho - refine pivot row of the inverse
316.1205 +*
316.1206 +*  This routine refines the pivot row of the inverse inv(B) assuming
316.1207 +*  that it was previously computed by the routine eval_rho. */
316.1208 +
316.1209 +static void refine_rho(struct csa *csa, double rho[])
316.1210 +{     int m = csa->m;
316.1211 +      int p = csa->p;
316.1212 +      double *e = csa->work3;
316.1213 +      int i;
316.1214 +#ifdef GLP_DEBUG
316.1215 +      xassert(1 <= p && p <= m);
316.1216 +#endif
316.1217 +      /* construct the right-hand side vector e[p] */
316.1218 +      for (i = 1; i <= m; i++)
316.1219 +         e[i] = 0.0;
316.1220 +      e[p] = 1.0;
316.1221 +      /* refine solution of B'* rho = e[p] */
316.1222 +      refine_btran(csa, e, rho);
316.1223 +      return;
316.1224 +}
316.1225 +#endif
316.1226 +
316.1227 +#if 1 /* 06/IV-2009 */
316.1228 +/***********************************************************************
316.1229 +*  eval_trow - compute pivot row of the simplex table
316.1230 +*
316.1231 +*  This routine computes the pivot row of the simplex table, which
316.1232 +*  corresponds to basic variable xB[p] chosen.
316.1233 +*
316.1234 +*  The pivot row is the following vector:
316.1235 +*
316.1236 +*     trow = T'* e[p] = - N'* inv(B') * e[p] = - N' * rho,
316.1237 +*
316.1238 +*  where rho is the pivot row of the inverse inv(B) previously computed
316.1239 +*  by the routine eval_rho.
316.1240 +*
316.1241 +*  Note that elements of the pivot row corresponding to fixed non-basic
316.1242 +*  variables are not computed.
316.1243 +*
316.1244 +*  NOTES
316.1245 +*
316.1246 +*  Computing pivot row of the simplex table is one of the most time
316.1247 +*  consuming operations, and for some instances it may take more than
316.1248 +*  50% of the total solution time.
316.1249 +*
316.1250 +*  In the current implementation there are two routines to compute the
316.1251 +*  pivot row. The routine eval_trow1 computes elements of the pivot row
316.1252 +*  as inner products of columns of the matrix N and the vector rho; it
316.1253 +*  is used when the vector rho is relatively dense. The routine
316.1254 +*  eval_trow2 computes the pivot row as a linear combination of rows of
316.1255 +*  the matrix N; it is used when the vector rho is relatively sparse. */
316.1256 +
316.1257 +static void eval_trow1(struct csa *csa, double rho[])
316.1258 +{     int m = csa->m;
316.1259 +      int n = csa->n;
316.1260 +      int *A_ptr = csa->A_ptr;
316.1261 +      int *A_ind = csa->A_ind;
316.1262 +      double *A_val = csa->A_val;
316.1263 +      int *head = csa->head;
316.1264 +      char *stat = csa->stat;
316.1265 +      int *trow_ind = csa->trow_ind;
316.1266 +      double *trow_vec = csa->trow_vec;
316.1267 +      int j, k, beg, end, ptr, nnz;
316.1268 +      double temp;
316.1269 +      /* compute the pivot row as inner products of columns of the
316.1270 +         matrix N and vector rho: trow[j] = - rho * N[j] */
316.1271 +      nnz = 0;
316.1272 +      for (j = 1; j <= n; j++)
316.1273 +      {  if (stat[j] == GLP_NS)
316.1274 +         {  /* xN[j] is fixed */
316.1275 +            trow_vec[j] = 0.0;
316.1276 +            continue;
316.1277 +         }
316.1278 +         k = head[m+j]; /* x[k] = xN[j] */
316.1279 +         if (k <= m)
316.1280 +         {  /* N[j] is k-th column of submatrix I */
316.1281 +            temp = - rho[k];
316.1282 +         }
316.1283 +         else
316.1284 +         {  /* N[j] is (k-m)-th column of submatrix (-A) */
316.1285 +            beg = A_ptr[k-m], end = A_ptr[k-m+1];
316.1286 +            temp = 0.0;
316.1287 +            for (ptr = beg; ptr < end; ptr++)
316.1288 +               temp += rho[A_ind[ptr]] * A_val[ptr];
316.1289 +         }
316.1290 +         if (temp != 0.0)
316.1291 +            trow_ind[++nnz] = j;
316.1292 +         trow_vec[j] = temp;
316.1293 +      }
316.1294 +      csa->trow_nnz = nnz;
316.1295 +      return;
316.1296 +}
316.1297 +
316.1298 +static void eval_trow2(struct csa *csa, double rho[])
316.1299 +{     int m = csa->m;
316.1300 +      int n = csa->n;
316.1301 +      int *AT_ptr = csa->AT_ptr;
316.1302 +      int *AT_ind = csa->AT_ind;
316.1303 +      double *AT_val = csa->AT_val;
316.1304 +      int *bind = csa->bind;
316.1305 +      char *stat = csa->stat;
316.1306 +      int *trow_ind = csa->trow_ind;
316.1307 +      double *trow_vec = csa->trow_vec;
316.1308 +      int i, j, beg, end, ptr, nnz;
316.1309 +      double temp;
316.1310 +      /* clear the pivot row */
316.1311 +      for (j = 1; j <= n; j++)
316.1312 +         trow_vec[j] = 0.0;
316.1313 +      /* compute the pivot row as a linear combination of rows of the
316.1314 +         matrix N: trow = - rho[1] * N'[1] - ... - rho[m] * N'[m] */
316.1315 +      for (i = 1; i <= m; i++)
316.1316 +      {  temp = rho[i];
316.1317 +         if (temp == 0.0) continue;
316.1318 +         /* trow := trow - rho[i] * N'[i] */
316.1319 +         j = bind[i] - m; /* x[i] = xN[j] */
316.1320 +         if (j >= 1 && stat[j] != GLP_NS)
316.1321 +            trow_vec[j] -= temp;
316.1322 +         beg = AT_ptr[i], end = AT_ptr[i+1];
316.1323 +         for (ptr = beg; ptr < end; ptr++)
316.1324 +         {  j = bind[m + AT_ind[ptr]] - m; /* x[k] = xN[j] */
316.1325 +            if (j >= 1 && stat[j] != GLP_NS)
316.1326 +               trow_vec[j] += temp * AT_val[ptr];
316.1327 +         }
316.1328 +      }
316.1329 +      /* construct sparse pattern of the pivot row */
316.1330 +      nnz = 0;
316.1331 +      for (j = 1; j <= n; j++)
316.1332 +      {  if (trow_vec[j] != 0.0)
316.1333 +            trow_ind[++nnz] = j;
316.1334 +      }
316.1335 +      csa->trow_nnz = nnz;
316.1336 +      return;
316.1337 +}
316.1338 +
316.1339 +static void eval_trow(struct csa *csa, double rho[])
316.1340 +{     int m = csa->m;
316.1341 +      int i, nnz;
316.1342 +      double dens;
316.1343 +      /* determine the density of the vector rho */
316.1344 +      nnz = 0;
316.1345 +      for (i = 1; i <= m; i++)
316.1346 +         if (rho[i] != 0.0) nnz++;
316.1347 +      dens = (double)nnz / (double)m;
316.1348 +      if (dens >= 0.20)
316.1349 +      {  /* rho is relatively dense */
316.1350 +         eval_trow1(csa, rho);
316.1351 +      }
316.1352 +      else
316.1353 +      {  /* rho is relatively sparse */
316.1354 +         eval_trow2(csa, rho);
316.1355 +      }
316.1356 +      return;
316.1357 +}
316.1358 +#endif
316.1359 +
316.1360 +/***********************************************************************
316.1361 +*  sort_trow - sort pivot row of the simplex table
316.1362 +*
316.1363 +*  This routine reorders the list of non-zero elements of the pivot
316.1364 +*  row to put significant elements, whose magnitude is not less than
316.1365 +*  a specified tolerance, in front of the list, and stores the number
316.1366 +*  of significant elements in trow_num. */
316.1367 +
316.1368 +static void sort_trow(struct csa *csa, double tol_piv)
316.1369 +{
316.1370 +#ifdef GLP_DEBUG
316.1371 +      int n = csa->n;
316.1372 +      char *stat = csa->stat;
316.1373 +#endif
316.1374 +      int nnz = csa->trow_nnz;
316.1375 +      int *trow_ind = csa->trow_ind;
316.1376 +      double *trow_vec = csa->trow_vec;
316.1377 +      int j, num, pos;
316.1378 +      double big, eps, temp;
316.1379 +      /* compute infinity (maximum) norm of the row */
316.1380 +      big = 0.0;
316.1381 +      for (pos = 1; pos <= nnz; pos++)
316.1382 +      {
316.1383 +#ifdef GLP_DEBUG
316.1384 +         j = trow_ind[pos];
316.1385 +         xassert(1 <= j && j <= n);
316.1386 +         xassert(stat[j] != GLP_NS);
316.1387 +#endif
316.1388 +         temp = fabs(trow_vec[trow_ind[pos]]);
316.1389 +         if (big < temp) big = temp;
316.1390 +      }
316.1391 +      csa->trow_max = big;
316.1392 +      /* determine absolute pivot tolerance */
316.1393 +      eps = tol_piv * (1.0 + 0.01 * big);
316.1394 +      /* move significant row components to the front of the list */
316.1395 +      for (num = 0; num < nnz; )
316.1396 +      {  j = trow_ind[nnz];
316.1397 +         if (fabs(trow_vec[j]) < eps)
316.1398 +            nnz--;
316.1399 +         else
316.1400 +         {  num++;
316.1401 +            trow_ind[nnz] = trow_ind[num];
316.1402 +            trow_ind[num] = j;
316.1403 +         }
316.1404 +      }
316.1405 +      csa->trow_num = num;
316.1406 +      return;
316.1407 +}
316.1408 +
316.1409 +#ifdef GLP_LONG_STEP /* 07/IV-2009 */
316.1410 +static int ls_func(const void *p1_, const void *p2_)
316.1411 +{     const struct bkpt *p1 = p1_, *p2 = p2_;
316.1412 +      if (p1->t < p2->t) return -1;
316.1413 +      if (p1->t > p2->t) return +1;
316.1414 +      return 0;
316.1415 +}
316.1416 +
316.1417 +static int ls_func1(const void *p1_, const void *p2_)
316.1418 +{     const struct bkpt *p1 = p1_, *p2 = p2_;
316.1419 +      if (p1->dz < p2->dz) return -1;
316.1420 +      if (p1->dz > p2->dz) return +1;
316.1421 +      return 0;
316.1422 +}
316.1423 +
316.1424 +static void long_step(struct csa *csa)
316.1425 +{     int m = csa->m;
316.1426 +#ifdef GLP_DEBUG
316.1427 +      int n = csa->n;
316.1428 +#endif
316.1429 +      char *type = csa->type;
316.1430 +      double *lb = csa->lb;
316.1431 +      double *ub = csa->ub;
316.1432 +      int *head = csa->head;
316.1433 +      char *stat = csa->stat;
316.1434 +      double *cbar = csa->cbar;
316.1435 +      double delta = csa->delta;
316.1436 +      int *trow_ind = csa->trow_ind;
316.1437 +      double *trow_vec = csa->trow_vec;
316.1438 +      int trow_num = csa->trow_num;
316.1439 +      struct bkpt *bkpt = csa->bkpt;
316.1440 +      int j, k, kk, nbps, pos;
316.1441 +      double alfa, s, slope, dzmax;
316.1442 +      /* delta > 0 means that xB[p] violates its lower bound, so to
316.1443 +         increase the dual objective lambdaB[p] must increase;
316.1444 +         delta < 0 means that xB[p] violates its upper bound, so to
316.1445 +         increase the dual objective lambdaB[p] must decrease */
316.1446 +      /* s := sign(delta) */
316.1447 +      s = (delta > 0.0 ? +1.0 : -1.0);
316.1448 +      /* determine breakpoints of the dual objective */
316.1449 +      nbps = 0;
316.1450 +      for (pos = 1; pos <= trow_num; pos++)
316.1451 +      {  j = trow_ind[pos];
316.1452 +#ifdef GLP_DEBUG
316.1453 +         xassert(1 <= j && j <= n);
316.1454 +         xassert(stat[j] != GLP_NS);
316.1455 +#endif
316.1456 +         /* if there is free non-basic variable, switch to the standard
316.1457 +            ratio test */
316.1458 +         if (stat[j] == GLP_NF)
316.1459 +         {  nbps = 0;
316.1460 +            goto done;
316.1461 +         }
316.1462 +         /* lambdaN[j] = ... - alfa * t - ..., where t = s * lambdaB[i]
316.1463 +            is the dual ray parameter, t >= 0 */
316.1464 +         alfa = s * trow_vec[j];
316.1465 +#ifdef GLP_DEBUG
316.1466 +         xassert(alfa != 0.0);
316.1467 +         xassert(stat[j] == GLP_NL || stat[j] == GLP_NU);
316.1468 +#endif
316.1469 +         if (alfa > 0.0 && stat[j] == GLP_NL ||
316.1470 +             alfa < 0.0 && stat[j] == GLP_NU)
316.1471 +         {  /* either lambdaN[j] >= 0 (if stat = GLP_NL) and decreases
316.1472 +               or lambdaN[j] <= 0 (if stat = GLP_NU) and increases; in
316.1473 +               both cases we have a breakpoint */
316.1474 +            nbps++;
316.1475 +#ifdef GLP_DEBUG
316.1476 +            xassert(nbps <= n);
316.1477 +#endif
316.1478 +            bkpt[nbps].j = j;
316.1479 +            bkpt[nbps].t = cbar[j] / alfa;
316.1480 +/*
316.1481 +if (stat[j] == GLP_NL && cbar[j] < 0.0 ||
316.1482 +    stat[j] == GLP_NU && cbar[j] > 0.0)
316.1483 +xprintf("%d %g\n", stat[j], cbar[j]);
316.1484 +*/
316.1485 +            /* if t is negative, replace it by exact zero (see comments
316.1486 +               in the routine chuzc) */
316.1487 +            if (bkpt[nbps].t < 0.0) bkpt[nbps].t = 0.0;
316.1488 +         }
316.1489 +      }
316.1490 +      /* if there are less than two breakpoints, switch to the standard
316.1491 +         ratio test */
316.1492 +      if (nbps < 2)
316.1493 +      {  nbps = 0;
316.1494 +         goto done;
316.1495 +      }
316.1496 +      /* sort breakpoints by ascending the dual ray parameter, t */
316.1497 +      qsort(&bkpt[1], nbps, sizeof(struct bkpt), ls_func);
316.1498 +      /* determine last breakpoint, at which the dual objective still
316.1499 +         greater than at t = 0 */
316.1500 +      dzmax = 0.0;
316.1501 +      slope = fabs(delta); /* initial slope */
316.1502 +      for (kk = 1; kk <= nbps; kk++)
316.1503 +      {  if (kk == 1)
316.1504 +            bkpt[kk].dz =
316.1505 +               0.0 + slope * (bkpt[kk].t - 0.0);
316.1506 +         else
316.1507 +            bkpt[kk].dz =
316.1508 +               bkpt[kk-1].dz + slope * (bkpt[kk].t - bkpt[kk-1].t);
316.1509 +         if (dzmax < bkpt[kk].dz)
316.1510 +            dzmax = bkpt[kk].dz;
316.1511 +         else if (bkpt[kk].dz < 0.05 * (1.0 + dzmax))
316.1512 +         {  nbps = kk - 1;
316.1513 +            break;
316.1514 +         }
316.1515 +         j = bkpt[kk].j;
316.1516 +         k = head[m+j]; /* x[k] = xN[j] */
316.1517 +         if (type[k] == GLP_DB)
316.1518 +            slope -= fabs(trow_vec[j]) * (ub[k] - lb[k]);
316.1519 +         else
316.1520 +         {  nbps = kk;
316.1521 +            break;
316.1522 +         }
316.1523 +      }
316.1524 +      /* if there are less than two breakpoints, switch to the standard
316.1525 +         ratio test */
316.1526 +      if (nbps < 2)
316.1527 +      {  nbps = 0;
316.1528 +         goto done;
316.1529 +      }
316.1530 +      /* sort breakpoints by ascending the dual change, dz */
316.1531 +      qsort(&bkpt[1], nbps, sizeof(struct bkpt), ls_func1);
316.1532 +/*
316.1533 +for (kk = 1; kk <= nbps; kk++)
316.1534 +xprintf("%d; t = %g; dz = %g\n", kk, bkpt[kk].t, bkpt[kk].dz);
316.1535 +*/
316.1536 +done: csa->nbps = nbps;
316.1537 +      return;
316.1538 +}
316.1539 +#endif
316.1540 +
316.1541 +/***********************************************************************
316.1542 +*  chuzc - choose non-basic variable (column of the simplex table)
316.1543 +*
316.1544 +*  This routine chooses non-basic variable xN[q], which being entered
316.1545 +*  in the basis keeps dual feasibility of the basic solution.
316.1546 +*
316.1547 +*  The parameter rtol is a relative tolerance used to relax zero bounds
316.1548 +*  of reduced costs of non-basic variables. If rtol = 0, the routine
316.1549 +*  implements the standard ratio test. Otherwise, if rtol > 0, the
316.1550 +*  routine implements Harris' two-pass ratio test. In the latter case
316.1551 +*  rtol should be about three times less than a tolerance used to check
316.1552 +*  dual feasibility. */
316.1553 +
316.1554 +static void chuzc(struct csa *csa, double rtol)
316.1555 +{
316.1556 +#ifdef GLP_DEBUG
316.1557 +      int m = csa->m;
316.1558 +      int n = csa->n;
316.1559 +#endif
316.1560 +      char *stat = csa->stat;
316.1561 +      double *cbar = csa->cbar;
316.1562 +#ifdef GLP_DEBUG
316.1563 +      int p = csa->p;
316.1564 +#endif
316.1565 +      double delta = csa->delta;
316.1566 +      int *trow_ind = csa->trow_ind;
316.1567 +      double *trow_vec = csa->trow_vec;
316.1568 +      int trow_num = csa->trow_num;
316.1569 +      int j, pos, q;
316.1570 +      double alfa, big, s, t, teta, tmax;
316.1571 +#ifdef GLP_DEBUG
316.1572 +      xassert(1 <= p && p <= m);
316.1573 +#endif
316.1574 +      /* delta > 0 means that xB[p] violates its lower bound and goes
316.1575 +         to it in the adjacent basis, so lambdaB[p] is increasing from
316.1576 +         its lower zero bound;
316.1577 +         delta < 0 means that xB[p] violates its upper bound and goes
316.1578 +         to it in the adjacent basis, so lambdaB[p] is decreasing from
316.1579 +         its upper zero bound */
316.1580 +#ifdef GLP_DEBUG
316.1581 +      xassert(delta != 0.0);
316.1582 +#endif
316.1583 +      /* s := sign(delta) */
316.1584 +      s = (delta > 0.0 ? +1.0 : -1.0);
316.1585 +      /*** FIRST PASS ***/
316.1586 +      /* nothing is chosen so far */
316.1587 +      q = 0, teta = DBL_MAX, big = 0.0;
316.1588 +      /* walk through significant elements of the pivot row */
316.1589 +      for (pos = 1; pos <= trow_num; pos++)
316.1590 +      {  j = trow_ind[pos];
316.1591 +#ifdef GLP_DEBUG
316.1592 +         xassert(1 <= j && j <= n);
316.1593 +#endif
316.1594 +         alfa = s * trow_vec[j];
316.1595 +#ifdef GLP_DEBUG
316.1596 +         xassert(alfa != 0.0);
316.1597 +#endif
316.1598 +         /* lambdaN[j] = ... - alfa * lambdaB[p] - ..., and due to s we
316.1599 +            need to consider only increasing lambdaB[p] */
316.1600 +         if (alfa > 0.0)
316.1601 +         {  /* lambdaN[j] is decreasing */
316.1602 +            if (stat[j] == GLP_NL || stat[j] == GLP_NF)
316.1603 +            {  /* lambdaN[j] has zero lower bound */
316.1604 +               t = (cbar[j] + rtol) / alfa;
316.1605 +            }
316.1606 +            else
316.1607 +            {  /* lambdaN[j] has no lower bound */
316.1608 +               continue;
316.1609 +            }
316.1610 +         }
316.1611 +         else
316.1612 +         {  /* lambdaN[j] is increasing */
316.1613 +            if (stat[j] == GLP_NU || stat[j] == GLP_NF)
316.1614 +            {  /* lambdaN[j] has zero upper bound */
316.1615 +               t = (cbar[j] - rtol) / alfa;
316.1616 +            }
316.1617 +            else
316.1618 +            {  /* lambdaN[j] has no upper bound */
316.1619 +               continue;
316.1620 +            }
316.1621 +         }
316.1622 +         /* t is a change of lambdaB[p], on which lambdaN[j] reaches
316.1623 +            its zero bound (possibly relaxed); since the basic solution
316.1624 +            is assumed to be dual feasible, t has to be non-negative by
316.1625 +            definition; however, it may happen that lambdaN[j] slightly
316.1626 +            (i.e. within a tolerance) violates its zero bound, that
316.1627 +            leads to negative t; in the latter case, if xN[j] is chosen,
316.1628 +            negative t means that lambdaB[p] changes in wrong direction
316.1629 +            that may cause wrong results on updating reduced costs;
316.1630 +            thus, if t is negative, we should replace it by exact zero
316.1631 +            assuming that lambdaN[j] is exactly on its zero bound, and
316.1632 +            violation appears due to round-off errors */
316.1633 +         if (t < 0.0) t = 0.0;
316.1634 +         /* apply minimal ratio test */
316.1635 +         if (teta > t || teta == t && big < fabs(alfa))
316.1636 +            q = j, teta = t, big = fabs(alfa);
316.1637 +      }
316.1638 +      /* the second pass is skipped in the following cases: */
316.1639 +      /* if the standard ratio test is used */
316.1640 +      if (rtol == 0.0) goto done;
316.1641 +      /* if no non-basic variable has been chosen on the first pass */
316.1642 +      if (q == 0) goto done;
316.1643 +      /* if lambdaN[q] prevents lambdaB[p] from any change */
316.1644 +      if (teta == 0.0) goto done;
316.1645 +      /*** SECOND PASS ***/
316.1646 +      /* here tmax is a maximal change of lambdaB[p], on which the
316.1647 +         solution remains dual feasible within a tolerance */
316.1648 +#if 0
316.1649 +      tmax = (1.0 + 10.0 * DBL_EPSILON) * teta;
316.1650 +#else
316.1651 +      tmax = teta;
316.1652 +#endif
316.1653 +      /* nothing is chosen so far */
316.1654 +      q = 0, teta = DBL_MAX, big = 0.0;
316.1655 +      /* walk through significant elements of the pivot row */
316.1656 +      for (pos = 1; pos <= trow_num; pos++)
316.1657 +      {  j = trow_ind[pos];
316.1658 +#ifdef GLP_DEBUG
316.1659 +         xassert(1 <= j && j <= n);
316.1660 +#endif
316.1661 +         alfa = s * trow_vec[j];
316.1662 +#ifdef GLP_DEBUG
316.1663 +         xassert(alfa != 0.0);
316.1664 +#endif
316.1665 +         /* lambdaN[j] = ... - alfa * lambdaB[p] - ..., and due to s we
316.1666 +            need to consider only increasing lambdaB[p] */
316.1667 +         if (alfa > 0.0)
316.1668 +         {  /* lambdaN[j] is decreasing */
316.1669 +            if (stat[j] == GLP_NL || stat[j] == GLP_NF)
316.1670 +            {  /* lambdaN[j] has zero lower bound */
316.1671 +               t = cbar[j] / alfa;
316.1672 +            }
316.1673 +            else
316.1674 +            {  /* lambdaN[j] has no lower bound */
316.1675 +               continue;
316.1676 +            }
316.1677 +         }
316.1678 +         else
316.1679 +         {  /* lambdaN[j] is increasing */
316.1680 +            if (stat[j] == GLP_NU || stat[j] == GLP_NF)
316.1681 +            {  /* lambdaN[j] has zero upper bound */
316.1682 +               t = cbar[j] / alfa;
316.1683 +            }
316.1684 +            else
316.1685 +            {  /* lambdaN[j] has no upper bound */
316.1686 +               continue;
316.1687 +            }
316.1688 +         }
316.1689 +         /* (see comments for the first pass) */
316.1690 +         if (t < 0.0) t = 0.0;
316.1691 +         /* t is a change of lambdaB[p], on which lambdaN[j] reaches
316.1692 +            its zero (lower or upper) bound; if t <= tmax, all reduced
316.1693 +            costs can violate their zero bounds only within relaxation
316.1694 +            tolerance rtol, so we can choose non-basic variable having
316.1695 +            largest influence coefficient to avoid possible numerical
316.1696 +            instability */
316.1697 +         if (t <= tmax && big < fabs(alfa))
316.1698 +            q = j, teta = t, big = fabs(alfa);
316.1699 +      }
316.1700 +      /* something must be chosen on the second pass */
316.1701 +      xassert(q != 0);
316.1702 +done: /* store the index of non-basic variable xN[q] chosen */
316.1703 +      csa->q = q;
316.1704 +      /* store reduced cost of xN[q] in the adjacent basis */
316.1705 +      csa->new_dq = s * teta;
316.1706 +      return;
316.1707 +}
316.1708 +
316.1709 +#if 1 /* copied from primal */
316.1710 +/***********************************************************************
316.1711 +*  eval_tcol - compute pivot column of the simplex table
316.1712 +*
316.1713 +*  This routine computes the pivot column of the simplex table, which
316.1714 +*  corresponds to non-basic variable xN[q] chosen.
316.1715 +*
316.1716 +*  The pivot column is the following vector:
316.1717 +*
316.1718 +*     tcol = T * e[q] = - inv(B) * N * e[q] = - inv(B) * N[q],
316.1719 +*
316.1720 +*  where B is the current basis matrix, N[q] is a column of the matrix
316.1721 +*  (I|-A) corresponding to variable xN[q]. */
316.1722 +
316.1723 +static void eval_tcol(struct csa *csa)
316.1724 +{     int m = csa->m;
316.1725 +#ifdef GLP_DEBUG
316.1726 +      int n = csa->n;
316.1727 +#endif
316.1728 +      int *head = csa->head;
316.1729 +      int q = csa->q;
316.1730 +      int *tcol_ind = csa->tcol_ind;
316.1731 +      double *tcol_vec = csa->tcol_vec;
316.1732 +      double *h = csa->tcol_vec;
316.1733 +      int i, k, nnz;
316.1734 +#ifdef GLP_DEBUG
316.1735 +      xassert(1 <= q && q <= n);
316.1736 +#endif
316.1737 +      k = head[m+q]; /* x[k] = xN[q] */
316.1738 +#ifdef GLP_DEBUG
316.1739 +      xassert(1 <= k && k <= m+n);
316.1740 +#endif
316.1741 +      /* construct the right-hand side vector h = - N[q] */
316.1742 +      for (i = 1; i <= m; i++)
316.1743 +         h[i] = 0.0;
316.1744 +      if (k <= m)
316.1745 +      {  /* N[q] is k-th column of submatrix I */
316.1746 +         h[k] = -1.0;
316.1747 +      }
316.1748 +      else
316.1749 +      {  /* N[q] is (k-m)-th column of submatrix (-A) */
316.1750 +         int *A_ptr = csa->A_ptr;
316.1751 +         int *A_ind = csa->A_ind;
316.1752 +         double *A_val = csa->A_val;
316.1753 +         int beg, end, ptr;
316.1754 +         beg = A_ptr[k-m];
316.1755 +         end = A_ptr[k-m+1];
316.1756 +         for (ptr = beg; ptr < end; ptr++)
316.1757 +            h[A_ind[ptr]] = A_val[ptr];
316.1758 +      }
316.1759 +      /* solve system B * tcol = h */
316.1760 +      xassert(csa->valid);
316.1761 +      bfd_ftran(csa->bfd, tcol_vec);
316.1762 +      /* construct sparse pattern of the pivot column */
316.1763 +      nnz = 0;
316.1764 +      for (i = 1; i <= m; i++)
316.1765 +      {  if (tcol_vec[i] != 0.0)
316.1766 +            tcol_ind[++nnz] = i;
316.1767 +      }
316.1768 +      csa->tcol_nnz = nnz;
316.1769 +      return;
316.1770 +}
316.1771 +#endif
316.1772 +
316.1773 +#if 1 /* copied from primal */
316.1774 +/***********************************************************************
316.1775 +*  refine_tcol - refine pivot column of the simplex table
316.1776 +*
316.1777 +*  This routine refines the pivot column of the simplex table assuming
316.1778 +*  that it was previously computed by the routine eval_tcol. */
316.1779 +
316.1780 +static void refine_tcol(struct csa *csa)
316.1781 +{     int m = csa->m;
316.1782 +#ifdef GLP_DEBUG
316.1783 +      int n = csa->n;
316.1784 +#endif
316.1785 +      int *head = csa->head;
316.1786 +      int q = csa->q;
316.1787 +      int *tcol_ind = csa->tcol_ind;
316.1788 +      double *tcol_vec = csa->tcol_vec;
316.1789 +      double *h = csa->work3;
316.1790 +      int i, k, nnz;
316.1791 +#ifdef GLP_DEBUG
316.1792 +      xassert(1 <= q && q <= n);
316.1793 +#endif
316.1794 +      k = head[m+q]; /* x[k] = xN[q] */
316.1795 +#ifdef GLP_DEBUG
316.1796 +      xassert(1 <= k && k <= m+n);
316.1797 +#endif
316.1798 +      /* construct the right-hand side vector h = - N[q] */
316.1799 +      for (i = 1; i <= m; i++)
316.1800 +         h[i] = 0.0;
316.1801 +      if (k <= m)
316.1802 +      {  /* N[q] is k-th column of submatrix I */
316.1803 +         h[k] = -1.0;
316.1804 +      }
316.1805 +      else
316.1806 +      {  /* N[q] is (k-m)-th column of submatrix (-A) */
316.1807 +         int *A_ptr = csa->A_ptr;
316.1808 +         int *A_ind = csa->A_ind;
316.1809 +         double *A_val = csa->A_val;
316.1810 +         int beg, end, ptr;
316.1811 +         beg = A_ptr[k-m];
316.1812 +         end = A_ptr[k-m+1];
316.1813 +         for (ptr = beg; ptr < end; ptr++)
316.1814 +            h[A_ind[ptr]] = A_val[ptr];
316.1815 +      }
316.1816 +      /* refine solution of B * tcol = h */
316.1817 +      refine_ftran(csa, h, tcol_vec);
316.1818 +      /* construct sparse pattern of the pivot column */
316.1819 +      nnz = 0;
316.1820 +      for (i = 1; i <= m; i++)
316.1821 +      {  if (tcol_vec[i] != 0.0)
316.1822 +            tcol_ind[++nnz] = i;
316.1823 +      }
316.1824 +      csa->tcol_nnz = nnz;
316.1825 +      return;
316.1826 +}
316.1827 +#endif
316.1828 +
316.1829 +/***********************************************************************
316.1830 +*  update_cbar - update reduced costs of non-basic variables
316.1831 +*
316.1832 +*  This routine updates reduced costs of all (except fixed) non-basic
316.1833 +*  variables for the adjacent basis. */
316.1834 +
316.1835 +static void update_cbar(struct csa *csa)
316.1836 +{
316.1837 +#ifdef GLP_DEBUG
316.1838 +      int n = csa->n;
316.1839 +#endif
316.1840 +      double *cbar = csa->cbar;
316.1841 +      int trow_nnz = csa->trow_nnz;
316.1842 +      int *trow_ind = csa->trow_ind;
316.1843 +      double *trow_vec = csa->trow_vec;
316.1844 +      int q = csa->q;
316.1845 +      double new_dq = csa->new_dq;
316.1846 +      int j, pos;
316.1847 +#ifdef GLP_DEBUG
316.1848 +      xassert(1 <= q && q <= n);
316.1849 +#endif
316.1850 +      /* set new reduced cost of xN[q] */
316.1851 +      cbar[q] = new_dq;
316.1852 +      /* update reduced costs of other non-basic variables */
316.1853 +      if (new_dq == 0.0) goto done;
316.1854 +      for (pos = 1; pos <= trow_nnz; pos++)
316.1855 +      {  j = trow_ind[pos];
316.1856 +#ifdef GLP_DEBUG
316.1857 +         xassert(1 <= j && j <= n);
316.1858 +#endif
316.1859 +         if (j != q)
316.1860 +            cbar[j] -= trow_vec[j] * new_dq;
316.1861 +      }
316.1862 +done: return;
316.1863 +}
316.1864 +
316.1865 +/***********************************************************************
316.1866 +*  update_bbar - update values of basic variables
316.1867 +*
316.1868 +*  This routine updates values of all basic variables for the adjacent
316.1869 +*  basis. */
316.1870 +
316.1871 +static void update_bbar(struct csa *csa)
316.1872 +{
316.1873 +#ifdef GLP_DEBUG
316.1874 +      int m = csa->m;
316.1875 +      int n = csa->n;
316.1876 +#endif
316.1877 +      double *bbar = csa->bbar;
316.1878 +      int p = csa->p;
316.1879 +      double delta = csa->delta;
316.1880 +      int q = csa->q;
316.1881 +      int tcol_nnz = csa->tcol_nnz;
316.1882 +      int *tcol_ind = csa->tcol_ind;
316.1883 +      double *tcol_vec = csa->tcol_vec;
316.1884 +      int i, pos;
316.1885 +      double teta;
316.1886 +#ifdef GLP_DEBUG
316.1887 +      xassert(1 <= p && p <= m);
316.1888 +      xassert(1 <= q && q <= n);
316.1889 +#endif
316.1890 +      /* determine the change of xN[q] in the adjacent basis */
316.1891 +#ifdef GLP_DEBUG
316.1892 +      xassert(tcol_vec[p] != 0.0);
316.1893 +#endif
316.1894 +      teta = delta / tcol_vec[p];
316.1895 +      /* set new primal value of xN[q] */
316.1896 +      bbar[p] = get_xN(csa, q) + teta;
316.1897 +      /* update primal values of other basic variables */
316.1898 +      if (teta == 0.0) goto done;
316.1899 +      for (pos = 1; pos <= tcol_nnz; pos++)
316.1900 +      {  i = tcol_ind[pos];
316.1901 +#ifdef GLP_DEBUG
316.1902 +         xassert(1 <= i && i <= m);
316.1903 +#endif
316.1904 +         if (i != p)
316.1905 +            bbar[i] += tcol_vec[i] * teta;
316.1906 +      }
316.1907 +done: return;
316.1908 +}
316.1909 +
316.1910 +/***********************************************************************
316.1911 +*  update_gamma - update steepest edge coefficients
316.1912 +*
316.1913 +*  This routine updates steepest-edge coefficients for the adjacent
316.1914 +*  basis. */
316.1915 +
316.1916 +static void update_gamma(struct csa *csa)
316.1917 +{     int m = csa->m;
316.1918 +#ifdef GLP_DEBUG
316.1919 +      int n = csa->n;
316.1920 +#endif
316.1921 +      char *type = csa->type;
316.1922 +      int *head = csa->head;
316.1923 +      char *refsp = csa->refsp;
316.1924 +      double *gamma = csa->gamma;
316.1925 +      int p = csa->p;
316.1926 +      int trow_nnz = csa->trow_nnz;
316.1927 +      int *trow_ind = csa->trow_ind;
316.1928 +      double *trow_vec = csa->trow_vec;
316.1929 +      int q = csa->q;
316.1930 +      int tcol_nnz = csa->tcol_nnz;
316.1931 +      int *tcol_ind = csa->tcol_ind;
316.1932 +      double *tcol_vec = csa->tcol_vec;
316.1933 +      double *u = csa->work3;
316.1934 +      int i, j, k,pos;
316.1935 +      double gamma_p, eta_p, pivot, t, t1, t2;
316.1936 +#ifdef GLP_DEBUG
316.1937 +      xassert(1 <= p && p <= m);
316.1938 +      xassert(1 <= q && q <= n);
316.1939 +#endif
316.1940 +      /* the basis changes, so decrease the count */
316.1941 +      xassert(csa->refct > 0);
316.1942 +      csa->refct--;
316.1943 +      /* recompute gamma[p] for the current basis more accurately and
316.1944 +         compute auxiliary vector u */
316.1945 +#ifdef GLP_DEBUG
316.1946 +      xassert(type[head[p]] != GLP_FR);
316.1947 +#endif
316.1948 +      gamma_p = eta_p = (refsp[head[p]] ? 1.0 : 0.0);
316.1949 +      for (i = 1; i <= m; i++) u[i] = 0.0;
316.1950 +      for (pos = 1; pos <= trow_nnz; pos++)
316.1951 +      {  j = trow_ind[pos];
316.1952 +#ifdef GLP_DEBUG
316.1953 +         xassert(1 <= j && j <= n);
316.1954 +#endif
316.1955 +         k = head[m+j]; /* x[k] = xN[j] */
316.1956 +#ifdef GLP_DEBUG
316.1957 +         xassert(1 <= k && k <= m+n);
316.1958 +         xassert(type[k] != GLP_FX);
316.1959 +#endif
316.1960 +         if (!refsp[k]) continue;
316.1961 +         t = trow_vec[j];
316.1962 +         gamma_p += t * t;
316.1963 +         /* u := u + N[j] * delta[j] * trow[j] */
316.1964 +         if (k <= m)
316.1965 +         {  /* N[k] = k-j stolbec submatrix I */
316.1966 +            u[k] += t;
316.1967 +         }
316.1968 +         else
316.1969 +         {  /* N[k] = k-m-k stolbec (-A) */
316.1970 +            int *A_ptr = csa->A_ptr;
316.1971 +            int *A_ind = csa->A_ind;
316.1972 +            double *A_val = csa->A_val;
316.1973 +            int beg, end, ptr;
316.1974 +            beg = A_ptr[k-m];
316.1975 +            end = A_ptr[k-m+1];
316.1976 +            for (ptr = beg; ptr < end; ptr++)
316.1977 +               u[A_ind[ptr]] -= t * A_val[ptr];
316.1978 +         }
316.1979 +      }
316.1980 +      xassert(csa->valid);
316.1981 +      bfd_ftran(csa->bfd, u);
316.1982 +      /* update gamma[i] for other basic variables (except xB[p] and
316.1983 +         free variables) */
316.1984 +      pivot = tcol_vec[p];
316.1985 +#ifdef GLP_DEBUG
316.1986 +      xassert(pivot != 0.0);
316.1987 +#endif
316.1988 +      for (pos = 1; pos <= tcol_nnz; pos++)
316.1989 +      {  i = tcol_ind[pos];
316.1990 +#ifdef GLP_DEBUG
316.1991 +         xassert(1 <= i && i <= m);
316.1992 +#endif
316.1993 +         k = head[i];
316.1994 +#ifdef GLP_DEBUG
316.1995 +         xassert(1 <= k && k <= m+n);
316.1996 +#endif
316.1997 +         /* skip xB[p] */
316.1998 +         if (i == p) continue;
316.1999 +         /* skip free basic variable */
316.2000 +         if (type[head[i]] == GLP_FR)
316.2001 +         {
316.2002 +#ifdef GLP_DEBUG
316.2003 +            xassert(gamma[i] == 1.0);
316.2004 +#endif
316.2005 +            continue;
316.2006 +         }
316.2007 +         /* compute gamma[i] for the adjacent basis */
316.2008 +         t = tcol_vec[i] / pivot;
316.2009 +         t1 = gamma[i] + t * t * gamma_p + 2.0 * t * u[i];
316.2010 +         t2 = (refsp[k] ? 1.0 : 0.0) + eta_p * t * t;
316.2011 +         gamma[i] = (t1 >= t2 ? t1 : t2);
316.2012 +         /* (though gamma[i] can be exact zero, because the reference
316.2013 +            space does not include non-basic fixed variables) */
316.2014 +         if (gamma[i] < DBL_EPSILON) gamma[i] = DBL_EPSILON;
316.2015 +      }
316.2016 +      /* compute gamma[p] for the adjacent basis */
316.2017 +      if (type[head[m+q]] == GLP_FR)
316.2018 +         gamma[p] = 1.0;
316.2019 +      else
316.2020 +      {  gamma[p] = gamma_p / (pivot * pivot);
316.2021 +         if (gamma[p] < DBL_EPSILON) gamma[p] = DBL_EPSILON;
316.2022 +      }
316.2023 +      /* if xB[p], which becomes xN[q] in the adjacent basis, is fixed
316.2024 +         and belongs to the reference space, remove it from there, and
316.2025 +         change all gamma's appropriately */
316.2026 +      k = head[p];
316.2027 +      if (type[k] == GLP_FX && refsp[k])
316.2028 +      {  refsp[k] = 0;
316.2029 +         for (pos = 1; pos <= tcol_nnz; pos++)
316.2030 +         {  i = tcol_ind[pos];
316.2031 +            if (i == p)
316.2032 +            {  if (type[head[m+q]] == GLP_FR) continue;
316.2033 +               t = 1.0 / tcol_vec[p];
316.2034 +            }
316.2035 +            else
316.2036 +            {  if (type[head[i]] == GLP_FR) continue;
316.2037 +               t = tcol_vec[i] / tcol_vec[p];
316.2038 +            }
316.2039 +            gamma[i] -= t * t;
316.2040 +            if (gamma[i] < DBL_EPSILON) gamma[i] = DBL_EPSILON;
316.2041 +         }
316.2042 +      }
316.2043 +      return;
316.2044 +}
316.2045 +
316.2046 +#if 1 /* copied from primal */
316.2047 +/***********************************************************************
316.2048 +*  err_in_bbar - compute maximal relative error in primal solution
316.2049 +*
316.2050 +*  This routine returns maximal relative error:
316.2051 +*
316.2052 +*     max |beta[i] - bbar[i]| / (1 + |beta[i]|),
316.2053 +*
316.2054 +*  where beta and bbar are, respectively, directly computed and the
316.2055 +*  current (updated) values of basic variables.
316.2056 +*
316.2057 +*  NOTE: The routine is intended only for debugginig purposes. */
316.2058 +
316.2059 +static double err_in_bbar(struct csa *csa)
316.2060 +{     int m = csa->m;
316.2061 +      double *bbar = csa->bbar;
316.2062 +      int i;
316.2063 +      double e, emax, *beta;
316.2064 +      beta = xcalloc(1+m, sizeof(double));
316.2065 +      eval_beta(csa, beta);
316.2066 +      emax = 0.0;
316.2067 +      for (i = 1; i <= m; i++)
316.2068 +      {  e = fabs(beta[i] - bbar[i]) / (1.0 + fabs(beta[i]));
316.2069 +         if (emax < e) emax = e;
316.2070 +      }
316.2071 +      xfree(beta);
316.2072 +      return emax;
316.2073 +}
316.2074 +#endif
316.2075 +
316.2076 +#if 1 /* copied from primal */
316.2077 +/***********************************************************************
316.2078 +*  err_in_cbar - compute maximal relative error in dual solution
316.2079 +*
316.2080 +*  This routine returns maximal relative error:
316.2081 +*
316.2082 +*     max |cost[j] - cbar[j]| / (1 + |cost[j]|),
316.2083 +*
316.2084 +*  where cost and cbar are, respectively, directly computed and the
316.2085 +*  current (updated) reduced costs of non-basic non-fixed variables.
316.2086 +*
316.2087 +*  NOTE: The routine is intended only for debugginig purposes. */
316.2088 +
316.2089 +static double err_in_cbar(struct csa *csa)
316.2090 +{     int m = csa->m;
316.2091 +      int n = csa->n;
316.2092 +      char *stat = csa->stat;
316.2093 +      double *cbar = csa->cbar;
316.2094 +      int j;
316.2095 +      double e, emax, cost, *pi;
316.2096 +      pi = xcalloc(1+m, sizeof(double));
316.2097 +      eval_pi(csa, pi);
316.2098 +      emax = 0.0;
316.2099 +      for (j = 1; j <= n; j++)
316.2100 +      {  if (stat[j] == GLP_NS) continue;
316.2101 +         cost = eval_cost(csa, pi, j);
316.2102 +         e = fabs(cost - cbar[j]) / (1.0 + fabs(cost));
316.2103 +         if (emax < e) emax = e;
316.2104 +      }
316.2105 +      xfree(pi);
316.2106 +      return emax;
316.2107 +}
316.2108 +#endif
316.2109 +
316.2110 +/***********************************************************************
316.2111 +*  err_in_gamma - compute maximal relative error in steepest edge cff.
316.2112 +*
316.2113 +*  This routine returns maximal relative error:
316.2114 +*
316.2115 +*     max |gamma'[j] - gamma[j]| / (1 + |gamma'[j]),
316.2116 +*
316.2117 +*  where gamma'[j] and gamma[j] are, respectively, directly computed
316.2118 +*  and the current (updated) steepest edge coefficients for non-basic
316.2119 +*  non-fixed variable x[j].
316.2120 +*
316.2121 +*  NOTE: The routine is intended only for debugginig purposes. */
316.2122 +
316.2123 +static double err_in_gamma(struct csa *csa)
316.2124 +{     int m = csa->m;
316.2125 +      char *type = csa->type;
316.2126 +      int *head = csa->head;
316.2127 +      double *gamma = csa->gamma;
316.2128 +      double *exact = csa->work4;
316.2129 +      int i;
316.2130 +      double e, emax, temp;
316.2131 +      eval_gamma(csa, exact);
316.2132 +      emax = 0.0;
316.2133 +      for (i = 1; i <= m; i++)
316.2134 +      {  if (type[head[i]] == GLP_FR)
316.2135 +         {  xassert(gamma[i] == 1.0);
316.2136 +            xassert(exact[i] == 1.0);
316.2137 +            continue;
316.2138 +         }
316.2139 +         temp = exact[i];
316.2140 +         e = fabs(temp - gamma[i]) / (1.0 + fabs(temp));
316.2141 +         if (emax < e) emax = e;
316.2142 +      }
316.2143 +      return emax;
316.2144 +}
316.2145 +
316.2146 +/***********************************************************************
316.2147 +*  change_basis - change basis header
316.2148 +*
316.2149 +*  This routine changes the basis header to make it corresponding to
316.2150 +*  the adjacent basis. */
316.2151 +
316.2152 +static void change_basis(struct csa *csa)
316.2153 +{     int m = csa->m;
316.2154 +#ifdef GLP_DEBUG
316.2155 +      int n = csa->n;
316.2156 +#endif
316.2157 +      char *type = csa->type;
316.2158 +      int *head = csa->head;
316.2159 +#if 1 /* 06/IV-2009 */
316.2160 +      int *bind = csa->bind;
316.2161 +#endif
316.2162 +      char *stat = csa->stat;
316.2163 +      int p = csa->p;
316.2164 +      double delta = csa->delta;
316.2165 +      int q = csa->q;
316.2166 +      int k;
316.2167 +      /* xB[p] leaves the basis, xN[q] enters the basis */
316.2168 +#ifdef GLP_DEBUG
316.2169 +      xassert(1 <= p && p <= m);
316.2170 +      xassert(1 <= q && q <= n);
316.2171 +#endif
316.2172 +      /* xB[p] <-> xN[q] */
316.2173 +      k = head[p], head[p] = head[m+q], head[m+q] = k;
316.2174 +#if 1 /* 06/IV-2009 */
316.2175 +      bind[head[p]] = p, bind[head[m+q]] = m + q;
316.2176 +#endif
316.2177 +      if (type[k] == GLP_FX)
316.2178 +         stat[q] = GLP_NS;
316.2179 +      else if (delta > 0.0)
316.2180 +      {
316.2181 +#ifdef GLP_DEBUG
316.2182 +         xassert(type[k] == GLP_LO || type[k] == GLP_DB);
316.2183 +#endif
316.2184 +         stat[q] = GLP_NL;
316.2185 +      }
316.2186 +      else /* delta < 0.0 */
316.2187 +      {
316.2188 +#ifdef GLP_DEBUG
316.2189 +         xassert(type[k] == GLP_UP || type[k] == GLP_DB);
316.2190 +#endif
316.2191 +         stat[q] = GLP_NU;
316.2192 +      }
316.2193 +      return;
316.2194 +}
316.2195 +
316.2196 +/***********************************************************************
316.2197 +*  check_feas - check dual feasibility of basic solution
316.2198 +*
316.2199 +*  If the current basic solution is dual feasible within a tolerance,
316.2200 +*  this routine returns zero, otherwise it returns non-zero. */
316.2201 +
316.2202 +static int check_feas(struct csa *csa, double tol_dj)
316.2203 +{     int m = csa->m;
316.2204 +      int n = csa->n;
316.2205 +      char *orig_type = csa->orig_type;
316.2206 +      int *head = csa->head;
316.2207 +      double *cbar = csa->cbar;
316.2208 +      int j, k;
316.2209 +      for (j = 1; j <= n; j++)
316.2210 +      {  k = head[m+j]; /* x[k] = xN[j] */
316.2211 +#ifdef GLP_DEBUG
316.2212 +         xassert(1 <= k && k <= m+n);
316.2213 +#endif
316.2214 +         if (cbar[j] < - tol_dj)
316.2215 +            if (orig_type[k] == GLP_LO || orig_type[k] == GLP_FR)
316.2216 +               return 1;
316.2217 +         if (cbar[j] > + tol_dj)
316.2218 +            if (orig_type[k] == GLP_UP || orig_type[k] == GLP_FR)
316.2219 +               return 1;
316.2220 +      }
316.2221 +      return 0;
316.2222 +}
316.2223 +
316.2224 +/***********************************************************************
316.2225 +*  set_aux_bnds - assign auxiliary bounds to variables
316.2226 +*
316.2227 +*  This routine assigns auxiliary bounds to variables to construct an
316.2228 +*  LP problem solved on phase I. */
316.2229 +
316.2230 +static void set_aux_bnds(struct csa *csa)
316.2231 +{     int m = csa->m;
316.2232 +      int n = csa->n;
316.2233 +      char *type = csa->type;
316.2234 +      double *lb = csa->lb;
316.2235 +      double *ub = csa->ub;
316.2236 +      char *orig_type = csa->orig_type;
316.2237 +      int *head = csa->head;
316.2238 +      char *stat = csa->stat;
316.2239 +      double *cbar = csa->cbar;
316.2240 +      int j, k;
316.2241 +      for (k = 1; k <= m+n; k++)
316.2242 +      {  switch (orig_type[k])
316.2243 +         {  case GLP_FR:
316.2244 +#if 0
316.2245 +               type[k] = GLP_DB, lb[k] = -1.0, ub[k] = +1.0;
316.2246 +#else
316.2247 +               /* to force free variables to enter the basis */
316.2248 +               type[k] = GLP_DB, lb[k] = -1e3, ub[k] = +1e3;
316.2249 +#endif
316.2250 +               break;
316.2251 +            case GLP_LO:
316.2252 +               type[k] = GLP_DB, lb[k] = 0.0, ub[k] = +1.0;
316.2253 +               break;
316.2254 +            case GLP_UP:
316.2255 +               type[k] = GLP_DB, lb[k] = -1.0, ub[k] = 0.0;
316.2256 +               break;
316.2257 +            case GLP_DB:
316.2258 +            case GLP_FX:
316.2259 +               type[k] = GLP_FX, lb[k] = ub[k] = 0.0;
316.2260 +               break;
316.2261 +            default:
316.2262 +               xassert(orig_type != orig_type);
316.2263 +         }
316.2264 +      }
316.2265 +      for (j = 1; j <= n; j++)
316.2266 +      {  k = head[m+j]; /* x[k] = xN[j] */
316.2267 +#ifdef GLP_DEBUG
316.2268 +         xassert(1 <= k && k <= m+n);
316.2269 +#endif
316.2270 +         if (type[k] == GLP_FX)
316.2271 +            stat[j] = GLP_NS;
316.2272 +         else if (cbar[j] >= 0.0)
316.2273 +            stat[j] = GLP_NL;
316.2274 +         else
316.2275 +            stat[j] = GLP_NU;
316.2276 +      }
316.2277 +      return;
316.2278 +}
316.2279 +
316.2280 +/***********************************************************************
316.2281 +*  set_orig_bnds - restore original bounds of variables
316.2282 +*
316.2283 +*  This routine restores original types and bounds of variables and
316.2284 +*  determines statuses of non-basic variables assuming that the current
316.2285 +*  basis is dual feasible. */
316.2286 +
316.2287 +static void set_orig_bnds(struct csa *csa)
316.2288 +{     int m = csa->m;
316.2289 +      int n = csa->n;
316.2290 +      char *type = csa->type;
316.2291 +      double *lb = csa->lb;
316.2292 +      double *ub = csa->ub;
316.2293 +      char *orig_type = csa->orig_type;
316.2294 +      double *orig_lb = csa->orig_lb;
316.2295 +      double *orig_ub = csa->orig_ub;
316.2296 +      int *head = csa->head;
316.2297 +      char *stat = csa->stat;
316.2298 +      double *cbar = csa->cbar;
316.2299 +      int j, k;
316.2300 +      memcpy(&type[1], &orig_type[1], (m+n) * sizeof(char));
316.2301 +      memcpy(&lb[1], &orig_lb[1], (m+n) * sizeof(double));
316.2302 +      memcpy(&ub[1], &orig_ub[1], (m+n) * sizeof(double));
316.2303 +      for (j = 1; j <= n; j++)
316.2304 +      {  k = head[m+j]; /* x[k] = xN[j] */
316.2305 +#ifdef GLP_DEBUG
316.2306 +         xassert(1 <= k && k <= m+n);
316.2307 +#endif
316.2308 +         switch (type[k])
316.2309 +         {  case GLP_FR:
316.2310 +               stat[j] = GLP_NF;
316.2311 +               break;
316.2312 +            case GLP_LO:
316.2313 +               stat[j] = GLP_NL;
316.2314 +               break;
316.2315 +            case GLP_UP:
316.2316 +               stat[j] = GLP_NU;
316.2317 +               break;
316.2318 +            case GLP_DB:
316.2319 +               if (cbar[j] >= +DBL_EPSILON)
316.2320 +                  stat[j] = GLP_NL;
316.2321 +               else if (cbar[j] <= -DBL_EPSILON)
316.2322 +                  stat[j] = GLP_NU;
316.2323 +               else if (fabs(lb[k]) <= fabs(ub[k]))
316.2324 +                  stat[j] = GLP_NL;
316.2325 +               else
316.2326 +                  stat[j] = GLP_NU;
316.2327 +               break;
316.2328 +            case GLP_FX:
316.2329 +               stat[j] = GLP_NS;
316.2330 +               break;
316.2331 +            default:
316.2332 +               xassert(type != type);
316.2333 +         }
316.2334 +      }
316.2335 +      return;
316.2336 +}
316.2337 +
316.2338 +/***********************************************************************
316.2339 +*  check_stab - check numerical stability of basic solution
316.2340 +*
316.2341 +*  If the current basic solution is dual feasible within a tolerance,
316.2342 +*  this routine returns zero, otherwise it returns non-zero. */
316.2343 +
316.2344 +static int check_stab(struct csa *csa, double tol_dj)
316.2345 +{     int n = csa->n;
316.2346 +      char *stat = csa->stat;
316.2347 +      double *cbar = csa->cbar;
316.2348 +      int j;
316.2349 +      for (j = 1; j <= n; j++)
316.2350 +      {  if (cbar[j] < - tol_dj)
316.2351 +            if (stat[j] == GLP_NL || stat[j] == GLP_NF) return 1;
316.2352 +         if (cbar[j] > + tol_dj)
316.2353 +            if (stat[j] == GLP_NU || stat[j] == GLP_NF) return 1;
316.2354 +      }
316.2355 +      return 0;
316.2356 +}
316.2357 +
316.2358 +#if 1 /* copied from primal */
316.2359 +/***********************************************************************
316.2360 +*  eval_obj - compute original objective function
316.2361 +*
316.2362 +*  This routine computes the current value of the original objective
316.2363 +*  function. */
316.2364 +
316.2365 +static double eval_obj(struct csa *csa)
316.2366 +{     int m = csa->m;
316.2367 +      int n = csa->n;
316.2368 +      double *obj = csa->obj;
316.2369 +      int *head = csa->head;
316.2370 +      double *bbar = csa->bbar;
316.2371 +      int i, j, k;
316.2372 +      double sum;
316.2373 +      sum = obj[0];
316.2374 +      /* walk through the list of basic variables */
316.2375 +      for (i = 1; i <= m; i++)
316.2376 +      {  k = head[i]; /* x[k] = xB[i] */
316.2377 +#ifdef GLP_DEBUG
316.2378 +         xassert(1 <= k && k <= m+n);
316.2379 +#endif
316.2380 +         if (k > m)
316.2381 +            sum += obj[k-m] * bbar[i];
316.2382 +      }
316.2383 +      /* walk through the list of non-basic variables */
316.2384 +      for (j = 1; j <= n; j++)
316.2385 +      {  k = head[m+j]; /* x[k] = xN[j] */
316.2386 +#ifdef GLP_DEBUG
316.2387 +         xassert(1 <= k && k <= m+n);
316.2388 +#endif
316.2389 +         if (k > m)
316.2390 +            sum += obj[k-m] * get_xN(csa, j);
316.2391 +      }
316.2392 +      return sum;
316.2393 +}
316.2394 +#endif
316.2395 +
316.2396 +/***********************************************************************
316.2397 +*  display - display the search progress
316.2398 +*
316.2399 +*  This routine displays some information about the search progress. */
316.2400 +
316.2401 +static void display(struct csa *csa, const glp_smcp *parm, int spec)
316.2402 +{     int m = csa->m;
316.2403 +      int n = csa->n;
316.2404 +      double *coef = csa->coef;
316.2405 +      char *orig_type = csa->orig_type;
316.2406 +      int *head = csa->head;
316.2407 +      char *stat = csa->stat;
316.2408 +      int phase = csa->phase;
316.2409 +      double *bbar = csa->bbar;
316.2410 +      double *cbar = csa->cbar;
316.2411 +      int i, j, cnt;
316.2412 +      double sum;
316.2413 +      if (parm->msg_lev < GLP_MSG_ON) goto skip;
316.2414 +      if (parm->out_dly > 0 &&
316.2415 +         1000.0 * xdifftime(xtime(), csa->tm_beg) < parm->out_dly)
316.2416 +         goto skip;
316.2417 +      if (csa->it_cnt == csa->it_dpy) goto skip;
316.2418 +      if (!spec && csa->it_cnt % parm->out_frq != 0) goto skip;
316.2419 +      /* compute the sum of dual infeasibilities */
316.2420 +      sum = 0.0;
316.2421 +      if (phase == 1)
316.2422 +      {  for (i = 1; i <= m; i++)
316.2423 +            sum -= coef[head[i]] * bbar[i];
316.2424 +         for (j = 1; j <= n; j++)
316.2425 +            sum -= coef[head[m+j]] * get_xN(csa, j);
316.2426 +      }
316.2427 +      else
316.2428 +      {  for (j = 1; j <= n; j++)
316.2429 +         {  if (cbar[j] < 0.0)
316.2430 +               if (stat[j] == GLP_NL || stat[j] == GLP_NF)
316.2431 +                  sum -= cbar[j];
316.2432 +            if (cbar[j] > 0.0)
316.2433 +               if (stat[j] == GLP_NU || stat[j] == GLP_NF)
316.2434 +                  sum += cbar[j];
316.2435 +         }
316.2436 +      }
316.2437 +      /* determine the number of basic fixed variables */
316.2438 +      cnt = 0;
316.2439 +      for (i = 1; i <= m; i++)
316.2440 +         if (orig_type[head[i]] == GLP_FX) cnt++;
316.2441 +      if (csa->phase == 1)
316.2442 +         xprintf(" %6d: %24s infeas = %10.3e (%d)\n",
316.2443 +            csa->it_cnt, "", sum, cnt);
316.2444 +      else
316.2445 +         xprintf("|%6d: obj = %17.9e  infeas = %10.3e (%d)\n",
316.2446 +            csa->it_cnt, eval_obj(csa), sum, cnt);
316.2447 +      csa->it_dpy = csa->it_cnt;
316.2448 +skip: return;
316.2449 +}
316.2450 +
316.2451 +#if 1 /* copied from primal */
316.2452 +/***********************************************************************
316.2453 +*  store_sol - store basic solution back to the problem object
316.2454 +*
316.2455 +*  This routine stores basic solution components back to the problem
316.2456 +*  object. */
316.2457 +
316.2458 +static void store_sol(struct csa *csa, glp_prob *lp, int p_stat,
316.2459 +      int d_stat, int ray)
316.2460 +{     int m = csa->m;
316.2461 +      int n = csa->n;
316.2462 +      double zeta = csa->zeta;
316.2463 +      int *head = csa->head;
316.2464 +      char *stat = csa->stat;
316.2465 +      double *bbar = csa->bbar;
316.2466 +      double *cbar = csa->cbar;
316.2467 +      int i, j, k;
316.2468 +#ifdef GLP_DEBUG
316.2469 +      xassert(lp->m == m);
316.2470 +      xassert(lp->n == n);
316.2471 +#endif
316.2472 +      /* basis factorization */
316.2473 +#ifdef GLP_DEBUG
316.2474 +      xassert(!lp->valid && lp->bfd == NULL);
316.2475 +      xassert(csa->valid && csa->bfd != NULL);
316.2476 +#endif
316.2477 +      lp->valid = 1, csa->valid = 0;
316.2478 +      lp->bfd = csa->bfd, csa->bfd = NULL;
316.2479 +      memcpy(&lp->head[1], &head[1], m * sizeof(int));
316.2480 +      /* basic solution status */
316.2481 +      lp->pbs_stat = p_stat;
316.2482 +      lp->dbs_stat = d_stat;
316.2483 +      /* objective function value */
316.2484 +      lp->obj_val = eval_obj(csa);
316.2485 +      /* simplex iteration count */
316.2486 +      lp->it_cnt = csa->it_cnt;
316.2487 +      /* unbounded ray */
316.2488 +      lp->some = ray;
316.2489 +      /* basic variables */
316.2490 +      for (i = 1; i <= m; i++)
316.2491 +      {  k = head[i]; /* x[k] = xB[i] */
316.2492 +#ifdef GLP_DEBUG
316.2493 +         xassert(1 <= k && k <= m+n);
316.2494 +#endif
316.2495 +         if (k <= m)
316.2496 +         {  GLPROW *row = lp->row[k];
316.2497 +            row->stat = GLP_BS;
316.2498 +            row->bind = i;
316.2499 +            row->prim = bbar[i] / row->rii;
316.2500 +            row->dual = 0.0;
316.2501 +         }
316.2502 +         else
316.2503 +         {  GLPCOL *col = lp->col[k-m];
316.2504 +            col->stat = GLP_BS;
316.2505 +            col->bind = i;
316.2506 +            col->prim = bbar[i] * col->sjj;
316.2507 +            col->dual = 0.0;
316.2508 +         }
316.2509 +      }
316.2510 +      /* non-basic variables */
316.2511 +      for (j = 1; j <= n; j++)
316.2512 +      {  k = head[m+j]; /* x[k] = xN[j] */
316.2513 +#ifdef GLP_DEBUG
316.2514 +         xassert(1 <= k && k <= m+n);
316.2515 +#endif
316.2516 +         if (k <= m)
316.2517 +         {  GLPROW *row = lp->row[k];
316.2518 +            row->stat = stat[j];
316.2519 +            row->bind = 0;
316.2520 +#if 0
316.2521 +            row->prim = get_xN(csa, j) / row->rii;
316.2522 +#else
316.2523 +            switch (stat[j])
316.2524 +            {  case GLP_NL:
316.2525 +                  row->prim = row->lb; break;
316.2526 +               case GLP_NU:
316.2527 +                  row->prim = row->ub; break;
316.2528 +               case GLP_NF:
316.2529 +                  row->prim = 0.0; break;
316.2530 +               case GLP_NS:
316.2531 +                  row->prim = row->lb; break;
316.2532 +               default:
316.2533 +                  xassert(stat != stat);
316.2534 +            }
316.2535 +#endif
316.2536 +            row->dual = (cbar[j] * row->rii) / zeta;
316.2537 +         }
316.2538 +         else
316.2539 +         {  GLPCOL *col = lp->col[k-m];
316.2540 +            col->stat = stat[j];
316.2541 +            col->bind = 0;
316.2542 +#if 0
316.2543 +            col->prim = get_xN(csa, j) * col->sjj;
316.2544 +#else
316.2545 +            switch (stat[j])
316.2546 +            {  case GLP_NL:
316.2547 +                  col->prim = col->lb; break;
316.2548 +               case GLP_NU:
316.2549 +                  col->prim = col->ub; break;
316.2550 +               case GLP_NF:
316.2551 +                  col->prim = 0.0; break;
316.2552 +               case GLP_NS:
316.2553 +                  col->prim = col->lb; break;
316.2554 +               default:
316.2555 +                  xassert(stat != stat);
316.2556 +            }
316.2557 +#endif
316.2558 +            col->dual = (cbar[j] / col->sjj) / zeta;
316.2559 +         }
316.2560 +      }
316.2561 +      return;
316.2562 +}
316.2563 +#endif
316.2564 +
316.2565 +/***********************************************************************
316.2566 +*  free_csa - deallocate common storage area
316.2567 +*
316.2568 +*  This routine frees all the memory allocated to arrays in the common
316.2569 +*  storage area (CSA). */
316.2570 +
316.2571 +static void free_csa(struct csa *csa)
316.2572 +{     xfree(csa->type);
316.2573 +      xfree(csa->lb);
316.2574 +      xfree(csa->ub);
316.2575 +      xfree(csa->coef);
316.2576 +      xfree(csa->orig_type);
316.2577 +      xfree(csa->orig_lb);
316.2578 +      xfree(csa->orig_ub);
316.2579 +      xfree(csa->obj);
316.2580 +      xfree(csa->A_ptr);
316.2581 +      xfree(csa->A_ind);
316.2582 +      xfree(csa->A_val);
316.2583 +#if 1 /* 06/IV-2009 */
316.2584 +      xfree(csa->AT_ptr);
316.2585 +      xfree(csa->AT_ind);
316.2586 +      xfree(csa->AT_val);
316.2587 +#endif
316.2588 +      xfree(csa->head);
316.2589 +#if 1 /* 06/IV-2009 */
316.2590 +      xfree(csa->bind);
316.2591 +#endif
316.2592 +      xfree(csa->stat);
316.2593 +#if 0 /* 06/IV-2009 */
316.2594 +      xfree(csa->N_ptr);
316.2595 +      xfree(csa->N_len);
316.2596 +      xfree(csa->N_ind);
316.2597 +      xfree(csa->N_val);
316.2598 +#endif
316.2599 +      xfree(csa->bbar);
316.2600 +      xfree(csa->cbar);
316.2601 +      xfree(csa->refsp);
316.2602 +      xfree(csa->gamma);
316.2603 +      xfree(csa->trow_ind);
316.2604 +      xfree(csa->trow_vec);
316.2605 +#ifdef GLP_LONG_STEP /* 07/IV-2009 */
316.2606 +      xfree(csa->bkpt);
316.2607 +#endif
316.2608 +      xfree(csa->tcol_ind);
316.2609 +      xfree(csa->tcol_vec);
316.2610 +      xfree(csa->work1);
316.2611 +      xfree(csa->work2);
316.2612 +      xfree(csa->work3);
316.2613 +      xfree(csa->work4);
316.2614 +      xfree(csa);
316.2615 +      return;
316.2616 +}
316.2617 +
316.2618 +/***********************************************************************
316.2619 +*  spx_dual - core LP solver based on the dual simplex method
316.2620 +*
316.2621 +*  SYNOPSIS
316.2622 +*
316.2623 +*  #include "glpspx.h"
316.2624 +*  int spx_dual(glp_prob *lp, const glp_smcp *parm);
316.2625 +*
316.2626 +*  DESCRIPTION
316.2627 +*
316.2628 +*  The routine spx_dual is a core LP solver based on the two-phase dual
316.2629 +*  simplex method.
316.2630 +*
316.2631 +*  RETURNS
316.2632 +*
316.2633 +*  0  LP instance has been successfully solved.
316.2634 +*
316.2635 +*  GLP_EOBJLL
316.2636 +*     Objective lower limit has been reached (maximization).
316.2637 +*
316.2638 +*  GLP_EOBJUL
316.2639 +*     Objective upper limit has been reached (minimization).
316.2640 +*
316.2641 +*  GLP_EITLIM
316.2642 +*     Iteration limit has been exhausted.
316.2643 +*
316.2644 +*  GLP_ETMLIM
316.2645 +*     Time limit has been exhausted.
316.2646 +*
316.2647 +*  GLP_EFAIL
316.2648 +*     The solver failed to solve LP instance. */
316.2649 +
316.2650 +int spx_dual(glp_prob *lp, const glp_smcp *parm)
316.2651 +{     struct csa *csa;
316.2652 +      int binv_st = 2;
316.2653 +      /* status of basis matrix factorization:
316.2654 +         0 - invalid; 1 - just computed; 2 - updated */
316.2655 +      int bbar_st = 0;
316.2656 +      /* status of primal values of basic variables:
316.2657 +         0 - invalid; 1 - just computed; 2 - updated */
316.2658 +      int cbar_st = 0;
316.2659 +      /* status of reduced costs of non-basic variables:
316.2660 +         0 - invalid; 1 - just computed; 2 - updated */
316.2661 +      int rigorous = 0;
316.2662 +      /* rigorous mode flag; this flag is used to enable iterative
316.2663 +         refinement on computing pivot rows and columns of the simplex
316.2664 +         table */
316.2665 +      int check = 0;
316.2666 +      int p_stat, d_stat, ret;
316.2667 +      /* allocate and initialize the common storage area */
316.2668 +      csa = alloc_csa(lp);
316.2669 +      init_csa(csa, lp);
316.2670 +      if (parm->msg_lev >= GLP_MSG_DBG)
316.2671 +         xprintf("Objective scale factor = %g\n", csa->zeta);
316.2672 +loop: /* main loop starts here */
316.2673 +      /* compute factorization of the basis matrix */
316.2674 +      if (binv_st == 0)
316.2675 +      {  ret = invert_B(csa);
316.2676 +         if (ret != 0)
316.2677 +         {  if (parm->msg_lev >= GLP_MSG_ERR)
316.2678 +            {  xprintf("Error: unable to factorize the basis matrix (%d"
316.2679 +                  ")\n", ret);
316.2680 +               xprintf("Sorry, basis recovery procedure not implemented"
316.2681 +                  " yet\n");
316.2682 +            }
316.2683 +            xassert(!lp->valid && lp->bfd == NULL);
316.2684 +            lp->bfd = csa->bfd, csa->bfd = NULL;
316.2685 +            lp->pbs_stat = lp->dbs_stat = GLP_UNDEF;
316.2686 +            lp->obj_val = 0.0;
316.2687 +            lp->it_cnt = csa->it_cnt;
316.2688 +            lp->some = 0;
316.2689 +            ret = GLP_EFAIL;
316.2690 +            goto done;
316.2691 +         }
316.2692 +         csa->valid = 1;
316.2693 +         binv_st = 1; /* just computed */
316.2694 +         /* invalidate basic solution components */
316.2695 +         bbar_st = cbar_st = 0;
316.2696 +      }
316.2697 +      /* compute reduced costs of non-basic variables */
316.2698 +      if (cbar_st == 0)
316.2699 +      {  eval_cbar(csa);
316.2700 +         cbar_st = 1; /* just computed */
316.2701 +         /* determine the search phase, if not determined yet */
316.2702 +         if (csa->phase == 0)
316.2703 +         {  if (check_feas(csa, 0.90 * parm->tol_dj) != 0)
316.2704 +            {  /* current basic solution is dual infeasible */
316.2705 +               /* start searching for dual feasible solution */
316.2706 +               csa->phase = 1;
316.2707 +               set_aux_bnds(csa);
316.2708 +            }
316.2709 +            else
316.2710 +            {  /* current basic solution is dual feasible */
316.2711 +               /* start searching for optimal solution */
316.2712 +               csa->phase = 2;
316.2713 +               set_orig_bnds(csa);
316.2714 +            }
316.2715 +            xassert(check_stab(csa, parm->tol_dj) == 0);
316.2716 +            /* some non-basic double-bounded variables might become
316.2717 +               fixed (on phase I) or vice versa (on phase II) */
316.2718 +#if 0 /* 06/IV-2009 */
316.2719 +            build_N(csa);
316.2720 +#endif
316.2721 +            csa->refct = 0;
316.2722 +            /* bounds of non-basic variables have been changed, so
316.2723 +               invalidate primal values */
316.2724 +            bbar_st = 0;
316.2725 +         }
316.2726 +         /* make sure that the current basic solution remains dual
316.2727 +            feasible */
316.2728 +         if (check_stab(csa, parm->tol_dj) != 0)
316.2729 +         {  if (parm->msg_lev >= GLP_MSG_ERR)
316.2730 +               xprintf("Warning: numerical instability (dual simplex, p"
316.2731 +                  "hase %s)\n", csa->phase == 1 ? "I" : "II");
316.2732 +#if 1
316.2733 +            if (parm->meth == GLP_DUALP)
316.2734 +            {  store_sol(csa, lp, GLP_UNDEF, GLP_UNDEF, 0);
316.2735 +               ret = GLP_EFAIL;
316.2736 +               goto done;
316.2737 +            }
316.2738 +#endif
316.2739 +            /* restart the search */
316.2740 +            csa->phase = 0;
316.2741 +            binv_st = 0;
316.2742 +            rigorous = 5;
316.2743 +            goto loop;
316.2744 +         }
316.2745 +      }
316.2746 +      xassert(csa->phase == 1 || csa->phase == 2);
316.2747 +      /* on phase I we do not need to wait until the current basic
316.2748 +         solution becomes primal feasible; it is sufficient to make
316.2749 +         sure that all reduced costs have correct signs */
316.2750 +      if (csa->phase == 1 && check_feas(csa, parm->tol_dj) == 0)
316.2751 +      {  /* the current basis is dual feasible; switch to phase II */
316.2752 +         display(csa, parm, 1);
316.2753 +         csa->phase = 2;
316.2754 +         if (cbar_st != 1)
316.2755 +         {  eval_cbar(csa);
316.2756 +            cbar_st = 1;
316.2757 +         }
316.2758 +         set_orig_bnds(csa);
316.2759 +#if 0 /* 06/IV-2009 */
316.2760 +         build_N(csa);
316.2761 +#endif
316.2762 +         csa->refct = 0;
316.2763 +         bbar_st = 0;
316.2764 +      }
316.2765 +      /* compute primal values of basic variables */
316.2766 +      if (bbar_st == 0)
316.2767 +      {  eval_bbar(csa);
316.2768 +         if (csa->phase == 2)
316.2769 +            csa->bbar[0] = eval_obj(csa);
316.2770 +         bbar_st = 1; /* just computed */
316.2771 +      }
316.2772 +      /* redefine the reference space, if required */
316.2773 +      switch (parm->pricing)
316.2774 +      {  case GLP_PT_STD:
316.2775 +            break;
316.2776 +         case GLP_PT_PSE:
316.2777 +            if (csa->refct == 0) reset_refsp(csa);
316.2778 +            break;
316.2779 +         default:
316.2780 +            xassert(parm != parm);
316.2781 +      }
316.2782 +      /* at this point the basis factorization and all basic solution
316.2783 +         components are valid */
316.2784 +      xassert(binv_st && bbar_st && cbar_st);
316.2785 +      /* check accuracy of current basic solution components (only for
316.2786 +         debugging) */
316.2787 +      if (check)
316.2788 +      {  double e_bbar = err_in_bbar(csa);
316.2789 +         double e_cbar = err_in_cbar(csa);
316.2790 +         double e_gamma =
316.2791 +            (parm->pricing == GLP_PT_PSE ? err_in_gamma(csa) : 0.0);
316.2792 +         xprintf("e_bbar = %10.3e; e_cbar = %10.3e; e_gamma = %10.3e\n",
316.2793 +            e_bbar, e_cbar, e_gamma);
316.2794 +         xassert(e_bbar <= 1e-5 && e_cbar <= 1e-5 && e_gamma <= 1e-3);
316.2795 +      }
316.2796 +      /* if the objective has to be maximized, check if it has reached
316.2797 +         its lower limit */
316.2798 +      if (csa->phase == 2 && csa->zeta < 0.0 &&
316.2799 +          parm->obj_ll > -DBL_MAX && csa->bbar[0] <= parm->obj_ll)
316.2800 +      {  if (bbar_st != 1 || cbar_st != 1)
316.2801 +         {  if (bbar_st != 1) bbar_st = 0;
316.2802 +            if (cbar_st != 1) cbar_st = 0;
316.2803 +            goto loop;
316.2804 +         }
316.2805 +         display(csa, parm, 1);
316.2806 +         if (parm->msg_lev >= GLP_MSG_ALL)
316.2807 +            xprintf("OBJECTIVE LOWER LIMIT REACHED; SEARCH TERMINATED\n"
316.2808 +               );
316.2809 +         store_sol(csa, lp, GLP_INFEAS, GLP_FEAS, 0);
316.2810 +         ret = GLP_EOBJLL;
316.2811 +         goto done;
316.2812 +      }
316.2813 +      /* if the objective has to be minimized, check if it has reached
316.2814 +         its upper limit */
316.2815 +      if (csa->phase == 2 && csa->zeta > 0.0 &&
316.2816 +          parm->obj_ul < +DBL_MAX && csa->bbar[0] >= parm->obj_ul)
316.2817 +      {  if (bbar_st != 1 || cbar_st != 1)
316.2818 +         {  if (bbar_st != 1) bbar_st = 0;
316.2819 +            if (cbar_st != 1) cbar_st = 0;
316.2820 +            goto loop;
316.2821 +         }
316.2822 +         display(csa, parm, 1);
316.2823 +         if (parm->msg_lev >= GLP_MSG_ALL)
316.2824 +            xprintf("OBJECTIVE UPPER LIMIT REACHED; SEARCH TERMINATED\n"
316.2825 +               );
316.2826 +         store_sol(csa, lp, GLP_INFEAS, GLP_FEAS, 0);
316.2827 +         ret = GLP_EOBJUL;
316.2828 +         goto done;
316.2829 +      }
316.2830 +      /* check if the iteration limit has been exhausted */
316.2831 +      if (parm->it_lim < INT_MAX &&
316.2832 +          csa->it_cnt - csa->it_beg >= parm->it_lim)
316.2833 +      {  if (csa->phase == 2 && bbar_st != 1 || cbar_st != 1)
316.2834 +         {  if (csa->phase == 2 && bbar_st != 1) bbar_st = 0;
316.2835 +            if (cbar_st != 1) cbar_st = 0;
316.2836 +            goto loop;
316.2837 +         }
316.2838 +         display(csa, parm, 1);
316.2839 +         if (parm->msg_lev >= GLP_MSG_ALL)
316.2840 +            xprintf("ITERATION LIMIT EXCEEDED; SEARCH TERMINATED\n");
316.2841 +         switch (csa->phase)
316.2842 +         {  case 1:
316.2843 +               d_stat = GLP_INFEAS;
316.2844 +               set_orig_bnds(csa);
316.2845 +               eval_bbar(csa);
316.2846 +               break;
316.2847 +            case 2:
316.2848 +               d_stat = GLP_FEAS;
316.2849 +               break;
316.2850 +            default:
316.2851 +               xassert(csa != csa);
316.2852 +         }
316.2853 +         store_sol(csa, lp, GLP_INFEAS, d_stat, 0);
316.2854 +         ret = GLP_EITLIM;
316.2855 +         goto done;
316.2856 +      }
316.2857 +      /* check if the time limit has been exhausted */
316.2858 +      if (parm->tm_lim < INT_MAX &&
316.2859 +          1000.0 * xdifftime(xtime(), csa->tm_beg) >= parm->tm_lim)
316.2860 +      {  if (csa->phase == 2 && bbar_st != 1 || cbar_st != 1)
316.2861 +         {  if (csa->phase == 2 && bbar_st != 1) bbar_st = 0;
316.2862 +            if (cbar_st != 1) cbar_st = 0;
316.2863 +            goto loop;
316.2864 +         }
316.2865 +         display(csa, parm, 1);
316.2866 +         if (parm->msg_lev >= GLP_MSG_ALL)
316.2867 +            xprintf("TIME LIMIT EXCEEDED; SEARCH TERMINATED\n");
316.2868 +         switch (csa->phase)
316.2869 +         {  case 1:
316.2870 +               d_stat = GLP_INFEAS;
316.2871 +               set_orig_bnds(csa);
316.2872 +               eval_bbar(csa);
316.2873 +               break;
316.2874 +            case 2:
316.2875 +               d_stat = GLP_FEAS;
316.2876 +               break;
316.2877 +            default:
316.2878 +               xassert(csa != csa);
316.2879 +         }
316.2880 +         store_sol(csa, lp, GLP_INFEAS, d_stat, 0);
316.2881 +         ret = GLP_ETMLIM;
316.2882 +         goto done;
316.2883 +      }
316.2884 +      /* display the search progress */
316.2885 +      display(csa, parm, 0);
316.2886 +      /* choose basic variable xB[p] */
316.2887 +      chuzr(csa, parm->tol_bnd);
316.2888 +      if (csa->p == 0)
316.2889 +      {  if (bbar_st != 1 || cbar_st != 1)
316.2890 +         {  if (bbar_st != 1) bbar_st = 0;
316.2891 +            if (cbar_st != 1) cbar_st = 0;
316.2892 +            goto loop;
316.2893 +         }
316.2894 +         display(csa, parm, 1);
316.2895 +         switch (csa->phase)
316.2896 +         {  case 1:
316.2897 +               if (parm->msg_lev >= GLP_MSG_ALL)
316.2898 +                  xprintf("PROBLEM HAS NO DUAL FEASIBLE SOLUTION\n");
316.2899 +               set_orig_bnds(csa);
316.2900 +               eval_bbar(csa);
316.2901 +               p_stat = GLP_INFEAS, d_stat = GLP_NOFEAS;
316.2902 +               break;
316.2903 +            case 2:
316.2904 +               if (parm->msg_lev >= GLP_MSG_ALL)
316.2905 +                  xprintf("OPTIMAL SOLUTION FOUND\n");
316.2906 +               p_stat = d_stat = GLP_FEAS;
316.2907 +               break;
316.2908 +            default:
316.2909 +               xassert(csa != csa);
316.2910 +         }
316.2911 +         store_sol(csa, lp, p_stat, d_stat, 0);
316.2912 +         ret = 0;
316.2913 +         goto done;
316.2914 +      }
316.2915 +      /* compute pivot row of the simplex table */
316.2916 +      {  double *rho = csa->work4;
316.2917 +         eval_rho(csa, rho);
316.2918 +         if (rigorous) refine_rho(csa, rho);
316.2919 +         eval_trow(csa, rho);
316.2920 +         sort_trow(csa, parm->tol_bnd);
316.2921 +      }
316.2922 +      /* unlike primal simplex there is no need to check accuracy of
316.2923 +         the primal value of xB[p] (which might be computed using the
316.2924 +         pivot row), since bbar is a result of FTRAN */
316.2925 +#ifdef GLP_LONG_STEP /* 07/IV-2009 */
316.2926 +      long_step(csa);
316.2927 +      if (csa->nbps > 0)
316.2928 +      {  csa->q = csa->bkpt[csa->nbps].j;
316.2929 +         if (csa->delta > 0.0)
316.2930 +            csa->new_dq = + csa->bkpt[csa->nbps].t;
316.2931 +         else
316.2932 +            csa->new_dq = - csa->bkpt[csa->nbps].t;
316.2933 +      }
316.2934 +      else
316.2935 +#endif
316.2936 +      /* choose non-basic variable xN[q] */
316.2937 +      switch (parm->r_test)
316.2938 +      {  case GLP_RT_STD:
316.2939 +            chuzc(csa, 0.0);
316.2940 +            break;
316.2941 +         case GLP_RT_HAR:
316.2942 +            chuzc(csa, 0.30 * parm->tol_dj);
316.2943 +            break;
316.2944 +         default:
316.2945 +            xassert(parm != parm);
316.2946 +      }
316.2947 +      if (csa->q == 0)
316.2948 +      {  if (bbar_st != 1 || cbar_st != 1 || !rigorous)
316.2949 +         {  if (bbar_st != 1) bbar_st = 0;
316.2950 +            if (cbar_st != 1) cbar_st = 0;
316.2951 +            rigorous = 1;
316.2952 +            goto loop;
316.2953 +         }
316.2954 +         display(csa, parm, 1);
316.2955 +         switch (csa->phase)
316.2956 +         {  case 1:
316.2957 +               if (parm->msg_lev >= GLP_MSG_ERR)
316.2958 +                  xprintf("Error: unable to choose basic variable on ph"
316.2959 +                     "ase I\n");
316.2960 +               xassert(!lp->valid && lp->bfd == NULL);
316.2961 +               lp->bfd = csa->bfd, csa->bfd = NULL;
316.2962 +               lp->pbs_stat = lp->dbs_stat = GLP_UNDEF;
316.2963 +               lp->obj_val = 0.0;
316.2964 +               lp->it_cnt = csa->it_cnt;
316.2965 +               lp->some = 0;
316.2966 +               ret = GLP_EFAIL;
316.2967 +               break;
316.2968 +            case 2:
316.2969 +               if (parm->msg_lev >= GLP_MSG_ALL)
316.2970 +                  xprintf("PROBLEM HAS NO FEASIBLE SOLUTION\n");
316.2971 +               store_sol(csa, lp, GLP_NOFEAS, GLP_FEAS,
316.2972 +                  csa->head[csa->p]);
316.2973 +               ret = 0;
316.2974 +               break;
316.2975 +            default:
316.2976 +               xassert(csa != csa);
316.2977 +         }
316.2978 +         goto done;
316.2979 +      }
316.2980 +      /* check if the pivot element is acceptable */
316.2981 +      {  double piv = csa->trow_vec[csa->q];
316.2982 +         double eps = 1e-5 * (1.0 + 0.01 * csa->trow_max);
316.2983 +         if (fabs(piv) < eps)
316.2984 +         {  if (parm->msg_lev >= GLP_MSG_DBG)
316.2985 +               xprintf("piv = %.12g; eps = %g\n", piv, eps);
316.2986 +            if (!rigorous)
316.2987 +            {  rigorous = 5;
316.2988 +               goto loop;
316.2989 +            }
316.2990 +         }
316.2991 +      }
316.2992 +      /* now xN[q] and xB[p] have been chosen anyhow */
316.2993 +      /* compute pivot column of the simplex table */
316.2994 +      eval_tcol(csa);
316.2995 +      if (rigorous) refine_tcol(csa);
316.2996 +      /* accuracy check based on the pivot element */
316.2997 +      {  double piv1 = csa->tcol_vec[csa->p]; /* more accurate */
316.2998 +         double piv2 = csa->trow_vec[csa->q]; /* less accurate */
316.2999 +         xassert(piv1 != 0.0);
316.3000 +         if (fabs(piv1 - piv2) > 1e-8 * (1.0 + fabs(piv1)) ||
316.3001 +             !(piv1 > 0.0 && piv2 > 0.0 || piv1 < 0.0 && piv2 < 0.0))
316.3002 +         {  if (parm->msg_lev >= GLP_MSG_DBG)
316.3003 +               xprintf("piv1 = %.12g; piv2 = %.12g\n", piv1, piv2);
316.3004 +            if (binv_st != 1 || !rigorous)
316.3005 +            {  if (binv_st != 1) binv_st = 0;
316.3006 +               rigorous = 5;
316.3007 +               goto loop;
316.3008 +            }
316.3009 +            /* (not a good idea; should be revised later) */
316.3010 +            if (csa->tcol_vec[csa->p] == 0.0)
316.3011 +            {  csa->tcol_nnz++;
316.3012 +               xassert(csa->tcol_nnz <= csa->m);
316.3013 +               csa->tcol_ind[csa->tcol_nnz] = csa->p;
316.3014 +            }
316.3015 +            csa->tcol_vec[csa->p] = piv2;
316.3016 +         }
316.3017 +      }
316.3018 +      /* update primal values of basic variables */
316.3019 +#ifdef GLP_LONG_STEP /* 07/IV-2009 */
316.3020 +      if (csa->nbps > 0)
316.3021 +      {  int kk, j, k;
316.3022 +         for (kk = 1; kk < csa->nbps; kk++)
316.3023 +         {  if (csa->bkpt[kk].t >= csa->bkpt[csa->nbps].t) continue;
316.3024 +            j = csa->bkpt[kk].j;
316.3025 +            k = csa->head[csa->m + j];
316.3026 +            xassert(csa->type[k] == GLP_DB);
316.3027 +            if (csa->stat[j] == GLP_NL)
316.3028 +               csa->stat[j] = GLP_NU;
316.3029 +            else
316.3030 +               csa->stat[j] = GLP_NL;
316.3031 +         }
316.3032 +      }
316.3033 +      bbar_st = 0;
316.3034 +#else
316.3035 +      update_bbar(csa);
316.3036 +      if (csa->phase == 2)
316.3037 +         csa->bbar[0] += (csa->cbar[csa->q] / csa->zeta) *
316.3038 +            (csa->delta / csa->tcol_vec[csa->p]);
316.3039 +      bbar_st = 2; /* updated */
316.3040 +#endif
316.3041 +      /* update reduced costs of non-basic variables */
316.3042 +      update_cbar(csa);
316.3043 +      cbar_st = 2; /* updated */
316.3044 +      /* update steepest edge coefficients */
316.3045 +      switch (parm->pricing)
316.3046 +      {  case GLP_PT_STD:
316.3047 +            break;
316.3048 +         case GLP_PT_PSE:
316.3049 +            if (csa->refct > 0) update_gamma(csa);
316.3050 +            break;
316.3051 +         default:
316.3052 +            xassert(parm != parm);
316.3053 +      }
316.3054 +      /* update factorization of the basis matrix */
316.3055 +      ret = update_B(csa, csa->p, csa->head[csa->m+csa->q]);
316.3056 +      if (ret == 0)
316.3057 +         binv_st = 2; /* updated */
316.3058 +      else
316.3059 +      {  csa->valid = 0;
316.3060 +         binv_st = 0; /* invalid */
316.3061 +      }
316.3062 +#if 0 /* 06/IV-2009 */
316.3063 +      /* update matrix N */
316.3064 +      del_N_col(csa, csa->q, csa->head[csa->m+csa->q]);
316.3065 +      if (csa->type[csa->head[csa->p]] != GLP_FX)
316.3066 +         add_N_col(csa, csa->q, csa->head[csa->p]);
316.3067 +#endif
316.3068 +      /* change the basis header */
316.3069 +      change_basis(csa);
316.3070 +      /* iteration complete */
316.3071 +      csa->it_cnt++;
316.3072 +      if (rigorous > 0) rigorous--;
316.3073 +      goto loop;
316.3074 +done: /* deallocate the common storage area */
316.3075 +      free_csa(csa);
316.3076 +      /* return to the calling program */
316.3077 +      return ret;
316.3078 +}
316.3079 +
316.3080 +/* eof */
   317.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
   317.2 +++ b/deps/glpk/src/glpsql.c	Sun Nov 06 20:59:10 2011 +0100
   317.3 @@ -0,0 +1,1631 @@
   317.4 +/* glpsql.c */
   317.5 +
   317.6 +/***********************************************************************
   317.7 +*  This code is part of GLPK (GNU Linear Programming Kit).
   317.8 +*
   317.9 +*  Author: Heinrich Schuchardt <xypron.glpk@gmx.de>.
  317.10 +*
  317.11 +*  Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008,
  317.12 +*  2009, 2010 Andrew Makhorin, Department for Applied Informatics,
  317.13 +*  Moscow Aviation Institute, Moscow, Russia. All rights reserved.
  317.14 +*  E-mail: <mao@gnu.org>.
  317.15 +*
  317.16 +*  GLPK is free software: you can redistribute it and/or modify it
  317.17 +*  under the terms of the GNU General Public License as published by
  317.18 +*  the Free Software Foundation, either version 3 of the License, or
  317.19 +*  (at your option) any later version.
  317.20 +*
  317.21 +*  GLPK is distributed in the hope that it will be useful, but WITHOUT
  317.22 +*  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
  317.23 +*  or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
  317.24 +*  License for more details.
  317.25 +*
  317.26 +*  You should have received a copy of the GNU General Public License
  317.27 +*  along with GLPK. If not, see <http://www.gnu.org/licenses/>.
  317.28 +***********************************************************************/
  317.29 +
  317.30 +#ifdef HAVE_CONFIG_H
  317.31 +#include <config.h>
  317.32 +#endif
  317.33 +
  317.34 +#include "glpmpl.h"
  317.35 +#include "glpsql.h"
  317.36 +
  317.37 +#ifdef ODBC_DLNAME
  317.38 +#define HAVE_ODBC
  317.39 +#define libodbc ODBC_DLNAME
  317.40 +#define h_odbc (get_env_ptr()->h_odbc)
  317.41 +#endif
  317.42 +
  317.43 +#ifdef MYSQL_DLNAME
  317.44 +#define HAVE_MYSQL
  317.45 +#define libmysql MYSQL_DLNAME
  317.46 +#define h_mysql (get_env_ptr()->h_mysql)
  317.47 +#endif
  317.48 +
  317.49 +static void *db_iodbc_open_int(TABDCA *dca, int mode, const char
  317.50 +      **sqllines);
  317.51 +static void *db_mysql_open_int(TABDCA *dca, int mode, const char
  317.52 +      **sqllines);
  317.53 +
  317.54 +/**********************************************************************/
  317.55 +
  317.56 +#if defined(HAVE_ODBC) || defined(HAVE_MYSQL)
  317.57 +
  317.58 +#define SQL_FIELD_MAX 100
  317.59 +/* maximal field count */
  317.60 +
  317.61 +#define SQL_FDLEN_MAX 255
  317.62 +/* maximal field length */
  317.63 +
  317.64 +/***********************************************************************
  317.65 +*  NAME
  317.66 +*
  317.67 +*  args_concat - concatenate arguments
  317.68 +*
  317.69 +*  SYNOPSIS
  317.70 +*
  317.71 +*  static char **args_concat(TABDCA *dca);
  317.72 +*
  317.73 +*  DESCRIPTION
  317.74 +*
  317.75 +*  The arguments passed in dca are SQL statements. A SQL statement may
  317.76 +*  be split over multiple arguments. The last argument of a SQL
  317.77 +*  statement will be terminated with a semilocon. Each SQL statement is
  317.78 +*  merged into a single zero terminated string. Boundaries between
  317.79 +*  arguments are replaced by space.
  317.80 +*
  317.81 +*  RETURNS
  317.82 +*
  317.83 +*  Buffer with SQL statements */
  317.84 +
  317.85 +static char **args_concat(TABDCA *dca)
  317.86 +{
  317.87 +   const char  *arg;
  317.88 +   int          i;
  317.89 +   int          j;
  317.90 +   int          j0;
  317.91 +   int          j1;
  317.92 +   int          len;
  317.93 +   int          lentot;
  317.94 +   int          narg;
  317.95 +   int          nline = 0;
  317.96 +   void        *ret;
  317.97 +   char       **sqllines = NULL;
  317.98 +
  317.99 +   narg = mpl_tab_num_args(dca);
 317.100 +   /* The SQL statements start with argument 3. */
 317.101 +   if (narg < 3)
 317.102 +      return NULL;
 317.103 +   /* Count the SQL statements */
 317.104 +   for (j = 3; j <= narg; j++)
 317.105 +   {
 317.106 +      arg = mpl_tab_get_arg(dca, j);
 317.107 +      len = strlen(arg);
 317.108 +      if (arg[len-1] == ';' || j == narg)
 317.109 +        nline ++;
 317.110 +   }
 317.111 +   /* Allocate string buffer. */
 317.112 +   sqllines = (char **) xmalloc((nline+1) * sizeof(char **));
 317.113 +   /* Join arguments */
 317.114 +   sqllines[0] = NULL;
 317.115 +   j0     = 3;
 317.116 +   i      = 0;
 317.117 +   lentot = 0;
 317.118 +   for (j = 3; j <= narg; j++)
 317.119 +   {
 317.120 +      arg = mpl_tab_get_arg(dca, j);
 317.121 +      len = strlen(arg);
 317.122 +      /* add length of part */
 317.123 +      lentot += len;
 317.124 +      /* add length of space separating parts or 0x00 at end of SQL
 317.125 +         statement */
 317.126 +      lentot++;
 317.127 +      if (arg[len-1] == ';' || j == narg)
 317.128 +      {  /* Join arguments for a single SQL statement */
 317.129 +         sqllines[i] = xmalloc(lentot);
 317.130 +         sqllines[i+1] = NULL;
 317.131 +         sqllines[i][0] = 0x00;
 317.132 +         for (j1 = j0; j1 <= j; j1++)
 317.133 +         {  if(j1>j0)
 317.134 +               strcat(sqllines[i], " ");
 317.135 +            strcat(sqllines[i], mpl_tab_get_arg(dca, j1));
 317.136 +         }
 317.137 +         len = strlen(sqllines[i]);
 317.138 +         if (sqllines[i][len-1] == ';')
 317.139 +            sqllines[i][len-1] = 0x00;
 317.140 +         j0 = j+1;
 317.141 +         i++;
 317.142 +         lentot = 0;
 317.143 +      }
 317.144 +   }
 317.145 +   return sqllines;
 317.146 +}
 317.147 +
 317.148 +/***********************************************************************
 317.149 +*  NAME
 317.150 +*
 317.151 +*  free_buffer - free multiline string buffer
 317.152 +*
 317.153 +*  SYNOPSIS
 317.154 +*
 317.155 +*  static void free_buffer(char **buf);
 317.156 +*
 317.157 +*  DESCRIPTION
 317.158 +*
 317.159 +*  buf is a list of strings terminated by NULL.
 317.160 +*  The memory for the strings and for the list is released. */
 317.161 +
 317.162 +static void free_buffer(char **buf)
 317.163 +{  int i;
 317.164 +
 317.165 +   for(i = 0; buf[i] != NULL; i++)
 317.166 +      xfree(buf[i]);
 317.167 +   xfree(buf);
 317.168 +}
 317.169 +
 317.170 +static int db_escaped_string_length(const char* from)
 317.171 +/* length of escaped string */
 317.172 +{
 317.173 +   int         count;
 317.174 +   const char *pointer;
 317.175 +
 317.176 +    for (pointer = from, count = 0; *pointer != (char) '\0'; pointer++,
 317.177 +         count++)
 317.178 +    {
 317.179 +      switch (*pointer)
 317.180 +      {
 317.181 +         case '\'':
 317.182 +            count++;
 317.183 +            break;
 317.184 +      }
 317.185 +    }
 317.186 +
 317.187 +    return count;
 317.188 +}
 317.189 +
 317.190 +static int db_escape_string (char *to, const char *from)
 317.191 +/* escape string*/
 317.192 +{
 317.193 +   const char *source = from;
 317.194 +   char *target = to;
 317.195 +   unsigned int remaining;
 317.196 +
 317.197 +   remaining = strlen(from);
 317.198 +
 317.199 +   if (to == NULL)
 317.200 +     to = (char *) (from + remaining);
 317.201 +
 317.202 +   while (remaining > 0)
 317.203 +   {
 317.204 +      switch (*source)
 317.205 +      {
 317.206 +         case '\'':
 317.207 +            *target = '\'';
 317.208 +            target++;
 317.209 +            *target = '\'';
 317.210 +            break;
 317.211 +
 317.212 +         default:
 317.213 +            *target = *source;
 317.214 +            }
 317.215 +      source++;
 317.216 +      target++;
 317.217 +      remaining--;
 317.218 +      }
 317.219 +
 317.220 +   /* Write the terminating NUL character. */
 317.221 +   *target = '\0';
 317.222 +
 317.223 +   return target - to;
 317.224 +}
 317.225 +
 317.226 +static char *db_generate_select_stmt(TABDCA *dca)
 317.227 +/* generate select statement */
 317.228 +{
 317.229 +   char        *arg;
 317.230 +   char const  *field;
 317.231 +   char        *query;
 317.232 +   int          j;
 317.233 +   int          narg;
 317.234 +   int          nf;
 317.235 +   int          total;
 317.236 +
 317.237 +   total = 50;
 317.238 +   nf = mpl_tab_num_flds(dca);
 317.239 +   narg = mpl_tab_num_args(dca);
 317.240 +   for (j=1; j <= nf && j <= SQL_FIELD_MAX; j++)
 317.241 +   {
 317.242 +      field = mpl_tab_get_name(dca, j);
 317.243 +      total += strlen(field);
 317.244 +      total += 2;
 317.245 +   }
 317.246 +   arg = (char *) mpl_tab_get_arg(dca, narg);
 317.247 +   total += strlen(arg);
 317.248 +   query = xmalloc( total * sizeof(char));
 317.249 +   strcpy (query, "SELECT ");
 317.250 +   for (j=1; j <= nf && j <= SQL_FIELD_MAX; j++)
 317.251 +   {
 317.252 +      field = mpl_tab_get_name(dca, j);
 317.253 +      strcat(query, field);
 317.254 +      if ( j < nf )
 317.255 +         strcat(query, ", ");
 317.256 +   }
 317.257 +   strcat(query, " FROM ");
 317.258 +   strcat(query, arg);
 317.259 +   return query;
 317.260 +}
 317.261 +
 317.262 +static char *db_generate_insert_stmt(TABDCA *dca)
 317.263 +/* generate insert statement */
 317.264 +{
 317.265 +   char        *arg;
 317.266 +   char const  *field;
 317.267 +   char        *query;
 317.268 +   int          j;
 317.269 +   int          narg;
 317.270 +   int          nf;
 317.271 +   int          total;
 317.272 +
 317.273 +   total = 50;
 317.274 +   nf = mpl_tab_num_flds(dca);
 317.275 +   narg = mpl_tab_num_args(dca);
 317.276 +   for (j=1; j <= nf && j <= SQL_FIELD_MAX; j++)
 317.277 +   {
 317.278 +      field = mpl_tab_get_name(dca, j);
 317.279 +      total += strlen(field);
 317.280 +      total += 5;
 317.281 +   }
 317.282 +   arg = (char *) mpl_tab_get_arg(dca, narg);
 317.283 +   total += strlen(arg);
 317.284 +   query = xmalloc( (total+1) * sizeof(char));
 317.285 +   strcpy (query, "INSERT INTO ");
 317.286 +   strcat(query, arg);
 317.287 +   strcat(query, " ( ");
 317.288 +   for (j=1; j <= nf && j <= SQL_FIELD_MAX; j++)
 317.289 +   {
 317.290 +      field = mpl_tab_get_name(dca, j);
 317.291 +      strcat(query, field);
 317.292 +      if ( j < nf )
 317.293 +         strcat(query, ", ");
 317.294 +   }
 317.295 +   strcat(query, " ) VALUES ( ");
 317.296 +   for (j=1; j <= nf && j <= SQL_FIELD_MAX; j++)
 317.297 +   {
 317.298 +      strcat(query, "?");
 317.299 +      if ( j < nf )
 317.300 +         strcat(query, ", ");
 317.301 +   }
 317.302 +   strcat(query, " )");
 317.303 +   return query;
 317.304 +}
 317.305 +
 317.306 +#endif
 317.307 +
 317.308 +/**********************************************************************/
 317.309 +
 317.310 +#ifndef HAVE_ODBC
 317.311 +
 317.312 +void *db_iodbc_open(TABDCA *dca, int mode)
 317.313 +{     xassert(dca == dca);
 317.314 +      xassert(mode == mode);
 317.315 +      xprintf("iODBC table driver not supported\n");
 317.316 +      return NULL;
 317.317 +}
 317.318 +
 317.319 +int db_iodbc_read(TABDCA *dca, void *link)
 317.320 +{     xassert(dca != dca);
 317.321 +      xassert(link != link);
 317.322 +      return 0;
 317.323 +}
 317.324 +
 317.325 +int db_iodbc_write(TABDCA *dca, void *link)
 317.326 +{     xassert(dca != dca);
 317.327 +      xassert(link != link);
 317.328 +      return 0;
 317.329 +}
 317.330 +
 317.331 +int db_iodbc_close(TABDCA *dca, void *link)
 317.332 +{     xassert(dca != dca);
 317.333 +      xassert(link != link);
 317.334 +      return 0;
 317.335 +}
 317.336 +
 317.337 +#else
 317.338 +
 317.339 +#if defined(__CYGWIN__) || defined(__MINGW32__) || defined(__WOE__)
 317.340 +#include <windows.h>
 317.341 +#endif
 317.342 +
 317.343 +#include <sql.h>
 317.344 +#include <sqlext.h>
 317.345 +
 317.346 +struct db_odbc
 317.347 +{
 317.348 +   int              mode;         /*'R' = Read, 'W' = Write*/
 317.349 +   SQLHDBC          hdbc;         /*connection handle*/
 317.350 +   SQLHENV          henv;         /*environment handle*/
 317.351 +   SQLHSTMT         hstmt;        /*statement handle*/
 317.352 +   SQLSMALLINT      nresultcols;  /* columns in result*/
 317.353 +   SQLULEN          collen[SQL_FIELD_MAX+1];
 317.354 +   SQLLEN           outlen[SQL_FIELD_MAX+1];
 317.355 +   SQLSMALLINT      coltype[SQL_FIELD_MAX+1];
 317.356 +   SQLCHAR          data[SQL_FIELD_MAX+1][SQL_FDLEN_MAX+1];
 317.357 +   SQLCHAR          colname[SQL_FIELD_MAX+1][SQL_FDLEN_MAX+1];
 317.358 +   int              isnumeric[SQL_FIELD_MAX+1];
 317.359 +   int              nf;
 317.360 +   /* number of fields in the csv file */
 317.361 +   int              ref[1+SQL_FIELD_MAX];
 317.362 +   /* ref[k] = k', if k-th field of the csv file corresponds to
 317.363 +      k'-th field in the table statement; if ref[k] = 0, k-th field
 317.364 +      of the csv file is ignored */
 317.365 +   SQLCHAR         *query;
 317.366 +   /* query generated by db_iodbc_open */
 317.367 +};
 317.368 +
 317.369 +SQLRETURN SQL_API dl_SQLAllocHandle (
 317.370 +   SQLSMALLINT           HandleType,
 317.371 +   SQLHANDLE             InputHandle,
 317.372 +   SQLHANDLE            *OutputHandle)
 317.373 +{
 317.374 +      typedef SQLRETURN SQL_API ep_SQLAllocHandle(
 317.375 +         SQLSMALLINT           HandleType,
 317.376 +         SQLHANDLE             InputHandle,
 317.377 +         SQLHANDLE            *OutputHandle);
 317.378 +
 317.379 +      ep_SQLAllocHandle *fn;
 317.380 +      fn = (ep_SQLAllocHandle *) xdlsym(h_odbc, "SQLAllocHandle");
 317.381 +      xassert(fn != NULL);
 317.382 +      return (*fn)(HandleType, InputHandle, OutputHandle);
 317.383 +}
 317.384 +
 317.385 +SQLRETURN SQL_API dl_SQLBindCol (
 317.386 +   SQLHSTMT              StatementHandle,
 317.387 +   SQLUSMALLINT          ColumnNumber,
 317.388 +   SQLSMALLINT           TargetType,
 317.389 +   SQLPOINTER            TargetValue,
 317.390 +   SQLLEN                BufferLength,
 317.391 +   SQLLEN               *StrLen_or_Ind)
 317.392 +{
 317.393 +      typedef SQLRETURN SQL_API ep_SQLBindCol(
 317.394 +         SQLHSTMT              StatementHandle,
 317.395 +         SQLUSMALLINT          ColumnNumber,
 317.396 +         SQLSMALLINT           TargetType,
 317.397 +         SQLPOINTER            TargetValue,
 317.398 +         SQLLEN                BufferLength,
 317.399 +         SQLLEN               *StrLen_or_Ind);
 317.400 +      ep_SQLBindCol *fn;
 317.401 +      fn = (ep_SQLBindCol *) xdlsym(h_odbc, "SQLBindCol");
 317.402 +      xassert(fn != NULL);
 317.403 +      return (*fn)(StatementHandle, ColumnNumber, TargetType,
 317.404 +         TargetValue, BufferLength, StrLen_or_Ind);
 317.405 +}
 317.406 +
 317.407 +SQLRETURN SQL_API dl_SQLCloseCursor (
 317.408 +   SQLHSTMT              StatementHandle)
 317.409 +{
 317.410 +      typedef SQLRETURN SQL_API ep_SQLCloseCursor (
 317.411 +         SQLHSTMT              StatementHandle);
 317.412 +
 317.413 +      ep_SQLCloseCursor *fn;
 317.414 +      fn = (ep_SQLCloseCursor *) xdlsym(h_odbc, "SQLCloseCursor");
 317.415 +      xassert(fn != NULL);
 317.416 +      return (*fn)(StatementHandle);
 317.417 +}
 317.418 +
 317.419 +
 317.420 +SQLRETURN SQL_API dl_SQLDisconnect (
 317.421 +   SQLHDBC               ConnectionHandle)
 317.422 +{
 317.423 +      typedef SQLRETURN SQL_API ep_SQLDisconnect(
 317.424 +         SQLHDBC               ConnectionHandle);
 317.425 +
 317.426 +      ep_SQLDisconnect *fn;
 317.427 +      fn = (ep_SQLDisconnect *) xdlsym(h_odbc, "SQLDisconnect");
 317.428 +      xassert(fn != NULL);
 317.429 +      return (*fn)(ConnectionHandle);
 317.430 +}
 317.431 +
 317.432 +SQLRETURN SQL_API dl_SQLDriverConnect (
 317.433 +   SQLHDBC               hdbc,
 317.434 +   SQLHWND               hwnd,
 317.435 +   SQLCHAR              *szConnStrIn,
 317.436 +   SQLSMALLINT           cbConnStrIn,
 317.437 +   SQLCHAR              *szConnStrOut,
 317.438 +   SQLSMALLINT           cbConnStrOutMax,
 317.439 +   SQLSMALLINT          *pcbConnStrOut,
 317.440 +   SQLUSMALLINT          fDriverCompletion)
 317.441 +{
 317.442 +      typedef SQLRETURN SQL_API ep_SQLDriverConnect(
 317.443 +         SQLHDBC               hdbc,
 317.444 +         SQLHWND               hwnd,
 317.445 +         SQLCHAR             * szConnStrIn,
 317.446 +         SQLSMALLINT           cbConnStrIn,
 317.447 +         SQLCHAR             * szConnStrOut,
 317.448 +         SQLSMALLINT           cbConnStrOutMax,
 317.449 +         SQLSMALLINT         * pcbConnStrOut,
 317.450 +         SQLUSMALLINT          fDriverCompletion);
 317.451 +
 317.452 +      ep_SQLDriverConnect *fn;
 317.453 +      fn = (ep_SQLDriverConnect *) xdlsym(h_odbc, "SQLDriverConnect");
 317.454 +      xassert(fn != NULL);
 317.455 +      return (*fn)(hdbc, hwnd, szConnStrIn, cbConnStrIn, szConnStrOut,
 317.456 +         cbConnStrOutMax, pcbConnStrOut, fDriverCompletion);
 317.457 +}
 317.458 +
 317.459 +SQLRETURN SQL_API dl_SQLEndTran (
 317.460 +   SQLSMALLINT           HandleType,
 317.461 +   SQLHANDLE             Handle,
 317.462 +   SQLSMALLINT           CompletionType)
 317.463 +{
 317.464 +      typedef SQLRETURN SQL_API ep_SQLEndTran (
 317.465 +         SQLSMALLINT           HandleType,
 317.466 +         SQLHANDLE             Handle,
 317.467 +         SQLSMALLINT           CompletionType);
 317.468 +
 317.469 +      ep_SQLEndTran *fn;
 317.470 +      fn = (ep_SQLEndTran *) xdlsym(h_odbc, "SQLEndTran");
 317.471 +      xassert(fn != NULL);
 317.472 +      return (*fn)(HandleType, Handle, CompletionType);
 317.473 +}
 317.474 +
 317.475 +SQLRETURN SQL_API dl_SQLExecDirect (
 317.476 +   SQLHSTMT              StatementHandle,
 317.477 +   SQLCHAR             * StatementText,
 317.478 +   SQLINTEGER            TextLength)
 317.479 +{
 317.480 +      typedef SQLRETURN SQL_API ep_SQLExecDirect (
 317.481 +         SQLHSTMT              StatementHandle,
 317.482 +         SQLCHAR             * StatementText,
 317.483 +         SQLINTEGER            TextLength);
 317.484 +
 317.485 +      ep_SQLExecDirect *fn;
 317.486 +      fn = (ep_SQLExecDirect *) xdlsym(h_odbc, "SQLExecDirect");
 317.487 +      xassert(fn != NULL);
 317.488 +      return (*fn)(StatementHandle, StatementText, TextLength);
 317.489 +}
 317.490 +
 317.491 +SQLRETURN SQL_API dl_SQLFetch (
 317.492 +   SQLHSTMT              StatementHandle)
 317.493 +{
 317.494 +      typedef SQLRETURN SQL_API ep_SQLFetch (
 317.495 +         SQLHSTMT              StatementHandle);
 317.496 +
 317.497 +      ep_SQLFetch *fn;
 317.498 +      fn = (ep_SQLFetch*) xdlsym(h_odbc, "SQLFetch");
 317.499 +      xassert(fn != NULL);
 317.500 +      return (*fn)(StatementHandle);
 317.501 +}
 317.502 +
 317.503 +SQLRETURN SQL_API dl_SQLFreeHandle (
 317.504 +   SQLSMALLINT           HandleType,
 317.505 +   SQLHANDLE             Handle)
 317.506 +{
 317.507 +      typedef SQLRETURN SQL_API ep_SQLFreeHandle (
 317.508 +         SQLSMALLINT           HandleType,
 317.509 +         SQLHANDLE             Handle);
 317.510 +
 317.511 +      ep_SQLFreeHandle *fn;
 317.512 +      fn = (ep_SQLFreeHandle *) xdlsym(h_odbc, "SQLFreeHandle");
 317.513 +      xassert(fn != NULL);
 317.514 +      return (*fn)(HandleType, Handle);
 317.515 +}
 317.516 +
 317.517 +SQLRETURN SQL_API dl_SQLDescribeCol (
 317.518 +   SQLHSTMT              StatementHandle,
 317.519 +   SQLUSMALLINT          ColumnNumber,
 317.520 +   SQLCHAR             * ColumnName,
 317.521 +   SQLSMALLINT           BufferLength,
 317.522 +   SQLSMALLINT         * NameLength,
 317.523 +   SQLSMALLINT         * DataType,
 317.524 +   SQLULEN             * ColumnSize,
 317.525 +   SQLSMALLINT         * DecimalDigits,
 317.526 +   SQLSMALLINT         * Nullable)
 317.527 +{
 317.528 +      typedef SQLRETURN SQL_API ep_SQLDescribeCol (
 317.529 +         SQLHSTMT              StatementHandle,
 317.530 +         SQLUSMALLINT          ColumnNumber,
 317.531 +         SQLCHAR              *ColumnName,
 317.532 +         SQLSMALLINT           BufferLength,
 317.533 +         SQLSMALLINT          *NameLength,
 317.534 +         SQLSMALLINT          *DataType,
 317.535 +         SQLULEN              *ColumnSize,
 317.536 +         SQLSMALLINT          *DecimalDigits,
 317.537 +         SQLSMALLINT          *Nullable);
 317.538 +
 317.539 +      ep_SQLDescribeCol *fn;
 317.540 +      fn = (ep_SQLDescribeCol *) xdlsym(h_odbc, "SQLDescribeCol");
 317.541 +      xassert(fn != NULL);
 317.542 +      return (*fn)(StatementHandle, ColumnNumber, ColumnName,
 317.543 +         BufferLength, NameLength,
 317.544 +         DataType, ColumnSize, DecimalDigits, Nullable);
 317.545 +}
 317.546 +
 317.547 +SQLRETURN SQL_API dl_SQLGetDiagRec (
 317.548 +   SQLSMALLINT           HandleType,
 317.549 +   SQLHANDLE             Handle,
 317.550 +   SQLSMALLINT           RecNumber,
 317.551 +   SQLCHAR              *Sqlstate,
 317.552 +   SQLINTEGER           *NativeError,
 317.553 +   SQLCHAR              *MessageText,
 317.554 +   SQLSMALLINT           BufferLength,
 317.555 +   SQLSMALLINT          *TextLength)
 317.556 +{
 317.557 +      typedef SQLRETURN SQL_API ep_SQLGetDiagRec (
 317.558 +         SQLSMALLINT           HandleType,
 317.559 +         SQLHANDLE             Handle,
 317.560 +         SQLSMALLINT           RecNumber,
 317.561 +         SQLCHAR              *Sqlstate,
 317.562 +         SQLINTEGER           *NativeError,
 317.563 +         SQLCHAR              *MessageText,
 317.564 +         SQLSMALLINT           BufferLength,
 317.565 +         SQLSMALLINT          *TextLength);
 317.566 +
 317.567 +      ep_SQLGetDiagRec *fn;
 317.568 +      fn = (ep_SQLGetDiagRec *) xdlsym(h_odbc, "SQLGetDiagRec");
 317.569 +      xassert(fn != NULL);
 317.570 +      return (*fn)(HandleType, Handle, RecNumber, Sqlstate,
 317.571 +         NativeError, MessageText, BufferLength, TextLength);
 317.572 +}
 317.573 +
 317.574 +SQLRETURN SQL_API dl_SQLGetInfo (
 317.575 +   SQLHDBC               ConnectionHandle,
 317.576 +   SQLUSMALLINT          InfoType,
 317.577 +   SQLPOINTER            InfoValue,
 317.578 +   SQLSMALLINT           BufferLength,
 317.579 +   SQLSMALLINT          *StringLength)
 317.580 +{
 317.581 +      typedef SQLRETURN SQL_API ep_SQLGetInfo (
 317.582 +         SQLHDBC               ConnectionHandle,
 317.583 +         SQLUSMALLINT          InfoType,
 317.584 +         SQLPOINTER            InfoValue,
 317.585 +         SQLSMALLINT           BufferLength,
 317.586 +         SQLSMALLINT          *StringLength);
 317.587 +
 317.588 +      ep_SQLGetInfo *fn;
 317.589 +      fn = (ep_SQLGetInfo *) xdlsym(h_odbc, "SQLGetInfo");
 317.590 +      xassert(fn != NULL);
 317.591 +      return (*fn)(ConnectionHandle, InfoType, InfoValue, BufferLength,
 317.592 +         StringLength);
 317.593 +}
 317.594 +
 317.595 +SQLRETURN SQL_API dl_SQLNumResultCols (
 317.596 +   SQLHSTMT              StatementHandle,
 317.597 +   SQLSMALLINT          *ColumnCount)
 317.598 +{
 317.599 +      typedef SQLRETURN SQL_API ep_SQLNumResultCols (
 317.600 +         SQLHSTMT              StatementHandle,
 317.601 +         SQLSMALLINT          *ColumnCount);
 317.602 +
 317.603 +      ep_SQLNumResultCols *fn;
 317.604 +      fn = (ep_SQLNumResultCols *) xdlsym(h_odbc, "SQLNumResultCols");
 317.605 +      xassert(fn != NULL);
 317.606 +      return (*fn)(StatementHandle, ColumnCount);
 317.607 +}
 317.608 +
 317.609 +SQLRETURN SQL_API dl_SQLSetConnectAttr (
 317.610 +   SQLHDBC               ConnectionHandle,
 317.611 +   SQLINTEGER            Attribute,
 317.612 +   SQLPOINTER            Value,
 317.613 +   SQLINTEGER            StringLength)
 317.614 +{
 317.615 +      typedef SQLRETURN SQL_API ep_SQLSetConnectAttr (
 317.616 +         SQLHDBC               ConnectionHandle,
 317.617 +         SQLINTEGER            Attribute,
 317.618 +         SQLPOINTER            Value,
 317.619 +         SQLINTEGER            StringLength);
 317.620 +
 317.621 +      ep_SQLSetConnectAttr *fn;
 317.622 +     fn = (ep_SQLSetConnectAttr *) xdlsym(h_odbc, "SQLSetConnectAttr");
 317.623 +      xassert(fn != NULL);
 317.624 +      return (*fn)(ConnectionHandle, Attribute, Value, StringLength);
 317.625 +}
 317.626 +
 317.627 +SQLRETURN SQL_API dl_SQLSetEnvAttr (
 317.628 +   SQLHENV               EnvironmentHandle,
 317.629 +   SQLINTEGER            Attribute,
 317.630 +   SQLPOINTER            Value,
 317.631 +   SQLINTEGER            StringLength)
 317.632 +{
 317.633 +      typedef SQLRETURN SQL_API ep_SQLSetEnvAttr (
 317.634 +         SQLHENV               EnvironmentHandle,
 317.635 +         SQLINTEGER            Attribute,
 317.636 +         SQLPOINTER            Value,
 317.637 +         SQLINTEGER            StringLength);
 317.638 +
 317.639 +      ep_SQLSetEnvAttr *fn;
 317.640 +      fn = (ep_SQLSetEnvAttr *) xdlsym(h_odbc, "SQLSetEnvAttr");
 317.641 +      xassert(fn != NULL);
 317.642 +      return (*fn)(EnvironmentHandle, Attribute, Value, StringLength);
 317.643 +}
 317.644 +
 317.645 +static void extract_error(
 317.646 +   char *fn,
 317.647 +   SQLHANDLE handle,
 317.648 +   SQLSMALLINT type);
 317.649 +
 317.650 +static int is_numeric(
 317.651 +    SQLSMALLINT coltype);
 317.652 +
 317.653 +/***********************************************************************
 317.654 +*  NAME
 317.655 +*
 317.656 +*  db_iodbc_open - open connection to ODBC data base
 317.657 +*
 317.658 +*  SYNOPSIS
 317.659 +*
 317.660 +*  #include "glpsql.h"
 317.661 +*  void *db_iodbc_open(TABDCA *dca, int mode);
 317.662 +*
 317.663 +*  DESCRIPTION
 317.664 +*
 317.665 +*  The routine db_iodbc_open opens a connection to an ODBC data base.
 317.666 +*  It then executes the sql statements passed.
 317.667 +*
 317.668 +*  In the case of table read the SELECT statement is executed.
 317.669 +*
 317.670 +*  In the case of table write the INSERT statement is prepared.
 317.671 +*  RETURNS
 317.672 +*
 317.673 +*  The routine returns a pointer to data storage area created. */
 317.674 +void *db_iodbc_open(TABDCA *dca, int mode)
 317.675 +{  void  *ret;
 317.676 +   char **sqllines;
 317.677 +
 317.678 +   sqllines = args_concat(dca);
 317.679 +   if (sqllines == NULL)
 317.680 +   {  xprintf("Missing arguments in table statement.\n"
 317.681 +              "Please, supply table driver, dsn, and query.\n");
 317.682 +      return NULL;
 317.683 +   }
 317.684 +   ret = db_iodbc_open_int(dca, mode, (const char **) sqllines);
 317.685 +   free_buffer(sqllines);
 317.686 +   return ret;
 317.687 +}
 317.688 +
 317.689 +static void *db_iodbc_open_int(TABDCA *dca, int mode, const char
 317.690 +   **sqllines)
 317.691 +{
 317.692 +   struct db_odbc    *sql;
 317.693 +   SQLRETURN          ret;
 317.694 +   SQLCHAR FAR       *dsn;
 317.695 +   SQLCHAR            info[256];
 317.696 +   SQLSMALLINT        colnamelen;
 317.697 +   SQLSMALLINT        nullable;
 317.698 +   SQLSMALLINT        scale;
 317.699 +   const char        *arg;
 317.700 +   int                narg;
 317.701 +   int                i, j;
 317.702 +   int                total;
 317.703 +
 317.704 +   if (libodbc == NULL)
 317.705 +   {
 317.706 +      xprintf("No loader for shared ODBC library available\n");
 317.707 +      return NULL;
 317.708 +   }
 317.709 +
 317.710 +   if (h_odbc == NULL)
 317.711 +   {
 317.712 +      h_odbc = xdlopen(libodbc);
 317.713 +      if (h_odbc == NULL)
 317.714 +      {  xprintf("unable to open library %s\n", libodbc);
 317.715 +         xprintf("%s\n", xerrmsg());
 317.716 +         return NULL;
 317.717 +      }
 317.718 +   }
 317.719 +
 317.720 +   sql = (struct db_odbc *) xmalloc(sizeof(struct db_odbc));
 317.721 +   if (sql == NULL)
 317.722 +         return NULL;
 317.723 +
 317.724 +   sql->mode  = mode;
 317.725 +   sql->hdbc  = NULL;
 317.726 +   sql->henv  = NULL;
 317.727 +   sql->hstmt = NULL;
 317.728 +   sql->query = NULL;
 317.729 +   narg = mpl_tab_num_args(dca);
 317.730 +
 317.731 +   dsn = (SQLCHAR FAR *) mpl_tab_get_arg(dca, 2);
 317.732 +   /* allocate an environment handle */
 317.733 +   ret = dl_SQLAllocHandle(SQL_HANDLE_ENV, SQL_NULL_HANDLE,
 317.734 +      &(sql->henv));
 317.735 +   /* set attribute to enable application to run as ODBC 3.0
 317.736 +      application */
 317.737 +   ret = dl_SQLSetEnvAttr(sql->henv, SQL_ATTR_ODBC_VERSION,
 317.738 +      (void *) SQL_OV_ODBC3, 0);
 317.739 +   /* allocate a connection handle */
 317.740 +   ret = dl_SQLAllocHandle(SQL_HANDLE_DBC, sql->henv, &(sql->hdbc));
 317.741 +   /* connect */
 317.742 +   ret = dl_SQLDriverConnect(sql->hdbc, NULL, dsn, SQL_NTS, NULL, 0,
 317.743 +      NULL, SQL_DRIVER_COMPLETE);
 317.744 +   if (SQL_SUCCEEDED(ret))
 317.745 +   {  /* output information about data base connection */
 317.746 +      xprintf("Connected to ");
 317.747 +      dl_SQLGetInfo(sql->hdbc, SQL_DBMS_NAME, (SQLPOINTER)info,
 317.748 +         sizeof(info), NULL);
 317.749 +      xprintf("%s ", info);
 317.750 +      dl_SQLGetInfo(sql->hdbc, SQL_DBMS_VER, (SQLPOINTER)info,
 317.751 +         sizeof(info), NULL);
 317.752 +      xprintf("%s - ", info);
 317.753 +      dl_SQLGetInfo(sql->hdbc, SQL_DATABASE_NAME, (SQLPOINTER)info,
 317.754 +         sizeof(info), NULL);
 317.755 +      xprintf("%s\n", info);
 317.756 +   }
 317.757 +   else
 317.758 +   {  /* describe error */
 317.759 +      xprintf("Failed to connect\n");
 317.760 +      extract_error("SQLDriverConnect", sql->hdbc, SQL_HANDLE_DBC);
 317.761 +      dl_SQLFreeHandle(SQL_HANDLE_DBC, sql->hdbc);
 317.762 +      dl_SQLFreeHandle(SQL_HANDLE_ENV, sql->henv);
 317.763 +      xfree(sql);
 317.764 +      return NULL;
 317.765 +   }
 317.766 +   /* set AUTOCOMMIT on*/
 317.767 +   ret = dl_SQLSetConnectAttr(sql->hdbc, SQL_ATTR_AUTOCOMMIT,
 317.768 +      (SQLPOINTER)SQL_AUTOCOMMIT_ON, 0);
 317.769 +   /* allocate a statement handle */
 317.770 +   ret = dl_SQLAllocHandle(SQL_HANDLE_STMT, sql->hdbc, &(sql->hstmt));
 317.771 +
 317.772 +   /* initialization queries */
 317.773 +   for(j = 0; sqllines[j+1] != NULL; j++)
 317.774 +   {
 317.775 +      sql->query = (SQLCHAR *) sqllines[j];
 317.776 +      xprintf("%s\n", sql->query);
 317.777 +      ret = dl_SQLExecDirect(sql->hstmt, sql->query, SQL_NTS);
 317.778 +      switch (ret)
 317.779 +      {
 317.780 +         case SQL_SUCCESS:
 317.781 +         case SQL_SUCCESS_WITH_INFO:
 317.782 +         case SQL_NO_DATA_FOUND:
 317.783 +            break;
 317.784 +         default:
 317.785 +            xprintf("db_iodbc_open: Query\n\"%s\"\nfailed.\n",
 317.786 +               sql->query);
 317.787 +            extract_error("SQLExecDirect", sql->hstmt, SQL_HANDLE_STMT);
 317.788 +            dl_SQLFreeHandle(SQL_HANDLE_STMT, sql->hstmt);
 317.789 +            dl_SQLDisconnect(sql->hdbc);
 317.790 +            dl_SQLFreeHandle(SQL_HANDLE_DBC, sql->hdbc);
 317.791 +            dl_SQLFreeHandle(SQL_HANDLE_ENV, sql->henv);
 317.792 +            xfree(sql);
 317.793 +            return NULL;
 317.794 +      }
 317.795 +      /* commit statement */
 317.796 +      dl_SQLEndTran(SQL_HANDLE_ENV, sql->henv, SQL_COMMIT);
 317.797 +   }
 317.798 +
 317.799 +   if ( sql->mode == 'R' )
 317.800 +   {  sql->nf = mpl_tab_num_flds(dca);
 317.801 +      for(j = 0; sqllines[j] != NULL; j++)
 317.802 +         arg = sqllines[j];
 317.803 +      total = strlen(arg);
 317.804 +      if (total > 7 && 0 == strncmp(arg, "SELECT ", 7))
 317.805 +      {
 317.806 +         total = strlen(arg);
 317.807 +         sql->query = xmalloc( (total+1) * sizeof(char));
 317.808 +         strcpy (sql->query, arg);
 317.809 +      }
 317.810 +      else
 317.811 +      {
 317.812 +         sql->query = db_generate_select_stmt(dca);
 317.813 +      }
 317.814 +      xprintf("%s\n", sql->query);
 317.815 +      if (dl_SQLExecDirect(sql->hstmt, sql->query, SQL_NTS) !=
 317.816 +         SQL_SUCCESS)
 317.817 +      {
 317.818 +         xprintf("db_iodbc_open: Query\n\"%s\"\nfailed.\n", sql->query);
 317.819 +         extract_error("SQLExecDirect", sql->hstmt, SQL_HANDLE_STMT);
 317.820 +         dl_SQLFreeHandle(SQL_HANDLE_STMT, sql->hstmt);
 317.821 +         dl_SQLDisconnect(sql->hdbc);
 317.822 +         dl_SQLFreeHandle(SQL_HANDLE_DBC, sql->hdbc);
 317.823 +         dl_SQLFreeHandle(SQL_HANDLE_ENV, sql->henv);
 317.824 +         xfree(sql->query);
 317.825 +            xfree(sql);
 317.826 +         return NULL;
 317.827 +      }
 317.828 +      xfree(sql->query);
 317.829 +      /* determine number of result columns */
 317.830 +      ret = dl_SQLNumResultCols(sql->hstmt, &sql->nresultcols);
 317.831 +      total = sql->nresultcols;
 317.832 +      if (total > SQL_FIELD_MAX)
 317.833 +      {  xprintf("db_iodbc_open: Too many fields (> %d) in query.\n"
 317.834 +            "\"%s\"\n", SQL_FIELD_MAX, sql->query);
 317.835 +         dl_SQLFreeHandle(SQL_HANDLE_STMT, sql->hstmt);
 317.836 +         dl_SQLDisconnect(sql->hdbc);
 317.837 +         dl_SQLFreeHandle(SQL_HANDLE_DBC, sql->hdbc);
 317.838 +         dl_SQLFreeHandle(SQL_HANDLE_ENV, sql->henv);
 317.839 +         xfree(sql->query);
 317.840 +         return NULL;
 317.841 +      }
 317.842 +      for (i = 1; i <= total; i++)
 317.843 +      {  /* return a set of attributes for a column */
 317.844 +         ret = dl_SQLDescribeCol(sql->hstmt, (SQLSMALLINT) i,
 317.845 +            sql->colname[i], SQL_FDLEN_MAX,
 317.846 +            &colnamelen, &(sql->coltype[i]), &(sql->collen[i]), &scale,
 317.847 +            &nullable);
 317.848 +         sql->isnumeric[i] = is_numeric(sql->coltype[i]);
 317.849 +         /* bind columns to program vars, converting all types to CHAR*/
 317.850 +         if (sql->isnumeric[i])
 317.851 +         {  dl_SQLBindCol(sql->hstmt, i, SQL_DOUBLE, sql->data[i],
 317.852 +               SQL_FDLEN_MAX, &(sql->outlen[i]));
 317.853 +         } else
 317.854 +         {  dl_SQLBindCol(sql->hstmt, i, SQL_CHAR, sql->data[i],
 317.855 +               SQL_FDLEN_MAX, &(sql->outlen[i]));
 317.856 +         }
 317.857 +         for (j = sql->nf; j >= 1; j--)
 317.858 +         {  if (strcmp(mpl_tab_get_name(dca, j), sql->colname[i]) == 0)
 317.859 +            break;
 317.860 +         }
 317.861 +         sql->ref[i] = j;
 317.862 +      }
 317.863 +   }
 317.864 +   else if ( sql->mode == 'W' )
 317.865 +   {  for(j = 0; sqllines[j] != NULL; j++)
 317.866 +         arg = sqllines[j];
 317.867 +      if (  NULL != strchr(arg, '?') )
 317.868 +      {
 317.869 +         total = strlen(arg);
 317.870 +         sql->query = xmalloc( (total+1) * sizeof(char));
 317.871 +         strcpy (sql->query, arg);
 317.872 +         }
 317.873 +      else
 317.874 +      {
 317.875 +         sql->query = db_generate_insert_stmt(dca);
 317.876 +      }
 317.877 +      xprintf("%s\n", sql->query);
 317.878 +   }
 317.879 +   return sql;
 317.880 +}
 317.881 +
 317.882 +int db_iodbc_read(TABDCA *dca, void *link)
 317.883 +{
 317.884 +   struct db_odbc  *sql;
 317.885 +   SQLRETURN        ret;
 317.886 +   char             buf[SQL_FDLEN_MAX+1];
 317.887 +   int              i;
 317.888 +   int              len;
 317.889 +   double           num;
 317.890 +
 317.891 +   sql = (struct db_odbc *) link;
 317.892 +
 317.893 +   xassert(sql != NULL);
 317.894 +   xassert(sql->mode == 'R');
 317.895 +
 317.896 +   ret=dl_SQLFetch(sql->hstmt);
 317.897 +   if (ret== SQL_ERROR)
 317.898 +      return -1;
 317.899 +   if (ret== SQL_NO_DATA_FOUND)
 317.900 +      return -1; /*EOF*/
 317.901 +   for (i=1; i <= sql->nresultcols; i++)
 317.902 +   {
 317.903 +      if (sql->ref[i] > 0)
 317.904 +      {
 317.905 +         len = sql->outlen[i];
 317.906 +         if (len != SQL_NULL_DATA)
 317.907 +         {
 317.908 +            if (sql->isnumeric[i])
 317.909 +            {  mpl_tab_set_num(dca, sql->ref[i],
 317.910 +                               *((const double *) sql->data[i]));
 317.911 +            }
 317.912 +            else
 317.913 +            {  if (len > SQL_FDLEN_MAX)
 317.914 +                  len = SQL_FDLEN_MAX;
 317.915 +               else if (len < 0)
 317.916 +                  len = 0;
 317.917 +               strncpy(buf, (const char *) sql->data[i], len);
 317.918 +               buf[len] = 0x00;
 317.919 +               mpl_tab_set_str(dca, sql->ref[i], strtrim(buf));
 317.920 +            }
 317.921 +         }
 317.922 +      }
 317.923 +   }
 317.924 +   return 0;
 317.925 +}
 317.926 +
 317.927 +int db_iodbc_write(TABDCA *dca, void *link)
 317.928 +{
 317.929 +   struct db_odbc  *sql;
 317.930 +   char            *part;
 317.931 +   char            *query;
 317.932 +   char            *template;
 317.933 +   char             num[50];
 317.934 +   int              k;
 317.935 +   int              len;
 317.936 +   int              nf;
 317.937 +
 317.938 +   sql = (struct db_odbc *) link;
 317.939 +   xassert(sql != NULL);
 317.940 +   xassert(sql->mode == 'W');
 317.941 +
 317.942 +   len      = strlen(sql->query);
 317.943 +   template = (char *) xmalloc( (len + 1) * sizeof(char) );
 317.944 +   strcpy(template, sql->query);
 317.945 +
 317.946 +   nf = mpl_tab_num_flds(dca);
 317.947 +   for (k = 1; k <= nf; k++)
 317.948 +   {     switch (mpl_tab_get_type(dca, k))
 317.949 +      {  case 'N':
 317.950 +            len += 20;
 317.951 +            break;
 317.952 +         case 'S':
 317.953 +            len += db_escaped_string_length(mpl_tab_get_str(dca, k));
 317.954 +            len += 2;
 317.955 +            break;
 317.956 +              default:
 317.957 +                        xassert(dca != dca);
 317.958 +         }
 317.959 +   }
 317.960 +   query = xmalloc( (len + 1 ) * sizeof(char) );
 317.961 +   query[0] = 0x00;
 317.962 +   for (k = 1, part = strtok (template, "?"); (part != NULL);
 317.963 +      part = strtok (NULL, "?"), k++)
 317.964 +   {
 317.965 +      if (k > nf) break;
 317.966 +      strcat( query, part );
 317.967 +      switch (mpl_tab_get_type(dca, k))
 317.968 +      {  case 'N':
 317.969 +#if 0 /* 02/XI-2010 by xypron */
 317.970 +            sprintf(num, "%-18g",mpl_tab_get_num(dca, k));
 317.971 +#else
 317.972 +            sprintf(num, "%.*g", DBL_DIG, mpl_tab_get_num(dca, k));
 317.973 +#endif
 317.974 +            strcat( query, num );
 317.975 +            break;
 317.976 +         case 'S':
 317.977 +            strcat( query, "'");
 317.978 +            db_escape_string( query + strlen(query),
 317.979 +               mpl_tab_get_str(dca, k) );
 317.980 +            strcat( query, "'");
 317.981 +            break;
 317.982 +              default:
 317.983 +                        xassert(dca != dca);
 317.984 +         }
 317.985 +   }
 317.986 +   if (part != NULL)
 317.987 +      strcat(query, part);
 317.988 +   if (dl_SQLExecDirect(sql->hstmt, (SQLCHAR *) query, SQL_NTS)
 317.989 +      != SQL_SUCCESS)
 317.990 +   {
 317.991 +      xprintf("db_iodbc_write: Query\n\"%s\"\nfailed.\n", query);
 317.992 +      extract_error("SQLExecDirect", sql->hdbc, SQL_HANDLE_DBC);
 317.993 +      xfree(query);
 317.994 +      xfree(template);
 317.995 +      return 1;
 317.996 +      }
 317.997 +
 317.998 +   xfree(query);
 317.999 +   xfree(template);
317.1000 +   return 0;
317.1001 +}
317.1002 +
317.1003 +int db_iodbc_close(TABDCA *dca, void *link)
317.1004 +{
317.1005 +   struct db_odbc *sql;
317.1006 +
317.1007 +   sql = (struct db_odbc *) link;
317.1008 +   xassert(sql != NULL);
317.1009 +   /* Commit */
317.1010 +   if ( sql->mode == 'W' )
317.1011 +      dl_SQLEndTran(SQL_HANDLE_ENV, sql->henv, SQL_COMMIT);
317.1012 +   if ( sql->mode == 'R' )
317.1013 +      dl_SQLCloseCursor(sql->hstmt);
317.1014 +
317.1015 +   dl_SQLFreeHandle(SQL_HANDLE_STMT, sql->hstmt);
317.1016 +   dl_SQLDisconnect(sql->hdbc);
317.1017 +   dl_SQLFreeHandle(SQL_HANDLE_DBC, sql->hdbc);
317.1018 +   dl_SQLFreeHandle(SQL_HANDLE_ENV, sql->henv);
317.1019 +   if ( sql->mode == 'W' )
317.1020 +      xfree(sql->query);
317.1021 +   xfree(sql);
317.1022 +   dca->link = NULL;
317.1023 +   return 0;
317.1024 +}
317.1025 +
317.1026 +static void extract_error(
317.1027 +   char *fn,
317.1028 +   SQLHANDLE handle,
317.1029 +   SQLSMALLINT type)
317.1030 +{
317.1031 +   SQLINTEGER   i = 0;
317.1032 +   SQLINTEGER   native;
317.1033 +   SQLCHAR   state[ 7 ];
317.1034 +   SQLCHAR   text[256];
317.1035 +   SQLSMALLINT  len;
317.1036 +   SQLRETURN    ret;
317.1037 +
317.1038 +   xprintf("\nThe driver reported the following diagnostics whilst "
317.1039 +      "running %s\n", fn);
317.1040 +
317.1041 +   do
317.1042 +   {
317.1043 +      ret = dl_SQLGetDiagRec(type, handle, ++i, state, &native, text,
317.1044 +         sizeof(text), &len );
317.1045 +      if (SQL_SUCCEEDED(ret))
317.1046 +         xprintf("%s:%ld:%ld:%s\n", state, i, native, text);
317.1047 +   }
317.1048 +   while( ret == SQL_SUCCESS );
317.1049 +}
317.1050 +
317.1051 +static int is_numeric(SQLSMALLINT coltype)
317.1052 +{
317.1053 +   int ret = 0;
317.1054 +   switch (coltype)
317.1055 +   {
317.1056 +      case SQL_DECIMAL:
317.1057 +      case SQL_NUMERIC:
317.1058 +      case SQL_SMALLINT:
317.1059 +      case SQL_INTEGER:
317.1060 +      case SQL_REAL:
317.1061 +      case SQL_FLOAT:
317.1062 +      case SQL_DOUBLE:
317.1063 +      case SQL_TINYINT:
317.1064 +      case SQL_BIGINT:
317.1065 +         ret = 1;
317.1066 +         break;
317.1067 +   }
317.1068 +   return ret;
317.1069 +}
317.1070 +
317.1071 +#endif
317.1072 +
317.1073 +/**********************************************************************/
317.1074 +
317.1075 +#ifndef HAVE_MYSQL
317.1076 +
317.1077 +void *db_mysql_open(TABDCA *dca, int mode)
317.1078 +{     xassert(dca == dca);
317.1079 +      xassert(mode == mode);
317.1080 +      xprintf("MySQL table driver not supported\n");
317.1081 +      return NULL;
317.1082 +}
317.1083 +
317.1084 +int db_mysql_read(TABDCA *dca, void *link)
317.1085 +{     xassert(dca != dca);
317.1086 +      xassert(link != link);
317.1087 +      return 0;
317.1088 +}
317.1089 +
317.1090 +int db_mysql_write(TABDCA *dca, void *link)
317.1091 +{     xassert(dca != dca);
317.1092 +      xassert(link != link);
317.1093 +      return 0;
317.1094 +}
317.1095 +
317.1096 +int db_mysql_close(TABDCA *dca, void *link)
317.1097 +{     xassert(dca != dca);
317.1098 +      xassert(link != link);
317.1099 +      return 0;
317.1100 +}
317.1101 +
317.1102 +#else
317.1103 +
317.1104 +#if defined(__CYGWIN__) || defined(__MINGW32__) || defined(__WOE__)
317.1105 +#include <windows.h>
317.1106 +#endif
317.1107 +
317.1108 +#ifdef __CYGWIN__
317.1109 +#define byte_defined 1
317.1110 +#endif
317.1111 +
317.1112 +#include <my_global.h>
317.1113 +#include <my_sys.h>
317.1114 +#include <mysql.h>
317.1115 +
317.1116 +struct db_mysql
317.1117 +{
317.1118 +   int              mode;  /*'R' = Read, 'W' = Write*/
317.1119 +   MYSQL           *con;   /*connection*/
317.1120 +   MYSQL_RES       *res;    /*result*/
317.1121 +   int              nf;
317.1122 +   /* number of fields in the csv file */
317.1123 +   int              ref[1+SQL_FIELD_MAX];
317.1124 +   /* ref[k] = k', if k-th field of the csv file corresponds to
317.1125 +      k'-th field in the table statement; if ref[k] = 0, k-th field
317.1126 +      of the csv file is ignored */
317.1127 +   char            *query;
317.1128 +   /* query generated by db_mysql_open */
317.1129 +};
317.1130 +
317.1131 +void STDCALL dl_mysql_close(MYSQL *sock)
317.1132 +{
317.1133 +      typedef void STDCALL ep_mysql_close(MYSQL *sock);
317.1134 +
317.1135 +      ep_mysql_close *fn;
317.1136 +      fn = (ep_mysql_close *) xdlsym(h_mysql, "mysql_close");
317.1137 +      xassert(fn != NULL);
317.1138 +      return (*fn)(sock);
317.1139 +}
317.1140 +
317.1141 +const char * STDCALL dl_mysql_error(MYSQL *mysql)
317.1142 +{
317.1143 +      typedef const char * STDCALL ep_mysql_error(MYSQL *mysql);
317.1144 +
317.1145 +      ep_mysql_error *fn;
317.1146 +      fn = (ep_mysql_error *) xdlsym(h_mysql, "mysql_error");
317.1147 +      xassert(fn != NULL);
317.1148 +      return (*fn)(mysql);
317.1149 +}
317.1150 +
317.1151 +MYSQL_FIELD * STDCALL dl_mysql_fetch_fields(MYSQL_RES *res)
317.1152 +{
317.1153 +      typedef MYSQL_FIELD * STDCALL
317.1154 +         ep_mysql_fetch_fields(MYSQL_RES *res);
317.1155 +
317.1156 +      ep_mysql_fetch_fields *fn;
317.1157 +   fn = (ep_mysql_fetch_fields *) xdlsym(h_mysql, "mysql_fetch_fields");
317.1158 +      xassert(fn != NULL);
317.1159 +      return (*fn)(res);
317.1160 +}
317.1161 +
317.1162 +unsigned long * STDCALL dl_mysql_fetch_lengths(MYSQL_RES *result)
317.1163 +{
317.1164 +      typedef unsigned long * STDCALL
317.1165 +         ep_mysql_fetch_lengths(MYSQL_RES *result);
317.1166 +
317.1167 +      ep_mysql_fetch_lengths *fn;
317.1168 +      fn = (ep_mysql_fetch_lengths *) xdlsym(h_mysql,
317.1169 +         "mysql_fetch_lengths");
317.1170 +      xassert(fn != NULL);
317.1171 +      return (*fn)(result);
317.1172 +}
317.1173 +
317.1174 +MYSQL_ROW STDCALL dl_mysql_fetch_row(MYSQL_RES *result)
317.1175 +{
317.1176 +      typedef MYSQL_ROW STDCALL ep_mysql_fetch_row(MYSQL_RES *result);
317.1177 +
317.1178 +      ep_mysql_fetch_row *fn;
317.1179 +      fn = (ep_mysql_fetch_row *) xdlsym(h_mysql, "mysql_fetch_row");
317.1180 +      xassert(fn != NULL);
317.1181 +      return (*fn)(result);
317.1182 +}
317.1183 +
317.1184 +unsigned int STDCALL dl_mysql_field_count(MYSQL *mysql)
317.1185 +{
317.1186 +      typedef unsigned int STDCALL ep_mysql_field_count(MYSQL *mysql);
317.1187 +
317.1188 +      ep_mysql_field_count *fn;
317.1189 +     fn = (ep_mysql_field_count *) xdlsym(h_mysql, "mysql_field_count");
317.1190 +      xassert(fn != NULL);
317.1191 +      return (*fn)(mysql);
317.1192 +}
317.1193 +
317.1194 +MYSQL * STDCALL dl_mysql_init(MYSQL *mysql)
317.1195 +{
317.1196 +      typedef MYSQL * STDCALL ep_mysql_init(MYSQL *mysql);
317.1197 +
317.1198 +      ep_mysql_init *fn;
317.1199 +      fn = (ep_mysql_init *) xdlsym(h_mysql, "mysql_init");
317.1200 +      xassert(fn != NULL);
317.1201 +      return (*fn)(mysql);
317.1202 +}
317.1203 +
317.1204 +unsigned int STDCALL dl_mysql_num_fields(MYSQL_RES *res)
317.1205 +{
317.1206 +      typedef unsigned int STDCALL ep_mysql_num_fields(MYSQL_RES *res);
317.1207 +
317.1208 +      ep_mysql_num_fields *fn;
317.1209 +      fn = (ep_mysql_num_fields *) xdlsym(h_mysql, "mysql_num_fields");
317.1210 +      xassert(fn != NULL);
317.1211 +      return (*fn)(res);
317.1212 +}
317.1213 +
317.1214 +int STDCALL dl_mysql_query(MYSQL *mysql, const char *q)
317.1215 +{
317.1216 +      typedef int STDCALL ep_mysql_query(MYSQL *mysql, const char *q);
317.1217 +
317.1218 +      ep_mysql_query *fn;
317.1219 +      fn = (ep_mysql_query *) xdlsym(h_mysql, "mysql_query");
317.1220 +      xassert(fn != NULL);
317.1221 +      return (*fn)(mysql, q);
317.1222 +}
317.1223 +
317.1224 +MYSQL * STDCALL dl_mysql_real_connect(MYSQL *mysql, const char *host,
317.1225 +                                           const char *user,
317.1226 +                                           const char *passwd,
317.1227 +                                           const char *db,
317.1228 +                                           unsigned int port,
317.1229 +                                           const char *unix_socket,
317.1230 +                                           unsigned long clientflag)
317.1231 +{
317.1232 +      typedef MYSQL * STDCALL ep_mysql_real_connect(MYSQL *mysql,
317.1233 +            const char *host,
317.1234 +            const char *user,
317.1235 +            const char *passwd,
317.1236 +            const char *db,
317.1237 +            unsigned int port,
317.1238 +            const char *unix_socket,
317.1239 +            unsigned long clientflag);
317.1240 +
317.1241 +      ep_mysql_real_connect *fn;
317.1242 +      fn = (ep_mysql_real_connect *) xdlsym(h_mysql,
317.1243 +         "mysql_real_connect");
317.1244 +      xassert(fn != NULL);
317.1245 +      return (*fn)(mysql, host, user, passwd, db, port, unix_socket,
317.1246 +         clientflag);
317.1247 +}
317.1248 +
317.1249 +MYSQL_RES * STDCALL dl_mysql_use_result(MYSQL *mysql)
317.1250 +{
317.1251 +      typedef MYSQL_RES * STDCALL ep_mysql_use_result(MYSQL *mysql);
317.1252 +      ep_mysql_use_result *fn;
317.1253 +      fn = (ep_mysql_use_result *) xdlsym(h_mysql, "mysql_use_result");
317.1254 +      xassert(fn != NULL);
317.1255 +      return (*fn)(mysql);
317.1256 +}
317.1257 +
317.1258 +/***********************************************************************
317.1259 +*  NAME
317.1260 +*
317.1261 +*  db_mysql_open - open connection to ODBC data base
317.1262 +*
317.1263 +*  SYNOPSIS
317.1264 +*
317.1265 +*  #include "glpsql.h"
317.1266 +*  void *db_mysql_open(TABDCA *dca, int mode);
317.1267 +*
317.1268 +*  DESCRIPTION
317.1269 +*
317.1270 +*  The routine db_mysql_open opens a connection to a MySQL data base.
317.1271 +*  It then executes the sql statements passed.
317.1272 +*
317.1273 +*  In the case of table read the SELECT statement is executed.
317.1274 +*
317.1275 +*  In the case of table write the INSERT statement is prepared.
317.1276 +*  RETURNS
317.1277 +*
317.1278 +*  The routine returns a pointer to data storage area created. */
317.1279 +
317.1280 +void *db_mysql_open(TABDCA *dca, int mode)
317.1281 +{  void  *ret;
317.1282 +   char **sqllines;
317.1283 +
317.1284 +   sqllines = args_concat(dca);
317.1285 +   if (sqllines == NULL)
317.1286 +   {  xprintf("Missing arguments in table statement.\n"
317.1287 +              "Please, supply table driver, dsn, and query.\n");
317.1288 +      return NULL;
317.1289 +   }
317.1290 +   ret = db_mysql_open_int(dca, mode, (const char **) sqllines);
317.1291 +   free_buffer(sqllines);
317.1292 +   return ret;
317.1293 +}
317.1294 +
317.1295 +static void *db_mysql_open_int(TABDCA *dca, int mode, const char
317.1296 +   **sqllines)
317.1297 +{
317.1298 +   struct db_mysql *sql = NULL;
317.1299 +   char            *arg = NULL;
317.1300 +   const char      *field;
317.1301 +   MYSQL_FIELD     *fields;
317.1302 +   char            *keyword;
317.1303 +   char            *value;
317.1304 +   char            *query;
317.1305 +   char            *dsn;
317.1306 +/* "Server=[server_name];Database=[database_name];UID=[username];*/
317.1307 +/* PWD=[password];Port=[port]"*/
317.1308 +   char            *server   = NULL;        /* Server */
317.1309 +   char            *user     = NULL;        /* UID */
317.1310 +   char            *password = NULL;        /* PWD */
317.1311 +   char            *database = NULL;        /* Database */
317.1312 +   unsigned int     port = 0;               /* Port */
317.1313 +   int              narg;
317.1314 +   int              i, j, total;
317.1315 +
317.1316 +   if (libmysql == NULL)
317.1317 +   {
317.1318 +      xprintf("No loader for shared MySQL library available\n");
317.1319 +      return NULL;
317.1320 +   }
317.1321 +
317.1322 +   if (h_mysql == NULL)
317.1323 +   {
317.1324 +      h_mysql = xdlopen(libmysql);
317.1325 +      if (h_mysql == NULL)
317.1326 +      {  xprintf("unable to open library %s\n", libmysql);
317.1327 +         xprintf("%s\n", xerrmsg());
317.1328 +         return NULL;
317.1329 +      }
317.1330 +   }
317.1331 +
317.1332 +   sql = (struct db_mysql *) xmalloc(sizeof(struct db_mysql));
317.1333 +   if (sql == NULL)
317.1334 +         return NULL;
317.1335 +   sql->mode = mode;
317.1336 +   sql->res = NULL;
317.1337 +   sql->query = NULL;
317.1338 +   sql->nf = mpl_tab_num_flds(dca);
317.1339 +
317.1340 +   narg = mpl_tab_num_args(dca);
317.1341 +   if (narg < 3 )
317.1342 +      xprintf("MySQL driver: string list too short \n");
317.1343 +
317.1344 +   /* get connection string*/
317.1345 +   dsn = (char *) mpl_tab_get_arg(dca, 2);
317.1346 +      /* copy connection string*/
317.1347 +   i = strlen(dsn);
317.1348 +   i++;
317.1349 +   arg = xmalloc(i * sizeof(char));
317.1350 +   strcpy(arg, dsn);
317.1351 +   /*tokenize connection string*/
317.1352 +   for (i = 1, keyword = strtok (arg, "="); (keyword != NULL);
317.1353 +      keyword = strtok (NULL, "="), i++)
317.1354 +   {
317.1355 +         value = strtok (NULL, ";");
317.1356 +      if (value==NULL)
317.1357 +         {
317.1358 +            xprintf("db_mysql_open: Missing value for keyword %s\n",
317.1359 +               keyword);
317.1360 +            xfree(arg);
317.1361 +            xfree(sql);
317.1362 +            return NULL;
317.1363 +      }
317.1364 +      if (0 == strcmp(keyword, "Server"))
317.1365 +            server = value;
317.1366 +      else if (0 == strcmp(keyword, "Database"))
317.1367 +             database = value;
317.1368 +      else if (0 == strcmp(keyword, "UID"))
317.1369 +             user = value;
317.1370 +      else if (0 == strcmp(keyword, "PWD"))
317.1371 +             password = value;
317.1372 +      else if (0 == strcmp(keyword, "Port"))
317.1373 +             port = (unsigned int) atol(value);
317.1374 +   }
317.1375 +   /* Connect to database */
317.1376 +   sql->con = dl_mysql_init(NULL);
317.1377 +  if (!dl_mysql_real_connect(sql->con, server, user, password, database,
317.1378 +      port, NULL, 0))
317.1379 +   {
317.1380 +      xprintf("db_mysql_open: Connect failed\n");
317.1381 +      xprintf("%s\n", dl_mysql_error(sql->con));
317.1382 +      xfree(arg);
317.1383 +      xfree(sql);
317.1384 +      return NULL;
317.1385 +   }
317.1386 +   xfree(arg);
317.1387 +
317.1388 +   for(j = 0; sqllines[j+1] != NULL; j++)
317.1389 +   {  query = (char *) sqllines[j];
317.1390 +      xprintf("%s\n", query);
317.1391 +      if (dl_mysql_query(sql->con, query))
317.1392 +      {
317.1393 +         xprintf("db_mysql_open: Query\n\"%s\"\nfailed.\n", query);
317.1394 +         xprintf("%s\n",dl_mysql_error(sql->con));
317.1395 +         dl_mysql_close(sql->con);
317.1396 +         xfree(sql);
317.1397 +         return NULL;
317.1398 +      }
317.1399 +   }
317.1400 +
317.1401 +   if ( sql->mode == 'R' )
317.1402 +   {  sql->nf = mpl_tab_num_flds(dca);
317.1403 +      for(j = 0; sqllines[j] != NULL; j++)
317.1404 +         arg = (char *) sqllines[j];
317.1405 +      total = strlen(arg);
317.1406 +      if (total > 7 && 0 == strncmp(arg, "SELECT ", 7))
317.1407 +      {
317.1408 +         total = strlen(arg);
317.1409 +         query = xmalloc( (total+1) * sizeof(char));
317.1410 +         strcpy (query, arg);
317.1411 +      }
317.1412 +      else
317.1413 +      {
317.1414 +         query = db_generate_select_stmt(dca);
317.1415 +      }
317.1416 +      xprintf("%s\n", query);
317.1417 +      if (dl_mysql_query(sql->con, query))
317.1418 +      {
317.1419 +         xprintf("db_mysql_open: Query\n\"%s\"\nfailed.\n", query);
317.1420 +         xprintf("%s\n",dl_mysql_error(sql->con));
317.1421 +         dl_mysql_close(sql->con);
317.1422 +         xfree(query);
317.1423 +         xfree(sql);
317.1424 +         return NULL;
317.1425 +      }
317.1426 +      xfree(query);
317.1427 +      sql->res = dl_mysql_use_result(sql->con);
317.1428 +      if (sql->res)
317.1429 +      {
317.1430 +         /* create references between query results and table fields*/
317.1431 +         total = dl_mysql_num_fields(sql->res);
317.1432 +         if (total > SQL_FIELD_MAX)
317.1433 +         {  xprintf("db_mysql_open: Too many fields (> %d) in query.\n"
317.1434 +               "\"%s\"\n", SQL_FIELD_MAX, query);
317.1435 +            xprintf("%s\n",dl_mysql_error(sql->con));
317.1436 +            dl_mysql_close(sql->con);
317.1437 +            xfree(query);
317.1438 +                 xfree(sql);
317.1439 +            return NULL;
317.1440 +         }
317.1441 +         fields = dl_mysql_fetch_fields(sql->res);
317.1442 +         for (i = 1; i <= total; i++)
317.1443 +         {
317.1444 +               for (j = sql->nf; j >= 1; j--)
317.1445 +            {
317.1446 +               if (strcmp(mpl_tab_get_name(dca, j), fields[i-1].name)
317.1447 +                  == 0)
317.1448 +               break;
317.1449 +            }
317.1450 +            sql->ref[i] = j;
317.1451 +         }
317.1452 +      }
317.1453 +      else
317.1454 +      {
317.1455 +         if(dl_mysql_field_count(sql->con) == 0)
317.1456 +            {
317.1457 +            xprintf("db_mysql_open: Query was not a SELECT\n\"%s\"\n",
317.1458 +               query);
317.1459 +            xprintf("%s\n",dl_mysql_error(sql->con));
317.1460 +            xfree(query);
317.1461 +            xfree(sql);
317.1462 +            return NULL;
317.1463 +         }
317.1464 +         else
317.1465 +         {
317.1466 +            xprintf("db_mysql_open: Query\n\"%s\"\nfailed.\n", query);
317.1467 +            xprintf("%s\n",dl_mysql_error(sql->con));
317.1468 +            xfree(query);
317.1469 +            xfree(sql);
317.1470 +            return NULL;
317.1471 +         }
317.1472 +      }
317.1473 +   }
317.1474 +   else if ( sql->mode == 'W' )
317.1475 +   {  for(j = 0; sqllines[j] != NULL; j++)
317.1476 +         arg = (char *) sqllines[j];
317.1477 +      if (  NULL != strchr(arg, '?') )
317.1478 +      {
317.1479 +         total = strlen(arg);
317.1480 +         query = xmalloc( (total+1) * sizeof(char));
317.1481 +         strcpy (query, arg);
317.1482 +         }
317.1483 +      else
317.1484 +         query = db_generate_insert_stmt(dca);
317.1485 +      sql->query = query;
317.1486 +      xprintf("%s\n", query);
317.1487 +   }
317.1488 +   return sql;
317.1489 +}
317.1490 +
317.1491 +int db_mysql_read(TABDCA *dca, void *link)
317.1492 +{  struct db_mysql *sql;
317.1493 +   char            buf[255+1];
317.1494 +   char            **row;
317.1495 +   unsigned long   *lengths;
317.1496 +   MYSQL_FIELD     *fields;
317.1497 +   double          num;
317.1498 +   int             len;
317.1499 +   unsigned long   num_fields;
317.1500 +   int             i;
317.1501 +
317.1502 +   sql = (struct db_mysql *) link;
317.1503 +
317.1504 +   xassert(sql != NULL);
317.1505 +   xassert(sql->mode == 'R');
317.1506 +   if (NULL == sql->res)
317.1507 +   {
317.1508 +      xprintf("db_mysql_read: no result set available");
317.1509 +      return 1;
317.1510 +   }
317.1511 +   if (NULL==(row = (char **)dl_mysql_fetch_row(sql->res))) {
317.1512 +       return -1; /*EOF*/
317.1513 +   }
317.1514 +   lengths = dl_mysql_fetch_lengths(sql->res);
317.1515 +   fields = dl_mysql_fetch_fields(sql->res);
317.1516 +   num_fields = dl_mysql_num_fields(sql->res);
317.1517 +   for (i=1; i <= num_fields; i++)
317.1518 +   {
317.1519 +      if (row[i-1] != NULL)
317.1520 +      {  len = (size_t) lengths[i-1];
317.1521 +         if (len > 255)
317.1522 +            len = 255;
317.1523 +         strncpy(buf, (const char *) row[i-1], len);
317.1524 +         buf[len] = 0x00;
317.1525 +         if (0 != (fields[i-1].flags & NUM_FLAG))
317.1526 +         {  strspx(buf); /* remove spaces*/
317.1527 +            if (str2num(buf, &num) != 0)
317.1528 +            {  xprintf("'%s' cannot be converted to a number.\n", buf);
317.1529 +               return 1;
317.1530 +            }
317.1531 +            if (sql->ref[i] > 0)
317.1532 +               mpl_tab_set_num(dca, sql->ref[i], num);
317.1533 +         }
317.1534 +         else
317.1535 +         {  if (sql->ref[i] > 0)
317.1536 +               mpl_tab_set_str(dca, sql->ref[i], strtrim(buf));
317.1537 +         }
317.1538 +      }
317.1539 +   }
317.1540 +   return 0;
317.1541 +}
317.1542 +
317.1543 +int db_mysql_write(TABDCA *dca, void *link)
317.1544 +{
317.1545 +   struct db_mysql *sql;
317.1546 +   char            *part;
317.1547 +   char            *query;
317.1548 +   char            *template;
317.1549 +   char             num[50];
317.1550 +   int              k;
317.1551 +   int              len;
317.1552 +   int              nf;
317.1553 +
317.1554 +   sql = (struct db_mysql *) link;
317.1555 +   xassert(sql != NULL);
317.1556 +   xassert(sql->mode == 'W');
317.1557 +
317.1558 +   len      = strlen(sql->query);
317.1559 +   template = (char *) xmalloc( (len + 1) * sizeof(char) );
317.1560 +   strcpy(template, sql->query);
317.1561 +
317.1562 +   nf = mpl_tab_num_flds(dca);
317.1563 +   for (k = 1; k <= nf; k++)
317.1564 +   {     switch (mpl_tab_get_type(dca, k))
317.1565 +      {  case 'N':
317.1566 +            len += 20;
317.1567 +            break;
317.1568 +         case 'S':
317.1569 +            len += db_escaped_string_length(mpl_tab_get_str(dca, k));
317.1570 +            len += 2;
317.1571 +            break;
317.1572 +              default:
317.1573 +                        xassert(dca != dca);
317.1574 +         }
317.1575 +   }
317.1576 +   query = xmalloc( (len + 1 ) * sizeof(char) );
317.1577 +   query[0] = 0x00;
317.1578 +   for (k = 1, part = strtok (template, "?"); (part != NULL);
317.1579 +      part = strtok (NULL, "?"), k++)
317.1580 +   {
317.1581 +      if (k > nf) break;
317.1582 +      strcat( query, part );
317.1583 +      switch (mpl_tab_get_type(dca, k))
317.1584 +      {  case 'N':
317.1585 +#if 0 /* 02/XI-2010 by xypron */
317.1586 +            sprintf(num, "%-18g",mpl_tab_get_num(dca, k));
317.1587 +#else
317.1588 +            sprintf(num, "%.*g", DBL_DIG, mpl_tab_get_num(dca, k));
317.1589 +#endif
317.1590 +            strcat( query, num );
317.1591 +            break;
317.1592 +         case 'S':
317.1593 +            strcat( query, "'");
317.1594 +            db_escape_string( query + strlen(query),
317.1595 +               mpl_tab_get_str(dca, k) );
317.1596 +            strcat( query, "'");
317.1597 +            break;
317.1598 +              default:
317.1599 +                        xassert(dca != dca);
317.1600 +         }
317.1601 +   }
317.1602 +   if (part != NULL)
317.1603 +      strcat(query, part);
317.1604 +   if (dl_mysql_query(sql->con, query))
317.1605 +   {
317.1606 +      xprintf("db_mysql_write: Query\n\"%s\"\nfailed.\n", query);
317.1607 +      xprintf("%s\n",dl_mysql_error(sql->con));
317.1608 +      xfree(query);
317.1609 +      xfree(template);
317.1610 +      return 1;
317.1611 +      }
317.1612 +
317.1613 +   xfree(query);
317.1614 +   xfree(template);
317.1615 +   return 0;
317.1616 +   }
317.1617 +
317.1618 +int db_mysql_close(TABDCA *dca, void *link)
317.1619 +{
317.1620 +   struct db_mysql *sql;
317.1621 +
317.1622 +   sql = (struct db_mysql *) link;
317.1623 +   xassert(sql != NULL);
317.1624 +   dl_mysql_close(sql->con);
317.1625 +   if ( sql->mode == 'W' )
317.1626 +      xfree(sql->query);
317.1627 +   xfree(sql);
317.1628 +   dca->link = NULL;
317.1629 +   return 0;
317.1630 +}
317.1631 +
317.1632 +#endif
317.1633 +
317.1634 +/* eof */
   318.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
   318.2 +++ b/deps/glpk/src/glpsql.h	Sun Nov 06 20:59:10 2011 +0100
   318.3 @@ -0,0 +1,64 @@
   318.4 +/* glpsql.h */
   318.5 +
   318.6 +/***********************************************************************
   318.7 +*  This code is part of GLPK (GNU Linear Programming Kit).
   318.8 +*
   318.9 +*  Author: Heinrich Schuchardt <heinrich.schuchardt@gmx.de>.
  318.10 +*
  318.11 +*  Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008,
  318.12 +*  2009, 2010, 2011 Andrew Makhorin, Department for Applied Informatics,
  318.13 +*  Moscow Aviation Institute, Moscow, Russia. All rights reserved.
  318.14 +*  E-mail: <mao@gnu.org>.
  318.15 +*
  318.16 +*  GLPK is free software: you can redistribute it and/or modify it
  318.17 +*  under the terms of the GNU General Public License as published by
  318.18 +*  the Free Software Foundation, either version 3 of the License, or
  318.19 +*  (at your option) any later version.
  318.20 +*
  318.21 +*  GLPK is distributed in the hope that it will be useful, but WITHOUT
  318.22 +*  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
  318.23 +*  or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
  318.24 +*  License for more details.
  318.25 +*
  318.26 +*  You should have received a copy of the GNU General Public License
  318.27 +*  along with GLPK. If not, see <http://www.gnu.org/licenses/>.
  318.28 +***********************************************************************/
  318.29 +
  318.30 +#ifndef GLPSQL_H
  318.31 +#define GLPSQL_H
  318.32 +
  318.33 +#define db_iodbc_open _glp_db_iodbc_open
  318.34 +void *db_iodbc_open(TABDCA *dca, int mode);
  318.35 +/* open iODBC database connection */
  318.36 +
  318.37 +#define db_iodbc_read _glp_db_iodbc_read
  318.38 +int db_iodbc_read(TABDCA *dca, void *link);
  318.39 +/* read data from iODBC */
  318.40 +
  318.41 +#define db_iodbc_write _glp_db_iodbc_write
  318.42 +int db_iodbc_write(TABDCA *dca, void *link);
  318.43 +/* write data to iODBC */
  318.44 +
  318.45 +#define db_iodbc_close _glp_db_iodbc_close
  318.46 +int db_iodbc_close(TABDCA *dca, void *link);
  318.47 +/* close iODBC database connection */
  318.48 +
  318.49 +#define db_mysql_open _glp_db_mysql_open
  318.50 +void *db_mysql_open(TABDCA *dca, int mode);
  318.51 +/* open MySQL database connection */
  318.52 +
  318.53 +#define db_mysql_read _glp_db_mysql_read
  318.54 +int db_mysql_read(TABDCA *dca, void *link);
  318.55 +/* read data from MySQL */
  318.56 +
  318.57 +#define db_mysql_write _glp_db_mysql_write
  318.58 +int db_mysql_write(TABDCA *dca, void *link);
  318.59 +/* write data to MySQL */
  318.60 +
  318.61 +#define db_mysql_close _glp_db_mysql_close
  318.62 +int db_mysql_close(TABDCA *dca, void *link);
  318.63 +/* close MySQL database connection */
  318.64 +
  318.65 +#endif
  318.66 +
  318.67 +/* eof */
   319.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
   319.2 +++ b/deps/glpk/src/glpssx.h	Sun Nov 06 20:59:10 2011 +0100
   319.3 @@ -0,0 +1,418 @@
   319.4 +/* glpssx.h (simplex method, bignum arithmetic) */
   319.5 +
   319.6 +/***********************************************************************
   319.7 +*  This code is part of GLPK (GNU Linear Programming Kit).
   319.8 +*
   319.9 +*  Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008,
  319.10 +*  2009, 2010, 2011 Andrew Makhorin, Department for Applied Informatics,
  319.11 +*  Moscow Aviation Institute, Moscow, Russia. All rights reserved.
  319.12 +*  E-mail: <mao@gnu.org>.
  319.13 +*
  319.14 +*  GLPK is free software: you can redistribute it and/or modify it
  319.15 +*  under the terms of the GNU General Public License as published by
  319.16 +*  the Free Software Foundation, either version 3 of the License, or
  319.17 +*  (at your option) any later version.
  319.18 +*
  319.19 +*  GLPK is distributed in the hope that it will be useful, but WITHOUT
  319.20 +*  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
  319.21 +*  or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
  319.22 +*  License for more details.
  319.23 +*
  319.24 +*  You should have received a copy of the GNU General Public License
  319.25 +*  along with GLPK. If not, see <http://www.gnu.org/licenses/>.
  319.26 +***********************************************************************/
  319.27 +
  319.28 +#ifndef GLPSSX_H
  319.29 +#define GLPSSX_H
  319.30 +
  319.31 +#include "glpbfx.h"
  319.32 +#include "glpenv.h"
  319.33 +
  319.34 +typedef struct SSX SSX;
  319.35 +
  319.36 +struct SSX
  319.37 +{     /* simplex solver workspace */
  319.38 +/*----------------------------------------------------------------------
  319.39 +// LP PROBLEM DATA
  319.40 +//
  319.41 +// It is assumed that LP problem has the following statement:
  319.42 +//
  319.43 +//    minimize (or maximize)
  319.44 +//
  319.45 +//       z = c[1]*x[1] + ... + c[m+n]*x[m+n] + c[0]                  (1)
  319.46 +//
  319.47 +//    subject to equality constraints
  319.48 +//
  319.49 +//       x[1] - a[1,1]*x[m+1] - ... - a[1,n]*x[m+n] = 0
  319.50 +//
  319.51 +//          .  .  .  .  .  .  .                                      (2)
  319.52 +//
  319.53 +//       x[m] - a[m,1]*x[m+1] + ... - a[m,n]*x[m+n] = 0
  319.54 +//
  319.55 +//    and bounds of variables
  319.56 +//
  319.57 +//         l[1] <= x[1]   <= u[1]
  319.58 +//
  319.59 +//          .  .  .  .  .  .  .                                      (3)
  319.60 +//
  319.61 +//       l[m+n] <= x[m+n] <= u[m+n]
  319.62 +//
  319.63 +// where:
  319.64 +// x[1], ..., x[m]      - auxiliary variables;
  319.65 +// x[m+1], ..., x[m+n]  - structural variables;
  319.66 +// z                    - objective function;
  319.67 +// c[1], ..., c[m+n]    - coefficients of the objective function;
  319.68 +// c[0]                 - constant term of the objective function;
  319.69 +// a[1,1], ..., a[m,n]  - constraint coefficients;
  319.70 +// l[1], ..., l[m+n]    - lower bounds of variables;
  319.71 +// u[1], ..., u[m+n]    - upper bounds of variables.
  319.72 +//
  319.73 +// Bounds of variables can be finite as well as inifinite. Besides,
  319.74 +// lower and upper bounds can be equal to each other. So the following
  319.75 +// five types of variables are possible:
  319.76 +//
  319.77 +//    Bounds of variable      Type of variable
  319.78 +//    -------------------------------------------------
  319.79 +//    -inf <  x[k] <  +inf    Free (unbounded) variable
  319.80 +//    l[k] <= x[k] <  +inf    Variable with lower bound
  319.81 +//    -inf <  x[k] <= u[k]    Variable with upper bound
  319.82 +//    l[k] <= x[k] <= u[k]    Double-bounded variable
  319.83 +//    l[k] =  x[k] =  u[k]    Fixed variable
  319.84 +//
  319.85 +// Using vector-matrix notations the LP problem (1)-(3) can be written
  319.86 +// as follows:
  319.87 +//
  319.88 +//    minimize (or maximize)
  319.89 +//
  319.90 +//       z = c * x + c[0]                                            (4)
  319.91 +//
  319.92 +//    subject to equality constraints
  319.93 +//
  319.94 +//       xR - A * xS = 0                                             (5)
  319.95 +//
  319.96 +//    and bounds of variables
  319.97 +//
  319.98 +//       l <= x <= u                                                 (6)
  319.99 +//
 319.100 +// where:
 319.101 +// xR                   - vector of auxiliary variables;
 319.102 +// xS                   - vector of structural variables;
 319.103 +// x = (xR, xS)         - vector of all variables;
 319.104 +// z                    - objective function;
 319.105 +// c                    - vector of objective coefficients;
 319.106 +// c[0]                 - constant term of the objective function;
 319.107 +// A                    - matrix of constraint coefficients (has m rows
 319.108 +//                        and n columns);
 319.109 +// l                    - vector of lower bounds of variables;
 319.110 +// u                    - vector of upper bounds of variables.
 319.111 +//
 319.112 +// The simplex method makes no difference between auxiliary and
 319.113 +// structural variables, so it is convenient to think the system of
 319.114 +// equality constraints (5) written in a homogeneous form:
 319.115 +//
 319.116 +//    (I | -A) * x = 0,                                              (7)
 319.117 +//
 319.118 +// where (I | -A) is an augmented (m+n)xm constraint matrix, I is mxm
 319.119 +// unity matrix whose columns correspond to auxiliary variables, and A
 319.120 +// is the original mxn constraint matrix whose columns correspond to
 319.121 +// structural variables. Note that only the matrix A is stored.
 319.122 +----------------------------------------------------------------------*/
 319.123 +      int m;
 319.124 +      /* number of rows (auxiliary variables), m > 0 */
 319.125 +      int n;
 319.126 +      /* number of columns (structural variables), n > 0 */
 319.127 +      int *type; /* int type[1+m+n]; */
 319.128 +      /* type[0] is not used;
 319.129 +         type[k], 1 <= k <= m+n, is the type of variable x[k]: */
 319.130 +#define SSX_FR          0     /* free (unbounded) variable */
 319.131 +#define SSX_LO          1     /* variable with lower bound */
 319.132 +#define SSX_UP          2     /* variable with upper bound */
 319.133 +#define SSX_DB          3     /* double-bounded variable */
 319.134 +#define SSX_FX          4     /* fixed variable */
 319.135 +      mpq_t *lb; /* mpq_t lb[1+m+n]; alias: l */
 319.136 +      /* lb[0] is not used;
 319.137 +         lb[k], 1 <= k <= m+n, is an lower bound of variable x[k];
 319.138 +         if x[k] has no lower bound, lb[k] is zero */
 319.139 +      mpq_t *ub; /* mpq_t ub[1+m+n]; alias: u */
 319.140 +      /* ub[0] is not used;
 319.141 +         ub[k], 1 <= k <= m+n, is an upper bound of variable x[k];
 319.142 +         if x[k] has no upper bound, ub[k] is zero;
 319.143 +         if x[k] is of fixed type, ub[k] is equal to lb[k] */
 319.144 +      int dir;
 319.145 +      /* optimization direction (sense of the objective function): */
 319.146 +#define SSX_MIN         0     /* minimization */
 319.147 +#define SSX_MAX         1     /* maximization */
 319.148 +      mpq_t *coef; /* mpq_t coef[1+m+n]; alias: c */
 319.149 +      /* coef[0] is a constant term of the objective function;
 319.150 +         coef[k], 1 <= k <= m+n, is a coefficient of the objective
 319.151 +         function at variable x[k];
 319.152 +         note that auxiliary variables also may have non-zero objective
 319.153 +         coefficients */
 319.154 +      int *A_ptr; /* int A_ptr[1+n+1]; */
 319.155 +      int *A_ind; /* int A_ind[A_ptr[n+1]]; */
 319.156 +      mpq_t *A_val; /* mpq_t A_val[A_ptr[n+1]]; */
 319.157 +      /* constraint matrix A (see (5)) in storage-by-columns format */
 319.158 +/*----------------------------------------------------------------------
 319.159 +// LP BASIS AND CURRENT BASIC SOLUTION
 319.160 +//
 319.161 +// The LP basis is defined by the following partition of the augmented
 319.162 +// constraint matrix (7):
 319.163 +//
 319.164 +//    (B | N) = (I | -A) * Q,                                        (8)
 319.165 +//
 319.166 +// where B is a mxm non-singular basis matrix whose columns correspond
 319.167 +// to basic variables xB, N is a mxn matrix whose columns correspond to
 319.168 +// non-basic variables xN, and Q is a permutation (m+n)x(m+n) matrix.
 319.169 +//
 319.170 +// From (7) and (8) it follows that
 319.171 +//
 319.172 +//    (I | -A) * x = (I | -A) * Q * Q' * x = (B | N) * (xB, xN),
 319.173 +//
 319.174 +// therefore
 319.175 +//
 319.176 +//    (xB, xN) = Q' * x,                                             (9)
 319.177 +//
 319.178 +// where x is the vector of all variables in the original order, xB is
 319.179 +// a vector of basic variables, xN is a vector of non-basic variables,
 319.180 +// Q' = inv(Q) is a matrix transposed to Q.
 319.181 +//
 319.182 +// Current values of non-basic variables xN[j], j = 1, ..., n, are not
 319.183 +// stored; they are defined implicitly by their statuses as follows:
 319.184 +//
 319.185 +//    0,             if xN[j] is free variable
 319.186 +//    lN[j],         if xN[j] is on its lower bound                 (10)
 319.187 +//    uN[j],         if xN[j] is on its upper bound
 319.188 +//    lN[j] = uN[j], if xN[j] is fixed variable
 319.189 +//
 319.190 +// where lN[j] and uN[j] are lower and upper bounds of xN[j].
 319.191 +//
 319.192 +// Current values of basic variables xB[i], i = 1, ..., m, are computed
 319.193 +// as follows:
 319.194 +//
 319.195 +//    beta = - inv(B) * N * xN,                                     (11)
 319.196 +//
 319.197 +// where current values of xN are defined by (10).
 319.198 +//
 319.199 +// Current values of simplex multipliers pi[i], i = 1, ..., m (which
 319.200 +// are values of Lagrange multipliers for equality constraints (7) also
 319.201 +// called shadow prices) are computed as follows:
 319.202 +//
 319.203 +//    pi = inv(B') * cB,                                            (12)
 319.204 +//
 319.205 +// where B' is a matrix transposed to B, cB is a vector of objective
 319.206 +// coefficients at basic variables xB.
 319.207 +//
 319.208 +// Current values of reduced costs d[j], j = 1, ..., n, (which are
 319.209 +// values of Langrange multipliers for active inequality constraints
 319.210 +// corresponding to non-basic variables) are computed as follows:
 319.211 +//
 319.212 +//    d = cN - N' * pi,                                             (13)
 319.213 +//
 319.214 +// where N' is a matrix transposed to N, cN is a vector of objective
 319.215 +// coefficients at non-basic variables xN.
 319.216 +----------------------------------------------------------------------*/
 319.217 +      int *stat; /* int stat[1+m+n]; */
 319.218 +      /* stat[0] is not used;
 319.219 +         stat[k], 1 <= k <= m+n, is the status of variable x[k]: */
 319.220 +#define SSX_BS          0     /* basic variable */
 319.221 +#define SSX_NL          1     /* non-basic variable on lower bound */
 319.222 +#define SSX_NU          2     /* non-basic variable on upper bound */
 319.223 +#define SSX_NF          3     /* non-basic free variable */
 319.224 +#define SSX_NS          4     /* non-basic fixed variable */
 319.225 +      int *Q_row; /* int Q_row[1+m+n]; */
 319.226 +      /* matrix Q in row-like format;
 319.227 +         Q_row[0] is not used;
 319.228 +         Q_row[i] = j means that q[i,j] = 1 */
 319.229 +      int *Q_col; /* int Q_col[1+m+n]; */
 319.230 +      /* matrix Q in column-like format;
 319.231 +         Q_col[0] is not used;
 319.232 +         Q_col[j] = i means that q[i,j] = 1 */
 319.233 +      /* if k-th column of the matrix (I | A) is k'-th column of the
 319.234 +         matrix (B | N), then Q_row[k] = k' and Q_col[k'] = k;
 319.235 +         if x[k] is xB[i], then Q_row[k] = i and Q_col[i] = k;
 319.236 +         if x[k] is xN[j], then Q_row[k] = m+j and Q_col[m+j] = k */
 319.237 +      BFX *binv;
 319.238 +      /* invertable form of the basis matrix B */
 319.239 +      mpq_t *bbar; /* mpq_t bbar[1+m]; alias: beta */
 319.240 +      /* bbar[0] is a value of the objective function;
 319.241 +         bbar[i], 1 <= i <= m, is a value of basic variable xB[i] */
 319.242 +      mpq_t *pi; /* mpq_t pi[1+m]; */
 319.243 +      /* pi[0] is not used;
 319.244 +         pi[i], 1 <= i <= m, is a simplex multiplier corresponding to
 319.245 +         i-th row (equality constraint) */
 319.246 +      mpq_t *cbar; /* mpq_t cbar[1+n]; alias: d */
 319.247 +      /* cbar[0] is not used;
 319.248 +         cbar[j], 1 <= j <= n, is a reduced cost of non-basic variable
 319.249 +         xN[j] */
 319.250 +/*----------------------------------------------------------------------
 319.251 +// SIMPLEX TABLE
 319.252 +//
 319.253 +// Due to (8) and (9) the system of equality constraints (7) for the
 319.254 +// current basis can be written as follows:
 319.255 +//
 319.256 +//    xB = A~ * xN,                                                 (14)
 319.257 +//
 319.258 +// where
 319.259 +//
 319.260 +//    A~ = - inv(B) * N                                             (15)
 319.261 +//
 319.262 +// is a mxn matrix called the simplex table.
 319.263 +//
 319.264 +// The revised simplex method uses only two components of A~, namely,
 319.265 +// pivot column corresponding to non-basic variable xN[q] chosen to
 319.266 +// enter the basis, and pivot row corresponding to basic variable xB[p]
 319.267 +// chosen to leave the basis.
 319.268 +//
 319.269 +// Pivot column alfa_q is q-th column of A~, so
 319.270 +//
 319.271 +//    alfa_q = A~ * e[q] = - inv(B) * N * e[q] = - inv(B) * N[q],   (16)
 319.272 +//
 319.273 +// where N[q] is q-th column of the matrix N.
 319.274 +//
 319.275 +// Pivot row alfa_p is p-th row of A~ or, equivalently, p-th column of
 319.276 +// A~', a matrix transposed to A~, so
 319.277 +//
 319.278 +//    alfa_p = A~' * e[p] = - N' * inv(B') * e[p] = - N' * rho_p,   (17)
 319.279 +//
 319.280 +// where (*)' means transposition, and
 319.281 +//
 319.282 +//    rho_p = inv(B') * e[p],                                       (18)
 319.283 +//
 319.284 +// is p-th column of inv(B') or, that is the same, p-th row of inv(B).
 319.285 +----------------------------------------------------------------------*/
 319.286 +      int p;
 319.287 +      /* number of basic variable xB[p], 1 <= p <= m, chosen to leave
 319.288 +         the basis */
 319.289 +      mpq_t *rho; /* mpq_t rho[1+m]; */
 319.290 +      /* p-th row of the inverse inv(B); see (18) */
 319.291 +      mpq_t *ap; /* mpq_t ap[1+n]; */
 319.292 +      /* p-th row of the simplex table; see (17) */
 319.293 +      int q;
 319.294 +      /* number of non-basic variable xN[q], 1 <= q <= n, chosen to
 319.295 +         enter the basis */
 319.296 +      mpq_t *aq; /* mpq_t aq[1+m]; */
 319.297 +      /* q-th column of the simplex table; see (16) */
 319.298 +/*--------------------------------------------------------------------*/
 319.299 +      int q_dir;
 319.300 +      /* direction in which non-basic variable xN[q] should change on
 319.301 +         moving to the adjacent vertex of the polyhedron:
 319.302 +         +1 means that xN[q] increases
 319.303 +         -1 means that xN[q] decreases */
 319.304 +      int p_stat;
 319.305 +      /* non-basic status which should be assigned to basic variable
 319.306 +         xB[p] when it has left the basis and become xN[q] */
 319.307 +      mpq_t delta;
 319.308 +      /* actual change of xN[q] in the adjacent basis (it has the same
 319.309 +         sign as q_dir) */
 319.310 +/*--------------------------------------------------------------------*/
 319.311 +      int it_lim;
 319.312 +      /* simplex iterations limit; if this value is positive, it is
 319.313 +         decreased by one each time when one simplex iteration has been
 319.314 +         performed, and reaching zero value signals the solver to stop
 319.315 +         the search; negative value means no iterations limit */
 319.316 +      int it_cnt;
 319.317 +      /* simplex iterations count; this count is increased by one each
 319.318 +         time when one simplex iteration has been performed */
 319.319 +      double tm_lim;
 319.320 +      /* searching time limit, in seconds; if this value is positive,
 319.321 +         it is decreased each time when one simplex iteration has been
 319.322 +         performed by the amount of time spent for the iteration, and
 319.323 +         reaching zero value signals the solver to stop the search;
 319.324 +         negative value means no time limit */
 319.325 +      double out_frq;
 319.326 +      /* output frequency, in seconds; this parameter specifies how
 319.327 +         frequently the solver sends information about the progress of
 319.328 +         the search to the standard output */
 319.329 +      glp_long tm_beg;
 319.330 +      /* starting time of the search, in seconds; the total time of the
 319.331 +         search is the difference between xtime() and tm_beg */
 319.332 +      glp_long tm_lag;
 319.333 +      /* the most recent time, in seconds, at which the progress of the
 319.334 +         the search was displayed */
 319.335 +};
 319.336 +
 319.337 +#define ssx_create            _glp_ssx_create
 319.338 +#define ssx_factorize         _glp_ssx_factorize
 319.339 +#define ssx_get_xNj           _glp_ssx_get_xNj
 319.340 +#define ssx_eval_bbar         _glp_ssx_eval_bbar
 319.341 +#define ssx_eval_pi           _glp_ssx_eval_pi
 319.342 +#define ssx_eval_dj           _glp_ssx_eval_dj
 319.343 +#define ssx_eval_cbar         _glp_ssx_eval_cbar
 319.344 +#define ssx_eval_rho          _glp_ssx_eval_rho
 319.345 +#define ssx_eval_row          _glp_ssx_eval_row
 319.346 +#define ssx_eval_col          _glp_ssx_eval_col
 319.347 +#define ssx_chuzc             _glp_ssx_chuzc
 319.348 +#define ssx_chuzr             _glp_ssx_chuzr
 319.349 +#define ssx_update_bbar       _glp_ssx_update_bbar
 319.350 +#define ssx_update_pi         _glp_ssx_update_pi
 319.351 +#define ssx_update_cbar       _glp_ssx_update_cbar
 319.352 +#define ssx_change_basis      _glp_ssx_change_basis
 319.353 +#define ssx_delete            _glp_ssx_delete
 319.354 +
 319.355 +#define ssx_phase_I           _glp_ssx_phase_I
 319.356 +#define ssx_phase_II          _glp_ssx_phase_II
 319.357 +#define ssx_driver            _glp_ssx_driver
 319.358 +
 319.359 +SSX *ssx_create(int m, int n, int nnz);
 319.360 +/* create simplex solver workspace */
 319.361 +
 319.362 +int ssx_factorize(SSX *ssx);
 319.363 +/* factorize the current basis matrix */
 319.364 +
 319.365 +void ssx_get_xNj(SSX *ssx, int j, mpq_t x);
 319.366 +/* determine value of non-basic variable */
 319.367 +
 319.368 +void ssx_eval_bbar(SSX *ssx);
 319.369 +/* compute values of basic variables */
 319.370 +
 319.371 +void ssx_eval_pi(SSX *ssx);
 319.372 +/* compute values of simplex multipliers */
 319.373 +
 319.374 +void ssx_eval_dj(SSX *ssx, int j, mpq_t dj);
 319.375 +/* compute reduced cost of non-basic variable */
 319.376 +
 319.377 +void ssx_eval_cbar(SSX *ssx);
 319.378 +/* compute reduced costs of all non-basic variables */
 319.379 +
 319.380 +void ssx_eval_rho(SSX *ssx);
 319.381 +/* compute p-th row of the inverse */
 319.382 +
 319.383 +void ssx_eval_row(SSX *ssx);
 319.384 +/* compute pivot row of the simplex table */
 319.385 +
 319.386 +void ssx_eval_col(SSX *ssx);
 319.387 +/* compute pivot column of the simplex table */
 319.388 +
 319.389 +void ssx_chuzc(SSX *ssx);
 319.390 +/* choose pivot column */
 319.391 +
 319.392 +void ssx_chuzr(SSX *ssx);
 319.393 +/* choose pivot row */
 319.394 +
 319.395 +void ssx_update_bbar(SSX *ssx);
 319.396 +/* update values of basic variables */
 319.397 +
 319.398 +void ssx_update_pi(SSX *ssx);
 319.399 +/* update simplex multipliers */
 319.400 +
 319.401 +void ssx_update_cbar(SSX *ssx);
 319.402 +/* update reduced costs of non-basic variables */
 319.403 +
 319.404 +void ssx_change_basis(SSX *ssx);
 319.405 +/* change current basis to adjacent one */
 319.406 +
 319.407 +void ssx_delete(SSX *ssx);
 319.408 +/* delete simplex solver workspace */
 319.409 +
 319.410 +int ssx_phase_I(SSX *ssx);
 319.411 +/* find primal feasible solution */
 319.412 +
 319.413 +int ssx_phase_II(SSX *ssx);
 319.414 +/* find optimal solution */
 319.415 +
 319.416 +int ssx_driver(SSX *ssx);
 319.417 +/* base driver to exact simplex method */
 319.418 +
 319.419 +#endif
 319.420 +
 319.421 +/* eof */
   320.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
   320.2 +++ b/deps/glpk/src/glpssx01.c	Sun Nov 06 20:59:10 2011 +0100
   320.3 @@ -0,0 +1,839 @@
   320.4 +/* glpssx01.c */
   320.5 +
   320.6 +/***********************************************************************
   320.7 +*  This code is part of GLPK (GNU Linear Programming Kit).
   320.8 +*
   320.9 +*  Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008,
  320.10 +*  2009, 2010, 2011 Andrew Makhorin, Department for Applied Informatics,
  320.11 +*  Moscow Aviation Institute, Moscow, Russia. All rights reserved.
  320.12 +*  E-mail: <mao@gnu.org>.
  320.13 +*
  320.14 +*  GLPK is free software: you can redistribute it and/or modify it
  320.15 +*  under the terms of the GNU General Public License as published by
  320.16 +*  the Free Software Foundation, either version 3 of the License, or
  320.17 +*  (at your option) any later version.
  320.18 +*
  320.19 +*  GLPK is distributed in the hope that it will be useful, but WITHOUT
  320.20 +*  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
  320.21 +*  or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
  320.22 +*  License for more details.
  320.23 +*
  320.24 +*  You should have received a copy of the GNU General Public License
  320.25 +*  along with GLPK. If not, see <http://www.gnu.org/licenses/>.
  320.26 +***********************************************************************/
  320.27 +
  320.28 +#include "glpenv.h"
  320.29 +#include "glpssx.h"
  320.30 +#define xfault xerror
  320.31 +
  320.32 +/*----------------------------------------------------------------------
  320.33 +// ssx_create - create simplex solver workspace.
  320.34 +//
  320.35 +// This routine creates the workspace used by simplex solver routines,
  320.36 +// and returns a pointer to it.
  320.37 +//
  320.38 +// Parameters m, n, and nnz specify, respectively, the number of rows,
  320.39 +// columns, and non-zero constraint coefficients.
  320.40 +//
  320.41 +// This routine only allocates the memory for the workspace components,
  320.42 +// so the workspace needs to be saturated by data. */
  320.43 +
  320.44 +SSX *ssx_create(int m, int n, int nnz)
  320.45 +{     SSX *ssx;
  320.46 +      int i, j, k;
  320.47 +      if (m < 1)
  320.48 +         xfault("ssx_create: m = %d; invalid number of rows\n", m);
  320.49 +      if (n < 1)
  320.50 +         xfault("ssx_create: n = %d; invalid number of columns\n", n);
  320.51 +      if (nnz < 0)
  320.52 +         xfault("ssx_create: nnz = %d; invalid number of non-zero const"
  320.53 +            "raint coefficients\n", nnz);
  320.54 +      ssx = xmalloc(sizeof(SSX));
  320.55 +      ssx->m = m;
  320.56 +      ssx->n = n;
  320.57 +      ssx->type = xcalloc(1+m+n, sizeof(int));
  320.58 +      ssx->lb = xcalloc(1+m+n, sizeof(mpq_t));
  320.59 +      for (k = 1; k <= m+n; k++) mpq_init(ssx->lb[k]);
  320.60 +      ssx->ub = xcalloc(1+m+n, sizeof(mpq_t));
  320.61 +      for (k = 1; k <= m+n; k++) mpq_init(ssx->ub[k]);
  320.62 +      ssx->coef = xcalloc(1+m+n, sizeof(mpq_t));
  320.63 +      for (k = 0; k <= m+n; k++) mpq_init(ssx->coef[k]);
  320.64 +      ssx->A_ptr = xcalloc(1+n+1, sizeof(int));
  320.65 +      ssx->A_ptr[n+1] = nnz+1;
  320.66 +      ssx->A_ind = xcalloc(1+nnz, sizeof(int));
  320.67 +      ssx->A_val = xcalloc(1+nnz, sizeof(mpq_t));
  320.68 +      for (k = 1; k <= nnz; k++) mpq_init(ssx->A_val[k]);
  320.69 +      ssx->stat = xcalloc(1+m+n, sizeof(int));
  320.70 +      ssx->Q_row = xcalloc(1+m+n, sizeof(int));
  320.71 +      ssx->Q_col = xcalloc(1+m+n, sizeof(int));
  320.72 +      ssx->binv = bfx_create_binv();
  320.73 +      ssx->bbar = xcalloc(1+m, sizeof(mpq_t));
  320.74 +      for (i = 0; i <= m; i++) mpq_init(ssx->bbar[i]);
  320.75 +      ssx->pi = xcalloc(1+m, sizeof(mpq_t));
  320.76 +      for (i = 1; i <= m; i++) mpq_init(ssx->pi[i]);
  320.77 +      ssx->cbar = xcalloc(1+n, sizeof(mpq_t));
  320.78 +      for (j = 1; j <= n; j++) mpq_init(ssx->cbar[j]);
  320.79 +      ssx->rho = xcalloc(1+m, sizeof(mpq_t));
  320.80 +      for (i = 1; i <= m; i++) mpq_init(ssx->rho[i]);
  320.81 +      ssx->ap = xcalloc(1+n, sizeof(mpq_t));
  320.82 +      for (j = 1; j <= n; j++) mpq_init(ssx->ap[j]);
  320.83 +      ssx->aq = xcalloc(1+m, sizeof(mpq_t));
  320.84 +      for (i = 1; i <= m; i++) mpq_init(ssx->aq[i]);
  320.85 +      mpq_init(ssx->delta);
  320.86 +      return ssx;
  320.87 +}
  320.88 +
  320.89 +/*----------------------------------------------------------------------
  320.90 +// ssx_factorize - factorize the current basis matrix.
  320.91 +//
  320.92 +// This routine computes factorization of the current basis matrix B
  320.93 +// and returns the singularity flag. If the matrix B is non-singular,
  320.94 +// the flag is zero, otherwise non-zero. */
  320.95 +
  320.96 +static int basis_col(void *info, int j, int ind[], mpq_t val[])
  320.97 +{     /* this auxiliary routine provides row indices and numeric values
  320.98 +         of non-zero elements in j-th column of the matrix B */
  320.99 +      SSX *ssx = info;
 320.100 +      int m = ssx->m;
 320.101 +      int n = ssx->n;
 320.102 +      int *A_ptr = ssx->A_ptr;
 320.103 +      int *A_ind = ssx->A_ind;
 320.104 +      mpq_t *A_val = ssx->A_val;
 320.105 +      int *Q_col = ssx->Q_col;
 320.106 +      int k, len, ptr;
 320.107 +      xassert(1 <= j && j <= m);
 320.108 +      k = Q_col[j]; /* x[k] = xB[j] */
 320.109 +      xassert(1 <= k && k <= m+n);
 320.110 +      /* j-th column of the matrix B is k-th column of the augmented
 320.111 +         constraint matrix (I | -A) */
 320.112 +      if (k <= m)
 320.113 +      {  /* it is a column of the unity matrix I */
 320.114 +         len = 1, ind[1] = k, mpq_set_si(val[1], 1, 1);
 320.115 +      }
 320.116 +      else
 320.117 +      {  /* it is a column of the original constraint matrix -A */
 320.118 +         len = 0;
 320.119 +         for (ptr = A_ptr[k-m]; ptr < A_ptr[k-m+1]; ptr++)
 320.120 +         {  len++;
 320.121 +            ind[len] = A_ind[ptr];
 320.122 +            mpq_neg(val[len], A_val[ptr]);
 320.123 +         }
 320.124 +      }
 320.125 +      return len;
 320.126 +}
 320.127 +
 320.128 +int ssx_factorize(SSX *ssx)
 320.129 +{     int ret;
 320.130 +      ret = bfx_factorize(ssx->binv, ssx->m, basis_col, ssx);
 320.131 +      return ret;
 320.132 +}
 320.133 +
 320.134 +/*----------------------------------------------------------------------
 320.135 +// ssx_get_xNj - determine value of non-basic variable.
 320.136 +//
 320.137 +// This routine determines the value of non-basic variable xN[j] in the
 320.138 +// current basic solution defined as follows:
 320.139 +//
 320.140 +//    0,             if xN[j] is free variable
 320.141 +//    lN[j],         if xN[j] is on its lower bound
 320.142 +//    uN[j],         if xN[j] is on its upper bound
 320.143 +//    lN[j] = uN[j], if xN[j] is fixed variable
 320.144 +//
 320.145 +// where lN[j] and uN[j] are lower and upper bounds of xN[j]. */
 320.146 +
 320.147 +void ssx_get_xNj(SSX *ssx, int j, mpq_t x)
 320.148 +{     int m = ssx->m;
 320.149 +      int n = ssx->n;
 320.150 +      mpq_t *lb = ssx->lb;
 320.151 +      mpq_t *ub = ssx->ub;
 320.152 +      int *stat = ssx->stat;
 320.153 +      int *Q_col = ssx->Q_col;
 320.154 +      int k;
 320.155 +      xassert(1 <= j && j <= n);
 320.156 +      k = Q_col[m+j]; /* x[k] = xN[j] */
 320.157 +      xassert(1 <= k && k <= m+n);
 320.158 +      switch (stat[k])
 320.159 +      {  case SSX_NL:
 320.160 +            /* xN[j] is on its lower bound */
 320.161 +            mpq_set(x, lb[k]); break;
 320.162 +         case SSX_NU:
 320.163 +            /* xN[j] is on its upper bound */
 320.164 +            mpq_set(x, ub[k]); break;
 320.165 +         case SSX_NF:
 320.166 +            /* xN[j] is free variable */
 320.167 +            mpq_set_si(x, 0, 1); break;
 320.168 +         case SSX_NS:
 320.169 +            /* xN[j] is fixed variable */
 320.170 +            mpq_set(x, lb[k]); break;
 320.171 +         default:
 320.172 +            xassert(stat != stat);
 320.173 +      }
 320.174 +      return;
 320.175 +}
 320.176 +
 320.177 +/*----------------------------------------------------------------------
 320.178 +// ssx_eval_bbar - compute values of basic variables.
 320.179 +//
 320.180 +// This routine computes values of basic variables xB in the current
 320.181 +// basic solution as follows:
 320.182 +//
 320.183 +//    beta = - inv(B) * N * xN,
 320.184 +//
 320.185 +// where B is the basis matrix, N is the matrix of non-basic columns,
 320.186 +// xN is a vector of current values of non-basic variables. */
 320.187 +
 320.188 +void ssx_eval_bbar(SSX *ssx)
 320.189 +{     int m = ssx->m;
 320.190 +      int n = ssx->n;
 320.191 +      mpq_t *coef = ssx->coef;
 320.192 +      int *A_ptr = ssx->A_ptr;
 320.193 +      int *A_ind = ssx->A_ind;
 320.194 +      mpq_t *A_val = ssx->A_val;
 320.195 +      int *Q_col = ssx->Q_col;
 320.196 +      mpq_t *bbar = ssx->bbar;
 320.197 +      int i, j, k, ptr;
 320.198 +      mpq_t x, temp;
 320.199 +      mpq_init(x);
 320.200 +      mpq_init(temp);
 320.201 +      /* bbar := 0 */
 320.202 +      for (i = 1; i <= m; i++)
 320.203 +         mpq_set_si(bbar[i], 0, 1);
 320.204 +      /* bbar := - N * xN = - N[1] * xN[1] - ... - N[n] * xN[n] */
 320.205 +      for (j = 1; j <= n; j++)
 320.206 +      {  ssx_get_xNj(ssx, j, x);
 320.207 +         if (mpq_sgn(x) == 0) continue;
 320.208 +         k = Q_col[m+j]; /* x[k] = xN[j] */
 320.209 +         if (k <= m)
 320.210 +         {  /* N[j] is a column of the unity matrix I */
 320.211 +            mpq_sub(bbar[k], bbar[k], x);
 320.212 +         }
 320.213 +         else
 320.214 +         {  /* N[j] is a column of the original constraint matrix -A */
 320.215 +            for (ptr = A_ptr[k-m]; ptr < A_ptr[k-m+1]; ptr++)
 320.216 +            {  mpq_mul(temp, A_val[ptr], x);
 320.217 +               mpq_add(bbar[A_ind[ptr]], bbar[A_ind[ptr]], temp);
 320.218 +            }
 320.219 +         }
 320.220 +      }
 320.221 +      /* bbar := inv(B) * bbar */
 320.222 +      bfx_ftran(ssx->binv, bbar, 0);
 320.223 +#if 1
 320.224 +      /* compute value of the objective function */
 320.225 +      /* bbar[0] := c[0] */
 320.226 +      mpq_set(bbar[0], coef[0]);
 320.227 +      /* bbar[0] := bbar[0] + sum{i in B} cB[i] * xB[i] */
 320.228 +      for (i = 1; i <= m; i++)
 320.229 +      {  k = Q_col[i]; /* x[k] = xB[i] */
 320.230 +         if (mpq_sgn(coef[k]) == 0) continue;
 320.231 +         mpq_mul(temp, coef[k], bbar[i]);
 320.232 +         mpq_add(bbar[0], bbar[0], temp);
 320.233 +      }
 320.234 +      /* bbar[0] := bbar[0] + sum{j in N} cN[j] * xN[j] */
 320.235 +      for (j = 1; j <= n; j++)
 320.236 +      {  k = Q_col[m+j]; /* x[k] = xN[j] */
 320.237 +         if (mpq_sgn(coef[k]) == 0) continue;
 320.238 +         ssx_get_xNj(ssx, j, x);
 320.239 +         mpq_mul(temp, coef[k], x);
 320.240 +         mpq_add(bbar[0], bbar[0], temp);
 320.241 +      }
 320.242 +#endif
 320.243 +      mpq_clear(x);
 320.244 +      mpq_clear(temp);
 320.245 +      return;
 320.246 +}
 320.247 +
 320.248 +/*----------------------------------------------------------------------
 320.249 +// ssx_eval_pi - compute values of simplex multipliers.
 320.250 +//
 320.251 +// This routine computes values of simplex multipliers (shadow prices)
 320.252 +// pi in the current basic solution as follows:
 320.253 +//
 320.254 +//    pi = inv(B') * cB,
 320.255 +//
 320.256 +// where B' is a matrix transposed to the basis matrix B, cB is a vector
 320.257 +// of objective coefficients at basic variables xB. */
 320.258 +
 320.259 +void ssx_eval_pi(SSX *ssx)
 320.260 +{     int m = ssx->m;
 320.261 +      mpq_t *coef = ssx->coef;
 320.262 +      int *Q_col = ssx->Q_col;
 320.263 +      mpq_t *pi = ssx->pi;
 320.264 +      int i;
 320.265 +      /* pi := cB */
 320.266 +      for (i = 1; i <= m; i++) mpq_set(pi[i], coef[Q_col[i]]);
 320.267 +      /* pi := inv(B') * cB */
 320.268 +      bfx_btran(ssx->binv, pi);
 320.269 +      return;
 320.270 +}
 320.271 +
 320.272 +/*----------------------------------------------------------------------
 320.273 +// ssx_eval_dj - compute reduced cost of non-basic variable.
 320.274 +//
 320.275 +// This routine computes reduced cost d[j] of non-basic variable xN[j]
 320.276 +// in the current basic solution as follows:
 320.277 +//
 320.278 +//    d[j] = cN[j] - N[j] * pi,
 320.279 +//
 320.280 +// where cN[j] is an objective coefficient at xN[j], N[j] is a column
 320.281 +// of the augmented constraint matrix (I | -A) corresponding to xN[j],
 320.282 +// pi is the vector of simplex multipliers (shadow prices). */
 320.283 +
 320.284 +void ssx_eval_dj(SSX *ssx, int j, mpq_t dj)
 320.285 +{     int m = ssx->m;
 320.286 +      int n = ssx->n;
 320.287 +      mpq_t *coef = ssx->coef;
 320.288 +      int *A_ptr = ssx->A_ptr;
 320.289 +      int *A_ind = ssx->A_ind;
 320.290 +      mpq_t *A_val = ssx->A_val;
 320.291 +      int *Q_col = ssx->Q_col;
 320.292 +      mpq_t *pi = ssx->pi;
 320.293 +      int k, ptr, end;
 320.294 +      mpq_t temp;
 320.295 +      mpq_init(temp);
 320.296 +      xassert(1 <= j && j <= n);
 320.297 +      k = Q_col[m+j]; /* x[k] = xN[j] */
 320.298 +      xassert(1 <= k && k <= m+n);
 320.299 +      /* j-th column of the matrix N is k-th column of the augmented
 320.300 +         constraint matrix (I | -A) */
 320.301 +      if (k <= m)
 320.302 +      {  /* it is a column of the unity matrix I */
 320.303 +         mpq_sub(dj, coef[k], pi[k]);
 320.304 +      }
 320.305 +      else
 320.306 +      {  /* it is a column of the original constraint matrix -A */
 320.307 +         mpq_set(dj, coef[k]);
 320.308 +         for (ptr = A_ptr[k-m], end = A_ptr[k-m+1]; ptr < end; ptr++)
 320.309 +         {  mpq_mul(temp, A_val[ptr], pi[A_ind[ptr]]);
 320.310 +            mpq_add(dj, dj, temp);
 320.311 +         }
 320.312 +      }
 320.313 +      mpq_clear(temp);
 320.314 +      return;
 320.315 +}
 320.316 +
 320.317 +/*----------------------------------------------------------------------
 320.318 +// ssx_eval_cbar - compute reduced costs of all non-basic variables.
 320.319 +//
 320.320 +// This routine computes the vector of reduced costs pi in the current
 320.321 +// basic solution for all non-basic variables, including fixed ones. */
 320.322 +
 320.323 +void ssx_eval_cbar(SSX *ssx)
 320.324 +{     int n = ssx->n;
 320.325 +      mpq_t *cbar = ssx->cbar;
 320.326 +      int j;
 320.327 +      for (j = 1; j <= n; j++)
 320.328 +         ssx_eval_dj(ssx, j, cbar[j]);
 320.329 +      return;
 320.330 +}
 320.331 +
 320.332 +/*----------------------------------------------------------------------
 320.333 +// ssx_eval_rho - compute p-th row of the inverse.
 320.334 +//
 320.335 +// This routine computes p-th row of the matrix inv(B), where B is the
 320.336 +// current basis matrix.
 320.337 +//
 320.338 +// p-th row of the inverse is computed using the following formula:
 320.339 +//
 320.340 +//    rho = inv(B') * e[p],
 320.341 +//
 320.342 +// where B' is a matrix transposed to B, e[p] is a unity vector, which
 320.343 +// contains one in p-th position. */
 320.344 +
 320.345 +void ssx_eval_rho(SSX *ssx)
 320.346 +{     int m = ssx->m;
 320.347 +      int p = ssx->p;
 320.348 +      mpq_t *rho = ssx->rho;
 320.349 +      int i;
 320.350 +      xassert(1 <= p && p <= m);
 320.351 +      /* rho := 0 */
 320.352 +      for (i = 1; i <= m; i++) mpq_set_si(rho[i], 0, 1);
 320.353 +      /* rho := e[p] */
 320.354 +      mpq_set_si(rho[p], 1, 1);
 320.355 +      /* rho := inv(B') * rho */
 320.356 +      bfx_btran(ssx->binv, rho);
 320.357 +      return;
 320.358 +}
 320.359 +
 320.360 +/*----------------------------------------------------------------------
 320.361 +// ssx_eval_row - compute pivot row of the simplex table.
 320.362 +//
 320.363 +// This routine computes p-th (pivot) row of the current simplex table
 320.364 +// A~ = - inv(B) * N using the following formula:
 320.365 +//
 320.366 +//    A~[p] = - N' * inv(B') * e[p] = - N' * rho[p],
 320.367 +//
 320.368 +// where N' is a matrix transposed to the matrix N, rho[p] is p-th row
 320.369 +// of the inverse inv(B). */
 320.370 +
 320.371 +void ssx_eval_row(SSX *ssx)
 320.372 +{     int m = ssx->m;
 320.373 +      int n = ssx->n;
 320.374 +      int *A_ptr = ssx->A_ptr;
 320.375 +      int *A_ind = ssx->A_ind;
 320.376 +      mpq_t *A_val = ssx->A_val;
 320.377 +      int *Q_col = ssx->Q_col;
 320.378 +      mpq_t *rho = ssx->rho;
 320.379 +      mpq_t *ap = ssx->ap;
 320.380 +      int j, k, ptr;
 320.381 +      mpq_t temp;
 320.382 +      mpq_init(temp);
 320.383 +      for (j = 1; j <= n; j++)
 320.384 +      {  /* ap[j] := - N'[j] * rho (inner product) */
 320.385 +         k = Q_col[m+j]; /* x[k] = xN[j] */
 320.386 +         if (k <= m)
 320.387 +            mpq_neg(ap[j], rho[k]);
 320.388 +         else
 320.389 +         {  mpq_set_si(ap[j], 0, 1);
 320.390 +            for (ptr = A_ptr[k-m]; ptr < A_ptr[k-m+1]; ptr++)
 320.391 +            {  mpq_mul(temp, A_val[ptr], rho[A_ind[ptr]]);
 320.392 +               mpq_add(ap[j], ap[j], temp);
 320.393 +            }
 320.394 +         }
 320.395 +      }
 320.396 +      mpq_clear(temp);
 320.397 +      return;
 320.398 +}
 320.399 +
 320.400 +/*----------------------------------------------------------------------
 320.401 +// ssx_eval_col - compute pivot column of the simplex table.
 320.402 +//
 320.403 +// This routine computes q-th (pivot) column of the current simplex
 320.404 +// table A~ = - inv(B) * N using the following formula:
 320.405 +//
 320.406 +//    A~[q] = - inv(B) * N[q],
 320.407 +//
 320.408 +// where N[q] is q-th column of the matrix N corresponding to chosen
 320.409 +// non-basic variable xN[q]. */
 320.410 +
 320.411 +void ssx_eval_col(SSX *ssx)
 320.412 +{     int m = ssx->m;
 320.413 +      int n = ssx->n;
 320.414 +      int *A_ptr = ssx->A_ptr;
 320.415 +      int *A_ind = ssx->A_ind;
 320.416 +      mpq_t *A_val = ssx->A_val;
 320.417 +      int *Q_col = ssx->Q_col;
 320.418 +      int q = ssx->q;
 320.419 +      mpq_t *aq = ssx->aq;
 320.420 +      int i, k, ptr;
 320.421 +      xassert(1 <= q && q <= n);
 320.422 +      /* aq := 0 */
 320.423 +      for (i = 1; i <= m; i++) mpq_set_si(aq[i], 0, 1);
 320.424 +      /* aq := N[q] */
 320.425 +      k = Q_col[m+q]; /* x[k] = xN[q] */
 320.426 +      if (k <= m)
 320.427 +      {  /* N[q] is a column of the unity matrix I */
 320.428 +         mpq_set_si(aq[k], 1, 1);
 320.429 +      }
 320.430 +      else
 320.431 +      {  /* N[q] is a column of the original constraint matrix -A */
 320.432 +         for (ptr = A_ptr[k-m]; ptr < A_ptr[k-m+1]; ptr++)
 320.433 +            mpq_neg(aq[A_ind[ptr]], A_val[ptr]);
 320.434 +      }
 320.435 +      /* aq := inv(B) * aq */
 320.436 +      bfx_ftran(ssx->binv, aq, 1);
 320.437 +      /* aq := - aq */
 320.438 +      for (i = 1; i <= m; i++) mpq_neg(aq[i], aq[i]);
 320.439 +      return;
 320.440 +}
 320.441 +
 320.442 +/*----------------------------------------------------------------------
 320.443 +// ssx_chuzc - choose pivot column.
 320.444 +//
 320.445 +// This routine chooses non-basic variable xN[q] whose reduced cost
 320.446 +// indicates possible improving of the objective function to enter it
 320.447 +// in the basis.
 320.448 +//
 320.449 +// Currently the standard (textbook) pricing is used, i.e. that
 320.450 +// non-basic variable is preferred which has greatest reduced cost (in
 320.451 +// magnitude).
 320.452 +//
 320.453 +// If xN[q] has been chosen, the routine stores its number q and also
 320.454 +// sets the flag q_dir that indicates direction in which xN[q] has to
 320.455 +// change (+1 means increasing, -1 means decreasing).
 320.456 +//
 320.457 +// If the choice cannot be made, because the current basic solution is
 320.458 +// dual feasible, the routine sets the number q to 0. */
 320.459 +
 320.460 +void ssx_chuzc(SSX *ssx)
 320.461 +{     int m = ssx->m;
 320.462 +      int n = ssx->n;
 320.463 +      int dir = (ssx->dir == SSX_MIN ? +1 : -1);
 320.464 +      int *Q_col = ssx->Q_col;
 320.465 +      int *stat = ssx->stat;
 320.466 +      mpq_t *cbar = ssx->cbar;
 320.467 +      int j, k, s, q, q_dir;
 320.468 +      double best, temp;
 320.469 +      /* nothing is chosen so far */
 320.470 +      q = 0, q_dir = 0, best = 0.0;
 320.471 +      /* look through the list of non-basic variables */
 320.472 +      for (j = 1; j <= n; j++)
 320.473 +      {  k = Q_col[m+j]; /* x[k] = xN[j] */
 320.474 +         s = dir * mpq_sgn(cbar[j]);
 320.475 +         if ((stat[k] == SSX_NF || stat[k] == SSX_NL) && s < 0 ||
 320.476 +             (stat[k] == SSX_NF || stat[k] == SSX_NU) && s > 0)
 320.477 +         {  /* reduced cost of xN[j] indicates possible improving of
 320.478 +               the objective function */
 320.479 +            temp = fabs(mpq_get_d(cbar[j]));
 320.480 +            xassert(temp != 0.0);
 320.481 +            if (q == 0 || best < temp)
 320.482 +               q = j, q_dir = - s, best = temp;
 320.483 +         }
 320.484 +      }
 320.485 +      ssx->q = q, ssx->q_dir = q_dir;
 320.486 +      return;
 320.487 +}
 320.488 +
 320.489 +/*----------------------------------------------------------------------
 320.490 +// ssx_chuzr - choose pivot row.
 320.491 +//
 320.492 +// This routine looks through elements of q-th column of the simplex
 320.493 +// table and chooses basic variable xB[p] which should leave the basis.
 320.494 +//
 320.495 +// The choice is based on the standard (textbook) ratio test.
 320.496 +//
 320.497 +// If xB[p] has been chosen, the routine stores its number p and also
 320.498 +// sets its non-basic status p_stat which should be assigned to xB[p]
 320.499 +// when it has left the basis and become xN[q].
 320.500 +//
 320.501 +// Special case p < 0 means that xN[q] is double-bounded variable and
 320.502 +// it reaches its opposite bound before any basic variable does that,
 320.503 +// so the current basis remains unchanged.
 320.504 +//
 320.505 +// If the choice cannot be made, because xN[q] can infinitely change in
 320.506 +// the feasible direction, the routine sets the number p to 0. */
 320.507 +
 320.508 +void ssx_chuzr(SSX *ssx)
 320.509 +{     int m = ssx->m;
 320.510 +      int n = ssx->n;
 320.511 +      int *type = ssx->type;
 320.512 +      mpq_t *lb = ssx->lb;
 320.513 +      mpq_t *ub = ssx->ub;
 320.514 +      int *Q_col = ssx->Q_col;
 320.515 +      mpq_t *bbar = ssx->bbar;
 320.516 +      int q = ssx->q;
 320.517 +      mpq_t *aq = ssx->aq;
 320.518 +      int q_dir = ssx->q_dir;
 320.519 +      int i, k, s, t, p, p_stat;
 320.520 +      mpq_t teta, temp;
 320.521 +      mpq_init(teta);
 320.522 +      mpq_init(temp);
 320.523 +      xassert(1 <= q && q <= n);
 320.524 +      xassert(q_dir == +1 || q_dir == -1);
 320.525 +      /* nothing is chosen so far */
 320.526 +      p = 0, p_stat = 0;
 320.527 +      /* look through the list of basic variables */
 320.528 +      for (i = 1; i <= m; i++)
 320.529 +      {  s = q_dir * mpq_sgn(aq[i]);
 320.530 +         if (s < 0)
 320.531 +         {  /* xB[i] decreases */
 320.532 +            k = Q_col[i]; /* x[k] = xB[i] */
 320.533 +            t = type[k];
 320.534 +            if (t == SSX_LO || t == SSX_DB || t == SSX_FX)
 320.535 +            {  /* xB[i] has finite lower bound */
 320.536 +               mpq_sub(temp, bbar[i], lb[k]);
 320.537 +               mpq_div(temp, temp, aq[i]);
 320.538 +               mpq_abs(temp, temp);
 320.539 +               if (p == 0 || mpq_cmp(teta, temp) > 0)
 320.540 +               {  p = i;
 320.541 +                  p_stat = (t == SSX_FX ? SSX_NS : SSX_NL);
 320.542 +                  mpq_set(teta, temp);
 320.543 +               }
 320.544 +            }
 320.545 +         }
 320.546 +         else if (s > 0)
 320.547 +         {  /* xB[i] increases */
 320.548 +            k = Q_col[i]; /* x[k] = xB[i] */
 320.549 +            t = type[k];
 320.550 +            if (t == SSX_UP || t == SSX_DB || t == SSX_FX)
 320.551 +            {  /* xB[i] has finite upper bound */
 320.552 +               mpq_sub(temp, bbar[i], ub[k]);
 320.553 +               mpq_div(temp, temp, aq[i]);
 320.554 +               mpq_abs(temp, temp);
 320.555 +               if (p == 0 || mpq_cmp(teta, temp) > 0)
 320.556 +               {  p = i;
 320.557 +                  p_stat = (t == SSX_FX ? SSX_NS : SSX_NU);
 320.558 +                  mpq_set(teta, temp);
 320.559 +               }
 320.560 +            }
 320.561 +         }
 320.562 +         /* if something has been chosen and the ratio test indicates
 320.563 +            exact degeneracy, the search can be finished */
 320.564 +         if (p != 0 && mpq_sgn(teta) == 0) break;
 320.565 +      }
 320.566 +      /* if xN[q] is double-bounded, check if it can reach its opposite
 320.567 +         bound before any basic variable */
 320.568 +      k = Q_col[m+q]; /* x[k] = xN[q] */
 320.569 +      if (type[k] == SSX_DB)
 320.570 +      {  mpq_sub(temp, ub[k], lb[k]);
 320.571 +         if (p == 0 || mpq_cmp(teta, temp) > 0)
 320.572 +         {  p = -1;
 320.573 +            p_stat = -1;
 320.574 +            mpq_set(teta, temp);
 320.575 +         }
 320.576 +      }
 320.577 +      ssx->p = p;
 320.578 +      ssx->p_stat = p_stat;
 320.579 +      /* if xB[p] has been chosen, determine its actual change in the
 320.580 +         adjacent basis (it has the same sign as q_dir) */
 320.581 +      if (p != 0)
 320.582 +      {  xassert(mpq_sgn(teta) >= 0);
 320.583 +         if (q_dir > 0)
 320.584 +            mpq_set(ssx->delta, teta);
 320.585 +         else
 320.586 +            mpq_neg(ssx->delta, teta);
 320.587 +      }
 320.588 +      mpq_clear(teta);
 320.589 +      mpq_clear(temp);
 320.590 +      return;
 320.591 +}
 320.592 +
 320.593 +/*----------------------------------------------------------------------
 320.594 +// ssx_update_bbar - update values of basic variables.
 320.595 +//
 320.596 +// This routine recomputes the current values of basic variables for
 320.597 +// the adjacent basis.
 320.598 +//
 320.599 +// The simplex table for the current basis is the following:
 320.600 +//
 320.601 +//    xB[i] = sum{j in 1..n} alfa[i,j] * xN[q],  i = 1,...,m
 320.602 +//
 320.603 +// therefore
 320.604 +//
 320.605 +//    delta xB[i] = alfa[i,q] * delta xN[q],  i = 1,...,m
 320.606 +//
 320.607 +// where delta xN[q] = xN.new[q] - xN[q] is the change of xN[q] in the
 320.608 +// adjacent basis, and delta xB[i] = xB.new[i] - xB[i] is the change of
 320.609 +// xB[i]. This gives formulae for recomputing values of xB[i]:
 320.610 +//
 320.611 +//    xB.new[p] = xN[q] + delta xN[q]
 320.612 +//
 320.613 +// (because xN[q] becomes xB[p] in the adjacent basis), and
 320.614 +//
 320.615 +//    xB.new[i] = xB[i] + alfa[i,q] * delta xN[q],  i != p
 320.616 +//
 320.617 +// for other basic variables. */
 320.618 +
 320.619 +void ssx_update_bbar(SSX *ssx)
 320.620 +{     int m = ssx->m;
 320.621 +      int n = ssx->n;
 320.622 +      mpq_t *bbar = ssx->bbar;
 320.623 +      mpq_t *cbar = ssx->cbar;
 320.624 +      int p = ssx->p;
 320.625 +      int q = ssx->q;
 320.626 +      mpq_t *aq = ssx->aq;
 320.627 +      int i;
 320.628 +      mpq_t temp;
 320.629 +      mpq_init(temp);
 320.630 +      xassert(1 <= q && q <= n);
 320.631 +      if (p < 0)
 320.632 +      {  /* xN[q] is double-bounded and goes to its opposite bound */
 320.633 +         /* nop */;
 320.634 +      }
 320.635 +      else
 320.636 +      {  /* xN[q] becomes xB[p] in the adjacent basis */
 320.637 +         /* xB.new[p] = xN[q] + delta xN[q] */
 320.638 +         xassert(1 <= p && p <= m);
 320.639 +         ssx_get_xNj(ssx, q, temp);
 320.640 +         mpq_add(bbar[p], temp, ssx->delta);
 320.641 +      }
 320.642 +      /* update values of other basic variables depending on xN[q] */
 320.643 +      for (i = 1; i <= m; i++)
 320.644 +      {  if (i == p) continue;
 320.645 +         /* xB.new[i] = xB[i] + alfa[i,q] * delta xN[q] */
 320.646 +         if (mpq_sgn(aq[i]) == 0) continue;
 320.647 +         mpq_mul(temp, aq[i], ssx->delta);
 320.648 +         mpq_add(bbar[i], bbar[i], temp);
 320.649 +      }
 320.650 +#if 1
 320.651 +      /* update value of the objective function */
 320.652 +      /* z.new = z + d[q] * delta xN[q] */
 320.653 +      mpq_mul(temp, cbar[q], ssx->delta);
 320.654 +      mpq_add(bbar[0], bbar[0], temp);
 320.655 +#endif
 320.656 +      mpq_clear(temp);
 320.657 +      return;
 320.658 +}
 320.659 +
 320.660 +/*----------------------------------------------------------------------
 320.661 +-- ssx_update_pi - update simplex multipliers.
 320.662 +--
 320.663 +-- This routine recomputes the vector of simplex multipliers for the
 320.664 +-- adjacent basis. */
 320.665 +
 320.666 +void ssx_update_pi(SSX *ssx)
 320.667 +{     int m = ssx->m;
 320.668 +      int n = ssx->n;
 320.669 +      mpq_t *pi = ssx->pi;
 320.670 +      mpq_t *cbar = ssx->cbar;
 320.671 +      int p = ssx->p;
 320.672 +      int q = ssx->q;
 320.673 +      mpq_t *aq = ssx->aq;
 320.674 +      mpq_t *rho = ssx->rho;
 320.675 +      int i;
 320.676 +      mpq_t new_dq, temp;
 320.677 +      mpq_init(new_dq);
 320.678 +      mpq_init(temp);
 320.679 +      xassert(1 <= p && p <= m);
 320.680 +      xassert(1 <= q && q <= n);
 320.681 +      /* compute d[q] in the adjacent basis */
 320.682 +      mpq_div(new_dq, cbar[q], aq[p]);
 320.683 +      /* update the vector of simplex multipliers */
 320.684 +      for (i = 1; i <= m; i++)
 320.685 +      {  if (mpq_sgn(rho[i]) == 0) continue;
 320.686 +         mpq_mul(temp, new_dq, rho[i]);
 320.687 +         mpq_sub(pi[i], pi[i], temp);
 320.688 +      }
 320.689 +      mpq_clear(new_dq);
 320.690 +      mpq_clear(temp);
 320.691 +      return;
 320.692 +}
 320.693 +
 320.694 +/*----------------------------------------------------------------------
 320.695 +// ssx_update_cbar - update reduced costs of non-basic variables.
 320.696 +//
 320.697 +// This routine recomputes the vector of reduced costs of non-basic
 320.698 +// variables for the adjacent basis. */
 320.699 +
 320.700 +void ssx_update_cbar(SSX *ssx)
 320.701 +{     int m = ssx->m;
 320.702 +      int n = ssx->n;
 320.703 +      mpq_t *cbar = ssx->cbar;
 320.704 +      int p = ssx->p;
 320.705 +      int q = ssx->q;
 320.706 +      mpq_t *ap = ssx->ap;
 320.707 +      int j;
 320.708 +      mpq_t temp;
 320.709 +      mpq_init(temp);
 320.710 +      xassert(1 <= p && p <= m);
 320.711 +      xassert(1 <= q && q <= n);
 320.712 +      /* compute d[q] in the adjacent basis */
 320.713 +      /* d.new[q] = d[q] / alfa[p,q] */
 320.714 +      mpq_div(cbar[q], cbar[q], ap[q]);
 320.715 +      /* update reduced costs of other non-basic variables */
 320.716 +      for (j = 1; j <= n; j++)
 320.717 +      {  if (j == q) continue;
 320.718 +         /* d.new[j] = d[j] - (alfa[p,j] / alfa[p,q]) * d[q] */
 320.719 +         if (mpq_sgn(ap[j]) == 0) continue;
 320.720 +         mpq_mul(temp, ap[j], cbar[q]);
 320.721 +         mpq_sub(cbar[j], cbar[j], temp);
 320.722 +      }
 320.723 +      mpq_clear(temp);
 320.724 +      return;
 320.725 +}
 320.726 +
 320.727 +/*----------------------------------------------------------------------
 320.728 +// ssx_change_basis - change current basis to adjacent one.
 320.729 +//
 320.730 +// This routine changes the current basis to the adjacent one swapping
 320.731 +// basic variable xB[p] and non-basic variable xN[q]. */
 320.732 +
 320.733 +void ssx_change_basis(SSX *ssx)
 320.734 +{     int m = ssx->m;
 320.735 +      int n = ssx->n;
 320.736 +      int *type = ssx->type;
 320.737 +      int *stat = ssx->stat;
 320.738 +      int *Q_row = ssx->Q_row;
 320.739 +      int *Q_col = ssx->Q_col;
 320.740 +      int p = ssx->p;
 320.741 +      int q = ssx->q;
 320.742 +      int p_stat = ssx->p_stat;
 320.743 +      int k, kp, kq;
 320.744 +      if (p < 0)
 320.745 +      {  /* special case: xN[q] goes to its opposite bound */
 320.746 +         xassert(1 <= q && q <= n);
 320.747 +         k = Q_col[m+q]; /* x[k] = xN[q] */
 320.748 +         xassert(type[k] == SSX_DB);
 320.749 +         switch (stat[k])
 320.750 +         {  case SSX_NL:
 320.751 +               stat[k] = SSX_NU;
 320.752 +               break;
 320.753 +            case SSX_NU:
 320.754 +               stat[k] = SSX_NL;
 320.755 +               break;
 320.756 +            default:
 320.757 +               xassert(stat != stat);
 320.758 +         }
 320.759 +      }
 320.760 +      else
 320.761 +      {  /* xB[p] leaves the basis, xN[q] enters the basis */
 320.762 +         xassert(1 <= p && p <= m);
 320.763 +         xassert(1 <= q && q <= n);
 320.764 +         kp = Q_col[p];   /* x[kp] = xB[p] */
 320.765 +         kq = Q_col[m+q]; /* x[kq] = xN[q] */
 320.766 +         /* check non-basic status of xB[p] which becomes xN[q] */
 320.767 +         switch (type[kp])
 320.768 +         {  case SSX_FR:
 320.769 +               xassert(p_stat == SSX_NF);
 320.770 +               break;
 320.771 +            case SSX_LO:
 320.772 +               xassert(p_stat == SSX_NL);
 320.773 +               break;
 320.774 +            case SSX_UP:
 320.775 +               xassert(p_stat == SSX_NU);
 320.776 +               break;
 320.777 +            case SSX_DB:
 320.778 +               xassert(p_stat == SSX_NL || p_stat == SSX_NU);
 320.779 +               break;
 320.780 +            case SSX_FX:
 320.781 +               xassert(p_stat == SSX_NS);
 320.782 +               break;
 320.783 +            default:
 320.784 +               xassert(type != type);
 320.785 +         }
 320.786 +         /* swap xB[p] and xN[q] */
 320.787 +         stat[kp] = (char)p_stat, stat[kq] = SSX_BS;
 320.788 +         Q_row[kp] = m+q, Q_row[kq] = p;
 320.789 +         Q_col[p] = kq, Q_col[m+q] = kp;
 320.790 +         /* update factorization of the basis matrix */
 320.791 +         if (bfx_update(ssx->binv, p))
 320.792 +         {  if (ssx_factorize(ssx))
 320.793 +               xassert(("Internal error: basis matrix is singular", 0));
 320.794 +         }
 320.795 +      }
 320.796 +      return;
 320.797 +}
 320.798 +
 320.799 +/*----------------------------------------------------------------------
 320.800 +// ssx_delete - delete simplex solver workspace.
 320.801 +//
 320.802 +// This routine deletes the simplex solver workspace freeing all the
 320.803 +// memory allocated to this object. */
 320.804 +
 320.805 +void ssx_delete(SSX *ssx)
 320.806 +{     int m = ssx->m;
 320.807 +      int n = ssx->n;
 320.808 +      int nnz = ssx->A_ptr[n+1]-1;
 320.809 +      int i, j, k;
 320.810 +      xfree(ssx->type);
 320.811 +      for (k = 1; k <= m+n; k++) mpq_clear(ssx->lb[k]);
 320.812 +      xfree(ssx->lb);
 320.813 +      for (k = 1; k <= m+n; k++) mpq_clear(ssx->ub[k]);
 320.814 +      xfree(ssx->ub);
 320.815 +      for (k = 0; k <= m+n; k++) mpq_clear(ssx->coef[k]);
 320.816 +      xfree(ssx->coef);
 320.817 +      xfree(ssx->A_ptr);
 320.818 +      xfree(ssx->A_ind);
 320.819 +      for (k = 1; k <= nnz; k++) mpq_clear(ssx->A_val[k]);
 320.820 +      xfree(ssx->A_val);
 320.821 +      xfree(ssx->stat);
 320.822 +      xfree(ssx->Q_row);
 320.823 +      xfree(ssx->Q_col);
 320.824 +      bfx_delete_binv(ssx->binv);
 320.825 +      for (i = 0; i <= m; i++) mpq_clear(ssx->bbar[i]);
 320.826 +      xfree(ssx->bbar);
 320.827 +      for (i = 1; i <= m; i++) mpq_clear(ssx->pi[i]);
 320.828 +      xfree(ssx->pi);
 320.829 +      for (j = 1; j <= n; j++) mpq_clear(ssx->cbar[j]);
 320.830 +      xfree(ssx->cbar);
 320.831 +      for (i = 1; i <= m; i++) mpq_clear(ssx->rho[i]);
 320.832 +      xfree(ssx->rho);
 320.833 +      for (j = 1; j <= n; j++) mpq_clear(ssx->ap[j]);
 320.834 +      xfree(ssx->ap);
 320.835 +      for (i = 1; i <= m; i++) mpq_clear(ssx->aq[i]);
 320.836 +      xfree(ssx->aq);
 320.837 +      mpq_clear(ssx->delta);
 320.838 +      xfree(ssx);
 320.839 +      return;
 320.840 +}
 320.841 +
 320.842 +/* eof */
   321.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
   321.2 +++ b/deps/glpk/src/glpssx02.c	Sun Nov 06 20:59:10 2011 +0100
   321.3 @@ -0,0 +1,479 @@
   321.4 +/* glpssx02.c */
   321.5 +
   321.6 +/***********************************************************************
   321.7 +*  This code is part of GLPK (GNU Linear Programming Kit).
   321.8 +*
   321.9 +*  Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008,
  321.10 +*  2009, 2010, 2011 Andrew Makhorin, Department for Applied Informatics,
  321.11 +*  Moscow Aviation Institute, Moscow, Russia. All rights reserved.
  321.12 +*  E-mail: <mao@gnu.org>.
  321.13 +*
  321.14 +*  GLPK is free software: you can redistribute it and/or modify it
  321.15 +*  under the terms of the GNU General Public License as published by
  321.16 +*  the Free Software Foundation, either version 3 of the License, or
  321.17 +*  (at your option) any later version.
  321.18 +*
  321.19 +*  GLPK is distributed in the hope that it will be useful, but WITHOUT
  321.20 +*  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
  321.21 +*  or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
  321.22 +*  License for more details.
  321.23 +*
  321.24 +*  You should have received a copy of the GNU General Public License
  321.25 +*  along with GLPK. If not, see <http://www.gnu.org/licenses/>.
  321.26 +***********************************************************************/
  321.27 +
  321.28 +#include "glpenv.h"
  321.29 +#include "glpssx.h"
  321.30 +
  321.31 +static void show_progress(SSX *ssx, int phase)
  321.32 +{     /* this auxiliary routine displays information about progress of
  321.33 +         the search */
  321.34 +      int i, def = 0;
  321.35 +      for (i = 1; i <= ssx->m; i++)
  321.36 +         if (ssx->type[ssx->Q_col[i]] == SSX_FX) def++;
  321.37 +      xprintf("%s%6d:   %s = %22.15g   (%d)\n", phase == 1 ? " " : "*",
  321.38 +         ssx->it_cnt, phase == 1 ? "infsum" : "objval",
  321.39 +         mpq_get_d(ssx->bbar[0]), def);
  321.40 +#if 0
  321.41 +      ssx->tm_lag = utime();
  321.42 +#else
  321.43 +      ssx->tm_lag = xtime();
  321.44 +#endif
  321.45 +      return;
  321.46 +}
  321.47 +
  321.48 +/*----------------------------------------------------------------------
  321.49 +// ssx_phase_I - find primal feasible solution.
  321.50 +//
  321.51 +// This routine implements phase I of the primal simplex method.
  321.52 +//
  321.53 +// On exit the routine returns one of the following codes:
  321.54 +//
  321.55 +// 0 - feasible solution found;
  321.56 +// 1 - problem has no feasible solution;
  321.57 +// 2 - iterations limit exceeded;
  321.58 +// 3 - time limit exceeded.
  321.59 +----------------------------------------------------------------------*/
  321.60 +
  321.61 +int ssx_phase_I(SSX *ssx)
  321.62 +{     int m = ssx->m;
  321.63 +      int n = ssx->n;
  321.64 +      int *type = ssx->type;
  321.65 +      mpq_t *lb = ssx->lb;
  321.66 +      mpq_t *ub = ssx->ub;
  321.67 +      mpq_t *coef = ssx->coef;
  321.68 +      int *A_ptr = ssx->A_ptr;
  321.69 +      int *A_ind = ssx->A_ind;
  321.70 +      mpq_t *A_val = ssx->A_val;
  321.71 +      int *Q_col = ssx->Q_col;
  321.72 +      mpq_t *bbar = ssx->bbar;
  321.73 +      mpq_t *pi = ssx->pi;
  321.74 +      mpq_t *cbar = ssx->cbar;
  321.75 +      int *orig_type, orig_dir;
  321.76 +      mpq_t *orig_lb, *orig_ub, *orig_coef;
  321.77 +      int i, k, ret;
  321.78 +      /* save components of the original LP problem, which are changed
  321.79 +         by the routine */
  321.80 +      orig_type = xcalloc(1+m+n, sizeof(int));
  321.81 +      orig_lb = xcalloc(1+m+n, sizeof(mpq_t));
  321.82 +      orig_ub = xcalloc(1+m+n, sizeof(mpq_t));
  321.83 +      orig_coef = xcalloc(1+m+n, sizeof(mpq_t));
  321.84 +      for (k = 1; k <= m+n; k++)
  321.85 +      {  orig_type[k] = type[k];
  321.86 +         mpq_init(orig_lb[k]);
  321.87 +         mpq_set(orig_lb[k], lb[k]);
  321.88 +         mpq_init(orig_ub[k]);
  321.89 +         mpq_set(orig_ub[k], ub[k]);
  321.90 +      }
  321.91 +      orig_dir = ssx->dir;
  321.92 +      for (k = 0; k <= m+n; k++)
  321.93 +      {  mpq_init(orig_coef[k]);
  321.94 +         mpq_set(orig_coef[k], coef[k]);
  321.95 +      }
  321.96 +      /* build an artificial basic solution, which is primal feasible,
  321.97 +         and also build an auxiliary objective function to minimize the
  321.98 +         sum of infeasibilities for the original problem */
  321.99 +      ssx->dir = SSX_MIN;
 321.100 +      for (k = 0; k <= m+n; k++) mpq_set_si(coef[k], 0, 1);
 321.101 +      mpq_set_si(bbar[0], 0, 1);
 321.102 +      for (i = 1; i <= m; i++)
 321.103 +      {  int t;
 321.104 +         k = Q_col[i]; /* x[k] = xB[i] */
 321.105 +         t = type[k];
 321.106 +         if (t == SSX_LO || t == SSX_DB || t == SSX_FX)
 321.107 +         {  /* in the original problem x[k] has lower bound */
 321.108 +            if (mpq_cmp(bbar[i], lb[k]) < 0)
 321.109 +            {  /* which is violated */
 321.110 +               type[k] = SSX_UP;
 321.111 +               mpq_set(ub[k], lb[k]);
 321.112 +               mpq_set_si(lb[k], 0, 1);
 321.113 +               mpq_set_si(coef[k], -1, 1);
 321.114 +               mpq_add(bbar[0], bbar[0], ub[k]);
 321.115 +               mpq_sub(bbar[0], bbar[0], bbar[i]);
 321.116 +            }
 321.117 +         }
 321.118 +         if (t == SSX_UP || t == SSX_DB || t == SSX_FX)
 321.119 +         {  /* in the original problem x[k] has upper bound */
 321.120 +            if (mpq_cmp(bbar[i], ub[k]) > 0)
 321.121 +            {  /* which is violated */
 321.122 +               type[k] = SSX_LO;
 321.123 +               mpq_set(lb[k], ub[k]);
 321.124 +               mpq_set_si(ub[k], 0, 1);
 321.125 +               mpq_set_si(coef[k], +1, 1);
 321.126 +               mpq_add(bbar[0], bbar[0], bbar[i]);
 321.127 +               mpq_sub(bbar[0], bbar[0], lb[k]);
 321.128 +            }
 321.129 +         }
 321.130 +      }
 321.131 +      /* now the initial basic solution should be primal feasible due
 321.132 +         to changes of bounds of some basic variables, which turned to
 321.133 +         implicit artifical variables */
 321.134 +      /* compute simplex multipliers and reduced costs */
 321.135 +      ssx_eval_pi(ssx);
 321.136 +      ssx_eval_cbar(ssx);
 321.137 +      /* display initial progress of the search */
 321.138 +      show_progress(ssx, 1);
 321.139 +      /* main loop starts here */
 321.140 +      for (;;)
 321.141 +      {  /* display current progress of the search */
 321.142 +#if 0
 321.143 +         if (utime() - ssx->tm_lag >= ssx->out_frq - 0.001)
 321.144 +#else
 321.145 +         if (xdifftime(xtime(), ssx->tm_lag) >= ssx->out_frq - 0.001)
 321.146 +#endif
 321.147 +            show_progress(ssx, 1);
 321.148 +         /* we do not need to wait until all artificial variables have
 321.149 +            left the basis */
 321.150 +         if (mpq_sgn(bbar[0]) == 0)
 321.151 +         {  /* the sum of infeasibilities is zero, therefore the current
 321.152 +               solution is primal feasible for the original problem */
 321.153 +            ret = 0;
 321.154 +            break;
 321.155 +         }
 321.156 +         /* check if the iterations limit has been exhausted */
 321.157 +         if (ssx->it_lim == 0)
 321.158 +         {  ret = 2;
 321.159 +            break;
 321.160 +         }
 321.161 +         /* check if the time limit has been exhausted */
 321.162 +#if 0
 321.163 +         if (ssx->tm_lim >= 0.0 && ssx->tm_lim <= utime() - ssx->tm_beg)
 321.164 +#else
 321.165 +         if (ssx->tm_lim >= 0.0 &&
 321.166 +             ssx->tm_lim <= xdifftime(xtime(), ssx->tm_beg))
 321.167 +#endif
 321.168 +         {  ret = 3;
 321.169 +            break;
 321.170 +         }
 321.171 +         /* choose non-basic variable xN[q] */
 321.172 +         ssx_chuzc(ssx);
 321.173 +         /* if xN[q] cannot be chosen, the sum of infeasibilities is
 321.174 +            minimal but non-zero; therefore the original problem has no
 321.175 +            primal feasible solution */
 321.176 +         if (ssx->q == 0)
 321.177 +         {  ret = 1;
 321.178 +            break;
 321.179 +         }
 321.180 +         /* compute q-th column of the simplex table */
 321.181 +         ssx_eval_col(ssx);
 321.182 +         /* choose basic variable xB[p] */
 321.183 +         ssx_chuzr(ssx);
 321.184 +         /* the sum of infeasibilities cannot be negative, therefore
 321.185 +            the auxiliary lp problem cannot have unbounded solution */
 321.186 +         xassert(ssx->p != 0);
 321.187 +         /* update values of basic variables */
 321.188 +         ssx_update_bbar(ssx);
 321.189 +         if (ssx->p > 0)
 321.190 +         {  /* compute p-th row of the inverse inv(B) */
 321.191 +            ssx_eval_rho(ssx);
 321.192 +            /* compute p-th row of the simplex table */
 321.193 +            ssx_eval_row(ssx);
 321.194 +            xassert(mpq_cmp(ssx->aq[ssx->p], ssx->ap[ssx->q]) == 0);
 321.195 +            /* update simplex multipliers */
 321.196 +            ssx_update_pi(ssx);
 321.197 +            /* update reduced costs of non-basic variables */
 321.198 +            ssx_update_cbar(ssx);
 321.199 +         }
 321.200 +         /* xB[p] is leaving the basis; if it is implicit artificial
 321.201 +            variable, the corresponding residual vanishes; therefore
 321.202 +            bounds of this variable should be restored to the original
 321.203 +            values */
 321.204 +         if (ssx->p > 0)
 321.205 +         {  k = Q_col[ssx->p]; /* x[k] = xB[p] */
 321.206 +            if (type[k] != orig_type[k])
 321.207 +            {  /* x[k] is implicit artificial variable */
 321.208 +               type[k] = orig_type[k];
 321.209 +               mpq_set(lb[k], orig_lb[k]);
 321.210 +               mpq_set(ub[k], orig_ub[k]);
 321.211 +               xassert(ssx->p_stat == SSX_NL || ssx->p_stat == SSX_NU);
 321.212 +               ssx->p_stat = (ssx->p_stat == SSX_NL ? SSX_NU : SSX_NL);
 321.213 +               if (type[k] == SSX_FX) ssx->p_stat = SSX_NS;
 321.214 +               /* nullify the objective coefficient at x[k] */
 321.215 +               mpq_set_si(coef[k], 0, 1);
 321.216 +               /* since coef[k] has been changed, we need to compute
 321.217 +                  new reduced cost of x[k], which it will have in the
 321.218 +                  adjacent basis */
 321.219 +               /* the formula d[j] = cN[j] - pi' * N[j] is used (note
 321.220 +                  that the vector pi is not changed, because it depends
 321.221 +                  on objective coefficients at basic variables, but in
 321.222 +                  the adjacent basis, for which the vector pi has been
 321.223 +                  just recomputed, x[k] is non-basic) */
 321.224 +               if (k <= m)
 321.225 +               {  /* x[k] is auxiliary variable */
 321.226 +                  mpq_neg(cbar[ssx->q], pi[k]);
 321.227 +               }
 321.228 +               else
 321.229 +               {  /* x[k] is structural variable */
 321.230 +                  int ptr;
 321.231 +                  mpq_t temp;
 321.232 +                  mpq_init(temp);
 321.233 +                  mpq_set_si(cbar[ssx->q], 0, 1);
 321.234 +                  for (ptr = A_ptr[k-m]; ptr < A_ptr[k-m+1]; ptr++)
 321.235 +                  {  mpq_mul(temp, pi[A_ind[ptr]], A_val[ptr]);
 321.236 +                     mpq_add(cbar[ssx->q], cbar[ssx->q], temp);
 321.237 +                  }
 321.238 +                  mpq_clear(temp);
 321.239 +               }
 321.240 +            }
 321.241 +         }
 321.242 +         /* jump to the adjacent vertex of the polyhedron */
 321.243 +         ssx_change_basis(ssx);
 321.244 +         /* one simplex iteration has been performed */
 321.245 +         if (ssx->it_lim > 0) ssx->it_lim--;
 321.246 +         ssx->it_cnt++;
 321.247 +      }
 321.248 +      /* display final progress of the search */
 321.249 +      show_progress(ssx, 1);
 321.250 +      /* restore components of the original problem, which were changed
 321.251 +         by the routine */
 321.252 +      for (k = 1; k <= m+n; k++)
 321.253 +      {  type[k] = orig_type[k];
 321.254 +         mpq_set(lb[k], orig_lb[k]);
 321.255 +         mpq_clear(orig_lb[k]);
 321.256 +         mpq_set(ub[k], orig_ub[k]);
 321.257 +         mpq_clear(orig_ub[k]);
 321.258 +      }
 321.259 +      ssx->dir = orig_dir;
 321.260 +      for (k = 0; k <= m+n; k++)
 321.261 +      {  mpq_set(coef[k], orig_coef[k]);
 321.262 +         mpq_clear(orig_coef[k]);
 321.263 +      }
 321.264 +      xfree(orig_type);
 321.265 +      xfree(orig_lb);
 321.266 +      xfree(orig_ub);
 321.267 +      xfree(orig_coef);
 321.268 +      /* return to the calling program */
 321.269 +      return ret;
 321.270 +}
 321.271 +
 321.272 +/*----------------------------------------------------------------------
 321.273 +// ssx_phase_II - find optimal solution.
 321.274 +//
 321.275 +// This routine implements phase II of the primal simplex method.
 321.276 +//
 321.277 +// On exit the routine returns one of the following codes:
 321.278 +//
 321.279 +// 0 - optimal solution found;
 321.280 +// 1 - problem has unbounded solution;
 321.281 +// 2 - iterations limit exceeded;
 321.282 +// 3 - time limit exceeded.
 321.283 +----------------------------------------------------------------------*/
 321.284 +
 321.285 +int ssx_phase_II(SSX *ssx)
 321.286 +{     int ret;
 321.287 +      /* display initial progress of the search */
 321.288 +      show_progress(ssx, 2);
 321.289 +      /* main loop starts here */
 321.290 +      for (;;)
 321.291 +      {  /* display current progress of the search */
 321.292 +#if 0
 321.293 +         if (utime() - ssx->tm_lag >= ssx->out_frq - 0.001)
 321.294 +#else
 321.295 +         if (xdifftime(xtime(), ssx->tm_lag) >= ssx->out_frq - 0.001)
 321.296 +#endif
 321.297 +            show_progress(ssx, 2);
 321.298 +         /* check if the iterations limit has been exhausted */
 321.299 +         if (ssx->it_lim == 0)
 321.300 +         {  ret = 2;
 321.301 +            break;
 321.302 +         }
 321.303 +         /* check if the time limit has been exhausted */
 321.304 +#if 0
 321.305 +         if (ssx->tm_lim >= 0.0 && ssx->tm_lim <= utime() - ssx->tm_beg)
 321.306 +#else
 321.307 +         if (ssx->tm_lim >= 0.0 &&
 321.308 +             ssx->tm_lim <= xdifftime(xtime(), ssx->tm_beg))
 321.309 +#endif
 321.310 +         {  ret = 3;
 321.311 +            break;
 321.312 +         }
 321.313 +         /* choose non-basic variable xN[q] */
 321.314 +         ssx_chuzc(ssx);
 321.315 +         /* if xN[q] cannot be chosen, the current basic solution is
 321.316 +            dual feasible and therefore optimal */
 321.317 +         if (ssx->q == 0)
 321.318 +         {  ret = 0;
 321.319 +            break;
 321.320 +         }
 321.321 +         /* compute q-th column of the simplex table */
 321.322 +         ssx_eval_col(ssx);
 321.323 +         /* choose basic variable xB[p] */
 321.324 +         ssx_chuzr(ssx);
 321.325 +         /* if xB[p] cannot be chosen, the problem has no dual feasible
 321.326 +            solution (i.e. unbounded) */
 321.327 +         if (ssx->p == 0)
 321.328 +         {  ret = 1;
 321.329 +            break;
 321.330 +         }
 321.331 +         /* update values of basic variables */
 321.332 +         ssx_update_bbar(ssx);
 321.333 +         if (ssx->p > 0)
 321.334 +         {  /* compute p-th row of the inverse inv(B) */
 321.335 +            ssx_eval_rho(ssx);
 321.336 +            /* compute p-th row of the simplex table */
 321.337 +            ssx_eval_row(ssx);
 321.338 +            xassert(mpq_cmp(ssx->aq[ssx->p], ssx->ap[ssx->q]) == 0);
 321.339 +#if 0
 321.340 +            /* update simplex multipliers */
 321.341 +            ssx_update_pi(ssx);
 321.342 +#endif
 321.343 +            /* update reduced costs of non-basic variables */
 321.344 +            ssx_update_cbar(ssx);
 321.345 +         }
 321.346 +         /* jump to the adjacent vertex of the polyhedron */
 321.347 +         ssx_change_basis(ssx);
 321.348 +         /* one simplex iteration has been performed */
 321.349 +         if (ssx->it_lim > 0) ssx->it_lim--;
 321.350 +         ssx->it_cnt++;
 321.351 +      }
 321.352 +      /* display final progress of the search */
 321.353 +      show_progress(ssx, 2);
 321.354 +      /* return to the calling program */
 321.355 +      return ret;
 321.356 +}
 321.357 +
 321.358 +/*----------------------------------------------------------------------
 321.359 +// ssx_driver - base driver to exact simplex method.
 321.360 +//
 321.361 +// This routine is a base driver to a version of the primal simplex
 321.362 +// method using exact (bignum) arithmetic.
 321.363 +//
 321.364 +// On exit the routine returns one of the following codes:
 321.365 +//
 321.366 +// 0 - optimal solution found;
 321.367 +// 1 - problem has no feasible solution;
 321.368 +// 2 - problem has unbounded solution;
 321.369 +// 3 - iterations limit exceeded (phase I);
 321.370 +// 4 - iterations limit exceeded (phase II);
 321.371 +// 5 - time limit exceeded (phase I);
 321.372 +// 6 - time limit exceeded (phase II);
 321.373 +// 7 - initial basis matrix is exactly singular.
 321.374 +----------------------------------------------------------------------*/
 321.375 +
 321.376 +int ssx_driver(SSX *ssx)
 321.377 +{     int m = ssx->m;
 321.378 +      int *type = ssx->type;
 321.379 +      mpq_t *lb = ssx->lb;
 321.380 +      mpq_t *ub = ssx->ub;
 321.381 +      int *Q_col = ssx->Q_col;
 321.382 +      mpq_t *bbar = ssx->bbar;
 321.383 +      int i, k, ret;
 321.384 +      ssx->tm_beg = xtime();
 321.385 +      /* factorize the initial basis matrix */
 321.386 +      if (ssx_factorize(ssx))
 321.387 +      {  xprintf("Initial basis matrix is singular\n");
 321.388 +         ret = 7;
 321.389 +         goto done;
 321.390 +      }
 321.391 +      /* compute values of basic variables */
 321.392 +      ssx_eval_bbar(ssx);
 321.393 +      /* check if the initial basic solution is primal feasible */
 321.394 +      for (i = 1; i <= m; i++)
 321.395 +      {  int t;
 321.396 +         k = Q_col[i]; /* x[k] = xB[i] */
 321.397 +         t = type[k];
 321.398 +         if (t == SSX_LO || t == SSX_DB || t == SSX_FX)
 321.399 +         {  /* x[k] has lower bound */
 321.400 +            if (mpq_cmp(bbar[i], lb[k]) < 0)
 321.401 +            {  /* which is violated */
 321.402 +               break;
 321.403 +            }
 321.404 +         }
 321.405 +         if (t == SSX_UP || t == SSX_DB || t == SSX_FX)
 321.406 +         {  /* x[k] has upper bound */
 321.407 +            if (mpq_cmp(bbar[i], ub[k]) > 0)
 321.408 +            {  /* which is violated */
 321.409 +               break;
 321.410 +            }
 321.411 +         }
 321.412 +      }
 321.413 +      if (i > m)
 321.414 +      {  /* no basic variable violates its bounds */
 321.415 +         ret = 0;
 321.416 +         goto skip;
 321.417 +      }
 321.418 +      /* phase I: find primal feasible solution */
 321.419 +      ret = ssx_phase_I(ssx);
 321.420 +      switch (ret)
 321.421 +      {  case 0:
 321.422 +            ret = 0;
 321.423 +            break;
 321.424 +         case 1:
 321.425 +            xprintf("PROBLEM HAS NO FEASIBLE SOLUTION\n");
 321.426 +            ret = 1;
 321.427 +            break;
 321.428 +         case 2:
 321.429 +            xprintf("ITERATIONS LIMIT EXCEEDED; SEARCH TERMINATED\n");
 321.430 +            ret = 3;
 321.431 +            break;
 321.432 +         case 3:
 321.433 +            xprintf("TIME LIMIT EXCEEDED; SEARCH TERMINATED\n");
 321.434 +            ret = 5;
 321.435 +            break;
 321.436 +         default:
 321.437 +            xassert(ret != ret);
 321.438 +      }
 321.439 +      /* compute values of basic variables (actually only the objective
 321.440 +         value needs to be computed) */
 321.441 +      ssx_eval_bbar(ssx);
 321.442 +skip: /* compute simplex multipliers */
 321.443 +      ssx_eval_pi(ssx);
 321.444 +      /* compute reduced costs of non-basic variables */
 321.445 +      ssx_eval_cbar(ssx);
 321.446 +      /* if phase I failed, do not start phase II */
 321.447 +      if (ret != 0) goto done;
 321.448 +      /* phase II: find optimal solution */
 321.449 +      ret = ssx_phase_II(ssx);
 321.450 +      switch (ret)
 321.451 +      {  case 0:
 321.452 +            xprintf("OPTIMAL SOLUTION FOUND\n");
 321.453 +            ret = 0;
 321.454 +            break;
 321.455 +         case 1:
 321.456 +            xprintf("PROBLEM HAS UNBOUNDED SOLUTION\n");
 321.457 +            ret = 2;
 321.458 +            break;
 321.459 +         case 2:
 321.460 +            xprintf("ITERATIONS LIMIT EXCEEDED; SEARCH TERMINATED\n");
 321.461 +            ret = 4;
 321.462 +            break;
 321.463 +         case 3:
 321.464 +            xprintf("TIME LIMIT EXCEEDED; SEARCH TERMINATED\n");
 321.465 +            ret = 6;
 321.466 +            break;
 321.467 +         default:
 321.468 +            xassert(ret != ret);
 321.469 +      }
 321.470 +done: /* decrease the time limit by the spent amount of time */
 321.471 +      if (ssx->tm_lim >= 0.0)
 321.472 +#if 0
 321.473 +      {  ssx->tm_lim -= utime() - ssx->tm_beg;
 321.474 +#else
 321.475 +      {  ssx->tm_lim -= xdifftime(xtime(), ssx->tm_beg);
 321.476 +#endif
 321.477 +         if (ssx->tm_lim < 0.0) ssx->tm_lim = 0.0;
 321.478 +      }
 321.479 +      return ret;
 321.480 +}
 321.481 +
 321.482 +/* eof */
   322.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
   322.2 +++ b/deps/glpk/src/glpstd.h	Sun Nov 06 20:59:10 2011 +0100
   322.3 @@ -0,0 +1,43 @@
   322.4 +/* glpstd.h (standard C headers) */
   322.5 +
   322.6 +/***********************************************************************
   322.7 +*  This code is part of GLPK (GNU Linear Programming Kit).
   322.8 +*
   322.9 +*  Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008,
  322.10 +*  2009, 2010, 2011 Andrew Makhorin, Department for Applied Informatics,
  322.11 +*  Moscow Aviation Institute, Moscow, Russia. All rights reserved.
  322.12 +*  E-mail: <mao@gnu.org>.
  322.13 +*
  322.14 +*  GLPK is free software: you can redistribute it and/or modify it
  322.15 +*  under the terms of the GNU General Public License as published by
  322.16 +*  the Free Software Foundation, either version 3 of the License, or
  322.17 +*  (at your option) any later version.
  322.18 +*
  322.19 +*  GLPK is distributed in the hope that it will be useful, but WITHOUT
  322.20 +*  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
  322.21 +*  or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
  322.22 +*  License for more details.
  322.23 +*
  322.24 +*  You should have received a copy of the GNU General Public License
  322.25 +*  along with GLPK. If not, see <http://www.gnu.org/licenses/>.
  322.26 +***********************************************************************/
  322.27 +
  322.28 +#ifndef GLPSTD_H
  322.29 +#define GLPSTD_H
  322.30 +
  322.31 +#include <ctype.h>
  322.32 +#include <errno.h>
  322.33 +#include <float.h>
  322.34 +#include <limits.h>
  322.35 +#include <math.h>
  322.36 +#include <setjmp.h>
  322.37 +#include <stdarg.h>
  322.38 +#include <stddef.h>
  322.39 +#include <stdio.h>
  322.40 +#include <stdlib.h>
  322.41 +#include <string.h>
  322.42 +#include <time.h>
  322.43 +
  322.44 +#endif
  322.45 +
  322.46 +/* eof */
   323.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
   323.2 +++ b/deps/glpk/src/glptsp.c	Sun Nov 06 20:59:10 2011 +0100
   323.3 @@ -0,0 +1,667 @@
   323.4 +/* glptsp.c */
   323.5 +
   323.6 +/***********************************************************************
   323.7 +*  This code is part of GLPK (GNU Linear Programming Kit).
   323.8 +*
   323.9 +*  Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008,
  323.10 +*  2009, 2010, 2011 Andrew Makhorin, Department for Applied Informatics,
  323.11 +*  Moscow Aviation Institute, Moscow, Russia. All rights reserved.
  323.12 +*  E-mail: <mao@gnu.org>.
  323.13 +*
  323.14 +*  GLPK is free software: you can redistribute it and/or modify it
  323.15 +*  under the terms of the GNU General Public License as published by
  323.16 +*  the Free Software Foundation, either version 3 of the License, or
  323.17 +*  (at your option) any later version.
  323.18 +*
  323.19 +*  GLPK is distributed in the hope that it will be useful, but WITHOUT
  323.20 +*  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
  323.21 +*  or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
  323.22 +*  License for more details.
  323.23 +*
  323.24 +*  You should have received a copy of the GNU General Public License
  323.25 +*  along with GLPK. If not, see <http://www.gnu.org/licenses/>.
  323.26 +***********************************************************************/
  323.27 +
  323.28 +#define _GLPSTD_ERRNO
  323.29 +#define _GLPSTD_STDIO
  323.30 +#include "glpenv.h"
  323.31 +#include "glptsp.h"
  323.32 +#define xfault xerror
  323.33 +
  323.34 +/*----------------------------------------------------------------------
  323.35 +-- tsp_read_data - read TSP instance data.
  323.36 +--
  323.37 +-- *Synopsis*
  323.38 +--
  323.39 +-- #include "glptsp.h"
  323.40 +-- TSP *tsp_read_data(char *fname);
  323.41 +--
  323.42 +-- *Description*
  323.43 +--
  323.44 +-- The routine tsp_read_data reads a TSP (or related problem) instance
  323.45 +-- data from the text file, whose name is the character string fname.
  323.46 +--
  323.47 +-- For detailed description of the format recognized by the routine see
  323.48 +-- the report: G.Reinelt, TSPLIB 95.
  323.49 +--
  323.50 +-- *Returns*
  323.51 +--
  323.52 +-- If no error occurred, the routine tsp_read_data returns a pointer to
  323.53 +-- the TSP instance data block, which contains loaded data. In the case
  323.54 +-- of error the routine prints an error message and returns NULL. */
  323.55 +
  323.56 +struct dsa
  323.57 +{     /* dynamic storage area used by the routine tsp_read_data */
  323.58 +      char *fname;
  323.59 +      /* name of the input text file */
  323.60 +      FILE *fp;
  323.61 +      /* stream assigned to the input text file */
  323.62 +      int seqn;
  323.63 +      /* line sequential number */
  323.64 +      int c;
  323.65 +      /* current character */
  323.66 +      char token[255+1];
  323.67 +      /* current token */
  323.68 +};
  323.69 +
  323.70 +static int get_char(struct dsa *dsa)
  323.71 +{     dsa->c = fgetc(dsa->fp);
  323.72 +      if (ferror(dsa->fp))
  323.73 +      {  xprintf("%s:%d: read error - %s\n",
  323.74 +            dsa->fname, dsa->seqn, strerror(errno));
  323.75 +         return 1;
  323.76 +      }
  323.77 +      if (feof(dsa->fp))
  323.78 +         dsa->c = EOF;
  323.79 +      else if (dsa->c == '\n')
  323.80 +         dsa->seqn++;
  323.81 +      else if (isspace(dsa->c))
  323.82 +         dsa->c = ' ';
  323.83 +      else if (iscntrl(dsa->c))
  323.84 +      {  xprintf("%s:%d: invalid control character 0x%02X\n",
  323.85 +            dsa->fname, dsa->seqn, dsa->c);
  323.86 +         return 1;
  323.87 +      }
  323.88 +      return 0;
  323.89 +}
  323.90 +
  323.91 +static int skip_spaces(struct dsa *dsa, int across)
  323.92 +{     while (dsa->c == ' ' || (across && dsa->c == '\n'))
  323.93 +         if (get_char(dsa)) return 1;
  323.94 +      return 0;
  323.95 +}
  323.96 +
  323.97 +static int scan_keyword(struct dsa *dsa)
  323.98 +{     int len = 0;
  323.99 +      if (skip_spaces(dsa, 0)) return 1;
 323.100 +      dsa->token[0] = '\0';
 323.101 +      while (isalnum(dsa->c) || dsa->c == '_')
 323.102 +      {  if (len == 31)
 323.103 +         {  xprintf("%s:%d: keyword `%s...' too long\n", dsa->fname,
 323.104 +               dsa->seqn, dsa->token);
 323.105 +            return 1;
 323.106 +         }
 323.107 +         dsa->token[len++] = (char)dsa->c, dsa->token[len] = '\0';
 323.108 +         if (get_char(dsa)) return 1;
 323.109 +      }
 323.110 +      if (len == 0)
 323.111 +      {  xprintf("%s:%d: missing keyword\n", dsa->fname, dsa->seqn);
 323.112 +         return 1;
 323.113 +      }
 323.114 +      return 0;
 323.115 +}
 323.116 +
 323.117 +static int check_colon(struct dsa *dsa)
 323.118 +{     if (skip_spaces(dsa, 0)) return 1;
 323.119 +      if (dsa->c != ':')
 323.120 +      {  xprintf("%s:%d: missing colon after `%s'\n", dsa->fname,
 323.121 +            dsa->seqn, dsa->token);
 323.122 +         return 1;
 323.123 +      }
 323.124 +      if (get_char(dsa)) return 1;
 323.125 +      return 0;
 323.126 +}
 323.127 +
 323.128 +static int scan_token(struct dsa *dsa, int across)
 323.129 +{     int len = 0;
 323.130 +      if (skip_spaces(dsa, across)) return 1;
 323.131 +      dsa->token[0] = '\0';
 323.132 +      while (!(dsa->c == EOF || dsa->c == '\n' || dsa->c == ' '))
 323.133 +      {  if (len == 255)
 323.134 +         {  dsa->token[31] = '\0';
 323.135 +            xprintf("%s:%d: token `%s...' too long\n", dsa->fname,
 323.136 +               dsa->seqn, dsa->token);
 323.137 +            return 1;
 323.138 +         }
 323.139 +         dsa->token[len++] = (char)dsa->c, dsa->token[len] = '\0';
 323.140 +         if (get_char(dsa)) return 1;
 323.141 +      }
 323.142 +      return 0;
 323.143 +}
 323.144 +
 323.145 +static int check_newline(struct dsa *dsa)
 323.146 +{     if (skip_spaces(dsa, 0)) return 1;
 323.147 +      if (!(dsa->c == EOF || dsa->c == '\n'))
 323.148 +      {  xprintf("%s:%d: extra symbols detected\n", dsa->fname,
 323.149 +            dsa->seqn);
 323.150 +         return 1;
 323.151 +      }
 323.152 +      if (get_char(dsa)) return 1;
 323.153 +      return 0;
 323.154 +}
 323.155 +
 323.156 +static int scan_comment(struct dsa *dsa)
 323.157 +{     int len = 0;
 323.158 +      if (skip_spaces(dsa, 0)) return 1;
 323.159 +      dsa->token[0] = '\0';
 323.160 +      while (!(dsa->c == EOF || dsa->c == '\n'))
 323.161 +      {  if (len == 255)
 323.162 +         {  xprintf("%s:%d: comment too long\n", dsa->fname, dsa->seqn)
 323.163 +               ;
 323.164 +            return 1;
 323.165 +         }
 323.166 +         dsa->token[len++] = (char)dsa->c, dsa->token[len] = '\0';
 323.167 +         if (get_char(dsa)) return 1;
 323.168 +      }
 323.169 +      return 0;
 323.170 +}
 323.171 +
 323.172 +static int scan_integer(struct dsa *dsa, int across, int *val)
 323.173 +{     if (scan_token(dsa, across)) return 1;
 323.174 +      if (strlen(dsa->token) == 0)
 323.175 +      {  xprintf("%s:%d: missing integer\n", dsa->fname, dsa->seqn);
 323.176 +         return 1;
 323.177 +      }
 323.178 +      if (str2int(dsa->token, val))
 323.179 +      {  xprintf("%s:%d: integer `%s' invalid\n", dsa->fname, dsa->seqn
 323.180 +            , dsa->token);
 323.181 +         return 1;
 323.182 +      }
 323.183 +      return 0;
 323.184 +}
 323.185 +
 323.186 +static int scan_number(struct dsa *dsa, int across, double *val)
 323.187 +{     if (scan_token(dsa, across)) return 1;
 323.188 +      if (strlen(dsa->token) == 0)
 323.189 +      {  xprintf("%s:%d: missing number\n", dsa->fname, dsa->seqn);
 323.190 +         return 1;
 323.191 +      }
 323.192 +      if (str2num(dsa->token, val))
 323.193 +      {  xprintf("%s:%d: number `%s' invalid\n", dsa->fname, dsa->seqn,
 323.194 +            dsa->token);
 323.195 +         return 1;
 323.196 +      }
 323.197 +      return 0;
 323.198 +}
 323.199 +
 323.200 +TSP *tsp_read_data(char *fname)
 323.201 +{     struct dsa _dsa, *dsa = &_dsa;
 323.202 +      TSP *tsp = NULL;
 323.203 +      dsa->fname = fname;
 323.204 +      xprintf("tsp_read_data: reading TSP data from `%s'...\n",
 323.205 +         dsa->fname);
 323.206 +      dsa->fp = fopen(dsa->fname, "r");
 323.207 +      if (dsa->fp == NULL)
 323.208 +      {  xprintf("tsp_read_data: unable to open `%s' - %s\n",
 323.209 +            dsa->fname, strerror(errno));
 323.210 +         goto fail;
 323.211 +      }
 323.212 +      tsp = xmalloc(sizeof(TSP));
 323.213 +      tsp->name = NULL;
 323.214 +      tsp->type = TSP_UNDEF;
 323.215 +      tsp->comment = NULL;
 323.216 +      tsp->dimension = 0;
 323.217 +      tsp->edge_weight_type = TSP_UNDEF;
 323.218 +      tsp->edge_weight_format = TSP_UNDEF;
 323.219 +      tsp->display_data_type = TSP_UNDEF;
 323.220 +      tsp->node_x_coord = NULL;
 323.221 +      tsp->node_y_coord = NULL;
 323.222 +      tsp->dply_x_coord = NULL;
 323.223 +      tsp->dply_y_coord = NULL;
 323.224 +      tsp->tour = NULL;
 323.225 +      tsp->edge_weight = NULL;
 323.226 +      dsa->seqn = 1;
 323.227 +      if (get_char(dsa)) goto fail;
 323.228 +loop: if (scan_keyword(dsa)) goto fail;
 323.229 +      if (strcmp(dsa->token, "NAME") == 0)
 323.230 +      {  if (tsp->name != NULL)
 323.231 +         {  xprintf("%s:%d: NAME entry multiply defined\n", dsa->fname,
 323.232 +               dsa->seqn);
 323.233 +            goto fail;
 323.234 +         }
 323.235 +         if (check_colon(dsa)) goto fail;
 323.236 +         if (scan_token(dsa, 0)) goto fail;
 323.237 +         if (strlen(dsa->token) == 0)
 323.238 +         {  xprintf("%s:%d: NAME entry incomplete\n", dsa->fname,
 323.239 +               dsa->seqn);
 323.240 +            goto fail;
 323.241 +         }
 323.242 +         tsp->name = xmalloc(strlen(dsa->token) + 1);
 323.243 +         strcpy(tsp->name, dsa->token);
 323.244 +         xprintf("tsp_read_data: NAME: %s\n", tsp->name);
 323.245 +         if (check_newline(dsa)) goto fail;
 323.246 +      }
 323.247 +      else if (strcmp(dsa->token, "TYPE") == 0)
 323.248 +      {  if (tsp->type != TSP_UNDEF)
 323.249 +         {  xprintf("%s:%d: TYPE entry multiply defined\n", dsa->fname,
 323.250 +               dsa->seqn);
 323.251 +            goto fail;
 323.252 +         }
 323.253 +         if (check_colon(dsa)) goto fail;
 323.254 +         if (scan_keyword(dsa)) goto fail;
 323.255 +         if (strcmp(dsa->token, "TSP") == 0)
 323.256 +            tsp->type = TSP_TSP;
 323.257 +         else if (strcmp(dsa->token, "ATSP") == 0)
 323.258 +            tsp->type = TSP_ATSP;
 323.259 +         else if (strcmp(dsa->token, "TOUR") == 0)
 323.260 +            tsp->type = TSP_TOUR;
 323.261 +         else
 323.262 +         {  xprintf("%s:%d: data type `%s' not recognized\n",
 323.263 +               dsa->fname, dsa->seqn, dsa->token);
 323.264 +            goto fail;
 323.265 +         }
 323.266 +         xprintf("tsp_read_data: TYPE: %s\n", dsa->token);
 323.267 +         if (check_newline(dsa)) goto fail;
 323.268 +      }
 323.269 +      else if (strcmp(dsa->token, "COMMENT") == 0)
 323.270 +      {  if (tsp->comment != NULL)
 323.271 +         {  xprintf("%s:%d: COMMENT entry multiply defined\n",
 323.272 +               dsa->fname, dsa->seqn);
 323.273 +            goto fail;
 323.274 +         }
 323.275 +         if (check_colon(dsa)) goto fail;
 323.276 +         if (scan_comment(dsa)) goto fail;
 323.277 +         tsp->comment = xmalloc(strlen(dsa->token) + 1);
 323.278 +         strcpy(tsp->comment, dsa->token);
 323.279 +         xprintf("tsp_read_data: COMMENT: %s\n", tsp->comment);
 323.280 +         if (check_newline(dsa)) goto fail;
 323.281 +      }
 323.282 +      else if (strcmp(dsa->token, "DIMENSION") == 0)
 323.283 +      {  if (tsp->dimension != 0)
 323.284 +         {  xprintf("%s:%d: DIMENSION entry multiply defined\n",
 323.285 +               dsa->fname, dsa->seqn);
 323.286 +            goto fail;
 323.287 +         }
 323.288 +         if (check_colon(dsa)) goto fail;
 323.289 +         if (scan_integer(dsa, 0, &tsp->dimension)) goto fail;
 323.290 +         if (tsp->dimension < 1)
 323.291 +         {  xprintf("%s:%d: invalid dimension\n", dsa->fname,
 323.292 +               dsa->seqn);
 323.293 +            goto fail;
 323.294 +         }
 323.295 +         xprintf("tsp_read_data: DIMENSION: %d\n", tsp->dimension);
 323.296 +         if (check_newline(dsa)) goto fail;
 323.297 +      }
 323.298 +      else if (strcmp(dsa->token, "EDGE_WEIGHT_TYPE") == 0)
 323.299 +      {  if (tsp->edge_weight_type != TSP_UNDEF)
 323.300 +         {  xprintf("%s:%d: EDGE_WEIGHT_TYPE entry multiply defined\n",
 323.301 +               dsa->fname, dsa->seqn);
 323.302 +            goto fail;
 323.303 +         }
 323.304 +         if (check_colon(dsa)) goto fail;
 323.305 +         if (scan_keyword(dsa)) goto fail;
 323.306 +         if (strcmp(dsa->token, "GEO") == 0)
 323.307 +            tsp->edge_weight_type = TSP_GEO;
 323.308 +         else if (strcmp(dsa->token, "EUC_2D") == 0)
 323.309 +            tsp->edge_weight_type = TSP_EUC_2D;
 323.310 +         else if (strcmp(dsa->token, "ATT") == 0)
 323.311 +            tsp->edge_weight_type = TSP_ATT;
 323.312 +         else if (strcmp(dsa->token, "EXPLICIT") == 0)
 323.313 +            tsp->edge_weight_type = TSP_EXPLICIT;
 323.314 +         else if (strcmp(dsa->token, "CEIL_2D") == 0)
 323.315 +            tsp->edge_weight_type = TSP_CEIL_2D;
 323.316 +         else
 323.317 +         {  xprintf("%s:%d: edge weight type `%s' not recognized\n",
 323.318 +               dsa->fname, dsa->seqn, dsa->token);
 323.319 +            goto fail;
 323.320 +         }
 323.321 +         xprintf("tsp_read_data: EDGE_WEIGHT_TYPE: %s\n", dsa->token);
 323.322 +         if (check_newline(dsa)) goto fail;
 323.323 +      }
 323.324 +      else if (strcmp(dsa->token, "EDGE_WEIGHT_FORMAT") == 0)
 323.325 +      {  if (tsp->edge_weight_format != TSP_UNDEF)
 323.326 +         {  xprintf(
 323.327 +               "%s:%d: EDGE_WEIGHT_FORMAT entry multiply defined\n",
 323.328 +               dsa->fname, dsa->seqn);
 323.329 +            goto fail;
 323.330 +         }
 323.331 +         if (check_colon(dsa)) goto fail;
 323.332 +         if (scan_keyword(dsa)) goto fail;
 323.333 +         if (strcmp(dsa->token, "UPPER_ROW") == 0)
 323.334 +            tsp->edge_weight_format = TSP_UPPER_ROW;
 323.335 +         else if (strcmp(dsa->token, "FULL_MATRIX") == 0)
 323.336 +            tsp->edge_weight_format = TSP_FULL_MATRIX;
 323.337 +         else if (strcmp(dsa->token, "FUNCTION") == 0)
 323.338 +            tsp->edge_weight_format = TSP_FUNCTION;
 323.339 +         else if (strcmp(dsa->token, "LOWER_DIAG_ROW") == 0)
 323.340 +            tsp->edge_weight_format = TSP_LOWER_DIAG_ROW;
 323.341 +         else
 323.342 +         {  xprintf("%s:%d: edge weight format `%s' not recognized\n",
 323.343 +               dsa->fname, dsa->seqn, dsa->token);
 323.344 +            goto fail;
 323.345 +         }
 323.346 +         xprintf("tsp_read_data: EDGE_WEIGHT_FORMAT: %s\n", dsa->token);
 323.347 +         if (check_newline(dsa)) goto fail;
 323.348 +      }
 323.349 +      else if (strcmp(dsa->token, "DISPLAY_DATA_TYPE") == 0)
 323.350 +      {  if (tsp->display_data_type != TSP_UNDEF)
 323.351 +         {  xprintf("%s:%d: DISPLAY_DATA_TYPE entry multiply defined\n",
 323.352 +               dsa->fname, dsa->seqn);
 323.353 +            goto fail;
 323.354 +         }
 323.355 +         if (check_colon(dsa)) goto fail;
 323.356 +         if (scan_keyword(dsa)) goto fail;
 323.357 +         if (strcmp(dsa->token, "COORD_DISPLAY") == 0)
 323.358 +            tsp->display_data_type = TSP_COORD_DISPLAY;
 323.359 +         else if (strcmp(dsa->token, "TWOD_DISPLAY") == 0)
 323.360 +            tsp->display_data_type = TSP_TWOD_DISPLAY;
 323.361 +         else
 323.362 +         {  xprintf("%s:%d: display data type `%s' not recognized\n",
 323.363 +               dsa->fname, dsa->seqn, dsa->token);
 323.364 +            goto fail;
 323.365 +         }
 323.366 +         xprintf("tsp_read_data: DISPLAY_DATA_TYPE: %s\n", dsa->token);
 323.367 +         if (check_newline(dsa)) goto fail;
 323.368 +      }
 323.369 +      else if (strcmp(dsa->token, "NODE_COORD_SECTION") == 0)
 323.370 +      {  int n = tsp->dimension, k, node;
 323.371 +         if (n == 0)
 323.372 +         {  xprintf("%s:%d: DIMENSION entry not specified\n",
 323.373 +               dsa->fname, dsa->seqn);
 323.374 +            goto fail;
 323.375 +         }
 323.376 +         if (tsp->node_x_coord != NULL)
 323.377 +         {  xprintf("%s:%d: NODE_COORD_SECTION multiply specified\n",
 323.378 +               dsa->fname, dsa->seqn);
 323.379 +            goto fail;
 323.380 +         }
 323.381 +         if (check_newline(dsa)) goto fail;
 323.382 +         tsp->node_x_coord = xcalloc(1+n, sizeof(double));
 323.383 +         tsp->node_y_coord = xcalloc(1+n, sizeof(double));
 323.384 +         for (node = 1; node <= n; node++)
 323.385 +            tsp->node_x_coord[node] = tsp->node_y_coord[node] = DBL_MAX;
 323.386 +         for (k = 1; k <= n; k++)
 323.387 +         {  if (scan_integer(dsa, 0, &node)) goto fail;
 323.388 +            if (!(1 <= node && node <= n))
 323.389 +            {  xprintf("%s:%d: invalid node number %d\n", dsa->fname,
 323.390 +                  dsa->seqn, node);
 323.391 +               goto fail;
 323.392 +            }
 323.393 +            if (tsp->node_x_coord[node] != DBL_MAX)
 323.394 +            {  xprintf("%s:%d: node number %d multiply specified\n",
 323.395 +                  dsa->fname, dsa->seqn, node);
 323.396 +               goto fail;
 323.397 +            }
 323.398 +            if (scan_number(dsa, 0, &tsp->node_x_coord[node]))
 323.399 +               goto fail;
 323.400 +            if (scan_number(dsa, 0, &tsp->node_y_coord[node]))
 323.401 +               goto fail;
 323.402 +            if (check_newline(dsa)) goto fail;
 323.403 +         }
 323.404 +      }
 323.405 +      else if (strcmp(dsa->token, "DISPLAY_DATA_SECTION") == 0)
 323.406 +      {  int n = tsp->dimension, k, node;
 323.407 +         if (n == 0)
 323.408 +         {  xprintf("%s:%d: DIMENSION entry not specified\n",
 323.409 +               dsa->fname, dsa->seqn);
 323.410 +            goto fail;
 323.411 +         }
 323.412 +         if (tsp->dply_x_coord != NULL)
 323.413 +         {  xprintf("%s:%d: DISPLAY_DATA_SECTION multiply specified\n",
 323.414 +               dsa->fname, dsa->seqn);
 323.415 +            goto fail;
 323.416 +         }
 323.417 +         if (check_newline(dsa)) goto fail;
 323.418 +         tsp->dply_x_coord = xcalloc(1+n, sizeof(double));
 323.419 +         tsp->dply_y_coord = xcalloc(1+n, sizeof(double));
 323.420 +         for (node = 1; node <= n; node++)
 323.421 +            tsp->dply_x_coord[node] = tsp->dply_y_coord[node] = DBL_MAX;
 323.422 +         for (k = 1; k <= n; k++)
 323.423 +         {  if (scan_integer(dsa, 0, &node)) goto fail;
 323.424 +            if (!(1 <= node && node <= n))
 323.425 +            {  xprintf("%s:%d: invalid node number %d\n", dsa->fname,
 323.426 +                  dsa->seqn, node);
 323.427 +               goto fail;
 323.428 +            }
 323.429 +            if (tsp->dply_x_coord[node] != DBL_MAX)
 323.430 +            {  xprintf("%s:%d: node number %d multiply specified\n",
 323.431 +                  dsa->fname, dsa->seqn, node);
 323.432 +               goto fail;
 323.433 +            }
 323.434 +            if (scan_number(dsa, 0, &tsp->dply_x_coord[node]))
 323.435 +               goto fail;
 323.436 +            if (scan_number(dsa, 0, &tsp->dply_y_coord[node]))
 323.437 +               goto fail;
 323.438 +            if (check_newline(dsa)) goto fail;
 323.439 +         }
 323.440 +      }
 323.441 +      else if (strcmp(dsa->token, "TOUR_SECTION") == 0)
 323.442 +      {  int n = tsp->dimension, k, node;
 323.443 +         if (n == 0)
 323.444 +         {  xprintf("%s:%d: DIMENSION entry not specified\n",
 323.445 +               dsa->fname, dsa->seqn);
 323.446 +            goto fail;
 323.447 +         }
 323.448 +         if (tsp->tour != NULL)
 323.449 +         {  xprintf("%s:%d: TOUR_SECTION multiply specified\n",
 323.450 +               dsa->fname, dsa->seqn);
 323.451 +            goto fail;
 323.452 +         }
 323.453 +         if (check_newline(dsa)) goto fail;
 323.454 +         tsp->tour = xcalloc(1+n, sizeof(int));
 323.455 +         for (k = 1; k <= n; k++)
 323.456 +         {  if (scan_integer(dsa, 1, &node)) goto fail;
 323.457 +            if (!(1 <= node && node <= n))
 323.458 +            {  xprintf("%s:%d: invalid node number %d\n", dsa->fname,
 323.459 +                  dsa->seqn, node);
 323.460 +               goto fail;
 323.461 +            }
 323.462 +            tsp->tour[k] = node;
 323.463 +         }
 323.464 +         if (scan_integer(dsa, 1, &node)) goto fail;
 323.465 +         if (node != -1)
 323.466 +         {  xprintf("%s:%d: extra node(s) detected\n", dsa->fname,
 323.467 +               dsa->seqn);
 323.468 +            goto fail;
 323.469 +         }
 323.470 +         if (check_newline(dsa)) goto fail;
 323.471 +      }
 323.472 +      else if (strcmp(dsa->token, "EDGE_WEIGHT_SECTION") == 0)
 323.473 +      {  int n = tsp->dimension, i, j, temp;
 323.474 +         if (n == 0)
 323.475 +         {  xprintf("%s:%d: DIMENSION entry not specified\n",
 323.476 +               dsa->fname, dsa->seqn);
 323.477 +            goto fail;
 323.478 +         }
 323.479 +         if (tsp->edge_weight_format == TSP_UNDEF)
 323.480 +         {  xprintf("%s:%d: EDGE_WEIGHT_FORMAT entry not specified\n",
 323.481 +               dsa->fname, dsa->seqn);
 323.482 +            goto fail;
 323.483 +         }
 323.484 +         if (tsp->edge_weight != NULL)
 323.485 +         {  xprintf("%s:%d: EDGE_WEIGHT_SECTION multiply specified\n",
 323.486 +               dsa->fname, dsa->seqn);
 323.487 +            goto fail;
 323.488 +         }
 323.489 +         if (check_newline(dsa)) goto fail;
 323.490 +         tsp->edge_weight = xcalloc(1+n*n, sizeof(int));
 323.491 +         switch (tsp->edge_weight_format)
 323.492 +         {  case TSP_FULL_MATRIX:
 323.493 +               for (i = 1; i <= n; i++)
 323.494 +               {  for (j = 1; j <= n; j++)
 323.495 +                  {  if (scan_integer(dsa, 1, &temp)) goto fail;
 323.496 +                     tsp->edge_weight[(i - 1) * n + j] = temp;
 323.497 +                  }
 323.498 +               }
 323.499 +               break;
 323.500 +            case TSP_UPPER_ROW:
 323.501 +               for (i = 1; i <= n; i++)
 323.502 +               {  tsp->edge_weight[(i - 1) * n + i] = 0;
 323.503 +                  for (j = i + 1; j <= n; j++)
 323.504 +                  {  if (scan_integer(dsa, 1, &temp)) goto fail;
 323.505 +                     tsp->edge_weight[(i - 1) * n + j] = temp;
 323.506 +                     tsp->edge_weight[(j - 1) * n + i] = temp;
 323.507 +                  }
 323.508 +               }
 323.509 +               break;
 323.510 +            case TSP_LOWER_DIAG_ROW:
 323.511 +               for (i = 1; i <= n; i++)
 323.512 +               {  for (j = 1; j <= i; j++)
 323.513 +                  {  if (scan_integer(dsa, 1, &temp)) goto fail;
 323.514 +                     tsp->edge_weight[(i - 1) * n + j] = temp;
 323.515 +                     tsp->edge_weight[(j - 1) * n + i] = temp;
 323.516 +                  }
 323.517 +               }
 323.518 +               break;
 323.519 +            default:
 323.520 +               goto fail;
 323.521 +         }
 323.522 +         if (check_newline(dsa)) goto fail;
 323.523 +      }
 323.524 +      else if (strcmp(dsa->token, "EOF") == 0)
 323.525 +      {  if (check_newline(dsa)) goto fail;
 323.526 +         goto done;
 323.527 +      }
 323.528 +      else
 323.529 +      {  xprintf("%s:%d: keyword `%s' not recognized\n", dsa->fname,
 323.530 +            dsa->seqn, dsa->token);
 323.531 +         goto fail;
 323.532 +      }
 323.533 +      goto loop;
 323.534 +done: xprintf("tsp_read_data: %d lines were read\n", dsa->seqn-1);
 323.535 +      fclose(dsa->fp);
 323.536 +      return tsp;
 323.537 +fail: if (tsp != NULL)
 323.538 +      {  if (tsp->name != NULL) xfree(tsp->name);
 323.539 +         if (tsp->comment != NULL) xfree(tsp->comment);
 323.540 +         if (tsp->node_x_coord != NULL) xfree(tsp->node_x_coord);
 323.541 +         if (tsp->node_y_coord != NULL) xfree(tsp->node_y_coord);
 323.542 +         if (tsp->dply_x_coord != NULL) xfree(tsp->dply_x_coord);
 323.543 +         if (tsp->dply_y_coord != NULL) xfree(tsp->dply_y_coord);
 323.544 +         if (tsp->tour != NULL) xfree(tsp->tour);
 323.545 +         if (tsp->edge_weight != NULL) xfree(tsp->edge_weight);
 323.546 +         xfree(tsp);
 323.547 +      }
 323.548 +      if (dsa->fp != NULL) fclose(dsa->fp);
 323.549 +      return NULL;
 323.550 +}
 323.551 +
 323.552 +/*----------------------------------------------------------------------
 323.553 +-- tsp_free_data - free TSP instance data.
 323.554 +--
 323.555 +-- *Synopsis*
 323.556 +--
 323.557 +-- #include "glptsp.h"
 323.558 +-- void tsp_free_data(TSP *tsp);
 323.559 +--
 323.560 +-- *Description*
 323.561 +--
 323.562 +-- The routine tsp_free_data frees all the memory allocated to the TSP
 323.563 +-- instance data block, which the parameter tsp points to. */
 323.564 +
 323.565 +void tsp_free_data(TSP *tsp)
 323.566 +{     if (tsp->name != NULL) xfree(tsp->name);
 323.567 +      if (tsp->comment != NULL) xfree(tsp->comment);
 323.568 +      if (tsp->node_x_coord != NULL) xfree(tsp->node_x_coord);
 323.569 +      if (tsp->node_y_coord != NULL) xfree(tsp->node_y_coord);
 323.570 +      if (tsp->dply_x_coord != NULL) xfree(tsp->dply_x_coord);
 323.571 +      if (tsp->dply_y_coord != NULL) xfree(tsp->dply_y_coord);
 323.572 +      if (tsp->tour != NULL) xfree(tsp->tour);
 323.573 +      if (tsp->edge_weight != NULL) xfree(tsp->edge_weight);
 323.574 +      xfree(tsp);
 323.575 +      return;
 323.576 +}
 323.577 +
 323.578 +/*----------------------------------------------------------------------
 323.579 +-- tsp_distance - compute distance between two nodes.
 323.580 +--
 323.581 +-- *Synopsis*
 323.582 +--
 323.583 +-- #include "glptsp.h"
 323.584 +-- int tsp_distance(TSP *tsp, int i, int j);
 323.585 +--
 323.586 +-- *Description*
 323.587 +--
 323.588 +-- The routine tsp_distance computes the distance between i-th and j-th
 323.589 +-- nodes for the TSP instance, which tsp points to.
 323.590 +--
 323.591 +-- *Returns*
 323.592 +--
 323.593 +-- The routine tsp_distance returns the computed distance. */
 323.594 +
 323.595 +#define nint(x) ((int)((x) + 0.5))
 323.596 +
 323.597 +static double rad(double x)
 323.598 +{     /* convert input coordinate to longitude/latitude, in radians */
 323.599 +      double pi = 3.141592, deg, min;
 323.600 +      deg = (int)x;
 323.601 +      min = x - deg;
 323.602 +      return pi * (deg + 5.0 * min / 3.0) / 180.0;
 323.603 +}
 323.604 +
 323.605 +int tsp_distance(TSP *tsp, int i, int j)
 323.606 +{     int n = tsp->dimension, dij;
 323.607 +      if (!(tsp->type == TSP_TSP || tsp->type == TSP_ATSP))
 323.608 +         xfault("tsp_distance: invalid TSP instance\n");
 323.609 +      if (!(1 <= i && i <= n && 1 <= j && j <= n))
 323.610 +         xfault("tsp_distance: node number out of range\n");
 323.611 +      switch (tsp->edge_weight_type)
 323.612 +      {  case TSP_UNDEF:
 323.613 +            xfault("tsp_distance: edge weight type not specified\n");
 323.614 +         case TSP_EXPLICIT:
 323.615 +            if (tsp->edge_weight == NULL)
 323.616 +               xfault("tsp_distance: edge weights not specified\n");
 323.617 +            dij = tsp->edge_weight[(i - 1) * n + j];
 323.618 +            break;
 323.619 +         case TSP_EUC_2D:
 323.620 +            if (tsp->node_x_coord == NULL || tsp->node_y_coord == NULL)
 323.621 +               xfault("tsp_distance: node coordinates not specified\n");
 323.622 +            {  double xd, yd;
 323.623 +               xd = tsp->node_x_coord[i] - tsp->node_x_coord[j];
 323.624 +               yd = tsp->node_y_coord[i] - tsp->node_y_coord[j];
 323.625 +               dij = nint(sqrt(xd * xd + yd * yd));
 323.626 +            }
 323.627 +            break;
 323.628 +         case TSP_CEIL_2D:
 323.629 +            if (tsp->node_x_coord == NULL || tsp->node_y_coord == NULL)
 323.630 +               xfault("tsp_distance: node coordinates not specified\n");
 323.631 +            {  double xd, yd;
 323.632 +               xd = tsp->node_x_coord[i] - tsp->node_x_coord[j];
 323.633 +               yd = tsp->node_y_coord[i] - tsp->node_y_coord[j];
 323.634 +               dij = (int)ceil(sqrt(xd * xd + yd * yd));
 323.635 +            }
 323.636 +            break;
 323.637 +         case TSP_GEO:
 323.638 +            if (tsp->node_x_coord == NULL || tsp->node_y_coord == NULL)
 323.639 +               xfault("tsp_distance: node coordinates not specified\n");
 323.640 +            {  double rrr = 6378.388;
 323.641 +               double latitude_i = rad(tsp->node_x_coord[i]);
 323.642 +               double latitude_j = rad(tsp->node_x_coord[j]);
 323.643 +               double longitude_i = rad(tsp->node_y_coord[i]);
 323.644 +               double longitude_j = rad(tsp->node_y_coord[j]);
 323.645 +               double q1 = cos(longitude_i - longitude_j);
 323.646 +               double q2 = cos(latitude_i - latitude_j);
 323.647 +               double q3 = cos(latitude_i + latitude_j);
 323.648 +               dij = (int)(rrr * acos(0.5 * ((1.0 + q1) * q2 -
 323.649 +                  (1.0 - q1) *q3)) + 1.0);
 323.650 +            }
 323.651 +            break;
 323.652 +         case TSP_ATT:
 323.653 +            if (tsp->node_x_coord == NULL || tsp->node_y_coord == NULL)
 323.654 +               xfault("tsp_distance: node coordinates not specified\n");
 323.655 +            {  int tij;
 323.656 +               double xd, yd, rij;
 323.657 +               xd = tsp->node_x_coord[i] - tsp->node_x_coord[j];
 323.658 +               yd = tsp->node_y_coord[i] - tsp->node_y_coord[j];
 323.659 +               rij = sqrt((xd * xd + yd * yd) / 10.0);
 323.660 +               tij = nint(rij);
 323.661 +               if (tij < rij) dij = tij + 1; else dij = tij;
 323.662 +            }
 323.663 +            break;
 323.664 +         default:
 323.665 +            xassert(tsp->edge_weight_type != tsp->edge_weight_type);
 323.666 +      }
 323.667 +      return dij;
 323.668 +}
 323.669 +
 323.670 +/* eof */
   324.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
   324.2 +++ b/deps/glpk/src/glptsp.h	Sun Nov 06 20:59:10 2011 +0100
   324.3 @@ -0,0 +1,104 @@
   324.4 +/* glptsp.h (TSP format) */
   324.5 +
   324.6 +/***********************************************************************
   324.7 +*  This code is part of GLPK (GNU Linear Programming Kit).
   324.8 +*
   324.9 +*  Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008,
  324.10 +*  2009, 2010, 2011 Andrew Makhorin, Department for Applied Informatics,
  324.11 +*  Moscow Aviation Institute, Moscow, Russia. All rights reserved.
  324.12 +*  E-mail: <mao@gnu.org>.
  324.13 +*
  324.14 +*  GLPK is free software: you can redistribute it and/or modify it
  324.15 +*  under the terms of the GNU General Public License as published by
  324.16 +*  the Free Software Foundation, either version 3 of the License, or
  324.17 +*  (at your option) any later version.
  324.18 +*
  324.19 +*  GLPK is distributed in the hope that it will be useful, but WITHOUT
  324.20 +*  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
  324.21 +*  or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
  324.22 +*  License for more details.
  324.23 +*
  324.24 +*  You should have received a copy of the GNU General Public License
  324.25 +*  along with GLPK. If not, see <http://www.gnu.org/licenses/>.
  324.26 +***********************************************************************/
  324.27 +
  324.28 +#ifndef GLPTSP_H
  324.29 +#define GLPTSP_H
  324.30 +
  324.31 +typedef struct TSP TSP;
  324.32 +
  324.33 +struct TSP
  324.34 +{     /* TSP (or related problem) instance in the format described in
  324.35 +         the report [G.Reinelt, TSPLIB 95] */
  324.36 +      /*--------------------------------------------------------------*/
  324.37 +      /* the specification part */
  324.38 +      char *name;
  324.39 +      /* identifies the data file */
  324.40 +      int type;
  324.41 +      /* specifies the type of data: */
  324.42 +#define TSP_UNDEF             0  /* undefined */
  324.43 +#define TSP_TSP               1  /* symmetric TSP */
  324.44 +#define TSP_ATSP              2  /* asymmetric TSP */
  324.45 +#define TSP_TOUR              3  /* collection of tours */
  324.46 +      char *comment;
  324.47 +      /* additional comments (usually the name of the contributor or
  324.48 +         creator of the problem instance is given here) */
  324.49 +      int dimension;
  324.50 +      /* for a TSP or ATSP, the dimension is the number of its nodes
  324.51 +         for a TOUR it is the dimension of the corresponding problem */
  324.52 +      int edge_weight_type;
  324.53 +      /* specifies how the edge weights (or distances) are given: */
  324.54 +#define TSP_UNDEF             0  /* undefined */
  324.55 +#define TSP_EXPLICIT          1  /* listed explicitly */
  324.56 +#define TSP_EUC_2D            2  /* Eucl. distances in 2-D */
  324.57 +#define TSP_CEIL_2D           3  /* Eucl. distances in 2-D rounded up */
  324.58 +#define TSP_GEO               4  /* geographical distances */
  324.59 +#define TSP_ATT               5  /* special distance function */
  324.60 +      int edge_weight_format;
  324.61 +      /* describes the format of the edge weights if they are given
  324.62 +         explicitly: */
  324.63 +#define TSP_UNDEF             0  /* undefined */
  324.64 +#define TSP_FUNCTION          1  /* given by a function */
  324.65 +#define TSP_FULL_MATRIX       2  /* given by a full matrix */
  324.66 +#define TSP_UPPER_ROW         3  /* upper triangulat matrix (row-wise
  324.67 +                                    without diagonal entries) */
  324.68 +#define TSP_LOWER_DIAG_ROW    4  /* lower triangular matrix (row-wise
  324.69 +                                    including diagonal entries) */
  324.70 +      int display_data_type;
  324.71 +      /* specifies how a graphical display of the nodes can be
  324.72 +         obtained: */
  324.73 +#define TSP_UNDEF             0  /* undefined */
  324.74 +#define TSP_COORD_DISPLAY     1  /* display is generated from the node
  324.75 +                                    coordinates */
  324.76 +#define TSP_TWOD_DISPLAY      2  /* explicit coordinates in 2-D are
  324.77 +                                    given */
  324.78 +      /*--------------------------------------------------------------*/
  324.79 +      /* data part */
  324.80 +      /* NODE_COORD_SECTION: */
  324.81 +      double *node_x_coord; /* double node_x_coord[1+dimension]; */
  324.82 +      double *node_y_coord; /* double node_y_coord[1+dimension]; */
  324.83 +      /* DISPLAY_DATA_SECTION: */
  324.84 +      double *dply_x_coord; /* double dply_x_coord[1+dimension]; */
  324.85 +      double *dply_y_coord; /* double dply_y_coord[1+dimension]; */
  324.86 +      /* TOUR_SECTION: */
  324.87 +      int *tour; /* int tour[1+dimension]; */
  324.88 +      /* EDGE_WEIGHT_SECTION: */
  324.89 +      int *edge_weight; /* int edge_weight[1+dimension*dimension]; */
  324.90 +};
  324.91 +
  324.92 +#define tsp_read_data         _glp_tsp_read_data
  324.93 +#define tsp_free_data         _glp_tsp_free_data
  324.94 +#define tsp_distance          _glp_tsp_distance
  324.95 +
  324.96 +TSP *tsp_read_data(char *fname);
  324.97 +/* read TSP instance data */
  324.98 +
  324.99 +void tsp_free_data(TSP *tsp);
 324.100 +/* free TSP instance data */
 324.101 +
 324.102 +int tsp_distance(TSP *tsp, int i, int j);
 324.103 +/* compute distance between two nodes */
 324.104 +
 324.105 +#endif
 324.106 +
 324.107 +/* eof */
   325.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
   325.2 +++ b/deps/glpk/src/minisat/LICENSE	Sun Nov 06 20:59:10 2011 +0100
   325.3 @@ -0,0 +1,20 @@
   325.4 +MiniSat -- Copyright (c) 2005, Niklas Sorensson
   325.5 +
   325.6 +Permission is hereby granted, free of charge, to any person obtaining a
   325.7 +copy of this software and associated documentation files (the
   325.8 +"Software"), to deal in the Software without restriction, including
   325.9 +without limitation the rights to use, copy, modify, merge, publish,
  325.10 +distribute, sublicense, and/or sell copies of the Software, and to
  325.11 +permit persons to whom the Software is furnished to do so, subject to
  325.12 +the following conditions:
  325.13 +
  325.14 +The above copyright notice and this permission notice shall be included
  325.15 +in all copies or substantial portions of the Software.
  325.16 +
  325.17 +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
  325.18 +OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  325.19 +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
  325.20 +NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
  325.21 +LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
  325.22 +OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
  325.23 +WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
   326.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
   326.2 +++ b/deps/glpk/src/minisat/README	Sun Nov 06 20:59:10 2011 +0100
   326.3 @@ -0,0 +1,22 @@
   326.4 +NOTE: Files in this subdirectory are NOT part of the GLPK package, but
   326.5 +      are used with GLPK.
   326.6 +
   326.7 +      The original code was modified according to GLPK requirements by
   326.8 +      Andrew Makhorin <mao@gnu.org>.
   326.9 +************************************************************************
  326.10 +MiniSat-C v1.14.1
  326.11 +========================================
  326.12 +
  326.13 +* Fixed some serious bugs.
  326.14 +* Tweaked to be Visual Studio friendly (by Alan Mishchenko).
  326.15 +  This disabled reading of gzipped DIMACS files and signal handling,
  326.16 +  but none of these features are essential (and easy to re-enable, if
  326.17 +  wanted).
  326.18 +
  326.19 +MiniSat-C v1.14
  326.20 +========================================
  326.21 +
  326.22 +Ok, we get it. You hate C++. You hate templates. We agree; C++ is a
  326.23 +seriously messed up language. Although we are more pragmatic about the
  326.24 +quirks and maldesigns in C++, we sympathize with you. So here is a
  326.25 +pure C version of MiniSat, put together by Niklas Sorensson.
   327.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
   327.2 +++ b/deps/glpk/src/minisat/minisat.c	Sun Nov 06 20:59:10 2011 +0100
   327.3 @@ -0,0 +1,1299 @@
   327.4 +/* minisat.c */
   327.5 +
   327.6 +/* Modified by Andrew Makhorin <mao@gnu.org>, August 2011 */
   327.7 +
   327.8 +/***********************************************************************
   327.9 +*  MiniSat -- Copyright (c) 2005, Niklas Sorensson
  327.10 +*  http://www.cs.chalmers.se/Cs/Research/FormalMethods/MiniSat/
  327.11 +*
  327.12 +*  Permission is hereby granted, free of charge, to any person
  327.13 +*  obtaining a copy of this software and associated documentation files
  327.14 +*  (the "Software"), to deal in the Software without restriction,
  327.15 +*  including without limitation the rights to use, copy, modify, merge,
  327.16 +*  publish, distribute, sublicense, and/or sell copies of the Software,
  327.17 +*  and to permit persons to whom the Software is furnished to do so,
  327.18 +*  subject to the following conditions:
  327.19 +*
  327.20 +*  The above copyright notice and this permission notice shall be
  327.21 +*  included in all copies or substantial portions of the Software.
  327.22 +*
  327.23 +*  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  327.24 +*  EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  327.25 +*  MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
  327.26 +*  NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
  327.27 +*  BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
  327.28 +*  ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
  327.29 +*  CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  327.30 +*  SOFTWARE.
  327.31 +***********************************************************************/
  327.32 +/* Modified to compile with MS Visual Studio 6.0 by Alan Mishchenko */
  327.33 +
  327.34 +#include "glpenv.h"
  327.35 +#include "minisat.h"
  327.36 +
  327.37 +#if 1 /* by mao */
  327.38 +static void *ymalloc(int size)
  327.39 +{     void *ptr;
  327.40 +      xassert(size > 0);
  327.41 +      ptr = malloc(size);
  327.42 +      if (ptr == NULL)
  327.43 +         xerror("MiniSat: no memory available\n");
  327.44 +      return ptr;
  327.45 +}
  327.46 +
  327.47 +static void *yrealloc(void *ptr, int size)
  327.48 +{     xassert(size > 0);
  327.49 +      if (ptr == NULL)
  327.50 +         ptr = malloc(size);
  327.51 +      else
  327.52 +         ptr = realloc(ptr, size);
  327.53 +      if (ptr == NULL)
  327.54 +         xerror("MiniSat: no memory available\n");
  327.55 +      return ptr;
  327.56 +}
  327.57 +
  327.58 +static void yfree(void *ptr)
  327.59 +{     xassert(ptr != NULL);
  327.60 +      free(ptr);
  327.61 +      return;
  327.62 +}
  327.63 +
  327.64 +#define assert  xassert
  327.65 +#define printf  xprintf
  327.66 +#define fflush(f) /* nop */
  327.67 +#define malloc  ymalloc
  327.68 +#define realloc yrealloc
  327.69 +#define free    yfree
  327.70 +#define inline  /* empty */
  327.71 +#endif
  327.72 +
  327.73 +/*====================================================================*/
  327.74 +/* Debug: */
  327.75 +
  327.76 +#if 0
  327.77 +#define VERBOSEDEBUG 1
  327.78 +#endif
  327.79 +
  327.80 +/* For derivation output (verbosity level 2) */
  327.81 +#define L_IND    "%-*d"
  327.82 +#define L_ind    solver_dlevel(s)*3+3,solver_dlevel(s)
  327.83 +#define L_LIT    "%sx%d"
  327.84 +#define L_lit(p) lit_sign(p)?"~":"", (lit_var(p))
  327.85 +
  327.86 +#if 0 /* by mao */
  327.87 +/* Just like 'assert()' but expression will be evaluated in the release
  327.88 +   version as well. */
  327.89 +static inline void check(int expr) { assert(expr); }
  327.90 +#endif
  327.91 +
  327.92 +#if 0 /* by mao */
  327.93 +static void printlits(lit* begin, lit* end)
  327.94 +{
  327.95 +    int i;
  327.96 +    for (i = 0; i < end - begin; i++)
  327.97 +        printf(L_LIT" ",L_lit(begin[i]));
  327.98 +}
  327.99 +#endif
 327.100 +
 327.101 +/*====================================================================*/
 327.102 +/* Random numbers: */
 327.103 +
 327.104 +/* Returns a random float 0 <= x < 1. Seed must never be 0. */
 327.105 +static inline double drand(double* seed) {
 327.106 +    int q;
 327.107 +    *seed *= 1389796;
 327.108 +    q = (int)(*seed / 2147483647);
 327.109 +    *seed -= (double)q * 2147483647;
 327.110 +    return *seed / 2147483647; }
 327.111 +
 327.112 +/* Returns a random integer 0 <= x < size. Seed must never be 0. */
 327.113 +static inline int irand(double* seed, int size) {
 327.114 +    return (int)(drand(seed) * size); }
 327.115 +
 327.116 +/*====================================================================*/
 327.117 +/* Predeclarations: */
 327.118 +
 327.119 +static void sort(void** array, int size,
 327.120 +    int(*comp)(const void *, const void *));
 327.121 +
 327.122 +/*====================================================================*/
 327.123 +/* Clause datatype + minor functions: */
 327.124 +
 327.125 +#if 0 /* by mao; see minisat.h */
 327.126 +struct clause_t
 327.127 +{
 327.128 +    int size_learnt;
 327.129 +    lit lits[0];
 327.130 +};
 327.131 +#endif
 327.132 +
 327.133 +#define clause_size(c) ((c)->size_learnt >> 1)
 327.134 +
 327.135 +#define clause_begin(c) ((c)->lits)
 327.136 +
 327.137 +#define clause_learnt(c) ((c)->size_learnt & 1)
 327.138 +
 327.139 +#define clause_activity(c) \
 327.140 +    (*((float*)&(c)->lits[(c)->size_learnt>>1]))
 327.141 +
 327.142 +#define clause_setactivity(c, a) \
 327.143 +    (void)(*((float*)&(c)->lits[(c)->size_learnt>>1]) = (a))
 327.144 +
 327.145 +/*====================================================================*/
 327.146 +/* Encode literals in clause pointers: */
 327.147 +
 327.148 +#define clause_from_lit(l) \
 327.149 +      (clause*)((unsigned long)(l) + (unsigned long)(l) + 1)
 327.150 +
 327.151 +#define clause_is_lit(c) \
 327.152 +      ((unsigned long)(c) & 1)
 327.153 +
 327.154 +#define clause_read_lit(c) \
 327.155 +      (lit)((unsigned long)(c) >> 1)
 327.156 +
 327.157 +/*====================================================================*/
 327.158 +/* Simple helpers: */
 327.159 +
 327.160 +#define solver_dlevel(s) \
 327.161 +    (int)veci_size(&(s)->trail_lim)
 327.162 +
 327.163 +#define solver_read_wlist(s, l) \
 327.164 +    (vecp *)(&(s)->wlists[l])
 327.165 +
 327.166 +static inline void    vecp_remove(vecp* v, void* e)
 327.167 +{
 327.168 +    void** ws = vecp_begin(v);
 327.169 +    int    j  = 0;
 327.170 +
 327.171 +    for (; ws[j] != e  ; j++);
 327.172 +    assert(j < vecp_size(v));
 327.173 +    for (; j < vecp_size(v)-1; j++) ws[j] = ws[j+1];
 327.174 +    vecp_resize(v,vecp_size(v)-1);
 327.175 +}
 327.176 +
 327.177 +/*====================================================================*/
 327.178 +/* Variable order functions: */
 327.179 +
 327.180 +static inline void order_update(solver* s, int v)
 327.181 +{   /* updateorder */
 327.182 +    int*    orderpos = s->orderpos;
 327.183 +    double* activity = s->activity;
 327.184 +    int*    heap     = veci_begin(&s->order);
 327.185 +    int     i        = orderpos[v];
 327.186 +    int     x        = heap[i];
 327.187 +    int     parent   = (i - 1) / 2;
 327.188 +
 327.189 +    assert(s->orderpos[v] != -1);
 327.190 +
 327.191 +    while (i != 0 && activity[x] > activity[heap[parent]]){
 327.192 +        heap[i]           = heap[parent];
 327.193 +        orderpos[heap[i]] = i;
 327.194 +        i                 = parent;
 327.195 +        parent            = (i - 1) / 2;
 327.196 +    }
 327.197 +    heap[i]     = x;
 327.198 +    orderpos[x] = i;
 327.199 +}
 327.200 +
 327.201 +#define order_assigned(s, v) /* nop */
 327.202 +
 327.203 +static inline void order_unassigned(solver* s, int v)
 327.204 +{   /* undoorder */
 327.205 +    int* orderpos = s->orderpos;
 327.206 +    if (orderpos[v] == -1){
 327.207 +        orderpos[v] = veci_size(&s->order);
 327.208 +        veci_push(&s->order,v);
 327.209 +        order_update(s,v);
 327.210 +    }
 327.211 +}
 327.212 +
 327.213 +static int order_select(solver* s, float random_var_freq)
 327.214 +{   /* selectvar */
 327.215 +    int*    heap;
 327.216 +    double* activity;
 327.217 +    int*    orderpos;
 327.218 +
 327.219 +    lbool* values = s->assigns;
 327.220 +
 327.221 +    /* Random decision: */
 327.222 +    if (drand(&s->random_seed) < random_var_freq){
 327.223 +        int next = irand(&s->random_seed,s->size);
 327.224 +        assert(next >= 0 && next < s->size);
 327.225 +        if (values[next] == l_Undef)
 327.226 +            return next;
 327.227 +    }
 327.228 +
 327.229 +    /* Activity based decision: */
 327.230 +
 327.231 +    heap     = veci_begin(&s->order);
 327.232 +    activity = s->activity;
 327.233 +    orderpos = s->orderpos;
 327.234 +
 327.235 +    while (veci_size(&s->order) > 0){
 327.236 +        int    next  = heap[0];
 327.237 +        int    size  = veci_size(&s->order)-1;
 327.238 +        int    x     = heap[size];
 327.239 +
 327.240 +        veci_resize(&s->order,size);
 327.241 +
 327.242 +        orderpos[next] = -1;
 327.243 +
 327.244 +        if (size > 0){
 327.245 +            double act   = activity[x];
 327.246 +
 327.247 +            int    i     = 0;
 327.248 +            int    child = 1;
 327.249 +
 327.250 +            while (child < size){
 327.251 +                if (child+1 < size
 327.252 +                    && activity[heap[child]] < activity[heap[child+1]])
 327.253 +                    child++;
 327.254 +
 327.255 +                assert(child < size);
 327.256 +
 327.257 +                if (act >= activity[heap[child]])
 327.258 +                    break;
 327.259 +
 327.260 +                heap[i]           = heap[child];
 327.261 +                orderpos[heap[i]] = i;
 327.262 +                i                 = child;
 327.263 +                child             = 2 * child + 1;
 327.264 +            }
 327.265 +            heap[i]           = x;
 327.266 +            orderpos[heap[i]] = i;
 327.267 +        }
 327.268 +
 327.269 +        if (values[next] == l_Undef)
 327.270 +            return next;
 327.271 +    }
 327.272 +
 327.273 +    return var_Undef;
 327.274 +}
 327.275 +
 327.276 +/*====================================================================*/
 327.277 +/* Activity functions: */
 327.278 +
 327.279 +static inline void act_var_rescale(solver* s) {
 327.280 +    double* activity = s->activity;
 327.281 +    int i;
 327.282 +    for (i = 0; i < s->size; i++)
 327.283 +        activity[i] *= 1e-100;
 327.284 +    s->var_inc *= 1e-100;
 327.285 +}
 327.286 +
 327.287 +static inline void act_var_bump(solver* s, int v) {
 327.288 +    double* activity = s->activity;
 327.289 +    if ((activity[v] += s->var_inc) > 1e100)
 327.290 +        act_var_rescale(s);
 327.291 +
 327.292 +    /* printf("bump %d %f\n", v-1, activity[v]); */
 327.293 +
 327.294 +    if (s->orderpos[v] != -1)
 327.295 +        order_update(s,v);
 327.296 +
 327.297 +}
 327.298 +
 327.299 +static inline void act_var_decay(solver* s)
 327.300 +    { s->var_inc *= s->var_decay; }
 327.301 +
 327.302 +static inline void act_clause_rescale(solver* s) {
 327.303 +    clause** cs = (clause**)vecp_begin(&s->learnts);
 327.304 +    int i;
 327.305 +    for (i = 0; i < vecp_size(&s->learnts); i++){
 327.306 +        float a = clause_activity(cs[i]);
 327.307 +        clause_setactivity(cs[i], a * (float)1e-20);
 327.308 +    }
 327.309 +    s->cla_inc *= (float)1e-20;
 327.310 +}
 327.311 +
 327.312 +static inline void act_clause_bump(solver* s, clause *c) {
 327.313 +    float a = clause_activity(c) + s->cla_inc;
 327.314 +    clause_setactivity(c,a);
 327.315 +    if (a > 1e20) act_clause_rescale(s);
 327.316 +}
 327.317 +
 327.318 +static inline void act_clause_decay(solver* s)
 327.319 +    { s->cla_inc *= s->cla_decay; }
 327.320 +
 327.321 +/*====================================================================*/
 327.322 +/* Clause functions: */
 327.323 +
 327.324 +/* pre: size > 1 && no variable occurs twice
 327.325 + */
 327.326 +static clause* clause_new(solver* s, lit* begin, lit* end, int learnt)
 327.327 +{
 327.328 +    int size;
 327.329 +    clause* c;
 327.330 +    int i;
 327.331 +
 327.332 +    assert(end - begin > 1);
 327.333 +    assert(learnt >= 0 && learnt < 2);
 327.334 +    size           = end - begin;
 327.335 +    c              = (clause*)malloc(sizeof(clause)
 327.336 +                     + sizeof(lit) * size + learnt * sizeof(float));
 327.337 +    c->size_learnt = (size << 1) | learnt;
 327.338 +#if 0 /* by mao; meaningless non-portable check */
 327.339 +    assert(((unsigned int)c & 1) == 0);
 327.340 +#endif
 327.341 +
 327.342 +    for (i = 0; i < size; i++)
 327.343 +        c->lits[i] = begin[i];
 327.344 +
 327.345 +    if (learnt)
 327.346 +        *((float*)&c->lits[size]) = 0.0;
 327.347 +
 327.348 +    assert(begin[0] >= 0);
 327.349 +    assert(begin[0] < s->size*2);
 327.350 +    assert(begin[1] >= 0);
 327.351 +    assert(begin[1] < s->size*2);
 327.352 +
 327.353 +    assert(lit_neg(begin[0]) < s->size*2);
 327.354 +    assert(lit_neg(begin[1]) < s->size*2);
 327.355 +
 327.356 +    /* vecp_push(solver_read_wlist(s,lit_neg(begin[0])),(void*)c); */
 327.357 +    /* vecp_push(solver_read_wlist(s,lit_neg(begin[1])),(void*)c); */
 327.358 +
 327.359 +    vecp_push(solver_read_wlist(s,lit_neg(begin[0])),
 327.360 +        (void*)(size > 2 ? c : clause_from_lit(begin[1])));
 327.361 +    vecp_push(solver_read_wlist(s,lit_neg(begin[1])),
 327.362 +        (void*)(size > 2 ? c : clause_from_lit(begin[0])));
 327.363 +
 327.364 +    return c;
 327.365 +}
 327.366 +
 327.367 +static void clause_remove(solver* s, clause* c)
 327.368 +{
 327.369 +    lit* lits = clause_begin(c);
 327.370 +    assert(lit_neg(lits[0]) < s->size*2);
 327.371 +    assert(lit_neg(lits[1]) < s->size*2);
 327.372 +
 327.373 +    /* vecp_remove(solver_read_wlist(s,lit_neg(lits[0])),(void*)c); */
 327.374 +    /* vecp_remove(solver_read_wlist(s,lit_neg(lits[1])),(void*)c); */
 327.375 +
 327.376 +    assert(lits[0] < s->size*2);
 327.377 +    vecp_remove(solver_read_wlist(s,lit_neg(lits[0])),
 327.378 +        (void*)(clause_size(c) > 2 ? c : clause_from_lit(lits[1])));
 327.379 +    vecp_remove(solver_read_wlist(s,lit_neg(lits[1])),
 327.380 +        (void*)(clause_size(c) > 2 ? c : clause_from_lit(lits[0])));
 327.381 +
 327.382 +    if (clause_learnt(c)){
 327.383 +        s->stats.learnts--;
 327.384 +        s->stats.learnts_literals -= clause_size(c);
 327.385 +    }else{
 327.386 +        s->stats.clauses--;
 327.387 +        s->stats.clauses_literals -= clause_size(c);
 327.388 +    }
 327.389 +
 327.390 +    free(c);
 327.391 +}
 327.392 +
 327.393 +static lbool clause_simplify(solver* s, clause* c)
 327.394 +{
 327.395 +    lit*   lits   = clause_begin(c);
 327.396 +    lbool* values = s->assigns;
 327.397 +    int i;
 327.398 +
 327.399 +    assert(solver_dlevel(s) == 0);
 327.400 +
 327.401 +    for (i = 0; i < clause_size(c); i++){
 327.402 +        lbool sig = !lit_sign(lits[i]); sig += sig - 1;
 327.403 +        if (values[lit_var(lits[i])] == sig)
 327.404 +            return l_True;
 327.405 +    }
 327.406 +    return l_False;
 327.407 +}
 327.408 +
 327.409 +/*====================================================================*/
 327.410 +/* Minor (solver) functions: */
 327.411 +
 327.412 +void solver_setnvars(solver* s,int n)
 327.413 +{
 327.414 +    int var;
 327.415 +
 327.416 +    if (s->cap < n){
 327.417 +
 327.418 +        while (s->cap < n) s->cap = s->cap*2+1;
 327.419 +
 327.420 +        s->wlists    = (vecp*)   realloc(s->wlists,
 327.421 +                                 sizeof(vecp)*s->cap*2);
 327.422 +        s->activity  = (double*) realloc(s->activity,
 327.423 +                                 sizeof(double)*s->cap);
 327.424 +        s->assigns   = (lbool*)  realloc(s->assigns,
 327.425 +                                 sizeof(lbool)*s->cap);
 327.426 +        s->orderpos  = (int*)    realloc(s->orderpos,
 327.427 +                                 sizeof(int)*s->cap);
 327.428 +        s->reasons   = (clause**)realloc(s->reasons,
 327.429 +                                 sizeof(clause*)*s->cap);
 327.430 +        s->levels    = (int*)    realloc(s->levels,
 327.431 +                                 sizeof(int)*s->cap);
 327.432 +        s->tags      = (lbool*)  realloc(s->tags,
 327.433 +                                 sizeof(lbool)*s->cap);
 327.434 +        s->trail     = (lit*)    realloc(s->trail,
 327.435 +                                 sizeof(lit)*s->cap);
 327.436 +    }
 327.437 +
 327.438 +    for (var = s->size; var < n; var++){
 327.439 +        vecp_new(&s->wlists[2*var]);
 327.440 +        vecp_new(&s->wlists[2*var+1]);
 327.441 +        s->activity [var] = 0;
 327.442 +        s->assigns  [var] = l_Undef;
 327.443 +        s->orderpos [var] = veci_size(&s->order);
 327.444 +        s->reasons  [var] = (clause*)0;
 327.445 +        s->levels   [var] = 0;
 327.446 +        s->tags     [var] = l_Undef;
 327.447 +
 327.448 +        /* does not hold because variables enqueued at top level will
 327.449 +           not be reinserted in the heap
 327.450 +           assert(veci_size(&s->order) == var);
 327.451 +         */
 327.452 +        veci_push(&s->order,var);
 327.453 +        order_update(s, var);
 327.454 +    }
 327.455 +
 327.456 +    s->size = n > s->size ? n : s->size;
 327.457 +}
 327.458 +
 327.459 +static inline bool enqueue(solver* s, lit l, clause* from)
 327.460 +{
 327.461 +    lbool* values = s->assigns;
 327.462 +    int    v      = lit_var(l);
 327.463 +    lbool  val    = values[v];
 327.464 +    lbool  sig;
 327.465 +#ifdef VERBOSEDEBUG
 327.466 +    printf(L_IND"enqueue("L_LIT")\n", L_ind, L_lit(l));
 327.467 +#endif
 327.468 +
 327.469 +    /* lbool */ sig = !lit_sign(l); sig += sig - 1;
 327.470 +    if (val != l_Undef){
 327.471 +        return val == sig;
 327.472 +    }else{
 327.473 +        /* New fact -- store it. */
 327.474 +        int*     levels;
 327.475 +        clause** reasons;
 327.476 +#ifdef VERBOSEDEBUG
 327.477 +        printf(L_IND"bind("L_LIT")\n", L_ind, L_lit(l));
 327.478 +#endif
 327.479 +        /* int*     */ levels  = s->levels;
 327.480 +        /* clause** */ reasons = s->reasons;
 327.481 +
 327.482 +        values [v] = sig;
 327.483 +        levels [v] = solver_dlevel(s);
 327.484 +        reasons[v] = from;
 327.485 +        s->trail[s->qtail++] = l;
 327.486 +
 327.487 +        order_assigned(s, v);
 327.488 +        return true;
 327.489 +    }
 327.490 +}
 327.491 +
 327.492 +static inline void assume(solver* s, lit l){
 327.493 +    assert(s->qtail == s->qhead);
 327.494 +    assert(s->assigns[lit_var(l)] == l_Undef);
 327.495 +#ifdef VERBOSEDEBUG
 327.496 +    printf(L_IND"assume("L_LIT")\n", L_ind, L_lit(l));
 327.497 +#endif
 327.498 +    veci_push(&s->trail_lim,s->qtail);
 327.499 +    enqueue(s,l,(clause*)0);
 327.500 +}
 327.501 +
 327.502 +static inline void solver_canceluntil(solver* s, int level) {
 327.503 +    lit*     trail;
 327.504 +    lbool*   values;
 327.505 +    clause** reasons;
 327.506 +    int      bound;
 327.507 +    int      c;
 327.508 +
 327.509 +    if (solver_dlevel(s) <= level)
 327.510 +        return;
 327.511 +
 327.512 +    trail   = s->trail;
 327.513 +    values  = s->assigns;
 327.514 +    reasons = s->reasons;
 327.515 +    bound   = (veci_begin(&s->trail_lim))[level];
 327.516 +
 327.517 +    for (c = s->qtail-1; c >= bound; c--) {
 327.518 +        int     x  = lit_var(trail[c]);
 327.519 +        values [x] = l_Undef;
 327.520 +        reasons[x] = (clause*)0;
 327.521 +    }
 327.522 +
 327.523 +    for (c = s->qhead-1; c >= bound; c--)
 327.524 +        order_unassigned(s,lit_var(trail[c]));
 327.525 +
 327.526 +    s->qhead = s->qtail = bound;
 327.527 +    veci_resize(&s->trail_lim,level);
 327.528 +}
 327.529 +
 327.530 +static void solver_record(solver* s, veci* cls)
 327.531 +{
 327.532 +    lit*    begin = veci_begin(cls);
 327.533 +    lit*    end   = begin + veci_size(cls);
 327.534 +    clause* c     = (veci_size(cls) > 1) ? clause_new(s,begin,end,1)
 327.535 +                                         : (clause*)0;
 327.536 +    enqueue(s,*begin,c);
 327.537 +
 327.538 +    assert(veci_size(cls) > 0);
 327.539 +
 327.540 +    if (c != 0) {
 327.541 +        vecp_push(&s->learnts,c);
 327.542 +        act_clause_bump(s,c);
 327.543 +        s->stats.learnts++;
 327.544 +        s->stats.learnts_literals += veci_size(cls);
 327.545 +    }
 327.546 +}
 327.547 +
 327.548 +static double solver_progress(solver* s)
 327.549 +{
 327.550 +    lbool*  values = s->assigns;
 327.551 +    int*    levels = s->levels;
 327.552 +    int     i;
 327.553 +
 327.554 +    double  progress = 0;
 327.555 +    double  F        = 1.0 / s->size;
 327.556 +    for (i = 0; i < s->size; i++)
 327.557 +        if (values[i] != l_Undef)
 327.558 +            progress += pow(F, levels[i]);
 327.559 +    return progress / s->size;
 327.560 +}
 327.561 +
 327.562 +/*====================================================================*/
 327.563 +/* Major methods: */
 327.564 +
 327.565 +static bool solver_lit_removable(solver* s, lit l, int minl)
 327.566 +{
 327.567 +    lbool*   tags    = s->tags;
 327.568 +    clause** reasons = s->reasons;
 327.569 +    int*     levels  = s->levels;
 327.570 +    int      top     = veci_size(&s->tagged);
 327.571 +
 327.572 +    assert(lit_var(l) >= 0 && lit_var(l) < s->size);
 327.573 +    assert(reasons[lit_var(l)] != 0);
 327.574 +    veci_resize(&s->stack,0);
 327.575 +    veci_push(&s->stack,lit_var(l));
 327.576 +
 327.577 +    while (veci_size(&s->stack) > 0){
 327.578 +        clause* c;
 327.579 +        int v = veci_begin(&s->stack)[veci_size(&s->stack)-1];
 327.580 +        assert(v >= 0 && v < s->size);
 327.581 +        veci_resize(&s->stack,veci_size(&s->stack)-1);
 327.582 +        assert(reasons[v] != 0);
 327.583 +        c    = reasons[v];
 327.584 +
 327.585 +        if (clause_is_lit(c)){
 327.586 +            int v = lit_var(clause_read_lit(c));
 327.587 +            if (tags[v] == l_Undef && levels[v] != 0){
 327.588 +                if (reasons[v] != 0
 327.589 +                    && ((1 << (levels[v] & 31)) & minl)){
 327.590 +                    veci_push(&s->stack,v);
 327.591 +                    tags[v] = l_True;
 327.592 +                    veci_push(&s->tagged,v);
 327.593 +                }else{
 327.594 +                    int* tagged = veci_begin(&s->tagged);
 327.595 +                    int j;
 327.596 +                    for (j = top; j < veci_size(&s->tagged); j++)
 327.597 +                        tags[tagged[j]] = l_Undef;
 327.598 +                    veci_resize(&s->tagged,top);
 327.599 +                    return false;
 327.600 +                }
 327.601 +            }
 327.602 +        }else{
 327.603 +            lit*    lits = clause_begin(c);
 327.604 +            int     i, j;
 327.605 +
 327.606 +            for (i = 1; i < clause_size(c); i++){
 327.607 +                int v = lit_var(lits[i]);
 327.608 +                if (tags[v] == l_Undef && levels[v] != 0){
 327.609 +                    if (reasons[v] != 0
 327.610 +                        && ((1 << (levels[v] & 31)) & minl)){
 327.611 +
 327.612 +                        veci_push(&s->stack,lit_var(lits[i]));
 327.613 +                        tags[v] = l_True;
 327.614 +                        veci_push(&s->tagged,v);
 327.615 +                    }else{
 327.616 +                        int* tagged = veci_begin(&s->tagged);
 327.617 +                        for (j = top; j < veci_size(&s->tagged); j++)
 327.618 +                            tags[tagged[j]] = l_Undef;
 327.619 +                        veci_resize(&s->tagged,top);
 327.620 +                        return false;
 327.621 +                    }
 327.622 +                }
 327.623 +            }
 327.624 +        }
 327.625 +    }
 327.626 +
 327.627 +    return true;
 327.628 +}
 327.629 +
 327.630 +static void solver_analyze(solver* s, clause* c, veci* learnt)
 327.631 +{
 327.632 +    lit*     trail   = s->trail;
 327.633 +    lbool*   tags    = s->tags;
 327.634 +    clause** reasons = s->reasons;
 327.635 +    int*     levels  = s->levels;
 327.636 +    int      cnt     = 0;
 327.637 +    lit      p       = lit_Undef;
 327.638 +    int      ind     = s->qtail-1;
 327.639 +    lit*     lits;
 327.640 +    int      i, j, minl;
 327.641 +    int*     tagged;
 327.642 +
 327.643 +    veci_push(learnt,lit_Undef);
 327.644 +
 327.645 +    do{
 327.646 +        assert(c != 0);
 327.647 +
 327.648 +        if (clause_is_lit(c)){
 327.649 +            lit q = clause_read_lit(c);
 327.650 +            assert(lit_var(q) >= 0 && lit_var(q) < s->size);
 327.651 +            if (tags[lit_var(q)] == l_Undef && levels[lit_var(q)] > 0){
 327.652 +                tags[lit_var(q)] = l_True;
 327.653 +                veci_push(&s->tagged,lit_var(q));
 327.654 +                act_var_bump(s,lit_var(q));
 327.655 +                if (levels[lit_var(q)] == solver_dlevel(s))
 327.656 +                    cnt++;
 327.657 +                else
 327.658 +                    veci_push(learnt,q);
 327.659 +            }
 327.660 +        }else{
 327.661 +
 327.662 +            if (clause_learnt(c))
 327.663 +                act_clause_bump(s,c);
 327.664 +
 327.665 +            lits = clause_begin(c);
 327.666 +            /* printlits(lits,lits+clause_size(c)); printf("\n"); */
 327.667 +            for (j = (p == lit_Undef ? 0 : 1); j < clause_size(c); j++){
 327.668 +                lit q = lits[j];
 327.669 +                assert(lit_var(q) >= 0 && lit_var(q) < s->size);
 327.670 +                if (tags[lit_var(q)] == l_Undef
 327.671 +                    && levels[lit_var(q)] > 0){
 327.672 +                    tags[lit_var(q)] = l_True;
 327.673 +                    veci_push(&s->tagged,lit_var(q));
 327.674 +                    act_var_bump(s,lit_var(q));
 327.675 +                    if (levels[lit_var(q)] == solver_dlevel(s))
 327.676 +                        cnt++;
 327.677 +                    else
 327.678 +                        veci_push(learnt,q);
 327.679 +                }
 327.680 +            }
 327.681 +        }
 327.682 +
 327.683 +        while (tags[lit_var(trail[ind--])] == l_Undef);
 327.684 +
 327.685 +        p = trail[ind+1];
 327.686 +        c = reasons[lit_var(p)];
 327.687 +        cnt--;
 327.688 +
 327.689 +    }while (cnt > 0);
 327.690 +
 327.691 +    *veci_begin(learnt) = lit_neg(p);
 327.692 +
 327.693 +    lits = veci_begin(learnt);
 327.694 +    minl = 0;
 327.695 +    for (i = 1; i < veci_size(learnt); i++){
 327.696 +        int lev = levels[lit_var(lits[i])];
 327.697 +        minl    |= 1 << (lev & 31);
 327.698 +    }
 327.699 +
 327.700 +    /* simplify (full) */
 327.701 +    for (i = j = 1; i < veci_size(learnt); i++){
 327.702 +        if (reasons[lit_var(lits[i])] == 0
 327.703 +            || !solver_lit_removable(s,lits[i],minl))
 327.704 +            lits[j++] = lits[i];
 327.705 +    }
 327.706 +
 327.707 +    /* update size of learnt + statistics */
 327.708 +    s->stats.max_literals += veci_size(learnt);
 327.709 +    veci_resize(learnt,j);
 327.710 +    s->stats.tot_literals += j;
 327.711 +
 327.712 +    /* clear tags */
 327.713 +    tagged = veci_begin(&s->tagged);
 327.714 +    for (i = 0; i < veci_size(&s->tagged); i++)
 327.715 +        tags[tagged[i]] = l_Undef;
 327.716 +    veci_resize(&s->tagged,0);
 327.717 +
 327.718 +#ifdef DEBUG
 327.719 +    for (i = 0; i < s->size; i++)
 327.720 +        assert(tags[i] == l_Undef);
 327.721 +#endif
 327.722 +
 327.723 +#ifdef VERBOSEDEBUG
 327.724 +    printf(L_IND"Learnt {", L_ind);
 327.725 +    for (i = 0; i < veci_size(learnt); i++)
 327.726 +        printf(" "L_LIT, L_lit(lits[i]));
 327.727 +#endif
 327.728 +    if (veci_size(learnt) > 1){
 327.729 +        int max_i = 1;
 327.730 +        int max   = levels[lit_var(lits[1])];
 327.731 +        lit tmp;
 327.732 +
 327.733 +        for (i = 2; i < veci_size(learnt); i++)
 327.734 +            if (levels[lit_var(lits[i])] > max){
 327.735 +                max   = levels[lit_var(lits[i])];
 327.736 +                max_i = i;
 327.737 +            }
 327.738 +
 327.739 +        tmp         = lits[1];
 327.740 +        lits[1]     = lits[max_i];
 327.741 +        lits[max_i] = tmp;
 327.742 +    }
 327.743 +#ifdef VERBOSEDEBUG
 327.744 +    {
 327.745 +        int lev = veci_size(learnt) > 1 ? levels[lit_var(lits[1])] : 0;
 327.746 +        printf(" } at level %d\n", lev);
 327.747 +    }
 327.748 +#endif
 327.749 +}
 327.750 +
 327.751 +clause* solver_propagate(solver* s)
 327.752 +{
 327.753 +    lbool*  values = s->assigns;
 327.754 +    clause* confl  = (clause*)0;
 327.755 +    lit*    lits;
 327.756 +
 327.757 +    /* printf("solver_propagate\n"); */
 327.758 +    while (confl == 0 && s->qtail - s->qhead > 0){
 327.759 +        lit  p  = s->trail[s->qhead++];
 327.760 +        vecp* ws = solver_read_wlist(s,p);
 327.761 +        clause **begin = (clause**)vecp_begin(ws);
 327.762 +        clause **end   = begin + vecp_size(ws);
 327.763 +        clause **i, **j;
 327.764 +
 327.765 +        s->stats.propagations++;
 327.766 +        s->simpdb_props--;
 327.767 +
 327.768 +        /* printf("checking lit %d: "L_LIT"\n", veci_size(ws),
 327.769 +               L_lit(p)); */
 327.770 +        for (i = j = begin; i < end; ){
 327.771 +            if (clause_is_lit(*i)){
 327.772 +                *j++ = *i;
 327.773 +                if (!enqueue(s,clause_read_lit(*i),clause_from_lit(p))){
 327.774 +                    confl = s->binary;
 327.775 +                    (clause_begin(confl))[1] = lit_neg(p);
 327.776 +                    (clause_begin(confl))[0] = clause_read_lit(*i++);
 327.777 +
 327.778 +                    /* Copy the remaining watches: */
 327.779 +                    while (i < end)
 327.780 +                        *j++ = *i++;
 327.781 +                }
 327.782 +            }else{
 327.783 +                lit false_lit;
 327.784 +                lbool sig;
 327.785 +
 327.786 +                lits = clause_begin(*i);
 327.787 +
 327.788 +                /* Make sure the false literal is data[1]: */
 327.789 +                false_lit = lit_neg(p);
 327.790 +                if (lits[0] == false_lit){
 327.791 +                    lits[0] = lits[1];
 327.792 +                    lits[1] = false_lit;
 327.793 +                }
 327.794 +                assert(lits[1] == false_lit);
 327.795 +                /* printf("checking clause: ");
 327.796 +                   printlits(lits, lits+clause_size(*i));
 327.797 +                   printf("\n"); */
 327.798 +
 327.799 +                /* If 0th watch is true, then clause is already
 327.800 +                   satisfied. */
 327.801 +                sig = !lit_sign(lits[0]); sig += sig - 1;
 327.802 +                if (values[lit_var(lits[0])] == sig){
 327.803 +                    *j++ = *i;
 327.804 +                }else{
 327.805 +                    /* Look for new watch: */
 327.806 +                    lit* stop = lits + clause_size(*i);
 327.807 +                    lit* k;
 327.808 +                    for (k = lits + 2; k < stop; k++){
 327.809 +                        lbool sig = lit_sign(*k); sig += sig - 1;
 327.810 +                        if (values[lit_var(*k)] != sig){
 327.811 +                            lits[1] = *k;
 327.812 +                            *k = false_lit;
 327.813 +                            vecp_push(solver_read_wlist(s,
 327.814 +                                lit_neg(lits[1])),*i);
 327.815 +                            goto next; }
 327.816 +                    }
 327.817 +
 327.818 +                    *j++ = *i;
 327.819 +                    /* Clause is unit under assignment: */
 327.820 +                    if (!enqueue(s,lits[0], *i)){
 327.821 +                        confl = *i++;
 327.822 +                        /* Copy the remaining watches: */
 327.823 +                        while (i < end)
 327.824 +                            *j++ = *i++;
 327.825 +                    }
 327.826 +                }
 327.827 +            }
 327.828 +        next:
 327.829 +            i++;
 327.830 +        }
 327.831 +
 327.832 +        s->stats.inspects += j - (clause**)vecp_begin(ws);
 327.833 +        vecp_resize(ws,j - (clause**)vecp_begin(ws));
 327.834 +    }
 327.835 +
 327.836 +    return confl;
 327.837 +}
 327.838 +
 327.839 +static inline int clause_cmp (const void* x, const void* y) {
 327.840 +    return clause_size((clause*)x) > 2
 327.841 +           && (clause_size((clause*)y) == 2
 327.842 +               || clause_activity((clause*)x)
 327.843 +                  < clause_activity((clause*)y)) ? -1 : 1; }
 327.844 +
 327.845 +void solver_reducedb(solver* s)
 327.846 +{
 327.847 +    int      i, j;
 327.848 +    double   extra_lim = s->cla_inc / vecp_size(&s->learnts);
 327.849 +             /* Remove any clause below this activity */
 327.850 +    clause** learnts = (clause**)vecp_begin(&s->learnts);
 327.851 +    clause** reasons = s->reasons;
 327.852 +
 327.853 +    sort(vecp_begin(&s->learnts), vecp_size(&s->learnts), clause_cmp);
 327.854 +
 327.855 +    for (i = j = 0; i < vecp_size(&s->learnts) / 2; i++){
 327.856 +        if (clause_size(learnts[i]) > 2
 327.857 +            && reasons[lit_var(*clause_begin(learnts[i]))]
 327.858 +               != learnts[i])
 327.859 +            clause_remove(s,learnts[i]);
 327.860 +        else
 327.861 +            learnts[j++] = learnts[i];
 327.862 +    }
 327.863 +    for (; i < vecp_size(&s->learnts); i++){
 327.864 +        if (clause_size(learnts[i]) > 2
 327.865 +            && reasons[lit_var(*clause_begin(learnts[i]))]
 327.866 +               != learnts[i]
 327.867 +            && clause_activity(learnts[i]) < extra_lim)
 327.868 +            clause_remove(s,learnts[i]);
 327.869 +        else
 327.870 +            learnts[j++] = learnts[i];
 327.871 +    }
 327.872 +
 327.873 +    /* printf("reducedb deleted %d\n", vecp_size(&s->learnts) - j); */
 327.874 +
 327.875 +    vecp_resize(&s->learnts,j);
 327.876 +}
 327.877 +
 327.878 +static lbool solver_search(solver* s, int nof_conflicts,
 327.879 +                           int nof_learnts)
 327.880 +{
 327.881 +    int*    levels          = s->levels;
 327.882 +    double  var_decay       = 0.95;
 327.883 +    double  clause_decay    = 0.999;
 327.884 +    double  random_var_freq = 0.02;
 327.885 +
 327.886 +    int     conflictC       = 0;
 327.887 +    veci    learnt_clause;
 327.888 +
 327.889 +    assert(s->root_level == solver_dlevel(s));
 327.890 +
 327.891 +    s->stats.starts++;
 327.892 +    s->var_decay = (float)(1 / var_decay   );
 327.893 +    s->cla_decay = (float)(1 / clause_decay);
 327.894 +    veci_resize(&s->model,0);
 327.895 +    veci_new(&learnt_clause);
 327.896 +
 327.897 +    for (;;){
 327.898 +        clause* confl = solver_propagate(s);
 327.899 +        if (confl != 0){
 327.900 +            /* CONFLICT */
 327.901 +            int blevel;
 327.902 +
 327.903 +#ifdef VERBOSEDEBUG
 327.904 +            printf(L_IND"**CONFLICT**\n", L_ind);
 327.905 +#endif
 327.906 +            s->stats.conflicts++; conflictC++;
 327.907 +            if (solver_dlevel(s) == s->root_level){
 327.908 +                veci_delete(&learnt_clause);
 327.909 +                return l_False;
 327.910 +            }
 327.911 +
 327.912 +            veci_resize(&learnt_clause,0);
 327.913 +            solver_analyze(s, confl, &learnt_clause);
 327.914 +            blevel = veci_size(&learnt_clause) > 1
 327.915 +                     ? levels[lit_var(veci_begin(&learnt_clause)[1])]
 327.916 +                     : s->root_level;
 327.917 +            blevel = s->root_level > blevel ? s->root_level : blevel;
 327.918 +            solver_canceluntil(s,blevel);
 327.919 +            solver_record(s,&learnt_clause);
 327.920 +            act_var_decay(s);
 327.921 +            act_clause_decay(s);
 327.922 +
 327.923 +        }else{
 327.924 +            /* NO CONFLICT */
 327.925 +            int next;
 327.926 +
 327.927 +            if (nof_conflicts >= 0 && conflictC >= nof_conflicts){
 327.928 +                /* Reached bound on number of conflicts: */
 327.929 +                s->progress_estimate = solver_progress(s);
 327.930 +                solver_canceluntil(s,s->root_level);
 327.931 +                veci_delete(&learnt_clause);
 327.932 +                return l_Undef; }
 327.933 +
 327.934 +            if (solver_dlevel(s) == 0)
 327.935 +                /* Simplify the set of problem clauses: */
 327.936 +                solver_simplify(s);
 327.937 +
 327.938 +            if (nof_learnts >= 0
 327.939 +                && vecp_size(&s->learnts) - s->qtail >= nof_learnts)
 327.940 +                /* Reduce the set of learnt clauses: */
 327.941 +                solver_reducedb(s);
 327.942 +
 327.943 +            /* New variable decision: */
 327.944 +            s->stats.decisions++;
 327.945 +            next = order_select(s,(float)random_var_freq);
 327.946 +
 327.947 +            if (next == var_Undef){
 327.948 +                /* Model found: */
 327.949 +                lbool* values = s->assigns;
 327.950 +                int i;
 327.951 +                for (i = 0; i < s->size; i++)
 327.952 +                    veci_push(&s->model,(int)values[i]);
 327.953 +                solver_canceluntil(s,s->root_level);
 327.954 +                veci_delete(&learnt_clause);
 327.955 +
 327.956 +                /*
 327.957 +                veci apa; veci_new(&apa);
 327.958 +                for (i = 0; i < s->size; i++)
 327.959 +                    veci_push(&apa,(int)(s->model.ptr[i] == l_True
 327.960 +                        ? toLit(i) : lit_neg(toLit(i))));
 327.961 +                printf("model: ");
 327.962 +                printlits((lit*)apa.ptr,
 327.963 +                    (lit*)apa.ptr + veci_size(&apa)); printf("\n");
 327.964 +                veci_delete(&apa);
 327.965 +                */
 327.966 +
 327.967 +                return l_True;
 327.968 +            }
 327.969 +
 327.970 +            assume(s,lit_neg(toLit(next)));
 327.971 +        }
 327.972 +    }
 327.973 +
 327.974 +#if 0 /* by mao; unreachable code */
 327.975 +    return l_Undef; /* cannot happen */
 327.976 +#endif
 327.977 +}
 327.978 +
 327.979 +/*====================================================================*/
 327.980 +/* External solver functions: */
 327.981 +
 327.982 +solver* solver_new(void)
 327.983 +{
 327.984 +    solver* s = (solver*)malloc(sizeof(solver));
 327.985 +
 327.986 +    /* initialize vectors */
 327.987 +    vecp_new(&s->clauses);
 327.988 +    vecp_new(&s->learnts);
 327.989 +    veci_new(&s->order);
 327.990 +    veci_new(&s->trail_lim);
 327.991 +    veci_new(&s->tagged);
 327.992 +    veci_new(&s->stack);
 327.993 +    veci_new(&s->model);
 327.994 +
 327.995 +    /* initialize arrays */
 327.996 +    s->wlists    = 0;
 327.997 +    s->activity  = 0;
 327.998 +    s->assigns   = 0;
 327.999 +    s->orderpos  = 0;
327.1000 +    s->reasons   = 0;
327.1001 +    s->levels    = 0;
327.1002 +    s->tags      = 0;
327.1003 +    s->trail     = 0;
327.1004 +
327.1005 +    /* initialize other vars */
327.1006 +    s->size                   = 0;
327.1007 +    s->cap                    = 0;
327.1008 +    s->qhead                  = 0;
327.1009 +    s->qtail                  = 0;
327.1010 +    s->cla_inc                = 1;
327.1011 +    s->cla_decay              = 1;
327.1012 +    s->var_inc                = 1;
327.1013 +    s->var_decay              = 1;
327.1014 +    s->root_level             = 0;
327.1015 +    s->simpdb_assigns         = 0;
327.1016 +    s->simpdb_props           = 0;
327.1017 +    s->random_seed            = 91648253;
327.1018 +    s->progress_estimate      = 0;
327.1019 +    s->binary                 = (clause*)malloc(sizeof(clause)
327.1020 +                                                + sizeof(lit)*2);
327.1021 +    s->binary->size_learnt    = (2 << 1);
327.1022 +    s->verbosity              = 0;
327.1023 +
327.1024 +    s->stats.starts           = 0;
327.1025 +    s->stats.decisions        = 0;
327.1026 +    s->stats.propagations     = 0;
327.1027 +    s->stats.inspects         = 0;
327.1028 +    s->stats.conflicts        = 0;
327.1029 +    s->stats.clauses          = 0;
327.1030 +    s->stats.clauses_literals = 0;
327.1031 +    s->stats.learnts          = 0;
327.1032 +    s->stats.learnts_literals = 0;
327.1033 +    s->stats.max_literals     = 0;
327.1034 +    s->stats.tot_literals     = 0;
327.1035 +
327.1036 +    return s;
327.1037 +}
327.1038 +
327.1039 +void solver_delete(solver* s)
327.1040 +{
327.1041 +    int i;
327.1042 +    for (i = 0; i < vecp_size(&s->clauses); i++)
327.1043 +        free(vecp_begin(&s->clauses)[i]);
327.1044 +
327.1045 +    for (i = 0; i < vecp_size(&s->learnts); i++)
327.1046 +        free(vecp_begin(&s->learnts)[i]);
327.1047 +
327.1048 +    /* delete vectors */
327.1049 +    vecp_delete(&s->clauses);
327.1050 +    vecp_delete(&s->learnts);
327.1051 +    veci_delete(&s->order);
327.1052 +    veci_delete(&s->trail_lim);
327.1053 +    veci_delete(&s->tagged);
327.1054 +    veci_delete(&s->stack);
327.1055 +    veci_delete(&s->model);
327.1056 +    free(s->binary);
327.1057 +
327.1058 +    /* delete arrays */
327.1059 +    if (s->wlists != 0){
327.1060 +        int i;
327.1061 +        for (i = 0; i < s->size*2; i++)
327.1062 +            vecp_delete(&s->wlists[i]);
327.1063 +
327.1064 +        /* if one is different from null, all are */
327.1065 +        free(s->wlists);
327.1066 +        free(s->activity );
327.1067 +        free(s->assigns  );
327.1068 +        free(s->orderpos );
327.1069 +        free(s->reasons  );
327.1070 +        free(s->levels   );
327.1071 +        free(s->trail    );
327.1072 +        free(s->tags     );
327.1073 +    }
327.1074 +
327.1075 +    free(s);
327.1076 +}
327.1077 +
327.1078 +bool solver_addclause(solver* s, lit* begin, lit* end)
327.1079 +{
327.1080 +    lit *i,*j;
327.1081 +    int maxvar;
327.1082 +    lbool* values;
327.1083 +    lit last;
327.1084 +
327.1085 +    if (begin == end) return false;
327.1086 +
327.1087 +    /* printlits(begin,end); printf("\n"); */
327.1088 +    /* insertion sort */
327.1089 +    maxvar = lit_var(*begin);
327.1090 +    for (i = begin + 1; i < end; i++){
327.1091 +        lit l = *i;
327.1092 +        maxvar = lit_var(l) > maxvar ? lit_var(l) : maxvar;
327.1093 +        for (j = i; j > begin && *(j-1) > l; j--)
327.1094 +            *j = *(j-1);
327.1095 +        *j = l;
327.1096 +    }
327.1097 +    solver_setnvars(s,maxvar+1);
327.1098 +
327.1099 +    /* printlits(begin,end); printf("\n"); */
327.1100 +    values = s->assigns;
327.1101 +
327.1102 +    /* delete duplicates */
327.1103 +    last = lit_Undef;
327.1104 +    for (i = j = begin; i < end; i++){
327.1105 +        /* printf("lit: "L_LIT", value = %d\n", L_lit(*i),
327.1106 +        (lit_sign(*i) ? -values[lit_var(*i)] : values[lit_var(*i)])); */
327.1107 +        lbool sig = !lit_sign(*i); sig += sig - 1;
327.1108 +        if (*i == lit_neg(last) || sig == values[lit_var(*i)])
327.1109 +            return true;   /* tautology */
327.1110 +        else if (*i != last && values[lit_var(*i)] == l_Undef)
327.1111 +            last = *j++ = *i;
327.1112 +    }
327.1113 +
327.1114 +    /* printf("final: "); printlits(begin,j); printf("\n"); */
327.1115 +
327.1116 +    if (j == begin)          /* empty clause */
327.1117 +        return false;
327.1118 +    else if (j - begin == 1) /* unit clause */
327.1119 +        return enqueue(s,*begin,(clause*)0);
327.1120 +
327.1121 +    /* create new clause */
327.1122 +    vecp_push(&s->clauses,clause_new(s,begin,j,0));
327.1123 +
327.1124 +    s->stats.clauses++;
327.1125 +    s->stats.clauses_literals += j - begin;
327.1126 +
327.1127 +    return true;
327.1128 +}
327.1129 +
327.1130 +bool   solver_simplify(solver* s)
327.1131 +{
327.1132 +    clause** reasons;
327.1133 +    int type;
327.1134 +
327.1135 +    assert(solver_dlevel(s) == 0);
327.1136 +
327.1137 +    if (solver_propagate(s) != 0)
327.1138 +        return false;
327.1139 +
327.1140 +    if (s->qhead == s->simpdb_assigns || s->simpdb_props > 0)
327.1141 +        return true;
327.1142 +
327.1143 +    reasons = s->reasons;
327.1144 +    for (type = 0; type < 2; type++){
327.1145 +        vecp*    cs  = type ? &s->learnts : &s->clauses;
327.1146 +        clause** cls = (clause**)vecp_begin(cs);
327.1147 +
327.1148 +        int i, j;
327.1149 +        for (j = i = 0; i < vecp_size(cs); i++){
327.1150 +            if (reasons[lit_var(*clause_begin(cls[i]))] != cls[i] &&
327.1151 +                clause_simplify(s,cls[i]) == l_True)
327.1152 +                clause_remove(s,cls[i]);
327.1153 +            else
327.1154 +                cls[j++] = cls[i];
327.1155 +        }
327.1156 +        vecp_resize(cs,j);
327.1157 +    }
327.1158 +
327.1159 +    s->simpdb_assigns = s->qhead;
327.1160 +    /* (shouldn't depend on 'stats' really, but it will do for now) */
327.1161 +    s->simpdb_props   = (int)(s->stats.clauses_literals
327.1162 +                              + s->stats.learnts_literals);
327.1163 +
327.1164 +    return true;
327.1165 +}
327.1166 +
327.1167 +bool   solver_solve(solver* s, lit* begin, lit* end)
327.1168 +{
327.1169 +    double  nof_conflicts = 100;
327.1170 +    double  nof_learnts   = solver_nclauses(s) / 3;
327.1171 +    lbool   status        = l_Undef;
327.1172 +    lbool*  values        = s->assigns;
327.1173 +    lit*    i;
327.1174 +
327.1175 +    /* printf("solve: "); printlits(begin, end); printf("\n"); */
327.1176 +    for (i = begin; i < end; i++){
327.1177 +        switch (lit_sign(*i) ? -values[lit_var(*i)]
327.1178 +                             : values[lit_var(*i)]){
327.1179 +        case 1: /* l_True: */
327.1180 +            break;
327.1181 +        case 0: /* l_Undef */
327.1182 +            assume(s, *i);
327.1183 +            if (solver_propagate(s) == NULL)
327.1184 +                break;
327.1185 +            /* falltrough */
327.1186 +        case -1: /* l_False */
327.1187 +            solver_canceluntil(s, 0);
327.1188 +            return false;
327.1189 +        }
327.1190 +    }
327.1191 +
327.1192 +    s->root_level = solver_dlevel(s);
327.1193 +
327.1194 +    if (s->verbosity >= 1){
327.1195 +        printf("==================================[MINISAT]============"
327.1196 +               "=======================\n");
327.1197 +        printf("| Conflicts |     ORIGINAL     |              LEARNT   "
327.1198 +               "           | Progress |\n");
327.1199 +        printf("|           | Clauses Literals |   Limit Clauses Litera"
327.1200 +               "ls  Lit/Cl |          |\n");
327.1201 +        printf("======================================================="
327.1202 +               "=======================\n");
327.1203 +    }
327.1204 +
327.1205 +    while (status == l_Undef){
327.1206 +        double Ratio = (s->stats.learnts == 0)? 0.0 :
327.1207 +            s->stats.learnts_literals / (double)s->stats.learnts;
327.1208 +
327.1209 +        if (s->verbosity >= 1){
327.1210 +            printf("| %9.0f | %7.0f %8.0f | %7.0f %7.0f %8.0f %7.1f | %"
327.1211 +                   "6.3f %% |\n",
327.1212 +                (double)s->stats.conflicts,
327.1213 +                (double)s->stats.clauses,
327.1214 +                (double)s->stats.clauses_literals,
327.1215 +                (double)nof_learnts,
327.1216 +                (double)s->stats.learnts,
327.1217 +                (double)s->stats.learnts_literals,
327.1218 +                Ratio,
327.1219 +                s->progress_estimate*100);
327.1220 +            fflush(stdout);
327.1221 +        }
327.1222 +        status = solver_search(s,(int)nof_conflicts, (int)nof_learnts);
327.1223 +        nof_conflicts *= 1.5;
327.1224 +        nof_learnts   *= 1.1;
327.1225 +    }
327.1226 +    if (s->verbosity >= 1)
327.1227 +        printf("======================================================="
327.1228 +               "=======================\n");
327.1229 +
327.1230 +    solver_canceluntil(s,0);
327.1231 +    return status != l_False;
327.1232 +}
327.1233 +
327.1234 +int solver_nvars(solver* s)
327.1235 +{
327.1236 +    return s->size;
327.1237 +}
327.1238 +
327.1239 +int solver_nclauses(solver* s)
327.1240 +{
327.1241 +    return vecp_size(&s->clauses);
327.1242 +}
327.1243 +
327.1244 +int solver_nconflicts(solver* s)
327.1245 +{
327.1246 +    return (int)s->stats.conflicts;
327.1247 +}
327.1248 +
327.1249 +/*====================================================================*/
327.1250 +/* Sorting functions (sigh): */
327.1251 +
327.1252 +static inline void selectionsort(void** array, int size,
327.1253 +                                 int(*comp)(const void *, const void *))
327.1254 +{
327.1255 +    int     i, j, best_i;
327.1256 +    void*   tmp;
327.1257 +
327.1258 +    for (i = 0; i < size-1; i++){
327.1259 +        best_i = i;
327.1260 +        for (j = i+1; j < size; j++){
327.1261 +            if (comp(array[j], array[best_i]) < 0)
327.1262 +                best_i = j;
327.1263 +        }
327.1264 +        tmp = array[i]; array[i] = array[best_i]; array[best_i] = tmp;
327.1265 +    }
327.1266 +}
327.1267 +
327.1268 +static void sortrnd(void** array, int size,
327.1269 +                    int(*comp)(const void *, const void *),
327.1270 +                    double* seed)
327.1271 +{
327.1272 +    if (size <= 15)
327.1273 +        selectionsort(array, size, comp);
327.1274 +
327.1275 +    else{
327.1276 +        void*       pivot = array[irand(seed, size)];
327.1277 +        void*       tmp;
327.1278 +        int         i = -1;
327.1279 +        int         j = size;
327.1280 +
327.1281 +        for(;;){
327.1282 +            do i++; while(comp(array[i], pivot)<0);
327.1283 +            do j--; while(comp(pivot, array[j])<0);
327.1284 +
327.1285 +            if (i >= j) break;
327.1286 +
327.1287 +            tmp = array[i]; array[i] = array[j]; array[j] = tmp;
327.1288 +        }
327.1289 +
327.1290 +        sortrnd(array    , i     , comp, seed);
327.1291 +        sortrnd(&array[i], size-i, comp, seed);
327.1292 +    }
327.1293 +}
327.1294 +
327.1295 +static void sort(void** array, int size,
327.1296 +          int(*comp)(const void *, const void *))
327.1297 +{
327.1298 +    double seed = 91648253;
327.1299 +    sortrnd(array,size,comp,&seed);
327.1300 +}
327.1301 +
327.1302 +/* eof */
   328.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
   328.2 +++ b/deps/glpk/src/minisat/minisat.h	Sun Nov 06 20:59:10 2011 +0100
   328.3 @@ -0,0 +1,230 @@
   328.4 +/* minisat.h */
   328.5 +
   328.6 +/* Modified by Andrew Makhorin <mao@gnu.org>, August 2011 */
   328.7 +
   328.8 +/***********************************************************************
   328.9 +*  MiniSat -- Copyright (c) 2005, Niklas Sorensson
  328.10 +*  http://www.cs.chalmers.se/Cs/Research/FormalMethods/MiniSat/
  328.11 +*
  328.12 +*  Permission is hereby granted, free of charge, to any person
  328.13 +*  obtaining a copy of this software and associated documentation files
  328.14 +*  (the "Software"), to deal in the Software without restriction,
  328.15 +*  including without limitation the rights to use, copy, modify, merge,
  328.16 +*  publish, distribute, sublicense, and/or sell copies of the Software,
  328.17 +*  and to permit persons to whom the Software is furnished to do so,
  328.18 +*  subject to the following conditions:
  328.19 +*
  328.20 +*  The above copyright notice and this permission notice shall be
  328.21 +*  included in all copies or substantial portions of the Software.
  328.22 +*
  328.23 +*  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  328.24 +*  EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  328.25 +*  MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
  328.26 +*  NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
  328.27 +*  BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
  328.28 +*  ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
  328.29 +*  CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  328.30 +*  SOFTWARE.
  328.31 +***********************************************************************/
  328.32 +/* Modified to compile with MS Visual Studio 6.0 by Alan Mishchenko */
  328.33 +
  328.34 +#ifndef MINISAT_H
  328.35 +#define MINISAT_H
  328.36 +
  328.37 +/*====================================================================*/
  328.38 +/* Simple types: */
  328.39 +
  328.40 +typedef int bool;
  328.41 +
  328.42 +#define true  1
  328.43 +#define false 0
  328.44 +
  328.45 +typedef int  lit;
  328.46 +#if 0 /* by mao */
  328.47 +typedef char lbool;
  328.48 +#else
  328.49 +typedef int lbool;
  328.50 +#endif
  328.51 +
  328.52 +#define var_Undef (int)(-1)
  328.53 +#define lit_Undef (lit)(-2)
  328.54 +
  328.55 +#define l_Undef (lbool)0
  328.56 +#define l_True  (lbool)1
  328.57 +#define l_False (lbool)(-1)
  328.58 +
  328.59 +#define toLit(v) (lit)((v) + (v))
  328.60 +#define lit_neg(l) (lit)((l) ^ 1)
  328.61 +#define lit_var(l) (int)((l) >> 1)
  328.62 +#define lit_sign(l) (int)((l) & 1)
  328.63 +
  328.64 +/*====================================================================*/
  328.65 +/* Vectors: */
  328.66 +
  328.67 +/* vector of 32-bit intergers (added for 64-bit portability) */
  328.68 +typedef struct /* veci_t */ {
  328.69 +    int    size;
  328.70 +    int    cap;
  328.71 +    int*   ptr;
  328.72 +} veci;
  328.73 +
  328.74 +#define veci_new(v) \
  328.75 +{   (v)->size = 0; \
  328.76 +    (v)->cap  = 4; \
  328.77 +    (v)->ptr  = (int*)malloc(sizeof(int)*(v)->cap); \
  328.78 +}
  328.79 +
  328.80 +#define veci_delete(v) free((v)->ptr)
  328.81 +
  328.82 +#define veci_begin(v) ((v)->ptr)
  328.83 +
  328.84 +#define veci_size(v) ((v)->size)
  328.85 +
  328.86 +#define veci_resize(v, k) (void)((v)->size = (k))
  328.87 +/* only safe to shrink !! */
  328.88 +
  328.89 +#define veci_push(v, e) \
  328.90 +{   if ((v)->size == (v)->cap) \
  328.91 +    {   int newsize = (v)->cap * 2+1; \
  328.92 +        (v)->ptr = (int*)realloc((v)->ptr,sizeof(int)*newsize); \
  328.93 +        (v)->cap = newsize; \
  328.94 +    } \
  328.95 +    (v)->ptr[(v)->size++] = (e); \
  328.96 +}
  328.97 +
  328.98 +/* vector of 32- or 64-bit pointers */
  328.99 +typedef struct /* vecp_t */ {
 328.100 +    int    size;
 328.101 +    int    cap;
 328.102 +    void** ptr;
 328.103 +} vecp;
 328.104 +
 328.105 +#define vecp_new(v) \
 328.106 +{   (v)->size = 0; \
 328.107 +    (v)->cap  = 4; \
 328.108 +    (v)->ptr  = (void**)malloc(sizeof(void*)*(v)->cap); \
 328.109 +}
 328.110 +
 328.111 +#define vecp_delete(v) free((v)->ptr)
 328.112 +
 328.113 +#define vecp_begin(v) ((v)->ptr)
 328.114 +
 328.115 +#define vecp_size(v) ((v)->size)
 328.116 +
 328.117 +#define vecp_resize(v, k) (void)((v)->size = (k))
 328.118 +/* only safe to shrink !! */
 328.119 +
 328.120 +#define vecp_push(v, e) \
 328.121 +{   if ((v)->size == (v)->cap) \
 328.122 +    {   int newsize = (v)->cap * 2+1; \
 328.123 +        (v)->ptr = (void**)realloc((v)->ptr,sizeof(void*)*newsize); \
 328.124 +        (v)->cap = newsize; \
 328.125 +    } \
 328.126 +    (v)->ptr[(v)->size++] = (e); \
 328.127 +}
 328.128 +
 328.129 +/*====================================================================*/
 328.130 +/* Solver representation: */
 328.131 +
 328.132 +typedef struct /* clause_t */
 328.133 +{
 328.134 +    int size_learnt;
 328.135 +    lit lits[1];
 328.136 +} clause;
 328.137 +
 328.138 +typedef struct /* stats_t */
 328.139 +{
 328.140 +    double   starts, decisions, propagations, inspects, conflicts;
 328.141 +    double   clauses, clauses_literals, learnts, learnts_literals,
 328.142 +             max_literals, tot_literals;
 328.143 +} stats;
 328.144 +
 328.145 +typedef struct /* solver_t */
 328.146 +{
 328.147 +    int      size;          /* nof variables */
 328.148 +    int      cap;           /* size of varmaps */
 328.149 +    int      qhead;         /* Head index of queue. */
 328.150 +    int      qtail;         /* Tail index of queue. */
 328.151 +
 328.152 +    /* clauses */
 328.153 +    vecp     clauses;       /* List of problem constraints.
 328.154 +                               (contains: clause*) */
 328.155 +    vecp     learnts;       /* List of learnt clauses.
 328.156 +                               (contains: clause*) */
 328.157 +
 328.158 +    /* activities */
 328.159 +    double   var_inc;       /* Amount to bump next variable with. */
 328.160 +    double   var_decay;     /* INVERSE decay factor for variable
 328.161 +                               activity: stores 1/decay. */
 328.162 +    float    cla_inc;       /* Amount to bump next clause with. */
 328.163 +    float    cla_decay;     /* INVERSE decay factor for clause
 328.164 +                               activity: stores 1/decay. */
 328.165 +
 328.166 +    vecp*    wlists;
 328.167 +    double*  activity;      /* A heuristic measurement of the activity
 328.168 +                               of a variable. */
 328.169 +    lbool*   assigns;       /* Current values of variables. */
 328.170 +    int*     orderpos;      /* Index in variable order. */
 328.171 +    clause** reasons;
 328.172 +    int*     levels;
 328.173 +    lit*     trail;
 328.174 +
 328.175 +    clause*  binary;        /* A temporary binary clause */
 328.176 +    lbool*   tags;
 328.177 +    veci     tagged;        /* (contains: var) */
 328.178 +    veci     stack;         /* (contains: var) */
 328.179 +
 328.180 +    veci     order;         /* Variable order. (heap) (contains: var) */
 328.181 +    veci     trail_lim;     /* Separator indices for different decision
 328.182 +                               levels in 'trail'. (contains: int) */
 328.183 +    veci     model;         /* If problem is solved, this vector
 328.184 +                               contains the model (contains: lbool). */
 328.185 +
 328.186 +    int      root_level;    /* Level of first proper decision. */
 328.187 +    int      simpdb_assigns;/* Number of top-level assignments at last
 328.188 +                               'simplifyDB()'. */
 328.189 +    int      simpdb_props;  /* Number of propagations before next
 328.190 +                               'simplifyDB()'. */
 328.191 +    double   random_seed;
 328.192 +    double   progress_estimate;
 328.193 +    int      verbosity;     /* Verbosity level.
 328.194 +                               0=silent,
 328.195 +                               1=some progress report,
 328.196 +                               2=everything */
 328.197 +
 328.198 +    stats    stats;
 328.199 +} solver;
 328.200 +
 328.201 +/*====================================================================*/
 328.202 +/* Public interface: */
 328.203 +
 328.204 +#if 1 /* by mao; to keep namespace clean */
 328.205 +#define solver_new        _glp_minisat_new
 328.206 +#define solver_delete     _glp_minisat_delete
 328.207 +#define solver_addclause  _glp_minisat_addclause
 328.208 +#define solver_simplify   _glp_minisat_simplify
 328.209 +#define solver_solve      _glp_minisat_solve
 328.210 +#define solver_nvars      _glp_minisat_nvars
 328.211 +#define solver_nclauses   _glp_minisat_nclauses
 328.212 +#define solver_nconflicts _glp_minisat_nconflicts
 328.213 +#define solver_setnvars   _glp_minisat_setnvars
 328.214 +#define solver_propagate  _glp_minisat_propagate
 328.215 +#define solver_reducedb   _glp_minisat_reducedb
 328.216 +#endif
 328.217 +
 328.218 +solver* solver_new(void);
 328.219 +void    solver_delete(solver* s);
 328.220 +
 328.221 +bool    solver_addclause(solver* s, lit* begin, lit* end);
 328.222 +bool    solver_simplify(solver* s);
 328.223 +bool    solver_solve(solver* s, lit* begin, lit* end);
 328.224 +
 328.225 +int     solver_nvars(solver* s);
 328.226 +int     solver_nclauses(solver* s);
 328.227 +int     solver_nconflicts(solver* s);
 328.228 +
 328.229 +void    solver_setnvars(solver* s,int n);
 328.230 +
 328.231 +#endif
 328.232 +
 328.233 +/* eof */
   329.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
   329.2 +++ b/deps/glpk/src/zlib/README	Sun Nov 06 20:59:10 2011 +0100
   329.3 @@ -0,0 +1,45 @@
   329.4 +NOTE: Files in this subdirectory are NOT part of the GLPK package, but
   329.5 +      are used with GLPK.
   329.6 +
   329.7 +      The original code was modified according to GLPK requirements by
   329.8 +      Andrew Makhorin <mao@gnu.org>.
   329.9 +
  329.10 +      The following files were rewritten:
  329.11 +      gzguts.h, zconf.h, zutil.h.
  329.12 +
  329.13 +      The following files were added:
  329.14 +      zio.h, zio.c.
  329.15 +
  329.16 +      Other files were not changed.
  329.17 +************************************************************************
  329.18 +zlib general purpose compression library
  329.19 +version 1.2.5, April 19th, 2010
  329.20 +
  329.21 +Copyright (C) 1995-2010 Jean-loup Gailly and Mark Adler
  329.22 +
  329.23 +This software is provided 'as-is', without any express or implied
  329.24 +warranty. In no event will the authors be held liable for any damages
  329.25 +arising from the use of this software.
  329.26 +
  329.27 +Permission is granted to anyone to use this software for any purpose,
  329.28 +including commercial applications, and to alter it and redistribute it
  329.29 +freely, subject to the following restrictions:
  329.30 +
  329.31 +1. The origin of this software must not be misrepresented; you must not
  329.32 +   claim that you wrote the original software. If you use this software
  329.33 +   in a product, an acknowledgment in the product documentation would
  329.34 +   be appreciated but is not required.
  329.35 +
  329.36 +2. Altered source versions must be plainly marked as such, and must not
  329.37 +   be misrepresented as being the original software.
  329.38 +
  329.39 +3. This notice may not be removed or altered from any source
  329.40 +   distribution.
  329.41 +
  329.42 +Jean-loup Gailly        Mark Adler
  329.43 +jloup@gzip.org          madler@alumni.caltech.edu
  329.44 +
  329.45 +The data format used by the zlib library is described by RFCs (Request
  329.46 +for Comments) 1950 to 1952 in the files
  329.47 +http://www.ietf.org/rfc/rfc1950.txt (zlib format), rfc1951.txt (deflate
  329.48 +format) and rfc1952.txt (gzip format).
   330.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
   330.2 +++ b/deps/glpk/src/zlib/adler32.c	Sun Nov 06 20:59:10 2011 +0100
   330.3 @@ -0,0 +1,169 @@
   330.4 +/* adler32.c -- compute the Adler-32 checksum of a data stream
   330.5 + * Copyright (C) 1995-2007 Mark Adler
   330.6 + * For conditions of distribution and use, see copyright notice in zlib.h
   330.7 + */
   330.8 +
   330.9 +/* @(#) $Id$ */
  330.10 +
  330.11 +#include "zutil.h"
  330.12 +
  330.13 +#define local static
  330.14 +
  330.15 +local uLong adler32_combine_(uLong adler1, uLong adler2, z_off64_t len2);
  330.16 +
  330.17 +#define BASE 65521UL    /* largest prime smaller than 65536 */
  330.18 +#define NMAX 5552
  330.19 +/* NMAX is the largest n such that 255n(n+1)/2 + (n+1)(BASE-1) <= 2^32-1 */
  330.20 +
  330.21 +#define DO1(buf,i)  {adler += (buf)[i]; sum2 += adler;}
  330.22 +#define DO2(buf,i)  DO1(buf,i); DO1(buf,i+1);
  330.23 +#define DO4(buf,i)  DO2(buf,i); DO2(buf,i+2);
  330.24 +#define DO8(buf,i)  DO4(buf,i); DO4(buf,i+4);
  330.25 +#define DO16(buf)   DO8(buf,0); DO8(buf,8);
  330.26 +
  330.27 +/* use NO_DIVIDE if your processor does not do division in hardware */
  330.28 +#ifdef NO_DIVIDE
  330.29 +#  define MOD(a) \
  330.30 +    do { \
  330.31 +        if (a >= (BASE << 16)) a -= (BASE << 16); \
  330.32 +        if (a >= (BASE << 15)) a -= (BASE << 15); \
  330.33 +        if (a >= (BASE << 14)) a -= (BASE << 14); \
  330.34 +        if (a >= (BASE << 13)) a -= (BASE << 13); \
  330.35 +        if (a >= (BASE << 12)) a -= (BASE << 12); \
  330.36 +        if (a >= (BASE << 11)) a -= (BASE << 11); \
  330.37 +        if (a >= (BASE << 10)) a -= (BASE << 10); \
  330.38 +        if (a >= (BASE << 9)) a -= (BASE << 9); \
  330.39 +        if (a >= (BASE << 8)) a -= (BASE << 8); \
  330.40 +        if (a >= (BASE << 7)) a -= (BASE << 7); \
  330.41 +        if (a >= (BASE << 6)) a -= (BASE << 6); \
  330.42 +        if (a >= (BASE << 5)) a -= (BASE << 5); \
  330.43 +        if (a >= (BASE << 4)) a -= (BASE << 4); \
  330.44 +        if (a >= (BASE << 3)) a -= (BASE << 3); \
  330.45 +        if (a >= (BASE << 2)) a -= (BASE << 2); \
  330.46 +        if (a >= (BASE << 1)) a -= (BASE << 1); \
  330.47 +        if (a >= BASE) a -= BASE; \
  330.48 +    } while (0)
  330.49 +#  define MOD4(a) \
  330.50 +    do { \
  330.51 +        if (a >= (BASE << 4)) a -= (BASE << 4); \
  330.52 +        if (a >= (BASE << 3)) a -= (BASE << 3); \
  330.53 +        if (a >= (BASE << 2)) a -= (BASE << 2); \
  330.54 +        if (a >= (BASE << 1)) a -= (BASE << 1); \
  330.55 +        if (a >= BASE) a -= BASE; \
  330.56 +    } while (0)
  330.57 +#else
  330.58 +#  define MOD(a) a %= BASE
  330.59 +#  define MOD4(a) a %= BASE
  330.60 +#endif
  330.61 +
  330.62 +/* ========================================================================= */
  330.63 +uLong ZEXPORT adler32(adler, buf, len)
  330.64 +    uLong adler;
  330.65 +    const Bytef *buf;
  330.66 +    uInt len;
  330.67 +{
  330.68 +    unsigned long sum2;
  330.69 +    unsigned n;
  330.70 +
  330.71 +    /* split Adler-32 into component sums */
  330.72 +    sum2 = (adler >> 16) & 0xffff;
  330.73 +    adler &= 0xffff;
  330.74 +
  330.75 +    /* in case user likes doing a byte at a time, keep it fast */
  330.76 +    if (len == 1) {
  330.77 +        adler += buf[0];
  330.78 +        if (adler >= BASE)
  330.79 +            adler -= BASE;
  330.80 +        sum2 += adler;
  330.81 +        if (sum2 >= BASE)
  330.82 +            sum2 -= BASE;
  330.83 +        return adler | (sum2 << 16);
  330.84 +    }
  330.85 +
  330.86 +    /* initial Adler-32 value (deferred check for len == 1 speed) */
  330.87 +    if (buf == Z_NULL)
  330.88 +        return 1L;
  330.89 +
  330.90 +    /* in case short lengths are provided, keep it somewhat fast */
  330.91 +    if (len < 16) {
  330.92 +        while (len--) {
  330.93 +            adler += *buf++;
  330.94 +            sum2 += adler;
  330.95 +        }
  330.96 +        if (adler >= BASE)
  330.97 +            adler -= BASE;
  330.98 +        MOD4(sum2);             /* only added so many BASE's */
  330.99 +        return adler | (sum2 << 16);
 330.100 +    }
 330.101 +
 330.102 +    /* do length NMAX blocks -- requires just one modulo operation */
 330.103 +    while (len >= NMAX) {
 330.104 +        len -= NMAX;
 330.105 +        n = NMAX / 16;          /* NMAX is divisible by 16 */
 330.106 +        do {
 330.107 +            DO16(buf);          /* 16 sums unrolled */
 330.108 +            buf += 16;
 330.109 +        } while (--n);
 330.110 +        MOD(adler);
 330.111 +        MOD(sum2);
 330.112 +    }
 330.113 +
 330.114 +    /* do remaining bytes (less than NMAX, still just one modulo) */
 330.115 +    if (len) {                  /* avoid modulos if none remaining */
 330.116 +        while (len >= 16) {
 330.117 +            len -= 16;
 330.118 +            DO16(buf);
 330.119 +            buf += 16;
 330.120 +        }
 330.121 +        while (len--) {
 330.122 +            adler += *buf++;
 330.123 +            sum2 += adler;
 330.124 +        }
 330.125 +        MOD(adler);
 330.126 +        MOD(sum2);
 330.127 +    }
 330.128 +
 330.129 +    /* return recombined sums */
 330.130 +    return adler | (sum2 << 16);
 330.131 +}
 330.132 +
 330.133 +/* ========================================================================= */
 330.134 +local uLong adler32_combine_(adler1, adler2, len2)
 330.135 +    uLong adler1;
 330.136 +    uLong adler2;
 330.137 +    z_off64_t len2;
 330.138 +{
 330.139 +    unsigned long sum1;
 330.140 +    unsigned long sum2;
 330.141 +    unsigned rem;
 330.142 +
 330.143 +    /* the derivation of this formula is left as an exercise for the reader */
 330.144 +    rem = (unsigned)(len2 % BASE);
 330.145 +    sum1 = adler1 & 0xffff;
 330.146 +    sum2 = rem * sum1;
 330.147 +    MOD(sum2);
 330.148 +    sum1 += (adler2 & 0xffff) + BASE - 1;
 330.149 +    sum2 += ((adler1 >> 16) & 0xffff) + ((adler2 >> 16) & 0xffff) + BASE - rem;
 330.150 +    if (sum1 >= BASE) sum1 -= BASE;
 330.151 +    if (sum1 >= BASE) sum1 -= BASE;
 330.152 +    if (sum2 >= (BASE << 1)) sum2 -= (BASE << 1);
 330.153 +    if (sum2 >= BASE) sum2 -= BASE;
 330.154 +    return sum1 | (sum2 << 16);
 330.155 +}
 330.156 +
 330.157 +/* ========================================================================= */
 330.158 +uLong ZEXPORT adler32_combine(adler1, adler2, len2)
 330.159 +    uLong adler1;
 330.160 +    uLong adler2;
 330.161 +    z_off_t len2;
 330.162 +{
 330.163 +    return adler32_combine_(adler1, adler2, len2);
 330.164 +}
 330.165 +
 330.166 +uLong ZEXPORT adler32_combine64(adler1, adler2, len2)
 330.167 +    uLong adler1;
 330.168 +    uLong adler2;
 330.169 +    z_off64_t len2;
 330.170 +{
 330.171 +    return adler32_combine_(adler1, adler2, len2);
 330.172 +}
   331.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
   331.2 +++ b/deps/glpk/src/zlib/compress.c	Sun Nov 06 20:59:10 2011 +0100
   331.3 @@ -0,0 +1,80 @@
   331.4 +/* compress.c -- compress a memory buffer
   331.5 + * Copyright (C) 1995-2005 Jean-loup Gailly.
   331.6 + * For conditions of distribution and use, see copyright notice in zlib.h
   331.7 + */
   331.8 +
   331.9 +/* @(#) $Id$ */
  331.10 +
  331.11 +#define ZLIB_INTERNAL
  331.12 +#include "zlib.h"
  331.13 +
  331.14 +/* ===========================================================================
  331.15 +     Compresses the source buffer into the destination buffer. The level
  331.16 +   parameter has the same meaning as in deflateInit.  sourceLen is the byte
  331.17 +   length of the source buffer. Upon entry, destLen is the total size of the
  331.18 +   destination buffer, which must be at least 0.1% larger than sourceLen plus
  331.19 +   12 bytes. Upon exit, destLen is the actual size of the compressed buffer.
  331.20 +
  331.21 +     compress2 returns Z_OK if success, Z_MEM_ERROR if there was not enough
  331.22 +   memory, Z_BUF_ERROR if there was not enough room in the output buffer,
  331.23 +   Z_STREAM_ERROR if the level parameter is invalid.
  331.24 +*/
  331.25 +int ZEXPORT compress2 (dest, destLen, source, sourceLen, level)
  331.26 +    Bytef *dest;
  331.27 +    uLongf *destLen;
  331.28 +    const Bytef *source;
  331.29 +    uLong sourceLen;
  331.30 +    int level;
  331.31 +{
  331.32 +    z_stream stream;
  331.33 +    int err;
  331.34 +
  331.35 +    stream.next_in = (Bytef*)source;
  331.36 +    stream.avail_in = (uInt)sourceLen;
  331.37 +#ifdef MAXSEG_64K
  331.38 +    /* Check for source > 64K on 16-bit machine: */
  331.39 +    if ((uLong)stream.avail_in != sourceLen) return Z_BUF_ERROR;
  331.40 +#endif
  331.41 +    stream.next_out = dest;
  331.42 +    stream.avail_out = (uInt)*destLen;
  331.43 +    if ((uLong)stream.avail_out != *destLen) return Z_BUF_ERROR;
  331.44 +
  331.45 +    stream.zalloc = (alloc_func)0;
  331.46 +    stream.zfree = (free_func)0;
  331.47 +    stream.opaque = (voidpf)0;
  331.48 +
  331.49 +    err = deflateInit(&stream, level);
  331.50 +    if (err != Z_OK) return err;
  331.51 +
  331.52 +    err = deflate(&stream, Z_FINISH);
  331.53 +    if (err != Z_STREAM_END) {
  331.54 +        deflateEnd(&stream);
  331.55 +        return err == Z_OK ? Z_BUF_ERROR : err;
  331.56 +    }
  331.57 +    *destLen = stream.total_out;
  331.58 +
  331.59 +    err = deflateEnd(&stream);
  331.60 +    return err;
  331.61 +}
  331.62 +
  331.63 +/* ===========================================================================
  331.64 + */
  331.65 +int ZEXPORT compress (dest, destLen, source, sourceLen)
  331.66 +    Bytef *dest;
  331.67 +    uLongf *destLen;
  331.68 +    const Bytef *source;
  331.69 +    uLong sourceLen;
  331.70 +{
  331.71 +    return compress2(dest, destLen, source, sourceLen, Z_DEFAULT_COMPRESSION);
  331.72 +}
  331.73 +
  331.74 +/* ===========================================================================
  331.75 +     If the default memLevel or windowBits for deflateInit() is changed, then
  331.76 +   this function needs to be updated.
  331.77 + */
  331.78 +uLong ZEXPORT compressBound (sourceLen)
  331.79 +    uLong sourceLen;
  331.80 +{
  331.81 +    return sourceLen + (sourceLen >> 12) + (sourceLen >> 14) +
  331.82 +           (sourceLen >> 25) + 13;
  331.83 +}
   332.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
   332.2 +++ b/deps/glpk/src/zlib/crc32.c	Sun Nov 06 20:59:10 2011 +0100
   332.3 @@ -0,0 +1,442 @@
   332.4 +/* crc32.c -- compute the CRC-32 of a data stream
   332.5 + * Copyright (C) 1995-2006, 2010 Mark Adler
   332.6 + * For conditions of distribution and use, see copyright notice in zlib.h
   332.7 + *
   332.8 + * Thanks to Rodney Brown <rbrown64@csc.com.au> for his contribution of faster
   332.9 + * CRC methods: exclusive-oring 32 bits of data at a time, and pre-computing
  332.10 + * tables for updating the shift register in one step with three exclusive-ors
  332.11 + * instead of four steps with four exclusive-ors.  This results in about a
  332.12 + * factor of two increase in speed on a Power PC G4 (PPC7455) using gcc -O3.
  332.13 + */
  332.14 +
  332.15 +/* @(#) $Id$ */
  332.16 +
  332.17 +/*
  332.18 +  Note on the use of DYNAMIC_CRC_TABLE: there is no mutex or semaphore
  332.19 +  protection on the static variables used to control the first-use generation
  332.20 +  of the crc tables.  Therefore, if you #define DYNAMIC_CRC_TABLE, you should
  332.21 +  first call get_crc_table() to initialize the tables before allowing more than
  332.22 +  one thread to use crc32().
  332.23 + */
  332.24 +
  332.25 +#ifdef MAKECRCH
  332.26 +#  include <stdio.h>
  332.27 +#  ifndef DYNAMIC_CRC_TABLE
  332.28 +#    define DYNAMIC_CRC_TABLE
  332.29 +#  endif /* !DYNAMIC_CRC_TABLE */
  332.30 +#endif /* MAKECRCH */
  332.31 +
  332.32 +#include "zutil.h"      /* for STDC and FAR definitions */
  332.33 +
  332.34 +#define local static
  332.35 +
  332.36 +/* Find a four-byte integer type for crc32_little() and crc32_big(). */
  332.37 +#ifndef NOBYFOUR
  332.38 +#  ifdef STDC           /* need ANSI C limits.h to determine sizes */
  332.39 +#    include <limits.h>
  332.40 +#    define BYFOUR
  332.41 +#    if (UINT_MAX == 0xffffffffUL)
  332.42 +       typedef unsigned int u4;
  332.43 +#    else
  332.44 +#      if (ULONG_MAX == 0xffffffffUL)
  332.45 +         typedef unsigned long u4;
  332.46 +#      else
  332.47 +#        if (USHRT_MAX == 0xffffffffUL)
  332.48 +           typedef unsigned short u4;
  332.49 +#        else
  332.50 +#          undef BYFOUR     /* can't find a four-byte integer type! */
  332.51 +#        endif
  332.52 +#      endif
  332.53 +#    endif
  332.54 +#  endif /* STDC */
  332.55 +#endif /* !NOBYFOUR */
  332.56 +
  332.57 +/* Definitions for doing the crc four data bytes at a time. */
  332.58 +#ifdef BYFOUR
  332.59 +#  define REV(w) ((((w)>>24)&0xff)+(((w)>>8)&0xff00)+ \
  332.60 +                (((w)&0xff00)<<8)+(((w)&0xff)<<24))
  332.61 +   local unsigned long crc32_little OF((unsigned long,
  332.62 +                        const unsigned char FAR *, unsigned));
  332.63 +   local unsigned long crc32_big OF((unsigned long,
  332.64 +                        const unsigned char FAR *, unsigned));
  332.65 +#  define TBLS 8
  332.66 +#else
  332.67 +#  define TBLS 1
  332.68 +#endif /* BYFOUR */
  332.69 +
  332.70 +/* Local functions for crc concatenation */
  332.71 +local unsigned long gf2_matrix_times OF((unsigned long *mat,
  332.72 +                                         unsigned long vec));
  332.73 +local void gf2_matrix_square OF((unsigned long *square, unsigned long *mat));
  332.74 +local uLong crc32_combine_(uLong crc1, uLong crc2, z_off64_t len2);
  332.75 +
  332.76 +
  332.77 +#ifdef DYNAMIC_CRC_TABLE
  332.78 +
  332.79 +local volatile int crc_table_empty = 1;
  332.80 +local unsigned long FAR crc_table[TBLS][256];
  332.81 +local void make_crc_table OF((void));
  332.82 +#ifdef MAKECRCH
  332.83 +   local void write_table OF((FILE *, const unsigned long FAR *));
  332.84 +#endif /* MAKECRCH */
  332.85 +/*
  332.86 +  Generate tables for a byte-wise 32-bit CRC calculation on the polynomial:
  332.87 +  x^32+x^26+x^23+x^22+x^16+x^12+x^11+x^10+x^8+x^7+x^5+x^4+x^2+x+1.
  332.88 +
  332.89 +  Polynomials over GF(2) are represented in binary, one bit per coefficient,
  332.90 +  with the lowest powers in the most significant bit.  Then adding polynomials
  332.91 +  is just exclusive-or, and multiplying a polynomial by x is a right shift by
  332.92 +  one.  If we call the above polynomial p, and represent a byte as the
  332.93 +  polynomial q, also with the lowest power in the most significant bit (so the
  332.94 +  byte 0xb1 is the polynomial x^7+x^3+x+1), then the CRC is (q*x^32) mod p,
  332.95 +  where a mod b means the remainder after dividing a by b.
  332.96 +
  332.97 +  This calculation is done using the shift-register method of multiplying and
  332.98 +  taking the remainder.  The register is initialized to zero, and for each
  332.99 +  incoming bit, x^32 is added mod p to the register if the bit is a one (where
 332.100 +  x^32 mod p is p+x^32 = x^26+...+1), and the register is multiplied mod p by
 332.101 +  x (which is shifting right by one and adding x^32 mod p if the bit shifted
 332.102 +  out is a one).  We start with the highest power (least significant bit) of
 332.103 +  q and repeat for all eight bits of q.
 332.104 +
 332.105 +  The first table is simply the CRC of all possible eight bit values.  This is
 332.106 +  all the information needed to generate CRCs on data a byte at a time for all
 332.107 +  combinations of CRC register values and incoming bytes.  The remaining tables
 332.108 +  allow for word-at-a-time CRC calculation for both big-endian and little-
 332.109 +  endian machines, where a word is four bytes.
 332.110 +*/
 332.111 +local void make_crc_table()
 332.112 +{
 332.113 +    unsigned long c;
 332.114 +    int n, k;
 332.115 +    unsigned long poly;                 /* polynomial exclusive-or pattern */
 332.116 +    /* terms of polynomial defining this crc (except x^32): */
 332.117 +    static volatile int first = 1;      /* flag to limit concurrent making */
 332.118 +    static const unsigned char p[] = {0,1,2,4,5,7,8,10,11,12,16,22,23,26};
 332.119 +
 332.120 +    /* See if another task is already doing this (not thread-safe, but better
 332.121 +       than nothing -- significantly reduces duration of vulnerability in
 332.122 +       case the advice about DYNAMIC_CRC_TABLE is ignored) */
 332.123 +    if (first) {
 332.124 +        first = 0;
 332.125 +
 332.126 +        /* make exclusive-or pattern from polynomial (0xedb88320UL) */
 332.127 +        poly = 0UL;
 332.128 +        for (n = 0; n < sizeof(p)/sizeof(unsigned char); n++)
 332.129 +            poly |= 1UL << (31 - p[n]);
 332.130 +
 332.131 +        /* generate a crc for every 8-bit value */
 332.132 +        for (n = 0; n < 256; n++) {
 332.133 +            c = (unsigned long)n;
 332.134 +            for (k = 0; k < 8; k++)
 332.135 +                c = c & 1 ? poly ^ (c >> 1) : c >> 1;
 332.136 +            crc_table[0][n] = c;
 332.137 +        }
 332.138 +
 332.139 +#ifdef BYFOUR
 332.140 +        /* generate crc for each value followed by one, two, and three zeros,
 332.141 +           and then the byte reversal of those as well as the first table */
 332.142 +        for (n = 0; n < 256; n++) {
 332.143 +            c = crc_table[0][n];
 332.144 +            crc_table[4][n] = REV(c);
 332.145 +            for (k = 1; k < 4; k++) {
 332.146 +                c = crc_table[0][c & 0xff] ^ (c >> 8);
 332.147 +                crc_table[k][n] = c;
 332.148 +                crc_table[k + 4][n] = REV(c);
 332.149 +            }
 332.150 +        }
 332.151 +#endif /* BYFOUR */
 332.152 +
 332.153 +        crc_table_empty = 0;
 332.154 +    }
 332.155 +    else {      /* not first */
 332.156 +        /* wait for the other guy to finish (not efficient, but rare) */
 332.157 +        while (crc_table_empty)
 332.158 +            ;
 332.159 +    }
 332.160 +
 332.161 +#ifdef MAKECRCH
 332.162 +    /* write out CRC tables to crc32.h */
 332.163 +    {
 332.164 +        FILE *out;
 332.165 +
 332.166 +        out = fopen("crc32.h", "w");
 332.167 +        if (out == NULL) return;
 332.168 +        fprintf(out, "/* crc32.h -- tables for rapid CRC calculation\n");
 332.169 +        fprintf(out, " * Generated automatically by crc32.c\n */\n\n");
 332.170 +        fprintf(out, "local const unsigned long FAR ");
 332.171 +        fprintf(out, "crc_table[TBLS][256] =\n{\n  {\n");
 332.172 +        write_table(out, crc_table[0]);
 332.173 +#  ifdef BYFOUR
 332.174 +        fprintf(out, "#ifdef BYFOUR\n");
 332.175 +        for (k = 1; k < 8; k++) {
 332.176 +            fprintf(out, "  },\n  {\n");
 332.177 +            write_table(out, crc_table[k]);
 332.178 +        }
 332.179 +        fprintf(out, "#endif\n");
 332.180 +#  endif /* BYFOUR */
 332.181 +        fprintf(out, "  }\n};\n");
 332.182 +        fclose(out);
 332.183 +    }
 332.184 +#endif /* MAKECRCH */
 332.185 +}
 332.186 +
 332.187 +#ifdef MAKECRCH
 332.188 +local void write_table(out, table)
 332.189 +    FILE *out;
 332.190 +    const unsigned long FAR *table;
 332.191 +{
 332.192 +    int n;
 332.193 +
 332.194 +    for (n = 0; n < 256; n++)
 332.195 +        fprintf(out, "%s0x%08lxUL%s", n % 5 ? "" : "    ", table[n],
 332.196 +                n == 255 ? "\n" : (n % 5 == 4 ? ",\n" : ", "));
 332.197 +}
 332.198 +#endif /* MAKECRCH */
 332.199 +
 332.200 +#else /* !DYNAMIC_CRC_TABLE */
 332.201 +/* ========================================================================
 332.202 + * Tables of CRC-32s of all single-byte values, made by make_crc_table().
 332.203 + */
 332.204 +#include "crc32.h"
 332.205 +#endif /* DYNAMIC_CRC_TABLE */
 332.206 +
 332.207 +/* =========================================================================
 332.208 + * This function can be used by asm versions of crc32()
 332.209 + */
 332.210 +const unsigned long FAR * ZEXPORT get_crc_table()
 332.211 +{
 332.212 +#ifdef DYNAMIC_CRC_TABLE
 332.213 +    if (crc_table_empty)
 332.214 +        make_crc_table();
 332.215 +#endif /* DYNAMIC_CRC_TABLE */
 332.216 +    return (const unsigned long FAR *)crc_table;
 332.217 +}
 332.218 +
 332.219 +/* ========================================================================= */
 332.220 +#define DO1 crc = crc_table[0][((int)crc ^ (*buf++)) & 0xff] ^ (crc >> 8)
 332.221 +#define DO8 DO1; DO1; DO1; DO1; DO1; DO1; DO1; DO1
 332.222 +
 332.223 +/* ========================================================================= */
 332.224 +unsigned long ZEXPORT crc32(crc, buf, len)
 332.225 +    unsigned long crc;
 332.226 +    const unsigned char FAR *buf;
 332.227 +    uInt len;
 332.228 +{
 332.229 +    if (buf == Z_NULL) return 0UL;
 332.230 +
 332.231 +#ifdef DYNAMIC_CRC_TABLE
 332.232 +    if (crc_table_empty)
 332.233 +        make_crc_table();
 332.234 +#endif /* DYNAMIC_CRC_TABLE */
 332.235 +
 332.236 +#ifdef BYFOUR
 332.237 +    if (sizeof(void *) == sizeof(ptrdiff_t)) {
 332.238 +        u4 endian;
 332.239 +
 332.240 +        endian = 1;
 332.241 +        if (*((unsigned char *)(&endian)))
 332.242 +            return crc32_little(crc, buf, len);
 332.243 +        else
 332.244 +            return crc32_big(crc, buf, len);
 332.245 +    }
 332.246 +#endif /* BYFOUR */
 332.247 +    crc = crc ^ 0xffffffffUL;
 332.248 +    while (len >= 8) {
 332.249 +        DO8;
 332.250 +        len -= 8;
 332.251 +    }
 332.252 +    if (len) do {
 332.253 +        DO1;
 332.254 +    } while (--len);
 332.255 +    return crc ^ 0xffffffffUL;
 332.256 +}
 332.257 +
 332.258 +#ifdef BYFOUR
 332.259 +
 332.260 +/* ========================================================================= */
 332.261 +#define DOLIT4 c ^= *buf4++; \
 332.262 +        c = crc_table[3][c & 0xff] ^ crc_table[2][(c >> 8) & 0xff] ^ \
 332.263 +            crc_table[1][(c >> 16) & 0xff] ^ crc_table[0][c >> 24]
 332.264 +#define DOLIT32 DOLIT4; DOLIT4; DOLIT4; DOLIT4; DOLIT4; DOLIT4; DOLIT4; DOLIT4
 332.265 +
 332.266 +/* ========================================================================= */
 332.267 +local unsigned long crc32_little(crc, buf, len)
 332.268 +    unsigned long crc;
 332.269 +    const unsigned char FAR *buf;
 332.270 +    unsigned len;
 332.271 +{
 332.272 +    register u4 c;
 332.273 +    register const u4 FAR *buf4;
 332.274 +
 332.275 +    c = (u4)crc;
 332.276 +    c = ~c;
 332.277 +    while (len && ((ptrdiff_t)buf & 3)) {
 332.278 +        c = crc_table[0][(c ^ *buf++) & 0xff] ^ (c >> 8);
 332.279 +        len--;
 332.280 +    }
 332.281 +
 332.282 +    buf4 = (const u4 FAR *)(const void FAR *)buf;
 332.283 +    while (len >= 32) {
 332.284 +        DOLIT32;
 332.285 +        len -= 32;
 332.286 +    }
 332.287 +    while (len >= 4) {
 332.288 +        DOLIT4;
 332.289 +        len -= 4;
 332.290 +    }
 332.291 +    buf = (const unsigned char FAR *)buf4;
 332.292 +
 332.293 +    if (len) do {
 332.294 +        c = crc_table[0][(c ^ *buf++) & 0xff] ^ (c >> 8);
 332.295 +    } while (--len);
 332.296 +    c = ~c;
 332.297 +    return (unsigned long)c;
 332.298 +}
 332.299 +
 332.300 +/* ========================================================================= */
 332.301 +#define DOBIG4 c ^= *++buf4; \
 332.302 +        c = crc_table[4][c & 0xff] ^ crc_table[5][(c >> 8) & 0xff] ^ \
 332.303 +            crc_table[6][(c >> 16) & 0xff] ^ crc_table[7][c >> 24]
 332.304 +#define DOBIG32 DOBIG4; DOBIG4; DOBIG4; DOBIG4; DOBIG4; DOBIG4; DOBIG4; DOBIG4
 332.305 +
 332.306 +/* ========================================================================= */
 332.307 +local unsigned long crc32_big(crc, buf, len)
 332.308 +    unsigned long crc;
 332.309 +    const unsigned char FAR *buf;
 332.310 +    unsigned len;
 332.311 +{
 332.312 +    register u4 c;
 332.313 +    register const u4 FAR *buf4;
 332.314 +
 332.315 +    c = REV((u4)crc);
 332.316 +    c = ~c;
 332.317 +    while (len && ((ptrdiff_t)buf & 3)) {
 332.318 +        c = crc_table[4][(c >> 24) ^ *buf++] ^ (c << 8);
 332.319 +        len--;
 332.320 +    }
 332.321 +
 332.322 +    buf4 = (const u4 FAR *)(const void FAR *)buf;
 332.323 +    buf4--;
 332.324 +    while (len >= 32) {
 332.325 +        DOBIG32;
 332.326 +        len -= 32;
 332.327 +    }
 332.328 +    while (len >= 4) {
 332.329 +        DOBIG4;
 332.330 +        len -= 4;
 332.331 +    }
 332.332 +    buf4++;
 332.333 +    buf = (const unsigned char FAR *)buf4;
 332.334 +
 332.335 +    if (len) do {
 332.336 +        c = crc_table[4][(c >> 24) ^ *buf++] ^ (c << 8);
 332.337 +    } while (--len);
 332.338 +    c = ~c;
 332.339 +    return (unsigned long)(REV(c));
 332.340 +}
 332.341 +
 332.342 +#endif /* BYFOUR */
 332.343 +
 332.344 +#define GF2_DIM 32      /* dimension of GF(2) vectors (length of CRC) */
 332.345 +
 332.346 +/* ========================================================================= */
 332.347 +local unsigned long gf2_matrix_times(mat, vec)
 332.348 +    unsigned long *mat;
 332.349 +    unsigned long vec;
 332.350 +{
 332.351 +    unsigned long sum;
 332.352 +
 332.353 +    sum = 0;
 332.354 +    while (vec) {
 332.355 +        if (vec & 1)
 332.356 +            sum ^= *mat;
 332.357 +        vec >>= 1;
 332.358 +        mat++;
 332.359 +    }
 332.360 +    return sum;
 332.361 +}
 332.362 +
 332.363 +/* ========================================================================= */
 332.364 +local void gf2_matrix_square(square, mat)
 332.365 +    unsigned long *square;
 332.366 +    unsigned long *mat;
 332.367 +{
 332.368 +    int n;
 332.369 +
 332.370 +    for (n = 0; n < GF2_DIM; n++)
 332.371 +        square[n] = gf2_matrix_times(mat, mat[n]);
 332.372 +}
 332.373 +
 332.374 +/* ========================================================================= */
 332.375 +local uLong crc32_combine_(crc1, crc2, len2)
 332.376 +    uLong crc1;
 332.377 +    uLong crc2;
 332.378 +    z_off64_t len2;
 332.379 +{
 332.380 +    int n;
 332.381 +    unsigned long row;
 332.382 +    unsigned long even[GF2_DIM];    /* even-power-of-two zeros operator */
 332.383 +    unsigned long odd[GF2_DIM];     /* odd-power-of-two zeros operator */
 332.384 +
 332.385 +    /* degenerate case (also disallow negative lengths) */
 332.386 +    if (len2 <= 0)
 332.387 +        return crc1;
 332.388 +
 332.389 +    /* put operator for one zero bit in odd */
 332.390 +    odd[0] = 0xedb88320UL;          /* CRC-32 polynomial */
 332.391 +    row = 1;
 332.392 +    for (n = 1; n < GF2_DIM; n++) {
 332.393 +        odd[n] = row;
 332.394 +        row <<= 1;
 332.395 +    }
 332.396 +
 332.397 +    /* put operator for two zero bits in even */
 332.398 +    gf2_matrix_square(even, odd);
 332.399 +
 332.400 +    /* put operator for four zero bits in odd */
 332.401 +    gf2_matrix_square(odd, even);
 332.402 +
 332.403 +    /* apply len2 zeros to crc1 (first square will put the operator for one
 332.404 +       zero byte, eight zero bits, in even) */
 332.405 +    do {
 332.406 +        /* apply zeros operator for this bit of len2 */
 332.407 +        gf2_matrix_square(even, odd);
 332.408 +        if (len2 & 1)
 332.409 +            crc1 = gf2_matrix_times(even, crc1);
 332.410 +        len2 >>= 1;
 332.411 +
 332.412 +        /* if no more bits set, then done */
 332.413 +        if (len2 == 0)
 332.414 +            break;
 332.415 +
 332.416 +        /* another iteration of the loop with odd and even swapped */
 332.417 +        gf2_matrix_square(odd, even);
 332.418 +        if (len2 & 1)
 332.419 +            crc1 = gf2_matrix_times(odd, crc1);
 332.420 +        len2 >>= 1;
 332.421 +
 332.422 +        /* if no more bits set, then done */
 332.423 +    } while (len2 != 0);
 332.424 +
 332.425 +    /* return combined crc */
 332.426 +    crc1 ^= crc2;
 332.427 +    return crc1;
 332.428 +}
 332.429 +
 332.430 +/* ========================================================================= */
 332.431 +uLong ZEXPORT crc32_combine(crc1, crc2, len2)
 332.432 +    uLong crc1;
 332.433 +    uLong crc2;
 332.434 +    z_off_t len2;
 332.435 +{
 332.436 +    return crc32_combine_(crc1, crc2, len2);
 332.437 +}
 332.438 +
 332.439 +uLong ZEXPORT crc32_combine64(crc1, crc2, len2)
 332.440 +    uLong crc1;
 332.441 +    uLong crc2;
 332.442 +    z_off64_t len2;
 332.443 +{
 332.444 +    return crc32_combine_(crc1, crc2, len2);
 332.445 +}
   333.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
   333.2 +++ b/deps/glpk/src/zlib/crc32.h	Sun Nov 06 20:59:10 2011 +0100
   333.3 @@ -0,0 +1,441 @@
   333.4 +/* crc32.h -- tables for rapid CRC calculation
   333.5 + * Generated automatically by crc32.c
   333.6 + */
   333.7 +
   333.8 +local const unsigned long FAR crc_table[TBLS][256] =
   333.9 +{
  333.10 +  {
  333.11 +    0x00000000UL, 0x77073096UL, 0xee0e612cUL, 0x990951baUL, 0x076dc419UL,
  333.12 +    0x706af48fUL, 0xe963a535UL, 0x9e6495a3UL, 0x0edb8832UL, 0x79dcb8a4UL,
  333.13 +    0xe0d5e91eUL, 0x97d2d988UL, 0x09b64c2bUL, 0x7eb17cbdUL, 0xe7b82d07UL,
  333.14 +    0x90bf1d91UL, 0x1db71064UL, 0x6ab020f2UL, 0xf3b97148UL, 0x84be41deUL,
  333.15 +    0x1adad47dUL, 0x6ddde4ebUL, 0xf4d4b551UL, 0x83d385c7UL, 0x136c9856UL,
  333.16 +    0x646ba8c0UL, 0xfd62f97aUL, 0x8a65c9ecUL, 0x14015c4fUL, 0x63066cd9UL,
  333.17 +    0xfa0f3d63UL, 0x8d080df5UL, 0x3b6e20c8UL, 0x4c69105eUL, 0xd56041e4UL,
  333.18 +    0xa2677172UL, 0x3c03e4d1UL, 0x4b04d447UL, 0xd20d85fdUL, 0xa50ab56bUL,
  333.19 +    0x35b5a8faUL, 0x42b2986cUL, 0xdbbbc9d6UL, 0xacbcf940UL, 0x32d86ce3UL,
  333.20 +    0x45df5c75UL, 0xdcd60dcfUL, 0xabd13d59UL, 0x26d930acUL, 0x51de003aUL,
  333.21 +    0xc8d75180UL, 0xbfd06116UL, 0x21b4f4b5UL, 0x56b3c423UL, 0xcfba9599UL,
  333.22 +    0xb8bda50fUL, 0x2802b89eUL, 0x5f058808UL, 0xc60cd9b2UL, 0xb10be924UL,
  333.23 +    0x2f6f7c87UL, 0x58684c11UL, 0xc1611dabUL, 0xb6662d3dUL, 0x76dc4190UL,
  333.24 +    0x01db7106UL, 0x98d220bcUL, 0xefd5102aUL, 0x71b18589UL, 0x06b6b51fUL,
  333.25 +    0x9fbfe4a5UL, 0xe8b8d433UL, 0x7807c9a2UL, 0x0f00f934UL, 0x9609a88eUL,
  333.26 +    0xe10e9818UL, 0x7f6a0dbbUL, 0x086d3d2dUL, 0x91646c97UL, 0xe6635c01UL,
  333.27 +    0x6b6b51f4UL, 0x1c6c6162UL, 0x856530d8UL, 0xf262004eUL, 0x6c0695edUL,
  333.28 +    0x1b01a57bUL, 0x8208f4c1UL, 0xf50fc457UL, 0x65b0d9c6UL, 0x12b7e950UL,
  333.29 +    0x8bbeb8eaUL, 0xfcb9887cUL, 0x62dd1ddfUL, 0x15da2d49UL, 0x8cd37cf3UL,
  333.30 +    0xfbd44c65UL, 0x4db26158UL, 0x3ab551ceUL, 0xa3bc0074UL, 0xd4bb30e2UL,
  333.31 +    0x4adfa541UL, 0x3dd895d7UL, 0xa4d1c46dUL, 0xd3d6f4fbUL, 0x4369e96aUL,
  333.32 +    0x346ed9fcUL, 0xad678846UL, 0xda60b8d0UL, 0x44042d73UL, 0x33031de5UL,
  333.33 +    0xaa0a4c5fUL, 0xdd0d7cc9UL, 0x5005713cUL, 0x270241aaUL, 0xbe0b1010UL,
  333.34 +    0xc90c2086UL, 0x5768b525UL, 0x206f85b3UL, 0xb966d409UL, 0xce61e49fUL,
  333.35 +    0x5edef90eUL, 0x29d9c998UL, 0xb0d09822UL, 0xc7d7a8b4UL, 0x59b33d17UL,
  333.36 +    0x2eb40d81UL, 0xb7bd5c3bUL, 0xc0ba6cadUL, 0xedb88320UL, 0x9abfb3b6UL,
  333.37 +    0x03b6e20cUL, 0x74b1d29aUL, 0xead54739UL, 0x9dd277afUL, 0x04db2615UL,
  333.38 +    0x73dc1683UL, 0xe3630b12UL, 0x94643b84UL, 0x0d6d6a3eUL, 0x7a6a5aa8UL,
  333.39 +    0xe40ecf0bUL, 0x9309ff9dUL, 0x0a00ae27UL, 0x7d079eb1UL, 0xf00f9344UL,
  333.40 +    0x8708a3d2UL, 0x1e01f268UL, 0x6906c2feUL, 0xf762575dUL, 0x806567cbUL,
  333.41 +    0x196c3671UL, 0x6e6b06e7UL, 0xfed41b76UL, 0x89d32be0UL, 0x10da7a5aUL,
  333.42 +    0x67dd4accUL, 0xf9b9df6fUL, 0x8ebeeff9UL, 0x17b7be43UL, 0x60b08ed5UL,
  333.43 +    0xd6d6a3e8UL, 0xa1d1937eUL, 0x38d8c2c4UL, 0x4fdff252UL, 0xd1bb67f1UL,
  333.44 +    0xa6bc5767UL, 0x3fb506ddUL, 0x48b2364bUL, 0xd80d2bdaUL, 0xaf0a1b4cUL,
  333.45 +    0x36034af6UL, 0x41047a60UL, 0xdf60efc3UL, 0xa867df55UL, 0x316e8eefUL,
  333.46 +    0x4669be79UL, 0xcb61b38cUL, 0xbc66831aUL, 0x256fd2a0UL, 0x5268e236UL,
  333.47 +    0xcc0c7795UL, 0xbb0b4703UL, 0x220216b9UL, 0x5505262fUL, 0xc5ba3bbeUL,
  333.48 +    0xb2bd0b28UL, 0x2bb45a92UL, 0x5cb36a04UL, 0xc2d7ffa7UL, 0xb5d0cf31UL,
  333.49 +    0x2cd99e8bUL, 0x5bdeae1dUL, 0x9b64c2b0UL, 0xec63f226UL, 0x756aa39cUL,
  333.50 +    0x026d930aUL, 0x9c0906a9UL, 0xeb0e363fUL, 0x72076785UL, 0x05005713UL,
  333.51 +    0x95bf4a82UL, 0xe2b87a14UL, 0x7bb12baeUL, 0x0cb61b38UL, 0x92d28e9bUL,
  333.52 +    0xe5d5be0dUL, 0x7cdcefb7UL, 0x0bdbdf21UL, 0x86d3d2d4UL, 0xf1d4e242UL,
  333.53 +    0x68ddb3f8UL, 0x1fda836eUL, 0x81be16cdUL, 0xf6b9265bUL, 0x6fb077e1UL,
  333.54 +    0x18b74777UL, 0x88085ae6UL, 0xff0f6a70UL, 0x66063bcaUL, 0x11010b5cUL,
  333.55 +    0x8f659effUL, 0xf862ae69UL, 0x616bffd3UL, 0x166ccf45UL, 0xa00ae278UL,
  333.56 +    0xd70dd2eeUL, 0x4e048354UL, 0x3903b3c2UL, 0xa7672661UL, 0xd06016f7UL,
  333.57 +    0x4969474dUL, 0x3e6e77dbUL, 0xaed16a4aUL, 0xd9d65adcUL, 0x40df0b66UL,
  333.58 +    0x37d83bf0UL, 0xa9bcae53UL, 0xdebb9ec5UL, 0x47b2cf7fUL, 0x30b5ffe9UL,
  333.59 +    0xbdbdf21cUL, 0xcabac28aUL, 0x53b39330UL, 0x24b4a3a6UL, 0xbad03605UL,
  333.60 +    0xcdd70693UL, 0x54de5729UL, 0x23d967bfUL, 0xb3667a2eUL, 0xc4614ab8UL,
  333.61 +    0x5d681b02UL, 0x2a6f2b94UL, 0xb40bbe37UL, 0xc30c8ea1UL, 0x5a05df1bUL,
  333.62 +    0x2d02ef8dUL
  333.63 +#ifdef BYFOUR
  333.64 +  },
  333.65 +  {
  333.66 +    0x00000000UL, 0x191b3141UL, 0x32366282UL, 0x2b2d53c3UL, 0x646cc504UL,
  333.67 +    0x7d77f445UL, 0x565aa786UL, 0x4f4196c7UL, 0xc8d98a08UL, 0xd1c2bb49UL,
  333.68 +    0xfaefe88aUL, 0xe3f4d9cbUL, 0xacb54f0cUL, 0xb5ae7e4dUL, 0x9e832d8eUL,
  333.69 +    0x87981ccfUL, 0x4ac21251UL, 0x53d92310UL, 0x78f470d3UL, 0x61ef4192UL,
  333.70 +    0x2eaed755UL, 0x37b5e614UL, 0x1c98b5d7UL, 0x05838496UL, 0x821b9859UL,
  333.71 +    0x9b00a918UL, 0xb02dfadbUL, 0xa936cb9aUL, 0xe6775d5dUL, 0xff6c6c1cUL,
  333.72 +    0xd4413fdfUL, 0xcd5a0e9eUL, 0x958424a2UL, 0x8c9f15e3UL, 0xa7b24620UL,
  333.73 +    0xbea97761UL, 0xf1e8e1a6UL, 0xe8f3d0e7UL, 0xc3de8324UL, 0xdac5b265UL,
  333.74 +    0x5d5daeaaUL, 0x44469febUL, 0x6f6bcc28UL, 0x7670fd69UL, 0x39316baeUL,
  333.75 +    0x202a5aefUL, 0x0b07092cUL, 0x121c386dUL, 0xdf4636f3UL, 0xc65d07b2UL,
  333.76 +    0xed705471UL, 0xf46b6530UL, 0xbb2af3f7UL, 0xa231c2b6UL, 0x891c9175UL,
  333.77 +    0x9007a034UL, 0x179fbcfbUL, 0x0e848dbaUL, 0x25a9de79UL, 0x3cb2ef38UL,
  333.78 +    0x73f379ffUL, 0x6ae848beUL, 0x41c51b7dUL, 0x58de2a3cUL, 0xf0794f05UL,
  333.79 +    0xe9627e44UL, 0xc24f2d87UL, 0xdb541cc6UL, 0x94158a01UL, 0x8d0ebb40UL,
  333.80 +    0xa623e883UL, 0xbf38d9c2UL, 0x38a0c50dUL, 0x21bbf44cUL, 0x0a96a78fUL,
  333.81 +    0x138d96ceUL, 0x5ccc0009UL, 0x45d73148UL, 0x6efa628bUL, 0x77e153caUL,
  333.82 +    0xbabb5d54UL, 0xa3a06c15UL, 0x888d3fd6UL, 0x91960e97UL, 0xded79850UL,
  333.83 +    0xc7cca911UL, 0xece1fad2UL, 0xf5facb93UL, 0x7262d75cUL, 0x6b79e61dUL,
  333.84 +    0x4054b5deUL, 0x594f849fUL, 0x160e1258UL, 0x0f152319UL, 0x243870daUL,
  333.85 +    0x3d23419bUL, 0x65fd6ba7UL, 0x7ce65ae6UL, 0x57cb0925UL, 0x4ed03864UL,
  333.86 +    0x0191aea3UL, 0x188a9fe2UL, 0x33a7cc21UL, 0x2abcfd60UL, 0xad24e1afUL,
  333.87 +    0xb43fd0eeUL, 0x9f12832dUL, 0x8609b26cUL, 0xc94824abUL, 0xd05315eaUL,
  333.88 +    0xfb7e4629UL, 0xe2657768UL, 0x2f3f79f6UL, 0x362448b7UL, 0x1d091b74UL,
  333.89 +    0x04122a35UL, 0x4b53bcf2UL, 0x52488db3UL, 0x7965de70UL, 0x607eef31UL,
  333.90 +    0xe7e6f3feUL, 0xfefdc2bfUL, 0xd5d0917cUL, 0xcccba03dUL, 0x838a36faUL,
  333.91 +    0x9a9107bbUL, 0xb1bc5478UL, 0xa8a76539UL, 0x3b83984bUL, 0x2298a90aUL,
  333.92 +    0x09b5fac9UL, 0x10aecb88UL, 0x5fef5d4fUL, 0x46f46c0eUL, 0x6dd93fcdUL,
  333.93 +    0x74c20e8cUL, 0xf35a1243UL, 0xea412302UL, 0xc16c70c1UL, 0xd8774180UL,
  333.94 +    0x9736d747UL, 0x8e2de606UL, 0xa500b5c5UL, 0xbc1b8484UL, 0x71418a1aUL,
  333.95 +    0x685abb5bUL, 0x4377e898UL, 0x5a6cd9d9UL, 0x152d4f1eUL, 0x0c367e5fUL,
  333.96 +    0x271b2d9cUL, 0x3e001cddUL, 0xb9980012UL, 0xa0833153UL, 0x8bae6290UL,
  333.97 +    0x92b553d1UL, 0xddf4c516UL, 0xc4eff457UL, 0xefc2a794UL, 0xf6d996d5UL,
  333.98 +    0xae07bce9UL, 0xb71c8da8UL, 0x9c31de6bUL, 0x852aef2aUL, 0xca6b79edUL,
  333.99 +    0xd37048acUL, 0xf85d1b6fUL, 0xe1462a2eUL, 0x66de36e1UL, 0x7fc507a0UL,
 333.100 +    0x54e85463UL, 0x4df36522UL, 0x02b2f3e5UL, 0x1ba9c2a4UL, 0x30849167UL,
 333.101 +    0x299fa026UL, 0xe4c5aeb8UL, 0xfdde9ff9UL, 0xd6f3cc3aUL, 0xcfe8fd7bUL,
 333.102 +    0x80a96bbcUL, 0x99b25afdUL, 0xb29f093eUL, 0xab84387fUL, 0x2c1c24b0UL,
 333.103 +    0x350715f1UL, 0x1e2a4632UL, 0x07317773UL, 0x4870e1b4UL, 0x516bd0f5UL,
 333.104 +    0x7a468336UL, 0x635db277UL, 0xcbfad74eUL, 0xd2e1e60fUL, 0xf9ccb5ccUL,
 333.105 +    0xe0d7848dUL, 0xaf96124aUL, 0xb68d230bUL, 0x9da070c8UL, 0x84bb4189UL,
 333.106 +    0x03235d46UL, 0x1a386c07UL, 0x31153fc4UL, 0x280e0e85UL, 0x674f9842UL,
 333.107 +    0x7e54a903UL, 0x5579fac0UL, 0x4c62cb81UL, 0x8138c51fUL, 0x9823f45eUL,
 333.108 +    0xb30ea79dUL, 0xaa1596dcUL, 0xe554001bUL, 0xfc4f315aUL, 0xd7626299UL,
 333.109 +    0xce7953d8UL, 0x49e14f17UL, 0x50fa7e56UL, 0x7bd72d95UL, 0x62cc1cd4UL,
 333.110 +    0x2d8d8a13UL, 0x3496bb52UL, 0x1fbbe891UL, 0x06a0d9d0UL, 0x5e7ef3ecUL,
 333.111 +    0x4765c2adUL, 0x6c48916eUL, 0x7553a02fUL, 0x3a1236e8UL, 0x230907a9UL,
 333.112 +    0x0824546aUL, 0x113f652bUL, 0x96a779e4UL, 0x8fbc48a5UL, 0xa4911b66UL,
 333.113 +    0xbd8a2a27UL, 0xf2cbbce0UL, 0xebd08da1UL, 0xc0fdde62UL, 0xd9e6ef23UL,
 333.114 +    0x14bce1bdUL, 0x0da7d0fcUL, 0x268a833fUL, 0x3f91b27eUL, 0x70d024b9UL,
 333.115 +    0x69cb15f8UL, 0x42e6463bUL, 0x5bfd777aUL, 0xdc656bb5UL, 0xc57e5af4UL,
 333.116 +    0xee530937UL, 0xf7483876UL, 0xb809aeb1UL, 0xa1129ff0UL, 0x8a3fcc33UL,
 333.117 +    0x9324fd72UL
 333.118 +  },
 333.119 +  {
 333.120 +    0x00000000UL, 0x01c26a37UL, 0x0384d46eUL, 0x0246be59UL, 0x0709a8dcUL,
 333.121 +    0x06cbc2ebUL, 0x048d7cb2UL, 0x054f1685UL, 0x0e1351b8UL, 0x0fd13b8fUL,
 333.122 +    0x0d9785d6UL, 0x0c55efe1UL, 0x091af964UL, 0x08d89353UL, 0x0a9e2d0aUL,
 333.123 +    0x0b5c473dUL, 0x1c26a370UL, 0x1de4c947UL, 0x1fa2771eUL, 0x1e601d29UL,
 333.124 +    0x1b2f0bacUL, 0x1aed619bUL, 0x18abdfc2UL, 0x1969b5f5UL, 0x1235f2c8UL,
 333.125 +    0x13f798ffUL, 0x11b126a6UL, 0x10734c91UL, 0x153c5a14UL, 0x14fe3023UL,
 333.126 +    0x16b88e7aUL, 0x177ae44dUL, 0x384d46e0UL, 0x398f2cd7UL, 0x3bc9928eUL,
 333.127 +    0x3a0bf8b9UL, 0x3f44ee3cUL, 0x3e86840bUL, 0x3cc03a52UL, 0x3d025065UL,
 333.128 +    0x365e1758UL, 0x379c7d6fUL, 0x35dac336UL, 0x3418a901UL, 0x3157bf84UL,
 333.129 +    0x3095d5b3UL, 0x32d36beaUL, 0x331101ddUL, 0x246be590UL, 0x25a98fa7UL,
 333.130 +    0x27ef31feUL, 0x262d5bc9UL, 0x23624d4cUL, 0x22a0277bUL, 0x20e69922UL,
 333.131 +    0x2124f315UL, 0x2a78b428UL, 0x2bbade1fUL, 0x29fc6046UL, 0x283e0a71UL,
 333.132 +    0x2d711cf4UL, 0x2cb376c3UL, 0x2ef5c89aUL, 0x2f37a2adUL, 0x709a8dc0UL,
 333.133 +    0x7158e7f7UL, 0x731e59aeUL, 0x72dc3399UL, 0x7793251cUL, 0x76514f2bUL,
 333.134 +    0x7417f172UL, 0x75d59b45UL, 0x7e89dc78UL, 0x7f4bb64fUL, 0x7d0d0816UL,
 333.135 +    0x7ccf6221UL, 0x798074a4UL, 0x78421e93UL, 0x7a04a0caUL, 0x7bc6cafdUL,
 333.136 +    0x6cbc2eb0UL, 0x6d7e4487UL, 0x6f38fadeUL, 0x6efa90e9UL, 0x6bb5866cUL,
 333.137 +    0x6a77ec5bUL, 0x68315202UL, 0x69f33835UL, 0x62af7f08UL, 0x636d153fUL,
 333.138 +    0x612bab66UL, 0x60e9c151UL, 0x65a6d7d4UL, 0x6464bde3UL, 0x662203baUL,
 333.139 +    0x67e0698dUL, 0x48d7cb20UL, 0x4915a117UL, 0x4b531f4eUL, 0x4a917579UL,
 333.140 +    0x4fde63fcUL, 0x4e1c09cbUL, 0x4c5ab792UL, 0x4d98dda5UL, 0x46c49a98UL,
 333.141 +    0x4706f0afUL, 0x45404ef6UL, 0x448224c1UL, 0x41cd3244UL, 0x400f5873UL,
 333.142 +    0x4249e62aUL, 0x438b8c1dUL, 0x54f16850UL, 0x55330267UL, 0x5775bc3eUL,
 333.143 +    0x56b7d609UL, 0x53f8c08cUL, 0x523aaabbUL, 0x507c14e2UL, 0x51be7ed5UL,
 333.144 +    0x5ae239e8UL, 0x5b2053dfUL, 0x5966ed86UL, 0x58a487b1UL, 0x5deb9134UL,
 333.145 +    0x5c29fb03UL, 0x5e6f455aUL, 0x5fad2f6dUL, 0xe1351b80UL, 0xe0f771b7UL,
 333.146 +    0xe2b1cfeeUL, 0xe373a5d9UL, 0xe63cb35cUL, 0xe7fed96bUL, 0xe5b86732UL,
 333.147 +    0xe47a0d05UL, 0xef264a38UL, 0xeee4200fUL, 0xeca29e56UL, 0xed60f461UL,
 333.148 +    0xe82fe2e4UL, 0xe9ed88d3UL, 0xebab368aUL, 0xea695cbdUL, 0xfd13b8f0UL,
 333.149 +    0xfcd1d2c7UL, 0xfe976c9eUL, 0xff5506a9UL, 0xfa1a102cUL, 0xfbd87a1bUL,
 333.150 +    0xf99ec442UL, 0xf85cae75UL, 0xf300e948UL, 0xf2c2837fUL, 0xf0843d26UL,
 333.151 +    0xf1465711UL, 0xf4094194UL, 0xf5cb2ba3UL, 0xf78d95faUL, 0xf64fffcdUL,
 333.152 +    0xd9785d60UL, 0xd8ba3757UL, 0xdafc890eUL, 0xdb3ee339UL, 0xde71f5bcUL,
 333.153 +    0xdfb39f8bUL, 0xddf521d2UL, 0xdc374be5UL, 0xd76b0cd8UL, 0xd6a966efUL,
 333.154 +    0xd4efd8b6UL, 0xd52db281UL, 0xd062a404UL, 0xd1a0ce33UL, 0xd3e6706aUL,
 333.155 +    0xd2241a5dUL, 0xc55efe10UL, 0xc49c9427UL, 0xc6da2a7eUL, 0xc7184049UL,
 333.156 +    0xc25756ccUL, 0xc3953cfbUL, 0xc1d382a2UL, 0xc011e895UL, 0xcb4dafa8UL,
 333.157 +    0xca8fc59fUL, 0xc8c97bc6UL, 0xc90b11f1UL, 0xcc440774UL, 0xcd866d43UL,
 333.158 +    0xcfc0d31aUL, 0xce02b92dUL, 0x91af9640UL, 0x906dfc77UL, 0x922b422eUL,
 333.159 +    0x93e92819UL, 0x96a63e9cUL, 0x976454abUL, 0x9522eaf2UL, 0x94e080c5UL,
 333.160 +    0x9fbcc7f8UL, 0x9e7eadcfUL, 0x9c381396UL, 0x9dfa79a1UL, 0x98b56f24UL,
 333.161 +    0x99770513UL, 0x9b31bb4aUL, 0x9af3d17dUL, 0x8d893530UL, 0x8c4b5f07UL,
 333.162 +    0x8e0de15eUL, 0x8fcf8b69UL, 0x8a809decUL, 0x8b42f7dbUL, 0x89044982UL,
 333.163 +    0x88c623b5UL, 0x839a6488UL, 0x82580ebfUL, 0x801eb0e6UL, 0x81dcdad1UL,
 333.164 +    0x8493cc54UL, 0x8551a663UL, 0x8717183aUL, 0x86d5720dUL, 0xa9e2d0a0UL,
 333.165 +    0xa820ba97UL, 0xaa6604ceUL, 0xaba46ef9UL, 0xaeeb787cUL, 0xaf29124bUL,
 333.166 +    0xad6fac12UL, 0xacadc625UL, 0xa7f18118UL, 0xa633eb2fUL, 0xa4755576UL,
 333.167 +    0xa5b73f41UL, 0xa0f829c4UL, 0xa13a43f3UL, 0xa37cfdaaUL, 0xa2be979dUL,
 333.168 +    0xb5c473d0UL, 0xb40619e7UL, 0xb640a7beUL, 0xb782cd89UL, 0xb2cddb0cUL,
 333.169 +    0xb30fb13bUL, 0xb1490f62UL, 0xb08b6555UL, 0xbbd72268UL, 0xba15485fUL,
 333.170 +    0xb853f606UL, 0xb9919c31UL, 0xbcde8ab4UL, 0xbd1ce083UL, 0xbf5a5edaUL,
 333.171 +    0xbe9834edUL
 333.172 +  },
 333.173 +  {
 333.174 +    0x00000000UL, 0xb8bc6765UL, 0xaa09c88bUL, 0x12b5afeeUL, 0x8f629757UL,
 333.175 +    0x37def032UL, 0x256b5fdcUL, 0x9dd738b9UL, 0xc5b428efUL, 0x7d084f8aUL,
 333.176 +    0x6fbde064UL, 0xd7018701UL, 0x4ad6bfb8UL, 0xf26ad8ddUL, 0xe0df7733UL,
 333.177 +    0x58631056UL, 0x5019579fUL, 0xe8a530faUL, 0xfa109f14UL, 0x42acf871UL,
 333.178 +    0xdf7bc0c8UL, 0x67c7a7adUL, 0x75720843UL, 0xcdce6f26UL, 0x95ad7f70UL,
 333.179 +    0x2d111815UL, 0x3fa4b7fbUL, 0x8718d09eUL, 0x1acfe827UL, 0xa2738f42UL,
 333.180 +    0xb0c620acUL, 0x087a47c9UL, 0xa032af3eUL, 0x188ec85bUL, 0x0a3b67b5UL,
 333.181 +    0xb28700d0UL, 0x2f503869UL, 0x97ec5f0cUL, 0x8559f0e2UL, 0x3de59787UL,
 333.182 +    0x658687d1UL, 0xdd3ae0b4UL, 0xcf8f4f5aUL, 0x7733283fUL, 0xeae41086UL,
 333.183 +    0x525877e3UL, 0x40edd80dUL, 0xf851bf68UL, 0xf02bf8a1UL, 0x48979fc4UL,
 333.184 +    0x5a22302aUL, 0xe29e574fUL, 0x7f496ff6UL, 0xc7f50893UL, 0xd540a77dUL,
 333.185 +    0x6dfcc018UL, 0x359fd04eUL, 0x8d23b72bUL, 0x9f9618c5UL, 0x272a7fa0UL,
 333.186 +    0xbafd4719UL, 0x0241207cUL, 0x10f48f92UL, 0xa848e8f7UL, 0x9b14583dUL,
 333.187 +    0x23a83f58UL, 0x311d90b6UL, 0x89a1f7d3UL, 0x1476cf6aUL, 0xaccaa80fUL,
 333.188 +    0xbe7f07e1UL, 0x06c36084UL, 0x5ea070d2UL, 0xe61c17b7UL, 0xf4a9b859UL,
 333.189 +    0x4c15df3cUL, 0xd1c2e785UL, 0x697e80e0UL, 0x7bcb2f0eUL, 0xc377486bUL,
 333.190 +    0xcb0d0fa2UL, 0x73b168c7UL, 0x6104c729UL, 0xd9b8a04cUL, 0x446f98f5UL,
 333.191 +    0xfcd3ff90UL, 0xee66507eUL, 0x56da371bUL, 0x0eb9274dUL, 0xb6054028UL,
 333.192 +    0xa4b0efc6UL, 0x1c0c88a3UL, 0x81dbb01aUL, 0x3967d77fUL, 0x2bd27891UL,
 333.193 +    0x936e1ff4UL, 0x3b26f703UL, 0x839a9066UL, 0x912f3f88UL, 0x299358edUL,
 333.194 +    0xb4446054UL, 0x0cf80731UL, 0x1e4da8dfUL, 0xa6f1cfbaUL, 0xfe92dfecUL,
 333.195 +    0x462eb889UL, 0x549b1767UL, 0xec277002UL, 0x71f048bbUL, 0xc94c2fdeUL,
 333.196 +    0xdbf98030UL, 0x6345e755UL, 0x6b3fa09cUL, 0xd383c7f9UL, 0xc1366817UL,
 333.197 +    0x798a0f72UL, 0xe45d37cbUL, 0x5ce150aeUL, 0x4e54ff40UL, 0xf6e89825UL,
 333.198 +    0xae8b8873UL, 0x1637ef16UL, 0x048240f8UL, 0xbc3e279dUL, 0x21e91f24UL,
 333.199 +    0x99557841UL, 0x8be0d7afUL, 0x335cb0caUL, 0xed59b63bUL, 0x55e5d15eUL,
 333.200 +    0x47507eb0UL, 0xffec19d5UL, 0x623b216cUL, 0xda874609UL, 0xc832e9e7UL,
 333.201 +    0x708e8e82UL, 0x28ed9ed4UL, 0x9051f9b1UL, 0x82e4565fUL, 0x3a58313aUL,
 333.202 +    0xa78f0983UL, 0x1f336ee6UL, 0x0d86c108UL, 0xb53aa66dUL, 0xbd40e1a4UL,
 333.203 +    0x05fc86c1UL, 0x1749292fUL, 0xaff54e4aUL, 0x322276f3UL, 0x8a9e1196UL,
 333.204 +    0x982bbe78UL, 0x2097d91dUL, 0x78f4c94bUL, 0xc048ae2eUL, 0xd2fd01c0UL,
 333.205 +    0x6a4166a5UL, 0xf7965e1cUL, 0x4f2a3979UL, 0x5d9f9697UL, 0xe523f1f2UL,
 333.206 +    0x4d6b1905UL, 0xf5d77e60UL, 0xe762d18eUL, 0x5fdeb6ebUL, 0xc2098e52UL,
 333.207 +    0x7ab5e937UL, 0x680046d9UL, 0xd0bc21bcUL, 0x88df31eaUL, 0x3063568fUL,
 333.208 +    0x22d6f961UL, 0x9a6a9e04UL, 0x07bda6bdUL, 0xbf01c1d8UL, 0xadb46e36UL,
 333.209 +    0x15080953UL, 0x1d724e9aUL, 0xa5ce29ffUL, 0xb77b8611UL, 0x0fc7e174UL,
 333.210 +    0x9210d9cdUL, 0x2aacbea8UL, 0x38191146UL, 0x80a57623UL, 0xd8c66675UL,
 333.211 +    0x607a0110UL, 0x72cfaefeUL, 0xca73c99bUL, 0x57a4f122UL, 0xef189647UL,
 333.212 +    0xfdad39a9UL, 0x45115eccUL, 0x764dee06UL, 0xcef18963UL, 0xdc44268dUL,
 333.213 +    0x64f841e8UL, 0xf92f7951UL, 0x41931e34UL, 0x5326b1daUL, 0xeb9ad6bfUL,
 333.214 +    0xb3f9c6e9UL, 0x0b45a18cUL, 0x19f00e62UL, 0xa14c6907UL, 0x3c9b51beUL,
 333.215 +    0x842736dbUL, 0x96929935UL, 0x2e2efe50UL, 0x2654b999UL, 0x9ee8defcUL,
 333.216 +    0x8c5d7112UL, 0x34e11677UL, 0xa9362eceUL, 0x118a49abUL, 0x033fe645UL,
 333.217 +    0xbb838120UL, 0xe3e09176UL, 0x5b5cf613UL, 0x49e959fdUL, 0xf1553e98UL,
 333.218 +    0x6c820621UL, 0xd43e6144UL, 0xc68bceaaUL, 0x7e37a9cfUL, 0xd67f4138UL,
 333.219 +    0x6ec3265dUL, 0x7c7689b3UL, 0xc4caeed6UL, 0x591dd66fUL, 0xe1a1b10aUL,
 333.220 +    0xf3141ee4UL, 0x4ba87981UL, 0x13cb69d7UL, 0xab770eb2UL, 0xb9c2a15cUL,
 333.221 +    0x017ec639UL, 0x9ca9fe80UL, 0x241599e5UL, 0x36a0360bUL, 0x8e1c516eUL,
 333.222 +    0x866616a7UL, 0x3eda71c2UL, 0x2c6fde2cUL, 0x94d3b949UL, 0x090481f0UL,
 333.223 +    0xb1b8e695UL, 0xa30d497bUL, 0x1bb12e1eUL, 0x43d23e48UL, 0xfb6e592dUL,
 333.224 +    0xe9dbf6c3UL, 0x516791a6UL, 0xccb0a91fUL, 0x740cce7aUL, 0x66b96194UL,
 333.225 +    0xde0506f1UL
 333.226 +  },
 333.227 +  {
 333.228 +    0x00000000UL, 0x96300777UL, 0x2c610eeeUL, 0xba510999UL, 0x19c46d07UL,
 333.229 +    0x8ff46a70UL, 0x35a563e9UL, 0xa395649eUL, 0x3288db0eUL, 0xa4b8dc79UL,
 333.230 +    0x1ee9d5e0UL, 0x88d9d297UL, 0x2b4cb609UL, 0xbd7cb17eUL, 0x072db8e7UL,
 333.231 +    0x911dbf90UL, 0x6410b71dUL, 0xf220b06aUL, 0x4871b9f3UL, 0xde41be84UL,
 333.232 +    0x7dd4da1aUL, 0xebe4dd6dUL, 0x51b5d4f4UL, 0xc785d383UL, 0x56986c13UL,
 333.233 +    0xc0a86b64UL, 0x7af962fdUL, 0xecc9658aUL, 0x4f5c0114UL, 0xd96c0663UL,
 333.234 +    0x633d0ffaUL, 0xf50d088dUL, 0xc8206e3bUL, 0x5e10694cUL, 0xe44160d5UL,
 333.235 +    0x727167a2UL, 0xd1e4033cUL, 0x47d4044bUL, 0xfd850dd2UL, 0x6bb50aa5UL,
 333.236 +    0xfaa8b535UL, 0x6c98b242UL, 0xd6c9bbdbUL, 0x40f9bcacUL, 0xe36cd832UL,
 333.237 +    0x755cdf45UL, 0xcf0dd6dcUL, 0x593dd1abUL, 0xac30d926UL, 0x3a00de51UL,
 333.238 +    0x8051d7c8UL, 0x1661d0bfUL, 0xb5f4b421UL, 0x23c4b356UL, 0x9995bacfUL,
 333.239 +    0x0fa5bdb8UL, 0x9eb80228UL, 0x0888055fUL, 0xb2d90cc6UL, 0x24e90bb1UL,
 333.240 +    0x877c6f2fUL, 0x114c6858UL, 0xab1d61c1UL, 0x3d2d66b6UL, 0x9041dc76UL,
 333.241 +    0x0671db01UL, 0xbc20d298UL, 0x2a10d5efUL, 0x8985b171UL, 0x1fb5b606UL,
 333.242 +    0xa5e4bf9fUL, 0x33d4b8e8UL, 0xa2c90778UL, 0x34f9000fUL, 0x8ea80996UL,
 333.243 +    0x18980ee1UL, 0xbb0d6a7fUL, 0x2d3d6d08UL, 0x976c6491UL, 0x015c63e6UL,
 333.244 +    0xf4516b6bUL, 0x62616c1cUL, 0xd8306585UL, 0x4e0062f2UL, 0xed95066cUL,
 333.245 +    0x7ba5011bUL, 0xc1f40882UL, 0x57c40ff5UL, 0xc6d9b065UL, 0x50e9b712UL,
 333.246 +    0xeab8be8bUL, 0x7c88b9fcUL, 0xdf1ddd62UL, 0x492dda15UL, 0xf37cd38cUL,
 333.247 +    0x654cd4fbUL, 0x5861b24dUL, 0xce51b53aUL, 0x7400bca3UL, 0xe230bbd4UL,
 333.248 +    0x41a5df4aUL, 0xd795d83dUL, 0x6dc4d1a4UL, 0xfbf4d6d3UL, 0x6ae96943UL,
 333.249 +    0xfcd96e34UL, 0x468867adUL, 0xd0b860daUL, 0x732d0444UL, 0xe51d0333UL,
 333.250 +    0x5f4c0aaaUL, 0xc97c0dddUL, 0x3c710550UL, 0xaa410227UL, 0x10100bbeUL,
 333.251 +    0x86200cc9UL, 0x25b56857UL, 0xb3856f20UL, 0x09d466b9UL, 0x9fe461ceUL,
 333.252 +    0x0ef9de5eUL, 0x98c9d929UL, 0x2298d0b0UL, 0xb4a8d7c7UL, 0x173db359UL,
 333.253 +    0x810db42eUL, 0x3b5cbdb7UL, 0xad6cbac0UL, 0x2083b8edUL, 0xb6b3bf9aUL,
 333.254 +    0x0ce2b603UL, 0x9ad2b174UL, 0x3947d5eaUL, 0xaf77d29dUL, 0x1526db04UL,
 333.255 +    0x8316dc73UL, 0x120b63e3UL, 0x843b6494UL, 0x3e6a6d0dUL, 0xa85a6a7aUL,
 333.256 +    0x0bcf0ee4UL, 0x9dff0993UL, 0x27ae000aUL, 0xb19e077dUL, 0x44930ff0UL,
 333.257 +    0xd2a30887UL, 0x68f2011eUL, 0xfec20669UL, 0x5d5762f7UL, 0xcb676580UL,
 333.258 +    0x71366c19UL, 0xe7066b6eUL, 0x761bd4feUL, 0xe02bd389UL, 0x5a7ada10UL,
 333.259 +    0xcc4add67UL, 0x6fdfb9f9UL, 0xf9efbe8eUL, 0x43beb717UL, 0xd58eb060UL,
 333.260 +    0xe8a3d6d6UL, 0x7e93d1a1UL, 0xc4c2d838UL, 0x52f2df4fUL, 0xf167bbd1UL,
 333.261 +    0x6757bca6UL, 0xdd06b53fUL, 0x4b36b248UL, 0xda2b0dd8UL, 0x4c1b0aafUL,
 333.262 +    0xf64a0336UL, 0x607a0441UL, 0xc3ef60dfUL, 0x55df67a8UL, 0xef8e6e31UL,
 333.263 +    0x79be6946UL, 0x8cb361cbUL, 0x1a8366bcUL, 0xa0d26f25UL, 0x36e26852UL,
 333.264 +    0x95770cccUL, 0x03470bbbUL, 0xb9160222UL, 0x2f260555UL, 0xbe3bbac5UL,
 333.265 +    0x280bbdb2UL, 0x925ab42bUL, 0x046ab35cUL, 0xa7ffd7c2UL, 0x31cfd0b5UL,
 333.266 +    0x8b9ed92cUL, 0x1daede5bUL, 0xb0c2649bUL, 0x26f263ecUL, 0x9ca36a75UL,
 333.267 +    0x0a936d02UL, 0xa906099cUL, 0x3f360eebUL, 0x85670772UL, 0x13570005UL,
 333.268 +    0x824abf95UL, 0x147ab8e2UL, 0xae2bb17bUL, 0x381bb60cUL, 0x9b8ed292UL,
 333.269 +    0x0dbed5e5UL, 0xb7efdc7cUL, 0x21dfdb0bUL, 0xd4d2d386UL, 0x42e2d4f1UL,
 333.270 +    0xf8b3dd68UL, 0x6e83da1fUL, 0xcd16be81UL, 0x5b26b9f6UL, 0xe177b06fUL,
 333.271 +    0x7747b718UL, 0xe65a0888UL, 0x706a0fffUL, 0xca3b0666UL, 0x5c0b0111UL,
 333.272 +    0xff9e658fUL, 0x69ae62f8UL, 0xd3ff6b61UL, 0x45cf6c16UL, 0x78e20aa0UL,
 333.273 +    0xeed20dd7UL, 0x5483044eUL, 0xc2b30339UL, 0x612667a7UL, 0xf71660d0UL,
 333.274 +    0x4d476949UL, 0xdb776e3eUL, 0x4a6ad1aeUL, 0xdc5ad6d9UL, 0x660bdf40UL,
 333.275 +    0xf03bd837UL, 0x53aebca9UL, 0xc59ebbdeUL, 0x7fcfb247UL, 0xe9ffb530UL,
 333.276 +    0x1cf2bdbdUL, 0x8ac2bacaUL, 0x3093b353UL, 0xa6a3b424UL, 0x0536d0baUL,
 333.277 +    0x9306d7cdUL, 0x2957de54UL, 0xbf67d923UL, 0x2e7a66b3UL, 0xb84a61c4UL,
 333.278 +    0x021b685dUL, 0x942b6f2aUL, 0x37be0bb4UL, 0xa18e0cc3UL, 0x1bdf055aUL,
 333.279 +    0x8def022dUL
 333.280 +  },
 333.281 +  {
 333.282 +    0x00000000UL, 0x41311b19UL, 0x82623632UL, 0xc3532d2bUL, 0x04c56c64UL,
 333.283 +    0x45f4777dUL, 0x86a75a56UL, 0xc796414fUL, 0x088ad9c8UL, 0x49bbc2d1UL,
 333.284 +    0x8ae8effaUL, 0xcbd9f4e3UL, 0x0c4fb5acUL, 0x4d7eaeb5UL, 0x8e2d839eUL,
 333.285 +    0xcf1c9887UL, 0x5112c24aUL, 0x1023d953UL, 0xd370f478UL, 0x9241ef61UL,
 333.286 +    0x55d7ae2eUL, 0x14e6b537UL, 0xd7b5981cUL, 0x96848305UL, 0x59981b82UL,
 333.287 +    0x18a9009bUL, 0xdbfa2db0UL, 0x9acb36a9UL, 0x5d5d77e6UL, 0x1c6c6cffUL,
 333.288 +    0xdf3f41d4UL, 0x9e0e5acdUL, 0xa2248495UL, 0xe3159f8cUL, 0x2046b2a7UL,
 333.289 +    0x6177a9beUL, 0xa6e1e8f1UL, 0xe7d0f3e8UL, 0x2483dec3UL, 0x65b2c5daUL,
 333.290 +    0xaaae5d5dUL, 0xeb9f4644UL, 0x28cc6b6fUL, 0x69fd7076UL, 0xae6b3139UL,
 333.291 +    0xef5a2a20UL, 0x2c09070bUL, 0x6d381c12UL, 0xf33646dfUL, 0xb2075dc6UL,
 333.292 +    0x715470edUL, 0x30656bf4UL, 0xf7f32abbUL, 0xb6c231a2UL, 0x75911c89UL,
 333.293 +    0x34a00790UL, 0xfbbc9f17UL, 0xba8d840eUL, 0x79dea925UL, 0x38efb23cUL,
 333.294 +    0xff79f373UL, 0xbe48e86aUL, 0x7d1bc541UL, 0x3c2ade58UL, 0x054f79f0UL,
 333.295 +    0x447e62e9UL, 0x872d4fc2UL, 0xc61c54dbUL, 0x018a1594UL, 0x40bb0e8dUL,
 333.296 +    0x83e823a6UL, 0xc2d938bfUL, 0x0dc5a038UL, 0x4cf4bb21UL, 0x8fa7960aUL,
 333.297 +    0xce968d13UL, 0x0900cc5cUL, 0x4831d745UL, 0x8b62fa6eUL, 0xca53e177UL,
 333.298 +    0x545dbbbaUL, 0x156ca0a3UL, 0xd63f8d88UL, 0x970e9691UL, 0x5098d7deUL,
 333.299 +    0x11a9ccc7UL, 0xd2fae1ecUL, 0x93cbfaf5UL, 0x5cd76272UL, 0x1de6796bUL,
 333.300 +    0xdeb55440UL, 0x9f844f59UL, 0x58120e16UL, 0x1923150fUL, 0xda703824UL,
 333.301 +    0x9b41233dUL, 0xa76bfd65UL, 0xe65ae67cUL, 0x2509cb57UL, 0x6438d04eUL,
 333.302 +    0xa3ae9101UL, 0xe29f8a18UL, 0x21cca733UL, 0x60fdbc2aUL, 0xafe124adUL,
 333.303 +    0xeed03fb4UL, 0x2d83129fUL, 0x6cb20986UL, 0xab2448c9UL, 0xea1553d0UL,
 333.304 +    0x29467efbUL, 0x687765e2UL, 0xf6793f2fUL, 0xb7482436UL, 0x741b091dUL,
 333.305 +    0x352a1204UL, 0xf2bc534bUL, 0xb38d4852UL, 0x70de6579UL, 0x31ef7e60UL,
 333.306 +    0xfef3e6e7UL, 0xbfc2fdfeUL, 0x7c91d0d5UL, 0x3da0cbccUL, 0xfa368a83UL,
 333.307 +    0xbb07919aUL, 0x7854bcb1UL, 0x3965a7a8UL, 0x4b98833bUL, 0x0aa99822UL,
 333.308 +    0xc9fab509UL, 0x88cbae10UL, 0x4f5def5fUL, 0x0e6cf446UL, 0xcd3fd96dUL,
 333.309 +    0x8c0ec274UL, 0x43125af3UL, 0x022341eaUL, 0xc1706cc1UL, 0x804177d8UL,
 333.310 +    0x47d73697UL, 0x06e62d8eUL, 0xc5b500a5UL, 0x84841bbcUL, 0x1a8a4171UL,
 333.311 +    0x5bbb5a68UL, 0x98e87743UL, 0xd9d96c5aUL, 0x1e4f2d15UL, 0x5f7e360cUL,
 333.312 +    0x9c2d1b27UL, 0xdd1c003eUL, 0x120098b9UL, 0x533183a0UL, 0x9062ae8bUL,
 333.313 +    0xd153b592UL, 0x16c5f4ddUL, 0x57f4efc4UL, 0x94a7c2efUL, 0xd596d9f6UL,
 333.314 +    0xe9bc07aeUL, 0xa88d1cb7UL, 0x6bde319cUL, 0x2aef2a85UL, 0xed796bcaUL,
 333.315 +    0xac4870d3UL, 0x6f1b5df8UL, 0x2e2a46e1UL, 0xe136de66UL, 0xa007c57fUL,
 333.316 +    0x6354e854UL, 0x2265f34dUL, 0xe5f3b202UL, 0xa4c2a91bUL, 0x67918430UL,
 333.317 +    0x26a09f29UL, 0xb8aec5e4UL, 0xf99fdefdUL, 0x3accf3d6UL, 0x7bfde8cfUL,
 333.318 +    0xbc6ba980UL, 0xfd5ab299UL, 0x3e099fb2UL, 0x7f3884abUL, 0xb0241c2cUL,
 333.319 +    0xf1150735UL, 0x32462a1eUL, 0x73773107UL, 0xb4e17048UL, 0xf5d06b51UL,
 333.320 +    0x3683467aUL, 0x77b25d63UL, 0x4ed7facbUL, 0x0fe6e1d2UL, 0xccb5ccf9UL,
 333.321 +    0x8d84d7e0UL, 0x4a1296afUL, 0x0b238db6UL, 0xc870a09dUL, 0x8941bb84UL,
 333.322 +    0x465d2303UL, 0x076c381aUL, 0xc43f1531UL, 0x850e0e28UL, 0x42984f67UL,
 333.323 +    0x03a9547eUL, 0xc0fa7955UL, 0x81cb624cUL, 0x1fc53881UL, 0x5ef42398UL,
 333.324 +    0x9da70eb3UL, 0xdc9615aaUL, 0x1b0054e5UL, 0x5a314ffcUL, 0x996262d7UL,
 333.325 +    0xd85379ceUL, 0x174fe149UL, 0x567efa50UL, 0x952dd77bUL, 0xd41ccc62UL,
 333.326 +    0x138a8d2dUL, 0x52bb9634UL, 0x91e8bb1fUL, 0xd0d9a006UL, 0xecf37e5eUL,
 333.327 +    0xadc26547UL, 0x6e91486cUL, 0x2fa05375UL, 0xe836123aUL, 0xa9070923UL,
 333.328 +    0x6a542408UL, 0x2b653f11UL, 0xe479a796UL, 0xa548bc8fUL, 0x661b91a4UL,
 333.329 +    0x272a8abdUL, 0xe0bccbf2UL, 0xa18dd0ebUL, 0x62defdc0UL, 0x23efe6d9UL,
 333.330 +    0xbde1bc14UL, 0xfcd0a70dUL, 0x3f838a26UL, 0x7eb2913fUL, 0xb924d070UL,
 333.331 +    0xf815cb69UL, 0x3b46e642UL, 0x7a77fd5bUL, 0xb56b65dcUL, 0xf45a7ec5UL,
 333.332 +    0x370953eeUL, 0x763848f7UL, 0xb1ae09b8UL, 0xf09f12a1UL, 0x33cc3f8aUL,
 333.333 +    0x72fd2493UL
 333.334 +  },
 333.335 +  {
 333.336 +    0x00000000UL, 0x376ac201UL, 0x6ed48403UL, 0x59be4602UL, 0xdca80907UL,
 333.337 +    0xebc2cb06UL, 0xb27c8d04UL, 0x85164f05UL, 0xb851130eUL, 0x8f3bd10fUL,
 333.338 +    0xd685970dUL, 0xe1ef550cUL, 0x64f91a09UL, 0x5393d808UL, 0x0a2d9e0aUL,
 333.339 +    0x3d475c0bUL, 0x70a3261cUL, 0x47c9e41dUL, 0x1e77a21fUL, 0x291d601eUL,
 333.340 +    0xac0b2f1bUL, 0x9b61ed1aUL, 0xc2dfab18UL, 0xf5b56919UL, 0xc8f23512UL,
 333.341 +    0xff98f713UL, 0xa626b111UL, 0x914c7310UL, 0x145a3c15UL, 0x2330fe14UL,
 333.342 +    0x7a8eb816UL, 0x4de47a17UL, 0xe0464d38UL, 0xd72c8f39UL, 0x8e92c93bUL,
 333.343 +    0xb9f80b3aUL, 0x3cee443fUL, 0x0b84863eUL, 0x523ac03cUL, 0x6550023dUL,
 333.344 +    0x58175e36UL, 0x6f7d9c37UL, 0x36c3da35UL, 0x01a91834UL, 0x84bf5731UL,
 333.345 +    0xb3d59530UL, 0xea6bd332UL, 0xdd011133UL, 0x90e56b24UL, 0xa78fa925UL,
 333.346 +    0xfe31ef27UL, 0xc95b2d26UL, 0x4c4d6223UL, 0x7b27a022UL, 0x2299e620UL,
 333.347 +    0x15f32421UL, 0x28b4782aUL, 0x1fdeba2bUL, 0x4660fc29UL, 0x710a3e28UL,
 333.348 +    0xf41c712dUL, 0xc376b32cUL, 0x9ac8f52eUL, 0xada2372fUL, 0xc08d9a70UL,
 333.349 +    0xf7e75871UL, 0xae591e73UL, 0x9933dc72UL, 0x1c259377UL, 0x2b4f5176UL,
 333.350 +    0x72f11774UL, 0x459bd575UL, 0x78dc897eUL, 0x4fb64b7fUL, 0x16080d7dUL,
 333.351 +    0x2162cf7cUL, 0xa4748079UL, 0x931e4278UL, 0xcaa0047aUL, 0xfdcac67bUL,
 333.352 +    0xb02ebc6cUL, 0x87447e6dUL, 0xdefa386fUL, 0xe990fa6eUL, 0x6c86b56bUL,
 333.353 +    0x5bec776aUL, 0x02523168UL, 0x3538f369UL, 0x087faf62UL, 0x3f156d63UL,
 333.354 +    0x66ab2b61UL, 0x51c1e960UL, 0xd4d7a665UL, 0xe3bd6464UL, 0xba032266UL,
 333.355 +    0x8d69e067UL, 0x20cbd748UL, 0x17a11549UL, 0x4e1f534bUL, 0x7975914aUL,
 333.356 +    0xfc63de4fUL, 0xcb091c4eUL, 0x92b75a4cUL, 0xa5dd984dUL, 0x989ac446UL,
 333.357 +    0xaff00647UL, 0xf64e4045UL, 0xc1248244UL, 0x4432cd41UL, 0x73580f40UL,
 333.358 +    0x2ae64942UL, 0x1d8c8b43UL, 0x5068f154UL, 0x67023355UL, 0x3ebc7557UL,
 333.359 +    0x09d6b756UL, 0x8cc0f853UL, 0xbbaa3a52UL, 0xe2147c50UL, 0xd57ebe51UL,
 333.360 +    0xe839e25aUL, 0xdf53205bUL, 0x86ed6659UL, 0xb187a458UL, 0x3491eb5dUL,
 333.361 +    0x03fb295cUL, 0x5a456f5eUL, 0x6d2fad5fUL, 0x801b35e1UL, 0xb771f7e0UL,
 333.362 +    0xeecfb1e2UL, 0xd9a573e3UL, 0x5cb33ce6UL, 0x6bd9fee7UL, 0x3267b8e5UL,
 333.363 +    0x050d7ae4UL, 0x384a26efUL, 0x0f20e4eeUL, 0x569ea2ecUL, 0x61f460edUL,
 333.364 +    0xe4e22fe8UL, 0xd388ede9UL, 0x8a36abebUL, 0xbd5c69eaUL, 0xf0b813fdUL,
 333.365 +    0xc7d2d1fcUL, 0x9e6c97feUL, 0xa90655ffUL, 0x2c101afaUL, 0x1b7ad8fbUL,
 333.366 +    0x42c49ef9UL, 0x75ae5cf8UL, 0x48e900f3UL, 0x7f83c2f2UL, 0x263d84f0UL,
 333.367 +    0x115746f1UL, 0x944109f4UL, 0xa32bcbf5UL, 0xfa958df7UL, 0xcdff4ff6UL,
 333.368 +    0x605d78d9UL, 0x5737bad8UL, 0x0e89fcdaUL, 0x39e33edbUL, 0xbcf571deUL,
 333.369 +    0x8b9fb3dfUL, 0xd221f5ddUL, 0xe54b37dcUL, 0xd80c6bd7UL, 0xef66a9d6UL,
 333.370 +    0xb6d8efd4UL, 0x81b22dd5UL, 0x04a462d0UL, 0x33cea0d1UL, 0x6a70e6d3UL,
 333.371 +    0x5d1a24d2UL, 0x10fe5ec5UL, 0x27949cc4UL, 0x7e2adac6UL, 0x494018c7UL,
 333.372 +    0xcc5657c2UL, 0xfb3c95c3UL, 0xa282d3c1UL, 0x95e811c0UL, 0xa8af4dcbUL,
 333.373 +    0x9fc58fcaUL, 0xc67bc9c8UL, 0xf1110bc9UL, 0x740744ccUL, 0x436d86cdUL,
 333.374 +    0x1ad3c0cfUL, 0x2db902ceUL, 0x4096af91UL, 0x77fc6d90UL, 0x2e422b92UL,
 333.375 +    0x1928e993UL, 0x9c3ea696UL, 0xab546497UL, 0xf2ea2295UL, 0xc580e094UL,
 333.376 +    0xf8c7bc9fUL, 0xcfad7e9eUL, 0x9613389cUL, 0xa179fa9dUL, 0x246fb598UL,
 333.377 +    0x13057799UL, 0x4abb319bUL, 0x7dd1f39aUL, 0x3035898dUL, 0x075f4b8cUL,
 333.378 +    0x5ee10d8eUL, 0x698bcf8fUL, 0xec9d808aUL, 0xdbf7428bUL, 0x82490489UL,
 333.379 +    0xb523c688UL, 0x88649a83UL, 0xbf0e5882UL, 0xe6b01e80UL, 0xd1dadc81UL,
 333.380 +    0x54cc9384UL, 0x63a65185UL, 0x3a181787UL, 0x0d72d586UL, 0xa0d0e2a9UL,
 333.381 +    0x97ba20a8UL, 0xce0466aaUL, 0xf96ea4abUL, 0x7c78ebaeUL, 0x4b1229afUL,
 333.382 +    0x12ac6fadUL, 0x25c6adacUL, 0x1881f1a7UL, 0x2feb33a6UL, 0x765575a4UL,
 333.383 +    0x413fb7a5UL, 0xc429f8a0UL, 0xf3433aa1UL, 0xaafd7ca3UL, 0x9d97bea2UL,
 333.384 +    0xd073c4b5UL, 0xe71906b4UL, 0xbea740b6UL, 0x89cd82b7UL, 0x0cdbcdb2UL,
 333.385 +    0x3bb10fb3UL, 0x620f49b1UL, 0x55658bb0UL, 0x6822d7bbUL, 0x5f4815baUL,
 333.386 +    0x06f653b8UL, 0x319c91b9UL, 0xb48adebcUL, 0x83e01cbdUL, 0xda5e5abfUL,
 333.387 +    0xed3498beUL
 333.388 +  },
 333.389 +  {
 333.390 +    0x00000000UL, 0x6567bcb8UL, 0x8bc809aaUL, 0xeeafb512UL, 0x5797628fUL,
 333.391 +    0x32f0de37UL, 0xdc5f6b25UL, 0xb938d79dUL, 0xef28b4c5UL, 0x8a4f087dUL,
 333.392 +    0x64e0bd6fUL, 0x018701d7UL, 0xb8bfd64aUL, 0xddd86af2UL, 0x3377dfe0UL,
 333.393 +    0x56106358UL, 0x9f571950UL, 0xfa30a5e8UL, 0x149f10faUL, 0x71f8ac42UL,
 333.394 +    0xc8c07bdfUL, 0xada7c767UL, 0x43087275UL, 0x266fcecdUL, 0x707fad95UL,
 333.395 +    0x1518112dUL, 0xfbb7a43fUL, 0x9ed01887UL, 0x27e8cf1aUL, 0x428f73a2UL,
 333.396 +    0xac20c6b0UL, 0xc9477a08UL, 0x3eaf32a0UL, 0x5bc88e18UL, 0xb5673b0aUL,
 333.397 +    0xd00087b2UL, 0x6938502fUL, 0x0c5fec97UL, 0xe2f05985UL, 0x8797e53dUL,
 333.398 +    0xd1878665UL, 0xb4e03addUL, 0x5a4f8fcfUL, 0x3f283377UL, 0x8610e4eaUL,
 333.399 +    0xe3775852UL, 0x0dd8ed40UL, 0x68bf51f8UL, 0xa1f82bf0UL, 0xc49f9748UL,
 333.400 +    0x2a30225aUL, 0x4f579ee2UL, 0xf66f497fUL, 0x9308f5c7UL, 0x7da740d5UL,
 333.401 +    0x18c0fc6dUL, 0x4ed09f35UL, 0x2bb7238dUL, 0xc518969fUL, 0xa07f2a27UL,
 333.402 +    0x1947fdbaUL, 0x7c204102UL, 0x928ff410UL, 0xf7e848a8UL, 0x3d58149bUL,
 333.403 +    0x583fa823UL, 0xb6901d31UL, 0xd3f7a189UL, 0x6acf7614UL, 0x0fa8caacUL,
 333.404 +    0xe1077fbeUL, 0x8460c306UL, 0xd270a05eUL, 0xb7171ce6UL, 0x59b8a9f4UL,
 333.405 +    0x3cdf154cUL, 0x85e7c2d1UL, 0xe0807e69UL, 0x0e2fcb7bUL, 0x6b4877c3UL,
 333.406 +    0xa20f0dcbUL, 0xc768b173UL, 0x29c70461UL, 0x4ca0b8d9UL, 0xf5986f44UL,
 333.407 +    0x90ffd3fcUL, 0x7e5066eeUL, 0x1b37da56UL, 0x4d27b90eUL, 0x284005b6UL,
 333.408 +    0xc6efb0a4UL, 0xa3880c1cUL, 0x1ab0db81UL, 0x7fd76739UL, 0x9178d22bUL,
 333.409 +    0xf41f6e93UL, 0x03f7263bUL, 0x66909a83UL, 0x883f2f91UL, 0xed589329UL,
 333.410 +    0x546044b4UL, 0x3107f80cUL, 0xdfa84d1eUL, 0xbacff1a6UL, 0xecdf92feUL,
 333.411 +    0x89b82e46UL, 0x67179b54UL, 0x027027ecUL, 0xbb48f071UL, 0xde2f4cc9UL,
 333.412 +    0x3080f9dbUL, 0x55e74563UL, 0x9ca03f6bUL, 0xf9c783d3UL, 0x176836c1UL,
 333.413 +    0x720f8a79UL, 0xcb375de4UL, 0xae50e15cUL, 0x40ff544eUL, 0x2598e8f6UL,
 333.414 +    0x73888baeUL, 0x16ef3716UL, 0xf8408204UL, 0x9d273ebcUL, 0x241fe921UL,
 333.415 +    0x41785599UL, 0xafd7e08bUL, 0xcab05c33UL, 0x3bb659edUL, 0x5ed1e555UL,
 333.416 +    0xb07e5047UL, 0xd519ecffUL, 0x6c213b62UL, 0x094687daUL, 0xe7e932c8UL,
 333.417 +    0x828e8e70UL, 0xd49eed28UL, 0xb1f95190UL, 0x5f56e482UL, 0x3a31583aUL,
 333.418 +    0x83098fa7UL, 0xe66e331fUL, 0x08c1860dUL, 0x6da63ab5UL, 0xa4e140bdUL,
 333.419 +    0xc186fc05UL, 0x2f294917UL, 0x4a4ef5afUL, 0xf3762232UL, 0x96119e8aUL,
 333.420 +    0x78be2b98UL, 0x1dd99720UL, 0x4bc9f478UL, 0x2eae48c0UL, 0xc001fdd2UL,
 333.421 +    0xa566416aUL, 0x1c5e96f7UL, 0x79392a4fUL, 0x97969f5dUL, 0xf2f123e5UL,
 333.422 +    0x05196b4dUL, 0x607ed7f5UL, 0x8ed162e7UL, 0xebb6de5fUL, 0x528e09c2UL,
 333.423 +    0x37e9b57aUL, 0xd9460068UL, 0xbc21bcd0UL, 0xea31df88UL, 0x8f566330UL,
 333.424 +    0x61f9d622UL, 0x049e6a9aUL, 0xbda6bd07UL, 0xd8c101bfUL, 0x366eb4adUL,
 333.425 +    0x53090815UL, 0x9a4e721dUL, 0xff29cea5UL, 0x11867bb7UL, 0x74e1c70fUL,
 333.426 +    0xcdd91092UL, 0xa8beac2aUL, 0x46111938UL, 0x2376a580UL, 0x7566c6d8UL,
 333.427 +    0x10017a60UL, 0xfeaecf72UL, 0x9bc973caUL, 0x22f1a457UL, 0x479618efUL,
 333.428 +    0xa939adfdUL, 0xcc5e1145UL, 0x06ee4d76UL, 0x6389f1ceUL, 0x8d2644dcUL,
 333.429 +    0xe841f864UL, 0x51792ff9UL, 0x341e9341UL, 0xdab12653UL, 0xbfd69aebUL,
 333.430 +    0xe9c6f9b3UL, 0x8ca1450bUL, 0x620ef019UL, 0x07694ca1UL, 0xbe519b3cUL,
 333.431 +    0xdb362784UL, 0x35999296UL, 0x50fe2e2eUL, 0x99b95426UL, 0xfcdee89eUL,
 333.432 +    0x12715d8cUL, 0x7716e134UL, 0xce2e36a9UL, 0xab498a11UL, 0x45e63f03UL,
 333.433 +    0x208183bbUL, 0x7691e0e3UL, 0x13f65c5bUL, 0xfd59e949UL, 0x983e55f1UL,
 333.434 +    0x2106826cUL, 0x44613ed4UL, 0xaace8bc6UL, 0xcfa9377eUL, 0x38417fd6UL,
 333.435 +    0x5d26c36eUL, 0xb389767cUL, 0xd6eecac4UL, 0x6fd61d59UL, 0x0ab1a1e1UL,
 333.436 +    0xe41e14f3UL, 0x8179a84bUL, 0xd769cb13UL, 0xb20e77abUL, 0x5ca1c2b9UL,
 333.437 +    0x39c67e01UL, 0x80fea99cUL, 0xe5991524UL, 0x0b36a036UL, 0x6e511c8eUL,
 333.438 +    0xa7166686UL, 0xc271da3eUL, 0x2cde6f2cUL, 0x49b9d394UL, 0xf0810409UL,
 333.439 +    0x95e6b8b1UL, 0x7b490da3UL, 0x1e2eb11bUL, 0x483ed243UL, 0x2d596efbUL,
 333.440 +    0xc3f6dbe9UL, 0xa6916751UL, 0x1fa9b0ccUL, 0x7ace0c74UL, 0x9461b966UL,
 333.441 +    0xf10605deUL
 333.442 +#endif
 333.443 +  }
 333.444 +};
   334.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
   334.2 +++ b/deps/glpk/src/zlib/deflate.c	Sun Nov 06 20:59:10 2011 +0100
   334.3 @@ -0,0 +1,1834 @@
   334.4 +/* deflate.c -- compress data using the deflation algorithm
   334.5 + * Copyright (C) 1995-2010 Jean-loup Gailly and Mark Adler
   334.6 + * For conditions of distribution and use, see copyright notice in zlib.h
   334.7 + */
   334.8 +
   334.9 +/*
  334.10 + *  ALGORITHM
  334.11 + *
  334.12 + *      The "deflation" process depends on being able to identify portions
  334.13 + *      of the input text which are identical to earlier input (within a
  334.14 + *      sliding window trailing behind the input currently being processed).
  334.15 + *
  334.16 + *      The most straightforward technique turns out to be the fastest for
  334.17 + *      most input files: try all possible matches and select the longest.
  334.18 + *      The key feature of this algorithm is that insertions into the string
  334.19 + *      dictionary are very simple and thus fast, and deletions are avoided
  334.20 + *      completely. Insertions are performed at each input character, whereas
  334.21 + *      string matches are performed only when the previous match ends. So it
  334.22 + *      is preferable to spend more time in matches to allow very fast string
  334.23 + *      insertions and avoid deletions. The matching algorithm for small
  334.24 + *      strings is inspired from that of Rabin & Karp. A brute force approach
  334.25 + *      is used to find longer strings when a small match has been found.
  334.26 + *      A similar algorithm is used in comic (by Jan-Mark Wams) and freeze
  334.27 + *      (by Leonid Broukhis).
  334.28 + *         A previous version of this file used a more sophisticated algorithm
  334.29 + *      (by Fiala and Greene) which is guaranteed to run in linear amortized
  334.30 + *      time, but has a larger average cost, uses more memory and is patented.
  334.31 + *      However the F&G algorithm may be faster for some highly redundant
  334.32 + *      files if the parameter max_chain_length (described below) is too large.
  334.33 + *
  334.34 + *  ACKNOWLEDGEMENTS
  334.35 + *
  334.36 + *      The idea of lazy evaluation of matches is due to Jan-Mark Wams, and
  334.37 + *      I found it in 'freeze' written by Leonid Broukhis.
  334.38 + *      Thanks to many people for bug reports and testing.
  334.39 + *
  334.40 + *  REFERENCES
  334.41 + *
  334.42 + *      Deutsch, L.P.,"DEFLATE Compressed Data Format Specification".
  334.43 + *      Available in http://www.ietf.org/rfc/rfc1951.txt
  334.44 + *
  334.45 + *      A description of the Rabin and Karp algorithm is given in the book
  334.46 + *         "Algorithms" by R. Sedgewick, Addison-Wesley, p252.
  334.47 + *
  334.48 + *      Fiala,E.R., and Greene,D.H.
  334.49 + *         Data Compression with Finite Windows, Comm.ACM, 32,4 (1989) 490-595
  334.50 + *
  334.51 + */
  334.52 +
  334.53 +/* @(#) $Id$ */
  334.54 +
  334.55 +#include "deflate.h"
  334.56 +
  334.57 +const char deflate_copyright[] =
  334.58 +   " deflate 1.2.5 Copyright 1995-2010 Jean-loup Gailly and Mark Adler ";
  334.59 +/*
  334.60 +  If you use the zlib library in a product, an acknowledgment is welcome
  334.61 +  in the documentation of your product. If for some reason you cannot
  334.62 +  include such an acknowledgment, I would appreciate that you keep this
  334.63 +  copyright string in the executable of your product.
  334.64 + */
  334.65 +
  334.66 +/* ===========================================================================
  334.67 + *  Function prototypes.
  334.68 + */
  334.69 +typedef enum {
  334.70 +    need_more,      /* block not completed, need more input or more output */
  334.71 +    block_done,     /* block flush performed */
  334.72 +    finish_started, /* finish started, need only more output at next deflate */
  334.73 +    finish_done     /* finish done, accept no more input or output */
  334.74 +} block_state;
  334.75 +
  334.76 +typedef block_state (*compress_func) OF((deflate_state *s, int flush));
  334.77 +/* Compression function. Returns the block state after the call. */
  334.78 +
  334.79 +local void fill_window    OF((deflate_state *s));
  334.80 +local block_state deflate_stored OF((deflate_state *s, int flush));
  334.81 +local block_state deflate_fast   OF((deflate_state *s, int flush));
  334.82 +#ifndef FASTEST
  334.83 +local block_state deflate_slow   OF((deflate_state *s, int flush));
  334.84 +#endif
  334.85 +local block_state deflate_rle    OF((deflate_state *s, int flush));
  334.86 +local block_state deflate_huff   OF((deflate_state *s, int flush));
  334.87 +local void lm_init        OF((deflate_state *s));
  334.88 +local void putShortMSB    OF((deflate_state *s, uInt b));
  334.89 +local void flush_pending  OF((z_streamp strm));
  334.90 +local int read_buf        OF((z_streamp strm, Bytef *buf, unsigned size));
  334.91 +#ifdef ASMV
  334.92 +      void match_init OF((void)); /* asm code initialization */
  334.93 +      uInt longest_match  OF((deflate_state *s, IPos cur_match));
  334.94 +#else
  334.95 +local uInt longest_match  OF((deflate_state *s, IPos cur_match));
  334.96 +#endif
  334.97 +
  334.98 +#ifdef DEBUG
  334.99 +local  void check_match OF((deflate_state *s, IPos start, IPos match,
 334.100 +                            int length));
 334.101 +#endif
 334.102 +
 334.103 +/* ===========================================================================
 334.104 + * Local data
 334.105 + */
 334.106 +
 334.107 +#define NIL 0
 334.108 +/* Tail of hash chains */
 334.109 +
 334.110 +#ifndef TOO_FAR
 334.111 +#  define TOO_FAR 4096
 334.112 +#endif
 334.113 +/* Matches of length 3 are discarded if their distance exceeds TOO_FAR */
 334.114 +
 334.115 +/* Values for max_lazy_match, good_match and max_chain_length, depending on
 334.116 + * the desired pack level (0..9). The values given below have been tuned to
 334.117 + * exclude worst case performance for pathological files. Better values may be
 334.118 + * found for specific files.
 334.119 + */
 334.120 +typedef struct config_s {
 334.121 +   ush good_length; /* reduce lazy search above this match length */
 334.122 +   ush max_lazy;    /* do not perform lazy search above this match length */
 334.123 +   ush nice_length; /* quit search above this match length */
 334.124 +   ush max_chain;
 334.125 +   compress_func func;
 334.126 +} config;
 334.127 +
 334.128 +#ifdef FASTEST
 334.129 +local const config configuration_table[2] = {
 334.130 +/*      good lazy nice chain */
 334.131 +/* 0 */ {0,    0,  0,    0, deflate_stored},  /* store only */
 334.132 +/* 1 */ {4,    4,  8,    4, deflate_fast}}; /* max speed, no lazy matches */
 334.133 +#else
 334.134 +local const config configuration_table[10] = {
 334.135 +/*      good lazy nice chain */
 334.136 +/* 0 */ {0,    0,  0,    0, deflate_stored},  /* store only */
 334.137 +/* 1 */ {4,    4,  8,    4, deflate_fast}, /* max speed, no lazy matches */
 334.138 +/* 2 */ {4,    5, 16,    8, deflate_fast},
 334.139 +/* 3 */ {4,    6, 32,   32, deflate_fast},
 334.140 +
 334.141 +/* 4 */ {4,    4, 16,   16, deflate_slow},  /* lazy matches */
 334.142 +/* 5 */ {8,   16, 32,   32, deflate_slow},
 334.143 +/* 6 */ {8,   16, 128, 128, deflate_slow},
 334.144 +/* 7 */ {8,   32, 128, 256, deflate_slow},
 334.145 +/* 8 */ {32, 128, 258, 1024, deflate_slow},
 334.146 +/* 9 */ {32, 258, 258, 4096, deflate_slow}}; /* max compression */
 334.147 +#endif
 334.148 +
 334.149 +/* Note: the deflate() code requires max_lazy >= MIN_MATCH and max_chain >= 4
 334.150 + * For deflate_fast() (levels <= 3) good is ignored and lazy has a different
 334.151 + * meaning.
 334.152 + */
 334.153 +
 334.154 +#define EQUAL 0
 334.155 +/* result of memcmp for equal strings */
 334.156 +
 334.157 +#ifndef NO_DUMMY_DECL
 334.158 +struct static_tree_desc_s {int dummy;}; /* for buggy compilers */
 334.159 +#endif
 334.160 +
 334.161 +/* ===========================================================================
 334.162 + * Update a hash value with the given input byte
 334.163 + * IN  assertion: all calls to to UPDATE_HASH are made with consecutive
 334.164 + *    input characters, so that a running hash key can be computed from the
 334.165 + *    previous key instead of complete recalculation each time.
 334.166 + */
 334.167 +#define UPDATE_HASH(s,h,c) (h = (((h)<<s->hash_shift) ^ (c)) & s->hash_mask)
 334.168 +
 334.169 +
 334.170 +/* ===========================================================================
 334.171 + * Insert string str in the dictionary and set match_head to the previous head
 334.172 + * of the hash chain (the most recent string with same hash key). Return
 334.173 + * the previous length of the hash chain.
 334.174 + * If this file is compiled with -DFASTEST, the compression level is forced
 334.175 + * to 1, and no hash chains are maintained.
 334.176 + * IN  assertion: all calls to to INSERT_STRING are made with consecutive
 334.177 + *    input characters and the first MIN_MATCH bytes of str are valid
 334.178 + *    (except for the last MIN_MATCH-1 bytes of the input file).
 334.179 + */
 334.180 +#ifdef FASTEST
 334.181 +#define INSERT_STRING(s, str, match_head) \
 334.182 +   (UPDATE_HASH(s, s->ins_h, s->window[(str) + (MIN_MATCH-1)]), \
 334.183 +    match_head = s->head[s->ins_h], \
 334.184 +    s->head[s->ins_h] = (Pos)(str))
 334.185 +#else
 334.186 +#define INSERT_STRING(s, str, match_head) \
 334.187 +   (UPDATE_HASH(s, s->ins_h, s->window[(str) + (MIN_MATCH-1)]), \
 334.188 +    match_head = s->prev[(str) & s->w_mask] = s->head[s->ins_h], \
 334.189 +    s->head[s->ins_h] = (Pos)(str))
 334.190 +#endif
 334.191 +
 334.192 +/* ===========================================================================
 334.193 + * Initialize the hash table (avoiding 64K overflow for 16 bit systems).
 334.194 + * prev[] will be initialized on the fly.
 334.195 + */
 334.196 +#define CLEAR_HASH(s) \
 334.197 +    s->head[s->hash_size-1] = NIL; \
 334.198 +    zmemzero((Bytef *)s->head, (unsigned)(s->hash_size-1)*sizeof(*s->head));
 334.199 +
 334.200 +/* ========================================================================= */
 334.201 +int ZEXPORT deflateInit_(strm, level, version, stream_size)
 334.202 +    z_streamp strm;
 334.203 +    int level;
 334.204 +    const char *version;
 334.205 +    int stream_size;
 334.206 +{
 334.207 +    return deflateInit2_(strm, level, Z_DEFLATED, MAX_WBITS, DEF_MEM_LEVEL,
 334.208 +                         Z_DEFAULT_STRATEGY, version, stream_size);
 334.209 +    /* To do: ignore strm->next_in if we use it as window */
 334.210 +}
 334.211 +
 334.212 +/* ========================================================================= */
 334.213 +int ZEXPORT deflateInit2_(strm, level, method, windowBits, memLevel, strategy,
 334.214 +                  version, stream_size)
 334.215 +    z_streamp strm;
 334.216 +    int  level;
 334.217 +    int  method;
 334.218 +    int  windowBits;
 334.219 +    int  memLevel;
 334.220 +    int  strategy;
 334.221 +    const char *version;
 334.222 +    int stream_size;
 334.223 +{
 334.224 +    deflate_state *s;
 334.225 +    int wrap = 1;
 334.226 +    static const char my_version[] = ZLIB_VERSION;
 334.227 +
 334.228 +    ushf *overlay;
 334.229 +    /* We overlay pending_buf and d_buf+l_buf. This works since the average
 334.230 +     * output size for (length,distance) codes is <= 24 bits.
 334.231 +     */
 334.232 +
 334.233 +    if (version == Z_NULL || version[0] != my_version[0] ||
 334.234 +        stream_size != sizeof(z_stream)) {
 334.235 +        return Z_VERSION_ERROR;
 334.236 +    }
 334.237 +    if (strm == Z_NULL) return Z_STREAM_ERROR;
 334.238 +
 334.239 +    strm->msg = Z_NULL;
 334.240 +    if (strm->zalloc == (alloc_func)0) {
 334.241 +        strm->zalloc = zcalloc;
 334.242 +        strm->opaque = (voidpf)0;
 334.243 +    }
 334.244 +    if (strm->zfree == (free_func)0) strm->zfree = zcfree;
 334.245 +
 334.246 +#ifdef FASTEST
 334.247 +    if (level != 0) level = 1;
 334.248 +#else
 334.249 +    if (level == Z_DEFAULT_COMPRESSION) level = 6;
 334.250 +#endif
 334.251 +
 334.252 +    if (windowBits < 0) { /* suppress zlib wrapper */
 334.253 +        wrap = 0;
 334.254 +        windowBits = -windowBits;
 334.255 +    }
 334.256 +#ifdef GZIP
 334.257 +    else if (windowBits > 15) {
 334.258 +        wrap = 2;       /* write gzip wrapper instead */
 334.259 +        windowBits -= 16;
 334.260 +    }
 334.261 +#endif
 334.262 +    if (memLevel < 1 || memLevel > MAX_MEM_LEVEL || method != Z_DEFLATED ||
 334.263 +        windowBits < 8 || windowBits > 15 || level < 0 || level > 9 ||
 334.264 +        strategy < 0 || strategy > Z_FIXED) {
 334.265 +        return Z_STREAM_ERROR;
 334.266 +    }
 334.267 +    if (windowBits == 8) windowBits = 9;  /* until 256-byte window bug fixed */
 334.268 +    s = (deflate_state *) ZALLOC(strm, 1, sizeof(deflate_state));
 334.269 +    if (s == Z_NULL) return Z_MEM_ERROR;
 334.270 +    strm->state = (struct internal_state FAR *)s;
 334.271 +    s->strm = strm;
 334.272 +
 334.273 +    s->wrap = wrap;
 334.274 +    s->gzhead = Z_NULL;
 334.275 +    s->w_bits = windowBits;
 334.276 +    s->w_size = 1 << s->w_bits;
 334.277 +    s->w_mask = s->w_size - 1;
 334.278 +
 334.279 +    s->hash_bits = memLevel + 7;
 334.280 +    s->hash_size = 1 << s->hash_bits;
 334.281 +    s->hash_mask = s->hash_size - 1;
 334.282 +    s->hash_shift =  ((s->hash_bits+MIN_MATCH-1)/MIN_MATCH);
 334.283 +
 334.284 +    s->window = (Bytef *) ZALLOC(strm, s->w_size, 2*sizeof(Byte));
 334.285 +    s->prev   = (Posf *)  ZALLOC(strm, s->w_size, sizeof(Pos));
 334.286 +    s->head   = (Posf *)  ZALLOC(strm, s->hash_size, sizeof(Pos));
 334.287 +
 334.288 +    s->high_water = 0;      /* nothing written to s->window yet */
 334.289 +
 334.290 +    s->lit_bufsize = 1 << (memLevel + 6); /* 16K elements by default */
 334.291 +
 334.292 +    overlay = (ushf *) ZALLOC(strm, s->lit_bufsize, sizeof(ush)+2);
 334.293 +    s->pending_buf = (uchf *) overlay;
 334.294 +    s->pending_buf_size = (ulg)s->lit_bufsize * (sizeof(ush)+2L);
 334.295 +
 334.296 +    if (s->window == Z_NULL || s->prev == Z_NULL || s->head == Z_NULL ||
 334.297 +        s->pending_buf == Z_NULL) {
 334.298 +        s->status = FINISH_STATE;
 334.299 +        strm->msg = (char*)ERR_MSG(Z_MEM_ERROR);
 334.300 +        deflateEnd (strm);
 334.301 +        return Z_MEM_ERROR;
 334.302 +    }
 334.303 +    s->d_buf = overlay + s->lit_bufsize/sizeof(ush);
 334.304 +    s->l_buf = s->pending_buf + (1+sizeof(ush))*s->lit_bufsize;
 334.305 +
 334.306 +    s->level = level;
 334.307 +    s->strategy = strategy;
 334.308 +    s->method = (Byte)method;
 334.309 +
 334.310 +    return deflateReset(strm);
 334.311 +}
 334.312 +
 334.313 +/* ========================================================================= */
 334.314 +int ZEXPORT deflateSetDictionary (strm, dictionary, dictLength)
 334.315 +    z_streamp strm;
 334.316 +    const Bytef *dictionary;
 334.317 +    uInt  dictLength;
 334.318 +{
 334.319 +    deflate_state *s;
 334.320 +    uInt length = dictLength;
 334.321 +    uInt n;
 334.322 +    IPos hash_head = 0;
 334.323 +
 334.324 +    if (strm == Z_NULL || strm->state == Z_NULL || dictionary == Z_NULL ||
 334.325 +        strm->state->wrap == 2 ||
 334.326 +        (strm->state->wrap == 1 && strm->state->status != INIT_STATE))
 334.327 +        return Z_STREAM_ERROR;
 334.328 +
 334.329 +    s = strm->state;
 334.330 +    if (s->wrap)
 334.331 +        strm->adler = adler32(strm->adler, dictionary, dictLength);
 334.332 +
 334.333 +    if (length < MIN_MATCH) return Z_OK;
 334.334 +    if (length > s->w_size) {
 334.335 +        length = s->w_size;
 334.336 +        dictionary += dictLength - length; /* use the tail of the dictionary */
 334.337 +    }
 334.338 +    zmemcpy(s->window, dictionary, length);
 334.339 +    s->strstart = length;
 334.340 +    s->block_start = (long)length;
 334.341 +
 334.342 +    /* Insert all strings in the hash table (except for the last two bytes).
 334.343 +     * s->lookahead stays null, so s->ins_h will be recomputed at the next
 334.344 +     * call of fill_window.
 334.345 +     */
 334.346 +    s->ins_h = s->window[0];
 334.347 +    UPDATE_HASH(s, s->ins_h, s->window[1]);
 334.348 +    for (n = 0; n <= length - MIN_MATCH; n++) {
 334.349 +        INSERT_STRING(s, n, hash_head);
 334.350 +    }
 334.351 +    if (hash_head) hash_head = 0;  /* to make compiler happy */
 334.352 +    return Z_OK;
 334.353 +}
 334.354 +
 334.355 +/* ========================================================================= */
 334.356 +int ZEXPORT deflateReset (strm)
 334.357 +    z_streamp strm;
 334.358 +{
 334.359 +    deflate_state *s;
 334.360 +
 334.361 +    if (strm == Z_NULL || strm->state == Z_NULL ||
 334.362 +        strm->zalloc == (alloc_func)0 || strm->zfree == (free_func)0) {
 334.363 +        return Z_STREAM_ERROR;
 334.364 +    }
 334.365 +
 334.366 +    strm->total_in = strm->total_out = 0;
 334.367 +    strm->msg = Z_NULL; /* use zfree if we ever allocate msg dynamically */
 334.368 +    strm->data_type = Z_UNKNOWN;
 334.369 +
 334.370 +    s = (deflate_state *)strm->state;
 334.371 +    s->pending = 0;
 334.372 +    s->pending_out = s->pending_buf;
 334.373 +
 334.374 +    if (s->wrap < 0) {
 334.375 +        s->wrap = -s->wrap; /* was made negative by deflate(..., Z_FINISH); */
 334.376 +    }
 334.377 +    s->status = s->wrap ? INIT_STATE : BUSY_STATE;
 334.378 +    strm->adler =
 334.379 +#ifdef GZIP
 334.380 +        s->wrap == 2 ? crc32(0L, Z_NULL, 0) :
 334.381 +#endif
 334.382 +        adler32(0L, Z_NULL, 0);
 334.383 +    s->last_flush = Z_NO_FLUSH;
 334.384 +
 334.385 +    _tr_init(s);
 334.386 +    lm_init(s);
 334.387 +
 334.388 +    return Z_OK;
 334.389 +}
 334.390 +
 334.391 +/* ========================================================================= */
 334.392 +int ZEXPORT deflateSetHeader (strm, head)
 334.393 +    z_streamp strm;
 334.394 +    gz_headerp head;
 334.395 +{
 334.396 +    if (strm == Z_NULL || strm->state == Z_NULL) return Z_STREAM_ERROR;
 334.397 +    if (strm->state->wrap != 2) return Z_STREAM_ERROR;
 334.398 +    strm->state->gzhead = head;
 334.399 +    return Z_OK;
 334.400 +}
 334.401 +
 334.402 +/* ========================================================================= */
 334.403 +int ZEXPORT deflatePrime (strm, bits, value)
 334.404 +    z_streamp strm;
 334.405 +    int bits;
 334.406 +    int value;
 334.407 +{
 334.408 +    if (strm == Z_NULL || strm->state == Z_NULL) return Z_STREAM_ERROR;
 334.409 +    strm->state->bi_valid = bits;
 334.410 +    strm->state->bi_buf = (ush)(value & ((1 << bits) - 1));
 334.411 +    return Z_OK;
 334.412 +}
 334.413 +
 334.414 +/* ========================================================================= */
 334.415 +int ZEXPORT deflateParams(strm, level, strategy)
 334.416 +    z_streamp strm;
 334.417 +    int level;
 334.418 +    int strategy;
 334.419 +{
 334.420 +    deflate_state *s;
 334.421 +    compress_func func;
 334.422 +    int err = Z_OK;
 334.423 +
 334.424 +    if (strm == Z_NULL || strm->state == Z_NULL) return Z_STREAM_ERROR;
 334.425 +    s = strm->state;
 334.426 +
 334.427 +#ifdef FASTEST
 334.428 +    if (level != 0) level = 1;
 334.429 +#else
 334.430 +    if (level == Z_DEFAULT_COMPRESSION) level = 6;
 334.431 +#endif
 334.432 +    if (level < 0 || level > 9 || strategy < 0 || strategy > Z_FIXED) {
 334.433 +        return Z_STREAM_ERROR;
 334.434 +    }
 334.435 +    func = configuration_table[s->level].func;
 334.436 +
 334.437 +    if ((strategy != s->strategy || func != configuration_table[level].func) &&
 334.438 +        strm->total_in != 0) {
 334.439 +        /* Flush the last buffer: */
 334.440 +        err = deflate(strm, Z_BLOCK);
 334.441 +    }
 334.442 +    if (s->level != level) {
 334.443 +        s->level = level;
 334.444 +        s->max_lazy_match   = configuration_table[level].max_lazy;
 334.445 +        s->good_match       = configuration_table[level].good_length;
 334.446 +        s->nice_match       = configuration_table[level].nice_length;
 334.447 +        s->max_chain_length = configuration_table[level].max_chain;
 334.448 +    }
 334.449 +    s->strategy = strategy;
 334.450 +    return err;
 334.451 +}
 334.452 +
 334.453 +/* ========================================================================= */
 334.454 +int ZEXPORT deflateTune(strm, good_length, max_lazy, nice_length, max_chain)
 334.455 +    z_streamp strm;
 334.456 +    int good_length;
 334.457 +    int max_lazy;
 334.458 +    int nice_length;
 334.459 +    int max_chain;
 334.460 +{
 334.461 +    deflate_state *s;
 334.462 +
 334.463 +    if (strm == Z_NULL || strm->state == Z_NULL) return Z_STREAM_ERROR;
 334.464 +    s = strm->state;
 334.465 +    s->good_match = good_length;
 334.466 +    s->max_lazy_match = max_lazy;
 334.467 +    s->nice_match = nice_length;
 334.468 +    s->max_chain_length = max_chain;
 334.469 +    return Z_OK;
 334.470 +}
 334.471 +
 334.472 +/* =========================================================================
 334.473 + * For the default windowBits of 15 and memLevel of 8, this function returns
 334.474 + * a close to exact, as well as small, upper bound on the compressed size.
 334.475 + * They are coded as constants here for a reason--if the #define's are
 334.476 + * changed, then this function needs to be changed as well.  The return
 334.477 + * value for 15 and 8 only works for those exact settings.
 334.478 + *
 334.479 + * For any setting other than those defaults for windowBits and memLevel,
 334.480 + * the value returned is a conservative worst case for the maximum expansion
 334.481 + * resulting from using fixed blocks instead of stored blocks, which deflate
 334.482 + * can emit on compressed data for some combinations of the parameters.
 334.483 + *
 334.484 + * This function could be more sophisticated to provide closer upper bounds for
 334.485 + * every combination of windowBits and memLevel.  But even the conservative
 334.486 + * upper bound of about 14% expansion does not seem onerous for output buffer
 334.487 + * allocation.
 334.488 + */
 334.489 +uLong ZEXPORT deflateBound(strm, sourceLen)
 334.490 +    z_streamp strm;
 334.491 +    uLong sourceLen;
 334.492 +{
 334.493 +    deflate_state *s;
 334.494 +    uLong complen, wraplen;
 334.495 +    Bytef *str;
 334.496 +
 334.497 +    /* conservative upper bound for compressed data */
 334.498 +    complen = sourceLen +
 334.499 +              ((sourceLen + 7) >> 3) + ((sourceLen + 63) >> 6) + 5;
 334.500 +
 334.501 +    /* if can't get parameters, return conservative bound plus zlib wrapper */
 334.502 +    if (strm == Z_NULL || strm->state == Z_NULL)
 334.503 +        return complen + 6;
 334.504 +
 334.505 +    /* compute wrapper length */
 334.506 +    s = strm->state;
 334.507 +    switch (s->wrap) {
 334.508 +    case 0:                                 /* raw deflate */
 334.509 +        wraplen = 0;
 334.510 +        break;
 334.511 +    case 1:                                 /* zlib wrapper */
 334.512 +        wraplen = 6 + (s->strstart ? 4 : 0);
 334.513 +        break;
 334.514 +    case 2:                                 /* gzip wrapper */
 334.515 +        wraplen = 18;
 334.516 +        if (s->gzhead != Z_NULL) {          /* user-supplied gzip header */
 334.517 +            if (s->gzhead->extra != Z_NULL)
 334.518 +                wraplen += 2 + s->gzhead->extra_len;
 334.519 +            str = s->gzhead->name;
 334.520 +            if (str != Z_NULL)
 334.521 +                do {
 334.522 +                    wraplen++;
 334.523 +                } while (*str++);
 334.524 +            str = s->gzhead->comment;
 334.525 +            if (str != Z_NULL)
 334.526 +                do {
 334.527 +                    wraplen++;
 334.528 +                } while (*str++);
 334.529 +            if (s->gzhead->hcrc)
 334.530 +                wraplen += 2;
 334.531 +        }
 334.532 +        break;
 334.533 +    default:                                /* for compiler happiness */
 334.534 +        wraplen = 6;
 334.535 +    }
 334.536 +
 334.537 +    /* if not default parameters, return conservative bound */
 334.538 +    if (s->w_bits != 15 || s->hash_bits != 8 + 7)
 334.539 +        return complen + wraplen;
 334.540 +
 334.541 +    /* default settings: return tight bound for that case */
 334.542 +    return sourceLen + (sourceLen >> 12) + (sourceLen >> 14) +
 334.543 +           (sourceLen >> 25) + 13 - 6 + wraplen;
 334.544 +}
 334.545 +
 334.546 +/* =========================================================================
 334.547 + * Put a short in the pending buffer. The 16-bit value is put in MSB order.
 334.548 + * IN assertion: the stream state is correct and there is enough room in
 334.549 + * pending_buf.
 334.550 + */
 334.551 +local void putShortMSB (s, b)
 334.552 +    deflate_state *s;
 334.553 +    uInt b;
 334.554 +{
 334.555 +    put_byte(s, (Byte)(b >> 8));
 334.556 +    put_byte(s, (Byte)(b & 0xff));
 334.557 +}
 334.558 +
 334.559 +/* =========================================================================
 334.560 + * Flush as much pending output as possible. All deflate() output goes
 334.561 + * through this function so some applications may wish to modify it
 334.562 + * to avoid allocating a large strm->next_out buffer and copying into it.
 334.563 + * (See also read_buf()).
 334.564 + */
 334.565 +local void flush_pending(strm)
 334.566 +    z_streamp strm;
 334.567 +{
 334.568 +    unsigned len = strm->state->pending;
 334.569 +
 334.570 +    if (len > strm->avail_out) len = strm->avail_out;
 334.571 +    if (len == 0) return;
 334.572 +
 334.573 +    zmemcpy(strm->next_out, strm->state->pending_out, len);
 334.574 +    strm->next_out  += len;
 334.575 +    strm->state->pending_out  += len;
 334.576 +    strm->total_out += len;
 334.577 +    strm->avail_out  -= len;
 334.578 +    strm->state->pending -= len;
 334.579 +    if (strm->state->pending == 0) {
 334.580 +        strm->state->pending_out = strm->state->pending_buf;
 334.581 +    }
 334.582 +}
 334.583 +
 334.584 +/* ========================================================================= */
 334.585 +int ZEXPORT deflate (strm, flush)
 334.586 +    z_streamp strm;
 334.587 +    int flush;
 334.588 +{
 334.589 +    int old_flush; /* value of flush param for previous deflate call */
 334.590 +    deflate_state *s;
 334.591 +
 334.592 +    if (strm == Z_NULL || strm->state == Z_NULL ||
 334.593 +        flush > Z_BLOCK || flush < 0) {
 334.594 +        return Z_STREAM_ERROR;
 334.595 +    }
 334.596 +    s = strm->state;
 334.597 +
 334.598 +    if (strm->next_out == Z_NULL ||
 334.599 +        (strm->next_in == Z_NULL && strm->avail_in != 0) ||
 334.600 +        (s->status == FINISH_STATE && flush != Z_FINISH)) {
 334.601 +        ERR_RETURN(strm, Z_STREAM_ERROR);
 334.602 +    }
 334.603 +    if (strm->avail_out == 0) ERR_RETURN(strm, Z_BUF_ERROR);
 334.604 +
 334.605 +    s->strm = strm; /* just in case */
 334.606 +    old_flush = s->last_flush;
 334.607 +    s->last_flush = flush;
 334.608 +
 334.609 +    /* Write the header */
 334.610 +    if (s->status == INIT_STATE) {
 334.611 +#ifdef GZIP
 334.612 +        if (s->wrap == 2) {
 334.613 +            strm->adler = crc32(0L, Z_NULL, 0);
 334.614 +            put_byte(s, 31);
 334.615 +            put_byte(s, 139);
 334.616 +            put_byte(s, 8);
 334.617 +            if (s->gzhead == Z_NULL) {
 334.618 +                put_byte(s, 0);
 334.619 +                put_byte(s, 0);
 334.620 +                put_byte(s, 0);
 334.621 +                put_byte(s, 0);
 334.622 +                put_byte(s, 0);
 334.623 +                put_byte(s, s->level == 9 ? 2 :
 334.624 +                            (s->strategy >= Z_HUFFMAN_ONLY || s->level < 2 ?
 334.625 +                             4 : 0));
 334.626 +                put_byte(s, OS_CODE);
 334.627 +                s->status = BUSY_STATE;
 334.628 +            }
 334.629 +            else {
 334.630 +                put_byte(s, (s->gzhead->text ? 1 : 0) +
 334.631 +                            (s->gzhead->hcrc ? 2 : 0) +
 334.632 +                            (s->gzhead->extra == Z_NULL ? 0 : 4) +
 334.633 +                            (s->gzhead->name == Z_NULL ? 0 : 8) +
 334.634 +                            (s->gzhead->comment == Z_NULL ? 0 : 16)
 334.635 +                        );
 334.636 +                put_byte(s, (Byte)(s->gzhead->time & 0xff));
 334.637 +                put_byte(s, (Byte)((s->gzhead->time >> 8) & 0xff));
 334.638 +                put_byte(s, (Byte)((s->gzhead->time >> 16) & 0xff));
 334.639 +                put_byte(s, (Byte)((s->gzhead->time >> 24) & 0xff));
 334.640 +                put_byte(s, s->level == 9 ? 2 :
 334.641 +                            (s->strategy >= Z_HUFFMAN_ONLY || s->level < 2 ?
 334.642 +                             4 : 0));
 334.643 +                put_byte(s, s->gzhead->os & 0xff);
 334.644 +                if (s->gzhead->extra != Z_NULL) {
 334.645 +                    put_byte(s, s->gzhead->extra_len & 0xff);
 334.646 +                    put_byte(s, (s->gzhead->extra_len >> 8) & 0xff);
 334.647 +                }
 334.648 +                if (s->gzhead->hcrc)
 334.649 +                    strm->adler = crc32(strm->adler, s->pending_buf,
 334.650 +                                        s->pending);
 334.651 +                s->gzindex = 0;
 334.652 +                s->status = EXTRA_STATE;
 334.653 +            }
 334.654 +        }
 334.655 +        else
 334.656 +#endif
 334.657 +        {
 334.658 +            uInt header = (Z_DEFLATED + ((s->w_bits-8)<<4)) << 8;
 334.659 +            uInt level_flags;
 334.660 +
 334.661 +            if (s->strategy >= Z_HUFFMAN_ONLY || s->level < 2)
 334.662 +                level_flags = 0;
 334.663 +            else if (s->level < 6)
 334.664 +                level_flags = 1;
 334.665 +            else if (s->level == 6)
 334.666 +                level_flags = 2;
 334.667 +            else
 334.668 +                level_flags = 3;
 334.669 +            header |= (level_flags << 6);
 334.670 +            if (s->strstart != 0) header |= PRESET_DICT;
 334.671 +            header += 31 - (header % 31);
 334.672 +
 334.673 +            s->status = BUSY_STATE;
 334.674 +            putShortMSB(s, header);
 334.675 +
 334.676 +            /* Save the adler32 of the preset dictionary: */
 334.677 +            if (s->strstart != 0) {
 334.678 +                putShortMSB(s, (uInt)(strm->adler >> 16));
 334.679 +                putShortMSB(s, (uInt)(strm->adler & 0xffff));
 334.680 +            }
 334.681 +            strm->adler = adler32(0L, Z_NULL, 0);
 334.682 +        }
 334.683 +    }
 334.684 +#ifdef GZIP
 334.685 +    if (s->status == EXTRA_STATE) {
 334.686 +        if (s->gzhead->extra != Z_NULL) {
 334.687 +            uInt beg = s->pending;  /* start of bytes to update crc */
 334.688 +
 334.689 +            while (s->gzindex < (s->gzhead->extra_len & 0xffff)) {
 334.690 +                if (s->pending == s->pending_buf_size) {
 334.691 +                    if (s->gzhead->hcrc && s->pending > beg)
 334.692 +                        strm->adler = crc32(strm->adler, s->pending_buf + beg,
 334.693 +                                            s->pending - beg);
 334.694 +                    flush_pending(strm);
 334.695 +                    beg = s->pending;
 334.696 +                    if (s->pending == s->pending_buf_size)
 334.697 +                        break;
 334.698 +                }
 334.699 +                put_byte(s, s->gzhead->extra[s->gzindex]);
 334.700 +                s->gzindex++;
 334.701 +            }
 334.702 +            if (s->gzhead->hcrc && s->pending > beg)
 334.703 +                strm->adler = crc32(strm->adler, s->pending_buf + beg,
 334.704 +                                    s->pending - beg);
 334.705 +            if (s->gzindex == s->gzhead->extra_len) {
 334.706 +                s->gzindex = 0;
 334.707 +                s->status = NAME_STATE;
 334.708 +            }
 334.709 +        }
 334.710 +        else
 334.711 +            s->status = NAME_STATE;
 334.712 +    }
 334.713 +    if (s->status == NAME_STATE) {
 334.714 +        if (s->gzhead->name != Z_NULL) {
 334.715 +            uInt beg = s->pending;  /* start of bytes to update crc */
 334.716 +            int val;
 334.717 +
 334.718 +            do {
 334.719 +                if (s->pending == s->pending_buf_size) {
 334.720 +                    if (s->gzhead->hcrc && s->pending > beg)
 334.721 +                        strm->adler = crc32(strm->adler, s->pending_buf + beg,
 334.722 +                                            s->pending - beg);
 334.723 +                    flush_pending(strm);
 334.724 +                    beg = s->pending;
 334.725 +                    if (s->pending == s->pending_buf_size) {
 334.726 +                        val = 1;
 334.727 +                        break;
 334.728 +                    }
 334.729 +                }
 334.730 +                val = s->gzhead->name[s->gzindex++];
 334.731 +                put_byte(s, val);
 334.732 +            } while (val != 0);
 334.733 +            if (s->gzhead->hcrc && s->pending > beg)
 334.734 +                strm->adler = crc32(strm->adler, s->pending_buf + beg,
 334.735 +                                    s->pending - beg);
 334.736 +            if (val == 0) {
 334.737 +                s->gzindex = 0;
 334.738 +                s->status = COMMENT_STATE;
 334.739 +            }
 334.740 +        }
 334.741 +        else
 334.742 +            s->status = COMMENT_STATE;
 334.743 +    }
 334.744 +    if (s->status == COMMENT_STATE) {
 334.745 +        if (s->gzhead->comment != Z_NULL) {
 334.746 +            uInt beg = s->pending;  /* start of bytes to update crc */
 334.747 +            int val;
 334.748 +
 334.749 +            do {
 334.750 +                if (s->pending == s->pending_buf_size) {
 334.751 +                    if (s->gzhead->hcrc && s->pending > beg)
 334.752 +                        strm->adler = crc32(strm->adler, s->pending_buf + beg,
 334.753 +                                            s->pending - beg);
 334.754 +                    flush_pending(strm);
 334.755 +                    beg = s->pending;
 334.756 +                    if (s->pending == s->pending_buf_size) {
 334.757 +                        val = 1;
 334.758 +                        break;
 334.759 +                    }
 334.760 +                }
 334.761 +                val = s->gzhead->comment[s->gzindex++];
 334.762 +                put_byte(s, val);
 334.763 +            } while (val != 0);
 334.764 +            if (s->gzhead->hcrc && s->pending > beg)
 334.765 +                strm->adler = crc32(strm->adler, s->pending_buf + beg,
 334.766 +                                    s->pending - beg);
 334.767 +            if (val == 0)
 334.768 +                s->status = HCRC_STATE;
 334.769 +        }
 334.770 +        else
 334.771 +            s->status = HCRC_STATE;
 334.772 +    }
 334.773 +    if (s->status == HCRC_STATE) {
 334.774 +        if (s->gzhead->hcrc) {
 334.775 +            if (s->pending + 2 > s->pending_buf_size)
 334.776 +                flush_pending(strm);
 334.777 +            if (s->pending + 2 <= s->pending_buf_size) {
 334.778 +                put_byte(s, (Byte)(strm->adler & 0xff));
 334.779 +                put_byte(s, (Byte)((strm->adler >> 8) & 0xff));
 334.780 +                strm->adler = crc32(0L, Z_NULL, 0);
 334.781 +                s->status = BUSY_STATE;
 334.782 +            }
 334.783 +        }
 334.784 +        else
 334.785 +            s->status = BUSY_STATE;
 334.786 +    }
 334.787 +#endif
 334.788 +
 334.789 +    /* Flush as much pending output as possible */
 334.790 +    if (s->pending != 0) {
 334.791 +        flush_pending(strm);
 334.792 +        if (strm->avail_out == 0) {
 334.793 +            /* Since avail_out is 0, deflate will be called again with
 334.794 +             * more output space, but possibly with both pending and
 334.795 +             * avail_in equal to zero. There won't be anything to do,
 334.796 +             * but this is not an error situation so make sure we
 334.797 +             * return OK instead of BUF_ERROR at next call of deflate:
 334.798 +             */
 334.799 +            s->last_flush = -1;
 334.800 +            return Z_OK;
 334.801 +        }
 334.802 +
 334.803 +    /* Make sure there is something to do and avoid duplicate consecutive
 334.804 +     * flushes. For repeated and useless calls with Z_FINISH, we keep
 334.805 +     * returning Z_STREAM_END instead of Z_BUF_ERROR.
 334.806 +     */
 334.807 +    } else if (strm->avail_in == 0 && flush <= old_flush &&
 334.808 +               flush != Z_FINISH) {
 334.809 +        ERR_RETURN(strm, Z_BUF_ERROR);
 334.810 +    }
 334.811 +
 334.812 +    /* User must not provide more input after the first FINISH: */
 334.813 +    if (s->status == FINISH_STATE && strm->avail_in != 0) {
 334.814 +        ERR_RETURN(strm, Z_BUF_ERROR);
 334.815 +    }
 334.816 +
 334.817 +    /* Start a new block or continue the current one.
 334.818 +     */
 334.819 +    if (strm->avail_in != 0 || s->lookahead != 0 ||
 334.820 +        (flush != Z_NO_FLUSH && s->status != FINISH_STATE)) {
 334.821 +        block_state bstate;
 334.822 +
 334.823 +        bstate = s->strategy == Z_HUFFMAN_ONLY ? deflate_huff(s, flush) :
 334.824 +                    (s->strategy == Z_RLE ? deflate_rle(s, flush) :
 334.825 +                        (*(configuration_table[s->level].func))(s, flush));
 334.826 +
 334.827 +        if (bstate == finish_started || bstate == finish_done) {
 334.828 +            s->status = FINISH_STATE;
 334.829 +        }
 334.830 +        if (bstate == need_more || bstate == finish_started) {
 334.831 +            if (strm->avail_out == 0) {
 334.832 +                s->last_flush = -1; /* avoid BUF_ERROR next call, see above */
 334.833 +            }
 334.834 +            return Z_OK;
 334.835 +            /* If flush != Z_NO_FLUSH && avail_out == 0, the next call
 334.836 +             * of deflate should use the same flush parameter to make sure
 334.837 +             * that the flush is complete. So we don't have to output an
 334.838 +             * empty block here, this will be done at next call. This also
 334.839 +             * ensures that for a very small output buffer, we emit at most
 334.840 +             * one empty block.
 334.841 +             */
 334.842 +        }
 334.843 +        if (bstate == block_done) {
 334.844 +            if (flush == Z_PARTIAL_FLUSH) {
 334.845 +                _tr_align(s);
 334.846 +            } else if (flush != Z_BLOCK) { /* FULL_FLUSH or SYNC_FLUSH */
 334.847 +                _tr_stored_block(s, (char*)0, 0L, 0);
 334.848 +                /* For a full flush, this empty block will be recognized
 334.849 +                 * as a special marker by inflate_sync().
 334.850 +                 */
 334.851 +                if (flush == Z_FULL_FLUSH) {
 334.852 +                    CLEAR_HASH(s);             /* forget history */
 334.853 +                    if (s->lookahead == 0) {
 334.854 +                        s->strstart = 0;
 334.855 +                        s->block_start = 0L;
 334.856 +                    }
 334.857 +                }
 334.858 +            }
 334.859 +            flush_pending(strm);
 334.860 +            if (strm->avail_out == 0) {
 334.861 +              s->last_flush = -1; /* avoid BUF_ERROR at next call, see above */
 334.862 +              return Z_OK;
 334.863 +            }
 334.864 +        }
 334.865 +    }
 334.866 +    Assert(strm->avail_out > 0, "bug2");
 334.867 +
 334.868 +    if (flush != Z_FINISH) return Z_OK;
 334.869 +    if (s->wrap <= 0) return Z_STREAM_END;
 334.870 +
 334.871 +    /* Write the trailer */
 334.872 +#ifdef GZIP
 334.873 +    if (s->wrap == 2) {
 334.874 +        put_byte(s, (Byte)(strm->adler & 0xff));
 334.875 +        put_byte(s, (Byte)((strm->adler >> 8) & 0xff));
 334.876 +        put_byte(s, (Byte)((strm->adler >> 16) & 0xff));
 334.877 +        put_byte(s, (Byte)((strm->adler >> 24) & 0xff));
 334.878 +        put_byte(s, (Byte)(strm->total_in & 0xff));
 334.879 +        put_byte(s, (Byte)((strm->total_in >> 8) & 0xff));
 334.880 +        put_byte(s, (Byte)((strm->total_in >> 16) & 0xff));
 334.881 +        put_byte(s, (Byte)((strm->total_in >> 24) & 0xff));
 334.882 +    }
 334.883 +    else
 334.884 +#endif
 334.885 +    {
 334.886 +        putShortMSB(s, (uInt)(strm->adler >> 16));
 334.887 +        putShortMSB(s, (uInt)(strm->adler & 0xffff));
 334.888 +    }
 334.889 +    flush_pending(strm);
 334.890 +    /* If avail_out is zero, the application will call deflate again
 334.891 +     * to flush the rest.
 334.892 +     */
 334.893 +    if (s->wrap > 0) s->wrap = -s->wrap; /* write the trailer only once! */
 334.894 +    return s->pending != 0 ? Z_OK : Z_STREAM_END;
 334.895 +}
 334.896 +
 334.897 +/* ========================================================================= */
 334.898 +int ZEXPORT deflateEnd (strm)
 334.899 +    z_streamp strm;
 334.900 +{
 334.901 +    int status;
 334.902 +
 334.903 +    if (strm == Z_NULL || strm->state == Z_NULL) return Z_STREAM_ERROR;
 334.904 +
 334.905 +    status = strm->state->status;
 334.906 +    if (status != INIT_STATE &&
 334.907 +        status != EXTRA_STATE &&
 334.908 +        status != NAME_STATE &&
 334.909 +        status != COMMENT_STATE &&
 334.910 +        status != HCRC_STATE &&
 334.911 +        status != BUSY_STATE &&
 334.912 +        status != FINISH_STATE) {
 334.913 +      return Z_STREAM_ERROR;
 334.914 +    }
 334.915 +
 334.916 +    /* Deallocate in reverse order of allocations: */
 334.917 +    TRY_FREE(strm, strm->state->pending_buf);
 334.918 +    TRY_FREE(strm, strm->state->head);
 334.919 +    TRY_FREE(strm, strm->state->prev);
 334.920 +    TRY_FREE(strm, strm->state->window);
 334.921 +
 334.922 +    ZFREE(strm, strm->state);
 334.923 +    strm->state = Z_NULL;
 334.924 +
 334.925 +    return status == BUSY_STATE ? Z_DATA_ERROR : Z_OK;
 334.926 +}
 334.927 +
 334.928 +/* =========================================================================
 334.929 + * Copy the source state to the destination state.
 334.930 + * To simplify the source, this is not supported for 16-bit MSDOS (which
 334.931 + * doesn't have enough memory anyway to duplicate compression states).
 334.932 + */
 334.933 +int ZEXPORT deflateCopy (dest, source)
 334.934 +    z_streamp dest;
 334.935 +    z_streamp source;
 334.936 +{
 334.937 +#ifdef MAXSEG_64K
 334.938 +    return Z_STREAM_ERROR;
 334.939 +#else
 334.940 +    deflate_state *ds;
 334.941 +    deflate_state *ss;
 334.942 +    ushf *overlay;
 334.943 +
 334.944 +
 334.945 +    if (source == Z_NULL || dest == Z_NULL || source->state == Z_NULL) {
 334.946 +        return Z_STREAM_ERROR;
 334.947 +    }
 334.948 +
 334.949 +    ss = source->state;
 334.950 +
 334.951 +    zmemcpy(dest, source, sizeof(z_stream));
 334.952 +
 334.953 +    ds = (deflate_state *) ZALLOC(dest, 1, sizeof(deflate_state));
 334.954 +    if (ds == Z_NULL) return Z_MEM_ERROR;
 334.955 +    dest->state = (struct internal_state FAR *) ds;
 334.956 +    zmemcpy(ds, ss, sizeof(deflate_state));
 334.957 +    ds->strm = dest;
 334.958 +
 334.959 +    ds->window = (Bytef *) ZALLOC(dest, ds->w_size, 2*sizeof(Byte));
 334.960 +    ds->prev   = (Posf *)  ZALLOC(dest, ds->w_size, sizeof(Pos));
 334.961 +    ds->head   = (Posf *)  ZALLOC(dest, ds->hash_size, sizeof(Pos));
 334.962 +    overlay = (ushf *) ZALLOC(dest, ds->lit_bufsize, sizeof(ush)+2);
 334.963 +    ds->pending_buf = (uchf *) overlay;
 334.964 +
 334.965 +    if (ds->window == Z_NULL || ds->prev == Z_NULL || ds->head == Z_NULL ||
 334.966 +        ds->pending_buf == Z_NULL) {
 334.967 +        deflateEnd (dest);
 334.968 +        return Z_MEM_ERROR;
 334.969 +    }
 334.970 +    /* following zmemcpy do not work for 16-bit MSDOS */
 334.971 +    zmemcpy(ds->window, ss->window, ds->w_size * 2 * sizeof(Byte));
 334.972 +    zmemcpy(ds->prev, ss->prev, ds->w_size * sizeof(Pos));
 334.973 +    zmemcpy(ds->head, ss->head, ds->hash_size * sizeof(Pos));
 334.974 +    zmemcpy(ds->pending_buf, ss->pending_buf, (uInt)ds->pending_buf_size);
 334.975 +
 334.976 +    ds->pending_out = ds->pending_buf + (ss->pending_out - ss->pending_buf);
 334.977 +    ds->d_buf = overlay + ds->lit_bufsize/sizeof(ush);
 334.978 +    ds->l_buf = ds->pending_buf + (1+sizeof(ush))*ds->lit_bufsize;
 334.979 +
 334.980 +    ds->l_desc.dyn_tree = ds->dyn_ltree;
 334.981 +    ds->d_desc.dyn_tree = ds->dyn_dtree;
 334.982 +    ds->bl_desc.dyn_tree = ds->bl_tree;
 334.983 +
 334.984 +    return Z_OK;
 334.985 +#endif /* MAXSEG_64K */
 334.986 +}
 334.987 +
 334.988 +/* ===========================================================================
 334.989 + * Read a new buffer from the current input stream, update the adler32
 334.990 + * and total number of bytes read.  All deflate() input goes through
 334.991 + * this function so some applications may wish to modify it to avoid
 334.992 + * allocating a large strm->next_in buffer and copying from it.
 334.993 + * (See also flush_pending()).
 334.994 + */
 334.995 +local int read_buf(strm, buf, size)
 334.996 +    z_streamp strm;
 334.997 +    Bytef *buf;
 334.998 +    unsigned size;
 334.999 +{
334.1000 +    unsigned len = strm->avail_in;
334.1001 +
334.1002 +    if (len > size) len = size;
334.1003 +    if (len == 0) return 0;
334.1004 +
334.1005 +    strm->avail_in  -= len;
334.1006 +
334.1007 +    if (strm->state->wrap == 1) {
334.1008 +        strm->adler = adler32(strm->adler, strm->next_in, len);
334.1009 +    }
334.1010 +#ifdef GZIP
334.1011 +    else if (strm->state->wrap == 2) {
334.1012 +        strm->adler = crc32(strm->adler, strm->next_in, len);
334.1013 +    }
334.1014 +#endif
334.1015 +    zmemcpy(buf, strm->next_in, len);
334.1016 +    strm->next_in  += len;
334.1017 +    strm->total_in += len;
334.1018 +
334.1019 +    return (int)len;
334.1020 +}
334.1021 +
334.1022 +/* ===========================================================================
334.1023 + * Initialize the "longest match" routines for a new zlib stream
334.1024 + */
334.1025 +local void lm_init (s)
334.1026 +    deflate_state *s;
334.1027 +{
334.1028 +    s->window_size = (ulg)2L*s->w_size;
334.1029 +
334.1030 +    CLEAR_HASH(s);
334.1031 +
334.1032 +    /* Set the default configuration parameters:
334.1033 +     */
334.1034 +    s->max_lazy_match   = configuration_table[s->level].max_lazy;
334.1035 +    s->good_match       = configuration_table[s->level].good_length;
334.1036 +    s->nice_match       = configuration_table[s->level].nice_length;
334.1037 +    s->max_chain_length = configuration_table[s->level].max_chain;
334.1038 +
334.1039 +    s->strstart = 0;
334.1040 +    s->block_start = 0L;
334.1041 +    s->lookahead = 0;
334.1042 +    s->match_length = s->prev_length = MIN_MATCH-1;
334.1043 +    s->match_available = 0;
334.1044 +    s->ins_h = 0;
334.1045 +#ifndef FASTEST
334.1046 +#ifdef ASMV
334.1047 +    match_init(); /* initialize the asm code */
334.1048 +#endif
334.1049 +#endif
334.1050 +}
334.1051 +
334.1052 +#ifndef FASTEST
334.1053 +/* ===========================================================================
334.1054 + * Set match_start to the longest match starting at the given string and
334.1055 + * return its length. Matches shorter or equal to prev_length are discarded,
334.1056 + * in which case the result is equal to prev_length and match_start is
334.1057 + * garbage.
334.1058 + * IN assertions: cur_match is the head of the hash chain for the current
334.1059 + *   string (strstart) and its distance is <= MAX_DIST, and prev_length >= 1
334.1060 + * OUT assertion: the match length is not greater than s->lookahead.
334.1061 + */
334.1062 +#ifndef ASMV
334.1063 +/* For 80x86 and 680x0, an optimized version will be provided in match.asm or
334.1064 + * match.S. The code will be functionally equivalent.
334.1065 + */
334.1066 +local uInt longest_match(s, cur_match)
334.1067 +    deflate_state *s;
334.1068 +    IPos cur_match;                             /* current match */
334.1069 +{
334.1070 +    unsigned chain_length = s->max_chain_length;/* max hash chain length */
334.1071 +    register Bytef *scan = s->window + s->strstart; /* current string */
334.1072 +    register Bytef *match;                       /* matched string */
334.1073 +    register int len;                           /* length of current match */
334.1074 +    int best_len = s->prev_length;              /* best match length so far */
334.1075 +    int nice_match = s->nice_match;             /* stop if match long enough */
334.1076 +    IPos limit = s->strstart > (IPos)MAX_DIST(s) ?
334.1077 +        s->strstart - (IPos)MAX_DIST(s) : NIL;
334.1078 +    /* Stop when cur_match becomes <= limit. To simplify the code,
334.1079 +     * we prevent matches with the string of window index 0.
334.1080 +     */
334.1081 +    Posf *prev = s->prev;
334.1082 +    uInt wmask = s->w_mask;
334.1083 +
334.1084 +#ifdef UNALIGNED_OK
334.1085 +    /* Compare two bytes at a time. Note: this is not always beneficial.
334.1086 +     * Try with and without -DUNALIGNED_OK to check.
334.1087 +     */
334.1088 +    register Bytef *strend = s->window + s->strstart + MAX_MATCH - 1;
334.1089 +    register ush scan_start = *(ushf*)scan;
334.1090 +    register ush scan_end   = *(ushf*)(scan+best_len-1);
334.1091 +#else
334.1092 +    register Bytef *strend = s->window + s->strstart + MAX_MATCH;
334.1093 +    register Byte scan_end1  = scan[best_len-1];
334.1094 +    register Byte scan_end   = scan[best_len];
334.1095 +#endif
334.1096 +
334.1097 +    /* The code is optimized for HASH_BITS >= 8 and MAX_MATCH-2 multiple of 16.
334.1098 +     * It is easy to get rid of this optimization if necessary.
334.1099 +     */
334.1100 +    Assert(s->hash_bits >= 8 && MAX_MATCH == 258, "Code too clever");
334.1101 +
334.1102 +    /* Do not waste too much time if we already have a good match: */
334.1103 +    if (s->prev_length >= s->good_match) {
334.1104 +        chain_length >>= 2;
334.1105 +    }
334.1106 +    /* Do not look for matches beyond the end of the input. This is necessary
334.1107 +     * to make deflate deterministic.
334.1108 +     */
334.1109 +    if ((uInt)nice_match > s->lookahead) nice_match = s->lookahead;
334.1110 +
334.1111 +    Assert((ulg)s->strstart <= s->window_size-MIN_LOOKAHEAD, "need lookahead");
334.1112 +
334.1113 +    do {
334.1114 +        Assert(cur_match < s->strstart, "no future");
334.1115 +        match = s->window + cur_match;
334.1116 +
334.1117 +        /* Skip to next match if the match length cannot increase
334.1118 +         * or if the match length is less than 2.  Note that the checks below
334.1119 +         * for insufficient lookahead only occur occasionally for performance
334.1120 +         * reasons.  Therefore uninitialized memory will be accessed, and
334.1121 +         * conditional jumps will be made that depend on those values.
334.1122 +         * However the length of the match is limited to the lookahead, so
334.1123 +         * the output of deflate is not affected by the uninitialized values.
334.1124 +         */
334.1125 +#if (defined(UNALIGNED_OK) && MAX_MATCH == 258)
334.1126 +        /* This code assumes sizeof(unsigned short) == 2. Do not use
334.1127 +         * UNALIGNED_OK if your compiler uses a different size.
334.1128 +         */
334.1129 +        if (*(ushf*)(match+best_len-1) != scan_end ||
334.1130 +            *(ushf*)match != scan_start) continue;
334.1131 +
334.1132 +        /* It is not necessary to compare scan[2] and match[2] since they are
334.1133 +         * always equal when the other bytes match, given that the hash keys
334.1134 +         * are equal and that HASH_BITS >= 8. Compare 2 bytes at a time at
334.1135 +         * strstart+3, +5, ... up to strstart+257. We check for insufficient
334.1136 +         * lookahead only every 4th comparison; the 128th check will be made
334.1137 +         * at strstart+257. If MAX_MATCH-2 is not a multiple of 8, it is
334.1138 +         * necessary to put more guard bytes at the end of the window, or
334.1139 +         * to check more often for insufficient lookahead.
334.1140 +         */
334.1141 +        Assert(scan[2] == match[2], "scan[2]?");
334.1142 +        scan++, match++;
334.1143 +        do {
334.1144 +        } while (*(ushf*)(scan+=2) == *(ushf*)(match+=2) &&
334.1145 +                 *(ushf*)(scan+=2) == *(ushf*)(match+=2) &&
334.1146 +                 *(ushf*)(scan+=2) == *(ushf*)(match+=2) &&
334.1147 +                 *(ushf*)(scan+=2) == *(ushf*)(match+=2) &&
334.1148 +                 scan < strend);
334.1149 +        /* The funny "do {}" generates better code on most compilers */
334.1150 +
334.1151 +        /* Here, scan <= window+strstart+257 */
334.1152 +        Assert(scan <= s->window+(unsigned)(s->window_size-1), "wild scan");
334.1153 +        if (*scan == *match) scan++;
334.1154 +
334.1155 +        len = (MAX_MATCH - 1) - (int)(strend-scan);
334.1156 +        scan = strend - (MAX_MATCH-1);
334.1157 +
334.1158 +#else /* UNALIGNED_OK */
334.1159 +
334.1160 +        if (match[best_len]   != scan_end  ||
334.1161 +            match[best_len-1] != scan_end1 ||
334.1162 +            *match            != *scan     ||
334.1163 +            *++match          != scan[1])      continue;
334.1164 +
334.1165 +        /* The check at best_len-1 can be removed because it will be made
334.1166 +         * again later. (This heuristic is not always a win.)
334.1167 +         * It is not necessary to compare scan[2] and match[2] since they
334.1168 +         * are always equal when the other bytes match, given that
334.1169 +         * the hash keys are equal and that HASH_BITS >= 8.
334.1170 +         */
334.1171 +        scan += 2, match++;
334.1172 +        Assert(*scan == *match, "match[2]?");
334.1173 +
334.1174 +        /* We check for insufficient lookahead only every 8th comparison;
334.1175 +         * the 256th check will be made at strstart+258.
334.1176 +         */
334.1177 +        do {
334.1178 +        } while (*++scan == *++match && *++scan == *++match &&
334.1179 +                 *++scan == *++match && *++scan == *++match &&
334.1180 +                 *++scan == *++match && *++scan == *++match &&
334.1181 +                 *++scan == *++match && *++scan == *++match &&
334.1182 +                 scan < strend);
334.1183 +
334.1184 +        Assert(scan <= s->window+(unsigned)(s->window_size-1), "wild scan");
334.1185 +
334.1186 +        len = MAX_MATCH - (int)(strend - scan);
334.1187 +        scan = strend - MAX_MATCH;
334.1188 +
334.1189 +#endif /* UNALIGNED_OK */
334.1190 +
334.1191 +        if (len > best_len) {
334.1192 +            s->match_start = cur_match;
334.1193 +            best_len = len;
334.1194 +            if (len >= nice_match) break;
334.1195 +#ifdef UNALIGNED_OK
334.1196 +            scan_end = *(ushf*)(scan+best_len-1);
334.1197 +#else
334.1198 +            scan_end1  = scan[best_len-1];
334.1199 +            scan_end   = scan[best_len];
334.1200 +#endif
334.1201 +        }
334.1202 +    } while ((cur_match = prev[cur_match & wmask]) > limit
334.1203 +             && --chain_length != 0);
334.1204 +
334.1205 +    if ((uInt)best_len <= s->lookahead) return (uInt)best_len;
334.1206 +    return s->lookahead;
334.1207 +}
334.1208 +#endif /* ASMV */
334.1209 +
334.1210 +#else /* FASTEST */
334.1211 +
334.1212 +/* ---------------------------------------------------------------------------
334.1213 + * Optimized version for FASTEST only
334.1214 + */
334.1215 +local uInt longest_match(s, cur_match)
334.1216 +    deflate_state *s;
334.1217 +    IPos cur_match;                             /* current match */
334.1218 +{
334.1219 +    register Bytef *scan = s->window + s->strstart; /* current string */
334.1220 +    register Bytef *match;                       /* matched string */
334.1221 +    register int len;                           /* length of current match */
334.1222 +    register Bytef *strend = s->window + s->strstart + MAX_MATCH;
334.1223 +
334.1224 +    /* The code is optimized for HASH_BITS >= 8 and MAX_MATCH-2 multiple of 16.
334.1225 +     * It is easy to get rid of this optimization if necessary.
334.1226 +     */
334.1227 +    Assert(s->hash_bits >= 8 && MAX_MATCH == 258, "Code too clever");
334.1228 +
334.1229 +    Assert((ulg)s->strstart <= s->window_size-MIN_LOOKAHEAD, "need lookahead");
334.1230 +
334.1231 +    Assert(cur_match < s->strstart, "no future");
334.1232 +
334.1233 +    match = s->window + cur_match;
334.1234 +
334.1235 +    /* Return failure if the match length is less than 2:
334.1236 +     */
334.1237 +    if (match[0] != scan[0] || match[1] != scan[1]) return MIN_MATCH-1;
334.1238 +
334.1239 +    /* The check at best_len-1 can be removed because it will be made
334.1240 +     * again later. (This heuristic is not always a win.)
334.1241 +     * It is not necessary to compare scan[2] and match[2] since they
334.1242 +     * are always equal when the other bytes match, given that
334.1243 +     * the hash keys are equal and that HASH_BITS >= 8.
334.1244 +     */
334.1245 +    scan += 2, match += 2;
334.1246 +    Assert(*scan == *match, "match[2]?");
334.1247 +
334.1248 +    /* We check for insufficient lookahead only every 8th comparison;
334.1249 +     * the 256th check will be made at strstart+258.
334.1250 +     */
334.1251 +    do {
334.1252 +    } while (*++scan == *++match && *++scan == *++match &&
334.1253 +             *++scan == *++match && *++scan == *++match &&
334.1254 +             *++scan == *++match && *++scan == *++match &&
334.1255 +             *++scan == *++match && *++scan == *++match &&
334.1256 +             scan < strend);
334.1257 +
334.1258 +    Assert(scan <= s->window+(unsigned)(s->window_size-1), "wild scan");
334.1259 +
334.1260 +    len = MAX_MATCH - (int)(strend - scan);
334.1261 +
334.1262 +    if (len < MIN_MATCH) return MIN_MATCH - 1;
334.1263 +
334.1264 +    s->match_start = cur_match;
334.1265 +    return (uInt)len <= s->lookahead ? (uInt)len : s->lookahead;
334.1266 +}
334.1267 +
334.1268 +#endif /* FASTEST */
334.1269 +
334.1270 +#ifdef DEBUG
334.1271 +/* ===========================================================================
334.1272 + * Check that the match at match_start is indeed a match.
334.1273 + */
334.1274 +local void check_match(s, start, match, length)
334.1275 +    deflate_state *s;
334.1276 +    IPos start, match;
334.1277 +    int length;
334.1278 +{
334.1279 +    /* check that the match is indeed a match */
334.1280 +    if (zmemcmp(s->window + match,
334.1281 +                s->window + start, length) != EQUAL) {
334.1282 +        fprintf(stderr, " start %u, match %u, length %d\n",
334.1283 +                start, match, length);
334.1284 +        do {
334.1285 +            fprintf(stderr, "%c%c", s->window[match++], s->window[start++]);
334.1286 +        } while (--length != 0);
334.1287 +        z_error("invalid match");
334.1288 +    }
334.1289 +    if (z_verbose > 1) {
334.1290 +        fprintf(stderr,"\\[%d,%d]", start-match, length);
334.1291 +        do { putc(s->window[start++], stderr); } while (--length != 0);
334.1292 +    }
334.1293 +}
334.1294 +#else
334.1295 +#  define check_match(s, start, match, length)
334.1296 +#endif /* DEBUG */
334.1297 +
334.1298 +/* ===========================================================================
334.1299 + * Fill the window when the lookahead becomes insufficient.
334.1300 + * Updates strstart and lookahead.
334.1301 + *
334.1302 + * IN assertion: lookahead < MIN_LOOKAHEAD
334.1303 + * OUT assertions: strstart <= window_size-MIN_LOOKAHEAD
334.1304 + *    At least one byte has been read, or avail_in == 0; reads are
334.1305 + *    performed for at least two bytes (required for the zip translate_eol
334.1306 + *    option -- not supported here).
334.1307 + */
334.1308 +local void fill_window(s)
334.1309 +    deflate_state *s;
334.1310 +{
334.1311 +    register unsigned n, m;
334.1312 +    register Posf *p;
334.1313 +    unsigned more;    /* Amount of free space at the end of the window. */
334.1314 +    uInt wsize = s->w_size;
334.1315 +
334.1316 +    do {
334.1317 +        more = (unsigned)(s->window_size -(ulg)s->lookahead -(ulg)s->strstart);
334.1318 +
334.1319 +        /* Deal with !@#$% 64K limit: */
334.1320 +        if (sizeof(int) <= 2) {
334.1321 +            if (more == 0 && s->strstart == 0 && s->lookahead == 0) {
334.1322 +                more = wsize;
334.1323 +
334.1324 +            } else if (more == (unsigned)(-1)) {
334.1325 +                /* Very unlikely, but possible on 16 bit machine if
334.1326 +                 * strstart == 0 && lookahead == 1 (input done a byte at time)
334.1327 +                 */
334.1328 +                more--;
334.1329 +            }
334.1330 +        }
334.1331 +
334.1332 +        /* If the window is almost full and there is insufficient lookahead,
334.1333 +         * move the upper half to the lower one to make room in the upper half.
334.1334 +         */
334.1335 +        if (s->strstart >= wsize+MAX_DIST(s)) {
334.1336 +
334.1337 +            zmemcpy(s->window, s->window+wsize, (unsigned)wsize);
334.1338 +            s->match_start -= wsize;
334.1339 +            s->strstart    -= wsize; /* we now have strstart >= MAX_DIST */
334.1340 +            s->block_start -= (long) wsize;
334.1341 +
334.1342 +            /* Slide the hash table (could be avoided with 32 bit values
334.1343 +               at the expense of memory usage). We slide even when level == 0
334.1344 +               to keep the hash table consistent if we switch back to level > 0
334.1345 +               later. (Using level 0 permanently is not an optimal usage of
334.1346 +               zlib, so we don't care about this pathological case.)
334.1347 +             */
334.1348 +            n = s->hash_size;
334.1349 +            p = &s->head[n];
334.1350 +            do {
334.1351 +                m = *--p;
334.1352 +                *p = (Pos)(m >= wsize ? m-wsize : NIL);
334.1353 +            } while (--n);
334.1354 +
334.1355 +            n = wsize;
334.1356 +#ifndef FASTEST
334.1357 +            p = &s->prev[n];
334.1358 +            do {
334.1359 +                m = *--p;
334.1360 +                *p = (Pos)(m >= wsize ? m-wsize : NIL);
334.1361 +                /* If n is not on any hash chain, prev[n] is garbage but
334.1362 +                 * its value will never be used.
334.1363 +                 */
334.1364 +            } while (--n);
334.1365 +#endif
334.1366 +            more += wsize;
334.1367 +        }
334.1368 +        if (s->strm->avail_in == 0) return;
334.1369 +
334.1370 +        /* If there was no sliding:
334.1371 +         *    strstart <= WSIZE+MAX_DIST-1 && lookahead <= MIN_LOOKAHEAD - 1 &&
334.1372 +         *    more == window_size - lookahead - strstart
334.1373 +         * => more >= window_size - (MIN_LOOKAHEAD-1 + WSIZE + MAX_DIST-1)
334.1374 +         * => more >= window_size - 2*WSIZE + 2
334.1375 +         * In the BIG_MEM or MMAP case (not yet supported),
334.1376 +         *   window_size == input_size + MIN_LOOKAHEAD  &&
334.1377 +         *   strstart + s->lookahead <= input_size => more >= MIN_LOOKAHEAD.
334.1378 +         * Otherwise, window_size == 2*WSIZE so more >= 2.
334.1379 +         * If there was sliding, more >= WSIZE. So in all cases, more >= 2.
334.1380 +         */
334.1381 +        Assert(more >= 2, "more < 2");
334.1382 +
334.1383 +        n = read_buf(s->strm, s->window + s->strstart + s->lookahead, more);
334.1384 +        s->lookahead += n;
334.1385 +
334.1386 +        /* Initialize the hash value now that we have some input: */
334.1387 +        if (s->lookahead >= MIN_MATCH) {
334.1388 +            s->ins_h = s->window[s->strstart];
334.1389 +            UPDATE_HASH(s, s->ins_h, s->window[s->strstart+1]);
334.1390 +#if MIN_MATCH != 3
334.1391 +            Call UPDATE_HASH() MIN_MATCH-3 more times
334.1392 +#endif
334.1393 +        }
334.1394 +        /* If the whole input has less than MIN_MATCH bytes, ins_h is garbage,
334.1395 +         * but this is not important since only literal bytes will be emitted.
334.1396 +         */
334.1397 +
334.1398 +    } while (s->lookahead < MIN_LOOKAHEAD && s->strm->avail_in != 0);
334.1399 +
334.1400 +    /* If the WIN_INIT bytes after the end of the current data have never been
334.1401 +     * written, then zero those bytes in order to avoid memory check reports of
334.1402 +     * the use of uninitialized (or uninitialised as Julian writes) bytes by
334.1403 +     * the longest match routines.  Update the high water mark for the next
334.1404 +     * time through here.  WIN_INIT is set to MAX_MATCH since the longest match
334.1405 +     * routines allow scanning to strstart + MAX_MATCH, ignoring lookahead.
334.1406 +     */
334.1407 +    if (s->high_water < s->window_size) {
334.1408 +        ulg curr = s->strstart + (ulg)(s->lookahead);
334.1409 +        ulg init;
334.1410 +
334.1411 +        if (s->high_water < curr) {
334.1412 +            /* Previous high water mark below current data -- zero WIN_INIT
334.1413 +             * bytes or up to end of window, whichever is less.
334.1414 +             */
334.1415 +            init = s->window_size - curr;
334.1416 +            if (init > WIN_INIT)
334.1417 +                init = WIN_INIT;
334.1418 +            zmemzero(s->window + curr, (unsigned)init);
334.1419 +            s->high_water = curr + init;
334.1420 +        }
334.1421 +        else if (s->high_water < (ulg)curr + WIN_INIT) {
334.1422 +            /* High water mark at or above current data, but below current data
334.1423 +             * plus WIN_INIT -- zero out to current data plus WIN_INIT, or up
334.1424 +             * to end of window, whichever is less.
334.1425 +             */
334.1426 +            init = (ulg)curr + WIN_INIT - s->high_water;
334.1427 +            if (init > s->window_size - s->high_water)
334.1428 +                init = s->window_size - s->high_water;
334.1429 +            zmemzero(s->window + s->high_water, (unsigned)init);
334.1430 +            s->high_water += init;
334.1431 +        }
334.1432 +    }
334.1433 +}
334.1434 +
334.1435 +/* ===========================================================================
334.1436 + * Flush the current block, with given end-of-file flag.
334.1437 + * IN assertion: strstart is set to the end of the current match.
334.1438 + */
334.1439 +#define FLUSH_BLOCK_ONLY(s, last) { \
334.1440 +   _tr_flush_block(s, (s->block_start >= 0L ? \
334.1441 +                   (charf *)&s->window[(unsigned)s->block_start] : \
334.1442 +                   (charf *)Z_NULL), \
334.1443 +                (ulg)((long)s->strstart - s->block_start), \
334.1444 +                (last)); \
334.1445 +   s->block_start = s->strstart; \
334.1446 +   flush_pending(s->strm); \
334.1447 +   Tracev((stderr,"[FLUSH]")); \
334.1448 +}
334.1449 +
334.1450 +/* Same but force premature exit if necessary. */
334.1451 +#define FLUSH_BLOCK(s, last) { \
334.1452 +   FLUSH_BLOCK_ONLY(s, last); \
334.1453 +   if (s->strm->avail_out == 0) return (last) ? finish_started : need_more; \
334.1454 +}
334.1455 +
334.1456 +/* ===========================================================================
334.1457 + * Copy without compression as much as possible from the input stream, return
334.1458 + * the current block state.
334.1459 + * This function does not insert new strings in the dictionary since
334.1460 + * uncompressible data is probably not useful. This function is used
334.1461 + * only for the level=0 compression option.
334.1462 + * NOTE: this function should be optimized to avoid extra copying from
334.1463 + * window to pending_buf.
334.1464 + */
334.1465 +local block_state deflate_stored(s, flush)
334.1466 +    deflate_state *s;
334.1467 +    int flush;
334.1468 +{
334.1469 +    /* Stored blocks are limited to 0xffff bytes, pending_buf is limited
334.1470 +     * to pending_buf_size, and each stored block has a 5 byte header:
334.1471 +     */
334.1472 +    ulg max_block_size = 0xffff;
334.1473 +    ulg max_start;
334.1474 +
334.1475 +    if (max_block_size > s->pending_buf_size - 5) {
334.1476 +        max_block_size = s->pending_buf_size - 5;
334.1477 +    }
334.1478 +
334.1479 +    /* Copy as much as possible from input to output: */
334.1480 +    for (;;) {
334.1481 +        /* Fill the window as much as possible: */
334.1482 +        if (s->lookahead <= 1) {
334.1483 +
334.1484 +            Assert(s->strstart < s->w_size+MAX_DIST(s) ||
334.1485 +                   s->block_start >= (long)s->w_size, "slide too late");
334.1486 +
334.1487 +            fill_window(s);
334.1488 +            if (s->lookahead == 0 && flush == Z_NO_FLUSH) return need_more;
334.1489 +
334.1490 +            if (s->lookahead == 0) break; /* flush the current block */
334.1491 +        }
334.1492 +        Assert(s->block_start >= 0L, "block gone");
334.1493 +
334.1494 +        s->strstart += s->lookahead;
334.1495 +        s->lookahead = 0;
334.1496 +
334.1497 +        /* Emit a stored block if pending_buf will be full: */
334.1498 +        max_start = s->block_start + max_block_size;
334.1499 +        if (s->strstart == 0 || (ulg)s->strstart >= max_start) {
334.1500 +            /* strstart == 0 is possible when wraparound on 16-bit machine */
334.1501 +            s->lookahead = (uInt)(s->strstart - max_start);
334.1502 +            s->strstart = (uInt)max_start;
334.1503 +            FLUSH_BLOCK(s, 0);
334.1504 +        }
334.1505 +        /* Flush if we may have to slide, otherwise block_start may become
334.1506 +         * negative and the data will be gone:
334.1507 +         */
334.1508 +        if (s->strstart - (uInt)s->block_start >= MAX_DIST(s)) {
334.1509 +            FLUSH_BLOCK(s, 0);
334.1510 +        }
334.1511 +    }
334.1512 +    FLUSH_BLOCK(s, flush == Z_FINISH);
334.1513 +    return flush == Z_FINISH ? finish_done : block_done;
334.1514 +}
334.1515 +
334.1516 +/* ===========================================================================
334.1517 + * Compress as much as possible from the input stream, return the current
334.1518 + * block state.
334.1519 + * This function does not perform lazy evaluation of matches and inserts
334.1520 + * new strings in the dictionary only for unmatched strings or for short
334.1521 + * matches. It is used only for the fast compression options.
334.1522 + */
334.1523 +local block_state deflate_fast(s, flush)
334.1524 +    deflate_state *s;
334.1525 +    int flush;
334.1526 +{
334.1527 +    IPos hash_head;       /* head of the hash chain */
334.1528 +    int bflush;           /* set if current block must be flushed */
334.1529 +
334.1530 +    for (;;) {
334.1531 +        /* Make sure that we always have enough lookahead, except
334.1532 +         * at the end of the input file. We need MAX_MATCH bytes
334.1533 +         * for the next match, plus MIN_MATCH bytes to insert the
334.1534 +         * string following the next match.
334.1535 +         */
334.1536 +        if (s->lookahead < MIN_LOOKAHEAD) {
334.1537 +            fill_window(s);
334.1538 +            if (s->lookahead < MIN_LOOKAHEAD && flush == Z_NO_FLUSH) {
334.1539 +                return need_more;
334.1540 +            }
334.1541 +            if (s->lookahead == 0) break; /* flush the current block */
334.1542 +        }
334.1543 +
334.1544 +        /* Insert the string window[strstart .. strstart+2] in the
334.1545 +         * dictionary, and set hash_head to the head of the hash chain:
334.1546 +         */
334.1547 +        hash_head = NIL;
334.1548 +        if (s->lookahead >= MIN_MATCH) {
334.1549 +            INSERT_STRING(s, s->strstart, hash_head);
334.1550 +        }
334.1551 +
334.1552 +        /* Find the longest match, discarding those <= prev_length.
334.1553 +         * At this point we have always match_length < MIN_MATCH
334.1554 +         */
334.1555 +        if (hash_head != NIL && s->strstart - hash_head <= MAX_DIST(s)) {
334.1556 +            /* To simplify the code, we prevent matches with the string
334.1557 +             * of window index 0 (in particular we have to avoid a match
334.1558 +             * of the string with itself at the start of the input file).
334.1559 +             */
334.1560 +            s->match_length = longest_match (s, hash_head);
334.1561 +            /* longest_match() sets match_start */
334.1562 +        }
334.1563 +        if (s->match_length >= MIN_MATCH) {
334.1564 +            check_match(s, s->strstart, s->match_start, s->match_length);
334.1565 +
334.1566 +            _tr_tally_dist(s, s->strstart - s->match_start,
334.1567 +                           s->match_length - MIN_MATCH, bflush);
334.1568 +
334.1569 +            s->lookahead -= s->match_length;
334.1570 +
334.1571 +            /* Insert new strings in the hash table only if the match length
334.1572 +             * is not too large. This saves time but degrades compression.
334.1573 +             */
334.1574 +#ifndef FASTEST
334.1575 +            if (s->match_length <= s->max_insert_length &&
334.1576 +                s->lookahead >= MIN_MATCH) {
334.1577 +                s->match_length--; /* string at strstart already in table */
334.1578 +                do {
334.1579 +                    s->strstart++;
334.1580 +                    INSERT_STRING(s, s->strstart, hash_head);
334.1581 +                    /* strstart never exceeds WSIZE-MAX_MATCH, so there are
334.1582 +                     * always MIN_MATCH bytes ahead.
334.1583 +                     */
334.1584 +                } while (--s->match_length != 0);
334.1585 +                s->strstart++;
334.1586 +            } else
334.1587 +#endif
334.1588 +            {
334.1589 +                s->strstart += s->match_length;
334.1590 +                s->match_length = 0;
334.1591 +                s->ins_h = s->window[s->strstart];
334.1592 +                UPDATE_HASH(s, s->ins_h, s->window[s->strstart+1]);
334.1593 +#if MIN_MATCH != 3
334.1594 +                Call UPDATE_HASH() MIN_MATCH-3 more times
334.1595 +#endif
334.1596 +                /* If lookahead < MIN_MATCH, ins_h is garbage, but it does not
334.1597 +                 * matter since it will be recomputed at next deflate call.
334.1598 +                 */
334.1599 +            }
334.1600 +        } else {
334.1601 +            /* No match, output a literal byte */
334.1602 +            Tracevv((stderr,"%c", s->window[s->strstart]));
334.1603 +            _tr_tally_lit (s, s->window[s->strstart], bflush);
334.1604 +            s->lookahead--;
334.1605 +            s->strstart++;
334.1606 +        }
334.1607 +        if (bflush) FLUSH_BLOCK(s, 0);
334.1608 +    }
334.1609 +    FLUSH_BLOCK(s, flush == Z_FINISH);
334.1610 +    return flush == Z_FINISH ? finish_done : block_done;
334.1611 +}
334.1612 +
334.1613 +#ifndef FASTEST
334.1614 +/* ===========================================================================
334.1615 + * Same as above, but achieves better compression. We use a lazy
334.1616 + * evaluation for matches: a match is finally adopted only if there is
334.1617 + * no better match at the next window position.
334.1618 + */
334.1619 +local block_state deflate_slow(s, flush)
334.1620 +    deflate_state *s;
334.1621 +    int flush;
334.1622 +{
334.1623 +    IPos hash_head;          /* head of hash chain */
334.1624 +    int bflush;              /* set if current block must be flushed */
334.1625 +
334.1626 +    /* Process the input block. */
334.1627 +    for (;;) {
334.1628 +        /* Make sure that we always have enough lookahead, except
334.1629 +         * at the end of the input file. We need MAX_MATCH bytes
334.1630 +         * for the next match, plus MIN_MATCH bytes to insert the
334.1631 +         * string following the next match.
334.1632 +         */
334.1633 +        if (s->lookahead < MIN_LOOKAHEAD) {
334.1634 +            fill_window(s);
334.1635 +            if (s->lookahead < MIN_LOOKAHEAD && flush == Z_NO_FLUSH) {
334.1636 +                return need_more;
334.1637 +            }
334.1638 +            if (s->lookahead == 0) break; /* flush the current block */
334.1639 +        }
334.1640 +
334.1641 +        /* Insert the string window[strstart .. strstart+2] in the
334.1642 +         * dictionary, and set hash_head to the head of the hash chain:
334.1643 +         */
334.1644 +        hash_head = NIL;
334.1645 +        if (s->lookahead >= MIN_MATCH) {
334.1646 +            INSERT_STRING(s, s->strstart, hash_head);
334.1647 +        }
334.1648 +
334.1649 +        /* Find the longest match, discarding those <= prev_length.
334.1650 +         */
334.1651 +        s->prev_length = s->match_length, s->prev_match = s->match_start;
334.1652 +        s->match_length = MIN_MATCH-1;
334.1653 +
334.1654 +        if (hash_head != NIL && s->prev_length < s->max_lazy_match &&
334.1655 +            s->strstart - hash_head <= MAX_DIST(s)) {
334.1656 +            /* To simplify the code, we prevent matches with the string
334.1657 +             * of window index 0 (in particular we have to avoid a match
334.1658 +             * of the string with itself at the start of the input file).
334.1659 +             */
334.1660 +            s->match_length = longest_match (s, hash_head);
334.1661 +            /* longest_match() sets match_start */
334.1662 +
334.1663 +            if (s->match_length <= 5 && (s->strategy == Z_FILTERED
334.1664 +#if TOO_FAR <= 32767
334.1665 +                || (s->match_length == MIN_MATCH &&
334.1666 +                    s->strstart - s->match_start > TOO_FAR)
334.1667 +#endif
334.1668 +                )) {
334.1669 +
334.1670 +                /* If prev_match is also MIN_MATCH, match_start is garbage
334.1671 +                 * but we will ignore the current match anyway.
334.1672 +                 */
334.1673 +                s->match_length = MIN_MATCH-1;
334.1674 +            }
334.1675 +        }
334.1676 +        /* If there was a match at the previous step and the current
334.1677 +         * match is not better, output the previous match:
334.1678 +         */
334.1679 +        if (s->prev_length >= MIN_MATCH && s->match_length <= s->prev_length) {
334.1680 +            uInt max_insert = s->strstart + s->lookahead - MIN_MATCH;
334.1681 +            /* Do not insert strings in hash table beyond this. */
334.1682 +
334.1683 +            check_match(s, s->strstart-1, s->prev_match, s->prev_length);
334.1684 +
334.1685 +            _tr_tally_dist(s, s->strstart -1 - s->prev_match,
334.1686 +                           s->prev_length - MIN_MATCH, bflush);
334.1687 +
334.1688 +            /* Insert in hash table all strings up to the end of the match.
334.1689 +             * strstart-1 and strstart are already inserted. If there is not
334.1690 +             * enough lookahead, the last two strings are not inserted in
334.1691 +             * the hash table.
334.1692 +             */
334.1693 +            s->lookahead -= s->prev_length-1;
334.1694 +            s->prev_length -= 2;
334.1695 +            do {
334.1696 +                if (++s->strstart <= max_insert) {
334.1697 +                    INSERT_STRING(s, s->strstart, hash_head);
334.1698 +                }
334.1699 +            } while (--s->prev_length != 0);
334.1700 +            s->match_available = 0;
334.1701 +            s->match_length = MIN_MATCH-1;
334.1702 +            s->strstart++;
334.1703 +
334.1704 +            if (bflush) FLUSH_BLOCK(s, 0);
334.1705 +
334.1706 +        } else if (s->match_available) {
334.1707 +            /* If there was no match at the previous position, output a
334.1708 +             * single literal. If there was a match but the current match
334.1709 +             * is longer, truncate the previous match to a single literal.
334.1710 +             */
334.1711 +            Tracevv((stderr,"%c", s->window[s->strstart-1]));
334.1712 +            _tr_tally_lit(s, s->window[s->strstart-1], bflush);
334.1713 +            if (bflush) {
334.1714 +                FLUSH_BLOCK_ONLY(s, 0);
334.1715 +            }
334.1716 +            s->strstart++;
334.1717 +            s->lookahead--;
334.1718 +            if (s->strm->avail_out == 0) return need_more;
334.1719 +        } else {
334.1720 +            /* There is no previous match to compare with, wait for
334.1721 +             * the next step to decide.
334.1722 +             */
334.1723 +            s->match_available = 1;
334.1724 +            s->strstart++;
334.1725 +            s->lookahead--;
334.1726 +        }
334.1727 +    }
334.1728 +    Assert (flush != Z_NO_FLUSH, "no flush?");
334.1729 +    if (s->match_available) {
334.1730 +        Tracevv((stderr,"%c", s->window[s->strstart-1]));
334.1731 +        _tr_tally_lit(s, s->window[s->strstart-1], bflush);
334.1732 +        s->match_available = 0;
334.1733 +    }
334.1734 +    FLUSH_BLOCK(s, flush == Z_FINISH);
334.1735 +    return flush == Z_FINISH ? finish_done : block_done;
334.1736 +}
334.1737 +#endif /* FASTEST */
334.1738 +
334.1739 +/* ===========================================================================
334.1740 + * For Z_RLE, simply look for runs of bytes, generate matches only of distance
334.1741 + * one.  Do not maintain a hash table.  (It will be regenerated if this run of
334.1742 + * deflate switches away from Z_RLE.)
334.1743 + */
334.1744 +local block_state deflate_rle(s, flush)
334.1745 +    deflate_state *s;
334.1746 +    int flush;
334.1747 +{
334.1748 +    int bflush;             /* set if current block must be flushed */
334.1749 +    uInt prev;              /* byte at distance one to match */
334.1750 +    Bytef *scan, *strend;   /* scan goes up to strend for length of run */
334.1751 +
334.1752 +    for (;;) {
334.1753 +        /* Make sure that we always have enough lookahead, except
334.1754 +         * at the end of the input file. We need MAX_MATCH bytes
334.1755 +         * for the longest encodable run.
334.1756 +         */
334.1757 +        if (s->lookahead < MAX_MATCH) {
334.1758 +            fill_window(s);
334.1759 +            if (s->lookahead < MAX_MATCH && flush == Z_NO_FLUSH) {
334.1760 +                return need_more;
334.1761 +            }
334.1762 +            if (s->lookahead == 0) break; /* flush the current block */
334.1763 +        }
334.1764 +
334.1765 +        /* See how many times the previous byte repeats */
334.1766 +        s->match_length = 0;
334.1767 +        if (s->lookahead >= MIN_MATCH && s->strstart > 0) {
334.1768 +            scan = s->window + s->strstart - 1;
334.1769 +            prev = *scan;
334.1770 +            if (prev == *++scan && prev == *++scan && prev == *++scan) {
334.1771 +                strend = s->window + s->strstart + MAX_MATCH;
334.1772 +                do {
334.1773 +                } while (prev == *++scan && prev == *++scan &&
334.1774 +                         prev == *++scan && prev == *++scan &&
334.1775 +                         prev == *++scan && prev == *++scan &&
334.1776 +                         prev == *++scan && prev == *++scan &&
334.1777 +                         scan < strend);
334.1778 +                s->match_length = MAX_MATCH - (int)(strend - scan);
334.1779 +                if (s->match_length > s->lookahead)
334.1780 +                    s->match_length = s->lookahead;
334.1781 +            }
334.1782 +        }
334.1783 +
334.1784 +        /* Emit match if have run of MIN_MATCH or longer, else emit literal */
334.1785 +        if (s->match_length >= MIN_MATCH) {
334.1786 +            check_match(s, s->strstart, s->strstart - 1, s->match_length);
334.1787 +
334.1788 +            _tr_tally_dist(s, 1, s->match_length - MIN_MATCH, bflush);
334.1789 +
334.1790 +            s->lookahead -= s->match_length;
334.1791 +            s->strstart += s->match_length;
334.1792 +            s->match_length = 0;
334.1793 +        } else {
334.1794 +            /* No match, output a literal byte */
334.1795 +            Tracevv((stderr,"%c", s->window[s->strstart]));
334.1796 +            _tr_tally_lit (s, s->window[s->strstart], bflush);
334.1797 +            s->lookahead--;
334.1798 +            s->strstart++;
334.1799 +        }
334.1800 +        if (bflush) FLUSH_BLOCK(s, 0);
334.1801 +    }
334.1802 +    FLUSH_BLOCK(s, flush == Z_FINISH);
334.1803 +    return flush == Z_FINISH ? finish_done : block_done;
334.1804 +}
334.1805 +
334.1806 +/* ===========================================================================
334.1807 + * For Z_HUFFMAN_ONLY, do not look for matches.  Do not maintain a hash table.
334.1808 + * (It will be regenerated if this run of deflate switches away from Huffman.)
334.1809 + */
334.1810 +local block_state deflate_huff(s, flush)
334.1811 +    deflate_state *s;
334.1812 +    int flush;
334.1813 +{
334.1814 +    int bflush;             /* set if current block must be flushed */
334.1815 +
334.1816 +    for (;;) {
334.1817 +        /* Make sure that we have a literal to write. */
334.1818 +        if (s->lookahead == 0) {
334.1819 +            fill_window(s);
334.1820 +            if (s->lookahead == 0) {
334.1821 +                if (flush == Z_NO_FLUSH)
334.1822 +                    return need_more;
334.1823 +                break;      /* flush the current block */
334.1824 +            }
334.1825 +        }
334.1826 +
334.1827 +        /* Output a literal byte */
334.1828 +        s->match_length = 0;
334.1829 +        Tracevv((stderr,"%c", s->window[s->strstart]));
334.1830 +        _tr_tally_lit (s, s->window[s->strstart], bflush);
334.1831 +        s->lookahead--;
334.1832 +        s->strstart++;
334.1833 +        if (bflush) FLUSH_BLOCK(s, 0);
334.1834 +    }
334.1835 +    FLUSH_BLOCK(s, flush == Z_FINISH);
334.1836 +    return flush == Z_FINISH ? finish_done : block_done;
334.1837 +}
   335.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
   335.2 +++ b/deps/glpk/src/zlib/deflate.h	Sun Nov 06 20:59:10 2011 +0100
   335.3 @@ -0,0 +1,342 @@
   335.4 +/* deflate.h -- internal compression state
   335.5 + * Copyright (C) 1995-2010 Jean-loup Gailly
   335.6 + * For conditions of distribution and use, see copyright notice in zlib.h
   335.7 + */
   335.8 +
   335.9 +/* WARNING: this file should *not* be used by applications. It is
  335.10 +   part of the implementation of the compression library and is
  335.11 +   subject to change. Applications should only use zlib.h.
  335.12 + */
  335.13 +
  335.14 +/* @(#) $Id$ */
  335.15 +
  335.16 +#ifndef DEFLATE_H
  335.17 +#define DEFLATE_H
  335.18 +
  335.19 +#include "zutil.h"
  335.20 +
  335.21 +/* define NO_GZIP when compiling if you want to disable gzip header and
  335.22 +   trailer creation by deflate().  NO_GZIP would be used to avoid linking in
  335.23 +   the crc code when it is not needed.  For shared libraries, gzip encoding
  335.24 +   should be left enabled. */
  335.25 +#ifndef NO_GZIP
  335.26 +#  define GZIP
  335.27 +#endif
  335.28 +
  335.29 +/* ===========================================================================
  335.30 + * Internal compression state.
  335.31 + */
  335.32 +
  335.33 +#define LENGTH_CODES 29
  335.34 +/* number of length codes, not counting the special END_BLOCK code */
  335.35 +
  335.36 +#define LITERALS  256
  335.37 +/* number of literal bytes 0..255 */
  335.38 +
  335.39 +#define L_CODES (LITERALS+1+LENGTH_CODES)
  335.40 +/* number of Literal or Length codes, including the END_BLOCK code */
  335.41 +
  335.42 +#define D_CODES   30
  335.43 +/* number of distance codes */
  335.44 +
  335.45 +#define BL_CODES  19
  335.46 +/* number of codes used to transfer the bit lengths */
  335.47 +
  335.48 +#define HEAP_SIZE (2*L_CODES+1)
  335.49 +/* maximum heap size */
  335.50 +
  335.51 +#define MAX_BITS 15
  335.52 +/* All codes must not exceed MAX_BITS bits */
  335.53 +
  335.54 +#define INIT_STATE    42
  335.55 +#define EXTRA_STATE   69
  335.56 +#define NAME_STATE    73
  335.57 +#define COMMENT_STATE 91
  335.58 +#define HCRC_STATE   103
  335.59 +#define BUSY_STATE   113
  335.60 +#define FINISH_STATE 666
  335.61 +/* Stream status */
  335.62 +
  335.63 +
  335.64 +/* Data structure describing a single value and its code string. */
  335.65 +typedef struct ct_data_s {
  335.66 +    union {
  335.67 +        ush  freq;       /* frequency count */
  335.68 +        ush  code;       /* bit string */
  335.69 +    } fc;
  335.70 +    union {
  335.71 +        ush  dad;        /* father node in Huffman tree */
  335.72 +        ush  len;        /* length of bit string */
  335.73 +    } dl;
  335.74 +} FAR ct_data;
  335.75 +
  335.76 +#define Freq fc.freq
  335.77 +#define Code fc.code
  335.78 +#define Dad  dl.dad
  335.79 +#define Len  dl.len
  335.80 +
  335.81 +typedef struct static_tree_desc_s  static_tree_desc;
  335.82 +
  335.83 +typedef struct tree_desc_s {
  335.84 +    ct_data *dyn_tree;           /* the dynamic tree */
  335.85 +    int     max_code;            /* largest code with non zero frequency */
  335.86 +    static_tree_desc *stat_desc; /* the corresponding static tree */
  335.87 +} FAR tree_desc;
  335.88 +
  335.89 +typedef ush Pos;
  335.90 +typedef Pos FAR Posf;
  335.91 +typedef unsigned IPos;
  335.92 +
  335.93 +/* A Pos is an index in the character window. We use short instead of int to
  335.94 + * save space in the various tables. IPos is used only for parameter passing.
  335.95 + */
  335.96 +
  335.97 +typedef struct internal_state {
  335.98 +    z_streamp strm;      /* pointer back to this zlib stream */
  335.99 +    int   status;        /* as the name implies */
 335.100 +    Bytef *pending_buf;  /* output still pending */
 335.101 +    ulg   pending_buf_size; /* size of pending_buf */
 335.102 +    Bytef *pending_out;  /* next pending byte to output to the stream */
 335.103 +    uInt   pending;      /* nb of bytes in the pending buffer */
 335.104 +    int   wrap;          /* bit 0 true for zlib, bit 1 true for gzip */
 335.105 +    gz_headerp  gzhead;  /* gzip header information to write */
 335.106 +    uInt   gzindex;      /* where in extra, name, or comment */
 335.107 +    Byte  method;        /* STORED (for zip only) or DEFLATED */
 335.108 +    int   last_flush;    /* value of flush param for previous deflate call */
 335.109 +
 335.110 +                /* used by deflate.c: */
 335.111 +
 335.112 +    uInt  w_size;        /* LZ77 window size (32K by default) */
 335.113 +    uInt  w_bits;        /* log2(w_size)  (8..16) */
 335.114 +    uInt  w_mask;        /* w_size - 1 */
 335.115 +
 335.116 +    Bytef *window;
 335.117 +    /* Sliding window. Input bytes are read into the second half of the window,
 335.118 +     * and move to the first half later to keep a dictionary of at least wSize
 335.119 +     * bytes. With this organization, matches are limited to a distance of
 335.120 +     * wSize-MAX_MATCH bytes, but this ensures that IO is always
 335.121 +     * performed with a length multiple of the block size. Also, it limits
 335.122 +     * the window size to 64K, which is quite useful on MSDOS.
 335.123 +     * To do: use the user input buffer as sliding window.
 335.124 +     */
 335.125 +
 335.126 +    ulg window_size;
 335.127 +    /* Actual size of window: 2*wSize, except when the user input buffer
 335.128 +     * is directly used as sliding window.
 335.129 +     */
 335.130 +
 335.131 +    Posf *prev;
 335.132 +    /* Link to older string with same hash index. To limit the size of this
 335.133 +     * array to 64K, this link is maintained only for the last 32K strings.
 335.134 +     * An index in this array is thus a window index modulo 32K.
 335.135 +     */
 335.136 +
 335.137 +    Posf *head; /* Heads of the hash chains or NIL. */
 335.138 +
 335.139 +    uInt  ins_h;          /* hash index of string to be inserted */
 335.140 +    uInt  hash_size;      /* number of elements in hash table */
 335.141 +    uInt  hash_bits;      /* log2(hash_size) */
 335.142 +    uInt  hash_mask;      /* hash_size-1 */
 335.143 +
 335.144 +    uInt  hash_shift;
 335.145 +    /* Number of bits by which ins_h must be shifted at each input
 335.146 +     * step. It must be such that after MIN_MATCH steps, the oldest
 335.147 +     * byte no longer takes part in the hash key, that is:
 335.148 +     *   hash_shift * MIN_MATCH >= hash_bits
 335.149 +     */
 335.150 +
 335.151 +    long block_start;
 335.152 +    /* Window position at the beginning of the current output block. Gets
 335.153 +     * negative when the window is moved backwards.
 335.154 +     */
 335.155 +
 335.156 +    uInt match_length;           /* length of best match */
 335.157 +    IPos prev_match;             /* previous match */
 335.158 +    int match_available;         /* set if previous match exists */
 335.159 +    uInt strstart;               /* start of string to insert */
 335.160 +    uInt match_start;            /* start of matching string */
 335.161 +    uInt lookahead;              /* number of valid bytes ahead in window */
 335.162 +
 335.163 +    uInt prev_length;
 335.164 +    /* Length of the best match at previous step. Matches not greater than this
 335.165 +     * are discarded. This is used in the lazy match evaluation.
 335.166 +     */
 335.167 +
 335.168 +    uInt max_chain_length;
 335.169 +    /* To speed up deflation, hash chains are never searched beyond this
 335.170 +     * length.  A higher limit improves compression ratio but degrades the
 335.171 +     * speed.
 335.172 +     */
 335.173 +
 335.174 +    uInt max_lazy_match;
 335.175 +    /* Attempt to find a better match only when the current match is strictly
 335.176 +     * smaller than this value. This mechanism is used only for compression
 335.177 +     * levels >= 4.
 335.178 +     */
 335.179 +#   define max_insert_length  max_lazy_match
 335.180 +    /* Insert new strings in the hash table only if the match length is not
 335.181 +     * greater than this length. This saves time but degrades compression.
 335.182 +     * max_insert_length is used only for compression levels <= 3.
 335.183 +     */
 335.184 +
 335.185 +    int level;    /* compression level (1..9) */
 335.186 +    int strategy; /* favor or force Huffman coding*/
 335.187 +
 335.188 +    uInt good_match;
 335.189 +    /* Use a faster search when the previous match is longer than this */
 335.190 +
 335.191 +    int nice_match; /* Stop searching when current match exceeds this */
 335.192 +
 335.193 +                /* used by trees.c: */
 335.194 +    /* Didn't use ct_data typedef below to supress compiler warning */
 335.195 +    struct ct_data_s dyn_ltree[HEAP_SIZE];   /* literal and length tree */
 335.196 +    struct ct_data_s dyn_dtree[2*D_CODES+1]; /* distance tree */
 335.197 +    struct ct_data_s bl_tree[2*BL_CODES+1];  /* Huffman tree for bit lengths */
 335.198 +
 335.199 +    struct tree_desc_s l_desc;               /* desc. for literal tree */
 335.200 +    struct tree_desc_s d_desc;               /* desc. for distance tree */
 335.201 +    struct tree_desc_s bl_desc;              /* desc. for bit length tree */
 335.202 +
 335.203 +    ush bl_count[MAX_BITS+1];
 335.204 +    /* number of codes at each bit length for an optimal tree */
 335.205 +
 335.206 +    int heap[2*L_CODES+1];      /* heap used to build the Huffman trees */
 335.207 +    int heap_len;               /* number of elements in the heap */
 335.208 +    int heap_max;               /* element of largest frequency */
 335.209 +    /* The sons of heap[n] are heap[2*n] and heap[2*n+1]. heap[0] is not used.
 335.210 +     * The same heap array is used to build all trees.
 335.211 +     */
 335.212 +
 335.213 +    uch depth[2*L_CODES+1];
 335.214 +    /* Depth of each subtree used as tie breaker for trees of equal frequency
 335.215 +     */
 335.216 +
 335.217 +    uchf *l_buf;          /* buffer for literals or lengths */
 335.218 +
 335.219 +    uInt  lit_bufsize;
 335.220 +    /* Size of match buffer for literals/lengths.  There are 4 reasons for
 335.221 +     * limiting lit_bufsize to 64K:
 335.222 +     *   - frequencies can be kept in 16 bit counters
 335.223 +     *   - if compression is not successful for the first block, all input
 335.224 +     *     data is still in the window so we can still emit a stored block even
 335.225 +     *     when input comes from standard input.  (This can also be done for
 335.226 +     *     all blocks if lit_bufsize is not greater than 32K.)
 335.227 +     *   - if compression is not successful for a file smaller than 64K, we can
 335.228 +     *     even emit a stored file instead of a stored block (saving 5 bytes).
 335.229 +     *     This is applicable only for zip (not gzip or zlib).
 335.230 +     *   - creating new Huffman trees less frequently may not provide fast
 335.231 +     *     adaptation to changes in the input data statistics. (Take for
 335.232 +     *     example a binary file with poorly compressible code followed by
 335.233 +     *     a highly compressible string table.) Smaller buffer sizes give
 335.234 +     *     fast adaptation but have of course the overhead of transmitting
 335.235 +     *     trees more frequently.
 335.236 +     *   - I can't count above 4
 335.237 +     */
 335.238 +
 335.239 +    uInt last_lit;      /* running index in l_buf */
 335.240 +
 335.241 +    ushf *d_buf;
 335.242 +    /* Buffer for distances. To simplify the code, d_buf and l_buf have
 335.243 +     * the same number of elements. To use different lengths, an extra flag
 335.244 +     * array would be necessary.
 335.245 +     */
 335.246 +
 335.247 +    ulg opt_len;        /* bit length of current block with optimal trees */
 335.248 +    ulg static_len;     /* bit length of current block with static trees */
 335.249 +    uInt matches;       /* number of string matches in current block */
 335.250 +    int last_eob_len;   /* bit length of EOB code for last block */
 335.251 +
 335.252 +#ifdef DEBUG
 335.253 +    ulg compressed_len; /* total bit length of compressed file mod 2^32 */
 335.254 +    ulg bits_sent;      /* bit length of compressed data sent mod 2^32 */
 335.255 +#endif
 335.256 +
 335.257 +    ush bi_buf;
 335.258 +    /* Output buffer. bits are inserted starting at the bottom (least
 335.259 +     * significant bits).
 335.260 +     */
 335.261 +    int bi_valid;
 335.262 +    /* Number of valid bits in bi_buf.  All bits above the last valid bit
 335.263 +     * are always zero.
 335.264 +     */
 335.265 +
 335.266 +    ulg high_water;
 335.267 +    /* High water mark offset in window for initialized bytes -- bytes above
 335.268 +     * this are set to zero in order to avoid memory check warnings when
 335.269 +     * longest match routines access bytes past the input.  This is then
 335.270 +     * updated to the new high water mark.
 335.271 +     */
 335.272 +
 335.273 +} FAR deflate_state;
 335.274 +
 335.275 +/* Output a byte on the stream.
 335.276 + * IN assertion: there is enough room in pending_buf.
 335.277 + */
 335.278 +#define put_byte(s, c) {s->pending_buf[s->pending++] = (c);}
 335.279 +
 335.280 +
 335.281 +#define MIN_LOOKAHEAD (MAX_MATCH+MIN_MATCH+1)
 335.282 +/* Minimum amount of lookahead, except at the end of the input file.
 335.283 + * See deflate.c for comments about the MIN_MATCH+1.
 335.284 + */
 335.285 +
 335.286 +#define MAX_DIST(s)  ((s)->w_size-MIN_LOOKAHEAD)
 335.287 +/* In order to simplify the code, particularly on 16 bit machines, match
 335.288 + * distances are limited to MAX_DIST instead of WSIZE.
 335.289 + */
 335.290 +
 335.291 +#define WIN_INIT MAX_MATCH
 335.292 +/* Number of bytes after end of data in window to initialize in order to avoid
 335.293 +   memory checker errors from longest match routines */
 335.294 +
 335.295 +        /* in trees.c */
 335.296 +void ZLIB_INTERNAL _tr_init OF((deflate_state *s));
 335.297 +int ZLIB_INTERNAL _tr_tally OF((deflate_state *s, unsigned dist, unsigned lc));
 335.298 +void ZLIB_INTERNAL _tr_flush_block OF((deflate_state *s, charf *buf,
 335.299 +                        ulg stored_len, int last));
 335.300 +void ZLIB_INTERNAL _tr_align OF((deflate_state *s));
 335.301 +void ZLIB_INTERNAL _tr_stored_block OF((deflate_state *s, charf *buf,
 335.302 +                        ulg stored_len, int last));
 335.303 +
 335.304 +#define d_code(dist) \
 335.305 +   ((dist) < 256 ? _dist_code[dist] : _dist_code[256+((dist)>>7)])
 335.306 +/* Mapping from a distance to a distance code. dist is the distance - 1 and
 335.307 + * must not have side effects. _dist_code[256] and _dist_code[257] are never
 335.308 + * used.
 335.309 + */
 335.310 +
 335.311 +#ifndef DEBUG
 335.312 +/* Inline versions of _tr_tally for speed: */
 335.313 +
 335.314 +#if defined(GEN_TREES_H) || !defined(STDC)
 335.315 +  extern uch ZLIB_INTERNAL _length_code[];
 335.316 +  extern uch ZLIB_INTERNAL _dist_code[];
 335.317 +#else
 335.318 +  extern const uch ZLIB_INTERNAL _length_code[];
 335.319 +  extern const uch ZLIB_INTERNAL _dist_code[];
 335.320 +#endif
 335.321 +
 335.322 +# define _tr_tally_lit(s, c, flush) \
 335.323 +  { uch cc = (c); \
 335.324 +    s->d_buf[s->last_lit] = 0; \
 335.325 +    s->l_buf[s->last_lit++] = cc; \
 335.326 +    s->dyn_ltree[cc].Freq++; \
 335.327 +    flush = (s->last_lit == s->lit_bufsize-1); \
 335.328 +   }
 335.329 +# define _tr_tally_dist(s, distance, length, flush) \
 335.330 +  { uch len = (length); \
 335.331 +    ush dist = (distance); \
 335.332 +    s->d_buf[s->last_lit] = dist; \
 335.333 +    s->l_buf[s->last_lit++] = len; \
 335.334 +    dist--; \
 335.335 +    s->dyn_ltree[_length_code[len]+LITERALS+1].Freq++; \
 335.336 +    s->dyn_dtree[d_code(dist)].Freq++; \
 335.337 +    flush = (s->last_lit == s->lit_bufsize-1); \
 335.338 +  }
 335.339 +#else
 335.340 +# define _tr_tally_lit(s, c, flush) flush = _tr_tally(s, 0, c)
 335.341 +# define _tr_tally_dist(s, distance, length, flush) \
 335.342 +              flush = _tr_tally(s, distance, length)
 335.343 +#endif
 335.344 +
 335.345 +#endif /* DEFLATE_H */
   336.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
   336.2 +++ b/deps/glpk/src/zlib/gzclose.c	Sun Nov 06 20:59:10 2011 +0100
   336.3 @@ -0,0 +1,25 @@
   336.4 +/* gzclose.c -- zlib gzclose() function
   336.5 + * Copyright (C) 2004, 2010 Mark Adler
   336.6 + * For conditions of distribution and use, see copyright notice in zlib.h
   336.7 + */
   336.8 +
   336.9 +#include "gzguts.h"
  336.10 +
  336.11 +/* gzclose() is in a separate file so that it is linked in only if it is used.
  336.12 +   That way the other gzclose functions can be used instead to avoid linking in
  336.13 +   unneeded compression or decompression routines. */
  336.14 +int ZEXPORT gzclose(file)
  336.15 +    gzFile file;
  336.16 +{
  336.17 +#ifndef NO_GZCOMPRESS
  336.18 +    gz_statep state;
  336.19 +
  336.20 +    if (file == NULL)
  336.21 +        return Z_STREAM_ERROR;
  336.22 +    state = (gz_statep)file;
  336.23 +
  336.24 +    return state->mode == GZ_READ ? gzclose_r(file) : gzclose_w(file);
  336.25 +#else
  336.26 +    return gzclose_r(file);
  336.27 +#endif
  336.28 +}
   337.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
   337.2 +++ b/deps/glpk/src/zlib/gzguts.h	Sun Nov 06 20:59:10 2011 +0100
   337.3 @@ -0,0 +1,74 @@
   337.4 +/* gzguts.h (zlib internal header definitions for gz* operations) */
   337.5 +
   337.6 +/* Modified by Andrew Makhorin <mao@gnu.org>, April 2011 */
   337.7 +
   337.8 +/* Copyright (C) 2004, 2005, 2010 Mark Adler
   337.9 + * For conditions of distribution and use, see copyright notice in
  337.10 + * zlib.h */
  337.11 +
  337.12 +/* WARNING: this file should *not* be used by applications. It is
  337.13 +   part of the implementation of the compression library and is
  337.14 +   subject to change. Applications should only use zlib.h. */
  337.15 +
  337.16 +#ifndef GZGUTS_H
  337.17 +#define GZGUTS_H
  337.18 +
  337.19 +#define ZLIB_INTERNAL
  337.20 +
  337.21 +#include <errno.h>
  337.22 +#include <limits.h>
  337.23 +#include <stdio.h>
  337.24 +#include <stdlib.h>
  337.25 +#include <string.h>
  337.26 +#include "zio.h"
  337.27 +#include "zlib.h"
  337.28 +
  337.29 +#define local static
  337.30 +
  337.31 +#define zstrerror() strerror(errno)
  337.32 +
  337.33 +#define GZBUFSIZE 8192
  337.34 +
  337.35 +#define GZ_NONE 0
  337.36 +#define GZ_READ 7247
  337.37 +#define GZ_WRITE 31153
  337.38 +#define GZ_APPEND 1
  337.39 +
  337.40 +#define LOOK 0
  337.41 +#define COPY 1
  337.42 +#define GZIP 2
  337.43 +
  337.44 +typedef struct
  337.45 +{     int mode;
  337.46 +      int fd;
  337.47 +      char *path;
  337.48 +      z_off64_t pos;
  337.49 +      unsigned size;
  337.50 +      unsigned want;
  337.51 +      unsigned char *in;
  337.52 +      unsigned char *out;
  337.53 +      unsigned char *next;
  337.54 +      unsigned have;
  337.55 +      int eof;
  337.56 +      z_off64_t start;
  337.57 +      z_off64_t raw;
  337.58 +      int how;
  337.59 +      int direct;
  337.60 +      int level;
  337.61 +      int strategy;
  337.62 +      z_off64_t skip;
  337.63 +      int seek;
  337.64 +      int err;
  337.65 +      char *msg;
  337.66 +      z_stream strm;
  337.67 +} gz_state;
  337.68 +
  337.69 +typedef gz_state *gz_statep;
  337.70 +
  337.71 +void ZLIB_INTERNAL gz_error OF((gz_statep, int, const char *));
  337.72 +
  337.73 +#define GT_OFF(x) (sizeof(int) == sizeof(z_off64_t) && (x) > INT_MAX)
  337.74 +
  337.75 +#endif
  337.76 +
  337.77 +/* eof */
   338.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
   338.2 +++ b/deps/glpk/src/zlib/gzlib.c	Sun Nov 06 20:59:10 2011 +0100
   338.3 @@ -0,0 +1,537 @@
   338.4 +/* gzlib.c -- zlib functions common to reading and writing gzip files
   338.5 + * Copyright (C) 2004, 2010 Mark Adler
   338.6 + * For conditions of distribution and use, see copyright notice in zlib.h
   338.7 + */
   338.8 +
   338.9 +#include "gzguts.h"
  338.10 +
  338.11 +#if defined(_LARGEFILE64_SOURCE) && _LFS64_LARGEFILE-0
  338.12 +#  define LSEEK lseek64
  338.13 +#else
  338.14 +#  define LSEEK lseek
  338.15 +#endif
  338.16 +
  338.17 +/* Local functions */
  338.18 +local void gz_reset OF((gz_statep));
  338.19 +local gzFile gz_open OF((const char *, int, const char *));
  338.20 +
  338.21 +#if defined UNDER_CE
  338.22 +
  338.23 +/* Map the Windows error number in ERROR to a locale-dependent error message
  338.24 +   string and return a pointer to it.  Typically, the values for ERROR come
  338.25 +   from GetLastError.
  338.26 +
  338.27 +   The string pointed to shall not be modified by the application, but may be
  338.28 +   overwritten by a subsequent call to gz_strwinerror
  338.29 +
  338.30 +   The gz_strwinerror function does not change the current setting of
  338.31 +   GetLastError. */
  338.32 +char ZLIB_INTERNAL *gz_strwinerror (error)
  338.33 +     DWORD error;
  338.34 +{
  338.35 +    static char buf[1024];
  338.36 +
  338.37 +    wchar_t *msgbuf;
  338.38 +    DWORD lasterr = GetLastError();
  338.39 +    DWORD chars = FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM
  338.40 +        | FORMAT_MESSAGE_ALLOCATE_BUFFER,
  338.41 +        NULL,
  338.42 +        error,
  338.43 +        0, /* Default language */
  338.44 +        (LPVOID)&msgbuf,
  338.45 +        0,
  338.46 +        NULL);
  338.47 +    if (chars != 0) {
  338.48 +        /* If there is an \r\n appended, zap it.  */
  338.49 +        if (chars >= 2
  338.50 +            && msgbuf[chars - 2] == '\r' && msgbuf[chars - 1] == '\n') {
  338.51 +            chars -= 2;
  338.52 +            msgbuf[chars] = 0;
  338.53 +        }
  338.54 +
  338.55 +        if (chars > sizeof (buf) - 1) {
  338.56 +            chars = sizeof (buf) - 1;
  338.57 +            msgbuf[chars] = 0;
  338.58 +        }
  338.59 +
  338.60 +        wcstombs(buf, msgbuf, chars + 1);
  338.61 +        LocalFree(msgbuf);
  338.62 +    }
  338.63 +    else {
  338.64 +        sprintf(buf, "unknown win32 error (%ld)", error);
  338.65 +    }
  338.66 +
  338.67 +    SetLastError(lasterr);
  338.68 +    return buf;
  338.69 +}
  338.70 +
  338.71 +#endif /* UNDER_CE */
  338.72 +
  338.73 +/* Reset gzip file state */
  338.74 +local void gz_reset(state)
  338.75 +    gz_statep state;
  338.76 +{
  338.77 +    if (state->mode == GZ_READ) {   /* for reading ... */
  338.78 +        state->have = 0;            /* no output data available */
  338.79 +        state->eof = 0;             /* not at end of file */
  338.80 +        state->how = LOOK;          /* look for gzip header */
  338.81 +        state->direct = 1;          /* default for empty file */
  338.82 +    }
  338.83 +    state->seek = 0;                /* no seek request pending */
  338.84 +    gz_error(state, Z_OK, NULL);    /* clear error */
  338.85 +    state->pos = 0;                 /* no uncompressed data yet */
  338.86 +    state->strm.avail_in = 0;       /* no input data yet */
  338.87 +}
  338.88 +
  338.89 +/* Open a gzip file either by name or file descriptor. */
  338.90 +local gzFile gz_open(path, fd, mode)
  338.91 +    const char *path;
  338.92 +    int fd;
  338.93 +    const char *mode;
  338.94 +{
  338.95 +    gz_statep state;
  338.96 +
  338.97 +    /* allocate gzFile structure to return */
  338.98 +    state = malloc(sizeof(gz_state));
  338.99 +    if (state == NULL)
 338.100 +        return NULL;
 338.101 +    state->size = 0;            /* no buffers allocated yet */
 338.102 +    state->want = GZBUFSIZE;    /* requested buffer size */
 338.103 +    state->msg = NULL;          /* no error message yet */
 338.104 +
 338.105 +    /* interpret mode */
 338.106 +    state->mode = GZ_NONE;
 338.107 +    state->level = Z_DEFAULT_COMPRESSION;
 338.108 +    state->strategy = Z_DEFAULT_STRATEGY;
 338.109 +    while (*mode) {
 338.110 +        if (*mode >= '0' && *mode <= '9')
 338.111 +            state->level = *mode - '0';
 338.112 +        else
 338.113 +            switch (*mode) {
 338.114 +            case 'r':
 338.115 +                state->mode = GZ_READ;
 338.116 +                break;
 338.117 +#ifndef NO_GZCOMPRESS
 338.118 +            case 'w':
 338.119 +                state->mode = GZ_WRITE;
 338.120 +                break;
 338.121 +            case 'a':
 338.122 +                state->mode = GZ_APPEND;
 338.123 +                break;
 338.124 +#endif
 338.125 +            case '+':       /* can't read and write at the same time */
 338.126 +                free(state);
 338.127 +                return NULL;
 338.128 +            case 'b':       /* ignore -- will request binary anyway */
 338.129 +                break;
 338.130 +            case 'f':
 338.131 +                state->strategy = Z_FILTERED;
 338.132 +                break;
 338.133 +            case 'h':
 338.134 +                state->strategy = Z_HUFFMAN_ONLY;
 338.135 +                break;
 338.136 +            case 'R':
 338.137 +                state->strategy = Z_RLE;
 338.138 +                break;
 338.139 +            case 'F':
 338.140 +                state->strategy = Z_FIXED;
 338.141 +            default:        /* could consider as an error, but just ignore */
 338.142 +                ;
 338.143 +            }
 338.144 +        mode++;
 338.145 +    }
 338.146 +
 338.147 +    /* must provide an "r", "w", or "a" */
 338.148 +    if (state->mode == GZ_NONE) {
 338.149 +        free(state);
 338.150 +        return NULL;
 338.151 +    }
 338.152 +
 338.153 +    /* save the path name for error messages */
 338.154 +    state->path = malloc(strlen(path) + 1);
 338.155 +    if (state->path == NULL) {
 338.156 +        free(state);
 338.157 +        return NULL;
 338.158 +    }
 338.159 +    strcpy(state->path, path);
 338.160 +
 338.161 +    /* open the file with the appropriate mode (or just use fd) */
 338.162 +    state->fd = fd != -1 ? fd :
 338.163 +        open(path,
 338.164 +#ifdef O_LARGEFILE
 338.165 +            O_LARGEFILE |
 338.166 +#endif
 338.167 +#ifdef O_BINARY
 338.168 +            O_BINARY |
 338.169 +#endif
 338.170 +            (state->mode == GZ_READ ?
 338.171 +                O_RDONLY :
 338.172 +                (O_WRONLY | O_CREAT | (
 338.173 +                    state->mode == GZ_WRITE ?
 338.174 +                        O_TRUNC :
 338.175 +                        O_APPEND))),
 338.176 +            0666);
 338.177 +    if (state->fd == -1) {
 338.178 +        free(state->path);
 338.179 +        free(state);
 338.180 +        return NULL;
 338.181 +    }
 338.182 +    if (state->mode == GZ_APPEND)
 338.183 +        state->mode = GZ_WRITE;         /* simplify later checks */
 338.184 +
 338.185 +    /* save the current position for rewinding (only if reading) */
 338.186 +    if (state->mode == GZ_READ) {
 338.187 +        state->start = LSEEK(state->fd, 0, SEEK_CUR);
 338.188 +        if (state->start == -1) state->start = 0;
 338.189 +    }
 338.190 +
 338.191 +    /* initialize stream */
 338.192 +    gz_reset(state);
 338.193 +
 338.194 +    /* return stream */
 338.195 +    return (gzFile)state;
 338.196 +}
 338.197 +
 338.198 +/* -- see zlib.h -- */
 338.199 +gzFile ZEXPORT gzopen(path, mode)
 338.200 +    const char *path;
 338.201 +    const char *mode;
 338.202 +{
 338.203 +    return gz_open(path, -1, mode);
 338.204 +}
 338.205 +
 338.206 +/* -- see zlib.h -- */
 338.207 +gzFile ZEXPORT gzopen64(path, mode)
 338.208 +    const char *path;
 338.209 +    const char *mode;
 338.210 +{
 338.211 +    return gz_open(path, -1, mode);
 338.212 +}
 338.213 +
 338.214 +/* -- see zlib.h -- */
 338.215 +gzFile ZEXPORT gzdopen(fd, mode)
 338.216 +    int fd;
 338.217 +    const char *mode;
 338.218 +{
 338.219 +    char *path;         /* identifier for error messages */
 338.220 +    gzFile gz;
 338.221 +
 338.222 +    if (fd == -1 || (path = malloc(7 + 3 * sizeof(int))) == NULL)
 338.223 +        return NULL;
 338.224 +    sprintf(path, "<fd:%d>", fd);   /* for debugging */
 338.225 +    gz = gz_open(path, fd, mode);
 338.226 +    free(path);
 338.227 +    return gz;
 338.228 +}
 338.229 +
 338.230 +/* -- see zlib.h -- */
 338.231 +int ZEXPORT gzbuffer(file, size)
 338.232 +    gzFile file;
 338.233 +    unsigned size;
 338.234 +{
 338.235 +    gz_statep state;
 338.236 +
 338.237 +    /* get internal structure and check integrity */
 338.238 +    if (file == NULL)
 338.239 +        return -1;
 338.240 +    state = (gz_statep)file;
 338.241 +    if (state->mode != GZ_READ && state->mode != GZ_WRITE)
 338.242 +        return -1;
 338.243 +
 338.244 +    /* make sure we haven't already allocated memory */
 338.245 +    if (state->size != 0)
 338.246 +        return -1;
 338.247 +
 338.248 +    /* check and set requested size */
 338.249 +    if (size == 0)
 338.250 +        return -1;
 338.251 +    state->want = size;
 338.252 +    return 0;
 338.253 +}
 338.254 +
 338.255 +/* -- see zlib.h -- */
 338.256 +int ZEXPORT gzrewind(file)
 338.257 +    gzFile file;
 338.258 +{
 338.259 +    gz_statep state;
 338.260 +
 338.261 +    /* get internal structure */
 338.262 +    if (file == NULL)
 338.263 +        return -1;
 338.264 +    state = (gz_statep)file;
 338.265 +
 338.266 +    /* check that we're reading and that there's no error */
 338.267 +    if (state->mode != GZ_READ || state->err != Z_OK)
 338.268 +        return -1;
 338.269 +
 338.270 +    /* back up and start over */
 338.271 +    if (LSEEK(state->fd, state->start, SEEK_SET) == -1)
 338.272 +        return -1;
 338.273 +    gz_reset(state);
 338.274 +    return 0;
 338.275 +}
 338.276 +
 338.277 +/* -- see zlib.h -- */
 338.278 +z_off64_t ZEXPORT gzseek64(file, offset, whence)
 338.279 +    gzFile file;
 338.280 +    z_off64_t offset;
 338.281 +    int whence;
 338.282 +{
 338.283 +    unsigned n;
 338.284 +    z_off64_t ret;
 338.285 +    gz_statep state;
 338.286 +
 338.287 +    /* get internal structure and check integrity */
 338.288 +    if (file == NULL)
 338.289 +        return -1;
 338.290 +    state = (gz_statep)file;
 338.291 +    if (state->mode != GZ_READ && state->mode != GZ_WRITE)
 338.292 +        return -1;
 338.293 +
 338.294 +    /* check that there's no error */
 338.295 +    if (state->err != Z_OK)
 338.296 +        return -1;
 338.297 +
 338.298 +    /* can only seek from start or relative to current position */
 338.299 +    if (whence != SEEK_SET && whence != SEEK_CUR)
 338.300 +        return -1;
 338.301 +
 338.302 +    /* normalize offset to a SEEK_CUR specification */
 338.303 +    if (whence == SEEK_SET)
 338.304 +        offset -= state->pos;
 338.305 +    else if (state->seek)
 338.306 +        offset += state->skip;
 338.307 +    state->seek = 0;
 338.308 +
 338.309 +    /* if within raw area while reading, just go there */
 338.310 +    if (state->mode == GZ_READ && state->how == COPY &&
 338.311 +        state->pos + offset >= state->raw) {
 338.312 +        ret = LSEEK(state->fd, offset - state->have, SEEK_CUR);
 338.313 +        if (ret == -1)
 338.314 +            return -1;
 338.315 +        state->have = 0;
 338.316 +        state->eof = 0;
 338.317 +        state->seek = 0;
 338.318 +        gz_error(state, Z_OK, NULL);
 338.319 +        state->strm.avail_in = 0;
 338.320 +        state->pos += offset;
 338.321 +        return state->pos;
 338.322 +    }
 338.323 +
 338.324 +    /* calculate skip amount, rewinding if needed for back seek when reading */
 338.325 +    if (offset < 0) {
 338.326 +        if (state->mode != GZ_READ)         /* writing -- can't go backwards */
 338.327 +            return -1;
 338.328 +        offset += state->pos;
 338.329 +        if (offset < 0)                     /* before start of file! */
 338.330 +            return -1;
 338.331 +        if (gzrewind(file) == -1)           /* rewind, then skip to offset */
 338.332 +            return -1;
 338.333 +    }
 338.334 +
 338.335 +    /* if reading, skip what's in output buffer (one less gzgetc() check) */
 338.336 +    if (state->mode == GZ_READ) {
 338.337 +        n = GT_OFF(state->have) || (z_off64_t)state->have > offset ?
 338.338 +            (unsigned)offset : state->have;
 338.339 +        state->have -= n;
 338.340 +        state->next += n;
 338.341 +        state->pos += n;
 338.342 +        offset -= n;
 338.343 +    }
 338.344 +
 338.345 +    /* request skip (if not zero) */
 338.346 +    if (offset) {
 338.347 +        state->seek = 1;
 338.348 +        state->skip = offset;
 338.349 +    }
 338.350 +    return state->pos + offset;
 338.351 +}
 338.352 +
 338.353 +/* -- see zlib.h -- */
 338.354 +z_off_t ZEXPORT gzseek(file, offset, whence)
 338.355 +    gzFile file;
 338.356 +    z_off_t offset;
 338.357 +    int whence;
 338.358 +{
 338.359 +    z_off64_t ret;
 338.360 +
 338.361 +    ret = gzseek64(file, (z_off64_t)offset, whence);
 338.362 +    return ret == (z_off_t)ret ? (z_off_t)ret : -1;
 338.363 +}
 338.364 +
 338.365 +/* -- see zlib.h -- */
 338.366 +z_off64_t ZEXPORT gztell64(file)
 338.367 +    gzFile file;
 338.368 +{
 338.369 +    gz_statep state;
 338.370 +
 338.371 +    /* get internal structure and check integrity */
 338.372 +    if (file == NULL)
 338.373 +        return -1;
 338.374 +    state = (gz_statep)file;
 338.375 +    if (state->mode != GZ_READ && state->mode != GZ_WRITE)
 338.376 +        return -1;
 338.377 +
 338.378 +    /* return position */
 338.379 +    return state->pos + (state->seek ? state->skip : 0);
 338.380 +}
 338.381 +
 338.382 +/* -- see zlib.h -- */
 338.383 +z_off_t ZEXPORT gztell(file)
 338.384 +    gzFile file;
 338.385 +{
 338.386 +    z_off64_t ret;
 338.387 +
 338.388 +    ret = gztell64(file);
 338.389 +    return ret == (z_off_t)ret ? (z_off_t)ret : -1;
 338.390 +}
 338.391 +
 338.392 +/* -- see zlib.h -- */
 338.393 +z_off64_t ZEXPORT gzoffset64(file)
 338.394 +    gzFile file;
 338.395 +{
 338.396 +    z_off64_t offset;
 338.397 +    gz_statep state;
 338.398 +
 338.399 +    /* get internal structure and check integrity */
 338.400 +    if (file == NULL)
 338.401 +        return -1;
 338.402 +    state = (gz_statep)file;
 338.403 +    if (state->mode != GZ_READ && state->mode != GZ_WRITE)
 338.404 +        return -1;
 338.405 +
 338.406 +    /* compute and return effective offset in file */
 338.407 +    offset = LSEEK(state->fd, 0, SEEK_CUR);
 338.408 +    if (offset == -1)
 338.409 +        return -1;
 338.410 +    if (state->mode == GZ_READ)             /* reading */
 338.411 +        offset -= state->strm.avail_in;     /* don't count buffered input */
 338.412 +    return offset;
 338.413 +}
 338.414 +
 338.415 +/* -- see zlib.h -- */
 338.416 +z_off_t ZEXPORT gzoffset(file)
 338.417 +    gzFile file;
 338.418 +{
 338.419 +    z_off64_t ret;
 338.420 +
 338.421 +    ret = gzoffset64(file);
 338.422 +    return ret == (z_off_t)ret ? (z_off_t)ret : -1;
 338.423 +}
 338.424 +
 338.425 +/* -- see zlib.h -- */
 338.426 +int ZEXPORT gzeof(file)
 338.427 +    gzFile file;
 338.428 +{
 338.429 +    gz_statep state;
 338.430 +
 338.431 +    /* get internal structure and check integrity */
 338.432 +    if (file == NULL)
 338.433 +        return 0;
 338.434 +    state = (gz_statep)file;
 338.435 +    if (state->mode != GZ_READ && state->mode != GZ_WRITE)
 338.436 +        return 0;
 338.437 +
 338.438 +    /* return end-of-file state */
 338.439 +    return state->mode == GZ_READ ?
 338.440 +        (state->eof && state->strm.avail_in == 0 && state->have == 0) : 0;
 338.441 +}
 338.442 +
 338.443 +/* -- see zlib.h -- */
 338.444 +const char * ZEXPORT gzerror(file, errnum)
 338.445 +    gzFile file;
 338.446 +    int *errnum;
 338.447 +{
 338.448 +    gz_statep state;
 338.449 +
 338.450 +    /* get internal structure and check integrity */
 338.451 +    if (file == NULL)
 338.452 +        return NULL;
 338.453 +    state = (gz_statep)file;
 338.454 +    if (state->mode != GZ_READ && state->mode != GZ_WRITE)
 338.455 +        return NULL;
 338.456 +
 338.457 +    /* return error information */
 338.458 +    if (errnum != NULL)
 338.459 +        *errnum = state->err;
 338.460 +    return state->msg == NULL ? "" : state->msg;
 338.461 +}
 338.462 +
 338.463 +/* -- see zlib.h -- */
 338.464 +void ZEXPORT gzclearerr(file)
 338.465 +    gzFile file;
 338.466 +{
 338.467 +    gz_statep state;
 338.468 +
 338.469 +    /* get internal structure and check integrity */
 338.470 +    if (file == NULL)
 338.471 +        return;
 338.472 +    state = (gz_statep)file;
 338.473 +    if (state->mode != GZ_READ && state->mode != GZ_WRITE)
 338.474 +        return;
 338.475 +
 338.476 +    /* clear error and end-of-file */
 338.477 +    if (state->mode == GZ_READ)
 338.478 +        state->eof = 0;
 338.479 +    gz_error(state, Z_OK, NULL);
 338.480 +}
 338.481 +
 338.482 +/* Create an error message in allocated memory and set state->err and
 338.483 +   state->msg accordingly.  Free any previous error message already there.  Do
 338.484 +   not try to free or allocate space if the error is Z_MEM_ERROR (out of
 338.485 +   memory).  Simply save the error message as a static string.  If there is an
 338.486 +   allocation failure constructing the error message, then convert the error to
 338.487 +   out of memory. */
 338.488 +void ZLIB_INTERNAL gz_error(state, err, msg)
 338.489 +    gz_statep state;
 338.490 +    int err;
 338.491 +    const char *msg;
 338.492 +{
 338.493 +    /* free previously allocated message and clear */
 338.494 +    if (state->msg != NULL) {
 338.495 +        if (state->err != Z_MEM_ERROR)
 338.496 +            free(state->msg);
 338.497 +        state->msg = NULL;
 338.498 +    }
 338.499 +
 338.500 +    /* set error code, and if no message, then done */
 338.501 +    state->err = err;
 338.502 +    if (msg == NULL)
 338.503 +        return;
 338.504 +
 338.505 +    /* for an out of memory error, save as static string */
 338.506 +    if (err == Z_MEM_ERROR) {
 338.507 +        state->msg = (char *)msg;
 338.508 +        return;
 338.509 +    }
 338.510 +
 338.511 +    /* construct error message with path */
 338.512 +    if ((state->msg = malloc(strlen(state->path) + strlen(msg) + 3)) == NULL) {
 338.513 +        state->err = Z_MEM_ERROR;
 338.514 +        state->msg = (char *)"out of memory";
 338.515 +        return;
 338.516 +    }
 338.517 +    strcpy(state->msg, state->path);
 338.518 +    strcat(state->msg, ": ");
 338.519 +    strcat(state->msg, msg);
 338.520 +    return;
 338.521 +}
 338.522 +
 338.523 +#ifndef INT_MAX
 338.524 +/* portably return maximum value for an int (when limits.h presumed not
 338.525 +   available) -- we need to do this to cover cases where 2's complement not
 338.526 +   used, since C standard permits 1's complement and sign-bit representations,
 338.527 +   otherwise we could just use ((unsigned)-1) >> 1 */
 338.528 +unsigned ZLIB_INTERNAL gz_intmax()
 338.529 +{
 338.530 +    unsigned p, q;
 338.531 +
 338.532 +    p = 1;
 338.533 +    do {
 338.534 +        q = p;
 338.535 +        p <<= 1;
 338.536 +        p++;
 338.537 +    } while (p > q);
 338.538 +    return q >> 1;
 338.539 +}
 338.540 +#endif
   339.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
   339.2 +++ b/deps/glpk/src/zlib/gzread.c	Sun Nov 06 20:59:10 2011 +0100
   339.3 @@ -0,0 +1,653 @@
   339.4 +/* gzread.c -- zlib functions for reading gzip files
   339.5 + * Copyright (C) 2004, 2005, 2010 Mark Adler
   339.6 + * For conditions of distribution and use, see copyright notice in zlib.h
   339.7 + */
   339.8 +
   339.9 +#include "gzguts.h"
  339.10 +
  339.11 +/* Local functions */
  339.12 +local int gz_load OF((gz_statep, unsigned char *, unsigned, unsigned *));
  339.13 +local int gz_avail OF((gz_statep));
  339.14 +local int gz_next4 OF((gz_statep, unsigned long *));
  339.15 +local int gz_head OF((gz_statep));
  339.16 +local int gz_decomp OF((gz_statep));
  339.17 +local int gz_make OF((gz_statep));
  339.18 +local int gz_skip OF((gz_statep, z_off64_t));
  339.19 +
  339.20 +/* Use read() to load a buffer -- return -1 on error, otherwise 0.  Read from
  339.21 +   state->fd, and update state->eof, state->err, and state->msg as appropriate.
  339.22 +   This function needs to loop on read(), since read() is not guaranteed to
  339.23 +   read the number of bytes requested, depending on the type of descriptor. */
  339.24 +local int gz_load(state, buf, len, have)
  339.25 +    gz_statep state;
  339.26 +    unsigned char *buf;
  339.27 +    unsigned len;
  339.28 +    unsigned *have;
  339.29 +{
  339.30 +    int ret;
  339.31 +
  339.32 +    *have = 0;
  339.33 +    do {
  339.34 +        ret = read(state->fd, buf + *have, len - *have);
  339.35 +        if (ret <= 0)
  339.36 +            break;
  339.37 +        *have += ret;
  339.38 +    } while (*have < len);
  339.39 +    if (ret < 0) {
  339.40 +        gz_error(state, Z_ERRNO, zstrerror());
  339.41 +        return -1;
  339.42 +    }
  339.43 +    if (ret == 0)
  339.44 +        state->eof = 1;
  339.45 +    return 0;
  339.46 +}
  339.47 +
  339.48 +/* Load up input buffer and set eof flag if last data loaded -- return -1 on
  339.49 +   error, 0 otherwise.  Note that the eof flag is set when the end of the input
  339.50 +   file is reached, even though there may be unused data in the buffer.  Once
  339.51 +   that data has been used, no more attempts will be made to read the file.
  339.52 +   gz_avail() assumes that strm->avail_in == 0. */
  339.53 +local int gz_avail(state)
  339.54 +    gz_statep state;
  339.55 +{
  339.56 +    z_streamp strm = &(state->strm);
  339.57 +
  339.58 +    if (state->err != Z_OK)
  339.59 +        return -1;
  339.60 +    if (state->eof == 0) {
  339.61 +        if (gz_load(state, state->in, state->size,
  339.62 +                (unsigned *)&(strm->avail_in)) == -1)
  339.63 +            return -1;
  339.64 +        strm->next_in = state->in;
  339.65 +    }
  339.66 +    return 0;
  339.67 +}
  339.68 +
  339.69 +/* Get next byte from input, or -1 if end or error. */
  339.70 +#define NEXT() ((strm->avail_in == 0 && gz_avail(state) == -1) ? -1 : \
  339.71 +                (strm->avail_in == 0 ? -1 : \
  339.72 +                 (strm->avail_in--, *(strm->next_in)++)))
  339.73 +
  339.74 +/* Get a four-byte little-endian integer and return 0 on success and the value
  339.75 +   in *ret.  Otherwise -1 is returned and *ret is not modified. */
  339.76 +local int gz_next4(state, ret)
  339.77 +    gz_statep state;
  339.78 +    unsigned long *ret;
  339.79 +{
  339.80 +    int ch;
  339.81 +    unsigned long val;
  339.82 +    z_streamp strm = &(state->strm);
  339.83 +
  339.84 +    val = NEXT();
  339.85 +    val += (unsigned)NEXT() << 8;
  339.86 +    val += (unsigned long)NEXT() << 16;
  339.87 +    ch = NEXT();
  339.88 +    if (ch == -1)
  339.89 +        return -1;
  339.90 +    val += (unsigned long)ch << 24;
  339.91 +    *ret = val;
  339.92 +    return 0;
  339.93 +}
  339.94 +
  339.95 +/* Look for gzip header, set up for inflate or copy.  state->have must be zero.
  339.96 +   If this is the first time in, allocate required memory.  state->how will be
  339.97 +   left unchanged if there is no more input data available, will be set to COPY
  339.98 +   if there is no gzip header and direct copying will be performed, or it will
  339.99 +   be set to GZIP for decompression, and the gzip header will be skipped so
 339.100 +   that the next available input data is the raw deflate stream.  If direct
 339.101 +   copying, then leftover input data from the input buffer will be copied to
 339.102 +   the output buffer.  In that case, all further file reads will be directly to
 339.103 +   either the output buffer or a user buffer.  If decompressing, the inflate
 339.104 +   state and the check value will be initialized.  gz_head() will return 0 on
 339.105 +   success or -1 on failure.  Failures may include read errors or gzip header
 339.106 +   errors.  */
 339.107 +local int gz_head(state)
 339.108 +    gz_statep state;
 339.109 +{
 339.110 +    z_streamp strm = &(state->strm);
 339.111 +    int flags;
 339.112 +    unsigned len;
 339.113 +
 339.114 +    /* allocate read buffers and inflate memory */
 339.115 +    if (state->size == 0) {
 339.116 +        /* allocate buffers */
 339.117 +        state->in = malloc(state->want);
 339.118 +        state->out = malloc(state->want << 1);
 339.119 +        if (state->in == NULL || state->out == NULL) {
 339.120 +            if (state->out != NULL)
 339.121 +                free(state->out);
 339.122 +            if (state->in != NULL)
 339.123 +                free(state->in);
 339.124 +            gz_error(state, Z_MEM_ERROR, "out of memory");
 339.125 +            return -1;
 339.126 +        }
 339.127 +        state->size = state->want;
 339.128 +
 339.129 +        /* allocate inflate memory */
 339.130 +        state->strm.zalloc = Z_NULL;
 339.131 +        state->strm.zfree = Z_NULL;
 339.132 +        state->strm.opaque = Z_NULL;
 339.133 +        state->strm.avail_in = 0;
 339.134 +        state->strm.next_in = Z_NULL;
 339.135 +        if (inflateInit2(&(state->strm), -15) != Z_OK) {    /* raw inflate */
 339.136 +            free(state->out);
 339.137 +            free(state->in);
 339.138 +            state->size = 0;
 339.139 +            gz_error(state, Z_MEM_ERROR, "out of memory");
 339.140 +            return -1;
 339.141 +        }
 339.142 +    }
 339.143 +
 339.144 +    /* get some data in the input buffer */
 339.145 +    if (strm->avail_in == 0) {
 339.146 +        if (gz_avail(state) == -1)
 339.147 +            return -1;
 339.148 +        if (strm->avail_in == 0)
 339.149 +            return 0;
 339.150 +    }
 339.151 +
 339.152 +    /* look for the gzip magic header bytes 31 and 139 */
 339.153 +    if (strm->next_in[0] == 31) {
 339.154 +        strm->avail_in--;
 339.155 +        strm->next_in++;
 339.156 +        if (strm->avail_in == 0 && gz_avail(state) == -1)
 339.157 +            return -1;
 339.158 +        if (strm->avail_in && strm->next_in[0] == 139) {
 339.159 +            /* we have a gzip header, woo hoo! */
 339.160 +            strm->avail_in--;
 339.161 +            strm->next_in++;
 339.162 +
 339.163 +            /* skip rest of header */
 339.164 +            if (NEXT() != 8) {      /* compression method */
 339.165 +                gz_error(state, Z_DATA_ERROR, "unknown compression method");
 339.166 +                return -1;
 339.167 +            }
 339.168 +            flags = NEXT();
 339.169 +            if (flags & 0xe0) {     /* reserved flag bits */
 339.170 +                gz_error(state, Z_DATA_ERROR, "unknown header flags set");
 339.171 +                return -1;
 339.172 +            }
 339.173 +            NEXT();                 /* modification time */
 339.174 +            NEXT();
 339.175 +            NEXT();
 339.176 +            NEXT();
 339.177 +            NEXT();                 /* extra flags */
 339.178 +            NEXT();                 /* operating system */
 339.179 +            if (flags & 4) {        /* extra field */
 339.180 +                len = (unsigned)NEXT();
 339.181 +                len += (unsigned)NEXT() << 8;
 339.182 +                while (len--)
 339.183 +                    if (NEXT() < 0)
 339.184 +                        break;
 339.185 +            }
 339.186 +            if (flags & 8)          /* file name */
 339.187 +                while (NEXT() > 0)
 339.188 +                    ;
 339.189 +            if (flags & 16)         /* comment */
 339.190 +                while (NEXT() > 0)
 339.191 +                    ;
 339.192 +            if (flags & 2) {        /* header crc */
 339.193 +                NEXT();
 339.194 +                NEXT();
 339.195 +            }
 339.196 +            /* an unexpected end of file is not checked for here -- it will be
 339.197 +               noticed on the first request for uncompressed data */
 339.198 +
 339.199 +            /* set up for decompression */
 339.200 +            inflateReset(strm);
 339.201 +            strm->adler = crc32(0L, Z_NULL, 0);
 339.202 +            state->how = GZIP;
 339.203 +            state->direct = 0;
 339.204 +            return 0;
 339.205 +        }
 339.206 +        else {
 339.207 +            /* not a gzip file -- save first byte (31) and fall to raw i/o */
 339.208 +            state->out[0] = 31;
 339.209 +            state->have = 1;
 339.210 +        }
 339.211 +    }
 339.212 +
 339.213 +    /* doing raw i/o, save start of raw data for seeking, copy any leftover
 339.214 +       input to output -- this assumes that the output buffer is larger than
 339.215 +       the input buffer, which also assures space for gzungetc() */
 339.216 +    state->raw = state->pos;
 339.217 +    state->next = state->out;
 339.218 +    if (strm->avail_in) {
 339.219 +        memcpy(state->next + state->have, strm->next_in, strm->avail_in);
 339.220 +        state->have += strm->avail_in;
 339.221 +        strm->avail_in = 0;
 339.222 +    }
 339.223 +    state->how = COPY;
 339.224 +    state->direct = 1;
 339.225 +    return 0;
 339.226 +}
 339.227 +
 339.228 +/* Decompress from input to the provided next_out and avail_out in the state.
 339.229 +   If the end of the compressed data is reached, then verify the gzip trailer
 339.230 +   check value and length (modulo 2^32).  state->have and state->next are set
 339.231 +   to point to the just decompressed data, and the crc is updated.  If the
 339.232 +   trailer is verified, state->how is reset to LOOK to look for the next gzip
 339.233 +   stream or raw data, once state->have is depleted.  Returns 0 on success, -1
 339.234 +   on failure.  Failures may include invalid compressed data or a failed gzip
 339.235 +   trailer verification. */
 339.236 +local int gz_decomp(state)
 339.237 +    gz_statep state;
 339.238 +{
 339.239 +    int ret;
 339.240 +    unsigned had;
 339.241 +    unsigned long crc, len;
 339.242 +    z_streamp strm = &(state->strm);
 339.243 +
 339.244 +    /* fill output buffer up to end of deflate stream */
 339.245 +    had = strm->avail_out;
 339.246 +    do {
 339.247 +        /* get more input for inflate() */
 339.248 +        if (strm->avail_in == 0 && gz_avail(state) == -1)
 339.249 +            return -1;
 339.250 +        if (strm->avail_in == 0) {
 339.251 +            gz_error(state, Z_DATA_ERROR, "unexpected end of file");
 339.252 +            return -1;
 339.253 +        }
 339.254 +
 339.255 +        /* decompress and handle errors */
 339.256 +        ret = inflate(strm, Z_NO_FLUSH);
 339.257 +        if (ret == Z_STREAM_ERROR || ret == Z_NEED_DICT) {
 339.258 +            gz_error(state, Z_STREAM_ERROR,
 339.259 +                      "internal error: inflate stream corrupt");
 339.260 +            return -1;
 339.261 +        }
 339.262 +        if (ret == Z_MEM_ERROR) {
 339.263 +            gz_error(state, Z_MEM_ERROR, "out of memory");
 339.264 +            return -1;
 339.265 +        }
 339.266 +        if (ret == Z_DATA_ERROR) {              /* deflate stream invalid */
 339.267 +            gz_error(state, Z_DATA_ERROR,
 339.268 +                      strm->msg == NULL ? "compressed data error" : strm->msg);
 339.269 +            return -1;
 339.270 +        }
 339.271 +    } while (strm->avail_out && ret != Z_STREAM_END);
 339.272 +
 339.273 +    /* update available output and crc check value */
 339.274 +    state->have = had - strm->avail_out;
 339.275 +    state->next = strm->next_out - state->have;
 339.276 +    strm->adler = crc32(strm->adler, state->next, state->have);
 339.277 +
 339.278 +    /* check gzip trailer if at end of deflate stream */
 339.279 +    if (ret == Z_STREAM_END) {
 339.280 +        if (gz_next4(state, &crc) == -1 || gz_next4(state, &len) == -1) {
 339.281 +            gz_error(state, Z_DATA_ERROR, "unexpected end of file");
 339.282 +            return -1;
 339.283 +        }
 339.284 +        if (crc != strm->adler) {
 339.285 +            gz_error(state, Z_DATA_ERROR, "incorrect data check");
 339.286 +            return -1;
 339.287 +        }
 339.288 +        if (len != (strm->total_out & 0xffffffffL)) {
 339.289 +            gz_error(state, Z_DATA_ERROR, "incorrect length check");
 339.290 +            return -1;
 339.291 +        }
 339.292 +        state->how = LOOK;      /* ready for next stream, once have is 0 (leave
 339.293 +                                   state->direct unchanged to remember how) */
 339.294 +    }
 339.295 +
 339.296 +    /* good decompression */
 339.297 +    return 0;
 339.298 +}
 339.299 +
 339.300 +/* Make data and put in the output buffer.  Assumes that state->have == 0.
 339.301 +   Data is either copied from the input file or decompressed from the input
 339.302 +   file depending on state->how.  If state->how is LOOK, then a gzip header is
 339.303 +   looked for (and skipped if found) to determine wither to copy or decompress.
 339.304 +   Returns -1 on error, otherwise 0.  gz_make() will leave state->have as COPY
 339.305 +   or GZIP unless the end of the input file has been reached and all data has
 339.306 +   been processed.  */
 339.307 +local int gz_make(state)
 339.308 +    gz_statep state;
 339.309 +{
 339.310 +    z_streamp strm = &(state->strm);
 339.311 +
 339.312 +    if (state->how == LOOK) {           /* look for gzip header */
 339.313 +        if (gz_head(state) == -1)
 339.314 +            return -1;
 339.315 +        if (state->have)                /* got some data from gz_head() */
 339.316 +            return 0;
 339.317 +    }
 339.318 +    if (state->how == COPY) {           /* straight copy */
 339.319 +        if (gz_load(state, state->out, state->size << 1, &(state->have)) == -1)
 339.320 +            return -1;
 339.321 +        state->next = state->out;
 339.322 +    }
 339.323 +    else if (state->how == GZIP) {      /* decompress */
 339.324 +        strm->avail_out = state->size << 1;
 339.325 +        strm->next_out = state->out;
 339.326 +        if (gz_decomp(state) == -1)
 339.327 +            return -1;
 339.328 +    }
 339.329 +    return 0;
 339.330 +}
 339.331 +
 339.332 +/* Skip len uncompressed bytes of output.  Return -1 on error, 0 on success. */
 339.333 +local int gz_skip(state, len)
 339.334 +    gz_statep state;
 339.335 +    z_off64_t len;
 339.336 +{
 339.337 +    unsigned n;
 339.338 +
 339.339 +    /* skip over len bytes or reach end-of-file, whichever comes first */
 339.340 +    while (len)
 339.341 +        /* skip over whatever is in output buffer */
 339.342 +        if (state->have) {
 339.343 +            n = GT_OFF(state->have) || (z_off64_t)state->have > len ?
 339.344 +                (unsigned)len : state->have;
 339.345 +            state->have -= n;
 339.346 +            state->next += n;
 339.347 +            state->pos += n;
 339.348 +            len -= n;
 339.349 +        }
 339.350 +
 339.351 +        /* output buffer empty -- return if we're at the end of the input */
 339.352 +        else if (state->eof && state->strm.avail_in == 0)
 339.353 +            break;
 339.354 +
 339.355 +        /* need more data to skip -- load up output buffer */
 339.356 +        else {
 339.357 +            /* get more output, looking for header if required */
 339.358 +            if (gz_make(state) == -1)
 339.359 +                return -1;
 339.360 +        }
 339.361 +    return 0;
 339.362 +}
 339.363 +
 339.364 +/* -- see zlib.h -- */
 339.365 +int ZEXPORT gzread(file, buf, len)
 339.366 +    gzFile file;
 339.367 +    voidp buf;
 339.368 +    unsigned len;
 339.369 +{
 339.370 +    unsigned got, n;
 339.371 +    gz_statep state;
 339.372 +    z_streamp strm;
 339.373 +
 339.374 +    /* get internal structure */
 339.375 +    if (file == NULL)
 339.376 +        return -1;
 339.377 +    state = (gz_statep)file;
 339.378 +    strm = &(state->strm);
 339.379 +
 339.380 +    /* check that we're reading and that there's no error */
 339.381 +    if (state->mode != GZ_READ || state->err != Z_OK)
 339.382 +        return -1;
 339.383 +
 339.384 +    /* since an int is returned, make sure len fits in one, otherwise return
 339.385 +       with an error (this avoids the flaw in the interface) */
 339.386 +    if ((int)len < 0) {
 339.387 +        gz_error(state, Z_BUF_ERROR, "requested length does not fit in int");
 339.388 +        return -1;
 339.389 +    }
 339.390 +
 339.391 +    /* if len is zero, avoid unnecessary operations */
 339.392 +    if (len == 0)
 339.393 +        return 0;
 339.394 +
 339.395 +    /* process a skip request */
 339.396 +    if (state->seek) {
 339.397 +        state->seek = 0;
 339.398 +        if (gz_skip(state, state->skip) == -1)
 339.399 +            return -1;
 339.400 +    }
 339.401 +
 339.402 +    /* get len bytes to buf, or less than len if at the end */
 339.403 +    got = 0;
 339.404 +    do {
 339.405 +        /* first just try copying data from the output buffer */
 339.406 +        if (state->have) {
 339.407 +            n = state->have > len ? len : state->have;
 339.408 +            memcpy(buf, state->next, n);
 339.409 +            state->next += n;
 339.410 +            state->have -= n;
 339.411 +        }
 339.412 +
 339.413 +        /* output buffer empty -- return if we're at the end of the input */
 339.414 +        else if (state->eof && strm->avail_in == 0)
 339.415 +            break;
 339.416 +
 339.417 +        /* need output data -- for small len or new stream load up our output
 339.418 +           buffer */
 339.419 +        else if (state->how == LOOK || len < (state->size << 1)) {
 339.420 +            /* get more output, looking for header if required */
 339.421 +            if (gz_make(state) == -1)
 339.422 +                return -1;
 339.423 +            continue;       /* no progress yet -- go back to memcpy() above */
 339.424 +            /* the copy above assures that we will leave with space in the
 339.425 +               output buffer, allowing at least one gzungetc() to succeed */
 339.426 +        }
 339.427 +
 339.428 +        /* large len -- read directly into user buffer */
 339.429 +        else if (state->how == COPY) {      /* read directly */
 339.430 +            if (gz_load(state, buf, len, &n) == -1)
 339.431 +                return -1;
 339.432 +        }
 339.433 +
 339.434 +        /* large len -- decompress directly into user buffer */
 339.435 +        else {  /* state->how == GZIP */
 339.436 +            strm->avail_out = len;
 339.437 +            strm->next_out = buf;
 339.438 +            if (gz_decomp(state) == -1)
 339.439 +                return -1;
 339.440 +            n = state->have;
 339.441 +            state->have = 0;
 339.442 +        }
 339.443 +
 339.444 +        /* update progress */
 339.445 +        len -= n;
 339.446 +        buf = (char *)buf + n;
 339.447 +        got += n;
 339.448 +        state->pos += n;
 339.449 +    } while (len);
 339.450 +
 339.451 +    /* return number of bytes read into user buffer (will fit in int) */
 339.452 +    return (int)got;
 339.453 +}
 339.454 +
 339.455 +/* -- see zlib.h -- */
 339.456 +int ZEXPORT gzgetc(file)
 339.457 +    gzFile file;
 339.458 +{
 339.459 +    int ret;
 339.460 +    unsigned char buf[1];
 339.461 +    gz_statep state;
 339.462 +
 339.463 +    /* get internal structure */
 339.464 +    if (file == NULL)
 339.465 +        return -1;
 339.466 +    state = (gz_statep)file;
 339.467 +
 339.468 +    /* check that we're reading and that there's no error */
 339.469 +    if (state->mode != GZ_READ || state->err != Z_OK)
 339.470 +        return -1;
 339.471 +
 339.472 +    /* try output buffer (no need to check for skip request) */
 339.473 +    if (state->have) {
 339.474 +        state->have--;
 339.475 +        state->pos++;
 339.476 +        return *(state->next)++;
 339.477 +    }
 339.478 +
 339.479 +    /* nothing there -- try gzread() */
 339.480 +    ret = gzread(file, buf, 1);
 339.481 +    return ret < 1 ? -1 : buf[0];
 339.482 +}
 339.483 +
 339.484 +/* -- see zlib.h -- */
 339.485 +int ZEXPORT gzungetc(c, file)
 339.486 +    int c;
 339.487 +    gzFile file;
 339.488 +{
 339.489 +    gz_statep state;
 339.490 +
 339.491 +    /* get internal structure */
 339.492 +    if (file == NULL)
 339.493 +        return -1;
 339.494 +    state = (gz_statep)file;
 339.495 +
 339.496 +    /* check that we're reading and that there's no error */
 339.497 +    if (state->mode != GZ_READ || state->err != Z_OK)
 339.498 +        return -1;
 339.499 +
 339.500 +    /* process a skip request */
 339.501 +    if (state->seek) {
 339.502 +        state->seek = 0;
 339.503 +        if (gz_skip(state, state->skip) == -1)
 339.504 +            return -1;
 339.505 +    }
 339.506 +
 339.507 +    /* can't push EOF */
 339.508 +    if (c < 0)
 339.509 +        return -1;
 339.510 +
 339.511 +    /* if output buffer empty, put byte at end (allows more pushing) */
 339.512 +    if (state->have == 0) {
 339.513 +        state->have = 1;
 339.514 +        state->next = state->out + (state->size << 1) - 1;
 339.515 +        state->next[0] = c;
 339.516 +        state->pos--;
 339.517 +        return c;
 339.518 +    }
 339.519 +
 339.520 +    /* if no room, give up (must have already done a gzungetc()) */
 339.521 +    if (state->have == (state->size << 1)) {
 339.522 +        gz_error(state, Z_BUF_ERROR, "out of room to push characters");
 339.523 +        return -1;
 339.524 +    }
 339.525 +
 339.526 +    /* slide output data if needed and insert byte before existing data */
 339.527 +    if (state->next == state->out) {
 339.528 +        unsigned char *src = state->out + state->have;
 339.529 +        unsigned char *dest = state->out + (state->size << 1);
 339.530 +        while (src > state->out)
 339.531 +            *--dest = *--src;
 339.532 +        state->next = dest;
 339.533 +    }
 339.534 +    state->have++;
 339.535 +    state->next--;
 339.536 +    state->next[0] = c;
 339.537 +    state->pos--;
 339.538 +    return c;
 339.539 +}
 339.540 +
 339.541 +/* -- see zlib.h -- */
 339.542 +char * ZEXPORT gzgets(file, buf, len)
 339.543 +    gzFile file;
 339.544 +    char *buf;
 339.545 +    int len;
 339.546 +{
 339.547 +    unsigned left, n;
 339.548 +    char *str;
 339.549 +    unsigned char *eol;
 339.550 +    gz_statep state;
 339.551 +
 339.552 +    /* check parameters and get internal structure */
 339.553 +    if (file == NULL || buf == NULL || len < 1)
 339.554 +        return NULL;
 339.555 +    state = (gz_statep)file;
 339.556 +
 339.557 +    /* check that we're reading and that there's no error */
 339.558 +    if (state->mode != GZ_READ || state->err != Z_OK)
 339.559 +        return NULL;
 339.560 +
 339.561 +    /* process a skip request */
 339.562 +    if (state->seek) {
 339.563 +        state->seek = 0;
 339.564 +        if (gz_skip(state, state->skip) == -1)
 339.565 +            return NULL;
 339.566 +    }
 339.567 +
 339.568 +    /* copy output bytes up to new line or len - 1, whichever comes first --
 339.569 +       append a terminating zero to the string (we don't check for a zero in
 339.570 +       the contents, let the user worry about that) */
 339.571 +    str = buf;
 339.572 +    left = (unsigned)len - 1;
 339.573 +    if (left) do {
 339.574 +        /* assure that something is in the output buffer */
 339.575 +        if (state->have == 0) {
 339.576 +            if (gz_make(state) == -1)
 339.577 +                return NULL;            /* error */
 339.578 +            if (state->have == 0) {     /* end of file */
 339.579 +                if (buf == str)         /* got bupkus */
 339.580 +                    return NULL;
 339.581 +                break;                  /* got something -- return it */
 339.582 +            }
 339.583 +        }
 339.584 +
 339.585 +        /* look for end-of-line in current output buffer */
 339.586 +        n = state->have > left ? left : state->have;
 339.587 +        eol = memchr(state->next, '\n', n);
 339.588 +        if (eol != NULL)
 339.589 +            n = (unsigned)(eol - state->next) + 1;
 339.590 +
 339.591 +        /* copy through end-of-line, or remainder if not found */
 339.592 +        memcpy(buf, state->next, n);
 339.593 +        state->have -= n;
 339.594 +        state->next += n;
 339.595 +        state->pos += n;
 339.596 +        left -= n;
 339.597 +        buf += n;
 339.598 +    } while (left && eol == NULL);
 339.599 +
 339.600 +    /* found end-of-line or out of space -- terminate string and return it */
 339.601 +    buf[0] = 0;
 339.602 +    return str;
 339.603 +}
 339.604 +
 339.605 +/* -- see zlib.h -- */
 339.606 +int ZEXPORT gzdirect(file)
 339.607 +    gzFile file;
 339.608 +{
 339.609 +    gz_statep state;
 339.610 +
 339.611 +    /* get internal structure */
 339.612 +    if (file == NULL)
 339.613 +        return 0;
 339.614 +    state = (gz_statep)file;
 339.615 +
 339.616 +    /* check that we're reading */
 339.617 +    if (state->mode != GZ_READ)
 339.618 +        return 0;
 339.619 +
 339.620 +    /* if the state is not known, but we can find out, then do so (this is
 339.621 +       mainly for right after a gzopen() or gzdopen()) */
 339.622 +    if (state->how == LOOK && state->have == 0)
 339.623 +        (void)gz_head(state);
 339.624 +
 339.625 +    /* return 1 if reading direct, 0 if decompressing a gzip stream */
 339.626 +    return state->direct;
 339.627 +}
 339.628 +
 339.629 +/* -- see zlib.h -- */
 339.630 +int ZEXPORT gzclose_r(file)
 339.631 +    gzFile file;
 339.632 +{
 339.633 +    int ret;
 339.634 +    gz_statep state;
 339.635 +
 339.636 +    /* get internal structure */
 339.637 +    if (file == NULL)
 339.638 +        return Z_STREAM_ERROR;
 339.639 +    state = (gz_statep)file;
 339.640 +
 339.641 +    /* check that we're reading */
 339.642 +    if (state->mode != GZ_READ)
 339.643 +        return Z_STREAM_ERROR;
 339.644 +
 339.645 +    /* free memory and close file */
 339.646 +    if (state->size) {
 339.647 +        inflateEnd(&(state->strm));
 339.648 +        free(state->out);
 339.649 +        free(state->in);
 339.650 +    }
 339.651 +    gz_error(state, Z_OK, NULL);
 339.652 +    free(state->path);
 339.653 +    ret = close(state->fd);
 339.654 +    free(state);
 339.655 +    return ret ? Z_ERRNO : Z_OK;
 339.656 +}
   340.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
   340.2 +++ b/deps/glpk/src/zlib/gzwrite.c	Sun Nov 06 20:59:10 2011 +0100
   340.3 @@ -0,0 +1,531 @@
   340.4 +/* gzwrite.c -- zlib functions for writing gzip files
   340.5 + * Copyright (C) 2004, 2005, 2010 Mark Adler
   340.6 + * For conditions of distribution and use, see copyright notice in zlib.h
   340.7 + */
   340.8 +
   340.9 +#include "gzguts.h"
  340.10 +
  340.11 +/* Local functions */
  340.12 +local int gz_init OF((gz_statep));
  340.13 +local int gz_comp OF((gz_statep, int));
  340.14 +local int gz_zero OF((gz_statep, z_off64_t));
  340.15 +
  340.16 +/* Initialize state for writing a gzip file.  Mark initialization by setting
  340.17 +   state->size to non-zero.  Return -1 on failure or 0 on success. */
  340.18 +local int gz_init(state)
  340.19 +    gz_statep state;
  340.20 +{
  340.21 +    int ret;
  340.22 +    z_streamp strm = &(state->strm);
  340.23 +
  340.24 +    /* allocate input and output buffers */
  340.25 +    state->in = malloc(state->want);
  340.26 +    state->out = malloc(state->want);
  340.27 +    if (state->in == NULL || state->out == NULL) {
  340.28 +        if (state->out != NULL)
  340.29 +            free(state->out);
  340.30 +        if (state->in != NULL)
  340.31 +            free(state->in);
  340.32 +        gz_error(state, Z_MEM_ERROR, "out of memory");
  340.33 +        return -1;
  340.34 +    }
  340.35 +
  340.36 +    /* allocate deflate memory, set up for gzip compression */
  340.37 +    strm->zalloc = Z_NULL;
  340.38 +    strm->zfree = Z_NULL;
  340.39 +    strm->opaque = Z_NULL;
  340.40 +    ret = deflateInit2(strm, state->level, Z_DEFLATED,
  340.41 +                       15 + 16, 8, state->strategy);
  340.42 +    if (ret != Z_OK) {
  340.43 +        free(state->in);
  340.44 +        gz_error(state, Z_MEM_ERROR, "out of memory");
  340.45 +        return -1;
  340.46 +    }
  340.47 +
  340.48 +    /* mark state as initialized */
  340.49 +    state->size = state->want;
  340.50 +
  340.51 +    /* initialize write buffer */
  340.52 +    strm->avail_out = state->size;
  340.53 +    strm->next_out = state->out;
  340.54 +    state->next = strm->next_out;
  340.55 +    return 0;
  340.56 +}
  340.57 +
  340.58 +/* Compress whatever is at avail_in and next_in and write to the output file.
  340.59 +   Return -1 if there is an error writing to the output file, otherwise 0.
  340.60 +   flush is assumed to be a valid deflate() flush value.  If flush is Z_FINISH,
  340.61 +   then the deflate() state is reset to start a new gzip stream. */
  340.62 +local int gz_comp(state, flush)
  340.63 +    gz_statep state;
  340.64 +    int flush;
  340.65 +{
  340.66 +    int ret, got;
  340.67 +    unsigned have;
  340.68 +    z_streamp strm = &(state->strm);
  340.69 +
  340.70 +    /* allocate memory if this is the first time through */
  340.71 +    if (state->size == 0 && gz_init(state) == -1)
  340.72 +        return -1;
  340.73 +
  340.74 +    /* run deflate() on provided input until it produces no more output */
  340.75 +    ret = Z_OK;
  340.76 +    do {
  340.77 +        /* write out current buffer contents if full, or if flushing, but if
  340.78 +           doing Z_FINISH then don't write until we get to Z_STREAM_END */
  340.79 +        if (strm->avail_out == 0 || (flush != Z_NO_FLUSH &&
  340.80 +            (flush != Z_FINISH || ret == Z_STREAM_END))) {
  340.81 +            have = (unsigned)(strm->next_out - state->next);
  340.82 +            if (have && ((got = write(state->fd, state->next, have)) < 0 ||
  340.83 +                         (unsigned)got != have)) {
  340.84 +                gz_error(state, Z_ERRNO, zstrerror());
  340.85 +                return -1;
  340.86 +            }
  340.87 +            if (strm->avail_out == 0) {
  340.88 +                strm->avail_out = state->size;
  340.89 +                strm->next_out = state->out;
  340.90 +            }
  340.91 +            state->next = strm->next_out;
  340.92 +        }
  340.93 +
  340.94 +        /* compress */
  340.95 +        have = strm->avail_out;
  340.96 +        ret = deflate(strm, flush);
  340.97 +        if (ret == Z_STREAM_ERROR) {
  340.98 +            gz_error(state, Z_STREAM_ERROR,
  340.99 +                      "internal error: deflate stream corrupt");
 340.100 +            return -1;
 340.101 +        }
 340.102 +        have -= strm->avail_out;
 340.103 +    } while (have);
 340.104 +
 340.105 +    /* if that completed a deflate stream, allow another to start */
 340.106 +    if (flush == Z_FINISH)
 340.107 +        deflateReset(strm);
 340.108 +
 340.109 +    /* all done, no errors */
 340.110 +    return 0;
 340.111 +}
 340.112 +
 340.113 +/* Compress len zeros to output.  Return -1 on error, 0 on success. */
 340.114 +local int gz_zero(state, len)
 340.115 +    gz_statep state;
 340.116 +    z_off64_t len;
 340.117 +{
 340.118 +    int first;
 340.119 +    unsigned n;
 340.120 +    z_streamp strm = &(state->strm);
 340.121 +
 340.122 +    /* consume whatever's left in the input buffer */
 340.123 +    if (strm->avail_in && gz_comp(state, Z_NO_FLUSH) == -1)
 340.124 +        return -1;
 340.125 +
 340.126 +    /* compress len zeros (len guaranteed > 0) */
 340.127 +    first = 1;
 340.128 +    while (len) {
 340.129 +        n = GT_OFF(state->size) || (z_off64_t)state->size > len ?
 340.130 +            (unsigned)len : state->size;
 340.131 +        if (first) {
 340.132 +            memset(state->in, 0, n);
 340.133 +            first = 0;
 340.134 +        }
 340.135 +        strm->avail_in = n;
 340.136 +        strm->next_in = state->in;
 340.137 +        state->pos += n;
 340.138 +        if (gz_comp(state, Z_NO_FLUSH) == -1)
 340.139 +            return -1;
 340.140 +        len -= n;
 340.141 +    }
 340.142 +    return 0;
 340.143 +}
 340.144 +
 340.145 +/* -- see zlib.h -- */
 340.146 +int ZEXPORT gzwrite(file, buf, len)
 340.147 +    gzFile file;
 340.148 +    voidpc buf;
 340.149 +    unsigned len;
 340.150 +{
 340.151 +    unsigned put = len;
 340.152 +    unsigned n;
 340.153 +    gz_statep state;
 340.154 +    z_streamp strm;
 340.155 +
 340.156 +    /* get internal structure */
 340.157 +    if (file == NULL)
 340.158 +        return 0;
 340.159 +    state = (gz_statep)file;
 340.160 +    strm = &(state->strm);
 340.161 +
 340.162 +    /* check that we're writing and that there's no error */
 340.163 +    if (state->mode != GZ_WRITE || state->err != Z_OK)
 340.164 +        return 0;
 340.165 +
 340.166 +    /* since an int is returned, make sure len fits in one, otherwise return
 340.167 +       with an error (this avoids the flaw in the interface) */
 340.168 +    if ((int)len < 0) {
 340.169 +        gz_error(state, Z_BUF_ERROR, "requested length does not fit in int");
 340.170 +        return 0;
 340.171 +    }
 340.172 +
 340.173 +    /* if len is zero, avoid unnecessary operations */
 340.174 +    if (len == 0)
 340.175 +        return 0;
 340.176 +
 340.177 +    /* allocate memory if this is the first time through */
 340.178 +    if (state->size == 0 && gz_init(state) == -1)
 340.179 +        return 0;
 340.180 +
 340.181 +    /* check for seek request */
 340.182 +    if (state->seek) {
 340.183 +        state->seek = 0;
 340.184 +        if (gz_zero(state, state->skip) == -1)
 340.185 +            return 0;
 340.186 +    }
 340.187 +
 340.188 +    /* for small len, copy to input buffer, otherwise compress directly */
 340.189 +    if (len < state->size) {
 340.190 +        /* copy to input buffer, compress when full */
 340.191 +        do {
 340.192 +            if (strm->avail_in == 0)
 340.193 +                strm->next_in = state->in;
 340.194 +            n = state->size - strm->avail_in;
 340.195 +            if (n > len)
 340.196 +                n = len;
 340.197 +            memcpy(strm->next_in + strm->avail_in, buf, n);
 340.198 +            strm->avail_in += n;
 340.199 +            state->pos += n;
 340.200 +            buf = (char *)buf + n;
 340.201 +            len -= n;
 340.202 +            if (len && gz_comp(state, Z_NO_FLUSH) == -1)
 340.203 +                return 0;
 340.204 +        } while (len);
 340.205 +    }
 340.206 +    else {
 340.207 +        /* consume whatever's left in the input buffer */
 340.208 +        if (strm->avail_in && gz_comp(state, Z_NO_FLUSH) == -1)
 340.209 +            return 0;
 340.210 +
 340.211 +        /* directly compress user buffer to file */
 340.212 +        strm->avail_in = len;
 340.213 +        strm->next_in = (voidp)buf;
 340.214 +        state->pos += len;
 340.215 +        if (gz_comp(state, Z_NO_FLUSH) == -1)
 340.216 +            return 0;
 340.217 +    }
 340.218 +
 340.219 +    /* input was all buffered or compressed (put will fit in int) */
 340.220 +    return (int)put;
 340.221 +}
 340.222 +
 340.223 +/* -- see zlib.h -- */
 340.224 +int ZEXPORT gzputc(file, c)
 340.225 +    gzFile file;
 340.226 +    int c;
 340.227 +{
 340.228 +    unsigned char buf[1];
 340.229 +    gz_statep state;
 340.230 +    z_streamp strm;
 340.231 +
 340.232 +    /* get internal structure */
 340.233 +    if (file == NULL)
 340.234 +        return -1;
 340.235 +    state = (gz_statep)file;
 340.236 +    strm = &(state->strm);
 340.237 +
 340.238 +    /* check that we're writing and that there's no error */
 340.239 +    if (state->mode != GZ_WRITE || state->err != Z_OK)
 340.240 +        return -1;
 340.241 +
 340.242 +    /* check for seek request */
 340.243 +    if (state->seek) {
 340.244 +        state->seek = 0;
 340.245 +        if (gz_zero(state, state->skip) == -1)
 340.246 +            return -1;
 340.247 +    }
 340.248 +
 340.249 +    /* try writing to input buffer for speed (state->size == 0 if buffer not
 340.250 +       initialized) */
 340.251 +    if (strm->avail_in < state->size) {
 340.252 +        if (strm->avail_in == 0)
 340.253 +            strm->next_in = state->in;
 340.254 +        strm->next_in[strm->avail_in++] = c;
 340.255 +        state->pos++;
 340.256 +        return c;
 340.257 +    }
 340.258 +
 340.259 +    /* no room in buffer or not initialized, use gz_write() */
 340.260 +    buf[0] = c;
 340.261 +    if (gzwrite(file, buf, 1) != 1)
 340.262 +        return -1;
 340.263 +    return c;
 340.264 +}
 340.265 +
 340.266 +/* -- see zlib.h -- */
 340.267 +int ZEXPORT gzputs(file, str)
 340.268 +    gzFile file;
 340.269 +    const char *str;
 340.270 +{
 340.271 +    int ret;
 340.272 +    unsigned len;
 340.273 +
 340.274 +    /* write string */
 340.275 +    len = (unsigned)strlen(str);
 340.276 +    ret = gzwrite(file, str, len);
 340.277 +    return ret == 0 && len != 0 ? -1 : ret;
 340.278 +}
 340.279 +
 340.280 +#ifdef STDC
 340.281 +#include <stdarg.h>
 340.282 +
 340.283 +/* -- see zlib.h -- */
 340.284 +int ZEXPORTVA gzprintf (gzFile file, const char *format, ...)
 340.285 +{
 340.286 +    int size, len;
 340.287 +    gz_statep state;
 340.288 +    z_streamp strm;
 340.289 +    va_list va;
 340.290 +
 340.291 +    /* get internal structure */
 340.292 +    if (file == NULL)
 340.293 +        return -1;
 340.294 +    state = (gz_statep)file;
 340.295 +    strm = &(state->strm);
 340.296 +
 340.297 +    /* check that we're writing and that there's no error */
 340.298 +    if (state->mode != GZ_WRITE || state->err != Z_OK)
 340.299 +        return 0;
 340.300 +
 340.301 +    /* make sure we have some buffer space */
 340.302 +    if (state->size == 0 && gz_init(state) == -1)
 340.303 +        return 0;
 340.304 +
 340.305 +    /* check for seek request */
 340.306 +    if (state->seek) {
 340.307 +        state->seek = 0;
 340.308 +        if (gz_zero(state, state->skip) == -1)
 340.309 +            return 0;
 340.310 +    }
 340.311 +
 340.312 +    /* consume whatever's left in the input buffer */
 340.313 +    if (strm->avail_in && gz_comp(state, Z_NO_FLUSH) == -1)
 340.314 +        return 0;
 340.315 +
 340.316 +    /* do the printf() into the input buffer, put length in len */
 340.317 +    size = (int)(state->size);
 340.318 +    state->in[size - 1] = 0;
 340.319 +    va_start(va, format);
 340.320 +#ifdef NO_vsnprintf
 340.321 +#  ifdef HAS_vsprintf_void
 340.322 +    (void)vsprintf(state->in, format, va);
 340.323 +    va_end(va);
 340.324 +    for (len = 0; len < size; len++)
 340.325 +        if (state->in[len] == 0) break;
 340.326 +#  else
 340.327 +    len = vsprintf(state->in, format, va);
 340.328 +    va_end(va);
 340.329 +#  endif
 340.330 +#else
 340.331 +#  ifdef HAS_vsnprintf_void
 340.332 +    (void)vsnprintf(state->in, size, format, va);
 340.333 +    va_end(va);
 340.334 +    len = strlen(state->in);
 340.335 +#  else
 340.336 +    len = vsnprintf((char *)(state->in), size, format, va);
 340.337 +    va_end(va);
 340.338 +#  endif
 340.339 +#endif
 340.340 +
 340.341 +    /* check that printf() results fit in buffer */
 340.342 +    if (len <= 0 || len >= (int)size || state->in[size - 1] != 0)
 340.343 +        return 0;
 340.344 +
 340.345 +    /* update buffer and position, defer compression until needed */
 340.346 +    strm->avail_in = (unsigned)len;
 340.347 +    strm->next_in = state->in;
 340.348 +    state->pos += len;
 340.349 +    return len;
 340.350 +}
 340.351 +
 340.352 +#else /* !STDC */
 340.353 +
 340.354 +/* -- see zlib.h -- */
 340.355 +int ZEXPORTVA gzprintf (file, format, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10,
 340.356 +                       a11, a12, a13, a14, a15, a16, a17, a18, a19, a20)
 340.357 +    gzFile file;
 340.358 +    const char *format;
 340.359 +    int a1, a2, a3, a4, a5, a6, a7, a8, a9, a10,
 340.360 +        a11, a12, a13, a14, a15, a16, a17, a18, a19, a20;
 340.361 +{
 340.362 +    int size, len;
 340.363 +    gz_statep state;
 340.364 +    z_streamp strm;
 340.365 +
 340.366 +    /* get internal structure */
 340.367 +    if (file == NULL)
 340.368 +        return -1;
 340.369 +    state = (gz_statep)file;
 340.370 +    strm = &(state->strm);
 340.371 +
 340.372 +    /* check that we're writing and that there's no error */
 340.373 +    if (state->mode != GZ_WRITE || state->err != Z_OK)
 340.374 +        return 0;
 340.375 +
 340.376 +    /* make sure we have some buffer space */
 340.377 +    if (state->size == 0 && gz_init(state) == -1)
 340.378 +        return 0;
 340.379 +
 340.380 +    /* check for seek request */
 340.381 +    if (state->seek) {
 340.382 +        state->seek = 0;
 340.383 +        if (gz_zero(state, state->skip) == -1)
 340.384 +            return 0;
 340.385 +    }
 340.386 +
 340.387 +    /* consume whatever's left in the input buffer */
 340.388 +    if (strm->avail_in && gz_comp(state, Z_NO_FLUSH) == -1)
 340.389 +        return 0;
 340.390 +
 340.391 +    /* do the printf() into the input buffer, put length in len */
 340.392 +    size = (int)(state->size);
 340.393 +    state->in[size - 1] = 0;
 340.394 +#ifdef NO_snprintf
 340.395 +#  ifdef HAS_sprintf_void
 340.396 +    sprintf(state->in, format, a1, a2, a3, a4, a5, a6, a7, a8,
 340.397 +            a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20);
 340.398 +    for (len = 0; len < size; len++)
 340.399 +        if (state->in[len] == 0) break;
 340.400 +#  else
 340.401 +    len = sprintf(state->in, format, a1, a2, a3, a4, a5, a6, a7, a8,
 340.402 +                a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20);
 340.403 +#  endif
 340.404 +#else
 340.405 +#  ifdef HAS_snprintf_void
 340.406 +    snprintf(state->in, size, format, a1, a2, a3, a4, a5, a6, a7, a8,
 340.407 +             a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20);
 340.408 +    len = strlen(state->in);
 340.409 +#  else
 340.410 +    len = snprintf(state->in, size, format, a1, a2, a3, a4, a5, a6, a7, a8,
 340.411 +                 a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20);
 340.412 +#  endif
 340.413 +#endif
 340.414 +
 340.415 +    /* check that printf() results fit in buffer */
 340.416 +    if (len <= 0 || len >= (int)size || state->in[size - 1] != 0)
 340.417 +        return 0;
 340.418 +
 340.419 +    /* update buffer and position, defer compression until needed */
 340.420 +    strm->avail_in = (unsigned)len;
 340.421 +    strm->next_in = state->in;
 340.422 +    state->pos += len;
 340.423 +    return len;
 340.424 +}
 340.425 +
 340.426 +#endif
 340.427 +
 340.428 +/* -- see zlib.h -- */
 340.429 +int ZEXPORT gzflush(file, flush)
 340.430 +    gzFile file;
 340.431 +    int flush;
 340.432 +{
 340.433 +    gz_statep state;
 340.434 +
 340.435 +    /* get internal structure */
 340.436 +    if (file == NULL)
 340.437 +        return -1;
 340.438 +    state = (gz_statep)file;
 340.439 +
 340.440 +    /* check that we're writing and that there's no error */
 340.441 +    if (state->mode != GZ_WRITE || state->err != Z_OK)
 340.442 +        return Z_STREAM_ERROR;
 340.443 +
 340.444 +    /* check flush parameter */
 340.445 +    if (flush < 0 || flush > Z_FINISH)
 340.446 +        return Z_STREAM_ERROR;
 340.447 +
 340.448 +    /* check for seek request */
 340.449 +    if (state->seek) {
 340.450 +        state->seek = 0;
 340.451 +        if (gz_zero(state, state->skip) == -1)
 340.452 +            return -1;
 340.453 +    }
 340.454 +
 340.455 +    /* compress remaining data with requested flush */
 340.456 +    gz_comp(state, flush);
 340.457 +    return state->err;
 340.458 +}
 340.459 +
 340.460 +/* -- see zlib.h -- */
 340.461 +int ZEXPORT gzsetparams(file, level, strategy)
 340.462 +    gzFile file;
 340.463 +    int level;
 340.464 +    int strategy;
 340.465 +{
 340.466 +    gz_statep state;
 340.467 +    z_streamp strm;
 340.468 +
 340.469 +    /* get internal structure */
 340.470 +    if (file == NULL)
 340.471 +        return Z_STREAM_ERROR;
 340.472 +    state = (gz_statep)file;
 340.473 +    strm = &(state->strm);
 340.474 +
 340.475 +    /* check that we're writing and that there's no error */
 340.476 +    if (state->mode != GZ_WRITE || state->err != Z_OK)
 340.477 +        return Z_STREAM_ERROR;
 340.478 +
 340.479 +    /* if no change is requested, then do nothing */
 340.480 +    if (level == state->level && strategy == state->strategy)
 340.481 +        return Z_OK;
 340.482 +
 340.483 +    /* check for seek request */
 340.484 +    if (state->seek) {
 340.485 +        state->seek = 0;
 340.486 +        if (gz_zero(state, state->skip) == -1)
 340.487 +            return -1;
 340.488 +    }
 340.489 +
 340.490 +    /* change compression parameters for subsequent input */
 340.491 +    if (state->size) {
 340.492 +        /* flush previous input with previous parameters before changing */
 340.493 +        if (strm->avail_in && gz_comp(state, Z_PARTIAL_FLUSH) == -1)
 340.494 +            return state->err;
 340.495 +        deflateParams(strm, level, strategy);
 340.496 +    }
 340.497 +    state->level = level;
 340.498 +    state->strategy = strategy;
 340.499 +    return Z_OK;
 340.500 +}
 340.501 +
 340.502 +/* -- see zlib.h -- */
 340.503 +int ZEXPORT gzclose_w(file)
 340.504 +    gzFile file;
 340.505 +{
 340.506 +    int ret = 0;
 340.507 +    gz_statep state;
 340.508 +
 340.509 +    /* get internal structure */
 340.510 +    if (file == NULL)
 340.511 +        return Z_STREAM_ERROR;
 340.512 +    state = (gz_statep)file;
 340.513 +
 340.514 +    /* check that we're writing */
 340.515 +    if (state->mode != GZ_WRITE)
 340.516 +        return Z_STREAM_ERROR;
 340.517 +
 340.518 +    /* check for seek request */
 340.519 +    if (state->seek) {
 340.520 +        state->seek = 0;
 340.521 +        ret += gz_zero(state, state->skip);
 340.522 +    }
 340.523 +
 340.524 +    /* flush, free memory, and close file */
 340.525 +    ret += gz_comp(state, Z_FINISH);
 340.526 +    (void)deflateEnd(&(state->strm));
 340.527 +    free(state->out);
 340.528 +    free(state->in);
 340.529 +    gz_error(state, Z_OK, NULL);
 340.530 +    free(state->path);
 340.531 +    ret += close(state->fd);
 340.532 +    free(state);
 340.533 +    return ret ? Z_ERRNO : Z_OK;
 340.534 +}
   341.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
   341.2 +++ b/deps/glpk/src/zlib/infback.c	Sun Nov 06 20:59:10 2011 +0100
   341.3 @@ -0,0 +1,632 @@
   341.4 +/* infback.c -- inflate using a call-back interface
   341.5 + * Copyright (C) 1995-2009 Mark Adler
   341.6 + * For conditions of distribution and use, see copyright notice in zlib.h
   341.7 + */
   341.8 +
   341.9 +/*
  341.10 +   This code is largely copied from inflate.c.  Normally either infback.o or
  341.11 +   inflate.o would be linked into an application--not both.  The interface
  341.12 +   with inffast.c is retained so that optimized assembler-coded versions of
  341.13 +   inflate_fast() can be used with either inflate.c or infback.c.
  341.14 + */
  341.15 +
  341.16 +#include "zutil.h"
  341.17 +#include "inftrees.h"
  341.18 +#include "inflate.h"
  341.19 +#include "inffast.h"
  341.20 +
  341.21 +/* function prototypes */
  341.22 +local void fixedtables OF((struct inflate_state FAR *state));
  341.23 +
  341.24 +/*
  341.25 +   strm provides memory allocation functions in zalloc and zfree, or
  341.26 +   Z_NULL to use the library memory allocation functions.
  341.27 +
  341.28 +   windowBits is in the range 8..15, and window is a user-supplied
  341.29 +   window and output buffer that is 2**windowBits bytes.
  341.30 + */
  341.31 +int ZEXPORT inflateBackInit_(strm, windowBits, window, version, stream_size)
  341.32 +z_streamp strm;
  341.33 +int windowBits;
  341.34 +unsigned char FAR *window;
  341.35 +const char *version;
  341.36 +int stream_size;
  341.37 +{
  341.38 +    struct inflate_state FAR *state;
  341.39 +
  341.40 +    if (version == Z_NULL || version[0] != ZLIB_VERSION[0] ||
  341.41 +        stream_size != (int)(sizeof(z_stream)))
  341.42 +        return Z_VERSION_ERROR;
  341.43 +    if (strm == Z_NULL || window == Z_NULL ||
  341.44 +        windowBits < 8 || windowBits > 15)
  341.45 +        return Z_STREAM_ERROR;
  341.46 +    strm->msg = Z_NULL;                 /* in case we return an error */
  341.47 +    if (strm->zalloc == (alloc_func)0) {
  341.48 +        strm->zalloc = zcalloc;
  341.49 +        strm->opaque = (voidpf)0;
  341.50 +    }
  341.51 +    if (strm->zfree == (free_func)0) strm->zfree = zcfree;
  341.52 +    state = (struct inflate_state FAR *)ZALLOC(strm, 1,
  341.53 +                                               sizeof(struct inflate_state));
  341.54 +    if (state == Z_NULL) return Z_MEM_ERROR;
  341.55 +    Tracev((stderr, "inflate: allocated\n"));
  341.56 +    strm->state = (struct internal_state FAR *)state;
  341.57 +    state->dmax = 32768U;
  341.58 +    state->wbits = windowBits;
  341.59 +    state->wsize = 1U << windowBits;
  341.60 +    state->window = window;
  341.61 +    state->wnext = 0;
  341.62 +    state->whave = 0;
  341.63 +    return Z_OK;
  341.64 +}
  341.65 +
  341.66 +/*
  341.67 +   Return state with length and distance decoding tables and index sizes set to
  341.68 +   fixed code decoding.  Normally this returns fixed tables from inffixed.h.
  341.69 +   If BUILDFIXED is defined, then instead this routine builds the tables the
  341.70 +   first time it's called, and returns those tables the first time and
  341.71 +   thereafter.  This reduces the size of the code by about 2K bytes, in
  341.72 +   exchange for a little execution time.  However, BUILDFIXED should not be
  341.73 +   used for threaded applications, since the rewriting of the tables and virgin
  341.74 +   may not be thread-safe.
  341.75 + */
  341.76 +local void fixedtables(state)
  341.77 +struct inflate_state FAR *state;
  341.78 +{
  341.79 +#ifdef BUILDFIXED
  341.80 +    static int virgin = 1;
  341.81 +    static code *lenfix, *distfix;
  341.82 +    static code fixed[544];
  341.83 +
  341.84 +    /* build fixed huffman tables if first call (may not be thread safe) */
  341.85 +    if (virgin) {
  341.86 +        unsigned sym, bits;
  341.87 +        static code *next;
  341.88 +
  341.89 +        /* literal/length table */
  341.90 +        sym = 0;
  341.91 +        while (sym < 144) state->lens[sym++] = 8;
  341.92 +        while (sym < 256) state->lens[sym++] = 9;
  341.93 +        while (sym < 280) state->lens[sym++] = 7;
  341.94 +        while (sym < 288) state->lens[sym++] = 8;
  341.95 +        next = fixed;
  341.96 +        lenfix = next;
  341.97 +        bits = 9;
  341.98 +        inflate_table(LENS, state->lens, 288, &(next), &(bits), state->work);
  341.99 +
 341.100 +        /* distance table */
 341.101 +        sym = 0;
 341.102 +        while (sym < 32) state->lens[sym++] = 5;
 341.103 +        distfix = next;
 341.104 +        bits = 5;
 341.105 +        inflate_table(DISTS, state->lens, 32, &(next), &(bits), state->work);
 341.106 +
 341.107 +        /* do this just once */
 341.108 +        virgin = 0;
 341.109 +    }
 341.110 +#else /* !BUILDFIXED */
 341.111 +#   include "inffixed.h"
 341.112 +#endif /* BUILDFIXED */
 341.113 +    state->lencode = lenfix;
 341.114 +    state->lenbits = 9;
 341.115 +    state->distcode = distfix;
 341.116 +    state->distbits = 5;
 341.117 +}
 341.118 +
 341.119 +/* Macros for inflateBack(): */
 341.120 +
 341.121 +/* Load returned state from inflate_fast() */
 341.122 +#define LOAD() \
 341.123 +    do { \
 341.124 +        put = strm->next_out; \
 341.125 +        left = strm->avail_out; \
 341.126 +        next = strm->next_in; \
 341.127 +        have = strm->avail_in; \
 341.128 +        hold = state->hold; \
 341.129 +        bits = state->bits; \
 341.130 +    } while (0)
 341.131 +
 341.132 +/* Set state from registers for inflate_fast() */
 341.133 +#define RESTORE() \
 341.134 +    do { \
 341.135 +        strm->next_out = put; \
 341.136 +        strm->avail_out = left; \
 341.137 +        strm->next_in = next; \
 341.138 +        strm->avail_in = have; \
 341.139 +        state->hold = hold; \
 341.140 +        state->bits = bits; \
 341.141 +    } while (0)
 341.142 +
 341.143 +/* Clear the input bit accumulator */
 341.144 +#define INITBITS() \
 341.145 +    do { \
 341.146 +        hold = 0; \
 341.147 +        bits = 0; \
 341.148 +    } while (0)
 341.149 +
 341.150 +/* Assure that some input is available.  If input is requested, but denied,
 341.151 +   then return a Z_BUF_ERROR from inflateBack(). */
 341.152 +#define PULL() \
 341.153 +    do { \
 341.154 +        if (have == 0) { \
 341.155 +            have = in(in_desc, &next); \
 341.156 +            if (have == 0) { \
 341.157 +                next = Z_NULL; \
 341.158 +                ret = Z_BUF_ERROR; \
 341.159 +                goto inf_leave; \
 341.160 +            } \
 341.161 +        } \
 341.162 +    } while (0)
 341.163 +
 341.164 +/* Get a byte of input into the bit accumulator, or return from inflateBack()
 341.165 +   with an error if there is no input available. */
 341.166 +#define PULLBYTE() \
 341.167 +    do { \
 341.168 +        PULL(); \
 341.169 +        have--; \
 341.170 +        hold += (unsigned long)(*next++) << bits; \
 341.171 +        bits += 8; \
 341.172 +    } while (0)
 341.173 +
 341.174 +/* Assure that there are at least n bits in the bit accumulator.  If there is
 341.175 +   not enough available input to do that, then return from inflateBack() with
 341.176 +   an error. */
 341.177 +#define NEEDBITS(n) \
 341.178 +    do { \
 341.179 +        while (bits < (unsigned)(n)) \
 341.180 +            PULLBYTE(); \
 341.181 +    } while (0)
 341.182 +
 341.183 +/* Return the low n bits of the bit accumulator (n < 16) */
 341.184 +#define BITS(n) \
 341.185 +    ((unsigned)hold & ((1U << (n)) - 1))
 341.186 +
 341.187 +/* Remove n bits from the bit accumulator */
 341.188 +#define DROPBITS(n) \
 341.189 +    do { \
 341.190 +        hold >>= (n); \
 341.191 +        bits -= (unsigned)(n); \
 341.192 +    } while (0)
 341.193 +
 341.194 +/* Remove zero to seven bits as needed to go to a byte boundary */
 341.195 +#define BYTEBITS() \
 341.196 +    do { \
 341.197 +        hold >>= bits & 7; \
 341.198 +        bits -= bits & 7; \
 341.199 +    } while (0)
 341.200 +
 341.201 +/* Assure that some output space is available, by writing out the window
 341.202 +   if it's full.  If the write fails, return from inflateBack() with a
 341.203 +   Z_BUF_ERROR. */
 341.204 +#define ROOM() \
 341.205 +    do { \
 341.206 +        if (left == 0) { \
 341.207 +            put = state->window; \
 341.208 +            left = state->wsize; \
 341.209 +            state->whave = left; \
 341.210 +            if (out(out_desc, put, left)) { \
 341.211 +                ret = Z_BUF_ERROR; \
 341.212 +                goto inf_leave; \
 341.213 +            } \
 341.214 +        } \
 341.215 +    } while (0)
 341.216 +
 341.217 +/*
 341.218 +   strm provides the memory allocation functions and window buffer on input,
 341.219 +   and provides information on the unused input on return.  For Z_DATA_ERROR
 341.220 +   returns, strm will also provide an error message.
 341.221 +
 341.222 +   in() and out() are the call-back input and output functions.  When
 341.223 +   inflateBack() needs more input, it calls in().  When inflateBack() has
 341.224 +   filled the window with output, or when it completes with data in the
 341.225 +   window, it calls out() to write out the data.  The application must not
 341.226 +   change the provided input until in() is called again or inflateBack()
 341.227 +   returns.  The application must not change the window/output buffer until
 341.228 +   inflateBack() returns.
 341.229 +
 341.230 +   in() and out() are called with a descriptor parameter provided in the
 341.231 +   inflateBack() call.  This parameter can be a structure that provides the
 341.232 +   information required to do the read or write, as well as accumulated
 341.233 +   information on the input and output such as totals and check values.
 341.234 +
 341.235 +   in() should return zero on failure.  out() should return non-zero on
 341.236 +   failure.  If either in() or out() fails, than inflateBack() returns a
 341.237 +   Z_BUF_ERROR.  strm->next_in can be checked for Z_NULL to see whether it
 341.238 +   was in() or out() that caused in the error.  Otherwise,  inflateBack()
 341.239 +   returns Z_STREAM_END on success, Z_DATA_ERROR for an deflate format
 341.240 +   error, or Z_MEM_ERROR if it could not allocate memory for the state.
 341.241 +   inflateBack() can also return Z_STREAM_ERROR if the input parameters
 341.242 +   are not correct, i.e. strm is Z_NULL or the state was not initialized.
 341.243 + */
 341.244 +int ZEXPORT inflateBack(strm, in, in_desc, out, out_desc)
 341.245 +z_streamp strm;
 341.246 +in_func in;
 341.247 +void FAR *in_desc;
 341.248 +out_func out;
 341.249 +void FAR *out_desc;
 341.250 +{
 341.251 +    struct inflate_state FAR *state;
 341.252 +    unsigned char FAR *next;    /* next input */
 341.253 +    unsigned char FAR *put;     /* next output */
 341.254 +    unsigned have, left;        /* available input and output */
 341.255 +    unsigned long hold;         /* bit buffer */
 341.256 +    unsigned bits;              /* bits in bit buffer */
 341.257 +    unsigned copy;              /* number of stored or match bytes to copy */
 341.258 +    unsigned char FAR *from;    /* where to copy match bytes from */
 341.259 +    code here;                  /* current decoding table entry */
 341.260 +    code last;                  /* parent table entry */
 341.261 +    unsigned len;               /* length to copy for repeats, bits to drop */
 341.262 +    int ret;                    /* return code */
 341.263 +    static const unsigned short order[19] = /* permutation of code lengths */
 341.264 +        {16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15};
 341.265 +
 341.266 +    /* Check that the strm exists and that the state was initialized */
 341.267 +    if (strm == Z_NULL || strm->state == Z_NULL)
 341.268 +        return Z_STREAM_ERROR;
 341.269 +    state = (struct inflate_state FAR *)strm->state;
 341.270 +
 341.271 +    /* Reset the state */
 341.272 +    strm->msg = Z_NULL;
 341.273 +    state->mode = TYPE;
 341.274 +    state->last = 0;
 341.275 +    state->whave = 0;
 341.276 +    next = strm->next_in;
 341.277 +    have = next != Z_NULL ? strm->avail_in : 0;
 341.278 +    hold = 0;
 341.279 +    bits = 0;
 341.280 +    put = state->window;
 341.281 +    left = state->wsize;
 341.282 +
 341.283 +    /* Inflate until end of block marked as last */
 341.284 +    for (;;)
 341.285 +        switch (state->mode) {
 341.286 +        case TYPE:
 341.287 +            /* determine and dispatch block type */
 341.288 +            if (state->last) {
 341.289 +                BYTEBITS();
 341.290 +                state->mode = DONE;
 341.291 +                break;
 341.292 +            }
 341.293 +            NEEDBITS(3);
 341.294 +            state->last = BITS(1);
 341.295 +            DROPBITS(1);
 341.296 +            switch (BITS(2)) {
 341.297 +            case 0:                             /* stored block */
 341.298 +                Tracev((stderr, "inflate:     stored block%s\n",
 341.299 +                        state->last ? " (last)" : ""));
 341.300 +                state->mode = STORED;
 341.301 +                break;
 341.302 +            case 1:                             /* fixed block */
 341.303 +                fixedtables(state);
 341.304 +                Tracev((stderr, "inflate:     fixed codes block%s\n",
 341.305 +                        state->last ? " (last)" : ""));
 341.306 +                state->mode = LEN;              /* decode codes */
 341.307 +                break;
 341.308 +            case 2:                             /* dynamic block */
 341.309 +                Tracev((stderr, "inflate:     dynamic codes block%s\n",
 341.310 +                        state->last ? " (last)" : ""));
 341.311 +                state->mode = TABLE;
 341.312 +                break;
 341.313 +            case 3:
 341.314 +                strm->msg = (char *)"invalid block type";
 341.315 +                state->mode = BAD;
 341.316 +            }
 341.317 +            DROPBITS(2);
 341.318 +            break;
 341.319 +
 341.320 +        case STORED:
 341.321 +            /* get and verify stored block length */
 341.322 +            BYTEBITS();                         /* go to byte boundary */
 341.323 +            NEEDBITS(32);
 341.324 +            if ((hold & 0xffff) != ((hold >> 16) ^ 0xffff)) {
 341.325 +                strm->msg = (char *)"invalid stored block lengths";
 341.326 +                state->mode = BAD;
 341.327 +                break;
 341.328 +            }
 341.329 +            state->length = (unsigned)hold & 0xffff;
 341.330 +            Tracev((stderr, "inflate:       stored length %u\n",
 341.331 +                    state->length));
 341.332 +            INITBITS();
 341.333 +
 341.334 +            /* copy stored block from input to output */
 341.335 +            while (state->length != 0) {
 341.336 +                copy = state->length;
 341.337 +                PULL();
 341.338 +                ROOM();
 341.339 +                if (copy > have) copy = have;
 341.340 +                if (copy > left) copy = left;
 341.341 +                zmemcpy(put, next, copy);
 341.342 +                have -= copy;
 341.343 +                next += copy;
 341.344 +                left -= copy;
 341.345 +                put += copy;
 341.346 +                state->length -= copy;
 341.347 +            }
 341.348 +            Tracev((stderr, "inflate:       stored end\n"));
 341.349 +            state->mode = TYPE;
 341.350 +            break;
 341.351 +
 341.352 +        case TABLE:
 341.353 +            /* get dynamic table entries descriptor */
 341.354 +            NEEDBITS(14);
 341.355 +            state->nlen = BITS(5) + 257;
 341.356 +            DROPBITS(5);
 341.357 +            state->ndist = BITS(5) + 1;
 341.358 +            DROPBITS(5);
 341.359 +            state->ncode = BITS(4) + 4;
 341.360 +            DROPBITS(4);
 341.361 +#ifndef PKZIP_BUG_WORKAROUND
 341.362 +            if (state->nlen > 286 || state->ndist > 30) {
 341.363 +                strm->msg = (char *)"too many length or distance symbols";
 341.364 +                state->mode = BAD;
 341.365 +                break;
 341.366 +            }
 341.367 +#endif
 341.368 +            Tracev((stderr, "inflate:       table sizes ok\n"));
 341.369 +
 341.370 +            /* get code length code lengths (not a typo) */
 341.371 +            state->have = 0;
 341.372 +            while (state->have < state->ncode) {
 341.373 +                NEEDBITS(3);
 341.374 +                state->lens[order[state->have++]] = (unsigned short)BITS(3);
 341.375 +                DROPBITS(3);
 341.376 +            }
 341.377 +            while (state->have < 19)
 341.378 +                state->lens[order[state->have++]] = 0;
 341.379 +            state->next = state->codes;
 341.380 +            state->lencode = (code const FAR *)(state->next);
 341.381 +            state->lenbits = 7;
 341.382 +            ret = inflate_table(CODES, state->lens, 19, &(state->next),
 341.383 +                                &(state->lenbits), state->work);
 341.384 +            if (ret) {
 341.385 +                strm->msg = (char *)"invalid code lengths set";
 341.386 +                state->mode = BAD;
 341.387 +                break;
 341.388 +            }
 341.389 +            Tracev((stderr, "inflate:       code lengths ok\n"));
 341.390 +
 341.391 +            /* get length and distance code code lengths */
 341.392 +            state->have = 0;
 341.393 +            while (state->have < state->nlen + state->ndist) {
 341.394 +                for (;;) {
 341.395 +                    here = state->lencode[BITS(state->lenbits)];
 341.396 +                    if ((unsigned)(here.bits) <= bits) break;
 341.397 +                    PULLBYTE();
 341.398 +                }
 341.399 +                if (here.val < 16) {
 341.400 +                    NEEDBITS(here.bits);
 341.401 +                    DROPBITS(here.bits);
 341.402 +                    state->lens[state->have++] = here.val;
 341.403 +                }
 341.404 +                else {
 341.405 +                    if (here.val == 16) {
 341.406 +                        NEEDBITS(here.bits + 2);
 341.407 +                        DROPBITS(here.bits);
 341.408 +                        if (state->have == 0) {
 341.409 +                            strm->msg = (char *)"invalid bit length repeat";
 341.410 +                            state->mode = BAD;
 341.411 +                            break;
 341.412 +                        }
 341.413 +                        len = (unsigned)(state->lens[state->have - 1]);
 341.414 +                        copy = 3 + BITS(2);
 341.415 +                        DROPBITS(2);
 341.416 +                    }
 341.417 +                    else if (here.val == 17) {
 341.418 +                        NEEDBITS(here.bits + 3);
 341.419 +                        DROPBITS(here.bits);
 341.420 +                        len = 0;
 341.421 +                        copy = 3 + BITS(3);
 341.422 +                        DROPBITS(3);
 341.423 +                    }
 341.424 +                    else {
 341.425 +                        NEEDBITS(here.bits + 7);
 341.426 +                        DROPBITS(here.bits);
 341.427 +                        len = 0;
 341.428 +                        copy = 11 + BITS(7);
 341.429 +                        DROPBITS(7);
 341.430 +                    }
 341.431 +                    if (state->have + copy > state->nlen + state->ndist) {
 341.432 +                        strm->msg = (char *)"invalid bit length repeat";
 341.433 +                        state->mode = BAD;
 341.434 +                        break;
 341.435 +                    }
 341.436 +                    while (copy--)
 341.437 +                        state->lens[state->have++] = (unsigned short)len;
 341.438 +                }
 341.439 +            }
 341.440 +
 341.441 +            /* handle error breaks in while */
 341.442 +            if (state->mode == BAD) break;
 341.443 +
 341.444 +            /* check for end-of-block code (better have one) */
 341.445 +            if (state->lens[256] == 0) {
 341.446 +                strm->msg = (char *)"invalid code -- missing end-of-block";
 341.447 +                state->mode = BAD;
 341.448 +                break;
 341.449 +            }
 341.450 +
 341.451 +            /* build code tables -- note: do not change the lenbits or distbits
 341.452 +               values here (9 and 6) without reading the comments in inftrees.h
 341.453 +               concerning the ENOUGH constants, which depend on those values */
 341.454 +            state->next = state->codes;
 341.455 +            state->lencode = (code const FAR *)(state->next);
 341.456 +            state->lenbits = 9;
 341.457 +            ret = inflate_table(LENS, state->lens, state->nlen, &(state->next),
 341.458 +                                &(state->lenbits), state->work);
 341.459 +            if (ret) {
 341.460 +                strm->msg = (char *)"invalid literal/lengths set";
 341.461 +                state->mode = BAD;
 341.462 +                break;
 341.463 +            }
 341.464 +            state->distcode = (code const FAR *)(state->next);
 341.465 +            state->distbits = 6;
 341.466 +            ret = inflate_table(DISTS, state->lens + state->nlen, state->ndist,
 341.467 +                            &(state->next), &(state->distbits), state->work);
 341.468 +            if (ret) {
 341.469 +                strm->msg = (char *)"invalid distances set";
 341.470 +                state->mode = BAD;
 341.471 +                break;
 341.472 +            }
 341.473 +            Tracev((stderr, "inflate:       codes ok\n"));
 341.474 +            state->mode = LEN;
 341.475 +
 341.476 +        case LEN:
 341.477 +            /* use inflate_fast() if we have enough input and output */
 341.478 +            if (have >= 6 && left >= 258) {
 341.479 +                RESTORE();
 341.480 +                if (state->whave < state->wsize)
 341.481 +                    state->whave = state->wsize - left;
 341.482 +                inflate_fast(strm, state->wsize);
 341.483 +                LOAD();
 341.484 +                break;
 341.485 +            }
 341.486 +
 341.487 +            /* get a literal, length, or end-of-block code */
 341.488 +            for (;;) {
 341.489 +                here = state->lencode[BITS(state->lenbits)];
 341.490 +                if ((unsigned)(here.bits) <= bits) break;
 341.491 +                PULLBYTE();
 341.492 +            }
 341.493 +            if (here.op && (here.op & 0xf0) == 0) {
 341.494 +                last = here;
 341.495 +                for (;;) {
 341.496 +                    here = state->lencode[last.val +
 341.497 +                            (BITS(last.bits + last.op) >> last.bits)];
 341.498 +                    if ((unsigned)(last.bits + here.bits) <= bits) break;
 341.499 +                    PULLBYTE();
 341.500 +                }
 341.501 +                DROPBITS(last.bits);
 341.502 +            }
 341.503 +            DROPBITS(here.bits);
 341.504 +            state->length = (unsigned)here.val;
 341.505 +
 341.506 +            /* process literal */
 341.507 +            if (here.op == 0) {
 341.508 +                Tracevv((stderr, here.val >= 0x20 && here.val < 0x7f ?
 341.509 +                        "inflate:         literal '%c'\n" :
 341.510 +                        "inflate:         literal 0x%02x\n", here.val));
 341.511 +                ROOM();
 341.512 +                *put++ = (unsigned char)(state->length);
 341.513 +                left--;
 341.514 +                state->mode = LEN;
 341.515 +                break;
 341.516 +            }
 341.517 +
 341.518 +            /* process end of block */
 341.519 +            if (here.op & 32) {
 341.520 +                Tracevv((stderr, "inflate:         end of block\n"));
 341.521 +                state->mode = TYPE;
 341.522 +                break;
 341.523 +            }
 341.524 +
 341.525 +            /* invalid code */
 341.526 +            if (here.op & 64) {
 341.527 +                strm->msg = (char *)"invalid literal/length code";
 341.528 +                state->mode = BAD;
 341.529 +                break;
 341.530 +            }
 341.531 +
 341.532 +            /* length code -- get extra bits, if any */
 341.533 +            state->extra = (unsigned)(here.op) & 15;
 341.534 +            if (state->extra != 0) {
 341.535 +                NEEDBITS(state->extra);
 341.536 +                state->length += BITS(state->extra);
 341.537 +                DROPBITS(state->extra);
 341.538 +            }
 341.539 +            Tracevv((stderr, "inflate:         length %u\n", state->length));
 341.540 +
 341.541 +            /* get distance code */
 341.542 +            for (;;) {
 341.543 +                here = state->distcode[BITS(state->distbits)];
 341.544 +                if ((unsigned)(here.bits) <= bits) break;
 341.545 +                PULLBYTE();
 341.546 +            }
 341.547 +            if ((here.op & 0xf0) == 0) {
 341.548 +                last = here;
 341.549 +                for (;;) {
 341.550 +                    here = state->distcode[last.val +
 341.551 +                            (BITS(last.bits + last.op) >> last.bits)];
 341.552 +                    if ((unsigned)(last.bits + here.bits) <= bits) break;
 341.553 +                    PULLBYTE();
 341.554 +                }
 341.555 +                DROPBITS(last.bits);
 341.556 +            }
 341.557 +            DROPBITS(here.bits);
 341.558 +            if (here.op & 64) {
 341.559 +                strm->msg = (char *)"invalid distance code";
 341.560 +                state->mode = BAD;
 341.561 +                break;
 341.562 +            }
 341.563 +            state->offset = (unsigned)here.val;
 341.564 +
 341.565 +            /* get distance extra bits, if any */
 341.566 +            state->extra = (unsigned)(here.op) & 15;
 341.567 +            if (state->extra != 0) {
 341.568 +                NEEDBITS(state->extra);
 341.569 +                state->offset += BITS(state->extra);
 341.570 +                DROPBITS(state->extra);
 341.571 +            }
 341.572 +            if (state->offset > state->wsize - (state->whave < state->wsize ?
 341.573 +                                                left : 0)) {
 341.574 +                strm->msg = (char *)"invalid distance too far back";
 341.575 +                state->mode = BAD;
 341.576 +                break;
 341.577 +            }
 341.578 +            Tracevv((stderr, "inflate:         distance %u\n", state->offset));
 341.579 +
 341.580 +            /* copy match from window to output */
 341.581 +            do {
 341.582 +                ROOM();
 341.583 +                copy = state->wsize - state->offset;
 341.584 +                if (copy < left) {
 341.585 +                    from = put + copy;
 341.586 +                    copy = left - copy;
 341.587 +                }
 341.588 +                else {
 341.589 +                    from = put - state->offset;
 341.590 +                    copy = left;
 341.591 +                }
 341.592 +                if (copy > state->length) copy = state->length;
 341.593 +                state->length -= copy;
 341.594 +                left -= copy;
 341.595 +                do {
 341.596 +                    *put++ = *from++;
 341.597 +                } while (--copy);
 341.598 +            } while (state->length != 0);
 341.599 +            break;
 341.600 +
 341.601 +        case DONE:
 341.602 +            /* inflate stream terminated properly -- write leftover output */
 341.603 +            ret = Z_STREAM_END;
 341.604 +            if (left < state->wsize) {
 341.605 +                if (out(out_desc, state->window, state->wsize - left))
 341.606 +                    ret = Z_BUF_ERROR;
 341.607 +            }
 341.608 +            goto inf_leave;
 341.609 +
 341.610 +        case BAD:
 341.611 +            ret = Z_DATA_ERROR;
 341.612 +            goto inf_leave;
 341.613 +
 341.614 +        default:                /* can't happen, but makes compilers happy */
 341.615 +            ret = Z_STREAM_ERROR;
 341.616 +            goto inf_leave;
 341.617 +        }
 341.618 +
 341.619 +    /* Return unused input */
 341.620 +  inf_leave:
 341.621 +    strm->next_in = next;
 341.622 +    strm->avail_in = have;
 341.623 +    return ret;
 341.624 +}
 341.625 +
 341.626 +int ZEXPORT inflateBackEnd(strm)
 341.627 +z_streamp strm;
 341.628 +{
 341.629 +    if (strm == Z_NULL || strm->state == Z_NULL || strm->zfree == (free_func)0)
 341.630 +        return Z_STREAM_ERROR;
 341.631 +    ZFREE(strm, strm->state);
 341.632 +    strm->state = Z_NULL;
 341.633 +    Tracev((stderr, "inflate: end\n"));
 341.634 +    return Z_OK;
 341.635 +}
   342.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
   342.2 +++ b/deps/glpk/src/zlib/inffast.c	Sun Nov 06 20:59:10 2011 +0100
   342.3 @@ -0,0 +1,340 @@
   342.4 +/* inffast.c -- fast decoding
   342.5 + * Copyright (C) 1995-2008, 2010 Mark Adler
   342.6 + * For conditions of distribution and use, see copyright notice in zlib.h
   342.7 + */
   342.8 +
   342.9 +#include "zutil.h"
  342.10 +#include "inftrees.h"
  342.11 +#include "inflate.h"
  342.12 +#include "inffast.h"
  342.13 +
  342.14 +#ifndef ASMINF
  342.15 +
  342.16 +/* Allow machine dependent optimization for post-increment or pre-increment.
  342.17 +   Based on testing to date,
  342.18 +   Pre-increment preferred for:
  342.19 +   - PowerPC G3 (Adler)
  342.20 +   - MIPS R5000 (Randers-Pehrson)
  342.21 +   Post-increment preferred for:
  342.22 +   - none
  342.23 +   No measurable difference:
  342.24 +   - Pentium III (Anderson)
  342.25 +   - M68060 (Nikl)
  342.26 + */
  342.27 +#ifdef POSTINC
  342.28 +#  define OFF 0
  342.29 +#  define PUP(a) *(a)++
  342.30 +#else
  342.31 +#  define OFF 1
  342.32 +#  define PUP(a) *++(a)
  342.33 +#endif
  342.34 +
  342.35 +/*
  342.36 +   Decode literal, length, and distance codes and write out the resulting
  342.37 +   literal and match bytes until either not enough input or output is
  342.38 +   available, an end-of-block is encountered, or a data error is encountered.
  342.39 +   When large enough input and output buffers are supplied to inflate(), for
  342.40 +   example, a 16K input buffer and a 64K output buffer, more than 95% of the
  342.41 +   inflate execution time is spent in this routine.
  342.42 +
  342.43 +   Entry assumptions:
  342.44 +
  342.45 +        state->mode == LEN
  342.46 +        strm->avail_in >= 6
  342.47 +        strm->avail_out >= 258
  342.48 +        start >= strm->avail_out
  342.49 +        state->bits < 8
  342.50 +
  342.51 +   On return, state->mode is one of:
  342.52 +
  342.53 +        LEN -- ran out of enough output space or enough available input
  342.54 +        TYPE -- reached end of block code, inflate() to interpret next block
  342.55 +        BAD -- error in block data
  342.56 +
  342.57 +   Notes:
  342.58 +
  342.59 +    - The maximum input bits used by a length/distance pair is 15 bits for the
  342.60 +      length code, 5 bits for the length extra, 15 bits for the distance code,
  342.61 +      and 13 bits for the distance extra.  This totals 48 bits, or six bytes.
  342.62 +      Therefore if strm->avail_in >= 6, then there is enough input to avoid
  342.63 +      checking for available input while decoding.
  342.64 +
  342.65 +    - The maximum bytes that a single length/distance pair can output is 258
  342.66 +      bytes, which is the maximum length that can be coded.  inflate_fast()
  342.67 +      requires strm->avail_out >= 258 for each loop to avoid checking for
  342.68 +      output space.
  342.69 + */
  342.70 +void ZLIB_INTERNAL inflate_fast(strm, start)
  342.71 +z_streamp strm;
  342.72 +unsigned start;         /* inflate()'s starting value for strm->avail_out */
  342.73 +{
  342.74 +    struct inflate_state FAR *state;
  342.75 +    unsigned char FAR *in;      /* local strm->next_in */
  342.76 +    unsigned char FAR *last;    /* while in < last, enough input available */
  342.77 +    unsigned char FAR *out;     /* local strm->next_out */
  342.78 +    unsigned char FAR *beg;     /* inflate()'s initial strm->next_out */
  342.79 +    unsigned char FAR *end;     /* while out < end, enough space available */
  342.80 +#ifdef INFLATE_STRICT
  342.81 +    unsigned dmax;              /* maximum distance from zlib header */
  342.82 +#endif
  342.83 +    unsigned wsize;             /* window size or zero if not using window */
  342.84 +    unsigned whave;             /* valid bytes in the window */
  342.85 +    unsigned wnext;             /* window write index */
  342.86 +    unsigned char FAR *window;  /* allocated sliding window, if wsize != 0 */
  342.87 +    unsigned long hold;         /* local strm->hold */
  342.88 +    unsigned bits;              /* local strm->bits */
  342.89 +    code const FAR *lcode;      /* local strm->lencode */
  342.90 +    code const FAR *dcode;      /* local strm->distcode */
  342.91 +    unsigned lmask;             /* mask for first level of length codes */
  342.92 +    unsigned dmask;             /* mask for first level of distance codes */
  342.93 +    code here;                  /* retrieved table entry */
  342.94 +    unsigned op;                /* code bits, operation, extra bits, or */
  342.95 +                                /*  window position, window bytes to copy */
  342.96 +    unsigned len;               /* match length, unused bytes */
  342.97 +    unsigned dist;              /* match distance */
  342.98 +    unsigned char FAR *from;    /* where to copy match from */
  342.99 +
 342.100 +    /* copy state to local variables */
 342.101 +    state = (struct inflate_state FAR *)strm->state;
 342.102 +    in = strm->next_in - OFF;
 342.103 +    last = in + (strm->avail_in - 5);
 342.104 +    out = strm->next_out - OFF;
 342.105 +    beg = out - (start - strm->avail_out);
 342.106 +    end = out + (strm->avail_out - 257);
 342.107 +#ifdef INFLATE_STRICT
 342.108 +    dmax = state->dmax;
 342.109 +#endif
 342.110 +    wsize = state->wsize;
 342.111 +    whave = state->whave;
 342.112 +    wnext = state->wnext;
 342.113 +    window = state->window;
 342.114 +    hold = state->hold;
 342.115 +    bits = state->bits;
 342.116 +    lcode = state->lencode;
 342.117 +    dcode = state->distcode;
 342.118 +    lmask = (1U << state->lenbits) - 1;
 342.119 +    dmask = (1U << state->distbits) - 1;
 342.120 +
 342.121 +    /* decode literals and length/distances until end-of-block or not enough
 342.122 +       input data or output space */
 342.123 +    do {
 342.124 +        if (bits < 15) {
 342.125 +            hold += (unsigned long)(PUP(in)) << bits;
 342.126 +            bits += 8;
 342.127 +            hold += (unsigned long)(PUP(in)) << bits;
 342.128 +            bits += 8;
 342.129 +        }
 342.130 +        here = lcode[hold & lmask];
 342.131 +      dolen:
 342.132 +        op = (unsigned)(here.bits);
 342.133 +        hold >>= op;
 342.134 +        bits -= op;
 342.135 +        op = (unsigned)(here.op);
 342.136 +        if (op == 0) {                          /* literal */
 342.137 +            Tracevv((stderr, here.val >= 0x20 && here.val < 0x7f ?
 342.138 +                    "inflate:         literal '%c'\n" :
 342.139 +                    "inflate:         literal 0x%02x\n", here.val));
 342.140 +            PUP(out) = (unsigned char)(here.val);
 342.141 +        }
 342.142 +        else if (op & 16) {                     /* length base */
 342.143 +            len = (unsigned)(here.val);
 342.144 +            op &= 15;                           /* number of extra bits */
 342.145 +            if (op) {
 342.146 +                if (bits < op) {
 342.147 +                    hold += (unsigned long)(PUP(in)) << bits;
 342.148 +                    bits += 8;
 342.149 +                }
 342.150 +                len += (unsigned)hold & ((1U << op) - 1);
 342.151 +                hold >>= op;
 342.152 +                bits -= op;
 342.153 +            }
 342.154 +            Tracevv((stderr, "inflate:         length %u\n", len));
 342.155 +            if (bits < 15) {
 342.156 +                hold += (unsigned long)(PUP(in)) << bits;
 342.157 +                bits += 8;
 342.158 +                hold += (unsigned long)(PUP(in)) << bits;
 342.159 +                bits += 8;
 342.160 +            }
 342.161 +            here = dcode[hold & dmask];
 342.162 +          dodist:
 342.163 +            op = (unsigned)(here.bits);
 342.164 +            hold >>= op;
 342.165 +            bits -= op;
 342.166 +            op = (unsigned)(here.op);
 342.167 +            if (op & 16) {                      /* distance base */
 342.168 +                dist = (unsigned)(here.val);
 342.169 +                op &= 15;                       /* number of extra bits */
 342.170 +                if (bits < op) {
 342.171 +                    hold += (unsigned long)(PUP(in)) << bits;
 342.172 +                    bits += 8;
 342.173 +                    if (bits < op) {
 342.174 +                        hold += (unsigned long)(PUP(in)) << bits;
 342.175 +                        bits += 8;
 342.176 +                    }
 342.177 +                }
 342.178 +                dist += (unsigned)hold & ((1U << op) - 1);
 342.179 +#ifdef INFLATE_STRICT
 342.180 +                if (dist > dmax) {
 342.181 +                    strm->msg = (char *)"invalid distance too far back";
 342.182 +                    state->mode = BAD;
 342.183 +                    break;
 342.184 +                }
 342.185 +#endif
 342.186 +                hold >>= op;
 342.187 +                bits -= op;
 342.188 +                Tracevv((stderr, "inflate:         distance %u\n", dist));
 342.189 +                op = (unsigned)(out - beg);     /* max distance in output */
 342.190 +                if (dist > op) {                /* see if copy from window */
 342.191 +                    op = dist - op;             /* distance back in window */
 342.192 +                    if (op > whave) {
 342.193 +                        if (state->sane) {
 342.194 +                            strm->msg =
 342.195 +                                (char *)"invalid distance too far back";
 342.196 +                            state->mode = BAD;
 342.197 +                            break;
 342.198 +                        }
 342.199 +#ifdef INFLATE_ALLOW_INVALID_DISTANCE_TOOFAR_ARRR
 342.200 +                        if (len <= op - whave) {
 342.201 +                            do {
 342.202 +                                PUP(out) = 0;
 342.203 +                            } while (--len);
 342.204 +                            continue;
 342.205 +                        }
 342.206 +                        len -= op - whave;
 342.207 +                        do {
 342.208 +                            PUP(out) = 0;
 342.209 +                        } while (--op > whave);
 342.210 +                        if (op == 0) {
 342.211 +                            from = out - dist;
 342.212 +                            do {
 342.213 +                                PUP(out) = PUP(from);
 342.214 +                            } while (--len);
 342.215 +                            continue;
 342.216 +                        }
 342.217 +#endif
 342.218 +                    }
 342.219 +                    from = window - OFF;
 342.220 +                    if (wnext == 0) {           /* very common case */
 342.221 +                        from += wsize - op;
 342.222 +                        if (op < len) {         /* some from window */
 342.223 +                            len -= op;
 342.224 +                            do {
 342.225 +                                PUP(out) = PUP(from);
 342.226 +                            } while (--op);
 342.227 +                            from = out - dist;  /* rest from output */
 342.228 +                        }
 342.229 +                    }
 342.230 +                    else if (wnext < op) {      /* wrap around window */
 342.231 +                        from += wsize + wnext - op;
 342.232 +                        op -= wnext;
 342.233 +                        if (op < len) {         /* some from end of window */
 342.234 +                            len -= op;
 342.235 +                            do {
 342.236 +                                PUP(out) = PUP(from);
 342.237 +                            } while (--op);
 342.238 +                            from = window - OFF;
 342.239 +                            if (wnext < len) {  /* some from start of window */
 342.240 +                                op = wnext;
 342.241 +                                len -= op;
 342.242 +                                do {
 342.243 +                                    PUP(out) = PUP(from);
 342.244 +                                } while (--op);
 342.245 +                                from = out - dist;      /* rest from output */
 342.246 +                            }
 342.247 +                        }
 342.248 +                    }
 342.249 +                    else {                      /* contiguous in window */
 342.250 +                        from += wnext - op;
 342.251 +                        if (op < len) {         /* some from window */
 342.252 +                            len -= op;
 342.253 +                            do {
 342.254 +                                PUP(out) = PUP(from);
 342.255 +                            } while (--op);
 342.256 +                            from = out - dist;  /* rest from output */
 342.257 +                        }
 342.258 +                    }
 342.259 +                    while (len > 2) {
 342.260 +                        PUP(out) = PUP(from);
 342.261 +                        PUP(out) = PUP(from);
 342.262 +                        PUP(out) = PUP(from);
 342.263 +                        len -= 3;
 342.264 +                    }
 342.265 +                    if (len) {
 342.266 +                        PUP(out) = PUP(from);
 342.267 +                        if (len > 1)
 342.268 +                            PUP(out) = PUP(from);
 342.269 +                    }
 342.270 +                }
 342.271 +                else {
 342.272 +                    from = out - dist;          /* copy direct from output */
 342.273 +                    do {                        /* minimum length is three */
 342.274 +                        PUP(out) = PUP(from);
 342.275 +                        PUP(out) = PUP(from);
 342.276 +                        PUP(out) = PUP(from);
 342.277 +                        len -= 3;
 342.278 +                    } while (len > 2);
 342.279 +                    if (len) {
 342.280 +                        PUP(out) = PUP(from);
 342.281 +                        if (len > 1)
 342.282 +                            PUP(out) = PUP(from);
 342.283 +                    }
 342.284 +                }
 342.285 +            }
 342.286 +            else if ((op & 64) == 0) {          /* 2nd level distance code */
 342.287 +                here = dcode[here.val + (hold & ((1U << op) - 1))];
 342.288 +                goto dodist;
 342.289 +            }
 342.290 +            else {
 342.291 +                strm->msg = (char *)"invalid distance code";
 342.292 +                state->mode = BAD;
 342.293 +                break;
 342.294 +            }
 342.295 +        }
 342.296 +        else if ((op & 64) == 0) {              /* 2nd level length code */
 342.297 +            here = lcode[here.val + (hold & ((1U << op) - 1))];
 342.298 +            goto dolen;
 342.299 +        }
 342.300 +        else if (op & 32) {                     /* end-of-block */
 342.301 +            Tracevv((stderr, "inflate:         end of block\n"));
 342.302 +            state->mode = TYPE;
 342.303 +            break;
 342.304 +        }
 342.305 +        else {
 342.306 +            strm->msg = (char *)"invalid literal/length code";
 342.307 +            state->mode = BAD;
 342.308 +            break;
 342.309 +        }
 342.310 +    } while (in < last && out < end);
 342.311 +
 342.312 +    /* return unused bytes (on entry, bits < 8, so in won't go too far back) */
 342.313 +    len = bits >> 3;
 342.314 +    in -= len;
 342.315 +    bits -= len << 3;
 342.316 +    hold &= (1U << bits) - 1;
 342.317 +
 342.318 +    /* update state and return */
 342.319 +    strm->next_in = in + OFF;
 342.320 +    strm->next_out = out + OFF;
 342.321 +    strm->avail_in = (unsigned)(in < last ? 5 + (last - in) : 5 - (in - last));
 342.322 +    strm->avail_out = (unsigned)(out < end ?
 342.323 +                                 257 + (end - out) : 257 - (out - end));
 342.324 +    state->hold = hold;
 342.325 +    state->bits = bits;
 342.326 +    return;
 342.327 +}
 342.328 +
 342.329 +/*
 342.330 +   inflate_fast() speedups that turned out slower (on a PowerPC G3 750CXe):
 342.331 +   - Using bit fields for code structure
 342.332 +   - Different op definition to avoid & for extra bits (do & for table bits)
 342.333 +   - Three separate decoding do-loops for direct, window, and wnext == 0
 342.334 +   - Special case for distance > 1 copies to do overlapped load and store copy
 342.335 +   - Explicit branch predictions (based on measured branch probabilities)
 342.336 +   - Deferring match copy and interspersed it with decoding subsequent codes
 342.337 +   - Swapping literal/length else
 342.338 +   - Swapping window/direct else
 342.339 +   - Larger unrolled copy loops (three is about right)
 342.340 +   - Moving len -= 3 statement into middle of loop
 342.341 + */
 342.342 +
 342.343 +#endif /* !ASMINF */
   343.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
   343.2 +++ b/deps/glpk/src/zlib/inffast.h	Sun Nov 06 20:59:10 2011 +0100
   343.3 @@ -0,0 +1,11 @@
   343.4 +/* inffast.h -- header to use inffast.c
   343.5 + * Copyright (C) 1995-2003, 2010 Mark Adler
   343.6 + * For conditions of distribution and use, see copyright notice in zlib.h
   343.7 + */
   343.8 +
   343.9 +/* WARNING: this file should *not* be used by applications. It is
  343.10 +   part of the implementation of the compression library and is
  343.11 +   subject to change. Applications should only use zlib.h.
  343.12 + */
  343.13 +
  343.14 +void ZLIB_INTERNAL inflate_fast OF((z_streamp strm, unsigned start));
   344.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
   344.2 +++ b/deps/glpk/src/zlib/inffixed.h	Sun Nov 06 20:59:10 2011 +0100
   344.3 @@ -0,0 +1,94 @@
   344.4 +    /* inffixed.h -- table for decoding fixed codes
   344.5 +     * Generated automatically by makefixed().
   344.6 +     */
   344.7 +
   344.8 +    /* WARNING: this file should *not* be used by applications. It
   344.9 +       is part of the implementation of the compression library and
  344.10 +       is subject to change. Applications should only use zlib.h.
  344.11 +     */
  344.12 +
  344.13 +    static const code lenfix[512] = {
  344.14 +        {96,7,0},{0,8,80},{0,8,16},{20,8,115},{18,7,31},{0,8,112},{0,8,48},
  344.15 +        {0,9,192},{16,7,10},{0,8,96},{0,8,32},{0,9,160},{0,8,0},{0,8,128},
  344.16 +        {0,8,64},{0,9,224},{16,7,6},{0,8,88},{0,8,24},{0,9,144},{19,7,59},
  344.17 +        {0,8,120},{0,8,56},{0,9,208},{17,7,17},{0,8,104},{0,8,40},{0,9,176},
  344.18 +        {0,8,8},{0,8,136},{0,8,72},{0,9,240},{16,7,4},{0,8,84},{0,8,20},
  344.19 +        {21,8,227},{19,7,43},{0,8,116},{0,8,52},{0,9,200},{17,7,13},{0,8,100},
  344.20 +        {0,8,36},{0,9,168},{0,8,4},{0,8,132},{0,8,68},{0,9,232},{16,7,8},
  344.21 +        {0,8,92},{0,8,28},{0,9,152},{20,7,83},{0,8,124},{0,8,60},{0,9,216},
  344.22 +        {18,7,23},{0,8,108},{0,8,44},{0,9,184},{0,8,12},{0,8,140},{0,8,76},
  344.23 +        {0,9,248},{16,7,3},{0,8,82},{0,8,18},{21,8,163},{19,7,35},{0,8,114},
  344.24 +        {0,8,50},{0,9,196},{17,7,11},{0,8,98},{0,8,34},{0,9,164},{0,8,2},
  344.25 +        {0,8,130},{0,8,66},{0,9,228},{16,7,7},{0,8,90},{0,8,26},{0,9,148},
  344.26 +        {20,7,67},{0,8,122},{0,8,58},{0,9,212},{18,7,19},{0,8,106},{0,8,42},
  344.27 +        {0,9,180},{0,8,10},{0,8,138},{0,8,74},{0,9,244},{16,7,5},{0,8,86},
  344.28 +        {0,8,22},{64,8,0},{19,7,51},{0,8,118},{0,8,54},{0,9,204},{17,7,15},
  344.29 +        {0,8,102},{0,8,38},{0,9,172},{0,8,6},{0,8,134},{0,8,70},{0,9,236},
  344.30 +        {16,7,9},{0,8,94},{0,8,30},{0,9,156},{20,7,99},{0,8,126},{0,8,62},
  344.31 +        {0,9,220},{18,7,27},{0,8,110},{0,8,46},{0,9,188},{0,8,14},{0,8,142},
  344.32 +        {0,8,78},{0,9,252},{96,7,0},{0,8,81},{0,8,17},{21,8,131},{18,7,31},
  344.33 +        {0,8,113},{0,8,49},{0,9,194},{16,7,10},{0,8,97},{0,8,33},{0,9,162},
  344.34 +        {0,8,1},{0,8,129},{0,8,65},{0,9,226},{16,7,6},{0,8,89},{0,8,25},
  344.35 +        {0,9,146},{19,7,59},{0,8,121},{0,8,57},{0,9,210},{17,7,17},{0,8,105},
  344.36 +        {0,8,41},{0,9,178},{0,8,9},{0,8,137},{0,8,73},{0,9,242},{16,7,4},
  344.37 +        {0,8,85},{0,8,21},{16,8,258},{19,7,43},{0,8,117},{0,8,53},{0,9,202},
  344.38 +        {17,7,13},{0,8,101},{0,8,37},{0,9,170},{0,8,5},{0,8,133},{0,8,69},
  344.39 +        {0,9,234},{16,7,8},{0,8,93},{0,8,29},{0,9,154},{20,7,83},{0,8,125},
  344.40 +        {0,8,61},{0,9,218},{18,7,23},{0,8,109},{0,8,45},{0,9,186},{0,8,13},
  344.41 +        {0,8,141},{0,8,77},{0,9,250},{16,7,3},{0,8,83},{0,8,19},{21,8,195},
  344.42 +        {19,7,35},{0,8,115},{0,8,51},{0,9,198},{17,7,11},{0,8,99},{0,8,35},
  344.43 +        {0,9,166},{0,8,3},{0,8,131},{0,8,67},{0,9,230},{16,7,7},{0,8,91},
  344.44 +        {0,8,27},{0,9,150},{20,7,67},{0,8,123},{0,8,59},{0,9,214},{18,7,19},
  344.45 +        {0,8,107},{0,8,43},{0,9,182},{0,8,11},{0,8,139},{0,8,75},{0,9,246},
  344.46 +        {16,7,5},{0,8,87},{0,8,23},{64,8,0},{19,7,51},{0,8,119},{0,8,55},
  344.47 +        {0,9,206},{17,7,15},{0,8,103},{0,8,39},{0,9,174},{0,8,7},{0,8,135},
  344.48 +        {0,8,71},{0,9,238},{16,7,9},{0,8,95},{0,8,31},{0,9,158},{20,7,99},
  344.49 +        {0,8,127},{0,8,63},{0,9,222},{18,7,27},{0,8,111},{0,8,47},{0,9,190},
  344.50 +        {0,8,15},{0,8,143},{0,8,79},{0,9,254},{96,7,0},{0,8,80},{0,8,16},
  344.51 +        {20,8,115},{18,7,31},{0,8,112},{0,8,48},{0,9,193},{16,7,10},{0,8,96},
  344.52 +        {0,8,32},{0,9,161},{0,8,0},{0,8,128},{0,8,64},{0,9,225},{16,7,6},
  344.53 +        {0,8,88},{0,8,24},{0,9,145},{19,7,59},{0,8,120},{0,8,56},{0,9,209},
  344.54 +        {17,7,17},{0,8,104},{0,8,40},{0,9,177},{0,8,8},{0,8,136},{0,8,72},
  344.55 +        {0,9,241},{16,7,4},{0,8,84},{0,8,20},{21,8,227},{19,7,43},{0,8,116},
  344.56 +        {0,8,52},{0,9,201},{17,7,13},{0,8,100},{0,8,36},{0,9,169},{0,8,4},
  344.57 +        {0,8,132},{0,8,68},{0,9,233},{16,7,8},{0,8,92},{0,8,28},{0,9,153},
  344.58 +        {20,7,83},{0,8,124},{0,8,60},{0,9,217},{18,7,23},{0,8,108},{0,8,44},
  344.59 +        {0,9,185},{0,8,12},{0,8,140},{0,8,76},{0,9,249},{16,7,3},{0,8,82},
  344.60 +        {0,8,18},{21,8,163},{19,7,35},{0,8,114},{0,8,50},{0,9,197},{17,7,11},
  344.61 +        {0,8,98},{0,8,34},{0,9,165},{0,8,2},{0,8,130},{0,8,66},{0,9,229},
  344.62 +        {16,7,7},{0,8,90},{0,8,26},{0,9,149},{20,7,67},{0,8,122},{0,8,58},
  344.63 +        {0,9,213},{18,7,19},{0,8,106},{0,8,42},{0,9,181},{0,8,10},{0,8,138},
  344.64 +        {0,8,74},{0,9,245},{16,7,5},{0,8,86},{0,8,22},{64,8,0},{19,7,51},
  344.65 +        {0,8,118},{0,8,54},{0,9,205},{17,7,15},{0,8,102},{0,8,38},{0,9,173},
  344.66 +        {0,8,6},{0,8,134},{0,8,70},{0,9,237},{16,7,9},{0,8,94},{0,8,30},
  344.67 +        {0,9,157},{20,7,99},{0,8,126},{0,8,62},{0,9,221},{18,7,27},{0,8,110},
  344.68 +        {0,8,46},{0,9,189},{0,8,14},{0,8,142},{0,8,78},{0,9,253},{96,7,0},
  344.69 +        {0,8,81},{0,8,17},{21,8,131},{18,7,31},{0,8,113},{0,8,49},{0,9,195},
  344.70 +        {16,7,10},{0,8,97},{0,8,33},{0,9,163},{0,8,1},{0,8,129},{0,8,65},
  344.71 +        {0,9,227},{16,7,6},{0,8,89},{0,8,25},{0,9,147},{19,7,59},{0,8,121},
  344.72 +        {0,8,57},{0,9,211},{17,7,17},{0,8,105},{0,8,41},{0,9,179},{0,8,9},
  344.73 +        {0,8,137},{0,8,73},{0,9,243},{16,7,4},{0,8,85},{0,8,21},{16,8,258},
  344.74 +        {19,7,43},{0,8,117},{0,8,53},{0,9,203},{17,7,13},{0,8,101},{0,8,37},
  344.75 +        {0,9,171},{0,8,5},{0,8,133},{0,8,69},{0,9,235},{16,7,8},{0,8,93},
  344.76 +        {0,8,29},{0,9,155},{20,7,83},{0,8,125},{0,8,61},{0,9,219},{18,7,23},
  344.77 +        {0,8,109},{0,8,45},{0,9,187},{0,8,13},{0,8,141},{0,8,77},{0,9,251},
  344.78 +        {16,7,3},{0,8,83},{0,8,19},{21,8,195},{19,7,35},{0,8,115},{0,8,51},
  344.79 +        {0,9,199},{17,7,11},{0,8,99},{0,8,35},{0,9,167},{0,8,3},{0,8,131},
  344.80 +        {0,8,67},{0,9,231},{16,7,7},{0,8,91},{0,8,27},{0,9,151},{20,7,67},
  344.81 +        {0,8,123},{0,8,59},{0,9,215},{18,7,19},{0,8,107},{0,8,43},{0,9,183},
  344.82 +        {0,8,11},{0,8,139},{0,8,75},{0,9,247},{16,7,5},{0,8,87},{0,8,23},
  344.83 +        {64,8,0},{19,7,51},{0,8,119},{0,8,55},{0,9,207},{17,7,15},{0,8,103},
  344.84 +        {0,8,39},{0,9,175},{0,8,7},{0,8,135},{0,8,71},{0,9,239},{16,7,9},
  344.85 +        {0,8,95},{0,8,31},{0,9,159},{20,7,99},{0,8,127},{0,8,63},{0,9,223},
  344.86 +        {18,7,27},{0,8,111},{0,8,47},{0,9,191},{0,8,15},{0,8,143},{0,8,79},
  344.87 +        {0,9,255}
  344.88 +    };
  344.89 +
  344.90 +    static const code distfix[32] = {
  344.91 +        {16,5,1},{23,5,257},{19,5,17},{27,5,4097},{17,5,5},{25,5,1025},
  344.92 +        {21,5,65},{29,5,16385},{16,5,3},{24,5,513},{20,5,33},{28,5,8193},
  344.93 +        {18,5,9},{26,5,2049},{22,5,129},{64,5,0},{16,5,2},{23,5,385},
  344.94 +        {19,5,25},{27,5,6145},{17,5,7},{25,5,1537},{21,5,97},{29,5,24577},
  344.95 +        {16,5,4},{24,5,769},{20,5,49},{28,5,12289},{18,5,13},{26,5,3073},
  344.96 +        {22,5,193},{64,5,0}
  344.97 +    };
   345.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
   345.2 +++ b/deps/glpk/src/zlib/inflate.c	Sun Nov 06 20:59:10 2011 +0100
   345.3 @@ -0,0 +1,1480 @@
   345.4 +/* inflate.c -- zlib decompression
   345.5 + * Copyright (C) 1995-2010 Mark Adler
   345.6 + * For conditions of distribution and use, see copyright notice in zlib.h
   345.7 + */
   345.8 +
   345.9 +/*
  345.10 + * Change history:
  345.11 + *
  345.12 + * 1.2.beta0    24 Nov 2002
  345.13 + * - First version -- complete rewrite of inflate to simplify code, avoid
  345.14 + *   creation of window when not needed, minimize use of window when it is
  345.15 + *   needed, make inffast.c even faster, implement gzip decoding, and to
  345.16 + *   improve code readability and style over the previous zlib inflate code
  345.17 + *
  345.18 + * 1.2.beta1    25 Nov 2002
  345.19 + * - Use pointers for available input and output checking in inffast.c
  345.20 + * - Remove input and output counters in inffast.c
  345.21 + * - Change inffast.c entry and loop from avail_in >= 7 to >= 6
  345.22 + * - Remove unnecessary second byte pull from length extra in inffast.c
  345.23 + * - Unroll direct copy to three copies per loop in inffast.c
  345.24 + *
  345.25 + * 1.2.beta2    4 Dec 2002
  345.26 + * - Change external routine names to reduce potential conflicts
  345.27 + * - Correct filename to inffixed.h for fixed tables in inflate.c
  345.28 + * - Make hbuf[] unsigned char to match parameter type in inflate.c
  345.29 + * - Change strm->next_out[-state->offset] to *(strm->next_out - state->offset)
  345.30 + *   to avoid negation problem on Alphas (64 bit) in inflate.c
  345.31 + *
  345.32 + * 1.2.beta3    22 Dec 2002
  345.33 + * - Add comments on state->bits assertion in inffast.c
  345.34 + * - Add comments on op field in inftrees.h
  345.35 + * - Fix bug in reuse of allocated window after inflateReset()
  345.36 + * - Remove bit fields--back to byte structure for speed
  345.37 + * - Remove distance extra == 0 check in inflate_fast()--only helps for lengths
  345.38 + * - Change post-increments to pre-increments in inflate_fast(), PPC biased?
  345.39 + * - Add compile time option, POSTINC, to use post-increments instead (Intel?)
  345.40 + * - Make MATCH copy in inflate() much faster for when inflate_fast() not used
  345.41 + * - Use local copies of stream next and avail values, as well as local bit
  345.42 + *   buffer and bit count in inflate()--for speed when inflate_fast() not used
  345.43 + *
  345.44 + * 1.2.beta4    1 Jan 2003
  345.45 + * - Split ptr - 257 statements in inflate_table() to avoid compiler warnings
  345.46 + * - Move a comment on output buffer sizes from inffast.c to inflate.c
  345.47 + * - Add comments in inffast.c to introduce the inflate_fast() routine
  345.48 + * - Rearrange window copies in inflate_fast() for speed and simplification
  345.49 + * - Unroll last copy for window match in inflate_fast()
  345.50 + * - Use local copies of window variables in inflate_fast() for speed
  345.51 + * - Pull out common wnext == 0 case for speed in inflate_fast()
  345.52 + * - Make op and len in inflate_fast() unsigned for consistency
  345.53 + * - Add FAR to lcode and dcode declarations in inflate_fast()
  345.54 + * - Simplified bad distance check in inflate_fast()
  345.55 + * - Added inflateBackInit(), inflateBack(), and inflateBackEnd() in new
  345.56 + *   source file infback.c to provide a call-back interface to inflate for
  345.57 + *   programs like gzip and unzip -- uses window as output buffer to avoid
  345.58 + *   window copying
  345.59 + *
  345.60 + * 1.2.beta5    1 Jan 2003
  345.61 + * - Improved inflateBack() interface to allow the caller to provide initial
  345.62 + *   input in strm.
  345.63 + * - Fixed stored blocks bug in inflateBack()
  345.64 + *
  345.65 + * 1.2.beta6    4 Jan 2003
  345.66 + * - Added comments in inffast.c on effectiveness of POSTINC
  345.67 + * - Typecasting all around to reduce compiler warnings
  345.68 + * - Changed loops from while (1) or do {} while (1) to for (;;), again to
  345.69 + *   make compilers happy
  345.70 + * - Changed type of window in inflateBackInit() to unsigned char *
  345.71 + *
  345.72 + * 1.2.beta7    27 Jan 2003
  345.73 + * - Changed many types to unsigned or unsigned short to avoid warnings
  345.74 + * - Added inflateCopy() function
  345.75 + *
  345.76 + * 1.2.0        9 Mar 2003
  345.77 + * - Changed inflateBack() interface to provide separate opaque descriptors
  345.78 + *   for the in() and out() functions
  345.79 + * - Changed inflateBack() argument and in_func typedef to swap the length
  345.80 + *   and buffer address return values for the input function
  345.81 + * - Check next_in and next_out for Z_NULL on entry to inflate()
  345.82 + *
  345.83 + * The history for versions after 1.2.0 are in ChangeLog in zlib distribution.
  345.84 + */
  345.85 +
  345.86 +#include "zutil.h"
  345.87 +#include "inftrees.h"
  345.88 +#include "inflate.h"
  345.89 +#include "inffast.h"
  345.90 +
  345.91 +#ifdef MAKEFIXED
  345.92 +#  ifndef BUILDFIXED
  345.93 +#    define BUILDFIXED
  345.94 +#  endif
  345.95 +#endif
  345.96 +
  345.97 +/* function prototypes */
  345.98 +local void fixedtables OF((struct inflate_state FAR *state));
  345.99 +local int updatewindow OF((z_streamp strm, unsigned out));
 345.100 +#ifdef BUILDFIXED
 345.101 +   void makefixed OF((void));
 345.102 +#endif
 345.103 +local unsigned syncsearch OF((unsigned FAR *have, unsigned char FAR *buf,
 345.104 +                              unsigned len));
 345.105 +
 345.106 +int ZEXPORT inflateReset(strm)
 345.107 +z_streamp strm;
 345.108 +{
 345.109 +    struct inflate_state FAR *state;
 345.110 +
 345.111 +    if (strm == Z_NULL || strm->state == Z_NULL) return Z_STREAM_ERROR;
 345.112 +    state = (struct inflate_state FAR *)strm->state;
 345.113 +    strm->total_in = strm->total_out = state->total = 0;
 345.114 +    strm->msg = Z_NULL;
 345.115 +    strm->adler = 1;        /* to support ill-conceived Java test suite */
 345.116 +    state->mode = HEAD;
 345.117 +    state->last = 0;
 345.118 +    state->havedict = 0;
 345.119 +    state->dmax = 32768U;
 345.120 +    state->head = Z_NULL;
 345.121 +    state->wsize = 0;
 345.122 +    state->whave = 0;
 345.123 +    state->wnext = 0;
 345.124 +    state->hold = 0;
 345.125 +    state->bits = 0;
 345.126 +    state->lencode = state->distcode = state->next = state->codes;
 345.127 +    state->sane = 1;
 345.128 +    state->back = -1;
 345.129 +    Tracev((stderr, "inflate: reset\n"));
 345.130 +    return Z_OK;
 345.131 +}
 345.132 +
 345.133 +int ZEXPORT inflateReset2(strm, windowBits)
 345.134 +z_streamp strm;
 345.135 +int windowBits;
 345.136 +{
 345.137 +    int wrap;
 345.138 +    struct inflate_state FAR *state;
 345.139 +
 345.140 +    /* get the state */
 345.141 +    if (strm == Z_NULL || strm->state == Z_NULL) return Z_STREAM_ERROR;
 345.142 +    state = (struct inflate_state FAR *)strm->state;
 345.143 +
 345.144 +    /* extract wrap request from windowBits parameter */
 345.145 +    if (windowBits < 0) {
 345.146 +        wrap = 0;
 345.147 +        windowBits = -windowBits;
 345.148 +    }
 345.149 +    else {
 345.150 +        wrap = (windowBits >> 4) + 1;
 345.151 +#ifdef GUNZIP
 345.152 +        if (windowBits < 48)
 345.153 +            windowBits &= 15;
 345.154 +#endif
 345.155 +    }
 345.156 +
 345.157 +    /* set number of window bits, free window if different */
 345.158 +    if (windowBits && (windowBits < 8 || windowBits > 15))
 345.159 +        return Z_STREAM_ERROR;
 345.160 +    if (state->window != Z_NULL && state->wbits != (unsigned)windowBits) {
 345.161 +        ZFREE(strm, state->window);
 345.162 +        state->window = Z_NULL;
 345.163 +    }
 345.164 +
 345.165 +    /* update state and reset the rest of it */
 345.166 +    state->wrap = wrap;
 345.167 +    state->wbits = (unsigned)windowBits;
 345.168 +    return inflateReset(strm);
 345.169 +}
 345.170 +
 345.171 +int ZEXPORT inflateInit2_(strm, windowBits, version, stream_size)
 345.172 +z_streamp strm;
 345.173 +int windowBits;
 345.174 +const char *version;
 345.175 +int stream_size;
 345.176 +{
 345.177 +    int ret;
 345.178 +    struct inflate_state FAR *state;
 345.179 +
 345.180 +    if (version == Z_NULL || version[0] != ZLIB_VERSION[0] ||
 345.181 +        stream_size != (int)(sizeof(z_stream)))
 345.182 +        return Z_VERSION_ERROR;
 345.183 +    if (strm == Z_NULL) return Z_STREAM_ERROR;
 345.184 +    strm->msg = Z_NULL;                 /* in case we return an error */
 345.185 +    if (strm->zalloc == (alloc_func)0) {
 345.186 +        strm->zalloc = zcalloc;
 345.187 +        strm->opaque = (voidpf)0;
 345.188 +    }
 345.189 +    if (strm->zfree == (free_func)0) strm->zfree = zcfree;
 345.190 +    state = (struct inflate_state FAR *)
 345.191 +            ZALLOC(strm, 1, sizeof(struct inflate_state));
 345.192 +    if (state == Z_NULL) return Z_MEM_ERROR;
 345.193 +    Tracev((stderr, "inflate: allocated\n"));
 345.194 +    strm->state = (struct internal_state FAR *)state;
 345.195 +    state->window = Z_NULL;
 345.196 +    ret = inflateReset2(strm, windowBits);
 345.197 +    if (ret != Z_OK) {
 345.198 +        ZFREE(strm, state);
 345.199 +        strm->state = Z_NULL;
 345.200 +    }
 345.201 +    return ret;
 345.202 +}
 345.203 +
 345.204 +int ZEXPORT inflateInit_(strm, version, stream_size)
 345.205 +z_streamp strm;
 345.206 +const char *version;
 345.207 +int stream_size;
 345.208 +{
 345.209 +    return inflateInit2_(strm, DEF_WBITS, version, stream_size);
 345.210 +}
 345.211 +
 345.212 +int ZEXPORT inflatePrime(strm, bits, value)
 345.213 +z_streamp strm;
 345.214 +int bits;
 345.215 +int value;
 345.216 +{
 345.217 +    struct inflate_state FAR *state;
 345.218 +
 345.219 +    if (strm == Z_NULL || strm->state == Z_NULL) return Z_STREAM_ERROR;
 345.220 +    state = (struct inflate_state FAR *)strm->state;
 345.221 +    if (bits < 0) {
 345.222 +        state->hold = 0;
 345.223 +        state->bits = 0;
 345.224 +        return Z_OK;
 345.225 +    }
 345.226 +    if (bits > 16 || state->bits + bits > 32) return Z_STREAM_ERROR;
 345.227 +    value &= (1L << bits) - 1;
 345.228 +    state->hold += value << state->bits;
 345.229 +    state->bits += bits;
 345.230 +    return Z_OK;
 345.231 +}
 345.232 +
 345.233 +/*
 345.234 +   Return state with length and distance decoding tables and index sizes set to
 345.235 +   fixed code decoding.  Normally this returns fixed tables from inffixed.h.
 345.236 +   If BUILDFIXED is defined, then instead this routine builds the tables the
 345.237 +   first time it's called, and returns those tables the first time and
 345.238 +   thereafter.  This reduces the size of the code by about 2K bytes, in
 345.239 +   exchange for a little execution time.  However, BUILDFIXED should not be
 345.240 +   used for threaded applications, since the rewriting of the tables and virgin
 345.241 +   may not be thread-safe.
 345.242 + */
 345.243 +local void fixedtables(state)
 345.244 +struct inflate_state FAR *state;
 345.245 +{
 345.246 +#ifdef BUILDFIXED
 345.247 +    static int virgin = 1;
 345.248 +    static code *lenfix, *distfix;
 345.249 +    static code fixed[544];
 345.250 +
 345.251 +    /* build fixed huffman tables if first call (may not be thread safe) */
 345.252 +    if (virgin) {
 345.253 +        unsigned sym, bits;
 345.254 +        static code *next;
 345.255 +
 345.256 +        /* literal/length table */
 345.257 +        sym = 0;
 345.258 +        while (sym < 144) state->lens[sym++] = 8;
 345.259 +        while (sym < 256) state->lens[sym++] = 9;
 345.260 +        while (sym < 280) state->lens[sym++] = 7;
 345.261 +        while (sym < 288) state->lens[sym++] = 8;
 345.262 +        next = fixed;
 345.263 +        lenfix = next;
 345.264 +        bits = 9;
 345.265 +        inflate_table(LENS, state->lens, 288, &(next), &(bits), state->work);
 345.266 +
 345.267 +        /* distance table */
 345.268 +        sym = 0;
 345.269 +        while (sym < 32) state->lens[sym++] = 5;
 345.270 +        distfix = next;
 345.271 +        bits = 5;
 345.272 +        inflate_table(DISTS, state->lens, 32, &(next), &(bits), state->work);
 345.273 +
 345.274 +        /* do this just once */
 345.275 +        virgin = 0;
 345.276 +    }
 345.277 +#else /* !BUILDFIXED */
 345.278 +#   include "inffixed.h"
 345.279 +#endif /* BUILDFIXED */
 345.280 +    state->lencode = lenfix;
 345.281 +    state->lenbits = 9;
 345.282 +    state->distcode = distfix;
 345.283 +    state->distbits = 5;
 345.284 +}
 345.285 +
 345.286 +#ifdef MAKEFIXED
 345.287 +#include <stdio.h>
 345.288 +
 345.289 +/*
 345.290 +   Write out the inffixed.h that is #include'd above.  Defining MAKEFIXED also
 345.291 +   defines BUILDFIXED, so the tables are built on the fly.  makefixed() writes
 345.292 +   those tables to stdout, which would be piped to inffixed.h.  A small program
 345.293 +   can simply call makefixed to do this:
 345.294 +
 345.295 +    void makefixed(void);
 345.296 +
 345.297 +    int main(void)
 345.298 +    {
 345.299 +        makefixed();
 345.300 +        return 0;
 345.301 +    }
 345.302 +
 345.303 +   Then that can be linked with zlib built with MAKEFIXED defined and run:
 345.304 +
 345.305 +    a.out > inffixed.h
 345.306 + */
 345.307 +void makefixed()
 345.308 +{
 345.309 +    unsigned low, size;
 345.310 +    struct inflate_state state;
 345.311 +
 345.312 +    fixedtables(&state);
 345.313 +    puts("    /* inffixed.h -- table for decoding fixed codes");
 345.314 +    puts("     * Generated automatically by makefixed().");
 345.315 +    puts("     */");
 345.316 +    puts("");
 345.317 +    puts("    /* WARNING: this file should *not* be used by applications.");
 345.318 +    puts("       It is part of the implementation of this library and is");
 345.319 +    puts("       subject to change. Applications should only use zlib.h.");
 345.320 +    puts("     */");
 345.321 +    puts("");
 345.322 +    size = 1U << 9;
 345.323 +    printf("    static const code lenfix[%u] = {", size);
 345.324 +    low = 0;
 345.325 +    for (;;) {
 345.326 +        if ((low % 7) == 0) printf("\n        ");
 345.327 +        printf("{%u,%u,%d}", state.lencode[low].op, state.lencode[low].bits,
 345.328 +               state.lencode[low].val);
 345.329 +        if (++low == size) break;
 345.330 +        putchar(',');
 345.331 +    }
 345.332 +    puts("\n    };");
 345.333 +    size = 1U << 5;
 345.334 +    printf("\n    static const code distfix[%u] = {", size);
 345.335 +    low = 0;
 345.336 +    for (;;) {
 345.337 +        if ((low % 6) == 0) printf("\n        ");
 345.338 +        printf("{%u,%u,%d}", state.distcode[low].op, state.distcode[low].bits,
 345.339 +               state.distcode[low].val);
 345.340 +        if (++low == size) break;
 345.341 +        putchar(',');
 345.342 +    }
 345.343 +    puts("\n    };");
 345.344 +}
 345.345 +#endif /* MAKEFIXED */
 345.346 +
 345.347 +/*
 345.348 +   Update the window with the last wsize (normally 32K) bytes written before
 345.349 +   returning.  If window does not exist yet, create it.  This is only called
 345.350 +   when a window is already in use, or when output has been written during this
 345.351 +   inflate call, but the end of the deflate stream has not been reached yet.
 345.352 +   It is also called to create a window for dictionary data when a dictionary
 345.353 +   is loaded.
 345.354 +
 345.355 +   Providing output buffers larger than 32K to inflate() should provide a speed
 345.356 +   advantage, since only the last 32K of output is copied to the sliding window
 345.357 +   upon return from inflate(), and since all distances after the first 32K of
 345.358 +   output will fall in the output data, making match copies simpler and faster.
 345.359 +   The advantage may be dependent on the size of the processor's data caches.
 345.360 + */
 345.361 +local int updatewindow(strm, out)
 345.362 +z_streamp strm;
 345.363 +unsigned out;
 345.364 +{
 345.365 +    struct inflate_state FAR *state;
 345.366 +    unsigned copy, dist;
 345.367 +
 345.368 +    state = (struct inflate_state FAR *)strm->state;
 345.369 +
 345.370 +    /* if it hasn't been done already, allocate space for the window */
 345.371 +    if (state->window == Z_NULL) {
 345.372 +        state->window = (unsigned char FAR *)
 345.373 +                        ZALLOC(strm, 1U << state->wbits,
 345.374 +                               sizeof(unsigned char));
 345.375 +        if (state->window == Z_NULL) return 1;
 345.376 +    }
 345.377 +
 345.378 +    /* if window not in use yet, initialize */
 345.379 +    if (state->wsize == 0) {
 345.380 +        state->wsize = 1U << state->wbits;
 345.381 +        state->wnext = 0;
 345.382 +        state->whave = 0;
 345.383 +    }
 345.384 +
 345.385 +    /* copy state->wsize or less output bytes into the circular window */
 345.386 +    copy = out - strm->avail_out;
 345.387 +    if (copy >= state->wsize) {
 345.388 +        zmemcpy(state->window, strm->next_out - state->wsize, state->wsize);
 345.389 +        state->wnext = 0;
 345.390 +        state->whave = state->wsize;
 345.391 +    }
 345.392 +    else {
 345.393 +        dist = state->wsize - state->wnext;
 345.394 +        if (dist > copy) dist = copy;
 345.395 +        zmemcpy(state->window + state->wnext, strm->next_out - copy, dist);
 345.396 +        copy -= dist;
 345.397 +        if (copy) {
 345.398 +            zmemcpy(state->window, strm->next_out - copy, copy);
 345.399 +            state->wnext = copy;
 345.400 +            state->whave = state->wsize;
 345.401 +        }
 345.402 +        else {
 345.403 +            state->wnext += dist;
 345.404 +            if (state->wnext == state->wsize) state->wnext = 0;
 345.405 +            if (state->whave < state->wsize) state->whave += dist;
 345.406 +        }
 345.407 +    }
 345.408 +    return 0;
 345.409 +}
 345.410 +
 345.411 +/* Macros for inflate(): */
 345.412 +
 345.413 +/* check function to use adler32() for zlib or crc32() for gzip */
 345.414 +#ifdef GUNZIP
 345.415 +#  define UPDATE(check, buf, len) \
 345.416 +    (state->flags ? crc32(check, buf, len) : adler32(check, buf, len))
 345.417 +#else
 345.418 +#  define UPDATE(check, buf, len) adler32(check, buf, len)
 345.419 +#endif
 345.420 +
 345.421 +/* check macros for header crc */
 345.422 +#ifdef GUNZIP
 345.423 +#  define CRC2(check, word) \
 345.424 +    do { \
 345.425 +        hbuf[0] = (unsigned char)(word); \
 345.426 +        hbuf[1] = (unsigned char)((word) >> 8); \
 345.427 +        check = crc32(check, hbuf, 2); \
 345.428 +    } while (0)
 345.429 +
 345.430 +#  define CRC4(check, word) \
 345.431 +    do { \
 345.432 +        hbuf[0] = (unsigned char)(word); \
 345.433 +        hbuf[1] = (unsigned char)((word) >> 8); \
 345.434 +        hbuf[2] = (unsigned char)((word) >> 16); \
 345.435 +        hbuf[3] = (unsigned char)((word) >> 24); \
 345.436 +        check = crc32(check, hbuf, 4); \
 345.437 +    } while (0)
 345.438 +#endif
 345.439 +
 345.440 +/* Load registers with state in inflate() for speed */
 345.441 +#define LOAD() \
 345.442 +    do { \
 345.443 +        put = strm->next_out; \
 345.444 +        left = strm->avail_out; \
 345.445 +        next = strm->next_in; \
 345.446 +        have = strm->avail_in; \
 345.447 +        hold = state->hold; \
 345.448 +        bits = state->bits; \
 345.449 +    } while (0)
 345.450 +
 345.451 +/* Restore state from registers in inflate() */
 345.452 +#define RESTORE() \
 345.453 +    do { \
 345.454 +        strm->next_out = put; \
 345.455 +        strm->avail_out = left; \
 345.456 +        strm->next_in = next; \
 345.457 +        strm->avail_in = have; \
 345.458 +        state->hold = hold; \
 345.459 +        state->bits = bits; \
 345.460 +    } while (0)
 345.461 +
 345.462 +/* Clear the input bit accumulator */
 345.463 +#define INITBITS() \
 345.464 +    do { \
 345.465 +        hold = 0; \
 345.466 +        bits = 0; \
 345.467 +    } while (0)
 345.468 +
 345.469 +/* Get a byte of input into the bit accumulator, or return from inflate()
 345.470 +   if there is no input available. */
 345.471 +#define PULLBYTE() \
 345.472 +    do { \
 345.473 +        if (have == 0) goto inf_leave; \
 345.474 +        have--; \
 345.475 +        hold += (unsigned long)(*next++) << bits; \
 345.476 +        bits += 8; \
 345.477 +    } while (0)
 345.478 +
 345.479 +/* Assure that there are at least n bits in the bit accumulator.  If there is
 345.480 +   not enough available input to do that, then return from inflate(). */
 345.481 +#define NEEDBITS(n) \
 345.482 +    do { \
 345.483 +        while (bits < (unsigned)(n)) \
 345.484 +            PULLBYTE(); \
 345.485 +    } while (0)
 345.486 +
 345.487 +/* Return the low n bits of the bit accumulator (n < 16) */
 345.488 +#define BITS(n) \
 345.489 +    ((unsigned)hold & ((1U << (n)) - 1))
 345.490 +
 345.491 +/* Remove n bits from the bit accumulator */
 345.492 +#define DROPBITS(n) \
 345.493 +    do { \
 345.494 +        hold >>= (n); \
 345.495 +        bits -= (unsigned)(n); \
 345.496 +    } while (0)
 345.497 +
 345.498 +/* Remove zero to seven bits as needed to go to a byte boundary */
 345.499 +#define BYTEBITS() \
 345.500 +    do { \
 345.501 +        hold >>= bits & 7; \
 345.502 +        bits -= bits & 7; \
 345.503 +    } while (0)
 345.504 +
 345.505 +/* Reverse the bytes in a 32-bit value */
 345.506 +#define REVERSE(q) \
 345.507 +    ((((q) >> 24) & 0xff) + (((q) >> 8) & 0xff00) + \
 345.508 +     (((q) & 0xff00) << 8) + (((q) & 0xff) << 24))
 345.509 +
 345.510 +/*
 345.511 +   inflate() uses a state machine to process as much input data and generate as
 345.512 +   much output data as possible before returning.  The state machine is
 345.513 +   structured roughly as follows:
 345.514 +
 345.515 +    for (;;) switch (state) {
 345.516 +    ...
 345.517 +    case STATEn:
 345.518 +        if (not enough input data or output space to make progress)
 345.519 +            return;
 345.520 +        ... make progress ...
 345.521 +        state = STATEm;
 345.522 +        break;
 345.523 +    ...
 345.524 +    }
 345.525 +
 345.526 +   so when inflate() is called again, the same case is attempted again, and
 345.527 +   if the appropriate resources are provided, the machine proceeds to the
 345.528 +   next state.  The NEEDBITS() macro is usually the way the state evaluates
 345.529 +   whether it can proceed or should return.  NEEDBITS() does the return if
 345.530 +   the requested bits are not available.  The typical use of the BITS macros
 345.531 +   is:
 345.532 +
 345.533 +        NEEDBITS(n);
 345.534 +        ... do something with BITS(n) ...
 345.535 +        DROPBITS(n);
 345.536 +
 345.537 +   where NEEDBITS(n) either returns from inflate() if there isn't enough
 345.538 +   input left to load n bits into the accumulator, or it continues.  BITS(n)
 345.539 +   gives the low n bits in the accumulator.  When done, DROPBITS(n) drops
 345.540 +   the low n bits off the accumulator.  INITBITS() clears the accumulator
 345.541 +   and sets the number of available bits to zero.  BYTEBITS() discards just
 345.542 +   enough bits to put the accumulator on a byte boundary.  After BYTEBITS()
 345.543 +   and a NEEDBITS(8), then BITS(8) would return the next byte in the stream.
 345.544 +
 345.545 +   NEEDBITS(n) uses PULLBYTE() to get an available byte of input, or to return
 345.546 +   if there is no input available.  The decoding of variable length codes uses
 345.547 +   PULLBYTE() directly in order to pull just enough bytes to decode the next
 345.548 +   code, and no more.
 345.549 +
 345.550 +   Some states loop until they get enough input, making sure that enough
 345.551 +   state information is maintained to continue the loop where it left off
 345.552 +   if NEEDBITS() returns in the loop.  For example, want, need, and keep
 345.553 +   would all have to actually be part of the saved state in case NEEDBITS()
 345.554 +   returns:
 345.555 +
 345.556 +    case STATEw:
 345.557 +        while (want < need) {
 345.558 +            NEEDBITS(n);
 345.559 +            keep[want++] = BITS(n);
 345.560 +            DROPBITS(n);
 345.561 +        }
 345.562 +        state = STATEx;
 345.563 +    case STATEx:
 345.564 +
 345.565 +   As shown above, if the next state is also the next case, then the break
 345.566 +   is omitted.
 345.567 +
 345.568 +   A state may also return if there is not enough output space available to
 345.569 +   complete that state.  Those states are copying stored data, writing a
 345.570 +   literal byte, and copying a matching string.
 345.571 +
 345.572 +   When returning, a "goto inf_leave" is used to update the total counters,
 345.573 +   update the check value, and determine whether any progress has been made
 345.574 +   during that inflate() call in order to return the proper return code.
 345.575 +   Progress is defined as a change in either strm->avail_in or strm->avail_out.
 345.576 +   When there is a window, goto inf_leave will update the window with the last
 345.577 +   output written.  If a goto inf_leave occurs in the middle of decompression
 345.578 +   and there is no window currently, goto inf_leave will create one and copy
 345.579 +   output to the window for the next call of inflate().
 345.580 +
 345.581 +   In this implementation, the flush parameter of inflate() only affects the
 345.582 +   return code (per zlib.h).  inflate() always writes as much as possible to
 345.583 +   strm->next_out, given the space available and the provided input--the effect
 345.584 +   documented in zlib.h of Z_SYNC_FLUSH.  Furthermore, inflate() always defers
 345.585 +   the allocation of and copying into a sliding window until necessary, which
 345.586 +   provides the effect documented in zlib.h for Z_FINISH when the entire input
 345.587 +   stream available.  So the only thing the flush parameter actually does is:
 345.588 +   when flush is set to Z_FINISH, inflate() cannot return Z_OK.  Instead it
 345.589 +   will return Z_BUF_ERROR if it has not reached the end of the stream.
 345.590 + */
 345.591 +
 345.592 +int ZEXPORT inflate(strm, flush)
 345.593 +z_streamp strm;
 345.594 +int flush;
 345.595 +{
 345.596 +    struct inflate_state FAR *state;
 345.597 +    unsigned char FAR *next;    /* next input */
 345.598 +    unsigned char FAR *put;     /* next output */
 345.599 +    unsigned have, left;        /* available input and output */
 345.600 +    unsigned long hold;         /* bit buffer */
 345.601 +    unsigned bits;              /* bits in bit buffer */
 345.602 +    unsigned in, out;           /* save starting available input and output */
 345.603 +    unsigned copy;              /* number of stored or match bytes to copy */
 345.604 +    unsigned char FAR *from;    /* where to copy match bytes from */
 345.605 +    code here;                  /* current decoding table entry */
 345.606 +    code last;                  /* parent table entry */
 345.607 +    unsigned len;               /* length to copy for repeats, bits to drop */
 345.608 +    int ret;                    /* return code */
 345.609 +#ifdef GUNZIP
 345.610 +    unsigned char hbuf[4];      /* buffer for gzip header crc calculation */
 345.611 +#endif
 345.612 +    static const unsigned short order[19] = /* permutation of code lengths */
 345.613 +        {16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15};
 345.614 +
 345.615 +    if (strm == Z_NULL || strm->state == Z_NULL || strm->next_out == Z_NULL ||
 345.616 +        (strm->next_in == Z_NULL && strm->avail_in != 0))
 345.617 +        return Z_STREAM_ERROR;
 345.618 +
 345.619 +    state = (struct inflate_state FAR *)strm->state;
 345.620 +    if (state->mode == TYPE) state->mode = TYPEDO;      /* skip check */
 345.621 +    LOAD();
 345.622 +    in = have;
 345.623 +    out = left;
 345.624 +    ret = Z_OK;
 345.625 +    for (;;)
 345.626 +        switch (state->mode) {
 345.627 +        case HEAD:
 345.628 +            if (state->wrap == 0) {
 345.629 +                state->mode = TYPEDO;
 345.630 +                break;
 345.631 +            }
 345.632 +            NEEDBITS(16);
 345.633 +#ifdef GUNZIP
 345.634 +            if ((state->wrap & 2) && hold == 0x8b1f) {  /* gzip header */
 345.635 +                state->check = crc32(0L, Z_NULL, 0);
 345.636 +                CRC2(state->check, hold);
 345.637 +                INITBITS();
 345.638 +                state->mode = FLAGS;
 345.639 +                break;
 345.640 +            }
 345.641 +            state->flags = 0;           /* expect zlib header */
 345.642 +            if (state->head != Z_NULL)
 345.643 +                state->head->done = -1;
 345.644 +            if (!(state->wrap & 1) ||   /* check if zlib header allowed */
 345.645 +#else
 345.646 +            if (
 345.647 +#endif
 345.648 +                ((BITS(8) << 8) + (hold >> 8)) % 31) {
 345.649 +                strm->msg = (char *)"incorrect header check";
 345.650 +                state->mode = BAD;
 345.651 +                break;
 345.652 +            }
 345.653 +            if (BITS(4) != Z_DEFLATED) {
 345.654 +                strm->msg = (char *)"unknown compression method";
 345.655 +                state->mode = BAD;
 345.656 +                break;
 345.657 +            }
 345.658 +            DROPBITS(4);
 345.659 +            len = BITS(4) + 8;
 345.660 +            if (state->wbits == 0)
 345.661 +                state->wbits = len;
 345.662 +            else if (len > state->wbits) {
 345.663 +                strm->msg = (char *)"invalid window size";
 345.664 +                state->mode = BAD;
 345.665 +                break;
 345.666 +            }
 345.667 +            state->dmax = 1U << len;
 345.668 +            Tracev((stderr, "inflate:   zlib header ok\n"));
 345.669 +            strm->adler = state->check = adler32(0L, Z_NULL, 0);
 345.670 +            state->mode = hold & 0x200 ? DICTID : TYPE;
 345.671 +            INITBITS();
 345.672 +            break;
 345.673 +#ifdef GUNZIP
 345.674 +        case FLAGS:
 345.675 +            NEEDBITS(16);
 345.676 +            state->flags = (int)(hold);
 345.677 +            if ((state->flags & 0xff) != Z_DEFLATED) {
 345.678 +                strm->msg = (char *)"unknown compression method";
 345.679 +                state->mode = BAD;
 345.680 +                break;
 345.681 +            }
 345.682 +            if (state->flags & 0xe000) {
 345.683 +                strm->msg = (char *)"unknown header flags set";
 345.684 +                state->mode = BAD;
 345.685 +                break;
 345.686 +            }
 345.687 +            if (state->head != Z_NULL)
 345.688 +                state->head->text = (int)((hold >> 8) & 1);
 345.689 +            if (state->flags & 0x0200) CRC2(state->check, hold);
 345.690 +            INITBITS();
 345.691 +            state->mode = TIME;
 345.692 +        case TIME:
 345.693 +            NEEDBITS(32);
 345.694 +            if (state->head != Z_NULL)
 345.695 +                state->head->time = hold;
 345.696 +            if (state->flags & 0x0200) CRC4(state->check, hold);
 345.697 +            INITBITS();
 345.698 +            state->mode = OS;
 345.699 +        case OS:
 345.700 +            NEEDBITS(16);
 345.701 +            if (state->head != Z_NULL) {
 345.702 +                state->head->xflags = (int)(hold & 0xff);
 345.703 +                state->head->os = (int)(hold >> 8);
 345.704 +            }
 345.705 +            if (state->flags & 0x0200) CRC2(state->check, hold);
 345.706 +            INITBITS();
 345.707 +            state->mode = EXLEN;
 345.708 +        case EXLEN:
 345.709 +            if (state->flags & 0x0400) {
 345.710 +                NEEDBITS(16);
 345.711 +                state->length = (unsigned)(hold);
 345.712 +                if (state->head != Z_NULL)
 345.713 +                    state->head->extra_len = (unsigned)hold;
 345.714 +                if (state->flags & 0x0200) CRC2(state->check, hold);
 345.715 +                INITBITS();
 345.716 +            }
 345.717 +            else if (state->head != Z_NULL)
 345.718 +                state->head->extra = Z_NULL;
 345.719 +            state->mode = EXTRA;
 345.720 +        case EXTRA:
 345.721 +            if (state->flags & 0x0400) {
 345.722 +                copy = state->length;
 345.723 +                if (copy > have) copy = have;
 345.724 +                if (copy) {
 345.725 +                    if (state->head != Z_NULL &&
 345.726 +                        state->head->extra != Z_NULL) {
 345.727 +                        len = state->head->extra_len - state->length;
 345.728 +                        zmemcpy(state->head->extra + len, next,
 345.729 +                                len + copy > state->head->extra_max ?
 345.730 +                                state->head->extra_max - len : copy);
 345.731 +                    }
 345.732 +                    if (state->flags & 0x0200)
 345.733 +                        state->check = crc32(state->check, next, copy);
 345.734 +                    have -= copy;
 345.735 +                    next += copy;
 345.736 +                    state->length -= copy;
 345.737 +                }
 345.738 +                if (state->length) goto inf_leave;
 345.739 +            }
 345.740 +            state->length = 0;
 345.741 +            state->mode = NAME;
 345.742 +        case NAME:
 345.743 +            if (state->flags & 0x0800) {
 345.744 +                if (have == 0) goto inf_leave;
 345.745 +                copy = 0;
 345.746 +                do {
 345.747 +                    len = (unsigned)(next[copy++]);
 345.748 +                    if (state->head != Z_NULL &&
 345.749 +                            state->head->name != Z_NULL &&
 345.750 +                            state->length < state->head->name_max)
 345.751 +                        state->head->name[state->length++] = len;
 345.752 +                } while (len && copy < have);
 345.753 +                if (state->flags & 0x0200)
 345.754 +                    state->check = crc32(state->check, next, copy);
 345.755 +                have -= copy;
 345.756 +                next += copy;
 345.757 +                if (len) goto inf_leave;
 345.758 +            }
 345.759 +            else if (state->head != Z_NULL)
 345.760 +                state->head->name = Z_NULL;
 345.761 +            state->length = 0;
 345.762 +            state->mode = COMMENT;
 345.763 +        case COMMENT:
 345.764 +            if (state->flags & 0x1000) {
 345.765 +                if (have == 0) goto inf_leave;
 345.766 +                copy = 0;
 345.767 +                do {
 345.768 +                    len = (unsigned)(next[copy++]);
 345.769 +                    if (state->head != Z_NULL &&
 345.770 +                            state->head->comment != Z_NULL &&
 345.771 +                            state->length < state->head->comm_max)
 345.772 +                        state->head->comment[state->length++] = len;
 345.773 +                } while (len && copy < have);
 345.774 +                if (state->flags & 0x0200)
 345.775 +                    state->check = crc32(state->check, next, copy);
 345.776 +                have -= copy;
 345.777 +                next += copy;
 345.778 +                if (len) goto inf_leave;
 345.779 +            }
 345.780 +            else if (state->head != Z_NULL)
 345.781 +                state->head->comment = Z_NULL;
 345.782 +            state->mode = HCRC;
 345.783 +        case HCRC:
 345.784 +            if (state->flags & 0x0200) {
 345.785 +                NEEDBITS(16);
 345.786 +                if (hold != (state->check & 0xffff)) {
 345.787 +                    strm->msg = (char *)"header crc mismatch";
 345.788 +                    state->mode = BAD;
 345.789 +                    break;
 345.790 +                }
 345.791 +                INITBITS();
 345.792 +            }
 345.793 +            if (state->head != Z_NULL) {
 345.794 +                state->head->hcrc = (int)((state->flags >> 9) & 1);
 345.795 +                state->head->done = 1;
 345.796 +            }
 345.797 +            strm->adler = state->check = crc32(0L, Z_NULL, 0);
 345.798 +            state->mode = TYPE;
 345.799 +            break;
 345.800 +#endif
 345.801 +        case DICTID:
 345.802 +            NEEDBITS(32);
 345.803 +            strm->adler = state->check = REVERSE(hold);
 345.804 +            INITBITS();
 345.805 +            state->mode = DICT;
 345.806 +        case DICT:
 345.807 +            if (state->havedict == 0) {
 345.808 +                RESTORE();
 345.809 +                return Z_NEED_DICT;
 345.810 +            }
 345.811 +            strm->adler = state->check = adler32(0L, Z_NULL, 0);
 345.812 +            state->mode = TYPE;
 345.813 +        case TYPE:
 345.814 +            if (flush == Z_BLOCK || flush == Z_TREES) goto inf_leave;
 345.815 +        case TYPEDO:
 345.816 +            if (state->last) {
 345.817 +                BYTEBITS();
 345.818 +                state->mode = CHECK;
 345.819 +                break;
 345.820 +            }
 345.821 +            NEEDBITS(3);
 345.822 +            state->last = BITS(1);
 345.823 +            DROPBITS(1);
 345.824 +            switch (BITS(2)) {
 345.825 +            case 0:                             /* stored block */
 345.826 +                Tracev((stderr, "inflate:     stored block%s\n",
 345.827 +                        state->last ? " (last)" : ""));
 345.828 +                state->mode = STORED;
 345.829 +                break;
 345.830 +            case 1:                             /* fixed block */
 345.831 +                fixedtables(state);
 345.832 +                Tracev((stderr, "inflate:     fixed codes block%s\n",
 345.833 +                        state->last ? " (last)" : ""));
 345.834 +                state->mode = LEN_;             /* decode codes */
 345.835 +                if (flush == Z_TREES) {
 345.836 +                    DROPBITS(2);
 345.837 +                    goto inf_leave;
 345.838 +                }
 345.839 +                break;
 345.840 +            case 2:                             /* dynamic block */
 345.841 +                Tracev((stderr, "inflate:     dynamic codes block%s\n",
 345.842 +                        state->last ? " (last)" : ""));
 345.843 +                state->mode = TABLE;
 345.844 +                break;
 345.845 +            case 3:
 345.846 +                strm->msg = (char *)"invalid block type";
 345.847 +                state->mode = BAD;
 345.848 +            }
 345.849 +            DROPBITS(2);
 345.850 +            break;
 345.851 +        case STORED:
 345.852 +            BYTEBITS();                         /* go to byte boundary */
 345.853 +            NEEDBITS(32);
 345.854 +            if ((hold & 0xffff) != ((hold >> 16) ^ 0xffff)) {
 345.855 +                strm->msg = (char *)"invalid stored block lengths";
 345.856 +                state->mode = BAD;
 345.857 +                break;
 345.858 +            }
 345.859 +            state->length = (unsigned)hold & 0xffff;
 345.860 +            Tracev((stderr, "inflate:       stored length %u\n",
 345.861 +                    state->length));
 345.862 +            INITBITS();
 345.863 +            state->mode = COPY_;
 345.864 +            if (flush == Z_TREES) goto inf_leave;
 345.865 +        case COPY_:
 345.866 +            state->mode = COPY;
 345.867 +        case COPY:
 345.868 +            copy = state->length;
 345.869 +            if (copy) {
 345.870 +                if (copy > have) copy = have;
 345.871 +                if (copy > left) copy = left;
 345.872 +                if (copy == 0) goto inf_leave;
 345.873 +                zmemcpy(put, next, copy);
 345.874 +                have -= copy;
 345.875 +                next += copy;
 345.876 +                left -= copy;
 345.877 +                put += copy;
 345.878 +                state->length -= copy;
 345.879 +                break;
 345.880 +            }
 345.881 +            Tracev((stderr, "inflate:       stored end\n"));
 345.882 +            state->mode = TYPE;
 345.883 +            break;
 345.884 +        case TABLE:
 345.885 +            NEEDBITS(14);
 345.886 +            state->nlen = BITS(5) + 257;
 345.887 +            DROPBITS(5);
 345.888 +            state->ndist = BITS(5) + 1;
 345.889 +            DROPBITS(5);
 345.890 +            state->ncode = BITS(4) + 4;
 345.891 +            DROPBITS(4);
 345.892 +#ifndef PKZIP_BUG_WORKAROUND
 345.893 +            if (state->nlen > 286 || state->ndist > 30) {
 345.894 +                strm->msg = (char *)"too many length or distance symbols";
 345.895 +                state->mode = BAD;
 345.896 +                break;
 345.897 +            }
 345.898 +#endif
 345.899 +            Tracev((stderr, "inflate:       table sizes ok\n"));
 345.900 +            state->have = 0;
 345.901 +            state->mode = LENLENS;
 345.902 +        case LENLENS:
 345.903 +            while (state->have < state->ncode) {
 345.904 +                NEEDBITS(3);
 345.905 +                state->lens[order[state->have++]] = (unsigned short)BITS(3);
 345.906 +                DROPBITS(3);
 345.907 +            }
 345.908 +            while (state->have < 19)
 345.909 +                state->lens[order[state->have++]] = 0;
 345.910 +            state->next = state->codes;
 345.911 +            state->lencode = (code const FAR *)(state->next);
 345.912 +            state->lenbits = 7;
 345.913 +            ret = inflate_table(CODES, state->lens, 19, &(state->next),
 345.914 +                                &(state->lenbits), state->work);
 345.915 +            if (ret) {
 345.916 +                strm->msg = (char *)"invalid code lengths set";
 345.917 +                state->mode = BAD;
 345.918 +                break;
 345.919 +            }
 345.920 +            Tracev((stderr, "inflate:       code lengths ok\n"));
 345.921 +            state->have = 0;
 345.922 +            state->mode = CODELENS;
 345.923 +        case CODELENS:
 345.924 +            while (state->have < state->nlen + state->ndist) {
 345.925 +                for (;;) {
 345.926 +                    here = state->lencode[BITS(state->lenbits)];
 345.927 +                    if ((unsigned)(here.bits) <= bits) break;
 345.928 +                    PULLBYTE();
 345.929 +                }
 345.930 +                if (here.val < 16) {
 345.931 +                    NEEDBITS(here.bits);
 345.932 +                    DROPBITS(here.bits);
 345.933 +                    state->lens[state->have++] = here.val;
 345.934 +                }
 345.935 +                else {
 345.936 +                    if (here.val == 16) {
 345.937 +                        NEEDBITS(here.bits + 2);
 345.938 +                        DROPBITS(here.bits);
 345.939 +                        if (state->have == 0) {
 345.940 +                            strm->msg = (char *)"invalid bit length repeat";
 345.941 +                            state->mode = BAD;
 345.942 +                            break;
 345.943 +                        }
 345.944 +                        len = state->lens[state->have - 1];
 345.945 +                        copy = 3 + BITS(2);
 345.946 +                        DROPBITS(2);
 345.947 +                    }
 345.948 +                    else if (here.val == 17) {
 345.949 +                        NEEDBITS(here.bits + 3);
 345.950 +                        DROPBITS(here.bits);
 345.951 +                        len = 0;
 345.952 +                        copy = 3 + BITS(3);
 345.953 +                        DROPBITS(3);
 345.954 +                    }
 345.955 +                    else {
 345.956 +                        NEEDBITS(here.bits + 7);
 345.957 +                        DROPBITS(here.bits);
 345.958 +                        len = 0;
 345.959 +                        copy = 11 + BITS(7);
 345.960 +                        DROPBITS(7);
 345.961 +                    }
 345.962 +                    if (state->have + copy > state->nlen + state->ndist) {
 345.963 +                        strm->msg = (char *)"invalid bit length repeat";
 345.964 +                        state->mode = BAD;
 345.965 +                        break;
 345.966 +                    }
 345.967 +                    while (copy--)
 345.968 +                        state->lens[state->have++] = (unsigned short)len;
 345.969 +                }
 345.970 +            }
 345.971 +
 345.972 +            /* handle error breaks in while */
 345.973 +            if (state->mode == BAD) break;
 345.974 +
 345.975 +            /* check for end-of-block code (better have one) */
 345.976 +            if (state->lens[256] == 0) {
 345.977 +                strm->msg = (char *)"invalid code -- missing end-of-block";
 345.978 +                state->mode = BAD;
 345.979 +                break;
 345.980 +            }
 345.981 +
 345.982 +            /* build code tables -- note: do not change the lenbits or distbits
 345.983 +               values here (9 and 6) without reading the comments in inftrees.h
 345.984 +               concerning the ENOUGH constants, which depend on those values */
 345.985 +            state->next = state->codes;
 345.986 +            state->lencode = (code const FAR *)(state->next);
 345.987 +            state->lenbits = 9;
 345.988 +            ret = inflate_table(LENS, state->lens, state->nlen, &(state->next),
 345.989 +                                &(state->lenbits), state->work);
 345.990 +            if (ret) {
 345.991 +                strm->msg = (char *)"invalid literal/lengths set";
 345.992 +                state->mode = BAD;
 345.993 +                break;
 345.994 +            }
 345.995 +            state->distcode = (code const FAR *)(state->next);
 345.996 +            state->distbits = 6;
 345.997 +            ret = inflate_table(DISTS, state->lens + state->nlen, state->ndist,
 345.998 +                            &(state->next), &(state->distbits), state->work);
 345.999 +            if (ret) {
345.1000 +                strm->msg = (char *)"invalid distances set";
345.1001 +                state->mode = BAD;
345.1002 +                break;
345.1003 +            }
345.1004 +            Tracev((stderr, "inflate:       codes ok\n"));
345.1005 +            state->mode = LEN_;
345.1006 +            if (flush == Z_TREES) goto inf_leave;
345.1007 +        case LEN_:
345.1008 +            state->mode = LEN;
345.1009 +        case LEN:
345.1010 +            if (have >= 6 && left >= 258) {
345.1011 +                RESTORE();
345.1012 +                inflate_fast(strm, out);
345.1013 +                LOAD();
345.1014 +                if (state->mode == TYPE)
345.1015 +                    state->back = -1;
345.1016 +                break;
345.1017 +            }
345.1018 +            state->back = 0;
345.1019 +            for (;;) {
345.1020 +                here = state->lencode[BITS(state->lenbits)];
345.1021 +                if ((unsigned)(here.bits) <= bits) break;
345.1022 +                PULLBYTE();
345.1023 +            }
345.1024 +            if (here.op && (here.op & 0xf0) == 0) {
345.1025 +                last = here;
345.1026 +                for (;;) {
345.1027 +                    here = state->lencode[last.val +
345.1028 +                            (BITS(last.bits + last.op) >> last.bits)];
345.1029 +                    if ((unsigned)(last.bits + here.bits) <= bits) break;
345.1030 +                    PULLBYTE();
345.1031 +                }
345.1032 +                DROPBITS(last.bits);
345.1033 +                state->back += last.bits;
345.1034 +            }
345.1035 +            DROPBITS(here.bits);
345.1036 +            state->back += here.bits;
345.1037 +            state->length = (unsigned)here.val;
345.1038 +            if ((int)(here.op) == 0) {
345.1039 +                Tracevv((stderr, here.val >= 0x20 && here.val < 0x7f ?
345.1040 +                        "inflate:         literal '%c'\n" :
345.1041 +                        "inflate:         literal 0x%02x\n", here.val));
345.1042 +                state->mode = LIT;
345.1043 +                break;
345.1044 +            }
345.1045 +            if (here.op & 32) {
345.1046 +                Tracevv((stderr, "inflate:         end of block\n"));
345.1047 +                state->back = -1;
345.1048 +                state->mode = TYPE;
345.1049 +                break;
345.1050 +            }
345.1051 +            if (here.op & 64) {
345.1052 +                strm->msg = (char *)"invalid literal/length code";
345.1053 +                state->mode = BAD;
345.1054 +                break;
345.1055 +            }
345.1056 +            state->extra = (unsigned)(here.op) & 15;
345.1057 +            state->mode = LENEXT;
345.1058 +        case LENEXT:
345.1059 +            if (state->extra) {
345.1060 +                NEEDBITS(state->extra);
345.1061 +                state->length += BITS(state->extra);
345.1062 +                DROPBITS(state->extra);
345.1063 +                state->back += state->extra;
345.1064 +            }
345.1065 +            Tracevv((stderr, "inflate:         length %u\n", state->length));
345.1066 +            state->was = state->length;
345.1067 +            state->mode = DIST;
345.1068 +        case DIST:
345.1069 +            for (;;) {
345.1070 +                here = state->distcode[BITS(state->distbits)];
345.1071 +                if ((unsigned)(here.bits) <= bits) break;
345.1072 +                PULLBYTE();
345.1073 +            }
345.1074 +            if ((here.op & 0xf0) == 0) {
345.1075 +                last = here;
345.1076 +                for (;;) {
345.1077 +                    here = state->distcode[last.val +
345.1078 +                            (BITS(last.bits + last.op) >> last.bits)];
345.1079 +                    if ((unsigned)(last.bits + here.bits) <= bits) break;
345.1080 +                    PULLBYTE();
345.1081 +                }
345.1082 +                DROPBITS(last.bits);
345.1083 +                state->back += last.bits;
345.1084 +            }
345.1085 +            DROPBITS(here.bits);
345.1086 +            state->back += here.bits;
345.1087 +            if (here.op & 64) {
345.1088 +                strm->msg = (char *)"invalid distance code";
345.1089 +                state->mode = BAD;
345.1090 +                break;
345.1091 +            }
345.1092 +            state->offset = (unsigned)here.val;
345.1093 +            state->extra = (unsigned)(here.op) & 15;
345.1094 +            state->mode = DISTEXT;
345.1095 +        case DISTEXT:
345.1096 +            if (state->extra) {
345.1097 +                NEEDBITS(state->extra);
345.1098 +                state->offset += BITS(state->extra);
345.1099 +                DROPBITS(state->extra);
345.1100 +                state->back += state->extra;
345.1101 +            }
345.1102 +#ifdef INFLATE_STRICT
345.1103 +            if (state->offset > state->dmax) {
345.1104 +                strm->msg = (char *)"invalid distance too far back";
345.1105 +                state->mode = BAD;
345.1106 +                break;
345.1107 +            }
345.1108 +#endif
345.1109 +            Tracevv((stderr, "inflate:         distance %u\n", state->offset));
345.1110 +            state->mode = MATCH;
345.1111 +        case MATCH:
345.1112 +            if (left == 0) goto inf_leave;
345.1113 +            copy = out - left;
345.1114 +            if (state->offset > copy) {         /* copy from window */
345.1115 +                copy = state->offset - copy;
345.1116 +                if (copy > state->whave) {
345.1117 +                    if (state->sane) {
345.1118 +                        strm->msg = (char *)"invalid distance too far back";
345.1119 +                        state->mode = BAD;
345.1120 +                        break;
345.1121 +                    }
345.1122 +#ifdef INFLATE_ALLOW_INVALID_DISTANCE_TOOFAR_ARRR
345.1123 +                    Trace((stderr, "inflate.c too far\n"));
345.1124 +                    copy -= state->whave;
345.1125 +                    if (copy > state->length) copy = state->length;
345.1126 +                    if (copy > left) copy = left;
345.1127 +                    left -= copy;
345.1128 +                    state->length -= copy;
345.1129 +                    do {
345.1130 +                        *put++ = 0;
345.1131 +                    } while (--copy);
345.1132 +                    if (state->length == 0) state->mode = LEN;
345.1133 +                    break;
345.1134 +#endif
345.1135 +                }
345.1136 +                if (copy > state->wnext) {
345.1137 +                    copy -= state->wnext;
345.1138 +                    from = state->window + (state->wsize - copy);
345.1139 +                }
345.1140 +                else
345.1141 +                    from = state->window + (state->wnext - copy);
345.1142 +                if (copy > state->length) copy = state->length;
345.1143 +            }
345.1144 +            else {                              /* copy from output */
345.1145 +                from = put - state->offset;
345.1146 +                copy = state->length;
345.1147 +            }
345.1148 +            if (copy > left) copy = left;
345.1149 +            left -= copy;
345.1150 +            state->length -= copy;
345.1151 +            do {
345.1152 +                *put++ = *from++;
345.1153 +            } while (--copy);
345.1154 +            if (state->length == 0) state->mode = LEN;
345.1155 +            break;
345.1156 +        case LIT:
345.1157 +            if (left == 0) goto inf_leave;
345.1158 +            *put++ = (unsigned char)(state->length);
345.1159 +            left--;
345.1160 +            state->mode = LEN;
345.1161 +            break;
345.1162 +        case CHECK:
345.1163 +            if (state->wrap) {
345.1164 +                NEEDBITS(32);
345.1165 +                out -= left;
345.1166 +                strm->total_out += out;
345.1167 +                state->total += out;
345.1168 +                if (out)
345.1169 +                    strm->adler = state->check =
345.1170 +                        UPDATE(state->check, put - out, out);
345.1171 +                out = left;
345.1172 +                if ((
345.1173 +#ifdef GUNZIP
345.1174 +                     state->flags ? hold :
345.1175 +#endif
345.1176 +                     REVERSE(hold)) != state->check) {
345.1177 +                    strm->msg = (char *)"incorrect data check";
345.1178 +                    state->mode = BAD;
345.1179 +                    break;
345.1180 +                }
345.1181 +                INITBITS();
345.1182 +                Tracev((stderr, "inflate:   check matches trailer\n"));
345.1183 +            }
345.1184 +#ifdef GUNZIP
345.1185 +            state->mode = LENGTH;
345.1186 +        case LENGTH:
345.1187 +            if (state->wrap && state->flags) {
345.1188 +                NEEDBITS(32);
345.1189 +                if (hold != (state->total & 0xffffffffUL)) {
345.1190 +                    strm->msg = (char *)"incorrect length check";
345.1191 +                    state->mode = BAD;
345.1192 +                    break;
345.1193 +                }
345.1194 +                INITBITS();
345.1195 +                Tracev((stderr, "inflate:   length matches trailer\n"));
345.1196 +            }
345.1197 +#endif
345.1198 +            state->mode = DONE;
345.1199 +        case DONE:
345.1200 +            ret = Z_STREAM_END;
345.1201 +            goto inf_leave;
345.1202 +        case BAD:
345.1203 +            ret = Z_DATA_ERROR;
345.1204 +            goto inf_leave;
345.1205 +        case MEM:
345.1206 +            return Z_MEM_ERROR;
345.1207 +        case SYNC:
345.1208 +        default:
345.1209 +            return Z_STREAM_ERROR;
345.1210 +        }
345.1211 +
345.1212 +    /*
345.1213 +       Return from inflate(), updating the total counts and the check value.
345.1214 +       If there was no progress during the inflate() call, return a buffer
345.1215 +       error.  Call updatewindow() to create and/or update the window state.
345.1216 +       Note: a memory error from inflate() is non-recoverable.
345.1217 +     */
345.1218 +  inf_leave:
345.1219 +    RESTORE();
345.1220 +    if (state->wsize || (state->mode < CHECK && out != strm->avail_out))
345.1221 +        if (updatewindow(strm, out)) {
345.1222 +            state->mode = MEM;
345.1223 +            return Z_MEM_ERROR;
345.1224 +        }
345.1225 +    in -= strm->avail_in;
345.1226 +    out -= strm->avail_out;
345.1227 +    strm->total_in += in;
345.1228 +    strm->total_out += out;
345.1229 +    state->total += out;
345.1230 +    if (state->wrap && out)
345.1231 +        strm->adler = state->check =
345.1232 +            UPDATE(state->check, strm->next_out - out, out);
345.1233 +    strm->data_type = state->bits + (state->last ? 64 : 0) +
345.1234 +                      (state->mode == TYPE ? 128 : 0) +
345.1235 +                      (state->mode == LEN_ || state->mode == COPY_ ? 256 : 0);
345.1236 +    if (((in == 0 && out == 0) || flush == Z_FINISH) && ret == Z_OK)
345.1237 +        ret = Z_BUF_ERROR;
345.1238 +    return ret;
345.1239 +}
345.1240 +
345.1241 +int ZEXPORT inflateEnd(strm)
345.1242 +z_streamp strm;
345.1243 +{
345.1244 +    struct inflate_state FAR *state;
345.1245 +    if (strm == Z_NULL || strm->state == Z_NULL || strm->zfree == (free_func)0)
345.1246 +        return Z_STREAM_ERROR;
345.1247 +    state = (struct inflate_state FAR *)strm->state;
345.1248 +    if (state->window != Z_NULL) ZFREE(strm, state->window);
345.1249 +    ZFREE(strm, strm->state);
345.1250 +    strm->state = Z_NULL;
345.1251 +    Tracev((stderr, "inflate: end\n"));
345.1252 +    return Z_OK;
345.1253 +}
345.1254 +
345.1255 +int ZEXPORT inflateSetDictionary(strm, dictionary, dictLength)
345.1256 +z_streamp strm;
345.1257 +const Bytef *dictionary;
345.1258 +uInt dictLength;
345.1259 +{
345.1260 +    struct inflate_state FAR *state;
345.1261 +    unsigned long id;
345.1262 +
345.1263 +    /* check state */
345.1264 +    if (strm == Z_NULL || strm->state == Z_NULL) return Z_STREAM_ERROR;
345.1265 +    state = (struct inflate_state FAR *)strm->state;
345.1266 +    if (state->wrap != 0 && state->mode != DICT)
345.1267 +        return Z_STREAM_ERROR;
345.1268 +
345.1269 +    /* check for correct dictionary id */
345.1270 +    if (state->mode == DICT) {
345.1271 +        id = adler32(0L, Z_NULL, 0);
345.1272 +        id = adler32(id, dictionary, dictLength);
345.1273 +        if (id != state->check)
345.1274 +            return Z_DATA_ERROR;
345.1275 +    }
345.1276 +
345.1277 +    /* copy dictionary to window */
345.1278 +    if (updatewindow(strm, strm->avail_out)) {
345.1279 +        state->mode = MEM;
345.1280 +        return Z_MEM_ERROR;
345.1281 +    }
345.1282 +    if (dictLength > state->wsize) {
345.1283 +        zmemcpy(state->window, dictionary + dictLength - state->wsize,
345.1284 +                state->wsize);
345.1285 +        state->whave = state->wsize;
345.1286 +    }
345.1287 +    else {
345.1288 +        zmemcpy(state->window + state->wsize - dictLength, dictionary,
345.1289 +                dictLength);
345.1290 +        state->whave = dictLength;
345.1291 +    }
345.1292 +    state->havedict = 1;
345.1293 +    Tracev((stderr, "inflate:   dictionary set\n"));
345.1294 +    return Z_OK;
345.1295 +}
345.1296 +
345.1297 +int ZEXPORT inflateGetHeader(strm, head)
345.1298 +z_streamp strm;
345.1299 +gz_headerp head;
345.1300 +{
345.1301 +    struct inflate_state FAR *state;
345.1302 +
345.1303 +    /* check state */
345.1304 +    if (strm == Z_NULL || strm->state == Z_NULL) return Z_STREAM_ERROR;
345.1305 +    state = (struct inflate_state FAR *)strm->state;
345.1306 +    if ((state->wrap & 2) == 0) return Z_STREAM_ERROR;
345.1307 +
345.1308 +    /* save header structure */
345.1309 +    state->head = head;
345.1310 +    head->done = 0;
345.1311 +    return Z_OK;
345.1312 +}
345.1313 +
345.1314 +/*
345.1315 +   Search buf[0..len-1] for the pattern: 0, 0, 0xff, 0xff.  Return when found
345.1316 +   or when out of input.  When called, *have is the number of pattern bytes
345.1317 +   found in order so far, in 0..3.  On return *have is updated to the new
345.1318 +   state.  If on return *have equals four, then the pattern was found and the
345.1319 +   return value is how many bytes were read including the last byte of the
345.1320 +   pattern.  If *have is less than four, then the pattern has not been found
345.1321 +   yet and the return value is len.  In the latter case, syncsearch() can be
345.1322 +   called again with more data and the *have state.  *have is initialized to
345.1323 +   zero for the first call.
345.1324 + */
345.1325 +local unsigned syncsearch(have, buf, len)
345.1326 +unsigned FAR *have;
345.1327 +unsigned char FAR *buf;
345.1328 +unsigned len;
345.1329 +{
345.1330 +    unsigned got;
345.1331 +    unsigned next;
345.1332 +
345.1333 +    got = *have;
345.1334 +    next = 0;
345.1335 +    while (next < len && got < 4) {
345.1336 +        if ((int)(buf[next]) == (got < 2 ? 0 : 0xff))
345.1337 +            got++;
345.1338 +        else if (buf[next])
345.1339 +            got = 0;
345.1340 +        else
345.1341 +            got = 4 - got;
345.1342 +        next++;
345.1343 +    }
345.1344 +    *have = got;
345.1345 +    return next;
345.1346 +}
345.1347 +
345.1348 +int ZEXPORT inflateSync(strm)
345.1349 +z_streamp strm;
345.1350 +{
345.1351 +    unsigned len;               /* number of bytes to look at or looked at */
345.1352 +    unsigned long in, out;      /* temporary to save total_in and total_out */
345.1353 +    unsigned char buf[4];       /* to restore bit buffer to byte string */
345.1354 +    struct inflate_state FAR *state;
345.1355 +
345.1356 +    /* check parameters */
345.1357 +    if (strm == Z_NULL || strm->state == Z_NULL) return Z_STREAM_ERROR;
345.1358 +    state = (struct inflate_state FAR *)strm->state;
345.1359 +    if (strm->avail_in == 0 && state->bits < 8) return Z_BUF_ERROR;
345.1360 +
345.1361 +    /* if first time, start search in bit buffer */
345.1362 +    if (state->mode != SYNC) {
345.1363 +        state->mode = SYNC;
345.1364 +        state->hold <<= state->bits & 7;
345.1365 +        state->bits -= state->bits & 7;
345.1366 +        len = 0;
345.1367 +        while (state->bits >= 8) {
345.1368 +            buf[len++] = (unsigned char)(state->hold);
345.1369 +            state->hold >>= 8;
345.1370 +            state->bits -= 8;
345.1371 +        }
345.1372 +        state->have = 0;
345.1373 +        syncsearch(&(state->have), buf, len);
345.1374 +    }
345.1375 +
345.1376 +    /* search available input */
345.1377 +    len = syncsearch(&(state->have), strm->next_in, strm->avail_in);
345.1378 +    strm->avail_in -= len;
345.1379 +    strm->next_in += len;
345.1380 +    strm->total_in += len;
345.1381 +
345.1382 +    /* return no joy or set up to restart inflate() on a new block */
345.1383 +    if (state->have != 4) return Z_DATA_ERROR;
345.1384 +    in = strm->total_in;  out = strm->total_out;
345.1385 +    inflateReset(strm);
345.1386 +    strm->total_in = in;  strm->total_out = out;
345.1387 +    state->mode = TYPE;
345.1388 +    return Z_OK;
345.1389 +}
345.1390 +
345.1391 +/*
345.1392 +   Returns true if inflate is currently at the end of a block generated by
345.1393 +   Z_SYNC_FLUSH or Z_FULL_FLUSH. This function is used by one PPP
345.1394 +   implementation to provide an additional safety check. PPP uses
345.1395 +   Z_SYNC_FLUSH but removes the length bytes of the resulting empty stored
345.1396 +   block. When decompressing, PPP checks that at the end of input packet,
345.1397 +   inflate is waiting for these length bytes.
345.1398 + */
345.1399 +int ZEXPORT inflateSyncPoint(strm)
345.1400 +z_streamp strm;
345.1401 +{
345.1402 +    struct inflate_state FAR *state;
345.1403 +
345.1404 +    if (strm == Z_NULL || strm->state == Z_NULL) return Z_STREAM_ERROR;
345.1405 +    state = (struct inflate_state FAR *)strm->state;
345.1406 +    return state->mode == STORED && state->bits == 0;
345.1407 +}
345.1408 +
345.1409 +int ZEXPORT inflateCopy(dest, source)
345.1410 +z_streamp dest;
345.1411 +z_streamp source;
345.1412 +{
345.1413 +    struct inflate_state FAR *state;
345.1414 +    struct inflate_state FAR *copy;
345.1415 +    unsigned char FAR *window;
345.1416 +    unsigned wsize;
345.1417 +
345.1418 +    /* check input */
345.1419 +    if (dest == Z_NULL || source == Z_NULL || source->state == Z_NULL ||
345.1420 +        source->zalloc == (alloc_func)0 || source->zfree == (free_func)0)
345.1421 +        return Z_STREAM_ERROR;
345.1422 +    state = (struct inflate_state FAR *)source->state;
345.1423 +
345.1424 +    /* allocate space */
345.1425 +    copy = (struct inflate_state FAR *)
345.1426 +           ZALLOC(source, 1, sizeof(struct inflate_state));
345.1427 +    if (copy == Z_NULL) return Z_MEM_ERROR;
345.1428 +    window = Z_NULL;
345.1429 +    if (state->window != Z_NULL) {
345.1430 +        window = (unsigned char FAR *)
345.1431 +                 ZALLOC(source, 1U << state->wbits, sizeof(unsigned char));
345.1432 +        if (window == Z_NULL) {
345.1433 +            ZFREE(source, copy);
345.1434 +            return Z_MEM_ERROR;
345.1435 +        }
345.1436 +    }
345.1437 +
345.1438 +    /* copy state */
345.1439 +    zmemcpy(dest, source, sizeof(z_stream));
345.1440 +    zmemcpy(copy, state, sizeof(struct inflate_state));
345.1441 +    if (state->lencode >= state->codes &&
345.1442 +        state->lencode <= state->codes + ENOUGH - 1) {
345.1443 +        copy->lencode = copy->codes + (state->lencode - state->codes);
345.1444 +        copy->distcode = copy->codes + (state->distcode - state->codes);
345.1445 +    }
345.1446 +    copy->next = copy->codes + (state->next - state->codes);
345.1447 +    if (window != Z_NULL) {
345.1448 +        wsize = 1U << state->wbits;
345.1449 +        zmemcpy(window, state->window, wsize);
345.1450 +    }
345.1451 +    copy->window = window;
345.1452 +    dest->state = (struct internal_state FAR *)copy;
345.1453 +    return Z_OK;
345.1454 +}
345.1455 +
345.1456 +int ZEXPORT inflateUndermine(strm, subvert)
345.1457 +z_streamp strm;
345.1458 +int subvert;
345.1459 +{
345.1460 +    struct inflate_state FAR *state;
345.1461 +
345.1462 +    if (strm == Z_NULL || strm->state == Z_NULL) return Z_STREAM_ERROR;
345.1463 +    state = (struct inflate_state FAR *)strm->state;
345.1464 +    state->sane = !subvert;
345.1465 +#ifdef INFLATE_ALLOW_INVALID_DISTANCE_TOOFAR_ARRR
345.1466 +    return Z_OK;
345.1467 +#else
345.1468 +    state->sane = 1;
345.1469 +    return Z_DATA_ERROR;
345.1470 +#endif
345.1471 +}
345.1472 +
345.1473 +long ZEXPORT inflateMark(strm)
345.1474 +z_streamp strm;
345.1475 +{
345.1476 +    struct inflate_state FAR *state;
345.1477 +
345.1478 +    if (strm == Z_NULL || strm->state == Z_NULL) return -1L << 16;
345.1479 +    state = (struct inflate_state FAR *)strm->state;
345.1480 +    return ((long)(state->back) << 16) +
345.1481 +        (state->mode == COPY ? state->length :
345.1482 +            (state->mode == MATCH ? state->was - state->length : 0));
345.1483 +}
   346.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
   346.2 +++ b/deps/glpk/src/zlib/inflate.h	Sun Nov 06 20:59:10 2011 +0100
   346.3 @@ -0,0 +1,122 @@
   346.4 +/* inflate.h -- internal inflate state definition
   346.5 + * Copyright (C) 1995-2009 Mark Adler
   346.6 + * For conditions of distribution and use, see copyright notice in zlib.h
   346.7 + */
   346.8 +
   346.9 +/* WARNING: this file should *not* be used by applications. It is
  346.10 +   part of the implementation of the compression library and is
  346.11 +   subject to change. Applications should only use zlib.h.
  346.12 + */
  346.13 +
  346.14 +/* define NO_GZIP when compiling if you want to disable gzip header and
  346.15 +   trailer decoding by inflate().  NO_GZIP would be used to avoid linking in
  346.16 +   the crc code when it is not needed.  For shared libraries, gzip decoding
  346.17 +   should be left enabled. */
  346.18 +#ifndef NO_GZIP
  346.19 +#  define GUNZIP
  346.20 +#endif
  346.21 +
  346.22 +/* Possible inflate modes between inflate() calls */
  346.23 +typedef enum {
  346.24 +    HEAD,       /* i: waiting for magic header */
  346.25 +    FLAGS,      /* i: waiting for method and flags (gzip) */
  346.26 +    TIME,       /* i: waiting for modification time (gzip) */
  346.27 +    OS,         /* i: waiting for extra flags and operating system (gzip) */
  346.28 +    EXLEN,      /* i: waiting for extra length (gzip) */
  346.29 +    EXTRA,      /* i: waiting for extra bytes (gzip) */
  346.30 +    NAME,       /* i: waiting for end of file name (gzip) */
  346.31 +    COMMENT,    /* i: waiting for end of comment (gzip) */
  346.32 +    HCRC,       /* i: waiting for header crc (gzip) */
  346.33 +    DICTID,     /* i: waiting for dictionary check value */
  346.34 +    DICT,       /* waiting for inflateSetDictionary() call */
  346.35 +        TYPE,       /* i: waiting for type bits, including last-flag bit */
  346.36 +        TYPEDO,     /* i: same, but skip check to exit inflate on new block */
  346.37 +        STORED,     /* i: waiting for stored size (length and complement) */
  346.38 +        COPY_,      /* i/o: same as COPY below, but only first time in */
  346.39 +        COPY,       /* i/o: waiting for input or output to copy stored block */
  346.40 +        TABLE,      /* i: waiting for dynamic block table lengths */
  346.41 +        LENLENS,    /* i: waiting for code length code lengths */
  346.42 +        CODELENS,   /* i: waiting for length/lit and distance code lengths */
  346.43 +            LEN_,       /* i: same as LEN below, but only first time in */
  346.44 +            LEN,        /* i: waiting for length/lit/eob code */
  346.45 +            LENEXT,     /* i: waiting for length extra bits */
  346.46 +            DIST,       /* i: waiting for distance code */
  346.47 +            DISTEXT,    /* i: waiting for distance extra bits */
  346.48 +            MATCH,      /* o: waiting for output space to copy string */
  346.49 +            LIT,        /* o: waiting for output space to write literal */
  346.50 +    CHECK,      /* i: waiting for 32-bit check value */
  346.51 +    LENGTH,     /* i: waiting for 32-bit length (gzip) */
  346.52 +    DONE,       /* finished check, done -- remain here until reset */
  346.53 +    BAD,        /* got a data error -- remain here until reset */
  346.54 +    MEM,        /* got an inflate() memory error -- remain here until reset */
  346.55 +    SYNC        /* looking for synchronization bytes to restart inflate() */
  346.56 +} inflate_mode;
  346.57 +
  346.58 +/*
  346.59 +    State transitions between above modes -
  346.60 +
  346.61 +    (most modes can go to BAD or MEM on error -- not shown for clarity)
  346.62 +
  346.63 +    Process header:
  346.64 +        HEAD -> (gzip) or (zlib) or (raw)
  346.65 +        (gzip) -> FLAGS -> TIME -> OS -> EXLEN -> EXTRA -> NAME -> COMMENT ->
  346.66 +                  HCRC -> TYPE
  346.67 +        (zlib) -> DICTID or TYPE
  346.68 +        DICTID -> DICT -> TYPE
  346.69 +        (raw) -> TYPEDO
  346.70 +    Read deflate blocks:
  346.71 +            TYPE -> TYPEDO -> STORED or TABLE or LEN_ or CHECK
  346.72 +            STORED -> COPY_ -> COPY -> TYPE
  346.73 +            TABLE -> LENLENS -> CODELENS -> LEN_
  346.74 +            LEN_ -> LEN
  346.75 +    Read deflate codes in fixed or dynamic block:
  346.76 +                LEN -> LENEXT or LIT or TYPE
  346.77 +                LENEXT -> DIST -> DISTEXT -> MATCH -> LEN
  346.78 +                LIT -> LEN
  346.79 +    Process trailer:
  346.80 +        CHECK -> LENGTH -> DONE
  346.81 + */
  346.82 +
  346.83 +/* state maintained between inflate() calls.  Approximately 10K bytes. */
  346.84 +struct inflate_state {
  346.85 +    inflate_mode mode;          /* current inflate mode */
  346.86 +    int last;                   /* true if processing last block */
  346.87 +    int wrap;                   /* bit 0 true for zlib, bit 1 true for gzip */
  346.88 +    int havedict;               /* true if dictionary provided */
  346.89 +    int flags;                  /* gzip header method and flags (0 if zlib) */
  346.90 +    unsigned dmax;              /* zlib header max distance (INFLATE_STRICT) */
  346.91 +    unsigned long check;        /* protected copy of check value */
  346.92 +    unsigned long total;        /* protected copy of output count */
  346.93 +    gz_headerp head;            /* where to save gzip header information */
  346.94 +        /* sliding window */
  346.95 +    unsigned wbits;             /* log base 2 of requested window size */
  346.96 +    unsigned wsize;             /* window size or zero if not using window */
  346.97 +    unsigned whave;             /* valid bytes in the window */
  346.98 +    unsigned wnext;             /* window write index */
  346.99 +    unsigned char FAR *window;  /* allocated sliding window, if needed */
 346.100 +        /* bit accumulator */
 346.101 +    unsigned long hold;         /* input bit accumulator */
 346.102 +    unsigned bits;              /* number of bits in "in" */
 346.103 +        /* for string and stored block copying */
 346.104 +    unsigned length;            /* literal or length of data to copy */
 346.105 +    unsigned offset;            /* distance back to copy string from */
 346.106 +        /* for table and code decoding */
 346.107 +    unsigned extra;             /* extra bits needed */
 346.108 +        /* fixed and dynamic code tables */
 346.109 +    code const FAR *lencode;    /* starting table for length/literal codes */
 346.110 +    code const FAR *distcode;   /* starting table for distance codes */
 346.111 +    unsigned lenbits;           /* index bits for lencode */
 346.112 +    unsigned distbits;          /* index bits for distcode */
 346.113 +        /* dynamic table building */
 346.114 +    unsigned ncode;             /* number of code length code lengths */
 346.115 +    unsigned nlen;              /* number of length code lengths */
 346.116 +    unsigned ndist;             /* number of distance code lengths */
 346.117 +    unsigned have;              /* number of code lengths in lens[] */
 346.118 +    code FAR *next;             /* next available space in codes[] */
 346.119 +    unsigned short lens[320];   /* temporary storage for code lengths */
 346.120 +    unsigned short work[288];   /* work area for code table building */
 346.121 +    code codes[ENOUGH];         /* space for code tables */
 346.122 +    int sane;                   /* if false, allow invalid distance too far */
 346.123 +    int back;                   /* bits back of last unprocessed length/lit */
 346.124 +    unsigned was;               /* initial length of match */
 346.125 +};
   347.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
   347.2 +++ b/deps/glpk/src/zlib/inftrees.c	Sun Nov 06 20:59:10 2011 +0100
   347.3 @@ -0,0 +1,330 @@
   347.4 +/* inftrees.c -- generate Huffman trees for efficient decoding
   347.5 + * Copyright (C) 1995-2010 Mark Adler
   347.6 + * For conditions of distribution and use, see copyright notice in zlib.h
   347.7 + */
   347.8 +
   347.9 +#include "zutil.h"
  347.10 +#include "inftrees.h"
  347.11 +
  347.12 +#define MAXBITS 15
  347.13 +
  347.14 +const char inflate_copyright[] =
  347.15 +   " inflate 1.2.5 Copyright 1995-2010 Mark Adler ";
  347.16 +/*
  347.17 +  If you use the zlib library in a product, an acknowledgment is welcome
  347.18 +  in the documentation of your product. If for some reason you cannot
  347.19 +  include such an acknowledgment, I would appreciate that you keep this
  347.20 +  copyright string in the executable of your product.
  347.21 + */
  347.22 +
  347.23 +/*
  347.24 +   Build a set of tables to decode the provided canonical Huffman code.
  347.25 +   The code lengths are lens[0..codes-1].  The result starts at *table,
  347.26 +   whose indices are 0..2^bits-1.  work is a writable array of at least
  347.27 +   lens shorts, which is used as a work area.  type is the type of code
  347.28 +   to be generated, CODES, LENS, or DISTS.  On return, zero is success,
  347.29 +   -1 is an invalid code, and +1 means that ENOUGH isn't enough.  table
  347.30 +   on return points to the next available entry's address.  bits is the
  347.31 +   requested root table index bits, and on return it is the actual root
  347.32 +   table index bits.  It will differ if the request is greater than the
  347.33 +   longest code or if it is less than the shortest code.
  347.34 + */
  347.35 +int ZLIB_INTERNAL inflate_table(type, lens, codes, table, bits, work)
  347.36 +codetype type;
  347.37 +unsigned short FAR *lens;
  347.38 +unsigned codes;
  347.39 +code FAR * FAR *table;
  347.40 +unsigned FAR *bits;
  347.41 +unsigned short FAR *work;
  347.42 +{
  347.43 +    unsigned len;               /* a code's length in bits */
  347.44 +    unsigned sym;               /* index of code symbols */
  347.45 +    unsigned min, max;          /* minimum and maximum code lengths */
  347.46 +    unsigned root;              /* number of index bits for root table */
  347.47 +    unsigned curr;              /* number of index bits for current table */
  347.48 +    unsigned drop;              /* code bits to drop for sub-table */
  347.49 +    int left;                   /* number of prefix codes available */
  347.50 +    unsigned used;              /* code entries in table used */
  347.51 +    unsigned huff;              /* Huffman code */
  347.52 +    unsigned incr;              /* for incrementing code, index */
  347.53 +    unsigned fill;              /* index for replicating entries */
  347.54 +    unsigned low;               /* low bits for current root entry */
  347.55 +    unsigned mask;              /* mask for low root bits */
  347.56 +    code here;                  /* table entry for duplication */
  347.57 +    code FAR *next;             /* next available space in table */
  347.58 +    const unsigned short FAR *base;     /* base value table to use */
  347.59 +    const unsigned short FAR *extra;    /* extra bits table to use */
  347.60 +    int end;                    /* use base and extra for symbol > end */
  347.61 +    unsigned short count[MAXBITS+1];    /* number of codes of each length */
  347.62 +    unsigned short offs[MAXBITS+1];     /* offsets in table for each length */
  347.63 +    static const unsigned short lbase[31] = { /* Length codes 257..285 base */
  347.64 +        3, 4, 5, 6, 7, 8, 9, 10, 11, 13, 15, 17, 19, 23, 27, 31,
  347.65 +        35, 43, 51, 59, 67, 83, 99, 115, 131, 163, 195, 227, 258, 0, 0};
  347.66 +    static const unsigned short lext[31] = { /* Length codes 257..285 extra */
  347.67 +        16, 16, 16, 16, 16, 16, 16, 16, 17, 17, 17, 17, 18, 18, 18, 18,
  347.68 +        19, 19, 19, 19, 20, 20, 20, 20, 21, 21, 21, 21, 16, 73, 195};
  347.69 +    static const unsigned short dbase[32] = { /* Distance codes 0..29 base */
  347.70 +        1, 2, 3, 4, 5, 7, 9, 13, 17, 25, 33, 49, 65, 97, 129, 193,
  347.71 +        257, 385, 513, 769, 1025, 1537, 2049, 3073, 4097, 6145,
  347.72 +        8193, 12289, 16385, 24577, 0, 0};
  347.73 +    static const unsigned short dext[32] = { /* Distance codes 0..29 extra */
  347.74 +        16, 16, 16, 16, 17, 17, 18, 18, 19, 19, 20, 20, 21, 21, 22, 22,
  347.75 +        23, 23, 24, 24, 25, 25, 26, 26, 27, 27,
  347.76 +        28, 28, 29, 29, 64, 64};
  347.77 +
  347.78 +    /*
  347.79 +       Process a set of code lengths to create a canonical Huffman code.  The
  347.80 +       code lengths are lens[0..codes-1].  Each length corresponds to the
  347.81 +       symbols 0..codes-1.  The Huffman code is generated by first sorting the
  347.82 +       symbols by length from short to long, and retaining the symbol order
  347.83 +       for codes with equal lengths.  Then the code starts with all zero bits
  347.84 +       for the first code of the shortest length, and the codes are integer
  347.85 +       increments for the same length, and zeros are appended as the length
  347.86 +       increases.  For the deflate format, these bits are stored backwards
  347.87 +       from their more natural integer increment ordering, and so when the
  347.88 +       decoding tables are built in the large loop below, the integer codes
  347.89 +       are incremented backwards.
  347.90 +
  347.91 +       This routine assumes, but does not check, that all of the entries in
  347.92 +       lens[] are in the range 0..MAXBITS.  The caller must assure this.
  347.93 +       1..MAXBITS is interpreted as that code length.  zero means that that
  347.94 +       symbol does not occur in this code.
  347.95 +
  347.96 +       The codes are sorted by computing a count of codes for each length,
  347.97 +       creating from that a table of starting indices for each length in the
  347.98 +       sorted table, and then entering the symbols in order in the sorted
  347.99 +       table.  The sorted table is work[], with that space being provided by
 347.100 +       the caller.
 347.101 +
 347.102 +       The length counts are used for other purposes as well, i.e. finding
 347.103 +       the minimum and maximum length codes, determining if there are any
 347.104 +       codes at all, checking for a valid set of lengths, and looking ahead
 347.105 +       at length counts to determine sub-table sizes when building the
 347.106 +       decoding tables.
 347.107 +     */
 347.108 +
 347.109 +    /* accumulate lengths for codes (assumes lens[] all in 0..MAXBITS) */
 347.110 +    for (len = 0; len <= MAXBITS; len++)
 347.111 +        count[len] = 0;
 347.112 +    for (sym = 0; sym < codes; sym++)
 347.113 +        count[lens[sym]]++;
 347.114 +
 347.115 +    /* bound code lengths, force root to be within code lengths */
 347.116 +    root = *bits;
 347.117 +    for (max = MAXBITS; max >= 1; max--)
 347.118 +        if (count[max] != 0) break;
 347.119 +    if (root > max) root = max;
 347.120 +    if (max == 0) {                     /* no symbols to code at all */
 347.121 +        here.op = (unsigned char)64;    /* invalid code marker */
 347.122 +        here.bits = (unsigned char)1;
 347.123 +        here.val = (unsigned short)0;
 347.124 +        *(*table)++ = here;             /* make a table to force an error */
 347.125 +        *(*table)++ = here;
 347.126 +        *bits = 1;
 347.127 +        return 0;     /* no symbols, but wait for decoding to report error */
 347.128 +    }
 347.129 +    for (min = 1; min < max; min++)
 347.130 +        if (count[min] != 0) break;
 347.131 +    if (root < min) root = min;
 347.132 +
 347.133 +    /* check for an over-subscribed or incomplete set of lengths */
 347.134 +    left = 1;
 347.135 +    for (len = 1; len <= MAXBITS; len++) {
 347.136 +        left <<= 1;
 347.137 +        left -= count[len];
 347.138 +        if (left < 0) return -1;        /* over-subscribed */
 347.139 +    }
 347.140 +    if (left > 0 && (type == CODES || max != 1))
 347.141 +        return -1;                      /* incomplete set */
 347.142 +
 347.143 +    /* generate offsets into symbol table for each length for sorting */
 347.144 +    offs[1] = 0;
 347.145 +    for (len = 1; len < MAXBITS; len++)
 347.146 +        offs[len + 1] = offs[len] + count[len];
 347.147 +
 347.148 +    /* sort symbols by length, by symbol order within each length */
 347.149 +    for (sym = 0; sym < codes; sym++)
 347.150 +        if (lens[sym] != 0) work[offs[lens[sym]]++] = (unsigned short)sym;
 347.151 +
 347.152 +    /*
 347.153 +       Create and fill in decoding tables.  In this loop, the table being
 347.154 +       filled is at next and has curr index bits.  The code being used is huff
 347.155 +       with length len.  That code is converted to an index by dropping drop
 347.156 +       bits off of the bottom.  For codes where len is less than drop + curr,
 347.157 +       those top drop + curr - len bits are incremented through all values to
 347.158 +       fill the table with replicated entries.
 347.159 +
 347.160 +       root is the number of index bits for the root table.  When len exceeds
 347.161 +       root, sub-tables are created pointed to by the root entry with an index
 347.162 +       of the low root bits of huff.  This is saved in low to check for when a
 347.163 +       new sub-table should be started.  drop is zero when the root table is
 347.164 +       being filled, and drop is root when sub-tables are being filled.
 347.165 +
 347.166 +       When a new sub-table is needed, it is necessary to look ahead in the
 347.167 +       code lengths to determine what size sub-table is needed.  The length
 347.168 +       counts are used for this, and so count[] is decremented as codes are
 347.169 +       entered in the tables.
 347.170 +
 347.171 +       used keeps track of how many table entries have been allocated from the
 347.172 +       provided *table space.  It is checked for LENS and DIST tables against
 347.173 +       the constants ENOUGH_LENS and ENOUGH_DISTS to guard against changes in
 347.174 +       the initial root table size constants.  See the comments in inftrees.h
 347.175 +       for more information.
 347.176 +
 347.177 +       sym increments through all symbols, and the loop terminates when
 347.178 +       all codes of length max, i.e. all codes, have been processed.  This
 347.179 +       routine permits incomplete codes, so another loop after this one fills
 347.180 +       in the rest of the decoding tables with invalid code markers.
 347.181 +     */
 347.182 +
 347.183 +    /* set up for code type */
 347.184 +    switch (type) {
 347.185 +    case CODES:
 347.186 +        base = extra = work;    /* dummy value--not used */
 347.187 +        end = 19;
 347.188 +        break;
 347.189 +    case LENS:
 347.190 +        base = lbase;
 347.191 +        base -= 257;
 347.192 +        extra = lext;
 347.193 +        extra -= 257;
 347.194 +        end = 256;
 347.195 +        break;
 347.196 +    default:            /* DISTS */
 347.197 +        base = dbase;
 347.198 +        extra = dext;
 347.199 +        end = -1;
 347.200 +    }
 347.201 +
 347.202 +    /* initialize state for loop */
 347.203 +    huff = 0;                   /* starting code */
 347.204 +    sym = 0;                    /* starting code symbol */
 347.205 +    len = min;                  /* starting code length */
 347.206 +    next = *table;              /* current table to fill in */
 347.207 +    curr = root;                /* current table index bits */
 347.208 +    drop = 0;                   /* current bits to drop from code for index */
 347.209 +    low = (unsigned)(-1);       /* trigger new sub-table when len > root */
 347.210 +    used = 1U << root;          /* use root table entries */
 347.211 +    mask = used - 1;            /* mask for comparing low */
 347.212 +
 347.213 +    /* check available table space */
 347.214 +    if ((type == LENS && used >= ENOUGH_LENS) ||
 347.215 +        (type == DISTS && used >= ENOUGH_DISTS))
 347.216 +        return 1;
 347.217 +
 347.218 +    /* process all codes and make table entries */
 347.219 +    for (;;) {
 347.220 +        /* create table entry */
 347.221 +        here.bits = (unsigned char)(len - drop);
 347.222 +        if ((int)(work[sym]) < end) {
 347.223 +            here.op = (unsigned char)0;
 347.224 +            here.val = work[sym];
 347.225 +        }
 347.226 +        else if ((int)(work[sym]) > end) {
 347.227 +            here.op = (unsigned char)(extra[work[sym]]);
 347.228 +            here.val = base[work[sym]];
 347.229 +        }
 347.230 +        else {
 347.231 +            here.op = (unsigned char)(32 + 64);         /* end of block */
 347.232 +            here.val = 0;
 347.233 +        }
 347.234 +
 347.235 +        /* replicate for those indices with low len bits equal to huff */
 347.236 +        incr = 1U << (len - drop);
 347.237 +        fill = 1U << curr;
 347.238 +        min = fill;                 /* save offset to next table */
 347.239 +        do {
 347.240 +            fill -= incr;
 347.241 +            next[(huff >> drop) + fill] = here;
 347.242 +        } while (fill != 0);
 347.243 +
 347.244 +        /* backwards increment the len-bit code huff */
 347.245 +        incr = 1U << (len - 1);
 347.246 +        while (huff & incr)
 347.247 +            incr >>= 1;
 347.248 +        if (incr != 0) {
 347.249 +            huff &= incr - 1;
 347.250 +            huff += incr;
 347.251 +        }
 347.252 +        else
 347.253 +            huff = 0;
 347.254 +
 347.255 +        /* go to next symbol, update count, len */
 347.256 +        sym++;
 347.257 +        if (--(count[len]) == 0) {
 347.258 +            if (len == max) break;
 347.259 +            len = lens[work[sym]];
 347.260 +        }
 347.261 +
 347.262 +        /* create new sub-table if needed */
 347.263 +        if (len > root && (huff & mask) != low) {
 347.264 +            /* if first time, transition to sub-tables */
 347.265 +            if (drop == 0)
 347.266 +                drop = root;
 347.267 +
 347.268 +            /* increment past last table */
 347.269 +            next += min;            /* here min is 1 << curr */
 347.270 +
 347.271 +            /* determine length of next table */
 347.272 +            curr = len - drop;
 347.273 +            left = (int)(1 << curr);
 347.274 +            while (curr + drop < max) {
 347.275 +                left -= count[curr + drop];
 347.276 +                if (left <= 0) break;
 347.277 +                curr++;
 347.278 +                left <<= 1;
 347.279 +            }
 347.280 +
 347.281 +            /* check for enough space */
 347.282 +            used += 1U << curr;
 347.283 +            if ((type == LENS && used >= ENOUGH_LENS) ||
 347.284 +                (type == DISTS && used >= ENOUGH_DISTS))
 347.285 +                return 1;
 347.286 +
 347.287 +            /* point entry in root table to sub-table */
 347.288 +            low = huff & mask;
 347.289 +            (*table)[low].op = (unsigned char)curr;
 347.290 +            (*table)[low].bits = (unsigned char)root;
 347.291 +            (*table)[low].val = (unsigned short)(next - *table);
 347.292 +        }
 347.293 +    }
 347.294 +
 347.295 +    /*
 347.296 +       Fill in rest of table for incomplete codes.  This loop is similar to the
 347.297 +       loop above in incrementing huff for table indices.  It is assumed that
 347.298 +       len is equal to curr + drop, so there is no loop needed to increment
 347.299 +       through high index bits.  When the current sub-table is filled, the loop
 347.300 +       drops back to the root table to fill in any remaining entries there.
 347.301 +     */
 347.302 +    here.op = (unsigned char)64;                /* invalid code marker */
 347.303 +    here.bits = (unsigned char)(len - drop);
 347.304 +    here.val = (unsigned short)0;
 347.305 +    while (huff != 0) {
 347.306 +        /* when done with sub-table, drop back to root table */
 347.307 +        if (drop != 0 && (huff & mask) != low) {
 347.308 +            drop = 0;
 347.309 +            len = root;
 347.310 +            next = *table;
 347.311 +            here.bits = (unsigned char)len;
 347.312 +        }
 347.313 +
 347.314 +        /* put invalid code marker in table */
 347.315 +        next[huff >> drop] = here;
 347.316 +
 347.317 +        /* backwards increment the len-bit code huff */
 347.318 +        incr = 1U << (len - 1);
 347.319 +        while (huff & incr)
 347.320 +            incr >>= 1;
 347.321 +        if (incr != 0) {
 347.322 +            huff &= incr - 1;
 347.323 +            huff += incr;
 347.324 +        }
 347.325 +        else
 347.326 +            huff = 0;
 347.327 +    }
 347.328 +
 347.329 +    /* set return parameters */
 347.330 +    *table += used;
 347.331 +    *bits = root;
 347.332 +    return 0;
 347.333 +}
   348.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
   348.2 +++ b/deps/glpk/src/zlib/inftrees.h	Sun Nov 06 20:59:10 2011 +0100
   348.3 @@ -0,0 +1,62 @@
   348.4 +/* inftrees.h -- header to use inftrees.c
   348.5 + * Copyright (C) 1995-2005, 2010 Mark Adler
   348.6 + * For conditions of distribution and use, see copyright notice in zlib.h
   348.7 + */
   348.8 +
   348.9 +/* WARNING: this file should *not* be used by applications. It is
  348.10 +   part of the implementation of the compression library and is
  348.11 +   subject to change. Applications should only use zlib.h.
  348.12 + */
  348.13 +
  348.14 +/* Structure for decoding tables.  Each entry provides either the
  348.15 +   information needed to do the operation requested by the code that
  348.16 +   indexed that table entry, or it provides a pointer to another
  348.17 +   table that indexes more bits of the code.  op indicates whether
  348.18 +   the entry is a pointer to another table, a literal, a length or
  348.19 +   distance, an end-of-block, or an invalid code.  For a table
  348.20 +   pointer, the low four bits of op is the number of index bits of
  348.21 +   that table.  For a length or distance, the low four bits of op
  348.22 +   is the number of extra bits to get after the code.  bits is
  348.23 +   the number of bits in this code or part of the code to drop off
  348.24 +   of the bit buffer.  val is the actual byte to output in the case
  348.25 +   of a literal, the base length or distance, or the offset from
  348.26 +   the current table to the next table.  Each entry is four bytes. */
  348.27 +typedef struct {
  348.28 +    unsigned char op;           /* operation, extra bits, table bits */
  348.29 +    unsigned char bits;         /* bits in this part of the code */
  348.30 +    unsigned short val;         /* offset in table or code value */
  348.31 +} code;
  348.32 +
  348.33 +/* op values as set by inflate_table():
  348.34 +    00000000 - literal
  348.35 +    0000tttt - table link, tttt != 0 is the number of table index bits
  348.36 +    0001eeee - length or distance, eeee is the number of extra bits
  348.37 +    01100000 - end of block
  348.38 +    01000000 - invalid code
  348.39 + */
  348.40 +
  348.41 +/* Maximum size of the dynamic table.  The maximum number of code structures is
  348.42 +   1444, which is the sum of 852 for literal/length codes and 592 for distance
  348.43 +   codes.  These values were found by exhaustive searches using the program
  348.44 +   examples/enough.c found in the zlib distribtution.  The arguments to that
  348.45 +   program are the number of symbols, the initial root table size, and the
  348.46 +   maximum bit length of a code.  "enough 286 9 15" for literal/length codes
  348.47 +   returns returns 852, and "enough 30 6 15" for distance codes returns 592.
  348.48 +   The initial root table size (9 or 6) is found in the fifth argument of the
  348.49 +   inflate_table() calls in inflate.c and infback.c.  If the root table size is
  348.50 +   changed, then these maximum sizes would be need to be recalculated and
  348.51 +   updated. */
  348.52 +#define ENOUGH_LENS 852
  348.53 +#define ENOUGH_DISTS 592
  348.54 +#define ENOUGH (ENOUGH_LENS+ENOUGH_DISTS)
  348.55 +
  348.56 +/* Type of code to build for inflate_table() */
  348.57 +typedef enum {
  348.58 +    CODES,
  348.59 +    LENS,
  348.60 +    DISTS
  348.61 +} codetype;
  348.62 +
  348.63 +int ZLIB_INTERNAL inflate_table OF((codetype type, unsigned short FAR *lens,
  348.64 +                             unsigned codes, code FAR * FAR *table,
  348.65 +                             unsigned FAR *bits, unsigned short FAR *work));
   349.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
   349.2 +++ b/deps/glpk/src/zlib/trees.c	Sun Nov 06 20:59:10 2011 +0100
   349.3 @@ -0,0 +1,1244 @@
   349.4 +/* trees.c -- output deflated data using Huffman coding
   349.5 + * Copyright (C) 1995-2010 Jean-loup Gailly
   349.6 + * detect_data_type() function provided freely by Cosmin Truta, 2006
   349.7 + * For conditions of distribution and use, see copyright notice in zlib.h
   349.8 + */
   349.9 +
  349.10 +/*
  349.11 + *  ALGORITHM
  349.12 + *
  349.13 + *      The "deflation" process uses several Huffman trees. The more
  349.14 + *      common source values are represented by shorter bit sequences.
  349.15 + *
  349.16 + *      Each code tree is stored in a compressed form which is itself
  349.17 + * a Huffman encoding of the lengths of all the code strings (in
  349.18 + * ascending order by source values).  The actual code strings are
  349.19 + * reconstructed from the lengths in the inflate process, as described
  349.20 + * in the deflate specification.
  349.21 + *
  349.22 + *  REFERENCES
  349.23 + *
  349.24 + *      Deutsch, L.P.,"'Deflate' Compressed Data Format Specification".
  349.25 + *      Available in ftp.uu.net:/pub/archiving/zip/doc/deflate-1.1.doc
  349.26 + *
  349.27 + *      Storer, James A.
  349.28 + *          Data Compression:  Methods and Theory, pp. 49-50.
  349.29 + *          Computer Science Press, 1988.  ISBN 0-7167-8156-5.
  349.30 + *
  349.31 + *      Sedgewick, R.
  349.32 + *          Algorithms, p290.
  349.33 + *          Addison-Wesley, 1983. ISBN 0-201-06672-6.
  349.34 + */
  349.35 +
  349.36 +/* @(#) $Id$ */
  349.37 +
  349.38 +/* #define GEN_TREES_H */
  349.39 +
  349.40 +#include "deflate.h"
  349.41 +
  349.42 +#ifdef DEBUG
  349.43 +#  include <ctype.h>
  349.44 +#endif
  349.45 +
  349.46 +/* ===========================================================================
  349.47 + * Constants
  349.48 + */
  349.49 +
  349.50 +#define MAX_BL_BITS 7
  349.51 +/* Bit length codes must not exceed MAX_BL_BITS bits */
  349.52 +
  349.53 +#define END_BLOCK 256
  349.54 +/* end of block literal code */
  349.55 +
  349.56 +#define REP_3_6      16
  349.57 +/* repeat previous bit length 3-6 times (2 bits of repeat count) */
  349.58 +
  349.59 +#define REPZ_3_10    17
  349.60 +/* repeat a zero length 3-10 times  (3 bits of repeat count) */
  349.61 +
  349.62 +#define REPZ_11_138  18
  349.63 +/* repeat a zero length 11-138 times  (7 bits of repeat count) */
  349.64 +
  349.65 +local const int extra_lbits[LENGTH_CODES] /* extra bits for each length code */
  349.66 +   = {0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0};
  349.67 +
  349.68 +local const int extra_dbits[D_CODES] /* extra bits for each distance code */
  349.69 +   = {0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13};
  349.70 +
  349.71 +local const int extra_blbits[BL_CODES]/* extra bits for each bit length code */
  349.72 +   = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7};
  349.73 +
  349.74 +local const uch bl_order[BL_CODES]
  349.75 +   = {16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15};
  349.76 +/* The lengths of the bit length codes are sent in order of decreasing
  349.77 + * probability, to avoid transmitting the lengths for unused bit length codes.
  349.78 + */
  349.79 +
  349.80 +#define Buf_size (8 * 2*sizeof(char))
  349.81 +/* Number of bits used within bi_buf. (bi_buf might be implemented on
  349.82 + * more than 16 bits on some systems.)
  349.83 + */
  349.84 +
  349.85 +/* ===========================================================================
  349.86 + * Local data. These are initialized only once.
  349.87 + */
  349.88 +
  349.89 +#define DIST_CODE_LEN  512 /* see definition of array dist_code below */
  349.90 +
  349.91 +#if defined(GEN_TREES_H) || !defined(STDC)
  349.92 +/* non ANSI compilers may not accept trees.h */
  349.93 +
  349.94 +local ct_data static_ltree[L_CODES+2];
  349.95 +/* The static literal tree. Since the bit lengths are imposed, there is no
  349.96 + * need for the L_CODES extra codes used during heap construction. However
  349.97 + * The codes 286 and 287 are needed to build a canonical tree (see _tr_init
  349.98 + * below).
  349.99 + */
 349.100 +
 349.101 +local ct_data static_dtree[D_CODES];
 349.102 +/* The static distance tree. (Actually a trivial tree since all codes use
 349.103 + * 5 bits.)
 349.104 + */
 349.105 +
 349.106 +uch _dist_code[DIST_CODE_LEN];
 349.107 +/* Distance codes. The first 256 values correspond to the distances
 349.108 + * 3 .. 258, the last 256 values correspond to the top 8 bits of
 349.109 + * the 15 bit distances.
 349.110 + */
 349.111 +
 349.112 +uch _length_code[MAX_MATCH-MIN_MATCH+1];
 349.113 +/* length code for each normalized match length (0 == MIN_MATCH) */
 349.114 +
 349.115 +local int base_length[LENGTH_CODES];
 349.116 +/* First normalized length for each code (0 = MIN_MATCH) */
 349.117 +
 349.118 +local int base_dist[D_CODES];
 349.119 +/* First normalized distance for each code (0 = distance of 1) */
 349.120 +
 349.121 +#else
 349.122 +#  include "trees.h"
 349.123 +#endif /* GEN_TREES_H */
 349.124 +
 349.125 +struct static_tree_desc_s {
 349.126 +    const ct_data *static_tree;  /* static tree or NULL */
 349.127 +    const intf *extra_bits;      /* extra bits for each code or NULL */
 349.128 +    int     extra_base;          /* base index for extra_bits */
 349.129 +    int     elems;               /* max number of elements in the tree */
 349.130 +    int     max_length;          /* max bit length for the codes */
 349.131 +};
 349.132 +
 349.133 +local static_tree_desc  static_l_desc =
 349.134 +{static_ltree, extra_lbits, LITERALS+1, L_CODES, MAX_BITS};
 349.135 +
 349.136 +local static_tree_desc  static_d_desc =
 349.137 +{static_dtree, extra_dbits, 0,          D_CODES, MAX_BITS};
 349.138 +
 349.139 +local static_tree_desc  static_bl_desc =
 349.140 +{(const ct_data *)0, extra_blbits, 0,   BL_CODES, MAX_BL_BITS};
 349.141 +
 349.142 +/* ===========================================================================
 349.143 + * Local (static) routines in this file.
 349.144 + */
 349.145 +
 349.146 +local void tr_static_init OF((void));
 349.147 +local void init_block     OF((deflate_state *s));
 349.148 +local void pqdownheap     OF((deflate_state *s, ct_data *tree, int k));
 349.149 +local void gen_bitlen     OF((deflate_state *s, tree_desc *desc));
 349.150 +local void gen_codes      OF((ct_data *tree, int max_code, ushf *bl_count));
 349.151 +local void build_tree     OF((deflate_state *s, tree_desc *desc));
 349.152 +local void scan_tree      OF((deflate_state *s, ct_data *tree, int max_code));
 349.153 +local void send_tree      OF((deflate_state *s, ct_data *tree, int max_code));
 349.154 +local int  build_bl_tree  OF((deflate_state *s));
 349.155 +local void send_all_trees OF((deflate_state *s, int lcodes, int dcodes,
 349.156 +                              int blcodes));
 349.157 +local void compress_block OF((deflate_state *s, ct_data *ltree,
 349.158 +                              ct_data *dtree));
 349.159 +local int  detect_data_type OF((deflate_state *s));
 349.160 +local unsigned bi_reverse OF((unsigned value, int length));
 349.161 +local void bi_windup      OF((deflate_state *s));
 349.162 +local void bi_flush       OF((deflate_state *s));
 349.163 +local void copy_block     OF((deflate_state *s, charf *buf, unsigned len,
 349.164 +                              int header));
 349.165 +
 349.166 +#ifdef GEN_TREES_H
 349.167 +local void gen_trees_header OF((void));
 349.168 +#endif
 349.169 +
 349.170 +#ifndef DEBUG
 349.171 +#  define send_code(s, c, tree) send_bits(s, tree[c].Code, tree[c].Len)
 349.172 +   /* Send a code of the given tree. c and tree must not have side effects */
 349.173 +
 349.174 +#else /* DEBUG */
 349.175 +#  define send_code(s, c, tree) \
 349.176 +     { if (z_verbose>2) fprintf(stderr,"\ncd %3d ",(c)); \
 349.177 +       send_bits(s, tree[c].Code, tree[c].Len); }
 349.178 +#endif
 349.179 +
 349.180 +/* ===========================================================================
 349.181 + * Output a short LSB first on the stream.
 349.182 + * IN assertion: there is enough room in pendingBuf.
 349.183 + */
 349.184 +#define put_short(s, w) { \
 349.185 +    put_byte(s, (uch)((w) & 0xff)); \
 349.186 +    put_byte(s, (uch)((ush)(w) >> 8)); \
 349.187 +}
 349.188 +
 349.189 +/* ===========================================================================
 349.190 + * Send a value on a given number of bits.
 349.191 + * IN assertion: length <= 16 and value fits in length bits.
 349.192 + */
 349.193 +#ifdef DEBUG
 349.194 +local void send_bits      OF((deflate_state *s, int value, int length));
 349.195 +
 349.196 +local void send_bits(s, value, length)
 349.197 +    deflate_state *s;
 349.198 +    int value;  /* value to send */
 349.199 +    int length; /* number of bits */
 349.200 +{
 349.201 +    Tracevv((stderr," l %2d v %4x ", length, value));
 349.202 +    Assert(length > 0 && length <= 15, "invalid length");
 349.203 +    s->bits_sent += (ulg)length;
 349.204 +
 349.205 +    /* If not enough room in bi_buf, use (valid) bits from bi_buf and
 349.206 +     * (16 - bi_valid) bits from value, leaving (width - (16-bi_valid))
 349.207 +     * unused bits in value.
 349.208 +     */
 349.209 +    if (s->bi_valid > (int)Buf_size - length) {
 349.210 +        s->bi_buf |= (ush)value << s->bi_valid;
 349.211 +        put_short(s, s->bi_buf);
 349.212 +        s->bi_buf = (ush)value >> (Buf_size - s->bi_valid);
 349.213 +        s->bi_valid += length - Buf_size;
 349.214 +    } else {
 349.215 +        s->bi_buf |= (ush)value << s->bi_valid;
 349.216 +        s->bi_valid += length;
 349.217 +    }
 349.218 +}
 349.219 +#else /* !DEBUG */
 349.220 +
 349.221 +#define send_bits(s, value, length) \
 349.222 +{ int len = length;\
 349.223 +  if (s->bi_valid > (int)Buf_size - len) {\
 349.224 +    int val = value;\
 349.225 +    s->bi_buf |= (ush)val << s->bi_valid;\
 349.226 +    put_short(s, s->bi_buf);\
 349.227 +    s->bi_buf = (ush)val >> (Buf_size - s->bi_valid);\
 349.228 +    s->bi_valid += len - Buf_size;\
 349.229 +  } else {\
 349.230 +    s->bi_buf |= (ush)(value) << s->bi_valid;\
 349.231 +    s->bi_valid += len;\
 349.232 +  }\
 349.233 +}
 349.234 +#endif /* DEBUG */
 349.235 +
 349.236 +
 349.237 +/* the arguments must not have side effects */
 349.238 +
 349.239 +/* ===========================================================================
 349.240 + * Initialize the various 'constant' tables.
 349.241 + */
 349.242 +local void tr_static_init()
 349.243 +{
 349.244 +#if defined(GEN_TREES_H) || !defined(STDC)
 349.245 +    static int static_init_done = 0;
 349.246 +    int n;        /* iterates over tree elements */
 349.247 +    int bits;     /* bit counter */
 349.248 +    int length;   /* length value */
 349.249 +    int code;     /* code value */
 349.250 +    int dist;     /* distance index */
 349.251 +    ush bl_count[MAX_BITS+1];
 349.252 +    /* number of codes at each bit length for an optimal tree */
 349.253 +
 349.254 +    if (static_init_done) return;
 349.255 +
 349.256 +    /* For some embedded targets, global variables are not initialized: */
 349.257 +#ifdef NO_INIT_GLOBAL_POINTERS
 349.258 +    static_l_desc.static_tree = static_ltree;
 349.259 +    static_l_desc.extra_bits = extra_lbits;
 349.260 +    static_d_desc.static_tree = static_dtree;
 349.261 +    static_d_desc.extra_bits = extra_dbits;
 349.262 +    static_bl_desc.extra_bits = extra_blbits;
 349.263 +#endif
 349.264 +
 349.265 +    /* Initialize the mapping length (0..255) -> length code (0..28) */
 349.266 +    length = 0;
 349.267 +    for (code = 0; code < LENGTH_CODES-1; code++) {
 349.268 +        base_length[code] = length;
 349.269 +        for (n = 0; n < (1<<extra_lbits[code]); n++) {
 349.270 +            _length_code[length++] = (uch)code;
 349.271 +        }
 349.272 +    }
 349.273 +    Assert (length == 256, "tr_static_init: length != 256");
 349.274 +    /* Note that the length 255 (match length 258) can be represented
 349.275 +     * in two different ways: code 284 + 5 bits or code 285, so we
 349.276 +     * overwrite length_code[255] to use the best encoding:
 349.277 +     */
 349.278 +    _length_code[length-1] = (uch)code;
 349.279 +
 349.280 +    /* Initialize the mapping dist (0..32K) -> dist code (0..29) */
 349.281 +    dist = 0;
 349.282 +    for (code = 0 ; code < 16; code++) {
 349.283 +        base_dist[code] = dist;
 349.284 +        for (n = 0; n < (1<<extra_dbits[code]); n++) {
 349.285 +            _dist_code[dist++] = (uch)code;
 349.286 +        }
 349.287 +    }
 349.288 +    Assert (dist == 256, "tr_static_init: dist != 256");
 349.289 +    dist >>= 7; /* from now on, all distances are divided by 128 */
 349.290 +    for ( ; code < D_CODES; code++) {
 349.291 +        base_dist[code] = dist << 7;
 349.292 +        for (n = 0; n < (1<<(extra_dbits[code]-7)); n++) {
 349.293 +            _dist_code[256 + dist++] = (uch)code;
 349.294 +        }
 349.295 +    }
 349.296 +    Assert (dist == 256, "tr_static_init: 256+dist != 512");
 349.297 +
 349.298 +    /* Construct the codes of the static literal tree */
 349.299 +    for (bits = 0; bits <= MAX_BITS; bits++) bl_count[bits] = 0;
 349.300 +    n = 0;
 349.301 +    while (n <= 143) static_ltree[n++].Len = 8, bl_count[8]++;
 349.302 +    while (n <= 255) static_ltree[n++].Len = 9, bl_count[9]++;
 349.303 +    while (n <= 279) static_ltree[n++].Len = 7, bl_count[7]++;
 349.304 +    while (n <= 287) static_ltree[n++].Len = 8, bl_count[8]++;
 349.305 +    /* Codes 286 and 287 do not exist, but we must include them in the
 349.306 +     * tree construction to get a canonical Huffman tree (longest code
 349.307 +     * all ones)
 349.308 +     */
 349.309 +    gen_codes((ct_data *)static_ltree, L_CODES+1, bl_count);
 349.310 +
 349.311 +    /* The static distance tree is trivial: */
 349.312 +    for (n = 0; n < D_CODES; n++) {
 349.313 +        static_dtree[n].Len = 5;
 349.314 +        static_dtree[n].Code = bi_reverse((unsigned)n, 5);
 349.315 +    }
 349.316 +    static_init_done = 1;
 349.317 +
 349.318 +#  ifdef GEN_TREES_H
 349.319 +    gen_trees_header();
 349.320 +#  endif
 349.321 +#endif /* defined(GEN_TREES_H) || !defined(STDC) */
 349.322 +}
 349.323 +
 349.324 +/* ===========================================================================
 349.325 + * Genererate the file trees.h describing the static trees.
 349.326 + */
 349.327 +#ifdef GEN_TREES_H
 349.328 +#  ifndef DEBUG
 349.329 +#    include <stdio.h>
 349.330 +#  endif
 349.331 +
 349.332 +#  define SEPARATOR(i, last, width) \
 349.333 +      ((i) == (last)? "\n};\n\n" :    \
 349.334 +       ((i) % (width) == (width)-1 ? ",\n" : ", "))
 349.335 +
 349.336 +void gen_trees_header()
 349.337 +{
 349.338 +    FILE *header = fopen("trees.h", "w");
 349.339 +    int i;
 349.340 +
 349.341 +    Assert (header != NULL, "Can't open trees.h");
 349.342 +    fprintf(header,
 349.343 +            "/* header created automatically with -DGEN_TREES_H */\n\n");
 349.344 +
 349.345 +    fprintf(header, "local const ct_data static_ltree[L_CODES+2] = {\n");
 349.346 +    for (i = 0; i < L_CODES+2; i++) {
 349.347 +        fprintf(header, "{{%3u},{%3u}}%s", static_ltree[i].Code,
 349.348 +                static_ltree[i].Len, SEPARATOR(i, L_CODES+1, 5));
 349.349 +    }
 349.350 +
 349.351 +    fprintf(header, "local const ct_data static_dtree[D_CODES] = {\n");
 349.352 +    for (i = 0; i < D_CODES; i++) {
 349.353 +        fprintf(header, "{{%2u},{%2u}}%s", static_dtree[i].Code,
 349.354 +                static_dtree[i].Len, SEPARATOR(i, D_CODES-1, 5));
 349.355 +    }
 349.356 +
 349.357 +    fprintf(header, "const uch ZLIB_INTERNAL _dist_code[DIST_CODE_LEN] = {\n");
 349.358 +    for (i = 0; i < DIST_CODE_LEN; i++) {
 349.359 +        fprintf(header, "%2u%s", _dist_code[i],
 349.360 +                SEPARATOR(i, DIST_CODE_LEN-1, 20));
 349.361 +    }
 349.362 +
 349.363 +    fprintf(header,
 349.364 +        "const uch ZLIB_INTERNAL _length_code[MAX_MATCH-MIN_MATCH+1]= {\n");
 349.365 +    for (i = 0; i < MAX_MATCH-MIN_MATCH+1; i++) {
 349.366 +        fprintf(header, "%2u%s", _length_code[i],
 349.367 +                SEPARATOR(i, MAX_MATCH-MIN_MATCH, 20));
 349.368 +    }
 349.369 +
 349.370 +    fprintf(header, "local const int base_length[LENGTH_CODES] = {\n");
 349.371 +    for (i = 0; i < LENGTH_CODES; i++) {
 349.372 +        fprintf(header, "%1u%s", base_length[i],
 349.373 +                SEPARATOR(i, LENGTH_CODES-1, 20));
 349.374 +    }
 349.375 +
 349.376 +    fprintf(header, "local const int base_dist[D_CODES] = {\n");
 349.377 +    for (i = 0; i < D_CODES; i++) {
 349.378 +        fprintf(header, "%5u%s", base_dist[i],
 349.379 +                SEPARATOR(i, D_CODES-1, 10));
 349.380 +    }
 349.381 +
 349.382 +    fclose(header);
 349.383 +}
 349.384 +#endif /* GEN_TREES_H */
 349.385 +
 349.386 +/* ===========================================================================
 349.387 + * Initialize the tree data structures for a new zlib stream.
 349.388 + */
 349.389 +void ZLIB_INTERNAL _tr_init(s)
 349.390 +    deflate_state *s;
 349.391 +{
 349.392 +    tr_static_init();
 349.393 +
 349.394 +    s->l_desc.dyn_tree = s->dyn_ltree;
 349.395 +    s->l_desc.stat_desc = &static_l_desc;
 349.396 +
 349.397 +    s->d_desc.dyn_tree = s->dyn_dtree;
 349.398 +    s->d_desc.stat_desc = &static_d_desc;
 349.399 +
 349.400 +    s->bl_desc.dyn_tree = s->bl_tree;
 349.401 +    s->bl_desc.stat_desc = &static_bl_desc;
 349.402 +
 349.403 +    s->bi_buf = 0;
 349.404 +    s->bi_valid = 0;
 349.405 +    s->last_eob_len = 8; /* enough lookahead for inflate */
 349.406 +#ifdef DEBUG
 349.407 +    s->compressed_len = 0L;
 349.408 +    s->bits_sent = 0L;
 349.409 +#endif
 349.410 +
 349.411 +    /* Initialize the first block of the first file: */
 349.412 +    init_block(s);
 349.413 +}
 349.414 +
 349.415 +/* ===========================================================================
 349.416 + * Initialize a new block.
 349.417 + */
 349.418 +local void init_block(s)
 349.419 +    deflate_state *s;
 349.420 +{
 349.421 +    int n; /* iterates over tree elements */
 349.422 +
 349.423 +    /* Initialize the trees. */
 349.424 +    for (n = 0; n < L_CODES;  n++) s->dyn_ltree[n].Freq = 0;
 349.425 +    for (n = 0; n < D_CODES;  n++) s->dyn_dtree[n].Freq = 0;
 349.426 +    for (n = 0; n < BL_CODES; n++) s->bl_tree[n].Freq = 0;
 349.427 +
 349.428 +    s->dyn_ltree[END_BLOCK].Freq = 1;
 349.429 +    s->opt_len = s->static_len = 0L;
 349.430 +    s->last_lit = s->matches = 0;
 349.431 +}
 349.432 +
 349.433 +#define SMALLEST 1
 349.434 +/* Index within the heap array of least frequent node in the Huffman tree */
 349.435 +
 349.436 +
 349.437 +/* ===========================================================================
 349.438 + * Remove the smallest element from the heap and recreate the heap with
 349.439 + * one less element. Updates heap and heap_len.
 349.440 + */
 349.441 +#define pqremove(s, tree, top) \
 349.442 +{\
 349.443 +    top = s->heap[SMALLEST]; \
 349.444 +    s->heap[SMALLEST] = s->heap[s->heap_len--]; \
 349.445 +    pqdownheap(s, tree, SMALLEST); \
 349.446 +}
 349.447 +
 349.448 +/* ===========================================================================
 349.449 + * Compares to subtrees, using the tree depth as tie breaker when
 349.450 + * the subtrees have equal frequency. This minimizes the worst case length.
 349.451 + */
 349.452 +#define smaller(tree, n, m, depth) \
 349.453 +   (tree[n].Freq < tree[m].Freq || \
 349.454 +   (tree[n].Freq == tree[m].Freq && depth[n] <= depth[m]))
 349.455 +
 349.456 +/* ===========================================================================
 349.457 + * Restore the heap property by moving down the tree starting at node k,
 349.458 + * exchanging a node with the smallest of its two sons if necessary, stopping
 349.459 + * when the heap property is re-established (each father smaller than its
 349.460 + * two sons).
 349.461 + */
 349.462 +local void pqdownheap(s, tree, k)
 349.463 +    deflate_state *s;
 349.464 +    ct_data *tree;  /* the tree to restore */
 349.465 +    int k;               /* node to move down */
 349.466 +{
 349.467 +    int v = s->heap[k];
 349.468 +    int j = k << 1;  /* left son of k */
 349.469 +    while (j <= s->heap_len) {
 349.470 +        /* Set j to the smallest of the two sons: */
 349.471 +        if (j < s->heap_len &&
 349.472 +            smaller(tree, s->heap[j+1], s->heap[j], s->depth)) {
 349.473 +            j++;
 349.474 +        }
 349.475 +        /* Exit if v is smaller than both sons */
 349.476 +        if (smaller(tree, v, s->heap[j], s->depth)) break;
 349.477 +
 349.478 +        /* Exchange v with the smallest son */
 349.479 +        s->heap[k] = s->heap[j];  k = j;
 349.480 +
 349.481 +        /* And continue down the tree, setting j to the left son of k */
 349.482 +        j <<= 1;
 349.483 +    }
 349.484 +    s->heap[k] = v;
 349.485 +}
 349.486 +
 349.487 +/* ===========================================================================
 349.488 + * Compute the optimal bit lengths for a tree and update the total bit length
 349.489 + * for the current block.
 349.490 + * IN assertion: the fields freq and dad are set, heap[heap_max] and
 349.491 + *    above are the tree nodes sorted by increasing frequency.
 349.492 + * OUT assertions: the field len is set to the optimal bit length, the
 349.493 + *     array bl_count contains the frequencies for each bit length.
 349.494 + *     The length opt_len is updated; static_len is also updated if stree is
 349.495 + *     not null.
 349.496 + */
 349.497 +local void gen_bitlen(s, desc)
 349.498 +    deflate_state *s;
 349.499 +    tree_desc *desc;    /* the tree descriptor */
 349.500 +{
 349.501 +    ct_data *tree        = desc->dyn_tree;
 349.502 +    int max_code         = desc->max_code;
 349.503 +    const ct_data *stree = desc->stat_desc->static_tree;
 349.504 +    const intf *extra    = desc->stat_desc->extra_bits;
 349.505 +    int base             = desc->stat_desc->extra_base;
 349.506 +    int max_length       = desc->stat_desc->max_length;
 349.507 +    int h;              /* heap index */
 349.508 +    int n, m;           /* iterate over the tree elements */
 349.509 +    int bits;           /* bit length */
 349.510 +    int xbits;          /* extra bits */
 349.511 +    ush f;              /* frequency */
 349.512 +    int overflow = 0;   /* number of elements with bit length too large */
 349.513 +
 349.514 +    for (bits = 0; bits <= MAX_BITS; bits++) s->bl_count[bits] = 0;
 349.515 +
 349.516 +    /* In a first pass, compute the optimal bit lengths (which may
 349.517 +     * overflow in the case of the bit length tree).
 349.518 +     */
 349.519 +    tree[s->heap[s->heap_max]].Len = 0; /* root of the heap */
 349.520 +
 349.521 +    for (h = s->heap_max+1; h < HEAP_SIZE; h++) {
 349.522 +        n = s->heap[h];
 349.523 +        bits = tree[tree[n].Dad].Len + 1;
 349.524 +        if (bits > max_length) bits = max_length, overflow++;
 349.525 +        tree[n].Len = (ush)bits;
 349.526 +        /* We overwrite tree[n].Dad which is no longer needed */
 349.527 +
 349.528 +        if (n > max_code) continue; /* not a leaf node */
 349.529 +
 349.530 +        s->bl_count[bits]++;
 349.531 +        xbits = 0;
 349.532 +        if (n >= base) xbits = extra[n-base];
 349.533 +        f = tree[n].Freq;
 349.534 +        s->opt_len += (ulg)f * (bits + xbits);
 349.535 +        if (stree) s->static_len += (ulg)f * (stree[n].Len + xbits);
 349.536 +    }
 349.537 +    if (overflow == 0) return;
 349.538 +
 349.539 +    Trace((stderr,"\nbit length overflow\n"));
 349.540 +    /* This happens for example on obj2 and pic of the Calgary corpus */
 349.541 +
 349.542 +    /* Find the first bit length which could increase: */
 349.543 +    do {
 349.544 +        bits = max_length-1;
 349.545 +        while (s->bl_count[bits] == 0) bits--;
 349.546 +        s->bl_count[bits]--;      /* move one leaf down the tree */
 349.547 +        s->bl_count[bits+1] += 2; /* move one overflow item as its brother */
 349.548 +        s->bl_count[max_length]--;
 349.549 +        /* The brother of the overflow item also moves one step up,
 349.550 +         * but this does not affect bl_count[max_length]
 349.551 +         */
 349.552 +        overflow -= 2;
 349.553 +    } while (overflow > 0);
 349.554 +
 349.555 +    /* Now recompute all bit lengths, scanning in increasing frequency.
 349.556 +     * h is still equal to HEAP_SIZE. (It is simpler to reconstruct all
 349.557 +     * lengths instead of fixing only the wrong ones. This idea is taken
 349.558 +     * from 'ar' written by Haruhiko Okumura.)
 349.559 +     */
 349.560 +    for (bits = max_length; bits != 0; bits--) {
 349.561 +        n = s->bl_count[bits];
 349.562 +        while (n != 0) {
 349.563 +            m = s->heap[--h];
 349.564 +            if (m > max_code) continue;
 349.565 +            if ((unsigned) tree[m].Len != (unsigned) bits) {
 349.566 +                Trace((stderr,"code %d bits %d->%d\n", m, tree[m].Len, bits));
 349.567 +                s->opt_len += ((long)bits - (long)tree[m].Len)
 349.568 +                              *(long)tree[m].Freq;
 349.569 +                tree[m].Len = (ush)bits;
 349.570 +            }
 349.571 +            n--;
 349.572 +        }
 349.573 +    }
 349.574 +}
 349.575 +
 349.576 +/* ===========================================================================
 349.577 + * Generate the codes for a given tree and bit counts (which need not be
 349.578 + * optimal).
 349.579 + * IN assertion: the array bl_count contains the bit length statistics for
 349.580 + * the given tree and the field len is set for all tree elements.
 349.581 + * OUT assertion: the field code is set for all tree elements of non
 349.582 + *     zero code length.
 349.583 + */
 349.584 +local void gen_codes (tree, max_code, bl_count)
 349.585 +    ct_data *tree;             /* the tree to decorate */
 349.586 +    int max_code;              /* largest code with non zero frequency */
 349.587 +    ushf *bl_count;            /* number of codes at each bit length */
 349.588 +{
 349.589 +    ush next_code[MAX_BITS+1]; /* next code value for each bit length */
 349.590 +    ush code = 0;              /* running code value */
 349.591 +    int bits;                  /* bit index */
 349.592 +    int n;                     /* code index */
 349.593 +
 349.594 +    /* The distribution counts are first used to generate the code values
 349.595 +     * without bit reversal.
 349.596 +     */
 349.597 +    for (bits = 1; bits <= MAX_BITS; bits++) {
 349.598 +        next_code[bits] = code = (code + bl_count[bits-1]) << 1;
 349.599 +    }
 349.600 +    /* Check that the bit counts in bl_count are consistent. The last code
 349.601 +     * must be all ones.
 349.602 +     */
 349.603 +    Assert (code + bl_count[MAX_BITS]-1 == (1<<MAX_BITS)-1,
 349.604 +            "inconsistent bit counts");
 349.605 +    Tracev((stderr,"\ngen_codes: max_code %d ", max_code));
 349.606 +
 349.607 +    for (n = 0;  n <= max_code; n++) {
 349.608 +        int len = tree[n].Len;
 349.609 +        if (len == 0) continue;
 349.610 +        /* Now reverse the bits */
 349.611 +        tree[n].Code = bi_reverse(next_code[len]++, len);
 349.612 +
 349.613 +        Tracecv(tree != static_ltree, (stderr,"\nn %3d %c l %2d c %4x (%x) ",
 349.614 +             n, (isgraph(n) ? n : ' '), len, tree[n].Code, next_code[len]-1));
 349.615 +    }
 349.616 +}
 349.617 +
 349.618 +/* ===========================================================================
 349.619 + * Construct one Huffman tree and assigns the code bit strings and lengths.
 349.620 + * Update the total bit length for the current block.
 349.621 + * IN assertion: the field freq is set for all tree elements.
 349.622 + * OUT assertions: the fields len and code are set to the optimal bit length
 349.623 + *     and corresponding code. The length opt_len is updated; static_len is
 349.624 + *     also updated if stree is not null. The field max_code is set.
 349.625 + */
 349.626 +local void build_tree(s, desc)
 349.627 +    deflate_state *s;
 349.628 +    tree_desc *desc; /* the tree descriptor */
 349.629 +{
 349.630 +    ct_data *tree         = desc->dyn_tree;
 349.631 +    const ct_data *stree  = desc->stat_desc->static_tree;
 349.632 +    int elems             = desc->stat_desc->elems;
 349.633 +    int n, m;          /* iterate over heap elements */
 349.634 +    int max_code = -1; /* largest code with non zero frequency */
 349.635 +    int node;          /* new node being created */
 349.636 +
 349.637 +    /* Construct the initial heap, with least frequent element in
 349.638 +     * heap[SMALLEST]. The sons of heap[n] are heap[2*n] and heap[2*n+1].
 349.639 +     * heap[0] is not used.
 349.640 +     */
 349.641 +    s->heap_len = 0, s->heap_max = HEAP_SIZE;
 349.642 +
 349.643 +    for (n = 0; n < elems; n++) {
 349.644 +        if (tree[n].Freq != 0) {
 349.645 +            s->heap[++(s->heap_len)] = max_code = n;
 349.646 +            s->depth[n] = 0;
 349.647 +        } else {
 349.648 +            tree[n].Len = 0;
 349.649 +        }
 349.650 +    }
 349.651 +
 349.652 +    /* The pkzip format requires that at least one distance code exists,
 349.653 +     * and that at least one bit should be sent even if there is only one
 349.654 +     * possible code. So to avoid special checks later on we force at least
 349.655 +     * two codes of non zero frequency.
 349.656 +     */
 349.657 +    while (s->heap_len < 2) {
 349.658 +        node = s->heap[++(s->heap_len)] = (max_code < 2 ? ++max_code : 0);
 349.659 +        tree[node].Freq = 1;
 349.660 +        s->depth[node] = 0;
 349.661 +        s->opt_len--; if (stree) s->static_len -= stree[node].Len;
 349.662 +        /* node is 0 or 1 so it does not have extra bits */
 349.663 +    }
 349.664 +    desc->max_code = max_code;
 349.665 +
 349.666 +    /* The elements heap[heap_len/2+1 .. heap_len] are leaves of the tree,
 349.667 +     * establish sub-heaps of increasing lengths:
 349.668 +     */
 349.669 +    for (n = s->heap_len/2; n >= 1; n--) pqdownheap(s, tree, n);
 349.670 +
 349.671 +    /* Construct the Huffman tree by repeatedly combining the least two
 349.672 +     * frequent nodes.
 349.673 +     */
 349.674 +    node = elems;              /* next internal node of the tree */
 349.675 +    do {
 349.676 +        pqremove(s, tree, n);  /* n = node of least frequency */
 349.677 +        m = s->heap[SMALLEST]; /* m = node of next least frequency */
 349.678 +
 349.679 +        s->heap[--(s->heap_max)] = n; /* keep the nodes sorted by frequency */
 349.680 +        s->heap[--(s->heap_max)] = m;
 349.681 +
 349.682 +        /* Create a new node father of n and m */
 349.683 +        tree[node].Freq = tree[n].Freq + tree[m].Freq;
 349.684 +        s->depth[node] = (uch)((s->depth[n] >= s->depth[m] ?
 349.685 +                                s->depth[n] : s->depth[m]) + 1);
 349.686 +        tree[n].Dad = tree[m].Dad = (ush)node;
 349.687 +#ifdef DUMP_BL_TREE
 349.688 +        if (tree == s->bl_tree) {
 349.689 +            fprintf(stderr,"\nnode %d(%d), sons %d(%d) %d(%d)",
 349.690 +                    node, tree[node].Freq, n, tree[n].Freq, m, tree[m].Freq);
 349.691 +        }
 349.692 +#endif
 349.693 +        /* and insert the new node in the heap */
 349.694 +        s->heap[SMALLEST] = node++;
 349.695 +        pqdownheap(s, tree, SMALLEST);
 349.696 +
 349.697 +    } while (s->heap_len >= 2);
 349.698 +
 349.699 +    s->heap[--(s->heap_max)] = s->heap[SMALLEST];
 349.700 +
 349.701 +    /* At this point, the fields freq and dad are set. We can now
 349.702 +     * generate the bit lengths.
 349.703 +     */
 349.704 +    gen_bitlen(s, (tree_desc *)desc);
 349.705 +
 349.706 +    /* The field len is now set, we can generate the bit codes */
 349.707 +    gen_codes ((ct_data *)tree, max_code, s->bl_count);
 349.708 +}
 349.709 +
 349.710 +/* ===========================================================================
 349.711 + * Scan a literal or distance tree to determine the frequencies of the codes
 349.712 + * in the bit length tree.
 349.713 + */
 349.714 +local void scan_tree (s, tree, max_code)
 349.715 +    deflate_state *s;
 349.716 +    ct_data *tree;   /* the tree to be scanned */
 349.717 +    int max_code;    /* and its largest code of non zero frequency */
 349.718 +{
 349.719 +    int n;                     /* iterates over all tree elements */
 349.720 +    int prevlen = -1;          /* last emitted length */
 349.721 +    int curlen;                /* length of current code */
 349.722 +    int nextlen = tree[0].Len; /* length of next code */
 349.723 +    int count = 0;             /* repeat count of the current code */
 349.724 +    int max_count = 7;         /* max repeat count */
 349.725 +    int min_count = 4;         /* min repeat count */
 349.726 +
 349.727 +    if (nextlen == 0) max_count = 138, min_count = 3;
 349.728 +    tree[max_code+1].Len = (ush)0xffff; /* guard */
 349.729 +
 349.730 +    for (n = 0; n <= max_code; n++) {
 349.731 +        curlen = nextlen; nextlen = tree[n+1].Len;
 349.732 +        if (++count < max_count && curlen == nextlen) {
 349.733 +            continue;
 349.734 +        } else if (count < min_count) {
 349.735 +            s->bl_tree[curlen].Freq += count;
 349.736 +        } else if (curlen != 0) {
 349.737 +            if (curlen != prevlen) s->bl_tree[curlen].Freq++;
 349.738 +            s->bl_tree[REP_3_6].Freq++;
 349.739 +        } else if (count <= 10) {
 349.740 +            s->bl_tree[REPZ_3_10].Freq++;
 349.741 +        } else {
 349.742 +            s->bl_tree[REPZ_11_138].Freq++;
 349.743 +        }
 349.744 +        count = 0; prevlen = curlen;
 349.745 +        if (nextlen == 0) {
 349.746 +            max_count = 138, min_count = 3;
 349.747 +        } else if (curlen == nextlen) {
 349.748 +            max_count = 6, min_count = 3;
 349.749 +        } else {
 349.750 +            max_count = 7, min_count = 4;
 349.751 +        }
 349.752 +    }
 349.753 +}
 349.754 +
 349.755 +/* ===========================================================================
 349.756 + * Send a literal or distance tree in compressed form, using the codes in
 349.757 + * bl_tree.
 349.758 + */
 349.759 +local void send_tree (s, tree, max_code)
 349.760 +    deflate_state *s;
 349.761 +    ct_data *tree; /* the tree to be scanned */
 349.762 +    int max_code;       /* and its largest code of non zero frequency */
 349.763 +{
 349.764 +    int n;                     /* iterates over all tree elements */
 349.765 +    int prevlen = -1;          /* last emitted length */
 349.766 +    int curlen;                /* length of current code */
 349.767 +    int nextlen = tree[0].Len; /* length of next code */
 349.768 +    int count = 0;             /* repeat count of the current code */
 349.769 +    int max_count = 7;         /* max repeat count */
 349.770 +    int min_count = 4;         /* min repeat count */
 349.771 +
 349.772 +    /* tree[max_code+1].Len = -1; */  /* guard already set */
 349.773 +    if (nextlen == 0) max_count = 138, min_count = 3;
 349.774 +
 349.775 +    for (n = 0; n <= max_code; n++) {
 349.776 +        curlen = nextlen; nextlen = tree[n+1].Len;
 349.777 +        if (++count < max_count && curlen == nextlen) {
 349.778 +            continue;
 349.779 +        } else if (count < min_count) {
 349.780 +            do { send_code(s, curlen, s->bl_tree); } while (--count != 0);
 349.781 +
 349.782 +        } else if (curlen != 0) {
 349.783 +            if (curlen != prevlen) {
 349.784 +                send_code(s, curlen, s->bl_tree); count--;
 349.785 +            }
 349.786 +            Assert(count >= 3 && count <= 6, " 3_6?");
 349.787 +            send_code(s, REP_3_6, s->bl_tree); send_bits(s, count-3, 2);
 349.788 +
 349.789 +        } else if (count <= 10) {
 349.790 +            send_code(s, REPZ_3_10, s->bl_tree); send_bits(s, count-3, 3);
 349.791 +
 349.792 +        } else {
 349.793 +            send_code(s, REPZ_11_138, s->bl_tree); send_bits(s, count-11, 7);
 349.794 +        }
 349.795 +        count = 0; prevlen = curlen;
 349.796 +        if (nextlen == 0) {
 349.797 +            max_count = 138, min_count = 3;
 349.798 +        } else if (curlen == nextlen) {
 349.799 +            max_count = 6, min_count = 3;
 349.800 +        } else {
 349.801 +            max_count = 7, min_count = 4;
 349.802 +        }
 349.803 +    }
 349.804 +}
 349.805 +
 349.806 +/* ===========================================================================
 349.807 + * Construct the Huffman tree for the bit lengths and return the index in
 349.808 + * bl_order of the last bit length code to send.
 349.809 + */
 349.810 +local int build_bl_tree(s)
 349.811 +    deflate_state *s;
 349.812 +{
 349.813 +    int max_blindex;  /* index of last bit length code of non zero freq */
 349.814 +
 349.815 +    /* Determine the bit length frequencies for literal and distance trees */
 349.816 +    scan_tree(s, (ct_data *)s->dyn_ltree, s->l_desc.max_code);
 349.817 +    scan_tree(s, (ct_data *)s->dyn_dtree, s->d_desc.max_code);
 349.818 +
 349.819 +    /* Build the bit length tree: */
 349.820 +    build_tree(s, (tree_desc *)(&(s->bl_desc)));
 349.821 +    /* opt_len now includes the length of the tree representations, except
 349.822 +     * the lengths of the bit lengths codes and the 5+5+4 bits for the counts.
 349.823 +     */
 349.824 +
 349.825 +    /* Determine the number of bit length codes to send. The pkzip format
 349.826 +     * requires that at least 4 bit length codes be sent. (appnote.txt says
 349.827 +     * 3 but the actual value used is 4.)
 349.828 +     */
 349.829 +    for (max_blindex = BL_CODES-1; max_blindex >= 3; max_blindex--) {
 349.830 +        if (s->bl_tree[bl_order[max_blindex]].Len != 0) break;
 349.831 +    }
 349.832 +    /* Update opt_len to include the bit length tree and counts */
 349.833 +    s->opt_len += 3*(max_blindex+1) + 5+5+4;
 349.834 +    Tracev((stderr, "\ndyn trees: dyn %ld, stat %ld",
 349.835 +            s->opt_len, s->static_len));
 349.836 +
 349.837 +    return max_blindex;
 349.838 +}
 349.839 +
 349.840 +/* ===========================================================================
 349.841 + * Send the header for a block using dynamic Huffman trees: the counts, the
 349.842 + * lengths of the bit length codes, the literal tree and the distance tree.
 349.843 + * IN assertion: lcodes >= 257, dcodes >= 1, blcodes >= 4.
 349.844 + */
 349.845 +local void send_all_trees(s, lcodes, dcodes, blcodes)
 349.846 +    deflate_state *s;
 349.847 +    int lcodes, dcodes, blcodes; /* number of codes for each tree */
 349.848 +{
 349.849 +    int rank;                    /* index in bl_order */
 349.850 +
 349.851 +    Assert (lcodes >= 257 && dcodes >= 1 && blcodes >= 4, "not enough codes");
 349.852 +    Assert (lcodes <= L_CODES && dcodes <= D_CODES && blcodes <= BL_CODES,
 349.853 +            "too many codes");
 349.854 +    Tracev((stderr, "\nbl counts: "));
 349.855 +    send_bits(s, lcodes-257, 5); /* not +255 as stated in appnote.txt */
 349.856 +    send_bits(s, dcodes-1,   5);
 349.857 +    send_bits(s, blcodes-4,  4); /* not -3 as stated in appnote.txt */
 349.858 +    for (rank = 0; rank < blcodes; rank++) {
 349.859 +        Tracev((stderr, "\nbl code %2d ", bl_order[rank]));
 349.860 +        send_bits(s, s->bl_tree[bl_order[rank]].Len, 3);
 349.861 +    }
 349.862 +    Tracev((stderr, "\nbl tree: sent %ld", s->bits_sent));
 349.863 +
 349.864 +    send_tree(s, (ct_data *)s->dyn_ltree, lcodes-1); /* literal tree */
 349.865 +    Tracev((stderr, "\nlit tree: sent %ld", s->bits_sent));
 349.866 +
 349.867 +    send_tree(s, (ct_data *)s->dyn_dtree, dcodes-1); /* distance tree */
 349.868 +    Tracev((stderr, "\ndist tree: sent %ld", s->bits_sent));
 349.869 +}
 349.870 +
 349.871 +/* ===========================================================================
 349.872 + * Send a stored block
 349.873 + */
 349.874 +void ZLIB_INTERNAL _tr_stored_block(s, buf, stored_len, last)
 349.875 +    deflate_state *s;
 349.876 +    charf *buf;       /* input block */
 349.877 +    ulg stored_len;   /* length of input block */
 349.878 +    int last;         /* one if this is the last block for a file */
 349.879 +{
 349.880 +    send_bits(s, (STORED_BLOCK<<1)+last, 3);    /* send block type */
 349.881 +#ifdef DEBUG
 349.882 +    s->compressed_len = (s->compressed_len + 3 + 7) & (ulg)~7L;
 349.883 +    s->compressed_len += (stored_len + 4) << 3;
 349.884 +#endif
 349.885 +    copy_block(s, buf, (unsigned)stored_len, 1); /* with header */
 349.886 +}
 349.887 +
 349.888 +/* ===========================================================================
 349.889 + * Send one empty static block to give enough lookahead for inflate.
 349.890 + * This takes 10 bits, of which 7 may remain in the bit buffer.
 349.891 + * The current inflate code requires 9 bits of lookahead. If the
 349.892 + * last two codes for the previous block (real code plus EOB) were coded
 349.893 + * on 5 bits or less, inflate may have only 5+3 bits of lookahead to decode
 349.894 + * the last real code. In this case we send two empty static blocks instead
 349.895 + * of one. (There are no problems if the previous block is stored or fixed.)
 349.896 + * To simplify the code, we assume the worst case of last real code encoded
 349.897 + * on one bit only.
 349.898 + */
 349.899 +void ZLIB_INTERNAL _tr_align(s)
 349.900 +    deflate_state *s;
 349.901 +{
 349.902 +    send_bits(s, STATIC_TREES<<1, 3);
 349.903 +    send_code(s, END_BLOCK, static_ltree);
 349.904 +#ifdef DEBUG
 349.905 +    s->compressed_len += 10L; /* 3 for block type, 7 for EOB */
 349.906 +#endif
 349.907 +    bi_flush(s);
 349.908 +    /* Of the 10 bits for the empty block, we have already sent
 349.909 +     * (10 - bi_valid) bits. The lookahead for the last real code (before
 349.910 +     * the EOB of the previous block) was thus at least one plus the length
 349.911 +     * of the EOB plus what we have just sent of the empty static block.
 349.912 +     */
 349.913 +    if (1 + s->last_eob_len + 10 - s->bi_valid < 9) {
 349.914 +        send_bits(s, STATIC_TREES<<1, 3);
 349.915 +        send_code(s, END_BLOCK, static_ltree);
 349.916 +#ifdef DEBUG
 349.917 +        s->compressed_len += 10L;
 349.918 +#endif
 349.919 +        bi_flush(s);
 349.920 +    }
 349.921 +    s->last_eob_len = 7;
 349.922 +}
 349.923 +
 349.924 +/* ===========================================================================
 349.925 + * Determine the best encoding for the current block: dynamic trees, static
 349.926 + * trees or store, and output the encoded block to the zip file.
 349.927 + */
 349.928 +void ZLIB_INTERNAL _tr_flush_block(s, buf, stored_len, last)
 349.929 +    deflate_state *s;
 349.930 +    charf *buf;       /* input block, or NULL if too old */
 349.931 +    ulg stored_len;   /* length of input block */
 349.932 +    int last;         /* one if this is the last block for a file */
 349.933 +{
 349.934 +    ulg opt_lenb, static_lenb; /* opt_len and static_len in bytes */
 349.935 +    int max_blindex = 0;  /* index of last bit length code of non zero freq */
 349.936 +
 349.937 +    /* Build the Huffman trees unless a stored block is forced */
 349.938 +    if (s->level > 0) {
 349.939 +
 349.940 +        /* Check if the file is binary or text */
 349.941 +        if (s->strm->data_type == Z_UNKNOWN)
 349.942 +            s->strm->data_type = detect_data_type(s);
 349.943 +
 349.944 +        /* Construct the literal and distance trees */
 349.945 +        build_tree(s, (tree_desc *)(&(s->l_desc)));
 349.946 +        Tracev((stderr, "\nlit data: dyn %ld, stat %ld", s->opt_len,
 349.947 +                s->static_len));
 349.948 +
 349.949 +        build_tree(s, (tree_desc *)(&(s->d_desc)));
 349.950 +        Tracev((stderr, "\ndist data: dyn %ld, stat %ld", s->opt_len,
 349.951 +                s->static_len));
 349.952 +        /* At this point, opt_len and static_len are the total bit lengths of
 349.953 +         * the compressed block data, excluding the tree representations.
 349.954 +         */
 349.955 +
 349.956 +        /* Build the bit length tree for the above two trees, and get the index
 349.957 +         * in bl_order of the last bit length code to send.
 349.958 +         */
 349.959 +        max_blindex = build_bl_tree(s);
 349.960 +
 349.961 +        /* Determine the best encoding. Compute the block lengths in bytes. */
 349.962 +        opt_lenb = (s->opt_len+3+7)>>3;
 349.963 +        static_lenb = (s->static_len+3+7)>>3;
 349.964 +
 349.965 +        Tracev((stderr, "\nopt %lu(%lu) stat %lu(%lu) stored %lu lit %u ",
 349.966 +                opt_lenb, s->opt_len, static_lenb, s->static_len, stored_len,
 349.967 +                s->last_lit));
 349.968 +
 349.969 +        if (static_lenb <= opt_lenb) opt_lenb = static_lenb;
 349.970 +
 349.971 +    } else {
 349.972 +        Assert(buf != (char*)0, "lost buf");
 349.973 +        opt_lenb = static_lenb = stored_len + 5; /* force a stored block */
 349.974 +    }
 349.975 +
 349.976 +#ifdef FORCE_STORED
 349.977 +    if (buf != (char*)0) { /* force stored block */
 349.978 +#else
 349.979 +    if (stored_len+4 <= opt_lenb && buf != (char*)0) {
 349.980 +                       /* 4: two words for the lengths */
 349.981 +#endif
 349.982 +        /* The test buf != NULL is only necessary if LIT_BUFSIZE > WSIZE.
 349.983 +         * Otherwise we can't have processed more than WSIZE input bytes since
 349.984 +         * the last block flush, because compression would have been
 349.985 +         * successful. If LIT_BUFSIZE <= WSIZE, it is never too late to
 349.986 +         * transform a block into a stored block.
 349.987 +         */
 349.988 +        _tr_stored_block(s, buf, stored_len, last);
 349.989 +
 349.990 +#ifdef FORCE_STATIC
 349.991 +    } else if (static_lenb >= 0) { /* force static trees */
 349.992 +#else
 349.993 +    } else if (s->strategy == Z_FIXED || static_lenb == opt_lenb) {
 349.994 +#endif
 349.995 +        send_bits(s, (STATIC_TREES<<1)+last, 3);
 349.996 +        compress_block(s, (ct_data *)static_ltree, (ct_data *)static_dtree);
 349.997 +#ifdef DEBUG
 349.998 +        s->compressed_len += 3 + s->static_len;
 349.999 +#endif
349.1000 +    } else {
349.1001 +        send_bits(s, (DYN_TREES<<1)+last, 3);
349.1002 +        send_all_trees(s, s->l_desc.max_code+1, s->d_desc.max_code+1,
349.1003 +                       max_blindex+1);
349.1004 +        compress_block(s, (ct_data *)s->dyn_ltree, (ct_data *)s->dyn_dtree);
349.1005 +#ifdef DEBUG
349.1006 +        s->compressed_len += 3 + s->opt_len;
349.1007 +#endif
349.1008 +    }
349.1009 +    Assert (s->compressed_len == s->bits_sent, "bad compressed size");
349.1010 +    /* The above check is made mod 2^32, for files larger than 512 MB
349.1011 +     * and uLong implemented on 32 bits.
349.1012 +     */
349.1013 +    init_block(s);
349.1014 +
349.1015 +    if (last) {
349.1016 +        bi_windup(s);
349.1017 +#ifdef DEBUG
349.1018 +        s->compressed_len += 7;  /* align on byte boundary */
349.1019 +#endif
349.1020 +    }
349.1021 +    Tracev((stderr,"\ncomprlen %lu(%lu) ", s->compressed_len>>3,
349.1022 +           s->compressed_len-7*last));
349.1023 +}
349.1024 +
349.1025 +/* ===========================================================================
349.1026 + * Save the match info and tally the frequency counts. Return true if
349.1027 + * the current block must be flushed.
349.1028 + */
349.1029 +int ZLIB_INTERNAL _tr_tally (s, dist, lc)
349.1030 +    deflate_state *s;
349.1031 +    unsigned dist;  /* distance of matched string */
349.1032 +    unsigned lc;    /* match length-MIN_MATCH or unmatched char (if dist==0) */
349.1033 +{
349.1034 +    s->d_buf[s->last_lit] = (ush)dist;
349.1035 +    s->l_buf[s->last_lit++] = (uch)lc;
349.1036 +    if (dist == 0) {
349.1037 +        /* lc is the unmatched char */
349.1038 +        s->dyn_ltree[lc].Freq++;
349.1039 +    } else {
349.1040 +        s->matches++;
349.1041 +        /* Here, lc is the match length - MIN_MATCH */
349.1042 +        dist--;             /* dist = match distance - 1 */
349.1043 +        Assert((ush)dist < (ush)MAX_DIST(s) &&
349.1044 +               (ush)lc <= (ush)(MAX_MATCH-MIN_MATCH) &&
349.1045 +               (ush)d_code(dist) < (ush)D_CODES,  "_tr_tally: bad match");
349.1046 +
349.1047 +        s->dyn_ltree[_length_code[lc]+LITERALS+1].Freq++;
349.1048 +        s->dyn_dtree[d_code(dist)].Freq++;
349.1049 +    }
349.1050 +
349.1051 +#ifdef TRUNCATE_BLOCK
349.1052 +    /* Try to guess if it is profitable to stop the current block here */
349.1053 +    if ((s->last_lit & 0x1fff) == 0 && s->level > 2) {
349.1054 +        /* Compute an upper bound for the compressed length */
349.1055 +        ulg out_length = (ulg)s->last_lit*8L;
349.1056 +        ulg in_length = (ulg)((long)s->strstart - s->block_start);
349.1057 +        int dcode;
349.1058 +        for (dcode = 0; dcode < D_CODES; dcode++) {
349.1059 +            out_length += (ulg)s->dyn_dtree[dcode].Freq *
349.1060 +                (5L+extra_dbits[dcode]);
349.1061 +        }
349.1062 +        out_length >>= 3;
349.1063 +        Tracev((stderr,"\nlast_lit %u, in %ld, out ~%ld(%ld%%) ",
349.1064 +               s->last_lit, in_length, out_length,
349.1065 +               100L - out_length*100L/in_length));
349.1066 +        if (s->matches < s->last_lit/2 && out_length < in_length/2) return 1;
349.1067 +    }
349.1068 +#endif
349.1069 +    return (s->last_lit == s->lit_bufsize-1);
349.1070 +    /* We avoid equality with lit_bufsize because of wraparound at 64K
349.1071 +     * on 16 bit machines and because stored blocks are restricted to
349.1072 +     * 64K-1 bytes.
349.1073 +     */
349.1074 +}
349.1075 +
349.1076 +/* ===========================================================================
349.1077 + * Send the block data compressed using the given Huffman trees
349.1078 + */
349.1079 +local void compress_block(s, ltree, dtree)
349.1080 +    deflate_state *s;
349.1081 +    ct_data *ltree; /* literal tree */
349.1082 +    ct_data *dtree; /* distance tree */
349.1083 +{
349.1084 +    unsigned dist;      /* distance of matched string */
349.1085 +    int lc;             /* match length or unmatched char (if dist == 0) */
349.1086 +    unsigned lx = 0;    /* running index in l_buf */
349.1087 +    unsigned code;      /* the code to send */
349.1088 +    int extra;          /* number of extra bits to send */
349.1089 +
349.1090 +    if (s->last_lit != 0) do {
349.1091 +        dist = s->d_buf[lx];
349.1092 +        lc = s->l_buf[lx++];
349.1093 +        if (dist == 0) {
349.1094 +            send_code(s, lc, ltree); /* send a literal byte */
349.1095 +            Tracecv(isgraph(lc), (stderr," '%c' ", lc));
349.1096 +        } else {
349.1097 +            /* Here, lc is the match length - MIN_MATCH */
349.1098 +            code = _length_code[lc];
349.1099 +            send_code(s, code+LITERALS+1, ltree); /* send the length code */
349.1100 +            extra = extra_lbits[code];
349.1101 +            if (extra != 0) {
349.1102 +                lc -= base_length[code];
349.1103 +                send_bits(s, lc, extra);       /* send the extra length bits */
349.1104 +            }
349.1105 +            dist--; /* dist is now the match distance - 1 */
349.1106 +            code = d_code(dist);
349.1107 +            Assert (code < D_CODES, "bad d_code");
349.1108 +
349.1109 +            send_code(s, code, dtree);       /* send the distance code */
349.1110 +            extra = extra_dbits[code];
349.1111 +            if (extra != 0) {
349.1112 +                dist -= base_dist[code];
349.1113 +                send_bits(s, dist, extra);   /* send the extra distance bits */
349.1114 +            }
349.1115 +        } /* literal or match pair ? */
349.1116 +
349.1117 +        /* Check that the overlay between pending_buf and d_buf+l_buf is ok: */
349.1118 +        Assert((uInt)(s->pending) < s->lit_bufsize + 2*lx,
349.1119 +               "pendingBuf overflow");
349.1120 +
349.1121 +    } while (lx < s->last_lit);
349.1122 +
349.1123 +    send_code(s, END_BLOCK, ltree);
349.1124 +    s->last_eob_len = ltree[END_BLOCK].Len;
349.1125 +}
349.1126 +
349.1127 +/* ===========================================================================
349.1128 + * Check if the data type is TEXT or BINARY, using the following algorithm:
349.1129 + * - TEXT if the two conditions below are satisfied:
349.1130 + *    a) There are no non-portable control characters belonging to the
349.1131 + *       "black list" (0..6, 14..25, 28..31).
349.1132 + *    b) There is at least one printable character belonging to the
349.1133 + *       "white list" (9 {TAB}, 10 {LF}, 13 {CR}, 32..255).
349.1134 + * - BINARY otherwise.
349.1135 + * - The following partially-portable control characters form a
349.1136 + *   "gray list" that is ignored in this detection algorithm:
349.1137 + *   (7 {BEL}, 8 {BS}, 11 {VT}, 12 {FF}, 26 {SUB}, 27 {ESC}).
349.1138 + * IN assertion: the fields Freq of dyn_ltree are set.
349.1139 + */
349.1140 +local int detect_data_type(s)
349.1141 +    deflate_state *s;
349.1142 +{
349.1143 +    /* black_mask is the bit mask of black-listed bytes
349.1144 +     * set bits 0..6, 14..25, and 28..31
349.1145 +     * 0xf3ffc07f = binary 11110011111111111100000001111111
349.1146 +     */
349.1147 +    unsigned long black_mask = 0xf3ffc07fUL;
349.1148 +    int n;
349.1149 +
349.1150 +    /* Check for non-textual ("black-listed") bytes. */
349.1151 +    for (n = 0; n <= 31; n++, black_mask >>= 1)
349.1152 +        if ((black_mask & 1) && (s->dyn_ltree[n].Freq != 0))
349.1153 +            return Z_BINARY;
349.1154 +
349.1155 +    /* Check for textual ("white-listed") bytes. */
349.1156 +    if (s->dyn_ltree[9].Freq != 0 || s->dyn_ltree[10].Freq != 0
349.1157 +            || s->dyn_ltree[13].Freq != 0)
349.1158 +        return Z_TEXT;
349.1159 +    for (n = 32; n < LITERALS; n++)
349.1160 +        if (s->dyn_ltree[n].Freq != 0)
349.1161 +            return Z_TEXT;
349.1162 +
349.1163 +    /* There are no "black-listed" or "white-listed" bytes:
349.1164 +     * this stream either is empty or has tolerated ("gray-listed") bytes only.
349.1165 +     */
349.1166 +    return Z_BINARY;
349.1167 +}
349.1168 +
349.1169 +/* ===========================================================================
349.1170 + * Reverse the first len bits of a code, using straightforward code (a faster
349.1171 + * method would use a table)
349.1172 + * IN assertion: 1 <= len <= 15
349.1173 + */
349.1174 +local unsigned bi_reverse(code, len)
349.1175 +    unsigned code; /* the value to invert */
349.1176 +    int len;       /* its bit length */
349.1177 +{
349.1178 +    register unsigned res = 0;
349.1179 +    do {
349.1180 +        res |= code & 1;
349.1181 +        code >>= 1, res <<= 1;
349.1182 +    } while (--len > 0);
349.1183 +    return res >> 1;
349.1184 +}
349.1185 +
349.1186 +/* ===========================================================================
349.1187 + * Flush the bit buffer, keeping at most 7 bits in it.
349.1188 + */
349.1189 +local void bi_flush(s)
349.1190 +    deflate_state *s;
349.1191 +{
349.1192 +    if (s->bi_valid == 16) {
349.1193 +        put_short(s, s->bi_buf);
349.1194 +        s->bi_buf = 0;
349.1195 +        s->bi_valid = 0;
349.1196 +    } else if (s->bi_valid >= 8) {
349.1197 +        put_byte(s, (Byte)s->bi_buf);
349.1198 +        s->bi_buf >>= 8;
349.1199 +        s->bi_valid -= 8;
349.1200 +    }
349.1201 +}
349.1202 +
349.1203 +/* ===========================================================================
349.1204 + * Flush the bit buffer and align the output on a byte boundary
349.1205 + */
349.1206 +local void bi_windup(s)
349.1207 +    deflate_state *s;
349.1208 +{
349.1209 +    if (s->bi_valid > 8) {
349.1210 +        put_short(s, s->bi_buf);
349.1211 +    } else if (s->bi_valid > 0) {
349.1212 +        put_byte(s, (Byte)s->bi_buf);
349.1213 +    }
349.1214 +    s->bi_buf = 0;
349.1215 +    s->bi_valid = 0;
349.1216 +#ifdef DEBUG
349.1217 +    s->bits_sent = (s->bits_sent+7) & ~7;
349.1218 +#endif
349.1219 +}
349.1220 +
349.1221 +/* ===========================================================================
349.1222 + * Copy a stored block, storing first the length and its
349.1223 + * one's complement if requested.
349.1224 + */
349.1225 +local void copy_block(s, buf, len, header)
349.1226 +    deflate_state *s;
349.1227 +    charf    *buf;    /* the input data */
349.1228 +    unsigned len;     /* its length */
349.1229 +    int      header;  /* true if block header must be written */
349.1230 +{
349.1231 +    bi_windup(s);        /* align on byte boundary */
349.1232 +    s->last_eob_len = 8; /* enough lookahead for inflate */
349.1233 +
349.1234 +    if (header) {
349.1235 +        put_short(s, (ush)len);
349.1236 +        put_short(s, (ush)~len);
349.1237 +#ifdef DEBUG
349.1238 +        s->bits_sent += 2*16;
349.1239 +#endif
349.1240 +    }
349.1241 +#ifdef DEBUG
349.1242 +    s->bits_sent += (ulg)len<<3;
349.1243 +#endif
349.1244 +    while (len--) {
349.1245 +        put_byte(s, *buf++);
349.1246 +    }
349.1247 +}
   350.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
   350.2 +++ b/deps/glpk/src/zlib/trees.h	Sun Nov 06 20:59:10 2011 +0100
   350.3 @@ -0,0 +1,128 @@
   350.4 +/* header created automatically with -DGEN_TREES_H */
   350.5 +
   350.6 +local const ct_data static_ltree[L_CODES+2] = {
   350.7 +{{ 12},{  8}}, {{140},{  8}}, {{ 76},{  8}}, {{204},{  8}}, {{ 44},{  8}},
   350.8 +{{172},{  8}}, {{108},{  8}}, {{236},{  8}}, {{ 28},{  8}}, {{156},{  8}},
   350.9 +{{ 92},{  8}}, {{220},{  8}}, {{ 60},{  8}}, {{188},{  8}}, {{124},{  8}},
  350.10 +{{252},{  8}}, {{  2},{  8}}, {{130},{  8}}, {{ 66},{  8}}, {{194},{  8}},
  350.11 +{{ 34},{  8}}, {{162},{  8}}, {{ 98},{  8}}, {{226},{  8}}, {{ 18},{  8}},
  350.12 +{{146},{  8}}, {{ 82},{  8}}, {{210},{  8}}, {{ 50},{  8}}, {{178},{  8}},
  350.13 +{{114},{  8}}, {{242},{  8}}, {{ 10},{  8}}, {{138},{  8}}, {{ 74},{  8}},
  350.14 +{{202},{  8}}, {{ 42},{  8}}, {{170},{  8}}, {{106},{  8}}, {{234},{  8}},
  350.15 +{{ 26},{  8}}, {{154},{  8}}, {{ 90},{  8}}, {{218},{  8}}, {{ 58},{  8}},
  350.16 +{{186},{  8}}, {{122},{  8}}, {{250},{  8}}, {{  6},{  8}}, {{134},{  8}},
  350.17 +{{ 70},{  8}}, {{198},{  8}}, {{ 38},{  8}}, {{166},{  8}}, {{102},{  8}},
  350.18 +{{230},{  8}}, {{ 22},{  8}}, {{150},{  8}}, {{ 86},{  8}}, {{214},{  8}},
  350.19 +{{ 54},{  8}}, {{182},{  8}}, {{118},{  8}}, {{246},{  8}}, {{ 14},{  8}},
  350.20 +{{142},{  8}}, {{ 78},{  8}}, {{206},{  8}}, {{ 46},{  8}}, {{174},{  8}},
  350.21 +{{110},{  8}}, {{238},{  8}}, {{ 30},{  8}}, {{158},{  8}}, {{ 94},{  8}},
  350.22 +{{222},{  8}}, {{ 62},{  8}}, {{190},{  8}}, {{126},{  8}}, {{254},{  8}},
  350.23 +{{  1},{  8}}, {{129},{  8}}, {{ 65},{  8}}, {{193},{  8}}, {{ 33},{  8}},
  350.24 +{{161},{  8}}, {{ 97},{  8}}, {{225},{  8}}, {{ 17},{  8}}, {{145},{  8}},
  350.25 +{{ 81},{  8}}, {{209},{  8}}, {{ 49},{  8}}, {{177},{  8}}, {{113},{  8}},
  350.26 +{{241},{  8}}, {{  9},{  8}}, {{137},{  8}}, {{ 73},{  8}}, {{201},{  8}},
  350.27 +{{ 41},{  8}}, {{169},{  8}}, {{105},{  8}}, {{233},{  8}}, {{ 25},{  8}},
  350.28 +{{153},{  8}}, {{ 89},{  8}}, {{217},{  8}}, {{ 57},{  8}}, {{185},{  8}},
  350.29 +{{121},{  8}}, {{249},{  8}}, {{  5},{  8}}, {{133},{  8}}, {{ 69},{  8}},
  350.30 +{{197},{  8}}, {{ 37},{  8}}, {{165},{  8}}, {{101},{  8}}, {{229},{  8}},
  350.31 +{{ 21},{  8}}, {{149},{  8}}, {{ 85},{  8}}, {{213},{  8}}, {{ 53},{  8}},
  350.32 +{{181},{  8}}, {{117},{  8}}, {{245},{  8}}, {{ 13},{  8}}, {{141},{  8}},
  350.33 +{{ 77},{  8}}, {{205},{  8}}, {{ 45},{  8}}, {{173},{  8}}, {{109},{  8}},
  350.34 +{{237},{  8}}, {{ 29},{  8}}, {{157},{  8}}, {{ 93},{  8}}, {{221},{  8}},
  350.35 +{{ 61},{  8}}, {{189},{  8}}, {{125},{  8}}, {{253},{  8}}, {{ 19},{  9}},
  350.36 +{{275},{  9}}, {{147},{  9}}, {{403},{  9}}, {{ 83},{  9}}, {{339},{  9}},
  350.37 +{{211},{  9}}, {{467},{  9}}, {{ 51},{  9}}, {{307},{  9}}, {{179},{  9}},
  350.38 +{{435},{  9}}, {{115},{  9}}, {{371},{  9}}, {{243},{  9}}, {{499},{  9}},
  350.39 +{{ 11},{  9}}, {{267},{  9}}, {{139},{  9}}, {{395},{  9}}, {{ 75},{  9}},
  350.40 +{{331},{  9}}, {{203},{  9}}, {{459},{  9}}, {{ 43},{  9}}, {{299},{  9}},
  350.41 +{{171},{  9}}, {{427},{  9}}, {{107},{  9}}, {{363},{  9}}, {{235},{  9}},
  350.42 +{{491},{  9}}, {{ 27},{  9}}, {{283},{  9}}, {{155},{  9}}, {{411},{  9}},
  350.43 +{{ 91},{  9}}, {{347},{  9}}, {{219},{  9}}, {{475},{  9}}, {{ 59},{  9}},
  350.44 +{{315},{  9}}, {{187},{  9}}, {{443},{  9}}, {{123},{  9}}, {{379},{  9}},
  350.45 +{{251},{  9}}, {{507},{  9}}, {{  7},{  9}}, {{263},{  9}}, {{135},{  9}},
  350.46 +{{391},{  9}}, {{ 71},{  9}}, {{327},{  9}}, {{199},{  9}}, {{455},{  9}},
  350.47 +{{ 39},{  9}}, {{295},{  9}}, {{167},{  9}}, {{423},{  9}}, {{103},{  9}},
  350.48 +{{359},{  9}}, {{231},{  9}}, {{487},{  9}}, {{ 23},{  9}}, {{279},{  9}},
  350.49 +{{151},{  9}}, {{407},{  9}}, {{ 87},{  9}}, {{343},{  9}}, {{215},{  9}},
  350.50 +{{471},{  9}}, {{ 55},{  9}}, {{311},{  9}}, {{183},{  9}}, {{439},{  9}},
  350.51 +{{119},{  9}}, {{375},{  9}}, {{247},{  9}}, {{503},{  9}}, {{ 15},{  9}},
  350.52 +{{271},{  9}}, {{143},{  9}}, {{399},{  9}}, {{ 79},{  9}}, {{335},{  9}},
  350.53 +{{207},{  9}}, {{463},{  9}}, {{ 47},{  9}}, {{303},{  9}}, {{175},{  9}},
  350.54 +{{431},{  9}}, {{111},{  9}}, {{367},{  9}}, {{239},{  9}}, {{495},{  9}},
  350.55 +{{ 31},{  9}}, {{287},{  9}}, {{159},{  9}}, {{415},{  9}}, {{ 95},{  9}},
  350.56 +{{351},{  9}}, {{223},{  9}}, {{479},{  9}}, {{ 63},{  9}}, {{319},{  9}},
  350.57 +{{191},{  9}}, {{447},{  9}}, {{127},{  9}}, {{383},{  9}}, {{255},{  9}},
  350.58 +{{511},{  9}}, {{  0},{  7}}, {{ 64},{  7}}, {{ 32},{  7}}, {{ 96},{  7}},
  350.59 +{{ 16},{  7}}, {{ 80},{  7}}, {{ 48},{  7}}, {{112},{  7}}, {{  8},{  7}},
  350.60 +{{ 72},{  7}}, {{ 40},{  7}}, {{104},{  7}}, {{ 24},{  7}}, {{ 88},{  7}},
  350.61 +{{ 56},{  7}}, {{120},{  7}}, {{  4},{  7}}, {{ 68},{  7}}, {{ 36},{  7}},
  350.62 +{{100},{  7}}, {{ 20},{  7}}, {{ 84},{  7}}, {{ 52},{  7}}, {{116},{  7}},
  350.63 +{{  3},{  8}}, {{131},{  8}}, {{ 67},{  8}}, {{195},{  8}}, {{ 35},{  8}},
  350.64 +{{163},{  8}}, {{ 99},{  8}}, {{227},{  8}}
  350.65 +};
  350.66 +
  350.67 +local const ct_data static_dtree[D_CODES] = {
  350.68 +{{ 0},{ 5}}, {{16},{ 5}}, {{ 8},{ 5}}, {{24},{ 5}}, {{ 4},{ 5}},
  350.69 +{{20},{ 5}}, {{12},{ 5}}, {{28},{ 5}}, {{ 2},{ 5}}, {{18},{ 5}},
  350.70 +{{10},{ 5}}, {{26},{ 5}}, {{ 6},{ 5}}, {{22},{ 5}}, {{14},{ 5}},
  350.71 +{{30},{ 5}}, {{ 1},{ 5}}, {{17},{ 5}}, {{ 9},{ 5}}, {{25},{ 5}},
  350.72 +{{ 5},{ 5}}, {{21},{ 5}}, {{13},{ 5}}, {{29},{ 5}}, {{ 3},{ 5}},
  350.73 +{{19},{ 5}}, {{11},{ 5}}, {{27},{ 5}}, {{ 7},{ 5}}, {{23},{ 5}}
  350.74 +};
  350.75 +
  350.76 +const uch ZLIB_INTERNAL _dist_code[DIST_CODE_LEN] = {
  350.77 + 0,  1,  2,  3,  4,  4,  5,  5,  6,  6,  6,  6,  7,  7,  7,  7,  8,  8,  8,  8,
  350.78 + 8,  8,  8,  8,  9,  9,  9,  9,  9,  9,  9,  9, 10, 10, 10, 10, 10, 10, 10, 10,
  350.79 +10, 10, 10, 10, 10, 10, 10, 10, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11,
  350.80 +11, 11, 11, 11, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12,
  350.81 +12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 13, 13, 13, 13,
  350.82 +13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
  350.83 +13, 13, 13, 13, 13, 13, 13, 13, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
  350.84 +14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
  350.85 +14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
  350.86 +14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 15, 15, 15, 15, 15, 15, 15, 15,
  350.87 +15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
  350.88 +15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
  350.89 +15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,  0,  0, 16, 17,
  350.90 +18, 18, 19, 19, 20, 20, 20, 20, 21, 21, 21, 21, 22, 22, 22, 22, 22, 22, 22, 22,
  350.91 +23, 23, 23, 23, 23, 23, 23, 23, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
  350.92 +24, 24, 24, 24, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,
  350.93 +26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26,
  350.94 +26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 27, 27, 27, 27, 27, 27, 27, 27,
  350.95 +27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27,
  350.96 +27, 27, 27, 27, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28,
  350.97 +28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28,
  350.98 +28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28,
  350.99 +28, 28, 28, 28, 28, 28, 28, 28, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29,
 350.100 +29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29,
 350.101 +29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29,
 350.102 +29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29
 350.103 +};
 350.104 +
 350.105 +const uch ZLIB_INTERNAL _length_code[MAX_MATCH-MIN_MATCH+1]= {
 350.106 + 0,  1,  2,  3,  4,  5,  6,  7,  8,  8,  9,  9, 10, 10, 11, 11, 12, 12, 12, 12,
 350.107 +13, 13, 13, 13, 14, 14, 14, 14, 15, 15, 15, 15, 16, 16, 16, 16, 16, 16, 16, 16,
 350.108 +17, 17, 17, 17, 17, 17, 17, 17, 18, 18, 18, 18, 18, 18, 18, 18, 19, 19, 19, 19,
 350.109 +19, 19, 19, 19, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20,
 350.110 +21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 22, 22, 22, 22,
 350.111 +22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 23, 23, 23, 23, 23, 23, 23, 23,
 350.112 +23, 23, 23, 23, 23, 23, 23, 23, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
 350.113 +24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
 350.114 +25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,
 350.115 +25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 26, 26, 26, 26, 26, 26, 26, 26,
 350.116 +26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26,
 350.117 +26, 26, 26, 26, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27,
 350.118 +27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 28
 350.119 +};
 350.120 +
 350.121 +local const int base_length[LENGTH_CODES] = {
 350.122 +0, 1, 2, 3, 4, 5, 6, 7, 8, 10, 12, 14, 16, 20, 24, 28, 32, 40, 48, 56,
 350.123 +64, 80, 96, 112, 128, 160, 192, 224, 0
 350.124 +};
 350.125 +
 350.126 +local const int base_dist[D_CODES] = {
 350.127 +    0,     1,     2,     3,     4,     6,     8,    12,    16,    24,
 350.128 +   32,    48,    64,    96,   128,   192,   256,   384,   512,   768,
 350.129 + 1024,  1536,  2048,  3072,  4096,  6144,  8192, 12288, 16384, 24576
 350.130 +};
 350.131 +
   351.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
   351.2 +++ b/deps/glpk/src/zlib/uncompr.c	Sun Nov 06 20:59:10 2011 +0100
   351.3 @@ -0,0 +1,59 @@
   351.4 +/* uncompr.c -- decompress a memory buffer
   351.5 + * Copyright (C) 1995-2003, 2010 Jean-loup Gailly.
   351.6 + * For conditions of distribution and use, see copyright notice in zlib.h
   351.7 + */
   351.8 +
   351.9 +/* @(#) $Id$ */
  351.10 +
  351.11 +#define ZLIB_INTERNAL
  351.12 +#include "zlib.h"
  351.13 +
  351.14 +/* ===========================================================================
  351.15 +     Decompresses the source buffer into the destination buffer.  sourceLen is
  351.16 +   the byte length of the source buffer. Upon entry, destLen is the total
  351.17 +   size of the destination buffer, which must be large enough to hold the
  351.18 +   entire uncompressed data. (The size of the uncompressed data must have
  351.19 +   been saved previously by the compressor and transmitted to the decompressor
  351.20 +   by some mechanism outside the scope of this compression library.)
  351.21 +   Upon exit, destLen is the actual size of the compressed buffer.
  351.22 +
  351.23 +     uncompress returns Z_OK if success, Z_MEM_ERROR if there was not
  351.24 +   enough memory, Z_BUF_ERROR if there was not enough room in the output
  351.25 +   buffer, or Z_DATA_ERROR if the input data was corrupted.
  351.26 +*/
  351.27 +int ZEXPORT uncompress (dest, destLen, source, sourceLen)
  351.28 +    Bytef *dest;
  351.29 +    uLongf *destLen;
  351.30 +    const Bytef *source;
  351.31 +    uLong sourceLen;
  351.32 +{
  351.33 +    z_stream stream;
  351.34 +    int err;
  351.35 +
  351.36 +    stream.next_in = (Bytef*)source;
  351.37 +    stream.avail_in = (uInt)sourceLen;
  351.38 +    /* Check for source > 64K on 16-bit machine: */
  351.39 +    if ((uLong)stream.avail_in != sourceLen) return Z_BUF_ERROR;
  351.40 +
  351.41 +    stream.next_out = dest;
  351.42 +    stream.avail_out = (uInt)*destLen;
  351.43 +    if ((uLong)stream.avail_out != *destLen) return Z_BUF_ERROR;
  351.44 +
  351.45 +    stream.zalloc = (alloc_func)0;
  351.46 +    stream.zfree = (free_func)0;
  351.47 +
  351.48 +    err = inflateInit(&stream);
  351.49 +    if (err != Z_OK) return err;
  351.50 +
  351.51 +    err = inflate(&stream, Z_FINISH);
  351.52 +    if (err != Z_STREAM_END) {
  351.53 +        inflateEnd(&stream);
  351.54 +        if (err == Z_NEED_DICT || (err == Z_BUF_ERROR && stream.avail_in == 0))
  351.55 +            return Z_DATA_ERROR;
  351.56 +        return err;
  351.57 +    }
  351.58 +    *destLen = stream.total_out;
  351.59 +
  351.60 +    err = inflateEnd(&stream);
  351.61 +    return err;
  351.62 +}
   352.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
   352.2 +++ b/deps/glpk/src/zlib/zconf.h	Sun Nov 06 20:59:10 2011 +0100
   352.3 @@ -0,0 +1,168 @@
   352.4 +/* zconf.h (configuration of the zlib compression library) */
   352.5 +
   352.6 +/* Modified by Andrew Makhorin <mao@gnu.org>, April 2011 */
   352.7 +
   352.8 +/* Copyright (C) 1995-2010 Jean-loup Gailly
   352.9 + * For conditions of distribution and use, see copyright notice in
  352.10 + * zlib.h */
  352.11 +
  352.12 +/* WARNING: this file should *not* be used by applications. It is
  352.13 +   part of the implementation of the compression library and is
  352.14 +   subject to change. Applications should only use zlib.h. */
  352.15 +
  352.16 +#ifndef ZCONF_H
  352.17 +#define ZCONF_H
  352.18 +
  352.19 +/* (file adler32.c) */
  352.20 +#define adler32               _glp_zlib_adler32
  352.21 +#define adler32_combine       _glp_zlib_adler32_combine
  352.22 +#define adler32_combine64     _glp_zlib_adler32_combine64
  352.23 +
  352.24 +/* (file compress.c) */
  352.25 +#define compress2             _glp_zlib_compress2
  352.26 +#define compress              _glp_zlib_compress
  352.27 +#define compressBound         _glp_zlib_compressBound
  352.28 +
  352.29 +/* (file crc32.c) */
  352.30 +#define get_crc_table         _glp_zlib_get_crc_table
  352.31 +#define crc32                 _glp_zlib_crc32
  352.32 +#define crc32_combine         _glp_zlib_crc32_combine
  352.33 +#define crc32_combine64       _glp_zlib_crc32_combine64
  352.34 +
  352.35 +/* (file deflate.c) */
  352.36 +#define deflateInit_          _glp_zlib_deflateInit_
  352.37 +#define deflateInit2_         _glp_zlib_deflateInit2_
  352.38 +#define deflateSetDictionary  _glp_zlib_deflateSetDictionary
  352.39 +#define deflateReset          _glp_zlib_deflateReset
  352.40 +#define deflateSetHeader      _glp_zlib_deflateSetHeader
  352.41 +#define deflatePrime          _glp_zlib_deflatePrime
  352.42 +#define deflateParams         _glp_zlib_deflateParams
  352.43 +#define deflateTune           _glp_zlib_deflateTune
  352.44 +#define deflateBound          _glp_zlib_deflateBound
  352.45 +#define deflate               _glp_zlib_deflate
  352.46 +#define deflateEnd            _glp_zlib_deflateEnd
  352.47 +#define deflateCopy           _glp_zlib_deflateCopy
  352.48 +#define deflate_copyright     _glp_zlib_deflate_copyright
  352.49 +
  352.50 +/* (file gzclose.c) */
  352.51 +#define gzclose               _glp_zlib_gzclose
  352.52 +
  352.53 +/* (file gzlib.c) */
  352.54 +#define gzopen                _glp_zlib_gzopen
  352.55 +#define gzopen64              _glp_zlib_gzopen64
  352.56 +#define gzdopen               _glp_zlib_gzdopen
  352.57 +#define gzbuffer              _glp_zlib_gzbuffer
  352.58 +#define gzrewind              _glp_zlib_gzrewind
  352.59 +#define gzseek64              _glp_zlib_gzseek64
  352.60 +#define gzseek                _glp_zlib_gzseek
  352.61 +#define gztell64              _glp_zlib_gztell64
  352.62 +#define gztell                _glp_zlib_gztell
  352.63 +#define gzoffset64            _glp_zlib_gzoffset64
  352.64 +#define gzoffset              _glp_zlib_gzoffset
  352.65 +#define gzeof                 _glp_zlib_gzeof
  352.66 +#define gzerror               _glp_zlib_gzerror
  352.67 +#define gzclearerr            _glp_zlib_gzclearerr
  352.68 +#define gz_error              _glp_zlib_gz_error
  352.69 +
  352.70 +/* (file gzread.c) */
  352.71 +#define gzread                _glp_zlib_gzread
  352.72 +#define gzgetc                _glp_zlib_gzgetc
  352.73 +#define gzungetc              _glp_zlib_gzungetc
  352.74 +#define gzgets                _glp_zlib_gzgets
  352.75 +#define gzdirect              _glp_zlib_gzdirect
  352.76 +#define gzclose_r             _glp_zlib_gzclose_r
  352.77 +
  352.78 +/* (file gzwrite.c) */
  352.79 +#define gzwrite               _glp_zlib_gzwrite
  352.80 +#define gzputc                _glp_zlib_gzputc
  352.81 +#define gzputs                _glp_zlib_gzputs
  352.82 +#define gzprintf              _glp_zlib_gzprintf
  352.83 +#define gzflush               _glp_zlib_gzflush
  352.84 +#define gzsetparams           _glp_zlib_gzsetparams
  352.85 +#define gzclose_w             _glp_zlib_gzclose_w
  352.86 +
  352.87 +/* (file infback.c) */
  352.88 +#define inflateBackInit_      _glp_zlib_inflateBackInit_
  352.89 +#define inflateBack           _glp_zlib_inflateBack
  352.90 +#define inflateBackEnd        _glp_zlib_inflateBackEnd
  352.91 +
  352.92 +/* (file inffast.c) */
  352.93 +#define inflate_fast          _glp_zlib_inflate_fast
  352.94 +
  352.95 +/* (file inflate.c) */
  352.96 +#define inflateReset          _glp_zlib_inflateReset
  352.97 +#define inflateReset2         _glp_zlib_inflateReset2
  352.98 +#define inflateInit2_         _glp_zlib_inflateInit2_
  352.99 +#define inflateInit_          _glp_zlib_inflateInit_
 352.100 +#define inflatePrime          _glp_zlib_inflatePrime
 352.101 +#define inflate               _glp_zlib_inflate
 352.102 +#define inflateEnd            _glp_zlib_inflateEnd
 352.103 +#define inflateSetDictionary  _glp_zlib_inflateSetDictionary
 352.104 +#define inflateGetHeader      _glp_zlib_inflateGetHeader
 352.105 +#define inflateSync           _glp_zlib_inflateSync
 352.106 +#define inflateSyncPoint      _glp_zlib_inflateSyncPoint
 352.107 +#define inflateCopy           _glp_zlib_inflateCopy
 352.108 +#define inflateUndermine      _glp_zlib_inflateUndermine
 352.109 +#define inflateMark           _glp_zlib_inflateMark
 352.110 +
 352.111 +/* (file inftrees.c) */
 352.112 +#define inflate_table         _glp_zlib_inflate_table
 352.113 +#define inflate_copyright     _glp_zlib_inflate_copyright
 352.114 +
 352.115 +/* (file trees.c) */
 352.116 +#define _tr_init              _glp_zlib_tr_init
 352.117 +#define _tr_stored_block      _glp_zlib_tr_stored_block
 352.118 +#define _tr_align             _glp_zlib_tr_align
 352.119 +#define _tr_flush_block       _glp_zlib_tr_flush_block
 352.120 +#define _tr_tally             _glp_zlib_tr_tally
 352.121 +#define _dist_code            _glp_zlib_dist_code
 352.122 +#define _length_code          _glp_zlib_length_code
 352.123 +
 352.124 +/* (file uncompr.c) */
 352.125 +#define uncompress            _glp_zlib_uncompress
 352.126 +
 352.127 +/* (file zutil.c) */
 352.128 +#define zlibVersion           _glp_zlib_zlibVersion
 352.129 +#define zlibCompileFlags      _glp_zlib_zlibCompileFlags
 352.130 +#define zError                _glp_zlib_zError
 352.131 +#define zcalloc               _glp_zlib_zcalloc
 352.132 +#define zcfree                _glp_zlib_zcfree
 352.133 +#define z_errmsg              _glp_zlib_z_errmsg
 352.134 +
 352.135 +#define STDC 1
 352.136 +
 352.137 +#define MAX_MEM_LEVEL 9
 352.138 +
 352.139 +#define MAX_WBITS 15
 352.140 +
 352.141 +#define OF(args) args
 352.142 +
 352.143 +#define ZEXTERN extern
 352.144 +#define ZEXPORT
 352.145 +#define ZEXPORTVA
 352.146 +
 352.147 +#define FAR
 352.148 +
 352.149 +typedef unsigned char Byte;
 352.150 +typedef unsigned int uInt;
 352.151 +typedef unsigned long uLong;
 352.152 +
 352.153 +typedef Byte Bytef;
 352.154 +typedef char charf;
 352.155 +typedef int intf;
 352.156 +typedef uInt uIntf;
 352.157 +typedef uLong uLongf;
 352.158 +
 352.159 +typedef void const *voidpc;
 352.160 +typedef void *voidpf;
 352.161 +typedef void *voidp;
 352.162 +
 352.163 +#define z_off_t long
 352.164 +
 352.165 +#define z_off64_t z_off_t
 352.166 +
 352.167 +#define NO_vsnprintf 1
 352.168 +
 352.169 +#endif
 352.170 +
 352.171 +/* eof */
   353.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
   353.2 +++ b/deps/glpk/src/zlib/zio.c	Sun Nov 06 20:59:10 2011 +0100
   353.3 @@ -0,0 +1,92 @@
   353.4 +/* zio.c (simulation of non-standard low-level i/o functions) */
   353.5 +
   353.6 +/* Written by Andrew Makhorin <mao@gnu.org>, April 2011
   353.7 + * For conditions of distribution and use, see copyright notice in
   353.8 + * zlib.h */
   353.9 +
  353.10 +/* (reserved for copyright notice) */
  353.11 +
  353.12 +#include <assert.h>
  353.13 +#include <stdio.h>
  353.14 +#include "zio.h"
  353.15 +
  353.16 +static FILE *file[FOPEN_MAX];
  353.17 +static int initialized = 0;
  353.18 +
  353.19 +static void initialize(void)
  353.20 +{     int fd;
  353.21 +      assert(!initialized);
  353.22 +      file[0] = stdin;
  353.23 +      file[1] = stdout;
  353.24 +      file[2] = stderr;
  353.25 +      for (fd = 3; fd < FOPEN_MAX; fd++)
  353.26 +         file[fd] = NULL;
  353.27 +      initialized = 1;
  353.28 +      return;
  353.29 +}
  353.30 +
  353.31 +int open(const char *path, int oflag, ...)
  353.32 +{     FILE *fp;
  353.33 +      int fd;
  353.34 +      if (!initialized) initialize();
  353.35 +      /* see file gzlib.c, function gz_open */
  353.36 +      if (oflag == O_RDONLY)
  353.37 +         fp = fopen(path, "rb");
  353.38 +      else if (oflag == (O_WRONLY | O_CREAT | O_TRUNC))
  353.39 +         fp = fopen(path, "wb");
  353.40 +      else if (oflag == (O_WRONLY | O_CREAT | O_APPEND))
  353.41 +         fp = fopen(path, "ab");
  353.42 +      else
  353.43 +         assert(oflag != oflag);
  353.44 +      if (fp == NULL)
  353.45 +         return -1;
  353.46 +      for (fd = 0; fd < FOPEN_MAX; fd++)
  353.47 +         if (file[fd] == NULL) break;
  353.48 +      assert(fd < FOPEN_MAX);
  353.49 +      file[fd] = fp;
  353.50 +      return fd;
  353.51 +}
  353.52 +
  353.53 +long read(int fd, void *buf, unsigned long nbyte)
  353.54 +{     unsigned long count;
  353.55 +      if (!initialized) initialize();
  353.56 +      assert(0 <= fd && fd < FOPEN_MAX);
  353.57 +      assert(file[fd] != NULL);
  353.58 +      count = fread(buf, 1, nbyte, file[fd]);
  353.59 +      if (ferror(file[fd]))
  353.60 +         return -1;
  353.61 +      return count;
  353.62 +}
  353.63 +
  353.64 +long write(int fd, const void *buf, unsigned long nbyte)
  353.65 +{     unsigned long count;
  353.66 +      if (!initialized) initialize();
  353.67 +      assert(0 <= fd && fd < FOPEN_MAX);
  353.68 +      assert(file[fd] != NULL);
  353.69 +      count = fwrite(buf, 1, nbyte, file[fd]);
  353.70 +      if (count != nbyte)
  353.71 +         return -1;
  353.72 +      if (fflush(file[fd]) != 0)
  353.73 +         return -1;
  353.74 +      return count;
  353.75 +}
  353.76 +
  353.77 +long lseek(int fd, long offset, int whence)
  353.78 +{     if (!initialized) initialize();
  353.79 +      assert(0 <= fd && fd < FOPEN_MAX);
  353.80 +      assert(file[fd] != NULL);
  353.81 +      if (fseek(file[fd], offset, whence) != 0)
  353.82 +         return -1;
  353.83 +      return ftell(file[fd]);
  353.84 +}
  353.85 +
  353.86 +int close(int fd)
  353.87 +{     if (!initialized) initialize();
  353.88 +      assert(0 <= fd && fd < FOPEN_MAX);
  353.89 +      assert(file[fd] != NULL);
  353.90 +      fclose(file[fd]);
  353.91 +      file[fd] = NULL;
  353.92 +      return 0;
  353.93 +}
  353.94 +
  353.95 +/* eof */
   354.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
   354.2 +++ b/deps/glpk/src/zlib/zio.h	Sun Nov 06 20:59:10 2011 +0100
   354.3 @@ -0,0 +1,37 @@
   354.4 +/* zio.h (simulation of non-standard low-level i/o functions) */
   354.5 +
   354.6 +/* Written by Andrew Makhorin <mao@gnu.org>, April 2011
   354.7 + * For conditions of distribution and use, see copyright notice in
   354.8 + * zlib.h */
   354.9 +
  354.10 +/* WARNING: this file should *not* be used by applications. It is
  354.11 +   part of the implementation of the compression library and is
  354.12 +   subject to change. Applications should only use zlib.h. */
  354.13 +
  354.14 +#ifndef ZIO_H
  354.15 +#define ZIO_H
  354.16 +
  354.17 +#define O_RDONLY 0x00
  354.18 +#define O_WRONLY 0x01
  354.19 +#define O_CREAT  0x10
  354.20 +#define O_TRUNC  0x20
  354.21 +#define O_APPEND 0x30
  354.22 +
  354.23 +#define open _glp_zlib_open
  354.24 +int open(const char *path, int oflag, ...);
  354.25 +
  354.26 +#define read _glp_zlib_read
  354.27 +long read(int fd, void *buf, unsigned long nbyte);
  354.28 +
  354.29 +#define write _glp_zlib_write
  354.30 +long write(int fd, const void *buf, unsigned long nbyte);
  354.31 +
  354.32 +#define lseek _glp_zlib_lseek
  354.33 +long lseek(int fd, long offset, int whence);
  354.34 +
  354.35 +#define close _glp_zlib_close
  354.36 +int close(int fd);
  354.37 +
  354.38 +#endif
  354.39 +
  354.40 +/* eof */
   355.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
   355.2 +++ b/deps/glpk/src/zlib/zlib.h	Sun Nov 06 20:59:10 2011 +0100
   355.3 @@ -0,0 +1,1613 @@
   355.4 +/* zlib.h -- interface of the 'zlib' general purpose compression library
   355.5 +  version 1.2.5, April 19th, 2010
   355.6 +
   355.7 +  Copyright (C) 1995-2010 Jean-loup Gailly and Mark Adler
   355.8 +
   355.9 +  This software is provided 'as-is', without any express or implied
  355.10 +  warranty.  In no event will the authors be held liable for any damages
  355.11 +  arising from the use of this software.
  355.12 +
  355.13 +  Permission is granted to anyone to use this software for any purpose,
  355.14 +  including commercial applications, and to alter it and redistribute it
  355.15 +  freely, subject to the following restrictions:
  355.16 +
  355.17 +  1. The origin of this software must not be misrepresented; you must not
  355.18 +     claim that you wrote the original software. If you use this software
  355.19 +     in a product, an acknowledgment in the product documentation would be
  355.20 +     appreciated but is not required.
  355.21 +  2. Altered source versions must be plainly marked as such, and must not be
  355.22 +     misrepresented as being the original software.
  355.23 +  3. This notice may not be removed or altered from any source distribution.
  355.24 +
  355.25 +  Jean-loup Gailly        Mark Adler
  355.26 +  jloup@gzip.org          madler@alumni.caltech.edu
  355.27 +
  355.28 +
  355.29 +  The data format used by the zlib library is described by RFCs (Request for
  355.30 +  Comments) 1950 to 1952 in the files http://www.ietf.org/rfc/rfc1950.txt
  355.31 +  (zlib format), rfc1951.txt (deflate format) and rfc1952.txt (gzip format).
  355.32 +*/
  355.33 +
  355.34 +#ifndef ZLIB_H
  355.35 +#define ZLIB_H
  355.36 +
  355.37 +#include "zconf.h"
  355.38 +
  355.39 +#ifdef __cplusplus
  355.40 +extern "C" {
  355.41 +#endif
  355.42 +
  355.43 +#define ZLIB_VERSION "1.2.5"
  355.44 +#define ZLIB_VERNUM 0x1250
  355.45 +#define ZLIB_VER_MAJOR 1
  355.46 +#define ZLIB_VER_MINOR 2
  355.47 +#define ZLIB_VER_REVISION 5
  355.48 +#define ZLIB_VER_SUBREVISION 0
  355.49 +
  355.50 +/*
  355.51 +    The 'zlib' compression library provides in-memory compression and
  355.52 +  decompression functions, including integrity checks of the uncompressed data.
  355.53 +  This version of the library supports only one compression method (deflation)
  355.54 +  but other algorithms will be added later and will have the same stream
  355.55 +  interface.
  355.56 +
  355.57 +    Compression can be done in a single step if the buffers are large enough,
  355.58 +  or can be done by repeated calls of the compression function.  In the latter
  355.59 +  case, the application must provide more input and/or consume the output
  355.60 +  (providing more output space) before each call.
  355.61 +
  355.62 +    The compressed data format used by default by the in-memory functions is
  355.63 +  the zlib format, which is a zlib wrapper documented in RFC 1950, wrapped
  355.64 +  around a deflate stream, which is itself documented in RFC 1951.
  355.65 +
  355.66 +    The library also supports reading and writing files in gzip (.gz) format
  355.67 +  with an interface similar to that of stdio using the functions that start
  355.68 +  with "gz".  The gzip format is different from the zlib format.  gzip is a
  355.69 +  gzip wrapper, documented in RFC 1952, wrapped around a deflate stream.
  355.70 +
  355.71 +    This library can optionally read and write gzip streams in memory as well.
  355.72 +
  355.73 +    The zlib format was designed to be compact and fast for use in memory
  355.74 +  and on communications channels.  The gzip format was designed for single-
  355.75 +  file compression on file systems, has a larger header than zlib to maintain
  355.76 +  directory information, and uses a different, slower check method than zlib.
  355.77 +
  355.78 +    The library does not install any signal handler.  The decoder checks
  355.79 +  the consistency of the compressed data, so the library should never crash
  355.80 +  even in case of corrupted input.
  355.81 +*/
  355.82 +
  355.83 +typedef voidpf (*alloc_func) OF((voidpf opaque, uInt items, uInt size));
  355.84 +typedef void   (*free_func)  OF((voidpf opaque, voidpf address));
  355.85 +
  355.86 +struct internal_state;
  355.87 +
  355.88 +typedef struct z_stream_s {
  355.89 +    Bytef    *next_in;  /* next input byte */
  355.90 +    uInt     avail_in;  /* number of bytes available at next_in */
  355.91 +    uLong    total_in;  /* total nb of input bytes read so far */
  355.92 +
  355.93 +    Bytef    *next_out; /* next output byte should be put there */
  355.94 +    uInt     avail_out; /* remaining free space at next_out */
  355.95 +    uLong    total_out; /* total nb of bytes output so far */
  355.96 +
  355.97 +    char     *msg;      /* last error message, NULL if no error */
  355.98 +    struct internal_state FAR *state; /* not visible by applications */
  355.99 +
 355.100 +    alloc_func zalloc;  /* used to allocate the internal state */
 355.101 +    free_func  zfree;   /* used to free the internal state */
 355.102 +    voidpf     opaque;  /* private data object passed to zalloc and zfree */
 355.103 +
 355.104 +    int     data_type;  /* best guess about the data type: binary or text */
 355.105 +    uLong   adler;      /* adler32 value of the uncompressed data */
 355.106 +    uLong   reserved;   /* reserved for future use */
 355.107 +} z_stream;
 355.108 +
 355.109 +typedef z_stream FAR *z_streamp;
 355.110 +
 355.111 +/*
 355.112 +     gzip header information passed to and from zlib routines.  See RFC 1952
 355.113 +  for more details on the meanings of these fields.
 355.114 +*/
 355.115 +typedef struct gz_header_s {
 355.116 +    int     text;       /* true if compressed data believed to be text */
 355.117 +    uLong   time;       /* modification time */
 355.118 +    int     xflags;     /* extra flags (not used when writing a gzip file) */
 355.119 +    int     os;         /* operating system */
 355.120 +    Bytef   *extra;     /* pointer to extra field or Z_NULL if none */
 355.121 +    uInt    extra_len;  /* extra field length (valid if extra != Z_NULL) */
 355.122 +    uInt    extra_max;  /* space at extra (only when reading header) */
 355.123 +    Bytef   *name;      /* pointer to zero-terminated file name or Z_NULL */
 355.124 +    uInt    name_max;   /* space at name (only when reading header) */
 355.125 +    Bytef   *comment;   /* pointer to zero-terminated comment or Z_NULL */
 355.126 +    uInt    comm_max;   /* space at comment (only when reading header) */
 355.127 +    int     hcrc;       /* true if there was or will be a header crc */
 355.128 +    int     done;       /* true when done reading gzip header (not used
 355.129 +                           when writing a gzip file) */
 355.130 +} gz_header;
 355.131 +
 355.132 +typedef gz_header FAR *gz_headerp;
 355.133 +
 355.134 +/*
 355.135 +     The application must update next_in and avail_in when avail_in has dropped
 355.136 +   to zero.  It must update next_out and avail_out when avail_out has dropped
 355.137 +   to zero.  The application must initialize zalloc, zfree and opaque before
 355.138 +   calling the init function.  All other fields are set by the compression
 355.139 +   library and must not be updated by the application.
 355.140 +
 355.141 +     The opaque value provided by the application will be passed as the first
 355.142 +   parameter for calls of zalloc and zfree.  This can be useful for custom
 355.143 +   memory management.  The compression library attaches no meaning to the
 355.144 +   opaque value.
 355.145 +
 355.146 +     zalloc must return Z_NULL if there is not enough memory for the object.
 355.147 +   If zlib is used in a multi-threaded application, zalloc and zfree must be
 355.148 +   thread safe.
 355.149 +
 355.150 +     On 16-bit systems, the functions zalloc and zfree must be able to allocate
 355.151 +   exactly 65536 bytes, but will not be required to allocate more than this if
 355.152 +   the symbol MAXSEG_64K is defined (see zconf.h).  WARNING: On MSDOS, pointers
 355.153 +   returned by zalloc for objects of exactly 65536 bytes *must* have their
 355.154 +   offset normalized to zero.  The default allocation function provided by this
 355.155 +   library ensures this (see zutil.c).  To reduce memory requirements and avoid
 355.156 +   any allocation of 64K objects, at the expense of compression ratio, compile
 355.157 +   the library with -DMAX_WBITS=14 (see zconf.h).
 355.158 +
 355.159 +     The fields total_in and total_out can be used for statistics or progress
 355.160 +   reports.  After compression, total_in holds the total size of the
 355.161 +   uncompressed data and may be saved for use in the decompressor (particularly
 355.162 +   if the decompressor wants to decompress everything in a single step).
 355.163 +*/
 355.164 +
 355.165 +                        /* constants */
 355.166 +
 355.167 +#define Z_NO_FLUSH      0
 355.168 +#define Z_PARTIAL_FLUSH 1
 355.169 +#define Z_SYNC_FLUSH    2
 355.170 +#define Z_FULL_FLUSH    3
 355.171 +#define Z_FINISH        4
 355.172 +#define Z_BLOCK         5
 355.173 +#define Z_TREES         6
 355.174 +/* Allowed flush values; see deflate() and inflate() below for details */
 355.175 +
 355.176 +#define Z_OK            0
 355.177 +#define Z_STREAM_END    1
 355.178 +#define Z_NEED_DICT     2
 355.179 +#define Z_ERRNO        (-1)
 355.180 +#define Z_STREAM_ERROR (-2)
 355.181 +#define Z_DATA_ERROR   (-3)
 355.182 +#define Z_MEM_ERROR    (-4)
 355.183 +#define Z_BUF_ERROR    (-5)
 355.184 +#define Z_VERSION_ERROR (-6)
 355.185 +/* Return codes for the compression/decompression functions. Negative values
 355.186 + * are errors, positive values are used for special but normal events.
 355.187 + */
 355.188 +
 355.189 +#define Z_NO_COMPRESSION         0
 355.190 +#define Z_BEST_SPEED             1
 355.191 +#define Z_BEST_COMPRESSION       9
 355.192 +#define Z_DEFAULT_COMPRESSION  (-1)
 355.193 +/* compression levels */
 355.194 +
 355.195 +#define Z_FILTERED            1
 355.196 +#define Z_HUFFMAN_ONLY        2
 355.197 +#define Z_RLE                 3
 355.198 +#define Z_FIXED               4
 355.199 +#define Z_DEFAULT_STRATEGY    0
 355.200 +/* compression strategy; see deflateInit2() below for details */
 355.201 +
 355.202 +#define Z_BINARY   0
 355.203 +#define Z_TEXT     1
 355.204 +#define Z_ASCII    Z_TEXT   /* for compatibility with 1.2.2 and earlier */
 355.205 +#define Z_UNKNOWN  2
 355.206 +/* Possible values of the data_type field (though see inflate()) */
 355.207 +
 355.208 +#define Z_DEFLATED   8
 355.209 +/* The deflate compression method (the only one supported in this version) */
 355.210 +
 355.211 +#define Z_NULL  0  /* for initializing zalloc, zfree, opaque */
 355.212 +
 355.213 +#define zlib_version zlibVersion()
 355.214 +/* for compatibility with versions < 1.0.2 */
 355.215 +
 355.216 +
 355.217 +                        /* basic functions */
 355.218 +
 355.219 +ZEXTERN const char * ZEXPORT zlibVersion OF((void));
 355.220 +/* The application can compare zlibVersion and ZLIB_VERSION for consistency.
 355.221 +   If the first character differs, the library code actually used is not
 355.222 +   compatible with the zlib.h header file used by the application.  This check
 355.223 +   is automatically made by deflateInit and inflateInit.
 355.224 + */
 355.225 +
 355.226 +/*
 355.227 +ZEXTERN int ZEXPORT deflateInit OF((z_streamp strm, int level));
 355.228 +
 355.229 +     Initializes the internal stream state for compression.  The fields
 355.230 +   zalloc, zfree and opaque must be initialized before by the caller.  If
 355.231 +   zalloc and zfree are set to Z_NULL, deflateInit updates them to use default
 355.232 +   allocation functions.
 355.233 +
 355.234 +     The compression level must be Z_DEFAULT_COMPRESSION, or between 0 and 9:
 355.235 +   1 gives best speed, 9 gives best compression, 0 gives no compression at all
 355.236 +   (the input data is simply copied a block at a time).  Z_DEFAULT_COMPRESSION
 355.237 +   requests a default compromise between speed and compression (currently
 355.238 +   equivalent to level 6).
 355.239 +
 355.240 +     deflateInit returns Z_OK if success, Z_MEM_ERROR if there was not enough
 355.241 +   memory, Z_STREAM_ERROR if level is not a valid compression level, or
 355.242 +   Z_VERSION_ERROR if the zlib library version (zlib_version) is incompatible
 355.243 +   with the version assumed by the caller (ZLIB_VERSION).  msg is set to null
 355.244 +   if there is no error message.  deflateInit does not perform any compression:
 355.245 +   this will be done by deflate().
 355.246 +*/
 355.247 +
 355.248 +
 355.249 +ZEXTERN int ZEXPORT deflate OF((z_streamp strm, int flush));
 355.250 +/*
 355.251 +    deflate compresses as much data as possible, and stops when the input
 355.252 +  buffer becomes empty or the output buffer becomes full.  It may introduce
 355.253 +  some output latency (reading input without producing any output) except when
 355.254 +  forced to flush.
 355.255 +
 355.256 +    The detailed semantics are as follows.  deflate performs one or both of the
 355.257 +  following actions:
 355.258 +
 355.259 +  - Compress more input starting at next_in and update next_in and avail_in
 355.260 +    accordingly.  If not all input can be processed (because there is not
 355.261 +    enough room in the output buffer), next_in and avail_in are updated and
 355.262 +    processing will resume at this point for the next call of deflate().
 355.263 +
 355.264 +  - Provide more output starting at next_out and update next_out and avail_out
 355.265 +    accordingly.  This action is forced if the parameter flush is non zero.
 355.266 +    Forcing flush frequently degrades the compression ratio, so this parameter
 355.267 +    should be set only when necessary (in interactive applications).  Some
 355.268 +    output may be provided even if flush is not set.
 355.269 +
 355.270 +    Before the call of deflate(), the application should ensure that at least
 355.271 +  one of the actions is possible, by providing more input and/or consuming more
 355.272 +  output, and updating avail_in or avail_out accordingly; avail_out should
 355.273 +  never be zero before the call.  The application can consume the compressed
 355.274 +  output when it wants, for example when the output buffer is full (avail_out
 355.275 +  == 0), or after each call of deflate().  If deflate returns Z_OK and with
 355.276 +  zero avail_out, it must be called again after making room in the output
 355.277 +  buffer because there might be more output pending.
 355.278 +
 355.279 +    Normally the parameter flush is set to Z_NO_FLUSH, which allows deflate to
 355.280 +  decide how much data to accumulate before producing output, in order to
 355.281 +  maximize compression.
 355.282 +
 355.283 +    If the parameter flush is set to Z_SYNC_FLUSH, all pending output is
 355.284 +  flushed to the output buffer and the output is aligned on a byte boundary, so
 355.285 +  that the decompressor can get all input data available so far.  (In
 355.286 +  particular avail_in is zero after the call if enough output space has been
 355.287 +  provided before the call.) Flushing may degrade compression for some
 355.288 +  compression algorithms and so it should be used only when necessary.  This
 355.289 +  completes the current deflate block and follows it with an empty stored block
 355.290 +  that is three bits plus filler bits to the next byte, followed by four bytes
 355.291 +  (00 00 ff ff).
 355.292 +
 355.293 +    If flush is set to Z_PARTIAL_FLUSH, all pending output is flushed to the
 355.294 +  output buffer, but the output is not aligned to a byte boundary.  All of the
 355.295 +  input data so far will be available to the decompressor, as for Z_SYNC_FLUSH.
 355.296 +  This completes the current deflate block and follows it with an empty fixed
 355.297 +  codes block that is 10 bits long.  This assures that enough bytes are output
 355.298 +  in order for the decompressor to finish the block before the empty fixed code
 355.299 +  block.
 355.300 +
 355.301 +    If flush is set to Z_BLOCK, a deflate block is completed and emitted, as
 355.302 +  for Z_SYNC_FLUSH, but the output is not aligned on a byte boundary, and up to
 355.303 +  seven bits of the current block are held to be written as the next byte after
 355.304 +  the next deflate block is completed.  In this case, the decompressor may not
 355.305 +  be provided enough bits at this point in order to complete decompression of
 355.306 +  the data provided so far to the compressor.  It may need to wait for the next
 355.307 +  block to be emitted.  This is for advanced applications that need to control
 355.308 +  the emission of deflate blocks.
 355.309 +
 355.310 +    If flush is set to Z_FULL_FLUSH, all output is flushed as with
 355.311 +  Z_SYNC_FLUSH, and the compression state is reset so that decompression can
 355.312 +  restart from this point if previous compressed data has been damaged or if
 355.313 +  random access is desired.  Using Z_FULL_FLUSH too often can seriously degrade
 355.314 +  compression.
 355.315 +
 355.316 +    If deflate returns with avail_out == 0, this function must be called again
 355.317 +  with the same value of the flush parameter and more output space (updated
 355.318 +  avail_out), until the flush is complete (deflate returns with non-zero
 355.319 +  avail_out).  In the case of a Z_FULL_FLUSH or Z_SYNC_FLUSH, make sure that
 355.320 +  avail_out is greater than six to avoid repeated flush markers due to
 355.321 +  avail_out == 0 on return.
 355.322 +
 355.323 +    If the parameter flush is set to Z_FINISH, pending input is processed,
 355.324 +  pending output is flushed and deflate returns with Z_STREAM_END if there was
 355.325 +  enough output space; if deflate returns with Z_OK, this function must be
 355.326 +  called again with Z_FINISH and more output space (updated avail_out) but no
 355.327 +  more input data, until it returns with Z_STREAM_END or an error.  After
 355.328 +  deflate has returned Z_STREAM_END, the only possible operations on the stream
 355.329 +  are deflateReset or deflateEnd.
 355.330 +
 355.331 +    Z_FINISH can be used immediately after deflateInit if all the compression
 355.332 +  is to be done in a single step.  In this case, avail_out must be at least the
 355.333 +  value returned by deflateBound (see below).  If deflate does not return
 355.334 +  Z_STREAM_END, then it must be called again as described above.
 355.335 +
 355.336 +    deflate() sets strm->adler to the adler32 checksum of all input read
 355.337 +  so far (that is, total_in bytes).
 355.338 +
 355.339 +    deflate() may update strm->data_type if it can make a good guess about
 355.340 +  the input data type (Z_BINARY or Z_TEXT).  In doubt, the data is considered
 355.341 +  binary.  This field is only for information purposes and does not affect the
 355.342 +  compression algorithm in any manner.
 355.343 +
 355.344 +    deflate() returns Z_OK if some progress has been made (more input
 355.345 +  processed or more output produced), Z_STREAM_END if all input has been
 355.346 +  consumed and all output has been produced (only when flush is set to
 355.347 +  Z_FINISH), Z_STREAM_ERROR if the stream state was inconsistent (for example
 355.348 +  if next_in or next_out was Z_NULL), Z_BUF_ERROR if no progress is possible
 355.349 +  (for example avail_in or avail_out was zero).  Note that Z_BUF_ERROR is not
 355.350 +  fatal, and deflate() can be called again with more input and more output
 355.351 +  space to continue compressing.
 355.352 +*/
 355.353 +
 355.354 +
 355.355 +ZEXTERN int ZEXPORT deflateEnd OF((z_streamp strm));
 355.356 +/*
 355.357 +     All dynamically allocated data structures for this stream are freed.
 355.358 +   This function discards any unprocessed input and does not flush any pending
 355.359 +   output.
 355.360 +
 355.361 +     deflateEnd returns Z_OK if success, Z_STREAM_ERROR if the
 355.362 +   stream state was inconsistent, Z_DATA_ERROR if the stream was freed
 355.363 +   prematurely (some input or output was discarded).  In the error case, msg
 355.364 +   may be set but then points to a static string (which must not be
 355.365 +   deallocated).
 355.366 +*/
 355.367 +
 355.368 +
 355.369 +/*
 355.370 +ZEXTERN int ZEXPORT inflateInit OF((z_streamp strm));
 355.371 +
 355.372 +     Initializes the internal stream state for decompression.  The fields
 355.373 +   next_in, avail_in, zalloc, zfree and opaque must be initialized before by
 355.374 +   the caller.  If next_in is not Z_NULL and avail_in is large enough (the
 355.375 +   exact value depends on the compression method), inflateInit determines the
 355.376 +   compression method from the zlib header and allocates all data structures
 355.377 +   accordingly; otherwise the allocation will be deferred to the first call of
 355.378 +   inflate.  If zalloc and zfree are set to Z_NULL, inflateInit updates them to
 355.379 +   use default allocation functions.
 355.380 +
 355.381 +     inflateInit returns Z_OK if success, Z_MEM_ERROR if there was not enough
 355.382 +   memory, Z_VERSION_ERROR if the zlib library version is incompatible with the
 355.383 +   version assumed by the caller, or Z_STREAM_ERROR if the parameters are
 355.384 +   invalid, such as a null pointer to the structure.  msg is set to null if
 355.385 +   there is no error message.  inflateInit does not perform any decompression
 355.386 +   apart from possibly reading the zlib header if present: actual decompression
 355.387 +   will be done by inflate().  (So next_in and avail_in may be modified, but
 355.388 +   next_out and avail_out are unused and unchanged.) The current implementation
 355.389 +   of inflateInit() does not process any header information -- that is deferred
 355.390 +   until inflate() is called.
 355.391 +*/
 355.392 +
 355.393 +
 355.394 +ZEXTERN int ZEXPORT inflate OF((z_streamp strm, int flush));
 355.395 +/*
 355.396 +    inflate decompresses as much data as possible, and stops when the input
 355.397 +  buffer becomes empty or the output buffer becomes full.  It may introduce
 355.398 +  some output latency (reading input without producing any output) except when
 355.399 +  forced to flush.
 355.400 +
 355.401 +  The detailed semantics are as follows.  inflate performs one or both of the
 355.402 +  following actions:
 355.403 +
 355.404 +  - Decompress more input starting at next_in and update next_in and avail_in
 355.405 +    accordingly.  If not all input can be processed (because there is not
 355.406 +    enough room in the output buffer), next_in is updated and processing will
 355.407 +    resume at this point for the next call of inflate().
 355.408 +
 355.409 +  - Provide more output starting at next_out and update next_out and avail_out
 355.410 +    accordingly.  inflate() provides as much output as possible, until there is
 355.411 +    no more input data or no more space in the output buffer (see below about
 355.412 +    the flush parameter).
 355.413 +
 355.414 +    Before the call of inflate(), the application should ensure that at least
 355.415 +  one of the actions is possible, by providing more input and/or consuming more
 355.416 +  output, and updating the next_* and avail_* values accordingly.  The
 355.417 +  application can consume the uncompressed output when it wants, for example
 355.418 +  when the output buffer is full (avail_out == 0), or after each call of
 355.419 +  inflate().  If inflate returns Z_OK and with zero avail_out, it must be
 355.420 +  called again after making room in the output buffer because there might be
 355.421 +  more output pending.
 355.422 +
 355.423 +    The flush parameter of inflate() can be Z_NO_FLUSH, Z_SYNC_FLUSH, Z_FINISH,
 355.424 +  Z_BLOCK, or Z_TREES.  Z_SYNC_FLUSH requests that inflate() flush as much
 355.425 +  output as possible to the output buffer.  Z_BLOCK requests that inflate()
 355.426 +  stop if and when it gets to the next deflate block boundary.  When decoding
 355.427 +  the zlib or gzip format, this will cause inflate() to return immediately
 355.428 +  after the header and before the first block.  When doing a raw inflate,
 355.429 +  inflate() will go ahead and process the first block, and will return when it
 355.430 +  gets to the end of that block, or when it runs out of data.
 355.431 +
 355.432 +    The Z_BLOCK option assists in appending to or combining deflate streams.
 355.433 +  Also to assist in this, on return inflate() will set strm->data_type to the
 355.434 +  number of unused bits in the last byte taken from strm->next_in, plus 64 if
 355.435 +  inflate() is currently decoding the last block in the deflate stream, plus
 355.436 +  128 if inflate() returned immediately after decoding an end-of-block code or
 355.437 +  decoding the complete header up to just before the first byte of the deflate
 355.438 +  stream.  The end-of-block will not be indicated until all of the uncompressed
 355.439 +  data from that block has been written to strm->next_out.  The number of
 355.440 +  unused bits may in general be greater than seven, except when bit 7 of
 355.441 +  data_type is set, in which case the number of unused bits will be less than
 355.442 +  eight.  data_type is set as noted here every time inflate() returns for all
 355.443 +  flush options, and so can be used to determine the amount of currently
 355.444 +  consumed input in bits.
 355.445 +
 355.446 +    The Z_TREES option behaves as Z_BLOCK does, but it also returns when the
 355.447 +  end of each deflate block header is reached, before any actual data in that
 355.448 +  block is decoded.  This allows the caller to determine the length of the
 355.449 +  deflate block header for later use in random access within a deflate block.
 355.450 +  256 is added to the value of strm->data_type when inflate() returns
 355.451 +  immediately after reaching the end of the deflate block header.
 355.452 +
 355.453 +    inflate() should normally be called until it returns Z_STREAM_END or an
 355.454 +  error.  However if all decompression is to be performed in a single step (a
 355.455 +  single call of inflate), the parameter flush should be set to Z_FINISH.  In
 355.456 +  this case all pending input is processed and all pending output is flushed;
 355.457 +  avail_out must be large enough to hold all the uncompressed data.  (The size
 355.458 +  of the uncompressed data may have been saved by the compressor for this
 355.459 +  purpose.) The next operation on this stream must be inflateEnd to deallocate
 355.460 +  the decompression state.  The use of Z_FINISH is never required, but can be
 355.461 +  used to inform inflate that a faster approach may be used for the single
 355.462 +  inflate() call.
 355.463 +
 355.464 +     In this implementation, inflate() always flushes as much output as
 355.465 +  possible to the output buffer, and always uses the faster approach on the
 355.466 +  first call.  So the only effect of the flush parameter in this implementation
 355.467 +  is on the return value of inflate(), as noted below, or when it returns early
 355.468 +  because Z_BLOCK or Z_TREES is used.
 355.469 +
 355.470 +     If a preset dictionary is needed after this call (see inflateSetDictionary
 355.471 +  below), inflate sets strm->adler to the adler32 checksum of the dictionary
 355.472 +  chosen by the compressor and returns Z_NEED_DICT; otherwise it sets
 355.473 +  strm->adler to the adler32 checksum of all output produced so far (that is,
 355.474 +  total_out bytes) and returns Z_OK, Z_STREAM_END or an error code as described
 355.475 +  below.  At the end of the stream, inflate() checks that its computed adler32
 355.476 +  checksum is equal to that saved by the compressor and returns Z_STREAM_END
 355.477 +  only if the checksum is correct.
 355.478 +
 355.479 +    inflate() can decompress and check either zlib-wrapped or gzip-wrapped
 355.480 +  deflate data.  The header type is detected automatically, if requested when
 355.481 +  initializing with inflateInit2().  Any information contained in the gzip
 355.482 +  header is not retained, so applications that need that information should
 355.483 +  instead use raw inflate, see inflateInit2() below, or inflateBack() and
 355.484 +  perform their own processing of the gzip header and trailer.
 355.485 +
 355.486 +    inflate() returns Z_OK if some progress has been made (more input processed
 355.487 +  or more output produced), Z_STREAM_END if the end of the compressed data has
 355.488 +  been reached and all uncompressed output has been produced, Z_NEED_DICT if a
 355.489 +  preset dictionary is needed at this point, Z_DATA_ERROR if the input data was
 355.490 +  corrupted (input stream not conforming to the zlib format or incorrect check
 355.491 +  value), Z_STREAM_ERROR if the stream structure was inconsistent (for example
 355.492 +  next_in or next_out was Z_NULL), Z_MEM_ERROR if there was not enough memory,
 355.493 +  Z_BUF_ERROR if no progress is possible or if there was not enough room in the
 355.494 +  output buffer when Z_FINISH is used.  Note that Z_BUF_ERROR is not fatal, and
 355.495 +  inflate() can be called again with more input and more output space to
 355.496 +  continue decompressing.  If Z_DATA_ERROR is returned, the application may
 355.497 +  then call inflateSync() to look for a good compression block if a partial
 355.498 +  recovery of the data is desired.
 355.499 +*/
 355.500 +
 355.501 +
 355.502 +ZEXTERN int ZEXPORT inflateEnd OF((z_streamp strm));
 355.503 +/*
 355.504 +     All dynamically allocated data structures for this stream are freed.
 355.505 +   This function discards any unprocessed input and does not flush any pending
 355.506 +   output.
 355.507 +
 355.508 +     inflateEnd returns Z_OK if success, Z_STREAM_ERROR if the stream state
 355.509 +   was inconsistent.  In the error case, msg may be set but then points to a
 355.510 +   static string (which must not be deallocated).
 355.511 +*/
 355.512 +
 355.513 +
 355.514 +                        /* Advanced functions */
 355.515 +
 355.516 +/*
 355.517 +    The following functions are needed only in some special applications.
 355.518 +*/
 355.519 +
 355.520 +/*
 355.521 +ZEXTERN int ZEXPORT deflateInit2 OF((z_streamp strm,
 355.522 +                                     int  level,
 355.523 +                                     int  method,
 355.524 +                                     int  windowBits,
 355.525 +                                     int  memLevel,
 355.526 +                                     int  strategy));
 355.527 +
 355.528 +     This is another version of deflateInit with more compression options.  The
 355.529 +   fields next_in, zalloc, zfree and opaque must be initialized before by the
 355.530 +   caller.
 355.531 +
 355.532 +     The method parameter is the compression method.  It must be Z_DEFLATED in
 355.533 +   this version of the library.
 355.534 +
 355.535 +     The windowBits parameter is the base two logarithm of the window size
 355.536 +   (the size of the history buffer).  It should be in the range 8..15 for this
 355.537 +   version of the library.  Larger values of this parameter result in better
 355.538 +   compression at the expense of memory usage.  The default value is 15 if
 355.539 +   deflateInit is used instead.
 355.540 +
 355.541 +     windowBits can also be -8..-15 for raw deflate.  In this case, -windowBits
 355.542 +   determines the window size.  deflate() will then generate raw deflate data
 355.543 +   with no zlib header or trailer, and will not compute an adler32 check value.
 355.544 +
 355.545 +     windowBits can also be greater than 15 for optional gzip encoding.  Add
 355.546 +   16 to windowBits to write a simple gzip header and trailer around the
 355.547 +   compressed data instead of a zlib wrapper.  The gzip header will have no
 355.548 +   file name, no extra data, no comment, no modification time (set to zero), no
 355.549 +   header crc, and the operating system will be set to 255 (unknown).  If a
 355.550 +   gzip stream is being written, strm->adler is a crc32 instead of an adler32.
 355.551 +
 355.552 +     The memLevel parameter specifies how much memory should be allocated
 355.553 +   for the internal compression state.  memLevel=1 uses minimum memory but is
 355.554 +   slow and reduces compression ratio; memLevel=9 uses maximum memory for
 355.555 +   optimal speed.  The default value is 8.  See zconf.h for total memory usage
 355.556 +   as a function of windowBits and memLevel.
 355.557 +
 355.558 +     The strategy parameter is used to tune the compression algorithm.  Use the
 355.559 +   value Z_DEFAULT_STRATEGY for normal data, Z_FILTERED for data produced by a
 355.560 +   filter (or predictor), Z_HUFFMAN_ONLY to force Huffman encoding only (no
 355.561 +   string match), or Z_RLE to limit match distances to one (run-length
 355.562 +   encoding).  Filtered data consists mostly of small values with a somewhat
 355.563 +   random distribution.  In this case, the compression algorithm is tuned to
 355.564 +   compress them better.  The effect of Z_FILTERED is to force more Huffman
 355.565 +   coding and less string matching; it is somewhat intermediate between
 355.566 +   Z_DEFAULT_STRATEGY and Z_HUFFMAN_ONLY.  Z_RLE is designed to be almost as
 355.567 +   fast as Z_HUFFMAN_ONLY, but give better compression for PNG image data.  The
 355.568 +   strategy parameter only affects the compression ratio but not the
 355.569 +   correctness of the compressed output even if it is not set appropriately.
 355.570 +   Z_FIXED prevents the use of dynamic Huffman codes, allowing for a simpler
 355.571 +   decoder for special applications.
 355.572 +
 355.573 +     deflateInit2 returns Z_OK if success, Z_MEM_ERROR if there was not enough
 355.574 +   memory, Z_STREAM_ERROR if any parameter is invalid (such as an invalid
 355.575 +   method), or Z_VERSION_ERROR if the zlib library version (zlib_version) is
 355.576 +   incompatible with the version assumed by the caller (ZLIB_VERSION).  msg is
 355.577 +   set to null if there is no error message.  deflateInit2 does not perform any
 355.578 +   compression: this will be done by deflate().
 355.579 +*/
 355.580 +
 355.581 +ZEXTERN int ZEXPORT deflateSetDictionary OF((z_streamp strm,
 355.582 +                                             const Bytef *dictionary,
 355.583 +                                             uInt  dictLength));
 355.584 +/*
 355.585 +     Initializes the compression dictionary from the given byte sequence
 355.586 +   without producing any compressed output.  This function must be called
 355.587 +   immediately after deflateInit, deflateInit2 or deflateReset, before any call
 355.588 +   of deflate.  The compressor and decompressor must use exactly the same
 355.589 +   dictionary (see inflateSetDictionary).
 355.590 +
 355.591 +     The dictionary should consist of strings (byte sequences) that are likely
 355.592 +   to be encountered later in the data to be compressed, with the most commonly
 355.593 +   used strings preferably put towards the end of the dictionary.  Using a
 355.594 +   dictionary is most useful when the data to be compressed is short and can be
 355.595 +   predicted with good accuracy; the data can then be compressed better than
 355.596 +   with the default empty dictionary.
 355.597 +
 355.598 +     Depending on the size of the compression data structures selected by
 355.599 +   deflateInit or deflateInit2, a part of the dictionary may in effect be
 355.600 +   discarded, for example if the dictionary is larger than the window size
 355.601 +   provided in deflateInit or deflateInit2.  Thus the strings most likely to be
 355.602 +   useful should be put at the end of the dictionary, not at the front.  In
 355.603 +   addition, the current implementation of deflate will use at most the window
 355.604 +   size minus 262 bytes of the provided dictionary.
 355.605 +
 355.606 +     Upon return of this function, strm->adler is set to the adler32 value
 355.607 +   of the dictionary; the decompressor may later use this value to determine
 355.608 +   which dictionary has been used by the compressor.  (The adler32 value
 355.609 +   applies to the whole dictionary even if only a subset of the dictionary is
 355.610 +   actually used by the compressor.) If a raw deflate was requested, then the
 355.611 +   adler32 value is not computed and strm->adler is not set.
 355.612 +
 355.613 +     deflateSetDictionary returns Z_OK if success, or Z_STREAM_ERROR if a
 355.614 +   parameter is invalid (e.g.  dictionary being Z_NULL) or the stream state is
 355.615 +   inconsistent (for example if deflate has already been called for this stream
 355.616 +   or if the compression method is bsort).  deflateSetDictionary does not
 355.617 +   perform any compression: this will be done by deflate().
 355.618 +*/
 355.619 +
 355.620 +ZEXTERN int ZEXPORT deflateCopy OF((z_streamp dest,
 355.621 +                                    z_streamp source));
 355.622 +/*
 355.623 +     Sets the destination stream as a complete copy of the source stream.
 355.624 +
 355.625 +     This function can be useful when several compression strategies will be
 355.626 +   tried, for example when there are several ways of pre-processing the input
 355.627 +   data with a filter.  The streams that will be discarded should then be freed
 355.628 +   by calling deflateEnd.  Note that deflateCopy duplicates the internal
 355.629 +   compression state which can be quite large, so this strategy is slow and can
 355.630 +   consume lots of memory.
 355.631 +
 355.632 +     deflateCopy returns Z_OK if success, Z_MEM_ERROR if there was not
 355.633 +   enough memory, Z_STREAM_ERROR if the source stream state was inconsistent
 355.634 +   (such as zalloc being Z_NULL).  msg is left unchanged in both source and
 355.635 +   destination.
 355.636 +*/
 355.637 +
 355.638 +ZEXTERN int ZEXPORT deflateReset OF((z_streamp strm));
 355.639 +/*
 355.640 +     This function is equivalent to deflateEnd followed by deflateInit,
 355.641 +   but does not free and reallocate all the internal compression state.  The
 355.642 +   stream will keep the same compression level and any other attributes that
 355.643 +   may have been set by deflateInit2.
 355.644 +
 355.645 +     deflateReset returns Z_OK if success, or Z_STREAM_ERROR if the source
 355.646 +   stream state was inconsistent (such as zalloc or state being Z_NULL).
 355.647 +*/
 355.648 +
 355.649 +ZEXTERN int ZEXPORT deflateParams OF((z_streamp strm,
 355.650 +                                      int level,
 355.651 +                                      int strategy));
 355.652 +/*
 355.653 +     Dynamically update the compression level and compression strategy.  The
 355.654 +   interpretation of level and strategy is as in deflateInit2.  This can be
 355.655 +   used to switch between compression and straight copy of the input data, or
 355.656 +   to switch to a different kind of input data requiring a different strategy.
 355.657 +   If the compression level is changed, the input available so far is
 355.658 +   compressed with the old level (and may be flushed); the new level will take
 355.659 +   effect only at the next call of deflate().
 355.660 +
 355.661 +     Before the call of deflateParams, the stream state must be set as for
 355.662 +   a call of deflate(), since the currently available input may have to be
 355.663 +   compressed and flushed.  In particular, strm->avail_out must be non-zero.
 355.664 +
 355.665 +     deflateParams returns Z_OK if success, Z_STREAM_ERROR if the source
 355.666 +   stream state was inconsistent or if a parameter was invalid, Z_BUF_ERROR if
 355.667 +   strm->avail_out was zero.
 355.668 +*/
 355.669 +
 355.670 +ZEXTERN int ZEXPORT deflateTune OF((z_streamp strm,
 355.671 +                                    int good_length,
 355.672 +                                    int max_lazy,
 355.673 +                                    int nice_length,
 355.674 +                                    int max_chain));
 355.675 +/*
 355.676 +     Fine tune deflate's internal compression parameters.  This should only be
 355.677 +   used by someone who understands the algorithm used by zlib's deflate for
 355.678 +   searching for the best matching string, and even then only by the most
 355.679 +   fanatic optimizer trying to squeeze out the last compressed bit for their
 355.680 +   specific input data.  Read the deflate.c source code for the meaning of the
 355.681 +   max_lazy, good_length, nice_length, and max_chain parameters.
 355.682 +
 355.683 +     deflateTune() can be called after deflateInit() or deflateInit2(), and
 355.684 +   returns Z_OK on success, or Z_STREAM_ERROR for an invalid deflate stream.
 355.685 + */
 355.686 +
 355.687 +ZEXTERN uLong ZEXPORT deflateBound OF((z_streamp strm,
 355.688 +                                       uLong sourceLen));
 355.689 +/*
 355.690 +     deflateBound() returns an upper bound on the compressed size after
 355.691 +   deflation of sourceLen bytes.  It must be called after deflateInit() or
 355.692 +   deflateInit2(), and after deflateSetHeader(), if used.  This would be used
 355.693 +   to allocate an output buffer for deflation in a single pass, and so would be
 355.694 +   called before deflate().
 355.695 +*/
 355.696 +
 355.697 +ZEXTERN int ZEXPORT deflatePrime OF((z_streamp strm,
 355.698 +                                     int bits,
 355.699 +                                     int value));
 355.700 +/*
 355.701 +     deflatePrime() inserts bits in the deflate output stream.  The intent
 355.702 +   is that this function is used to start off the deflate output with the bits
 355.703 +   leftover from a previous deflate stream when appending to it.  As such, this
 355.704 +   function can only be used for raw deflate, and must be used before the first
 355.705 +   deflate() call after a deflateInit2() or deflateReset().  bits must be less
 355.706 +   than or equal to 16, and that many of the least significant bits of value
 355.707 +   will be inserted in the output.
 355.708 +
 355.709 +     deflatePrime returns Z_OK if success, or Z_STREAM_ERROR if the source
 355.710 +   stream state was inconsistent.
 355.711 +*/
 355.712 +
 355.713 +ZEXTERN int ZEXPORT deflateSetHeader OF((z_streamp strm,
 355.714 +                                         gz_headerp head));
 355.715 +/*
 355.716 +     deflateSetHeader() provides gzip header information for when a gzip
 355.717 +   stream is requested by deflateInit2().  deflateSetHeader() may be called
 355.718 +   after deflateInit2() or deflateReset() and before the first call of
 355.719 +   deflate().  The text, time, os, extra field, name, and comment information
 355.720 +   in the provided gz_header structure are written to the gzip header (xflag is
 355.721 +   ignored -- the extra flags are set according to the compression level).  The
 355.722 +   caller must assure that, if not Z_NULL, name and comment are terminated with
 355.723 +   a zero byte, and that if extra is not Z_NULL, that extra_len bytes are
 355.724 +   available there.  If hcrc is true, a gzip header crc is included.  Note that
 355.725 +   the current versions of the command-line version of gzip (up through version
 355.726 +   1.3.x) do not support header crc's, and will report that it is a "multi-part
 355.727 +   gzip file" and give up.
 355.728 +
 355.729 +     If deflateSetHeader is not used, the default gzip header has text false,
 355.730 +   the time set to zero, and os set to 255, with no extra, name, or comment
 355.731 +   fields.  The gzip header is returned to the default state by deflateReset().
 355.732 +
 355.733 +     deflateSetHeader returns Z_OK if success, or Z_STREAM_ERROR if the source
 355.734 +   stream state was inconsistent.
 355.735 +*/
 355.736 +
 355.737 +/*
 355.738 +ZEXTERN int ZEXPORT inflateInit2 OF((z_streamp strm,
 355.739 +                                     int  windowBits));
 355.740 +
 355.741 +     This is another version of inflateInit with an extra parameter.  The
 355.742 +   fields next_in, avail_in, zalloc, zfree and opaque must be initialized
 355.743 +   before by the caller.
 355.744 +
 355.745 +     The windowBits parameter is the base two logarithm of the maximum window
 355.746 +   size (the size of the history buffer).  It should be in the range 8..15 for
 355.747 +   this version of the library.  The default value is 15 if inflateInit is used
 355.748 +   instead.  windowBits must be greater than or equal to the windowBits value
 355.749 +   provided to deflateInit2() while compressing, or it must be equal to 15 if
 355.750 +   deflateInit2() was not used.  If a compressed stream with a larger window
 355.751 +   size is given as input, inflate() will return with the error code
 355.752 +   Z_DATA_ERROR instead of trying to allocate a larger window.
 355.753 +
 355.754 +     windowBits can also be zero to request that inflate use the window size in
 355.755 +   the zlib header of the compressed stream.
 355.756 +
 355.757 +     windowBits can also be -8..-15 for raw inflate.  In this case, -windowBits
 355.758 +   determines the window size.  inflate() will then process raw deflate data,
 355.759 +   not looking for a zlib or gzip header, not generating a check value, and not
 355.760 +   looking for any check values for comparison at the end of the stream.  This
 355.761 +   is for use with other formats that use the deflate compressed data format
 355.762 +   such as zip.  Those formats provide their own check values.  If a custom
 355.763 +   format is developed using the raw deflate format for compressed data, it is
 355.764 +   recommended that a check value such as an adler32 or a crc32 be applied to
 355.765 +   the uncompressed data as is done in the zlib, gzip, and zip formats.  For
 355.766 +   most applications, the zlib format should be used as is.  Note that comments
 355.767 +   above on the use in deflateInit2() applies to the magnitude of windowBits.
 355.768 +
 355.769 +     windowBits can also be greater than 15 for optional gzip decoding.  Add
 355.770 +   32 to windowBits to enable zlib and gzip decoding with automatic header
 355.771 +   detection, or add 16 to decode only the gzip format (the zlib format will
 355.772 +   return a Z_DATA_ERROR).  If a gzip stream is being decoded, strm->adler is a
 355.773 +   crc32 instead of an adler32.
 355.774 +
 355.775 +     inflateInit2 returns Z_OK if success, Z_MEM_ERROR if there was not enough
 355.776 +   memory, Z_VERSION_ERROR if the zlib library version is incompatible with the
 355.777 +   version assumed by the caller, or Z_STREAM_ERROR if the parameters are
 355.778 +   invalid, such as a null pointer to the structure.  msg is set to null if
 355.779 +   there is no error message.  inflateInit2 does not perform any decompression
 355.780 +   apart from possibly reading the zlib header if present: actual decompression
 355.781 +   will be done by inflate().  (So next_in and avail_in may be modified, but
 355.782 +   next_out and avail_out are unused and unchanged.) The current implementation
 355.783 +   of inflateInit2() does not process any header information -- that is
 355.784 +   deferred until inflate() is called.
 355.785 +*/
 355.786 +
 355.787 +ZEXTERN int ZEXPORT inflateSetDictionary OF((z_streamp strm,
 355.788 +                                             const Bytef *dictionary,
 355.789 +                                             uInt  dictLength));
 355.790 +/*
 355.791 +     Initializes the decompression dictionary from the given uncompressed byte
 355.792 +   sequence.  This function must be called immediately after a call of inflate,
 355.793 +   if that call returned Z_NEED_DICT.  The dictionary chosen by the compressor
 355.794 +   can be determined from the adler32 value returned by that call of inflate.
 355.795 +   The compressor and decompressor must use exactly the same dictionary (see
 355.796 +   deflateSetDictionary).  For raw inflate, this function can be called
 355.797 +   immediately after inflateInit2() or inflateReset() and before any call of
 355.798 +   inflate() to set the dictionary.  The application must insure that the
 355.799 +   dictionary that was used for compression is provided.
 355.800 +
 355.801 +     inflateSetDictionary returns Z_OK if success, Z_STREAM_ERROR if a
 355.802 +   parameter is invalid (e.g.  dictionary being Z_NULL) or the stream state is
 355.803 +   inconsistent, Z_DATA_ERROR if the given dictionary doesn't match the
 355.804 +   expected one (incorrect adler32 value).  inflateSetDictionary does not
 355.805 +   perform any decompression: this will be done by subsequent calls of
 355.806 +   inflate().
 355.807 +*/
 355.808 +
 355.809 +ZEXTERN int ZEXPORT inflateSync OF((z_streamp strm));
 355.810 +/*
 355.811 +     Skips invalid compressed data until a full flush point (see above the
 355.812 +   description of deflate with Z_FULL_FLUSH) can be found, or until all
 355.813 +   available input is skipped.  No output is provided.
 355.814 +
 355.815 +     inflateSync returns Z_OK if a full flush point has been found, Z_BUF_ERROR
 355.816 +   if no more input was provided, Z_DATA_ERROR if no flush point has been
 355.817 +   found, or Z_STREAM_ERROR if the stream structure was inconsistent.  In the
 355.818 +   success case, the application may save the current current value of total_in
 355.819 +   which indicates where valid compressed data was found.  In the error case,
 355.820 +   the application may repeatedly call inflateSync, providing more input each
 355.821 +   time, until success or end of the input data.
 355.822 +*/
 355.823 +
 355.824 +ZEXTERN int ZEXPORT inflateCopy OF((z_streamp dest,
 355.825 +                                    z_streamp source));
 355.826 +/*
 355.827 +     Sets the destination stream as a complete copy of the source stream.
 355.828 +
 355.829 +     This function can be useful when randomly accessing a large stream.  The
 355.830 +   first pass through the stream can periodically record the inflate state,
 355.831 +   allowing restarting inflate at those points when randomly accessing the
 355.832 +   stream.
 355.833 +
 355.834 +     inflateCopy returns Z_OK if success, Z_MEM_ERROR if there was not
 355.835 +   enough memory, Z_STREAM_ERROR if the source stream state was inconsistent
 355.836 +   (such as zalloc being Z_NULL).  msg is left unchanged in both source and
 355.837 +   destination.
 355.838 +*/
 355.839 +
 355.840 +ZEXTERN int ZEXPORT inflateReset OF((z_streamp strm));
 355.841 +/*
 355.842 +     This function is equivalent to inflateEnd followed by inflateInit,
 355.843 +   but does not free and reallocate all the internal decompression state.  The
 355.844 +   stream will keep attributes that may have been set by inflateInit2.
 355.845 +
 355.846 +     inflateReset returns Z_OK if success, or Z_STREAM_ERROR if the source
 355.847 +   stream state was inconsistent (such as zalloc or state being Z_NULL).
 355.848 +*/
 355.849 +
 355.850 +ZEXTERN int ZEXPORT inflateReset2 OF((z_streamp strm,
 355.851 +                                      int windowBits));
 355.852 +/*
 355.853 +     This function is the same as inflateReset, but it also permits changing
 355.854 +   the wrap and window size requests.  The windowBits parameter is interpreted
 355.855 +   the same as it is for inflateInit2.
 355.856 +
 355.857 +     inflateReset2 returns Z_OK if success, or Z_STREAM_ERROR if the source
 355.858 +   stream state was inconsistent (such as zalloc or state being Z_NULL), or if
 355.859 +   the windowBits parameter is invalid.
 355.860 +*/
 355.861 +
 355.862 +ZEXTERN int ZEXPORT inflatePrime OF((z_streamp strm,
 355.863 +                                     int bits,
 355.864 +                                     int value));
 355.865 +/*
 355.866 +     This function inserts bits in the inflate input stream.  The intent is
 355.867 +   that this function is used to start inflating at a bit position in the
 355.868 +   middle of a byte.  The provided bits will be used before any bytes are used
 355.869 +   from next_in.  This function should only be used with raw inflate, and
 355.870 +   should be used before the first inflate() call after inflateInit2() or
 355.871 +   inflateReset().  bits must be less than or equal to 16, and that many of the
 355.872 +   least significant bits of value will be inserted in the input.
 355.873 +
 355.874 +     If bits is negative, then the input stream bit buffer is emptied.  Then
 355.875 +   inflatePrime() can be called again to put bits in the buffer.  This is used
 355.876 +   to clear out bits leftover after feeding inflate a block description prior
 355.877 +   to feeding inflate codes.
 355.878 +
 355.879 +     inflatePrime returns Z_OK if success, or Z_STREAM_ERROR if the source
 355.880 +   stream state was inconsistent.
 355.881 +*/
 355.882 +
 355.883 +ZEXTERN long ZEXPORT inflateMark OF((z_streamp strm));
 355.884 +/*
 355.885 +     This function returns two values, one in the lower 16 bits of the return
 355.886 +   value, and the other in the remaining upper bits, obtained by shifting the
 355.887 +   return value down 16 bits.  If the upper value is -1 and the lower value is
 355.888 +   zero, then inflate() is currently decoding information outside of a block.
 355.889 +   If the upper value is -1 and the lower value is non-zero, then inflate is in
 355.890 +   the middle of a stored block, with the lower value equaling the number of
 355.891 +   bytes from the input remaining to copy.  If the upper value is not -1, then
 355.892 +   it is the number of bits back from the current bit position in the input of
 355.893 +   the code (literal or length/distance pair) currently being processed.  In
 355.894 +   that case the lower value is the number of bytes already emitted for that
 355.895 +   code.
 355.896 +
 355.897 +     A code is being processed if inflate is waiting for more input to complete
 355.898 +   decoding of the code, or if it has completed decoding but is waiting for
 355.899 +   more output space to write the literal or match data.
 355.900 +
 355.901 +     inflateMark() is used to mark locations in the input data for random
 355.902 +   access, which may be at bit positions, and to note those cases where the
 355.903 +   output of a code may span boundaries of random access blocks.  The current
 355.904 +   location in the input stream can be determined from avail_in and data_type
 355.905 +   as noted in the description for the Z_BLOCK flush parameter for inflate.
 355.906 +
 355.907 +     inflateMark returns the value noted above or -1 << 16 if the provided
 355.908 +   source stream state was inconsistent.
 355.909 +*/
 355.910 +
 355.911 +ZEXTERN int ZEXPORT inflateGetHeader OF((z_streamp strm,
 355.912 +                                         gz_headerp head));
 355.913 +/*
 355.914 +     inflateGetHeader() requests that gzip header information be stored in the
 355.915 +   provided gz_header structure.  inflateGetHeader() may be called after
 355.916 +   inflateInit2() or inflateReset(), and before the first call of inflate().
 355.917 +   As inflate() processes the gzip stream, head->done is zero until the header
 355.918 +   is completed, at which time head->done is set to one.  If a zlib stream is
 355.919 +   being decoded, then head->done is set to -1 to indicate that there will be
 355.920 +   no gzip header information forthcoming.  Note that Z_BLOCK or Z_TREES can be
 355.921 +   used to force inflate() to return immediately after header processing is
 355.922 +   complete and before any actual data is decompressed.
 355.923 +
 355.924 +     The text, time, xflags, and os fields are filled in with the gzip header
 355.925 +   contents.  hcrc is set to true if there is a header CRC.  (The header CRC
 355.926 +   was valid if done is set to one.) If extra is not Z_NULL, then extra_max
 355.927 +   contains the maximum number of bytes to write to extra.  Once done is true,
 355.928 +   extra_len contains the actual extra field length, and extra contains the
 355.929 +   extra field, or that field truncated if extra_max is less than extra_len.
 355.930 +   If name is not Z_NULL, then up to name_max characters are written there,
 355.931 +   terminated with a zero unless the length is greater than name_max.  If
 355.932 +   comment is not Z_NULL, then up to comm_max characters are written there,
 355.933 +   terminated with a zero unless the length is greater than comm_max.  When any
 355.934 +   of extra, name, or comment are not Z_NULL and the respective field is not
 355.935 +   present in the header, then that field is set to Z_NULL to signal its
 355.936 +   absence.  This allows the use of deflateSetHeader() with the returned
 355.937 +   structure to duplicate the header.  However if those fields are set to
 355.938 +   allocated memory, then the application will need to save those pointers
 355.939 +   elsewhere so that they can be eventually freed.
 355.940 +
 355.941 +     If inflateGetHeader is not used, then the header information is simply
 355.942 +   discarded.  The header is always checked for validity, including the header
 355.943 +   CRC if present.  inflateReset() will reset the process to discard the header
 355.944 +   information.  The application would need to call inflateGetHeader() again to
 355.945 +   retrieve the header from the next gzip stream.
 355.946 +
 355.947 +     inflateGetHeader returns Z_OK if success, or Z_STREAM_ERROR if the source
 355.948 +   stream state was inconsistent.
 355.949 +*/
 355.950 +
 355.951 +/*
 355.952 +ZEXTERN int ZEXPORT inflateBackInit OF((z_streamp strm, int windowBits,
 355.953 +                                        unsigned char FAR *window));
 355.954 +
 355.955 +     Initialize the internal stream state for decompression using inflateBack()
 355.956 +   calls.  The fields zalloc, zfree and opaque in strm must be initialized
 355.957 +   before the call.  If zalloc and zfree are Z_NULL, then the default library-
 355.958 +   derived memory allocation routines are used.  windowBits is the base two
 355.959 +   logarithm of the window size, in the range 8..15.  window is a caller
 355.960 +   supplied buffer of that size.  Except for special applications where it is
 355.961 +   assured that deflate was used with small window sizes, windowBits must be 15
 355.962 +   and a 32K byte window must be supplied to be able to decompress general
 355.963 +   deflate streams.
 355.964 +
 355.965 +     See inflateBack() for the usage of these routines.
 355.966 +
 355.967 +     inflateBackInit will return Z_OK on success, Z_STREAM_ERROR if any of
 355.968 +   the paramaters are invalid, Z_MEM_ERROR if the internal state could not be
 355.969 +   allocated, or Z_VERSION_ERROR if the version of the library does not match
 355.970 +   the version of the header file.
 355.971 +*/
 355.972 +
 355.973 +typedef unsigned (*in_func) OF((void FAR *, unsigned char FAR * FAR *));
 355.974 +typedef int (*out_func) OF((void FAR *, unsigned char FAR *, unsigned));
 355.975 +
 355.976 +ZEXTERN int ZEXPORT inflateBack OF((z_streamp strm,
 355.977 +                                    in_func in, void FAR *in_desc,
 355.978 +                                    out_func out, void FAR *out_desc));
 355.979 +/*
 355.980 +     inflateBack() does a raw inflate with a single call using a call-back
 355.981 +   interface for input and output.  This is more efficient than inflate() for
 355.982 +   file i/o applications in that it avoids copying between the output and the
 355.983 +   sliding window by simply making the window itself the output buffer.  This
 355.984 +   function trusts the application to not change the output buffer passed by
 355.985 +   the output function, at least until inflateBack() returns.
 355.986 +
 355.987 +     inflateBackInit() must be called first to allocate the internal state
 355.988 +   and to initialize the state with the user-provided window buffer.
 355.989 +   inflateBack() may then be used multiple times to inflate a complete, raw
 355.990 +   deflate stream with each call.  inflateBackEnd() is then called to free the
 355.991 +   allocated state.
 355.992 +
 355.993 +     A raw deflate stream is one with no zlib or gzip header or trailer.
 355.994 +   This routine would normally be used in a utility that reads zip or gzip
 355.995 +   files and writes out uncompressed files.  The utility would decode the
 355.996 +   header and process the trailer on its own, hence this routine expects only
 355.997 +   the raw deflate stream to decompress.  This is different from the normal
 355.998 +   behavior of inflate(), which expects either a zlib or gzip header and
 355.999 +   trailer around the deflate stream.
355.1000 +
355.1001 +     inflateBack() uses two subroutines supplied by the caller that are then
355.1002 +   called by inflateBack() for input and output.  inflateBack() calls those
355.1003 +   routines until it reads a complete deflate stream and writes out all of the
355.1004 +   uncompressed data, or until it encounters an error.  The function's
355.1005 +   parameters and return types are defined above in the in_func and out_func
355.1006 +   typedefs.  inflateBack() will call in(in_desc, &buf) which should return the
355.1007 +   number of bytes of provided input, and a pointer to that input in buf.  If
355.1008 +   there is no input available, in() must return zero--buf is ignored in that
355.1009 +   case--and inflateBack() will return a buffer error.  inflateBack() will call
355.1010 +   out(out_desc, buf, len) to write the uncompressed data buf[0..len-1].  out()
355.1011 +   should return zero on success, or non-zero on failure.  If out() returns
355.1012 +   non-zero, inflateBack() will return with an error.  Neither in() nor out()
355.1013 +   are permitted to change the contents of the window provided to
355.1014 +   inflateBackInit(), which is also the buffer that out() uses to write from.
355.1015 +   The length written by out() will be at most the window size.  Any non-zero
355.1016 +   amount of input may be provided by in().
355.1017 +
355.1018 +     For convenience, inflateBack() can be provided input on the first call by
355.1019 +   setting strm->next_in and strm->avail_in.  If that input is exhausted, then
355.1020 +   in() will be called.  Therefore strm->next_in must be initialized before
355.1021 +   calling inflateBack().  If strm->next_in is Z_NULL, then in() will be called
355.1022 +   immediately for input.  If strm->next_in is not Z_NULL, then strm->avail_in
355.1023 +   must also be initialized, and then if strm->avail_in is not zero, input will
355.1024 +   initially be taken from strm->next_in[0 ..  strm->avail_in - 1].
355.1025 +
355.1026 +     The in_desc and out_desc parameters of inflateBack() is passed as the
355.1027 +   first parameter of in() and out() respectively when they are called.  These
355.1028 +   descriptors can be optionally used to pass any information that the caller-
355.1029 +   supplied in() and out() functions need to do their job.
355.1030 +
355.1031 +     On return, inflateBack() will set strm->next_in and strm->avail_in to
355.1032 +   pass back any unused input that was provided by the last in() call.  The
355.1033 +   return values of inflateBack() can be Z_STREAM_END on success, Z_BUF_ERROR
355.1034 +   if in() or out() returned an error, Z_DATA_ERROR if there was a format error
355.1035 +   in the deflate stream (in which case strm->msg is set to indicate the nature
355.1036 +   of the error), or Z_STREAM_ERROR if the stream was not properly initialized.
355.1037 +   In the case of Z_BUF_ERROR, an input or output error can be distinguished
355.1038 +   using strm->next_in which will be Z_NULL only if in() returned an error.  If
355.1039 +   strm->next_in is not Z_NULL, then the Z_BUF_ERROR was due to out() returning
355.1040 +   non-zero.  (in() will always be called before out(), so strm->next_in is
355.1041 +   assured to be defined if out() returns non-zero.) Note that inflateBack()
355.1042 +   cannot return Z_OK.
355.1043 +*/
355.1044 +
355.1045 +ZEXTERN int ZEXPORT inflateBackEnd OF((z_streamp strm));
355.1046 +/*
355.1047 +     All memory allocated by inflateBackInit() is freed.
355.1048 +
355.1049 +     inflateBackEnd() returns Z_OK on success, or Z_STREAM_ERROR if the stream
355.1050 +   state was inconsistent.
355.1051 +*/
355.1052 +
355.1053 +ZEXTERN uLong ZEXPORT zlibCompileFlags OF((void));
355.1054 +/* Return flags indicating compile-time options.
355.1055 +
355.1056 +    Type sizes, two bits each, 00 = 16 bits, 01 = 32, 10 = 64, 11 = other:
355.1057 +     1.0: size of uInt
355.1058 +     3.2: size of uLong
355.1059 +     5.4: size of voidpf (pointer)
355.1060 +     7.6: size of z_off_t
355.1061 +
355.1062 +    Compiler, assembler, and debug options:
355.1063 +     8: DEBUG
355.1064 +     9: ASMV or ASMINF -- use ASM code
355.1065 +     10: ZLIB_WINAPI -- exported functions use the WINAPI calling convention
355.1066 +     11: 0 (reserved)
355.1067 +
355.1068 +    One-time table building (smaller code, but not thread-safe if true):
355.1069 +     12: BUILDFIXED -- build static block decoding tables when needed
355.1070 +     13: DYNAMIC_CRC_TABLE -- build CRC calculation tables when needed
355.1071 +     14,15: 0 (reserved)
355.1072 +
355.1073 +    Library content (indicates missing functionality):
355.1074 +     16: NO_GZCOMPRESS -- gz* functions cannot compress (to avoid linking
355.1075 +                          deflate code when not needed)
355.1076 +     17: NO_GZIP -- deflate can't write gzip streams, and inflate can't detect
355.1077 +                    and decode gzip streams (to avoid linking crc code)
355.1078 +     18-19: 0 (reserved)
355.1079 +
355.1080 +    Operation variations (changes in library functionality):
355.1081 +     20: PKZIP_BUG_WORKAROUND -- slightly more permissive inflate
355.1082 +     21: FASTEST -- deflate algorithm with only one, lowest compression level
355.1083 +     22,23: 0 (reserved)
355.1084 +
355.1085 +    The sprintf variant used by gzprintf (zero is best):
355.1086 +     24: 0 = vs*, 1 = s* -- 1 means limited to 20 arguments after the format
355.1087 +     25: 0 = *nprintf, 1 = *printf -- 1 means gzprintf() not secure!
355.1088 +     26: 0 = returns value, 1 = void -- 1 means inferred string length returned
355.1089 +
355.1090 +    Remainder:
355.1091 +     27-31: 0 (reserved)
355.1092 + */
355.1093 +
355.1094 +
355.1095 +                        /* utility functions */
355.1096 +
355.1097 +/*
355.1098 +     The following utility functions are implemented on top of the basic
355.1099 +   stream-oriented functions.  To simplify the interface, some default options
355.1100 +   are assumed (compression level and memory usage, standard memory allocation
355.1101 +   functions).  The source code of these utility functions can be modified if
355.1102 +   you need special options.
355.1103 +*/
355.1104 +
355.1105 +ZEXTERN int ZEXPORT compress OF((Bytef *dest,   uLongf *destLen,
355.1106 +                                 const Bytef *source, uLong sourceLen));
355.1107 +/*
355.1108 +     Compresses the source buffer into the destination buffer.  sourceLen is
355.1109 +   the byte length of the source buffer.  Upon entry, destLen is the total size
355.1110 +   of the destination buffer, which must be at least the value returned by
355.1111 +   compressBound(sourceLen).  Upon exit, destLen is the actual size of the
355.1112 +   compressed buffer.
355.1113 +
355.1114 +     compress returns Z_OK if success, Z_MEM_ERROR if there was not
355.1115 +   enough memory, Z_BUF_ERROR if there was not enough room in the output
355.1116 +   buffer.
355.1117 +*/
355.1118 +
355.1119 +ZEXTERN int ZEXPORT compress2 OF((Bytef *dest,   uLongf *destLen,
355.1120 +                                  const Bytef *source, uLong sourceLen,
355.1121 +                                  int level));
355.1122 +/*
355.1123 +     Compresses the source buffer into the destination buffer.  The level
355.1124 +   parameter has the same meaning as in deflateInit.  sourceLen is the byte
355.1125 +   length of the source buffer.  Upon entry, destLen is the total size of the
355.1126 +   destination buffer, which must be at least the value returned by
355.1127 +   compressBound(sourceLen).  Upon exit, destLen is the actual size of the
355.1128 +   compressed buffer.
355.1129 +
355.1130 +     compress2 returns Z_OK if success, Z_MEM_ERROR if there was not enough
355.1131 +   memory, Z_BUF_ERROR if there was not enough room in the output buffer,
355.1132 +   Z_STREAM_ERROR if the level parameter is invalid.
355.1133 +*/
355.1134 +
355.1135 +ZEXTERN uLong ZEXPORT compressBound OF((uLong sourceLen));
355.1136 +/*
355.1137 +     compressBound() returns an upper bound on the compressed size after
355.1138 +   compress() or compress2() on sourceLen bytes.  It would be used before a
355.1139 +   compress() or compress2() call to allocate the destination buffer.
355.1140 +*/
355.1141 +
355.1142 +ZEXTERN int ZEXPORT uncompress OF((Bytef *dest,   uLongf *destLen,
355.1143 +                                   const Bytef *source, uLong sourceLen));
355.1144 +/*
355.1145 +     Decompresses the source buffer into the destination buffer.  sourceLen is
355.1146 +   the byte length of the source buffer.  Upon entry, destLen is the total size
355.1147 +   of the destination buffer, which must be large enough to hold the entire
355.1148 +   uncompressed data.  (The size of the uncompressed data must have been saved
355.1149 +   previously by the compressor and transmitted to the decompressor by some
355.1150 +   mechanism outside the scope of this compression library.) Upon exit, destLen
355.1151 +   is the actual size of the uncompressed buffer.
355.1152 +
355.1153 +     uncompress returns Z_OK if success, Z_MEM_ERROR if there was not
355.1154 +   enough memory, Z_BUF_ERROR if there was not enough room in the output
355.1155 +   buffer, or Z_DATA_ERROR if the input data was corrupted or incomplete.
355.1156 +*/
355.1157 +
355.1158 +
355.1159 +                        /* gzip file access functions */
355.1160 +
355.1161 +/*
355.1162 +     This library supports reading and writing files in gzip (.gz) format with
355.1163 +   an interface similar to that of stdio, using the functions that start with
355.1164 +   "gz".  The gzip format is different from the zlib format.  gzip is a gzip
355.1165 +   wrapper, documented in RFC 1952, wrapped around a deflate stream.
355.1166 +*/
355.1167 +
355.1168 +typedef voidp gzFile;       /* opaque gzip file descriptor */
355.1169 +
355.1170 +/*
355.1171 +ZEXTERN gzFile ZEXPORT gzopen OF((const char *path, const char *mode));
355.1172 +
355.1173 +     Opens a gzip (.gz) file for reading or writing.  The mode parameter is as
355.1174 +   in fopen ("rb" or "wb") but can also include a compression level ("wb9") or
355.1175 +   a strategy: 'f' for filtered data as in "wb6f", 'h' for Huffman-only
355.1176 +   compression as in "wb1h", 'R' for run-length encoding as in "wb1R", or 'F'
355.1177 +   for fixed code compression as in "wb9F".  (See the description of
355.1178 +   deflateInit2 for more information about the strategy parameter.) Also "a"
355.1179 +   can be used instead of "w" to request that the gzip stream that will be
355.1180 +   written be appended to the file.  "+" will result in an error, since reading
355.1181 +   and writing to the same gzip file is not supported.
355.1182 +
355.1183 +     gzopen can be used to read a file which is not in gzip format; in this
355.1184 +   case gzread will directly read from the file without decompression.
355.1185 +
355.1186 +     gzopen returns NULL if the file could not be opened, if there was
355.1187 +   insufficient memory to allocate the gzFile state, or if an invalid mode was
355.1188 +   specified (an 'r', 'w', or 'a' was not provided, or '+' was provided).
355.1189 +   errno can be checked to determine if the reason gzopen failed was that the
355.1190 +   file could not be opened.
355.1191 +*/
355.1192 +
355.1193 +ZEXTERN gzFile ZEXPORT gzdopen OF((int fd, const char *mode));
355.1194 +/*
355.1195 +     gzdopen associates a gzFile with the file descriptor fd.  File descriptors
355.1196 +   are obtained from calls like open, dup, creat, pipe or fileno (if the file
355.1197 +   has been previously opened with fopen).  The mode parameter is as in gzopen.
355.1198 +
355.1199 +     The next call of gzclose on the returned gzFile will also close the file
355.1200 +   descriptor fd, just like fclose(fdopen(fd, mode)) closes the file descriptor
355.1201 +   fd.  If you want to keep fd open, use fd = dup(fd_keep); gz = gzdopen(fd,
355.1202 +   mode);.  The duplicated descriptor should be saved to avoid a leak, since
355.1203 +   gzdopen does not close fd if it fails.
355.1204 +
355.1205 +     gzdopen returns NULL if there was insufficient memory to allocate the
355.1206 +   gzFile state, if an invalid mode was specified (an 'r', 'w', or 'a' was not
355.1207 +   provided, or '+' was provided), or if fd is -1.  The file descriptor is not
355.1208 +   used until the next gz* read, write, seek, or close operation, so gzdopen
355.1209 +   will not detect if fd is invalid (unless fd is -1).
355.1210 +*/
355.1211 +
355.1212 +ZEXTERN int ZEXPORT gzbuffer OF((gzFile file, unsigned size));
355.1213 +/*
355.1214 +     Set the internal buffer size used by this library's functions.  The
355.1215 +   default buffer size is 8192 bytes.  This function must be called after
355.1216 +   gzopen() or gzdopen(), and before any other calls that read or write the
355.1217 +   file.  The buffer memory allocation is always deferred to the first read or
355.1218 +   write.  Two buffers are allocated, either both of the specified size when
355.1219 +   writing, or one of the specified size and the other twice that size when
355.1220 +   reading.  A larger buffer size of, for example, 64K or 128K bytes will
355.1221 +   noticeably increase the speed of decompression (reading).
355.1222 +
355.1223 +     The new buffer size also affects the maximum length for gzprintf().
355.1224 +
355.1225 +     gzbuffer() returns 0 on success, or -1 on failure, such as being called
355.1226 +   too late.
355.1227 +*/
355.1228 +
355.1229 +ZEXTERN int ZEXPORT gzsetparams OF((gzFile file, int level, int strategy));
355.1230 +/*
355.1231 +     Dynamically update the compression level or strategy.  See the description
355.1232 +   of deflateInit2 for the meaning of these parameters.
355.1233 +
355.1234 +     gzsetparams returns Z_OK if success, or Z_STREAM_ERROR if the file was not
355.1235 +   opened for writing.
355.1236 +*/
355.1237 +
355.1238 +ZEXTERN int ZEXPORT gzread OF((gzFile file, voidp buf, unsigned len));
355.1239 +/*
355.1240 +     Reads the given number of uncompressed bytes from the compressed file.  If
355.1241 +   the input file was not in gzip format, gzread copies the given number of
355.1242 +   bytes into the buffer.
355.1243 +
355.1244 +     After reaching the end of a gzip stream in the input, gzread will continue
355.1245 +   to read, looking for another gzip stream, or failing that, reading the rest
355.1246 +   of the input file directly without decompression.  The entire input file
355.1247 +   will be read if gzread is called until it returns less than the requested
355.1248 +   len.
355.1249 +
355.1250 +     gzread returns the number of uncompressed bytes actually read, less than
355.1251 +   len for end of file, or -1 for error.
355.1252 +*/
355.1253 +
355.1254 +ZEXTERN int ZEXPORT gzwrite OF((gzFile file,
355.1255 +                                voidpc buf, unsigned len));
355.1256 +/*
355.1257 +     Writes the given number of uncompressed bytes into the compressed file.
355.1258 +   gzwrite returns the number of uncompressed bytes written or 0 in case of
355.1259 +   error.
355.1260 +*/
355.1261 +
355.1262 +ZEXTERN int ZEXPORTVA gzprintf OF((gzFile file, const char *format, ...));
355.1263 +/*
355.1264 +     Converts, formats, and writes the arguments to the compressed file under
355.1265 +   control of the format string, as in fprintf.  gzprintf returns the number of
355.1266 +   uncompressed bytes actually written, or 0 in case of error.  The number of
355.1267 +   uncompressed bytes written is limited to 8191, or one less than the buffer
355.1268 +   size given to gzbuffer().  The caller should assure that this limit is not
355.1269 +   exceeded.  If it is exceeded, then gzprintf() will return an error (0) with
355.1270 +   nothing written.  In this case, there may also be a buffer overflow with
355.1271 +   unpredictable consequences, which is possible only if zlib was compiled with
355.1272 +   the insecure functions sprintf() or vsprintf() because the secure snprintf()
355.1273 +   or vsnprintf() functions were not available.  This can be determined using
355.1274 +   zlibCompileFlags().
355.1275 +*/
355.1276 +
355.1277 +ZEXTERN int ZEXPORT gzputs OF((gzFile file, const char *s));
355.1278 +/*
355.1279 +     Writes the given null-terminated string to the compressed file, excluding
355.1280 +   the terminating null character.
355.1281 +
355.1282 +     gzputs returns the number of characters written, or -1 in case of error.
355.1283 +*/
355.1284 +
355.1285 +ZEXTERN char * ZEXPORT gzgets OF((gzFile file, char *buf, int len));
355.1286 +/*
355.1287 +     Reads bytes from the compressed file until len-1 characters are read, or a
355.1288 +   newline character is read and transferred to buf, or an end-of-file
355.1289 +   condition is encountered.  If any characters are read or if len == 1, the
355.1290 +   string is terminated with a null character.  If no characters are read due
355.1291 +   to an end-of-file or len < 1, then the buffer is left untouched.
355.1292 +
355.1293 +     gzgets returns buf which is a null-terminated string, or it returns NULL
355.1294 +   for end-of-file or in case of error.  If there was an error, the contents at
355.1295 +   buf are indeterminate.
355.1296 +*/
355.1297 +
355.1298 +ZEXTERN int ZEXPORT gzputc OF((gzFile file, int c));
355.1299 +/*
355.1300 +     Writes c, converted to an unsigned char, into the compressed file.  gzputc
355.1301 +   returns the value that was written, or -1 in case of error.
355.1302 +*/
355.1303 +
355.1304 +ZEXTERN int ZEXPORT gzgetc OF((gzFile file));
355.1305 +/*
355.1306 +     Reads one byte from the compressed file.  gzgetc returns this byte or -1
355.1307 +   in case of end of file or error.
355.1308 +*/
355.1309 +
355.1310 +ZEXTERN int ZEXPORT gzungetc OF((int c, gzFile file));
355.1311 +/*
355.1312 +     Push one character back onto the stream to be read as the first character
355.1313 +   on the next read.  At least one character of push-back is allowed.
355.1314 +   gzungetc() returns the character pushed, or -1 on failure.  gzungetc() will
355.1315 +   fail if c is -1, and may fail if a character has been pushed but not read
355.1316 +   yet.  If gzungetc is used immediately after gzopen or gzdopen, at least the
355.1317 +   output buffer size of pushed characters is allowed.  (See gzbuffer above.)
355.1318 +   The pushed character will be discarded if the stream is repositioned with
355.1319 +   gzseek() or gzrewind().
355.1320 +*/
355.1321 +
355.1322 +ZEXTERN int ZEXPORT gzflush OF((gzFile file, int flush));
355.1323 +/*
355.1324 +     Flushes all pending output into the compressed file.  The parameter flush
355.1325 +   is as in the deflate() function.  The return value is the zlib error number
355.1326 +   (see function gzerror below).  gzflush is only permitted when writing.
355.1327 +
355.1328 +     If the flush parameter is Z_FINISH, the remaining data is written and the
355.1329 +   gzip stream is completed in the output.  If gzwrite() is called again, a new
355.1330 +   gzip stream will be started in the output.  gzread() is able to read such
355.1331 +   concatented gzip streams.
355.1332 +
355.1333 +     gzflush should be called only when strictly necessary because it will
355.1334 +   degrade compression if called too often.
355.1335 +*/
355.1336 +
355.1337 +/*
355.1338 +ZEXTERN z_off_t ZEXPORT gzseek OF((gzFile file,
355.1339 +                                   z_off_t offset, int whence));
355.1340 +
355.1341 +     Sets the starting position for the next gzread or gzwrite on the given
355.1342 +   compressed file.  The offset represents a number of bytes in the
355.1343 +   uncompressed data stream.  The whence parameter is defined as in lseek(2);
355.1344 +   the value SEEK_END is not supported.
355.1345 +
355.1346 +     If the file is opened for reading, this function is emulated but can be
355.1347 +   extremely slow.  If the file is opened for writing, only forward seeks are
355.1348 +   supported; gzseek then compresses a sequence of zeroes up to the new
355.1349 +   starting position.
355.1350 +
355.1351 +     gzseek returns the resulting offset location as measured in bytes from
355.1352 +   the beginning of the uncompressed stream, or -1 in case of error, in
355.1353 +   particular if the file is opened for writing and the new starting position
355.1354 +   would be before the current position.
355.1355 +*/
355.1356 +
355.1357 +ZEXTERN int ZEXPORT    gzrewind OF((gzFile file));
355.1358 +/*
355.1359 +     Rewinds the given file. This function is supported only for reading.
355.1360 +
355.1361 +     gzrewind(file) is equivalent to (int)gzseek(file, 0L, SEEK_SET)
355.1362 +*/
355.1363 +
355.1364 +/*
355.1365 +ZEXTERN z_off_t ZEXPORT    gztell OF((gzFile file));
355.1366 +
355.1367 +     Returns the starting position for the next gzread or gzwrite on the given
355.1368 +   compressed file.  This position represents a number of bytes in the
355.1369 +   uncompressed data stream, and is zero when starting, even if appending or
355.1370 +   reading a gzip stream from the middle of a file using gzdopen().
355.1371 +
355.1372 +     gztell(file) is equivalent to gzseek(file, 0L, SEEK_CUR)
355.1373 +*/
355.1374 +
355.1375 +/*
355.1376 +ZEXTERN z_off_t ZEXPORT gzoffset OF((gzFile file));
355.1377 +
355.1378 +     Returns the current offset in the file being read or written.  This offset
355.1379 +   includes the count of bytes that precede the gzip stream, for example when
355.1380 +   appending or when using gzdopen() for reading.  When reading, the offset
355.1381 +   does not include as yet unused buffered input.  This information can be used
355.1382 +   for a progress indicator.  On error, gzoffset() returns -1.
355.1383 +*/
355.1384 +
355.1385 +ZEXTERN int ZEXPORT gzeof OF((gzFile file));
355.1386 +/*
355.1387 +     Returns true (1) if the end-of-file indicator has been set while reading,
355.1388 +   false (0) otherwise.  Note that the end-of-file indicator is set only if the
355.1389 +   read tried to go past the end of the input, but came up short.  Therefore,
355.1390 +   just like feof(), gzeof() may return false even if there is no more data to
355.1391 +   read, in the event that the last read request was for the exact number of
355.1392 +   bytes remaining in the input file.  This will happen if the input file size
355.1393 +   is an exact multiple of the buffer size.
355.1394 +
355.1395 +     If gzeof() returns true, then the read functions will return no more data,
355.1396 +   unless the end-of-file indicator is reset by gzclearerr() and the input file
355.1397 +   has grown since the previous end of file was detected.
355.1398 +*/
355.1399 +
355.1400 +ZEXTERN int ZEXPORT gzdirect OF((gzFile file));
355.1401 +/*
355.1402 +     Returns true (1) if file is being copied directly while reading, or false
355.1403 +   (0) if file is a gzip stream being decompressed.  This state can change from
355.1404 +   false to true while reading the input file if the end of a gzip stream is
355.1405 +   reached, but is followed by data that is not another gzip stream.
355.1406 +
355.1407 +     If the input file is empty, gzdirect() will return true, since the input
355.1408 +   does not contain a gzip stream.
355.1409 +
355.1410 +     If gzdirect() is used immediately after gzopen() or gzdopen() it will
355.1411 +   cause buffers to be allocated to allow reading the file to determine if it
355.1412 +   is a gzip file.  Therefore if gzbuffer() is used, it should be called before
355.1413 +   gzdirect().
355.1414 +*/
355.1415 +
355.1416 +ZEXTERN int ZEXPORT    gzclose OF((gzFile file));
355.1417 +/*
355.1418 +     Flushes all pending output if necessary, closes the compressed file and
355.1419 +   deallocates the (de)compression state.  Note that once file is closed, you
355.1420 +   cannot call gzerror with file, since its structures have been deallocated.
355.1421 +   gzclose must not be called more than once on the same file, just as free
355.1422 +   must not be called more than once on the same allocation.
355.1423 +
355.1424 +     gzclose will return Z_STREAM_ERROR if file is not valid, Z_ERRNO on a
355.1425 +   file operation error, or Z_OK on success.
355.1426 +*/
355.1427 +
355.1428 +ZEXTERN int ZEXPORT gzclose_r OF((gzFile file));
355.1429 +ZEXTERN int ZEXPORT gzclose_w OF((gzFile file));
355.1430 +/*
355.1431 +     Same as gzclose(), but gzclose_r() is only for use when reading, and
355.1432 +   gzclose_w() is only for use when writing or appending.  The advantage to
355.1433 +   using these instead of gzclose() is that they avoid linking in zlib
355.1434 +   compression or decompression code that is not used when only reading or only
355.1435 +   writing respectively.  If gzclose() is used, then both compression and
355.1436 +   decompression code will be included the application when linking to a static
355.1437 +   zlib library.
355.1438 +*/
355.1439 +
355.1440 +ZEXTERN const char * ZEXPORT gzerror OF((gzFile file, int *errnum));
355.1441 +/*
355.1442 +     Returns the error message for the last error which occurred on the given
355.1443 +   compressed file.  errnum is set to zlib error number.  If an error occurred
355.1444 +   in the file system and not in the compression library, errnum is set to
355.1445 +   Z_ERRNO and the application may consult errno to get the exact error code.
355.1446 +
355.1447 +     The application must not modify the returned string.  Future calls to
355.1448 +   this function may invalidate the previously returned string.  If file is
355.1449 +   closed, then the string previously returned by gzerror will no longer be
355.1450 +   available.
355.1451 +
355.1452 +     gzerror() should be used to distinguish errors from end-of-file for those
355.1453 +   functions above that do not distinguish those cases in their return values.
355.1454 +*/
355.1455 +
355.1456 +ZEXTERN void ZEXPORT gzclearerr OF((gzFile file));
355.1457 +/*
355.1458 +     Clears the error and end-of-file flags for file.  This is analogous to the
355.1459 +   clearerr() function in stdio.  This is useful for continuing to read a gzip
355.1460 +   file that is being written concurrently.
355.1461 +*/
355.1462 +
355.1463 +
355.1464 +                        /* checksum functions */
355.1465 +
355.1466 +/*
355.1467 +     These functions are not related to compression but are exported
355.1468 +   anyway because they might be useful in applications using the compression
355.1469 +   library.
355.1470 +*/
355.1471 +
355.1472 +ZEXTERN uLong ZEXPORT adler32 OF((uLong adler, const Bytef *buf, uInt len));
355.1473 +/*
355.1474 +     Update a running Adler-32 checksum with the bytes buf[0..len-1] and
355.1475 +   return the updated checksum.  If buf is Z_NULL, this function returns the
355.1476 +   required initial value for the checksum.
355.1477 +
355.1478 +     An Adler-32 checksum is almost as reliable as a CRC32 but can be computed
355.1479 +   much faster.
355.1480 +
355.1481 +   Usage example:
355.1482 +
355.1483 +     uLong adler = adler32(0L, Z_NULL, 0);
355.1484 +
355.1485 +     while (read_buffer(buffer, length) != EOF) {
355.1486 +       adler = adler32(adler, buffer, length);
355.1487 +     }
355.1488 +     if (adler != original_adler) error();
355.1489 +*/
355.1490 +
355.1491 +/*
355.1492 +ZEXTERN uLong ZEXPORT adler32_combine OF((uLong adler1, uLong adler2,
355.1493 +                                          z_off_t len2));
355.1494 +
355.1495 +     Combine two Adler-32 checksums into one.  For two sequences of bytes, seq1
355.1496 +   and seq2 with lengths len1 and len2, Adler-32 checksums were calculated for
355.1497 +   each, adler1 and adler2.  adler32_combine() returns the Adler-32 checksum of
355.1498 +   seq1 and seq2 concatenated, requiring only adler1, adler2, and len2.
355.1499 +*/
355.1500 +
355.1501 +ZEXTERN uLong ZEXPORT crc32   OF((uLong crc, const Bytef *buf, uInt len));
355.1502 +/*
355.1503 +     Update a running CRC-32 with the bytes buf[0..len-1] and return the
355.1504 +   updated CRC-32.  If buf is Z_NULL, this function returns the required
355.1505 +   initial value for the for the crc.  Pre- and post-conditioning (one's
355.1506 +   complement) is performed within this function so it shouldn't be done by the
355.1507 +   application.
355.1508 +
355.1509 +   Usage example:
355.1510 +
355.1511 +     uLong crc = crc32(0L, Z_NULL, 0);
355.1512 +
355.1513 +     while (read_buffer(buffer, length) != EOF) {
355.1514 +       crc = crc32(crc, buffer, length);
355.1515 +     }
355.1516 +     if (crc != original_crc) error();
355.1517 +*/
355.1518 +
355.1519 +/*
355.1520 +ZEXTERN uLong ZEXPORT crc32_combine OF((uLong crc1, uLong crc2, z_off_t len2));
355.1521 +
355.1522 +     Combine two CRC-32 check values into one.  For two sequences of bytes,
355.1523 +   seq1 and seq2 with lengths len1 and len2, CRC-32 check values were
355.1524 +   calculated for each, crc1 and crc2.  crc32_combine() returns the CRC-32
355.1525 +   check value of seq1 and seq2 concatenated, requiring only crc1, crc2, and
355.1526 +   len2.
355.1527 +*/
355.1528 +
355.1529 +
355.1530 +                        /* various hacks, don't look :) */
355.1531 +
355.1532 +/* deflateInit and inflateInit are macros to allow checking the zlib version
355.1533 + * and the compiler's view of z_stream:
355.1534 + */
355.1535 +ZEXTERN int ZEXPORT deflateInit_ OF((z_streamp strm, int level,
355.1536 +                                     const char *version, int stream_size));
355.1537 +ZEXTERN int ZEXPORT inflateInit_ OF((z_streamp strm,
355.1538 +                                     const char *version, int stream_size));
355.1539 +ZEXTERN int ZEXPORT deflateInit2_ OF((z_streamp strm, int  level, int  method,
355.1540 +                                      int windowBits, int memLevel,
355.1541 +                                      int strategy, const char *version,
355.1542 +                                      int stream_size));
355.1543 +ZEXTERN int ZEXPORT inflateInit2_ OF((z_streamp strm, int  windowBits,
355.1544 +                                      const char *version, int stream_size));
355.1545 +ZEXTERN int ZEXPORT inflateBackInit_ OF((z_streamp strm, int windowBits,
355.1546 +                                         unsigned char FAR *window,
355.1547 +                                         const char *version,
355.1548 +                                         int stream_size));
355.1549 +#define deflateInit(strm, level) \
355.1550 +        deflateInit_((strm), (level),       ZLIB_VERSION, sizeof(z_stream))
355.1551 +#define inflateInit(strm) \
355.1552 +        inflateInit_((strm),                ZLIB_VERSION, sizeof(z_stream))
355.1553 +#define deflateInit2(strm, level, method, windowBits, memLevel, strategy) \
355.1554 +        deflateInit2_((strm),(level),(method),(windowBits),(memLevel),\
355.1555 +                      (strategy),           ZLIB_VERSION, sizeof(z_stream))
355.1556 +#define inflateInit2(strm, windowBits) \
355.1557 +        inflateInit2_((strm), (windowBits), ZLIB_VERSION, sizeof(z_stream))
355.1558 +#define inflateBackInit(strm, windowBits, window) \
355.1559 +        inflateBackInit_((strm), (windowBits), (window), \
355.1560 +                                            ZLIB_VERSION, sizeof(z_stream))
355.1561 +
355.1562 +/* provide 64-bit offset functions if _LARGEFILE64_SOURCE defined, and/or
355.1563 + * change the regular functions to 64 bits if _FILE_OFFSET_BITS is 64 (if
355.1564 + * both are true, the application gets the *64 functions, and the regular
355.1565 + * functions are changed to 64 bits) -- in case these are set on systems
355.1566 + * without large file support, _LFS64_LARGEFILE must also be true
355.1567 + */
355.1568 +#if defined(_LARGEFILE64_SOURCE) && _LFS64_LARGEFILE-0
355.1569 +   ZEXTERN gzFile ZEXPORT gzopen64 OF((const char *, const char *));
355.1570 +   ZEXTERN z_off64_t ZEXPORT gzseek64 OF((gzFile, z_off64_t, int));
355.1571 +   ZEXTERN z_off64_t ZEXPORT gztell64 OF((gzFile));
355.1572 +   ZEXTERN z_off64_t ZEXPORT gzoffset64 OF((gzFile));
355.1573 +   ZEXTERN uLong ZEXPORT adler32_combine64 OF((uLong, uLong, z_off64_t));
355.1574 +   ZEXTERN uLong ZEXPORT crc32_combine64 OF((uLong, uLong, z_off64_t));
355.1575 +#endif
355.1576 +
355.1577 +#if !defined(ZLIB_INTERNAL) && _FILE_OFFSET_BITS-0 == 64 && _LFS64_LARGEFILE-0
355.1578 +#  define gzopen gzopen64
355.1579 +#  define gzseek gzseek64
355.1580 +#  define gztell gztell64
355.1581 +#  define gzoffset gzoffset64
355.1582 +#  define adler32_combine adler32_combine64
355.1583 +#  define crc32_combine crc32_combine64
355.1584 +#  ifdef _LARGEFILE64_SOURCE
355.1585 +     ZEXTERN gzFile ZEXPORT gzopen64 OF((const char *, const char *));
355.1586 +     ZEXTERN z_off_t ZEXPORT gzseek64 OF((gzFile, z_off_t, int));
355.1587 +     ZEXTERN z_off_t ZEXPORT gztell64 OF((gzFile));
355.1588 +     ZEXTERN z_off_t ZEXPORT gzoffset64 OF((gzFile));
355.1589 +     ZEXTERN uLong ZEXPORT adler32_combine64 OF((uLong, uLong, z_off_t));
355.1590 +     ZEXTERN uLong ZEXPORT crc32_combine64 OF((uLong, uLong, z_off_t));
355.1591 +#  endif
355.1592 +#else
355.1593 +   ZEXTERN gzFile ZEXPORT gzopen OF((const char *, const char *));
355.1594 +   ZEXTERN z_off_t ZEXPORT gzseek OF((gzFile, z_off_t, int));
355.1595 +   ZEXTERN z_off_t ZEXPORT gztell OF((gzFile));
355.1596 +   ZEXTERN z_off_t ZEXPORT gzoffset OF((gzFile));
355.1597 +   ZEXTERN uLong ZEXPORT adler32_combine OF((uLong, uLong, z_off_t));
355.1598 +   ZEXTERN uLong ZEXPORT crc32_combine OF((uLong, uLong, z_off_t));
355.1599 +#endif
355.1600 +
355.1601 +/* hack for buggy compilers */
355.1602 +#if !defined(ZUTIL_H) && !defined(NO_DUMMY_DECL)
355.1603 +    struct internal_state {int dummy;};
355.1604 +#endif
355.1605 +
355.1606 +/* undocumented functions */
355.1607 +ZEXTERN const char   * ZEXPORT zError           OF((int));
355.1608 +ZEXTERN int            ZEXPORT inflateSyncPoint OF((z_streamp));
355.1609 +ZEXTERN const uLongf * ZEXPORT get_crc_table    OF((void));
355.1610 +ZEXTERN int            ZEXPORT inflateUndermine OF((z_streamp, int));
355.1611 +
355.1612 +#ifdef __cplusplus
355.1613 +}
355.1614 +#endif
355.1615 +
355.1616 +#endif /* ZLIB_H */
   356.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
   356.2 +++ b/deps/glpk/src/zlib/zutil.c	Sun Nov 06 20:59:10 2011 +0100
   356.3 @@ -0,0 +1,318 @@
   356.4 +/* zutil.c -- target dependent utility functions for the compression library
   356.5 + * Copyright (C) 1995-2005, 2010 Jean-loup Gailly.
   356.6 + * For conditions of distribution and use, see copyright notice in zlib.h
   356.7 + */
   356.8 +
   356.9 +/* @(#) $Id$ */
  356.10 +
  356.11 +#include "zutil.h"
  356.12 +
  356.13 +#ifndef NO_DUMMY_DECL
  356.14 +struct internal_state      {int dummy;}; /* for buggy compilers */
  356.15 +#endif
  356.16 +
  356.17 +const char * const z_errmsg[10] = {
  356.18 +"need dictionary",     /* Z_NEED_DICT       2  */
  356.19 +"stream end",          /* Z_STREAM_END      1  */
  356.20 +"",                    /* Z_OK              0  */
  356.21 +"file error",          /* Z_ERRNO         (-1) */
  356.22 +"stream error",        /* Z_STREAM_ERROR  (-2) */
  356.23 +"data error",          /* Z_DATA_ERROR    (-3) */
  356.24 +"insufficient memory", /* Z_MEM_ERROR     (-4) */
  356.25 +"buffer error",        /* Z_BUF_ERROR     (-5) */
  356.26 +"incompatible version",/* Z_VERSION_ERROR (-6) */
  356.27 +""};
  356.28 +
  356.29 +
  356.30 +const char * ZEXPORT zlibVersion()
  356.31 +{
  356.32 +    return ZLIB_VERSION;
  356.33 +}
  356.34 +
  356.35 +uLong ZEXPORT zlibCompileFlags()
  356.36 +{
  356.37 +    uLong flags;
  356.38 +
  356.39 +    flags = 0;
  356.40 +    switch ((int)(sizeof(uInt))) {
  356.41 +    case 2:     break;
  356.42 +    case 4:     flags += 1;     break;
  356.43 +    case 8:     flags += 2;     break;
  356.44 +    default:    flags += 3;
  356.45 +    }
  356.46 +    switch ((int)(sizeof(uLong))) {
  356.47 +    case 2:     break;
  356.48 +    case 4:     flags += 1 << 2;        break;
  356.49 +    case 8:     flags += 2 << 2;        break;
  356.50 +    default:    flags += 3 << 2;
  356.51 +    }
  356.52 +    switch ((int)(sizeof(voidpf))) {
  356.53 +    case 2:     break;
  356.54 +    case 4:     flags += 1 << 4;        break;
  356.55 +    case 8:     flags += 2 << 4;        break;
  356.56 +    default:    flags += 3 << 4;
  356.57 +    }
  356.58 +    switch ((int)(sizeof(z_off_t))) {
  356.59 +    case 2:     break;
  356.60 +    case 4:     flags += 1 << 6;        break;
  356.61 +    case 8:     flags += 2 << 6;        break;
  356.62 +    default:    flags += 3 << 6;
  356.63 +    }
  356.64 +#ifdef DEBUG
  356.65 +    flags += 1 << 8;
  356.66 +#endif
  356.67 +#if defined(ASMV) || defined(ASMINF)
  356.68 +    flags += 1 << 9;
  356.69 +#endif
  356.70 +#ifdef ZLIB_WINAPI
  356.71 +    flags += 1 << 10;
  356.72 +#endif
  356.73 +#ifdef BUILDFIXED
  356.74 +    flags += 1 << 12;
  356.75 +#endif
  356.76 +#ifdef DYNAMIC_CRC_TABLE
  356.77 +    flags += 1 << 13;
  356.78 +#endif
  356.79 +#ifdef NO_GZCOMPRESS
  356.80 +    flags += 1L << 16;
  356.81 +#endif
  356.82 +#ifdef NO_GZIP
  356.83 +    flags += 1L << 17;
  356.84 +#endif
  356.85 +#ifdef PKZIP_BUG_WORKAROUND
  356.86 +    flags += 1L << 20;
  356.87 +#endif
  356.88 +#ifdef FASTEST
  356.89 +    flags += 1L << 21;
  356.90 +#endif
  356.91 +#ifdef STDC
  356.92 +#  ifdef NO_vsnprintf
  356.93 +        flags += 1L << 25;
  356.94 +#    ifdef HAS_vsprintf_void
  356.95 +        flags += 1L << 26;
  356.96 +#    endif
  356.97 +#  else
  356.98 +#    ifdef HAS_vsnprintf_void
  356.99 +        flags += 1L << 26;
 356.100 +#    endif
 356.101 +#  endif
 356.102 +#else
 356.103 +        flags += 1L << 24;
 356.104 +#  ifdef NO_snprintf
 356.105 +        flags += 1L << 25;
 356.106 +#    ifdef HAS_sprintf_void
 356.107 +        flags += 1L << 26;
 356.108 +#    endif
 356.109 +#  else
 356.110 +#    ifdef HAS_snprintf_void
 356.111 +        flags += 1L << 26;
 356.112 +#    endif
 356.113 +#  endif
 356.114 +#endif
 356.115 +    return flags;
 356.116 +}
 356.117 +
 356.118 +#ifdef DEBUG
 356.119 +
 356.120 +#  ifndef verbose
 356.121 +#    define verbose 0
 356.122 +#  endif
 356.123 +int ZLIB_INTERNAL z_verbose = verbose;
 356.124 +
 356.125 +void ZLIB_INTERNAL z_error (m)
 356.126 +    char *m;
 356.127 +{
 356.128 +    fprintf(stderr, "%s\n", m);
 356.129 +    exit(1);
 356.130 +}
 356.131 +#endif
 356.132 +
 356.133 +/* exported to allow conversion of error code to string for compress() and
 356.134 + * uncompress()
 356.135 + */
 356.136 +const char * ZEXPORT zError(err)
 356.137 +    int err;
 356.138 +{
 356.139 +    return ERR_MSG(err);
 356.140 +}
 356.141 +
 356.142 +#if defined(_WIN32_WCE)
 356.143 +    /* The Microsoft C Run-Time Library for Windows CE doesn't have
 356.144 +     * errno.  We define it as a global variable to simplify porting.
 356.145 +     * Its value is always 0 and should not be used.
 356.146 +     */
 356.147 +    int errno = 0;
 356.148 +#endif
 356.149 +
 356.150 +#ifndef HAVE_MEMCPY
 356.151 +
 356.152 +void ZLIB_INTERNAL zmemcpy(dest, source, len)
 356.153 +    Bytef* dest;
 356.154 +    const Bytef* source;
 356.155 +    uInt  len;
 356.156 +{
 356.157 +    if (len == 0) return;
 356.158 +    do {
 356.159 +        *dest++ = *source++; /* ??? to be unrolled */
 356.160 +    } while (--len != 0);
 356.161 +}
 356.162 +
 356.163 +int ZLIB_INTERNAL zmemcmp(s1, s2, len)
 356.164 +    const Bytef* s1;
 356.165 +    const Bytef* s2;
 356.166 +    uInt  len;
 356.167 +{
 356.168 +    uInt j;
 356.169 +
 356.170 +    for (j = 0; j < len; j++) {
 356.171 +        if (s1[j] != s2[j]) return 2*(s1[j] > s2[j])-1;
 356.172 +    }
 356.173 +    return 0;
 356.174 +}
 356.175 +
 356.176 +void ZLIB_INTERNAL zmemzero(dest, len)
 356.177 +    Bytef* dest;
 356.178 +    uInt  len;
 356.179 +{
 356.180 +    if (len == 0) return;
 356.181 +    do {
 356.182 +        *dest++ = 0;  /* ??? to be unrolled */
 356.183 +    } while (--len != 0);
 356.184 +}
 356.185 +#endif
 356.186 +
 356.187 +
 356.188 +#ifdef SYS16BIT
 356.189 +
 356.190 +#ifdef __TURBOC__
 356.191 +/* Turbo C in 16-bit mode */
 356.192 +
 356.193 +#  define MY_ZCALLOC
 356.194 +
 356.195 +/* Turbo C malloc() does not allow dynamic allocation of 64K bytes
 356.196 + * and farmalloc(64K) returns a pointer with an offset of 8, so we
 356.197 + * must fix the pointer. Warning: the pointer must be put back to its
 356.198 + * original form in order to free it, use zcfree().
 356.199 + */
 356.200 +
 356.201 +#define MAX_PTR 10
 356.202 +/* 10*64K = 640K */
 356.203 +
 356.204 +local int next_ptr = 0;
 356.205 +
 356.206 +typedef struct ptr_table_s {
 356.207 +    voidpf org_ptr;
 356.208 +    voidpf new_ptr;
 356.209 +} ptr_table;
 356.210 +
 356.211 +local ptr_table table[MAX_PTR];
 356.212 +/* This table is used to remember the original form of pointers
 356.213 + * to large buffers (64K). Such pointers are normalized with a zero offset.
 356.214 + * Since MSDOS is not a preemptive multitasking OS, this table is not
 356.215 + * protected from concurrent access. This hack doesn't work anyway on
 356.216 + * a protected system like OS/2. Use Microsoft C instead.
 356.217 + */
 356.218 +
 356.219 +voidpf ZLIB_INTERNAL zcalloc (voidpf opaque, unsigned items, unsigned size)
 356.220 +{
 356.221 +    voidpf buf = opaque; /* just to make some compilers happy */
 356.222 +    ulg bsize = (ulg)items*size;
 356.223 +
 356.224 +    /* If we allocate less than 65520 bytes, we assume that farmalloc
 356.225 +     * will return a usable pointer which doesn't have to be normalized.
 356.226 +     */
 356.227 +    if (bsize < 65520L) {
 356.228 +        buf = farmalloc(bsize);
 356.229 +        if (*(ush*)&buf != 0) return buf;
 356.230 +    } else {
 356.231 +        buf = farmalloc(bsize + 16L);
 356.232 +    }
 356.233 +    if (buf == NULL || next_ptr >= MAX_PTR) return NULL;
 356.234 +    table[next_ptr].org_ptr = buf;
 356.235 +
 356.236 +    /* Normalize the pointer to seg:0 */
 356.237 +    *((ush*)&buf+1) += ((ush)((uch*)buf-0) + 15) >> 4;
 356.238 +    *(ush*)&buf = 0;
 356.239 +    table[next_ptr++].new_ptr = buf;
 356.240 +    return buf;
 356.241 +}
 356.242 +
 356.243 +void ZLIB_INTERNAL zcfree (voidpf opaque, voidpf ptr)
 356.244 +{
 356.245 +    int n;
 356.246 +    if (*(ush*)&ptr != 0) { /* object < 64K */
 356.247 +        farfree(ptr);
 356.248 +        return;
 356.249 +    }
 356.250 +    /* Find the original pointer */
 356.251 +    for (n = 0; n < next_ptr; n++) {
 356.252 +        if (ptr != table[n].new_ptr) continue;
 356.253 +
 356.254 +        farfree(table[n].org_ptr);
 356.255 +        while (++n < next_ptr) {
 356.256 +            table[n-1] = table[n];
 356.257 +        }
 356.258 +        next_ptr--;
 356.259 +        return;
 356.260 +    }
 356.261 +    ptr = opaque; /* just to make some compilers happy */
 356.262 +    Assert(0, "zcfree: ptr not found");
 356.263 +}
 356.264 +
 356.265 +#endif /* __TURBOC__ */
 356.266 +
 356.267 +
 356.268 +#ifdef M_I86
 356.269 +/* Microsoft C in 16-bit mode */
 356.270 +
 356.271 +#  define MY_ZCALLOC
 356.272 +
 356.273 +#if (!defined(_MSC_VER) || (_MSC_VER <= 600))
 356.274 +#  define _halloc  halloc
 356.275 +#  define _hfree   hfree
 356.276 +#endif
 356.277 +
 356.278 +voidpf ZLIB_INTERNAL zcalloc (voidpf opaque, uInt items, uInt size)
 356.279 +{
 356.280 +    if (opaque) opaque = 0; /* to make compiler happy */
 356.281 +    return _halloc((long)items, size);
 356.282 +}
 356.283 +
 356.284 +void ZLIB_INTERNAL zcfree (voidpf opaque, voidpf ptr)
 356.285 +{
 356.286 +    if (opaque) opaque = 0; /* to make compiler happy */
 356.287 +    _hfree(ptr);
 356.288 +}
 356.289 +
 356.290 +#endif /* M_I86 */
 356.291 +
 356.292 +#endif /* SYS16BIT */
 356.293 +
 356.294 +
 356.295 +#ifndef MY_ZCALLOC /* Any system without a special alloc function */
 356.296 +
 356.297 +#ifndef STDC
 356.298 +extern voidp  malloc OF((uInt size));
 356.299 +extern voidp  calloc OF((uInt items, uInt size));
 356.300 +extern void   free   OF((voidpf ptr));
 356.301 +#endif
 356.302 +
 356.303 +voidpf ZLIB_INTERNAL zcalloc (opaque, items, size)
 356.304 +    voidpf opaque;
 356.305 +    unsigned items;
 356.306 +    unsigned size;
 356.307 +{
 356.308 +    if (opaque) items += size - size; /* make compiler happy */
 356.309 +    return sizeof(uInt) > 2 ? (voidpf)malloc(items * size) :
 356.310 +                              (voidpf)calloc(items, size);
 356.311 +}
 356.312 +
 356.313 +void ZLIB_INTERNAL zcfree (opaque, ptr)
 356.314 +    voidpf opaque;
 356.315 +    voidpf ptr;
 356.316 +{
 356.317 +    free(ptr);
 356.318 +    if (opaque) return; /* make compiler happy */
 356.319 +}
 356.320 +
 356.321 +#endif /* MY_ZCALLOC */
   357.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
   357.2 +++ b/deps/glpk/src/zlib/zutil.h	Sun Nov 06 20:59:10 2011 +0100
   357.3 @@ -0,0 +1,93 @@
   357.4 +/* zutil.h (internal interface of the zlib compression library) */
   357.5 +
   357.6 +/* Modified by Andrew Makhorin <mao@gnu.org>, April 2011 */
   357.7 +
   357.8 +/* Copyright (C) 1995-2010 Jean-loup Gailly
   357.9 + * For conditions of distribution and use, see copyright notice in
  357.10 + * zlib.h */
  357.11 +
  357.12 +/* WARNING: this file should *not* be used by applications. It is
  357.13 +   part of the implementation of the compression library and is
  357.14 +   subject to change. Applications should only use zlib.h. */
  357.15 +
  357.16 +#ifndef ZUTIL_H
  357.17 +#define ZUTIL_H
  357.18 +
  357.19 +#define ZLIB_INTERNAL
  357.20 +
  357.21 +#include "zlib.h"
  357.22 +
  357.23 +#include <stddef.h>
  357.24 +#include <string.h>
  357.25 +#include <stdlib.h>
  357.26 +
  357.27 +#define local static
  357.28 +
  357.29 +typedef unsigned char uch;
  357.30 +typedef uch uchf;
  357.31 +typedef unsigned short ush;
  357.32 +typedef ush ushf;
  357.33 +typedef unsigned long ulg;
  357.34 +
  357.35 +extern const char * const z_errmsg[10];
  357.36 +
  357.37 +#define ERR_MSG(err) z_errmsg[Z_NEED_DICT-(err)]
  357.38 +
  357.39 +#define ERR_RETURN(strm, err) \
  357.40 +      return (strm->msg = (char *)ERR_MSG(err), (err))
  357.41 +
  357.42 +#define DEF_WBITS MAX_WBITS
  357.43 +
  357.44 +#if MAX_MEM_LEVEL >= 8
  357.45 +#define DEF_MEM_LEVEL 8
  357.46 +#else
  357.47 +#define DEF_MEM_LEVEL MAX_MEM_LEVEL
  357.48 +#endif
  357.49 +
  357.50 +#define STORED_BLOCK 0
  357.51 +#define STATIC_TREES 1
  357.52 +#define DYN_TREES    2
  357.53 +
  357.54 +#define MIN_MATCH 3
  357.55 +#define MAX_MATCH 258
  357.56 +
  357.57 +#define PRESET_DICT 0x20
  357.58 +
  357.59 +#define OS_CODE 0x03 /* assume Unix */
  357.60 +
  357.61 +#define HAVE_MEMCPY 1
  357.62 +#define zmemcpy memcpy
  357.63 +#define zmemzero(dest, len) memset(dest, 0, len)
  357.64 +
  357.65 +#ifdef DEBUG
  357.66 +#include <stdio.h>
  357.67 +extern int ZLIB_INTERNAL z_verbose;
  357.68 +extern void ZLIB_INTERNAL z_error OF((char *m));
  357.69 +#define Assert(cond, msg) { if(!(cond)) z_error(msg); }
  357.70 +#define Trace(x) { if (z_verbose >= 0) fprintf x; }
  357.71 +#define Tracev(x) { if (z_verbose > 0) fprintf x; }
  357.72 +#define Tracevv(x) {if (z_verbose > 1) fprintf x; }
  357.73 +#define Tracec(c, x) {if (z_verbose > 0 && (c)) fprintf x; }
  357.74 +#define Tracecv(c, x) {if (z_verbose > 1 && (c)) fprintf x; }
  357.75 +#else
  357.76 +#define Assert(cond, msg)
  357.77 +#define Trace(x)
  357.78 +#define Tracev(x)
  357.79 +#define Tracevv(x)
  357.80 +#define Tracec(c, x)
  357.81 +#define Tracecv(c, x)
  357.82 +#endif
  357.83 +
  357.84 +voidpf ZLIB_INTERNAL zcalloc OF((voidpf opaque, unsigned items,
  357.85 +      unsigned size));
  357.86 +void ZLIB_INTERNAL zcfree OF((voidpf opaque, voidpf ptr));
  357.87 +
  357.88 +#define ZALLOC(strm, items, size) \
  357.89 +      (*((strm)->zalloc))((strm)->opaque, (items), (size))
  357.90 +#define ZFREE(strm, addr) \
  357.91 +      (*((strm)->zfree))((strm)->opaque, (voidpf)(addr))
  357.92 +#define TRY_FREE(s, p) { if (p) ZFREE(s, p); }
  357.93 +
  357.94 +#endif
  357.95 +
  357.96 +/* eof */
   358.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
   358.2 +++ b/deps/glpk/w32/Build_GLPK_with_VC10.bat	Sun Nov 06 20:59:10 2011 +0100
   358.3 @@ -0,0 +1,11 @@
   358.4 +rem Build GLPK with Microsoft Visual Studio Express 2010
   358.5 +
   358.6 +rem NOTE: Make sure that HOME variable specifies correct path
   358.7 +set HOME="C:\Program Files\Microsoft Visual Studio 10.0\VC"
   358.8 +
   358.9 +call %HOME%\vcvarsall.bat x86
  358.10 +copy config_VC config.h
  358.11 +%HOME%\bin\nmake.exe /f Makefile_VC
  358.12 +%HOME%\bin\nmake.exe /f Makefile_VC check
  358.13 +
  358.14 +pause
   359.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
   359.2 +++ b/deps/glpk/w32/Build_GLPK_with_VC10_DLL.bat	Sun Nov 06 20:59:10 2011 +0100
   359.3 @@ -0,0 +1,11 @@
   359.4 +rem Build GLPK DLL with Microsoft Visual Studio Express 2010
   359.5 +
   359.6 +rem NOTE: Make sure that HOME variable specifies correct path
   359.7 +set HOME="C:\Program Files\Microsoft Visual Studio 10.0\VC"
   359.8 +
   359.9 +call %HOME%\vcvarsall.bat x86
  359.10 +copy config_VC config.h
  359.11 +%HOME%\bin\nmake.exe /f Makefile_VC_DLL
  359.12 +%HOME%\bin\nmake.exe /f Makefile_VC_DLL check
  359.13 +
  359.14 +pause
   360.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
   360.2 +++ b/deps/glpk/w32/Build_GLPK_with_VC9.bat	Sun Nov 06 20:59:10 2011 +0100
   360.3 @@ -0,0 +1,11 @@
   360.4 +rem Build GLPK with Microsoft Visual Studio Express 2008
   360.5 +
   360.6 +rem NOTE: Make sure that HOME variable specifies correct path
   360.7 +set HOME="C:\Program Files\Microsoft Visual Studio 9.0\VC"
   360.8 +
   360.9 +call %HOME%\bin\vcvars32.bat
  360.10 +copy config_VC config.h
  360.11 +%HOME%\bin\nmake.exe /f Makefile_VC
  360.12 +%HOME%\bin\nmake.exe /f Makefile_VC check
  360.13 +
  360.14 +pause
   361.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
   361.2 +++ b/deps/glpk/w32/Build_GLPK_with_VC9_DLL.bat	Sun Nov 06 20:59:10 2011 +0100
   361.3 @@ -0,0 +1,11 @@
   361.4 +rem Build GLPK DLL with Microsoft Visual Studio Express 2008
   361.5 +
   361.6 +rem NOTE: Make sure that HOME variable specifies correct path
   361.7 +set HOME="C:\Program Files\Microsoft Visual Studio 9.0\VC"
   361.8 +
   361.9 +call %HOME%\bin\vcvars32.bat
  361.10 +copy config_VC config.h
  361.11 +%HOME%\bin\nmake.exe /f Makefile_VC_DLL
  361.12 +%HOME%\bin\nmake.exe /f Makefile_VC_DLL check
  361.13 +
  361.14 +pause
   362.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
   362.2 +++ b/deps/glpk/w32/Makefile_VC	Sun Nov 06 20:59:10 2011 +0100
   362.3 @@ -0,0 +1,168 @@
   362.4 +## Build GLPK with Microsoft Visual Studio Express ##
   362.5 +
   362.6 +CFLAGS = \
   362.7 +/I. \
   362.8 +/I..\src \
   362.9 +/I..\src\amd \
  362.10 +/I..\src\colamd \
  362.11 +/I..\src\minisat \
  362.12 +/I..\src\zlib \
  362.13 +/DHAVE_CONFIG_H=1 \
  362.14 +/D_CRT_SECURE_NO_WARNINGS=1 \
  362.15 +/nologo \
  362.16 +/W3 \
  362.17 +/O2
  362.18 +
  362.19 +OBJSET = \
  362.20 +..\src\glpapi01.obj \
  362.21 +..\src\glpapi02.obj \
  362.22 +..\src\glpapi03.obj \
  362.23 +..\src\glpapi04.obj \
  362.24 +..\src\glpapi05.obj \
  362.25 +..\src\glpapi06.obj \
  362.26 +..\src\glpapi07.obj \
  362.27 +..\src\glpapi08.obj \
  362.28 +..\src\glpapi09.obj \
  362.29 +..\src\glpapi10.obj \
  362.30 +..\src\glpapi11.obj \
  362.31 +..\src\glpapi12.obj \
  362.32 +..\src\glpapi13.obj \
  362.33 +..\src\glpapi14.obj \
  362.34 +..\src\glpapi15.obj \
  362.35 +..\src\glpapi16.obj \
  362.36 +..\src\glpapi17.obj \
  362.37 +..\src\glpapi18.obj \
  362.38 +..\src\glpapi19.obj \
  362.39 +..\src\glpapi20.obj \
  362.40 +..\src\glpapi21.obj \
  362.41 +..\src\glpavl.obj \
  362.42 +..\src\glpbfd.obj \
  362.43 +..\src\glpbfx.obj \
  362.44 +..\src\glpcpx.obj \
  362.45 +..\src\glpdmp.obj \
  362.46 +..\src\glpdmx.obj \
  362.47 +..\src\glpenv01.obj \
  362.48 +..\src\glpenv02.obj \
  362.49 +..\src\glpenv03.obj \
  362.50 +..\src\glpenv04.obj \
  362.51 +..\src\glpenv05.obj \
  362.52 +..\src\glpenv06.obj \
  362.53 +..\src\glpenv07.obj \
  362.54 +..\src\glpenv08.obj \
  362.55 +..\src\glpfhv.obj \
  362.56 +..\src\glpgmp.obj \
  362.57 +..\src\glphbm.obj \
  362.58 +..\src\glpini01.obj \
  362.59 +..\src\glpini02.obj \
  362.60 +..\src\glpios01.obj \
  362.61 +..\src\glpios02.obj \
  362.62 +..\src\glpios03.obj \
  362.63 +..\src\glpios04.obj \
  362.64 +..\src\glpios05.obj \
  362.65 +..\src\glpios06.obj \
  362.66 +..\src\glpios07.obj \
  362.67 +..\src\glpios08.obj \
  362.68 +..\src\glpios09.obj \
  362.69 +..\src\glpios10.obj \
  362.70 +..\src\glpios11.obj \
  362.71 +..\src\glpios12.obj \
  362.72 +..\src\glpipm.obj \
  362.73 +..\src\glplib01.obj \
  362.74 +..\src\glplib02.obj \
  362.75 +..\src\glplib03.obj \
  362.76 +..\src\glplpf.obj \
  362.77 +..\src\glplpx01.obj \
  362.78 +..\src\glplpx02.obj \
  362.79 +..\src\glplpx03.obj \
  362.80 +..\src\glpluf.obj \
  362.81 +..\src\glplux.obj \
  362.82 +..\src\glpmat.obj \
  362.83 +..\src\glpmpl01.obj \
  362.84 +..\src\glpmpl02.obj \
  362.85 +..\src\glpmpl03.obj \
  362.86 +..\src\glpmpl04.obj \
  362.87 +..\src\glpmpl05.obj \
  362.88 +..\src\glpmpl06.obj \
  362.89 +..\src\glpmps.obj \
  362.90 +..\src\glpnet01.obj \
  362.91 +..\src\glpnet02.obj \
  362.92 +..\src\glpnet03.obj \
  362.93 +..\src\glpnet04.obj \
  362.94 +..\src\glpnet05.obj \
  362.95 +..\src\glpnet06.obj \
  362.96 +..\src\glpnet07.obj \
  362.97 +..\src\glpnet08.obj \
  362.98 +..\src\glpnet09.obj \
  362.99 +..\src\glpnpp01.obj \
 362.100 +..\src\glpnpp02.obj \
 362.101 +..\src\glpnpp03.obj \
 362.102 +..\src\glpnpp04.obj \
 362.103 +..\src\glpnpp05.obj \
 362.104 +..\src\glpnpp06.obj \
 362.105 +..\src\glpqmd.obj \
 362.106 +..\src\glprgr.obj \
 362.107 +..\src\glprng01.obj \
 362.108 +..\src\glprng02.obj \
 362.109 +..\src\glpscf.obj \
 362.110 +..\src\glpscl.obj \
 362.111 +..\src\glpsdf.obj \
 362.112 +..\src\glpspm.obj \
 362.113 +..\src\glpspx01.obj \
 362.114 +..\src\glpspx02.obj \
 362.115 +..\src\glpsql.obj \
 362.116 +..\src\glpssx01.obj \
 362.117 +..\src\glpssx02.obj \
 362.118 +..\src\glptsp.obj \
 362.119 +..\src\amd\amd_1.obj \
 362.120 +..\src\amd\amd_2.obj \
 362.121 +..\src\amd\amd_aat.obj \
 362.122 +..\src\amd\amd_control.obj \
 362.123 +..\src\amd\amd_defaults.obj \
 362.124 +..\src\amd\amd_dump.obj \
 362.125 +..\src\amd\amd_info.obj \
 362.126 +..\src\amd\amd_order.obj \
 362.127 +..\src\amd\amd_post_tree.obj \
 362.128 +..\src\amd\amd_postorder.obj \
 362.129 +..\src\amd\amd_preprocess.obj \
 362.130 +..\src\amd\amd_valid.obj \
 362.131 +..\src\colamd\colamd.obj \
 362.132 +..\src\minisat\minisat.obj \
 362.133 +..\src\zlib\adler32.obj \
 362.134 +..\src\zlib\compress.obj \
 362.135 +..\src\zlib\crc32.obj \
 362.136 +..\src\zlib\deflate.obj \
 362.137 +..\src\zlib\gzclose.obj \
 362.138 +..\src\zlib\gzlib.obj \
 362.139 +..\src\zlib\gzread.obj \
 362.140 +..\src\zlib\gzwrite.obj \
 362.141 +..\src\zlib\infback.obj \
 362.142 +..\src\zlib\inffast.obj \
 362.143 +..\src\zlib\inflate.obj \
 362.144 +..\src\zlib\inftrees.obj \
 362.145 +..\src\zlib\trees.obj \
 362.146 +..\src\zlib\uncompr.obj \
 362.147 +..\src\zlib\zio.obj \
 362.148 +..\src\zlib\zutil.obj
 362.149 +
 362.150 +.c.obj:
 362.151 +        cl.exe $(CFLAGS) /Fo$*.obj /c $*.c
 362.152 +
 362.153 +all: glpk.lib glpsol.exe
 362.154 +
 362.155 +glpk.lib: $(OBJSET)
 362.156 +        lib.exe /out:glpk.lib \
 362.157 +                ..\src\*.obj \
 362.158 +                ..\src\amd\*.obj \
 362.159 +                ..\src\colamd\*.obj \
 362.160 +                ..\src\minisat\*.obj \
 362.161 +                ..\src\zlib\*.obj
 362.162 +
 362.163 +glpsol.exe: ..\examples\glpsol.obj glpk.lib
 362.164 +        cl.exe $(CFLAGS) /Feglpsol.exe \
 362.165 +                ..\examples\glpsol.obj glpk.lib
 362.166 +
 362.167 +check: glpsol.exe
 362.168 +        .\glpsol.exe --version
 362.169 +        .\glpsol.exe --mps ..\examples\plan.mps
 362.170 +
 362.171 +## eof ##
   363.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
   363.2 +++ b/deps/glpk/w32/Makefile_VC_DLL	Sun Nov 06 20:59:10 2011 +0100
   363.3 @@ -0,0 +1,169 @@
   363.4 +## Build GLPK DLL with Microsoft Visual Studio Express ##
   363.5 +
   363.6 +CFLAGS = \
   363.7 +/I. \
   363.8 +/I..\src \
   363.9 +/I..\src\amd \
  363.10 +/I..\src\colamd \
  363.11 +/I..\src\minisat \
  363.12 +/I..\src\zlib \
  363.13 +/DHAVE_CONFIG_H=1 \
  363.14 +/D_CRT_SECURE_NO_WARNINGS=1 \
  363.15 +/nologo \
  363.16 +/W3 \
  363.17 +/O2
  363.18 +
  363.19 +OBJSET = \
  363.20 +..\src\glpapi01.obj \
  363.21 +..\src\glpapi02.obj \
  363.22 +..\src\glpapi03.obj \
  363.23 +..\src\glpapi04.obj \
  363.24 +..\src\glpapi05.obj \
  363.25 +..\src\glpapi06.obj \
  363.26 +..\src\glpapi07.obj \
  363.27 +..\src\glpapi08.obj \
  363.28 +..\src\glpapi09.obj \
  363.29 +..\src\glpapi10.obj \
  363.30 +..\src\glpapi11.obj \
  363.31 +..\src\glpapi12.obj \
  363.32 +..\src\glpapi13.obj \
  363.33 +..\src\glpapi14.obj \
  363.34 +..\src\glpapi15.obj \
  363.35 +..\src\glpapi16.obj \
  363.36 +..\src\glpapi17.obj \
  363.37 +..\src\glpapi18.obj \
  363.38 +..\src\glpapi19.obj \
  363.39 +..\src\glpapi20.obj \
  363.40 +..\src\glpapi21.obj \
  363.41 +..\src\glpavl.obj \
  363.42 +..\src\glpbfd.obj \
  363.43 +..\src\glpbfx.obj \
  363.44 +..\src\glpcpx.obj \
  363.45 +..\src\glpdmp.obj \
  363.46 +..\src\glpdmx.obj \
  363.47 +..\src\glpenv01.obj \
  363.48 +..\src\glpenv02.obj \
  363.49 +..\src\glpenv03.obj \
  363.50 +..\src\glpenv04.obj \
  363.51 +..\src\glpenv05.obj \
  363.52 +..\src\glpenv06.obj \
  363.53 +..\src\glpenv07.obj \
  363.54 +..\src\glpenv08.obj \
  363.55 +..\src\glpfhv.obj \
  363.56 +..\src\glpgmp.obj \
  363.57 +..\src\glphbm.obj \
  363.58 +..\src\glpini01.obj \
  363.59 +..\src\glpini02.obj \
  363.60 +..\src\glpios01.obj \
  363.61 +..\src\glpios02.obj \
  363.62 +..\src\glpios03.obj \
  363.63 +..\src\glpios04.obj \
  363.64 +..\src\glpios05.obj \
  363.65 +..\src\glpios06.obj \
  363.66 +..\src\glpios07.obj \
  363.67 +..\src\glpios08.obj \
  363.68 +..\src\glpios09.obj \
  363.69 +..\src\glpios10.obj \
  363.70 +..\src\glpios11.obj \
  363.71 +..\src\glpios12.obj \
  363.72 +..\src\glpipm.obj \
  363.73 +..\src\glplib01.obj \
  363.74 +..\src\glplib02.obj \
  363.75 +..\src\glplib03.obj \
  363.76 +..\src\glplpf.obj \
  363.77 +..\src\glplpx01.obj \
  363.78 +..\src\glplpx02.obj \
  363.79 +..\src\glplpx03.obj \
  363.80 +..\src\glpluf.obj \
  363.81 +..\src\glplux.obj \
  363.82 +..\src\glpmat.obj \
  363.83 +..\src\glpmpl01.obj \
  363.84 +..\src\glpmpl02.obj \
  363.85 +..\src\glpmpl03.obj \
  363.86 +..\src\glpmpl04.obj \
  363.87 +..\src\glpmpl05.obj \
  363.88 +..\src\glpmpl06.obj \
  363.89 +..\src\glpmps.obj \
  363.90 +..\src\glpnet01.obj \
  363.91 +..\src\glpnet02.obj \
  363.92 +..\src\glpnet03.obj \
  363.93 +..\src\glpnet04.obj \
  363.94 +..\src\glpnet05.obj \
  363.95 +..\src\glpnet06.obj \
  363.96 +..\src\glpnet07.obj \
  363.97 +..\src\glpnet08.obj \
  363.98 +..\src\glpnet09.obj \
  363.99 +..\src\glpnpp01.obj \
 363.100 +..\src\glpnpp02.obj \
 363.101 +..\src\glpnpp03.obj \
 363.102 +..\src\glpnpp04.obj \
 363.103 +..\src\glpnpp05.obj \
 363.104 +..\src\glpnpp06.obj \
 363.105 +..\src\glpqmd.obj \
 363.106 +..\src\glprgr.obj \
 363.107 +..\src\glprng01.obj \
 363.108 +..\src\glprng02.obj \
 363.109 +..\src\glpscf.obj \
 363.110 +..\src\glpscl.obj \
 363.111 +..\src\glpsdf.obj \
 363.112 +..\src\glpspm.obj \
 363.113 +..\src\glpspx01.obj \
 363.114 +..\src\glpspx02.obj \
 363.115 +..\src\glpsql.obj \
 363.116 +..\src\glpssx01.obj \
 363.117 +..\src\glpssx02.obj \
 363.118 +..\src\glptsp.obj \
 363.119 +..\src\amd\amd_1.obj \
 363.120 +..\src\amd\amd_2.obj \
 363.121 +..\src\amd\amd_aat.obj \
 363.122 +..\src\amd\amd_control.obj \
 363.123 +..\src\amd\amd_defaults.obj \
 363.124 +..\src\amd\amd_dump.obj \
 363.125 +..\src\amd\amd_info.obj \
 363.126 +..\src\amd\amd_order.obj \
 363.127 +..\src\amd\amd_post_tree.obj \
 363.128 +..\src\amd\amd_postorder.obj \
 363.129 +..\src\amd\amd_preprocess.obj \
 363.130 +..\src\amd\amd_valid.obj \
 363.131 +..\src\colamd\colamd.obj \
 363.132 +..\src\minisat\minisat.obj \
 363.133 +..\src\zlib\adler32.obj \
 363.134 +..\src\zlib\compress.obj \
 363.135 +..\src\zlib\crc32.obj \
 363.136 +..\src\zlib\deflate.obj \
 363.137 +..\src\zlib\gzclose.obj \
 363.138 +..\src\zlib\gzlib.obj \
 363.139 +..\src\zlib\gzread.obj \
 363.140 +..\src\zlib\gzwrite.obj \
 363.141 +..\src\zlib\infback.obj \
 363.142 +..\src\zlib\inffast.obj \
 363.143 +..\src\zlib\inflate.obj \
 363.144 +..\src\zlib\inftrees.obj \
 363.145 +..\src\zlib\trees.obj \
 363.146 +..\src\zlib\uncompr.obj \
 363.147 +..\src\zlib\zio.obj \
 363.148 +..\src\zlib\zutil.obj
 363.149 +
 363.150 +.c.obj:
 363.151 +        cl.exe $(CFLAGS) /Fo$*.obj /c $*.c
 363.152 +
 363.153 +all: glpk_4_47.dll glpsol.exe
 363.154 +
 363.155 +glpk_4_47.dll: $(OBJSET)
 363.156 +        cl.exe $(CFLAGS) /LD /Feglpk_4_47.dll \
 363.157 +                ..\src\*.obj \
 363.158 +                ..\src\amd\*.obj \
 363.159 +                ..\src\colamd\*.obj \
 363.160 +                ..\src\minisat\*.obj \
 363.161 +                ..\src\zlib\*.obj \
 363.162 +                glpk_4_47.def
 363.163 +
 363.164 +glpsol.exe: ..\examples\glpsol.obj glpk_4_47.dll
 363.165 +        cl.exe $(CFLAGS) /Feglpsol.exe \
 363.166 +                ..\examples\glpsol.obj glpk_4_47.lib
 363.167 +
 363.168 +check: glpsol.exe
 363.169 +        .\glpsol.exe --version
 363.170 +        .\glpsol.exe --mps ..\examples\plan.mps
 363.171 +
 363.172 +## eof ##
   364.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
   364.2 +++ b/deps/glpk/w32/config_VC	Sun Nov 06 20:59:10 2011 +0100
   364.3 @@ -0,0 +1,13 @@
   364.4 +/* GLPK configuration file (Microsoft Visual Studio Express) */
   364.5 +
   364.6 +#define __WOE__ 1
   364.7 +
   364.8 +#define ODBC_DLNAME "odbc32.dll"
   364.9 +/* ODBC shared library name if this feature is enabled */
  364.10 +
  364.11 +#if 0
  364.12 +#define MYSQL_DLNAME "libmysql.dll"
  364.13 +/* MySQL shared library name if this feature is enabled */
  364.14 +#endif
  364.15 +
  364.16 +/* eof */
   365.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
   365.2 +++ b/deps/glpk/w32/glpk_4_47.def	Sun Nov 06 20:59:10 2011 +0100
   365.3 @@ -0,0 +1,1210 @@
   365.4 +LIBRARY glpk_4_47
   365.5 +VERSION 4.47
   365.6 +DESCRIPTION "GNU Linear Programming Kit"
   365.7 +EXPORTS
   365.8 +;; from adler32 ;;
   365.9 + _glp_zlib_adler32
  365.10 + _glp_zlib_adler32_combine
  365.11 + _glp_zlib_adler32_combine64
  365.12 +;; from amd_1 ;;
  365.13 + _glp_amd_1
  365.14 +;; from amd_2 ;;
  365.15 + _glp_amd_2
  365.16 +;; from amd_aat ;;
  365.17 + _glp_amd_aat
  365.18 +;; from amd_control ;;
  365.19 + _glp_amd_control
  365.20 +;; from amd_defaults ;;
  365.21 + _glp_amd_defaults
  365.22 +;; from amd_dump ;;
  365.23 +;; from amd_info ;;
  365.24 + _glp_amd_info
  365.25 +;; from amd_order ;;
  365.26 + _glp_amd_order
  365.27 +;; from amd_post_tree ;;
  365.28 + _glp_amd_post_tree
  365.29 +;; from amd_postorder ;;
  365.30 + _glp_amd_postorder
  365.31 +;; from amd_preprocess ;;
  365.32 + _glp_amd_preprocess
  365.33 +;; from amd_valid ;;
  365.34 + _glp_amd_valid
  365.35 +;; from colamd ;;
  365.36 + _glp_colamd
  365.37 + _glp_colamd_recommended
  365.38 + _glp_colamd_report
  365.39 + _glp_colamd_set_defaults
  365.40 + _glp_symamd
  365.41 + _glp_symamd_report
  365.42 +;; from compress ;;
  365.43 + _glp_zlib_compress
  365.44 + _glp_zlib_compress2
  365.45 + _glp_zlib_compressBound
  365.46 +;; from crc32 ;;
  365.47 + _glp_zlib_crc32
  365.48 + _glp_zlib_crc32_combine
  365.49 + _glp_zlib_crc32_combine64
  365.50 + _glp_zlib_get_crc_table
  365.51 +;; from deflate ;;
  365.52 + _glp_zlib_deflate
  365.53 + _glp_zlib_deflateBound
  365.54 + _glp_zlib_deflateCopy
  365.55 + _glp_zlib_deflateEnd
  365.56 + _glp_zlib_deflateInit2_
  365.57 + _glp_zlib_deflateInit_
  365.58 + _glp_zlib_deflateParams
  365.59 + _glp_zlib_deflatePrime
  365.60 + _glp_zlib_deflateReset
  365.61 + _glp_zlib_deflateSetDictionary
  365.62 + _glp_zlib_deflateSetHeader
  365.63 + _glp_zlib_deflateTune
  365.64 + _glp_zlib_deflate_copyright
  365.65 +;; from glpapi01 ;;
  365.66 + glp_add_cols
  365.67 + glp_add_rows
  365.68 + glp_check_dup
  365.69 + glp_copy_prob
  365.70 + glp_create_prob
  365.71 + glp_del_cols
  365.72 + glp_del_rows
  365.73 + glp_delete_prob
  365.74 + glp_erase_prob
  365.75 + glp_load_matrix
  365.76 + glp_set_col_bnds
  365.77 + glp_set_col_name
  365.78 + glp_set_mat_col
  365.79 + glp_set_mat_row
  365.80 + glp_set_obj_coef
  365.81 + glp_set_obj_dir
  365.82 + glp_set_obj_name
  365.83 + glp_set_prob_name
  365.84 + glp_set_row_bnds
  365.85 + glp_set_row_name
  365.86 + glp_sort_matrix
  365.87 +;; from glpapi02 ;;
  365.88 + glp_get_col_lb
  365.89 + glp_get_col_name
  365.90 + glp_get_col_type
  365.91 + glp_get_col_ub
  365.92 + glp_get_mat_col
  365.93 + glp_get_mat_row
  365.94 + glp_get_num_cols
  365.95 + glp_get_num_nz
  365.96 + glp_get_num_rows
  365.97 + glp_get_obj_coef
  365.98 + glp_get_obj_dir
  365.99 + glp_get_obj_name
 365.100 + glp_get_prob_name
 365.101 + glp_get_row_lb
 365.102 + glp_get_row_name
 365.103 + glp_get_row_type
 365.104 + glp_get_row_ub
 365.105 +;; from glpapi03 ;;
 365.106 + glp_create_index
 365.107 + glp_delete_index
 365.108 + glp_find_col
 365.109 + glp_find_row
 365.110 +;; from glpapi04 ;;
 365.111 + glp_get_rii
 365.112 + glp_get_sjj
 365.113 + glp_set_rii
 365.114 + glp_set_sjj
 365.115 + glp_unscale_prob
 365.116 +;; from glpapi05 ;;
 365.117 + glp_set_col_stat
 365.118 + glp_set_row_stat
 365.119 + glp_std_basis
 365.120 +;; from glpapi06 ;;
 365.121 + glp_get_col_dual
 365.122 + glp_get_col_prim
 365.123 + glp_get_col_stat
 365.124 + glp_get_dual_stat
 365.125 + glp_get_obj_val
 365.126 + glp_get_prim_stat
 365.127 + glp_get_row_dual
 365.128 + glp_get_row_prim
 365.129 + glp_get_row_stat
 365.130 + glp_get_status
 365.131 + glp_get_unbnd_ray
 365.132 + glp_init_smcp
 365.133 + glp_simplex
 365.134 +;; from glpapi07 ;;
 365.135 + glp_exact
 365.136 +;; from glpapi08 ;;
 365.137 + glp_init_iptcp
 365.138 + glp_interior
 365.139 + glp_ipt_col_dual
 365.140 + glp_ipt_col_prim
 365.141 + glp_ipt_obj_val
 365.142 + glp_ipt_row_dual
 365.143 + glp_ipt_row_prim
 365.144 + glp_ipt_status
 365.145 +;; from glpapi09 ;;
 365.146 + _glp_intopt1
 365.147 + glp_get_col_kind
 365.148 + glp_get_num_bin
 365.149 + glp_get_num_int
 365.150 + glp_init_iocp
 365.151 + glp_intopt
 365.152 + glp_mip_col_val
 365.153 + glp_mip_obj_val
 365.154 + glp_mip_row_val
 365.155 + glp_mip_status
 365.156 + glp_set_col_kind
 365.157 +;; from glpapi10 ;;
 365.158 + _glp_check_kkt
 365.159 +;; from glpapi11 ;;
 365.160 + glp_print_ipt
 365.161 + glp_print_mip
 365.162 + glp_print_ranges
 365.163 + glp_print_sol
 365.164 + glp_read_ipt
 365.165 + glp_read_mip
 365.166 + glp_read_sol
 365.167 + glp_write_ipt
 365.168 + glp_write_mip
 365.169 + glp_write_sol
 365.170 +;; from glpapi12 ;;
 365.171 + _glp_analyze_row
 365.172 + glp_analyze_bound
 365.173 + glp_analyze_coef
 365.174 + glp_bf_exists
 365.175 + glp_bf_updated
 365.176 + glp_btran
 365.177 + glp_dual_rtest
 365.178 + glp_eval_tab_col
 365.179 + glp_eval_tab_row
 365.180 + glp_factorize
 365.181 + glp_ftran
 365.182 + glp_get_bfcp
 365.183 + glp_get_bhead
 365.184 + glp_get_col_bind
 365.185 + glp_get_row_bind
 365.186 + glp_prim_rtest
 365.187 + glp_set_bfcp
 365.188 + glp_transform_col
 365.189 + glp_transform_row
 365.190 + glp_warm_up
 365.191 +;; from glpapi13 ;;
 365.192 + glp_ios_add_row
 365.193 + glp_ios_best_node
 365.194 + glp_ios_branch_upon
 365.195 + glp_ios_can_branch
 365.196 + glp_ios_clear_pool
 365.197 + glp_ios_curr_node
 365.198 + glp_ios_del_row
 365.199 + glp_ios_get_prob
 365.200 + glp_ios_heur_sol
 365.201 + glp_ios_mip_gap
 365.202 + glp_ios_next_node
 365.203 + glp_ios_node_bound
 365.204 + glp_ios_node_data
 365.205 + glp_ios_node_level
 365.206 + glp_ios_pool_size
 365.207 + glp_ios_prev_node
 365.208 + glp_ios_reason
 365.209 + glp_ios_row_attr
 365.210 + glp_ios_select_node
 365.211 + glp_ios_terminate
 365.212 + glp_ios_tree_size
 365.213 + glp_ios_up_node
 365.214 +;; from glpapi14 ;;
 365.215 + _glp_mpl_init_rand
 365.216 + glp_mpl_alloc_wksp
 365.217 + glp_mpl_build_prob
 365.218 + glp_mpl_free_wksp
 365.219 + glp_mpl_generate
 365.220 + glp_mpl_postsolve
 365.221 + glp_mpl_read_data
 365.222 + glp_mpl_read_model
 365.223 +;; from glpapi15 ;;
 365.224 + glp_add_arc
 365.225 + glp_add_vertices
 365.226 + glp_create_graph
 365.227 + glp_create_v_index
 365.228 + glp_del_arc
 365.229 + glp_del_vertices
 365.230 + glp_delete_graph
 365.231 + glp_delete_v_index
 365.232 + glp_erase_graph
 365.233 + glp_find_vertex
 365.234 + glp_read_graph
 365.235 + glp_set_graph_name
 365.236 + glp_set_vertex_name
 365.237 + glp_write_graph
 365.238 +;; from glpapi16 ;;
 365.239 + glp_strong_comp
 365.240 + glp_top_sort
 365.241 + glp_weak_comp
 365.242 +;; from glpapi17 ;;
 365.243 + glp_asnprob_hall
 365.244 + glp_asnprob_lp
 365.245 + glp_asnprob_okalg
 365.246 + glp_check_asnprob
 365.247 + glp_cpp
 365.248 + glp_maxflow_ffalg
 365.249 + glp_maxflow_lp
 365.250 + glp_mincost_lp
 365.251 + glp_mincost_okalg
 365.252 +;; from glpapi18 ;;
 365.253 + glp_wclique_exact
 365.254 +;; from glpapi19 ;;
 365.255 + glp_minisat1
 365.256 +;; from glpapi20 ;;
 365.257 + glp_intfeas1
 365.258 +;; from glpapi21 ;;
 365.259 + glp_main
 365.260 +;; from glpavl ;;
 365.261 + _glp_avl_create_tree
 365.262 + _glp_avl_delete_node
 365.263 + _glp_avl_delete_tree
 365.264 + _glp_avl_find_node
 365.265 + _glp_avl_get_node_link
 365.266 + _glp_avl_get_node_type
 365.267 + _glp_avl_insert_node
 365.268 + _glp_avl_set_node_link
 365.269 + _glp_avl_set_node_type
 365.270 + _glp_avl_strcmp
 365.271 +;; from glpbfd ;;
 365.272 + _glp_bfd_btran
 365.273 + _glp_bfd_create_it
 365.274 + _glp_bfd_delete_it
 365.275 + _glp_bfd_factorize
 365.276 + _glp_bfd_ftran
 365.277 + _glp_bfd_get_count
 365.278 + _glp_bfd_set_parm
 365.279 + _glp_bfd_update_it
 365.280 +;; from glpbfx ;;
 365.281 + _glp_bfx_btran
 365.282 + _glp_bfx_create_binv
 365.283 + _glp_bfx_delete_binv
 365.284 + _glp_bfx_factorize
 365.285 + _glp_bfx_ftran
 365.286 + _glp_bfx_update
 365.287 +;; from glpcpx ;;
 365.288 + glp_init_cpxcp
 365.289 + glp_read_lp
 365.290 + glp_write_lp
 365.291 +;; from glpdmp ;;
 365.292 + _glp_dmp_create_pool
 365.293 + _glp_dmp_delete_pool
 365.294 + _glp_dmp_free_atom
 365.295 + _glp_dmp_get_atom
 365.296 + _glp_dmp_in_use
 365.297 +;; from glpdmx ;;
 365.298 + glp_check_cnfsat
 365.299 + glp_read_asnprob
 365.300 + glp_read_ccdata
 365.301 + glp_read_cnfsat
 365.302 + glp_read_maxflow
 365.303 + glp_read_mincost
 365.304 + glp_read_prob
 365.305 + glp_write_asnprob
 365.306 + glp_write_ccdata
 365.307 + glp_write_cnfsat
 365.308 + glp_write_maxflow
 365.309 + glp_write_mincost
 365.310 + glp_write_prob
 365.311 +;; from glpenv01 ;;
 365.312 + _glp_get_env_ptr
 365.313 + glp_free_env
 365.314 + glp_init_env
 365.315 + glp_version
 365.316 +;; from glpenv02 ;;
 365.317 + _glp_tls_get_ptr
 365.318 + _glp_tls_set_ptr
 365.319 +;; from glpenv03 ;;
 365.320 + glp_close_tee
 365.321 + glp_open_tee
 365.322 + glp_printf
 365.323 + glp_term_hook
 365.324 + glp_term_out
 365.325 + glp_vprintf
 365.326 +;; from glpenv04 ;;
 365.327 + glp_assert_
 365.328 + glp_error_
 365.329 + glp_error_hook
 365.330 +;; from glpenv05 ;;
 365.331 + glp_calloc
 365.332 + glp_free
 365.333 + glp_malloc
 365.334 + glp_mem_limit
 365.335 + glp_mem_usage
 365.336 +;; from glpenv06 ;;
 365.337 + glp_difftime
 365.338 + glp_time
 365.339 +;; from glpenv07 ;;
 365.340 + _glp_lib_err_msg
 365.341 + _glp_lib_xerrmsg
 365.342 + _glp_lib_xfclose
 365.343 + _glp_lib_xfeof
 365.344 + _glp_lib_xferror
 365.345 + _glp_lib_xfflush
 365.346 + _glp_lib_xfgetc
 365.347 + _glp_lib_xfopen
 365.348 + _glp_lib_xfprintf
 365.349 + _glp_lib_xfputc
 365.350 +;; from glpenv08 ;;
 365.351 + _glp_xdlclose
 365.352 + _glp_xdlopen
 365.353 + _glp_xdlsym
 365.354 +;; from glpfhv ;;
 365.355 + _glp_fhv_btran
 365.356 + _glp_fhv_create_it
 365.357 + _glp_fhv_delete_it
 365.358 + _glp_fhv_factorize
 365.359 + _glp_fhv_ftran
 365.360 + _glp_fhv_h_solve
 365.361 + _glp_fhv_update_it
 365.362 +;; from glpgmp ;;
 365.363 + _glp_gmp_free_atom
 365.364 + _glp_gmp_free_mem
 365.365 + _glp_gmp_get_atom
 365.366 + _glp_gmp_get_work
 365.367 + _glp_gmp_pool_count
 365.368 + _glp_mpq_abs
 365.369 + _glp_mpq_add
 365.370 + _glp_mpq_canonicalize
 365.371 + _glp_mpq_clear
 365.372 + _glp_mpq_cmp
 365.373 + _glp_mpq_div
 365.374 + _glp_mpq_get_d
 365.375 + _glp_mpq_init
 365.376 + _glp_mpq_mul
 365.377 + _glp_mpq_neg
 365.378 + _glp_mpq_out_str
 365.379 + _glp_mpq_set
 365.380 + _glp_mpq_set_d
 365.381 + _glp_mpq_set_si
 365.382 + _glp_mpq_sgn
 365.383 + _glp_mpq_sub
 365.384 + _glp_mpz_abs
 365.385 + _glp_mpz_add
 365.386 + _glp_mpz_clear
 365.387 + _glp_mpz_cmp
 365.388 + _glp_mpz_div
 365.389 + _glp_mpz_gcd
 365.390 + _glp_mpz_get_d
 365.391 + _glp_mpz_get_d_2exp
 365.392 + _glp_mpz_init
 365.393 + _glp_mpz_mul
 365.394 + _glp_mpz_neg
 365.395 + _glp_mpz_out_str
 365.396 + _glp_mpz_set
 365.397 + _glp_mpz_set_si
 365.398 + _glp_mpz_sgn
 365.399 + _glp_mpz_sub
 365.400 + _glp_mpz_swap
 365.401 +;; from glphbm ;;
 365.402 + _glp_hbm_free_mat
 365.403 + _glp_hbm_read_mat
 365.404 +;; from glpini01 ;;
 365.405 + glp_adv_basis
 365.406 +;; from glpini02 ;;
 365.407 + glp_cpx_basis
 365.408 +;; from glpios01 ;;
 365.409 + _glp_ios_add_row
 365.410 + _glp_ios_best_node
 365.411 + _glp_ios_clear_pool
 365.412 + _glp_ios_clone_node
 365.413 + _glp_ios_create_pool
 365.414 + _glp_ios_create_tree
 365.415 + _glp_ios_del_row
 365.416 + _glp_ios_delete_node
 365.417 + _glp_ios_delete_pool
 365.418 + _glp_ios_delete_tree
 365.419 + _glp_ios_eval_degrad
 365.420 + _glp_ios_find_row
 365.421 + _glp_ios_freeze_node
 365.422 + _glp_ios_is_hopeful
 365.423 + _glp_ios_relative_gap
 365.424 + _glp_ios_revive_node
 365.425 + _glp_ios_round_bound
 365.426 + _glp_ios_solve_node
 365.427 +;; from glpios02 ;;
 365.428 + _glp_ios_preprocess_node
 365.429 +;; from glpios03 ;;
 365.430 + _glp_ios_driver
 365.431 +;; from glpios04 ;;
 365.432 + _glp_ios_check_vec
 365.433 + _glp_ios_clean_vec
 365.434 + _glp_ios_clear_vec
 365.435 + _glp_ios_copy_vec
 365.436 + _glp_ios_create_vec
 365.437 + _glp_ios_delete_vec
 365.438 + _glp_ios_get_vj
 365.439 + _glp_ios_linear_comb
 365.440 + _glp_ios_set_vj
 365.441 +;; from glpios05 ;;
 365.442 + _glp_ios_gmi_gen
 365.443 +;; from glpios06 ;;
 365.444 + _glp_ios_mir_gen
 365.445 + _glp_ios_mir_init
 365.446 + _glp_ios_mir_term
 365.447 +;; from glpios07 ;;
 365.448 + _glp_ios_cov_gen
 365.449 +;; from glpios08 ;;
 365.450 + _glp_ios_clq_gen
 365.451 + _glp_ios_clq_init
 365.452 + _glp_ios_clq_term
 365.453 +;; from glpios09 ;;
 365.454 + _glp_ios_choose_var
 365.455 + _glp_ios_pcost_branch
 365.456 + _glp_ios_pcost_free
 365.457 + _glp_ios_pcost_init
 365.458 + _glp_ios_pcost_update
 365.459 +;; from glpios10 ;;
 365.460 + _glp_ios_feas_pump
 365.461 +;; from glpios11 ;;
 365.462 + _glp_ios_process_cuts
 365.463 +;; from glpios12 ;;
 365.464 + _glp_ios_choose_node
 365.465 +;; from glpipm ;;
 365.466 + _glp_ipm_solve
 365.467 +;; from glplib01 ;;
 365.468 + _glp_lib_bigdiv
 365.469 + _glp_lib_bigmul
 365.470 +;; from glplib02 ;;
 365.471 + _glp_lib_xladd
 365.472 + _glp_lib_xlcmp
 365.473 + _glp_lib_xldiv
 365.474 + _glp_lib_xlmul
 365.475 + _glp_lib_xlneg
 365.476 + _glp_lib_xlset
 365.477 + _glp_lib_xlsub
 365.478 + _glp_lib_xltoa
 365.479 + _glp_lib_xltod
 365.480 +;; from glplib03 ;;
 365.481 + _glp_lib_fp2rat
 365.482 + _glp_lib_gcd
 365.483 + _glp_lib_gcdn
 365.484 + _glp_lib_jdate
 365.485 + _glp_lib_jday
 365.486 + _glp_lib_lcm
 365.487 + _glp_lib_lcmn
 365.488 + _glp_lib_round2n
 365.489 + _glp_lib_str2int
 365.490 + _glp_lib_str2num
 365.491 + _glp_lib_strrev
 365.492 + _glp_lib_strspx
 365.493 + _glp_lib_strtrim
 365.494 +;; from glplpf ;;
 365.495 + _glp_lpf_btran
 365.496 + _glp_lpf_create_it
 365.497 + _glp_lpf_delete_it
 365.498 + _glp_lpf_factorize
 365.499 + _glp_lpf_ftran
 365.500 + _glp_lpf_update_it
 365.501 +;; from glplpx01 ;;
 365.502 + _glp_lpx_add_cols
 365.503 + _glp_lpx_add_rows
 365.504 + _glp_lpx_adv_basis
 365.505 + _glp_lpx_check_int
 365.506 + _glp_lpx_check_kkt
 365.507 + _glp_lpx_cpx_basis
 365.508 + _glp_lpx_create_index
 365.509 + _glp_lpx_create_prob
 365.510 + _glp_lpx_del_cols
 365.511 + _glp_lpx_del_rows
 365.512 + _glp_lpx_delete_index
 365.513 + _glp_lpx_delete_prob
 365.514 + _glp_lpx_dual_ratio_test
 365.515 + _glp_lpx_eval_tab_col
 365.516 + _glp_lpx_eval_tab_row
 365.517 + _glp_lpx_exact
 365.518 + _glp_lpx_find_col
 365.519 + _glp_lpx_find_row
 365.520 + _glp_lpx_get_class
 365.521 + _glp_lpx_get_col_bnds
 365.522 + _glp_lpx_get_col_dual
 365.523 + _glp_lpx_get_col_info
 365.524 + _glp_lpx_get_col_kind
 365.525 + _glp_lpx_get_col_lb
 365.526 + _glp_lpx_get_col_name
 365.527 + _glp_lpx_get_col_prim
 365.528 + _glp_lpx_get_col_stat
 365.529 + _glp_lpx_get_col_type
 365.530 + _glp_lpx_get_col_ub
 365.531 + _glp_lpx_get_dual_stat
 365.532 + _glp_lpx_get_int_parm
 365.533 + _glp_lpx_get_mat_col
 365.534 + _glp_lpx_get_mat_row
 365.535 + _glp_lpx_get_num_bin
 365.536 + _glp_lpx_get_num_cols
 365.537 + _glp_lpx_get_num_int
 365.538 + _glp_lpx_get_num_nz
 365.539 + _glp_lpx_get_num_rows
 365.540 + _glp_lpx_get_obj_coef
 365.541 + _glp_lpx_get_obj_dir
 365.542 + _glp_lpx_get_obj_name
 365.543 + _glp_lpx_get_obj_val
 365.544 + _glp_lpx_get_prim_stat
 365.545 + _glp_lpx_get_prob_name
 365.546 + _glp_lpx_get_ray_info
 365.547 + _glp_lpx_get_real_parm
 365.548 + _glp_lpx_get_row_bnds
 365.549 + _glp_lpx_get_row_dual
 365.550 + _glp_lpx_get_row_info
 365.551 + _glp_lpx_get_row_lb
 365.552 + _glp_lpx_get_row_name
 365.553 + _glp_lpx_get_row_prim
 365.554 + _glp_lpx_get_row_stat
 365.555 + _glp_lpx_get_row_type
 365.556 + _glp_lpx_get_row_ub
 365.557 + _glp_lpx_get_status
 365.558 + _glp_lpx_integer
 365.559 + _glp_lpx_interior
 365.560 + _glp_lpx_intopt
 365.561 + _glp_lpx_ipt_col_dual
 365.562 + _glp_lpx_ipt_col_prim
 365.563 + _glp_lpx_ipt_obj_val
 365.564 + _glp_lpx_ipt_row_dual
 365.565 + _glp_lpx_ipt_row_prim
 365.566 + _glp_lpx_ipt_status
 365.567 + _glp_lpx_is_b_avail
 365.568 + _glp_lpx_load_matrix
 365.569 + _glp_lpx_main
 365.570 + _glp_lpx_mip_col_val
 365.571 + _glp_lpx_mip_obj_val
 365.572 + _glp_lpx_mip_row_val
 365.573 + _glp_lpx_mip_status
 365.574 + _glp_lpx_prim_ratio_test
 365.575 + _glp_lpx_print_ips
 365.576 + _glp_lpx_print_mip
 365.577 + _glp_lpx_print_prob
 365.578 + _glp_lpx_print_sens_bnds
 365.579 + _glp_lpx_print_sol
 365.580 + _glp_lpx_read_bas
 365.581 + _glp_lpx_read_cpxlp
 365.582 + _glp_lpx_read_freemps
 365.583 + _glp_lpx_read_model
 365.584 + _glp_lpx_read_mps
 365.585 + _glp_lpx_reset_parms
 365.586 + _glp_lpx_scale_prob
 365.587 + _glp_lpx_set_class
 365.588 + _glp_lpx_set_col_bnds
 365.589 + _glp_lpx_set_col_kind
 365.590 + _glp_lpx_set_col_name
 365.591 + _glp_lpx_set_col_stat
 365.592 + _glp_lpx_set_int_parm
 365.593 + _glp_lpx_set_mat_col
 365.594 + _glp_lpx_set_mat_row
 365.595 + _glp_lpx_set_obj_coef
 365.596 + _glp_lpx_set_obj_dir
 365.597 + _glp_lpx_set_obj_name
 365.598 + _glp_lpx_set_prob_name
 365.599 + _glp_lpx_set_real_parm
 365.600 + _glp_lpx_set_row_bnds
 365.601 + _glp_lpx_set_row_name
 365.602 + _glp_lpx_set_row_stat
 365.603 + _glp_lpx_simplex
 365.604 + _glp_lpx_std_basis
 365.605 + _glp_lpx_transform_col
 365.606 + _glp_lpx_transform_row
 365.607 + _glp_lpx_unscale_prob
 365.608 + _glp_lpx_warm_up
 365.609 + _glp_lpx_write_bas
 365.610 + _glp_lpx_write_cpxlp
 365.611 + _glp_lpx_write_freemps
 365.612 + _glp_lpx_write_mps
 365.613 +;; from glplpx02 ;;
 365.614 + _glp_put_mip_soln
 365.615 + _glp_put_solution
 365.616 +;; from glplpx03 ;;
 365.617 + _glp_lpx_write_pb
 365.618 +;; from glpluf ;;
 365.619 + _glp_luf_a_solve
 365.620 + _glp_luf_create_it
 365.621 + _glp_luf_defrag_sva
 365.622 + _glp_luf_delete_it
 365.623 + _glp_luf_enlarge_col
 365.624 + _glp_luf_enlarge_row
 365.625 + _glp_luf_f_solve
 365.626 + _glp_luf_factorize
 365.627 + _glp_luf_v_solve
 365.628 +;; from glplux ;;
 365.629 + _glp_lux_create
 365.630 + _glp_lux_decomp
 365.631 + _glp_lux_delete
 365.632 + _glp_lux_f_solve
 365.633 + _glp_lux_solve
 365.634 + _glp_lux_v_solve
 365.635 +;; from glpmat ;;
 365.636 + _glp_mat_adat_numeric
 365.637 + _glp_mat_adat_symbolic
 365.638 + _glp_mat_amd_order1
 365.639 + _glp_mat_check_fvs
 365.640 + _glp_mat_check_pattern
 365.641 + _glp_mat_chol_numeric
 365.642 + _glp_mat_chol_symbolic
 365.643 + _glp_mat_min_degree
 365.644 + _glp_mat_symamd_ord
 365.645 + _glp_mat_transpose
 365.646 + _glp_mat_u_solve
 365.647 + _glp_mat_ut_solve
 365.648 +;; from glpmpl01 ;;
 365.649 + _glp_mpl_append_block
 365.650 + _glp_mpl_append_char
 365.651 + _glp_mpl_append_slot
 365.652 + _glp_mpl_arg_list_len
 365.653 + _glp_mpl_branched_expression
 365.654 + _glp_mpl_check_statement
 365.655 + _glp_mpl_close_scope
 365.656 + _glp_mpl_constraint_statement
 365.657 + _glp_mpl_create_arg_list
 365.658 + _glp_mpl_create_block
 365.659 + _glp_mpl_create_domain
 365.660 + _glp_mpl_display_statement
 365.661 + _glp_mpl_domain_arity
 365.662 + _glp_mpl_elemset_argument
 365.663 + _glp_mpl_end_statement
 365.664 + _glp_mpl_enter_context
 365.665 + _glp_mpl_error_dimension
 365.666 + _glp_mpl_error_following
 365.667 + _glp_mpl_error_preceding
 365.668 + _glp_mpl_expand_arg_list
 365.669 + _glp_mpl_expression_0
 365.670 + _glp_mpl_expression_1
 365.671 + _glp_mpl_expression_10
 365.672 + _glp_mpl_expression_11
 365.673 + _glp_mpl_expression_12
 365.674 + _glp_mpl_expression_13
 365.675 + _glp_mpl_expression_2
 365.676 + _glp_mpl_expression_3
 365.677 + _glp_mpl_expression_4
 365.678 + _glp_mpl_expression_5
 365.679 + _glp_mpl_expression_6
 365.680 + _glp_mpl_expression_7
 365.681 + _glp_mpl_expression_8
 365.682 + _glp_mpl_expression_9
 365.683 + _glp_mpl_expression_list
 365.684 + _glp_mpl_for_statement
 365.685 + _glp_mpl_function_reference
 365.686 + _glp_mpl_get_char
 365.687 + _glp_mpl_get_token
 365.688 + _glp_mpl_indexing_expression
 365.689 + _glp_mpl_is_keyword
 365.690 + _glp_mpl_is_reserved
 365.691 + _glp_mpl_iterated_expression
 365.692 + _glp_mpl_literal_set
 365.693 + _glp_mpl_make_binary
 365.694 + _glp_mpl_make_code
 365.695 + _glp_mpl_make_ternary
 365.696 + _glp_mpl_make_unary
 365.697 + _glp_mpl_model_section
 365.698 + _glp_mpl_numeric_argument
 365.699 + _glp_mpl_numeric_literal
 365.700 + _glp_mpl_object_reference
 365.701 + _glp_mpl_objective_statement
 365.702 + _glp_mpl_parameter_statement
 365.703 + _glp_mpl_primary_expression
 365.704 + _glp_mpl_print_context
 365.705 + _glp_mpl_printf_statement
 365.706 + _glp_mpl_set_expression
 365.707 + _glp_mpl_set_statement
 365.708 + _glp_mpl_simple_statement
 365.709 + _glp_mpl_solve_statement
 365.710 + _glp_mpl_string_literal
 365.711 + _glp_mpl_subscript_list
 365.712 + _glp_mpl_symbolic_argument
 365.713 + _glp_mpl_table_statement
 365.714 + _glp_mpl_unget_token
 365.715 + _glp_mpl_variable_statement
 365.716 +;; from glpmpl02 ;;
 365.717 + _glp_mpl_create_slice
 365.718 + _glp_mpl_data_section
 365.719 + _glp_mpl_delete_slice
 365.720 + _glp_mpl_expand_slice
 365.721 + _glp_mpl_fake_slice
 365.722 + _glp_mpl_is_literal
 365.723 + _glp_mpl_is_number
 365.724 + _glp_mpl_is_symbol
 365.725 + _glp_mpl_matrix_format
 365.726 + _glp_mpl_parameter_data
 365.727 + _glp_mpl_plain_format
 365.728 + _glp_mpl_read_number
 365.729 + _glp_mpl_read_slice
 365.730 + _glp_mpl_read_symbol
 365.731 + _glp_mpl_read_value
 365.732 + _glp_mpl_select_parameter
 365.733 + _glp_mpl_select_set
 365.734 + _glp_mpl_set_data
 365.735 + _glp_mpl_set_default
 365.736 + _glp_mpl_simple_format
 365.737 + _glp_mpl_slice_arity
 365.738 + _glp_mpl_slice_dimen
 365.739 + _glp_mpl_tabbing_format
 365.740 + _glp_mpl_tabular_format
 365.741 +;; from glpmpl03 ;;
 365.742 + _glp_mpl_add_member
 365.743 + _glp_mpl_add_tuple
 365.744 + _glp_mpl_arelset_member
 365.745 + _glp_mpl_arelset_size
 365.746 + _glp_mpl_assign_dummy_index
 365.747 + _glp_mpl_build_subtuple
 365.748 + _glp_mpl_check_elem_set
 365.749 + _glp_mpl_check_then_add
 365.750 + _glp_mpl_check_value_num
 365.751 + _glp_mpl_check_value_sym
 365.752 + _glp_mpl_clean_check
 365.753 + _glp_mpl_clean_code
 365.754 + _glp_mpl_clean_constraint
 365.755 + _glp_mpl_clean_display
 365.756 + _glp_mpl_clean_domain
 365.757 + _glp_mpl_clean_for
 365.758 + _glp_mpl_clean_parameter
 365.759 + _glp_mpl_clean_printf
 365.760 + _glp_mpl_clean_set
 365.761 + _glp_mpl_clean_statement
 365.762 + _glp_mpl_clean_table
 365.763 + _glp_mpl_clean_variable
 365.764 + _glp_mpl_compare_strings
 365.765 + _glp_mpl_compare_symbols
 365.766 + _glp_mpl_compare_tuples
 365.767 + _glp_mpl_concat_symbols
 365.768 + _glp_mpl_constant_term
 365.769 + _glp_mpl_copy_elemset
 365.770 + _glp_mpl_copy_formula
 365.771 + _glp_mpl_copy_string
 365.772 + _glp_mpl_copy_symbol
 365.773 + _glp_mpl_copy_tuple
 365.774 + _glp_mpl_create_arelset
 365.775 + _glp_mpl_create_array
 365.776 + _glp_mpl_create_elemset
 365.777 + _glp_mpl_create_string
 365.778 + _glp_mpl_create_symbol_num
 365.779 + _glp_mpl_create_symbol_str
 365.780 + _glp_mpl_create_tuple
 365.781 + _glp_mpl_delete_array
 365.782 + _glp_mpl_delete_elemset
 365.783 + _glp_mpl_delete_formula
 365.784 + _glp_mpl_delete_string
 365.785 + _glp_mpl_delete_symbol
 365.786 + _glp_mpl_delete_tuple
 365.787 + _glp_mpl_delete_value
 365.788 + _glp_mpl_enter_domain_block
 365.789 + _glp_mpl_eval_elemset
 365.790 + _glp_mpl_eval_formula
 365.791 + _glp_mpl_eval_logical
 365.792 + _glp_mpl_eval_member_con
 365.793 + _glp_mpl_eval_member_num
 365.794 + _glp_mpl_eval_member_set
 365.795 + _glp_mpl_eval_member_sym
 365.796 + _glp_mpl_eval_member_var
 365.797 + _glp_mpl_eval_numeric
 365.798 + _glp_mpl_eval_symbolic
 365.799 + _glp_mpl_eval_tuple
 365.800 + _glp_mpl_eval_whole_con
 365.801 + _glp_mpl_eval_whole_par
 365.802 + _glp_mpl_eval_whole_set
 365.803 + _glp_mpl_eval_whole_var
 365.804 + _glp_mpl_eval_within_domain
 365.805 + _glp_mpl_execute_check
 365.806 + _glp_mpl_execute_display
 365.807 + _glp_mpl_execute_for
 365.808 + _glp_mpl_execute_printf
 365.809 + _glp_mpl_execute_statement
 365.810 + _glp_mpl_execute_table
 365.811 + _glp_mpl_expand_tuple
 365.812 + _glp_mpl_fetch_string
 365.813 + _glp_mpl_find_member
 365.814 + _glp_mpl_find_tuple
 365.815 + _glp_mpl_format_symbol
 365.816 + _glp_mpl_format_tuple
 365.817 + _glp_mpl_fp_add
 365.818 + _glp_mpl_fp_atan
 365.819 + _glp_mpl_fp_atan2
 365.820 + _glp_mpl_fp_cos
 365.821 + _glp_mpl_fp_div
 365.822 + _glp_mpl_fp_exp
 365.823 + _glp_mpl_fp_idiv
 365.824 + _glp_mpl_fp_irand224
 365.825 + _glp_mpl_fp_less
 365.826 + _glp_mpl_fp_log
 365.827 + _glp_mpl_fp_log10
 365.828 + _glp_mpl_fp_mod
 365.829 + _glp_mpl_fp_mul
 365.830 + _glp_mpl_fp_normal
 365.831 + _glp_mpl_fp_normal01
 365.832 + _glp_mpl_fp_power
 365.833 + _glp_mpl_fp_round
 365.834 + _glp_mpl_fp_sin
 365.835 + _glp_mpl_fp_sqrt
 365.836 + _glp_mpl_fp_sub
 365.837 + _glp_mpl_fp_trunc
 365.838 + _glp_mpl_fp_uniform01
 365.839 + _glp_mpl_free_dca
 365.840 + _glp_mpl_get_domain_tuple
 365.841 + _glp_mpl_is_member
 365.842 + _glp_mpl_linear_comb
 365.843 + _glp_mpl_loop_within_domain
 365.844 + _glp_mpl_out_of_domain
 365.845 + _glp_mpl_reduce_terms
 365.846 + _glp_mpl_remove_constant
 365.847 + _glp_mpl_set_cross
 365.848 + _glp_mpl_set_diff
 365.849 + _glp_mpl_set_inter
 365.850 + _glp_mpl_set_symdiff
 365.851 + _glp_mpl_set_union
 365.852 + _glp_mpl_single_variable
 365.853 + _glp_mpl_tab_get_arg
 365.854 + _glp_mpl_tab_get_name
 365.855 + _glp_mpl_tab_get_num
 365.856 + _glp_mpl_tab_get_str
 365.857 + _glp_mpl_tab_get_type
 365.858 + _glp_mpl_tab_num_args
 365.859 + _glp_mpl_tab_num_flds
 365.860 + _glp_mpl_tab_set_num
 365.861 + _glp_mpl_tab_set_str
 365.862 + _glp_mpl_take_member_con
 365.863 + _glp_mpl_take_member_num
 365.864 + _glp_mpl_take_member_set
 365.865 + _glp_mpl_take_member_sym
 365.866 + _glp_mpl_take_member_var
 365.867 + _glp_mpl_tuple_dimen
 365.868 + _glp_mpl_uniform
 365.869 + _glp_mpl_update_dummy_indices
 365.870 +;; from glpmpl04 ;;
 365.871 + _glp_mpl_alloc_content
 365.872 + _glp_mpl_build_problem
 365.873 + _glp_mpl_clean_model
 365.874 + _glp_mpl_close_input
 365.875 + _glp_mpl_error
 365.876 + _glp_mpl_flush_output
 365.877 + _glp_mpl_generate
 365.878 + _glp_mpl_generate_model
 365.879 + _glp_mpl_get_col_bnds
 365.880 + _glp_mpl_get_col_kind
 365.881 + _glp_mpl_get_col_name
 365.882 + _glp_mpl_get_mat_row
 365.883 + _glp_mpl_get_num_cols
 365.884 + _glp_mpl_get_num_rows
 365.885 + _glp_mpl_get_prob_name
 365.886 + _glp_mpl_get_row_bnds
 365.887 + _glp_mpl_get_row_c0
 365.888 + _glp_mpl_get_row_kind
 365.889 + _glp_mpl_get_row_name
 365.890 + _glp_mpl_has_solve_stmt
 365.891 + _glp_mpl_initialize
 365.892 + _glp_mpl_open_input
 365.893 + _glp_mpl_open_output
 365.894 + _glp_mpl_postsolve
 365.895 + _glp_mpl_postsolve_model
 365.896 + _glp_mpl_put_col_soln
 365.897 + _glp_mpl_put_row_soln
 365.898 + _glp_mpl_read_char
 365.899 + _glp_mpl_read_data
 365.900 + _glp_mpl_read_model
 365.901 + _glp_mpl_terminate
 365.902 + _glp_mpl_warning
 365.903 + _glp_mpl_write_char
 365.904 + _glp_mpl_write_text
 365.905 +;; from glpmpl05 ;;
 365.906 + _glp_mpl_fn_gmtime
 365.907 + _glp_mpl_fn_str2time
 365.908 + _glp_mpl_fn_time2str
 365.909 +;; from glpmpl06 ;;
 365.910 + _glp_mpl_tab_drv_close
 365.911 + _glp_mpl_tab_drv_open
 365.912 + _glp_mpl_tab_drv_read
 365.913 + _glp_mpl_tab_drv_write
 365.914 +;; from glpmps ;;
 365.915 + glp_init_mpscp
 365.916 + glp_read_mps
 365.917 + glp_write_mps
 365.918 +;; from glpnet01 ;;
 365.919 + _glp_mc21a
 365.920 +;; from glpnet02 ;;
 365.921 + _glp_mc13d
 365.922 +;; from glpnet03 ;;
 365.923 + glp_netgen
 365.924 +;; from glpnet04 ;;
 365.925 + glp_gridgen
 365.926 +;; from glpnet05 ;;
 365.927 + glp_rmfgen
 365.928 +;; from glpnet06 ;;
 365.929 + _glp_okalg
 365.930 +;; from glpnet07 ;;
 365.931 + _glp_ffalg
 365.932 +;; from glpnet08 ;;
 365.933 + _glp_wclique
 365.934 +;; from glpnet09 ;;
 365.935 + _glp_kellerman
 365.936 +;; from glpnpp01 ;;
 365.937 + _glp_npp_activate_col
 365.938 + _glp_npp_activate_row
 365.939 + _glp_npp_add_aij
 365.940 + _glp_npp_add_col
 365.941 + _glp_npp_add_row
 365.942 + _glp_npp_build_prob
 365.943 + _glp_npp_col_nnz
 365.944 + _glp_npp_create_wksp
 365.945 + _glp_npp_deactivate_col
 365.946 + _glp_npp_deactivate_row
 365.947 + _glp_npp_del_aij
 365.948 + _glp_npp_del_col
 365.949 + _glp_npp_del_row
 365.950 + _glp_npp_delete_wksp
 365.951 + _glp_npp_erase_row
 365.952 + _glp_npp_insert_col
 365.953 + _glp_npp_insert_row
 365.954 + _glp_npp_load_prob
 365.955 + _glp_npp_postprocess
 365.956 + _glp_npp_push_tse
 365.957 + _glp_npp_remove_col
 365.958 + _glp_npp_remove_row
 365.959 + _glp_npp_row_nnz
 365.960 + _glp_npp_unload_sol
 365.961 +;; from glpnpp02 ;;
 365.962 + _glp_npp_dbnd_col
 365.963 + _glp_npp_fixed_col
 365.964 + _glp_npp_free_col
 365.965 + _glp_npp_free_row
 365.966 + _glp_npp_geq_row
 365.967 + _glp_npp_lbnd_col
 365.968 + _glp_npp_leq_row
 365.969 + _glp_npp_make_equality
 365.970 + _glp_npp_make_fixed
 365.971 + _glp_npp_ubnd_col
 365.972 +;; from glpnpp03 ;;
 365.973 + _glp_npp_analyze_row
 365.974 + _glp_npp_empty_col
 365.975 + _glp_npp_empty_row
 365.976 + _glp_npp_eq_doublet
 365.977 + _glp_npp_eq_singlet
 365.978 + _glp_npp_forcing_row
 365.979 + _glp_npp_implied_bounds
 365.980 + _glp_npp_implied_free
 365.981 + _glp_npp_implied_lower
 365.982 + _glp_npp_implied_slack
 365.983 + _glp_npp_implied_upper
 365.984 + _glp_npp_implied_value
 365.985 + _glp_npp_inactive_bound
 365.986 + _glp_npp_ineq_singlet
 365.987 +;; from glpnpp04 ;;
 365.988 + _glp_npp_binarize_prob
 365.989 + _glp_npp_hidden_covering
 365.990 + _glp_npp_hidden_packing
 365.991 + _glp_npp_implied_packing
 365.992 + _glp_npp_is_covering
 365.993 + _glp_npp_is_packing
 365.994 + _glp_npp_is_partitioning
 365.995 + _glp_npp_reduce_ineq_coef
 365.996 +;; from glpnpp05 ;;
 365.997 + _glp_npp_clean_prob
 365.998 + _glp_npp_improve_bounds
 365.999 + _glp_npp_integer
365.1000 + _glp_npp_process_col
365.1001 + _glp_npp_process_prob
365.1002 + _glp_npp_process_row
365.1003 + _glp_npp_simplex
365.1004 +;; from glpnpp06 ;;
365.1005 + _glp_npp_sat_encode_clause
365.1006 + _glp_npp_sat_encode_geq
365.1007 + _glp_npp_sat_encode_leq
365.1008 + _glp_npp_sat_encode_pack
365.1009 + _glp_npp_sat_encode_prob
365.1010 + _glp_npp_sat_encode_row
365.1011 + _glp_npp_sat_encode_sum2
365.1012 + _glp_npp_sat_encode_sum3
365.1013 + _glp_npp_sat_encode_sum_ax
365.1014 + _glp_npp_sat_fixed_col
365.1015 + _glp_npp_sat_free_row
365.1016 + _glp_npp_sat_is_bin_comb
365.1017 + _glp_npp_sat_is_cover_ineq
365.1018 + _glp_npp_sat_is_pack_ineq
365.1019 + _glp_npp_sat_is_partn_eq
365.1020 + _glp_npp_sat_normalize_clause
365.1021 + _glp_npp_sat_num_neg_coef
365.1022 + _glp_npp_sat_num_pos_coef
365.1023 + _glp_npp_sat_reverse_row
365.1024 + _glp_npp_sat_split_pack
365.1025 +;; from glpqmd ;;
365.1026 + _glp_qmd_genqmd
365.1027 + _glp_qmd_qmdmrg
365.1028 + _glp_qmd_qmdqt
365.1029 + _glp_qmd_qmdrch
365.1030 + _glp_qmd_qmdupd
365.1031 +;; from glprgr ;;
365.1032 + _glp_rgr_write_bmp16
365.1033 +;; from glprng01 ;;
365.1034 + _glp_rng_create_rand
365.1035 + _glp_rng_delete_rand
365.1036 + _glp_rng_init_rand
365.1037 + _glp_rng_next_rand
365.1038 + _glp_rng_unif_rand
365.1039 +;; from glprng02 ;;
365.1040 + _glp_rng_unif_01
365.1041 + _glp_rng_uniform
365.1042 +;; from glpscf ;;
365.1043 + _glp_scf_create_it
365.1044 + _glp_scf_delete_it
365.1045 + _glp_scf_reset_it
365.1046 + _glp_scf_solve_it
365.1047 + _glp_scf_update_exp
365.1048 +;; from glpscl ;;
365.1049 + glp_scale_prob
365.1050 +;; from glpsdf ;;
365.1051 + glp_sdf_close_file
365.1052 + glp_sdf_error
365.1053 + glp_sdf_line
365.1054 + glp_sdf_open_file
365.1055 + glp_sdf_read_int
365.1056 + glp_sdf_read_item
365.1057 + glp_sdf_read_num
365.1058 + glp_sdf_read_text
365.1059 + glp_sdf_set_jump
365.1060 + glp_sdf_warning
365.1061 +;; from glpspm ;;
365.1062 + _glp_spm_add_mat
365.1063 + _glp_spm_add_num
365.1064 + _glp_spm_add_sym
365.1065 + _glp_spm_check_per
365.1066 + _glp_spm_count_nnz
365.1067 + _glp_spm_create_mat
365.1068 + _glp_spm_create_per
365.1069 + _glp_spm_delete_mat
365.1070 + _glp_spm_delete_per
365.1071 + _glp_spm_drop_zeros
365.1072 + _glp_spm_mul_mat
365.1073 + _glp_spm_mul_num
365.1074 + _glp_spm_mul_sym
365.1075 + _glp_spm_new_elem
365.1076 + _glp_spm_read_hbm
365.1077 + _glp_spm_read_mat
365.1078 + _glp_spm_show_mat
365.1079 + _glp_spm_test_mat_d
365.1080 + _glp_spm_test_mat_e
365.1081 + _glp_spm_transpose
365.1082 + _glp_spm_write_mat
365.1083 +;; from glpspx01 ;;
365.1084 + _glp_spx_primal
365.1085 +;; from glpspx02 ;;
365.1086 + _glp_spx_dual
365.1087 +;; from glpsql ;;
365.1088 + _glp_db_iodbc_close
365.1089 + _glp_db_iodbc_open
365.1090 + _glp_db_iodbc_read
365.1091 + _glp_db_iodbc_write
365.1092 + _glp_db_mysql_close
365.1093 + _glp_db_mysql_open
365.1094 + _glp_db_mysql_read
365.1095 + _glp_db_mysql_write
365.1096 +;; from glpssx01 ;;
365.1097 + _glp_ssx_change_basis
365.1098 + _glp_ssx_chuzc
365.1099 + _glp_ssx_chuzr
365.1100 + _glp_ssx_create
365.1101 + _glp_ssx_delete
365.1102 + _glp_ssx_eval_bbar
365.1103 + _glp_ssx_eval_cbar
365.1104 + _glp_ssx_eval_col
365.1105 + _glp_ssx_eval_dj
365.1106 + _glp_ssx_eval_pi
365.1107 + _glp_ssx_eval_rho
365.1108 + _glp_ssx_eval_row
365.1109 + _glp_ssx_factorize
365.1110 + _glp_ssx_get_xNj
365.1111 + _glp_ssx_update_bbar
365.1112 + _glp_ssx_update_cbar
365.1113 + _glp_ssx_update_pi
365.1114 +;; from glpssx02 ;;
365.1115 + _glp_ssx_driver
365.1116 + _glp_ssx_phase_I
365.1117 + _glp_ssx_phase_II
365.1118 +;; from glptsp ;;
365.1119 + _glp_tsp_distance
365.1120 + _glp_tsp_free_data
365.1121 + _glp_tsp_read_data
365.1122 +;; from gzclose ;;
365.1123 + _glp_zlib_gzclose
365.1124 +;; from gzlib ;;
365.1125 + _glp_zlib_gz_error
365.1126 + _glp_zlib_gzbuffer
365.1127 + _glp_zlib_gzclearerr
365.1128 + _glp_zlib_gzdopen
365.1129 + _glp_zlib_gzeof
365.1130 + _glp_zlib_gzerror
365.1131 + _glp_zlib_gzoffset
365.1132 + _glp_zlib_gzoffset64
365.1133 + _glp_zlib_gzopen
365.1134 + _glp_zlib_gzopen64
365.1135 + _glp_zlib_gzrewind
365.1136 + _glp_zlib_gzseek
365.1137 + _glp_zlib_gzseek64
365.1138 + _glp_zlib_gztell
365.1139 + _glp_zlib_gztell64
365.1140 +;; from gzread ;;
365.1141 + _glp_zlib_gzclose_r
365.1142 + _glp_zlib_gzdirect
365.1143 + _glp_zlib_gzgetc
365.1144 + _glp_zlib_gzgets
365.1145 + _glp_zlib_gzread
365.1146 + _glp_zlib_gzungetc
365.1147 +;; from gzwrite ;;
365.1148 + _glp_zlib_gzclose_w
365.1149 + _glp_zlib_gzflush
365.1150 + _glp_zlib_gzprintf
365.1151 + _glp_zlib_gzputc
365.1152 + _glp_zlib_gzputs
365.1153 + _glp_zlib_gzsetparams
365.1154 + _glp_zlib_gzwrite
365.1155 +;; from infback ;;
365.1156 + _glp_zlib_inflateBack
365.1157 + _glp_zlib_inflateBackEnd
365.1158 + _glp_zlib_inflateBackInit_
365.1159 +;; from inffast ;;
365.1160 + _glp_zlib_inflate_fast
365.1161 +;; from inflate ;;
365.1162 + _glp_zlib_inflate
365.1163 + _glp_zlib_inflateCopy
365.1164 + _glp_zlib_inflateEnd
365.1165 + _glp_zlib_inflateGetHeader
365.1166 + _glp_zlib_inflateInit2_
365.1167 + _glp_zlib_inflateInit_
365.1168 + _glp_zlib_inflateMark
365.1169 + _glp_zlib_inflatePrime
365.1170 + _glp_zlib_inflateReset
365.1171 + _glp_zlib_inflateReset2
365.1172 + _glp_zlib_inflateSetDictionary
365.1173 + _glp_zlib_inflateSync
365.1174 + _glp_zlib_inflateSyncPoint
365.1175 + _glp_zlib_inflateUndermine
365.1176 +;; from inftrees ;;
365.1177 + _glp_zlib_inflate_copyright
365.1178 + _glp_zlib_inflate_table
365.1179 +;; from minisat ;;
365.1180 + _glp_minisat_addclause
365.1181 + _glp_minisat_delete
365.1182 + _glp_minisat_nclauses
365.1183 + _glp_minisat_nconflicts
365.1184 + _glp_minisat_new
365.1185 + _glp_minisat_nvars
365.1186 + _glp_minisat_propagate
365.1187 + _glp_minisat_reducedb
365.1188 + _glp_minisat_setnvars
365.1189 + _glp_minisat_simplify
365.1190 + _glp_minisat_solve
365.1191 +;; from trees ;;
365.1192 + _glp_zlib_dist_code
365.1193 + _glp_zlib_length_code
365.1194 + _glp_zlib_tr_align
365.1195 + _glp_zlib_tr_flush_block
365.1196 + _glp_zlib_tr_init
365.1197 + _glp_zlib_tr_stored_block
365.1198 + _glp_zlib_tr_tally
365.1199 +;; from uncompr ;;
365.1200 + _glp_zlib_uncompress
365.1201 +;; from zio ;;
365.1202 + _glp_zlib_close
365.1203 + _glp_zlib_lseek
365.1204 + _glp_zlib_open
365.1205 + _glp_zlib_read
365.1206 + _glp_zlib_write
365.1207 +;; from zutil ;;
365.1208 + _glp_zlib_zError
365.1209 + _glp_zlib_z_errmsg
365.1210 + _glp_zlib_zcalloc
365.1211 + _glp_zlib_zcfree
365.1212 + _glp_zlib_zlibCompileFlags
365.1213 + _glp_zlib_zlibVersion
   366.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
   366.2 +++ b/deps/glpk/w32/readme.txt	Sun Nov 06 20:59:10 2011 +0100
   366.3 @@ -0,0 +1,24 @@
   366.4 +This directory contains batch files and other stuff which you can use
   366.5 +to build GLPK for 32-bit Windows with the native C/C++ compilers.
   366.6 +
   366.7 +Before running the batch file do the following:
   366.8 +
   366.9 +1. Make sure that you have installed the compiler you are going to use
  366.10 +   to build GLPK.
  366.11 +
  366.12 +2. Look into corresponding batch file (just right-click it and choose
  366.13 +   'Edit' in the popup menu; DO NOT choose 'Open'). Make sure that HOME
  366.14 +   variable specifies correct path to the compiler directory; if not,
  366.15 +   make necessary changes.
  366.16 +
  366.17 +To run the batch file just double-click it and wait a bit while the
  366.18 +Make utility does its job. The message 'OPTIMAL SOLUTION FOUND' in the
  366.19 +MS-DOS window means that all is OK. If you do not see it, something is
  366.20 +wrong.
  366.21 +
  366.22 +Once GLPK has been successfully built, there must appear two files in
  366.23 +this directory:
  366.24 +
  366.25 +glpk.lib, which is the GLPK object library, and
  366.26 +
  366.27 +glpsol.exe, which is the stand-alone GLPK LP/MIP solver.
   367.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
   367.2 +++ b/deps/glpk/w64/Build_GLPK_with_VC10.bat	Sun Nov 06 20:59:10 2011 +0100
   367.3 @@ -0,0 +1,11 @@
   367.4 +rem Build GLPK with Microsoft Visual Studio Express 2010
   367.5 +
   367.6 +rem NOTE: Make sure that HOME variable specifies correct path
   367.7 +set HOME="C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC"
   367.8 +
   367.9 +call %HOME%\vcvarsall.bat x64
  367.10 +copy config_VC config.h
  367.11 +%HOME%\bin\nmake.exe /f Makefile_VC
  367.12 +%HOME%\bin\nmake.exe /f Makefile_VC check
  367.13 +
  367.14 +pause
   368.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
   368.2 +++ b/deps/glpk/w64/Build_GLPK_with_VC10_DLL.bat	Sun Nov 06 20:59:10 2011 +0100
   368.3 @@ -0,0 +1,11 @@
   368.4 +rem Build GLPK DLL with Microsoft Visual Studio Express 2010
   368.5 +
   368.6 +rem NOTE: Make sure that HOME variable specifies correct path
   368.7 +set HOME="C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC"
   368.8 +
   368.9 +call %HOME%\vcvarsall.bat x64
  368.10 +copy config_VC config.h
  368.11 +%HOME%\bin\nmake.exe /f Makefile_VC_DLL
  368.12 +%HOME%\bin\nmake.exe /f Makefile_VC_DLL check
  368.13 +
  368.14 +pause
   369.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
   369.2 +++ b/deps/glpk/w64/Build_GLPK_with_VC9.bat	Sun Nov 06 20:59:10 2011 +0100
   369.3 @@ -0,0 +1,11 @@
   369.4 +rem Build GLPK with Microsoft Visual Studio Express 2008
   369.5 +
   369.6 +rem NOTE: Make sure that HOME variable specifies correct path
   369.7 +set HOME="C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC"
   369.8 +
   369.9 +call %HOME%\bin\vcvars64.bat
  369.10 +copy config_VC config.h
  369.11 +%HOME%\bin\nmake.exe /f Makefile_VC
  369.12 +%HOME%\bin\nmake.exe /f Makefile_VC check
  369.13 +
  369.14 +pause
   370.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
   370.2 +++ b/deps/glpk/w64/Build_GLPK_with_VC9_DLL.bat	Sun Nov 06 20:59:10 2011 +0100
   370.3 @@ -0,0 +1,11 @@
   370.4 +rem Build GLPK DLL with Microsoft Visual Studio Express 2008
   370.5 +
   370.6 +rem NOTE: Make sure that HOME variable specifies correct path
   370.7 +set HOME="C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC"
   370.8 +
   370.9 +call %HOME%\bin\vcvars64.bat
  370.10 +copy config_VC config.h
  370.11 +%HOME%\bin\nmake.exe /f Makefile_VC_DLL
  370.12 +%HOME%\bin\nmake.exe /f Makefile_VC_DLL check
  370.13 +
  370.14 +pause
   371.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
   371.2 +++ b/deps/glpk/w64/config_VC	Sun Nov 06 20:59:10 2011 +0100
   371.3 @@ -0,0 +1,13 @@
   371.4 +/* GLPK configuration file (Microsoft Visual Studio Express) */
   371.5 +
   371.6 +#define __WOE__ 1
   371.7 +
   371.8 +#define ODBC_DLNAME "odbc32.dll"
   371.9 +/* ODBC shared library name if this feature is enabled */
  371.10 +
  371.11 +#if 0
  371.12 +#define MYSQL_DLNAME "libmysql.dll"
  371.13 +/* MySQL shared library name if this feature is enabled */
  371.14 +#endif
  371.15 +
  371.16 +/* eof */
   372.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
   372.2 +++ b/deps/glpk/w64/glpk_4_47.def	Sun Nov 06 20:59:10 2011 +0100
   372.3 @@ -0,0 +1,1210 @@
   372.4 +LIBRARY glpk_4_47
   372.5 +VERSION 4.47
   372.6 +DESCRIPTION "GNU Linear Programming Kit"
   372.7 +EXPORTS
   372.8 +;; from adler32 ;;
   372.9 + _glp_zlib_adler32
  372.10 + _glp_zlib_adler32_combine
  372.11 + _glp_zlib_adler32_combine64
  372.12 +;; from amd_1 ;;
  372.13 + _glp_amd_1
  372.14 +;; from amd_2 ;;
  372.15 + _glp_amd_2
  372.16 +;; from amd_aat ;;
  372.17 + _glp_amd_aat
  372.18 +;; from amd_control ;;
  372.19 + _glp_amd_control
  372.20 +;; from amd_defaults ;;
  372.21 + _glp_amd_defaults
  372.22 +;; from amd_dump ;;
  372.23 +;; from amd_info ;;
  372.24 + _glp_amd_info
  372.25 +;; from amd_order ;;
  372.26 + _glp_amd_order
  372.27 +;; from amd_post_tree ;;
  372.28 + _glp_amd_post_tree
  372.29 +;; from amd_postorder ;;
  372.30 + _glp_amd_postorder
  372.31 +;; from amd_preprocess ;;
  372.32 + _glp_amd_preprocess
  372.33 +;; from amd_valid ;;
  372.34 + _glp_amd_valid
  372.35 +;; from colamd ;;
  372.36 + _glp_colamd
  372.37 + _glp_colamd_recommended
  372.38 + _glp_colamd_report
  372.39 + _glp_colamd_set_defaults
  372.40 + _glp_symamd
  372.41 + _glp_symamd_report
  372.42 +;; from compress ;;
  372.43 + _glp_zlib_compress
  372.44 + _glp_zlib_compress2
  372.45 + _glp_zlib_compressBound
  372.46 +;; from crc32 ;;
  372.47 + _glp_zlib_crc32
  372.48 + _glp_zlib_crc32_combine
  372.49 + _glp_zlib_crc32_combine64
  372.50 + _glp_zlib_get_crc_table
  372.51 +;; from deflate ;;
  372.52 + _glp_zlib_deflate
  372.53 + _glp_zlib_deflateBound
  372.54 + _glp_zlib_deflateCopy
  372.55 + _glp_zlib_deflateEnd
  372.56 + _glp_zlib_deflateInit2_
  372.57 + _glp_zlib_deflateInit_
  372.58 + _glp_zlib_deflateParams
  372.59 + _glp_zlib_deflatePrime
  372.60 + _glp_zlib_deflateReset
  372.61 + _glp_zlib_deflateSetDictionary
  372.62 + _glp_zlib_deflateSetHeader
  372.63 + _glp_zlib_deflateTune
  372.64 + _glp_zlib_deflate_copyright
  372.65 +;; from glpapi01 ;;
  372.66 + glp_add_cols
  372.67 + glp_add_rows
  372.68 + glp_check_dup
  372.69 + glp_copy_prob
  372.70 + glp_create_prob
  372.71 + glp_del_cols
  372.72 + glp_del_rows
  372.73 + glp_delete_prob
  372.74 + glp_erase_prob
  372.75 + glp_load_matrix
  372.76 + glp_set_col_bnds
  372.77 + glp_set_col_name
  372.78 + glp_set_mat_col
  372.79 + glp_set_mat_row
  372.80 + glp_set_obj_coef
  372.81 + glp_set_obj_dir
  372.82 + glp_set_obj_name
  372.83 + glp_set_prob_name
  372.84 + glp_set_row_bnds
  372.85 + glp_set_row_name
  372.86 + glp_sort_matrix
  372.87 +;; from glpapi02 ;;
  372.88 + glp_get_col_lb
  372.89 + glp_get_col_name
  372.90 + glp_get_col_type
  372.91 + glp_get_col_ub
  372.92 + glp_get_mat_col
  372.93 + glp_get_mat_row
  372.94 + glp_get_num_cols
  372.95 + glp_get_num_nz
  372.96 + glp_get_num_rows
  372.97 + glp_get_obj_coef
  372.98 + glp_get_obj_dir
  372.99 + glp_get_obj_name
 372.100 + glp_get_prob_name
 372.101 + glp_get_row_lb
 372.102 + glp_get_row_name
 372.103 + glp_get_row_type
 372.104 + glp_get_row_ub
 372.105 +;; from glpapi03 ;;
 372.106 + glp_create_index
 372.107 + glp_delete_index
 372.108 + glp_find_col
 372.109 + glp_find_row
 372.110 +;; from glpapi04 ;;
 372.111 + glp_get_rii
 372.112 + glp_get_sjj
 372.113 + glp_set_rii
 372.114 + glp_set_sjj
 372.115 + glp_unscale_prob
 372.116 +;; from glpapi05 ;;
 372.117 + glp_set_col_stat
 372.118 + glp_set_row_stat
 372.119 + glp_std_basis
 372.120 +;; from glpapi06 ;;
 372.121 + glp_get_col_dual
 372.122 + glp_get_col_prim
 372.123 + glp_get_col_stat
 372.124 + glp_get_dual_stat
 372.125 + glp_get_obj_val
 372.126 + glp_get_prim_stat
 372.127 + glp_get_row_dual
 372.128 + glp_get_row_prim
 372.129 + glp_get_row_stat
 372.130 + glp_get_status
 372.131 + glp_get_unbnd_ray
 372.132 + glp_init_smcp
 372.133 + glp_simplex
 372.134 +;; from glpapi07 ;;
 372.135 + glp_exact
 372.136 +;; from glpapi08 ;;
 372.137 + glp_init_iptcp
 372.138 + glp_interior
 372.139 + glp_ipt_col_dual
 372.140 + glp_ipt_col_prim
 372.141 + glp_ipt_obj_val
 372.142 + glp_ipt_row_dual
 372.143 + glp_ipt_row_prim
 372.144 + glp_ipt_status
 372.145 +;; from glpapi09 ;;
 372.146 + _glp_intopt1
 372.147 + glp_get_col_kind
 372.148 + glp_get_num_bin
 372.149 + glp_get_num_int
 372.150 + glp_init_iocp
 372.151 + glp_intopt
 372.152 + glp_mip_col_val
 372.153 + glp_mip_obj_val
 372.154 + glp_mip_row_val
 372.155 + glp_mip_status
 372.156 + glp_set_col_kind
 372.157 +;; from glpapi10 ;;
 372.158 + _glp_check_kkt
 372.159 +;; from glpapi11 ;;
 372.160 + glp_print_ipt
 372.161 + glp_print_mip
 372.162 + glp_print_ranges
 372.163 + glp_print_sol
 372.164 + glp_read_ipt
 372.165 + glp_read_mip
 372.166 + glp_read_sol
 372.167 + glp_write_ipt
 372.168 + glp_write_mip
 372.169 + glp_write_sol
 372.170 +;; from glpapi12 ;;
 372.171 + _glp_analyze_row
 372.172 + glp_analyze_bound
 372.173 + glp_analyze_coef
 372.174 + glp_bf_exists
 372.175 + glp_bf_updated
 372.176 + glp_btran
 372.177 + glp_dual_rtest
 372.178 + glp_eval_tab_col
 372.179 + glp_eval_tab_row
 372.180 + glp_factorize
 372.181 + glp_ftran
 372.182 + glp_get_bfcp
 372.183 + glp_get_bhead
 372.184 + glp_get_col_bind
 372.185 + glp_get_row_bind
 372.186 + glp_prim_rtest
 372.187 + glp_set_bfcp
 372.188 + glp_transform_col
 372.189 + glp_transform_row
 372.190 + glp_warm_up
 372.191 +;; from glpapi13 ;;
 372.192 + glp_ios_add_row
 372.193 + glp_ios_best_node
 372.194 + glp_ios_branch_upon
 372.195 + glp_ios_can_branch
 372.196 + glp_ios_clear_pool
 372.197 + glp_ios_curr_node
 372.198 + glp_ios_del_row
 372.199 + glp_ios_get_prob
 372.200 + glp_ios_heur_sol
 372.201 + glp_ios_mip_gap
 372.202 + glp_ios_next_node
 372.203 + glp_ios_node_bound
 372.204 + glp_ios_node_data
 372.205 + glp_ios_node_level
 372.206 + glp_ios_pool_size
 372.207 + glp_ios_prev_node
 372.208 + glp_ios_reason
 372.209 + glp_ios_row_attr
 372.210 + glp_ios_select_node
 372.211 + glp_ios_terminate
 372.212 + glp_ios_tree_size
 372.213 + glp_ios_up_node
 372.214 +;; from glpapi14 ;;
 372.215 + _glp_mpl_init_rand
 372.216 + glp_mpl_alloc_wksp
 372.217 + glp_mpl_build_prob
 372.218 + glp_mpl_free_wksp
 372.219 + glp_mpl_generate
 372.220 + glp_mpl_postsolve
 372.221 + glp_mpl_read_data
 372.222 + glp_mpl_read_model
 372.223 +;; from glpapi15 ;;
 372.224 + glp_add_arc
 372.225 + glp_add_vertices
 372.226 + glp_create_graph
 372.227 + glp_create_v_index
 372.228 + glp_del_arc
 372.229 + glp_del_vertices
 372.230 + glp_delete_graph
 372.231 + glp_delete_v_index
 372.232 + glp_erase_graph
 372.233 + glp_find_vertex
 372.234 + glp_read_graph
 372.235 + glp_set_graph_name
 372.236 + glp_set_vertex_name
 372.237 + glp_write_graph
 372.238 +;; from glpapi16 ;;
 372.239 + glp_strong_comp
 372.240 + glp_top_sort
 372.241 + glp_weak_comp
 372.242 +;; from glpapi17 ;;
 372.243 + glp_asnprob_hall
 372.244 + glp_asnprob_lp
 372.245 + glp_asnprob_okalg
 372.246 + glp_check_asnprob
 372.247 + glp_cpp
 372.248 + glp_maxflow_ffalg
 372.249 + glp_maxflow_lp
 372.250 + glp_mincost_lp
 372.251 + glp_mincost_okalg
 372.252 +;; from glpapi18 ;;
 372.253 + glp_wclique_exact
 372.254 +;; from glpapi19 ;;
 372.255 + glp_minisat1
 372.256 +;; from glpapi20 ;;
 372.257 + glp_intfeas1
 372.258 +;; from glpapi21 ;;
 372.259 + glp_main
 372.260 +;; from glpavl ;;
 372.261 + _glp_avl_create_tree
 372.262 + _glp_avl_delete_node
 372.263 + _glp_avl_delete_tree
 372.264 + _glp_avl_find_node
 372.265 + _glp_avl_get_node_link
 372.266 + _glp_avl_get_node_type
 372.267 + _glp_avl_insert_node
 372.268 + _glp_avl_set_node_link
 372.269 + _glp_avl_set_node_type
 372.270 + _glp_avl_strcmp
 372.271 +;; from glpbfd ;;
 372.272 + _glp_bfd_btran
 372.273 + _glp_bfd_create_it
 372.274 + _glp_bfd_delete_it
 372.275 + _glp_bfd_factorize
 372.276 + _glp_bfd_ftran
 372.277 + _glp_bfd_get_count
 372.278 + _glp_bfd_set_parm
 372.279 + _glp_bfd_update_it
 372.280 +;; from glpbfx ;;
 372.281 + _glp_bfx_btran
 372.282 + _glp_bfx_create_binv
 372.283 + _glp_bfx_delete_binv
 372.284 + _glp_bfx_factorize
 372.285 + _glp_bfx_ftran
 372.286 + _glp_bfx_update
 372.287 +;; from glpcpx ;;
 372.288 + glp_init_cpxcp
 372.289 + glp_read_lp
 372.290 + glp_write_lp
 372.291 +;; from glpdmp ;;
 372.292 + _glp_dmp_create_pool
 372.293 + _glp_dmp_delete_pool
 372.294 + _glp_dmp_free_atom
 372.295 + _glp_dmp_get_atom
 372.296 + _glp_dmp_in_use
 372.297 +;; from glpdmx ;;
 372.298 + glp_check_cnfsat
 372.299 + glp_read_asnprob
 372.300 + glp_read_ccdata
 372.301 + glp_read_cnfsat
 372.302 + glp_read_maxflow
 372.303 + glp_read_mincost
 372.304 + glp_read_prob
 372.305 + glp_write_asnprob
 372.306 + glp_write_ccdata
 372.307 + glp_write_cnfsat
 372.308 + glp_write_maxflow
 372.309 + glp_write_mincost
 372.310 + glp_write_prob
 372.311 +;; from glpenv01 ;;
 372.312 + _glp_get_env_ptr
 372.313 + glp_free_env
 372.314 + glp_init_env
 372.315 + glp_version
 372.316 +;; from glpenv02 ;;
 372.317 + _glp_tls_get_ptr
 372.318 + _glp_tls_set_ptr
 372.319 +;; from glpenv03 ;;
 372.320 + glp_close_tee
 372.321 + glp_open_tee
 372.322 + glp_printf
 372.323 + glp_term_hook
 372.324 + glp_term_out
 372.325 + glp_vprintf
 372.326 +;; from glpenv04 ;;
 372.327 + glp_assert_
 372.328 + glp_error_
 372.329 + glp_error_hook
 372.330 +;; from glpenv05 ;;
 372.331 + glp_calloc
 372.332 + glp_free
 372.333 + glp_malloc
 372.334 + glp_mem_limit
 372.335 + glp_mem_usage
 372.336 +;; from glpenv06 ;;
 372.337 + glp_difftime
 372.338 + glp_time
 372.339 +;; from glpenv07 ;;
 372.340 + _glp_lib_err_msg
 372.341 + _glp_lib_xerrmsg
 372.342 + _glp_lib_xfclose
 372.343 + _glp_lib_xfeof
 372.344 + _glp_lib_xferror
 372.345 + _glp_lib_xfflush
 372.346 + _glp_lib_xfgetc
 372.347 + _glp_lib_xfopen
 372.348 + _glp_lib_xfprintf
 372.349 + _glp_lib_xfputc
 372.350 +;; from glpenv08 ;;
 372.351 + _glp_xdlclose
 372.352 + _glp_xdlopen
 372.353 + _glp_xdlsym
 372.354 +;; from glpfhv ;;
 372.355 + _glp_fhv_btran
 372.356 + _glp_fhv_create_it
 372.357 + _glp_fhv_delete_it
 372.358 + _glp_fhv_factorize
 372.359 + _glp_fhv_ftran
 372.360 + _glp_fhv_h_solve
 372.361 + _glp_fhv_update_it
 372.362 +;; from glpgmp ;;
 372.363 + _glp_gmp_free_atom
 372.364 + _glp_gmp_free_mem
 372.365 + _glp_gmp_get_atom
 372.366 + _glp_gmp_get_work
 372.367 + _glp_gmp_pool_count
 372.368 + _glp_mpq_abs
 372.369 + _glp_mpq_add
 372.370 + _glp_mpq_canonicalize
 372.371 + _glp_mpq_clear
 372.372 + _glp_mpq_cmp
 372.373 + _glp_mpq_div
 372.374 + _glp_mpq_get_d
 372.375 + _glp_mpq_init
 372.376 + _glp_mpq_mul
 372.377 + _glp_mpq_neg
 372.378 + _glp_mpq_out_str
 372.379 + _glp_mpq_set
 372.380 + _glp_mpq_set_d
 372.381 + _glp_mpq_set_si
 372.382 + _glp_mpq_sgn
 372.383 + _glp_mpq_sub
 372.384 + _glp_mpz_abs
 372.385 + _glp_mpz_add
 372.386 + _glp_mpz_clear
 372.387 + _glp_mpz_cmp
 372.388 + _glp_mpz_div
 372.389 + _glp_mpz_gcd
 372.390 + _glp_mpz_get_d
 372.391 + _glp_mpz_get_d_2exp
 372.392 + _glp_mpz_init
 372.393 + _glp_mpz_mul
 372.394 + _glp_mpz_neg
 372.395 + _glp_mpz_out_str
 372.396 + _glp_mpz_set
 372.397 + _glp_mpz_set_si
 372.398 + _glp_mpz_sgn
 372.399 + _glp_mpz_sub
 372.400 + _glp_mpz_swap
 372.401 +;; from glphbm ;;
 372.402 + _glp_hbm_free_mat
 372.403 + _glp_hbm_read_mat
 372.404 +;; from glpini01 ;;
 372.405 + glp_adv_basis
 372.406 +;; from glpini02 ;;
 372.407 + glp_cpx_basis
 372.408 +;; from glpios01 ;;
 372.409 + _glp_ios_add_row
 372.410 + _glp_ios_best_node
 372.411 + _glp_ios_clear_pool
 372.412 + _glp_ios_clone_node
 372.413 + _glp_ios_create_pool
 372.414 + _glp_ios_create_tree
 372.415 + _glp_ios_del_row
 372.416 + _glp_ios_delete_node
 372.417 + _glp_ios_delete_pool
 372.418 + _glp_ios_delete_tree
 372.419 + _glp_ios_eval_degrad
 372.420 + _glp_ios_find_row
 372.421 + _glp_ios_freeze_node
 372.422 + _glp_ios_is_hopeful
 372.423 + _glp_ios_relative_gap
 372.424 + _glp_ios_revive_node
 372.425 + _glp_ios_round_bound
 372.426 + _glp_ios_solve_node
 372.427 +;; from glpios02 ;;
 372.428 + _glp_ios_preprocess_node
 372.429 +;; from glpios03 ;;
 372.430 + _glp_ios_driver
 372.431 +;; from glpios04 ;;
 372.432 + _glp_ios_check_vec
 372.433 + _glp_ios_clean_vec
 372.434 + _glp_ios_clear_vec
 372.435 + _glp_ios_copy_vec
 372.436 + _glp_ios_create_vec
 372.437 + _glp_ios_delete_vec
 372.438 + _glp_ios_get_vj
 372.439 + _glp_ios_linear_comb
 372.440 + _glp_ios_set_vj
 372.441 +;; from glpios05 ;;
 372.442 + _glp_ios_gmi_gen
 372.443 +;; from glpios06 ;;
 372.444 + _glp_ios_mir_gen
 372.445 + _glp_ios_mir_init
 372.446 + _glp_ios_mir_term
 372.447 +;; from glpios07 ;;
 372.448 + _glp_ios_cov_gen
 372.449 +;; from glpios08 ;;
 372.450 + _glp_ios_clq_gen
 372.451 + _glp_ios_clq_init
 372.452 + _glp_ios_clq_term
 372.453 +;; from glpios09 ;;
 372.454 + _glp_ios_choose_var
 372.455 + _glp_ios_pcost_branch
 372.456 + _glp_ios_pcost_free
 372.457 + _glp_ios_pcost_init
 372.458 + _glp_ios_pcost_update
 372.459 +;; from glpios10 ;;
 372.460 + _glp_ios_feas_pump
 372.461 +;; from glpios11 ;;
 372.462 + _glp_ios_process_cuts
 372.463 +;; from glpios12 ;;
 372.464 + _glp_ios_choose_node
 372.465 +;; from glpipm ;;
 372.466 + _glp_ipm_solve
 372.467 +;; from glplib01 ;;
 372.468 + _glp_lib_bigdiv
 372.469 + _glp_lib_bigmul
 372.470 +;; from glplib02 ;;
 372.471 + _glp_lib_xladd
 372.472 + _glp_lib_xlcmp
 372.473 + _glp_lib_xldiv
 372.474 + _glp_lib_xlmul
 372.475 + _glp_lib_xlneg
 372.476 + _glp_lib_xlset
 372.477 + _glp_lib_xlsub
 372.478 + _glp_lib_xltoa
 372.479 + _glp_lib_xltod
 372.480 +;; from glplib03 ;;
 372.481 + _glp_lib_fp2rat
 372.482 + _glp_lib_gcd
 372.483 + _glp_lib_gcdn
 372.484 + _glp_lib_jdate
 372.485 + _glp_lib_jday
 372.486 + _glp_lib_lcm
 372.487 + _glp_lib_lcmn
 372.488 + _glp_lib_round2n
 372.489 + _glp_lib_str2int
 372.490 + _glp_lib_str2num
 372.491 + _glp_lib_strrev
 372.492 + _glp_lib_strspx
 372.493 + _glp_lib_strtrim
 372.494 +;; from glplpf ;;
 372.495 + _glp_lpf_btran
 372.496 + _glp_lpf_create_it
 372.497 + _glp_lpf_delete_it
 372.498 + _glp_lpf_factorize
 372.499 + _glp_lpf_ftran
 372.500 + _glp_lpf_update_it
 372.501 +;; from glplpx01 ;;
 372.502 + _glp_lpx_add_cols
 372.503 + _glp_lpx_add_rows
 372.504 + _glp_lpx_adv_basis
 372.505 + _glp_lpx_check_int
 372.506 + _glp_lpx_check_kkt
 372.507 + _glp_lpx_cpx_basis
 372.508 + _glp_lpx_create_index
 372.509 + _glp_lpx_create_prob
 372.510 + _glp_lpx_del_cols
 372.511 + _glp_lpx_del_rows
 372.512 + _glp_lpx_delete_index
 372.513 + _glp_lpx_delete_prob
 372.514 + _glp_lpx_dual_ratio_test
 372.515 + _glp_lpx_eval_tab_col
 372.516 + _glp_lpx_eval_tab_row
 372.517 + _glp_lpx_exact
 372.518 + _glp_lpx_find_col
 372.519 + _glp_lpx_find_row
 372.520 + _glp_lpx_get_class
 372.521 + _glp_lpx_get_col_bnds
 372.522 + _glp_lpx_get_col_dual
 372.523 + _glp_lpx_get_col_info
 372.524 + _glp_lpx_get_col_kind
 372.525 + _glp_lpx_get_col_lb
 372.526 + _glp_lpx_get_col_name
 372.527 + _glp_lpx_get_col_prim
 372.528 + _glp_lpx_get_col_stat
 372.529 + _glp_lpx_get_col_type
 372.530 + _glp_lpx_get_col_ub
 372.531 + _glp_lpx_get_dual_stat
 372.532 + _glp_lpx_get_int_parm
 372.533 + _glp_lpx_get_mat_col
 372.534 + _glp_lpx_get_mat_row
 372.535 + _glp_lpx_get_num_bin
 372.536 + _glp_lpx_get_num_cols
 372.537 + _glp_lpx_get_num_int
 372.538 + _glp_lpx_get_num_nz
 372.539 + _glp_lpx_get_num_rows
 372.540 + _glp_lpx_get_obj_coef
 372.541 + _glp_lpx_get_obj_dir
 372.542 + _glp_lpx_get_obj_name
 372.543 + _glp_lpx_get_obj_val
 372.544 + _glp_lpx_get_prim_stat
 372.545 + _glp_lpx_get_prob_name
 372.546 + _glp_lpx_get_ray_info
 372.547 + _glp_lpx_get_real_parm
 372.548 + _glp_lpx_get_row_bnds
 372.549 + _glp_lpx_get_row_dual
 372.550 + _glp_lpx_get_row_info
 372.551 + _glp_lpx_get_row_lb
 372.552 + _glp_lpx_get_row_name
 372.553 + _glp_lpx_get_row_prim
 372.554 + _glp_lpx_get_row_stat
 372.555 + _glp_lpx_get_row_type
 372.556 + _glp_lpx_get_row_ub
 372.557 + _glp_lpx_get_status
 372.558 + _glp_lpx_integer
 372.559 + _glp_lpx_interior
 372.560 + _glp_lpx_intopt
 372.561 + _glp_lpx_ipt_col_dual
 372.562 + _glp_lpx_ipt_col_prim
 372.563 + _glp_lpx_ipt_obj_val
 372.564 + _glp_lpx_ipt_row_dual
 372.565 + _glp_lpx_ipt_row_prim
 372.566 + _glp_lpx_ipt_status
 372.567 + _glp_lpx_is_b_avail
 372.568 + _glp_lpx_load_matrix
 372.569 + _glp_lpx_main
 372.570 + _glp_lpx_mip_col_val
 372.571 + _glp_lpx_mip_obj_val
 372.572 + _glp_lpx_mip_row_val
 372.573 + _glp_lpx_mip_status
 372.574 + _glp_lpx_prim_ratio_test
 372.575 + _glp_lpx_print_ips
 372.576 + _glp_lpx_print_mip
 372.577 + _glp_lpx_print_prob
 372.578 + _glp_lpx_print_sens_bnds
 372.579 + _glp_lpx_print_sol
 372.580 + _glp_lpx_read_bas
 372.581 + _glp_lpx_read_cpxlp
 372.582 + _glp_lpx_read_freemps
 372.583 + _glp_lpx_read_model
 372.584 + _glp_lpx_read_mps
 372.585 + _glp_lpx_reset_parms
 372.586 + _glp_lpx_scale_prob
 372.587 + _glp_lpx_set_class
 372.588 + _glp_lpx_set_col_bnds
 372.589 + _glp_lpx_set_col_kind
 372.590 + _glp_lpx_set_col_name
 372.591 + _glp_lpx_set_col_stat
 372.592 + _glp_lpx_set_int_parm
 372.593 + _glp_lpx_set_mat_col
 372.594 + _glp_lpx_set_mat_row
 372.595 + _glp_lpx_set_obj_coef
 372.596 + _glp_lpx_set_obj_dir
 372.597 + _glp_lpx_set_obj_name
 372.598 + _glp_lpx_set_prob_name
 372.599 + _glp_lpx_set_real_parm
 372.600 + _glp_lpx_set_row_bnds
 372.601 + _glp_lpx_set_row_name
 372.602 + _glp_lpx_set_row_stat
 372.603 + _glp_lpx_simplex
 372.604 + _glp_lpx_std_basis
 372.605 + _glp_lpx_transform_col
 372.606 + _glp_lpx_transform_row
 372.607 + _glp_lpx_unscale_prob
 372.608 + _glp_lpx_warm_up
 372.609 + _glp_lpx_write_bas
 372.610 + _glp_lpx_write_cpxlp
 372.611 + _glp_lpx_write_freemps
 372.612 + _glp_lpx_write_mps
 372.613 +;; from glplpx02 ;;
 372.614 + _glp_put_mip_soln
 372.615 + _glp_put_solution
 372.616 +;; from glplpx03 ;;
 372.617 + _glp_lpx_write_pb
 372.618 +;; from glpluf ;;
 372.619 + _glp_luf_a_solve
 372.620 + _glp_luf_create_it
 372.621 + _glp_luf_defrag_sva
 372.622 + _glp_luf_delete_it
 372.623 + _glp_luf_enlarge_col
 372.624 + _glp_luf_enlarge_row
 372.625 + _glp_luf_f_solve
 372.626 + _glp_luf_factorize
 372.627 + _glp_luf_v_solve
 372.628 +;; from glplux ;;
 372.629 + _glp_lux_create
 372.630 + _glp_lux_decomp
 372.631 + _glp_lux_delete
 372.632 + _glp_lux_f_solve
 372.633 + _glp_lux_solve
 372.634 + _glp_lux_v_solve
 372.635 +;; from glpmat ;;
 372.636 + _glp_mat_adat_numeric
 372.637 + _glp_mat_adat_symbolic
 372.638 + _glp_mat_amd_order1
 372.639 + _glp_mat_check_fvs
 372.640 + _glp_mat_check_pattern
 372.641 + _glp_mat_chol_numeric
 372.642 + _glp_mat_chol_symbolic
 372.643 + _glp_mat_min_degree
 372.644 + _glp_mat_symamd_ord
 372.645 + _glp_mat_transpose
 372.646 + _glp_mat_u_solve
 372.647 + _glp_mat_ut_solve
 372.648 +;; from glpmpl01 ;;
 372.649 + _glp_mpl_append_block
 372.650 + _glp_mpl_append_char
 372.651 + _glp_mpl_append_slot
 372.652 + _glp_mpl_arg_list_len
 372.653 + _glp_mpl_branched_expression
 372.654 + _glp_mpl_check_statement
 372.655 + _glp_mpl_close_scope
 372.656 + _glp_mpl_constraint_statement
 372.657 + _glp_mpl_create_arg_list
 372.658 + _glp_mpl_create_block
 372.659 + _glp_mpl_create_domain
 372.660 + _glp_mpl_display_statement
 372.661 + _glp_mpl_domain_arity
 372.662 + _glp_mpl_elemset_argument
 372.663 + _glp_mpl_end_statement
 372.664 + _glp_mpl_enter_context
 372.665 + _glp_mpl_error_dimension
 372.666 + _glp_mpl_error_following
 372.667 + _glp_mpl_error_preceding
 372.668 + _glp_mpl_expand_arg_list
 372.669 + _glp_mpl_expression_0
 372.670 + _glp_mpl_expression_1
 372.671 + _glp_mpl_expression_10
 372.672 + _glp_mpl_expression_11
 372.673 + _glp_mpl_expression_12
 372.674 + _glp_mpl_expression_13
 372.675 + _glp_mpl_expression_2
 372.676 + _glp_mpl_expression_3
 372.677 + _glp_mpl_expression_4
 372.678 + _glp_mpl_expression_5
 372.679 + _glp_mpl_expression_6
 372.680 + _glp_mpl_expression_7
 372.681 + _glp_mpl_expression_8
 372.682 + _glp_mpl_expression_9
 372.683 + _glp_mpl_expression_list
 372.684 + _glp_mpl_for_statement
 372.685 + _glp_mpl_function_reference
 372.686 + _glp_mpl_get_char
 372.687 + _glp_mpl_get_token
 372.688 + _glp_mpl_indexing_expression
 372.689 + _glp_mpl_is_keyword
 372.690 + _glp_mpl_is_reserved
 372.691 + _glp_mpl_iterated_expression
 372.692 + _glp_mpl_literal_set
 372.693 + _glp_mpl_make_binary
 372.694 + _glp_mpl_make_code
 372.695 + _glp_mpl_make_ternary
 372.696 + _glp_mpl_make_unary
 372.697 + _glp_mpl_model_section
 372.698 + _glp_mpl_numeric_argument
 372.699 + _glp_mpl_numeric_literal
 372.700 + _glp_mpl_object_reference
 372.701 + _glp_mpl_objective_statement
 372.702 + _glp_mpl_parameter_statement
 372.703 + _glp_mpl_primary_expression
 372.704 + _glp_mpl_print_context
 372.705 + _glp_mpl_printf_statement
 372.706 + _glp_mpl_set_expression
 372.707 + _glp_mpl_set_statement
 372.708 + _glp_mpl_simple_statement
 372.709 + _glp_mpl_solve_statement
 372.710 + _glp_mpl_string_literal
 372.711 + _glp_mpl_subscript_list
 372.712 + _glp_mpl_symbolic_argument
 372.713 + _glp_mpl_table_statement
 372.714 + _glp_mpl_unget_token
 372.715 + _glp_mpl_variable_statement
 372.716 +;; from glpmpl02 ;;
 372.717 + _glp_mpl_create_slice
 372.718 + _glp_mpl_data_section
 372.719 + _glp_mpl_delete_slice
 372.720 + _glp_mpl_expand_slice
 372.721 + _glp_mpl_fake_slice
 372.722 + _glp_mpl_is_literal
 372.723 + _glp_mpl_is_number
 372.724 + _glp_mpl_is_symbol
 372.725 + _glp_mpl_matrix_format
 372.726 + _glp_mpl_parameter_data
 372.727 + _glp_mpl_plain_format
 372.728 + _glp_mpl_read_number
 372.729 + _glp_mpl_read_slice
 372.730 + _glp_mpl_read_symbol
 372.731 + _glp_mpl_read_value
 372.732 + _glp_mpl_select_parameter
 372.733 + _glp_mpl_select_set
 372.734 + _glp_mpl_set_data
 372.735 + _glp_mpl_set_default
 372.736 + _glp_mpl_simple_format
 372.737 + _glp_mpl_slice_arity
 372.738 + _glp_mpl_slice_dimen
 372.739 + _glp_mpl_tabbing_format
 372.740 + _glp_mpl_tabular_format
 372.741 +;; from glpmpl03 ;;
 372.742 + _glp_mpl_add_member
 372.743 + _glp_mpl_add_tuple
 372.744 + _glp_mpl_arelset_member
 372.745 + _glp_mpl_arelset_size
 372.746 + _glp_mpl_assign_dummy_index
 372.747 + _glp_mpl_build_subtuple
 372.748 + _glp_mpl_check_elem_set
 372.749 + _glp_mpl_check_then_add
 372.750 + _glp_mpl_check_value_num
 372.751 + _glp_mpl_check_value_sym
 372.752 + _glp_mpl_clean_check
 372.753 + _glp_mpl_clean_code
 372.754 + _glp_mpl_clean_constraint
 372.755 + _glp_mpl_clean_display
 372.756 + _glp_mpl_clean_domain
 372.757 + _glp_mpl_clean_for
 372.758 + _glp_mpl_clean_parameter
 372.759 + _glp_mpl_clean_printf
 372.760 + _glp_mpl_clean_set
 372.761 + _glp_mpl_clean_statement
 372.762 + _glp_mpl_clean_table
 372.763 + _glp_mpl_clean_variable
 372.764 + _glp_mpl_compare_strings
 372.765 + _glp_mpl_compare_symbols
 372.766 + _glp_mpl_compare_tuples
 372.767 + _glp_mpl_concat_symbols
 372.768 + _glp_mpl_constant_term
 372.769 + _glp_mpl_copy_elemset
 372.770 + _glp_mpl_copy_formula
 372.771 + _glp_mpl_copy_string
 372.772 + _glp_mpl_copy_symbol
 372.773 + _glp_mpl_copy_tuple
 372.774 + _glp_mpl_create_arelset
 372.775 + _glp_mpl_create_array
 372.776 + _glp_mpl_create_elemset
 372.777 + _glp_mpl_create_string
 372.778 + _glp_mpl_create_symbol_num
 372.779 + _glp_mpl_create_symbol_str
 372.780 + _glp_mpl_create_tuple
 372.781 + _glp_mpl_delete_array
 372.782 + _glp_mpl_delete_elemset
 372.783 + _glp_mpl_delete_formula
 372.784 + _glp_mpl_delete_string
 372.785 + _glp_mpl_delete_symbol
 372.786 + _glp_mpl_delete_tuple
 372.787 + _glp_mpl_delete_value
 372.788 + _glp_mpl_enter_domain_block
 372.789 + _glp_mpl_eval_elemset
 372.790 + _glp_mpl_eval_formula
 372.791 + _glp_mpl_eval_logical
 372.792 + _glp_mpl_eval_member_con
 372.793 + _glp_mpl_eval_member_num
 372.794 + _glp_mpl_eval_member_set
 372.795 + _glp_mpl_eval_member_sym
 372.796 + _glp_mpl_eval_member_var
 372.797 + _glp_mpl_eval_numeric
 372.798 + _glp_mpl_eval_symbolic
 372.799 + _glp_mpl_eval_tuple
 372.800 + _glp_mpl_eval_whole_con
 372.801 + _glp_mpl_eval_whole_par
 372.802 + _glp_mpl_eval_whole_set
 372.803 + _glp_mpl_eval_whole_var
 372.804 + _glp_mpl_eval_within_domain
 372.805 + _glp_mpl_execute_check
 372.806 + _glp_mpl_execute_display
 372.807 + _glp_mpl_execute_for
 372.808 + _glp_mpl_execute_printf
 372.809 + _glp_mpl_execute_statement
 372.810 + _glp_mpl_execute_table
 372.811 + _glp_mpl_expand_tuple
 372.812 + _glp_mpl_fetch_string
 372.813 + _glp_mpl_find_member
 372.814 + _glp_mpl_find_tuple
 372.815 + _glp_mpl_format_symbol
 372.816 + _glp_mpl_format_tuple
 372.817 + _glp_mpl_fp_add
 372.818 + _glp_mpl_fp_atan
 372.819 + _glp_mpl_fp_atan2
 372.820 + _glp_mpl_fp_cos
 372.821 + _glp_mpl_fp_div
 372.822 + _glp_mpl_fp_exp
 372.823 + _glp_mpl_fp_idiv
 372.824 + _glp_mpl_fp_irand224
 372.825 + _glp_mpl_fp_less
 372.826 + _glp_mpl_fp_log
 372.827 + _glp_mpl_fp_log10
 372.828 + _glp_mpl_fp_mod
 372.829 + _glp_mpl_fp_mul
 372.830 + _glp_mpl_fp_normal
 372.831 + _glp_mpl_fp_normal01
 372.832 + _glp_mpl_fp_power
 372.833 + _glp_mpl_fp_round
 372.834 + _glp_mpl_fp_sin
 372.835 + _glp_mpl_fp_sqrt
 372.836 + _glp_mpl_fp_sub
 372.837 + _glp_mpl_fp_trunc
 372.838 + _glp_mpl_fp_uniform01
 372.839 + _glp_mpl_free_dca
 372.840 + _glp_mpl_get_domain_tuple
 372.841 + _glp_mpl_is_member
 372.842 + _glp_mpl_linear_comb
 372.843 + _glp_mpl_loop_within_domain
 372.844 + _glp_mpl_out_of_domain
 372.845 + _glp_mpl_reduce_terms
 372.846 + _glp_mpl_remove_constant
 372.847 + _glp_mpl_set_cross
 372.848 + _glp_mpl_set_diff
 372.849 + _glp_mpl_set_inter
 372.850 + _glp_mpl_set_symdiff
 372.851 + _glp_mpl_set_union
 372.852 + _glp_mpl_single_variable
 372.853 + _glp_mpl_tab_get_arg
 372.854 + _glp_mpl_tab_get_name
 372.855 + _glp_mpl_tab_get_num
 372.856 + _glp_mpl_tab_get_str
 372.857 + _glp_mpl_tab_get_type
 372.858 + _glp_mpl_tab_num_args
 372.859 + _glp_mpl_tab_num_flds
 372.860 + _glp_mpl_tab_set_num
 372.861 + _glp_mpl_tab_set_str
 372.862 + _glp_mpl_take_member_con
 372.863 + _glp_mpl_take_member_num
 372.864 + _glp_mpl_take_member_set
 372.865 + _glp_mpl_take_member_sym
 372.866 + _glp_mpl_take_member_var
 372.867 + _glp_mpl_tuple_dimen
 372.868 + _glp_mpl_uniform
 372.869 + _glp_mpl_update_dummy_indices
 372.870 +;; from glpmpl04 ;;
 372.871 + _glp_mpl_alloc_content
 372.872 + _glp_mpl_build_problem
 372.873 + _glp_mpl_clean_model
 372.874 + _glp_mpl_close_input
 372.875 + _glp_mpl_error
 372.876 + _glp_mpl_flush_output
 372.877 + _glp_mpl_generate
 372.878 + _glp_mpl_generate_model
 372.879 + _glp_mpl_get_col_bnds
 372.880 + _glp_mpl_get_col_kind
 372.881 + _glp_mpl_get_col_name
 372.882 + _glp_mpl_get_mat_row
 372.883 + _glp_mpl_get_num_cols
 372.884 + _glp_mpl_get_num_rows
 372.885 + _glp_mpl_get_prob_name
 372.886 + _glp_mpl_get_row_bnds
 372.887 + _glp_mpl_get_row_c0
 372.888 + _glp_mpl_get_row_kind
 372.889 + _glp_mpl_get_row_name
 372.890 + _glp_mpl_has_solve_stmt
 372.891 + _glp_mpl_initialize
 372.892 + _glp_mpl_open_input
 372.893 + _glp_mpl_open_output
 372.894 + _glp_mpl_postsolve
 372.895 + _glp_mpl_postsolve_model
 372.896 + _glp_mpl_put_col_soln
 372.897 + _glp_mpl_put_row_soln
 372.898 + _glp_mpl_read_char
 372.899 + _glp_mpl_read_data
 372.900 + _glp_mpl_read_model
 372.901 + _glp_mpl_terminate
 372.902 + _glp_mpl_warning
 372.903 + _glp_mpl_write_char
 372.904 + _glp_mpl_write_text
 372.905 +;; from glpmpl05 ;;
 372.906 + _glp_mpl_fn_gmtime
 372.907 + _glp_mpl_fn_str2time
 372.908 + _glp_mpl_fn_time2str
 372.909 +;; from glpmpl06 ;;
 372.910 + _glp_mpl_tab_drv_close
 372.911 + _glp_mpl_tab_drv_open
 372.912 + _glp_mpl_tab_drv_read
 372.913 + _glp_mpl_tab_drv_write
 372.914 +;; from glpmps ;;
 372.915 + glp_init_mpscp
 372.916 + glp_read_mps
 372.917 + glp_write_mps
 372.918 +;; from glpnet01 ;;
 372.919 + _glp_mc21a
 372.920 +;; from glpnet02 ;;
 372.921 + _glp_mc13d
 372.922 +;; from glpnet03 ;;
 372.923 + glp_netgen
 372.924 +;; from glpnet04 ;;
 372.925 + glp_gridgen
 372.926 +;; from glpnet05 ;;
 372.927 + glp_rmfgen
 372.928 +;; from glpnet06 ;;
 372.929 + _glp_okalg
 372.930 +;; from glpnet07 ;;
 372.931 + _glp_ffalg
 372.932 +;; from glpnet08 ;;
 372.933 + _glp_wclique
 372.934 +;; from glpnet09 ;;
 372.935 + _glp_kellerman
 372.936 +;; from glpnpp01 ;;
 372.937 + _glp_npp_activate_col
 372.938 + _glp_npp_activate_row
 372.939 + _glp_npp_add_aij
 372.940 + _glp_npp_add_col
 372.941 + _glp_npp_add_row
 372.942 + _glp_npp_build_prob
 372.943 + _glp_npp_col_nnz
 372.944 + _glp_npp_create_wksp
 372.945 + _glp_npp_deactivate_col
 372.946 + _glp_npp_deactivate_row
 372.947 + _glp_npp_del_aij
 372.948 + _glp_npp_del_col
 372.949 + _glp_npp_del_row
 372.950 + _glp_npp_delete_wksp
 372.951 + _glp_npp_erase_row
 372.952 + _glp_npp_insert_col
 372.953 + _glp_npp_insert_row
 372.954 + _glp_npp_load_prob
 372.955 + _glp_npp_postprocess
 372.956 + _glp_npp_push_tse
 372.957 + _glp_npp_remove_col
 372.958 + _glp_npp_remove_row
 372.959 + _glp_npp_row_nnz
 372.960 + _glp_npp_unload_sol
 372.961 +;; from glpnpp02 ;;
 372.962 + _glp_npp_dbnd_col
 372.963 + _glp_npp_fixed_col
 372.964 + _glp_npp_free_col
 372.965 + _glp_npp_free_row
 372.966 + _glp_npp_geq_row
 372.967 + _glp_npp_lbnd_col
 372.968 + _glp_npp_leq_row
 372.969 + _glp_npp_make_equality
 372.970 + _glp_npp_make_fixed
 372.971 + _glp_npp_ubnd_col
 372.972 +;; from glpnpp03 ;;
 372.973 + _glp_npp_analyze_row
 372.974 + _glp_npp_empty_col
 372.975 + _glp_npp_empty_row
 372.976 + _glp_npp_eq_doublet
 372.977 + _glp_npp_eq_singlet
 372.978 + _glp_npp_forcing_row
 372.979 + _glp_npp_implied_bounds
 372.980 + _glp_npp_implied_free
 372.981 + _glp_npp_implied_lower
 372.982 + _glp_npp_implied_slack
 372.983 + _glp_npp_implied_upper
 372.984 + _glp_npp_implied_value
 372.985 + _glp_npp_inactive_bound
 372.986 + _glp_npp_ineq_singlet
 372.987 +;; from glpnpp04 ;;
 372.988 + _glp_npp_binarize_prob
 372.989 + _glp_npp_hidden_covering
 372.990 + _glp_npp_hidden_packing
 372.991 + _glp_npp_implied_packing
 372.992 + _glp_npp_is_covering
 372.993 + _glp_npp_is_packing
 372.994 + _glp_npp_is_partitioning
 372.995 + _glp_npp_reduce_ineq_coef
 372.996 +;; from glpnpp05 ;;
 372.997 + _glp_npp_clean_prob
 372.998 + _glp_npp_improve_bounds
 372.999 + _glp_npp_integer
372.1000 + _glp_npp_process_col
372.1001 + _glp_npp_process_prob
372.1002 + _glp_npp_process_row
372.1003 + _glp_npp_simplex
372.1004 +;; from glpnpp06 ;;
372.1005 + _glp_npp_sat_encode_clause
372.1006 + _glp_npp_sat_encode_geq
372.1007 + _glp_npp_sat_encode_leq
372.1008 + _glp_npp_sat_encode_pack
372.1009 + _glp_npp_sat_encode_prob
372.1010 + _glp_npp_sat_encode_row
372.1011 + _glp_npp_sat_encode_sum2
372.1012 + _glp_npp_sat_encode_sum3
372.1013 + _glp_npp_sat_encode_sum_ax
372.1014 + _glp_npp_sat_fixed_col
372.1015 + _glp_npp_sat_free_row
372.1016 + _glp_npp_sat_is_bin_comb
372.1017 + _glp_npp_sat_is_cover_ineq
372.1018 + _glp_npp_sat_is_pack_ineq
372.1019 + _glp_npp_sat_is_partn_eq
372.1020 + _glp_npp_sat_normalize_clause
372.1021 + _glp_npp_sat_num_neg_coef
372.1022 + _glp_npp_sat_num_pos_coef
372.1023 + _glp_npp_sat_reverse_row
372.1024 + _glp_npp_sat_split_pack
372.1025 +;; from glpqmd ;;
372.1026 + _glp_qmd_genqmd
372.1027 + _glp_qmd_qmdmrg
372.1028 + _glp_qmd_qmdqt
372.1029 + _glp_qmd_qmdrch
372.1030 + _glp_qmd_qmdupd
372.1031 +;; from glprgr ;;
372.1032 + _glp_rgr_write_bmp16
372.1033 +;; from glprng01 ;;
372.1034 + _glp_rng_create_rand
372.1035 + _glp_rng_delete_rand
372.1036 + _glp_rng_init_rand
372.1037 + _glp_rng_next_rand
372.1038 + _glp_rng_unif_rand
372.1039 +;; from glprng02 ;;
372.1040 + _glp_rng_unif_01
372.1041 + _glp_rng_uniform
372.1042 +;; from glpscf ;;
372.1043 + _glp_scf_create_it
372.1044 + _glp_scf_delete_it
372.1045 + _glp_scf_reset_it
372.1046 + _glp_scf_solve_it
372.1047 + _glp_scf_update_exp
372.1048 +;; from glpscl ;;
372.1049 + glp_scale_prob
372.1050 +;; from glpsdf ;;
372.1051 + glp_sdf_close_file
372.1052 + glp_sdf_error
372.1053 + glp_sdf_line
372.1054 + glp_sdf_open_file
372.1055 + glp_sdf_read_int
372.1056 + glp_sdf_read_item
372.1057 + glp_sdf_read_num
372.1058 + glp_sdf_read_text
372.1059 + glp_sdf_set_jump
372.1060 + glp_sdf_warning
372.1061 +;; from glpspm ;;
372.1062 + _glp_spm_add_mat
372.1063 + _glp_spm_add_num
372.1064 + _glp_spm_add_sym
372.1065 + _glp_spm_check_per
372.1066 + _glp_spm_count_nnz
372.1067 + _glp_spm_create_mat
372.1068 + _glp_spm_create_per
372.1069 + _glp_spm_delete_mat
372.1070 + _glp_spm_delete_per
372.1071 + _glp_spm_drop_zeros
372.1072 + _glp_spm_mul_mat
372.1073 + _glp_spm_mul_num
372.1074 + _glp_spm_mul_sym
372.1075 + _glp_spm_new_elem
372.1076 + _glp_spm_read_hbm
372.1077 + _glp_spm_read_mat
372.1078 + _glp_spm_show_mat
372.1079 + _glp_spm_test_mat_d
372.1080 + _glp_spm_test_mat_e
372.1081 + _glp_spm_transpose
372.1082 + _glp_spm_write_mat
372.1083 +;; from glpspx01 ;;
372.1084 + _glp_spx_primal
372.1085 +;; from glpspx02 ;;
372.1086 + _glp_spx_dual
372.1087 +;; from glpsql ;;
372.1088 + _glp_db_iodbc_close
372.1089 + _glp_db_iodbc_open
372.1090 + _glp_db_iodbc_read
372.1091 + _glp_db_iodbc_write
372.1092 + _glp_db_mysql_close
372.1093 + _glp_db_mysql_open
372.1094 + _glp_db_mysql_read
372.1095 + _glp_db_mysql_write
372.1096 +;; from glpssx01 ;;
372.1097 + _glp_ssx_change_basis
372.1098 + _glp_ssx_chuzc
372.1099 + _glp_ssx_chuzr
372.1100 + _glp_ssx_create
372.1101 + _glp_ssx_delete
372.1102 + _glp_ssx_eval_bbar
372.1103 + _glp_ssx_eval_cbar
372.1104 + _glp_ssx_eval_col
372.1105 + _glp_ssx_eval_dj
372.1106 + _glp_ssx_eval_pi
372.1107 + _glp_ssx_eval_rho
372.1108 + _glp_ssx_eval_row
372.1109 + _glp_ssx_factorize
372.1110 + _glp_ssx_get_xNj
372.1111 + _glp_ssx_update_bbar
372.1112 + _glp_ssx_update_cbar
372.1113 + _glp_ssx_update_pi
372.1114 +;; from glpssx02 ;;
372.1115 + _glp_ssx_driver
372.1116 + _glp_ssx_phase_I
372.1117 + _glp_ssx_phase_II
372.1118 +;; from glptsp ;;
372.1119 + _glp_tsp_distance
372.1120 + _glp_tsp_free_data
372.1121 + _glp_tsp_read_data
372.1122 +;; from gzclose ;;
372.1123 + _glp_zlib_gzclose
372.1124 +;; from gzlib ;;
372.1125 + _glp_zlib_gz_error
372.1126 + _glp_zlib_gzbuffer
372.1127 + _glp_zlib_gzclearerr
372.1128 + _glp_zlib_gzdopen
372.1129 + _glp_zlib_gzeof
372.1130 + _glp_zlib_gzerror
372.1131 + _glp_zlib_gzoffset
372.1132 + _glp_zlib_gzoffset64
372.1133 + _glp_zlib_gzopen
372.1134 + _glp_zlib_gzopen64
372.1135 + _glp_zlib_gzrewind
372.1136 + _glp_zlib_gzseek
372.1137 + _glp_zlib_gzseek64
372.1138 + _glp_zlib_gztell
372.1139 + _glp_zlib_gztell64
372.1140 +;; from gzread ;;
372.1141 + _glp_zlib_gzclose_r
372.1142 + _glp_zlib_gzdirect
372.1143 + _glp_zlib_gzgetc
372.1144 + _glp_zlib_gzgets
372.1145 + _glp_zlib_gzread
372.1146 + _glp_zlib_gzungetc
372.1147 +;; from gzwrite ;;
372.1148 + _glp_zlib_gzclose_w
372.1149 + _glp_zlib_gzflush
372.1150 + _glp_zlib_gzprintf
372.1151 + _glp_zlib_gzputc
372.1152 + _glp_zlib_gzputs
372.1153 + _glp_zlib_gzsetparams
372.1154 + _glp_zlib_gzwrite
372.1155 +;; from infback ;;
372.1156 + _glp_zlib_inflateBack
372.1157 + _glp_zlib_inflateBackEnd
372.1158 + _glp_zlib_inflateBackInit_
372.1159 +;; from inffast ;;
372.1160 + _glp_zlib_inflate_fast
372.1161 +;; from inflate ;;
372.1162 + _glp_zlib_inflate
372.1163 + _glp_zlib_inflateCopy
372.1164 + _glp_zlib_inflateEnd
372.1165 + _glp_zlib_inflateGetHeader
372.1166 + _glp_zlib_inflateInit2_
372.1167 + _glp_zlib_inflateInit_
372.1168 + _glp_zlib_inflateMark
372.1169 + _glp_zlib_inflatePrime
372.1170 + _glp_zlib_inflateReset
372.1171 + _glp_zlib_inflateReset2
372.1172 + _glp_zlib_inflateSetDictionary
372.1173 + _glp_zlib_inflateSync
372.1174 + _glp_zlib_inflateSyncPoint
372.1175 + _glp_zlib_inflateUndermine
372.1176 +;; from inftrees ;;
372.1177 + _glp_zlib_inflate_copyright
372.1178 + _glp_zlib_inflate_table
372.1179 +;; from minisat ;;
372.1180 + _glp_minisat_addclause
372.1181 + _glp_minisat_delete
372.1182 + _glp_minisat_nclauses
372.1183 + _glp_minisat_nconflicts
372.1184 + _glp_minisat_new
372.1185 + _glp_minisat_nvars
372.1186 + _glp_minisat_propagate
372.1187 + _glp_minisat_reducedb
372.1188 + _glp_minisat_setnvars
372.1189 + _glp_minisat_simplify
372.1190 + _glp_minisat_solve
372.1191 +;; from trees ;;
372.1192 + _glp_zlib_dist_code
372.1193 + _glp_zlib_length_code
372.1194 + _glp_zlib_tr_align
372.1195 + _glp_zlib_tr_flush_block
372.1196 + _glp_zlib_tr_init
372.1197 + _glp_zlib_tr_stored_block
372.1198 + _glp_zlib_tr_tally
372.1199 +;; from uncompr ;;
372.1200 + _glp_zlib_uncompress
372.1201 +;; from zio ;;
372.1202 + _glp_zlib_close
372.1203 + _glp_zlib_lseek
372.1204 + _glp_zlib_open
372.1205 + _glp_zlib_read
372.1206 + _glp_zlib_write
372.1207 +;; from zutil ;;
372.1208 + _glp_zlib_zError
372.1209 + _glp_zlib_z_errmsg
372.1210 + _glp_zlib_zcalloc
372.1211 + _glp_zlib_zcfree
372.1212 + _glp_zlib_zlibCompileFlags
372.1213 + _glp_zlib_zlibVersion
   373.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
   373.2 +++ b/deps/glpk/w64/makefile_VC	Sun Nov 06 20:59:10 2011 +0100
   373.3 @@ -0,0 +1,168 @@
   373.4 +## Build GLPK with Microsoft Visual Studio Express ##
   373.5 +
   373.6 +CFLAGS = \
   373.7 +/I. \
   373.8 +/I..\src \
   373.9 +/I..\src\amd \
  373.10 +/I..\src\colamd \
  373.11 +/I..\src\minisat \
  373.12 +/I..\src\zlib \
  373.13 +/DHAVE_CONFIG_H=1 \
  373.14 +/D_CRT_SECURE_NO_WARNINGS=1 \
  373.15 +/nologo \
  373.16 +/W3 \
  373.17 +/O2
  373.18 +
  373.19 +OBJSET = \
  373.20 +..\src\glpapi01.obj \
  373.21 +..\src\glpapi02.obj \
  373.22 +..\src\glpapi03.obj \
  373.23 +..\src\glpapi04.obj \
  373.24 +..\src\glpapi05.obj \
  373.25 +..\src\glpapi06.obj \
  373.26 +..\src\glpapi07.obj \
  373.27 +..\src\glpapi08.obj \
  373.28 +..\src\glpapi09.obj \
  373.29 +..\src\glpapi10.obj \
  373.30 +..\src\glpapi11.obj \
  373.31 +..\src\glpapi12.obj \
  373.32 +..\src\glpapi13.obj \
  373.33 +..\src\glpapi14.obj \
  373.34 +..\src\glpapi15.obj \
  373.35 +..\src\glpapi16.obj \
  373.36 +..\src\glpapi17.obj \
  373.37 +..\src\glpapi18.obj \
  373.38 +..\src\glpapi19.obj \
  373.39 +..\src\glpapi20.obj \
  373.40 +..\src\glpapi21.obj \
  373.41 +..\src\glpavl.obj \
  373.42 +..\src\glpbfd.obj \
  373.43 +..\src\glpbfx.obj \
  373.44 +..\src\glpcpx.obj \
  373.45 +..\src\glpdmp.obj \
  373.46 +..\src\glpdmx.obj \
  373.47 +..\src\glpenv01.obj \
  373.48 +..\src\glpenv02.obj \
  373.49 +..\src\glpenv03.obj \
  373.50 +..\src\glpenv04.obj \
  373.51 +..\src\glpenv05.obj \
  373.52 +..\src\glpenv06.obj \
  373.53 +..\src\glpenv07.obj \
  373.54 +..\src\glpenv08.obj \
  373.55 +..\src\glpfhv.obj \
  373.56 +..\src\glpgmp.obj \
  373.57 +..\src\glphbm.obj \
  373.58 +..\src\glpini01.obj \
  373.59 +..\src\glpini02.obj \
  373.60 +..\src\glpios01.obj \
  373.61 +..\src\glpios02.obj \
  373.62 +..\src\glpios03.obj \
  373.63 +..\src\glpios04.obj \
  373.64 +..\src\glpios05.obj \
  373.65 +..\src\glpios06.obj \
  373.66 +..\src\glpios07.obj \
  373.67 +..\src\glpios08.obj \
  373.68 +..\src\glpios09.obj \
  373.69 +..\src\glpios10.obj \
  373.70 +..\src\glpios11.obj \
  373.71 +..\src\glpios12.obj \
  373.72 +..\src\glpipm.obj \
  373.73 +..\src\glplib01.obj \
  373.74 +..\src\glplib02.obj \
  373.75 +..\src\glplib03.obj \
  373.76 +..\src\glplpf.obj \
  373.77 +..\src\glplpx01.obj \
  373.78 +..\src\glplpx02.obj \
  373.79 +..\src\glplpx03.obj \
  373.80 +..\src\glpluf.obj \
  373.81 +..\src\glplux.obj \
  373.82 +..\src\glpmat.obj \
  373.83 +..\src\glpmpl01.obj \
  373.84 +..\src\glpmpl02.obj \
  373.85 +..\src\glpmpl03.obj \
  373.86 +..\src\glpmpl04.obj \
  373.87 +..\src\glpmpl05.obj \
  373.88 +..\src\glpmpl06.obj \
  373.89 +..\src\glpmps.obj \
  373.90 +..\src\glpnet01.obj \
  373.91 +..\src\glpnet02.obj \
  373.92 +..\src\glpnet03.obj \
  373.93 +..\src\glpnet04.obj \
  373.94 +..\src\glpnet05.obj \
  373.95 +..\src\glpnet06.obj \
  373.96 +..\src\glpnet07.obj \
  373.97 +..\src\glpnet08.obj \
  373.98 +..\src\glpnet09.obj \
  373.99 +..\src\glpnpp01.obj \
 373.100 +..\src\glpnpp02.obj \
 373.101 +..\src\glpnpp03.obj \
 373.102 +..\src\glpnpp04.obj \
 373.103 +..\src\glpnpp05.obj \
 373.104 +..\src\glpnpp06.obj \
 373.105 +..\src\glpqmd.obj \
 373.106 +..\src\glprgr.obj \
 373.107 +..\src\glprng01.obj \
 373.108 +..\src\glprng02.obj \
 373.109 +..\src\glpscf.obj \
 373.110 +..\src\glpscl.obj \
 373.111 +..\src\glpsdf.obj \
 373.112 +..\src\glpspm.obj \
 373.113 +..\src\glpspx01.obj \
 373.114 +..\src\glpspx02.obj \
 373.115 +..\src\glpsql.obj \
 373.116 +..\src\glpssx01.obj \
 373.117 +..\src\glpssx02.obj \
 373.118 +..\src\glptsp.obj \
 373.119 +..\src\amd\amd_1.obj \
 373.120 +..\src\amd\amd_2.obj \
 373.121 +..\src\amd\amd_aat.obj \
 373.122 +..\src\amd\amd_control.obj \
 373.123 +..\src\amd\amd_defaults.obj \
 373.124 +..\src\amd\amd_dump.obj \
 373.125 +..\src\amd\amd_info.obj \
 373.126 +..\src\amd\amd_order.obj \
 373.127 +..\src\amd\amd_post_tree.obj \
 373.128 +..\src\amd\amd_postorder.obj \
 373.129 +..\src\amd\amd_preprocess.obj \
 373.130 +..\src\amd\amd_valid.obj \
 373.131 +..\src\colamd\colamd.obj \
 373.132 +..\src\minisat\minisat.obj \
 373.133 +..\src\zlib\adler32.obj \
 373.134 +..\src\zlib\compress.obj \
 373.135 +..\src\zlib\crc32.obj \
 373.136 +..\src\zlib\deflate.obj \
 373.137 +..\src\zlib\gzclose.obj \
 373.138 +..\src\zlib\gzlib.obj \
 373.139 +..\src\zlib\gzread.obj \
 373.140 +..\src\zlib\gzwrite.obj \
 373.141 +..\src\zlib\infback.obj \
 373.142 +..\src\zlib\inffast.obj \
 373.143 +..\src\zlib\inflate.obj \
 373.144 +..\src\zlib\inftrees.obj \
 373.145 +..\src\zlib\trees.obj \
 373.146 +..\src\zlib\uncompr.obj \
 373.147 +..\src\zlib\zio.obj \
 373.148 +..\src\zlib\zutil.obj
 373.149 +
 373.150 +.c.obj:
 373.151 +        cl.exe $(CFLAGS) /Fo$*.obj /c $*.c
 373.152 +
 373.153 +all: glpk.lib glpsol.exe
 373.154 +
 373.155 +glpk.lib: $(OBJSET)
 373.156 +        lib.exe /out:glpk.lib \
 373.157 +                ..\src\*.obj \
 373.158 +                ..\src\amd\*.obj \
 373.159 +                ..\src\colamd\*.obj \
 373.160 +                ..\src\minisat\*.obj \
 373.161 +                ..\src\zlib\*.obj
 373.162 +
 373.163 +glpsol.exe: ..\examples\glpsol.obj glpk.lib
 373.164 +        cl.exe $(CFLAGS) /Feglpsol.exe \
 373.165 +                ..\examples\glpsol.obj glpk.lib
 373.166 +
 373.167 +check: glpsol.exe
 373.168 +        .\glpsol.exe --version
 373.169 +        .\glpsol.exe --mps ..\examples\plan.mps
 373.170 +
 373.171 +## eof ##
   374.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
   374.2 +++ b/deps/glpk/w64/makefile_VC_DLL	Sun Nov 06 20:59:10 2011 +0100
   374.3 @@ -0,0 +1,169 @@
   374.4 +## Build GLPK DLL with Microsoft Visual Studio Express ##
   374.5 +
   374.6 +CFLAGS = \
   374.7 +/I. \
   374.8 +/I..\src \
   374.9 +/I..\src\amd \
  374.10 +/I..\src\colamd \
  374.11 +/I..\src\minisat \
  374.12 +/I..\src\zlib \
  374.13 +/DHAVE_CONFIG_H=1 \
  374.14 +/D_CRT_SECURE_NO_WARNINGS=1 \
  374.15 +/nologo \
  374.16 +/W3 \
  374.17 +/O2
  374.18 +
  374.19 +OBJSET = \
  374.20 +..\src\glpapi01.obj \
  374.21 +..\src\glpapi02.obj \
  374.22 +..\src\glpapi03.obj \
  374.23 +..\src\glpapi04.obj \
  374.24 +..\src\glpapi05.obj \
  374.25 +..\src\glpapi06.obj \
  374.26 +..\src\glpapi07.obj \
  374.27 +..\src\glpapi08.obj \
  374.28 +..\src\glpapi09.obj \
  374.29 +..\src\glpapi10.obj \
  374.30 +..\src\glpapi11.obj \
  374.31 +..\src\glpapi12.obj \
  374.32 +..\src\glpapi13.obj \
  374.33 +..\src\glpapi14.obj \
  374.34 +..\src\glpapi15.obj \
  374.35 +..\src\glpapi16.obj \
  374.36 +..\src\glpapi17.obj \
  374.37 +..\src\glpapi18.obj \
  374.38 +..\src\glpapi19.obj \
  374.39 +..\src\glpapi20.obj \
  374.40 +..\src\glpapi21.obj \
  374.41 +..\src\glpavl.obj \
  374.42 +..\src\glpbfd.obj \
  374.43 +..\src\glpbfx.obj \
  374.44 +..\src\glpcpx.obj \
  374.45 +..\src\glpdmp.obj \
  374.46 +..\src\glpdmx.obj \
  374.47 +..\src\glpenv01.obj \
  374.48 +..\src\glpenv02.obj \
  374.49 +..\src\glpenv03.obj \
  374.50 +..\src\glpenv04.obj \
  374.51 +..\src\glpenv05.obj \
  374.52 +..\src\glpenv06.obj \
  374.53 +..\src\glpenv07.obj \
  374.54 +..\src\glpenv08.obj \
  374.55 +..\src\glpfhv.obj \
  374.56 +..\src\glpgmp.obj \
  374.57 +..\src\glphbm.obj \
  374.58 +..\src\glpini01.obj \
  374.59 +..\src\glpini02.obj \
  374.60 +..\src\glpios01.obj \
  374.61 +..\src\glpios02.obj \
  374.62 +..\src\glpios03.obj \
  374.63 +..\src\glpios04.obj \
  374.64 +..\src\glpios05.obj \
  374.65 +..\src\glpios06.obj \
  374.66 +..\src\glpios07.obj \
  374.67 +..\src\glpios08.obj \
  374.68 +..\src\glpios09.obj \
  374.69 +..\src\glpios10.obj \
  374.70 +..\src\glpios11.obj \
  374.71 +..\src\glpios12.obj \
  374.72 +..\src\glpipm.obj \
  374.73 +..\src\glplib01.obj \
  374.74 +..\src\glplib02.obj \
  374.75 +..\src\glplib03.obj \
  374.76 +..\src\glplpf.obj \
  374.77 +..\src\glplpx01.obj \
  374.78 +..\src\glplpx02.obj \
  374.79 +..\src\glplpx03.obj \
  374.80 +..\src\glpluf.obj \
  374.81 +..\src\glplux.obj \
  374.82 +..\src\glpmat.obj \
  374.83 +..\src\glpmpl01.obj \
  374.84 +..\src\glpmpl02.obj \
  374.85 +..\src\glpmpl03.obj \
  374.86 +..\src\glpmpl04.obj \
  374.87 +..\src\glpmpl05.obj \
  374.88 +..\src\glpmpl06.obj \
  374.89 +..\src\glpmps.obj \
  374.90 +..\src\glpnet01.obj \
  374.91 +..\src\glpnet02.obj \
  374.92 +..\src\glpnet03.obj \
  374.93 +..\src\glpnet04.obj \
  374.94 +..\src\glpnet05.obj \
  374.95 +..\src\glpnet06.obj \
  374.96 +..\src\glpnet07.obj \
  374.97 +..\src\glpnet08.obj \
  374.98 +..\src\glpnet09.obj \
  374.99 +..\src\glpnpp01.obj \
 374.100 +..\src\glpnpp02.obj \
 374.101 +..\src\glpnpp03.obj \
 374.102 +..\src\glpnpp04.obj \
 374.103 +..\src\glpnpp05.obj \
 374.104 +..\src\glpnpp06.obj \
 374.105 +..\src\glpqmd.obj \
 374.106 +..\src\glprgr.obj \
 374.107 +..\src\glprng01.obj \
 374.108 +..\src\glprng02.obj \
 374.109 +..\src\glpscf.obj \
 374.110 +..\src\glpscl.obj \
 374.111 +..\src\glpsdf.obj \
 374.112 +..\src\glpspm.obj \
 374.113 +..\src\glpspx01.obj \
 374.114 +..\src\glpspx02.obj \
 374.115 +..\src\glpsql.obj \
 374.116 +..\src\glpssx01.obj \
 374.117 +..\src\glpssx02.obj \
 374.118 +..\src\glptsp.obj \
 374.119 +..\src\amd\amd_1.obj \
 374.120 +..\src\amd\amd_2.obj \
 374.121 +..\src\amd\amd_aat.obj \
 374.122 +..\src\amd\amd_control.obj \
 374.123 +..\src\amd\amd_defaults.obj \
 374.124 +..\src\amd\amd_dump.obj \
 374.125 +..\src\amd\amd_info.obj \
 374.126 +..\src\amd\amd_order.obj \
 374.127 +..\src\amd\amd_post_tree.obj \
 374.128 +..\src\amd\amd_postorder.obj \
 374.129 +..\src\amd\amd_preprocess.obj \
 374.130 +..\src\amd\amd_valid.obj \
 374.131 +..\src\colamd\colamd.obj \
 374.132 +..\src\minisat\minisat.obj \
 374.133 +..\src\zlib\adler32.obj \
 374.134 +..\src\zlib\compress.obj \
 374.135 +..\src\zlib\crc32.obj \
 374.136 +..\src\zlib\deflate.obj \
 374.137 +..\src\zlib\gzclose.obj \
 374.138 +..\src\zlib\gzlib.obj \
 374.139 +..\src\zlib\gzread.obj \
 374.140 +..\src\zlib\gzwrite.obj \
 374.141 +..\src\zlib\infback.obj \
 374.142 +..\src\zlib\inffast.obj \
 374.143 +..\src\zlib\inflate.obj \
 374.144 +..\src\zlib\inftrees.obj \
 374.145 +..\src\zlib\trees.obj \
 374.146 +..\src\zlib\uncompr.obj \
 374.147 +..\src\zlib\zio.obj \
 374.148 +..\src\zlib\zutil.obj
 374.149 +
 374.150 +.c.obj:
 374.151 +        cl.exe $(CFLAGS) /Fo$*.obj /c $*.c
 374.152 +
 374.153 +all: glpk_4_47.dll glpsol.exe
 374.154 +
 374.155 +glpk_4_47.dll: $(OBJSET)
 374.156 +        cl.exe $(CFLAGS) /LD /Feglpk_4_47.dll \
 374.157 +                ..\src\*.obj \
 374.158 +                ..\src\amd\*.obj \
 374.159 +                ..\src\colamd\*.obj \
 374.160 +                ..\src\minisat\*.obj \
 374.161 +                ..\src\zlib\*.obj \
 374.162 +                glpk_4_47.def
 374.163 +
 374.164 +glpsol.exe: ..\examples\glpsol.obj glpk_4_47.dll
 374.165 +        cl.exe $(CFLAGS) /Feglpsol.exe \
 374.166 +                ..\examples\glpsol.obj glpk_4_47.lib
 374.167 +
 374.168 +check: glpsol.exe
 374.169 +        .\glpsol.exe --version
 374.170 +        .\glpsol.exe --mps ..\examples\plan.mps
 374.171 +
 374.172 +## eof ##
   375.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
   375.2 +++ b/deps/glpk/w64/readme.txt	Sun Nov 06 20:59:10 2011 +0100
   375.3 @@ -0,0 +1,24 @@
   375.4 +This directory contains batch files and other stuff which you can use
   375.5 +to build GLPK for 64-bit Windows with the native C/C++ compilers.
   375.6 +
   375.7 +Before running the batch file do the following:
   375.8 +
   375.9 +1. Make sure that you have installed the compiler you are going to use
  375.10 +   to build GLPK.
  375.11 +
  375.12 +2. Look into corresponding batch file (just right-click it and choose
  375.13 +   'Edit' in the popup menu; DO NOT choose 'Open'). Make sure that HOME
  375.14 +   variable specifies correct path to the compiler directory; if not,
  375.15 +   make necessary changes.
  375.16 +
  375.17 +To run the batch file just double-click it and wait a bit while the
  375.18 +Make utility does its job. The message 'OPTIMAL SOLUTION FOUND' in the
  375.19 +MS-DOS window means that all is OK. If you do not see it, something is
  375.20 +wrong.
  375.21 +
  375.22 +Once GLPK has been successfully built, there must appear two files in
  375.23 +this directory:
  375.24 +
  375.25 +glpk.lib, which is the GLPK object library, and
  375.26 +
  375.27 +glpsol.exe, which is the stand-alone GLPK LP/MIP solver.